@burtson-labs/bandit-engine 2.0.161 → 2.0.162
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/dist/{aiProviderStore-BNZGM6QU.mjs → aiProviderStore-JOB2H4LP.mjs} +2 -2
- package/dist/chat-LB6UEEEW.mjs +16 -0
- package/dist/chat-provider.js +86 -31
- package/dist/chat-provider.js.map +1 -1
- package/dist/chat-provider.mjs +5 -5
- package/dist/{chunk-TTAORNWI.mjs → chunk-3ACT5BTW.mjs} +6 -6
- package/dist/{chunk-QPXG4A5C.mjs → chunk-47MOBOP3.mjs} +2 -2
- package/dist/{chunk-PFKKGJAQ.mjs → chunk-G5POQT2R.mjs} +2 -2
- package/dist/{chunk-MIDYEQOS.mjs → chunk-ODGVCSKV.mjs} +17 -11
- package/dist/{chunk-MIDYEQOS.mjs.map → chunk-ODGVCSKV.mjs.map} +1 -1
- package/dist/{chunk-FSRMNQRN.mjs → chunk-OGMXL7BF.mjs} +4 -4
- package/dist/{chunk-B3HAQC6F.mjs → chunk-Q6LXVYTC.mjs} +68 -25
- package/dist/chunk-Q6LXVYTC.mjs.map +1 -0
- package/dist/{chunk-EOMOOMUC.mjs → chunk-R6HMLYKQ.mjs} +3 -3
- package/dist/{chunk-XC7HDKFW.mjs → chunk-RUXYVMW2.mjs} +9 -9
- package/dist/{chunk-X65A3NED.mjs → chunk-YHSYHU5P.mjs} +5 -5
- package/dist/{chunk-QXITTH2X.mjs → chunk-ZNK3ELTZ.mjs} +2 -2
- package/dist/index.js +86 -31
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +10 -10
- package/dist/management/management.js +86 -31
- package/dist/management/management.js.map +1 -1
- package/dist/management/management.mjs +8 -8
- 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 +4 -4
- package/package.json +1 -1
- package/dist/chat-3JAV77HO.mjs +0 -16
- package/dist/chunk-B3HAQC6F.mjs.map +0 -1
- /package/dist/{aiProviderStore-BNZGM6QU.mjs.map → aiProviderStore-JOB2H4LP.mjs.map} +0 -0
- /package/dist/{chat-3JAV77HO.mjs.map → chat-LB6UEEEW.mjs.map} +0 -0
- /package/dist/{chunk-TTAORNWI.mjs.map → chunk-3ACT5BTW.mjs.map} +0 -0
- /package/dist/{chunk-QPXG4A5C.mjs.map → chunk-47MOBOP3.mjs.map} +0 -0
- /package/dist/{chunk-PFKKGJAQ.mjs.map → chunk-G5POQT2R.mjs.map} +0 -0
- /package/dist/{chunk-FSRMNQRN.mjs.map → chunk-OGMXL7BF.mjs.map} +0 -0
- /package/dist/{chunk-EOMOOMUC.mjs.map → chunk-R6HMLYKQ.mjs.map} +0 -0
- /package/dist/{chunk-XC7HDKFW.mjs.map → chunk-RUXYVMW2.mjs.map} +0 -0
- /package/dist/{chunk-X65A3NED.mjs.map → chunk-YHSYHU5P.mjs.map} +0 -0
- /package/dist/{chunk-QXITTH2X.mjs.map → chunk-ZNK3ELTZ.mjs.map} +0 -0
|
@@ -1,14 +1,14 @@
|
|
|
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-
|
|
3
|
+
} from "../chunk-RUXYVMW2.mjs";
|
|
4
|
+
import "../chunk-47MOBOP3.mjs";
|
|
5
|
+
import "../chunk-ZNK3ELTZ.mjs";
|
|
6
|
+
import "../chunk-G5POQT2R.mjs";
|
|
7
|
+
import "../chunk-OGMXL7BF.mjs";
|
|
8
|
+
import "../chunk-R6HMLYKQ.mjs";
|
|
9
|
+
import "../chunk-ODGVCSKV.mjs";
|
|
10
10
|
import "../chunk-WQEBTH2R.mjs";
|
|
11
|
-
import "../chunk-
|
|
11
|
+
import "../chunk-Q6LXVYTC.mjs";
|
|
12
12
|
import "../chunk-KCI46M23.mjs";
|
|
13
13
|
import "../chunk-BJTO5JO5.mjs";
|
|
14
14
|
export {
|
|
@@ -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(() => {
|