@liveblocks/core 2.25.0-aiprivatebeta8 → 3.0.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/dist/index.js CHANGED
@@ -6,7 +6,7 @@ var __export = (target, all) => {
6
6
 
7
7
  // src/version.ts
8
8
  var PKG_NAME = "@liveblocks/core";
9
- var PKG_VERSION = "2.25.0-aiprivatebeta8";
9
+ var PKG_VERSION = "3.0.0";
10
10
  var PKG_FORMAT = "esm";
11
11
 
12
12
  // src/dupe-detection.ts
@@ -3715,6 +3715,11 @@ function appendDelta(content, delta) {
3715
3715
 
3716
3716
  // src/ai.ts
3717
3717
  var DEFAULT_REQUEST_TIMEOUT = 4e3;
3718
+ function defineAiTool() {
3719
+ return (def) => {
3720
+ return def;
3721
+ };
3722
+ }
3718
3723
  var KnowledgeStack = class {
3719
3724
  #_layers;
3720
3725
  #stack;
@@ -3775,50 +3780,66 @@ var KnowledgeStack = class {
3775
3780
  function now() {
3776
3781
  return (/* @__PURE__ */ new Date()).toISOString();
3777
3782
  }
3783
+ var kWILDCARD = Symbol("*");
3778
3784
  function createStore_forTools() {
3779
- const toolsByChatId\u03A3 = new DefaultMap((_chatId) => {
3780
- return new DefaultMap((_toolName) => {
3781
- return new Signal(void 0);
3785
+ const toolsByChatId\u03A3 = new DefaultMap(
3786
+ (_chatId) => {
3787
+ return new DefaultMap((_name) => {
3788
+ return new Signal(void 0);
3789
+ });
3790
+ }
3791
+ );
3792
+ const globalOrScopedTool\u03A3 = new DefaultMap((nameAndChat) => {
3793
+ const [name, chatId] = tryParseJson(nameAndChat);
3794
+ return DerivedSignal.from(() => {
3795
+ return (
3796
+ // A tool that's registered and scoped to a specific chat ID...
3797
+ (chatId !== void 0 ? toolsByChatId\u03A3.get(chatId)?.get(name) : void 0)?.get() ?? // ...or a globally registered tool
3798
+ toolsByChatId\u03A3.getOrCreate(kWILDCARD).get(name)?.get()
3799
+ );
3782
3800
  });
3783
3801
  });
3784
- function getToolDefinition\u03A3(chatId, toolName) {
3785
- return toolsByChatId\u03A3.getOrCreate(chatId).getOrCreate(toolName);
3802
+ function getTool\u03A3(name, chatId) {
3803
+ const key = JSON.stringify(chatId !== void 0 ? [name, chatId] : [name]);
3804
+ return globalOrScopedTool\u03A3.getOrCreate(key);
3786
3805
  }
3787
- function addToolDefinition(chatId, name, definition) {
3788
- if (!definition.execute && !definition.render) {
3806
+ function registerTool(name, tool, chatId) {
3807
+ if (!tool.execute && !tool.render) {
3789
3808
  throw new Error(
3790
- "A tool definition must have an execute() function, a render property, or both."
3809
+ "A tool definition must have an execute() function, a render() function, or both."
3791
3810
  );
3792
3811
  }
3793
- toolsByChatId\u03A3.getOrCreate(chatId).getOrCreate(name).set(definition);
3812
+ const key = chatId ?? kWILDCARD;
3813
+ toolsByChatId\u03A3.getOrCreate(key).getOrCreate(name).set(tool);
3814
+ return () => unregisterTool(key, name);
3794
3815
  }
3795
- function removeToolDefinition(chatId, toolName) {
3816
+ function unregisterTool(chatId, name) {
3796
3817
  const tools = toolsByChatId\u03A3.get(chatId);
3797
3818
  if (tools === void 0) return;
3798
- const tool = tools.get(toolName);
3819
+ const tool = tools.get(name);
3799
3820
  if (tool === void 0) return;
3800
3821
  tool.set(void 0);
3801
3822
  }
3802
- function getToolsForChat(chatId) {
3803
- const tools = toolsByChatId\u03A3.get(chatId);
3804
- if (tools === void 0) return [];
3805
- return Array.from(tools.entries()).map(([name, tool]) => {
3806
- if (tool.get() === void 0) return null;
3807
- return {
3808
- name,
3809
- definition: tool.get()
3810
- };
3811
- }).filter((tool) => tool !== null);
3823
+ function getToolDescriptions(chatId) {
3824
+ const globalTools\u03A3 = toolsByChatId\u03A3.get(kWILDCARD);
3825
+ const scopedTools\u03A3 = toolsByChatId\u03A3.get(chatId);
3826
+ return Array.from([
3827
+ ...globalTools\u03A3?.entries() ?? [],
3828
+ ...scopedTools\u03A3?.entries() ?? []
3829
+ ]).flatMap(([name, tool\u03A3]) => {
3830
+ const tool = tool\u03A3.get();
3831
+ return tool ? [{ name, description: tool.description, parameters: tool.parameters }] : [];
3832
+ });
3812
3833
  }
3813
3834
  return {
3814
- getToolDefinition\u03A3,
3815
- getToolsForChat,
3816
- addToolDefinition,
3817
- removeToolDefinition
3835
+ getToolDescriptions,
3836
+ getTool\u03A3,
3837
+ registerTool
3818
3838
  };
3819
3839
  }
3820
- function createStore_forChatMessages(toolsStore, setToolResult) {
3821
- const seenToolCallIds = /* @__PURE__ */ new Set();
3840
+ function createStore_forChatMessages(toolsStore, setToolResultFn) {
3841
+ const myMessages = /* @__PURE__ */ new Set();
3842
+ const handledInvocations = /* @__PURE__ */ new Set();
3822
3843
  const messagePoolByChatId\u03A3 = new DefaultMap(
3823
3844
  (_chatId) => new MutableSignal(
3824
3845
  new TreePool(
@@ -3896,39 +3917,39 @@ function createStore_forChatMessages(toolsStore, setToolResult) {
3896
3917
  });
3897
3918
  }
3898
3919
  if (message.role === "assistant" && message.status === "awaiting-tool") {
3899
- for (const toolCall of message.contentSoFar.filter(
3900
- (part) => part.type === "tool-invocation" && part.status === "executing"
3901
- )) {
3902
- if (seenToolCallIds.has(toolCall.toolCallId)) {
3903
- continue;
3904
- }
3905
- seenToolCallIds.add(toolCall.toolCallId);
3906
- const toolDef = toolsStore.getToolDefinition\u03A3(message.chatId, toolCall.toolName).get();
3907
- const respondSync = (result) => {
3908
- setToolResult(
3909
- message.chatId,
3910
- message.id,
3911
- toolCall.toolCallId,
3912
- result
3913
- // TODO Pass in AiGenerationOptions here, or make the backend use the same options
3914
- ).catch((err) => {
3915
- error2(
3916
- `Error trying to respond to tool-call: ${String(err)} (in respond())`
3917
- );
3918
- });
3919
- };
3920
- const executeFn = toolDef?.execute;
3921
- if (executeFn) {
3922
- (async () => {
3923
- const result = await executeFn(toolCall.args);
3924
- respondSync(result);
3925
- })().catch((err) => {
3926
- error2(
3927
- `Error trying to respond to tool-call: ${String(err)} (in execute())`
3928
- );
3929
- });
3920
+ if (myMessages.has(message.id)) {
3921
+ for (const toolInvocation of message.contentSoFar.filter(
3922
+ (part) => part.type === "tool-invocation" && part.stage === "executing"
3923
+ )) {
3924
+ if (!handledInvocations.has(toolInvocation.invocationId)) {
3925
+ handledInvocations.add(toolInvocation.invocationId);
3926
+ } else {
3927
+ continue;
3928
+ }
3929
+ const executeFn = toolsStore.getTool\u03A3(toolInvocation.name, message.chatId).get()?.execute;
3930
+ if (executeFn) {
3931
+ (async () => {
3932
+ const result = await executeFn(toolInvocation.args, {
3933
+ name: toolInvocation.name,
3934
+ invocationId: toolInvocation.invocationId
3935
+ });
3936
+ return await setToolResultFn(
3937
+ message.chatId,
3938
+ message.id,
3939
+ toolInvocation.invocationId,
3940
+ result ?? { data: {} }
3941
+ // TODO Pass in AiGenerationOptions here, or make the backend use the same options
3942
+ );
3943
+ })().catch((err) => {
3944
+ error2(
3945
+ `Error trying to respond to tool-call: ${String(err)} (in execute())`
3946
+ );
3947
+ });
3948
+ }
3930
3949
  }
3931
3950
  }
3951
+ } else {
3952
+ myMessages.delete(message.id);
3932
3953
  }
3933
3954
  });
3934
3955
  }
@@ -4073,20 +4094,23 @@ function createStore_forChatMessages(toolsStore, setToolResult) {
4073
4094
  remove,
4074
4095
  removeByChatId,
4075
4096
  addDelta,
4076
- failAllPending
4097
+ failAllPending,
4098
+ markMine(messageId) {
4099
+ myMessages.add(messageId);
4100
+ }
4077
4101
  };
4078
4102
  }
4079
4103
  function createStore_forUserAiChats() {
4080
- const mutable\u03A3 = new MutableSignal(
4104
+ const allChatsInclDeleted\u03A3 = new MutableSignal(
4081
4105
  SortedList.with((x, y) => y.createdAt < x.createdAt)
4082
4106
  );
4083
- const chats\u03A3 = DerivedSignal.from(
4084
- () => Array.from(mutable\u03A3.get()).filter((c) => !c.deletedAt)
4107
+ const nonDeletedChats\u03A3 = DerivedSignal.from(
4108
+ () => Array.from(allChatsInclDeleted\u03A3.get()).filter((c) => !c.deletedAt)
4085
4109
  );
4086
4110
  function upsertMany(chats) {
4087
- mutable\u03A3.mutate((list) => {
4111
+ allChatsInclDeleted\u03A3.mutate((list) => {
4088
4112
  for (const chat of chats) {
4089
- remove(chat.id);
4113
+ list.removeBy((c) => c.id === chat.id, 1);
4090
4114
  list.add(chat);
4091
4115
  }
4092
4116
  });
@@ -4094,19 +4118,26 @@ function createStore_forUserAiChats() {
4094
4118
  function upsert(chat) {
4095
4119
  upsertMany([chat]);
4096
4120
  }
4097
- function remove(chatId) {
4098
- mutable\u03A3.mutate((list) => list.removeBy((c) => c.id === chatId, 1));
4121
+ function markDeleted(chatId) {
4122
+ allChatsInclDeleted\u03A3.mutate((list) => {
4123
+ const chat = list.find((c) => c.id === chatId);
4124
+ if (!chat) return false;
4125
+ upsert({ ...chat, deletedAt: now() });
4126
+ return void 0;
4127
+ });
4099
4128
  }
4100
4129
  function getChatById(chatId) {
4101
- return Array.from(mutable\u03A3.get()).find((chat) => chat.id === chatId);
4130
+ return Array.from(allChatsInclDeleted\u03A3.get()).find(
4131
+ (chat) => chat.id === chatId
4132
+ );
4102
4133
  }
4103
4134
  return {
4104
- chats\u03A3,
4135
+ chats\u03A3: nonDeletedChats\u03A3,
4105
4136
  getChatById,
4106
4137
  // Mutations
4107
4138
  upsert,
4108
4139
  upsertMany,
4109
- remove
4140
+ markDeleted
4110
4141
  };
4111
4142
  }
4112
4143
  function createAi(config) {
@@ -4116,7 +4147,6 @@ function createAi(config) {
4116
4147
  false
4117
4148
  // AI doesn't have actors (yet, but it will)
4118
4149
  );
4119
- const clientId = nanoid(7);
4120
4150
  const chatsStore = createStore_forUserAiChats();
4121
4151
  const toolsStore = createStore_forTools();
4122
4152
  const messagesStore = createStore_forChatMessages(toolsStore, setToolResult);
@@ -4196,7 +4226,11 @@ function createAi(config) {
4196
4226
  context.messagesStore.upsert(msg.message);
4197
4227
  break;
4198
4228
  }
4229
+ case "warning":
4230
+ warn(msg.message);
4231
+ break;
4199
4232
  case "error":
4233
+ error2(msg.error);
4200
4234
  break;
4201
4235
  case "rebooted":
4202
4236
  context.messagesStore.failAllPending();
@@ -4207,7 +4241,7 @@ function createAi(config) {
4207
4241
  context.messagesStore.remove(m.chatId, m.id);
4208
4242
  }
4209
4243
  for (const chatId of msg["-chats"] ?? []) {
4210
- context.chatsStore.remove(chatId);
4244
+ context.chatsStore.markDeleted(chatId);
4211
4245
  context.messagesStore.removeByChatId(chatId);
4212
4246
  }
4213
4247
  for (const chatId of msg.clear ?? []) {
@@ -4233,7 +4267,7 @@ function createAi(config) {
4233
4267
  context.chatsStore.upsert(msg.chat);
4234
4268
  break;
4235
4269
  case "delete-chat":
4236
- context.chatsStore.remove(msg.chatId);
4270
+ context.chatsStore.markDeleted(msg.chatId);
4237
4271
  context.messagesStore.removeByChatId(msg.chatId);
4238
4272
  break;
4239
4273
  case "get-message-tree":
@@ -4277,7 +4311,13 @@ function createAi(config) {
4277
4311
  );
4278
4312
  }
4279
4313
  });
4314
+ function connectInitially() {
4315
+ if (managedSocket.getStatus() === "initial") {
4316
+ managedSocket.connect();
4317
+ }
4318
+ }
4280
4319
  async function sendClientMsgWithResponse(msg) {
4320
+ connectInitially();
4281
4321
  if (managedSocket.getStatus() !== "connected") {
4282
4322
  await managedSocket.events.didConnect.waitUntil();
4283
4323
  }
@@ -4331,70 +4371,65 @@ function createAi(config) {
4331
4371
  function updateKnowledge(layerKey, data, key = nanoid()) {
4332
4372
  context.knowledge.updateKnowledge(layerKey, key, data);
4333
4373
  }
4334
- function debug_getAllKnowledge() {
4335
- return context.knowledge.get();
4336
- }
4337
- async function setToolResult(chatId, messageId, toolCallId, result, options) {
4374
+ async function setToolResult(chatId, messageId, invocationId, result, options) {
4338
4375
  const knowledge = context.knowledge.get();
4339
- return sendClientMsgWithResponse({
4376
+ const tools = context.toolsStore.getToolDescriptions(chatId);
4377
+ const resp = await sendClientMsgWithResponse({
4340
4378
  cmd: "set-tool-result",
4341
4379
  chatId,
4342
4380
  messageId,
4343
- toolCallId,
4344
- clientId,
4381
+ invocationId,
4345
4382
  result,
4346
4383
  generationOptions: {
4347
4384
  copilotId: options?.copilotId,
4348
4385
  stream: options?.stream,
4349
4386
  timeout: options?.timeout,
4387
+ // Knowledge and tools aren't coming from the options, but retrieved
4388
+ // from the global context
4350
4389
  knowledge: knowledge.length > 0 ? knowledge : void 0,
4351
- tools: context.toolsStore.getToolsForChat(chatId).map((tool) => ({
4352
- name: tool.name,
4353
- description: tool.definition.description,
4354
- parameters: tool.definition.parameters
4355
- }))
4390
+ tools: tools.length > 0 ? tools : void 0
4356
4391
  }
4357
4392
  });
4393
+ if (resp.ok) {
4394
+ messagesStore.markMine(resp.message.id);
4395
+ }
4358
4396
  }
4359
4397
  return Object.defineProperty(
4360
4398
  {
4361
4399
  [kInternal]: {
4362
4400
  context
4363
4401
  },
4364
- connect: () => managedSocket.connect(),
4365
- reconnect: () => managedSocket.reconnect(),
4402
+ connectInitially,
4403
+ // reconnect: () => managedSocket.reconnect(),
4366
4404
  disconnect: () => managedSocket.disconnect(),
4367
4405
  getChats,
4368
4406
  getOrCreateChat,
4369
4407
  deleteChat: (chatId) => {
4370
- return sendClientMsgWithResponse({
4371
- cmd: "delete-chat",
4372
- chatId
4373
- });
4408
+ return sendClientMsgWithResponse({ cmd: "delete-chat", chatId });
4374
4409
  },
4375
4410
  getMessageTree,
4376
4411
  deleteMessage: (chatId, messageId) => sendClientMsgWithResponse({ cmd: "delete-message", chatId, messageId }),
4377
4412
  clearChat: (chatId) => sendClientMsgWithResponse({ cmd: "clear-chat", chatId }),
4378
4413
  askUserMessageInChat: async (chatId, userMessage, targetMessageId, options) => {
4379
4414
  const knowledge = context.knowledge.get();
4380
- return sendClientMsgWithResponse({
4415
+ const tools = context.toolsStore.getToolDescriptions(chatId);
4416
+ const resp = await sendClientMsgWithResponse({
4381
4417
  cmd: "ask-in-chat",
4382
4418
  chatId,
4383
4419
  sourceMessage: userMessage,
4384
4420
  targetMessageId,
4385
- clientId,
4386
4421
  generationOptions: {
4387
4422
  copilotId: options?.copilotId,
4388
4423
  stream: options?.stream,
4389
4424
  timeout: options?.timeout,
4425
+ // Knowledge and tools aren't coming from the options, but retrieved
4426
+ // from the global context
4390
4427
  knowledge: knowledge.length > 0 ? knowledge : void 0,
4391
- tools: context.toolsStore.getToolsForChat(chatId).map((tool) => ({
4392
- name: tool.name,
4393
- description: tool.definition.description,
4394
- parameters: tool.definition.parameters
4395
- }))
4428
+ tools: tools.length > 0 ? tools : void 0
4396
4429
  }
4397
4430
  });
4431
+ messagesStore.markMine(resp.targetMessage.id);
4432
+ return resp;
4398
4433
  },
4399
4434
  abort: (messageId) => sendClientMsgWithResponse({ cmd: "abort-ai", messageId }),
4400
4435
  setToolResult,
@@ -4402,15 +4437,13 @@ function createAi(config) {
4402
4437
  signals: {
4403
4438
  chats\u03A3: context.chatsStore.chats\u03A3,
4404
4439
  getChatMessagesForBranch\u03A3: context.messagesStore.getChatMessagesForBranch\u03A3,
4405
- getChatById: context.chatsStore.getChatById,
4406
- getToolDefinition\u03A3: context.toolsStore.getToolDefinition\u03A3
4440
+ getTool\u03A3: context.toolsStore.getTool\u03A3
4407
4441
  },
4442
+ getChatById: context.chatsStore.getChatById,
4408
4443
  registerKnowledgeLayer,
4409
4444
  deregisterKnowledgeLayer,
4410
4445
  updateKnowledge,
4411
- debug_getAllKnowledge,
4412
- registerChatTool: context.toolsStore.addToolDefinition,
4413
- unregisterChatTool: context.toolsStore.removeToolDefinition
4446
+ registerTool: context.toolsStore.registerTool
4414
4447
  },
4415
4448
  kInternal,
4416
4449
  { enumerable: false }
@@ -4426,7 +4459,7 @@ function makeCreateSocketDelegateForAi(baseUrl, WebSocketPolyfill) {
4426
4459
  }
4427
4460
  const url2 = new URL(baseUrl);
4428
4461
  url2.protocol = url2.protocol === "http:" ? "ws" : "wss";
4429
- url2.pathname = "/ai/v1";
4462
+ url2.pathname = "/ai/v4";
4430
4463
  if (authValue.type === "secret") {
4431
4464
  url2.searchParams.set("tok", authValue.token.raw);
4432
4465
  } else if (authValue.type === "public") {
@@ -7743,7 +7776,7 @@ var LiveblocksError = class _LiveblocksError extends Error {
7743
7776
  get roomId() {
7744
7777
  return this.context.roomId;
7745
7778
  }
7746
- /** @deprecated Prefer using `context.code` instead, to enable type narrowing */
7779
+ /** @internal Use `context.code` instead, to enable type narrowing */
7747
7780
  get code() {
7748
7781
  return this.context.code;
7749
7782
  }
@@ -7813,11 +7846,9 @@ function defaultMessageFromContext(context) {
7813
7846
  return "Could not mark all inbox notifications as read";
7814
7847
  case "DELETE_ALL_INBOX_NOTIFICATIONS_ERROR":
7815
7848
  return "Could not delete all inbox notifications";
7816
- case "UPDATE_NOTIFICATION_SETTINGS_ERROR":
7817
- return "Could not update notification settings";
7818
7849
  case "UPDATE_ROOM_SUBSCRIPTION_SETTINGS_ERROR":
7819
7850
  return "Could not update room subscription settings";
7820
- case "UPDATE_USER_NOTIFICATION_SETTINGS_ERROR":
7851
+ case "UPDATE_NOTIFICATION_SETTINGS_ERROR":
7821
7852
  return "Could not update notification settings";
7822
7853
  default:
7823
7854
  return assertNever(context, "Unhandled case");
@@ -8950,8 +8981,6 @@ ${Array.from(traces).join("\n\n")}`
8950
8981
  others: eventHub.others.observable,
8951
8982
  self: eventHub.self.observable,
8952
8983
  myPresence: eventHub.myPresence.observable,
8953
- /** @deprecated */
8954
- storage: eventHub.storageBatch.observable,
8955
8984
  storageBatch: eventHub.storageBatch.observable,
8956
8985
  history: eventHub.history.observable,
8957
8986
  storageDidLoad: eventHub.storageDidLoad.observable,
@@ -9413,8 +9442,26 @@ function createClient(options) {
9413
9442
  baseUrl,
9414
9443
  clientOptions.polyfills?.WebSocket
9415
9444
  ),
9416
- authenticate: makeAuthDelegateForRoom("default", authManager),
9417
- canZombie: () => true
9445
+ authenticate: async () => {
9446
+ const resp = await authManager.getAuthValue({
9447
+ requestedScope: "room:read"
9448
+ });
9449
+ if (resp.type === "public") {
9450
+ throw new StopRetrying(
9451
+ "Cannot use AI Copilots with a public API key"
9452
+ );
9453
+ } else if (resp.token.parsed.k === "sec-legacy" /* SECRET_LEGACY */) {
9454
+ throw new StopRetrying("AI Copilots requires an ID or Access token");
9455
+ } else {
9456
+ if (!resp.token.parsed.ai) {
9457
+ throw new StopRetrying(
9458
+ "AI Copilots is not yet enabled for this account. To get started, see https://liveblocks.io/docs/get-started/ai-copilots#Quickstart"
9459
+ );
9460
+ }
9461
+ }
9462
+ return resp;
9463
+ },
9464
+ canZombie: () => false
9418
9465
  }
9419
9466
  });
9420
9467
  function teardownRoom(room) {
@@ -9468,7 +9515,7 @@ function createClient(options) {
9468
9515
  enableDebugLogging: clientOptions.enableDebugLogging,
9469
9516
  baseUrl,
9470
9517
  errorEventSource: liveblocksErrorSource,
9471
- largeMessageStrategy: clientOptions.largeMessageStrategy ?? (clientOptions.unstable_fallbackToHTTP ? "experimental-fallback-to-http" : void 0),
9518
+ largeMessageStrategy: clientOptions.largeMessageStrategy,
9472
9519
  unstable_streamData: !!clientOptions.unstable_streamData,
9473
9520
  roomHttpClient: httpClient,
9474
9521
  createSyncSource
@@ -9748,21 +9795,30 @@ function traverseCommentBody(body, elementOrVisitor, possiblyVisitor) {
9748
9795
  }
9749
9796
  }
9750
9797
  }
9751
- function getMentionedIdsFromCommentBody(body) {
9752
- const mentionedIds = /* @__PURE__ */ new Set();
9753
- traverseCommentBody(
9754
- body,
9755
- "mention",
9756
- (mention) => mentionedIds.add(mention.id)
9757
- );
9758
- return Array.from(mentionedIds);
9798
+ function getMentionsFromCommentBody(body, predicate) {
9799
+ const mentionIds = /* @__PURE__ */ new Set();
9800
+ const mentions = [];
9801
+ traverseCommentBody(body, "mention", (mention) => {
9802
+ if (
9803
+ // If this mention isn't already in the list
9804
+ !mentionIds.has(mention.id) && // And the provided predicate is true
9805
+ (predicate ? predicate(mention) : true)
9806
+ ) {
9807
+ mentionIds.add(mention.id);
9808
+ mentions.push(mention);
9809
+ }
9810
+ });
9811
+ return mentions;
9759
9812
  }
9760
9813
  async function resolveUsersInCommentBody(body, resolveUsers) {
9761
9814
  const resolvedUsers = /* @__PURE__ */ new Map();
9762
9815
  if (!resolveUsers) {
9763
9816
  return resolvedUsers;
9764
9817
  }
9765
- const userIds = getMentionedIdsFromCommentBody(body);
9818
+ const userIds = getMentionsFromCommentBody(
9819
+ body,
9820
+ (mention) => mention.kind === "user"
9821
+ ).map((mention) => mention.id);
9766
9822
  const users = await resolveUsers({
9767
9823
  userIds
9768
9824
  });
@@ -10525,11 +10581,8 @@ var TextEditorType = /* @__PURE__ */ ((TextEditorType2) => {
10525
10581
 
10526
10582
  // src/index.ts
10527
10583
  detectDupes(PKG_NAME, PKG_VERSION, PKG_FORMAT);
10528
- var CommentsApiError = HttpError;
10529
- var NotificationsApiError = HttpError;
10530
10584
  export {
10531
10585
  ClientMsgCode,
10532
- CommentsApiError,
10533
10586
  CrdtType,
10534
10587
  DefaultMap,
10535
10588
  Deque,
@@ -10540,7 +10593,6 @@ export {
10540
10593
  LiveObject,
10541
10594
  LiveblocksError,
10542
10595
  MutableSignal,
10543
- NotificationsApiError,
10544
10596
  OpCode,
10545
10597
  Permission,
10546
10598
  Promise_withResolvers,
@@ -10574,6 +10626,7 @@ export {
10574
10626
  createManagedPool,
10575
10627
  createNotificationSettings,
10576
10628
  createThreadId,
10629
+ defineAiTool,
10577
10630
  deprecate,
10578
10631
  deprecateIf,
10579
10632
  detectDupes,
@@ -10581,7 +10634,7 @@ export {
10581
10634
  errorIf,
10582
10635
  freeze,
10583
10636
  generateCommentUrl,
10584
- getMentionedIdsFromCommentBody,
10637
+ getMentionsFromCommentBody,
10585
10638
  getSubscriptionKey,
10586
10639
  html,
10587
10640
  htmlSafe,