@agentnext/next 0.1.1 → 0.1.3

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 (2) hide show
  1. package/README.md +107 -0
  2. package/package.json +2 -2
package/README.md ADDED
@@ -0,0 +1,107 @@
1
+ # @agentnext/next
2
+
3
+ Next.js integration for AgentNext — wrap your `next.config` with AgentKit support for App Router projects.
4
+
5
+ ## Features
6
+
7
+ - `withAgentKit` — a `next.config` wrapper that extends the webpack pipeline for AgentKit compatibility
8
+ - App Router and Pages Router compatible
9
+
10
+ ## Installation
11
+
12
+ ```bash
13
+ npm install @agentnext/next @agentnext/core
14
+ ```
15
+
16
+ > **Peer dependencies:** `next` ≥ 14
17
+
18
+ ## Usage
19
+
20
+ ### Configure `next.config`
21
+
22
+ Wrap your existing Next.js config with `withAgentKit`. It is safe to compose with other wrappers:
23
+
24
+ ```ts
25
+ // next.config.ts
26
+ import { withAgentKit } from "@agentnext/next";
27
+
28
+ const nextConfig = {
29
+ // your existing Next.js options
30
+ };
31
+
32
+ export default withAgentKit(nextConfig);
33
+ ```
34
+
35
+ Or in CommonJS:
36
+
37
+ ```js
38
+ // next.config.js
39
+ const { withAgentKit } = require("@agentnext/next");
40
+
41
+ module.exports = withAgentKit({
42
+ // your existing Next.js options
43
+ });
44
+ ```
45
+
46
+ ### Full Next.js + AgentNext setup
47
+
48
+ Combine `withAgentKit` in config with `@agentnext/react` bindings in your layout:
49
+
50
+ ```tsx
51
+ // app/layout.tsx
52
+ import { AgentProvider } from "@agentnext/react";
53
+
54
+ export default function RootLayout({ children }: { children: React.ReactNode }) {
55
+ return (
56
+ <html lang="en">
57
+ <body>
58
+ <AgentProvider>{children}</AgentProvider>
59
+ </body>
60
+ </html>
61
+ );
62
+ }
63
+ ```
64
+
65
+ ```tsx
66
+ // app/shop/page.tsx
67
+ "use client";
68
+ import { z } from "zod";
69
+ import { action } from "@agentnext/core";
70
+ import { useAgentAction } from "@agentnext/react";
71
+
72
+ const checkout = action({
73
+ name: "checkout",
74
+ description: "Initiates the checkout flow for the current cart.",
75
+ input: z.object({ cartId: z.string() }),
76
+ permissions: { authentication: true, confirmation: true },
77
+ execute: async ({ cartId }) => {
78
+ const order = await api.checkout(cartId);
79
+ return order;
80
+ },
81
+ });
82
+
83
+ export default function ShopPage() {
84
+ useAgentAction(checkout);
85
+ return <div>Shop</div>;
86
+ }
87
+ ```
88
+
89
+ ### Composing with other config wrappers
90
+
91
+ `withAgentKit` forwards any custom `webpack` function from your config, so it composes safely with other wrappers like `next-transpile-modules`:
92
+
93
+ ```ts
94
+ import { withAgentKit } from "@agentnext/next";
95
+
96
+ export default withAgentKit(
97
+ withSomeOtherPlugin({
98
+ // config
99
+ })
100
+ );
101
+ ```
102
+
103
+ ## API Reference
104
+
105
+ | Export | Description |
106
+ | --------------- | -------------------------------------------------------- |
107
+ | `withAgentKit(nextConfig?)` | Wraps a Next.js config object, extending webpack for AgentKit. Returns a new config object. |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agentnext/next",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "description": "Next.js adapter for AgentNext — App Router integration, server execution, auth propagation",
5
5
  "license": "MIT",
6
6
  "author": "AgentNext",
@@ -35,7 +35,7 @@
35
35
  "prepublishOnly": "npm run build"
36
36
  },
37
37
  "dependencies": {
38
- "@agentnext/core": "^0.1.0"
38
+ "@agentnext/core": "^0.1.3"
39
39
  },
40
40
  "peerDependencies": {
41
41
  "next": "^14.0.0 || ^15.0.0"