@vettvangur/ai-sdk 0.7.3 → 0.7.4

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.
@@ -286,14 +286,21 @@ function createLiveChatProvider(config) {
286
286
  thread: { events }
287
287
  };
288
288
  try {
289
- const started = await sdk.startChat({ chat });
289
+ const { chat: started } = await sdk.startChat({ chat });
290
290
  adopt(started.id, started.thread, started.users, false);
291
291
  } catch (caught) {
292
292
  if (errorCode(caught) !== "CHAT_LIMIT_REACHED") throw caught;
293
293
  const { chatsSummary } = await sdk.listChats({ limit: 1 });
294
294
  const earlier = chatsSummary[0];
295
295
  if (!earlier) throw caught;
296
- const resumed = await sdk.resumeChat({ chat: {
296
+ if (earlier.active) {
297
+ const open = await sdk.getChat({ chatId: earlier.id });
298
+ if (open.thread?.active) {
299
+ adopt(open.id, open.thread, open.users, false);
300
+ return;
301
+ }
302
+ }
303
+ const { chat: resumed } = await sdk.resumeChat({ chat: {
297
304
  id: earlier.id,
298
305
  ...chat
299
306
  } });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vettvangur/ai-sdk",
3
- "version": "0.7.3",
3
+ "version": "0.7.4",
4
4
  "description": "Framework-agnostic AI chat client for server-rendered shells",
5
5
  "type": "module",
6
6
  "access": "public",