@convex-dev/agent 0.1.18-alpha.1 → 0.2.0-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (96) hide show
  1. package/dist/client/createTool.d.ts +31 -10
  2. package/dist/client/createTool.d.ts.map +1 -1
  3. package/dist/client/createTool.js +25 -10
  4. package/dist/client/createTool.js.map +1 -1
  5. package/dist/client/defaultComponent.d.ts +11 -0
  6. package/dist/client/defaultComponent.d.ts.map +1 -0
  7. package/dist/client/defaultComponent.js +7 -0
  8. package/dist/client/defaultComponent.js.map +1 -0
  9. package/dist/client/definePlaygroundAPI.d.ts +174 -199
  10. package/dist/client/definePlaygroundAPI.d.ts.map +1 -1
  11. package/dist/client/definePlaygroundAPI.js +17 -35
  12. package/dist/client/definePlaygroundAPI.js.map +1 -1
  13. package/dist/client/files.d.ts +6 -3
  14. package/dist/client/files.d.ts.map +1 -1
  15. package/dist/client/files.js +7 -7
  16. package/dist/client/files.js.map +1 -1
  17. package/dist/client/index.d.ts +152 -589
  18. package/dist/client/index.d.ts.map +1 -1
  19. package/dist/client/index.js +138 -222
  20. package/dist/client/index.js.map +1 -1
  21. package/dist/client/messages.d.ts +538 -0
  22. package/dist/client/messages.d.ts.map +1 -0
  23. package/dist/client/messages.js +91 -0
  24. package/dist/client/messages.js.map +1 -0
  25. package/dist/client/search.d.ts +30 -7
  26. package/dist/client/search.d.ts.map +1 -1
  27. package/dist/client/search.js +20 -3
  28. package/dist/client/search.js.map +1 -1
  29. package/dist/client/streaming.d.ts +3 -2
  30. package/dist/client/streaming.d.ts.map +1 -1
  31. package/dist/client/streaming.js.map +1 -1
  32. package/dist/client/threads.d.ts +46 -0
  33. package/dist/client/threads.d.ts.map +1 -0
  34. package/dist/client/threads.js +49 -0
  35. package/dist/client/threads.js.map +1 -0
  36. package/dist/client/types.d.ts +39 -42
  37. package/dist/client/types.d.ts.map +1 -1
  38. package/dist/component/_generated/api.d.ts +437 -75
  39. package/dist/component/messages.d.ts +254 -55
  40. package/dist/component/messages.d.ts.map +1 -1
  41. package/dist/component/messages.js +29 -25
  42. package/dist/component/messages.js.map +1 -1
  43. package/dist/component/schema.d.ts +1459 -158
  44. package/dist/component/schema.d.ts.map +1 -1
  45. package/dist/component/schema.js +8 -14
  46. package/dist/component/schema.js.map +1 -1
  47. package/dist/component/streams.d.ts +180 -6
  48. package/dist/component/streams.d.ts.map +1 -1
  49. package/dist/mapping.d.ts +11 -15
  50. package/dist/mapping.d.ts.map +1 -1
  51. package/dist/mapping.js +191 -61
  52. package/dist/mapping.js.map +1 -1
  53. package/dist/react/deltas.d.ts +0 -3
  54. package/dist/react/deltas.d.ts.map +1 -1
  55. package/dist/react/deltas.js +140 -44
  56. package/dist/react/deltas.js.map +1 -1
  57. package/dist/react/optimisticallySendMessage.d.ts.map +1 -1
  58. package/dist/react/optimisticallySendMessage.js +2 -1
  59. package/dist/react/optimisticallySendMessage.js.map +1 -1
  60. package/dist/react/toUIMessages.d.ts +5 -4
  61. package/dist/react/toUIMessages.d.ts.map +1 -1
  62. package/dist/react/toUIMessages.js +103 -40
  63. package/dist/react/toUIMessages.js.map +1 -1
  64. package/dist/validators.d.ts +1978 -1210
  65. package/dist/validators.d.ts.map +1 -1
  66. package/dist/validators.js +90 -54
  67. package/dist/validators.js.map +1 -1
  68. package/package.json +32 -28
  69. package/src/client/createTool.ts +69 -38
  70. package/src/client/defaultComponent.ts +17 -0
  71. package/src/client/definePlaygroundAPI.ts +29 -43
  72. package/src/client/files.ts +7 -8
  73. package/src/client/index.test.ts +20 -18
  74. package/src/client/index.ts +228 -434
  75. package/src/client/messages.ts +191 -0
  76. package/src/client/search.ts +30 -6
  77. package/src/client/streaming.ts +4 -3
  78. package/src/client/threads.ts +78 -0
  79. package/src/client/types.ts +50 -72
  80. package/src/component/_generated/api.d.ts +437 -75
  81. package/src/component/messages.test.ts +182 -40
  82. package/src/component/messages.ts +30 -32
  83. package/src/component/schema.ts +8 -14
  84. package/src/mapping.ts +230 -94
  85. package/src/react/deltas.ts +165 -52
  86. package/src/react/optimisticallySendMessage.ts +4 -1
  87. package/src/react/toUIMessages.test.ts +154 -36
  88. package/src/react/toUIMessages.ts +136 -57
  89. package/src/validators.test.ts +2 -101
  90. package/src/validators.ts +111 -68
  91. package/dist/client/listMessages.d.ts +0 -22
  92. package/dist/client/listMessages.d.ts.map +0 -1
  93. package/dist/client/listMessages.js +0 -25
  94. package/dist/client/listMessages.js.map +0 -1
  95. package/src/client/listMessages.ts +0 -38
  96. package/src/node_modules/.vite/vitest/da39a3ee5e6b4b0d3255bfef95601890afd80709/results.json +0 -1
@@ -1,25 +1,27 @@
1
- import type { EmbeddingModelV1, LanguageModelV1 } from "@ai-sdk/provider";
2
- import type { CoreMessage, DeepPartial, GenerateObjectResult, GenerateTextResult, StepResult, StreamObjectResult, StreamTextResult, ToolSet } from "ai";
1
+ import type { LanguageModelV2 } from "@ai-sdk/provider";
2
+ import type { ModelMessage, DeepPartial, GenerateObjectResult, GenerateTextResult, StepResult, StreamObjectResult, StreamTextResult, ToolSet, StopCondition, Schema, LanguageModel, EmbeddingModel, CallSettings } from "ai";
3
3
  import { type GenericActionCtx, type GenericDataModel, type PaginationOptions, type PaginationResult } from "convex/server";
4
4
  import type { MessageDoc, ThreadDoc } from "../component/schema.js";
5
5
  import type { threadFieldsSupportingPatch } from "../component/threads.js";
6
6
  import { type VectorDimension } from "../component/vector/tables.js";
7
- import { type AIMessageWithoutId } from "../mapping.js";
8
7
  import { extractText, isTool } from "../shared.js";
9
- import { type MessageEmbeddings, type MessageStatus, type MessageWithMetadata, type ProviderMetadata, type StreamArgs, type Usage } from "../validators.js";
8
+ import { type Message, type MessageStatus, type MessageWithMetadata, type ProviderMetadata, type StreamArgs, type Usage } from "../validators.js";
10
9
  import { createTool } from "./createTool.js";
11
- import { listMessages } from "./listMessages.js";
12
- import { fetchContextMessages } from "./search.js";
13
- import { type StreamingOptions, syncStreams } from "./streaming.js";
10
+ import { type SaveMessageArgs, type SaveMessagesArgs } from "./messages.js";
11
+ import { type StreamingOptions } from "./streaming.js";
14
12
  import type { ActionCtx, AgentComponent, ContextOptions, GenerationOutputMetadata, Options, OurObjectArgs, OurStreamObjectArgs, RawRequestResponseHandler, RunActionCtx, RunMutationCtx, RunQueryCtx, StorageOptions, StreamingTextArgs, SyncStreamsReturnValue, TextArgs, Thread, UsageHandler } from "./types.js";
13
+ import type z from "zod/v3";
14
+ export { stepCountIs } from "ai";
15
15
  export { vMessageDoc, vThreadDoc } from "../component/schema.js";
16
- export { serializeDataOrUrl } from "../mapping.js";
16
+ export { serializeDataOrUrl, deserializeMessage, serializeMessage, } from "../mapping.js";
17
17
  export { vAssistantMessage, vContextOptions, vMessage, vPaginationResult, vProviderMetadata, vStorageOptions, vStreamArgs, vSystemMessage, vToolMessage, vUsage, vUserMessage, } from "../validators.js";
18
18
  export type { ToolCtx } from "./createTool.js";
19
19
  export { getFile, storeFile } from "./files.js";
20
- export { filterOutOrphanedToolMessages } from "./search.js";
21
- export { abortStream, listStreams } from "./streaming.js";
22
- export { createTool, extractText, fetchContextMessages, isTool, listMessages, syncStreams, };
20
+ export { filterOutOrphanedToolMessages, fetchContextMessages, } from "./search.js";
21
+ export { abortStream, listStreams, syncStreams } from "./streaming.js";
22
+ export { listMessages, saveMessage, saveMessages, type SaveMessageArgs, type SaveMessagesArgs, } from "./messages.js";
23
+ export { createThread, getThreadMetadata } from "./threads.js";
24
+ export { createTool, extractText, isTool };
23
25
  export { definePlaygroundAPI, type PlaygroundAPI, type AgentsFn, } from "./definePlaygroundAPI.js";
24
26
  export type { AgentComponent, ContextOptions, MessageDoc, ProviderMetadata, RawRequestResponseHandler, StorageOptions, StreamArgs, SyncStreamsReturnValue, Thread, ThreadDoc, Usage, UsageHandler, };
25
27
  export declare class Agent<
@@ -57,7 +59,7 @@ CustomCtx extends object = object, AgentTools extends ToolSet = any> {
57
59
  * const myAgent = new Agent(components.agent, {
58
60
  * chat: openai.chat("gpt-4o-mini"),
59
61
  */
60
- chat: LanguageModelV1;
62
+ chat: LanguageModel;
61
63
  /**
62
64
  * The model to use for text embeddings. Optional.
63
65
  * If specified, it will use this for generating vector embeddings
@@ -68,7 +70,7 @@ CustomCtx extends object = object, AgentTools extends ToolSet = any> {
68
70
  * const myAgent = new Agent(components.agent, {
69
71
  * textEmbedding: openai.embedding("text-embedding-3-small")
70
72
  */
71
- textEmbedding?: EmbeddingModelV1<string>;
73
+ textEmbedding?: EmbeddingModel<string>;
72
74
  /**
73
75
  * The default system prompt to put in each request.
74
76
  * Override per-prompt by passing the "system" parameter.
@@ -94,14 +96,15 @@ CustomCtx extends object = object, AgentTools extends ToolSet = any> {
94
96
  storageOptions?: StorageOptions;
95
97
  /**
96
98
  * When generating or streaming text with tools available, this
97
- * determines the default max number of iterations.
99
+ * determines when to stop. Defaults to stepCountIs(1).
98
100
  */
99
- maxSteps?: number;
101
+ stopWhen?: StopCondition<AgentTools> | Array<StopCondition<AgentTools>>;
100
102
  /**
101
- * The maximum number of calls to make to an LLM in case it fails.
102
- * This can be overridden at each generate/stream callsite.
103
+ * The default settings to use for the LLM calls.
104
+ * This can be overridden at each generate/stream callsite on a per-field
105
+ * basis. To clear a default setting, you'll need to pass `undefined`.
103
106
  */
104
- maxRetries?: number;
107
+ callSettings?: CallSettings;
105
108
  /**
106
109
  * The usage handler to use for this agent.
107
110
  */
@@ -125,7 +128,7 @@ CustomCtx extends object = object, AgentTools extends ToolSet = any> {
125
128
  * const myAgent = new Agent(components.agent, {
126
129
  * chat: openai.chat("gpt-4o-mini"),
127
130
  */
128
- chat: LanguageModelV1;
131
+ chat: LanguageModel;
129
132
  /**
130
133
  * The model to use for text embeddings. Optional.
131
134
  * If specified, it will use this for generating vector embeddings
@@ -136,7 +139,7 @@ CustomCtx extends object = object, AgentTools extends ToolSet = any> {
136
139
  * const myAgent = new Agent(components.agent, {
137
140
  * textEmbedding: openai.embedding("text-embedding-3-small")
138
141
  */
139
- textEmbedding?: EmbeddingModelV1<string>;
142
+ textEmbedding?: EmbeddingModel<string>;
140
143
  /**
141
144
  * The default system prompt to put in each request.
142
145
  * Override per-prompt by passing the "system" parameter.
@@ -162,14 +165,15 @@ CustomCtx extends object = object, AgentTools extends ToolSet = any> {
162
165
  storageOptions?: StorageOptions;
163
166
  /**
164
167
  * When generating or streaming text with tools available, this
165
- * determines the default max number of iterations.
168
+ * determines when to stop. Defaults to stepCountIs(1).
166
169
  */
167
- maxSteps?: number;
170
+ stopWhen?: StopCondition<AgentTools> | Array<StopCondition<AgentTools>>;
168
171
  /**
169
- * The maximum number of calls to make to an LLM in case it fails.
170
- * This can be overridden at each generate/stream callsite.
172
+ * The default settings to use for the LLM calls.
173
+ * This can be overridden at each generate/stream callsite on a per-field
174
+ * basis. To clear a default setting, you'll need to pass `undefined`.
171
175
  */
172
- maxRetries?: number;
176
+ callSettings?: CallSettings;
173
177
  /**
174
178
  * The usage handler to use for this agent.
175
179
  */
@@ -285,16 +289,6 @@ CustomCtx extends object = object, AgentTools extends ToolSet = any> {
285
289
  }): Promise<{
286
290
  thread: Thread<ThreadTools extends undefined ? AgentTools : ThreadTools>;
287
291
  }>;
288
- /**
289
- * Search for threads by title, paginated.
290
- * @param ctx The context passed from the query/mutation/action.
291
- * @returns The threads matching the search, paginated.
292
- */
293
- searchThreadTitles(ctx: RunQueryCtx, { userId, query, limit, }: {
294
- userId?: string | undefined;
295
- query: string;
296
- limit?: number;
297
- }): Promise<ThreadDoc[]>;
298
292
  /**
299
293
  * This behaves like {@link generateText} from the "ai" package except that
300
294
  * it add context based on the userId and threadId and saves the input and
@@ -307,7 +301,7 @@ CustomCtx extends object = object, AgentTools extends ToolSet = any> {
307
301
  * for the {@link ContextOptions} and {@link StorageOptions}.
308
302
  * @returns The result of the generateText function.
309
303
  */
310
- generateText<TOOLS extends ToolSet | undefined = undefined, OUTPUT = never, OUTPUT_PARTIAL = never>(ctx: ActionCtx & CustomCtx, { userId: argsUserId, threadId, usageHandler, tools: threadTools, }: {
304
+ generateText<TOOLS extends ToolSet | undefined = undefined, OUTPUT = never, OUTPUT_PARTIAL = never>(ctx: ActionCtx & CustomCtx, { userId: argsUserId, threadId, tools: threadTools, ...usageHandler }: {
311
305
  userId?: string | null;
312
306
  threadId?: string;
313
307
  /**
@@ -325,9 +319,9 @@ CustomCtx extends object = object, AgentTools extends ToolSet = any> {
325
319
  * Use {@link continueThread} to get a version of this function already scoped
326
320
  * to a thread (and optionally userId).
327
321
  */
328
- streamText<TOOLS extends ToolSet | undefined = undefined, OUTPUT = never, PARTIAL_OUTPUT = never>(ctx: ActionCtx & CustomCtx, { userId: argsUserId, threadId, usageHandler,
322
+ streamText<TOOLS extends ToolSet | undefined = undefined, OUTPUT = never, PARTIAL_OUTPUT = never>(ctx: ActionCtx & CustomCtx, { userId: argsUserId, threadId,
329
323
  /** Note: to get better type inference, pass tools in the next arg */
330
- tools: threadTools, }: {
324
+ tools: threadTools, ...usageHandler }: {
331
325
  userId?: string | null;
332
326
  threadId?: string;
333
327
  usageHandler?: UsageHandler;
@@ -361,7 +355,7 @@ CustomCtx extends object = object, AgentTools extends ToolSet = any> {
361
355
  * Use {@link continueThread} to get a version of this function already scoped
362
356
  * to a thread (and optionally userId).
363
357
  */
364
- generateObject<T>(ctx: ActionCtx, { userId: argsUserId, threadId, usageHandler, }: {
358
+ generateObject<T>(ctx: ActionCtx, { userId: argsUserId, threadId, ...usageHandler }: {
365
359
  userId?: string | null;
366
360
  threadId?: string;
367
361
  usageHandler?: UsageHandler;
@@ -382,7 +376,7 @@ CustomCtx extends object = object, AgentTools extends ToolSet = any> {
382
376
  * Use {@link continueThread} to get a version of this function already scoped
383
377
  * to a thread (and optionally userId).
384
378
  */
385
- streamObject<T>(ctx: ActionCtx, { userId: argsUserId, threadId, usageHandler, }: {
379
+ streamObject<T extends z.Schema | Schema>(ctx: ActionCtx, { userId: argsUserId, threadId, ...usageHandler }: {
386
380
  userId?: string | null;
387
381
  threadId?: string;
388
382
  usageHandler?: UsageHandler;
@@ -458,6 +452,7 @@ CustomCtx extends object = object, AgentTools extends ToolSet = any> {
458
452
  } | {
459
453
  providerOptions?: Record<string, Record<string, any>> | undefined;
460
454
  signature?: string | undefined;
455
+ state?: "streaming" | "done" | undefined;
461
456
  type: "reasoning";
462
457
  text: string;
463
458
  } | {
@@ -466,6 +461,7 @@ CustomCtx extends object = object, AgentTools extends ToolSet = any> {
466
461
  data: string;
467
462
  } | {
468
463
  providerOptions?: Record<string, Record<string, any>> | undefined;
464
+ providerExecuted?: boolean | undefined;
469
465
  type: "tool-call";
470
466
  toolCallId: string;
471
467
  toolName: string;
@@ -477,6 +473,8 @@ CustomCtx extends object = object, AgentTools extends ToolSet = any> {
477
473
  content: {
478
474
  providerOptions?: Record<string, Record<string, any>> | undefined;
479
475
  args?: any;
476
+ providerExecuted?: boolean | undefined;
477
+ isError?: boolean | undefined;
480
478
  experimental_content?: ({
481
479
  type: "text";
482
480
  text: string;
@@ -485,7 +483,6 @@ CustomCtx extends object = object, AgentTools extends ToolSet = any> {
485
483
  type: "image";
486
484
  data: string;
487
485
  })[] | undefined;
488
- isError?: boolean | undefined;
489
486
  type: "tool-result";
490
487
  toolCallId: string;
491
488
  toolName: string;
@@ -499,19 +496,36 @@ CustomCtx extends object = object, AgentTools extends ToolSet = any> {
499
496
  text?: string | undefined;
500
497
  reasoning?: string | undefined;
501
498
  usage?: {
499
+ reasoningTokens?: number | undefined;
500
+ cachedInputTokens?: number | undefined;
502
501
  promptTokens: number;
503
502
  completionTokens: number;
504
503
  totalTokens: number;
505
504
  } | undefined;
506
505
  providerMetadata?: Record<string, Record<string, any>> | undefined;
507
- sources?: {
506
+ sources?: ({
508
507
  title?: string | undefined;
508
+ type?: "source" | undefined;
509
509
  providerOptions?: Record<string, Record<string, any>> | undefined;
510
+ url?: string | undefined;
510
511
  id: string;
511
512
  sourceType: "url";
512
- url: string;
513
- }[] | undefined;
513
+ } | {
514
+ filename?: string | undefined;
515
+ providerMetadata?: Record<string, Record<string, any>> | undefined;
516
+ id: string;
517
+ title: string;
518
+ type: "source";
519
+ sourceType: "document";
520
+ mediaType: string;
521
+ })[] | undefined;
514
522
  reasoningDetails?: ({
523
+ providerOptions?: Record<string, Record<string, any>> | undefined;
524
+ signature?: string | undefined;
525
+ state?: "streaming" | "done" | undefined;
526
+ type: "reasoning";
527
+ text: string;
528
+ } | {
515
529
  signature?: string | undefined;
516
530
  type: "text";
517
531
  text: string;
@@ -558,7 +572,6 @@ CustomCtx extends object = object, AgentTools extends ToolSet = any> {
558
572
  */
559
573
  skipEmbeddings?: boolean;
560
574
  }): Promise<{
561
- lastMessageId: string;
562
575
  messages: MessageDoc[];
563
576
  }>;
564
577
  /**
@@ -601,7 +614,7 @@ CustomCtx extends object = object, AgentTools extends ToolSet = any> {
601
614
  fetchContextMessages(ctx: RunQueryCtx | RunActionCtx, args: {
602
615
  userId: string | undefined;
603
616
  threadId: string | undefined;
604
- messages: CoreMessage[];
617
+ messages: (ModelMessage | Message)[];
605
618
  /**
606
619
  * If provided, it will search for messages up to and including this message.
607
620
  * Note: if this is far in the past, text and vector search results may be more
@@ -638,7 +651,7 @@ CustomCtx extends object = object, AgentTools extends ToolSet = any> {
638
651
  generateEmbeddings(ctx: RunActionCtx, { userId, threadId, }: {
639
652
  userId: string | undefined;
640
653
  threadId: string | undefined;
641
- }, messages: CoreMessage[]): Promise<{
654
+ }, messages: (ModelMessage | Message)[]): Promise<{
642
655
  vectors: (number[] | null)[];
643
656
  dimension: VectorDimension;
644
657
  model: string;
@@ -682,7 +695,6 @@ CustomCtx extends object = object, AgentTools extends ToolSet = any> {
682
695
  provider?: string;
683
696
  }): Promise<{
684
697
  messages: MessageDoc[];
685
- pending?: MessageDoc;
686
698
  }>;
687
699
  /**
688
700
  * Manually save the result of a generateObject call to the thread.
@@ -699,7 +711,9 @@ CustomCtx extends object = object, AgentTools extends ToolSet = any> {
699
711
  provider: string | undefined;
700
712
  result: GenerateObjectResult<unknown>;
701
713
  metadata?: Omit<MessageWithMetadata, "message">;
702
- }): Promise<void>;
714
+ }): Promise<{
715
+ messages: MessageDoc[];
716
+ }>;
703
717
  /**
704
718
  * Commit or rollback a message that was pending.
705
719
  * This is done automatically when saving messages by default.
@@ -728,9 +742,7 @@ CustomCtx extends object = object, AgentTools extends ToolSet = any> {
728
742
  messageId: string;
729
743
  patch: {
730
744
  /** The message to replace the existing message. */
731
- message: CoreMessage & {
732
- id?: string;
733
- };
745
+ message: ModelMessage | Message;
734
746
  /** The status to set on the message. */
735
747
  status: "success" | "error";
736
748
  /** The error message to set on the message. */
@@ -809,7 +821,11 @@ CustomCtx extends object = object, AgentTools extends ToolSet = any> {
809
821
  startStepOrder?: number;
810
822
  endOrder: number;
811
823
  endStepOrder?: number;
812
- }): Promise<void>;
824
+ }): Promise<{
825
+ isDone: boolean;
826
+ lastOrder?: number;
827
+ lastStepOrder?: number;
828
+ }>;
813
829
  /**
814
830
  * Delete a thread and all its messages and streams asynchronously (in batches)
815
831
  * This uses a mutation to that processes one page and recursively queues the
@@ -834,23 +850,23 @@ CustomCtx extends object = object, AgentTools extends ToolSet = any> {
834
850
  }): Promise<void>;
835
851
  _saveMessagesAndFetchContext<T extends {
836
852
  id?: string;
837
- prompt?: string;
838
- messages?: CoreMessage[] | AIMessageWithoutId[];
853
+ prompt?: string | (ModelMessage | Message)[];
854
+ messages?: (ModelMessage | Message)[];
839
855
  system?: string;
840
856
  promptMessageId?: string;
841
- model?: LanguageModelV1;
842
- maxRetries?: number;
857
+ model?: LanguageModelV2;
843
858
  }>(ctx: RunActionCtx, args: T, { userId: argsUserId, threadId, contextOptions, storageOptions, }: {
844
859
  userId: string | undefined;
845
860
  threadId: string | undefined;
846
861
  } & Options): Promise<{
847
862
  args: T & {
848
- model: LanguageModelV1;
863
+ model: LanguageModelV2;
849
864
  };
850
865
  userId: string | undefined;
851
866
  messageId: string | undefined;
852
867
  order: number | undefined;
853
868
  stepOrder: number | undefined;
869
+ savedMessages: MessageDoc[] | undefined;
854
870
  }>;
855
871
  doEmbed(ctx: RunActionCtx, options: {
856
872
  userId: string | undefined;
@@ -907,14 +923,14 @@ CustomCtx extends object = object, AgentTools extends ToolSet = any> {
907
923
  * Create an action out of this agent so you can call it from workflows or other actions
908
924
  * without a wrapping function.
909
925
  * @param spec Configuration for the agent acting as an action, including
910
- * {@link ContextOptions}, {@link StorageOptions}, and maxSteps.
926
+ * {@link ContextOptions}, {@link StorageOptions}, and {@link stopWhen}.
911
927
  */
912
928
  asTextAction<DataModel extends GenericDataModel>(spec?: {
913
929
  /**
914
- * The maximum number of steps to take in this action.
915
- * Defaults to the {@link Agent.maxSteps} option.
930
+ * When to stop generating text.
931
+ * Defaults to the {@link Agent["options"].stopWhen} option.
916
932
  */
917
- maxSteps?: number;
933
+ stopWhen?: StopCondition<AgentTools> | Array<StopCondition<AgentTools>>;
918
934
  /**
919
935
  * The {@link ContextOptions} to use for fetching contextual messages and
920
936
  * saving input/output messages.
@@ -997,6 +1013,7 @@ CustomCtx extends object = object, AgentTools extends ToolSet = any> {
997
1013
  } | {
998
1014
  providerOptions?: Record<string, Record<string, any>> | undefined;
999
1015
  signature?: string | undefined;
1016
+ state?: "streaming" | "done" | undefined;
1000
1017
  type: "reasoning";
1001
1018
  text: string;
1002
1019
  } | {
@@ -1005,6 +1022,7 @@ CustomCtx extends object = object, AgentTools extends ToolSet = any> {
1005
1022
  data: string;
1006
1023
  } | {
1007
1024
  providerOptions?: Record<string, Record<string, any>> | undefined;
1025
+ providerExecuted?: boolean | undefined;
1008
1026
  type: "tool-call";
1009
1027
  toolCallId: string;
1010
1028
  toolName: string;
@@ -1016,6 +1034,8 @@ CustomCtx extends object = object, AgentTools extends ToolSet = any> {
1016
1034
  content: {
1017
1035
  providerOptions?: Record<string, Record<string, any>> | undefined;
1018
1036
  args?: any;
1037
+ providerExecuted?: boolean | undefined;
1038
+ isError?: boolean | undefined;
1019
1039
  experimental_content?: ({
1020
1040
  type: "text";
1021
1041
  text: string;
@@ -1024,7 +1044,6 @@ CustomCtx extends object = object, AgentTools extends ToolSet = any> {
1024
1044
  type: "image";
1025
1045
  data: string;
1026
1046
  })[] | undefined;
1027
- isError?: boolean | undefined;
1028
1047
  type: "tool-result";
1029
1048
  toolCallId: string;
1030
1049
  toolName: string;
@@ -1035,15 +1054,6 @@ CustomCtx extends object = object, AgentTools extends ToolSet = any> {
1035
1054
  role: "system";
1036
1055
  content: string;
1037
1056
  })[] | undefined;
1038
- headers?: Record<string, string> | undefined;
1039
- maxTokens?: number | undefined;
1040
- temperature?: number | undefined;
1041
- topP?: number | undefined;
1042
- topK?: number | undefined;
1043
- presencePenalty?: number | undefined;
1044
- frequencyPenalty?: number | undefined;
1045
- seed?: number | undefined;
1046
- maxRetries?: number | undefined;
1047
1057
  stream?: boolean | undefined;
1048
1058
  toolChoice?: "required" | "none" | "auto" | {
1049
1059
  type: "tool";
@@ -1071,29 +1081,39 @@ CustomCtx extends object = object, AgentTools extends ToolSet = any> {
1071
1081
  storageOptions?: {
1072
1082
  saveMessages?: "all" | "none" | "promptAndOutput" | undefined;
1073
1083
  } | undefined;
1084
+ callSettings?: {
1085
+ headers?: Record<string, string> | undefined;
1086
+ maxOutputTokens?: number | undefined;
1087
+ temperature?: number | undefined;
1088
+ topP?: number | undefined;
1089
+ topK?: number | undefined;
1090
+ presencePenalty?: number | undefined;
1091
+ frequencyPenalty?: number | undefined;
1092
+ stopSequences?: string[] | undefined;
1093
+ seed?: number | undefined;
1094
+ maxRetries?: number | undefined;
1095
+ } | undefined;
1074
1096
  }, Promise<{
1075
1097
  text: string;
1076
1098
  messageId: string | undefined;
1077
1099
  order: number | undefined;
1078
- finishReason: import("@ai-sdk/provider").LanguageModelV1FinishReason;
1079
- warnings: Promise<import("@ai-sdk/provider").LanguageModelV1CallWarning[] | undefined>;
1100
+ finishReason: import("@ai-sdk/provider").LanguageModelV2FinishReason;
1101
+ warnings: Promise<import("@ai-sdk/provider").LanguageModelV2CallWarning[] | undefined>;
1080
1102
  } | {
1081
1103
  text: string;
1082
1104
  messageId: string | undefined;
1083
1105
  order: number | undefined;
1084
- finishReason: import("@ai-sdk/provider").LanguageModelV1FinishReason;
1085
- warnings: import("@ai-sdk/provider").LanguageModelV1CallWarning[] | undefined;
1106
+ finishReason: import("@ai-sdk/provider").LanguageModelV2FinishReason;
1107
+ warnings: import("@ai-sdk/provider").LanguageModelV2CallWarning[] | undefined;
1086
1108
  }>>;
1087
1109
  /**
1088
1110
  * Create an action that generates an object out of this agent so you can call
1089
1111
  * it from workflows or other actions without a wrapping function.
1090
1112
  * @param spec Configuration for the agent acting as an action, including
1091
1113
  * the normal parameters to {@link generateObject}, plus {@link ContextOptions}
1092
- * and maxSteps.
1114
+ * and stopWhen.
1093
1115
  */
1094
- asObjectAction<T>(spec: OurObjectArgs<T> & {
1095
- maxSteps?: number;
1096
- }, options?: {
1116
+ asObjectAction<T>(spec: OurObjectArgs<T>, options?: {
1097
1117
  contextOptions?: ContextOptions;
1098
1118
  storageOptions?: StorageOptions;
1099
1119
  }): import("convex/server").RegisteredAction<"internal", {
@@ -1136,6 +1156,7 @@ CustomCtx extends object = object, AgentTools extends ToolSet = any> {
1136
1156
  } | {
1137
1157
  providerOptions?: Record<string, Record<string, any>> | undefined;
1138
1158
  signature?: string | undefined;
1159
+ state?: "streaming" | "done" | undefined;
1139
1160
  type: "reasoning";
1140
1161
  text: string;
1141
1162
  } | {
@@ -1144,6 +1165,7 @@ CustomCtx extends object = object, AgentTools extends ToolSet = any> {
1144
1165
  data: string;
1145
1166
  } | {
1146
1167
  providerOptions?: Record<string, Record<string, any>> | undefined;
1168
+ providerExecuted?: boolean | undefined;
1147
1169
  type: "tool-call";
1148
1170
  toolCallId: string;
1149
1171
  toolName: string;
@@ -1155,6 +1177,8 @@ CustomCtx extends object = object, AgentTools extends ToolSet = any> {
1155
1177
  content: {
1156
1178
  providerOptions?: Record<string, Record<string, any>> | undefined;
1157
1179
  args?: any;
1180
+ providerExecuted?: boolean | undefined;
1181
+ isError?: boolean | undefined;
1158
1182
  experimental_content?: ({
1159
1183
  type: "text";
1160
1184
  text: string;
@@ -1163,7 +1187,6 @@ CustomCtx extends object = object, AgentTools extends ToolSet = any> {
1163
1187
  type: "image";
1164
1188
  data: string;
1165
1189
  })[] | undefined;
1166
- isError?: boolean | undefined;
1167
1190
  type: "tool-result";
1168
1191
  toolCallId: string;
1169
1192
  toolName: string;
@@ -1174,15 +1197,6 @@ CustomCtx extends object = object, AgentTools extends ToolSet = any> {
1174
1197
  role: "system";
1175
1198
  content: string;
1176
1199
  })[] | undefined;
1177
- headers?: Record<string, string> | undefined;
1178
- maxTokens?: number | undefined;
1179
- temperature?: number | undefined;
1180
- topP?: number | undefined;
1181
- topK?: number | undefined;
1182
- presencePenalty?: number | undefined;
1183
- frequencyPenalty?: number | undefined;
1184
- seed?: number | undefined;
1185
- maxRetries?: number | undefined;
1186
1200
  prompt?: string | undefined;
1187
1201
  promptMessageId?: string | undefined;
1188
1202
  contextOptions?: {
@@ -1203,12 +1217,24 @@ CustomCtx extends object = object, AgentTools extends ToolSet = any> {
1203
1217
  storageOptions?: {
1204
1218
  saveMessages?: "all" | "none" | "promptAndOutput" | undefined;
1205
1219
  } | undefined;
1220
+ callSettings?: {
1221
+ headers?: Record<string, string> | undefined;
1222
+ maxOutputTokens?: number | undefined;
1223
+ temperature?: number | undefined;
1224
+ topP?: number | undefined;
1225
+ topK?: number | undefined;
1226
+ presencePenalty?: number | undefined;
1227
+ frequencyPenalty?: number | undefined;
1228
+ stopSequences?: string[] | undefined;
1229
+ seed?: number | undefined;
1230
+ maxRetries?: number | undefined;
1231
+ } | undefined;
1206
1232
  }, Promise<{
1207
1233
  object: T;
1208
1234
  messageId: string | undefined;
1209
1235
  order: number | undefined;
1210
- finishReason: import("@ai-sdk/provider").LanguageModelV1FinishReason;
1211
- warnings: import("@ai-sdk/provider").LanguageModelV1CallWarning[] | undefined;
1236
+ finishReason: import("@ai-sdk/provider").LanguageModelV2FinishReason;
1237
+ warnings: import("@ai-sdk/provider").LanguageModelV2CallWarning[] | undefined;
1212
1238
  }>>;
1213
1239
  /**
1214
1240
  * Save messages to the thread.
@@ -1232,12 +1258,15 @@ CustomCtx extends object = object, AgentTools extends ToolSet = any> {
1232
1258
  */
1233
1259
  asSaveMessagesMutation(): import("convex/server").RegisteredMutation<"internal", {
1234
1260
  userId?: string | undefined;
1235
- pending?: boolean | undefined;
1236
1261
  promptMessageId?: string | undefined;
1262
+ embeddings?: {
1263
+ model: string;
1264
+ vectors: (number[] | null)[];
1265
+ } | undefined;
1237
1266
  failPendingSteps?: boolean | undefined;
1238
1267
  threadId: string;
1239
1268
  messages: {
1240
- id?: string | undefined;
1269
+ status?: "pending" | "success" | "failed" | undefined;
1241
1270
  fileIds?: string[] | undefined;
1242
1271
  error?: string | undefined;
1243
1272
  model?: string | undefined;
@@ -1245,19 +1274,36 @@ CustomCtx extends object = object, AgentTools extends ToolSet = any> {
1245
1274
  text?: string | undefined;
1246
1275
  reasoning?: string | undefined;
1247
1276
  usage?: {
1277
+ reasoningTokens?: number | undefined;
1278
+ cachedInputTokens?: number | undefined;
1248
1279
  promptTokens: number;
1249
1280
  completionTokens: number;
1250
1281
  totalTokens: number;
1251
1282
  } | undefined;
1252
1283
  providerMetadata?: Record<string, Record<string, any>> | undefined;
1253
- sources?: {
1284
+ sources?: ({
1254
1285
  title?: string | undefined;
1286
+ type?: "source" | undefined;
1255
1287
  providerOptions?: Record<string, Record<string, any>> | undefined;
1288
+ url?: string | undefined;
1256
1289
  id: string;
1257
1290
  sourceType: "url";
1258
- url: string;
1259
- }[] | undefined;
1291
+ } | {
1292
+ filename?: string | undefined;
1293
+ providerMetadata?: Record<string, Record<string, any>> | undefined;
1294
+ id: string;
1295
+ title: string;
1296
+ type: "source";
1297
+ sourceType: "document";
1298
+ mediaType: string;
1299
+ })[] | undefined;
1260
1300
  reasoningDetails?: ({
1301
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1302
+ signature?: string | undefined;
1303
+ state?: "streaming" | "done" | undefined;
1304
+ type: "reasoning";
1305
+ text: string;
1306
+ } | {
1261
1307
  signature?: string | undefined;
1262
1308
  type: "text";
1263
1309
  text: string;
@@ -1313,6 +1359,7 @@ CustomCtx extends object = object, AgentTools extends ToolSet = any> {
1313
1359
  } | {
1314
1360
  providerOptions?: Record<string, Record<string, any>> | undefined;
1315
1361
  signature?: string | undefined;
1362
+ state?: "streaming" | "done" | undefined;
1316
1363
  type: "reasoning";
1317
1364
  text: string;
1318
1365
  } | {
@@ -1321,6 +1368,7 @@ CustomCtx extends object = object, AgentTools extends ToolSet = any> {
1321
1368
  data: string;
1322
1369
  } | {
1323
1370
  providerOptions?: Record<string, Record<string, any>> | undefined;
1371
+ providerExecuted?: boolean | undefined;
1324
1372
  type: "tool-call";
1325
1373
  toolCallId: string;
1326
1374
  toolName: string;
@@ -1332,6 +1380,8 @@ CustomCtx extends object = object, AgentTools extends ToolSet = any> {
1332
1380
  content: {
1333
1381
  providerOptions?: Record<string, Record<string, any>> | undefined;
1334
1382
  args?: any;
1383
+ providerExecuted?: boolean | undefined;
1384
+ isError?: boolean | undefined;
1335
1385
  experimental_content?: ({
1336
1386
  type: "text";
1337
1387
  text: string;
@@ -1340,7 +1390,6 @@ CustomCtx extends object = object, AgentTools extends ToolSet = any> {
1340
1390
  type: "image";
1341
1391
  data: string;
1342
1392
  })[] | undefined;
1343
- isError?: boolean | undefined;
1344
1393
  type: "tool-result";
1345
1394
  toolCallId: string;
1346
1395
  toolName: string;
@@ -1354,497 +1403,11 @@ CustomCtx extends object = object, AgentTools extends ToolSet = any> {
1354
1403
  }[];
1355
1404
  }, Promise<{
1356
1405
  lastMessageId: string;
1357
- messageIds: string[];
1406
+ messages: {
1407
+ _id: string;
1408
+ order: number;
1409
+ stepOrder: number;
1410
+ }[];
1358
1411
  }>>;
1359
1412
  }
1360
- type CoreMessageMaybeWithId = CoreMessage & {
1361
- id?: string | undefined;
1362
- };
1363
- /**
1364
- * Create a thread to store messages with an Agent.
1365
- * @param ctx The context from a mutation or action.
1366
- * @param component The Agent component, usually `components.agent`.
1367
- * @param args The associated thread metadata.
1368
- * @returns The id of the created thread.
1369
- */
1370
- export declare function createThread(ctx: RunMutationCtx, component: AgentComponent, args?: {
1371
- userId?: string | null;
1372
- title?: string;
1373
- summary?: string;
1374
- }): Promise<string>;
1375
- /**
1376
- * Get the metadata for a thread.
1377
- * @param ctx A ctx object from a query, mutation, or action.
1378
- * @param args.threadId The thread to get the metadata for.
1379
- * @returns The metadata for the thread.
1380
- */
1381
- export declare function getThreadMetadata(ctx: RunQueryCtx, component: AgentComponent, args: {
1382
- threadId: string;
1383
- }): Promise<ThreadDoc>;
1384
- type SaveMessagesArgs = {
1385
- threadId: string;
1386
- userId?: string | null;
1387
- /**
1388
- * The message that these messages are in response to. They will be
1389
- * the same "order" as this message, at increasing stepOrder(s).
1390
- */
1391
- promptMessageId?: string;
1392
- /**
1393
- * The messages to save.
1394
- */
1395
- messages: CoreMessageMaybeWithId[];
1396
- /**
1397
- * Metadata to save with the messages. Each element corresponds to the
1398
- * message at the same index.
1399
- */
1400
- metadata?: Omit<MessageWithMetadata, "message">[];
1401
- /**
1402
- * If false, it will "commit" the messages immediately.
1403
- * If true, it will mark them as pending until the final step has finished.
1404
- * Defaults to false.
1405
- */
1406
- pending?: boolean;
1407
- /**
1408
- * If true, it will fail any pending steps.
1409
- * Defaults to false.
1410
- */
1411
- failPendingSteps?: boolean;
1412
- /**
1413
- * The embeddings to save with the messages.
1414
- */
1415
- embeddings?: Omit<MessageEmbeddings, "dimension">;
1416
- };
1417
- /**
1418
- * Explicitly save messages associated with the thread (& user if provided)
1419
- */
1420
- export declare function saveMessages(ctx: RunMutationCtx, component: AgentComponent, args: SaveMessagesArgs & {
1421
- /**
1422
- * The agent name to associate with the messages.
1423
- */
1424
- agentName?: string;
1425
- }): Promise<{
1426
- lastMessageId: string;
1427
- messages: {
1428
- _creationTime: number;
1429
- _id: string;
1430
- agentName?: string | undefined;
1431
- embeddingId?: string | undefined;
1432
- error?: string | undefined;
1433
- fileIds?: string[] | undefined;
1434
- finishReason?: "stop" | "length" | "content-filter" | "tool-calls" | "error" | "other" | "unknown" | undefined;
1435
- id?: string | undefined;
1436
- message?: {
1437
- content: string | ({
1438
- providerOptions?: {
1439
- [x: string]: {
1440
- [x: string]: any;
1441
- };
1442
- } | undefined;
1443
- text: string;
1444
- type: "text";
1445
- } | {
1446
- image: string | ArrayBuffer;
1447
- mimeType?: string | undefined;
1448
- providerOptions?: {
1449
- [x: string]: {
1450
- [x: string]: any;
1451
- };
1452
- } | undefined;
1453
- type: "image";
1454
- } | {
1455
- data: string | ArrayBuffer;
1456
- filename?: string | undefined;
1457
- mimeType: string;
1458
- providerOptions?: {
1459
- [x: string]: {
1460
- [x: string]: any;
1461
- };
1462
- } | undefined;
1463
- type: "file";
1464
- })[];
1465
- providerOptions?: {
1466
- [x: string]: {
1467
- [x: string]: any;
1468
- };
1469
- } | undefined;
1470
- role: "user";
1471
- } | {
1472
- content: string | ({
1473
- providerOptions?: {
1474
- [x: string]: {
1475
- [x: string]: any;
1476
- };
1477
- } | undefined;
1478
- text: string;
1479
- type: "text";
1480
- } | {
1481
- data: string | ArrayBuffer;
1482
- filename?: string | undefined;
1483
- mimeType: string;
1484
- providerOptions?: {
1485
- [x: string]: {
1486
- [x: string]: any;
1487
- };
1488
- } | undefined;
1489
- type: "file";
1490
- } | {
1491
- providerOptions?: {
1492
- [x: string]: {
1493
- [x: string]: any;
1494
- };
1495
- } | undefined;
1496
- signature?: string | undefined;
1497
- text: string;
1498
- type: "reasoning";
1499
- } | {
1500
- data: string;
1501
- providerOptions?: {
1502
- [x: string]: {
1503
- [x: string]: any;
1504
- };
1505
- } | undefined;
1506
- type: "redacted-reasoning";
1507
- } | {
1508
- args: any;
1509
- providerOptions?: {
1510
- [x: string]: {
1511
- [x: string]: any;
1512
- };
1513
- } | undefined;
1514
- toolCallId: string;
1515
- toolName: string;
1516
- type: "tool-call";
1517
- })[];
1518
- providerOptions?: {
1519
- [x: string]: {
1520
- [x: string]: any;
1521
- };
1522
- } | undefined;
1523
- role: "assistant";
1524
- } | {
1525
- content: {
1526
- args?: any;
1527
- experimental_content?: ({
1528
- text: string;
1529
- type: "text";
1530
- } | {
1531
- data: string;
1532
- mimeType?: string | undefined;
1533
- type: "image";
1534
- })[] | undefined;
1535
- isError?: boolean | undefined;
1536
- providerOptions?: {
1537
- [x: string]: {
1538
- [x: string]: any;
1539
- };
1540
- } | undefined;
1541
- result: any;
1542
- toolCallId: string;
1543
- toolName: string;
1544
- type: "tool-result";
1545
- }[];
1546
- providerOptions?: {
1547
- [x: string]: {
1548
- [x: string]: any;
1549
- };
1550
- } | undefined;
1551
- role: "tool";
1552
- } | {
1553
- content: string;
1554
- providerOptions?: {
1555
- [x: string]: {
1556
- [x: string]: any;
1557
- };
1558
- } | undefined;
1559
- role: "system";
1560
- } | undefined;
1561
- model?: string | undefined;
1562
- order: number;
1563
- provider?: string | undefined;
1564
- providerMetadata?: {
1565
- [x: string]: {
1566
- [x: string]: any;
1567
- };
1568
- } | undefined;
1569
- providerOptions?: {
1570
- [x: string]: {
1571
- [x: string]: any;
1572
- };
1573
- } | undefined;
1574
- reasoning?: string | undefined;
1575
- reasoningDetails?: ({
1576
- signature?: string | undefined;
1577
- text: string;
1578
- type: "text";
1579
- } | {
1580
- data: string;
1581
- type: "redacted";
1582
- })[] | undefined;
1583
- sources?: {
1584
- id: string;
1585
- providerOptions?: {
1586
- [x: string]: {
1587
- [x: string]: any;
1588
- };
1589
- } | undefined;
1590
- sourceType: "url";
1591
- title?: string | undefined;
1592
- url: string;
1593
- }[] | undefined;
1594
- status: "pending" | "success" | "failed";
1595
- stepOrder: number;
1596
- text?: string | undefined;
1597
- threadId: string;
1598
- tool: boolean;
1599
- usage?: {
1600
- completionTokens: number;
1601
- promptTokens: number;
1602
- totalTokens: number;
1603
- } | undefined;
1604
- userId?: string | undefined;
1605
- warnings?: ({
1606
- details?: string | undefined;
1607
- setting: string;
1608
- type: "unsupported-setting";
1609
- } | {
1610
- details?: string | undefined;
1611
- tool: any;
1612
- type: "unsupported-tool";
1613
- } | {
1614
- message: string;
1615
- type: "other";
1616
- })[] | undefined;
1617
- }[];
1618
- }>;
1619
- type SaveMessageArgs = {
1620
- threadId: string;
1621
- userId?: string | null;
1622
- /**
1623
- * Metadata to save with the messages. Each element corresponds to the
1624
- * message at the same index.
1625
- */
1626
- metadata?: Omit<MessageWithMetadata, "message">;
1627
- /**
1628
- * The embedding to save with the message.
1629
- */
1630
- embedding?: {
1631
- vector: number[];
1632
- model: string;
1633
- };
1634
- } & ({
1635
- prompt?: undefined;
1636
- /**
1637
- * The message to save.
1638
- */
1639
- message: CoreMessage;
1640
- } | {
1641
- prompt: string;
1642
- message?: undefined;
1643
- });
1644
- /**
1645
- * Save a message to the thread.
1646
- * @param ctx A ctx object from a mutation or action.
1647
- * @param args The message and what to associate it with (user / thread)
1648
- * You can pass extra metadata alongside the message, e.g. associated fileIds.
1649
- * @returns The messageId of the saved message.
1650
- */
1651
- export declare function saveMessage(ctx: RunMutationCtx, component: AgentComponent, args: SaveMessageArgs & {
1652
- /**
1653
- * The agent name to associate with the message.
1654
- */
1655
- agentName?: string;
1656
- }): Promise<{
1657
- messageId: string;
1658
- message: {
1659
- _creationTime: number;
1660
- _id: string;
1661
- agentName?: string | undefined;
1662
- embeddingId?: string | undefined;
1663
- error?: string | undefined;
1664
- fileIds?: string[] | undefined;
1665
- finishReason?: "stop" | "length" | "content-filter" | "tool-calls" | "error" | "other" | "unknown" | undefined;
1666
- id?: string | undefined;
1667
- message?: {
1668
- content: string | ({
1669
- providerOptions?: {
1670
- [x: string]: {
1671
- [x: string]: any;
1672
- };
1673
- } | undefined;
1674
- text: string;
1675
- type: "text";
1676
- } | {
1677
- image: string | ArrayBuffer;
1678
- mimeType?: string | undefined;
1679
- providerOptions?: {
1680
- [x: string]: {
1681
- [x: string]: any;
1682
- };
1683
- } | undefined;
1684
- type: "image";
1685
- } | {
1686
- data: string | ArrayBuffer;
1687
- filename?: string | undefined;
1688
- mimeType: string;
1689
- providerOptions?: {
1690
- [x: string]: {
1691
- [x: string]: any;
1692
- };
1693
- } | undefined;
1694
- type: "file";
1695
- })[];
1696
- providerOptions?: {
1697
- [x: string]: {
1698
- [x: string]: any;
1699
- };
1700
- } | undefined;
1701
- role: "user";
1702
- } | {
1703
- content: string | ({
1704
- providerOptions?: {
1705
- [x: string]: {
1706
- [x: string]: any;
1707
- };
1708
- } | undefined;
1709
- text: string;
1710
- type: "text";
1711
- } | {
1712
- data: string | ArrayBuffer;
1713
- filename?: string | undefined;
1714
- mimeType: string;
1715
- providerOptions?: {
1716
- [x: string]: {
1717
- [x: string]: any;
1718
- };
1719
- } | undefined;
1720
- type: "file";
1721
- } | {
1722
- providerOptions?: {
1723
- [x: string]: {
1724
- [x: string]: any;
1725
- };
1726
- } | undefined;
1727
- signature?: string | undefined;
1728
- text: string;
1729
- type: "reasoning";
1730
- } | {
1731
- data: string;
1732
- providerOptions?: {
1733
- [x: string]: {
1734
- [x: string]: any;
1735
- };
1736
- } | undefined;
1737
- type: "redacted-reasoning";
1738
- } | {
1739
- args: any;
1740
- providerOptions?: {
1741
- [x: string]: {
1742
- [x: string]: any;
1743
- };
1744
- } | undefined;
1745
- toolCallId: string;
1746
- toolName: string;
1747
- type: "tool-call";
1748
- })[];
1749
- providerOptions?: {
1750
- [x: string]: {
1751
- [x: string]: any;
1752
- };
1753
- } | undefined;
1754
- role: "assistant";
1755
- } | {
1756
- content: {
1757
- args?: any;
1758
- experimental_content?: ({
1759
- text: string;
1760
- type: "text";
1761
- } | {
1762
- data: string;
1763
- mimeType?: string | undefined;
1764
- type: "image";
1765
- })[] | undefined;
1766
- isError?: boolean | undefined;
1767
- providerOptions?: {
1768
- [x: string]: {
1769
- [x: string]: any;
1770
- };
1771
- } | undefined;
1772
- result: any;
1773
- toolCallId: string;
1774
- toolName: string;
1775
- type: "tool-result";
1776
- }[];
1777
- providerOptions?: {
1778
- [x: string]: {
1779
- [x: string]: any;
1780
- };
1781
- } | undefined;
1782
- role: "tool";
1783
- } | {
1784
- content: string;
1785
- providerOptions?: {
1786
- [x: string]: {
1787
- [x: string]: any;
1788
- };
1789
- } | undefined;
1790
- role: "system";
1791
- } | undefined;
1792
- model?: string | undefined;
1793
- order: number;
1794
- provider?: string | undefined;
1795
- providerMetadata?: {
1796
- [x: string]: {
1797
- [x: string]: any;
1798
- };
1799
- } | undefined;
1800
- providerOptions?: {
1801
- [x: string]: {
1802
- [x: string]: any;
1803
- };
1804
- } | undefined;
1805
- reasoning?: string | undefined;
1806
- reasoningDetails?: ({
1807
- signature?: string | undefined;
1808
- text: string;
1809
- type: "text";
1810
- } | {
1811
- data: string;
1812
- type: "redacted";
1813
- })[] | undefined;
1814
- sources?: {
1815
- id: string;
1816
- providerOptions?: {
1817
- [x: string]: {
1818
- [x: string]: any;
1819
- };
1820
- } | undefined;
1821
- sourceType: "url";
1822
- title?: string | undefined;
1823
- url: string;
1824
- }[] | undefined;
1825
- status: "pending" | "success" | "failed";
1826
- stepOrder: number;
1827
- text?: string | undefined;
1828
- threadId: string;
1829
- tool: boolean;
1830
- usage?: {
1831
- completionTokens: number;
1832
- promptTokens: number;
1833
- totalTokens: number;
1834
- } | undefined;
1835
- userId?: string | undefined;
1836
- warnings?: ({
1837
- details?: string | undefined;
1838
- setting: string;
1839
- type: "unsupported-setting";
1840
- } | {
1841
- details?: string | undefined;
1842
- tool: any;
1843
- type: "unsupported-tool";
1844
- } | {
1845
- message: string;
1846
- type: "other";
1847
- })[] | undefined;
1848
- };
1849
- }>;
1850
1413
  //# sourceMappingURL=index.d.ts.map