@copilotkitnext/react 0.0.13 → 0.0.14
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/index.d.mts +7 -6
- package/dist/index.d.ts +7 -6
- package/dist/index.js +16 -113
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +15 -112
- package/dist/index.mjs.map +1 -1
- package/dist/styles.css +1 -1
- package/package.json +5 -10
- package/vitest.config.mjs +5 -0
package/dist/index.mjs
CHANGED
|
@@ -882,11 +882,6 @@ CopilotChatInput.Toolbar.displayName = "CopilotChatInput.Toolbar";
|
|
|
882
882
|
var CopilotChatInput_default = CopilotChatInput;
|
|
883
883
|
|
|
884
884
|
// src/components/chat/CopilotChatAssistantMessage.tsx
|
|
885
|
-
import { MarkdownHooks } from "react-markdown";
|
|
886
|
-
import remarkGfm from "remark-gfm";
|
|
887
|
-
import remarkMath from "remark-math";
|
|
888
|
-
import rehypePrettyCode from "rehype-pretty-code";
|
|
889
|
-
import rehypeKatex from "rehype-katex";
|
|
890
885
|
import { useState as useState7 } from "react";
|
|
891
886
|
import {
|
|
892
887
|
Copy,
|
|
@@ -898,7 +893,7 @@ import {
|
|
|
898
893
|
} from "lucide-react";
|
|
899
894
|
import { twMerge as twMerge4 } from "tailwind-merge";
|
|
900
895
|
import "katex/dist/katex.min.css";
|
|
901
|
-
import {
|
|
896
|
+
import { Streamdown } from "streamdown";
|
|
902
897
|
|
|
903
898
|
// src/hooks/use-render-tool-call.tsx
|
|
904
899
|
import { useCallback, useEffect as useEffect5, useState as useState4, useSyncExternalStore } from "react";
|
|
@@ -956,7 +951,7 @@ var CopilotKitCoreReact = class extends CopilotKitCore {
|
|
|
956
951
|
}
|
|
957
952
|
};
|
|
958
953
|
|
|
959
|
-
// src/components/
|
|
954
|
+
// src/components/CopilotKitInspector.tsx
|
|
960
955
|
import * as React4 from "react";
|
|
961
956
|
import { createComponent } from "@lit-labs/react";
|
|
962
957
|
import {
|
|
@@ -966,12 +961,12 @@ import {
|
|
|
966
961
|
} from "@copilotkitnext/web-inspector";
|
|
967
962
|
import { jsx as jsx7 } from "react/jsx-runtime";
|
|
968
963
|
defineWebInspector();
|
|
969
|
-
var
|
|
964
|
+
var CopilotKitInspectorBase = createComponent({
|
|
970
965
|
tagName: WEB_INSPECTOR_TAG,
|
|
971
966
|
elementClass: WebInspectorElement,
|
|
972
967
|
react: React4
|
|
973
968
|
});
|
|
974
|
-
var
|
|
969
|
+
var CopilotKitInspector = React4.forwardRef(
|
|
975
970
|
({ core, ...rest }, ref) => {
|
|
976
971
|
const innerRef = React4.useRef(null);
|
|
977
972
|
React4.useImperativeHandle(ref, () => innerRef.current, []);
|
|
@@ -980,10 +975,16 @@ var WebInspector = React4.forwardRef(
|
|
|
980
975
|
innerRef.current.core = core ?? null;
|
|
981
976
|
}
|
|
982
977
|
}, [core]);
|
|
983
|
-
return /* @__PURE__ */ jsx7(
|
|
978
|
+
return /* @__PURE__ */ jsx7(
|
|
979
|
+
CopilotKitInspectorBase,
|
|
980
|
+
{
|
|
981
|
+
...rest,
|
|
982
|
+
ref: innerRef
|
|
983
|
+
}
|
|
984
|
+
);
|
|
984
985
|
}
|
|
985
986
|
);
|
|
986
|
-
|
|
987
|
+
CopilotKitInspector.displayName = "CopilotKitInspector";
|
|
987
988
|
|
|
988
989
|
// src/providers/CopilotKitProvider.tsx
|
|
989
990
|
import { jsx as jsx8, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
@@ -1145,7 +1146,7 @@ var CopilotKitProvider = ({
|
|
|
1145
1146
|
},
|
|
1146
1147
|
children: [
|
|
1147
1148
|
children,
|
|
1148
|
-
shouldRenderInspector ? /* @__PURE__ */ jsx8(
|
|
1149
|
+
shouldRenderInspector ? /* @__PURE__ */ jsx8(CopilotKitInspector, { core: copilotkit }) : null
|
|
1149
1150
|
]
|
|
1150
1151
|
}
|
|
1151
1152
|
);
|
|
@@ -1850,105 +1851,7 @@ function CopilotChatAssistantMessage({
|
|
|
1850
1851
|
);
|
|
1851
1852
|
}
|
|
1852
1853
|
((CopilotChatAssistantMessage2) => {
|
|
1853
|
-
|
|
1854
|
-
children,
|
|
1855
|
-
...props
|
|
1856
|
-
}) => {
|
|
1857
|
-
return /* @__PURE__ */ jsx12(
|
|
1858
|
-
"code",
|
|
1859
|
-
{
|
|
1860
|
-
className: "px-[4.8px] py-[2.5px] bg-[rgb(236,236,236)] dark:bg-gray-800 rounded text-sm font-mono font-medium! text-foreground!",
|
|
1861
|
-
...props,
|
|
1862
|
-
children
|
|
1863
|
-
}
|
|
1864
|
-
);
|
|
1865
|
-
};
|
|
1866
|
-
const CodeBlock = ({ children, className, onClick, ...props }) => {
|
|
1867
|
-
const config = useCopilotChatConfiguration();
|
|
1868
|
-
const labels = config?.labels ?? CopilotChatDefaultLabels;
|
|
1869
|
-
const [copied, setCopied] = useState7(false);
|
|
1870
|
-
const getCodeContent = (node) => {
|
|
1871
|
-
if (typeof node === "string") return node;
|
|
1872
|
-
if (Array.isArray(node)) return node.map(getCodeContent).join("");
|
|
1873
|
-
if (node?.props?.children) return getCodeContent(node.props.children);
|
|
1874
|
-
return "";
|
|
1875
|
-
};
|
|
1876
|
-
const codeContent = getCodeContent(children);
|
|
1877
|
-
const language = props["data-language"];
|
|
1878
|
-
const copyToClipboard = async () => {
|
|
1879
|
-
if (!codeContent.trim()) return;
|
|
1880
|
-
try {
|
|
1881
|
-
setCopied(true);
|
|
1882
|
-
setTimeout(() => setCopied(false), 2e3);
|
|
1883
|
-
if (onClick) {
|
|
1884
|
-
onClick();
|
|
1885
|
-
}
|
|
1886
|
-
} catch (err) {
|
|
1887
|
-
console.error("Failed to copy code:", err);
|
|
1888
|
-
}
|
|
1889
|
-
};
|
|
1890
|
-
return /* @__PURE__ */ jsxs5("div", { className: "relative", children: [
|
|
1891
|
-
/* @__PURE__ */ jsxs5("div", { className: "flex items-center justify-between px-4 pr-3 py-3 text-xs", children: [
|
|
1892
|
-
language && /* @__PURE__ */ jsx12("span", { className: "font-regular text-muted-foreground dark:text-white", children: language }),
|
|
1893
|
-
/* @__PURE__ */ jsxs5(
|
|
1894
|
-
"button",
|
|
1895
|
-
{
|
|
1896
|
-
className: cn(
|
|
1897
|
-
"px-2 gap-0.5 text-xs flex items-center cursor-pointer text-muted-foreground dark:text-white"
|
|
1898
|
-
),
|
|
1899
|
-
onClick: copyToClipboard,
|
|
1900
|
-
title: copied ? labels.assistantMessageToolbarCopyCodeCopiedLabel : `${labels.assistantMessageToolbarCopyCodeLabel} code`,
|
|
1901
|
-
children: [
|
|
1902
|
-
copied ? /* @__PURE__ */ jsx12(Check2, { className: "h-[10px]! w-[10px]!" }) : /* @__PURE__ */ jsx12(Copy, { className: "h-[10px]! w-[10px]!" }),
|
|
1903
|
-
/* @__PURE__ */ jsx12("span", { className: "text-[11px]", children: copied ? labels.assistantMessageToolbarCopyCodeCopiedLabel : labels.assistantMessageToolbarCopyCodeLabel })
|
|
1904
|
-
]
|
|
1905
|
-
}
|
|
1906
|
-
)
|
|
1907
|
-
] }),
|
|
1908
|
-
/* @__PURE__ */ jsx12(
|
|
1909
|
-
"pre",
|
|
1910
|
-
{
|
|
1911
|
-
className: cn(
|
|
1912
|
-
className,
|
|
1913
|
-
"rounded-2xl bg-transparent border-t-0 my-1!"
|
|
1914
|
-
),
|
|
1915
|
-
...props,
|
|
1916
|
-
children
|
|
1917
|
-
}
|
|
1918
|
-
)
|
|
1919
|
-
] });
|
|
1920
|
-
};
|
|
1921
|
-
CopilotChatAssistantMessage2.MarkdownRenderer = ({ content, className }) => /* @__PURE__ */ jsx12("div", { className, children: /* @__PURE__ */ jsx12(
|
|
1922
|
-
MarkdownHooks,
|
|
1923
|
-
{
|
|
1924
|
-
remarkPlugins: [remarkGfm, remarkMath],
|
|
1925
|
-
rehypePlugins: [
|
|
1926
|
-
[
|
|
1927
|
-
rehypePrettyCode,
|
|
1928
|
-
{
|
|
1929
|
-
keepBackground: false,
|
|
1930
|
-
theme: {
|
|
1931
|
-
dark: "one-dark-pro",
|
|
1932
|
-
light: "one-light"
|
|
1933
|
-
},
|
|
1934
|
-
bypassInlineCode: true
|
|
1935
|
-
}
|
|
1936
|
-
],
|
|
1937
|
-
rehypeKatex
|
|
1938
|
-
],
|
|
1939
|
-
components: {
|
|
1940
|
-
pre: CodeBlock,
|
|
1941
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1942
|
-
code: ({ className: className2, children, ...props }) => {
|
|
1943
|
-
if (typeof children === "string") {
|
|
1944
|
-
return /* @__PURE__ */ jsx12(InlineCode, { ...props, children });
|
|
1945
|
-
}
|
|
1946
|
-
return /* @__PURE__ */ jsx12("code", { className: className2, ...props, children });
|
|
1947
|
-
}
|
|
1948
|
-
},
|
|
1949
|
-
children: completePartialMarkdown(content || "")
|
|
1950
|
-
}
|
|
1951
|
-
) });
|
|
1854
|
+
CopilotChatAssistantMessage2.MarkdownRenderer = ({ content, className, ...props }) => /* @__PURE__ */ jsx12(Streamdown, { className, ...props, children: content ?? "" });
|
|
1952
1855
|
CopilotChatAssistantMessage2.Toolbar = ({
|
|
1953
1856
|
className,
|
|
1954
1857
|
...props
|
|
@@ -3258,11 +3161,11 @@ export {
|
|
|
3258
3161
|
CopilotChatUserMessage_default as CopilotChatUserMessage,
|
|
3259
3162
|
CopilotChatView_default as CopilotChatView,
|
|
3260
3163
|
CopilotKitCoreReact,
|
|
3164
|
+
CopilotKitInspector,
|
|
3261
3165
|
CopilotKitProvider,
|
|
3262
3166
|
CopilotModalHeader,
|
|
3263
3167
|
CopilotSidebar,
|
|
3264
3168
|
CopilotSidebarView,
|
|
3265
|
-
WebInspector,
|
|
3266
3169
|
WildcardToolCallRender,
|
|
3267
3170
|
defineToolCallRenderer,
|
|
3268
3171
|
useAgent,
|