@meshagent/meshagent-tailwind 0.43.2 → 0.43.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +3 -0
- package/dist/cjs/chat/agent-thread.d.ts +15 -0
- package/dist/cjs/chat/agent-thread.js +613 -0
- package/dist/cjs/chat/chat-bot-view.d.ts +3 -2
- package/dist/cjs/chat/chat-bot-view.js +34 -34
- package/dist/cjs/chat/chat-bot-view.test.js +325 -0
- package/dist/cjs/chat/live-chat-widgets.test.js +256 -0
- package/dist/cjs/chat/multi-thread-view.d.ts +3 -2
- package/dist/cjs/chat/multi-thread-view.js +4 -2
- package/dist/cjs/chat/new-chat-thread.d.ts +3 -2
- package/dist/cjs/chat/new-chat-thread.js +5 -2
- package/dist/cjs/file-preview/file-preview.js +2 -2
- package/dist/cjs/index.d.ts +1 -2
- package/dist/cjs/index.js +1 -2
- package/dist/esm/chat/agent-thread.d.ts +15 -0
- package/dist/esm/chat/agent-thread.js +606 -0
- package/dist/esm/chat/chat-bot-view.d.ts +3 -2
- package/dist/esm/chat/chat-bot-view.js +34 -34
- package/dist/esm/chat/chat-bot-view.test.js +336 -0
- package/dist/esm/chat/live-chat-widgets.test.js +262 -0
- package/dist/esm/chat/multi-thread-view.d.ts +3 -2
- package/dist/esm/chat/multi-thread-view.js +4 -2
- package/dist/esm/chat/new-chat-thread.d.ts +3 -2
- package/dist/esm/chat/new-chat-thread.js +5 -2
- package/dist/esm/file-preview/file-preview.js +2 -2
- package/dist/esm/index.d.ts +1 -2
- package/dist/esm/index.js +1 -2
- package/dist/index.css +1 -1
- package/package.json +10 -5
- package/dist/cjs/chat/chat-thread.d.ts +0 -12
- package/dist/cjs/chat/chat-thread.js +0 -815
- package/dist/cjs/chat/dataset-chat-thread.d.ts +0 -16
- package/dist/cjs/chat/dataset-chat-thread.js +0 -1813
- package/dist/esm/chat/chat-thread.d.ts +0 -12
- package/dist/esm/chat/chat-thread.js +0 -785
- package/dist/esm/chat/dataset-chat-thread.d.ts +0 -16
- package/dist/esm/chat/dataset-chat-thread.js +0 -1811
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
3
|
+
var import_vitest = require("vitest");
|
|
4
|
+
var import_react = require("react");
|
|
5
|
+
var import_react2 = require("@testing-library/react");
|
|
6
|
+
var import_meshagent = require("@meshagent/meshagent");
|
|
7
|
+
var import_meshagent_agents = require("@meshagent/meshagent-agents");
|
|
8
|
+
var import_agent_thread = require("./agent-thread.js");
|
|
9
|
+
var import_chat_bot_view = require("./chat-bot-view.js");
|
|
10
|
+
const REQUIRED_ENV = [
|
|
11
|
+
"MESHAGENT_TOKEN",
|
|
12
|
+
"MESHAGENT_ROOM",
|
|
13
|
+
"RUN_LIVE_WIDGET_TESTS",
|
|
14
|
+
"TEST_AGENT_NAME"
|
|
15
|
+
];
|
|
16
|
+
const missingEnv = REQUIRED_ENV.filter((name) => process.env[name] == null || process.env[name]?.trim() === "");
|
|
17
|
+
const liveDescribe = missingEnv.length === 0 ? import_vitest.describe : import_vitest.describe.skip;
|
|
18
|
+
liveDescribe("Live chat widgets", () => {
|
|
19
|
+
let room;
|
|
20
|
+
let chatClient;
|
|
21
|
+
const observedMessages = [];
|
|
22
|
+
let previousActEnvironment;
|
|
23
|
+
(0, import_vitest.beforeAll)(async () => {
|
|
24
|
+
previousActEnvironment = globalThis.IS_REACT_ACT_ENVIRONMENT;
|
|
25
|
+
setReactActEnvironment(false);
|
|
26
|
+
room = new import_meshagent.RoomClient();
|
|
27
|
+
await room.start({
|
|
28
|
+
onError: (error) => {
|
|
29
|
+
console.error("live widget room client error", error);
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
chatClient = new import_meshagent_agents.MessagingChatClient({
|
|
33
|
+
room,
|
|
34
|
+
agentName: process.env.TEST_AGENT_NAME
|
|
35
|
+
});
|
|
36
|
+
void (async () => {
|
|
37
|
+
for await (const event of chatClient.events) {
|
|
38
|
+
observedMessages.push(event.message);
|
|
39
|
+
}
|
|
40
|
+
})();
|
|
41
|
+
await chatClient.start();
|
|
42
|
+
await withTimeout(
|
|
43
|
+
chatClient.waitForAgentParticipant({ waitKey: "live-chat-widget-agent" }),
|
|
44
|
+
3e4,
|
|
45
|
+
`agent participant '${process.env.TEST_AGENT_NAME}' did not appear`
|
|
46
|
+
);
|
|
47
|
+
});
|
|
48
|
+
(0, import_vitest.afterEach)(() => {
|
|
49
|
+
(0, import_react2.cleanup)();
|
|
50
|
+
});
|
|
51
|
+
(0, import_vitest.afterAll)(async () => {
|
|
52
|
+
await chatClient?.stop().catch(() => void 0);
|
|
53
|
+
room?.dispose();
|
|
54
|
+
setReactActEnvironment(previousActEnvironment);
|
|
55
|
+
});
|
|
56
|
+
(0, import_vitest.it)("renders a live AgentThread pending message and assistant response", async () => {
|
|
57
|
+
const start = await chatClient.startThread({
|
|
58
|
+
message: "Reply with only LIVE_WIDGET_INITIAL_OK.",
|
|
59
|
+
attachments: [],
|
|
60
|
+
senderName: "live-widget-test"
|
|
61
|
+
});
|
|
62
|
+
(0, import_react2.render)(
|
|
63
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
64
|
+
import_agent_thread.AgentThread,
|
|
65
|
+
{
|
|
66
|
+
room,
|
|
67
|
+
path: start.threadPath,
|
|
68
|
+
chatClient,
|
|
69
|
+
agentName: process.env.TEST_AGENT_NAME
|
|
70
|
+
}
|
|
71
|
+
)
|
|
72
|
+
);
|
|
73
|
+
await waitForDocumentText("LIVE_WIDGET_INITIAL_OK", "initial assistant response");
|
|
74
|
+
const pendingMessage = `live widget turn ${liveId()}: reply with only LIVE_WIDGET_TURN_OK.`;
|
|
75
|
+
const beforeObservedCount = observedMessages.length;
|
|
76
|
+
import_react2.fireEvent.change(import_react2.screen.getByPlaceholderText("Type a message"), {
|
|
77
|
+
target: { value: pendingMessage }
|
|
78
|
+
});
|
|
79
|
+
import_react2.fireEvent.click(import_react2.screen.getByTitle("Send"));
|
|
80
|
+
(0, import_vitest.expect)(await import_react2.screen.findByText(pendingMessage)).toBeTruthy();
|
|
81
|
+
await waitForObservedMessage(
|
|
82
|
+
beforeObservedCount,
|
|
83
|
+
(message) => message.type === import_meshagent_agents.agentTurnStartAcceptedType && stringValue(message, "threadId") === start.threadPath,
|
|
84
|
+
"widget turn acceptance"
|
|
85
|
+
);
|
|
86
|
+
await waitForObservedMessage(
|
|
87
|
+
beforeObservedCount,
|
|
88
|
+
(message) => message.type === import_meshagent_agents.agentTurnStartedType && stringValue(message, "threadId") === start.threadPath,
|
|
89
|
+
"widget turn start"
|
|
90
|
+
);
|
|
91
|
+
await waitForObservedMessage(
|
|
92
|
+
beforeObservedCount,
|
|
93
|
+
(message) => message.type === import_meshagent_agents.agentTextContentDeltaType && stringValue(message, "threadId") === start.threadPath,
|
|
94
|
+
"widget turn assistant delta"
|
|
95
|
+
);
|
|
96
|
+
await waitForDocumentText("LIVE_WIDGET_TURN_OK", "turn assistant response");
|
|
97
|
+
}, 18e4);
|
|
98
|
+
(0, import_vitest.it)("creates two live threads through ChatBotView and keeps the second selected", async () => {
|
|
99
|
+
const selectedPaths = [];
|
|
100
|
+
(0, import_react2.render)(
|
|
101
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react.StrictMode, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
102
|
+
import_chat_bot_view.ChatBotView,
|
|
103
|
+
{
|
|
104
|
+
room,
|
|
105
|
+
chatClient,
|
|
106
|
+
agentName: process.env.TEST_AGENT_NAME,
|
|
107
|
+
threadDisplayMode: import_chat_bot_view.ChatThreadDisplayMode.MultiThreadComposer,
|
|
108
|
+
threadListPath: `agent://${process.env.TEST_AGENT_NAME}/threads`,
|
|
109
|
+
onSelectedThreadPathChanged: (path) => {
|
|
110
|
+
selectedPaths.push(path);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
) })
|
|
114
|
+
);
|
|
115
|
+
const firstPending = `live widget first thread ${liveId()}: reply with only LIVE_WIDGET_THREAD_ONE_OK.`;
|
|
116
|
+
import_react2.fireEvent.change(await import_react2.screen.findByPlaceholderText(`Type a message or @${process.env.TEST_AGENT_NAME}`), {
|
|
117
|
+
target: { value: firstPending }
|
|
118
|
+
});
|
|
119
|
+
import_react2.fireEvent.click(import_react2.screen.getByTitle("Send"));
|
|
120
|
+
await (0, import_react2.waitFor)(() => (0, import_vitest.expect)(selectedPaths.at(-1)).to.be.a("string").and.not.equal(""), { timeout: 9e4 });
|
|
121
|
+
const firstPath = selectedPaths.at(-1);
|
|
122
|
+
(0, import_vitest.expect)(firstPath).to.be.a("string").and.not.equal("");
|
|
123
|
+
(0, import_vitest.expect)(await import_react2.screen.findByText(firstPending)).toBeTruthy();
|
|
124
|
+
await waitForDocumentText("LIVE_WIDGET_THREAD_ONE_OK", "first ChatBotView assistant response");
|
|
125
|
+
import_react2.fireEvent.click(import_react2.screen.getByText("New thread"));
|
|
126
|
+
await (0, import_react2.waitFor)(() => (0, import_vitest.expect)(selectedPaths.at(-1)).to.equal(null), { timeout: 1e4 });
|
|
127
|
+
const secondPending = `live widget second thread ${liveId()}: reply with only LIVE_WIDGET_THREAD_TWO_OK.`;
|
|
128
|
+
import_react2.fireEvent.change(await import_react2.screen.findByPlaceholderText(`Type a message or @${process.env.TEST_AGENT_NAME}`), {
|
|
129
|
+
target: { value: secondPending }
|
|
130
|
+
});
|
|
131
|
+
import_react2.fireEvent.click(import_react2.screen.getByTitle("Send"));
|
|
132
|
+
await (0, import_react2.waitFor)(() => {
|
|
133
|
+
(0, import_vitest.expect)(selectedPaths.at(-1)).to.be.a("string").and.not.equal("");
|
|
134
|
+
(0, import_vitest.expect)(selectedPaths.at(-1)).to.not.equal(firstPath);
|
|
135
|
+
}, { timeout: 9e4 });
|
|
136
|
+
(0, import_vitest.expect)(await import_react2.screen.findByText(secondPending)).toBeTruthy();
|
|
137
|
+
(0, import_vitest.expect)(import_react2.screen.queryByText(firstPending)).to.equal(null);
|
|
138
|
+
await waitForDocumentText("LIVE_WIDGET_THREAD_TWO_OK", "second ChatBotView assistant response");
|
|
139
|
+
}, 24e4);
|
|
140
|
+
(0, import_vitest.it)("passes client toolkits from widgets into live turn starts", async () => {
|
|
141
|
+
const start = await chatClient.startThread({
|
|
142
|
+
message: "Reply with only LIVE_WIDGET_TOOL_THREAD_OK.",
|
|
143
|
+
attachments: [],
|
|
144
|
+
senderName: "live-widget-test"
|
|
145
|
+
});
|
|
146
|
+
const clientToolkits = [new import_meshagent_agents.ClientToolkitDescription({
|
|
147
|
+
name: "ask_user",
|
|
148
|
+
title: "Ask User",
|
|
149
|
+
description: "Ask the user a short question.",
|
|
150
|
+
inputSchema: {
|
|
151
|
+
type: "object",
|
|
152
|
+
additionalProperties: false,
|
|
153
|
+
required: ["prompt"],
|
|
154
|
+
properties: {
|
|
155
|
+
prompt: { type: "string" }
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
})];
|
|
159
|
+
(0, import_react2.render)(
|
|
160
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
161
|
+
import_agent_thread.AgentThread,
|
|
162
|
+
{
|
|
163
|
+
room,
|
|
164
|
+
path: start.threadPath,
|
|
165
|
+
chatClient,
|
|
166
|
+
agentName: process.env.TEST_AGENT_NAME,
|
|
167
|
+
clientToolkits
|
|
168
|
+
}
|
|
169
|
+
)
|
|
170
|
+
);
|
|
171
|
+
await waitForDocumentText("LIVE_WIDGET_TOOL_THREAD_OK", "tool setup assistant response");
|
|
172
|
+
const beforeObservedCount = observedMessages.length;
|
|
173
|
+
import_react2.fireEvent.change(import_react2.screen.getByPlaceholderText("Type a message"), {
|
|
174
|
+
target: {
|
|
175
|
+
value: "Use the ask_user client tool to ask whether the live widget client toolkit is connected."
|
|
176
|
+
}
|
|
177
|
+
});
|
|
178
|
+
import_react2.fireEvent.click(import_react2.screen.getByTitle("Send"));
|
|
179
|
+
await waitForObservedMessage(
|
|
180
|
+
beforeObservedCount,
|
|
181
|
+
(message) => stringValue(message, "threadId") === start.threadPath && (message.type === import_meshagent_agents.agentClientToolCallRequestedType || message.type === import_meshagent_agents.agentTextContentDeltaType),
|
|
182
|
+
"widget client toolkit-capable response"
|
|
183
|
+
);
|
|
184
|
+
}, 18e4);
|
|
185
|
+
async function waitForObservedMessage(afterCount, predicate, label, timeoutMs = 9e4) {
|
|
186
|
+
const deadline = Date.now() + timeoutMs;
|
|
187
|
+
while (Date.now() < deadline) {
|
|
188
|
+
const message = observedMessages.slice(afterCount).find(predicate);
|
|
189
|
+
if (message != null) {
|
|
190
|
+
return message;
|
|
191
|
+
}
|
|
192
|
+
await delay(50);
|
|
193
|
+
}
|
|
194
|
+
throw new Error(`${label} was not observed within ${timeoutMs}ms. Observed: ${summarizeMessages(observedMessages)}`);
|
|
195
|
+
}
|
|
196
|
+
});
|
|
197
|
+
if (missingEnv.length > 0) {
|
|
198
|
+
(0, import_vitest.describe)("Live chat widgets", () => {
|
|
199
|
+
(0, import_vitest.it)(`is skipped unless ${REQUIRED_ENV.join(", ")} are set`, () => {
|
|
200
|
+
(0, import_vitest.expect)(missingEnv.length).to.be.greaterThan(0);
|
|
201
|
+
});
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
async function waitForDocumentText(text, label, timeoutMs = 9e4) {
|
|
205
|
+
await (0, import_react2.waitFor)(() => {
|
|
206
|
+
(0, import_vitest.expect)(document.body.textContent ?? "", label).to.contain(text);
|
|
207
|
+
}, { timeout: timeoutMs });
|
|
208
|
+
}
|
|
209
|
+
async function withTimeout(promise, timeoutMs, label) {
|
|
210
|
+
let timeout;
|
|
211
|
+
try {
|
|
212
|
+
return await Promise.race([
|
|
213
|
+
promise,
|
|
214
|
+
new Promise((_, reject) => {
|
|
215
|
+
timeout = setTimeout(() => reject(new Error(`${label} within ${timeoutMs}ms`)), timeoutMs);
|
|
216
|
+
})
|
|
217
|
+
]);
|
|
218
|
+
} finally {
|
|
219
|
+
if (timeout != null) {
|
|
220
|
+
clearTimeout(timeout);
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
function stringValue(value, property) {
|
|
225
|
+
if (value == null || typeof value !== "object" || !Object.prototype.hasOwnProperty.call(value, property)) {
|
|
226
|
+
return void 0;
|
|
227
|
+
}
|
|
228
|
+
const item = value[property];
|
|
229
|
+
return typeof item === "string" && item.trim() !== "" ? item : void 0;
|
|
230
|
+
}
|
|
231
|
+
function summarizeMessages(messages) {
|
|
232
|
+
return messages.map((message) => {
|
|
233
|
+
const threadId = stringValue(message, "threadId");
|
|
234
|
+
const source = stringValue(message, "sourceMessageId");
|
|
235
|
+
const turn = stringValue(message, "turnId");
|
|
236
|
+
return [message.type, threadId == null ? void 0 : `thread=${threadId}`, source == null ? void 0 : `source=${source}`, turn == null ? void 0 : `turn=${turn}`].filter((part) => part != null).join(" ");
|
|
237
|
+
}).join(", ");
|
|
238
|
+
}
|
|
239
|
+
function setReactActEnvironment(value) {
|
|
240
|
+
Object.defineProperty(globalThis, "IS_REACT_ACT_ENVIRONMENT", {
|
|
241
|
+
configurable: true,
|
|
242
|
+
writable: true,
|
|
243
|
+
value
|
|
244
|
+
});
|
|
245
|
+
Object.defineProperty(window, "IS_REACT_ACT_ENVIRONMENT", {
|
|
246
|
+
configurable: true,
|
|
247
|
+
writable: true,
|
|
248
|
+
value
|
|
249
|
+
});
|
|
250
|
+
}
|
|
251
|
+
function liveId() {
|
|
252
|
+
return `${Date.now()}-${Math.random().toString(16).slice(2)}`;
|
|
253
|
+
}
|
|
254
|
+
function delay(ms) {
|
|
255
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
256
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ReactElement } from "react";
|
|
2
2
|
import { RoomClient } from "@meshagent/meshagent";
|
|
3
|
-
import type { BaseChatClient } from "@meshagent/meshagent-agents";
|
|
3
|
+
import type { BaseChatClient, ClientToolkitDescription } from "@meshagent/meshagent-agents";
|
|
4
4
|
export type MultiThreadContentBuilder = (threadPath: string) => ReactElement;
|
|
5
5
|
export interface MultiThreadViewProps {
|
|
6
6
|
room: RoomClient;
|
|
@@ -17,5 +17,6 @@ export interface MultiThreadViewProps {
|
|
|
17
17
|
centerComposer?: boolean;
|
|
18
18
|
emptyStateTitle?: string;
|
|
19
19
|
emptyStateDescription?: string;
|
|
20
|
+
clientToolkits?: ClientToolkitDescription[];
|
|
20
21
|
}
|
|
21
|
-
export declare function MultiThreadView({ room, chatClient, disposeChatClient, agentName, builder, toolkit, tool, selectedThreadPath, onSelectedThreadPathChanged, onSelectedThreadResolved, newThreadResetVersion, centerComposer, emptyStateTitle, emptyStateDescription, }: MultiThreadViewProps): ReactElement;
|
|
22
|
+
export declare function MultiThreadView({ room, chatClient, disposeChatClient, agentName, builder, toolkit, tool, selectedThreadPath, onSelectedThreadPathChanged, onSelectedThreadResolved, newThreadResetVersion, centerComposer, emptyStateTitle, emptyStateDescription, clientToolkits, }: MultiThreadViewProps): ReactElement;
|
|
@@ -42,7 +42,8 @@ function MultiThreadView({
|
|
|
42
42
|
newThreadResetVersion = 0,
|
|
43
43
|
centerComposer = true,
|
|
44
44
|
emptyStateTitle = "Start a new thread",
|
|
45
|
-
emptyStateDescription = "Connect with this agent and your team"
|
|
45
|
+
emptyStateDescription = "Connect with this agent and your team",
|
|
46
|
+
clientToolkits
|
|
46
47
|
}) {
|
|
47
48
|
const controlledSelectedThreadPath = selectedThreadPath !== void 0 ? normalizeSelectedThreadPath(selectedThreadPath) : void 0;
|
|
48
49
|
const [internalSelectedThreadPath, setInternalSelectedThreadPath] = (0, import_react.useState)(() => controlledSelectedThreadPath ?? null);
|
|
@@ -90,7 +91,8 @@ function MultiThreadView({
|
|
|
90
91
|
onSelectedThreadResolved?.(normalizedPath, displayName);
|
|
91
92
|
},
|
|
92
93
|
emptyStateTitle,
|
|
93
|
-
emptyStateDescription
|
|
94
|
+
emptyStateDescription,
|
|
95
|
+
clientToolkits
|
|
94
96
|
},
|
|
95
97
|
composerKey
|
|
96
98
|
);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ReactElement } from "react";
|
|
2
2
|
import { RoomClient } from "@meshagent/meshagent";
|
|
3
|
-
import type { BaseChatClient } from "@meshagent/meshagent-agents";
|
|
3
|
+
import type { BaseChatClient, ClientToolkitDescription } from "@meshagent/meshagent-agents";
|
|
4
4
|
export type NewChatThreadBuilder = (threadPath: string) => ReactElement;
|
|
5
5
|
export interface NewChatThreadProps {
|
|
6
6
|
room: RoomClient;
|
|
@@ -16,5 +16,6 @@ export interface NewChatThreadProps {
|
|
|
16
16
|
centerComposer?: boolean;
|
|
17
17
|
emptyStateTitle?: string;
|
|
18
18
|
emptyStateDescription?: string;
|
|
19
|
+
clientToolkits?: ClientToolkitDescription[];
|
|
19
20
|
}
|
|
20
|
-
export declare function NewChatThread({ room, chatClient, disposeChatClient, agentName, builder, selectedThreadPath, onThreadPathChanged, onThreadResolved, centerComposer, emptyStateTitle, emptyStateDescription, }: NewChatThreadProps): ReactElement;
|
|
21
|
+
export declare function NewChatThread({ room, chatClient, disposeChatClient, agentName, builder, selectedThreadPath, onThreadPathChanged, onThreadResolved, centerComposer, emptyStateTitle, emptyStateDescription, clientToolkits, }: NewChatThreadProps): ReactElement;
|
|
@@ -98,7 +98,8 @@ function NewChatThread({
|
|
|
98
98
|
onThreadResolved,
|
|
99
99
|
centerComposer = true,
|
|
100
100
|
emptyStateTitle,
|
|
101
|
-
emptyStateDescription
|
|
101
|
+
emptyStateDescription,
|
|
102
|
+
clientToolkits
|
|
102
103
|
}) {
|
|
103
104
|
const [internalThreadPath, setInternalThreadPath] = (0, import_react.useState)(null);
|
|
104
105
|
const [newThreadDraft, setNewThreadDraft] = (0, import_react.useState)("");
|
|
@@ -193,7 +194,8 @@ function NewChatThread({
|
|
|
193
194
|
const result = await activeChatClient.startThread({
|
|
194
195
|
message: text,
|
|
195
196
|
attachments: newThreadAttachments.map((attachment) => attachment.path),
|
|
196
|
-
senderName: getParticipantName(room.localParticipant) || void 0
|
|
197
|
+
senderName: getParticipantName(room.localParticipant) || void 0,
|
|
198
|
+
clientToolkits
|
|
197
199
|
});
|
|
198
200
|
ensureOperationActive(operationId, activeOperationRef);
|
|
199
201
|
const threadPath = result.threadPath;
|
|
@@ -225,6 +227,7 @@ function NewChatThread({
|
|
|
225
227
|
creatingNewThread,
|
|
226
228
|
newThreadAttachments,
|
|
227
229
|
newThreadDraft,
|
|
230
|
+
clientToolkits,
|
|
228
231
|
onThreadPathChanged,
|
|
229
232
|
onThreadResolved,
|
|
230
233
|
room,
|
|
@@ -40,7 +40,7 @@ var import_dialog = require("../components/ui/dialog.js");
|
|
|
40
40
|
var import_button = require("../components/ui/button.js");
|
|
41
41
|
var import_spinner = require("../components/ui/spinner.js");
|
|
42
42
|
var import_utils = require("../lib/utils.js");
|
|
43
|
-
var
|
|
43
|
+
var import_agent_thread = require("../chat/agent-thread.js");
|
|
44
44
|
import_react_pdf.pdfjs.GlobalWorkerOptions.workerSrc = `https://unpkg.com/pdfjs-dist@${import_react_pdf.pdfjs.version}/build/pdf.worker.min.mjs`;
|
|
45
45
|
var FileKind = /* @__PURE__ */ ((FileKind2) => {
|
|
46
46
|
FileKind2["Image"] = "image";
|
|
@@ -515,7 +515,7 @@ function FilePreview({ room, path }) {
|
|
|
515
515
|
case "source" /* Source */:
|
|
516
516
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SourcePreview, { room, path });
|
|
517
517
|
case "thread" /* Thread */:
|
|
518
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
518
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_agent_thread.AgentThread, { room, path });
|
|
519
519
|
case "unknown" /* Unknown */:
|
|
520
520
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(UnsupportedPreview, { room, path });
|
|
521
521
|
}
|
package/dist/cjs/index.d.ts
CHANGED
|
@@ -2,13 +2,12 @@ export * from './chat/chat-bot-view.js';
|
|
|
2
2
|
export * from './chat/chat-hooks.js';
|
|
3
3
|
export * from './chat/chat-input.js';
|
|
4
4
|
export * from './chat/chat-message.js';
|
|
5
|
-
export * from './chat/chat-thread.js';
|
|
6
5
|
export * from './chat/chat-typing-indicator.js';
|
|
7
6
|
export * from './chat/conversation-descriptor.js';
|
|
8
|
-
export * from './chat/dataset-chat-thread.js';
|
|
9
7
|
export * from './chat/file-attachment.js';
|
|
10
8
|
export * from './chat/file-uploader.js';
|
|
11
9
|
export * from './chat/multi-thread-view.js';
|
|
10
|
+
export * from './chat/agent-thread.js';
|
|
12
11
|
export * from './chat/new-chat-thread.js';
|
|
13
12
|
export * from './file-preview/file-preview.js';
|
|
14
13
|
export * from './forms/email-address.js';
|
package/dist/cjs/index.js
CHANGED
|
@@ -19,13 +19,12 @@ __reExport(index_exports, require("./chat/chat-bot-view.js"), module.exports);
|
|
|
19
19
|
__reExport(index_exports, require("./chat/chat-hooks.js"), module.exports);
|
|
20
20
|
__reExport(index_exports, require("./chat/chat-input.js"), module.exports);
|
|
21
21
|
__reExport(index_exports, require("./chat/chat-message.js"), module.exports);
|
|
22
|
-
__reExport(index_exports, require("./chat/chat-thread.js"), module.exports);
|
|
23
22
|
__reExport(index_exports, require("./chat/chat-typing-indicator.js"), module.exports);
|
|
24
23
|
__reExport(index_exports, require("./chat/conversation-descriptor.js"), module.exports);
|
|
25
|
-
__reExport(index_exports, require("./chat/dataset-chat-thread.js"), module.exports);
|
|
26
24
|
__reExport(index_exports, require("./chat/file-attachment.js"), module.exports);
|
|
27
25
|
__reExport(index_exports, require("./chat/file-uploader.js"), module.exports);
|
|
28
26
|
__reExport(index_exports, require("./chat/multi-thread-view.js"), module.exports);
|
|
27
|
+
__reExport(index_exports, require("./chat/agent-thread.js"), module.exports);
|
|
29
28
|
__reExport(index_exports, require("./chat/new-chat-thread.js"), module.exports);
|
|
30
29
|
__reExport(index_exports, require("./file-preview/file-preview.js"), module.exports);
|
|
31
30
|
__reExport(index_exports, require("./forms/email-address.js"), module.exports);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { ReactElement } from "react";
|
|
2
|
+
import type { RoomClient } from "@meshagent/meshagent";
|
|
3
|
+
import type { BaseChatClient, ClientToolkitDescription } from "@meshagent/meshagent-agents";
|
|
4
|
+
interface AgentThreadProps {
|
|
5
|
+
room: RoomClient;
|
|
6
|
+
path: string;
|
|
7
|
+
chatClient?: BaseChatClient;
|
|
8
|
+
disposeChatClient?: boolean;
|
|
9
|
+
agentName?: string;
|
|
10
|
+
emptyStateTitle?: string;
|
|
11
|
+
emptyStateDescription?: string;
|
|
12
|
+
clientToolkits?: ClientToolkitDescription[];
|
|
13
|
+
}
|
|
14
|
+
export declare function AgentThread({ room, path, chatClient, disposeChatClient, agentName, emptyStateTitle, emptyStateDescription, clientToolkits, }: AgentThreadProps): ReactElement;
|
|
15
|
+
export {};
|