@burtson-labs/bandit-engine 2.0.65 → 2.0.67

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-5XCDDPTK.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-7EPFQDJW.mjs → chunk-5UD7EJ23.mjs} +24 -13
  8. package/dist/chunk-5UD7EJ23.mjs.map +1 -0
  9. package/dist/{chunk-FXFTA5PZ.mjs → chunk-6DY7W4NK.mjs} +3 -3
  10. package/dist/{chunk-VTC6AIWY.mjs → chunk-6ITUH375.mjs} +3 -3
  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-O44AP4XI.mjs → chunk-RI4LBQ3Q.mjs} +53 -9
  17. package/dist/chunk-RI4LBQ3Q.mjs.map +1 -0
  18. package/dist/{chunk-O7M4OPZU.mjs → chunk-U633CJBV.mjs} +2 -2
  19. package/dist/index.js +121 -37
  20. package/dist/index.js.map +1 -1
  21. package/dist/index.mjs +10 -10
  22. package/dist/management/management.js +120 -36
  23. package/dist/management/management.js.map +1 -1
  24. package/dist/management/management.mjs +8 -8
  25. package/dist/modals/chat-modal/chat-modal.js +4 -0
  26. package/dist/modals/chat-modal/chat-modal.js.map +1 -1
  27. package/dist/modals/chat-modal/chat-modal.mjs +4 -4
  28. package/dist/{modelStore-FBPBG7TI.mjs → modelStore-KCJPXFKO.mjs} +2 -2
  29. package/package.json +1 -1
  30. package/dist/chat-57M4OXFX.mjs +0 -16
  31. package/dist/chunk-7EPFQDJW.mjs.map +0 -1
  32. package/dist/chunk-EUBVBTB3.mjs.map +0 -1
  33. package/dist/chunk-O44AP4XI.mjs.map +0 -1
  34. /package/dist/{chat-57M4OXFX.mjs.map → chat-5XCDDPTK.mjs.map} +0 -0
  35. /package/dist/{chunk-FXFTA5PZ.mjs.map → chunk-6DY7W4NK.mjs.map} +0 -0
  36. /package/dist/{chunk-VTC6AIWY.mjs.map → chunk-6ITUH375.mjs.map} +0 -0
  37. /package/dist/{chunk-D55E6ZDV.mjs.map → chunk-HHMGNCBS.mjs.map} +0 -0
  38. /package/dist/{chunk-6QTTNYF2.mjs.map → chunk-IDZEEONG.mjs.map} +0 -0
  39. /package/dist/{chunk-HKQSZALO.mjs.map → chunk-JURUEF52.mjs.map} +0 -0
  40. /package/dist/{chunk-O7M4OPZU.mjs.map → chunk-U633CJBV.mjs.map} +0 -0
  41. /package/dist/{modelStore-FBPBG7TI.mjs.map → modelStore-KCJPXFKO.mjs.map} +0 -0
@@ -4,7 +4,7 @@ import {
4
4
  getHighlightTree,
5
5
  markdownSanitizeSchema,
6
6
  renderLowlightChildren
7
- } from "./chunk-FXFTA5PZ.mjs";
7
+ } from "./chunk-6DY7W4NK.mjs";
8
8
 
9
9
  // src/components/StreamingMarkdown.tsx
10
10
  import React, { useEffect, useMemo, useRef, useState } from "react";
@@ -495,4 +495,4 @@ var StreamingMarkdown_default = React.memo(StreamingMarkdown, arePropsEqual);
495
495
  export {
496
496
  StreamingMarkdown_default
497
497
  };
498
- //# sourceMappingURL=chunk-O7M4OPZU.mjs.map
498
+ //# sourceMappingURL=chunk-U633CJBV.mjs.map
package/dist/index.js CHANGED
@@ -710,6 +710,8 @@ var init_preferencesStore = __esm({
710
710
  sttEnabled: true,
711
711
  banditModelsEnabled: true,
712
712
  feedbackEnabled: true,
713
+ interests: [],
714
+ useKnowledgeForStarters: false,
713
715
  homeUrl: ""
714
716
  };
715
717
  sanitizePreferences = (preferences) => {
@@ -807,6 +809,8 @@ var init_preferencesStore = __esm({
807
809
  sttEnabled: typeof mergedPreferences.sttEnabled === "boolean" ? mergedPreferences.sttEnabled : defaultPreferences.sttEnabled,
808
810
  banditModelsEnabled: typeof mergedPreferences.banditModelsEnabled === "boolean" ? mergedPreferences.banditModelsEnabled : defaultPreferences.banditModelsEnabled,
809
811
  feedbackEnabled: typeof mergedPreferences.feedbackEnabled === "boolean" ? mergedPreferences.feedbackEnabled : defaultPreferences.feedbackEnabled,
812
+ interests: Array.isArray(mergedPreferences.interests) ? mergedPreferences.interests.filter((i) => typeof i === "string") : defaultPreferences.interests,
813
+ useKnowledgeForStarters: typeof mergedPreferences.useKnowledgeForStarters === "boolean" ? mergedPreferences.useKnowledgeForStarters : defaultPreferences.useKnowledgeForStarters,
810
814
  homeUrl: typeof mergedPreferences.homeUrl === "string" ? mergedPreferences.homeUrl : defaultPreferences.homeUrl
811
815
  };
812
816
  set({ preferences: validatedPreferences });
@@ -6620,7 +6624,7 @@ var init_util = __esm({
6620
6624
  });
6621
6625
 
6622
6626
  // src/prompts/getStableQuestionPrompt.ts
6623
- var TOPICS, getRandomTopicOfInterest, getStableQuestionPrompt;
6627
+ var TOPICS, getRandomTopicOfInterest, pickDistinctRandomTopics, getStableQuestionPrompt;
6624
6628
  var init_getStableQuestionPrompt = __esm({
6625
6629
  "src/prompts/getStableQuestionPrompt.ts"() {
6626
6630
  "use strict";
@@ -6633,42 +6637,65 @@ var init_getStableQuestionPrompt = __esm({
6633
6637
  const randomTopic = TOPICS[randomIndex];
6634
6638
  return randomTopic;
6635
6639
  };
6640
+ pickDistinctRandomTopics = (count) => {
6641
+ const pool = [...TOPICS];
6642
+ const picked = [];
6643
+ const n = Math.min(Math.max(count, 0), pool.length);
6644
+ for (let i = 0; i < n; i++) {
6645
+ const idx = randomRange(0, pool.length - 1);
6646
+ picked.push(pool[idx]);
6647
+ pool.splice(idx, 1);
6648
+ }
6649
+ return picked;
6650
+ };
6636
6651
  getStableQuestionPrompt = (args) => {
6637
- const { limit, topicOfInterest, modelSystemPrompt } = args;
6652
+ const { limit, topicOfInterest, modelSystemPrompt, interests, knowledgeTopics, webSearchAvailable } = args;
6638
6653
  if (limit < 1 || limit > 10) {
6639
6654
  throw new Error("Limit must be between 1 and 10");
6640
6655
  }
6641
6656
  const seed = generateSeed();
6642
- let prompt = `You are a helpful assistant.
6643
-
6644
- The following seed uniquely identifies the topic: "${seed}"`;
6657
+ const lines = [
6658
+ `You are crafting fresh, engaging conversation starters for a chat app's home screen.`,
6659
+ ``,
6660
+ `Variation seed (make this set different from any previous set): "${seed}"`
6661
+ ];
6645
6662
  if (modelSystemPrompt && modelSystemPrompt.trim()) {
6646
- prompt += `
6647
-
6648
- Based on this specialized assistant profile: "${modelSystemPrompt.trim()}"`;
6663
+ lines.push(``, `Tailor the questions to this assistant's role and expertise: "${modelSystemPrompt.trim()}"`);
6649
6664
  }
6650
- prompt += `
6651
-
6652
- 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:
6653
-
6654
- - Relevant to ${topicOfInterest}`;
6655
- if (modelSystemPrompt && modelSystemPrompt.trim()) {
6656
- prompt += `
6657
- - Aligned with the assistant's specialized capabilities and knowledge area`;
6658
- }
6659
- prompt += `
6660
- - Specific enough to be practical
6661
- - Easy to understand and not abstract
6662
-
6663
- Do not:
6664
- - Refer to yourself or use phrases like "As an AI..."
6665
- - Include greetings, explanations, or personality
6666
- - Include jokes, fiction, or quotes
6667
- - Number, bullet, or otherwise prefix the questions with extra characters
6668
- - Repeat the same idea phrased differently \u2014 each question must explore a distinct angle or subtopic
6669
-
6670
- Output only ${limit} questions \u2014 one per line, with no leading numbers, bullets, or prefixes.`;
6671
- return prompt.trim();
6665
+ if (interests && interests.length) {
6666
+ lines.push(
6667
+ ``,
6668
+ `The user is especially interested in: ${interests.join(", ")}. Lean toward these, but do NOT make every question about the same one.`
6669
+ );
6670
+ }
6671
+ if (knowledgeTopics && knowledgeTopics.length) {
6672
+ lines.push(
6673
+ ``,
6674
+ `The user keeps these documents in their library: ${knowledgeTopics.join("; ")}. Include one or two questions that draw on this material.`
6675
+ );
6676
+ }
6677
+ lines.push(
6678
+ ``,
6679
+ `Spread the set across a VARIETY of these topics so it never feels repetitive (do not cluster on one): ${topicOfInterest}.`
6680
+ );
6681
+ if (webSearchAvailable) {
6682
+ lines.push(
6683
+ ``,
6684
+ `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.`
6685
+ );
6686
+ }
6687
+ lines.push(
6688
+ ``,
6689
+ `Generate ${limit} concise (5\u201320 words), natural-sounding questions a user might ask${modelSystemPrompt ? " this specialized assistant" : " an AI assistant"}. Requirements:`,
6690
+ `- Each question must explore a DISTINCT topic or angle \u2014 no two may be similar or rephrasings of each other.`,
6691
+ `- Vary the type across the set: practical how-to, curious exploration, current/topical, creative, and learning.`,
6692
+ `- Specific and concrete, easy to understand, not abstract.`,
6693
+ ``,
6694
+ `Do not refer to yourself, say "As an AI", add greetings, explanations, jokes, fiction, quotes, or number/bullet the lines.`,
6695
+ ``,
6696
+ `Output only ${limit} questions \u2014 one per line, with no leading numbers, bullets, or prefixes.`
6697
+ );
6698
+ return lines.join("\n").trim();
6672
6699
  };
6673
6700
  }
6674
6701
  });
@@ -21049,7 +21076,7 @@ ${r.output}`).join("\n\n");
21049
21076
 
21050
21077
  ${toolResultsText}
21051
21078
 
21052
- Using these results together with your own knowledge, answer my original question concisely and in a natural, well-formatted way. Reference sources by name where relevant, but do NOT paste raw URLs or a list of links \u2014 a clean Sources section is added automatically below your answer. Do NOT output tool_code or call any tools again.`
21079
+ Using these results together with your own knowledge, answer my original question concisely and in a natural, well-formatted way. Do NOT add a "Sources", "References", or "Citations" list of any kind \u2014 not names and not URLs. A clean, clickable Sources section is appended automatically below your answer, so any list you add just duplicates it. (Mentioning a source naturally inside a sentence is fine; a trailing list is not.) Do NOT output tool_code or call any tools again.`
21053
21080
  }
21054
21081
  ];
21055
21082
  const summaryRequest = {
@@ -21104,6 +21131,10 @@ _Writing the answer\u2026_` : "_Writing the answer\u2026_"
21104
21131
  }, 3e4);
21105
21132
  });
21106
21133
  if (summaryText.trim()) {
21134
+ const cleanedSummary = summaryText.replace(
21135
+ /\n{1,}\s*(?:[*_#>\s]*)(?:sources?|references?|citations?|further reading)(?:\s*:)?\s*(?:[*_]*)\s*\n[\s\S]*$/i,
21136
+ ""
21137
+ ).trimEnd();
21107
21138
  const sourcesMd = collectedSources.length ? `
21108
21139
 
21109
21140
  **Sources**
@@ -21115,7 +21146,7 @@ ${collectedSources.slice(0, 6).map((s) => {
21115
21146
  }
21116
21147
  return `- [${s.title || domain}](${s.url}) \u2014 ${domain}`;
21117
21148
  }).join("\n")}` : "";
21118
- enhancedMessage = summaryText + sourcesMd + (inlineImageBlocks.length ? `
21149
+ enhancedMessage = cleanedSummary + sourcesMd + (inlineImageBlocks.length ? `
21119
21150
 
21120
21151
  ${inlineImageBlocks.join("\n\n")}` : "");
21121
21152
  }
@@ -25596,6 +25627,9 @@ var init_query_suggestion_picker = __esm({
25596
25627
  init_prompts();
25597
25628
  init_getStableQuestionPrompt();
25598
25629
  init_modelStore();
25630
+ init_preferencesStore();
25631
+ init_knowledgeStore();
25632
+ init_mcpToolsStore();
25599
25633
  import_jsx_runtime25 = require("react/jsx-runtime");
25600
25634
  markdownComponents = {
25601
25635
  p: ({ node, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("span", { ...props }),
@@ -25622,13 +25656,19 @@ var init_query_suggestion_picker = __esm({
25622
25656
  if (hasGenerated.current || isLoading) return;
25623
25657
  hasGenerated.current = true;
25624
25658
  const currentModel = getCurrentModel();
25659
+ const prefs = usePreferencesStore.getState().preferences;
25660
+ const interests = (prefs.interests ?? []).filter((i) => i && i.trim());
25661
+ const randomTopics = pickDistinctRandomTopics(interests.length ? 3 : 5);
25662
+ const topicOfInterest = Array.from(/* @__PURE__ */ new Set([...interests, ...randomTopics])).join(", ") || getRandomTopicOfInterest();
25663
+ const webSearchAvailable = useMCPToolsStore.getState().getEnabledTools().some((t) => t.name === "web_search");
25664
+ const knowledgeTopics = prefs.useKnowledgeForStarters ? useKnowledgeStore.getState().docs.map((d) => d.name).filter((n) => n && n.trim()).slice(0, 12) : void 0;
25625
25665
  const args = {
25626
- // keep responses quick and snappy, server may be handling concurrent requests adjust as needed
25627
25666
  limit: 9,
25628
- // pick a random topic of interest from the list, consider using the users preference topics dynamically, otherwise get a random one
25629
- topicOfInterest: getRandomTopicOfInterest(),
25630
- // Pass the current model's system prompt to tailor suggestions
25631
- modelSystemPrompt: currentModel?.systemPrompt
25667
+ topicOfInterest,
25668
+ modelSystemPrompt: currentModel?.systemPrompt,
25669
+ interests,
25670
+ knowledgeTopics,
25671
+ webSearchAvailable
25632
25672
  };
25633
25673
  generateConversationStarters(args).then((prompts) => {
25634
25674
  if (prompts.length > 0) {
@@ -35302,6 +35342,7 @@ var PersonalitiesTab_default = PersonalitiesTab;
35302
35342
  var import_react47 = require("react");
35303
35343
  var import_material38 = require("@mui/material");
35304
35344
  init_preferencesStore();
35345
+ init_getStableQuestionPrompt();
35305
35346
  init_modelStore();
35306
35347
  init_voiceStore();
35307
35348
  init_useFeatures();
@@ -35759,6 +35800,49 @@ var PreferencesTab = ({
35759
35800
  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."
35760
35801
  }
35761
35802
  ),
35803
+ /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)(import_material38.Paper, { sx: { p: { xs: 1.75, sm: 2.5 }, mb: { xs: 2, md: 3 } }, children: [
35804
+ /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)(import_material38.Box, { children: [
35805
+ /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(import_material38.Typography, { variant: "h6", sx: { fontWeight: 600, color: "text.primary" }, children: "Conversation Starters" }),
35806
+ /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(import_material38.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." })
35807
+ ] }),
35808
+ /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(import_material38.Box, { sx: { mt: 2, display: "flex", flexWrap: "wrap", gap: 1 }, children: TOPICS.map((topic) => {
35809
+ const selected = (preferences.interests ?? []).includes(topic);
35810
+ return /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
35811
+ import_material38.Chip,
35812
+ {
35813
+ label: topic,
35814
+ size: "small",
35815
+ color: selected ? "primary" : "default",
35816
+ variant: selected ? "filled" : "outlined",
35817
+ onClick: () => {
35818
+ const current = preferences.interests ?? [];
35819
+ const next = selected ? current.filter((t) => t !== topic) : [...current, topic];
35820
+ updatePreference("interests", next);
35821
+ },
35822
+ sx: { textTransform: "capitalize" }
35823
+ },
35824
+ topic
35825
+ );
35826
+ }) }),
35827
+ /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(import_material38.Box, { sx: { mt: 2.5 }, children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
35828
+ import_material38.FormControlLabel,
35829
+ {
35830
+ control: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
35831
+ import_material38.Switch,
35832
+ {
35833
+ checked: !!preferences.useKnowledgeForStarters,
35834
+ onChange: (e) => updatePreference("useKnowledgeForStarters", e.target.checked),
35835
+ color: "primary"
35836
+ }
35837
+ ),
35838
+ label: /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)(import_material38.Box, { textAlign: "left", children: [
35839
+ /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(import_material38.Typography, { variant: "body1", sx: { fontWeight: 600, color: "text.primary" }, children: "Use my knowledge documents" }),
35840
+ /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(import_material38.Typography, { variant: "body2", color: "text.secondary", children: "Let some starters reference the documents in your library." })
35841
+ ] }),
35842
+ sx: { alignSelf: "flex-start", ml: 0 }
35843
+ }
35844
+ ) })
35845
+ ] }),
35762
35846
  /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)(import_material38.Paper, { sx: { p: { xs: 1.75, sm: 2.5 }, mb: { xs: 2, md: 3 } }, children: [
35763
35847
  /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)(import_material38.Box, { sx: { display: "flex", flexDirection: { xs: "column", sm: "row" }, justifyContent: "space-between", gap: 2 }, children: [
35764
35848
  /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)(import_material38.Box, { children: [