@axiom-lattice/react-sdk 2.1.8 → 2.1.10
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 +72 -34
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +77 -35
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.mjs
CHANGED
|
@@ -396,15 +396,21 @@ function AgentThreadProvider({
|
|
|
396
396
|
});
|
|
397
397
|
const stopStreamingRef = useRef2(null);
|
|
398
398
|
const chunkMessageMerger = useRef2(createSimpleMessageMerger2());
|
|
399
|
+
const lastAgentStateCreatedAtRef = useRef2(null);
|
|
399
400
|
const fetchAndUpdateAgentState = useCallback2(
|
|
400
401
|
async (threadId2) => {
|
|
401
402
|
if (!options.enableReturnStateWhenStreamCompleted) return;
|
|
402
403
|
try {
|
|
403
404
|
const agentState = await client.getAgentState(threadId2);
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
405
|
+
const currentCreatedAt = agentState?.createdAt;
|
|
406
|
+
const needsUpdate = !lastAgentStateCreatedAtRef.current || currentCreatedAt !== lastAgentStateCreatedAtRef.current;
|
|
407
|
+
if (currentCreatedAt) {
|
|
408
|
+
lastAgentStateCreatedAtRef.current = currentCreatedAt;
|
|
409
|
+
}
|
|
410
|
+
let needUpdateFields = {};
|
|
411
|
+
if (needsUpdate) {
|
|
412
|
+
needUpdateFields.agentState = agentState;
|
|
413
|
+
needUpdateFields.interrupts = agentState?.tasks?.flatMap((task) => {
|
|
408
414
|
return task.interrupts.map((interrupt) => {
|
|
409
415
|
return {
|
|
410
416
|
id: interrupt.id,
|
|
@@ -413,7 +419,12 @@ function AgentThreadProvider({
|
|
|
413
419
|
type: "interrupt"
|
|
414
420
|
};
|
|
415
421
|
});
|
|
416
|
-
})
|
|
422
|
+
});
|
|
423
|
+
needUpdateFields.todos = agentState?.values?.todos;
|
|
424
|
+
}
|
|
425
|
+
setState((prev) => ({
|
|
426
|
+
...prev,
|
|
427
|
+
...needUpdateFields
|
|
417
428
|
}));
|
|
418
429
|
} catch (error) {
|
|
419
430
|
console.warn("Failed to fetch agent state:", error);
|
|
@@ -583,27 +594,39 @@ function AgentThreadProvider({
|
|
|
583
594
|
setState((prev) => ({ ...prev, isLoading: true, error: null }));
|
|
584
595
|
try {
|
|
585
596
|
const agentState = await client.getAgentState(threadId);
|
|
586
|
-
const
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
597
|
+
const currentCreatedAt = agentState?.createdAt;
|
|
598
|
+
const needsUpdate = !lastAgentStateCreatedAtRef.current || currentCreatedAt !== lastAgentStateCreatedAtRef.current;
|
|
599
|
+
if (currentCreatedAt) {
|
|
600
|
+
lastAgentStateCreatedAtRef.current = currentCreatedAt;
|
|
601
|
+
}
|
|
602
|
+
let needUpdateFields = {};
|
|
603
|
+
let fetchedMessages = [];
|
|
604
|
+
if (needsUpdate) {
|
|
605
|
+
needUpdateFields.agentState = agentState;
|
|
606
|
+
needUpdateFields.todos = agentState?.values?.todos;
|
|
607
|
+
const interrupts = agentState?.tasks?.flatMap(
|
|
608
|
+
(task) => {
|
|
609
|
+
return task.interrupts.map((interrupt) => {
|
|
610
|
+
return {
|
|
611
|
+
id: interrupt.id,
|
|
612
|
+
value: interrupt.value,
|
|
613
|
+
role: "ai",
|
|
614
|
+
type: "interrupt"
|
|
615
|
+
};
|
|
616
|
+
});
|
|
617
|
+
}
|
|
618
|
+
);
|
|
619
|
+
needUpdateFields.interrupts = interrupts;
|
|
620
|
+
fetchedMessages = await client.getMessages({ threadId });
|
|
621
|
+
needUpdateFields.messages = fetchedMessages;
|
|
622
|
+
chunkMessageMerger.current.reset();
|
|
623
|
+
chunkMessageMerger.current.initialMessages(fetchedMessages);
|
|
624
|
+
} else {
|
|
625
|
+
fetchedMessages = chunkMessageMerger.current.getMessages();
|
|
626
|
+
}
|
|
601
627
|
setState((prev) => ({
|
|
602
628
|
...prev,
|
|
603
|
-
|
|
604
|
-
interrupts,
|
|
605
|
-
todos: agentState?.values?.todos,
|
|
606
|
-
messages: chunkMessageMerger.current.getMessages(),
|
|
629
|
+
...needUpdateFields,
|
|
607
630
|
isLoading: false
|
|
608
631
|
}));
|
|
609
632
|
if (options.enableResumeStream && fetchedMessages.length > 0) {
|
|
@@ -657,6 +680,7 @@ function AgentThreadProvider({
|
|
|
657
680
|
);
|
|
658
681
|
const clearMessages = useCallback2(() => {
|
|
659
682
|
chunkMessageMerger.current.reset();
|
|
683
|
+
lastAgentStateCreatedAtRef.current = null;
|
|
660
684
|
setState((prev) => ({
|
|
661
685
|
...prev,
|
|
662
686
|
messages: [],
|
|
@@ -671,7 +695,8 @@ function AgentThreadProvider({
|
|
|
671
695
|
}));
|
|
672
696
|
}, []);
|
|
673
697
|
useEffect3(() => {
|
|
674
|
-
if (threadId) {
|
|
698
|
+
if (threadId && clientAssistantId === assistantId) {
|
|
699
|
+
lastAgentStateCreatedAtRef.current = null;
|
|
675
700
|
loadMessages();
|
|
676
701
|
} else {
|
|
677
702
|
clearMessages();
|
|
@@ -682,7 +707,7 @@ function AgentThreadProvider({
|
|
|
682
707
|
stopStreamingRef.current = null;
|
|
683
708
|
}
|
|
684
709
|
};
|
|
685
|
-
}, [threadId, loadMessages, clearMessages]);
|
|
710
|
+
}, [threadId, loadMessages, clearMessages, clientAssistantId, assistantId]);
|
|
686
711
|
const value = {
|
|
687
712
|
state,
|
|
688
713
|
sendMessage,
|
|
@@ -3259,17 +3284,17 @@ var useStyle5 = createStyles7(({ token, css }) => ({
|
|
|
3259
3284
|
&:hover {
|
|
3260
3285
|
border-color: ${token.colorPrimary};
|
|
3261
3286
|
box-shadow: 0 8px 24px rgba(24, 144, 255, 0.12);
|
|
3262
|
-
transform:
|
|
3287
|
+
transform: translateX(4px);
|
|
3263
3288
|
}
|
|
3264
3289
|
&::before {
|
|
3265
3290
|
content: "";
|
|
3266
3291
|
position: absolute;
|
|
3267
3292
|
top: 0;
|
|
3268
3293
|
left: 0;
|
|
3269
|
-
|
|
3270
|
-
|
|
3294
|
+
bottom: 0;
|
|
3295
|
+
width: 4px;
|
|
3271
3296
|
background: linear-gradient(
|
|
3272
|
-
|
|
3297
|
+
180deg,
|
|
3273
3298
|
${token.colorPrimary} 0%,
|
|
3274
3299
|
${token.colorPrimaryHover} 100%
|
|
3275
3300
|
);
|
|
@@ -3387,7 +3412,7 @@ var TaskCard = ({
|
|
|
3387
3412
|
const { description, subagent_type, assignee } = toolCallData?.args || {};
|
|
3388
3413
|
const status = toolCallData.status || "pending";
|
|
3389
3414
|
const { threadId } = useAgentChat();
|
|
3390
|
-
const subagent_thread_id = (threadId || "") + "
|
|
3415
|
+
const subagent_thread_id = (threadId || "") + "____" + subagent_type + "_" + toolCallData.id;
|
|
3391
3416
|
const getStatusConfig = (status2) => {
|
|
3392
3417
|
switch (status2) {
|
|
3393
3418
|
case "success":
|
|
@@ -3485,7 +3510,11 @@ var TaskCard = ({
|
|
|
3485
3510
|
import { Typography as Typography12 } from "antd";
|
|
3486
3511
|
|
|
3487
3512
|
// src/components/Chat/Chating.tsx
|
|
3488
|
-
import {
|
|
3513
|
+
import {
|
|
3514
|
+
CloudUploadOutlined,
|
|
3515
|
+
PaperClipOutlined,
|
|
3516
|
+
ReloadOutlined
|
|
3517
|
+
} from "@ant-design/icons";
|
|
3489
3518
|
import {
|
|
3490
3519
|
Attachments,
|
|
3491
3520
|
Bubble as Bubble2,
|
|
@@ -3888,7 +3917,8 @@ var Chating = ({
|
|
|
3888
3917
|
uploadAction = "/api/file_storage/upload?path=temp",
|
|
3889
3918
|
showHeader = true,
|
|
3890
3919
|
showSender = true,
|
|
3891
|
-
showHITL = true
|
|
3920
|
+
showHITL = true,
|
|
3921
|
+
showRefreshButton = false
|
|
3892
3922
|
}) => {
|
|
3893
3923
|
const [content, setContent] = useState16("");
|
|
3894
3924
|
const [attachedFiles, setAttachedFiles] = useState16([]);
|
|
@@ -3900,6 +3930,7 @@ var Chating = ({
|
|
|
3900
3930
|
messages,
|
|
3901
3931
|
sendMessage,
|
|
3902
3932
|
stopStreaming,
|
|
3933
|
+
loadMessages,
|
|
3903
3934
|
isLoading,
|
|
3904
3935
|
error,
|
|
3905
3936
|
interrupts,
|
|
@@ -4041,6 +4072,17 @@ var Chating = ({
|
|
|
4041
4072
|
)
|
|
4042
4073
|
}
|
|
4043
4074
|
);
|
|
4075
|
+
const refreshButton = /* @__PURE__ */ jsx28(
|
|
4076
|
+
Button10,
|
|
4077
|
+
{
|
|
4078
|
+
type: "text",
|
|
4079
|
+
icon: /* @__PURE__ */ jsx28(ReloadOutlined, {}),
|
|
4080
|
+
onClick: () => {
|
|
4081
|
+
loadMessages();
|
|
4082
|
+
}
|
|
4083
|
+
}
|
|
4084
|
+
);
|
|
4085
|
+
const headerExtra = showRefreshButton ? [refreshButton] : [];
|
|
4044
4086
|
return /* @__PURE__ */ jsxs17(Fragment4, { children: [
|
|
4045
4087
|
/* @__PURE__ */ jsx28("div", { children: showHeader && /* @__PURE__ */ jsx28(
|
|
4046
4088
|
AgentHeader,
|
|
@@ -4048,7 +4090,7 @@ var Chating = ({
|
|
|
4048
4090
|
description,
|
|
4049
4091
|
avatar,
|
|
4050
4092
|
name,
|
|
4051
|
-
extra,
|
|
4093
|
+
extra: extra ? [...extra, ...headerExtra] : headerExtra,
|
|
4052
4094
|
extraMeta
|
|
4053
4095
|
}
|
|
4054
4096
|
) }),
|
|
@@ -4108,7 +4150,7 @@ var TaskDetail = ({ data, component_key, interactive = true }) => {
|
|
|
4108
4150
|
children: /* @__PURE__ */ jsx29("div", { style: { overflow: "hidden" }, children: /* @__PURE__ */ jsx29(
|
|
4109
4151
|
Chating,
|
|
4110
4152
|
{
|
|
4111
|
-
|
|
4153
|
+
showRefreshButton: true,
|
|
4112
4154
|
name: subagent_type,
|
|
4113
4155
|
showHeader: true,
|
|
4114
4156
|
showSender: false,
|