@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
package/README.md CHANGED
@@ -7,14 +7,17 @@
7
7
  </a>
8
8
  </div>
9
9
 
10
- # Code-First Notifications Workflow SDK
10
+ # Novu Framework
11
11
 
12
12
  [![Version](https://img.shields.io/npm/v/@novu/framework.svg)](https://www.npmjs.org/package/@novu/framework)
13
13
  [![Downloads](https://img.shields.io/npm/dm/@novu/framework.svg)](https://www.npmjs.com/package/@novu/framework)
14
14
 
15
- Novu Framework allows you to write notification workflows in your codebase. Workflows are functions that execute business logic and use your preferred libraries for email, SMS, and chat generation. You can use Novu Framework with [React.Email](https://react.email/), [MJML](https://mjml.io/), or any other template generator.
15
+ `@novu/framework` is Novu's code-first SDK for two things:
16
16
 
17
- Learn more about the Code-First Notifications Workflow SDK in our [docs](https://docs.novu.co/framework/quickstart).
17
+ 1. **Conversational agents** define bridge agents in your codebase and connect them to Slack, Email, Telegram, WhatsApp, and Microsoft Teams with `npx novu connect`.
18
+ 2. **Notification workflows** — write durable, multi-channel notification flows as TypeScript functions.
19
+
20
+ Learn more in the [Framework docs](https://docs.novu.co/framework/quickstart) and [managed agent quickstart](https://docs.novu.co/agents/managed-agent/quickstart).
18
21
 
19
22
  ## Installation
20
23
 
@@ -22,14 +25,83 @@ Learn more about the Code-First Notifications Workflow SDK in our [docs](https:/
22
25
  npm install @novu/framework
23
26
  ```
24
27
 
25
- ## Quickstart
28
+ ## Connect an agent to channels
29
+
30
+ The fastest path is the Novu CLI — it creates the agent in Novu Cloud, provisions channel credentials, and (for bridge runtimes) wires your local app:
31
+
32
+ ```bash
33
+ npx novu@latest connect
34
+ ```
35
+
36
+ For a self-hosted agent in your repo, pick a bridge runtime when prompted, or pass one explicitly:
37
+
38
+ ```bash
39
+ # Vercel AI SDK agent
40
+ npx novu@latest connect --runtime ai-sdk
41
+
42
+ # Chat SDK multi-channel agent
43
+ npx novu@latest connect --runtime chat-sdk
44
+ ```
45
+
46
+ Re-run `npx novu connect` to add another channel. Each run connects one channel to one agent.
47
+
48
+ ## Bridge agents
49
+
50
+ Define agents in your codebase and serve them on a Novu bridge endpoint. Use `@novu/framework/ai-sdk` when your agent is built with the [Vercel AI SDK](https://ai-sdk.dev/):
51
+
52
+ ```typescript
53
+ import { serve } from '@novu/framework/next';
54
+ import { agent } from '@novu/framework/ai-sdk';
55
+ import { streamText } from 'ai';
56
+ import { anthropic } from '@ai-sdk/anthropic';
57
+
58
+ const supportAgent = agent('support-bot', {
59
+ onMessage: async (message, ctx) => {
60
+ const result = streamText({
61
+ model: anthropic('claude-sonnet-4-20250514'),
62
+ messages: await ctx.toModelMessages(),
63
+ });
64
+
65
+ return result;
66
+ },
67
+ });
68
+
69
+ const { GET, POST, OPTIONS } = serve({ agents: [supportAgent] });
70
+ ```
71
+
72
+ For custom handlers without the AI SDK, use the core `agent()` export:
73
+
74
+ ```typescript
75
+ import { agent } from '@novu/framework';
76
+ import { serve } from '@novu/framework/next';
77
+
78
+ const supportAgent = agent('support-bot', {
79
+ onMessage: async (message, ctx) => {
80
+ await ctx.reply(`You said: ${message.text}`);
81
+ },
82
+ });
83
+
84
+ const { GET, POST, OPTIONS } = serve({ agents: [supportAgent] });
85
+ ```
86
+
87
+ After your bridge is running, connect channels:
88
+
89
+ ```bash
90
+ npx novu@latest connect --runtime ai-sdk --channel slack
91
+ npx novu@latest sync -b https://your-app.com/api/novu -s "$NOVU_SECRET_KEY"
92
+ ```
93
+
94
+ Bridge runtimes supported by `novu connect`: `ai-sdk`, `langchain`, `custom-code`, `chat-sdk`.
95
+
96
+ ## Notification workflows
97
+
98
+ Write notification workflows as functions that execute business logic and use your preferred libraries for email, SMS, and chat generation. Use [React.Email](https://react.email/), [MJML](https://mjml.io/), or any other template generator.
26
99
 
27
100
  ```typescript
28
101
  import { workflow, CronExpression } from '@novu/framework';
29
102
  import { serve } from '@novu/framework/next';
30
103
  import { z } from 'zod';
31
104
 
32
- // Define your notification workflow
33
105
  const weeklyComments = workflow(
34
106
  'comment-on-post',
35
107
  async ({ payload, step }) => {
@@ -48,9 +120,7 @@ const weeklyComments = workflow(
48
120
  body: `Weekly digest: ${weeklyDigest.events.map(({ payload }) => payload.comment).join(', ')}`,
49
121
  }),
50
122
  {
51
- // Skip the notification if the weekly digest is empty
52
123
  skip: () => weeklyDigest.events.length === 0,
53
- // Non-technical stakeholders can modify strongly-validated copy in Novu Cloud
54
124
  controlSchema: z.object({ prefix: z.string().describe('The prefix of the subject.').default('Hi!') }),
55
125
  }
56
126
  );
@@ -58,9 +128,44 @@ const weeklyComments = workflow(
58
128
  { payloadSchema: z.object({ comment: z.string().describe('The comment on the post.') }) }
59
129
  );
60
130
 
61
- // Use your favorite framework to serve your workflows
62
131
  const { GET, POST, OPTIONS } = serve({ workflows: [weeklyComments] });
63
132
 
64
- // Trigger your notification workflow
65
133
  weeklyComments.trigger({ to: 'user:123', comment: 'This is a comment on a post' });
66
134
  ```
135
+
136
+ Sync workflows with Novu Cloud:
137
+
138
+ ```bash
139
+ npx novu@latest sync -b https://your-app.com/api/novu -s "$NOVU_SECRET_KEY"
140
+ ```
141
+
142
+ For local workflow development with Novu Studio, see the [Novu CLI `dev` command](../novu/README.MD#local-novu-studio).
143
+
144
+ ## Framework adapters
145
+
146
+ Serve workflows and agents from your framework of choice:
147
+
148
+ | Import | Framework |
149
+ | --- | --- |
150
+ | `@novu/framework/next` | Next.js |
151
+ | `@novu/framework/nest` | NestJS |
152
+ | `@novu/framework/express` | Express |
153
+ | `@novu/framework/h3` | H3 / Nuxt |
154
+ | `@novu/framework/lambda` | AWS Lambda |
155
+ | `@novu/framework/sveltekit` | SvelteKit |
156
+ | `@novu/framework/remix` | Remix |
157
+
158
+ Additional exports:
159
+
160
+ | Import | Purpose |
161
+ | --- | --- |
162
+ | `@novu/framework/ai-sdk` | Vercel AI SDK agent helpers |
163
+ | `@novu/framework/step-resolver` | Deploy custom step handlers |
164
+ | `@novu/framework/validators` | Schema validation utilities |
165
+
166
+ ## Links
167
+
168
+ - [Managed agent quickstart](https://docs.novu.co/agents/managed-agent/quickstart)
169
+ - [Framework quickstart](https://docs.novu.co/framework/quickstart)
170
+ - [Novu CLI](../novu/README.MD)
171
+ - [Chat SDK adapter](https://www.npmjs.com/package/@novu/chat-sdk-adapter)
@@ -0,0 +1,4 @@
1
+ {
2
+ "main": "../dist/cjs/ai-sdk/index.cjs",
3
+ "types": "../dist/cjs/ai-sdk/index.d.cts"
4
+ }
@@ -0,0 +1,4 @@
1
+ {
2
+ "main": "../dist/cjs/cards.cjs",
3
+ "types": "../dist/cjs/cards.d.cts"
4
+ }