@burtson-labs/bandit-engine 2.0.8 → 2.0.9
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 +2 -2
- package/README.md +87 -27
- package/dist/chat-OLCX6TBK.mjs +15 -0
- package/dist/chat-provider.js +9413 -0
- package/dist/chat-provider.js.map +1 -0
- package/dist/chat-provider.mjs +17 -0
- package/dist/chunk-5E7S7DK3.mjs +231 -0
- package/dist/chunk-5E7S7DK3.mjs.map +1 -0
- package/dist/chunk-6IHJZCUH.mjs +5658 -0
- package/dist/chunk-6IHJZCUH.mjs.map +1 -0
- package/dist/chunk-6YRLBITU.mjs +9418 -0
- package/dist/chunk-6YRLBITU.mjs.map +1 -0
- package/dist/chunk-CVIOLFMX.mjs +259 -0
- package/dist/chunk-CVIOLFMX.mjs.map +1 -0
- package/dist/chunk-HHKXWNCG.mjs +2810 -0
- package/dist/chunk-HHKXWNCG.mjs.map +1 -0
- package/dist/chunk-JQ6UNJNW.mjs +8757 -0
- package/dist/chunk-JQ6UNJNW.mjs.map +1 -0
- package/dist/chunk-ONQMRE2G.mjs +26 -0
- package/dist/chunk-ONQMRE2G.mjs.map +1 -0
- package/dist/chunk-PXXVEH5M.mjs +8925 -0
- package/dist/chunk-PXXVEH5M.mjs.map +1 -0
- package/dist/{chunk-WYS5CZVG.mjs → chunk-QHLKGSMB.mjs} +2 -2
- package/dist/{chunk-WYS5CZVG.mjs.map → chunk-QHLKGSMB.mjs.map} +1 -1
- package/dist/chunk-VSHO7PF2.mjs +150 -0
- package/dist/chunk-VSHO7PF2.mjs.map +1 -0
- package/dist/cli/cli.js +11 -13
- package/dist/cli/cli.js.map +1 -1
- package/dist/gateway-BXVrH8B-.d.mts +312 -0
- package/dist/gateway-BXVrH8B-.d.ts +312 -0
- package/dist/index.d.mts +11 -309
- package/dist/index.d.ts +11 -309
- package/dist/index.js +118 -83
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +86 -11874
- package/dist/index.mjs.map +1 -1
- package/dist/management/management.js +39335 -0
- package/dist/management/management.js.map +1 -0
- package/dist/management/management.mjs +16 -0
- package/dist/management/management.mjs.map +1 -0
- package/dist/{chunk-BIPELT57.mjs → modals/chat-modal/chat-modal.js} +16653 -20880
- package/dist/modals/chat-modal/chat-modal.js.map +1 -0
- package/dist/modals/chat-modal/chat-modal.mjs +19 -0
- package/dist/modals/chat-modal/chat-modal.mjs.map +1 -0
- package/dist/{modelStore-Y3LZWRQC.mjs → modelStore-CY6SECYD.mjs} +2 -2
- package/dist/modelStore-CY6SECYD.mjs.map +1 -0
- package/dist/public-types.d.mts +32 -0
- package/dist/public-types.d.ts +32 -0
- package/docs/04_local_dev.md +1 -1
- package/docs/api_reference/assets/navigation.js +1 -1
- 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 +4 -4
- 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 +97 -26
- 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 +7 -0
- 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 +3 -3
- 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/LICENSE +2 -2
- package/docs/api_reference/media/PROTECTION-README.md +6 -8
- package/docs/api_reference/modules.html +1 -0
- 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 +11 -13
- package/dist/chat-QXB526NZ.mjs +0 -11
- package/dist/chunk-BIPELT57.mjs.map +0 -1
- /package/dist/{chat-QXB526NZ.mjs.map → chat-OLCX6TBK.mjs.map} +0 -0
- /package/dist/{modelStore-Y3LZWRQC.mjs.map → chat-provider.mjs.map} +0 -0
|
@@ -0,0 +1,312 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Common types used across all AI providers
|
|
5
|
+
*/
|
|
6
|
+
interface AIMessage {
|
|
7
|
+
role: 'system' | 'user' | 'assistant';
|
|
8
|
+
content: string;
|
|
9
|
+
}
|
|
10
|
+
interface AIChatRequest {
|
|
11
|
+
model: string;
|
|
12
|
+
messages: AIMessage[];
|
|
13
|
+
stream?: boolean;
|
|
14
|
+
temperature?: number;
|
|
15
|
+
maxTokens?: number;
|
|
16
|
+
images?: string[];
|
|
17
|
+
options?: Record<string, unknown>;
|
|
18
|
+
}
|
|
19
|
+
interface AIChatResponse {
|
|
20
|
+
message: {
|
|
21
|
+
content: string;
|
|
22
|
+
role: 'assistant';
|
|
23
|
+
};
|
|
24
|
+
done?: boolean;
|
|
25
|
+
}
|
|
26
|
+
interface AIGenerateRequest {
|
|
27
|
+
model: string;
|
|
28
|
+
prompt: string;
|
|
29
|
+
stream?: boolean;
|
|
30
|
+
options?: Record<string, unknown>;
|
|
31
|
+
}
|
|
32
|
+
interface AIGenerateResponse {
|
|
33
|
+
response: string;
|
|
34
|
+
done?: boolean;
|
|
35
|
+
}
|
|
36
|
+
interface AIModel {
|
|
37
|
+
name: string;
|
|
38
|
+
size?: number;
|
|
39
|
+
details?: {
|
|
40
|
+
format?: string;
|
|
41
|
+
family?: string;
|
|
42
|
+
families?: string[];
|
|
43
|
+
parameter_size?: string;
|
|
44
|
+
quantization_level?: string;
|
|
45
|
+
};
|
|
46
|
+
digest?: string;
|
|
47
|
+
modified_at?: string;
|
|
48
|
+
}
|
|
49
|
+
interface AIProviderConfig {
|
|
50
|
+
type: 'ollama' | 'openai' | 'azure-openai' | 'anthropic' | 'gateway';
|
|
51
|
+
baseUrl?: string;
|
|
52
|
+
apiKey?: string;
|
|
53
|
+
apiVersion?: string;
|
|
54
|
+
deploymentName?: string;
|
|
55
|
+
gatewayUrl?: string;
|
|
56
|
+
provider?: 'openai' | 'azure-openai' | 'anthropic' | 'ollama';
|
|
57
|
+
tokenFactory?: () => string | null;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Subscription tiers available in the system
|
|
62
|
+
*/
|
|
63
|
+
type SubscriptionTier = 'basic' | 'premium' | 'pro' | 'team' | 'trial' | 'expired';
|
|
64
|
+
/**
|
|
65
|
+
* Available feature keys that can be toggled
|
|
66
|
+
*/
|
|
67
|
+
type FeatureKey = 'memory' | 'documentKnowledge' | 'moodAdaptation' | 'chatSuggestions' | 'tts' | 'stt' | 'adminDashboardEnabled' | 'limitedAdminDashboard' | 'semanticSearchSimple' | 'semanticSearchPremium' | 'advancedSearch' | 'advancedMemories';
|
|
68
|
+
/**
|
|
69
|
+
* Feature matrix defining which features are enabled/disabled
|
|
70
|
+
*/
|
|
71
|
+
type FeatureMatrix = Partial<Record<FeatureKey, boolean>>;
|
|
72
|
+
/**
|
|
73
|
+
* Feature flag configuration interface
|
|
74
|
+
*/
|
|
75
|
+
interface FeatureFlagConfig {
|
|
76
|
+
/** Current subscription tier - if not provided, assumes OSS mode */
|
|
77
|
+
subscriptionType?: SubscriptionTier;
|
|
78
|
+
/** JWT claim key to extract roles from (default: 'roles') */
|
|
79
|
+
rolesClaimKey?: string;
|
|
80
|
+
/** JWT claim key to extract subscription type from (default: 'subscriptionType') */
|
|
81
|
+
subscriptionTypeClaimKey?: string;
|
|
82
|
+
/** JWT claim key to check if subscription is active (default: 'isSubscribed') */
|
|
83
|
+
isSubscribedClaimKey?: string;
|
|
84
|
+
/** LocalStorage key where JWT is stored (default: 'bandit-jwt') */
|
|
85
|
+
jwtStorageKey?: string;
|
|
86
|
+
/** Manual feature overrides - takes precedence in OSS mode */
|
|
87
|
+
featureMatrix?: FeatureMatrix;
|
|
88
|
+
/** Admin role name that grants full access (default: 'admin') */
|
|
89
|
+
adminRole?: string;
|
|
90
|
+
/** Enable debug logging for feature evaluation */
|
|
91
|
+
debug?: boolean;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Default feature matrices for each subscription tier
|
|
95
|
+
*/
|
|
96
|
+
declare const DEFAULT_TIER_FEATURES: Record<SubscriptionTier, FeatureMatrix>;
|
|
97
|
+
/**
|
|
98
|
+
* Open source mode - all features available by default
|
|
99
|
+
*/
|
|
100
|
+
declare const OSS_DEFAULT_FEATURES: FeatureMatrix;
|
|
101
|
+
/**
|
|
102
|
+
* Trial usage information from JWT
|
|
103
|
+
*/
|
|
104
|
+
interface TrialUsage {
|
|
105
|
+
chatRequestsUsed: number;
|
|
106
|
+
chatRequestsLimit: number;
|
|
107
|
+
generateRequestsUsed: number;
|
|
108
|
+
generateRequestsLimit: number;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Feature evaluation result
|
|
112
|
+
*/
|
|
113
|
+
interface FeatureEvaluation {
|
|
114
|
+
/** Current subscription tier (or 'oss' for open source mode) */
|
|
115
|
+
tier: SubscriptionTier | 'oss';
|
|
116
|
+
/** Whether the user has admin role */
|
|
117
|
+
isAdmin: boolean;
|
|
118
|
+
/** Whether the user's subscription is active (false for trial users) */
|
|
119
|
+
isSubscribed: boolean;
|
|
120
|
+
/** Trial usage limits (only present for trial users) */
|
|
121
|
+
trialUsage?: TrialUsage;
|
|
122
|
+
/** Final computed feature matrix */
|
|
123
|
+
features: FeatureMatrix;
|
|
124
|
+
/** Evaluation metadata */
|
|
125
|
+
metadata: {
|
|
126
|
+
jwtFound: boolean;
|
|
127
|
+
jwtValid: boolean;
|
|
128
|
+
rolesExtracted: string[];
|
|
129
|
+
subscriptionTypeFromJWT?: SubscriptionTier;
|
|
130
|
+
isSubscribedFromJWT?: boolean;
|
|
131
|
+
trialUsageFromJWT?: TrialUsage;
|
|
132
|
+
evaluatedAt: number;
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
interface PackageSettings {
|
|
137
|
+
ollamaUrl?: string;
|
|
138
|
+
defaultModel: string;
|
|
139
|
+
fallbackModel?: string;
|
|
140
|
+
aiProvider?: AIProviderConfig;
|
|
141
|
+
gatewayApiUrl: string;
|
|
142
|
+
fileStorageApiUrl?: string;
|
|
143
|
+
brandingConfigUrl: string;
|
|
144
|
+
homeUrl?: string | null;
|
|
145
|
+
feedbackEmail?: string;
|
|
146
|
+
featureFlags?: FeatureFlagConfig;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
interface ChatConfig {
|
|
150
|
+
packageSettings: PackageSettings;
|
|
151
|
+
/** Feature flag configuration - can override packageSettings.featureFlags */
|
|
152
|
+
featureFlags?: FeatureFlagConfig;
|
|
153
|
+
children?: React.ReactNode;
|
|
154
|
+
}
|
|
155
|
+
declare const ChatProvider: React.FC<ChatConfig>;
|
|
156
|
+
|
|
157
|
+
interface ChatModalProps {
|
|
158
|
+
/**
|
|
159
|
+
* Controls whether the modal is rendered. When `true`, the modal
|
|
160
|
+
* mounts and begins loading the latest conversation context.
|
|
161
|
+
*/
|
|
162
|
+
open: boolean;
|
|
163
|
+
/**
|
|
164
|
+
* Invoked when the user clicks the close button or presses escape.
|
|
165
|
+
* Consumers should toggle their `open` state off in this handler.
|
|
166
|
+
*/
|
|
167
|
+
onClose: () => void;
|
|
168
|
+
}
|
|
169
|
+
declare const ChatModal: React.FC<ChatModalProps>;
|
|
170
|
+
|
|
171
|
+
interface VoiceModelsResponse {
|
|
172
|
+
models: string[];
|
|
173
|
+
defaultModel: string;
|
|
174
|
+
fallbackModel: string;
|
|
175
|
+
}
|
|
176
|
+
declare class VoiceService {
|
|
177
|
+
private static instance;
|
|
178
|
+
private cachedModels;
|
|
179
|
+
private cacheTimestamp;
|
|
180
|
+
private readonly CACHE_DURATION;
|
|
181
|
+
private constructor();
|
|
182
|
+
static getInstance(): VoiceService;
|
|
183
|
+
private getGatewayApiUrl;
|
|
184
|
+
private isValid;
|
|
185
|
+
private isCacheValid;
|
|
186
|
+
fetchAvailableVoices(): Promise<VoiceModelsResponse>;
|
|
187
|
+
clearCache(): void;
|
|
188
|
+
}
|
|
189
|
+
declare const voiceService: VoiceService;
|
|
190
|
+
|
|
191
|
+
interface GatewayMessageContent {
|
|
192
|
+
type: 'text' | 'image_url';
|
|
193
|
+
text?: string;
|
|
194
|
+
image_url?: {
|
|
195
|
+
url: string;
|
|
196
|
+
detail?: 'low' | 'high' | 'auto';
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
interface GatewayMessage {
|
|
200
|
+
role: 'system' | 'user' | 'assistant';
|
|
201
|
+
content: string | GatewayMessageContent[];
|
|
202
|
+
name?: string;
|
|
203
|
+
images?: string[];
|
|
204
|
+
}
|
|
205
|
+
interface GatewayChatRequest {
|
|
206
|
+
model: string;
|
|
207
|
+
messages: GatewayMessage[];
|
|
208
|
+
stream?: boolean;
|
|
209
|
+
temperature?: number;
|
|
210
|
+
max_tokens?: number;
|
|
211
|
+
top_p?: number;
|
|
212
|
+
frequency_penalty?: number;
|
|
213
|
+
presence_penalty?: number;
|
|
214
|
+
provider?: 'openai' | 'azure-openai' | 'anthropic' | 'ollama';
|
|
215
|
+
stop?: string | string[];
|
|
216
|
+
images?: string[];
|
|
217
|
+
}
|
|
218
|
+
interface GatewayChatResponse {
|
|
219
|
+
id: string;
|
|
220
|
+
object: string;
|
|
221
|
+
created: number;
|
|
222
|
+
model: string;
|
|
223
|
+
choices: {
|
|
224
|
+
index: number;
|
|
225
|
+
delta?: {
|
|
226
|
+
role?: string;
|
|
227
|
+
content?: string;
|
|
228
|
+
};
|
|
229
|
+
message?: {
|
|
230
|
+
role: string;
|
|
231
|
+
content: string;
|
|
232
|
+
};
|
|
233
|
+
finish_reason?: string | null;
|
|
234
|
+
}[];
|
|
235
|
+
usage?: {
|
|
236
|
+
prompt_tokens: number;
|
|
237
|
+
completion_tokens: number;
|
|
238
|
+
total_tokens: number;
|
|
239
|
+
};
|
|
240
|
+
}
|
|
241
|
+
interface GatewayGenerateRequest {
|
|
242
|
+
model: string;
|
|
243
|
+
prompt: string;
|
|
244
|
+
stream?: boolean;
|
|
245
|
+
temperature?: number;
|
|
246
|
+
max_tokens?: number;
|
|
247
|
+
provider?: 'openai' | 'azure-openai' | 'anthropic' | 'ollama';
|
|
248
|
+
stop?: string | string[];
|
|
249
|
+
}
|
|
250
|
+
interface GatewayGenerateResponse {
|
|
251
|
+
model: string;
|
|
252
|
+
created_at: string;
|
|
253
|
+
response: string;
|
|
254
|
+
done: boolean;
|
|
255
|
+
context?: number[];
|
|
256
|
+
total_duration?: number;
|
|
257
|
+
load_duration?: number;
|
|
258
|
+
prompt_eval_count?: number;
|
|
259
|
+
prompt_eval_duration?: number;
|
|
260
|
+
eval_count?: number;
|
|
261
|
+
eval_duration?: number;
|
|
262
|
+
}
|
|
263
|
+
interface GatewayModel {
|
|
264
|
+
id: string;
|
|
265
|
+
name: string;
|
|
266
|
+
provider: string;
|
|
267
|
+
created: number;
|
|
268
|
+
modified_at: string;
|
|
269
|
+
size: number;
|
|
270
|
+
digest: string;
|
|
271
|
+
details?: {
|
|
272
|
+
format: string;
|
|
273
|
+
family: string;
|
|
274
|
+
families: string[];
|
|
275
|
+
parameter_size: string;
|
|
276
|
+
quantization_level: string;
|
|
277
|
+
};
|
|
278
|
+
}
|
|
279
|
+
interface GatewayModelsResponse {
|
|
280
|
+
models: GatewayModel[];
|
|
281
|
+
}
|
|
282
|
+
interface GatewayHealthResponse {
|
|
283
|
+
status: 'healthy' | 'unhealthy';
|
|
284
|
+
version: string;
|
|
285
|
+
providers: {
|
|
286
|
+
name: string;
|
|
287
|
+
status: 'available' | 'unavailable';
|
|
288
|
+
models_count: number;
|
|
289
|
+
}[];
|
|
290
|
+
uptime: number;
|
|
291
|
+
}
|
|
292
|
+
interface GatewayMemoryRecord {
|
|
293
|
+
id: string;
|
|
294
|
+
type: string;
|
|
295
|
+
content: string;
|
|
296
|
+
createdAt: string;
|
|
297
|
+
updatedAt: string;
|
|
298
|
+
metadata?: Record<string, unknown>;
|
|
299
|
+
}
|
|
300
|
+
interface GatewayMemoryResponse {
|
|
301
|
+
records: GatewayMemoryRecord[];
|
|
302
|
+
total: number;
|
|
303
|
+
nextCursor?: string | null;
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
interface GatewayContract {
|
|
307
|
+
chat(request: GatewayChatRequest): Promise<GatewayChatResponse>;
|
|
308
|
+
generate(request: GatewayGenerateRequest): Promise<GatewayGenerateResponse>;
|
|
309
|
+
health(): Promise<GatewayHealthResponse>;
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
export { type AIProviderConfig as A, ChatProvider as C, DEFAULT_TIER_FEATURES as D, type FeatureFlagConfig as F, type GatewayHealthResponse as G, OSS_DEFAULT_FEATURES as O, type PackageSettings as P, type SubscriptionTier as S, type TrialUsage as T, VoiceService as V, type FeatureKey as a, type FeatureEvaluation as b, type GatewayModel as c, type GatewayMemoryResponse as d, ChatModal as e, type FeatureMatrix as f, type ChatConfig as g, type ChatModalProps as h, type VoiceModelsResponse as i, type GatewayContract as j, type GatewayMessageContent as k, type GatewayMessage as l, type GatewayChatRequest as m, type GatewayChatResponse as n, type GatewayGenerateRequest as o, type GatewayGenerateResponse as p, type GatewayModelsResponse as q, type GatewayMemoryRecord as r, type AIModel as s, type AIChatRequest as t, type AIChatResponse as u, voiceService as v, type AIGenerateRequest as w, type AIGenerateResponse as x, type AIMessage as y };
|
|
@@ -0,0 +1,312 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Common types used across all AI providers
|
|
5
|
+
*/
|
|
6
|
+
interface AIMessage {
|
|
7
|
+
role: 'system' | 'user' | 'assistant';
|
|
8
|
+
content: string;
|
|
9
|
+
}
|
|
10
|
+
interface AIChatRequest {
|
|
11
|
+
model: string;
|
|
12
|
+
messages: AIMessage[];
|
|
13
|
+
stream?: boolean;
|
|
14
|
+
temperature?: number;
|
|
15
|
+
maxTokens?: number;
|
|
16
|
+
images?: string[];
|
|
17
|
+
options?: Record<string, unknown>;
|
|
18
|
+
}
|
|
19
|
+
interface AIChatResponse {
|
|
20
|
+
message: {
|
|
21
|
+
content: string;
|
|
22
|
+
role: 'assistant';
|
|
23
|
+
};
|
|
24
|
+
done?: boolean;
|
|
25
|
+
}
|
|
26
|
+
interface AIGenerateRequest {
|
|
27
|
+
model: string;
|
|
28
|
+
prompt: string;
|
|
29
|
+
stream?: boolean;
|
|
30
|
+
options?: Record<string, unknown>;
|
|
31
|
+
}
|
|
32
|
+
interface AIGenerateResponse {
|
|
33
|
+
response: string;
|
|
34
|
+
done?: boolean;
|
|
35
|
+
}
|
|
36
|
+
interface AIModel {
|
|
37
|
+
name: string;
|
|
38
|
+
size?: number;
|
|
39
|
+
details?: {
|
|
40
|
+
format?: string;
|
|
41
|
+
family?: string;
|
|
42
|
+
families?: string[];
|
|
43
|
+
parameter_size?: string;
|
|
44
|
+
quantization_level?: string;
|
|
45
|
+
};
|
|
46
|
+
digest?: string;
|
|
47
|
+
modified_at?: string;
|
|
48
|
+
}
|
|
49
|
+
interface AIProviderConfig {
|
|
50
|
+
type: 'ollama' | 'openai' | 'azure-openai' | 'anthropic' | 'gateway';
|
|
51
|
+
baseUrl?: string;
|
|
52
|
+
apiKey?: string;
|
|
53
|
+
apiVersion?: string;
|
|
54
|
+
deploymentName?: string;
|
|
55
|
+
gatewayUrl?: string;
|
|
56
|
+
provider?: 'openai' | 'azure-openai' | 'anthropic' | 'ollama';
|
|
57
|
+
tokenFactory?: () => string | null;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Subscription tiers available in the system
|
|
62
|
+
*/
|
|
63
|
+
type SubscriptionTier = 'basic' | 'premium' | 'pro' | 'team' | 'trial' | 'expired';
|
|
64
|
+
/**
|
|
65
|
+
* Available feature keys that can be toggled
|
|
66
|
+
*/
|
|
67
|
+
type FeatureKey = 'memory' | 'documentKnowledge' | 'moodAdaptation' | 'chatSuggestions' | 'tts' | 'stt' | 'adminDashboardEnabled' | 'limitedAdminDashboard' | 'semanticSearchSimple' | 'semanticSearchPremium' | 'advancedSearch' | 'advancedMemories';
|
|
68
|
+
/**
|
|
69
|
+
* Feature matrix defining which features are enabled/disabled
|
|
70
|
+
*/
|
|
71
|
+
type FeatureMatrix = Partial<Record<FeatureKey, boolean>>;
|
|
72
|
+
/**
|
|
73
|
+
* Feature flag configuration interface
|
|
74
|
+
*/
|
|
75
|
+
interface FeatureFlagConfig {
|
|
76
|
+
/** Current subscription tier - if not provided, assumes OSS mode */
|
|
77
|
+
subscriptionType?: SubscriptionTier;
|
|
78
|
+
/** JWT claim key to extract roles from (default: 'roles') */
|
|
79
|
+
rolesClaimKey?: string;
|
|
80
|
+
/** JWT claim key to extract subscription type from (default: 'subscriptionType') */
|
|
81
|
+
subscriptionTypeClaimKey?: string;
|
|
82
|
+
/** JWT claim key to check if subscription is active (default: 'isSubscribed') */
|
|
83
|
+
isSubscribedClaimKey?: string;
|
|
84
|
+
/** LocalStorage key where JWT is stored (default: 'bandit-jwt') */
|
|
85
|
+
jwtStorageKey?: string;
|
|
86
|
+
/** Manual feature overrides - takes precedence in OSS mode */
|
|
87
|
+
featureMatrix?: FeatureMatrix;
|
|
88
|
+
/** Admin role name that grants full access (default: 'admin') */
|
|
89
|
+
adminRole?: string;
|
|
90
|
+
/** Enable debug logging for feature evaluation */
|
|
91
|
+
debug?: boolean;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Default feature matrices for each subscription tier
|
|
95
|
+
*/
|
|
96
|
+
declare const DEFAULT_TIER_FEATURES: Record<SubscriptionTier, FeatureMatrix>;
|
|
97
|
+
/**
|
|
98
|
+
* Open source mode - all features available by default
|
|
99
|
+
*/
|
|
100
|
+
declare const OSS_DEFAULT_FEATURES: FeatureMatrix;
|
|
101
|
+
/**
|
|
102
|
+
* Trial usage information from JWT
|
|
103
|
+
*/
|
|
104
|
+
interface TrialUsage {
|
|
105
|
+
chatRequestsUsed: number;
|
|
106
|
+
chatRequestsLimit: number;
|
|
107
|
+
generateRequestsUsed: number;
|
|
108
|
+
generateRequestsLimit: number;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Feature evaluation result
|
|
112
|
+
*/
|
|
113
|
+
interface FeatureEvaluation {
|
|
114
|
+
/** Current subscription tier (or 'oss' for open source mode) */
|
|
115
|
+
tier: SubscriptionTier | 'oss';
|
|
116
|
+
/** Whether the user has admin role */
|
|
117
|
+
isAdmin: boolean;
|
|
118
|
+
/** Whether the user's subscription is active (false for trial users) */
|
|
119
|
+
isSubscribed: boolean;
|
|
120
|
+
/** Trial usage limits (only present for trial users) */
|
|
121
|
+
trialUsage?: TrialUsage;
|
|
122
|
+
/** Final computed feature matrix */
|
|
123
|
+
features: FeatureMatrix;
|
|
124
|
+
/** Evaluation metadata */
|
|
125
|
+
metadata: {
|
|
126
|
+
jwtFound: boolean;
|
|
127
|
+
jwtValid: boolean;
|
|
128
|
+
rolesExtracted: string[];
|
|
129
|
+
subscriptionTypeFromJWT?: SubscriptionTier;
|
|
130
|
+
isSubscribedFromJWT?: boolean;
|
|
131
|
+
trialUsageFromJWT?: TrialUsage;
|
|
132
|
+
evaluatedAt: number;
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
interface PackageSettings {
|
|
137
|
+
ollamaUrl?: string;
|
|
138
|
+
defaultModel: string;
|
|
139
|
+
fallbackModel?: string;
|
|
140
|
+
aiProvider?: AIProviderConfig;
|
|
141
|
+
gatewayApiUrl: string;
|
|
142
|
+
fileStorageApiUrl?: string;
|
|
143
|
+
brandingConfigUrl: string;
|
|
144
|
+
homeUrl?: string | null;
|
|
145
|
+
feedbackEmail?: string;
|
|
146
|
+
featureFlags?: FeatureFlagConfig;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
interface ChatConfig {
|
|
150
|
+
packageSettings: PackageSettings;
|
|
151
|
+
/** Feature flag configuration - can override packageSettings.featureFlags */
|
|
152
|
+
featureFlags?: FeatureFlagConfig;
|
|
153
|
+
children?: React.ReactNode;
|
|
154
|
+
}
|
|
155
|
+
declare const ChatProvider: React.FC<ChatConfig>;
|
|
156
|
+
|
|
157
|
+
interface ChatModalProps {
|
|
158
|
+
/**
|
|
159
|
+
* Controls whether the modal is rendered. When `true`, the modal
|
|
160
|
+
* mounts and begins loading the latest conversation context.
|
|
161
|
+
*/
|
|
162
|
+
open: boolean;
|
|
163
|
+
/**
|
|
164
|
+
* Invoked when the user clicks the close button or presses escape.
|
|
165
|
+
* Consumers should toggle their `open` state off in this handler.
|
|
166
|
+
*/
|
|
167
|
+
onClose: () => void;
|
|
168
|
+
}
|
|
169
|
+
declare const ChatModal: React.FC<ChatModalProps>;
|
|
170
|
+
|
|
171
|
+
interface VoiceModelsResponse {
|
|
172
|
+
models: string[];
|
|
173
|
+
defaultModel: string;
|
|
174
|
+
fallbackModel: string;
|
|
175
|
+
}
|
|
176
|
+
declare class VoiceService {
|
|
177
|
+
private static instance;
|
|
178
|
+
private cachedModels;
|
|
179
|
+
private cacheTimestamp;
|
|
180
|
+
private readonly CACHE_DURATION;
|
|
181
|
+
private constructor();
|
|
182
|
+
static getInstance(): VoiceService;
|
|
183
|
+
private getGatewayApiUrl;
|
|
184
|
+
private isValid;
|
|
185
|
+
private isCacheValid;
|
|
186
|
+
fetchAvailableVoices(): Promise<VoiceModelsResponse>;
|
|
187
|
+
clearCache(): void;
|
|
188
|
+
}
|
|
189
|
+
declare const voiceService: VoiceService;
|
|
190
|
+
|
|
191
|
+
interface GatewayMessageContent {
|
|
192
|
+
type: 'text' | 'image_url';
|
|
193
|
+
text?: string;
|
|
194
|
+
image_url?: {
|
|
195
|
+
url: string;
|
|
196
|
+
detail?: 'low' | 'high' | 'auto';
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
interface GatewayMessage {
|
|
200
|
+
role: 'system' | 'user' | 'assistant';
|
|
201
|
+
content: string | GatewayMessageContent[];
|
|
202
|
+
name?: string;
|
|
203
|
+
images?: string[];
|
|
204
|
+
}
|
|
205
|
+
interface GatewayChatRequest {
|
|
206
|
+
model: string;
|
|
207
|
+
messages: GatewayMessage[];
|
|
208
|
+
stream?: boolean;
|
|
209
|
+
temperature?: number;
|
|
210
|
+
max_tokens?: number;
|
|
211
|
+
top_p?: number;
|
|
212
|
+
frequency_penalty?: number;
|
|
213
|
+
presence_penalty?: number;
|
|
214
|
+
provider?: 'openai' | 'azure-openai' | 'anthropic' | 'ollama';
|
|
215
|
+
stop?: string | string[];
|
|
216
|
+
images?: string[];
|
|
217
|
+
}
|
|
218
|
+
interface GatewayChatResponse {
|
|
219
|
+
id: string;
|
|
220
|
+
object: string;
|
|
221
|
+
created: number;
|
|
222
|
+
model: string;
|
|
223
|
+
choices: {
|
|
224
|
+
index: number;
|
|
225
|
+
delta?: {
|
|
226
|
+
role?: string;
|
|
227
|
+
content?: string;
|
|
228
|
+
};
|
|
229
|
+
message?: {
|
|
230
|
+
role: string;
|
|
231
|
+
content: string;
|
|
232
|
+
};
|
|
233
|
+
finish_reason?: string | null;
|
|
234
|
+
}[];
|
|
235
|
+
usage?: {
|
|
236
|
+
prompt_tokens: number;
|
|
237
|
+
completion_tokens: number;
|
|
238
|
+
total_tokens: number;
|
|
239
|
+
};
|
|
240
|
+
}
|
|
241
|
+
interface GatewayGenerateRequest {
|
|
242
|
+
model: string;
|
|
243
|
+
prompt: string;
|
|
244
|
+
stream?: boolean;
|
|
245
|
+
temperature?: number;
|
|
246
|
+
max_tokens?: number;
|
|
247
|
+
provider?: 'openai' | 'azure-openai' | 'anthropic' | 'ollama';
|
|
248
|
+
stop?: string | string[];
|
|
249
|
+
}
|
|
250
|
+
interface GatewayGenerateResponse {
|
|
251
|
+
model: string;
|
|
252
|
+
created_at: string;
|
|
253
|
+
response: string;
|
|
254
|
+
done: boolean;
|
|
255
|
+
context?: number[];
|
|
256
|
+
total_duration?: number;
|
|
257
|
+
load_duration?: number;
|
|
258
|
+
prompt_eval_count?: number;
|
|
259
|
+
prompt_eval_duration?: number;
|
|
260
|
+
eval_count?: number;
|
|
261
|
+
eval_duration?: number;
|
|
262
|
+
}
|
|
263
|
+
interface GatewayModel {
|
|
264
|
+
id: string;
|
|
265
|
+
name: string;
|
|
266
|
+
provider: string;
|
|
267
|
+
created: number;
|
|
268
|
+
modified_at: string;
|
|
269
|
+
size: number;
|
|
270
|
+
digest: string;
|
|
271
|
+
details?: {
|
|
272
|
+
format: string;
|
|
273
|
+
family: string;
|
|
274
|
+
families: string[];
|
|
275
|
+
parameter_size: string;
|
|
276
|
+
quantization_level: string;
|
|
277
|
+
};
|
|
278
|
+
}
|
|
279
|
+
interface GatewayModelsResponse {
|
|
280
|
+
models: GatewayModel[];
|
|
281
|
+
}
|
|
282
|
+
interface GatewayHealthResponse {
|
|
283
|
+
status: 'healthy' | 'unhealthy';
|
|
284
|
+
version: string;
|
|
285
|
+
providers: {
|
|
286
|
+
name: string;
|
|
287
|
+
status: 'available' | 'unavailable';
|
|
288
|
+
models_count: number;
|
|
289
|
+
}[];
|
|
290
|
+
uptime: number;
|
|
291
|
+
}
|
|
292
|
+
interface GatewayMemoryRecord {
|
|
293
|
+
id: string;
|
|
294
|
+
type: string;
|
|
295
|
+
content: string;
|
|
296
|
+
createdAt: string;
|
|
297
|
+
updatedAt: string;
|
|
298
|
+
metadata?: Record<string, unknown>;
|
|
299
|
+
}
|
|
300
|
+
interface GatewayMemoryResponse {
|
|
301
|
+
records: GatewayMemoryRecord[];
|
|
302
|
+
total: number;
|
|
303
|
+
nextCursor?: string | null;
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
interface GatewayContract {
|
|
307
|
+
chat(request: GatewayChatRequest): Promise<GatewayChatResponse>;
|
|
308
|
+
generate(request: GatewayGenerateRequest): Promise<GatewayGenerateResponse>;
|
|
309
|
+
health(): Promise<GatewayHealthResponse>;
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
export { type AIProviderConfig as A, ChatProvider as C, DEFAULT_TIER_FEATURES as D, type FeatureFlagConfig as F, type GatewayHealthResponse as G, OSS_DEFAULT_FEATURES as O, type PackageSettings as P, type SubscriptionTier as S, type TrialUsage as T, VoiceService as V, type FeatureKey as a, type FeatureEvaluation as b, type GatewayModel as c, type GatewayMemoryResponse as d, ChatModal as e, type FeatureMatrix as f, type ChatConfig as g, type ChatModalProps as h, type VoiceModelsResponse as i, type GatewayContract as j, type GatewayMessageContent as k, type GatewayMessage as l, type GatewayChatRequest as m, type GatewayChatResponse as n, type GatewayGenerateRequest as o, type GatewayGenerateResponse as p, type GatewayModelsResponse as q, type GatewayMemoryRecord as r, type AIModel as s, type AIChatRequest as t, type AIChatResponse as u, voiceService as v, type AIGenerateRequest as w, type AIGenerateResponse as x, type AIMessage as y };
|