@usabledev/usable-chat 1.207.2 → 1.207.4
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/cli.js +63 -13
- package/package.json +1 -1
package/cli.js
CHANGED
|
@@ -362966,9 +362966,34 @@ function shouldRecoverSilentStop({
|
|
|
362966
362966
|
text: text5,
|
|
362967
362967
|
lastStepHadToolErrors,
|
|
362968
362968
|
lastStepHadToolActivity,
|
|
362969
|
-
recoveryAttempted
|
|
362969
|
+
recoveryAttempted,
|
|
362970
|
+
recoverPreToolStop = false
|
|
362970
362971
|
}) {
|
|
362971
|
-
|
|
362972
|
+
const stoppedBeforeAction = !text5?.trim() || recoverPreToolStop && isIncompleteWorkActionPreamble(text5);
|
|
362973
|
+
return !recoveryAttempted && stoppedBeforeAction && (lastStepHadToolErrors || lastStepHadToolActivity || recoverPreToolStop);
|
|
362974
|
+
}
|
|
362975
|
+
function isIncompleteWorkActionPreamble(text5) {
|
|
362976
|
+
const value = text5?.trim();
|
|
362977
|
+
if (!value || value.length > 160 || /[\n:;—–]|```/.test(value)) return false;
|
|
362978
|
+
const withoutLeadIn = value.replace(/^sure[,!.]?\s*/i, "");
|
|
362979
|
+
const withoutTerminalPunctuation = withoutLeadIn.replace(/[.!?]$/, "");
|
|
362980
|
+
if (/[,.!?]/.test(withoutTerminalPunctuation)) return false;
|
|
362981
|
+
if (!/(?:\bfor you|\bnow|\bnext|\bright away|\bshortly|\bmomentarily|\bfirst)[.!?]?$/i.test(value)) {
|
|
362982
|
+
return false;
|
|
362983
|
+
}
|
|
362984
|
+
return /^(?:sure[,!.]?\s*)?(?:i(?:'ll|\s+will|\s+am going to)|let me)\s+(?:now\s+)?(?:retrieve|fetch|look up|check|find|list|gather|inspect|run|execute|search|load|open|read|create|update|write|analy[sz]e)\b/i.test(
|
|
362985
|
+
value
|
|
362986
|
+
);
|
|
362987
|
+
}
|
|
362988
|
+
function resolveSilentStopResponse({
|
|
362989
|
+
text: text5,
|
|
362990
|
+
recoveryAttempted,
|
|
362991
|
+
recoverPreToolStop
|
|
362992
|
+
}) {
|
|
362993
|
+
if (recoverPreToolStop && recoveryAttempted && (!text5?.trim() || isIncompleteWorkActionPreamble(text5))) {
|
|
362994
|
+
return "I could not complete that Work request. Please try again.";
|
|
362995
|
+
}
|
|
362996
|
+
return text5 || "";
|
|
362972
362997
|
}
|
|
362973
362998
|
function shouldInjectVisualizationPrompt(config3) {
|
|
362974
362999
|
return !config3.localFilesystem && config3.visualizationsEnabled !== false;
|
|
@@ -366637,7 +366662,9 @@ ${combinedSystemMessage}` : combinedSystemMessage;
|
|
|
366637
366662
|
);
|
|
366638
366663
|
if (receipt) {
|
|
366639
366664
|
if (receipt.outcome === "unknown")
|
|
366640
|
-
throw new Error(
|
|
366665
|
+
throw new Error(
|
|
366666
|
+
"Earlier tool outcome is unknown; repeating this action requires user resolution."
|
|
366667
|
+
);
|
|
366641
366668
|
return receipt.result;
|
|
366642
366669
|
}
|
|
366643
366670
|
}
|
|
@@ -367455,13 +367482,19 @@ Re-read them (working_memory on web, bash on the CLI \u2014 grep/sed projection,
|
|
|
367455
367482
|
text: result.text,
|
|
367456
367483
|
lastStepHadToolErrors,
|
|
367457
367484
|
lastStepHadToolActivity,
|
|
367458
|
-
recoveryAttempted
|
|
367485
|
+
recoveryAttempted,
|
|
367486
|
+
recoverPreToolStop: context3.metadata?.workRuntime === "machine"
|
|
367459
367487
|
})) {
|
|
367460
367488
|
recoveryAttempted = true;
|
|
367461
|
-
const recoveryPrompt = lastStepHadToolErrors ? "The previous tool call failed. Briefly summarise to the user what happened, why it likely failed, and any next steps they could take (without retrying the failed tool)." : "The previous step used tools but did not produce a visible final answer. Using the available tool results, answer the user now. Do not call more tools unless absolutely required.";
|
|
367489
|
+
const recoveryPrompt = lastStepHadToolErrors ? "The previous tool call failed. Briefly summarise to the user what happened, why it likely failed, and any next steps they could take (without retrying the failed tool)." : lastStepHadToolActivity ? "The previous step used tools but did not produce a visible final answer. Using the available tool results, answer the user now. Do not call more tools unless absolutely required." : "The previous response stopped before completing the requested action. Do not merely announce what you will do. Complete the user's original request now and call the required tool when one is available.";
|
|
367462
367490
|
orchestrationLogger.warn(
|
|
367463
|
-
"Model stopped silently
|
|
367464
|
-
{
|
|
367491
|
+
"Model stopped silently \u2014 injecting recovery prompt",
|
|
367492
|
+
{
|
|
367493
|
+
step: currentStep,
|
|
367494
|
+
finishReason: result.finishReason,
|
|
367495
|
+
hadToolActivity: lastStepHadToolActivity,
|
|
367496
|
+
workRuntime: context3.metadata?.workRuntime === "machine"
|
|
367497
|
+
},
|
|
367465
367498
|
{ userId, sessionId: sessionId2 }
|
|
367466
367499
|
);
|
|
367467
367500
|
conversationMessages.push({
|
|
@@ -367472,13 +367505,30 @@ Re-read them (working_memory on web, bash on the CLI \u2014 grep/sed projection,
|
|
|
367472
367505
|
lastStepHadToolActivity = false;
|
|
367473
367506
|
continue;
|
|
367474
367507
|
}
|
|
367508
|
+
const finalResponseText = resolveSilentStopResponse({
|
|
367509
|
+
text: result.text,
|
|
367510
|
+
recoveryAttempted,
|
|
367511
|
+
recoverPreToolStop: context3.metadata?.workRuntime === "machine"
|
|
367512
|
+
});
|
|
367513
|
+
if (finalResponseText !== (result.text || "")) {
|
|
367514
|
+
multiplexer.send(
|
|
367515
|
+
emitter.emit("text-delta", {
|
|
367516
|
+
textDelta: finalResponseText
|
|
367517
|
+
})
|
|
367518
|
+
);
|
|
367519
|
+
orchestrationLogger.error(
|
|
367520
|
+
"Work model stopped silently after its bounded recovery",
|
|
367521
|
+
{ step: currentStep, finishReason: result.finishReason },
|
|
367522
|
+
{ userId, sessionId: sessionId2 }
|
|
367523
|
+
);
|
|
367524
|
+
}
|
|
367475
367525
|
if (context3.hookExecution && !hookContinuationAttempted) {
|
|
367476
367526
|
try {
|
|
367477
367527
|
const stopHooks = await context3.hookExecution.run(
|
|
367478
367528
|
"agent-stop",
|
|
367479
367529
|
{
|
|
367480
|
-
responseProduced: Boolean(
|
|
367481
|
-
response:
|
|
367530
|
+
responseProduced: Boolean(finalResponseText.trim()),
|
|
367531
|
+
response: finalResponseText,
|
|
367482
367532
|
finishReason: result.finishReason,
|
|
367483
367533
|
continuationCount: hookContinuationAttempted ? 1 : 0
|
|
367484
367534
|
},
|
|
@@ -367489,7 +367539,7 @@ Re-read them (working_memory on web, bash on the CLI \u2014 grep/sed projection,
|
|
|
367489
367539
|
hookContinuationAttempted = true;
|
|
367490
367540
|
conversationMessages.push({
|
|
367491
367541
|
role: "assistant",
|
|
367492
|
-
content:
|
|
367542
|
+
content: finalResponseText
|
|
367493
367543
|
});
|
|
367494
367544
|
conversationMessages.push({
|
|
367495
367545
|
role: "user",
|
|
@@ -367504,10 +367554,10 @@ Continue once without hiding or replacing your prior response.`
|
|
|
367504
367554
|
});
|
|
367505
367555
|
}
|
|
367506
367556
|
}
|
|
367507
|
-
const hasOnlyThinking = !
|
|
367557
|
+
const hasOnlyThinking = !finalResponseText.trim() && result.reasoningDetails?.length;
|
|
367508
367558
|
const finalAssistantMessage = {
|
|
367509
367559
|
role: "assistant",
|
|
367510
|
-
content: hasOnlyThinking ? "(thinking completed)" :
|
|
367560
|
+
content: hasOnlyThinking ? "(thinking completed)" : finalResponseText
|
|
367511
367561
|
};
|
|
367512
367562
|
if (result.reasoningDetails && result.reasoningDetails.length > 0) {
|
|
367513
367563
|
if (!isClaude) {
|
|
@@ -391524,7 +391574,7 @@ init_tui_select();
|
|
|
391524
391574
|
init_model_registry();
|
|
391525
391575
|
|
|
391526
391576
|
// package.json
|
|
391527
|
-
var version2 = "1.207.
|
|
391577
|
+
var version2 = "1.207.4";
|
|
391528
391578
|
|
|
391529
391579
|
// src/adapters/cli/model-catalog.ts
|
|
391530
391580
|
init_codex_auth();
|