@convex-dev/agent 0.1.13-alpha.0 → 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.
- package/dist/esm/client/createTool.d.ts +2 -2
- package/dist/esm/client/createTool.d.ts.map +1 -1
- package/dist/esm/client/index.d.ts +6 -0
- package/dist/esm/client/index.d.ts.map +1 -1
- package/dist/esm/client/index.js +33 -1
- package/dist/esm/client/index.js.map +1 -1
- package/dist/esm/client/types.d.ts +9 -1
- package/dist/esm/client/types.d.ts.map +1 -1
- package/dist/esm/component/_generated/api.d.ts +30 -0
- package/dist/esm/component/schema.d.ts +24 -4
- package/dist/esm/component/schema.d.ts.map +1 -1
- package/dist/esm/component/schema.js +6 -1
- package/dist/esm/component/schema.js.map +1 -1
- package/dist/esm/component/threads.d.ts +25 -0
- package/dist/esm/component/threads.d.ts.map +1 -1
- package/dist/esm/component/threads.js +20 -0
- package/dist/esm/component/threads.js.map +1 -1
- package/dist/esm.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/client/createTool.ts +2 -2
- package/src/client/index.test.ts +18 -17
- package/src/client/index.ts +40 -1
- package/src/client/types.ts +11 -0
- package/src/component/_generated/api.d.ts +30 -0
- package/src/component/schema.ts +6 -1
- package/src/component/threads.ts +23 -0
package/src/client/types.ts
CHANGED
|
@@ -19,12 +19,15 @@ import type {
|
|
|
19
19
|
ToolSet,
|
|
20
20
|
} from "ai";
|
|
21
21
|
import type {
|
|
22
|
+
Auth,
|
|
22
23
|
Expand,
|
|
23
24
|
FunctionReference,
|
|
24
25
|
GenericActionCtx,
|
|
25
26
|
GenericDataModel,
|
|
26
27
|
GenericMutationCtx,
|
|
27
28
|
GenericQueryCtx,
|
|
29
|
+
PaginationOptions,
|
|
30
|
+
PaginationResult,
|
|
28
31
|
StorageActionWriter,
|
|
29
32
|
StorageReader,
|
|
30
33
|
WithoutSystemFields,
|
|
@@ -351,6 +354,13 @@ export interface Thread<DefaultTools extends ToolSet> {
|
|
|
351
354
|
updateMetadata: (
|
|
352
355
|
patch: Partial<WithoutSystemFields<ThreadDoc>>
|
|
353
356
|
) => Promise<ThreadDoc>;
|
|
357
|
+
/**
|
|
358
|
+
* Search for threads by title.
|
|
359
|
+
*/
|
|
360
|
+
searchThreadTitles(args: {
|
|
361
|
+
query: string;
|
|
362
|
+
paginationOpts?: PaginationOptions;
|
|
363
|
+
}): Promise<PaginationResult<ThreadDoc>>;
|
|
354
364
|
/**
|
|
355
365
|
* This behaves like {@link generateText} from the "ai" package except that
|
|
356
366
|
* it add context based on the userId and threadId and saves the input and
|
|
@@ -495,6 +505,7 @@ export type RunActionCtx = {
|
|
|
495
505
|
runAction: GenericActionCtx<GenericDataModel>["runAction"];
|
|
496
506
|
};
|
|
497
507
|
export type ActionCtx = RunActionCtx & {
|
|
508
|
+
auth: Auth;
|
|
498
509
|
storage: StorageActionWriter;
|
|
499
510
|
};
|
|
500
511
|
export type QueryCtx = RunQueryCtx & {
|
|
@@ -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",
|
package/src/component/schema.ts
CHANGED
|
@@ -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
|
-
})
|
|
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
|
package/src/component/threads.ts
CHANGED
|
@@ -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") },
|