@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
package/dist/index.mjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
IS_STORE_BUILD,
|
|
3
3
|
chat_default
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-3ACT5BTW.mjs";
|
|
5
5
|
import {
|
|
6
6
|
chat_provider_default
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-YHSYHU5P.mjs";
|
|
8
8
|
import "./chunk-ONQMRE2G.mjs";
|
|
9
9
|
import {
|
|
10
10
|
MANAGEMENT_SECTIONS,
|
|
@@ -15,17 +15,17 @@ import {
|
|
|
15
15
|
useGatewayMemory,
|
|
16
16
|
useGatewayModels,
|
|
17
17
|
useManagementAccess
|
|
18
|
-
} from "./chunk-
|
|
19
|
-
import "./chunk-
|
|
20
|
-
import "./chunk-
|
|
21
|
-
import "./chunk-
|
|
18
|
+
} from "./chunk-RUXYVMW2.mjs";
|
|
19
|
+
import "./chunk-47MOBOP3.mjs";
|
|
20
|
+
import "./chunk-ZNK3ELTZ.mjs";
|
|
21
|
+
import "./chunk-G5POQT2R.mjs";
|
|
22
22
|
import {
|
|
23
23
|
defineCustomElement
|
|
24
24
|
} from "./chunk-IXIM7BNO.mjs";
|
|
25
25
|
import {
|
|
26
26
|
FeedbackButton,
|
|
27
27
|
chat_modal_default
|
|
28
|
-
} from "./chunk-
|
|
28
|
+
} from "./chunk-OGMXL7BF.mjs";
|
|
29
29
|
import {
|
|
30
30
|
FeedbackModal,
|
|
31
31
|
StreamingTTSClient,
|
|
@@ -42,7 +42,7 @@ import {
|
|
|
42
42
|
useTTS,
|
|
43
43
|
useVoiceStore,
|
|
44
44
|
voiceService
|
|
45
|
-
} from "./chunk-
|
|
45
|
+
} from "./chunk-R6HMLYKQ.mjs";
|
|
46
46
|
import {
|
|
47
47
|
DEFAULT_TIER_FEATURES,
|
|
48
48
|
FeatureFlagContext,
|
|
@@ -61,7 +61,7 @@ import {
|
|
|
61
61
|
useVectorStore,
|
|
62
62
|
vectorDatabaseService,
|
|
63
63
|
vectorMigrationService
|
|
64
|
-
} from "./chunk-
|
|
64
|
+
} from "./chunk-ODGVCSKV.mjs";
|
|
65
65
|
import {
|
|
66
66
|
usePackageSettingsStore,
|
|
67
67
|
usePreferencesStore
|
|
@@ -69,7 +69,7 @@ import {
|
|
|
69
69
|
import {
|
|
70
70
|
authenticationService,
|
|
71
71
|
useAuthenticationStore
|
|
72
|
-
} from "./chunk-
|
|
72
|
+
} from "./chunk-Q6LXVYTC.mjs";
|
|
73
73
|
import {
|
|
74
74
|
DebugLogger,
|
|
75
75
|
debugLogger
|
|
@@ -448,6 +448,40 @@ var init_common_types = __esm({
|
|
|
448
448
|
}
|
|
449
449
|
});
|
|
450
450
|
|
|
451
|
+
// src/services/stream/streamLineParser.ts
|
|
452
|
+
var SKIP, StreamLineParser;
|
|
453
|
+
var init_streamLineParser = __esm({
|
|
454
|
+
"src/services/stream/streamLineParser.ts"() {
|
|
455
|
+
"use strict";
|
|
456
|
+
SKIP = { kind: "skip" };
|
|
457
|
+
StreamLineParser = class {
|
|
458
|
+
/** Set by `event: ping` until the frame's blank-line terminator. */
|
|
459
|
+
inHeartbeatFrame = false;
|
|
460
|
+
next(rawLine) {
|
|
461
|
+
const line = rawLine.trim();
|
|
462
|
+
if (!line) {
|
|
463
|
+
this.inHeartbeatFrame = false;
|
|
464
|
+
return SKIP;
|
|
465
|
+
}
|
|
466
|
+
if (line.startsWith(":")) return SKIP;
|
|
467
|
+
if (line.startsWith("event:")) {
|
|
468
|
+
this.inHeartbeatFrame = line.slice(6).trim().toLowerCase() === "ping";
|
|
469
|
+
return SKIP;
|
|
470
|
+
}
|
|
471
|
+
if (line.startsWith("id:") || line.startsWith("retry:")) return SKIP;
|
|
472
|
+
if (line.startsWith("data:")) {
|
|
473
|
+
if (this.inHeartbeatFrame) return SKIP;
|
|
474
|
+
const data = line.slice(5).trim();
|
|
475
|
+
if (!data) return SKIP;
|
|
476
|
+
if (data === "[DONE]") return { kind: "done" };
|
|
477
|
+
return { kind: "json", text: data };
|
|
478
|
+
}
|
|
479
|
+
return { kind: "json", text: line };
|
|
480
|
+
}
|
|
481
|
+
};
|
|
482
|
+
}
|
|
483
|
+
});
|
|
484
|
+
|
|
451
485
|
// src/services/ollama/ollama.service.ts
|
|
452
486
|
var import_rxjs, handleError, parseResponseBody, OllamaService;
|
|
453
487
|
var init_ollama_service = __esm({
|
|
@@ -455,6 +489,7 @@ var init_ollama_service = __esm({
|
|
|
455
489
|
"use strict";
|
|
456
490
|
import_rxjs = require("rxjs");
|
|
457
491
|
init_debugLogger();
|
|
492
|
+
init_streamLineParser();
|
|
458
493
|
handleError = () => (obs) => obs.pipe(
|
|
459
494
|
(0, import_rxjs.switchMap)(
|
|
460
495
|
(response) => response.ok ? (0, import_rxjs.of)(response) : (0, import_rxjs.throwError)(() => new Error(`Request failed: ${response.status} ${response.statusText}`))
|
|
@@ -545,13 +580,15 @@ var init_ollama_service = __esm({
|
|
|
545
580
|
this._throwErrorIfNotOk(url, response);
|
|
546
581
|
const reader = response.body?.getReader();
|
|
547
582
|
const decoder = new TextDecoder();
|
|
583
|
+
const lineParser = new StreamLineParser();
|
|
548
584
|
let buffer = "";
|
|
549
585
|
const read = () => {
|
|
550
586
|
reader?.read().then(({ done, value }) => {
|
|
551
587
|
if (done) {
|
|
552
|
-
|
|
588
|
+
const tail = lineParser.next(buffer);
|
|
589
|
+
if (tail.kind === "json") {
|
|
553
590
|
try {
|
|
554
|
-
observer.next(JSON.parse(
|
|
591
|
+
observer.next(JSON.parse(tail.text));
|
|
555
592
|
} catch (err) {
|
|
556
593
|
observer.error(err);
|
|
557
594
|
debugLogger.error("Final chunk parsing error (generate):", { buffer });
|
|
@@ -564,9 +601,10 @@ var init_ollama_service = __esm({
|
|
|
564
601
|
const lines = buffer.split("\n");
|
|
565
602
|
buffer = lines.pop() ?? "";
|
|
566
603
|
for (const line of lines) {
|
|
567
|
-
|
|
604
|
+
const classified = lineParser.next(line);
|
|
605
|
+
if (classified.kind === "json") {
|
|
568
606
|
try {
|
|
569
|
-
observer.next(JSON.parse(
|
|
607
|
+
observer.next(JSON.parse(classified.text));
|
|
570
608
|
} catch (err) {
|
|
571
609
|
observer.error(err);
|
|
572
610
|
debugLogger.error("Error parsing JSON line (generate):", { line });
|
|
@@ -596,13 +634,15 @@ var init_ollama_service = __esm({
|
|
|
596
634
|
this._throwErrorIfNotOk(url, response);
|
|
597
635
|
const reader = response.body?.getReader();
|
|
598
636
|
const decoder = new TextDecoder();
|
|
637
|
+
const lineParser = new StreamLineParser();
|
|
599
638
|
let buffer = "";
|
|
600
639
|
const read = () => {
|
|
601
640
|
reader?.read().then(({ done, value }) => {
|
|
602
641
|
if (done) {
|
|
603
|
-
|
|
642
|
+
const tail = lineParser.next(buffer);
|
|
643
|
+
if (tail.kind === "json") {
|
|
604
644
|
try {
|
|
605
|
-
observer.next(JSON.parse(
|
|
645
|
+
observer.next(JSON.parse(tail.text));
|
|
606
646
|
} catch (err) {
|
|
607
647
|
observer.error(err);
|
|
608
648
|
debugLogger.error("Final chunk parsing error (chat):", { buffer });
|
|
@@ -615,9 +655,10 @@ var init_ollama_service = __esm({
|
|
|
615
655
|
const lines = buffer.split("\n");
|
|
616
656
|
buffer = lines.pop() ?? "";
|
|
617
657
|
for (const line of lines) {
|
|
618
|
-
|
|
658
|
+
const classified = lineParser.next(line);
|
|
659
|
+
if (classified.kind === "json") {
|
|
619
660
|
try {
|
|
620
|
-
observer.next(JSON.parse(
|
|
661
|
+
observer.next(JSON.parse(classified.text));
|
|
621
662
|
} catch (err) {
|
|
622
663
|
observer.error(err);
|
|
623
664
|
debugLogger.error("Error parsing JSON line (chat):", { line });
|
|
@@ -1648,6 +1689,7 @@ var init_gateway_service = __esm({
|
|
|
1648
1689
|
"src/services/gateway/gateway.service.ts"() {
|
|
1649
1690
|
"use strict";
|
|
1650
1691
|
import_axios = __toESM(require("axios"));
|
|
1692
|
+
init_streamLineParser();
|
|
1651
1693
|
import_rxjs6 = require("rxjs");
|
|
1652
1694
|
init_debugLogger();
|
|
1653
1695
|
init_authenticationService();
|
|
@@ -1829,13 +1871,15 @@ var init_gateway_service = __esm({
|
|
|
1829
1871
|
const handleStreamingResponse = async (response) => {
|
|
1830
1872
|
const reader = response.body?.getReader();
|
|
1831
1873
|
const decoder = new TextDecoder();
|
|
1874
|
+
const lineParser = new StreamLineParser();
|
|
1832
1875
|
let buffer = "";
|
|
1833
1876
|
const read = () => {
|
|
1834
1877
|
reader?.read().then(({ done, value }) => {
|
|
1835
1878
|
if (done) {
|
|
1836
|
-
|
|
1879
|
+
const tail = lineParser.next(buffer);
|
|
1880
|
+
if (tail.kind === "json") {
|
|
1837
1881
|
try {
|
|
1838
|
-
const finalResponse = JSON.parse(
|
|
1882
|
+
const finalResponse = JSON.parse(tail.text);
|
|
1839
1883
|
observer.next(finalResponse);
|
|
1840
1884
|
} catch (err) {
|
|
1841
1885
|
debugLogger.error("GatewayService chat final chunk parsing error", { buffer, error: err });
|
|
@@ -1849,16 +1893,14 @@ var init_gateway_service = __esm({
|
|
|
1849
1893
|
const lines = buffer.split("\n");
|
|
1850
1894
|
buffer = lines.pop() ?? "";
|
|
1851
1895
|
for (const line of lines) {
|
|
1852
|
-
const
|
|
1853
|
-
if (
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
}
|
|
1861
|
-
}
|
|
1896
|
+
const classified = lineParser.next(line);
|
|
1897
|
+
if (classified.kind === "done") {
|
|
1898
|
+
observer.complete();
|
|
1899
|
+
return;
|
|
1900
|
+
}
|
|
1901
|
+
if (classified.kind === "json") {
|
|
1902
|
+
const trimmed = line.trim();
|
|
1903
|
+
const data = classified.text;
|
|
1862
1904
|
try {
|
|
1863
1905
|
const parsed = JSON.parse(data);
|
|
1864
1906
|
if (request.provider === "ollama" && parsed.message) {
|
|
@@ -2025,13 +2067,15 @@ var init_gateway_service = __esm({
|
|
|
2025
2067
|
}
|
|
2026
2068
|
const reader = response.body?.getReader();
|
|
2027
2069
|
const decoder = new TextDecoder();
|
|
2070
|
+
const lineParser = new StreamLineParser();
|
|
2028
2071
|
let buffer = "";
|
|
2029
2072
|
const read = () => {
|
|
2030
2073
|
reader?.read().then(({ done, value }) => {
|
|
2031
2074
|
if (done) {
|
|
2032
|
-
|
|
2075
|
+
const tail = lineParser.next(buffer);
|
|
2076
|
+
if (tail.kind === "json") {
|
|
2033
2077
|
try {
|
|
2034
|
-
observer.next(JSON.parse(
|
|
2078
|
+
observer.next(JSON.parse(tail.text));
|
|
2035
2079
|
} catch (err) {
|
|
2036
2080
|
observer.error(err);
|
|
2037
2081
|
debugLogger.error("Final chunk parsing error (gateway generate):", { buffer });
|
|
@@ -2044,9 +2088,14 @@ var init_gateway_service = __esm({
|
|
|
2044
2088
|
const lines = buffer.split("\n");
|
|
2045
2089
|
buffer = lines.pop() ?? "";
|
|
2046
2090
|
for (const line of lines) {
|
|
2047
|
-
|
|
2091
|
+
const classified = lineParser.next(line);
|
|
2092
|
+
if (classified.kind === "done") {
|
|
2093
|
+
observer.complete();
|
|
2094
|
+
return;
|
|
2095
|
+
}
|
|
2096
|
+
if (classified.kind === "json") {
|
|
2048
2097
|
try {
|
|
2049
|
-
observer.next(JSON.parse(
|
|
2098
|
+
observer.next(JSON.parse(classified.text));
|
|
2050
2099
|
} catch (err) {
|
|
2051
2100
|
observer.error(err);
|
|
2052
2101
|
debugLogger.error("Error parsing JSON line (gateway generate):", { line });
|
|
@@ -9308,9 +9357,17 @@ var init_useVectorStore = __esm({
|
|
|
9308
9357
|
const hasAnyAdvancedFeatures = isAdvancedVectorFeaturesEnabled;
|
|
9309
9358
|
const hasVectorAccess = features.isAdmin() || features.hasAdvancedSearch() || features.hasAdvancedMemories();
|
|
9310
9359
|
const [hasCompatibleProvider, setHasCompatibleProvider] = (0, import_react3.useState)(false);
|
|
9360
|
+
const mountedRef = (0, import_react3.useRef)(true);
|
|
9361
|
+
(0, import_react3.useEffect)(() => {
|
|
9362
|
+
mountedRef.current = true;
|
|
9363
|
+
return () => {
|
|
9364
|
+
mountedRef.current = false;
|
|
9365
|
+
};
|
|
9366
|
+
}, []);
|
|
9311
9367
|
const checkProviderCompatibility = (0, import_react3.useCallback)(async () => {
|
|
9312
9368
|
try {
|
|
9313
9369
|
const { useAIProviderStore: useAIProviderStore2 } = await Promise.resolve().then(() => (init_aiProviderStore(), aiProviderStore_exports));
|
|
9370
|
+
if (!mountedRef.current) return false;
|
|
9314
9371
|
const aiProviderState = useAIProviderStore2.getState();
|
|
9315
9372
|
const provider = aiProviderState.provider;
|
|
9316
9373
|
const config = aiProviderState.config;
|
|
@@ -9327,7 +9384,7 @@ var init_useVectorStore = __esm({
|
|
|
9327
9384
|
return isCompatible;
|
|
9328
9385
|
} catch (error) {
|
|
9329
9386
|
debugLogger.warn("Could not check AI provider for vector compatibility", { error });
|
|
9330
|
-
setHasCompatibleProvider(false);
|
|
9387
|
+
if (mountedRef.current) setHasCompatibleProvider(false);
|
|
9331
9388
|
return false;
|
|
9332
9389
|
}
|
|
9333
9390
|
}, []);
|
|
@@ -9335,12 +9392,10 @@ var init_useVectorStore = __esm({
|
|
|
9335
9392
|
checkProviderCompatibility();
|
|
9336
9393
|
}, [checkProviderCompatibility]);
|
|
9337
9394
|
(0, import_react3.useEffect)(() => {
|
|
9338
|
-
const
|
|
9339
|
-
|
|
9340
|
-
|
|
9341
|
-
|
|
9342
|
-
};
|
|
9343
|
-
checkOnProviderChange();
|
|
9395
|
+
const timer = setTimeout(() => {
|
|
9396
|
+
void checkProviderCompatibility();
|
|
9397
|
+
}, 100);
|
|
9398
|
+
return () => clearTimeout(timer);
|
|
9344
9399
|
}, [authStore.token, checkProviderCompatibility]);
|
|
9345
9400
|
(0, import_react3.useEffect)(() => {
|
|
9346
9401
|
const interval = setInterval(() => {
|