@liveblocks/core 3.5.2 → 3.5.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.
package/dist/index.d.cts CHANGED
@@ -3449,6 +3449,7 @@ declare const brand: unique symbol;
3449
3449
  type Brand<T, TBrand extends string> = T & {
3450
3450
  [brand]: TBrand;
3451
3451
  };
3452
+ type ISODateString = Brand<string, "ISODateString">;
3452
3453
  type DistributiveOmit<T, K extends PropertyKey> = T extends any ? Omit<T, K> : never;
3453
3454
  type WithRequired<T, K extends keyof T> = T & {
3454
3455
  [P in K]-?: T[P];
@@ -3519,7 +3520,6 @@ declare function memoizeOnSuccess<T>(factoryFn: () => Promise<T>): () => Promise
3519
3520
  declare function findLastIndex<T>(arr: T[], predicate: (value: T, index: number, obj: T[]) => boolean): number;
3520
3521
 
3521
3522
  type Cursor = Brand<string, "Cursor">;
3522
- type ISODateString = Brand<string, "ISODateString">;
3523
3523
  type ChatId = string;
3524
3524
  type MessageId = Brand<`ms_${string}`, "MessageId">;
3525
3525
  type CmdId = Brand<string, "CmdId">;
@@ -3796,6 +3796,8 @@ type AiToolInvocationDelta = {
3796
3796
  type AiReasoningPart = {
3797
3797
  type: "reasoning";
3798
3798
  text: string;
3799
+ startedAt: ISODateString;
3800
+ endedAt?: ISODateString;
3799
3801
  };
3800
3802
  type AiUploadedImagePart = {
3801
3803
  type: "image";
@@ -3804,9 +3806,21 @@ type AiUploadedImagePart = {
3804
3806
  size: number;
3805
3807
  mimeType: string;
3806
3808
  };
3809
+ /**
3810
+ * Represents a pending or completed knowledge retrieval operation.
3811
+ * Since protocol V6.
3812
+ */
3813
+ type AiRetrievalPart = {
3814
+ type: "retrieval";
3815
+ kind: "knowledge";
3816
+ id: string;
3817
+ query: string;
3818
+ startedAt: ISODateString;
3819
+ endedAt?: ISODateString;
3820
+ };
3807
3821
  type AiUserContentPart = AiTextPart | AiUploadedImagePart;
3808
- type AiAssistantContentPart = AiReasoningPart | AiTextPart | AiToolInvocationPart;
3809
- type AiAssistantDeltaUpdate = AiTextDelta | AiReasoningDelta | AiExecutingToolInvocationPart | AiToolInvocationStreamStart | AiToolInvocationDelta;
3822
+ type AiAssistantContentPart = AiReasoningPart | AiTextPart | AiToolInvocationPart | AiRetrievalPart;
3823
+ type AiAssistantDeltaUpdate = AiTextDelta | AiReasoningDelta | AiExecutingToolInvocationPart | AiToolInvocationStreamStart | AiToolInvocationDelta | AiRetrievalPart;
3810
3824
  type AiUserMessage = {
3811
3825
  id: MessageId;
3812
3826
  chatId: ChatId;
@@ -4036,6 +4050,17 @@ declare function createStore_forChatMessages(toolsStore: ReturnType<typeof creat
4036
4050
  addDelta: (messageId: MessageId, delta: AiAssistantDeltaUpdate) => void;
4037
4051
  failAllPending: () => void;
4038
4052
  markMine(messageId: MessageId): void;
4053
+ /**
4054
+ * Iterates over all my auto-executing messages.
4055
+ *
4056
+ * These are messages that match all these conditions:
4057
+ * - The message is an assistant message
4058
+ * - The message is owned by this client ("mine")
4059
+ * - The message is currently in "awaiting-tool" status
4060
+ * - The message has at least one tool invocation in "executing" stage
4061
+ * - The tool invocation has an execute() function defined
4062
+ */
4063
+ getAutoExecutingMessageIds(): Iterable<MessageId>;
4039
4064
  };
4040
4065
  declare function createStore_forUserAiChats(): {
4041
4066
  getChatById: (chatId: string) => AiChat | undefined;
@@ -4889,4 +4914,4 @@ type EnsureJson<T> = T extends Json ? T : T extends Array<infer I> ? (EnsureJson
4889
4914
  [K in keyof T as EnsureJson<T[K]> extends never ? never : K]: EnsureJson<T[K]>;
4890
4915
  };
4891
4916
 
4892
- export { type AckOp, type ActivityData, type AiAssistantContentPart, type AiAssistantMessage, type AiChat, type AiChatMessage, type AiChatsQuery, type AiKnowledgeSource, type AiOpaqueToolDefinition, type AiOpaqueToolInvocationProps, type AiReasoningPart, type AiTextPart, type AiToolDefinition, type AiToolExecuteCallback, type AiToolExecuteContext, type AiToolInvocationPart, type AiToolInvocationProps, type AiToolTypePack, type AiUserMessage, type AsyncError, type AsyncLoading, type AsyncResult, type AsyncSuccess, type Awaitable, type BaseActivitiesData, type BaseAuthResult, type BaseMetadata, type BaseRoomInfo, type BaseUserMeta, type Brand, type BroadcastEventClientMsg, type BroadcastOptions, type BroadcastedEventServerMsg, type Client, type ClientMsg, ClientMsgCode, type ClientOptions, type CommentAttachment, type CommentBody, type CommentBodyBlockElement, type CommentBodyElement, type CommentBodyInlineElement, type CommentBodyLink, type CommentBodyLinkElementArgs, type CommentBodyMention, type CommentBodyMentionElementArgs, type CommentBodyParagraph, type CommentBodyParagraphElementArgs, type CommentBodyText, type CommentBodyTextElementArgs, type CommentData, type CommentDataPlain, type CommentLocalAttachment, type CommentMixedAttachment, type CommentReaction, type CommentUserReaction, type CommentUserReactionPlain, type CommentsEventServerMsg, type ContextualPromptContext, type ContextualPromptResponse, type CopilotId, CrdtType, type CreateListOp, type CreateManagedPoolOptions, type CreateMapOp, type CreateObjectOp, type CreateOp, type CreateRegisterOp, type Cursor, type CustomAuthenticationResult, type DAD, type DE, type DM, type DP, type DRI, type DS, type DU, DefaultMap, type Delegates, type DeleteCrdtOp, type DeleteObjectKeyOp, Deque, DerivedSignal, DevToolsTreeNode as DevTools, protocol as DevToolsMsg, type DistributiveOmit, type EnsureJson, type EnterOptions, type EventSource, type FetchStorageClientMsg, type FetchYDocClientMsg, type GetThreadsOptions, type History, type HistoryVersion, HttpError, type ISignal, type IUserInfo, type IWebSocket, type IWebSocketCloseEvent, type IWebSocketEvent, type IWebSocketInstance, type IWebSocketMessageEvent, type IYjsProvider, type IdTuple, type Immutable, type InboxNotificationCustomData, type InboxNotificationCustomDataPlain, type InboxNotificationData, type InboxNotificationDataPlain, type InboxNotificationDeleteInfo, type InboxNotificationTextMentionData, type InboxNotificationTextMentionDataPlain, type InboxNotificationThreadData, type InboxNotificationThreadDataPlain, type InferFromSchema, type InitialDocumentStateServerMsg, type Json, type JsonArray, type JsonObject, type JsonScalar, type KDAD, type LargeMessageStrategy, LiveList, type LiveListUpdate, LiveMap, type LiveMapUpdate, type LiveNode, LiveObject, type LiveObjectUpdate, type LiveStructure, LiveblocksError, type LiveblocksErrorContext, type LostConnectionEvent, type Lson, type LsonObject, type ManagedPool, type MentionData, type MessageId, MutableSignal, type NoInfr, type NodeMap, type NotificationChannel, type NotificationChannelSettings, type NotificationKind, type NotificationSettings, type NotificationSettingsPlain, type Observable, type Op, OpCode, type OpaqueClient, type OpaqueRoom, type OptionalTupleUnless, type OthersEvent, type ParentToChildNodeMap, type PartialNotificationSettings, type PartialUnless, type Patchable, Permission, type PlainLson, type PlainLsonFields, type PlainLsonList, type PlainLsonMap, type PlainLsonObject, type Poller, type PrivateClientApi, type PrivateRoomApi, Promise_withResolvers, type QueryMetadata, type QueryParams, type RejectedStorageOpServerMsg, type Relax, type RenderableToolResultResponse, type Resolve, type ResolveMentionSuggestionsArgs, type ResolveRoomsInfoArgs, type ResolveUsersArgs, type Room, type RoomEventMessage, type RoomStateServerMsg, type RoomSubscriptionSettings, type SerializedChild, type SerializedCrdt, type SerializedList, type SerializedMap, type SerializedObject, type SerializedRegister, type SerializedRootObject, type ServerMsg, ServerMsgCode, type SetParentKeyOp, Signal, type SignalType, SortedList, type Status, type StorageStatus, type StorageUpdate, type StringifyCommentBodyElements, type StringifyCommentBodyOptions, type SubscriptionData, type SubscriptionDataPlain, type SubscriptionDeleteInfo, type SubscriptionDeleteInfoPlain, type SubscriptionKey, type SyncSource, type SyncStatus, TextEditorType, type ThreadData, type ThreadDataPlain, type ThreadDataWithDeleteInfo, type ThreadDeleteInfo, type ToImmutable, type ToJson, type ToolResultResponse, type URLSafeString, type UnsubscribeCallback, type UpdateObjectOp, type UpdatePresenceClientMsg, type UpdatePresenceServerMsg, type UpdateStorageClientMsg, type UpdateStorageServerMsg, type UpdateYDocClientMsg, type UploadAttachmentOptions, type User, type UserJoinServerMsg, type UserLeftServerMsg, type UserMentionData, type UserRoomSubscriptionSettings, type UserSubscriptionData, type UserSubscriptionDataPlain, WebsocketCloseCodes, type WithNavigation, type WithOptional, type WithRequired, type YDocUpdateServerMsg, type YjsSyncStatus, ackOp, asPos, assert, assertNever, autoRetry, b64decode, batch, checkBounds, chunk, cloneLson, compactObject, fancyConsole as console, convertToCommentData, convertToCommentUserReaction, convertToInboxNotificationData, convertToSubscriptionData, convertToThreadData, convertToUserSubscriptionData, createClient, createCommentAttachmentId, createCommentId, createInboxNotificationId, createManagedPool, createNotificationSettings, createThreadId, defineAiTool, deprecate, deprecateIf, detectDupes, entries, errorIf, findLastIndex, freeze, generateUrl, getMentionsFromCommentBody, getSubscriptionKey, html, htmlSafe, isChildCrdt, isCommentBodyLink, isCommentBodyMention, isCommentBodyText, isJsonArray, isJsonObject, isJsonScalar, isLiveNode, isNotificationChannelEnabled, isPlainObject, isRootCrdt, isStartsWithOperator, isUrl, kInternal, keys, legacy_patchImmutableObject, lsonToJson, makeAbortController, makeEventSource, makePoller, makePosition, mapValues, memoizeOnSuccess, nanoid, nn, objectToQuery, patchLiveObjectKey, patchNotificationSettings, raise, resolveUsersInCommentBody, sanitizeUrl, shallow, shallow2, stableStringify, stringifyCommentBody, throwUsageError, toPlainLson, tryParseJson, url, urljoin, wait, withTimeout };
4917
+ export { type AckOp, type ActivityData, type AiAssistantContentPart, type AiAssistantMessage, type AiChat, type AiChatMessage, type AiChatsQuery, type AiKnowledgeSource, type AiOpaqueToolDefinition, type AiOpaqueToolInvocationProps, type AiReasoningPart, type AiRetrievalPart, type AiTextPart, type AiToolDefinition, type AiToolExecuteCallback, type AiToolExecuteContext, type AiToolInvocationPart, type AiToolInvocationProps, type AiToolTypePack, type AiUserMessage, type AsyncError, type AsyncLoading, type AsyncResult, type AsyncSuccess, type Awaitable, type BaseActivitiesData, type BaseAuthResult, type BaseMetadata, type BaseRoomInfo, type BaseUserMeta, type Brand, type BroadcastEventClientMsg, type BroadcastOptions, type BroadcastedEventServerMsg, type Client, type ClientMsg, ClientMsgCode, type ClientOptions, type CommentAttachment, type CommentBody, type CommentBodyBlockElement, type CommentBodyElement, type CommentBodyInlineElement, type CommentBodyLink, type CommentBodyLinkElementArgs, type CommentBodyMention, type CommentBodyMentionElementArgs, type CommentBodyParagraph, type CommentBodyParagraphElementArgs, type CommentBodyText, type CommentBodyTextElementArgs, type CommentData, type CommentDataPlain, type CommentLocalAttachment, type CommentMixedAttachment, type CommentReaction, type CommentUserReaction, type CommentUserReactionPlain, type CommentsEventServerMsg, type ContextualPromptContext, type ContextualPromptResponse, type CopilotId, CrdtType, type CreateListOp, type CreateManagedPoolOptions, type CreateMapOp, type CreateObjectOp, type CreateOp, type CreateRegisterOp, type Cursor, type CustomAuthenticationResult, type DAD, type DE, type DM, type DP, type DRI, type DS, type DU, DefaultMap, type Delegates, type DeleteCrdtOp, type DeleteObjectKeyOp, Deque, DerivedSignal, DevToolsTreeNode as DevTools, protocol as DevToolsMsg, type DistributiveOmit, type EnsureJson, type EnterOptions, type EventSource, type FetchStorageClientMsg, type FetchYDocClientMsg, type GetThreadsOptions, type History, type HistoryVersion, HttpError, type ISignal, type IUserInfo, type IWebSocket, type IWebSocketCloseEvent, type IWebSocketEvent, type IWebSocketInstance, type IWebSocketMessageEvent, type IYjsProvider, type IdTuple, type Immutable, type InboxNotificationCustomData, type InboxNotificationCustomDataPlain, type InboxNotificationData, type InboxNotificationDataPlain, type InboxNotificationDeleteInfo, type InboxNotificationTextMentionData, type InboxNotificationTextMentionDataPlain, type InboxNotificationThreadData, type InboxNotificationThreadDataPlain, type InferFromSchema, type InitialDocumentStateServerMsg, type Json, type JsonArray, type JsonObject, type JsonScalar, type KDAD, type LargeMessageStrategy, LiveList, type LiveListUpdate, LiveMap, type LiveMapUpdate, type LiveNode, LiveObject, type LiveObjectUpdate, type LiveStructure, LiveblocksError, type LiveblocksErrorContext, type LostConnectionEvent, type Lson, type LsonObject, type ManagedPool, type MentionData, type MessageId, MutableSignal, type NoInfr, type NodeMap, type NotificationChannel, type NotificationChannelSettings, type NotificationKind, type NotificationSettings, type NotificationSettingsPlain, type Observable, type Op, OpCode, type OpaqueClient, type OpaqueRoom, type OptionalTupleUnless, type OthersEvent, type ParentToChildNodeMap, type PartialNotificationSettings, type PartialUnless, type Patchable, Permission, type PlainLson, type PlainLsonFields, type PlainLsonList, type PlainLsonMap, type PlainLsonObject, type Poller, type PrivateClientApi, type PrivateRoomApi, Promise_withResolvers, type QueryMetadata, type QueryParams, type RejectedStorageOpServerMsg, type Relax, type RenderableToolResultResponse, type Resolve, type ResolveMentionSuggestionsArgs, type ResolveRoomsInfoArgs, type ResolveUsersArgs, type Room, type RoomEventMessage, type RoomStateServerMsg, type RoomSubscriptionSettings, type SerializedChild, type SerializedCrdt, type SerializedList, type SerializedMap, type SerializedObject, type SerializedRegister, type SerializedRootObject, type ServerMsg, ServerMsgCode, type SetParentKeyOp, Signal, type SignalType, SortedList, type Status, type StorageStatus, type StorageUpdate, type StringifyCommentBodyElements, type StringifyCommentBodyOptions, type SubscriptionData, type SubscriptionDataPlain, type SubscriptionDeleteInfo, type SubscriptionDeleteInfoPlain, type SubscriptionKey, type SyncSource, type SyncStatus, TextEditorType, type ThreadData, type ThreadDataPlain, type ThreadDataWithDeleteInfo, type ThreadDeleteInfo, type ToImmutable, type ToJson, type ToolResultResponse, type URLSafeString, type UnsubscribeCallback, type UpdateObjectOp, type UpdatePresenceClientMsg, type UpdatePresenceServerMsg, type UpdateStorageClientMsg, type UpdateStorageServerMsg, type UpdateYDocClientMsg, type UploadAttachmentOptions, type User, type UserJoinServerMsg, type UserLeftServerMsg, type UserMentionData, type UserRoomSubscriptionSettings, type UserSubscriptionData, type UserSubscriptionDataPlain, WebsocketCloseCodes, type WithNavigation, type WithOptional, type WithRequired, type YDocUpdateServerMsg, type YjsSyncStatus, ackOp, asPos, assert, assertNever, autoRetry, b64decode, batch, checkBounds, chunk, cloneLson, compactObject, fancyConsole as console, convertToCommentData, convertToCommentUserReaction, convertToInboxNotificationData, convertToSubscriptionData, convertToThreadData, convertToUserSubscriptionData, createClient, createCommentAttachmentId, createCommentId, createInboxNotificationId, createManagedPool, createNotificationSettings, createThreadId, defineAiTool, deprecate, deprecateIf, detectDupes, entries, errorIf, findLastIndex, freeze, generateUrl, getMentionsFromCommentBody, getSubscriptionKey, html, htmlSafe, isChildCrdt, isCommentBodyLink, isCommentBodyMention, isCommentBodyText, isJsonArray, isJsonObject, isJsonScalar, isLiveNode, isNotificationChannelEnabled, isPlainObject, isRootCrdt, isStartsWithOperator, isUrl, kInternal, keys, legacy_patchImmutableObject, lsonToJson, makeAbortController, makeEventSource, makePoller, makePosition, mapValues, memoizeOnSuccess, nanoid, nn, objectToQuery, patchLiveObjectKey, patchNotificationSettings, raise, resolveUsersInCommentBody, sanitizeUrl, shallow, shallow2, stableStringify, stringifyCommentBody, throwUsageError, toPlainLson, tryParseJson, url, urljoin, wait, withTimeout };
package/dist/index.d.ts CHANGED
@@ -3449,6 +3449,7 @@ declare const brand: unique symbol;
3449
3449
  type Brand<T, TBrand extends string> = T & {
3450
3450
  [brand]: TBrand;
3451
3451
  };
3452
+ type ISODateString = Brand<string, "ISODateString">;
3452
3453
  type DistributiveOmit<T, K extends PropertyKey> = T extends any ? Omit<T, K> : never;
3453
3454
  type WithRequired<T, K extends keyof T> = T & {
3454
3455
  [P in K]-?: T[P];
@@ -3519,7 +3520,6 @@ declare function memoizeOnSuccess<T>(factoryFn: () => Promise<T>): () => Promise
3519
3520
  declare function findLastIndex<T>(arr: T[], predicate: (value: T, index: number, obj: T[]) => boolean): number;
3520
3521
 
3521
3522
  type Cursor = Brand<string, "Cursor">;
3522
- type ISODateString = Brand<string, "ISODateString">;
3523
3523
  type ChatId = string;
3524
3524
  type MessageId = Brand<`ms_${string}`, "MessageId">;
3525
3525
  type CmdId = Brand<string, "CmdId">;
@@ -3796,6 +3796,8 @@ type AiToolInvocationDelta = {
3796
3796
  type AiReasoningPart = {
3797
3797
  type: "reasoning";
3798
3798
  text: string;
3799
+ startedAt: ISODateString;
3800
+ endedAt?: ISODateString;
3799
3801
  };
3800
3802
  type AiUploadedImagePart = {
3801
3803
  type: "image";
@@ -3804,9 +3806,21 @@ type AiUploadedImagePart = {
3804
3806
  size: number;
3805
3807
  mimeType: string;
3806
3808
  };
3809
+ /**
3810
+ * Represents a pending or completed knowledge retrieval operation.
3811
+ * Since protocol V6.
3812
+ */
3813
+ type AiRetrievalPart = {
3814
+ type: "retrieval";
3815
+ kind: "knowledge";
3816
+ id: string;
3817
+ query: string;
3818
+ startedAt: ISODateString;
3819
+ endedAt?: ISODateString;
3820
+ };
3807
3821
  type AiUserContentPart = AiTextPart | AiUploadedImagePart;
3808
- type AiAssistantContentPart = AiReasoningPart | AiTextPart | AiToolInvocationPart;
3809
- type AiAssistantDeltaUpdate = AiTextDelta | AiReasoningDelta | AiExecutingToolInvocationPart | AiToolInvocationStreamStart | AiToolInvocationDelta;
3822
+ type AiAssistantContentPart = AiReasoningPart | AiTextPart | AiToolInvocationPart | AiRetrievalPart;
3823
+ type AiAssistantDeltaUpdate = AiTextDelta | AiReasoningDelta | AiExecutingToolInvocationPart | AiToolInvocationStreamStart | AiToolInvocationDelta | AiRetrievalPart;
3810
3824
  type AiUserMessage = {
3811
3825
  id: MessageId;
3812
3826
  chatId: ChatId;
@@ -4036,6 +4050,17 @@ declare function createStore_forChatMessages(toolsStore: ReturnType<typeof creat
4036
4050
  addDelta: (messageId: MessageId, delta: AiAssistantDeltaUpdate) => void;
4037
4051
  failAllPending: () => void;
4038
4052
  markMine(messageId: MessageId): void;
4053
+ /**
4054
+ * Iterates over all my auto-executing messages.
4055
+ *
4056
+ * These are messages that match all these conditions:
4057
+ * - The message is an assistant message
4058
+ * - The message is owned by this client ("mine")
4059
+ * - The message is currently in "awaiting-tool" status
4060
+ * - The message has at least one tool invocation in "executing" stage
4061
+ * - The tool invocation has an execute() function defined
4062
+ */
4063
+ getAutoExecutingMessageIds(): Iterable<MessageId>;
4039
4064
  };
4040
4065
  declare function createStore_forUserAiChats(): {
4041
4066
  getChatById: (chatId: string) => AiChat | undefined;
@@ -4889,4 +4914,4 @@ type EnsureJson<T> = T extends Json ? T : T extends Array<infer I> ? (EnsureJson
4889
4914
  [K in keyof T as EnsureJson<T[K]> extends never ? never : K]: EnsureJson<T[K]>;
4890
4915
  };
4891
4916
 
4892
- export { type AckOp, type ActivityData, type AiAssistantContentPart, type AiAssistantMessage, type AiChat, type AiChatMessage, type AiChatsQuery, type AiKnowledgeSource, type AiOpaqueToolDefinition, type AiOpaqueToolInvocationProps, type AiReasoningPart, type AiTextPart, type AiToolDefinition, type AiToolExecuteCallback, type AiToolExecuteContext, type AiToolInvocationPart, type AiToolInvocationProps, type AiToolTypePack, type AiUserMessage, type AsyncError, type AsyncLoading, type AsyncResult, type AsyncSuccess, type Awaitable, type BaseActivitiesData, type BaseAuthResult, type BaseMetadata, type BaseRoomInfo, type BaseUserMeta, type Brand, type BroadcastEventClientMsg, type BroadcastOptions, type BroadcastedEventServerMsg, type Client, type ClientMsg, ClientMsgCode, type ClientOptions, type CommentAttachment, type CommentBody, type CommentBodyBlockElement, type CommentBodyElement, type CommentBodyInlineElement, type CommentBodyLink, type CommentBodyLinkElementArgs, type CommentBodyMention, type CommentBodyMentionElementArgs, type CommentBodyParagraph, type CommentBodyParagraphElementArgs, type CommentBodyText, type CommentBodyTextElementArgs, type CommentData, type CommentDataPlain, type CommentLocalAttachment, type CommentMixedAttachment, type CommentReaction, type CommentUserReaction, type CommentUserReactionPlain, type CommentsEventServerMsg, type ContextualPromptContext, type ContextualPromptResponse, type CopilotId, CrdtType, type CreateListOp, type CreateManagedPoolOptions, type CreateMapOp, type CreateObjectOp, type CreateOp, type CreateRegisterOp, type Cursor, type CustomAuthenticationResult, type DAD, type DE, type DM, type DP, type DRI, type DS, type DU, DefaultMap, type Delegates, type DeleteCrdtOp, type DeleteObjectKeyOp, Deque, DerivedSignal, DevToolsTreeNode as DevTools, protocol as DevToolsMsg, type DistributiveOmit, type EnsureJson, type EnterOptions, type EventSource, type FetchStorageClientMsg, type FetchYDocClientMsg, type GetThreadsOptions, type History, type HistoryVersion, HttpError, type ISignal, type IUserInfo, type IWebSocket, type IWebSocketCloseEvent, type IWebSocketEvent, type IWebSocketInstance, type IWebSocketMessageEvent, type IYjsProvider, type IdTuple, type Immutable, type InboxNotificationCustomData, type InboxNotificationCustomDataPlain, type InboxNotificationData, type InboxNotificationDataPlain, type InboxNotificationDeleteInfo, type InboxNotificationTextMentionData, type InboxNotificationTextMentionDataPlain, type InboxNotificationThreadData, type InboxNotificationThreadDataPlain, type InferFromSchema, type InitialDocumentStateServerMsg, type Json, type JsonArray, type JsonObject, type JsonScalar, type KDAD, type LargeMessageStrategy, LiveList, type LiveListUpdate, LiveMap, type LiveMapUpdate, type LiveNode, LiveObject, type LiveObjectUpdate, type LiveStructure, LiveblocksError, type LiveblocksErrorContext, type LostConnectionEvent, type Lson, type LsonObject, type ManagedPool, type MentionData, type MessageId, MutableSignal, type NoInfr, type NodeMap, type NotificationChannel, type NotificationChannelSettings, type NotificationKind, type NotificationSettings, type NotificationSettingsPlain, type Observable, type Op, OpCode, type OpaqueClient, type OpaqueRoom, type OptionalTupleUnless, type OthersEvent, type ParentToChildNodeMap, type PartialNotificationSettings, type PartialUnless, type Patchable, Permission, type PlainLson, type PlainLsonFields, type PlainLsonList, type PlainLsonMap, type PlainLsonObject, type Poller, type PrivateClientApi, type PrivateRoomApi, Promise_withResolvers, type QueryMetadata, type QueryParams, type RejectedStorageOpServerMsg, type Relax, type RenderableToolResultResponse, type Resolve, type ResolveMentionSuggestionsArgs, type ResolveRoomsInfoArgs, type ResolveUsersArgs, type Room, type RoomEventMessage, type RoomStateServerMsg, type RoomSubscriptionSettings, type SerializedChild, type SerializedCrdt, type SerializedList, type SerializedMap, type SerializedObject, type SerializedRegister, type SerializedRootObject, type ServerMsg, ServerMsgCode, type SetParentKeyOp, Signal, type SignalType, SortedList, type Status, type StorageStatus, type StorageUpdate, type StringifyCommentBodyElements, type StringifyCommentBodyOptions, type SubscriptionData, type SubscriptionDataPlain, type SubscriptionDeleteInfo, type SubscriptionDeleteInfoPlain, type SubscriptionKey, type SyncSource, type SyncStatus, TextEditorType, type ThreadData, type ThreadDataPlain, type ThreadDataWithDeleteInfo, type ThreadDeleteInfo, type ToImmutable, type ToJson, type ToolResultResponse, type URLSafeString, type UnsubscribeCallback, type UpdateObjectOp, type UpdatePresenceClientMsg, type UpdatePresenceServerMsg, type UpdateStorageClientMsg, type UpdateStorageServerMsg, type UpdateYDocClientMsg, type UploadAttachmentOptions, type User, type UserJoinServerMsg, type UserLeftServerMsg, type UserMentionData, type UserRoomSubscriptionSettings, type UserSubscriptionData, type UserSubscriptionDataPlain, WebsocketCloseCodes, type WithNavigation, type WithOptional, type WithRequired, type YDocUpdateServerMsg, type YjsSyncStatus, ackOp, asPos, assert, assertNever, autoRetry, b64decode, batch, checkBounds, chunk, cloneLson, compactObject, fancyConsole as console, convertToCommentData, convertToCommentUserReaction, convertToInboxNotificationData, convertToSubscriptionData, convertToThreadData, convertToUserSubscriptionData, createClient, createCommentAttachmentId, createCommentId, createInboxNotificationId, createManagedPool, createNotificationSettings, createThreadId, defineAiTool, deprecate, deprecateIf, detectDupes, entries, errorIf, findLastIndex, freeze, generateUrl, getMentionsFromCommentBody, getSubscriptionKey, html, htmlSafe, isChildCrdt, isCommentBodyLink, isCommentBodyMention, isCommentBodyText, isJsonArray, isJsonObject, isJsonScalar, isLiveNode, isNotificationChannelEnabled, isPlainObject, isRootCrdt, isStartsWithOperator, isUrl, kInternal, keys, legacy_patchImmutableObject, lsonToJson, makeAbortController, makeEventSource, makePoller, makePosition, mapValues, memoizeOnSuccess, nanoid, nn, objectToQuery, patchLiveObjectKey, patchNotificationSettings, raise, resolveUsersInCommentBody, sanitizeUrl, shallow, shallow2, stableStringify, stringifyCommentBody, throwUsageError, toPlainLson, tryParseJson, url, urljoin, wait, withTimeout };
4917
+ export { type AckOp, type ActivityData, type AiAssistantContentPart, type AiAssistantMessage, type AiChat, type AiChatMessage, type AiChatsQuery, type AiKnowledgeSource, type AiOpaqueToolDefinition, type AiOpaqueToolInvocationProps, type AiReasoningPart, type AiRetrievalPart, type AiTextPart, type AiToolDefinition, type AiToolExecuteCallback, type AiToolExecuteContext, type AiToolInvocationPart, type AiToolInvocationProps, type AiToolTypePack, type AiUserMessage, type AsyncError, type AsyncLoading, type AsyncResult, type AsyncSuccess, type Awaitable, type BaseActivitiesData, type BaseAuthResult, type BaseMetadata, type BaseRoomInfo, type BaseUserMeta, type Brand, type BroadcastEventClientMsg, type BroadcastOptions, type BroadcastedEventServerMsg, type Client, type ClientMsg, ClientMsgCode, type ClientOptions, type CommentAttachment, type CommentBody, type CommentBodyBlockElement, type CommentBodyElement, type CommentBodyInlineElement, type CommentBodyLink, type CommentBodyLinkElementArgs, type CommentBodyMention, type CommentBodyMentionElementArgs, type CommentBodyParagraph, type CommentBodyParagraphElementArgs, type CommentBodyText, type CommentBodyTextElementArgs, type CommentData, type CommentDataPlain, type CommentLocalAttachment, type CommentMixedAttachment, type CommentReaction, type CommentUserReaction, type CommentUserReactionPlain, type CommentsEventServerMsg, type ContextualPromptContext, type ContextualPromptResponse, type CopilotId, CrdtType, type CreateListOp, type CreateManagedPoolOptions, type CreateMapOp, type CreateObjectOp, type CreateOp, type CreateRegisterOp, type Cursor, type CustomAuthenticationResult, type DAD, type DE, type DM, type DP, type DRI, type DS, type DU, DefaultMap, type Delegates, type DeleteCrdtOp, type DeleteObjectKeyOp, Deque, DerivedSignal, DevToolsTreeNode as DevTools, protocol as DevToolsMsg, type DistributiveOmit, type EnsureJson, type EnterOptions, type EventSource, type FetchStorageClientMsg, type FetchYDocClientMsg, type GetThreadsOptions, type History, type HistoryVersion, HttpError, type ISignal, type IUserInfo, type IWebSocket, type IWebSocketCloseEvent, type IWebSocketEvent, type IWebSocketInstance, type IWebSocketMessageEvent, type IYjsProvider, type IdTuple, type Immutable, type InboxNotificationCustomData, type InboxNotificationCustomDataPlain, type InboxNotificationData, type InboxNotificationDataPlain, type InboxNotificationDeleteInfo, type InboxNotificationTextMentionData, type InboxNotificationTextMentionDataPlain, type InboxNotificationThreadData, type InboxNotificationThreadDataPlain, type InferFromSchema, type InitialDocumentStateServerMsg, type Json, type JsonArray, type JsonObject, type JsonScalar, type KDAD, type LargeMessageStrategy, LiveList, type LiveListUpdate, LiveMap, type LiveMapUpdate, type LiveNode, LiveObject, type LiveObjectUpdate, type LiveStructure, LiveblocksError, type LiveblocksErrorContext, type LostConnectionEvent, type Lson, type LsonObject, type ManagedPool, type MentionData, type MessageId, MutableSignal, type NoInfr, type NodeMap, type NotificationChannel, type NotificationChannelSettings, type NotificationKind, type NotificationSettings, type NotificationSettingsPlain, type Observable, type Op, OpCode, type OpaqueClient, type OpaqueRoom, type OptionalTupleUnless, type OthersEvent, type ParentToChildNodeMap, type PartialNotificationSettings, type PartialUnless, type Patchable, Permission, type PlainLson, type PlainLsonFields, type PlainLsonList, type PlainLsonMap, type PlainLsonObject, type Poller, type PrivateClientApi, type PrivateRoomApi, Promise_withResolvers, type QueryMetadata, type QueryParams, type RejectedStorageOpServerMsg, type Relax, type RenderableToolResultResponse, type Resolve, type ResolveMentionSuggestionsArgs, type ResolveRoomsInfoArgs, type ResolveUsersArgs, type Room, type RoomEventMessage, type RoomStateServerMsg, type RoomSubscriptionSettings, type SerializedChild, type SerializedCrdt, type SerializedList, type SerializedMap, type SerializedObject, type SerializedRegister, type SerializedRootObject, type ServerMsg, ServerMsgCode, type SetParentKeyOp, Signal, type SignalType, SortedList, type Status, type StorageStatus, type StorageUpdate, type StringifyCommentBodyElements, type StringifyCommentBodyOptions, type SubscriptionData, type SubscriptionDataPlain, type SubscriptionDeleteInfo, type SubscriptionDeleteInfoPlain, type SubscriptionKey, type SyncSource, type SyncStatus, TextEditorType, type ThreadData, type ThreadDataPlain, type ThreadDataWithDeleteInfo, type ThreadDeleteInfo, type ToImmutable, type ToJson, type ToolResultResponse, type URLSafeString, type UnsubscribeCallback, type UpdateObjectOp, type UpdatePresenceClientMsg, type UpdatePresenceServerMsg, type UpdateStorageClientMsg, type UpdateStorageServerMsg, type UpdateYDocClientMsg, type UploadAttachmentOptions, type User, type UserJoinServerMsg, type UserLeftServerMsg, type UserMentionData, type UserRoomSubscriptionSettings, type UserSubscriptionData, type UserSubscriptionDataPlain, WebsocketCloseCodes, type WithNavigation, type WithOptional, type WithRequired, type YDocUpdateServerMsg, type YjsSyncStatus, ackOp, asPos, assert, assertNever, autoRetry, b64decode, batch, checkBounds, chunk, cloneLson, compactObject, fancyConsole as console, convertToCommentData, convertToCommentUserReaction, convertToInboxNotificationData, convertToSubscriptionData, convertToThreadData, convertToUserSubscriptionData, createClient, createCommentAttachmentId, createCommentId, createInboxNotificationId, createManagedPool, createNotificationSettings, createThreadId, defineAiTool, deprecate, deprecateIf, detectDupes, entries, errorIf, findLastIndex, freeze, generateUrl, getMentionsFromCommentBody, getSubscriptionKey, html, htmlSafe, isChildCrdt, isCommentBodyLink, isCommentBodyMention, isCommentBodyText, isJsonArray, isJsonObject, isJsonScalar, isLiveNode, isNotificationChannelEnabled, isPlainObject, isRootCrdt, isStartsWithOperator, isUrl, kInternal, keys, legacy_patchImmutableObject, lsonToJson, makeAbortController, makeEventSource, makePoller, makePosition, mapValues, memoizeOnSuccess, nanoid, nn, objectToQuery, patchLiveObjectKey, patchNotificationSettings, raise, resolveUsersInCommentBody, sanitizeUrl, shallow, shallow2, stableStringify, stringifyCommentBody, throwUsageError, toPlainLson, tryParseJson, url, urljoin, wait, withTimeout };
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.5.2";
9
+ var PKG_VERSION = "3.5.3";
10
10
  var PKG_FORMAT = "esm";
11
11
 
12
12
  // src/dupe-detection.ts
@@ -3987,13 +3987,34 @@ var IncrementalJsonParser = class {
3987
3987
  };
3988
3988
 
3989
3989
  // src/types/ai.ts
3990
+ function replaceOrAppend(content, newItem, keyFn, now2) {
3991
+ const existingIndex = findLastIndex(
3992
+ content,
3993
+ (item) => item.type === newItem.type && keyFn(item) === keyFn(newItem)
3994
+ );
3995
+ if (existingIndex > -1) {
3996
+ content[existingIndex] = newItem;
3997
+ } else {
3998
+ closePart(content[content.length - 1], now2);
3999
+ content.push(newItem);
4000
+ }
4001
+ }
4002
+ function closePart(prevPart, endedAt) {
4003
+ if (prevPart?.type === "reasoning") {
4004
+ prevPart.endedAt ??= endedAt;
4005
+ }
4006
+ }
3990
4007
  function patchContentWithDelta(content, delta) {
4008
+ if (delta === null)
4009
+ return;
4010
+ const now2 = (/* @__PURE__ */ new Date()).toISOString();
3991
4011
  const lastPart = content[content.length - 1];
3992
4012
  switch (delta.type) {
3993
4013
  case "text-delta":
3994
4014
  if (lastPart?.type === "text") {
3995
4015
  lastPart.text += delta.textDelta;
3996
4016
  } else {
4017
+ closePart(lastPart, now2);
3997
4018
  content.push({ type: "text", text: delta.textDelta });
3998
4019
  }
3999
4020
  break;
@@ -4001,9 +4022,11 @@ function patchContentWithDelta(content, delta) {
4001
4022
  if (lastPart?.type === "reasoning") {
4002
4023
  lastPart.text += delta.textDelta;
4003
4024
  } else {
4025
+ closePart(lastPart, now2);
4004
4026
  content.push({
4005
4027
  type: "reasoning",
4006
- text: delta.textDelta ?? ""
4028
+ text: delta.textDelta ?? "",
4029
+ startedAt: now2
4007
4030
  });
4008
4031
  }
4009
4032
  break;
@@ -4021,18 +4044,12 @@ function patchContentWithDelta(content, delta) {
4021
4044
  }
4022
4045
  break;
4023
4046
  }
4024
- case "tool-invocation": {
4025
- const existingIndex = findLastIndex(
4026
- content,
4027
- (part) => part.type === "tool-invocation" && part.invocationId === delta.invocationId
4028
- );
4029
- if (existingIndex > -1) {
4030
- content[existingIndex] = delta;
4031
- } else {
4032
- content.push(delta);
4033
- }
4047
+ case "tool-invocation":
4048
+ replaceOrAppend(content, delta, (x) => x.invocationId, now2);
4049
+ break;
4050
+ case "retrieval":
4051
+ replaceOrAppend(content, delta, (x) => x.id, now2);
4034
4052
  break;
4035
- }
4036
4053
  default:
4037
4054
  return assertNever(delta, "Unhandled case");
4038
4055
  }
@@ -4044,16 +4061,20 @@ function createReceivingToolInvocation(invocationId, name, partialArgsText = "")
4044
4061
  stage: "receiving",
4045
4062
  invocationId,
4046
4063
  name,
4064
+ // --- Alternative implementation for FRONTEND only ------------------------
4047
4065
  get partialArgsText() {
4048
4066
  return parser.source;
4049
4067
  },
4068
+ // prettier-ignore
4050
4069
  get partialArgs() {
4051
4070
  return parser.json;
4052
4071
  },
4053
- // Internal method to append deltas
4072
+ // prettier-ignore
4054
4073
  __appendDelta(delta) {
4055
4074
  parser.append(delta);
4056
4075
  }
4076
+ // prettier-ignore
4077
+ // ------------------------------------------------------------------------
4057
4078
  };
4058
4079
  }
4059
4080
 
@@ -4455,6 +4476,33 @@ function createStore_forChatMessages(toolsStore, setToolResultFn) {
4455
4476
  failAllPending,
4456
4477
  markMine(messageId) {
4457
4478
  myMessages.add(messageId);
4479
+ },
4480
+ /**
4481
+ * Iterates over all my auto-executing messages.
4482
+ *
4483
+ * These are messages that match all these conditions:
4484
+ * - The message is an assistant message
4485
+ * - The message is owned by this client ("mine")
4486
+ * - The message is currently in "awaiting-tool" status
4487
+ * - The message has at least one tool invocation in "executing" stage
4488
+ * - The tool invocation has an execute() function defined
4489
+ */
4490
+ *getAutoExecutingMessageIds() {
4491
+ for (const messageId of myMessages) {
4492
+ const message = getMessageById(messageId);
4493
+ if (message?.role === "assistant" && message.status === "awaiting-tool") {
4494
+ const isAutoExecuting = message.contentSoFar.some((part) => {
4495
+ if (part.type === "tool-invocation" && part.stage === "executing") {
4496
+ const tool = toolsStore.getTool\u03A3(part.name, message.chatId).get();
4497
+ return typeof tool?.execute === "function";
4498
+ }
4499
+ return false;
4500
+ });
4501
+ if (isAutoExecuting) {
4502
+ yield message.id;
4503
+ }
4504
+ }
4505
+ }
4458
4506
  }
4459
4507
  };
4460
4508
  }
@@ -4766,6 +4814,14 @@ function createAi(config) {
4766
4814
  messagesStore.markMine(resp.message.id);
4767
4815
  }
4768
4816
  }
4817
+ function handleBeforeUnload() {
4818
+ for (const messageId of context.messagesStore.getAutoExecutingMessageIds()) {
4819
+ sendClientMsgWithResponse({ cmd: "abort-ai", messageId }).catch(() => {
4820
+ });
4821
+ }
4822
+ }
4823
+ const win = typeof window !== "undefined" ? window : void 0;
4824
+ win?.addEventListener("beforeunload", handleBeforeUnload, { once: true });
4769
4825
  return Object.defineProperty(
4770
4826
  {
4771
4827
  [kInternal]: {
@@ -4833,7 +4889,7 @@ function makeCreateSocketDelegateForAi(baseUrl, WebSocketPolyfill) {
4833
4889
  }
4834
4890
  const url2 = new URL(baseUrl);
4835
4891
  url2.protocol = url2.protocol === "http:" ? "ws" : "wss";
4836
- url2.pathname = "/ai/v5";
4892
+ url2.pathname = "/ai/v6";
4837
4893
  if (authValue.type === "secret") {
4838
4894
  url2.searchParams.set("tok", authValue.token.raw);
4839
4895
  } else if (authValue.type === "public") {