@nexface/chat 0.1.21-alpha.5 → 0.1.21-alpha.6
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 +12 -0
- package/dist/BUNDLED_LICENSES.txt +50 -0
- package/dist/assistant-components.d.ts +1 -2
- package/dist/assistant-components.js +6 -8
- package/dist/assistant-runtime.d.ts +1 -4
- package/dist/assistant-runtime.js +5 -19
- package/dist/client.js +12 -24
- package/dist/default-chat.d.ts +1 -1
- package/dist/default-chat.js +7864 -1553
- package/dist/messages.d.ts +0 -3
- package/dist/protocol-messages.d.ts +2 -3
- package/dist/protocol-messages.js +27 -145
- package/dist/protocol-response.js +2 -2
- package/dist/react.d.ts +1 -11
- package/dist/react.js +100 -515
- package/dist/storage.d.ts +6 -3
- package/dist/storage.js +44 -50
- package/dist/styles.css +676 -1503
- package/dist/tool-result.d.ts +0 -5
- package/dist/tool-result.js +0 -31
- package/dist/types.d.ts +1 -3
- package/dist/ui/home-demo/action-bar.js +2 -13
- package/dist/ui/home-demo/greeting.d.ts +1 -3
- package/dist/ui/home-demo/greeting.js +2 -2
- package/dist/ui/home-demo/suggestions.d.ts +4 -2
- package/dist/ui/home-demo/suggestions.js +4 -5
- package/dist/ui/home-demo/trace.js +3 -2
- package/dist/ui/markdown-text.d.ts +1 -6
- package/dist/ui/markdown-text.js +2 -39
- package/dist/ui/thread-list.aui.d.ts +1 -2
- package/dist/ui/thread-list.aui.js +2 -6
- package/package.json +3 -4
- package/dist/fonts/Inter-OFL.txt +0 -93
- package/dist/fonts/inter-medium.ttf +0 -0
- package/dist/session-coordinator.d.ts +0 -23
- package/dist/session-coordinator.js +0 -139
- package/dist/session-history.d.ts +0 -29
- package/dist/session-history.js +0 -282
- package/dist/shared/text-only-reply.d.ts +0 -6
- package/dist/shared/text-only-reply.js +0 -10
- package/dist/shared/tool-presentation.d.ts +0 -18
- package/dist/shared/tool-presentation.js +0 -5
- package/dist/shared/tool-result-markdown.d.ts +0 -15
- package/dist/shared/tool-result-markdown.js +0 -55
- package/dist/shared/tool-result-reference.d.ts +0 -2
- package/dist/shared/tool-result-reference.js +0 -5
- package/dist/tool-presentation.d.ts +0 -6
- package/dist/tool-presentation.js +0 -113
package/dist/tool-result.d.ts
CHANGED
|
@@ -1,6 +1 @@
|
|
|
1
1
|
export declare function getToolResultError(content: string): string | undefined;
|
|
2
|
-
export declare function decodeToolResult(content: string, toolName?: string): {
|
|
3
|
-
value: unknown;
|
|
4
|
-
omitted: boolean;
|
|
5
|
-
};
|
|
6
|
-
export declare function toolResultPreview(result: unknown): string;
|
package/dist/tool-result.js
CHANGED
|
@@ -14,34 +14,3 @@ export function getToolResultError(content) {
|
|
|
14
14
|
}
|
|
15
15
|
return undefined;
|
|
16
16
|
}
|
|
17
|
-
export function decodeToolResult(content, toolName) {
|
|
18
|
-
try {
|
|
19
|
-
const payload = JSON.parse(content);
|
|
20
|
-
if (payload && typeof payload === "object" && !Array.isArray(payload)) {
|
|
21
|
-
const record = payload;
|
|
22
|
-
if (record.contentOmitted === true &&
|
|
23
|
-
typeof record.preview === "string" &&
|
|
24
|
-
Object.keys(record).length === 2)
|
|
25
|
-
return { value: record.preview, omitted: true };
|
|
26
|
-
if (Object.hasOwn(record, "result") &&
|
|
27
|
-
(Object.keys(record).length === 1 ||
|
|
28
|
-
(toolName !== undefined &&
|
|
29
|
-
record.toolName === toolName &&
|
|
30
|
-
Object.keys(record).length === 2)))
|
|
31
|
-
return { value: record.result, omitted: false };
|
|
32
|
-
}
|
|
33
|
-
return { value: payload, omitted: false };
|
|
34
|
-
}
|
|
35
|
-
catch {
|
|
36
|
-
return { value: content, omitted: false };
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
export function toolResultPreview(result) {
|
|
40
|
-
const decoded = typeof result === "string" ? decodeToolResult(result) : undefined;
|
|
41
|
-
const text = decoded?.omitted
|
|
42
|
-
? String(decoded.value)
|
|
43
|
-
: typeof result === "string"
|
|
44
|
-
? result
|
|
45
|
-
: (JSON.stringify(result, null, 2) ?? "");
|
|
46
|
-
return text.length > 4000 || decoded?.omitted ? `${text.slice(0, 4000)}…` : text;
|
|
47
|
-
}
|
package/dist/types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { AgentRunResult } from "@nexface/agent";
|
|
2
|
-
import type { CSSProperties
|
|
2
|
+
import type { CSSProperties } from "react";
|
|
3
3
|
import type { ChatDictation } from "./voice/types.js";
|
|
4
4
|
export type ChatRunResult = Extract<AgentRunResult, {
|
|
5
5
|
outcome: {
|
|
@@ -7,12 +7,10 @@ export type ChatRunResult = Extract<AgentRunResult, {
|
|
|
7
7
|
};
|
|
8
8
|
}>;
|
|
9
9
|
export interface ChatSuggestion {
|
|
10
|
-
readonly icon?: ReactNode;
|
|
11
10
|
readonly label: string;
|
|
12
11
|
readonly prompt: string;
|
|
13
12
|
}
|
|
14
13
|
export interface ChatProps {
|
|
15
|
-
welcomeIcon?: ReactNode;
|
|
16
14
|
dictation?: false | ChatDictation | undefined;
|
|
17
15
|
open?: boolean;
|
|
18
16
|
onOpenChange?: (open: boolean) => void;
|
|
@@ -1,20 +1,9 @@
|
|
|
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
|
|
4
|
+
import { ActionBarPrimitive, AuiIf } 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";
|
|
8
6
|
import { actionButtonClass } from "./styles.js";
|
|
9
7
|
export function AssistantActionBar() {
|
|
10
|
-
|
|
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") }) })] }) }));
|
|
8
|
+
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), children: [_jsx(AuiIf, { condition: (s) => s.message.isCopied, children: _jsx(CheckIcon, { className: cn("size-4") }) }), _jsx(AuiIf, { condition: (s) => !s.message.isCopied, children: _jsx(CopyIcon, { className: cn("size-4") }) })] }) }));
|
|
20
9
|
}
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
export declare function Greeting({ title, description, icon, }: {
|
|
1
|
+
export declare function Greeting({ title, description, }: {
|
|
3
2
|
title: string;
|
|
4
3
|
description?: string | undefined;
|
|
5
|
-
icon?: ReactNode;
|
|
6
4
|
}): import("react").JSX.Element;
|
|
@@ -2,6 +2,6 @@ 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
4
|
import { typeSection, typeDeck } from "./type.js";
|
|
5
|
-
export function Greeting({ title, description,
|
|
6
|
-
return (_jsxs("div", { className: cn("animate-in fade-in slide-in-from-bottom-1 mx-auto mb-8 flex w-full max-w-(--nxf-thread-max-width) flex-col items-center text-center duration-200"), children: [
|
|
5
|
+
export function Greeting({ title, description, }) {
|
|
6
|
+
return (_jsxs("div", { className: cn("animate-in fade-in slide-in-from-bottom-1 mx-auto mb-8 flex w-full max-w-(--nxf-thread-max-width) flex-col items-center text-center duration-200"), children: [_jsx("p", { className: cn(typeSection), children: title }), description ? _jsx("p", { className: cn(typeDeck), children: description }) : null] }));
|
|
7
7
|
}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import type { ChatSuggestion } from "../../types.js";
|
|
2
1
|
export declare function Suggestions({ suggestions, disabled, onSend, }: {
|
|
3
|
-
suggestions: readonly
|
|
2
|
+
suggestions: readonly {
|
|
3
|
+
label: string;
|
|
4
|
+
prompt: string;
|
|
5
|
+
}[];
|
|
4
6
|
disabled: boolean;
|
|
5
7
|
onSend(prompt: string): void;
|
|
6
8
|
}): import("react").JSX.Element;
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
// Adapted from the pinned official homepage Demo; see vendor/assistant-ui/home-demo/ADAPTATIONS.md.
|
|
2
2
|
"use client";
|
|
3
|
-
import { jsx as _jsx
|
|
3
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
4
4
|
import { ThreadPrimitive, useAuiState } from "@assistant-ui/react";
|
|
5
5
|
import { cn } from "../utils.js";
|
|
6
|
-
|
|
7
|
-
const suggestionChipClass = "bg-background text-suggestion hover:text-foreground font-suggestion inset-ring inset-ring-black/8 dark:inset-ring-foreground/8 hover:inset-ring-foreground/25 rounded-lg inline-flex min-h-[32px] min-w-0 max-w-full items-center gap-2 px-3 py-[5px] text-sm font-medium leading-[1.57143] transition-colors focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring";
|
|
6
|
+
const suggestionChipClass = "border-foreground/10 bg-background text-muted-foreground hover:border-foreground/25 hover:text-foreground rounded-control h-8 border px-3 text-[13px] transition-colors";
|
|
8
7
|
export function Suggestions({ suggestions, disabled, onSend, }) {
|
|
9
8
|
const isComposerEmpty = useAuiState((s) => s.composer.isEmpty);
|
|
10
9
|
const hidden = !isComposerEmpty || disabled;
|
|
@@ -12,8 +11,8 @@ export function Suggestions({ suggestions, disabled, onSend, }) {
|
|
|
12
11
|
// Typing hides the suggestions without unmounting them: the empty view is
|
|
13
12
|
// centred, so collapsing a block this tall moves the composer out from
|
|
14
13
|
// under the cursor. Disabled buttons also stay out of the tab order in React 18.
|
|
15
|
-
_jsx("div", { "aria-hidden": hidden, className: cn("animate-in fade-in mx-auto flex max-w-[34rem] flex-wrap items-center justify-center gap-2 transition-opacity duration-200 motion-reduce:animate-none", hidden && "opacity-0"), children: suggestions.map((suggestion) => (
|
|
14
|
+
_jsx("div", { "aria-hidden": hidden, className: cn("animate-in fade-in mx-auto flex max-w-[34rem] flex-wrap items-center justify-center gap-2 transition-opacity duration-200 motion-reduce:animate-none", hidden && "opacity-0"), children: suggestions.map((suggestion) => (_jsx(ThreadPrimitive.Suggestion, { prompt: suggestion.prompt, send: true, disabled: hidden, onClick: (event) => {
|
|
16
15
|
event.preventDefault();
|
|
17
16
|
onSend(suggestion.prompt);
|
|
18
|
-
}, className: cn(suggestionChipClass), children:
|
|
17
|
+
}, className: cn(suggestionChipClass), children: suggestion.label }, suggestion.prompt))) }));
|
|
19
18
|
}
|
|
@@ -5,7 +5,6 @@ import { Collapsible, CollapsibleContent } from "../collapsible.js";
|
|
|
5
5
|
import { ShimmerLabel } from "./surfaces.js";
|
|
6
6
|
import { CollapsibleTrigger } from "../collapsible.js";
|
|
7
7
|
import { TraceLine, TraceMarker, useToolDuration, formatDuration } from "./trace-line.js";
|
|
8
|
-
import { toolResultPreview } from "../../tool-result.js";
|
|
9
8
|
export const disclosureContentClass = "border-foreground/10 ms-[5px] border-s ps-4";
|
|
10
9
|
export function DisclosureTrigger({ live, label, detail, }) {
|
|
11
10
|
return (_jsxs(CollapsibleTrigger, { "data-slot": "tool-group-trigger", className: cn("group/trigger my-1 flex max-w-full items-baseline gap-2 text-left font-mono text-[12px] outline-none [font-variant-ligatures:none] focus-visible:underline"), children: [_jsx(TraceMarker, { live: live, className: cn("group-data-[state=open]/trigger:rotate-90") }), _jsx("span", { className: cn("text-muted-foreground group-hover/trigger:text-foreground min-w-0 truncate transition-colors"), children: live ? (_jsxs(ShimmerLabel, { children: [label, detail ? ` ${detail}` : null] })) : (_jsxs(_Fragment, { children: [label, detail ? ` ${detail}` : null] })) })] }));
|
|
@@ -38,5 +37,7 @@ export function ToolCall({ toolName, args, argsText, result, status, isError, sh
|
|
|
38
37
|
? "Rejected"
|
|
39
38
|
: tool?.toolState === "not_started"
|
|
40
39
|
? "Not started"
|
|
41
|
-
:
|
|
40
|
+
: typeof result === "string"
|
|
41
|
+
? result
|
|
42
|
+
: JSON.stringify(result, null, 2) })) : null] })] })] }));
|
|
42
43
|
}
|
|
@@ -1,6 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export declare const MarkdownText: import("react").NamedExoticComponent<{
|
|
3
|
-
assistant?: boolean;
|
|
4
|
-
replyIndex?: number | undefined;
|
|
5
|
-
replyParts?: readonly UIMessagePart[] | undefined;
|
|
6
|
-
}>;
|
|
1
|
+
export declare const MarkdownText: import("react").NamedExoticComponent<{}>;
|
package/dist/ui/markdown-text.js
CHANGED
|
@@ -1,49 +1,13 @@
|
|
|
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";
|
|
5
4
|
import remarkGfm from "remark-gfm";
|
|
6
|
-
import {
|
|
5
|
+
import { memo, useRef } from "react";
|
|
7
6
|
import { CheckIcon, CopyIcon } from "lucide-react";
|
|
8
7
|
import { CodeBlock } from "./code-block.js";
|
|
9
8
|
import { useCopyToClipboard } from "./use-copy-to-clipboard.js";
|
|
10
9
|
import { cn } from "./utils.js";
|
|
11
|
-
|
|
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
|
-
};
|
|
10
|
+
const MarkdownTextImpl = () => (_jsx(MarkdownTextPrimitive, { remarkPlugins: [remarkGfm], skipHtml: true, className: cn("aui-md"), components: defaultComponents, defer: true }));
|
|
47
11
|
export const MarkdownText = memo(MarkdownTextImpl);
|
|
48
12
|
function MarkdownTable({ className, children, ...props }) {
|
|
49
13
|
const ref = useRef(null);
|
|
@@ -74,7 +38,6 @@ function MarkdownTable({ className, children, ...props }) {
|
|
|
74
38
|
const SyntaxHighlighter = ({ language, code }) => (_jsx(CodeBlock, { title: language || undefined, copyText: code, className: cn("my-3"), children: _jsx("pre", { children: _jsx("code", { children: code }) }) }));
|
|
75
39
|
const NoCodeHeader = () => null;
|
|
76
40
|
const defaultComponents = memoizeMarkdownComponents({
|
|
77
|
-
div: ToolResultSlot,
|
|
78
41
|
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 })),
|
|
79
42
|
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 })),
|
|
80
43
|
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 })),
|
|
@@ -6,8 +6,7 @@ export declare function ThreadListSearch({ value, onValueChange, }: {
|
|
|
6
6
|
value: string;
|
|
7
7
|
onValueChange(value: string): void;
|
|
8
8
|
}): import("react").JSX.Element;
|
|
9
|
-
export declare function ThreadListItem({ disabled, menu,
|
|
9
|
+
export declare function ThreadListItem({ disabled, menu, }: {
|
|
10
10
|
disabled: boolean;
|
|
11
|
-
disabledReason?: string | undefined;
|
|
12
11
|
menu: (beginRename: () => void) => ReactNode;
|
|
13
12
|
}): import("react").JSX.Element;
|
|
@@ -6,7 +6,6 @@ import { ThreadListItemPrimitive, ThreadListPrimitive, useAui, useAuiState, } fr
|
|
|
6
6
|
import { Loader2Icon, MoreHorizontalIcon, PlusIcon, SearchIcon } from "lucide-react";
|
|
7
7
|
import { Input } from "./input.js";
|
|
8
8
|
import { DropdownMenu, DropdownMenuTrigger, DropdownMenuContent } from "./dropdown-menu.js";
|
|
9
|
-
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "./tooltip.js";
|
|
10
9
|
import { cn } from "./utils.js";
|
|
11
10
|
export function ThreadListRoot({ className, ...props }) {
|
|
12
11
|
return (_jsx(ThreadListPrimitive.Root, { "data-slot": "aui_thread-list-root", className: cn("flex flex-col gap-0.5", className), ...props }));
|
|
@@ -17,7 +16,7 @@ export function ThreadListNew(props) {
|
|
|
17
16
|
export function ThreadListSearch({ value, onValueChange, }) {
|
|
18
17
|
return (_jsxs("div", { "data-slot": "aui_thread-list-search", className: cn("relative px-0.5 py-1"), children: [_jsx(SearchIcon, { "data-slot": "aui_thread-list-search-icon", className: cn("text-muted-foreground pointer-events-none absolute start-3 top-1/2 size-4 -translate-y-1/2") }), _jsx(Input, { type: "search", value: value, onChange: (event) => onValueChange(event.target.value), "aria-label": "\u641C\u7D22\u4F1A\u8BDD", placeholder: "\u641C\u7D22\u4F1A\u8BDD", className: cn("border-foreground/10 bg-background h-8 ps-8 text-[13px] md:text-[13px]") })] }));
|
|
19
18
|
}
|
|
20
|
-
export function ThreadListItem({ disabled, menu,
|
|
19
|
+
export function ThreadListItem({ disabled, menu, }) {
|
|
21
20
|
const isRunning = useAuiState((s) => s.threadListItem.isRunning);
|
|
22
21
|
const title = useAuiState((s) => s.threadListItem.title);
|
|
23
22
|
const [isRenaming, setIsRenaming] = useState(false);
|
|
@@ -29,13 +28,10 @@ export function ThreadListItem({ disabled, menu, disabledReason, }) {
|
|
|
29
28
|
triggerRef.current?.focus();
|
|
30
29
|
}
|
|
31
30
|
}, [isRenaming]);
|
|
32
|
-
|
|
31
|
+
return (_jsxs(ThreadListItemPrimitive.Root, { "data-slot": "aui_thread-list-item", className: cn("group data-active:bg-foreground/[0.06] hover:bg-foreground/[0.04] has-data-[state=open]:bg-foreground/[0.04] rounded-control relative flex h-8 shrink-0 items-center transition-colors"), children: [isRenaming ? (_jsx(ThreadListItemRename, { onDone: (focus) => {
|
|
33
32
|
restoreFocus.current = focus;
|
|
34
33
|
setIsRenaming(false);
|
|
35
34
|
} })) : (_jsxs(ThreadListItemPrimitive.Trigger, { ref: triggerRef, disabled: disabled, "data-slot": "aui_thread-list-item-trigger", className: cn("text-muted-foreground group-data-active:text-foreground hover:text-foreground flex h-full min-w-0 flex-1 items-center px-2 text-left text-[13px] transition-colors outline-none group-hover:pe-8 group-has-focus-visible:pe-8 group-has-data-[state=open]:pe-8 group-data-active:pe-8"), children: [isRunning && (_jsx(Loader2Icon, { "aria-hidden": true, className: cn("text-muted-foreground me-1.5 size-3.5 shrink-0 animate-spin") })), _jsx("span", { className: cn("min-w-0 flex-1 truncate"), children: _jsx(ThreadListItemPrimitive.Title, { fallback: "\u65B0\u4F1A\u8BDD" }) })] })), _jsxs(DropdownMenu, { modal: false, children: [_jsx(DropdownMenuTrigger, { asChild: true, children: _jsx("button", { type: "button", "aria-label": `管理 ${title}`, className: cn("text-muted-foreground hover:text-foreground absolute end-1 top-1/2 grid size-6 -translate-y-1/2 place-items-center rounded-sm opacity-0 transition-colors group-hover:opacity-100 group-has-focus-visible:opacity-100 group-data-active:opacity-100 focus-visible:opacity-100 data-[state=open]:opacity-100"), children: _jsx(MoreHorizontalIcon, { className: cn("size-3.5") }) }) }), _jsx(DropdownMenuContent, { side: "right", align: "start", sideOffset: 6, children: menu(() => setIsRenaming(true)) })] })] }));
|
|
36
|
-
if (!disabledReason)
|
|
37
|
-
return item;
|
|
38
|
-
return (_jsx(TooltipProvider, { delayDuration: 300, skipDelayDuration: 0, children: _jsxs(Tooltip, { children: [_jsx(TooltipTrigger, { asChild: true, children: item }), _jsx(TooltipContent, { side: "right", sideOffset: 8, className: cn("max-w-[min(20rem,var(--radix-tooltip-content-available-width))] break-words"), children: disabledReason })] }) }));
|
|
39
35
|
}
|
|
40
36
|
function ThreadListItemRename({ onDone }) {
|
|
41
37
|
const aui = useAui();
|
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.6",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"types": "./dist/index.d.ts",
|
|
6
6
|
"sideEffects": [
|
|
@@ -19,17 +19,16 @@
|
|
|
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.6",
|
|
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",
|
|
27
26
|
"react-remove-scroll-bar": "2.3.8",
|
|
28
27
|
"use-composed-ref": "1.4.0",
|
|
29
28
|
"use-sync-external-store": "1.7.0"
|
|
30
29
|
},
|
|
31
30
|
"peerDependencies": {
|
|
32
|
-
"@nexface/tools": "0.1.21-alpha.
|
|
31
|
+
"@nexface/tools": "0.1.21-alpha.6",
|
|
33
32
|
"react": ">=17",
|
|
34
33
|
"react-dom": ">=17"
|
|
35
34
|
},
|
package/dist/fonts/Inter-OFL.txt
DELETED
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
Copyright 2020 The Inter Project Authors (https://github.com/rsms/inter)
|
|
2
|
-
|
|
3
|
-
This Font Software is licensed under the SIL Open Font License, Version 1.1.
|
|
4
|
-
This license is copied below, and is also available with a FAQ at:
|
|
5
|
-
https://scripts.sil.org/OFL
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
-----------------------------------------------------------
|
|
9
|
-
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
|
|
10
|
-
-----------------------------------------------------------
|
|
11
|
-
|
|
12
|
-
PREAMBLE
|
|
13
|
-
The goals of the Open Font License (OFL) are to stimulate worldwide
|
|
14
|
-
development of collaborative font projects, to support the font creation
|
|
15
|
-
efforts of academic and linguistic communities, and to provide a free and
|
|
16
|
-
open framework in which fonts may be shared and improved in partnership
|
|
17
|
-
with others.
|
|
18
|
-
|
|
19
|
-
The OFL allows the licensed fonts to be used, studied, modified and
|
|
20
|
-
redistributed freely as long as they are not sold by themselves. The
|
|
21
|
-
fonts, including any derivative works, can be bundled, embedded,
|
|
22
|
-
redistributed and/or sold with any software provided that any reserved
|
|
23
|
-
names are not used by derivative works. The fonts and derivatives,
|
|
24
|
-
however, cannot be released under any other type of license. The
|
|
25
|
-
requirement for fonts to remain under this license does not apply
|
|
26
|
-
to any document created using the fonts or their derivatives.
|
|
27
|
-
|
|
28
|
-
DEFINITIONS
|
|
29
|
-
"Font Software" refers to the set of files released by the Copyright
|
|
30
|
-
Holder(s) under this license and clearly marked as such. This may
|
|
31
|
-
include source files, build scripts and documentation.
|
|
32
|
-
|
|
33
|
-
"Reserved Font Name" refers to any names specified as such after the
|
|
34
|
-
copyright statement(s).
|
|
35
|
-
|
|
36
|
-
"Original Version" refers to the collection of Font Software components as
|
|
37
|
-
distributed by the Copyright Holder(s).
|
|
38
|
-
|
|
39
|
-
"Modified Version" refers to any derivative made by adding to, deleting,
|
|
40
|
-
or substituting -- in part or in whole -- any of the components of the
|
|
41
|
-
Original Version, by changing formats or by porting the Font Software to a
|
|
42
|
-
new environment.
|
|
43
|
-
|
|
44
|
-
"Author" refers to any designer, engineer, programmer, technical
|
|
45
|
-
writer or other person who contributed to the Font Software.
|
|
46
|
-
|
|
47
|
-
PERMISSION & CONDITIONS
|
|
48
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
|
49
|
-
a copy of the Font Software, to use, study, copy, merge, embed, modify,
|
|
50
|
-
redistribute, and sell modified and unmodified copies of the Font
|
|
51
|
-
Software, subject to the following conditions:
|
|
52
|
-
|
|
53
|
-
1) Neither the Font Software nor any of its individual components,
|
|
54
|
-
in Original or Modified Versions, may be sold by itself.
|
|
55
|
-
|
|
56
|
-
2) Original or Modified Versions of the Font Software may be bundled,
|
|
57
|
-
redistributed and/or sold with any software, provided that each copy
|
|
58
|
-
contains the above copyright notice and this license. These can be
|
|
59
|
-
included either as stand-alone text files, human-readable headers or
|
|
60
|
-
in the appropriate machine-readable metadata fields within text or
|
|
61
|
-
binary files as long as those fields can be easily viewed by the user.
|
|
62
|
-
|
|
63
|
-
3) No Modified Version of the Font Software may use the Reserved Font
|
|
64
|
-
Name(s) unless explicit written permission is granted by the corresponding
|
|
65
|
-
Copyright Holder. This restriction only applies to the primary font name as
|
|
66
|
-
presented to the users.
|
|
67
|
-
|
|
68
|
-
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
|
|
69
|
-
Software shall not be used to promote, endorse or advertise any
|
|
70
|
-
Modified Version, except to acknowledge the contribution(s) of the
|
|
71
|
-
Copyright Holder(s) and the Author(s) or with their explicit written
|
|
72
|
-
permission.
|
|
73
|
-
|
|
74
|
-
5) The Font Software, modified or unmodified, in part or in whole,
|
|
75
|
-
must be distributed entirely under this license, and must not be
|
|
76
|
-
distributed under any other license. The requirement for fonts to
|
|
77
|
-
remain under this license does not apply to any document created
|
|
78
|
-
using the Font Software.
|
|
79
|
-
|
|
80
|
-
TERMINATION
|
|
81
|
-
This license becomes null and void if any of the above conditions are
|
|
82
|
-
not met.
|
|
83
|
-
|
|
84
|
-
DISCLAIMER
|
|
85
|
-
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
86
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
|
|
87
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
|
88
|
-
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
|
|
89
|
-
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
90
|
-
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
|
|
91
|
-
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
92
|
-
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
|
|
93
|
-
OTHER DEALINGS IN THE FONT SOFTWARE.
|
|
Binary file
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
export declare class HistoryError extends Error {
|
|
2
|
-
readonly code: string;
|
|
3
|
-
constructor(code: string, message: string);
|
|
4
|
-
}
|
|
5
|
-
export declare class SessionCoordinator {
|
|
6
|
-
private readonly held;
|
|
7
|
-
private readonly acquiring;
|
|
8
|
-
private channel?;
|
|
9
|
-
private closed;
|
|
10
|
-
private watchers;
|
|
11
|
-
private notifyLocal?;
|
|
12
|
-
connect(notify: () => void): void;
|
|
13
|
-
watch(): () => void;
|
|
14
|
-
get visible(): boolean;
|
|
15
|
-
private manager;
|
|
16
|
-
owns(id: string): boolean;
|
|
17
|
-
acquire(id: string): Promise<boolean>;
|
|
18
|
-
release(id: string): void;
|
|
19
|
-
write<T>(work: () => T | Promise<T>): Promise<T>;
|
|
20
|
-
occupied(): Promise<Set<string>>;
|
|
21
|
-
notify(): void;
|
|
22
|
-
close(): void;
|
|
23
|
-
}
|
|
@@ -1,139 +0,0 @@
|
|
|
1
|
-
const prefix = "nexface:chat:v4:";
|
|
2
|
-
const listeners = new Set();
|
|
3
|
-
export class HistoryError extends Error {
|
|
4
|
-
code;
|
|
5
|
-
constructor(code, message) {
|
|
6
|
-
super(message);
|
|
7
|
-
this.code = code;
|
|
8
|
-
this.name = "HistoryError";
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
export class SessionCoordinator {
|
|
12
|
-
held = new Map();
|
|
13
|
-
acquiring = new Map();
|
|
14
|
-
channel;
|
|
15
|
-
closed = false;
|
|
16
|
-
watchers = 0;
|
|
17
|
-
notifyLocal;
|
|
18
|
-
connect(notify) {
|
|
19
|
-
this.closed = false;
|
|
20
|
-
if (this.notifyLocal)
|
|
21
|
-
listeners.delete(this.notifyLocal);
|
|
22
|
-
this.channel?.close();
|
|
23
|
-
delete this.channel;
|
|
24
|
-
this.notifyLocal = notify;
|
|
25
|
-
listeners.add(notify);
|
|
26
|
-
if (typeof BroadcastChannel !== "undefined") {
|
|
27
|
-
this.channel = new BroadcastChannel(`${prefix}events`);
|
|
28
|
-
this.channel.onmessage = () => notify();
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
watch() {
|
|
32
|
-
this.watchers++;
|
|
33
|
-
this.notifyLocal?.();
|
|
34
|
-
return () => {
|
|
35
|
-
this.watchers--;
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
get visible() {
|
|
39
|
-
return this.watchers > 0;
|
|
40
|
-
}
|
|
41
|
-
manager() {
|
|
42
|
-
if (!globalThis.navigator?.locks)
|
|
43
|
-
throw new HistoryError("CHAT_STORAGE_UNAVAILABLE", "Chat history requires the Web Locks API in a secure browser context.");
|
|
44
|
-
return navigator.locks;
|
|
45
|
-
}
|
|
46
|
-
owns(id) {
|
|
47
|
-
return this.held.has(id);
|
|
48
|
-
}
|
|
49
|
-
acquire(id) {
|
|
50
|
-
if (this.closed)
|
|
51
|
-
return Promise.resolve(false);
|
|
52
|
-
if (this.owns(id))
|
|
53
|
-
return Promise.resolve(true);
|
|
54
|
-
const pending = this.acquiring.get(id);
|
|
55
|
-
if (pending)
|
|
56
|
-
return pending;
|
|
57
|
-
let resolve;
|
|
58
|
-
let reject;
|
|
59
|
-
const result = new Promise((yes, no) => {
|
|
60
|
-
resolve = yes;
|
|
61
|
-
reject = no;
|
|
62
|
-
});
|
|
63
|
-
this.acquiring.set(id, result);
|
|
64
|
-
let granted = false;
|
|
65
|
-
try {
|
|
66
|
-
void this.manager()
|
|
67
|
-
.request(`${prefix}session:${id}`, { ifAvailable: true }, async (lock) => {
|
|
68
|
-
if (!lock || this.closed) {
|
|
69
|
-
this.acquiring.delete(id);
|
|
70
|
-
resolve(false);
|
|
71
|
-
return;
|
|
72
|
-
}
|
|
73
|
-
await new Promise((release) => {
|
|
74
|
-
granted = true;
|
|
75
|
-
this.held.set(id, release);
|
|
76
|
-
this.acquiring.delete(id);
|
|
77
|
-
resolve(true);
|
|
78
|
-
this.notify();
|
|
79
|
-
});
|
|
80
|
-
})
|
|
81
|
-
.catch((cause) => {
|
|
82
|
-
this.acquiring.delete(id);
|
|
83
|
-
reject(cause);
|
|
84
|
-
})
|
|
85
|
-
.finally(() => {
|
|
86
|
-
if (granted)
|
|
87
|
-
setTimeout(() => this.notify(), 0);
|
|
88
|
-
});
|
|
89
|
-
}
|
|
90
|
-
catch (cause) {
|
|
91
|
-
this.acquiring.delete(id);
|
|
92
|
-
reject(cause);
|
|
93
|
-
}
|
|
94
|
-
return result;
|
|
95
|
-
}
|
|
96
|
-
release(id) {
|
|
97
|
-
const release = this.held.get(id);
|
|
98
|
-
if (!release)
|
|
99
|
-
return;
|
|
100
|
-
this.held.delete(id);
|
|
101
|
-
release();
|
|
102
|
-
// The request completion above notifies after actual browser lock release.
|
|
103
|
-
}
|
|
104
|
-
write(work) {
|
|
105
|
-
return this.manager()
|
|
106
|
-
.request(`${prefix}storage`, () => {
|
|
107
|
-
if (this.closed)
|
|
108
|
-
throw new HistoryError("CHAT_STORAGE_UNAVAILABLE", "The chat history owner has been closed.");
|
|
109
|
-
return work();
|
|
110
|
-
})
|
|
111
|
-
.then((value) => value);
|
|
112
|
-
}
|
|
113
|
-
async occupied() {
|
|
114
|
-
const state = await this.manager().query();
|
|
115
|
-
return new Set((state.held ?? [])
|
|
116
|
-
.flatMap((lock) => {
|
|
117
|
-
const name = lock.name ?? "";
|
|
118
|
-
return name.startsWith(`${prefix}session:`)
|
|
119
|
-
? [name.slice(`${prefix}session:`.length)]
|
|
120
|
-
: [];
|
|
121
|
-
})
|
|
122
|
-
.filter((id) => !this.owns(id)));
|
|
123
|
-
}
|
|
124
|
-
notify() {
|
|
125
|
-
for (const listener of listeners)
|
|
126
|
-
listener();
|
|
127
|
-
this.channel?.postMessage({ type: "changed" });
|
|
128
|
-
}
|
|
129
|
-
close() {
|
|
130
|
-
this.closed = true;
|
|
131
|
-
if (this.notifyLocal)
|
|
132
|
-
listeners.delete(this.notifyLocal);
|
|
133
|
-
delete this.notifyLocal;
|
|
134
|
-
this.channel?.close();
|
|
135
|
-
delete this.channel;
|
|
136
|
-
for (const id of this.held.keys())
|
|
137
|
-
this.release(id);
|
|
138
|
-
}
|
|
139
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { type StoredSession } from "./storage.js";
|
|
2
|
-
import { HistoryError, SessionCoordinator } from "./session-coordinator.js";
|
|
3
|
-
export declare const historyMetaKey = "nexface:chat:sessions:v4:meta";
|
|
4
|
-
export declare const historySessionKey: (id: string) => string;
|
|
5
|
-
declare const locked: () => HistoryError;
|
|
6
|
-
export { locked as sessionLockedError };
|
|
7
|
-
export declare class SessionHistory {
|
|
8
|
-
readonly coordinator: SessionCoordinator;
|
|
9
|
-
private generation?;
|
|
10
|
-
private readonly seen;
|
|
11
|
-
private readonly reusable;
|
|
12
|
-
private readonly observed;
|
|
13
|
-
private readonly opened;
|
|
14
|
-
private readonly fresh;
|
|
15
|
-
private readonly baselines;
|
|
16
|
-
private initialized?;
|
|
17
|
-
onEvict?: (count: number) => void;
|
|
18
|
-
initialize(): Promise<void>;
|
|
19
|
-
list(): StoredSession[];
|
|
20
|
-
unchangedSinceSaved(id: string): boolean;
|
|
21
|
-
private snapshot;
|
|
22
|
-
open(id: string, fresh?: boolean): Promise<StoredSession | undefined>;
|
|
23
|
-
isSaved(session: StoredSession): boolean;
|
|
24
|
-
canReuse(id: string): boolean;
|
|
25
|
-
adoptRestored(session: StoredSession): void;
|
|
26
|
-
private commit;
|
|
27
|
-
save(session: StoredSession): Promise<void>;
|
|
28
|
-
remove(ids: string[], clearAll?: boolean): Promise<void>;
|
|
29
|
-
}
|