@burtson-labs/bandit-engine 2.0.58 → 2.0.59

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-N7GCS2BH.mjs";
3
+ } from "./chunk-V5QRXIIO.mjs";
4
4
  import {
5
5
  chat_provider_default
6
6
  } from "./chunk-POTQI33D.mjs";
@@ -10,7 +10,7 @@ import {
10
10
  useGatewayHealth,
11
11
  useGatewayMemory,
12
12
  useGatewayModels
13
- } from "./chunk-VU5N57QZ.mjs";
13
+ } from "./chunk-URKUD3OL.mjs";
14
14
  import "./chunk-KM7FUWCM.mjs";
15
15
  import "./chunk-UFSEYVRS.mjs";
16
16
  import "./chunk-QPBG6JQE.mjs";
@@ -22009,7 +22009,14 @@ var init_mcpService = __esm({
22009
22009
  requestOptions.body = JSON.stringify(toolCall.parameters);
22010
22010
  }
22011
22011
  }
22012
- const response = await fetch(url, requestOptions);
22012
+ const controller = new AbortController();
22013
+ const timeoutId = setTimeout(() => controller.abort(), 3e4);
22014
+ let response;
22015
+ try {
22016
+ response = await fetch(url, { ...requestOptions, signal: controller.signal });
22017
+ } finally {
22018
+ clearTimeout(timeoutId);
22019
+ }
22013
22020
  const data = await response.json();
22014
22021
  if (!response.ok) {
22015
22022
  debugLogger.error("MCP tool execution failed", {
@@ -23058,9 +23065,22 @@ Using these results together with your own knowledge, answer my original questio
23058
23065
  options: { num_predict: tokenLimit + 250 }
23059
23066
  };
23060
23067
  clearFlushTimer();
23061
- setStreamBuffer("");
23068
+ const summaryPreamble = stripToolBlocks(fullMessage).trim();
23069
+ setStreamBuffer(
23070
+ summaryPreamble ? `${summaryPreamble}
23071
+
23072
+ _Working on it\u2026_` : "_Working on it\u2026_"
23073
+ );
23062
23074
  const summaryText = await new Promise((resolve) => {
23063
23075
  let acc = "";
23076
+ let settled = false;
23077
+ let timer;
23078
+ const done = (value) => {
23079
+ if (settled) return;
23080
+ settled = true;
23081
+ if (timer) clearTimeout(timer);
23082
+ resolve(value);
23083
+ };
23064
23084
  const summarySub = provider.chat(summaryRequest).subscribe({
23065
23085
  next: (data) => {
23066
23086
  if (data?.message?.content) {
@@ -23075,11 +23095,19 @@ Using these results together with your own knowledge, answer my original questio
23075
23095
  debugLogger.error("Summarization pass failed", {
23076
23096
  error: summaryErr instanceof Error ? summaryErr.message : String(summaryErr)
23077
23097
  });
23078
- resolve("");
23098
+ done("");
23079
23099
  },
23080
- complete: () => resolve(stripThinking(acc).trim())
23100
+ complete: () => done(stripThinking(acc).trim())
23081
23101
  });
23082
23102
  currentSubRef.current = summarySub;
23103
+ timer = setTimeout(() => {
23104
+ debugLogger.warn("Summarization pass timed out; using inline tool output");
23105
+ try {
23106
+ summarySub.unsubscribe();
23107
+ } catch {
23108
+ }
23109
+ done("");
23110
+ }, 3e4);
23083
23111
  });
23084
23112
  if (summaryText.trim()) {
23085
23113
  enhancedMessage = summaryText + (inlineImageBlocks.length ? `