@burtson-labs/bandit-engine 2.0.19 → 2.0.20

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.js CHANGED
@@ -18607,7 +18607,7 @@ var init_useMoodEngine = __esm({
18607
18607
  });
18608
18608
 
18609
18609
  // src/services/mcp/mcpService.ts
18610
- var executeMCPTool, getEnabledMCPToolsForAI, isMCPAvailable;
18610
+ var isPlaygroundMode, executeMCPTool, getEnabledMCPToolsForAI, isMCPAvailable;
18611
18611
  var init_mcpService = __esm({
18612
18612
  "src/services/mcp/mcpService.ts"() {
18613
18613
  "use strict";
@@ -18615,10 +18615,25 @@ var init_mcpService = __esm({
18615
18615
  init_packageSettingsStore();
18616
18616
  init_authenticationService();
18617
18617
  init_debugLogger();
18618
+ isPlaygroundMode = () => {
18619
+ const settings = usePackageSettingsStore.getState().settings;
18620
+ if (!settings) {
18621
+ return false;
18622
+ }
18623
+ const gatewayUrl = settings.gatewayApiUrl?.toLowerCase() ?? "";
18624
+ return Boolean(settings.playgroundMode || gatewayUrl.startsWith("playground://"));
18625
+ };
18618
18626
  executeMCPTool = async (toolCall) => {
18619
18627
  try {
18620
18628
  const { tools } = useMCPToolsStore.getState();
18621
18629
  const { settings } = usePackageSettingsStore.getState();
18630
+ if (isPlaygroundMode()) {
18631
+ debugLogger.info("Skipping MCP tool execution in playground mode", { toolName: toolCall.toolName });
18632
+ return {
18633
+ success: false,
18634
+ error: "MCP tools are disabled while playground mode is active."
18635
+ };
18636
+ }
18622
18637
  const tool = tools.find((t) => t.function.name === toolCall.toolName && t.enabled);
18623
18638
  if (!tool) {
18624
18639
  return {
@@ -18721,6 +18736,9 @@ var init_mcpService = __esm({
18721
18736
  }));
18722
18737
  };
18723
18738
  isMCPAvailable = () => {
18739
+ if (isPlaygroundMode()) {
18740
+ return false;
18741
+ }
18724
18742
  const { settings } = usePackageSettingsStore.getState();
18725
18743
  const { tools } = useMCPToolsStore.getState();
18726
18744
  return !!(settings?.gatewayApiUrl && tools.some((t) => t.enabled));
@@ -21690,20 +21708,16 @@ var init_conversation_drawer = __esm({
21690
21708
  return text.slice(start, end).replace(/\s+/g, " ").trim();
21691
21709
  };
21692
21710
  const projectGroups = (0, import_react28.useMemo)(() => {
21693
- const groups = [];
21694
- projects.forEach((project) => {
21695
- const projectConversations = getConversationsByProject(project.id).map((conversation) => ({
21711
+ const groups = projects.map((project) => ({
21712
+ id: project.id,
21713
+ name: project.name,
21714
+ color: project.color,
21715
+ conversations: conversations.filter((conversation) => conversation.projectId === project.id).map((conversation) => ({
21696
21716
  ...conversation
21697
- }));
21698
- groups.push({
21699
- id: project.id,
21700
- name: project.name,
21701
- color: project.color,
21702
- conversations: projectConversations,
21703
- collapsed: collapsedProjects.has(project.id)
21704
- });
21705
- });
21706
- const ungroupedConversations = getConversationsByProject(null).map((conversation) => ({
21717
+ })),
21718
+ collapsed: collapsedProjects.has(project.id)
21719
+ }));
21720
+ const ungroupedConversations = conversations.filter((conversation) => !conversation.projectId).map((conversation) => ({
21707
21721
  ...conversation
21708
21722
  }));
21709
21723
  if (ungroupedConversations.length > 0) {
@@ -21712,11 +21726,10 @@ var init_conversation_drawer = __esm({
21712
21726
  name: "Ungrouped",
21713
21727
  conversations: ungroupedConversations,
21714
21728
  collapsed: false
21715
- // Never collapsed for ungrouped
21716
21729
  });
21717
21730
  }
21718
21731
  return groups.filter((group) => group.conversations.length > 0 || group.id !== null);
21719
- }, [projects, getConversationsByProject, collapsedProjects]);
21732
+ }, [projects, conversations, collapsedProjects]);
21720
21733
  const filteredProjectGroups = (0, import_react28.useMemo)(() => {
21721
21734
  if (!searchQuery.trim()) return projectGroups;
21722
21735
  const query = searchQuery.toLowerCase();
@@ -23270,6 +23283,9 @@ var init_chat_app_bar = __esm({
23270
23283
  const { conversations, currentId, createNewConversation, _hasHydrated } = useConversationStore();
23271
23284
  const { preferences } = usePreferencesStore();
23272
23285
  const { settings: packageSettings } = usePackageSettingsStore();
23286
+ const isPlaygroundRoute = typeof window !== "undefined" && window.location.pathname.includes("/playground");
23287
+ const isPlaygroundMode3 = Boolean(packageSettings?.playgroundMode) || (packageSettings?.gatewayApiUrl ?? "").toLowerCase().startsWith("playground://") || typeof window !== "undefined" && window.location.pathname.startsWith("/playground");
23288
+ const managementPath = isPlaygroundMode3 ? "/playground/management" : "/management";
23273
23289
  const {
23274
23290
  syncEnabled,
23275
23291
  syncStatus,
@@ -23443,10 +23459,10 @@ var init_chat_app_bar = __esm({
23443
23459
  showLimitedAdminPanel() && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_material22.Tooltip, { title: "Management & Settings", arrow: true, children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
23444
23460
  import_material22.IconButton,
23445
23461
  {
23446
- onClick: () => safeNavigate("/management"),
23462
+ onClick: () => safeNavigate(managementPath),
23447
23463
  sx: {
23448
23464
  ...pillButtonStyles,
23449
- ...window.location.pathname === "/management" && {
23465
+ ...typeof window !== "undefined" && window.location.pathname === managementPath && {
23450
23466
  bgcolor: theme.palette.primary.main + "20",
23451
23467
  color: theme.palette.primary.main
23452
23468
  }
@@ -28721,8 +28737,8 @@ var ChatProvider = (props) => {
28721
28737
  useAIQueryStore.getState().hydrate();
28722
28738
  useMemoryStore.getState().hydrate();
28723
28739
  const isPlaygroundRoute = typeof window !== "undefined" && window.location.pathname.includes("/playground");
28724
- const isPlaygroundMode = isPlaygroundRoute || props.packageSettings.playgroundMode === true;
28725
- if (isPlaygroundMode) {
28740
+ const isPlaygroundMode3 = isPlaygroundRoute || props.packageSettings.playgroundMode === true;
28741
+ if (isPlaygroundMode3) {
28726
28742
  debugLogger.info("ChatProvider: Playground mode detected \u2014 skipping remote preference and sync initialization");
28727
28743
  } else {
28728
28744
  await usePreferencesStore.getState().loadPreferences();
@@ -28791,7 +28807,7 @@ var ChatProvider = (props) => {
28791
28807
  debugLogger.error("\u274C Failed to fetch or apply branding config:", { error: err });
28792
28808
  });
28793
28809
  }
28794
- if (!isPlaygroundMode) {
28810
+ if (!isPlaygroundMode3) {
28795
28811
  loadDocuments();
28796
28812
  embeddingService.backfillMissingEmbeddings().catch((err) => {
28797
28813
  debugLogger.error("\u274C Failed to backfill memory embeddings:", { error: err });
@@ -37685,7 +37701,7 @@ var StorageTab = ({ currentTheme }) => {
37685
37701
  ]);
37686
37702
  const calculatedUsed = categories.reduce((sum, cat) => sum + cat.size, 0);
37687
37703
  const browserQuota = quotaEstimate.quota && quotaEstimate.quota > 0 ? quotaEstimate.quota : 0;
37688
- let normalizedQuota = browserQuota > 0 ? Math.min(Math.max(browserQuota, calculatedUsed || DEFAULT_DISPLAY_QUOTA_BYTES), MAX_DISPLAY_QUOTA_BYTES) : Math.max(DEFAULT_DISPLAY_QUOTA_BYTES, calculatedUsed);
37704
+ const normalizedQuota = browserQuota > 0 ? Math.min(Math.max(browserQuota, calculatedUsed || DEFAULT_DISPLAY_QUOTA_BYTES), MAX_DISPLAY_QUOTA_BYTES) : Math.max(DEFAULT_DISPLAY_QUOTA_BYTES, calculatedUsed);
37689
37705
  const available = Math.max(normalizedQuota - calculatedUsed, 0);
37690
37706
  debugLogger.info("Storage data loaded successfully", {
37691
37707
  browserQuota,
@@ -38768,7 +38784,19 @@ var import_Settings3 = __toESM(require("@mui/icons-material/Settings"));
38768
38784
  init_packageSettingsStore();
38769
38785
  init_authenticationService();
38770
38786
  init_debugLogger();
38787
+ var isPlaygroundMode2 = () => {
38788
+ const settings = usePackageSettingsStore.getState().settings;
38789
+ if (!settings) {
38790
+ return false;
38791
+ }
38792
+ const gatewayUrl = settings.gatewayApiUrl?.toLowerCase() ?? "";
38793
+ return Boolean(settings.playgroundMode || gatewayUrl.startsWith("playground://"));
38794
+ };
38771
38795
  function buildUrl2(path) {
38796
+ if (isPlaygroundMode2()) {
38797
+ debugLogger.info("MCP controller URL build skipped in playground mode", { path });
38798
+ return path.startsWith("/") ? path : `/${path}`;
38799
+ }
38772
38800
  const base = usePackageSettingsStore.getState().settings?.gatewayApiUrl?.replace(/\/$/, "") || "";
38773
38801
  if (base) {
38774
38802
  const normalized = path.startsWith("/") ? path : `/${path}`;
@@ -38783,6 +38811,10 @@ function authHeaders() {
38783
38811
  return headers;
38784
38812
  }
38785
38813
  async function fetchAvailableMcpTools() {
38814
+ if (isPlaygroundMode2()) {
38815
+ debugLogger.info("Skipping remote MCP tool fetch \u2014 playground mode active");
38816
+ return [];
38817
+ }
38786
38818
  const url = buildUrl2("/mcp/tools");
38787
38819
  try {
38788
38820
  const res = await fetch(url, { headers: authHeaders() });
@@ -38797,6 +38829,16 @@ async function fetchAvailableMcpTools() {
38797
38829
  }
38798
38830
  }
38799
38831
  async function fetchMcpHealth() {
38832
+ if (isPlaygroundMode2()) {
38833
+ debugLogger.info("Returning mocked MCP health \u2014 playground mode active");
38834
+ return {
38835
+ status: "healthy",
38836
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
38837
+ totalTools: 0,
38838
+ enabledTools: 0,
38839
+ availableTools: []
38840
+ };
38841
+ }
38800
38842
  const url = buildUrl2("/mcp/health");
38801
38843
  try {
38802
38844
  const res = await fetch(url, { headers: authHeaders() });