@copilotkit/react-core 2.0.0-rc.7 → 2.0.0-rc.9
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-CS35epe1.d.mts} +17 -33
- package/dist/MarkdownRendererContext-CS35epe1.d.mts.map +1 -0
- package/dist/{MarkdownRendererContext-CRKFzsEB.d.mts → MarkdownRendererContext-CfTh92vk.d.cts} +17 -33
- package/dist/MarkdownRendererContext-CfTh92vk.d.cts.map +1 -0
- package/dist/{MarkdownSurfaces-S4wfUl3J.cjs → MarkdownSurfaces-Ije2ZQh0.cjs} +111 -89
- package/dist/MarkdownSurfaces-Ije2ZQh0.cjs.map +1 -0
- package/dist/{MarkdownSurfaces-Bd--93O1.mjs → MarkdownSurfaces-iFKorV2w.mjs} +95 -80
- package/dist/MarkdownSurfaces-iFKorV2w.mjs.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 +541 -520
- 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 +37 -17
- 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 +765 -1292
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +176 -518
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +175 -517
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +469 -1251
- package/dist/index.mjs.map +1 -1
- package/dist/index.umd.js +867 -1375
- package/dist/index.umd.js.map +1 -1
- package/package.json +15 -16
- 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
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import { extractFenceOperations, flattenInformationalCards, getMarkdownOperationSurfaceId, prepareSurfaceOperations, segmentSurfaceProse, splitA2UIMarkdown } from "@copilotkit/core";
|
|
2
|
-
import React, { Component, createContext, memo, useCallback, useContext, useEffect, useInsertionEffect, useLayoutEffect, useMemo, useReducer, useRef, useState, useSyncExternalStore } from "react";
|
|
3
|
-
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
1
|
+
import { CopilotChatDefaultLabels, extractFenceOperations, flattenInformationalCards, getMarkdownOperationSurfaceId, prepareSurfaceOperations, segmentSurfaceProse, splitA2UIMarkdown, ɵcopilotIconSvgAttributes, ɵcopilotIcons } from "@copilotkit/core";
|
|
2
|
+
import React, { Component, createContext, createElement, forwardRef, memo, useCallback, useContext, useEffect, useInsertionEffect, useLayoutEffect, useMemo, useReducer, useRef, useState, useSyncExternalStore } from "react";
|
|
4
3
|
import { StreamingMarkdownRenderer, createStreamingMarkdownNodeRenderers } from "@copilotkit/markdown-renderer/react";
|
|
5
4
|
import { warnUnsupportedRichSyntaxOnce } from "@copilotkit/markdown-renderer";
|
|
6
|
-
import {
|
|
5
|
+
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
import { A2UI_COMPONENT_ENVELOPE_KEYS, A2UI_INDEX_FUNCTION, A2UI_VERSION, DEFAULT_AGENT_ID, GENERATIVE_UI_ACTIVITY_TYPE, GENERATIVE_UI_CHAT_TARGET, GENERATIVE_UI_FUNCTIONS, GENERATIVE_UI_FUNCTION_CALL_ACTIVITY_TYPE, GENERATIVE_UI_RENDER_TOOL, GENERATIVE_UI_ROOT_ID, applyChildRefMarks, childIdsAtRefs, collectChildRefs, functionCallers, getOperationKind, hasBoundChildRef, isActionBinding, isCallBinding, isPathBinding, isValidationResult, mapAtChildRef, randomUUID, schemaToJsonSchema, validateOperation, ɵanySchema } from "@copilotkit/shared";
|
|
7
7
|
import { CopilotKitContext, useCopilotKit, useDefaultAgentId } from "@copilotkit/react-core/context";
|
|
8
|
-
import
|
|
9
|
-
import { zodToJsonSchema } from "zod-to-json-schema";
|
|
8
|
+
import * as z from "zod";
|
|
10
9
|
|
|
11
10
|
//#region src/components/chat/StreamingMarkdownDefaultRenderer.tsx
|
|
12
11
|
const defaultNodeRenderers = createStreamingMarkdownNodeRenderers({ codeBlock: ({ node }) => /* @__PURE__ */ jsx("pre", {
|
|
@@ -43,6 +42,90 @@ function StreamingMarkdownDefaultRenderer({ content, isStreaming, className, nod
|
|
|
43
42
|
}
|
|
44
43
|
StreamingMarkdownDefaultRenderer.displayName = "StreamingMarkdownDefaultRenderer";
|
|
45
44
|
|
|
45
|
+
//#endregion
|
|
46
|
+
//#region src/lib/utils.ts
|
|
47
|
+
/**
|
|
48
|
+
* Joins class names, skipping falsy values. Takes the same inputs as `clsx`.
|
|
49
|
+
* Classes are not merged: every rule CopilotKit ships sits in `:where()`, so a
|
|
50
|
+
* class the app adds wins without removing ours.
|
|
51
|
+
*/
|
|
52
|
+
function cn(...inputs) {
|
|
53
|
+
const out = [];
|
|
54
|
+
for (const input of inputs) {
|
|
55
|
+
if (!input) continue;
|
|
56
|
+
if (typeof input === "string" || typeof input === "number" || typeof input === "bigint") out.push(String(input));
|
|
57
|
+
else if (Array.isArray(input)) {
|
|
58
|
+
const nested = cn(...input);
|
|
59
|
+
if (nested) out.push(nested);
|
|
60
|
+
} else if (typeof input === "object") {
|
|
61
|
+
for (const key in input) if (input[key]) out.push(key);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return out.join(" ");
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
//#endregion
|
|
68
|
+
//#region src/components/icons/CopilotIcon.tsx
|
|
69
|
+
/** Turns SVG attribute names such as `stroke-width` into React's `strokeWidth`. */
|
|
70
|
+
function toReactAttributes(attributes) {
|
|
71
|
+
return Object.fromEntries(Object.entries(attributes).map(([key, value]) => [key.replace(/-([a-z])/g, (_match, letter) => letter.toUpperCase()), value]));
|
|
72
|
+
}
|
|
73
|
+
const svgDefaults = toReactAttributes(ɵcopilotIconSvgAttributes);
|
|
74
|
+
/** True when the props give the icon an accessible name or role. */
|
|
75
|
+
function hasAccessibleProp(props) {
|
|
76
|
+
return Object.keys(props).some((key) => key.startsWith("aria-") || key === "role" || key === "title");
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Internal. Draws a Lucide icon from its node data, the way Lucide's React package
|
|
80
|
+
* does: Lucide's default SVG attributes, the `lucide lucide-<name>` classes,
|
|
81
|
+
* and `aria-hidden="true"` when no `aria-*`, `role` or `title` prop names it.
|
|
82
|
+
*/
|
|
83
|
+
const IconSvg = forwardRef(function IconSvg({ lucideName, nodes, size = 24, color = "currentColor", strokeWidth = 2, className, children, ...props }, ref) {
|
|
84
|
+
const isDecorative = !children && !hasAccessibleProp(props);
|
|
85
|
+
return /* @__PURE__ */ jsxs("svg", {
|
|
86
|
+
ref,
|
|
87
|
+
...svgDefaults,
|
|
88
|
+
width: size,
|
|
89
|
+
height: size,
|
|
90
|
+
stroke: color,
|
|
91
|
+
strokeWidth,
|
|
92
|
+
className: cn("lucide", `lucide-${lucideName}`, className),
|
|
93
|
+
"aria-hidden": isDecorative || void 0,
|
|
94
|
+
...props,
|
|
95
|
+
children: [nodes.map((node, index) => createElement(node.tag, {
|
|
96
|
+
key: index,
|
|
97
|
+
...node.attributes
|
|
98
|
+
})), children]
|
|
99
|
+
});
|
|
100
|
+
});
|
|
101
|
+
/**
|
|
102
|
+
* Draws one of the chat icons as an inline `<svg>`.
|
|
103
|
+
*
|
|
104
|
+
* The `<svg>` has the classes `lucide lucide-<icon name>`, so CSS that selects
|
|
105
|
+
* them (for example `svg.lucide-arrow-up`) keeps working. The icon is hidden
|
|
106
|
+
* from screen readers unless you give it an `aria-label`, `role` or `title`.
|
|
107
|
+
*
|
|
108
|
+
* @param props.name - The chat icon, for example `"ArrowUp"` or `"X"`.
|
|
109
|
+
* @param props.size - Width and height. Defaults to `24`.
|
|
110
|
+
* @param props.strokeWidth - Line width. Defaults to `2`.
|
|
111
|
+
* @param props.color - Line color. Defaults to `currentColor`.
|
|
112
|
+
*
|
|
113
|
+
* @example
|
|
114
|
+
* ```tsx
|
|
115
|
+
* <CopilotIcon name="ArrowUp" className="cpk-chat-input-send-icon" />
|
|
116
|
+
* <CopilotIcon name="X" aria-label="Close" />
|
|
117
|
+
* ```
|
|
118
|
+
*/
|
|
119
|
+
const CopilotIcon = forwardRef(function CopilotIcon({ name, ...props }, ref) {
|
|
120
|
+
const icon = ɵcopilotIcons[name];
|
|
121
|
+
return /* @__PURE__ */ jsx(IconSvg, {
|
|
122
|
+
ref,
|
|
123
|
+
lucideName: icon.name,
|
|
124
|
+
nodes: icon.nodes,
|
|
125
|
+
...props
|
|
126
|
+
});
|
|
127
|
+
});
|
|
128
|
+
|
|
46
129
|
//#endregion
|
|
47
130
|
//#region src/lib/shallow-stable-ref.ts
|
|
48
131
|
/**
|
|
@@ -87,51 +170,6 @@ function useShallowStableRef(value) {
|
|
|
87
170
|
|
|
88
171
|
//#endregion
|
|
89
172
|
//#region src/providers/CopilotChatConfigurationProvider.tsx
|
|
90
|
-
const CopilotChatDefaultLabels = {
|
|
91
|
-
chatInputPlaceholder: "Type a message...",
|
|
92
|
-
chatInputToolbarStartTranscribeButtonLabel: "Transcribe",
|
|
93
|
-
chatInputToolbarCancelTranscribeButtonLabel: "Cancel",
|
|
94
|
-
chatInputToolbarFinishTranscribeButtonLabel: "Finish",
|
|
95
|
-
chatInputToolbarAddButtonLabel: "Add attachments",
|
|
96
|
-
chatInputToolbarToolsButtonLabel: "Tools",
|
|
97
|
-
chatInputToolbarSendButtonLabel: "Send message",
|
|
98
|
-
chatInputToolbarStopButtonLabel: "Stop",
|
|
99
|
-
assistantMessageToolbarCopyCodeLabel: "Copy",
|
|
100
|
-
assistantMessageToolbarCopyCodeCopiedLabel: "Copied",
|
|
101
|
-
assistantMessageToolbarCopyMessageLabel: "Copy",
|
|
102
|
-
assistantMessageToolbarInspectorLabel: "View in Inspector",
|
|
103
|
-
assistantMessageToolbarInspectorDescription: "Open this message in the Inspector",
|
|
104
|
-
assistantMessageToolbarInspectorLocalOnlyLabel: "Local only",
|
|
105
|
-
assistantMessageToolbarInspectorLocalOnlyDescription: "Only visible on localhost or loopback hosts in development. Never shown in production.",
|
|
106
|
-
assistantMessageToolbarInspectorTitle: "CopilotKit Inspector",
|
|
107
|
-
assistantMessageToolbarInspectorHideLabel: "Hide this icon",
|
|
108
|
-
assistantMessageToolbarInspectorHideDescription: "Until you reload this page",
|
|
109
|
-
assistantMessageToolbarThumbsUpLabel: "Good response",
|
|
110
|
-
assistantMessageToolbarThumbsDownLabel: "Bad response",
|
|
111
|
-
assistantMessageFeedbackCommentPlaceholder: "Add a comment (optional)",
|
|
112
|
-
assistantMessageFeedbackCommentSubmitLabel: "Send comment",
|
|
113
|
-
assistantMessageToolbarReadAloudLabel: "Read aloud",
|
|
114
|
-
assistantMessageToolbarRegenerateLabel: "Regenerate",
|
|
115
|
-
userMessageToolbarCopyMessageLabel: "Copy",
|
|
116
|
-
userMessageToolbarEditMessageLabel: "Edit",
|
|
117
|
-
userMessageToolbarPreviousBranchLabel: "Previous branch",
|
|
118
|
-
userMessageToolbarNextBranchLabel: "Next branch",
|
|
119
|
-
chatDisclaimerText: "AI can make mistakes. Please verify important information.",
|
|
120
|
-
chatToggleOpenLabel: "Open chat",
|
|
121
|
-
chatToggleCloseLabel: "Close chat",
|
|
122
|
-
chatScrollToBottomLabel: "Scroll to bottom",
|
|
123
|
-
modalHeaderTitle: "CopilotKit Chat",
|
|
124
|
-
welcomeMessageText: "How can I help you today?",
|
|
125
|
-
reasoningMessageThinkingLabel: "Thinking…",
|
|
126
|
-
chatInputSlashMenuLabel: "Slash commands",
|
|
127
|
-
chatInputSlashMenuEmptyText: "No commands found",
|
|
128
|
-
attachmentRemoveButtonLabel: "Remove attachment",
|
|
129
|
-
attachmentPlayVideoButtonLabel: "Play video",
|
|
130
|
-
attachmentPreviewCloseButtonLabel: "Close preview",
|
|
131
|
-
modalHeaderCloseButtonLabel: "Close",
|
|
132
|
-
modalHeaderThreadsButtonLabel: "Open threads",
|
|
133
|
-
sidebarLabel: "Copilot chat sidebar"
|
|
134
|
-
};
|
|
135
173
|
/**
|
|
136
174
|
* Mobile breakpoint below which the chat modal and the thread-list drawer are
|
|
137
175
|
* mutually exclusive. At or above this width both surfaces may coexist. This
|
|
@@ -388,28 +426,6 @@ const ControlledModalOpenScope = ({ children, open, onOpenChange }) => {
|
|
|
388
426
|
};
|
|
389
427
|
ControlledModalOpenScope.displayName = "ControlledModalOpenScope";
|
|
390
428
|
|
|
391
|
-
//#endregion
|
|
392
|
-
//#region src/lib/utils.ts
|
|
393
|
-
/**
|
|
394
|
-
* Joins class names, skipping falsy values. Takes the same inputs as `clsx`.
|
|
395
|
-
* Classes are not merged: every rule CopilotKit ships sits in `:where()`, so a
|
|
396
|
-
* class the app adds wins without removing ours.
|
|
397
|
-
*/
|
|
398
|
-
function cn(...inputs) {
|
|
399
|
-
const out = [];
|
|
400
|
-
for (const input of inputs) {
|
|
401
|
-
if (!input) continue;
|
|
402
|
-
if (typeof input === "string" || typeof input === "number" || typeof input === "bigint") out.push(String(input));
|
|
403
|
-
else if (Array.isArray(input)) {
|
|
404
|
-
const nested = cn(...input);
|
|
405
|
-
if (nested) out.push(nested);
|
|
406
|
-
} else if (typeof input === "object") {
|
|
407
|
-
for (const key in input) if (input[key]) out.push(key);
|
|
408
|
-
}
|
|
409
|
-
}
|
|
410
|
-
return out.join(" ");
|
|
411
|
-
}
|
|
412
|
-
|
|
413
429
|
//#endregion
|
|
414
430
|
//#region src/lib/slots.tsx
|
|
415
431
|
/**
|
|
@@ -491,7 +507,7 @@ function useMarkdownRenderer() {
|
|
|
491
507
|
//#endregion
|
|
492
508
|
//#region src/types/defineToolCallRenderer.ts
|
|
493
509
|
function defineToolCallRenderer(def) {
|
|
494
|
-
const argsSchema = def.name === "*" && !def.args ?
|
|
510
|
+
const argsSchema = def.name === "*" && !def.args ? ɵanySchema : def.args;
|
|
495
511
|
return {
|
|
496
512
|
name: def.name,
|
|
497
513
|
args: argsSchema,
|
|
@@ -504,12 +520,11 @@ function defineToolCallRenderer(def) {
|
|
|
504
520
|
//#endregion
|
|
505
521
|
//#region src/generative-ui/json-schema.ts
|
|
506
522
|
/**
|
|
507
|
-
* JSON Schema for a Standard Schema
|
|
508
|
-
* inlined, no `$schema`. A prop marked by `child()` or `childList()`
|
|
523
|
+
* JSON Schema for a Standard Schema, without `$schema`. A prop marked by `child()` or `childList()`
|
|
509
524
|
* becomes an A2UI `$ref` to `ComponentId` or `ChildList`.
|
|
510
525
|
*/
|
|
511
526
|
function toJsonSchema(schema) {
|
|
512
|
-
const { $schema: _omit, ...rest } = schemaToJsonSchema(schema
|
|
527
|
+
const { $schema: _omit, ...rest } = schemaToJsonSchema(schema);
|
|
513
528
|
return applyChildRefMarks(rest);
|
|
514
529
|
}
|
|
515
530
|
|
|
@@ -3463,7 +3478,7 @@ const ContentSchema = z.object({
|
|
|
3463
3478
|
index: z.number(),
|
|
3464
3479
|
reason: z.string()
|
|
3465
3480
|
})).default([])
|
|
3466
|
-
}).
|
|
3481
|
+
}).loose();
|
|
3467
3482
|
function GenerativeUIChatActivity({ content, agent }) {
|
|
3468
3483
|
const runtime = useGenerativeUIRuntime();
|
|
3469
3484
|
const threadId = useCopilotChatConfiguration()?.threadId ?? agent?.threadId;
|
|
@@ -3672,5 +3687,5 @@ function MarkdownSurfaces({ content, messageId, isStreaming = false, ...markdown
|
|
|
3672
3687
|
}
|
|
3673
3688
|
|
|
3674
3689
|
//#endregion
|
|
3675
|
-
export { GenerativeUIError as A, renderSlot as B, issueKey as C, getMarkdownSurfaceSource as D, containsDynamicValue as E, toJsonSchema as F,
|
|
3676
|
-
//# sourceMappingURL=MarkdownSurfaces-
|
|
3690
|
+
export { GenerativeUIError as A, renderSlot as B, issueKey as C, getMarkdownSurfaceSource as D, containsDynamicValue as E, toJsonSchema as F, CopilotIcon as G, CopilotChatConfigurationProvider as H, defineToolCallRenderer as I, StreamingMarkdownDefaultRenderer as J, IconSvg as K, MarkdownRendererProvider as L, catalogIdsOf as M, componentCatalogIds as N, BASIC_FUNCTIONS as O, createGenerativeUI as P, useMarkdownRenderer as R, isAsyncIssue as S, withoutRejectedNulls as T, useCopilotChatConfiguration as U, ControlledModalOpenScope as V, useShallowStableRef as W, GenerativeUINodeContext as _, GenerativeUIToolCallRenderer as a, useRequiredGenerativeUIRuntime as b, SurfaceView as c, namedRole as d, useGenerativeUIAccessibility as f, useManagerVersion as g, useGenerativeUIState as h, GenerativeUIChatSlotContext as i, isRecord as j, ExpressionError as k, DARK_THEME_CSS as l, useGenerativeUIFunction as m, ProviderMarkdown as n, createGenerativeUIActivityRenderer as o, wrapperAria as p, cn as q, DefaultGenerativeUIChatCard as r, createGenerativeUIFunctionCallActivityRenderer as s, MarkdownSurfaces as t, controlAria as u, GenerativeUIRuntimeContext as v, validateSchemaSync as w, formatIssues as x, useGenerativeUIRuntime as y, isReactComponentType as z };
|
|
3691
|
+
//# sourceMappingURL=MarkdownSurfaces-iFKorV2w.mjs.map
|