@convex-dev/agent 0.6.0 → 0.6.1

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 (184) hide show
  1. package/dist/UIMessages.d.ts +46 -0
  2. package/dist/UIMessages.d.ts.map +1 -0
  3. package/dist/UIMessages.js +634 -0
  4. package/dist/UIMessages.js.map +1 -0
  5. package/dist/client/createTool.d.ts +167 -0
  6. package/dist/client/createTool.d.ts.map +1 -0
  7. package/dist/client/createTool.js +116 -0
  8. package/dist/client/createTool.js.map +1 -0
  9. package/dist/client/defaultComponent.d.ts +11 -0
  10. package/dist/client/defaultComponent.d.ts.map +1 -0
  11. package/dist/client/defaultComponent.js +7 -0
  12. package/dist/client/defaultComponent.js.map +1 -0
  13. package/dist/client/definePlaygroundAPI.d.ts +1725 -0
  14. package/dist/client/definePlaygroundAPI.d.ts.map +1 -0
  15. package/dist/client/definePlaygroundAPI.js +271 -0
  16. package/dist/client/definePlaygroundAPI.js.map +1 -0
  17. package/dist/client/files.d.ts +69 -0
  18. package/dist/client/files.d.ts.map +1 -0
  19. package/dist/client/files.js +181 -0
  20. package/dist/client/files.js.map +1 -0
  21. package/dist/client/index.d.ts +2091 -0
  22. package/dist/client/index.d.ts.map +1 -0
  23. package/dist/client/index.js +929 -0
  24. package/dist/client/index.js.map +1 -0
  25. package/dist/client/messages.d.ts +461 -0
  26. package/dist/client/messages.d.ts.map +1 -0
  27. package/dist/client/messages.js +106 -0
  28. package/dist/client/messages.js.map +1 -0
  29. package/dist/client/mockModel.d.ts +42 -0
  30. package/dist/client/mockModel.d.ts.map +1 -0
  31. package/dist/client/mockModel.js +182 -0
  32. package/dist/client/mockModel.js.map +1 -0
  33. package/dist/client/saveInputMessages.d.ts +20 -0
  34. package/dist/client/saveInputMessages.d.ts.map +1 -0
  35. package/dist/client/saveInputMessages.js +58 -0
  36. package/dist/client/saveInputMessages.js.map +1 -0
  37. package/dist/client/search.d.ts +493 -0
  38. package/dist/client/search.d.ts.map +1 -0
  39. package/dist/client/search.js +435 -0
  40. package/dist/client/search.js.map +1 -0
  41. package/dist/client/start.d.ts +84 -0
  42. package/dist/client/start.d.ts.map +1 -0
  43. package/dist/client/start.js +185 -0
  44. package/dist/client/start.js.map +1 -0
  45. package/dist/client/streamText.d.ts +46 -0
  46. package/dist/client/streamText.d.ts.map +1 -0
  47. package/dist/client/streamText.js +127 -0
  48. package/dist/client/streamText.js.map +1 -0
  49. package/dist/client/streaming.d.ts +3778 -0
  50. package/dist/client/streaming.d.ts.map +1 -0
  51. package/dist/client/streaming.js +330 -0
  52. package/dist/client/streaming.js.map +1 -0
  53. package/dist/client/threads.d.ts +46 -0
  54. package/dist/client/threads.d.ts.map +1 -0
  55. package/dist/client/threads.js +49 -0
  56. package/dist/client/threads.js.map +1 -0
  57. package/dist/client/types.d.ts +461 -0
  58. package/dist/client/types.d.ts.map +1 -0
  59. package/dist/client/types.js +2 -0
  60. package/dist/client/types.js.map +1 -0
  61. package/dist/client/utils.d.ts +4 -0
  62. package/dist/client/utils.d.ts.map +1 -0
  63. package/dist/client/utils.js +21 -0
  64. package/dist/client/utils.js.map +1 -0
  65. package/dist/component/_generated/api.d.ts +48 -0
  66. package/dist/component/_generated/api.d.ts.map +1 -0
  67. package/dist/component/_generated/api.js +31 -0
  68. package/dist/component/_generated/api.js.map +1 -0
  69. package/dist/component/_generated/component.d.ts +3120 -0
  70. package/dist/component/_generated/component.d.ts.map +1 -0
  71. package/dist/component/_generated/component.js +11 -0
  72. package/dist/component/_generated/component.js.map +1 -0
  73. package/dist/component/_generated/dataModel.d.ts +46 -0
  74. package/dist/component/_generated/dataModel.d.ts.map +1 -0
  75. package/dist/component/_generated/dataModel.js +11 -0
  76. package/dist/component/_generated/dataModel.js.map +1 -0
  77. package/dist/component/_generated/server.d.ts +121 -0
  78. package/dist/component/_generated/server.d.ts.map +1 -0
  79. package/dist/component/_generated/server.js +78 -0
  80. package/dist/component/_generated/server.js.map +1 -0
  81. package/dist/component/apiKeys.d.ts +11 -0
  82. package/dist/component/apiKeys.d.ts.map +1 -0
  83. package/dist/component/apiKeys.js +69 -0
  84. package/dist/component/apiKeys.js.map +1 -0
  85. package/dist/component/convex.config.d.ts +3 -0
  86. package/dist/component/convex.config.d.ts.map +1 -0
  87. package/dist/component/convex.config.js +3 -0
  88. package/dist/component/convex.config.js.map +1 -0
  89. package/dist/component/files.d.ts +97 -0
  90. package/dist/component/files.d.ts.map +1 -0
  91. package/dist/component/files.js +190 -0
  92. package/dist/component/files.js.map +1 -0
  93. package/dist/component/messages.d.ts +3851 -0
  94. package/dist/component/messages.d.ts.map +1 -0
  95. package/dist/component/messages.js +757 -0
  96. package/dist/component/messages.js.map +1 -0
  97. package/dist/component/schema.d.ts +8029 -0
  98. package/dist/component/schema.d.ts.map +1 -0
  99. package/dist/component/schema.js +147 -0
  100. package/dist/component/schema.js.map +1 -0
  101. package/dist/component/streams.d.ts +128 -0
  102. package/dist/component/streams.d.ts.map +1 -0
  103. package/dist/component/streams.js +413 -0
  104. package/dist/component/streams.js.map +1 -0
  105. package/dist/component/threads.d.ts +115 -0
  106. package/dist/component/threads.d.ts.map +1 -0
  107. package/dist/component/threads.js +208 -0
  108. package/dist/component/threads.js.map +1 -0
  109. package/dist/component/users.d.ts +52 -0
  110. package/dist/component/users.d.ts.map +1 -0
  111. package/dist/component/users.js +229 -0
  112. package/dist/component/users.js.map +1 -0
  113. package/dist/component/vector/index.d.ts +61 -0
  114. package/dist/component/vector/index.d.ts.map +1 -0
  115. package/dist/component/vector/index.js +146 -0
  116. package/dist/component/vector/index.js.map +1 -0
  117. package/dist/component/vector/tables.d.ts +58 -0
  118. package/dist/component/vector/tables.d.ts.map +1 -0
  119. package/dist/component/vector/tables.js +56 -0
  120. package/dist/component/vector/tables.js.map +1 -0
  121. package/dist/deltas.d.ts +43 -0
  122. package/dist/deltas.d.ts.map +1 -0
  123. package/dist/deltas.js +446 -0
  124. package/dist/deltas.js.map +1 -0
  125. package/dist/mapping.d.ts +76 -0
  126. package/dist/mapping.d.ts.map +1 -0
  127. package/dist/mapping.js +720 -0
  128. package/dist/mapping.js.map +1 -0
  129. package/dist/react/SmoothText.d.ts +5 -0
  130. package/dist/react/SmoothText.d.ts.map +1 -0
  131. package/dist/react/SmoothText.js +6 -0
  132. package/dist/react/SmoothText.js.map +1 -0
  133. package/dist/react/index.d.ts +25 -0
  134. package/dist/react/index.d.ts.map +1 -0
  135. package/dist/react/index.js +70 -0
  136. package/dist/react/index.js.map +1 -0
  137. package/dist/react/optimisticallySendMessage.d.ts +42 -0
  138. package/dist/react/optimisticallySendMessage.d.ts.map +1 -0
  139. package/dist/react/optimisticallySendMessage.js +74 -0
  140. package/dist/react/optimisticallySendMessage.js.map +1 -0
  141. package/dist/react/types.d.ts +12 -0
  142. package/dist/react/types.d.ts.map +1 -0
  143. package/dist/react/types.js +2 -0
  144. package/dist/react/types.js.map +1 -0
  145. package/dist/react/useDeltaStreams.d.ts +10 -0
  146. package/dist/react/useDeltaStreams.d.ts.map +1 -0
  147. package/dist/react/useDeltaStreams.js +106 -0
  148. package/dist/react/useDeltaStreams.js.map +1 -0
  149. package/dist/react/useSmoothText.d.ts +27 -0
  150. package/dist/react/useSmoothText.d.ts.map +1 -0
  151. package/dist/react/useSmoothText.js +68 -0
  152. package/dist/react/useSmoothText.js.map +1 -0
  153. package/dist/react/useStreamingUIMessages.d.ts +22 -0
  154. package/dist/react/useStreamingUIMessages.d.ts.map +1 -0
  155. package/dist/react/useStreamingUIMessages.js +92 -0
  156. package/dist/react/useStreamingUIMessages.js.map +1 -0
  157. package/dist/react/useThreadMessages.d.ts +104 -0
  158. package/dist/react/useThreadMessages.d.ts.map +1 -0
  159. package/dist/react/useThreadMessages.js +148 -0
  160. package/dist/react/useThreadMessages.js.map +1 -0
  161. package/dist/react/useUIMessages.d.ts +96 -0
  162. package/dist/react/useUIMessages.d.ts.map +1 -0
  163. package/dist/react/useUIMessages.js +108 -0
  164. package/dist/react/useUIMessages.js.map +1 -0
  165. package/dist/shared.d.ts +26 -0
  166. package/dist/shared.d.ts.map +1 -0
  167. package/dist/shared.js +67 -0
  168. package/dist/shared.js.map +1 -0
  169. package/dist/validators.d.ts +24516 -0
  170. package/dist/validators.d.ts.map +1 -0
  171. package/dist/validators.js +475 -0
  172. package/dist/validators.js.map +1 -0
  173. package/package.json +39 -39
  174. package/src/UIMessages.ts +0 -9
  175. package/src/client/approval.test.ts +144 -0
  176. package/src/client/index.ts +17 -9
  177. package/src/client/search.ts +0 -29
  178. package/src/client/start.ts +2 -2
  179. package/src/client/streamText.ts +9 -0
  180. package/src/client/streaming.ts +30 -23
  181. package/src/component/_generated/dataModel.ts +1 -1
  182. package/src/component/_generated/server.ts +0 -5
  183. package/src/mapping.ts +38 -22
  184. package/src/node_modules/.vite/vitest/da39a3ee5e6b4b0d3255bfef95601890afd80709/results.json +1 -0
@@ -0,0 +1,2091 @@
1
+ import type { JSONValue } from "@ai-sdk/provider";
2
+ import type { FlexibleSchema, IdGenerator, InferSchema } from "@ai-sdk/provider-utils";
3
+ import type { CallSettings, GenerateObjectResult, GenerateTextResult, LanguageModel, ModelMessage, StepResult, StopCondition, StreamTextResult, ToolSet } from "ai";
4
+ import { streamObject } from "ai";
5
+ import { type GenericDataModel, type PaginationOptions, type PaginationResult } from "convex/server";
6
+ import type { threadFieldsSupportingPatch } from "../component/threads.js";
7
+ import { type VectorDimension } from "../component/vector/tables.js";
8
+ import { type Message, type MessageDoc, type MessageStatus, type MessageWithMetadata, type ProviderMetadata, type StreamArgs, type ThreadDoc } from "../validators.js";
9
+ import { type SaveMessageArgs, type SaveMessagesArgs } from "./messages.js";
10
+ import { type StreamingOptions } from "./streaming.js";
11
+ import type { ActionCtx, AgentComponent, Config, ContextOptions, GenerateObjectArgs, GenerationOutputMetadata, MaybeCustomCtx, ObjectMode, Options, RawRequestResponseHandler, MutationCtx, StorageOptions, StreamingTextArgs, StreamObjectArgs, SyncStreamsReturnValue, TextArgs, Thread, UsageHandler, QueryCtx, AgentPrompt, Output } from "./types.js";
12
+ export { stepCountIs } from "ai";
13
+ export { docsToModelMessages, toModelMessage, toModelMessage as deserializeMessage, guessMimeType, serializeDataOrUrl, serializeMessage, toUIFilePart, } from "../mapping.js";
14
+ export { extractText, isTool, sorted } from "../shared.js";
15
+ export { vAssistantMessage, vContent, vContextOptions, vMessage, vMessageDoc, vPaginationResult, vProviderMetadata, vSource, vStorageOptions, vStreamArgs, vSystemMessage, vThreadDoc, vToolMessage, vUsage, vUserMessage, type Message, type MessageDoc, type SourcePart, type ThreadDoc, type Usage, } from "../validators.js";
16
+ export { createTool, type ToolCtx } from "./createTool.js";
17
+ export { definePlaygroundAPI, type AgentsFn, type PlaygroundAPI, } from "./definePlaygroundAPI.js";
18
+ export { getFile, storeFile } from "./files.js";
19
+ export { listMessages, listUIMessages, saveMessage, saveMessages, type SaveMessageArgs, type SaveMessagesArgs, } from "./messages.js";
20
+ export { mockModel } from "./mockModel.js";
21
+ export { fetchContextMessages, filterOutOrphanedToolMessages, fetchContextWithPrompt, generateAndSaveEmbeddings, embedMessages, embedMany, } from "./search.js";
22
+ export { startGeneration } from "./start.js";
23
+ export { DEFAULT_STREAMING_OPTIONS, DeltaStreamer, abortStream, compressUIMessageChunks, listStreams, syncStreams, vStreamMessagesReturnValue, } from "./streaming.js";
24
+ export { createThread, getThreadMetadata, searchThreadTitles, updateThreadMetadata, } from "./threads.js";
25
+ export type { ContextHandler } from "./types.js";
26
+ export { toUIMessages, fromUIMessages, type UIMessage } from "../UIMessages.js";
27
+ export type { AgentComponent, Config, ContextOptions, ProviderMetadata, RawRequestResponseHandler, StorageOptions, StreamArgs, SyncStreamsReturnValue, Thread, UsageHandler, };
28
+ export declare class Agent<
29
+ /**
30
+ * You can require that all `ctx` args to generateText & streamText
31
+ * have a certain shape by passing a type here.
32
+ * e.g.
33
+ * ```ts
34
+ * const myAgent = new Agent<{ orgId: string }>(...);
35
+ * ```
36
+ * This is useful if you want to share that type in `createTool`
37
+ * e.g.
38
+ * ```ts
39
+ * type MyCtx = ToolCtx & { orgId: string };
40
+ * const myTool = createTool({
41
+ * args: z.object({...}),
42
+ * description: "...",
43
+ * handler: async (ctx: MyCtx, args) => {
44
+ * // use ctx.orgId
45
+ * },
46
+ * });
47
+ */
48
+ CustomCtx extends object = object, AgentTools extends ToolSet = any> {
49
+ component: AgentComponent;
50
+ options: Config & {
51
+ /**
52
+ * The name for the agent. This will be attributed on each message
53
+ * created by this agent.
54
+ */
55
+ name: string;
56
+ /**
57
+ * The LLM model to use for generating / streaming text and objects.
58
+ * e.g.
59
+ * import { openai } from "@ai-sdk/openai"
60
+ * const myAgent = new Agent(components.agent, {
61
+ * languageModel: openai.chat("gpt-4o-mini"),
62
+ */
63
+ languageModel: LanguageModel;
64
+ /**
65
+ * The default system prompt to put in each request.
66
+ * Override per-prompt by passing the "system" parameter.
67
+ */
68
+ instructions?: string;
69
+ /**
70
+ * Tools that the agent can call out to and get responses from.
71
+ * They can be AI SDK tools (import {tool} from "ai")
72
+ * or tools that have Convex context
73
+ * (import { createTool } from "@convex-dev/agent")
74
+ */
75
+ tools?: AgentTools;
76
+ /**
77
+ * When generating or streaming text with tools available, this
78
+ * determines when to stop. Defaults to the AI SDK default.
79
+ */
80
+ stopWhen?: StopCondition<NoInfer<AgentTools>> | Array<StopCondition<NoInfer<AgentTools>>>;
81
+ };
82
+ constructor(component: AgentComponent, options: Config & {
83
+ /**
84
+ * The name for the agent. This will be attributed on each message
85
+ * created by this agent.
86
+ */
87
+ name: string;
88
+ /**
89
+ * The LLM model to use for generating / streaming text and objects.
90
+ * e.g.
91
+ * import { openai } from "@ai-sdk/openai"
92
+ * const myAgent = new Agent(components.agent, {
93
+ * languageModel: openai.chat("gpt-4o-mini"),
94
+ */
95
+ languageModel: LanguageModel;
96
+ /**
97
+ * The default system prompt to put in each request.
98
+ * Override per-prompt by passing the "system" parameter.
99
+ */
100
+ instructions?: string;
101
+ /**
102
+ * Tools that the agent can call out to and get responses from.
103
+ * They can be AI SDK tools (import {tool} from "ai")
104
+ * or tools that have Convex context
105
+ * (import { createTool } from "@convex-dev/agent")
106
+ */
107
+ tools?: AgentTools;
108
+ /**
109
+ * When generating or streaming text with tools available, this
110
+ * determines when to stop. Defaults to the AI SDK default.
111
+ */
112
+ stopWhen?: StopCondition<NoInfer<AgentTools>> | Array<StopCondition<NoInfer<AgentTools>>>;
113
+ });
114
+ /**
115
+ * Get the embedding model, prioritizing embeddingModel over textEmbeddingModel.
116
+ * @private
117
+ */
118
+ private getEmbeddingModel;
119
+ /**
120
+ * Start a new thread with the agent. This will have a fresh history, though if
121
+ * you pass in a userId you can have it search across other threads for relevant
122
+ * messages as context for the LLM calls.
123
+ * @param ctx The context of the Convex function. From an action, you can thread
124
+ * with the agent. From a mutation, you can start a thread and save the threadId
125
+ * to pass to continueThread later.
126
+ * @param args The thread metadata.
127
+ * @returns The threadId of the new thread and the thread object.
128
+ */
129
+ createThread(ctx: ActionCtx & CustomCtx, args?: {
130
+ /**
131
+ * The userId to associate with the thread. If not provided, the thread will be
132
+ * anonymous.
133
+ */
134
+ userId?: string | null;
135
+ /**
136
+ * The title of the thread. Not currently used for anything.
137
+ */
138
+ title?: string;
139
+ /**
140
+ * The summary of the thread. Not currently used for anything.
141
+ */
142
+ summary?: string;
143
+ }): Promise<{
144
+ threadId: string;
145
+ thread: Thread<AgentTools>;
146
+ }>;
147
+ /**
148
+ * Start a new thread with the agent. This will have a fresh history, though if
149
+ * you pass in a userId you can have it search across other threads for relevant
150
+ * messages as context for the LLM calls.
151
+ * @param ctx The context of the Convex function. From a mutation, you can
152
+ * start a thread and save the threadId to pass to continueThread later.
153
+ * @param args The thread metadata.
154
+ * @returns The threadId of the new thread.
155
+ */
156
+ createThread(ctx: MutationCtx, args?: {
157
+ /**
158
+ * The userId to associate with the thread. If not provided, the thread will be
159
+ * anonymous.
160
+ */
161
+ userId?: string | null;
162
+ /**
163
+ * The title of the thread. Not currently used for anything.
164
+ */
165
+ title?: string;
166
+ /**
167
+ * The summary of the thread. Not currently used for anything.
168
+ */
169
+ summary?: string;
170
+ }): Promise<{
171
+ threadId: string;
172
+ }>;
173
+ /**
174
+ * Continues a thread using this agent. Note: threads can be continued
175
+ * by different agents. This is a convenience around calling the various
176
+ * generate and stream functions with explicit userId and threadId parameters.
177
+ * @param ctx The ctx object passed to the action handler
178
+ * @param { threadId, userId }: the thread and user to associate the messages with.
179
+ * @returns Functions bound to the userId and threadId on a `{thread}` object.
180
+ */
181
+ continueThread(ctx: ActionCtx & CustomCtx, args: {
182
+ /**
183
+ * The associated thread created by {@link createThread}
184
+ */
185
+ threadId: string;
186
+ /**
187
+ * If supplied, the userId can be used to search across other threads for
188
+ * relevant messages from the same user as context for the LLM calls.
189
+ */
190
+ userId?: string | null;
191
+ }): Promise<{
192
+ thread: Thread<AgentTools>;
193
+ }>;
194
+ start<TOOLS extends ToolSet | undefined, T extends {
195
+ _internal?: {
196
+ generateId?: IdGenerator;
197
+ };
198
+ }>(ctx: ActionCtx & CustomCtx,
199
+ /**
200
+ * These are the arguments you'll pass to the LLM call such as
201
+ * `generateText` or `streamText`. This function will look up the context
202
+ * and provide functions to save the steps, abort the generation, and more.
203
+ * The type of the arguments returned infers from the type of the arguments
204
+ * you pass here.
205
+ */
206
+ args: T & AgentPrompt & {
207
+ /**
208
+ * The tools to use for the tool calls. This will override tools specified
209
+ * in the Agent constructor or createThread / continueThread.
210
+ */
211
+ tools?: TOOLS;
212
+ /**
213
+ * The abort signal to be passed to the LLM call. If triggered, it will
214
+ * mark the pending message as failed. If the generation is asynchronously
215
+ * aborted, it will trigger this signal when detected.
216
+ */
217
+ abortSignal?: AbortSignal;
218
+ stopWhen?: StopCondition<TOOLS extends undefined ? AgentTools : TOOLS> | Array<StopCondition<TOOLS extends undefined ? AgentTools : TOOLS>>;
219
+ }, options?: Options & {
220
+ userId?: string | null;
221
+ threadId?: string;
222
+ }): Promise<{
223
+ args: T & {
224
+ system?: string;
225
+ model: LanguageModel;
226
+ prompt?: never;
227
+ messages: ModelMessage[];
228
+ tools?: TOOLS extends undefined ? AgentTools : TOOLS;
229
+ } & CallSettings;
230
+ order: number;
231
+ stepOrder: number;
232
+ userId: string | undefined;
233
+ promptMessageId: string | undefined;
234
+ updateModel: (model: LanguageModel | undefined) => void;
235
+ save: <TOOLS extends ToolSet>(toSave: {
236
+ step: StepResult<TOOLS>;
237
+ } | {
238
+ object: GenerateObjectResult<unknown>;
239
+ }, createPendingMessage?: boolean) => Promise<void>;
240
+ fail: (reason: string) => Promise<void>;
241
+ getSavedMessages: () => MessageDoc[];
242
+ }>;
243
+ /**
244
+ * This behaves like {@link generateText} from the "ai" package except that
245
+ * it add context based on the userId and threadId and saves the input and
246
+ * resulting messages to the thread, if specified.
247
+ * Use {@link continueThread} to get a version of this function already scoped
248
+ * to a thread (and optionally userId).
249
+ * @param ctx The context passed from the action function calling this.
250
+ * @param scope: The user and thread to associate the message with
251
+ * @param generateTextArgs The arguments to the generateText function, along
252
+ * with {@link AgentPrompt} options, such as promptMessageId.
253
+ * @param options Extra controls for the {@link ContextOptions} and {@link StorageOptions}.
254
+ * @returns The result of the generateText function.
255
+ */
256
+ generateText<TOOLS extends ToolSet | undefined = undefined, OUTPUT extends Output<any, any, any> = never>(ctx: ActionCtx & CustomCtx, threadOpts: {
257
+ userId?: string | null;
258
+ threadId?: string;
259
+ },
260
+ /**
261
+ * The arguments to the generateText function, similar to the ai sdk's
262
+ * {@link generateText} function, along with Agent prompt options.
263
+ */
264
+ generateTextArgs: AgentPrompt & TextArgs<AgentTools, TOOLS, OUTPUT>, options?: Options): Promise<GenerateTextResult<TOOLS extends undefined ? AgentTools : TOOLS, OUTPUT> & GenerationOutputMetadata>;
265
+ /**
266
+ * This behaves like {@link streamText} from the "ai" package except that
267
+ * it add context based on the userId and threadId and saves the input and
268
+ * resulting messages to the thread, if specified.
269
+ * Use {@link continueThread} to get a version of this function already scoped
270
+ * to a thread (and optionally userId).
271
+ */
272
+ streamText<TOOLS extends ToolSet | undefined = undefined, OUTPUT extends Output<any, any, any> = never>(ctx: ActionCtx & CustomCtx, threadOpts: {
273
+ userId?: string | null;
274
+ threadId?: string;
275
+ },
276
+ /**
277
+ * The arguments to the streamText function, similar to the ai sdk's
278
+ * {@link streamText} function, along with Agent prompt options.
279
+ */
280
+ streamTextArgs: AgentPrompt & StreamingTextArgs<AgentTools, TOOLS, OUTPUT>,
281
+ /**
282
+ * The {@link ContextOptions} and {@link StorageOptions}
283
+ * options to use for fetching contextual messages and saving input/output messages.
284
+ */
285
+ options?: Options & {
286
+ /**
287
+ * Whether to save incremental data (deltas) from streaming responses.
288
+ * Defaults to false.
289
+ * If false, it will not save any deltas to the database.
290
+ * If true, it will save deltas with {@link DEFAULT_STREAMING_OPTIONS}.
291
+ *
292
+ * Regardless of this option, when streaming you are able to use this
293
+ * `streamText` function as you would with the "ai" package's version:
294
+ * iterating over the text, streaming it over HTTP, etc.
295
+ */
296
+ saveStreamDeltas?: boolean | StreamingOptions;
297
+ }): Promise<StreamTextResult<TOOLS extends undefined ? AgentTools : TOOLS, OUTPUT> & GenerationOutputMetadata>;
298
+ /**
299
+ * This behaves like {@link generateObject} from the "ai" package except that
300
+ * it add context based on the userId and threadId and saves the input and
301
+ * resulting messages to the thread, if specified.
302
+ * Use {@link continueThread} to get a version of this function already scoped
303
+ * to a thread (and optionally userId).
304
+ */
305
+ generateObject<SCHEMA extends FlexibleSchema<unknown> = FlexibleSchema<JSONValue>, OUTPUT extends ObjectMode = InferSchema<SCHEMA> extends string ? "enum" : "object", RESULT = OUTPUT extends "array" ? Array<InferSchema<SCHEMA>> : InferSchema<SCHEMA>>(ctx: ActionCtx & CustomCtx, threadOpts: {
306
+ userId?: string | null;
307
+ threadId?: string;
308
+ },
309
+ /**
310
+ * The arguments to the generateObject function, similar to the ai sdk's
311
+ * {@link generateObject} function, along with Agent prompt options.
312
+ */
313
+ generateObjectArgs: AgentPrompt & GenerateObjectArgs<SCHEMA, OUTPUT, RESULT>,
314
+ /**
315
+ * The {@link ContextOptions} and {@link StorageOptions}
316
+ * options to use for fetching contextual messages and saving input/output messages.
317
+ */
318
+ options?: Options): Promise<GenerateObjectResult<RESULT> & GenerationOutputMetadata>;
319
+ /**
320
+ * This behaves like `streamObject` from the "ai" package except that
321
+ * it add context based on the userId and threadId and saves the input and
322
+ * resulting messages to the thread, if specified.
323
+ * Use {@link continueThread} to get a version of this function already scoped
324
+ * to a thread (and optionally userId).
325
+ */
326
+ streamObject<SCHEMA extends FlexibleSchema<unknown> = FlexibleSchema<JSONValue>, OUTPUT extends ObjectMode = InferSchema<SCHEMA> extends string ? "enum" : "object", RESULT = OUTPUT extends "array" ? Array<InferSchema<SCHEMA>> : InferSchema<SCHEMA>>(ctx: ActionCtx & CustomCtx, threadOpts: {
327
+ userId?: string | null;
328
+ threadId?: string;
329
+ },
330
+ /**
331
+ * The arguments to the streamObject function, similar to the ai sdk's
332
+ * {@link streamObject} function, along with Agent prompt options.
333
+ */
334
+ streamObjectArgs: AgentPrompt & StreamObjectArgs<SCHEMA, OUTPUT, RESULT>,
335
+ /**
336
+ * The {@link ContextOptions} and {@link StorageOptions}
337
+ * options to use for fetching contextual messages and saving input/output messages.
338
+ */
339
+ options?: Options): Promise<ReturnType<typeof streamObject<SCHEMA, OUTPUT, RESULT>> & GenerationOutputMetadata>;
340
+ /**
341
+ * Save a message to the thread.
342
+ * @param ctx A ctx object from a mutation or action.
343
+ * @param args The message and what to associate it with (user / thread)
344
+ * You can pass extra metadata alongside the message, e.g. associated fileIds.
345
+ * @returns The messageId of the saved message.
346
+ */
347
+ saveMessage(ctx: MutationCtx | ActionCtx, args: SaveMessageArgs & {
348
+ /**
349
+ * If true, it will not generate embeddings for the message.
350
+ * Useful if you're saving messages in a mutation where you can't run `fetch`.
351
+ * You can generate them asynchronously by using the scheduler to run an
352
+ * action later that calls `agent.generateAndSaveEmbeddings`.
353
+ */
354
+ skipEmbeddings?: boolean;
355
+ }): Promise<{
356
+ messageId: string;
357
+ message: {
358
+ id?: string | undefined;
359
+ userId?: string | undefined;
360
+ embeddingId?: string | undefined;
361
+ fileIds?: string[] | undefined;
362
+ error?: string | undefined;
363
+ agentName?: string | undefined;
364
+ model?: string | undefined;
365
+ provider?: string | undefined;
366
+ providerOptions?: Record<string, Record<string, any>> | undefined;
367
+ message?: {
368
+ providerOptions?: Record<string, Record<string, any>> | undefined;
369
+ role: "user";
370
+ content: string | ({
371
+ providerOptions?: Record<string, Record<string, any>> | undefined;
372
+ providerMetadata?: Record<string, Record<string, any>> | undefined;
373
+ type: "text";
374
+ text: string;
375
+ } | {
376
+ providerOptions?: Record<string, Record<string, any>> | undefined;
377
+ mediaType?: string | undefined;
378
+ mimeType?: string | undefined;
379
+ type: "image";
380
+ image: string | ArrayBuffer;
381
+ } | {
382
+ providerOptions?: Record<string, Record<string, any>> | undefined;
383
+ providerMetadata?: Record<string, Record<string, any>> | undefined;
384
+ mediaType?: string | undefined;
385
+ mimeType?: string | undefined;
386
+ filename?: string | undefined;
387
+ type: "file";
388
+ data: string | ArrayBuffer;
389
+ })[];
390
+ } | {
391
+ providerOptions?: Record<string, Record<string, any>> | undefined;
392
+ role: "assistant";
393
+ content: string | ({
394
+ providerOptions?: Record<string, Record<string, any>> | undefined;
395
+ providerMetadata?: Record<string, Record<string, any>> | undefined;
396
+ type: "text";
397
+ text: string;
398
+ } | {
399
+ providerOptions?: Record<string, Record<string, any>> | undefined;
400
+ providerMetadata?: Record<string, Record<string, any>> | undefined;
401
+ mediaType?: string | undefined;
402
+ mimeType?: string | undefined;
403
+ filename?: string | undefined;
404
+ type: "file";
405
+ data: string | ArrayBuffer;
406
+ } | {
407
+ providerOptions?: Record<string, Record<string, any>> | undefined;
408
+ providerMetadata?: Record<string, Record<string, any>> | undefined;
409
+ signature?: string | undefined;
410
+ type: "reasoning";
411
+ text: string;
412
+ } | {
413
+ providerOptions?: Record<string, Record<string, any>> | undefined;
414
+ providerMetadata?: Record<string, Record<string, any>> | undefined;
415
+ type: "redacted-reasoning";
416
+ data: string;
417
+ } | {
418
+ providerOptions?: Record<string, Record<string, any>> | undefined;
419
+ providerMetadata?: Record<string, Record<string, any>> | undefined;
420
+ args?: any;
421
+ providerExecuted?: boolean | undefined;
422
+ type: "tool-call";
423
+ toolCallId: string;
424
+ toolName: string;
425
+ input: any;
426
+ } | {
427
+ providerOptions?: Record<string, Record<string, any>> | undefined;
428
+ providerMetadata?: Record<string, Record<string, any>> | undefined;
429
+ input?: any;
430
+ providerExecuted?: boolean | undefined;
431
+ type: "tool-call";
432
+ toolCallId: string;
433
+ toolName: string;
434
+ args: any;
435
+ } | {
436
+ providerOptions?: Record<string, Record<string, any>> | undefined;
437
+ providerMetadata?: Record<string, Record<string, any>> | undefined;
438
+ args?: any;
439
+ providerExecuted?: boolean | undefined;
440
+ output?: {
441
+ providerOptions?: Record<string, Record<string, any>> | undefined;
442
+ type: "text";
443
+ value: string;
444
+ } | {
445
+ providerOptions?: Record<string, Record<string, any>> | undefined;
446
+ type: "json";
447
+ value: any;
448
+ } | {
449
+ providerOptions?: Record<string, Record<string, any>> | undefined;
450
+ type: "error-text";
451
+ value: string;
452
+ } | {
453
+ providerOptions?: Record<string, Record<string, any>> | undefined;
454
+ type: "error-json";
455
+ value: any;
456
+ } | {
457
+ providerOptions?: Record<string, Record<string, any>> | undefined;
458
+ reason?: string | undefined;
459
+ type: "execution-denied";
460
+ } | {
461
+ type: "content";
462
+ value: ({
463
+ providerOptions?: Record<string, Record<string, any>> | undefined;
464
+ type: "text";
465
+ text: string;
466
+ } | {
467
+ type: "media";
468
+ mediaType: string;
469
+ data: string;
470
+ } | {
471
+ providerOptions?: Record<string, Record<string, any>> | undefined;
472
+ filename?: string | undefined;
473
+ type: "file-data";
474
+ mediaType: string;
475
+ data: string;
476
+ } | {
477
+ providerOptions?: Record<string, Record<string, any>> | undefined;
478
+ type: "file-url";
479
+ url: string;
480
+ } | {
481
+ providerOptions?: Record<string, Record<string, any>> | undefined;
482
+ type: "file-id";
483
+ fileId: string | Record<string, string>;
484
+ } | {
485
+ providerOptions?: Record<string, Record<string, any>> | undefined;
486
+ type: "image-data";
487
+ mediaType: string;
488
+ data: string;
489
+ } | {
490
+ providerOptions?: Record<string, Record<string, any>> | undefined;
491
+ type: "image-url";
492
+ url: string;
493
+ } | {
494
+ providerOptions?: Record<string, Record<string, any>> | undefined;
495
+ type: "image-file-id";
496
+ fileId: string | Record<string, string>;
497
+ } | {
498
+ providerOptions?: Record<string, Record<string, any>> | undefined;
499
+ type: "custom";
500
+ })[];
501
+ } | undefined;
502
+ result?: any;
503
+ isError?: boolean | undefined;
504
+ experimental_content?: ({
505
+ type: "text";
506
+ text: string;
507
+ } | {
508
+ mimeType?: string | undefined;
509
+ type: "image";
510
+ data: string;
511
+ })[] | undefined;
512
+ type: "tool-result";
513
+ toolCallId: string;
514
+ toolName: string;
515
+ } | {
516
+ title?: string | undefined;
517
+ providerOptions?: Record<string, Record<string, any>> | undefined;
518
+ providerMetadata?: Record<string, Record<string, any>> | undefined;
519
+ id: string;
520
+ type: "source";
521
+ url: string;
522
+ sourceType: "url";
523
+ } | {
524
+ providerOptions?: Record<string, Record<string, any>> | undefined;
525
+ providerMetadata?: Record<string, Record<string, any>> | undefined;
526
+ filename?: string | undefined;
527
+ id: string;
528
+ title: string;
529
+ type: "source";
530
+ mediaType: string;
531
+ sourceType: "document";
532
+ } | {
533
+ providerOptions?: Record<string, Record<string, any>> | undefined;
534
+ providerMetadata?: Record<string, Record<string, any>> | undefined;
535
+ type: "tool-approval-request";
536
+ toolCallId: string;
537
+ approvalId: string;
538
+ })[];
539
+ } | {
540
+ providerOptions?: Record<string, Record<string, any>> | undefined;
541
+ role: "tool";
542
+ content: ({
543
+ providerOptions?: Record<string, Record<string, any>> | undefined;
544
+ providerMetadata?: Record<string, Record<string, any>> | undefined;
545
+ args?: any;
546
+ providerExecuted?: boolean | undefined;
547
+ output?: {
548
+ providerOptions?: Record<string, Record<string, any>> | undefined;
549
+ type: "text";
550
+ value: string;
551
+ } | {
552
+ providerOptions?: Record<string, Record<string, any>> | undefined;
553
+ type: "json";
554
+ value: any;
555
+ } | {
556
+ providerOptions?: Record<string, Record<string, any>> | undefined;
557
+ type: "error-text";
558
+ value: string;
559
+ } | {
560
+ providerOptions?: Record<string, Record<string, any>> | undefined;
561
+ type: "error-json";
562
+ value: any;
563
+ } | {
564
+ providerOptions?: Record<string, Record<string, any>> | undefined;
565
+ reason?: string | undefined;
566
+ type: "execution-denied";
567
+ } | {
568
+ type: "content";
569
+ value: ({
570
+ providerOptions?: Record<string, Record<string, any>> | undefined;
571
+ type: "text";
572
+ text: string;
573
+ } | {
574
+ type: "media";
575
+ mediaType: string;
576
+ data: string;
577
+ } | {
578
+ providerOptions?: Record<string, Record<string, any>> | undefined;
579
+ filename?: string | undefined;
580
+ type: "file-data";
581
+ mediaType: string;
582
+ data: string;
583
+ } | {
584
+ providerOptions?: Record<string, Record<string, any>> | undefined;
585
+ type: "file-url";
586
+ url: string;
587
+ } | {
588
+ providerOptions?: Record<string, Record<string, any>> | undefined;
589
+ type: "file-id";
590
+ fileId: string | Record<string, string>;
591
+ } | {
592
+ providerOptions?: Record<string, Record<string, any>> | undefined;
593
+ type: "image-data";
594
+ mediaType: string;
595
+ data: string;
596
+ } | {
597
+ providerOptions?: Record<string, Record<string, any>> | undefined;
598
+ type: "image-url";
599
+ url: string;
600
+ } | {
601
+ providerOptions?: Record<string, Record<string, any>> | undefined;
602
+ type: "image-file-id";
603
+ fileId: string | Record<string, string>;
604
+ } | {
605
+ providerOptions?: Record<string, Record<string, any>> | undefined;
606
+ type: "custom";
607
+ })[];
608
+ } | undefined;
609
+ result?: any;
610
+ isError?: boolean | undefined;
611
+ experimental_content?: ({
612
+ type: "text";
613
+ text: string;
614
+ } | {
615
+ mimeType?: string | undefined;
616
+ type: "image";
617
+ data: string;
618
+ })[] | undefined;
619
+ type: "tool-result";
620
+ toolCallId: string;
621
+ toolName: string;
622
+ } | {
623
+ providerOptions?: Record<string, Record<string, any>> | undefined;
624
+ providerMetadata?: Record<string, Record<string, any>> | undefined;
625
+ providerExecuted?: boolean | undefined;
626
+ reason?: string | undefined;
627
+ type: "tool-approval-response";
628
+ approvalId: string;
629
+ approved: boolean;
630
+ })[];
631
+ } | {
632
+ providerOptions?: Record<string, Record<string, any>> | undefined;
633
+ role: "system";
634
+ content: string;
635
+ } | undefined;
636
+ text?: string | undefined;
637
+ providerMetadata?: Record<string, Record<string, any>> | undefined;
638
+ reasoning?: string | undefined;
639
+ usage?: {
640
+ reasoningTokens?: number | undefined;
641
+ cachedInputTokens?: number | undefined;
642
+ promptTokens: number;
643
+ completionTokens: number;
644
+ totalTokens: number;
645
+ } | undefined;
646
+ sources?: ({
647
+ title?: string | undefined;
648
+ type?: "source" | undefined;
649
+ providerOptions?: Record<string, Record<string, any>> | undefined;
650
+ providerMetadata?: Record<string, Record<string, any>> | undefined;
651
+ id: string;
652
+ url: string;
653
+ sourceType: "url";
654
+ } | {
655
+ providerOptions?: Record<string, Record<string, any>> | undefined;
656
+ providerMetadata?: Record<string, Record<string, any>> | undefined;
657
+ filename?: string | undefined;
658
+ id: string;
659
+ title: string;
660
+ type: "source";
661
+ mediaType: string;
662
+ sourceType: "document";
663
+ })[] | undefined;
664
+ warnings?: ({
665
+ details?: string | undefined;
666
+ type: "unsupported-setting";
667
+ setting: string;
668
+ } | {
669
+ details?: string | undefined;
670
+ type: "unsupported-tool";
671
+ tool: any;
672
+ } | {
673
+ type: "other";
674
+ message: string;
675
+ })[] | undefined;
676
+ finishReason?: "error" | "length" | "other" | "stop" | "content-filter" | "tool-calls" | "unknown" | undefined;
677
+ reasoningDetails?: ({
678
+ providerOptions?: Record<string, Record<string, any>> | undefined;
679
+ providerMetadata?: Record<string, Record<string, any>> | undefined;
680
+ signature?: string | undefined;
681
+ type: "reasoning";
682
+ text: string;
683
+ } | {
684
+ signature?: string | undefined;
685
+ type: "text";
686
+ text: string;
687
+ } | {
688
+ type: "redacted";
689
+ data: string;
690
+ })[] | undefined;
691
+ status: "pending" | "success" | "failed";
692
+ order: number;
693
+ _creationTime: number;
694
+ threadId: string;
695
+ stepOrder: number;
696
+ tool: boolean;
697
+ _id: string;
698
+ };
699
+ }>;
700
+ /**
701
+ * Explicitly save messages associated with the thread (& user if provided)
702
+ * If you have an embedding model set, it will also generate embeddings for
703
+ * the messages.
704
+ * @param ctx The ctx parameter to a mutation or action.
705
+ * @param args The messages and context to save
706
+ * @returns
707
+ */
708
+ saveMessages(ctx: MutationCtx | ActionCtx, args: SaveMessagesArgs & {
709
+ /**
710
+ * Skip generating embeddings for the messages. Useful if you're
711
+ * saving messages in a mutation where you can't run `fetch`.
712
+ * You can generate them asynchronously by using the scheduler to run an
713
+ * action later that calls `agent.generateAndSaveEmbeddings`.
714
+ */
715
+ skipEmbeddings?: boolean;
716
+ }): Promise<{
717
+ messages: MessageDoc[];
718
+ }>;
719
+ /**
720
+ * List messages from a thread.
721
+ * @param ctx A ctx object from a query, mutation, or action.
722
+ * @param args.threadId The thread to list messages from.
723
+ * @param args.paginationOpts Pagination options (e.g. via usePaginatedQuery).
724
+ * @param args.excludeToolMessages Whether to exclude tool messages.
725
+ * False by default.
726
+ * @param args.statuses What statuses to include. All by default.
727
+ * @returns The MessageDoc's in a format compatible with usePaginatedQuery.
728
+ */
729
+ listMessages(ctx: QueryCtx | MutationCtx | ActionCtx, args: {
730
+ threadId: string;
731
+ paginationOpts: PaginationOptions;
732
+ excludeToolMessages?: boolean;
733
+ statuses?: MessageStatus[];
734
+ }): Promise<PaginationResult<MessageDoc>>;
735
+ /**
736
+ * A function that handles fetching stream deltas, used with the React hooks
737
+ * `useThreadMessages` or `useStreamingThreadMessages`.
738
+ * @param ctx A ctx object from a query, mutation, or action.
739
+ * @param args.threadId The thread to sync streams for.
740
+ * @param args.streamArgs The stream arguments with per-stream cursors.
741
+ * @returns The deltas for each stream from their existing cursor.
742
+ */
743
+ syncStreams(ctx: QueryCtx | MutationCtx | ActionCtx, args: {
744
+ threadId: string;
745
+ streamArgs: StreamArgs | undefined;
746
+ includeStatuses?: ("streaming" | "finished" | "aborted")[];
747
+ }): Promise<SyncStreamsReturnValue | undefined>;
748
+ /**
749
+ * Fetch the context messages for a thread.
750
+ * @param ctx Either a query, mutation, or action ctx.
751
+ * If it is not an action context, you can't do text or
752
+ * vector search.
753
+ * @param args The associated thread, user, message
754
+ * @returns
755
+ */
756
+ fetchContextMessages(ctx: QueryCtx | MutationCtx | ActionCtx, args: {
757
+ userId: string | undefined;
758
+ threadId: string | undefined;
759
+ /**
760
+ * If targetMessageId is not provided, this text will be used
761
+ * for text and vector search
762
+ */
763
+ searchText?: string;
764
+ /**
765
+ * If provided, it will use this message for text/vector search (if enabled)
766
+ * and will only fetch messages up to (and including) this message's "order"
767
+ */
768
+ targetMessageId?: string;
769
+ /**
770
+ * @deprecated use searchText and targetMessageId instead
771
+ */
772
+ messages?: (ModelMessage | Message)[];
773
+ /**
774
+ * @deprecated use targetMessageId instead
775
+ */
776
+ upToAndIncludingMessageId?: string;
777
+ contextOptions: ContextOptions | undefined;
778
+ }): Promise<MessageDoc[]>;
779
+ /**
780
+ * Get the metadata for a thread.
781
+ * @param ctx A ctx object from a query, mutation, or action.
782
+ * @param args.threadId The thread to get the metadata for.
783
+ * @returns The metadata for the thread.
784
+ */
785
+ getThreadMetadata(ctx: QueryCtx | MutationCtx | ActionCtx, args: {
786
+ threadId: string;
787
+ }): Promise<ThreadDoc>;
788
+ /**
789
+ * Update the metadata for a thread.
790
+ * @param ctx A ctx object from a mutation or action.
791
+ * @param args.threadId The thread to update the metadata for.
792
+ * @param args.patch The patch to apply to the thread.
793
+ * @returns The updated thread metadata.
794
+ */
795
+ updateThreadMetadata(ctx: MutationCtx | ActionCtx, args: {
796
+ threadId: string;
797
+ patch: Partial<Pick<ThreadDoc, (typeof threadFieldsSupportingPatch)[number]>>;
798
+ }): Promise<ThreadDoc>;
799
+ /**
800
+ * Get the embeddings for a set of messages.
801
+ * @param messages The messages to get the embeddings for.
802
+ * @returns The embeddings for the messages.
803
+ */
804
+ generateEmbeddings(ctx: ActionCtx, args: {
805
+ userId: string | undefined;
806
+ threadId: string | undefined;
807
+ }, messages: (ModelMessage | Message)[]): Promise<{
808
+ vectors: (number[] | null)[];
809
+ dimension: VectorDimension;
810
+ model: string;
811
+ } | undefined>;
812
+ /**
813
+ * Generate embeddings for a set of messages, and save them to the database.
814
+ * It will not generate or save embeddings for messages that already have an
815
+ * embedding.
816
+ * @param ctx The ctx parameter to an action.
817
+ * @param args The messageIds to generate embeddings for.
818
+ */
819
+ generateAndSaveEmbeddings(ctx: ActionCtx, args: {
820
+ messageIds: string[];
821
+ }): Promise<void>;
822
+ /**
823
+ * Approve a tool call that requires human approval.
824
+ * Saves a `tool-approval-response` message to the thread.
825
+ * After calling this, call `agent.streamText` or `agent.generateText`
826
+ * with `promptMessageId` set to the returned `messageId` to continue
827
+ * generation — the AI SDK will automatically execute the approved tool.
828
+ *
829
+ * The approval response is attached to the same generation order as the
830
+ * original approval request, preserving tool_call/tool_result adjacency in
831
+ * the continuation context even if newer thread messages exist.
832
+ *
833
+ * @param ctx A ctx object from a mutation.
834
+ * @param args.threadId The thread containing the tool call.
835
+ * @param args.approvalId The approval ID from the tool-approval-request part.
836
+ * @param args.reason Optional reason for approval.
837
+ * @returns The messageId of the saved approval response message.
838
+ */
839
+ approveToolCall(ctx: MutationCtx, args: {
840
+ threadId: string;
841
+ approvalId: string;
842
+ reason?: string;
843
+ }): Promise<{
844
+ messageId: string;
845
+ }>;
846
+ /**
847
+ * Deny a tool call that requires human approval.
848
+ * Saves a `tool-approval-response` message to the thread.
849
+ * After calling this, call `agent.streamText` or `agent.generateText`
850
+ * with `promptMessageId` set to the returned `messageId` to continue
851
+ * generation — the AI SDK will automatically create an `execution-denied`
852
+ * result and let the model respond accordingly.
853
+ *
854
+ * @param ctx A ctx object from a mutation.
855
+ * @param args.threadId The thread containing the tool call.
856
+ * @param args.approvalId The approval ID from the tool-approval-request part.
857
+ * @param args.reason Optional reason for denial.
858
+ * @returns The messageId of the saved denial response message.
859
+ */
860
+ denyToolCall(ctx: MutationCtx, args: {
861
+ threadId: string;
862
+ approvalId: string;
863
+ reason?: string;
864
+ }): Promise<{
865
+ messageId: string;
866
+ }>;
867
+ private respondToToolCallApproval;
868
+ private findApprovalContext;
869
+ /**
870
+ * Explicitly save a "step" created by the AI SDK.
871
+ * @param ctx The ctx argument to a mutation or action.
872
+ * @param args The Step generated by the AI SDK.
873
+ */
874
+ saveStep<TOOLS extends ToolSet>(ctx: ActionCtx, args: {
875
+ userId?: string;
876
+ threadId: string;
877
+ /**
878
+ * The message this step is in response to.
879
+ */
880
+ promptMessageId: string;
881
+ /**
882
+ * The step to save, possibly including multiple tool calls.
883
+ */
884
+ step: StepResult<TOOLS>;
885
+ /**
886
+ * The model used to generate the step.
887
+ * Defaults to the chat model for the Agent.
888
+ */
889
+ model?: string;
890
+ /**
891
+ * The provider of the model used to generate the step.
892
+ * Defaults to the chat provider for the Agent.
893
+ */
894
+ provider?: string;
895
+ }): Promise<{
896
+ messages: MessageDoc[];
897
+ }>;
898
+ /**
899
+ * Manually save the result of a generateObject call to the thread.
900
+ * This happens automatically when using {@link generateObject} or {@link streamObject}
901
+ * from the `thread` object created by {@link continueThread} or {@link createThread}.
902
+ * @param ctx The context passed from the mutation or action function calling this.
903
+ * @param args The arguments to the saveObject function.
904
+ */
905
+ saveObject(ctx: ActionCtx, args: {
906
+ userId: string | undefined;
907
+ threadId: string;
908
+ promptMessageId: string;
909
+ model: string | undefined;
910
+ provider: string | undefined;
911
+ result: GenerateObjectResult<unknown>;
912
+ metadata?: Omit<MessageWithMetadata, "message">;
913
+ }): Promise<{
914
+ messages: MessageDoc[];
915
+ }>;
916
+ /**
917
+ * Commit or rollback a message that was pending.
918
+ * This is done automatically when saving messages by default.
919
+ * If creating pending messages, you can call this when the full "transaction" is done.
920
+ * @param ctx The ctx argument to your mutation or action.
921
+ * @param args What message to save. Generally the parent message sent into
922
+ * the generateText call.
923
+ */
924
+ finalizeMessage(ctx: MutationCtx | ActionCtx, args: {
925
+ messageId: string;
926
+ result: {
927
+ status: "failed";
928
+ error: string;
929
+ } | {
930
+ status: "success";
931
+ };
932
+ }): Promise<void>;
933
+ /**
934
+ * Update a message by its id.
935
+ * @param ctx The ctx argument to your mutation or action.
936
+ * @param args The message fields to update.
937
+ */
938
+ updateMessage(ctx: MutationCtx | ActionCtx, args: {
939
+ /** The id of the message to update. */
940
+ messageId: string;
941
+ patch: {
942
+ /** The message to replace the existing message. */
943
+ message: ModelMessage | Message;
944
+ /** The status to set on the message. */
945
+ status: "success" | "error";
946
+ /** The error message to set on the message. */
947
+ error?: string;
948
+ /**
949
+ * These will override the fileIds in the message.
950
+ * To remove all existing files, pass an empty array.
951
+ * If passing in a new message, pass in the fileIds you explicitly want to keep
952
+ * from the previous message, as the new files generated from the new message
953
+ * will be added to the list.
954
+ * If you pass undefined, it will not change the fileIds unless new
955
+ * files are generated from the message. In that case, the new fileIds
956
+ * will replace the old fileIds.
957
+ */
958
+ fileIds?: string[];
959
+ };
960
+ }): Promise<void>;
961
+ /**
962
+ * Delete multiple messages by their ids, including their embeddings
963
+ * and reduce the refcount of any files they reference.
964
+ * @param ctx The ctx argument to your mutation or action.
965
+ * @param args The ids of the messages to delete.
966
+ */
967
+ deleteMessages(ctx: MutationCtx | ActionCtx, args: {
968
+ messageIds: string[];
969
+ }): Promise<void>;
970
+ /**
971
+ * Delete a single message by its id, including its embedding
972
+ * and reduce the refcount of any files it references.
973
+ * @param ctx The ctx argument to your mutation or action.
974
+ * @param args The id of the message to delete.
975
+ */
976
+ deleteMessage(ctx: MutationCtx | ActionCtx, args: {
977
+ messageId: string;
978
+ }): Promise<void>;
979
+ /**
980
+ * Delete a range of messages by their order and step order.
981
+ * Each "order" is a set of associated messages in response to the message
982
+ * at stepOrder 0.
983
+ * The (startOrder, startStepOrder) is inclusive
984
+ * and the (endOrder, endStepOrder) is exclusive.
985
+ * To delete all messages at "order" 1, you can pass:
986
+ * `{ startOrder: 1, endOrder: 2 }`
987
+ * To delete a message at step (order=1, stepOrder=1), you can pass:
988
+ * `{ startOrder: 1, startStepOrder: 1, endOrder: 1, endStepOrder: 2 }`
989
+ * To delete all messages between (1, 1) up to and including (3, 5), you can pass:
990
+ * `{ startOrder: 1, startStepOrder: 1, endOrder: 3, endStepOrder: 6 }`
991
+ *
992
+ * If it cannot do it in one transaction, it returns information you can use
993
+ * to resume the deletion.
994
+ * e.g.
995
+ * ```ts
996
+ * let isDone = false;
997
+ * let lastOrder = args.startOrder;
998
+ * let lastStepOrder = args.startStepOrder ?? 0;
999
+ * while (!isDone) {
1000
+ * // eslint-disable-next-line @typescript-eslint/no-explicit-any
1001
+ * ({ isDone, lastOrder, lastStepOrder } = await agent.deleteMessageRange(
1002
+ * ctx,
1003
+ * {
1004
+ * threadId: args.threadId,
1005
+ * startOrder: lastOrder,
1006
+ * startStepOrder: lastStepOrder,
1007
+ * endOrder: args.endOrder,
1008
+ * endStepOrder: args.endStepOrder,
1009
+ * }
1010
+ * ));
1011
+ * }
1012
+ * ```
1013
+ * @param ctx The ctx argument to your mutation or action.
1014
+ * @param args The range of messages to delete.
1015
+ */
1016
+ deleteMessageRange(ctx: MutationCtx | ActionCtx, args: {
1017
+ threadId: string;
1018
+ startOrder: number;
1019
+ startStepOrder?: number;
1020
+ endOrder: number;
1021
+ endStepOrder?: number;
1022
+ }): Promise<{
1023
+ isDone: boolean;
1024
+ lastOrder?: number;
1025
+ lastStepOrder?: number;
1026
+ }>;
1027
+ /**
1028
+ * Delete a thread and all its messages and streams asynchronously (in batches)
1029
+ * This uses a mutation to that processes one page and recursively queues the
1030
+ * next page for deletion.
1031
+ * @param ctx The ctx argument to your mutation or action.
1032
+ * @param args The id of the thread to delete and optionally the page size to use for the delete.
1033
+ */
1034
+ deleteThreadAsync(ctx: MutationCtx | ActionCtx, args: {
1035
+ threadId: string;
1036
+ pageSize?: number;
1037
+ }): Promise<void>;
1038
+ /**
1039
+ * Delete a thread and all its messages and streams synchronously.
1040
+ * This uses an action to iterate through all pages. If the action fails
1041
+ * partway, it will not automatically restart.
1042
+ * @param ctx The ctx argument to your action.
1043
+ * @param args The id of the thread to delete and optionally the page size to use for the delete.
1044
+ */
1045
+ deleteThreadSync(ctx: ActionCtx, args: {
1046
+ threadId: string;
1047
+ pageSize?: number;
1048
+ }): Promise<void>;
1049
+ /**
1050
+ * WORKFLOW UTILITIES
1051
+ */
1052
+ /**
1053
+ * Create a mutation that creates a thread so you can call it from a Workflow.
1054
+ * e.g.
1055
+ * ```ts
1056
+ * // in convex/foo.ts
1057
+ * export const createThread = weatherAgent.createThreadMutation();
1058
+ *
1059
+ * const workflow = new WorkflowManager(components.workflow);
1060
+ * export const myWorkflow = workflow.define({
1061
+ * args: {},
1062
+ * handler: async (step) => {
1063
+ * const { threadId } = await step.runMutation(internal.foo.createThread);
1064
+ * // use the threadId to generate text, object, etc.
1065
+ * },
1066
+ * });
1067
+ * ```
1068
+ * @returns A mutation that creates a thread.
1069
+ */
1070
+ createThreadMutation(): import("convex/server").RegisteredMutation<"internal", {
1071
+ userId?: string | undefined;
1072
+ title?: string | undefined;
1073
+ summary?: string | undefined;
1074
+ }, Promise<{
1075
+ threadId: string;
1076
+ }>>;
1077
+ /**
1078
+ * Create an action out of this agent so you can call it from workflows or other actions
1079
+ * without a wrapping function.
1080
+ * @param spec Configuration for the agent acting as an action, including
1081
+ * {@link ContextOptions}, {@link StorageOptions}, and {@link stopWhen}.
1082
+ */
1083
+ asTextAction<DataModel extends GenericDataModel>(spec: MaybeCustomCtx<CustomCtx, DataModel, AgentTools> & {
1084
+ /**
1085
+ * Whether to stream the text.
1086
+ * If false, it will generate the text in a single call. (default)
1087
+ * If true or {@link StreamingOptions}, it will stream the text from the LLM
1088
+ * and save the chunks to the database with the options you specify, or the
1089
+ * defaults if you pass true.
1090
+ */
1091
+ stream?: boolean | StreamingOptions;
1092
+ /**
1093
+ * When to stop generating text.
1094
+ * Defaults to the {@link Agent["options"].stopWhen} option.
1095
+ */
1096
+ stopWhen?: StopCondition<AgentTools> | Array<StopCondition<AgentTools>>;
1097
+ } & Options, overrides?: CallSettings): import("convex/server").RegisteredAction<"internal", {
1098
+ userId?: string | undefined;
1099
+ threadId?: string | undefined;
1100
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1101
+ system?: string | undefined;
1102
+ messages?: ({
1103
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1104
+ role: "user";
1105
+ content: string | ({
1106
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1107
+ providerMetadata?: Record<string, Record<string, any>> | undefined;
1108
+ type: "text";
1109
+ text: string;
1110
+ } | {
1111
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1112
+ mediaType?: string | undefined;
1113
+ mimeType?: string | undefined;
1114
+ type: "image";
1115
+ image: string | ArrayBuffer;
1116
+ } | {
1117
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1118
+ providerMetadata?: Record<string, Record<string, any>> | undefined;
1119
+ mediaType?: string | undefined;
1120
+ mimeType?: string | undefined;
1121
+ filename?: string | undefined;
1122
+ type: "file";
1123
+ data: string | ArrayBuffer;
1124
+ })[];
1125
+ } | {
1126
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1127
+ role: "assistant";
1128
+ content: string | ({
1129
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1130
+ providerMetadata?: Record<string, Record<string, any>> | undefined;
1131
+ type: "text";
1132
+ text: string;
1133
+ } | {
1134
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1135
+ providerMetadata?: Record<string, Record<string, any>> | undefined;
1136
+ mediaType?: string | undefined;
1137
+ mimeType?: string | undefined;
1138
+ filename?: string | undefined;
1139
+ type: "file";
1140
+ data: string | ArrayBuffer;
1141
+ } | {
1142
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1143
+ providerMetadata?: Record<string, Record<string, any>> | undefined;
1144
+ signature?: string | undefined;
1145
+ type: "reasoning";
1146
+ text: string;
1147
+ } | {
1148
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1149
+ providerMetadata?: Record<string, Record<string, any>> | undefined;
1150
+ type: "redacted-reasoning";
1151
+ data: string;
1152
+ } | {
1153
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1154
+ providerMetadata?: Record<string, Record<string, any>> | undefined;
1155
+ args?: any;
1156
+ providerExecuted?: boolean | undefined;
1157
+ type: "tool-call";
1158
+ toolCallId: string;
1159
+ toolName: string;
1160
+ input: any;
1161
+ } | {
1162
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1163
+ providerMetadata?: Record<string, Record<string, any>> | undefined;
1164
+ input?: any;
1165
+ providerExecuted?: boolean | undefined;
1166
+ type: "tool-call";
1167
+ toolCallId: string;
1168
+ toolName: string;
1169
+ args: any;
1170
+ } | {
1171
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1172
+ providerMetadata?: Record<string, Record<string, any>> | undefined;
1173
+ args?: any;
1174
+ providerExecuted?: boolean | undefined;
1175
+ output?: {
1176
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1177
+ type: "text";
1178
+ value: string;
1179
+ } | {
1180
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1181
+ type: "json";
1182
+ value: any;
1183
+ } | {
1184
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1185
+ type: "error-text";
1186
+ value: string;
1187
+ } | {
1188
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1189
+ type: "error-json";
1190
+ value: any;
1191
+ } | {
1192
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1193
+ reason?: string | undefined;
1194
+ type: "execution-denied";
1195
+ } | {
1196
+ type: "content";
1197
+ value: ({
1198
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1199
+ type: "text";
1200
+ text: string;
1201
+ } | {
1202
+ type: "media";
1203
+ mediaType: string;
1204
+ data: string;
1205
+ } | {
1206
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1207
+ filename?: string | undefined;
1208
+ type: "file-data";
1209
+ mediaType: string;
1210
+ data: string;
1211
+ } | {
1212
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1213
+ type: "file-url";
1214
+ url: string;
1215
+ } | {
1216
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1217
+ type: "file-id";
1218
+ fileId: string | Record<string, string>;
1219
+ } | {
1220
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1221
+ type: "image-data";
1222
+ mediaType: string;
1223
+ data: string;
1224
+ } | {
1225
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1226
+ type: "image-url";
1227
+ url: string;
1228
+ } | {
1229
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1230
+ type: "image-file-id";
1231
+ fileId: string | Record<string, string>;
1232
+ } | {
1233
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1234
+ type: "custom";
1235
+ })[];
1236
+ } | undefined;
1237
+ result?: any;
1238
+ isError?: boolean | undefined;
1239
+ experimental_content?: ({
1240
+ type: "text";
1241
+ text: string;
1242
+ } | {
1243
+ mimeType?: string | undefined;
1244
+ type: "image";
1245
+ data: string;
1246
+ })[] | undefined;
1247
+ type: "tool-result";
1248
+ toolCallId: string;
1249
+ toolName: string;
1250
+ } | {
1251
+ title?: string | undefined;
1252
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1253
+ providerMetadata?: Record<string, Record<string, any>> | undefined;
1254
+ id: string;
1255
+ type: "source";
1256
+ url: string;
1257
+ sourceType: "url";
1258
+ } | {
1259
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1260
+ providerMetadata?: Record<string, Record<string, any>> | undefined;
1261
+ filename?: string | undefined;
1262
+ id: string;
1263
+ title: string;
1264
+ type: "source";
1265
+ mediaType: string;
1266
+ sourceType: "document";
1267
+ } | {
1268
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1269
+ providerMetadata?: Record<string, Record<string, any>> | undefined;
1270
+ type: "tool-approval-request";
1271
+ toolCallId: string;
1272
+ approvalId: string;
1273
+ })[];
1274
+ } | {
1275
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1276
+ role: "tool";
1277
+ content: ({
1278
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1279
+ providerMetadata?: Record<string, Record<string, any>> | undefined;
1280
+ args?: any;
1281
+ providerExecuted?: boolean | undefined;
1282
+ output?: {
1283
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1284
+ type: "text";
1285
+ value: string;
1286
+ } | {
1287
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1288
+ type: "json";
1289
+ value: any;
1290
+ } | {
1291
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1292
+ type: "error-text";
1293
+ value: string;
1294
+ } | {
1295
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1296
+ type: "error-json";
1297
+ value: any;
1298
+ } | {
1299
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1300
+ reason?: string | undefined;
1301
+ type: "execution-denied";
1302
+ } | {
1303
+ type: "content";
1304
+ value: ({
1305
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1306
+ type: "text";
1307
+ text: string;
1308
+ } | {
1309
+ type: "media";
1310
+ mediaType: string;
1311
+ data: string;
1312
+ } | {
1313
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1314
+ filename?: string | undefined;
1315
+ type: "file-data";
1316
+ mediaType: string;
1317
+ data: string;
1318
+ } | {
1319
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1320
+ type: "file-url";
1321
+ url: string;
1322
+ } | {
1323
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1324
+ type: "file-id";
1325
+ fileId: string | Record<string, string>;
1326
+ } | {
1327
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1328
+ type: "image-data";
1329
+ mediaType: string;
1330
+ data: string;
1331
+ } | {
1332
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1333
+ type: "image-url";
1334
+ url: string;
1335
+ } | {
1336
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1337
+ type: "image-file-id";
1338
+ fileId: string | Record<string, string>;
1339
+ } | {
1340
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1341
+ type: "custom";
1342
+ })[];
1343
+ } | undefined;
1344
+ result?: any;
1345
+ isError?: boolean | undefined;
1346
+ experimental_content?: ({
1347
+ type: "text";
1348
+ text: string;
1349
+ } | {
1350
+ mimeType?: string | undefined;
1351
+ type: "image";
1352
+ data: string;
1353
+ })[] | undefined;
1354
+ type: "tool-result";
1355
+ toolCallId: string;
1356
+ toolName: string;
1357
+ } | {
1358
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1359
+ providerMetadata?: Record<string, Record<string, any>> | undefined;
1360
+ providerExecuted?: boolean | undefined;
1361
+ reason?: string | undefined;
1362
+ type: "tool-approval-response";
1363
+ approvalId: string;
1364
+ approved: boolean;
1365
+ })[];
1366
+ } | {
1367
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1368
+ role: "system";
1369
+ content: string;
1370
+ })[] | undefined;
1371
+ stream?: boolean | undefined;
1372
+ toolChoice?: "required" | "none" | "auto" | {
1373
+ type: "tool";
1374
+ toolName: string;
1375
+ } | undefined;
1376
+ maxSteps?: number | undefined;
1377
+ experimental_continueSteps?: boolean | undefined;
1378
+ prompt?: string | undefined;
1379
+ promptMessageId?: string | undefined;
1380
+ contextOptions?: {
1381
+ excludeToolMessages?: boolean | undefined;
1382
+ recentMessages?: number | undefined;
1383
+ searchOptions?: {
1384
+ textSearch?: boolean | undefined;
1385
+ vectorSearch?: boolean | undefined;
1386
+ vectorScoreThreshold?: number | undefined;
1387
+ messageRange?: {
1388
+ before: number;
1389
+ after: number;
1390
+ } | undefined;
1391
+ limit: number;
1392
+ } | undefined;
1393
+ searchOtherThreads?: boolean | undefined;
1394
+ } | undefined;
1395
+ storageOptions?: {
1396
+ saveMessages?: "all" | "none" | "promptAndOutput" | undefined;
1397
+ } | undefined;
1398
+ callSettings?: {
1399
+ headers?: Record<string, string> | undefined;
1400
+ maxOutputTokens?: number | undefined;
1401
+ temperature?: number | undefined;
1402
+ topP?: number | undefined;
1403
+ topK?: number | undefined;
1404
+ presencePenalty?: number | undefined;
1405
+ frequencyPenalty?: number | undefined;
1406
+ stopSequences?: string[] | undefined;
1407
+ seed?: number | undefined;
1408
+ maxRetries?: number | undefined;
1409
+ } | undefined;
1410
+ }, Promise<{
1411
+ text: string;
1412
+ promptMessageId: string | undefined;
1413
+ order: number | undefined;
1414
+ finishReason: import("ai").FinishReason;
1415
+ warnings: import("@ai-sdk/provider").SharedV3Warning[] | undefined;
1416
+ savedMessageIds: string[];
1417
+ }>>;
1418
+ /**
1419
+ * Create an action that generates an object out of this agent so you can call
1420
+ * it from workflows or other actions without a wrapping function.
1421
+ * @param spec Configuration for the agent acting as an action, including
1422
+ * the normal parameters to {@link generateObject}, plus {@link ContextOptions}
1423
+ * and stopWhen.
1424
+ */
1425
+ asObjectAction<T, DataModel extends GenericDataModel>(objectArgs: GenerateObjectArgs<FlexibleSchema<T>> & Partial<AgentPrompt>, options?: Options & MaybeCustomCtx<CustomCtx, DataModel, AgentTools>): import("convex/server").RegisteredAction<"internal", {
1426
+ userId?: string | undefined;
1427
+ threadId?: string | undefined;
1428
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1429
+ system?: string | undefined;
1430
+ messages?: ({
1431
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1432
+ role: "user";
1433
+ content: string | ({
1434
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1435
+ providerMetadata?: Record<string, Record<string, any>> | undefined;
1436
+ type: "text";
1437
+ text: string;
1438
+ } | {
1439
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1440
+ mediaType?: string | undefined;
1441
+ mimeType?: string | undefined;
1442
+ type: "image";
1443
+ image: string | ArrayBuffer;
1444
+ } | {
1445
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1446
+ providerMetadata?: Record<string, Record<string, any>> | undefined;
1447
+ mediaType?: string | undefined;
1448
+ mimeType?: string | undefined;
1449
+ filename?: string | undefined;
1450
+ type: "file";
1451
+ data: string | ArrayBuffer;
1452
+ })[];
1453
+ } | {
1454
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1455
+ role: "assistant";
1456
+ content: string | ({
1457
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1458
+ providerMetadata?: Record<string, Record<string, any>> | undefined;
1459
+ type: "text";
1460
+ text: string;
1461
+ } | {
1462
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1463
+ providerMetadata?: Record<string, Record<string, any>> | undefined;
1464
+ mediaType?: string | undefined;
1465
+ mimeType?: string | undefined;
1466
+ filename?: string | undefined;
1467
+ type: "file";
1468
+ data: string | ArrayBuffer;
1469
+ } | {
1470
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1471
+ providerMetadata?: Record<string, Record<string, any>> | undefined;
1472
+ signature?: string | undefined;
1473
+ type: "reasoning";
1474
+ text: string;
1475
+ } | {
1476
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1477
+ providerMetadata?: Record<string, Record<string, any>> | undefined;
1478
+ type: "redacted-reasoning";
1479
+ data: string;
1480
+ } | {
1481
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1482
+ providerMetadata?: Record<string, Record<string, any>> | undefined;
1483
+ args?: any;
1484
+ providerExecuted?: boolean | undefined;
1485
+ type: "tool-call";
1486
+ toolCallId: string;
1487
+ toolName: string;
1488
+ input: any;
1489
+ } | {
1490
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1491
+ providerMetadata?: Record<string, Record<string, any>> | undefined;
1492
+ input?: any;
1493
+ providerExecuted?: boolean | undefined;
1494
+ type: "tool-call";
1495
+ toolCallId: string;
1496
+ toolName: string;
1497
+ args: any;
1498
+ } | {
1499
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1500
+ providerMetadata?: Record<string, Record<string, any>> | undefined;
1501
+ args?: any;
1502
+ providerExecuted?: boolean | undefined;
1503
+ output?: {
1504
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1505
+ type: "text";
1506
+ value: string;
1507
+ } | {
1508
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1509
+ type: "json";
1510
+ value: any;
1511
+ } | {
1512
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1513
+ type: "error-text";
1514
+ value: string;
1515
+ } | {
1516
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1517
+ type: "error-json";
1518
+ value: any;
1519
+ } | {
1520
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1521
+ reason?: string | undefined;
1522
+ type: "execution-denied";
1523
+ } | {
1524
+ type: "content";
1525
+ value: ({
1526
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1527
+ type: "text";
1528
+ text: string;
1529
+ } | {
1530
+ type: "media";
1531
+ mediaType: string;
1532
+ data: string;
1533
+ } | {
1534
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1535
+ filename?: string | undefined;
1536
+ type: "file-data";
1537
+ mediaType: string;
1538
+ data: string;
1539
+ } | {
1540
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1541
+ type: "file-url";
1542
+ url: string;
1543
+ } | {
1544
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1545
+ type: "file-id";
1546
+ fileId: string | Record<string, string>;
1547
+ } | {
1548
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1549
+ type: "image-data";
1550
+ mediaType: string;
1551
+ data: string;
1552
+ } | {
1553
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1554
+ type: "image-url";
1555
+ url: string;
1556
+ } | {
1557
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1558
+ type: "image-file-id";
1559
+ fileId: string | Record<string, string>;
1560
+ } | {
1561
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1562
+ type: "custom";
1563
+ })[];
1564
+ } | undefined;
1565
+ result?: any;
1566
+ isError?: boolean | undefined;
1567
+ experimental_content?: ({
1568
+ type: "text";
1569
+ text: string;
1570
+ } | {
1571
+ mimeType?: string | undefined;
1572
+ type: "image";
1573
+ data: string;
1574
+ })[] | undefined;
1575
+ type: "tool-result";
1576
+ toolCallId: string;
1577
+ toolName: string;
1578
+ } | {
1579
+ title?: string | undefined;
1580
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1581
+ providerMetadata?: Record<string, Record<string, any>> | undefined;
1582
+ id: string;
1583
+ type: "source";
1584
+ url: string;
1585
+ sourceType: "url";
1586
+ } | {
1587
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1588
+ providerMetadata?: Record<string, Record<string, any>> | undefined;
1589
+ filename?: string | undefined;
1590
+ id: string;
1591
+ title: string;
1592
+ type: "source";
1593
+ mediaType: string;
1594
+ sourceType: "document";
1595
+ } | {
1596
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1597
+ providerMetadata?: Record<string, Record<string, any>> | undefined;
1598
+ type: "tool-approval-request";
1599
+ toolCallId: string;
1600
+ approvalId: string;
1601
+ })[];
1602
+ } | {
1603
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1604
+ role: "tool";
1605
+ content: ({
1606
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1607
+ providerMetadata?: Record<string, Record<string, any>> | undefined;
1608
+ args?: any;
1609
+ providerExecuted?: boolean | undefined;
1610
+ output?: {
1611
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1612
+ type: "text";
1613
+ value: string;
1614
+ } | {
1615
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1616
+ type: "json";
1617
+ value: any;
1618
+ } | {
1619
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1620
+ type: "error-text";
1621
+ value: string;
1622
+ } | {
1623
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1624
+ type: "error-json";
1625
+ value: any;
1626
+ } | {
1627
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1628
+ reason?: string | undefined;
1629
+ type: "execution-denied";
1630
+ } | {
1631
+ type: "content";
1632
+ value: ({
1633
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1634
+ type: "text";
1635
+ text: string;
1636
+ } | {
1637
+ type: "media";
1638
+ mediaType: string;
1639
+ data: string;
1640
+ } | {
1641
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1642
+ filename?: string | undefined;
1643
+ type: "file-data";
1644
+ mediaType: string;
1645
+ data: string;
1646
+ } | {
1647
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1648
+ type: "file-url";
1649
+ url: string;
1650
+ } | {
1651
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1652
+ type: "file-id";
1653
+ fileId: string | Record<string, string>;
1654
+ } | {
1655
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1656
+ type: "image-data";
1657
+ mediaType: string;
1658
+ data: string;
1659
+ } | {
1660
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1661
+ type: "image-url";
1662
+ url: string;
1663
+ } | {
1664
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1665
+ type: "image-file-id";
1666
+ fileId: string | Record<string, string>;
1667
+ } | {
1668
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1669
+ type: "custom";
1670
+ })[];
1671
+ } | undefined;
1672
+ result?: any;
1673
+ isError?: boolean | undefined;
1674
+ experimental_content?: ({
1675
+ type: "text";
1676
+ text: string;
1677
+ } | {
1678
+ mimeType?: string | undefined;
1679
+ type: "image";
1680
+ data: string;
1681
+ })[] | undefined;
1682
+ type: "tool-result";
1683
+ toolCallId: string;
1684
+ toolName: string;
1685
+ } | {
1686
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1687
+ providerMetadata?: Record<string, Record<string, any>> | undefined;
1688
+ providerExecuted?: boolean | undefined;
1689
+ reason?: string | undefined;
1690
+ type: "tool-approval-response";
1691
+ approvalId: string;
1692
+ approved: boolean;
1693
+ })[];
1694
+ } | {
1695
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1696
+ role: "system";
1697
+ content: string;
1698
+ })[] | undefined;
1699
+ prompt?: string | undefined;
1700
+ promptMessageId?: string | undefined;
1701
+ contextOptions?: {
1702
+ excludeToolMessages?: boolean | undefined;
1703
+ recentMessages?: number | undefined;
1704
+ searchOptions?: {
1705
+ textSearch?: boolean | undefined;
1706
+ vectorSearch?: boolean | undefined;
1707
+ vectorScoreThreshold?: number | undefined;
1708
+ messageRange?: {
1709
+ before: number;
1710
+ after: number;
1711
+ } | undefined;
1712
+ limit: number;
1713
+ } | undefined;
1714
+ searchOtherThreads?: boolean | undefined;
1715
+ } | undefined;
1716
+ storageOptions?: {
1717
+ saveMessages?: "all" | "none" | "promptAndOutput" | undefined;
1718
+ } | undefined;
1719
+ callSettings?: {
1720
+ headers?: Record<string, string> | undefined;
1721
+ maxOutputTokens?: number | undefined;
1722
+ temperature?: number | undefined;
1723
+ topP?: number | undefined;
1724
+ topK?: number | undefined;
1725
+ presencePenalty?: number | undefined;
1726
+ frequencyPenalty?: number | undefined;
1727
+ stopSequences?: string[] | undefined;
1728
+ seed?: number | undefined;
1729
+ maxRetries?: number | undefined;
1730
+ } | undefined;
1731
+ }, Promise<{
1732
+ object: T;
1733
+ promptMessageId: string | undefined;
1734
+ order: number | undefined;
1735
+ finishReason: import("ai").FinishReason;
1736
+ warnings: import("@ai-sdk/provider").SharedV3Warning[] | undefined;
1737
+ savedMessageIds: string[];
1738
+ }>>;
1739
+ /**
1740
+ * @deprecated Use {@link saveMessages} directly instead.
1741
+ */
1742
+ asSaveMessagesMutation(): import("convex/server").RegisteredMutation<"internal", {
1743
+ userId?: string | undefined;
1744
+ promptMessageId?: string | undefined;
1745
+ embeddings?: {
1746
+ model: string;
1747
+ vectors: (number[] | null)[];
1748
+ } | undefined;
1749
+ failPendingSteps?: boolean | undefined;
1750
+ threadId: string;
1751
+ messages: {
1752
+ status?: "pending" | "success" | "failed" | undefined;
1753
+ fileIds?: string[] | undefined;
1754
+ error?: string | undefined;
1755
+ model?: string | undefined;
1756
+ provider?: string | undefined;
1757
+ text?: string | undefined;
1758
+ providerMetadata?: Record<string, Record<string, any>> | undefined;
1759
+ reasoning?: string | undefined;
1760
+ usage?: {
1761
+ reasoningTokens?: number | undefined;
1762
+ cachedInputTokens?: number | undefined;
1763
+ promptTokens: number;
1764
+ completionTokens: number;
1765
+ totalTokens: number;
1766
+ } | undefined;
1767
+ sources?: ({
1768
+ title?: string | undefined;
1769
+ type?: "source" | undefined;
1770
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1771
+ providerMetadata?: Record<string, Record<string, any>> | undefined;
1772
+ id: string;
1773
+ url: string;
1774
+ sourceType: "url";
1775
+ } | {
1776
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1777
+ providerMetadata?: Record<string, Record<string, any>> | undefined;
1778
+ filename?: string | undefined;
1779
+ id: string;
1780
+ title: string;
1781
+ type: "source";
1782
+ mediaType: string;
1783
+ sourceType: "document";
1784
+ })[] | undefined;
1785
+ warnings?: ({
1786
+ details?: string | undefined;
1787
+ type: "unsupported-setting";
1788
+ setting: string;
1789
+ } | {
1790
+ details?: string | undefined;
1791
+ type: "unsupported-tool";
1792
+ tool: any;
1793
+ } | {
1794
+ type: "other";
1795
+ message: string;
1796
+ })[] | undefined;
1797
+ finishReason?: "error" | "length" | "other" | "stop" | "content-filter" | "tool-calls" | "unknown" | undefined;
1798
+ reasoningDetails?: ({
1799
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1800
+ providerMetadata?: Record<string, Record<string, any>> | undefined;
1801
+ signature?: string | undefined;
1802
+ type: "reasoning";
1803
+ text: string;
1804
+ } | {
1805
+ signature?: string | undefined;
1806
+ type: "text";
1807
+ text: string;
1808
+ } | {
1809
+ type: "redacted";
1810
+ data: string;
1811
+ })[] | undefined;
1812
+ message: {
1813
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1814
+ role: "user";
1815
+ content: string | ({
1816
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1817
+ providerMetadata?: Record<string, Record<string, any>> | undefined;
1818
+ type: "text";
1819
+ text: string;
1820
+ } | {
1821
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1822
+ mediaType?: string | undefined;
1823
+ mimeType?: string | undefined;
1824
+ type: "image";
1825
+ image: string | ArrayBuffer;
1826
+ } | {
1827
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1828
+ providerMetadata?: Record<string, Record<string, any>> | undefined;
1829
+ mediaType?: string | undefined;
1830
+ mimeType?: string | undefined;
1831
+ filename?: string | undefined;
1832
+ type: "file";
1833
+ data: string | ArrayBuffer;
1834
+ })[];
1835
+ } | {
1836
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1837
+ role: "assistant";
1838
+ content: string | ({
1839
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1840
+ providerMetadata?: Record<string, Record<string, any>> | undefined;
1841
+ type: "text";
1842
+ text: string;
1843
+ } | {
1844
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1845
+ providerMetadata?: Record<string, Record<string, any>> | undefined;
1846
+ mediaType?: string | undefined;
1847
+ mimeType?: string | undefined;
1848
+ filename?: string | undefined;
1849
+ type: "file";
1850
+ data: string | ArrayBuffer;
1851
+ } | {
1852
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1853
+ providerMetadata?: Record<string, Record<string, any>> | undefined;
1854
+ signature?: string | undefined;
1855
+ type: "reasoning";
1856
+ text: string;
1857
+ } | {
1858
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1859
+ providerMetadata?: Record<string, Record<string, any>> | undefined;
1860
+ type: "redacted-reasoning";
1861
+ data: string;
1862
+ } | {
1863
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1864
+ providerMetadata?: Record<string, Record<string, any>> | undefined;
1865
+ args?: any;
1866
+ providerExecuted?: boolean | undefined;
1867
+ type: "tool-call";
1868
+ toolCallId: string;
1869
+ toolName: string;
1870
+ input: any;
1871
+ } | {
1872
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1873
+ providerMetadata?: Record<string, Record<string, any>> | undefined;
1874
+ input?: any;
1875
+ providerExecuted?: boolean | undefined;
1876
+ type: "tool-call";
1877
+ toolCallId: string;
1878
+ toolName: string;
1879
+ args: any;
1880
+ } | {
1881
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1882
+ providerMetadata?: Record<string, Record<string, any>> | undefined;
1883
+ args?: any;
1884
+ providerExecuted?: boolean | undefined;
1885
+ output?: {
1886
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1887
+ type: "text";
1888
+ value: string;
1889
+ } | {
1890
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1891
+ type: "json";
1892
+ value: any;
1893
+ } | {
1894
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1895
+ type: "error-text";
1896
+ value: string;
1897
+ } | {
1898
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1899
+ type: "error-json";
1900
+ value: any;
1901
+ } | {
1902
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1903
+ reason?: string | undefined;
1904
+ type: "execution-denied";
1905
+ } | {
1906
+ type: "content";
1907
+ value: ({
1908
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1909
+ type: "text";
1910
+ text: string;
1911
+ } | {
1912
+ type: "media";
1913
+ mediaType: string;
1914
+ data: string;
1915
+ } | {
1916
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1917
+ filename?: string | undefined;
1918
+ type: "file-data";
1919
+ mediaType: string;
1920
+ data: string;
1921
+ } | {
1922
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1923
+ type: "file-url";
1924
+ url: string;
1925
+ } | {
1926
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1927
+ type: "file-id";
1928
+ fileId: string | Record<string, string>;
1929
+ } | {
1930
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1931
+ type: "image-data";
1932
+ mediaType: string;
1933
+ data: string;
1934
+ } | {
1935
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1936
+ type: "image-url";
1937
+ url: string;
1938
+ } | {
1939
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1940
+ type: "image-file-id";
1941
+ fileId: string | Record<string, string>;
1942
+ } | {
1943
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1944
+ type: "custom";
1945
+ })[];
1946
+ } | undefined;
1947
+ result?: any;
1948
+ isError?: boolean | undefined;
1949
+ experimental_content?: ({
1950
+ type: "text";
1951
+ text: string;
1952
+ } | {
1953
+ mimeType?: string | undefined;
1954
+ type: "image";
1955
+ data: string;
1956
+ })[] | undefined;
1957
+ type: "tool-result";
1958
+ toolCallId: string;
1959
+ toolName: string;
1960
+ } | {
1961
+ title?: string | undefined;
1962
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1963
+ providerMetadata?: Record<string, Record<string, any>> | undefined;
1964
+ id: string;
1965
+ type: "source";
1966
+ url: string;
1967
+ sourceType: "url";
1968
+ } | {
1969
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1970
+ providerMetadata?: Record<string, Record<string, any>> | undefined;
1971
+ filename?: string | undefined;
1972
+ id: string;
1973
+ title: string;
1974
+ type: "source";
1975
+ mediaType: string;
1976
+ sourceType: "document";
1977
+ } | {
1978
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1979
+ providerMetadata?: Record<string, Record<string, any>> | undefined;
1980
+ type: "tool-approval-request";
1981
+ toolCallId: string;
1982
+ approvalId: string;
1983
+ })[];
1984
+ } | {
1985
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1986
+ role: "tool";
1987
+ content: ({
1988
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1989
+ providerMetadata?: Record<string, Record<string, any>> | undefined;
1990
+ args?: any;
1991
+ providerExecuted?: boolean | undefined;
1992
+ output?: {
1993
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1994
+ type: "text";
1995
+ value: string;
1996
+ } | {
1997
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1998
+ type: "json";
1999
+ value: any;
2000
+ } | {
2001
+ providerOptions?: Record<string, Record<string, any>> | undefined;
2002
+ type: "error-text";
2003
+ value: string;
2004
+ } | {
2005
+ providerOptions?: Record<string, Record<string, any>> | undefined;
2006
+ type: "error-json";
2007
+ value: any;
2008
+ } | {
2009
+ providerOptions?: Record<string, Record<string, any>> | undefined;
2010
+ reason?: string | undefined;
2011
+ type: "execution-denied";
2012
+ } | {
2013
+ type: "content";
2014
+ value: ({
2015
+ providerOptions?: Record<string, Record<string, any>> | undefined;
2016
+ type: "text";
2017
+ text: string;
2018
+ } | {
2019
+ type: "media";
2020
+ mediaType: string;
2021
+ data: string;
2022
+ } | {
2023
+ providerOptions?: Record<string, Record<string, any>> | undefined;
2024
+ filename?: string | undefined;
2025
+ type: "file-data";
2026
+ mediaType: string;
2027
+ data: string;
2028
+ } | {
2029
+ providerOptions?: Record<string, Record<string, any>> | undefined;
2030
+ type: "file-url";
2031
+ url: string;
2032
+ } | {
2033
+ providerOptions?: Record<string, Record<string, any>> | undefined;
2034
+ type: "file-id";
2035
+ fileId: string | Record<string, string>;
2036
+ } | {
2037
+ providerOptions?: Record<string, Record<string, any>> | undefined;
2038
+ type: "image-data";
2039
+ mediaType: string;
2040
+ data: string;
2041
+ } | {
2042
+ providerOptions?: Record<string, Record<string, any>> | undefined;
2043
+ type: "image-url";
2044
+ url: string;
2045
+ } | {
2046
+ providerOptions?: Record<string, Record<string, any>> | undefined;
2047
+ type: "image-file-id";
2048
+ fileId: string | Record<string, string>;
2049
+ } | {
2050
+ providerOptions?: Record<string, Record<string, any>> | undefined;
2051
+ type: "custom";
2052
+ })[];
2053
+ } | undefined;
2054
+ result?: any;
2055
+ isError?: boolean | undefined;
2056
+ experimental_content?: ({
2057
+ type: "text";
2058
+ text: string;
2059
+ } | {
2060
+ mimeType?: string | undefined;
2061
+ type: "image";
2062
+ data: string;
2063
+ })[] | undefined;
2064
+ type: "tool-result";
2065
+ toolCallId: string;
2066
+ toolName: string;
2067
+ } | {
2068
+ providerOptions?: Record<string, Record<string, any>> | undefined;
2069
+ providerMetadata?: Record<string, Record<string, any>> | undefined;
2070
+ providerExecuted?: boolean | undefined;
2071
+ reason?: string | undefined;
2072
+ type: "tool-approval-response";
2073
+ approvalId: string;
2074
+ approved: boolean;
2075
+ })[];
2076
+ } | {
2077
+ providerOptions?: Record<string, Record<string, any>> | undefined;
2078
+ role: "system";
2079
+ content: string;
2080
+ };
2081
+ }[];
2082
+ }, Promise<{
2083
+ lastMessageId: string;
2084
+ messages: {
2085
+ order: number;
2086
+ stepOrder: number;
2087
+ _id: string;
2088
+ }[];
2089
+ }>>;
2090
+ }
2091
+ //# sourceMappingURL=index.d.ts.map