@meshagent/meshagent-tailwind 0.39.8 → 0.40.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.
- package/CHANGELOG.md +8 -0
- package/dist/cjs/{ChatBotView.js → chat/chat-bot-view.js} +37 -22
- package/dist/cjs/{chat-hooks.d.ts → chat/chat-hooks.d.ts} +5 -1
- package/dist/cjs/{chat-hooks.js → chat/chat-hooks.js} +12 -2
- package/dist/cjs/{ChatInput.js → chat/chat-input.js} +9 -9
- package/dist/cjs/chat/chat-thread.d.ts +12 -0
- package/dist/cjs/{ChatThread.js → chat/chat-thread.js} +75 -28
- package/dist/cjs/{ChatTypingIndicator.js → chat/chat-typing-indicator.js} +4 -4
- package/dist/{esm → cjs/chat}/conversation-descriptor.d.ts +7 -1
- package/dist/cjs/{conversation-descriptor.js → chat/conversation-descriptor.js} +41 -7
- package/dist/cjs/chat/dataset-chat-thread.d.ts +13 -0
- package/dist/cjs/chat/dataset-chat-thread.js +1840 -0
- package/dist/cjs/{FileUploader.js → chat/file-uploader.js} +4 -4
- package/dist/cjs/{multi-thread-view.js → chat/multi-thread-view.js} +8 -3
- package/dist/cjs/chat/new-chat-thread.d.ts +17 -0
- package/dist/cjs/{Chat.js → chat/new-chat-thread.js} +43 -168
- package/dist/cjs/{UploadPill.js → chat/upload-pill.js} +5 -5
- package/dist/cjs/file-preview/file-preview.d.ts +34 -0
- package/dist/cjs/file-preview/file-preview.js +329 -0
- package/dist/cjs/forms/email-address.d.ts +10 -0
- package/dist/cjs/forms/email-address.js +105 -0
- package/dist/cjs/forms/form.d.ts +27 -0
- package/dist/cjs/forms/form.js +200 -0
- package/dist/cjs/forms/multi-select-autocomplete.d.ts +35 -0
- package/dist/cjs/forms/multi-select-autocomplete.js +294 -0
- package/dist/cjs/forms/select-users-dialog.d.ts +20 -0
- package/dist/cjs/forms/select-users-dialog.js +145 -0
- package/dist/cjs/forms/select-users.d.ts +16 -0
- package/dist/cjs/forms/select-users.js +117 -0
- package/dist/cjs/index.d.ts +19 -11
- package/dist/cjs/index.js +19 -11
- package/dist/cjs/meetings/audio-visualization.d.ts +7 -0
- package/dist/cjs/meetings/audio-visualization.js +74 -0
- package/dist/cjs/meetings/controls.d.ts +19 -0
- package/dist/cjs/meetings/controls.js +300 -0
- package/dist/cjs/meetings/meeting-scope.d.ts +83 -0
- package/dist/cjs/meetings/meeting-scope.js +309 -0
- package/dist/cjs/meetings/meetings.d.ts +5 -0
- package/dist/cjs/meetings/meetings.js +22 -0
- package/dist/cjs/meetings/participants.d.ts +13 -0
- package/dist/cjs/meetings/participants.js +154 -0
- package/dist/cjs/meetings/wake-lock.d.ts +4 -0
- package/dist/cjs/meetings/wake-lock.js +55 -0
- package/dist/esm/{ChatBotView.js → chat/chat-bot-view.js} +34 -19
- package/dist/esm/{chat-hooks.d.ts → chat/chat-hooks.d.ts} +5 -1
- package/dist/esm/{chat-hooks.js → chat/chat-hooks.js} +12 -2
- package/dist/esm/{ChatInput.js → chat/chat-input.js} +4 -4
- package/dist/esm/chat/chat-thread.d.ts +12 -0
- package/dist/esm/{ChatThread.js → chat/chat-thread.js} +70 -23
- package/dist/esm/{ChatTypingIndicator.js → chat/chat-typing-indicator.js} +1 -1
- package/dist/{cjs → esm/chat}/conversation-descriptor.d.ts +7 -1
- package/dist/esm/{conversation-descriptor.js → chat/conversation-descriptor.js} +41 -7
- package/dist/esm/chat/dataset-chat-thread.d.ts +13 -0
- package/dist/esm/chat/dataset-chat-thread.js +1815 -0
- package/dist/esm/{FileUploader.js → chat/file-uploader.js} +1 -1
- package/dist/esm/{multi-thread-view.js → chat/multi-thread-view.js} +8 -3
- package/dist/esm/chat/new-chat-thread.d.ts +17 -0
- package/dist/esm/{Chat.js → chat/new-chat-thread.js} +40 -165
- package/dist/esm/{UploadPill.js → chat/upload-pill.js} +2 -2
- package/dist/esm/file-preview/file-preview.d.ts +34 -0
- package/dist/esm/file-preview/file-preview.js +316 -0
- package/dist/esm/forms/email-address.d.ts +10 -0
- package/dist/esm/forms/email-address.js +85 -0
- package/dist/esm/forms/form.d.ts +27 -0
- package/dist/esm/forms/form.js +193 -0
- package/dist/esm/forms/multi-select-autocomplete.d.ts +35 -0
- package/dist/esm/forms/multi-select-autocomplete.js +274 -0
- package/dist/esm/forms/select-users-dialog.d.ts +20 -0
- package/dist/esm/forms/select-users-dialog.js +132 -0
- package/dist/esm/forms/select-users.d.ts +16 -0
- package/dist/esm/forms/select-users.js +97 -0
- package/dist/esm/index.d.ts +19 -11
- package/dist/esm/index.js +19 -11
- package/dist/esm/meetings/audio-visualization.d.ts +7 -0
- package/dist/esm/meetings/audio-visualization.js +54 -0
- package/dist/esm/meetings/controls.d.ts +19 -0
- package/dist/esm/meetings/controls.js +294 -0
- package/dist/esm/meetings/meeting-scope.d.ts +83 -0
- package/dist/esm/meetings/meeting-scope.js +294 -0
- package/dist/esm/meetings/meetings.d.ts +5 -0
- package/dist/esm/meetings/meetings.js +5 -0
- package/dist/esm/meetings/participants.d.ts +13 -0
- package/dist/esm/meetings/participants.js +137 -0
- package/dist/esm/meetings/wake-lock.d.ts +4 -0
- package/dist/esm/meetings/wake-lock.js +35 -0
- package/dist/index.css +2 -2
- package/package.json +7 -4
- package/dist/cjs/Chat.d.ts +0 -15
- package/dist/cjs/ChatThread.d.ts +0 -21
- package/dist/esm/Chat.d.ts +0 -15
- package/dist/esm/ChatThread.d.ts +0 -21
- /package/dist/cjs/{ChatBotView.d.ts → chat/chat-bot-view.d.ts} +0 -0
- /package/dist/cjs/{ChatInput.d.ts → chat/chat-input.d.ts} +0 -0
- /package/dist/cjs/{chat-message.d.ts → chat/chat-message.d.ts} +0 -0
- /package/dist/cjs/{chat-message.js → chat/chat-message.js} +0 -0
- /package/dist/cjs/{ChatTypingIndicator.d.ts → chat/chat-typing-indicator.d.ts} +0 -0
- /package/dist/cjs/{file-attachment.d.ts → chat/file-attachment.d.ts} +0 -0
- /package/dist/cjs/{file-attachment.js → chat/file-attachment.js} +0 -0
- /package/dist/cjs/{FileUploader.d.ts → chat/file-uploader.d.ts} +0 -0
- /package/dist/cjs/{multi-thread-view.d.ts → chat/multi-thread-view.d.ts} +0 -0
- /package/dist/cjs/{UploadPill.d.ts → chat/upload-pill.d.ts} +0 -0
- /package/dist/esm/{ChatBotView.d.ts → chat/chat-bot-view.d.ts} +0 -0
- /package/dist/esm/{ChatInput.d.ts → chat/chat-input.d.ts} +0 -0
- /package/dist/esm/{chat-message.d.ts → chat/chat-message.d.ts} +0 -0
- /package/dist/esm/{chat-message.js → chat/chat-message.js} +0 -0
- /package/dist/esm/{ChatTypingIndicator.d.ts → chat/chat-typing-indicator.d.ts} +0 -0
- /package/dist/esm/{file-attachment.d.ts → chat/file-attachment.d.ts} +0 -0
- /package/dist/esm/{file-attachment.js → chat/file-attachment.js} +0 -0
- /package/dist/esm/{FileUploader.d.ts → chat/file-uploader.d.ts} +0 -0
- /package/dist/esm/{multi-thread-view.d.ts → chat/multi-thread-view.d.ts} +0 -0
- /package/dist/esm/{UploadPill.d.ts → chat/upload-pill.d.ts} +0 -0
|
@@ -26,15 +26,15 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
26
26
|
mod
|
|
27
27
|
));
|
|
28
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
var
|
|
30
|
-
__export(
|
|
29
|
+
var file_uploader_exports = {};
|
|
30
|
+
__export(file_uploader_exports, {
|
|
31
31
|
FileUploader: () => FileUploader
|
|
32
32
|
});
|
|
33
|
-
module.exports = __toCommonJS(
|
|
33
|
+
module.exports = __toCommonJS(file_uploader_exports);
|
|
34
34
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
35
35
|
var React = __toESM(require("react"));
|
|
36
36
|
var import_lucide_react = require("lucide-react");
|
|
37
|
-
var import_button = require("
|
|
37
|
+
var import_button = require("../components/ui/button");
|
|
38
38
|
function FileUploader({
|
|
39
39
|
onFilesSelected,
|
|
40
40
|
accept = "",
|
|
@@ -23,7 +23,7 @@ __export(multi_thread_view_exports, {
|
|
|
23
23
|
module.exports = __toCommonJS(multi_thread_view_exports);
|
|
24
24
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
25
25
|
var import_react = require("react");
|
|
26
|
-
var
|
|
26
|
+
var import_new_chat_thread = require("./new-chat-thread");
|
|
27
27
|
function normalizeSelectedThreadPath(path) {
|
|
28
28
|
const normalized = path?.trim();
|
|
29
29
|
return normalized ? normalized : null;
|
|
@@ -65,19 +65,24 @@ function MultiThreadView({
|
|
|
65
65
|
return builder(activeSelectedThreadPath);
|
|
66
66
|
}
|
|
67
67
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
68
|
-
|
|
68
|
+
import_new_chat_thread.NewChatThread,
|
|
69
69
|
{
|
|
70
70
|
room,
|
|
71
71
|
agentName,
|
|
72
|
+
builder,
|
|
72
73
|
toolkit,
|
|
73
74
|
tool,
|
|
75
|
+
selectedThreadPath: activeSelectedThreadPath,
|
|
74
76
|
centerComposer,
|
|
75
|
-
|
|
77
|
+
onThreadPathChanged: (path) => {
|
|
76
78
|
const normalizedPath = normalizeSelectedThreadPath(path);
|
|
77
79
|
if (controlledSelectedThreadPath === void 0) {
|
|
78
80
|
setInternalSelectedThreadPath(normalizedPath);
|
|
79
81
|
}
|
|
80
82
|
onSelectedThreadPathChanged?.(normalizedPath);
|
|
83
|
+
},
|
|
84
|
+
onThreadResolved: (path, displayName) => {
|
|
85
|
+
const normalizedPath = normalizeSelectedThreadPath(path);
|
|
81
86
|
onSelectedThreadResolved?.(normalizedPath, displayName);
|
|
82
87
|
},
|
|
83
88
|
emptyStateTitle,
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { ReactElement } from "react";
|
|
2
|
+
import { RoomClient } from "@meshagent/meshagent";
|
|
3
|
+
export type NewChatThreadBuilder = (threadPath: string) => ReactElement;
|
|
4
|
+
export interface NewChatThreadProps {
|
|
5
|
+
room: RoomClient;
|
|
6
|
+
agentName: string;
|
|
7
|
+
builder: NewChatThreadBuilder;
|
|
8
|
+
toolkit?: string;
|
|
9
|
+
tool?: string;
|
|
10
|
+
selectedThreadPath?: string | null;
|
|
11
|
+
onThreadPathChanged?: (path: string | null) => void;
|
|
12
|
+
onThreadResolved?: (path: string | null, displayName: string | null) => void;
|
|
13
|
+
centerComposer?: boolean;
|
|
14
|
+
emptyStateTitle?: string;
|
|
15
|
+
emptyStateDescription?: string;
|
|
16
|
+
}
|
|
17
|
+
export declare function NewChatThread({ room, agentName, builder, toolkit, tool, selectedThreadPath, onThreadPathChanged, onThreadResolved, centerComposer, emptyStateTitle, emptyStateDescription, }: NewChatThreadProps): ReactElement;
|
|
@@ -16,22 +16,17 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
return to;
|
|
17
17
|
};
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var
|
|
20
|
-
__export(
|
|
21
|
-
|
|
19
|
+
var new_chat_thread_exports = {};
|
|
20
|
+
__export(new_chat_thread_exports, {
|
|
21
|
+
NewChatThread: () => NewChatThread
|
|
22
22
|
});
|
|
23
|
-
module.exports = __toCommonJS(
|
|
23
|
+
module.exports = __toCommonJS(new_chat_thread_exports);
|
|
24
24
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
25
25
|
var import_react = require("react");
|
|
26
26
|
var import_meshagent = require("@meshagent/meshagent");
|
|
27
|
-
var
|
|
28
|
-
var import_lucide_react = require("lucide-react");
|
|
29
|
-
var import_ChatInput = require("./ChatInput");
|
|
30
|
-
var import_ChatThread = require("./ChatThread");
|
|
31
|
-
var import_button = require("./components/ui/button");
|
|
32
|
-
var import_sonner = require("./components/ui/sonner");
|
|
27
|
+
var import_chat_input = require("./chat-input");
|
|
33
28
|
var import_file_attachment = require("./file-attachment");
|
|
34
|
-
var
|
|
29
|
+
var import_sonner = require("../components/ui/sonner");
|
|
35
30
|
class NewThreadCancelledError extends Error {
|
|
36
31
|
constructor() {
|
|
37
32
|
super("new thread creation cancelled");
|
|
@@ -119,10 +114,7 @@ function parseThreadToolResult(toolkit, tool, content) {
|
|
|
119
114
|
if (!path) {
|
|
120
115
|
throw new Error(`${toolkit}.${tool} response missing path`);
|
|
121
116
|
}
|
|
122
|
-
return
|
|
123
|
-
path,
|
|
124
|
-
displayName: getStringField(content.json, "name")
|
|
125
|
-
};
|
|
117
|
+
return [path, getStringField(content.json, "name")];
|
|
126
118
|
}
|
|
127
119
|
function describeError(error) {
|
|
128
120
|
if (error instanceof Error && error.message.trim() !== "") {
|
|
@@ -134,115 +126,26 @@ function EmptyState({
|
|
|
134
126
|
title,
|
|
135
127
|
description
|
|
136
128
|
}) {
|
|
137
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "h-full flex flex-col items-center justify-center px-6 py-20 text-center", children: [
|
|
138
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("h2", { className: "text-4xl font-
|
|
129
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "h-full mx-auto flex max-w-2xl flex-col items-center justify-center px-6 py-20 text-center", children: [
|
|
130
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("h2", { className: "text-4xl font-semibold tracking-tight text-foreground sm:text-5xl", children: title }),
|
|
139
131
|
description?.trim() ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "mt-3 max-w-xl text-sm leading-6 text-muted-foreground sm:text-base", children: description }) : null
|
|
140
132
|
] });
|
|
141
133
|
}
|
|
142
134
|
function ErrorBanner({ message }) {
|
|
143
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "mx-auto w-full max-w-[912px] whitespace-pre-wrap rounded-
|
|
135
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "mx-auto w-full max-w-[912px] whitespace-pre-wrap rounded-md border border-destructive/30 bg-destructive/5 px-6 py-5 text-sm text-destructive", children: message });
|
|
144
136
|
}
|
|
145
|
-
function
|
|
137
|
+
function NewChatThread({
|
|
146
138
|
room,
|
|
147
|
-
path,
|
|
148
|
-
participants,
|
|
149
|
-
agentName,
|
|
150
|
-
emptyStateTitle,
|
|
151
|
-
emptyStateDescription,
|
|
152
|
-
showNewThreadButton = false,
|
|
153
|
-
onStartNewThread
|
|
154
|
-
}) {
|
|
155
|
-
const threadStatus = (0, import_chat_hooks.useThreadStatus)({ room, path, agentName });
|
|
156
|
-
const useAgentMessages = threadStatus.supportsAgentMessages;
|
|
157
|
-
const messageType = useAgentMessages && threadStatus.mode === "steerable" && threadStatus.turnId ? "steer" : "chat";
|
|
158
|
-
const {
|
|
159
|
-
document,
|
|
160
|
-
messages,
|
|
161
|
-
sendMessage,
|
|
162
|
-
selectAttachments,
|
|
163
|
-
attachments,
|
|
164
|
-
setAttachments,
|
|
165
|
-
onlineParticipants,
|
|
166
|
-
localParticipantName,
|
|
167
|
-
cancelRequest
|
|
168
|
-
} = (0, import_chat_hooks.useChatThread)({
|
|
169
|
-
room,
|
|
170
|
-
path,
|
|
171
|
-
participants,
|
|
172
|
-
agentName,
|
|
173
|
-
useAgentMessages,
|
|
174
|
-
messageType,
|
|
175
|
-
turnId: threadStatus.turnId
|
|
176
|
-
});
|
|
177
|
-
const { typing, thinking } = (0, import_meshagent_react.useRoomIndicators)({ room, path });
|
|
178
|
-
const [showCompletedToolCalls, setShowCompletedToolCalls] = (0, import_react.useState)(false);
|
|
179
|
-
const onTextChange = (0, import_react.useCallback)(() => {
|
|
180
|
-
for (const participant of onlineParticipants) {
|
|
181
|
-
room.messaging.sendMessage({
|
|
182
|
-
to: participant,
|
|
183
|
-
type: "typing",
|
|
184
|
-
message: { path }
|
|
185
|
-
});
|
|
186
|
-
}
|
|
187
|
-
}, [onlineParticipants, path, room]);
|
|
188
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex min-h-0 flex-1 flex-col", children: [
|
|
189
|
-
showNewThreadButton && onStartNewThread ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "px-4 pt-3", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "mx-auto flex w-full max-w-[912px] justify-end", children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
190
|
-
import_button.Button,
|
|
191
|
-
{
|
|
192
|
-
type: "button",
|
|
193
|
-
variant: "outline",
|
|
194
|
-
size: "sm",
|
|
195
|
-
className: "rounded-full shadow-xs",
|
|
196
|
-
onClick: onStartNewThread,
|
|
197
|
-
children: [
|
|
198
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_lucide_react.Plus, { className: "mr-2 h-4 w-4" }),
|
|
199
|
-
"New thread"
|
|
200
|
-
]
|
|
201
|
-
}
|
|
202
|
-
) }) }) : null,
|
|
203
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
204
|
-
import_ChatThread.ChatThread,
|
|
205
|
-
{
|
|
206
|
-
room,
|
|
207
|
-
path,
|
|
208
|
-
messages,
|
|
209
|
-
isLoading: document === null,
|
|
210
|
-
localParticipantName,
|
|
211
|
-
showCompletedToolCalls,
|
|
212
|
-
onShowCompletedToolCallsChanged: setShowCompletedToolCalls,
|
|
213
|
-
typing,
|
|
214
|
-
thinking,
|
|
215
|
-
threadStatusText: threadStatus.text,
|
|
216
|
-
threadStatusStartedAt: threadStatus.startedAt,
|
|
217
|
-
threadStatusMode: threadStatus.mode,
|
|
218
|
-
onCancelRequest: cancelRequest,
|
|
219
|
-
emptyStateTitle,
|
|
220
|
-
emptyStateDescription
|
|
221
|
-
}
|
|
222
|
-
),
|
|
223
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
224
|
-
import_ChatInput.ChatInput,
|
|
225
|
-
{
|
|
226
|
-
onSubmit: sendMessage,
|
|
227
|
-
attachments,
|
|
228
|
-
onFilesSelected: selectAttachments,
|
|
229
|
-
setAttachments,
|
|
230
|
-
onTextChange
|
|
231
|
-
}
|
|
232
|
-
)
|
|
233
|
-
] });
|
|
234
|
-
}
|
|
235
|
-
function Chat({
|
|
236
|
-
room,
|
|
237
|
-
path,
|
|
238
|
-
participants,
|
|
239
139
|
agentName,
|
|
140
|
+
builder,
|
|
240
141
|
toolkit = "chat",
|
|
241
142
|
tool = "new_thread",
|
|
143
|
+
selectedThreadPath,
|
|
144
|
+
onThreadPathChanged,
|
|
145
|
+
onThreadResolved,
|
|
242
146
|
centerComposer = true,
|
|
243
147
|
emptyStateTitle,
|
|
244
|
-
emptyStateDescription
|
|
245
|
-
onThreadResolved
|
|
148
|
+
emptyStateDescription
|
|
246
149
|
}) {
|
|
247
150
|
const [internalThreadPath, setInternalThreadPath] = (0, import_react.useState)(null);
|
|
248
151
|
const [newThreadDraft, setNewThreadDraft] = (0, import_react.useState)("");
|
|
@@ -251,20 +154,23 @@ function Chat({
|
|
|
251
154
|
const [creatingNewThread, setCreatingNewThread] = (0, import_react.useState)(false);
|
|
252
155
|
const [waitingForAgent, setWaitingForAgent] = (0, import_react.useState)(false);
|
|
253
156
|
const activeOperationRef = (0, import_react.useRef)(0);
|
|
254
|
-
const
|
|
255
|
-
const
|
|
256
|
-
const activePath = controlledPath ?? internalThreadPath;
|
|
157
|
+
const controlledThreadPath = selectedThreadPath !== void 0 ? normalizeThreadPath(selectedThreadPath) : void 0;
|
|
158
|
+
const activePath = controlledThreadPath ?? internalThreadPath;
|
|
257
159
|
(0, import_react.useEffect)(() => {
|
|
258
160
|
return () => {
|
|
259
161
|
activeOperationRef.current += 1;
|
|
260
162
|
};
|
|
261
163
|
}, []);
|
|
262
164
|
(0, import_react.useEffect)(() => {
|
|
263
|
-
if (
|
|
264
|
-
|
|
165
|
+
if (controlledThreadPath === void 0) {
|
|
166
|
+
return;
|
|
265
167
|
}
|
|
266
|
-
|
|
168
|
+
setInternalThreadPath(controlledThreadPath);
|
|
169
|
+
}, [controlledThreadPath]);
|
|
267
170
|
(0, import_react.useEffect)(() => {
|
|
171
|
+
if (controlledThreadPath !== void 0) {
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
268
174
|
activeOperationRef.current += 1;
|
|
269
175
|
setInternalThreadPath(null);
|
|
270
176
|
setNewThreadDraft("");
|
|
@@ -272,7 +178,7 @@ function Chat({
|
|
|
272
178
|
setNewThreadError(null);
|
|
273
179
|
setCreatingNewThread(false);
|
|
274
180
|
setWaitingForAgent(false);
|
|
275
|
-
}, [agentName,
|
|
181
|
+
}, [agentName, controlledThreadPath, room]);
|
|
276
182
|
const selectNewThreadAttachments = (0, import_react.useCallback)((files) => {
|
|
277
183
|
const nextAttachments = files.map((file) => new import_file_attachment.MeshagentFileUpload(
|
|
278
184
|
room,
|
|
@@ -288,15 +194,6 @@ function Chat({
|
|
|
288
194
|
setWaitingForAgent(false);
|
|
289
195
|
setNewThreadError(null);
|
|
290
196
|
}, []);
|
|
291
|
-
const openNewThreadComposer = (0, import_react.useCallback)(() => {
|
|
292
|
-
activeOperationRef.current += 1;
|
|
293
|
-
setInternalThreadPath(null);
|
|
294
|
-
setNewThreadDraft("");
|
|
295
|
-
setNewThreadAttachments([]);
|
|
296
|
-
setNewThreadError(null);
|
|
297
|
-
setCreatingNewThread(false);
|
|
298
|
-
setWaitingForAgent(false);
|
|
299
|
-
}, []);
|
|
300
197
|
const handleCreateThread = (0, import_react.useCallback)(async () => {
|
|
301
198
|
const text = newThreadDraft.trim();
|
|
302
199
|
const hasDraft = text !== "" || newThreadAttachments.length > 0;
|
|
@@ -329,7 +226,8 @@ function Chat({
|
|
|
329
226
|
activeOperationRef
|
|
330
227
|
});
|
|
331
228
|
ensureOperationActive(operationId, activeOperationRef);
|
|
332
|
-
const response = await room.
|
|
229
|
+
const response = await room.invoke({
|
|
230
|
+
participantId: targetAgent.id,
|
|
333
231
|
toolkit,
|
|
334
232
|
tool,
|
|
335
233
|
arguments: {
|
|
@@ -343,16 +241,18 @@ function Chat({
|
|
|
343
241
|
if (!(response instanceof import_meshagent.JsonContent)) {
|
|
344
242
|
throw new Error(`${toolkit}.${tool} returned non-JSON content`);
|
|
345
243
|
}
|
|
346
|
-
const
|
|
347
|
-
|
|
348
|
-
|
|
244
|
+
const [threadPath, displayName] = parseThreadToolResult(toolkit, tool, response);
|
|
245
|
+
const normalizedPath = normalizeThreadPath(threadPath);
|
|
246
|
+
if (controlledThreadPath === void 0) {
|
|
247
|
+
setInternalThreadPath(normalizedPath);
|
|
349
248
|
}
|
|
350
249
|
setNewThreadDraft("");
|
|
351
250
|
setNewThreadAttachments([]);
|
|
352
251
|
setNewThreadError(null);
|
|
353
252
|
setCreatingNewThread(false);
|
|
354
253
|
setWaitingForAgent(false);
|
|
355
|
-
|
|
254
|
+
onThreadPathChanged?.(normalizedPath);
|
|
255
|
+
onThreadResolved?.(normalizedPath, displayName);
|
|
356
256
|
} catch (error) {
|
|
357
257
|
if (error instanceof NewThreadCancelledError) {
|
|
358
258
|
return;
|
|
@@ -363,34 +263,19 @@ function Chat({
|
|
|
363
263
|
}
|
|
364
264
|
}, [
|
|
365
265
|
agentName,
|
|
366
|
-
|
|
266
|
+
controlledThreadPath,
|
|
367
267
|
creatingNewThread,
|
|
368
268
|
newThreadAttachments,
|
|
369
269
|
newThreadDraft,
|
|
270
|
+
onThreadPathChanged,
|
|
370
271
|
onThreadResolved,
|
|
371
272
|
room,
|
|
372
273
|
toolkit,
|
|
373
274
|
tool,
|
|
374
275
|
waitingForAgent
|
|
375
276
|
]);
|
|
376
|
-
(0, import_react.useEffect)(() => {
|
|
377
|
-
if (!managesOwnThread) {
|
|
378
|
-
return;
|
|
379
|
-
}
|
|
380
|
-
const handleKeyDown = (event) => {
|
|
381
|
-
if (!(event.ctrlKey || event.metaKey) || event.key.toLowerCase() !== "n") {
|
|
382
|
-
return;
|
|
383
|
-
}
|
|
384
|
-
event.preventDefault();
|
|
385
|
-
openNewThreadComposer();
|
|
386
|
-
};
|
|
387
|
-
window.addEventListener("keydown", handleKeyDown);
|
|
388
|
-
return () => {
|
|
389
|
-
window.removeEventListener("keydown", handleKeyDown);
|
|
390
|
-
};
|
|
391
|
-
}, [managesOwnThread, openNewThreadComposer]);
|
|
392
277
|
const targetAgentLabel = (0, import_react.useMemo)(() => {
|
|
393
|
-
const knownAgentName = agentName
|
|
278
|
+
const knownAgentName = agentName.trim();
|
|
394
279
|
if (knownAgentName) {
|
|
395
280
|
return displayParticipantName(knownAgentName);
|
|
396
281
|
}
|
|
@@ -398,8 +283,11 @@ function Chat({
|
|
|
398
283
|
return displayParticipantName(targetAgent ? getParticipantName(targetAgent) : null);
|
|
399
284
|
}, [agentName, room]);
|
|
400
285
|
const pendingStatusText = waitingForAgent ? `Waiting for ${targetAgentLabel} to be ready.` : creatingNewThread ? `Starting a thread with ${targetAgentLabel}.` : null;
|
|
286
|
+
if (activePath !== null) {
|
|
287
|
+
return builder(activePath);
|
|
288
|
+
}
|
|
401
289
|
const composer = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
402
|
-
|
|
290
|
+
import_chat_input.ChatInput,
|
|
403
291
|
{
|
|
404
292
|
onSubmit: handleCreateThread,
|
|
405
293
|
attachments: newThreadAttachments,
|
|
@@ -411,24 +299,11 @@ function Chat({
|
|
|
411
299
|
showCancelButton: creatingNewThread || waitingForAgent,
|
|
412
300
|
onCancelRequest: cancelPendingNewThread,
|
|
413
301
|
disabled: creatingNewThread || waitingForAgent,
|
|
414
|
-
placeholder: agentName
|
|
302
|
+
placeholder: agentName.trim() ? `Type a message or @${displayParticipantName(agentName)}` : "Type a message"
|
|
415
303
|
}
|
|
416
304
|
);
|
|
417
305
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "h-full flex flex-1 flex-col", children: [
|
|
418
|
-
|
|
419
|
-
ResolvedChatView,
|
|
420
|
-
{
|
|
421
|
-
room,
|
|
422
|
-
path: activePath,
|
|
423
|
-
participants,
|
|
424
|
-
agentName,
|
|
425
|
-
emptyStateTitle,
|
|
426
|
-
emptyStateDescription,
|
|
427
|
-
showNewThreadButton: managesOwnThread,
|
|
428
|
-
onStartNewThread: openNewThreadComposer
|
|
429
|
-
},
|
|
430
|
-
activePath
|
|
431
|
-
) : 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: [
|
|
306
|
+
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: [
|
|
432
307
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "space-y-2 text-center", children: [
|
|
433
308
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("h2", { className: "text-4xl font-semibold tracking-tight text-foreground sm:text-5xl", children: "Start a new thread" }),
|
|
434
309
|
pendingStatusText ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "text-sm text-muted-foreground sm:text-base", children: pendingStatusText }) : null
|
|
@@ -26,17 +26,17 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
26
26
|
mod
|
|
27
27
|
));
|
|
28
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
var
|
|
30
|
-
__export(
|
|
29
|
+
var upload_pill_exports = {};
|
|
30
|
+
__export(upload_pill_exports, {
|
|
31
31
|
UploadPill: () => UploadPill
|
|
32
32
|
});
|
|
33
|
-
module.exports = __toCommonJS(
|
|
33
|
+
module.exports = __toCommonJS(upload_pill_exports);
|
|
34
34
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
35
35
|
var React = __toESM(require("react"));
|
|
36
36
|
var import_lucide_react = require("lucide-react");
|
|
37
|
-
var import_progress = require("
|
|
37
|
+
var import_progress = require("../components/ui/progress");
|
|
38
38
|
var import_file_attachment = require("./file-attachment");
|
|
39
|
-
var import_utils = require("
|
|
39
|
+
var import_utils = require("../lib/utils");
|
|
40
40
|
function measureUploadProgress(attachment) {
|
|
41
41
|
if (attachment.size <= 0) {
|
|
42
42
|
return attachment.status === import_file_attachment.UploadStatus.Completed ? 100 : 0;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { ReactElement, ReactNode } from "react";
|
|
2
|
+
import { RoomClient } from "@meshagent/meshagent";
|
|
3
|
+
export declare enum FileKind {
|
|
4
|
+
Image = "image",
|
|
5
|
+
Video = "video",
|
|
6
|
+
Pdf = "pdf",
|
|
7
|
+
Unknown = "unknown"
|
|
8
|
+
}
|
|
9
|
+
export declare function filePreviewName(path: string): string;
|
|
10
|
+
export declare function classifyFile(path: string): FileKind;
|
|
11
|
+
export declare function isImagePath(path: string): boolean;
|
|
12
|
+
export declare function ImagePreview({ room, path, alt, }: {
|
|
13
|
+
room: RoomClient;
|
|
14
|
+
path: string;
|
|
15
|
+
alt?: string;
|
|
16
|
+
}): ReactElement;
|
|
17
|
+
export declare function VideoPreview({ room, path }: {
|
|
18
|
+
room: RoomClient;
|
|
19
|
+
path: string;
|
|
20
|
+
}): ReactElement;
|
|
21
|
+
export declare function PdfPreview({ room, path }: {
|
|
22
|
+
room: RoomClient;
|
|
23
|
+
path: string;
|
|
24
|
+
}): ReactElement;
|
|
25
|
+
export declare function FilePreview({ room, path }: {
|
|
26
|
+
room: RoomClient;
|
|
27
|
+
path: string;
|
|
28
|
+
}): ReactElement;
|
|
29
|
+
export declare function FilePreviewDialog({ room, path, children, className, }: {
|
|
30
|
+
room: RoomClient;
|
|
31
|
+
path: string;
|
|
32
|
+
children: ReactNode;
|
|
33
|
+
className?: string;
|
|
34
|
+
}): ReactElement;
|