@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
|
@@ -81,6 +81,7 @@ function ChatBotView({
|
|
|
81
81
|
threadListWidth = 280,
|
|
82
82
|
threadListCollapsedHeight = 220,
|
|
83
83
|
clientToolkits,
|
|
84
|
+
clientTools,
|
|
84
85
|
chatFeedWidgets,
|
|
85
86
|
toolChoice,
|
|
86
87
|
collapseMessages = true,
|
|
@@ -182,6 +183,7 @@ function ChatBotView({
|
|
|
182
183
|
onSelectedThreadResolved: emitResolvedThread,
|
|
183
184
|
newThreadResetVersion,
|
|
184
185
|
clientToolkits,
|
|
186
|
+
clientTools,
|
|
185
187
|
chatFeedWidgets,
|
|
186
188
|
toolChoice,
|
|
187
189
|
collapseMessages,
|
|
@@ -8,9 +8,10 @@ export interface ToolCall {
|
|
|
8
8
|
status: ToolCallStatus;
|
|
9
9
|
input: Record<string, unknown>;
|
|
10
10
|
output?: Content;
|
|
11
|
+
sendMessage?: (message: string) => void;
|
|
11
12
|
}
|
|
12
13
|
export declare abstract class ChatFeedWidget extends Tool {
|
|
13
|
-
abstract render(toolCall: ToolCall): ReactElement;
|
|
14
|
+
abstract render(toolCall: ToolCall): ReactElement | null;
|
|
14
15
|
getFollowUpSuggestions?(toolCall: ToolCall): readonly AgentThreadSuggestion[];
|
|
15
16
|
}
|
|
16
|
-
export declare function resolveClientToolkitDescriptions(clientToolkits: ClientToolkitDescription[] | undefined, chatFeedWidgets: ChatFeedWidget[] | undefined): ClientToolkitDescription[] | undefined;
|
|
17
|
+
export declare function resolveClientToolkitDescriptions(clientToolkits: readonly ClientToolkitDescription[] | undefined, chatFeedWidgets: readonly ChatFeedWidget[] | undefined, clientTools?: readonly Tool[]): ClientToolkitDescription[] | undefined;
|
|
@@ -26,22 +26,22 @@ var import_meshagent = require("@meshagent/meshagent");
|
|
|
26
26
|
var import_meshagent_agents = require("@meshagent/meshagent-agents");
|
|
27
27
|
class ChatFeedWidget extends import_meshagent.Tool {
|
|
28
28
|
}
|
|
29
|
-
function resolveClientToolkitDescriptions(clientToolkits, chatFeedWidgets) {
|
|
30
|
-
if ((clientToolkits?.length ?? 0) === 0 && (chatFeedWidgets?.length ?? 0) === 0) {
|
|
29
|
+
function resolveClientToolkitDescriptions(clientToolkits, chatFeedWidgets, clientTools) {
|
|
30
|
+
if ((clientToolkits?.length ?? 0) === 0 && (chatFeedWidgets?.length ?? 0) === 0 && (clientTools?.length ?? 0) === 0) {
|
|
31
31
|
return void 0;
|
|
32
32
|
}
|
|
33
33
|
const descriptions = [...clientToolkits ?? []];
|
|
34
34
|
const names = new Set(descriptions.map((description) => description.name));
|
|
35
|
-
for (const
|
|
36
|
-
if (names.has(
|
|
37
|
-
throw new Error(`client tool '${
|
|
35
|
+
for (const tool of [...clientTools ?? [], ...chatFeedWidgets ?? []]) {
|
|
36
|
+
if (names.has(tool.name)) {
|
|
37
|
+
throw new Error(`client tool '${tool.name}' has already been registered`);
|
|
38
38
|
}
|
|
39
|
-
names.add(
|
|
39
|
+
names.add(tool.name);
|
|
40
40
|
descriptions.push(new import_meshagent_agents.ClientToolkitDescription({
|
|
41
|
-
name:
|
|
42
|
-
title:
|
|
43
|
-
description:
|
|
44
|
-
inputSchema:
|
|
41
|
+
name: tool.name,
|
|
42
|
+
title: tool.title,
|
|
43
|
+
description: tool.description,
|
|
44
|
+
inputSchema: tool.inputSchema ?? {
|
|
45
45
|
type: "object",
|
|
46
46
|
additionalProperties: true
|
|
47
47
|
}
|
|
@@ -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;
|
|
@@ -312,15 +312,12 @@ function formatGroupedStatusDigits(value) {
|
|
|
312
312
|
function formatStatusSecondUnit(value) {
|
|
313
313
|
return value === 1 ? "second" : "seconds";
|
|
314
314
|
}
|
|
315
|
-
function formatThreadStatusText(text, startedAt,
|
|
315
|
+
function formatThreadStatusText(text, startedAt, linesAdded, linesRemoved) {
|
|
316
316
|
if (linesAdded != null || linesRemoved != null) {
|
|
317
317
|
const added = linesAdded != null ? "+" + formatGroupedStatusDigits(linesAdded) : null;
|
|
318
318
|
const removed = linesRemoved != null ? "-" + formatGroupedStatusDigits(linesRemoved) : null;
|
|
319
319
|
return [text, added, removed].filter((part) => part != null).join(" ");
|
|
320
320
|
}
|
|
321
|
-
if (totalBytes != null && totalBytes > 100) {
|
|
322
|
-
return text + " " + formatGroupedStatusDigits(totalBytes) + " bytes";
|
|
323
|
-
}
|
|
324
321
|
if (!(startedAt instanceof Date) || Number.isNaN(startedAt.getTime())) {
|
|
325
322
|
return text;
|
|
326
323
|
}
|
|
@@ -83,7 +83,7 @@ function ComposerActionButton({
|
|
|
83
83
|
type: "button",
|
|
84
84
|
size: "icon",
|
|
85
85
|
variant: "ghost",
|
|
86
|
-
className: (0, import_utils.cn)("relative size-9 rounded-full", disabled
|
|
86
|
+
className: (0, import_utils.cn)("relative size-9 rounded-full", disabled ? "opacity-55" : "cursor-pointer"),
|
|
87
87
|
disabled,
|
|
88
88
|
onClick,
|
|
89
89
|
title: disabled ? "Cancelling" : "Stop",
|
|
@@ -99,7 +99,7 @@ function ComposerActionButton({
|
|
|
99
99
|
{
|
|
100
100
|
type: "button",
|
|
101
101
|
size: "icon",
|
|
102
|
-
className: "size-9 rounded-full shadow-xs",
|
|
102
|
+
className: (0, import_utils.cn)("size-9 rounded-full shadow-xs", !disabled && "cursor-pointer"),
|
|
103
103
|
disabled,
|
|
104
104
|
onClick,
|
|
105
105
|
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;
|
|
@@ -38,7 +38,7 @@ var import_meshagent_react = require("@meshagent/meshagent-react");
|
|
|
38
38
|
var import_lucide_react = require("lucide-react");
|
|
39
39
|
var import_chat_hooks = require("./chat-hooks.js");
|
|
40
40
|
var import_utils = require("../lib/utils.js");
|
|
41
|
-
function useStatusLabel(text, startedAt,
|
|
41
|
+
function useStatusLabel(text, startedAt, linesAdded, linesRemoved) {
|
|
42
42
|
const normalizedText = text?.trim() ?? "";
|
|
43
43
|
const [tick, setTick] = React.useState(0);
|
|
44
44
|
React.useEffect(() => {
|
|
@@ -51,24 +51,23 @@ function useStatusLabel(text, startedAt, totalBytes, linesAdded, linesRemoved) {
|
|
|
51
51
|
return () => {
|
|
52
52
|
window.clearInterval(timer);
|
|
53
53
|
};
|
|
54
|
-
}, [normalizedText, startedAt,
|
|
54
|
+
}, [normalizedText, startedAt, linesAdded, linesRemoved]);
|
|
55
55
|
if (normalizedText === "") {
|
|
56
56
|
return null;
|
|
57
57
|
}
|
|
58
58
|
void tick;
|
|
59
|
-
return (0, import_chat_hooks.formatThreadStatusText)(normalizedText, startedAt,
|
|
59
|
+
return (0, import_chat_hooks.formatThreadStatusText)(normalizedText, startedAt, linesAdded, linesRemoved);
|
|
60
60
|
}
|
|
61
61
|
function ChatThreadStatusIndicator({
|
|
62
62
|
statusText,
|
|
63
63
|
startedAt,
|
|
64
|
-
totalBytes,
|
|
65
64
|
linesAdded,
|
|
66
65
|
linesRemoved,
|
|
67
66
|
reserveSpace = false,
|
|
68
67
|
size = 16,
|
|
69
68
|
className
|
|
70
69
|
}) {
|
|
71
|
-
const label = useStatusLabel(statusText, startedAt,
|
|
70
|
+
const label = useStatusLabel(statusText, startedAt, linesAdded, linesRemoved);
|
|
72
71
|
if (label == null) {
|
|
73
72
|
return reserveSpace ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { "aria-hidden": "true", style: { width: size, height: size }, className: (0, import_utils.cn)("inline-block shrink-0", className) }) : null;
|
|
74
73
|
}
|
|
@@ -115,7 +114,6 @@ function ChatTypingIndicator({
|
|
|
115
114
|
thinking,
|
|
116
115
|
statusText,
|
|
117
116
|
startedAt,
|
|
118
|
-
totalBytes,
|
|
119
117
|
linesAdded,
|
|
120
118
|
linesRemoved,
|
|
121
119
|
onCancel,
|
|
@@ -128,7 +126,6 @@ function ChatTypingIndicator({
|
|
|
128
126
|
const resolvedStatusText = useStatusLabel(
|
|
129
127
|
statusText?.trim() ? statusText : resolvedThinking ? "Thinking" : null,
|
|
130
128
|
startedAt,
|
|
131
|
-
totalBytes,
|
|
132
129
|
linesAdded,
|
|
133
130
|
linesRemoved
|
|
134
131
|
);
|
|
@@ -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[]>;
|
|
@@ -38,6 +38,7 @@ function DatasetAgentThread({
|
|
|
38
38
|
emptyStateTitle,
|
|
39
39
|
emptyStateDescription,
|
|
40
40
|
clientToolkits,
|
|
41
|
+
clientTools,
|
|
41
42
|
chatFeedWidgets,
|
|
42
43
|
toolChoice,
|
|
43
44
|
collapseMessages,
|
|
@@ -53,9 +54,17 @@ function DatasetAgentThread({
|
|
|
53
54
|
onEventsChanged
|
|
54
55
|
}) {
|
|
55
56
|
const normalizedPath = path.trim();
|
|
56
|
-
const activeRowsLoader = (0, import_react.useMemo)(() =>
|
|
57
|
+
const activeRowsLoader = (0, import_react.useMemo)(() => {
|
|
58
|
+
if (rowsLoader != null) return rowsLoader;
|
|
59
|
+
if (room != null) return defaultRowsLoader(room);
|
|
60
|
+
throw new Error("DatasetAgentThread requires either a room or a rows loader.");
|
|
61
|
+
}, [room, rowsLoader]);
|
|
57
62
|
const activeChatClient = (0, import_react.useMemo)(
|
|
58
|
-
() =>
|
|
63
|
+
() => {
|
|
64
|
+
if (chatClient != null) return chatClient;
|
|
65
|
+
if (room != null) return new import_meshagent_agents.MessagingChatClient({ room, agentName });
|
|
66
|
+
throw new Error("DatasetAgentThread requires either a room or a chat client.");
|
|
67
|
+
},
|
|
59
68
|
[agentName, chatClient, room]
|
|
60
69
|
);
|
|
61
70
|
const [persistedEvents, setPersistedEvents] = (0, import_react.useState)(null);
|
|
@@ -114,11 +123,12 @@ function DatasetAgentThread({
|
|
|
114
123
|
emptyStateTitle,
|
|
115
124
|
emptyStateDescription,
|
|
116
125
|
clientToolkits,
|
|
126
|
+
clientTools,
|
|
117
127
|
chatFeedWidgets,
|
|
118
128
|
toolChoice,
|
|
119
129
|
collapseMessages,
|
|
120
130
|
suggestions,
|
|
121
|
-
enableFileUpload,
|
|
131
|
+
enableFileUpload: enableFileUpload && room != null,
|
|
122
132
|
persistedEvents: persistedEvents ?? [],
|
|
123
133
|
deferLiveEvents: persistedEvents == null,
|
|
124
134
|
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;
|
|
@@ -44,6 +44,7 @@ function MultiThreadView({
|
|
|
44
44
|
emptyStateTitle = "Start a new thread",
|
|
45
45
|
emptyStateDescription = "Connect with this agent and your team",
|
|
46
46
|
clientToolkits,
|
|
47
|
+
clientTools,
|
|
47
48
|
chatFeedWidgets,
|
|
48
49
|
toolChoice,
|
|
49
50
|
suggestions,
|
|
@@ -98,6 +99,7 @@ function MultiThreadView({
|
|
|
98
99
|
emptyStateTitle,
|
|
99
100
|
emptyStateDescription,
|
|
100
101
|
clientToolkits,
|
|
102
|
+
clientTools,
|
|
101
103
|
chatFeedWidgets,
|
|
102
104
|
toolChoice,
|
|
103
105
|
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;
|
|
@@ -103,6 +103,7 @@ function NewChatThread({
|
|
|
103
103
|
emptyStateTitle,
|
|
104
104
|
emptyStateDescription,
|
|
105
105
|
clientToolkits,
|
|
106
|
+
clientTools,
|
|
106
107
|
chatFeedWidgets,
|
|
107
108
|
toolChoice,
|
|
108
109
|
suggestions,
|
|
@@ -120,13 +121,17 @@ function NewChatThread({
|
|
|
120
121
|
const activePath = controlledThreadPath ?? internalThreadPath;
|
|
121
122
|
const ownsChatClient = chatClient == null;
|
|
122
123
|
const activeChatClient = (0, import_react.useMemo)(
|
|
123
|
-
() =>
|
|
124
|
+
() => {
|
|
125
|
+
if (chatClient != null) return chatClient;
|
|
126
|
+
if (room != null) return new import_meshagent_agents.MessagingChatClient({ room, agentName });
|
|
127
|
+
throw new Error("NewChatThread requires either a room or a chat client.");
|
|
128
|
+
},
|
|
124
129
|
[agentName, chatClient, room]
|
|
125
130
|
);
|
|
126
131
|
const [clientVersion, setClientVersion] = (0, import_react.useState)(0);
|
|
127
132
|
const resolvedClientToolkits = (0, import_react.useMemo)(
|
|
128
|
-
() => (0, import_chat_feed_widget.resolveClientToolkitDescriptions)(clientToolkits, chatFeedWidgets),
|
|
129
|
-
[chatFeedWidgets, clientToolkits]
|
|
133
|
+
() => (0, import_chat_feed_widget.resolveClientToolkitDescriptions)(clientToolkits, chatFeedWidgets, clientTools),
|
|
134
|
+
[chatFeedWidgets, clientToolkits, clientTools]
|
|
130
135
|
);
|
|
131
136
|
(0, import_react.useEffect)(() => {
|
|
132
137
|
return () => {
|
|
@@ -165,6 +170,7 @@ function NewChatThread({
|
|
|
165
170
|
setWaitingForAgent(false);
|
|
166
171
|
}, [agentName, controlledThreadPath, room]);
|
|
167
172
|
const selectNewThreadAttachments = (0, import_react.useCallback)((files) => {
|
|
173
|
+
if (room == null) return;
|
|
168
174
|
const nextAttachments = files.map((file) => new import_file_attachment.MeshagentFileUpload(
|
|
169
175
|
room,
|
|
170
176
|
`uploaded-files/${file.name}`,
|
|
@@ -187,7 +193,7 @@ function NewChatThread({
|
|
|
187
193
|
}
|
|
188
194
|
const operationId = activeOperationRef.current + 1;
|
|
189
195
|
activeOperationRef.current = operationId;
|
|
190
|
-
const initialTargetAgent = activeChatClient.agentParticipant() ?? findTargetAgent(room, agentName);
|
|
196
|
+
const initialTargetAgent = activeChatClient.agentParticipant() ?? (room == null ? null : findTargetAgent(room, agentName));
|
|
191
197
|
setWaitingForAgent(initialTargetAgent === null && chatClient == null);
|
|
192
198
|
setCreatingNewThread(initialTargetAgent !== null || chatClient != null);
|
|
193
199
|
setNewThreadError(null);
|
|
@@ -206,7 +212,7 @@ function NewChatThread({
|
|
|
206
212
|
const result = await activeChatClient.startThread({
|
|
207
213
|
message: text,
|
|
208
214
|
attachments: newThreadAttachments.map((attachment) => new import_meshagent_agents.AgentFileContent({ url: attachment.path })),
|
|
209
|
-
senderName: getParticipantName(room.localParticipant) || void 0,
|
|
215
|
+
senderName: room == null ? activeChatClient.localParticipantName() : getParticipantName(room.localParticipant) || void 0,
|
|
210
216
|
clientToolkits: resolvedClientToolkits
|
|
211
217
|
});
|
|
212
218
|
ensureOperationActive(operationId, activeOperationRef);
|
|
@@ -253,7 +259,7 @@ function NewChatThread({
|
|
|
253
259
|
if (knownAgentName) {
|
|
254
260
|
return displayParticipantName(knownAgentName);
|
|
255
261
|
}
|
|
256
|
-
const targetAgent = activeChatClient.agentParticipant() ?? findTargetAgent(room);
|
|
262
|
+
const targetAgent = activeChatClient.agentParticipant() ?? (room == null ? null : findTargetAgent(room));
|
|
257
263
|
return displayParticipantName(targetAgent ? getParticipantName(targetAgent) : null);
|
|
258
264
|
}, [activeChatClient, agentName, clientVersion, room]);
|
|
259
265
|
const pendingStatusText = waitingForAgent ? `Waiting for ${targetAgentLabel} to be ready.` : creatingNewThread ? `Starting a thread with ${targetAgentLabel}.` : null;
|
|
@@ -269,18 +275,19 @@ function NewChatThread({
|
|
|
269
275
|
"ul",
|
|
270
276
|
{
|
|
271
277
|
"aria-label": "Starter suggestions",
|
|
272
|
-
className: "mx-auto flex
|
|
278
|
+
className: "mx-auto flex w-full max-w-[912px] flex-wrap gap-2 px-4 pt-2 pb-1",
|
|
273
279
|
children: visibleSuggestions.map((suggestion, index) => {
|
|
274
280
|
const text = suggestion.prompt?.trim() || suggestion.label.trim();
|
|
275
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("li", { className: "
|
|
281
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("li", { className: "min-w-0 max-w-full", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
276
282
|
import_button.Button,
|
|
277
283
|
{
|
|
278
284
|
type: "button",
|
|
279
285
|
variant: "outline",
|
|
280
|
-
className: "h-auto min-h-8 rounded-full px-3 py-1.5",
|
|
286
|
+
className: "h-auto min-h-8 max-w-full overflow-hidden rounded-full px-3 py-1.5 text-left text-sm leading-snug",
|
|
287
|
+
title: suggestion.label,
|
|
281
288
|
disabled: creatingNewThread || waitingForAgent,
|
|
282
289
|
onClick: () => void handleCreateThread({ text }),
|
|
283
|
-
children: suggestion.label
|
|
290
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "min-w-0 truncate", children: suggestion.label })
|
|
284
291
|
}
|
|
285
292
|
) }, index);
|
|
286
293
|
})
|
|
@@ -293,7 +300,7 @@ function NewChatThread({
|
|
|
293
300
|
attachments: newThreadAttachments,
|
|
294
301
|
onFilesSelected: selectNewThreadAttachments,
|
|
295
302
|
setAttachments: setNewThreadAttachments,
|
|
296
|
-
enableFileUpload,
|
|
303
|
+
enableFileUpload: enableFileUpload && room != null,
|
|
297
304
|
value: newThreadDraft,
|
|
298
305
|
onValueChange: setNewThreadDraft,
|
|
299
306
|
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;
|
|
@@ -40,6 +40,15 @@ function MultiThreadUnavailable() {
|
|
|
40
40
|
] })
|
|
41
41
|
] }) }) });
|
|
42
42
|
}
|
|
43
|
+
function RoomUnavailable({ message }) {
|
|
44
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "flex min-h-0 flex-1 items-center justify-center px-4 py-8", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "w-full max-w-[912px] rounded-3xl border border-destructive/30 bg-destructive/5 p-6 text-destructive", children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex items-start gap-3", children: [
|
|
45
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_lucide_react.AlertTriangle, { className: "mt-0.5 h-5 w-5 shrink-0" }),
|
|
46
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
|
|
47
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("h2", { className: "text-lg font-semibold", children: "Unable to open chat" }),
|
|
48
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "mt-1 text-sm text-destructive/80", children: message })
|
|
49
|
+
] })
|
|
50
|
+
] }) }) });
|
|
51
|
+
}
|
|
43
52
|
function ThreadView({
|
|
44
53
|
room,
|
|
45
54
|
chatClient = null,
|
|
@@ -60,6 +69,7 @@ function ThreadView({
|
|
|
60
69
|
onSelectedThreadResolved,
|
|
61
70
|
newThreadResetVersion = 0,
|
|
62
71
|
clientToolkits,
|
|
72
|
+
clientTools,
|
|
63
73
|
chatFeedWidgets,
|
|
64
74
|
toolChoice,
|
|
65
75
|
collapseMessages = true,
|
|
@@ -80,6 +90,12 @@ function ThreadView({
|
|
|
80
90
|
const resolvedDocumentPath = normalizePath(documentPath ?? path);
|
|
81
91
|
const resolvedSingleThreadPath = resolvedDocumentPath ?? (0, import_conversation_descriptor.chatDocumentPath)(agentName, { threadDir });
|
|
82
92
|
const activeChatClient = chatClient ?? void 0;
|
|
93
|
+
if (room == null && activeChatClient == null) {
|
|
94
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(RoomUnavailable, { message: "ThreadView requires either a room or a chat client." });
|
|
95
|
+
}
|
|
96
|
+
if (threadSource === "dataset" && room == null && rowsLoader == null) {
|
|
97
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(RoomUnavailable, { message: "Dataset-backed threads require a room connection or rows loader." });
|
|
98
|
+
}
|
|
83
99
|
if (threadDisplayMode !== import_conversation_descriptor.ChatThreadDisplayMode.MultiThreadComposer) {
|
|
84
100
|
if (threadSource === "dataset") {
|
|
85
101
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
@@ -94,6 +110,7 @@ function ThreadView({
|
|
|
94
110
|
emptyStateTitle,
|
|
95
111
|
emptyStateDescription,
|
|
96
112
|
clientToolkits,
|
|
113
|
+
clientTools,
|
|
97
114
|
chatFeedWidgets,
|
|
98
115
|
toolChoice,
|
|
99
116
|
collapseMessages,
|
|
@@ -120,6 +137,7 @@ function ThreadView({
|
|
|
120
137
|
emptyStateTitle,
|
|
121
138
|
emptyStateDescription,
|
|
122
139
|
clientToolkits,
|
|
140
|
+
clientTools,
|
|
123
141
|
chatFeedWidgets,
|
|
124
142
|
toolChoice,
|
|
125
143
|
collapseMessages,
|
|
@@ -154,6 +172,7 @@ function ThreadView({
|
|
|
154
172
|
newThreadResetVersion,
|
|
155
173
|
centerComposer,
|
|
156
174
|
clientToolkits,
|
|
175
|
+
clientTools,
|
|
157
176
|
chatFeedWidgets,
|
|
158
177
|
toolChoice,
|
|
159
178
|
suggestions,
|
|
@@ -171,6 +190,7 @@ function ThreadView({
|
|
|
171
190
|
emptyStateTitle: startNewThreadTitle,
|
|
172
191
|
emptyStateDescription: startNewThreadDescription,
|
|
173
192
|
clientToolkits,
|
|
193
|
+
clientTools,
|
|
174
194
|
chatFeedWidgets,
|
|
175
195
|
toolChoice,
|
|
176
196
|
collapseMessages,
|
|
@@ -195,6 +215,7 @@ function ThreadView({
|
|
|
195
215
|
emptyStateTitle: startNewThreadTitle,
|
|
196
216
|
emptyStateDescription: startNewThreadDescription,
|
|
197
217
|
clientToolkits,
|
|
218
|
+
clientTools,
|
|
198
219
|
chatFeedWidgets,
|
|
199
220
|
toolChoice,
|
|
200
221
|
collapseMessages,
|
|
@@ -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 type { AgentMessage, AgentMessageEvent, BaseChatClient, ClientToolkitDescription } from "@meshagent/meshagent-agents";
|
|
4
4
|
import type { AgentUsageSnapshot } from "./chat-thread-timeline.js";
|
|
5
5
|
export { AgentUsageSnapshot, shouldReplaceAgentUsageSnapshot } from "./chat-thread-timeline.js";
|
|
@@ -18,15 +18,19 @@ export interface AgentThreadSuggestion {
|
|
|
18
18
|
prompt?: string;
|
|
19
19
|
}
|
|
20
20
|
export interface AgentThreadProps {
|
|
21
|
-
room
|
|
21
|
+
room?: RoomClient;
|
|
22
22
|
path: string;
|
|
23
23
|
chatClient?: BaseChatClient;
|
|
24
24
|
disposeChatClient?: boolean;
|
|
25
25
|
agentName?: string;
|
|
26
26
|
emptyStateTitle?: string;
|
|
27
27
|
emptyStateDescription?: string;
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
/** Description-only client tools whose execution is owned outside this component. */
|
|
29
|
+
clientToolkits?: readonly ClientToolkitDescription[];
|
|
30
|
+
/** Client tools executed locally without rendering conversation-feed rows. */
|
|
31
|
+
clientTools?: readonly Tool[];
|
|
32
|
+
/** Client tools executed locally with custom feed rendering or feed behavior. */
|
|
33
|
+
chatFeedWidgets?: readonly ChatFeedWidget[];
|
|
30
34
|
toolChoice?: AgentToolChoice;
|
|
31
35
|
collapseMessages?: boolean;
|
|
32
36
|
suggestions?: readonly AgentThreadSuggestion[];
|
|
@@ -79,9 +83,9 @@ export interface EventLineProps {
|
|
|
79
83
|
}
|
|
80
84
|
export declare function EventLine({ headline, details, state, failed, className }: EventLineProps): ReactElement | null;
|
|
81
85
|
export interface ChatThreadPreviewProps {
|
|
82
|
-
room
|
|
86
|
+
room?: RoomClient;
|
|
83
87
|
path: string;
|
|
84
88
|
className?: string;
|
|
85
89
|
}
|
|
86
90
|
export declare function ChatThreadPreview({ room, path, className }: ChatThreadPreviewProps): ReactElement;
|
|
87
|
-
export declare function AgentThread({ room, path, chatClient, disposeChatClient, agentName, emptyStateTitle, emptyStateDescription, clientToolkits, chatFeedWidgets, collapseMessages, suggestions, enableFileUpload, persistedEvents, deferLiveEvents, loadThread, injectPersistedEvents, composerDisabled: composerDisabledProp, closeThreadOnUnmount, onPersistedEventsInjectionStarted, onPersistedEventsInjected, onEventsChanged, }: AgentThreadProps): ReactElement;
|
|
91
|
+
export declare function AgentThread({ room, path, chatClient, disposeChatClient, agentName, emptyStateTitle, emptyStateDescription, clientToolkits, clientTools, chatFeedWidgets, collapseMessages, suggestions, enableFileUpload, persistedEvents, deferLiveEvents, loadThread, injectPersistedEvents, composerDisabled: composerDisabledProp, closeThreadOnUnmount, onPersistedEventsInjectionStarted, onPersistedEventsInjected, onEventsChanged, }: AgentThreadProps): ReactElement;
|