@meshagent/meshagent-tailwind 0.44.11 → 0.44.12

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 (48) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/README.md +47 -0
  3. package/dist/cjs/chat/chat-bot-view.d.ts +4 -1
  4. package/dist/cjs/chat/chat-bot-view.js +20 -52
  5. package/dist/cjs/chat/dataset-agent-thread.d.ts +35 -0
  6. package/dist/cjs/chat/dataset-agent-thread.js +429 -0
  7. package/dist/cjs/chat/realtime-audio-output.d.ts +44 -0
  8. package/dist/cjs/chat/realtime-audio-output.js +326 -0
  9. package/dist/cjs/chat/thread-list-view.js +18 -1
  10. package/dist/cjs/chat/thread-view.d.ts +32 -0
  11. package/dist/cjs/chat/thread-view.js +157 -0
  12. package/dist/cjs/index.d.ts +3 -0
  13. package/dist/cjs/index.js +3 -0
  14. package/dist/cjs/meetings/controls.js +8 -15
  15. package/dist/cjs/meetings/lobby.d.ts +1 -1
  16. package/dist/cjs/meetings/lobby.js +10 -6
  17. package/dist/cjs/meetings/meeting-scope.d.ts +3 -0
  18. package/dist/cjs/meetings/meeting-scope.js +25 -4
  19. package/dist/cjs/meetings/meeting-view.d.ts +4 -0
  20. package/dist/cjs/meetings/meeting-view.js +4 -10
  21. package/dist/cjs/meetings/meetings.d.ts +1 -0
  22. package/dist/cjs/meetings/meetings.js +1 -0
  23. package/dist/cjs/meetings/voice-agent-caller.d.ts +11 -0
  24. package/dist/cjs/meetings/voice-agent-caller.js +133 -0
  25. package/dist/esm/chat/chat-bot-view.d.ts +4 -1
  26. package/dist/esm/chat/chat-bot-view.js +23 -55
  27. package/dist/esm/chat/dataset-agent-thread.d.ts +35 -0
  28. package/dist/esm/chat/dataset-agent-thread.js +426 -0
  29. package/dist/esm/chat/realtime-audio-output.d.ts +44 -0
  30. package/dist/esm/chat/realtime-audio-output.js +310 -0
  31. package/dist/esm/chat/thread-list-view.js +18 -1
  32. package/dist/esm/chat/thread-view.d.ts +32 -0
  33. package/dist/esm/chat/thread-view.js +137 -0
  34. package/dist/esm/index.d.ts +3 -0
  35. package/dist/esm/index.js +3 -0
  36. package/dist/esm/meetings/controls.js +8 -15
  37. package/dist/esm/meetings/lobby.d.ts +1 -1
  38. package/dist/esm/meetings/lobby.js +10 -8
  39. package/dist/esm/meetings/meeting-scope.d.ts +3 -0
  40. package/dist/esm/meetings/meeting-scope.js +25 -4
  41. package/dist/esm/meetings/meeting-view.d.ts +4 -0
  42. package/dist/esm/meetings/meeting-view.js +4 -10
  43. package/dist/esm/meetings/meetings.d.ts +1 -0
  44. package/dist/esm/meetings/meetings.js +1 -0
  45. package/dist/esm/meetings/voice-agent-caller.d.ts +11 -0
  46. package/dist/esm/meetings/voice-agent-caller.js +113 -0
  47. package/dist/index.css +2 -2
  48. package/package.json +5 -4
@@ -31,7 +31,6 @@ var import_dialog = require("../components/ui/dialog.js");
31
31
  var import_select = require("../components/ui/select.js");
32
32
  var import_spinner = require("../components/ui/spinner.js");
33
33
  var import_utils = require("../lib/utils.js");
34
- var import_meeting_scope = require("./meeting-scope.js");
35
34
  const audioInputStorageKey = "audioInput";
36
35
  const audioOutputStorageKey = "audioOutput";
37
36
  const videoInputStorageKey = "videoInput";
@@ -511,17 +510,16 @@ function meetingFastConnectOptions(options) {
511
510
  };
512
511
  }
513
512
  function MeetingLobby({
514
- controller: providedController,
515
513
  onCancel,
516
514
  onJoin
517
515
  }) {
518
- const controller = (0, import_meeting_scope.useMeetingController)(providedController);
519
516
  const state = useMeetingLobbyState();
517
+ const [joining, setJoining] = (0, import_react.useState)(false);
520
518
  const previewRef = useAttachedPreviewVideo(state.videoTrack);
521
519
  const videoPending = state.videoOn && state.videoTrack == null && !state.videoUnavailable;
522
520
  const audioPending = state.audioOn && state.audioTrack == null && !state.audioUnavailable;
523
521
  const starting = videoPending || audioPending || state.videoProcessing || state.audioProcessing;
524
- const canJoin = controller.config != null && !starting;
522
+ const canJoin = !starting && !joining;
525
523
  const statusText = state.loaded ? "Get ready to meet" : "Preparing devices";
526
524
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "flex h-full min-h-0 flex-col px-6 py-5", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "flex min-h-0 flex-1 items-center justify-center", children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "grid w-full max-w-[800px] gap-5", children: [
527
525
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "text-center text-base font-semibold", children: statusText }),
@@ -581,9 +579,15 @@ function MeetingLobby({
581
579
  className: "h-10 bg-emerald-600 text-white hover:bg-emerald-700 sm:w-[120px]",
582
580
  disabled: !canJoin,
583
581
  onClick: () => {
584
- onJoin?.(joinOptions(state));
582
+ if (joining) {
583
+ return;
584
+ }
585
+ setJoining(true);
586
+ Promise.resolve().then(() => onJoin?.(joinOptions(state))).catch((error) => {
587
+ console.warn("Unable to join meeting", error);
588
+ }).finally(() => setJoining(false));
585
589
  },
586
- children: starting ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
590
+ children: starting || joining ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
587
591
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_spinner.Spinner, { className: "h-4 w-4" }),
588
592
  "Starting"
589
593
  ] }) : "Meet now"
@@ -54,12 +54,15 @@ export declare class MeetingController {
54
54
  private readonly listeners;
55
55
  private _config;
56
56
  private _configurationError;
57
+ private _configurationRequestId;
58
+ private _snapshotVersion;
57
59
  constructor({ room, roomOptions }: {
58
60
  room: RoomClient;
59
61
  roomOptions?: RoomOptions;
60
62
  });
61
63
  get config(): LivekitConnectionInfo | null;
62
64
  get configurationError(): unknown;
65
+ get snapshotVersion(): number;
63
66
  get isConnected(): boolean;
64
67
  get hasParticipantsWithVideo(): boolean;
65
68
  subscribe(listener: Listener): () => void;
@@ -147,6 +147,8 @@ class MeetingController {
147
147
  listeners = /* @__PURE__ */ new Set();
148
148
  _config = null;
149
149
  _configurationError = null;
150
+ _configurationRequestId = 0;
151
+ _snapshotVersion = 0;
150
152
  constructor({ room, roomOptions }) {
151
153
  this.room = room;
152
154
  this.livekitRoom = new import_livekit_client.Room(roomOptions);
@@ -179,6 +181,9 @@ class MeetingController {
179
181
  get configurationError() {
180
182
  return this._configurationError;
181
183
  }
184
+ get snapshotVersion() {
185
+ return this._snapshotVersion;
186
+ }
182
187
  get isConnected() {
183
188
  return this.livekitRoom.state !== import_livekit_client.ConnectionState.Disconnected;
184
189
  }
@@ -205,21 +210,32 @@ class MeetingController {
205
210
  "You cannot reconfigure while the controller is connected"
206
211
  );
207
212
  }
213
+ const requestId = ++this._configurationRequestId;
208
214
  this._config = null;
209
215
  this._configurationError = null;
210
216
  this.notify();
211
217
  try {
212
- this._config = await this.room.livekit.getConnectionInfo({
218
+ const config = await this.room.livekit.getConnectionInfo({
213
219
  breakoutRoom
214
220
  });
221
+ if (requestId !== this._configurationRequestId) {
222
+ return;
223
+ }
224
+ this._config = config;
215
225
  this.notify();
216
226
  } catch (error) {
227
+ if (requestId !== this._configurationRequestId) {
228
+ return;
229
+ }
217
230
  this._configurationError = error;
218
231
  this.notify();
219
232
  throw error;
220
233
  }
221
234
  }
222
235
  async connect(options) {
236
+ if (this._config == null) {
237
+ await this.configure();
238
+ }
223
239
  const config = this._config;
224
240
  if (config == null) {
225
241
  throw new Error("The controller has not been configured");
@@ -302,6 +318,7 @@ class MeetingController {
302
318
  );
303
319
  }
304
320
  notify() {
321
+ this._snapshotVersion += 1;
305
322
  for (const listener of this.listeners) {
306
323
  listener();
307
324
  }
@@ -318,8 +335,8 @@ function useMeetingController(controller) {
318
335
  }
319
336
  (0, import_react.useSyncExternalStore)(
320
337
  (listener) => resolved.subscribe(listener),
321
- () => resolved.livekitRoom.state,
322
- () => resolved.livekitRoom.state
338
+ () => resolved.snapshotVersion,
339
+ () => resolved.snapshotVersion
323
340
  );
324
341
  return resolved;
325
342
  }
@@ -337,7 +354,11 @@ function MeetingScope({
337
354
  [client, roomOptions]
338
355
  );
339
356
  (0, import_react.useEffect)(() => {
340
- controller.configure({ breakoutRoom });
357
+ if (breakoutRoom !== void 0) {
358
+ controller.configure({ breakoutRoom }).catch((error) => {
359
+ console.warn("unable to configure meeting", error);
360
+ });
361
+ }
341
362
  return () => {
342
363
  if (controller.isConnected) {
343
364
  controller.disconnect().catch((error) => {
@@ -1,5 +1,9 @@
1
1
  import type { ReactElement } from "react";
2
+ import type { Room } from "livekit-client";
2
3
  import { type MeetingController } from "./meeting-scope.js";
4
+ export declare function MeetingAudioRenderer({ room }: {
5
+ room: Room;
6
+ }): ReactElement | null;
3
7
  export declare function MeetingView({ controller: providedController, onCancel }: {
4
8
  controller?: MeetingController;
5
9
  onCancel?: () => void;
@@ -18,6 +18,7 @@ var __copyProps = (to, from, except, desc) => {
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
19
  var meeting_view_exports = {};
20
20
  __export(meeting_view_exports, {
21
+ MeetingAudioRenderer: () => MeetingAudioRenderer,
21
22
  MeetingView: () => MeetingView
22
23
  });
23
24
  module.exports = __toCommonJS(meeting_view_exports);
@@ -664,7 +665,7 @@ function ShareScreenToggle({ controller: providedController }) {
664
665
  );
665
666
  }
666
667
  function ActiveMeetingToolbar({ controller, onDisconnect }) {
667
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex flex-wrap items-center justify-center gap-2", children: [
668
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex flex-wrap gap-2", children: [
668
669
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_controls.MeetingControls, { controller, onDisconnect, spacing: 8 }),
669
670
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ShareScreenToggle, { controller })
670
671
  ] });
@@ -675,18 +676,11 @@ function MeetingView({ controller: providedController, onCancel }) {
675
676
  const connected = controller.livekitRoom.state !== import_livekit_client.ConnectionState.Disconnected;
676
677
  const inPreview = viewState === "preview" || !connected;
677
678
  if (inPreview) {
678
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
679
- import_lobby.MeetingLobby,
680
- {
681
- controller,
682
- onCancel,
683
- onJoin: joinMeeting
684
- }
685
- );
679
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_lobby.MeetingLobby, { onCancel, onJoin: joinMeeting });
686
680
  }
687
681
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex h-full min-h-0 flex-col", children: [
688
682
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(MeetingAudioRenderer, { room: controller.livekitRoom }),
689
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "flex-0 border-b px-5 py-3", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ActiveMeetingToolbar, { controller, onDisconnect: onCancel }) }),
683
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "flex-0 px-5 py-3", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ActiveMeetingToolbar, { controller, onDisconnect: onCancel }) }),
690
684
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "min-h-0 flex-1 p-5", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(MeetingStage, { controller }) })
691
685
  ] });
692
686
  }
@@ -6,3 +6,4 @@ export * from "./meeting-scope.js";
6
6
  export * from "./meeting-view.js";
7
7
  export * from "./participants.js";
8
8
  export * from "./wake-lock.js";
9
+ export * from "./voice-agent-caller.js";
@@ -23,3 +23,4 @@ __reExport(meetings_exports, require("./meeting-scope.js"), module.exports);
23
23
  __reExport(meetings_exports, require("./meeting-view.js"), module.exports);
24
24
  __reExport(meetings_exports, require("./participants.js"), module.exports);
25
25
  __reExport(meetings_exports, require("./wake-lock.js"), module.exports);
26
+ __reExport(meetings_exports, require("./voice-agent-caller.js"), module.exports);
@@ -0,0 +1,11 @@
1
+ import type { RemoteParticipant, RoomClient } from "@meshagent/meshagent";
2
+ import type { ReactElement } from "react";
3
+ import { type MeetingController } from "./meeting-scope.js";
4
+ export declare function VoiceAgentCaller({ room, participant, controller: providedController, className, title, description, }: {
5
+ room: RoomClient;
6
+ participant: RemoteParticipant;
7
+ controller?: MeetingController;
8
+ className?: string;
9
+ title?: string;
10
+ description?: string;
11
+ }): ReactElement;
@@ -0,0 +1,133 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var voice_agent_caller_exports = {};
20
+ __export(voice_agent_caller_exports, {
21
+ VoiceAgentCaller: () => VoiceAgentCaller
22
+ });
23
+ module.exports = __toCommonJS(voice_agent_caller_exports);
24
+ var import_jsx_runtime = require("react/jsx-runtime");
25
+ var import_react = require("react");
26
+ var import_livekit_client = require("livekit-client");
27
+ var import_lucide_react = require("lucide-react");
28
+ var import_button = require("../components/ui/button.js");
29
+ var import_spinner = require("../components/ui/spinner.js");
30
+ var import_utils = require("../lib/utils.js");
31
+ var import_controls = require("./controls.js");
32
+ var import_meeting_view = require("./meeting-view.js");
33
+ var import_meeting_scope = require("./meeting-scope.js");
34
+ function describeStartSessionError(error) {
35
+ const message = String(error);
36
+ if (message.includes("NotAllowedError")) {
37
+ return "Microphone access was blocked by the browser or system.";
38
+ }
39
+ if (message.includes("NotFoundError")) {
40
+ return "The selected microphone was not found.";
41
+ }
42
+ return `Unable to start session: ${message}`;
43
+ }
44
+ function useMeetingConnectionState(controller) {
45
+ return (0, import_react.useSyncExternalStore)(
46
+ (listener) => controller.subscribe(listener),
47
+ () => controller.livekitRoom.state,
48
+ () => controller.livekitRoom.state
49
+ );
50
+ }
51
+ function VoiceAgentCaller({
52
+ room,
53
+ participant,
54
+ controller: providedController,
55
+ className,
56
+ title = "Start an audio session",
57
+ description = "Connect with this agent using your microphone."
58
+ }) {
59
+ const controller = (0, import_meeting_scope.useMeetingController)(providedController);
60
+ const connectionState = useMeetingConnectionState(controller);
61
+ const [pending, setPending] = (0, import_react.useState)(false);
62
+ const [error, setError] = (0, import_react.useState)(null);
63
+ const startSession = (0, import_react.useCallback)(async () => {
64
+ if (pending) {
65
+ return;
66
+ }
67
+ setPending(true);
68
+ setError(null);
69
+ const breakoutRoom = crypto.randomUUID();
70
+ try {
71
+ const callerParticipantId = room.localParticipant?.id;
72
+ if (callerParticipantId == null) {
73
+ throw new Error("The room local participant is not ready.");
74
+ }
75
+ await controller.configure({ breakoutRoom });
76
+ await controller.connect({ microphone: { enabled: true } });
77
+ await room.messaging.sendMessage({
78
+ to: participant,
79
+ type: "voice_call",
80
+ message: {
81
+ breakout_room: breakoutRoom,
82
+ participant_id: callerParticipantId
83
+ }
84
+ });
85
+ } catch (startError) {
86
+ setError(describeStartSessionError(startError));
87
+ if (controller.isConnected) {
88
+ await controller.disconnect().catch((disconnectError) => {
89
+ console.warn("unable to disconnect failed voice session", disconnectError);
90
+ });
91
+ }
92
+ } finally {
93
+ setPending(false);
94
+ }
95
+ }, [controller, participant, pending, room]);
96
+ if (connectionState !== import_livekit_client.ConnectionState.Disconnected) {
97
+ const remoteParticipant = Array.from(
98
+ controller.livekitRoom.remoteParticipants.values()
99
+ )[0];
100
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: (0, import_utils.cn)("flex h-full min-h-0 flex-col items-center justify-center gap-6 p-6 text-center", className), children: [
101
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_meeting_view.MeetingAudioRenderer, { room: controller.livekitRoom }),
102
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "flex min-h-44 w-full max-w-md items-center justify-center rounded-md border bg-muted/20", children: remoteParticipant == null ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex flex-col items-center gap-3 text-sm text-muted-foreground", children: [
103
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_spinner.Spinner, { size: "lg" }),
104
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "Waiting for the voice agent to join..." })
105
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex flex-col items-center gap-3", children: [
106
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_lucide_react.AudioWaveform, { className: "size-12 text-primary" }),
107
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "text-sm text-muted-foreground", children: "Voice session connected" })
108
+ ] }) }),
109
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_controls.MeetingControls, { controller })
110
+ ] });
111
+ }
112
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: (0, import_utils.cn)("flex h-full min-h-0 items-center justify-center p-6", className), children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex w-full max-w-lg flex-col items-center text-center", children: [
113
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "mb-5 flex size-14 items-center justify-center rounded-full bg-muted text-muted-foreground", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_lucide_react.AudioWaveform, { className: "size-7" }) }),
114
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("h2", { className: "text-xl font-semibold tracking-normal", children: title }),
115
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "mt-2 max-w-sm text-sm leading-6 text-muted-foreground", children: description }),
116
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
117
+ import_button.Button,
118
+ {
119
+ type: "button",
120
+ className: "mt-6",
121
+ disabled: pending,
122
+ onClick: () => {
123
+ void startSession();
124
+ },
125
+ children: [
126
+ pending ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_spinner.Spinner, { size: "sm" }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_lucide_react.Phone, { className: "size-4" }),
127
+ pending ? "Starting session" : "Start session"
128
+ ]
129
+ }
130
+ ),
131
+ error == null ? null : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "mt-4 max-w-md text-sm leading-6 text-destructive", children: error })
132
+ ] }) });
133
+ }
@@ -2,6 +2,7 @@ import type { ReactElement } from "react";
2
2
  import type { Participant, RoomClient } from "@meshagent/meshagent";
3
3
  import type { BaseChatClient, ClientToolkitDescription } from "@meshagent/meshagent-agents";
4
4
  import type { AgentToolChoice } from "./agent-thread";
5
+ import type { DatasetThreadRowsLoader } from "./dataset-agent-thread";
5
6
  import { ChatThreadDisplayMode } from "./conversation-descriptor";
6
7
  export { ChatThreadDisplayMode, chatDocumentPath, resolvedThreadListPath, } from "./conversation-descriptor";
7
8
  export interface ChatBotViewProps {
@@ -34,5 +35,7 @@ export interface ChatBotViewProps {
34
35
  clientToolkits?: ClientToolkitDescription[];
35
36
  toolChoice?: AgentToolChoice;
36
37
  collapseMessages?: boolean;
38
+ threadSource?: "session" | "dataset";
39
+ rowsLoader?: DatasetThreadRowsLoader;
37
40
  }
38
- 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, toolChoice, collapseMessages, }: ChatBotViewProps): ReactElement;
41
+ 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, toolChoice, collapseMessages, threadSource, rowsLoader, }: ChatBotViewProps): ReactElement;
@@ -1,15 +1,13 @@
1
1
  import { jsx, jsxs } from "react/jsx-runtime";
2
2
  import { useCallback, useEffect, useMemo, useRef, useState } from "react";
3
3
  import { MessagingChatClient } from "@meshagent/meshagent-agents";
4
- import { AlertTriangle } from "lucide-react";
5
- import { AgentThread } from "./agent-thread";
6
- import { ChatThreadDisplayMode, chatDocumentPath } from "./conversation-descriptor";
4
+ import { ChatThreadDisplayMode } from "./conversation-descriptor";
7
5
  import { cn } from "../lib/utils";
8
- import { MultiThreadView } from "./multi-thread-view";
9
6
  import { ThreadListView } from "./thread-list-view";
7
+ import { ThreadView } from "./thread-view";
10
8
  import {
11
9
  ChatThreadDisplayMode as ChatThreadDisplayMode2,
12
- chatDocumentPath as chatDocumentPath2,
10
+ chatDocumentPath,
13
11
  resolvedThreadListPath
14
12
  } from "./conversation-descriptor";
15
13
  const multiThreadLayoutBreakpointPx = 920;
@@ -35,15 +33,6 @@ function useIsWideLayout(minWidth) {
35
33
  }, [minWidth]);
36
34
  return matches;
37
35
  }
38
- function MultiThreadUnavailable() {
39
- return /* @__PURE__ */ jsx("div", { className: "flex min-h-0 flex-1 items-center justify-center px-4 py-8", children: /* @__PURE__ */ jsx("div", { className: "w-full max-w-[912px] rounded-3xl border border-destructive/30 bg-destructive/5 p-6 text-destructive", children: /* @__PURE__ */ jsxs("div", { className: "flex items-start gap-3", children: [
40
- /* @__PURE__ */ jsx(AlertTriangle, { className: "mt-0.5 h-5 w-5 shrink-0" }),
41
- /* @__PURE__ */ jsxs("div", { children: [
42
- /* @__PURE__ */ jsx("h2", { className: "text-lg font-semibold", children: "Unable to start a new thread" }),
43
- /* @__PURE__ */ jsx("p", { className: "mt-1 text-sm text-destructive/80", children: "No chat agent is selected." })
44
- ] })
45
- ] }) }) });
46
- }
47
36
  function ChatBotView({
48
37
  room,
49
38
  chatClient,
@@ -71,11 +60,12 @@ function ChatBotView({
71
60
  threadListCollapsedHeight = 220,
72
61
  clientToolkits,
73
62
  toolChoice,
74
- collapseMessages = true
63
+ collapseMessages = true,
64
+ threadSource = "session",
65
+ rowsLoader
75
66
  }) {
76
67
  const isWideLayout = useIsWideLayout(multiThreadLayoutBreakpointPx);
77
68
  const resolvedDocumentPath = useMemo(() => normalizePath(documentPath ?? path), [documentPath, path]);
78
- const resolvedSingleThreadPath = useMemo(() => resolvedDocumentPath ?? chatDocumentPath(agentName, { threadDir }), [agentName, resolvedDocumentPath, threadDir]);
79
69
  const needsChatClient = chatClient != null || threadDisplayMode === ChatThreadDisplayMode.MultiThreadComposer;
80
70
  const ownsChatClient = chatClient == null && needsChatClient;
81
71
  const activeChatClient = useMemo(
@@ -137,59 +127,37 @@ function ChatBotView({
137
127
  }
138
128
  previousNewThreadResetVersionRef.current = newThreadResetVersion;
139
129
  }, [activeSelectedThreadPath, newThreadResetVersion, setSelectedThread, threadDisplayMode]);
140
- if (threadDisplayMode !== ChatThreadDisplayMode.MultiThreadComposer) {
141
- return /* @__PURE__ */ jsx(
142
- AgentThread,
143
- {
144
- room,
145
- path: resolvedSingleThreadPath,
146
- chatClient: activeChatClient ?? void 0,
147
- disposeChatClient: false,
148
- agentName,
149
- emptyStateTitle,
150
- emptyStateDescription,
151
- clientToolkits,
152
- toolChoice,
153
- collapseMessages
154
- }
155
- );
156
- }
157
- if (!agentName?.trim()) {
158
- return /* @__PURE__ */ jsx(MultiThreadUnavailable, {});
159
- }
160
130
  const content = /* @__PURE__ */ jsx(
161
- MultiThreadView,
131
+ ThreadView,
162
132
  {
163
133
  room,
164
134
  chatClient: activeChatClient ?? void 0,
165
- disposeChatClient: false,
135
+ path,
136
+ documentPath,
166
137
  agentName,
138
+ threadDisplayMode,
139
+ threadDir,
167
140
  toolkit,
168
141
  tool,
142
+ centerComposer,
143
+ emptyStateTitle,
144
+ emptyStateDescription,
145
+ startNewThreadTitle,
146
+ startNewThreadDescription,
169
147
  selectedThreadPath: activeSelectedThreadPath,
170
148
  onSelectedThreadPathChanged: handleSelectedThreadPathChanged,
171
149
  onSelectedThreadResolved: emitResolvedThread,
172
150
  newThreadResetVersion,
173
- centerComposer,
174
151
  clientToolkits,
175
152
  toolChoice,
176
- builder: (threadPath) => /* @__PURE__ */ jsx(
177
- AgentThread,
178
- {
179
- room,
180
- path: threadPath,
181
- chatClient: activeChatClient ?? void 0,
182
- disposeChatClient: false,
183
- agentName,
184
- emptyStateTitle: startNewThreadTitle,
185
- emptyStateDescription: startNewThreadDescription,
186
- clientToolkits,
187
- toolChoice,
188
- collapseMessages
189
- }
190
- )
153
+ collapseMessages,
154
+ threadSource,
155
+ rowsLoader
191
156
  }
192
157
  );
158
+ if (threadDisplayMode !== ChatThreadDisplayMode.MultiThreadComposer) {
159
+ return content;
160
+ }
193
161
  if (!showThreadList || activeChatClient === null) {
194
162
  return content;
195
163
  }
@@ -212,6 +180,6 @@ function ChatBotView({
212
180
  export {
213
181
  ChatBotView,
214
182
  ChatThreadDisplayMode2 as ChatThreadDisplayMode,
215
- chatDocumentPath2 as chatDocumentPath,
183
+ chatDocumentPath,
216
184
  resolvedThreadListPath
217
185
  };
@@ -0,0 +1,35 @@
1
+ import type { ReactElement } from "react";
2
+ import type { RoomClient } from "@meshagent/meshagent";
3
+ import { BaseChatClient } from "@meshagent/meshagent-agents";
4
+ import type { ClientToolkitDescription } from "@meshagent/meshagent-agents";
5
+ import { type AgentToolChoice } from "./agent-thread.js";
6
+ export type DatasetThreadRow = Record<string, unknown>;
7
+ export type DatasetThreadRows = Iterable<DatasetThreadRow>;
8
+ export type DatasetThreadRowsLoader = (args: DatasetThreadRowsLoaderArgs) => AsyncIterable<DatasetThreadRows> | Promise<DatasetThreadRows> | DatasetThreadRows;
9
+ export interface DatasetThreadRowsLoaderArgs {
10
+ path: string;
11
+ namespace: string[];
12
+ table: string;
13
+ }
14
+ export interface DatasetThreadRef {
15
+ namespace: string[];
16
+ table: string;
17
+ }
18
+ export interface DatasetAgentThreadProps {
19
+ room: RoomClient;
20
+ path: string;
21
+ chatClient?: BaseChatClient;
22
+ disposeChatClient?: boolean;
23
+ agentName?: string;
24
+ rowsLoader?: DatasetThreadRowsLoader;
25
+ emptyStateTitle?: string;
26
+ emptyStateDescription?: string;
27
+ clientToolkits?: ClientToolkitDescription[];
28
+ toolChoice?: AgentToolChoice;
29
+ collapseMessages?: boolean;
30
+ retryMissingTableMs?: number;
31
+ }
32
+ export type RoomDatasetAgentThreadProps = Omit<DatasetAgentThreadProps, "rowsLoader">;
33
+ export declare function DatasetAgentThread({ room, path, chatClient, disposeChatClient, agentName, rowsLoader, emptyStateTitle, emptyStateDescription, clientToolkits, toolChoice, collapseMessages, retryMissingTableMs, }: DatasetAgentThreadProps): ReactElement;
34
+ export declare function RoomDatasetAgentThread(props: RoomDatasetAgentThreadProps): ReactElement;
35
+ export declare function parseDatasetThreadRef(path: string): DatasetThreadRef;