@novu/framework 2.11.1 → 2.11.2-alpha.0

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 (85) hide show
  1. package/README.md +114 -9
  2. package/ai-sdk/package.json +4 -0
  3. package/cards/package.json +4 -0
  4. package/dist/{esm/index-D6L0Yufw.d.ts → cjs/agent.types-DdgaVUb7.d.cts} +356 -193
  5. package/dist/cjs/ai-sdk/index.cjs +1 -0
  6. package/dist/cjs/ai-sdk/index.d.cts +39 -0
  7. package/dist/cjs/cards.cjs +57 -0
  8. package/dist/cjs/cards.d.cts +2 -0
  9. package/dist/cjs/{health-check.types-D4NEyjyC.d.cts → health-check.types-CkUmYLNG.d.cts} +6 -140
  10. package/dist/cjs/index-BCp3U0UG.d.cts +189 -0
  11. package/dist/cjs/index.cjs +138 -138
  12. package/dist/cjs/index.d.cts +5 -3
  13. package/dist/cjs/internal/index.cjs +1 -1
  14. package/dist/cjs/internal/index.d.cts +96 -4
  15. package/dist/cjs/jsx-dev-runtime.cjs +1 -1
  16. package/dist/cjs/jsx-runtime.cjs +1 -1
  17. package/dist/cjs/langchain/index.cjs +1 -0
  18. package/dist/cjs/langchain/index.d.cts +105 -0
  19. package/dist/cjs/servers/express.cjs +137 -137
  20. package/dist/cjs/servers/express.d.cts +6 -4
  21. package/dist/cjs/servers/h3.cjs +136 -136
  22. package/dist/cjs/servers/h3.d.cts +6 -4
  23. package/dist/cjs/servers/lambda.cjs +137 -137
  24. package/dist/cjs/servers/lambda.d.cts +6 -5
  25. package/dist/cjs/servers/nest.cjs +136 -136
  26. package/dist/cjs/servers/nest.d.cts +21 -7
  27. package/dist/cjs/servers/next.cjs +138 -138
  28. package/dist/cjs/servers/next.d.cts +6 -4
  29. package/dist/cjs/servers/nuxt.cjs +136 -136
  30. package/dist/cjs/servers/nuxt.d.cts +6 -4
  31. package/dist/cjs/servers/remix.cjs +138 -138
  32. package/dist/cjs/servers/remix.d.cts +6 -4
  33. package/dist/cjs/servers/sveltekit.cjs +136 -136
  34. package/dist/cjs/servers/sveltekit.d.cts +6 -4
  35. package/dist/cjs/step-resolver.d.cts +3 -2
  36. package/dist/cjs/{subscriber.types-PRaHFLJu.d.cts → subscriber.types-DxMMRBIi.d.cts} +2 -78
  37. package/dist/cjs/util.types-DaFfsxgy.d.cts +78 -0
  38. package/dist/{cjs/index-BNiIiOE-.d.cts → esm/agent.types-Bu3DhlVb.d.ts} +356 -193
  39. package/dist/esm/ai-sdk/index.d.ts +39 -0
  40. package/dist/esm/ai-sdk/index.js +1 -0
  41. package/dist/esm/cards.d.ts +2 -0
  42. package/dist/esm/cards.js +1 -0
  43. package/dist/esm/{chunk-KLCBNFAF.js → chunk-3XT6S7TZ.js} +14 -14
  44. package/dist/esm/chunk-3ZWME5KT.js +0 -0
  45. package/dist/esm/chunk-C3P3ZH2I.js +36 -0
  46. package/dist/esm/chunk-FHYMHX3T.js +1 -0
  47. package/dist/esm/chunk-KLIOXJR3.js +1 -0
  48. package/dist/esm/chunk-W6DIBD4Z.js +1 -0
  49. package/dist/esm/chunk-YF62BBGH.js +98 -0
  50. package/dist/esm/{health-check.types-C-81VaBO.d.ts → health-check.types-nDCnGlmX.d.ts} +6 -140
  51. package/dist/esm/index-DEehllqa.d.ts +189 -0
  52. package/dist/esm/index.d.ts +5 -3
  53. package/dist/esm/index.js +1 -1
  54. package/dist/esm/internal/index.d.ts +96 -4
  55. package/dist/esm/internal/index.js +1 -1
  56. package/dist/esm/jsx-dev-runtime.js +1 -1
  57. package/dist/esm/jsx-runtime-7EPQR56T.js +1 -0
  58. package/dist/esm/jsx-runtime.js +1 -1
  59. package/dist/esm/langchain/index.d.ts +105 -0
  60. package/dist/esm/langchain/index.js +1 -0
  61. package/dist/esm/servers/express.d.ts +6 -4
  62. package/dist/esm/servers/express.js +1 -1
  63. package/dist/esm/servers/h3.d.ts +6 -4
  64. package/dist/esm/servers/h3.js +1 -1
  65. package/dist/esm/servers/lambda.d.ts +6 -5
  66. package/dist/esm/servers/lambda.js +1 -1
  67. package/dist/esm/servers/nest.d.ts +21 -7
  68. package/dist/esm/servers/nest.js +1 -1
  69. package/dist/esm/servers/next.d.ts +6 -4
  70. package/dist/esm/servers/next.js +1 -1
  71. package/dist/esm/servers/nuxt.d.ts +6 -4
  72. package/dist/esm/servers/nuxt.js +1 -1
  73. package/dist/esm/servers/remix.d.ts +6 -4
  74. package/dist/esm/servers/remix.js +1 -1
  75. package/dist/esm/servers/sveltekit.d.ts +6 -4
  76. package/dist/esm/servers/sveltekit.js +1 -1
  77. package/dist/esm/step-resolver.d.ts +3 -2
  78. package/dist/esm/step-resolver.js +1 -1
  79. package/dist/esm/{subscriber.types-CC7F0JO_.d.ts → subscriber.types-BbyO_Cz6.d.ts} +2 -78
  80. package/dist/esm/util.types-DaFfsxgy.d.ts +78 -0
  81. package/dist/esm/validators.js +1 -1
  82. package/package.json +55 -7
  83. package/dist/esm/chunk-52LSX2V5.js +0 -1
  84. package/dist/esm/chunk-N4PZBM53.js +0 -1
  85. package/dist/esm/chunk-ND6IQFTA.js +0 -133
@@ -1,8 +1,10 @@
1
- export { A as Agent, a as AgentAction, b as AgentActionContext, c as AgentAttachment, d as AgentBridgeRequest, e as AgentContext, f as AgentConversation, g as AgentDeliveryError, h as AgentEventEnum, i as AgentHandlers, j as AgentHistoryEntry, k as AgentMessage, l as AgentMessageAuthor, m as AgentMessageContext, n as AgentPlatformContext, o as AgentReaction, p as AgentReactionContext, q as AgentReplyPayload, r as AgentResolveContext, s as AgentSubscriber, C as Client, E as EditPayload, F as FileRef, M as MessageContent, t as MetadataSignal, N as NovuRequestHandler, R as ReplyContent, u as ReplyHandle, v as SentMessageInfo, S as ServeHandlerOptions, w as Signal, T as TriggerSignal, x as agent, y as workflow } from './index-BNiIiOE-.cjs';
2
- export { C as ClientOptions, a as CronExpression, E as ExecuteInput, S as SeverityLevelEnum, W as Workflow } from './health-check.types-D4NEyjyC.cjs';
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';
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
5
  export { AnyStepResolver, ChatStepResolver, EmailStepResolver, InAppStepResolver, PushStepResolver, SmsStepResolver, StepResolverContext, step } from './step-resolver.cjs';
5
- export { C as ContextResolved, E as EnvironmentSystemVariables, S as Subscriber, p as providerSchemas } from './subscriber.types-PRaHFLJu.cjs';
6
+ export { C as ContextResolved, E as EnvironmentSystemVariables, S as Subscriber, p as providerSchemas } from './subscriber.types-DxMMRBIi.cjs';
7
+ import './util.types-DaFfsxgy.cjs';
6
8
  import './base.schema.types-BApIn9jr.cjs';
7
9
  import 'json-schema-to-ts';
8
10
  import 'zod';
@@ -1 +1 @@
1
- "use strict";var it=Object.create;var P=Object.defineProperty;var nt=Object.getOwnPropertyDescriptor;var ot=Object.getOwnPropertyNames;var st=Object.getPrototypeOf,rt=Object.prototype.hasOwnProperty;var at=(e,n)=>{for(var i in n)P(e,i,{get:n[i],enumerable:!0})},fe=(e,n,i,s)=>{if(n&&typeof n=="object"||typeof n=="function")for(let r of ot(n))!rt.call(e,r)&&r!==i&&P(e,r,{get:()=>n[r],enumerable:!(s=nt(n,r))||s.enumerable});return e};var be=(e,n,i)=>(i=e!=null?it(st(e)):{},fe(n||!e||!e.__esModule?P(i,"default",{value:e,enumerable:!0}):i,e)),pt=e=>fe(P({},"__esModule",{value:!0}),e);var kt={};at(kt,{ActionStepEnum:()=>Re,BadRequestError:()=>u,BridgeError:()=>M,ChannelStepEnum:()=>_e,ConflictError:()=>v,CronExpression:()=>Oe,ErrorCodeEnum:()=>m,ExecutionEventControlsInvalidError:()=>j,ExecutionEventPayloadInvalidError:()=>F,ExecutionProviderOutputInvalidError:()=>J,ExecutionStateControlsInvalidError:()=>Y,ExecutionStateCorruptError:()=>L,ExecutionStateOutputInvalidError:()=>V,ExecutionStateResultInvalidError:()=>q,FILTER_VALIDATORS:()=>ct,ForbiddenError:()=>U,FrameworkError:()=>g,GetActionEnum:()=>we,HttpHeaderKeysEnum:()=>D,HttpMethodEnum:()=>E,HttpQueryKeysEnum:()=>Ae,HttpStatusEnum:()=>_,InvalidActionError:()=>z,JobStatusEnum:()=>Ke,MethodNotAllowedError:()=>B,MissingSecretKeyError:()=>X,NotFoundError:()=>x,NovuApiEndpointsEnum:()=>Se,PlatformError:()=>K,PostActionEnum:()=>Te,ProviderExecutionFailedError:()=>H,ProviderNotFoundError:()=>Q,ResourceConflictError:()=>O,ResourceEnum:()=>R,ResourceExecutionFailed:()=>A,ResourceNotFoundError:()=>b,SIGNATURE_TIMESTAMP_TOLERANCE:()=>lt,SIGNATURE_TIMESTAMP_TOLERANCE_MINUTES:()=>C,ServerError:()=>S,SeverityLevelEnum:()=>Qe,SignatureExpiredError:()=>ie,SignatureInvalidError:()=>te,SignatureMismatchError:()=>Z,SignatureNotFoundError:()=>ee,SignatureVersionInvalidError:()=>oe,SigningKeyNotFoundError:()=>ne,StepAlreadyExistsError:()=>re,StepControlCompilationFailedError:()=>W,StepExecutionFailedError:()=>ae,StepNotFoundError:()=>se,UnauthorizedError:()=>f,WorkflowAlreadyExistsError:()=>le,WorkflowChannelEnum:()=>xe,WorkflowNotFoundError:()=>pe,WorkflowPayloadInvalidError:()=>G,actionStepSchemas:()=>Ve,channelStepSchemas:()=>Xe,createLiquidEngine:()=>et,digest:()=>ce,isFrameworkError:()=>Ie,isNativeError:()=>ve,pluralize:()=>de,toSentence:()=>he,toSentenceArgsValidator:()=>me});module.exports=pt(kt);var Te=(r=>(r.TRIGGER="trigger",r.EXECUTE="execute",r.PREVIEW="preview",r.AGENT_EVENT="agent-event",r))(Te||{}),we=(s=>(s.DISCOVER="discover",s.HEALTH_CHECK="health-check",s.CODE="code",s))(we||{});var Se=(i=>(i.SYNC="/v1/bridge/sync",i.DIFF="/v1/bridge/diff",i))(Se||{}),C=5,lt=3e5;var Oe=(o=>(o.EVERY_SECOND="* * * * * *",o.EVERY_5_SECONDS="*/5 * * * * *",o.EVERY_10_SECONDS="*/10 * * * * *",o.EVERY_30_SECONDS="*/30 * * * * *",o.EVERY_MINUTE="*/1 * * * *",o.EVERY_5_MINUTES="0 */5 * * * *",o.EVERY_10_MINUTES="0 */10 * * * *",o.EVERY_30_MINUTES="0 */30 * * * *",o.EVERY_HOUR="0 0-23/1 * * *",o.EVERY_2_HOURS="0 0-23/2 * * *",o.EVERY_3_HOURS="0 0-23/3 * * *",o.EVERY_4_HOURS="0 0-23/4 * * *",o.EVERY_5_HOURS="0 0-23/5 * * *",o.EVERY_6_HOURS="0 0-23/6 * * *",o.EVERY_7_HOURS="0 0-23/7 * * *",o.EVERY_8_HOURS="0 0-23/8 * * *",o.EVERY_9_HOURS="0 0-23/9 * * *",o.EVERY_10_HOURS="0 0-23/10 * * *",o.EVERY_11_HOURS="0 0-23/11 * * *",o.EVERY_12_HOURS="0 0-23/12 * * *",o.EVERY_DAY_AT_1AM="0 01 * * *",o.EVERY_DAY_AT_2AM="0 02 * * *",o.EVERY_DAY_AT_3AM="0 03 * * *",o.EVERY_DAY_AT_4AM="0 04 * * *",o.EVERY_DAY_AT_5AM="0 05 * * *",o.EVERY_DAY_AT_6AM="0 06 * * *",o.EVERY_DAY_AT_7AM="0 07 * * *",o.EVERY_DAY_AT_8AM="0 08 * * *",o.EVERY_DAY_AT_9AM="0 09 * * *",o.EVERY_DAY_AT_10AM="0 10 * * *",o.EVERY_DAY_AT_11AM="0 11 * * *",o.EVERY_DAY_AT_NOON="0 12 * * *",o.EVERY_DAY_AT_1PM="0 13 * * *",o.EVERY_DAY_AT_2PM="0 14 * * *",o.EVERY_DAY_AT_3PM="0 15 * * *",o.EVERY_DAY_AT_4PM="0 16 * * *",o.EVERY_DAY_AT_5PM="0 17 * * *",o.EVERY_DAY_AT_6PM="0 18 * * *",o.EVERY_DAY_AT_7PM="0 19 * * *",o.EVERY_DAY_AT_8PM="0 20 * * *",o.EVERY_DAY_AT_9PM="0 21 * * *",o.EVERY_DAY_AT_10PM="0 22 * * *",o.EVERY_DAY_AT_11PM="0 23 * * *",o.EVERY_DAY_AT_MIDNIGHT="0 0 * * *",o.EVERY_WEEK="0 0 * * 0",o.EVERY_WEEKDAY="0 0 * * 1-5",o.EVERY_WEEKEND="0 0 * * 6,0",o.EVERY_1ST_DAY_OF_MONTH_AT_MIDNIGHT="0 0 1 * *",o.EVERY_1ST_DAY_OF_MONTH_AT_NOON="0 12 1 * *",o.EVERY_2ND_DAY_OF_MONTH_AT_10AM="0 10 2 * *",o.EVERY_2ND_HOUR="0 */2 * * *",o.EVERY_2ND_HOUR_FROM_1AM_THROUGH_11PM="0 1-23/2 * * *",o.EVERY_2ND_MONTH="0 0 1 */2 *",o.EVERY_QUARTER="0 0 1 */3 *",o.EVERY_6_MONTHS="0 0 1 */6 *",o.EVERY_YEAR="0 0 1 0 *",o.EVERY_30_MINUTES_BETWEEN_9AM_AND_5PM="0 */30 9-17 * * *",o.EVERY_30_MINUTES_BETWEEN_9AM_AND_6PM="0 */30 9-18 * * *",o.EVERY_30_MINUTES_BETWEEN_10AM_AND_7PM="0 */30 10-19 * * *",o.MONDAY_TO_FRIDAY_AT_1AM="0 0 01 * * 1-5",o.MONDAY_TO_FRIDAY_AT_2AM="0 0 02 * * 1-5",o.MONDAY_TO_FRIDAY_AT_3AM="0 0 03 * * 1-5",o.MONDAY_TO_FRIDAY_AT_4AM="0 0 04 * * 1-5",o.MONDAY_TO_FRIDAY_AT_5AM="0 0 05 * * 1-5",o.MONDAY_TO_FRIDAY_AT_6AM="0 0 06 * * 1-5",o.MONDAY_TO_FRIDAY_AT_7AM="0 0 07 * * 1-5",o.MONDAY_TO_FRIDAY_AT_8AM="0 0 08 * * 1-5",o.MONDAY_TO_FRIDAY_AT_9AM="0 0 09 * * 1-5",o.MONDAY_TO_FRIDAY_AT_09_30AM="0 30 09 * * 1-5",o.MONDAY_TO_FRIDAY_AT_10AM="0 0 10 * * 1-5",o.MONDAY_TO_FRIDAY_AT_11AM="0 0 11 * * 1-5",o.MONDAY_TO_FRIDAY_AT_11_30AM="0 30 11 * * 1-5",o.MONDAY_TO_FRIDAY_AT_12PM="0 0 12 * * 1-5",o.MONDAY_TO_FRIDAY_AT_1PM="0 0 13 * * 1-5",o.MONDAY_TO_FRIDAY_AT_2PM="0 0 14 * * 1-5",o.MONDAY_TO_FRIDAY_AT_3PM="0 0 15 * * 1-5",o.MONDAY_TO_FRIDAY_AT_4PM="0 0 16 * * 1-5",o.MONDAY_TO_FRIDAY_AT_5PM="0 0 17 * * 1-5",o.MONDAY_TO_FRIDAY_AT_6PM="0 0 18 * * 1-5",o.MONDAY_TO_FRIDAY_AT_7PM="0 0 19 * * 1-5",o.MONDAY_TO_FRIDAY_AT_8PM="0 0 20 * * 1-5",o.MONDAY_TO_FRIDAY_AT_9PM="0 0 21 * * 1-5",o.MONDAY_TO_FRIDAY_AT_10PM="0 0 22 * * 1-5",o.MONDAY_TO_FRIDAY_AT_11PM="0 0 23 * * 1-5",o))(Oe||{});var m=(p=>(p.BRIDGE_ERROR="BridgeError",p.EXECUTION_EVENT_CONTROL_INVALID_ERROR="ExecutionEventControlInvalidError",p.EXECUTION_EVENT_PAYLOAD_INVALID_ERROR="ExecutionEventPayloadInvalidError",p.EXECUTION_PROVIDER_OUTPUT_INVALID_ERROR="ExecutionProviderOutputInvalidError",p.EXECUTION_STATE_CONTROL_INVALID_ERROR="ExecutionStateControlInvalidError",p.EXECUTION_STATE_CORRUPT_ERROR="ExecutionStateCorruptError",p.EXECUTION_STATE_OUTPUT_INVALID_ERROR="ExecutionStateOutputInvalidError",p.EXECUTION_STATE_RESULT_INVALID_ERROR="ExecutionStateResultInvalidError",p.INVALID_ACTION_ERROR="InvalidActionError",p.METHOD_NOT_ALLOWED_ERROR="MethodNotAllowedError",p.MISSING_DEPENDENCY_ERROR="MissingDependencyError",p.MISSING_SECRET_KEY_ERROR="MissingSecretKeyError",p.PROVIDER_EXECUTION_FAILED_ERROR="ProviderExecutionFailedError",p.PROVIDER_NOT_FOUND_ERROR="ProviderNotFoundError",p.SIGNATURE_EXPIRED_ERROR="SignatureExpiredError",p.SIGNATURE_INVALID_ERROR="SignatureInvalidError",p.SIGNATURE_MISMATCH_ERROR="SignatureMismatchError",p.SIGNATURE_NOT_FOUND_ERROR="SignatureNotFoundError",p.SIGNATURE_VERSION_INVALID_ERROR="SignatureVersionInvalidError",p.SIGNING_KEY_NOT_FOUND_ERROR="SigningKeyNotFoundError",p.STEP_ALREADY_EXISTS_ERROR="StepAlreadyExistsError",p.STEP_CONTROL_COMPILATION_FAILED_ERROR="StepControlCompilationFailedError",p.STEP_EXECUTION_FAILED_ERROR="StepExecutionFailedError",p.STEP_NOT_FOUND_ERROR="StepNotFoundError",p.WORKFLOW_ALREADY_EXISTS_ERROR="WorkflowAlreadyExistsError",p.WORKFLOW_NOT_FOUND_ERROR="WorkflowNotFoundError",p.WORKFLOW_PAYLOAD_INVALID_ERROR="WorkflowPayloadInvalidError",p))(m||{});var D=(c=>(c.NOVU_SIGNATURE="novu-signature",c.NOVU_ANONYMOUS="novu-anonymous",c.NOVU_FRAMEWORK_SDK="novu-framework-sdk",c.NOVU_FRAMEWORK_SERVER="novu-framework-server",c.NOVU_FRAMEWORK_VERSION="novu-framework-version",c.USER_AGENT="user-agent",c.CONTENT_TYPE="content-type",c.ACCESS_CONTROL_ALLOW_ORIGIN="access-control-allow-origin",c.ACCESS_CONTROL_ALLOW_METHODS="access-control-allow-methods",c.ACCESS_CONTROL_ALLOW_HEADERS="access-control-allow-headers",c.ACCESS_CONTROL_MAX_AGE="access-control-max-age",c.ACCESS_CONTROL_ALLOW_PRIVATE_NETWORK="access-control-allow-private-network",c))(D||{});var E=(s=>(s.POST="POST",s.GET="GET",s.OPTIONS="OPTIONS",s))(E||{});var Ae=(h=>(h.WORKFLOW_ID="workflowId",h.STEP_ID="stepId",h.ACTION="action",h.SOURCE="source",h.AGENT_ID="agentId",h.EVENT="event",h))(Ae||{});var _=(t=>(t[t.CONTINUE=100]="CONTINUE",t[t.SWITCHING_PROTOCOLS=101]="SWITCHING_PROTOCOLS",t[t.PROCESSING=102]="PROCESSING",t[t.EARLYHINTS=103]="EARLYHINTS",t[t.OK=200]="OK",t[t.CREATED=201]="CREATED",t[t.ACCEPTED=202]="ACCEPTED",t[t.NON_AUTHORITATIVE_INFORMATION=203]="NON_AUTHORITATIVE_INFORMATION",t[t.NO_CONTENT=204]="NO_CONTENT",t[t.RESET_CONTENT=205]="RESET_CONTENT",t[t.PARTIAL_CONTENT=206]="PARTIAL_CONTENT",t[t.AMBIGUOUS=300]="AMBIGUOUS",t[t.MOVED_PERMANENTLY=301]="MOVED_PERMANENTLY",t[t.FOUND=302]="FOUND",t[t.SEE_OTHER=303]="SEE_OTHER",t[t.NOT_MODIFIED=304]="NOT_MODIFIED",t[t.TEMPORARY_REDIRECT=307]="TEMPORARY_REDIRECT",t[t.PERMANENT_REDIRECT=308]="PERMANENT_REDIRECT",t[t.BAD_REQUEST=400]="BAD_REQUEST",t[t.UNAUTHORIZED=401]="UNAUTHORIZED",t[t.PAYMENT_REQUIRED=402]="PAYMENT_REQUIRED",t[t.FORBIDDEN=403]="FORBIDDEN",t[t.NOT_FOUND=404]="NOT_FOUND",t[t.METHOD_NOT_ALLOWED=405]="METHOD_NOT_ALLOWED",t[t.NOT_ACCEPTABLE=406]="NOT_ACCEPTABLE",t[t.PROXY_AUTHENTICATION_REQUIRED=407]="PROXY_AUTHENTICATION_REQUIRED",t[t.REQUEST_TIMEOUT=408]="REQUEST_TIMEOUT",t[t.CONFLICT=409]="CONFLICT",t[t.GONE=410]="GONE",t[t.LENGTH_REQUIRED=411]="LENGTH_REQUIRED",t[t.PRECONDITION_FAILED=412]="PRECONDITION_FAILED",t[t.PAYLOAD_TOO_LARGE=413]="PAYLOAD_TOO_LARGE",t[t.URI_TOO_LONG=414]="URI_TOO_LONG",t[t.UNSUPPORTED_MEDIA_TYPE=415]="UNSUPPORTED_MEDIA_TYPE",t[t.REQUESTED_RANGE_NOT_SATISFIABLE=416]="REQUESTED_RANGE_NOT_SATISFIABLE",t[t.EXPECTATION_FAILED=417]="EXPECTATION_FAILED",t[t.I_AM_A_TEAPOT=418]="I_AM_A_TEAPOT",t[t.MISDIRECTED=421]="MISDIRECTED",t[t.UNPROCESSABLE_ENTITY=422]="UNPROCESSABLE_ENTITY",t[t.FAILED_DEPENDENCY=424]="FAILED_DEPENDENCY",t[t.PRECONDITION_REQUIRED=428]="PRECONDITION_REQUIRED",t[t.TOO_MANY_REQUESTS=429]="TOO_MANY_REQUESTS",t[t.INTERNAL_SERVER_ERROR=500]="INTERNAL_SERVER_ERROR",t[t.NOT_IMPLEMENTED=501]="NOT_IMPLEMENTED",t[t.BAD_GATEWAY=502]="BAD_GATEWAY",t[t.SERVICE_UNAVAILABLE=503]="SERVICE_UNAVAILABLE",t[t.GATEWAY_TIMEOUT=504]="GATEWAY_TIMEOUT",t[t.HTTP_VERSION_NOT_SUPPORTED=505]="HTTP_VERSION_NOT_SUPPORTED",t))(_||{});var R=(s=>(s.WORKFLOW="workflow",s.PROVIDER="provider",s.STEP="step",s))(R||{});var _e=(a=>(a.EMAIL="email",a.SMS="sms",a.PUSH="push",a.CHAT="chat",a.IN_APP="in_app",a))(_e||{}),Re=(a=>(a.DIGEST="digest",a.DELAY="delay",a.THROTTLE="throttle",a.CUSTOM="custom",a.HTTP_REQUEST="http_request",a))(Re||{});var xe=(a=>(a.EMAIL="email",a.SMS="sms",a.PUSH="push",a.CHAT="chat",a.IN_APP="inApp",a))(xe||{});var ve=e=>{var i,s;if(typeof e!="object"||e===null)return!1;let n=Object.getPrototypeOf(e);return(s=(i=n==null?void 0:n.constructor)==null?void 0:i.name.endsWith("Error"))!=null?s:!1},g=class extends Error{},x=class extends g{constructor(){super(...arguments);this.statusCode=404}},u=class extends g{constructor(){super(...arguments);this.statusCode=400}},f=class extends g{constructor(){super(...arguments);this.statusCode=401}},S=class extends g{constructor(n,{cause:i}={}){var s;ve(i)?(super(`${n}: ${i.message}`),this.data={stack:(s=i.stack)!=null?s:n}):(super(`${n}${i?`: ${JSON.stringify(i,null,2)}`:""}`),this.data={stack:n})}},v=class extends g{constructor(){super(...arguments);this.statusCode=409}},U=class extends g{constructor(){super(...arguments);this.statusCode=403}};var M=class extends S{constructor(i){super("Unknown BridgeError",{cause:i});this.statusCode=500;this.code="BridgeError"}};var L=class extends u{constructor(i,s){super(`Workflow with id: \`${i}\` has a corrupt state. Step with id: \`${s}\` does not exist. Please provide the missing state.`);this.code="ExecutionStateCorruptError";this.data={workflowId:i,stepId:s}}},F=class extends u{constructor(i,s){super(`Workflow with id: \`${i}\` has invalid \`payload\`. Please provide the correct event payload.`);this.code="ExecutionEventPayloadInvalidError";this.data=s}},j=class extends u{constructor(i,s){super(`Workflow with id: \`${i}\` has invalid \`controls\`. Please provide the correct event controls.`);this.code="ExecutionEventControlInvalidError";this.data=s}},Y=class extends u{constructor(i,s,r){super(`Workflow with id: \`${i}\` has an invalid state. Step with id: \`${s}\` has invalid \`controls\`. Please provide the correct step controls.`);this.code="ExecutionStateControlInvalidError";this.data=r}},V=class extends u{constructor(i,s,r){super(`Workflow with id: \`${i}\` has an invalid state. Step with id: \`${s}\` has invalid output. Please provide the correct step output.`);this.code="ExecutionStateOutputInvalidError";this.data=r}},q=class extends u{constructor(i,s,r){super(`Workflow with id: \`${i}\` has an invalid state. Step with id: \`${s}\` has invalid result. Please provide the correct step result.`);this.code="ExecutionStateResultInvalidError";this.data=r}},W=class extends u{constructor(i,s,r){super(`Workflow with id: \`${i}\` has invalid controls syntax in step with id: \`${s}\`. Please correct step control syntax.`);this.code="StepControlCompilationFailedError";this.data=r}},J=class extends u{constructor(i,s,r,a){super(`Workflow with id: \`${i}\` has an invalid state. Step with id: \`${s}\` and provider with id: \`${r}\` has invalid output. Please provide the correct provider output.`);this.code="ExecutionProviderOutputInvalidError";this.data=a}},G=class extends u{constructor(i,s){super(`Workflow with id: \`${i}\` has invalid \`payload\`. Please provide the correct payload.`);this.code="WorkflowPayloadInvalidError";this.data=s}};var Ie=e=>Object.values(m).includes(e==null?void 0:e.code);var $=e=>Object.values(e).map(n=>`\`${n}\``).join(", "),N=e=>e.replaceAll(/(\w)(\w*)/g,(n,i,s)=>i.toUpperCase()+s.toLowerCase()).replaceAll(/[\s-]+/g,"");var B=class extends g{constructor(){super(...arguments);this.code="MethodNotAllowedError";this.statusCode=405;this.message=`Method not allowed. Please use one of ${$(E)}`}},z=class extends u{constructor(i,s){super(`Invalid query string: \`action\`=\`${i}\`. Please use one of ${$(s)}`);this.code="InvalidActionError"}},X=class extends u{constructor(){super("Missing secret key. Set the `NOVU_SECRET_KEY` environment variable or pass `secretKey` to the client options.");this.code="MissingSecretKeyError"}};var K=class extends Error{constructor(n,i,s){super(),this.data={message:s},this.statusCode=n,this.code=i}};var O=class extends v{constructor(n,i){super(`${N(n)} with id: \`${i}\` already exists. Please use a different id.`)}},b=class extends x{constructor(n,i){super(`${N(n)} with id: \`${i}\` does not exist. Please provide a valid id.`)}},A=class extends S{constructor(i,s,r,a){super(`Failed to ${r} ${N(i)} with id: \`${s}\``,{cause:a});this.statusCode=502}};var Q=class extends b{constructor(i){super("provider",i);this.code="ProviderNotFoundError"}},H=class extends A{constructor(i,s,r){super("provider",i,s,r);this.code="ProviderExecutionFailedError"}};var Z=class extends f{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"}},ee=class extends f{constructor(){super("Signature not found. Please provide a signature in the `novu-signature` header");this.code="SignatureNotFoundError"}},te=class extends f{constructor(){super("Signature is invalid. Please provide a valid signature in the `novu-signature` header");this.code="SignatureInvalidError"}},ie=class extends f{constructor(){super(`Signature expired. Please provide a signature with a timestamp no older than ${5} minutes in the \`novu-signature\` header`);this.code="SignatureExpiredError"}},ne=class extends f{constructor(){super("Signature key not found. Please provide a valid key in the Client constructor `config.secretKey`");this.code="SigningKeyNotFoundError"}},oe=class extends f{constructor(){super("Signature version is invalid. Please provide a signature version with version `v1` in the `novu-signature` header");this.code="SignatureVersionInvalidError"}};var se=class extends b{constructor(i){super("step",i);this.code="StepNotFoundError"}},re=class extends O{constructor(i){super("step",i);this.code="StepAlreadyExistsError"}},ae=class extends A{constructor(i,s,r){super("step",i,s,r);this.code="StepExecutionFailedError"}};var pe=class extends b{constructor(i){super("workflow",i);this.code="WorkflowNotFoundError"}},le=class extends O{constructor(i){super("workflow",i);this.code="WorkflowAlreadyExistsError"}};function k(e,n){let i=n.split(".").reduce((s,r)=>{if(s&&typeof s=="object")return s[r]},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 s=JSON.stringify(i);return s==="{}"?"":s}return""}function ce(e,n=2,i,s=", "){if(!Array.isArray(e)||e.length===0)return"";let r=i?e.map(l=>typeof l!="object"||!l?"":k(l,i)):e;if(r.length===1)return r[0];if(r.length===2)return`${r[0]} and ${r[1]}`;if(r.length===3&&n>=3)return`${r[0]}, ${s}${r[1]} and ${r[2]}`;let a=r.slice(0,n),h=r.length-n;return`${a.join(s)} and ${h} ${h===1?"other":"others"}`}var Pe=be(require("pluralize"),1);function de(e,n="",i="",s="true"){if(e==null)return"";let r=0;if(Array.isArray(e)?r=e.length:typeof e=="object"?r=Object.keys(e).length:typeof e=="string"?r=+e:typeof e=="number"?r=e:r=Number(e),Number.isNaN(r)&&(r=0),r<=0)return"";let a;return i?a=r===1?n:i:a=(0,Pe.default)(n,r),s==="true"?`${r} ${a}`:a}var ue=require("liquidjs"),Ne=be(require("pluralize"),1),T=require("zod");var ke="",Ce=2,De="other",Ue=", ",Me=" and ",Le=", and ",Ee={0:"keyPath",1:"limit",2:"overflowSuffix",3:"wordsConnector",4:"twoWordsConnector",5:"lastWordConnector"};function he(e,n=ke,i=Ce,s=De,r=Ue,a=Me,h=Le){if(!Array.isArray(e)||e.length===0)return"";let l=n?e.map(c=>typeof c!="object"||!c?"":k(c,n)):e,y=l.length;if(y===1)return l[0];if(y===2)return`${l[0]}${a}${l[1]}`;if(i>=y){let c=l.slice(0,y-1),ge=l[y-1];return`${c.join(r)}${h}${ge}`}let d=l.slice(0,i),w=y-i,I=i===1?a:h;return`${d.join(r)}${I}${w} ${(0,Ne.default)(s,w)}`}function me(e={},...n){let{requireKeyPath:i=!1}=e,s=[];if(n.length<1)return s.push({message:"Expected at least 1 argument",begin:0,end:0,value:""}),s;let r=T.z.object({keyPath:i?T.z.string().min(1,"must be non-empty"):T.z.string().optional().default(ke),limit:T.z.number().optional().default(Ce).refine(l=>l>=0,"must be greater than or equal to 0"),overflowSuffix:T.z.string().optional().default(De),wordsConnector:T.z.string().optional().default(Ue),twoWordsConnector:T.z.string().optional().default(Me),lastWordConnector:T.z.string().optional().default(Le)}),a={};n.forEach((l,y)=>{if(!Array.isArray(l)){let d=l.getText();(l.kind===ue.TokenKind.Quoted||l.kind===ue.TokenKind.Number)&&(d=l.content);let w=Ee[y];a[w]=d}});let h=r.safeParse(a);if(!h.success)for(let l of h.error.issues){let y="string";"type"in l&&(y=l.type);let d=l.path[0],w=Object.entries(Ee).find(([ge,tt])=>tt===d),I=w?parseInt(w[0],10):null,c=typeof I=="number"?n[I]:null;c&&!Array.isArray(c)&&s.push({message:`"toSentence" expects a ${y}${l.message?` that ${l.message}`:""} for argument "${d}"`,begin:c.begin,end:c.end,value:c.getText()})}return s}var ct={toSentence:me};var dt={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},ut={type:"object",properties:{type:{enum:["timed"]},cron:{type:"string"},extendToSchedule:{type:"boolean"}},required:["cron"],additionalProperties:!1},ht={type:"object",properties:{type:{enum:["dynamic"]},dynamicKey:{type:"string"},extendToSchedule:{type:"boolean"}},required:["dynamicKey"],additionalProperties:!1},mt={oneOf:[dt,ut,ht]},yt={type:"object",properties:{duration:{type:"number"}},required:["duration"],additionalProperties:!1},Fe={output:mt,result:yt};var gt={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},ft={type:"object",properties:{type:{enum:["timed"]},cron:{type:"string"},digestKey:{type:"string"},extendToSchedule:{type:"boolean"}},required:["cron"],additionalProperties:!1},bt={oneOf:[gt,ft]},Tt={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},je={output:bt,result:Tt};var Ye={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 Ve={delay:Fe,digest:je,throttle:Ye};var wt={type:"object",properties:{body:{type:"string"}},required:["body"],additionalProperties:!1},St={type:"object",properties:{},required:[],additionalProperties:!1},qe={output:wt,result:St};var Ot={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},At={type:"object",properties:{},required:[],additionalProperties:!1},We={output:Ot,result:At};var _t="^(?!mailto:)(?:(https?):\\/\\/[^\\s/$.?#].[^\\s]*)|^(\\/[^\\s]*)$",Ge={type:"object",properties:{url:{type:"string",pattern:_t},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},Je={type:"object",properties:{label:{type:"string"},redirect:Ge},required:["label"],additionalProperties:!1},Rt={type:"object",properties:{subject:{type:"string",minLength:1},body:{type:"string",minLength:1},avatar:{type:"string",format:"uri"},primaryAction:Je,secondaryAction:Je,data:{type:"object",additionalProperties:!0},redirect:Ge},anyOf:[{required:["subject"]},{required:["body"]}],additionalProperties:!1},xt={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},$e={output:Rt,result:xt};var vt={type:"object",properties:{subject:{type:"string"},body:{type:"string"}},required:["subject","body"],additionalProperties:!1},It={type:"object",properties:{},required:[],additionalProperties:!1},Be={output:vt,result:It};var Pt={type:"object",properties:{body:{type:"string"}},required:["body"],additionalProperties:!1},Et={type:"object",properties:{},required:[],additionalProperties:!1},ze={output:Pt,result:Et};var Xe={chat:qe,sms:ze,push:Be,email:We,in_app:$e};var Ke=(d=>(d.PENDING="pending",d.QUEUED="queued",d.RUNNING="running",d.COMPLETED="completed",d.FAILED="failed",d.DELAYED="delayed",d.CANCELED="canceled",d.MERGED="merged",d.SKIPPED="skipped",d))(Ke||{});var Qe=(r=>(r.NONE="none",r.LOW="low",r.MEDIUM="medium",r.HIGH="high",r))(Qe||{});var He=require("liquidjs");function Nt(e){return Array.isArray(e)||typeof e=="object"&&e!==null?Ze(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 Ze=(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 et(e){let n=new He.Liquid({outputEscape:Nt,...e});return n.registerFilter("json",(i,s)=>Ze(i,s)),n.registerFilter("digest",ce),n.registerFilter("toSentence",he),n.registerFilter("pluralize",de),n}0&&(module.exports={ActionStepEnum,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,channelStepSchemas,createLiquidEngine,digest,isFrameworkError,isNativeError,pluralize,toSentence,toSentenceArgsValidator});
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,9 +1,13 @@
1
- import { P as PostActionEnum } from '../health-check.types-D4NEyjyC.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-D4NEyjyC.cjs';
3
- export { i as ActionStep, A as ActionStepEnum, g as Awaitable, j as ChannelStep, f as ChannelStepEnum, k as ChatOutput, l as ChatOutputUnvalidated, m as ChatResult, c as ConditionalPartial, b as ContextPayload, C as ContextResolved, n as ContextValue, o as CustomStep, D as DeepPartial, q as DeepRequired, r as DelayDynamicOutput, s as DelayDynamicOutputUnvalidated, t as DelayOutput, u as DelayOutputUnvalidated, v as DelayRegularOutput, w as DelayRegularOutputUnvalidated, x as DelayResult, y as DelayTimedOutput, z as DelayTimedOutputUnvalidated, B as DigestOutput, F as DigestOutputUnvalidated, G as DigestRegularOutput, H as DigestRegularOutputUnvalidated, I as DigestResult, J as DigestTimedOutput, K as DigestTimedOutputUnvalidated, a as Either, L as EmailOutput, M as EmailOutputUnvalidated, N as EmailResult, E as EnvironmentSystemVariables, O as InAppOutput, Q as InAppOutputUnvalidated, R as InAppResult, T as Indexable, U as JobStatusEnum, V as PickOptional, X as PickOptionalKeys, Y as PickRequired, P as PickRequiredKeys, e as Prettify, Z as PushOutput, _ as PushOutputUnvalidated, $ as PushResult, a0 as Skip, a1 as SmsOutput, a2 as SmsOutputUnvalidated, a3 as SmsResult, d as Step, a4 as StepContext, h as StepOptions, a5 as StepOutput, S as Subscriber, a6 as ThrottleOutput, a7 as ThrottleOutputUnvalidated, a8 as ThrottleResult, a9 as actionStepSchemas, aa as channelStepSchemas } from '../subscriber.types-PRaHFLJu.cjs';
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';
4
4
  import { Filter, LiquidOptions, Liquid } from 'liquidjs';
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';
5
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';
6
9
  export { S as SupportedFrameworkName } from '../server.types-BRWsA1CA.cjs';
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';
7
11
  export { a as ValidateFunction, V as ValidateResult, b as ValidationError, c as Validator } from '../validator.types-BeoiKdnR.cjs';
8
12
  import 'json-schema-to-ts';
9
13
  import 'zod';
@@ -418,6 +422,94 @@ type FilterValidators = {
418
422
  };
419
423
  declare const FILTER_VALIDATORS: FilterValidators;
420
424
 
425
+ declare const RUNTIME_CONTEXT_BRAND: unique symbol;
426
+ interface AgentRuntimeContext extends AgentHandlerContext {
427
+ readonly [RUNTIME_CONTEXT_BRAND]: true;
428
+ emitToolResult(result: ToolResult): void;
429
+ emitToolApprovalRequest(request: ToolApprovalRequestPayload): void;
430
+ replyApprovalCard(card: ToolApprovalCard): Promise<ReplyHandle>;
431
+ asMessageContext(): AgentMessageContext;
432
+ }
433
+
434
+ interface ReplyPoster {
435
+ post(body: AgentReplyPayload): Promise<SentMessageInfo | null>;
436
+ }
437
+ declare class ReplyHandleImpl implements ReplyHandle {
438
+ private readonly conversationId;
439
+ private readonly integrationIdentifier;
440
+ private readonly poster;
441
+ messageId: string;
442
+ platformThreadId: string;
443
+ /** @internal set when the handler calls `edit()`; dispatch skips default approval card cleanup. */
444
+ editedByHandler: boolean;
445
+ constructor(messageId: string, platformThreadId: string, conversationId: string, integrationIdentifier: string, poster: ReplyPoster);
446
+ edit(content: MessageContent, options?: {
447
+ files?: FileRef[];
448
+ }): Promise<ReplyHandle>;
449
+ delete(): Promise<void>;
450
+ }
451
+ declare class AgentContextImpl implements AgentRuntimeContext {
452
+ readonly [RUNTIME_CONTEXT_BRAND] = true;
453
+ readonly event: AgentEventEnum;
454
+ readonly action: AgentAction | null;
455
+ readonly message: AgentMessage | null;
456
+ readonly reaction: AgentReaction | null;
457
+ readonly conversation: AgentConversation;
458
+ readonly subscriber: AgentSubscriber | null;
459
+ readonly history: AgentHistoryEntry[];
460
+ readonly platform: string;
461
+ readonly platformContext: AgentPlatformContext;
462
+ readonly typing: TypingControl;
463
+ readonly toolApproval: ToolApprovalControl;
464
+ readonly metadata: {
465
+ get(key: string): unknown;
466
+ set(key: string, value: unknown): void;
467
+ delete(key: string): void;
468
+ clear(): void;
469
+ readonly current: Readonly<Record<string, unknown>>;
470
+ };
471
+ private _signals;
472
+ private _toolResults;
473
+ private _pendingToolApprovalRequest;
474
+ private _pendingReactions;
475
+ private _pendingDeletes;
476
+ private _resolveSignal;
477
+ private _metadataState;
478
+ private readonly _toolApprovalConfig?;
479
+ private readonly _replyUrl;
480
+ private readonly _conversationId;
481
+ private readonly _integrationIdentifier;
482
+ private readonly _secretKey;
483
+ private readonly _poster;
484
+ constructor(request: AgentBridgeRequest, secretKey: string, toolApprovalConfig?: ToolApprovalConfig);
485
+ asMessageContext(): AgentMessageContext;
486
+ reply(content: MessageContent, options?: {
487
+ files?: FileRef[];
488
+ }): Promise<ReplyHandle>;
489
+ replyApprovalCard(card: ToolApprovalCard): Promise<ReplyHandle>;
490
+ /** @internal Build a handle to an already-posted message (used to resume an approval). */
491
+ createReplyHandle(messageId: string): ReplyHandleImpl;
492
+ resolve(summary?: string): void;
493
+ trigger(workflowId: string, opts?: {
494
+ to?: TriggerRecipientsPayload;
495
+ payload?: Record<string, unknown>;
496
+ }): void;
497
+ /** @internal Queue a gated tool call for the ledger; flushed with the next reply. */
498
+ emitToolApprovalRequest(request: ToolApprovalRequestPayload): void;
499
+ /** @internal Queue a tool-call outcome to be recorded in history; flushed with the next reply. */
500
+ emitToolResult(result: ToolResult): void;
501
+ addReaction(messageId: string, emojiName: Emoji): void;
502
+ deleteMessage(messageId: string): void;
503
+ /**
504
+ * Flush any remaining signals that weren't sent with reply().
505
+ * Called internally after onResolve returns.
506
+ */
507
+ flush(): Promise<void>;
508
+ private _hasPendingSideEffects;
509
+ private _drainSideEffects;
510
+ private _post;
511
+ }
512
+
421
513
  /**
422
514
  * Creates a configured Liquid instance with Novu's default settings.
423
515
  *
@@ -427,4 +519,4 @@ declare const FILTER_VALIDATORS: FilterValidators;
427
519
  */
428
520
  declare function createLiquidEngine(options?: LiquidOptions): Liquid;
429
521
 
430
- export { BadRequestError, BridgeError, ConflictError, ErrorCodeEnum, ExecutionEventControlsInvalidError, ExecutionEventPayloadInvalidError, ExecutionProviderOutputInvalidError, ExecutionStateControlsInvalidError, ExecutionStateCorruptError, ExecutionStateOutputInvalidError, ExecutionStateResultInvalidError, FILTER_VALIDATORS, ForbiddenError, FrameworkError, HttpHeaderKeysEnum, HttpMethodEnum, HttpQueryKeysEnum, HttpStatusEnum, InvalidActionError, type LiquidFilterIssue, MethodNotAllowedError, MissingSecretKeyError, NotFoundError, NovuApiEndpointsEnum, PlatformError, PostActionEnum, ProviderExecutionFailedError, ProviderNotFoundError, ResourceConflictError, ResourceEnum, ResourceExecutionFailed, ResourceNotFoundError, SIGNATURE_TIMESTAMP_TOLERANCE, SIGNATURE_TIMESTAMP_TOLERANCE_MINUTES, ServerError, SignatureExpiredError, SignatureInvalidError, SignatureMismatchError, SignatureNotFoundError, SignatureVersionInvalidError, SigningKeyNotFoundError, StepAlreadyExistsError, StepControlCompilationFailedError, StepExecutionFailedError, StepNotFoundError, UnauthorizedError, WorkflowAlreadyExistsError, WorkflowNotFoundError, WorkflowPayloadInvalidError, createLiquidEngine, digest, isFrameworkError, isNativeError, pluralize, toSentence, toSentenceArgsValidator };
522
+ export { AgentBridgeRequest, AgentContextImpl, AgentEventEnum, AgentReplyPayload, type AgentRuntimeContext, BadRequestError, BridgeError, ConflictError, ErrorCodeEnum, ExecutionEventControlsInvalidError, ExecutionEventPayloadInvalidError, ExecutionProviderOutputInvalidError, ExecutionStateControlsInvalidError, ExecutionStateCorruptError, ExecutionStateOutputInvalidError, ExecutionStateResultInvalidError, FILTER_VALIDATORS, ForbiddenError, FrameworkError, HttpHeaderKeysEnum, HttpMethodEnum, HttpQueryKeysEnum, HttpStatusEnum, InvalidActionError, type LiquidFilterIssue, MethodNotAllowedError, MissingSecretKeyError, NotFoundError, NovuApiEndpointsEnum, PlatformError, PostActionEnum, ProviderExecutionFailedError, ProviderNotFoundError, ResourceConflictError, ResourceEnum, ResourceExecutionFailed, ResourceNotFoundError, SIGNATURE_TIMESTAMP_TOLERANCE, SIGNATURE_TIMESTAMP_TOLERANCE_MINUTES, SentMessageInfo, ServerError, SignatureExpiredError, SignatureInvalidError, SignatureMismatchError, SignatureNotFoundError, SignatureVersionInvalidError, SigningKeyNotFoundError, StepAlreadyExistsError, StepControlCompilationFailedError, StepExecutionFailedError, StepNotFoundError, ToolApprovalRequestPayload, ToolResult, UnauthorizedError, WorkflowAlreadyExistsError, WorkflowNotFoundError, WorkflowPayloadInvalidError, createLiquidEngine, digest, isFrameworkError, isNativeError, pluralize, toSentence, toSentenceArgsValidator };
@@ -1 +1 @@
1
- "use strict";var f=Object.defineProperty;var U=Object.getOwnPropertyDescriptor;var B=Object.getOwnPropertyNames;var _=Object.prototype.hasOwnProperty;var R=(e,n)=>{for(var t in n)f(e,t,{get:n[t],enumerable:!0})},D=(e,n,t,i)=>{if(n&&typeof n=="object"||typeof n=="function")for(let r of B(n))!_.call(e,r)&&r!==t&&f(e,r,{get:()=>n[r],enumerable:!(i=U(n,r))||i.enumerable});return e};var V=e=>D(f({},"__esModule",{value:!0}),e);var le={};R(le,{Fragment:()=>s,jsx:()=>o,jsxDEV:()=>c,jsxs:()=>u});module.exports=V(le);function J(e={}){var n;return{type:"card",title:e.title,subtitle:e.subtitle,imageUrl:e.imageUrl,children:(n=e.children)!=null?n:[]}}function g(e,n={}){return{type:"text",content:e,style:n.style}}function x(e){return{type:"image",url:e.url,alt:e.alt}}function k(){return{type:"divider"}}function w(e){return{type:"section",children:e}}function T(e){return{type:"actions",children:e}}function S(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 C(e){return{type:"link-button",url:e.url,label:e.label,style:e.style}}function v(e){return{type:"field",label:e.label,value:e.value}}function L(e){return{type:"fields",children:e}}function E(e){return{type:"table",headers:e.headers,rows:e.rows,align:e.align}}function j(e){return{type:"link",url:e.url,label:e.label}}var X=["text_input","select","external_select","radio_select","text","fields"];function Q(e){let n=e.filter(t=>typeof t=="object"&&t!==null&&"type"in t&&X.includes(t.type));return n.length<e.length&&console.warn("[chat] Modal contains unsupported child elements that were ignored"),n}function M(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 $(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 A(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 O(e){return{type:"external_select",id:e.id,initialOption:e.initialOption,label:e.label,placeholder:e.placeholder,minQueryLength:e.minQueryLength,optional:e.optional}}function P(e){return{label:e.label,value:e.value,description:e.description}}function I(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}}var d=Symbol.for("chat.jsx.element");function H(e){return typeof e=="object"&&e!==null&&e.$$typeof===d}function p(e){if(e==null)return[];if(Array.isArray(e))return e.flatMap(p);if(H(e)){let n=ie(e);return n?[n]:[]}return typeof e=="object"&&"type"in e?[e]:typeof e=="string"||typeof e=="number"?[String(e)]:[]}function W(e){return!("id"in e||"url"in e||"label"in e)}function G(e){return"id"in e&&typeof e.id=="string"&&!("url"in e)}function Y(e){return"url"in e&&typeof e.url=="string"&&!("id"in e)}function N(e){return"url"in e&&typeof e.url=="string"&&!("id"in e)&&!("alt"in e)&&!("style"in e)}function z(e){return"url"in e&&typeof e.url=="string"}function K(e){return"label"in e&&"value"in e&&typeof e.label=="string"&&typeof e.value=="string"}function Z(e){return!("id"in e||"url"in e||"callbackId"in e)&&("title"in e||"subtitle"in e||"imageUrl"in e)}function ee(e){return"callbackId"in e&&"title"in e}function te(e){return"id"in e&&"label"in e&&!("options"in e)&&!("value"in e)}function F(e){return"id"in e&&"label"in e&&!("value"in e)}function ne(e){return"id"in e&&"label"in e&&!("value"in e)&&!("children"in e)}function re(e){return"label"in e&&"value"in e&&!("id"in e)}function ie(e){var y,b,h,m;let{type:n,props:t,children:i}=e,r=p(i);if(n===g){let l=W(t)?t:{style:void 0},q=r.length>0?r.map(String).join(""):String((y=l.children)!=null?y:"");return g(q,{style:l.style})}if(n===w)return w(r);if(n===T)return T(r);if(n===L)return L(r);if(n===S){if(!G(t))throw new Error("Button requires an 'id' prop");let l=r.length>0?r.map(String).join(""):(b=t.label)!=null?b:"";return S({id:t.id,label:l,style:t.style,value:t.value,actionType:t.actionType,callbackUrl:t.callbackUrl,disabled:t.disabled})}if(n===C){if(!Y(t))throw new Error("LinkButton requires a 'url' prop");let l=r.length>0?r.map(String).join(""):(h=t.label)!=null?h:"";return C({url:t.url,label:l,style:t.style})}if(n===j){if(!N(t))throw new Error("CardLink requires a 'url' prop");let l=r.length>0?r.map(String).join(""):(m=t.label)!=null?m:"";return j({url:t.url,label:l})}if(n===x){if(!z(t))throw new Error("Image requires a 'url' prop");return x({url:t.url,alt:t.alt})}if(n===v){if(!K(t))throw new Error("Field requires 'label' and 'value' props");return v({label:t.label,value:t.value})}if(n===k)return k();if(n===M){if(!ee(t))throw new Error("Modal requires 'callbackId' and 'title' props");return M({callbackId:t.callbackId,callbackUrl:t.callbackUrl,title:t.title,submitLabel:t.submitLabel,closeLabel:t.closeLabel,notifyOnClose:t.notifyOnClose,privateMetadata:t.privateMetadata,children:Q(r)})}if(n===$){if(!te(t))throw new Error("TextInput requires 'id' and 'label' props");return $({id:t.id,label:t.label,placeholder:t.placeholder,initialValue:t.initialValue,multiline:t.multiline,optional:t.optional,maxLength:t.maxLength})}if(n===A){if(!F(t))throw new Error("Select requires 'id' and 'label' props");return A({id:t.id,label:t.label,placeholder:t.placeholder,initialOption:t.initialOption,optional:t.optional,options:r})}if(n===O){if(!ne(t))throw new Error("ExternalSelect requires 'id' and 'label' props");return O({id:t.id,initialOption:t.initialOption,label:t.label,placeholder:t.placeholder,minQueryLength:t.minQueryLength,optional:t.optional})}if(n===I){if(!F(t))throw new Error("RadioSelect requires 'id' and 'label' props");return I({id:t.id,label:t.label,initialOption:t.initialOption,optional:t.optional,options:r})}if(n===P){if(!re(t))throw new Error("SelectOption requires 'label' and 'value' props");return P({label:t.label,value:t.value,description:t.description})}if(n===E){let l=t;return E({headers:l.headers,rows:l.rows})}let a=Z(t)?t:{};return J({title:a.title,subtitle:a.subtitle,imageUrl:a.imageUrl,children:r})}function o(e,n,t){let{children:i,...r}=n;return{$$typeof:d,type:e,props:r,children:i!=null?[i]:[]}}function u(e,n,t){let{children:i,...r}=n,a;return Array.isArray(i)?a=i:i!=null?a=[i]:a=[],{$$typeof:d,type:e,props:r,children:a}}var c=o;function s(e){return p(e.children)}0&&(module.exports={Fragment,jsx,jsxDEV,jsxs});
1
+ "use strict";var f=Object.defineProperty;var U=Object.getOwnPropertyDescriptor;var B=Object.getOwnPropertyNames;var _=Object.prototype.hasOwnProperty;var R=(e,n)=>{for(var t in n)f(e,t,{get:n[t],enumerable:!0})},D=(e,n,t,i)=>{if(n&&typeof n=="object"||typeof n=="function")for(let r of B(n))!_.call(e,r)&&r!==t&&f(e,r,{get:()=>n[r],enumerable:!(i=U(n,r))||i.enumerable});return e};var V=e=>D(f({},"__esModule",{value:!0}),e);var le={};R(le,{Fragment:()=>s,jsx:()=>o,jsxDEV:()=>c,jsxs:()=>u});module.exports=V(le);function J(e={}){var n;return{type:"card",title:e.title,subtitle:e.subtitle,imageUrl:e.imageUrl,children:(n=e.children)!=null?n:[]}}function g(e,n={}){return{type:"text",content:e,style:n.style}}function x(e){return{type:"image",url:e.url,alt:e.alt}}function k(){return{type:"divider"}}function w(e){return{type:"section",children:e}}function T(e){return{type:"actions",children:e}}function S(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 C(e){return{type:"link-button",id:e.id,url:e.url,label:e.label,style:e.style}}function v(e){return{type:"field",label:e.label,value:e.value}}function L(e){return{type:"fields",children:e}}function E(e){return{type:"table",headers:e.headers,rows:e.rows,align:e.align}}function j(e){return{type:"link",url:e.url,label:e.label}}var X=["text_input","select","external_select","radio_select","text","fields"];function Q(e){let n=e.filter(t=>typeof t=="object"&&t!==null&&"type"in t&&X.includes(t.type));return n.length<e.length&&console.warn("[chat] Modal contains unsupported child elements that were ignored"),n}function M(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 $(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 A(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 O(e){return{type:"external_select",id:e.id,initialOption:e.initialOption,label:e.label,placeholder:e.placeholder,minQueryLength:e.minQueryLength,optional:e.optional}}function P(e){return{label:e.label,value:e.value,description:e.description}}function I(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}}var d=Symbol.for("chat.jsx.element");function H(e){return typeof e=="object"&&e!==null&&e.$$typeof===d}function p(e){if(e==null)return[];if(Array.isArray(e))return e.flatMap(p);if(H(e)){let n=ie(e);return n?[n]:[]}return typeof e=="object"&&"type"in e?[e]:typeof e=="string"||typeof e=="number"?[String(e)]:[]}function W(e){return!("id"in e||"url"in e||"label"in e)}function G(e){return"id"in e&&typeof e.id=="string"&&!("url"in e)}function Y(e){return"url"in e&&typeof e.url=="string"&&!("id"in e)}function N(e){return"url"in e&&typeof e.url=="string"&&!("id"in e)&&!("alt"in e)&&!("style"in e)}function z(e){return"url"in e&&typeof e.url=="string"}function K(e){return"label"in e&&"value"in e&&typeof e.label=="string"&&typeof e.value=="string"}function Z(e){return!("id"in e||"url"in e||"callbackId"in e)&&("title"in e||"subtitle"in e||"imageUrl"in e)}function ee(e){return"callbackId"in e&&"title"in e}function te(e){return"id"in e&&"label"in e&&!("options"in e)&&!("value"in e)}function F(e){return"id"in e&&"label"in e&&!("value"in e)}function ne(e){return"id"in e&&"label"in e&&!("value"in e)&&!("children"in e)}function re(e){return"label"in e&&"value"in e&&!("id"in e)}function ie(e){var y,b,h,m;let{type:n,props:t,children:i}=e,r=p(i);if(n===g){let l=W(t)?t:{style:void 0},q=r.length>0?r.map(String).join(""):String((y=l.children)!=null?y:"");return g(q,{style:l.style})}if(n===w)return w(r);if(n===T)return T(r);if(n===L)return L(r);if(n===S){if(!G(t))throw new Error("Button requires an 'id' prop");let l=r.length>0?r.map(String).join(""):(b=t.label)!=null?b:"";return S({id:t.id,label:l,style:t.style,value:t.value,actionType:t.actionType,callbackUrl:t.callbackUrl,disabled:t.disabled})}if(n===C){if(!Y(t))throw new Error("LinkButton requires a 'url' prop");let l=r.length>0?r.map(String).join(""):(h=t.label)!=null?h:"";return C({id:t.id,url:t.url,label:l,style:t.style})}if(n===j){if(!N(t))throw new Error("CardLink requires a 'url' prop");let l=r.length>0?r.map(String).join(""):(m=t.label)!=null?m:"";return j({url:t.url,label:l})}if(n===x){if(!z(t))throw new Error("Image requires a 'url' prop");return x({url:t.url,alt:t.alt})}if(n===v){if(!K(t))throw new Error("Field requires 'label' and 'value' props");return v({label:t.label,value:t.value})}if(n===k)return k();if(n===M){if(!ee(t))throw new Error("Modal requires 'callbackId' and 'title' props");return M({callbackId:t.callbackId,callbackUrl:t.callbackUrl,title:t.title,submitLabel:t.submitLabel,closeLabel:t.closeLabel,notifyOnClose:t.notifyOnClose,privateMetadata:t.privateMetadata,children:Q(r)})}if(n===$){if(!te(t))throw new Error("TextInput requires 'id' and 'label' props");return $({id:t.id,label:t.label,placeholder:t.placeholder,initialValue:t.initialValue,multiline:t.multiline,optional:t.optional,maxLength:t.maxLength})}if(n===A){if(!F(t))throw new Error("Select requires 'id' and 'label' props");return A({id:t.id,label:t.label,placeholder:t.placeholder,initialOption:t.initialOption,optional:t.optional,options:r})}if(n===O){if(!ne(t))throw new Error("ExternalSelect requires 'id' and 'label' props");return O({id:t.id,initialOption:t.initialOption,label:t.label,placeholder:t.placeholder,minQueryLength:t.minQueryLength,optional:t.optional})}if(n===I){if(!F(t))throw new Error("RadioSelect requires 'id' and 'label' props");return I({id:t.id,label:t.label,initialOption:t.initialOption,optional:t.optional,options:r})}if(n===P){if(!re(t))throw new Error("SelectOption requires 'label' and 'value' props");return P({label:t.label,value:t.value,description:t.description})}if(n===E){let l=t;return E({headers:l.headers,rows:l.rows})}let a=Z(t)?t:{};return J({title:a.title,subtitle:a.subtitle,imageUrl:a.imageUrl,children:r})}function o(e,n,t){let{children:i,...r}=n;return{$$typeof:d,type:e,props:r,children:i!=null?[i]:[]}}function u(e,n,t){let{children:i,...r}=n,a;return Array.isArray(i)?a=i:i!=null?a=[i]:a=[],{$$typeof:d,type:e,props:r,children:a}}var c=o;function s(e){return p(e.children)}0&&(module.exports={Fragment,jsx,jsxDEV,jsxs});
@@ -1 +1 @@
1
- "use strict";var u=Object.defineProperty;var U=Object.getOwnPropertyDescriptor;var B=Object.getOwnPropertyNames;var _=Object.prototype.hasOwnProperty;var R=(e,n)=>{for(var t in n)u(e,t,{get:n[t],enumerable:!0})},D=(e,n,t,i)=>{if(n&&typeof n=="object"||typeof n=="function")for(let r of B(n))!_.call(e,r)&&r!==t&&u(e,r,{get:()=>n[r],enumerable:!(i=U(n,r))||i.enumerable});return e};var V=e=>D(u({},"__esModule",{value:!0}),e);var le={};R(le,{Fragment:()=>p,jsx:()=>o,jsxDEV:()=>d,jsxs:()=>f});module.exports=V(le);function J(e={}){var n;return{type:"card",title:e.title,subtitle:e.subtitle,imageUrl:e.imageUrl,children:(n=e.children)!=null?n:[]}}function g(e,n={}){return{type:"text",content:e,style:n.style}}function k(e){return{type:"image",url:e.url,alt:e.alt}}function w(){return{type:"divider"}}function x(e){return{type:"section",children:e}}function T(e){return{type:"actions",children:e}}function C(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 S(e){return{type:"link-button",url:e.url,label:e.label,style:e.style}}function v(e){return{type:"field",label:e.label,value:e.value}}function L(e){return{type:"fields",children:e}}function E(e){return{type:"table",headers:e.headers,rows:e.rows,align:e.align}}function M(e){return{type:"link",url:e.url,label:e.label}}var Q=["text_input","select","external_select","radio_select","text","fields"];function X(e){let n=e.filter(t=>typeof t=="object"&&t!==null&&"type"in t&&Q.includes(t.type));return n.length<e.length&&console.warn("[chat] Modal contains unsupported child elements that were ignored"),n}function $(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 j(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 A(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 O(e){return{type:"external_select",id:e.id,initialOption:e.initialOption,label:e.label,placeholder:e.placeholder,minQueryLength:e.minQueryLength,optional:e.optional}}function P(e){return{label:e.label,value:e.value,description:e.description}}function I(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}}var c=Symbol.for("chat.jsx.element");function H(e){return typeof e=="object"&&e!==null&&e.$$typeof===c}function s(e){if(e==null)return[];if(Array.isArray(e))return e.flatMap(s);if(H(e)){let n=ie(e);return n?[n]:[]}return typeof e=="object"&&"type"in e?[e]:typeof e=="string"||typeof e=="number"?[String(e)]:[]}function W(e){return!("id"in e||"url"in e||"label"in e)}function G(e){return"id"in e&&typeof e.id=="string"&&!("url"in e)}function Y(e){return"url"in e&&typeof e.url=="string"&&!("id"in e)}function N(e){return"url"in e&&typeof e.url=="string"&&!("id"in e)&&!("alt"in e)&&!("style"in e)}function z(e){return"url"in e&&typeof e.url=="string"}function K(e){return"label"in e&&"value"in e&&typeof e.label=="string"&&typeof e.value=="string"}function Z(e){return!("id"in e||"url"in e||"callbackId"in e)&&("title"in e||"subtitle"in e||"imageUrl"in e)}function ee(e){return"callbackId"in e&&"title"in e}function te(e){return"id"in e&&"label"in e&&!("options"in e)&&!("value"in e)}function F(e){return"id"in e&&"label"in e&&!("value"in e)}function ne(e){return"id"in e&&"label"in e&&!("value"in e)&&!("children"in e)}function re(e){return"label"in e&&"value"in e&&!("id"in e)}function ie(e){var b,y,h,m;let{type:n,props:t,children:i}=e,r=s(i);if(n===g){let l=W(t)?t:{style:void 0},q=r.length>0?r.map(String).join(""):String((b=l.children)!=null?b:"");return g(q,{style:l.style})}if(n===x)return x(r);if(n===T)return T(r);if(n===L)return L(r);if(n===C){if(!G(t))throw new Error("Button requires an 'id' prop");let l=r.length>0?r.map(String).join(""):(y=t.label)!=null?y:"";return C({id:t.id,label:l,style:t.style,value:t.value,actionType:t.actionType,callbackUrl:t.callbackUrl,disabled:t.disabled})}if(n===S){if(!Y(t))throw new Error("LinkButton requires a 'url' prop");let l=r.length>0?r.map(String).join(""):(h=t.label)!=null?h:"";return S({url:t.url,label:l,style:t.style})}if(n===M){if(!N(t))throw new Error("CardLink requires a 'url' prop");let l=r.length>0?r.map(String).join(""):(m=t.label)!=null?m:"";return M({url:t.url,label:l})}if(n===k){if(!z(t))throw new Error("Image requires a 'url' prop");return k({url:t.url,alt:t.alt})}if(n===v){if(!K(t))throw new Error("Field requires 'label' and 'value' props");return v({label:t.label,value:t.value})}if(n===w)return w();if(n===$){if(!ee(t))throw new Error("Modal requires 'callbackId' and 'title' props");return $({callbackId:t.callbackId,callbackUrl:t.callbackUrl,title:t.title,submitLabel:t.submitLabel,closeLabel:t.closeLabel,notifyOnClose:t.notifyOnClose,privateMetadata:t.privateMetadata,children:X(r)})}if(n===j){if(!te(t))throw new Error("TextInput requires 'id' and 'label' props");return j({id:t.id,label:t.label,placeholder:t.placeholder,initialValue:t.initialValue,multiline:t.multiline,optional:t.optional,maxLength:t.maxLength})}if(n===A){if(!F(t))throw new Error("Select requires 'id' and 'label' props");return A({id:t.id,label:t.label,placeholder:t.placeholder,initialOption:t.initialOption,optional:t.optional,options:r})}if(n===O){if(!ne(t))throw new Error("ExternalSelect requires 'id' and 'label' props");return O({id:t.id,initialOption:t.initialOption,label:t.label,placeholder:t.placeholder,minQueryLength:t.minQueryLength,optional:t.optional})}if(n===I){if(!F(t))throw new Error("RadioSelect requires 'id' and 'label' props");return I({id:t.id,label:t.label,initialOption:t.initialOption,optional:t.optional,options:r})}if(n===P){if(!re(t))throw new Error("SelectOption requires 'label' and 'value' props");return P({label:t.label,value:t.value,description:t.description})}if(n===E){let l=t;return E({headers:l.headers,rows:l.rows})}let a=Z(t)?t:{};return J({title:a.title,subtitle:a.subtitle,imageUrl:a.imageUrl,children:r})}function o(e,n,t){let{children:i,...r}=n;return{$$typeof:c,type:e,props:r,children:i!=null?[i]:[]}}function f(e,n,t){let{children:i,...r}=n,a;return Array.isArray(i)?a=i:i!=null?a=[i]:a=[],{$$typeof:c,type:e,props:r,children:a}}var d=o;function p(e){return s(e.children)}0&&(module.exports={Fragment,jsx,jsxDEV,jsxs});
1
+ "use strict";var u=Object.defineProperty;var U=Object.getOwnPropertyDescriptor;var B=Object.getOwnPropertyNames;var _=Object.prototype.hasOwnProperty;var R=(e,n)=>{for(var t in n)u(e,t,{get:n[t],enumerable:!0})},D=(e,n,t,i)=>{if(n&&typeof n=="object"||typeof n=="function")for(let r of B(n))!_.call(e,r)&&r!==t&&u(e,r,{get:()=>n[r],enumerable:!(i=U(n,r))||i.enumerable});return e};var V=e=>D(u({},"__esModule",{value:!0}),e);var le={};R(le,{Fragment:()=>p,jsx:()=>o,jsxDEV:()=>d,jsxs:()=>f});module.exports=V(le);function J(e={}){var n;return{type:"card",title:e.title,subtitle:e.subtitle,imageUrl:e.imageUrl,children:(n=e.children)!=null?n:[]}}function g(e,n={}){return{type:"text",content:e,style:n.style}}function k(e){return{type:"image",url:e.url,alt:e.alt}}function w(){return{type:"divider"}}function x(e){return{type:"section",children:e}}function T(e){return{type:"actions",children:e}}function C(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 S(e){return{type:"link-button",id:e.id,url:e.url,label:e.label,style:e.style}}function v(e){return{type:"field",label:e.label,value:e.value}}function L(e){return{type:"fields",children:e}}function E(e){return{type:"table",headers:e.headers,rows:e.rows,align:e.align}}function M(e){return{type:"link",url:e.url,label:e.label}}var Q=["text_input","select","external_select","radio_select","text","fields"];function X(e){let n=e.filter(t=>typeof t=="object"&&t!==null&&"type"in t&&Q.includes(t.type));return n.length<e.length&&console.warn("[chat] Modal contains unsupported child elements that were ignored"),n}function $(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 j(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 A(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 O(e){return{type:"external_select",id:e.id,initialOption:e.initialOption,label:e.label,placeholder:e.placeholder,minQueryLength:e.minQueryLength,optional:e.optional}}function P(e){return{label:e.label,value:e.value,description:e.description}}function I(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}}var c=Symbol.for("chat.jsx.element");function H(e){return typeof e=="object"&&e!==null&&e.$$typeof===c}function s(e){if(e==null)return[];if(Array.isArray(e))return e.flatMap(s);if(H(e)){let n=ie(e);return n?[n]:[]}return typeof e=="object"&&"type"in e?[e]:typeof e=="string"||typeof e=="number"?[String(e)]:[]}function W(e){return!("id"in e||"url"in e||"label"in e)}function G(e){return"id"in e&&typeof e.id=="string"&&!("url"in e)}function Y(e){return"url"in e&&typeof e.url=="string"&&!("id"in e)}function N(e){return"url"in e&&typeof e.url=="string"&&!("id"in e)&&!("alt"in e)&&!("style"in e)}function z(e){return"url"in e&&typeof e.url=="string"}function K(e){return"label"in e&&"value"in e&&typeof e.label=="string"&&typeof e.value=="string"}function Z(e){return!("id"in e||"url"in e||"callbackId"in e)&&("title"in e||"subtitle"in e||"imageUrl"in e)}function ee(e){return"callbackId"in e&&"title"in e}function te(e){return"id"in e&&"label"in e&&!("options"in e)&&!("value"in e)}function F(e){return"id"in e&&"label"in e&&!("value"in e)}function ne(e){return"id"in e&&"label"in e&&!("value"in e)&&!("children"in e)}function re(e){return"label"in e&&"value"in e&&!("id"in e)}function ie(e){var b,y,h,m;let{type:n,props:t,children:i}=e,r=s(i);if(n===g){let l=W(t)?t:{style:void 0},q=r.length>0?r.map(String).join(""):String((b=l.children)!=null?b:"");return g(q,{style:l.style})}if(n===x)return x(r);if(n===T)return T(r);if(n===L)return L(r);if(n===C){if(!G(t))throw new Error("Button requires an 'id' prop");let l=r.length>0?r.map(String).join(""):(y=t.label)!=null?y:"";return C({id:t.id,label:l,style:t.style,value:t.value,actionType:t.actionType,callbackUrl:t.callbackUrl,disabled:t.disabled})}if(n===S){if(!Y(t))throw new Error("LinkButton requires a 'url' prop");let l=r.length>0?r.map(String).join(""):(h=t.label)!=null?h:"";return S({id:t.id,url:t.url,label:l,style:t.style})}if(n===M){if(!N(t))throw new Error("CardLink requires a 'url' prop");let l=r.length>0?r.map(String).join(""):(m=t.label)!=null?m:"";return M({url:t.url,label:l})}if(n===k){if(!z(t))throw new Error("Image requires a 'url' prop");return k({url:t.url,alt:t.alt})}if(n===v){if(!K(t))throw new Error("Field requires 'label' and 'value' props");return v({label:t.label,value:t.value})}if(n===w)return w();if(n===$){if(!ee(t))throw new Error("Modal requires 'callbackId' and 'title' props");return $({callbackId:t.callbackId,callbackUrl:t.callbackUrl,title:t.title,submitLabel:t.submitLabel,closeLabel:t.closeLabel,notifyOnClose:t.notifyOnClose,privateMetadata:t.privateMetadata,children:X(r)})}if(n===j){if(!te(t))throw new Error("TextInput requires 'id' and 'label' props");return j({id:t.id,label:t.label,placeholder:t.placeholder,initialValue:t.initialValue,multiline:t.multiline,optional:t.optional,maxLength:t.maxLength})}if(n===A){if(!F(t))throw new Error("Select requires 'id' and 'label' props");return A({id:t.id,label:t.label,placeholder:t.placeholder,initialOption:t.initialOption,optional:t.optional,options:r})}if(n===O){if(!ne(t))throw new Error("ExternalSelect requires 'id' and 'label' props");return O({id:t.id,initialOption:t.initialOption,label:t.label,placeholder:t.placeholder,minQueryLength:t.minQueryLength,optional:t.optional})}if(n===I){if(!F(t))throw new Error("RadioSelect requires 'id' and 'label' props");return I({id:t.id,label:t.label,initialOption:t.initialOption,optional:t.optional,options:r})}if(n===P){if(!re(t))throw new Error("SelectOption requires 'label' and 'value' props");return P({label:t.label,value:t.value,description:t.description})}if(n===E){let l=t;return E({headers:l.headers,rows:l.rows})}let a=Z(t)?t:{};return J({title:a.title,subtitle:a.subtitle,imageUrl:a.imageUrl,children:r})}function o(e,n,t){let{children:i,...r}=n;return{$$typeof:c,type:e,props:r,children:i!=null?[i]:[]}}function f(e,n,t){let{children:i,...r}=n,a;return Array.isArray(i)?a=i:i!=null?a=[i]:a=[],{$$typeof:c,type:e,props:r,children:a}}var d=o;function p(e){return s(e.children)}0&&(module.exports={Fragment,jsx,jsxDEV,jsxs});
@@ -0,0 +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});
@@ -0,0 +1,105 @@
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';
3
+ import { LanguageModelLike } from '@langchain/core/language_models/base';
4
+ import { StructuredToolInterface } from '@langchain/core/tools';
5
+ import { AgentMiddleware } from 'langchain';
6
+ import { A as Awaitable } from '../util.types-DaFfsxgy.cjs';
7
+ import 'chat';
8
+
9
+ interface ToolResultPayload {
10
+ toolCallId: string;
11
+ toolName?: string;
12
+ output: unknown;
13
+ }
14
+
15
+ /**
16
+ * Convert `ctx.history` into LangChain `BaseMessage[]` for `createAgent().invoke(...)`.
17
+ *
18
+ * History already includes the current incoming message — do not append the handler's
19
+ * `message` argument on top of it.
20
+ *
21
+ * @param system - Optional system prompt prepended as a `SystemMessage`. Omit it when the
22
+ * agent already receives a prompt (e.g. via `createAgent({ prompt })`) to avoid duplication.
23
+ * @param freshResults - Tool outputs the adapter executed this turn (approve-resume). Cycles
24
+ * with a fresh result are replayed as resolved call+result pairs.
25
+ */
26
+ declare function toLangChainMessages(history: AgentHistoryEntry[], system?: string, freshResults?: Map<string, ToolResultPayload>): BaseMessage[];
27
+
28
+ /** A tool call surfaced to `needsApproval` before it executes. */
29
+ interface LangChainToolCall {
30
+ id?: string;
31
+ name: string;
32
+ args: Record<string, unknown>;
33
+ }
34
+ /**
35
+ * Declarative agent config the adapter runs on your behalf.
36
+ *
37
+ * Returning this from `onMessage` lets Novu own the tool-approval loop: gated
38
+ * tools pause the turn with an approval card and resume statelessly from
39
+ * `ctx.history` — no LangGraph checkpointer required.
40
+ */
41
+ interface LangChainAgentConfig {
42
+ /** Chat model instance or `"provider:model"` identifier passed to `createAgent`. */
43
+ model: string | LanguageModelLike;
44
+ /** Tools available to the agent. */
45
+ tools?: StructuredToolInterface[];
46
+ /** System prompt for the agent (forwarded to `createAgent` as `prompt`). */
47
+ system?: string;
48
+ /** Return `true` to gate a tool call behind a Novu approval card before it runs. */
49
+ needsApproval?: (toolCall: LangChainToolCall) => boolean;
50
+ /** Extra LangChain middleware, appended after Novu's approval middleware. */
51
+ middleware?: AgentMiddleware[];
52
+ }
53
+ /**
54
+ * Result of a LangChain agent/graph you invoked yourself (e.g. `await agent.invoke(...)`).
55
+ * Delivered as-is — tool approval is not managed by Novu on this path.
56
+ */
57
+ interface LangChainInvokeResult {
58
+ messages: BaseMessage[];
59
+ }
60
+ /** Anything a `@novu/framework/langchain` handler may return for automatic delivery. */
61
+ type LangChainResult = LangChainAgentConfig | LangChainInvokeResult | BaseMessage;
62
+ /**
63
+ * Handlers for `@novu/framework/langchain` agents.
64
+ *
65
+ * Extends {@link AgentHandlers}: same events and config (`toolApproval`, etc.),
66
+ * but `onMessage` and `onToolApproval` may return a {@link LangChainResult} for
67
+ * automatic delivery.
68
+ */
69
+ type LangChainAgentHandlers = Omit<AgentHandlers, 'onMessage' | 'onToolApproval'> & {
70
+ onMessage: (message: AgentMessage, ctx: AgentMessageContext) => Awaitable<MessageContent | LangChainResult | void>;
71
+ /**
72
+ * Optional. Auto-resumes `onMessage` after approve/deny unless you return a
73
+ * `LangChainResult` to drive the resume yourself.
74
+ */
75
+ onToolApproval?: (decision: ToolApprovalDecision, ctx: AgentActionContext) => Awaitable<MessageContent | LangChainResult | ReplyHandle | void>;
76
+ };
77
+
78
+ type LangChainMessageHandler = LangChainAgentHandlers['onMessage'];
79
+ /**
80
+ * Wrap LangChain handlers as a Novu {@link Agent}.
81
+ *
82
+ * Return a {@link import('./types').LangChainAgentConfig} from `onMessage` to let Novu run the
83
+ * agent and own the tool-approval loop; gated tools pause with an approval card and resume
84
+ * statelessly from `ctx.history`. You may also return already-produced messages, a card, or plain
85
+ * text. Approvals auto-resume `onMessage` unless a custom `onToolApproval` handles them.
86
+ */
87
+ declare function agent(id: string, handlers: LangChainMessageHandler | LangChainAgentHandlers): Agent;
88
+
89
+ /**
90
+ * Thrown from the approval middleware when a gated tool is about to run. It propagates out
91
+ * of `agent.invoke()` so the adapter can post a Novu approval card and end the turn instead
92
+ * of executing the tool. The approval decision is later replayed from `ctx.history`.
93
+ */
94
+ declare class NovuToolApprovalRequired extends Error {
95
+ readonly toolCallId: string;
96
+ readonly toolName: string;
97
+ readonly input?: Record<string, unknown>;
98
+ constructor(toolCall: {
99
+ toolCallId: string;
100
+ toolName: string;
101
+ input?: Record<string, unknown>;
102
+ });
103
+ }
104
+
105
+ export { type LangChainAgentConfig, type LangChainAgentHandlers, type LangChainInvokeResult, type LangChainResult, type LangChainToolCall, NovuToolApprovalRequired, agent, toLangChainMessages };