bs-agent 0.0.22 → 0.0.24
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 +40 -19
- package/dist/react/index.cjs.map +1 -1
- package/dist/react/index.js +40 -19
- package/dist/react/index.js.map +1 -1
- package/package.json +1 -1
package/dist/react/index.cjs
CHANGED
|
@@ -372,17 +372,23 @@ function buildStreamCallbacks(deps, debugKey) {
|
|
|
372
372
|
return {
|
|
373
373
|
onComplete: () => {
|
|
374
374
|
console.log("Agent closed");
|
|
375
|
+
setMessages((current) => {
|
|
376
|
+
if (syncSessionRef.current) {
|
|
377
|
+
syncSessionRef.current(current);
|
|
378
|
+
}
|
|
379
|
+
return current;
|
|
380
|
+
});
|
|
375
381
|
setInProgress(false);
|
|
376
|
-
if (syncSessionRef.current) {
|
|
377
|
-
syncSessionRef.current(messagesRef.current);
|
|
378
|
-
}
|
|
379
382
|
},
|
|
380
383
|
onError: (error) => {
|
|
381
384
|
console.log("Agent error", error);
|
|
385
|
+
setMessages((current) => {
|
|
386
|
+
if (syncSessionRef.current) {
|
|
387
|
+
syncSessionRef.current(current);
|
|
388
|
+
}
|
|
389
|
+
return current;
|
|
390
|
+
});
|
|
382
391
|
setInProgress(false);
|
|
383
|
-
if (syncSessionRef.current) {
|
|
384
|
-
syncSessionRef.current(messagesRef.current);
|
|
385
|
-
}
|
|
386
392
|
},
|
|
387
393
|
onEvent: (event) => {
|
|
388
394
|
if (event.type === "text_delta") {
|
|
@@ -815,19 +821,34 @@ function useAgent(agent, options) {
|
|
|
815
821
|
sessionUtils.syncSessionRef.current(messagesRef.current);
|
|
816
822
|
}
|
|
817
823
|
}, [sessionUtils.syncSessionRef]);
|
|
818
|
-
return
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
824
|
+
return (0, import_react3.useMemo)(
|
|
825
|
+
() => ({
|
|
826
|
+
inProgress,
|
|
827
|
+
messages,
|
|
828
|
+
handleSend,
|
|
829
|
+
resumeTool,
|
|
830
|
+
addOptimisticMessage,
|
|
831
|
+
abort,
|
|
832
|
+
sessionId: currentSessionId,
|
|
833
|
+
switchSession: sessionUtils.switchSession,
|
|
834
|
+
deleteSession: sessionUtils.deleteSession,
|
|
835
|
+
sessions: sessionUtils.sessionsList,
|
|
836
|
+
debugData
|
|
837
|
+
}),
|
|
838
|
+
[
|
|
839
|
+
inProgress,
|
|
840
|
+
messages,
|
|
841
|
+
handleSend,
|
|
842
|
+
resumeTool,
|
|
843
|
+
addOptimisticMessage,
|
|
844
|
+
abort,
|
|
845
|
+
currentSessionId,
|
|
846
|
+
sessionUtils.switchSession,
|
|
847
|
+
sessionUtils.deleteSession,
|
|
848
|
+
sessionUtils.sessionsList,
|
|
849
|
+
debugData
|
|
850
|
+
]
|
|
851
|
+
);
|
|
831
852
|
}
|
|
832
853
|
|
|
833
854
|
// src/core/stream.ts
|