@convex-dev/agent 0.0.17-alpha.0 → 0.1.0-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 (58) hide show
  1. package/README.md +35 -7
  2. package/dist/commonjs/client/index.d.ts +229 -756
  3. package/dist/commonjs/client/index.d.ts.map +1 -1
  4. package/dist/commonjs/client/index.js +135 -140
  5. package/dist/commonjs/client/index.js.map +1 -1
  6. package/dist/commonjs/component/messages.d.ts +208 -896
  7. package/dist/commonjs/component/messages.d.ts.map +1 -1
  8. package/dist/commonjs/component/messages.js +117 -109
  9. package/dist/commonjs/component/messages.js.map +1 -1
  10. package/dist/commonjs/component/schema.d.ts +1278 -580
  11. package/dist/commonjs/component/schema.d.ts.map +1 -1
  12. package/dist/commonjs/component/schema.js +28 -21
  13. package/dist/commonjs/component/schema.js.map +1 -1
  14. package/dist/commonjs/component/users.d.ts +5 -2
  15. package/dist/commonjs/component/users.d.ts.map +1 -1
  16. package/dist/commonjs/component/users.js +57 -27
  17. package/dist/commonjs/component/users.js.map +1 -1
  18. package/dist/commonjs/validators.d.ts +44 -59
  19. package/dist/commonjs/validators.d.ts.map +1 -1
  20. package/dist/commonjs/validators.js +10 -12
  21. package/dist/commonjs/validators.js.map +1 -1
  22. package/dist/esm/client/index.d.ts +229 -756
  23. package/dist/esm/client/index.d.ts.map +1 -1
  24. package/dist/esm/client/index.js +135 -140
  25. package/dist/esm/client/index.js.map +1 -1
  26. package/dist/esm/component/messages.d.ts +208 -896
  27. package/dist/esm/component/messages.d.ts.map +1 -1
  28. package/dist/esm/component/messages.js +117 -109
  29. package/dist/esm/component/messages.js.map +1 -1
  30. package/dist/esm/component/schema.d.ts +1278 -580
  31. package/dist/esm/component/schema.d.ts.map +1 -1
  32. package/dist/esm/component/schema.js +28 -21
  33. package/dist/esm/component/schema.js.map +1 -1
  34. package/dist/esm/component/users.d.ts +5 -2
  35. package/dist/esm/component/users.d.ts.map +1 -1
  36. package/dist/esm/component/users.js +57 -27
  37. package/dist/esm/component/users.js.map +1 -1
  38. package/dist/esm/validators.d.ts +44 -59
  39. package/dist/esm/validators.d.ts.map +1 -1
  40. package/dist/esm/validators.js +10 -12
  41. package/dist/esm/validators.js.map +1 -1
  42. package/package.json +2 -9
  43. package/src/client/index.ts +215 -199
  44. package/src/component/_generated/api.d.ts +19 -94
  45. package/src/component/messages.test.ts +110 -3
  46. package/src/component/messages.ts +176 -154
  47. package/src/component/schema.ts +34 -21
  48. package/src/component/users.ts +57 -32
  49. package/src/validators.ts +12 -15
  50. package/dist/commonjs/client/playground.d.ts +0 -609
  51. package/dist/commonjs/client/playground.d.ts.map +0 -1
  52. package/dist/commonjs/client/playground.js +0 -200
  53. package/dist/commonjs/client/playground.js.map +0 -1
  54. package/dist/esm/client/playground.d.ts +0 -609
  55. package/dist/esm/client/playground.d.ts.map +0 -1
  56. package/dist/esm/client/playground.js +0 -200
  57. package/dist/esm/client/playground.js.map +0 -1
  58. package/src/client/playground.ts +0 -257
@@ -1,7 +1,6 @@
1
1
  import type { EmbeddingModelV1, LanguageModelV1 } from "@ai-sdk/provider";
2
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
- import { Infer } from "convex/values";
5
4
  import { z } from "zod";
6
5
  import { Mounts } from "../component/_generated/api.js";
7
6
  import { type VectorDimension } from "../component/vector/tables.js";
@@ -9,9 +8,13 @@ import { type AIMessageWithoutId } from "../mapping.js";
9
8
  import { extractText, isTool } from "../shared.js";
10
9
  import { type CallSettings, type MessageWithMetadata as InnerMessageWithMetadata, type ProviderMetadata, type ProviderOptions, type SearchOptions, type Usage } from "../validators.js";
11
10
  import type { OpaqueIds, RunActionCtx, RunMutationCtx, RunQueryCtx, UseApi } from "./types.js";
11
+ import type { MessageDoc, ThreadDoc } from "../component/schema.js";
12
+ export { vMessageDoc, vThreadDoc } from "../component/schema.js";
12
13
  export { extractText, isTool };
13
- export type { Usage, ProviderMetadata };
14
- export { paginationResultValidator, vContextOptions, vUsage, vProviderMetadata, vUserMessage, vAssistantMessage, vToolMessage, vStorageOptions, vSystemMessage, vMessage, } from "../validators.js";
14
+ export type { Usage, ProviderMetadata, MessageDoc, ThreadDoc };
15
+ export {
16
+ /** @deprecated Use vPaginationResult instead. */
17
+ paginationResultValidator, paginationResultValidator as vPaginationResult, vContextOptions, vUsage, vProviderMetadata, vUserMessage, vAssistantMessage, vToolMessage, vStorageOptions, vSystemMessage, vMessage, } from "../validators.js";
15
18
  /**
16
19
  * Options to configure what messages are fetched as context,
17
20
  * automatically with thread.generateText, or directly via search.
@@ -242,11 +245,11 @@ export declare class Agent<AgentTools extends ToolSet> {
242
245
  */
243
246
  userId?: string;
244
247
  /**
245
- * The title of the thread. Not currently used.
248
+ * The title of the thread. Not currently used for anything.
246
249
  */
247
250
  title?: string;
248
251
  /**
249
- * The summary of the thread. Not currently used.
252
+ * The summary of the thread. Not currently used for anything.
250
253
  */
251
254
  summary?: string;
252
255
  /**
@@ -279,11 +282,11 @@ export declare class Agent<AgentTools extends ToolSet> {
279
282
  */
280
283
  userId?: string;
281
284
  /**
282
- * The title of the thread. Not currently used.
285
+ * The title of the thread. Not currently used for anything.
283
286
  */
284
287
  title?: string;
285
288
  /**
286
- * The summary of the thread. Not currently used.
289
+ * The summary of the thread. Not currently used for anything.
287
290
  */
288
291
  summary?: string;
289
292
  /**
@@ -343,11 +346,11 @@ export declare class Agent<AgentTools extends ToolSet> {
343
346
  threadId: string | undefined;
344
347
  messages: CoreMessage[];
345
348
  /**
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
349
+ * If provided, it will search for messages up to and including this message.
350
+ * Note: if this is far in the past, text and vector search results may be more
348
351
  * limited, as it's post-filtering the results.
349
352
  */
350
- beforeMessageId?: string;
353
+ upToAndIncludingMessageId?: string;
351
354
  contextOptions: ContextOptions | undefined;
352
355
  }): Promise<MessageDoc[]>;
353
356
  /**
@@ -369,6 +372,14 @@ export declare class Agent<AgentTools extends ToolSet> {
369
372
  saveMessages(ctx: RunMutationCtx, args: {
370
373
  threadId: string;
371
374
  userId?: string;
375
+ /**
376
+ * The message that these messages are in response to. They will be
377
+ * the same "order" as this message, at increasing stepOrder(s).
378
+ */
379
+ promptMessageId?: string;
380
+ /**
381
+ * The messages to save.
382
+ */
372
383
  messages: CoreMessageMaybeWithId[];
373
384
  /**
374
385
  * Metadata to save with the messages. Each element corresponds to the
@@ -390,10 +401,149 @@ export declare class Agent<AgentTools extends ToolSet> {
390
401
  lastMessageId: string;
391
402
  messageIds: string[];
392
403
  }>;
404
+ /**
405
+ * Save messages to the thread.
406
+ * Useful as a step in Workflows, e.g.
407
+ * ```ts
408
+ * const saveMessages = agent.asSaveMessagesMutation();
409
+ *
410
+ * const myWorkflow = workflow.define()
411
+ * ```
412
+ * @returns A mutation that can be used to save messages to the thread.
413
+ */
414
+ asSaveMessagesMutation(): import("convex/server").RegisteredMutation<"internal", {
415
+ userId?: string | undefined;
416
+ pending?: boolean | undefined;
417
+ promptMessageId?: string | undefined;
418
+ failPendingSteps?: boolean | undefined;
419
+ threadId: string;
420
+ messages: {
421
+ id?: string | undefined;
422
+ error?: string | undefined;
423
+ model?: string | undefined;
424
+ provider?: string | undefined;
425
+ text?: string | undefined;
426
+ reasoning?: string | undefined;
427
+ files?: {
428
+ data?: string | ArrayBuffer | undefined;
429
+ url?: string | undefined;
430
+ fileId?: import("convex/values").GenericId<"files"> | undefined;
431
+ mimeType: string;
432
+ }[] | undefined;
433
+ usage?: {
434
+ promptTokens: number;
435
+ completionTokens: number;
436
+ totalTokens: number;
437
+ } | undefined;
438
+ providerMetadata?: Record<string, Record<string, any>> | undefined;
439
+ sources?: {
440
+ title?: string | undefined;
441
+ providerOptions?: Record<string, Record<string, any>> | undefined;
442
+ id: string;
443
+ url: string;
444
+ sourceType: "url";
445
+ }[] | undefined;
446
+ reasoningDetails?: ({
447
+ signature?: string | undefined;
448
+ type: "text";
449
+ text: string;
450
+ } | {
451
+ type: "redacted";
452
+ data: string;
453
+ })[] | undefined;
454
+ warnings?: ({
455
+ details?: string | undefined;
456
+ type: "unsupported-setting";
457
+ setting: string;
458
+ } | {
459
+ details?: string | undefined;
460
+ type: "unsupported-tool";
461
+ tool: any;
462
+ } | {
463
+ type: "other";
464
+ message: string;
465
+ })[] | undefined;
466
+ finishReason?: "length" | "error" | "other" | "stop" | "content-filter" | "tool-calls" | "unknown" | undefined;
467
+ message: {
468
+ providerOptions?: Record<string, Record<string, any>> | undefined;
469
+ role: "user";
470
+ content: string | ({
471
+ providerOptions?: Record<string, Record<string, any>> | undefined;
472
+ type: "text";
473
+ text: string;
474
+ } | {
475
+ providerOptions?: Record<string, Record<string, any>> | undefined;
476
+ mimeType?: string | undefined;
477
+ type: "image";
478
+ image: string | ArrayBuffer;
479
+ } | {
480
+ providerOptions?: Record<string, Record<string, any>> | undefined;
481
+ type: "file";
482
+ mimeType: string;
483
+ data: string | ArrayBuffer;
484
+ })[];
485
+ } | {
486
+ providerOptions?: Record<string, Record<string, any>> | undefined;
487
+ role: "assistant";
488
+ content: string | ({
489
+ providerOptions?: Record<string, Record<string, any>> | undefined;
490
+ type: "text";
491
+ text: string;
492
+ } | {
493
+ providerOptions?: Record<string, Record<string, any>> | undefined;
494
+ type: "file";
495
+ mimeType: string;
496
+ data: string | ArrayBuffer;
497
+ } | {
498
+ providerOptions?: Record<string, Record<string, any>> | undefined;
499
+ signature?: string | undefined;
500
+ type: "reasoning";
501
+ text: string;
502
+ } | {
503
+ providerOptions?: Record<string, Record<string, any>> | undefined;
504
+ type: "redacted-reasoning";
505
+ data: string;
506
+ } | {
507
+ providerOptions?: Record<string, Record<string, any>> | undefined;
508
+ type: "tool-call";
509
+ toolCallId: string;
510
+ toolName: string;
511
+ args: any;
512
+ })[];
513
+ } | {
514
+ providerOptions?: Record<string, Record<string, any>> | undefined;
515
+ role: "tool";
516
+ content: {
517
+ providerOptions?: Record<string, Record<string, any>> | undefined;
518
+ args?: any;
519
+ experimental_content?: ({
520
+ type: "text";
521
+ text: string;
522
+ } | {
523
+ mimeType?: string | undefined;
524
+ type: "image";
525
+ data: string;
526
+ })[] | undefined;
527
+ isError?: boolean | undefined;
528
+ type: "tool-result";
529
+ toolCallId: string;
530
+ toolName: string;
531
+ result: any;
532
+ }[];
533
+ } | {
534
+ providerOptions?: Record<string, Record<string, any>> | undefined;
535
+ role: "system";
536
+ content: string;
537
+ };
538
+ }[];
539
+ }, Promise<{
540
+ lastMessageId: string;
541
+ messageIds: string[];
542
+ }>>;
393
543
  /**
394
544
  * Explicitly save a "step" created by the AI SDK.
395
545
  * @param ctx The ctx argument to a mutation or action.
396
- * @param args What to save
546
+ * @param args The Step generated by the AI SDK.
397
547
  */
398
548
  saveStep<TOOLS extends ToolSet>(ctx: RunMutationCtx, args: {
399
549
  userId?: string;
@@ -401,7 +551,7 @@ export declare class Agent<AgentTools extends ToolSet> {
401
551
  /**
402
552
  * The message this step is in response to.
403
553
  */
404
- parentMessageId: string;
554
+ promptMessageId: string;
405
555
  /**
406
556
  * The step to save, possibly including multiple tool calls.
407
557
  */
@@ -455,9 +605,7 @@ export declare class Agent<AgentTools extends ToolSet> {
455
605
  * set in the agent constructor.
456
606
  */
457
607
  usageHandler?: UsageHandler;
458
- /**
459
- * The tools to use for this thread. Overrides any tools passed in the agent constructor.
460
- */
608
+ /** @deprecated Pass `tools` in the next parameter instead. This is only intended to pass through thread-default tools. */
461
609
  tools?: ToolSet;
462
610
  }, args: TextArgs<AgentTools, TOOLS, OUTPUT, OUTPUT_PARTIAL>, options?: Options): Promise<GenerateTextResult<TOOLS extends undefined ? AgentTools : TOOLS, OUTPUT> & GenerationOutputMetadata>;
463
611
  /**
@@ -466,11 +614,6 @@ export declare class Agent<AgentTools extends ToolSet> {
466
614
  * resulting messages to the thread, if specified.
467
615
  * Use {@link continueThread} to get a version of this function already scoped
468
616
  * to a thread (and optionally userId).
469
- * @param ctx The context passed from the action function calling this.
470
- * @param { userId, threadId }: The user and thread to associate the message with
471
- * @param args The arguments to the streamText function, along with extra controls
472
- * for the {@link ContextOptions} and {@link StorageOptions}.
473
- * @returns The result of the streamText function.
474
617
  */
475
618
  streamText<TOOLS extends ToolSet | undefined = undefined, OUTPUT = never, PARTIAL_OUTPUT = never>(ctx: RunActionCtx, { userId, threadId, usageHandler,
476
619
  /**
@@ -482,17 +625,31 @@ export declare class Agent<AgentTools extends ToolSet> {
482
625
  threadId?: string;
483
626
  usageHandler?: UsageHandler;
484
627
  tools?: ToolSet;
485
- }, args: StreamingTextArgs<AgentTools, TOOLS, OUTPUT, PARTIAL_OUTPUT>, options?: Options): Promise<StreamTextResult<TOOLS extends undefined ? AgentTools : TOOLS, PARTIAL_OUTPUT> & GenerationOutputMetadata>;
486
- saveMessagesAndFetchContext<T extends {
628
+ },
629
+ /**
630
+ * The arguments to the streamText function, similar to the ai `streamText` function.
631
+ */
632
+ args: StreamingTextArgs<AgentTools, TOOLS, OUTPUT, PARTIAL_OUTPUT>,
633
+ /**
634
+ * The {@link ContextOptions} and {@link StorageOptions}
635
+ * options to use for fetching contextual messages and saving input/output messages.
636
+ */
637
+ options?: Options): Promise<StreamTextResult<TOOLS extends undefined ? AgentTools : TOOLS, PARTIAL_OUTPUT> & GenerationOutputMetadata>;
638
+ _saveMessagesAndFetchContext<T extends {
487
639
  id?: string;
488
640
  prompt?: string;
489
641
  messages?: CoreMessage[] | AIMessageWithoutId[];
490
642
  system?: string;
643
+ promptMessageId?: string;
644
+ model?: LanguageModelV1;
645
+ maxRetries?: number;
491
646
  }>(ctx: RunActionCtx | RunMutationCtx, args: T, { userId, threadId, contextOptions, storageOptions, }: {
492
647
  userId: string | undefined;
493
648
  threadId: string | undefined;
494
649
  } & Options): Promise<{
495
- args: T;
650
+ args: T & {
651
+ model: LanguageModelV1;
652
+ };
496
653
  messageId: string | undefined;
497
654
  }>;
498
655
  /**
@@ -501,34 +658,42 @@ export declare class Agent<AgentTools extends ToolSet> {
501
658
  * resulting messages to the thread, if specified.
502
659
  * Use {@link continueThread} to get a version of this function already scoped
503
660
  * to a thread (and optionally userId).
504
- * @param ctx The context passed from the action function calling this.
505
- * @param { userId, threadId }: The user and thread to associate the message with
506
- * @param args The arguments to the generateObject function, along with extra controls
507
- * for the {@link ContextOptions} and {@link StorageOptions}.
508
- * @returns The result of the generateObject function.
509
661
  */
510
662
  generateObject<T>(ctx: RunActionCtx, { userId, threadId, usageHandler, }: {
511
663
  userId?: string;
512
664
  threadId?: string;
513
665
  usageHandler?: UsageHandler;
514
- }, args: OurObjectArgs<T>, options?: Options): Promise<GenerateObjectResult<T> & GenerationOutputMetadata>;
666
+ },
515
667
  /**
516
- * This behaves like {@link streamObject} from the "ai" package except that
668
+ * The arguments to the generateObject function, similar to the ai.generateObject function.
669
+ */
670
+ args: OurObjectArgs<T>,
671
+ /**
672
+ * The {@link ContextOptions} and {@link StorageOptions}
673
+ * options to use for fetching contextual messages and saving input/output messages.
674
+ */
675
+ options?: Options): Promise<GenerateObjectResult<T> & GenerationOutputMetadata>;
676
+ /**
677
+ * This behaves like `streamObject` from the "ai" package except that
517
678
  * it add context based on the userId and threadId and saves the input and
518
679
  * resulting messages to the thread, if specified.
519
680
  * Use {@link continueThread} to get a version of this function already scoped
520
681
  * to a thread (and optionally userId).
521
- * @param ctx The context passed from the action function calling this.
522
- * @param { userId, threadId }: The user and thread to associate the message with
523
- * @param args The arguments to the streamObject function, along with extra controls
524
- * for the {@link ContextOptions} and {@link StorageOptions}.
525
- * @returns The result of the streamObject function.
526
682
  */
527
683
  streamObject<T>(ctx: RunActionCtx, { userId, threadId, usageHandler, }: {
528
684
  userId?: string;
529
685
  threadId?: string;
530
686
  usageHandler?: UsageHandler;
531
- }, args: OurStreamObjectArgs<T>, options?: Options): Promise<StreamObjectResult<DeepPartial<T>, T, never> & GenerationOutputMetadata>;
687
+ },
688
+ /**
689
+ * The arguments to the streamObject function, similar to the ai `streamObject` function.
690
+ */
691
+ args: OurStreamObjectArgs<T>,
692
+ /**
693
+ * The {@link ContextOptions} and {@link StorageOptions}
694
+ * options to use for fetching contextual messages and saving input/output messages.
695
+ */
696
+ options?: Options): Promise<StreamObjectResult<DeepPartial<T>, T, never> & GenerationOutputMetadata>;
532
697
  /**
533
698
  * Manually save the result of a generateObject call to the thread.
534
699
  * This happens automatically when using {@link generateObject} or {@link streamObject}
@@ -539,7 +704,7 @@ export declare class Agent<AgentTools extends ToolSet> {
539
704
  saveObject(ctx: RunMutationCtx, args: {
540
705
  userId: string | undefined;
541
706
  threadId: string;
542
- parentMessageId: string;
707
+ promptMessageId: string;
543
708
  result: GenerateObjectResult<unknown>;
544
709
  metadata?: Omit<MessageWithMetadata, "message">;
545
710
  }): Promise<void>;
@@ -574,15 +739,17 @@ export declare class Agent<AgentTools extends ToolSet> {
574
739
  * Create an action out of this agent so you can call it from workflows or other actions
575
740
  * without a wrapping function.
576
741
  * @param spec Configuration for the agent acting as an action, including
577
- * {@link ContextOptions} and maxSteps.
742
+ * {@link ContextOptions}, {@link StorageOptions}, and maxSteps.
578
743
  */
579
744
  asTextAction(spec?: {
580
- contextOptions?: ContextOptions;
581
745
  maxSteps?: number;
746
+ contextOptions?: ContextOptions;
582
747
  storageOptions?: StorageOptions;
583
748
  }): import("convex/server").RegisteredAction<"internal", {
584
749
  userId?: string | undefined;
585
750
  threadId?: string | undefined;
751
+ providerOptions?: Record<string, Record<string, any>> | undefined;
752
+ system?: string | undefined;
586
753
  messages?: ({
587
754
  providerOptions?: Record<string, Record<string, any>> | undefined;
588
755
  role: "user";
@@ -654,8 +821,6 @@ export declare class Agent<AgentTools extends ToolSet> {
654
821
  role: "system";
655
822
  content: string;
656
823
  })[] | undefined;
657
- providerOptions?: Record<string, Record<string, any>> | undefined;
658
- system?: string | undefined;
659
824
  headers?: Record<string, string> | undefined;
660
825
  maxTokens?: number | undefined;
661
826
  temperature?: number | undefined;
@@ -707,6 +872,8 @@ export declare class Agent<AgentTools extends ToolSet> {
707
872
  }): import("convex/server").RegisteredAction<"internal", {
708
873
  userId?: string | undefined;
709
874
  threadId?: string | undefined;
875
+ providerOptions?: Record<string, Record<string, any>> | undefined;
876
+ system?: string | undefined;
710
877
  messages?: ({
711
878
  providerOptions?: Record<string, Record<string, any>> | undefined;
712
879
  role: "user";
@@ -778,8 +945,6 @@ export declare class Agent<AgentTools extends ToolSet> {
778
945
  role: "system";
779
946
  content: string;
780
947
  })[] | undefined;
781
- providerOptions?: Record<string, Record<string, any>> | undefined;
782
- system?: string | undefined;
783
948
  headers?: Record<string, string> | undefined;
784
949
  maxTokens?: number | undefined;
785
950
  temperature?: number | undefined;
@@ -809,13 +974,13 @@ export declare class Agent<AgentTools extends ToolSet> {
809
974
  saveAnyInputMessages?: boolean | undefined;
810
975
  saveOutputMessages?: boolean | undefined;
811
976
  } | undefined;
812
- }, Promise<T>>;
977
+ }, Promise<{
978
+ object: T;
979
+ }>>;
813
980
  }
814
981
  export declare function filterOutOrphanedToolMessages(docs: MessageDoc[]): {
815
982
  id?: string | undefined;
816
983
  userId?: string | undefined;
817
- parentMessageId?: string | undefined;
818
- stepId?: string | undefined;
819
984
  embeddingId?: string | undefined;
820
985
  error?: string | undefined;
821
986
  agentName?: string | undefined;
@@ -896,7 +1061,7 @@ export declare function filterOutOrphanedToolMessages(docs: MessageDoc[]): {
896
1061
  text?: string | undefined;
897
1062
  reasoning?: string | undefined;
898
1063
  files?: {
899
- bytes?: ArrayBuffer | undefined;
1064
+ data?: string | ArrayBuffer | undefined;
900
1065
  url?: string | undefined;
901
1066
  fileId?: string | undefined;
902
1067
  mimeType: string;
@@ -993,6 +1158,13 @@ type Options = {
993
1158
  storageOptions?: StorageOptions;
994
1159
  };
995
1160
  type TextArgs<AgentTools extends ToolSet, TOOLS extends ToolSet | undefined = undefined, OUTPUT = never, OUTPUT_PARTIAL = never> = Omit<Parameters<typeof generateText<TOOLS extends undefined ? AgentTools : TOOLS, OUTPUT, OUTPUT_PARTIAL>>[0], "toolChoice" | "tools" | "model"> & {
1161
+ /**
1162
+ * If provided, this message will be used as the "prompt" for the LLM call,
1163
+ * instead of the prompt or messages.
1164
+ * This is useful if you want to first save a user message, then use it as
1165
+ * the prompt for the LLM call in another call.
1166
+ */
1167
+ promptMessageId?: string;
996
1168
  /**
997
1169
  * The model to use for the tool calls. This will override the model specified
998
1170
  * in the Agent constructor.
@@ -1008,8 +1180,7 @@ type TextArgs<AgentTools extends ToolSet, TOOLS extends ToolSet | undefined = un
1008
1180
  * specified in the tools array. e.g. {toolName: "getWeather", type: "tool"}
1009
1181
  */
1010
1182
  toolChoice?: ToolChoice<TOOLS extends undefined ? AgentTools : TOOLS>;
1011
- } & ContextOptions & // DEPRECATED: pass them in the subsequent parameter instead
1012
- StorageOptions;
1183
+ };
1013
1184
  type StreamingTextArgs<AgentTools extends ToolSet, TOOLS extends ToolSet | undefined = undefined, OUTPUT = never, OUTPUT_PARTIAL = never> = Omit<Parameters<typeof streamText<TOOLS extends undefined ? AgentTools : TOOLS, OUTPUT, OUTPUT_PARTIAL>>[0], "toolChoice" | "tools" | "model"> & {
1014
1185
  /**
1015
1186
  * The model to use for the tool calls. This will override the model specified
@@ -1026,8 +1197,8 @@ type StreamingTextArgs<AgentTools extends ToolSet, TOOLS extends ToolSet | undef
1026
1197
  * specified in the tools array. e.g. {toolName: "getWeather", type: "tool"}
1027
1198
  */
1028
1199
  toolChoice?: ToolChoice<TOOLS extends undefined ? AgentTools : TOOLS>;
1029
- } & ContextOptions & StorageOptions;
1030
- type BaseGenerateObjectOptions = StorageOptions & ContextOptions & CallSettings & {
1200
+ };
1201
+ type BaseGenerateObjectOptions = CallSettings & {
1031
1202
  /**
1032
1203
  * The model to use for the object generation. This will override the model
1033
1204
  * specified in the Agent constructor.
@@ -1049,6 +1220,13 @@ type BaseGenerateObjectOptions = StorageOptions & ContextOptions & CallSettings
1049
1220
  * associated with and your contextOptions.
1050
1221
  */
1051
1222
  messages?: CoreMessage[];
1223
+ /**
1224
+ * The message to use as the "prompt" for the object generation.
1225
+ * If this is provided, it will be used instead of the prompt or messages.
1226
+ * This is useful if you want to first save a user message, then use it as
1227
+ * the prompt for the object generation in another call.
1228
+ */
1229
+ promptMessageId?: string;
1052
1230
  experimental_repairText?: RepairTextFunction;
1053
1231
  experimental_telemetry?: TelemetrySettings;
1054
1232
  providerOptions?: ProviderOptions;
@@ -1149,711 +1327,6 @@ interface Thread<DefaultTools extends ToolSet> {
1149
1327
  */
1150
1328
  streamObject<T>(args: OurStreamObjectArgs<T>, options?: Options): Promise<StreamObjectResult<DeepPartial<T>, T, never> & ThreadOutputMetadata>;
1151
1329
  }
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
1330
  type MessageWithMetadata = OpaqueIds<InnerMessageWithMetadata>;
1858
1331
  export declare function toUIMessages(messages: MessageDoc[]): UIMessage[];
1859
1332
  //# sourceMappingURL=index.d.ts.map