@convex-dev/agent 0.1.13-alpha.1 → 0.1.13-alpha.2

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.
@@ -1723,6 +1723,36 @@ export type Mounts = {
1723
1723
  splitCursor?: string | null;
1724
1724
  }
1725
1725
  >;
1726
+ searchThreadTitles: FunctionReference<
1727
+ "query",
1728
+ "public",
1729
+ {
1730
+ paginationOpts?: {
1731
+ cursor: string | null;
1732
+ endCursor?: string | null;
1733
+ id?: number;
1734
+ maximumBytesRead?: number;
1735
+ maximumRowsRead?: number;
1736
+ numItems: number;
1737
+ };
1738
+ query: string;
1739
+ userId?: string | null;
1740
+ },
1741
+ {
1742
+ continueCursor: string;
1743
+ isDone: boolean;
1744
+ page: Array<{
1745
+ _creationTime: number;
1746
+ _id: string;
1747
+ status: "active" | "archived";
1748
+ summary?: string;
1749
+ title?: string;
1750
+ userId?: string;
1751
+ }>;
1752
+ pageStatus?: "SplitRecommended" | "SplitRequired" | null;
1753
+ splitCursor?: string | null;
1754
+ }
1755
+ >;
1726
1756
  updateThread: FunctionReference<
1727
1757
  "mutation",
1728
1758
  "public",
@@ -27,7 +27,12 @@ export const schema = defineSchema({
27
27
  defaultSystemPrompt: v.optional(v.string()),
28
28
  parentThreadIds: v.optional(v.array(v.id("threads"))),
29
29
  order: /*DEPRECATED*/ v.optional(v.number()),
30
- }).index("userId", ["userId"]),
30
+ })
31
+ .index("userId", ["userId"])
32
+ .searchIndex("title", {
33
+ searchField: "title",
34
+ filterFields: ["userId"],
35
+ }),
31
36
  messages: defineTable({
32
37
  id: v.optional(v.string()), // external id, e.g. from Vercel AI SDK
33
38
  userId: v.optional(v.string()), // useful for searching across threads
@@ -92,6 +92,29 @@ export const updateThread = mutation({
92
92
  returns: vThreadDoc,
93
93
  });
94
94
 
95
+ export const searchThreadTitles = query({
96
+ args: {
97
+ query: v.string(),
98
+ userId: v.optional(v.union(v.string(), v.null())),
99
+ paginationOpts: v.optional(paginationOptsValidator),
100
+ },
101
+ handler: async (ctx, args) => {
102
+ const threads = await ctx.db
103
+ .query("threads")
104
+ .withSearchIndex("title", (q) =>
105
+ args.userId
106
+ ? q.search("title", args.query).eq("userId", args.userId ?? undefined)
107
+ : q.search("title", args.query)
108
+ )
109
+ .paginate(args.paginationOpts ?? { cursor: null, numItems: 100 });
110
+ return {
111
+ ...threads,
112
+ page: threads.page.map(publicThread),
113
+ };
114
+ },
115
+ returns: vPaginationResult(vThreadDoc),
116
+ });
117
+
95
118
  // When we expose this, we need to also hide all the messages and steps
96
119
  // export const archiveThread = mutation({
97
120
  // args: { threadId: v.id("threads") },