@bernierllc/onboarding-agent-nextjs 0.0.1 → 0.1.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 CHANGED
@@ -1,45 +1,109 @@
1
1
  # @bernierllc/onboarding-agent-nextjs
2
2
 
3
- ## ⚠️ IMPORTANT NOTICE ⚠️
3
+ Thin Next.js App Router adapter that wraps `OnboardingAgent` into streaming SSE route handlers compatible with the Vercel AI SDK v6 and `onboarding-chat-ui`.
4
4
 
5
- **This package is created solely for the purpose of setting up OIDC (OpenID Connect) trusted publishing with npm.**
5
+ ## Installation
6
6
 
7
- This is **NOT** a functional package and contains **NO** code or functionality beyond the OIDC setup configuration.
7
+ ```bash
8
+ npm install @bernierllc/onboarding-agent-nextjs @bernierllc/onboarding-agent-service
9
+ ```
8
10
 
9
- ## Purpose
11
+ Peer dependency: `next ^14.0.0 || ^15.0.0`.
10
12
 
11
- This package exists to:
12
- 1. Configure OIDC trusted publishing for the package name `@bernierllc/onboarding-agent-nextjs`
13
- 2. Enable secure, token-less publishing from CI/CD workflows
14
- 3. Establish provenance for packages published under this name
13
+ ## Usage
15
14
 
16
- ## What is OIDC Trusted Publishing?
15
+ ### Chat Handler (SSE streaming)
17
16
 
18
- OIDC trusted publishing allows package maintainers to publish packages directly from their CI/CD workflows without needing to manage npm access tokens. Instead, it uses OpenID Connect to establish trust between the CI/CD provider (like GitHub Actions) and npm.
17
+ ```typescript
18
+ // app/api/onboarding/chat/route.ts
19
+ import { createOnboardingRouteHandler } from '@bernierllc/onboarding-agent-nextjs';
20
+ import { agent } from '@/lib/onboarding-agent';
21
+ import { getServerSession } from 'next-auth';
22
+ import type { NextRequest } from 'next/server';
23
+ import { NextResponse } from 'next/server';
19
24
 
20
- ## Setup Instructions
25
+ export const POST = createOnboardingRouteHandler(agent, {
26
+ auth: async (req: NextRequest) => {
27
+ const session = await getServerSession();
28
+ if (!session?.user) {
29
+ return new NextResponse(JSON.stringify({ error: 'Unauthorized' }), { status: 401 });
30
+ }
31
+ return { userId: session.user.id, sessionId: session.user.orgId };
32
+ },
33
+ });
34
+ ```
21
35
 
22
- To properly configure OIDC trusted publishing for this package:
36
+ ### Status Handler
23
37
 
24
- 1. Go to [npmjs.com](https://www.npmjs.com/) and navigate to your package settings
25
- 2. Configure the trusted publisher (e.g., GitHub Actions)
26
- 3. Specify the repository and workflow that should be allowed to publish
27
- 4. Use the configured workflow to publish your actual package
38
+ ```typescript
39
+ // app/api/onboarding/status/route.ts
40
+ import { createStatusRouteHandler } from '@bernierllc/onboarding-agent-nextjs';
41
+ import { agent } from '@/lib/onboarding-agent';
28
42
 
29
- ## DO NOT USE THIS PACKAGE
43
+ export const GET = createStatusRouteHandler(agent);
44
+ ```
30
45
 
31
- This package is a placeholder for OIDC configuration only. It:
32
- - Contains no executable code
33
- - Provides no functionality
34
- - Should not be installed as a dependency
35
- - Exists only for administrative purposes
46
+ ### Rating Handler
36
47
 
37
- ## More Information
48
+ ```typescript
49
+ // app/api/onboarding/rating/route.ts
50
+ import { createRatingRouteHandler } from '@bernierllc/onboarding-agent-nextjs';
51
+ import { agent } from '@/lib/onboarding-agent';
38
52
 
39
- For more details about npm's trusted publishing feature, see:
40
- - [npm Trusted Publishing Documentation](https://docs.npmjs.com/generating-provenance-statements)
41
- - [GitHub Actions OIDC Documentation](https://docs.github.com/en/actions/deployment/security-hardening-your-deployments/about-security-hardening-with-openid-connect)
53
+ export const POST = createRatingRouteHandler(agent);
54
+ ```
42
55
 
43
- ---
56
+ ## API
44
57
 
45
- **Maintained for OIDC setup purposes only**
58
+ ### `createOnboardingRouteHandler(agent, options?)`
59
+
60
+ Returns a `POST` handler that streams `OnboardingAgent.chat()` output as SSE events.
61
+
62
+ **Streaming format** (Vercel AI SDK v6 compatible):
63
+
64
+ ```
65
+ data: {"type":"text-delta","delta":"Hello"}
66
+
67
+ data: {"type":"done"}
68
+
69
+ data: [DONE]
70
+
71
+ ```
72
+
73
+ **Attachment extraction:** Accepts both JSON `{ attachments: [{ filename, dataUrl, mimeType }] }` and `multipart/form-data` with `files[]` fields (converted to base64 data URLs).
74
+
75
+ ### `createStatusRouteHandler(agent, options?)`
76
+
77
+ Returns a `GET` handler that calls `agent.getSetupStatus(sessionId)` and returns JSON.
78
+
79
+ ### `createRatingRouteHandler(agent, options?)`
80
+
81
+ Returns a `POST` handler that accepts `{ rating: 'up' | 'down' }` and calls `agent.recordRating(sessionId, rating)`.
82
+
83
+ ### `OnboardingRouteOptions`
84
+
85
+ | Field | Type | Description |
86
+ |---|---|---|
87
+ | `auth?` | `(req: NextRequest) => Promise<{ userId, sessionId } \| NextResponse>` | Optional auth middleware. Return `NextResponse` to block the request. |
88
+ | `contentType?` | `string` | Override SSE content-type. Default: `text/event-stream`. |
89
+
90
+ ### HTTP Error Mapping
91
+
92
+ | OnboardingAgentError code | HTTP status |
93
+ |---|---|
94
+ | `ONBOARDING_AGENT_INIT_ERROR` | 503 |
95
+ | `ONBOARDING_HANDOFF_ERROR` | 500 |
96
+ | `ONBOARDING_CONFIG_VALIDATION_ERROR` | 400 |
97
+ | `ONBOARDING_PLUGIN_ERROR` | 400 |
98
+ | Any other `OnboardingAgentError` | 500 |
99
+ | Non-OnboardingAgentError | 500 |
100
+
101
+ Error response body: `{ error: string, code?: string }`.
102
+
103
+ ## Node.js Only
104
+
105
+ This package requires a Node.js server runtime. It is not browser-safe.
106
+
107
+ ## License
108
+
109
+ Copyright (c) 2025 Bernier LLC. All rights reserved.
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Error class for all onboarding-agent-nextjs exceptional conditions.
3
+ *
4
+ * Uses ES2022 `Error.cause` chaining per the BernierLLC error propagation
5
+ * standard — underlying errors are never swallowed.
6
+ */
7
+ export declare class OnboardingNextjsError extends Error {
8
+ readonly code: string;
9
+ readonly context?: Record<string, unknown>;
10
+ constructor(message: string, options?: {
11
+ cause?: Error;
12
+ code?: string;
13
+ context?: Record<string, unknown>;
14
+ });
15
+ }
16
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAQA;;;;;GAKG;AACH,qBAAa,qBAAsB,SAAQ,KAAK;IAC9C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;gBAGzC,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE;QACR,KAAK,CAAC,EAAE,KAAK,CAAC;QACd,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;KACnC;CAUJ"}
package/dist/errors.js ADDED
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ /*
3
+ Copyright (c) 2025 Bernier LLC
4
+
5
+ This file is licensed to the client under a limited-use license.
6
+ The client may use and modify this code *only within the scope of the project it was delivered for*.
7
+ Redistribution or use in other products or commercial offerings is not permitted without written consent from Bernier LLC.
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.OnboardingNextjsError = void 0;
11
+ /**
12
+ * Error class for all onboarding-agent-nextjs exceptional conditions.
13
+ *
14
+ * Uses ES2022 `Error.cause` chaining per the BernierLLC error propagation
15
+ * standard — underlying errors are never swallowed.
16
+ */
17
+ class OnboardingNextjsError extends Error {
18
+ code;
19
+ context;
20
+ constructor(message, options) {
21
+ super(message, { ...(options?.cause !== undefined ? { cause: options.cause } : {}) });
22
+ this.name = 'OnboardingNextjsError';
23
+ this.code = options?.code ?? 'ONBOARDING_NEXTJS_ERROR';
24
+ if (options?.context !== undefined) {
25
+ this.context = options.context;
26
+ }
27
+ Error.captureStackTrace?.(this, this.constructor);
28
+ }
29
+ }
30
+ exports.OnboardingNextjsError = OnboardingNextjsError;
31
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":";AAAA;;;;;;EAME;;;AAEF;;;;;GAKG;AACH,MAAa,qBAAsB,SAAQ,KAAK;IACrC,IAAI,CAAS;IACb,OAAO,CAA2B;IAE3C,YACE,OAAe,EACf,OAIC;QAED,KAAK,CAAC,OAAO,EAAE,EAAE,GAAG,CAAC,OAAO,EAAE,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;QACtF,IAAI,CAAC,IAAI,GAAG,uBAAuB,CAAC;QACpC,IAAI,CAAC,IAAI,GAAG,OAAO,EAAE,IAAI,IAAI,yBAAyB,CAAC;QACvD,IAAI,OAAO,EAAE,OAAO,KAAK,SAAS,EAAE,CAAC;YACnC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;QACjC,CAAC;QACD,KAAK,CAAC,iBAAiB,EAAE,CAAC,IAAI,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;IACpD,CAAC;CACF;AApBD,sDAoBC"}
@@ -0,0 +1,65 @@
1
+ import type { NextRequest } from 'next/server';
2
+ import { NextResponse } from 'next/server';
3
+ import type { OnboardingAgent } from '@bernierllc/onboarding-agent-service';
4
+ /**
5
+ * Options shared by all onboarding route handlers.
6
+ */
7
+ export interface OnboardingRouteOptions {
8
+ /**
9
+ * Optional auth middleware. Called before each request.
10
+ * Return `{ userId, sessionId }` to allow the request.
11
+ * Return a `NextResponse` (e.g. 401/403) to block the request immediately.
12
+ */
13
+ auth?: (req: NextRequest) => Promise<{
14
+ userId: string;
15
+ sessionId: string;
16
+ } | NextResponse>;
17
+ /**
18
+ * Override the streaming content-type.
19
+ * Default: `'text/event-stream'`.
20
+ */
21
+ contentType?: string;
22
+ }
23
+ /**
24
+ * Creates a Next.js App Router POST handler that streams `OnboardingAgent`
25
+ * responses as Server-Sent Events (SSE), compatible with Vercel AI SDK v6.
26
+ *
27
+ * Handles both JSON and `multipart/form-data` request bodies, auth middleware,
28
+ * attachment extraction, and HTTP error mapping.
29
+ *
30
+ * ```typescript
31
+ * // app/api/onboarding/chat/route.ts
32
+ * export const POST = createOnboardingRouteHandler(agent, {
33
+ * auth: async (req) => getSessionFromRequest(req),
34
+ * });
35
+ * ```
36
+ */
37
+ export declare function createOnboardingRouteHandler(agent: OnboardingAgent, options?: OnboardingRouteOptions): (req: NextRequest) => Promise<Response>;
38
+ /**
39
+ * Creates a Next.js App Router GET handler that returns the current
40
+ * onboarding goal progress for a session as JSON.
41
+ *
42
+ * The session id is sourced from the auth function when provided, or from
43
+ * the `sessionId` query parameter otherwise.
44
+ *
45
+ * ```typescript
46
+ * // app/api/onboarding/status/route.ts
47
+ * export const GET = createStatusRouteHandler(agent, { auth });
48
+ * ```
49
+ */
50
+ export declare function createStatusRouteHandler(agent: OnboardingAgent, options?: Pick<OnboardingRouteOptions, 'auth'>): (req: NextRequest) => Promise<Response>;
51
+ /**
52
+ * Creates a Next.js App Router POST handler that records a thumbs-up or
53
+ * thumbs-down rating for the most recent conversation in a session.
54
+ *
55
+ * Expected body: `{ rating: 'up' | 'down', sessionId?: string }`.
56
+ * The session id is sourced from the auth function when provided, or from
57
+ * the request body otherwise.
58
+ *
59
+ * ```typescript
60
+ * // app/api/onboarding/rating/route.ts
61
+ * export const POST = createRatingRouteHandler(agent, { auth });
62
+ * ```
63
+ */
64
+ export declare function createRatingRouteHandler(agent: OnboardingAgent, options?: Pick<OnboardingRouteOptions, 'auth'>): (req: NextRequest) => Promise<Response>;
65
+ //# sourceMappingURL=handler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handler.d.ts","sourceRoot":"","sources":["../src/handler.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,KAAK,EAAE,eAAe,EAAyB,MAAM,sCAAsC,CAAC;AAUnG;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC;;;;OAIG;IACH,IAAI,CAAC,EAAE,CAAC,GAAG,EAAE,WAAW,KAAK,OAAO,CAAC;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,GAAG,YAAY,CAAC,CAAC;IAE3F;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAyGD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,4BAA4B,CAC1C,KAAK,EAAE,eAAe,EACtB,OAAO,CAAC,EAAE,sBAAsB,GAC/B,CAAC,GAAG,EAAE,WAAW,KAAK,OAAO,CAAC,QAAQ,CAAC,CAoFzC;AAMD;;;;;;;;;;;GAWG;AACH,wBAAgB,wBAAwB,CACtC,KAAK,EAAE,eAAe,EACtB,OAAO,CAAC,EAAE,IAAI,CAAC,sBAAsB,EAAE,MAAM,CAAC,GAC7C,CAAC,GAAG,EAAE,WAAW,KAAK,OAAO,CAAC,QAAQ,CAAC,CAsCzC;AAMD;;;;;;;;;;;;GAYG;AACH,wBAAgB,wBAAwB,CACtC,KAAK,EAAE,eAAe,EACtB,OAAO,CAAC,EAAE,IAAI,CAAC,sBAAsB,EAAE,MAAM,CAAC,GAC7C,CAAC,GAAG,EAAE,WAAW,KAAK,OAAO,CAAC,QAAQ,CAAC,CA0DzC"}
@@ -0,0 +1,299 @@
1
+ "use strict";
2
+ /*
3
+ Copyright (c) 2025 Bernier LLC
4
+
5
+ This file is licensed to the client under a limited-use license.
6
+ The client may use and modify this code *only within the scope of the project it was delivered for*.
7
+ Redistribution or use in other products or commercial offerings is not permitted without written consent from Bernier LLC.
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.createOnboardingRouteHandler = createOnboardingRouteHandler;
11
+ exports.createStatusRouteHandler = createStatusRouteHandler;
12
+ exports.createRatingRouteHandler = createRatingRouteHandler;
13
+ const server_1 = require("next/server");
14
+ const onboarding_agent_service_1 = require("@bernierllc/onboarding-agent-service");
15
+ const logger_1 = require("@bernierllc/logger");
16
+ const log = (0, logger_1.createLogger)();
17
+ // ---------------------------------------------------------------------------
18
+ // Internal helpers
19
+ // ---------------------------------------------------------------------------
20
+ const encoder = new TextEncoder();
21
+ function sseChunk(chunk) {
22
+ return encoder.encode(`data: ${JSON.stringify(chunk)}\n\n`);
23
+ }
24
+ const SSE_DONE = encoder.encode('data: [DONE]\n\n');
25
+ function jsonError(message, code, status = 500) {
26
+ const body = { error: message };
27
+ if (code !== undefined) {
28
+ body['code'] = code;
29
+ }
30
+ return new Response(JSON.stringify(body), {
31
+ status,
32
+ headers: { 'Content-Type': 'application/json' },
33
+ });
34
+ }
35
+ /**
36
+ * Map an `OnboardingAgentError` code to an HTTP status code.
37
+ */
38
+ function agentErrorStatus(err) {
39
+ switch (err.code) {
40
+ case 'ONBOARDING_AGENT_INIT_ERROR':
41
+ return 503;
42
+ case 'ONBOARDING_HANDOFF_ERROR':
43
+ return 500;
44
+ case 'ONBOARDING_CONFIG_VALIDATION_ERROR':
45
+ case 'ONBOARDING_PLUGIN_ERROR':
46
+ return 400;
47
+ default:
48
+ return 500;
49
+ }
50
+ }
51
+ /**
52
+ * Run auth middleware if provided. Returns `{ userId, sessionId }` on success,
53
+ * or a `Response` to return immediately.
54
+ */
55
+ async function runAuth(req, auth) {
56
+ if (auth === undefined) {
57
+ return { userId: 'anonymous', sessionId: 'default' };
58
+ }
59
+ const result = await auth(req);
60
+ if (result instanceof server_1.NextResponse) {
61
+ return result;
62
+ }
63
+ return result;
64
+ }
65
+ /**
66
+ * Extract `Attachment` objects from a JSON request body.
67
+ */
68
+ function extractJsonAttachments(raw) {
69
+ return raw.map((item) => {
70
+ const a = item;
71
+ return {
72
+ filename: String(a['filename'] ?? ''),
73
+ dataUrl: String(a['dataUrl'] ?? ''),
74
+ mimeType: String(a['mimeType'] ?? ''),
75
+ };
76
+ });
77
+ }
78
+ /**
79
+ * Extract `Attachment` objects from a `FormData` `files[]` field.
80
+ * Each file is read as an ArrayBuffer and encoded as a base64 data URL.
81
+ */
82
+ async function extractMultipartAttachments(formData) {
83
+ const files = formData.getAll('files[]');
84
+ const attachments = [];
85
+ for (const file of files) {
86
+ if (!(file instanceof File))
87
+ continue;
88
+ const buffer = await file.arrayBuffer();
89
+ const base64 = Buffer.from(buffer).toString('base64');
90
+ const dataUrl = `data:${file.type};base64,${base64}`;
91
+ attachments.push({
92
+ filename: file.name,
93
+ dataUrl,
94
+ mimeType: file.type,
95
+ });
96
+ }
97
+ return attachments;
98
+ }
99
+ // ---------------------------------------------------------------------------
100
+ // createOnboardingRouteHandler
101
+ // ---------------------------------------------------------------------------
102
+ /**
103
+ * Creates a Next.js App Router POST handler that streams `OnboardingAgent`
104
+ * responses as Server-Sent Events (SSE), compatible with Vercel AI SDK v6.
105
+ *
106
+ * Handles both JSON and `multipart/form-data` request bodies, auth middleware,
107
+ * attachment extraction, and HTTP error mapping.
108
+ *
109
+ * ```typescript
110
+ * // app/api/onboarding/chat/route.ts
111
+ * export const POST = createOnboardingRouteHandler(agent, {
112
+ * auth: async (req) => getSessionFromRequest(req),
113
+ * });
114
+ * ```
115
+ */
116
+ function createOnboardingRouteHandler(agent, options) {
117
+ const contentType = options?.contentType ?? 'text/event-stream';
118
+ return async (req) => {
119
+ // ── Auth ─────────────────────────────────────────────────────────────────
120
+ const authResult = await runAuth(req, options?.auth);
121
+ if (authResult instanceof Response) {
122
+ return authResult;
123
+ }
124
+ const { userId, sessionId } = authResult;
125
+ // ── Body parsing ─────────────────────────────────────────────────────────
126
+ let message;
127
+ let attachments;
128
+ const reqContentType = req.headers.get('content-type') ?? '';
129
+ try {
130
+ if (reqContentType.includes('multipart/form-data')) {
131
+ const formData = await req.formData();
132
+ message = String(formData.get('message') ?? '');
133
+ attachments = await extractMultipartAttachments(formData);
134
+ }
135
+ else {
136
+ const body = await req.json();
137
+ message = String(body['message'] ?? '');
138
+ const rawAttachments = body['attachments'];
139
+ if (Array.isArray(rawAttachments) && rawAttachments.length > 0) {
140
+ attachments = extractJsonAttachments(rawAttachments);
141
+ }
142
+ }
143
+ }
144
+ catch (err) {
145
+ log.error('[onboarding-agent-nextjs] Body parse error', err instanceof Error ? err : new Error(String(err)));
146
+ return jsonError('Failed to parse request body', undefined, 400);
147
+ }
148
+ // ── Stream ───────────────────────────────────────────────────────────────
149
+ const stream = new ReadableStream({
150
+ async start(controller) {
151
+ try {
152
+ const input = {
153
+ sessionId,
154
+ userId,
155
+ message,
156
+ ...(attachments !== undefined ? { attachments } : {}),
157
+ };
158
+ for await (const chunk of agent.chat(input)) {
159
+ controller.enqueue(sseChunk(chunk));
160
+ }
161
+ controller.enqueue(SSE_DONE);
162
+ }
163
+ catch (err) {
164
+ log.error('[onboarding-agent-nextjs] Stream error', err instanceof Error ? err : new Error(String(err)));
165
+ if (err instanceof onboarding_agent_service_1.OnboardingAgentError) {
166
+ const status = agentErrorStatus(err);
167
+ const errBytes = encoder.encode(`data: ${JSON.stringify({ error: err.message, code: err.code })}\n\n`);
168
+ controller.enqueue(errBytes);
169
+ // status is already 200 (streaming started)
170
+ log.error(`[onboarding-agent-nextjs] OnboardingAgentError (${err.code}) mapped to ${status}`);
171
+ }
172
+ }
173
+ finally {
174
+ controller.close();
175
+ }
176
+ },
177
+ });
178
+ return new Response(stream, {
179
+ status: 200,
180
+ headers: {
181
+ 'Content-Type': contentType,
182
+ 'Cache-Control': 'no-cache',
183
+ Connection: 'keep-alive',
184
+ },
185
+ });
186
+ };
187
+ }
188
+ // ---------------------------------------------------------------------------
189
+ // createStatusRouteHandler
190
+ // ---------------------------------------------------------------------------
191
+ /**
192
+ * Creates a Next.js App Router GET handler that returns the current
193
+ * onboarding goal progress for a session as JSON.
194
+ *
195
+ * The session id is sourced from the auth function when provided, or from
196
+ * the `sessionId` query parameter otherwise.
197
+ *
198
+ * ```typescript
199
+ * // app/api/onboarding/status/route.ts
200
+ * export const GET = createStatusRouteHandler(agent, { auth });
201
+ * ```
202
+ */
203
+ function createStatusRouteHandler(agent, options) {
204
+ return async (req) => {
205
+ // ── Auth ─────────────────────────────────────────────────────────────────
206
+ const authResult = await runAuth(req, options?.auth);
207
+ if (authResult instanceof Response) {
208
+ return authResult;
209
+ }
210
+ // sessionId: from auth or from query param
211
+ let sessionId = authResult.sessionId;
212
+ if (sessionId === 'default' && options?.auth === undefined) {
213
+ const paramSessionId = req.nextUrl.searchParams.get('sessionId');
214
+ if (paramSessionId !== null) {
215
+ sessionId = paramSessionId;
216
+ }
217
+ }
218
+ // ── Delegate to agent ────────────────────────────────────────────────────
219
+ try {
220
+ const status = await agent.getSetupStatus(sessionId);
221
+ return new Response(JSON.stringify(status), {
222
+ status: 200,
223
+ headers: { 'Content-Type': 'application/json' },
224
+ });
225
+ }
226
+ catch (err) {
227
+ log.error('[onboarding-agent-nextjs] Status error', err instanceof Error ? err : new Error(String(err)));
228
+ if (err instanceof onboarding_agent_service_1.OnboardingAgentError) {
229
+ const status = agentErrorStatus(err);
230
+ return jsonError(err.message, err.code, status);
231
+ }
232
+ return jsonError('Internal server error', undefined, 500);
233
+ }
234
+ };
235
+ }
236
+ // ---------------------------------------------------------------------------
237
+ // createRatingRouteHandler
238
+ // ---------------------------------------------------------------------------
239
+ /**
240
+ * Creates a Next.js App Router POST handler that records a thumbs-up or
241
+ * thumbs-down rating for the most recent conversation in a session.
242
+ *
243
+ * Expected body: `{ rating: 'up' | 'down', sessionId?: string }`.
244
+ * The session id is sourced from the auth function when provided, or from
245
+ * the request body otherwise.
246
+ *
247
+ * ```typescript
248
+ * // app/api/onboarding/rating/route.ts
249
+ * export const POST = createRatingRouteHandler(agent, { auth });
250
+ * ```
251
+ */
252
+ function createRatingRouteHandler(agent, options) {
253
+ return async (req) => {
254
+ // ── Auth ─────────────────────────────────────────────────────────────────
255
+ const authResult = await runAuth(req, options?.auth);
256
+ if (authResult instanceof Response) {
257
+ return authResult;
258
+ }
259
+ // ── Parse body ───────────────────────────────────────────────────────────
260
+ let rating;
261
+ let sessionId = authResult.sessionId;
262
+ try {
263
+ const body = await req.json();
264
+ const rawRating = body['rating'];
265
+ if (rawRating !== 'up' && rawRating !== 'down') {
266
+ return jsonError('rating must be "up" or "down"', undefined, 400);
267
+ }
268
+ rating = rawRating;
269
+ // Override sessionId from body when no auth provided
270
+ if (sessionId === 'default' && options?.auth === undefined) {
271
+ const bodySessionId = body['sessionId'];
272
+ if (typeof bodySessionId === 'string') {
273
+ sessionId = bodySessionId;
274
+ }
275
+ }
276
+ }
277
+ catch (err) {
278
+ log.error('[onboarding-agent-nextjs] Rating body parse error', err instanceof Error ? err : new Error(String(err)));
279
+ return jsonError('Failed to parse request body', undefined, 400);
280
+ }
281
+ // ── Delegate to agent ────────────────────────────────────────────────────
282
+ try {
283
+ await agent.recordRating(sessionId, rating);
284
+ return new Response(JSON.stringify({ success: true }), {
285
+ status: 200,
286
+ headers: { 'Content-Type': 'application/json' },
287
+ });
288
+ }
289
+ catch (err) {
290
+ log.error('[onboarding-agent-nextjs] Rating error', err instanceof Error ? err : new Error(String(err)));
291
+ if (err instanceof onboarding_agent_service_1.OnboardingAgentError) {
292
+ const status = agentErrorStatus(err);
293
+ return jsonError(err.message, err.code, status);
294
+ }
295
+ return jsonError('Internal server error', undefined, 500);
296
+ }
297
+ };
298
+ }
299
+ //# sourceMappingURL=handler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handler.js","sourceRoot":"","sources":["../src/handler.ts"],"names":[],"mappings":";AAAA;;;;;;EAME;;AAqJF,oEAuFC;AAkBD,4DAyCC;AAmBD,4DA6DC;AApXD,wCAA2C;AAE3C,mFAA4E;AAC5E,+CAAkD;AAElD,MAAM,GAAG,GAAG,IAAA,qBAAY,GAAE,CAAC;AAwB3B,8EAA8E;AAC9E,mBAAmB;AACnB,8EAA8E;AAE9E,MAAM,OAAO,GAAG,IAAI,WAAW,EAAE,CAAC;AAElC,SAAS,QAAQ,CA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IAAI,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CACpD,CAAC;YAEF,IAAI,GAAG,YAAY,+CAAoB,EAAE,CAAC;gBACxC,MAAM,MAAM,GAAG,gBAAgB,CAAC,GAAG,CAAC,CAAC;gBACrC,OAAO,SAAS,CAAC,GAAG,CAAC,OAAO,EAAE,GAAG,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;YAClD,CAAC;YAED,OAAO,SAAS,CAAC,uBAAuB,EAAE,SAAS,EAAE,GAAG,CAAC,CAAC;QAC5D,CAAC;IACH,CAAC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,25 @@
1
+ /**
2
+ * @bernierllc/onboarding-agent-nextjs
3
+ *
4
+ * Thin Next.js App Router adapter that wraps `OnboardingAgent` into streaming
5
+ * SSE route handlers compatible with the Vercel AI SDK.
6
+ *
7
+ * Quick start:
8
+ * ```typescript
9
+ * // app/api/onboarding/chat/route.ts
10
+ * import { createOnboardingRouteHandler } from '@bernierllc/onboarding-agent-nextjs';
11
+ * export const POST = createOnboardingRouteHandler(agent, { auth });
12
+ *
13
+ * // app/api/onboarding/status/route.ts
14
+ * import { createStatusRouteHandler } from '@bernierllc/onboarding-agent-nextjs';
15
+ * export const GET = createStatusRouteHandler(agent);
16
+ *
17
+ * // app/api/onboarding/rating/route.ts
18
+ * import { createRatingRouteHandler } from '@bernierllc/onboarding-agent-nextjs';
19
+ * export const POST = createRatingRouteHandler(agent);
20
+ * ```
21
+ */
22
+ export { createOnboardingRouteHandler, createStatusRouteHandler, createRatingRouteHandler, } from './handler';
23
+ export type { OnboardingRouteOptions } from './handler';
24
+ export { OnboardingNextjsError } from './errors';
25
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAQA;;;;;;;;;;;;;;;;;;;;GAoBG;AAGH,OAAO,EACL,4BAA4B,EAC5B,wBAAwB,EACxB,wBAAwB,GACzB,MAAM,WAAW,CAAC;AACnB,YAAY,EAAE,sBAAsB,EAAE,MAAM,WAAW,CAAC;AAGxD,OAAO,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ /*
3
+ Copyright (c) 2025 Bernier LLC
4
+
5
+ This file is licensed to the client under a limited-use license.
6
+ The client may use and modify this code *only within the scope of the project it was delivered for*.
7
+ Redistribution or use in other products or commercial offerings is not permitted without written consent from Bernier LLC.
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.OnboardingNextjsError = exports.createRatingRouteHandler = exports.createStatusRouteHandler = exports.createOnboardingRouteHandler = void 0;
11
+ /**
12
+ * @bernierllc/onboarding-agent-nextjs
13
+ *
14
+ * Thin Next.js App Router adapter that wraps `OnboardingAgent` into streaming
15
+ * SSE route handlers compatible with the Vercel AI SDK.
16
+ *
17
+ * Quick start:
18
+ * ```typescript
19
+ * // app/api/onboarding/chat/route.ts
20
+ * import { createOnboardingRouteHandler } from '@bernierllc/onboarding-agent-nextjs';
21
+ * export const POST = createOnboardingRouteHandler(agent, { auth });
22
+ *
23
+ * // app/api/onboarding/status/route.ts
24
+ * import { createStatusRouteHandler } from '@bernierllc/onboarding-agent-nextjs';
25
+ * export const GET = createStatusRouteHandler(agent);
26
+ *
27
+ * // app/api/onboarding/rating/route.ts
28
+ * import { createRatingRouteHandler } from '@bernierllc/onboarding-agent-nextjs';
29
+ * export const POST = createRatingRouteHandler(agent);
30
+ * ```
31
+ */
32
+ // ── Public API ────────────────────────────────────────────────────────────────
33
+ var handler_1 = require("./handler");
34
+ Object.defineProperty(exports, "createOnboardingRouteHandler", { enumerable: true, get: function () { return handler_1.createOnboardingRouteHandler; } });
35
+ Object.defineProperty(exports, "createStatusRouteHandler", { enumerable: true, get: function () { return handler_1.createStatusRouteHandler; } });
36
+ Object.defineProperty(exports, "createRatingRouteHandler", { enumerable: true, get: function () { return handler_1.createRatingRouteHandler; } });
37
+ // ── Errors ────────────────────────────────────────────────────────────────────
38
+ var errors_1 = require("./errors");
39
+ Object.defineProperty(exports, "OnboardingNextjsError", { enumerable: true, get: function () { return errors_1.OnboardingNextjsError; } });
40
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;EAME;;;AAEF;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,iFAAiF;AACjF,qCAImB;AAHjB,uHAAA,4BAA4B,OAAA;AAC5B,mHAAA,wBAAwB,OAAA;AACxB,mHAAA,wBAAwB,OAAA;AAI1B,iFAAiF;AACjF,mCAAiD;AAAxC,+GAAA,qBAAqB,OAAA"}
package/package.json CHANGED
@@ -1,10 +1,71 @@
1
1
  {
2
2
  "name": "@bernierllc/onboarding-agent-nextjs",
3
- "version": "0.0.1",
4
- "description": "OIDC trusted publishing setup package for @bernierllc/onboarding-agent-nextjs",
3
+ "version": "0.1.0",
4
+ "description": "Next.js App Router adapter for OnboardingAgent: streaming SSE route handler, attachment extraction, and auth middleware.",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "browser": false,
5
8
  "keywords": [
6
- "oidc",
7
- "trusted-publishing",
8
- "setup"
9
- ]
10
- }
9
+ "onboarding-agent",
10
+ "nextjs",
11
+ "app-router",
12
+ "streaming",
13
+ "sse",
14
+ "adapter",
15
+ "bernierllc"
16
+ ],
17
+ "author": "Bernier LLC",
18
+ "license": "Bernier LLC",
19
+ "dependencies": {
20
+ "@bernierllc/logger": "^1.7.0",
21
+ "@bernierllc/onboarding-agent-service": "0.1.0"
22
+ },
23
+ "peerDependencies": {
24
+ "next": "^14.0.0 || ^15.0.0"
25
+ },
26
+ "devDependencies": {
27
+ "@types/jest": "^29.5.5",
28
+ "@types/node": "^20.6.0",
29
+ "jest": "^29.6.4",
30
+ "next": "^15.0.0",
31
+ "rimraf": "^5.0.1",
32
+ "ts-jest": "^29.1.1",
33
+ "typescript": "^5.2.2"
34
+ },
35
+ "files": [
36
+ "dist/**/*",
37
+ "README.md",
38
+ "LICENSE"
39
+ ],
40
+ "repository": {
41
+ "type": "git",
42
+ "url": "git+https://github.com/bernier-llc/tools.git"
43
+ },
44
+ "engines": {
45
+ "node": ">=18.0.0"
46
+ },
47
+ "publishConfig": {
48
+ "access": "public",
49
+ "registry": "https://registry.npmjs.org/"
50
+ },
51
+ "bernierllc": {
52
+ "runtime": "node",
53
+ "category": "service",
54
+ "integration": {
55
+ "neverhub": "not-applicable",
56
+ "neveradmin": "not-applicable",
57
+ "logger": "integrated"
58
+ }
59
+ },
60
+ "scripts": {
61
+ "build": "tsc",
62
+ "dev": "tsc --watch",
63
+ "test": "jest",
64
+ "test:watch": "jest --watch",
65
+ "test:run": "jest",
66
+ "test:coverage": "jest --coverage",
67
+ "lint": "eslint src/**/*.ts",
68
+ "clean": "rimraf dist",
69
+ "prebuild": "npm run clean"
70
+ }
71
+ }