@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.
Files changed (59) hide show
  1. package/README.md +26 -15
  2. package/dist/client/createTool.d.ts +2 -2
  3. package/dist/client/createTool.d.ts.map +1 -1
  4. package/dist/client/createTool.js.map +1 -1
  5. package/dist/client/files.js +2 -2
  6. package/dist/client/files.js.map +1 -1
  7. package/dist/client/index.d.ts +2 -1
  8. package/dist/client/index.d.ts.map +1 -1
  9. package/dist/client/index.js +47 -29
  10. package/dist/client/index.js.map +1 -1
  11. package/dist/client/search.d.ts +2 -3
  12. package/dist/client/search.d.ts.map +1 -1
  13. package/dist/client/search.js +2 -1
  14. package/dist/client/search.js.map +1 -1
  15. package/dist/client/types.d.ts +7 -9
  16. package/dist/client/types.d.ts.map +1 -1
  17. package/dist/component/messages.d.ts +1 -1
  18. package/dist/component/messages.d.ts.map +1 -1
  19. package/dist/component/messages.js +5 -5
  20. package/dist/component/messages.js.map +1 -1
  21. package/dist/component/schema.d.ts.map +1 -1
  22. package/dist/component/schema.js.map +1 -1
  23. package/dist/mapping.d.ts.map +1 -1
  24. package/dist/mapping.js +3 -1
  25. package/dist/mapping.js.map +1 -1
  26. package/dist/validators.js +1 -2
  27. package/dist/validators.js.map +1 -1
  28. package/package.json +1 -1
  29. package/src/client/createTool.ts +9 -6
  30. package/src/client/files.ts +8 -8
  31. package/src/client/index.test.ts +14 -12
  32. package/src/client/index.ts +127 -99
  33. package/src/client/listMessages.ts +1 -1
  34. package/src/client/search.ts +14 -14
  35. package/src/client/streaming.ts +7 -7
  36. package/src/client/types.ts +29 -23
  37. package/src/component/apiKeys.ts +1 -1
  38. package/src/component/files.test.ts +1 -1
  39. package/src/component/files.ts +6 -6
  40. package/src/component/messages.test.ts +6 -6
  41. package/src/component/messages.ts +44 -43
  42. package/src/component/schema.ts +1 -2
  43. package/src/component/streams.ts +27 -27
  44. package/src/component/threads.test.ts +4 -4
  45. package/src/component/threads.ts +4 -4
  46. package/src/component/users.test.ts +2 -2
  47. package/src/component/users.ts +4 -4
  48. package/src/component/vector/index.ts +11 -11
  49. package/src/component/vector/tables.ts +6 -6
  50. package/src/mapping.test.ts +4 -4
  51. package/src/mapping.ts +18 -17
  52. package/src/react/deltas.test.ts +16 -16
  53. package/src/react/deltas.ts +13 -13
  54. package/src/react/index.ts +11 -11
  55. package/src/react/optimisticallySendMessage.ts +2 -2
  56. package/src/react/toUIMessages.test.ts +10 -10
  57. package/src/react/toUIMessages.ts +6 -6
  58. package/src/react/useSmoothText.ts +6 -6
  59. package/src/validators.ts +24 -24
@@ -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.createThread(ctx, { userId: "10" }).then(({ threadId }) => threadId)
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",