@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.
Files changed (213) hide show
  1. package/README.md +7 -22
  2. package/dist/aiProviderStore-PEGSX4PK.mjs +9 -0
  3. package/dist/chat-MRDQ2WRJ.mjs +16 -0
  4. package/dist/chat-provider.js +86 -31
  5. package/dist/chat-provider.js.map +1 -1
  6. package/dist/chat-provider.mjs +7 -7
  7. package/dist/{chunk-QXITTH2X.mjs → chunk-5KBTOCQZ.mjs} +4 -4
  8. package/dist/chunk-5KBTOCQZ.mjs.map +1 -0
  9. package/dist/{chunk-B3HAQC6F.mjs → chunk-CQJGUYRW.mjs} +69 -26
  10. package/dist/chunk-CQJGUYRW.mjs.map +1 -0
  11. package/dist/{chunk-TTAORNWI.mjs → chunk-F32P7Q5O.mjs} +122 -232
  12. package/dist/chunk-F32P7Q5O.mjs.map +1 -0
  13. package/dist/{chunk-XC7HDKFW.mjs → chunk-HSGQXL4N.mjs} +11 -11
  14. package/dist/chunk-HSGQXL4N.mjs.map +1 -0
  15. package/dist/{chunk-QPXG4A5C.mjs → chunk-IZX2J65Q.mjs} +2 -2
  16. package/dist/chunk-IZX2J65Q.mjs.map +1 -0
  17. package/dist/{chunk-MIDYEQOS.mjs → chunk-J6SWNO7Z.mjs} +20 -35
  18. package/dist/chunk-J6SWNO7Z.mjs.map +1 -0
  19. package/dist/{chunk-PFKKGJAQ.mjs → chunk-O6P37PFR.mjs} +4 -4
  20. package/dist/chunk-O6P37PFR.mjs.map +1 -0
  21. package/dist/{chunk-KCI46M23.mjs → chunk-OCVZVBQQ.mjs} +1 -1
  22. package/dist/chunk-OCVZVBQQ.mjs.map +1 -0
  23. package/dist/{chunk-IXIM7BNO.mjs → chunk-P4C5IRM5.mjs} +1 -1
  24. package/dist/chunk-P4C5IRM5.mjs.map +1 -0
  25. package/dist/{chunk-WQEBTH2R.mjs → chunk-TY5VL3SG.mjs} +3 -3
  26. package/dist/chunk-TY5VL3SG.mjs.map +1 -0
  27. package/dist/{chunk-X65A3NED.mjs → chunk-URZSIL7X.mjs} +7 -7
  28. package/dist/chunk-URZSIL7X.mjs.map +1 -0
  29. package/dist/{chunk-FSRMNQRN.mjs → chunk-VBHI4TJC.mjs} +6 -6
  30. package/dist/chunk-VBHI4TJC.mjs.map +1 -0
  31. package/dist/{chunk-EOMOOMUC.mjs → chunk-WLNZL6SP.mjs} +5 -16
  32. package/dist/chunk-WLNZL6SP.mjs.map +1 -0
  33. package/dist/index.d.mts +6 -0
  34. package/dist/index.d.ts +6 -0
  35. package/dist/index.js +660 -759
  36. package/dist/index.js.map +1 -1
  37. package/dist/index.mjs +15 -31
  38. package/dist/index.mjs.map +1 -1
  39. package/dist/management/management.js +300 -383
  40. package/dist/management/management.js.map +1 -1
  41. package/dist/management/management.mjs +10 -10
  42. package/dist/{memoryUtils-33TZKHSQ.mjs → memoryUtils-2FVXDSS6.mjs} +1 -1
  43. package/dist/memoryUtils-2FVXDSS6.mjs.map +1 -0
  44. package/dist/modals/chat-modal/chat-modal.js +86 -31
  45. package/dist/modals/chat-modal/chat-modal.js.map +1 -1
  46. package/dist/modals/chat-modal/chat-modal.mjs +6 -6
  47. package/dist/modelStore-7XYYDCNC.mjs +9 -0
  48. package/dist/shared/custom-element.js.map +1 -1
  49. package/dist/shared/custom-element.mjs +1 -1
  50. package/docs/05_contributing.md +1 -1
  51. package/docs/api_reference/assets/navigation.js +1 -1
  52. package/docs/api_reference/assets/search.js +1 -1
  53. package/docs/api_reference/classes/DebugLogger.html +11 -11
  54. package/docs/api_reference/classes/FeatureFlagService.html +13 -13
  55. package/docs/api_reference/classes/NotificationService.html +10 -10
  56. package/docs/api_reference/classes/StreamingTTSClient.html +9 -9
  57. package/docs/api_reference/classes/VectorDatabaseService.html +24 -24
  58. package/docs/api_reference/classes/VectorMigrationService.html +8 -8
  59. package/docs/api_reference/classes/VoiceService.html +2 -2
  60. package/docs/api_reference/enums/TTSState.html +2 -2
  61. package/docs/api_reference/functions/Chat.html +1 -1
  62. package/docs/api_reference/functions/ChatModal.html +1 -1
  63. package/docs/api_reference/functions/ChatProvider.html +1 -1
  64. package/docs/api_reference/functions/FeatureFlagProvider.html +1 -1
  65. package/docs/api_reference/functions/FeedbackButton.html +1 -1
  66. package/docs/api_reference/functions/FeedbackModal.html +1 -1
  67. package/docs/api_reference/functions/InterestsEditor.html +5 -0
  68. package/docs/api_reference/functions/Management.html +1 -1
  69. package/docs/api_reference/functions/NotificationProvider.html +1 -1
  70. package/docs/api_reference/functions/SubscriptionExpiredGuard.html +1 -1
  71. package/docs/api_reference/functions/SubscriptionExpiredModal.html +1 -1
  72. package/docs/api_reference/functions/defineCustomElement.html +1 -1
  73. package/docs/api_reference/functions/getCriticalConfig.html +2 -1
  74. package/docs/api_reference/functions/getFeatureMatrix.html +1 -1
  75. package/docs/api_reference/functions/getStreamingTTSClient.html +1 -1
  76. package/docs/api_reference/functions/getSystemConstants.html +2 -1
  77. package/docs/api_reference/functions/getTTSState.html +1 -1
  78. package/docs/api_reference/functions/handleHttpError.html +1 -1
  79. package/docs/api_reference/functions/handleSubscriptionUpgrade.html +1 -1
  80. package/docs/api_reference/functions/handleValidationError.html +1 -1
  81. package/docs/api_reference/functions/initializeCoreSystem.html +2 -1
  82. package/docs/api_reference/functions/isWorkspaceAdminRole.html +6 -0
  83. package/docs/api_reference/functions/pauseTTS.html +1 -1
  84. package/docs/api_reference/functions/previewTierUpgrade.html +1 -1
  85. package/docs/api_reference/functions/resolveManagementSections.html +2 -0
  86. package/docs/api_reference/functions/resumeTTS.html +1 -1
  87. package/docs/api_reference/functions/showInfoNotification.html +1 -1
  88. package/docs/api_reference/functions/showSuccessNotification.html +1 -1
  89. package/docs/api_reference/functions/speakWithStreaming.html +1 -1
  90. package/docs/api_reference/functions/stopTTS.html +1 -1
  91. package/docs/api_reference/functions/syncSubscriptionWithAPI.html +1 -1
  92. package/docs/api_reference/functions/updateSubscriptionTier.html +1 -1
  93. package/docs/api_reference/functions/useFeatureFlag.html +1 -1
  94. package/docs/api_reference/functions/useFeatureVisibility.html +1 -1
  95. package/docs/api_reference/functions/useFeatures.html +1 -1
  96. package/docs/api_reference/functions/useGatewayHealth.html +1 -1
  97. package/docs/api_reference/functions/useGatewayMemory.html +1 -1
  98. package/docs/api_reference/functions/useGatewayModels.html +1 -1
  99. package/docs/api_reference/functions/useGlobalTTS.html +1 -1
  100. package/docs/api_reference/functions/useManagementAccess.html +2 -0
  101. package/docs/api_reference/functions/useNotification.html +1 -1
  102. package/docs/api_reference/functions/useNotificationService.html +1 -1
  103. package/docs/api_reference/functions/useTTS.html +1 -1
  104. package/docs/api_reference/functions/useVectorStore.html +1 -1
  105. package/docs/api_reference/functions/useVoiceStore.html +2 -2
  106. package/docs/api_reference/functions/useVoices.html +1 -1
  107. package/docs/api_reference/functions/validateEnvironment.html +2 -1
  108. package/docs/api_reference/functions/validateSystemIntegrity.html +2 -1
  109. package/docs/api_reference/index.html +219 -155
  110. package/docs/api_reference/interfaces/AIChatRequest.html +2 -2
  111. package/docs/api_reference/interfaces/AIChatResponse.html +2 -2
  112. package/docs/api_reference/interfaces/AIGenerateRequest.html +2 -2
  113. package/docs/api_reference/interfaces/AIGenerateResponse.html +2 -2
  114. package/docs/api_reference/interfaces/AIMessage.html +2 -2
  115. package/docs/api_reference/interfaces/AIModel.html +2 -2
  116. package/docs/api_reference/interfaces/AIProviderConfig.html +5 -2
  117. package/docs/api_reference/interfaces/ChatConfig.html +3 -3
  118. package/docs/api_reference/interfaces/ChatModalProps.html +3 -3
  119. package/docs/api_reference/interfaces/CreateMemoryOptions.html +2 -2
  120. package/docs/api_reference/interfaces/FeatureEvaluation.html +7 -7
  121. package/docs/api_reference/interfaces/FeatureFlagConfig.html +9 -9
  122. package/docs/api_reference/interfaces/FeatureFlagContextValue.html +8 -8
  123. package/docs/api_reference/interfaces/FeatureFlagProviderProps.html +2 -2
  124. package/docs/api_reference/interfaces/FeedbackButtonProps.html +10 -10
  125. package/docs/api_reference/interfaces/FeedbackCategories.html +2 -2
  126. package/docs/api_reference/interfaces/FeedbackModalProps.html +2 -2
  127. package/docs/api_reference/interfaces/FeedbackPriorities.html +2 -2
  128. package/docs/api_reference/interfaces/FeedbackRequest.html +2 -2
  129. package/docs/api_reference/interfaces/FeedbackResponse.html +2 -2
  130. package/docs/api_reference/interfaces/FileUploadResult.html +2 -2
  131. package/docs/api_reference/interfaces/GatewayChatRequest.html +3 -2
  132. package/docs/api_reference/interfaces/GatewayChatResponse.html +2 -2
  133. package/docs/api_reference/interfaces/GatewayContract.html +2 -2
  134. package/docs/api_reference/interfaces/GatewayGenerateRequest.html +2 -2
  135. package/docs/api_reference/interfaces/GatewayGenerateResponse.html +2 -2
  136. package/docs/api_reference/interfaces/GatewayHealthResponse.html +2 -2
  137. package/docs/api_reference/interfaces/GatewayMemoryRecord.html +2 -2
  138. package/docs/api_reference/interfaces/GatewayMemoryResponse.html +2 -2
  139. package/docs/api_reference/interfaces/GatewayMessage.html +2 -2
  140. package/docs/api_reference/interfaces/GatewayMessageContent.html +2 -2
  141. package/docs/api_reference/interfaces/GatewayModel.html +2 -2
  142. package/docs/api_reference/interfaces/GatewayModelsResponse.html +2 -2
  143. package/docs/api_reference/interfaces/ManagementAccess.html +5 -0
  144. package/docs/api_reference/interfaces/ManagementAccessInput.html +5 -0
  145. package/docs/api_reference/interfaces/ManagementLink.html +7 -0
  146. package/docs/api_reference/interfaces/ManagementProps.html +22 -0
  147. package/docs/api_reference/interfaces/ManagementSectionDef.html +10 -0
  148. package/docs/api_reference/interfaces/MemorySearchFilters.html +2 -2
  149. package/docs/api_reference/interfaces/MigrationProgress.html +2 -2
  150. package/docs/api_reference/interfaces/MigrationStatus.html +2 -2
  151. package/docs/api_reference/interfaces/NotificationConfig.html +2 -2
  152. package/docs/api_reference/interfaces/NotificationContextType.html +2 -2
  153. package/docs/api_reference/interfaces/NotificationProviderProps.html +2 -2
  154. package/docs/api_reference/interfaces/PackageSettings.html +11 -2
  155. package/docs/api_reference/interfaces/SearchOptions.html +2 -2
  156. package/docs/api_reference/interfaces/SearchResult.html +2 -2
  157. package/docs/api_reference/interfaces/SubscriptionExpiredGuardProps.html +2 -2
  158. package/docs/api_reference/interfaces/SubscriptionExpiredModalProps.html +2 -2
  159. package/docs/api_reference/interfaces/TTSOptions.html +2 -2
  160. package/docs/api_reference/interfaces/TTSProgress.html +2 -2
  161. package/docs/api_reference/interfaces/TrialUsage.html +2 -2
  162. package/docs/api_reference/interfaces/UploadRequest.html +3 -3
  163. package/docs/api_reference/interfaces/UseTTSReturn.html +2 -2
  164. package/docs/api_reference/interfaces/VectorDocument.html +2 -2
  165. package/docs/api_reference/interfaces/VectorMemory.html +2 -2
  166. package/docs/api_reference/interfaces/VectorMemoryMetadata.html +2 -2
  167. package/docs/api_reference/interfaces/VectorStoreStatus.html +2 -2
  168. package/docs/api_reference/interfaces/VoiceModelsResponse.html +2 -2
  169. package/docs/api_reference/interfaces/VoiceState.html +2 -2
  170. package/docs/api_reference/media/PROTECTION-NOTICE.md +6 -55
  171. package/docs/api_reference/media/README.md +20 -1
  172. package/docs/api_reference/modules.html +18 -6
  173. package/docs/api_reference/types/FeatureKey.html +1 -1
  174. package/docs/api_reference/types/FeatureMatrix.html +1 -1
  175. package/docs/api_reference/types/GatewayQueryOptions.html +1 -1
  176. package/docs/api_reference/types/LogContext.html +1 -1
  177. package/docs/api_reference/types/ManagementRequest.html +1 -0
  178. package/docs/api_reference/types/ManagementSectionId.html +2 -0
  179. package/docs/api_reference/types/SubscriptionTier.html +1 -1
  180. package/docs/api_reference/variables/DEFAULT_TIER_FEATURES.html +1 -1
  181. package/docs/api_reference/variables/FeatureFlagContext.html +1 -1
  182. package/docs/api_reference/variables/MANAGEMENT_SECTIONS.html +1 -0
  183. package/docs/api_reference/variables/OSS_DEFAULT_FEATURES.html +1 -1
  184. package/docs/api_reference/variables/SYSTEM_FLAGS.html +2 -1
  185. package/docs/api_reference/variables/authenticationService.html +1 -1
  186. package/docs/api_reference/variables/debugLogger-1.html +1 -1
  187. package/docs/api_reference/variables/featureFlagService-1.html +1 -1
  188. package/docs/api_reference/variables/notificationService-1.html +1 -1
  189. package/docs/api_reference/variables/vectorDatabaseService-1.html +1 -1
  190. package/docs/api_reference/variables/vectorMigrationService-1.html +1 -1
  191. package/docs/api_reference/variables/voiceService-1.html +1 -1
  192. package/package.json +1 -1
  193. package/dist/aiProviderStore-BNZGM6QU.mjs +0 -9
  194. package/dist/chat-3JAV77HO.mjs +0 -16
  195. package/dist/chunk-B3HAQC6F.mjs.map +0 -1
  196. package/dist/chunk-EOMOOMUC.mjs.map +0 -1
  197. package/dist/chunk-FSRMNQRN.mjs.map +0 -1
  198. package/dist/chunk-IXIM7BNO.mjs.map +0 -1
  199. package/dist/chunk-KCI46M23.mjs.map +0 -1
  200. package/dist/chunk-MIDYEQOS.mjs.map +0 -1
  201. package/dist/chunk-PFKKGJAQ.mjs.map +0 -1
  202. package/dist/chunk-QPXG4A5C.mjs.map +0 -1
  203. package/dist/chunk-QXITTH2X.mjs.map +0 -1
  204. package/dist/chunk-TTAORNWI.mjs.map +0 -1
  205. package/dist/chunk-WQEBTH2R.mjs.map +0 -1
  206. package/dist/chunk-X65A3NED.mjs.map +0 -1
  207. package/dist/chunk-XC7HDKFW.mjs.map +0 -1
  208. package/dist/memoryUtils-33TZKHSQ.mjs.map +0 -1
  209. package/dist/modelStore-FGUGOWTL.mjs +0 -9
  210. package/docs/api_reference/media/PROTECTION-README.md +0 -39
  211. /package/dist/{aiProviderStore-BNZGM6QU.mjs.map → aiProviderStore-PEGSX4PK.mjs.map} +0 -0
  212. /package/dist/{chat-3JAV77HO.mjs.map → chat-MRDQ2WRJ.mjs.map} +0 -0
  213. /package/dist/{modelStore-FGUGOWTL.mjs.map → modelStore-7XYYDCNC.mjs.map} +0 -0
package/README.md CHANGED
@@ -1350,29 +1350,14 @@ Before contributing or publishing a new Pull Request, run the available validati
1350
1350
  npm run lint # Static analysis for the src tree
1351
1351
  npm run test # Vitest suite
1352
1352
  npm run build # Generate the dist bundle with tsup
1353
- npm run validate-protection # Ensure license headers and fingerprints are intact
1353
+ npm run validate-protection # Check source notice presence
1354
1354
  ```
1355
1355
 
1356
- **Developer Resources:**
1357
- - **[PROTECTION-README.md](./PROTECTION-README.md)** - Quick protection system guide
1358
- - **[PRE-PUSH-CHECKLIST.md](./PRE-PUSH-CHECKLIST.md)** - Complete workflow documentation
1359
- - **[PROTECTION-NOTICE.md](./PROTECTION-NOTICE.md)** - Legal notices and compliance requirements
1360
- - **[LICENSE](./LICENSE)** - Full BUSL 1.1 license text
1356
+ **Developer resources:**
1357
+ - [PRE-PUSH-CHECKLIST.md](./PRE-PUSH-CHECKLIST.md) — build, test, and package checks.
1358
+ - [PROTECTION-NOTICE.md](./PROTECTION-NOTICE.md) — source notices and deprecated compatibility helpers.
1359
+ - [LICENSE](./LICENSE) — the repository's current license terms.
1361
1360
 
1362
- ### <img src="https://icons.burtson.ai/svg-accent/edit.svg" width="18" align="center" alt="" /> License Compliance
1361
+ Source notices are attribution, not telemetry or enforcement. They do not track usage or prevent distribution. The legacy helpers with integrity and validation names are deprecated and must not be used as security controls.
1363
1362
 
1364
- All source files must include proper license headers and watermarks. The protection system automatically:
1365
- - Adds license headers to new files
1366
- - Validates compliance on every build
1367
- - Tracks usage and modifications
1368
- - Prevents unauthorized distribution
1369
-
1370
- **Quick Commands:**
1371
- ```bash
1372
- npm run protect # Apply protection to new files
1373
- npm run validate-protection # Check for license violations
1374
- ```
1375
-
1376
- ---
1377
-
1378
- **© 2025 Burtson Labs LLC. All rights reserved.**
1363
+ © 2025 Burtson Labs LLC.
@@ -0,0 +1,9 @@
1
+ import {
2
+ useAIProviderStore
3
+ } from "./chunk-CQJGUYRW.mjs";
4
+ import "./chunk-OCVZVBQQ.mjs";
5
+ import "./chunk-BJTO5JO5.mjs";
6
+ export {
7
+ useAIProviderStore
8
+ };
9
+ //# sourceMappingURL=aiProviderStore-PEGSX4PK.mjs.map
@@ -0,0 +1,16 @@
1
+ import {
2
+ chat_default
3
+ } from "./chunk-F32P7Q5O.mjs";
4
+ import "./chunk-ONQMRE2G.mjs";
5
+ import "./chunk-IZX2J65Q.mjs";
6
+ import "./chunk-O6P37PFR.mjs";
7
+ import "./chunk-WLNZL6SP.mjs";
8
+ import "./chunk-J6SWNO7Z.mjs";
9
+ import "./chunk-TY5VL3SG.mjs";
10
+ import "./chunk-CQJGUYRW.mjs";
11
+ import "./chunk-OCVZVBQQ.mjs";
12
+ import "./chunk-BJTO5JO5.mjs";
13
+ export {
14
+ chat_default as default
15
+ };
16
+ //# sourceMappingURL=chat-MRDQ2WRJ.mjs.map
@@ -1174,6 +1174,40 @@ var init_common_types = __esm({
1174
1174
  }
1175
1175
  });
1176
1176
 
1177
+ // src/services/stream/streamLineParser.ts
1178
+ var SKIP, StreamLineParser;
1179
+ var init_streamLineParser = __esm({
1180
+ "src/services/stream/streamLineParser.ts"() {
1181
+ "use strict";
1182
+ SKIP = { kind: "skip" };
1183
+ StreamLineParser = class {
1184
+ /** Set by `event: ping` until the frame's blank-line terminator. */
1185
+ inHeartbeatFrame = false;
1186
+ next(rawLine) {
1187
+ const line = rawLine.trim();
1188
+ if (!line) {
1189
+ this.inHeartbeatFrame = false;
1190
+ return SKIP;
1191
+ }
1192
+ if (line.startsWith(":")) return SKIP;
1193
+ if (line.startsWith("event:")) {
1194
+ this.inHeartbeatFrame = line.slice(6).trim().toLowerCase() === "ping";
1195
+ return SKIP;
1196
+ }
1197
+ if (line.startsWith("id:") || line.startsWith("retry:")) return SKIP;
1198
+ if (line.startsWith("data:")) {
1199
+ if (this.inHeartbeatFrame) return SKIP;
1200
+ const data = line.slice(5).trim();
1201
+ if (!data) return SKIP;
1202
+ if (data === "[DONE]") return { kind: "done" };
1203
+ return { kind: "json", text: data };
1204
+ }
1205
+ return { kind: "json", text: line };
1206
+ }
1207
+ };
1208
+ }
1209
+ });
1210
+
1177
1211
  // src/services/ollama/ollama.service.ts
1178
1212
  var import_rxjs, handleError, parseResponseBody, OllamaService;
1179
1213
  var init_ollama_service = __esm({
@@ -1181,6 +1215,7 @@ var init_ollama_service = __esm({
1181
1215
  "use strict";
1182
1216
  import_rxjs = require("rxjs");
1183
1217
  init_debugLogger();
1218
+ init_streamLineParser();
1184
1219
  handleError = () => (obs) => obs.pipe(
1185
1220
  (0, import_rxjs.switchMap)(
1186
1221
  (response) => response.ok ? (0, import_rxjs.of)(response) : (0, import_rxjs.throwError)(() => new Error(`Request failed: ${response.status} ${response.statusText}`))
@@ -1271,13 +1306,15 @@ var init_ollama_service = __esm({
1271
1306
  this._throwErrorIfNotOk(url, response);
1272
1307
  const reader = response.body?.getReader();
1273
1308
  const decoder = new TextDecoder();
1309
+ const lineParser = new StreamLineParser();
1274
1310
  let buffer = "";
1275
1311
  const read = () => {
1276
1312
  reader?.read().then(({ done, value }) => {
1277
1313
  if (done) {
1278
- if (buffer.trim() !== "") {
1314
+ const tail = lineParser.next(buffer);
1315
+ if (tail.kind === "json") {
1279
1316
  try {
1280
- observer.next(JSON.parse(buffer));
1317
+ observer.next(JSON.parse(tail.text));
1281
1318
  } catch (err) {
1282
1319
  observer.error(err);
1283
1320
  debugLogger.error("Final chunk parsing error (generate):", { buffer });
@@ -1290,9 +1327,10 @@ var init_ollama_service = __esm({
1290
1327
  const lines = buffer.split("\n");
1291
1328
  buffer = lines.pop() ?? "";
1292
1329
  for (const line of lines) {
1293
- if (line.trim()) {
1330
+ const classified = lineParser.next(line);
1331
+ if (classified.kind === "json") {
1294
1332
  try {
1295
- observer.next(JSON.parse(line));
1333
+ observer.next(JSON.parse(classified.text));
1296
1334
  } catch (err) {
1297
1335
  observer.error(err);
1298
1336
  debugLogger.error("Error parsing JSON line (generate):", { line });
@@ -1322,13 +1360,15 @@ var init_ollama_service = __esm({
1322
1360
  this._throwErrorIfNotOk(url, response);
1323
1361
  const reader = response.body?.getReader();
1324
1362
  const decoder = new TextDecoder();
1363
+ const lineParser = new StreamLineParser();
1325
1364
  let buffer = "";
1326
1365
  const read = () => {
1327
1366
  reader?.read().then(({ done, value }) => {
1328
1367
  if (done) {
1329
- if (buffer.trim() !== "") {
1368
+ const tail = lineParser.next(buffer);
1369
+ if (tail.kind === "json") {
1330
1370
  try {
1331
- observer.next(JSON.parse(buffer));
1371
+ observer.next(JSON.parse(tail.text));
1332
1372
  } catch (err) {
1333
1373
  observer.error(err);
1334
1374
  debugLogger.error("Final chunk parsing error (chat):", { buffer });
@@ -1341,9 +1381,10 @@ var init_ollama_service = __esm({
1341
1381
  const lines = buffer.split("\n");
1342
1382
  buffer = lines.pop() ?? "";
1343
1383
  for (const line of lines) {
1344
- if (line.trim()) {
1384
+ const classified = lineParser.next(line);
1385
+ if (classified.kind === "json") {
1345
1386
  try {
1346
- observer.next(JSON.parse(line));
1387
+ observer.next(JSON.parse(classified.text));
1347
1388
  } catch (err) {
1348
1389
  observer.error(err);
1349
1390
  debugLogger.error("Error parsing JSON line (chat):", { line });
@@ -2237,6 +2278,7 @@ var init_gateway_service = __esm({
2237
2278
  "src/services/gateway/gateway.service.ts"() {
2238
2279
  "use strict";
2239
2280
  import_axios = __toESM(require("axios"));
2281
+ init_streamLineParser();
2240
2282
  import_rxjs6 = require("rxjs");
2241
2283
  init_debugLogger();
2242
2284
  init_authenticationService();
@@ -2418,13 +2460,15 @@ var init_gateway_service = __esm({
2418
2460
  const handleStreamingResponse = async (response) => {
2419
2461
  const reader = response.body?.getReader();
2420
2462
  const decoder = new TextDecoder();
2463
+ const lineParser = new StreamLineParser();
2421
2464
  let buffer = "";
2422
2465
  const read = () => {
2423
2466
  reader?.read().then(({ done, value }) => {
2424
2467
  if (done) {
2425
- if (buffer.trim() !== "") {
2468
+ const tail = lineParser.next(buffer);
2469
+ if (tail.kind === "json") {
2426
2470
  try {
2427
- const finalResponse = JSON.parse(buffer);
2471
+ const finalResponse = JSON.parse(tail.text);
2428
2472
  observer.next(finalResponse);
2429
2473
  } catch (err) {
2430
2474
  debugLogger.error("GatewayService chat final chunk parsing error", { buffer, error: err });
@@ -2438,16 +2482,14 @@ var init_gateway_service = __esm({
2438
2482
  const lines = buffer.split("\n");
2439
2483
  buffer = lines.pop() ?? "";
2440
2484
  for (const line of lines) {
2441
- const trimmed = line.trim();
2442
- if (trimmed) {
2443
- let data = trimmed;
2444
- if (trimmed.startsWith("data: ")) {
2445
- data = trimmed.slice(6);
2446
- if (data === "[DONE]") {
2447
- observer.complete();
2448
- return;
2449
- }
2450
- }
2485
+ const classified = lineParser.next(line);
2486
+ if (classified.kind === "done") {
2487
+ observer.complete();
2488
+ return;
2489
+ }
2490
+ if (classified.kind === "json") {
2491
+ const trimmed = line.trim();
2492
+ const data = classified.text;
2451
2493
  try {
2452
2494
  const parsed = JSON.parse(data);
2453
2495
  if (request.provider === "ollama" && parsed.message) {
@@ -2614,13 +2656,15 @@ var init_gateway_service = __esm({
2614
2656
  }
2615
2657
  const reader = response.body?.getReader();
2616
2658
  const decoder = new TextDecoder();
2659
+ const lineParser = new StreamLineParser();
2617
2660
  let buffer = "";
2618
2661
  const read = () => {
2619
2662
  reader?.read().then(({ done, value }) => {
2620
2663
  if (done) {
2621
- if (buffer.trim() !== "") {
2664
+ const tail = lineParser.next(buffer);
2665
+ if (tail.kind === "json") {
2622
2666
  try {
2623
- observer.next(JSON.parse(buffer));
2667
+ observer.next(JSON.parse(tail.text));
2624
2668
  } catch (err) {
2625
2669
  observer.error(err);
2626
2670
  debugLogger.error("Final chunk parsing error (gateway generate):", { buffer });
@@ -2633,9 +2677,14 @@ var init_gateway_service = __esm({
2633
2677
  const lines = buffer.split("\n");
2634
2678
  buffer = lines.pop() ?? "";
2635
2679
  for (const line of lines) {
2636
- if (line.trim()) {
2680
+ const classified = lineParser.next(line);
2681
+ if (classified.kind === "done") {
2682
+ observer.complete();
2683
+ return;
2684
+ }
2685
+ if (classified.kind === "json") {
2637
2686
  try {
2638
- observer.next(JSON.parse(line));
2687
+ observer.next(JSON.parse(classified.text));
2639
2688
  } catch (err) {
2640
2689
  observer.error(err);
2641
2690
  debugLogger.error("Error parsing JSON line (gateway generate):", { line });
@@ -9380,9 +9429,17 @@ var useVectorStore = () => {
9380
9429
  const hasAnyAdvancedFeatures = isAdvancedVectorFeaturesEnabled;
9381
9430
  const hasVectorAccess = features.isAdmin() || features.hasAdvancedSearch() || features.hasAdvancedMemories();
9382
9431
  const [hasCompatibleProvider, setHasCompatibleProvider] = (0, import_react3.useState)(false);
9432
+ const mountedRef = (0, import_react3.useRef)(true);
9433
+ (0, import_react3.useEffect)(() => {
9434
+ mountedRef.current = true;
9435
+ return () => {
9436
+ mountedRef.current = false;
9437
+ };
9438
+ }, []);
9383
9439
  const checkProviderCompatibility = (0, import_react3.useCallback)(async () => {
9384
9440
  try {
9385
9441
  const { useAIProviderStore: useAIProviderStore2 } = await Promise.resolve().then(() => (init_aiProviderStore(), aiProviderStore_exports));
9442
+ if (!mountedRef.current) return false;
9386
9443
  const aiProviderState = useAIProviderStore2.getState();
9387
9444
  const provider = aiProviderState.provider;
9388
9445
  const config = aiProviderState.config;
@@ -9399,7 +9456,7 @@ var useVectorStore = () => {
9399
9456
  return isCompatible;
9400
9457
  } catch (error) {
9401
9458
  debugLogger.warn("Could not check AI provider for vector compatibility", { error });
9402
- setHasCompatibleProvider(false);
9459
+ if (mountedRef.current) setHasCompatibleProvider(false);
9403
9460
  return false;
9404
9461
  }
9405
9462
  }, []);
@@ -9407,12 +9464,10 @@ var useVectorStore = () => {
9407
9464
  checkProviderCompatibility();
9408
9465
  }, [checkProviderCompatibility]);
9409
9466
  (0, import_react3.useEffect)(() => {
9410
- const checkOnProviderChange = async () => {
9411
- setTimeout(() => {
9412
- checkProviderCompatibility();
9413
- }, 100);
9414
- };
9415
- checkOnProviderChange();
9467
+ const timer = setTimeout(() => {
9468
+ void checkProviderCompatibility();
9469
+ }, 100);
9470
+ return () => clearTimeout(timer);
9416
9471
  }, [authStore.token, checkProviderCompatibility]);
9417
9472
  (0, import_react3.useEffect)(() => {
9418
9473
  const interval = setInterval(() => {