@copilotkitnext/react 0.0.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/.turbo/turbo-build$colon$css.log +9 -0
- package/.turbo/turbo-build.log +28 -0
- package/.turbo/turbo-check-types.log +0 -0
- package/.turbo/turbo-lint.log +78 -0
- package/.turbo/turbo-test.log +79 -0
- package/LICENSE +11 -0
- package/components.json +20 -0
- package/dist/index.d.mts +363 -0
- package/dist/index.d.ts +363 -0
- package/dist/index.js +2322 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +2291 -0
- package/dist/index.mjs.map +1 -0
- package/dist/styles.css +2 -0
- package/eslint.config.mjs +11 -0
- package/package.json +84 -0
- package/postcss.config.js +7 -0
- package/src/__tests__/setup.ts +2 -0
- package/src/components/chat/CopilotChat.tsx +90 -0
- package/src/components/chat/CopilotChatAssistantMessage.tsx +478 -0
- package/src/components/chat/CopilotChatAudioRecorder.tsx +157 -0
- package/src/components/chat/CopilotChatInput.tsx +596 -0
- package/src/components/chat/CopilotChatMessageView.tsx +85 -0
- package/src/components/chat/CopilotChatToolCallsView.tsx +43 -0
- package/src/components/chat/CopilotChatUserMessage.tsx +337 -0
- package/src/components/chat/CopilotChatView.tsx +385 -0
- package/src/components/chat/__tests__/CopilotChatAssistantMessage.test.tsx +684 -0
- package/src/components/chat/__tests__/CopilotChatInput.test.tsx +531 -0
- package/src/components/chat/__tests__/setup.ts +1 -0
- package/src/components/chat/index.ts +35 -0
- package/src/components/index.ts +4 -0
- package/src/components/ui/button.tsx +123 -0
- package/src/components/ui/dropdown-menu.tsx +257 -0
- package/src/components/ui/tooltip.tsx +59 -0
- package/src/hooks/index.ts +6 -0
- package/src/hooks/use-agent-context.tsx +17 -0
- package/src/hooks/use-agent.tsx +48 -0
- package/src/hooks/use-frontend-tool.tsx +46 -0
- package/src/hooks/use-human-in-the-loop.tsx +76 -0
- package/src/hooks/use-render-tool-call.tsx +81 -0
- package/src/index.ts +4 -0
- package/src/lib/__tests__/completePartialMarkdown.test.ts +495 -0
- package/src/lib/__tests__/renderSlot.test.tsx +610 -0
- package/src/lib/slots.tsx +55 -0
- package/src/lib/utils.ts +6 -0
- package/src/providers/CopilotChatConfigurationProvider.tsx +81 -0
- package/src/providers/CopilotKitProvider.tsx +269 -0
- package/src/providers/__tests__/CopilotKitProvider.test.tsx +487 -0
- package/src/providers/__tests__/CopilotKitProvider.wildcard.test.tsx +261 -0
- package/src/providers/index.ts +14 -0
- package/src/styles/globals.css +302 -0
- package/src/types/frontend-tool.ts +8 -0
- package/src/types/human-in-the-loop.ts +33 -0
- package/src/types/index.ts +3 -0
- package/src/types/react-tool-call-render.ts +29 -0
- package/tailwind.config.js +9 -0
- package/test.css +2355 -0
- package/tsconfig.json +23 -0
- package/tsup.config.ts +19 -0
- package/vitest.config.mjs +15 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,363 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import * as React$1 from 'react';
|
|
3
|
+
import React__default, { ReactNode } from 'react';
|
|
4
|
+
import { AssistantMessage, Message, UserMessage, ToolCall, ToolMessage } from '@ag-ui/core';
|
|
5
|
+
import { ToolCallStatus, FrontendTool, CopilotKitCore } from '@copilotkitnext/core';
|
|
6
|
+
import { z } from 'zod';
|
|
7
|
+
import { AbstractAgent, Context } from '@ag-ui/client';
|
|
8
|
+
|
|
9
|
+
declare const CopilotChatDefaultLabels: {
|
|
10
|
+
chatInputPlaceholder: string;
|
|
11
|
+
chatInputToolbarStartTranscribeButtonLabel: string;
|
|
12
|
+
chatInputToolbarCancelTranscribeButtonLabel: string;
|
|
13
|
+
chatInputToolbarFinishTranscribeButtonLabel: string;
|
|
14
|
+
chatInputToolbarAddButtonLabel: string;
|
|
15
|
+
chatInputToolbarToolsButtonLabel: string;
|
|
16
|
+
assistantMessageToolbarCopyCodeLabel: string;
|
|
17
|
+
assistantMessageToolbarCopyCodeCopiedLabel: string;
|
|
18
|
+
assistantMessageToolbarCopyMessageLabel: string;
|
|
19
|
+
assistantMessageToolbarThumbsUpLabel: string;
|
|
20
|
+
assistantMessageToolbarThumbsDownLabel: string;
|
|
21
|
+
assistantMessageToolbarReadAloudLabel: string;
|
|
22
|
+
assistantMessageToolbarRegenerateLabel: string;
|
|
23
|
+
userMessageToolbarCopyMessageLabel: string;
|
|
24
|
+
userMessageToolbarEditMessageLabel: string;
|
|
25
|
+
chatDisclaimerText: string;
|
|
26
|
+
};
|
|
27
|
+
type CopilotChatLabels = typeof CopilotChatDefaultLabels;
|
|
28
|
+
interface CopilotChatConfigurationValue {
|
|
29
|
+
labels: CopilotChatLabels;
|
|
30
|
+
inputValue?: string;
|
|
31
|
+
onSubmitInput?: (value: string) => void;
|
|
32
|
+
onChangeInput?: (value: string) => void;
|
|
33
|
+
}
|
|
34
|
+
interface CopilotChatConfigurationProviderProps {
|
|
35
|
+
children: ReactNode;
|
|
36
|
+
labels?: Partial<CopilotChatLabels>;
|
|
37
|
+
inputValue?: string;
|
|
38
|
+
onSubmitInput?: (value: string) => void;
|
|
39
|
+
onChangeInput?: (value: string) => void;
|
|
40
|
+
}
|
|
41
|
+
declare const CopilotChatConfigurationProvider: React__default.FC<CopilotChatConfigurationProviderProps>;
|
|
42
|
+
declare const useCopilotChatConfiguration: () => CopilotChatConfigurationValue;
|
|
43
|
+
|
|
44
|
+
/** Finite-state machine for every recorder implementation */
|
|
45
|
+
type AudioRecorderState = "idle" | "recording" | "processing";
|
|
46
|
+
/** Error subclass so callers can `instanceof`-guard recorder failures */
|
|
47
|
+
declare class AudioRecorderError extends Error {
|
|
48
|
+
constructor(message: string);
|
|
49
|
+
}
|
|
50
|
+
declare const CopilotChatAudioRecorder: React$1.ForwardRefExoticComponent<React$1.HTMLAttributes<HTMLDivElement> & React$1.RefAttributes<any>>;
|
|
51
|
+
|
|
52
|
+
/** Existing union (unchanged) */
|
|
53
|
+
type SlotValue<C extends React__default.ComponentType<any>> = C | string | Partial<React__default.ComponentProps<C>>;
|
|
54
|
+
/** Utility: concrete React elements for every slot */
|
|
55
|
+
type SlotElements<S> = {
|
|
56
|
+
[K in keyof S]: React__default.ReactElement;
|
|
57
|
+
};
|
|
58
|
+
type WithSlots<S extends Record<string, React__default.ComponentType<any>>, Rest = {}> = {
|
|
59
|
+
[K in keyof S]?: SlotValue<S[K]>;
|
|
60
|
+
} & {
|
|
61
|
+
children?: (props: SlotElements<S> & Rest) => React__default.ReactNode;
|
|
62
|
+
} & Omit<Rest, "children">;
|
|
63
|
+
|
|
64
|
+
type CopilotChatInputMode = "input" | "transcribe" | "processing";
|
|
65
|
+
type ToolsMenuItem = {
|
|
66
|
+
label: string;
|
|
67
|
+
} & ({
|
|
68
|
+
action: () => void;
|
|
69
|
+
items?: never;
|
|
70
|
+
} | {
|
|
71
|
+
action?: never;
|
|
72
|
+
items: (ToolsMenuItem | "-")[];
|
|
73
|
+
});
|
|
74
|
+
type CopilotChatInputProps = WithSlots<{
|
|
75
|
+
textArea: typeof CopilotChatInput.TextArea;
|
|
76
|
+
sendButton: typeof CopilotChatInput.SendButton;
|
|
77
|
+
startTranscribeButton: typeof CopilotChatInput.StartTranscribeButton;
|
|
78
|
+
cancelTranscribeButton: typeof CopilotChatInput.CancelTranscribeButton;
|
|
79
|
+
finishTranscribeButton: typeof CopilotChatInput.FinishTranscribeButton;
|
|
80
|
+
addFileButton: typeof CopilotChatInput.AddFileButton;
|
|
81
|
+
toolsButton: typeof CopilotChatInput.ToolsButton;
|
|
82
|
+
toolbar: typeof CopilotChatInput.Toolbar;
|
|
83
|
+
audioRecorder: typeof CopilotChatAudioRecorder;
|
|
84
|
+
}, {
|
|
85
|
+
mode?: CopilotChatInputMode;
|
|
86
|
+
toolsMenu?: (ToolsMenuItem | "-")[];
|
|
87
|
+
autoFocus?: boolean;
|
|
88
|
+
additionalToolbarItems?: React__default.ReactNode;
|
|
89
|
+
onSubmitMessage?: (value: string) => void;
|
|
90
|
+
onStartTranscribe?: () => void;
|
|
91
|
+
onCancelTranscribe?: () => void;
|
|
92
|
+
onFinishTranscribe?: () => void;
|
|
93
|
+
onAddFile?: () => void;
|
|
94
|
+
value?: string;
|
|
95
|
+
onChange?: (value: string) => void;
|
|
96
|
+
} & Omit<React__default.HTMLAttributes<HTMLDivElement>, "onChange">>;
|
|
97
|
+
declare function CopilotChatInput({ mode, onSubmitMessage, onStartTranscribe, onCancelTranscribe, onFinishTranscribe, onAddFile, onChange, value, toolsMenu, autoFocus, additionalToolbarItems, textArea, sendButton, startTranscribeButton, cancelTranscribeButton, finishTranscribeButton, addFileButton, toolsButton, toolbar, audioRecorder, children, className, ...props }: CopilotChatInputProps): react_jsx_runtime.JSX.Element;
|
|
98
|
+
declare namespace CopilotChatInput {
|
|
99
|
+
const SendButton: React__default.FC<React__default.ButtonHTMLAttributes<HTMLButtonElement>>;
|
|
100
|
+
const ToolbarButton: React__default.FC<React__default.ButtonHTMLAttributes<HTMLButtonElement> & {
|
|
101
|
+
icon: React__default.ReactNode;
|
|
102
|
+
labelKey: keyof CopilotChatLabels;
|
|
103
|
+
defaultClassName?: string;
|
|
104
|
+
}>;
|
|
105
|
+
const StartTranscribeButton: React__default.FC<React__default.ButtonHTMLAttributes<HTMLButtonElement>>;
|
|
106
|
+
const CancelTranscribeButton: React__default.FC<React__default.ButtonHTMLAttributes<HTMLButtonElement>>;
|
|
107
|
+
const FinishTranscribeButton: React__default.FC<React__default.ButtonHTMLAttributes<HTMLButtonElement>>;
|
|
108
|
+
const AddFileButton: React__default.FC<React__default.ButtonHTMLAttributes<HTMLButtonElement>>;
|
|
109
|
+
const ToolsButton: React__default.FC<React__default.ButtonHTMLAttributes<HTMLButtonElement> & {
|
|
110
|
+
toolsMenu?: (ToolsMenuItem | "-")[];
|
|
111
|
+
}>;
|
|
112
|
+
const Toolbar: React__default.FC<React__default.HTMLAttributes<HTMLDivElement>>;
|
|
113
|
+
interface TextAreaProps extends React__default.TextareaHTMLAttributes<HTMLTextAreaElement> {
|
|
114
|
+
maxRows?: number;
|
|
115
|
+
}
|
|
116
|
+
const TextArea: React__default.ForwardRefExoticComponent<TextAreaProps & React__default.RefAttributes<HTMLTextAreaElement>>;
|
|
117
|
+
const AudioRecorder: React__default.ForwardRefExoticComponent<React__default.HTMLAttributes<HTMLDivElement> & React__default.RefAttributes<any>>;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
type CopilotChatToolCallsViewProps = {
|
|
121
|
+
message: AssistantMessage;
|
|
122
|
+
messages?: Message[];
|
|
123
|
+
isLoading?: boolean;
|
|
124
|
+
};
|
|
125
|
+
declare function CopilotChatToolCallsView({ message, messages, isLoading, }: CopilotChatToolCallsViewProps): react_jsx_runtime.JSX.Element | null;
|
|
126
|
+
|
|
127
|
+
type CopilotChatAssistantMessageProps = WithSlots<{
|
|
128
|
+
markdownRenderer: typeof CopilotChatAssistantMessage.MarkdownRenderer;
|
|
129
|
+
toolbar: typeof CopilotChatAssistantMessage.Toolbar;
|
|
130
|
+
copyButton: typeof CopilotChatAssistantMessage.CopyButton;
|
|
131
|
+
thumbsUpButton: typeof CopilotChatAssistantMessage.ThumbsUpButton;
|
|
132
|
+
thumbsDownButton: typeof CopilotChatAssistantMessage.ThumbsDownButton;
|
|
133
|
+
readAloudButton: typeof CopilotChatAssistantMessage.ReadAloudButton;
|
|
134
|
+
regenerateButton: typeof CopilotChatAssistantMessage.RegenerateButton;
|
|
135
|
+
toolCallsView: typeof CopilotChatToolCallsView;
|
|
136
|
+
}, {
|
|
137
|
+
onThumbsUp?: (message: AssistantMessage) => void;
|
|
138
|
+
onThumbsDown?: (message: AssistantMessage) => void;
|
|
139
|
+
onReadAloud?: (message: AssistantMessage) => void;
|
|
140
|
+
onRegenerate?: (message: AssistantMessage) => void;
|
|
141
|
+
message: AssistantMessage;
|
|
142
|
+
messages?: Message[];
|
|
143
|
+
isLoading?: boolean;
|
|
144
|
+
additionalToolbarItems?: React.ReactNode;
|
|
145
|
+
toolbarVisible?: boolean;
|
|
146
|
+
} & React.HTMLAttributes<HTMLDivElement>>;
|
|
147
|
+
declare function CopilotChatAssistantMessage({ message, messages, isLoading, onThumbsUp, onThumbsDown, onReadAloud, onRegenerate, additionalToolbarItems, toolbarVisible, markdownRenderer, toolbar, copyButton, thumbsUpButton, thumbsDownButton, readAloudButton, regenerateButton, toolCallsView, children, className, ...props }: CopilotChatAssistantMessageProps): react_jsx_runtime.JSX.Element;
|
|
148
|
+
declare namespace CopilotChatAssistantMessage {
|
|
149
|
+
const MarkdownRenderer: React.FC<React.HTMLAttributes<HTMLDivElement> & {
|
|
150
|
+
content: string;
|
|
151
|
+
}>;
|
|
152
|
+
const Toolbar: React.FC<React.HTMLAttributes<HTMLDivElement>>;
|
|
153
|
+
const ToolbarButton: React.FC<React.ButtonHTMLAttributes<HTMLButtonElement> & {
|
|
154
|
+
title: string;
|
|
155
|
+
children: React.ReactNode;
|
|
156
|
+
}>;
|
|
157
|
+
const CopyButton: React.FC<React.ButtonHTMLAttributes<HTMLButtonElement>>;
|
|
158
|
+
const ThumbsUpButton: React.FC<React.ButtonHTMLAttributes<HTMLButtonElement>>;
|
|
159
|
+
const ThumbsDownButton: React.FC<React.ButtonHTMLAttributes<HTMLButtonElement>>;
|
|
160
|
+
const ReadAloudButton: React.FC<React.ButtonHTMLAttributes<HTMLButtonElement>>;
|
|
161
|
+
const RegenerateButton: React.FC<React.ButtonHTMLAttributes<HTMLButtonElement>>;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
interface CopilotChatUserMessageOnEditMessageProps {
|
|
165
|
+
message: UserMessage;
|
|
166
|
+
}
|
|
167
|
+
interface CopilotChatUserMessageOnSwitchToBranchProps {
|
|
168
|
+
message: UserMessage;
|
|
169
|
+
branchIndex: number;
|
|
170
|
+
numberOfBranches: number;
|
|
171
|
+
}
|
|
172
|
+
type CopilotChatUserMessageProps = WithSlots<{
|
|
173
|
+
messageRenderer: typeof CopilotChatUserMessage.MessageRenderer;
|
|
174
|
+
toolbar: typeof CopilotChatUserMessage.Toolbar;
|
|
175
|
+
copyButton: typeof CopilotChatUserMessage.CopyButton;
|
|
176
|
+
editButton: typeof CopilotChatUserMessage.EditButton;
|
|
177
|
+
branchNavigation: typeof CopilotChatUserMessage.BranchNavigation;
|
|
178
|
+
}, {
|
|
179
|
+
onEditMessage?: (props: CopilotChatUserMessageOnEditMessageProps) => void;
|
|
180
|
+
onSwitchToBranch?: (props: CopilotChatUserMessageOnSwitchToBranchProps) => void;
|
|
181
|
+
message: UserMessage;
|
|
182
|
+
branchIndex?: number;
|
|
183
|
+
numberOfBranches?: number;
|
|
184
|
+
additionalToolbarItems?: React.ReactNode;
|
|
185
|
+
} & React.HTMLAttributes<HTMLDivElement>>;
|
|
186
|
+
declare function CopilotChatUserMessage({ message, onEditMessage, branchIndex, numberOfBranches, onSwitchToBranch, additionalToolbarItems, messageRenderer, toolbar, copyButton, editButton, branchNavigation, children, className, ...props }: CopilotChatUserMessageProps): react_jsx_runtime.JSX.Element;
|
|
187
|
+
declare namespace CopilotChatUserMessage {
|
|
188
|
+
const Container: React.FC<React.PropsWithChildren<React.HTMLAttributes<HTMLDivElement>>>;
|
|
189
|
+
const MessageRenderer: React.FC<{
|
|
190
|
+
content: string;
|
|
191
|
+
className?: string;
|
|
192
|
+
}>;
|
|
193
|
+
const Toolbar: React.FC<React.HTMLAttributes<HTMLDivElement>>;
|
|
194
|
+
const ToolbarButton: React.FC<React.ButtonHTMLAttributes<HTMLButtonElement> & {
|
|
195
|
+
title: string;
|
|
196
|
+
children: React.ReactNode;
|
|
197
|
+
}>;
|
|
198
|
+
const CopyButton: React.FC<React.ButtonHTMLAttributes<HTMLButtonElement> & {
|
|
199
|
+
copied?: boolean;
|
|
200
|
+
}>;
|
|
201
|
+
const EditButton: React.FC<React.ButtonHTMLAttributes<HTMLButtonElement>>;
|
|
202
|
+
const BranchNavigation: React.FC<React.HTMLAttributes<HTMLDivElement> & {
|
|
203
|
+
currentBranch?: number;
|
|
204
|
+
numberOfBranches?: number;
|
|
205
|
+
onSwitchToBranch?: (props: CopilotChatUserMessageOnSwitchToBranchProps) => void;
|
|
206
|
+
message: UserMessage;
|
|
207
|
+
}>;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
type CopilotChatMessageViewProps = Omit<WithSlots<{
|
|
211
|
+
assistantMessage: typeof CopilotChatAssistantMessage;
|
|
212
|
+
userMessage: typeof CopilotChatUserMessage;
|
|
213
|
+
cursor: typeof CopilotChatMessageView.Cursor;
|
|
214
|
+
}, {
|
|
215
|
+
isLoading?: boolean;
|
|
216
|
+
messages?: Message[];
|
|
217
|
+
} & React.HTMLAttributes<HTMLDivElement>>, "children"> & {
|
|
218
|
+
children?: (props: {
|
|
219
|
+
isLoading: boolean;
|
|
220
|
+
messages: Message[];
|
|
221
|
+
messageElements: React.ReactElement[];
|
|
222
|
+
}) => React.ReactElement;
|
|
223
|
+
};
|
|
224
|
+
declare function CopilotChatMessageView({ messages, assistantMessage, userMessage, cursor, isLoading, children, className, ...props }: CopilotChatMessageViewProps): react_jsx_runtime.JSX.Element;
|
|
225
|
+
declare namespace CopilotChatMessageView {
|
|
226
|
+
var Cursor: ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) => react_jsx_runtime.JSX.Element;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
type CopilotChatViewProps = WithSlots<{
|
|
230
|
+
messageView: typeof CopilotChatMessageView;
|
|
231
|
+
scrollView: React__default.FC<React__default.HTMLAttributes<HTMLDivElement>>;
|
|
232
|
+
scrollToBottomButton: React__default.FC<React__default.ButtonHTMLAttributes<HTMLButtonElement>>;
|
|
233
|
+
input: typeof CopilotChatInput;
|
|
234
|
+
inputContainer: React__default.FC<React__default.HTMLAttributes<HTMLDivElement> & {
|
|
235
|
+
children: React__default.ReactNode;
|
|
236
|
+
}>;
|
|
237
|
+
feather: React__default.FC<React__default.HTMLAttributes<HTMLDivElement>>;
|
|
238
|
+
disclaimer: React__default.FC<React__default.HTMLAttributes<HTMLDivElement>>;
|
|
239
|
+
}, {
|
|
240
|
+
messages?: Message[];
|
|
241
|
+
autoScroll?: boolean;
|
|
242
|
+
} & React__default.HTMLAttributes<HTMLDivElement>>;
|
|
243
|
+
declare function CopilotChatView({ messageView, input, scrollView, scrollToBottomButton, feather, inputContainer, disclaimer, messages, autoScroll, children, className, ...props }: CopilotChatViewProps): string | number | bigint | boolean | Iterable<React__default.ReactNode> | Promise<string | number | bigint | boolean | React__default.ReactPortal | React__default.ReactElement<unknown, string | React__default.JSXElementConstructor<any>> | Iterable<React__default.ReactNode> | null | undefined> | react_jsx_runtime.JSX.Element | null | undefined;
|
|
244
|
+
declare namespace CopilotChatView {
|
|
245
|
+
const ScrollView: React__default.FC<React__default.HTMLAttributes<HTMLDivElement> & {
|
|
246
|
+
autoScroll?: boolean;
|
|
247
|
+
scrollToBottomButton?: React__default.FC<React__default.ButtonHTMLAttributes<HTMLButtonElement>>;
|
|
248
|
+
inputContainerHeight?: number;
|
|
249
|
+
isResizing?: boolean;
|
|
250
|
+
}>;
|
|
251
|
+
const ScrollToBottomButton: React__default.FC<React__default.ButtonHTMLAttributes<HTMLButtonElement>>;
|
|
252
|
+
const Feather: React__default.FC<React__default.HTMLAttributes<HTMLDivElement>>;
|
|
253
|
+
const InputContainer: React__default.ForwardRefExoticComponent<React__default.HTMLAttributes<HTMLDivElement> & {
|
|
254
|
+
children: React__default.ReactNode;
|
|
255
|
+
} & React__default.RefAttributes<HTMLDivElement>>;
|
|
256
|
+
const Disclaimer: React__default.FC<React__default.HTMLAttributes<HTMLDivElement>>;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
type CopilotChatProps = Omit<CopilotChatViewProps, "messages"> & {
|
|
260
|
+
agentId?: string;
|
|
261
|
+
threadId?: string;
|
|
262
|
+
};
|
|
263
|
+
declare function CopilotChat({ agentId, threadId, ...props }: CopilotChatProps): react_jsx_runtime.JSX.Element;
|
|
264
|
+
|
|
265
|
+
interface UseRenderToolCallProps {
|
|
266
|
+
toolCall: ToolCall;
|
|
267
|
+
toolMessage?: ToolMessage;
|
|
268
|
+
isLoading: boolean;
|
|
269
|
+
}
|
|
270
|
+
/**
|
|
271
|
+
* Hook that returns a function to render tool calls based on the render functions
|
|
272
|
+
* defined in CopilotKitProvider.
|
|
273
|
+
*
|
|
274
|
+
* @returns A function that takes a tool call and optional tool message and returns the rendered component
|
|
275
|
+
*/
|
|
276
|
+
declare function useRenderToolCall(): ({ toolCall, toolMessage, isLoading, }: UseRenderToolCallProps) => React__default.ReactElement | null;
|
|
277
|
+
|
|
278
|
+
interface ReactToolCallRender<T> {
|
|
279
|
+
name: string;
|
|
280
|
+
args: z.ZodSchema<T>;
|
|
281
|
+
/**
|
|
282
|
+
* Optional agent ID to constrain this tool render to a specific agent.
|
|
283
|
+
* If specified, this render will only be used for the specified agent.
|
|
284
|
+
*/
|
|
285
|
+
agentId?: string;
|
|
286
|
+
render: React.ComponentType<{
|
|
287
|
+
args: Partial<T>;
|
|
288
|
+
status: ToolCallStatus.InProgress;
|
|
289
|
+
result: undefined;
|
|
290
|
+
} | {
|
|
291
|
+
args: T;
|
|
292
|
+
status: ToolCallStatus.Executing;
|
|
293
|
+
result: undefined;
|
|
294
|
+
} | {
|
|
295
|
+
args: T;
|
|
296
|
+
status: ToolCallStatus.Complete;
|
|
297
|
+
result: string;
|
|
298
|
+
}>;
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
type ReactFrontendTool<T extends Record<string, unknown> = Record<string, unknown>> = FrontendTool<T> & {
|
|
302
|
+
render?: ReactToolCallRender<T>["render"];
|
|
303
|
+
};
|
|
304
|
+
|
|
305
|
+
declare function useFrontendTool<T extends Record<string, unknown> = Record<string, unknown>>(tool: ReactFrontendTool<T>): void;
|
|
306
|
+
|
|
307
|
+
type ReactHumanInTheLoop<T extends Record<string, unknown> = Record<string, unknown>> = Omit<FrontendTool<T>, "handler"> & {
|
|
308
|
+
render: React__default.ComponentType<{
|
|
309
|
+
name: string;
|
|
310
|
+
description: string;
|
|
311
|
+
args: Partial<T>;
|
|
312
|
+
status: ToolCallStatus.InProgress;
|
|
313
|
+
result: undefined;
|
|
314
|
+
respond: undefined;
|
|
315
|
+
} | {
|
|
316
|
+
name: string;
|
|
317
|
+
description: string;
|
|
318
|
+
args: T;
|
|
319
|
+
status: ToolCallStatus.Executing;
|
|
320
|
+
result: undefined;
|
|
321
|
+
respond: (result: unknown) => Promise<void>;
|
|
322
|
+
} | {
|
|
323
|
+
name: string;
|
|
324
|
+
description: string;
|
|
325
|
+
args: T;
|
|
326
|
+
status: ToolCallStatus.Complete;
|
|
327
|
+
result: string;
|
|
328
|
+
respond: undefined;
|
|
329
|
+
}>;
|
|
330
|
+
};
|
|
331
|
+
|
|
332
|
+
declare function useHumanInTheLoop<T extends Record<string, unknown> = Record<string, unknown>>(tool: ReactHumanInTheLoop<T>): void;
|
|
333
|
+
|
|
334
|
+
interface UseAgentProps {
|
|
335
|
+
agentId?: string;
|
|
336
|
+
}
|
|
337
|
+
declare function useAgent({ agentId }?: UseAgentProps): {
|
|
338
|
+
agent: AbstractAgent | undefined;
|
|
339
|
+
isRunning: boolean;
|
|
340
|
+
};
|
|
341
|
+
|
|
342
|
+
declare function useAgentContext(context: Context): void;
|
|
343
|
+
|
|
344
|
+
interface CopilotKitContextValue {
|
|
345
|
+
copilotkit: CopilotKitCore;
|
|
346
|
+
renderToolCalls: ReactToolCallRender<unknown>[];
|
|
347
|
+
currentRenderToolCalls: ReactToolCallRender<unknown>[];
|
|
348
|
+
setCurrentRenderToolCalls: React__default.Dispatch<React__default.SetStateAction<ReactToolCallRender<unknown>[]>>;
|
|
349
|
+
}
|
|
350
|
+
interface CopilotKitProviderProps {
|
|
351
|
+
children: ReactNode;
|
|
352
|
+
runtimeUrl?: string;
|
|
353
|
+
headers?: Record<string, string>;
|
|
354
|
+
properties?: Record<string, unknown>;
|
|
355
|
+
agents?: Record<string, AbstractAgent>;
|
|
356
|
+
renderToolCalls?: ReactToolCallRender<unknown>[];
|
|
357
|
+
frontendTools?: ReactFrontendTool[];
|
|
358
|
+
humanInTheLoop?: ReactHumanInTheLoop[];
|
|
359
|
+
}
|
|
360
|
+
declare const CopilotKitProvider: React__default.FC<CopilotKitProviderProps>;
|
|
361
|
+
declare const useCopilotKit: () => CopilotKitContextValue;
|
|
362
|
+
|
|
363
|
+
export { AudioRecorderError, type AudioRecorderState, CopilotChat, CopilotChatAssistantMessage, type CopilotChatAssistantMessageProps, CopilotChatAudioRecorder, CopilotChatConfigurationProvider, type CopilotChatConfigurationProviderProps, type CopilotChatConfigurationValue, CopilotChatInput, type CopilotChatInputProps, type CopilotChatLabels, CopilotChatMessageView, type CopilotChatMessageViewProps, type CopilotChatProps, CopilotChatToolCallsView, type CopilotChatToolCallsViewProps, CopilotChatUserMessage, type CopilotChatUserMessageProps, CopilotChatView, type CopilotChatViewProps, type CopilotKitContextValue, CopilotKitProvider, type CopilotKitProviderProps, type ToolsMenuItem, useAgent, useAgentContext, useCopilotChatConfiguration, useCopilotKit, useFrontendTool, useHumanInTheLoop, useRenderToolCall };
|