bs-agent 0.0.24 → 0.0.25
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/react/index.cjs +20 -72
- package/dist/react/index.cjs.map +1 -1
- package/dist/react/index.js +20 -72
- package/dist/react/index.js.map +1 -1
- package/package.json +1 -1
package/dist/react/index.js
CHANGED
|
@@ -341,23 +341,17 @@ function buildStreamCallbacks(deps, debugKey) {
|
|
|
341
341
|
return {
|
|
342
342
|
onComplete: () => {
|
|
343
343
|
console.log("Agent closed");
|
|
344
|
-
setMessages((current) => {
|
|
345
|
-
if (syncSessionRef.current) {
|
|
346
|
-
syncSessionRef.current(current);
|
|
347
|
-
}
|
|
348
|
-
return current;
|
|
349
|
-
});
|
|
350
344
|
setInProgress(false);
|
|
345
|
+
if (syncSessionRef.current) {
|
|
346
|
+
syncSessionRef.current(messagesRef.current);
|
|
347
|
+
}
|
|
351
348
|
},
|
|
352
349
|
onError: (error) => {
|
|
353
350
|
console.log("Agent error", error);
|
|
354
|
-
setMessages((current) => {
|
|
355
|
-
if (syncSessionRef.current) {
|
|
356
|
-
syncSessionRef.current(current);
|
|
357
|
-
}
|
|
358
|
-
return current;
|
|
359
|
-
});
|
|
360
351
|
setInProgress(false);
|
|
352
|
+
if (syncSessionRef.current) {
|
|
353
|
+
syncSessionRef.current(messagesRef.current);
|
|
354
|
+
}
|
|
361
355
|
},
|
|
362
356
|
onEvent: (event) => {
|
|
363
357
|
if (event.type === "text_delta") {
|
|
@@ -484,25 +478,7 @@ function handleTextDelta(event, setMessages, syncSessionRef, modifier, fullTextM
|
|
|
484
478
|
}
|
|
485
479
|
function handleClientToolCall(event, setMessages, syncSessionRef, toolContext, agentId) {
|
|
486
480
|
const tool = toolContext?.getTool(agentId, event.data.toolName);
|
|
487
|
-
|
|
488
|
-
"[DEBUG] handleClientToolCall:",
|
|
489
|
-
event.data.toolName,
|
|
490
|
-
"paused:",
|
|
491
|
-
event.data.paused,
|
|
492
|
-
"toolFound:",
|
|
493
|
-
!!tool,
|
|
494
|
-
"hasRender:",
|
|
495
|
-
!!tool?.render
|
|
496
|
-
);
|
|
497
|
-
if (!tool?.render && !event.data.paused) {
|
|
498
|
-
console.log("[DEBUG] handleClientToolCall: SKIPPING part creation \u2014 not paused and no render");
|
|
499
|
-
return;
|
|
500
|
-
}
|
|
501
|
-
console.log(
|
|
502
|
-
"[DEBUG] handleClientToolCall: CREATING widget part for",
|
|
503
|
-
event.data.toolName,
|
|
504
|
-
event.data.callId
|
|
505
|
-
);
|
|
481
|
+
if (!tool?.render && !event.data.paused) return;
|
|
506
482
|
setMessages((prev) => {
|
|
507
483
|
const lastMessage = prev[prev.length - 1];
|
|
508
484
|
const newPart = {
|
|
@@ -790,34 +766,19 @@ function useAgent(agent, options) {
|
|
|
790
766
|
sessionUtils.syncSessionRef.current(messagesRef.current);
|
|
791
767
|
}
|
|
792
768
|
}, [sessionUtils.syncSessionRef]);
|
|
793
|
-
return
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
}),
|
|
807
|
-
[
|
|
808
|
-
inProgress,
|
|
809
|
-
messages,
|
|
810
|
-
handleSend,
|
|
811
|
-
resumeTool,
|
|
812
|
-
addOptimisticMessage,
|
|
813
|
-
abort,
|
|
814
|
-
currentSessionId,
|
|
815
|
-
sessionUtils.switchSession,
|
|
816
|
-
sessionUtils.deleteSession,
|
|
817
|
-
sessionUtils.sessionsList,
|
|
818
|
-
debugData
|
|
819
|
-
]
|
|
820
|
-
);
|
|
769
|
+
return {
|
|
770
|
+
inProgress,
|
|
771
|
+
messages,
|
|
772
|
+
handleSend,
|
|
773
|
+
resumeTool,
|
|
774
|
+
addOptimisticMessage,
|
|
775
|
+
abort,
|
|
776
|
+
sessionId: currentSessionId,
|
|
777
|
+
switchSession: sessionUtils.switchSession,
|
|
778
|
+
deleteSession: sessionUtils.deleteSession,
|
|
779
|
+
sessions: sessionUtils.sessionsList,
|
|
780
|
+
debugData
|
|
781
|
+
};
|
|
821
782
|
}
|
|
822
783
|
|
|
823
784
|
// src/core/stream.ts
|
|
@@ -1636,19 +1597,6 @@ function ToolRenderer({ agentId, part }) {
|
|
|
1636
1597
|
throw new Error("ToolRenderer must be used within <AgentContextProvider>");
|
|
1637
1598
|
}
|
|
1638
1599
|
const tool = context.getTool(agentId, part.toolName);
|
|
1639
|
-
console.log(
|
|
1640
|
-
"[DEBUG] ToolRenderer:",
|
|
1641
|
-
part.toolName,
|
|
1642
|
-
part.callId,
|
|
1643
|
-
"toolFound:",
|
|
1644
|
-
!!tool,
|
|
1645
|
-
"hasRender:",
|
|
1646
|
-
!!tool?.render,
|
|
1647
|
-
"paused:",
|
|
1648
|
-
part.paused,
|
|
1649
|
-
"status:",
|
|
1650
|
-
localStatus
|
|
1651
|
-
);
|
|
1652
1600
|
const handleSubmit = useCallback6(
|
|
1653
1601
|
(result) => {
|
|
1654
1602
|
if (localStatus === "submitted") return;
|