@convex-dev/agent 0.0.1-alpha.1 → 0.0.1-alpha.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. package/README.md +293 -6
  2. package/dist/commonjs/client/index.d.ts +520 -96
  3. package/dist/commonjs/client/index.d.ts.map +1 -1
  4. package/dist/commonjs/client/index.js +210 -131
  5. package/dist/commonjs/client/index.js.map +1 -1
  6. package/dist/commonjs/client/types.d.ts +3 -0
  7. package/dist/commonjs/client/types.d.ts.map +1 -1
  8. package/dist/commonjs/component/messages.d.ts +57 -56
  9. package/dist/commonjs/component/messages.d.ts.map +1 -1
  10. package/dist/commonjs/component/messages.js +184 -147
  11. package/dist/commonjs/component/messages.js.map +1 -1
  12. package/dist/commonjs/component/schema.d.ts +260 -256
  13. package/dist/commonjs/component/schema.d.ts.map +1 -1
  14. package/dist/commonjs/component/schema.js +25 -18
  15. package/dist/commonjs/component/schema.js.map +1 -1
  16. package/dist/commonjs/component/vector/index.d.ts +4 -4
  17. package/dist/commonjs/component/vector/index.d.ts.map +1 -1
  18. package/dist/commonjs/component/vector/index.js +12 -10
  19. package/dist/commonjs/component/vector/index.js.map +1 -1
  20. package/dist/commonjs/component/vector/tables.d.ts +3 -3
  21. package/dist/commonjs/component/vector/tables.js +6 -6
  22. package/dist/commonjs/component/vector/tables.js.map +1 -1
  23. package/dist/commonjs/mapping.d.ts +6 -1
  24. package/dist/commonjs/mapping.d.ts.map +1 -1
  25. package/dist/commonjs/mapping.js +25 -0
  26. package/dist/commonjs/mapping.js.map +1 -1
  27. package/dist/commonjs/validators.d.ts +1376 -1
  28. package/dist/commonjs/validators.d.ts.map +1 -1
  29. package/dist/commonjs/validators.js +28 -1
  30. package/dist/commonjs/validators.js.map +1 -1
  31. package/dist/esm/client/index.d.ts +520 -96
  32. package/dist/esm/client/index.d.ts.map +1 -1
  33. package/dist/esm/client/index.js +210 -131
  34. package/dist/esm/client/index.js.map +1 -1
  35. package/dist/esm/client/types.d.ts +3 -0
  36. package/dist/esm/client/types.d.ts.map +1 -1
  37. package/dist/esm/component/messages.d.ts +57 -56
  38. package/dist/esm/component/messages.d.ts.map +1 -1
  39. package/dist/esm/component/messages.js +184 -147
  40. package/dist/esm/component/messages.js.map +1 -1
  41. package/dist/esm/component/schema.d.ts +260 -256
  42. package/dist/esm/component/schema.d.ts.map +1 -1
  43. package/dist/esm/component/schema.js +25 -18
  44. package/dist/esm/component/schema.js.map +1 -1
  45. package/dist/esm/component/vector/index.d.ts +4 -4
  46. package/dist/esm/component/vector/index.d.ts.map +1 -1
  47. package/dist/esm/component/vector/index.js +12 -10
  48. package/dist/esm/component/vector/index.js.map +1 -1
  49. package/dist/esm/component/vector/tables.d.ts +3 -3
  50. package/dist/esm/component/vector/tables.js +6 -6
  51. package/dist/esm/component/vector/tables.js.map +1 -1
  52. package/dist/esm/mapping.d.ts +6 -1
  53. package/dist/esm/mapping.d.ts.map +1 -1
  54. package/dist/esm/mapping.js +25 -0
  55. package/dist/esm/mapping.js.map +1 -1
  56. package/dist/esm/validators.d.ts +1376 -1
  57. package/dist/esm/validators.d.ts.map +1 -1
  58. package/dist/esm/validators.js +28 -1
  59. package/dist/esm/validators.js.map +1 -1
  60. package/package.json +3 -3
  61. package/src/client/index.ts +384 -276
  62. package/src/client/types.ts +4 -0
  63. package/src/component/_generated/api.d.ts +54 -53
  64. package/src/component/messages.ts +219 -177
  65. package/src/component/schema.ts +25 -18
  66. package/src/component/vector/index.ts +13 -11
  67. package/src/component/vector/tables.ts +6 -6
  68. package/src/mapping.ts +46 -11
  69. package/src/validators.test.ts +9 -0
  70. package/src/validators.ts +36 -1
@@ -7,6 +7,10 @@ import {
7
7
  GenericActionCtx,
8
8
  } from "convex/server";
9
9
  import { GenericId } from "convex/values";
10
+ import type { Doc } from "../component/_generated/dataModel";
11
+
12
+ export type ThreadDoc = OpaqueIds<Doc<"threads">>;
13
+ export type MessageDoc = OpaqueIds<Doc<"messages">>;
10
14
 
11
15
  /* Type utils follow */
12
16
  export type RunQueryCtx = {
@@ -40,7 +40,6 @@ export type Mounts = {
40
40
  "public",
41
41
  {
42
42
  agentName?: string;
43
- chatId: string;
44
43
  failPendingSteps?: boolean;
45
44
  messages: Array<{
46
45
  fileId?: string;
@@ -147,13 +146,14 @@ export type Mounts = {
147
146
  parentMessageId?: string;
148
147
  pending?: boolean;
149
148
  stepId?: string;
149
+ threadId?: string;
150
+ userId?: string;
150
151
  },
151
152
  {
152
153
  messages: Array<{
153
154
  _creationTime: number;
154
155
  _id: string;
155
156
  agentName?: string;
156
- chatId: string;
157
157
  embeddingId?:
158
158
  | string
159
159
  | string
@@ -265,6 +265,7 @@ export type Mounts = {
265
265
  };
266
266
  model?: string;
267
267
  order: number;
268
+ parentMessageId?: string;
268
269
  status: "pending" | "success" | "failed";
269
270
  stepId?: string;
270
271
  stepOrder?: number;
@@ -277,7 +278,6 @@ export type Mounts = {
277
278
  _creationTime: number;
278
279
  _id: string;
279
280
  agentName?: string;
280
- chatId: string;
281
281
  embeddingId?:
282
282
  | string
283
283
  | string
@@ -389,6 +389,7 @@ export type Mounts = {
389
389
  };
390
390
  model?: string;
391
391
  order: number;
392
+ parentMessageId?: string;
392
393
  status: "pending" | "success" | "failed";
393
394
  stepId?: string;
394
395
  stepOrder?: number;
@@ -403,7 +404,6 @@ export type Mounts = {
403
404
  "mutation",
404
405
  "public",
405
406
  {
406
- chatId: string;
407
407
  failPendingSteps?: boolean;
408
408
  messageId: string;
409
409
  steps: Array<{
@@ -710,11 +710,11 @@ export type Mounts = {
710
710
  >;
711
711
  };
712
712
  }>;
713
+ threadId: string;
713
714
  },
714
715
  Array<{
715
716
  _creationTime: number;
716
717
  _id: string;
717
- chatId: string;
718
718
  order: number;
719
719
  parentMessageId: string;
720
720
  status: "pending" | "success" | "failed";
@@ -916,18 +916,19 @@ export type Mounts = {
916
916
  >;
917
917
  };
918
918
  stepOrder: number;
919
+ threadId: string;
919
920
  }>
920
921
  >;
921
- archiveChat: FunctionReference<
922
+ archiveThread: FunctionReference<
922
923
  "mutation",
923
924
  "public",
924
- { chatId: string },
925
+ { threadId: string },
925
926
  {
926
927
  _creationTime: number;
927
928
  _id: string;
928
929
  defaultSystemPrompt?: string;
929
930
  order?: number;
930
- parentChatIds?: Array<string>;
931
+ parentThreadIds?: Array<string>;
931
932
  status: "active" | "archived";
932
933
  summary?: string;
933
934
  title?: string;
@@ -940,12 +941,12 @@ export type Mounts = {
940
941
  { messageId: string },
941
942
  null
942
943
  >;
943
- createChat: FunctionReference<
944
+ createThread: FunctionReference<
944
945
  "mutation",
945
946
  "public",
946
947
  {
947
948
  defaultSystemPrompt?: string;
948
- parentChatIds?: Array<string>;
949
+ parentThreadIds?: Array<string>;
949
950
  summary?: string;
950
951
  title?: string;
951
952
  userId?: string;
@@ -955,23 +956,23 @@ export type Mounts = {
955
956
  _id: string;
956
957
  defaultSystemPrompt?: string;
957
958
  order?: number;
958
- parentChatIds?: Array<string>;
959
+ parentThreadIds?: Array<string>;
959
960
  status: "active" | "archived";
960
961
  summary?: string;
961
962
  title?: string;
962
963
  userId?: string;
963
964
  }
964
965
  >;
965
- deleteAllForChatIdAsync: FunctionReference<
966
+ deleteAllForThreadIdAsync: FunctionReference<
966
967
  "mutation",
967
968
  "public",
968
- { chatId: string; cursor?: string; limit?: number },
969
+ { cursor?: string; limit?: number; threadId: string },
969
970
  { cursor: string; isDone: boolean }
970
971
  >;
971
- deleteAllForChatIdSync: FunctionReference<
972
+ deleteAllForThreadIdSync: FunctionReference<
972
973
  "action",
973
974
  "public",
974
- { chatId: string; cursor?: string; limit?: number },
975
+ { cursor?: string; limit?: number; threadId: string },
975
976
  { cursor: string; isDone: boolean }
976
977
  >;
977
978
  deleteAllForUserId: FunctionReference<
@@ -986,33 +987,49 @@ export type Mounts = {
986
987
  { userId: string },
987
988
  boolean
988
989
  >;
989
- getChat: FunctionReference<
990
+ getFilesToDelete: FunctionReference<
990
991
  "query",
991
992
  "public",
992
- { chatId: string },
993
+ { cursor?: string; limit?: number },
994
+ {
995
+ continueCursor: string;
996
+ files: Array<{
997
+ _creationTime: number;
998
+ _id: string;
999
+ hash: string;
1000
+ refcount: number;
1001
+ storageId: string;
1002
+ }>;
1003
+ isDone: boolean;
1004
+ }
1005
+ >;
1006
+ getThread: FunctionReference<
1007
+ "query",
1008
+ "public",
1009
+ { threadId: string },
993
1010
  {
994
1011
  _creationTime: number;
995
1012
  _id: string;
996
1013
  defaultSystemPrompt?: string;
997
1014
  order?: number;
998
- parentChatIds?: Array<string>;
1015
+ parentThreadIds?: Array<string>;
999
1016
  status: "active" | "archived";
1000
1017
  summary?: string;
1001
1018
  title?: string;
1002
1019
  userId?: string;
1003
1020
  } | null
1004
1021
  >;
1005
- getChatMessages: FunctionReference<
1022
+ getThreadMessages: FunctionReference<
1006
1023
  "query",
1007
1024
  "public",
1008
1025
  {
1009
- chatId: string;
1010
1026
  cursor?: string;
1011
1027
  isTool?: boolean;
1012
1028
  limit?: number;
1013
1029
  order?: "asc" | "desc";
1014
1030
  parentMessageId?: string;
1015
1031
  statuses?: Array<"pending" | "success" | "failed">;
1032
+ threadId: string;
1016
1033
  },
1017
1034
  {
1018
1035
  continueCursor: string;
@@ -1021,7 +1038,6 @@ export type Mounts = {
1021
1038
  _creationTime: number;
1022
1039
  _id: string;
1023
1040
  agentName?: string;
1024
- chatId: string;
1025
1041
  embeddingId?:
1026
1042
  | string
1027
1043
  | string
@@ -1133,6 +1149,7 @@ export type Mounts = {
1133
1149
  };
1134
1150
  model?: string;
1135
1151
  order: number;
1152
+ parentMessageId?: string;
1136
1153
  status: "pending" | "success" | "failed";
1137
1154
  stepId?: string;
1138
1155
  stepOrder?: number;
@@ -1143,7 +1160,7 @@ export type Mounts = {
1143
1160
  }>;
1144
1161
  }
1145
1162
  >;
1146
- getChatsByUserId: FunctionReference<
1163
+ getThreadsByUserId: FunctionReference<
1147
1164
  "query",
1148
1165
  "public",
1149
1166
  {
@@ -1154,35 +1171,19 @@ export type Mounts = {
1154
1171
  userId: string;
1155
1172
  },
1156
1173
  {
1157
- chats: Array<{
1174
+ continueCursor: string;
1175
+ isDone: boolean;
1176
+ threads: Array<{
1158
1177
  _creationTime: number;
1159
1178
  _id: string;
1160
1179
  defaultSystemPrompt?: string;
1161
1180
  order?: number;
1162
- parentChatIds?: Array<string>;
1181
+ parentThreadIds?: Array<string>;
1163
1182
  status: "active" | "archived";
1164
1183
  summary?: string;
1165
1184
  title?: string;
1166
1185
  userId?: string;
1167
1186
  }>;
1168
- continueCursor: string;
1169
- isDone: boolean;
1170
- }
1171
- >;
1172
- getFilesToDelete: FunctionReference<
1173
- "query",
1174
- "public",
1175
- { cursor?: string; limit?: number },
1176
- {
1177
- continueCursor: string;
1178
- files: Array<{
1179
- _creationTime: number;
1180
- _id: string;
1181
- hash: string;
1182
- refcount: number;
1183
- storageId: string;
1184
- }>;
1185
- isDone: boolean;
1186
1187
  }
1187
1188
  >;
1188
1189
  rollbackMessage: FunctionReference<
@@ -1195,11 +1196,11 @@ export type Mounts = {
1195
1196
  "action",
1196
1197
  "public",
1197
1198
  {
1198
- chatId?: string;
1199
1199
  limit: number;
1200
1200
  messageRange?: { after: number; before: number };
1201
1201
  parentMessageId?: string;
1202
1202
  text?: string;
1203
+ threadId?: string;
1203
1204
  userId?: string;
1204
1205
  vector?: Array<number>;
1205
1206
  vectorModel?: string;
@@ -1208,7 +1209,6 @@ export type Mounts = {
1208
1209
  _creationTime: number;
1209
1210
  _id: string;
1210
1211
  agentName?: string;
1211
- chatId: string;
1212
1212
  embeddingId?:
1213
1213
  | string
1214
1214
  | string
@@ -1320,6 +1320,7 @@ export type Mounts = {
1320
1320
  };
1321
1321
  model?: string;
1322
1322
  order: number;
1323
+ parentMessageId?: string;
1323
1324
  status: "pending" | "success" | "failed";
1324
1325
  stepId?: string;
1325
1326
  stepOrder?: number;
@@ -1332,12 +1333,11 @@ export type Mounts = {
1332
1333
  textSearch: FunctionReference<
1333
1334
  "query",
1334
1335
  "public",
1335
- { chatId?: string; limit: number; text: string; userId?: string },
1336
+ { limit: number; text: string; threadId?: string; userId?: string },
1336
1337
  Array<{
1337
1338
  _creationTime: number;
1338
1339
  _id: string;
1339
1340
  agentName?: string;
1340
- chatId: string;
1341
1341
  embeddingId?:
1342
1342
  | string
1343
1343
  | string
@@ -1449,6 +1449,7 @@ export type Mounts = {
1449
1449
  };
1450
1450
  model?: string;
1451
1451
  order: number;
1452
+ parentMessageId?: string;
1452
1453
  status: "pending" | "success" | "failed";
1453
1454
  stepId?: string;
1454
1455
  stepOrder?: number;
@@ -1458,24 +1459,24 @@ export type Mounts = {
1458
1459
  userId?: string;
1459
1460
  }>
1460
1461
  >;
1461
- updateChat: FunctionReference<
1462
+ updateThread: FunctionReference<
1462
1463
  "mutation",
1463
1464
  "public",
1464
1465
  {
1465
- chatId: string;
1466
1466
  patch: {
1467
1467
  defaultSystemPrompt?: string;
1468
1468
  status?: "active" | "archived";
1469
1469
  summary?: string;
1470
1470
  title?: string;
1471
1471
  };
1472
+ threadId: string;
1472
1473
  },
1473
1474
  {
1474
1475
  _creationTime: number;
1475
1476
  _id: string;
1476
1477
  defaultSystemPrompt?: string;
1477
1478
  order?: number;
1478
- parentChatIds?: Array<string>;
1479
+ parentThreadIds?: Array<string>;
1479
1480
  status: "active" | "archived";
1480
1481
  summary?: string;
1481
1482
  title?: string;
@@ -1503,14 +1504,14 @@ export type Mounts = {
1503
1504
  },
1504
1505
  null
1505
1506
  >;
1506
- deleteBatchForChat: FunctionReference<
1507
+ deleteBatchForThread: FunctionReference<
1507
1508
  "mutation",
1508
1509
  "public",
1509
1510
  {
1510
- chatId: string;
1511
1511
  cursor?: string;
1512
1512
  limit: number;
1513
1513
  model: string;
1514
+ threadId: string;
1514
1515
  vectorDimension:
1515
1516
  | 128
1516
1517
  | 256
@@ -1539,9 +1540,9 @@ export type Mounts = {
1539
1540
  | 3072
1540
1541
  | 4096;
1541
1542
  vectors: Array<{
1542
- chatId?: string;
1543
- kind: "chat" | "memory";
1543
+ kind: "thread" | "memory";
1544
1544
  model: string;
1545
+ threadId?: string;
1545
1546
  userId?: string;
1546
1547
  vector: Array<number>;
1547
1548
  }>;