@burtson-labs/bandit-engine 2.0.52 → 2.0.53

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 (45) hide show
  1. package/dist/{aiProviderStore-3N3VE6D4.mjs → aiProviderStore-337QNQB3.mjs} +2 -2
  2. package/dist/{chat-YWYLVKXX.mjs → chat-U4SE4JQK.mjs} +6 -6
  3. package/dist/chat-provider.js +17 -9
  4. package/dist/chat-provider.js.map +1 -1
  5. package/dist/chat-provider.mjs +4 -4
  6. package/dist/{chunk-RSSJADDD.mjs → chunk-2BGORTWS.mjs} +4 -4
  7. package/dist/{chunk-QX6CO7TJ.mjs → chunk-557E5VZ2.mjs} +3 -3
  8. package/dist/{chunk-MH7WFWCP.mjs → chunk-AVV7HDGR.mjs} +3 -3
  9. package/dist/{chunk-YZ2HJFPQ.mjs → chunk-EULV5CHD.mjs} +2 -2
  10. package/dist/{chunk-TSQCNHOX.mjs → chunk-GNE4TTSI.mjs} +48 -15
  11. package/dist/chunk-GNE4TTSI.mjs.map +1 -0
  12. package/dist/{chunk-BENL3EF2.mjs → chunk-H3BYFEIE.mjs} +18 -10
  13. package/dist/chunk-H3BYFEIE.mjs.map +1 -0
  14. package/dist/{chunk-M3BEAMCC.mjs → chunk-NZKLKZJT.mjs} +3 -3
  15. package/dist/{chunk-Y5N3NSTU.mjs → chunk-O54PTFJM.mjs} +8 -8
  16. package/dist/{chunk-37PEP5JK.mjs → chunk-UFSEYVRS.mjs} +3 -3
  17. package/dist/cli.js +1 -1
  18. package/dist/cli.js.map +1 -1
  19. package/dist/{gateway-oScD5tvE.d.mts → gateway-C5T5FfCy.d.mts} +32 -0
  20. package/dist/{gateway-oScD5tvE.d.ts → gateway-C5T5FfCy.d.ts} +32 -0
  21. package/dist/index.d.mts +2 -2
  22. package/dist/index.d.ts +2 -2
  23. package/dist/index.js +60 -19
  24. package/dist/index.js.map +1 -1
  25. package/dist/index.mjs +9 -9
  26. package/dist/management/management.js +60 -19
  27. package/dist/management/management.js.map +1 -1
  28. package/dist/management/management.mjs +7 -7
  29. package/dist/modals/chat-modal/chat-modal.js +17 -9
  30. package/dist/modals/chat-modal/chat-modal.js.map +1 -1
  31. package/dist/modals/chat-modal/chat-modal.mjs +4 -4
  32. package/dist/public-types.d.mts +1 -1
  33. package/dist/public-types.d.ts +1 -1
  34. package/package.json +1 -1
  35. package/dist/chunk-BENL3EF2.mjs.map +0 -1
  36. package/dist/chunk-TSQCNHOX.mjs.map +0 -1
  37. /package/dist/{aiProviderStore-3N3VE6D4.mjs.map → aiProviderStore-337QNQB3.mjs.map} +0 -0
  38. /package/dist/{chat-YWYLVKXX.mjs.map → chat-U4SE4JQK.mjs.map} +0 -0
  39. /package/dist/{chunk-RSSJADDD.mjs.map → chunk-2BGORTWS.mjs.map} +0 -0
  40. /package/dist/{chunk-QX6CO7TJ.mjs.map → chunk-557E5VZ2.mjs.map} +0 -0
  41. /package/dist/{chunk-MH7WFWCP.mjs.map → chunk-AVV7HDGR.mjs.map} +0 -0
  42. /package/dist/{chunk-YZ2HJFPQ.mjs.map → chunk-EULV5CHD.mjs.map} +0 -0
  43. /package/dist/{chunk-M3BEAMCC.mjs.map → chunk-NZKLKZJT.mjs.map} +0 -0
  44. /package/dist/{chunk-Y5N3NSTU.mjs.map → chunk-O54PTFJM.mjs.map} +0 -0
  45. /package/dist/{chunk-37PEP5JK.mjs.map → chunk-UFSEYVRS.mjs.map} +0 -0
package/dist/index.mjs CHANGED
@@ -1,25 +1,25 @@
1
1
  import {
2
2
  chat_default
3
- } from "./chunk-TSQCNHOX.mjs";
3
+ } from "./chunk-GNE4TTSI.mjs";
4
4
  import {
5
5
  chat_provider_default
6
- } from "./chunk-MH7WFWCP.mjs";
6
+ } from "./chunk-AVV7HDGR.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-Y5N3NSTU.mjs";
14
- import "./chunk-YZ2HJFPQ.mjs";
15
- import "./chunk-37PEP5JK.mjs";
13
+ } from "./chunk-O54PTFJM.mjs";
14
+ import "./chunk-EULV5CHD.mjs";
15
+ import "./chunk-UFSEYVRS.mjs";
16
16
  import "./chunk-EHNWQ4T3.mjs";
17
17
  import {
18
18
  defineCustomElement
19
19
  } from "./chunk-IXIM7BNO.mjs";
20
20
  import {
21
21
  chat_modal_default
22
- } from "./chunk-RSSJADDD.mjs";
22
+ } from "./chunk-2BGORTWS.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-M3BEAMCC.mjs";
40
+ } from "./chunk-NZKLKZJT.mjs";
41
41
  import {
42
42
  DEFAULT_TIER_FEATURES,
43
43
  FeatureFlagContext,
@@ -57,11 +57,11 @@ import {
57
57
  useVectorStore,
58
58
  vectorDatabaseService,
59
59
  vectorMigrationService
60
- } from "./chunk-QX6CO7TJ.mjs";
60
+ } from "./chunk-557E5VZ2.mjs";
61
61
  import {
62
62
  usePackageSettingsStore
63
63
  } from "./chunk-7ZDS33S2.mjs";
64
- import "./chunk-BENL3EF2.mjs";
64
+ import "./chunk-H3BYFEIE.mjs";
65
65
  import {
66
66
  DebugLogger,
67
67
  debugLogger
@@ -1709,7 +1709,8 @@ var init_gateway_service = __esm({
1709
1709
  index: 0,
1710
1710
  delta: {
1711
1711
  role: parsed.message.role,
1712
- content: parsed.message.content
1712
+ content: parsed.message.content,
1713
+ tool_calls: parsed.message.tool_calls
1713
1714
  },
1714
1715
  finish_reason: parsed.done ? parsed.done_reason || "stop" : null
1715
1716
  }]
@@ -2689,6 +2690,7 @@ var init_gateway_provider = __esm({
2689
2690
  }
2690
2691
  }
2691
2692
  }
2693
+ const toolAwareRequest = request;
2692
2694
  const gatewayRequest = {
2693
2695
  model: request.model,
2694
2696
  messages,
@@ -2697,7 +2699,8 @@ var init_gateway_provider = __esm({
2697
2699
  max_tokens: request.maxTokens,
2698
2700
  provider: this.config.provider,
2699
2701
  // Only include top-level images for Ollama (fallback)
2700
- images: this.config.provider === "ollama" ? request.images : void 0
2702
+ images: this.config.provider === "ollama" ? request.images : void 0,
2703
+ tools: toolAwareRequest.tools?.length ? toolAwareRequest.tools : void 0
2701
2704
  };
2702
2705
  debugLogger.debug("Gateway provider chat request", {
2703
2706
  model: request.model,
@@ -2714,13 +2717,18 @@ var init_gateway_provider = __esm({
2714
2717
  }))
2715
2718
  });
2716
2719
  return this.gatewayService.chat(gatewayRequest).pipe(
2717
- (0, import_rxjs7.map)((response) => ({
2718
- message: {
2719
- content: response.choices?.[0]?.message?.content || response.choices?.[0]?.delta?.content || "",
2720
- role: "assistant"
2721
- },
2722
- done: response.choices?.[0]?.finish_reason === "stop" || response.choices?.[0]?.finish_reason === "length"
2723
- }))
2720
+ (0, import_rxjs7.map)((response) => {
2721
+ const choice = response.choices?.[0];
2722
+ const toolCalls = choice?.message?.tool_calls ?? choice?.delta?.tool_calls;
2723
+ return {
2724
+ message: {
2725
+ content: choice?.message?.content ?? choice?.delta?.content ?? "",
2726
+ role: "assistant",
2727
+ tool_calls: toolCalls
2728
+ },
2729
+ done: choice?.finish_reason === "stop" || choice?.finish_reason === "length" || choice?.finish_reason === "tool_calls"
2730
+ };
2731
+ })
2724
2732
  );
2725
2733
  }
2726
2734
  generate(request) {
@@ -20065,6 +20073,7 @@ var init_chat_messages = __esm({
20065
20073
  scrollTargetRef,
20066
20074
  responseStarted,
20067
20075
  isStreaming,
20076
+ isThinking = false,
20068
20077
  isNetworkSlow = false,
20069
20078
  showInstantFeedback = true,
20070
20079
  selectedModel,
@@ -20081,6 +20090,7 @@ var init_chat_messages = __esm({
20081
20090
  const isLast = index === lastIndex;
20082
20091
  const isPlaceholder = entry.answer === "...";
20083
20092
  const showLoader = isLast && isStreaming && streamBuffer.trim() === "";
20093
+ const showThinking = showLoader && isThinking;
20084
20094
  const content = isLast ? isStreaming ? streamBuffer || "" : isPlaceholder ? "" : entry.answer : entry.answer;
20085
20095
  const rawSources = entry.sourceFiles;
20086
20096
  const sourceSummaries = rawSources ? rawSources.filter((doc) => doc && typeof doc.name === "string" && doc.name.trim()).map((doc) => ({ id: doc.id || doc.name, name: doc.name.trim() })) : void 0;
@@ -20108,11 +20118,27 @@ var init_chat_messages = __esm({
20108
20118
  pointerEvents: showLoader ? "auto" : "none",
20109
20119
  zIndex: showLoader ? 1 : 0
20110
20120
  },
20111
- children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(import_material32.Box, { sx: { display: "flex", alignItems: "center", minHeight: "40px", pl: 2 }, children: /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)("div", { className: "typing-only", children: [
20112
- /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("span", { className: "dot" }),
20113
- /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("span", { className: "dot" }),
20114
- /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("span", { className: "dot" })
20115
- ] }) })
20121
+ children: /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)(import_material32.Box, { sx: { display: "flex", alignItems: "center", gap: 1, minHeight: "40px", pl: 2 }, children: [
20122
+ /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)("div", { className: "typing-only", children: [
20123
+ /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("span", { className: "dot" }),
20124
+ /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("span", { className: "dot" }),
20125
+ /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("span", { className: "dot" })
20126
+ ] }),
20127
+ showThinking && /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
20128
+ import_material32.Box,
20129
+ {
20130
+ component: "span",
20131
+ sx: {
20132
+ fontSize: "0.75rem",
20133
+ color: "text.secondary",
20134
+ opacity: 0.6,
20135
+ fontStyle: "italic",
20136
+ userSelect: "none"
20137
+ },
20138
+ children: "Thinking\u2026"
20139
+ }
20140
+ )
20141
+ ] })
20116
20142
  }
20117
20143
  ),
20118
20144
  /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
@@ -22251,6 +22277,7 @@ var init_useAIProvider = __esm({
22251
22277
  setIsSubmitting,
22252
22278
  setResponseStarted,
22253
22279
  setIsStreaming,
22280
+ setIsThinking,
22254
22281
  setResponse,
22255
22282
  setPastedImages,
22256
22283
  setPendingMessage,
@@ -22708,6 +22735,12 @@ ${protocol}`;
22708
22735
  let fullMessage = "";
22709
22736
  let latestDisplayMessage = "";
22710
22737
  let sawToolBlock = false;
22738
+ const stripThinking = (text) => {
22739
+ let result = text.replace(/<think>[\s\S]*?<\/think>/g, "");
22740
+ const openIdx = result.indexOf("<think>");
22741
+ if (openIdx !== -1) result = result.slice(0, openIdx);
22742
+ return result.trimStart();
22743
+ };
22711
22744
  const flushNow = () => {
22712
22745
  clearFlushTimer();
22713
22746
  if (!sawToolBlock) {
@@ -22735,13 +22768,16 @@ ${protocol}`;
22735
22768
  }
22736
22769
  const sub = stream.subscribe({
22737
22770
  next: (data) => {
22738
- if (!data?.message?.content) return;
22739
- fullMessage += data.message.content;
22740
- if (/```(?:tool_code|TOOL_CODE)/.test(fullMessage)) {
22771
+ if (!data?.message?.content && !data?.message?.tool_calls) return;
22772
+ if (data.message.content) fullMessage += data.message.content;
22773
+ const inThinkBlock = /<think>/.test(fullMessage) && !/<think>[\s\S]*<\/think>/.test(fullMessage);
22774
+ setIsThinking?.(inThinkBlock);
22775
+ const visibleMessage = stripThinking(fullMessage);
22776
+ if (/```(?:tool_code|TOOL_CODE)/.test(visibleMessage)) {
22741
22777
  sawToolBlock = true;
22742
22778
  clearFlushTimer();
22743
22779
  }
22744
- latestDisplayMessage = fullMessage;
22780
+ latestDisplayMessage = visibleMessage;
22745
22781
  if (!sawToolBlock) {
22746
22782
  scheduleFlush();
22747
22783
  }
@@ -22762,6 +22798,7 @@ ${protocol}`;
22762
22798
  setResponse(partial);
22763
22799
  }
22764
22800
  setStreamBuffer("");
22801
+ setIsThinking?.(false);
22765
22802
  setPendingMessage(null);
22766
22803
  setLogoVisible(false);
22767
22804
  if (onError) {
@@ -22770,7 +22807,8 @@ ${protocol}`;
22770
22807
  },
22771
22808
  complete: async () => {
22772
22809
  try {
22773
- latestDisplayMessage = fullMessage;
22810
+ setIsThinking?.(false);
22811
+ latestDisplayMessage = stripThinking(fullMessage);
22774
22812
  if (!sawToolBlock) {
22775
22813
  flushNow();
22776
22814
  }
@@ -28132,6 +28170,7 @@ var init_chat2 = __esm({
28132
28170
  const [streamBuffer, setStreamBuffer] = (0, import_react55.useState)("");
28133
28171
  const [responseStarted, setResponseStarted] = (0, import_react55.useState)(false);
28134
28172
  const [isStreaming, setIsStreaming] = (0, import_react55.useState)(false);
28173
+ const [isThinking, setIsThinking] = (0, import_react55.useState)(false);
28135
28174
  const initialLogoState = history.length === 0;
28136
28175
  const [logoVisible, setLogoVisible] = (0, import_react55.useState)(initialLogoState);
28137
28176
  const [logoShouldRender, setLogoShouldRender] = (0, import_react55.useState)(initialLogoState);
@@ -28615,6 +28654,7 @@ var init_chat2 = __esm({
28615
28654
  overrideComponentStatus: setComponentStatus,
28616
28655
  setIsSubmitting,
28617
28656
  setIsStreaming,
28657
+ setIsThinking,
28618
28658
  setResponseStarted,
28619
28659
  setResponse,
28620
28660
  setStreamBuffer,
@@ -29021,6 +29061,7 @@ var init_chat2 = __esm({
29021
29061
  chat_messages_default,
29022
29062
  {
29023
29063
  isStreaming,
29064
+ isThinking,
29024
29065
  history,
29025
29066
  pendingMessage,
29026
29067
  streamBuffer,