@blocksdiy/react-common 1.35.2 → 1.36.1
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/components/agent-chat.d.ts +39 -19
- package/dist/components/agent-chat.d.ts.map +1 -1
- package/dist/components/agent-chat.js +44 -63
- package/dist/components/new-agent-chat.d.ts +21 -7
- package/dist/components/new-agent-chat.d.ts.map +1 -1
- package/dist/components/new-agent-chat.js +22 -24
- package/dist/utils/compose-render.d.ts +25 -0
- package/dist/utils/compose-render.d.ts.map +1 -0
- package/dist/utils/compose-render.js +60 -0
- package/package.json +2 -2
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ReactNode, SetStateAction } from "react";
|
|
2
2
|
import { type VoiceCallMessage } from "../hooks/use-voice-call.js";
|
|
3
|
+
import { type RenderProp } from "../utils/compose-render.js";
|
|
3
4
|
export interface Attachment {
|
|
4
5
|
url: string;
|
|
5
6
|
fileType: string;
|
|
@@ -72,35 +73,41 @@ export interface ToolCardContextValue {
|
|
|
72
73
|
export declare const useToolCard: () => ToolCardContextValue;
|
|
73
74
|
export interface ToolCardProps {
|
|
74
75
|
asChild?: boolean;
|
|
76
|
+
render?: RenderProp;
|
|
75
77
|
defaultOpen?: boolean;
|
|
76
78
|
open?: boolean;
|
|
77
79
|
onOpenChange?: (open: boolean) => void;
|
|
78
80
|
size?: string;
|
|
79
81
|
variant?: string;
|
|
80
82
|
}
|
|
81
|
-
export declare function ToolCard({ asChild, defaultOpen, open: controlledOpen, onOpenChange, size, variant, ...props }: React.ComponentProps<"div"> & ToolCardProps): import("react/jsx-runtime").JSX.Element;
|
|
83
|
+
export declare function ToolCard({ asChild, render, defaultOpen, open: controlledOpen, onOpenChange, size, variant, ...props }: React.ComponentProps<"div"> & ToolCardProps): import("react/jsx-runtime").JSX.Element;
|
|
82
84
|
export interface ToolHeaderProps {
|
|
83
85
|
asChild?: boolean;
|
|
86
|
+
render?: RenderProp;
|
|
84
87
|
collapseTrigger?: ReactNode;
|
|
85
88
|
}
|
|
86
|
-
export declare function ToolHeader({ asChild, collapseTrigger, children, ...props }: React.ComponentProps<"div"> & ToolHeaderProps): import("react/jsx-runtime").JSX.Element;
|
|
89
|
+
export declare function ToolHeader({ asChild, render, collapseTrigger, children, ...props }: React.ComponentProps<"div"> & ToolHeaderProps): import("react/jsx-runtime").JSX.Element;
|
|
87
90
|
export interface ToolTitleProps {
|
|
88
91
|
asChild?: boolean;
|
|
92
|
+
render?: RenderProp;
|
|
89
93
|
status?: ReactNode;
|
|
90
94
|
}
|
|
91
|
-
export declare function ToolTitle({ asChild, status, children, ...props }: React.ComponentProps<"div"> & ToolTitleProps): import("react/jsx-runtime").JSX.Element;
|
|
95
|
+
export declare function ToolTitle({ asChild, render, status, children, ...props }: React.ComponentProps<"div"> & ToolTitleProps): import("react/jsx-runtime").JSX.Element;
|
|
92
96
|
export interface ToolActionsProps {
|
|
93
97
|
asChild?: boolean;
|
|
98
|
+
render?: RenderProp;
|
|
94
99
|
}
|
|
95
|
-
export declare function ToolActions({ asChild, ...props }: React.ComponentProps<"div"> & ToolActionsProps): import("react/jsx-runtime").JSX.Element;
|
|
100
|
+
export declare function ToolActions({ asChild, render, ...props }: React.ComponentProps<"div"> & ToolActionsProps): import("react/jsx-runtime").JSX.Element;
|
|
96
101
|
export interface ToolCollapseTriggerProps {
|
|
97
102
|
asChild?: boolean;
|
|
103
|
+
render?: RenderProp;
|
|
98
104
|
}
|
|
99
|
-
export declare function ToolCollapseTrigger({ asChild, onClick, ...props }: React.ComponentProps<"button"> & ToolCollapseTriggerProps): import("react/jsx-runtime").JSX.Element;
|
|
105
|
+
export declare function ToolCollapseTrigger({ asChild, render, onClick, ...props }: React.ComponentProps<"button"> & ToolCollapseTriggerProps): import("react/jsx-runtime").JSX.Element;
|
|
100
106
|
export interface ToolContentProps {
|
|
101
107
|
asChild?: boolean;
|
|
108
|
+
render?: RenderProp;
|
|
102
109
|
}
|
|
103
|
-
export declare function ToolContent({ asChild, ...props }: React.ComponentProps<"div"> & ToolContentProps): import("react/jsx-runtime").JSX.Element;
|
|
110
|
+
export declare function ToolContent({ asChild, render, ...props }: React.ComponentProps<"div"> & ToolContentProps): import("react/jsx-runtime").JSX.Element;
|
|
104
111
|
export interface AgentChatData {
|
|
105
112
|
agent: {
|
|
106
113
|
title?: string;
|
|
@@ -163,63 +170,76 @@ export interface AgentChatMessageProps {
|
|
|
163
170
|
export declare function AgentChatMessage({ message, index, ...props }: React.ComponentProps<"div"> & AgentChatMessageProps): import("react/jsx-runtime").JSX.Element;
|
|
164
171
|
export interface AgentChatMessagesProps {
|
|
165
172
|
asChild?: boolean;
|
|
173
|
+
render?: RenderProp;
|
|
166
174
|
autoScroll?: boolean;
|
|
167
175
|
scrollAreaClassName?: string;
|
|
168
176
|
}
|
|
169
|
-
export declare function AgentChatMessages({ asChild, autoScroll, scrollAreaClassName, ...props }: React.ComponentProps<"div"> & AgentChatMessagesProps): import("react/jsx-runtime").JSX.Element;
|
|
177
|
+
export declare function AgentChatMessages({ asChild, render, autoScroll, scrollAreaClassName, ...props }: React.ComponentProps<"div"> & AgentChatMessagesProps): import("react/jsx-runtime").JSX.Element;
|
|
170
178
|
export interface AgentChatThinkingProps {
|
|
171
179
|
asChild?: boolean;
|
|
180
|
+
render?: RenderProp;
|
|
172
181
|
}
|
|
173
|
-
export declare function AgentChatThinking({ asChild, ...props }: React.ComponentProps<"div"> & AgentChatThinkingProps): import("react/jsx-runtime").JSX.Element | null;
|
|
182
|
+
export declare function AgentChatThinking({ asChild, render, ...props }: React.ComponentProps<"div"> & AgentChatThinkingProps): import("react/jsx-runtime").JSX.Element | null;
|
|
174
183
|
export interface AgentChatFetchingProps {
|
|
175
184
|
asChild?: boolean;
|
|
185
|
+
render?: RenderProp;
|
|
176
186
|
}
|
|
177
|
-
export declare function AgentChatFetching({ asChild, ...props }: React.ComponentProps<"div"> & AgentChatFetchingProps): import("react/jsx-runtime").JSX.Element | null;
|
|
187
|
+
export declare function AgentChatFetching({ asChild, render, ...props }: React.ComponentProps<"div"> & AgentChatFetchingProps): import("react/jsx-runtime").JSX.Element | null;
|
|
178
188
|
export interface AgentChatInputProps {
|
|
179
189
|
asChild?: boolean;
|
|
190
|
+
render?: RenderProp;
|
|
180
191
|
onSubmit?: (e: React.FormEvent<HTMLTextAreaElement>) => void;
|
|
181
192
|
acceptFiles?: boolean;
|
|
182
193
|
}
|
|
183
|
-
export declare function AgentChatInput({ asChild, onChange, onKeyDown, onPaste, onDragOver, onDragLeave, onDrop, onSubmit, acceptFiles, ...props }: React.ComponentProps<"textarea"> & AgentChatInputProps): import("react/jsx-runtime").JSX.Element;
|
|
194
|
+
export declare function AgentChatInput({ asChild, render, onChange, onKeyDown, onPaste, onDragOver, onDragLeave, onDrop, onSubmit, acceptFiles, ...props }: React.ComponentProps<"textarea"> & AgentChatInputProps): import("react/jsx-runtime").JSX.Element;
|
|
184
195
|
export interface AgentChatSendTriggerProps {
|
|
185
196
|
asChild?: boolean;
|
|
197
|
+
render?: RenderProp;
|
|
186
198
|
}
|
|
187
|
-
export declare function AgentChatSendTrigger({ asChild, onClick, disabled, ...props }: React.ComponentProps<"button"> & AgentChatSendTriggerProps): import("react/jsx-runtime").JSX.Element;
|
|
199
|
+
export declare function AgentChatSendTrigger({ asChild, render, onClick, disabled, ...props }: React.ComponentProps<"button"> & AgentChatSendTriggerProps): import("react/jsx-runtime").JSX.Element;
|
|
188
200
|
export interface AgentChatAttachmentTriggerProps {
|
|
189
201
|
asChild?: boolean;
|
|
202
|
+
render?: RenderProp;
|
|
190
203
|
accept?: string;
|
|
191
204
|
multiple?: boolean;
|
|
192
205
|
}
|
|
193
|
-
export declare function AgentChatAttachmentTrigger({ asChild, onClick, disabled, accept, multiple, ...props }: React.ComponentProps<"button"> & AgentChatAttachmentTriggerProps): import("react/jsx-runtime").JSX.Element;
|
|
206
|
+
export declare function AgentChatAttachmentTrigger({ asChild, render, onClick, disabled, accept, multiple, ...props }: React.ComponentProps<"button"> & AgentChatAttachmentTriggerProps): import("react/jsx-runtime").JSX.Element;
|
|
194
207
|
export interface AgentChatAttachmentProps {
|
|
195
208
|
attachment: Attachment;
|
|
196
209
|
asChild?: boolean;
|
|
210
|
+
render?: RenderProp;
|
|
197
211
|
}
|
|
198
|
-
export declare function AgentChatAttachment({ attachment, asChild, ...props }: React.ComponentProps<"div"> & AgentChatAttachmentProps): import("react/jsx-runtime").JSX.Element;
|
|
212
|
+
export declare function AgentChatAttachment({ attachment, asChild, render, ...props }: React.ComponentProps<"div"> & AgentChatAttachmentProps): import("react/jsx-runtime").JSX.Element;
|
|
199
213
|
export interface AgentChatAttachmentRemoveProps {
|
|
200
214
|
attachment: Attachment;
|
|
201
215
|
asChild?: boolean;
|
|
216
|
+
render?: RenderProp;
|
|
202
217
|
}
|
|
203
|
-
export declare function AgentChatAttachmentRemove({ attachment, asChild, onClick, ...props }: React.ComponentProps<"button"> & AgentChatAttachmentRemoveProps): import("react/jsx-runtime").JSX.Element;
|
|
218
|
+
export declare function AgentChatAttachmentRemove({ attachment, asChild, render, onClick, ...props }: React.ComponentProps<"button"> & AgentChatAttachmentRemoveProps): import("react/jsx-runtime").JSX.Element;
|
|
204
219
|
export interface AgentChatVoiceStartTriggerProps {
|
|
205
220
|
asChild?: boolean;
|
|
221
|
+
render?: RenderProp;
|
|
206
222
|
}
|
|
207
|
-
export declare function AgentChatVoiceStartTrigger({ asChild, onClick, disabled, ...props }: React.ComponentProps<"button"> & AgentChatVoiceStartTriggerProps): import("react/jsx-runtime").JSX.Element;
|
|
223
|
+
export declare function AgentChatVoiceStartTrigger({ asChild, render, onClick, disabled, ...props }: React.ComponentProps<"button"> & AgentChatVoiceStartTriggerProps): import("react/jsx-runtime").JSX.Element;
|
|
208
224
|
export interface AgentChatVoiceEndTriggerProps {
|
|
209
225
|
asChild?: boolean;
|
|
226
|
+
render?: RenderProp;
|
|
210
227
|
}
|
|
211
|
-
export declare function AgentChatVoiceEndTrigger({ asChild, onClick, disabled, ...props }: React.ComponentProps<"button"> & AgentChatVoiceEndTriggerProps): import("react/jsx-runtime").JSX.Element;
|
|
228
|
+
export declare function AgentChatVoiceEndTrigger({ asChild, render, onClick, disabled, ...props }: React.ComponentProps<"button"> & AgentChatVoiceEndTriggerProps): import("react/jsx-runtime").JSX.Element;
|
|
212
229
|
export interface AgentChatVoiceMuteTriggerProps {
|
|
213
230
|
asChild?: boolean;
|
|
231
|
+
render?: RenderProp;
|
|
214
232
|
}
|
|
215
|
-
export declare function AgentChatVoiceMuteTrigger({ asChild, onClick, disabled, ...props }: React.ComponentProps<"button"> & AgentChatVoiceMuteTriggerProps): import("react/jsx-runtime").JSX.Element;
|
|
233
|
+
export declare function AgentChatVoiceMuteTrigger({ asChild, render, onClick, disabled, ...props }: React.ComponentProps<"button"> & AgentChatVoiceMuteTriggerProps): import("react/jsx-runtime").JSX.Element;
|
|
216
234
|
export interface AgentChatVoiceStatusProps {
|
|
217
235
|
asChild?: boolean;
|
|
236
|
+
render?: RenderProp;
|
|
218
237
|
}
|
|
219
|
-
export declare function AgentChatVoiceStatus({ asChild, ...props }: React.ComponentProps<"div"> & AgentChatVoiceStatusProps): import("react/jsx-runtime").JSX.Element;
|
|
238
|
+
export declare function AgentChatVoiceStatus({ asChild, render, ...props }: React.ComponentProps<"div"> & AgentChatVoiceStatusProps): import("react/jsx-runtime").JSX.Element;
|
|
220
239
|
export interface AgentChatVoiceVolumeProps {
|
|
221
240
|
asChild?: boolean;
|
|
241
|
+
render?: RenderProp;
|
|
222
242
|
}
|
|
223
|
-
export declare function AgentChatVoiceVolume({ asChild, style, ...props }: React.ComponentProps<"div"> & AgentChatVoiceVolumeProps): import("react/jsx-runtime").JSX.Element;
|
|
243
|
+
export declare function AgentChatVoiceVolume({ asChild, render, style, ...props }: React.ComponentProps<"div"> & AgentChatVoiceVolumeProps): import("react/jsx-runtime").JSX.Element;
|
|
224
244
|
export {};
|
|
225
245
|
//# sourceMappingURL=agent-chat.d.ts.map
|
|
@@ -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":"AASA,OAAO,EAAiB,SAAS,EAAE,cAAc,EAAwD,MAAM,OAAO,CAAC;AAEvH,OAAO,EAAgB,KAAK,gBAAgB,EAA4B,MAAM,yBAAyB,CAAC;AACxG,OAAO,EAAiB,KAAK,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAYzE,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,MAAM,MAAM,uBAAuB,GAAG,oBAAoB,CAAC;AAE3D,UAAU,eAAe;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,EAAE,CAAC,EAAE,MAAM,CAAC;CACb;AAED,MAAM,MAAM,iBAAiB,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AC,cAAc,CAAC,QAAQ,CAAC,GAAG,6BAA6B,2CAiBhE;AAED,MAAM,WAAW,8BAA8B;IAC7C,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,MAAM,CAAC,EAAE,UAAU,CAAC;CACrB;AAED,wBAAgB,yBAAyB,CAAC,EACxC,OAAe,EACf,MAAM,EACN,OAAO,EACP,QAAQ,EACR,GAAG,KAAK,EACT,EAAE,KAAK,CAAC,cAAc,CAAC,QAAQ,CAAC,GAAG,8BAA8B,2CAmBjE;AAED,MAAM,WAAW,yBAAyB;IACxC,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,MAAM,CAAC,EAAE,UAAU,CAAC;CACrB;AAED,wBAAgB,oBAAoB,CAAC,EACnC,OAAe,EACf,MAAM,EACN,GAAG,KAAK,EACT,EAAE,KAAK,CAAC,cAAc,CAAC,KAAK,CAAC,GAAG,yBAAyB,2CAuBzD;AAED,MAAM,WAAW,yBAAyB;IACxC,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,MAAM,CAAC,EAAE,UAAU,CAAC;CACrB;AAED,wBAAgB,oBAAoB,CAAC,EACnC,OAAe,EACf,MAAM,EACN,KAAK,EACL,GAAG,KAAK,EACT,EAAE,KAAK,CAAC,cAAc,CAAC,KAAK,CAAC,GAAG,yBAAyB,2CAmBzD"}
|
|
@@ -2,9 +2,9 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
|
|
|
2
2
|
import { AppVersionService, BlocksApiService, DataApiService, getBuilderContextHeaders, websocketsService, } from "@blocksdiy/blocks-client-api";
|
|
3
3
|
import { getApiHost } from "@blocksdiy/blocks-client-api/envService";
|
|
4
4
|
import { WorkflowRequest } from "@blocksdiy/blocks-client-api/workflowService";
|
|
5
|
-
import { Slot } from "@radix-ui/react-slot";
|
|
6
5
|
import { createContext, useCallback, useContext, useEffect, useRef, useState } from "react";
|
|
7
6
|
import { useVoiceCall } from "../hooks/use-voice-call.js";
|
|
7
|
+
import { ComposeRender } from "../utils/compose-render.js";
|
|
8
8
|
/* public decouple - blocks common */
|
|
9
9
|
const CHAT_AGENT_HISTORY_TABLE_BLOCK_ID = "688ed13adefd8b565c779b8e";
|
|
10
10
|
const CHAT_AGENT_CALL_ACTION_BLOCK_ID = "688ed4d77b454b1fdaf5cf2d";
|
|
@@ -56,7 +56,7 @@ export const useToolCard = () => {
|
|
|
56
56
|
}
|
|
57
57
|
return context;
|
|
58
58
|
};
|
|
59
|
-
export function ToolCard({ asChild = false, defaultOpen = false, open: controlledOpen, onOpenChange, size, variant, ...props }) {
|
|
59
|
+
export function ToolCard({ asChild = false, render, defaultOpen = false, open: controlledOpen, onOpenChange, size, variant, ...props }) {
|
|
60
60
|
const [uncontrolledOpen, setUncontrolledOpen] = useState(defaultOpen);
|
|
61
61
|
const open = controlledOpen ?? uncontrolledOpen;
|
|
62
62
|
const setOpen = useCallback((nextOpen) => {
|
|
@@ -65,34 +65,28 @@ export function ToolCard({ asChild = false, defaultOpen = false, open: controlle
|
|
|
65
65
|
}
|
|
66
66
|
onOpenChange?.(nextOpen);
|
|
67
67
|
}, [controlledOpen, onOpenChange]);
|
|
68
|
-
|
|
69
|
-
return (_jsx(ToolCardContext.Provider, { value: { open, setOpen }, children: _jsx(Comp, { "data-slot": "agent-chat-tool-card", "data-state": open ? "open" : "closed", "data-size": size, "data-variant": variant, ...props }) }));
|
|
68
|
+
return (_jsx(ToolCardContext.Provider, { value: { open, setOpen }, children: _jsx(ComposeRender, { render: render, asChild: asChild, defaultTag: "div", "data-slot": "agent-chat-tool-card", "data-state": open ? "open" : "closed", "data-size": size, "data-variant": variant, ...props }) }));
|
|
70
69
|
}
|
|
71
|
-
export function ToolHeader({ asChild = false, collapseTrigger, children, ...props }) {
|
|
70
|
+
export function ToolHeader({ asChild = false, render, collapseTrigger, children, ...props }) {
|
|
72
71
|
const { open } = useToolCard();
|
|
73
|
-
|
|
74
|
-
return (_jsxs(Comp, { "data-slot": "agent-chat-tool-header", "data-state": open ? "open" : "closed", ...props, children: [children, collapseTrigger] }));
|
|
72
|
+
return (_jsxs(ComposeRender, { render: render, asChild: asChild, defaultTag: "div", "data-slot": "agent-chat-tool-header", "data-state": open ? "open" : "closed", ...props, children: [children, collapseTrigger] }));
|
|
75
73
|
}
|
|
76
|
-
export function ToolTitle({ asChild = false, status, children, ...props }) {
|
|
77
|
-
|
|
78
|
-
return (_jsxs(Comp, { "data-slot": "agent-chat-tool-title", ...props, children: [status, children] }));
|
|
74
|
+
export function ToolTitle({ asChild = false, render, status, children, ...props }) {
|
|
75
|
+
return (_jsxs(ComposeRender, { render: render, asChild: asChild, defaultTag: "div", "data-slot": "agent-chat-tool-title", ...props, children: [status, children] }));
|
|
79
76
|
}
|
|
80
|
-
export function ToolActions({ asChild = false, ...props }) {
|
|
81
|
-
|
|
82
|
-
return _jsx(Comp, { "data-slot": "agent-chat-tool-actions", ...props });
|
|
77
|
+
export function ToolActions({ asChild = false, render, ...props }) {
|
|
78
|
+
return (_jsx(ComposeRender, { render: render, asChild: asChild, defaultTag: "div", "data-slot": "agent-chat-tool-actions", ...props }));
|
|
83
79
|
}
|
|
84
|
-
export function ToolCollapseTrigger({ asChild = false, onClick, ...props }) {
|
|
80
|
+
export function ToolCollapseTrigger({ asChild = false, render, onClick, ...props }) {
|
|
85
81
|
const { open, setOpen } = useToolCard();
|
|
86
|
-
|
|
87
|
-
return (_jsx(Comp, { type: "button", "aria-expanded": open, "data-slot": "agent-chat-tool-collapse-trigger", "data-state": open ? "open" : "closed", onClick: (e) => {
|
|
82
|
+
return (_jsx(ComposeRender, { render: render, asChild: asChild, defaultTag: "button", type: "button", "aria-expanded": open, "data-slot": "agent-chat-tool-collapse-trigger", "data-state": open ? "open" : "closed", onClick: (e) => {
|
|
88
83
|
setOpen(!open);
|
|
89
84
|
onClick?.(e);
|
|
90
85
|
}, ...props }));
|
|
91
86
|
}
|
|
92
|
-
export function ToolContent({ asChild = false, ...props }) {
|
|
87
|
+
export function ToolContent({ asChild = false, render, ...props }) {
|
|
93
88
|
const { open } = useToolCard();
|
|
94
|
-
|
|
95
|
-
return _jsx(Comp, { "data-slot": "agent-chat-tool-content", "data-state": open ? "open" : "closed", ...props });
|
|
89
|
+
return (_jsx(ComposeRender, { render: render, asChild: asChild, defaultTag: "div", "data-slot": "agent-chat-tool-content", "data-state": open ? "open" : "closed", ...props }));
|
|
96
90
|
}
|
|
97
91
|
const fileFromAttachment = async (attachment) => {
|
|
98
92
|
const res = await fetch(attachment.url); // or use XMLHttpRequest if you need progress events
|
|
@@ -180,12 +174,12 @@ const getPhotoUrlFromAgentBlockData = (agentBlockData) => {
|
|
|
180
174
|
}
|
|
181
175
|
return undefined;
|
|
182
176
|
};
|
|
183
|
-
const resolveAgentChatConfig = async ({ agentChatId, token, }) => {
|
|
177
|
+
const resolveAgentChatConfig = async ({ agentChatId, appId, token, }) => {
|
|
184
178
|
if (!agentChatId) {
|
|
185
179
|
return { shortTermMemory: DEFAULT_SHORT_TERM_MEMORY };
|
|
186
180
|
}
|
|
187
181
|
const blocksApiService = new BlocksApiService({ token });
|
|
188
|
-
const agentChatBlock = await blocksApiService.getBlock(agentChatId);
|
|
182
|
+
const agentChatBlock = await blocksApiService.getBlock(agentChatId, appId, "agent", "agent_chat");
|
|
189
183
|
const agentChatBlockData = agentChatBlock?.data;
|
|
190
184
|
if (!agentChatBlockData) {
|
|
191
185
|
return { shortTermMemory: DEFAULT_SHORT_TERM_MEMORY };
|
|
@@ -193,7 +187,7 @@ const resolveAgentChatConfig = async ({ agentChatId, token, }) => {
|
|
|
193
187
|
const { agentBlockId, initialMessages, initialPrompt } = agentChatBlockData;
|
|
194
188
|
let agentBlockData;
|
|
195
189
|
if (agentBlockId) {
|
|
196
|
-
const agentBlock = await blocksApiService.getBlock(agentBlockId);
|
|
190
|
+
const agentBlock = await blocksApiService.getBlock(agentBlockId, appId, "agent", "agent");
|
|
197
191
|
agentBlockData = agentBlock?.data;
|
|
198
192
|
}
|
|
199
193
|
return {
|
|
@@ -295,7 +289,7 @@ export const AgentChatRoot = ({ appId, token, agentChatId, children, chatId, noP
|
|
|
295
289
|
setResolvedAgentChatConfig(null);
|
|
296
290
|
const fetchAgentChatConfig = async () => {
|
|
297
291
|
try {
|
|
298
|
-
const config = await resolveAgentChatConfig({ agentChatId, token });
|
|
292
|
+
const config = await resolveAgentChatConfig({ agentChatId, appId, token });
|
|
299
293
|
if (!cancelled) {
|
|
300
294
|
setResolvedAgentChatConfig(config);
|
|
301
295
|
}
|
|
@@ -310,7 +304,7 @@ export const AgentChatRoot = ({ appId, token, agentChatId, children, chatId, noP
|
|
|
310
304
|
return () => {
|
|
311
305
|
cancelled = true;
|
|
312
306
|
};
|
|
313
|
-
}, [agentChatId, token]);
|
|
307
|
+
}, [agentChatId, appId, token]);
|
|
314
308
|
useEffect(() => {
|
|
315
309
|
let cancelled = false;
|
|
316
310
|
if (effectiveNoPersistency) {
|
|
@@ -703,12 +697,11 @@ export function AgentChatVoice({ children }) {
|
|
|
703
697
|
export function AgentChatMessage({ message, index, ...props }) {
|
|
704
698
|
return _jsx("div", { "data-message-index": index, "data-message-role": message.msg.role, ...props });
|
|
705
699
|
}
|
|
706
|
-
export function AgentChatMessages({ asChild = false, autoScroll = true, scrollAreaClassName, ...props }) {
|
|
700
|
+
export function AgentChatMessages({ asChild = false, render, autoScroll = true, scrollAreaClassName, ...props }) {
|
|
707
701
|
const { messages, isThinking } = useAgentChat();
|
|
708
702
|
const scrollRef = useRef(null);
|
|
709
703
|
const bottomRef = useRef(null);
|
|
710
704
|
const [isAtBottom, setIsAtBottom] = useState(true);
|
|
711
|
-
const Comp = asChild ? Slot : "div";
|
|
712
705
|
const scrollToBottom = useCallback(() => {
|
|
713
706
|
if (scrollRef.current) {
|
|
714
707
|
scrollRef.current.scrollTo({ top: scrollRef.current.scrollHeight, behavior: "instant" });
|
|
@@ -763,29 +756,27 @@ export function AgentChatMessages({ asChild = false, autoScroll = true, scrollAr
|
|
|
763
756
|
resizeObserver.disconnect();
|
|
764
757
|
};
|
|
765
758
|
}, [autoScroll, isAtBottom, scrollToBottom]);
|
|
766
|
-
return (_jsxs("div", { ref: scrollRef, style: { overflow: "auto" }, className: scrollAreaClassName, ...props, children: [_jsx(
|
|
759
|
+
return (_jsxs("div", { ref: scrollRef, style: { overflow: "auto" }, className: scrollAreaClassName, ...props, children: [_jsx(ComposeRender, { render: render, asChild: asChild, defaultTag: "div", "data-slot": "agent-chat-messages", ...props }), _jsx("div", { ref: bottomRef, style: {
|
|
767
760
|
height: 0,
|
|
768
761
|
width: "100%",
|
|
769
762
|
pointerEvents: "none",
|
|
770
763
|
}, "aria-hidden": "true" })] }));
|
|
771
764
|
}
|
|
772
|
-
export function AgentChatThinking({ asChild = false, ...props }) {
|
|
765
|
+
export function AgentChatThinking({ asChild = false, render, ...props }) {
|
|
773
766
|
const { isThinking } = useAgentChat();
|
|
774
|
-
const Comp = asChild ? Slot : "div";
|
|
775
767
|
if (!isThinking) {
|
|
776
768
|
return null;
|
|
777
769
|
}
|
|
778
|
-
return _jsx(
|
|
770
|
+
return (_jsx(ComposeRender, { render: render, asChild: asChild, defaultTag: "div", "data-slot": "agent-chat-thinking", ...props }));
|
|
779
771
|
}
|
|
780
|
-
export function AgentChatFetching({ asChild = false, ...props }) {
|
|
772
|
+
export function AgentChatFetching({ asChild = false, render, ...props }) {
|
|
781
773
|
const { isFetchingMessages, agentChatData } = useAgentChat();
|
|
782
|
-
const Comp = asChild ? Slot : "div";
|
|
783
774
|
if (!isFetchingMessages && agentChatData) {
|
|
784
775
|
return null;
|
|
785
776
|
}
|
|
786
|
-
return _jsx(
|
|
777
|
+
return (_jsx(ComposeRender, { render: render, asChild: asChild, defaultTag: "div", "data-slot": "agent-chat-fetching", ...props }));
|
|
787
778
|
}
|
|
788
|
-
export function AgentChatInput({ asChild = false, onChange, onKeyDown, onPaste, onDragOver, onDragLeave, onDrop, onSubmit, acceptFiles = true, ...props }) {
|
|
779
|
+
export function AgentChatInput({ asChild = false, render, onChange, onKeyDown, onPaste, onDragOver, onDragLeave, onDrop, onSubmit, acceptFiles = true, ...props }) {
|
|
789
780
|
const { setIsDraggingFiles, addAttachments, prompt, setPrompt, sendFromInputs } = useAgentChat();
|
|
790
781
|
const handleDragOver = useCallback((e) => {
|
|
791
782
|
if (!acceptFiles) {
|
|
@@ -846,8 +837,7 @@ export function AgentChatInput({ asChild = false, onChange, onKeyDown, onPaste,
|
|
|
846
837
|
addAttachments(attachments);
|
|
847
838
|
}
|
|
848
839
|
}, [addAttachments, acceptFiles]);
|
|
849
|
-
|
|
850
|
-
return (_jsx(Comp, { value: prompt, onChange: (e) => {
|
|
840
|
+
return (_jsx(ComposeRender, { render: render, asChild: asChild, defaultTag: "textarea", value: prompt, onChange: (e) => {
|
|
851
841
|
handleChange(e);
|
|
852
842
|
onChange?.(e);
|
|
853
843
|
}, onKeyDown: (e) => {
|
|
@@ -873,15 +863,14 @@ export function AgentChatInput({ asChild = false, onChange, onKeyDown, onPaste,
|
|
|
873
863
|
}
|
|
874
864
|
: onDrop, "data-slot": "agent-chat-input", ...props }));
|
|
875
865
|
}
|
|
876
|
-
export function AgentChatSendTrigger({ asChild = false, onClick, disabled, ...props }) {
|
|
866
|
+
export function AgentChatSendTrigger({ asChild = false, render, onClick, disabled, ...props }) {
|
|
877
867
|
const { isThinking, sendFromInputs } = useAgentChat();
|
|
878
|
-
|
|
879
|
-
return (_jsx(Comp, { onClick: (e) => {
|
|
868
|
+
return (_jsx(ComposeRender, { render: render, asChild: asChild, defaultTag: "button", onClick: (e) => {
|
|
880
869
|
sendFromInputs();
|
|
881
870
|
onClick?.(e);
|
|
882
871
|
}, disabled: disabled ?? isThinking, "data-slot": "agent-chat-send-trigger", ...props }));
|
|
883
872
|
}
|
|
884
|
-
export function AgentChatAttachmentTrigger({ asChild = false, onClick, disabled, accept, multiple = true, ...props }) {
|
|
873
|
+
export function AgentChatAttachmentTrigger({ asChild = false, render, onClick, disabled, accept, multiple = true, ...props }) {
|
|
885
874
|
const { isThinking, addAttachments } = useAgentChat();
|
|
886
875
|
const fileInputRef = useRef(null);
|
|
887
876
|
const handleFileChange = useCallback(async (e) => {
|
|
@@ -901,51 +890,44 @@ export function AgentChatAttachmentTrigger({ asChild = false, onClick, disabled,
|
|
|
901
890
|
const handleClick = useCallback(() => {
|
|
902
891
|
fileInputRef.current?.click();
|
|
903
892
|
}, []);
|
|
904
|
-
|
|
905
|
-
return (_jsxs(_Fragment, { children: [_jsx("input", { type: "file", ref: fileInputRef, onChange: handleFileChange, accept: accept, multiple: multiple, style: { display: "none" }, "aria-hidden": "true" }), _jsx(Comp, { onClick: (e) => {
|
|
893
|
+
return (_jsxs(_Fragment, { children: [_jsx("input", { type: "file", ref: fileInputRef, onChange: handleFileChange, accept: accept, multiple: multiple, style: { display: "none" }, "aria-hidden": "true" }), _jsx(ComposeRender, { render: render, asChild: asChild, defaultTag: "button", onClick: (e) => {
|
|
906
894
|
handleClick();
|
|
907
895
|
onClick?.(e);
|
|
908
896
|
}, disabled: disabled ?? isThinking, "data-slot": "agent-chat-attachment-trigger", ...props })] }));
|
|
909
897
|
}
|
|
910
|
-
export function AgentChatAttachment({ attachment, asChild = false, ...props }) {
|
|
911
|
-
|
|
912
|
-
return _jsx(Comp, { "data-slot": "agent-chat-attachment", "data-file-type": attachment.fileType, ...props });
|
|
898
|
+
export function AgentChatAttachment({ attachment, asChild = false, render, ...props }) {
|
|
899
|
+
return (_jsx(ComposeRender, { render: render, asChild: asChild, defaultTag: "div", "data-slot": "agent-chat-attachment", "data-file-type": attachment.fileType, ...props }));
|
|
913
900
|
}
|
|
914
|
-
export function AgentChatAttachmentRemove({ attachment, asChild = false, onClick, ...props }) {
|
|
901
|
+
export function AgentChatAttachmentRemove({ attachment, asChild = false, render, onClick, ...props }) {
|
|
915
902
|
const { removeAttachment } = useAgentChat();
|
|
916
|
-
|
|
917
|
-
return (_jsx(Comp, { onClick: (e) => {
|
|
903
|
+
return (_jsx(ComposeRender, { render: render, asChild: asChild, defaultTag: "button", onClick: (e) => {
|
|
918
904
|
removeAttachment(attachment.url);
|
|
919
905
|
onClick?.(e);
|
|
920
906
|
}, "data-slot": "agent-chat-attachment-remove", ...props }));
|
|
921
907
|
}
|
|
922
|
-
export function AgentChatVoiceStartTrigger({ asChild = false, onClick, disabled, ...props }) {
|
|
908
|
+
export function AgentChatVoiceStartTrigger({ asChild = false, render, onClick, disabled, ...props }) {
|
|
923
909
|
const { startVoiceCall, isConnecting, isConnected } = useAgentChatVoice();
|
|
924
|
-
|
|
925
|
-
return (_jsx(Comp, { onClick: (e) => {
|
|
910
|
+
return (_jsx(ComposeRender, { render: render, asChild: asChild, defaultTag: "button", onClick: (e) => {
|
|
926
911
|
startVoiceCall();
|
|
927
912
|
onClick?.(e);
|
|
928
913
|
}, disabled: disabled ?? isConnecting ?? isConnected, "data-slot": "agent-chat-voice-start-trigger", ...props }));
|
|
929
914
|
}
|
|
930
|
-
export function AgentChatVoiceEndTrigger({ asChild = false, onClick, disabled, ...props }) {
|
|
915
|
+
export function AgentChatVoiceEndTrigger({ asChild = false, render, onClick, disabled, ...props }) {
|
|
931
916
|
const { endVoiceCall, isConnected } = useAgentChatVoice();
|
|
932
|
-
|
|
933
|
-
return (_jsx(Comp, { onClick: (e) => {
|
|
917
|
+
return (_jsx(ComposeRender, { render: render, asChild: asChild, defaultTag: "button", onClick: (e) => {
|
|
934
918
|
endVoiceCall();
|
|
935
919
|
onClick?.(e);
|
|
936
920
|
}, disabled: disabled ?? !isConnected, "data-slot": "agent-chat-voice-end-trigger", ...props }));
|
|
937
921
|
}
|
|
938
|
-
export function AgentChatVoiceMuteTrigger({ asChild = false, onClick, disabled, ...props }) {
|
|
922
|
+
export function AgentChatVoiceMuteTrigger({ asChild = false, render, onClick, disabled, ...props }) {
|
|
939
923
|
const { toggleMute, isMuted, isConnected } = useAgentChatVoice();
|
|
940
|
-
|
|
941
|
-
return (_jsx(Comp, { onClick: (e) => {
|
|
924
|
+
return (_jsx(ComposeRender, { render: render, asChild: asChild, defaultTag: "button", onClick: (e) => {
|
|
942
925
|
toggleMute();
|
|
943
926
|
onClick?.(e);
|
|
944
927
|
}, disabled: disabled ?? !isConnected, "data-slot": "agent-chat-voice-mute-trigger", "data-muted": isMuted, "aria-pressed": isMuted, ...props }));
|
|
945
928
|
}
|
|
946
|
-
export function AgentChatVoiceStatus({ asChild = false, ...props }) {
|
|
929
|
+
export function AgentChatVoiceStatus({ asChild = false, render, ...props }) {
|
|
947
930
|
const { isConnecting, isConnected, isSpeaking, isMuted } = useAgentChatVoice();
|
|
948
|
-
const Comp = asChild ? Slot : "div";
|
|
949
931
|
const status = isConnecting
|
|
950
932
|
? "connecting"
|
|
951
933
|
: isConnected && isMuted
|
|
@@ -955,12 +937,11 @@ export function AgentChatVoiceStatus({ asChild = false, ...props }) {
|
|
|
955
937
|
: isConnected
|
|
956
938
|
? "listening"
|
|
957
939
|
: "idle";
|
|
958
|
-
return _jsx(
|
|
940
|
+
return (_jsx(ComposeRender, { render: render, asChild: asChild, defaultTag: "div", "data-slot": "agent-chat-voice-status", "data-status": status, ...props }));
|
|
959
941
|
}
|
|
960
|
-
export function AgentChatVoiceVolume({ asChild = false, style, ...props }) {
|
|
942
|
+
export function AgentChatVoiceVolume({ asChild = false, render, style, ...props }) {
|
|
961
943
|
const { volumeLevel, isConnected } = useAgentChatVoice();
|
|
962
|
-
|
|
963
|
-
return (_jsx(Comp, { "data-slot": "agent-chat-voice-volume", "data-connected": isConnected, style: {
|
|
944
|
+
return (_jsx(ComposeRender, { render: render, asChild: asChild, defaultTag: "div", "data-slot": "agent-chat-voice-volume", "data-connected": isConnected, style: {
|
|
964
945
|
...style,
|
|
965
946
|
"--voice-volume": isConnected ? volumeLevel : 0,
|
|
966
947
|
}, ...props }));
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { type Message, ToolMessage, type UserMessage } from "@ag-ui/client";
|
|
2
2
|
import { useRenderToolCall } from "@copilotkit/react-core/v2";
|
|
3
3
|
import { ReactNode, SetStateAction } from "react";
|
|
4
|
+
import { type RenderProp } from "../utils/compose-render.js";
|
|
4
5
|
export { type Message, type AssistantMessage, type UserMessage } from "@ag-ui/client";
|
|
5
6
|
export { useRenderTool, useDefaultRenderTool, useHumanInTheLoop, useFrontendTool, ToolCallStatus, } from "@copilotkit/react-core/v2";
|
|
6
7
|
export interface Attachment {
|
|
@@ -88,6 +89,12 @@ export interface AgentChatRootProps {
|
|
|
88
89
|
chatId?: string;
|
|
89
90
|
chatContext?: any;
|
|
90
91
|
chatContextFiles?: Attachment[];
|
|
92
|
+
/**
|
|
93
|
+
* Self-config edit ("Talk to Leo"): when true, the agent turn is flagged so the agent gets a
|
|
94
|
+
* tool to change its OWN config. Set ONLY by the builder-preview chat surface (gated by the
|
|
95
|
+
* `agent-self-modify` flag) — never in the published app.
|
|
96
|
+
*/
|
|
97
|
+
selfEditEnabled?: boolean;
|
|
91
98
|
}
|
|
92
99
|
export declare const AgentChatRoot: ({ ...props }: AgentChatRootProps) => import("react/jsx-runtime").JSX.Element | null;
|
|
93
100
|
export interface AgentChatMessageProps {
|
|
@@ -108,35 +115,42 @@ export interface AgentChatMessagesProps {
|
|
|
108
115
|
export declare function AgentChatMessages({ scrollAreaClassName, ...props }: React.ComponentProps<"div"> & AgentChatMessagesProps): import("react/jsx-runtime").JSX.Element;
|
|
109
116
|
export interface AgentChatThinkingProps {
|
|
110
117
|
asChild?: boolean;
|
|
118
|
+
render?: RenderProp;
|
|
111
119
|
}
|
|
112
|
-
export declare function AgentChatThinking({ asChild, ...props }: React.ComponentProps<"div"> & AgentChatThinkingProps): import("react/jsx-runtime").JSX.Element | null;
|
|
120
|
+
export declare function AgentChatThinking({ asChild, render, ...props }: React.ComponentProps<"div"> & AgentChatThinkingProps): import("react/jsx-runtime").JSX.Element | null;
|
|
113
121
|
export interface AgentChatFetchingProps {
|
|
114
122
|
asChild?: boolean;
|
|
123
|
+
render?: RenderProp;
|
|
115
124
|
}
|
|
116
|
-
export declare function AgentChatFetching({ asChild, ...props }: React.ComponentProps<"div"> & AgentChatFetchingProps): import("react/jsx-runtime").JSX.Element | null;
|
|
125
|
+
export declare function AgentChatFetching({ asChild, render, ...props }: React.ComponentProps<"div"> & AgentChatFetchingProps): import("react/jsx-runtime").JSX.Element | null;
|
|
117
126
|
export interface AgentChatInputProps {
|
|
118
127
|
asChild?: boolean;
|
|
128
|
+
render?: RenderProp;
|
|
119
129
|
onSubmit?: (e: React.FormEvent<HTMLTextAreaElement>) => void;
|
|
120
130
|
}
|
|
121
|
-
export declare function AgentChatInput({ asChild, onChange, onKeyDown, onPaste, onDragOver, onDragLeave, onDrop, onSubmit, ...props }: React.ComponentProps<"textarea"> & AgentChatInputProps): import("react/jsx-runtime").JSX.Element;
|
|
131
|
+
export declare function AgentChatInput({ asChild, render, onChange, onKeyDown, onPaste, onDragOver, onDragLeave, onDrop, onSubmit, ...props }: React.ComponentProps<"textarea"> & AgentChatInputProps): import("react/jsx-runtime").JSX.Element;
|
|
122
132
|
export interface AgentChatSendTriggerProps {
|
|
123
133
|
asChild?: boolean;
|
|
134
|
+
render?: RenderProp;
|
|
124
135
|
}
|
|
125
|
-
export declare function AgentChatSendTrigger({ asChild, onClick, disabled, ...props }: React.ComponentProps<"button"> & AgentChatSendTriggerProps): import("react/jsx-runtime").JSX.Element;
|
|
136
|
+
export declare function AgentChatSendTrigger({ asChild, render, onClick, disabled, ...props }: React.ComponentProps<"button"> & AgentChatSendTriggerProps): import("react/jsx-runtime").JSX.Element;
|
|
126
137
|
export interface AgentChatAttachmentTriggerProps {
|
|
127
138
|
asChild?: boolean;
|
|
139
|
+
render?: RenderProp;
|
|
128
140
|
accept?: string;
|
|
129
141
|
multiple?: boolean;
|
|
130
142
|
}
|
|
131
|
-
export declare function AgentChatAttachmentTrigger({ asChild, onClick, disabled, accept, multiple, ...props }: React.ComponentProps<"button"> & AgentChatAttachmentTriggerProps): import("react/jsx-runtime").JSX.Element;
|
|
143
|
+
export declare function AgentChatAttachmentTrigger({ asChild, render, onClick, disabled, accept, multiple, ...props }: React.ComponentProps<"button"> & AgentChatAttachmentTriggerProps): import("react/jsx-runtime").JSX.Element;
|
|
132
144
|
export interface AgentChatAttachmentProps {
|
|
133
145
|
attachment: Attachment;
|
|
134
146
|
asChild?: boolean;
|
|
147
|
+
render?: RenderProp;
|
|
135
148
|
}
|
|
136
|
-
export declare function AgentChatAttachment({ attachment, asChild, ...props }: React.ComponentProps<"div"> & AgentChatAttachmentProps): import("react/jsx-runtime").JSX.Element;
|
|
149
|
+
export declare function AgentChatAttachment({ attachment, asChild, render, ...props }: React.ComponentProps<"div"> & AgentChatAttachmentProps): import("react/jsx-runtime").JSX.Element;
|
|
137
150
|
export interface AgentChatAttachmentRemoveProps {
|
|
138
151
|
attachment: Attachment;
|
|
139
152
|
asChild?: boolean;
|
|
153
|
+
render?: RenderProp;
|
|
140
154
|
}
|
|
141
|
-
export declare function AgentChatAttachmentRemove({ attachment, asChild, onClick, ...props }: React.ComponentProps<"button"> & AgentChatAttachmentRemoveProps): import("react/jsx-runtime").JSX.Element;
|
|
155
|
+
export declare function AgentChatAttachmentRemove({ attachment, asChild, render, onClick, ...props }: React.ComponentProps<"button"> & AgentChatAttachmentRemoveProps): import("react/jsx-runtime").JSX.Element;
|
|
142
156
|
//# sourceMappingURL=new-agent-chat.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"new-agent-chat.d.ts","sourceRoot":"","sources":["../../src/components/new-agent-chat.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,OAAO,EAAE,WAAW,EAAE,KAAK,WAAW,EAAE,MAAM,eAAe,CAAC;AAI5E,OAAO,EAAiB,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"new-agent-chat.d.ts","sourceRoot":"","sources":["../../src/components/new-agent-chat.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,OAAO,EAAE,WAAW,EAAE,KAAK,WAAW,EAAE,MAAM,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,EACN,OAAO,EACP,GAAG,KAAK,EACT,EAAE,KAAK,CAAC,cAAc,CAAC,QAAQ,CAAC,GAAG,8BAA8B,2CAgBjE"}
|
|
@@ -3,9 +3,9 @@ import { BlocksApiService, getBuilderContextHeaders, websocketsService } from "@
|
|
|
3
3
|
import { getApiHost } from "@blocksdiy/blocks-client-api/envService";
|
|
4
4
|
import { CopilotKit, useCopilotChatInternal } from "@copilotkit/react-core";
|
|
5
5
|
import { useCopilotKit, useRenderToolCall } from "@copilotkit/react-core/v2";
|
|
6
|
-
import { Slot } from "@radix-ui/react-slot";
|
|
7
6
|
import { createContext, useCallback, useContext, useEffect, useLayoutEffect, useMemo, useRef, useState, } from "react";
|
|
8
7
|
import { useStickToBottom } from "use-stick-to-bottom";
|
|
8
|
+
import { ComposeRender } from "../utils/compose-render.js";
|
|
9
9
|
export { useRenderTool, useDefaultRenderTool, useHumanInTheLoop, useFrontendTool, ToolCallStatus, } from "@copilotkit/react-core/v2";
|
|
10
10
|
// Client-only `useLayoutEffect`, falls back to `useEffect` during SSR.
|
|
11
11
|
// Needed so the `agent.threadId` mirror commits before CopilotKit's
|
|
@@ -597,7 +597,7 @@ export const AgentChatRoot = ({ ...props
|
|
|
597
597
|
// memoryEnabled = false,
|
|
598
598
|
// shortTermMemory,
|
|
599
599
|
}) => {
|
|
600
|
-
const { appId, token, children, agentId, agentHarness, useAgentBlockDirectChat, agentChatId, componentIds, chatId, defaultThreadId, noPersistency, chatContext, chatContextFiles, } = props;
|
|
600
|
+
const { appId, token, children, agentId, agentHarness, useAgentBlockDirectChat, agentChatId, componentIds, chatId, defaultThreadId, noPersistency, chatContext, chatContextFiles, selfEditEnabled, } = props;
|
|
601
601
|
const socketId = websocketsService.getSocketId();
|
|
602
602
|
const headers = useMemo(() => ({
|
|
603
603
|
...(token ? { Authorization: `Bearer ${token}` } : {}),
|
|
@@ -663,7 +663,11 @@ export const AgentChatRoot = ({ ...props
|
|
|
663
663
|
useEffect(() => {
|
|
664
664
|
getAgentChatBlock().then((agentChatBlock) => {
|
|
665
665
|
setAgentChatBlock(agentChatBlock);
|
|
666
|
-
|
|
666
|
+
// The chat block's stored agentBlockId is authoritative — sync resolves it
|
|
667
|
+
// to a real block id, while the `agentId` prop from generated product-types
|
|
668
|
+
// is a name that can drift from the agent's `block.name`. The prop is only
|
|
669
|
+
// the fallback for direct agent chats without an agent-chat block.
|
|
670
|
+
const effectiveAgentId = agentChatBlock?.data?.agentBlockId ?? agentId;
|
|
667
671
|
getAgentBlock(effectiveAgentId).then((agentBlock) => {
|
|
668
672
|
setAgentBlock(agentBlock);
|
|
669
673
|
});
|
|
@@ -687,6 +691,7 @@ export const AgentChatRoot = ({ ...props
|
|
|
687
691
|
noPersistency,
|
|
688
692
|
chatContext: chatContextStr,
|
|
689
693
|
chatContextFiles,
|
|
694
|
+
...(selfEditEnabled ? { selfEditEnabled: true } : {}),
|
|
690
695
|
},
|
|
691
696
|
// Explicit false: when undefined, CopilotKit auto-enables its inspector
|
|
692
697
|
// devtools on localhost hostnames.
|
|
@@ -725,18 +730,16 @@ export function AgentChatMessages({ scrollAreaClassName, ...props }) {
|
|
|
725
730
|
scrollbarGutter: "stable both-edges",
|
|
726
731
|
}, children: _jsx("div", { ref: contentRef, "data-slot": "agent-chat-messages", ...props }) }));
|
|
727
732
|
}
|
|
728
|
-
export function AgentChatThinking({ asChild = false, ...props }) {
|
|
733
|
+
export function AgentChatThinking({ asChild = false, render, ...props }) {
|
|
729
734
|
const { isThinking } = useAgentChat();
|
|
730
|
-
const Comp = asChild ? Slot : "div";
|
|
731
735
|
if (!isThinking) {
|
|
732
736
|
return null;
|
|
733
737
|
}
|
|
734
|
-
return _jsx(
|
|
738
|
+
return (_jsx(ComposeRender, { render: render, asChild: asChild, defaultTag: "div", "data-slot": "agent-chat-thinking", ...props }));
|
|
735
739
|
}
|
|
736
|
-
export function AgentChatFetching({ asChild = false, ...props }) {
|
|
740
|
+
export function AgentChatFetching({ asChild = false, render, ...props }) {
|
|
737
741
|
const { isFetchingMessages } = useAgentChat();
|
|
738
742
|
const [shouldRender, setShouldRender] = useState(isFetchingMessages);
|
|
739
|
-
const Comp = asChild ? Slot : "div";
|
|
740
743
|
useEffect(() => {
|
|
741
744
|
const timeoutId = window.setTimeout(() => {
|
|
742
745
|
setShouldRender(isFetchingMessages);
|
|
@@ -748,9 +751,9 @@ export function AgentChatFetching({ asChild = false, ...props }) {
|
|
|
748
751
|
if (!shouldRender) {
|
|
749
752
|
return null;
|
|
750
753
|
}
|
|
751
|
-
return _jsx(
|
|
754
|
+
return (_jsx(ComposeRender, { render: render, asChild: asChild, defaultTag: "div", "data-state": isFetchingMessages ? "open" : "closed", "data-slot": "agent-chat-fetching", ...props }));
|
|
752
755
|
}
|
|
753
|
-
export function AgentChatInput({ asChild = false, onChange, onKeyDown, onPaste, onDragOver, onDragLeave, onDrop, onSubmit, ...props }) {
|
|
756
|
+
export function AgentChatInput({ asChild = false, render, onChange, onKeyDown, onPaste, onDragOver, onDragLeave, onDrop, onSubmit, ...props }) {
|
|
754
757
|
const { setIsDraggingFiles, addAttachments, attachments, prompt, setPrompt, sendFromInputs, isThinking, isAgentReady, isFetchingMessages, agentChat, } = useAgentChat();
|
|
755
758
|
const attachmentsEnabled = agentChat ? agentChat.disableAttachments !== true : false;
|
|
756
759
|
const isDisabled = props.disabled || isThinking || !isAgentReady || isFetchingMessages;
|
|
@@ -817,8 +820,7 @@ export function AgentChatInput({ asChild = false, onChange, onKeyDown, onPaste,
|
|
|
817
820
|
addAttachments(attachments);
|
|
818
821
|
}
|
|
819
822
|
}, [addAttachments, attachmentsEnabled]);
|
|
820
|
-
|
|
821
|
-
return (_jsx(Comp, { value: prompt, onChange: (e) => {
|
|
823
|
+
return (_jsx(ComposeRender, { render: render, asChild: asChild, defaultTag: "textarea", value: prompt, onChange: (e) => {
|
|
822
824
|
handleChange(e);
|
|
823
825
|
onChange?.(e);
|
|
824
826
|
}, onKeyDown: (e) => {
|
|
@@ -844,13 +846,12 @@ export function AgentChatInput({ asChild = false, onChange, onKeyDown, onPaste,
|
|
|
844
846
|
}
|
|
845
847
|
: onDrop, "data-slot": "agent-chat-input", ...props }));
|
|
846
848
|
}
|
|
847
|
-
export function AgentChatSendTrigger({ asChild = false, onClick, disabled, ...props }) {
|
|
849
|
+
export function AgentChatSendTrigger({ asChild = false, render, onClick, disabled, ...props }) {
|
|
848
850
|
const { attachments, prompt, isThinking, isAgentReady, isFetchingMessages, sendFromInputs,
|
|
849
851
|
/* , stopGeneration */
|
|
850
852
|
} = useAgentChat();
|
|
851
|
-
const Comp = asChild ? Slot : "button";
|
|
852
853
|
const isDisabled = Boolean(disabled || isThinking || !isAgentReady || isFetchingMessages || !hasSendableInput(prompt, attachments));
|
|
853
|
-
return (_jsx(
|
|
854
|
+
return (_jsx(ComposeRender, { render: render, asChild: asChild, defaultTag: "button", onClick: (e) => {
|
|
854
855
|
if (isDisabled) {
|
|
855
856
|
e.preventDefault();
|
|
856
857
|
return;
|
|
@@ -863,7 +864,7 @@ export function AgentChatSendTrigger({ asChild = false, onClick, disabled, ...pr
|
|
|
863
864
|
onClick?.(e);
|
|
864
865
|
}, disabled: isDisabled, "data-slot": "agent-chat-send-trigger", ...props }));
|
|
865
866
|
}
|
|
866
|
-
export function AgentChatAttachmentTrigger({ asChild = false, onClick, disabled, accept, multiple = true, ...props }) {
|
|
867
|
+
export function AgentChatAttachmentTrigger({ asChild = false, render, onClick, disabled, accept, multiple = true, ...props }) {
|
|
867
868
|
const { isThinking, isAgentReady, isFetchingMessages, addAttachments, agentChat } = useAgentChat();
|
|
868
869
|
const fileInputRef = useRef(null);
|
|
869
870
|
const disableAttachments = agentChat ? agentChat.disableAttachments === true : true;
|
|
@@ -891,20 +892,17 @@ export function AgentChatAttachmentTrigger({ asChild = false, onClick, disabled,
|
|
|
891
892
|
}
|
|
892
893
|
fileInputRef.current?.click();
|
|
893
894
|
}, [disableAttachments]);
|
|
894
|
-
|
|
895
|
-
return (_jsxs(_Fragment, { children: [!disableAttachments && (_jsx("input", { type: "file", ref: fileInputRef, onChange: handleFileChange, accept: accept, multiple: multiple, disabled: isDisabled, style: { display: "none" }, "aria-hidden": "true" })), _jsx(Comp, { onClick: (e) => {
|
|
895
|
+
return (_jsxs(_Fragment, { children: [!disableAttachments && (_jsx("input", { type: "file", ref: fileInputRef, onChange: handleFileChange, accept: accept, multiple: multiple, disabled: isDisabled, style: { display: "none" }, "aria-hidden": "true" })), _jsx(ComposeRender, { render: render, asChild: asChild, defaultTag: "button", onClick: (e) => {
|
|
896
896
|
handleClick();
|
|
897
897
|
onClick?.(e);
|
|
898
898
|
}, disabled: isDisabled, "data-slot": "agent-chat-attachment-trigger", ...props })] }));
|
|
899
899
|
}
|
|
900
|
-
export function AgentChatAttachment({ attachment, asChild = false, ...props }) {
|
|
901
|
-
|
|
902
|
-
return _jsx(Comp, { "data-slot": "agent-chat-attachment", "data-file-type": attachment.fileType, ...props });
|
|
900
|
+
export function AgentChatAttachment({ attachment, asChild = false, render, ...props }) {
|
|
901
|
+
return (_jsx(ComposeRender, { render: render, asChild: asChild, defaultTag: "div", "data-slot": "agent-chat-attachment", "data-file-type": attachment.fileType, ...props }));
|
|
903
902
|
}
|
|
904
|
-
export function AgentChatAttachmentRemove({ attachment, asChild = false, onClick, ...props }) {
|
|
903
|
+
export function AgentChatAttachmentRemove({ attachment, asChild = false, render, onClick, ...props }) {
|
|
905
904
|
const { removeAttachment } = useAgentChat();
|
|
906
|
-
|
|
907
|
-
return (_jsx(Comp, { onClick: (e) => {
|
|
905
|
+
return (_jsx(ComposeRender, { render: render, asChild: asChild, defaultTag: "button", onClick: (e) => {
|
|
908
906
|
removeAttachment(attachment.url);
|
|
909
907
|
onClick?.(e);
|
|
910
908
|
}, "data-slot": "agent-chat-attachment-remove", ...props }));
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
/**
|
|
3
|
+
* Composition element shared by the agent-chat kit primitives.
|
|
4
|
+
*
|
|
5
|
+
* Blocks apps come in two shadcn flavors (the `base` field of `components.json`):
|
|
6
|
+
* - `base` (Base UI): composes with a `render` prop — `render={<Textarea />}` or
|
|
7
|
+
* `render={(props) => <Textarea {...props} />}`.
|
|
8
|
+
* - `radix` (legacy): composes with `asChild` + a single element child.
|
|
9
|
+
*
|
|
10
|
+
* Kit primitives accept both so the same registry sources work on either flavor.
|
|
11
|
+
* `render` wins when both are provided, and is consumed here — it never reaches the DOM
|
|
12
|
+
* (passing it through would serialize as `render="[object Object]"`).
|
|
13
|
+
*/
|
|
14
|
+
type AnyProps = Record<string, any>;
|
|
15
|
+
export type RenderProp = React.ReactElement<AnyProps> | ((props: AnyProps) => React.ReactNode);
|
|
16
|
+
export interface ComposeRenderProps {
|
|
17
|
+
render?: RenderProp;
|
|
18
|
+
asChild?: boolean;
|
|
19
|
+
defaultTag: keyof React.JSX.IntrinsicElements;
|
|
20
|
+
ref?: React.Ref<unknown>;
|
|
21
|
+
[prop: string]: any;
|
|
22
|
+
}
|
|
23
|
+
export declare function ComposeRender({ render, asChild, defaultTag, ...props }: ComposeRenderProps): React.ReactNode;
|
|
24
|
+
export {};
|
|
25
|
+
//# sourceMappingURL=compose-render.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compose-render.d.ts","sourceRoot":"","sources":["../../src/utils/compose-render.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B;;;;;;;;;;;GAWG;AAEH,KAAK,QAAQ,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;AAEpC,MAAM,MAAM,UAAU,GAAG,KAAK,CAAC,YAAY,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,QAAQ,KAAK,KAAK,CAAC,SAAS,CAAC,CAAC;AAE/F,MAAM,WAAW,kBAAkB;IACjC,MAAM,CAAC,EAAE,UAAU,CAAC;IACpB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,UAAU,EAAE,MAAM,KAAK,CAAC,GAAG,CAAC,iBAAiB,CAAC;IAC9C,GAAG,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IACzB,CAAC,IAAI,EAAE,MAAM,GAAG,GAAG,CAAC;CACrB;AA6CD,wBAAgB,aAAa,CAAC,EAAE,MAAM,EAAE,OAAe,EAAE,UAAU,EAAE,GAAG,KAAK,EAAE,EAAE,kBAAkB,GAAG,KAAK,CAAC,SAAS,CAgBpH"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Slot } from "@radix-ui/react-slot";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
function composeRefs(...refs) {
|
|
5
|
+
return (node) => {
|
|
6
|
+
for (const ref of refs) {
|
|
7
|
+
if (typeof ref === "function") {
|
|
8
|
+
ref(node);
|
|
9
|
+
}
|
|
10
|
+
else if (ref != null) {
|
|
11
|
+
ref.current = node;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
// Mirrors @radix-ui/react-slot's mergeProps so the `render` path behaves like `asChild`:
|
|
17
|
+
// event handlers chain (render element's first), style objects merge, classNames join,
|
|
18
|
+
// and any other prop on the render element wins over the slot's.
|
|
19
|
+
function mergeRenderProps(slotProps, childProps) {
|
|
20
|
+
const overrideProps = { ...childProps };
|
|
21
|
+
for (const propName in childProps) {
|
|
22
|
+
const slotPropValue = slotProps[propName];
|
|
23
|
+
const childPropValue = childProps[propName];
|
|
24
|
+
const isHandler = /^on[A-Z]/.test(propName);
|
|
25
|
+
if (isHandler) {
|
|
26
|
+
if (slotPropValue && childPropValue) {
|
|
27
|
+
overrideProps[propName] = (...args) => {
|
|
28
|
+
const result = childPropValue(...args);
|
|
29
|
+
slotPropValue(...args);
|
|
30
|
+
return result;
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
else if (slotPropValue) {
|
|
34
|
+
overrideProps[propName] = slotPropValue;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
else if (propName === "style") {
|
|
38
|
+
overrideProps[propName] = { ...slotPropValue, ...childPropValue };
|
|
39
|
+
}
|
|
40
|
+
else if (propName === "className") {
|
|
41
|
+
overrideProps[propName] = [slotPropValue, childPropValue].filter(Boolean).join(" ");
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return { ...slotProps, ...overrideProps };
|
|
45
|
+
}
|
|
46
|
+
export function ComposeRender({ render, asChild = false, defaultTag, ...props }) {
|
|
47
|
+
if (render) {
|
|
48
|
+
if (typeof render === "function") {
|
|
49
|
+
return render(props);
|
|
50
|
+
}
|
|
51
|
+
const childProps = (render.props ?? {});
|
|
52
|
+
const merged = mergeRenderProps(props, childProps);
|
|
53
|
+
if (props.ref && childProps.ref) {
|
|
54
|
+
merged.ref = composeRefs(props.ref, childProps.ref);
|
|
55
|
+
}
|
|
56
|
+
return React.cloneElement(render, merged);
|
|
57
|
+
}
|
|
58
|
+
const Comp = asChild ? Slot : defaultTag;
|
|
59
|
+
return _jsx(Comp, { ...props });
|
|
60
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blocksdiy/react-common",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.36.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "React common",
|
|
6
6
|
"keywords": [],
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"penpal": "^7.0.6",
|
|
39
39
|
"react": "^19.2.4",
|
|
40
40
|
"use-stick-to-bottom": "1.1.4",
|
|
41
|
-
"@blocksdiy/blocks-client-api": "1.
|
|
41
|
+
"@blocksdiy/blocks-client-api": "1.5.0"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"@types/react": "^19.2.14",
|