@convex-dev/agent 0.6.0-alpha.0 → 0.6.0-beta.0

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 (75) hide show
  1. package/MIGRATION.md +153 -0
  2. package/dist/UIMessages.d.ts.map +1 -1
  3. package/dist/UIMessages.js +88 -0
  4. package/dist/UIMessages.js.map +1 -1
  5. package/dist/client/createTool.d.ts +18 -21
  6. package/dist/client/createTool.d.ts.map +1 -1
  7. package/dist/client/createTool.js +3 -2
  8. package/dist/client/createTool.js.map +1 -1
  9. package/dist/client/definePlaygroundAPI.d.ts +31 -31
  10. package/dist/client/index.d.ts +70 -23
  11. package/dist/client/index.d.ts.map +1 -1
  12. package/dist/client/index.js +126 -1
  13. package/dist/client/index.js.map +1 -1
  14. package/dist/client/messages.d.ts +9 -9
  15. package/dist/client/mockModel.d.ts.map +1 -1
  16. package/dist/client/mockModel.js +9 -2
  17. package/dist/client/mockModel.js.map +1 -1
  18. package/dist/client/search.d.ts +9 -9
  19. package/dist/client/search.d.ts.map +1 -1
  20. package/dist/client/search.js +12 -2
  21. package/dist/client/search.js.map +1 -1
  22. package/dist/client/start.d.ts +1 -1
  23. package/dist/client/start.d.ts.map +1 -1
  24. package/dist/client/start.js +29 -15
  25. package/dist/client/start.js.map +1 -1
  26. package/dist/client/streamText.d.ts.map +1 -1
  27. package/dist/client/streamText.js +37 -3
  28. package/dist/client/streamText.js.map +1 -1
  29. package/dist/client/streaming.d.ts +78 -67
  30. package/dist/client/streaming.d.ts.map +1 -1
  31. package/dist/client/streaming.js +64 -28
  32. package/dist/client/streaming.js.map +1 -1
  33. package/dist/client/types.d.ts +13 -12
  34. package/dist/client/types.d.ts.map +1 -1
  35. package/dist/component/_generated/component.d.ts +1 -0
  36. package/dist/component/_generated/component.d.ts.map +1 -1
  37. package/dist/component/messages.d.ts +107 -106
  38. package/dist/component/messages.d.ts.map +1 -1
  39. package/dist/component/messages.js +13 -3
  40. package/dist/component/messages.js.map +1 -1
  41. package/dist/component/schema.d.ts +40 -40
  42. package/dist/component/streams.d.ts +4 -4
  43. package/dist/component/threads.d.ts +17 -17
  44. package/dist/component/users.d.ts +3 -3
  45. package/dist/component/vector/index.d.ts +1 -1
  46. package/dist/deltas.d.ts.map +1 -1
  47. package/dist/deltas.js +0 -1
  48. package/dist/deltas.js.map +1 -1
  49. package/dist/mapping.d.ts +22 -0
  50. package/dist/mapping.d.ts.map +1 -1
  51. package/dist/mapping.js +99 -5
  52. package/dist/mapping.js.map +1 -1
  53. package/dist/react/useDeltaStreams.d.ts.map +1 -1
  54. package/dist/react/useDeltaStreams.js +5 -0
  55. package/dist/react/useDeltaStreams.js.map +1 -1
  56. package/dist/validators.d.ts +13 -13
  57. package/package.json +4 -2
  58. package/src/UIMessages.ts +126 -0
  59. package/src/client/approval.test.ts +494 -0
  60. package/src/client/createTool.ts +50 -52
  61. package/src/client/index.ts +170 -1
  62. package/src/client/mockModel.ts +9 -2
  63. package/src/client/search.test.ts +4 -5
  64. package/src/client/search.ts +18 -2
  65. package/src/client/start.ts +42 -25
  66. package/src/client/streamText.ts +36 -3
  67. package/src/client/streaming.integration.test.ts +1206 -0
  68. package/src/client/streaming.ts +67 -31
  69. package/src/client/types.ts +14 -12
  70. package/src/component/_generated/component.ts +53 -64
  71. package/src/component/messages.ts +12 -2
  72. package/src/deltas.ts +0 -1
  73. package/src/mapping.test.ts +143 -1
  74. package/src/mapping.ts +131 -6
  75. package/src/react/useDeltaStreams.ts +6 -0
@@ -15,7 +15,6 @@ export declare function definePlaygroundAPI<DataModel extends GenericDataModel>(
15
15
  apiKey: string;
16
16
  }, Promise<boolean>>;
17
17
  listUsers: import("convex/server").RegisteredQuery<"public", {
18
- apiKey: string;
19
18
  paginationOpts: {
20
19
  id?: number;
21
20
  endCursor?: string | null;
@@ -24,6 +23,7 @@ export declare function definePlaygroundAPI<DataModel extends GenericDataModel>(
24
23
  numItems: number;
25
24
  cursor: string | null;
26
25
  };
26
+ apiKey: string;
27
27
  }, Promise<{
28
28
  page: {
29
29
  _id: string;
@@ -36,7 +36,6 @@ export declare function definePlaygroundAPI<DataModel extends GenericDataModel>(
36
36
  }>>;
37
37
  listThreads: import("convex/server").RegisteredQuery<"public", {
38
38
  userId?: string | undefined;
39
- apiKey: string;
40
39
  paginationOpts: {
41
40
  id?: number;
42
41
  endCursor?: string | null;
@@ -45,6 +44,7 @@ export declare function definePlaygroundAPI<DataModel extends GenericDataModel>(
45
44
  numItems: number;
46
45
  cursor: string | null;
47
46
  };
47
+ apiKey: string;
48
48
  }, Promise<{
49
49
  page: {
50
50
  lastAgentName: string | undefined;
@@ -74,7 +74,6 @@ export declare function definePlaygroundAPI<DataModel extends GenericDataModel>(
74
74
  }[];
75
75
  } | undefined;
76
76
  threadId: string;
77
- apiKey: string;
78
77
  paginationOpts: {
79
78
  id?: number;
80
79
  endCursor?: string | null;
@@ -83,11 +82,12 @@ export declare function definePlaygroundAPI<DataModel extends GenericDataModel>(
83
82
  numItems: number;
84
83
  cursor: string | null;
85
84
  };
85
+ apiKey: string;
86
86
  }, Promise<{
87
87
  streams: import("./types.js").SyncStreamsReturnValue;
88
88
  page: {
89
- id?: string | undefined;
90
89
  userId?: string | undefined;
90
+ id?: string | undefined;
91
91
  embeddingId?: string | undefined;
92
92
  fileIds?: string[] | undefined;
93
93
  error?: string | undefined;
@@ -244,9 +244,9 @@ export declare function definePlaygroundAPI<DataModel extends GenericDataModel>(
244
244
  toolCallId: string;
245
245
  toolName: string;
246
246
  } | {
247
- title?: string | undefined;
248
247
  providerOptions?: Record<string, Record<string, any>> | undefined;
249
248
  providerMetadata?: Record<string, Record<string, any>> | undefined;
249
+ title?: string | undefined;
250
250
  id: string;
251
251
  type: "source";
252
252
  url: string;
@@ -256,10 +256,10 @@ export declare function definePlaygroundAPI<DataModel extends GenericDataModel>(
256
256
  providerMetadata?: Record<string, Record<string, any>> | undefined;
257
257
  filename?: string | undefined;
258
258
  id: string;
259
- title: string;
260
259
  type: "source";
261
260
  mediaType: string;
262
261
  sourceType: "document";
262
+ title: string;
263
263
  } | {
264
264
  providerOptions?: Record<string, Record<string, any>> | undefined;
265
265
  providerMetadata?: Record<string, Record<string, any>> | undefined;
@@ -375,10 +375,10 @@ export declare function definePlaygroundAPI<DataModel extends GenericDataModel>(
375
375
  totalTokens: number;
376
376
  } | undefined;
377
377
  sources?: ({
378
- title?: string | undefined;
379
378
  type?: "source" | undefined;
380
379
  providerOptions?: Record<string, Record<string, any>> | undefined;
381
380
  providerMetadata?: Record<string, Record<string, any>> | undefined;
381
+ title?: string | undefined;
382
382
  id: string;
383
383
  url: string;
384
384
  sourceType: "url";
@@ -387,10 +387,10 @@ export declare function definePlaygroundAPI<DataModel extends GenericDataModel>(
387
387
  providerMetadata?: Record<string, Record<string, any>> | undefined;
388
388
  filename?: string | undefined;
389
389
  id: string;
390
- title: string;
391
390
  type: "source";
392
391
  mediaType: string;
393
392
  sourceType: "document";
393
+ title: string;
394
394
  })[] | undefined;
395
395
  warnings?: ({
396
396
  details?: string | undefined;
@@ -404,7 +404,7 @@ export declare function definePlaygroundAPI<DataModel extends GenericDataModel>(
404
404
  type: "other";
405
405
  message: string;
406
406
  })[] | undefined;
407
- finishReason?: "error" | "length" | "other" | "stop" | "content-filter" | "tool-calls" | "unknown" | undefined;
407
+ finishReason?: "length" | "error" | "other" | "stop" | "content-filter" | "tool-calls" | "unknown" | undefined;
408
408
  reasoningDetails?: ({
409
409
  providerOptions?: Record<string, Record<string, any>> | undefined;
410
410
  providerMetadata?: Record<string, Record<string, any>> | undefined;
@@ -419,13 +419,13 @@ export declare function definePlaygroundAPI<DataModel extends GenericDataModel>(
419
419
  type: "redacted";
420
420
  data: string;
421
421
  })[] | undefined;
422
- status: "pending" | "success" | "failed";
423
- order: number;
422
+ _id: string;
424
423
  _creationTime: number;
425
424
  threadId: string;
425
+ order: number;
426
426
  stepOrder: number;
427
+ status: "pending" | "success" | "failed";
427
428
  tool: boolean;
428
- _id: string;
429
429
  }[];
430
430
  isDone: boolean;
431
431
  continueCursor: import("convex/server").Cursor;
@@ -445,9 +445,9 @@ export declare function definePlaygroundAPI<DataModel extends GenericDataModel>(
445
445
  tools: string[];
446
446
  }[]>>;
447
447
  createThread: import("convex/server").RegisteredMutation<"public", {
448
+ agentName?: string | undefined;
448
449
  title?: string | undefined;
449
450
  summary?: string | undefined;
450
- agentName?: string | undefined;
451
451
  userId: string;
452
452
  apiKey: string;
453
453
  }, Promise<{
@@ -604,9 +604,9 @@ export declare function definePlaygroundAPI<DataModel extends GenericDataModel>(
604
604
  toolCallId: string;
605
605
  toolName: string;
606
606
  } | {
607
- title?: string | undefined;
608
607
  providerOptions?: Record<string, Record<string, any>> | undefined;
609
608
  providerMetadata?: Record<string, Record<string, any>> | undefined;
609
+ title?: string | undefined;
610
610
  id: string;
611
611
  type: "source";
612
612
  url: string;
@@ -616,10 +616,10 @@ export declare function definePlaygroundAPI<DataModel extends GenericDataModel>(
616
616
  providerMetadata?: Record<string, Record<string, any>> | undefined;
617
617
  filename?: string | undefined;
618
618
  id: string;
619
- title: string;
620
619
  type: "source";
621
620
  mediaType: string;
622
621
  sourceType: "document";
622
+ title: string;
623
623
  } | {
624
624
  providerOptions?: Record<string, Record<string, any>> | undefined;
625
625
  providerMetadata?: Record<string, Record<string, any>> | undefined;
@@ -772,10 +772,10 @@ export declare function definePlaygroundAPI<DataModel extends GenericDataModel>(
772
772
  totalTokens: number;
773
773
  } | undefined;
774
774
  sources?: ({
775
- title?: string | undefined;
776
775
  type?: "source" | undefined;
777
776
  providerOptions?: Record<string, Record<string, any>> | undefined;
778
777
  providerMetadata?: Record<string, Record<string, any>> | undefined;
778
+ title?: string | undefined;
779
779
  id: string;
780
780
  url: string;
781
781
  sourceType: "url";
@@ -784,10 +784,10 @@ export declare function definePlaygroundAPI<DataModel extends GenericDataModel>(
784
784
  providerMetadata?: Record<string, Record<string, any>> | undefined;
785
785
  filename?: string | undefined;
786
786
  id: string;
787
- title: string;
788
787
  type: "source";
789
788
  mediaType: string;
790
789
  sourceType: "document";
790
+ title: string;
791
791
  })[] | undefined;
792
792
  warnings?: ({
793
793
  details?: string | undefined;
@@ -801,7 +801,7 @@ export declare function definePlaygroundAPI<DataModel extends GenericDataModel>(
801
801
  type: "other";
802
802
  message: string;
803
803
  })[] | undefined;
804
- finishReason?: "error" | "length" | "other" | "stop" | "content-filter" | "tool-calls" | "unknown" | undefined;
804
+ finishReason?: "length" | "error" | "other" | "stop" | "content-filter" | "tool-calls" | "unknown" | undefined;
805
805
  reasoningDetails?: ({
806
806
  providerOptions?: Record<string, Record<string, any>> | undefined;
807
807
  providerMetadata?: Record<string, Record<string, any>> | undefined;
@@ -965,9 +965,9 @@ export declare function definePlaygroundAPI<DataModel extends GenericDataModel>(
965
965
  toolCallId: string;
966
966
  toolName: string;
967
967
  } | {
968
- title?: string | undefined;
969
968
  providerOptions?: Record<string, Record<string, any>> | undefined;
970
969
  providerMetadata?: Record<string, Record<string, any>> | undefined;
970
+ title?: string | undefined;
971
971
  id: string;
972
972
  type: "source";
973
973
  url: string;
@@ -977,10 +977,10 @@ export declare function definePlaygroundAPI<DataModel extends GenericDataModel>(
977
977
  providerMetadata?: Record<string, Record<string, any>> | undefined;
978
978
  filename?: string | undefined;
979
979
  id: string;
980
- title: string;
981
980
  type: "source";
982
981
  mediaType: string;
983
982
  sourceType: "document";
983
+ title: string;
984
984
  } | {
985
985
  providerOptions?: Record<string, Record<string, any>> | undefined;
986
986
  providerMetadata?: Record<string, Record<string, any>> | undefined;
@@ -1239,9 +1239,9 @@ export declare function definePlaygroundAPI<DataModel extends GenericDataModel>(
1239
1239
  toolCallId: string;
1240
1240
  toolName: string;
1241
1241
  } | {
1242
- title?: string | undefined;
1243
1242
  providerOptions?: Record<string, Record<string, any>> | undefined;
1244
1243
  providerMetadata?: Record<string, Record<string, any>> | undefined;
1244
+ title?: string | undefined;
1245
1245
  id: string;
1246
1246
  type: "source";
1247
1247
  url: string;
@@ -1251,10 +1251,10 @@ export declare function definePlaygroundAPI<DataModel extends GenericDataModel>(
1251
1251
  providerMetadata?: Record<string, Record<string, any>> | undefined;
1252
1252
  filename?: string | undefined;
1253
1253
  id: string;
1254
- title: string;
1255
1254
  type: "source";
1256
1255
  mediaType: string;
1257
1256
  sourceType: "document";
1257
+ title: string;
1258
1258
  } | {
1259
1259
  providerOptions?: Record<string, Record<string, any>> | undefined;
1260
1260
  providerMetadata?: Record<string, Record<string, any>> | undefined;
@@ -1380,8 +1380,8 @@ export declare function definePlaygroundAPI<DataModel extends GenericDataModel>(
1380
1380
  };
1381
1381
  apiKey: string;
1382
1382
  }, Promise<{
1383
- id?: string | undefined;
1384
1383
  userId?: string | undefined;
1384
+ id?: string | undefined;
1385
1385
  embeddingId?: string | undefined;
1386
1386
  fileIds?: string[] | undefined;
1387
1387
  error?: string | undefined;
@@ -1538,9 +1538,9 @@ export declare function definePlaygroundAPI<DataModel extends GenericDataModel>(
1538
1538
  toolCallId: string;
1539
1539
  toolName: string;
1540
1540
  } | {
1541
- title?: string | undefined;
1542
1541
  providerOptions?: Record<string, Record<string, any>> | undefined;
1543
1542
  providerMetadata?: Record<string, Record<string, any>> | undefined;
1543
+ title?: string | undefined;
1544
1544
  id: string;
1545
1545
  type: "source";
1546
1546
  url: string;
@@ -1550,10 +1550,10 @@ export declare function definePlaygroundAPI<DataModel extends GenericDataModel>(
1550
1550
  providerMetadata?: Record<string, Record<string, any>> | undefined;
1551
1551
  filename?: string | undefined;
1552
1552
  id: string;
1553
- title: string;
1554
1553
  type: "source";
1555
1554
  mediaType: string;
1556
1555
  sourceType: "document";
1556
+ title: string;
1557
1557
  } | {
1558
1558
  providerOptions?: Record<string, Record<string, any>> | undefined;
1559
1559
  providerMetadata?: Record<string, Record<string, any>> | undefined;
@@ -1669,10 +1669,10 @@ export declare function definePlaygroundAPI<DataModel extends GenericDataModel>(
1669
1669
  totalTokens: number;
1670
1670
  } | undefined;
1671
1671
  sources?: ({
1672
- title?: string | undefined;
1673
1672
  type?: "source" | undefined;
1674
1673
  providerOptions?: Record<string, Record<string, any>> | undefined;
1675
1674
  providerMetadata?: Record<string, Record<string, any>> | undefined;
1675
+ title?: string | undefined;
1676
1676
  id: string;
1677
1677
  url: string;
1678
1678
  sourceType: "url";
@@ -1681,10 +1681,10 @@ export declare function definePlaygroundAPI<DataModel extends GenericDataModel>(
1681
1681
  providerMetadata?: Record<string, Record<string, any>> | undefined;
1682
1682
  filename?: string | undefined;
1683
1683
  id: string;
1684
- title: string;
1685
1684
  type: "source";
1686
1685
  mediaType: string;
1687
1686
  sourceType: "document";
1687
+ title: string;
1688
1688
  })[] | undefined;
1689
1689
  warnings?: ({
1690
1690
  details?: string | undefined;
@@ -1698,7 +1698,7 @@ export declare function definePlaygroundAPI<DataModel extends GenericDataModel>(
1698
1698
  type: "other";
1699
1699
  message: string;
1700
1700
  })[] | undefined;
1701
- finishReason?: "error" | "length" | "other" | "stop" | "content-filter" | "tool-calls" | "unknown" | undefined;
1701
+ finishReason?: "length" | "error" | "other" | "stop" | "content-filter" | "tool-calls" | "unknown" | undefined;
1702
1702
  reasoningDetails?: ({
1703
1703
  providerOptions?: Record<string, Record<string, any>> | undefined;
1704
1704
  providerMetadata?: Record<string, Record<string, any>> | undefined;
@@ -1713,13 +1713,13 @@ export declare function definePlaygroundAPI<DataModel extends GenericDataModel>(
1713
1713
  type: "redacted";
1714
1714
  data: string;
1715
1715
  })[] | undefined;
1716
- status: "pending" | "success" | "failed";
1717
- order: number;
1716
+ _id: string;
1718
1717
  _creationTime: number;
1719
1718
  threadId: string;
1719
+ order: number;
1720
1720
  stepOrder: number;
1721
+ status: "pending" | "success" | "failed";
1721
1722
  tool: boolean;
1722
- _id: string;
1723
1723
  }[]>>;
1724
1724
  };
1725
1725
  //# sourceMappingURL=definePlaygroundAPI.d.ts.map
@@ -355,8 +355,8 @@ CustomCtx extends object = object, AgentTools extends ToolSet = any> {
355
355
  }): Promise<{
356
356
  messageId: string;
357
357
  message: {
358
- id?: string | undefined;
359
358
  userId?: string | undefined;
359
+ id?: string | undefined;
360
360
  embeddingId?: string | undefined;
361
361
  fileIds?: string[] | undefined;
362
362
  error?: string | undefined;
@@ -513,9 +513,9 @@ CustomCtx extends object = object, AgentTools extends ToolSet = any> {
513
513
  toolCallId: string;
514
514
  toolName: string;
515
515
  } | {
516
- title?: string | undefined;
517
516
  providerOptions?: Record<string, Record<string, any>> | undefined;
518
517
  providerMetadata?: Record<string, Record<string, any>> | undefined;
518
+ title?: string | undefined;
519
519
  id: string;
520
520
  type: "source";
521
521
  url: string;
@@ -525,10 +525,10 @@ CustomCtx extends object = object, AgentTools extends ToolSet = any> {
525
525
  providerMetadata?: Record<string, Record<string, any>> | undefined;
526
526
  filename?: string | undefined;
527
527
  id: string;
528
- title: string;
529
528
  type: "source";
530
529
  mediaType: string;
531
530
  sourceType: "document";
531
+ title: string;
532
532
  } | {
533
533
  providerOptions?: Record<string, Record<string, any>> | undefined;
534
534
  providerMetadata?: Record<string, Record<string, any>> | undefined;
@@ -644,10 +644,10 @@ CustomCtx extends object = object, AgentTools extends ToolSet = any> {
644
644
  totalTokens: number;
645
645
  } | undefined;
646
646
  sources?: ({
647
- title?: string | undefined;
648
647
  type?: "source" | undefined;
649
648
  providerOptions?: Record<string, Record<string, any>> | undefined;
650
649
  providerMetadata?: Record<string, Record<string, any>> | undefined;
650
+ title?: string | undefined;
651
651
  id: string;
652
652
  url: string;
653
653
  sourceType: "url";
@@ -656,10 +656,10 @@ CustomCtx extends object = object, AgentTools extends ToolSet = any> {
656
656
  providerMetadata?: Record<string, Record<string, any>> | undefined;
657
657
  filename?: string | undefined;
658
658
  id: string;
659
- title: string;
660
659
  type: "source";
661
660
  mediaType: string;
662
661
  sourceType: "document";
662
+ title: string;
663
663
  })[] | undefined;
664
664
  warnings?: ({
665
665
  details?: string | undefined;
@@ -673,7 +673,7 @@ CustomCtx extends object = object, AgentTools extends ToolSet = any> {
673
673
  type: "other";
674
674
  message: string;
675
675
  })[] | undefined;
676
- finishReason?: "error" | "length" | "other" | "stop" | "content-filter" | "tool-calls" | "unknown" | undefined;
676
+ finishReason?: "length" | "error" | "other" | "stop" | "content-filter" | "tool-calls" | "unknown" | undefined;
677
677
  reasoningDetails?: ({
678
678
  providerOptions?: Record<string, Record<string, any>> | undefined;
679
679
  providerMetadata?: Record<string, Record<string, any>> | undefined;
@@ -688,13 +688,13 @@ CustomCtx extends object = object, AgentTools extends ToolSet = any> {
688
688
  type: "redacted";
689
689
  data: string;
690
690
  })[] | undefined;
691
- status: "pending" | "success" | "failed";
692
- order: number;
691
+ _id: string;
693
692
  _creationTime: number;
694
693
  threadId: string;
694
+ order: number;
695
695
  stepOrder: number;
696
+ status: "pending" | "success" | "failed";
696
697
  tool: boolean;
697
- _id: string;
698
698
  };
699
699
  }>;
700
700
  /**
@@ -819,6 +819,53 @@ CustomCtx extends object = object, AgentTools extends ToolSet = any> {
819
819
  generateAndSaveEmbeddings(ctx: ActionCtx, args: {
820
820
  messageIds: string[];
821
821
  }): Promise<void>;
822
+ /**
823
+ * Approve a tool call that requires human approval.
824
+ * Saves a `tool-approval-response` message to the thread.
825
+ * After calling this, call `agent.streamText` or `agent.generateText`
826
+ * with `promptMessageId` set to the returned `messageId` to continue
827
+ * generation — the AI SDK will automatically execute the approved tool.
828
+ *
829
+ * The approval response is attached to the same generation order as the
830
+ * original approval request, preserving tool_call/tool_result adjacency in
831
+ * the continuation context even if newer thread messages exist.
832
+ *
833
+ * @param ctx A ctx object from a mutation.
834
+ * @param args.threadId The thread containing the tool call.
835
+ * @param args.approvalId The approval ID from the tool-approval-request part.
836
+ * @param args.reason Optional reason for approval.
837
+ * @returns The messageId of the saved approval response message.
838
+ */
839
+ approveToolCall(ctx: MutationCtx, args: {
840
+ threadId: string;
841
+ approvalId: string;
842
+ reason?: string;
843
+ }): Promise<{
844
+ messageId: string;
845
+ }>;
846
+ /**
847
+ * Deny a tool call that requires human approval.
848
+ * Saves a `tool-approval-response` message to the thread.
849
+ * After calling this, call `agent.streamText` or `agent.generateText`
850
+ * with `promptMessageId` set to the returned `messageId` to continue
851
+ * generation — the AI SDK will automatically create an `execution-denied`
852
+ * result and let the model respond accordingly.
853
+ *
854
+ * @param ctx A ctx object from a mutation.
855
+ * @param args.threadId The thread containing the tool call.
856
+ * @param args.approvalId The approval ID from the tool-approval-request part.
857
+ * @param args.reason Optional reason for denial.
858
+ * @returns The messageId of the saved denial response message.
859
+ */
860
+ denyToolCall(ctx: MutationCtx, args: {
861
+ threadId: string;
862
+ approvalId: string;
863
+ reason?: string;
864
+ }): Promise<{
865
+ messageId: string;
866
+ }>;
867
+ private respondToToolCallApproval;
868
+ private findApprovalContext;
822
869
  /**
823
870
  * Explicitly save a "step" created by the AI SDK.
824
871
  * @param ctx The ctx argument to a mutation or action.
@@ -1201,9 +1248,9 @@ CustomCtx extends object = object, AgentTools extends ToolSet = any> {
1201
1248
  toolCallId: string;
1202
1249
  toolName: string;
1203
1250
  } | {
1204
- title?: string | undefined;
1205
1251
  providerOptions?: Record<string, Record<string, any>> | undefined;
1206
1252
  providerMetadata?: Record<string, Record<string, any>> | undefined;
1253
+ title?: string | undefined;
1207
1254
  id: string;
1208
1255
  type: "source";
1209
1256
  url: string;
@@ -1213,10 +1260,10 @@ CustomCtx extends object = object, AgentTools extends ToolSet = any> {
1213
1260
  providerMetadata?: Record<string, Record<string, any>> | undefined;
1214
1261
  filename?: string | undefined;
1215
1262
  id: string;
1216
- title: string;
1217
1263
  type: "source";
1218
1264
  mediaType: string;
1219
1265
  sourceType: "document";
1266
+ title: string;
1220
1267
  } | {
1221
1268
  providerOptions?: Record<string, Record<string, any>> | undefined;
1222
1269
  providerMetadata?: Record<string, Record<string, any>> | undefined;
@@ -1349,7 +1396,6 @@ CustomCtx extends object = object, AgentTools extends ToolSet = any> {
1349
1396
  saveMessages?: "all" | "none" | "promptAndOutput" | undefined;
1350
1397
  } | undefined;
1351
1398
  callSettings?: {
1352
- headers?: Record<string, string> | undefined;
1353
1399
  maxOutputTokens?: number | undefined;
1354
1400
  temperature?: number | undefined;
1355
1401
  topP?: number | undefined;
@@ -1359,6 +1405,7 @@ CustomCtx extends object = object, AgentTools extends ToolSet = any> {
1359
1405
  stopSequences?: string[] | undefined;
1360
1406
  seed?: number | undefined;
1361
1407
  maxRetries?: number | undefined;
1408
+ headers?: Record<string, string> | undefined;
1362
1409
  } | undefined;
1363
1410
  }, Promise<{
1364
1411
  text: string;
@@ -1529,9 +1576,9 @@ CustomCtx extends object = object, AgentTools extends ToolSet = any> {
1529
1576
  toolCallId: string;
1530
1577
  toolName: string;
1531
1578
  } | {
1532
- title?: string | undefined;
1533
1579
  providerOptions?: Record<string, Record<string, any>> | undefined;
1534
1580
  providerMetadata?: Record<string, Record<string, any>> | undefined;
1581
+ title?: string | undefined;
1535
1582
  id: string;
1536
1583
  type: "source";
1537
1584
  url: string;
@@ -1541,10 +1588,10 @@ CustomCtx extends object = object, AgentTools extends ToolSet = any> {
1541
1588
  providerMetadata?: Record<string, Record<string, any>> | undefined;
1542
1589
  filename?: string | undefined;
1543
1590
  id: string;
1544
- title: string;
1545
1591
  type: "source";
1546
1592
  mediaType: string;
1547
1593
  sourceType: "document";
1594
+ title: string;
1548
1595
  } | {
1549
1596
  providerOptions?: Record<string, Record<string, any>> | undefined;
1550
1597
  providerMetadata?: Record<string, Record<string, any>> | undefined;
@@ -1670,7 +1717,6 @@ CustomCtx extends object = object, AgentTools extends ToolSet = any> {
1670
1717
  saveMessages?: "all" | "none" | "promptAndOutput" | undefined;
1671
1718
  } | undefined;
1672
1719
  callSettings?: {
1673
- headers?: Record<string, string> | undefined;
1674
1720
  maxOutputTokens?: number | undefined;
1675
1721
  temperature?: number | undefined;
1676
1722
  topP?: number | undefined;
@@ -1680,6 +1726,7 @@ CustomCtx extends object = object, AgentTools extends ToolSet = any> {
1680
1726
  stopSequences?: string[] | undefined;
1681
1727
  seed?: number | undefined;
1682
1728
  maxRetries?: number | undefined;
1729
+ headers?: Record<string, string> | undefined;
1683
1730
  } | undefined;
1684
1731
  }, Promise<{
1685
1732
  object: T;
@@ -1695,16 +1742,16 @@ CustomCtx extends object = object, AgentTools extends ToolSet = any> {
1695
1742
  asSaveMessagesMutation(): import("convex/server").RegisteredMutation<"internal", {
1696
1743
  userId?: string | undefined;
1697
1744
  promptMessageId?: string | undefined;
1745
+ failPendingSteps?: boolean | undefined;
1698
1746
  embeddings?: {
1699
1747
  model: string;
1700
1748
  vectors: (number[] | null)[];
1701
1749
  } | undefined;
1702
- failPendingSteps?: boolean | undefined;
1703
1750
  threadId: string;
1704
1751
  messages: {
1705
- status?: "pending" | "success" | "failed" | undefined;
1706
1752
  fileIds?: string[] | undefined;
1707
1753
  error?: string | undefined;
1754
+ status?: "pending" | "success" | "failed" | undefined;
1708
1755
  model?: string | undefined;
1709
1756
  provider?: string | undefined;
1710
1757
  text?: string | undefined;
@@ -1718,10 +1765,10 @@ CustomCtx extends object = object, AgentTools extends ToolSet = any> {
1718
1765
  totalTokens: number;
1719
1766
  } | undefined;
1720
1767
  sources?: ({
1721
- title?: string | undefined;
1722
1768
  type?: "source" | undefined;
1723
1769
  providerOptions?: Record<string, Record<string, any>> | undefined;
1724
1770
  providerMetadata?: Record<string, Record<string, any>> | undefined;
1771
+ title?: string | undefined;
1725
1772
  id: string;
1726
1773
  url: string;
1727
1774
  sourceType: "url";
@@ -1730,10 +1777,10 @@ CustomCtx extends object = object, AgentTools extends ToolSet = any> {
1730
1777
  providerMetadata?: Record<string, Record<string, any>> | undefined;
1731
1778
  filename?: string | undefined;
1732
1779
  id: string;
1733
- title: string;
1734
1780
  type: "source";
1735
1781
  mediaType: string;
1736
1782
  sourceType: "document";
1783
+ title: string;
1737
1784
  })[] | undefined;
1738
1785
  warnings?: ({
1739
1786
  details?: string | undefined;
@@ -1747,7 +1794,7 @@ CustomCtx extends object = object, AgentTools extends ToolSet = any> {
1747
1794
  type: "other";
1748
1795
  message: string;
1749
1796
  })[] | undefined;
1750
- finishReason?: "error" | "length" | "other" | "stop" | "content-filter" | "tool-calls" | "unknown" | undefined;
1797
+ finishReason?: "length" | "error" | "other" | "stop" | "content-filter" | "tool-calls" | "unknown" | undefined;
1751
1798
  reasoningDetails?: ({
1752
1799
  providerOptions?: Record<string, Record<string, any>> | undefined;
1753
1800
  providerMetadata?: Record<string, Record<string, any>> | undefined;
@@ -1911,9 +1958,9 @@ CustomCtx extends object = object, AgentTools extends ToolSet = any> {
1911
1958
  toolCallId: string;
1912
1959
  toolName: string;
1913
1960
  } | {
1914
- title?: string | undefined;
1915
1961
  providerOptions?: Record<string, Record<string, any>> | undefined;
1916
1962
  providerMetadata?: Record<string, Record<string, any>> | undefined;
1963
+ title?: string | undefined;
1917
1964
  id: string;
1918
1965
  type: "source";
1919
1966
  url: string;
@@ -1923,10 +1970,10 @@ CustomCtx extends object = object, AgentTools extends ToolSet = any> {
1923
1970
  providerMetadata?: Record<string, Record<string, any>> | undefined;
1924
1971
  filename?: string | undefined;
1925
1972
  id: string;
1926
- title: string;
1927
1973
  type: "source";
1928
1974
  mediaType: string;
1929
1975
  sourceType: "document";
1976
+ title: string;
1930
1977
  } | {
1931
1978
  providerOptions?: Record<string, Record<string, any>> | undefined;
1932
1979
  providerMetadata?: Record<string, Record<string, any>> | undefined;
@@ -2035,9 +2082,9 @@ CustomCtx extends object = object, AgentTools extends ToolSet = any> {
2035
2082
  }, Promise<{
2036
2083
  lastMessageId: string;
2037
2084
  messages: {
2085
+ _id: string;
2038
2086
  order: number;
2039
2087
  stepOrder: number;
2040
- _id: string;
2041
2088
  }[];
2042
2089
  }>>;
2043
2090
  }