@copilotkit/react-core 2.0.0-rc.6 → 2.0.0-rc.60
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/README.md +1 -1
- package/dist/MarkdownRendererContext-QFCldfW_.d.cts +34 -0
- package/dist/MarkdownRendererContext-QFCldfW_.d.cts.map +1 -0
- package/dist/MarkdownRendererContext-aK63ZFd-.d.mts +34 -0
- package/dist/MarkdownRendererContext-aK63ZFd-.d.mts.map +1 -0
- package/dist/MarkdownSurfaces-Do948N1P.cjs +141 -0
- package/dist/MarkdownSurfaces-Do948N1P.cjs.map +1 -0
- package/dist/MarkdownSurfaces-rtE9wRUP.mjs +135 -0
- package/dist/MarkdownSurfaces-rtE9wRUP.mjs.map +1 -0
- package/dist/ProviderMarkdown-D0eI0aPo.cjs +268 -0
- package/dist/ProviderMarkdown-D0eI0aPo.cjs.map +1 -0
- package/dist/ProviderMarkdown-epL7F3Vt.mjs +214 -0
- package/dist/ProviderMarkdown-epL7F3Vt.mjs.map +1 -0
- package/dist/accessibility-BLK-gE0R.mjs +129 -0
- package/dist/accessibility-BLK-gE0R.mjs.map +1 -0
- package/dist/accessibility-GnodqxkH.cjs +228 -0
- package/dist/accessibility-GnodqxkH.cjs.map +1 -0
- package/dist/chat-B1zczXUD.mjs +1476 -0
- package/dist/chat-B1zczXUD.mjs.map +1 -0
- package/dist/chat-BZ_bvAkg.d.mts +38 -0
- package/dist/chat-BZ_bvAkg.d.mts.map +1 -0
- package/dist/chat-CkFZMo5E.cjs +1579 -0
- package/dist/chat-CkFZMo5E.cjs.map +1 -0
- package/dist/chat-CpZVyF_t.d.cts +38 -0
- package/dist/chat-CpZVyF_t.d.cts.map +1 -0
- package/dist/context.cjs +75 -63
- package/dist/context.cjs.map +1 -1
- package/dist/context.d.cts +62 -107
- package/dist/context.d.cts.map +1 -1
- package/dist/context.d.mts +62 -107
- package/dist/context.d.mts.map +1 -1
- package/dist/context.mjs +76 -64
- package/dist/context.mjs.map +1 -1
- package/dist/generative-ui/map.cjs +26 -0
- package/dist/generative-ui/map.cjs.map +1 -0
- package/dist/generative-ui/map.d.cts +23 -0
- package/dist/generative-ui/map.d.cts.map +1 -0
- package/dist/generative-ui/map.d.mts +23 -0
- package/dist/generative-ui/map.d.mts.map +1 -0
- package/dist/generative-ui/map.mjs +24 -0
- package/dist/generative-ui/map.mjs.map +1 -0
- package/dist/generative-ui/native.cjs +67 -0
- package/dist/generative-ui/native.cjs.map +1 -0
- package/dist/generative-ui/native.d.cts +156 -0
- package/dist/generative-ui/native.d.cts.map +1 -0
- package/dist/generative-ui/native.d.mts +156 -0
- package/dist/generative-ui/native.d.mts.map +1 -0
- package/dist/generative-ui/native.mjs +25 -0
- package/dist/generative-ui/native.mjs.map +1 -0
- package/dist/generative-ui.cjs +33 -8088
- package/dist/generative-ui.cjs.map +1 -1
- package/dist/generative-ui.d.cts +2472 -4789
- package/dist/generative-ui.d.cts.map +1 -1
- package/dist/generative-ui.d.mts +2472 -4789
- package/dist/generative-ui.d.mts.map +1 -1
- package/dist/generative-ui.mjs +9 -8074
- package/dist/generative-ui.mjs.map +1 -1
- package/dist/headless.cjs +289 -1054
- package/dist/headless.cjs.map +1 -1
- package/dist/headless.d.cts +149 -372
- package/dist/headless.d.cts.map +1 -1
- package/dist/headless.d.mts +123 -237
- package/dist/headless.d.mts.map +1 -1
- package/dist/headless.mjs +283 -1054
- package/dist/headless.mjs.map +1 -1
- package/dist/hooks-D2H3iL0N.d.mts +84 -0
- package/dist/hooks-D2H3iL0N.d.mts.map +1 -0
- package/dist/hooks-Dy8HeEdr.d.cts +84 -0
- package/dist/hooks-Dy8HeEdr.d.cts.map +1 -0
- package/dist/index.cjs +8702 -13238
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +312 -872
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +311 -871
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +1790 -7803
- package/dist/index.mjs.map +1 -1
- package/dist/index.umd.js +14075 -13828
- package/dist/index.umd.js.map +1 -1
- package/dist/refs-B5Dn59Pn.cjs +43 -0
- package/dist/refs-B5Dn59Pn.cjs.map +1 -0
- package/dist/refs-BW15wX_V.mjs +31 -0
- package/dist/refs-BW15wX_V.mjs.map +1 -0
- package/dist/runtime-context-B7f4M85q.d.mts +215 -0
- package/dist/runtime-context-B7f4M85q.d.mts.map +1 -0
- package/dist/runtime-context-CIkZS0ap.d.cts +215 -0
- package/dist/runtime-context-CIkZS0ap.d.cts.map +1 -0
- package/dist/standard-CSBR4FhM.mjs +5800 -0
- package/dist/standard-CSBR4FhM.mjs.map +1 -0
- package/dist/standard-DBjcBGyd.cjs +5796 -0
- package/dist/standard-DBjcBGyd.cjs.map +1 -0
- package/dist/use-generative-ui-root-CIp0ytE6.cjs +390 -0
- package/dist/use-generative-ui-root-CIp0ytE6.cjs.map +1 -0
- package/dist/use-generative-ui-root-oBqPa6uy.mjs +386 -0
- package/dist/use-generative-ui-root-oBqPa6uy.mjs.map +1 -0
- package/dist/v2/context.d.cts +28 -0
- package/dist/v2/context.d.mts +28 -0
- package/dist/v2/generative-ui/native.d.cts +112 -0
- package/dist/v2/generative-ui/native.d.mts +112 -0
- package/dist/v2/generative-ui.d.cts +96 -0
- package/dist/v2/generative-ui.d.mts +96 -0
- package/dist/v2/headless.d.cts +96 -0
- package/dist/v2/headless.d.mts +96 -0
- package/dist/v2/index.d.cts +2220 -0
- package/dist/v2/index.d.mts +2220 -0
- package/dist/v2/styles.css +5 -0
- package/package.json +116 -24
- package/dist/MarkdownRendererContext-B4Us6mwL.d.cts +0 -954
- package/dist/MarkdownRendererContext-B4Us6mwL.d.cts.map +0 -1
- package/dist/MarkdownRendererContext-CRKFzsEB.d.mts +0 -954
- package/dist/MarkdownRendererContext-CRKFzsEB.d.mts.map +0 -1
- package/dist/MarkdownSurfaces-Bd--93O1.mjs +0 -3676
- package/dist/MarkdownSurfaces-Bd--93O1.mjs.map +0 -1
- package/dist/MarkdownSurfaces-S4wfUl3J.cjs +0 -3991
- package/dist/MarkdownSurfaces-S4wfUl3J.cjs.map +0 -1
package/dist/headless.d.cts
CHANGED
|
@@ -1,349 +1,40 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { CopilotKitCoreReact, CopilotKitCoreReactConfig, useCopilotKit } from "@copilotkit/react-core/context";
|
|
2
|
+
import React$1, { ComponentType, MutableRefObject, ReactNode } from "react";
|
|
3
|
+
import * as _copilotkit_core0 from "@copilotkit/core";
|
|
4
|
+
import { CopilotChatDefaultLabels, CopilotChatLabels, CopilotChatLabels as CopilotChatLabels$1, FrontendTool, HumanInTheLoopRenderProps, InterruptEvent, InterruptHandlerProps, InterruptRenderProps, Suggestion, ToolCallRenderProps, ToolCallRendererDef, ɵChatConfigurationStore, ɵJsonSerializable, ɵSuggestionsConfigInput, ɵThreadSummary } from "@copilotkit/core";
|
|
5
|
+
import * as _ag_ui_client0 from "@ag-ui/client";
|
|
6
|
+
import { Interrupt, ResumeEntry, ResumeStatus } from "@ag-ui/client";
|
|
2
7
|
import { InferSchemaOutput, StandardSchemaV1 } from "@copilotkit/shared";
|
|
3
|
-
import {
|
|
4
|
-
import { ActivityMessage, AgentCapabilities, Message, ToolCall, ToolMessage } from "@ag-ui/core";
|
|
5
|
-
import { AbstractAgent, Interrupt, ResumeEntry, ResumeStatus, RunAgentResult } from "@ag-ui/client";
|
|
8
|
+
import { AgentCapabilities, ToolCall, ToolMessage } from "@ag-ui/core";
|
|
6
9
|
|
|
7
|
-
//#region src/
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
* Schema describing the tool arguments. Optional — renderers registered for
|
|
12
|
-
* tools without parameters (e.g. HITL confirm dialogs) have no schema.
|
|
13
|
-
*/
|
|
14
|
-
args?: StandardSchemaV1<any, T>;
|
|
15
|
-
/**
|
|
16
|
-
* Optional agent ID to constrain this tool renderer to a specific agent.
|
|
17
|
-
* If specified, this renderer will only be used for the specified agent.
|
|
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
|
-
}
|
|
47
|
-
//#endregion
|
|
48
|
-
//#region src/types/react-activity-message-renderer.d.ts
|
|
49
|
-
interface ReactActivityMessageRenderer<TActivityContent> {
|
|
50
|
-
/**
|
|
51
|
-
* Activity type to match when rendering. Use "*" as a wildcard renderer.
|
|
52
|
-
*/
|
|
53
|
-
activityType: string;
|
|
54
|
-
/**
|
|
55
|
-
* Optional agent ID to scope the renderer to a particular agent.
|
|
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
|
-
}
|
|
72
|
-
//#endregion
|
|
73
|
-
//#region src/types/react-custom-message-renderer.d.ts
|
|
74
|
-
type ReactCustomMessageRendererPosition = "before" | "after";
|
|
75
|
-
interface ReactCustomMessageRenderer {
|
|
76
|
-
agentId?: string;
|
|
77
|
-
render: React.ComponentType<{
|
|
78
|
-
message: Message;
|
|
79
|
-
position: ReactCustomMessageRendererPosition;
|
|
80
|
-
runId: string;
|
|
81
|
-
messageIndex: number;
|
|
82
|
-
messageIndexInRun: number;
|
|
83
|
-
numberOfMessagesInRun: number;
|
|
84
|
-
agentId: string;
|
|
85
|
-
stateSnapshot: any;
|
|
86
|
-
}> | null;
|
|
87
|
-
}
|
|
88
|
-
//#endregion
|
|
89
|
-
//#region src/types/frontend-tool.d.ts
|
|
90
|
-
type ReactFrontendTool<T extends Record<string, unknown> = Record<string, unknown>> = FrontendTool<T> & {
|
|
91
|
-
render?: ReactToolCallRenderer<T>["render"];
|
|
92
|
-
};
|
|
93
|
-
//#endregion
|
|
94
|
-
//#region src/types/human-in-the-loop.d.ts
|
|
95
|
-
type ReactHumanInTheLoop<T extends Record<string, unknown> = Record<string, unknown>> = Omit<FrontendTool<T>, "handler"> & {
|
|
96
|
-
/**
|
|
97
|
-
* Render the human-in-the-loop UI for this tool call.
|
|
98
|
-
*
|
|
99
|
-
* Beyond the tool call's `args`/`status`/`result`, the render props carry
|
|
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.
|
|
111
|
-
*/
|
|
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
|
-
}>;
|
|
140
|
-
};
|
|
141
|
-
//#endregion
|
|
142
|
-
//#region src/types/defineToolCallRenderer.d.ts
|
|
143
|
-
/**
|
|
144
|
-
* Helper to define a type-safe tool call renderer entry.
|
|
145
|
-
* - Accepts a single object whose keys match ReactToolCallRenderer's fields: { name, args, render, agentId? }.
|
|
146
|
-
* - Derives `args` type from the provided schema (any Standard Schema V1 compatible library).
|
|
147
|
-
* - Ensures the render function param type exactly matches ReactToolCallRenderer<T>["render"]'s param.
|
|
148
|
-
* - For wildcard tools (name: "*"), args is optional and defaults to z.any()
|
|
149
|
-
*/
|
|
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
|
-
declare function defineToolCallRenderer(def: {
|
|
170
|
-
name: "*";
|
|
171
|
-
render: (props: RenderProps<any>) => React$1.ReactElement | null;
|
|
172
|
-
agentId?: string;
|
|
173
|
-
group?: boolean;
|
|
174
|
-
}): ReactToolCallRenderer<any>;
|
|
175
|
-
declare function defineToolCallRenderer<S extends StandardSchemaV1>(def: {
|
|
176
|
-
name: string;
|
|
177
|
-
args: S;
|
|
178
|
-
render: (props: RenderProps<InferSchemaOutput<S>>) => React$1.ReactElement | null;
|
|
179
|
-
agentId?: string;
|
|
180
|
-
group?: boolean;
|
|
181
|
-
}): ReactToolCallRenderer<InferSchemaOutput<S>>;
|
|
182
|
-
//#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;
|
|
10
|
+
//#region src/providers/use-owned-core.d.ts
|
|
11
|
+
/** The part of a core this hook needs: something it can dispose. */
|
|
12
|
+
interface Disposable {
|
|
13
|
+
dispose(): void;
|
|
188
14
|
}
|
|
189
15
|
/**
|
|
190
|
-
*
|
|
16
|
+
* @internal Create a core for the provider's lifetime and dispose it on
|
|
17
|
+
* unmount.
|
|
191
18
|
*
|
|
192
|
-
*
|
|
193
|
-
*
|
|
194
|
-
*
|
|
195
|
-
*
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
*
|
|
19
|
+
* The dispose waits one task. StrictMode (and Fast Refresh) unmount and
|
|
20
|
+
* remount effects in the same commit, so the remount cancels the pending
|
|
21
|
+
* dispose and the same core keeps working. When effects mount again after the
|
|
22
|
+
* core was really disposed (for example an `<Activity>` that was hidden and
|
|
23
|
+
* shown), the hook creates a new core and renders again: a disposed core is
|
|
24
|
+
* never reused.
|
|
25
|
+
*
|
|
26
|
+
* `ref` holds the current core. The provider owns it, so code that runs
|
|
27
|
+
* before the core exists can read `ref.current`.
|
|
200
28
|
*
|
|
201
|
-
*
|
|
202
|
-
*
|
|
203
|
-
*
|
|
29
|
+
* @example
|
|
30
|
+
* const coreRef = useRef<CopilotKitCoreReact | null>(null);
|
|
31
|
+
* const core = ɵuseOwnedCore(coreRef, () => new CopilotKitCoreReact(config));
|
|
204
32
|
*/
|
|
205
|
-
|
|
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
|
-
//#region src/lib/react-core.d.ts
|
|
230
|
-
interface CopilotKitCoreReactConfig extends CopilotKitCoreConfig {
|
|
231
|
-
renderToolCalls?: ReactToolCallRenderer<any>[];
|
|
232
|
-
renderActivityMessages?: ReactActivityMessageRenderer<any>[];
|
|
233
|
-
renderCustomMessages?: ReactCustomMessageRenderer[];
|
|
234
|
-
}
|
|
235
|
-
interface CopilotKitCoreReactSubscriber extends CopilotKitCoreSubscriber {
|
|
236
|
-
onRenderToolCallsChanged?: (event: {
|
|
237
|
-
copilotkit: CopilotKitCore;
|
|
238
|
-
renderToolCalls: ReactToolCallRenderer<any>[];
|
|
239
|
-
}) => void | Promise<void>;
|
|
240
|
-
onInterruptElementChanged?: (event: {
|
|
241
|
-
copilotkit: CopilotKitCore;
|
|
242
|
-
interruptElement: React$1.ReactElement | null;
|
|
243
|
-
}) => void | Promise<void>;
|
|
244
|
-
}
|
|
245
|
-
declare class CopilotKitCoreReact extends CopilotKitCore {
|
|
246
|
-
private _renderToolCalls;
|
|
247
|
-
private _hookRenderToolCalls;
|
|
248
|
-
private _cachedMergedRenderToolCalls;
|
|
249
|
-
private _renderCustomMessages;
|
|
250
|
-
private _renderActivityMessages;
|
|
251
|
-
private _interruptElement;
|
|
252
|
-
constructor(config: CopilotKitCoreReactConfig);
|
|
253
|
-
get renderCustomMessages(): Readonly<ReactCustomMessageRenderer[]>;
|
|
254
|
-
get renderActivityMessages(): Readonly<ReactActivityMessageRenderer<any>>[];
|
|
255
|
-
get renderToolCalls(): Readonly<ReactToolCallRenderer<any>>[];
|
|
256
|
-
setRenderActivityMessages(renderers: ReactActivityMessageRenderer<any>[]): void;
|
|
257
|
-
setRenderCustomMessages(renderers: ReactCustomMessageRenderer[]): void;
|
|
258
|
-
setRenderToolCalls(renderToolCalls: ReactToolCallRenderer<any>[]): void;
|
|
259
|
-
addHookRenderToolCall(entry: ReactToolCallRenderer<any>): void;
|
|
260
|
-
removeHookRenderToolCall(name: string, agentId?: string): void;
|
|
261
|
-
private _notifyRenderToolCallsChanged;
|
|
262
|
-
get interruptElement(): React$1.ReactElement | null;
|
|
263
|
-
setInterruptElement(element: React$1.ReactElement | null): void;
|
|
264
|
-
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
|
-
}
|
|
280
|
-
//#endregion
|
|
281
|
-
//#region src/context.d.ts
|
|
282
|
-
interface CopilotKitContextValue {
|
|
283
|
-
copilotkit: CopilotKitCoreReact;
|
|
284
|
-
/**
|
|
285
|
-
* Whether CopilotKit should automatically mount Intelligence indicators.
|
|
286
|
-
* Defaults to true when omitted for compatibility with custom providers.
|
|
287
|
-
*/
|
|
288
|
-
showIntelligenceIndicator?: boolean;
|
|
289
|
-
/**
|
|
290
|
-
* Set of tool call IDs currently being executed.
|
|
291
|
-
* This is tracked at the provider level to ensure tool execution events
|
|
292
|
-
* are captured even before child components mount.
|
|
293
|
-
*/
|
|
294
|
-
executingToolCallIds: ReadonlySet<string>;
|
|
295
|
-
}
|
|
296
|
-
declare const useCopilotKit: () => CopilotKitContextValue;
|
|
33
|
+
declare function ɵuseOwnedCore<T extends Disposable>(ref: MutableRefObject<T | null>, create: () => T): T;
|
|
297
34
|
//#endregion
|
|
298
35
|
//#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
36
|
interface CopilotChatConfigurationValue {
|
|
346
|
-
labels: CopilotChatLabels;
|
|
37
|
+
labels: CopilotChatLabels$1;
|
|
347
38
|
agentId: string;
|
|
348
39
|
threadId: string;
|
|
349
40
|
isModalOpen: boolean;
|
|
@@ -393,7 +84,7 @@ interface CopilotChatConfigurationValue {
|
|
|
393
84
|
* `<CopilotThreadsDrawer>` selecting a thread row sets it explicitly so the chat
|
|
394
85
|
* connects to that backend thread.
|
|
395
86
|
*
|
|
396
|
-
* Guarded like the top-level `<
|
|
87
|
+
* Guarded like the top-level `<CopilotKitProvider>`'s `setThreadId`: when
|
|
397
88
|
* the consumer controls the threadId via the `threadId` prop on this
|
|
398
89
|
* provider, this is a no-op (a warning is logged) so a prop-controlled
|
|
399
90
|
* threadId is never silently overridden.
|
|
@@ -416,10 +107,15 @@ interface CopilotChatConfigurationValue {
|
|
|
416
107
|
* threadId is prop-controlled.
|
|
417
108
|
*/
|
|
418
109
|
startNewThread: () => void;
|
|
110
|
+
/**
|
|
111
|
+
* Internal: the core store behind this value, so a nested provider can link
|
|
112
|
+
* its own store to it.
|
|
113
|
+
*/
|
|
114
|
+
ɵstore?: ɵChatConfigurationStore;
|
|
419
115
|
}
|
|
420
116
|
interface CopilotChatConfigurationProviderProps {
|
|
421
117
|
children: ReactNode;
|
|
422
|
-
labels?: Partial<CopilotChatLabels>;
|
|
118
|
+
labels?: Partial<CopilotChatLabels$1>;
|
|
423
119
|
agentId?: string;
|
|
424
120
|
threadId?: string;
|
|
425
121
|
hasExplicitThreadId?: boolean;
|
|
@@ -553,7 +249,7 @@ declare function useAgent({
|
|
|
553
249
|
updates,
|
|
554
250
|
throttleMs
|
|
555
251
|
}?: UseAgentProps): {
|
|
556
|
-
agent: AbstractAgent;
|
|
252
|
+
agent: _ag_ui_client0.AbstractAgent | _copilotkit_core0.ProxiedCopilotRuntimeAgent;
|
|
557
253
|
/**
|
|
558
254
|
* Whether `agent` is the real, runtime-synced (or locally-registered) agent
|
|
559
255
|
* rather than a provisional stand-in returned while the runtime is still
|
|
@@ -571,7 +267,48 @@ declare function useAgent({
|
|
|
571
267
|
isReady: boolean;
|
|
572
268
|
};
|
|
573
269
|
//#endregion
|
|
270
|
+
//#region src/types/react-tool-call-renderer.d.ts
|
|
271
|
+
/**
|
|
272
|
+
* A tool call renderer for React: a React component that draws one tool call
|
|
273
|
+
* in the chat. The component receives {@link ToolCallRenderProps}.
|
|
274
|
+
*
|
|
275
|
+
* Pass a list of these to `renderToolCalls` on `CopilotKitProvider`, or build
|
|
276
|
+
* one with `defineToolCallRenderer`.
|
|
277
|
+
*
|
|
278
|
+
* @typeParam T - The shape of the tool arguments.
|
|
279
|
+
*/
|
|
280
|
+
type ReactToolCallRenderer<T = unknown> = ToolCallRendererDef<T, React$1.ComponentType<ToolCallRenderProps<T>>>;
|
|
281
|
+
//#endregion
|
|
282
|
+
//#region src/types/frontend-tool.d.ts
|
|
283
|
+
type ReactFrontendTool<T extends Record<string, unknown> = Record<string, unknown>> = FrontendTool<T> & {
|
|
284
|
+
render?: ReactToolCallRenderer<T>["render"];
|
|
285
|
+
};
|
|
286
|
+
//#endregion
|
|
574
287
|
//#region src/hooks/use-frontend-tool.d.ts
|
|
288
|
+
/**
|
|
289
|
+
* Register a frontend tool while the component is mounted. The agent can
|
|
290
|
+
* call it, and its `render` component draws the call in the chat.
|
|
291
|
+
*
|
|
292
|
+
* A tool with the same name and agentId as a tool that is already registered
|
|
293
|
+
* (for example one from the provider's `tools`) overrides it while this
|
|
294
|
+
* component is mounted. When the component unmounts, the overridden tool is
|
|
295
|
+
* active again. The renderer stays registered after unmount, so past tool
|
|
296
|
+
* calls still render in the chat history.
|
|
297
|
+
*
|
|
298
|
+
* @param tool - The tool to register.
|
|
299
|
+
* @param deps - Extra values that re-register the tool when they change. Use
|
|
300
|
+
* it when the handler closes over a value that is not part of the tool.
|
|
301
|
+
*
|
|
302
|
+
* @example
|
|
303
|
+
* ```tsx
|
|
304
|
+
* useFrontendTool({
|
|
305
|
+
* name: "showWeather",
|
|
306
|
+
* description: "Show the weather for a city",
|
|
307
|
+
* parameters: z.object({ city: z.string() }),
|
|
308
|
+
* handler: async ({ city }) => `Sunny in ${city}`,
|
|
309
|
+
* });
|
|
310
|
+
* ```
|
|
311
|
+
*/
|
|
575
312
|
declare function useFrontendTool<T extends Record<string, unknown> = Record<string, unknown>>(tool: ReactFrontendTool<T>, deps?: ReadonlyArray<unknown>): void;
|
|
576
313
|
//#endregion
|
|
577
314
|
//#region src/hooks/use-frontend-tools.d.ts
|
|
@@ -585,8 +322,10 @@ declare function useFrontendTool<T extends Record<string, unknown> = Record<stri
|
|
|
585
322
|
*
|
|
586
323
|
* Tools are keyed by `name` plus `agentId`, the same as `useFrontendTool`. A
|
|
587
324
|
* tool that disappears from the array is unregistered on the next render, and
|
|
588
|
-
* every tool is unregistered on unmount.
|
|
589
|
-
*
|
|
325
|
+
* every tool is unregistered on unmount. A listed tool hides a tool with the
|
|
326
|
+
* same name and agentId (for example one from the provider's `tools`) until it
|
|
327
|
+
* is unregistered, and then the hidden tool is active again. Renderers stay
|
|
328
|
+
* registered after unmount so past tool calls still render in the chat history.
|
|
590
329
|
*
|
|
591
330
|
* @param tools - The tools to register. May be empty and may change length.
|
|
592
331
|
* @param deps - Extra dependencies that force re-registration, compared by
|
|
@@ -687,6 +426,22 @@ declare function useComponent<TSchema extends StandardSchemaV1<any, Record<strin
|
|
|
687
426
|
followUp?: boolean;
|
|
688
427
|
}, deps?: ReadonlyArray<unknown>): void;
|
|
689
428
|
//#endregion
|
|
429
|
+
//#region src/types/human-in-the-loop.d.ts
|
|
430
|
+
/**
|
|
431
|
+
* A human-in-the-loop tool for React. It has no handler: the agent waits until
|
|
432
|
+
* the `render` component calls `respond` with the user's answer.
|
|
433
|
+
*
|
|
434
|
+
* @typeParam T - The shape of the tool arguments.
|
|
435
|
+
*/
|
|
436
|
+
type ReactHumanInTheLoop<T extends Record<string, unknown> = Record<string, unknown>> = Omit<FrontendTool<T>, "handler"> & {
|
|
437
|
+
/**
|
|
438
|
+
* Render the human-in-the-loop UI for this tool call. The component
|
|
439
|
+
* receives {@link HumanInTheLoopRenderProps}, which also carry `toolCallId`
|
|
440
|
+
* and `agentId` for attribution.
|
|
441
|
+
*/
|
|
442
|
+
render: React$1.ComponentType<HumanInTheLoopRenderProps<T>>;
|
|
443
|
+
};
|
|
444
|
+
//#endregion
|
|
690
445
|
//#region src/hooks/use-human-in-the-loop.d.ts
|
|
691
446
|
declare function useHumanInTheLoop<T extends Record<string, unknown> = Record<string, unknown>>(tool: ReactHumanInTheLoop<T>, deps?: ReadonlyArray<unknown>): void;
|
|
692
447
|
//#endregion
|
|
@@ -696,7 +451,6 @@ type InterruptResultFromHandler<THandler> = THandler extends ((...args: never[])
|
|
|
696
451
|
type InterruptResult<TValue, TResult> = InterruptResultFromHandler<InterruptHandlerFn<TValue, TResult>>;
|
|
697
452
|
type InterruptRenderInChat = boolean | undefined;
|
|
698
453
|
type UseInterruptReturn<TRenderInChat extends InterruptRenderInChat> = TRenderInChat extends false ? React$1.ReactElement | null : TRenderInChat extends true | undefined ? void : React$1.ReactElement | null | void;
|
|
699
|
-
/** Recognize thenables returned by interrupt preprocessing handlers. */
|
|
700
454
|
/**
|
|
701
455
|
* Configuration options for `useInterrupt`.
|
|
702
456
|
*/
|
|
@@ -770,29 +524,39 @@ declare function useSuggestions({
|
|
|
770
524
|
}?: UseSuggestionsOptions): UseSuggestionsResult;
|
|
771
525
|
//#endregion
|
|
772
526
|
//#region src/hooks/use-configure-suggestions.d.ts
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
527
|
+
/**
|
|
528
|
+
* Registers a suggestions configuration (dynamic or static) for the current
|
|
529
|
+
* chat. A global config (no `consumerAgentId`, or `"*"`) applies to every
|
|
530
|
+
* agent and loads for the surrounding chat's agent first.
|
|
531
|
+
*
|
|
532
|
+
* Pass `deps` to reload suggestions when values the config reads change.
|
|
533
|
+
*
|
|
534
|
+
* @example
|
|
535
|
+
* useConfigureSuggestions({
|
|
536
|
+
* instructions: "Suggest concise next steps for the user",
|
|
537
|
+
* available: "always",
|
|
538
|
+
* });
|
|
539
|
+
*/
|
|
540
|
+
declare function useConfigureSuggestions(config: ɵSuggestionsConfigInput | null | undefined, deps?: ReadonlyArray<unknown>): void;
|
|
779
541
|
//#endregion
|
|
780
542
|
//#region src/hooks/use-agent-context.d.ts
|
|
781
543
|
/**
|
|
782
544
|
* Represents any value that can be serialized to JSON.
|
|
783
545
|
*/
|
|
784
|
-
type JsonSerializable =
|
|
785
|
-
[key: string]: JsonSerializable;
|
|
786
|
-
};
|
|
546
|
+
type JsonSerializable = ɵJsonSerializable;
|
|
787
547
|
/**
|
|
788
548
|
* Context configuration for useAgentContext.
|
|
789
|
-
* Accepts any
|
|
549
|
+
* Accepts any value; a value that is not a string is sent as its JSON text.
|
|
790
550
|
*/
|
|
791
551
|
interface AgentContextInput {
|
|
792
552
|
/** A human-readable description of what this context represents */
|
|
793
553
|
description: string;
|
|
794
|
-
/**
|
|
795
|
-
|
|
554
|
+
/**
|
|
555
|
+
* The context value. A string is sent as-is; any other value is sent as its
|
|
556
|
+
* JSON text, so it should be JSON-serializable. Interface types and optional
|
|
557
|
+
* fields are accepted.
|
|
558
|
+
*/
|
|
559
|
+
value: unknown;
|
|
796
560
|
}
|
|
797
561
|
declare function useAgentContext(context: AgentContextInput): void;
|
|
798
562
|
//#endregion
|
|
@@ -801,23 +565,12 @@ declare function useAgentContext(context: AgentContextInput): void;
|
|
|
801
565
|
* A conversation thread managed by CopilotKit Intelligence.
|
|
802
566
|
*
|
|
803
567
|
* Each thread has a unique `id`, an optional human-readable `name`, and
|
|
804
|
-
*
|
|
568
|
+
* ISO-8601 `createdAt` and `updatedAt` timestamps. `lastRunAt` is the time of
|
|
569
|
+
* the most recent agent run, absent when the thread has never run; prefer it
|
|
570
|
+
* over `updatedAt` for "last activity", since rename and archive do not bump
|
|
571
|
+
* it. The shape is core's thread summary, which Angular also exposes.
|
|
805
572
|
*/
|
|
806
|
-
|
|
807
|
-
id: string;
|
|
808
|
-
agentId: string;
|
|
809
|
-
name: string | null;
|
|
810
|
-
archived: boolean;
|
|
811
|
-
createdAt: string;
|
|
812
|
-
updatedAt: string;
|
|
813
|
-
/**
|
|
814
|
-
* ISO-8601 timestamp of the most recent agent run on this thread. Absent
|
|
815
|
-
* when the thread has never been run. Prefer this over `updatedAt` for
|
|
816
|
-
* user-facing "last activity" displays — it is not bumped by metadata-only
|
|
817
|
-
* actions like rename or archive.
|
|
818
|
-
*/
|
|
819
|
-
lastRunAt?: string;
|
|
820
|
-
}
|
|
573
|
+
type Thread = ɵThreadSummary;
|
|
821
574
|
/**
|
|
822
575
|
* Configuration for the {@link useThreads} hook.
|
|
823
576
|
*
|
|
@@ -877,7 +630,9 @@ interface UseThreadsResult {
|
|
|
877
630
|
* `null`. Unlike {@link error}, this EXCLUDES developer/config errors (a
|
|
878
631
|
* missing runtime URL, or a runtime that does not advertise thread
|
|
879
632
|
* endpoints), so an end-user surface can render it directly without leaking
|
|
880
|
-
* a developer-facing configuration message into the UI.
|
|
633
|
+
* a developer-facing configuration message into the UI. It does report a
|
|
634
|
+
* runtime that refuses to list threads because the caller has no identity
|
|
635
|
+
* (no `identifyUser`), since the list cannot load until that is set.
|
|
881
636
|
*/
|
|
882
637
|
listError: Error | null;
|
|
883
638
|
/**
|
|
@@ -1097,6 +852,28 @@ declare function useRenderToolCall(): ({
|
|
|
1097
852
|
toolMessage
|
|
1098
853
|
}: UseRenderToolCallProps) => React$1.ReactElement | null;
|
|
1099
854
|
//#endregion
|
|
855
|
+
//#region src/types/defineToolCallRenderer.d.ts
|
|
856
|
+
/**
|
|
857
|
+
* Helper to define a type-safe tool call renderer entry.
|
|
858
|
+
* - Accepts a single object whose keys match ReactToolCallRenderer's fields: { name, args, render, agentId? }.
|
|
859
|
+
* - Derives `args` type from the provided schema (any Standard Schema V1 compatible library).
|
|
860
|
+
* - Ensures the render function param type exactly matches ReactToolCallRenderer<T>["render"]'s param.
|
|
861
|
+
* - For wildcard tools (name: "*"), args is optional and defaults to a schema that accepts any value.
|
|
862
|
+
*/
|
|
863
|
+
declare function defineToolCallRenderer(def: {
|
|
864
|
+
name: "*";
|
|
865
|
+
render: (props: ToolCallRenderProps<any>) => React$1.ReactElement | null;
|
|
866
|
+
agentId?: string;
|
|
867
|
+
group?: boolean;
|
|
868
|
+
}): ReactToolCallRenderer<any>;
|
|
869
|
+
declare function defineToolCallRenderer<S extends StandardSchemaV1>(def: {
|
|
870
|
+
name: string;
|
|
871
|
+
args: S;
|
|
872
|
+
render: (props: ToolCallRenderProps<InferSchemaOutput<S>>) => React$1.ReactElement | null;
|
|
873
|
+
agentId?: string;
|
|
874
|
+
group?: boolean;
|
|
875
|
+
}): ReactToolCallRenderer<InferSchemaOutput<S>>;
|
|
876
|
+
//#endregion
|
|
1100
877
|
//#region src/hooks/use-capabilities.d.ts
|
|
1101
878
|
/**
|
|
1102
879
|
* Returns the capabilities declared by the given agent (or the agent resolved
|
|
@@ -1113,5 +890,5 @@ declare function useRenderToolCall(): ({
|
|
|
1113
890
|
*/
|
|
1114
891
|
declare function useCapabilities(agentId?: string): AgentCapabilities | undefined;
|
|
1115
892
|
//#endregion
|
|
1116
|
-
export { type AgentContextInput, CopilotChatConfigurationProvider, type CopilotChatConfigurationProviderProps, type CopilotChatConfigurationValue, CopilotChatDefaultLabels, type CopilotChatLabels, CopilotKitCoreReact, type CopilotKitCoreReactConfig, type Interrupt, type InterruptEvent, type InterruptHandlerProps, type InterruptRenderProps, type JsonSerializable, type ReactFrontendTool, type ReactHumanInTheLoop, type ReactToolCallRenderer, type RenderToolCompleteProps, type RenderToolExecutingProps, type RenderToolInProgressProps, type RenderToolProps, type ResumeEntry, type ResumeStatus, type Thread, UseAgentUpdate, type UseInterruptConfig, type UseThreadsInput, type UseThreadsResult, defineToolCallRenderer, useAgent, useAgentContext, useCapabilities, useComponent, useConfigureSuggestions, useCopilotChatConfiguration, useCopilotKit, useFrontendTool, useFrontendTools, useHumanInTheLoop, useInterrupt, useRenderTool, useRenderToolCall, useSuggestions, useThreads };
|
|
893
|
+
export { type AgentContextInput, CopilotChatConfigurationProvider, type CopilotChatConfigurationProviderProps, type CopilotChatConfigurationValue, CopilotChatDefaultLabels, type CopilotChatLabels, CopilotKitCoreReact, type CopilotKitCoreReactConfig, type Interrupt, type InterruptEvent, type InterruptHandlerProps, type InterruptRenderProps, type JsonSerializable, type ReactFrontendTool, type ReactHumanInTheLoop, type ReactToolCallRenderer, type RenderToolCompleteProps, type RenderToolExecutingProps, type RenderToolInProgressProps, type RenderToolProps, type ResumeEntry, type ResumeStatus, type Thread, UseAgentUpdate, type UseInterruptConfig, type UseThreadsInput, type UseThreadsResult, defineToolCallRenderer, useAgent, useAgentContext, useCapabilities, useComponent, useConfigureSuggestions, useCopilotChatConfiguration, useCopilotKit, useFrontendTool, useFrontendTools, useHumanInTheLoop, useInterrupt, useRenderTool, useRenderToolCall, useSuggestions, useThreads, ɵuseOwnedCore };
|
|
1117
894
|
//# sourceMappingURL=headless.d.cts.map
|