@liveblocks/core 3.4.0 → 3.4.1

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.d.cts CHANGED
@@ -3824,6 +3824,7 @@ type AiGeneratingAssistantMessage = {
3824
3824
  role: "assistant";
3825
3825
  createdAt: ISODateString;
3826
3826
  deletedAt?: ISODateString;
3827
+ copilotId?: CopilotId;
3827
3828
  status: "generating";
3828
3829
  contentSoFar: AiAssistantContentPart[];
3829
3830
  };
@@ -3834,6 +3835,7 @@ type AiAwaitingToolAssistantMessage = {
3834
3835
  role: "assistant";
3835
3836
  createdAt: ISODateString;
3836
3837
  deletedAt?: ISODateString;
3838
+ copilotId?: CopilotId;
3837
3839
  status: "awaiting-tool";
3838
3840
  contentSoFar: AiAssistantContentPart[];
3839
3841
  };
@@ -3845,6 +3847,7 @@ type AiCompletedAssistantMessage = {
3845
3847
  content: AiAssistantContentPart[];
3846
3848
  createdAt: ISODateString;
3847
3849
  deletedAt?: ISODateString;
3850
+ copilotId?: CopilotId;
3848
3851
  status: "completed";
3849
3852
  };
3850
3853
  type AiFailedAssistantMessage = {
@@ -3854,6 +3857,7 @@ type AiFailedAssistantMessage = {
3854
3857
  role: "assistant";
3855
3858
  createdAt: ISODateString;
3856
3859
  deletedAt?: ISODateString;
3860
+ copilotId?: CopilotId;
3857
3861
  status: "failed";
3858
3862
  contentSoFar: AiAssistantContentPart[];
3859
3863
  errorReason: string;
@@ -4020,9 +4024,10 @@ declare function createStore_forTools(): {
4020
4024
  declare function createStore_forChatMessages(toolsStore: ReturnType<typeof createStore_forTools>, setToolResultFn: (chatId: string, messageId: MessageId, invocationId: string, result: ToolResultResponse, options?: SetToolResultOptions) => Promise<void>): {
4021
4025
  getMessageById: (messageId: MessageId) => AiChatMessage | undefined;
4022
4026
  getChatMessagesForBranchΣ: (chatId: string, branch?: MessageId) => DerivedSignal<UiChatMessage[]>;
4027
+ getLastUsedCopilotId: (chatId: string) => CopilotId | undefined;
4023
4028
  createOptimistically: {
4024
4029
  (chatId: string, role: "user", parentId: MessageId | null, content: AiUserContentPart[]): MessageId;
4025
- (chatId: string, role: "assistant", parentId: MessageId | null): MessageId;
4030
+ (chatId: string, role: "assistant", parentId: MessageId | null, copilotId?: CopilotId): MessageId;
4026
4031
  };
4027
4032
  upsert: (message: AiChatMessage) => void;
4028
4033
  upsertMany: (messages: AiChatMessage[]) => void;
@@ -4081,6 +4086,8 @@ type Ai = {
4081
4086
  /** @private This API will change, and is not considered stable. DO NOT RELY on it. */
4082
4087
  queryChats: (query: AiChatsQuery) => AiChat[];
4083
4088
  /** @private This API will change, and is not considered stable. DO NOT RELY on it. */
4089
+ getLastUsedCopilotId: (chatId: string) => CopilotId | undefined;
4090
+ /** @private This API will change, and is not considered stable. DO NOT RELY on it. */
4084
4091
  registerKnowledgeLayer: (uniqueLayerId: string) => LayerKey;
4085
4092
  /** @private This API will change, and is not considered stable. DO NOT RELY on it. */
4086
4093
  deregisterKnowledgeLayer: (layerKey: LayerKey) => void;
package/dist/index.d.ts CHANGED
@@ -3824,6 +3824,7 @@ type AiGeneratingAssistantMessage = {
3824
3824
  role: "assistant";
3825
3825
  createdAt: ISODateString;
3826
3826
  deletedAt?: ISODateString;
3827
+ copilotId?: CopilotId;
3827
3828
  status: "generating";
3828
3829
  contentSoFar: AiAssistantContentPart[];
3829
3830
  };
@@ -3834,6 +3835,7 @@ type AiAwaitingToolAssistantMessage = {
3834
3835
  role: "assistant";
3835
3836
  createdAt: ISODateString;
3836
3837
  deletedAt?: ISODateString;
3838
+ copilotId?: CopilotId;
3837
3839
  status: "awaiting-tool";
3838
3840
  contentSoFar: AiAssistantContentPart[];
3839
3841
  };
@@ -3845,6 +3847,7 @@ type AiCompletedAssistantMessage = {
3845
3847
  content: AiAssistantContentPart[];
3846
3848
  createdAt: ISODateString;
3847
3849
  deletedAt?: ISODateString;
3850
+ copilotId?: CopilotId;
3848
3851
  status: "completed";
3849
3852
  };
3850
3853
  type AiFailedAssistantMessage = {
@@ -3854,6 +3857,7 @@ type AiFailedAssistantMessage = {
3854
3857
  role: "assistant";
3855
3858
  createdAt: ISODateString;
3856
3859
  deletedAt?: ISODateString;
3860
+ copilotId?: CopilotId;
3857
3861
  status: "failed";
3858
3862
  contentSoFar: AiAssistantContentPart[];
3859
3863
  errorReason: string;
@@ -4020,9 +4024,10 @@ declare function createStore_forTools(): {
4020
4024
  declare function createStore_forChatMessages(toolsStore: ReturnType<typeof createStore_forTools>, setToolResultFn: (chatId: string, messageId: MessageId, invocationId: string, result: ToolResultResponse, options?: SetToolResultOptions) => Promise<void>): {
4021
4025
  getMessageById: (messageId: MessageId) => AiChatMessage | undefined;
4022
4026
  getChatMessagesForBranchΣ: (chatId: string, branch?: MessageId) => DerivedSignal<UiChatMessage[]>;
4027
+ getLastUsedCopilotId: (chatId: string) => CopilotId | undefined;
4023
4028
  createOptimistically: {
4024
4029
  (chatId: string, role: "user", parentId: MessageId | null, content: AiUserContentPart[]): MessageId;
4025
- (chatId: string, role: "assistant", parentId: MessageId | null): MessageId;
4030
+ (chatId: string, role: "assistant", parentId: MessageId | null, copilotId?: CopilotId): MessageId;
4026
4031
  };
4027
4032
  upsert: (message: AiChatMessage) => void;
4028
4033
  upsertMany: (messages: AiChatMessage[]) => void;
@@ -4081,6 +4086,8 @@ type Ai = {
4081
4086
  /** @private This API will change, and is not considered stable. DO NOT RELY on it. */
4082
4087
  queryChats: (query: AiChatsQuery) => AiChat[];
4083
4088
  /** @private This API will change, and is not considered stable. DO NOT RELY on it. */
4089
+ getLastUsedCopilotId: (chatId: string) => CopilotId | undefined;
4090
+ /** @private This API will change, and is not considered stable. DO NOT RELY on it. */
4084
4091
  registerKnowledgeLayer: (uniqueLayerId: string) => LayerKey;
4085
4092
  /** @private This API will change, and is not considered stable. DO NOT RELY on it. */
4086
4093
  deregisterKnowledgeLayer: (layerKey: LayerKey) => void;
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 = "3.4.0";
9
+ var PKG_VERSION = "3.4.1";
10
10
  var PKG_FORMAT = "esm";
11
11
 
12
12
  // src/dupe-detection.ts
@@ -4129,6 +4129,7 @@ function createStore_forChatMessages(toolsStore, setToolResultFn) {
4129
4129
  _optimistic: true
4130
4130
  });
4131
4131
  } else {
4132
+ const copilotId = third;
4132
4133
  upsert({
4133
4134
  id,
4134
4135
  chatId,
@@ -4137,6 +4138,7 @@ function createStore_forChatMessages(toolsStore, setToolResultFn) {
4137
4138
  createdAt,
4138
4139
  status: "generating",
4139
4140
  contentSoFar: [],
4141
+ copilotId,
4140
4142
  _optimistic: true
4141
4143
  });
4142
4144
  }
@@ -4199,8 +4201,9 @@ function createStore_forChatMessages(toolsStore, setToolResultFn) {
4199
4201
  message.chatId,
4200
4202
  message.id,
4201
4203
  toolInvocation.invocationId,
4202
- result ?? { data: {} }
4203
- // TODO Pass in AiGenerationOptions here, or make the backend use the same options
4204
+ result ?? { data: {} },
4205
+ { copilotId: message.copilotId }
4206
+ // TODO: Should we pass the other generation options (tools, knowledge) as well?
4204
4207
  );
4205
4208
  })().catch((err) => {
4206
4209
  error2(
@@ -4348,10 +4351,18 @@ function createStore_forChatMessages(toolsStore, setToolResultFn) {
4348
4351
  function getChatMessagesForBranch\u03A3(chatId, branch) {
4349
4352
  return immutableMessagesByBranch.getOrCreate(chatId).getOrCreate(branch || null);
4350
4353
  }
4354
+ function getLastUsedCopilotId(chatId) {
4355
+ const pool = messagePoolByChatId\u03A3.getOrCreate(chatId).get();
4356
+ const latest = pool.sorted.findRight(
4357
+ (m) => m.role === "assistant" && !m.deletedAt
4358
+ );
4359
+ return latest?.copilotId;
4360
+ }
4351
4361
  return {
4352
4362
  // Readers
4353
4363
  getMessageById,
4354
4364
  getChatMessagesForBranch\u03A3,
4365
+ getLastUsedCopilotId,
4355
4366
  // Mutations
4356
4367
  createOptimistically,
4357
4368
  upsert,
@@ -4453,7 +4464,6 @@ function createAi(config) {
4453
4464
  function onDidConnect() {
4454
4465
  }
4455
4466
  function onDidDisconnect() {
4456
- warn("onDidDisconnect");
4457
4467
  }
4458
4468
  function handleServerMessage(event) {
4459
4469
  if (typeof event.data !== "string")
@@ -4697,6 +4707,7 @@ function createAi(config) {
4697
4707
  },
4698
4708
  getChatById: context.chatsStore.getChatById,
4699
4709
  queryChats: context.chatsStore.findMany,
4710
+ getLastUsedCopilotId: context.messagesStore.getLastUsedCopilotId,
4700
4711
  registerKnowledgeLayer,
4701
4712
  deregisterKnowledgeLayer,
4702
4713
  updateKnowledge,