@springbrand/chat-client 0.1.3-alpha.22 → 0.1.3-alpha.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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@springbrand/chat-client",
|
|
3
|
-
"version": "0.1.3-alpha.
|
|
3
|
+
"version": "0.1.3-alpha.24",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"files": [
|
|
6
6
|
"src",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"@types/react-dom": "^19.2.3",
|
|
26
26
|
"react-dom": "^19.2.7",
|
|
27
27
|
"typescript": "^7.0.2",
|
|
28
|
-
"@springbrand/agent-runtime": "0.2.0-alpha.
|
|
28
|
+
"@springbrand/agent-runtime": "0.2.0-alpha.31"
|
|
29
29
|
},
|
|
30
30
|
"scripts": {
|
|
31
31
|
"typecheck": "tsc --noEmit"
|
|
@@ -572,11 +572,25 @@ export function useUniversalAgentChat(): ChatRuntime {
|
|
|
572
572
|
const dispatchMessage = useCallback(async (
|
|
573
573
|
message: ChatMessage,
|
|
574
574
|
delivery: MessageDelivery,
|
|
575
|
-
): Promise<MessageDispatchReceipt> =>
|
|
576
|
-
agentRef.current.call<MessageDispatchReceipt>(
|
|
575
|
+
): Promise<MessageDispatchReceipt> => {
|
|
576
|
+
const dispatch = () => agentRef.current.call<MessageDispatchReceipt>(
|
|
577
577
|
"dispatchMessage",
|
|
578
578
|
[message, delivery],
|
|
579
|
-
)
|
|
579
|
+
);
|
|
580
|
+
try {
|
|
581
|
+
return await dispatch();
|
|
582
|
+
} catch (error) {
|
|
583
|
+
// The server deduplicates dispatches by message.id, so replay only the
|
|
584
|
+
// transport failures that mean admission may already have succeeded.
|
|
585
|
+
const retryable = error instanceof Error && (
|
|
586
|
+
/^RPC call to dispatchMessage timed out after \d+ms$/u.test(error.message) ||
|
|
587
|
+
(error.message === "Connection closed" && agentRef.current.shouldReconnect)
|
|
588
|
+
);
|
|
589
|
+
if (!retryable) throw error;
|
|
590
|
+
await agentRef.current.ready;
|
|
591
|
+
return dispatch();
|
|
592
|
+
}
|
|
593
|
+
}, []);
|
|
580
594
|
|
|
581
595
|
const submitMessage = useCallback(async (
|
|
582
596
|
message: ChatMessage,
|
|
@@ -777,16 +791,15 @@ export function useUniversalAgentChat(): ChatRuntime {
|
|
|
777
791
|
}));
|
|
778
792
|
return;
|
|
779
793
|
}
|
|
780
|
-
|
|
781
|
-
?
|
|
794
|
+
await (submissionId
|
|
795
|
+
? agentRef.current.call<{ ok: boolean }>(
|
|
782
796
|
"cancelSubmissionById",
|
|
783
797
|
[submissionId, USER_STOP_REASON],
|
|
784
798
|
)
|
|
785
|
-
:
|
|
799
|
+
: agentRef.current.call<{ ok: boolean }>(
|
|
786
800
|
"stopTurn",
|
|
787
801
|
[undefined, USER_STOP_REASON],
|
|
788
|
-
);
|
|
789
|
-
if (!result.ok) setDispatchError("The active Turn could not be stopped");
|
|
802
|
+
));
|
|
790
803
|
} catch (cause) {
|
|
791
804
|
setDispatchError(
|
|
792
805
|
cause instanceof Error ? cause.message : String(cause),
|