@convex-dev/agent 0.1.0 → 0.1.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/dist/commonjs/component/files.d.ts +18 -4
- package/dist/commonjs/component/files.d.ts.map +1 -1
- package/dist/commonjs/component/files.js +49 -5
- package/dist/commonjs/component/files.js.map +1 -1
- package/dist/commonjs/component/messages.d.ts +5 -5
- package/dist/commonjs/component/schema.d.ts +152 -48
- package/dist/commonjs/component/schema.d.ts.map +1 -1
- package/dist/commonjs/component/vector/index.d.ts +8 -8
- package/dist/commonjs/component/vector/index.d.ts.map +1 -1
- package/dist/commonjs/component/vector/tables.d.ts +5 -5
- package/dist/commonjs/component/vector/tables.d.ts.map +1 -1
- package/dist/commonjs/component/vector/tables.js +1 -1
- package/dist/commonjs/component/vector/tables.js.map +1 -1
- package/dist/commonjs/validators.d.ts +7 -7
- package/dist/esm/component/files.d.ts +18 -4
- package/dist/esm/component/files.d.ts.map +1 -1
- package/dist/esm/component/files.js +49 -5
- package/dist/esm/component/files.js.map +1 -1
- package/dist/esm/component/messages.d.ts +5 -5
- package/dist/esm/component/schema.d.ts +152 -48
- package/dist/esm/component/schema.d.ts.map +1 -1
- package/dist/esm/component/vector/index.d.ts +8 -8
- package/dist/esm/component/vector/index.d.ts.map +1 -1
- package/dist/esm/component/vector/tables.d.ts +5 -5
- package/dist/esm/component/vector/tables.d.ts.map +1 -1
- package/dist/esm/component/vector/tables.js +1 -1
- package/dist/esm/component/vector/tables.js.map +1 -1
- package/dist/esm/validators.d.ts +7 -7
- package/package.json +2 -2
- package/src/component/_generated/api.d.ts +33 -6
- package/src/component/files.ts +50 -5
- package/src/component/vector/tables.ts +1 -1
|
@@ -3,15 +3,29 @@ import { Id } from "./_generated/dataModel.js";
|
|
|
3
3
|
export declare const addFile: import("convex/server").RegisteredMutation<"public", {
|
|
4
4
|
storageId: string;
|
|
5
5
|
hash: string;
|
|
6
|
-
}, Promise<
|
|
6
|
+
}, Promise<{
|
|
7
|
+
fileId: import("convex/values").GenericId<"files">;
|
|
8
|
+
storageIdUnused: boolean;
|
|
9
|
+
}>>;
|
|
7
10
|
export declare function addFileHandler(ctx: MutationCtx, args: {
|
|
8
11
|
storageId: string;
|
|
9
12
|
hash: string;
|
|
10
|
-
}): Promise<
|
|
11
|
-
|
|
13
|
+
}): Promise<{
|
|
14
|
+
fileId: import("convex/values").GenericId<"files">;
|
|
15
|
+
storageIdUnused: boolean;
|
|
16
|
+
}>;
|
|
17
|
+
/**
|
|
18
|
+
* If you plan to have the same file added over and over without a reference to
|
|
19
|
+
* the fileId, you can use this query to get the fileId of the existing file.
|
|
20
|
+
* And if it's
|
|
21
|
+
*/
|
|
22
|
+
export declare const useExistingFile: import("convex/server").RegisteredMutation<"public", {
|
|
23
|
+
hash: string;
|
|
24
|
+
}, Promise<import("convex/values").GenericId<"files"> | null>>;
|
|
25
|
+
export declare const copyFile: import("convex/server").RegisteredMutation<"public", {
|
|
12
26
|
fileId: Id<"files">;
|
|
13
27
|
}, Promise<void>>;
|
|
14
|
-
export declare function
|
|
28
|
+
export declare function copyFileHandler(ctx: MutationCtx, args: {
|
|
15
29
|
fileId: Id<"files">;
|
|
16
30
|
}): Promise<void>;
|
|
17
31
|
export declare const getFilesToDelete: import("convex/server").RegisteredQuery<"public", {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"files.d.ts","sourceRoot":"","sources":["../../../src/component/files.ts"],"names":[],"mappings":"AACA,OAAO,EAAY,WAAW,EAAS,MAAM,wBAAwB,CAAC;AAEtE,OAAO,EAAE,EAAE,EAAE,MAAM,2BAA2B,CAAC;AAE/C,eAAO,MAAM,OAAO;
|
|
1
|
+
{"version":3,"file":"files.d.ts","sourceRoot":"","sources":["../../../src/component/files.ts"],"names":[],"mappings":"AACA,OAAO,EAAY,WAAW,EAAS,MAAM,wBAAwB,CAAC;AAEtE,OAAO,EAAE,EAAE,EAAE,MAAM,2BAA2B,CAAC;AAE/C,eAAO,MAAM,OAAO;eAcC,MAAM;UAAQ,MAAM;;;;GAJvC,CAAC;AAEH,wBAAsB,cAAc,CAClC,GAAG,EAAE,WAAW,EAChB,IAAI,EAAE;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE;;;GAyB1C;AAED;;;;GAIG;AACH,eAAO,MAAM,eAAe;;8DAkB1B,CAAC;AAEH,eAAO,MAAM,QAAQ;YAUH,EAAE,CAAC,OAAO,CAAC;iBAJ3B,CAAC;AAEH,wBAAsB,eAAe,CACnC,GAAG,EAAE,WAAW,EAChB,IAAI,EAAE;IAAE,MAAM,EAAE,EAAE,CAAC,OAAO,CAAC,CAAA;CAAE,iBAS9B;AAED,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;GAwB3B,CAAC"}
|
|
@@ -7,24 +7,68 @@ export const addFile = mutation({
|
|
|
7
7
|
hash: v.string(),
|
|
8
8
|
},
|
|
9
9
|
handler: addFileHandler,
|
|
10
|
-
returns:
|
|
10
|
+
returns: {
|
|
11
|
+
fileId: v.id("files"),
|
|
12
|
+
storageIdUnused: v.boolean(),
|
|
13
|
+
},
|
|
11
14
|
});
|
|
12
15
|
export async function addFileHandler(ctx, args) {
|
|
16
|
+
const existingFile = await ctx.db
|
|
17
|
+
.query("files")
|
|
18
|
+
.withIndex("hash", (q) => q.eq("hash", args.hash))
|
|
19
|
+
.first();
|
|
20
|
+
if (existingFile) {
|
|
21
|
+
// increment the refcount
|
|
22
|
+
await ctx.db.patch(existingFile._id, {
|
|
23
|
+
refcount: existingFile.refcount + 1,
|
|
24
|
+
});
|
|
25
|
+
return {
|
|
26
|
+
fileId: existingFile._id,
|
|
27
|
+
storageIdUnused: existingFile.storageId !== args.storageId,
|
|
28
|
+
};
|
|
29
|
+
}
|
|
13
30
|
const fileId = await ctx.db.insert("files", {
|
|
14
31
|
storageId: args.storageId,
|
|
15
32
|
hash: args.hash,
|
|
16
33
|
refcount: 1,
|
|
17
34
|
});
|
|
18
|
-
return
|
|
35
|
+
return {
|
|
36
|
+
fileId,
|
|
37
|
+
storageIdUnused: false,
|
|
38
|
+
};
|
|
19
39
|
}
|
|
20
|
-
|
|
40
|
+
/**
|
|
41
|
+
* If you plan to have the same file added over and over without a reference to
|
|
42
|
+
* the fileId, you can use this query to get the fileId of the existing file.
|
|
43
|
+
* And if it's
|
|
44
|
+
*/
|
|
45
|
+
export const useExistingFile = mutation({
|
|
46
|
+
args: {
|
|
47
|
+
hash: v.string(),
|
|
48
|
+
},
|
|
49
|
+
handler: async (ctx, args) => {
|
|
50
|
+
const file = await ctx.db
|
|
51
|
+
.query("files")
|
|
52
|
+
.withIndex("hash", (q) => q.eq("hash", args.hash))
|
|
53
|
+
.first();
|
|
54
|
+
if (!file) {
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
57
|
+
await ctx.db.patch(file._id, {
|
|
58
|
+
refcount: file.refcount + 1,
|
|
59
|
+
});
|
|
60
|
+
return file._id;
|
|
61
|
+
},
|
|
62
|
+
returns: v.union(v.id("files"), v.null()),
|
|
63
|
+
});
|
|
64
|
+
export const copyFile = mutation({
|
|
21
65
|
args: {
|
|
22
66
|
fileId: v.id("files"),
|
|
23
67
|
},
|
|
24
|
-
handler:
|
|
68
|
+
handler: copyFileHandler,
|
|
25
69
|
returns: v.null(),
|
|
26
70
|
});
|
|
27
|
-
export async function
|
|
71
|
+
export async function copyFileHandler(ctx, args) {
|
|
28
72
|
const file = await ctx.db.get(args.fileId);
|
|
29
73
|
if (!file) {
|
|
30
74
|
throw new Error("File not found");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"files.js","sourceRoot":"","sources":["../../../src/component/files.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAC;AAC7D,OAAO,EAAE,QAAQ,EAAe,KAAK,EAAE,MAAM,wBAAwB,CAAC;AACtE,OAAO,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,aAAa,C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,EAAE,IAAI,CAAC,MAAM,IAAI,IAAI;SAC5B,CAAC,CAAC;QACL,OAAO;YACL,KAAK,EAAE,KAAK,CAAC,IAAI;YACjB,cAAc,EAAE,KAAK,CAAC,cAAc;YACpC,MAAM,EAAE,KAAK,CAAC,MAAM;SACrB,CAAC;IACJ,CAAC;IACD,OAAO,EAAE,CAAC,CAAC,MAAM,CAAC;QAChB,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QAC9B,cAAc,EAAE,CAAC,CAAC,MAAM,EAAE;QAC1B,MAAM,EAAE,CAAC,CAAC,OAAO,EAAE;KACpB,CAAC;CACH,CAAC,CAAC"}
|
|
@@ -62,7 +62,7 @@ export declare const addMessages: import("convex/server").RegisteredMutation<"pu
|
|
|
62
62
|
stepId?: import("convex/values").GenericId<"steps"> | undefined;
|
|
63
63
|
embeddings?: {
|
|
64
64
|
model: string;
|
|
65
|
-
dimension: 128 | 256 | 512 | 768 | 1024 | 1536 | 2048 | 3072 | 4096;
|
|
65
|
+
dimension: 128 | 256 | 512 | 768 | 1024 | 1408 | 1536 | 2048 | 3072 | 4096;
|
|
66
66
|
vectors: (number[] | null)[];
|
|
67
67
|
} | undefined;
|
|
68
68
|
promptMessageId?: import("convex/values").GenericId<"messages"> | undefined;
|
|
@@ -193,7 +193,7 @@ export declare const addMessages: import("convex/server").RegisteredMutation<"pu
|
|
|
193
193
|
_creationTime: number;
|
|
194
194
|
id?: string | undefined;
|
|
195
195
|
userId?: string | undefined;
|
|
196
|
-
embeddingId?: import("convex/values").GenericId<"embeddings_128" | "embeddings_256" | "embeddings_512" | "embeddings_768" | "embeddings_1024" | "embeddings_1536" | "embeddings_2048" | "embeddings_3072" | "embeddings_4096"> | undefined;
|
|
196
|
+
embeddingId?: import("convex/values").GenericId<"embeddings_128" | "embeddings_256" | "embeddings_512" | "embeddings_768" | "embeddings_1024" | "embeddings_1408" | "embeddings_1536" | "embeddings_2048" | "embeddings_3072" | "embeddings_4096"> | undefined;
|
|
197
197
|
error?: string | undefined;
|
|
198
198
|
agentName?: string | undefined;
|
|
199
199
|
model?: string | undefined;
|
|
@@ -326,7 +326,7 @@ export declare function getMaxMessage(ctx: QueryCtx, threadId: Id<"threads">, or
|
|
|
326
326
|
_creationTime: number;
|
|
327
327
|
id?: string | undefined;
|
|
328
328
|
userId?: string | undefined;
|
|
329
|
-
embeddingId?: import("convex/values").GenericId<"embeddings_128" | "embeddings_256" | "embeddings_512" | "embeddings_768" | "embeddings_1024" | "embeddings_1536" | "embeddings_2048" | "embeddings_3072" | "embeddings_4096"> | undefined;
|
|
329
|
+
embeddingId?: import("convex/values").GenericId<"embeddings_128" | "embeddings_256" | "embeddings_512" | "embeddings_768" | "embeddings_1024" | "embeddings_1408" | "embeddings_1536" | "embeddings_2048" | "embeddings_3072" | "embeddings_4096"> | undefined;
|
|
330
330
|
error?: string | undefined;
|
|
331
331
|
agentName?: string | undefined;
|
|
332
332
|
model?: string | undefined;
|
|
@@ -460,7 +460,7 @@ export declare const addStep: import("convex/server").RegisteredMutation<"public
|
|
|
460
460
|
step: {
|
|
461
461
|
embeddings?: {
|
|
462
462
|
model: string;
|
|
463
|
-
dimension: 128 | 256 | 512 | 768 | 1024 | 1536 | 2048 | 3072 | 4096;
|
|
463
|
+
dimension: 128 | 256 | 512 | 768 | 1024 | 1408 | 1536 | 2048 | 3072 | 4096;
|
|
464
464
|
vectors: (number[] | null)[];
|
|
465
465
|
} | undefined;
|
|
466
466
|
messages: {
|
|
@@ -1347,7 +1347,7 @@ export declare const _fetchSearchMessages: import("convex/server").RegisteredQue
|
|
|
1347
1347
|
before: number;
|
|
1348
1348
|
after: number;
|
|
1349
1349
|
};
|
|
1350
|
-
vectorIds: import("convex/values").GenericId<"embeddings_128" | "embeddings_256" | "embeddings_512" | "embeddings_768" | "embeddings_1024" | "embeddings_1536" | "embeddings_2048" | "embeddings_3072" | "embeddings_4096">[];
|
|
1350
|
+
vectorIds: import("convex/values").GenericId<"embeddings_128" | "embeddings_256" | "embeddings_512" | "embeddings_768" | "embeddings_1024" | "embeddings_1408" | "embeddings_1536" | "embeddings_2048" | "embeddings_3072" | "embeddings_4096">[];
|
|
1351
1351
|
}, Promise<{
|
|
1352
1352
|
id?: string | undefined;
|
|
1353
1353
|
userId?: string | undefined;
|