@usabledev/usable-chat 1.207.7 → 1.207.9
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 +48 -35
- package/package.json +1 -1
package/cli.js
CHANGED
|
@@ -138091,6 +138091,7 @@ async function callClaude(apiKey, request, options2) {
|
|
|
138091
138091
|
delta: typedEvent.delta,
|
|
138092
138092
|
content_block: typedEvent.content_block,
|
|
138093
138093
|
index: typedEvent.index,
|
|
138094
|
+
usage: typedEvent.usage,
|
|
138094
138095
|
error: typedEvent.error
|
|
138095
138096
|
};
|
|
138096
138097
|
if (options2?.onChunk) {
|
|
@@ -164720,6 +164721,46 @@ async function adaptOpenRouterStream(stream, options2) {
|
|
|
164720
164721
|
multiplexer.send(errorEvent);
|
|
164721
164722
|
}
|
|
164722
164723
|
};
|
|
164724
|
+
const startPendingToolCall = (index2, args) => {
|
|
164725
|
+
const pending = pendingToolCalls.get(index2);
|
|
164726
|
+
if (!pending?.id || !pending.name) return false;
|
|
164727
|
+
completedToolCalls.push({
|
|
164728
|
+
id: pending.id,
|
|
164729
|
+
name: pending.name,
|
|
164730
|
+
arguments: args
|
|
164731
|
+
});
|
|
164732
|
+
streamLogger.debug("Tool call complete", {
|
|
164733
|
+
toolName: pending.name,
|
|
164734
|
+
toolId: pending.id
|
|
164735
|
+
});
|
|
164736
|
+
const toolCallEvent = emitter.emit("tool-call", {
|
|
164737
|
+
id: pending.id,
|
|
164738
|
+
toolName: pending.name,
|
|
164739
|
+
args,
|
|
164740
|
+
state: "complete"
|
|
164741
|
+
});
|
|
164742
|
+
providerAttempt?.markObservableProgress();
|
|
164743
|
+
multiplexer.send(toolCallEvent);
|
|
164744
|
+
const retrievalTools = [
|
|
164745
|
+
"agentic-search-fragments",
|
|
164746
|
+
"search-memory-fragments",
|
|
164747
|
+
"get-memory-fragment-content",
|
|
164748
|
+
"list-memory-fragments"
|
|
164749
|
+
];
|
|
164750
|
+
if (retrievalTools.includes(pending.name)) {
|
|
164751
|
+
const retrievalQuery = typeof args.query === "string" ? args.query : typeof args.fragmentId === "string" ? args.fragmentId : "unknown";
|
|
164752
|
+
const retrievalEvent = emitter.emit("retrieval", {
|
|
164753
|
+
source: pending.name,
|
|
164754
|
+
query: retrievalQuery,
|
|
164755
|
+
resultCount: void 0
|
|
164756
|
+
});
|
|
164757
|
+
multiplexer.send(retrievalEvent);
|
|
164758
|
+
}
|
|
164759
|
+
providerAttempt?.pause();
|
|
164760
|
+
toolExecutionPromises.push(executeParsedToolCall(pending.id, pending.name, args));
|
|
164761
|
+
pendingToolCalls.delete(index2);
|
|
164762
|
+
return true;
|
|
164763
|
+
};
|
|
164723
164764
|
async function drainStartedTools() {
|
|
164724
164765
|
if (toolExecutionPromises.length === 0) return;
|
|
164725
164766
|
providerAttempt?.pause();
|
|
@@ -164967,40 +165008,7 @@ async function adaptOpenRouterStream(stream, options2) {
|
|
|
164967
165008
|
if (pending.id && pending.name && pending.arguments) {
|
|
164968
165009
|
try {
|
|
164969
165010
|
const args = JSON.parse(pending.arguments);
|
|
164970
|
-
|
|
164971
|
-
id: pending.id,
|
|
164972
|
-
name: pending.name,
|
|
164973
|
-
arguments: args
|
|
164974
|
-
});
|
|
164975
|
-
streamLogger.debug("Tool call complete", {
|
|
164976
|
-
toolName: pending.name,
|
|
164977
|
-
toolId: pending.id
|
|
164978
|
-
});
|
|
164979
|
-
const toolCallEvent = emitter.emit("tool-call", {
|
|
164980
|
-
id: pending.id,
|
|
164981
|
-
toolName: pending.name,
|
|
164982
|
-
args,
|
|
164983
|
-
state: "complete"
|
|
164984
|
-
});
|
|
164985
|
-
providerAttempt?.markObservableProgress();
|
|
164986
|
-
multiplexer.send(toolCallEvent);
|
|
164987
|
-
const retrievalTools = [
|
|
164988
|
-
"agentic-search-fragments",
|
|
164989
|
-
"search-memory-fragments",
|
|
164990
|
-
"get-memory-fragment-content",
|
|
164991
|
-
"list-memory-fragments"
|
|
164992
|
-
];
|
|
164993
|
-
if (retrievalTools.includes(pending.name)) {
|
|
164994
|
-
const retrievalEvent = emitter.emit("retrieval", {
|
|
164995
|
-
source: pending.name,
|
|
164996
|
-
query: args?.query || args?.fragmentId || "unknown",
|
|
164997
|
-
resultCount: void 0
|
|
164998
|
-
});
|
|
164999
|
-
multiplexer.send(retrievalEvent);
|
|
165000
|
-
}
|
|
165001
|
-
providerAttempt?.pause();
|
|
165002
|
-
toolExecutionPromises.push(executeParsedToolCall(pending.id, pending.name, args));
|
|
165003
|
-
pendingToolCalls.delete(index2);
|
|
165011
|
+
startPendingToolCall(index2, args);
|
|
165004
165012
|
} catch {
|
|
165005
165013
|
}
|
|
165006
165014
|
}
|
|
@@ -165012,6 +165020,11 @@ async function adaptOpenRouterStream(stream, options2) {
|
|
|
165012
165020
|
finishReason: finish_reason,
|
|
165013
165021
|
hasUsage: !!capturedUsage
|
|
165014
165022
|
});
|
|
165023
|
+
if (finish_reason === "tool_calls") {
|
|
165024
|
+
for (const [index2, pending] of pendingToolCalls) {
|
|
165025
|
+
if (pending.arguments.length === 0) startPendingToolCall(index2, {});
|
|
165026
|
+
}
|
|
165027
|
+
}
|
|
165015
165028
|
if (finish_reason === "tool_calls" && toolExecutionPromises.length > 0) {
|
|
165016
165029
|
streamLogger.debug("Waiting for OpenRouter tool executions", {
|
|
165017
165030
|
toolCount: toolExecutionPromises.length
|
|
@@ -391591,7 +391604,7 @@ init_tui_select();
|
|
|
391591
391604
|
init_model_registry();
|
|
391592
391605
|
|
|
391593
391606
|
// package.json
|
|
391594
|
-
var version2 = "1.207.
|
|
391607
|
+
var version2 = "1.207.9";
|
|
391595
391608
|
|
|
391596
391609
|
// src/adapters/cli/model-catalog.ts
|
|
391597
391610
|
init_codex_auth();
|