@axiom-lattice/react-sdk 2.1.9 → 2.1.11
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.d.mts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +57 -24
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +62 -26
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -58,6 +58,7 @@ interface ChatResponse {
|
|
|
58
58
|
* Agent state interface
|
|
59
59
|
*/
|
|
60
60
|
interface AgentState {
|
|
61
|
+
createdAt?: string;
|
|
61
62
|
values: {
|
|
62
63
|
messages: Message[];
|
|
63
64
|
[key: string]: any;
|
|
@@ -446,6 +447,7 @@ interface ChatingProps {
|
|
|
446
447
|
showHeader?: boolean;
|
|
447
448
|
showSender?: boolean;
|
|
448
449
|
showHITL?: boolean;
|
|
450
|
+
showRefreshButton?: boolean;
|
|
449
451
|
}
|
|
450
452
|
declare const Chating: React__default.FC<ChatingProps>;
|
|
451
453
|
|
package/dist/index.d.ts
CHANGED
|
@@ -58,6 +58,7 @@ interface ChatResponse {
|
|
|
58
58
|
* Agent state interface
|
|
59
59
|
*/
|
|
60
60
|
interface AgentState {
|
|
61
|
+
createdAt?: string;
|
|
61
62
|
values: {
|
|
62
63
|
messages: Message[];
|
|
63
64
|
[key: string]: any;
|
|
@@ -446,6 +447,7 @@ interface ChatingProps {
|
|
|
446
447
|
showHeader?: boolean;
|
|
447
448
|
showSender?: boolean;
|
|
448
449
|
showHITL?: boolean;
|
|
450
|
+
showRefreshButton?: boolean;
|
|
449
451
|
}
|
|
450
452
|
declare const Chating: React__default.FC<ChatingProps>;
|
|
451
453
|
|
package/dist/index.js
CHANGED
|
@@ -441,24 +441,33 @@ function AgentThreadProvider({
|
|
|
441
441
|
});
|
|
442
442
|
const stopStreamingRef = (0, import_react3.useRef)(null);
|
|
443
443
|
const chunkMessageMerger = (0, import_react3.useRef)((0, import_client_sdk3.createSimpleMessageMerger)());
|
|
444
|
+
const lastAgentStateCreatedAtRef = (0, import_react3.useRef)(null);
|
|
444
445
|
const fetchAndUpdateAgentState = (0, import_react3.useCallback)(
|
|
445
446
|
async (threadId2) => {
|
|
446
447
|
if (!options.enableReturnStateWhenStreamCompleted) return;
|
|
447
448
|
try {
|
|
448
449
|
const agentState = await client.getAgentState(threadId2);
|
|
450
|
+
const currentCreatedAt = agentState?.createdAt;
|
|
451
|
+
const needsUpdate = !lastAgentStateCreatedAtRef.current || currentCreatedAt !== lastAgentStateCreatedAtRef.current;
|
|
452
|
+
if (currentCreatedAt) {
|
|
453
|
+
lastAgentStateCreatedAtRef.current = currentCreatedAt;
|
|
454
|
+
}
|
|
455
|
+
let needUpdateFields = {};
|
|
456
|
+
needUpdateFields.agentState = agentState;
|
|
457
|
+
needUpdateFields.interrupts = agentState?.tasks?.flatMap((task) => {
|
|
458
|
+
return task.interrupts.map((interrupt) => {
|
|
459
|
+
return {
|
|
460
|
+
id: interrupt.id,
|
|
461
|
+
value: interrupt.value,
|
|
462
|
+
role: "ai",
|
|
463
|
+
type: "interrupt"
|
|
464
|
+
};
|
|
465
|
+
});
|
|
466
|
+
});
|
|
467
|
+
needUpdateFields.todos = agentState?.values?.todos;
|
|
449
468
|
setState((prev) => ({
|
|
450
469
|
...prev,
|
|
451
|
-
|
|
452
|
-
interrupts: agentState?.tasks?.flatMap((task) => {
|
|
453
|
-
return task.interrupts.map((interrupt) => {
|
|
454
|
-
return {
|
|
455
|
-
id: interrupt.id,
|
|
456
|
-
value: interrupt.value,
|
|
457
|
-
role: "ai",
|
|
458
|
-
type: "interrupt"
|
|
459
|
-
};
|
|
460
|
-
});
|
|
461
|
-
})
|
|
470
|
+
...needUpdateFields
|
|
462
471
|
}));
|
|
463
472
|
} catch (error) {
|
|
464
473
|
console.warn("Failed to fetch agent state:", error);
|
|
@@ -628,6 +637,15 @@ function AgentThreadProvider({
|
|
|
628
637
|
setState((prev) => ({ ...prev, isLoading: true, error: null }));
|
|
629
638
|
try {
|
|
630
639
|
const agentState = await client.getAgentState(threadId);
|
|
640
|
+
const currentCreatedAt = agentState?.createdAt;
|
|
641
|
+
const needsUpdate = !lastAgentStateCreatedAtRef.current || currentCreatedAt !== lastAgentStateCreatedAtRef.current;
|
|
642
|
+
if (currentCreatedAt) {
|
|
643
|
+
lastAgentStateCreatedAtRef.current = currentCreatedAt;
|
|
644
|
+
}
|
|
645
|
+
let needUpdateFields = {};
|
|
646
|
+
let fetchedMessages = [];
|
|
647
|
+
needUpdateFields.agentState = agentState;
|
|
648
|
+
needUpdateFields.todos = agentState?.values?.todos;
|
|
631
649
|
const interrupts = agentState?.tasks?.flatMap(
|
|
632
650
|
(task) => {
|
|
633
651
|
return task.interrupts.map((interrupt) => {
|
|
@@ -640,15 +658,14 @@ function AgentThreadProvider({
|
|
|
640
658
|
});
|
|
641
659
|
}
|
|
642
660
|
);
|
|
643
|
-
|
|
661
|
+
needUpdateFields.interrupts = interrupts;
|
|
662
|
+
fetchedMessages = await client.getMessages({ threadId });
|
|
663
|
+
needUpdateFields.messages = fetchedMessages;
|
|
644
664
|
chunkMessageMerger.current.reset();
|
|
645
665
|
chunkMessageMerger.current.initialMessages(fetchedMessages);
|
|
646
666
|
setState((prev) => ({
|
|
647
667
|
...prev,
|
|
648
|
-
|
|
649
|
-
interrupts,
|
|
650
|
-
todos: agentState?.values?.todos,
|
|
651
|
-
messages: chunkMessageMerger.current.getMessages(),
|
|
668
|
+
...needUpdateFields,
|
|
652
669
|
isLoading: false
|
|
653
670
|
}));
|
|
654
671
|
if (options.enableResumeStream && fetchedMessages.length > 0) {
|
|
@@ -702,6 +719,7 @@ function AgentThreadProvider({
|
|
|
702
719
|
);
|
|
703
720
|
const clearMessages = (0, import_react3.useCallback)(() => {
|
|
704
721
|
chunkMessageMerger.current.reset();
|
|
722
|
+
lastAgentStateCreatedAtRef.current = null;
|
|
705
723
|
setState((prev) => ({
|
|
706
724
|
...prev,
|
|
707
725
|
messages: [],
|
|
@@ -717,6 +735,7 @@ function AgentThreadProvider({
|
|
|
717
735
|
}, []);
|
|
718
736
|
(0, import_react3.useEffect)(() => {
|
|
719
737
|
if (threadId && clientAssistantId === assistantId) {
|
|
738
|
+
lastAgentStateCreatedAtRef.current = null;
|
|
720
739
|
loadMessages();
|
|
721
740
|
} else {
|
|
722
741
|
clearMessages();
|
|
@@ -3262,17 +3281,17 @@ var useStyle5 = (0, import_antd_style7.createStyles)(({ token, css }) => ({
|
|
|
3262
3281
|
&:hover {
|
|
3263
3282
|
border-color: ${token.colorPrimary};
|
|
3264
3283
|
box-shadow: 0 8px 24px rgba(24, 144, 255, 0.12);
|
|
3265
|
-
transform:
|
|
3284
|
+
transform: translateX(4px);
|
|
3266
3285
|
}
|
|
3267
3286
|
&::before {
|
|
3268
3287
|
content: "";
|
|
3269
3288
|
position: absolute;
|
|
3270
3289
|
top: 0;
|
|
3271
3290
|
left: 0;
|
|
3272
|
-
|
|
3273
|
-
|
|
3291
|
+
bottom: 0;
|
|
3292
|
+
width: 4px;
|
|
3274
3293
|
background: linear-gradient(
|
|
3275
|
-
|
|
3294
|
+
180deg,
|
|
3276
3295
|
${token.colorPrimary} 0%,
|
|
3277
3296
|
${token.colorPrimaryHover} 100%
|
|
3278
3297
|
);
|
|
@@ -3390,7 +3409,7 @@ var TaskCard = ({
|
|
|
3390
3409
|
const { description, subagent_type, assignee } = toolCallData?.args || {};
|
|
3391
3410
|
const status = toolCallData.status || "pending";
|
|
3392
3411
|
const { threadId } = useAgentChat();
|
|
3393
|
-
const subagent_thread_id = (threadId || "") + "
|
|
3412
|
+
const subagent_thread_id = (threadId || "") + "____" + subagent_type + "_" + toolCallData.id;
|
|
3394
3413
|
const getStatusConfig = (status2) => {
|
|
3395
3414
|
switch (status2) {
|
|
3396
3415
|
case "success":
|
|
@@ -3869,7 +3888,8 @@ var Chating = ({
|
|
|
3869
3888
|
uploadAction = "/api/file_storage/upload?path=temp",
|
|
3870
3889
|
showHeader = true,
|
|
3871
3890
|
showSender = true,
|
|
3872
|
-
showHITL = true
|
|
3891
|
+
showHITL = true,
|
|
3892
|
+
showRefreshButton = false
|
|
3873
3893
|
}) => {
|
|
3874
3894
|
const [content, setContent] = (0, import_react18.useState)("");
|
|
3875
3895
|
const [attachedFiles, setAttachedFiles] = (0, import_react18.useState)([]);
|
|
@@ -3881,6 +3901,7 @@ var Chating = ({
|
|
|
3881
3901
|
messages,
|
|
3882
3902
|
sendMessage,
|
|
3883
3903
|
stopStreaming,
|
|
3904
|
+
loadMessages,
|
|
3884
3905
|
isLoading,
|
|
3885
3906
|
error,
|
|
3886
3907
|
interrupts,
|
|
@@ -4022,6 +4043,17 @@ var Chating = ({
|
|
|
4022
4043
|
)
|
|
4023
4044
|
}
|
|
4024
4045
|
);
|
|
4046
|
+
const refreshButton = /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
|
|
4047
|
+
import_antd19.Button,
|
|
4048
|
+
{
|
|
4049
|
+
type: "text",
|
|
4050
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(import_icons11.ReloadOutlined, {}),
|
|
4051
|
+
onClick: () => {
|
|
4052
|
+
loadMessages();
|
|
4053
|
+
}
|
|
4054
|
+
}
|
|
4055
|
+
);
|
|
4056
|
+
const headerExtra = showRefreshButton ? [refreshButton] : [];
|
|
4025
4057
|
return /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(import_jsx_runtime28.Fragment, { children: [
|
|
4026
4058
|
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { children: showHeader && /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
|
|
4027
4059
|
AgentHeader,
|
|
@@ -4029,12 +4061,12 @@ var Chating = ({
|
|
|
4029
4061
|
description,
|
|
4030
4062
|
avatar,
|
|
4031
4063
|
name,
|
|
4032
|
-
extra,
|
|
4064
|
+
extra: extra ? [...extra, ...headerExtra] : headerExtra,
|
|
4033
4065
|
extraMeta
|
|
4034
4066
|
}
|
|
4035
4067
|
) }),
|
|
4036
4068
|
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)(MessageList, { messages, className: styles.messages }),
|
|
4037
|
-
isLoading ? /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", {
|
|
4069
|
+
isLoading ? /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", {}) : /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(import_x4.Prompts, { items: senderPromptsItems, onItemClick: onPromptsItemClick }),
|
|
4038
4070
|
error && /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { style: { padding: "0 16px 8px" }, children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
|
|
4039
4071
|
import_antd19.Alert,
|
|
4040
4072
|
{
|
|
@@ -4089,6 +4121,7 @@ var TaskDetail = ({ data, component_key, interactive = true }) => {
|
|
|
4089
4121
|
children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { style: { overflow: "hidden" }, children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
4090
4122
|
Chating,
|
|
4091
4123
|
{
|
|
4124
|
+
showRefreshButton: true,
|
|
4092
4125
|
name: subagent_type,
|
|
4093
4126
|
showHeader: true,
|
|
4094
4127
|
showSender: false,
|