@nexface/chat 0.1.7 → 0.1.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.
@@ -1,7 +1,7 @@
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, ErrorPrimitive, MessagePrimitive } from "@assistant-ui/react";
4
+ import { ActionBarPrimitive, ErrorPrimitive, MessagePrimitive, useAuiState } from "@assistant-ui/react";
5
5
  import { AssistantActionBar } from "./action-bar.js";
6
6
  export function UserMessage({ children, attachments, actions }) {
7
7
  return (_jsxs(MessagePrimitive.Root, { "data-role": "user", "data-slot": "aui_user-message-root", className: cn("animate-in fade-in slide-in-from-bottom-1 mx-auto flex w-full max-w-(--nxf-thread-max-width) flex-col items-end duration-150"), children: [_jsx("div", { className: cn("w-full has-[.aui-attachment-root]:mb-2"), children: attachments }), _jsxs("div", { className: cn("relative max-w-[80%]"), children: [_jsx("div", { className: cn("peer bg-muted rounded-thread px-4 py-2 text-[15px] wrap-break-word empty:hidden"), children: children }), _jsx(ActionBarPrimitive.Root, { hideWhenRunning: true, autohide: "not-last", className: cn("absolute start-0 top-1/2 -translate-x-full -translate-y-1/2 pe-1.5 peer-empty:hidden"), children: actions })] })] }));
@@ -10,6 +10,9 @@ export function AssistantMessage({ children }) {
10
10
  return (_jsxs(MessagePrimitive.Root, { "data-role": "assistant", "data-slot": "aui_assistant-message-root", className: cn("animate-in fade-in slide-in-from-bottom-1 mx-auto w-full max-w-(--nxf-thread-max-width) duration-150"), children: [_jsxs("div", { "data-slot": "aui_assistant-message-content", className: cn("text-[15px] leading-relaxed wrap-break-word"), children: [children, _jsx(MessageError, {})] }), _jsx("div", { className: cn("mt-2 flex items-center gap-1.5 empty:hidden"), children: _jsx(AssistantActionBar, {}) })] }));
11
11
  }
12
12
  function MessageError() {
13
- return _jsx(MessagePrimitive.Error, { children: _jsx(ErrorPrimitive.Root, { className: cn("mt-2 border-l-2 pl-3 text-[13px] border-destructive/60 text-destructive"), children: _jsx(ErrorPrimitive.Message, { className: cn("line-clamp-2") }) }) });
13
+ const cancelled = useAuiState((s) => s.message.status?.type === "incomplete" && s.message.status.reason === "cancelled");
14
+ if (cancelled)
15
+ return _jsx("p", { role: "status", className: cn("mt-2 text-[13px] text-muted-foreground"), children: "Stopped" });
16
+ return _jsx(MessagePrimitive.Error, { children: _jsx(ErrorPrimitive.Root, { role: "alert", className: cn("mt-2 border-l-2 pl-3 text-[13px] border-destructive/60 text-destructive"), children: _jsx(ErrorPrimitive.Message, { className: cn("line-clamp-2") }) }) });
14
17
  }
15
18
  //# sourceMappingURL=messages.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"messages.js","sourceRoot":"","sources":["../../../src/ui/home-demo/messages.tsx"],"names":[],"mappings":";AAAA,oGAAoG;AACpG,OAAO,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AAEjC,OAAO,EAAE,kBAAkB,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAC3F,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AACrD,MAAM,UAAU,WAAW,CAAC,EAAE,QAAQ,EAAE,WAAW,EAAE,OAAO,EAAuE;IACjI,OAAO,CACL,MAAC,gBAAgB,CAAC,IAAI,iBACV,MAAM,eAAW,uBAAuB,EAClD,SAAS,EAAE,EAAE,CAAC,8HAA8H,CAAC,aAE7I,cAAK,SAAS,EAAE,EAAE,CAAC,wCAAwC,CAAC,YACzD,WAAW,GACR,EACN,eAAK,SAAS,EAAE,EAAE,CAAC,sBAAsB,CAAC,aACxC,cAAK,SAAS,EAAE,EAAE,CAAC,iFAAiF,CAAC,YAClG,QAAQ,GACL,EACN,KAAC,kBAAkB,CAAC,IAAI,IACtB,eAAe,QACf,QAAQ,EAAC,UAAU,EACnB,SAAS,EAAE,EAAE,CAAC,sFAAsF,CAAC,YAEpG,OAAO,GACgB,IACtB,IACgB,CACzB,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,EAAE,QAAQ,EAA2B;IACpE,OAAO,CACL,MAAC,gBAAgB,CAAC,IAAI,iBACV,WAAW,eAAW,4BAA4B,EAC5D,SAAS,EAAE,EAAE,CAAC,sGAAsG,CAAC,aAErH,4BAAe,+BAA+B,EAAC,SAAS,EAAE,EAAE,CAAC,6CAA6C,CAAC,aACxG,QAAQ,EACT,KAAC,YAAY,KAAG,IACZ,EACN,cAAK,SAAS,EAAE,EAAE,CAAC,6CAA6C,CAAC,YAC/D,KAAC,kBAAkB,KAAG,GAClB,IACgB,CACzB,CAAC;AACJ,CAAC;AAED,SAAS,YAAY;IACnB,OAAO,KAAC,gBAAgB,CAAC,KAAK,cAAC,KAAC,cAAc,CAAC,IAAI,IAAC,SAAS,EAAE,EAAE,CAAC,yEAAyE,CAAC,YAAE,KAAC,cAAc,CAAC,OAAO,IAAC,SAAS,EAAE,EAAE,CAAC,cAAc,CAAC,GAAI,GAAsB,GAAyB,CAAC;AACzP,CAAC","sourcesContent":["// Adapted from the pinned official homepage Demo; see vendor/assistant-ui/home-demo/ADAPTATIONS.md.\nimport { cn } from \"../utils.js\";\nimport type { ReactNode } from \"react\";\nimport { ActionBarPrimitive, ErrorPrimitive, MessagePrimitive } from \"@assistant-ui/react\";\nimport { AssistantActionBar } from \"./action-bar.js\";\nexport function UserMessage({ children, attachments, actions }: { children: ReactNode; attachments: ReactNode; actions: ReactNode }): ReactNode {\n return (\n <MessagePrimitive.Root\n data-role=\"user\" data-slot=\"aui_user-message-root\"\n className={cn(\"animate-in fade-in slide-in-from-bottom-1 mx-auto flex w-full max-w-(--nxf-thread-max-width) flex-col items-end duration-150\")}\n >\n <div className={cn(\"w-full has-[.aui-attachment-root]:mb-2\")} >\n {attachments}\n </div>\n <div className={cn(\"relative max-w-[80%]\")} >\n <div className={cn(\"peer bg-muted rounded-thread px-4 py-2 text-[15px] wrap-break-word empty:hidden\")} >\n {children}\n </div>\n <ActionBarPrimitive.Root\n hideWhenRunning\n autohide=\"not-last\"\n className={cn(\"absolute start-0 top-1/2 -translate-x-full -translate-y-1/2 pe-1.5 peer-empty:hidden\")}\n >\n {actions}\n </ActionBarPrimitive.Root>\n </div>\n </MessagePrimitive.Root>\n );\n}\n\nexport function AssistantMessage({ children }: { children: ReactNode }): ReactNode {\n return (\n <MessagePrimitive.Root\n data-role=\"assistant\" data-slot=\"aui_assistant-message-root\"\n className={cn(\"animate-in fade-in slide-in-from-bottom-1 mx-auto w-full max-w-(--nxf-thread-max-width) duration-150\")}\n >\n <div data-slot=\"aui_assistant-message-content\" className={cn(\"text-[15px] leading-relaxed wrap-break-word\")} >\n {children}\n <MessageError />\n </div>\n <div className={cn(\"mt-2 flex items-center gap-1.5 empty:hidden\")} >\n <AssistantActionBar />\n </div>\n </MessagePrimitive.Root>\n );\n}\n\nfunction MessageError() {\n return <MessagePrimitive.Error><ErrorPrimitive.Root className={cn(\"mt-2 border-l-2 pl-3 text-[13px] border-destructive/60 text-destructive\")}><ErrorPrimitive.Message className={cn(\"line-clamp-2\")} /></ErrorPrimitive.Root></MessagePrimitive.Error>;\n}\n"]}
1
+ {"version":3,"file":"messages.js","sourceRoot":"","sources":["../../../src/ui/home-demo/messages.tsx"],"names":[],"mappings":";AAAA,oGAAoG;AACpG,OAAO,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AAEjC,OAAO,EAAE,kBAAkB,EAAE,cAAc,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACxG,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AACrD,MAAM,UAAU,WAAW,CAAC,EAAE,QAAQ,EAAE,WAAW,EAAE,OAAO,EAAuE;IACjI,OAAO,CACL,MAAC,gBAAgB,CAAC,IAAI,iBACV,MAAM,eAAW,uBAAuB,EAClD,SAAS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AAC,YAAE,KAAC,cAAc,CAAC,OAAO,IAAC,SAAS,EAAE,EAAE,CAAC,cAAc,CAAC,GAAI,GAAsB,GAAyB,CAAC;AACtQ,CAAC","sourcesContent":["// Adapted from the pinned official homepage Demo; see vendor/assistant-ui/home-demo/ADAPTATIONS.md.\nimport { cn } from \"../utils.js\";\nimport type { ReactNode } from \"react\";\nimport { ActionBarPrimitive, ErrorPrimitive, MessagePrimitive, useAuiState } from \"@assistant-ui/react\";\nimport { AssistantActionBar } from \"./action-bar.js\";\nexport function UserMessage({ children, attachments, actions }: { children: ReactNode; attachments: ReactNode; actions: ReactNode }): ReactNode {\n return (\n <MessagePrimitive.Root\n data-role=\"user\" data-slot=\"aui_user-message-root\"\n className={cn(\"animate-in fade-in slide-in-from-bottom-1 mx-auto flex w-full max-w-(--nxf-thread-max-width) flex-col items-end duration-150\")}\n >\n <div className={cn(\"w-full has-[.aui-attachment-root]:mb-2\")} >\n {attachments}\n </div>\n <div className={cn(\"relative max-w-[80%]\")} >\n <div className={cn(\"peer bg-muted rounded-thread px-4 py-2 text-[15px] wrap-break-word empty:hidden\")} >\n {children}\n </div>\n <ActionBarPrimitive.Root\n hideWhenRunning\n autohide=\"not-last\"\n className={cn(\"absolute start-0 top-1/2 -translate-x-full -translate-y-1/2 pe-1.5 peer-empty:hidden\")}\n >\n {actions}\n </ActionBarPrimitive.Root>\n </div>\n </MessagePrimitive.Root>\n );\n}\n\nexport function AssistantMessage({ children }: { children: ReactNode }): ReactNode {\n return (\n <MessagePrimitive.Root\n data-role=\"assistant\" data-slot=\"aui_assistant-message-root\"\n className={cn(\"animate-in fade-in slide-in-from-bottom-1 mx-auto w-full max-w-(--nxf-thread-max-width) duration-150\")}\n >\n <div data-slot=\"aui_assistant-message-content\" className={cn(\"text-[15px] leading-relaxed wrap-break-word\")} >\n {children}\n <MessageError />\n </div>\n <div className={cn(\"mt-2 flex items-center gap-1.5 empty:hidden\")} >\n <AssistantActionBar />\n </div>\n </MessagePrimitive.Root>\n );\n}\n\nfunction MessageError() {\n const cancelled = useAuiState((s) => s.message.status?.type === \"incomplete\" && s.message.status.reason === \"cancelled\");\n if (cancelled) return <p role=\"status\" className={cn(\"mt-2 text-[13px] text-muted-foreground\")}>Stopped</p>;\n return <MessagePrimitive.Error><ErrorPrimitive.Root role=\"alert\" className={cn(\"mt-2 border-l-2 pl-3 text-[13px] border-destructive/60 text-destructive\")}><ErrorPrimitive.Message className={cn(\"line-clamp-2\")} /></ErrorPrimitive.Root></MessagePrimitive.Error>;\n}\n"]}
@@ -1,3 +1,4 @@
1
+ import type { UIMessagePart } from "../../messages.js";
1
2
  import type { ToolCallMessagePartProps } from "@assistant-ui/react";
2
3
  import type { ReactNode } from "react";
3
4
  export declare const disclosureContentClass = "border-foreground/10 ms-[5px] border-s ps-4";
@@ -6,6 +7,7 @@ export declare function DisclosureTrigger({ live, label, detail, }: {
6
7
  label: string;
7
8
  detail?: string;
8
9
  }): ReactNode;
9
- export declare function ToolCall({ toolName, args, argsText, result, status, isError, showDetails }: ToolCallMessagePartProps & {
10
+ export declare function ToolCall({ toolName, args, argsText, result, status, isError, showDetails, presentation }: ToolCallMessagePartProps & {
10
11
  showDetails: boolean;
12
+ presentation?: UIMessagePart | undefined;
11
13
  }): ReactNode;
@@ -9,12 +9,16 @@ export const disclosureContentClass = "border-foreground/10 ms-[5px] border-s ps
9
9
  export function DisclosureTrigger({ live, label, detail, }) {
10
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-open/trigger:rotate-90 group-data-panel-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] })) })] }));
11
11
  }
12
- export function ToolCall({ toolName, args, argsText, result, status, isError, showDetails }) {
13
- const live = status?.type === "running";
12
+ export function ToolCall({ toolName, args, argsText, result, status, isError, showDetails, presentation }) {
13
+ const tool = presentation?.type === "tool" ? presentation : undefined;
14
+ const error = tool?.error;
15
+ const label = tool?.toolState === "unknown" ? "Result unknown" : tool?.toolState === "rejected" ? "Rejected" : tool?.toolState === "cancelled" ? "Stopped" : tool?.toolState === "not_started" ? "Not started" : tool?.toolState === "failed" || isError ? "Failed" : undefined;
16
+ const live = !label && status?.type === "running";
14
17
  const duration = useToolDuration(live);
15
- const line = _jsx(TraceLine, { live: live, label: isError ? "failed" : live ? "running" : "ran", detail: toolName, ...(duration === null ? {} : { meta: formatDuration(duration) }) });
18
+ const line = _jsx(TraceLine, { live: live, label: label ?? (live ? "running" : "ran"), detail: toolName, ...(duration === null ? {} : { meta: formatDuration(duration) }) });
19
+ const reason = error && !error.parentErrorId && error.scope === "tool" && error.execution !== "unknown" ? _jsx("p", { role: "alert", className: cn("mt-2 border-l-2 pl-3 text-[13px] border-destructive/60 text-destructive"), children: error.userMessage }) : null;
16
20
  if (!showDetails)
17
- return line;
18
- return _jsxs(_Fragment, { children: [line, _jsxs(Collapsible, { children: [_jsx(DisclosureTrigger, { live: false, label: "\u64CD\u4F5C\u660E\u7EC6" }), _jsxs(CollapsibleContent, { className: cn(disclosureContentClass), children: [_jsx("pre", { className: cn("overflow-x-auto text-xs"), "aria-label": "\u64CD\u4F5C\u8F93\u5165", children: argsText || JSON.stringify(args, null, 2) }), result !== undefined ? _jsx("pre", { className: cn("overflow-x-auto text-xs"), "aria-label": "\u64CD\u4F5C\u8F93\u51FA", children: typeof result === "string" ? result : JSON.stringify(result, null, 2) }) : null] })] })] });
21
+ return _jsxs(_Fragment, { children: [line, reason] });
22
+ return _jsxs(_Fragment, { children: [line, reason, _jsxs(Collapsible, { children: [_jsx(DisclosureTrigger, { live: false, label: "\u64CD\u4F5C\u660E\u7EC6" }), _jsxs(CollapsibleContent, { className: cn(disclosureContentClass), children: [_jsx("pre", { className: cn("overflow-x-auto text-xs"), "aria-label": "\u64CD\u4F5C\u8F93\u5165", children: argsText || JSON.stringify(args, null, 2) }), result !== undefined ? _jsx("pre", { className: cn("overflow-x-auto text-xs"), "aria-label": "\u64CD\u4F5C\u8F93\u51FA", children: error ? error.userMessage : tool?.toolState === "cancelled" ? "Stopped" : tool?.toolState === "rejected" ? "Rejected" : tool?.toolState === "not_started" ? "Not started" : typeof result === "string" ? result : JSON.stringify(result, null, 2) }) : null] })] })] });
19
23
  }
20
24
  //# sourceMappingURL=trace.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"trace.js","sourceRoot":"","sources":["../../../src/ui/home-demo/trace.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AACjC,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACpE,YAAY,CAAC;AAIb,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,EACL,SAAS,EACT,WAAW,EACX,eAAe,EACf,cAAc,GACf,MAAM,iBAAiB,CAAC;AAEzB,MAAM,CAAC,MAAM,sBAAsB,GACjC,6CAA6C,CAAC;AAEhD,MAAM,UAAU,iBAAiB,CAAC,EAChC,IAAI,EACJ,KAAK,EACL,MAAM,GAKP;IACC,OAAO,CACL,MAAC,kBAAkB,iBAAW,oBAAoB,EAAC,SAAS,EAAE,EAAE,CAAC,4JAA4J,CAAC,aAC5N,KAAC,WAAW,IACV,IAAI,EAAE,IAAI,EACV,SAAS,EAAE,EAAE,CAAC,2EAA2E,CAAC,GAC1F,EACF,eAAM,SAAS,EAAE,EAAE,CAAC,8FAA8F,CAAC,YAChH,IAAI,CAAC,CAAC,CAAC,CACN,MAAC,YAAY,eACV,KAAK,EACL,MA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AAC,CAAC,cAAK,SAAS,EAAE,EAAE,CAAC,yBAAyB,CAAC,gBAAa,0BAAM,YAAE,OAAO,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,GAAO,CAAC,CAAC,CAAC,IAAI,IAC1J,IAAc,IAAG,CAAC;AACzC,CAAC","sourcesContent":["import { cn } from \"../utils.js\";\nimport { Collapsible, CollapsibleContent } from \"../collapsible.js\";\n\"use client\";\n\nimport type { ToolCallMessagePartProps } from \"@assistant-ui/react\";\nimport type { ReactNode } from \"react\";\nimport { ShimmerLabel } from \"./surfaces.js\";\nimport { CollapsibleTrigger } from \"../collapsible.js\";\nimport {\n TraceLine,\n TraceMarker,\n useToolDuration,\n formatDuration,\n} from \"./trace-line.js\";\n\nexport const disclosureContentClass =\n \"border-foreground/10 ms-[5px] border-s ps-4\";\n\nexport function DisclosureTrigger({\n live,\n label,\n detail,\n}: {\n live: boolean;\n label: string;\n detail?: string;\n}): ReactNode {\n return (\n <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\")}>\n <TraceMarker\n live={live}\n className={cn(\"group-data-open/trigger:rotate-90 group-data-panel-open/trigger:rotate-90\")}\n />\n <span className={cn(\"text-muted-foreground group-hover/trigger:text-foreground min-w-0 truncate transition-colors\")}>\n {live ? (\n <ShimmerLabel>\n {label}\n {detail ? ` ${detail}` : null}\n </ShimmerLabel>\n ) : (\n <>\n {label}\n {detail ? ` ${detail}` : null}\n </>\n )}\n </span>\n </CollapsibleTrigger>\n );\n}\n\nexport function ToolCall({ toolName, args, argsText, result, status, isError, showDetails }: ToolCallMessagePartProps & { showDetails: boolean }): ReactNode {\n const live = status?.type === \"running\";\n const duration = useToolDuration(live);\n const line = <TraceLine live={live} label={isError ? \"failed\" : live ? \"running\" : \"ran\"} detail={toolName} {...(duration === null ? {} : { meta: formatDuration(duration) })} />;\n if (!showDetails) return line;\n return <>{line}<Collapsible><DisclosureTrigger live={false} label=\"操作明细\" /><CollapsibleContent className={cn(disclosureContentClass)}>\n <pre className={cn(\"overflow-x-auto text-xs\")} aria-label=\"操作输入\">{argsText || JSON.stringify(args, null, 2)}</pre>\n {result !== undefined ? <pre className={cn(\"overflow-x-auto text-xs\")} aria-label=\"操作输出\">{typeof result === \"string\" ? result : JSON.stringify(result, null, 2)}</pre> : null}\n </CollapsibleContent></Collapsible></>;\n}\n"]}
1
+ {"version":3,"file":"trace.js","sourceRoot":"","sources":["../../../src/ui/home-demo/trace.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AACjC,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACpE,YAAY,CAAC;AAIb,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,EACL,SAAS,EACT,WAAW,EACX,eAAe,EACf,cAAc,GACf,MAAM,iBAAiB,CAAC;AAEzB,MAAM,CAAC,MAAM,sBAAsB,GACjC,6CAA6C,CAAC;AAEhD,MAAM,UAAU,iBAAiB,CAAC,EAChC,IAAI,EACJ,KAAK,EACL,MAAM,GAKP;IACC,OAAO,CACL,MAAC,kBAAkB,iBAAW,oBAAoB,EAAC,SAAS,EAAE,EAAE,CAAC,4JAA4J,CAAC,aAC5N,KAAC,WAAW,IACV,IAAI,EAAE,IAAI,EACV,SAAS,EAAE,EAAE,CAAC,2EAA2E,CAAC,GAC1F,EACF,eAAM,SAAS,EAAE,EAAE,CAAC,8FAA8F,CAAC,YAChH,IAAI,CAAC,CAAC,CAAC,CACN,MAAC,YAAY,eACV,KAAK,EACL,MAAM,CAAC,CAAC,CAAC,IAAI,MAAM,EAA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,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,GAAO,CAAC,CAAC,CAAC,IAAI,IACtU,IAAc,IAAG,CAAC;AACzC,CAAC","sourcesContent":["import type { UIMessagePart } from \"../../messages.js\";\nimport { cn } from \"../utils.js\";\nimport { Collapsible, CollapsibleContent } from \"../collapsible.js\";\n\"use client\";\n\nimport type { ToolCallMessagePartProps } from \"@assistant-ui/react\";\nimport type { ReactNode } from \"react\";\nimport { ShimmerLabel } from \"./surfaces.js\";\nimport { CollapsibleTrigger } from \"../collapsible.js\";\nimport {\n TraceLine,\n TraceMarker,\n useToolDuration,\n formatDuration,\n} from \"./trace-line.js\";\n\nexport const disclosureContentClass =\n \"border-foreground/10 ms-[5px] border-s ps-4\";\n\nexport function DisclosureTrigger({\n live,\n label,\n detail,\n}: {\n live: boolean;\n label: string;\n detail?: string;\n}): ReactNode {\n return (\n <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\")}>\n <TraceMarker\n live={live}\n className={cn(\"group-data-open/trigger:rotate-90 group-data-panel-open/trigger:rotate-90\")}\n />\n <span className={cn(\"text-muted-foreground group-hover/trigger:text-foreground min-w-0 truncate transition-colors\")}>\n {live ? (\n <ShimmerLabel>\n {label}\n {detail ? ` ${detail}` : null}\n </ShimmerLabel>\n ) : (\n <>\n {label}\n {detail ? ` ${detail}` : null}\n </>\n )}\n </span>\n </CollapsibleTrigger>\n );\n}\n\nexport function ToolCall({ toolName, args, argsText, result, status, isError, showDetails, presentation }: ToolCallMessagePartProps & { showDetails: boolean; presentation?: UIMessagePart | undefined }): ReactNode {\n const tool = presentation?.type === \"tool\" ? presentation : undefined;\n const error = tool?.error;\n const label = tool?.toolState === \"unknown\" ? \"Result unknown\" : tool?.toolState === \"rejected\" ? \"Rejected\" : tool?.toolState === \"cancelled\" ? \"Stopped\" : tool?.toolState === \"not_started\" ? \"Not started\" : tool?.toolState === \"failed\" || isError ? \"Failed\" : undefined;\n const live = !label && status?.type === \"running\";\n const duration = useToolDuration(live);\n const line = <TraceLine live={live} label={label ?? (live ? \"running\" : \"ran\")} detail={toolName} {...(duration === null ? {} : { meta: formatDuration(duration) })} />;\n const reason = error && !error.parentErrorId && error.scope === \"tool\" && error.execution !== \"unknown\" ? <p role=\"alert\" className={cn(\"mt-2 border-l-2 pl-3 text-[13px] border-destructive/60 text-destructive\")}>{error.userMessage}</p> : null;\n if (!showDetails) return <>{line}{reason}</>;\n return <>{line}{reason}<Collapsible><DisclosureTrigger live={false} label=\"操作明细\" /><CollapsibleContent className={cn(disclosureContentClass)}>\n <pre className={cn(\"overflow-x-auto text-xs\")} aria-label=\"操作输入\">{argsText || JSON.stringify(args, null, 2)}</pre>\n {result !== undefined ? <pre className={cn(\"overflow-x-auto text-xs\")} aria-label=\"操作输出\">{error ? error.userMessage : tool?.toolState === \"cancelled\" ? \"Stopped\" : tool?.toolState === \"rejected\" ? \"Rejected\" : tool?.toolState === \"not_started\" ? \"Not started\" : typeof result === \"string\" ? result : JSON.stringify(result, null, 2)}</pre> : null}\n </CollapsibleContent></Collapsible></>;\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nexface/chat",
3
- "version": "0.1.7",
3
+ "version": "0.1.8",
4
4
  "type": "module",
5
5
  "engines": {
6
6
  "node": ">=22.19.0"
@@ -17,7 +17,7 @@
17
17
  "@assistant-ui/react": "0.15.21",
18
18
  "@assistant-ui/react-markdown": "0.14.16",
19
19
  "@base-ui/react": "1.8.0",
20
- "@nexface/agent": "0.1.7",
20
+ "@nexface/agent": "0.1.8",
21
21
  "class-variance-authority": "0.7.1",
22
22
  "clsx": "2.1.1",
23
23
  "fast-json-patch": "3.1.1",
@@ -27,7 +27,7 @@
27
27
  "tailwind-merge": "3.6.0"
28
28
  },
29
29
  "peerDependencies": {
30
- "@nexface/tools": "0.1.7",
30
+ "@nexface/tools": "0.1.8",
31
31
  "react": ">=18",
32
32
  "react-dom": ">=18"
33
33
  },