@nexface/chat 0.1.21-alpha.3 → 0.1.21-alpha.5
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/BUNDLED_DEPENDENCIES.json +0 -12
- package/dist/BUNDLED_LICENSES.txt +0 -50
- package/dist/assistant-components.d.ts +2 -1
- package/dist/assistant-components.js +9 -12
- package/dist/assistant-runtime.d.ts +4 -1
- package/dist/assistant-runtime.js +5 -1
- package/dist/client.js +14 -6
- package/dist/default-chat.js +1405 -8030
- package/dist/messages.d.ts +3 -0
- package/dist/protocol-messages.d.ts +3 -2
- package/dist/protocol-messages.js +144 -20
- package/dist/protocol-response.js +2 -2
- package/dist/react.js +1 -1
- package/dist/shared/text-only-reply.d.ts +6 -0
- package/dist/shared/text-only-reply.js +10 -0
- package/dist/shared/tool-presentation.d.ts +2 -1
- package/dist/shared/tool-result-markdown.d.ts +15 -0
- package/dist/shared/tool-result-markdown.js +55 -0
- package/dist/shared/tool-result-reference.d.ts +2 -0
- package/dist/shared/tool-result-reference.js +5 -0
- package/dist/styles.css +8 -0
- package/dist/tool-presentation.d.ts +5 -5
- package/dist/tool-presentation.js +58 -77
- package/dist/ui/home-demo/action-bar.js +13 -2
- package/dist/ui/markdown-text.d.ts +6 -1
- package/dist/ui/markdown-text.js +39 -2
- package/package.json +4 -3
|
@@ -1,9 +1,20 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
// Adapted from the pinned official homepage Demo; see vendor/assistant-ui/home-demo/ADAPTATIONS.md.
|
|
3
3
|
import { cn } from "../utils.js";
|
|
4
|
-
import { ActionBarPrimitive, AuiIf } from "@assistant-ui/react";
|
|
4
|
+
import { ActionBarPrimitive, AuiIf, useAui } from "@assistant-ui/react";
|
|
5
5
|
import { CheckIcon, CopyIcon } from "lucide-react";
|
|
6
|
+
import { stripToolResultBlocks } from "../../shared/tool-result-markdown.js";
|
|
7
|
+
import { useCopyToClipboard } from "../use-copy-to-clipboard.js";
|
|
6
8
|
import { actionButtonClass } from "./styles.js";
|
|
7
9
|
export function AssistantActionBar() {
|
|
8
|
-
|
|
10
|
+
const aui = useAui();
|
|
11
|
+
const { isCopied, copyToClipboard } = useCopyToClipboard();
|
|
12
|
+
return (_jsx(ActionBarPrimitive.Root, { autohide: "never", className: cn("flex items-center gap-1.5"), children: _jsxs(ActionBarPrimitive.Copy, { "aria-label": "\u590D\u5236\u56DE\u590D", className: cn(actionButtonClass), onClick: (event) => {
|
|
13
|
+
const raw = aui.message.getCopyText();
|
|
14
|
+
const text = stripToolResultBlocks(raw);
|
|
15
|
+
if (text !== raw) {
|
|
16
|
+
event.preventDefault();
|
|
17
|
+
copyToClipboard(text);
|
|
18
|
+
}
|
|
19
|
+
}, children: [_jsx(AuiIf, { condition: (s) => isCopied || s.message.isCopied, children: _jsx(CheckIcon, { className: cn("size-4") }) }), _jsx(AuiIf, { condition: (s) => !isCopied && !s.message.isCopied, children: _jsx(CopyIcon, { className: cn("size-4") }) })] }) }));
|
|
9
20
|
}
|
|
@@ -1 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
import type { UIMessagePart } from "../messages.js";
|
|
2
|
+
export declare const MarkdownText: import("react").NamedExoticComponent<{
|
|
3
|
+
assistant?: boolean;
|
|
4
|
+
replyIndex?: number | undefined;
|
|
5
|
+
replyParts?: readonly UIMessagePart[] | undefined;
|
|
6
|
+
}>;
|
package/dist/ui/markdown-text.js
CHANGED
|
@@ -1,13 +1,49 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { MarkdownTextPrimitive, unstable_memoizeMarkdownComponents as memoizeMarkdownComponents, useIsMarkdownCodeBlock, } from "@assistant-ui/react-markdown";
|
|
4
|
+
import { useAui } from "@assistant-ui/react";
|
|
4
5
|
import remarkGfm from "remark-gfm";
|
|
5
|
-
import { memo, useRef } from "react";
|
|
6
|
+
import { createContext, memo, useContext, useRef } from "react";
|
|
6
7
|
import { CheckIcon, CopyIcon } from "lucide-react";
|
|
7
8
|
import { CodeBlock } from "./code-block.js";
|
|
8
9
|
import { useCopyToClipboard } from "./use-copy-to-clipboard.js";
|
|
9
10
|
import { cn } from "./utils.js";
|
|
10
|
-
|
|
11
|
+
import { ToolPresentationUI } from "../tool-presentation.js";
|
|
12
|
+
import { toolResultBlock } from "../shared/tool-result-markdown.js";
|
|
13
|
+
function remarkToolResultReferences() {
|
|
14
|
+
return (tree, file) => {
|
|
15
|
+
const source = String(file.value);
|
|
16
|
+
const seen = new Set();
|
|
17
|
+
tree.children = tree.children.flatMap((node) => {
|
|
18
|
+
const block = toolResultBlock(node, source);
|
|
19
|
+
if (!block)
|
|
20
|
+
return [node];
|
|
21
|
+
const { id } = block;
|
|
22
|
+
if (!id || seen.has(id))
|
|
23
|
+
return [];
|
|
24
|
+
seen.add(id);
|
|
25
|
+
return [
|
|
26
|
+
{
|
|
27
|
+
type: "paragraph",
|
|
28
|
+
children: [],
|
|
29
|
+
data: { hName: "div", hProperties: { "data-nexface-result": id } },
|
|
30
|
+
},
|
|
31
|
+
];
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
const ReplyParts = createContext(undefined);
|
|
36
|
+
const ToolResultSlot = ({ "data-nexface-result": toolCallId, }) => {
|
|
37
|
+
const parts = useContext(ReplyParts);
|
|
38
|
+
const calls = parts?.filter((part) => part.type === "tool" && part.toolCallId === toolCallId);
|
|
39
|
+
const tool = calls?.length === 1 ? calls[0] : undefined;
|
|
40
|
+
return tool?.type === "tool" ? _jsx(ToolPresentationUI, { tool: tool }) : null;
|
|
41
|
+
};
|
|
42
|
+
const MarkdownTextImpl = ({ assistant, replyIndex, replyParts }) => {
|
|
43
|
+
const query = useAui().part.query;
|
|
44
|
+
const isFinalReply = query?.type === "index" && query.index === replyIndex;
|
|
45
|
+
return (_jsx(ReplyParts.Provider, { value: isFinalReply ? replyParts : undefined, children: _jsx(MarkdownTextPrimitive, { remarkPlugins: assistant ? [remarkGfm, remarkToolResultReferences] : [remarkGfm], skipHtml: true, className: cn("aui-md"), components: defaultComponents, defer: true }) }));
|
|
46
|
+
};
|
|
11
47
|
export const MarkdownText = memo(MarkdownTextImpl);
|
|
12
48
|
function MarkdownTable({ className, children, ...props }) {
|
|
13
49
|
const ref = useRef(null);
|
|
@@ -38,6 +74,7 @@ function MarkdownTable({ className, children, ...props }) {
|
|
|
38
74
|
const SyntaxHighlighter = ({ language, code }) => (_jsx(CodeBlock, { title: language || undefined, copyText: code, className: cn("my-3"), children: _jsx("pre", { children: _jsx("code", { children: code }) }) }));
|
|
39
75
|
const NoCodeHeader = () => null;
|
|
40
76
|
const defaultComponents = memoizeMarkdownComponents({
|
|
77
|
+
div: ToolResultSlot,
|
|
41
78
|
h1: ({ className, ...props }) => (_jsx("h1", { className: cn("aui-md-h1 mt-5 mb-2 scroll-m-20 text-xl font-semibold first:mt-0 last:mb-0", className), ...props })),
|
|
42
79
|
h2: ({ className, ...props }) => (_jsx("h2", { className: cn("aui-md-h2 mt-5 mb-2 scroll-m-20 text-lg font-semibold first:mt-0 last:mb-0", className), ...props })),
|
|
43
80
|
h3: ({ className, ...props }) => (_jsx("h3", { className: cn("aui-md-h3 mt-4 mb-1.5 scroll-m-20 text-base font-semibold first:mt-0 last:mb-0", className), ...props })),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nexface/chat",
|
|
3
|
-
"version": "0.1.21-alpha.
|
|
3
|
+
"version": "0.1.21-alpha.5",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"types": "./dist/index.d.ts",
|
|
6
6
|
"sideEffects": [
|
|
@@ -19,16 +19,17 @@
|
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
21
|
"@ag-ui/core": "0.0.59",
|
|
22
|
-
"@nexface/agent": "0.1.21-alpha.
|
|
22
|
+
"@nexface/agent": "0.1.21-alpha.5",
|
|
23
23
|
"class-variance-authority": "0.7.1",
|
|
24
24
|
"clsx": "2.1.1",
|
|
25
25
|
"fast-json-patch": "3.1.1",
|
|
26
|
+
"mdast-util-from-markdown": "2.0.3",
|
|
26
27
|
"react-remove-scroll-bar": "2.3.8",
|
|
27
28
|
"use-composed-ref": "1.4.0",
|
|
28
29
|
"use-sync-external-store": "1.7.0"
|
|
29
30
|
},
|
|
30
31
|
"peerDependencies": {
|
|
31
|
-
"@nexface/tools": "0.1.21-alpha.
|
|
32
|
+
"@nexface/tools": "0.1.21-alpha.5",
|
|
32
33
|
"react": ">=17",
|
|
33
34
|
"react-dom": ">=17"
|
|
34
35
|
},
|