@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
@@ -16,10 +16,19 @@ interface AIChatRequest {
16
16
  images?: string[];
17
17
  options?: Record<string, unknown>;
18
18
  }
19
+ interface AIToolCall {
20
+ id?: string;
21
+ type?: 'function';
22
+ function: {
23
+ name: string;
24
+ arguments: string | Record<string, unknown>;
25
+ };
26
+ }
19
27
  interface AIChatResponse {
20
28
  message: {
21
29
  content: string;
22
30
  role: 'assistant';
31
+ tool_calls?: AIToolCall[];
23
32
  };
24
33
  done?: boolean;
25
34
  }
@@ -208,6 +217,18 @@ interface GatewayMessage {
208
217
  name?: string;
209
218
  images?: string[];
210
219
  }
220
+ interface GatewayTool {
221
+ type: 'function';
222
+ function: {
223
+ name: string;
224
+ description?: string;
225
+ parameters?: {
226
+ type: string;
227
+ properties?: Record<string, unknown>;
228
+ required?: string[];
229
+ };
230
+ };
231
+ }
211
232
  interface GatewayChatRequest {
212
233
  model: string;
213
234
  messages: GatewayMessage[];
@@ -220,6 +241,15 @@ interface GatewayChatRequest {
220
241
  provider?: 'openai' | 'azure-openai' | 'anthropic' | 'ollama' | 'xai' | 'bandit' | 'playground';
221
242
  stop?: string | string[];
222
243
  images?: string[];
244
+ tools?: GatewayTool[];
245
+ }
246
+ interface GatewayToolCall {
247
+ id?: string;
248
+ type?: 'function';
249
+ function: {
250
+ name: string;
251
+ arguments: string | Record<string, unknown>;
252
+ };
223
253
  }
224
254
  interface GatewayChatResponse {
225
255
  id: string;
@@ -231,10 +261,12 @@ interface GatewayChatResponse {
231
261
  delta?: {
232
262
  role?: string;
233
263
  content?: string;
264
+ tool_calls?: GatewayToolCall[];
234
265
  };
235
266
  message?: {
236
267
  role: string;
237
268
  content: string;
269
+ tool_calls?: GatewayToolCall[];
238
270
  };
239
271
  finish_reason?: string | null;
240
272
  }[];
@@ -16,10 +16,19 @@ interface AIChatRequest {
16
16
  images?: string[];
17
17
  options?: Record<string, unknown>;
18
18
  }
19
+ interface AIToolCall {
20
+ id?: string;
21
+ type?: 'function';
22
+ function: {
23
+ name: string;
24
+ arguments: string | Record<string, unknown>;
25
+ };
26
+ }
19
27
  interface AIChatResponse {
20
28
  message: {
21
29
  content: string;
22
30
  role: 'assistant';
31
+ tool_calls?: AIToolCall[];
23
32
  };
24
33
  done?: boolean;
25
34
  }
@@ -208,6 +217,18 @@ interface GatewayMessage {
208
217
  name?: string;
209
218
  images?: string[];
210
219
  }
220
+ interface GatewayTool {
221
+ type: 'function';
222
+ function: {
223
+ name: string;
224
+ description?: string;
225
+ parameters?: {
226
+ type: string;
227
+ properties?: Record<string, unknown>;
228
+ required?: string[];
229
+ };
230
+ };
231
+ }
211
232
  interface GatewayChatRequest {
212
233
  model: string;
213
234
  messages: GatewayMessage[];
@@ -220,6 +241,15 @@ interface GatewayChatRequest {
220
241
  provider?: 'openai' | 'azure-openai' | 'anthropic' | 'ollama' | 'xai' | 'bandit' | 'playground';
221
242
  stop?: string | string[];
222
243
  images?: string[];
244
+ tools?: GatewayTool[];
245
+ }
246
+ interface GatewayToolCall {
247
+ id?: string;
248
+ type?: 'function';
249
+ function: {
250
+ name: string;
251
+ arguments: string | Record<string, unknown>;
252
+ };
223
253
  }
224
254
  interface GatewayChatResponse {
225
255
  id: string;
@@ -231,10 +261,12 @@ interface GatewayChatResponse {
231
261
  delta?: {
232
262
  role?: string;
233
263
  content?: string;
264
+ tool_calls?: GatewayToolCall[];
234
265
  };
235
266
  message?: {
236
267
  role: string;
237
268
  content: string;
269
+ tool_calls?: GatewayToolCall[];
238
270
  };
239
271
  finish_reason?: string | null;
240
272
  }[];
package/dist/index.d.mts CHANGED
@@ -1,5 +1,5 @@
1
- import { F as FeatureFlagConfig, a as FeatureKey, b as FeatureEvaluation, S as SubscriptionTier, T as TrialUsage, G as GatewayHealthResponse, c as GatewayModel, d as GatewayMemoryResponse } from './gateway-oScD5tvE.mjs';
2
- export { t as AIChatRequest, u as AIChatResponse, w as AIGenerateRequest, x as AIGenerateResponse, y as AIMessage, s as AIModel, A as AIProviderConfig, g as ChatConfig, e as ChatModal, h as ChatModalProps, C as ChatProvider, D as DEFAULT_TIER_FEATURES, f as FeatureMatrix, m as GatewayChatRequest, n as GatewayChatResponse, j as GatewayContract, o as GatewayGenerateRequest, p as GatewayGenerateResponse, r as GatewayMemoryRecord, l as GatewayMessage, k as GatewayMessageContent, q as GatewayModelsResponse, O as OSS_DEFAULT_FEATURES, P as PackageSettings, i as VoiceModelsResponse, V as VoiceService, v as voiceService } from './gateway-oScD5tvE.mjs';
1
+ import { F as FeatureFlagConfig, a as FeatureKey, b as FeatureEvaluation, S as SubscriptionTier, T as TrialUsage, G as GatewayHealthResponse, c as GatewayModel, d as GatewayMemoryResponse } from './gateway-C5T5FfCy.mjs';
2
+ export { t as AIChatRequest, u as AIChatResponse, w as AIGenerateRequest, x as AIGenerateResponse, y as AIMessage, s as AIModel, A as AIProviderConfig, g as ChatConfig, e as ChatModal, h as ChatModalProps, C as ChatProvider, D as DEFAULT_TIER_FEATURES, f as FeatureMatrix, m as GatewayChatRequest, n as GatewayChatResponse, j as GatewayContract, o as GatewayGenerateRequest, p as GatewayGenerateResponse, r as GatewayMemoryRecord, l as GatewayMessage, k as GatewayMessageContent, q as GatewayModelsResponse, O as OSS_DEFAULT_FEATURES, P as PackageSettings, i as VoiceModelsResponse, V as VoiceService, v as voiceService } from './gateway-C5T5FfCy.mjs';
3
3
  import * as react_jsx_runtime from 'react/jsx-runtime';
4
4
  import React, { ReactNode } from 'react';
5
5
  import * as zustand from 'zustand';
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { F as FeatureFlagConfig, a as FeatureKey, b as FeatureEvaluation, S as SubscriptionTier, T as TrialUsage, G as GatewayHealthResponse, c as GatewayModel, d as GatewayMemoryResponse } from './gateway-oScD5tvE.js';
2
- export { t as AIChatRequest, u as AIChatResponse, w as AIGenerateRequest, x as AIGenerateResponse, y as AIMessage, s as AIModel, A as AIProviderConfig, g as ChatConfig, e as ChatModal, h as ChatModalProps, C as ChatProvider, D as DEFAULT_TIER_FEATURES, f as FeatureMatrix, m as GatewayChatRequest, n as GatewayChatResponse, j as GatewayContract, o as GatewayGenerateRequest, p as GatewayGenerateResponse, r as GatewayMemoryRecord, l as GatewayMessage, k as GatewayMessageContent, q as GatewayModelsResponse, O as OSS_DEFAULT_FEATURES, P as PackageSettings, i as VoiceModelsResponse, V as VoiceService, v as voiceService } from './gateway-oScD5tvE.js';
1
+ import { F as FeatureFlagConfig, a as FeatureKey, b as FeatureEvaluation, S as SubscriptionTier, T as TrialUsage, G as GatewayHealthResponse, c as GatewayModel, d as GatewayMemoryResponse } from './gateway-C5T5FfCy.js';
2
+ export { t as AIChatRequest, u as AIChatResponse, w as AIGenerateRequest, x as AIGenerateResponse, y as AIMessage, s as AIModel, A as AIProviderConfig, g as ChatConfig, e as ChatModal, h as ChatModalProps, C as ChatProvider, D as DEFAULT_TIER_FEATURES, f as FeatureMatrix, m as GatewayChatRequest, n as GatewayChatResponse, j as GatewayContract, o as GatewayGenerateRequest, p as GatewayGenerateResponse, r as GatewayMemoryRecord, l as GatewayMessage, k as GatewayMessageContent, q as GatewayModelsResponse, O as OSS_DEFAULT_FEATURES, P as PackageSettings, i as VoiceModelsResponse, V as VoiceService, v as voiceService } from './gateway-C5T5FfCy.js';
3
3
  import * as react_jsx_runtime from 'react/jsx-runtime';
4
4
  import React, { ReactNode } from 'react';
5
5
  import * as zustand from 'zustand';
package/dist/index.js CHANGED
@@ -4755,7 +4755,8 @@ var init_gateway_service = __esm({
4755
4755
  index: 0,
4756
4756
  delta: {
4757
4757
  role: parsed.message.role,
4758
- content: parsed.message.content
4758
+ content: parsed.message.content,
4759
+ tool_calls: parsed.message.tool_calls
4759
4760
  },
4760
4761
  finish_reason: parsed.done ? parsed.done_reason || "stop" : null
4761
4762
  }]
@@ -5735,6 +5736,7 @@ var init_gateway_provider = __esm({
5735
5736
  }
5736
5737
  }
5737
5738
  }
5739
+ const toolAwareRequest = request;
5738
5740
  const gatewayRequest = {
5739
5741
  model: request.model,
5740
5742
  messages,
@@ -5743,7 +5745,8 @@ var init_gateway_provider = __esm({
5743
5745
  max_tokens: request.maxTokens,
5744
5746
  provider: this.config.provider,
5745
5747
  // Only include top-level images for Ollama (fallback)
5746
- images: this.config.provider === "ollama" ? request.images : void 0
5748
+ images: this.config.provider === "ollama" ? request.images : void 0,
5749
+ tools: toolAwareRequest.tools?.length ? toolAwareRequest.tools : void 0
5747
5750
  };
5748
5751
  debugLogger.debug("Gateway provider chat request", {
5749
5752
  model: request.model,
@@ -5760,13 +5763,18 @@ var init_gateway_provider = __esm({
5760
5763
  }))
5761
5764
  });
5762
5765
  return this.gatewayService.chat(gatewayRequest).pipe(
5763
- (0, import_rxjs7.map)((response) => ({
5764
- message: {
5765
- content: response.choices?.[0]?.message?.content || response.choices?.[0]?.delta?.content || "",
5766
- role: "assistant"
5767
- },
5768
- done: response.choices?.[0]?.finish_reason === "stop" || response.choices?.[0]?.finish_reason === "length"
5769
- }))
5766
+ (0, import_rxjs7.map)((response) => {
5767
+ const choice = response.choices?.[0];
5768
+ const toolCalls = choice?.message?.tool_calls ?? choice?.delta?.tool_calls;
5769
+ return {
5770
+ message: {
5771
+ content: choice?.message?.content ?? choice?.delta?.content ?? "",
5772
+ role: "assistant",
5773
+ tool_calls: toolCalls
5774
+ },
5775
+ done: choice?.finish_reason === "stop" || choice?.finish_reason === "length" || choice?.finish_reason === "tool_calls"
5776
+ };
5777
+ })
5770
5778
  );
5771
5779
  }
5772
5780
  generate(request) {
@@ -15084,6 +15092,7 @@ var init_chat_messages = __esm({
15084
15092
  scrollTargetRef,
15085
15093
  responseStarted,
15086
15094
  isStreaming,
15095
+ isThinking = false,
15087
15096
  isNetworkSlow = false,
15088
15097
  showInstantFeedback = true,
15089
15098
  selectedModel,
@@ -15100,6 +15109,7 @@ var init_chat_messages = __esm({
15100
15109
  const isLast = index === lastIndex;
15101
15110
  const isPlaceholder = entry.answer === "...";
15102
15111
  const showLoader = isLast && isStreaming && streamBuffer.trim() === "";
15112
+ const showThinking = showLoader && isThinking;
15103
15113
  const content = isLast ? isStreaming ? streamBuffer || "" : isPlaceholder ? "" : entry.answer : entry.answer;
15104
15114
  const rawSources = entry.sourceFiles;
15105
15115
  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;
@@ -15127,11 +15137,27 @@ var init_chat_messages = __esm({
15127
15137
  pointerEvents: showLoader ? "auto" : "none",
15128
15138
  zIndex: showLoader ? 1 : 0
15129
15139
  },
15130
- children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_material9.Box, { sx: { display: "flex", alignItems: "center", minHeight: "40px", pl: 2 }, children: /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "typing-only", children: [
15131
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "dot" }),
15132
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "dot" }),
15133
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "dot" })
15134
- ] }) })
15140
+ children: /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_material9.Box, { sx: { display: "flex", alignItems: "center", gap: 1, minHeight: "40px", pl: 2 }, children: [
15141
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "typing-only", children: [
15142
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "dot" }),
15143
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "dot" }),
15144
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "dot" })
15145
+ ] }),
15146
+ showThinking && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
15147
+ import_material9.Box,
15148
+ {
15149
+ component: "span",
15150
+ sx: {
15151
+ fontSize: "0.75rem",
15152
+ color: "text.secondary",
15153
+ opacity: 0.6,
15154
+ fontStyle: "italic",
15155
+ userSelect: "none"
15156
+ },
15157
+ children: "Thinking\u2026"
15158
+ }
15159
+ )
15160
+ ] })
15135
15161
  }
15136
15162
  ),
15137
15163
  /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
@@ -20012,6 +20038,7 @@ var init_useAIProvider = __esm({
20012
20038
  setIsSubmitting,
20013
20039
  setResponseStarted,
20014
20040
  setIsStreaming,
20041
+ setIsThinking,
20015
20042
  setResponse,
20016
20043
  setPastedImages,
20017
20044
  setPendingMessage,
@@ -20469,6 +20496,12 @@ ${protocol}`;
20469
20496
  let fullMessage = "";
20470
20497
  let latestDisplayMessage = "";
20471
20498
  let sawToolBlock = false;
20499
+ const stripThinking = (text) => {
20500
+ let result = text.replace(/<think>[\s\S]*?<\/think>/g, "");
20501
+ const openIdx = result.indexOf("<think>");
20502
+ if (openIdx !== -1) result = result.slice(0, openIdx);
20503
+ return result.trimStart();
20504
+ };
20472
20505
  const flushNow = () => {
20473
20506
  clearFlushTimer();
20474
20507
  if (!sawToolBlock) {
@@ -20496,13 +20529,16 @@ ${protocol}`;
20496
20529
  }
20497
20530
  const sub = stream.subscribe({
20498
20531
  next: (data) => {
20499
- if (!data?.message?.content) return;
20500
- fullMessage += data.message.content;
20501
- if (/```(?:tool_code|TOOL_CODE)/.test(fullMessage)) {
20532
+ if (!data?.message?.content && !data?.message?.tool_calls) return;
20533
+ if (data.message.content) fullMessage += data.message.content;
20534
+ const inThinkBlock = /<think>/.test(fullMessage) && !/<think>[\s\S]*<\/think>/.test(fullMessage);
20535
+ setIsThinking?.(inThinkBlock);
20536
+ const visibleMessage = stripThinking(fullMessage);
20537
+ if (/```(?:tool_code|TOOL_CODE)/.test(visibleMessage)) {
20502
20538
  sawToolBlock = true;
20503
20539
  clearFlushTimer();
20504
20540
  }
20505
- latestDisplayMessage = fullMessage;
20541
+ latestDisplayMessage = visibleMessage;
20506
20542
  if (!sawToolBlock) {
20507
20543
  scheduleFlush();
20508
20544
  }
@@ -20523,6 +20559,7 @@ ${protocol}`;
20523
20559
  setResponse(partial);
20524
20560
  }
20525
20561
  setStreamBuffer("");
20562
+ setIsThinking?.(false);
20526
20563
  setPendingMessage(null);
20527
20564
  setLogoVisible(false);
20528
20565
  if (onError) {
@@ -20531,7 +20568,8 @@ ${protocol}`;
20531
20568
  },
20532
20569
  complete: async () => {
20533
20570
  try {
20534
- latestDisplayMessage = fullMessage;
20571
+ setIsThinking?.(false);
20572
+ latestDisplayMessage = stripThinking(fullMessage);
20535
20573
  if (!sawToolBlock) {
20536
20574
  flushNow();
20537
20575
  }
@@ -28522,6 +28560,7 @@ var init_chat2 = __esm({
28522
28560
  const [streamBuffer, setStreamBuffer] = (0, import_react35.useState)("");
28523
28561
  const [responseStarted, setResponseStarted] = (0, import_react35.useState)(false);
28524
28562
  const [isStreaming, setIsStreaming] = (0, import_react35.useState)(false);
28563
+ const [isThinking, setIsThinking] = (0, import_react35.useState)(false);
28525
28564
  const initialLogoState = history.length === 0;
28526
28565
  const [logoVisible, setLogoVisible] = (0, import_react35.useState)(initialLogoState);
28527
28566
  const [logoShouldRender, setLogoShouldRender] = (0, import_react35.useState)(initialLogoState);
@@ -29005,6 +29044,7 @@ var init_chat2 = __esm({
29005
29044
  overrideComponentStatus: setComponentStatus,
29006
29045
  setIsSubmitting,
29007
29046
  setIsStreaming,
29047
+ setIsThinking,
29008
29048
  setResponseStarted,
29009
29049
  setResponse,
29010
29050
  setStreamBuffer,
@@ -29411,6 +29451,7 @@ var init_chat2 = __esm({
29411
29451
  chat_messages_default,
29412
29452
  {
29413
29453
  isStreaming,
29454
+ isThinking,
29414
29455
  history,
29415
29456
  pendingMessage,
29416
29457
  streamBuffer,