@springbrand/chat-client 0.1.3-alpha.22 → 0.1.3-alpha.23
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
|
@@ -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,
|