@liveblocks/core 2.17.0-usrnotsettings3 → 2.18.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.d.mts +45 -7
- package/dist/index.d.ts +45 -7
- package/dist/index.js +104 -13
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +104 -13
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1127,6 +1127,22 @@ type BatchStore<O, I> = {
|
|
|
1127
1127
|
invalidate: (inputs?: I[]) => void;
|
|
1128
1128
|
};
|
|
1129
1129
|
|
|
1130
|
+
type ContextualPromptResponse = Relax<{
|
|
1131
|
+
type: "insert";
|
|
1132
|
+
text: string;
|
|
1133
|
+
} | {
|
|
1134
|
+
type: "replace";
|
|
1135
|
+
text: string;
|
|
1136
|
+
} | {
|
|
1137
|
+
type: "other";
|
|
1138
|
+
text: string;
|
|
1139
|
+
}>;
|
|
1140
|
+
type ContextualPromptContext = {
|
|
1141
|
+
beforeSelection: string;
|
|
1142
|
+
selection: string;
|
|
1143
|
+
afterSelection: string;
|
|
1144
|
+
};
|
|
1145
|
+
|
|
1130
1146
|
declare enum ClientMsgCode {
|
|
1131
1147
|
UPDATE_PRESENCE = 100,
|
|
1132
1148
|
BROADCAST_EVENT = 103,
|
|
@@ -2406,6 +2422,15 @@ type PrivateRoomApi = {
|
|
|
2406
2422
|
}>;
|
|
2407
2423
|
getTextVersion(versionId: string): Promise<Response>;
|
|
2408
2424
|
createTextVersion(): Promise<void>;
|
|
2425
|
+
executeContextualPrompt(options: {
|
|
2426
|
+
prompt: string;
|
|
2427
|
+
context: ContextualPromptContext;
|
|
2428
|
+
previous?: {
|
|
2429
|
+
prompt: string;
|
|
2430
|
+
response: ContextualPromptResponse;
|
|
2431
|
+
};
|
|
2432
|
+
signal: AbortSignal;
|
|
2433
|
+
}): Promise<string>;
|
|
2409
2434
|
simulate: {
|
|
2410
2435
|
explicitClose(event: IWebSocketCloseEvent): void;
|
|
2411
2436
|
rawSend(data: string): void;
|
|
@@ -2443,6 +2468,7 @@ type PartialUnless<C, T> = Record<string, never> extends C ? Partial<T> : [
|
|
|
2443
2468
|
type OptionalTupleUnless<C, T extends any[]> = Record<string, never> extends C ? OptionalTuple<T> : [
|
|
2444
2469
|
C
|
|
2445
2470
|
] extends [never] ? OptionalTuple<T> : T;
|
|
2471
|
+
type LargeMessageStrategy = "default" | "split" | "experimental-fallback-to-http";
|
|
2446
2472
|
|
|
2447
2473
|
/**
|
|
2448
2474
|
* Pre-defined notification channels support list.
|
|
@@ -2668,6 +2694,16 @@ interface RoomHttpApi<M extends BaseMetadata> {
|
|
|
2668
2694
|
nonce: string | undefined;
|
|
2669
2695
|
messages: ClientMsg<P, E>[];
|
|
2670
2696
|
}): Promise<Response>;
|
|
2697
|
+
executeContextualPrompt({ roomId, prompt, context, signal, }: {
|
|
2698
|
+
roomId: string;
|
|
2699
|
+
prompt: string;
|
|
2700
|
+
context: ContextualPromptContext;
|
|
2701
|
+
previous?: {
|
|
2702
|
+
prompt: string;
|
|
2703
|
+
response: ContextualPromptResponse;
|
|
2704
|
+
};
|
|
2705
|
+
signal: AbortSignal;
|
|
2706
|
+
}): Promise<string>;
|
|
2671
2707
|
}
|
|
2672
2708
|
interface NotificationHttpApi<M extends BaseMetadata> {
|
|
2673
2709
|
getInboxNotifications(options?: {
|
|
@@ -2821,7 +2857,7 @@ declare class MutableSignal<T extends object> extends AbstractSignal<T> {
|
|
|
2821
2857
|
mutate(callback?: (state: T) => void | boolean): void;
|
|
2822
2858
|
}
|
|
2823
2859
|
|
|
2824
|
-
type
|
|
2860
|
+
type Awaitable<T> = T | PromiseLike<T>;
|
|
2825
2861
|
|
|
2826
2862
|
type ResolveMentionSuggestionsArgs = {
|
|
2827
2863
|
/**
|
|
@@ -3123,22 +3159,24 @@ type ClientOptions<U extends BaseUserMeta = DU> = {
|
|
|
3123
3159
|
lostConnectionTimeout?: number;
|
|
3124
3160
|
backgroundKeepAliveTimeout?: number;
|
|
3125
3161
|
polyfills?: Polyfills;
|
|
3162
|
+
largeMessageStrategy?: LargeMessageStrategy;
|
|
3163
|
+
/** @deprecated Use `largeMessageStrategy="experimental-fallback-to-http"` instead. */
|
|
3126
3164
|
unstable_fallbackToHTTP?: boolean;
|
|
3127
3165
|
unstable_streamData?: boolean;
|
|
3128
3166
|
/**
|
|
3129
3167
|
* A function that returns a list of user IDs matching a string.
|
|
3130
3168
|
*/
|
|
3131
|
-
resolveMentionSuggestions?: (args: ResolveMentionSuggestionsArgs) =>
|
|
3169
|
+
resolveMentionSuggestions?: (args: ResolveMentionSuggestionsArgs) => Awaitable<string[]>;
|
|
3132
3170
|
/**
|
|
3133
3171
|
* A function that returns user info from user IDs.
|
|
3134
3172
|
* You should return a list of user objects of the same size, in the same order.
|
|
3135
3173
|
*/
|
|
3136
|
-
resolveUsers?: (args: ResolveUsersArgs) =>
|
|
3174
|
+
resolveUsers?: (args: ResolveUsersArgs) => Awaitable<(U["info"] | undefined)[] | undefined>;
|
|
3137
3175
|
/**
|
|
3138
3176
|
* A function that returns room info from room IDs.
|
|
3139
3177
|
* You should return a list of room info objects of the same size, in the same order.
|
|
3140
3178
|
*/
|
|
3141
|
-
resolveRoomsInfo?: (args: ResolveRoomsInfoArgs) =>
|
|
3179
|
+
resolveRoomsInfo?: (args: ResolveRoomsInfoArgs) => Awaitable<(DRI | undefined)[] | undefined>;
|
|
3142
3180
|
/**
|
|
3143
3181
|
* Prevent the current browser tab from being closed if there are any locally
|
|
3144
3182
|
* pending Liveblocks changes that haven't been submitted to or confirmed by
|
|
@@ -3249,7 +3287,7 @@ type StringifyCommentBodyOptions<U extends BaseUserMeta = DU> = {
|
|
|
3249
3287
|
* A function that returns user info from user IDs.
|
|
3250
3288
|
* You should return a list of user objects of the same size, in the same order.
|
|
3251
3289
|
*/
|
|
3252
|
-
resolveUsers?: (args: ResolveUsersArgs) =>
|
|
3290
|
+
resolveUsers?: (args: ResolveUsersArgs) => Awaitable<(U["info"] | undefined)[] | undefined>;
|
|
3253
3291
|
};
|
|
3254
3292
|
declare function isCommentBodyText(element: CommentBodyElement): element is CommentBodyText;
|
|
3255
3293
|
declare function isCommentBodyMention(element: CommentBodyElement): element is CommentBodyMention;
|
|
@@ -3258,7 +3296,7 @@ declare function isCommentBodyLink(element: CommentBodyElement): element is Comm
|
|
|
3258
3296
|
* Get an array of each user's ID that has been mentioned in a `CommentBody`.
|
|
3259
3297
|
*/
|
|
3260
3298
|
declare function getMentionedIdsFromCommentBody(body: CommentBody): string[];
|
|
3261
|
-
declare function resolveUsersInCommentBody<U extends BaseUserMeta>(body: CommentBody, resolveUsers?: (args: ResolveUsersArgs) =>
|
|
3299
|
+
declare function resolveUsersInCommentBody<U extends BaseUserMeta>(body: CommentBody, resolveUsers?: (args: ResolveUsersArgs) => Awaitable<(U["info"] | undefined)[] | undefined>): Promise<Map<string, U["info"]>>;
|
|
3262
3300
|
declare function htmlSafe(value: string): HtmlSafeString;
|
|
3263
3301
|
declare class HtmlSafeString {
|
|
3264
3302
|
#private;
|
|
@@ -3928,4 +3966,4 @@ declare const CommentsApiError: typeof HttpError;
|
|
|
3928
3966
|
/** @deprecated Use HttpError instead. */
|
|
3929
3967
|
declare const NotificationsApiError: typeof HttpError;
|
|
3930
3968
|
|
|
3931
|
-
export { type AckOp, type ActivityData, type AsyncError, type AsyncLoading, type AsyncResult, type AsyncSuccess, 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, CommentsApiError, type CommentsEventServerMsg, CrdtType, type CreateListOp, type CreateMapOp, type CreateObjectOp, type CreateOp, type CreateRegisterOp, type CustomAuthenticationResult, type DAD, type DE, type DM, type DP, type DRI, type DS, type DU, DefaultMap, type Delegates, type DeleteCrdtOp, type DeleteObjectKeyOp, 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 InitialDocumentStateServerMsg, type Json, type JsonArray, type JsonObject, type JsonScalar, type KDAD, LiveList, type LiveListUpdate, LiveMap, type LiveMapUpdate, type LiveNode, LiveObject, type LiveObjectUpdate, type LiveStructure, LiveblocksError, type LiveblocksErrorContext, type LostConnectionEvent, type Lson, type LsonObject, MutableSignal, type NoInfr, type NodeMap, type NotificationChannel, type NotificationChannelSettings, type NotificationKind, NotificationsApiError, type Observable, type Op, OpCode, type OpaqueClient, type OpaqueRoom, type
|
|
3969
|
+
export { type AckOp, type ActivityData, 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, CommentsApiError, type CommentsEventServerMsg, type ContextualPromptContext, type ContextualPromptResponse, CrdtType, type CreateListOp, type CreateMapOp, type CreateObjectOp, type CreateOp, type CreateRegisterOp, type CustomAuthenticationResult, type DAD, type DE, type DM, type DP, type DRI, type DS, type DU, DefaultMap, type Delegates, type DeleteCrdtOp, type DeleteObjectKeyOp, 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 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, MutableSignal, type NoInfr, type NodeMap, type NotificationChannel, type NotificationChannelSettings, type NotificationKind, NotificationsApiError, type Observable, type Op, OpCode, type OpaqueClient, type OpaqueRoom, type OptionalTupleUnless, type OthersEvent, type ParentToChildNodeMap, type PartialUnless, type PartialUserNotificationSettings, 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 Resolve, type ResolveMentionSuggestionsArgs, type ResolveRoomsInfoArgs, type ResolveUsersArgs, type Room, type RoomEventMessage, type RoomNotificationSettings, type RoomStateServerMsg, 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 SyncSource, type SyncStatus, TextEditorType, type ThreadData, type ThreadDataPlain, type ThreadDataWithDeleteInfo, type ThreadDeleteInfo, type ToImmutable, type ToJson, 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 UserNotificationSettings, WebsocketCloseCodes, type YDocUpdateServerMsg, type YjsSyncStatus, ackOp, asPos, assert, assertNever, autoRetry, b64decode, batch, chunk, cloneLson, compactObject, fancyConsole as console, convertToCommentData, convertToCommentUserReaction, convertToInboxNotificationData, convertToThreadData, createClient, createCommentAttachmentId, createCommentId, createInboxNotificationId, createThreadId, deprecate, deprecateIf, detectDupes, entries, errorIf, freeze, generateCommentUrl, getMentionedIdsFromCommentBody, html, htmlSafe, isChildCrdt, isCommentBodyLink, isCommentBodyMention, isCommentBodyText, isJsonArray, isJsonObject, isJsonScalar, isLiveNode, isNotificationChannelEnabled, isPlainObject, isRootCrdt, isStartsWithOperator, kInternal, keys, legacy_patchImmutableObject, lsonToJson, makeEventSource, makePoller, makePosition, mapValues, memoizeOnSuccess, nanoid, nn, objectToQuery, patchLiveObjectKey, raise, resolveUsersInCommentBody, shallow, stringify, stringifyCommentBody, throwUsageError, toAbsoluteUrl, toPlainLson, tryParseJson, url, urljoin, wait, withTimeout };
|
package/dist/index.d.ts
CHANGED
|
@@ -1127,6 +1127,22 @@ type BatchStore<O, I> = {
|
|
|
1127
1127
|
invalidate: (inputs?: I[]) => void;
|
|
1128
1128
|
};
|
|
1129
1129
|
|
|
1130
|
+
type ContextualPromptResponse = Relax<{
|
|
1131
|
+
type: "insert";
|
|
1132
|
+
text: string;
|
|
1133
|
+
} | {
|
|
1134
|
+
type: "replace";
|
|
1135
|
+
text: string;
|
|
1136
|
+
} | {
|
|
1137
|
+
type: "other";
|
|
1138
|
+
text: string;
|
|
1139
|
+
}>;
|
|
1140
|
+
type ContextualPromptContext = {
|
|
1141
|
+
beforeSelection: string;
|
|
1142
|
+
selection: string;
|
|
1143
|
+
afterSelection: string;
|
|
1144
|
+
};
|
|
1145
|
+
|
|
1130
1146
|
declare enum ClientMsgCode {
|
|
1131
1147
|
UPDATE_PRESENCE = 100,
|
|
1132
1148
|
BROADCAST_EVENT = 103,
|
|
@@ -2406,6 +2422,15 @@ type PrivateRoomApi = {
|
|
|
2406
2422
|
}>;
|
|
2407
2423
|
getTextVersion(versionId: string): Promise<Response>;
|
|
2408
2424
|
createTextVersion(): Promise<void>;
|
|
2425
|
+
executeContextualPrompt(options: {
|
|
2426
|
+
prompt: string;
|
|
2427
|
+
context: ContextualPromptContext;
|
|
2428
|
+
previous?: {
|
|
2429
|
+
prompt: string;
|
|
2430
|
+
response: ContextualPromptResponse;
|
|
2431
|
+
};
|
|
2432
|
+
signal: AbortSignal;
|
|
2433
|
+
}): Promise<string>;
|
|
2409
2434
|
simulate: {
|
|
2410
2435
|
explicitClose(event: IWebSocketCloseEvent): void;
|
|
2411
2436
|
rawSend(data: string): void;
|
|
@@ -2443,6 +2468,7 @@ type PartialUnless<C, T> = Record<string, never> extends C ? Partial<T> : [
|
|
|
2443
2468
|
type OptionalTupleUnless<C, T extends any[]> = Record<string, never> extends C ? OptionalTuple<T> : [
|
|
2444
2469
|
C
|
|
2445
2470
|
] extends [never] ? OptionalTuple<T> : T;
|
|
2471
|
+
type LargeMessageStrategy = "default" | "split" | "experimental-fallback-to-http";
|
|
2446
2472
|
|
|
2447
2473
|
/**
|
|
2448
2474
|
* Pre-defined notification channels support list.
|
|
@@ -2668,6 +2694,16 @@ interface RoomHttpApi<M extends BaseMetadata> {
|
|
|
2668
2694
|
nonce: string | undefined;
|
|
2669
2695
|
messages: ClientMsg<P, E>[];
|
|
2670
2696
|
}): Promise<Response>;
|
|
2697
|
+
executeContextualPrompt({ roomId, prompt, context, signal, }: {
|
|
2698
|
+
roomId: string;
|
|
2699
|
+
prompt: string;
|
|
2700
|
+
context: ContextualPromptContext;
|
|
2701
|
+
previous?: {
|
|
2702
|
+
prompt: string;
|
|
2703
|
+
response: ContextualPromptResponse;
|
|
2704
|
+
};
|
|
2705
|
+
signal: AbortSignal;
|
|
2706
|
+
}): Promise<string>;
|
|
2671
2707
|
}
|
|
2672
2708
|
interface NotificationHttpApi<M extends BaseMetadata> {
|
|
2673
2709
|
getInboxNotifications(options?: {
|
|
@@ -2821,7 +2857,7 @@ declare class MutableSignal<T extends object> extends AbstractSignal<T> {
|
|
|
2821
2857
|
mutate(callback?: (state: T) => void | boolean): void;
|
|
2822
2858
|
}
|
|
2823
2859
|
|
|
2824
|
-
type
|
|
2860
|
+
type Awaitable<T> = T | PromiseLike<T>;
|
|
2825
2861
|
|
|
2826
2862
|
type ResolveMentionSuggestionsArgs = {
|
|
2827
2863
|
/**
|
|
@@ -3123,22 +3159,24 @@ type ClientOptions<U extends BaseUserMeta = DU> = {
|
|
|
3123
3159
|
lostConnectionTimeout?: number;
|
|
3124
3160
|
backgroundKeepAliveTimeout?: number;
|
|
3125
3161
|
polyfills?: Polyfills;
|
|
3162
|
+
largeMessageStrategy?: LargeMessageStrategy;
|
|
3163
|
+
/** @deprecated Use `largeMessageStrategy="experimental-fallback-to-http"` instead. */
|
|
3126
3164
|
unstable_fallbackToHTTP?: boolean;
|
|
3127
3165
|
unstable_streamData?: boolean;
|
|
3128
3166
|
/**
|
|
3129
3167
|
* A function that returns a list of user IDs matching a string.
|
|
3130
3168
|
*/
|
|
3131
|
-
resolveMentionSuggestions?: (args: ResolveMentionSuggestionsArgs) =>
|
|
3169
|
+
resolveMentionSuggestions?: (args: ResolveMentionSuggestionsArgs) => Awaitable<string[]>;
|
|
3132
3170
|
/**
|
|
3133
3171
|
* A function that returns user info from user IDs.
|
|
3134
3172
|
* You should return a list of user objects of the same size, in the same order.
|
|
3135
3173
|
*/
|
|
3136
|
-
resolveUsers?: (args: ResolveUsersArgs) =>
|
|
3174
|
+
resolveUsers?: (args: ResolveUsersArgs) => Awaitable<(U["info"] | undefined)[] | undefined>;
|
|
3137
3175
|
/**
|
|
3138
3176
|
* A function that returns room info from room IDs.
|
|
3139
3177
|
* You should return a list of room info objects of the same size, in the same order.
|
|
3140
3178
|
*/
|
|
3141
|
-
resolveRoomsInfo?: (args: ResolveRoomsInfoArgs) =>
|
|
3179
|
+
resolveRoomsInfo?: (args: ResolveRoomsInfoArgs) => Awaitable<(DRI | undefined)[] | undefined>;
|
|
3142
3180
|
/**
|
|
3143
3181
|
* Prevent the current browser tab from being closed if there are any locally
|
|
3144
3182
|
* pending Liveblocks changes that haven't been submitted to or confirmed by
|
|
@@ -3249,7 +3287,7 @@ type StringifyCommentBodyOptions<U extends BaseUserMeta = DU> = {
|
|
|
3249
3287
|
* A function that returns user info from user IDs.
|
|
3250
3288
|
* You should return a list of user objects of the same size, in the same order.
|
|
3251
3289
|
*/
|
|
3252
|
-
resolveUsers?: (args: ResolveUsersArgs) =>
|
|
3290
|
+
resolveUsers?: (args: ResolveUsersArgs) => Awaitable<(U["info"] | undefined)[] | undefined>;
|
|
3253
3291
|
};
|
|
3254
3292
|
declare function isCommentBodyText(element: CommentBodyElement): element is CommentBodyText;
|
|
3255
3293
|
declare function isCommentBodyMention(element: CommentBodyElement): element is CommentBodyMention;
|
|
@@ -3258,7 +3296,7 @@ declare function isCommentBodyLink(element: CommentBodyElement): element is Comm
|
|
|
3258
3296
|
* Get an array of each user's ID that has been mentioned in a `CommentBody`.
|
|
3259
3297
|
*/
|
|
3260
3298
|
declare function getMentionedIdsFromCommentBody(body: CommentBody): string[];
|
|
3261
|
-
declare function resolveUsersInCommentBody<U extends BaseUserMeta>(body: CommentBody, resolveUsers?: (args: ResolveUsersArgs) =>
|
|
3299
|
+
declare function resolveUsersInCommentBody<U extends BaseUserMeta>(body: CommentBody, resolveUsers?: (args: ResolveUsersArgs) => Awaitable<(U["info"] | undefined)[] | undefined>): Promise<Map<string, U["info"]>>;
|
|
3262
3300
|
declare function htmlSafe(value: string): HtmlSafeString;
|
|
3263
3301
|
declare class HtmlSafeString {
|
|
3264
3302
|
#private;
|
|
@@ -3928,4 +3966,4 @@ declare const CommentsApiError: typeof HttpError;
|
|
|
3928
3966
|
/** @deprecated Use HttpError instead. */
|
|
3929
3967
|
declare const NotificationsApiError: typeof HttpError;
|
|
3930
3968
|
|
|
3931
|
-
export { type AckOp, type ActivityData, type AsyncError, type AsyncLoading, type AsyncResult, type AsyncSuccess, 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, CommentsApiError, type CommentsEventServerMsg, CrdtType, type CreateListOp, type CreateMapOp, type CreateObjectOp, type CreateOp, type CreateRegisterOp, type CustomAuthenticationResult, type DAD, type DE, type DM, type DP, type DRI, type DS, type DU, DefaultMap, type Delegates, type DeleteCrdtOp, type DeleteObjectKeyOp, 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 InitialDocumentStateServerMsg, type Json, type JsonArray, type JsonObject, type JsonScalar, type KDAD, LiveList, type LiveListUpdate, LiveMap, type LiveMapUpdate, type LiveNode, LiveObject, type LiveObjectUpdate, type LiveStructure, LiveblocksError, type LiveblocksErrorContext, type LostConnectionEvent, type Lson, type LsonObject, MutableSignal, type NoInfr, type NodeMap, type NotificationChannel, type NotificationChannelSettings, type NotificationKind, NotificationsApiError, type Observable, type Op, OpCode, type OpaqueClient, type OpaqueRoom, type
|
|
3969
|
+
export { type AckOp, type ActivityData, 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, CommentsApiError, type CommentsEventServerMsg, type ContextualPromptContext, type ContextualPromptResponse, CrdtType, type CreateListOp, type CreateMapOp, type CreateObjectOp, type CreateOp, type CreateRegisterOp, type CustomAuthenticationResult, type DAD, type DE, type DM, type DP, type DRI, type DS, type DU, DefaultMap, type Delegates, type DeleteCrdtOp, type DeleteObjectKeyOp, 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 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, MutableSignal, type NoInfr, type NodeMap, type NotificationChannel, type NotificationChannelSettings, type NotificationKind, NotificationsApiError, type Observable, type Op, OpCode, type OpaqueClient, type OpaqueRoom, type OptionalTupleUnless, type OthersEvent, type ParentToChildNodeMap, type PartialUnless, type PartialUserNotificationSettings, 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 Resolve, type ResolveMentionSuggestionsArgs, type ResolveRoomsInfoArgs, type ResolveUsersArgs, type Room, type RoomEventMessage, type RoomNotificationSettings, type RoomStateServerMsg, 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 SyncSource, type SyncStatus, TextEditorType, type ThreadData, type ThreadDataPlain, type ThreadDataWithDeleteInfo, type ThreadDeleteInfo, type ToImmutable, type ToJson, 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 UserNotificationSettings, WebsocketCloseCodes, type YDocUpdateServerMsg, type YjsSyncStatus, ackOp, asPos, assert, assertNever, autoRetry, b64decode, batch, chunk, cloneLson, compactObject, fancyConsole as console, convertToCommentData, convertToCommentUserReaction, convertToInboxNotificationData, convertToThreadData, createClient, createCommentAttachmentId, createCommentId, createInboxNotificationId, createThreadId, deprecate, deprecateIf, detectDupes, entries, errorIf, freeze, generateCommentUrl, getMentionedIdsFromCommentBody, html, htmlSafe, isChildCrdt, isCommentBodyLink, isCommentBodyMention, isCommentBodyText, isJsonArray, isJsonObject, isJsonScalar, isLiveNode, isNotificationChannelEnabled, isPlainObject, isRootCrdt, isStartsWithOperator, kInternal, keys, legacy_patchImmutableObject, lsonToJson, makeEventSource, makePoller, makePosition, mapValues, memoizeOnSuccess, nanoid, nn, objectToQuery, patchLiveObjectKey, raise, resolveUsersInCommentBody, shallow, stringify, stringifyCommentBody, throwUsageError, toAbsoluteUrl, 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 = "2.
|
|
9
|
+
var PKG_VERSION = "2.18.0";
|
|
10
10
|
var PKG_FORMAT = "cjs";
|
|
11
11
|
|
|
12
12
|
// src/dupe-detection.ts
|
|
@@ -1562,6 +1562,29 @@ function createApiClient({
|
|
|
1562
1562
|
}
|
|
1563
1563
|
);
|
|
1564
1564
|
}
|
|
1565
|
+
async function executeContextualPrompt(options) {
|
|
1566
|
+
const result = await httpClient.post(
|
|
1567
|
+
url`/v2/c/rooms/${options.roomId}/ai/contextual-prompt`,
|
|
1568
|
+
await authManager.getAuthValue({
|
|
1569
|
+
requestedScope: "room:read",
|
|
1570
|
+
roomId: options.roomId
|
|
1571
|
+
}),
|
|
1572
|
+
{
|
|
1573
|
+
prompt: options.prompt,
|
|
1574
|
+
context: {
|
|
1575
|
+
beforeSelection: options.context.beforeSelection,
|
|
1576
|
+
selection: options.context.selection,
|
|
1577
|
+
afterSelection: options.context.afterSelection
|
|
1578
|
+
},
|
|
1579
|
+
previous: options.previous
|
|
1580
|
+
},
|
|
1581
|
+
{ signal: options.signal }
|
|
1582
|
+
);
|
|
1583
|
+
if (!result || result.content.length === 0) {
|
|
1584
|
+
throw new Error("No content returned from server");
|
|
1585
|
+
}
|
|
1586
|
+
return result.content[0].text;
|
|
1587
|
+
}
|
|
1565
1588
|
async function listTextVersions(options) {
|
|
1566
1589
|
const result = await httpClient.get(
|
|
1567
1590
|
url`/v2/c/rooms/${options.roomId}/versions`,
|
|
@@ -1819,7 +1842,9 @@ function createApiClient({
|
|
|
1819
1842
|
updateUserNotificationSettings,
|
|
1820
1843
|
// User threads
|
|
1821
1844
|
getUserThreads_experimental,
|
|
1822
|
-
getUserThreadsSince_experimental
|
|
1845
|
+
getUserThreadsSince_experimental,
|
|
1846
|
+
// AI
|
|
1847
|
+
executeContextualPrompt
|
|
1823
1848
|
};
|
|
1824
1849
|
}
|
|
1825
1850
|
function getBearerTokenFromAuthValue(authValue) {
|
|
@@ -6345,7 +6370,7 @@ function defaultMessageFromContext(context) {
|
|
|
6345
6370
|
}
|
|
6346
6371
|
|
|
6347
6372
|
// src/room.ts
|
|
6348
|
-
var MAX_SOCKET_MESSAGE_SIZE = 1024 * 1024 -
|
|
6373
|
+
var MAX_SOCKET_MESSAGE_SIZE = 1024 * 1024 - 512;
|
|
6349
6374
|
function makeIdFactory(connectionId) {
|
|
6350
6375
|
let count = 0;
|
|
6351
6376
|
return () => `${connectionId}:${count++}`;
|
|
@@ -6614,24 +6639,88 @@ function createRoom(options, config) {
|
|
|
6614
6639
|
async function createTextVersion() {
|
|
6615
6640
|
return httpClient.createTextVersion({ roomId });
|
|
6616
6641
|
}
|
|
6642
|
+
async function executeContextualPrompt(options2) {
|
|
6643
|
+
return httpClient.executeContextualPrompt({
|
|
6644
|
+
roomId,
|
|
6645
|
+
...options2
|
|
6646
|
+
});
|
|
6647
|
+
}
|
|
6648
|
+
function* chunkOps(msg) {
|
|
6649
|
+
const { ops, ...rest } = msg;
|
|
6650
|
+
if (ops.length < 2) {
|
|
6651
|
+
throw new Error("Cannot split ops into smaller chunks");
|
|
6652
|
+
}
|
|
6653
|
+
const mid = Math.floor(ops.length / 2);
|
|
6654
|
+
const firstHalf = ops.slice(0, mid);
|
|
6655
|
+
const secondHalf = ops.slice(mid);
|
|
6656
|
+
for (const halfOps of [firstHalf, secondHalf]) {
|
|
6657
|
+
const half = { ops: halfOps, ...rest };
|
|
6658
|
+
const text = JSON.stringify([half]);
|
|
6659
|
+
if (!isTooBigForWebSocket(text)) {
|
|
6660
|
+
yield text;
|
|
6661
|
+
} else {
|
|
6662
|
+
yield* chunkOps(half);
|
|
6663
|
+
}
|
|
6664
|
+
}
|
|
6665
|
+
}
|
|
6666
|
+
function* chunkMessages(messages) {
|
|
6667
|
+
if (messages.length < 2) {
|
|
6668
|
+
if (messages[0].type === 201 /* UPDATE_STORAGE */) {
|
|
6669
|
+
yield* chunkOps(messages[0]);
|
|
6670
|
+
return;
|
|
6671
|
+
} else {
|
|
6672
|
+
throw new Error(
|
|
6673
|
+
"Cannot split into chunks smaller than the allowed message size"
|
|
6674
|
+
);
|
|
6675
|
+
}
|
|
6676
|
+
}
|
|
6677
|
+
const mid = Math.floor(messages.length / 2);
|
|
6678
|
+
const firstHalf = messages.slice(0, mid);
|
|
6679
|
+
const secondHalf = messages.slice(mid);
|
|
6680
|
+
for (const half of [firstHalf, secondHalf]) {
|
|
6681
|
+
const text = JSON.stringify(half);
|
|
6682
|
+
if (!isTooBigForWebSocket(text)) {
|
|
6683
|
+
yield text;
|
|
6684
|
+
} else {
|
|
6685
|
+
yield* chunkMessages(half);
|
|
6686
|
+
}
|
|
6687
|
+
}
|
|
6688
|
+
}
|
|
6689
|
+
function isTooBigForWebSocket(text) {
|
|
6690
|
+
if (text.length * 4 < MAX_SOCKET_MESSAGE_SIZE) {
|
|
6691
|
+
return false;
|
|
6692
|
+
}
|
|
6693
|
+
return new TextEncoder().encode(text).length >= MAX_SOCKET_MESSAGE_SIZE;
|
|
6694
|
+
}
|
|
6617
6695
|
function sendMessages(messages) {
|
|
6618
|
-
const
|
|
6619
|
-
const
|
|
6620
|
-
if (
|
|
6621
|
-
|
|
6622
|
-
|
|
6696
|
+
const strategy = _nullishCoalesce(config.largeMessageStrategy, () => ( "default"));
|
|
6697
|
+
const text = JSON.stringify(messages);
|
|
6698
|
+
if (!isTooBigForWebSocket(text)) {
|
|
6699
|
+
return managedSocket.send(text);
|
|
6700
|
+
}
|
|
6701
|
+
switch (strategy) {
|
|
6702
|
+
case "default": {
|
|
6703
|
+
error2("Message is too large for websockets, not sending. Configure largeMessageStrategy option to deal with this.");
|
|
6704
|
+
return;
|
|
6705
|
+
}
|
|
6706
|
+
case "split": {
|
|
6707
|
+
warn("Message is too large for websockets, splitting into smaller chunks");
|
|
6708
|
+
for (const chunk2 of chunkMessages(messages)) {
|
|
6709
|
+
managedSocket.send(chunk2);
|
|
6710
|
+
}
|
|
6711
|
+
return;
|
|
6712
|
+
}
|
|
6713
|
+
case "experimental-fallback-to-http": {
|
|
6714
|
+
warn("Message is too large for websockets, so sending over HTTP instead");
|
|
6715
|
+
const nonce = _nullishCoalesce(_optionalChain([context, 'access', _142 => _142.dynamicSessionInfoSig, 'access', _143 => _143.get, 'call', _144 => _144(), 'optionalAccess', _145 => _145.nonce]), () => ( raise("Session is not authorized to send message over HTTP")));
|
|
6623
6716
|
void httpClient.sendMessages({ roomId, nonce, messages }).then((resp) => {
|
|
6624
6717
|
if (!resp.ok && resp.status === 403) {
|
|
6625
6718
|
managedSocket.reconnect();
|
|
6626
6719
|
}
|
|
6627
6720
|
});
|
|
6628
|
-
warn(
|
|
6629
|
-
"Message was too large for websockets and sent over HTTP instead"
|
|
6630
|
-
);
|
|
6631
6721
|
return;
|
|
6632
6722
|
}
|
|
6633
6723
|
}
|
|
6634
|
-
managedSocket.send(serializedPayload);
|
|
6635
6724
|
}
|
|
6636
6725
|
const self = DerivedSignal.from(
|
|
6637
6726
|
context.staticSessionInfoSig,
|
|
@@ -7598,6 +7687,8 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
7598
7687
|
getTextVersion,
|
|
7599
7688
|
// create a version
|
|
7600
7689
|
createTextVersion,
|
|
7690
|
+
// execute a contextual prompt
|
|
7691
|
+
executeContextualPrompt,
|
|
7601
7692
|
// Support for the Liveblocks browser extension
|
|
7602
7693
|
getSelf_forDevTools: () => selfAsTreeNode.get(),
|
|
7603
7694
|
getOthers_forDevTools: () => others_forDevTools.get(),
|
|
@@ -7902,7 +7993,7 @@ function createClient(options) {
|
|
|
7902
7993
|
enableDebugLogging: clientOptions.enableDebugLogging,
|
|
7903
7994
|
baseUrl,
|
|
7904
7995
|
errorEventSource: liveblocksErrorSource,
|
|
7905
|
-
|
|
7996
|
+
largeMessageStrategy: _nullishCoalesce(clientOptions.largeMessageStrategy, () => ( (clientOptions.unstable_fallbackToHTTP ? "experimental-fallback-to-http" : void 0))),
|
|
7906
7997
|
unstable_streamData: !!clientOptions.unstable_streamData,
|
|
7907
7998
|
roomHttpClient: httpClient,
|
|
7908
7999
|
createSyncSource
|