@burtson-labs/bandit-engine 2.0.148 → 2.0.149

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.
@@ -9811,7 +9811,7 @@ var MCPToolsTabV2_default = MCPToolsTabV2;
9811
9811
 
9812
9812
  // src/management/management.tsx
9813
9813
  import { jsx as jsx14, jsxs as jsxs14 } from "react/jsx-runtime";
9814
- var preloadChatPage = () => import("./chat-N2KBORSG.mjs");
9814
+ var preloadChatPage = () => import("./chat-Z4SQGSMN.mjs");
9815
9815
  var buildCapabilitiesUrl = (gatewayApiUrl) => {
9816
9816
  const trimmed = gatewayApiUrl.replace(/\/$/, "");
9817
9817
  if (trimmed.endsWith("/api")) {
@@ -11184,4 +11184,4 @@ export {
11184
11184
  useGatewayMemory,
11185
11185
  management_default
11186
11186
  };
11187
- //# sourceMappingURL=chunk-3ADU3BFL.mjs.map
11187
+ //# sourceMappingURL=chunk-JQSZNGII.mjs.map
package/dist/index.js CHANGED
@@ -20990,6 +20990,10 @@ ${protocol}`;
20990
20990
  /\b(?:web_search|web_fetch|image_generation|create_file|ask_user)\s*\(/
20991
20991
  );
20992
20992
  if (callIdx !== -1) t = t.slice(0, callIdx);
20993
+ const jsonIdx = t.search(
20994
+ /\{\s*"name"\s*:\s*"(?:web_search|web_fetch|image_generation|create_file|ask_user)"/
20995
+ );
20996
+ if (jsonIdx !== -1) t = t.slice(0, jsonIdx);
20993
20997
  t = t.replace(/```[\w-]*\s*$/, "");
20994
20998
  const fenceCount = (t.match(/```/g) || []).length;
20995
20999
  if (fenceCount % 2 === 1) t = t.slice(0, t.lastIndexOf("```"));
@@ -21055,6 +21059,9 @@ ${protocol}`;
21055
21059
  const visibleMessage = stripThinking(fullMessage);
21056
21060
  const bareToolMatch = visibleMessage.match(
21057
21061
  /\b(web_search|web_fetch|image_generation|create_file|ask_user)\s*\(/
21062
+ ) || // JSON-form calls from cloud/native-tool engines.
21063
+ visibleMessage.match(
21064
+ /\{\s*"name"\s*:\s*"(web_search|web_fetch|image_generation|create_file|ask_user)"/
21058
21065
  );
21059
21066
  if (/```(?:tool_code|TOOL_CODE)/.test(visibleMessage) || bareToolMatch) {
21060
21067
  sawToolBlock = true;
@@ -21182,6 +21189,70 @@ ${fn}(${argStr})
21182
21189
  }
21183
21190
  return out;
21184
21191
  };
21192
+ const bridgeJsonToolBlobs = (message) => {
21193
+ const KNOWN = ["web_search", "web_fetch", "image_generation", "create_file", "ask_user", "ask-user"];
21194
+ const re = new RegExp(`\\{\\s*"name"\\s*:\\s*"(${KNOWN.join("|")})"`, "g");
21195
+ const spans = [];
21196
+ let m;
21197
+ while ((m = re.exec(message)) !== null) {
21198
+ let depth = 0;
21199
+ let i = m.index;
21200
+ let inStr = false;
21201
+ let esc = false;
21202
+ for (; i < message.length; i++) {
21203
+ const ch = message[i];
21204
+ if (esc) {
21205
+ esc = false;
21206
+ continue;
21207
+ }
21208
+ if (ch === "\\") {
21209
+ esc = true;
21210
+ continue;
21211
+ }
21212
+ if (ch === '"') {
21213
+ inStr = !inStr;
21214
+ continue;
21215
+ }
21216
+ if (inStr) continue;
21217
+ if (ch === "{") depth++;
21218
+ else if (ch === "}") {
21219
+ depth--;
21220
+ if (depth === 0) {
21221
+ i++;
21222
+ break;
21223
+ }
21224
+ }
21225
+ }
21226
+ const blob = message.slice(m.index, i);
21227
+ try {
21228
+ const parsed = JSON.parse(blob);
21229
+ const args = parsed.arguments ?? parsed.parameters ?? parsed.input ?? {};
21230
+ let start = m.index;
21231
+ let end = i;
21232
+ const fenceOpen = message.slice(0, start).match(/```[a-zA-Z0-9_-]*[ \t]*\n[ \t]*$/);
21233
+ if (fenceOpen) {
21234
+ start -= fenceOpen[0].length;
21235
+ const fenceClose = message.slice(end).match(/^[ \t]*\n?```/);
21236
+ if (fenceClose) end += fenceClose[0].length;
21237
+ }
21238
+ spans.push({
21239
+ start,
21240
+ end,
21241
+ fn: parsed.name,
21242
+ args: typeof args === "string" ? args : JSON.stringify(args)
21243
+ });
21244
+ } catch {
21245
+ }
21246
+ re.lastIndex = i;
21247
+ }
21248
+ let result = message;
21249
+ for (let k = spans.length - 1; k >= 0; k--) {
21250
+ const s = spans[k];
21251
+ result = result.slice(0, s.start) + "\n```tool_code\n" + s.fn + "(" + s.args + ")\n```\n" + result.slice(s.end);
21252
+ }
21253
+ return result;
21254
+ };
21255
+ fullMessage = bridgeJsonToolBlobs(fullMessage);
21185
21256
  const toolCallMatches = extractToolCalls(fullMessage);
21186
21257
  let enhancedMessage = fullMessage;
21187
21258
  const summarizableResults = [];