@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/{chat-GLBQOPNT.mjs → chat-W4HX45DE.mjs} +2 -2
- package/dist/{chunk-7ZHLQXHL.mjs → chunk-E7GT3NR4.mjs} +2 -2
- package/dist/{chunk-LDL4X6CB.mjs → chunk-YBQRVTZF.mjs} +38 -9
- package/dist/chunk-YBQRVTZF.mjs.map +1 -0
- package/dist/index.js +37 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2 -2
- package/dist/management/management.js +37 -8
- package/dist/management/management.js.map +1 -1
- package/dist/management/management.mjs +1 -1
- package/package.json +1 -1
- package/dist/chunk-LDL4X6CB.mjs.map +0 -1
- /package/dist/{chat-GLBQOPNT.mjs.map → chat-W4HX45DE.mjs.map} +0 -0
- /package/dist/{chunk-7ZHLQXHL.mjs.map → chunk-E7GT3NR4.mjs.map} +0 -0
package/dist/index.js
CHANGED
|
@@ -21021,6 +21021,7 @@ ${protocol}`;
|
|
|
21021
21021
|
let latestDisplayMessage = "";
|
|
21022
21022
|
let sawToolBlock = false;
|
|
21023
21023
|
const nativeToolCalls = [];
|
|
21024
|
+
let workingTimer = null;
|
|
21024
21025
|
const stripThinking = (text) => {
|
|
21025
21026
|
let result = text.replace(/<think>[\s\S]*?<\/think>/g, "");
|
|
21026
21027
|
const openIdx = result.indexOf("<think>");
|
|
@@ -21028,6 +21029,28 @@ ${protocol}`;
|
|
|
21028
21029
|
return result.trimStart();
|
|
21029
21030
|
};
|
|
21030
21031
|
const stripToolBlocks = (text) => text.replace(/```(?:tool_code|TOOL_CODE)\s*\n[\s\S]*?\n```/gi, "").trim();
|
|
21032
|
+
let workingLabel = "Working on it";
|
|
21033
|
+
let workingPreamble = "";
|
|
21034
|
+
const stopWorking = () => {
|
|
21035
|
+
if (workingTimer) {
|
|
21036
|
+
clearInterval(workingTimer);
|
|
21037
|
+
workingTimer = null;
|
|
21038
|
+
}
|
|
21039
|
+
};
|
|
21040
|
+
const startWorking = (label = "Working on it") => {
|
|
21041
|
+
workingLabel = label.replace(/[.…]+\s*$/, "").trim() || "Working on it";
|
|
21042
|
+
workingPreamble = stripToolBlocks(stripThinking(fullMessage)).trim();
|
|
21043
|
+
if (workingTimer) return;
|
|
21044
|
+
let dots = 0;
|
|
21045
|
+
const render = () => {
|
|
21046
|
+
dots = (dots + 1) % 4;
|
|
21047
|
+
setStreamBuffer(
|
|
21048
|
+
`${workingPreamble}${workingPreamble ? "\n\n" : ""}_${workingLabel}${".".repeat(dots)}_`
|
|
21049
|
+
);
|
|
21050
|
+
};
|
|
21051
|
+
render();
|
|
21052
|
+
workingTimer = setInterval(render, 450);
|
|
21053
|
+
};
|
|
21031
21054
|
const flushNow = () => {
|
|
21032
21055
|
clearFlushTimer();
|
|
21033
21056
|
if (!sawToolBlock) {
|
|
@@ -21063,6 +21086,7 @@ ${protocol}`;
|
|
|
21063
21086
|
nativeToolCalls.push(...data.message.tool_calls);
|
|
21064
21087
|
sawToolBlock = true;
|
|
21065
21088
|
clearFlushTimer();
|
|
21089
|
+
startWorking();
|
|
21066
21090
|
}
|
|
21067
21091
|
if (data.message.content) {
|
|
21068
21092
|
fullMessage += data.message.content;
|
|
@@ -21074,6 +21098,7 @@ ${protocol}`;
|
|
|
21074
21098
|
if (/```(?:tool_code|TOOL_CODE)/.test(visibleMessage)) {
|
|
21075
21099
|
sawToolBlock = true;
|
|
21076
21100
|
clearFlushTimer();
|
|
21101
|
+
startWorking();
|
|
21077
21102
|
}
|
|
21078
21103
|
latestDisplayMessage = visibleMessage;
|
|
21079
21104
|
if (!sawToolBlock) {
|
|
@@ -21082,6 +21107,7 @@ ${protocol}`;
|
|
|
21082
21107
|
},
|
|
21083
21108
|
error: (err) => {
|
|
21084
21109
|
debugLogger.error("Stream error:", err);
|
|
21110
|
+
stopWorking();
|
|
21085
21111
|
overrideComponentStatus("Idle");
|
|
21086
21112
|
setIsSubmitting(false);
|
|
21087
21113
|
setIsStreaming(false);
|
|
@@ -21166,6 +21192,7 @@ ${fn}(${argStr})
|
|
|
21166
21192
|
if (functionName === "ask_user" || functionName === "ask-user") {
|
|
21167
21193
|
enhancedMessage = enhancedMessage.replace(match, "");
|
|
21168
21194
|
clearFlushTimer();
|
|
21195
|
+
stopWorking();
|
|
21169
21196
|
const askPreamble = stripToolBlocks(fullMessage).trim();
|
|
21170
21197
|
setStreamBuffer(askPreamble || "_Waiting for your answer\u2026_");
|
|
21171
21198
|
const questions = parseAskUserQuestions(
|
|
@@ -21188,11 +21215,8 @@ A: ${(answers[q.id] || "").trim() || "(no answer)"}`).join("\n\n") : "The user d
|
|
|
21188
21215
|
const placeholderToken = `<<TOOL_LOADING_${functionName}_${Math.random().toString(36).slice(2)}>>`;
|
|
21189
21216
|
enhancedMessage = enhancedMessage.replace(match, placeholderToken);
|
|
21190
21217
|
clearFlushTimer();
|
|
21191
|
-
const toolStatus = functionName === "web_search" || functionName === "web-search" ? "Searching the web
|
|
21192
|
-
|
|
21193
|
-
setStreamBuffer(toolPreamble ? `${toolPreamble}
|
|
21194
|
-
|
|
21195
|
-
_${toolStatus}_` : `_${toolStatus}_`);
|
|
21218
|
+
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";
|
|
21219
|
+
startWorking(toolStatus);
|
|
21196
21220
|
telemetryEvent("tool_loop:tool_execute", { name: functionName, params: parsedParams });
|
|
21197
21221
|
const result = await executeMCPTool({
|
|
21198
21222
|
toolName: functionName,
|
|
@@ -21343,7 +21367,10 @@ Use them to fully complete my original request. If you still need to take an act
|
|
|
21343
21367
|
const visible = stripThinking(acc);
|
|
21344
21368
|
latestDisplayMessage = visible;
|
|
21345
21369
|
lastPartialRef.current.text = visible;
|
|
21346
|
-
if (visible)
|
|
21370
|
+
if (visible) {
|
|
21371
|
+
stopWorking();
|
|
21372
|
+
setIsThinking?.(false);
|
|
21373
|
+
}
|
|
21347
21374
|
setStreamBuffer(visible);
|
|
21348
21375
|
}
|
|
21349
21376
|
},
|
|
@@ -21367,8 +21394,8 @@ Use them to fully complete my original request. If you still need to take an act
|
|
|
21367
21394
|
return ans ? "The user answered:\n\n" + qs.map((q) => `Q: ${q.question}
|
|
21368
21395
|
A: ${(ans[q.id] || "").trim() || "(no answer)"}`).join("\n\n") : "The user dismissed the question(s). Proceed with your best judgment.";
|
|
21369
21396
|
}
|
|
21370
|
-
const status = fn === "create_file" || fn === "create-file" ? "Creating
|
|
21371
|
-
|
|
21397
|
+
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";
|
|
21398
|
+
startWorking(status);
|
|
21372
21399
|
const result = await executeMCPTool({ toolName: fn, parameters: params });
|
|
21373
21400
|
if (!result.success) return `That step failed: ${result.error || "unknown error"}.`;
|
|
21374
21401
|
if (fn === "create_file" || fn === "create-file") {
|
|
@@ -21398,6 +21425,7 @@ _This link is temporary and expires in about ${mins} minutes._`);
|
|
|
21398
21425
|
let finalText = "";
|
|
21399
21426
|
let lastTurnText = "";
|
|
21400
21427
|
for (let round = 0; round < MAX_CHAIN_ROUNDS; round++) {
|
|
21428
|
+
stopWorking();
|
|
21401
21429
|
setStreamBuffer("");
|
|
21402
21430
|
setIsThinking?.(true);
|
|
21403
21431
|
const turnRequest = {
|
|
@@ -21491,6 +21519,7 @@ ${inlineImageBlocks.join("\n\n")}` : "");
|
|
|
21491
21519
|
}
|
|
21492
21520
|
}
|
|
21493
21521
|
}
|
|
21522
|
+
stopWorking();
|
|
21494
21523
|
overrideComponentStatus("Idle");
|
|
21495
21524
|
setIsSubmitting(false);
|
|
21496
21525
|
setPreviousQuestion(question);
|