@convex-dev/agent 0.1.1 → 0.1.2-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -3
- package/dist/commonjs/client/createTool.d.ts +49 -0
- package/dist/commonjs/client/createTool.d.ts.map +1 -0
- package/dist/commonjs/client/createTool.js +45 -0
- package/dist/commonjs/client/createTool.js.map +1 -0
- package/dist/commonjs/client/index.d.ts +101 -322
- package/dist/commonjs/client/index.d.ts.map +1 -1
- package/dist/commonjs/client/index.js +142 -194
- package/dist/commonjs/client/index.js.map +1 -1
- package/dist/commonjs/client/streaming.d.ts +54 -0
- package/dist/commonjs/client/streaming.d.ts.map +1 -0
- package/dist/commonjs/client/streaming.js +121 -0
- package/dist/commonjs/client/streaming.js.map +1 -0
- package/dist/commonjs/client/types.d.ts +290 -2
- package/dist/commonjs/client/types.d.ts.map +1 -1
- package/dist/commonjs/component/messages.d.ts +104 -138
- package/dist/commonjs/component/messages.d.ts.map +1 -1
- package/dist/commonjs/component/messages.js +15 -14
- package/dist/commonjs/component/messages.js.map +1 -1
- package/dist/commonjs/component/schema.d.ts +873 -3
- package/dist/commonjs/component/schema.d.ts.map +1 -1
- package/dist/commonjs/component/schema.js +44 -1
- package/dist/commonjs/component/schema.js.map +1 -1
- package/dist/commonjs/component/streams.d.ts +191 -0
- package/dist/commonjs/component/streams.d.ts.map +1 -0
- package/dist/commonjs/component/streams.js +169 -0
- package/dist/commonjs/component/streams.js.map +1 -0
- package/dist/commonjs/component/threads.d.ts +1 -1
- package/dist/commonjs/component/threads.js +3 -3
- package/dist/commonjs/component/threads.js.map +1 -1
- package/dist/commonjs/component/users.js +2 -2
- package/dist/commonjs/component/users.js.map +1 -1
- package/dist/commonjs/mapping.d.ts.map +1 -1
- package/dist/commonjs/mapping.js +3 -1
- package/dist/commonjs/mapping.js.map +1 -1
- package/dist/commonjs/react/index.d.ts +99 -0
- package/dist/commonjs/react/index.d.ts.map +1 -1
- package/dist/commonjs/react/index.js +505 -1
- package/dist/commonjs/react/index.js.map +1 -1
- package/dist/commonjs/react/toUIMessages.d.ts +8 -0
- package/dist/commonjs/react/toUIMessages.d.ts.map +1 -0
- package/dist/commonjs/react/toUIMessages.js +134 -0
- package/dist/commonjs/react/toUIMessages.js.map +1 -0
- package/dist/commonjs/validators.d.ts +506 -4
- package/dist/commonjs/validators.d.ts.map +1 -1
- package/dist/commonjs/validators.js +49 -2
- package/dist/commonjs/validators.js.map +1 -1
- package/dist/esm/client/createTool.d.ts +49 -0
- package/dist/esm/client/createTool.d.ts.map +1 -0
- package/dist/esm/client/createTool.js +45 -0
- package/dist/esm/client/createTool.js.map +1 -0
- package/dist/esm/client/index.d.ts +101 -322
- package/dist/esm/client/index.d.ts.map +1 -1
- package/dist/esm/client/index.js +142 -194
- package/dist/esm/client/index.js.map +1 -1
- package/dist/esm/client/streaming.d.ts +54 -0
- package/dist/esm/client/streaming.d.ts.map +1 -0
- package/dist/esm/client/streaming.js +121 -0
- package/dist/esm/client/streaming.js.map +1 -0
- package/dist/esm/client/types.d.ts +290 -2
- package/dist/esm/client/types.d.ts.map +1 -1
- package/dist/esm/component/messages.d.ts +104 -138
- package/dist/esm/component/messages.d.ts.map +1 -1
- package/dist/esm/component/messages.js +15 -14
- package/dist/esm/component/messages.js.map +1 -1
- package/dist/esm/component/schema.d.ts +873 -3
- package/dist/esm/component/schema.d.ts.map +1 -1
- package/dist/esm/component/schema.js +44 -1
- package/dist/esm/component/schema.js.map +1 -1
- package/dist/esm/component/streams.d.ts +191 -0
- package/dist/esm/component/streams.d.ts.map +1 -0
- package/dist/esm/component/streams.js +169 -0
- package/dist/esm/component/streams.js.map +1 -0
- package/dist/esm/component/threads.d.ts +1 -1
- package/dist/esm/component/threads.js +3 -3
- package/dist/esm/component/threads.js.map +1 -1
- package/dist/esm/component/users.js +2 -2
- package/dist/esm/component/users.js.map +1 -1
- package/dist/esm/mapping.d.ts.map +1 -1
- package/dist/esm/mapping.js +3 -1
- package/dist/esm/mapping.js.map +1 -1
- package/dist/esm/react/index.d.ts +99 -0
- package/dist/esm/react/index.d.ts.map +1 -1
- package/dist/esm/react/index.js +505 -1
- package/dist/esm/react/index.js.map +1 -1
- package/dist/esm/react/toUIMessages.d.ts +8 -0
- package/dist/esm/react/toUIMessages.d.ts.map +1 -0
- package/dist/esm/react/toUIMessages.js +134 -0
- package/dist/esm/react/toUIMessages.js.map +1 -0
- package/dist/esm/validators.d.ts +506 -4
- package/dist/esm/validators.d.ts.map +1 -1
- package/dist/esm/validators.js +49 -2
- package/dist/esm/validators.js.map +1 -1
- package/package.json +5 -1
- package/src/client/createTool.ts +108 -0
- package/src/client/index.ts +270 -689
- package/src/client/streaming.ts +166 -0
- package/src/client/types.ts +430 -5
- package/src/component/_generated/api.d.ts +339 -188
- package/src/component/messages.ts +15 -14
- package/src/component/schema.ts +51 -0
- package/src/component/streams.ts +206 -0
- package/src/component/threads.ts +3 -3
- package/src/component/users.ts +2 -2
- package/src/mapping.ts +3 -1
- package/src/react/index.ts +687 -1
- package/src/react/toUIMessages.ts +153 -0
- package/src/validators.test.ts +18 -0
- package/src/validators.ts +72 -2
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
import type * as apiKeys from "../apiKeys.js";
|
|
12
12
|
import type * as files from "../files.js";
|
|
13
13
|
import type * as messages from "../messages.js";
|
|
14
|
+
import type * as streams from "../streams.js";
|
|
14
15
|
import type * as threads from "../threads.js";
|
|
15
16
|
import type * as users from "../users.js";
|
|
16
17
|
import type * as vector_index from "../vector/index.js";
|
|
@@ -34,6 +35,7 @@ declare const fullApi: ApiFromModules<{
|
|
|
34
35
|
apiKeys: typeof apiKeys;
|
|
35
36
|
files: typeof files;
|
|
36
37
|
messages: typeof messages;
|
|
38
|
+
streams: typeof streams;
|
|
37
39
|
threads: typeof threads;
|
|
38
40
|
users: typeof users;
|
|
39
41
|
"vector/index": typeof vector_index;
|
|
@@ -899,196 +901,142 @@ export type Mounts = {
|
|
|
899
901
|
Array<{
|
|
900
902
|
_creationTime: number;
|
|
901
903
|
_id: string;
|
|
904
|
+
agentName?: string;
|
|
905
|
+
embeddingId?: string;
|
|
906
|
+
error?: string;
|
|
907
|
+
files?: Array<{
|
|
908
|
+
data?: ArrayBuffer | string;
|
|
909
|
+
fileId?: string;
|
|
910
|
+
mimeType: string;
|
|
911
|
+
url?: string;
|
|
912
|
+
}>;
|
|
913
|
+
finishReason?:
|
|
914
|
+
| "stop"
|
|
915
|
+
| "length"
|
|
916
|
+
| "content-filter"
|
|
917
|
+
| "tool-calls"
|
|
918
|
+
| "error"
|
|
919
|
+
| "other"
|
|
920
|
+
| "unknown";
|
|
921
|
+
id?: string;
|
|
922
|
+
message?:
|
|
923
|
+
| {
|
|
924
|
+
content:
|
|
925
|
+
| string
|
|
926
|
+
| Array<
|
|
927
|
+
| {
|
|
928
|
+
providerOptions?: Record<string, Record<string, any>>;
|
|
929
|
+
text: string;
|
|
930
|
+
type: "text";
|
|
931
|
+
}
|
|
932
|
+
| {
|
|
933
|
+
image: string | ArrayBuffer;
|
|
934
|
+
mimeType?: string;
|
|
935
|
+
providerOptions?: Record<string, Record<string, any>>;
|
|
936
|
+
type: "image";
|
|
937
|
+
}
|
|
938
|
+
| {
|
|
939
|
+
data: string | ArrayBuffer;
|
|
940
|
+
mimeType: string;
|
|
941
|
+
providerOptions?: Record<string, Record<string, any>>;
|
|
942
|
+
type: "file";
|
|
943
|
+
}
|
|
944
|
+
>;
|
|
945
|
+
providerOptions?: Record<string, Record<string, any>>;
|
|
946
|
+
role: "user";
|
|
947
|
+
}
|
|
948
|
+
| {
|
|
949
|
+
content:
|
|
950
|
+
| string
|
|
951
|
+
| Array<
|
|
952
|
+
| {
|
|
953
|
+
providerOptions?: Record<string, Record<string, any>>;
|
|
954
|
+
text: string;
|
|
955
|
+
type: "text";
|
|
956
|
+
}
|
|
957
|
+
| {
|
|
958
|
+
data: string | ArrayBuffer;
|
|
959
|
+
mimeType: string;
|
|
960
|
+
providerOptions?: Record<string, Record<string, any>>;
|
|
961
|
+
type: "file";
|
|
962
|
+
}
|
|
963
|
+
| {
|
|
964
|
+
providerOptions?: Record<string, Record<string, any>>;
|
|
965
|
+
signature?: string;
|
|
966
|
+
text: string;
|
|
967
|
+
type: "reasoning";
|
|
968
|
+
}
|
|
969
|
+
| {
|
|
970
|
+
data: string;
|
|
971
|
+
providerOptions?: Record<string, Record<string, any>>;
|
|
972
|
+
type: "redacted-reasoning";
|
|
973
|
+
}
|
|
974
|
+
| {
|
|
975
|
+
args: any;
|
|
976
|
+
providerOptions?: Record<string, Record<string, any>>;
|
|
977
|
+
toolCallId: string;
|
|
978
|
+
toolName: string;
|
|
979
|
+
type: "tool-call";
|
|
980
|
+
}
|
|
981
|
+
>;
|
|
982
|
+
providerOptions?: Record<string, Record<string, any>>;
|
|
983
|
+
role: "assistant";
|
|
984
|
+
}
|
|
985
|
+
| {
|
|
986
|
+
content: Array<{
|
|
987
|
+
args?: any;
|
|
988
|
+
experimental_content?: Array<
|
|
989
|
+
| { text: string; type: "text" }
|
|
990
|
+
| { data: string; mimeType?: string; type: "image" }
|
|
991
|
+
>;
|
|
992
|
+
isError?: boolean;
|
|
993
|
+
providerOptions?: Record<string, Record<string, any>>;
|
|
994
|
+
result: any;
|
|
995
|
+
toolCallId: string;
|
|
996
|
+
toolName: string;
|
|
997
|
+
type: "tool-result";
|
|
998
|
+
}>;
|
|
999
|
+
providerOptions?: Record<string, Record<string, any>>;
|
|
1000
|
+
role: "tool";
|
|
1001
|
+
}
|
|
1002
|
+
| {
|
|
1003
|
+
content: string;
|
|
1004
|
+
providerOptions?: Record<string, Record<string, any>>;
|
|
1005
|
+
role: "system";
|
|
1006
|
+
};
|
|
1007
|
+
model?: string;
|
|
902
1008
|
order: number;
|
|
903
|
-
|
|
1009
|
+
provider?: string;
|
|
1010
|
+
providerMetadata?: Record<string, Record<string, any>>;
|
|
1011
|
+
providerOptions?: Record<string, Record<string, any>>;
|
|
1012
|
+
reasoning?: string;
|
|
1013
|
+
reasoningDetails?: Array<
|
|
1014
|
+
| { signature?: string; text: string; type: "text" }
|
|
1015
|
+
| { data: string; type: "redacted" }
|
|
1016
|
+
>;
|
|
1017
|
+
sources?: Array<{
|
|
1018
|
+
id: string;
|
|
1019
|
+
providerOptions?: Record<string, Record<string, any>>;
|
|
1020
|
+
sourceType: "url";
|
|
1021
|
+
title?: string;
|
|
1022
|
+
url: string;
|
|
1023
|
+
}>;
|
|
904
1024
|
status: "pending" | "success" | "failed";
|
|
905
|
-
step: {
|
|
906
|
-
experimental_providerMetadata?: Record<string, Record<string, any>>;
|
|
907
|
-
files?: Array<any>;
|
|
908
|
-
finishReason:
|
|
909
|
-
| "stop"
|
|
910
|
-
| "length"
|
|
911
|
-
| "content-filter"
|
|
912
|
-
| "tool-calls"
|
|
913
|
-
| "error"
|
|
914
|
-
| "other"
|
|
915
|
-
| "unknown";
|
|
916
|
-
isContinued: boolean;
|
|
917
|
-
logprobs?: any;
|
|
918
|
-
providerMetadata?: Record<string, Record<string, any>>;
|
|
919
|
-
reasoning?: string;
|
|
920
|
-
reasoningDetails?: Array<
|
|
921
|
-
| { signature?: string; text: string; type: "text" }
|
|
922
|
-
| { data: string; type: "redacted" }
|
|
923
|
-
>;
|
|
924
|
-
request?: {
|
|
925
|
-
body?: any;
|
|
926
|
-
headers?: Record<string, string>;
|
|
927
|
-
method?: string;
|
|
928
|
-
url?: string;
|
|
929
|
-
};
|
|
930
|
-
response?: {
|
|
931
|
-
body?: any;
|
|
932
|
-
headers?: Record<string, string>;
|
|
933
|
-
id: string;
|
|
934
|
-
messages: Array<{
|
|
935
|
-
fileId?: string;
|
|
936
|
-
id?: string;
|
|
937
|
-
message:
|
|
938
|
-
| {
|
|
939
|
-
content:
|
|
940
|
-
| string
|
|
941
|
-
| Array<
|
|
942
|
-
| {
|
|
943
|
-
providerOptions?: Record<
|
|
944
|
-
string,
|
|
945
|
-
Record<string, any>
|
|
946
|
-
>;
|
|
947
|
-
text: string;
|
|
948
|
-
type: "text";
|
|
949
|
-
}
|
|
950
|
-
| {
|
|
951
|
-
image: string | ArrayBuffer;
|
|
952
|
-
mimeType?: string;
|
|
953
|
-
providerOptions?: Record<
|
|
954
|
-
string,
|
|
955
|
-
Record<string, any>
|
|
956
|
-
>;
|
|
957
|
-
type: "image";
|
|
958
|
-
}
|
|
959
|
-
| {
|
|
960
|
-
data: string | ArrayBuffer;
|
|
961
|
-
mimeType: string;
|
|
962
|
-
providerOptions?: Record<
|
|
963
|
-
string,
|
|
964
|
-
Record<string, any>
|
|
965
|
-
>;
|
|
966
|
-
type: "file";
|
|
967
|
-
}
|
|
968
|
-
>;
|
|
969
|
-
providerOptions?: Record<string, Record<string, any>>;
|
|
970
|
-
role: "user";
|
|
971
|
-
}
|
|
972
|
-
| {
|
|
973
|
-
content:
|
|
974
|
-
| string
|
|
975
|
-
| Array<
|
|
976
|
-
| {
|
|
977
|
-
providerOptions?: Record<
|
|
978
|
-
string,
|
|
979
|
-
Record<string, any>
|
|
980
|
-
>;
|
|
981
|
-
text: string;
|
|
982
|
-
type: "text";
|
|
983
|
-
}
|
|
984
|
-
| {
|
|
985
|
-
data: string | ArrayBuffer;
|
|
986
|
-
mimeType: string;
|
|
987
|
-
providerOptions?: Record<
|
|
988
|
-
string,
|
|
989
|
-
Record<string, any>
|
|
990
|
-
>;
|
|
991
|
-
type: "file";
|
|
992
|
-
}
|
|
993
|
-
| {
|
|
994
|
-
providerOptions?: Record<
|
|
995
|
-
string,
|
|
996
|
-
Record<string, any>
|
|
997
|
-
>;
|
|
998
|
-
signature?: string;
|
|
999
|
-
text: string;
|
|
1000
|
-
type: "reasoning";
|
|
1001
|
-
}
|
|
1002
|
-
| {
|
|
1003
|
-
data: string;
|
|
1004
|
-
providerOptions?: Record<
|
|
1005
|
-
string,
|
|
1006
|
-
Record<string, any>
|
|
1007
|
-
>;
|
|
1008
|
-
type: "redacted-reasoning";
|
|
1009
|
-
}
|
|
1010
|
-
| {
|
|
1011
|
-
args: any;
|
|
1012
|
-
providerOptions?: Record<
|
|
1013
|
-
string,
|
|
1014
|
-
Record<string, any>
|
|
1015
|
-
>;
|
|
1016
|
-
toolCallId: string;
|
|
1017
|
-
toolName: string;
|
|
1018
|
-
type: "tool-call";
|
|
1019
|
-
}
|
|
1020
|
-
>;
|
|
1021
|
-
providerOptions?: Record<string, Record<string, any>>;
|
|
1022
|
-
role: "assistant";
|
|
1023
|
-
}
|
|
1024
|
-
| {
|
|
1025
|
-
content: Array<{
|
|
1026
|
-
args?: any;
|
|
1027
|
-
experimental_content?: Array<
|
|
1028
|
-
| { text: string; type: "text" }
|
|
1029
|
-
| { data: string; mimeType?: string; type: "image" }
|
|
1030
|
-
>;
|
|
1031
|
-
isError?: boolean;
|
|
1032
|
-
providerOptions?: Record<string, Record<string, any>>;
|
|
1033
|
-
result: any;
|
|
1034
|
-
toolCallId: string;
|
|
1035
|
-
toolName: string;
|
|
1036
|
-
type: "tool-result";
|
|
1037
|
-
}>;
|
|
1038
|
-
providerOptions?: Record<string, Record<string, any>>;
|
|
1039
|
-
role: "tool";
|
|
1040
|
-
}
|
|
1041
|
-
| {
|
|
1042
|
-
content: string;
|
|
1043
|
-
providerOptions?: Record<string, Record<string, any>>;
|
|
1044
|
-
role: "system";
|
|
1045
|
-
};
|
|
1046
|
-
}>;
|
|
1047
|
-
modelId: string;
|
|
1048
|
-
timestamp: number;
|
|
1049
|
-
};
|
|
1050
|
-
sources?: Array<{
|
|
1051
|
-
id: string;
|
|
1052
|
-
providerOptions?: Record<string, Record<string, any>>;
|
|
1053
|
-
sourceType: "url";
|
|
1054
|
-
title?: string;
|
|
1055
|
-
url: string;
|
|
1056
|
-
}>;
|
|
1057
|
-
stepType: "initial" | "continue" | "tool-result";
|
|
1058
|
-
text: string;
|
|
1059
|
-
toolCalls: Array<{
|
|
1060
|
-
args: any;
|
|
1061
|
-
providerOptions?: Record<string, Record<string, any>>;
|
|
1062
|
-
toolCallId: string;
|
|
1063
|
-
toolName: string;
|
|
1064
|
-
type: "tool-call";
|
|
1065
|
-
}>;
|
|
1066
|
-
toolResults: Array<{
|
|
1067
|
-
args?: any;
|
|
1068
|
-
experimental_content?: Array<
|
|
1069
|
-
| { text: string; type: "text" }
|
|
1070
|
-
| { data: string; mimeType?: string; type: "image" }
|
|
1071
|
-
>;
|
|
1072
|
-
isError?: boolean;
|
|
1073
|
-
providerOptions?: Record<string, Record<string, any>>;
|
|
1074
|
-
result: any;
|
|
1075
|
-
toolCallId: string;
|
|
1076
|
-
toolName: string;
|
|
1077
|
-
type: "tool-result";
|
|
1078
|
-
}>;
|
|
1079
|
-
usage?: {
|
|
1080
|
-
completionTokens: number;
|
|
1081
|
-
promptTokens: number;
|
|
1082
|
-
totalTokens: number;
|
|
1083
|
-
};
|
|
1084
|
-
warnings?: Array<
|
|
1085
|
-
| { details?: string; setting: string; type: "unsupported-setting" }
|
|
1086
|
-
| { details?: string; tool: any; type: "unsupported-tool" }
|
|
1087
|
-
| { message: string; type: "other" }
|
|
1088
|
-
>;
|
|
1089
|
-
};
|
|
1090
1025
|
stepOrder: number;
|
|
1026
|
+
text?: string;
|
|
1091
1027
|
threadId: string;
|
|
1028
|
+
tool: boolean;
|
|
1029
|
+
usage?: {
|
|
1030
|
+
completionTokens: number;
|
|
1031
|
+
promptTokens: number;
|
|
1032
|
+
totalTokens: number;
|
|
1033
|
+
};
|
|
1034
|
+
userId?: string;
|
|
1035
|
+
warnings?: Array<
|
|
1036
|
+
| { details?: string; setting: string; type: "unsupported-setting" }
|
|
1037
|
+
| { details?: string; tool: any; type: "unsupported-tool" }
|
|
1038
|
+
| { message: string; type: "other" }
|
|
1039
|
+
>;
|
|
1092
1040
|
}>
|
|
1093
1041
|
>;
|
|
1094
1042
|
commitMessage: FunctionReference<
|
|
@@ -1254,7 +1202,7 @@ export type Mounts = {
|
|
|
1254
1202
|
{
|
|
1255
1203
|
excludeToolMessages?: boolean;
|
|
1256
1204
|
isTool?: "use excludeToolMessages instead of this";
|
|
1257
|
-
order
|
|
1205
|
+
order: "asc" | "desc";
|
|
1258
1206
|
paginationOpts?: {
|
|
1259
1207
|
cursor: string | null;
|
|
1260
1208
|
endCursor?: string | null;
|
|
@@ -1727,6 +1675,209 @@ export type Mounts = {
|
|
|
1727
1675
|
}>
|
|
1728
1676
|
>;
|
|
1729
1677
|
};
|
|
1678
|
+
streams: {
|
|
1679
|
+
addDelta: FunctionReference<
|
|
1680
|
+
"mutation",
|
|
1681
|
+
"public",
|
|
1682
|
+
{
|
|
1683
|
+
end: number;
|
|
1684
|
+
parts: Array<
|
|
1685
|
+
| { textDelta: string; type: "text-delta" }
|
|
1686
|
+
| { textDelta: string; type: "reasoning" }
|
|
1687
|
+
| {
|
|
1688
|
+
source: {
|
|
1689
|
+
id: string;
|
|
1690
|
+
providerOptions?: Record<string, Record<string, any>>;
|
|
1691
|
+
sourceType: "url";
|
|
1692
|
+
title?: string;
|
|
1693
|
+
url: string;
|
|
1694
|
+
};
|
|
1695
|
+
type: "source";
|
|
1696
|
+
}
|
|
1697
|
+
| {
|
|
1698
|
+
args: any;
|
|
1699
|
+
providerOptions?: Record<string, Record<string, any>>;
|
|
1700
|
+
toolCallId: string;
|
|
1701
|
+
toolName: string;
|
|
1702
|
+
type: "tool-call";
|
|
1703
|
+
}
|
|
1704
|
+
| {
|
|
1705
|
+
toolCallId: string;
|
|
1706
|
+
toolName: string;
|
|
1707
|
+
type: "tool-call-streaming-start";
|
|
1708
|
+
}
|
|
1709
|
+
| {
|
|
1710
|
+
argsTextDelta: string;
|
|
1711
|
+
toolCallId: string;
|
|
1712
|
+
toolName: string;
|
|
1713
|
+
type: "tool-call-delta";
|
|
1714
|
+
}
|
|
1715
|
+
| {
|
|
1716
|
+
args?: any;
|
|
1717
|
+
experimental_content?: Array<
|
|
1718
|
+
| { text: string; type: "text" }
|
|
1719
|
+
| { data: string; mimeType?: string; type: "image" }
|
|
1720
|
+
>;
|
|
1721
|
+
isError?: boolean;
|
|
1722
|
+
providerOptions?: Record<string, Record<string, any>>;
|
|
1723
|
+
result: any;
|
|
1724
|
+
toolCallId: string;
|
|
1725
|
+
toolName: string;
|
|
1726
|
+
type: "tool-result";
|
|
1727
|
+
}
|
|
1728
|
+
>;
|
|
1729
|
+
start: number;
|
|
1730
|
+
streamId: string;
|
|
1731
|
+
},
|
|
1732
|
+
null
|
|
1733
|
+
>;
|
|
1734
|
+
create: FunctionReference<
|
|
1735
|
+
"mutation",
|
|
1736
|
+
"public",
|
|
1737
|
+
{
|
|
1738
|
+
agentName?: string;
|
|
1739
|
+
model?: string;
|
|
1740
|
+
order: number;
|
|
1741
|
+
provider?: string;
|
|
1742
|
+
providerOptions?: Record<string, Record<string, any>>;
|
|
1743
|
+
stepOrder: number;
|
|
1744
|
+
threadId: string;
|
|
1745
|
+
userId?: string;
|
|
1746
|
+
},
|
|
1747
|
+
string
|
|
1748
|
+
>;
|
|
1749
|
+
finish: FunctionReference<
|
|
1750
|
+
"mutation",
|
|
1751
|
+
"public",
|
|
1752
|
+
{
|
|
1753
|
+
finalDelta?: {
|
|
1754
|
+
end: number;
|
|
1755
|
+
parts: Array<
|
|
1756
|
+
| { textDelta: string; type: "text-delta" }
|
|
1757
|
+
| { textDelta: string; type: "reasoning" }
|
|
1758
|
+
| {
|
|
1759
|
+
source: {
|
|
1760
|
+
id: string;
|
|
1761
|
+
providerOptions?: Record<string, Record<string, any>>;
|
|
1762
|
+
sourceType: "url";
|
|
1763
|
+
title?: string;
|
|
1764
|
+
url: string;
|
|
1765
|
+
};
|
|
1766
|
+
type: "source";
|
|
1767
|
+
}
|
|
1768
|
+
| {
|
|
1769
|
+
args: any;
|
|
1770
|
+
providerOptions?: Record<string, Record<string, any>>;
|
|
1771
|
+
toolCallId: string;
|
|
1772
|
+
toolName: string;
|
|
1773
|
+
type: "tool-call";
|
|
1774
|
+
}
|
|
1775
|
+
| {
|
|
1776
|
+
toolCallId: string;
|
|
1777
|
+
toolName: string;
|
|
1778
|
+
type: "tool-call-streaming-start";
|
|
1779
|
+
}
|
|
1780
|
+
| {
|
|
1781
|
+
argsTextDelta: string;
|
|
1782
|
+
toolCallId: string;
|
|
1783
|
+
toolName: string;
|
|
1784
|
+
type: "tool-call-delta";
|
|
1785
|
+
}
|
|
1786
|
+
| {
|
|
1787
|
+
args?: any;
|
|
1788
|
+
experimental_content?: Array<
|
|
1789
|
+
| { text: string; type: "text" }
|
|
1790
|
+
| { data: string; mimeType?: string; type: "image" }
|
|
1791
|
+
>;
|
|
1792
|
+
isError?: boolean;
|
|
1793
|
+
providerOptions?: Record<string, Record<string, any>>;
|
|
1794
|
+
result: any;
|
|
1795
|
+
toolCallId: string;
|
|
1796
|
+
toolName: string;
|
|
1797
|
+
type: "tool-result";
|
|
1798
|
+
}
|
|
1799
|
+
>;
|
|
1800
|
+
start: number;
|
|
1801
|
+
streamId: string;
|
|
1802
|
+
};
|
|
1803
|
+
streamId: string;
|
|
1804
|
+
},
|
|
1805
|
+
null
|
|
1806
|
+
>;
|
|
1807
|
+
list: FunctionReference<
|
|
1808
|
+
"query",
|
|
1809
|
+
"public",
|
|
1810
|
+
{ threadId: string },
|
|
1811
|
+
Array<{
|
|
1812
|
+
agentName?: string;
|
|
1813
|
+
model?: string;
|
|
1814
|
+
order: number;
|
|
1815
|
+
provider?: string;
|
|
1816
|
+
providerOptions?: Record<string, Record<string, any>>;
|
|
1817
|
+
stepOrder: number;
|
|
1818
|
+
streamId: string;
|
|
1819
|
+
userId?: string;
|
|
1820
|
+
}>
|
|
1821
|
+
>;
|
|
1822
|
+
listDeltas: FunctionReference<
|
|
1823
|
+
"query",
|
|
1824
|
+
"public",
|
|
1825
|
+
{
|
|
1826
|
+
cursors: Array<{ cursor: number; streamId: string }>;
|
|
1827
|
+
threadId: string;
|
|
1828
|
+
},
|
|
1829
|
+
Array<{
|
|
1830
|
+
end: number;
|
|
1831
|
+
parts: Array<
|
|
1832
|
+
| { textDelta: string; type: "text-delta" }
|
|
1833
|
+
| { textDelta: string; type: "reasoning" }
|
|
1834
|
+
| {
|
|
1835
|
+
source: {
|
|
1836
|
+
id: string;
|
|
1837
|
+
providerOptions?: Record<string, Record<string, any>>;
|
|
1838
|
+
sourceType: "url";
|
|
1839
|
+
title?: string;
|
|
1840
|
+
url: string;
|
|
1841
|
+
};
|
|
1842
|
+
type: "source";
|
|
1843
|
+
}
|
|
1844
|
+
| {
|
|
1845
|
+
args: any;
|
|
1846
|
+
providerOptions?: Record<string, Record<string, any>>;
|
|
1847
|
+
toolCallId: string;
|
|
1848
|
+
toolName: string;
|
|
1849
|
+
type: "tool-call";
|
|
1850
|
+
}
|
|
1851
|
+
| {
|
|
1852
|
+
toolCallId: string;
|
|
1853
|
+
toolName: string;
|
|
1854
|
+
type: "tool-call-streaming-start";
|
|
1855
|
+
}
|
|
1856
|
+
| {
|
|
1857
|
+
argsTextDelta: string;
|
|
1858
|
+
toolCallId: string;
|
|
1859
|
+
toolName: string;
|
|
1860
|
+
type: "tool-call-delta";
|
|
1861
|
+
}
|
|
1862
|
+
| {
|
|
1863
|
+
args?: any;
|
|
1864
|
+
experimental_content?: Array<
|
|
1865
|
+
| { text: string; type: "text" }
|
|
1866
|
+
| { data: string; mimeType?: string; type: "image" }
|
|
1867
|
+
>;
|
|
1868
|
+
isError?: boolean;
|
|
1869
|
+
providerOptions?: Record<string, Record<string, any>>;
|
|
1870
|
+
result: any;
|
|
1871
|
+
toolCallId: string;
|
|
1872
|
+
toolName: string;
|
|
1873
|
+
type: "tool-result";
|
|
1874
|
+
}
|
|
1875
|
+
>;
|
|
1876
|
+
start: number;
|
|
1877
|
+
streamId: string;
|
|
1878
|
+
}>
|
|
1879
|
+
>;
|
|
1880
|
+
};
|
|
1730
1881
|
threads: {
|
|
1731
1882
|
createThread: FunctionReference<
|
|
1732
1883
|
"mutation",
|
|
@@ -1785,7 +1936,7 @@ export type Mounts = {
|
|
|
1785
1936
|
maximumRowsRead?: number;
|
|
1786
1937
|
numItems: number;
|
|
1787
1938
|
};
|
|
1788
|
-
userId
|
|
1939
|
+
userId?: string;
|
|
1789
1940
|
},
|
|
1790
1941
|
{
|
|
1791
1942
|
continueCursor: string;
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
isTool,
|
|
9
9
|
} from "../shared.js";
|
|
10
10
|
import {
|
|
11
|
-
|
|
11
|
+
vPaginationResult,
|
|
12
12
|
vMessageEmbeddings,
|
|
13
13
|
vMessageStatus,
|
|
14
14
|
vMessageWithMetadata,
|
|
@@ -180,11 +180,12 @@ async function addMessagesHandler(
|
|
|
180
180
|
error: fail ? "Parent message failed" : undefined,
|
|
181
181
|
stepOrder,
|
|
182
182
|
});
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
}
|
|
183
|
+
// Let's just not set the id field and have it set only in explicit cases.
|
|
184
|
+
// if (!message.id) {
|
|
185
|
+
// await ctx.db.patch(messageId, {
|
|
186
|
+
// id: messageId,
|
|
187
|
+
// });
|
|
188
|
+
// }
|
|
188
189
|
for (const { fileId } of message.files ?? []) {
|
|
189
190
|
if (!fileId) continue;
|
|
190
191
|
await ctx.db.patch(fileId, {
|
|
@@ -214,7 +215,7 @@ function orderedMessagesStream(
|
|
|
214
215
|
) {
|
|
215
216
|
return mergedStream(
|
|
216
217
|
[true, false].flatMap((tool) =>
|
|
217
|
-
|
|
218
|
+
messageStatuses.map((status) =>
|
|
218
219
|
stream(ctx.db, schema)
|
|
219
220
|
.query("messages")
|
|
220
221
|
.withIndex("threadId_status_tool_order_stepOrder", (q) => {
|
|
@@ -244,7 +245,7 @@ const addStepArgs = {
|
|
|
244
245
|
|
|
245
246
|
export const addStep = mutation({
|
|
246
247
|
args: addStepArgs,
|
|
247
|
-
returns: v.array(
|
|
248
|
+
returns: v.array(vMessageDoc),
|
|
248
249
|
handler: addStepHandler,
|
|
249
250
|
});
|
|
250
251
|
async function addStepHandler(
|
|
@@ -279,7 +280,7 @@ async function addStepHandler(
|
|
|
279
280
|
status: step.finishReason === "stop" ? "success" : "pending",
|
|
280
281
|
step,
|
|
281
282
|
});
|
|
282
|
-
await addMessagesHandler(ctx, {
|
|
283
|
+
const added = await addMessagesHandler(ctx, {
|
|
283
284
|
userId: args.userId,
|
|
284
285
|
threadId: args.threadId,
|
|
285
286
|
stepId,
|
|
@@ -293,8 +294,7 @@ async function addStepHandler(
|
|
|
293
294
|
if (step.finishReason === "stop") {
|
|
294
295
|
await commitMessageHandler(ctx, { messageId: args.promptMessageId });
|
|
295
296
|
}
|
|
296
|
-
|
|
297
|
-
return steps;
|
|
297
|
+
return added.messages.map(publicMessage);
|
|
298
298
|
}
|
|
299
299
|
|
|
300
300
|
export const rollbackMessage = mutation({
|
|
@@ -388,7 +388,8 @@ export const listMessagesByThreadId = query({
|
|
|
388
388
|
excludeToolMessages: v.optional(v.boolean()),
|
|
389
389
|
/** @deprecated Use excludeToolMessages instead. */
|
|
390
390
|
isTool: v.optional(v.literal("use excludeToolMessages instead of this")),
|
|
391
|
-
order
|
|
391
|
+
/** What order to sort the messages in. To get the latest, use "desc". */
|
|
392
|
+
order: v.union(v.literal("asc"), v.literal("desc")),
|
|
392
393
|
paginationOpts: v.optional(paginationOptsValidator),
|
|
393
394
|
statuses: v.optional(v.array(vMessageStatus)),
|
|
394
395
|
upToAndIncludingMessageId: v.optional(v.id("messages")),
|
|
@@ -439,7 +440,7 @@ export const listMessagesByThreadId = query({
|
|
|
439
440
|
);
|
|
440
441
|
return { ...messages, page: messages.page.map(publicMessage) };
|
|
441
442
|
},
|
|
442
|
-
returns:
|
|
443
|
+
returns: vPaginationResult(vMessageDoc),
|
|
443
444
|
});
|
|
444
445
|
|
|
445
446
|
/** @deprecated Use listMessagesByThreadId instead. */
|
|
@@ -448,7 +449,7 @@ export const getThreadMessages = query({
|
|
|
448
449
|
handler: async () => {
|
|
449
450
|
throw new Error("Use listMessagesByThreadId instead of getThreadMessages");
|
|
450
451
|
},
|
|
451
|
-
returns:
|
|
452
|
+
returns: vPaginationResult(vMessageDoc),
|
|
452
453
|
});
|
|
453
454
|
|
|
454
455
|
export const searchMessages = action({
|