@burtson-labs/bandit-engine 2.0.9 → 2.0.11
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 +74 -29
- package/dist/{aiProviderStore-YWJHSWFA.mjs → aiProviderStore-3YS2BZU3.mjs} +2 -2
- package/dist/chat-ZPJNWIXI.mjs +15 -0
- package/dist/chat-provider.js +211 -16
- package/dist/chat-provider.js.map +1 -1
- package/dist/chat-provider.mjs +6 -6
- package/dist/{chunk-CVIOLFMX.mjs → chunk-2ZNIQD26.mjs} +4 -4
- package/dist/{chunk-6YRLBITU.mjs → chunk-5UVULH77.mjs} +18 -9
- package/dist/chunk-5UVULH77.mjs.map +1 -0
- package/dist/{chunk-VSHO7PF2.mjs → chunk-CY227I4F.mjs} +23 -13
- package/dist/chunk-CY227I4F.mjs.map +1 -0
- package/dist/{chunk-JQ6UNJNW.mjs → chunk-IFN52MQL.mjs} +16 -10
- package/dist/{chunk-JQ6UNJNW.mjs.map → chunk-IFN52MQL.mjs.map} +1 -1
- package/dist/{chunk-AVC6IZJQ.mjs → chunk-IHJPVIGB.mjs} +179 -2
- package/dist/chunk-IHJPVIGB.mjs.map +1 -0
- package/dist/{chunk-HHKXWNCG.mjs → chunk-L7UOQ2Y2.mjs} +5 -5
- package/dist/{chunk-5E7S7DK3.mjs → chunk-RTQDQ6TC.mjs} +2 -2
- package/dist/{chunk-6IHJZCUH.mjs → chunk-UMPVXYVC.mjs} +4 -4
- package/dist/{chunk-PXXVEH5M.mjs → chunk-XEG45Q6V.mjs} +4 -4
- package/dist/{chunk-QHLKGSMB.mjs → chunk-XUBYA5I7.mjs} +2 -2
- package/dist/{chunk-QHLKGSMB.mjs.map → chunk-XUBYA5I7.mjs.map} +1 -1
- package/dist/cli/cli.js +14 -1
- package/dist/cli/cli.js.map +1 -1
- package/dist/{gateway-BXVrH8B-.d.mts → gateway-BiHRHJMM.d.mts} +3 -1
- package/dist/{gateway-BXVrH8B-.d.ts → gateway-BiHRHJMM.d.ts} +3 -1
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +282 -72
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +10 -10
- package/dist/management/management.js +262 -62
- package/dist/management/management.js.map +1 -1
- package/dist/management/management.mjs +8 -8
- package/dist/modals/chat-modal/chat-modal.js +202 -17
- package/dist/modals/chat-modal/chat-modal.js.map +1 -1
- package/dist/modals/chat-modal/chat-modal.mjs +5 -5
- package/dist/{modelStore-CY6SECYD.mjs → modelStore-UMJBDSEF.mjs} +2 -2
- package/dist/public-types.d.mts +1 -1
- package/dist/public-types.d.ts +1 -1
- package/docs/01_quickstart.md +9 -6
- package/docs/02_gateway_api.md +55 -12
- package/docs/api_reference/assets/search.js +1 -1
- package/docs/api_reference/classes/DebugLogger.html +11 -11
- package/docs/api_reference/classes/FeatureFlagService.html +13 -13
- package/docs/api_reference/classes/NotificationService.html +10 -10
- package/docs/api_reference/classes/StreamingTTSClient.html +9 -9
- package/docs/api_reference/classes/VectorDatabaseService.html +24 -24
- package/docs/api_reference/classes/VectorMigrationService.html +8 -8
- package/docs/api_reference/classes/VoiceService.html +2 -2
- package/docs/api_reference/enums/TTSState.html +2 -2
- package/docs/api_reference/functions/Chat.html +1 -1
- package/docs/api_reference/functions/ChatModal.html +1 -1
- package/docs/api_reference/functions/ChatProvider.html +1 -1
- package/docs/api_reference/functions/FeatureFlagProvider.html +1 -1
- package/docs/api_reference/functions/FeedbackButton.html +1 -1
- package/docs/api_reference/functions/FeedbackModal.html +1 -1
- package/docs/api_reference/functions/Management.html +1 -1
- package/docs/api_reference/functions/NotificationProvider.html +1 -1
- package/docs/api_reference/functions/SubscriptionExpiredGuard.html +1 -1
- package/docs/api_reference/functions/SubscriptionExpiredModal.html +1 -1
- package/docs/api_reference/functions/defineCustomElement.html +1 -1
- package/docs/api_reference/functions/getCriticalConfig.html +1 -1
- package/docs/api_reference/functions/getFeatureMatrix.html +1 -1
- package/docs/api_reference/functions/getStreamingTTSClient.html +1 -1
- package/docs/api_reference/functions/getSystemConstants.html +1 -1
- package/docs/api_reference/functions/getTTSState.html +1 -1
- package/docs/api_reference/functions/handleHttpError.html +1 -1
- package/docs/api_reference/functions/handleSubscriptionUpgrade.html +1 -1
- package/docs/api_reference/functions/handleValidationError.html +1 -1
- package/docs/api_reference/functions/initializeCoreSystem.html +1 -1
- package/docs/api_reference/functions/pauseTTS.html +1 -1
- package/docs/api_reference/functions/previewTierUpgrade.html +1 -1
- package/docs/api_reference/functions/resumeTTS.html +1 -1
- package/docs/api_reference/functions/showInfoNotification.html +1 -1
- package/docs/api_reference/functions/showSuccessNotification.html +1 -1
- package/docs/api_reference/functions/speakWithStreaming.html +1 -1
- package/docs/api_reference/functions/stopTTS.html +1 -1
- package/docs/api_reference/functions/syncSubscriptionWithAPI.html +1 -1
- package/docs/api_reference/functions/updateSubscriptionTier.html +1 -1
- package/docs/api_reference/functions/useFeatureFlag.html +1 -1
- package/docs/api_reference/functions/useFeatureVisibility.html +1 -1
- package/docs/api_reference/functions/useFeatures.html +1 -1
- package/docs/api_reference/functions/useGatewayHealth.html +1 -1
- package/docs/api_reference/functions/useGatewayMemory.html +1 -1
- package/docs/api_reference/functions/useGatewayModels.html +1 -1
- package/docs/api_reference/functions/useGlobalTTS.html +1 -1
- package/docs/api_reference/functions/useNotification.html +1 -1
- package/docs/api_reference/functions/useNotificationService.html +1 -1
- package/docs/api_reference/functions/useTTS.html +1 -1
- package/docs/api_reference/functions/useVectorStore.html +1 -1
- package/docs/api_reference/functions/useVoiceStore.html +2 -2
- package/docs/api_reference/functions/useVoices.html +1 -1
- package/docs/api_reference/functions/validateEnvironment.html +1 -1
- package/docs/api_reference/functions/validateSystemIntegrity.html +1 -1
- package/docs/api_reference/index.html +34 -15
- package/docs/api_reference/interfaces/AIChatRequest.html +2 -2
- package/docs/api_reference/interfaces/AIChatResponse.html +2 -2
- package/docs/api_reference/interfaces/AIGenerateRequest.html +2 -2
- package/docs/api_reference/interfaces/AIGenerateResponse.html +2 -2
- package/docs/api_reference/interfaces/AIMessage.html +2 -2
- package/docs/api_reference/interfaces/AIModel.html +2 -2
- package/docs/api_reference/interfaces/AIProviderConfig.html +2 -2
- package/docs/api_reference/interfaces/ChatConfig.html +3 -3
- package/docs/api_reference/interfaces/ChatModalProps.html +3 -3
- package/docs/api_reference/interfaces/CreateMemoryOptions.html +2 -2
- package/docs/api_reference/interfaces/FeatureEvaluation.html +7 -7
- package/docs/api_reference/interfaces/FeatureFlagConfig.html +9 -9
- package/docs/api_reference/interfaces/FeatureFlagContextValue.html +8 -8
- package/docs/api_reference/interfaces/FeatureFlagProviderProps.html +2 -2
- package/docs/api_reference/interfaces/FeedbackButtonProps.html +10 -10
- package/docs/api_reference/interfaces/FeedbackCategories.html +2 -2
- package/docs/api_reference/interfaces/FeedbackModalProps.html +2 -2
- package/docs/api_reference/interfaces/FeedbackPriorities.html +2 -2
- package/docs/api_reference/interfaces/FeedbackRequest.html +2 -2
- package/docs/api_reference/interfaces/FeedbackResponse.html +2 -2
- package/docs/api_reference/interfaces/FileUploadResult.html +2 -2
- package/docs/api_reference/interfaces/GatewayChatRequest.html +2 -2
- package/docs/api_reference/interfaces/GatewayChatResponse.html +2 -2
- package/docs/api_reference/interfaces/GatewayContract.html +2 -2
- package/docs/api_reference/interfaces/GatewayGenerateRequest.html +2 -2
- package/docs/api_reference/interfaces/GatewayGenerateResponse.html +2 -2
- package/docs/api_reference/interfaces/GatewayHealthResponse.html +2 -2
- package/docs/api_reference/interfaces/GatewayMemoryRecord.html +2 -2
- package/docs/api_reference/interfaces/GatewayMemoryResponse.html +2 -2
- package/docs/api_reference/interfaces/GatewayMessage.html +2 -2
- package/docs/api_reference/interfaces/GatewayMessageContent.html +2 -2
- package/docs/api_reference/interfaces/GatewayModel.html +2 -2
- package/docs/api_reference/interfaces/GatewayModelsResponse.html +2 -2
- package/docs/api_reference/interfaces/MemorySearchFilters.html +2 -2
- package/docs/api_reference/interfaces/MigrationProgress.html +2 -2
- package/docs/api_reference/interfaces/MigrationStatus.html +2 -2
- package/docs/api_reference/interfaces/NotificationConfig.html +2 -2
- package/docs/api_reference/interfaces/NotificationContextType.html +2 -2
- package/docs/api_reference/interfaces/NotificationProviderProps.html +2 -2
- package/docs/api_reference/interfaces/PackageSettings.html +4 -2
- package/docs/api_reference/interfaces/SearchOptions.html +2 -2
- package/docs/api_reference/interfaces/SearchResult.html +2 -2
- package/docs/api_reference/interfaces/SubscriptionExpiredGuardProps.html +2 -2
- package/docs/api_reference/interfaces/SubscriptionExpiredModalProps.html +2 -2
- package/docs/api_reference/interfaces/TTSOptions.html +2 -2
- package/docs/api_reference/interfaces/TTSProgress.html +2 -2
- package/docs/api_reference/interfaces/TrialUsage.html +2 -2
- package/docs/api_reference/interfaces/UploadRequest.html +3 -3
- package/docs/api_reference/interfaces/UseTTSReturn.html +2 -2
- package/docs/api_reference/interfaces/VectorDocument.html +2 -2
- package/docs/api_reference/interfaces/VectorMemory.html +2 -2
- package/docs/api_reference/interfaces/VectorMemoryMetadata.html +2 -2
- package/docs/api_reference/interfaces/VectorStoreStatus.html +2 -2
- package/docs/api_reference/interfaces/VoiceModelsResponse.html +2 -2
- package/docs/api_reference/interfaces/VoiceState.html +2 -2
- package/docs/api_reference/media/02_gateway_api.md +55 -12
- package/docs/api_reference/media/README.md +37 -9
- package/docs/api_reference/types/FeatureKey.html +1 -1
- package/docs/api_reference/types/FeatureMatrix.html +1 -1
- package/docs/api_reference/types/GatewayQueryOptions.html +1 -1
- package/docs/api_reference/types/LogContext.html +1 -1
- package/docs/api_reference/types/SubscriptionTier.html +1 -1
- package/docs/api_reference/variables/DEFAULT_TIER_FEATURES.html +1 -1
- package/docs/api_reference/variables/FeatureFlagContext.html +1 -1
- package/docs/api_reference/variables/OSS_DEFAULT_FEATURES.html +1 -1
- package/docs/api_reference/variables/SYSTEM_FLAGS.html +1 -1
- package/docs/api_reference/variables/authenticationService.html +1 -1
- package/docs/api_reference/variables/debugLogger-1.html +1 -1
- package/docs/api_reference/variables/featureFlagService-1.html +1 -1
- package/docs/api_reference/variables/notificationService-1.html +1 -1
- package/docs/api_reference/variables/vectorDatabaseService-1.html +1 -1
- package/docs/api_reference/variables/vectorMigrationService-1.html +1 -1
- package/docs/api_reference/variables/voiceService-1.html +1 -1
- package/package.json +14 -1
- package/dist/chat-OLCX6TBK.mjs +0 -15
- package/dist/chunk-6YRLBITU.mjs.map +0 -1
- package/dist/chunk-AVC6IZJQ.mjs.map +0 -1
- package/dist/chunk-VSHO7PF2.mjs.map +0 -1
- package/docs/api_reference/media/README-1.md +0 -23
- /package/dist/{aiProviderStore-YWJHSWFA.mjs.map → aiProviderStore-3YS2BZU3.mjs.map} +0 -0
- /package/dist/{chat-OLCX6TBK.mjs.map → chat-ZPJNWIXI.mjs.map} +0 -0
- /package/dist/{chunk-CVIOLFMX.mjs.map → chunk-2ZNIQD26.mjs.map} +0 -0
- /package/dist/{chunk-HHKXWNCG.mjs.map → chunk-L7UOQ2Y2.mjs.map} +0 -0
- /package/dist/{chunk-5E7S7DK3.mjs.map → chunk-RTQDQ6TC.mjs.map} +0 -0
- /package/dist/{chunk-6IHJZCUH.mjs.map → chunk-UMPVXYVC.mjs.map} +0 -0
- /package/dist/{chunk-PXXVEH5M.mjs.map → chunk-XEG45Q6V.mjs.map} +0 -0
- /package/dist/{modelStore-CY6SECYD.mjs.map → modelStore-UMJBDSEF.mjs.map} +0 -0
package/README.md
CHANGED
|
@@ -6,18 +6,32 @@
|
|
|
6
6
|
</picture>
|
|
7
7
|
</a>
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
# Bandit Engine ⚡
|
|
10
|
+
|
|
11
|
+
An AI chat toolkit built for speed, design, and control. Power branded AI assistants with battle-tested React components and a secure gateway contract.
|
|
12
|
+
|
|
13
|
+
[](https://www.npmjs.com/package/@burtson-labs/bandit-engine)
|
|
14
|
+
[](https://banditailabs.com/npm-package)
|
|
15
|
+
[](https://banditailabs.com/)
|
|
10
16
|
[](https://www.typescriptlang.org/)
|
|
11
17
|
[](./LICENSE)
|
|
12
18
|
|
|
13
|
-
|
|
14
|
-
|
|
19
|
+
## Features
|
|
20
|
+
- 🔌 Plug-and-play React chat, modal, and management surfaces
|
|
21
|
+
- 🧠 Memory, vector knowledge, and provider switching behind a secure gateway
|
|
22
|
+
- 🎨 Full MUI theming, dark mode, and branding controls out of the box
|
|
23
|
+
- 🌐 Multimodal support (voice, images, documents) with Ollama, OpenAI, Azure, Anthropic
|
|
24
|
+
- 🛠️ CLI scaffolding, sample gateway, and docs to launch in minutes
|
|
15
25
|
|
|
16
|
-
|
|
26
|
+
## Quick Links
|
|
27
|
+
- 📚 Full docs: [banditailabs.com/npm-package](https://banditailabs.com/npm-package) (mirrors `/docs` in this repo)
|
|
28
|
+
- 🎯 Live demo with OAuth sign-in: [banditailabs.com](https://banditailabs.com/)
|
|
29
|
+
- 🧪 Playground (no auth required): [banditailabs.com/playground](https://banditailabs.com/playground)
|
|
30
|
+
- 🔁 Sample gateway: [`examples/gateway-node`](./examples/gateway-node/README.md)
|
|
17
31
|
|
|
18
|
-
|
|
32
|
+
## Quick Start
|
|
19
33
|
|
|
20
|
-
|
|
34
|
+
### CLI Scaffold
|
|
21
35
|
|
|
22
36
|
Want a working playground instantly? Scaffold a Bandit app and gateway in one command:
|
|
23
37
|
|
|
@@ -59,6 +73,16 @@ Check out the [CLI quick start guide](./docs/05_cli_quickstart.md) for the full
|
|
|
59
73
|
|
|
60
74
|
The CLI prints next steps (install, copy `.env`, run dev server) once scaffolding completes, so you can copy-paste and ship immediately.
|
|
61
75
|
|
|
76
|
+
### Playground (Password-Free Preview)
|
|
77
|
+
|
|
78
|
+
Want to feel the UX without wiring a gateway or signing in? Visit the hosted playground:
|
|
79
|
+
|
|
80
|
+
- **URL:** [`https://banditailabs.com/playground`](https://banditailabs.com/playground)
|
|
81
|
+
- **What you get:** Mock streaming answers, conversation starters, and theming preview powered by the built-in `PlaygroundProvider`.
|
|
82
|
+
- **What’s simulated:** Responses come from canned scripts – no external API keys, tokens, or backend required.
|
|
83
|
+
|
|
84
|
+
The playground is ideal for product demos, initial stakeholder reviews, or QA before you connect real providers. When you’re ready to go live, swap the provider back to your gateway for production traffic.
|
|
85
|
+
|
|
62
86
|
## 🛠️ Getting Started – Plug & Play AI
|
|
63
87
|
|
|
64
88
|
|
|
@@ -676,11 +700,13 @@ const chatPackageSettings = {
|
|
|
676
700
|
- 🔄 **Provider Switching**: Change backends without frontend updates
|
|
677
701
|
- 🛡️ **Authentication**: Unified auth across all AI services
|
|
678
702
|
|
|
679
|
-
**Gateway Requirements:**
|
|
703
|
+
**Gateway Requirements:**
|
|
680
704
|
Your gateway API can be built with any technology (Node.js, Python, .NET, Java, etc.) as long as it implements:
|
|
681
|
-
- `GET /api/health`
|
|
682
|
-
- `
|
|
683
|
-
- `POST /api/generate` -
|
|
705
|
+
- `GET /api/health` — Health check endpoint that lists available providers.
|
|
706
|
+
- `GET /api/models` and `GET /api/models/{provider}` — Model discovery for the management UI.
|
|
707
|
+
- `POST /api/chat/completions` and `POST /api/generate` — Default OpenAI-style routes when no provider override is present.
|
|
708
|
+
- `POST /api/{provider}/chat/completions` and `POST /api/{provider}/generate` — Provider-specific routing for `openai`, `azure-openai`, and `anthropic`.
|
|
709
|
+
- `POST /api/ollama/chat` and `POST /api/ollama/generate` — Native Ollama routes (no `/chat/completions` suffix).
|
|
684
710
|
|
|
685
711
|
### Legacy Direct Providers
|
|
686
712
|
|
|
@@ -742,22 +768,32 @@ The Bandit Engine provides comprehensive image support across all AI providers t
|
|
|
742
768
|
Your gateway API should accept images in the standardized format sent by the Bandit Engine and forward them appropriately to each provider. No transformation needed - the frontend handles provider-specific formatting.
|
|
743
769
|
|
|
744
770
|
```javascript
|
|
745
|
-
// Example: Gateway forwards images as-is
|
|
746
|
-
app.post('/api/chat/completions', async (req, res) => {
|
|
747
|
-
const {
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
771
|
+
// Example: Gateway forwards images as-is using provider-specific routes
|
|
772
|
+
app.post('/api/openai/chat/completions', async (req, res) => {
|
|
773
|
+
const { messages, ...options } = req.body;
|
|
774
|
+
const response = await fetch('https://api.openai.com/v1/chat/completions', {
|
|
775
|
+
method: 'POST',
|
|
776
|
+
headers: {
|
|
777
|
+
'Content-Type': 'application/json',
|
|
778
|
+
Authorization: `Bearer ${process.env.OPENAI_API_KEY}`
|
|
779
|
+
},
|
|
780
|
+
body: JSON.stringify({ messages, ...options })
|
|
781
|
+
});
|
|
782
|
+
|
|
783
|
+
res.status(response.status);
|
|
784
|
+
response.body?.pipe(res);
|
|
785
|
+
});
|
|
786
|
+
|
|
787
|
+
app.post('/api/ollama/chat', async (req, res) => {
|
|
788
|
+
const { messages, ...options } = req.body;
|
|
789
|
+
const response = await fetch(`${process.env.OLLAMA_URL}/api/chat`, {
|
|
790
|
+
method: 'POST',
|
|
791
|
+
headers: { 'Content-Type': 'application/json' },
|
|
792
|
+
body: JSON.stringify({ messages, ...options })
|
|
793
|
+
});
|
|
794
|
+
|
|
795
|
+
res.status(response.status);
|
|
796
|
+
response.body?.pipe(res);
|
|
761
797
|
});
|
|
762
798
|
```
|
|
763
799
|
|
|
@@ -1025,7 +1061,7 @@ Your gateway API should validate subscription tiers and return appropriate featu
|
|
|
1025
1061
|
|
|
1026
1062
|
```javascript
|
|
1027
1063
|
// Example: Gateway API subscription validation
|
|
1028
|
-
app.post('/api/chat/completions', authenticateJWT, async (req, res) => {
|
|
1064
|
+
app.post('/api/openai/chat/completions', authenticateJWT, async (req, res) => {
|
|
1029
1065
|
const { subscriptionType, isSubscribed } = req.user;
|
|
1030
1066
|
|
|
1031
1067
|
// Validate tier access for requested features
|
|
@@ -1036,8 +1072,17 @@ app.post('/api/chat/completions', authenticateJWT, async (req, res) => {
|
|
|
1036
1072
|
}
|
|
1037
1073
|
|
|
1038
1074
|
// Proceed with AI request
|
|
1039
|
-
const response = await
|
|
1040
|
-
|
|
1075
|
+
const response = await fetch('https://api.openai.com/v1/chat/completions', {
|
|
1076
|
+
method: 'POST',
|
|
1077
|
+
headers: {
|
|
1078
|
+
'Content-Type': 'application/json',
|
|
1079
|
+
Authorization: `Bearer ${process.env.OPENAI_API_KEY}`
|
|
1080
|
+
},
|
|
1081
|
+
body: JSON.stringify(req.body)
|
|
1082
|
+
});
|
|
1083
|
+
|
|
1084
|
+
res.status(response.status);
|
|
1085
|
+
response.body?.pipe(res);
|
|
1041
1086
|
});
|
|
1042
1087
|
```
|
|
1043
1088
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
useAIProviderStore
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-IHJPVIGB.mjs";
|
|
4
4
|
import "./chunk-KCI46M23.mjs";
|
|
5
5
|
import "./chunk-BJTO5JO5.mjs";
|
|
6
6
|
export {
|
|
7
7
|
useAIProviderStore
|
|
8
8
|
};
|
|
9
|
-
//# sourceMappingURL=aiProviderStore-
|
|
9
|
+
//# sourceMappingURL=aiProviderStore-3YS2BZU3.mjs.map
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import {
|
|
2
|
+
chat_default
|
|
3
|
+
} from "./chunk-5UVULH77.mjs";
|
|
4
|
+
import "./chunk-ONQMRE2G.mjs";
|
|
5
|
+
import "./chunk-RTQDQ6TC.mjs";
|
|
6
|
+
import "./chunk-XEG45Q6V.mjs";
|
|
7
|
+
import "./chunk-UMPVXYVC.mjs";
|
|
8
|
+
import "./chunk-XUBYA5I7.mjs";
|
|
9
|
+
import "./chunk-IHJPVIGB.mjs";
|
|
10
|
+
import "./chunk-KCI46M23.mjs";
|
|
11
|
+
import "./chunk-BJTO5JO5.mjs";
|
|
12
|
+
export {
|
|
13
|
+
chat_default as default
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=chat-ZPJNWIXI.mjs.map
|
package/dist/chat-provider.js
CHANGED
|
@@ -3184,6 +3184,185 @@ var init_gateway_provider = __esm({
|
|
|
3184
3184
|
}
|
|
3185
3185
|
});
|
|
3186
3186
|
|
|
3187
|
+
// src/services/ai-provider/providers/playground.provider.ts
|
|
3188
|
+
var import_rxjs8, PLAYGROUND_MODELS, PLAYGROUND_CONVERSATION_STARTERS, PLAYGROUND_SCRIPTS, FALLBACK_RESPONSE, STREAM_DELAY_MS, PlaygroundProvider;
|
|
3189
|
+
var init_playground_provider = __esm({
|
|
3190
|
+
"src/services/ai-provider/providers/playground.provider.ts"() {
|
|
3191
|
+
"use strict";
|
|
3192
|
+
import_rxjs8 = require("rxjs");
|
|
3193
|
+
init_common_types();
|
|
3194
|
+
PLAYGROUND_MODELS = [
|
|
3195
|
+
{
|
|
3196
|
+
name: "bandit-playground",
|
|
3197
|
+
details: {
|
|
3198
|
+
format: "chat",
|
|
3199
|
+
family: "bandit",
|
|
3200
|
+
families: ["bandit", "demo"],
|
|
3201
|
+
parameter_size: "demo",
|
|
3202
|
+
quantization_level: "synthetic"
|
|
3203
|
+
},
|
|
3204
|
+
digest: "playground-demo-001",
|
|
3205
|
+
modified_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
3206
|
+
},
|
|
3207
|
+
{
|
|
3208
|
+
name: "bandit-starter",
|
|
3209
|
+
details: {
|
|
3210
|
+
format: "chat",
|
|
3211
|
+
family: "bandit",
|
|
3212
|
+
families: ["bandit", "demo"],
|
|
3213
|
+
parameter_size: "demo",
|
|
3214
|
+
quantization_level: "synthetic"
|
|
3215
|
+
},
|
|
3216
|
+
digest: "playground-demo-002",
|
|
3217
|
+
modified_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
3218
|
+
}
|
|
3219
|
+
];
|
|
3220
|
+
PLAYGROUND_CONVERSATION_STARTERS = [
|
|
3221
|
+
"What can I build with Bandit Engine if my backend is not ready yet?",
|
|
3222
|
+
"How does the gateway contract keep API keys out of the browser?",
|
|
3223
|
+
"Can I theme the chat UI to match my product brand?",
|
|
3224
|
+
"How do I switch between Ollama and OpenAI without redeploying the frontend?",
|
|
3225
|
+
"Show me how the management console handles personas and models."
|
|
3226
|
+
];
|
|
3227
|
+
PLAYGROUND_SCRIPTS = [
|
|
3228
|
+
{
|
|
3229
|
+
match: (input) => /model|switch|personas|management/i.test(input),
|
|
3230
|
+
response: [
|
|
3231
|
+
"Absolutely \u2014 the management console ships with live model switching, persona editing, and feature toggles.",
|
|
3232
|
+
"",
|
|
3233
|
+
"- Use the **Models** tab to expose whichever gateway-backed models you want customers to see.",
|
|
3234
|
+
"- Personas hydrate the chat with branded system prompts, voice preferences, and avatars.",
|
|
3235
|
+
"- Everything persists through the gateway, so you can roll out changes without shipping a new build."
|
|
3236
|
+
].join("\n")
|
|
3237
|
+
},
|
|
3238
|
+
{
|
|
3239
|
+
match: (input) => /gateway|api|contract|backend/i.test(input),
|
|
3240
|
+
response: [
|
|
3241
|
+
"The gateway contract keeps secrets on the server while giving the UI a unified AI API.",
|
|
3242
|
+
"",
|
|
3243
|
+
"Key highlights:",
|
|
3244
|
+
"1. `/api/chat/completions` is the default OpenAI-format endpoint when no provider override is set.",
|
|
3245
|
+
"2. `/api/{provider}/chat/completions` handles OpenAI, Azure OpenAI, and Anthropic while `/api/ollama/chat` streams Ollama responses.",
|
|
3246
|
+
"3. The contract is language-agnostic \u2014 Express, FastAPI, .NET, Go\u2026 anything works as long as it speaks HTTP."
|
|
3247
|
+
].join("\n")
|
|
3248
|
+
},
|
|
3249
|
+
{
|
|
3250
|
+
match: (input) => /style|theme|brand|ui/i.test(input),
|
|
3251
|
+
response: [
|
|
3252
|
+
"Every surface in Bandit Engine is themeable.",
|
|
3253
|
+
"",
|
|
3254
|
+
"- Drop a JSON config into your `public/` folder (or host it on a CDN) to control themes, logos, and accent colors.",
|
|
3255
|
+
"- The React components expose hooks for custom headers, menus, and call-to-action buttons.",
|
|
3256
|
+
"- Need a modal? `ChatModal` reuses the same store, so the handoff between embedded chat and floating assistant stays seamless."
|
|
3257
|
+
].join("\n")
|
|
3258
|
+
},
|
|
3259
|
+
{
|
|
3260
|
+
match: (input) => /voice|tts|audio/i.test(input),
|
|
3261
|
+
response: [
|
|
3262
|
+
"Voice is opt-in, but the plumbing is ready.",
|
|
3263
|
+
"",
|
|
3264
|
+
"- Configure `/api/tts` and `/api/stt` on the gateway to unlock the speak/listen controls.",
|
|
3265
|
+
"- The UI lazily loads voices and respects feature flags, so you can leave it disabled in the playground.",
|
|
3266
|
+
"- Everything streams \u2014 the assistant starts speaking before the full response lands."
|
|
3267
|
+
].join("\n")
|
|
3268
|
+
},
|
|
3269
|
+
{
|
|
3270
|
+
match: (input) => /deploy|production|secure/i.test(input),
|
|
3271
|
+
response: [
|
|
3272
|
+
"Production hardening is front and center.",
|
|
3273
|
+
"",
|
|
3274
|
+
"- Gateway tokens ride in the `Authorization` header; rotate them server-side without touching the bundle.",
|
|
3275
|
+
"- Feature flags gate premium surfaces, letting you trial the UI before wiring billing.",
|
|
3276
|
+
"- Vector search, knowledge, and memories are isolated behind `/api/embedding/*` so you can plug in your own storage policies."
|
|
3277
|
+
].join("\n")
|
|
3278
|
+
}
|
|
3279
|
+
];
|
|
3280
|
+
FALLBACK_RESPONSE = [
|
|
3281
|
+
"Bandit Engine is running in playground mode. I'm simulating how streaming works so you can explore the UX without connecting a live model.",
|
|
3282
|
+
"",
|
|
3283
|
+
"Try asking about the gateway contract, theming, voice features, or model management to see tailored walkthroughs."
|
|
3284
|
+
].join("\n");
|
|
3285
|
+
STREAM_DELAY_MS = 350;
|
|
3286
|
+
PlaygroundProvider = class {
|
|
3287
|
+
config;
|
|
3288
|
+
constructor(config) {
|
|
3289
|
+
this.config = { type: "playground" /* PLAYGROUND */, ...config };
|
|
3290
|
+
}
|
|
3291
|
+
chat(request) {
|
|
3292
|
+
const lastUserMessage = [...request.messages].reverse().find((m) => m.role === "user")?.content ?? "";
|
|
3293
|
+
const script = PLAYGROUND_SCRIPTS.find(
|
|
3294
|
+
(scenario) => scenario.match(lastUserMessage)
|
|
3295
|
+
);
|
|
3296
|
+
const responseText = script?.response ?? FALLBACK_RESPONSE;
|
|
3297
|
+
const chunks = this.splitIntoChunks(responseText);
|
|
3298
|
+
return new import_rxjs8.Observable((observer) => {
|
|
3299
|
+
let index = 0;
|
|
3300
|
+
const emitChunk = () => {
|
|
3301
|
+
if (index >= chunks.length) {
|
|
3302
|
+
observer.complete();
|
|
3303
|
+
return;
|
|
3304
|
+
}
|
|
3305
|
+
const chunk = chunks[index];
|
|
3306
|
+
observer.next({
|
|
3307
|
+
message: {
|
|
3308
|
+
content: chunk,
|
|
3309
|
+
role: "assistant"
|
|
3310
|
+
},
|
|
3311
|
+
done: index === chunks.length - 1
|
|
3312
|
+
});
|
|
3313
|
+
index += 1;
|
|
3314
|
+
setTimeout(emitChunk, STREAM_DELAY_MS);
|
|
3315
|
+
};
|
|
3316
|
+
emitChunk();
|
|
3317
|
+
return () => {
|
|
3318
|
+
index = chunks.length;
|
|
3319
|
+
};
|
|
3320
|
+
});
|
|
3321
|
+
}
|
|
3322
|
+
generate(_request) {
|
|
3323
|
+
const starters = PLAYGROUND_CONVERSATION_STARTERS.join("\n");
|
|
3324
|
+
return new import_rxjs8.Observable((observer) => {
|
|
3325
|
+
observer.next({
|
|
3326
|
+
response: starters,
|
|
3327
|
+
done: true
|
|
3328
|
+
});
|
|
3329
|
+
observer.complete();
|
|
3330
|
+
});
|
|
3331
|
+
}
|
|
3332
|
+
listModels() {
|
|
3333
|
+
return new import_rxjs8.Observable((observer) => {
|
|
3334
|
+
observer.next(PLAYGROUND_MODELS);
|
|
3335
|
+
observer.complete();
|
|
3336
|
+
});
|
|
3337
|
+
}
|
|
3338
|
+
async validateServiceAvailability(args) {
|
|
3339
|
+
const simulatedUrl = this.config.baseUrl ?? "playground://local";
|
|
3340
|
+
if (args.timeoutMs > 0) {
|
|
3341
|
+
await new Promise((resolve) => setTimeout(resolve, Math.min(args.timeoutMs, 250)));
|
|
3342
|
+
}
|
|
3343
|
+
return {
|
|
3344
|
+
url: simulatedUrl,
|
|
3345
|
+
isAvailable: true
|
|
3346
|
+
};
|
|
3347
|
+
}
|
|
3348
|
+
getProviderType() {
|
|
3349
|
+
return "playground" /* PLAYGROUND */;
|
|
3350
|
+
}
|
|
3351
|
+
getConfig() {
|
|
3352
|
+
return this.config;
|
|
3353
|
+
}
|
|
3354
|
+
splitIntoChunks(response) {
|
|
3355
|
+
const paragraphs = response.split("\n\n").map((p) => p.trim()).filter(Boolean);
|
|
3356
|
+
if (paragraphs.length <= 1) {
|
|
3357
|
+
const sentences = response.split(/(?<=[.!?])\s+/).filter(Boolean);
|
|
3358
|
+
return sentences.length > 0 ? sentences : [response];
|
|
3359
|
+
}
|
|
3360
|
+
return paragraphs;
|
|
3361
|
+
}
|
|
3362
|
+
};
|
|
3363
|
+
}
|
|
3364
|
+
});
|
|
3365
|
+
|
|
3187
3366
|
// src/services/ai-provider/ai-provider.factory.ts
|
|
3188
3367
|
var AIProviderFactory;
|
|
3189
3368
|
var init_ai_provider_factory = __esm({
|
|
@@ -3195,6 +3374,7 @@ var init_ai_provider_factory = __esm({
|
|
|
3195
3374
|
init_azure_openai_provider();
|
|
3196
3375
|
init_anthropic_provider();
|
|
3197
3376
|
init_gateway_provider();
|
|
3377
|
+
init_playground_provider();
|
|
3198
3378
|
AIProviderFactory = class {
|
|
3199
3379
|
static createProvider(config) {
|
|
3200
3380
|
switch (config.type) {
|
|
@@ -3208,6 +3388,8 @@ var init_ai_provider_factory = __esm({
|
|
|
3208
3388
|
return new AnthropicProvider(config);
|
|
3209
3389
|
case "gateway" /* GATEWAY */:
|
|
3210
3390
|
return new GatewayProvider(config);
|
|
3391
|
+
case "playground" /* PLAYGROUND */:
|
|
3392
|
+
return new PlaygroundProvider(config);
|
|
3211
3393
|
default:
|
|
3212
3394
|
throw new Error(`Unsupported AI provider type: ${config.type}`);
|
|
3213
3395
|
}
|
|
@@ -3218,7 +3400,8 @@ var init_ai_provider_factory = __esm({
|
|
|
3218
3400
|
"openai" /* OPENAI */,
|
|
3219
3401
|
"azure-openai" /* AZURE_OPENAI */,
|
|
3220
3402
|
"anthropic" /* ANTHROPIC */,
|
|
3221
|
-
"gateway" /* GATEWAY
|
|
3403
|
+
"gateway" /* GATEWAY */,
|
|
3404
|
+
"playground" /* PLAYGROUND */
|
|
3222
3405
|
];
|
|
3223
3406
|
}
|
|
3224
3407
|
static validateConfig(config) {
|
|
@@ -3234,6 +3417,8 @@ var init_ai_provider_factory = __esm({
|
|
|
3234
3417
|
return !!config.apiKey;
|
|
3235
3418
|
case "gateway" /* GATEWAY */:
|
|
3236
3419
|
return !!(config.gatewayUrl && config.provider);
|
|
3420
|
+
case "playground" /* PLAYGROUND */:
|
|
3421
|
+
return true;
|
|
3237
3422
|
default:
|
|
3238
3423
|
return false;
|
|
3239
3424
|
}
|
|
@@ -5659,7 +5844,7 @@ var import_mammoth = __toESM(require("mammoth"));
|
|
|
5659
5844
|
var pdfjsLib = __toESM(require("pdfjs-dist/legacy/build/pdf"));
|
|
5660
5845
|
|
|
5661
5846
|
// src/services/prompts/conversationStarters.ts
|
|
5662
|
-
var
|
|
5847
|
+
var import_rxjs9 = require("rxjs");
|
|
5663
5848
|
init_aiProviderStore();
|
|
5664
5849
|
init_packageSettingsStore();
|
|
5665
5850
|
|
|
@@ -5817,19 +6002,19 @@ var NotificationService = class {
|
|
|
5817
6002
|
var notificationService = new NotificationService();
|
|
5818
6003
|
|
|
5819
6004
|
// src/services/prompts/moodDetection.ts
|
|
5820
|
-
var
|
|
6005
|
+
var import_rxjs10 = require("rxjs");
|
|
5821
6006
|
init_aiProviderStore();
|
|
5822
6007
|
init_packageSettingsStore();
|
|
5823
6008
|
init_debugLogger();
|
|
5824
6009
|
|
|
5825
6010
|
// src/services/prompts/detectUserInterestAndExcitement.ts
|
|
5826
|
-
var
|
|
6011
|
+
var import_rxjs11 = require("rxjs");
|
|
5827
6012
|
init_aiProviderStore();
|
|
5828
6013
|
init_packageSettingsStore();
|
|
5829
6014
|
init_debugLogger();
|
|
5830
6015
|
|
|
5831
6016
|
// src/services/prompts/documentSummarization.ts
|
|
5832
|
-
var
|
|
6017
|
+
var import_rxjs12 = require("rxjs");
|
|
5833
6018
|
init_aiProviderStore();
|
|
5834
6019
|
init_packageSettingsStore();
|
|
5835
6020
|
init_debugLogger();
|
|
@@ -5857,8 +6042,8 @@ ${content.slice(0, 4e3)}
|
|
|
5857
6042
|
stream: false,
|
|
5858
6043
|
options: { temperature: 0.3, num_predict: 100 }
|
|
5859
6044
|
});
|
|
5860
|
-
const summary$ = data$.pipe((0,
|
|
5861
|
-
const summary = await (0,
|
|
6045
|
+
const summary$ = data$.pipe((0, import_rxjs12.map)((d) => d.response.trim()));
|
|
6046
|
+
const summary = await (0, import_rxjs12.lastValueFrom)(summary$);
|
|
5862
6047
|
debugLogger.ragDebug("summarizeDocument result", { name, summary });
|
|
5863
6048
|
return summary || `Document summary for ${name}`;
|
|
5864
6049
|
} catch (error) {
|
|
@@ -5868,7 +6053,7 @@ ${content.slice(0, 4e3)}
|
|
|
5868
6053
|
};
|
|
5869
6054
|
|
|
5870
6055
|
// src/services/prompts/documentRelevance.ts
|
|
5871
|
-
var
|
|
6056
|
+
var import_rxjs13 = require("rxjs");
|
|
5872
6057
|
init_aiProviderStore();
|
|
5873
6058
|
init_packageSettingsStore();
|
|
5874
6059
|
init_debugLogger();
|
|
@@ -9331,10 +9516,16 @@ var ChatProvider = (props) => {
|
|
|
9331
9516
|
useProjectStore.getState().hydrate();
|
|
9332
9517
|
useAIQueryStore.getState().hydrate();
|
|
9333
9518
|
useMemoryStore.getState().hydrate();
|
|
9334
|
-
|
|
9335
|
-
|
|
9336
|
-
|
|
9337
|
-
|
|
9519
|
+
const isPlaygroundRoute = typeof window !== "undefined" && window.location.pathname.includes("/playground");
|
|
9520
|
+
const isPlaygroundMode = isPlaygroundRoute || props.packageSettings.playgroundMode === true;
|
|
9521
|
+
if (isPlaygroundMode) {
|
|
9522
|
+
debugLogger.info("ChatProvider: Playground mode detected \u2014 skipping remote preference and sync initialization");
|
|
9523
|
+
} else {
|
|
9524
|
+
await usePreferencesStore.getState().loadPreferences();
|
|
9525
|
+
await useKnowledgeStore.getState().loadDocs();
|
|
9526
|
+
await useMCPToolsStore.getState().loadTools();
|
|
9527
|
+
await useConversationSyncStore.getState().initialize();
|
|
9528
|
+
}
|
|
9338
9529
|
debugLogger.info("ChatProvider about to call initModels - checking for existing branding first");
|
|
9339
9530
|
const storeConfigs6 = [{ name: "config", keyPath: "id" }];
|
|
9340
9531
|
let existingBranding = null;
|
|
@@ -9396,10 +9587,14 @@ var ChatProvider = (props) => {
|
|
|
9396
9587
|
debugLogger.error("\u274C Failed to fetch or apply branding config:", { error: err });
|
|
9397
9588
|
});
|
|
9398
9589
|
}
|
|
9399
|
-
|
|
9400
|
-
|
|
9401
|
-
|
|
9402
|
-
|
|
9590
|
+
if (!isPlaygroundMode) {
|
|
9591
|
+
loadDocuments();
|
|
9592
|
+
embeddingService.backfillMissingEmbeddings().catch((err) => {
|
|
9593
|
+
debugLogger.error("\u274C Failed to backfill memory embeddings:", { error: err });
|
|
9594
|
+
});
|
|
9595
|
+
} else {
|
|
9596
|
+
debugLogger.info("ChatProvider: Playground mode skipping knowledge backfill");
|
|
9597
|
+
}
|
|
9403
9598
|
};
|
|
9404
9599
|
initializeAsync();
|
|
9405
9600
|
}, [props.packageSettings, loadDocuments]);
|