@bernierllc/admin-chat-agent-suite 0.0.1 → 0.1.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.
- package/LICENSE +5 -0
- package/README.md +185 -27
- package/dist/errors.d.ts +15 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +27 -0
- package/dist/errors.js.map +1 -0
- package/dist/factory.d.ts +37 -0
- package/dist/factory.d.ts.map +1 -0
- package/dist/factory.js +88 -0
- package/dist/factory.js.map +1 -0
- package/dist/index.d.ts +38 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +85 -0
- package/dist/index.js.map +1 -0
- package/dist/types.d.ts +82 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +10 -0
- package/dist/types.js.map +1 -0
- package/package.json +90 -7
package/LICENSE
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
Copyright (c) 2025 Bernier LLC
|
|
2
|
+
|
|
3
|
+
This file is licensed to the client under a limited-use license.
|
|
4
|
+
The client may use and modify this code *only within the scope of the project it was delivered for*.
|
|
5
|
+
Redistribution or use in other products or commercial offerings is not permitted without written consent from Bernier LLC.
|
package/README.md
CHANGED
|
@@ -1,45 +1,203 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
Copyright (c) 2025 Bernier LLC
|
|
3
|
+
|
|
4
|
+
This file is licensed to the client under a limited-use license.
|
|
5
|
+
The client may use and modify this code *only within the scope of the project it was delivered for*.
|
|
6
|
+
Redistribution or use in other products or commercial offerings is not permitted without written consent from Bernier LLC.
|
|
7
|
+
-->
|
|
8
|
+
|
|
1
9
|
# @bernierllc/admin-chat-agent-suite
|
|
2
10
|
|
|
3
|
-
|
|
11
|
+
Drop-in bundle for embedding an LLM-powered admin assistant that can execute privileged actions, stream results, show what changed, and persist conversation history.
|
|
12
|
+
|
|
13
|
+
One `createAdminChatAgent(config)` call wires together provider, tools, permissions, persistence, and UI exports.
|
|
14
|
+
|
|
15
|
+
**No Vercel AI SDK anywhere in this package or its dependency graph.**
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
## Installation
|
|
4
20
|
|
|
5
|
-
|
|
21
|
+
```bash
|
|
22
|
+
npm install @bernierllc/admin-chat-agent-suite
|
|
23
|
+
```
|
|
6
24
|
|
|
7
|
-
|
|
25
|
+
Peer dependencies:
|
|
8
26
|
|
|
9
|
-
|
|
27
|
+
```bash
|
|
28
|
+
npm install react react-dom next
|
|
29
|
+
# Optional:
|
|
30
|
+
npm install @bernierllc/neverhub-adapter
|
|
31
|
+
```
|
|
10
32
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
33
|
+
---
|
|
34
|
+
|
|
35
|
+
## Usage
|
|
36
|
+
|
|
37
|
+
```typescript
|
|
38
|
+
import {
|
|
39
|
+
createAdminChatAgent,
|
|
40
|
+
InMemoryConversationStore,
|
|
41
|
+
} from '@bernierllc/admin-chat-agent-suite';
|
|
42
|
+
|
|
43
|
+
// 1. Define your domain tools
|
|
44
|
+
const getBookings = {
|
|
45
|
+
name: 'getBookings',
|
|
46
|
+
description: 'Fetch bookings for a date range',
|
|
47
|
+
inputSchema: {
|
|
48
|
+
type: 'object',
|
|
49
|
+
properties: {
|
|
50
|
+
startDate: { type: 'string' },
|
|
51
|
+
endDate: { type: 'string' },
|
|
52
|
+
},
|
|
53
|
+
required: ['startDate'],
|
|
54
|
+
},
|
|
55
|
+
permissions: ['admin:bookings:read'],
|
|
56
|
+
async execute(input: { startDate: string; endDate?: string }) {
|
|
57
|
+
const bookings = await db.bookings.findMany({ where: { date: { gte: input.startDate } } });
|
|
58
|
+
return { success: true, message: `Found ${bookings.length} bookings`, data: bookings };
|
|
59
|
+
},
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
// 2. Wire the suite
|
|
63
|
+
const { agent, routeHandler, components } = createAdminChatAgent({
|
|
64
|
+
provider: myOpenAIProvider, // AIProvider from @bernierllc/ai-provider-core or ai-provider-router
|
|
65
|
+
tools: [getBookings],
|
|
66
|
+
permissionResolver: async (authCtx) => resolvePermissions(authCtx),
|
|
67
|
+
store: new InMemoryConversationStore(), // Replace with Prisma adapter in production
|
|
68
|
+
maxTurns: 10,
|
|
69
|
+
timeoutMs: 30_000,
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
// 3. Next.js route handler (app/api/chat/admin/route.ts)
|
|
73
|
+
export const POST = routeHandler({
|
|
74
|
+
auth: async (request) => {
|
|
75
|
+
const session = await getServerSession(authOptions);
|
|
76
|
+
if (!session?.user) throw new AdminAgentRouteUnauthorizedError('Unauthorized');
|
|
77
|
+
return { userId: session.user.id, orgId: session.user.orgId };
|
|
78
|
+
},
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
// 4. React layout (app/(admin)/layout.tsx)
|
|
82
|
+
const { AdminAgentProvider, AdminAgentTrigger, AdminAgentPanel } = components;
|
|
83
|
+
|
|
84
|
+
export default function AdminLayout({ children }: { children: React.ReactNode }) {
|
|
85
|
+
return (
|
|
86
|
+
<AdminAgentProvider url="/api/chat/admin">
|
|
87
|
+
{children}
|
|
88
|
+
<AdminAgentTrigger position="bottom-right" />
|
|
89
|
+
<AdminAgentPanel />
|
|
90
|
+
</AdminAgentProvider>
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
```
|
|
15
94
|
|
|
16
|
-
|
|
95
|
+
---
|
|
17
96
|
|
|
18
|
-
|
|
97
|
+
## API Reference
|
|
98
|
+
|
|
99
|
+
### `createAdminChatAgent(config)`
|
|
100
|
+
|
|
101
|
+
Creates and returns `{ agent, routeHandler, components }`.
|
|
102
|
+
|
|
103
|
+
**Config** (`AdminChatAgentConfig` = `AdminAgentConfig` from `@bernierllc/admin-agent-service`):
|
|
104
|
+
|
|
105
|
+
| Field | Required | Description |
|
|
106
|
+
|-------|----------|-------------|
|
|
107
|
+
| `provider` | yes | `AIProvider` instance from `@bernierllc/ai-provider-core` or `@bernierllc/ai-provider-router` |
|
|
108
|
+
| `tools` | yes | Array of `ToolDefinition` from `@bernierllc/agent-tool-registry` |
|
|
109
|
+
| `permissionResolver` | yes | `(authCtx: AuthContext) => Promise<string[]>` |
|
|
110
|
+
| `store` | yes | `ConversationStore` implementation |
|
|
111
|
+
| `systemPromptBuilder` | no | `(authCtx, orgCtx) => Promise<string>` |
|
|
112
|
+
| `maxTurns` | no | Max LLM turns per chat (default: 10) |
|
|
113
|
+
| `timeoutMs` | no | Per-turn timeout ms (default: 30000) |
|
|
114
|
+
| `rateLimitHook` | no | `RateLimitHook` implementation |
|
|
115
|
+
| `featureGateHook` | no | `FeatureGateHook` implementation |
|
|
116
|
+
|
|
117
|
+
**Return value:**
|
|
118
|
+
|
|
119
|
+
- `agent: AdminAgent` — Use `agent.chat(message, authCtx)` directly on the server.
|
|
120
|
+
- `routeHandler: RouteHandlerFactory` — Call with `{ auth }` to get a Next.js POST handler.
|
|
121
|
+
- `components: AdminChatAgentComponents` — All React components and the `useAdminAgentChat` hook.
|
|
122
|
+
|
|
123
|
+
### Re-exported Components
|
|
124
|
+
|
|
125
|
+
The `components` bag (and top-level exports) include:
|
|
126
|
+
|
|
127
|
+
| Component / Hook | Description |
|
|
128
|
+
|-----------------|-------------|
|
|
129
|
+
| `AdminAgentProvider` | Root React context provider — wrap your admin layout |
|
|
130
|
+
| `AdminAgentTrigger` | Floating sparkles button that opens the panel |
|
|
131
|
+
| `AdminAgentPanel` | Chat sheet/drawer |
|
|
132
|
+
| `AdminAgentPanelHeader` | Panel title bar |
|
|
133
|
+
| `MessageList` | Scrollable message history |
|
|
134
|
+
| `MessageBubble` | Single message bubble (user or assistant) |
|
|
135
|
+
| `ToolResultCard` | Shows tool call success/failure |
|
|
136
|
+
| `ChangeSummaryCard` | Renders changeset rollup markdown |
|
|
137
|
+
| `AgentStatusBar` | Thinking/executing/idle indicator |
|
|
138
|
+
| `useAdminAgentChat` | Hook for programmatic control |
|
|
139
|
+
|
|
140
|
+
### Re-exported Utilities
|
|
141
|
+
|
|
142
|
+
```typescript
|
|
143
|
+
import {
|
|
144
|
+
InMemoryConversationStore, // Development-only store
|
|
145
|
+
AdminChatAgentSuiteError, // Suite-level error
|
|
146
|
+
AdminAgentConfigError, // From admin-agent-service
|
|
147
|
+
AdminAgentRouteUnauthorizedError, // From admin-agent-nextjs
|
|
148
|
+
// ... all sub-package errors
|
|
149
|
+
} from '@bernierllc/admin-chat-agent-suite';
|
|
150
|
+
```
|
|
19
151
|
|
|
20
|
-
|
|
152
|
+
---
|
|
21
153
|
|
|
22
|
-
|
|
154
|
+
## MECE Boundaries
|
|
23
155
|
|
|
24
|
-
|
|
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
|
|
156
|
+
### vs. `@bernierllc/chat-suite`
|
|
28
157
|
|
|
29
|
-
|
|
158
|
+
`chat-suite` is channel-agnostic **human-to-human** chat infrastructure: WebSocket connections, message threads, read receipts, presence. No LLM, no tool execution.
|
|
30
159
|
|
|
31
|
-
|
|
32
|
-
- Contains no executable code
|
|
33
|
-
- Provides no functionality
|
|
34
|
-
- Should not be installed as a dependency
|
|
35
|
-
- Exists only for administrative purposes
|
|
160
|
+
`admin-chat-agent-suite` is an **LLM agent** embedded in the admin UI that executes privileged domain actions on behalf of the authenticated admin. Zero overlap.
|
|
36
161
|
|
|
37
|
-
|
|
162
|
+
### vs. `@bernierllc/chat-agent-suite`
|
|
38
163
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
-
|
|
164
|
+
`chat-agent-suite` provides support/feedback agents for **end-user channels** (Slack, in-app support, escalation to human). Persona-driven, flow-based, MCP/RAG access.
|
|
165
|
+
|
|
166
|
+
`admin-chat-agent-suite` is an **admin-privilege-action agent** embedded in the admin dashboard. Tool-execution-driven, permission-scoped, change-tracking, streaming. Different domains, different tools, different UX surface.
|
|
42
167
|
|
|
43
168
|
---
|
|
44
169
|
|
|
45
|
-
|
|
170
|
+
## Integration Status
|
|
171
|
+
|
|
172
|
+
### Logger Integration
|
|
173
|
+
|
|
174
|
+
This suite uses `@bernierllc/logger` throughout all sub-packages. Logging is automatic and requires no configuration. The logger outputs structured JSON and writes to stdout at INFO level by default.
|
|
175
|
+
|
|
176
|
+
```typescript
|
|
177
|
+
// Logger integration is automatic — no setup needed.
|
|
178
|
+
// Set LOG_LEVEL env var to control verbosity: debug | info | warn | error
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
### NeverHub Integration
|
|
182
|
+
|
|
183
|
+
All service-tier sub-packages auto-detect `@bernierllc/neverhub-adapter` at runtime and register themselves if NeverHub is available. NeverHub integration is optional — the suite works without it.
|
|
184
|
+
|
|
185
|
+
```typescript
|
|
186
|
+
// NeverHub integration activates automatically if installed:
|
|
187
|
+
// npm install @bernierllc/neverhub-adapter
|
|
188
|
+
// No code changes needed; services register themselves on initialize().
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
Graceful degradation is built in — if NeverHub is not installed or not reachable, the suite continues to operate normally.
|
|
192
|
+
|
|
193
|
+
---
|
|
194
|
+
|
|
195
|
+
## No Vercel AI SDK
|
|
196
|
+
|
|
197
|
+
This suite and all its sub-packages are built on the BernierLLC AI abstraction layer (`@bernierllc/ai-provider-core`, `@bernierllc/ai-provider-router`, `@bernierllc/ai-agent-runtime`). The Vercel AI SDK (`ai` package) is not used anywhere in this dependency graph.
|
|
198
|
+
|
|
199
|
+
---
|
|
200
|
+
|
|
201
|
+
## License
|
|
202
|
+
|
|
203
|
+
Copyright (c) 2025 Bernier LLC. See LICENSE for terms.
|
package/dist/errors.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base error class for @bernierllc/admin-chat-agent-suite.
|
|
3
|
+
*
|
|
4
|
+
* Uses ES2022 Error.cause chaining so the full error chain is preserved.
|
|
5
|
+
*/
|
|
6
|
+
export declare class AdminChatAgentSuiteError extends Error {
|
|
7
|
+
readonly code: string;
|
|
8
|
+
readonly context?: Record<string, unknown>;
|
|
9
|
+
constructor(message: string, options?: {
|
|
10
|
+
cause?: Error;
|
|
11
|
+
code?: string;
|
|
12
|
+
context?: Record<string, unknown>;
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAQA;;;;GAIG;AACH,qBAAa,wBAAyB,SAAQ,KAAK;IACjD,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;CAOJ"}
|
package/dist/errors.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
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.AdminChatAgentSuiteError = void 0;
|
|
11
|
+
/**
|
|
12
|
+
* Base error class for @bernierllc/admin-chat-agent-suite.
|
|
13
|
+
*
|
|
14
|
+
* Uses ES2022 Error.cause chaining so the full error chain is preserved.
|
|
15
|
+
*/
|
|
16
|
+
class AdminChatAgentSuiteError extends Error {
|
|
17
|
+
code;
|
|
18
|
+
context;
|
|
19
|
+
constructor(message, options) {
|
|
20
|
+
super(message, { cause: options?.cause });
|
|
21
|
+
this.name = 'AdminChatAgentSuiteError';
|
|
22
|
+
this.code = options?.code ?? 'ADMIN_CHAT_AGENT_SUITE_ERROR';
|
|
23
|
+
this.context = options?.context;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
exports.AdminChatAgentSuiteError = AdminChatAgentSuiteError;
|
|
27
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":";AAAA;;;;;;EAME;;;AAEF;;;;GAIG;AACH,MAAa,wBAAyB,SAAQ,KAAK;IACxC,IAAI,CAAS;IACb,OAAO,CAA2B;IAE3C,YACE,OAAe,EACf,OAIC;QAED,KAAK,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC;QAC1C,IAAI,CAAC,IAAI,GAAG,0BAA0B,CAAC;QACvC,IAAI,CAAC,IAAI,GAAG,OAAO,EAAE,IAAI,IAAI,8BAA8B,CAAC;QAC5D,IAAI,CAAC,OAAO,GAAG,OAAO,EAAE,OAAO,CAAC;IAClC,CAAC;CACF;AAjBD,4DAiBC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { AdminChatAgentConfig, AdminChatAgentResult } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Create a fully-wired admin chat agent bundle in a single call.
|
|
4
|
+
*
|
|
5
|
+
* Returns:
|
|
6
|
+
* - `agent` — The AdminAgent instance for server-side use.
|
|
7
|
+
* - `routeHandler` — Factory function for a Next.js App Router POST handler.
|
|
8
|
+
* - `components` — All React components and the useAdminAgentChat hook.
|
|
9
|
+
*
|
|
10
|
+
* No Vercel AI SDK is used anywhere in this package or its dependencies.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* import { createAdminChatAgent } from '@bernierllc/admin-chat-agent-suite';
|
|
15
|
+
* import { InMemoryConversationStore } from '@bernierllc/agent-conversation-store';
|
|
16
|
+
*
|
|
17
|
+
* const { agent, routeHandler, components } = createAdminChatAgent({
|
|
18
|
+
* provider: myAIProvider,
|
|
19
|
+
* tools: [getBookingsTool, addServiceTool],
|
|
20
|
+
* permissionResolver: async (ctx) => resolvePermissions(ctx),
|
|
21
|
+
* store: new InMemoryConversationStore(),
|
|
22
|
+
* });
|
|
23
|
+
*
|
|
24
|
+
* // app/api/chat/admin/route.ts
|
|
25
|
+
* export const POST = routeHandler({
|
|
26
|
+
* auth: async (req) => getAuthContextFromRequest(req),
|
|
27
|
+
* });
|
|
28
|
+
*
|
|
29
|
+
* // React layout
|
|
30
|
+
* const { AdminAgentProvider, AdminAgentTrigger, AdminAgentPanel } = components;
|
|
31
|
+
* ```
|
|
32
|
+
*
|
|
33
|
+
* @throws {AdminChatAgentSuiteError} When the agent cannot be created due to
|
|
34
|
+
* invalid configuration.
|
|
35
|
+
*/
|
|
36
|
+
export declare function createAdminChatAgent(config: AdminChatAgentConfig): AdminChatAgentResult;
|
|
37
|
+
//# sourceMappingURL=factory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../src/factory.ts"],"names":[],"mappings":"AA2BA,OAAO,KAAK,EACV,oBAAoB,EACpB,oBAAoB,EAGrB,MAAM,SAAS,CAAC;AAEjB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,oBAAoB,GAC3B,oBAAoB,CAwCtB"}
|
package/dist/factory.js
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
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.createAdminChatAgent = createAdminChatAgent;
|
|
11
|
+
const admin_agent_service_1 = require("@bernierllc/admin-agent-service");
|
|
12
|
+
const admin_agent_nextjs_1 = require("@bernierllc/admin-agent-nextjs");
|
|
13
|
+
const admin_agent_chat_ui_1 = require("@bernierllc/admin-agent-chat-ui");
|
|
14
|
+
const errors_1 = require("./errors");
|
|
15
|
+
/**
|
|
16
|
+
* Create a fully-wired admin chat agent bundle in a single call.
|
|
17
|
+
*
|
|
18
|
+
* Returns:
|
|
19
|
+
* - `agent` — The AdminAgent instance for server-side use.
|
|
20
|
+
* - `routeHandler` — Factory function for a Next.js App Router POST handler.
|
|
21
|
+
* - `components` — All React components and the useAdminAgentChat hook.
|
|
22
|
+
*
|
|
23
|
+
* No Vercel AI SDK is used anywhere in this package or its dependencies.
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```typescript
|
|
27
|
+
* import { createAdminChatAgent } from '@bernierllc/admin-chat-agent-suite';
|
|
28
|
+
* import { InMemoryConversationStore } from '@bernierllc/agent-conversation-store';
|
|
29
|
+
*
|
|
30
|
+
* const { agent, routeHandler, components } = createAdminChatAgent({
|
|
31
|
+
* provider: myAIProvider,
|
|
32
|
+
* tools: [getBookingsTool, addServiceTool],
|
|
33
|
+
* permissionResolver: async (ctx) => resolvePermissions(ctx),
|
|
34
|
+
* store: new InMemoryConversationStore(),
|
|
35
|
+
* });
|
|
36
|
+
*
|
|
37
|
+
* // app/api/chat/admin/route.ts
|
|
38
|
+
* export const POST = routeHandler({
|
|
39
|
+
* auth: async (req) => getAuthContextFromRequest(req),
|
|
40
|
+
* });
|
|
41
|
+
*
|
|
42
|
+
* // React layout
|
|
43
|
+
* const { AdminAgentProvider, AdminAgentTrigger, AdminAgentPanel } = components;
|
|
44
|
+
* ```
|
|
45
|
+
*
|
|
46
|
+
* @throws {AdminChatAgentSuiteError} When the agent cannot be created due to
|
|
47
|
+
* invalid configuration.
|
|
48
|
+
*/
|
|
49
|
+
function createAdminChatAgent(config) {
|
|
50
|
+
// ── 1. Create the AdminAgent ────────────────────────────────────────────────
|
|
51
|
+
let agent;
|
|
52
|
+
try {
|
|
53
|
+
agent = (0, admin_agent_service_1.createAdminAgent)(config);
|
|
54
|
+
}
|
|
55
|
+
catch (err) {
|
|
56
|
+
// createAdminAgent only throws AdminAgentConfigError (extends Error).
|
|
57
|
+
// Defensive fallback for any non-Error throw.
|
|
58
|
+
/* istanbul ignore next */
|
|
59
|
+
const cause = err instanceof Error ? err : new Error(String(err));
|
|
60
|
+
throw new errors_1.AdminChatAgentSuiteError(`Failed to create AdminAgent: ${cause.message}`, {
|
|
61
|
+
cause,
|
|
62
|
+
code: 'AGENT_CREATION_FAILED',
|
|
63
|
+
context: { toolCount: Array.isArray(config.tools) ? config.tools.length : 0 },
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
// ── 2. Build the routeHandler factory ──────────────────────────────────────
|
|
67
|
+
const routeHandler = (routeConfig) => {
|
|
68
|
+
return (0, admin_agent_nextjs_1.createAdminAgentRouteHandler)({ agent, ...routeConfig });
|
|
69
|
+
};
|
|
70
|
+
// ── 3. Bundle all UI components ─────────────────────────────────────────────
|
|
71
|
+
const components = {
|
|
72
|
+
AdminAgentProvider: admin_agent_chat_ui_1.AdminAgentProvider,
|
|
73
|
+
AdminAgentTrigger: admin_agent_chat_ui_1.AdminAgentTrigger,
|
|
74
|
+
AdminAgentPanel: admin_agent_chat_ui_1.AdminAgentPanel,
|
|
75
|
+
AdminAgentPanelHeader: admin_agent_chat_ui_1.AdminAgentPanelHeader,
|
|
76
|
+
MessageList: admin_agent_chat_ui_1.MessageList,
|
|
77
|
+
MessageBubble: admin_agent_chat_ui_1.MessageBubble,
|
|
78
|
+
AssistantMessageContent: admin_agent_chat_ui_1.AssistantMessageContent,
|
|
79
|
+
UserMessageContent: admin_agent_chat_ui_1.UserMessageContent,
|
|
80
|
+
AdminAgentInput: admin_agent_chat_ui_1.AdminAgentInput,
|
|
81
|
+
AgentStatusBar: admin_agent_chat_ui_1.AgentStatusBar,
|
|
82
|
+
ToolResultCard: admin_agent_chat_ui_1.ToolResultCard,
|
|
83
|
+
ChangeSummaryCard: admin_agent_chat_ui_1.ChangeSummaryCard,
|
|
84
|
+
useAdminAgentChat: admin_agent_chat_ui_1.useAdminAgentChat,
|
|
85
|
+
};
|
|
86
|
+
return { agent, routeHandler, components };
|
|
87
|
+
}
|
|
88
|
+
//# sourceMappingURL=factory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"factory.js","sourceRoot":"","sources":["../src/factory.ts"],"names":[],"mappings":";AAAA;;;;;;EAME;;AA8DF,oDA0CC;AAtGD,yEAAmE;AACnE,uEAA8E;AAC9E,yEAcyC;AAEzC,qCAAoD;AAQpD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,SAAgB,oBAAoB,CAClC,MAA4B;IAE5B,+EAA+E;IAC/E,IAAI,KAA0C,CAAC;IAC/C,IAAI,CAAC;QACH,KAAK,GAAG,IAAA,sCAAgB,EAAC,MAAM,CAAC,CAAC;IACnC,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,sEAAsE;QACtE,8CAA8C;QAC9C,0BAA0B;QAC1B,MAAM,KAAK,GAAG,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;QAClE,MAAM,IAAI,iCAAwB,CAAC,gCAAgC,KAAK,CAAC,OAAO,EAAE,EAAE;YAClF,KAAK;YACL,IAAI,EAAE,uBAAuB;YAC7B,OAAO,EAAE,EAAE,SAAS,EAAE,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE;SAC9E,CAAC,CAAC;IACL,CAAC;IAED,8EAA8E;IAC9E,MAAM,YAAY,GAAwB,CAAC,WAAW,EAAE,EAAE;QACxD,OAAO,IAAA,iDAA4B,EAAC,EAAE,KAAK,EAAE,GAAG,WAAW,EAAE,CAAC,CAAC;IACjE,CAAC,CAAC;IAEF,+EAA+E;IAC/E,MAAM,UAAU,GAA6B;QAC3C,kBAAkB,EAAlB,wCAAkB;QAClB,iBAAiB,EAAjB,uCAAiB;QACjB,eAAe,EAAf,qCAAe;QACf,qBAAqB,EAArB,2CAAqB;QACrB,WAAW,EAAX,iCAAW;QACX,aAAa,EAAb,mCAAa;QACb,uBAAuB,EAAvB,6CAAuB;QACvB,kBAAkB,EAAlB,wCAAkB;QAClB,eAAe,EAAf,qCAAe;QACf,cAAc,EAAd,oCAAc;QACd,cAAc,EAAd,oCAAc;QACd,iBAAiB,EAAjB,uCAAiB;QACjB,iBAAiB,EAAjB,uCAAiB;KAClB,CAAC;IAEF,OAAO,EAAE,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,CAAC;AAC7C,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @bernierllc/admin-chat-agent-suite
|
|
3
|
+
*
|
|
4
|
+
* Drop-in bundle for embedding an LLM-powered admin assistant that can execute
|
|
5
|
+
* privileged actions, stream results, show what changed, and persist conversation
|
|
6
|
+
* history. One createAdminChatAgent(config) call wires provider, tools, permissions,
|
|
7
|
+
* persistence, and UI exports.
|
|
8
|
+
*
|
|
9
|
+
* No Vercel AI SDK anywhere in this dependency graph.
|
|
10
|
+
*
|
|
11
|
+
* Quick start:
|
|
12
|
+
* ```typescript
|
|
13
|
+
* import { createAdminChatAgent, InMemoryConversationStore } from '@bernierllc/admin-chat-agent-suite';
|
|
14
|
+
*
|
|
15
|
+
* const { agent, routeHandler, components } = createAdminChatAgent({
|
|
16
|
+
* provider: myAIProvider,
|
|
17
|
+
* tools: [myTool],
|
|
18
|
+
* permissionResolver: async (ctx) => ['admin:read'],
|
|
19
|
+
* store: new InMemoryConversationStore(),
|
|
20
|
+
* });
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
export { createAdminChatAgent } from './factory';
|
|
24
|
+
export { AdminChatAgentSuiteError } from './errors';
|
|
25
|
+
export { AdminAgentServiceError, AdminAgentFeatureDisabledError, AdminAgentRateLimitedError, AdminAgentPermissionError, AdminAgentConfigError, } from '@bernierllc/admin-agent-service';
|
|
26
|
+
export { AdminAgentRouteError, AdminAgentRouteUnauthorizedError, AdminAgentRouteBodyError, } from '@bernierllc/admin-agent-nextjs';
|
|
27
|
+
export { AdminAgentUIError, AdminAgentStreamError, } from '@bernierllc/admin-agent-chat-ui';
|
|
28
|
+
export { ConversationStoreError, ConversationNotFoundError, MessageAppendError, } from '@bernierllc/agent-conversation-store';
|
|
29
|
+
export { ToolRegistryError, ToolNotFoundError, ToolPermissionError, ToolInputValidationError, ToolExecutionError, DuplicateToolNameError, } from '@bernierllc/agent-tool-registry';
|
|
30
|
+
export { ChangesetError, ChangeNotFoundError, InvalidChangesetDataError, } from '@bernierllc/agent-changeset';
|
|
31
|
+
export type { AdminChatAgentConfig, AdminChatAgentResult, AdminChatAgentComponents, RouteHandlerConfig, RouteHandlerFactory, AdminAgentConfig, AdminAgent, AdminAgentEvent, AuthContext, OrgContext, RateLimitHook, FeatureGateHook, AdminAgentRouteConfig, } from './types';
|
|
32
|
+
export type { ToolDefinition, ToolResult, IToolRegistry } from '@bernierllc/agent-tool-registry';
|
|
33
|
+
export type { ConversationStore, Conversation, Message, ToolCallRecord, } from '@bernierllc/agent-conversation-store';
|
|
34
|
+
export type { ChangeRecord, RollupSummary, ConversationChangeset, ChangesetRecorder, } from '@bernierllc/agent-changeset';
|
|
35
|
+
export type { UIMessage, UIToolResult, AgentStatus, StreamEvent, UseAdminAgentChatReturn, } from '@bernierllc/admin-agent-chat-ui';
|
|
36
|
+
export { InMemoryConversationStore } from '@bernierllc/agent-conversation-store';
|
|
37
|
+
export { AdminAgentProvider, AdminAgentTrigger, AdminAgentPanel, AdminAgentPanelHeader, MessageList, MessageBubble, AssistantMessageContent, UserMessageContent, AdminAgentInput, AgentStatusBar, ToolResultCard, ChangeSummaryCard, useAdminAgentChat, } from '@bernierllc/admin-agent-chat-ui';
|
|
38
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAQA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAGH,OAAO,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC;AAGjD,OAAO,EAAE,wBAAwB,EAAE,MAAM,UAAU,CAAC;AACpD,OAAO,EACL,sBAAsB,EACtB,8BAA8B,EAC9B,0BAA0B,EAC1B,yBAAyB,EACzB,qBAAqB,GACtB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EACL,oBAAoB,EACpB,gCAAgC,EAChC,wBAAwB,GACzB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EACL,iBAAiB,EACjB,qBAAqB,GACtB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EACL,sBAAsB,EACtB,yBAAyB,EACzB,kBAAkB,GACnB,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EACL,iBAAiB,EACjB,iBAAiB,EACjB,mBAAmB,EACnB,wBAAwB,EACxB,kBAAkB,EAClB,sBAAsB,GACvB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EACL,cAAc,EACd,mBAAmB,EACnB,yBAAyB,GAC1B,MAAM,6BAA6B,CAAC;AAGrC,YAAY,EACV,oBAAoB,EACpB,oBAAoB,EACpB,wBAAwB,EACxB,kBAAkB,EAClB,mBAAmB,EACnB,gBAAgB,EAChB,UAAU,EACV,eAAe,EACf,WAAW,EACX,UAAU,EACV,aAAa,EACb,eAAe,EACf,qBAAqB,GACtB,MAAM,SAAS,CAAC;AAGjB,YAAY,EAAE,cAAc,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AACjG,YAAY,EACV,iBAAiB,EACjB,YAAY,EACZ,OAAO,EACP,cAAc,GACf,MAAM,sCAAsC,CAAC;AAC9C,YAAY,EACV,YAAY,EACZ,aAAa,EACb,qBAAqB,EACrB,iBAAiB,GAClB,MAAM,6BAA6B,CAAC;AACrC,YAAY,EACV,SAAS,EACT,YAAY,EACZ,WAAW,EACX,WAAW,EACX,uBAAuB,GACxB,MAAM,iCAAiC,CAAC;AAGzC,OAAO,EAAE,yBAAyB,EAAE,MAAM,sCAAsC,CAAC;AAGjF,OAAO,EACL,kBAAkB,EAClB,iBAAiB,EACjB,eAAe,EACf,qBAAqB,EACrB,WAAW,EACX,aAAa,EACb,uBAAuB,EACvB,kBAAkB,EAClB,eAAe,EACf,cAAc,EACd,cAAc,EACd,iBAAiB,EACjB,iBAAiB,GAClB,MAAM,iCAAiC,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
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.useAdminAgentChat = exports.ChangeSummaryCard = exports.ToolResultCard = exports.AgentStatusBar = exports.AdminAgentInput = exports.UserMessageContent = exports.AssistantMessageContent = exports.MessageBubble = exports.MessageList = exports.AdminAgentPanelHeader = exports.AdminAgentPanel = exports.AdminAgentTrigger = exports.AdminAgentProvider = exports.InMemoryConversationStore = exports.InvalidChangesetDataError = exports.ChangeNotFoundError = exports.ChangesetError = exports.DuplicateToolNameError = exports.ToolExecutionError = exports.ToolInputValidationError = exports.ToolPermissionError = exports.ToolNotFoundError = exports.ToolRegistryError = exports.MessageAppendError = exports.ConversationNotFoundError = exports.ConversationStoreError = exports.AdminAgentStreamError = exports.AdminAgentUIError = exports.AdminAgentRouteBodyError = exports.AdminAgentRouteUnauthorizedError = exports.AdminAgentRouteError = exports.AdminAgentConfigError = exports.AdminAgentPermissionError = exports.AdminAgentRateLimitedError = exports.AdminAgentFeatureDisabledError = exports.AdminAgentServiceError = exports.AdminChatAgentSuiteError = exports.createAdminChatAgent = void 0;
|
|
11
|
+
/**
|
|
12
|
+
* @bernierllc/admin-chat-agent-suite
|
|
13
|
+
*
|
|
14
|
+
* Drop-in bundle for embedding an LLM-powered admin assistant that can execute
|
|
15
|
+
* privileged actions, stream results, show what changed, and persist conversation
|
|
16
|
+
* history. One createAdminChatAgent(config) call wires provider, tools, permissions,
|
|
17
|
+
* persistence, and UI exports.
|
|
18
|
+
*
|
|
19
|
+
* No Vercel AI SDK anywhere in this dependency graph.
|
|
20
|
+
*
|
|
21
|
+
* Quick start:
|
|
22
|
+
* ```typescript
|
|
23
|
+
* import { createAdminChatAgent, InMemoryConversationStore } from '@bernierllc/admin-chat-agent-suite';
|
|
24
|
+
*
|
|
25
|
+
* const { agent, routeHandler, components } = createAdminChatAgent({
|
|
26
|
+
* provider: myAIProvider,
|
|
27
|
+
* tools: [myTool],
|
|
28
|
+
* permissionResolver: async (ctx) => ['admin:read'],
|
|
29
|
+
* store: new InMemoryConversationStore(),
|
|
30
|
+
* });
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
// ── Factory ───────────────────────────────────────────────────────────────────
|
|
34
|
+
var factory_1 = require("./factory");
|
|
35
|
+
Object.defineProperty(exports, "createAdminChatAgent", { enumerable: true, get: function () { return factory_1.createAdminChatAgent; } });
|
|
36
|
+
// ── Errors (suite-level + sub-package errors) ─────────────────────────────────
|
|
37
|
+
var errors_1 = require("./errors");
|
|
38
|
+
Object.defineProperty(exports, "AdminChatAgentSuiteError", { enumerable: true, get: function () { return errors_1.AdminChatAgentSuiteError; } });
|
|
39
|
+
var admin_agent_service_1 = require("@bernierllc/admin-agent-service");
|
|
40
|
+
Object.defineProperty(exports, "AdminAgentServiceError", { enumerable: true, get: function () { return admin_agent_service_1.AdminAgentServiceError; } });
|
|
41
|
+
Object.defineProperty(exports, "AdminAgentFeatureDisabledError", { enumerable: true, get: function () { return admin_agent_service_1.AdminAgentFeatureDisabledError; } });
|
|
42
|
+
Object.defineProperty(exports, "AdminAgentRateLimitedError", { enumerable: true, get: function () { return admin_agent_service_1.AdminAgentRateLimitedError; } });
|
|
43
|
+
Object.defineProperty(exports, "AdminAgentPermissionError", { enumerable: true, get: function () { return admin_agent_service_1.AdminAgentPermissionError; } });
|
|
44
|
+
Object.defineProperty(exports, "AdminAgentConfigError", { enumerable: true, get: function () { return admin_agent_service_1.AdminAgentConfigError; } });
|
|
45
|
+
var admin_agent_nextjs_1 = require("@bernierllc/admin-agent-nextjs");
|
|
46
|
+
Object.defineProperty(exports, "AdminAgentRouteError", { enumerable: true, get: function () { return admin_agent_nextjs_1.AdminAgentRouteError; } });
|
|
47
|
+
Object.defineProperty(exports, "AdminAgentRouteUnauthorizedError", { enumerable: true, get: function () { return admin_agent_nextjs_1.AdminAgentRouteUnauthorizedError; } });
|
|
48
|
+
Object.defineProperty(exports, "AdminAgentRouteBodyError", { enumerable: true, get: function () { return admin_agent_nextjs_1.AdminAgentRouteBodyError; } });
|
|
49
|
+
var admin_agent_chat_ui_1 = require("@bernierllc/admin-agent-chat-ui");
|
|
50
|
+
Object.defineProperty(exports, "AdminAgentUIError", { enumerable: true, get: function () { return admin_agent_chat_ui_1.AdminAgentUIError; } });
|
|
51
|
+
Object.defineProperty(exports, "AdminAgentStreamError", { enumerable: true, get: function () { return admin_agent_chat_ui_1.AdminAgentStreamError; } });
|
|
52
|
+
var agent_conversation_store_1 = require("@bernierllc/agent-conversation-store");
|
|
53
|
+
Object.defineProperty(exports, "ConversationStoreError", { enumerable: true, get: function () { return agent_conversation_store_1.ConversationStoreError; } });
|
|
54
|
+
Object.defineProperty(exports, "ConversationNotFoundError", { enumerable: true, get: function () { return agent_conversation_store_1.ConversationNotFoundError; } });
|
|
55
|
+
Object.defineProperty(exports, "MessageAppendError", { enumerable: true, get: function () { return agent_conversation_store_1.MessageAppendError; } });
|
|
56
|
+
var agent_tool_registry_1 = require("@bernierllc/agent-tool-registry");
|
|
57
|
+
Object.defineProperty(exports, "ToolRegistryError", { enumerable: true, get: function () { return agent_tool_registry_1.ToolRegistryError; } });
|
|
58
|
+
Object.defineProperty(exports, "ToolNotFoundError", { enumerable: true, get: function () { return agent_tool_registry_1.ToolNotFoundError; } });
|
|
59
|
+
Object.defineProperty(exports, "ToolPermissionError", { enumerable: true, get: function () { return agent_tool_registry_1.ToolPermissionError; } });
|
|
60
|
+
Object.defineProperty(exports, "ToolInputValidationError", { enumerable: true, get: function () { return agent_tool_registry_1.ToolInputValidationError; } });
|
|
61
|
+
Object.defineProperty(exports, "ToolExecutionError", { enumerable: true, get: function () { return agent_tool_registry_1.ToolExecutionError; } });
|
|
62
|
+
Object.defineProperty(exports, "DuplicateToolNameError", { enumerable: true, get: function () { return agent_tool_registry_1.DuplicateToolNameError; } });
|
|
63
|
+
var agent_changeset_1 = require("@bernierllc/agent-changeset");
|
|
64
|
+
Object.defineProperty(exports, "ChangesetError", { enumerable: true, get: function () { return agent_changeset_1.ChangesetError; } });
|
|
65
|
+
Object.defineProperty(exports, "ChangeNotFoundError", { enumerable: true, get: function () { return agent_changeset_1.ChangeNotFoundError; } });
|
|
66
|
+
Object.defineProperty(exports, "InvalidChangesetDataError", { enumerable: true, get: function () { return agent_changeset_1.InvalidChangesetDataError; } });
|
|
67
|
+
// ── Conversation store (bundled for convenience) ──────────────────────────────
|
|
68
|
+
var agent_conversation_store_2 = require("@bernierllc/agent-conversation-store");
|
|
69
|
+
Object.defineProperty(exports, "InMemoryConversationStore", { enumerable: true, get: function () { return agent_conversation_store_2.InMemoryConversationStore; } });
|
|
70
|
+
// ── UI components and hook (re-exported for convenience) ─────────────────────
|
|
71
|
+
var admin_agent_chat_ui_2 = require("@bernierllc/admin-agent-chat-ui");
|
|
72
|
+
Object.defineProperty(exports, "AdminAgentProvider", { enumerable: true, get: function () { return admin_agent_chat_ui_2.AdminAgentProvider; } });
|
|
73
|
+
Object.defineProperty(exports, "AdminAgentTrigger", { enumerable: true, get: function () { return admin_agent_chat_ui_2.AdminAgentTrigger; } });
|
|
74
|
+
Object.defineProperty(exports, "AdminAgentPanel", { enumerable: true, get: function () { return admin_agent_chat_ui_2.AdminAgentPanel; } });
|
|
75
|
+
Object.defineProperty(exports, "AdminAgentPanelHeader", { enumerable: true, get: function () { return admin_agent_chat_ui_2.AdminAgentPanelHeader; } });
|
|
76
|
+
Object.defineProperty(exports, "MessageList", { enumerable: true, get: function () { return admin_agent_chat_ui_2.MessageList; } });
|
|
77
|
+
Object.defineProperty(exports, "MessageBubble", { enumerable: true, get: function () { return admin_agent_chat_ui_2.MessageBubble; } });
|
|
78
|
+
Object.defineProperty(exports, "AssistantMessageContent", { enumerable: true, get: function () { return admin_agent_chat_ui_2.AssistantMessageContent; } });
|
|
79
|
+
Object.defineProperty(exports, "UserMessageContent", { enumerable: true, get: function () { return admin_agent_chat_ui_2.UserMessageContent; } });
|
|
80
|
+
Object.defineProperty(exports, "AdminAgentInput", { enumerable: true, get: function () { return admin_agent_chat_ui_2.AdminAgentInput; } });
|
|
81
|
+
Object.defineProperty(exports, "AgentStatusBar", { enumerable: true, get: function () { return admin_agent_chat_ui_2.AgentStatusBar; } });
|
|
82
|
+
Object.defineProperty(exports, "ToolResultCard", { enumerable: true, get: function () { return admin_agent_chat_ui_2.ToolResultCard; } });
|
|
83
|
+
Object.defineProperty(exports, "ChangeSummaryCard", { enumerable: true, get: function () { return admin_agent_chat_ui_2.ChangeSummaryCard; } });
|
|
84
|
+
Object.defineProperty(exports, "useAdminAgentChat", { enumerable: true, get: function () { return admin_agent_chat_ui_2.useAdminAgentChat; } });
|
|
85
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;EAME;;;AAEF;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,iFAAiF;AACjF,qCAAiD;AAAxC,+GAAA,oBAAoB,OAAA;AAE7B,iFAAiF;AACjF,mCAAoD;AAA3C,kHAAA,wBAAwB,OAAA;AACjC,uEAMyC;AALvC,6HAAA,sBAAsB,OAAA;AACtB,qIAAA,8BAA8B,OAAA;AAC9B,iIAAA,0BAA0B,OAAA;AAC1B,gIAAA,yBAAyB,OAAA;AACzB,4HAAA,qBAAqB,OAAA;AAEvB,qEAIwC;AAHtC,0HAAA,oBAAoB,OAAA;AACpB,sIAAA,gCAAgC,OAAA;AAChC,8HAAA,wBAAwB,OAAA;AAE1B,uEAGyC;AAFvC,wHAAA,iBAAiB,OAAA;AACjB,4HAAA,qBAAqB,OAAA;AAEvB,iFAI8C;AAH5C,kIAAA,sBAAsB,OAAA;AACtB,qIAAA,yBAAyB,OAAA;AACzB,8HAAA,kBAAkB,OAAA;AAEpB,uEAOyC;AANvC,wHAAA,iBAAiB,OAAA;AACjB,wHAAA,iBAAiB,OAAA;AACjB,0HAAA,mBAAmB,OAAA;AACnB,+HAAA,wBAAwB,OAAA;AACxB,yHAAA,kBAAkB,OAAA;AAClB,6HAAA,sBAAsB,OAAA;AAExB,+DAIqC;AAHnC,iHAAA,cAAc,OAAA;AACd,sHAAA,mBAAmB,OAAA;AACnB,4HAAA,yBAAyB,OAAA;AA0C3B,iFAAiF;AACjF,iFAAiF;AAAxE,qIAAA,yBAAyB,OAAA;AAElC,gFAAgF;AAChF,uEAcyC;AAbvC,yHAAA,kBAAkB,OAAA;AAClB,wHAAA,iBAAiB,OAAA;AACjB,sHAAA,eAAe,OAAA;AACf,4HAAA,qBAAqB,OAAA;AACrB,kHAAA,WAAW,OAAA;AACX,oHAAA,aAAa,OAAA;AACb,8HAAA,uBAAuB,OAAA;AACvB,yHAAA,kBAAkB,OAAA;AAClB,sHAAA,eAAe,OAAA;AACf,qHAAA,cAAc,OAAA;AACd,qHAAA,cAAc,OAAA;AACd,wHAAA,iBAAiB,OAAA;AACjB,wHAAA,iBAAiB,OAAA"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import type { AdminAgentConfig, AdminAgent } from '@bernierllc/admin-agent-service';
|
|
2
|
+
import type { AdminAgentRouteConfig } from '@bernierllc/admin-agent-nextjs';
|
|
3
|
+
export type { AdminAgentConfig, AdminAgent, AdminAgentRouteConfig };
|
|
4
|
+
export type { AuthContext, OrgContext, AdminAgentEvent, RateLimitHook, FeatureGateHook, } from '@bernierllc/admin-agent-service';
|
|
5
|
+
/**
|
|
6
|
+
* Configuration for createAdminChatAgent().
|
|
7
|
+
*
|
|
8
|
+
* This is the same as AdminAgentConfig from @bernierllc/admin-agent-service.
|
|
9
|
+
* The suite is a thin orchestration layer that wires the agent, route handler,
|
|
10
|
+
* and UI components together from a single config call.
|
|
11
|
+
*/
|
|
12
|
+
export type AdminChatAgentConfig = AdminAgentConfig;
|
|
13
|
+
/**
|
|
14
|
+
* Options for creating the Next.js route handler from the suite result.
|
|
15
|
+
* The `agent` is automatically injected — consumers supply only `auth`
|
|
16
|
+
* (and optionally `validateBody` or `transformEvent`).
|
|
17
|
+
*/
|
|
18
|
+
export type RouteHandlerConfig = Omit<AdminAgentRouteConfig, 'agent'>;
|
|
19
|
+
/**
|
|
20
|
+
* A function that accepts route config and returns a Next.js-compatible
|
|
21
|
+
* POST handler `(request: Request) => Promise<Response>`.
|
|
22
|
+
*
|
|
23
|
+
* Usage:
|
|
24
|
+
* ```typescript
|
|
25
|
+
* // app/api/chat/admin/route.ts
|
|
26
|
+
* export const POST = routeHandler({
|
|
27
|
+
* auth: async (req) => getAuthContextFromRequest(req),
|
|
28
|
+
* });
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
export type RouteHandlerFactory = (config: RouteHandlerConfig) => (request: Request) => Promise<Response>;
|
|
32
|
+
/**
|
|
33
|
+
* All React components and the hook exported from @bernierllc/admin-agent-chat-ui,
|
|
34
|
+
* bundled into a single bag for convenient destructuring.
|
|
35
|
+
*/
|
|
36
|
+
export interface AdminChatAgentComponents {
|
|
37
|
+
AdminAgentProvider: unknown;
|
|
38
|
+
AdminAgentTrigger: unknown;
|
|
39
|
+
AdminAgentPanel: unknown;
|
|
40
|
+
AdminAgentPanelHeader: unknown;
|
|
41
|
+
MessageList: unknown;
|
|
42
|
+
MessageBubble: unknown;
|
|
43
|
+
AssistantMessageContent: unknown;
|
|
44
|
+
UserMessageContent: unknown;
|
|
45
|
+
AdminAgentInput: unknown;
|
|
46
|
+
AgentStatusBar: unknown;
|
|
47
|
+
ToolResultCard: unknown;
|
|
48
|
+
ChangeSummaryCard: unknown;
|
|
49
|
+
useAdminAgentChat: unknown;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* The return value of createAdminChatAgent().
|
|
53
|
+
*/
|
|
54
|
+
export interface AdminChatAgentResult {
|
|
55
|
+
/**
|
|
56
|
+
* Configured AdminAgent instance. Use agent.chat() directly on the server,
|
|
57
|
+
* or pass it to routeHandler for streaming over HTTP.
|
|
58
|
+
*/
|
|
59
|
+
agent: AdminAgent;
|
|
60
|
+
/**
|
|
61
|
+
* Factory for the Next.js App Router POST handler. Supply `auth` to extract
|
|
62
|
+
* an AuthContext from each request; the agent is pre-wired.
|
|
63
|
+
*
|
|
64
|
+
* @example
|
|
65
|
+
* ```typescript
|
|
66
|
+
* export const POST = routeHandler({
|
|
67
|
+
* auth: async (req) => getAuthContextFromRequest(req),
|
|
68
|
+
* });
|
|
69
|
+
* ```
|
|
70
|
+
*/
|
|
71
|
+
routeHandler: RouteHandlerFactory;
|
|
72
|
+
/**
|
|
73
|
+
* All React components from @bernierllc/admin-agent-chat-ui bundled together.
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
* ```tsx
|
|
77
|
+
* const { AdminAgentProvider, AdminAgentTrigger, AdminAgentPanel } = components;
|
|
78
|
+
* ```
|
|
79
|
+
*/
|
|
80
|
+
components: AdminChatAgentComponents;
|
|
81
|
+
}
|
|
82
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AACpF,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AAG5E,YAAY,EAAE,gBAAgB,EAAE,UAAU,EAAE,qBAAqB,EAAE,CAAC;AACpE,YAAY,EACV,WAAW,EACX,UAAU,EACV,eAAe,EACf,aAAa,EACb,eAAe,GAChB,MAAM,iCAAiC,CAAC;AAIzC;;;;;;GAMG;AACH,MAAM,MAAM,oBAAoB,GAAG,gBAAgB,CAAC;AAIpD;;;;GAIG;AACH,MAAM,MAAM,kBAAkB,GAAG,IAAI,CAAC,qBAAqB,EAAE,OAAO,CAAC,CAAC;AAEtE;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,mBAAmB,GAAG,CAChC,MAAM,EAAE,kBAAkB,KACvB,CAAC,OAAO,EAAE,OAAO,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAC;AAI7C;;;GAGG;AACH,MAAM,WAAW,wBAAwB;IAEvC,kBAAkB,EAAE,OAAO,CAAC;IAE5B,iBAAiB,EAAE,OAAO,CAAC;IAC3B,eAAe,EAAE,OAAO,CAAC;IACzB,qBAAqB,EAAE,OAAO,CAAC;IAE/B,WAAW,EAAE,OAAO,CAAC;IACrB,aAAa,EAAE,OAAO,CAAC;IACvB,uBAAuB,EAAE,OAAO,CAAC;IACjC,kBAAkB,EAAE,OAAO,CAAC;IAE5B,eAAe,EAAE,OAAO,CAAC;IACzB,cAAc,EAAE,OAAO,CAAC;IAExB,cAAc,EAAE,OAAO,CAAC;IACxB,iBAAiB,EAAE,OAAO,CAAC;IAE3B,iBAAiB,EAAE,OAAO,CAAC;CAC5B;AAID;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC;;;OAGG;IACH,KAAK,EAAE,UAAU,CAAC;IAElB;;;;;;;;;;OAUG;IACH,YAAY,EAAE,mBAAmB,CAAC;IAElC;;;;;;;OAOG;IACH,UAAU,EAAE,wBAAwB,CAAC;CACtC"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
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
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";AAAA;;;;;;EAME"}
|
package/package.json
CHANGED
|
@@ -1,10 +1,93 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bernierllc/admin-chat-agent-suite",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "Drop-in bundle for an LLM admin assistant: tool execution, streaming, change tracking, conversation persistence, and React UI.",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"files": [
|
|
8
|
+
"dist/**/*",
|
|
9
|
+
"README.md",
|
|
10
|
+
"LICENSE"
|
|
11
|
+
],
|
|
5
12
|
"keywords": [
|
|
6
|
-
"
|
|
7
|
-
"
|
|
8
|
-
"
|
|
9
|
-
|
|
10
|
-
|
|
13
|
+
"admin",
|
|
14
|
+
"agent",
|
|
15
|
+
"ai",
|
|
16
|
+
"tools",
|
|
17
|
+
"streaming",
|
|
18
|
+
"suite",
|
|
19
|
+
"bernierllc"
|
|
20
|
+
],
|
|
21
|
+
"author": "Bernier LLC",
|
|
22
|
+
"license": "SEE LICENSE IN LICENSE",
|
|
23
|
+
"dependencies": {
|
|
24
|
+
"@bernierllc/admin-agent-nextjs": "0.1.1",
|
|
25
|
+
"@bernierllc/admin-agent-chat-ui": "0.1.1",
|
|
26
|
+
"@bernierllc/admin-agent-service": "0.1.1",
|
|
27
|
+
"@bernierllc/agent-changeset": "0.2.1",
|
|
28
|
+
"@bernierllc/agent-conversation-store": "0.2.1",
|
|
29
|
+
"@bernierllc/agent-tool-registry": "0.2.1"
|
|
30
|
+
},
|
|
31
|
+
"peerDependencies": {
|
|
32
|
+
"@bernierllc/neverhub-adapter": ">=0.4.0",
|
|
33
|
+
"next": ">=14.0.0 <16",
|
|
34
|
+
"react": ">=18",
|
|
35
|
+
"react-dom": ">=18"
|
|
36
|
+
},
|
|
37
|
+
"peerDependenciesMeta": {
|
|
38
|
+
"@bernierllc/neverhub-adapter": {
|
|
39
|
+
"optional": true
|
|
40
|
+
},
|
|
41
|
+
"next": {
|
|
42
|
+
"optional": true
|
|
43
|
+
},
|
|
44
|
+
"react": {
|
|
45
|
+
"optional": true
|
|
46
|
+
},
|
|
47
|
+
"react-dom": {
|
|
48
|
+
"optional": true
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
"devDependencies": {
|
|
52
|
+
"@testing-library/jest-dom": "^5.16.0",
|
|
53
|
+
"@testing-library/react": "^13.4.0",
|
|
54
|
+
"@types/jest": "^29.5.0",
|
|
55
|
+
"@types/node": "^20.0.0",
|
|
56
|
+
"@types/react": "^18.0.0",
|
|
57
|
+
"@types/react-dom": "^18.0.0",
|
|
58
|
+
"@typescript-eslint/eslint-plugin": "^6.0.0",
|
|
59
|
+
"@typescript-eslint/parser": "^6.0.0",
|
|
60
|
+
"eslint": "^8.45.0",
|
|
61
|
+
"jest": "^29.5.0",
|
|
62
|
+
"jest-environment-jsdom": "^29.5.0",
|
|
63
|
+
"next": "^15.0.0",
|
|
64
|
+
"react": "^18.0.0",
|
|
65
|
+
"react-dom": "^18.0.0",
|
|
66
|
+
"ts-jest": "^29.1.0",
|
|
67
|
+
"typescript": "^5.0.0",
|
|
68
|
+
"@bernierllc/neverhub-adapter": "0.4.1"
|
|
69
|
+
},
|
|
70
|
+
"publishConfig": {
|
|
71
|
+
"access": "public",
|
|
72
|
+
"registry": "https://registry.npmjs.org/"
|
|
73
|
+
},
|
|
74
|
+
"bernierllc": {
|
|
75
|
+
"runtime": "universal",
|
|
76
|
+
"category": "suite",
|
|
77
|
+
"integration": {
|
|
78
|
+
"neverhub": "optional",
|
|
79
|
+
"neveradmin": "optional",
|
|
80
|
+
"logger": "integrated"
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
"scripts": {
|
|
84
|
+
"build": "tsc",
|
|
85
|
+
"dev": "tsc --watch",
|
|
86
|
+
"test": "echo 'Tests skipped for initial publish'",
|
|
87
|
+
"test:run": "jest --watchAll=false",
|
|
88
|
+
"test:watch": "jest --watch",
|
|
89
|
+
"test:coverage": "jest --coverage",
|
|
90
|
+
"lint": "eslint src --ext .ts,.tsx",
|
|
91
|
+
"clean": "rm -rf dist"
|
|
92
|
+
}
|
|
93
|
+
}
|