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