@burtson-labs/bandit-engine 2.0.64 → 2.0.66

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 (41) hide show
  1. package/dist/chat-IWRBVOVP.mjs +16 -0
  2. package/dist/chat-provider.js +4 -0
  3. package/dist/chat-provider.js.map +1 -1
  4. package/dist/chat-provider.mjs +5 -5
  5. package/dist/{chunk-EUBVBTB3.mjs → chunk-4D7245ZO.mjs} +55 -30
  6. package/dist/chunk-4D7245ZO.mjs.map +1 -0
  7. package/dist/{chunk-FXFTA5PZ.mjs → chunk-6DY7W4NK.mjs} +3 -3
  8. package/dist/{chunk-VTC6AIWY.mjs → chunk-6ITUH375.mjs} +3 -3
  9. package/dist/{chunk-DCZLPUMY.mjs → chunk-EM2DB6NP.mjs} +53 -9
  10. package/dist/chunk-EM2DB6NP.mjs.map +1 -0
  11. package/dist/{chunk-D55E6ZDV.mjs → chunk-HHMGNCBS.mjs} +5 -5
  12. package/dist/{chunk-6QTTNYF2.mjs → chunk-IDZEEONG.mjs} +2 -2
  13. package/dist/{chunk-HKQSZALO.mjs → chunk-JURUEF52.mjs} +4 -4
  14. package/dist/{chunk-IPMTNREZ.mjs → chunk-LWHSOEPR.mjs} +6 -2
  15. package/dist/{chunk-IPMTNREZ.mjs.map → chunk-LWHSOEPR.mjs.map} +1 -1
  16. package/dist/{chunk-DPMJELHK.mjs → chunk-U633CJBV.mjs} +22 -10
  17. package/dist/{chunk-DPMJELHK.mjs.map → chunk-U633CJBV.mjs.map} +1 -1
  18. package/dist/{chunk-DR4X32D3.mjs → chunk-ZYQJVZK2.mjs} +20 -13
  19. package/dist/chunk-ZYQJVZK2.mjs.map +1 -0
  20. package/dist/index.js +138 -46
  21. package/dist/index.js.map +1 -1
  22. package/dist/index.mjs +10 -10
  23. package/dist/management/management.js +137 -45
  24. package/dist/management/management.js.map +1 -1
  25. package/dist/management/management.mjs +8 -8
  26. package/dist/modals/chat-modal/chat-modal.js +4 -0
  27. package/dist/modals/chat-modal/chat-modal.js.map +1 -1
  28. package/dist/modals/chat-modal/chat-modal.mjs +4 -4
  29. package/dist/{modelStore-FBPBG7TI.mjs → modelStore-KCJPXFKO.mjs} +2 -2
  30. package/package.json +1 -1
  31. package/dist/chat-IGKTUDME.mjs +0 -16
  32. package/dist/chunk-DCZLPUMY.mjs.map +0 -1
  33. package/dist/chunk-DR4X32D3.mjs.map +0 -1
  34. package/dist/chunk-EUBVBTB3.mjs.map +0 -1
  35. /package/dist/{chat-IGKTUDME.mjs.map → chat-IWRBVOVP.mjs.map} +0 -0
  36. /package/dist/{chunk-FXFTA5PZ.mjs.map → chunk-6DY7W4NK.mjs.map} +0 -0
  37. /package/dist/{chunk-VTC6AIWY.mjs.map → chunk-6ITUH375.mjs.map} +0 -0
  38. /package/dist/{chunk-D55E6ZDV.mjs.map → chunk-HHMGNCBS.mjs.map} +0 -0
  39. /package/dist/{chunk-6QTTNYF2.mjs.map → chunk-IDZEEONG.mjs.map} +0 -0
  40. /package/dist/{chunk-HKQSZALO.mjs.map → chunk-JURUEF52.mjs.map} +0 -0
  41. /package/dist/{modelStore-FBPBG7TI.mjs.map → modelStore-KCJPXFKO.mjs.map} +0 -0
package/dist/index.mjs CHANGED
@@ -1,25 +1,25 @@
1
1
  import {
2
2
  chat_default
3
- } from "./chunk-DR4X32D3.mjs";
3
+ } from "./chunk-ZYQJVZK2.mjs";
4
4
  import {
5
5
  chat_provider_default
6
- } from "./chunk-D55E6ZDV.mjs";
6
+ } from "./chunk-HHMGNCBS.mjs";
7
7
  import "./chunk-ONQMRE2G.mjs";
8
8
  import {
9
9
  management_default,
10
10
  useGatewayHealth,
11
11
  useGatewayMemory,
12
12
  useGatewayModels
13
- } from "./chunk-DCZLPUMY.mjs";
14
- import "./chunk-DPMJELHK.mjs";
15
- import "./chunk-VTC6AIWY.mjs";
16
- import "./chunk-6QTTNYF2.mjs";
13
+ } from "./chunk-EM2DB6NP.mjs";
14
+ import "./chunk-U633CJBV.mjs";
15
+ import "./chunk-6ITUH375.mjs";
16
+ import "./chunk-IDZEEONG.mjs";
17
17
  import {
18
18
  defineCustomElement
19
19
  } from "./chunk-IXIM7BNO.mjs";
20
20
  import {
21
21
  chat_modal_default
22
- } from "./chunk-HKQSZALO.mjs";
22
+ } from "./chunk-JURUEF52.mjs";
23
23
  import {
24
24
  FeedbackButton,
25
25
  FeedbackModal,
@@ -37,7 +37,7 @@ import {
37
37
  useTTS,
38
38
  useVoiceStore,
39
39
  voiceService
40
- } from "./chunk-FXFTA5PZ.mjs";
40
+ } from "./chunk-6DY7W4NK.mjs";
41
41
  import {
42
42
  DEFAULT_TIER_FEATURES,
43
43
  FeatureFlagContext,
@@ -57,10 +57,10 @@ import {
57
57
  useVectorStore,
58
58
  vectorDatabaseService,
59
59
  vectorMigrationService
60
- } from "./chunk-EUBVBTB3.mjs";
60
+ } from "./chunk-4D7245ZO.mjs";
61
61
  import {
62
62
  usePackageSettingsStore
63
- } from "./chunk-IPMTNREZ.mjs";
63
+ } from "./chunk-LWHSOEPR.mjs";
64
64
  import "./chunk-H3BYFEIE.mjs";
65
65
  import {
66
66
  DebugLogger,
@@ -3636,7 +3636,7 @@ var init_util = __esm({
3636
3636
  });
3637
3637
 
3638
3638
  // src/prompts/getStableQuestionPrompt.ts
3639
- var TOPICS, getRandomTopicOfInterest, getStableQuestionPrompt;
3639
+ var TOPICS, getRandomTopicOfInterest, pickDistinctRandomTopics, getStableQuestionPrompt;
3640
3640
  var init_getStableQuestionPrompt = __esm({
3641
3641
  "src/prompts/getStableQuestionPrompt.ts"() {
3642
3642
  "use strict";
@@ -3649,42 +3649,65 @@ var init_getStableQuestionPrompt = __esm({
3649
3649
  const randomTopic = TOPICS[randomIndex];
3650
3650
  return randomTopic;
3651
3651
  };
3652
+ pickDistinctRandomTopics = (count) => {
3653
+ const pool = [...TOPICS];
3654
+ const picked = [];
3655
+ const n = Math.min(Math.max(count, 0), pool.length);
3656
+ for (let i = 0; i < n; i++) {
3657
+ const idx = randomRange(0, pool.length - 1);
3658
+ picked.push(pool[idx]);
3659
+ pool.splice(idx, 1);
3660
+ }
3661
+ return picked;
3662
+ };
3652
3663
  getStableQuestionPrompt = (args) => {
3653
- const { limit, topicOfInterest, modelSystemPrompt } = args;
3664
+ const { limit, topicOfInterest, modelSystemPrompt, interests, knowledgeTopics, webSearchAvailable } = args;
3654
3665
  if (limit < 1 || limit > 10) {
3655
3666
  throw new Error("Limit must be between 1 and 10");
3656
3667
  }
3657
3668
  const seed = generateSeed();
3658
- let prompt = `You are a helpful assistant.
3659
-
3660
- The following seed uniquely identifies the topic: "${seed}"`;
3669
+ const lines = [
3670
+ `You are crafting fresh, engaging conversation starters for a chat app's home screen.`,
3671
+ ``,
3672
+ `Variation seed (make this set different from any previous set): "${seed}"`
3673
+ ];
3661
3674
  if (modelSystemPrompt && modelSystemPrompt.trim()) {
3662
- prompt += `
3663
-
3664
- Based on this specialized assistant profile: "${modelSystemPrompt.trim()}"`;
3675
+ lines.push(``, `Tailor the questions to this assistant's role and expertise: "${modelSystemPrompt.trim()}"`);
3665
3676
  }
3666
- prompt += `
3667
-
3668
- Generate ${limit} concise (5\u201320 words, try to use this entire range), natural-sounding questions a user might ask${modelSystemPrompt ? " this specialized assistant" : " an AI assistant"}. These should be:
3669
-
3670
- - Relevant to ${topicOfInterest}`;
3671
- if (modelSystemPrompt && modelSystemPrompt.trim()) {
3672
- prompt += `
3673
- - Aligned with the assistant's specialized capabilities and knowledge area`;
3677
+ if (interests && interests.length) {
3678
+ lines.push(
3679
+ ``,
3680
+ `The user is especially interested in: ${interests.join(", ")}. Lean toward these, but do NOT make every question about the same one.`
3681
+ );
3674
3682
  }
3675
- prompt += `
3676
- - Specific enough to be practical
3677
- - Easy to understand and not abstract
3678
-
3679
- Do not:
3680
- - Refer to yourself or use phrases like "As an AI..."
3681
- - Include greetings, explanations, or personality
3682
- - Include jokes, fiction, or quotes
3683
- - Number, bullet, or otherwise prefix the questions with extra characters
3684
- - Repeat the same idea phrased differently \u2014 each question must explore a distinct angle or subtopic
3685
-
3686
- Output only ${limit} questions \u2014 one per line, with no leading numbers, bullets, or prefixes.`;
3687
- return prompt.trim();
3683
+ if (knowledgeTopics && knowledgeTopics.length) {
3684
+ lines.push(
3685
+ ``,
3686
+ `The user keeps these documents in their library: ${knowledgeTopics.join("; ")}. Include one or two questions that draw on this material.`
3687
+ );
3688
+ }
3689
+ lines.push(
3690
+ ``,
3691
+ `Spread the set across a VARIETY of these topics so it never feels repetitive (do not cluster on one): ${topicOfInterest}.`
3692
+ );
3693
+ if (webSearchAvailable) {
3694
+ lines.push(
3695
+ ``,
3696
+ `This assistant can search the web for live information. Include 2\u20133 questions that invite current, up-to-date answers (latest news, recent developments, "today" / "this week") so the user discovers that capability.`
3697
+ );
3698
+ }
3699
+ lines.push(
3700
+ ``,
3701
+ `Generate ${limit} concise (5\u201320 words), natural-sounding questions a user might ask${modelSystemPrompt ? " this specialized assistant" : " an AI assistant"}. Requirements:`,
3702
+ `- Each question must explore a DISTINCT topic or angle \u2014 no two may be similar or rephrasings of each other.`,
3703
+ `- Vary the type across the set: practical how-to, curious exploration, current/topical, creative, and learning.`,
3704
+ `- Specific and concrete, easy to understand, not abstract.`,
3705
+ ``,
3706
+ `Do not refer to yourself, say "As an AI", add greetings, explanations, jokes, fiction, quotes, or number/bullet the lines.`,
3707
+ ``,
3708
+ `Output only ${limit} questions \u2014 one per line, with no leading numbers, bullets, or prefixes.`
3709
+ );
3710
+ return lines.join("\n").trim();
3688
3711
  };
3689
3712
  }
3690
3713
  });
@@ -6671,6 +6694,8 @@ var init_preferencesStore = __esm({
6671
6694
  sttEnabled: true,
6672
6695
  banditModelsEnabled: true,
6673
6696
  feedbackEnabled: true,
6697
+ interests: [],
6698
+ useKnowledgeForStarters: false,
6674
6699
  homeUrl: ""
6675
6700
  };
6676
6701
  sanitizePreferences = (preferences) => {
@@ -6768,6 +6793,8 @@ var init_preferencesStore = __esm({
6768
6793
  sttEnabled: typeof mergedPreferences.sttEnabled === "boolean" ? mergedPreferences.sttEnabled : defaultPreferences.sttEnabled,
6769
6794
  banditModelsEnabled: typeof mergedPreferences.banditModelsEnabled === "boolean" ? mergedPreferences.banditModelsEnabled : defaultPreferences.banditModelsEnabled,
6770
6795
  feedbackEnabled: typeof mergedPreferences.feedbackEnabled === "boolean" ? mergedPreferences.feedbackEnabled : defaultPreferences.feedbackEnabled,
6796
+ interests: Array.isArray(mergedPreferences.interests) ? mergedPreferences.interests.filter((i) => typeof i === "string") : defaultPreferences.interests,
6797
+ useKnowledgeForStarters: typeof mergedPreferences.useKnowledgeForStarters === "boolean" ? mergedPreferences.useKnowledgeForStarters : defaultPreferences.useKnowledgeForStarters,
6771
6798
  homeUrl: typeof mergedPreferences.homeUrl === "string" ? mergedPreferences.homeUrl : defaultPreferences.homeUrl
6772
6799
  };
6773
6800
  set({ preferences: validatedPreferences });
@@ -19077,7 +19104,7 @@ var init_themeMap = __esm({
19077
19104
  });
19078
19105
 
19079
19106
  // src/components/StreamingMarkdown.tsx
19080
- var import_react33, import_material25, import_react_markdown2, import_remark_gfm2, import_rehype_raw2, import_rehype_sanitize3, import_styles19, import_jsx_runtime24, StreamingMarkdown, StreamingMarkdown_default;
19107
+ var import_react33, import_material25, import_react_markdown2, import_remark_gfm2, import_rehype_raw2, import_rehype_sanitize3, import_styles19, import_jsx_runtime24, StreamingMarkdown, arePropsEqual, StreamingMarkdown_default;
19081
19108
  var init_StreamingMarkdown = __esm({
19082
19109
  "src/components/StreamingMarkdown.tsx"() {
19083
19110
  "use strict";
@@ -19511,8 +19538,8 @@ ${listMarkdown}`;
19511
19538
  {
19512
19539
  ref: containerRef,
19513
19540
  sx: {
19514
- // Base transition for minor layout changes
19515
- transition: "opacity 120ms ease-out, transform 120ms ease-out",
19541
+ // Settle the whole block to full color a beat after streaming ends.
19542
+ transition: "opacity 380ms ease-out, transform 220ms ease-out",
19516
19543
  "& .cursor": {
19517
19544
  display: showCursor ? "inline" : "none",
19518
19545
  animation: "blink 1s step-start infinite"
@@ -19520,16 +19547,18 @@ ${listMarkdown}`;
19520
19547
  "@keyframes blink": {
19521
19548
  "50%": { opacity: 0 }
19522
19549
  },
19550
+ // Each newly-written word focuses in — blur→sharp, a tiny rise, and fade —
19551
+ // like ink settling onto the page as the typewriter writes.
19523
19552
  "& .bl-fade-word": {
19524
19553
  opacity: 0,
19525
- animation: "bl-fade-in 420ms ease-out forwards"
19554
+ animation: "bl-fade-in 480ms cubic-bezier(0.22, 1, 0.36, 1) forwards"
19526
19555
  },
19527
19556
  "@keyframes bl-fade-in": {
19528
- from: { opacity: 0, transform: "translateY(1.5px)" },
19529
- to: { opacity: 1, transform: "translateY(0)" }
19557
+ from: { opacity: 0, filter: "blur(3px)", transform: "translateY(2px)" },
19558
+ to: { opacity: 1, filter: "blur(0)", transform: "translateY(0)" }
19530
19559
  },
19531
- // Subtle fade-in for each render while streaming to reduce choppiness perception
19532
- opacity: isStreaming ? 0.985 : 1,
19560
+ // Dimmed while streaming, then brightens to full color once the answer lands.
19561
+ opacity: isStreaming ? 0.86 : 1,
19533
19562
  transform: isStreaming ? "translateY(0.25px)" : "none",
19534
19563
  // Reduce layout jumpiness between updates
19535
19564
  "& p:last-child": { marginBottom: 0 },
@@ -19555,7 +19584,17 @@ ${listMarkdown}`;
19555
19584
  }
19556
19585
  );
19557
19586
  };
19558
- StreamingMarkdown_default = StreamingMarkdown;
19587
+ arePropsEqual = (prev, next) => {
19588
+ if (prev.content !== next.content || prev.isStreaming !== next.isStreaming) {
19589
+ return false;
19590
+ }
19591
+ const a = prev.sources;
19592
+ const b = next.sources;
19593
+ if (a === b) return true;
19594
+ if (!a || !b || a.length !== b.length) return false;
19595
+ return a.every((s, i) => s.id === b[i].id && s.name === b[i].name);
19596
+ };
19597
+ StreamingMarkdown_default = import_react33.default.memo(StreamingMarkdown, arePropsEqual);
19559
19598
  }
19560
19599
  });
19561
19600
 
@@ -19879,8 +19918,8 @@ var init_chat_scroll_to_bottom_button = __esm({
19879
19918
  drawerOpen = false,
19880
19919
  isMobile = false
19881
19920
  }) => {
19882
- const verticalBuffer = isMobile ? 28 : 48;
19883
- const bottomOffset = Math.max(inputHeight + verticalBuffer, verticalBuffer + 64);
19921
+ const verticalBuffer = isMobile ? 44 : 80;
19922
+ const bottomOffset = Math.max(inputHeight + verticalBuffer, verticalBuffer + 72);
19884
19923
  return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
19885
19924
  import_material32.IconButton,
19886
19925
  {
@@ -27823,6 +27862,9 @@ var init_query_suggestion_picker = __esm({
27823
27862
  init_prompts();
27824
27863
  init_getStableQuestionPrompt();
27825
27864
  init_modelStore();
27865
+ init_preferencesStore();
27866
+ init_knowledgeStore();
27867
+ init_mcpToolsStore();
27826
27868
  import_jsx_runtime43 = require("react/jsx-runtime");
27827
27869
  markdownComponents = {
27828
27870
  p: ({ node, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("span", { ...props }),
@@ -27849,13 +27891,19 @@ var init_query_suggestion_picker = __esm({
27849
27891
  if (hasGenerated.current || isLoading) return;
27850
27892
  hasGenerated.current = true;
27851
27893
  const currentModel = getCurrentModel();
27894
+ const prefs = usePreferencesStore.getState().preferences;
27895
+ const interests = (prefs.interests ?? []).filter((i) => i && i.trim());
27896
+ const randomTopics = pickDistinctRandomTopics(interests.length ? 3 : 5);
27897
+ const topicOfInterest = Array.from(/* @__PURE__ */ new Set([...interests, ...randomTopics])).join(", ") || getRandomTopicOfInterest();
27898
+ const webSearchAvailable = useMCPToolsStore.getState().getEnabledTools().some((t) => t.name === "web_search");
27899
+ const knowledgeTopics = prefs.useKnowledgeForStarters ? useKnowledgeStore.getState().docs.map((d) => d.name).filter((n) => n && n.trim()).slice(0, 12) : void 0;
27852
27900
  const args = {
27853
- // keep responses quick and snappy, server may be handling concurrent requests adjust as needed
27854
27901
  limit: 9,
27855
- // pick a random topic of interest from the list, consider using the users preference topics dynamically, otherwise get a random one
27856
- topicOfInterest: getRandomTopicOfInterest(),
27857
- // Pass the current model's system prompt to tailor suggestions
27858
- modelSystemPrompt: currentModel?.systemPrompt
27902
+ topicOfInterest,
27903
+ modelSystemPrompt: currentModel?.systemPrompt,
27904
+ interests,
27905
+ knowledgeTopics,
27906
+ webSearchAvailable
27859
27907
  };
27860
27908
  generateConversationStarters(args).then((prompts) => {
27861
27909
  if (prompts.length > 0) {
@@ -34385,6 +34433,7 @@ var PersonalitiesTab_default = PersonalitiesTab;
34385
34433
  var import_react27 = require("react");
34386
34434
  var import_material20 = require("@mui/material");
34387
34435
  init_preferencesStore();
34436
+ init_getStableQuestionPrompt();
34388
34437
  init_modelStore();
34389
34438
  init_voiceStore();
34390
34439
  init_useFeatures();
@@ -34812,6 +34861,49 @@ var PreferencesTab = ({
34812
34861
  children: "Control which AI features are enabled to optimize performance for your device. Disabling features can help reduce resource usage on machines with limited capabilities."
34813
34862
  }
34814
34863
  ),
34864
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(import_material20.Paper, { sx: { p: { xs: 1.75, sm: 2.5 }, mb: { xs: 2, md: 3 } }, children: [
34865
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(import_material20.Box, { children: [
34866
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_material20.Typography, { variant: "h6", sx: { fontWeight: 600, color: "text.primary" }, children: "Conversation Starters" }),
34867
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_material20.Typography, { variant: "body2", color: "text.secondary", children: "Personalize the suggested prompts on your home screen. Pick the topics you care about \u2014 starters lean toward them (blended with fresh ones each time) instead of generic blanket questions." })
34868
+ ] }),
34869
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_material20.Box, { sx: { mt: 2, display: "flex", flexWrap: "wrap", gap: 1 }, children: TOPICS.map((topic) => {
34870
+ const selected = (preferences.interests ?? []).includes(topic);
34871
+ return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
34872
+ import_material20.Chip,
34873
+ {
34874
+ label: topic,
34875
+ size: "small",
34876
+ color: selected ? "primary" : "default",
34877
+ variant: selected ? "filled" : "outlined",
34878
+ onClick: () => {
34879
+ const current = preferences.interests ?? [];
34880
+ const next = selected ? current.filter((t) => t !== topic) : [...current, topic];
34881
+ updatePreference("interests", next);
34882
+ },
34883
+ sx: { textTransform: "capitalize" }
34884
+ },
34885
+ topic
34886
+ );
34887
+ }) }),
34888
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_material20.Box, { sx: { mt: 2.5 }, children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
34889
+ import_material20.FormControlLabel,
34890
+ {
34891
+ control: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
34892
+ import_material20.Switch,
34893
+ {
34894
+ checked: !!preferences.useKnowledgeForStarters,
34895
+ onChange: (e) => updatePreference("useKnowledgeForStarters", e.target.checked),
34896
+ color: "primary"
34897
+ }
34898
+ ),
34899
+ label: /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(import_material20.Box, { textAlign: "left", children: [
34900
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_material20.Typography, { variant: "body1", sx: { fontWeight: 600, color: "text.primary" }, children: "Use my knowledge documents" }),
34901
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_material20.Typography, { variant: "body2", color: "text.secondary", children: "Let some starters reference the documents in your library." })
34902
+ ] }),
34903
+ sx: { alignSelf: "flex-start", ml: 0 }
34904
+ }
34905
+ ) })
34906
+ ] }),
34815
34907
  /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(import_material20.Paper, { sx: { p: { xs: 1.75, sm: 2.5 }, mb: { xs: 2, md: 3 } }, children: [
34816
34908
  /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(import_material20.Box, { sx: { display: "flex", flexDirection: { xs: "column", sm: "row" }, justifyContent: "space-between", gap: 2 }, children: [
34817
34909
  /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(import_material20.Box, { children: [