@burtson-labs/bandit-engine 2.0.61 → 2.0.62

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.mjs CHANGED
@@ -1,22 +1,22 @@
1
1
  import {
2
2
  chat_default
3
- } from "./chunk-G7U2FNUK.mjs";
3
+ } from "./chunk-Y4NDNAAR.mjs";
4
4
  import {
5
5
  chat_provider_default
6
6
  } from "./chunk-D55E6ZDV.mjs";
7
7
  import "./chunk-ONQMRE2G.mjs";
8
- import {
9
- defineCustomElement
10
- } from "./chunk-IXIM7BNO.mjs";
11
8
  import {
12
9
  management_default,
13
10
  useGatewayHealth,
14
11
  useGatewayMemory,
15
12
  useGatewayModels
16
- } from "./chunk-SKMJ43NN.mjs";
13
+ } from "./chunk-O7JGT7HR.mjs";
17
14
  import "./chunk-SRCCNBHF.mjs";
18
15
  import "./chunk-VTC6AIWY.mjs";
19
16
  import "./chunk-6QTTNYF2.mjs";
17
+ import {
18
+ defineCustomElement
19
+ } from "./chunk-IXIM7BNO.mjs";
20
20
  import {
21
21
  chat_modal_default
22
22
  } from "./chunk-PY7A3J5T.mjs";
@@ -23216,6 +23216,7 @@ ${protocol}`;
23216
23216
  let fullMessage = "";
23217
23217
  let latestDisplayMessage = "";
23218
23218
  let sawToolBlock = false;
23219
+ const nativeToolCalls = [];
23219
23220
  const stripThinking = (text) => {
23220
23221
  let result = text.replace(/<think>[\s\S]*?<\/think>/g, "");
23221
23222
  const openIdx = result.indexOf("<think>");
@@ -23254,6 +23255,11 @@ ${protocol}`;
23254
23255
  const sub = stream.subscribe({
23255
23256
  next: (data) => {
23256
23257
  if (!data?.message?.content && !data?.message?.tool_calls) return;
23258
+ if (Array.isArray(data.message.tool_calls) && data.message.tool_calls.length > 0) {
23259
+ nativeToolCalls.push(...data.message.tool_calls);
23260
+ sawToolBlock = true;
23261
+ clearFlushTimer();
23262
+ }
23257
23263
  if (data.message.content) {
23258
23264
  fullMessage += data.message.content;
23259
23265
  telemetryEvent("tool_loop:llm_chunk", { chunk: data.message.content });
@@ -23302,6 +23308,20 @@ ${protocol}`;
23302
23308
  if (!sawToolBlock) {
23303
23309
  flushNow();
23304
23310
  }
23311
+ if (nativeToolCalls.length > 0 && !/```(?:tool_code|TOOL_CODE)/.test(fullMessage)) {
23312
+ for (const raw of nativeToolCalls) {
23313
+ const tc = raw;
23314
+ const fn = tc.function?.name ?? tc.name;
23315
+ if (!fn) continue;
23316
+ const rawArgs = tc.function?.arguments ?? tc.arguments ?? {};
23317
+ const argStr = typeof rawArgs === "string" ? rawArgs : JSON.stringify(rawArgs ?? {});
23318
+ fullMessage += `
23319
+
23320
+ \`\`\`tool_code
23321
+ ${fn}(${argStr})
23322
+ \`\`\``;
23323
+ }
23324
+ }
23305
23325
  const toolCallMatches = fullMessage.match(/```(?:tool_code|TOOL_CODE)\s*\n([^`]+)\n```/gi);
23306
23326
  let enhancedMessage = fullMessage;
23307
23327
  const summarizableResults = [];
@@ -27249,8 +27269,10 @@ var init_chat_app_bar = __esm({
27249
27269
  const engines = useEngineStore((s) => s.engines);
27250
27270
  const selectedEngine = useEngineStore((s) => s.selectedEngine);
27251
27271
  const effectiveEngineId = selectedEngine || usePackageSettingsStore.getState().settings?.defaultModel || "bandit-core";
27252
- const currentEngine = engines.find((e) => e.id === effectiveEngineId);
27253
- const engineLabel = currentEngine?.displayName?.replace(/^Bandit /, "") || "Engine";
27272
+ const currentEngine = engines.find((e) => e.id === effectiveEngineId) || engines.find((e) => effectiveEngineId.startsWith(e.id + ":"));
27273
+ const resolvedEngineId = currentEngine?.id ?? effectiveEngineId;
27274
+ const cleanEngineName = (name) => (name || "").replace(/\s*\([^)]*\)\s*$/, "").trim();
27275
+ const engineDisplay = cleanEngineName(currentEngine?.displayName) || "Engine";
27254
27276
  (0, import_react53.useEffect)(() => {
27255
27277
  useEngineStore.getState().fetchEngines();
27256
27278
  }, []);
@@ -27566,16 +27588,13 @@ var init_chat_app_bar = __esm({
27566
27588
  )
27567
27589
  }
27568
27590
  ) }),
27569
- /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(import_material43.Tooltip, { title: `Engine: ${currentEngine?.displayName ?? effectiveEngineId}`, arrow: true, children: /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)(
27591
+ /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(import_material43.Tooltip, { title: `Engine \xB7 ${engineDisplay}`, arrow: true, children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
27570
27592
  import_material43.IconButton,
27571
27593
  {
27572
27594
  onClick: (e) => setEngineAnchorEl(e.currentTarget),
27573
27595
  sx: pillButtonStyles,
27574
- "aria-label": `Change base model (engine). Currently ${effectiveEngineId}`,
27575
- children: [
27576
- currentEngine?.cloud ? /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(CloudDoneIcon, { fontSize: "small" }) : /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(CloudOffIcon, { fontSize: "small" }),
27577
- /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(import_material43.Typography, { variant: "caption", sx: { ml: 0.75, fontWeight: 600, whiteSpace: "nowrap" }, children: engineLabel })
27578
- ]
27596
+ "aria-label": `Change base model (engine). Currently ${engineDisplay}`,
27597
+ children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(PsychologyIcon, { fontSize: "small" })
27579
27598
  }
27580
27599
  ) }),
27581
27600
  /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)(
@@ -27599,7 +27618,7 @@ var init_chat_app_bar = __esm({
27599
27618
  return /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)(
27600
27619
  import_material43.MenuItem,
27601
27620
  {
27602
- selected: engine.id === effectiveEngineId,
27621
+ selected: engine.id === resolvedEngineId,
27603
27622
  disabled: !engine.available,
27604
27623
  onClick: () => {
27605
27624
  useEngineStore.getState().setSelectedEngine(engine.id);
@@ -27617,8 +27636,8 @@ var init_chat_app_bar = __esm({
27617
27636
  },
27618
27637
  children: [
27619
27638
  /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)(import_material43.Box, { sx: { display: "flex", alignItems: "center", gap: 1, width: "100%" }, children: [
27620
- /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(import_material43.Typography, { variant: "body2", sx: { fontWeight: 600, flex: 1 }, children: engine.displayName }),
27621
- engine.id === effectiveEngineId && /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(import_material43.Box, { sx: { width: 8, height: 8, borderRadius: "50%", bgcolor: theme.palette.primary.main } })
27639
+ /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(import_material43.Typography, { variant: "body2", sx: { fontWeight: 600, flex: 1 }, children: cleanEngineName(engine.displayName) }),
27640
+ engine.id === resolvedEngineId && /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(import_material43.Box, { sx: { width: 8, height: 8, borderRadius: "50%", bgcolor: theme.palette.primary.main } })
27622
27641
  ] }),
27623
27642
  /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(import_material43.Typography, { variant: "caption", sx: { color: theme.palette.text.secondary }, children: engine.available ? engine.description : engine.unavailableReason || "Unavailable" }),
27624
27643
  badges.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(import_material43.Box, { sx: { display: "flex", gap: 0.5, flexWrap: "wrap", mt: 0.25 }, children: badges.map((b) => /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(