@burtson-labs/bandit-engine 2.0.72 → 2.0.74
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-3JIZRRCI.mjs} +4 -4
- package/dist/chunk-3JIZRRCI.mjs.map +1 -0
- package/dist/{chunk-LDL4X6CB.mjs → chunk-YBQRVTZF.mjs} +38 -9
- package/dist/chunk-YBQRVTZF.mjs.map +1 -0
- package/dist/index.js +39 -10
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2 -2
- package/dist/management/management.js +39 -10
- package/dist/management/management.js.map +1 -1
- package/dist/management/management.mjs +1 -1
- package/package.json +1 -1
- package/dist/chunk-7ZHLQXHL.mjs.map +0 -1
- package/dist/chunk-LDL4X6CB.mjs.map +0 -1
- /package/dist/{chat-GLBQOPNT.mjs.map → chat-W4HX45DE.mjs.map} +0 -0
|
@@ -3341,6 +3341,7 @@ ${protocol}`;
|
|
|
3341
3341
|
let latestDisplayMessage = "";
|
|
3342
3342
|
let sawToolBlock = false;
|
|
3343
3343
|
const nativeToolCalls = [];
|
|
3344
|
+
let workingTimer = null;
|
|
3344
3345
|
const stripThinking = (text) => {
|
|
3345
3346
|
let result = text.replace(/<think>[\s\S]*?<\/think>/g, "");
|
|
3346
3347
|
const openIdx = result.indexOf("<think>");
|
|
@@ -3348,6 +3349,28 @@ ${protocol}`;
|
|
|
3348
3349
|
return result.trimStart();
|
|
3349
3350
|
};
|
|
3350
3351
|
const stripToolBlocks = (text) => text.replace(/```(?:tool_code|TOOL_CODE)\s*\n[\s\S]*?\n```/gi, "").trim();
|
|
3352
|
+
let workingLabel = "Working on it";
|
|
3353
|
+
let workingPreamble = "";
|
|
3354
|
+
const stopWorking = () => {
|
|
3355
|
+
if (workingTimer) {
|
|
3356
|
+
clearInterval(workingTimer);
|
|
3357
|
+
workingTimer = null;
|
|
3358
|
+
}
|
|
3359
|
+
};
|
|
3360
|
+
const startWorking = (label = "Working on it") => {
|
|
3361
|
+
workingLabel = label.replace(/[.…]+\s*$/, "").trim() || "Working on it";
|
|
3362
|
+
workingPreamble = stripToolBlocks(stripThinking(fullMessage)).trim();
|
|
3363
|
+
if (workingTimer) return;
|
|
3364
|
+
let dots = 0;
|
|
3365
|
+
const render = () => {
|
|
3366
|
+
dots = (dots + 1) % 4;
|
|
3367
|
+
setStreamBuffer(
|
|
3368
|
+
`${workingPreamble}${workingPreamble ? "\n\n" : ""}_${workingLabel}${".".repeat(dots)}_`
|
|
3369
|
+
);
|
|
3370
|
+
};
|
|
3371
|
+
render();
|
|
3372
|
+
workingTimer = setInterval(render, 450);
|
|
3373
|
+
};
|
|
3351
3374
|
const flushNow = () => {
|
|
3352
3375
|
clearFlushTimer();
|
|
3353
3376
|
if (!sawToolBlock) {
|
|
@@ -3383,6 +3406,7 @@ ${protocol}`;
|
|
|
3383
3406
|
nativeToolCalls.push(...data.message.tool_calls);
|
|
3384
3407
|
sawToolBlock = true;
|
|
3385
3408
|
clearFlushTimer();
|
|
3409
|
+
startWorking();
|
|
3386
3410
|
}
|
|
3387
3411
|
if (data.message.content) {
|
|
3388
3412
|
fullMessage += data.message.content;
|
|
@@ -3394,6 +3418,7 @@ ${protocol}`;
|
|
|
3394
3418
|
if (/```(?:tool_code|TOOL_CODE)/.test(visibleMessage)) {
|
|
3395
3419
|
sawToolBlock = true;
|
|
3396
3420
|
clearFlushTimer();
|
|
3421
|
+
startWorking();
|
|
3397
3422
|
}
|
|
3398
3423
|
latestDisplayMessage = visibleMessage;
|
|
3399
3424
|
if (!sawToolBlock) {
|
|
@@ -3402,6 +3427,7 @@ ${protocol}`;
|
|
|
3402
3427
|
},
|
|
3403
3428
|
error: (err) => {
|
|
3404
3429
|
debugLogger.error("Stream error:", err);
|
|
3430
|
+
stopWorking();
|
|
3405
3431
|
overrideComponentStatus("Idle");
|
|
3406
3432
|
setIsSubmitting(false);
|
|
3407
3433
|
setIsStreaming(false);
|
|
@@ -3486,6 +3512,7 @@ ${fn}(${argStr})
|
|
|
3486
3512
|
if (functionName === "ask_user" || functionName === "ask-user") {
|
|
3487
3513
|
enhancedMessage = enhancedMessage.replace(match, "");
|
|
3488
3514
|
clearFlushTimer();
|
|
3515
|
+
stopWorking();
|
|
3489
3516
|
const askPreamble = stripToolBlocks(fullMessage).trim();
|
|
3490
3517
|
setStreamBuffer(askPreamble || "_Waiting for your answer\u2026_");
|
|
3491
3518
|
const questions = parseAskUserQuestions(
|
|
@@ -3508,11 +3535,8 @@ A: ${(answers[q.id] || "").trim() || "(no answer)"}`).join("\n\n") : "The user d
|
|
|
3508
3535
|
const placeholderToken = `<<TOOL_LOADING_${functionName}_${Math.random().toString(36).slice(2)}>>`;
|
|
3509
3536
|
enhancedMessage = enhancedMessage.replace(match, placeholderToken);
|
|
3510
3537
|
clearFlushTimer();
|
|
3511
|
-
const toolStatus = functionName === "web_search" || functionName === "web-search" ? "Searching the web
|
|
3512
|
-
|
|
3513
|
-
setStreamBuffer(toolPreamble ? `${toolPreamble}
|
|
3514
|
-
|
|
3515
|
-
_${toolStatus}_` : `_${toolStatus}_`);
|
|
3538
|
+
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";
|
|
3539
|
+
startWorking(toolStatus);
|
|
3516
3540
|
telemetryEvent("tool_loop:tool_execute", { name: functionName, params: parsedParams });
|
|
3517
3541
|
const result = await executeMCPTool({
|
|
3518
3542
|
toolName: functionName,
|
|
@@ -3663,7 +3687,10 @@ Use them to fully complete my original request. If you still need to take an act
|
|
|
3663
3687
|
const visible = stripThinking(acc);
|
|
3664
3688
|
latestDisplayMessage = visible;
|
|
3665
3689
|
lastPartialRef.current.text = visible;
|
|
3666
|
-
if (visible)
|
|
3690
|
+
if (visible) {
|
|
3691
|
+
stopWorking();
|
|
3692
|
+
setIsThinking?.(false);
|
|
3693
|
+
}
|
|
3667
3694
|
setStreamBuffer(visible);
|
|
3668
3695
|
}
|
|
3669
3696
|
},
|
|
@@ -3687,8 +3714,8 @@ Use them to fully complete my original request. If you still need to take an act
|
|
|
3687
3714
|
return ans ? "The user answered:\n\n" + qs.map((q) => `Q: ${q.question}
|
|
3688
3715
|
A: ${(ans[q.id] || "").trim() || "(no answer)"}`).join("\n\n") : "The user dismissed the question(s). Proceed with your best judgment.";
|
|
3689
3716
|
}
|
|
3690
|
-
const status = fn === "create_file" || fn === "create-file" ? "Creating
|
|
3691
|
-
|
|
3717
|
+
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";
|
|
3718
|
+
startWorking(status);
|
|
3692
3719
|
const result = await executeMCPTool({ toolName: fn, parameters: params });
|
|
3693
3720
|
if (!result.success) return `That step failed: ${result.error || "unknown error"}.`;
|
|
3694
3721
|
if (fn === "create_file" || fn === "create-file") {
|
|
@@ -3718,6 +3745,7 @@ _This link is temporary and expires in about ${mins} minutes._`);
|
|
|
3718
3745
|
let finalText = "";
|
|
3719
3746
|
let lastTurnText = "";
|
|
3720
3747
|
for (let round = 0; round < MAX_CHAIN_ROUNDS; round++) {
|
|
3748
|
+
stopWorking();
|
|
3721
3749
|
setStreamBuffer("");
|
|
3722
3750
|
setIsThinking?.(true);
|
|
3723
3751
|
const turnRequest = {
|
|
@@ -3811,6 +3839,7 @@ ${inlineImageBlocks.join("\n\n")}` : "");
|
|
|
3811
3839
|
}
|
|
3812
3840
|
}
|
|
3813
3841
|
}
|
|
3842
|
+
stopWorking();
|
|
3814
3843
|
overrideComponentStatus("Idle");
|
|
3815
3844
|
setIsSubmitting(false);
|
|
3816
3845
|
setPreviousQuestion(question);
|
|
@@ -10049,4 +10078,4 @@ var chat_default = Chat;
|
|
|
10049
10078
|
export {
|
|
10050
10079
|
chat_default
|
|
10051
10080
|
};
|
|
10052
|
-
//# sourceMappingURL=chunk-
|
|
10081
|
+
//# sourceMappingURL=chunk-YBQRVTZF.mjs.map
|