@burtson-labs/bandit-engine 2.0.60 → 2.0.61

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/index.mjs CHANGED
@@ -1,22 +1,22 @@
1
1
  import {
2
2
  chat_default
3
- } from "./chunk-MFDMM5MS.mjs";
3
+ } from "./chunk-G7U2FNUK.mjs";
4
4
  import {
5
5
  chat_provider_default
6
6
  } from "./chunk-D55E6ZDV.mjs";
7
7
  import "./chunk-ONQMRE2G.mjs";
8
+ import {
9
+ defineCustomElement
10
+ } from "./chunk-IXIM7BNO.mjs";
8
11
  import {
9
12
  management_default,
10
13
  useGatewayHealth,
11
14
  useGatewayMemory,
12
15
  useGatewayModels
13
- } from "./chunk-3AWAL2YH.mjs";
16
+ } from "./chunk-SKMJ43NN.mjs";
14
17
  import "./chunk-SRCCNBHF.mjs";
15
18
  import "./chunk-VTC6AIWY.mjs";
16
19
  import "./chunk-6QTTNYF2.mjs";
17
- import {
18
- defineCustomElement
19
- } from "./chunk-IXIM7BNO.mjs";
20
20
  import {
21
21
  chat_modal_default
22
22
  } from "./chunk-PY7A3J5T.mjs";
@@ -21674,6 +21674,64 @@ var init_telemetry = __esm({
21674
21674
  }
21675
21675
  });
21676
21676
 
21677
+ // src/store/engineStore.ts
21678
+ var import_zustand15, STORAGE_KEY2, readStored, useEngineStore;
21679
+ var init_engineStore = __esm({
21680
+ "src/store/engineStore.ts"() {
21681
+ "use strict";
21682
+ import_zustand15 = require("zustand");
21683
+ init_packageSettingsStore();
21684
+ init_authenticationService();
21685
+ init_debugLogger();
21686
+ STORAGE_KEY2 = "bandit.selectedEngine";
21687
+ readStored = () => {
21688
+ try {
21689
+ return typeof window !== "undefined" ? window.localStorage.getItem(STORAGE_KEY2) : null;
21690
+ } catch {
21691
+ return null;
21692
+ }
21693
+ };
21694
+ useEngineStore = (0, import_zustand15.create)((set, get) => ({
21695
+ selectedEngine: readStored(),
21696
+ engines: [],
21697
+ loaded: false,
21698
+ setSelectedEngine: (id) => {
21699
+ set({ selectedEngine: id });
21700
+ try {
21701
+ window.localStorage.setItem(STORAGE_KEY2, id);
21702
+ } catch {
21703
+ }
21704
+ },
21705
+ getSelectedEngine: () => get().selectedEngine || usePackageSettingsStore.getState().settings?.defaultModel || "bandit-core",
21706
+ fetchEngines: async () => {
21707
+ const settings = usePackageSettingsStore.getState().settings;
21708
+ const base = settings?.gatewayApiUrl?.replace(/\/$/, "") ?? "";
21709
+ if (!base || settings?.playgroundMode || base.toLowerCase().startsWith("playground://")) {
21710
+ set({ loaded: true });
21711
+ return;
21712
+ }
21713
+ try {
21714
+ const headers = { "Content-Type": "application/json" };
21715
+ const token = authenticationService.getToken();
21716
+ if (token) headers["Authorization"] = `Bearer ${token}`;
21717
+ const res = await fetch(`${base}/models`, { headers });
21718
+ const data = await res.json();
21719
+ if (res.ok && Array.isArray(data?.models)) {
21720
+ set({ engines: data.models, loaded: true });
21721
+ } else {
21722
+ set({ loaded: true });
21723
+ }
21724
+ } catch (error) {
21725
+ debugLogger.error("Failed to fetch engines", {
21726
+ error: error instanceof Error ? error.message : String(error)
21727
+ });
21728
+ set({ loaded: true });
21729
+ }
21730
+ }
21731
+ }));
21732
+ }
21733
+ });
21734
+
21677
21735
  // src/chat/hooks/useMemoryEnhancer.tsx
21678
21736
  var import_rxjs23, MEMORY_LIMIT, MIN_MEMORY_WORDS, MERGE_THRESHOLD, REJECT_ECHO_THRESHOLD, REJECT_DUPLICATE_THRESHOLD, CONTEXTUAL_DIVERGENCE_THRESHOLD, normalizeText, isStructurallyDuplicate, isAboutBandit, hasEngagementValue, isMemoryTooShortOrGeneric, isPersonalText, mergeMemory, isVoiceShifted, sanitizeMemory, sanitizeMemoryText, shouldAcceptMemory, isContextuallyDivergent, useMemoryEnhancer;
21679
21737
  var init_useMemoryEnhancer = __esm({
@@ -22416,12 +22474,12 @@ var init_useAIProvider = __esm({
22416
22474
  init_knowledgeStore();
22417
22475
  init_aiProviderStore();
22418
22476
  init_telemetry();
22477
+ init_engineStore();
22419
22478
  init_conversationStore();
22420
22479
  init_useMemoryEnhancer();
22421
22480
  init_useVectorStore();
22422
22481
  init_embeddingService();
22423
22482
  init_useMoodEngine();
22424
- init_packageSettingsStore();
22425
22483
  init_prompts();
22426
22484
  init_preferencesStore();
22427
22485
  init_mcp();
@@ -22785,7 +22843,7 @@ var init_useAIProvider = __esm({
22785
22843
  question: pendingQuestion,
22786
22844
  images: pendingImages
22787
22845
  });
22788
- const modelName = usePackageSettingsStore.getState().settings?.defaultModel || "bandit-core:4b-it-qat";
22846
+ const modelName = useEngineStore.getState().getSelectedEngine();
22789
22847
  const CONFIG = modelConfigs[modelName] ?? modelConfigs["bandit-core:4b-it-qat"];
22790
22848
  const base64Images = imageList.map((img) => img.split(",")[1]);
22791
22849
  const latestEntries = history.slice(-CONFIG.historyMessages);
@@ -27017,6 +27075,7 @@ var init_chat_app_bar = __esm({
27017
27075
  init_packageSettingsStore();
27018
27076
  init_useFeatures();
27019
27077
  init_conversationSyncStore();
27078
+ init_engineStore();
27020
27079
  import_shallow2 = require("zustand/shallow");
27021
27080
  import_jsx_runtime42 = require("react/jsx-runtime");
27022
27081
  CDN_BASE2 = "https://cdn.burtson.ai/";
@@ -27066,6 +27125,7 @@ var init_chat_app_bar = __esm({
27066
27125
  menuText
27067
27126
  } = theme.palette.chat.appBar;
27068
27127
  const [modelAnchorEl, setModelAnchorEl] = (0, import_react53.useState)(null);
27128
+ const [engineAnchorEl, setEngineAnchorEl] = (0, import_react53.useState)(null);
27069
27129
  const [voiceAnchorEl, setVoiceAnchorEl] = (0, import_react53.useState)(null);
27070
27130
  const [modalOpen, setModalOpen] = (0, import_react53.useState)(false);
27071
27131
  const [confirmModelChangeOpen, setConfirmModelChangeOpen] = (0, import_react53.useState)(false);
@@ -27186,6 +27246,14 @@ var init_chat_app_bar = __esm({
27186
27246
  const selectedModel = useModelStore((s) => s.selectedModel);
27187
27247
  const currentModel = useModelStore((s) => s.availableModels.find((m) => m.name === selectedModel));
27188
27248
  const currentAvatar = currentModel?.avatarBase64 || modelAvatars3[selectedModel] || banditHead5;
27249
+ const engines = useEngineStore((s) => s.engines);
27250
+ const selectedEngine = useEngineStore((s) => s.selectedEngine);
27251
+ const effectiveEngineId = selectedEngine || usePackageSettingsStore.getState().settings?.defaultModel || "bandit-core";
27252
+ const currentEngine = engines.find((e) => e.id === effectiveEngineId);
27253
+ const engineLabel = currentEngine?.displayName?.replace(/^Bandit /, "") || "Engine";
27254
+ (0, import_react53.useEffect)(() => {
27255
+ useEngineStore.getState().fetchEngines();
27256
+ }, []);
27189
27257
  const pendingModelAvatar = useModelStore.getState().availableModels.find((m) => m.name === pendingModel)?.avatarBase64 || modelAvatars3[pendingModel || ""] || banditHead5;
27190
27258
  const resolvedHomeUrl = preferences.homeUrl?.trim() || packageSettings?.homeUrl?.trim() || "";
27191
27259
  const homeTooltip = (() => {
@@ -27498,6 +27566,84 @@ var init_chat_app_bar = __esm({
27498
27566
  )
27499
27567
  }
27500
27568
  ) }),
27569
+ /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(import_material43.Tooltip, { title: `Engine: ${currentEngine?.displayName ?? effectiveEngineId}`, arrow: true, children: /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)(
27570
+ import_material43.IconButton,
27571
+ {
27572
+ onClick: (e) => setEngineAnchorEl(e.currentTarget),
27573
+ sx: pillButtonStyles,
27574
+ "aria-label": `Change base model (engine). Currently ${effectiveEngineId}`,
27575
+ children: [
27576
+ currentEngine?.cloud ? /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(CloudDoneIcon, { fontSize: "small" }) : /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(CloudOffIcon, { fontSize: "small" }),
27577
+ /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(import_material43.Typography, { variant: "caption", sx: { ml: 0.75, fontWeight: 600, whiteSpace: "nowrap" }, children: engineLabel })
27578
+ ]
27579
+ }
27580
+ ) }),
27581
+ /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)(
27582
+ import_material43.Menu,
27583
+ {
27584
+ anchorEl: engineAnchorEl,
27585
+ open: Boolean(engineAnchorEl),
27586
+ onClose: () => setEngineAnchorEl(null),
27587
+ transformOrigin: { horizontal: "right", vertical: "top" },
27588
+ anchorOrigin: { horizontal: "right", vertical: "bottom" },
27589
+ children: [
27590
+ /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(import_material43.Typography, { variant: "overline", sx: { px: 2, color: theme.palette.text.secondary }, children: "Engine \xB7 base model" }),
27591
+ engines.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(import_material43.MenuItem, { disabled: true, children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(import_material43.Typography, { variant: "body2", children: "No engines available" }) }),
27592
+ engines.map((engine) => {
27593
+ const badges = [
27594
+ engine.vision && "vision",
27595
+ engine.tools && "tools",
27596
+ engine.thinking && "thinking",
27597
+ engine.cloud && "cloud"
27598
+ ].filter(Boolean);
27599
+ return /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)(
27600
+ import_material43.MenuItem,
27601
+ {
27602
+ selected: engine.id === effectiveEngineId,
27603
+ disabled: !engine.available,
27604
+ onClick: () => {
27605
+ useEngineStore.getState().setSelectedEngine(engine.id);
27606
+ setEngineAnchorEl(null);
27607
+ },
27608
+ sx: {
27609
+ display: "flex",
27610
+ flexDirection: "column",
27611
+ alignItems: "flex-start",
27612
+ gap: 0.5,
27613
+ py: 1,
27614
+ px: 2,
27615
+ maxWidth: 360,
27616
+ whiteSpace: "normal"
27617
+ },
27618
+ children: [
27619
+ /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)(import_material43.Box, { sx: { display: "flex", alignItems: "center", gap: 1, width: "100%" }, children: [
27620
+ /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(import_material43.Typography, { variant: "body2", sx: { fontWeight: 600, flex: 1 }, children: engine.displayName }),
27621
+ engine.id === effectiveEngineId && /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(import_material43.Box, { sx: { width: 8, height: 8, borderRadius: "50%", bgcolor: theme.palette.primary.main } })
27622
+ ] }),
27623
+ /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(import_material43.Typography, { variant: "caption", sx: { color: theme.palette.text.secondary }, children: engine.available ? engine.description : engine.unavailableReason || "Unavailable" }),
27624
+ badges.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(import_material43.Box, { sx: { display: "flex", gap: 0.5, flexWrap: "wrap", mt: 0.25 }, children: badges.map((b) => /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
27625
+ import_material43.Box,
27626
+ {
27627
+ sx: {
27628
+ fontSize: "0.65rem",
27629
+ px: 0.75,
27630
+ py: 0.1,
27631
+ borderRadius: 1,
27632
+ bgcolor: theme.palette.primary.main + "22",
27633
+ color: theme.palette.primary.main
27634
+ },
27635
+ children: b
27636
+ },
27637
+ b
27638
+ )) })
27639
+ ]
27640
+ },
27641
+ engine.id
27642
+ );
27643
+ })
27644
+ ]
27645
+ }
27646
+ ),
27501
27647
  /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
27502
27648
  import_material43.Menu,
27503
27649
  {