@meshagent/meshagent-tailwind 0.43.1 → 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.
Files changed (37) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/cjs/chat/agent-thread.d.ts +15 -0
  3. package/dist/cjs/chat/agent-thread.js +613 -0
  4. package/dist/cjs/chat/chat-bot-view.d.ts +3 -2
  5. package/dist/cjs/chat/chat-bot-view.js +34 -34
  6. package/dist/cjs/chat/chat-bot-view.test.js +325 -0
  7. package/dist/cjs/chat/live-chat-widgets.test.js +256 -0
  8. package/dist/cjs/chat/multi-thread-view.d.ts +3 -2
  9. package/dist/cjs/chat/multi-thread-view.js +4 -2
  10. package/dist/cjs/chat/new-chat-thread.d.ts +3 -2
  11. package/dist/cjs/chat/new-chat-thread.js +5 -2
  12. package/dist/cjs/file-preview/file-preview.js +2 -2
  13. package/dist/cjs/index.d.ts +1 -2
  14. package/dist/cjs/index.js +1 -2
  15. package/dist/esm/chat/agent-thread.d.ts +15 -0
  16. package/dist/esm/chat/agent-thread.js +606 -0
  17. package/dist/esm/chat/chat-bot-view.d.ts +3 -2
  18. package/dist/esm/chat/chat-bot-view.js +34 -34
  19. package/dist/esm/chat/chat-bot-view.test.js +336 -0
  20. package/dist/esm/chat/live-chat-widgets.test.js +262 -0
  21. package/dist/esm/chat/multi-thread-view.d.ts +3 -2
  22. package/dist/esm/chat/multi-thread-view.js +4 -2
  23. package/dist/esm/chat/new-chat-thread.d.ts +3 -2
  24. package/dist/esm/chat/new-chat-thread.js +5 -2
  25. package/dist/esm/file-preview/file-preview.js +2 -2
  26. package/dist/esm/index.d.ts +1 -2
  27. package/dist/esm/index.js +1 -2
  28. package/dist/index.css +1 -1
  29. package/package.json +10 -5
  30. package/dist/cjs/chat/chat-thread.d.ts +0 -12
  31. package/dist/cjs/chat/chat-thread.js +0 -815
  32. package/dist/cjs/chat/dataset-chat-thread.d.ts +0 -16
  33. package/dist/cjs/chat/dataset-chat-thread.js +0 -1813
  34. package/dist/esm/chat/chat-thread.d.ts +0 -12
  35. package/dist/esm/chat/chat-thread.js +0 -785
  36. package/dist/esm/chat/dataset-chat-thread.d.ts +0 -16
  37. package/dist/esm/chat/dataset-chat-thread.js +0 -1811
@@ -30,8 +30,7 @@ var import_meshagent_react = require("@meshagent/meshagent-react");
30
30
  var import_meshagent_agents = require("@meshagent/meshagent-agents");
31
31
  var import_lucide_react = require("lucide-react");
32
32
  var import_chat_hooks = require("./chat-hooks.js");
33
- var import_chat_thread = require("./chat-thread.js");
34
- var import_dataset_chat_thread = require("./dataset-chat-thread.js");
33
+ var import_agent_thread = require("./agent-thread.js");
35
34
  var import_button = require("../components/ui/button.js");
36
35
  var import_dialog = require("../components/ui/dialog.js");
37
36
  var import_input = require("../components/ui/input.js");
@@ -46,9 +45,6 @@ function normalizePath(path) {
46
45
  const normalized = path?.trim();
47
46
  return normalized ? normalized : null;
48
47
  }
49
- function isDatasetBackedThreadPath(path) {
50
- return path.startsWith("dataset://") || path.startsWith("tmp://");
51
- }
52
48
  function parseDate(value) {
53
49
  const parsed = new Date(value);
54
50
  return Number.isNaN(parsed.getTime()) ? /* @__PURE__ */ new Date(0) : parsed;
@@ -374,7 +370,13 @@ function ThreadListPanel({
374
370
  }) {
375
371
  const { entries, error, loading } = threadList;
376
372
  const hasSelectedEntry = selectedThreadPath !== null && entries.some((entry) => entry.path === selectedThreadPath);
377
- const showPendingNewThreadSelection = selectedThreadPath === null || !hasSelectedEntry;
373
+ const showPendingNewThreadSelection = selectedThreadPath === null;
374
+ const pendingSelectedThreadEntry = selectedThreadPath !== null && !hasSelectedEntry ? {
375
+ path: selectedThreadPath,
376
+ name: (0, import_conversation_descriptor.defaultThreadDisplayNameFromPath)(selectedThreadPath),
377
+ createdAt: "",
378
+ modifiedAt: ""
379
+ } : null;
378
380
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "h-full flex flex-col rounded-md border", children: loading ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "flex min-h-0 flex-1 items-center justify-center p-6", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_spinner.Spinner, { size: "lg", className: "text-muted-foreground" }) }) : error ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "flex min-h-0 flex-1 items-center justify-center p-6 text-center text-sm text-muted-foreground", children: `Unable to load threads: ${describeError(error)}` }) : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex h-full flex-1 flex-col overflow-y-auto py-1", children: [
379
381
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
380
382
  ThreadListRow,
@@ -386,6 +388,18 @@ function ThreadListPanel({
386
388
  }
387
389
  ),
388
390
  entries.length === 0 && showPendingNewThreadSelection ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "flex min-h-0 flex-1 items-center justify-center px-4 py-6 text-center text-sm text-muted-foreground", children: "No threads yet" }) : null,
391
+ pendingSelectedThreadEntry !== null ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
392
+ ThreadListEntryRow,
393
+ {
394
+ room,
395
+ entry: pendingSelectedThreadEntry,
396
+ agentName,
397
+ selected: true,
398
+ onSelect: onSelectThread,
399
+ onRename: onRenameThread
400
+ },
401
+ pendingSelectedThreadEntry.path
402
+ ) : null,
389
403
  entries.map((entry) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
390
404
  ThreadListEntryRow,
391
405
  {
@@ -480,7 +494,8 @@ function ChatBotView({
480
494
  newThreadResetVersion = 0,
481
495
  showThreadList = true,
482
496
  threadListWidth = 280,
483
- threadListCollapsedHeight = 220
497
+ threadListCollapsedHeight = 220,
498
+ clientToolkits
484
499
  }) {
485
500
  const isWideLayout = useIsWideLayout(multiThreadLayoutBreakpointPx);
486
501
  const resolvedDocumentPath = (0, import_react.useMemo)(
@@ -491,7 +506,7 @@ function ChatBotView({
491
506
  () => resolvedDocumentPath ?? (0, import_conversation_descriptor.chatDocumentPath)(agentName, { threadDir }),
492
507
  [agentName, resolvedDocumentPath, threadDir]
493
508
  );
494
- const needsChatClient = chatClient != null || threadDisplayMode === import_conversation_descriptor.ChatThreadDisplayMode.MultiThreadComposer || isDatasetBackedThreadPath(resolvedSingleThreadPath);
509
+ const needsChatClient = chatClient != null || threadDisplayMode === import_conversation_descriptor.ChatThreadDisplayMode.MultiThreadComposer;
495
510
  const ownsChatClient = chatClient == null && needsChatClient;
496
511
  const activeChatClient = (0, import_react.useMemo)(
497
512
  () => needsChatClient ? chatClient ?? new import_meshagent_agents.MessagingChatClient({ room, agentName }) : null,
@@ -609,25 +624,17 @@ function ChatBotView({
609
624
  });
610
625
  }, [activeSelectedThreadPath, closeRenameThreadDialog, emitResolvedThread, renameThreadDialog, threadList]);
611
626
  if (threadDisplayMode !== import_conversation_descriptor.ChatThreadDisplayMode.MultiThreadComposer) {
612
- return isDatasetBackedThreadPath(resolvedSingleThreadPath) ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
613
- import_dataset_chat_thread.DatasetChatThread,
627
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
628
+ import_agent_thread.AgentThread,
614
629
  {
615
630
  room,
616
631
  path: resolvedSingleThreadPath,
617
632
  chatClient: activeChatClient ?? void 0,
633
+ disposeChatClient: false,
618
634
  agentName,
619
635
  emptyStateTitle,
620
- emptyStateDescription
621
- }
622
- ) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
623
- import_chat_thread.ChatThread,
624
- {
625
- room,
626
- path: resolvedSingleThreadPath,
627
- participants,
628
- agentName,
629
- emptyStateTitle,
630
- emptyStateDescription
636
+ emptyStateDescription,
637
+ clientToolkits
631
638
  }
632
639
  );
633
640
  }
@@ -648,25 +655,18 @@ function ChatBotView({
648
655
  onSelectedThreadResolved: emitResolvedThread,
649
656
  newThreadResetVersion,
650
657
  centerComposer,
651
- builder: (threadPath) => isDatasetBackedThreadPath(threadPath) ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
652
- import_dataset_chat_thread.DatasetChatThread,
658
+ clientToolkits,
659
+ builder: (threadPath) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
660
+ import_agent_thread.AgentThread,
653
661
  {
654
662
  room,
655
663
  path: threadPath,
656
664
  chatClient: activeChatClient ?? void 0,
665
+ disposeChatClient: false,
657
666
  agentName,
658
667
  emptyStateTitle: startNewThreadTitle,
659
- emptyStateDescription: startNewThreadDescription
660
- }
661
- ) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
662
- import_chat_thread.ChatThread,
663
- {
664
- room,
665
- path: threadPath,
666
- participants,
667
- agentName,
668
- emptyStateTitle: startNewThreadTitle,
669
- emptyStateDescription: startNewThreadDescription
668
+ emptyStateDescription: startNewThreadDescription,
669
+ clientToolkits
670
670
  }
671
671
  )
672
672
  }
@@ -0,0 +1,325 @@
1
+ "use strict";
2
+ var import_jsx_runtime = require("react/jsx-runtime");
3
+ var import_react = require("react");
4
+ var import_vitest = require("vitest");
5
+ var import_react2 = require("@testing-library/react");
6
+ var import_meshagent_agents = require("@meshagent/meshagent-agents");
7
+ var import_agent_thread = require("./agent-thread.js");
8
+ var import_chat_bot_view = require("./chat-bot-view.js");
9
+ class FakeParticipant {
10
+ id;
11
+ role;
12
+ attributes;
13
+ constructor({ id, role, attributes }) {
14
+ this.id = id;
15
+ this.role = role;
16
+ this.attributes = new Map(Object.entries(attributes));
17
+ }
18
+ getAttribute(name) {
19
+ return this.attributes.get(name);
20
+ }
21
+ }
22
+ class FakeMessaging {
23
+ remoteParticipants = [
24
+ new FakeParticipant({
25
+ id: "agent-codex",
26
+ role: "agent",
27
+ attributes: {
28
+ name: "codex",
29
+ supports_agent_messages: true
30
+ }
31
+ })
32
+ ];
33
+ listeners = /* @__PURE__ */ new Map();
34
+ on(event, listener) {
35
+ const listeners = this.listeners.get(event) ?? /* @__PURE__ */ new Set();
36
+ listeners.add(listener);
37
+ this.listeners.set(event, listeners);
38
+ }
39
+ off(event, listener) {
40
+ this.listeners.get(event)?.delete(listener);
41
+ }
42
+ sendMessage() {
43
+ }
44
+ }
45
+ class FakeElement {
46
+ tagName;
47
+ id;
48
+ attributes;
49
+ children = [];
50
+ constructor(tagName, attributes = {}) {
51
+ this.tagName = tagName;
52
+ this.id = typeof attributes.id === "string" ? attributes.id : crypto.randomUUID();
53
+ this.attributes = new Map(Object.entries(attributes));
54
+ }
55
+ getAttribute(name) {
56
+ return this.attributes.get(name);
57
+ }
58
+ getChildren() {
59
+ return this.children;
60
+ }
61
+ createChildElement(tagName, attributes = {}) {
62
+ const child = new FakeElement(tagName, attributes);
63
+ this.children.push(child);
64
+ return child;
65
+ }
66
+ }
67
+ class FakeDocument {
68
+ root;
69
+ constructor() {
70
+ this.root = new FakeElement("thread");
71
+ this.root.createChildElement("members");
72
+ this.root.createChildElement("messages");
73
+ }
74
+ }
75
+ function neverEndingEvents() {
76
+ return {
77
+ [Symbol.asyncIterator]: () => ({
78
+ next: () => new Promise(() => void 0),
79
+ return: async () => ({ done: true, value: void 0 })
80
+ })
81
+ };
82
+ }
83
+ function fakeRoom() {
84
+ return {
85
+ localParticipant: new FakeParticipant({
86
+ id: "local",
87
+ role: "user",
88
+ attributes: { name: "Jesse" }
89
+ }),
90
+ messaging: new FakeMessaging(),
91
+ sync: {
92
+ open: async () => new FakeDocument(),
93
+ close: async () => void 0
94
+ },
95
+ listen: neverEndingEvents,
96
+ on: () => void 0,
97
+ off: () => void 0
98
+ };
99
+ }
100
+ class FakeChatClient extends import_meshagent_agents.BaseChatClient {
101
+ sent = [];
102
+ threadEntries = [];
103
+ async sendAgentMessage(message) {
104
+ this.sent.push(message);
105
+ if (message instanceof import_meshagent_agents.ListThreads) {
106
+ queueMicrotask(() => {
107
+ this.handleAgentMessage(new import_meshagent_agents.ThreadsListed({
108
+ sourceMessageId: message.messageId,
109
+ threads: this.threadEntries,
110
+ total: this.threadEntries.length,
111
+ offset: 0,
112
+ limit: 200
113
+ }));
114
+ });
115
+ }
116
+ }
117
+ publishThread(path, name) {
118
+ const now = (/* @__PURE__ */ new Date()).toISOString();
119
+ this.threadEntries.unshift({
120
+ path,
121
+ name,
122
+ createdAt: now,
123
+ modifiedAt: now
124
+ });
125
+ this.handleAgentMessage(new import_meshagent_agents.ThreadCreated({
126
+ thread: new import_meshagent_agents.AgentThreadListEntry({
127
+ path,
128
+ name,
129
+ createdAt: now,
130
+ modifiedAt: now
131
+ })
132
+ }));
133
+ }
134
+ startThreadMessages() {
135
+ return this.sent.filter((message) => message instanceof import_meshagent_agents.StartThread);
136
+ }
137
+ }
138
+ (0, import_vitest.afterEach)(() => {
139
+ (0, import_react2.cleanup)();
140
+ });
141
+ (0, import_vitest.describe)("ChatBotView multi-thread composer", () => {
142
+ (0, import_vitest.it)("renders typed agent messages and selects the second newly-created thread after returning to New thread", async () => {
143
+ const room = fakeRoom();
144
+ const chatClient = new FakeChatClient();
145
+ const selectedPaths = [];
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
+ properties: {
153
+ prompt: { type: "string" }
154
+ }
155
+ }
156
+ })];
157
+ (0, import_react2.render)(
158
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
159
+ import_chat_bot_view.ChatBotView,
160
+ {
161
+ room,
162
+ chatClient,
163
+ agentName: "codex",
164
+ threadDisplayMode: import_chat_bot_view.ChatThreadDisplayMode.MultiThreadComposer,
165
+ threadListPath: "agent://codex/threads",
166
+ onSelectedThreadPathChanged: (path) => {
167
+ selectedPaths.push(path);
168
+ },
169
+ clientToolkits
170
+ }
171
+ )
172
+ );
173
+ await (0, import_react2.waitFor)(() => (0, import_vitest.expect)(import_react2.screen.getByText("Start a new thread")).toBeTruthy());
174
+ import_react2.fireEvent.change(import_react2.screen.getByPlaceholderText("Type a message or @codex"), {
175
+ target: { value: "first pending message" }
176
+ });
177
+ import_react2.fireEvent.click(import_react2.screen.getByTitle("Send"));
178
+ await (0, import_react2.waitFor)(() => (0, import_vitest.expect)(chatClient.startThreadMessages()).toHaveLength(1));
179
+ (0, import_vitest.expect)(chatClient.startThreadMessages()[0].clientToolkits?.[0].name).to.equal("ask_user");
180
+ await (0, import_react2.act)(async () => {
181
+ chatClient.publishThread("thread-first", "First thread");
182
+ chatClient.handleAgentMessage(new import_meshagent_agents.ThreadStarted({
183
+ sourceMessageId: chatClient.startThreadMessages()[0].messageId,
184
+ threadId: "thread-first"
185
+ }));
186
+ });
187
+ await (0, import_react2.waitFor)(() => (0, import_vitest.expect)(selectedPaths.at(-1)).to.equal("thread-first"));
188
+ (0, import_vitest.expect)(await import_react2.screen.findByText("first pending message")).toBeTruthy();
189
+ await (0, import_react2.act)(async () => {
190
+ chatClient.handleAgentMessage(new import_meshagent_agents.AgentTextContentDelta({
191
+ threadId: "thread-first",
192
+ turnId: "turn-first",
193
+ itemId: "agent-response-first",
194
+ text: "first agent response"
195
+ }));
196
+ });
197
+ (0, import_vitest.expect)(await import_react2.screen.findByText("first agent response")).toBeTruthy();
198
+ import_react2.fireEvent.click(import_react2.screen.getByText("New thread"));
199
+ await (0, import_react2.waitFor)(() => (0, import_vitest.expect)(import_react2.screen.getByText("Start a new thread")).toBeTruthy());
200
+ import_react2.fireEvent.change(import_react2.screen.getByPlaceholderText("Type a message or @codex"), {
201
+ target: { value: "second pending message" }
202
+ });
203
+ import_react2.fireEvent.click(import_react2.screen.getByTitle("Send"));
204
+ await (0, import_react2.waitFor)(() => (0, import_vitest.expect)(chatClient.startThreadMessages()).toHaveLength(2));
205
+ (0, import_vitest.expect)(chatClient.startThreadMessages()[1].clientToolkits?.[0].name).to.equal("ask_user");
206
+ await (0, import_react2.act)(async () => {
207
+ chatClient.handleAgentMessage(new import_meshagent_agents.ThreadStarted({
208
+ sourceMessageId: chatClient.startThreadMessages()[1].messageId,
209
+ threadId: "thread-second"
210
+ }));
211
+ });
212
+ await (0, import_react2.waitFor)(() => (0, import_vitest.expect)(selectedPaths.at(-1)).to.equal("thread-second"));
213
+ (0, import_vitest.expect)(await import_react2.screen.findByText("second pending message")).toBeTruthy();
214
+ (0, import_vitest.expect)(import_react2.screen.queryByText("first pending message")).to.equal(null);
215
+ (0, import_vitest.expect)(import_react2.screen.queryByText("first agent response")).to.equal(null);
216
+ });
217
+ (0, import_vitest.it)("keeps started sessions alive across StrictMode remounts and renders responses for each redirected thread", async () => {
218
+ const room = fakeRoom();
219
+ const chatClient = new FakeChatClient();
220
+ const selectedPaths = [];
221
+ (0, import_react2.render)(
222
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react.StrictMode, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
223
+ import_chat_bot_view.ChatBotView,
224
+ {
225
+ room,
226
+ chatClient,
227
+ agentName: "codex",
228
+ threadDisplayMode: import_chat_bot_view.ChatThreadDisplayMode.MultiThreadComposer,
229
+ threadListPath: "agent://codex/threads",
230
+ onSelectedThreadPathChanged: (path) => {
231
+ selectedPaths.push(path);
232
+ }
233
+ }
234
+ ) })
235
+ );
236
+ await (0, import_react2.waitFor)(() => (0, import_vitest.expect)(import_react2.screen.getByText("Start a new thread")).toBeTruthy());
237
+ import_react2.fireEvent.change(import_react2.screen.getByPlaceholderText("Type a message or @codex"), {
238
+ target: { value: "first strict pending" }
239
+ });
240
+ import_react2.fireEvent.click(import_react2.screen.getByTitle("Send"));
241
+ await (0, import_react2.waitFor)(() => (0, import_vitest.expect)(chatClient.startThreadMessages()).toHaveLength(1));
242
+ await (0, import_react2.act)(async () => {
243
+ chatClient.handleAgentMessage(new import_meshagent_agents.ThreadStarted({
244
+ sourceMessageId: chatClient.startThreadMessages()[0].messageId,
245
+ threadId: "thread-strict-first"
246
+ }));
247
+ chatClient.handleAgentMessage(new import_meshagent_agents.AgentTextContentDelta({
248
+ threadId: "thread-strict-first",
249
+ turnId: "turn-strict-first",
250
+ itemId: "agent-response-strict-first",
251
+ text: "first strict response"
252
+ }));
253
+ });
254
+ await (0, import_react2.waitFor)(() => (0, import_vitest.expect)(selectedPaths.at(-1)).to.equal("thread-strict-first"));
255
+ (0, import_vitest.expect)(await import_react2.screen.findByText("first strict pending")).toBeTruthy();
256
+ (0, import_vitest.expect)(await import_react2.screen.findByText("first strict response")).toBeTruthy();
257
+ (0, import_vitest.expect)(import_react2.screen.queryByText(/Starting a thread/i)).to.equal(null);
258
+ (0, import_vitest.expect)(chatClient.sent.some((message) => message instanceof import_meshagent_agents.CloseThread && message.threadId === "thread-strict-first")).to.equal(false);
259
+ import_react2.fireEvent.click(import_react2.screen.getByText("New thread"));
260
+ await (0, import_react2.waitFor)(() => (0, import_vitest.expect)(selectedPaths.at(-1)).to.equal(null));
261
+ await (0, import_react2.waitFor)(() => (0, import_vitest.expect)(import_react2.screen.getByText("Start a new thread")).toBeTruthy());
262
+ import_react2.fireEvent.change(import_react2.screen.getByPlaceholderText("Type a message or @codex"), {
263
+ target: { value: "second strict pending" }
264
+ });
265
+ import_react2.fireEvent.click(import_react2.screen.getByTitle("Send"));
266
+ await (0, import_react2.waitFor)(() => (0, import_vitest.expect)(chatClient.startThreadMessages()).toHaveLength(2));
267
+ await (0, import_react2.act)(async () => {
268
+ chatClient.handleAgentMessage(new import_meshagent_agents.ThreadStarted({
269
+ sourceMessageId: chatClient.startThreadMessages()[1].messageId,
270
+ threadId: "thread-strict-second"
271
+ }));
272
+ chatClient.handleAgentMessage(new import_meshagent_agents.AgentTextContentDelta({
273
+ threadId: "thread-strict-second",
274
+ turnId: "turn-strict-second",
275
+ itemId: "agent-response-strict-second",
276
+ text: "second strict response"
277
+ }));
278
+ });
279
+ await (0, import_react2.waitFor)(() => (0, import_vitest.expect)(selectedPaths.at(-1)).to.equal("thread-strict-second"));
280
+ (0, import_vitest.expect)(await import_react2.screen.findByText("second strict pending")).toBeTruthy();
281
+ (0, import_vitest.expect)(await import_react2.screen.findByText("second strict response")).toBeTruthy();
282
+ (0, import_vitest.expect)(import_react2.screen.queryByText("first strict pending")).to.equal(null);
283
+ (0, import_vitest.expect)(import_react2.screen.queryByText("first strict response")).to.equal(null);
284
+ (0, import_vitest.expect)(import_react2.screen.queryByText(/Starting a thread/i)).to.equal(null);
285
+ (0, import_vitest.expect)(chatClient.sent.some((message) => message instanceof import_meshagent_agents.CloseThread && message.threadId === "thread-strict-second")).to.equal(false);
286
+ });
287
+ });
288
+ (0, import_vitest.describe)("AgentThread", () => {
289
+ (0, import_vitest.it)("passes client toolkits on turn starts from the composer", async () => {
290
+ const room = fakeRoom();
291
+ const chatClient = new FakeChatClient();
292
+ const clientToolkits = [new import_meshagent_agents.ClientToolkitDescription({
293
+ name: "ask_user",
294
+ title: "Ask User",
295
+ description: "Ask the user a short question.",
296
+ inputSchema: {
297
+ type: "object",
298
+ properties: {
299
+ prompt: { type: "string" }
300
+ }
301
+ }
302
+ })];
303
+ (0, import_react2.render)(
304
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
305
+ import_agent_thread.AgentThread,
306
+ {
307
+ room,
308
+ path: "thread-existing",
309
+ chatClient,
310
+ agentName: "codex",
311
+ clientToolkits
312
+ }
313
+ )
314
+ );
315
+ import_react2.fireEvent.change(import_react2.screen.getByPlaceholderText("Type a message"), {
316
+ target: { value: "turn start with a client toolkit" }
317
+ });
318
+ import_react2.fireEvent.click(import_react2.screen.getByTitle("Send"));
319
+ await (0, import_react2.waitFor)(() => {
320
+ const turnStarts = chatClient.sent.filter((message) => message instanceof import_meshagent_agents.TurnStart);
321
+ (0, import_vitest.expect)(turnStarts).toHaveLength(1);
322
+ (0, import_vitest.expect)(turnStarts[0].clientToolkits?.[0].name).to.equal("ask_user");
323
+ });
324
+ });
325
+ });