@lumerahq/ui 0.10.0-dev.0 → 0.11.0-dev.0
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/{RecordSheet-CZ-x6AeG.js → RecordSheet-DZKLwpi1.js} +1053 -93
- package/dist/components/agent-chat/tool-renderers/ToolCallCard.d.ts.map +1 -1
- package/dist/components/agent-chat/tool-renderers/utils.d.ts +2 -0
- package/dist/components/agent-chat/tool-renderers/utils.d.ts.map +1 -1
- package/dist/components/assistant/AssistantChat.d.ts +37 -0
- package/dist/components/assistant/AssistantChat.d.ts.map +1 -0
- package/dist/components/assistant/AssistantPage.d.ts +22 -0
- package/dist/components/assistant/AssistantPage.d.ts.map +1 -0
- package/dist/components/assistant/AssistantWidget.d.ts +25 -0
- package/dist/components/assistant/AssistantWidget.d.ts.map +1 -0
- package/dist/components/assistant/agent-data-sync.d.ts +35 -0
- package/dist/components/assistant/agent-data-sync.d.ts.map +1 -0
- package/dist/components/assistant/chat-ui.d.ts +48 -0
- package/dist/components/assistant/chat-ui.d.ts.map +1 -0
- package/dist/components/assistant/index.d.ts +6 -0
- package/dist/components/assistant/index.d.ts.map +1 -0
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +12 -6
- package/dist/{highlighted-body-OFNGDK62-DMJuoRQR.js → highlighted-body-OFNGDK62-D-6VBgoC.js} +1 -1
- package/dist/hooks/index.js +10 -10
- package/dist/hooks/use-agent-chat.d.ts.map +1 -1
- package/dist/index.js +40 -34
- package/dist/mermaid-GHXKKRXX-CBvNHga_.js +4 -0
- package/dist/ui.css +583 -3
- package/dist/{use-automation-run-BnhDQAJ6.js → use-automation-run-BNFRnQEA.js} +102 -3
- package/dist/{use-sql-table-D5tupvS2.js → use-sql-table-BgXH7Xzu.js} +7 -102
- package/package.json +1 -1
- package/dist/mermaid-GHXKKRXX-oYSoQafD.js +0 -4
|
@@ -273,6 +273,7 @@ function useAgentChat({
|
|
|
273
273
|
const loadEarlier = useCallback(async () => {
|
|
274
274
|
if (disabled || isLoadingEarlier || !page?.hasMoreBefore || !page.beforeCursor) return;
|
|
275
275
|
const loadEarlierImpl = transport.loadEarlier ?? transport.loadHistory;
|
|
276
|
+
const requestedIdentity = `${agentId ?? ""}::${sessionId}`;
|
|
276
277
|
setIsLoadingEarlier(true);
|
|
277
278
|
setError(null);
|
|
278
279
|
try {
|
|
@@ -282,14 +283,15 @@ function useAgentChat({
|
|
|
282
283
|
beforeCursor: page.beforeCursor,
|
|
283
284
|
limit: historyLimit
|
|
284
285
|
});
|
|
285
|
-
if (!mountedRef.current) return;
|
|
286
|
+
if (!mountedRef.current || identityKeyRef.current !== requestedIdentity) return;
|
|
286
287
|
const earlier = mergePendingMessages(result.messages, result.pending ?? []);
|
|
287
288
|
setMessages((current) => mergeUniqueMessages([...earlier, ...current]));
|
|
288
289
|
setPage(result.page ?? page);
|
|
289
290
|
} catch (err) {
|
|
291
|
+
if (identityKeyRef.current !== requestedIdentity) return;
|
|
290
292
|
handleError(err);
|
|
291
293
|
} finally {
|
|
292
|
-
if (mountedRef.current) setIsLoadingEarlier(false);
|
|
294
|
+
if (mountedRef.current && identityKeyRef.current === requestedIdentity) setIsLoadingEarlier(false);
|
|
293
295
|
}
|
|
294
296
|
}, [agentId, disabled, handleError, historyLimit, isLoadingEarlier, page, sessionId, setMessages, transport]);
|
|
295
297
|
const settleRequest = useCallback(
|
|
@@ -542,6 +544,8 @@ function useAgentChat({
|
|
|
542
544
|
setPage(initialPage ?? null);
|
|
543
545
|
setTokenUsage(null);
|
|
544
546
|
setError(null);
|
|
547
|
+
setIsLoadingHistory(false);
|
|
548
|
+
setIsLoadingEarlier(false);
|
|
545
549
|
setIsStreaming(false);
|
|
546
550
|
setIsSubmitting(false);
|
|
547
551
|
setIsAborting(false);
|
|
@@ -856,6 +860,100 @@ function accumulateTokenUsage(current, incoming) {
|
|
|
856
860
|
} : current.cost
|
|
857
861
|
};
|
|
858
862
|
}
|
|
863
|
+
function useAgentChatSessions({
|
|
864
|
+
agentId,
|
|
865
|
+
transport,
|
|
866
|
+
disabled = false,
|
|
867
|
+
autoLoad = true,
|
|
868
|
+
onError
|
|
869
|
+
}) {
|
|
870
|
+
const [sessions, setSessions] = useState([]);
|
|
871
|
+
const [activeSessionId, setActiveSessionId] = useState(void 0);
|
|
872
|
+
const [error, setError] = useState(null);
|
|
873
|
+
const [isLoading, setIsLoading] = useState(false);
|
|
874
|
+
const [isRenaming, setIsRenaming] = useState(false);
|
|
875
|
+
const handleError = useCallback(
|
|
876
|
+
(err) => {
|
|
877
|
+
setError(err);
|
|
878
|
+
onError?.(err);
|
|
879
|
+
},
|
|
880
|
+
[onError]
|
|
881
|
+
);
|
|
882
|
+
const loadSessions = useCallback(async () => {
|
|
883
|
+
if (disabled) return void 0;
|
|
884
|
+
if (!transport.listSessions) {
|
|
885
|
+
const err = new Error("Agent chat transport does not support listing sessions.");
|
|
886
|
+
handleError(err);
|
|
887
|
+
return void 0;
|
|
888
|
+
}
|
|
889
|
+
setIsLoading(true);
|
|
890
|
+
setError(null);
|
|
891
|
+
try {
|
|
892
|
+
const result = await transport.listSessions({ agentId });
|
|
893
|
+
setSessions(result.sessions);
|
|
894
|
+
setActiveSessionId(result.activeSessionId ?? result.sessions[0]?.id);
|
|
895
|
+
return result;
|
|
896
|
+
} catch (err) {
|
|
897
|
+
handleError(err);
|
|
898
|
+
return void 0;
|
|
899
|
+
} finally {
|
|
900
|
+
setIsLoading(false);
|
|
901
|
+
}
|
|
902
|
+
}, [agentId, disabled, handleError, transport]);
|
|
903
|
+
const renameSession = useCallback(
|
|
904
|
+
async (sessionId, name) => {
|
|
905
|
+
if (disabled) return void 0;
|
|
906
|
+
if (!transport.renameSession) {
|
|
907
|
+
const err = new Error("Agent chat transport does not support renaming sessions.");
|
|
908
|
+
handleError(err);
|
|
909
|
+
return void 0;
|
|
910
|
+
}
|
|
911
|
+
const trimmedName = name.trim();
|
|
912
|
+
if (!trimmedName) {
|
|
913
|
+
const err = new Error("Session name is required.");
|
|
914
|
+
handleError(err);
|
|
915
|
+
return void 0;
|
|
916
|
+
}
|
|
917
|
+
setIsRenaming(true);
|
|
918
|
+
setError(null);
|
|
919
|
+
try {
|
|
920
|
+
const session = await transport.renameSession({ agentId, sessionId, name: trimmedName });
|
|
921
|
+
setSessions((current) => replaceSession(current, session));
|
|
922
|
+
setActiveSessionId((current) => current ?? session.id);
|
|
923
|
+
return session;
|
|
924
|
+
} catch (err) {
|
|
925
|
+
handleError(err);
|
|
926
|
+
return void 0;
|
|
927
|
+
} finally {
|
|
928
|
+
setIsRenaming(false);
|
|
929
|
+
}
|
|
930
|
+
},
|
|
931
|
+
[agentId, disabled, handleError, transport]
|
|
932
|
+
);
|
|
933
|
+
useEffect(() => {
|
|
934
|
+
if (!autoLoad || disabled) return;
|
|
935
|
+
void loadSessions();
|
|
936
|
+
}, [autoLoad, disabled, loadSessions]);
|
|
937
|
+
return {
|
|
938
|
+
sessions,
|
|
939
|
+
activeSessionId,
|
|
940
|
+
error,
|
|
941
|
+
isLoading,
|
|
942
|
+
isRenaming,
|
|
943
|
+
setSessions,
|
|
944
|
+
loadSessions,
|
|
945
|
+
renameSession
|
|
946
|
+
};
|
|
947
|
+
}
|
|
948
|
+
function replaceSession(sessions, next) {
|
|
949
|
+
let found = false;
|
|
950
|
+
const updated = sessions.map((session) => {
|
|
951
|
+
if (session.id !== next.id) return session;
|
|
952
|
+
found = true;
|
|
953
|
+
return next;
|
|
954
|
+
});
|
|
955
|
+
return found ? updated : [next, ...updated];
|
|
956
|
+
}
|
|
859
957
|
function useAutomationRun(options) {
|
|
860
958
|
const {
|
|
861
959
|
agentId,
|
|
@@ -985,6 +1083,7 @@ function useAutomationRun(options) {
|
|
|
985
1083
|
};
|
|
986
1084
|
}
|
|
987
1085
|
export {
|
|
988
|
-
|
|
1086
|
+
useAgentChatSessions as a,
|
|
1087
|
+
useAutomationRun as b,
|
|
989
1088
|
useAgentChat as u
|
|
990
1089
|
};
|
|
@@ -1,100 +1,6 @@
|
|
|
1
|
-
import { useState, useCallback, useEffect, useMemo } from "react";
|
|
2
1
|
import { useQueryClient, useQuery, useMutation } from "@tanstack/react-query";
|
|
2
|
+
import { useState, useCallback, useEffect, useMemo } from "react";
|
|
3
3
|
import { T as listRunsByAgent, z as automationStatuses, F as createAutomationRun, y as uploadFile, o as onInitMessage, t as pbSql, v as pbUpdateRecord } from "./automations-Bb9nlU05.js";
|
|
4
|
-
function useAgentChatSessions({
|
|
5
|
-
agentId,
|
|
6
|
-
transport,
|
|
7
|
-
disabled = false,
|
|
8
|
-
autoLoad = true,
|
|
9
|
-
onError
|
|
10
|
-
}) {
|
|
11
|
-
const [sessions, setSessions] = useState([]);
|
|
12
|
-
const [activeSessionId, setActiveSessionId] = useState(void 0);
|
|
13
|
-
const [error, setError] = useState(null);
|
|
14
|
-
const [isLoading, setIsLoading] = useState(false);
|
|
15
|
-
const [isRenaming, setIsRenaming] = useState(false);
|
|
16
|
-
const handleError = useCallback(
|
|
17
|
-
(err) => {
|
|
18
|
-
setError(err);
|
|
19
|
-
onError?.(err);
|
|
20
|
-
},
|
|
21
|
-
[onError]
|
|
22
|
-
);
|
|
23
|
-
const loadSessions = useCallback(async () => {
|
|
24
|
-
if (disabled) return void 0;
|
|
25
|
-
if (!transport.listSessions) {
|
|
26
|
-
const err = new Error("Agent chat transport does not support listing sessions.");
|
|
27
|
-
handleError(err);
|
|
28
|
-
return void 0;
|
|
29
|
-
}
|
|
30
|
-
setIsLoading(true);
|
|
31
|
-
setError(null);
|
|
32
|
-
try {
|
|
33
|
-
const result = await transport.listSessions({ agentId });
|
|
34
|
-
setSessions(result.sessions);
|
|
35
|
-
setActiveSessionId(result.activeSessionId ?? result.sessions[0]?.id);
|
|
36
|
-
return result;
|
|
37
|
-
} catch (err) {
|
|
38
|
-
handleError(err);
|
|
39
|
-
return void 0;
|
|
40
|
-
} finally {
|
|
41
|
-
setIsLoading(false);
|
|
42
|
-
}
|
|
43
|
-
}, [agentId, disabled, handleError, transport]);
|
|
44
|
-
const renameSession = useCallback(
|
|
45
|
-
async (sessionId, name) => {
|
|
46
|
-
if (disabled) return void 0;
|
|
47
|
-
if (!transport.renameSession) {
|
|
48
|
-
const err = new Error("Agent chat transport does not support renaming sessions.");
|
|
49
|
-
handleError(err);
|
|
50
|
-
return void 0;
|
|
51
|
-
}
|
|
52
|
-
const trimmedName = name.trim();
|
|
53
|
-
if (!trimmedName) {
|
|
54
|
-
const err = new Error("Session name is required.");
|
|
55
|
-
handleError(err);
|
|
56
|
-
return void 0;
|
|
57
|
-
}
|
|
58
|
-
setIsRenaming(true);
|
|
59
|
-
setError(null);
|
|
60
|
-
try {
|
|
61
|
-
const session = await transport.renameSession({ agentId, sessionId, name: trimmedName });
|
|
62
|
-
setSessions((current) => replaceSession(current, session));
|
|
63
|
-
setActiveSessionId((current) => current ?? session.id);
|
|
64
|
-
return session;
|
|
65
|
-
} catch (err) {
|
|
66
|
-
handleError(err);
|
|
67
|
-
return void 0;
|
|
68
|
-
} finally {
|
|
69
|
-
setIsRenaming(false);
|
|
70
|
-
}
|
|
71
|
-
},
|
|
72
|
-
[agentId, disabled, handleError, transport]
|
|
73
|
-
);
|
|
74
|
-
useEffect(() => {
|
|
75
|
-
if (!autoLoad || disabled) return;
|
|
76
|
-
void loadSessions();
|
|
77
|
-
}, [autoLoad, disabled, loadSessions]);
|
|
78
|
-
return {
|
|
79
|
-
sessions,
|
|
80
|
-
activeSessionId,
|
|
81
|
-
error,
|
|
82
|
-
isLoading,
|
|
83
|
-
isRenaming,
|
|
84
|
-
setSessions,
|
|
85
|
-
loadSessions,
|
|
86
|
-
renameSession
|
|
87
|
-
};
|
|
88
|
-
}
|
|
89
|
-
function replaceSession(sessions, next) {
|
|
90
|
-
let found = false;
|
|
91
|
-
const updated = sessions.map((session) => {
|
|
92
|
-
if (session.id !== next.id) return session;
|
|
93
|
-
found = true;
|
|
94
|
-
return next;
|
|
95
|
-
});
|
|
96
|
-
return found ? updated : [next, ...updated];
|
|
97
|
-
}
|
|
98
4
|
function useAutomationAgent({
|
|
99
5
|
agentId,
|
|
100
6
|
limit = 5,
|
|
@@ -427,11 +333,10 @@ function useSqlTable(options) {
|
|
|
427
333
|
};
|
|
428
334
|
}
|
|
429
335
|
export {
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
useAgentChatSessions as u
|
|
336
|
+
useFileUpload as a,
|
|
337
|
+
useLumeraUser as b,
|
|
338
|
+
usePbSql as c,
|
|
339
|
+
usePbUpdate as d,
|
|
340
|
+
useSqlTable as e,
|
|
341
|
+
useAutomationAgent as u
|
|
437
342
|
};
|
package/package.json
CHANGED