@liveblocks/core 2.25.0-aiprivatebeta6 → 2.25.0-aiprivatebeta7
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.cjs +95 -94
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +10 -13
- package/dist/index.d.ts +10 -13
- package/dist/index.js +10 -9
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -3540,10 +3540,10 @@ type DefineCmd<CmdName extends string, TRequest, TResponse> = [
|
|
|
3540
3540
|
cmdId: CmdId;
|
|
3541
3541
|
} & TResponse>
|
|
3542
3542
|
];
|
|
3543
|
-
type CommandPair = GetChatsPair |
|
|
3543
|
+
type CommandPair = GetChatsPair | GetOrCreateChatPair | DeleteChatPair | GetMessageTreePair | DeleteMessagePair | ClearChatPair | AskInChatPair | AbortAiPair;
|
|
3544
3544
|
type ServerCmdResponse<T extends CommandPair = CommandPair> = T[1];
|
|
3545
3545
|
type GetChatsResponse = ServerCmdResponse<GetChatsPair>;
|
|
3546
|
-
type
|
|
3546
|
+
type GetOrCreateChatResponse = ServerCmdResponse<GetOrCreateChatPair>;
|
|
3547
3547
|
type DeleteChatResponse = ServerCmdResponse<DeleteChatPair>;
|
|
3548
3548
|
type GetMessageTreeResponse = ServerCmdResponse<GetMessageTreePair>;
|
|
3549
3549
|
type DeleteMessageResponse = ServerCmdResponse<DeleteMessagePair>;
|
|
@@ -3557,11 +3557,13 @@ type GetChatsPair = DefineCmd<"get-chats", {
|
|
|
3557
3557
|
chats: AiChat[];
|
|
3558
3558
|
nextCursor: Cursor | null;
|
|
3559
3559
|
}>;
|
|
3560
|
-
type
|
|
3561
|
-
id: ChatId;
|
|
3560
|
+
type CreateChatOptions = {
|
|
3562
3561
|
title?: string;
|
|
3563
|
-
|
|
3564
|
-
|
|
3562
|
+
metadata?: Record<string, string | string[]>;
|
|
3563
|
+
};
|
|
3564
|
+
type GetOrCreateChatPair = DefineCmd<"get-or-create-chat", {
|
|
3565
|
+
id: ChatId;
|
|
3566
|
+
options?: CreateChatOptions;
|
|
3565
3567
|
}, {
|
|
3566
3568
|
chat: AiChat;
|
|
3567
3569
|
}>;
|
|
@@ -3680,7 +3682,6 @@ type SettleServerEvent = {
|
|
|
3680
3682
|
type AiChat = {
|
|
3681
3683
|
id: ChatId;
|
|
3682
3684
|
title: string;
|
|
3683
|
-
ephemeral: boolean;
|
|
3684
3685
|
metadata: Record<string, string | string[]>;
|
|
3685
3686
|
createdAt: ISODateString;
|
|
3686
3687
|
lastMessageAt?: ISODateString;
|
|
@@ -3806,10 +3807,6 @@ type AiContext = {
|
|
|
3806
3807
|
messagesStore: ReturnType<typeof createStore_forChatMessages>;
|
|
3807
3808
|
knowledgeByChatId: Map<string, Set<AiKnowledgeSource>>;
|
|
3808
3809
|
};
|
|
3809
|
-
type CreateChatOptions = {
|
|
3810
|
-
ephemeral?: boolean;
|
|
3811
|
-
metadata?: AiChat["metadata"];
|
|
3812
|
-
};
|
|
3813
3810
|
type AskAiOptions = {
|
|
3814
3811
|
copilotId?: CopilotId;
|
|
3815
3812
|
stream?: boolean;
|
|
@@ -3860,11 +3857,11 @@ type Ai = {
|
|
|
3860
3857
|
cursor?: Cursor;
|
|
3861
3858
|
}) => Promise<GetChatsResponse>;
|
|
3862
3859
|
/** @private This AI will change, and is not considered stable. DO NOT RELY on it. */
|
|
3863
|
-
|
|
3860
|
+
getOrCreateChat: (
|
|
3864
3861
|
/** A unique identifier for the chat. */
|
|
3865
3862
|
chatId: string,
|
|
3866
3863
|
/** A human-friendly title for the chat. If not set, it will get auto-generated after the first response. */
|
|
3867
|
-
title?: string, options?: CreateChatOptions) => Promise<
|
|
3864
|
+
title?: string, options?: CreateChatOptions) => Promise<GetOrCreateChatResponse>;
|
|
3868
3865
|
/** @private This AI will change, and is not considered stable. DO NOT RELY on it. */
|
|
3869
3866
|
deleteChat: (chatId: string) => Promise<DeleteChatResponse>;
|
|
3870
3867
|
/** @private This AI will change, and is not considered stable. DO NOT RELY on it. */
|
package/dist/index.d.ts
CHANGED
|
@@ -3540,10 +3540,10 @@ type DefineCmd<CmdName extends string, TRequest, TResponse> = [
|
|
|
3540
3540
|
cmdId: CmdId;
|
|
3541
3541
|
} & TResponse>
|
|
3542
3542
|
];
|
|
3543
|
-
type CommandPair = GetChatsPair |
|
|
3543
|
+
type CommandPair = GetChatsPair | GetOrCreateChatPair | DeleteChatPair | GetMessageTreePair | DeleteMessagePair | ClearChatPair | AskInChatPair | AbortAiPair;
|
|
3544
3544
|
type ServerCmdResponse<T extends CommandPair = CommandPair> = T[1];
|
|
3545
3545
|
type GetChatsResponse = ServerCmdResponse<GetChatsPair>;
|
|
3546
|
-
type
|
|
3546
|
+
type GetOrCreateChatResponse = ServerCmdResponse<GetOrCreateChatPair>;
|
|
3547
3547
|
type DeleteChatResponse = ServerCmdResponse<DeleteChatPair>;
|
|
3548
3548
|
type GetMessageTreeResponse = ServerCmdResponse<GetMessageTreePair>;
|
|
3549
3549
|
type DeleteMessageResponse = ServerCmdResponse<DeleteMessagePair>;
|
|
@@ -3557,11 +3557,13 @@ type GetChatsPair = DefineCmd<"get-chats", {
|
|
|
3557
3557
|
chats: AiChat[];
|
|
3558
3558
|
nextCursor: Cursor | null;
|
|
3559
3559
|
}>;
|
|
3560
|
-
type
|
|
3561
|
-
id: ChatId;
|
|
3560
|
+
type CreateChatOptions = {
|
|
3562
3561
|
title?: string;
|
|
3563
|
-
|
|
3564
|
-
|
|
3562
|
+
metadata?: Record<string, string | string[]>;
|
|
3563
|
+
};
|
|
3564
|
+
type GetOrCreateChatPair = DefineCmd<"get-or-create-chat", {
|
|
3565
|
+
id: ChatId;
|
|
3566
|
+
options?: CreateChatOptions;
|
|
3565
3567
|
}, {
|
|
3566
3568
|
chat: AiChat;
|
|
3567
3569
|
}>;
|
|
@@ -3680,7 +3682,6 @@ type SettleServerEvent = {
|
|
|
3680
3682
|
type AiChat = {
|
|
3681
3683
|
id: ChatId;
|
|
3682
3684
|
title: string;
|
|
3683
|
-
ephemeral: boolean;
|
|
3684
3685
|
metadata: Record<string, string | string[]>;
|
|
3685
3686
|
createdAt: ISODateString;
|
|
3686
3687
|
lastMessageAt?: ISODateString;
|
|
@@ -3806,10 +3807,6 @@ type AiContext = {
|
|
|
3806
3807
|
messagesStore: ReturnType<typeof createStore_forChatMessages>;
|
|
3807
3808
|
knowledgeByChatId: Map<string, Set<AiKnowledgeSource>>;
|
|
3808
3809
|
};
|
|
3809
|
-
type CreateChatOptions = {
|
|
3810
|
-
ephemeral?: boolean;
|
|
3811
|
-
metadata?: AiChat["metadata"];
|
|
3812
|
-
};
|
|
3813
3810
|
type AskAiOptions = {
|
|
3814
3811
|
copilotId?: CopilotId;
|
|
3815
3812
|
stream?: boolean;
|
|
@@ -3860,11 +3857,11 @@ type Ai = {
|
|
|
3860
3857
|
cursor?: Cursor;
|
|
3861
3858
|
}) => Promise<GetChatsResponse>;
|
|
3862
3859
|
/** @private This AI will change, and is not considered stable. DO NOT RELY on it. */
|
|
3863
|
-
|
|
3860
|
+
getOrCreateChat: (
|
|
3864
3861
|
/** A unique identifier for the chat. */
|
|
3865
3862
|
chatId: string,
|
|
3866
3863
|
/** A human-friendly title for the chat. If not set, it will get auto-generated after the first response. */
|
|
3867
|
-
title?: string, options?: CreateChatOptions) => Promise<
|
|
3864
|
+
title?: string, options?: CreateChatOptions) => Promise<GetOrCreateChatResponse>;
|
|
3868
3865
|
/** @private This AI will change, and is not considered stable. DO NOT RELY on it. */
|
|
3869
3866
|
deleteChat: (chatId: string) => Promise<DeleteChatResponse>;
|
|
3870
3867
|
/** @private This AI will change, and is not considered stable. DO NOT RELY on it. */
|
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-
|
|
9
|
+
var PKG_VERSION = "2.25.0-aiprivatebeta7";
|
|
10
10
|
var PKG_FORMAT = "esm";
|
|
11
11
|
|
|
12
12
|
// src/dupe-detection.ts
|
|
@@ -3999,7 +3999,7 @@ function createStore_forUserAiChats() {
|
|
|
3999
3999
|
SortedList.with((x, y) => y.createdAt < x.createdAt)
|
|
4000
4000
|
);
|
|
4001
4001
|
const chats\u03A3 = DerivedSignal.from(
|
|
4002
|
-
() => Array.from(mutable\u03A3.get()).filter((c) => !c.
|
|
4002
|
+
() => Array.from(mutable\u03A3.get()).filter((c) => !c.deletedAt)
|
|
4003
4003
|
);
|
|
4004
4004
|
function upsertMany(chats) {
|
|
4005
4005
|
mutable\u03A3.mutate((list) => {
|
|
@@ -4143,7 +4143,7 @@ function createAi(config) {
|
|
|
4143
4143
|
case "get-chats":
|
|
4144
4144
|
context.chatsStore.upsertMany(msg.chats);
|
|
4145
4145
|
break;
|
|
4146
|
-
case "create-chat":
|
|
4146
|
+
case "get-or-create-chat":
|
|
4147
4147
|
context.chatsStore.upsert(msg.chat);
|
|
4148
4148
|
break;
|
|
4149
4149
|
case "delete-chat":
|
|
@@ -4218,13 +4218,14 @@ function createAi(config) {
|
|
|
4218
4218
|
cursor: options.cursor
|
|
4219
4219
|
});
|
|
4220
4220
|
}
|
|
4221
|
-
function
|
|
4221
|
+
function getOrCreateChat(id, title, options) {
|
|
4222
4222
|
return sendClientMsgWithResponse({
|
|
4223
|
-
cmd: "create-chat",
|
|
4223
|
+
cmd: "get-or-create-chat",
|
|
4224
4224
|
id,
|
|
4225
|
-
|
|
4226
|
-
|
|
4227
|
-
|
|
4225
|
+
options: {
|
|
4226
|
+
title,
|
|
4227
|
+
metadata: options?.metadata
|
|
4228
|
+
}
|
|
4228
4229
|
});
|
|
4229
4230
|
}
|
|
4230
4231
|
function getMessageTree(chatId) {
|
|
@@ -4288,7 +4289,7 @@ function createAi(config) {
|
|
|
4288
4289
|
reconnect: () => managedSocket.reconnect(),
|
|
4289
4290
|
disconnect: () => managedSocket.disconnect(),
|
|
4290
4291
|
getChats,
|
|
4291
|
-
|
|
4292
|
+
getOrCreateChat,
|
|
4292
4293
|
deleteChat: (chatId) => {
|
|
4293
4294
|
return sendClientMsgWithResponse({
|
|
4294
4295
|
cmd: "delete-chat",
|