@convex-dev/agent 0.1.16-alpha.1 → 0.1.16-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/README.md +26 -15
- package/dist/client/createTool.d.ts +2 -2
- package/dist/client/createTool.d.ts.map +1 -1
- package/dist/client/createTool.js.map +1 -1
- package/dist/client/files.js +2 -2
- package/dist/client/files.js.map +1 -1
- package/dist/client/index.d.ts +2 -1
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +47 -29
- package/dist/client/index.js.map +1 -1
- package/dist/client/search.d.ts +2 -3
- package/dist/client/search.d.ts.map +1 -1
- package/dist/client/search.js +2 -1
- package/dist/client/search.js.map +1 -1
- package/dist/client/types.d.ts +7 -9
- package/dist/client/types.d.ts.map +1 -1
- package/dist/component/messages.d.ts +1 -1
- package/dist/component/messages.d.ts.map +1 -1
- package/dist/component/messages.js +5 -5
- package/dist/component/messages.js.map +1 -1
- package/dist/component/schema.d.ts.map +1 -1
- package/dist/component/schema.js.map +1 -1
- package/dist/mapping.d.ts.map +1 -1
- package/dist/mapping.js +3 -1
- package/dist/mapping.js.map +1 -1
- package/dist/validators.js +1 -2
- package/dist/validators.js.map +1 -1
- package/package.json +1 -1
- package/src/client/createTool.ts +9 -6
- package/src/client/files.ts +8 -8
- package/src/client/index.test.ts +14 -12
- package/src/client/index.ts +127 -99
- package/src/client/listMessages.ts +1 -1
- package/src/client/search.ts +14 -14
- package/src/client/streaming.ts +7 -7
- package/src/client/types.ts +29 -23
- package/src/component/apiKeys.ts +1 -1
- package/src/component/files.test.ts +1 -1
- package/src/component/files.ts +6 -6
- package/src/component/messages.test.ts +6 -6
- package/src/component/messages.ts +44 -43
- package/src/component/schema.ts +1 -2
- package/src/component/streams.ts +27 -27
- package/src/component/threads.test.ts +4 -4
- package/src/component/threads.ts +4 -4
- package/src/component/users.test.ts +2 -2
- package/src/component/users.ts +4 -4
- package/src/component/vector/index.ts +11 -11
- package/src/component/vector/tables.ts +6 -6
- package/src/mapping.test.ts +4 -4
- package/src/mapping.ts +18 -17
- package/src/react/deltas.test.ts +16 -16
- package/src/react/deltas.ts +13 -13
- package/src/react/index.ts +11 -11
- package/src/react/optimisticallySendMessage.ts +2 -2
- package/src/react/toUIMessages.test.ts +10 -10
- package/src/react/toUIMessages.ts +6 -6
- package/src/react/useSmoothText.ts +6 -6
- package/src/validators.ts +24 -24
package/src/client/index.test.ts
CHANGED
|
@@ -113,7 +113,7 @@ export const generateTextWithThread = action({
|
|
|
113
113
|
{
|
|
114
114
|
contextOptions: args.contextOptions,
|
|
115
115
|
storageOptions: args.storageOptions,
|
|
116
|
-
}
|
|
116
|
+
},
|
|
117
117
|
);
|
|
118
118
|
return { text: result.text };
|
|
119
119
|
},
|
|
@@ -313,7 +313,7 @@ describe("Agent thread management", () => {
|
|
|
313
313
|
test("createThread returns threadId (mutation context)", async () => {
|
|
314
314
|
const t = initConvexTest(schema);
|
|
315
315
|
const threadId = await t.run(async (ctx) =>
|
|
316
|
-
agent.createThread(ctx, { userId: "2" }).then(({ threadId }) => threadId)
|
|
316
|
+
agent.createThread(ctx, { userId: "2" }).then(({ threadId }) => threadId),
|
|
317
317
|
);
|
|
318
318
|
expect(threadId).toBeTypeOf("string");
|
|
319
319
|
});
|
|
@@ -321,7 +321,7 @@ describe("Agent thread management", () => {
|
|
|
321
321
|
test("continueThread returns thread object", async () => {
|
|
322
322
|
const t = initConvexTest(schema);
|
|
323
323
|
const threadId = await t.run(async (ctx) =>
|
|
324
|
-
agent.createThread(ctx, { userId: "3" }).then(({ threadId }) => threadId)
|
|
324
|
+
agent.createThread(ctx, { userId: "3" }).then(({ threadId }) => threadId),
|
|
325
325
|
);
|
|
326
326
|
const result = await t.action(testApi.continueThreadAction, {
|
|
327
327
|
threadId,
|
|
@@ -335,14 +335,14 @@ describe("Agent message operations", () => {
|
|
|
335
335
|
test("saveMessage and saveMessages store messages", async () => {
|
|
336
336
|
const t = initConvexTest(schema);
|
|
337
337
|
const threadId = await t.run(async (ctx) =>
|
|
338
|
-
agent.createThread(ctx, { userId: "4" }).then(({ threadId }) => threadId)
|
|
338
|
+
agent.createThread(ctx, { userId: "4" }).then(({ threadId }) => threadId),
|
|
339
339
|
);
|
|
340
340
|
const { messageId } = await t.run(async (ctx) =>
|
|
341
341
|
agent.saveMessage(ctx, {
|
|
342
342
|
threadId,
|
|
343
343
|
userId: "4",
|
|
344
344
|
message: { role: "user", content: "Hello" },
|
|
345
|
-
})
|
|
345
|
+
}),
|
|
346
346
|
);
|
|
347
347
|
expect(messageId).toBeTypeOf("string");
|
|
348
348
|
|
|
@@ -354,7 +354,7 @@ describe("Agent message operations", () => {
|
|
|
354
354
|
{ role: "user", content: "Hi" },
|
|
355
355
|
{ role: "assistant", content: "Hello!" },
|
|
356
356
|
],
|
|
357
|
-
})
|
|
357
|
+
}),
|
|
358
358
|
);
|
|
359
359
|
expect(messages.length).toBe(2);
|
|
360
360
|
expect(lastMessageId).toBe(messages[1]._id);
|
|
@@ -365,7 +365,7 @@ describe("Agent text/object generation", () => {
|
|
|
365
365
|
test("generateText with custom context and storage options", async () => {
|
|
366
366
|
const t = initConvexTest(schema);
|
|
367
367
|
const threadId = await t.run(async (ctx) =>
|
|
368
|
-
agent.createThread(ctx, { userId: "5" }).then(({ threadId }) => threadId)
|
|
368
|
+
agent.createThread(ctx, { userId: "5" }).then(({ threadId }) => threadId),
|
|
369
369
|
);
|
|
370
370
|
const result = await t.action(testApi.generateTextWithThread, {
|
|
371
371
|
threadId,
|
|
@@ -380,7 +380,7 @@ describe("Agent text/object generation", () => {
|
|
|
380
380
|
test("generateObject returns object", async () => {
|
|
381
381
|
const t = initConvexTest(schema);
|
|
382
382
|
const threadId = await t.run(async (ctx) =>
|
|
383
|
-
agent.createThread(ctx, { userId: "6" }).then(({ threadId }) => threadId)
|
|
383
|
+
agent.createThread(ctx, { userId: "6" }).then(({ threadId }) => threadId),
|
|
384
384
|
);
|
|
385
385
|
const result = await t.action(testApi.generateObjectWithThread, {
|
|
386
386
|
threadId,
|
|
@@ -402,7 +402,7 @@ describe("Agent-generated mutations/actions/queries", () => {
|
|
|
402
402
|
test("asTextAction and asObjectAction work via t.action", async () => {
|
|
403
403
|
const t = initConvexTest(schema);
|
|
404
404
|
const threadId = await t.run(async (ctx) =>
|
|
405
|
-
agent.createThread(ctx, { userId: "8" }).then(({ threadId }) => threadId)
|
|
405
|
+
agent.createThread(ctx, { userId: "8" }).then(({ threadId }) => threadId),
|
|
406
406
|
);
|
|
407
407
|
const textResult = await t.action(testApi.generateTextAction, {
|
|
408
408
|
userId: "8",
|
|
@@ -422,7 +422,7 @@ describe("Agent-generated mutations/actions/queries", () => {
|
|
|
422
422
|
test("asSaveMessagesMutation works via t.mutation", async () => {
|
|
423
423
|
const t = initConvexTest(schema);
|
|
424
424
|
const threadId = await t.run(async (ctx) =>
|
|
425
|
-
agent.createThread(ctx, { userId: "9" }).then(({ threadId }) => threadId)
|
|
425
|
+
agent.createThread(ctx, { userId: "9" }).then(({ threadId }) => threadId),
|
|
426
426
|
);
|
|
427
427
|
const result = await t.mutation(testApi.saveMessageMutation, {
|
|
428
428
|
threadId,
|
|
@@ -442,14 +442,16 @@ describe("Agent context and search options", () => {
|
|
|
442
442
|
test("fetchContextMessages returns context messages", async () => {
|
|
443
443
|
const t = initConvexTest(schema);
|
|
444
444
|
const threadId = await t.run(async (ctx) =>
|
|
445
|
-
agent
|
|
445
|
+
agent
|
|
446
|
+
.createThread(ctx, { userId: "10" })
|
|
447
|
+
.then(({ threadId }) => threadId),
|
|
446
448
|
);
|
|
447
449
|
await t.run(async (ctx) =>
|
|
448
450
|
agent.saveMessage(ctx, {
|
|
449
451
|
threadId,
|
|
450
452
|
userId: "10",
|
|
451
453
|
message: { role: "user", content: "Context test" },
|
|
452
|
-
})
|
|
454
|
+
}),
|
|
453
455
|
);
|
|
454
456
|
const context = await t.action(testApi.fetchContextAction, {
|
|
455
457
|
userId: "10",
|