@meshagent/meshagent-tailwind 0.47.1 → 0.48.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 +10 -0
- package/dist/cjs/chat/agent-thread.d.ts +24 -24
- package/dist/cjs/chat/agent-thread.js +575 -808
- package/dist/cjs/chat/chat-bot-view.d.ts +18 -6
- package/dist/cjs/chat/chat-bot-view.js +29 -7
- package/dist/cjs/chat/chat-feed-widget-view.d.ts +7 -0
- package/dist/cjs/chat/chat-feed-widget-view.js +50 -0
- package/dist/cjs/chat/chat-feed-widget.d.ts +16 -0
- package/dist/cjs/chat/chat-feed-widget.js +51 -0
- package/dist/cjs/chat/chat-hooks.d.ts +2 -2
- package/dist/cjs/chat/chat-input.d.ts +3 -3
- package/dist/cjs/chat/chat-input.js +9 -4
- package/dist/cjs/chat/chat-scroller.d.ts +21 -0
- package/dist/cjs/chat/chat-scroller.js +139 -0
- package/dist/cjs/chat/chat-thread-timeline.d.ts +66 -0
- package/dist/cjs/chat/chat-thread-timeline.js +595 -0
- package/dist/cjs/chat/dataset-agent-thread.d.ts +16 -4
- package/dist/cjs/chat/dataset-agent-thread.js +112 -292
- package/dist/cjs/chat/multi-thread-view.d.ts +8 -3
- package/dist/cjs/chat/multi-thread-view.js +10 -2
- package/dist/cjs/chat/new-chat-thread.d.ts +8 -3
- package/dist/cjs/chat/new-chat-thread.js +63 -24
- package/dist/cjs/chat/thread-view.d.ts +18 -5
- package/dist/cjs/chat/thread-view.js +67 -9
- package/dist/cjs/chat/use-chat-virtualizer.d.ts +47 -0
- package/dist/cjs/chat/use-chat-virtualizer.js +336 -0
- package/dist/cjs/chat/virtualization.d.ts +44 -0
- package/dist/cjs/chat/virtualization.js +143 -0
- package/dist/cjs/components/ui/button.d.ts +2 -2
- package/dist/cjs/components/ui/dialog.d.ts +1 -1
- package/dist/cjs/components/ui/dialog.js +11 -1
- package/dist/cjs/components/ui/portal-container.d.ts +7 -0
- package/dist/cjs/components/ui/portal-container.js +46 -0
- package/dist/cjs/file-preview/file-preview.js +1 -1
- package/dist/cjs/index.d.ts +3 -0
- package/dist/cjs/index.js +4 -0
- package/dist/cjs/meetings/meeting-scope.d.ts +2 -1
- package/dist/cjs/meetings/meeting-scope.js +1 -0
- package/dist/cjs/react-syntax-highlighter.d.js +1 -0
- package/dist/esm/chat/agent-thread.d.ts +24 -24
- package/dist/esm/chat/agent-thread.js +574 -838
- package/dist/esm/chat/chat-bot-view.d.ts +18 -6
- package/dist/esm/chat/chat-bot-view.js +29 -7
- package/dist/esm/chat/chat-feed-widget-view.d.ts +7 -0
- package/dist/esm/chat/chat-feed-widget-view.js +30 -0
- package/dist/esm/chat/chat-feed-widget.d.ts +16 -0
- package/dist/esm/chat/chat-feed-widget.js +31 -0
- package/dist/esm/chat/chat-hooks.d.ts +2 -2
- package/dist/esm/chat/chat-input.d.ts +3 -3
- package/dist/esm/chat/chat-input.js +9 -4
- package/dist/esm/chat/chat-scroller.d.ts +21 -0
- package/dist/esm/chat/chat-scroller.js +122 -0
- package/dist/esm/chat/chat-thread-timeline.d.ts +66 -0
- package/dist/esm/chat/chat-thread-timeline.js +605 -0
- package/dist/esm/chat/dataset-agent-thread.d.ts +16 -4
- package/dist/esm/chat/dataset-agent-thread.js +114 -307
- package/dist/esm/chat/multi-thread-view.d.ts +8 -3
- package/dist/esm/chat/multi-thread-view.js +10 -2
- package/dist/esm/chat/new-chat-thread.d.ts +8 -3
- package/dist/esm/chat/new-chat-thread.js +64 -25
- package/dist/esm/chat/thread-view.d.ts +18 -5
- package/dist/esm/chat/thread-view.js +67 -9
- package/dist/esm/chat/use-chat-virtualizer.d.ts +47 -0
- package/dist/esm/chat/use-chat-virtualizer.js +331 -0
- package/dist/esm/chat/virtualization.d.ts +44 -0
- package/dist/esm/chat/virtualization.js +123 -0
- package/dist/esm/components/ui/button.d.ts +2 -2
- package/dist/esm/components/ui/dialog.d.ts +1 -1
- package/dist/esm/components/ui/dialog.js +11 -1
- package/dist/esm/components/ui/portal-container.d.ts +7 -0
- package/dist/esm/components/ui/portal-container.js +16 -0
- package/dist/esm/file-preview/file-preview.js +1 -1
- package/dist/esm/index.d.ts +3 -0
- package/dist/esm/index.js +4 -0
- package/dist/esm/meetings/meeting-scope.d.ts +2 -1
- package/dist/esm/meetings/meeting-scope.js +1 -0
- package/dist/esm/react-syntax-highlighter.d.js +0 -0
- package/dist/index.css +1 -1
- package/package.json +6 -5
|
@@ -2,82 +2,10 @@ import { jsx, jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { useEffect, useMemo, useState } from "react";
|
|
3
3
|
import {
|
|
4
4
|
AgentMessage,
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
AgentTextContentStarted,
|
|
8
|
-
AgentReasoningContentDelta,
|
|
9
|
-
AgentReasoningContentEnded,
|
|
10
|
-
AgentReasoningContentStarted,
|
|
11
|
-
AgentToolCallEnded,
|
|
12
|
-
AgentToolCallPending,
|
|
13
|
-
AgentToolCallStarted,
|
|
14
|
-
BaseChatClient,
|
|
15
|
-
MessagingChatClient,
|
|
16
|
-
ThreadLoaded,
|
|
17
|
-
agentThreadOpenType,
|
|
18
|
-
agentThreadCloseType,
|
|
19
|
-
TurnStart
|
|
5
|
+
AgentMessageEvent,
|
|
6
|
+
MessagingChatClient
|
|
20
7
|
} from "@meshagent/meshagent-agents";
|
|
21
8
|
import { AgentThread } from "./agent-thread.js";
|
|
22
|
-
class DatasetReplayChatClient extends BaseChatClient {
|
|
23
|
-
upstream;
|
|
24
|
-
shouldStopUpstream;
|
|
25
|
-
eventPump;
|
|
26
|
-
stopped = false;
|
|
27
|
-
constructor({ upstream, shouldStopUpstream }) {
|
|
28
|
-
super();
|
|
29
|
-
this.upstream = upstream;
|
|
30
|
-
this.shouldStopUpstream = shouldStopUpstream;
|
|
31
|
-
}
|
|
32
|
-
agentParticipant() {
|
|
33
|
-
return this.upstream.agentParticipant();
|
|
34
|
-
}
|
|
35
|
-
localParticipantName() {
|
|
36
|
-
return this.upstream.localParticipantName();
|
|
37
|
-
}
|
|
38
|
-
async start() {
|
|
39
|
-
this.stopped = false;
|
|
40
|
-
await this.upstream.start();
|
|
41
|
-
if (this.eventPump == null) {
|
|
42
|
-
this.eventPump = this.pumpUpstreamEvents();
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
async stop() {
|
|
46
|
-
this.stopped = true;
|
|
47
|
-
if (this.shouldStopUpstream) {
|
|
48
|
-
await this.upstream.stop();
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
async sendAgentMessage(message, options) {
|
|
52
|
-
if (message.type === agentThreadOpenType || message.type === agentThreadCloseType) {
|
|
53
|
-
return;
|
|
54
|
-
}
|
|
55
|
-
await this.upstream.sendAgentMessage(message, options);
|
|
56
|
-
}
|
|
57
|
-
replayMessages(messages) {
|
|
58
|
-
for (const message of messages) {
|
|
59
|
-
this.handleAgentMessage(message, { createdAt: dateFromString(message.createdAt) ?? void 0 });
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
markThreadLoaded(path) {
|
|
63
|
-
this.handleAgentMessage(new ThreadLoaded({ threadId: path }));
|
|
64
|
-
}
|
|
65
|
-
async pumpUpstreamEvents() {
|
|
66
|
-
try {
|
|
67
|
-
for await (const event of this.upstream.events) {
|
|
68
|
-
if (this.stopped) {
|
|
69
|
-
return;
|
|
70
|
-
}
|
|
71
|
-
this.handleAgentMessage(event.message, {
|
|
72
|
-
createdAt: event.createdAt,
|
|
73
|
-
attachment: event.attachment
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
} finally {
|
|
77
|
-
this.eventPump = void 0;
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
9
|
function DatasetAgentThread({
|
|
82
10
|
room,
|
|
83
11
|
path,
|
|
@@ -88,75 +16,69 @@ function DatasetAgentThread({
|
|
|
88
16
|
emptyStateTitle,
|
|
89
17
|
emptyStateDescription,
|
|
90
18
|
clientToolkits,
|
|
19
|
+
chatFeedWidgets,
|
|
91
20
|
toolChoice,
|
|
92
21
|
collapseMessages,
|
|
93
|
-
|
|
22
|
+
suggestions,
|
|
23
|
+
enableFileUpload = false,
|
|
24
|
+
retryMissingTableMs = 500,
|
|
25
|
+
loadThread = true,
|
|
26
|
+
injectPersistedEvents = false,
|
|
27
|
+
composerDisabled = false,
|
|
28
|
+
closeThreadOnUnmount = false,
|
|
29
|
+
onPersistedEventsInjectionStarted,
|
|
30
|
+
onPersistedEventsInjected,
|
|
31
|
+
onEventsChanged
|
|
94
32
|
}) {
|
|
95
|
-
const [loadError, setLoadError] = useState(null);
|
|
96
33
|
const normalizedPath = path.trim();
|
|
97
34
|
const activeRowsLoader = useMemo(() => rowsLoader ?? defaultRowsLoader(room), [room, rowsLoader]);
|
|
98
|
-
const
|
|
35
|
+
const activeChatClient = useMemo(
|
|
99
36
|
() => chatClient ?? new MessagingChatClient({ room, agentName }),
|
|
100
37
|
[agentName, chatClient, room]
|
|
101
38
|
);
|
|
102
|
-
const
|
|
103
|
-
|
|
104
|
-
upstream: upstreamChatClient,
|
|
105
|
-
shouldStopUpstream: chatClient == null || disposeChatClient
|
|
106
|
-
}),
|
|
107
|
-
[chatClient, disposeChatClient, upstreamChatClient]
|
|
108
|
-
);
|
|
39
|
+
const [persistedEvents, setPersistedEvents] = useState(null);
|
|
40
|
+
const [loadError, setLoadError] = useState(null);
|
|
109
41
|
useEffect(() => {
|
|
110
42
|
let cancelled = false;
|
|
111
43
|
let retryTimer;
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
replayChatClient.markThreadLoaded(normalizedPath);
|
|
116
|
-
return;
|
|
117
|
-
}
|
|
44
|
+
setPersistedEvents(null);
|
|
45
|
+
setLoadError(null);
|
|
46
|
+
const load = async () => {
|
|
118
47
|
let ref;
|
|
119
48
|
try {
|
|
120
49
|
ref = parseDatasetThreadRef(normalizedPath);
|
|
121
50
|
} catch (error) {
|
|
122
|
-
|
|
123
|
-
|
|
51
|
+
if (!cancelled) {
|
|
52
|
+
setPersistedEvents([]);
|
|
53
|
+
setLoadError(describeError(error));
|
|
54
|
+
}
|
|
124
55
|
return;
|
|
125
56
|
}
|
|
126
57
|
try {
|
|
127
|
-
|
|
128
|
-
const messages = await loadDatasetThreadMessages(activeRowsLoader, {
|
|
58
|
+
const events = await loadDatasetThreadEvents(activeRowsLoader, {
|
|
129
59
|
path: normalizedPath,
|
|
130
60
|
namespace: ref.namespace,
|
|
131
61
|
table: ref.table
|
|
132
62
|
});
|
|
133
|
-
if (cancelled)
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
replayChatClient.replayMessages(messages);
|
|
137
|
-
replayChatClient.markThreadLoaded(normalizedPath);
|
|
63
|
+
if (cancelled) return;
|
|
64
|
+
setPersistedEvents(events);
|
|
65
|
+
setLoadError(null);
|
|
138
66
|
} catch (error) {
|
|
139
|
-
if (cancelled)
|
|
140
|
-
return;
|
|
141
|
-
}
|
|
67
|
+
if (cancelled) return;
|
|
142
68
|
if (isDatasetTableNotFoundError(error)) {
|
|
143
|
-
retryTimer = setTimeout(() =>
|
|
144
|
-
void loadRows();
|
|
145
|
-
}, retryMissingTableMs);
|
|
69
|
+
retryTimer = setTimeout(() => void load(), retryMissingTableMs);
|
|
146
70
|
return;
|
|
147
71
|
}
|
|
72
|
+
setPersistedEvents([]);
|
|
148
73
|
setLoadError(describeError(error));
|
|
149
|
-
replayChatClient.markThreadLoaded(normalizedPath);
|
|
150
74
|
}
|
|
151
75
|
};
|
|
152
|
-
void
|
|
76
|
+
void load();
|
|
153
77
|
return () => {
|
|
154
78
|
cancelled = true;
|
|
155
|
-
if (retryTimer !== void 0)
|
|
156
|
-
clearTimeout(retryTimer);
|
|
157
|
-
}
|
|
79
|
+
if (retryTimer !== void 0) clearTimeout(retryTimer);
|
|
158
80
|
};
|
|
159
|
-
}, [activeRowsLoader, normalizedPath,
|
|
81
|
+
}, [activeRowsLoader, normalizedPath, retryMissingTableMs]);
|
|
160
82
|
return /* @__PURE__ */ jsxs("div", { className: "flex h-full min-h-0 flex-1 flex-col", children: [
|
|
161
83
|
loadError === null ? null : /* @__PURE__ */ jsx("div", { className: "px-4 pt-3", children: /* @__PURE__ */ jsx("div", { className: "mx-auto w-full max-w-[912px] whitespace-pre-wrap rounded-md border border-destructive/30 bg-destructive/5 px-4 py-3 text-sm text-destructive", children: loadError }) }),
|
|
162
84
|
/* @__PURE__ */ jsx(
|
|
@@ -164,14 +86,26 @@ function DatasetAgentThread({
|
|
|
164
86
|
{
|
|
165
87
|
room,
|
|
166
88
|
path: normalizedPath,
|
|
167
|
-
chatClient:
|
|
168
|
-
disposeChatClient:
|
|
89
|
+
chatClient: activeChatClient,
|
|
90
|
+
disposeChatClient: chatClient == null || disposeChatClient,
|
|
169
91
|
agentName,
|
|
170
92
|
emptyStateTitle,
|
|
171
93
|
emptyStateDescription,
|
|
172
94
|
clientToolkits,
|
|
95
|
+
chatFeedWidgets,
|
|
173
96
|
toolChoice,
|
|
174
|
-
collapseMessages
|
|
97
|
+
collapseMessages,
|
|
98
|
+
suggestions,
|
|
99
|
+
enableFileUpload,
|
|
100
|
+
persistedEvents: persistedEvents ?? [],
|
|
101
|
+
deferLiveEvents: persistedEvents == null,
|
|
102
|
+
loadThread,
|
|
103
|
+
injectPersistedEvents,
|
|
104
|
+
composerDisabled,
|
|
105
|
+
closeThreadOnUnmount,
|
|
106
|
+
onPersistedEventsInjectionStarted,
|
|
107
|
+
onPersistedEventsInjected,
|
|
108
|
+
onEventsChanged
|
|
175
109
|
}
|
|
176
110
|
)
|
|
177
111
|
] });
|
|
@@ -185,202 +119,100 @@ function parseDatasetThreadRef(path) {
|
|
|
185
119
|
if (!normalized.startsWith(prefix)) {
|
|
186
120
|
throw new TypeError("dataset thread path must start with dataset://");
|
|
187
121
|
}
|
|
188
|
-
const
|
|
189
|
-
const parts = body.split("/").map((part) => part.trim()).filter((part) => part !== "");
|
|
122
|
+
const parts = normalized.slice(prefix.length).split("/").map((part) => part.trim()).filter((part) => part !== "");
|
|
190
123
|
const table = parts[parts.length - 1];
|
|
191
124
|
if (table == null || table === "") {
|
|
192
125
|
throw new TypeError("dataset thread path must include a table name");
|
|
193
126
|
}
|
|
194
|
-
return {
|
|
195
|
-
namespace: parts.slice(0, -1),
|
|
196
|
-
table
|
|
197
|
-
};
|
|
198
|
-
}
|
|
199
|
-
function defaultRowsLoader(room) {
|
|
200
|
-
return async function* loadRows({ namespace, table }) {
|
|
201
|
-
for await (const chunk of room.datasets.searchStream({ table, namespace })) {
|
|
202
|
-
yield rowsFromTable(chunk);
|
|
203
|
-
}
|
|
204
|
-
};
|
|
127
|
+
return { namespace: parts.slice(0, -1), table };
|
|
205
128
|
}
|
|
206
|
-
async function
|
|
129
|
+
async function loadDatasetThreadEvents(loader, args) {
|
|
207
130
|
const rows = [];
|
|
208
131
|
const loaded = await loader(args);
|
|
209
132
|
if (isAsyncIterable(loaded)) {
|
|
210
|
-
for await (const chunk of loaded)
|
|
211
|
-
rows.push(...chunk);
|
|
212
|
-
}
|
|
133
|
+
for await (const chunk of loaded) rows.push(...chunk);
|
|
213
134
|
} else {
|
|
214
135
|
rows.push(...loaded);
|
|
215
136
|
}
|
|
216
|
-
return rows.
|
|
137
|
+
return rows.sort(compareDatasetThreadRows).flatMap(eventFromDatasetRow);
|
|
217
138
|
}
|
|
218
|
-
function
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
139
|
+
function defaultRowsLoader(room) {
|
|
140
|
+
return async function* loadRows({ namespace, table }) {
|
|
141
|
+
for await (const chunk of room.datasets.searchStream({ table, namespace })) {
|
|
142
|
+
const tableLike = chunk;
|
|
143
|
+
if (typeof tableLike.toArray !== "function") {
|
|
144
|
+
yield [];
|
|
145
|
+
continue;
|
|
146
|
+
}
|
|
147
|
+
yield tableLike.toArray().map((row) => row != null && typeof row === "object" ? { ...row } : {});
|
|
148
|
+
}
|
|
149
|
+
};
|
|
224
150
|
}
|
|
225
|
-
function
|
|
151
|
+
function eventFromDatasetRow(row) {
|
|
226
152
|
const data = rowData(row);
|
|
227
|
-
if (data
|
|
153
|
+
if (data == null) return [];
|
|
154
|
+
try {
|
|
155
|
+
return [new AgentMessageEvent({
|
|
156
|
+
message: AgentMessage.fromJson(data),
|
|
157
|
+
createdAt: rowCreatedAt(row, data) ?? void 0,
|
|
158
|
+
attachment: byteArray(row.attachment)
|
|
159
|
+
})];
|
|
160
|
+
} catch {
|
|
228
161
|
return [];
|
|
229
162
|
}
|
|
230
|
-
const agentMessage = agentMessageFromPayload(data);
|
|
231
|
-
if (agentMessage !== null) {
|
|
232
|
-
return [agentMessage];
|
|
233
|
-
}
|
|
234
|
-
const kind = stringValue(data.kind);
|
|
235
|
-
if (kind === "message" || kind === "file") {
|
|
236
|
-
const text = stringValue(data.text) ?? "";
|
|
237
|
-
const attachments = kind === "file" ? stringList(data.urls) : stringList(data.attachments);
|
|
238
|
-
if (text.trim() === "" && attachments.length === 0) {
|
|
239
|
-
return [];
|
|
240
|
-
}
|
|
241
|
-
const role = stringValue(data.role);
|
|
242
|
-
if (role === "user") {
|
|
243
|
-
return [new TurnStart({
|
|
244
|
-
threadId: path,
|
|
245
|
-
messageId: rowItemId(row),
|
|
246
|
-
senderName: stringValue(data.sender_name),
|
|
247
|
-
createdAt: rowCreatedAt(row).toISOString(),
|
|
248
|
-
content: [
|
|
249
|
-
...text.trim() === "" ? [] : [{ type: "text", text }],
|
|
250
|
-
...attachments.map((url) => ({ type: "file", url }))
|
|
251
|
-
]
|
|
252
|
-
})];
|
|
253
|
-
}
|
|
254
|
-
return [
|
|
255
|
-
new AgentTextContentStarted({
|
|
256
|
-
threadId: path,
|
|
257
|
-
itemId: rowItemId(row),
|
|
258
|
-
turnId: rowTurnId(row),
|
|
259
|
-
phase: stringValue(data.phase),
|
|
260
|
-
createdAt: rowCreatedAt(row).toISOString()
|
|
261
|
-
}),
|
|
262
|
-
...text.trim() === "" ? [] : [new AgentTextContentDelta({
|
|
263
|
-
threadId: path,
|
|
264
|
-
itemId: rowItemId(row),
|
|
265
|
-
turnId: rowTurnId(row),
|
|
266
|
-
phase: stringValue(data.phase),
|
|
267
|
-
text,
|
|
268
|
-
createdAt: rowCreatedAt(row).toISOString()
|
|
269
|
-
})],
|
|
270
|
-
new AgentTextContentEnded({
|
|
271
|
-
threadId: path,
|
|
272
|
-
itemId: rowItemId(row),
|
|
273
|
-
turnId: rowTurnId(row),
|
|
274
|
-
phase: stringValue(data.phase),
|
|
275
|
-
createdAt: rowCreatedAt(row).toISOString()
|
|
276
|
-
})
|
|
277
|
-
];
|
|
278
|
-
}
|
|
279
|
-
if (kind === "reasoning") {
|
|
280
|
-
const text = stringValue(data.text) ?? "";
|
|
281
|
-
if (text.trim() === "") {
|
|
282
|
-
return [];
|
|
283
|
-
}
|
|
284
|
-
return [
|
|
285
|
-
new AgentReasoningContentStarted({
|
|
286
|
-
threadId: path,
|
|
287
|
-
itemId: rowItemId(row),
|
|
288
|
-
turnId: rowTurnId(row),
|
|
289
|
-
createdAt: rowCreatedAt(row).toISOString()
|
|
290
|
-
}),
|
|
291
|
-
new AgentReasoningContentDelta({
|
|
292
|
-
threadId: path,
|
|
293
|
-
itemId: rowItemId(row),
|
|
294
|
-
turnId: rowTurnId(row),
|
|
295
|
-
text,
|
|
296
|
-
createdAt: rowCreatedAt(row).toISOString()
|
|
297
|
-
}),
|
|
298
|
-
new AgentReasoningContentEnded({
|
|
299
|
-
threadId: path,
|
|
300
|
-
itemId: rowItemId(row),
|
|
301
|
-
turnId: rowTurnId(row),
|
|
302
|
-
createdAt: rowCreatedAt(row).toISOString()
|
|
303
|
-
})
|
|
304
|
-
];
|
|
305
|
-
}
|
|
306
|
-
if (kind === "tool_call") {
|
|
307
|
-
const toolkit = stringValue(data.toolkit) ?? "";
|
|
308
|
-
const tool = stringValue(data.tool) ?? "tool";
|
|
309
|
-
const status = stringValue(data.status);
|
|
310
|
-
const message = toolCallIsFinished(status) ? new AgentToolCallEnded({
|
|
311
|
-
threadId: path,
|
|
312
|
-
itemId: rowItemId(row),
|
|
313
|
-
turnId: rowTurnId(row),
|
|
314
|
-
toolkit,
|
|
315
|
-
tool,
|
|
316
|
-
arguments: objectValue(data.arguments) ?? void 0,
|
|
317
|
-
createdAt: rowCreatedAt(row).toISOString(),
|
|
318
|
-
error: stringValue(data.error_message) == null ? void 0 : { message: stringValue(data.error_message) }
|
|
319
|
-
}) : toolCallIsPending(status) ? new AgentToolCallPending({
|
|
320
|
-
threadId: path,
|
|
321
|
-
itemId: rowItemId(row),
|
|
322
|
-
turnId: rowTurnId(row),
|
|
323
|
-
toolkit,
|
|
324
|
-
tool,
|
|
325
|
-
arguments: objectValue(data.arguments) ?? void 0,
|
|
326
|
-
createdAt: rowCreatedAt(row).toISOString()
|
|
327
|
-
}) : new AgentToolCallStarted({
|
|
328
|
-
threadId: path,
|
|
329
|
-
itemId: rowItemId(row),
|
|
330
|
-
turnId: rowTurnId(row),
|
|
331
|
-
toolkit,
|
|
332
|
-
tool,
|
|
333
|
-
arguments: objectValue(data.arguments) ?? void 0,
|
|
334
|
-
createdAt: rowCreatedAt(row).toISOString()
|
|
335
|
-
});
|
|
336
|
-
return [message];
|
|
337
|
-
}
|
|
338
|
-
return [];
|
|
339
163
|
}
|
|
340
|
-
function
|
|
341
|
-
if (typeof
|
|
342
|
-
return
|
|
164
|
+
function rowData(row) {
|
|
165
|
+
if (row.data != null && typeof row.data === "object" && !Array.isArray(row.data)) {
|
|
166
|
+
return row.data;
|
|
343
167
|
}
|
|
168
|
+
if (typeof row.data !== "string") return null;
|
|
344
169
|
try {
|
|
345
|
-
|
|
170
|
+
const decoded = JSON.parse(row.data);
|
|
171
|
+
return decoded != null && typeof decoded === "object" && !Array.isArray(decoded) ? decoded : null;
|
|
346
172
|
} catch {
|
|
347
173
|
return null;
|
|
348
174
|
}
|
|
349
175
|
}
|
|
350
|
-
function
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
const sequenceOrder = numberValue(left.sequence) - numberValue(right.sequence);
|
|
355
|
-
if (sequenceOrder !== 0) {
|
|
356
|
-
return sequenceOrder;
|
|
176
|
+
function byteArray(value) {
|
|
177
|
+
if (value instanceof Uint8Array) return value;
|
|
178
|
+
if (Array.isArray(value) && value.every((entry) => typeof entry === "number")) {
|
|
179
|
+
return new Uint8Array(value);
|
|
357
180
|
}
|
|
358
|
-
|
|
359
|
-
if (timestampOrder !== 0) {
|
|
360
|
-
return timestampOrder;
|
|
361
|
-
}
|
|
362
|
-
return rowItemId(left).localeCompare(rowItemId(right));
|
|
363
|
-
}
|
|
364
|
-
function rowItemId(row) {
|
|
365
|
-
return stringValue(row.item_id) ?? `row:${stringValue(row.sequence) ?? ""}:${stringValue(row.timestamp) ?? stringValue(row.created_at) ?? ""}`;
|
|
181
|
+
return void 0;
|
|
366
182
|
}
|
|
367
|
-
function
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
183
|
+
function compareDatasetThreadRows(left, right) {
|
|
184
|
+
const sequenceOrder = rowSequence(left) - rowSequence(right);
|
|
185
|
+
if (sequenceOrder !== 0) return sequenceOrder;
|
|
186
|
+
const timestampOrder = (rowCreatedAt(left, rowData(left))?.getTime() ?? 0) - (rowCreatedAt(right, rowData(right))?.getTime() ?? 0);
|
|
187
|
+
if (timestampOrder !== 0) return timestampOrder;
|
|
188
|
+
return String(left.item_id ?? "").localeCompare(String(right.item_id ?? ""));
|
|
189
|
+
}
|
|
190
|
+
function rowSequence(row) {
|
|
191
|
+
const value = row.sequence;
|
|
192
|
+
if (typeof value === "number" && Number.isFinite(value)) return Math.trunc(value);
|
|
193
|
+
if (typeof value === "bigint") return Number(value);
|
|
194
|
+
if (typeof value === "string") {
|
|
195
|
+
const parsed = Number(value);
|
|
196
|
+
if (Number.isFinite(parsed)) return Math.trunc(parsed);
|
|
197
|
+
}
|
|
198
|
+
return 0;
|
|
199
|
+
}
|
|
200
|
+
function rowCreatedAt(row, data) {
|
|
201
|
+
const message = data?.message;
|
|
202
|
+
const nestedMessage = message != null && typeof message === "object" && !Array.isArray(message) ? message : null;
|
|
203
|
+
for (const value of [row.timestamp, row.created_at, data?.created_at, nestedMessage?.created_at]) {
|
|
204
|
+
if (value instanceof Date && !Number.isNaN(value.getTime())) return value;
|
|
205
|
+
if (typeof value === "string" && value.trim() !== "") {
|
|
206
|
+
const parsed = new Date(value);
|
|
207
|
+
if (!Number.isNaN(parsed.getTime())) return parsed;
|
|
208
|
+
}
|
|
376
209
|
}
|
|
377
|
-
|
|
378
|
-
return Number.isNaN(parsed.getTime()) ? null : parsed;
|
|
210
|
+
return null;
|
|
379
211
|
}
|
|
380
212
|
function isDatasetTableNotFoundError(error) {
|
|
381
213
|
const values = [
|
|
382
214
|
error instanceof Error ? error.message : void 0,
|
|
383
|
-
typeof error === "object" && error !== null ?
|
|
215
|
+
typeof error === "object" && error !== null && "code" in error ? String(error.code ?? "") : void 0
|
|
384
216
|
].filter((value) => value != null);
|
|
385
217
|
return values.some((value) => {
|
|
386
218
|
const normalized = value.trim().toLowerCase();
|
|
@@ -388,39 +220,14 @@ function isDatasetTableNotFoundError(error) {
|
|
|
388
220
|
});
|
|
389
221
|
}
|
|
390
222
|
function describeError(error) {
|
|
391
|
-
|
|
392
|
-
return error.message;
|
|
393
|
-
}
|
|
394
|
-
return String(error);
|
|
223
|
+
return error instanceof Error && error.message.trim() !== "" ? error.message : String(error);
|
|
395
224
|
}
|
|
396
225
|
function isAsyncIterable(value) {
|
|
397
226
|
return value != null && typeof value === "object" && Symbol.asyncIterator in value;
|
|
398
227
|
}
|
|
399
|
-
function objectValue(value) {
|
|
400
|
-
return value != null && typeof value === "object" && !Array.isArray(value) ? value : null;
|
|
401
|
-
}
|
|
402
|
-
function stringValue(value) {
|
|
403
|
-
return typeof value === "string" && value.trim() !== "" ? value.trim() : void 0;
|
|
404
|
-
}
|
|
405
|
-
function stringList(value) {
|
|
406
|
-
if (!Array.isArray(value)) {
|
|
407
|
-
return [];
|
|
408
|
-
}
|
|
409
|
-
return value.filter((entry) => typeof entry === "string" && entry.trim() !== "").map((entry) => entry.trim());
|
|
410
|
-
}
|
|
411
|
-
function numberValue(value) {
|
|
412
|
-
return typeof value === "number" && Number.isFinite(value) ? value : 0;
|
|
413
|
-
}
|
|
414
|
-
function toolCallIsPending(status) {
|
|
415
|
-
const normalized = status?.trim().toLowerCase();
|
|
416
|
-
return normalized === "pending" || normalized === "queued";
|
|
417
|
-
}
|
|
418
|
-
function toolCallIsFinished(status) {
|
|
419
|
-
const normalized = status?.trim().toLowerCase();
|
|
420
|
-
return normalized === "completed" || normalized === "failed" || normalized === "error";
|
|
421
|
-
}
|
|
422
228
|
export {
|
|
423
229
|
DatasetAgentThread,
|
|
424
230
|
RoomDatasetAgentThread,
|
|
231
|
+
loadDatasetThreadEvents,
|
|
425
232
|
parseDatasetThreadRef
|
|
426
233
|
};
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type { ReactElement } from "react";
|
|
2
2
|
import { RoomClient } from "@meshagent/meshagent";
|
|
3
|
-
import type { BaseChatClient, ClientToolkitDescription } from "@meshagent/meshagent-agents";
|
|
4
|
-
import type { AgentToolChoice } from "./agent-thread.js";
|
|
3
|
+
import type { AgentMessageEvent, BaseChatClient, ClientToolkitDescription } from "@meshagent/meshagent-agents";
|
|
4
|
+
import type { AgentThreadSuggestion, AgentToolChoice } from "./agent-thread.js";
|
|
5
|
+
import type { ChatFeedWidget } from "./chat-feed-widget.js";
|
|
5
6
|
export type MultiThreadContentBuilder = (threadPath: string) => ReactElement;
|
|
6
7
|
export interface MultiThreadViewProps {
|
|
7
8
|
room: RoomClient;
|
|
@@ -19,6 +20,10 @@ export interface MultiThreadViewProps {
|
|
|
19
20
|
emptyStateTitle?: string;
|
|
20
21
|
emptyStateDescription?: string;
|
|
21
22
|
clientToolkits?: ClientToolkitDescription[];
|
|
23
|
+
chatFeedWidgets?: ChatFeedWidget[];
|
|
22
24
|
toolChoice?: AgentToolChoice;
|
|
25
|
+
suggestions?: readonly AgentThreadSuggestion[];
|
|
26
|
+
enableFileUpload?: boolean;
|
|
27
|
+
onThreadStarted?: (threadId: string, events: readonly AgentMessageEvent[]) => Promise<void> | void;
|
|
23
28
|
}
|
|
24
|
-
export declare function MultiThreadView({ room, chatClient, disposeChatClient, agentName, builder, toolkit, tool, selectedThreadPath, onSelectedThreadPathChanged, onSelectedThreadResolved, newThreadResetVersion, centerComposer, emptyStateTitle, emptyStateDescription, clientToolkits, toolChoice, }: MultiThreadViewProps): ReactElement;
|
|
29
|
+
export declare function MultiThreadView({ room, chatClient, disposeChatClient, agentName, builder, toolkit, tool, selectedThreadPath, onSelectedThreadPathChanged, onSelectedThreadResolved, newThreadResetVersion, centerComposer, emptyStateTitle, emptyStateDescription, clientToolkits, chatFeedWidgets, toolChoice, suggestions, enableFileUpload, onThreadStarted, }: MultiThreadViewProps): ReactElement;
|
|
@@ -21,7 +21,11 @@ function MultiThreadView({
|
|
|
21
21
|
emptyStateTitle = "Start a new thread",
|
|
22
22
|
emptyStateDescription = "Connect with this agent and your team",
|
|
23
23
|
clientToolkits,
|
|
24
|
-
|
|
24
|
+
chatFeedWidgets,
|
|
25
|
+
toolChoice,
|
|
26
|
+
suggestions,
|
|
27
|
+
enableFileUpload = false,
|
|
28
|
+
onThreadStarted
|
|
25
29
|
}) {
|
|
26
30
|
const controlledSelectedThreadPath = selectedThreadPath !== void 0 ? normalizeSelectedThreadPath(selectedThreadPath) : void 0;
|
|
27
31
|
const [internalSelectedThreadPath, setInternalSelectedThreadPath] = useState(() => controlledSelectedThreadPath ?? null);
|
|
@@ -71,7 +75,11 @@ function MultiThreadView({
|
|
|
71
75
|
emptyStateTitle,
|
|
72
76
|
emptyStateDescription,
|
|
73
77
|
clientToolkits,
|
|
74
|
-
|
|
78
|
+
chatFeedWidgets,
|
|
79
|
+
toolChoice,
|
|
80
|
+
suggestions,
|
|
81
|
+
enableFileUpload,
|
|
82
|
+
onThreadStarted
|
|
75
83
|
},
|
|
76
84
|
composerKey
|
|
77
85
|
);
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type { ReactElement } from "react";
|
|
2
2
|
import { RoomClient } from "@meshagent/meshagent";
|
|
3
|
-
import type { BaseChatClient, ClientToolkitDescription } from "@meshagent/meshagent-agents";
|
|
4
|
-
import type { AgentToolChoice } from "./agent-thread.js";
|
|
3
|
+
import type { AgentMessageEvent, BaseChatClient, ClientToolkitDescription } from "@meshagent/meshagent-agents";
|
|
4
|
+
import type { AgentThreadSuggestion, AgentToolChoice } from "./agent-thread.js";
|
|
5
|
+
import type { ChatFeedWidget } from "./chat-feed-widget.js";
|
|
5
6
|
export type NewChatThreadBuilder = (threadPath: string) => ReactElement;
|
|
6
7
|
export interface NewChatThreadProps {
|
|
7
8
|
room: RoomClient;
|
|
@@ -18,6 +19,10 @@ export interface NewChatThreadProps {
|
|
|
18
19
|
emptyStateTitle?: string;
|
|
19
20
|
emptyStateDescription?: string;
|
|
20
21
|
clientToolkits?: ClientToolkitDescription[];
|
|
22
|
+
chatFeedWidgets?: ChatFeedWidget[];
|
|
21
23
|
toolChoice?: AgentToolChoice;
|
|
24
|
+
suggestions?: readonly AgentThreadSuggestion[];
|
|
25
|
+
enableFileUpload?: boolean;
|
|
26
|
+
onThreadStarted?: (threadId: string, events: readonly AgentMessageEvent[]) => Promise<void> | void;
|
|
22
27
|
}
|
|
23
|
-
export declare function NewChatThread({ room, chatClient, disposeChatClient, agentName, builder, selectedThreadPath, onThreadPathChanged, onThreadResolved, centerComposer, emptyStateTitle, emptyStateDescription, clientToolkits, toolChoice, }: NewChatThreadProps): ReactElement;
|
|
28
|
+
export declare function NewChatThread({ room, chatClient, disposeChatClient, agentName, builder, selectedThreadPath, onThreadPathChanged, onThreadResolved, centerComposer, emptyStateTitle, emptyStateDescription, clientToolkits, chatFeedWidgets, toolChoice, suggestions, enableFileUpload, onThreadStarted, }: NewChatThreadProps): ReactElement;
|