@burtson-labs/bandit-engine 2.0.72 → 2.0.73

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,6 +1,6 @@
1
1
  import {
2
2
  chat_default
3
- } from "./chunk-LDL4X6CB.mjs";
3
+ } from "./chunk-YBQRVTZF.mjs";
4
4
  import {
5
5
  chat_provider_default
6
6
  } from "./chunk-SXLI47FV.mjs";
@@ -10,7 +10,7 @@ import {
10
10
  useGatewayHealth,
11
11
  useGatewayMemory,
12
12
  useGatewayModels
13
- } from "./chunk-7ZHLQXHL.mjs";
13
+ } from "./chunk-E7GT3NR4.mjs";
14
14
  import "./chunk-U633CJBV.mjs";
15
15
  import "./chunk-6ITUH375.mjs";
16
16
  import "./chunk-DHYP4K5O.mjs";
@@ -23260,6 +23260,7 @@ ${protocol}`;
23260
23260
  let latestDisplayMessage = "";
23261
23261
  let sawToolBlock = false;
23262
23262
  const nativeToolCalls = [];
23263
+ let workingTimer = null;
23263
23264
  const stripThinking = (text) => {
23264
23265
  let result = text.replace(/<think>[\s\S]*?<\/think>/g, "");
23265
23266
  const openIdx = result.indexOf("<think>");
@@ -23267,6 +23268,28 @@ ${protocol}`;
23267
23268
  return result.trimStart();
23268
23269
  };
23269
23270
  const stripToolBlocks = (text) => text.replace(/```(?:tool_code|TOOL_CODE)\s*\n[\s\S]*?\n```/gi, "").trim();
23271
+ let workingLabel = "Working on it";
23272
+ let workingPreamble = "";
23273
+ const stopWorking = () => {
23274
+ if (workingTimer) {
23275
+ clearInterval(workingTimer);
23276
+ workingTimer = null;
23277
+ }
23278
+ };
23279
+ const startWorking = (label = "Working on it") => {
23280
+ workingLabel = label.replace(/[.…]+\s*$/, "").trim() || "Working on it";
23281
+ workingPreamble = stripToolBlocks(stripThinking(fullMessage)).trim();
23282
+ if (workingTimer) return;
23283
+ let dots = 0;
23284
+ const render = () => {
23285
+ dots = (dots + 1) % 4;
23286
+ setStreamBuffer(
23287
+ `${workingPreamble}${workingPreamble ? "\n\n" : ""}_${workingLabel}${".".repeat(dots)}_`
23288
+ );
23289
+ };
23290
+ render();
23291
+ workingTimer = setInterval(render, 450);
23292
+ };
23270
23293
  const flushNow = () => {
23271
23294
  clearFlushTimer();
23272
23295
  if (!sawToolBlock) {
@@ -23302,6 +23325,7 @@ ${protocol}`;
23302
23325
  nativeToolCalls.push(...data.message.tool_calls);
23303
23326
  sawToolBlock = true;
23304
23327
  clearFlushTimer();
23328
+ startWorking();
23305
23329
  }
23306
23330
  if (data.message.content) {
23307
23331
  fullMessage += data.message.content;
@@ -23313,6 +23337,7 @@ ${protocol}`;
23313
23337
  if (/```(?:tool_code|TOOL_CODE)/.test(visibleMessage)) {
23314
23338
  sawToolBlock = true;
23315
23339
  clearFlushTimer();
23340
+ startWorking();
23316
23341
  }
23317
23342
  latestDisplayMessage = visibleMessage;
23318
23343
  if (!sawToolBlock) {
@@ -23321,6 +23346,7 @@ ${protocol}`;
23321
23346
  },
23322
23347
  error: (err) => {
23323
23348
  debugLogger.error("Stream error:", err);
23349
+ stopWorking();
23324
23350
  overrideComponentStatus("Idle");
23325
23351
  setIsSubmitting(false);
23326
23352
  setIsStreaming(false);
@@ -23405,6 +23431,7 @@ ${fn}(${argStr})
23405
23431
  if (functionName === "ask_user" || functionName === "ask-user") {
23406
23432
  enhancedMessage = enhancedMessage.replace(match, "");
23407
23433
  clearFlushTimer();
23434
+ stopWorking();
23408
23435
  const askPreamble = stripToolBlocks(fullMessage).trim();
23409
23436
  setStreamBuffer(askPreamble || "_Waiting for your answer\u2026_");
23410
23437
  const questions = parseAskUserQuestions(
@@ -23427,11 +23454,8 @@ A: ${(answers[q.id] || "").trim() || "(no answer)"}`).join("\n\n") : "The user d
23427
23454
  const placeholderToken = `<<TOOL_LOADING_${functionName}_${Math.random().toString(36).slice(2)}>>`;
23428
23455
  enhancedMessage = enhancedMessage.replace(match, placeholderToken);
23429
23456
  clearFlushTimer();
23430
- const toolStatus = functionName === "web_search" || functionName === "web-search" ? "Searching the web\u2026" : functionName === "web_fetch" || functionName === "web-fetch" ? "Reading the page\u2026" : functionName === "image_generation" || functionName === "image-generation" ? "Generating the image\u2026" : "Working on it\u2026";
23431
- const toolPreamble = stripToolBlocks(fullMessage).trim();
23432
- setStreamBuffer(toolPreamble ? `${toolPreamble}
23433
-
23434
- _${toolStatus}_` : `_${toolStatus}_`);
23457
+ const toolStatus = functionName === "web_search" || functionName === "web-search" ? "Searching the web" : functionName === "web_fetch" || functionName === "web-fetch" ? "Reading the page" : functionName === "image_generation" || functionName === "image-generation" ? "Generating the image" : functionName === "create_file" || functionName === "create-file" ? "Creating your file" : "Working on it";
23458
+ startWorking(toolStatus);
23435
23459
  telemetryEvent("tool_loop:tool_execute", { name: functionName, params: parsedParams });
23436
23460
  const result = await executeMCPTool({
23437
23461
  toolName: functionName,
@@ -23582,7 +23606,10 @@ Use them to fully complete my original request. If you still need to take an act
23582
23606
  const visible = stripThinking(acc);
23583
23607
  latestDisplayMessage = visible;
23584
23608
  lastPartialRef.current.text = visible;
23585
- if (visible) setIsThinking?.(false);
23609
+ if (visible) {
23610
+ stopWorking();
23611
+ setIsThinking?.(false);
23612
+ }
23586
23613
  setStreamBuffer(visible);
23587
23614
  }
23588
23615
  },
@@ -23606,8 +23633,8 @@ Use them to fully complete my original request. If you still need to take an act
23606
23633
  return ans ? "The user answered:\n\n" + qs.map((q) => `Q: ${q.question}
23607
23634
  A: ${(ans[q.id] || "").trim() || "(no answer)"}`).join("\n\n") : "The user dismissed the question(s). Proceed with your best judgment.";
23608
23635
  }
23609
- const status = fn === "create_file" || fn === "create-file" ? "Creating the file\u2026" : fn === "web_search" || fn === "web-search" ? "Searching the web\u2026" : fn === "web_fetch" || fn === "web-fetch" ? "Reading the page\u2026" : fn === "image_generation" || fn === "image-generation" ? "Generating the image\u2026" : "Working on it\u2026";
23610
- setStreamBuffer(`_${status}_`);
23636
+ const status = fn === "create_file" || fn === "create-file" ? "Creating your file" : fn === "web_search" || fn === "web-search" ? "Searching the web" : fn === "web_fetch" || fn === "web-fetch" ? "Reading the page" : fn === "image_generation" || fn === "image-generation" ? "Generating the image" : "Working on it";
23637
+ startWorking(status);
23611
23638
  const result = await executeMCPTool({ toolName: fn, parameters: params });
23612
23639
  if (!result.success) return `That step failed: ${result.error || "unknown error"}.`;
23613
23640
  if (fn === "create_file" || fn === "create-file") {
@@ -23637,6 +23664,7 @@ _This link is temporary and expires in about ${mins} minutes._`);
23637
23664
  let finalText = "";
23638
23665
  let lastTurnText = "";
23639
23666
  for (let round = 0; round < MAX_CHAIN_ROUNDS; round++) {
23667
+ stopWorking();
23640
23668
  setStreamBuffer("");
23641
23669
  setIsThinking?.(true);
23642
23670
  const turnRequest = {
@@ -23730,6 +23758,7 @@ ${inlineImageBlocks.join("\n\n")}` : "");
23730
23758
  }
23731
23759
  }
23732
23760
  }
23761
+ stopWorking();
23733
23762
  overrideComponentStatus("Idle");
23734
23763
  setIsSubmitting(false);
23735
23764
  setPreviousQuestion(question);