@meshagent/meshagent-tailwind 0.49.0 → 0.50.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/CHANGELOG.md +9 -0
- package/dist/cjs/chat/agent-thread.d.ts +10 -6
- package/dist/cjs/chat/agent-thread.js +87 -213
- package/dist/cjs/chat/chat-bot-view.d.ts +5 -4
- package/dist/cjs/chat/chat-bot-view.js +2 -0
- package/dist/cjs/chat/chat-feed-widget.d.ts +3 -2
- package/dist/cjs/chat/chat-feed-widget.js +10 -10
- package/dist/cjs/chat/chat-hooks.d.ts +1 -1
- package/dist/cjs/chat/chat-hooks.js +1 -4
- package/dist/cjs/chat/chat-input.js +2 -2
- package/dist/cjs/chat/chat-typing-indicator.d.ts +2 -4
- package/dist/cjs/chat/chat-typing-indicator.js +4 -7
- package/dist/cjs/chat/dataset-agent-thread.d.ts +9 -6
- package/dist/cjs/chat/dataset-agent-thread.js +13 -3
- package/dist/cjs/chat/multi-thread-view.d.ts +6 -5
- package/dist/cjs/chat/multi-thread-view.js +2 -0
- package/dist/cjs/chat/new-chat-thread.d.ts +6 -4
- package/dist/cjs/chat/new-chat-thread.js +18 -11
- package/dist/cjs/chat/thread-view.d.ts +6 -5
- package/dist/cjs/chat/thread-view.js +21 -0
- package/dist/esm/chat/agent-thread.d.ts +10 -6
- package/dist/esm/chat/agent-thread.js +87 -213
- package/dist/esm/chat/chat-bot-view.d.ts +5 -4
- package/dist/esm/chat/chat-bot-view.js +2 -0
- package/dist/esm/chat/chat-feed-widget.d.ts +3 -2
- package/dist/esm/chat/chat-feed-widget.js +10 -10
- package/dist/esm/chat/chat-hooks.d.ts +1 -1
- package/dist/esm/chat/chat-hooks.js +1 -4
- package/dist/esm/chat/chat-input.js +2 -2
- package/dist/esm/chat/chat-typing-indicator.d.ts +2 -4
- package/dist/esm/chat/chat-typing-indicator.js +4 -7
- package/dist/esm/chat/dataset-agent-thread.d.ts +9 -6
- package/dist/esm/chat/dataset-agent-thread.js +13 -3
- package/dist/esm/chat/multi-thread-view.d.ts +6 -5
- package/dist/esm/chat/multi-thread-view.js +2 -0
- package/dist/esm/chat/new-chat-thread.d.ts +6 -4
- package/dist/esm/chat/new-chat-thread.js +18 -11
- package/dist/esm/chat/thread-view.d.ts +6 -5
- package/dist/esm/chat/thread-view.js +21 -0
- package/dist/index.css +1 -1
- package/package.json +6 -6
|
@@ -78,5 +78,5 @@ export interface UseThreadStatusProps {
|
|
|
78
78
|
agentName?: string;
|
|
79
79
|
previous?: ChatThreadStatusState;
|
|
80
80
|
}
|
|
81
|
-
export declare function formatThreadStatusText(text: string, startedAt?: Date | null,
|
|
81
|
+
export declare function formatThreadStatusText(text: string, startedAt?: Date | null, linesAdded?: number | null, linesRemoved?: number | null): string;
|
|
82
82
|
export declare function useThreadStatus({ room, path, agentName }: UseThreadStatusProps): ThreadStatus;
|
|
@@ -288,15 +288,12 @@ function formatGroupedStatusDigits(value) {
|
|
|
288
288
|
function formatStatusSecondUnit(value) {
|
|
289
289
|
return value === 1 ? "second" : "seconds";
|
|
290
290
|
}
|
|
291
|
-
function formatThreadStatusText(text, startedAt,
|
|
291
|
+
function formatThreadStatusText(text, startedAt, linesAdded, linesRemoved) {
|
|
292
292
|
if (linesAdded != null || linesRemoved != null) {
|
|
293
293
|
const added = linesAdded != null ? "+" + formatGroupedStatusDigits(linesAdded) : null;
|
|
294
294
|
const removed = linesRemoved != null ? "-" + formatGroupedStatusDigits(linesRemoved) : null;
|
|
295
295
|
return [text, added, removed].filter((part) => part != null).join(" ");
|
|
296
296
|
}
|
|
297
|
-
if (totalBytes != null && totalBytes > 100) {
|
|
298
|
-
return text + " " + formatGroupedStatusDigits(totalBytes) + " bytes";
|
|
299
|
-
}
|
|
300
297
|
if (!(startedAt instanceof Date) || Number.isNaN(startedAt.getTime())) {
|
|
301
298
|
return text;
|
|
302
299
|
}
|
|
@@ -60,7 +60,7 @@ function ComposerActionButton({
|
|
|
60
60
|
type: "button",
|
|
61
61
|
size: "icon",
|
|
62
62
|
variant: "ghost",
|
|
63
|
-
className: cn("relative size-9 rounded-full", disabled
|
|
63
|
+
className: cn("relative size-9 rounded-full", disabled ? "opacity-55" : "cursor-pointer"),
|
|
64
64
|
disabled,
|
|
65
65
|
onClick,
|
|
66
66
|
title: disabled ? "Cancelling" : "Stop",
|
|
@@ -76,7 +76,7 @@ function ComposerActionButton({
|
|
|
76
76
|
{
|
|
77
77
|
type: "button",
|
|
78
78
|
size: "icon",
|
|
79
|
-
className: "size-9 rounded-full shadow-xs",
|
|
79
|
+
className: cn("size-9 rounded-full shadow-xs", !disabled && "cursor-pointer"),
|
|
80
80
|
disabled,
|
|
81
81
|
onClick,
|
|
82
82
|
title: "Send",
|
|
@@ -7,7 +7,6 @@ export interface ChatTypingIndicatorProps {
|
|
|
7
7
|
thinking?: boolean;
|
|
8
8
|
statusText?: string | null;
|
|
9
9
|
startedAt?: Date | null;
|
|
10
|
-
totalBytes?: number | null;
|
|
11
10
|
linesAdded?: number | null;
|
|
12
11
|
linesRemoved?: number | null;
|
|
13
12
|
onCancel?: () => void;
|
|
@@ -17,12 +16,11 @@ export interface ChatTypingIndicatorProps {
|
|
|
17
16
|
export interface ChatThreadStatusIndicatorProps {
|
|
18
17
|
statusText?: string | null;
|
|
19
18
|
startedAt?: Date | null;
|
|
20
|
-
totalBytes?: number | null;
|
|
21
19
|
linesAdded?: number | null;
|
|
22
20
|
linesRemoved?: number | null;
|
|
23
21
|
reserveSpace?: boolean;
|
|
24
22
|
size?: number;
|
|
25
23
|
className?: string;
|
|
26
24
|
}
|
|
27
|
-
export declare function ChatThreadStatusIndicator({ statusText, startedAt,
|
|
28
|
-
export declare function ChatTypingIndicator({ room, path, typing, thinking, statusText, startedAt,
|
|
25
|
+
export declare function ChatThreadStatusIndicator({ statusText, startedAt, linesAdded, linesRemoved, reserveSpace, size, className, }: ChatThreadStatusIndicatorProps): React.ReactElement | null;
|
|
26
|
+
export declare function ChatTypingIndicator({ room, path, typing, thinking, statusText, startedAt, linesAdded, linesRemoved, onCancel, showCancelButton, cancelEnabled, }: ChatTypingIndicatorProps): React.ReactElement | null;
|
|
@@ -4,7 +4,7 @@ import { useRoomIndicators } from "@meshagent/meshagent-react";
|
|
|
4
4
|
import { LoaderCircle, X } from "lucide-react";
|
|
5
5
|
import { formatThreadStatusText } from "./chat-hooks.js";
|
|
6
6
|
import { cn } from "../lib/utils.js";
|
|
7
|
-
function useStatusLabel(text, startedAt,
|
|
7
|
+
function useStatusLabel(text, startedAt, linesAdded, linesRemoved) {
|
|
8
8
|
const normalizedText = text?.trim() ?? "";
|
|
9
9
|
const [tick, setTick] = React.useState(0);
|
|
10
10
|
React.useEffect(() => {
|
|
@@ -17,24 +17,23 @@ function useStatusLabel(text, startedAt, totalBytes, linesAdded, linesRemoved) {
|
|
|
17
17
|
return () => {
|
|
18
18
|
window.clearInterval(timer);
|
|
19
19
|
};
|
|
20
|
-
}, [normalizedText, startedAt,
|
|
20
|
+
}, [normalizedText, startedAt, linesAdded, linesRemoved]);
|
|
21
21
|
if (normalizedText === "") {
|
|
22
22
|
return null;
|
|
23
23
|
}
|
|
24
24
|
void tick;
|
|
25
|
-
return formatThreadStatusText(normalizedText, startedAt,
|
|
25
|
+
return formatThreadStatusText(normalizedText, startedAt, linesAdded, linesRemoved);
|
|
26
26
|
}
|
|
27
27
|
function ChatThreadStatusIndicator({
|
|
28
28
|
statusText,
|
|
29
29
|
startedAt,
|
|
30
|
-
totalBytes,
|
|
31
30
|
linesAdded,
|
|
32
31
|
linesRemoved,
|
|
33
32
|
reserveSpace = false,
|
|
34
33
|
size = 16,
|
|
35
34
|
className
|
|
36
35
|
}) {
|
|
37
|
-
const label = useStatusLabel(statusText, startedAt,
|
|
36
|
+
const label = useStatusLabel(statusText, startedAt, linesAdded, linesRemoved);
|
|
38
37
|
if (label == null) {
|
|
39
38
|
return reserveSpace ? /* @__PURE__ */ jsx("span", { "aria-hidden": "true", style: { width: size, height: size }, className: cn("inline-block shrink-0", className) }) : null;
|
|
40
39
|
}
|
|
@@ -81,7 +80,6 @@ function ChatTypingIndicator({
|
|
|
81
80
|
thinking,
|
|
82
81
|
statusText,
|
|
83
82
|
startedAt,
|
|
84
|
-
totalBytes,
|
|
85
83
|
linesAdded,
|
|
86
84
|
linesRemoved,
|
|
87
85
|
onCancel,
|
|
@@ -94,7 +92,6 @@ function ChatTypingIndicator({
|
|
|
94
92
|
const resolvedStatusText = useStatusLabel(
|
|
95
93
|
statusText?.trim() ? statusText : resolvedThinking ? "Thinking" : null,
|
|
96
94
|
startedAt,
|
|
97
|
-
totalBytes,
|
|
98
95
|
linesAdded,
|
|
99
96
|
linesRemoved
|
|
100
97
|
);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ReactElement } from "react";
|
|
2
|
-
import type { RoomClient } from "@meshagent/meshagent";
|
|
2
|
+
import type { RoomClient, Tool } from "@meshagent/meshagent";
|
|
3
3
|
import { AgentMessageEvent, BaseChatClient } from "@meshagent/meshagent-agents";
|
|
4
4
|
import type { AgentMessage as AgentMessageType, AgentMessageEvent as AgentMessageEventType, ClientToolkitDescription } from "@meshagent/meshagent-agents";
|
|
5
5
|
import { type AgentThreadSuggestion, type AgentToolChoice } from "./agent-thread.js";
|
|
@@ -17,7 +17,7 @@ export interface DatasetThreadRef {
|
|
|
17
17
|
table: string;
|
|
18
18
|
}
|
|
19
19
|
export interface DatasetAgentThreadProps {
|
|
20
|
-
room
|
|
20
|
+
room?: RoomClient;
|
|
21
21
|
path: string;
|
|
22
22
|
chatClient?: BaseChatClient;
|
|
23
23
|
disposeChatClient?: boolean;
|
|
@@ -25,8 +25,9 @@ export interface DatasetAgentThreadProps {
|
|
|
25
25
|
rowsLoader?: DatasetThreadRowsLoader;
|
|
26
26
|
emptyStateTitle?: string;
|
|
27
27
|
emptyStateDescription?: string;
|
|
28
|
-
clientToolkits?: ClientToolkitDescription[];
|
|
29
|
-
|
|
28
|
+
clientToolkits?: readonly ClientToolkitDescription[];
|
|
29
|
+
clientTools?: readonly Tool[];
|
|
30
|
+
chatFeedWidgets?: readonly ChatFeedWidget[];
|
|
30
31
|
toolChoice?: AgentToolChoice;
|
|
31
32
|
collapseMessages?: boolean;
|
|
32
33
|
suggestions?: readonly AgentThreadSuggestion[];
|
|
@@ -40,8 +41,10 @@ export interface DatasetAgentThreadProps {
|
|
|
40
41
|
onPersistedEventsInjected?: (error: unknown | null) => void;
|
|
41
42
|
onEventsChanged?: (threadId: string, events: readonly AgentMessageEventType[], latestMessage: AgentMessageType | null) => void;
|
|
42
43
|
}
|
|
43
|
-
export type RoomDatasetAgentThreadProps = Omit<DatasetAgentThreadProps, "rowsLoader"
|
|
44
|
-
|
|
44
|
+
export type RoomDatasetAgentThreadProps = Omit<DatasetAgentThreadProps, "room" | "rowsLoader"> & {
|
|
45
|
+
room: RoomClient;
|
|
46
|
+
};
|
|
47
|
+
export declare function DatasetAgentThread({ room, path, chatClient, disposeChatClient, agentName, rowsLoader, emptyStateTitle, emptyStateDescription, clientToolkits, clientTools, chatFeedWidgets, toolChoice, collapseMessages, suggestions, enableFileUpload, retryMissingTableMs, loadThread, injectPersistedEvents, composerDisabled, closeThreadOnUnmount, onPersistedEventsInjectionStarted, onPersistedEventsInjected, onEventsChanged, }: DatasetAgentThreadProps): ReactElement;
|
|
45
48
|
export declare function RoomDatasetAgentThread(props: RoomDatasetAgentThreadProps): ReactElement;
|
|
46
49
|
export declare function parseDatasetThreadRef(path: string): DatasetThreadRef;
|
|
47
50
|
export declare function loadDatasetThreadEvents(loader: DatasetThreadRowsLoader, args: DatasetThreadRowsLoaderArgs): Promise<AgentMessageEvent[]>;
|
|
@@ -16,6 +16,7 @@ function DatasetAgentThread({
|
|
|
16
16
|
emptyStateTitle,
|
|
17
17
|
emptyStateDescription,
|
|
18
18
|
clientToolkits,
|
|
19
|
+
clientTools,
|
|
19
20
|
chatFeedWidgets,
|
|
20
21
|
toolChoice,
|
|
21
22
|
collapseMessages,
|
|
@@ -31,9 +32,17 @@ function DatasetAgentThread({
|
|
|
31
32
|
onEventsChanged
|
|
32
33
|
}) {
|
|
33
34
|
const normalizedPath = path.trim();
|
|
34
|
-
const activeRowsLoader = useMemo(() =>
|
|
35
|
+
const activeRowsLoader = useMemo(() => {
|
|
36
|
+
if (rowsLoader != null) return rowsLoader;
|
|
37
|
+
if (room != null) return defaultRowsLoader(room);
|
|
38
|
+
throw new Error("DatasetAgentThread requires either a room or a rows loader.");
|
|
39
|
+
}, [room, rowsLoader]);
|
|
35
40
|
const activeChatClient = useMemo(
|
|
36
|
-
() =>
|
|
41
|
+
() => {
|
|
42
|
+
if (chatClient != null) return chatClient;
|
|
43
|
+
if (room != null) return new MessagingChatClient({ room, agentName });
|
|
44
|
+
throw new Error("DatasetAgentThread requires either a room or a chat client.");
|
|
45
|
+
},
|
|
37
46
|
[agentName, chatClient, room]
|
|
38
47
|
);
|
|
39
48
|
const [persistedEvents, setPersistedEvents] = useState(null);
|
|
@@ -92,11 +101,12 @@ function DatasetAgentThread({
|
|
|
92
101
|
emptyStateTitle,
|
|
93
102
|
emptyStateDescription,
|
|
94
103
|
clientToolkits,
|
|
104
|
+
clientTools,
|
|
95
105
|
chatFeedWidgets,
|
|
96
106
|
toolChoice,
|
|
97
107
|
collapseMessages,
|
|
98
108
|
suggestions,
|
|
99
|
-
enableFileUpload,
|
|
109
|
+
enableFileUpload: enableFileUpload && room != null,
|
|
100
110
|
persistedEvents: persistedEvents ?? [],
|
|
101
111
|
deferLiveEvents: persistedEvents == null,
|
|
102
112
|
loadThread,
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { ReactElement } from "react";
|
|
2
|
-
import { RoomClient } from "@meshagent/meshagent";
|
|
2
|
+
import type { RoomClient, Tool } from "@meshagent/meshagent";
|
|
3
3
|
import type { AgentMessageEvent, BaseChatClient, ClientToolkitDescription } from "@meshagent/meshagent-agents";
|
|
4
4
|
import type { AgentThreadSuggestion, AgentToolChoice } from "./agent-thread.js";
|
|
5
5
|
import type { ChatFeedWidget } from "./chat-feed-widget.js";
|
|
6
6
|
export type MultiThreadContentBuilder = (threadPath: string) => ReactElement;
|
|
7
7
|
export interface MultiThreadViewProps {
|
|
8
|
-
room
|
|
8
|
+
room?: RoomClient;
|
|
9
9
|
chatClient?: BaseChatClient;
|
|
10
10
|
disposeChatClient?: boolean;
|
|
11
11
|
agentName: string;
|
|
@@ -19,11 +19,12 @@ export interface MultiThreadViewProps {
|
|
|
19
19
|
centerComposer?: boolean;
|
|
20
20
|
emptyStateTitle?: string;
|
|
21
21
|
emptyStateDescription?: string;
|
|
22
|
-
clientToolkits?: ClientToolkitDescription[];
|
|
23
|
-
|
|
22
|
+
clientToolkits?: readonly ClientToolkitDescription[];
|
|
23
|
+
clientTools?: readonly Tool[];
|
|
24
|
+
chatFeedWidgets?: readonly ChatFeedWidget[];
|
|
24
25
|
toolChoice?: AgentToolChoice;
|
|
25
26
|
suggestions?: readonly AgentThreadSuggestion[];
|
|
26
27
|
enableFileUpload?: boolean;
|
|
27
28
|
onThreadStarted?: (threadId: string, events: readonly AgentMessageEvent[]) => Promise<void> | void;
|
|
28
29
|
}
|
|
29
|
-
export declare function MultiThreadView({ room, chatClient, disposeChatClient, agentName, builder, toolkit, tool, selectedThreadPath, onSelectedThreadPathChanged, onSelectedThreadResolved, newThreadResetVersion, centerComposer, emptyStateTitle, emptyStateDescription, clientToolkits, chatFeedWidgets, toolChoice, suggestions, enableFileUpload, onThreadStarted, }: MultiThreadViewProps): ReactElement;
|
|
30
|
+
export declare function MultiThreadView({ room, chatClient, disposeChatClient, agentName, builder, toolkit, tool, selectedThreadPath, onSelectedThreadPathChanged, onSelectedThreadResolved, newThreadResetVersion, centerComposer, emptyStateTitle, emptyStateDescription, clientToolkits, clientTools, chatFeedWidgets, toolChoice, suggestions, enableFileUpload, onThreadStarted, }: MultiThreadViewProps): ReactElement;
|
|
@@ -21,6 +21,7 @@ function MultiThreadView({
|
|
|
21
21
|
emptyStateTitle = "Start a new thread",
|
|
22
22
|
emptyStateDescription = "Connect with this agent and your team",
|
|
23
23
|
clientToolkits,
|
|
24
|
+
clientTools,
|
|
24
25
|
chatFeedWidgets,
|
|
25
26
|
toolChoice,
|
|
26
27
|
suggestions,
|
|
@@ -75,6 +76,7 @@ function MultiThreadView({
|
|
|
75
76
|
emptyStateTitle,
|
|
76
77
|
emptyStateDescription,
|
|
77
78
|
clientToolkits,
|
|
79
|
+
clientTools,
|
|
78
80
|
chatFeedWidgets,
|
|
79
81
|
toolChoice,
|
|
80
82
|
suggestions,
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import type { ReactElement } from "react";
|
|
2
2
|
import { RoomClient } from "@meshagent/meshagent";
|
|
3
|
+
import type { Tool } from "@meshagent/meshagent";
|
|
3
4
|
import type { AgentMessageEvent, BaseChatClient, ClientToolkitDescription } from "@meshagent/meshagent-agents";
|
|
4
5
|
import type { AgentThreadSuggestion, AgentToolChoice } from "./agent-thread.js";
|
|
5
6
|
import type { ChatFeedWidget } from "./chat-feed-widget.js";
|
|
6
7
|
export type NewChatThreadBuilder = (threadPath: string) => ReactElement;
|
|
7
8
|
export interface NewChatThreadProps {
|
|
8
|
-
room
|
|
9
|
+
room?: RoomClient;
|
|
9
10
|
chatClient?: BaseChatClient;
|
|
10
11
|
disposeChatClient?: boolean;
|
|
11
12
|
agentName: string;
|
|
@@ -18,11 +19,12 @@ export interface NewChatThreadProps {
|
|
|
18
19
|
centerComposer?: boolean;
|
|
19
20
|
emptyStateTitle?: string;
|
|
20
21
|
emptyStateDescription?: string;
|
|
21
|
-
clientToolkits?: ClientToolkitDescription[];
|
|
22
|
-
|
|
22
|
+
clientToolkits?: readonly ClientToolkitDescription[];
|
|
23
|
+
clientTools?: readonly Tool[];
|
|
24
|
+
chatFeedWidgets?: readonly ChatFeedWidget[];
|
|
23
25
|
toolChoice?: AgentToolChoice;
|
|
24
26
|
suggestions?: readonly AgentThreadSuggestion[];
|
|
25
27
|
enableFileUpload?: boolean;
|
|
26
28
|
onThreadStarted?: (threadId: string, events: readonly AgentMessageEvent[]) => Promise<void> | void;
|
|
27
29
|
}
|
|
28
|
-
export declare function NewChatThread({ room, chatClient, disposeChatClient, agentName, builder, selectedThreadPath, onThreadPathChanged, onThreadResolved, centerComposer, emptyStateTitle, emptyStateDescription, clientToolkits, chatFeedWidgets, toolChoice, suggestions, enableFileUpload, onThreadStarted, }: NewChatThreadProps): ReactElement;
|
|
30
|
+
export declare function NewChatThread({ room, chatClient, disposeChatClient, agentName, builder, selectedThreadPath, onThreadPathChanged, onThreadResolved, centerComposer, emptyStateTitle, emptyStateDescription, clientToolkits, clientTools, chatFeedWidgets, toolChoice, suggestions, enableFileUpload, onThreadStarted, }: NewChatThreadProps): ReactElement;
|
|
@@ -80,6 +80,7 @@ function NewChatThread({
|
|
|
80
80
|
emptyStateTitle,
|
|
81
81
|
emptyStateDescription,
|
|
82
82
|
clientToolkits,
|
|
83
|
+
clientTools,
|
|
83
84
|
chatFeedWidgets,
|
|
84
85
|
toolChoice,
|
|
85
86
|
suggestions,
|
|
@@ -97,13 +98,17 @@ function NewChatThread({
|
|
|
97
98
|
const activePath = controlledThreadPath ?? internalThreadPath;
|
|
98
99
|
const ownsChatClient = chatClient == null;
|
|
99
100
|
const activeChatClient = useMemo(
|
|
100
|
-
() =>
|
|
101
|
+
() => {
|
|
102
|
+
if (chatClient != null) return chatClient;
|
|
103
|
+
if (room != null) return new MessagingChatClient({ room, agentName });
|
|
104
|
+
throw new Error("NewChatThread requires either a room or a chat client.");
|
|
105
|
+
},
|
|
101
106
|
[agentName, chatClient, room]
|
|
102
107
|
);
|
|
103
108
|
const [clientVersion, setClientVersion] = useState(0);
|
|
104
109
|
const resolvedClientToolkits = useMemo(
|
|
105
|
-
() => resolveClientToolkitDescriptions(clientToolkits, chatFeedWidgets),
|
|
106
|
-
[chatFeedWidgets, clientToolkits]
|
|
110
|
+
() => resolveClientToolkitDescriptions(clientToolkits, chatFeedWidgets, clientTools),
|
|
111
|
+
[chatFeedWidgets, clientToolkits, clientTools]
|
|
107
112
|
);
|
|
108
113
|
useEffect(() => {
|
|
109
114
|
return () => {
|
|
@@ -142,6 +147,7 @@ function NewChatThread({
|
|
|
142
147
|
setWaitingForAgent(false);
|
|
143
148
|
}, [agentName, controlledThreadPath, room]);
|
|
144
149
|
const selectNewThreadAttachments = useCallback((files) => {
|
|
150
|
+
if (room == null) return;
|
|
145
151
|
const nextAttachments = files.map((file) => new MeshagentFileUpload(
|
|
146
152
|
room,
|
|
147
153
|
`uploaded-files/${file.name}`,
|
|
@@ -164,7 +170,7 @@ function NewChatThread({
|
|
|
164
170
|
}
|
|
165
171
|
const operationId = activeOperationRef.current + 1;
|
|
166
172
|
activeOperationRef.current = operationId;
|
|
167
|
-
const initialTargetAgent = activeChatClient.agentParticipant() ?? findTargetAgent(room, agentName);
|
|
173
|
+
const initialTargetAgent = activeChatClient.agentParticipant() ?? (room == null ? null : findTargetAgent(room, agentName));
|
|
168
174
|
setWaitingForAgent(initialTargetAgent === null && chatClient == null);
|
|
169
175
|
setCreatingNewThread(initialTargetAgent !== null || chatClient != null);
|
|
170
176
|
setNewThreadError(null);
|
|
@@ -183,7 +189,7 @@ function NewChatThread({
|
|
|
183
189
|
const result = await activeChatClient.startThread({
|
|
184
190
|
message: text,
|
|
185
191
|
attachments: newThreadAttachments.map((attachment) => new AgentFileContent({ url: attachment.path })),
|
|
186
|
-
senderName: getParticipantName(room.localParticipant) || void 0,
|
|
192
|
+
senderName: room == null ? activeChatClient.localParticipantName() : getParticipantName(room.localParticipant) || void 0,
|
|
187
193
|
clientToolkits: resolvedClientToolkits
|
|
188
194
|
});
|
|
189
195
|
ensureOperationActive(operationId, activeOperationRef);
|
|
@@ -230,7 +236,7 @@ function NewChatThread({
|
|
|
230
236
|
if (knownAgentName) {
|
|
231
237
|
return displayParticipantName(knownAgentName);
|
|
232
238
|
}
|
|
233
|
-
const targetAgent = activeChatClient.agentParticipant() ?? findTargetAgent(room);
|
|
239
|
+
const targetAgent = activeChatClient.agentParticipant() ?? (room == null ? null : findTargetAgent(room));
|
|
234
240
|
return displayParticipantName(targetAgent ? getParticipantName(targetAgent) : null);
|
|
235
241
|
}, [activeChatClient, agentName, clientVersion, room]);
|
|
236
242
|
const pendingStatusText = waitingForAgent ? `Waiting for ${targetAgentLabel} to be ready.` : creatingNewThread ? `Starting a thread with ${targetAgentLabel}.` : null;
|
|
@@ -246,18 +252,19 @@ function NewChatThread({
|
|
|
246
252
|
"ul",
|
|
247
253
|
{
|
|
248
254
|
"aria-label": "Starter suggestions",
|
|
249
|
-
className: "mx-auto flex
|
|
255
|
+
className: "mx-auto flex w-full max-w-[912px] flex-wrap gap-2 px-4 pt-2 pb-1",
|
|
250
256
|
children: visibleSuggestions.map((suggestion, index) => {
|
|
251
257
|
const text = suggestion.prompt?.trim() || suggestion.label.trim();
|
|
252
|
-
return /* @__PURE__ */ jsx("li", { className: "
|
|
258
|
+
return /* @__PURE__ */ jsx("li", { className: "min-w-0 max-w-full", children: /* @__PURE__ */ jsx(
|
|
253
259
|
Button,
|
|
254
260
|
{
|
|
255
261
|
type: "button",
|
|
256
262
|
variant: "outline",
|
|
257
|
-
className: "h-auto min-h-8 rounded-full px-3 py-1.5",
|
|
263
|
+
className: "h-auto min-h-8 max-w-full overflow-hidden rounded-full px-3 py-1.5 text-left text-sm leading-snug",
|
|
264
|
+
title: suggestion.label,
|
|
258
265
|
disabled: creatingNewThread || waitingForAgent,
|
|
259
266
|
onClick: () => void handleCreateThread({ text }),
|
|
260
|
-
children: suggestion.label
|
|
267
|
+
children: /* @__PURE__ */ jsx("span", { className: "min-w-0 truncate", children: suggestion.label })
|
|
261
268
|
}
|
|
262
269
|
) }, index);
|
|
263
270
|
})
|
|
@@ -270,7 +277,7 @@ function NewChatThread({
|
|
|
270
277
|
attachments: newThreadAttachments,
|
|
271
278
|
onFilesSelected: selectNewThreadAttachments,
|
|
272
279
|
setAttachments: setNewThreadAttachments,
|
|
273
|
-
enableFileUpload,
|
|
280
|
+
enableFileUpload: enableFileUpload && room != null,
|
|
274
281
|
value: newThreadDraft,
|
|
275
282
|
onValueChange: setNewThreadDraft,
|
|
276
283
|
clearOnSubmit: false,
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import type { ReactElement } from "react";
|
|
2
|
-
import type { RoomClient } from "@meshagent/meshagent";
|
|
2
|
+
import type { RoomClient, Tool } from "@meshagent/meshagent";
|
|
3
3
|
import type { AgentMessage, AgentMessageEvent, BaseChatClient, ClientToolkitDescription } from "@meshagent/meshagent-agents";
|
|
4
4
|
import type { AgentThreadSuggestion, AgentToolChoice } from "./agent-thread.js";
|
|
5
5
|
import { ChatThreadDisplayMode } from "./conversation-descriptor.js";
|
|
6
6
|
import type { DatasetThreadRowsLoader } from "./dataset-agent-thread.js";
|
|
7
7
|
import type { ChatFeedWidget } from "./chat-feed-widget.js";
|
|
8
8
|
export interface ThreadViewProps {
|
|
9
|
-
room
|
|
9
|
+
room?: RoomClient;
|
|
10
10
|
chatClient?: BaseChatClient | null;
|
|
11
11
|
path?: string;
|
|
12
12
|
documentPath?: string;
|
|
@@ -24,8 +24,9 @@ export interface ThreadViewProps {
|
|
|
24
24
|
onSelectedThreadPathChanged?: (path: string | null) => void;
|
|
25
25
|
onSelectedThreadResolved?: (path: string | null, displayName: string | null) => void;
|
|
26
26
|
newThreadResetVersion?: number;
|
|
27
|
-
clientToolkits?: ClientToolkitDescription[];
|
|
28
|
-
|
|
27
|
+
clientToolkits?: readonly ClientToolkitDescription[];
|
|
28
|
+
clientTools?: readonly Tool[];
|
|
29
|
+
chatFeedWidgets?: readonly ChatFeedWidget[];
|
|
29
30
|
toolChoice?: AgentToolChoice;
|
|
30
31
|
collapseMessages?: boolean;
|
|
31
32
|
suggestions?: readonly AgentThreadSuggestion[];
|
|
@@ -42,4 +43,4 @@ export interface ThreadViewProps {
|
|
|
42
43
|
onEventsChanged?: (threadId: string, events: readonly AgentMessageEvent[], latestMessage: AgentMessage | null) => void;
|
|
43
44
|
onThreadStarted?: (threadId: string, events: readonly AgentMessageEvent[]) => Promise<void> | void;
|
|
44
45
|
}
|
|
45
|
-
export declare function ThreadView({ room, chatClient, path, documentPath, agentName, threadDisplayMode, threadDir, toolkit, tool, centerComposer, emptyStateTitle, emptyStateDescription, startNewThreadTitle, startNewThreadDescription, selectedThreadPath, onSelectedThreadPathChanged, onSelectedThreadResolved, newThreadResetVersion, clientToolkits, chatFeedWidgets, toolChoice, collapseMessages, suggestions, enableFileUpload, threadSource, rowsLoader, persistedEvents, loadThread, injectPersistedEvents, composerDisabled, closeThreadOnUnmount, onPersistedEventsInjectionStarted, onPersistedEventsInjected, onEventsChanged, onThreadStarted, }: ThreadViewProps): ReactElement;
|
|
46
|
+
export declare function ThreadView({ room, chatClient, path, documentPath, agentName, threadDisplayMode, threadDir, toolkit, tool, centerComposer, emptyStateTitle, emptyStateDescription, startNewThreadTitle, startNewThreadDescription, selectedThreadPath, onSelectedThreadPathChanged, onSelectedThreadResolved, newThreadResetVersion, clientToolkits, clientTools, chatFeedWidgets, toolChoice, collapseMessages, suggestions, enableFileUpload, threadSource, rowsLoader, persistedEvents, loadThread, injectPersistedEvents, composerDisabled, closeThreadOnUnmount, onPersistedEventsInjectionStarted, onPersistedEventsInjected, onEventsChanged, onThreadStarted, }: ThreadViewProps): ReactElement;
|
|
@@ -17,6 +17,15 @@ function MultiThreadUnavailable() {
|
|
|
17
17
|
] })
|
|
18
18
|
] }) }) });
|
|
19
19
|
}
|
|
20
|
+
function RoomUnavailable({ message }) {
|
|
21
|
+
return /* @__PURE__ */ jsx("div", { className: "flex min-h-0 flex-1 items-center justify-center px-4 py-8", children: /* @__PURE__ */ jsx("div", { className: "w-full max-w-[912px] rounded-3xl border border-destructive/30 bg-destructive/5 p-6 text-destructive", children: /* @__PURE__ */ jsxs("div", { className: "flex items-start gap-3", children: [
|
|
22
|
+
/* @__PURE__ */ jsx(AlertTriangle, { className: "mt-0.5 h-5 w-5 shrink-0" }),
|
|
23
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
24
|
+
/* @__PURE__ */ jsx("h2", { className: "text-lg font-semibold", children: "Unable to open chat" }),
|
|
25
|
+
/* @__PURE__ */ jsx("p", { className: "mt-1 text-sm text-destructive/80", children: message })
|
|
26
|
+
] })
|
|
27
|
+
] }) }) });
|
|
28
|
+
}
|
|
20
29
|
function ThreadView({
|
|
21
30
|
room,
|
|
22
31
|
chatClient = null,
|
|
@@ -37,6 +46,7 @@ function ThreadView({
|
|
|
37
46
|
onSelectedThreadResolved,
|
|
38
47
|
newThreadResetVersion = 0,
|
|
39
48
|
clientToolkits,
|
|
49
|
+
clientTools,
|
|
40
50
|
chatFeedWidgets,
|
|
41
51
|
toolChoice,
|
|
42
52
|
collapseMessages = true,
|
|
@@ -57,6 +67,12 @@ function ThreadView({
|
|
|
57
67
|
const resolvedDocumentPath = normalizePath(documentPath ?? path);
|
|
58
68
|
const resolvedSingleThreadPath = resolvedDocumentPath ?? chatDocumentPath(agentName, { threadDir });
|
|
59
69
|
const activeChatClient = chatClient ?? void 0;
|
|
70
|
+
if (room == null && activeChatClient == null) {
|
|
71
|
+
return /* @__PURE__ */ jsx(RoomUnavailable, { message: "ThreadView requires either a room or a chat client." });
|
|
72
|
+
}
|
|
73
|
+
if (threadSource === "dataset" && room == null && rowsLoader == null) {
|
|
74
|
+
return /* @__PURE__ */ jsx(RoomUnavailable, { message: "Dataset-backed threads require a room connection or rows loader." });
|
|
75
|
+
}
|
|
60
76
|
if (threadDisplayMode !== ChatThreadDisplayMode.MultiThreadComposer) {
|
|
61
77
|
if (threadSource === "dataset") {
|
|
62
78
|
return /* @__PURE__ */ jsx(
|
|
@@ -71,6 +87,7 @@ function ThreadView({
|
|
|
71
87
|
emptyStateTitle,
|
|
72
88
|
emptyStateDescription,
|
|
73
89
|
clientToolkits,
|
|
90
|
+
clientTools,
|
|
74
91
|
chatFeedWidgets,
|
|
75
92
|
toolChoice,
|
|
76
93
|
collapseMessages,
|
|
@@ -97,6 +114,7 @@ function ThreadView({
|
|
|
97
114
|
emptyStateTitle,
|
|
98
115
|
emptyStateDescription,
|
|
99
116
|
clientToolkits,
|
|
117
|
+
clientTools,
|
|
100
118
|
chatFeedWidgets,
|
|
101
119
|
toolChoice,
|
|
102
120
|
collapseMessages,
|
|
@@ -131,6 +149,7 @@ function ThreadView({
|
|
|
131
149
|
newThreadResetVersion,
|
|
132
150
|
centerComposer,
|
|
133
151
|
clientToolkits,
|
|
152
|
+
clientTools,
|
|
134
153
|
chatFeedWidgets,
|
|
135
154
|
toolChoice,
|
|
136
155
|
suggestions,
|
|
@@ -148,6 +167,7 @@ function ThreadView({
|
|
|
148
167
|
emptyStateTitle: startNewThreadTitle,
|
|
149
168
|
emptyStateDescription: startNewThreadDescription,
|
|
150
169
|
clientToolkits,
|
|
170
|
+
clientTools,
|
|
151
171
|
chatFeedWidgets,
|
|
152
172
|
toolChoice,
|
|
153
173
|
collapseMessages,
|
|
@@ -172,6 +192,7 @@ function ThreadView({
|
|
|
172
192
|
emptyStateTitle: startNewThreadTitle,
|
|
173
193
|
emptyStateDescription: startNewThreadDescription,
|
|
174
194
|
clientToolkits,
|
|
195
|
+
clientTools,
|
|
175
196
|
chatFeedWidgets,
|
|
176
197
|
toolChoice,
|
|
177
198
|
collapseMessages,
|