@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;
@@ -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,
@@ -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;
@@ -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 widget of chatFeedWidgets ?? []) {
36
- if (names.has(widget.name)) {
37
- throw new Error(`client tool '${widget.name}' has already been registered`);
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(widget.name);
39
+ names.add(tool.name);
40
40
  descriptions.push(new import_meshagent_agents.ClientToolkitDescription({
41
- name: widget.name,
42
- title: widget.title,
43
- description: widget.description,
44
- inputSchema: widget.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, 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;
@@ -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, totalBytes, linesAdded, linesRemoved) {
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 && "opacity-55"),
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, 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;
@@ -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, totalBytes, linesAdded, linesRemoved) {
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, totalBytes, linesAdded, linesRemoved]);
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, totalBytes, linesAdded, linesRemoved);
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, totalBytes, linesAdded, linesRemoved);
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,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[]>;
@@ -38,10 +38,10 @@ function DatasetAgentThread({
38
38
  emptyStateTitle,
39
39
  emptyStateDescription,
40
40
  clientToolkits,
41
+ clientTools,
41
42
  chatFeedWidgets,
42
43
  toolChoice,
43
44
  collapseMessages,
44
- suggestions,
45
45
  enableFileUpload = false,
46
46
  retryMissingTableMs = 500,
47
47
  loadThread = true,
@@ -53,9 +53,17 @@ function DatasetAgentThread({
53
53
  onEventsChanged
54
54
  }) {
55
55
  const normalizedPath = path.trim();
56
- const activeRowsLoader = (0, import_react.useMemo)(() => rowsLoader ?? defaultRowsLoader(room), [room, rowsLoader]);
56
+ const activeRowsLoader = (0, import_react.useMemo)(() => {
57
+ if (rowsLoader != null) return rowsLoader;
58
+ if (room != null) return defaultRowsLoader(room);
59
+ throw new Error("DatasetAgentThread requires either a room or a rows loader.");
60
+ }, [room, rowsLoader]);
57
61
  const activeChatClient = (0, import_react.useMemo)(
58
- () => chatClient ?? new import_meshagent_agents.MessagingChatClient({ room, agentName }),
62
+ () => {
63
+ if (chatClient != null) return chatClient;
64
+ if (room != null) return new import_meshagent_agents.MessagingChatClient({ room, agentName });
65
+ throw new Error("DatasetAgentThread requires either a room or a chat client.");
66
+ },
59
67
  [agentName, chatClient, room]
60
68
  );
61
69
  const [persistedEvents, setPersistedEvents] = (0, import_react.useState)(null);
@@ -114,11 +122,11 @@ function DatasetAgentThread({
114
122
  emptyStateTitle,
115
123
  emptyStateDescription,
116
124
  clientToolkits,
125
+ clientTools,
117
126
  chatFeedWidgets,
118
127
  toolChoice,
119
128
  collapseMessages,
120
- suggestions,
121
- enableFileUpload,
129
+ enableFileUpload: enableFileUpload && room != null,
122
130
  persistedEvents: persistedEvents ?? [],
123
131
  deferLiveEvents: persistedEvents == null,
124
132
  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;
@@ -44,9 +44,9 @@ 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
- suggestions,
50
50
  enableFileUpload = false,
51
51
  onThreadStarted
52
52
  }) {
@@ -98,9 +98,9 @@ function MultiThreadView({
98
98
  emptyStateTitle,
99
99
  emptyStateDescription,
100
100
  clientToolkits,
101
+ clientTools,
101
102
  chatFeedWidgets,
102
103
  toolChoice,
103
- suggestions,
104
104
  enableFileUpload,
105
105
  onThreadStarted
106
106
  },
@@ -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;
@@ -27,7 +27,6 @@ var import_meshagent_agents = require("@meshagent/meshagent-agents");
27
27
  var import_chat_feed_widget = require("./chat-feed-widget.js");
28
28
  var import_conversation_descriptor = require("./conversation-descriptor.js");
29
29
  var import_chat_input = require("./chat-input.js");
30
- var import_button = require("../components/ui/button.js");
31
30
  var import_file_attachment = require("./file-attachment.js");
32
31
  var import_sonner = require("../components/ui/sonner.js");
33
32
  class NewThreadCancelledError extends Error {
@@ -103,9 +102,9 @@ function NewChatThread({
103
102
  emptyStateTitle,
104
103
  emptyStateDescription,
105
104
  clientToolkits,
105
+ clientTools,
106
106
  chatFeedWidgets,
107
107
  toolChoice,
108
- suggestions,
109
108
  enableFileUpload = false,
110
109
  onThreadStarted
111
110
  }) {
@@ -120,13 +119,17 @@ function NewChatThread({
120
119
  const activePath = controlledThreadPath ?? internalThreadPath;
121
120
  const ownsChatClient = chatClient == null;
122
121
  const activeChatClient = (0, import_react.useMemo)(
123
- () => chatClient ?? new import_meshagent_agents.MessagingChatClient({ room, agentName }),
122
+ () => {
123
+ if (chatClient != null) return chatClient;
124
+ if (room != null) return new import_meshagent_agents.MessagingChatClient({ room, agentName });
125
+ throw new Error("NewChatThread requires either a room or a chat client.");
126
+ },
124
127
  [agentName, chatClient, room]
125
128
  );
126
129
  const [clientVersion, setClientVersion] = (0, import_react.useState)(0);
127
130
  const resolvedClientToolkits = (0, import_react.useMemo)(
128
- () => (0, import_chat_feed_widget.resolveClientToolkitDescriptions)(clientToolkits, chatFeedWidgets),
129
- [chatFeedWidgets, clientToolkits]
131
+ () => (0, import_chat_feed_widget.resolveClientToolkitDescriptions)(clientToolkits, chatFeedWidgets, clientTools),
132
+ [chatFeedWidgets, clientToolkits, clientTools]
130
133
  );
131
134
  (0, import_react.useEffect)(() => {
132
135
  return () => {
@@ -165,6 +168,7 @@ function NewChatThread({
165
168
  setWaitingForAgent(false);
166
169
  }, [agentName, controlledThreadPath, room]);
167
170
  const selectNewThreadAttachments = (0, import_react.useCallback)((files) => {
171
+ if (room == null) return;
168
172
  const nextAttachments = files.map((file) => new import_file_attachment.MeshagentFileUpload(
169
173
  room,
170
174
  `uploaded-files/${file.name}`,
@@ -187,7 +191,7 @@ function NewChatThread({
187
191
  }
188
192
  const operationId = activeOperationRef.current + 1;
189
193
  activeOperationRef.current = operationId;
190
- const initialTargetAgent = activeChatClient.agentParticipant() ?? findTargetAgent(room, agentName);
194
+ const initialTargetAgent = activeChatClient.agentParticipant() ?? (room == null ? null : findTargetAgent(room, agentName));
191
195
  setWaitingForAgent(initialTargetAgent === null && chatClient == null);
192
196
  setCreatingNewThread(initialTargetAgent !== null || chatClient != null);
193
197
  setNewThreadError(null);
@@ -206,7 +210,7 @@ function NewChatThread({
206
210
  const result = await activeChatClient.startThread({
207
211
  message: text,
208
212
  attachments: newThreadAttachments.map((attachment) => new import_meshagent_agents.AgentFileContent({ url: attachment.path })),
209
- senderName: getParticipantName(room.localParticipant) || void 0,
213
+ senderName: room == null ? activeChatClient.localParticipantName() : getParticipantName(room.localParticipant) || void 0,
210
214
  clientToolkits: resolvedClientToolkits
211
215
  });
212
216
  ensureOperationActive(operationId, activeOperationRef);
@@ -253,57 +257,30 @@ function NewChatThread({
253
257
  if (knownAgentName) {
254
258
  return displayParticipantName(knownAgentName);
255
259
  }
256
- const targetAgent = activeChatClient.agentParticipant() ?? findTargetAgent(room);
260
+ const targetAgent = activeChatClient.agentParticipant() ?? (room == null ? null : findTargetAgent(room));
257
261
  return displayParticipantName(targetAgent ? getParticipantName(targetAgent) : null);
258
262
  }, [activeChatClient, agentName, clientVersion, room]);
259
263
  const pendingStatusText = waitingForAgent ? `Waiting for ${targetAgentLabel} to be ready.` : creatingNewThread ? `Starting a thread with ${targetAgentLabel}.` : null;
260
- const visibleSuggestions = (0, import_react.useMemo)(
261
- () => (suggestions ?? []).filter((suggestion) => suggestion.label.trim() !== ""),
262
- [suggestions]
263
- );
264
264
  if (activePath !== null) {
265
265
  return builder(activePath);
266
266
  }
267
- const composer = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex flex-col gap-1", children: [
268
- visibleSuggestions.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
269
- "ul",
270
- {
271
- "aria-label": "Starter suggestions",
272
- className: "mx-auto flex flex-wrap w-full max-w-[912px] gap-2 overflow-x-auto px-4 pt-2 pb-1",
273
- children: visibleSuggestions.map((suggestion, index) => {
274
- const text = suggestion.prompt?.trim() || suggestion.label.trim();
275
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("li", { className: "shrink-0", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
276
- import_button.Button,
277
- {
278
- type: "button",
279
- variant: "outline",
280
- className: "h-auto min-h-8 rounded-full px-3 py-1.5",
281
- disabled: creatingNewThread || waitingForAgent,
282
- onClick: () => void handleCreateThread({ text }),
283
- children: suggestion.label
284
- }
285
- ) }, index);
286
- })
287
- }
288
- ) : null,
289
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
290
- import_chat_input.ChatInput,
291
- {
292
- onSubmit: handleCreateThread,
293
- attachments: newThreadAttachments,
294
- onFilesSelected: selectNewThreadAttachments,
295
- setAttachments: setNewThreadAttachments,
296
- enableFileUpload,
297
- value: newThreadDraft,
298
- onValueChange: setNewThreadDraft,
299
- clearOnSubmit: false,
300
- showCancelButton: creatingNewThread || waitingForAgent,
301
- onCancelRequest: cancelPendingNewThread,
302
- disabled: creatingNewThread || waitingForAgent,
303
- placeholder: agentName.trim() ? `Type a message or @${displayParticipantName(agentName)}` : "Type a message"
304
- }
305
- )
306
- ] });
267
+ const composer = /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "flex flex-col gap-1", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
268
+ import_chat_input.ChatInput,
269
+ {
270
+ onSubmit: handleCreateThread,
271
+ attachments: newThreadAttachments,
272
+ onFilesSelected: selectNewThreadAttachments,
273
+ setAttachments: setNewThreadAttachments,
274
+ enableFileUpload: enableFileUpload && room != null,
275
+ value: newThreadDraft,
276
+ onValueChange: setNewThreadDraft,
277
+ clearOnSubmit: false,
278
+ showCancelButton: creatingNewThread || waitingForAgent,
279
+ onCancelRequest: cancelPendingNewThread,
280
+ disabled: creatingNewThread || waitingForAgent,
281
+ placeholder: agentName.trim() ? `Type a message or @${displayParticipantName(agentName)}` : "Type a message"
282
+ }
283
+ ) });
307
284
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "h-full flex flex-1 flex-col", children: [
308
285
  centerComposer ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "flex min-h-0 flex-1 items-center justify-center px-4 py-6", children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "w-full max-w-[912px] space-y-5", children: [
309
286
  /* @__PURE__ */ (0, import_jsx_runtime.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;