@convex-dev/agent 0.0.16 → 0.0.17-alpha.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 (108) hide show
  1. package/README.md +159 -98
  2. package/dist/commonjs/client/index.d.ts +806 -189
  3. package/dist/commonjs/client/index.d.ts.map +1 -1
  4. package/dist/commonjs/client/index.js +178 -28
  5. package/dist/commonjs/client/index.js.map +1 -1
  6. package/dist/commonjs/client/playground.d.ts +609 -0
  7. package/dist/commonjs/client/playground.d.ts.map +1 -0
  8. package/dist/commonjs/client/playground.js +200 -0
  9. package/dist/commonjs/client/playground.js.map +1 -0
  10. package/dist/commonjs/component/apiKeys.d.ts +11 -0
  11. package/dist/commonjs/component/apiKeys.d.ts.map +1 -0
  12. package/dist/commonjs/component/apiKeys.js +69 -0
  13. package/dist/commonjs/component/apiKeys.js.map +1 -0
  14. package/dist/commonjs/component/files.d.ts +31 -0
  15. package/dist/commonjs/component/files.d.ts.map +1 -0
  16. package/dist/commonjs/component/files.js +61 -0
  17. package/dist/commonjs/component/files.js.map +1 -0
  18. package/dist/commonjs/component/messages.d.ts +720 -676
  19. package/dist/commonjs/component/messages.d.ts.map +1 -1
  20. package/dist/commonjs/component/messages.js +99 -287
  21. package/dist/commonjs/component/messages.js.map +1 -1
  22. package/dist/commonjs/component/schema.d.ts +1124 -1324
  23. package/dist/commonjs/component/schema.d.ts.map +1 -1
  24. package/dist/commonjs/component/schema.js +26 -14
  25. package/dist/commonjs/component/schema.js.map +1 -1
  26. package/dist/commonjs/component/threads.d.ts +95 -0
  27. package/dist/commonjs/component/threads.d.ts.map +1 -0
  28. package/dist/commonjs/component/threads.js +151 -0
  29. package/dist/commonjs/component/threads.js.map +1 -0
  30. package/dist/commonjs/component/users.d.ts +37 -0
  31. package/dist/commonjs/component/users.d.ts.map +1 -0
  32. package/dist/commonjs/component/users.js +118 -0
  33. package/dist/commonjs/component/users.js.map +1 -0
  34. package/dist/commonjs/component/vector/index.d.ts.map +1 -1
  35. package/dist/commonjs/component/vector/index.js +4 -6
  36. package/dist/commonjs/component/vector/index.js.map +1 -1
  37. package/dist/commonjs/component/vector/tables.d.ts +10 -10
  38. package/dist/commonjs/component/vector/tables.d.ts.map +1 -1
  39. package/dist/commonjs/component/vector/tables.js.map +1 -1
  40. package/dist/commonjs/mapping.d.ts +7 -1
  41. package/dist/commonjs/mapping.d.ts.map +1 -1
  42. package/dist/commonjs/mapping.js +39 -18
  43. package/dist/commonjs/mapping.js.map +1 -1
  44. package/dist/commonjs/validators.d.ts +1669 -2340
  45. package/dist/commonjs/validators.d.ts.map +1 -1
  46. package/dist/commonjs/validators.js +35 -26
  47. package/dist/commonjs/validators.js.map +1 -1
  48. package/dist/esm/client/index.d.ts +806 -189
  49. package/dist/esm/client/index.d.ts.map +1 -1
  50. package/dist/esm/client/index.js +178 -28
  51. package/dist/esm/client/index.js.map +1 -1
  52. package/dist/esm/client/playground.d.ts +609 -0
  53. package/dist/esm/client/playground.d.ts.map +1 -0
  54. package/dist/esm/client/playground.js +200 -0
  55. package/dist/esm/client/playground.js.map +1 -0
  56. package/dist/esm/component/apiKeys.d.ts +11 -0
  57. package/dist/esm/component/apiKeys.d.ts.map +1 -0
  58. package/dist/esm/component/apiKeys.js +69 -0
  59. package/dist/esm/component/apiKeys.js.map +1 -0
  60. package/dist/esm/component/files.d.ts +31 -0
  61. package/dist/esm/component/files.d.ts.map +1 -0
  62. package/dist/esm/component/files.js +61 -0
  63. package/dist/esm/component/files.js.map +1 -0
  64. package/dist/esm/component/messages.d.ts +720 -676
  65. package/dist/esm/component/messages.d.ts.map +1 -1
  66. package/dist/esm/component/messages.js +99 -287
  67. package/dist/esm/component/messages.js.map +1 -1
  68. package/dist/esm/component/schema.d.ts +1124 -1324
  69. package/dist/esm/component/schema.d.ts.map +1 -1
  70. package/dist/esm/component/schema.js +26 -14
  71. package/dist/esm/component/schema.js.map +1 -1
  72. package/dist/esm/component/threads.d.ts +95 -0
  73. package/dist/esm/component/threads.d.ts.map +1 -0
  74. package/dist/esm/component/threads.js +151 -0
  75. package/dist/esm/component/threads.js.map +1 -0
  76. package/dist/esm/component/users.d.ts +37 -0
  77. package/dist/esm/component/users.d.ts.map +1 -0
  78. package/dist/esm/component/users.js +118 -0
  79. package/dist/esm/component/users.js.map +1 -0
  80. package/dist/esm/component/vector/index.d.ts.map +1 -1
  81. package/dist/esm/component/vector/index.js +4 -6
  82. package/dist/esm/component/vector/index.js.map +1 -1
  83. package/dist/esm/component/vector/tables.d.ts +10 -10
  84. package/dist/esm/component/vector/tables.d.ts.map +1 -1
  85. package/dist/esm/component/vector/tables.js.map +1 -1
  86. package/dist/esm/mapping.d.ts +7 -1
  87. package/dist/esm/mapping.d.ts.map +1 -1
  88. package/dist/esm/mapping.js +39 -18
  89. package/dist/esm/mapping.js.map +1 -1
  90. package/dist/esm/validators.d.ts +1669 -2340
  91. package/dist/esm/validators.d.ts.map +1 -1
  92. package/dist/esm/validators.js +35 -26
  93. package/dist/esm/validators.js.map +1 -1
  94. package/package.json +8 -1
  95. package/src/client/index.ts +220 -59
  96. package/src/client/playground.ts +257 -0
  97. package/src/component/_generated/api.d.ts +601 -400
  98. package/src/component/apiKeys.ts +74 -0
  99. package/src/component/files.ts +72 -0
  100. package/src/component/messages.test.ts +23 -0
  101. package/src/component/messages.ts +127 -341
  102. package/src/component/schema.ts +32 -13
  103. package/src/component/threads.ts +184 -0
  104. package/src/component/users.ts +145 -0
  105. package/src/component/vector/index.ts +5 -6
  106. package/src/component/vector/tables.ts +15 -15
  107. package/src/mapping.ts +65 -32
  108. package/src/validators.ts +47 -28
@@ -1,34 +1,29 @@
1
1
  import type { EmbeddingModelV1, LanguageModelV1 } from "@ai-sdk/provider";
2
- import type { CoreMessage, DeepPartial, GenerateObjectResult, GenerateTextResult, JSONValue, RepairTextFunction, Schema, StepResult, StreamObjectResult, StreamTextResult, TelemetrySettings, Tool, ToolChoice, ToolExecutionOptions, ToolSet } from "ai";
2
+ import type { CoreMessage, DeepPartial, GenerateObjectResult, GenerateTextResult, JSONValue, RepairTextFunction, Schema, StepResult, StreamObjectResult, StreamTextResult, TelemetrySettings, Tool, ToolChoice, ToolExecutionOptions, ToolSet, UIMessage } from "ai";
3
3
  import { generateObject, generateText, streamObject, streamText } from "ai";
4
4
  import { Infer } from "convex/values";
5
5
  import { z } from "zod";
6
6
  import { Mounts } from "../component/_generated/api.js";
7
7
  import { type VectorDimension } from "../component/vector/tables.js";
8
8
  import { type AIMessageWithoutId } from "../mapping.js";
9
- import { type CallSettings, MessageWithMetadata, type ProviderMetadata, type ProviderOptions, type SearchOptions, type Usage } from "../validators.js";
9
+ import { extractText, isTool } from "../shared.js";
10
+ import { type CallSettings, type MessageWithMetadata as InnerMessageWithMetadata, type ProviderMetadata, type ProviderOptions, type SearchOptions, type Usage } from "../validators.js";
10
11
  import type { OpaqueIds, RunActionCtx, RunMutationCtx, RunQueryCtx, UseApi } from "./types.js";
11
- import schema from "../component/schema.js";
12
+ export { extractText, isTool };
12
13
  export type { Usage, ProviderMetadata };
13
- export { vUsage, vProviderMetadata, vUserMessage, vAssistantMessage, vToolMessage, vSystemMessage, vMessage, } from "../validators.js";
14
- export type ThreadDoc = OpaqueIds<{
15
- _id: string;
16
- _creationTime: number;
17
- } & Infer<typeof schema.tables.threads.validator>>;
18
- export type MessageDoc = OpaqueIds<{
19
- _id: string;
20
- _creationTime: number;
21
- } & Infer<typeof schema.tables.messages.validator>>;
14
+ export { paginationResultValidator, vContextOptions, vUsage, vProviderMetadata, vUserMessage, vAssistantMessage, vToolMessage, vStorageOptions, vSystemMessage, vMessage, } from "../validators.js";
22
15
  /**
23
16
  * Options to configure what messages are fetched as context,
24
17
  * automatically with thread.generateText, or directly via search.
25
18
  */
26
19
  export type ContextOptions = {
20
+ /** @deprecated Use excludeToolMessages instead. */
21
+ includeToolCalls?: boolean;
27
22
  /**
28
23
  * Whether to include tool messages in the context.
29
24
  * By default, tool calls and results are not included.
30
25
  */
31
- includeToolCalls?: boolean;
26
+ excludeToolMessages?: boolean;
32
27
  /**
33
28
  * How many recent messages to include. These are added after the search
34
29
  * messages, and do not count against the search limit.
@@ -101,8 +96,9 @@ export type UsageHandler = (ctx: RunActionCtx, args: {
101
96
  model: string;
102
97
  provider: string;
103
98
  }) => void | Promise<void>;
99
+ export type AgentComponent = UseApi<Mounts>;
104
100
  export declare class Agent<AgentTools extends ToolSet> {
105
- component: UseApi<Mounts>;
101
+ component: AgentComponent;
106
102
  options: {
107
103
  /**
108
104
  * The name for the agent. This will be attributed on each message
@@ -166,7 +162,7 @@ export declare class Agent<AgentTools extends ToolSet> {
166
162
  */
167
163
  usageHandler?: UsageHandler;
168
164
  };
169
- constructor(component: UseApi<Mounts>, options: {
165
+ constructor(component: AgentComponent, options: {
170
166
  /**
171
167
  * The name for the agent. This will be attributed on each message
172
168
  * created by this agent.
@@ -346,9 +342,14 @@ export declare class Agent<AgentTools extends ToolSet> {
346
342
  userId: string | undefined;
347
343
  threadId: string | undefined;
348
344
  messages: CoreMessage[];
349
- parentMessageId?: string;
345
+ /**
346
+ * If provided, it will search for messages before this message.
347
+ * Note: if this is far in the past, the search results may be more
348
+ * limited, as it's post-filtering the results.
349
+ */
350
+ beforeMessageId?: string;
350
351
  contextOptions: ContextOptions | undefined;
351
- }): Promise<CoreMessage[]>;
352
+ }): Promise<MessageDoc[]>;
352
353
  /**
353
354
  * Get the embeddings for a set of messages.
354
355
  * @param messages The messages to get the embeddings for.
@@ -381,13 +382,8 @@ export declare class Agent<AgentTools extends ToolSet> {
381
382
  */
382
383
  pending?: boolean;
383
384
  /**
384
- * The message that this is responding to.
385
- */
386
- parentMessageId?: string;
387
- /**
388
- * Whether to mark all pending messages in the thread as failed.
389
- * This is used to recover from a failure via a retry that wipes the slate clean.
390
- * Defaults to true.
385
+ * If true, it will fail any pending steps.
386
+ * Defaults to false.
391
387
  */
392
388
  failPendingSteps?: boolean;
393
389
  }): Promise<{
@@ -405,7 +401,7 @@ export declare class Agent<AgentTools extends ToolSet> {
405
401
  /**
406
402
  * The message this step is in response to.
407
403
  */
408
- messageId: string;
404
+ parentMessageId: string;
409
405
  /**
410
406
  * The step to save, possibly including multiple tool calls.
411
407
  */
@@ -492,7 +488,7 @@ export declare class Agent<AgentTools extends ToolSet> {
492
488
  prompt?: string;
493
489
  messages?: CoreMessage[] | AIMessageWithoutId[];
494
490
  system?: string;
495
- }>(ctx: RunActionCtx | RunMutationCtx, args: T, { userId, threadId, parentMessageId, contextOptions, storageOptions, }: {
491
+ }>(ctx: RunActionCtx | RunMutationCtx, args: T, { userId, threadId, contextOptions, storageOptions, }: {
496
492
  userId: string | undefined;
497
493
  threadId: string | undefined;
498
494
  } & Options): Promise<{
@@ -543,7 +539,7 @@ export declare class Agent<AgentTools extends ToolSet> {
543
539
  saveObject(ctx: RunMutationCtx, args: {
544
540
  userId: string | undefined;
545
541
  threadId: string;
546
- messageId: string;
542
+ parentMessageId: string;
547
543
  result: GenerateObjectResult<unknown>;
548
544
  metadata?: Omit<MessageWithMetadata, "message">;
549
545
  }): Promise<void>;
@@ -587,69 +583,57 @@ export declare class Agent<AgentTools extends ToolSet> {
587
583
  }): import("convex/server").RegisteredAction<"internal", {
588
584
  userId?: string | undefined;
589
585
  threadId?: string | undefined;
590
- parentMessageId?: string | undefined;
591
586
  messages?: ({
592
- providerOptions?: Record<string, any> | undefined;
593
- experimental_providerMetadata?: Record<string, any> | undefined;
587
+ providerOptions?: Record<string, Record<string, any>> | undefined;
594
588
  role: "user";
595
589
  content: string | ({
596
- providerOptions?: Record<string, any> | undefined;
597
- experimental_providerMetadata?: Record<string, any> | undefined;
590
+ providerOptions?: Record<string, Record<string, any>> | undefined;
598
591
  type: "text";
599
592
  text: string;
600
593
  } | {
601
- providerOptions?: Record<string, any> | undefined;
602
- experimental_providerMetadata?: Record<string, any> | undefined;
594
+ providerOptions?: Record<string, Record<string, any>> | undefined;
603
595
  mimeType?: string | undefined;
604
596
  type: "image";
605
597
  image: string | ArrayBuffer;
606
598
  } | {
607
- providerOptions?: Record<string, any> | undefined;
608
- experimental_providerMetadata?: Record<string, any> | undefined;
599
+ providerOptions?: Record<string, Record<string, any>> | undefined;
609
600
  type: "file";
610
601
  mimeType: string;
611
602
  data: string | ArrayBuffer;
612
603
  })[];
613
604
  } | {
614
- providerOptions?: Record<string, any> | undefined;
615
- experimental_providerMetadata?: Record<string, any> | undefined;
605
+ providerOptions?: Record<string, Record<string, any>> | undefined;
616
606
  role: "assistant";
617
607
  content: string | ({
618
- providerOptions?: Record<string, any> | undefined;
619
- experimental_providerMetadata?: Record<string, any> | undefined;
608
+ providerOptions?: Record<string, Record<string, any>> | undefined;
620
609
  type: "text";
621
610
  text: string;
622
611
  } | {
623
- providerOptions?: Record<string, any> | undefined;
624
- experimental_providerMetadata?: Record<string, any> | undefined;
612
+ providerOptions?: Record<string, Record<string, any>> | undefined;
625
613
  type: "file";
626
614
  mimeType: string;
627
615
  data: string | ArrayBuffer;
628
616
  } | {
629
- providerOptions?: Record<string, any> | undefined;
630
- experimental_providerMetadata?: Record<string, any> | undefined;
617
+ providerOptions?: Record<string, Record<string, any>> | undefined;
618
+ signature?: string | undefined;
631
619
  type: "reasoning";
632
620
  text: string;
633
621
  } | {
634
- providerOptions?: Record<string, any> | undefined;
635
- experimental_providerMetadata?: Record<string, any> | undefined;
622
+ providerOptions?: Record<string, Record<string, any>> | undefined;
636
623
  type: "redacted-reasoning";
637
624
  data: string;
638
625
  } | {
639
- providerOptions?: Record<string, any> | undefined;
640
- experimental_providerMetadata?: Record<string, any> | undefined;
626
+ providerOptions?: Record<string, Record<string, any>> | undefined;
641
627
  type: "tool-call";
642
628
  toolCallId: string;
643
629
  toolName: string;
644
630
  args: any;
645
631
  })[];
646
632
  } | {
647
- providerOptions?: Record<string, any> | undefined;
648
- experimental_providerMetadata?: Record<string, any> | undefined;
633
+ providerOptions?: Record<string, Record<string, any>> | undefined;
649
634
  role: "tool";
650
635
  content: {
651
- providerOptions?: Record<string, any> | undefined;
652
- experimental_providerMetadata?: Record<string, any> | undefined;
636
+ providerOptions?: Record<string, Record<string, any>> | undefined;
653
637
  args?: any;
654
638
  experimental_content?: ({
655
639
  type: "text";
@@ -666,13 +650,11 @@ export declare class Agent<AgentTools extends ToolSet> {
666
650
  result: any;
667
651
  }[];
668
652
  } | {
669
- providerOptions?: Record<string, any> | undefined;
670
- experimental_providerMetadata?: Record<string, any> | undefined;
653
+ providerOptions?: Record<string, Record<string, any>> | undefined;
671
654
  role: "system";
672
655
  content: string;
673
656
  })[] | undefined;
674
- providerOptions?: Record<string, any> | undefined;
675
- experimental_providerMetadata?: Record<string, any> | undefined;
657
+ providerOptions?: Record<string, Record<string, any>> | undefined;
676
658
  system?: string | undefined;
677
659
  headers?: Record<string, string> | undefined;
678
660
  maxTokens?: number | undefined;
@@ -691,7 +673,7 @@ export declare class Agent<AgentTools extends ToolSet> {
691
673
  experimental_continueSteps?: boolean | undefined;
692
674
  prompt?: string | undefined;
693
675
  contextOptions?: {
694
- includeToolCalls?: boolean | undefined;
676
+ excludeToolMessages?: boolean | undefined;
695
677
  recentMessages?: number | undefined;
696
678
  searchOptions?: {
697
679
  messageRange?: {
@@ -706,7 +688,8 @@ export declare class Agent<AgentTools extends ToolSet> {
706
688
  } | undefined;
707
689
  storageOptions?: {
708
690
  saveAllInputMessages?: boolean | undefined;
709
- saveAllOutputMessages?: boolean | undefined;
691
+ saveAnyInputMessages?: boolean | undefined;
692
+ saveOutputMessages?: boolean | undefined;
710
693
  } | undefined;
711
694
  }, Promise<string>>;
712
695
  /**
@@ -724,69 +707,57 @@ export declare class Agent<AgentTools extends ToolSet> {
724
707
  }): import("convex/server").RegisteredAction<"internal", {
725
708
  userId?: string | undefined;
726
709
  threadId?: string | undefined;
727
- parentMessageId?: string | undefined;
728
710
  messages?: ({
729
- providerOptions?: Record<string, any> | undefined;
730
- experimental_providerMetadata?: Record<string, any> | undefined;
711
+ providerOptions?: Record<string, Record<string, any>> | undefined;
731
712
  role: "user";
732
713
  content: string | ({
733
- providerOptions?: Record<string, any> | undefined;
734
- experimental_providerMetadata?: Record<string, any> | undefined;
714
+ providerOptions?: Record<string, Record<string, any>> | undefined;
735
715
  type: "text";
736
716
  text: string;
737
717
  } | {
738
- providerOptions?: Record<string, any> | undefined;
739
- experimental_providerMetadata?: Record<string, any> | undefined;
718
+ providerOptions?: Record<string, Record<string, any>> | undefined;
740
719
  mimeType?: string | undefined;
741
720
  type: "image";
742
721
  image: string | ArrayBuffer;
743
722
  } | {
744
- providerOptions?: Record<string, any> | undefined;
745
- experimental_providerMetadata?: Record<string, any> | undefined;
723
+ providerOptions?: Record<string, Record<string, any>> | undefined;
746
724
  type: "file";
747
725
  mimeType: string;
748
726
  data: string | ArrayBuffer;
749
727
  })[];
750
728
  } | {
751
- providerOptions?: Record<string, any> | undefined;
752
- experimental_providerMetadata?: Record<string, any> | undefined;
729
+ providerOptions?: Record<string, Record<string, any>> | undefined;
753
730
  role: "assistant";
754
731
  content: string | ({
755
- providerOptions?: Record<string, any> | undefined;
756
- experimental_providerMetadata?: Record<string, any> | undefined;
732
+ providerOptions?: Record<string, Record<string, any>> | undefined;
757
733
  type: "text";
758
734
  text: string;
759
735
  } | {
760
- providerOptions?: Record<string, any> | undefined;
761
- experimental_providerMetadata?: Record<string, any> | undefined;
736
+ providerOptions?: Record<string, Record<string, any>> | undefined;
762
737
  type: "file";
763
738
  mimeType: string;
764
739
  data: string | ArrayBuffer;
765
740
  } | {
766
- providerOptions?: Record<string, any> | undefined;
767
- experimental_providerMetadata?: Record<string, any> | undefined;
741
+ providerOptions?: Record<string, Record<string, any>> | undefined;
742
+ signature?: string | undefined;
768
743
  type: "reasoning";
769
744
  text: string;
770
745
  } | {
771
- providerOptions?: Record<string, any> | undefined;
772
- experimental_providerMetadata?: Record<string, any> | undefined;
746
+ providerOptions?: Record<string, Record<string, any>> | undefined;
773
747
  type: "redacted-reasoning";
774
748
  data: string;
775
749
  } | {
776
- providerOptions?: Record<string, any> | undefined;
777
- experimental_providerMetadata?: Record<string, any> | undefined;
750
+ providerOptions?: Record<string, Record<string, any>> | undefined;
778
751
  type: "tool-call";
779
752
  toolCallId: string;
780
753
  toolName: string;
781
754
  args: any;
782
755
  })[];
783
756
  } | {
784
- providerOptions?: Record<string, any> | undefined;
785
- experimental_providerMetadata?: Record<string, any> | undefined;
757
+ providerOptions?: Record<string, Record<string, any>> | undefined;
786
758
  role: "tool";
787
759
  content: {
788
- providerOptions?: Record<string, any> | undefined;
789
- experimental_providerMetadata?: Record<string, any> | undefined;
760
+ providerOptions?: Record<string, Record<string, any>> | undefined;
790
761
  args?: any;
791
762
  experimental_content?: ({
792
763
  type: "text";
@@ -803,13 +774,11 @@ export declare class Agent<AgentTools extends ToolSet> {
803
774
  result: any;
804
775
  }[];
805
776
  } | {
806
- providerOptions?: Record<string, any> | undefined;
807
- experimental_providerMetadata?: Record<string, any> | undefined;
777
+ providerOptions?: Record<string, Record<string, any>> | undefined;
808
778
  role: "system";
809
779
  content: string;
810
780
  })[] | undefined;
811
- providerOptions?: Record<string, any> | undefined;
812
- experimental_providerMetadata?: Record<string, any> | undefined;
781
+ providerOptions?: Record<string, Record<string, any>> | undefined;
813
782
  system?: string | undefined;
814
783
  headers?: Record<string, string> | undefined;
815
784
  maxTokens?: number | undefined;
@@ -822,7 +791,7 @@ export declare class Agent<AgentTools extends ToolSet> {
822
791
  maxRetries?: number | undefined;
823
792
  prompt?: string | undefined;
824
793
  contextOptions?: {
825
- includeToolCalls?: boolean | undefined;
794
+ excludeToolMessages?: boolean | undefined;
826
795
  recentMessages?: number | undefined;
827
796
  searchOptions?: {
828
797
  messageRange?: {
@@ -837,128 +806,73 @@ export declare class Agent<AgentTools extends ToolSet> {
837
806
  } | undefined;
838
807
  storageOptions?: {
839
808
  saveAllInputMessages?: boolean | undefined;
840
- saveAllOutputMessages?: boolean | undefined;
809
+ saveAnyInputMessages?: boolean | undefined;
810
+ saveOutputMessages?: boolean | undefined;
841
811
  } | undefined;
842
812
  }, Promise<T>>;
843
813
  }
844
814
  export declare function filterOutOrphanedToolMessages(docs: MessageDoc[]): {
845
- _id: string;
846
- _creationTime: number;
847
815
  id?: string | undefined;
848
816
  userId?: string | undefined;
849
817
  parentMessageId?: string | undefined;
850
818
  stepId?: string | undefined;
819
+ embeddingId?: string | undefined;
820
+ error?: string | undefined;
851
821
  agentName?: string | undefined;
822
+ model?: string | undefined;
823
+ provider?: string | undefined;
824
+ providerOptions?: Record<string, Record<string, any>> | undefined;
852
825
  message?: {
853
- providerOptions?: {
854
- [x: string]: any;
855
- } | undefined;
856
- experimental_providerMetadata?: {
857
- [x: string]: any;
858
- } | undefined;
826
+ providerOptions?: Record<string, Record<string, any>> | undefined;
859
827
  role: "user";
860
828
  content: string | ({
861
- providerOptions?: {
862
- [x: string]: any;
863
- } | undefined;
864
- experimental_providerMetadata?: {
865
- [x: string]: any;
866
- } | undefined;
829
+ providerOptions?: Record<string, Record<string, any>> | undefined;
867
830
  type: "text";
868
831
  text: string;
869
832
  } | {
870
- providerOptions?: {
871
- [x: string]: any;
872
- } | undefined;
873
- experimental_providerMetadata?: {
874
- [x: string]: any;
875
- } | undefined;
833
+ providerOptions?: Record<string, Record<string, any>> | undefined;
876
834
  mimeType?: string | undefined;
877
835
  type: "image";
878
836
  image: string | ArrayBuffer;
879
837
  } | {
880
- providerOptions?: {
881
- [x: string]: any;
882
- } | undefined;
883
- experimental_providerMetadata?: {
884
- [x: string]: any;
885
- } | undefined;
838
+ providerOptions?: Record<string, Record<string, any>> | undefined;
886
839
  type: "file";
887
840
  mimeType: string;
888
841
  data: string | ArrayBuffer;
889
842
  })[];
890
843
  } | {
891
- providerOptions?: {
892
- [x: string]: any;
893
- } | undefined;
894
- experimental_providerMetadata?: {
895
- [x: string]: any;
896
- } | undefined;
844
+ providerOptions?: Record<string, Record<string, any>> | undefined;
897
845
  role: "assistant";
898
846
  content: string | ({
899
- providerOptions?: {
900
- [x: string]: any;
901
- } | undefined;
902
- experimental_providerMetadata?: {
903
- [x: string]: any;
904
- } | undefined;
847
+ providerOptions?: Record<string, Record<string, any>> | undefined;
905
848
  type: "text";
906
849
  text: string;
907
850
  } | {
908
- providerOptions?: {
909
- [x: string]: any;
910
- } | undefined;
911
- experimental_providerMetadata?: {
912
- [x: string]: any;
913
- } | undefined;
851
+ providerOptions?: Record<string, Record<string, any>> | undefined;
914
852
  type: "file";
915
853
  mimeType: string;
916
854
  data: string | ArrayBuffer;
917
855
  } | {
918
- providerOptions?: {
919
- [x: string]: any;
920
- } | undefined;
921
- experimental_providerMetadata?: {
922
- [x: string]: any;
923
- } | undefined;
856
+ providerOptions?: Record<string, Record<string, any>> | undefined;
857
+ signature?: string | undefined;
924
858
  type: "reasoning";
925
859
  text: string;
926
860
  } | {
927
- providerOptions?: {
928
- [x: string]: any;
929
- } | undefined;
930
- experimental_providerMetadata?: {
931
- [x: string]: any;
932
- } | undefined;
861
+ providerOptions?: Record<string, Record<string, any>> | undefined;
933
862
  type: "redacted-reasoning";
934
863
  data: string;
935
864
  } | {
936
- providerOptions?: {
937
- [x: string]: any;
938
- } | undefined;
939
- experimental_providerMetadata?: {
940
- [x: string]: any;
941
- } | undefined;
865
+ providerOptions?: Record<string, Record<string, any>> | undefined;
942
866
  type: "tool-call";
943
867
  toolCallId: string;
944
868
  toolName: string;
945
869
  args: any;
946
870
  })[];
947
871
  } | {
948
- providerOptions?: {
949
- [x: string]: any;
950
- } | undefined;
951
- experimental_providerMetadata?: {
952
- [x: string]: any;
953
- } | undefined;
872
+ providerOptions?: Record<string, Record<string, any>> | undefined;
954
873
  role: "tool";
955
874
  content: {
956
- providerOptions?: {
957
- [x: string]: any;
958
- } | undefined;
959
- experimental_providerMetadata?: {
960
- [x: string]: any;
961
- } | undefined;
875
+ providerOptions?: Record<string, Record<string, any>> | undefined;
962
876
  args?: any;
963
877
  experimental_content?: ({
964
878
  type: "text";
@@ -975,41 +889,39 @@ export declare function filterOutOrphanedToolMessages(docs: MessageDoc[]): {
975
889
  result: any;
976
890
  }[];
977
891
  } | {
978
- providerOptions?: {
979
- [x: string]: any;
980
- } | undefined;
981
- experimental_providerMetadata?: {
982
- [x: string]: any;
983
- } | undefined;
892
+ providerOptions?: Record<string, Record<string, any>> | undefined;
984
893
  role: "system";
985
894
  content: string;
986
895
  } | undefined;
987
896
  text?: string | undefined;
988
897
  reasoning?: string | undefined;
989
- error?: string | undefined;
990
- model?: string | undefined;
991
- provider?: string | undefined;
992
- embeddingId?: string | undefined;
898
+ files?: {
899
+ bytes?: ArrayBuffer | undefined;
900
+ url?: string | undefined;
901
+ fileId?: string | undefined;
902
+ mimeType: string;
903
+ }[] | undefined;
993
904
  usage?: {
994
905
  promptTokens: number;
995
906
  completionTokens: number;
996
907
  totalTokens: number;
997
908
  } | undefined;
998
- finishReason?: "length" | "error" | "stop" | "content-filter" | "tool-calls" | "other" | "unknown" | undefined;
999
- providerMetadata?: {
1000
- [x: string]: any;
1001
- } | undefined;
909
+ providerMetadata?: Record<string, Record<string, any>> | undefined;
1002
910
  sources?: {
1003
911
  title?: string | undefined;
1004
- providerMetadata?: {
1005
- [x: string]: {
1006
- [x: string]: any;
1007
- };
1008
- } | undefined;
912
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1009
913
  id: string;
1010
- sourceType: "url";
1011
914
  url: string;
915
+ sourceType: "url";
1012
916
  }[] | undefined;
917
+ reasoningDetails?: ({
918
+ signature?: string | undefined;
919
+ type: "text";
920
+ text: string;
921
+ } | {
922
+ type: "redacted";
923
+ data: string;
924
+ })[] | undefined;
1013
925
  warnings?: ({
1014
926
  details?: string | undefined;
1015
927
  type: "unsupported-setting";
@@ -1022,12 +934,14 @@ export declare function filterOutOrphanedToolMessages(docs: MessageDoc[]): {
1022
934
  type: "other";
1023
935
  message: string;
1024
936
  })[] | undefined;
1025
- fileId?: string | undefined;
937
+ finishReason?: "length" | "error" | "other" | "stop" | "content-filter" | "tool-calls" | "unknown" | undefined;
1026
938
  status: "pending" | "success" | "failed";
1027
939
  order: number;
940
+ _creationTime: number;
1028
941
  threadId: string;
1029
- tool: boolean;
1030
942
  stepOrder: number;
943
+ tool: boolean;
944
+ _id: string;
1031
945
  }[];
1032
946
  export type ToolCtx = RunActionCtx & {
1033
947
  userId?: string;
@@ -1069,10 +983,6 @@ export declare function createTool<PARAMETERS extends ToolParameters, RESULT>(t:
1069
983
  execute: (args: inferParameters<PARAMETERS>, options: ToolExecutionOptions) => PromiseLike<RESULT>;
1070
984
  };
1071
985
  type Options = {
1072
- /**
1073
- * The parent message id to use for the tool calls.
1074
- */
1075
- parentMessageId?: string;
1076
986
  /**
1077
987
  * The context options to use for passing in message history to the LLM.
1078
988
  */
@@ -1239,4 +1149,711 @@ interface Thread<DefaultTools extends ToolSet> {
1239
1149
  */
1240
1150
  streamObject<T>(args: OurStreamObjectArgs<T>, options?: Options): Promise<StreamObjectResult<DeepPartial<T>, T, never> & ThreadOutputMetadata>;
1241
1151
  }
1152
+ export declare const vThreadDoc: import("convex/values").VObject<{
1153
+ userId?: string | undefined;
1154
+ title?: string | undefined;
1155
+ summary?: string | undefined;
1156
+ status: "active" | "archived";
1157
+ _creationTime: number;
1158
+ _id: string;
1159
+ }, {
1160
+ _id: import("convex/values").VString<string, "required">;
1161
+ _creationTime: import("convex/values").VFloat64<number, "required">;
1162
+ userId: import("convex/values").VString<string | undefined, "optional">;
1163
+ title: import("convex/values").VString<string | undefined, "optional">;
1164
+ summary: import("convex/values").VString<string | undefined, "optional">;
1165
+ status: import("convex/values").VUnion<"active" | "archived", [import("convex/values").VLiteral<"active", "required">, import("convex/values").VLiteral<"archived", "required">], "required", never>;
1166
+ }, "required", "status" | "userId" | "title" | "summary" | "_creationTime" | "_id">;
1167
+ export type ThreadDoc = Infer<typeof vThreadDoc>;
1168
+ export declare const vMessageDoc: import("convex/values").VObject<{
1169
+ id?: string | undefined;
1170
+ userId?: string | undefined;
1171
+ parentMessageId?: string | undefined;
1172
+ stepId?: string | undefined;
1173
+ embeddingId?: string | undefined;
1174
+ error?: string | undefined;
1175
+ agentName?: string | undefined;
1176
+ model?: string | undefined;
1177
+ provider?: string | undefined;
1178
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1179
+ message?: {
1180
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1181
+ role: "user";
1182
+ content: string | ({
1183
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1184
+ type: "text";
1185
+ text: string;
1186
+ } | {
1187
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1188
+ mimeType?: string | undefined;
1189
+ type: "image";
1190
+ image: string | ArrayBuffer;
1191
+ } | {
1192
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1193
+ type: "file";
1194
+ mimeType: string;
1195
+ data: string | ArrayBuffer;
1196
+ })[];
1197
+ } | {
1198
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1199
+ role: "assistant";
1200
+ content: string | ({
1201
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1202
+ type: "text";
1203
+ text: string;
1204
+ } | {
1205
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1206
+ type: "file";
1207
+ mimeType: string;
1208
+ data: string | ArrayBuffer;
1209
+ } | {
1210
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1211
+ signature?: string | undefined;
1212
+ type: "reasoning";
1213
+ text: string;
1214
+ } | {
1215
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1216
+ type: "redacted-reasoning";
1217
+ data: string;
1218
+ } | {
1219
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1220
+ type: "tool-call";
1221
+ toolCallId: string;
1222
+ toolName: string;
1223
+ args: any;
1224
+ })[];
1225
+ } | {
1226
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1227
+ role: "tool";
1228
+ content: {
1229
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1230
+ args?: any;
1231
+ experimental_content?: ({
1232
+ type: "text";
1233
+ text: string;
1234
+ } | {
1235
+ mimeType?: string | undefined;
1236
+ type: "image";
1237
+ data: string;
1238
+ })[] | undefined;
1239
+ isError?: boolean | undefined;
1240
+ type: "tool-result";
1241
+ toolCallId: string;
1242
+ toolName: string;
1243
+ result: any;
1244
+ }[];
1245
+ } | {
1246
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1247
+ role: "system";
1248
+ content: string;
1249
+ } | undefined;
1250
+ text?: string | undefined;
1251
+ reasoning?: string | undefined;
1252
+ files?: {
1253
+ bytes?: ArrayBuffer | undefined;
1254
+ url?: string | undefined;
1255
+ fileId?: string | undefined;
1256
+ mimeType: string;
1257
+ }[] | undefined;
1258
+ usage?: {
1259
+ promptTokens: number;
1260
+ completionTokens: number;
1261
+ totalTokens: number;
1262
+ } | undefined;
1263
+ providerMetadata?: Record<string, Record<string, any>> | undefined;
1264
+ sources?: {
1265
+ title?: string | undefined;
1266
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1267
+ id: string;
1268
+ url: string;
1269
+ sourceType: "url";
1270
+ }[] | undefined;
1271
+ reasoningDetails?: ({
1272
+ signature?: string | undefined;
1273
+ type: "text";
1274
+ text: string;
1275
+ } | {
1276
+ type: "redacted";
1277
+ data: string;
1278
+ })[] | undefined;
1279
+ warnings?: ({
1280
+ details?: string | undefined;
1281
+ type: "unsupported-setting";
1282
+ setting: string;
1283
+ } | {
1284
+ details?: string | undefined;
1285
+ type: "unsupported-tool";
1286
+ tool: any;
1287
+ } | {
1288
+ type: "other";
1289
+ message: string;
1290
+ })[] | undefined;
1291
+ finishReason?: "length" | "error" | "other" | "stop" | "content-filter" | "tool-calls" | "unknown" | undefined;
1292
+ status: "pending" | "success" | "failed";
1293
+ order: number;
1294
+ _creationTime: number;
1295
+ threadId: string;
1296
+ stepOrder: number;
1297
+ tool: boolean;
1298
+ _id: string;
1299
+ }, {
1300
+ threadId: import("convex/values").VString<string, "required">;
1301
+ parentMessageId: import("convex/values").VString<string | undefined, "optional">;
1302
+ stepId: import("convex/values").VString<string | undefined, "optional">;
1303
+ embeddingId: import("convex/values").VString<string | undefined, "optional">;
1304
+ files: import("convex/values").VArray<{
1305
+ bytes?: ArrayBuffer | undefined;
1306
+ url?: string | undefined;
1307
+ fileId?: string | undefined;
1308
+ mimeType: string;
1309
+ }[] | undefined, import("convex/values").VObject<{
1310
+ bytes?: ArrayBuffer | undefined;
1311
+ url?: string | undefined;
1312
+ fileId?: string | undefined;
1313
+ mimeType: string;
1314
+ }, {
1315
+ bytes: import("convex/values").VBytes<ArrayBuffer | undefined, "optional">;
1316
+ url: import("convex/values").VString<string | undefined, "optional">;
1317
+ mimeType: import("convex/values").VString<string, "required">;
1318
+ fileId: import("convex/values").VString<string | undefined, "optional">;
1319
+ }, "required", "bytes" | "mimeType" | "url" | "fileId">, "optional">;
1320
+ id: import("convex/values").VString<string | undefined, "optional">;
1321
+ userId: import("convex/values").VString<string | undefined, "optional">;
1322
+ order: import("convex/values").VFloat64<number, "required">;
1323
+ stepOrder: import("convex/values").VFloat64<number, "required">;
1324
+ error: import("convex/values").VString<string | undefined, "optional">;
1325
+ status: import("convex/values").VUnion<"pending" | "success" | "failed", [import("convex/values").VLiteral<"pending", "required">, import("convex/values").VLiteral<"success", "required">, import("convex/values").VLiteral<"failed", "required">], "required", never>;
1326
+ agentName: import("convex/values").VString<string | undefined, "optional">;
1327
+ model: import("convex/values").VString<string | undefined, "optional">;
1328
+ provider: import("convex/values").VString<string | undefined, "optional">;
1329
+ providerOptions: import("convex/values").VRecord<Record<string, Record<string, any>> | undefined, import("convex/values").VString<string, "required">, import("convex/values").VRecord<Record<string, any>, import("convex/values").VString<string, "required">, import("convex/values").VAny<any, "required", string>, "required", string>, "optional", string>;
1330
+ message: import("convex/values").VUnion<{
1331
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1332
+ role: "user";
1333
+ content: string | ({
1334
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1335
+ type: "text";
1336
+ text: string;
1337
+ } | {
1338
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1339
+ mimeType?: string | undefined;
1340
+ type: "image";
1341
+ image: string | ArrayBuffer;
1342
+ } | {
1343
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1344
+ type: "file";
1345
+ mimeType: string;
1346
+ data: string | ArrayBuffer;
1347
+ })[];
1348
+ } | {
1349
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1350
+ role: "assistant";
1351
+ content: string | ({
1352
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1353
+ type: "text";
1354
+ text: string;
1355
+ } | {
1356
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1357
+ type: "file";
1358
+ mimeType: string;
1359
+ data: string | ArrayBuffer;
1360
+ } | {
1361
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1362
+ signature?: string | undefined;
1363
+ type: "reasoning";
1364
+ text: string;
1365
+ } | {
1366
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1367
+ type: "redacted-reasoning";
1368
+ data: string;
1369
+ } | {
1370
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1371
+ type: "tool-call";
1372
+ toolCallId: string;
1373
+ toolName: string;
1374
+ args: any;
1375
+ })[];
1376
+ } | {
1377
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1378
+ role: "tool";
1379
+ content: {
1380
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1381
+ args?: any;
1382
+ experimental_content?: ({
1383
+ type: "text";
1384
+ text: string;
1385
+ } | {
1386
+ mimeType?: string | undefined;
1387
+ type: "image";
1388
+ data: string;
1389
+ })[] | undefined;
1390
+ isError?: boolean | undefined;
1391
+ type: "tool-result";
1392
+ toolCallId: string;
1393
+ toolName: string;
1394
+ result: any;
1395
+ }[];
1396
+ } | {
1397
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1398
+ role: "system";
1399
+ content: string;
1400
+ } | undefined, [import("convex/values").VObject<{
1401
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1402
+ role: "user";
1403
+ content: string | ({
1404
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1405
+ type: "text";
1406
+ text: string;
1407
+ } | {
1408
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1409
+ mimeType?: string | undefined;
1410
+ type: "image";
1411
+ image: string | ArrayBuffer;
1412
+ } | {
1413
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1414
+ type: "file";
1415
+ mimeType: string;
1416
+ data: string | ArrayBuffer;
1417
+ })[];
1418
+ }, {
1419
+ role: import("convex/values").VLiteral<"user", "required">;
1420
+ content: import("convex/values").VUnion<string | ({
1421
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1422
+ type: "text";
1423
+ text: string;
1424
+ } | {
1425
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1426
+ mimeType?: string | undefined;
1427
+ type: "image";
1428
+ image: string | ArrayBuffer;
1429
+ } | {
1430
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1431
+ type: "file";
1432
+ mimeType: string;
1433
+ data: string | ArrayBuffer;
1434
+ })[], [import("convex/values").VString<string, "required">, import("convex/values").VArray<({
1435
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1436
+ type: "text";
1437
+ text: string;
1438
+ } | {
1439
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1440
+ mimeType?: string | undefined;
1441
+ type: "image";
1442
+ image: string | ArrayBuffer;
1443
+ } | {
1444
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1445
+ type: "file";
1446
+ mimeType: string;
1447
+ data: string | ArrayBuffer;
1448
+ })[], import("convex/values").VUnion<{
1449
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1450
+ type: "text";
1451
+ text: string;
1452
+ } | {
1453
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1454
+ mimeType?: string | undefined;
1455
+ type: "image";
1456
+ image: string | ArrayBuffer;
1457
+ } | {
1458
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1459
+ type: "file";
1460
+ mimeType: string;
1461
+ data: string | ArrayBuffer;
1462
+ }, [import("convex/values").VObject<{
1463
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1464
+ type: "text";
1465
+ text: string;
1466
+ }, {
1467
+ type: import("convex/values").VLiteral<"text", "required">;
1468
+ text: import("convex/values").VString<string, "required">;
1469
+ providerOptions: import("convex/values").VRecord<Record<string, Record<string, any>> | undefined, import("convex/values").VString<string, "required">, import("convex/values").VRecord<Record<string, any>, import("convex/values").VString<string, "required">, import("convex/values").VAny<any, "required", string>, "required", string>, "optional", string>;
1470
+ }, "required", "type" | "providerOptions" | "text" | `providerOptions.${string}`>, import("convex/values").VObject<{
1471
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1472
+ mimeType?: string | undefined;
1473
+ type: "image";
1474
+ image: string | ArrayBuffer;
1475
+ }, {
1476
+ type: import("convex/values").VLiteral<"image", "required">;
1477
+ image: import("convex/values").VUnion<string | ArrayBuffer, [import("convex/values").VString<string, "required">, import("convex/values").VBytes<ArrayBuffer, "required">], "required", never>;
1478
+ mimeType: import("convex/values").VString<string | undefined, "optional">;
1479
+ providerOptions: import("convex/values").VRecord<Record<string, Record<string, any>> | undefined, import("convex/values").VString<string, "required">, import("convex/values").VRecord<Record<string, any>, import("convex/values").VString<string, "required">, import("convex/values").VAny<any, "required", string>, "required", string>, "optional", string>;
1480
+ }, "required", "type" | "providerOptions" | `providerOptions.${string}` | "image" | "mimeType">, import("convex/values").VObject<{
1481
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1482
+ type: "file";
1483
+ mimeType: string;
1484
+ data: string | ArrayBuffer;
1485
+ }, {
1486
+ type: import("convex/values").VLiteral<"file", "required">;
1487
+ data: import("convex/values").VUnion<string | ArrayBuffer, [import("convex/values").VString<string, "required">, import("convex/values").VBytes<ArrayBuffer, "required">], "required", never>;
1488
+ mimeType: import("convex/values").VString<string, "required">;
1489
+ providerOptions: import("convex/values").VRecord<Record<string, Record<string, any>> | undefined, import("convex/values").VString<string, "required">, import("convex/values").VRecord<Record<string, any>, import("convex/values").VString<string, "required">, import("convex/values").VAny<any, "required", string>, "required", string>, "optional", string>;
1490
+ }, "required", "type" | "providerOptions" | `providerOptions.${string}` | "mimeType" | "data">], "required", "type" | "providerOptions" | "text" | `providerOptions.${string}` | "image" | "mimeType" | "data">, "required">], "required", never>;
1491
+ providerOptions: import("convex/values").VRecord<Record<string, Record<string, any>> | undefined, import("convex/values").VString<string, "required">, import("convex/values").VRecord<Record<string, any>, import("convex/values").VString<string, "required">, import("convex/values").VAny<any, "required", string>, "required", string>, "optional", string>;
1492
+ }, "required", "providerOptions" | "role" | `providerOptions.${string}` | "content">, import("convex/values").VObject<{
1493
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1494
+ role: "assistant";
1495
+ content: string | ({
1496
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1497
+ type: "text";
1498
+ text: string;
1499
+ } | {
1500
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1501
+ type: "file";
1502
+ mimeType: string;
1503
+ data: string | ArrayBuffer;
1504
+ } | {
1505
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1506
+ signature?: string | undefined;
1507
+ type: "reasoning";
1508
+ text: string;
1509
+ } | {
1510
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1511
+ type: "redacted-reasoning";
1512
+ data: string;
1513
+ } | {
1514
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1515
+ type: "tool-call";
1516
+ toolCallId: string;
1517
+ toolName: string;
1518
+ args: any;
1519
+ })[];
1520
+ }, {
1521
+ role: import("convex/values").VLiteral<"assistant", "required">;
1522
+ content: import("convex/values").VUnion<string | ({
1523
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1524
+ type: "text";
1525
+ text: string;
1526
+ } | {
1527
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1528
+ type: "file";
1529
+ mimeType: string;
1530
+ data: string | ArrayBuffer;
1531
+ } | {
1532
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1533
+ signature?: string | undefined;
1534
+ type: "reasoning";
1535
+ text: string;
1536
+ } | {
1537
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1538
+ type: "redacted-reasoning";
1539
+ data: string;
1540
+ } | {
1541
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1542
+ type: "tool-call";
1543
+ toolCallId: string;
1544
+ toolName: string;
1545
+ args: any;
1546
+ })[], [import("convex/values").VString<string, "required">, import("convex/values").VArray<({
1547
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1548
+ type: "text";
1549
+ text: string;
1550
+ } | {
1551
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1552
+ type: "file";
1553
+ mimeType: string;
1554
+ data: string | ArrayBuffer;
1555
+ } | {
1556
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1557
+ signature?: string | undefined;
1558
+ type: "reasoning";
1559
+ text: string;
1560
+ } | {
1561
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1562
+ type: "redacted-reasoning";
1563
+ data: string;
1564
+ } | {
1565
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1566
+ type: "tool-call";
1567
+ toolCallId: string;
1568
+ toolName: string;
1569
+ args: any;
1570
+ })[], import("convex/values").VUnion<{
1571
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1572
+ type: "text";
1573
+ text: string;
1574
+ } | {
1575
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1576
+ type: "file";
1577
+ mimeType: string;
1578
+ data: string | ArrayBuffer;
1579
+ } | {
1580
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1581
+ signature?: string | undefined;
1582
+ type: "reasoning";
1583
+ text: string;
1584
+ } | {
1585
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1586
+ type: "redacted-reasoning";
1587
+ data: string;
1588
+ } | {
1589
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1590
+ type: "tool-call";
1591
+ toolCallId: string;
1592
+ toolName: string;
1593
+ args: any;
1594
+ }, [import("convex/values").VObject<{
1595
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1596
+ type: "text";
1597
+ text: string;
1598
+ }, {
1599
+ type: import("convex/values").VLiteral<"text", "required">;
1600
+ text: import("convex/values").VString<string, "required">;
1601
+ providerOptions: import("convex/values").VRecord<Record<string, Record<string, any>> | undefined, import("convex/values").VString<string, "required">, import("convex/values").VRecord<Record<string, any>, import("convex/values").VString<string, "required">, import("convex/values").VAny<any, "required", string>, "required", string>, "optional", string>;
1602
+ }, "required", "type" | "providerOptions" | "text" | `providerOptions.${string}`>, import("convex/values").VObject<{
1603
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1604
+ type: "file";
1605
+ mimeType: string;
1606
+ data: string | ArrayBuffer;
1607
+ }, {
1608
+ type: import("convex/values").VLiteral<"file", "required">;
1609
+ data: import("convex/values").VUnion<string | ArrayBuffer, [import("convex/values").VString<string, "required">, import("convex/values").VBytes<ArrayBuffer, "required">], "required", never>;
1610
+ mimeType: import("convex/values").VString<string, "required">;
1611
+ providerOptions: import("convex/values").VRecord<Record<string, Record<string, any>> | undefined, import("convex/values").VString<string, "required">, import("convex/values").VRecord<Record<string, any>, import("convex/values").VString<string, "required">, import("convex/values").VAny<any, "required", string>, "required", string>, "optional", string>;
1612
+ }, "required", "type" | "providerOptions" | `providerOptions.${string}` | "mimeType" | "data">, import("convex/values").VObject<{
1613
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1614
+ signature?: string | undefined;
1615
+ type: "reasoning";
1616
+ text: string;
1617
+ }, {
1618
+ type: import("convex/values").VLiteral<"reasoning", "required">;
1619
+ text: import("convex/values").VString<string, "required">;
1620
+ signature: import("convex/values").VString<string | undefined, "optional">;
1621
+ providerOptions: import("convex/values").VRecord<Record<string, Record<string, any>> | undefined, import("convex/values").VString<string, "required">, import("convex/values").VRecord<Record<string, any>, import("convex/values").VString<string, "required">, import("convex/values").VAny<any, "required", string>, "required", string>, "optional", string>;
1622
+ }, "required", "type" | "providerOptions" | "text" | `providerOptions.${string}` | "signature">, import("convex/values").VObject<{
1623
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1624
+ type: "redacted-reasoning";
1625
+ data: string;
1626
+ }, {
1627
+ type: import("convex/values").VLiteral<"redacted-reasoning", "required">;
1628
+ data: import("convex/values").VString<string, "required">;
1629
+ providerOptions: import("convex/values").VRecord<Record<string, Record<string, any>> | undefined, import("convex/values").VString<string, "required">, import("convex/values").VRecord<Record<string, any>, import("convex/values").VString<string, "required">, import("convex/values").VAny<any, "required", string>, "required", string>, "optional", string>;
1630
+ }, "required", "type" | "providerOptions" | `providerOptions.${string}` | "data">, import("convex/values").VObject<{
1631
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1632
+ type: "tool-call";
1633
+ toolCallId: string;
1634
+ toolName: string;
1635
+ args: any;
1636
+ }, {
1637
+ type: import("convex/values").VLiteral<"tool-call", "required">;
1638
+ toolCallId: import("convex/values").VString<string, "required">;
1639
+ toolName: import("convex/values").VString<string, "required">;
1640
+ args: import("convex/values").VAny<any, "required", string>;
1641
+ providerOptions: import("convex/values").VRecord<Record<string, Record<string, any>> | undefined, import("convex/values").VString<string, "required">, import("convex/values").VRecord<Record<string, any>, import("convex/values").VString<string, "required">, import("convex/values").VAny<any, "required", string>, "required", string>, "optional", string>;
1642
+ }, "required", "type" | "providerOptions" | `providerOptions.${string}` | "toolCallId" | "toolName" | "args" | `args.${string}`>], "required", "type" | "providerOptions" | "text" | `providerOptions.${string}` | "mimeType" | "data" | "signature" | "toolCallId" | "toolName" | "args" | `args.${string}`>, "required">], "required", never>;
1643
+ providerOptions: import("convex/values").VRecord<Record<string, Record<string, any>> | undefined, import("convex/values").VString<string, "required">, import("convex/values").VRecord<Record<string, any>, import("convex/values").VString<string, "required">, import("convex/values").VAny<any, "required", string>, "required", string>, "optional", string>;
1644
+ }, "required", "providerOptions" | "role" | `providerOptions.${string}` | "content">, import("convex/values").VObject<{
1645
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1646
+ role: "tool";
1647
+ content: {
1648
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1649
+ args?: any;
1650
+ experimental_content?: ({
1651
+ type: "text";
1652
+ text: string;
1653
+ } | {
1654
+ mimeType?: string | undefined;
1655
+ type: "image";
1656
+ data: string;
1657
+ })[] | undefined;
1658
+ isError?: boolean | undefined;
1659
+ type: "tool-result";
1660
+ toolCallId: string;
1661
+ toolName: string;
1662
+ result: any;
1663
+ }[];
1664
+ }, {
1665
+ role: import("convex/values").VLiteral<"tool", "required">;
1666
+ content: import("convex/values").VArray<{
1667
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1668
+ args?: any;
1669
+ experimental_content?: ({
1670
+ type: "text";
1671
+ text: string;
1672
+ } | {
1673
+ mimeType?: string | undefined;
1674
+ type: "image";
1675
+ data: string;
1676
+ })[] | undefined;
1677
+ isError?: boolean | undefined;
1678
+ type: "tool-result";
1679
+ toolCallId: string;
1680
+ toolName: string;
1681
+ result: any;
1682
+ }[], import("convex/values").VObject<{
1683
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1684
+ args?: any;
1685
+ experimental_content?: ({
1686
+ type: "text";
1687
+ text: string;
1688
+ } | {
1689
+ mimeType?: string | undefined;
1690
+ type: "image";
1691
+ data: string;
1692
+ })[] | undefined;
1693
+ isError?: boolean | undefined;
1694
+ type: "tool-result";
1695
+ toolCallId: string;
1696
+ toolName: string;
1697
+ result: any;
1698
+ }, {
1699
+ type: import("convex/values").VLiteral<"tool-result", "required">;
1700
+ toolCallId: import("convex/values").VString<string, "required">;
1701
+ toolName: import("convex/values").VString<string, "required">;
1702
+ result: import("convex/values").VAny<any, "required", string>;
1703
+ args: import("convex/values").VAny<any, "optional", string>;
1704
+ experimental_content: import("convex/values").VArray<({
1705
+ type: "text";
1706
+ text: string;
1707
+ } | {
1708
+ mimeType?: string | undefined;
1709
+ type: "image";
1710
+ data: string;
1711
+ })[] | undefined, import("convex/values").VUnion<{
1712
+ type: "text";
1713
+ text: string;
1714
+ } | {
1715
+ mimeType?: string | undefined;
1716
+ type: "image";
1717
+ data: string;
1718
+ }, [import("convex/values").VObject<{
1719
+ type: "text";
1720
+ text: string;
1721
+ }, {
1722
+ type: import("convex/values").VLiteral<"text", "required">;
1723
+ text: import("convex/values").VString<string, "required">;
1724
+ }, "required", "type" | "text">, import("convex/values").VObject<{
1725
+ mimeType?: string | undefined;
1726
+ type: "image";
1727
+ data: string;
1728
+ }, {
1729
+ type: import("convex/values").VLiteral<"image", "required">;
1730
+ data: import("convex/values").VString<string, "required">;
1731
+ mimeType: import("convex/values").VString<string | undefined, "optional">;
1732
+ }, "required", "type" | "mimeType" | "data">], "required", "type" | "text" | "mimeType" | "data">, "optional">;
1733
+ isError: import("convex/values").VBoolean<boolean | undefined, "optional">;
1734
+ providerOptions: import("convex/values").VRecord<Record<string, Record<string, any>> | undefined, import("convex/values").VString<string, "required">, import("convex/values").VRecord<Record<string, any>, import("convex/values").VString<string, "required">, import("convex/values").VAny<any, "required", string>, "required", string>, "optional", string>;
1735
+ }, "required", "type" | "providerOptions" | `providerOptions.${string}` | "toolCallId" | "toolName" | "args" | `args.${string}` | "result" | "experimental_content" | "isError" | `result.${string}`>, "required">;
1736
+ providerOptions: import("convex/values").VRecord<Record<string, Record<string, any>> | undefined, import("convex/values").VString<string, "required">, import("convex/values").VRecord<Record<string, any>, import("convex/values").VString<string, "required">, import("convex/values").VAny<any, "required", string>, "required", string>, "optional", string>;
1737
+ }, "required", "providerOptions" | "role" | `providerOptions.${string}` | "content">, import("convex/values").VObject<{
1738
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1739
+ role: "system";
1740
+ content: string;
1741
+ }, {
1742
+ role: import("convex/values").VLiteral<"system", "required">;
1743
+ content: import("convex/values").VString<string, "required">;
1744
+ providerOptions: import("convex/values").VRecord<Record<string, Record<string, any>> | undefined, import("convex/values").VString<string, "required">, import("convex/values").VRecord<Record<string, any>, import("convex/values").VString<string, "required">, import("convex/values").VAny<any, "required", string>, "required", string>, "optional", string>;
1745
+ }, "required", "providerOptions" | "role" | `providerOptions.${string}` | "content">], "optional", "providerOptions" | "role" | `providerOptions.${string}` | "content">;
1746
+ tool: import("convex/values").VBoolean<boolean, "required">;
1747
+ text: import("convex/values").VString<string | undefined, "optional">;
1748
+ usage: import("convex/values").VObject<{
1749
+ promptTokens: number;
1750
+ completionTokens: number;
1751
+ totalTokens: number;
1752
+ } | undefined, {
1753
+ promptTokens: import("convex/values").VFloat64<number, "required">;
1754
+ completionTokens: import("convex/values").VFloat64<number, "required">;
1755
+ totalTokens: import("convex/values").VFloat64<number, "required">;
1756
+ }, "optional", "promptTokens" | "completionTokens" | "totalTokens">;
1757
+ providerMetadata: import("convex/values").VRecord<Record<string, Record<string, any>> | undefined, import("convex/values").VString<string, "required">, import("convex/values").VRecord<Record<string, any>, import("convex/values").VString<string, "required">, import("convex/values").VAny<any, "required", string>, "required", string>, "optional", string>;
1758
+ sources: import("convex/values").VArray<{
1759
+ title?: string | undefined;
1760
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1761
+ id: string;
1762
+ url: string;
1763
+ sourceType: "url";
1764
+ }[] | undefined, import("convex/values").VObject<{
1765
+ title?: string | undefined;
1766
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1767
+ id: string;
1768
+ url: string;
1769
+ sourceType: "url";
1770
+ }, {
1771
+ sourceType: import("convex/values").VLiteral<"url", "required">;
1772
+ id: import("convex/values").VString<string, "required">;
1773
+ url: import("convex/values").VString<string, "required">;
1774
+ title: import("convex/values").VString<string | undefined, "optional">;
1775
+ providerOptions: import("convex/values").VRecord<Record<string, Record<string, any>> | undefined, import("convex/values").VString<string, "required">, import("convex/values").VRecord<Record<string, any>, import("convex/values").VString<string, "required">, import("convex/values").VAny<any, "required", string>, "required", string>, "optional", string>;
1776
+ }, "required", "id" | "title" | "providerOptions" | `providerOptions.${string}` | "url" | "sourceType">, "optional">;
1777
+ reasoning: import("convex/values").VString<string | undefined, "optional">;
1778
+ reasoningDetails: import("convex/values").VArray<({
1779
+ signature?: string | undefined;
1780
+ type: "text";
1781
+ text: string;
1782
+ } | {
1783
+ type: "redacted";
1784
+ data: string;
1785
+ })[] | undefined, import("convex/values").VUnion<{
1786
+ signature?: string | undefined;
1787
+ type: "text";
1788
+ text: string;
1789
+ } | {
1790
+ type: "redacted";
1791
+ data: string;
1792
+ }, [import("convex/values").VObject<{
1793
+ signature?: string | undefined;
1794
+ type: "text";
1795
+ text: string;
1796
+ }, {
1797
+ type: import("convex/values").VLiteral<"text", "required">;
1798
+ text: import("convex/values").VString<string, "required">;
1799
+ signature: import("convex/values").VString<string | undefined, "optional">;
1800
+ }, "required", "type" | "text" | "signature">, import("convex/values").VObject<{
1801
+ type: "redacted";
1802
+ data: string;
1803
+ }, {
1804
+ type: import("convex/values").VLiteral<"redacted", "required">;
1805
+ data: import("convex/values").VString<string, "required">;
1806
+ }, "required", "type" | "data">], "required", "type" | "text" | "data" | "signature">, "optional">;
1807
+ warnings: import("convex/values").VArray<({
1808
+ details?: string | undefined;
1809
+ type: "unsupported-setting";
1810
+ setting: string;
1811
+ } | {
1812
+ details?: string | undefined;
1813
+ type: "unsupported-tool";
1814
+ tool: any;
1815
+ } | {
1816
+ type: "other";
1817
+ message: string;
1818
+ })[] | undefined, import("convex/values").VUnion<{
1819
+ details?: string | undefined;
1820
+ type: "unsupported-setting";
1821
+ setting: string;
1822
+ } | {
1823
+ details?: string | undefined;
1824
+ type: "unsupported-tool";
1825
+ tool: any;
1826
+ } | {
1827
+ type: "other";
1828
+ message: string;
1829
+ }, [import("convex/values").VObject<{
1830
+ details?: string | undefined;
1831
+ type: "unsupported-setting";
1832
+ setting: string;
1833
+ }, {
1834
+ type: import("convex/values").VLiteral<"unsupported-setting", "required">;
1835
+ setting: import("convex/values").VString<string, "required">;
1836
+ details: import("convex/values").VString<string | undefined, "optional">;
1837
+ }, "required", "type" | "setting" | "details">, import("convex/values").VObject<{
1838
+ details?: string | undefined;
1839
+ type: "unsupported-tool";
1840
+ tool: any;
1841
+ }, {
1842
+ type: import("convex/values").VLiteral<"unsupported-tool", "required">;
1843
+ tool: import("convex/values").VAny<any, "required", string>;
1844
+ details: import("convex/values").VString<string | undefined, "optional">;
1845
+ }, "required", "type" | "tool" | "details" | `tool.${string}`>, import("convex/values").VObject<{
1846
+ type: "other";
1847
+ message: string;
1848
+ }, {
1849
+ type: import("convex/values").VLiteral<"other", "required">;
1850
+ message: import("convex/values").VString<string, "required">;
1851
+ }, "required", "type" | "message">], "required", "type" | "message" | "tool" | "setting" | "details" | `tool.${string}`>, "optional">;
1852
+ finishReason: import("convex/values").VUnion<"length" | "error" | "other" | "stop" | "content-filter" | "tool-calls" | "unknown" | undefined, [import("convex/values").VLiteral<"stop", "required">, import("convex/values").VLiteral<"length", "required">, import("convex/values").VLiteral<"content-filter", "required">, import("convex/values").VLiteral<"tool-calls", "required">, import("convex/values").VLiteral<"error", "required">, import("convex/values").VLiteral<"other", "required">, import("convex/values").VLiteral<"unknown", "required">], "optional", never>;
1853
+ _id: import("convex/values").VString<string, "required">;
1854
+ _creationTime: import("convex/values").VFloat64<number, "required">;
1855
+ }, "required", "id" | "status" | "userId" | "order" | "_creationTime" | "threadId" | "parentMessageId" | "stepId" | "stepOrder" | "embeddingId" | "error" | "agentName" | "model" | "provider" | "providerOptions" | "message" | "text" | `providerOptions.${string}` | "reasoning" | "tool" | "files" | "usage" | "providerMetadata" | "sources" | "reasoningDetails" | "warnings" | "finishReason" | "message.providerOptions" | "message.role" | `message.providerOptions.${string}` | "message.content" | "usage.promptTokens" | "usage.completionTokens" | "usage.totalTokens" | `providerMetadata.${string}` | "_id">;
1856
+ export type MessageDoc = Infer<typeof vMessageDoc>;
1857
+ type MessageWithMetadata = OpaqueIds<InnerMessageWithMetadata>;
1858
+ export declare function toUIMessages(messages: MessageDoc[]): UIMessage[];
1242
1859
  //# sourceMappingURL=index.d.ts.map