@novu/framework 2.13.1-rc.852194fa77 → 2.13.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. package/dist/cjs/{agent.types-CQKSD7NC.d.cts → agent.types-crcJBtCy.d.cts} +119 -3
  2. package/dist/cjs/ai-sdk/index.d.cts +1 -1
  3. package/dist/cjs/{health-check.types-B6RuXNc8.d.cts → health-check.types-C2XZ-Tpt.d.cts} +2 -2
  4. package/dist/cjs/{index-phn3kJ9H.d.cts → index-DVSB455a.d.cts} +3 -3
  5. package/dist/cjs/index.cjs +96 -96
  6. package/dist/cjs/index.d.cts +4 -4
  7. package/dist/cjs/internal/index.cjs +36 -36
  8. package/dist/cjs/internal/index.d.cts +29 -14
  9. package/dist/cjs/langchain/index.d.cts +1 -1
  10. package/dist/cjs/servers/express.cjs +97 -97
  11. package/dist/cjs/servers/express.d.cts +5 -5
  12. package/dist/cjs/servers/h3.cjs +106 -106
  13. package/dist/cjs/servers/h3.d.cts +5 -5
  14. package/dist/cjs/servers/hono.cjs +103 -103
  15. package/dist/cjs/servers/hono.d.cts +5 -5
  16. package/dist/cjs/servers/lambda.cjs +97 -97
  17. package/dist/cjs/servers/lambda.d.cts +5 -5
  18. package/dist/cjs/servers/nest.cjs +99 -99
  19. package/dist/cjs/servers/nest.d.cts +7 -7
  20. package/dist/cjs/servers/next.cjs +116 -116
  21. package/dist/cjs/servers/next.d.cts +5 -5
  22. package/dist/cjs/servers/nuxt.cjs +106 -106
  23. package/dist/cjs/servers/nuxt.d.cts +5 -5
  24. package/dist/cjs/servers/remix.cjs +110 -110
  25. package/dist/cjs/servers/remix.d.cts +5 -5
  26. package/dist/cjs/servers/sveltekit.cjs +110 -110
  27. package/dist/cjs/servers/sveltekit.d.cts +5 -5
  28. package/dist/cjs/step-resolver.cjs +1 -1
  29. package/dist/cjs/step-resolver.d.cts +2 -2
  30. package/dist/cjs/{subscriber.types-_eHz1E0m.d.cts → subscriber.types-BanvmGul.d.cts} +1 -1
  31. package/dist/esm/{agent.types-C17NUGxY.d.ts → agent.types-DFLG1_vb.d.ts} +119 -3
  32. package/dist/esm/ai-sdk/index.d.ts +1 -1
  33. package/dist/esm/chunk-4ETX7FIT.js +1 -0
  34. package/dist/esm/{chunk-UXO4RWZV.js → chunk-IREH6K2M.js} +2 -2
  35. package/dist/esm/{chunk-WJUYDVXH.js → chunk-PBC7WR2R.js} +46 -46
  36. package/dist/esm/{health-check.types-CL5-B_D4.d.ts → health-check.types-DORn4djx.d.ts} +2 -2
  37. package/dist/esm/{index-CYtGHJJu.d.ts → index-BvRGmHFw.d.ts} +3 -3
  38. package/dist/esm/index.d.ts +4 -4
  39. package/dist/esm/index.js +1 -1
  40. package/dist/esm/internal/index.d.ts +20 -5
  41. package/dist/esm/internal/index.js +1 -1
  42. package/dist/esm/langchain/index.d.ts +1 -1
  43. package/dist/esm/servers/express.d.ts +5 -5
  44. package/dist/esm/servers/express.js +1 -1
  45. package/dist/esm/servers/h3.d.ts +5 -5
  46. package/dist/esm/servers/h3.js +1 -1
  47. package/dist/esm/servers/hono.d.ts +5 -5
  48. package/dist/esm/servers/hono.js +1 -1
  49. package/dist/esm/servers/lambda.d.ts +5 -5
  50. package/dist/esm/servers/lambda.js +1 -1
  51. package/dist/esm/servers/nest.d.ts +7 -7
  52. package/dist/esm/servers/nest.js +1 -1
  53. package/dist/esm/servers/next.d.ts +5 -5
  54. package/dist/esm/servers/next.js +1 -1
  55. package/dist/esm/servers/nuxt.d.ts +5 -5
  56. package/dist/esm/servers/nuxt.js +1 -1
  57. package/dist/esm/servers/remix.d.ts +5 -5
  58. package/dist/esm/servers/remix.js +1 -1
  59. package/dist/esm/servers/sveltekit.d.ts +5 -5
  60. package/dist/esm/servers/sveltekit.js +1 -1
  61. package/dist/esm/step-resolver.d.ts +2 -2
  62. package/dist/esm/step-resolver.js +1 -1
  63. package/dist/esm/{subscriber.types-D4PvRIKR.d.ts → subscriber.types-Drf26WPA.d.ts} +1 -1
  64. package/package.json +1 -1
  65. package/dist/esm/chunk-Q3ALQWIF.js +0 -1
@@ -114,7 +114,7 @@ declare enum ChatProviderIdEnum {
114
114
  Novu = "novu-slack",
115
115
  Telegram = "telegram",
116
116
  Sendblue = "sendblue",
117
- NovuAgentChat = "novu-agent-chat"
117
+ NovuWebChat = "novu-web-chat"
118
118
  }
119
119
  declare enum PushProviderIdEnum {
120
120
  FCM = "fcm",
@@ -205,6 +205,51 @@ declare enum AgentEventEnum {
205
205
  ON_RESOLVE = "onResolve",
206
206
  ON_REACTION = "onReaction"
207
207
  }
208
+ type HumanInteractionKind = 'ask' | 'approve' | 'choose' | 'tell';
209
+ type HumanAskApproveOptions = {
210
+ /** Attribution label shown to the human (e.g. `"deploy-bot"`). */
211
+ from?: string;
212
+ /** Time until the request expires, in seconds (max 72h; default 24h). */
213
+ ttlSeconds?: number;
214
+ /**
215
+ * Novu `subscriberId`(s) allowed to settle this request. First valid answer
216
+ * wins. When omitted, the conversation's first subscriber participant is used.
217
+ * The maximum number of subscribers is 50.
218
+ */
219
+ to?: string | string[];
220
+ };
221
+ type HumanChooseOptions = HumanAskApproveOptions;
222
+ type HumanTellOptions = {
223
+ /** Attribution label shown to the human (e.g. `"deploy-bot"`). */
224
+ from?: string;
225
+ /**
226
+ * Novu `subscriberId`(s) this notice is addressed to. In-thread delivery
227
+ * still posts one card on the current conversation.
228
+ */
229
+ to?: string | string[];
230
+ };
231
+ /**
232
+ * Outcome of a `ctx.ask` / `ctx.approve` / `ctx.choose` request, attached to
233
+ * the later `onMessage` (ask) or `onAction` (approve / choose) turn.
234
+ */
235
+ type AgentHumanResponse = {
236
+ /** Client-minted id returned by `ctx.ask` / `ctx.approve` / `ctx.choose`. */
237
+ requestId: string;
238
+ /** Public interaction identifier (`hi_...`). */
239
+ interactionId: string;
240
+ kind: HumanInteractionKind;
241
+ /** Terminal status: `answered` | `approved` | `denied` | `expired` | `canceled` | `delivered`. */
242
+ status: string;
243
+ /** True when the TTL elapsed before a valid answer. Do not treat `text` / `optionId` as a verdict. */
244
+ expired: boolean;
245
+ /** Freeform reply text for `ask`. */
246
+ text?: string;
247
+ /** `approve`: `'approve'` | `'deny'`; `choose`: the picked option id. */
248
+ optionId?: string;
249
+ respondedBy?: string;
250
+ /** Stable Novu subscriberId of whoever settled the interaction. */
251
+ respondedBySubscriberId?: string;
252
+ };
208
253
  /** Identity of the user or bot that authored a message. */
209
254
  interface AgentMessageAuthor {
210
255
  userId: string;
@@ -553,6 +598,12 @@ interface AgentHandlerContext {
553
598
  * conversation was not opened from a workflow send.
554
599
  */
555
600
  readonly notification: AgentNotification | null;
601
+ /**
602
+ * Settled `ctx.ask` / `ctx.approve` / `ctx.choose` payload when this
603
+ * `onMessage` or `onAction` turn answered (or expired) a human interaction.
604
+ * `null` on ordinary chat and button clicks.
605
+ */
606
+ readonly humanResponse: AgentHumanResponse | null;
556
607
  /**
557
608
  * Full conversation history as an ordered array of entries.
558
609
  * Map to your LLM's message format before making a model call:
@@ -633,6 +684,50 @@ interface AgentHandlerContext {
633
684
  to?: TriggerRecipientsPayload;
634
685
  payload?: Record<string, unknown>;
635
686
  }): void;
687
+ /**
688
+ * Ask the conversation subscriber a freeform question. Queued and flushed
689
+ * with the next `ctx.reply()`, or automatically when the handler completes.
690
+ * The answer arrives later on `onMessage` with `ctx.humanResponse` set.
691
+ * Pass `to` to let any listed subscriber settle (first valid answer wins).
692
+ *
693
+ * @returns A `requestId` you can match against `ctx.humanResponse.requestId`.
694
+ *
695
+ * @example
696
+ * ctx.ask('What environment should we deploy to?');
697
+ * ctx.ask('Which environment?', { to: 'alice' });
698
+ */
699
+ ask(question: string, opts?: HumanAskApproveOptions): string;
700
+ /**
701
+ * Ask the conversation subscriber to approve or deny an action.
702
+ * The verdict arrives later on `onAction` with `ctx.humanResponse` set.
703
+ * Pass `to` to let any listed subscriber settle (first valid answer wins).
704
+ *
705
+ * @returns A `requestId` you can match against `ctx.humanResponse.requestId`.
706
+ *
707
+ * @example
708
+ * ctx.approve('Deploy v2.4.1 to production?');
709
+ * ctx.approve('Deploy v2.4.1?', { to: ['alice', 'bob'] });
710
+ */
711
+ approve(action: string, opts?: HumanAskApproveOptions): string;
712
+ /**
713
+ * Ask the conversation subscriber to pick one of several options (2–10).
714
+ * The pick arrives later on `onAction` with `ctx.humanResponse` set.
715
+ * Pass `to` to let any listed subscriber settle (first valid answer wins).
716
+ *
717
+ * @returns A `requestId` you can match against `ctx.humanResponse.requestId`.
718
+ *
719
+ * @example
720
+ * ctx.choose('Which region?', ['us-east', 'eu-west', 'ap-south']);
721
+ */
722
+ choose(question: string, options: string[], opts?: HumanChooseOptions): string;
723
+ /**
724
+ * Send a one-way notification to the conversation subscriber. Nothing to wait
725
+ * on — `tell` never sets `ctx.humanResponse`.
726
+ *
727
+ * @example
728
+ * ctx.tell('Deploy finished. v2.4.1 is live.');
729
+ */
730
+ tell(message: string, opts?: HumanTellOptions): string;
636
731
  /**
637
732
  * Add an emoji reaction to any platform message.
638
733
  * Reactions are queued and sent with the next `ctx.reply()`, or flushed automatically
@@ -809,6 +904,12 @@ interface AgentBridgeRequest {
809
904
  * absent → `ctx.notification` is `null`.
810
905
  */
811
906
  notification?: AgentNotification | null;
907
+ /**
908
+ * Settled human-interaction payload when this `onMessage` / `onAction` turn
909
+ * answered or expired a `ctx.ask` / `ctx.approve` / `ctx.choose`. Optional on
910
+ * the wire for backward compatibility; absent → `ctx.humanResponse` is `null`.
911
+ */
912
+ humanResponse?: AgentHumanResponse | null;
812
913
  history: AgentHistoryEntry[];
813
914
  platform: string;
814
915
  platformContext: AgentPlatformContext;
@@ -841,7 +942,22 @@ type TriggerSignal = {
841
942
  to?: TriggerRecipientsPayload;
842
943
  payload?: Record<string, unknown>;
843
944
  };
844
- type Signal = MetadataSignal | TriggerSignal;
945
+ /**
946
+ * Queued by `ctx.ask` / `ctx.approve` / `ctx.choose` / `ctx.tell` — instructs
947
+ * Novu to create a human interaction in the current conversation thread.
948
+ */
949
+ type HumanSignal = {
950
+ type: 'human';
951
+ kind: HumanInteractionKind;
952
+ prompt: string;
953
+ requestId: string;
954
+ options?: string[];
955
+ from?: string;
956
+ ttlSeconds?: number;
957
+ /** Novu subscriberId(s) allowed to settle. Omitted = conversation subscriber. */
958
+ to?: string | string[];
959
+ };
960
+ type Signal = MetadataSignal | TriggerSignal | HumanSignal;
845
961
  /** The outcome of a tool call, reported back so it's saved in the conversation history. */
846
962
  type ToolResult = {
847
963
  /** Id of the tool call this result belongs to. */
@@ -904,4 +1020,4 @@ interface SentMessageInfo {
904
1020
  platformThreadId: string;
905
1021
  }
906
1022
 
907
- export { buildApprovalActionId as $, type Agent as A, type TriggerRecipientsPayload as B, type ISubscriberPayload as C, TriggerEventStatusEnum as D, type ToolResult as E, type FileRef as F, type ToolApprovalRequestPayload as G, AgentEventEnum as H, type ITriggerPayload as I, type TypingControl as J, type ToolApprovalControl as K, type AgentBridgeRequest as L, type MessageContent as M, type ReplyContent as N, type AddReactionPayload as O, type DeleteMessagePayload as P, type SentMessageInfo as Q, type ReplyHandle as R, type Signal as S, type ToolApprovalCard as T, type TypingOp as U, type AgentReplyPayload as V, type WorkflowPreferencesPartial as W, type EditPayload as X, type MetadataSignal as Y, type ParsedApprovalAction as Z, type TriggerSignal as _, type AgentAction as a, parseApprovalActionId as a0, type AgentActionContext as b, type AgentAttachment as c, type AgentContext as d, type AgentContextPayload as e, type AgentContextValue as f, type AgentConversation as g, AgentDeliveryError as h, AgentError as i, type AgentHandlerContext as j, type AgentHandlers as k, type AgentHistoryEntry as l, type AgentMessage as m, type AgentMessageAuthor as n, type AgentMessageContext as o, type AgentNotification as p, type AgentPlatformContext as q, type AgentReaction as r, type AgentReactionContext as s, type AgentResolveContext as t, type AgentSubscriber as u, type AgentSubscriberAccess as v, type AgentToolCall as w, type ToolApprovalConfig as x, type ToolApprovalDecision as y, toAgentError as z };
1023
+ export { type AgentReplyPayload as $, type Agent as A, type HumanTellOptions as B, type ToolApprovalConfig as C, type ToolApprovalDecision as D, toAgentError as E, type FileRef as F, type TriggerRecipientsPayload as G, type HumanAskApproveOptions as H, type ITriggerPayload as I, type ISubscriberPayload as J, TriggerEventStatusEnum as K, type ToolResult as L, type MessageContent as M, type ToolApprovalRequestPayload as N, AgentEventEnum as O, type TypingControl as P, type ToolApprovalControl as Q, type ReplyHandle as R, type AgentBridgeRequest as S, type ToolApprovalCard as T, type ReplyContent as U, type Signal as V, type WorkflowPreferencesPartial as W, type AddReactionPayload as X, type DeleteMessagePayload as Y, type SentMessageInfo as Z, type TypingOp as _, type AgentAction as a, type EditPayload as a0, type HumanSignal as a1, type MetadataSignal as a2, type ParsedApprovalAction as a3, type TriggerSignal as a4, buildApprovalActionId as a5, parseApprovalActionId as a6, type AgentActionContext as b, type AgentAttachment as c, type AgentContext as d, type AgentContextPayload as e, type AgentContextValue as f, type AgentConversation as g, AgentDeliveryError as h, AgentError as i, type AgentHandlerContext as j, type AgentHandlers as k, type AgentHistoryEntry as l, type AgentHumanResponse as m, type AgentMessage as n, type AgentMessageAuthor as o, type AgentMessageContext as p, type AgentNotification as q, type AgentPlatformContext as r, type AgentReaction as s, type AgentReactionContext as t, type AgentResolveContext as u, type AgentSubscriber as v, type AgentSubscriberAccess as w, type AgentToolCall as x, type HumanChooseOptions as y, type HumanInteractionKind as z };
@@ -1,4 +1,4 @@
1
- import { k as AgentHandlers, m as AgentMessage, o as AgentMessageContext, M as MessageContent, y as ToolApprovalDecision, b as AgentActionContext, R as ReplyHandle, A as Agent, l as AgentHistoryEntry, j as AgentHandlerContext } from '../agent.types-CQKSD7NC.cjs';
1
+ import { k as AgentHandlers, n as AgentMessage, p as AgentMessageContext, M as MessageContent, D as ToolApprovalDecision, b as AgentActionContext, R as ReplyHandle, A as Agent, l as AgentHistoryEntry, j as AgentHandlerContext } from '../agent.types-crcJBtCy.cjs';
2
2
  import { streamText, generateText, ModelMessage } from 'ai';
3
3
  import { A as Awaitable } from '../util.types-DaFfsxgy.cjs';
4
4
  import 'chat';
@@ -1,5 +1,5 @@
1
- import { a as ContextPayload, b as Step, S as Subscriber, E as EnvironmentSystemVariables, C as ContextResolved, c as ChannelStepEnum, A as ActionStepEnum, W as WithPassthrough, d as StepOptions } from './subscriber.types-_eHz1E0m.cjs';
2
- import { I as ITriggerPayload, B as TriggerRecipientsPayload, C as ISubscriberPayload, D as TriggerEventStatusEnum, W as WorkflowPreferencesPartial } from './agent.types-CQKSD7NC.cjs';
1
+ import { a as ContextPayload, b as Step, S as Subscriber, E as EnvironmentSystemVariables, C as ContextResolved, c as ChannelStepEnum, A as ActionStepEnum, W as WithPassthrough, d as StepOptions } from './subscriber.types-BanvmGul.cjs';
2
+ import { I as ITriggerPayload, G as TriggerRecipientsPayload, J as ISubscriberPayload, K as TriggerEventStatusEnum, W as WorkflowPreferencesPartial } from './agent.types-crcJBtCy.cjs';
3
3
  import { C as ConditionalPartial, P as PickRequiredKeys, a as Prettify, D as DeepPartial, A as Awaitable } from './util.types-DaFfsxgy.cjs';
4
4
  import { S as Schema, J as JsonSchema } from './base.schema.types-BApIn9jr.cjs';
5
5
 
@@ -1,10 +1,10 @@
1
- import { k as AgentHandlers, A as Agent, p as AgentNotification } from './agent.types-CQKSD7NC.cjs';
2
- import { W as Workflow, L as Logger, C as ClientOptions, H as HealthCheck, e as DiscoverOutput, i as Event, n as ExecuteOutput, d as CodeResult, j as EventTriggerParams, m as Execute, t as WorkflowOptions } from './health-check.types-B6RuXNc8.cjs';
1
+ import { k as AgentHandlers, A as Agent, q as AgentNotification } from './agent.types-crcJBtCy.cjs';
2
+ import { W as Workflow, L as Logger, C as ClientOptions, H as HealthCheck, e as DiscoverOutput, i as Event, n as ExecuteOutput, d as CodeResult, j as EventTriggerParams, m as Execute, t as WorkflowOptions } from './health-check.types-C2XZ-Tpt.cjs';
3
3
  import { A as Awaitable } from './util.types-DaFfsxgy.cjs';
4
4
  import 'chat';
5
5
  import { S as Schema, a as FromSchema, F as FromSchemaUnvalidated } from './base.schema.types-BApIn9jr.cjs';
6
6
  import './step-resolver.cjs';
7
- import './subscriber.types-_eHz1E0m.cjs';
7
+ import './subscriber.types-BanvmGul.cjs';
8
8
 
9
9
  /**
10
10
  * Define a new conversational agent.