@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
|
@@ -28,9 +28,9 @@ 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 react_jsx_runtime = require("react/jsx-runtime");
|
|
32
31
|
let _copilotkit_markdown_renderer_react = require("@copilotkit/markdown-renderer/react");
|
|
33
32
|
let _copilotkit_markdown_renderer = require("@copilotkit/markdown-renderer");
|
|
33
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
34
34
|
let _copilotkit_shared = require("@copilotkit/shared");
|
|
35
35
|
let _copilotkit_react_core_context = require("@copilotkit/react-core/context");
|
|
36
36
|
let zod = require("zod");
|
|
@@ -71,6 +71,90 @@ function StreamingMarkdownDefaultRenderer({ content, isStreaming, className, nod
|
|
|
71
71
|
}
|
|
72
72
|
StreamingMarkdownDefaultRenderer.displayName = "StreamingMarkdownDefaultRenderer";
|
|
73
73
|
|
|
74
|
+
//#endregion
|
|
75
|
+
//#region src/lib/utils.ts
|
|
76
|
+
/**
|
|
77
|
+
* Joins class names, skipping falsy values. Takes the same inputs as `clsx`.
|
|
78
|
+
* Classes are not merged: every rule CopilotKit ships sits in `:where()`, so a
|
|
79
|
+
* class the app adds wins without removing ours.
|
|
80
|
+
*/
|
|
81
|
+
function cn(...inputs) {
|
|
82
|
+
const out = [];
|
|
83
|
+
for (const input of inputs) {
|
|
84
|
+
if (!input) continue;
|
|
85
|
+
if (typeof input === "string" || typeof input === "number" || typeof input === "bigint") out.push(String(input));
|
|
86
|
+
else if (Array.isArray(input)) {
|
|
87
|
+
const nested = cn(...input);
|
|
88
|
+
if (nested) out.push(nested);
|
|
89
|
+
} else if (typeof input === "object") {
|
|
90
|
+
for (const key in input) if (input[key]) out.push(key);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
return out.join(" ");
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
//#endregion
|
|
97
|
+
//#region src/components/icons/CopilotIcon.tsx
|
|
98
|
+
/** Turns SVG attribute names such as `stroke-width` into React's `strokeWidth`. */
|
|
99
|
+
function toReactAttributes(attributes) {
|
|
100
|
+
return Object.fromEntries(Object.entries(attributes).map(([key, value]) => [key.replace(/-([a-z])/g, (_match, letter) => letter.toUpperCase()), value]));
|
|
101
|
+
}
|
|
102
|
+
const svgDefaults = toReactAttributes(_copilotkit_core.ɵcopilotIconSvgAttributes);
|
|
103
|
+
/** True when the props give the icon an accessible name or role. */
|
|
104
|
+
function hasAccessibleProp(props) {
|
|
105
|
+
return Object.keys(props).some((key) => key.startsWith("aria-") || key === "role" || key === "title");
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Internal. Draws a Lucide icon from its node data, the way Lucide's React package
|
|
109
|
+
* does: Lucide's default SVG attributes, the `lucide lucide-<name>` classes,
|
|
110
|
+
* and `aria-hidden="true"` when no `aria-*`, `role` or `title` prop names it.
|
|
111
|
+
*/
|
|
112
|
+
const IconSvg = (0, react.forwardRef)(function IconSvg({ lucideName, nodes, size = 24, color = "currentColor", strokeWidth = 2, className, children, ...props }, ref) {
|
|
113
|
+
const isDecorative = !children && !hasAccessibleProp(props);
|
|
114
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("svg", {
|
|
115
|
+
ref,
|
|
116
|
+
...svgDefaults,
|
|
117
|
+
width: size,
|
|
118
|
+
height: size,
|
|
119
|
+
stroke: color,
|
|
120
|
+
strokeWidth,
|
|
121
|
+
className: cn("lucide", `lucide-${lucideName}`, className),
|
|
122
|
+
"aria-hidden": isDecorative || void 0,
|
|
123
|
+
...props,
|
|
124
|
+
children: [nodes.map((node, index) => (0, react.createElement)(node.tag, {
|
|
125
|
+
key: index,
|
|
126
|
+
...node.attributes
|
|
127
|
+
})), children]
|
|
128
|
+
});
|
|
129
|
+
});
|
|
130
|
+
/**
|
|
131
|
+
* Draws one of the chat icons as an inline `<svg>`.
|
|
132
|
+
*
|
|
133
|
+
* The `<svg>` has the classes `lucide lucide-<icon name>`, so CSS that selects
|
|
134
|
+
* them (for example `svg.lucide-arrow-up`) keeps working. The icon is hidden
|
|
135
|
+
* from screen readers unless you give it an `aria-label`, `role` or `title`.
|
|
136
|
+
*
|
|
137
|
+
* @param props.name - The chat icon, for example `"ArrowUp"` or `"X"`.
|
|
138
|
+
* @param props.size - Width and height. Defaults to `24`.
|
|
139
|
+
* @param props.strokeWidth - Line width. Defaults to `2`.
|
|
140
|
+
* @param props.color - Line color. Defaults to `currentColor`.
|
|
141
|
+
*
|
|
142
|
+
* @example
|
|
143
|
+
* ```tsx
|
|
144
|
+
* <CopilotIcon name="ArrowUp" className="cpk-chat-input-send-icon" />
|
|
145
|
+
* <CopilotIcon name="X" aria-label="Close" />
|
|
146
|
+
* ```
|
|
147
|
+
*/
|
|
148
|
+
const CopilotIcon = (0, react.forwardRef)(function CopilotIcon({ name, ...props }, ref) {
|
|
149
|
+
const icon = _copilotkit_core.ɵcopilotIcons[name];
|
|
150
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(IconSvg, {
|
|
151
|
+
ref,
|
|
152
|
+
lucideName: icon.name,
|
|
153
|
+
nodes: icon.nodes,
|
|
154
|
+
...props
|
|
155
|
+
});
|
|
156
|
+
});
|
|
157
|
+
|
|
74
158
|
//#endregion
|
|
75
159
|
//#region src/lib/shallow-stable-ref.ts
|
|
76
160
|
/**
|
|
@@ -115,51 +199,6 @@ function useShallowStableRef(value) {
|
|
|
115
199
|
|
|
116
200
|
//#endregion
|
|
117
201
|
//#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
202
|
/**
|
|
164
203
|
* Mobile breakpoint below which the chat modal and the thread-list drawer are
|
|
165
204
|
* mutually exclusive. At or above this width both surfaces may coexist. This
|
|
@@ -184,7 +223,7 @@ const CopilotChatConfigurationProvider = ({ children, labels, agentId, threadId,
|
|
|
184
223
|
const parentConfig = (0, react.useContext)(CopilotChatConfiguration);
|
|
185
224
|
const stableLabels = useShallowStableRef(labels);
|
|
186
225
|
const mergedLabels = (0, react.useMemo)(() => ({
|
|
187
|
-
...CopilotChatDefaultLabels,
|
|
226
|
+
..._copilotkit_core.CopilotChatDefaultLabels,
|
|
188
227
|
...parentConfig?.labels,
|
|
189
228
|
...stableLabels
|
|
190
229
|
}), [stableLabels, parentConfig?.labels]);
|
|
@@ -416,28 +455,6 @@ const ControlledModalOpenScope = ({ children, open, onOpenChange }) => {
|
|
|
416
455
|
};
|
|
417
456
|
ControlledModalOpenScope.displayName = "ControlledModalOpenScope";
|
|
418
457
|
|
|
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
458
|
//#endregion
|
|
442
459
|
//#region src/lib/slots.tsx
|
|
443
460
|
/**
|
|
@@ -519,7 +536,7 @@ function useMarkdownRenderer() {
|
|
|
519
536
|
//#endregion
|
|
520
537
|
//#region src/types/defineToolCallRenderer.ts
|
|
521
538
|
function defineToolCallRenderer(def) {
|
|
522
|
-
const argsSchema = def.name === "*" && !def.args ?
|
|
539
|
+
const argsSchema = def.name === "*" && !def.args ? _copilotkit_shared.ɵanySchema : def.args;
|
|
523
540
|
return {
|
|
524
541
|
name: def.name,
|
|
525
542
|
args: argsSchema,
|
|
@@ -3718,10 +3735,10 @@ Object.defineProperty(exports, 'CopilotChatConfigurationProvider', {
|
|
|
3718
3735
|
return CopilotChatConfigurationProvider;
|
|
3719
3736
|
}
|
|
3720
3737
|
});
|
|
3721
|
-
Object.defineProperty(exports, '
|
|
3738
|
+
Object.defineProperty(exports, 'CopilotIcon', {
|
|
3722
3739
|
enumerable: true,
|
|
3723
3740
|
get: function () {
|
|
3724
|
-
return
|
|
3741
|
+
return CopilotIcon;
|
|
3725
3742
|
}
|
|
3726
3743
|
});
|
|
3727
3744
|
Object.defineProperty(exports, 'DARK_THEME_CSS', {
|
|
@@ -3772,6 +3789,12 @@ Object.defineProperty(exports, 'GenerativeUIToolCallRenderer', {
|
|
|
3772
3789
|
return GenerativeUIToolCallRenderer;
|
|
3773
3790
|
}
|
|
3774
3791
|
});
|
|
3792
|
+
Object.defineProperty(exports, 'IconSvg', {
|
|
3793
|
+
enumerable: true,
|
|
3794
|
+
get: function () {
|
|
3795
|
+
return IconSvg;
|
|
3796
|
+
}
|
|
3797
|
+
});
|
|
3775
3798
|
Object.defineProperty(exports, 'MarkdownRendererProvider', {
|
|
3776
3799
|
enumerable: true,
|
|
3777
3800
|
get: function () {
|
|
@@ -3988,4 +4011,4 @@ Object.defineProperty(exports, 'wrapperAria', {
|
|
|
3988
4011
|
return wrapperAria;
|
|
3989
4012
|
}
|
|
3990
4013
|
});
|
|
3991
|
-
//# sourceMappingURL=MarkdownSurfaces-
|
|
4014
|
+
//# sourceMappingURL=MarkdownSurfaces-DQZM4lSI.cjs.map
|