@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.js CHANGED
@@ -19770,7 +19770,14 @@ var init_mcpService = __esm({
19770
19770
  requestOptions.body = JSON.stringify(toolCall.parameters);
19771
19771
  }
19772
19772
  }
19773
- const response = await fetch(url, requestOptions);
19773
+ const controller = new AbortController();
19774
+ const timeoutId = setTimeout(() => controller.abort(), 3e4);
19775
+ let response;
19776
+ try {
19777
+ response = await fetch(url, { ...requestOptions, signal: controller.signal });
19778
+ } finally {
19779
+ clearTimeout(timeoutId);
19780
+ }
19774
19781
  const data = await response.json();
19775
19782
  if (!response.ok) {
19776
19783
  debugLogger.error("MCP tool execution failed", {
@@ -20819,9 +20826,22 @@ Using these results together with your own knowledge, answer my original questio
20819
20826
  options: { num_predict: tokenLimit + 250 }
20820
20827
  };
20821
20828
  clearFlushTimer();
20822
- setStreamBuffer("");
20829
+ const summaryPreamble = stripToolBlocks(fullMessage).trim();
20830
+ setStreamBuffer(
20831
+ summaryPreamble ? `${summaryPreamble}
20832
+
20833
+ _Working on it\u2026_` : "_Working on it\u2026_"
20834
+ );
20823
20835
  const summaryText = await new Promise((resolve) => {
20824
20836
  let acc = "";
20837
+ let settled = false;
20838
+ let timer;
20839
+ const done = (value) => {
20840
+ if (settled) return;
20841
+ settled = true;
20842
+ if (timer) clearTimeout(timer);
20843
+ resolve(value);
20844
+ };
20825
20845
  const summarySub = provider.chat(summaryRequest).subscribe({
20826
20846
  next: (data) => {
20827
20847
  if (data?.message?.content) {
@@ -20836,11 +20856,19 @@ Using these results together with your own knowledge, answer my original questio
20836
20856
  debugLogger.error("Summarization pass failed", {
20837
20857
  error: summaryErr instanceof Error ? summaryErr.message : String(summaryErr)
20838
20858
  });
20839
- resolve("");
20859
+ done("");
20840
20860
  },
20841
- complete: () => resolve(stripThinking(acc).trim())
20861
+ complete: () => done(stripThinking(acc).trim())
20842
20862
  });
20843
20863
  currentSubRef.current = summarySub;
20864
+ timer = setTimeout(() => {
20865
+ debugLogger.warn("Summarization pass timed out; using inline tool output");
20866
+ try {
20867
+ summarySub.unsubscribe();
20868
+ } catch {
20869
+ }
20870
+ done("");
20871
+ }, 3e4);
20844
20872
  });
20845
20873
  if (summaryText.trim()) {
20846
20874
  enhancedMessage = summaryText + (inlineImageBlocks.length ? `