@ash-cloud/ash-ui 0.2.1 → 0.2.2
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/index.cjs +9 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +7 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +9 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1053,6 +1053,8 @@ interface StreamEvent {
|
|
|
1053
1053
|
result?: string;
|
|
1054
1054
|
totalCost?: number;
|
|
1055
1055
|
totalTokens?: number;
|
|
1056
|
+
/** SSE event ID (sequence number from relay) for reconnection */
|
|
1057
|
+
id?: string;
|
|
1056
1058
|
entry?: {
|
|
1057
1059
|
timestamp: string;
|
|
1058
1060
|
level: string;
|
|
@@ -1292,6 +1294,11 @@ interface UseAgentChatReturn {
|
|
|
1292
1294
|
* This replaces all entries and clears streaming state
|
|
1293
1295
|
*/
|
|
1294
1296
|
setEntries: (entries: NormalizedEntry[]) => void;
|
|
1297
|
+
/**
|
|
1298
|
+
* Last seen SSE sequence number.
|
|
1299
|
+
* Use this for reconnection via the relay endpoint: GET /sessions/:id/stream?after=lastSequence
|
|
1300
|
+
*/
|
|
1301
|
+
lastSequence: number;
|
|
1295
1302
|
}
|
|
1296
1303
|
declare function useAgentChat(options: UseAgentChatOptions): UseAgentChatReturn;
|
|
1297
1304
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1053,6 +1053,8 @@ interface StreamEvent {
|
|
|
1053
1053
|
result?: string;
|
|
1054
1054
|
totalCost?: number;
|
|
1055
1055
|
totalTokens?: number;
|
|
1056
|
+
/** SSE event ID (sequence number from relay) for reconnection */
|
|
1057
|
+
id?: string;
|
|
1056
1058
|
entry?: {
|
|
1057
1059
|
timestamp: string;
|
|
1058
1060
|
level: string;
|
|
@@ -1292,6 +1294,11 @@ interface UseAgentChatReturn {
|
|
|
1292
1294
|
* This replaces all entries and clears streaming state
|
|
1293
1295
|
*/
|
|
1294
1296
|
setEntries: (entries: NormalizedEntry[]) => void;
|
|
1297
|
+
/**
|
|
1298
|
+
* Last seen SSE sequence number.
|
|
1299
|
+
* Use this for reconnection via the relay endpoint: GET /sessions/:id/stream?after=lastSequence
|
|
1300
|
+
*/
|
|
1301
|
+
lastSequence: number;
|
|
1295
1302
|
}
|
|
1296
1303
|
declare function useAgentChat(options: UseAgentChatOptions): UseAgentChatReturn;
|
|
1297
1304
|
|
package/dist/index.js
CHANGED
|
@@ -3615,6 +3615,7 @@ function useAgentChat(options) {
|
|
|
3615
3615
|
const eventCountRef = useRef(0);
|
|
3616
3616
|
const sessionIdRef = useRef(sessionId);
|
|
3617
3617
|
const streamingEntriesRef = useRef([]);
|
|
3618
|
+
const lastSequenceRef = useRef(0);
|
|
3618
3619
|
useEffect(() => {
|
|
3619
3620
|
sessionIdRef.current = sessionId;
|
|
3620
3621
|
}, [sessionId]);
|
|
@@ -3639,6 +3640,12 @@ function useAgentChat(options) {
|
|
|
3639
3640
|
setStreamingEntries([]);
|
|
3640
3641
|
}, []);
|
|
3641
3642
|
const processEvent = useCallback((event, streamEntries) => {
|
|
3643
|
+
if (event.id) {
|
|
3644
|
+
const seq = parseInt(event.id, 10);
|
|
3645
|
+
if (!isNaN(seq)) {
|
|
3646
|
+
lastSequenceRef.current = seq;
|
|
3647
|
+
}
|
|
3648
|
+
}
|
|
3642
3649
|
const newEntries = [...streamEntries];
|
|
3643
3650
|
switch (event.type) {
|
|
3644
3651
|
case "session_start":
|
|
@@ -3975,7 +3982,8 @@ function useAgentChat(options) {
|
|
|
3975
3982
|
send,
|
|
3976
3983
|
stop,
|
|
3977
3984
|
clear,
|
|
3978
|
-
setEntries
|
|
3985
|
+
setEntries,
|
|
3986
|
+
lastSequence: lastSequenceRef.current
|
|
3979
3987
|
};
|
|
3980
3988
|
}
|
|
3981
3989
|
function generateId() {
|