strapi-plugin-ai-sdk 0.6.3 → 0.6.5
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 +24 -29
- package/dist/_chunks/App-Dg01IPnx.js +1806 -0
- package/dist/_chunks/App-T05Erwmh.mjs +1803 -0
- package/dist/_chunks/{index-HDnO9h6E.js → index-CZYebcrb.js} +1 -1
- package/dist/_chunks/{index-5GDOg82N.mjs → index-DzpIKOjG.mjs} +1 -1
- package/dist/admin/index.js +1 -1
- package/dist/admin/index.mjs +1 -1
- package/dist/admin/src/components/ChatInput.d.ts +1 -3
- package/dist/admin/src/components/MessageList.d.ts +0 -3
- package/dist/admin/src/hooks/useChat.d.ts +0 -2
- package/dist/server/index.js +14 -168
- package/dist/server/index.mjs +14 -168
- package/dist/server/src/controllers/controller.d.ts +0 -1
- package/dist/server/src/controllers/index.d.ts +0 -1
- package/dist/server/src/index.d.ts +0 -1
- package/dist/server/src/lib/types.d.ts +0 -6
- package/dist/server/src/mcp/server.d.ts +1 -1
- package/dist/widget/widget.js +3 -14
- package/package.json +3 -5
- package/dist/_chunks/App-BhTbl60k.mjs +0 -2755
- package/dist/_chunks/App-CdOD0qmW.js +0 -2776
- package/dist/admin/src/components/Avatar3D/Avatar3D.d.ts +0 -1
- package/dist/admin/src/components/Avatar3D/PlaceholderModel.d.ts +0 -6
- package/dist/admin/src/components/Avatar3D/animations.d.ts +0 -23
- package/dist/admin/src/components/AvatarPanel.d.ts +0 -1
- package/dist/admin/src/context/AvatarAnimationContext.d.ts +0 -12
- package/dist/admin/src/hooks/useAudioPlayer.d.ts +0 -9
- package/dist/admin/src/hooks/useTextReveal.d.ts +0 -11
- package/dist/server/src/lib/tts/index.d.ts +0 -19
- package/dist/server/src/lib/tts/typecast-provider.d.ts +0 -10
- package/dist/server/src/lib/tts/types.d.ts +0 -9
- package/dist/server/src/tools/definitions/trigger-animation.d.ts +0 -2
package/README.md
CHANGED
|
@@ -4,14 +4,14 @@ A Strapi v5 plugin that adds an AI-powered chat assistant to the admin panel, ex
|
|
|
4
4
|
|
|
5
5
|
## Features
|
|
6
6
|
|
|
7
|
-
- **Admin Chat UI** with
|
|
7
|
+
- **Admin Chat UI** with markdown rendering, tool call visualization, conversation history, and memory management
|
|
8
8
|
- **Content Tools** -- the AI can list content types, search content, create/update documents, and send emails
|
|
9
9
|
- **API Endpoints** -- `/ask`, `/ask-stream`, and `/chat` for frontend consumption (compatible with `useChat` from `@ai-sdk/react`)
|
|
10
10
|
- **Public Chat** -- sandboxed public-facing chat with read-only tools and a separate public memory store
|
|
11
|
-
- **Embeddable Widget** -- drop a single `<script>` tag on any website to add an AI chat bubble
|
|
11
|
+
- **Embeddable Widget** -- drop a single `<script>` tag on any website to add an AI chat bubble
|
|
12
12
|
- **MCP Server** -- expose tools to external AI clients (Claude Desktop, Cursor, etc.) via the Model Context Protocol
|
|
13
13
|
- **Guardrails** -- regex-based input safety middleware that blocks prompt injection, jailbreaks, and destructive commands
|
|
14
|
-
- **Extensible** -- register custom tools
|
|
14
|
+
- **Extensible** -- register custom tools and AI providers at runtime
|
|
15
15
|
|
|
16
16
|
## Quick Start
|
|
17
17
|
|
|
@@ -92,10 +92,9 @@ That's it. A floating chat button appears in the bottom-right corner. The widget
|
|
|
92
92
|
|
|
93
93
|
### How it works
|
|
94
94
|
|
|
95
|
-
- The widget bundles React
|
|
95
|
+
- The widget bundles React and AI SDK internally (~130KB gzipped)
|
|
96
96
|
- It renders inside a Shadow DOM so styles never conflict with your page
|
|
97
97
|
- It uses the `/api/ai-sdk/public-chat` endpoint which only exposes read-only tools
|
|
98
|
-
- The 3D avatar loads from `/models/avatar.glb` on your Strapi server (optional -- falls back to a procedural avatar)
|
|
99
98
|
|
|
100
99
|
### Public Chat vs Admin Chat
|
|
101
100
|
|
|
@@ -116,6 +115,7 @@ In `config/plugins.ts`, add `publicChat` with the content types visitors can que
|
|
|
116
115
|
config: {
|
|
117
116
|
anthropicApiKey: env('ANTHROPIC_API_KEY'),
|
|
118
117
|
publicChat: {
|
|
118
|
+
chatModel: 'claude-haiku-4-5-20251001', // optional: use a cheaper model for public chat
|
|
119
119
|
allowedContentTypes: [
|
|
120
120
|
'api::article.article',
|
|
121
121
|
'api::category.category',
|
|
@@ -126,6 +126,8 @@ In `config/plugins.ts`, add `publicChat` with the content types visitors can que
|
|
|
126
126
|
},
|
|
127
127
|
```
|
|
128
128
|
|
|
129
|
+
If `allowedContentTypes` is an empty array, public chat will have no access to content.
|
|
130
|
+
|
|
129
131
|
### Managing public memories
|
|
130
132
|
|
|
131
133
|
Public memories are facts the AI knows when talking to visitors (e.g., "Our return policy is 30 days"). Manage them from the Strapi admin panel:
|
|
@@ -152,10 +154,6 @@ export default ({ env }) => ({
|
|
|
152
154
|
// System Prompt (optional)
|
|
153
155
|
systemPrompt: 'You are a helpful CMS assistant.\n\n{tools}',
|
|
154
156
|
|
|
155
|
-
// TTS (optional)
|
|
156
|
-
typecastApiKey: env('TYPECAST_API_KEY'),
|
|
157
|
-
typecastActorId: env('TYPECAST_ACTOR_ID'),
|
|
158
|
-
|
|
159
157
|
// MCP Session Tuning (optional)
|
|
160
158
|
mcp: {
|
|
161
159
|
sessionTimeoutMs: 4 * 60 * 60 * 1000, // 4 hours (default)
|
|
@@ -165,6 +163,7 @@ export default ({ env }) => ({
|
|
|
165
163
|
|
|
166
164
|
// Public Chat (optional)
|
|
167
165
|
publicChat: {
|
|
166
|
+
chatModel: 'claude-haiku-4-5-20251001', // optional cheaper model
|
|
168
167
|
allowedContentTypes: ['api::article.article'],
|
|
169
168
|
},
|
|
170
169
|
|
|
@@ -185,9 +184,9 @@ export default ({ env }) => ({
|
|
|
185
184
|
|
|
186
185
|
- `claude-sonnet-4-20250514` (default)
|
|
187
186
|
- `claude-opus-4-20250514`
|
|
187
|
+
- `claude-haiku-4-5-20251001`
|
|
188
188
|
- `claude-3-5-sonnet-20241022`
|
|
189
189
|
- `claude-3-5-haiku-20241022`
|
|
190
|
-
- `claude-3-haiku-20240307`
|
|
191
190
|
|
|
192
191
|
## API Endpoints
|
|
193
192
|
|
|
@@ -208,8 +207,7 @@ export default ({ env }) => ({
|
|
|
208
207
|
|
|
209
208
|
| Method | Endpoint | Description |
|
|
210
209
|
|--------|----------|-------------|
|
|
211
|
-
| `POST` | `/ai-sdk/chat` | Admin chat with tool
|
|
212
|
-
| `POST` | `/ai-sdk/tts` | Text-to-speech synthesis |
|
|
210
|
+
| `POST` | `/ai-sdk/chat` | Admin chat with full tool access |
|
|
213
211
|
|
|
214
212
|
All routes with user input are protected by the guardrail middleware.
|
|
215
213
|
|
|
@@ -290,7 +288,6 @@ The AI assistant has access to these tools. Tools marked as **public** are also
|
|
|
290
288
|
| `searchContent` | `search_content` | Search and query any content type with filters, sorting, and pagination |
|
|
291
289
|
| `writeContent` | `write_content` | Create or update documents in any content type |
|
|
292
290
|
| `sendEmail` | `send_email` | Send emails via the configured email provider (e.g. Resend) |
|
|
293
|
-
| `triggerAnimation` | *(internal)* | Trigger 3D avatar animations in the admin chat UI |
|
|
294
291
|
|
|
295
292
|
### Tool Details
|
|
296
293
|
|
|
@@ -548,11 +545,11 @@ Per-request `system` overrides in the request body take priority over the config
|
|
|
548
545
|
The plugin adds a chat interface to the Strapi admin panel with:
|
|
549
546
|
|
|
550
547
|
- **Chat UI** -- message list with markdown rendering, tool call visualization, and typing indicator
|
|
551
|
-
- **
|
|
552
|
-
- **
|
|
548
|
+
- **Conversation History** -- persistent conversations stored per-user, accessible via the sidebar
|
|
549
|
+
- **Memory Management** -- the AI remembers facts across conversations; view and manage memories from the toolbar
|
|
550
|
+
- **Public Memory Store** -- shared facts available to public chat visitors (FAQ, policies, etc.)
|
|
553
551
|
- **Tool Call Display** -- collapsible viewer showing tool inputs and outputs inline in the chat
|
|
554
|
-
|
|
555
|
-
The avatar supports custom `.glb` models -- place your model at `<strapi-project>/public/models/avatar.glb` and restart Strapi.
|
|
552
|
+
- **Widget Preview** -- live preview of the embeddable chat widget with copy-paste embed code
|
|
556
553
|
|
|
557
554
|
## Error Handling
|
|
558
555
|
|
|
@@ -581,7 +578,7 @@ Error response format:
|
|
|
581
578
|
server/src/
|
|
582
579
|
index.ts # Server entry point
|
|
583
580
|
register.ts # Plugin register lifecycle
|
|
584
|
-
bootstrap.ts # Initialize providers, tools, MCP
|
|
581
|
+
bootstrap.ts # Initialize providers, tools, MCP
|
|
585
582
|
destroy.ts # Graceful shutdown
|
|
586
583
|
config/index.ts # Plugin config defaults
|
|
587
584
|
guardrails/ # Input safety middleware
|
|
@@ -590,9 +587,8 @@ server/src/
|
|
|
590
587
|
tool-registry.ts # ToolRegistry class
|
|
591
588
|
types.ts # Shared types
|
|
592
589
|
utils.ts # Controller helpers
|
|
593
|
-
tts/ # TTS provider registry + Typecast
|
|
594
590
|
controllers/
|
|
595
|
-
controller.ts # ask, askStream, chat, publicChat,
|
|
591
|
+
controller.ts # ask, askStream, chat, publicChat, serveWidget handlers
|
|
596
592
|
public-memory.ts # CRUD for public memories
|
|
597
593
|
mcp.ts # MCP session management
|
|
598
594
|
services/service.ts # AI service facade
|
|
@@ -608,26 +604,25 @@ server/src/
|
|
|
608
604
|
utils/sanitize.ts # Content API sanitization
|
|
609
605
|
|
|
610
606
|
admin/src/
|
|
611
|
-
pages/ # App router
|
|
607
|
+
pages/ # App router, HomePage, WidgetPreviewPage, MemoryStorePage
|
|
612
608
|
components/
|
|
613
609
|
Chat.tsx # Chat orchestrator
|
|
614
|
-
MessageList.tsx # Message rendering
|
|
615
|
-
ChatInput.tsx # Input
|
|
610
|
+
MessageList.tsx # Message rendering with markdown
|
|
611
|
+
ChatInput.tsx # Input area
|
|
616
612
|
ToolCallDisplay.tsx # Tool call viewer
|
|
617
|
-
|
|
618
|
-
|
|
613
|
+
ConversationSidebar.tsx # Conversation history panel
|
|
614
|
+
MemoryPanel.tsx # Memory management panel
|
|
619
615
|
hooks/
|
|
620
616
|
useChat.ts # Chat state + SSE streaming
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
context/ # Avatar animation context
|
|
617
|
+
useConversations.ts # Conversation CRUD
|
|
618
|
+
useMemories.ts # Memory CRUD
|
|
624
619
|
|
|
625
620
|
widget/src/ # Embeddable chat widget (separate Vite build)
|
|
626
621
|
embed.tsx # Auto-mount entry (Shadow DOM)
|
|
627
622
|
react.tsx # React component export
|
|
628
623
|
auto-detect.ts # Script URL detection
|
|
629
624
|
styles.css # Scoped CSS (no Tailwind)
|
|
630
|
-
components/
|
|
625
|
+
components/strapi-chat.tsx # Chat UI component
|
|
631
626
|
|
|
632
627
|
tests/ # E2E integration tests
|
|
633
628
|
docs/ # Architecture + guardrails + email guides
|