@liveblocks/core 2.25.0-aiprivatebeta1 → 2.25.0-aiprivatebeta10
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 +325 -271
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +258 -112
- package/dist/index.d.ts +258 -112
- package/dist/index.js +241 -187
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { ComponentType } from 'react';
|
|
1
|
+
import { JSONSchema7 } from 'json-schema';
|
|
3
2
|
|
|
4
3
|
/**
|
|
5
4
|
* Throws an error if multiple copies of a Liveblocks package are being loaded
|
|
@@ -3527,7 +3526,6 @@ type ISODateString = Brand<string, "ISODateString">;
|
|
|
3527
3526
|
type ChatId = string;
|
|
3528
3527
|
type MessageId = Brand<`ms_${string}`, "MessageId">;
|
|
3529
3528
|
type CmdId = Brand<string, "CmdId">;
|
|
3530
|
-
type ClientId = Brand<string, "ClientId">;
|
|
3531
3529
|
type CopilotId = Brand<`co_${string}`, "CopilotId">;
|
|
3532
3530
|
type ServerAiMsg = ServerCmdResponse | ServerEvent;
|
|
3533
3531
|
type DefineCmd<CmdName extends string, TRequest, TResponse> = [
|
|
@@ -3540,17 +3538,17 @@ type DefineCmd<CmdName extends string, TRequest, TResponse> = [
|
|
|
3540
3538
|
cmdId: CmdId;
|
|
3541
3539
|
} & TResponse>
|
|
3542
3540
|
];
|
|
3543
|
-
type CommandPair = GetChatsPair |
|
|
3541
|
+
type CommandPair = GetChatsPair | GetOrCreateChatPair | DeleteChatPair | GetMessageTreePair | DeleteMessagePair | ClearChatPair | AskInChatPair | AbortAiPair | SetToolResultPair;
|
|
3544
3542
|
type ServerCmdResponse<T extends CommandPair = CommandPair> = T[1];
|
|
3545
3543
|
type GetChatsResponse = ServerCmdResponse<GetChatsPair>;
|
|
3546
|
-
type
|
|
3544
|
+
type GetOrCreateChatResponse = ServerCmdResponse<GetOrCreateChatPair>;
|
|
3547
3545
|
type DeleteChatResponse = ServerCmdResponse<DeleteChatPair>;
|
|
3548
3546
|
type GetMessageTreeResponse = ServerCmdResponse<GetMessageTreePair>;
|
|
3549
|
-
type AddUserMessageResponse = ServerCmdResponse<AddUserMessagePair>;
|
|
3550
3547
|
type DeleteMessageResponse = ServerCmdResponse<DeleteMessagePair>;
|
|
3551
3548
|
type ClearChatResponse = ServerCmdResponse<ClearChatPair>;
|
|
3552
|
-
type
|
|
3549
|
+
type AskInChatResponse = ServerCmdResponse<AskInChatPair>;
|
|
3553
3550
|
type AbortAiResponse = ServerCmdResponse<AbortAiPair>;
|
|
3551
|
+
type SetToolResultResponse = ServerCmdResponse<SetToolResultPair>;
|
|
3554
3552
|
type GetChatsPair = DefineCmd<"get-chats", {
|
|
3555
3553
|
cursor?: Cursor;
|
|
3556
3554
|
pageSize?: number;
|
|
@@ -3558,12 +3556,15 @@ type GetChatsPair = DefineCmd<"get-chats", {
|
|
|
3558
3556
|
chats: AiChat[];
|
|
3559
3557
|
nextCursor: Cursor | null;
|
|
3560
3558
|
}>;
|
|
3561
|
-
type
|
|
3562
|
-
|
|
3559
|
+
type CreateChatOptions = {
|
|
3560
|
+
/** A human-friendly title for the chat. If not set, it will get auto-generated after the first response. */
|
|
3561
|
+
title?: string;
|
|
3562
|
+
/** Arbitrary metadata to record for this chat. This can be later used to filter the list of chats by metadata. */
|
|
3563
|
+
metadata?: Record<string, string | string[]>;
|
|
3564
|
+
};
|
|
3565
|
+
type GetOrCreateChatPair = DefineCmd<"get-or-create-chat", {
|
|
3563
3566
|
id: ChatId;
|
|
3564
|
-
|
|
3565
|
-
ephemeral: boolean;
|
|
3566
|
-
metadata: Record<string, string | string[]>;
|
|
3567
|
+
options?: CreateChatOptions;
|
|
3567
3568
|
}, {
|
|
3568
3569
|
chat: AiChat;
|
|
3569
3570
|
}>;
|
|
@@ -3578,14 +3579,6 @@ type GetMessageTreePair = DefineCmd<"get-message-tree", {
|
|
|
3578
3579
|
chat: AiChat;
|
|
3579
3580
|
messages: AiChatMessage[];
|
|
3580
3581
|
}>;
|
|
3581
|
-
type AddUserMessagePair = DefineCmd<"add-user-message", {
|
|
3582
|
-
id: MessageId;
|
|
3583
|
-
chatId: ChatId;
|
|
3584
|
-
parentMessageId: MessageId | null;
|
|
3585
|
-
content: AiUserContentPart[];
|
|
3586
|
-
}, {
|
|
3587
|
-
message: AiUserMessage;
|
|
3588
|
-
}>;
|
|
3589
3582
|
type DeleteMessagePair = DefineCmd<"delete-message", {
|
|
3590
3583
|
chatId: ChatId;
|
|
3591
3584
|
messageId: MessageId;
|
|
@@ -3598,10 +3591,27 @@ type ClearChatPair = DefineCmd<"clear-chat", {
|
|
|
3598
3591
|
}, {
|
|
3599
3592
|
chatId: ChatId;
|
|
3600
3593
|
}>;
|
|
3601
|
-
type
|
|
3594
|
+
type AiGenerationOptions = {
|
|
3595
|
+
/**
|
|
3596
|
+
* The Copilot ID to use for this request. If not provided, a built-in
|
|
3597
|
+
* default Copilot will be used instead of one that you configured via the
|
|
3598
|
+
* dashboard.
|
|
3599
|
+
*/
|
|
3600
|
+
copilotId?: CopilotId;
|
|
3601
|
+
stream?: boolean;
|
|
3602
|
+
tools?: AiToolDescription[];
|
|
3603
|
+
knowledge?: AiKnowledgeSource[];
|
|
3604
|
+
timeout?: number;
|
|
3605
|
+
};
|
|
3606
|
+
type AskInChatPair = DefineCmd<"ask-in-chat", {
|
|
3602
3607
|
chatId: ChatId;
|
|
3603
3608
|
/** The chat message to use as the source to create the assistant response. */
|
|
3604
|
-
|
|
3609
|
+
sourceMessage: // An existing message ID to reply to
|
|
3610
|
+
MessageId | {
|
|
3611
|
+
id: MessageId;
|
|
3612
|
+
parentMessageId: MessageId | null;
|
|
3613
|
+
content: AiUserContentPart[];
|
|
3614
|
+
};
|
|
3605
3615
|
/**
|
|
3606
3616
|
* The new (!) message ID to output the assistant response into. This ID
|
|
3607
3617
|
* should be a non-existing message ID, optimistically assigned by the
|
|
@@ -3609,32 +3619,29 @@ type AskAIPair = DefineCmd<"ask-ai", {
|
|
|
3609
3619
|
* message ID.
|
|
3610
3620
|
*/
|
|
3611
3621
|
targetMessageId: MessageId;
|
|
3612
|
-
|
|
3613
|
-
* The Copilot ID to use for this request. If not provided, a built-in
|
|
3614
|
-
* default Copilot will be used instead of one that you configured via the
|
|
3615
|
-
* dashboard.
|
|
3616
|
-
*/
|
|
3617
|
-
copilotId?: CopilotId;
|
|
3618
|
-
/**
|
|
3619
|
-
* A client ID unique to this command. Later delta and settle messages will
|
|
3620
|
-
* reference this client ID, which is important to ensure that tool calls
|
|
3621
|
-
* with side effects will only get executed once, and only by the client
|
|
3622
|
-
* that originally made the request that produced the tool call.
|
|
3623
|
-
*/
|
|
3624
|
-
clientId: ClientId;
|
|
3625
|
-
stream: boolean;
|
|
3626
|
-
tools?: AiToolDefinition[];
|
|
3627
|
-
toolChoice?: ToolChoice;
|
|
3628
|
-
context?: AiChatContext[];
|
|
3629
|
-
timeout: number;
|
|
3622
|
+
generationOptions: AiGenerationOptions;
|
|
3630
3623
|
}, {
|
|
3631
|
-
|
|
3624
|
+
sourceMessage?: AiChatMessage;
|
|
3625
|
+
targetMessage: AiChatMessage;
|
|
3632
3626
|
}>;
|
|
3633
3627
|
type AbortAiPair = DefineCmd<"abort-ai", {
|
|
3634
3628
|
messageId: MessageId;
|
|
3635
3629
|
}, {
|
|
3636
3630
|
ok: true;
|
|
3637
3631
|
}>;
|
|
3632
|
+
type ToolResultData = Json;
|
|
3633
|
+
type SetToolResultPair = DefineCmd<"set-tool-result", {
|
|
3634
|
+
chatId: ChatId;
|
|
3635
|
+
messageId: MessageId;
|
|
3636
|
+
toolCallId: string;
|
|
3637
|
+
result: ToolResultData;
|
|
3638
|
+
generationOptions: AiGenerationOptions;
|
|
3639
|
+
}, {
|
|
3640
|
+
ok: true;
|
|
3641
|
+
message: AiChatMessage;
|
|
3642
|
+
} | {
|
|
3643
|
+
ok: false;
|
|
3644
|
+
}>;
|
|
3638
3645
|
type ServerEvent = RebootedEvent | CmdFailedEvent | ErrorServerEvent | SyncServerEvent | DeltaServerEvent | SettleServerEvent;
|
|
3639
3646
|
type RebootedEvent = {
|
|
3640
3647
|
event: "rebooted";
|
|
@@ -3664,8 +3671,6 @@ type SyncServerEvent = {
|
|
|
3664
3671
|
type DeltaServerEvent = {
|
|
3665
3672
|
event: "delta";
|
|
3666
3673
|
id: MessageId;
|
|
3667
|
-
/** The client ID that originally made the request that led to this event */
|
|
3668
|
-
clientId: ClientId;
|
|
3669
3674
|
delta: AiAssistantDeltaUpdate;
|
|
3670
3675
|
};
|
|
3671
3676
|
/**
|
|
@@ -3675,29 +3680,43 @@ type DeltaServerEvent = {
|
|
|
3675
3680
|
*/
|
|
3676
3681
|
type SettleServerEvent = {
|
|
3677
3682
|
event: "settle";
|
|
3678
|
-
|
|
3679
|
-
clientId: ClientId;
|
|
3680
|
-
message: AiCompletedAssistantMessage | AiFailedAssistantMessage;
|
|
3683
|
+
message: AiAwaitingToolAssistantMessage | AiCompletedAssistantMessage | AiFailedAssistantMessage;
|
|
3681
3684
|
};
|
|
3682
3685
|
type AiChat = {
|
|
3683
3686
|
id: ChatId;
|
|
3684
|
-
|
|
3685
|
-
ephemeral: boolean;
|
|
3687
|
+
title: string;
|
|
3686
3688
|
metadata: Record<string, string | string[]>;
|
|
3687
3689
|
createdAt: ISODateString;
|
|
3688
3690
|
lastMessageAt?: ISODateString;
|
|
3689
3691
|
deletedAt?: ISODateString;
|
|
3690
3692
|
};
|
|
3691
|
-
type
|
|
3693
|
+
type AiToolDescription = {
|
|
3692
3694
|
name: string;
|
|
3693
3695
|
description?: string;
|
|
3694
|
-
parameters:
|
|
3696
|
+
parameters: JSONSchema7;
|
|
3695
3697
|
};
|
|
3696
|
-
type
|
|
3697
|
-
|
|
3698
|
+
type AiToolInvocationPart<A extends JsonObject = JsonObject, R extends ToolResultData = ToolResultData> = Relax<AiReceivingToolInvocationPart | AiExecutingToolInvocationPart<A> | AiExecutedToolInvocationPart<A, R>>;
|
|
3699
|
+
type AiReceivingToolInvocationPart = {
|
|
3700
|
+
type: "tool-invocation";
|
|
3701
|
+
status: "receiving";
|
|
3698
3702
|
toolCallId: string;
|
|
3699
3703
|
toolName: string;
|
|
3700
|
-
|
|
3704
|
+
partialArgs: Json;
|
|
3705
|
+
};
|
|
3706
|
+
type AiExecutingToolInvocationPart<A extends JsonObject = JsonObject> = {
|
|
3707
|
+
type: "tool-invocation";
|
|
3708
|
+
status: "executing";
|
|
3709
|
+
toolCallId: string;
|
|
3710
|
+
toolName: string;
|
|
3711
|
+
args: A;
|
|
3712
|
+
};
|
|
3713
|
+
type AiExecutedToolInvocationPart<A extends JsonObject = JsonObject, R extends ToolResultData = ToolResultData> = {
|
|
3714
|
+
type: "tool-invocation";
|
|
3715
|
+
status: "executed";
|
|
3716
|
+
toolCallId: string;
|
|
3717
|
+
toolName: string;
|
|
3718
|
+
args: A;
|
|
3719
|
+
result: R;
|
|
3701
3720
|
};
|
|
3702
3721
|
type AiTextPart = {
|
|
3703
3722
|
type: "text";
|
|
@@ -3717,7 +3736,6 @@ type AiReasoningDelta = Relax<{
|
|
|
3717
3736
|
type AiReasoningPart = {
|
|
3718
3737
|
type: "reasoning";
|
|
3719
3738
|
text: string;
|
|
3720
|
-
signature?: string;
|
|
3721
3739
|
};
|
|
3722
3740
|
type AiUploadedImagePart = {
|
|
3723
3741
|
type: "image";
|
|
@@ -3727,12 +3745,8 @@ type AiUploadedImagePart = {
|
|
|
3727
3745
|
mimeType: string;
|
|
3728
3746
|
};
|
|
3729
3747
|
type AiUserContentPart = AiTextPart | AiUploadedImagePart;
|
|
3730
|
-
type AiAssistantContentPart = AiReasoningPart | AiTextPart |
|
|
3731
|
-
type AiAssistantDeltaUpdate =
|
|
3732
|
-
type ToolChoice = "auto" | "required" | "none" | {
|
|
3733
|
-
type: "tool";
|
|
3734
|
-
toolName: string;
|
|
3735
|
-
};
|
|
3748
|
+
type AiAssistantContentPart = AiReasoningPart | AiTextPart | AiToolInvocationPart;
|
|
3749
|
+
type AiAssistantDeltaUpdate = AiTextDelta | AiReasoningDelta | AiExecutingToolInvocationPart;
|
|
3736
3750
|
type AiUserMessage = {
|
|
3737
3751
|
id: MessageId;
|
|
3738
3752
|
chatId: ChatId;
|
|
@@ -3742,63 +3756,173 @@ type AiUserMessage = {
|
|
|
3742
3756
|
createdAt: ISODateString;
|
|
3743
3757
|
deletedAt?: ISODateString;
|
|
3744
3758
|
};
|
|
3745
|
-
type AiAssistantMessage = Relax<
|
|
3746
|
-
type
|
|
3759
|
+
type AiAssistantMessage = Relax<AiGeneratingAssistantMessage | AiAwaitingToolAssistantMessage | AiCompletedAssistantMessage | AiFailedAssistantMessage>;
|
|
3760
|
+
type AiGeneratingAssistantMessage = {
|
|
3747
3761
|
id: MessageId;
|
|
3748
3762
|
chatId: ChatId;
|
|
3749
3763
|
parentId: MessageId | null;
|
|
3750
3764
|
role: "assistant";
|
|
3751
|
-
content: AiAssistantContentPart[];
|
|
3752
3765
|
createdAt: ISODateString;
|
|
3753
3766
|
deletedAt?: ISODateString;
|
|
3754
|
-
status: "
|
|
3767
|
+
status: "generating";
|
|
3768
|
+
contentSoFar: AiAssistantContentPart[];
|
|
3755
3769
|
};
|
|
3756
|
-
type
|
|
3770
|
+
type AiAwaitingToolAssistantMessage = {
|
|
3757
3771
|
id: MessageId;
|
|
3758
3772
|
chatId: ChatId;
|
|
3759
3773
|
parentId: MessageId | null;
|
|
3760
3774
|
role: "assistant";
|
|
3761
3775
|
createdAt: ISODateString;
|
|
3762
3776
|
deletedAt?: ISODateString;
|
|
3763
|
-
status: "
|
|
3777
|
+
status: "awaiting-tool";
|
|
3764
3778
|
contentSoFar: AiAssistantContentPart[];
|
|
3765
|
-
errorReason: string;
|
|
3766
3779
|
};
|
|
3767
|
-
type
|
|
3780
|
+
type AiCompletedAssistantMessage = {
|
|
3768
3781
|
id: MessageId;
|
|
3769
3782
|
chatId: ChatId;
|
|
3770
3783
|
parentId: MessageId | null;
|
|
3771
3784
|
role: "assistant";
|
|
3785
|
+
content: AiAssistantContentPart[];
|
|
3772
3786
|
createdAt: ISODateString;
|
|
3773
3787
|
deletedAt?: ISODateString;
|
|
3774
|
-
status: "
|
|
3788
|
+
status: "completed";
|
|
3789
|
+
};
|
|
3790
|
+
type AiFailedAssistantMessage = {
|
|
3791
|
+
id: MessageId;
|
|
3792
|
+
chatId: ChatId;
|
|
3793
|
+
parentId: MessageId | null;
|
|
3794
|
+
role: "assistant";
|
|
3795
|
+
createdAt: ISODateString;
|
|
3796
|
+
deletedAt?: ISODateString;
|
|
3797
|
+
status: "failed";
|
|
3775
3798
|
contentSoFar: AiAssistantContentPart[];
|
|
3799
|
+
errorReason: string;
|
|
3776
3800
|
};
|
|
3777
3801
|
type AiChatMessage = AiUserMessage | AiAssistantMessage;
|
|
3778
|
-
type
|
|
3779
|
-
value: string;
|
|
3802
|
+
type AiKnowledgeSource = {
|
|
3780
3803
|
description: string;
|
|
3804
|
+
value: Json;
|
|
3781
3805
|
};
|
|
3782
3806
|
|
|
3783
|
-
type
|
|
3807
|
+
type InferFromSchema<T extends JSONSchema7> = JSONSchema7 extends T ? JsonObject : T extends {
|
|
3808
|
+
type: "object";
|
|
3809
|
+
properties: Record<string, JSONSchema7>;
|
|
3810
|
+
required: readonly string[];
|
|
3811
|
+
} ? Resolve<{
|
|
3812
|
+
-readonly [K in keyof T["properties"] as K extends string ? K extends Extract<K, T["required"][number]> ? K : never : never]: InferFromSchema<T["properties"][K]>;
|
|
3813
|
+
} & {
|
|
3814
|
+
-readonly [K in keyof T["properties"] as K extends string ? K extends Extract<K, T["required"][number]> ? never : K : never]?: InferFromSchema<T["properties"][K]>;
|
|
3815
|
+
}> : T extends {
|
|
3816
|
+
type: "object";
|
|
3817
|
+
properties: Record<string, JSONSchema7>;
|
|
3818
|
+
} ? {
|
|
3819
|
+
-readonly [K in keyof T["properties"]]?: InferFromSchema<T["properties"][K]>;
|
|
3820
|
+
} : T extends {
|
|
3821
|
+
type: "string";
|
|
3822
|
+
} ? string : T extends {
|
|
3823
|
+
type: "number";
|
|
3824
|
+
} ? number : T extends {
|
|
3825
|
+
type: "boolean";
|
|
3826
|
+
} ? boolean : T extends {
|
|
3827
|
+
type: "null";
|
|
3828
|
+
} ? null : T extends {
|
|
3829
|
+
type: "array";
|
|
3830
|
+
items: JSONSchema7;
|
|
3831
|
+
} ? InferFromSchema<T["items"]>[] : unknown;
|
|
3832
|
+
type AiToolTypePack<A extends JsonObject = JsonObject, R extends ToolResultData = ToolResultData> = {
|
|
3833
|
+
A: A;
|
|
3834
|
+
R: R;
|
|
3835
|
+
};
|
|
3836
|
+
type AiToolInvocationProps<A extends JsonObject, R extends ToolResultData> = Resolve<DistributiveOmit<AiToolInvocationPart<A, R>, "type"> & {
|
|
3837
|
+
respond: (result: R) => void;
|
|
3838
|
+
/**
|
|
3839
|
+
* These are the inferred types for your tool call which you can pass down
|
|
3840
|
+
* to UI components, like so:
|
|
3841
|
+
*
|
|
3842
|
+
* <AiTool.Confirmation
|
|
3843
|
+
* types={types}
|
|
3844
|
+
* confirm={
|
|
3845
|
+
* // Now fully type-safe!
|
|
3846
|
+
* (args) => result
|
|
3847
|
+
* } />
|
|
3848
|
+
*
|
|
3849
|
+
* This will make your AiTool.Confirmation component aware of the types for
|
|
3850
|
+
* `args` and `result`.
|
|
3851
|
+
*/
|
|
3852
|
+
types: AiToolTypePack<A, R>;
|
|
3853
|
+
[kInternal]: {
|
|
3854
|
+
execute: AiToolExecuteCallback<A, R> | undefined;
|
|
3855
|
+
};
|
|
3856
|
+
}>;
|
|
3857
|
+
type AiOpaqueToolInvocationProps = AiToolInvocationProps<JsonObject, ToolResultData>;
|
|
3858
|
+
type AiToolExecuteContext = {
|
|
3859
|
+
toolName: string;
|
|
3860
|
+
toolCallId: string;
|
|
3861
|
+
};
|
|
3862
|
+
type AiToolExecuteCallback<A extends JsonObject, R extends ToolResultData> = (args: A, context: AiToolExecuteContext) => Awaitable<R>;
|
|
3863
|
+
type AiToolDefinition<S extends JSONObjectSchema7, A extends JsonObject, R extends ToolResultData> = {
|
|
3784
3864
|
description?: string;
|
|
3785
|
-
parameters:
|
|
3786
|
-
|
|
3787
|
-
|
|
3788
|
-
}>;
|
|
3789
|
-
execute?: never;
|
|
3865
|
+
parameters: S;
|
|
3866
|
+
execute?: AiToolExecuteCallback<A, R>;
|
|
3867
|
+
render?: (props: AiToolInvocationProps<A, R>) => unknown;
|
|
3790
3868
|
};
|
|
3869
|
+
type AiOpaqueToolDefinition = AiToolDefinition<JSONObjectSchema7, JsonObject, ToolResultData>;
|
|
3870
|
+
type JSONObjectSchema7 = JSONSchema7 & {
|
|
3871
|
+
type: "object";
|
|
3872
|
+
};
|
|
3873
|
+
/**
|
|
3874
|
+
* Helper function to help infer the types of `args`, `render`, and `result`.
|
|
3875
|
+
* This function has no runtime implementation and is only needed to make it
|
|
3876
|
+
* possible for TypeScript to infer types.
|
|
3877
|
+
*/
|
|
3878
|
+
declare function defineAiTool<R extends ToolResultData>(): <const S extends JSONObjectSchema7>(def: AiToolDefinition<S, InferFromSchema<S> extends JsonObject ? InferFromSchema<S> : JsonObject, R>) => AiOpaqueToolDefinition;
|
|
3791
3879
|
type UiChatMessage = AiChatMessage & {
|
|
3792
|
-
|
|
3793
|
-
|
|
3880
|
+
navigation: {
|
|
3881
|
+
/**
|
|
3882
|
+
* The message ID of the parent message, or null if there is no parent.
|
|
3883
|
+
*/
|
|
3884
|
+
parent: MessageId | null;
|
|
3885
|
+
/**
|
|
3886
|
+
* The message ID of the left sibling message, or null if there is no left sibling.
|
|
3887
|
+
*/
|
|
3888
|
+
prev: MessageId | null;
|
|
3889
|
+
/**
|
|
3890
|
+
* The message ID of the right sibling message, or null if there is no right sibling.
|
|
3891
|
+
*/
|
|
3892
|
+
next: MessageId | null;
|
|
3893
|
+
};
|
|
3794
3894
|
};
|
|
3795
3895
|
type UiUserMessage = AiUserMessage & {
|
|
3796
|
-
|
|
3797
|
-
|
|
3896
|
+
navigation: {
|
|
3897
|
+
/**
|
|
3898
|
+
* The message ID of the parent message, or null if there is no parent.
|
|
3899
|
+
*/
|
|
3900
|
+
parent: MessageId | null;
|
|
3901
|
+
/**
|
|
3902
|
+
* The message ID of the left sibling message, or null if there is no left sibling.
|
|
3903
|
+
*/
|
|
3904
|
+
prev: MessageId | null;
|
|
3905
|
+
/**
|
|
3906
|
+
* The message ID of the right sibling message, or null if there is no right sibling.
|
|
3907
|
+
*/
|
|
3908
|
+
next: MessageId | null;
|
|
3909
|
+
};
|
|
3798
3910
|
};
|
|
3799
3911
|
type UiAssistantMessage = AiAssistantMessage & {
|
|
3800
|
-
|
|
3801
|
-
|
|
3912
|
+
navigation: {
|
|
3913
|
+
/**
|
|
3914
|
+
* The message ID of the parent message, or null if there is no parent.
|
|
3915
|
+
*/
|
|
3916
|
+
parent: MessageId | null;
|
|
3917
|
+
/**
|
|
3918
|
+
* The message ID of the left sibling message, or null if there is no left sibling.
|
|
3919
|
+
*/
|
|
3920
|
+
prev: MessageId | null;
|
|
3921
|
+
/**
|
|
3922
|
+
* The message ID of the right sibling message, or null if there is no right sibling.
|
|
3923
|
+
*/
|
|
3924
|
+
next: MessageId | null;
|
|
3925
|
+
};
|
|
3802
3926
|
};
|
|
3803
3927
|
type AiContext = {
|
|
3804
3928
|
staticSessionInfoSig: Signal<StaticSessionInfo | null>;
|
|
@@ -3810,31 +3934,30 @@ type AiContext = {
|
|
|
3810
3934
|
chatsStore: ReturnType<typeof createStore_forUserAiChats>;
|
|
3811
3935
|
toolsStore: ReturnType<typeof createStore_forTools>;
|
|
3812
3936
|
messagesStore: ReturnType<typeof createStore_forChatMessages>;
|
|
3813
|
-
|
|
3814
|
-
};
|
|
3815
|
-
type CreateChatOptions = {
|
|
3816
|
-
ephemeral?: boolean;
|
|
3817
|
-
metadata?: AiChat["metadata"];
|
|
3818
|
-
};
|
|
3819
|
-
type AskAiOptions = {
|
|
3820
|
-
copilotId?: CopilotId;
|
|
3821
|
-
stream?: boolean;
|
|
3822
|
-
timeout?: number;
|
|
3937
|
+
knowledge: KnowledgeStack;
|
|
3823
3938
|
};
|
|
3939
|
+
type LayerKey = Brand<string, "LayerKey">;
|
|
3940
|
+
declare class KnowledgeStack {
|
|
3941
|
+
#private;
|
|
3942
|
+
constructor();
|
|
3943
|
+
registerLayer(uniqueLayerId: string): LayerKey;
|
|
3944
|
+
deregisterLayer(layerKey: LayerKey): void;
|
|
3945
|
+
get(): AiKnowledgeSource[];
|
|
3946
|
+
invalidate(): void;
|
|
3947
|
+
updateKnowledge(layerKey: LayerKey, key: string, data: AiKnowledgeSource | null): void;
|
|
3948
|
+
}
|
|
3824
3949
|
declare function createStore_forTools(): {
|
|
3825
|
-
|
|
3950
|
+
getToolDefinitionΣ: (chatId: string, toolName: string) => Signal<AiOpaqueToolDefinition | undefined>;
|
|
3826
3951
|
getToolsForChat: (chatId: string) => {
|
|
3827
3952
|
name: string;
|
|
3828
|
-
definition:
|
|
3953
|
+
definition: AiOpaqueToolDefinition;
|
|
3829
3954
|
}[];
|
|
3830
|
-
addToolDefinition: (chatId: string, name: string, definition:
|
|
3955
|
+
addToolDefinition: (chatId: string, name: string, definition: AiOpaqueToolDefinition) => void;
|
|
3831
3956
|
removeToolDefinition: (chatId: string, toolName: string) => void;
|
|
3832
3957
|
};
|
|
3833
|
-
declare function createStore_forChatMessages(): {
|
|
3958
|
+
declare function createStore_forChatMessages(toolsStore: ReturnType<typeof createStore_forTools>, setToolResult: (chatId: string, messageId: MessageId, toolCallId: string, result: ToolResultData, options?: AiGenerationOptions) => Promise<SetToolResultResponse>): {
|
|
3834
3959
|
getMessageById: (messageId: MessageId) => AiChatMessage | undefined;
|
|
3835
3960
|
getChatMessagesForBranchΣ: (chatId: string, branch?: MessageId) => DerivedSignal<UiChatMessage[]>;
|
|
3836
|
-
getMessagesForChatΣ: (chatId: string) => DerivedSignal<AiChatMessage[]>;
|
|
3837
|
-
getLatestUserMessageAncestor: (chatId: string, messageId: MessageId) => MessageId | null;
|
|
3838
3961
|
createOptimistically: {
|
|
3839
3962
|
(chatId: string, role: "user", parentId: MessageId | null, content: AiUserContentPart[]): MessageId;
|
|
3840
3963
|
(chatId: string, role: "assistant", parentId: MessageId | null): MessageId;
|
|
@@ -3845,44 +3968,67 @@ declare function createStore_forChatMessages(): {
|
|
|
3845
3968
|
removeByChatId: (chatId: string) => void;
|
|
3846
3969
|
addDelta: (messageId: MessageId, delta: AiAssistantDeltaUpdate) => void;
|
|
3847
3970
|
failAllPending: () => void;
|
|
3971
|
+
allowAutoExecuteToolCall(messageId: MessageId): void;
|
|
3848
3972
|
};
|
|
3849
3973
|
declare function createStore_forUserAiChats(): {
|
|
3850
3974
|
chatsΣ: DerivedSignal<AiChat[]>;
|
|
3975
|
+
getChatById: (chatId: string) => AiChat | undefined;
|
|
3851
3976
|
upsert: (chat: AiChat) => void;
|
|
3852
3977
|
upsertMany: (chats: AiChat[]) => void;
|
|
3853
3978
|
remove: (chatId: string) => void;
|
|
3854
3979
|
};
|
|
3980
|
+
/** @private This API will change, and is not considered stable. DO NOT RELY on it. */
|
|
3855
3981
|
type Ai = {
|
|
3856
3982
|
[kInternal]: {
|
|
3857
|
-
|
|
3983
|
+
context: AiContext;
|
|
3858
3984
|
};
|
|
3859
3985
|
connect: () => void;
|
|
3860
3986
|
reconnect: () => void;
|
|
3861
3987
|
disconnect: () => void;
|
|
3862
3988
|
getStatus: () => Status;
|
|
3989
|
+
/** @private This API will change, and is not considered stable. DO NOT RELY on it. */
|
|
3863
3990
|
getChats: (options?: {
|
|
3864
3991
|
cursor?: Cursor;
|
|
3865
3992
|
}) => Promise<GetChatsResponse>;
|
|
3866
|
-
|
|
3867
|
-
|
|
3868
|
-
|
|
3993
|
+
/** @private This API will change, and is not considered stable. DO NOT RELY on it. */
|
|
3994
|
+
getOrCreateChat: (
|
|
3995
|
+
/** A unique identifier for the chat. */
|
|
3996
|
+
chatId: string, options?: CreateChatOptions) => Promise<GetOrCreateChatResponse>;
|
|
3997
|
+
/** @private This API will change, and is not considered stable. DO NOT RELY on it. */
|
|
3869
3998
|
deleteChat: (chatId: string) => Promise<DeleteChatResponse>;
|
|
3999
|
+
/** @private This API will change, and is not considered stable. DO NOT RELY on it. */
|
|
3870
4000
|
getMessageTree: (chatId: string) => Promise<GetMessageTreeResponse>;
|
|
4001
|
+
/** @private This API will change, and is not considered stable. DO NOT RELY on it. */
|
|
3871
4002
|
deleteMessage: (chatId: string, messageId: MessageId) => Promise<DeleteMessageResponse>;
|
|
4003
|
+
/** @private This API will change, and is not considered stable. DO NOT RELY on it. */
|
|
3872
4004
|
clearChat: (chatId: string) => Promise<ClearChatResponse>;
|
|
3873
|
-
|
|
3874
|
-
|
|
3875
|
-
|
|
3876
|
-
|
|
4005
|
+
/** @private This API will change, and is not considered stable. DO NOT RELY on it. */
|
|
4006
|
+
askUserMessageInChat: (chatId: string, userMessage: MessageId | {
|
|
4007
|
+
id: MessageId;
|
|
4008
|
+
parentMessageId: MessageId | null;
|
|
4009
|
+
content: AiUserContentPart[];
|
|
4010
|
+
}, targetMessageId: MessageId, options?: AiGenerationOptions) => Promise<AskInChatResponse>;
|
|
4011
|
+
/** @private This API will change, and is not considered stable. DO NOT RELY on it. */
|
|
3877
4012
|
abort: (messageId: MessageId) => Promise<AbortAiResponse>;
|
|
4013
|
+
/** @private This API will change, and is not considered stable. DO NOT RELY on it. */
|
|
4014
|
+
setToolResult: (chatId: string, messageId: MessageId, toolCallId: string, result: ToolResultData, options?: AiGenerationOptions) => Promise<SetToolResultResponse>;
|
|
4015
|
+
/** @private This API will change, and is not considered stable. DO NOT RELY on it. */
|
|
3878
4016
|
signals: {
|
|
3879
4017
|
chatsΣ: DerivedSignal<AiChat[]>;
|
|
3880
4018
|
getChatMessagesForBranchΣ(chatId: string, branch?: MessageId): DerivedSignal<UiChatMessage[]>;
|
|
3881
|
-
|
|
3882
|
-
getToolDefinitionΣ(chatId: string, toolName: string): Signal<ClientToolDefinition | undefined>;
|
|
4019
|
+
getToolDefinitionΣ(chatId: string, toolName: string): Signal<AiOpaqueToolDefinition | undefined>;
|
|
3883
4020
|
};
|
|
3884
|
-
|
|
3885
|
-
|
|
4021
|
+
/** @private This API will change, and is not considered stable. DO NOT RELY on it. */
|
|
4022
|
+
getChatById: (chatId: string) => AiChat | undefined;
|
|
4023
|
+
/** @private This API will change, and is not considered stable. DO NOT RELY on it. */
|
|
4024
|
+
registerKnowledgeLayer: (uniqueLayerId: string) => LayerKey;
|
|
4025
|
+
/** @private This API will change, and is not considered stable. DO NOT RELY on it. */
|
|
4026
|
+
deregisterKnowledgeLayer: (layerKey: LayerKey) => void;
|
|
4027
|
+
/** @private This API will change, and is not considered stable. DO NOT RELY on it. */
|
|
4028
|
+
updateKnowledge: (layerKey: LayerKey, data: AiKnowledgeSource, key?: string) => void;
|
|
4029
|
+
/** @private This API will change, and is not considered stable. DO NOT RELY on it. */
|
|
4030
|
+
registerChatTool: (chatId: string, name: string, definition: AiOpaqueToolDefinition) => void;
|
|
4031
|
+
/** @private This API will change, and is not considered stable. DO NOT RELY on it. */
|
|
3886
4032
|
unregisterChatTool: (chatId: string, toolName: string) => void;
|
|
3887
4033
|
};
|
|
3888
4034
|
|
|
@@ -4674,4 +4820,4 @@ declare const CommentsApiError: typeof HttpError;
|
|
|
4674
4820
|
/** @deprecated Use HttpError instead. */
|
|
4675
4821
|
declare const NotificationsApiError: typeof HttpError;
|
|
4676
4822
|
|
|
4677
|
-
export { type AckOp, type ActivityData, type AiAssistantContentPart, type AiChat, type
|
|
4823
|
+
export { type AckOp, type ActivityData, type AiAssistantContentPart, type AiChat, type AiChatMessage, type AiKnowledgeSource, type AiOpaqueToolDefinition, type AiOpaqueToolInvocationProps, type AiReasoningPart, type AiTextPart, type AiToolDefinition, type AiToolExecuteCallback, type AiToolExecuteContext, type AiToolInvocationPart, type AiToolInvocationProps, type AiToolTypePack, 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, 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 MessageId, MutableSignal, type NoInfr, type NodeMap, type NotificationChannel, type NotificationChannelSettings, type NotificationKind, type NotificationSettings, type NotificationSettingsPlain, NotificationsApiError, 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 Resolve, type ResolveMentionSuggestionsArgs, type ResolveRoomsInfoArgs, type ResolveUsersArgs, type Room, type RoomEventMessage, type RoomNotificationSettings, 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 ToolResultData, type URLSafeString, type UiAssistantMessage, type UiChatMessage, type UiUserMessage, type UnsubscribeCallback, type UpdateObjectOp, type UpdatePresenceClientMsg, type UpdatePresenceServerMsg, type UpdateStorageClientMsg, type UpdateStorageServerMsg, type UpdateYDocClientMsg, type UploadAttachmentOptions, type User, type UserJoinServerMsg, type UserLeftServerMsg, type UserNotificationSettings, type UserRoomSubscriptionSettings, type UserSubscriptionData, type UserSubscriptionDataPlain, WebsocketCloseCodes, 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, freeze, generateCommentUrl, getMentionedIdsFromCommentBody, getSubscriptionKey, html, htmlSafe, isChildCrdt, isCommentBodyLink, isCommentBodyMention, isCommentBodyText, isJsonArray, isJsonObject, isJsonScalar, isLiveNode, isNotificationChannelEnabled, isPlainObject, isRootCrdt, isStartsWithOperator, kInternal, keys, legacy_patchImmutableObject, lsonToJson, makeAbortController, makeEventSource, makePoller, makePosition, mapValues, memoizeOnSuccess, nanoid, nn, objectToQuery, patchLiveObjectKey, patchNotificationSettings, raise, resolveUsersInCommentBody, shallow, shallow2, stableStringify, stringifyCommentBody, throwUsageError, toAbsoluteUrl, toPlainLson, tryParseJson, url, urljoin, wait, withTimeout };
|