@copilotkit/react-core 2.0.0-rc.3 → 2.0.0-rc.31
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-BX26QLwl.d.cts} +16 -33
- package/dist/MarkdownRendererContext-BX26QLwl.d.cts.map +1 -0
- package/dist/{MarkdownRendererContext-CRKFzsEB.d.mts → MarkdownRendererContext-DAOMewji.d.mts} +16 -33
- package/dist/MarkdownRendererContext-DAOMewji.d.mts.map +1 -0
- package/dist/{MarkdownSurfaces-S4wfUl3J.cjs → MarkdownSurfaces-BbrHcSHN.cjs} +246 -334
- package/dist/MarkdownSurfaces-BbrHcSHN.cjs.map +1 -0
- package/dist/{MarkdownSurfaces-Bd--93O1.mjs → MarkdownSurfaces-DQbRS91-.mjs} +226 -315
- package/dist/MarkdownSurfaces-DQbRS91-.mjs.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.cjs +570 -567
- package/dist/generative-ui.cjs.map +1 -1
- package/dist/generative-ui.d.cts +2137 -4178
- package/dist/generative-ui.d.cts.map +1 -1
- package/dist/generative-ui.d.mts +2137 -4178
- package/dist/generative-ui.d.mts.map +1 -1
- package/dist/generative-ui.mjs +75 -73
- 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 +159 -293
- package/dist/headless.d.cts.map +1 -1
- package/dist/headless.d.mts +112 -232
- package/dist/headless.d.mts.map +1 -1
- package/dist/headless.mjs +283 -1054
- package/dist/headless.mjs.map +1 -1
- package/dist/index.cjs +4157 -6520
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +332 -831
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +329 -828
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +2012 -6009
- package/dist/index.mjs.map +1 -1
- package/dist/index.umd.js +4057 -6472
- package/dist/index.umd.js.map +1 -1
- package/package.json +19 -20
- 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
|
@@ -28,41 +28,31 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
28
28
|
let _copilotkit_core = require("@copilotkit/core");
|
|
29
29
|
let react = require("react");
|
|
30
30
|
react = __toESM(react);
|
|
31
|
+
let _copilotkit_markdown_react = require("@copilotkit/markdown/react");
|
|
32
|
+
let _copilotkit_markdown = require("@copilotkit/markdown");
|
|
31
33
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
32
|
-
let _copilotkit_markdown_renderer_react = require("@copilotkit/markdown-renderer/react");
|
|
33
|
-
let _copilotkit_markdown_renderer = require("@copilotkit/markdown-renderer");
|
|
34
|
-
let _copilotkit_shared = require("@copilotkit/shared");
|
|
35
34
|
let _copilotkit_react_core_context = require("@copilotkit/react-core/context");
|
|
35
|
+
let _copilotkit_shared = require("@copilotkit/shared");
|
|
36
36
|
let zod = require("zod");
|
|
37
|
-
|
|
37
|
+
zod = __toESM(zod);
|
|
38
38
|
|
|
39
39
|
//#region src/components/chat/StreamingMarkdownDefaultRenderer.tsx
|
|
40
|
-
const defaultNodeRenderers = (0, _copilotkit_markdown_renderer_react.createStreamingMarkdownNodeRenderers)({ codeBlock: ({ node }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("pre", {
|
|
41
|
-
className: "cpk-markdown-code-block",
|
|
42
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("code", {
|
|
43
|
-
"data-code-info": node.info ?? void 0,
|
|
44
|
-
children: node.text
|
|
45
|
-
})
|
|
46
|
-
}) });
|
|
47
40
|
/**
|
|
48
41
|
* react-core's built-in default markdown renderer — a thin adapter over
|
|
49
|
-
* `@copilotkit/markdown
|
|
42
|
+
* `@copilotkit/markdown`'s streaming renderer. Maps the pluggable
|
|
50
43
|
* renderer contract (`{ content, isStreaming, className }`) onto the streaming
|
|
51
44
|
* renderer for streaming-safe incremental rendering + per-token animation.
|
|
52
45
|
* Still overridable via the slot/provider pluggable interface.
|
|
53
46
|
*/
|
|
54
47
|
function StreamingMarkdownDefaultRenderer({ content, isStreaming, className, nodeRenderers, caret, options, onLinkClick, onCitationClick }) {
|
|
55
|
-
const mergedNodeRenderers = (0, react.useMemo)(() => nodeRenderers ? (0, _copilotkit_markdown_renderer_react.createStreamingMarkdownNodeRenderers)({
|
|
56
|
-
...defaultNodeRenderers,
|
|
57
|
-
...nodeRenderers
|
|
58
|
-
}) : defaultNodeRenderers, [nodeRenderers]);
|
|
59
48
|
if (!content) return null;
|
|
60
|
-
(0,
|
|
61
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
49
|
+
(0, _copilotkit_markdown.warnUnsupportedRichSyntaxOnce)(content);
|
|
50
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_copilotkit_markdown_react.StreamingMarkdownRenderer, {
|
|
62
51
|
className,
|
|
63
52
|
isComplete: !isStreaming,
|
|
64
53
|
caret: caret ?? !!isStreaming,
|
|
65
|
-
nodeRenderers
|
|
54
|
+
nodeRenderers,
|
|
55
|
+
nodeClassNames: _copilotkit_markdown.CHAT_MARKDOWN_NODE_CLASS_NAMES,
|
|
66
56
|
options,
|
|
67
57
|
onLinkClick,
|
|
68
58
|
onCitationClick,
|
|
@@ -71,17 +61,76 @@ function StreamingMarkdownDefaultRenderer({ content, isStreaming, className, nod
|
|
|
71
61
|
}
|
|
72
62
|
StreamingMarkdownDefaultRenderer.displayName = "StreamingMarkdownDefaultRenderer";
|
|
73
63
|
|
|
64
|
+
//#endregion
|
|
65
|
+
//#region src/components/icons/CopilotIcon.tsx
|
|
66
|
+
/** Turns SVG attribute names such as `stroke-width` into React's `strokeWidth`. */
|
|
67
|
+
function toReactAttributes(attributes) {
|
|
68
|
+
return Object.fromEntries(Object.entries(attributes).map(([key, value]) => [key.replace(/-([a-z])/g, (_match, letter) => letter.toUpperCase()), value]));
|
|
69
|
+
}
|
|
70
|
+
const svgDefaults = toReactAttributes(_copilotkit_core.ɵcopilotIconSvgAttributes);
|
|
71
|
+
/** True when the props give the icon an accessible name or role. */
|
|
72
|
+
function hasAccessibleProp(props) {
|
|
73
|
+
return Object.keys(props).some((key) => key.startsWith("aria-") || key === "role" || key === "title");
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Internal. Draws a Lucide icon from its node data, the way Lucide's React package
|
|
77
|
+
* does: Lucide's default SVG attributes, the `lucide lucide-<name>` classes,
|
|
78
|
+
* and `aria-hidden="true"` when no `aria-*`, `role` or `title` prop names it.
|
|
79
|
+
*/
|
|
80
|
+
const IconSvg = (0, react.forwardRef)(function IconSvg({ lucideName, nodes, size = 24, color = "currentColor", strokeWidth = 2, className, children, ...props }, ref) {
|
|
81
|
+
const isDecorative = !children && !hasAccessibleProp(props);
|
|
82
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("svg", {
|
|
83
|
+
ref,
|
|
84
|
+
...svgDefaults,
|
|
85
|
+
width: size,
|
|
86
|
+
height: size,
|
|
87
|
+
stroke: color,
|
|
88
|
+
strokeWidth,
|
|
89
|
+
className: (0, _copilotkit_core.ɵcn)("lucide", `lucide-${lucideName}`, className),
|
|
90
|
+
"aria-hidden": isDecorative || void 0,
|
|
91
|
+
...props,
|
|
92
|
+
children: [nodes.map((node, index) => (0, react.createElement)(node.tag, {
|
|
93
|
+
key: index,
|
|
94
|
+
...node.attributes
|
|
95
|
+
})), children]
|
|
96
|
+
});
|
|
97
|
+
});
|
|
98
|
+
/**
|
|
99
|
+
* Draws one of the chat icons as an inline `<svg>`.
|
|
100
|
+
*
|
|
101
|
+
* The `<svg>` has the classes `lucide lucide-<icon name>`, so CSS that selects
|
|
102
|
+
* them (for example `svg.lucide-arrow-up`) keeps working. The icon is hidden
|
|
103
|
+
* from screen readers unless you give it an `aria-label`, `role` or `title`.
|
|
104
|
+
*
|
|
105
|
+
* @param props.name - The chat icon, for example `"ArrowUp"` or `"X"`.
|
|
106
|
+
* @param props.size - Width and height. Defaults to `24`.
|
|
107
|
+
* @param props.strokeWidth - Line width. Defaults to `2`.
|
|
108
|
+
* @param props.color - Line color. Defaults to `currentColor`.
|
|
109
|
+
*
|
|
110
|
+
* @example
|
|
111
|
+
* ```tsx
|
|
112
|
+
* <CopilotIcon name="ArrowUp" className="cpk-chat-input-send-icon" />
|
|
113
|
+
* <CopilotIcon name="X" aria-label="Close" />
|
|
114
|
+
* ```
|
|
115
|
+
*/
|
|
116
|
+
const CopilotIcon = (0, react.forwardRef)(function CopilotIcon({ name, ...props }, ref) {
|
|
117
|
+
const icon = _copilotkit_core.ɵcopilotIcons[name];
|
|
118
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(IconSvg, {
|
|
119
|
+
ref,
|
|
120
|
+
lucideName: icon.name,
|
|
121
|
+
nodes: icon.nodes,
|
|
122
|
+
...props
|
|
123
|
+
});
|
|
124
|
+
});
|
|
125
|
+
|
|
74
126
|
//#endregion
|
|
75
127
|
//#region src/lib/shallow-stable-ref.ts
|
|
76
128
|
/**
|
|
77
|
-
* Shallow equality comparison for objects
|
|
129
|
+
* Shallow equality comparison for objects: same own keys, each holding the
|
|
130
|
+
* same value (`Object.is`). Core's `ɵshallowEqualRecord` holds the rule.
|
|
78
131
|
*/
|
|
79
132
|
function shallowEqual(obj1, obj2) {
|
|
80
|
-
|
|
81
|
-
const keys2 = Object.keys(obj2);
|
|
82
|
-
if (keys1.length !== keys2.length) return false;
|
|
83
|
-
for (const key of keys1) if (obj1[key] !== obj2[key]) return false;
|
|
84
|
-
return true;
|
|
133
|
+
return (0, _copilotkit_core.ɵshallowEqualRecord)(obj1, obj2);
|
|
85
134
|
}
|
|
86
135
|
/**
|
|
87
136
|
* Returns true only for plain JS objects (`{}`), excluding arrays, Dates,
|
|
@@ -115,241 +164,77 @@ function useShallowStableRef(value) {
|
|
|
115
164
|
|
|
116
165
|
//#endregion
|
|
117
166
|
//#region src/providers/CopilotChatConfigurationProvider.tsx
|
|
118
|
-
const CopilotChatDefaultLabels = {
|
|
119
|
-
chatInputPlaceholder: "Type a message...",
|
|
120
|
-
chatInputToolbarStartTranscribeButtonLabel: "Transcribe",
|
|
121
|
-
chatInputToolbarCancelTranscribeButtonLabel: "Cancel",
|
|
122
|
-
chatInputToolbarFinishTranscribeButtonLabel: "Finish",
|
|
123
|
-
chatInputToolbarAddButtonLabel: "Add attachments",
|
|
124
|
-
chatInputToolbarToolsButtonLabel: "Tools",
|
|
125
|
-
chatInputToolbarSendButtonLabel: "Send message",
|
|
126
|
-
chatInputToolbarStopButtonLabel: "Stop",
|
|
127
|
-
assistantMessageToolbarCopyCodeLabel: "Copy",
|
|
128
|
-
assistantMessageToolbarCopyCodeCopiedLabel: "Copied",
|
|
129
|
-
assistantMessageToolbarCopyMessageLabel: "Copy",
|
|
130
|
-
assistantMessageToolbarInspectorLabel: "View in Inspector",
|
|
131
|
-
assistantMessageToolbarInspectorDescription: "Open this message in the Inspector",
|
|
132
|
-
assistantMessageToolbarInspectorLocalOnlyLabel: "Local only",
|
|
133
|
-
assistantMessageToolbarInspectorLocalOnlyDescription: "Only visible on localhost or loopback hosts in development. Never shown in production.",
|
|
134
|
-
assistantMessageToolbarInspectorTitle: "CopilotKit Inspector",
|
|
135
|
-
assistantMessageToolbarInspectorHideLabel: "Hide this icon",
|
|
136
|
-
assistantMessageToolbarInspectorHideDescription: "Until you reload this page",
|
|
137
|
-
assistantMessageToolbarThumbsUpLabel: "Good response",
|
|
138
|
-
assistantMessageToolbarThumbsDownLabel: "Bad response",
|
|
139
|
-
assistantMessageFeedbackCommentPlaceholder: "Add a comment (optional)",
|
|
140
|
-
assistantMessageFeedbackCommentSubmitLabel: "Send comment",
|
|
141
|
-
assistantMessageToolbarReadAloudLabel: "Read aloud",
|
|
142
|
-
assistantMessageToolbarRegenerateLabel: "Regenerate",
|
|
143
|
-
userMessageToolbarCopyMessageLabel: "Copy",
|
|
144
|
-
userMessageToolbarEditMessageLabel: "Edit",
|
|
145
|
-
userMessageToolbarPreviousBranchLabel: "Previous branch",
|
|
146
|
-
userMessageToolbarNextBranchLabel: "Next branch",
|
|
147
|
-
chatDisclaimerText: "AI can make mistakes. Please verify important information.",
|
|
148
|
-
chatToggleOpenLabel: "Open chat",
|
|
149
|
-
chatToggleCloseLabel: "Close chat",
|
|
150
|
-
chatScrollToBottomLabel: "Scroll to bottom",
|
|
151
|
-
modalHeaderTitle: "CopilotKit Chat",
|
|
152
|
-
welcomeMessageText: "How can I help you today?",
|
|
153
|
-
reasoningMessageThinkingLabel: "Thinking…",
|
|
154
|
-
chatInputSlashMenuLabel: "Slash commands",
|
|
155
|
-
chatInputSlashMenuEmptyText: "No commands found",
|
|
156
|
-
attachmentRemoveButtonLabel: "Remove attachment",
|
|
157
|
-
attachmentPlayVideoButtonLabel: "Play video",
|
|
158
|
-
attachmentPreviewCloseButtonLabel: "Close preview",
|
|
159
|
-
modalHeaderCloseButtonLabel: "Close",
|
|
160
|
-
modalHeaderThreadsButtonLabel: "Open threads",
|
|
161
|
-
sidebarLabel: "Copilot chat sidebar"
|
|
162
|
-
};
|
|
163
|
-
/**
|
|
164
|
-
* Mobile breakpoint below which the chat modal and the thread-list drawer are
|
|
165
|
-
* mutually exclusive. At or above this width both surfaces may coexist. This
|
|
166
|
-
* mirrors the `(max-width: 767px)` / `(min-width: 768px)` split already used by
|
|
167
|
-
* CopilotChatInput and CopilotSidebarView.
|
|
168
|
-
*/
|
|
169
|
-
const MOBILE_MAX_WIDTH_PX = 767;
|
|
170
|
-
/**
|
|
171
|
-
* Reports whether the current viewport is in the mobile range (`<768px`), where
|
|
172
|
-
* the chat modal and drawer must not be open simultaneously. SSR-safe and
|
|
173
|
-
* defensive against environments without `matchMedia` (treated as desktop, so
|
|
174
|
-
* no mutual-exclusion constraint is applied).
|
|
175
|
-
*
|
|
176
|
-
* @returns `true` when the viewport is mobile-width, `false` otherwise.
|
|
177
|
-
*/
|
|
178
|
-
function isMobileViewport() {
|
|
179
|
-
if (typeof window === "undefined" || typeof window.matchMedia !== "function") return false;
|
|
180
|
-
return window.matchMedia(`(max-width: ${MOBILE_MAX_WIDTH_PX}px)`).matches;
|
|
181
|
-
}
|
|
182
167
|
const CopilotChatConfiguration = (0, react.createContext)(null);
|
|
183
168
|
const CopilotChatConfigurationProvider = ({ children, labels, agentId, threadId, hasExplicitThreadId, isModalDefaultOpen }) => {
|
|
184
169
|
const parentConfig = (0, react.useContext)(CopilotChatConfiguration);
|
|
185
170
|
const stableLabels = useShallowStableRef(labels);
|
|
186
171
|
const mergedLabels = (0, react.useMemo)(() => ({
|
|
187
|
-
...CopilotChatDefaultLabels,
|
|
172
|
+
..._copilotkit_core.CopilotChatDefaultLabels,
|
|
188
173
|
...parentConfig?.labels,
|
|
189
174
|
...stableLabels
|
|
190
175
|
}), [stableLabels, parentConfig?.labels]);
|
|
191
176
|
const providerAgentId = (0, _copilotkit_react_core_context.useDefaultAgentId)();
|
|
192
|
-
const
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
177
|
+
const options = {
|
|
178
|
+
agentId,
|
|
179
|
+
threadId,
|
|
180
|
+
hasExplicitThreadId,
|
|
181
|
+
isModalDefaultOpen,
|
|
182
|
+
providerAgentId
|
|
183
|
+
};
|
|
184
|
+
const parentStore = parentConfig?.ɵstore ?? null;
|
|
185
|
+
const [store] = (0, react.useState)(() => new _copilotkit_core.ɵChatConfigurationStore(options, parentStore));
|
|
186
|
+
store.ɵsetOptions(options);
|
|
187
|
+
const snapshot = (0, react.useSyncExternalStore)(store.subscribe, store.getSnapshot, store.getSnapshot);
|
|
188
|
+
(0, react.useEffect)(() => {
|
|
189
|
+
store.update({
|
|
190
|
+
agentId,
|
|
191
|
+
threadId,
|
|
192
|
+
hasExplicitThreadId,
|
|
193
|
+
isModalDefaultOpen,
|
|
194
|
+
providerAgentId
|
|
195
|
+
});
|
|
202
196
|
}, [
|
|
203
|
-
|
|
197
|
+
store,
|
|
198
|
+
agentId,
|
|
204
199
|
threadId,
|
|
205
|
-
|
|
206
|
-
|
|
200
|
+
hasExplicitThreadId,
|
|
201
|
+
isModalDefaultOpen,
|
|
202
|
+
providerAgentId
|
|
207
203
|
]);
|
|
208
204
|
const copilotkit = (0, react.useContext)(_copilotkit_react_core_context.CopilotKitContext)?.copilotkit;
|
|
209
|
-
const openThreadRef = (0, react.useRef)(null);
|
|
210
|
-
const latestThreadIdRef = (0, react.useRef)(resolvedThreadId);
|
|
211
|
-
latestThreadIdRef.current = resolvedThreadId;
|
|
212
205
|
(0, react.useEffect)(() => {
|
|
213
206
|
if (copilotkit === void 0) return;
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
registration.unregister();
|
|
221
|
-
openThreadRef.current = null;
|
|
222
|
-
};
|
|
223
|
-
}, [copilotkit, resolvedAgentId]);
|
|
224
|
-
(0, react.useEffect)(() => {
|
|
225
|
-
openThreadRef.current?.update(resolvedThreadId);
|
|
226
|
-
}, [resolvedThreadId]);
|
|
227
|
-
const resolvedHasExplicitThreadId = (threadIdPropIsAuthoritative ? true : activeThreadOverride?.explicit ?? hasExplicitThreadId ?? false) || !!parentConfig?.hasExplicitThreadId;
|
|
228
|
-
const [internalModalOpen, setInternalModalOpen] = (0, react.useState)(isModalDefaultOpen ?? true);
|
|
229
|
-
const hasExplicitDefault = isModalDefaultOpen !== void 0;
|
|
230
|
-
const setAndSync = (0, react.useCallback)((open) => {
|
|
231
|
-
setInternalModalOpen(open);
|
|
232
|
-
parentConfig?.setModalOpen(open);
|
|
233
|
-
}, [parentConfig?.setModalOpen]);
|
|
234
|
-
const isMounted = (0, react.useRef)(false);
|
|
235
|
-
(0, react.useEffect)(() => {
|
|
236
|
-
if (!hasExplicitDefault) return;
|
|
237
|
-
if (!isMounted.current) {
|
|
238
|
-
isMounted.current = true;
|
|
239
|
-
return;
|
|
240
|
-
}
|
|
241
|
-
if (parentConfig?.isModalOpen === void 0) return;
|
|
242
|
-
setInternalModalOpen(parentConfig.isModalOpen);
|
|
243
|
-
}, [parentConfig?.isModalOpen, hasExplicitDefault]);
|
|
244
|
-
const resolvedIsModalOpen = hasExplicitDefault ? internalModalOpen : parentConfig?.isModalOpen ?? internalModalOpen;
|
|
245
|
-
const resolvedSetModalOpen = hasExplicitDefault ? setAndSync : parentConfig?.setModalOpen ?? setInternalModalOpen;
|
|
246
|
-
const [ownDrawerOpen, setOwnDrawerOpen] = (0, react.useState)(false);
|
|
247
|
-
const [ownDrawerCount, setOwnDrawerCount] = (0, react.useState)(0);
|
|
248
|
-
const modalCloseRef = (0, react.useRef)(() => {});
|
|
249
|
-
modalCloseRef.current = resolvedSetModalOpen;
|
|
250
|
-
const registeredModalClosersRef = (0, react.useRef)([]);
|
|
251
|
-
const ownRegisterModalCloser = (0, react.useCallback)((closeModal) => {
|
|
252
|
-
registeredModalClosersRef.current.push(closeModal);
|
|
253
|
-
return () => {
|
|
254
|
-
registeredModalClosersRef.current = registeredModalClosersRef.current.filter((entry) => entry !== closeModal);
|
|
255
|
-
};
|
|
256
|
-
}, []);
|
|
257
|
-
const ownSetDrawerOpen = (0, react.useCallback)((open) => {
|
|
258
|
-
setOwnDrawerOpen(open);
|
|
259
|
-
if (open && isMobileViewport()) {
|
|
260
|
-
const registered = registeredModalClosersRef.current;
|
|
261
|
-
(registered.length > 0 ? registered[registered.length - 1] : modalCloseRef.current)(false);
|
|
262
|
-
}
|
|
263
|
-
}, []);
|
|
264
|
-
const ownRegisterDrawer = (0, react.useCallback)(() => {
|
|
265
|
-
setOwnDrawerCount((count) => count + 1);
|
|
266
|
-
return () => {
|
|
267
|
-
setOwnDrawerCount((count) => Math.max(0, count - 1));
|
|
268
|
-
};
|
|
269
|
-
}, []);
|
|
270
|
-
const resolvedDrawerOpen = parentConfig ? parentConfig.drawerOpen : ownDrawerOpen;
|
|
271
|
-
const resolvedSetDrawerOpen = parentConfig ? parentConfig.setDrawerOpen : ownSetDrawerOpen;
|
|
272
|
-
const resolvedDrawerRegistered = parentConfig ? parentConfig.drawerRegistered : ownDrawerCount > 0;
|
|
273
|
-
const resolvedRegisterDrawer = parentConfig ? parentConfig.registerDrawer : ownRegisterDrawer;
|
|
274
|
-
const resolvedRegisterModalCloser = parentConfig ? parentConfig.ɵregisterModalCloser : ownRegisterModalCloser;
|
|
275
|
-
(0, react.useEffect)(() => {
|
|
276
|
-
if (!hasExplicitDefault) return;
|
|
277
|
-
return resolvedRegisterModalCloser(resolvedSetModalOpen);
|
|
278
|
-
}, [
|
|
279
|
-
hasExplicitDefault,
|
|
280
|
-
resolvedRegisterModalCloser,
|
|
281
|
-
resolvedSetModalOpen
|
|
282
|
-
]);
|
|
283
|
-
const isThreadIdControlledRef = (0, react.useRef)(isThreadIdControlled);
|
|
284
|
-
isThreadIdControlledRef.current = isThreadIdControlled;
|
|
285
|
-
const ownSetActiveThreadId = (0, react.useCallback)((id, options) => {
|
|
286
|
-
setActiveThreadOverride({
|
|
287
|
-
threadId: id,
|
|
288
|
-
explicit: options?.explicit ?? true
|
|
289
|
-
});
|
|
290
|
-
}, []);
|
|
291
|
-
const ownStartNewThread = (0, react.useCallback)(() => {
|
|
292
|
-
setActiveThreadOverride({
|
|
293
|
-
threadId: (0, _copilotkit_shared.randomUUID)(),
|
|
294
|
-
explicit: false
|
|
295
|
-
});
|
|
296
|
-
}, []);
|
|
297
|
-
const parentSetActiveThreadId = parentConfig?.setActiveThreadId;
|
|
298
|
-
const parentStartNewThread = parentConfig?.startNewThread;
|
|
299
|
-
const resolvedSetActiveThreadId = (0, react.useCallback)((id, options) => {
|
|
300
|
-
if (isThreadIdControlledRef.current) {
|
|
301
|
-
console.warn("[CopilotKit] Ignoring setActiveThreadId(): threadId is controlled via the `threadId` prop on CopilotChatConfigurationProvider.");
|
|
302
|
-
return;
|
|
303
|
-
}
|
|
304
|
-
if (parentSetActiveThreadId) {
|
|
305
|
-
parentSetActiveThreadId(id, options);
|
|
306
|
-
return;
|
|
307
|
-
}
|
|
308
|
-
ownSetActiveThreadId(id, options);
|
|
309
|
-
}, [parentSetActiveThreadId, ownSetActiveThreadId]);
|
|
310
|
-
const resolvedStartNewThread = (0, react.useCallback)(() => {
|
|
311
|
-
if (isThreadIdControlledRef.current) {
|
|
312
|
-
console.warn("[CopilotKit] Ignoring startNewThread(): threadId is controlled via the `threadId` prop on CopilotChatConfigurationProvider.");
|
|
313
|
-
return;
|
|
314
|
-
}
|
|
315
|
-
if (parentStartNewThread) {
|
|
316
|
-
parentStartNewThread();
|
|
317
|
-
return;
|
|
318
|
-
}
|
|
319
|
-
ownStartNewThread();
|
|
320
|
-
}, [parentStartNewThread, ownStartNewThread]);
|
|
321
|
-
const setModalOpenWithDrawerExclusion = (0, react.useCallback)((open) => {
|
|
322
|
-
if (open && isMobileViewport()) resolvedSetDrawerOpen(false);
|
|
323
|
-
resolvedSetModalOpen(open);
|
|
324
|
-
}, [resolvedSetModalOpen, resolvedSetDrawerOpen]);
|
|
207
|
+
return store.bindOpenThread(copilotkit);
|
|
208
|
+
}, [copilotkit, store]);
|
|
209
|
+
const ownsModal = isModalDefaultOpen !== void 0;
|
|
210
|
+
const isModalOpen = ownsModal || !parentConfig ? snapshot.isModalOpen : parentConfig.isModalOpen;
|
|
211
|
+
const setModalOpen = ownsModal || !parentConfig ? store.setModalOpen : parentConfig.setModalOpen;
|
|
212
|
+
const { agentId: resolvedAgentId, threadId: resolvedThreadId, hasExplicitThreadId: resolvedHasExplicitThreadId, drawerOpen, drawerRegistered } = snapshot;
|
|
325
213
|
const configurationValue = (0, react.useMemo)(() => ({
|
|
326
214
|
labels: mergedLabels,
|
|
327
215
|
agentId: resolvedAgentId,
|
|
328
216
|
threadId: resolvedThreadId,
|
|
329
217
|
hasExplicitThreadId: resolvedHasExplicitThreadId,
|
|
330
|
-
isModalOpen
|
|
331
|
-
setModalOpen
|
|
332
|
-
drawerOpen
|
|
333
|
-
setDrawerOpen:
|
|
334
|
-
drawerRegistered
|
|
335
|
-
registerDrawer:
|
|
336
|
-
ɵregisterModalCloser:
|
|
337
|
-
setActiveThreadId:
|
|
338
|
-
startNewThread:
|
|
218
|
+
isModalOpen,
|
|
219
|
+
setModalOpen,
|
|
220
|
+
drawerOpen,
|
|
221
|
+
setDrawerOpen: store.setDrawerOpen,
|
|
222
|
+
drawerRegistered,
|
|
223
|
+
registerDrawer: store.registerDrawer,
|
|
224
|
+
ɵregisterModalCloser: store.registerModalCloser,
|
|
225
|
+
setActiveThreadId: store.setActiveThreadId,
|
|
226
|
+
startNewThread: store.startNewThread,
|
|
227
|
+
ɵstore: store
|
|
339
228
|
}), [
|
|
340
229
|
mergedLabels,
|
|
341
230
|
resolvedAgentId,
|
|
342
231
|
resolvedThreadId,
|
|
343
232
|
resolvedHasExplicitThreadId,
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
resolvedRegisterDrawer,
|
|
350
|
-
resolvedRegisterModalCloser,
|
|
351
|
-
resolvedSetActiveThreadId,
|
|
352
|
-
resolvedStartNewThread
|
|
233
|
+
isModalOpen,
|
|
234
|
+
setModalOpen,
|
|
235
|
+
drawerOpen,
|
|
236
|
+
drawerRegistered,
|
|
237
|
+
store
|
|
353
238
|
]);
|
|
354
239
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CopilotChatConfiguration.Provider, {
|
|
355
240
|
value: configurationValue,
|
|
@@ -416,28 +301,6 @@ const ControlledModalOpenScope = ({ children, open, onOpenChange }) => {
|
|
|
416
301
|
};
|
|
417
302
|
ControlledModalOpenScope.displayName = "ControlledModalOpenScope";
|
|
418
303
|
|
|
419
|
-
//#endregion
|
|
420
|
-
//#region src/lib/utils.ts
|
|
421
|
-
/**
|
|
422
|
-
* Joins class names, skipping falsy values. Takes the same inputs as `clsx`.
|
|
423
|
-
* Classes are not merged: every rule CopilotKit ships sits in `:where()`, so a
|
|
424
|
-
* class the app adds wins without removing ours.
|
|
425
|
-
*/
|
|
426
|
-
function cn(...inputs) {
|
|
427
|
-
const out = [];
|
|
428
|
-
for (const input of inputs) {
|
|
429
|
-
if (!input) continue;
|
|
430
|
-
if (typeof input === "string" || typeof input === "number" || typeof input === "bigint") out.push(String(input));
|
|
431
|
-
else if (Array.isArray(input)) {
|
|
432
|
-
const nested = cn(...input);
|
|
433
|
-
if (nested) out.push(nested);
|
|
434
|
-
} else if (typeof input === "object") {
|
|
435
|
-
for (const key in input) if (input[key]) out.push(key);
|
|
436
|
-
}
|
|
437
|
-
}
|
|
438
|
-
return out.join(" ");
|
|
439
|
-
}
|
|
440
|
-
|
|
441
304
|
//#endregion
|
|
442
305
|
//#region src/lib/slots.tsx
|
|
443
306
|
/**
|
|
@@ -456,7 +319,7 @@ function renderSlotElement(slot, DefaultComponent, props) {
|
|
|
456
319
|
const existingClassName = props.className;
|
|
457
320
|
return react.default.createElement(DefaultComponent, {
|
|
458
321
|
...props,
|
|
459
|
-
className: cn(existingClassName, slot)
|
|
322
|
+
className: (0, _copilotkit_core.ɵcn)(existingClassName, slot)
|
|
460
323
|
});
|
|
461
324
|
}
|
|
462
325
|
if (isReactComponentType(slot)) return react.default.createElement(slot, props);
|
|
@@ -519,7 +382,7 @@ function useMarkdownRenderer() {
|
|
|
519
382
|
//#endregion
|
|
520
383
|
//#region src/types/defineToolCallRenderer.ts
|
|
521
384
|
function defineToolCallRenderer(def) {
|
|
522
|
-
const argsSchema = def.name === "*" && !def.args ?
|
|
385
|
+
const argsSchema = def.name === "*" && !def.args ? _copilotkit_shared.ɵanySchema : def.args;
|
|
523
386
|
return {
|
|
524
387
|
name: def.name,
|
|
525
388
|
args: argsSchema,
|
|
@@ -532,12 +395,11 @@ function defineToolCallRenderer(def) {
|
|
|
532
395
|
//#endregion
|
|
533
396
|
//#region src/generative-ui/json-schema.ts
|
|
534
397
|
/**
|
|
535
|
-
* JSON Schema for a Standard Schema
|
|
536
|
-
* inlined, no `$schema`. A prop marked by `child()` or `childList()`
|
|
398
|
+
* JSON Schema for a Standard Schema, without `$schema`. A prop marked by `child()` or `childList()`
|
|
537
399
|
* becomes an A2UI `$ref` to `ComponentId` or `ChildList`.
|
|
538
400
|
*/
|
|
539
401
|
function toJsonSchema(schema) {
|
|
540
|
-
const { $schema: _omit, ...rest } = (0, _copilotkit_shared.schemaToJsonSchema)(schema
|
|
402
|
+
const { $schema: _omit, ...rest } = (0, _copilotkit_shared.schemaToJsonSchema)(schema);
|
|
541
403
|
return (0, _copilotkit_shared.applyChildRefMarks)(rest);
|
|
542
404
|
}
|
|
543
405
|
|
|
@@ -844,16 +706,10 @@ function toManifest(definition, modelProps, modelEvents) {
|
|
|
844
706
|
return manifest;
|
|
845
707
|
}
|
|
846
708
|
|
|
847
|
-
//#endregion
|
|
848
|
-
//#region src/generative-ui/is-record.ts
|
|
849
|
-
/** True for a plain object: not null, not an array. Internal, not exported. */
|
|
850
|
-
function isRecord(value) {
|
|
851
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
852
|
-
}
|
|
853
|
-
|
|
854
709
|
//#endregion
|
|
855
710
|
//#region src/generative-ui/errors.ts
|
|
856
711
|
var GenerativeUIError = class extends Error {
|
|
712
|
+
code;
|
|
857
713
|
constructor(code, message) {
|
|
858
714
|
super(message);
|
|
859
715
|
this.name = "GenerativeUIError";
|
|
@@ -953,6 +809,7 @@ function formatDatePattern(date, pattern) {
|
|
|
953
809
|
case "m": return pad(date.getMinutes(), 2);
|
|
954
810
|
case "s": return pad(date.getSeconds(), 2);
|
|
955
811
|
case "a": return date.getHours() < 12 ? "AM" : "PM";
|
|
812
|
+
case void 0:
|
|
956
813
|
default: return token;
|
|
957
814
|
}
|
|
958
815
|
});
|
|
@@ -1056,6 +913,13 @@ function givesValidationResult(name) {
|
|
|
1056
913
|
return _copilotkit_shared.GENERATIVE_UI_FUNCTIONS[name]?.returnType === "validationResult";
|
|
1057
914
|
}
|
|
1058
915
|
|
|
916
|
+
//#endregion
|
|
917
|
+
//#region src/generative-ui/is-record.ts
|
|
918
|
+
/** True for a plain object: not null, not an array. Internal, not exported. */
|
|
919
|
+
function isRecord(value) {
|
|
920
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
921
|
+
}
|
|
922
|
+
|
|
1059
923
|
//#endregion
|
|
1060
924
|
//#region src/generative-ui/markdown/source.ts
|
|
1061
925
|
/**
|
|
@@ -1063,10 +927,8 @@ function givesValidationResult(name) {
|
|
|
1063
927
|
* is dropped at the end of that build, so the cache does not grow.
|
|
1064
928
|
*/
|
|
1065
929
|
var BuildMemo = class {
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
this.current = /* @__PURE__ */ new Map();
|
|
1069
|
-
}
|
|
930
|
+
previous = /* @__PURE__ */ new Map();
|
|
931
|
+
current = /* @__PURE__ */ new Map();
|
|
1070
932
|
/**
|
|
1071
933
|
* The value of `key`. It is computed when no earlier value is there, or
|
|
1072
934
|
* when `isFresh` says that the earlier value is out of date.
|
|
@@ -1084,12 +946,11 @@ var BuildMemo = class {
|
|
|
1084
946
|
};
|
|
1085
947
|
/** The results of the builds of one thread. See `BuildMarkdownSurfacesOptions.cache`. */
|
|
1086
948
|
var MarkdownBuildCache = class {
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
}
|
|
949
|
+
segments = new BuildMemo();
|
|
950
|
+
fences = new BuildMemo();
|
|
951
|
+
drafts = new BuildMemo();
|
|
952
|
+
/** The copies of an operation for other surface ids, by operation. */
|
|
953
|
+
readdressed = /* @__PURE__ */ new WeakMap();
|
|
1093
954
|
endBuild() {
|
|
1094
955
|
this.segments.endBuild();
|
|
1095
956
|
this.fences.endBuild();
|
|
@@ -1600,13 +1461,18 @@ function removalContent(surfaceId, catalogId) {
|
|
|
1600
1461
|
* that each fence renders.
|
|
1601
1462
|
*/
|
|
1602
1463
|
var MarkdownSurfaceSource = class {
|
|
1464
|
+
functions;
|
|
1465
|
+
/** By thread: the blocks of each fence, from the latest sync. */
|
|
1466
|
+
fences = /* @__PURE__ */ new Map();
|
|
1467
|
+
/** By thread, then surface: the operations last ingested, as JSON. */
|
|
1468
|
+
ingested = /* @__PURE__ */ new Map();
|
|
1469
|
+
/** By thread, then surface: the content last ingested. */
|
|
1470
|
+
contents = /* @__PURE__ */ new Map();
|
|
1471
|
+
/** By thread: the results of the earlier builds. */
|
|
1472
|
+
caches = /* @__PURE__ */ new Map();
|
|
1603
1473
|
constructor(manager, ui) {
|
|
1604
1474
|
this.manager = manager;
|
|
1605
1475
|
this.ui = ui;
|
|
1606
|
-
this.fences = /* @__PURE__ */ new Map();
|
|
1607
|
-
this.ingested = /* @__PURE__ */ new Map();
|
|
1608
|
-
this.contents = /* @__PURE__ */ new Map();
|
|
1609
|
-
this.caches = /* @__PURE__ */ new Map();
|
|
1610
1476
|
this.functions = declaredFunctions(ui);
|
|
1611
1477
|
}
|
|
1612
1478
|
/**
|
|
@@ -1704,6 +1570,7 @@ const OPERATORS = [
|
|
|
1704
1570
|
"*",
|
|
1705
1571
|
"/",
|
|
1706
1572
|
"%",
|
|
1573
|
+
"^",
|
|
1707
1574
|
"(",
|
|
1708
1575
|
")",
|
|
1709
1576
|
",",
|
|
@@ -1784,27 +1651,58 @@ function describe(value) {
|
|
|
1784
1651
|
const MATH = {
|
|
1785
1652
|
min: (args) => Math.min(...args),
|
|
1786
1653
|
max: (args) => Math.max(...args),
|
|
1787
|
-
abs: ([x]) => Math.abs(x),
|
|
1788
|
-
floor: ([x]) => Math.floor(x),
|
|
1789
|
-
ceil: ([x]) => Math.ceil(x),
|
|
1790
|
-
round: ([x, decimals = 0]) => {
|
|
1654
|
+
abs: ([x = NaN]) => Math.abs(x),
|
|
1655
|
+
floor: ([x = NaN]) => Math.floor(x),
|
|
1656
|
+
ceil: ([x = NaN]) => Math.ceil(x),
|
|
1657
|
+
round: ([x = NaN, decimals = 0]) => {
|
|
1791
1658
|
const factor = 10 ** Math.trunc(decimals);
|
|
1792
1659
|
return Math.round(x * factor) / factor;
|
|
1793
|
-
}
|
|
1660
|
+
},
|
|
1661
|
+
pow: ([x = NaN, y = NaN]) => x ** y,
|
|
1662
|
+
sqrt: ([x = NaN]) => Math.sqrt(x),
|
|
1663
|
+
exp: ([x = NaN]) => Math.exp(x),
|
|
1664
|
+
ln: ([x = NaN]) => Math.log(x),
|
|
1665
|
+
log10: ([x = NaN]) => Math.log10(x)
|
|
1666
|
+
};
|
|
1667
|
+
/** How many args a function takes, at least and at most; min and max take any. */
|
|
1668
|
+
const ARITY = {
|
|
1669
|
+
abs: [1, 1],
|
|
1670
|
+
floor: [1, 1],
|
|
1671
|
+
ceil: [1, 1],
|
|
1672
|
+
round: [1, 2],
|
|
1673
|
+
pow: [2, 2],
|
|
1674
|
+
sqrt: [1, 1],
|
|
1675
|
+
exp: [1, 1],
|
|
1676
|
+
ln: [1, 1],
|
|
1677
|
+
log10: [1, 1]
|
|
1678
|
+
};
|
|
1679
|
+
/** Named constants, when no arg of the same name is passed. */
|
|
1680
|
+
const CONSTANTS = {
|
|
1681
|
+
pi: Math.PI,
|
|
1682
|
+
e: Math.E
|
|
1794
1683
|
};
|
|
1795
1684
|
var CalcParser = class {
|
|
1685
|
+
pos = 0;
|
|
1796
1686
|
constructor(tokens, scope, source) {
|
|
1797
1687
|
this.tokens = tokens;
|
|
1798
1688
|
this.scope = scope;
|
|
1799
1689
|
this.source = source;
|
|
1800
|
-
this.pos = 0;
|
|
1801
|
-
this.skipDepth = 0;
|
|
1802
1690
|
}
|
|
1803
1691
|
parse() {
|
|
1804
1692
|
const value = this.ternary();
|
|
1805
|
-
|
|
1693
|
+
const token = this.peek();
|
|
1694
|
+
if (token.kind !== "end") this.fail(`unexpected "${this.text(token)}"`);
|
|
1806
1695
|
return value;
|
|
1807
1696
|
}
|
|
1697
|
+
/**
|
|
1698
|
+
* The token at `pos`. The parser never moves past the "end" token, which
|
|
1699
|
+
* `tokenize` always adds last, so there is always one.
|
|
1700
|
+
*/
|
|
1701
|
+
peek() {
|
|
1702
|
+
const token = this.tokens[this.pos];
|
|
1703
|
+
if (token === void 0) throw new Error(`calc: no token at ${this.pos} in "${this.source}"`);
|
|
1704
|
+
return token;
|
|
1705
|
+
}
|
|
1808
1706
|
fail(what) {
|
|
1809
1707
|
throw new ExpressionError(`calc: ${what} in "${this.source}"`);
|
|
1810
1708
|
}
|
|
@@ -1812,11 +1710,11 @@ var CalcParser = class {
|
|
|
1812
1710
|
return token.kind === "end" ? "end" : String(token.value);
|
|
1813
1711
|
}
|
|
1814
1712
|
peekOp(...ops) {
|
|
1815
|
-
const token = this.
|
|
1713
|
+
const token = this.peek();
|
|
1816
1714
|
return token.kind === "op" && ops.includes(token.value) ? token.value : void 0;
|
|
1817
1715
|
}
|
|
1818
1716
|
expectOp(op) {
|
|
1819
|
-
if (this.peekOp(op) === void 0) this.fail(`expected "${op}" but found "${this.text(this.
|
|
1717
|
+
if (this.peekOp(op) === void 0) this.fail(`expected "${op}" but found "${this.text(this.peek())}"`);
|
|
1820
1718
|
this.pos++;
|
|
1821
1719
|
}
|
|
1822
1720
|
/**
|
|
@@ -1835,6 +1733,8 @@ var CalcParser = class {
|
|
|
1835
1733
|
}
|
|
1836
1734
|
return null;
|
|
1837
1735
|
}
|
|
1736
|
+
/** Above 0 while parsing a part whose value is not needed. */
|
|
1737
|
+
skipDepth = 0;
|
|
1838
1738
|
/** The number of a value, or 0 while skipping. */
|
|
1839
1739
|
num(value, what) {
|
|
1840
1740
|
return this.skipDepth > 0 ? 0 : numberOf(value, what);
|
|
@@ -1925,10 +1825,24 @@ var CalcParser = class {
|
|
|
1925
1825
|
this.pos++;
|
|
1926
1826
|
return !truthOf(this.unary());
|
|
1927
1827
|
}
|
|
1928
|
-
return this.
|
|
1828
|
+
return this.power();
|
|
1829
|
+
}
|
|
1830
|
+
/** `a ^ b`: binds tighter than `*` and unary minus, right to left. */
|
|
1831
|
+
power() {
|
|
1832
|
+
const base = this.primary();
|
|
1833
|
+
if (!this.peekOp("^")) return base;
|
|
1834
|
+
this.pos++;
|
|
1835
|
+
const exponent = this.unary();
|
|
1836
|
+
if (this.skipDepth > 0) return null;
|
|
1837
|
+
return this.finite(this.num(base, "the left side of ^") ** this.num(exponent, "the right side of ^"), "^");
|
|
1838
|
+
}
|
|
1839
|
+
finite(value, what) {
|
|
1840
|
+
if (!Number.isFinite(value)) this.fail(`${what} has no finite result`);
|
|
1841
|
+
return value;
|
|
1929
1842
|
}
|
|
1930
1843
|
primary() {
|
|
1931
|
-
const token = this.
|
|
1844
|
+
const token = this.peek();
|
|
1845
|
+
this.pos++;
|
|
1932
1846
|
switch (token.kind) {
|
|
1933
1847
|
case "number": return token.value;
|
|
1934
1848
|
case "string": return token.value;
|
|
@@ -1960,10 +1874,15 @@ var CalcParser = class {
|
|
|
1960
1874
|
const fn = Object.prototype.hasOwnProperty.call(MATH, name) ? MATH[name] : void 0;
|
|
1961
1875
|
if (!fn) this.fail(`unknown function ${name}`);
|
|
1962
1876
|
if (args.length === 0) this.fail(`${name} needs an argument`);
|
|
1963
|
-
|
|
1877
|
+
const [least, most] = ARITY[name] ?? [1, Infinity];
|
|
1878
|
+
if (args.length < least || args.length > most) this.fail(`${name} takes ${least === most ? least : `${least} or ${most}`} argument${most === 1 ? "" : "s"}`);
|
|
1879
|
+
return this.finite(fn(args), name);
|
|
1964
1880
|
}
|
|
1965
1881
|
if (this.skipDepth > 0) return null;
|
|
1966
|
-
if (!Object.prototype.hasOwnProperty.call(this.scope, name))
|
|
1882
|
+
if (!Object.prototype.hasOwnProperty.call(this.scope, name)) {
|
|
1883
|
+
if (Object.prototype.hasOwnProperty.call(CONSTANTS, name)) return CONSTANTS[name];
|
|
1884
|
+
this.fail(`unknown name ${name}; pass it as an arg`);
|
|
1885
|
+
}
|
|
1967
1886
|
const value = this.scope[name];
|
|
1968
1887
|
if (value !== null && typeof value !== "number" && typeof value !== "string" && typeof value !== "boolean") this.fail(`${name} is not a number, text or boolean (${describe(value)})`);
|
|
1969
1888
|
return value;
|
|
@@ -2203,10 +2122,10 @@ const IDENTIFIER = /@?[A-Za-z_][A-Za-z0-9_-]*/y;
|
|
|
2203
2122
|
const NUMBER = /-?\d+(?:\.\d+)?/y;
|
|
2204
2123
|
const PATH_SEGMENT = /[^\s,():'"]+/y;
|
|
2205
2124
|
var ExpressionParser = class {
|
|
2125
|
+
pos = 0;
|
|
2206
2126
|
constructor(source, state) {
|
|
2207
2127
|
this.source = source;
|
|
2208
2128
|
this.state = state;
|
|
2209
|
-
this.pos = 0;
|
|
2210
2129
|
}
|
|
2211
2130
|
parse() {
|
|
2212
2131
|
const value = this.expression();
|
|
@@ -2508,14 +2427,10 @@ function NodePlaceholder(_props) {
|
|
|
2508
2427
|
}
|
|
2509
2428
|
/** Per-node boundary. Resets on retry or a new agent revision, not on data ticks. */
|
|
2510
2429
|
var NodeBoundary = class extends react.Component {
|
|
2511
|
-
|
|
2512
|
-
|
|
2513
|
-
this.
|
|
2514
|
-
|
|
2515
|
-
revision: this.props.revision
|
|
2516
|
-
};
|
|
2517
|
-
this.retry = () => this.setState({ error: null });
|
|
2518
|
-
}
|
|
2430
|
+
state = {
|
|
2431
|
+
error: null,
|
|
2432
|
+
revision: this.props.revision
|
|
2433
|
+
};
|
|
2519
2434
|
static getDerivedStateFromError(error) {
|
|
2520
2435
|
return { error };
|
|
2521
2436
|
}
|
|
@@ -2534,6 +2449,7 @@ var NodeBoundary = class extends react.Component {
|
|
|
2534
2449
|
error
|
|
2535
2450
|
});
|
|
2536
2451
|
}
|
|
2452
|
+
retry = () => this.setState({ error: null });
|
|
2537
2453
|
render() {
|
|
2538
2454
|
const { error } = this.state;
|
|
2539
2455
|
if (!error) return this.props.children;
|
|
@@ -2553,10 +2469,7 @@ var NodeBoundary = class extends react.Component {
|
|
|
2553
2469
|
};
|
|
2554
2470
|
/** Outer boundary: a failure here must not reach the chat or the host page. */
|
|
2555
2471
|
var SurfaceBoundary = class extends react.Component {
|
|
2556
|
-
|
|
2557
|
-
super(..._args2);
|
|
2558
|
-
this.state = { error: null };
|
|
2559
|
-
}
|
|
2472
|
+
state = { error: null };
|
|
2560
2473
|
static getDerivedStateFromError(error) {
|
|
2561
2474
|
return { error };
|
|
2562
2475
|
}
|
|
@@ -3466,7 +3379,7 @@ function ResolvedNode({ surface, componentId, definition, properties, runtime, b
|
|
|
3466
3379
|
//#endregion
|
|
3467
3380
|
//#region src/generative-ui/chat.tsx
|
|
3468
3381
|
const GenerativeUIChatSlotContext = (0, react.createContext)(void 0);
|
|
3469
|
-
function DefaultGenerativeUIChatCard({ surfaceId,
|
|
3382
|
+
function DefaultGenerativeUIChatCard({ surfaceId, error, children }) {
|
|
3470
3383
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3471
3384
|
"data-generative-ui-chat-surface": surfaceId,
|
|
3472
3385
|
className: "cpk-generative-ui-chat-card",
|
|
@@ -3477,21 +3390,21 @@ function DefaultGenerativeUIChatCard({ surfaceId, isStreaming, error, children }
|
|
|
3477
3390
|
})]
|
|
3478
3391
|
});
|
|
3479
3392
|
}
|
|
3480
|
-
const ContentSchema = zod.
|
|
3481
|
-
surfaceId: zod.
|
|
3482
|
-
target: zod.
|
|
3483
|
-
catalogId: zod.
|
|
3484
|
-
operations: zod.
|
|
3485
|
-
status: zod.
|
|
3393
|
+
const ContentSchema = zod.object({
|
|
3394
|
+
surfaceId: zod.string(),
|
|
3395
|
+
target: zod.string(),
|
|
3396
|
+
catalogId: zod.string(),
|
|
3397
|
+
operations: zod.array(zod.any()),
|
|
3398
|
+
status: zod.enum([
|
|
3486
3399
|
"streaming",
|
|
3487
3400
|
"ready",
|
|
3488
3401
|
"error"
|
|
3489
3402
|
]),
|
|
3490
|
-
rejected: zod.
|
|
3491
|
-
index: zod.
|
|
3492
|
-
reason: zod.
|
|
3403
|
+
rejected: zod.array(zod.object({
|
|
3404
|
+
index: zod.number(),
|
|
3405
|
+
reason: zod.string()
|
|
3493
3406
|
})).default([])
|
|
3494
|
-
}).
|
|
3407
|
+
}).loose();
|
|
3495
3408
|
function GenerativeUIChatActivity({ content, agent }) {
|
|
3496
3409
|
const runtime = useGenerativeUIRuntime();
|
|
3497
3410
|
const threadId = useCopilotChatConfiguration()?.threadId ?? agent?.threadId;
|
|
@@ -3533,7 +3446,7 @@ function createGenerativeUIActivityRenderer() {
|
|
|
3533
3446
|
function createGenerativeUIFunctionCallActivityRenderer() {
|
|
3534
3447
|
return {
|
|
3535
3448
|
activityType: _copilotkit_shared.GENERATIVE_UI_FUNCTION_CALL_ACTIVITY_TYPE,
|
|
3536
|
-
content: zod.
|
|
3449
|
+
content: zod.unknown(),
|
|
3537
3450
|
render: () => null
|
|
3538
3451
|
};
|
|
3539
3452
|
}
|
|
@@ -3543,11 +3456,10 @@ function GenerativeUIToolCallRenderer() {
|
|
|
3543
3456
|
(0, react.useEffect)(() => {
|
|
3544
3457
|
const renderer = defineToolCallRenderer({
|
|
3545
3458
|
name: _copilotkit_shared.GENERATIVE_UI_RENDER_TOOL,
|
|
3546
|
-
args: zod.
|
|
3459
|
+
args: zod.any(),
|
|
3547
3460
|
render: () => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_jsx_runtime.Fragment, {})
|
|
3548
3461
|
});
|
|
3549
|
-
|
|
3550
|
-
copilotkit.setRenderToolCalls([...existing.filter((rc) => rc.name !== _copilotkit_shared.GENERATIVE_UI_RENDER_TOOL), renderer]);
|
|
3462
|
+
return copilotkit.ɵaddBuiltInRenderToolCall(renderer);
|
|
3551
3463
|
}, [copilotkit]);
|
|
3552
3464
|
return null;
|
|
3553
3465
|
}
|
|
@@ -3718,10 +3630,10 @@ Object.defineProperty(exports, 'CopilotChatConfigurationProvider', {
|
|
|
3718
3630
|
return CopilotChatConfigurationProvider;
|
|
3719
3631
|
}
|
|
3720
3632
|
});
|
|
3721
|
-
Object.defineProperty(exports, '
|
|
3633
|
+
Object.defineProperty(exports, 'CopilotIcon', {
|
|
3722
3634
|
enumerable: true,
|
|
3723
3635
|
get: function () {
|
|
3724
|
-
return
|
|
3636
|
+
return CopilotIcon;
|
|
3725
3637
|
}
|
|
3726
3638
|
});
|
|
3727
3639
|
Object.defineProperty(exports, 'DARK_THEME_CSS', {
|
|
@@ -3772,6 +3684,12 @@ Object.defineProperty(exports, 'GenerativeUIToolCallRenderer', {
|
|
|
3772
3684
|
return GenerativeUIToolCallRenderer;
|
|
3773
3685
|
}
|
|
3774
3686
|
});
|
|
3687
|
+
Object.defineProperty(exports, 'IconSvg', {
|
|
3688
|
+
enumerable: true,
|
|
3689
|
+
get: function () {
|
|
3690
|
+
return IconSvg;
|
|
3691
|
+
}
|
|
3692
|
+
});
|
|
3775
3693
|
Object.defineProperty(exports, 'MarkdownRendererProvider', {
|
|
3776
3694
|
enumerable: true,
|
|
3777
3695
|
get: function () {
|
|
@@ -3814,12 +3732,6 @@ Object.defineProperty(exports, 'catalogIdsOf', {
|
|
|
3814
3732
|
return catalogIdsOf;
|
|
3815
3733
|
}
|
|
3816
3734
|
});
|
|
3817
|
-
Object.defineProperty(exports, 'cn', {
|
|
3818
|
-
enumerable: true,
|
|
3819
|
-
get: function () {
|
|
3820
|
-
return cn;
|
|
3821
|
-
}
|
|
3822
|
-
});
|
|
3823
3735
|
Object.defineProperty(exports, 'componentCatalogIds', {
|
|
3824
3736
|
enumerable: true,
|
|
3825
3737
|
get: function () {
|
|
@@ -3988,4 +3900,4 @@ Object.defineProperty(exports, 'wrapperAria', {
|
|
|
3988
3900
|
return wrapperAria;
|
|
3989
3901
|
}
|
|
3990
3902
|
});
|
|
3991
|
-
//# sourceMappingURL=MarkdownSurfaces-
|
|
3903
|
+
//# sourceMappingURL=MarkdownSurfaces-BbrHcSHN.cjs.map
|