@burtson-labs/bandit-engine 2.0.161 → 2.0.163
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 +7 -22
- package/dist/aiProviderStore-PEGSX4PK.mjs +9 -0
- package/dist/chat-MRDQ2WRJ.mjs +16 -0
- package/dist/chat-provider.js +86 -31
- package/dist/chat-provider.js.map +1 -1
- package/dist/chat-provider.mjs +7 -7
- package/dist/{chunk-QXITTH2X.mjs → chunk-5KBTOCQZ.mjs} +4 -4
- package/dist/chunk-5KBTOCQZ.mjs.map +1 -0
- package/dist/{chunk-B3HAQC6F.mjs → chunk-CQJGUYRW.mjs} +69 -26
- package/dist/chunk-CQJGUYRW.mjs.map +1 -0
- package/dist/{chunk-TTAORNWI.mjs → chunk-F32P7Q5O.mjs} +122 -232
- package/dist/chunk-F32P7Q5O.mjs.map +1 -0
- package/dist/{chunk-XC7HDKFW.mjs → chunk-HSGQXL4N.mjs} +11 -11
- package/dist/chunk-HSGQXL4N.mjs.map +1 -0
- package/dist/{chunk-QPXG4A5C.mjs → chunk-IZX2J65Q.mjs} +2 -2
- package/dist/chunk-IZX2J65Q.mjs.map +1 -0
- package/dist/{chunk-MIDYEQOS.mjs → chunk-J6SWNO7Z.mjs} +20 -35
- package/dist/chunk-J6SWNO7Z.mjs.map +1 -0
- package/dist/{chunk-PFKKGJAQ.mjs → chunk-O6P37PFR.mjs} +4 -4
- package/dist/chunk-O6P37PFR.mjs.map +1 -0
- package/dist/{chunk-KCI46M23.mjs → chunk-OCVZVBQQ.mjs} +1 -1
- package/dist/chunk-OCVZVBQQ.mjs.map +1 -0
- package/dist/{chunk-IXIM7BNO.mjs → chunk-P4C5IRM5.mjs} +1 -1
- package/dist/chunk-P4C5IRM5.mjs.map +1 -0
- package/dist/{chunk-WQEBTH2R.mjs → chunk-TY5VL3SG.mjs} +3 -3
- package/dist/chunk-TY5VL3SG.mjs.map +1 -0
- package/dist/{chunk-X65A3NED.mjs → chunk-URZSIL7X.mjs} +7 -7
- package/dist/chunk-URZSIL7X.mjs.map +1 -0
- package/dist/{chunk-FSRMNQRN.mjs → chunk-VBHI4TJC.mjs} +6 -6
- package/dist/chunk-VBHI4TJC.mjs.map +1 -0
- package/dist/{chunk-EOMOOMUC.mjs → chunk-WLNZL6SP.mjs} +5 -16
- package/dist/chunk-WLNZL6SP.mjs.map +1 -0
- package/dist/index.d.mts +6 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +660 -759
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +15 -31
- package/dist/index.mjs.map +1 -1
- package/dist/management/management.js +300 -383
- package/dist/management/management.js.map +1 -1
- package/dist/management/management.mjs +10 -10
- package/dist/{memoryUtils-33TZKHSQ.mjs → memoryUtils-2FVXDSS6.mjs} +1 -1
- package/dist/memoryUtils-2FVXDSS6.mjs.map +1 -0
- package/dist/modals/chat-modal/chat-modal.js +86 -31
- package/dist/modals/chat-modal/chat-modal.js.map +1 -1
- package/dist/modals/chat-modal/chat-modal.mjs +6 -6
- package/dist/modelStore-7XYYDCNC.mjs +9 -0
- package/dist/shared/custom-element.js.map +1 -1
- package/dist/shared/custom-element.mjs +1 -1
- package/docs/05_contributing.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 +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/InterestsEditor.html +5 -0
- 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 +2 -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 +2 -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 +2 -1
- package/docs/api_reference/functions/isWorkspaceAdminRole.html +6 -0
- package/docs/api_reference/functions/pauseTTS.html +1 -1
- package/docs/api_reference/functions/previewTierUpgrade.html +1 -1
- package/docs/api_reference/functions/resolveManagementSections.html +2 -0
- 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/useManagementAccess.html +2 -0
- 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 +2 -1
- package/docs/api_reference/functions/validateSystemIntegrity.html +2 -1
- package/docs/api_reference/index.html +219 -155
- 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 +5 -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 +3 -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/ManagementAccess.html +5 -0
- package/docs/api_reference/interfaces/ManagementAccessInput.html +5 -0
- package/docs/api_reference/interfaces/ManagementLink.html +7 -0
- package/docs/api_reference/interfaces/ManagementProps.html +22 -0
- package/docs/api_reference/interfaces/ManagementSectionDef.html +10 -0
- 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 +11 -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/PROTECTION-NOTICE.md +6 -55
- package/docs/api_reference/media/README.md +20 -1
- package/docs/api_reference/modules.html +18 -6
- 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/ManagementRequest.html +1 -0
- package/docs/api_reference/types/ManagementSectionId.html +2 -0
- 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/MANAGEMENT_SECTIONS.html +1 -0
- package/docs/api_reference/variables/OSS_DEFAULT_FEATURES.html +1 -1
- package/docs/api_reference/variables/SYSTEM_FLAGS.html +2 -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 +1 -1
- package/dist/aiProviderStore-BNZGM6QU.mjs +0 -9
- package/dist/chat-3JAV77HO.mjs +0 -16
- package/dist/chunk-B3HAQC6F.mjs.map +0 -1
- package/dist/chunk-EOMOOMUC.mjs.map +0 -1
- package/dist/chunk-FSRMNQRN.mjs.map +0 -1
- package/dist/chunk-IXIM7BNO.mjs.map +0 -1
- package/dist/chunk-KCI46M23.mjs.map +0 -1
- package/dist/chunk-MIDYEQOS.mjs.map +0 -1
- package/dist/chunk-PFKKGJAQ.mjs.map +0 -1
- package/dist/chunk-QPXG4A5C.mjs.map +0 -1
- package/dist/chunk-QXITTH2X.mjs.map +0 -1
- package/dist/chunk-TTAORNWI.mjs.map +0 -1
- package/dist/chunk-WQEBTH2R.mjs.map +0 -1
- package/dist/chunk-X65A3NED.mjs.map +0 -1
- package/dist/chunk-XC7HDKFW.mjs.map +0 -1
- package/dist/memoryUtils-33TZKHSQ.mjs.map +0 -1
- package/dist/modelStore-FGUGOWTL.mjs +0 -9
- package/docs/api_reference/media/PROTECTION-README.md +0 -39
- /package/dist/{aiProviderStore-BNZGM6QU.mjs.map → aiProviderStore-PEGSX4PK.mjs.map} +0 -0
- /package/dist/{chat-3JAV77HO.mjs.map → chat-MRDQ2WRJ.mjs.map} +0 -0
- /package/dist/{modelStore-FGUGOWTL.mjs.map → modelStore-7XYYDCNC.mjs.map} +0 -0
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import {
|
|
2
2
|
management_default
|
|
3
|
-
} from "../chunk-
|
|
4
|
-
import "../chunk-
|
|
5
|
-
import "../chunk-
|
|
6
|
-
import "../chunk-
|
|
7
|
-
import "../chunk-
|
|
8
|
-
import "../chunk-
|
|
9
|
-
import "../chunk-
|
|
10
|
-
import "../chunk-
|
|
11
|
-
import "../chunk-
|
|
12
|
-
import "../chunk-
|
|
3
|
+
} from "../chunk-HSGQXL4N.mjs";
|
|
4
|
+
import "../chunk-IZX2J65Q.mjs";
|
|
5
|
+
import "../chunk-5KBTOCQZ.mjs";
|
|
6
|
+
import "../chunk-O6P37PFR.mjs";
|
|
7
|
+
import "../chunk-VBHI4TJC.mjs";
|
|
8
|
+
import "../chunk-WLNZL6SP.mjs";
|
|
9
|
+
import "../chunk-J6SWNO7Z.mjs";
|
|
10
|
+
import "../chunk-TY5VL3SG.mjs";
|
|
11
|
+
import "../chunk-CQJGUYRW.mjs";
|
|
12
|
+
import "../chunk-OCVZVBQQ.mjs";
|
|
13
13
|
import "../chunk-BJTO5JO5.mjs";
|
|
14
14
|
export {
|
|
15
15
|
management_default as default
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/utils/memoryUtils.ts"],"sourcesContent":["/*\n * Copyright (c) 2025 Burtson Labs LLC.\n * SPDX-License-Identifier: BUSL-1.1\n * See LICENSE for the applicable terms.\n */\n\n\nexport interface BulkMemoryResult {\n success: boolean;\n message: string;\n totalProcessed: number;\n successCount: number;\n failureCount: number;\n errors: string[];\n}\n\nexport interface MemoryImportOptions {\n mode: 'append' | 'replace' | 'smartDedupe';\n clearExisting?: boolean;\n includeMetadata?: boolean;\n batchSize?: number;\n}\n\ntype MemoryRecordCandidate = {\n content?: unknown;\n title?: unknown;\n tags?: unknown;\n timestamp?: unknown;\n};\n\ntype BatchOperationResult = {\n summary?: {\n totalProcessed?: number;\n successCount?: number;\n failureCount?: number;\n };\n totalMemories?: number;\n successCount?: number;\n failureCount?: number;\n};\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n typeof value === 'object' && value !== null;\n\nconst isStringArray = (value: unknown): value is string[] =>\n Array.isArray(value) && value.every((item) => typeof item === 'string');\n\nconst resolveTimestampLabel = (timestamp: unknown): string => {\n if (timestamp instanceof Date && !Number.isNaN(timestamp.getTime())) {\n return timestamp.toLocaleDateString();\n }\n\n if (typeof timestamp === 'number' && Number.isFinite(timestamp)) {\n const date = new Date(timestamp);\n if (!Number.isNaN(date.getTime())) {\n return date.toLocaleDateString();\n }\n }\n\n if (typeof timestamp === 'string' && timestamp.trim()) {\n const date = new Date(timestamp);\n if (!Number.isNaN(date.getTime())) {\n return date.toLocaleDateString();\n }\n }\n\n return new Date().toLocaleDateString();\n};\n\n/**\n * Memory Utilities for Bulk Operations\n * \n * Provides helper functions for batch memory operations,\n * data formatting, and migration utilities.\n */\nexport class MemoryUtils {\n /**\n * Validate memory content before bulk operations\n */\n static validateMemories(memories: Array<{ content: string; title?: string; tags?: string[] }>): {\n valid: Array<{ content: string; title?: string; tags?: string[] }>;\n invalid: Array<{ content: string; error: string; index: number }>;\n } {\n const valid: Array<{ content: string; title?: string; tags?: string[] }> = [];\n const invalid: Array<{ content: string; error: string; index: number }> = [];\n\n memories.forEach((memory, index) => {\n // Check content length\n if (!memory.content || memory.content.trim().length === 0) {\n invalid.push({\n content: memory.content || '',\n error: 'Empty content',\n index\n });\n return;\n }\n\n // Check maximum content length (e.g., 50KB)\n if (memory.content.length > 50000) {\n invalid.push({\n content: memory.content.substring(0, 100) + '...',\n error: 'Content too long (max 50KB)',\n index\n });\n return;\n }\n\n // Check tags format\n if (memory.tags && (!Array.isArray(memory.tags) || memory.tags.some(tag => typeof tag !== 'string'))) {\n invalid.push({\n content: memory.content.substring(0, 100) + '...',\n error: 'Invalid tags format (must be string array)',\n index\n });\n return;\n }\n\n valid.push(memory);\n });\n\n return { valid, invalid };\n }\n\n /**\n * Format IndexedDB memories for vector import\n */\n static formatForVectorImport(indexedDBMemories: ReadonlyArray<unknown>): Array<{ content: string; title?: string; tags?: string[] }> {\n return indexedDBMemories.reduce<Array<{ content: string; title?: string; tags?: string[] }>>((acc, entry) => {\n if (!isRecord(entry)) {\n return acc;\n }\n\n const candidate = entry as MemoryRecordCandidate;\n if (typeof candidate.content !== 'string') {\n return acc;\n }\n\n const title = typeof candidate.title === 'string' && candidate.title.trim().length > 0\n ? candidate.title\n : `Memory from ${resolveTimestampLabel(candidate.timestamp)}`;\n\n const tags = isStringArray(candidate.tags) ? candidate.tags : [];\n\n acc.push({\n content: candidate.content,\n title,\n tags\n });\n return acc;\n }, []);\n }\n\n /**\n * Chunk large batch operations for better performance\n */\n static chunkMemories<T>(\n memories: T[], \n chunkSize: number = 100\n ): T[][] {\n const chunks: T[][] = [];\n for (let i = 0; i < memories.length; i += chunkSize) {\n chunks.push(memories.slice(i, i + chunkSize));\n }\n return chunks;\n }\n\n /**\n * Estimate batch operation time and resource usage\n */\n static estimateBatchOperation(memoryCount: number, averageContentLength: number): {\n estimatedTimeMinutes: number;\n estimatedTokens: number;\n recommendedChunkSize: number;\n warnings: string[];\n } {\n const warnings: string[] = [];\n \n // Rough estimates based on typical embedding performance\n const embeddingsPerMinute = 100; // Conservative estimate\n const tokensPerCharacter = 0.25; // Rough estimate for token calculation\n \n const estimatedTimeMinutes = Math.ceil(memoryCount / embeddingsPerMinute);\n const estimatedTokens = Math.ceil(memoryCount * averageContentLength * tokensPerCharacter);\n \n // Recommend smaller chunks for large operations\n let recommendedChunkSize = 50;\n if (memoryCount > 1000) {\n recommendedChunkSize = 25;\n warnings.push('Large batch operation - consider running during off-peak hours');\n }\n if (averageContentLength > 2000) {\n recommendedChunkSize = Math.max(10, recommendedChunkSize / 2);\n warnings.push('Large content size - reduced chunk size recommended');\n }\n if (estimatedTimeMinutes > 30) {\n warnings.push('Long operation expected - ensure stable internet connection');\n }\n\n return {\n estimatedTimeMinutes,\n estimatedTokens,\n recommendedChunkSize,\n warnings\n };\n }\n\n /**\n * Create summary report for batch operations\n */\n static createBatchSummary(\n result: BatchOperationResult,\n operationType: 'import' | 'create' | 'migrate',\n startTime: Date\n ): {\n summary: string;\n details: {\n operation: string;\n duration: string;\n totalMemories: number;\n successful: number;\n failed: number;\n successRate: string;\n averageTimePerMemory: string;\n };\n } {\n const endTime = new Date();\n const durationMs = endTime.getTime() - startTime.getTime();\n const durationMinutes = Math.floor(durationMs / 60000);\n const durationSeconds = Math.floor((durationMs % 60000) / 1000);\n \n const totalMemories = result.summary?.totalProcessed ?? result.totalMemories ?? 0;\n const successful = result.summary?.successCount ?? result.successCount ?? 0;\n const failed = result.summary?.failureCount ?? result.failureCount ?? 0;\n const successRate = totalMemories > 0 ? ((successful / totalMemories) * 100).toFixed(1) : '0';\n const avgTimePerMemory = totalMemories > 0 ? (durationMs / totalMemories).toFixed(0) : '0';\n\n const summary = `${operationType.toUpperCase()} completed: ${successful}/${totalMemories} memories processed successfully (${successRate}% success rate) in ${durationMinutes}m ${durationSeconds}s`;\n\n const details = {\n operation: operationType,\n duration: `${durationMinutes}m ${durationSeconds}s`,\n totalMemories,\n successful,\n failed,\n successRate: `${successRate}%`,\n averageTimePerMemory: `${avgTimePerMemory}ms`\n };\n\n return { summary, details };\n }\n\n /**\n * Generate progress messages for UI updates\n */\n static generateProgressMessage(\n current: number, \n total: number, \n operation: string = 'Processing'\n ): string {\n const percentage = Math.floor((current / total) * 100);\n const remaining = total - current;\n \n if (current === 0) {\n return `Starting ${operation.toLowerCase()}...`;\n } else if (current === total) {\n return `${operation} completed!`;\n } else if (current < total / 4) {\n return `${operation} memories... (${current}/${total})`;\n } else if (current < total / 2) {\n return `${percentage}% complete... (${remaining} remaining)`;\n } else if (current < total * 0.9) {\n return `Almost done... ${percentage}% complete`;\n } else {\n return `Finishing up... ${remaining} memories left`;\n }\n }\n\n /**\n * Compare memory content for deduplication\n */\n static calculateSimilarity(content1: string, content2: string): number {\n // Simple similarity check - could be enhanced with more sophisticated algorithms\n const words1 = content1.toLowerCase().split(/\\s+/);\n const words2 = content2.toLowerCase().split(/\\s+/);\n \n const set1 = new Set(words1);\n const set2 = new Set(words2);\n \n const intersection = new Set([...set1].filter(word => set2.has(word)));\n const union = new Set([...set1, ...set2]);\n \n return union.size > 0 ? intersection.size / union.size : 0;\n }\n\n /**\n * Find potential duplicates in memory list\n */\n static findPotentialDuplicates(\n memories: Array<{ content: string; title?: string; tags?: string[] }>,\n similarityThreshold: number = 0.8\n ): Array<{\n memory: { content: string; title?: string; tags?: string[] };\n duplicates: Array<{\n memory: { content: string; title?: string; tags?: string[] };\n similarity: number;\n index: number;\n }>;\n }> {\n const duplicates: Array<{\n memory: { content: string; title?: string; tags?: string[] };\n duplicates: Array<{\n memory: { content: string; title?: string; tags?: string[] };\n similarity: number;\n index: number;\n }>;\n }> = [];\n\n for (let i = 0; i < memories.length; i++) {\n const currentMemory = memories[i];\n const potentialDuplicates: Array<{\n memory: { content: string; title?: string; tags?: string[] };\n similarity: number;\n index: number;\n }> = [];\n\n for (let j = i + 1; j < memories.length; j++) {\n const compareMemory = memories[j];\n const similarity = this.calculateSimilarity(currentMemory.content, compareMemory.content);\n \n if (similarity >= similarityThreshold) {\n potentialDuplicates.push({\n memory: compareMemory,\n similarity,\n index: j\n });\n }\n }\n\n if (potentialDuplicates.length > 0) {\n duplicates.push({\n memory: currentMemory,\n duplicates: potentialDuplicates\n });\n }\n }\n\n return duplicates;\n }\n}\n\n// Export utility functions for direct use\nexport const validateMemories = MemoryUtils.validateMemories;\nexport const formatForVectorImport = MemoryUtils.formatForVectorImport;\nexport const chunkMemories = MemoryUtils.chunkMemories;\nexport const estimateBatchOperation = MemoryUtils.estimateBatchOperation;\nexport const createBatchSummary = MemoryUtils.createBatchSummary;\nexport const generateProgressMessage = MemoryUtils.generateProgressMessage;\nexport const findPotentialDuplicates = MemoryUtils.findPotentialDuplicates;\n"],"mappings":";;;AAyCA,IAAM,WAAW,CAAC,UAChB,OAAO,UAAU,YAAY,UAAU;AAEzC,IAAM,gBAAgB,CAAC,UACrB,MAAM,QAAQ,KAAK,KAAK,MAAM,MAAM,CAAC,SAAS,OAAO,SAAS,QAAQ;AAExE,IAAM,wBAAwB,CAAC,cAA+B;AAC5D,MAAI,qBAAqB,QAAQ,CAAC,OAAO,MAAM,UAAU,QAAQ,CAAC,GAAG;AACnE,WAAO,UAAU,mBAAmB;AAAA,EACtC;AAEA,MAAI,OAAO,cAAc,YAAY,OAAO,SAAS,SAAS,GAAG;AAC/D,UAAM,OAAO,IAAI,KAAK,SAAS;AAC/B,QAAI,CAAC,OAAO,MAAM,KAAK,QAAQ,CAAC,GAAG;AACjC,aAAO,KAAK,mBAAmB;AAAA,IACjC;AAAA,EACF;AAEA,MAAI,OAAO,cAAc,YAAY,UAAU,KAAK,GAAG;AACrD,UAAM,OAAO,IAAI,KAAK,SAAS;AAC/B,QAAI,CAAC,OAAO,MAAM,KAAK,QAAQ,CAAC,GAAG;AACjC,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B,YAAY;AAC3C,IAAM,qBAAqB,YAAY;AACvC,IAAM,0BAA0B,YAAY;AAC5C,IAAM,0BAA0B,YAAY;","names":[]}
|
|
@@ -342,6 +342,40 @@ var init_common_types = __esm({
|
|
|
342
342
|
}
|
|
343
343
|
});
|
|
344
344
|
|
|
345
|
+
// src/services/stream/streamLineParser.ts
|
|
346
|
+
var SKIP, StreamLineParser;
|
|
347
|
+
var init_streamLineParser = __esm({
|
|
348
|
+
"src/services/stream/streamLineParser.ts"() {
|
|
349
|
+
"use strict";
|
|
350
|
+
SKIP = { kind: "skip" };
|
|
351
|
+
StreamLineParser = class {
|
|
352
|
+
/** Set by `event: ping` until the frame's blank-line terminator. */
|
|
353
|
+
inHeartbeatFrame = false;
|
|
354
|
+
next(rawLine) {
|
|
355
|
+
const line = rawLine.trim();
|
|
356
|
+
if (!line) {
|
|
357
|
+
this.inHeartbeatFrame = false;
|
|
358
|
+
return SKIP;
|
|
359
|
+
}
|
|
360
|
+
if (line.startsWith(":")) return SKIP;
|
|
361
|
+
if (line.startsWith("event:")) {
|
|
362
|
+
this.inHeartbeatFrame = line.slice(6).trim().toLowerCase() === "ping";
|
|
363
|
+
return SKIP;
|
|
364
|
+
}
|
|
365
|
+
if (line.startsWith("id:") || line.startsWith("retry:")) return SKIP;
|
|
366
|
+
if (line.startsWith("data:")) {
|
|
367
|
+
if (this.inHeartbeatFrame) return SKIP;
|
|
368
|
+
const data = line.slice(5).trim();
|
|
369
|
+
if (!data) return SKIP;
|
|
370
|
+
if (data === "[DONE]") return { kind: "done" };
|
|
371
|
+
return { kind: "json", text: data };
|
|
372
|
+
}
|
|
373
|
+
return { kind: "json", text: line };
|
|
374
|
+
}
|
|
375
|
+
};
|
|
376
|
+
}
|
|
377
|
+
});
|
|
378
|
+
|
|
345
379
|
// src/services/ollama/ollama.service.ts
|
|
346
380
|
var import_rxjs, handleError, parseResponseBody, OllamaService;
|
|
347
381
|
var init_ollama_service = __esm({
|
|
@@ -349,6 +383,7 @@ var init_ollama_service = __esm({
|
|
|
349
383
|
"use strict";
|
|
350
384
|
import_rxjs = require("rxjs");
|
|
351
385
|
init_debugLogger();
|
|
386
|
+
init_streamLineParser();
|
|
352
387
|
handleError = () => (obs) => obs.pipe(
|
|
353
388
|
(0, import_rxjs.switchMap)(
|
|
354
389
|
(response) => response.ok ? (0, import_rxjs.of)(response) : (0, import_rxjs.throwError)(() => new Error(`Request failed: ${response.status} ${response.statusText}`))
|
|
@@ -439,13 +474,15 @@ var init_ollama_service = __esm({
|
|
|
439
474
|
this._throwErrorIfNotOk(url, response);
|
|
440
475
|
const reader = response.body?.getReader();
|
|
441
476
|
const decoder = new TextDecoder();
|
|
477
|
+
const lineParser = new StreamLineParser();
|
|
442
478
|
let buffer = "";
|
|
443
479
|
const read = () => {
|
|
444
480
|
reader?.read().then(({ done, value }) => {
|
|
445
481
|
if (done) {
|
|
446
|
-
|
|
482
|
+
const tail = lineParser.next(buffer);
|
|
483
|
+
if (tail.kind === "json") {
|
|
447
484
|
try {
|
|
448
|
-
observer.next(JSON.parse(
|
|
485
|
+
observer.next(JSON.parse(tail.text));
|
|
449
486
|
} catch (err) {
|
|
450
487
|
observer.error(err);
|
|
451
488
|
debugLogger.error("Final chunk parsing error (generate):", { buffer });
|
|
@@ -458,9 +495,10 @@ var init_ollama_service = __esm({
|
|
|
458
495
|
const lines = buffer.split("\n");
|
|
459
496
|
buffer = lines.pop() ?? "";
|
|
460
497
|
for (const line of lines) {
|
|
461
|
-
|
|
498
|
+
const classified = lineParser.next(line);
|
|
499
|
+
if (classified.kind === "json") {
|
|
462
500
|
try {
|
|
463
|
-
observer.next(JSON.parse(
|
|
501
|
+
observer.next(JSON.parse(classified.text));
|
|
464
502
|
} catch (err) {
|
|
465
503
|
observer.error(err);
|
|
466
504
|
debugLogger.error("Error parsing JSON line (generate):", { line });
|
|
@@ -490,13 +528,15 @@ var init_ollama_service = __esm({
|
|
|
490
528
|
this._throwErrorIfNotOk(url, response);
|
|
491
529
|
const reader = response.body?.getReader();
|
|
492
530
|
const decoder = new TextDecoder();
|
|
531
|
+
const lineParser = new StreamLineParser();
|
|
493
532
|
let buffer = "";
|
|
494
533
|
const read = () => {
|
|
495
534
|
reader?.read().then(({ done, value }) => {
|
|
496
535
|
if (done) {
|
|
497
|
-
|
|
536
|
+
const tail = lineParser.next(buffer);
|
|
537
|
+
if (tail.kind === "json") {
|
|
498
538
|
try {
|
|
499
|
-
observer.next(JSON.parse(
|
|
539
|
+
observer.next(JSON.parse(tail.text));
|
|
500
540
|
} catch (err) {
|
|
501
541
|
observer.error(err);
|
|
502
542
|
debugLogger.error("Final chunk parsing error (chat):", { buffer });
|
|
@@ -509,9 +549,10 @@ var init_ollama_service = __esm({
|
|
|
509
549
|
const lines = buffer.split("\n");
|
|
510
550
|
buffer = lines.pop() ?? "";
|
|
511
551
|
for (const line of lines) {
|
|
512
|
-
|
|
552
|
+
const classified = lineParser.next(line);
|
|
553
|
+
if (classified.kind === "json") {
|
|
513
554
|
try {
|
|
514
|
-
observer.next(JSON.parse(
|
|
555
|
+
observer.next(JSON.parse(classified.text));
|
|
515
556
|
} catch (err) {
|
|
516
557
|
observer.error(err);
|
|
517
558
|
debugLogger.error("Error parsing JSON line (chat):", { line });
|
|
@@ -1528,6 +1569,7 @@ var init_gateway_service = __esm({
|
|
|
1528
1569
|
"src/services/gateway/gateway.service.ts"() {
|
|
1529
1570
|
"use strict";
|
|
1530
1571
|
import_axios = __toESM(require("axios"));
|
|
1572
|
+
init_streamLineParser();
|
|
1531
1573
|
import_rxjs6 = require("rxjs");
|
|
1532
1574
|
init_debugLogger();
|
|
1533
1575
|
init_authenticationService();
|
|
@@ -1709,13 +1751,15 @@ var init_gateway_service = __esm({
|
|
|
1709
1751
|
const handleStreamingResponse = async (response) => {
|
|
1710
1752
|
const reader = response.body?.getReader();
|
|
1711
1753
|
const decoder = new TextDecoder();
|
|
1754
|
+
const lineParser = new StreamLineParser();
|
|
1712
1755
|
let buffer = "";
|
|
1713
1756
|
const read = () => {
|
|
1714
1757
|
reader?.read().then(({ done, value }) => {
|
|
1715
1758
|
if (done) {
|
|
1716
|
-
|
|
1759
|
+
const tail = lineParser.next(buffer);
|
|
1760
|
+
if (tail.kind === "json") {
|
|
1717
1761
|
try {
|
|
1718
|
-
const finalResponse = JSON.parse(
|
|
1762
|
+
const finalResponse = JSON.parse(tail.text);
|
|
1719
1763
|
observer.next(finalResponse);
|
|
1720
1764
|
} catch (err) {
|
|
1721
1765
|
debugLogger.error("GatewayService chat final chunk parsing error", { buffer, error: err });
|
|
@@ -1729,16 +1773,14 @@ var init_gateway_service = __esm({
|
|
|
1729
1773
|
const lines = buffer.split("\n");
|
|
1730
1774
|
buffer = lines.pop() ?? "";
|
|
1731
1775
|
for (const line of lines) {
|
|
1732
|
-
const
|
|
1733
|
-
if (
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
}
|
|
1741
|
-
}
|
|
1776
|
+
const classified = lineParser.next(line);
|
|
1777
|
+
if (classified.kind === "done") {
|
|
1778
|
+
observer.complete();
|
|
1779
|
+
return;
|
|
1780
|
+
}
|
|
1781
|
+
if (classified.kind === "json") {
|
|
1782
|
+
const trimmed = line.trim();
|
|
1783
|
+
const data = classified.text;
|
|
1742
1784
|
try {
|
|
1743
1785
|
const parsed = JSON.parse(data);
|
|
1744
1786
|
if (request.provider === "ollama" && parsed.message) {
|
|
@@ -1905,13 +1947,15 @@ var init_gateway_service = __esm({
|
|
|
1905
1947
|
}
|
|
1906
1948
|
const reader = response.body?.getReader();
|
|
1907
1949
|
const decoder = new TextDecoder();
|
|
1950
|
+
const lineParser = new StreamLineParser();
|
|
1908
1951
|
let buffer = "";
|
|
1909
1952
|
const read = () => {
|
|
1910
1953
|
reader?.read().then(({ done, value }) => {
|
|
1911
1954
|
if (done) {
|
|
1912
|
-
|
|
1955
|
+
const tail = lineParser.next(buffer);
|
|
1956
|
+
if (tail.kind === "json") {
|
|
1913
1957
|
try {
|
|
1914
|
-
observer.next(JSON.parse(
|
|
1958
|
+
observer.next(JSON.parse(tail.text));
|
|
1915
1959
|
} catch (err) {
|
|
1916
1960
|
observer.error(err);
|
|
1917
1961
|
debugLogger.error("Final chunk parsing error (gateway generate):", { buffer });
|
|
@@ -1924,9 +1968,14 @@ var init_gateway_service = __esm({
|
|
|
1924
1968
|
const lines = buffer.split("\n");
|
|
1925
1969
|
buffer = lines.pop() ?? "";
|
|
1926
1970
|
for (const line of lines) {
|
|
1927
|
-
|
|
1971
|
+
const classified = lineParser.next(line);
|
|
1972
|
+
if (classified.kind === "done") {
|
|
1973
|
+
observer.complete();
|
|
1974
|
+
return;
|
|
1975
|
+
}
|
|
1976
|
+
if (classified.kind === "json") {
|
|
1928
1977
|
try {
|
|
1929
|
-
observer.next(JSON.parse(
|
|
1978
|
+
observer.next(JSON.parse(classified.text));
|
|
1930
1979
|
} catch (err) {
|
|
1931
1980
|
observer.error(err);
|
|
1932
1981
|
debugLogger.error("Error parsing JSON line (gateway generate):", { line });
|
|
@@ -9209,9 +9258,17 @@ var useVectorStore = () => {
|
|
|
9209
9258
|
const hasAnyAdvancedFeatures = isAdvancedVectorFeaturesEnabled;
|
|
9210
9259
|
const hasVectorAccess = features.isAdmin() || features.hasAdvancedSearch() || features.hasAdvancedMemories();
|
|
9211
9260
|
const [hasCompatibleProvider, setHasCompatibleProvider] = (0, import_react6.useState)(false);
|
|
9261
|
+
const mountedRef = (0, import_react6.useRef)(true);
|
|
9262
|
+
(0, import_react6.useEffect)(() => {
|
|
9263
|
+
mountedRef.current = true;
|
|
9264
|
+
return () => {
|
|
9265
|
+
mountedRef.current = false;
|
|
9266
|
+
};
|
|
9267
|
+
}, []);
|
|
9212
9268
|
const checkProviderCompatibility = (0, import_react6.useCallback)(async () => {
|
|
9213
9269
|
try {
|
|
9214
9270
|
const { useAIProviderStore: useAIProviderStore2 } = await Promise.resolve().then(() => (init_aiProviderStore(), aiProviderStore_exports));
|
|
9271
|
+
if (!mountedRef.current) return false;
|
|
9215
9272
|
const aiProviderState = useAIProviderStore2.getState();
|
|
9216
9273
|
const provider = aiProviderState.provider;
|
|
9217
9274
|
const config = aiProviderState.config;
|
|
@@ -9228,7 +9285,7 @@ var useVectorStore = () => {
|
|
|
9228
9285
|
return isCompatible;
|
|
9229
9286
|
} catch (error) {
|
|
9230
9287
|
debugLogger.warn("Could not check AI provider for vector compatibility", { error });
|
|
9231
|
-
setHasCompatibleProvider(false);
|
|
9288
|
+
if (mountedRef.current) setHasCompatibleProvider(false);
|
|
9232
9289
|
return false;
|
|
9233
9290
|
}
|
|
9234
9291
|
}, []);
|
|
@@ -9236,12 +9293,10 @@ var useVectorStore = () => {
|
|
|
9236
9293
|
checkProviderCompatibility();
|
|
9237
9294
|
}, [checkProviderCompatibility]);
|
|
9238
9295
|
(0, import_react6.useEffect)(() => {
|
|
9239
|
-
const
|
|
9240
|
-
|
|
9241
|
-
|
|
9242
|
-
|
|
9243
|
-
};
|
|
9244
|
-
checkOnProviderChange();
|
|
9296
|
+
const timer = setTimeout(() => {
|
|
9297
|
+
void checkProviderCompatibility();
|
|
9298
|
+
}, 100);
|
|
9299
|
+
return () => clearTimeout(timer);
|
|
9245
9300
|
}, [authStore.token, checkProviderCompatibility]);
|
|
9246
9301
|
(0, import_react6.useEffect)(() => {
|
|
9247
9302
|
const interval = setInterval(() => {
|