@blocksdiy/react-common 1.12.0 → 1.14.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.
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { type UIMessage } from "ai";
|
|
2
1
|
import { ReactNode, SetStateAction } from "react";
|
|
3
2
|
import { type VoiceCallMessage } from "../hooks/use-voice-call.js";
|
|
4
3
|
export interface Attachment {
|
|
@@ -13,8 +12,7 @@ type MessageType = "progress" | "text" | "missing_integration";
|
|
|
13
12
|
*
|
|
14
13
|
* Consumers of `@blocksdiy/react-common/agent-chat` currently read `msg.content`,
|
|
15
14
|
* `msg.role` (`human`/`ai`), `msg.attachments`, and the flattened compatibility
|
|
16
|
-
* fields returned from `AgentChatContextValue.messages`. Keep this shape stable
|
|
17
|
-
* while the runtime underneath moves to AI SDK `UIMessage` objects.
|
|
15
|
+
* fields returned from `AgentChatContextValue.messages`. Keep this shape stable.
|
|
18
16
|
*/
|
|
19
17
|
export interface LegacyMessagePayload {
|
|
20
18
|
id: string;
|
|
@@ -26,12 +24,30 @@ export interface LegacyMessagePayload {
|
|
|
26
24
|
payload: Record<string, any>;
|
|
27
25
|
hiddenContent?: string;
|
|
28
26
|
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
27
|
+
type CopilotMessageMetadata = {
|
|
28
|
+
version?: 1;
|
|
29
|
+
hiddenPrompt?: string;
|
|
30
|
+
};
|
|
31
|
+
type CopilotToolCall = {
|
|
32
|
+
id?: string;
|
|
33
|
+
name?: string;
|
|
34
|
+
args?: unknown;
|
|
35
|
+
input?: unknown;
|
|
36
|
+
function?: {
|
|
37
|
+
name?: string;
|
|
38
|
+
arguments?: unknown;
|
|
32
39
|
};
|
|
33
40
|
};
|
|
34
|
-
|
|
41
|
+
type CopilotMessage = {
|
|
42
|
+
id?: string;
|
|
43
|
+
role?: string;
|
|
44
|
+
content?: string;
|
|
45
|
+
metadata?: CopilotMessageMetadata;
|
|
46
|
+
toolCalls?: CopilotToolCall[];
|
|
47
|
+
toolCallId?: string;
|
|
48
|
+
name?: string;
|
|
49
|
+
};
|
|
50
|
+
export type PersistedMessagePayload = LegacyMessagePayload | CopilotMessage;
|
|
35
51
|
interface MessageItemBase {
|
|
36
52
|
createdAt: string;
|
|
37
53
|
createdBy?: string;
|
|
@@ -42,10 +58,7 @@ interface MessageItemBase {
|
|
|
42
58
|
export type LegacyMessageItem = MessageItemBase & {
|
|
43
59
|
msg: LegacyMessagePayload;
|
|
44
60
|
};
|
|
45
|
-
export type
|
|
46
|
-
msg: V1AiSdkMessagePayload;
|
|
47
|
-
};
|
|
48
|
-
export type MessageItem = LegacyMessageItem | V1AiSdkMessageItem;
|
|
61
|
+
export type MessageItem = LegacyMessageItem;
|
|
49
62
|
export interface AgentChatContextValue {
|
|
50
63
|
messages: MessageItem[];
|
|
51
64
|
attachments: Attachment[];
|
|
@@ -74,15 +87,6 @@ export interface AgentChatContextValue {
|
|
|
74
87
|
chatId?: string;
|
|
75
88
|
noPersistency?: boolean;
|
|
76
89
|
}
|
|
77
|
-
export type AgentChatUIMessage = UIMessage & {
|
|
78
|
-
metadata?: {
|
|
79
|
-
version?: 1;
|
|
80
|
-
hiddenPrompt?: string;
|
|
81
|
-
};
|
|
82
|
-
};
|
|
83
|
-
export declare const isV1AiSdkMessageItem: (message: MessageItem) => message is V1AiSdkMessageItem;
|
|
84
|
-
export declare const isLegacyMessageItem: (message: MessageItem) => message is LegacyMessageItem;
|
|
85
|
-
export declare const uiMessageToV1MessageItem: (message: AgentChatUIMessage, createdAt?: string) => V1AiSdkMessageItem;
|
|
86
90
|
export declare const useAgentChat: () => AgentChatContextValue;
|
|
87
91
|
export interface ToolCardContextValue {
|
|
88
92
|
open: boolean;
|
|
@@ -184,7 +188,7 @@ export interface AgentChatMessageProps {
|
|
|
184
188
|
message: MessageItem;
|
|
185
189
|
index: number;
|
|
186
190
|
}
|
|
187
|
-
export declare function AgentChatMessage({ message, index, ...props }: React.ComponentProps<"div"> & AgentChatMessageProps): import("react/jsx-runtime").JSX.Element
|
|
191
|
+
export declare function AgentChatMessage({ message, index, ...props }: React.ComponentProps<"div"> & AgentChatMessageProps): import("react/jsx-runtime").JSX.Element;
|
|
188
192
|
export interface AgentChatMessagesProps {
|
|
189
193
|
asChild?: boolean;
|
|
190
194
|
autoScroll?: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-chat.d.ts","sourceRoot":"","sources":["../../src/components/agent-chat.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"agent-chat.d.ts","sourceRoot":"","sources":["../../src/components/agent-chat.tsx"],"names":[],"mappings":"AAMA,OAAO,EAEL,SAAS,EACT,cAAc,EAOf,MAAM,OAAO,CAAC;AAEf,OAAO,EAAgB,KAAK,gBAAgB,EAA4B,MAAM,yBAAyB,CAAC;AAYxG,MAAM,WAAW,UAAU;IACzB,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAqBD,MAAM,MAAM,WAAW,GAAG,OAAO,GAAG,IAAI,CAAC;AACzC,KAAK,WAAW,GAAG,UAAU,GAAG,MAAM,GAAG,qBAAqB,CAAC;AAE/D;;;;;;GAMG;AACH,MAAM,WAAW,oBAAoB;IACnC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,WAAW,CAAC;IAClB,WAAW,CAAC,EAAE,UAAU,EAAE,CAAC;IAC3B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,WAAW,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC7B,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,KAAK,sBAAsB,GAAG;IAC5B,OAAO,CAAC,EAAE,CAAC,CAAC;IACZ,YAAY,CAAC,EAAE,MAAM,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ACR,GAAG,KAAK,EACT,EAAE,KAAK,CAAC,cAAc,CAAC,QAAQ,CAAC,GAAG,+BAA+B,2CAelE;AAED,MAAM,WAAW,6BAA6B;IAC5C,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,wBAAgB,wBAAwB,CAAC,EACvC,OAAe,EACf,OAAO,EACP,QAAQ,EACR,GAAG,KAAK,EACT,EAAE,KAAK,CAAC,cAAc,CAAC,QAAQ,CAAC,GAAG,6BAA6B,2CAehE;AAED,MAAM,WAAW,8BAA8B;IAC7C,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,wBAAgB,yBAAyB,CAAC,EACxC,OAAe,EACf,OAAO,EACP,QAAQ,EACR,GAAG,KAAK,EACT,EAAE,KAAK,CAAC,cAAc,CAAC,QAAQ,CAAC,GAAG,8BAA8B,2CAiBjE;AAED,MAAM,WAAW,yBAAyB;IACxC,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,wBAAgB,oBAAoB,CAAC,EACnC,OAAe,EACf,GAAG,KAAK,EACT,EAAE,KAAK,CAAC,cAAc,CAAC,KAAK,CAAC,GAAG,yBAAyB,2CAezD;AAED,MAAM,WAAW,yBAAyB;IACxC,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,wBAAgB,oBAAoB,CAAC,EACnC,OAAe,EACf,KAAK,EACL,GAAG,KAAK,EACT,EAAE,KAAK,CAAC,cAAc,CAAC,KAAK,CAAC,GAAG,yBAAyB,2CAiBzD"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
2
|
+
import { HttpAgent } from "@ag-ui/client";
|
|
3
3
|
import { AppVersionService, BlocksApiService, DataApiService, websocketsService } from "@blocksdiy/blocks-client-api";
|
|
4
4
|
import { getApiHost } from "@blocksdiy/blocks-client-api/envService";
|
|
5
5
|
import { WorkflowRequest } from "@blocksdiy/blocks-client-api/workflowService";
|
|
6
|
+
import { CopilotKit, useCopilotChatInternal } from "@copilotkit/react-core";
|
|
6
7
|
import { Slot } from "@radix-ui/react-slot";
|
|
7
|
-
import { DefaultChatTransport } from "ai";
|
|
8
8
|
import { createContext, useCallback, useContext, useEffect, useMemo, useRef, useState, } from "react";
|
|
9
9
|
import { useVoiceCall } from "../hooks/use-voice-call.js";
|
|
10
10
|
/* public decouple - blocks common */
|
|
@@ -36,77 +36,89 @@ const generateId = (length = 10) => {
|
|
|
36
36
|
.toString(36)
|
|
37
37
|
.substring(2, 2 + length);
|
|
38
38
|
};
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
url: attachment.url,
|
|
45
|
-
filename: attachment.fileName,
|
|
46
|
-
mediaType: attachment.fileType,
|
|
47
|
-
}));
|
|
48
|
-
const uiMessageToLegacyPayload = (message) => {
|
|
49
|
-
const text = message.parts
|
|
50
|
-
.filter((part) => part.type === "text")
|
|
51
|
-
.map((part) => part.text)
|
|
52
|
-
.join("");
|
|
53
|
-
const attachments = message.parts
|
|
54
|
-
.filter((part) => part.type === "file")
|
|
55
|
-
.map((part) => ({
|
|
56
|
-
url: part.url,
|
|
57
|
-
fileName: part.filename ?? "File",
|
|
58
|
-
fileType: part.mediaType ?? "application/octet-stream",
|
|
59
|
-
}));
|
|
60
|
-
if (!text && attachments.length === 0) {
|
|
61
|
-
return null;
|
|
39
|
+
class BlocksCopilotHttpAgent extends HttpAgent {
|
|
40
|
+
requestHeaders = {};
|
|
41
|
+
requestBody = {};
|
|
42
|
+
constructor({ url }) {
|
|
43
|
+
super({ url, headers: {} });
|
|
62
44
|
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
type: "text",
|
|
67
|
-
content: text,
|
|
68
|
-
attachments: attachments.length > 0 ? attachments : undefined,
|
|
69
|
-
hiddenContent: message.metadata?.hiddenPrompt,
|
|
70
|
-
payload: {},
|
|
71
|
-
};
|
|
72
|
-
};
|
|
73
|
-
const messageItemToLegacyPayload = (message) => {
|
|
74
|
-
if (isLegacyMessageItem(message)) {
|
|
75
|
-
return message.msg;
|
|
45
|
+
setRequestOptions({ headers, body }) {
|
|
46
|
+
this.requestHeaders = headers;
|
|
47
|
+
this.requestBody = body;
|
|
76
48
|
}
|
|
77
|
-
|
|
78
|
-
};
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
49
|
+
clearRequestOptions() {
|
|
50
|
+
this.requestHeaders = {};
|
|
51
|
+
this.requestBody = {};
|
|
52
|
+
}
|
|
53
|
+
requestInit(input) {
|
|
54
|
+
const init = super.requestInit({ ...input, ...this.requestBody });
|
|
55
|
+
return {
|
|
56
|
+
...init,
|
|
57
|
+
headers: {
|
|
58
|
+
...init.headers,
|
|
59
|
+
...this.requestHeaders,
|
|
60
|
+
},
|
|
61
|
+
};
|
|
82
62
|
}
|
|
63
|
+
}
|
|
64
|
+
const parseMaybeJson = (value) => {
|
|
65
|
+
if (typeof value !== "string") {
|
|
66
|
+
return value;
|
|
67
|
+
}
|
|
68
|
+
try {
|
|
69
|
+
return JSON.parse(value);
|
|
70
|
+
}
|
|
71
|
+
catch {
|
|
72
|
+
return value;
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
const legacyPayloadToCopilotMessage = (message) => ({
|
|
76
|
+
id: message.id,
|
|
77
|
+
role: message.role === "human" ? "user" : "assistant",
|
|
78
|
+
content: message.content ?? "",
|
|
79
|
+
metadata: {
|
|
80
|
+
version: 1,
|
|
81
|
+
hiddenPrompt: message.hiddenContent,
|
|
82
|
+
},
|
|
83
|
+
});
|
|
84
|
+
const messageItemToCopilotMessage = (message) => {
|
|
85
|
+
return legacyPayloadToCopilotMessage(message.msg);
|
|
86
|
+
};
|
|
87
|
+
const normalizeCopilotToolCall = (toolCall, allMessages) => {
|
|
88
|
+
const toolCallId = toolCall.id;
|
|
89
|
+
const toolName = toolCall.function?.name ?? toolCall.name ?? "tool";
|
|
90
|
+
const toolResult = toolCallId
|
|
91
|
+
? allMessages.find((candidate) => candidate.role === "tool" && candidate.toolCallId === toolCallId)
|
|
92
|
+
: undefined;
|
|
83
93
|
return {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
},
|
|
94
|
+
...toolCall,
|
|
95
|
+
type: `tool-${toolName}`,
|
|
96
|
+
toolCallId,
|
|
97
|
+
toolName,
|
|
98
|
+
state: toolResult ? "output-available" : "input-available",
|
|
99
|
+
input: parseMaybeJson(toolCall.function?.arguments ?? toolCall.args ?? toolCall.input),
|
|
100
|
+
...(toolResult ? { output: parseMaybeJson(toolResult.content) } : {}),
|
|
91
101
|
};
|
|
92
102
|
};
|
|
93
|
-
|
|
103
|
+
const copilotMessageToLegacyPayload = (message, allMessages = []) => {
|
|
104
|
+
if (!message.id || (message.role !== "user" && message.role !== "assistant")) {
|
|
105
|
+
return null;
|
|
106
|
+
}
|
|
107
|
+
const toolCalls = message.toolCalls?.map((toolCall) => normalizeCopilotToolCall(toolCall, allMessages)) ?? [];
|
|
94
108
|
return {
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
109
|
+
id: message.id,
|
|
110
|
+
role: message.role === "user" ? "human" : "ai",
|
|
111
|
+
type: "text",
|
|
112
|
+
content: message.content ?? "",
|
|
113
|
+
hiddenContent: message.metadata?.hiddenPrompt,
|
|
114
|
+
payload: toolCalls.length ? { toolCalls } : {},
|
|
100
115
|
};
|
|
101
116
|
};
|
|
102
|
-
const
|
|
117
|
+
const messageItemToLegacyPayload = (message) => message.msg;
|
|
118
|
+
const appendCopilotErrorMessage = (messages, error) => {
|
|
103
119
|
const text = "Error: " + (error instanceof Error ? error.message : "Unknown error");
|
|
104
120
|
const lastMessage = messages[messages.length - 1];
|
|
105
|
-
|
|
106
|
-
?.filter((part) => part.type === "text")
|
|
107
|
-
.map((part) => part.text)
|
|
108
|
-
.join("");
|
|
109
|
-
if (lastMessage?.role === "assistant" && lastText === text) {
|
|
121
|
+
if (lastMessage?.role === "assistant" && lastMessage.content === text) {
|
|
110
122
|
return messages;
|
|
111
123
|
}
|
|
112
124
|
return [
|
|
@@ -114,22 +126,33 @@ const appendAiSdkErrorMessage = (messages, error) => {
|
|
|
114
126
|
{
|
|
115
127
|
id: generateId(10),
|
|
116
128
|
role: "assistant",
|
|
117
|
-
|
|
129
|
+
content: text,
|
|
118
130
|
metadata: { version: 1 },
|
|
119
131
|
},
|
|
120
132
|
];
|
|
121
133
|
};
|
|
122
134
|
const storedMessageToLegacyView = (message) => {
|
|
123
|
-
if (
|
|
135
|
+
if ("type" in message.msg) {
|
|
136
|
+
return message;
|
|
137
|
+
}
|
|
138
|
+
const legacyPayload = copilotMessageToLegacyPayload(message.msg);
|
|
139
|
+
if (legacyPayload) {
|
|
124
140
|
return {
|
|
125
|
-
...
|
|
141
|
+
...message,
|
|
126
142
|
createdAt: message.createdAt,
|
|
127
|
-
|
|
128
|
-
chatId: message.chatId,
|
|
129
|
-
threadId: message.threadId,
|
|
143
|
+
msg: legacyPayload,
|
|
130
144
|
};
|
|
131
145
|
}
|
|
132
|
-
return
|
|
146
|
+
return {
|
|
147
|
+
...message,
|
|
148
|
+
msg: {
|
|
149
|
+
id: message.msg.id ?? generateId(),
|
|
150
|
+
role: "ai",
|
|
151
|
+
type: "text",
|
|
152
|
+
content: "",
|
|
153
|
+
payload: {},
|
|
154
|
+
},
|
|
155
|
+
};
|
|
133
156
|
};
|
|
134
157
|
export const useAgentChat = () => {
|
|
135
158
|
const context = useContext(AgentChatContext);
|
|
@@ -302,7 +325,7 @@ const resolveAgentChatConfig = async ({ agentChatId, token, }) => {
|
|
|
302
325
|
},
|
|
303
326
|
};
|
|
304
327
|
};
|
|
305
|
-
const flattenLegacyMessages = (messages) => messages.map((m) => (
|
|
328
|
+
const flattenLegacyMessages = (messages) => messages.map((m) => ({ ...m, ...m.msg }));
|
|
306
329
|
const createInitialAgentMessages = (initialMessages = []) => initialMessages.map((initialMessage) => {
|
|
307
330
|
const id = generateId();
|
|
308
331
|
return {
|
|
@@ -471,7 +494,7 @@ export const AgentChatRoot = ({ appId, token, agentBlockId, agentHarness, useAge
|
|
|
471
494
|
fetchedMessages,
|
|
472
495
|
};
|
|
473
496
|
if (isNewAgent) {
|
|
474
|
-
return _jsx(
|
|
497
|
+
return _jsx(CopilotAgentChatRootProvider, { ...commonProps });
|
|
475
498
|
}
|
|
476
499
|
return _jsx(LegacyAgentChatProvider, { ...commonProps });
|
|
477
500
|
};
|
|
@@ -598,50 +621,44 @@ function LegacyAgentChatProvider({ appId, token, agentChatId, children, chatId,
|
|
|
598
621
|
const inputState = useAgentChatInputState({ isThinking, isFetchingMessages, sendMessage });
|
|
599
622
|
return (_jsx(AgentChatContextProvider, { ...inputState, messages: flattenLegacyMessages(messages), isThinking: isThinking, isFetchingMessages: isFetchingMessages, currentThreadId: currentThreadId, agentChatData: agentChatData, sendMessage: sendMessage, addMessages: addMessages, setCurrentThreadId: setCurrentThreadId, appId: appId, token: token, agentChatId: agentChatId, chatId: chatId, noPersistency: noPersistency, children: children }));
|
|
600
623
|
}
|
|
601
|
-
function
|
|
624
|
+
function CopilotAgentChatRootProvider({ appId, token, ...props }) {
|
|
625
|
+
const copilotRuntimeUrl = `${getApiHost()}/agent-chat-stream`;
|
|
626
|
+
const agent = useMemo(() => new BlocksCopilotHttpAgent({ url: copilotRuntimeUrl }), [copilotRuntimeUrl]);
|
|
627
|
+
const agents = useMemo(() => ({ default: agent }), [agent]);
|
|
628
|
+
return (_jsx(CopilotKit, { runtimeUrl: copilotRuntimeUrl, agents__unsafe_dev_only: agents, children: _jsx(CopilotAgentChatProvider, { ...props, appId: appId, token: token, copilotAgent: agent }) }));
|
|
629
|
+
}
|
|
630
|
+
function CopilotAgentChatProvider({ appId, token, agentBlockId, agentChatId, children, chatId, noPersistency, currentThreadId, chatContext, chatContextFiles, agentChatData, shortTermMemory = { isEnabled: true, isPersistent: false }, isFetchingMessages, setCurrentThreadId, fetchedMessages, copilotAgent, }) {
|
|
602
631
|
const [externalMessages, setExternalMessages] = useState([]);
|
|
603
|
-
const
|
|
604
|
-
const
|
|
605
|
-
const
|
|
606
|
-
|
|
607
|
-
credentials: "include",
|
|
608
|
-
prepareSendMessagesRequest: ({ body, id, messages, trigger, messageId }) => {
|
|
609
|
-
const submittedMessage = messages[messages.length - 1];
|
|
610
|
-
const requestMessages = Array.isArray(body?.messages) ? body.messages : [];
|
|
611
|
-
return {
|
|
612
|
-
body: {
|
|
613
|
-
...body,
|
|
614
|
-
id,
|
|
615
|
-
trigger,
|
|
616
|
-
messages: submittedMessage ? [...requestMessages, submittedMessage] : requestMessages,
|
|
617
|
-
...(messageId ? { messageId } : {}),
|
|
618
|
-
},
|
|
619
|
-
};
|
|
620
|
-
},
|
|
621
|
-
}), []);
|
|
622
|
-
const aiChatId = useMemo(() => [appId, agentChatId, chatId, currentThreadId].filter(Boolean).join(":"), [appId, agentChatId, chatId, currentThreadId]);
|
|
623
|
-
const { messages: aiMessages, sendMessage: sendAiSdkMessage, setMessages: setAiMessages, status: aiChatStatus, } = useChat({
|
|
624
|
-
id: aiChatId,
|
|
625
|
-
transport: aiChatTransport,
|
|
626
|
-
onError: (error) => {
|
|
627
|
-
setAiMessages((prev) => appendAiSdkErrorMessage(prev, error));
|
|
628
|
-
},
|
|
629
|
-
});
|
|
632
|
+
const copilotMessageCreatedAtByIdRef = useRef({});
|
|
633
|
+
const previousCopilotChatIdRef = useRef(undefined);
|
|
634
|
+
const copilotChatId = useMemo(() => [appId, agentChatId, chatId, currentThreadId].filter(Boolean).join(":"), [appId, agentChatId, chatId, currentThreadId]);
|
|
635
|
+
const { messages: copilotMessages, sendMessage: sendCopilotMessage, setMessages: setCopilotMessages, isLoading: isCopilotLoading, } = useCopilotChatInternal();
|
|
630
636
|
useEffect(() => {
|
|
631
|
-
if (
|
|
637
|
+
if (previousCopilotChatIdRef.current === copilotChatId) {
|
|
632
638
|
return;
|
|
633
639
|
}
|
|
634
|
-
|
|
635
|
-
|
|
640
|
+
previousCopilotChatIdRef.current = copilotChatId;
|
|
641
|
+
copilotMessageCreatedAtByIdRef.current = {};
|
|
636
642
|
setExternalMessages([]);
|
|
637
|
-
|
|
638
|
-
}, [
|
|
643
|
+
setCopilotMessages([]);
|
|
644
|
+
}, [copilotChatId, setCopilotMessages]);
|
|
645
|
+
const copilotMessageItems = useMemo(() => copilotMessages
|
|
646
|
+
.map((message) => {
|
|
647
|
+
const legacyPayload = copilotMessageToLegacyPayload(message, copilotMessages);
|
|
648
|
+
if (!legacyPayload) {
|
|
649
|
+
return null;
|
|
650
|
+
}
|
|
651
|
+
copilotMessageCreatedAtByIdRef.current[legacyPayload.id] ??= new Date().toISOString();
|
|
652
|
+
return {
|
|
653
|
+
createdAt: copilotMessageCreatedAtByIdRef.current[legacyPayload.id],
|
|
654
|
+
msg: legacyPayload,
|
|
655
|
+
};
|
|
656
|
+
})
|
|
657
|
+
.filter((message) => Boolean(message)), [copilotMessages]);
|
|
639
658
|
const messages = useMemo(() => {
|
|
640
659
|
const fetchedMessageItems = fetchedMessages.map(storedMessageToLegacyView);
|
|
641
660
|
const nextMessages = mergeMessageItemsById(fetchedMessageItems, externalMessages);
|
|
642
|
-
for (const
|
|
643
|
-
aiMessageCreatedAtByIdRef.current[aiMessage.id] ??= new Date().toISOString();
|
|
644
|
-
const messageItem = uiMessageToV1MessageItem(aiMessage, aiMessageCreatedAtByIdRef.current[aiMessage.id]);
|
|
661
|
+
for (const messageItem of copilotMessageItems) {
|
|
645
662
|
const existingIndex = nextMessages.findIndex((message) => message.msg.id === messageItem.msg.id);
|
|
646
663
|
if (existingIndex !== -1) {
|
|
647
664
|
nextMessages[existingIndex] = {
|
|
@@ -656,26 +673,30 @@ function AiSdkAgentChatProvider({ appId, token, agentBlockId, agentChatId, child
|
|
|
656
673
|
}
|
|
657
674
|
nextMessages.sort((a, b) => Date.parse(a.createdAt) - Date.parse(b.createdAt));
|
|
658
675
|
return nextMessages;
|
|
659
|
-
}, [
|
|
660
|
-
const isThinking =
|
|
676
|
+
}, [copilotMessageItems, externalMessages, fetchedMessages]);
|
|
677
|
+
const isThinking = isCopilotLoading;
|
|
661
678
|
const addExternalMessages = useCallback((messagesToAdd) => {
|
|
662
679
|
const normalizedMessages = messagesToAdd.map(storedMessageToLegacyView);
|
|
663
680
|
setExternalMessages((prevMessages) => mergeMessageItemsById(prevMessages, normalizedMessages));
|
|
664
681
|
}, []);
|
|
665
|
-
const
|
|
666
|
-
|
|
667
|
-
}, [
|
|
682
|
+
const addCopilotErrorMessage = useCallback((error) => {
|
|
683
|
+
setCopilotMessages(appendCopilotErrorMessage(copilotMessages, error));
|
|
684
|
+
}, [copilotMessages, setCopilotMessages]);
|
|
668
685
|
const sendMessage = useCallback(async ({ content, hiddenContent, ...message }) => {
|
|
669
686
|
try {
|
|
670
687
|
const messageId = generateId();
|
|
671
688
|
const uploadedAttachments = await uploadAttachments({ attachments: message.attachments, appId, token });
|
|
672
|
-
const
|
|
689
|
+
const userCopilotMessage = {
|
|
673
690
|
id: messageId,
|
|
674
691
|
role: "user",
|
|
675
|
-
|
|
692
|
+
content: content ?? "",
|
|
676
693
|
metadata: { version: 1, hiddenPrompt: hiddenContent ?? undefined },
|
|
677
694
|
};
|
|
678
|
-
|
|
695
|
+
const requestMessages = messages
|
|
696
|
+
.map(messageItemToCopilotMessage)
|
|
697
|
+
.filter((requestMessage) => Boolean(requestMessage));
|
|
698
|
+
setCopilotMessages(requestMessages);
|
|
699
|
+
copilotAgent.setRequestOptions({
|
|
679
700
|
headers: {
|
|
680
701
|
...(token ? { Authorization: `Bearer ${token}` } : {}),
|
|
681
702
|
...(AppVersionService.getCurrentVersionNumber()
|
|
@@ -694,25 +715,33 @@ function AiSdkAgentChatProvider({ appId, token, agentBlockId, agentChatId, child
|
|
|
694
715
|
shortTermMemory,
|
|
695
716
|
chatContextFiles,
|
|
696
717
|
chatContext: formatChatContext(chatContext),
|
|
697
|
-
|
|
718
|
+
files: uploadedAttachments,
|
|
719
|
+
messages: [...requestMessages, userCopilotMessage],
|
|
720
|
+
messageId,
|
|
698
721
|
},
|
|
699
722
|
});
|
|
723
|
+
await sendCopilotMessage(userCopilotMessage);
|
|
700
724
|
}
|
|
701
725
|
catch (error) {
|
|
702
|
-
|
|
726
|
+
addCopilotErrorMessage(error);
|
|
727
|
+
}
|
|
728
|
+
finally {
|
|
729
|
+
copilotAgent.clearRequestOptions();
|
|
703
730
|
}
|
|
704
731
|
}, [
|
|
705
|
-
|
|
732
|
+
addCopilotErrorMessage,
|
|
706
733
|
agentBlockId,
|
|
707
734
|
agentChatId,
|
|
708
735
|
appId,
|
|
709
736
|
chatId,
|
|
710
737
|
chatContext,
|
|
711
738
|
chatContextFiles,
|
|
739
|
+
copilotAgent,
|
|
712
740
|
currentThreadId,
|
|
713
741
|
messages,
|
|
714
742
|
noPersistency,
|
|
715
|
-
|
|
743
|
+
sendCopilotMessage,
|
|
744
|
+
setCopilotMessages,
|
|
716
745
|
shortTermMemory,
|
|
717
746
|
token,
|
|
718
747
|
]);
|
|
@@ -904,7 +933,7 @@ export function AgentChatVoice({ children }) {
|
|
|
904
933
|
return;
|
|
905
934
|
}
|
|
906
935
|
const conversationHistory = messagesRef.current
|
|
907
|
-
.filter((m) =>
|
|
936
|
+
.filter((m) => Boolean(m.msg.content) && m.msg.type === "text" && !m.msg.payload?.isVoiceMarker)
|
|
908
937
|
.slice(-20)
|
|
909
938
|
.map((m) => ({
|
|
910
939
|
role: (m.msg.role === "human" ? "user" : "assistant"),
|
|
@@ -944,18 +973,7 @@ export function AgentChatVoice({ children }) {
|
|
|
944
973
|
say: voiceSay,
|
|
945
974
|
}, children: children }));
|
|
946
975
|
}
|
|
947
|
-
const hasRenderableMessageContent = (message) => {
|
|
948
|
-
if (isV1AiSdkMessageItem(message)) {
|
|
949
|
-
return Boolean(message.msg.parts.length);
|
|
950
|
-
}
|
|
951
|
-
const hasTextContent = Boolean(message.msg.content);
|
|
952
|
-
const hasAttachments = Boolean(message.msg.attachments?.length);
|
|
953
|
-
return hasTextContent || hasAttachments;
|
|
954
|
-
};
|
|
955
976
|
export function AgentChatMessage({ message, index, ...props }) {
|
|
956
|
-
if (!hasRenderableMessageContent(message)) {
|
|
957
|
-
return null;
|
|
958
|
-
}
|
|
959
977
|
return _jsx("div", { "data-message-index": index, "data-message-role": message.msg.role, ...props });
|
|
960
978
|
}
|
|
961
979
|
export function AgentChatMessages({ asChild = false, autoScroll = true, scrollAreaClassName, ...props }) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blocksdiy/react-common",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.14.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "React common",
|
|
6
6
|
"keywords": [],
|
|
@@ -30,10 +30,10 @@
|
|
|
30
30
|
]
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@
|
|
33
|
+
"@ag-ui/client": "^0.0.53",
|
|
34
|
+
"@copilotkit/react-core": "^1.57.1",
|
|
34
35
|
"@radix-ui/react-slot": "^1.2.3",
|
|
35
36
|
"@vapi-ai/web": "^2.5.2",
|
|
36
|
-
"ai": "^6.0.175",
|
|
37
37
|
"penpal": "^7.0.6",
|
|
38
38
|
"react": "^19.2.4",
|
|
39
39
|
"@blocksdiy/blocks-client-api": "1.5.0"
|