@nexface/chat 0.1.20 → 0.1.21-alpha.0
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/assistant-components.d.ts +2 -1
- package/dist/assistant-components.js +22 -10
- package/dist/assistant-runtime.js +1 -0
- package/dist/client.d.ts +3 -1
- package/dist/client.js +136 -42
- package/dist/config.d.ts +1 -1
- package/dist/default-chat.d.ts +1 -1
- package/dist/default-chat.js +26370 -26035
- package/dist/fonts/Inter-OFL.txt +93 -0
- package/dist/fonts/inter-medium.ttf +0 -0
- package/dist/protocol-messages.js +15 -16
- package/dist/protocol-response.js +10 -3
- package/dist/react.d.ts +7 -1
- package/dist/react.js +124 -12
- package/dist/shared/errors.d.ts +1 -1
- package/dist/shared/errors.js +2 -0
- package/dist/shared/tool-presentation.d.ts +17 -0
- package/dist/shared/tool-presentation.js +5 -0
- package/dist/shared/tool-proxy.d.ts +6 -0
- package/dist/shared/tool-proxy.js +25 -0
- package/dist/storage.d.ts +1 -0
- package/dist/storage.js +4 -1
- package/dist/styles.css +1491 -676
- package/dist/tool-confirmation-card.d.ts +5 -0
- package/dist/tool-confirmation-card.js +33 -0
- package/dist/tool-confirmation.d.ts +23 -0
- package/dist/tool-confirmation.js +25 -0
- package/dist/tool-presentation.d.ts +6 -0
- package/dist/tool-presentation.js +132 -0
- package/dist/tool-result.d.ts +5 -0
- package/dist/tool-result.js +31 -0
- package/dist/types.d.ts +3 -1
- package/dist/ui/home-demo/greeting.d.ts +3 -1
- package/dist/ui/home-demo/greeting.js +2 -2
- package/dist/ui/home-demo/suggestions.d.ts +2 -4
- package/dist/ui/home-demo/suggestions.js +5 -4
- package/dist/ui/home-demo/trace.js +2 -3
- package/package.json +3 -3
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from "react";
|
|
3
|
+
import { useChat } from "./react.js";
|
|
4
|
+
import { confirmationControllers, confirmationRequest } from "./tool-confirmation.js";
|
|
5
|
+
import { Button } from "./ui/button.js";
|
|
6
|
+
import { cn } from "./ui/utils.js";
|
|
7
|
+
export function ToolConfirmationCards({ sessionId, parts, }) {
|
|
8
|
+
const chat = useChat();
|
|
9
|
+
const [error, setError] = useState();
|
|
10
|
+
const controller = confirmationControllers.get(chat.sendMessage);
|
|
11
|
+
return (_jsx(_Fragment, { children: parts.map((part) => {
|
|
12
|
+
const request = confirmationRequest(part);
|
|
13
|
+
if (!request || !controller)
|
|
14
|
+
return null;
|
|
15
|
+
const state = controller.state(sessionId, request);
|
|
16
|
+
const disabled = state !== "pending" || (chat.status !== "idle" && chat.status !== "error");
|
|
17
|
+
const respond = (approved) => {
|
|
18
|
+
setError(undefined);
|
|
19
|
+
void controller.respond(sessionId, request, approved).catch(() => {
|
|
20
|
+
if (controller.state(sessionId, request) === "pending")
|
|
21
|
+
setError({
|
|
22
|
+
toolCallId: request.toolCallId,
|
|
23
|
+
message: "Could not send your response. Please try again.",
|
|
24
|
+
});
|
|
25
|
+
});
|
|
26
|
+
};
|
|
27
|
+
return (_jsxs("section", { "aria-label": "\u64CD\u4F5C\u786E\u8BA4", className: cn("my-3 rounded-lg border p-4"), children: [_jsx("p", { className: cn("mb-3 whitespace-pre-wrap"), children: request.message }), state === "pending" || state === "sending" ? (_jsxs("div", { className: cn("flex gap-2"), children: [_jsx(Button, { disabled: disabled, onClick: () => respond(true), children: "\u786E\u8BA4" }), _jsx(Button, { variant: "outline", disabled: disabled, onClick: () => respond(false), children: "\u62D2\u7EDD" })] })) : (_jsx("p", { role: "status", children: state === "approved"
|
|
28
|
+
? "已确认"
|
|
29
|
+
: state === "rejected"
|
|
30
|
+
? "已拒绝"
|
|
31
|
+
: "此确认已失效,请重新发起操作。" })), error?.toolCallId === request.toolCallId ? _jsx("p", { role: "alert", children: error.message }) : null] }, request.toolCallId));
|
|
32
|
+
}) }));
|
|
33
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { UIMessagePart } from "./messages.js";
|
|
2
|
+
export type ConfirmationRequest = {
|
|
3
|
+
toolCallId: string;
|
|
4
|
+
toolName: string;
|
|
5
|
+
requestId: string;
|
|
6
|
+
message: string;
|
|
7
|
+
};
|
|
8
|
+
export declare function parseConfirmationResult(content: string): {
|
|
9
|
+
requestId: string;
|
|
10
|
+
message: string;
|
|
11
|
+
} | undefined;
|
|
12
|
+
export declare function confirmationRequest(part: UIMessagePart): ConfirmationRequest | undefined;
|
|
13
|
+
export type ConfirmationState = "pending" | "sending" | "approved" | "rejected" | "expired";
|
|
14
|
+
export type ConfirmationSession = {
|
|
15
|
+
restored: Set<string>;
|
|
16
|
+
decisions: Map<string, ConfirmationState>;
|
|
17
|
+
};
|
|
18
|
+
type Controller = {
|
|
19
|
+
state(sessionId: string, request: ConfirmationRequest): ConfirmationState;
|
|
20
|
+
respond(sessionId: string, request: ConfirmationRequest, approved: boolean): Promise<void>;
|
|
21
|
+
};
|
|
22
|
+
export declare const confirmationControllers: WeakMap<(text: string, attachments?: import("./attachments.js").Attachment[], revisionOf?: string) => Promise<import("@nexface/agent").AgentRunResult>, Controller>;
|
|
23
|
+
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export function parseConfirmationResult(content) {
|
|
2
|
+
try {
|
|
3
|
+
const parsed = JSON.parse(content);
|
|
4
|
+
const result = parsed?.result;
|
|
5
|
+
if (result?.status === "confirmation_required" &&
|
|
6
|
+
typeof result.requestId === "string" &&
|
|
7
|
+
result.requestId.trim() &&
|
|
8
|
+
typeof result.message === "string" &&
|
|
9
|
+
result.message.trim() &&
|
|
10
|
+
!parsed.error) {
|
|
11
|
+
return { requestId: result.requestId, message: result.message };
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
catch {
|
|
15
|
+
/* Other tool results are not confirmation requests. */
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
export function confirmationRequest(part) {
|
|
19
|
+
if (part.type !== "tool" || part.isError || !part.result)
|
|
20
|
+
return;
|
|
21
|
+
const result = parseConfirmationResult(part.result);
|
|
22
|
+
return result ? { ...result, toolCallId: part.toolCallId, toolName: part.name } : undefined;
|
|
23
|
+
}
|
|
24
|
+
// Internal bridge: the public useChat and Chat interfaces stay unchanged.
|
|
25
|
+
export const confirmationControllers = new WeakMap();
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { ToolCallMessagePartProps } from "@assistant-ui/react";
|
|
2
|
+
import type { UIMessagePart } from "./messages.js";
|
|
3
|
+
export declare function ToolPresentationUI({ presentation: tool, ...props }: ToolCallMessagePartProps & {
|
|
4
|
+
showDetails: boolean;
|
|
5
|
+
presentation?: UIMessagePart | undefined;
|
|
6
|
+
}): import("react").JSX.Element;
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Component, memo, useMemo } from "react";
|
|
3
|
+
import { validateAgentToolInput } from "./shared/schema.js";
|
|
4
|
+
import { decodeToolResult } from "./tool-result.js";
|
|
5
|
+
import { useChat, useToolPresentations } from "./react.js";
|
|
6
|
+
import { ToolCall } from "./ui/home-demo/trace.js";
|
|
7
|
+
import { cn } from "./ui/utils.js";
|
|
8
|
+
function confirmationInputText(argsText, toolName, toolCallId, messages) {
|
|
9
|
+
try {
|
|
10
|
+
const wire = JSON.parse(argsText);
|
|
11
|
+
if (!wire || typeof wire !== "object" || Array.isArray(wire))
|
|
12
|
+
return;
|
|
13
|
+
if (Object.keys(wire).length !== 1)
|
|
14
|
+
return;
|
|
15
|
+
if (Object.hasOwn(wire, "input"))
|
|
16
|
+
return JSON.stringify(wire.input);
|
|
17
|
+
const answer = wire.confirmation;
|
|
18
|
+
if (!answer || typeof answer.requestId !== "string" || typeof answer.approved !== "boolean")
|
|
19
|
+
return;
|
|
20
|
+
// Use the original receipt so settled calls also render after history recovery.
|
|
21
|
+
for (const message of messages)
|
|
22
|
+
for (const part of message.parts) {
|
|
23
|
+
if (part.type !== "tool")
|
|
24
|
+
continue;
|
|
25
|
+
if (part.toolCallId === toolCallId)
|
|
26
|
+
return;
|
|
27
|
+
if (part.name !== toolName || part.result === undefined)
|
|
28
|
+
continue;
|
|
29
|
+
const { value, omitted } = decodeToolResult(part.result, toolName);
|
|
30
|
+
if (!omitted &&
|
|
31
|
+
value &&
|
|
32
|
+
typeof value === "object" &&
|
|
33
|
+
"status" in value &&
|
|
34
|
+
value.status === "confirmation_required" &&
|
|
35
|
+
"requestId" in value &&
|
|
36
|
+
value.requestId === answer.requestId) {
|
|
37
|
+
const original = JSON.parse(part.arguments);
|
|
38
|
+
if (original && Object.hasOwn(original, "input"))
|
|
39
|
+
return JSON.stringify(original.input);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
catch {
|
|
44
|
+
/* Invalid or unavailable business arguments use the default UI. */
|
|
45
|
+
}
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
class RenderBoundary extends Component {
|
|
49
|
+
state = { failed: false };
|
|
50
|
+
static getDerivedStateFromError() {
|
|
51
|
+
return { failed: true };
|
|
52
|
+
}
|
|
53
|
+
componentDidCatch(error) {
|
|
54
|
+
this.props.report(error);
|
|
55
|
+
}
|
|
56
|
+
render() {
|
|
57
|
+
return this.state.failed ? this.props.fallback : this.props.children;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
const ToolContent = memo(function ToolContent({ presentation, context, }) {
|
|
61
|
+
return _jsx(_Fragment, { children: presentation.render(context) });
|
|
62
|
+
});
|
|
63
|
+
export function ToolPresentationUI({ presentation: tool, ...props }) {
|
|
64
|
+
const registry = useToolPresentations();
|
|
65
|
+
const chat = useChat();
|
|
66
|
+
const presentation = registry?.controller?.get(props.toolName);
|
|
67
|
+
const schema = presentation?.definition.inputSchema;
|
|
68
|
+
const argsText = useMemo(() => presentation?.confirmationProtocol
|
|
69
|
+
? confirmationInputText(props.argsText, props.toolName, props.toolCallId, chat.messages)
|
|
70
|
+
: props.argsText, [
|
|
71
|
+
presentation?.confirmationProtocol,
|
|
72
|
+
props.argsText,
|
|
73
|
+
props.toolName,
|
|
74
|
+
props.toolCallId,
|
|
75
|
+
chat.messages,
|
|
76
|
+
]);
|
|
77
|
+
const parsed = useMemo(() => {
|
|
78
|
+
if (!schema || argsText === undefined)
|
|
79
|
+
return;
|
|
80
|
+
try {
|
|
81
|
+
const input = JSON.parse(argsText);
|
|
82
|
+
if (!validateAgentToolInput(schema, input).length)
|
|
83
|
+
return { input };
|
|
84
|
+
}
|
|
85
|
+
catch {
|
|
86
|
+
/* Incomplete or invalid arguments use the default UI. */
|
|
87
|
+
}
|
|
88
|
+
return;
|
|
89
|
+
}, [schema, argsText]);
|
|
90
|
+
const decoded = useMemo(() => typeof props.result === "string" ? decodeToolResult(props.result, props.toolName) : undefined, [props.result, props.toolName]);
|
|
91
|
+
const confirmation = presentation?.confirmationProtocol && decoded?.value && typeof decoded.value === "object"
|
|
92
|
+
? decoded.value
|
|
93
|
+
: undefined;
|
|
94
|
+
const confirmationPending = confirmation?.status === "confirmation_required" &&
|
|
95
|
+
typeof confirmation.requestId === "string" &&
|
|
96
|
+
typeof confirmation.message === "string" &&
|
|
97
|
+
typeof confirmation.nextAction === "string" &&
|
|
98
|
+
Object.keys(confirmation).length === 4;
|
|
99
|
+
const confirmationRejected = confirmation?.status === "rejected" &&
|
|
100
|
+
confirmation.toolExecuted === false &&
|
|
101
|
+
Object.keys(confirmation).every((key) => ["status", "requestId", "toolExecuted"].includes(key));
|
|
102
|
+
const state = tool?.type === "tool" ? tool.toolState : undefined;
|
|
103
|
+
const status = confirmationRejected ||
|
|
104
|
+
state === "cancelled" ||
|
|
105
|
+
state === "rejected" ||
|
|
106
|
+
(props.result === undefined &&
|
|
107
|
+
props.status.type === "incomplete" &&
|
|
108
|
+
props.status.reason === "cancelled")
|
|
109
|
+
? "cancelled"
|
|
110
|
+
: state || props.isError || (props.result === undefined && props.status.type === "incomplete")
|
|
111
|
+
? "error"
|
|
112
|
+
: props.result === undefined
|
|
113
|
+
? "running"
|
|
114
|
+
: "success";
|
|
115
|
+
const context = useMemo(() => parsed
|
|
116
|
+
? {
|
|
117
|
+
input: parsed.input,
|
|
118
|
+
status,
|
|
119
|
+
...(status === "success" ? { result: decoded ? decoded.value : props.result } : {}),
|
|
120
|
+
}
|
|
121
|
+
: undefined, [parsed, status, decoded, props.result]);
|
|
122
|
+
const fallback = _jsx(ToolCall, { ...props, presentation: tool });
|
|
123
|
+
if (!presentation ||
|
|
124
|
+
!context ||
|
|
125
|
+
confirmationPending ||
|
|
126
|
+
decoded?.omitted ||
|
|
127
|
+
(chat.interrupt?.toolName === props.toolName &&
|
|
128
|
+
tool?.type === "tool" &&
|
|
129
|
+
tool.result === undefined))
|
|
130
|
+
return fallback;
|
|
131
|
+
return (_jsxs(RenderBoundary, { fallback: fallback, report: (error) => registry?.report(error, chat.activeSessionId, props.toolCallId), children: [_jsx("div", { className: cn("my-2 min-w-0 max-w-full"), "data-slot": "nexface-tool-content", children: _jsx(ToolContent, { presentation: presentation, context: context }) }), props.showDetails ? fallback : null] }, props.toolCallId));
|
|
132
|
+
}
|
package/dist/tool-result.d.ts
CHANGED
|
@@ -1 +1,6 @@
|
|
|
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,3 +14,34 @@ 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 } from "react";
|
|
2
|
+
import type { CSSProperties, ReactNode } from "react";
|
|
3
3
|
import type { ChatDictation } from "./voice/types.js";
|
|
4
4
|
export type ChatRunResult = Extract<AgentRunResult, {
|
|
5
5
|
outcome: {
|
|
@@ -7,10 +7,12 @@ export type ChatRunResult = Extract<AgentRunResult, {
|
|
|
7
7
|
};
|
|
8
8
|
}>;
|
|
9
9
|
export interface ChatSuggestion {
|
|
10
|
+
readonly icon?: ReactNode;
|
|
10
11
|
readonly label: string;
|
|
11
12
|
readonly prompt: string;
|
|
12
13
|
}
|
|
13
14
|
export interface ChatProps {
|
|
15
|
+
welcomeIcon?: ReactNode;
|
|
14
16
|
dictation?: false | ChatDictation | undefined;
|
|
15
17
|
open?: boolean;
|
|
16
18
|
onOpenChange?: (open: boolean) => void;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
export declare function Greeting({ title, description, icon, }: {
|
|
2
3
|
title: string;
|
|
3
4
|
description?: string | undefined;
|
|
5
|
+
icon?: ReactNode;
|
|
4
6
|
}): 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: [_jsx("p", { className: cn(typeSection), children: title }), description ? _jsx("p", { className: cn(typeDeck), children: description }) : null] }));
|
|
5
|
+
export function Greeting({ title, description, icon, }) {
|
|
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: [icon != null ? (_jsx("div", { className: cn("mb-4 flex max-w-full justify-center [&_img]:max-w-full"), children: icon })) : null, _jsx("p", { className: cn(typeSection), children: title }), description ? _jsx("p", { className: cn(typeDeck), children: description }) : null] }));
|
|
7
7
|
}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
+
import type { ChatSuggestion } from "../../types.js";
|
|
1
2
|
export declare function Suggestions({ suggestions, disabled, onSend, }: {
|
|
2
|
-
suggestions: readonly
|
|
3
|
-
label: string;
|
|
4
|
-
prompt: string;
|
|
5
|
-
}[];
|
|
3
|
+
suggestions: readonly ChatSuggestion[];
|
|
6
4
|
disabled: boolean;
|
|
7
5
|
onSend(prompt: string): void;
|
|
8
6
|
}): import("react").JSX.Element;
|
|
@@ -1,9 +1,10 @@
|
|
|
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 } from "react/jsx-runtime";
|
|
3
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
4
4
|
import { ThreadPrimitive, useAuiState } from "@assistant-ui/react";
|
|
5
5
|
import { cn } from "../utils.js";
|
|
6
|
-
|
|
6
|
+
// Keep the 32px design height without trimming CJK glyphs; wrapped or enlarged labels can grow.
|
|
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";
|
|
7
8
|
export function Suggestions({ suggestions, disabled, onSend, }) {
|
|
8
9
|
const isComposerEmpty = useAuiState((s) => s.composer.isEmpty);
|
|
9
10
|
const hidden = !isComposerEmpty || disabled;
|
|
@@ -11,8 +12,8 @@ export function Suggestions({ suggestions, disabled, onSend, }) {
|
|
|
11
12
|
// Typing hides the suggestions without unmounting them: the empty view is
|
|
12
13
|
// centred, so collapsing a block this tall moves the composer out from
|
|
13
14
|
// under the cursor. Disabled buttons also stay out of the tab order in React 18.
|
|
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) => (
|
|
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) => (_jsxs(ThreadPrimitive.Suggestion, { prompt: suggestion.prompt, send: true, disabled: hidden, onClick: (event) => {
|
|
15
16
|
event.preventDefault();
|
|
16
17
|
onSend(suggestion.prompt);
|
|
17
|
-
}, className: cn(suggestionChipClass), children: suggestion.label }, suggestion.prompt))) }));
|
|
18
|
+
}, className: cn(suggestionChipClass), children: [suggestion.icon != null ? (_jsx("span", { "aria-hidden": "true", className: cn("inline-flex size-4 shrink-0 items-center justify-center [&>svg]:size-4 [&>img]:size-4"), children: suggestion.icon })) : null, _jsx("span", { className: cn("min-w-0 wrap-anywhere"), children: suggestion.label })] }, suggestion.prompt))) }));
|
|
18
19
|
}
|
|
@@ -5,6 +5,7 @@ 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";
|
|
8
9
|
export const disclosureContentClass = "border-foreground/10 ms-[5px] border-s ps-4";
|
|
9
10
|
export function DisclosureTrigger({ live, label, detail, }) {
|
|
10
11
|
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] })) })] }));
|
|
@@ -37,7 +38,5 @@ export function ToolCall({ toolName, args, argsText, result, status, isError, sh
|
|
|
37
38
|
? "Rejected"
|
|
38
39
|
: tool?.toolState === "not_started"
|
|
39
40
|
? "Not started"
|
|
40
|
-
:
|
|
41
|
-
? result
|
|
42
|
-
: JSON.stringify(result, null, 2) })) : null] })] })] }));
|
|
41
|
+
: toolResultPreview(result) })) : null] })] })] }));
|
|
43
42
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nexface/chat",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.21-alpha.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"types": "./dist/index.d.ts",
|
|
6
6
|
"sideEffects": [
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
21
|
"@ag-ui/core": "0.0.59",
|
|
22
|
-
"@nexface/agent": "0.1.
|
|
22
|
+
"@nexface/agent": "0.1.21-alpha.0",
|
|
23
23
|
"class-variance-authority": "0.7.1",
|
|
24
24
|
"clsx": "2.1.1",
|
|
25
25
|
"fast-json-patch": "3.1.1",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"use-sync-external-store": "1.7.0"
|
|
29
29
|
},
|
|
30
30
|
"peerDependencies": {
|
|
31
|
-
"@nexface/tools": "0.1.
|
|
31
|
+
"@nexface/tools": "0.1.21-alpha.0",
|
|
32
32
|
"react": ">=17",
|
|
33
33
|
"react-dom": ">=17"
|
|
34
34
|
},
|