@ash-cloud/ash-ui 0.2.1 → 0.2.3
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 +8 -0
- package/dist/index.d.ts +8 -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
|
@@ -1050,9 +1050,12 @@ interface StreamEvent {
|
|
|
1050
1050
|
error?: string;
|
|
1051
1051
|
code?: string;
|
|
1052
1052
|
status?: string;
|
|
1053
|
+
message?: string;
|
|
1053
1054
|
result?: string;
|
|
1054
1055
|
totalCost?: number;
|
|
1055
1056
|
totalTokens?: number;
|
|
1057
|
+
/** SSE event ID (sequence number from relay) for reconnection */
|
|
1058
|
+
id?: string;
|
|
1056
1059
|
entry?: {
|
|
1057
1060
|
timestamp: string;
|
|
1058
1061
|
level: string;
|
|
@@ -1292,6 +1295,11 @@ interface UseAgentChatReturn {
|
|
|
1292
1295
|
* This replaces all entries and clears streaming state
|
|
1293
1296
|
*/
|
|
1294
1297
|
setEntries: (entries: NormalizedEntry[]) => void;
|
|
1298
|
+
/**
|
|
1299
|
+
* Last seen SSE sequence number.
|
|
1300
|
+
* Use this for reconnection via the relay endpoint: GET /sessions/:id/stream?after=lastSequence
|
|
1301
|
+
*/
|
|
1302
|
+
lastSequence: number;
|
|
1295
1303
|
}
|
|
1296
1304
|
declare function useAgentChat(options: UseAgentChatOptions): UseAgentChatReturn;
|
|
1297
1305
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1050,9 +1050,12 @@ interface StreamEvent {
|
|
|
1050
1050
|
error?: string;
|
|
1051
1051
|
code?: string;
|
|
1052
1052
|
status?: string;
|
|
1053
|
+
message?: string;
|
|
1053
1054
|
result?: string;
|
|
1054
1055
|
totalCost?: number;
|
|
1055
1056
|
totalTokens?: number;
|
|
1057
|
+
/** SSE event ID (sequence number from relay) for reconnection */
|
|
1058
|
+
id?: string;
|
|
1056
1059
|
entry?: {
|
|
1057
1060
|
timestamp: string;
|
|
1058
1061
|
level: string;
|
|
@@ -1292,6 +1295,11 @@ interface UseAgentChatReturn {
|
|
|
1292
1295
|
* This replaces all entries and clears streaming state
|
|
1293
1296
|
*/
|
|
1294
1297
|
setEntries: (entries: NormalizedEntry[]) => void;
|
|
1298
|
+
/**
|
|
1299
|
+
* Last seen SSE sequence number.
|
|
1300
|
+
* Use this for reconnection via the relay endpoint: GET /sessions/:id/stream?after=lastSequence
|
|
1301
|
+
*/
|
|
1302
|
+
lastSequence: number;
|
|
1295
1303
|
}
|
|
1296
1304
|
declare function useAgentChat(options: UseAgentChatOptions): UseAgentChatReturn;
|
|
1297
1305
|
|
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() {
|