@meshagent/meshagent-tailwind 0.44.10 → 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 +9 -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
@@ -0,0 +1,44 @@
1
+ import type { ChatThreadSession } from "@meshagent/meshagent-agents";
2
+ export type RealtimeAudioOutputState = "idle" | "starting" | "playing" | "completed" | "stopped" | "error";
3
+ export interface RealtimeAudioOutputStartOptions {
4
+ sampleRate: number;
5
+ channels: number;
6
+ }
7
+ export interface RealtimeAudioOutputAppendOptions {
8
+ mimeType?: string;
9
+ }
10
+ export interface RealtimeAudioOutput {
11
+ start(options: RealtimeAudioOutputStartOptions): Promise<void>;
12
+ append(pcm: Uint8Array, options?: RealtimeAudioOutputAppendOptions): Promise<void>;
13
+ complete(): Promise<void>;
14
+ stop(): Promise<void>;
15
+ dispose(): Promise<void>;
16
+ }
17
+ export interface UseRealtimeAudioOutputOptions {
18
+ sampleRate?: number;
19
+ channels?: number;
20
+ createOutput?: () => RealtimeAudioOutput;
21
+ }
22
+ export interface UseRealtimeAudioOutputResult {
23
+ state: RealtimeAudioOutputState;
24
+ error: unknown;
25
+ start: (options?: Partial<RealtimeAudioOutputStartOptions>) => Promise<void>;
26
+ append: (pcm: Uint8Array, options?: RealtimeAudioOutputAppendOptions) => Promise<void>;
27
+ complete: () => Promise<void>;
28
+ stop: () => Promise<void>;
29
+ dispose: () => Promise<void>;
30
+ }
31
+ export interface UseAgentRealtimeAudioOutputOptions extends UseRealtimeAudioOutputOptions {
32
+ enabled?: boolean;
33
+ }
34
+ export declare function createRealtimeAudioOutput(): RealtimeAudioOutput;
35
+ export declare function useRealtimeAudioOutput({ sampleRate, channels, createOutput, }?: UseRealtimeAudioOutputOptions): UseRealtimeAudioOutputResult;
36
+ export declare function useAgentRealtimeAudioOutput(session: ChatThreadSession | null | undefined, options?: UseAgentRealtimeAudioOutputOptions): UseRealtimeAudioOutputResult;
37
+ export declare function pcm16ChannelToFloat32({ data, frames, channels, channel, }: {
38
+ data: DataView;
39
+ frames: number;
40
+ channels: number;
41
+ channel: number;
42
+ }): Float32Array;
43
+ export declare function pcmAudioBytes(bytes: Uint8Array, mimeType?: string): Uint8Array;
44
+ export declare function wavDataChunk(bytes: Uint8Array): Uint8Array | null;
@@ -0,0 +1,326 @@
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 realtime_audio_output_exports = {};
20
+ __export(realtime_audio_output_exports, {
21
+ createRealtimeAudioOutput: () => createRealtimeAudioOutput,
22
+ pcm16ChannelToFloat32: () => pcm16ChannelToFloat32,
23
+ pcmAudioBytes: () => pcmAudioBytes,
24
+ useAgentRealtimeAudioOutput: () => useAgentRealtimeAudioOutput,
25
+ useRealtimeAudioOutput: () => useRealtimeAudioOutput,
26
+ wavDataChunk: () => wavDataChunk
27
+ });
28
+ module.exports = __toCommonJS(realtime_audio_output_exports);
29
+ var import_react = require("react");
30
+ var import_meshagent_agents = require("@meshagent/meshagent-agents");
31
+ const defaultSampleRate = 24e3;
32
+ const defaultChannels = 1;
33
+ const bytesPerSample = 2;
34
+ const scheduleLeadSeconds = 0.03;
35
+ function createRealtimeAudioOutput() {
36
+ return new BrowserRealtimeAudioOutput();
37
+ }
38
+ class BrowserRealtimeAudioOutput {
39
+ context = null;
40
+ nodes = [];
41
+ generation = 0;
42
+ sampleRate = defaultSampleRate;
43
+ channels = defaultChannels;
44
+ nextStartTime = 0;
45
+ started = false;
46
+ async start({ sampleRate, channels }) {
47
+ validateAudioFormat({ sampleRate, channels });
48
+ if (this.started && this.sampleRate === sampleRate && this.channels === channels) {
49
+ return;
50
+ }
51
+ if (this.started || this.nodes.length > 0) {
52
+ await this.stop();
53
+ }
54
+ this.sampleRate = sampleRate;
55
+ this.channels = channels;
56
+ const context = this.context ?? new AudioContext();
57
+ this.context = context;
58
+ void context.resume().catch(() => void 0);
59
+ this.nextStartTime = context.currentTime + scheduleLeadSeconds;
60
+ this.started = true;
61
+ }
62
+ async append(bytes, options = {}) {
63
+ if (!this.started || bytes.length === 0) {
64
+ return;
65
+ }
66
+ const context = this.context;
67
+ if (context == null) {
68
+ return;
69
+ }
70
+ const pcm = pcmAudioBytes(bytes, options.mimeType);
71
+ const bytesPerFrame = this.channels * bytesPerSample;
72
+ if (pcm.length === 0 || pcm.length % bytesPerFrame !== 0) {
73
+ return;
74
+ }
75
+ const frames = pcm.length / bytesPerFrame;
76
+ const buffer = context.createBuffer(this.channels, frames, this.sampleRate);
77
+ const data = new DataView(pcm.buffer, pcm.byteOffset, pcm.byteLength);
78
+ for (let channel = 0; channel < this.channels; channel++) {
79
+ buffer.copyToChannel(pcm16ChannelToFloat32({ data, frames, channels: this.channels, channel }), channel);
80
+ }
81
+ const source = context.createBufferSource();
82
+ source.buffer = buffer;
83
+ source.connect(context.destination);
84
+ const startAt = this.nextStartTime < context.currentTime ? context.currentTime : this.nextStartTime;
85
+ this.nextStartTime = startAt + frames / this.sampleRate;
86
+ const generation = this.generation;
87
+ this.nodes.push(source);
88
+ source.onended = () => {
89
+ this.nodes = this.nodes.filter((node) => node !== source);
90
+ };
91
+ try {
92
+ source.start(startAt);
93
+ } catch {
94
+ if (generation === this.generation) {
95
+ this.nodes = this.nodes.filter((node) => node !== source);
96
+ }
97
+ }
98
+ }
99
+ async complete() {
100
+ this.started = false;
101
+ }
102
+ async stop() {
103
+ this.generation += 1;
104
+ this.started = false;
105
+ this.nextStartTime = this.context?.currentTime ?? 0;
106
+ const nodes = this.nodes;
107
+ this.nodes = [];
108
+ for (const node of nodes) {
109
+ try {
110
+ node.stop();
111
+ } catch {
112
+ }
113
+ try {
114
+ node.disconnect();
115
+ } catch {
116
+ }
117
+ }
118
+ }
119
+ async dispose() {
120
+ await this.stop();
121
+ const context = this.context;
122
+ this.context = null;
123
+ if (context != null) {
124
+ try {
125
+ await context.close();
126
+ } catch {
127
+ }
128
+ }
129
+ }
130
+ }
131
+ function useRealtimeAudioOutput({
132
+ sampleRate = defaultSampleRate,
133
+ channels = defaultChannels,
134
+ createOutput = createRealtimeAudioOutput
135
+ } = {}) {
136
+ const outputRef = (0, import_react.useRef)(null);
137
+ const disposedRef = (0, import_react.useRef)(false);
138
+ const [state, setState] = (0, import_react.useState)("idle");
139
+ const [error, setError] = (0, import_react.useState)(null);
140
+ const output = (0, import_react.useMemo)(() => {
141
+ const created = createOutput();
142
+ outputRef.current = created;
143
+ return created;
144
+ }, [createOutput]);
145
+ const run = (0, import_react.useCallback)(async (nextState, action) => {
146
+ if (disposedRef.current) {
147
+ return;
148
+ }
149
+ try {
150
+ setError(null);
151
+ await action();
152
+ if (!disposedRef.current) {
153
+ setState(nextState);
154
+ }
155
+ } catch (caught) {
156
+ if (!disposedRef.current) {
157
+ setError(caught);
158
+ setState("error");
159
+ }
160
+ throw caught;
161
+ }
162
+ }, []);
163
+ const start = (0, import_react.useCallback)(
164
+ (options = {}) => run("playing", async () => {
165
+ setState("starting");
166
+ await output.start({
167
+ sampleRate: options.sampleRate ?? sampleRate,
168
+ channels: options.channels ?? channels
169
+ });
170
+ }),
171
+ [channels, output, run, sampleRate]
172
+ );
173
+ const append = (0, import_react.useCallback)(
174
+ (pcm, options) => run("playing", () => output.append(pcm, options)),
175
+ [output, run]
176
+ );
177
+ const complete = (0, import_react.useCallback)(() => run("completed", () => output.complete()), [output, run]);
178
+ const stop = (0, import_react.useCallback)(() => run("stopped", () => output.stop()), [output, run]);
179
+ const dispose = (0, import_react.useCallback)(async () => {
180
+ disposedRef.current = true;
181
+ await outputRef.current?.dispose();
182
+ outputRef.current = null;
183
+ }, []);
184
+ (0, import_react.useEffect)(() => {
185
+ disposedRef.current = false;
186
+ return () => {
187
+ disposedRef.current = true;
188
+ void output.dispose();
189
+ if (outputRef.current === output) {
190
+ outputRef.current = null;
191
+ }
192
+ };
193
+ }, [output]);
194
+ return { state, error, start, append, complete, stop, dispose };
195
+ }
196
+ function useAgentRealtimeAudioOutput(session, options = {}) {
197
+ const { enabled = true, ...audioOptions } = options;
198
+ const audio = useRealtimeAudioOutput(audioOptions);
199
+ const processedMessageIdsRef = (0, import_react.useRef)(/* @__PURE__ */ new Set());
200
+ const activeItemIdRef = (0, import_react.useRef)(null);
201
+ (0, import_react.useEffect)(() => {
202
+ if (!enabled || session == null) {
203
+ return void 0;
204
+ }
205
+ const processEvent = (event) => {
206
+ if (processedMessageIdsRef.current.has(event.message.messageId)) {
207
+ return;
208
+ }
209
+ processedMessageIdsRef.current.add(event.message.messageId);
210
+ void handleRealtimeAudioEvent({
211
+ event,
212
+ audio,
213
+ activeItemIdRef,
214
+ fallbackSampleRate: audioOptions.sampleRate ?? defaultSampleRate,
215
+ fallbackChannels: audioOptions.channels ?? defaultChannels
216
+ });
217
+ };
218
+ for (const event of session.messages) {
219
+ processEvent(event);
220
+ }
221
+ const listener = () => {
222
+ for (const event of session.messages) {
223
+ processEvent(event);
224
+ }
225
+ };
226
+ session.addListener(listener);
227
+ return () => {
228
+ session.removeListener(listener);
229
+ };
230
+ }, [audio, audioOptions.channels, audioOptions.sampleRate, enabled, session]);
231
+ (0, import_react.useEffect)(() => {
232
+ if (enabled) {
233
+ return void 0;
234
+ }
235
+ void audio.stop();
236
+ return void 0;
237
+ }, [audio, enabled]);
238
+ return audio;
239
+ }
240
+ async function handleRealtimeAudioEvent({
241
+ event,
242
+ audio,
243
+ activeItemIdRef,
244
+ fallbackSampleRate,
245
+ fallbackChannels
246
+ }) {
247
+ const message = event.message;
248
+ if (message.type === import_meshagent_agents.agentAudioGenerationDeltaType) {
249
+ const audioMessage = message;
250
+ const itemId = audioMessage.itemId ?? message.messageId;
251
+ if (activeItemIdRef.current !== itemId) {
252
+ await audio.stop();
253
+ await audio.start({
254
+ sampleRate: audioMessage.outputFormat?.sampleRate ?? fallbackSampleRate,
255
+ channels: fallbackChannels
256
+ });
257
+ activeItemIdRef.current = itemId;
258
+ }
259
+ await audio.append(audioMessage.data, { mimeType: audioMessage.mimeType ?? audioMessage.outputFormat?.type });
260
+ } else if (message.type === import_meshagent_agents.agentAudioGenerationCompletedType) {
261
+ await audio.complete();
262
+ activeItemIdRef.current = null;
263
+ } else if (message.type === import_meshagent_agents.agentRealtimeAudioChunkType) {
264
+ const audioMessage = message;
265
+ if (activeItemIdRef.current == null) {
266
+ await audio.start({
267
+ sampleRate: audioMessage.format?.sampleRate ?? fallbackSampleRate,
268
+ channels: fallbackChannels
269
+ });
270
+ activeItemIdRef.current = message.messageId;
271
+ }
272
+ await audio.append(audioMessage.data, { mimeType: audioMessage.format?.type });
273
+ }
274
+ }
275
+ function pcm16ChannelToFloat32({
276
+ data,
277
+ frames,
278
+ channels,
279
+ channel
280
+ }) {
281
+ const samples = new Float32Array(frames);
282
+ const bytesPerFrame = channels * bytesPerSample;
283
+ for (let frame = 0; frame < frames; frame++) {
284
+ samples[frame] = data.getInt16(frame * bytesPerFrame + channel * bytesPerSample, true) / 32768;
285
+ }
286
+ return samples;
287
+ }
288
+ function pcmAudioBytes(bytes, mimeType) {
289
+ const normalizedMimeType = mimeType?.split(";")[0]?.trim().toLowerCase();
290
+ if (normalizedMimeType === "audio/wav" || normalizedMimeType === "audio/wave" || normalizedMimeType === "audio/x-wav") {
291
+ return wavDataChunk(bytes) ?? bytes;
292
+ }
293
+ return bytes;
294
+ }
295
+ function wavDataChunk(bytes) {
296
+ if (bytes.length < 44 || ascii(bytes, 0, 4) !== "RIFF" || ascii(bytes, 8, 12) !== "WAVE") {
297
+ return null;
298
+ }
299
+ const data = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
300
+ let offset = 12;
301
+ while (offset + 8 <= bytes.length) {
302
+ const chunkId = ascii(bytes, offset, offset + 4);
303
+ const chunkSize = data.getUint32(offset + 4, true);
304
+ const chunkStart = offset + 8;
305
+ const chunkEnd = chunkStart + chunkSize;
306
+ if (chunkEnd > bytes.length) {
307
+ return null;
308
+ }
309
+ if (chunkId === "data") {
310
+ return bytes.subarray(chunkStart, chunkEnd);
311
+ }
312
+ offset = chunkEnd + (chunkSize % 2 === 1 ? 1 : 0);
313
+ }
314
+ return null;
315
+ }
316
+ function ascii(bytes, start, end) {
317
+ return String.fromCharCode(...bytes.subarray(start, end));
318
+ }
319
+ function validateAudioFormat({ sampleRate, channels }) {
320
+ if (!Number.isInteger(sampleRate) || sampleRate <= 0) {
321
+ throw new TypeError("sampleRate must be a positive integer");
322
+ }
323
+ if (!Number.isInteger(channels) || channels <= 0) {
324
+ throw new TypeError("channels must be a positive integer");
325
+ }
326
+ }
@@ -79,6 +79,17 @@ function describeError(error) {
79
79
  }
80
80
  return `${error}`;
81
81
  }
82
+ function hasAgentParticipantWaiter(chatClient) {
83
+ return "waitForAgentParticipant" in chatClient && typeof chatClient.waitForAgentParticipant === "function";
84
+ }
85
+ async function waitForThreadListPrerequisites(chatClient) {
86
+ if (chatClient.agentParticipant() !== null) {
87
+ return;
88
+ }
89
+ if (hasAgentParticipantWaiter(chatClient)) {
90
+ await chatClient.waitForAgentParticipant({ waitKey: "thread-list" });
91
+ }
92
+ }
82
93
  class ChatThreadListStore {
83
94
  constructor(repository, onChanged) {
84
95
  this.repository = repository;
@@ -131,9 +142,15 @@ function useThreadList({ room, chatClient }) {
131
142
  setEntries([]);
132
143
  setLoading(true);
133
144
  setError(null);
145
+ if (chatClient === null) {
146
+ setEntries([]);
147
+ setLoading(false);
148
+ setError(new Error("Agent thread lists require a chat client."));
149
+ return;
150
+ }
134
151
  const store = createStore();
135
152
  storeRef.current = store;
136
- void store.open().then(() => {
153
+ void waitForThreadListPrerequisites(chatClient).then(() => store.open()).then(() => {
137
154
  if (cancelled) {
138
155
  void store.close();
139
156
  return;
@@ -0,0 +1,32 @@
1
+ import type { ReactElement } from "react";
2
+ import type { RoomClient } from "@meshagent/meshagent";
3
+ import type { BaseChatClient, ClientToolkitDescription } from "@meshagent/meshagent-agents";
4
+ import type { AgentToolChoice } from "./agent-thread";
5
+ import { ChatThreadDisplayMode } from "./conversation-descriptor";
6
+ import type { DatasetThreadRowsLoader } from "./dataset-agent-thread";
7
+ export interface ThreadViewProps {
8
+ room: RoomClient;
9
+ chatClient?: BaseChatClient | null;
10
+ path?: string;
11
+ documentPath?: string;
12
+ agentName?: string;
13
+ threadDisplayMode?: ChatThreadDisplayMode;
14
+ threadDir?: string;
15
+ toolkit?: string;
16
+ tool?: string;
17
+ centerComposer?: boolean;
18
+ emptyStateTitle?: string;
19
+ emptyStateDescription?: string;
20
+ startNewThreadTitle?: string;
21
+ startNewThreadDescription?: string;
22
+ selectedThreadPath?: string | null;
23
+ onSelectedThreadPathChanged?: (path: string | null) => void;
24
+ onSelectedThreadResolved?: (path: string | null, displayName: string | null) => void;
25
+ newThreadResetVersion?: number;
26
+ clientToolkits?: ClientToolkitDescription[];
27
+ toolChoice?: AgentToolChoice;
28
+ collapseMessages?: boolean;
29
+ threadSource?: "session" | "dataset";
30
+ rowsLoader?: DatasetThreadRowsLoader;
31
+ }
32
+ export declare function ThreadView({ room, chatClient, path, documentPath, agentName, threadDisplayMode, threadDir, toolkit, tool, centerComposer, emptyStateTitle, emptyStateDescription, startNewThreadTitle, startNewThreadDescription, selectedThreadPath, onSelectedThreadPathChanged, onSelectedThreadResolved, newThreadResetVersion, clientToolkits, toolChoice, collapseMessages, threadSource, rowsLoader, }: ThreadViewProps): ReactElement;
@@ -0,0 +1,157 @@
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 thread_view_exports = {};
20
+ __export(thread_view_exports, {
21
+ ThreadView: () => ThreadView
22
+ });
23
+ module.exports = __toCommonJS(thread_view_exports);
24
+ var import_jsx_runtime = require("react/jsx-runtime");
25
+ var import_lucide_react = require("lucide-react");
26
+ var import_agent_thread = require("./agent-thread");
27
+ var import_conversation_descriptor = require("./conversation-descriptor");
28
+ var import_dataset_agent_thread = require("./dataset-agent-thread");
29
+ var import_multi_thread_view = require("./multi-thread-view");
30
+ function normalizePath(path) {
31
+ const normalized = path?.trim();
32
+ return normalized ? normalized : null;
33
+ }
34
+ function MultiThreadUnavailable() {
35
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "flex min-h-0 flex-1 items-center justify-center px-4 py-8", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "w-full max-w-[912px] rounded-3xl border border-destructive/30 bg-destructive/5 p-6 text-destructive", children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex items-start gap-3", children: [
36
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_lucide_react.AlertTriangle, { className: "mt-0.5 h-5 w-5 shrink-0" }),
37
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
38
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("h2", { className: "text-lg font-semibold", children: "Unable to start a new thread" }),
39
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "mt-1 text-sm text-destructive/80", children: "No chat agent is selected." })
40
+ ] })
41
+ ] }) }) });
42
+ }
43
+ function ThreadView({
44
+ room,
45
+ chatClient = null,
46
+ path,
47
+ documentPath,
48
+ agentName,
49
+ threadDisplayMode = import_conversation_descriptor.ChatThreadDisplayMode.SingleThread,
50
+ threadDir,
51
+ toolkit,
52
+ tool,
53
+ centerComposer = false,
54
+ emptyStateTitle = "No threads yet",
55
+ emptyStateDescription = "Start a new conversation to see it here.",
56
+ startNewThreadTitle = "Start a new thread",
57
+ startNewThreadDescription = "Connect with this agent and your team.",
58
+ selectedThreadPath,
59
+ onSelectedThreadPathChanged,
60
+ onSelectedThreadResolved,
61
+ newThreadResetVersion = 0,
62
+ clientToolkits,
63
+ toolChoice,
64
+ collapseMessages = true,
65
+ threadSource = "session",
66
+ rowsLoader
67
+ }) {
68
+ const resolvedDocumentPath = normalizePath(documentPath ?? path);
69
+ const resolvedSingleThreadPath = resolvedDocumentPath ?? (0, import_conversation_descriptor.chatDocumentPath)(agentName, { threadDir });
70
+ const activeChatClient = chatClient ?? void 0;
71
+ if (threadDisplayMode !== import_conversation_descriptor.ChatThreadDisplayMode.MultiThreadComposer) {
72
+ if (threadSource === "dataset") {
73
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
74
+ import_dataset_agent_thread.DatasetAgentThread,
75
+ {
76
+ room,
77
+ path: resolvedSingleThreadPath,
78
+ chatClient: activeChatClient,
79
+ disposeChatClient: false,
80
+ agentName,
81
+ rowsLoader,
82
+ emptyStateTitle,
83
+ emptyStateDescription,
84
+ clientToolkits,
85
+ toolChoice,
86
+ collapseMessages
87
+ }
88
+ );
89
+ }
90
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
91
+ import_agent_thread.AgentThread,
92
+ {
93
+ room,
94
+ path: resolvedSingleThreadPath,
95
+ chatClient: activeChatClient,
96
+ disposeChatClient: false,
97
+ agentName,
98
+ emptyStateTitle,
99
+ emptyStateDescription,
100
+ clientToolkits,
101
+ toolChoice,
102
+ collapseMessages
103
+ }
104
+ );
105
+ }
106
+ if (!agentName?.trim()) {
107
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(MultiThreadUnavailable, {});
108
+ }
109
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
110
+ import_multi_thread_view.MultiThreadView,
111
+ {
112
+ room,
113
+ chatClient: activeChatClient,
114
+ disposeChatClient: false,
115
+ agentName,
116
+ toolkit,
117
+ tool,
118
+ selectedThreadPath,
119
+ onSelectedThreadPathChanged,
120
+ onSelectedThreadResolved,
121
+ newThreadResetVersion,
122
+ centerComposer,
123
+ clientToolkits,
124
+ toolChoice,
125
+ builder: (threadPath) => threadSource === "dataset" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
126
+ import_dataset_agent_thread.DatasetAgentThread,
127
+ {
128
+ room,
129
+ path: threadPath,
130
+ chatClient: activeChatClient,
131
+ disposeChatClient: false,
132
+ agentName,
133
+ rowsLoader,
134
+ emptyStateTitle: startNewThreadTitle,
135
+ emptyStateDescription: startNewThreadDescription,
136
+ clientToolkits,
137
+ toolChoice,
138
+ collapseMessages
139
+ }
140
+ ) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
141
+ import_agent_thread.AgentThread,
142
+ {
143
+ room,
144
+ path: threadPath,
145
+ chatClient: activeChatClient,
146
+ disposeChatClient: false,
147
+ agentName,
148
+ emptyStateTitle: startNewThreadTitle,
149
+ emptyStateDescription: startNewThreadDescription,
150
+ clientToolkits,
151
+ toolChoice,
152
+ collapseMessages
153
+ }
154
+ )
155
+ }
156
+ );
157
+ }
@@ -4,12 +4,15 @@ export * from './chat/chat-input.js';
4
4
  export * from './chat/chat-message.js';
5
5
  export * from './chat/chat-typing-indicator.js';
6
6
  export * from './chat/conversation-descriptor.js';
7
+ export * from './chat/dataset-agent-thread.js';
7
8
  export * from './chat/file-attachment.js';
8
9
  export * from './chat/file-uploader.js';
9
10
  export * from './chat/multi-thread-view.js';
10
11
  export * from './chat/thread-list-view.js';
12
+ export * from './chat/thread-view.js';
11
13
  export * from './chat/agent-thread.js';
12
14
  export * from './chat/new-chat-thread.js';
15
+ export * from './chat/realtime-audio-output.js';
13
16
  export * from './chat/tool-call-status-accumulator.js';
14
17
  export { AgentThreadMessageStatusStore, resolveChatThreadStatusFromStore, shouldShowChatThreadStatus, trackAgentThreadStatusMessageInStore } from './chat/agent-thread-message-status-store.js';
15
18
  export * from './file-preview/file-preview.js';
package/dist/cjs/index.js CHANGED
@@ -31,12 +31,15 @@ __reExport(index_exports, require("./chat/chat-input.js"), module.exports);
31
31
  __reExport(index_exports, require("./chat/chat-message.js"), module.exports);
32
32
  __reExport(index_exports, require("./chat/chat-typing-indicator.js"), module.exports);
33
33
  __reExport(index_exports, require("./chat/conversation-descriptor.js"), module.exports);
34
+ __reExport(index_exports, require("./chat/dataset-agent-thread.js"), module.exports);
34
35
  __reExport(index_exports, require("./chat/file-attachment.js"), module.exports);
35
36
  __reExport(index_exports, require("./chat/file-uploader.js"), module.exports);
36
37
  __reExport(index_exports, require("./chat/multi-thread-view.js"), module.exports);
37
38
  __reExport(index_exports, require("./chat/thread-list-view.js"), module.exports);
39
+ __reExport(index_exports, require("./chat/thread-view.js"), module.exports);
38
40
  __reExport(index_exports, require("./chat/agent-thread.js"), module.exports);
39
41
  __reExport(index_exports, require("./chat/new-chat-thread.js"), module.exports);
42
+ __reExport(index_exports, require("./chat/realtime-audio-output.js"), module.exports);
40
43
  __reExport(index_exports, require("./chat/tool-call-status-accumulator.js"), module.exports);
41
44
  var import_agent_thread_message_status_store = require("./chat/agent-thread-message-status-store.js");
42
45
  __reExport(index_exports, require("./file-preview/file-preview.js"), module.exports);
@@ -55,21 +55,14 @@ function MeetingControls({
55
55
  const controller = (0, import_meeting_scope.useMeetingController)(providedController);
56
56
  useControllerVersion(controller);
57
57
  const hasLocalParticipant = controller.livekitRoom.localParticipant != null;
58
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
59
- "div",
60
- {
61
- className: "flex flex-wrap items-center justify-center",
62
- style: { gap: spacing },
63
- children: [
64
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ConnectionButton, { controller, onDisconnect }),
65
- hasLocalParticipant ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
66
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(MicToggle, { controller }),
67
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CameraToggle, { controller }),
68
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ChangeSettings, { room: controller.livekitRoom })
69
- ] }) : null
70
- ]
71
- }
72
- );
58
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex flex-wrap items-center justify-center", style: { gap: spacing }, children: [
59
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ConnectionButton, { controller, onDisconnect }),
60
+ hasLocalParticipant ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
61
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(MicToggle, { controller }),
62
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CameraToggle, { controller }),
63
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ChangeSettings, { room: controller.livekitRoom })
64
+ ] }) : null
65
+ ] });
73
66
  }
74
67
  function describeCameraToggleError(error) {
75
68
  const message = String(error);
@@ -10,7 +10,7 @@ export interface MeetingLobbyJoinOptions {
10
10
  audioOutputDeviceId?: string;
11
11
  }
12
12
  export declare function meetingFastConnectOptions(options: MeetingLobbyJoinOptions): MeetingFastConnectOptions;
13
- export declare function MeetingLobby({ controller: providedController, onCancel, onJoin, }: {
13
+ export declare function MeetingLobby({ onCancel, onJoin, }: {
14
14
  controller?: MeetingController;
15
15
  onCancel?: () => void;
16
16
  onJoin?: (options: MeetingLobbyJoinOptions) => void | Promise<void>;