@novu/framework 2.11.0 → 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.
- package/README.md +114 -9
- package/ai-sdk/package.json +4 -0
- package/cards/package.json +4 -0
- package/dist/{esm/index-dylq0Kmx.d.ts → cjs/agent.types-DdgaVUb7.d.cts} +356 -192
- package/dist/cjs/ai-sdk/index.cjs +1 -0
- package/dist/cjs/ai-sdk/index.d.cts +39 -0
- package/dist/cjs/cards.cjs +57 -0
- package/dist/cjs/cards.d.cts +2 -0
- package/dist/cjs/{health-check.types-uaDLF5bo.d.cts → health-check.types-CkUmYLNG.d.cts} +34 -140
- package/dist/cjs/index-BCp3U0UG.d.cts +189 -0
- package/dist/cjs/index.cjs +138 -135
- package/dist/cjs/index.d.cts +5 -3
- package/dist/cjs/internal/index.cjs +1 -1
- package/dist/cjs/internal/index.d.cts +96 -4
- package/dist/cjs/jsx-dev-runtime.cjs +1 -1
- package/dist/cjs/jsx-runtime.cjs +1 -1
- package/dist/cjs/langchain/index.cjs +1 -0
- package/dist/cjs/langchain/index.d.cts +105 -0
- package/dist/cjs/servers/express.cjs +137 -134
- package/dist/cjs/servers/express.d.cts +6 -4
- package/dist/cjs/servers/h3.cjs +136 -133
- package/dist/cjs/servers/h3.d.cts +6 -4
- package/dist/cjs/servers/lambda.cjs +138 -135
- package/dist/cjs/servers/lambda.d.cts +6 -5
- package/dist/cjs/servers/nest.cjs +136 -133
- package/dist/cjs/servers/nest.d.cts +21 -7
- package/dist/cjs/servers/next.cjs +138 -135
- package/dist/cjs/servers/next.d.cts +6 -4
- package/dist/cjs/servers/nuxt.cjs +136 -133
- package/dist/cjs/servers/nuxt.d.cts +6 -4
- package/dist/cjs/servers/remix.cjs +138 -135
- package/dist/cjs/servers/remix.d.cts +6 -4
- package/dist/cjs/servers/sveltekit.cjs +136 -133
- package/dist/cjs/servers/sveltekit.d.cts +6 -4
- package/dist/cjs/step-resolver.d.cts +3 -2
- package/dist/cjs/{subscriber.types-PRaHFLJu.d.cts → subscriber.types-DxMMRBIi.d.cts} +2 -78
- package/dist/cjs/util.types-DaFfsxgy.d.cts +78 -0
- package/dist/{cjs/index-D-SLxj--.d.cts → esm/agent.types-Bu3DhlVb.d.ts} +356 -192
- package/dist/esm/ai-sdk/index.d.ts +39 -0
- package/dist/esm/ai-sdk/index.js +1 -0
- package/dist/esm/cards.d.ts +2 -0
- package/dist/esm/cards.js +1 -0
- package/dist/esm/{chunk-K7PM3FEJ.js → chunk-3XT6S7TZ.js} +14 -14
- package/dist/esm/chunk-3ZWME5KT.js +0 -0
- package/dist/esm/chunk-C3P3ZH2I.js +36 -0
- package/dist/esm/chunk-FHYMHX3T.js +1 -0
- package/dist/esm/chunk-KLIOXJR3.js +1 -0
- package/dist/esm/chunk-W6DIBD4Z.js +1 -0
- package/dist/esm/chunk-YF62BBGH.js +98 -0
- package/dist/esm/{health-check.types-XZwesagD.d.ts → health-check.types-nDCnGlmX.d.ts} +34 -140
- package/dist/esm/index-DEehllqa.d.ts +189 -0
- package/dist/esm/index.d.ts +5 -3
- package/dist/esm/index.js +1 -1
- package/dist/esm/internal/index.d.ts +96 -4
- package/dist/esm/internal/index.js +1 -1
- package/dist/esm/jsx-dev-runtime.js +1 -1
- package/dist/esm/jsx-runtime-7EPQR56T.js +1 -0
- package/dist/esm/jsx-runtime.js +1 -1
- package/dist/esm/langchain/index.d.ts +105 -0
- package/dist/esm/langchain/index.js +1 -0
- package/dist/esm/servers/express.d.ts +6 -4
- package/dist/esm/servers/express.js +1 -1
- package/dist/esm/servers/h3.d.ts +6 -4
- package/dist/esm/servers/h3.js +1 -1
- package/dist/esm/servers/lambda.d.ts +6 -5
- package/dist/esm/servers/lambda.js +1 -1
- package/dist/esm/servers/nest.d.ts +21 -7
- package/dist/esm/servers/nest.js +1 -1
- package/dist/esm/servers/next.d.ts +6 -4
- package/dist/esm/servers/next.js +1 -1
- package/dist/esm/servers/nuxt.d.ts +6 -4
- package/dist/esm/servers/nuxt.js +1 -1
- package/dist/esm/servers/remix.d.ts +6 -4
- package/dist/esm/servers/remix.js +1 -1
- package/dist/esm/servers/sveltekit.d.ts +6 -4
- package/dist/esm/servers/sveltekit.js +1 -1
- package/dist/esm/step-resolver.d.ts +3 -2
- package/dist/esm/step-resolver.js +1 -1
- package/dist/esm/{subscriber.types-CC7F0JO_.d.ts → subscriber.types-BbyO_Cz6.d.ts} +2 -78
- package/dist/esm/util.types-DaFfsxgy.d.ts +78 -0
- package/dist/esm/validators.js +1 -1
- package/package.json +55 -7
- package/dist/esm/chunk-52LSX2V5.js +0 -1
- package/dist/esm/chunk-LJUUDK2J.js +0 -130
- package/dist/esm/chunk-N4PZBM53.js +0 -1
package/README.md
CHANGED
|
@@ -7,14 +7,17 @@
|
|
|
7
7
|
</a>
|
|
8
8
|
</div>
|
|
9
9
|
|
|
10
|
-
#
|
|
10
|
+
# Novu Framework
|
|
11
11
|
|
|
12
12
|
[](https://www.npmjs.org/package/@novu/framework)
|
|
13
13
|
[](https://www.npmjs.com/package/@novu/framework)
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
`@novu/framework` is Novu's code-first SDK for two things:
|
|
16
16
|
|
|
17
|
-
|
|
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
|
-
##
|
|
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)
|