@meshagent/meshagent-tailwind 0.49.1 → 0.51.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.
Files changed (44) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/README.md +30 -0
  3. package/dist/cjs/chat/agent-thread.d.ts +17 -12
  4. package/dist/cjs/chat/agent-thread.js +166 -284
  5. package/dist/cjs/chat/chat-bot-view.d.ts +5 -4
  6. package/dist/cjs/chat/chat-bot-view.js +2 -0
  7. package/dist/cjs/chat/chat-feed-widget.d.ts +3 -4
  8. package/dist/cjs/chat/chat-feed-widget.js +10 -10
  9. package/dist/cjs/chat/chat-hooks.d.ts +1 -1
  10. package/dist/cjs/chat/chat-hooks.js +1 -4
  11. package/dist/cjs/chat/chat-input.js +2 -2
  12. package/dist/cjs/chat/chat-typing-indicator.d.ts +2 -4
  13. package/dist/cjs/chat/chat-typing-indicator.js +4 -7
  14. package/dist/cjs/chat/dataset-agent-thread.d.ts +10 -8
  15. package/dist/cjs/chat/dataset-agent-thread.js +13 -5
  16. package/dist/cjs/chat/multi-thread-view.d.ts +7 -7
  17. package/dist/cjs/chat/multi-thread-view.js +2 -2
  18. package/dist/cjs/chat/new-chat-thread.d.ts +7 -6
  19. package/dist/cjs/chat/new-chat-thread.js +29 -52
  20. package/dist/cjs/chat/thread-view.d.ts +7 -7
  21. package/dist/cjs/chat/thread-view.js +21 -6
  22. package/dist/cjs/components/ui/form.d.ts +1 -1
  23. package/dist/esm/chat/agent-thread.d.ts +17 -12
  24. package/dist/esm/chat/agent-thread.js +168 -286
  25. package/dist/esm/chat/chat-bot-view.d.ts +5 -4
  26. package/dist/esm/chat/chat-bot-view.js +2 -0
  27. package/dist/esm/chat/chat-feed-widget.d.ts +3 -4
  28. package/dist/esm/chat/chat-feed-widget.js +10 -10
  29. package/dist/esm/chat/chat-hooks.d.ts +1 -1
  30. package/dist/esm/chat/chat-hooks.js +1 -4
  31. package/dist/esm/chat/chat-input.js +2 -2
  32. package/dist/esm/chat/chat-typing-indicator.d.ts +2 -4
  33. package/dist/esm/chat/chat-typing-indicator.js +4 -7
  34. package/dist/esm/chat/dataset-agent-thread.d.ts +10 -8
  35. package/dist/esm/chat/dataset-agent-thread.js +13 -5
  36. package/dist/esm/chat/multi-thread-view.d.ts +7 -7
  37. package/dist/esm/chat/multi-thread-view.js +2 -2
  38. package/dist/esm/chat/new-chat-thread.d.ts +7 -6
  39. package/dist/esm/chat/new-chat-thread.js +29 -52
  40. package/dist/esm/chat/thread-view.d.ts +7 -7
  41. package/dist/esm/chat/thread-view.js +21 -6
  42. package/dist/esm/components/ui/form.d.ts +1 -1
  43. package/dist/index.css +1 -1
  44. package/package.json +6 -6
@@ -1,5 +1,5 @@
1
1
  import type { ReactElement } from "react";
2
- import type { Participant, RoomClient } from "@meshagent/meshagent";
2
+ import type { Participant, RoomClient, Tool } from "@meshagent/meshagent";
3
3
  import type { AgentMessage, AgentMessageEvent, BaseChatClient, ClientToolkitDescription } from "@meshagent/meshagent-agents";
4
4
  import type { AgentToolChoice } from "./agent-thread.js";
5
5
  import type { DatasetThreadRowsLoader } from "./dataset-agent-thread.js";
@@ -33,8 +33,9 @@ export interface ChatBotViewProps {
33
33
  showThreadList?: boolean;
34
34
  threadListWidth?: number;
35
35
  threadListCollapsedHeight?: number;
36
- clientToolkits?: ClientToolkitDescription[];
37
- chatFeedWidgets?: ChatFeedWidget[];
36
+ clientToolkits?: readonly ClientToolkitDescription[];
37
+ clientTools?: readonly Tool[];
38
+ chatFeedWidgets?: readonly ChatFeedWidget[];
38
39
  toolChoice?: AgentToolChoice;
39
40
  collapseMessages?: boolean;
40
41
  enableFileUpload?: boolean;
@@ -50,4 +51,4 @@ export interface ChatBotViewProps {
50
51
  onEventsChanged?: (threadId: string, events: readonly AgentMessageEvent[], latestMessage: AgentMessage | null) => void;
51
52
  onThreadStarted?: (threadId: string, events: readonly AgentMessageEvent[]) => Promise<void> | void;
52
53
  }
53
- export declare function ChatBotView({ room, chatClient, disposeChatClient, path, documentPath, agentName, threadDisplayMode, threadDir, toolkit, tool, centerComposer, emptyStateTitle, emptyStateDescription, startNewThreadTitle, startNewThreadDescription, selectedThreadPath, selectedThreadDisplayName, onSelectedThreadPathChanged, onSelectedThreadResolved, onThreadResolved, newThreadResetVersion, showThreadList, threadListWidth, threadListCollapsedHeight, clientToolkits, chatFeedWidgets, toolChoice, collapseMessages, enableFileUpload, threadSource, rowsLoader, persistedEvents, loadThread, injectPersistedEvents, composerDisabled, closeThreadOnUnmount, onPersistedEventsInjectionStarted, onPersistedEventsInjected, onEventsChanged, onThreadStarted, }: ChatBotViewProps): ReactElement;
54
+ export declare function ChatBotView({ room, chatClient, disposeChatClient, path, documentPath, agentName, threadDisplayMode, threadDir, toolkit, tool, centerComposer, emptyStateTitle, emptyStateDescription, startNewThreadTitle, startNewThreadDescription, selectedThreadPath, selectedThreadDisplayName, onSelectedThreadPathChanged, onSelectedThreadResolved, onThreadResolved, newThreadResetVersion, showThreadList, threadListWidth, threadListCollapsedHeight, clientToolkits, clientTools, chatFeedWidgets, toolChoice, collapseMessages, enableFileUpload, threadSource, rowsLoader, persistedEvents, loadThread, injectPersistedEvents, composerDisabled, closeThreadOnUnmount, onPersistedEventsInjectionStarted, onPersistedEventsInjected, onEventsChanged, onThreadStarted, }: ChatBotViewProps): ReactElement;
@@ -59,6 +59,7 @@ function ChatBotView({
59
59
  threadListWidth = 280,
60
60
  threadListCollapsedHeight = 220,
61
61
  clientToolkits,
62
+ clientTools,
62
63
  chatFeedWidgets,
63
64
  toolChoice,
64
65
  collapseMessages = true,
@@ -160,6 +161,7 @@ function ChatBotView({
160
161
  onSelectedThreadResolved: emitResolvedThread,
161
162
  newThreadResetVersion,
162
163
  clientToolkits,
164
+ clientTools,
163
165
  chatFeedWidgets,
164
166
  toolChoice,
165
167
  collapseMessages,
@@ -2,15 +2,14 @@ import type { ReactElement } from "react";
2
2
  import { Tool } from "@meshagent/meshagent";
3
3
  import type { Content } from "@meshagent/meshagent";
4
4
  import { ClientToolkitDescription } from "@meshagent/meshagent-agents";
5
- import type { AgentThreadSuggestion } from "./agent-thread.js";
6
5
  export type ToolCallStatus = "queued" | "in_progress" | "completed" | "failed";
7
6
  export interface ToolCall {
8
7
  status: ToolCallStatus;
9
8
  input: Record<string, unknown>;
10
9
  output?: Content;
10
+ sendMessage?: (message: string) => void;
11
11
  }
12
12
  export declare abstract class ChatFeedWidget extends Tool {
13
- abstract render(toolCall: ToolCall): ReactElement;
14
- getFollowUpSuggestions?(toolCall: ToolCall): readonly AgentThreadSuggestion[];
13
+ abstract render(toolCall: ToolCall): ReactElement | null;
15
14
  }
16
- export declare function resolveClientToolkitDescriptions(clientToolkits: ClientToolkitDescription[] | undefined, chatFeedWidgets: ChatFeedWidget[] | undefined): ClientToolkitDescription[] | undefined;
15
+ export declare function resolveClientToolkitDescriptions(clientToolkits: readonly ClientToolkitDescription[] | undefined, chatFeedWidgets: readonly ChatFeedWidget[] | undefined, clientTools?: readonly Tool[]): ClientToolkitDescription[] | undefined;
@@ -2,22 +2,22 @@ import { Tool } from "@meshagent/meshagent";
2
2
  import { ClientToolkitDescription } from "@meshagent/meshagent-agents";
3
3
  class ChatFeedWidget extends Tool {
4
4
  }
5
- function resolveClientToolkitDescriptions(clientToolkits, chatFeedWidgets) {
6
- if ((clientToolkits?.length ?? 0) === 0 && (chatFeedWidgets?.length ?? 0) === 0) {
5
+ function resolveClientToolkitDescriptions(clientToolkits, chatFeedWidgets, clientTools) {
6
+ if ((clientToolkits?.length ?? 0) === 0 && (chatFeedWidgets?.length ?? 0) === 0 && (clientTools?.length ?? 0) === 0) {
7
7
  return void 0;
8
8
  }
9
9
  const descriptions = [...clientToolkits ?? []];
10
10
  const names = new Set(descriptions.map((description) => description.name));
11
- for (const widget of chatFeedWidgets ?? []) {
12
- if (names.has(widget.name)) {
13
- throw new Error(`client tool '${widget.name}' has already been registered`);
11
+ for (const tool of [...clientTools ?? [], ...chatFeedWidgets ?? []]) {
12
+ if (names.has(tool.name)) {
13
+ throw new Error(`client tool '${tool.name}' has already been registered`);
14
14
  }
15
- names.add(widget.name);
15
+ names.add(tool.name);
16
16
  descriptions.push(new ClientToolkitDescription({
17
- name: widget.name,
18
- title: widget.title,
19
- description: widget.description,
20
- inputSchema: widget.inputSchema ?? {
17
+ name: tool.name,
18
+ title: tool.title,
19
+ description: tool.description,
20
+ inputSchema: tool.inputSchema ?? {
21
21
  type: "object",
22
22
  additionalProperties: true
23
23
  }
@@ -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, totalBytes?: number | null, linesAdded?: number | null, linesRemoved?: number | null): string;
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, totalBytes, linesAdded, linesRemoved) {
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 && "opacity-55"),
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, totalBytes, linesAdded, linesRemoved, reserveSpace, size, className, }: ChatThreadStatusIndicatorProps): React.ReactElement | null;
28
- export declare function ChatTypingIndicator({ room, path, typing, thinking, statusText, startedAt, totalBytes, linesAdded, linesRemoved, onCancel, showCancelButton, cancelEnabled, }: ChatTypingIndicatorProps): React.ReactElement | null;
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, totalBytes, linesAdded, linesRemoved) {
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, totalBytes, linesAdded, linesRemoved]);
20
+ }, [normalizedText, startedAt, linesAdded, linesRemoved]);
21
21
  if (normalizedText === "") {
22
22
  return null;
23
23
  }
24
24
  void tick;
25
- return formatThreadStatusText(normalizedText, startedAt, totalBytes, linesAdded, linesRemoved);
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, totalBytes, linesAdded, linesRemoved);
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,8 +1,8 @@
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
- import { type AgentThreadSuggestion, type AgentToolChoice } from "./agent-thread.js";
5
+ import { type AgentToolChoice } from "./agent-thread.js";
6
6
  import type { ChatFeedWidget } from "./chat-feed-widget.js";
7
7
  export type DatasetThreadRow = Record<string, unknown>;
8
8
  export type DatasetThreadRows = Iterable<DatasetThreadRow>;
@@ -17,7 +17,7 @@ export interface DatasetThreadRef {
17
17
  table: string;
18
18
  }
19
19
  export interface DatasetAgentThreadProps {
20
- room: RoomClient;
20
+ room?: RoomClient;
21
21
  path: string;
22
22
  chatClient?: BaseChatClient;
23
23
  disposeChatClient?: boolean;
@@ -25,11 +25,11 @@ export interface DatasetAgentThreadProps {
25
25
  rowsLoader?: DatasetThreadRowsLoader;
26
26
  emptyStateTitle?: string;
27
27
  emptyStateDescription?: string;
28
- clientToolkits?: ClientToolkitDescription[];
29
- chatFeedWidgets?: ChatFeedWidget[];
28
+ clientToolkits?: readonly ClientToolkitDescription[];
29
+ clientTools?: readonly Tool[];
30
+ chatFeedWidgets?: readonly ChatFeedWidget[];
30
31
  toolChoice?: AgentToolChoice;
31
32
  collapseMessages?: boolean;
32
- suggestions?: readonly AgentThreadSuggestion[];
33
33
  enableFileUpload?: boolean;
34
34
  retryMissingTableMs?: number;
35
35
  loadThread?: boolean;
@@ -40,8 +40,10 @@ export interface DatasetAgentThreadProps {
40
40
  onPersistedEventsInjected?: (error: unknown | null) => void;
41
41
  onEventsChanged?: (threadId: string, events: readonly AgentMessageEventType[], latestMessage: AgentMessageType | null) => void;
42
42
  }
43
- export type RoomDatasetAgentThreadProps = Omit<DatasetAgentThreadProps, "rowsLoader">;
44
- export declare function DatasetAgentThread({ room, path, chatClient, disposeChatClient, agentName, rowsLoader, emptyStateTitle, emptyStateDescription, clientToolkits, chatFeedWidgets, toolChoice, collapseMessages, suggestions, enableFileUpload, retryMissingTableMs, loadThread, injectPersistedEvents, composerDisabled, closeThreadOnUnmount, onPersistedEventsInjectionStarted, onPersistedEventsInjected, onEventsChanged, }: DatasetAgentThreadProps): ReactElement;
43
+ export type RoomDatasetAgentThreadProps = Omit<DatasetAgentThreadProps, "room" | "rowsLoader"> & {
44
+ room: RoomClient;
45
+ };
46
+ export declare function DatasetAgentThread({ room, path, chatClient, disposeChatClient, agentName, rowsLoader, emptyStateTitle, emptyStateDescription, clientToolkits, clientTools, chatFeedWidgets, toolChoice, collapseMessages, enableFileUpload, retryMissingTableMs, loadThread, injectPersistedEvents, composerDisabled, closeThreadOnUnmount, onPersistedEventsInjectionStarted, onPersistedEventsInjected, onEventsChanged, }: DatasetAgentThreadProps): ReactElement;
45
47
  export declare function RoomDatasetAgentThread(props: RoomDatasetAgentThreadProps): ReactElement;
46
48
  export declare function parseDatasetThreadRef(path: string): DatasetThreadRef;
47
49
  export declare function loadDatasetThreadEvents(loader: DatasetThreadRowsLoader, args: DatasetThreadRowsLoaderArgs): Promise<AgentMessageEvent[]>;
@@ -16,10 +16,10 @@ function DatasetAgentThread({
16
16
  emptyStateTitle,
17
17
  emptyStateDescription,
18
18
  clientToolkits,
19
+ clientTools,
19
20
  chatFeedWidgets,
20
21
  toolChoice,
21
22
  collapseMessages,
22
- suggestions,
23
23
  enableFileUpload = false,
24
24
  retryMissingTableMs = 500,
25
25
  loadThread = true,
@@ -31,9 +31,17 @@ function DatasetAgentThread({
31
31
  onEventsChanged
32
32
  }) {
33
33
  const normalizedPath = path.trim();
34
- const activeRowsLoader = useMemo(() => rowsLoader ?? defaultRowsLoader(room), [room, rowsLoader]);
34
+ const activeRowsLoader = useMemo(() => {
35
+ if (rowsLoader != null) return rowsLoader;
36
+ if (room != null) return defaultRowsLoader(room);
37
+ throw new Error("DatasetAgentThread requires either a room or a rows loader.");
38
+ }, [room, rowsLoader]);
35
39
  const activeChatClient = useMemo(
36
- () => chatClient ?? new MessagingChatClient({ room, agentName }),
40
+ () => {
41
+ if (chatClient != null) return chatClient;
42
+ if (room != null) return new MessagingChatClient({ room, agentName });
43
+ throw new Error("DatasetAgentThread requires either a room or a chat client.");
44
+ },
37
45
  [agentName, chatClient, room]
38
46
  );
39
47
  const [persistedEvents, setPersistedEvents] = useState(null);
@@ -92,11 +100,11 @@ function DatasetAgentThread({
92
100
  emptyStateTitle,
93
101
  emptyStateDescription,
94
102
  clientToolkits,
103
+ clientTools,
95
104
  chatFeedWidgets,
96
105
  toolChoice,
97
106
  collapseMessages,
98
- suggestions,
99
- enableFileUpload,
107
+ enableFileUpload: enableFileUpload && room != null,
100
108
  persistedEvents: persistedEvents ?? [],
101
109
  deferLiveEvents: persistedEvents == null,
102
110
  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
- import type { AgentThreadSuggestion, AgentToolChoice } from "./agent-thread.js";
4
+ import type { 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: RoomClient;
8
+ room?: RoomClient;
9
9
  chatClient?: BaseChatClient;
10
10
  disposeChatClient?: boolean;
11
11
  agentName: string;
@@ -19,11 +19,11 @@ export interface MultiThreadViewProps {
19
19
  centerComposer?: boolean;
20
20
  emptyStateTitle?: string;
21
21
  emptyStateDescription?: string;
22
- clientToolkits?: ClientToolkitDescription[];
23
- chatFeedWidgets?: ChatFeedWidget[];
22
+ clientToolkits?: readonly ClientToolkitDescription[];
23
+ clientTools?: readonly Tool[];
24
+ chatFeedWidgets?: readonly ChatFeedWidget[];
24
25
  toolChoice?: AgentToolChoice;
25
- suggestions?: readonly AgentThreadSuggestion[];
26
26
  enableFileUpload?: boolean;
27
27
  onThreadStarted?: (threadId: string, events: readonly AgentMessageEvent[]) => Promise<void> | void;
28
28
  }
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;
29
+ export declare function MultiThreadView({ room, chatClient, disposeChatClient, agentName, builder, toolkit, tool, selectedThreadPath, onSelectedThreadPathChanged, onSelectedThreadResolved, newThreadResetVersion, centerComposer, emptyStateTitle, emptyStateDescription, clientToolkits, clientTools, chatFeedWidgets, toolChoice, enableFileUpload, onThreadStarted, }: MultiThreadViewProps): ReactElement;
@@ -21,9 +21,9 @@ 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
- suggestions,
27
27
  enableFileUpload = false,
28
28
  onThreadStarted
29
29
  }) {
@@ -75,9 +75,9 @@ function MultiThreadView({
75
75
  emptyStateTitle,
76
76
  emptyStateDescription,
77
77
  clientToolkits,
78
+ clientTools,
78
79
  chatFeedWidgets,
79
80
  toolChoice,
80
- suggestions,
81
81
  enableFileUpload,
82
82
  onThreadStarted
83
83
  },
@@ -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
- import type { AgentThreadSuggestion, AgentToolChoice } from "./agent-thread.js";
5
+ import type { 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: RoomClient;
9
+ room?: RoomClient;
9
10
  chatClient?: BaseChatClient;
10
11
  disposeChatClient?: boolean;
11
12
  agentName: string;
@@ -18,11 +19,11 @@ export interface NewChatThreadProps {
18
19
  centerComposer?: boolean;
19
20
  emptyStateTitle?: string;
20
21
  emptyStateDescription?: string;
21
- clientToolkits?: ClientToolkitDescription[];
22
- chatFeedWidgets?: ChatFeedWidget[];
22
+ clientToolkits?: readonly ClientToolkitDescription[];
23
+ clientTools?: readonly Tool[];
24
+ chatFeedWidgets?: readonly ChatFeedWidget[];
23
25
  toolChoice?: AgentToolChoice;
24
- suggestions?: readonly AgentThreadSuggestion[];
25
26
  enableFileUpload?: boolean;
26
27
  onThreadStarted?: (threadId: string, events: readonly AgentMessageEvent[]) => Promise<void> | void;
27
28
  }
28
- export declare function NewChatThread({ room, chatClient, disposeChatClient, agentName, builder, selectedThreadPath, onThreadPathChanged, onThreadResolved, centerComposer, emptyStateTitle, emptyStateDescription, clientToolkits, chatFeedWidgets, toolChoice, suggestions, enableFileUpload, onThreadStarted, }: NewChatThreadProps): ReactElement;
29
+ export declare function NewChatThread({ room, chatClient, disposeChatClient, agentName, builder, selectedThreadPath, onThreadPathChanged, onThreadResolved, centerComposer, emptyStateTitle, emptyStateDescription, clientToolkits, clientTools, chatFeedWidgets, toolChoice, enableFileUpload, onThreadStarted, }: NewChatThreadProps): ReactElement;
@@ -4,7 +4,6 @@ import { AgentFileContent, MessagingChatClient } from "@meshagent/meshagent-agen
4
4
  import { resolveClientToolkitDescriptions } from "./chat-feed-widget.js";
5
5
  import { defaultThreadDisplayNameFromPath } from "./conversation-descriptor.js";
6
6
  import { ChatInput } from "./chat-input.js";
7
- import { Button } from "../components/ui/button.js";
8
7
  import { MeshagentFileUpload, fileToAsyncIterable } from "./file-attachment.js";
9
8
  import { Toaster } from "../components/ui/sonner.js";
10
9
  class NewThreadCancelledError extends Error {
@@ -80,9 +79,9 @@ function NewChatThread({
80
79
  emptyStateTitle,
81
80
  emptyStateDescription,
82
81
  clientToolkits,
82
+ clientTools,
83
83
  chatFeedWidgets,
84
84
  toolChoice,
85
- suggestions,
86
85
  enableFileUpload = false,
87
86
  onThreadStarted
88
87
  }) {
@@ -97,13 +96,17 @@ function NewChatThread({
97
96
  const activePath = controlledThreadPath ?? internalThreadPath;
98
97
  const ownsChatClient = chatClient == null;
99
98
  const activeChatClient = useMemo(
100
- () => chatClient ?? new MessagingChatClient({ room, agentName }),
99
+ () => {
100
+ if (chatClient != null) return chatClient;
101
+ if (room != null) return new MessagingChatClient({ room, agentName });
102
+ throw new Error("NewChatThread requires either a room or a chat client.");
103
+ },
101
104
  [agentName, chatClient, room]
102
105
  );
103
106
  const [clientVersion, setClientVersion] = useState(0);
104
107
  const resolvedClientToolkits = useMemo(
105
- () => resolveClientToolkitDescriptions(clientToolkits, chatFeedWidgets),
106
- [chatFeedWidgets, clientToolkits]
108
+ () => resolveClientToolkitDescriptions(clientToolkits, chatFeedWidgets, clientTools),
109
+ [chatFeedWidgets, clientToolkits, clientTools]
107
110
  );
108
111
  useEffect(() => {
109
112
  return () => {
@@ -142,6 +145,7 @@ function NewChatThread({
142
145
  setWaitingForAgent(false);
143
146
  }, [agentName, controlledThreadPath, room]);
144
147
  const selectNewThreadAttachments = useCallback((files) => {
148
+ if (room == null) return;
145
149
  const nextAttachments = files.map((file) => new MeshagentFileUpload(
146
150
  room,
147
151
  `uploaded-files/${file.name}`,
@@ -164,7 +168,7 @@ function NewChatThread({
164
168
  }
165
169
  const operationId = activeOperationRef.current + 1;
166
170
  activeOperationRef.current = operationId;
167
- const initialTargetAgent = activeChatClient.agentParticipant() ?? findTargetAgent(room, agentName);
171
+ const initialTargetAgent = activeChatClient.agentParticipant() ?? (room == null ? null : findTargetAgent(room, agentName));
168
172
  setWaitingForAgent(initialTargetAgent === null && chatClient == null);
169
173
  setCreatingNewThread(initialTargetAgent !== null || chatClient != null);
170
174
  setNewThreadError(null);
@@ -183,7 +187,7 @@ function NewChatThread({
183
187
  const result = await activeChatClient.startThread({
184
188
  message: text,
185
189
  attachments: newThreadAttachments.map((attachment) => new AgentFileContent({ url: attachment.path })),
186
- senderName: getParticipantName(room.localParticipant) || void 0,
190
+ senderName: room == null ? activeChatClient.localParticipantName() : getParticipantName(room.localParticipant) || void 0,
187
191
  clientToolkits: resolvedClientToolkits
188
192
  });
189
193
  ensureOperationActive(operationId, activeOperationRef);
@@ -230,57 +234,30 @@ function NewChatThread({
230
234
  if (knownAgentName) {
231
235
  return displayParticipantName(knownAgentName);
232
236
  }
233
- const targetAgent = activeChatClient.agentParticipant() ?? findTargetAgent(room);
237
+ const targetAgent = activeChatClient.agentParticipant() ?? (room == null ? null : findTargetAgent(room));
234
238
  return displayParticipantName(targetAgent ? getParticipantName(targetAgent) : null);
235
239
  }, [activeChatClient, agentName, clientVersion, room]);
236
240
  const pendingStatusText = waitingForAgent ? `Waiting for ${targetAgentLabel} to be ready.` : creatingNewThread ? `Starting a thread with ${targetAgentLabel}.` : null;
237
- const visibleSuggestions = useMemo(
238
- () => (suggestions ?? []).filter((suggestion) => suggestion.label.trim() !== ""),
239
- [suggestions]
240
- );
241
241
  if (activePath !== null) {
242
242
  return builder(activePath);
243
243
  }
244
- const composer = /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1", children: [
245
- visibleSuggestions.length > 0 ? /* @__PURE__ */ jsx(
246
- "ul",
247
- {
248
- "aria-label": "Starter suggestions",
249
- className: "mx-auto flex flex-wrap w-full max-w-[912px] gap-2 overflow-x-auto px-4 pt-2 pb-1",
250
- children: visibleSuggestions.map((suggestion, index) => {
251
- const text = suggestion.prompt?.trim() || suggestion.label.trim();
252
- return /* @__PURE__ */ jsx("li", { className: "shrink-0", children: /* @__PURE__ */ jsx(
253
- Button,
254
- {
255
- type: "button",
256
- variant: "outline",
257
- className: "h-auto min-h-8 rounded-full px-3 py-1.5",
258
- disabled: creatingNewThread || waitingForAgent,
259
- onClick: () => void handleCreateThread({ text }),
260
- children: suggestion.label
261
- }
262
- ) }, index);
263
- })
264
- }
265
- ) : null,
266
- /* @__PURE__ */ jsx(
267
- ChatInput,
268
- {
269
- onSubmit: handleCreateThread,
270
- attachments: newThreadAttachments,
271
- onFilesSelected: selectNewThreadAttachments,
272
- setAttachments: setNewThreadAttachments,
273
- enableFileUpload,
274
- value: newThreadDraft,
275
- onValueChange: setNewThreadDraft,
276
- clearOnSubmit: false,
277
- showCancelButton: creatingNewThread || waitingForAgent,
278
- onCancelRequest: cancelPendingNewThread,
279
- disabled: creatingNewThread || waitingForAgent,
280
- placeholder: agentName.trim() ? `Type a message or @${displayParticipantName(agentName)}` : "Type a message"
281
- }
282
- )
283
- ] });
244
+ const composer = /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-1", children: /* @__PURE__ */ jsx(
245
+ ChatInput,
246
+ {
247
+ onSubmit: handleCreateThread,
248
+ attachments: newThreadAttachments,
249
+ onFilesSelected: selectNewThreadAttachments,
250
+ setAttachments: setNewThreadAttachments,
251
+ enableFileUpload: enableFileUpload && room != null,
252
+ value: newThreadDraft,
253
+ onValueChange: setNewThreadDraft,
254
+ clearOnSubmit: false,
255
+ showCancelButton: creatingNewThread || waitingForAgent,
256
+ onCancelRequest: cancelPendingNewThread,
257
+ disabled: creatingNewThread || waitingForAgent,
258
+ placeholder: agentName.trim() ? `Type a message or @${displayParticipantName(agentName)}` : "Type a message"
259
+ }
260
+ ) });
284
261
  return /* @__PURE__ */ jsxs("div", { className: "h-full flex flex-1 flex-col", children: [
285
262
  centerComposer ? /* @__PURE__ */ jsx("div", { className: "flex min-h-0 flex-1 items-center justify-center px-4 py-6", children: /* @__PURE__ */ jsxs("div", { className: "w-full max-w-[912px] space-y-5", children: [
286
263
  /* @__PURE__ */ jsxs("div", { className: "space-y-2 text-center", children: [
@@ -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
- import type { AgentThreadSuggestion, AgentToolChoice } from "./agent-thread.js";
4
+ import type { 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: RoomClient;
9
+ room?: RoomClient;
10
10
  chatClient?: BaseChatClient | null;
11
11
  path?: string;
12
12
  documentPath?: string;
@@ -24,11 +24,11 @@ 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
- chatFeedWidgets?: ChatFeedWidget[];
27
+ clientToolkits?: readonly ClientToolkitDescription[];
28
+ clientTools?: readonly Tool[];
29
+ chatFeedWidgets?: readonly ChatFeedWidget[];
29
30
  toolChoice?: AgentToolChoice;
30
31
  collapseMessages?: boolean;
31
- suggestions?: readonly AgentThreadSuggestion[];
32
32
  enableFileUpload?: boolean;
33
33
  threadSource?: "session" | "dataset";
34
34
  rowsLoader?: DatasetThreadRowsLoader;
@@ -42,4 +42,4 @@ export interface ThreadViewProps {
42
42
  onEventsChanged?: (threadId: string, events: readonly AgentMessageEvent[], latestMessage: AgentMessage | null) => void;
43
43
  onThreadStarted?: (threadId: string, events: readonly AgentMessageEvent[]) => Promise<void> | void;
44
44
  }
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;
45
+ 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, enableFileUpload, threadSource, rowsLoader, persistedEvents, loadThread, injectPersistedEvents, composerDisabled, closeThreadOnUnmount, onPersistedEventsInjectionStarted, onPersistedEventsInjected, onEventsChanged, onThreadStarted, }: ThreadViewProps): ReactElement;