@copilotkit/react-core 2.0.0-rc.6 → 2.0.0-rc.8
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/{MarkdownRendererContext-B4Us6mwL.d.cts → MarkdownRendererContext-DAuVISwv.d.cts} +14 -30
- package/dist/MarkdownRendererContext-DAuVISwv.d.cts.map +1 -0
- package/dist/{MarkdownRendererContext-CRKFzsEB.d.mts → MarkdownRendererContext-XWC2OXD5.d.mts} +15 -31
- package/dist/MarkdownRendererContext-XWC2OXD5.d.mts.map +1 -0
- package/dist/{MarkdownSurfaces-Bd--93O1.mjs → MarkdownSurfaces-BXaxgpm_.mjs} +91 -74
- package/dist/MarkdownSurfaces-BXaxgpm_.mjs.map +1 -0
- package/dist/{MarkdownSurfaces-S4wfUl3J.cjs → MarkdownSurfaces-DQZM4lSI.cjs} +96 -73
- package/dist/MarkdownSurfaces-DQZM4lSI.cjs.map +1 -0
- package/dist/context.cjs +20 -17
- package/dist/context.cjs.map +1 -1
- package/dist/context.d.cts +38 -98
- package/dist/context.d.cts.map +1 -1
- package/dist/context.d.mts +38 -98
- package/dist/context.d.mts.map +1 -1
- package/dist/context.mjs +20 -17
- package/dist/context.mjs.map +1 -1
- package/dist/generative-ui.cjs +35 -15
- package/dist/generative-ui.cjs.map +1 -1
- package/dist/generative-ui.d.cts +9 -9
- package/dist/generative-ui.d.mts +9 -9
- package/dist/generative-ui.mjs +35 -15
- package/dist/generative-ui.mjs.map +1 -1
- package/dist/headless.cjs +50 -76
- package/dist/headless.cjs.map +1 -1
- package/dist/headless.d.cts +78 -253
- package/dist/headless.d.cts.map +1 -1
- package/dist/headless.d.mts +56 -202
- package/dist/headless.d.mts.map +1 -1
- package/dist/headless.mjs +43 -74
- package/dist/headless.mjs.map +1 -1
- package/dist/index.cjs +667 -963
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +168 -485
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +168 -485
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +446 -954
- package/dist/index.mjs.map +1 -1
- package/dist/index.umd.js +757 -1034
- package/dist/index.umd.js.map +1 -1
- package/package.json +9 -10
- package/dist/MarkdownRendererContext-B4Us6mwL.d.cts.map +0 -1
- package/dist/MarkdownRendererContext-CRKFzsEB.d.mts.map +0 -1
- package/dist/MarkdownSurfaces-Bd--93O1.mjs.map +0 -1
- package/dist/MarkdownSurfaces-S4wfUl3J.cjs.map +0 -1
package/dist/headless.d.cts
CHANGED
|
@@ -1,90 +1,46 @@
|
|
|
1
1
|
import React$1, { ComponentType, ReactNode } from "react";
|
|
2
|
+
import { ActivityMessageRenderProps, ActivityMessageRendererDef, CopilotChatDefaultLabels, CopilotChatLabels, CopilotChatLabels as CopilotChatLabels$1, CopilotKitCore, CopilotKitCoreConfig, CopilotKitCoreSubscriber, CopilotKitCoreSubscription, CustomMessageRenderProps, CustomMessageRendererDef, DynamicSuggestionsConfig, FrontendTool, HumanInTheLoopRenderProps, InterruptEvent, InterruptHandlerProps, InterruptRenderProps, StaticSuggestionsConfig, Suggestion, ToolCallRenderProps, ToolCallRendererDef } from "@copilotkit/core";
|
|
2
3
|
import { InferSchemaOutput, StandardSchemaV1 } from "@copilotkit/shared";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { AbstractAgent, Interrupt, ResumeEntry, ResumeStatus, RunAgentResult } from "@ag-ui/client";
|
|
4
|
+
import { AbstractAgent, Interrupt, ResumeEntry, ResumeStatus } from "@ag-ui/client";
|
|
5
|
+
import { AgentCapabilities, ToolCall, ToolMessage } from "@ag-ui/core";
|
|
6
6
|
|
|
7
7
|
//#region src/types/react-tool-call-renderer.d.ts
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
*/
|
|
19
|
-
agentId?: string;
|
|
20
|
-
/**
|
|
21
|
-
* Whether calls this renderer draws join the chat's tool-call groups (see
|
|
22
|
-
* `toolCallDisplay` on `CopilotChatMessageView`). CopilotKit's built-in card
|
|
23
|
-
* sets it; a renderer that leaves it unset always shows its calls on their
|
|
24
|
-
* own, since the chat can't tell what it draws (it may even draw nothing).
|
|
25
|
-
*/
|
|
26
|
-
group?: boolean;
|
|
27
|
-
render: React.ComponentType<{
|
|
28
|
-
name: string;
|
|
29
|
-
toolCallId: string;
|
|
30
|
-
args: Partial<T>;
|
|
31
|
-
status: ToolCallStatus.InProgress;
|
|
32
|
-
result: undefined;
|
|
33
|
-
} | {
|
|
34
|
-
name: string;
|
|
35
|
-
toolCallId: string;
|
|
36
|
-
args: T;
|
|
37
|
-
status: ToolCallStatus.Executing;
|
|
38
|
-
result: undefined;
|
|
39
|
-
} | {
|
|
40
|
-
name: string;
|
|
41
|
-
toolCallId: string;
|
|
42
|
-
args: T;
|
|
43
|
-
status: ToolCallStatus.Complete;
|
|
44
|
-
result: string;
|
|
45
|
-
}>;
|
|
46
|
-
}
|
|
8
|
+
/**
|
|
9
|
+
* A tool call renderer for React: a React component that draws one tool call
|
|
10
|
+
* in the chat. The component receives {@link ToolCallRenderProps}.
|
|
11
|
+
*
|
|
12
|
+
* Pass a list of these to `renderToolCalls` on `CopilotKitProvider`, or build
|
|
13
|
+
* one with `defineToolCallRenderer`.
|
|
14
|
+
*
|
|
15
|
+
* @typeParam T - The shape of the tool arguments.
|
|
16
|
+
*/
|
|
17
|
+
type ReactToolCallRenderer<T = unknown> = ToolCallRendererDef<T, React$1.ComponentType<ToolCallRenderProps<T>>>;
|
|
47
18
|
//#endregion
|
|
48
19
|
//#region src/types/react-activity-message-renderer.d.ts
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
agentId?: string;
|
|
58
|
-
/**
|
|
59
|
-
* Schema describing the activity content payload.
|
|
60
|
-
*/
|
|
61
|
-
content: StandardSchemaV1<any, TActivityContent>;
|
|
62
|
-
/**
|
|
63
|
-
* React component invoked to render the activity message.
|
|
64
|
-
*/
|
|
65
|
-
render: React.ComponentType<{
|
|
66
|
-
activityType: string;
|
|
67
|
-
content: TActivityContent;
|
|
68
|
-
message: ActivityMessage;
|
|
69
|
-
agent: AbstractAgent | undefined;
|
|
70
|
-
}>;
|
|
71
|
-
}
|
|
20
|
+
/**
|
|
21
|
+
* An activity message renderer for React: a React component that draws
|
|
22
|
+
* activity messages of one `activityType` (or `"*"` for any type). The
|
|
23
|
+
* component receives {@link ActivityMessageRenderProps}.
|
|
24
|
+
*
|
|
25
|
+
* @typeParam TActivityContent - The shape of the activity content.
|
|
26
|
+
*/
|
|
27
|
+
type ReactActivityMessageRenderer<TActivityContent> = ActivityMessageRendererDef<TActivityContent, React$1.ComponentType<ActivityMessageRenderProps<TActivityContent>>>;
|
|
72
28
|
//#endregion
|
|
73
29
|
//#region src/types/react-custom-message-renderer.d.ts
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
30
|
+
/**
|
|
31
|
+
* Props a React custom message renderer receives: the same as
|
|
32
|
+
* {@link CustomMessageRenderProps}, with `stateSnapshot` typed `any` so a
|
|
33
|
+
* component can read the agent state without a cast.
|
|
34
|
+
*/
|
|
35
|
+
type ReactCustomMessageRenderProps = Omit<CustomMessageRenderProps, "stateSnapshot"> & {
|
|
36
|
+
stateSnapshot: any;
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* A custom message renderer for React: a component that draws before or
|
|
40
|
+
* after each chat message. Return `null` from the component to draw nothing
|
|
41
|
+
* for a message. A `null` render is skipped.
|
|
42
|
+
*/
|
|
43
|
+
type ReactCustomMessageRenderer = CustomMessageRendererDef<React$1.ComponentType<ReactCustomMessageRenderProps> | null>;
|
|
88
44
|
//#endregion
|
|
89
45
|
//#region src/types/frontend-tool.d.ts
|
|
90
46
|
type ReactFrontendTool<T extends Record<string, unknown> = Record<string, unknown>> = FrontendTool<T> & {
|
|
@@ -92,51 +48,19 @@ type ReactFrontendTool<T extends Record<string, unknown> = Record<string, unknow
|
|
|
92
48
|
};
|
|
93
49
|
//#endregion
|
|
94
50
|
//#region src/types/human-in-the-loop.d.ts
|
|
51
|
+
/**
|
|
52
|
+
* A human-in-the-loop tool for React. It has no handler: the agent waits until
|
|
53
|
+
* the `render` component calls `respond` with the user's answer.
|
|
54
|
+
*
|
|
55
|
+
* @typeParam T - The shape of the tool arguments.
|
|
56
|
+
*/
|
|
95
57
|
type ReactHumanInTheLoop<T extends Record<string, unknown> = Record<string, unknown>> = Omit<FrontendTool<T>, "handler"> & {
|
|
96
58
|
/**
|
|
97
|
-
* Render the human-in-the-loop UI for this tool call.
|
|
98
|
-
*
|
|
99
|
-
*
|
|
100
|
-
* attribution:
|
|
101
|
-
* - `toolCallId` — the AG-UI tool call id, unique per interrupt. It is the
|
|
102
|
-
* stable key for correlating this interrupt with runtime (sub)agent
|
|
103
|
-
* attribution — e.g. the `agentId` reported by `onToolExecutionStart`, or
|
|
104
|
-
* per-run attribution stamped on the event stream — so the UI can label
|
|
105
|
-
* the interrupt with the agent that actually raised it.
|
|
106
|
-
* - `agentId` — the agent this tool was *registered* to (the tool's own
|
|
107
|
-
* `agentId`), or `undefined` for an unscoped tool. This is the static
|
|
108
|
-
* registration scope; it is NOT necessarily the runtime (sub)agent that
|
|
109
|
-
* raised the interrupt. For runtime attribution, correlate `toolCallId`
|
|
110
|
-
* with the event-stream/`onToolExecutionStart` agent id.
|
|
59
|
+
* Render the human-in-the-loop UI for this tool call. The component
|
|
60
|
+
* receives {@link HumanInTheLoopRenderProps}, which also carry `toolCallId`
|
|
61
|
+
* and `agentId` for attribution.
|
|
111
62
|
*/
|
|
112
|
-
render: React$1.ComponentType<
|
|
113
|
-
name: string;
|
|
114
|
-
description: string;
|
|
115
|
-
toolCallId: string;
|
|
116
|
-
agentId?: string;
|
|
117
|
-
args: Partial<T>;
|
|
118
|
-
status: ToolCallStatus.InProgress;
|
|
119
|
-
result: undefined;
|
|
120
|
-
respond: undefined;
|
|
121
|
-
} | {
|
|
122
|
-
name: string;
|
|
123
|
-
description: string;
|
|
124
|
-
toolCallId: string;
|
|
125
|
-
agentId?: string;
|
|
126
|
-
args: T;
|
|
127
|
-
status: ToolCallStatus.Executing;
|
|
128
|
-
result: undefined;
|
|
129
|
-
respond: (result: unknown) => Promise<void>;
|
|
130
|
-
} | {
|
|
131
|
-
name: string;
|
|
132
|
-
description: string;
|
|
133
|
-
toolCallId: string;
|
|
134
|
-
agentId?: string;
|
|
135
|
-
args: T;
|
|
136
|
-
status: ToolCallStatus.Complete;
|
|
137
|
-
result: string;
|
|
138
|
-
respond: undefined;
|
|
139
|
-
}>;
|
|
63
|
+
render: React$1.ComponentType<HumanInTheLoopRenderProps<T>>;
|
|
140
64
|
};
|
|
141
65
|
//#endregion
|
|
142
66
|
//#region src/types/defineToolCallRenderer.d.ts
|
|
@@ -145,87 +69,22 @@ type ReactHumanInTheLoop<T extends Record<string, unknown> = Record<string, unkn
|
|
|
145
69
|
* - Accepts a single object whose keys match ReactToolCallRenderer's fields: { name, args, render, agentId? }.
|
|
146
70
|
* - Derives `args` type from the provided schema (any Standard Schema V1 compatible library).
|
|
147
71
|
* - Ensures the render function param type exactly matches ReactToolCallRenderer<T>["render"]'s param.
|
|
148
|
-
* - For wildcard tools (name: "*"), args is optional and defaults to
|
|
72
|
+
* - For wildcard tools (name: "*"), args is optional and defaults to a schema that accepts any value.
|
|
149
73
|
*/
|
|
150
|
-
type RenderProps<T> = {
|
|
151
|
-
name: string;
|
|
152
|
-
toolCallId: string;
|
|
153
|
-
args: Partial<T>;
|
|
154
|
-
status: ToolCallStatus.InProgress;
|
|
155
|
-
result: undefined;
|
|
156
|
-
} | {
|
|
157
|
-
name: string;
|
|
158
|
-
toolCallId: string;
|
|
159
|
-
args: T;
|
|
160
|
-
status: ToolCallStatus.Executing;
|
|
161
|
-
result: undefined;
|
|
162
|
-
} | {
|
|
163
|
-
name: string;
|
|
164
|
-
toolCallId: string;
|
|
165
|
-
args: T;
|
|
166
|
-
status: ToolCallStatus.Complete;
|
|
167
|
-
result: string;
|
|
168
|
-
};
|
|
169
74
|
declare function defineToolCallRenderer(def: {
|
|
170
75
|
name: "*";
|
|
171
|
-
render: (props:
|
|
76
|
+
render: (props: ToolCallRenderProps<any>) => React$1.ReactElement | null;
|
|
172
77
|
agentId?: string;
|
|
173
78
|
group?: boolean;
|
|
174
79
|
}): ReactToolCallRenderer<any>;
|
|
175
80
|
declare function defineToolCallRenderer<S extends StandardSchemaV1>(def: {
|
|
176
81
|
name: string;
|
|
177
82
|
args: S;
|
|
178
|
-
render: (props:
|
|
83
|
+
render: (props: ToolCallRenderProps<InferSchemaOutput<S>>) => React$1.ReactElement | null;
|
|
179
84
|
agentId?: string;
|
|
180
85
|
group?: boolean;
|
|
181
86
|
}): ReactToolCallRenderer<InferSchemaOutput<S>>;
|
|
182
87
|
//#endregion
|
|
183
|
-
//#region src/types/interrupt.d.ts
|
|
184
|
-
/** Legacy custom-event interrupt payload (agent emits a custom `on_interrupt` event). */
|
|
185
|
-
interface InterruptEvent<TValue = unknown> {
|
|
186
|
-
name: string;
|
|
187
|
-
value: TValue;
|
|
188
|
-
}
|
|
189
|
-
/**
|
|
190
|
-
* Resolve the agent with user input for an interrupt.
|
|
191
|
-
*
|
|
192
|
-
* - Standard interrupts: records `{ status: "resolved", payload }` for the target
|
|
193
|
-
* interrupt (defaults to the primary one). Resumes once every open interrupt is
|
|
194
|
-
* addressed; returns the resume run result, or `void` while still awaiting others.
|
|
195
|
-
* - Legacy interrupts: resumes immediately via `command.resume = payload`.
|
|
196
|
-
*/
|
|
197
|
-
type InterruptResolveFn = (payload?: unknown, interruptId?: string) => Promise<RunAgentResult | void>;
|
|
198
|
-
/**
|
|
199
|
-
* Cancel an interrupt.
|
|
200
|
-
*
|
|
201
|
-
* - Standard interrupts: records `{ status: "cancelled" }` for the target interrupt
|
|
202
|
-
* (defaults to the primary one), then resumes once all are addressed.
|
|
203
|
-
* - Legacy interrupts: dismisses the pending interrupt without resuming.
|
|
204
|
-
*/
|
|
205
|
-
type InterruptCancelFn = (interruptId?: string) => Promise<RunAgentResult | void>;
|
|
206
|
-
interface InterruptHandlerProps<TValue = unknown> {
|
|
207
|
-
/**
|
|
208
|
-
* Legacy event shape (`{ name, value }`). Always present for back-compat: for
|
|
209
|
-
* standard interrupts, `value` is the primary `Interrupt` and `name` is `"on_interrupt"`.
|
|
210
|
-
* Prefer `interrupt` / `interrupts` for standard interrupts.
|
|
211
|
-
*/
|
|
212
|
-
event: InterruptEvent<TValue>;
|
|
213
|
-
/** Primary standard interrupt (`interrupts[0]`), or `null` for legacy interrupts. */
|
|
214
|
-
interrupt: Interrupt | null;
|
|
215
|
-
/** All open standard interrupts (empty array for legacy interrupts). */
|
|
216
|
-
interrupts: Interrupt[];
|
|
217
|
-
resolve: InterruptResolveFn;
|
|
218
|
-
cancel: InterruptCancelFn;
|
|
219
|
-
}
|
|
220
|
-
interface InterruptRenderProps<TValue = unknown, TResult = unknown> {
|
|
221
|
-
event: InterruptEvent<TValue>;
|
|
222
|
-
interrupt: Interrupt | null;
|
|
223
|
-
interrupts: Interrupt[];
|
|
224
|
-
result: TResult;
|
|
225
|
-
resolve: InterruptResolveFn;
|
|
226
|
-
cancel: InterruptCancelFn;
|
|
227
|
-
}
|
|
228
|
-
//#endregion
|
|
229
88
|
//#region src/lib/react-core.d.ts
|
|
230
89
|
interface CopilotKitCoreReactConfig extends CopilotKitCoreConfig {
|
|
231
90
|
renderToolCalls?: ReactToolCallRenderer<any>[];
|
|
@@ -262,20 +121,6 @@ declare class CopilotKitCoreReact extends CopilotKitCore {
|
|
|
262
121
|
get interruptElement(): React$1.ReactElement | null;
|
|
263
122
|
setInterruptElement(element: React$1.ReactElement | null): void;
|
|
264
123
|
subscribe(subscriber: CopilotKitCoreReactSubscriber): CopilotKitCoreSubscription;
|
|
265
|
-
/**
|
|
266
|
-
* Wait for pending React state updates before the follow-up agent run.
|
|
267
|
-
*
|
|
268
|
-
* When a frontend tool handler calls setState(), React 18 batches the update
|
|
269
|
-
* and schedules a commit via its internal scheduler (MessageChannel). The
|
|
270
|
-
* useAgentContext hook registers context via useLayoutEffect, which runs
|
|
271
|
-
* synchronously after React commits that batch.
|
|
272
|
-
*
|
|
273
|
-
* Awaiting a zero-delay timeout yields to the macrotask queue. React's
|
|
274
|
-
* MessageChannel task runs first, committing the pending state and running
|
|
275
|
-
* useLayoutEffect (which updates the context store). The follow-up runAgent
|
|
276
|
-
* call then reads fresh context.
|
|
277
|
-
*/
|
|
278
|
-
waitForPendingFrameworkUpdates(): Promise<void>;
|
|
279
124
|
}
|
|
280
125
|
//#endregion
|
|
281
126
|
//#region src/context.d.ts
|
|
@@ -296,54 +141,8 @@ interface CopilotKitContextValue {
|
|
|
296
141
|
declare const useCopilotKit: () => CopilotKitContextValue;
|
|
297
142
|
//#endregion
|
|
298
143
|
//#region src/providers/CopilotChatConfigurationProvider.d.ts
|
|
299
|
-
declare const CopilotChatDefaultLabels: {
|
|
300
|
-
chatInputPlaceholder: string;
|
|
301
|
-
chatInputToolbarStartTranscribeButtonLabel: string;
|
|
302
|
-
chatInputToolbarCancelTranscribeButtonLabel: string;
|
|
303
|
-
chatInputToolbarFinishTranscribeButtonLabel: string;
|
|
304
|
-
chatInputToolbarAddButtonLabel: string;
|
|
305
|
-
chatInputToolbarToolsButtonLabel: string;
|
|
306
|
-
chatInputToolbarSendButtonLabel: string;
|
|
307
|
-
chatInputToolbarStopButtonLabel: string;
|
|
308
|
-
assistantMessageToolbarCopyCodeLabel: string;
|
|
309
|
-
assistantMessageToolbarCopyCodeCopiedLabel: string;
|
|
310
|
-
assistantMessageToolbarCopyMessageLabel: string;
|
|
311
|
-
assistantMessageToolbarInspectorLabel: string;
|
|
312
|
-
assistantMessageToolbarInspectorDescription: string;
|
|
313
|
-
assistantMessageToolbarInspectorLocalOnlyLabel: string;
|
|
314
|
-
assistantMessageToolbarInspectorLocalOnlyDescription: string;
|
|
315
|
-
assistantMessageToolbarInspectorTitle: string;
|
|
316
|
-
assistantMessageToolbarInspectorHideLabel: string;
|
|
317
|
-
assistantMessageToolbarInspectorHideDescription: string;
|
|
318
|
-
assistantMessageToolbarThumbsUpLabel: string;
|
|
319
|
-
assistantMessageToolbarThumbsDownLabel: string;
|
|
320
|
-
assistantMessageFeedbackCommentPlaceholder: string;
|
|
321
|
-
assistantMessageFeedbackCommentSubmitLabel: string;
|
|
322
|
-
assistantMessageToolbarReadAloudLabel: string;
|
|
323
|
-
assistantMessageToolbarRegenerateLabel: string;
|
|
324
|
-
userMessageToolbarCopyMessageLabel: string;
|
|
325
|
-
userMessageToolbarEditMessageLabel: string;
|
|
326
|
-
userMessageToolbarPreviousBranchLabel: string;
|
|
327
|
-
userMessageToolbarNextBranchLabel: string;
|
|
328
|
-
chatDisclaimerText: string;
|
|
329
|
-
chatToggleOpenLabel: string;
|
|
330
|
-
chatToggleCloseLabel: string;
|
|
331
|
-
chatScrollToBottomLabel: string;
|
|
332
|
-
modalHeaderTitle: string;
|
|
333
|
-
welcomeMessageText: string;
|
|
334
|
-
reasoningMessageThinkingLabel: string;
|
|
335
|
-
chatInputSlashMenuLabel: string;
|
|
336
|
-
chatInputSlashMenuEmptyText: string;
|
|
337
|
-
attachmentRemoveButtonLabel: string;
|
|
338
|
-
attachmentPlayVideoButtonLabel: string;
|
|
339
|
-
attachmentPreviewCloseButtonLabel: string;
|
|
340
|
-
modalHeaderCloseButtonLabel: string;
|
|
341
|
-
modalHeaderThreadsButtonLabel: string;
|
|
342
|
-
sidebarLabel: string;
|
|
343
|
-
};
|
|
344
|
-
type CopilotChatLabels = typeof CopilotChatDefaultLabels;
|
|
345
144
|
interface CopilotChatConfigurationValue {
|
|
346
|
-
labels: CopilotChatLabels;
|
|
145
|
+
labels: CopilotChatLabels$1;
|
|
347
146
|
agentId: string;
|
|
348
147
|
threadId: string;
|
|
349
148
|
isModalOpen: boolean;
|
|
@@ -419,7 +218,7 @@ interface CopilotChatConfigurationValue {
|
|
|
419
218
|
}
|
|
420
219
|
interface CopilotChatConfigurationProviderProps {
|
|
421
220
|
children: ReactNode;
|
|
422
|
-
labels?: Partial<CopilotChatLabels>;
|
|
221
|
+
labels?: Partial<CopilotChatLabels$1>;
|
|
423
222
|
agentId?: string;
|
|
424
223
|
threadId?: string;
|
|
425
224
|
hasExplicitThreadId?: boolean;
|
|
@@ -572,6 +371,30 @@ declare function useAgent({
|
|
|
572
371
|
};
|
|
573
372
|
//#endregion
|
|
574
373
|
//#region src/hooks/use-frontend-tool.d.ts
|
|
374
|
+
/**
|
|
375
|
+
* Register a frontend tool while the component is mounted. The agent can
|
|
376
|
+
* call it, and its `render` component draws the call in the chat.
|
|
377
|
+
*
|
|
378
|
+
* A tool with the same name and agentId as a tool that is already registered
|
|
379
|
+
* (for example one from the provider's `tools`) overrides it while this
|
|
380
|
+
* component is mounted. When the component unmounts, the overridden tool is
|
|
381
|
+
* active again. The renderer stays registered after unmount, so past tool
|
|
382
|
+
* calls still render in the chat history.
|
|
383
|
+
*
|
|
384
|
+
* @param tool - The tool to register.
|
|
385
|
+
* @param deps - Extra values that re-register the tool when they change. Use
|
|
386
|
+
* it when the handler closes over a value that is not part of the tool.
|
|
387
|
+
*
|
|
388
|
+
* @example
|
|
389
|
+
* ```tsx
|
|
390
|
+
* useFrontendTool({
|
|
391
|
+
* name: "showWeather",
|
|
392
|
+
* description: "Show the weather for a city",
|
|
393
|
+
* parameters: z.object({ city: z.string() }),
|
|
394
|
+
* handler: async ({ city }) => `Sunny in ${city}`,
|
|
395
|
+
* });
|
|
396
|
+
* ```
|
|
397
|
+
*/
|
|
575
398
|
declare function useFrontendTool<T extends Record<string, unknown> = Record<string, unknown>>(tool: ReactFrontendTool<T>, deps?: ReadonlyArray<unknown>): void;
|
|
576
399
|
//#endregion
|
|
577
400
|
//#region src/hooks/use-frontend-tools.d.ts
|
|
@@ -585,8 +408,10 @@ declare function useFrontendTool<T extends Record<string, unknown> = Record<stri
|
|
|
585
408
|
*
|
|
586
409
|
* Tools are keyed by `name` plus `agentId`, the same as `useFrontendTool`. A
|
|
587
410
|
* tool that disappears from the array is unregistered on the next render, and
|
|
588
|
-
* every tool is unregistered on unmount.
|
|
589
|
-
*
|
|
411
|
+
* every tool is unregistered on unmount. A listed tool hides a tool with the
|
|
412
|
+
* same name and agentId (for example one from the provider's `tools`) until it
|
|
413
|
+
* is unregistered, and then the hidden tool is active again. Renderers stay
|
|
414
|
+
* registered after unmount so past tool calls still render in the chat history.
|
|
590
415
|
*
|
|
591
416
|
* @param tools - The tools to register. May be empty and may change length.
|
|
592
417
|
* @param deps - Extra dependencies that force re-registration, compared by
|
package/dist/headless.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"headless.d.cts","names":[],"sources":["../src/types/react-tool-call-renderer.ts","../src/types/react-activity-message-renderer.ts","../src/types/react-custom-message-renderer.ts","../src/types/frontend-tool.ts","../src/types/human-in-the-loop.ts","../src/types/defineToolCallRenderer.ts","../src/
|
|
1
|
+
{"version":3,"file":"headless.d.cts","names":[],"sources":["../src/types/react-tool-call-renderer.ts","../src/types/react-activity-message-renderer.ts","../src/types/react-custom-message-renderer.ts","../src/types/frontend-tool.ts","../src/types/human-in-the-loop.ts","../src/types/defineToolCallRenderer.ts","../src/lib/react-core.ts","../src/context.ts","../src/providers/CopilotChatConfigurationProvider.tsx","../src/hooks/use-agent.tsx","../src/hooks/use-frontend-tool.tsx","../src/hooks/use-frontend-tools.tsx","../src/hooks/use-component.tsx","../src/hooks/use-human-in-the-loop.tsx","../src/hooks/use-interrupt.tsx","../src/hooks/use-suggestions.tsx","../src/hooks/use-configure-suggestions.tsx","../src/hooks/use-agent-context.tsx","../src/hooks/use-threads.tsx","../src/hooks/use-render-tool.tsx","../src/hooks/use-render-tool-call.tsx","../src/hooks/use-capabilities.tsx"],"mappings":";;;;;;;;;;;;AAeA;;;;KAAY,qBAAA,gBAAqC,mBAAA,CAC/C,CAAA,EACA,OAAA,CAAM,aAAA,CAAc,mBAAA,CAAoB,CAAA;;;;;;;;AAF1C;;KCFY,4BAAA,qBACV,0BAAA,CACE,gBAAA,EACA,OAAA,CAAM,aAAA,CAAc,0BAAA,CAA2B,gBAAA;;;;;;ADDnD;;KEAK,6BAAA,GAAgC,IAAA,CACnC,wBAAA;EAGA,aAAA;AAAA;;;;;;KAQU,0BAAA,GACV,wBAAA,CAAyB,OAAA,CAAM,aAAA,CAAc,6BAAA;;;KCzBnC,iBAAA,WACA,MAAA,oBAA0B,MAAA,qBAClC,YAAA,CAAa,CAAA;EACf,MAAA,GAAS,qBAAA,CAAsB,CAAA;AAAA;;;;;;;;AHSjC;KINY,mBAAA,WACA,MAAA,oBAA0B,MAAA,qBAClC,IAAA,CAAK,YAAA,CAAa,CAAA;EJIW;;;;;EIE/B,MAAA,EAAQ,OAAA,CAAM,aAAA,CAAc,yBAAA,CAA0B,CAAA;AAAA;;;;;;AJFxD;;;;iBKDgB,sBAAA,CAAuB,GAAA;EACrC,IAAA;EACA,MAAA,GAAS,KAAA,EAAO,mBAAA,UAA6B,OAAA,CAAM,YAAA;EACnD,OAAA;EACA,KAAA;AAAA,IACE,qBAAA;AAAA,iBAGY,sBAAA,WAAiC,gBAAA,CAAA,CAAkB,GAAA;EACjE,IAAA;EACA,IAAA,EAAM,CAAA;EACN,MAAA,GACE,KAAA,EAAO,mBAAA,CAAoB,iBAAA,CAAkB,CAAA,OAC1C,OAAA,CAAM,YAAA;EACX,OAAA;EACA,KAAA;AAAA,IACE,qBAAA,CAAsB,iBAAA,CAAkB,CAAA;;;UCjB3B,yBAAA,SAAkC,oBAAA;EAEjD,eAAA,GAAkB,qBAAA;EAClB,sBAAA,GAAyB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