@convex-dev/agent 0.1.6 → 0.1.7-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (99) hide show
  1. package/README.md +23 -12
  2. package/dist/commonjs/client/_generated/_ignore.d.ts +1 -0
  3. package/dist/commonjs/client/_generated/_ignore.d.ts.map +1 -0
  4. package/dist/commonjs/client/_generated/_ignore.js +3 -0
  5. package/dist/commonjs/client/_generated/_ignore.js.map +1 -0
  6. package/dist/commonjs/client/files.d.ts +57 -0
  7. package/dist/commonjs/client/files.d.ts.map +1 -0
  8. package/dist/commonjs/client/files.js +124 -0
  9. package/dist/commonjs/client/files.js.map +1 -0
  10. package/dist/commonjs/client/index.d.ts +489 -318
  11. package/dist/commonjs/client/index.d.ts.map +1 -1
  12. package/dist/commonjs/client/index.js +652 -550
  13. package/dist/commonjs/client/index.js.map +1 -1
  14. package/dist/commonjs/client/types.d.ts +35 -5
  15. package/dist/commonjs/client/types.d.ts.map +1 -1
  16. package/dist/commonjs/component/_generated/api.d.ts +53 -711
  17. package/dist/commonjs/component/files.d.ts +66 -21
  18. package/dist/commonjs/component/files.d.ts.map +1 -1
  19. package/dist/commonjs/component/files.js +71 -26
  20. package/dist/commonjs/component/files.js.map +1 -1
  21. package/dist/commonjs/component/messages.d.ts +37 -499
  22. package/dist/commonjs/component/messages.d.ts.map +1 -1
  23. package/dist/commonjs/component/messages.js +44 -124
  24. package/dist/commonjs/component/messages.js.map +1 -1
  25. package/dist/commonjs/component/schema.d.ts +951 -3785
  26. package/dist/commonjs/component/schema.d.ts.map +1 -1
  27. package/dist/commonjs/component/schema.js +8 -25
  28. package/dist/commonjs/component/schema.js.map +1 -1
  29. package/dist/commonjs/component/streams.d.ts +3 -3
  30. package/dist/commonjs/mapping.d.ts +28 -19
  31. package/dist/commonjs/mapping.d.ts.map +1 -1
  32. package/dist/commonjs/mapping.js +136 -81
  33. package/dist/commonjs/mapping.js.map +1 -1
  34. package/dist/commonjs/react/toUIMessages.d.ts.map +1 -1
  35. package/dist/commonjs/react/toUIMessages.js +12 -6
  36. package/dist/commonjs/react/toUIMessages.js.map +1 -1
  37. package/dist/commonjs/validators.d.ts +851 -3388
  38. package/dist/commonjs/validators.d.ts.map +1 -1
  39. package/dist/commonjs/validators.js +11 -37
  40. package/dist/commonjs/validators.js.map +1 -1
  41. package/dist/commonjs.tsbuildinfo +1 -1
  42. package/dist/esm/client/_generated/_ignore.d.ts +1 -0
  43. package/dist/esm/client/_generated/_ignore.d.ts.map +1 -0
  44. package/dist/esm/client/_generated/_ignore.js +3 -0
  45. package/dist/esm/client/_generated/_ignore.js.map +1 -0
  46. package/dist/esm/client/files.d.ts +57 -0
  47. package/dist/esm/client/files.d.ts.map +1 -0
  48. package/dist/esm/client/files.js +124 -0
  49. package/dist/esm/client/files.js.map +1 -0
  50. package/dist/esm/client/index.d.ts +489 -318
  51. package/dist/esm/client/index.d.ts.map +1 -1
  52. package/dist/esm/client/index.js +652 -550
  53. package/dist/esm/client/index.js.map +1 -1
  54. package/dist/esm/client/types.d.ts +35 -5
  55. package/dist/esm/client/types.d.ts.map +1 -1
  56. package/dist/esm/component/_generated/api.d.ts +53 -711
  57. package/dist/esm/component/files.d.ts +66 -21
  58. package/dist/esm/component/files.d.ts.map +1 -1
  59. package/dist/esm/component/files.js +71 -26
  60. package/dist/esm/component/files.js.map +1 -1
  61. package/dist/esm/component/messages.d.ts +37 -499
  62. package/dist/esm/component/messages.d.ts.map +1 -1
  63. package/dist/esm/component/messages.js +44 -124
  64. package/dist/esm/component/messages.js.map +1 -1
  65. package/dist/esm/component/schema.d.ts +951 -3785
  66. package/dist/esm/component/schema.d.ts.map +1 -1
  67. package/dist/esm/component/schema.js +8 -25
  68. package/dist/esm/component/schema.js.map +1 -1
  69. package/dist/esm/component/streams.d.ts +3 -3
  70. package/dist/esm/mapping.d.ts +28 -19
  71. package/dist/esm/mapping.d.ts.map +1 -1
  72. package/dist/esm/mapping.js +136 -81
  73. package/dist/esm/mapping.js.map +1 -1
  74. package/dist/esm/react/toUIMessages.d.ts.map +1 -1
  75. package/dist/esm/react/toUIMessages.js +12 -6
  76. package/dist/esm/react/toUIMessages.js.map +1 -1
  77. package/dist/esm/validators.d.ts +851 -3388
  78. package/dist/esm/validators.d.ts.map +1 -1
  79. package/dist/esm/validators.js +11 -37
  80. package/dist/esm/validators.js.map +1 -1
  81. package/dist/esm.tsbuildinfo +1 -1
  82. package/package.json +11 -9
  83. package/src/client/_generated/_ignore.ts +1 -0
  84. package/src/client/files.ts +167 -0
  85. package/src/client/index.test.ts +127 -1
  86. package/src/client/index.ts +970 -812
  87. package/src/client/setup.test.ts +29 -0
  88. package/src/client/types.ts +41 -3
  89. package/src/component/_generated/api.d.ts +53 -711
  90. package/src/component/files.test.ts +130 -0
  91. package/src/component/files.ts +83 -27
  92. package/src/component/messages.test.ts +2 -1
  93. package/src/component/messages.ts +46 -136
  94. package/src/component/schema.ts +7 -28
  95. package/src/mapping.test.ts +163 -0
  96. package/src/mapping.ts +173 -103
  97. package/src/react/deltas.test.ts +4 -1
  98. package/src/react/toUIMessages.ts +12 -6
  99. package/src/validators.ts +33 -47
@@ -5,10 +5,12 @@ import type { MessageDoc, ThreadDoc } from "../component/schema.js";
5
5
  import { type VectorDimension } from "../component/vector/tables.js";
6
6
  import { type AIMessageWithoutId } from "../mapping.js";
7
7
  import { extractText, isTool } from "../shared.js";
8
- import { type MessageWithMetadata as InnerMessageWithMetadata, type MessageStatus, type ProviderMetadata, type SearchOptions, type StreamArgs, type Usage } from "../validators.js";
8
+ import { type MessageWithMetadata, type MessageStatus, type ProviderMetadata, type SearchOptions, type StreamArgs, type Usage } from "../validators.js";
9
9
  import { createTool } from "./createTool.js";
10
10
  import { type StreamingOptions } from "./streaming.js";
11
- import type { AgentComponent, ContextOptions, GenerationOutputMetadata, OpaqueIds, Options, OurObjectArgs, OurStreamObjectArgs, RunActionCtx, RunMutationCtx, RunQueryCtx, StorageOptions, StreamingTextArgs, SyncStreamsReturnValue, TextArgs, Thread, UsageHandler } from "./types.js";
11
+ import type { AgentComponent, ContextOptions, GenerationOutputMetadata, Options, OurObjectArgs, OurStreamObjectArgs, RawRequestResponseHandler, RunActionCtx, RunMutationCtx, RunQueryCtx, ActionCtx, StorageOptions, StreamingTextArgs, SyncStreamsReturnValue, TextArgs, Thread, UsageHandler } from "./types.js";
12
+ export { storeFile, getFile } from "./files.js";
13
+ export { serializeDataOrUrl } from "../mapping.js";
12
14
  export { vMessageDoc, vThreadDoc } from "../component/schema.js";
13
15
  export { vAssistantMessage, vContextOptions, vMessage, vPaginationResult, vProviderMetadata, vStorageOptions, vStreamArgs, vSystemMessage, vToolMessage, vUsage, vUserMessage, } from "../validators.js";
14
16
  export type { ToolCtx } from "./createTool.js";
@@ -78,6 +80,11 @@ export declare class Agent<AgentTools extends ToolSet> {
78
80
  * The usage handler to use for this agent.
79
81
  */
80
82
  usageHandler?: UsageHandler;
83
+ /**
84
+ * Called for each LLM request/response, so you can do things like
85
+ * log the raw request body or response headers to a table, or logs.
86
+ */
87
+ rawRequestResponseHandler?: RawRequestResponseHandler;
81
88
  };
82
89
  constructor(component: AgentComponent, options: {
83
90
  /**
@@ -141,6 +148,11 @@ export declare class Agent<AgentTools extends ToolSet> {
141
148
  * The usage handler to use for this agent.
142
149
  */
143
150
  usageHandler?: UsageHandler;
151
+ /**
152
+ * Called for each LLM request/response, so you can do things like
153
+ * log the raw request body or response headers to a table, or logs.
154
+ */
155
+ rawRequestResponseHandler?: RawRequestResponseHandler;
144
156
  });
145
157
  /**
146
158
  * Start a new thread with the agent. This will have a fresh history, though if
@@ -224,7 +236,7 @@ export declare class Agent<AgentTools extends ToolSet> {
224
236
  * @param { threadId, userId }: the thread and user to associate the messages with.
225
237
  * @returns Functions bound to the userId and threadId on a `{thread}` object.
226
238
  */
227
- continueThread<ThreadTools extends ToolSet | undefined = undefined>(ctx: RunActionCtx, args: {
239
+ continueThread<ThreadTools extends ToolSet | undefined = undefined>(ctx: ActionCtx, args: {
228
240
  /**
229
241
  * The associated thread created by {@link createThread}
230
242
  */
@@ -248,93 +260,116 @@ export declare class Agent<AgentTools extends ToolSet> {
248
260
  thread: Thread<ThreadTools extends undefined ? AgentTools : ThreadTools>;
249
261
  }>;
250
262
  /**
251
- * Get the metadata for a thread.
252
- * @param ctx A ctx object from a query, mutation, or action.
253
- * @param args.threadId The thread to get the metadata for.
254
- * @returns The metadata for the thread.
263
+ * This behaves like {@link generateText} from the "ai" package except that
264
+ * it add context based on the userId and threadId and saves the input and
265
+ * resulting messages to the thread, if specified.
266
+ * Use {@link continueThread} to get a version of this function already scoped
267
+ * to a thread (and optionally userId).
268
+ * @param ctx The context passed from the action function calling this.
269
+ * @param { userId, threadId }: The user and thread to associate the message with
270
+ * @param args The arguments to the generateText function, along with extra controls
271
+ * for the {@link ContextOptions} and {@link StorageOptions}.
272
+ * @returns The result of the generateText function.
255
273
  */
256
- getThreadMetadata(ctx: RunQueryCtx, args: {
257
- threadId: string;
258
- }): Promise<ThreadDoc>;
274
+ generateText<TOOLS extends ToolSet | undefined = undefined, OUTPUT = never, OUTPUT_PARTIAL = never>(ctx: ActionCtx, { userId: argsUserId, threadId, usageHandler, tools: threadTools, }: {
275
+ userId?: string;
276
+ threadId?: string;
277
+ /**
278
+ * The usage handler to use for this thread. Overrides any handler
279
+ * set in the agent constructor.
280
+ */
281
+ usageHandler?: UsageHandler;
282
+ /** @deprecated Pass `tools` in the next parameter instead. This is only intended to pass through thread-default tools. */
283
+ tools?: ToolSet;
284
+ }, args: TextArgs<AgentTools, TOOLS, OUTPUT, OUTPUT_PARTIAL>, options?: Options): Promise<GenerateTextResult<TOOLS extends undefined ? AgentTools : TOOLS, OUTPUT> & GenerationOutputMetadata>;
259
285
  /**
260
- * Update the metadata for a thread.
261
- * @param ctx A ctx object from a mutation or action.
262
- * @param args.threadId The thread to update the metadata for.
263
- * @param args.patch The patch to apply to the thread.
264
- * @returns The updated thread metadata.
286
+ * This behaves like {@link streamText} from the "ai" package except that
287
+ * it add context based on the userId and threadId and saves the input and
288
+ * resulting messages to the thread, if specified.
289
+ * Use {@link continueThread} to get a version of this function already scoped
290
+ * to a thread (and optionally userId).
265
291
  */
266
- updateThreadMetadata(ctx: RunMutationCtx, args: {
267
- threadId: string;
268
- patch: Partial<WithoutSystemFields<ThreadDoc>>;
269
- }): Promise<ThreadDoc>;
292
+ streamText<TOOLS extends ToolSet | undefined = undefined, OUTPUT = never, PARTIAL_OUTPUT = never>(ctx: ActionCtx, { userId: argsUserId, threadId, usageHandler,
270
293
  /**
271
- * List messages from a thread.
272
- * @param ctx A ctx object from a query, mutation, or action.
273
- * @param args.threadId The thread to list messages from.
274
- * @param args.paginationOpts Pagination options (e.g. via usePaginatedQuery).
275
- * @param args.excludeToolMessages Whether to exclude tool messages.
276
- * False by default.
277
- * @param args.statuses What statuses to include. All by default.
278
- * @returns The MessageDoc's in a format compatible with usePaginatedQuery.
294
+ * @deprecated Pass `tools` in the next parameter instead.
295
+ * This is only intended to pass through thread-default tools.
279
296
  */
280
- listMessages(ctx: RunQueryCtx, args: {
281
- threadId: string;
282
- paginationOpts: PaginationOptions;
283
- excludeToolMessages?: boolean;
284
- statuses?: MessageStatus[];
285
- }): Promise<PaginationResult<MessageDoc>>;
297
+ tools: threadTools, }: {
298
+ userId?: string;
299
+ threadId?: string;
300
+ usageHandler?: UsageHandler;
301
+ tools?: ToolSet;
302
+ },
286
303
  /**
287
- * A function that handles fetching stream deltas, used with the React hooks
288
- * `useThreadMessages` or `useStreamingThreadMessages`.
289
- * @param ctx A ctx object from a query, mutation, or action.
290
- * @param args.threadId The thread to sync streams for.
291
- * @param args.streamArgs The stream arguments with per-stream cursors.
292
- * @returns The deltas for each stream from their existing cursor.
304
+ * The arguments to the streamText function, similar to the ai `streamText` function.
293
305
  */
294
- syncStreams(ctx: RunQueryCtx, args: {
295
- threadId: string;
296
- streamArgs: StreamArgs | undefined;
297
- }): Promise<SyncStreamsReturnValue | undefined>;
306
+ args: StreamingTextArgs<AgentTools, TOOLS, OUTPUT, PARTIAL_OUTPUT>,
298
307
  /**
299
- * Fetch the context messages for a thread.
300
- * @param ctx Either a query, mutation, or action ctx.
301
- * If it is not an action context, you can't do text or
302
- * vector search.
303
- * @param args The associated thread, user, message
304
- * @returns
308
+ * The {@link ContextOptions} and {@link StorageOptions}
309
+ * options to use for fetching contextual messages and saving input/output messages.
305
310
  */
306
- fetchContextMessages(ctx: RunQueryCtx | RunActionCtx, args: {
307
- userId: string | undefined;
308
- threadId: string | undefined;
309
- messages: CoreMessage[];
311
+ options?: Options & {
310
312
  /**
311
- * If provided, it will search for messages up to and including this message.
312
- * Note: if this is far in the past, text and vector search results may be more
313
- * limited, as it's post-filtering the results.
313
+ * Whether to save incremental data (deltas) from streaming responses.
314
+ * Defaults to false.
315
+ * If false, it will not save any deltas to the database.
316
+ * If true, it will save deltas with {@link DEFAULT_STREAMING_OPTIONS}.
317
+ *
318
+ * Regardless of this option, when streaming you are able to use this
319
+ * `streamText` function as you would with the "ai" package's version:
320
+ * iterating over the text, streaming it over HTTP, etc.
314
321
  */
315
- upToAndIncludingMessageId?: string;
316
- contextOptions: ContextOptions | undefined;
317
- }): Promise<MessageDoc[]>;
322
+ saveStreamDeltas?: boolean | StreamingOptions;
323
+ }): Promise<StreamTextResult<TOOLS extends undefined ? AgentTools : TOOLS, PARTIAL_OUTPUT> & GenerationOutputMetadata>;
318
324
  /**
319
- * Get the embeddings for a set of messages.
320
- * @param messages The messages to get the embeddings for.
321
- * @returns The embeddings for the messages.
325
+ * This behaves like {@link generateObject} from the "ai" package except that
326
+ * it add context based on the userId and threadId and saves the input and
327
+ * resulting messages to the thread, if specified.
328
+ * Use {@link continueThread} to get a version of this function already scoped
329
+ * to a thread (and optionally userId).
322
330
  */
323
- generateEmbeddings(messages: CoreMessage[]): Promise<{
324
- vectors: (number[] | null)[];
325
- dimension: VectorDimension;
326
- model: string;
327
- } | undefined>;
331
+ generateObject<T>(ctx: RunActionCtx, { userId: argsUserId, threadId, usageHandler, }: {
332
+ userId?: string;
333
+ threadId?: string;
334
+ usageHandler?: UsageHandler;
335
+ },
328
336
  /**
329
- * Generate embeddings for a set of messages, and save them to the database.
330
- * It will not generate or save embeddings for messages that already have an
331
- * embedding.
332
- * @param ctx The ctx parameter to an action.
333
- * @param args The messageIds to generate embeddings for.
337
+ * The arguments to the generateObject function, similar to the ai.generateObject function.
338
+ */
339
+ args: OurObjectArgs<T>,
340
+ /**
341
+ * The {@link ContextOptions} and {@link StorageOptions}
342
+ * options to use for fetching contextual messages and saving input/output messages.
343
+ */
344
+ options?: Options): Promise<GenerateObjectResult<T> & GenerationOutputMetadata>;
345
+ /**
346
+ * This behaves like `streamObject` from the "ai" package except that
347
+ * it add context based on the userId and threadId and saves the input and
348
+ * resulting messages to the thread, if specified.
349
+ * Use {@link continueThread} to get a version of this function already scoped
350
+ * to a thread (and optionally userId).
351
+ */
352
+ streamObject<T>(ctx: RunActionCtx, { userId: argsUserId, threadId, usageHandler, }: {
353
+ userId?: string;
354
+ threadId?: string;
355
+ usageHandler?: UsageHandler;
356
+ },
357
+ /**
358
+ * The arguments to the streamObject function, similar to the ai `streamObject` function.
359
+ */
360
+ args: OurStreamObjectArgs<T>,
361
+ /**
362
+ * The {@link ContextOptions} and {@link StorageOptions}
363
+ * options to use for fetching contextual messages and saving input/output messages.
364
+ */
365
+ options?: Options): Promise<StreamObjectResult<DeepPartial<T>, T, never> & GenerationOutputMetadata>;
366
+ /**
367
+ * Save a message to the thread.
368
+ * @param ctx A ctx object from a mutation or action.
369
+ * @param args The message and what to associate it with (user / thread)
370
+ * You can pass extra metadata alongside the message, e.g. associated fileIds.
371
+ * @returns The messageId of the saved message.
334
372
  */
335
- generateAndSaveEmbeddings(ctx: RunActionCtx, args: {
336
- messageIds: string[];
337
- }): Promise<void>;
338
373
  saveMessage(ctx: RunMutationCtx, args: {
339
374
  threadId: string;
340
375
  userId?: string;
@@ -361,116 +396,18 @@ export declare class Agent<AgentTools extends ToolSet> {
361
396
  message?: undefined;
362
397
  })): Promise<{
363
398
  messageId: string;
364
- }>;
365
- /**
366
- * Explicitly save messages associated with the thread (& user if provided)
367
- * @param ctx The ctx parameter to a mutation or action.
368
- * @param args The messages and context to save
369
- * @returns
370
- */
371
- saveMessages(ctx: RunMutationCtx, args: {
372
- threadId: string;
373
- userId?: string;
374
- /**
375
- * The message that these messages are in response to. They will be
376
- * the same "order" as this message, at increasing stepOrder(s).
377
- */
378
- promptMessageId?: string;
379
- /**
380
- * The messages to save.
381
- */
382
- messages: CoreMessageMaybeWithId[];
383
- /**
384
- * Metadata to save with the messages. Each element corresponds to the
385
- * message at the same index.
386
- */
387
- metadata?: Omit<MessageWithMetadata, "message">[];
388
- /**
389
- * If false, it will "commit" the messages immediately.
390
- * If true, it will mark them as pending until the final step has finished.
391
- * Defaults to false.
392
- */
393
- pending?: boolean;
394
- /**
395
- * If true, it will fail any pending steps.
396
- * Defaults to false.
397
- */
398
- failPendingSteps?: boolean;
399
- /**
400
- * Skip generating embeddings for the messages. Useful if you're
401
- * saving messages in a mutation where you can't run `fetch`.
402
- * You can generate them asynchronously by using the scheduler to run an
403
- * action later that calls `agent.generateAndSaveEmbeddings`.
404
- */
405
- skipEmbeddings?: boolean;
406
- }): Promise<{
407
- lastMessageId: string;
408
- messages: MessageDoc[];
409
- }>;
410
- /**
411
- * Save messages to the thread.
412
- * Useful as a step in Workflows, e.g.
413
- * ```ts
414
- * const saveMessages = agent.asSaveMessagesMutation();
415
- *
416
- * const myWorkflow = workflow.define()
417
- * ```
418
- * @returns A mutation that can be used to save messages to the thread.
419
- */
420
- asSaveMessagesMutation(): import("convex/server").RegisteredMutation<"internal", {
421
- userId?: string | undefined;
422
- pending?: boolean | undefined;
423
- promptMessageId?: string | undefined;
424
- failPendingSteps?: boolean | undefined;
425
- threadId: string;
426
- messages: {
399
+ message: {
427
400
  id?: string | undefined;
401
+ userId?: string | undefined;
402
+ embeddingId?: string | undefined;
403
+ fileIds?: string[] | undefined;
404
+ files?: any[] | undefined;
428
405
  error?: string | undefined;
406
+ agentName?: string | undefined;
429
407
  model?: string | undefined;
430
408
  provider?: string | undefined;
431
- text?: string | undefined;
432
- reasoning?: string | undefined;
433
- files?: {
434
- data?: string | ArrayBuffer | undefined;
435
- url?: string | undefined;
436
- fileId?: import("convex/values").GenericId<"files"> | undefined;
437
- mimeType: string;
438
- }[] | undefined;
439
- usage?: {
440
- promptTokens: number;
441
- completionTokens: number;
442
- totalTokens: number;
443
- } | undefined;
444
- providerMetadata?: Record<string, Record<string, any>> | undefined;
445
- sources?: {
446
- title?: string | undefined;
447
- providerOptions?: Record<string, Record<string, any>> | undefined;
448
- id: string;
449
- url: string;
450
- sourceType: "url";
451
- }[] | undefined;
452
- reasoningDetails?: ({
453
- signature?: string | undefined;
454
- type: "text";
455
- text: string;
456
- } | {
457
- type: "redacted";
458
- data: string;
459
- })[] | undefined;
460
- warnings?: ({
461
- details?: string | undefined;
462
- type: "unsupported-setting";
463
- setting: string;
464
- } | {
465
- details?: string | undefined;
466
- type: "unsupported-tool";
467
- tool: any;
468
- } | {
469
- type: "other";
470
- message: string;
471
- })[] | undefined;
472
- finishReason?: "length" | "error" | "other" | "stop" | "content-filter" | "tool-calls" | "unknown" | undefined;
473
- message: {
409
+ providerOptions?: Record<string, Record<string, any>> | undefined;
410
+ message?: {
474
411
  providerOptions?: Record<string, Record<string, any>> | undefined;
475
412
  role: "user";
476
413
  content: string | ({
@@ -542,18 +479,194 @@ export declare class Agent<AgentTools extends ToolSet> {
542
479
  providerOptions?: Record<string, Record<string, any>> | undefined;
543
480
  role: "system";
544
481
  content: string;
545
- };
546
- }[];
547
- }, Promise<{
482
+ } | undefined;
483
+ text?: string | undefined;
484
+ reasoning?: string | undefined;
485
+ usage?: {
486
+ promptTokens: number;
487
+ completionTokens: number;
488
+ totalTokens: number;
489
+ } | undefined;
490
+ providerMetadata?: Record<string, Record<string, any>> | undefined;
491
+ sources?: {
492
+ title?: string | undefined;
493
+ providerOptions?: Record<string, Record<string, any>> | undefined;
494
+ id: string;
495
+ sourceType: "url";
496
+ url: string;
497
+ }[] | undefined;
498
+ reasoningDetails?: ({
499
+ signature?: string | undefined;
500
+ type: "text";
501
+ text: string;
502
+ } | {
503
+ type: "redacted";
504
+ data: string;
505
+ })[] | undefined;
506
+ warnings?: ({
507
+ details?: string | undefined;
508
+ type: "unsupported-setting";
509
+ setting: string;
510
+ } | {
511
+ details?: string | undefined;
512
+ type: "unsupported-tool";
513
+ tool: any;
514
+ } | {
515
+ type: "other";
516
+ message: string;
517
+ })[] | undefined;
518
+ finishReason?: "length" | "error" | "other" | "stop" | "content-filter" | "tool-calls" | "unknown" | undefined;
519
+ _id: string;
520
+ _creationTime: number;
521
+ status: "pending" | "success" | "failed";
522
+ order: number;
523
+ threadId: string;
524
+ stepOrder: number;
525
+ tool: boolean;
526
+ };
527
+ }>;
528
+ /**
529
+ * Explicitly save messages associated with the thread (& user if provided)
530
+ * @param ctx The ctx parameter to a mutation or action.
531
+ * @param args The messages and context to save
532
+ * @returns
533
+ */
534
+ saveMessages(ctx: RunMutationCtx | RunActionCtx, args: {
535
+ threadId: string;
536
+ userId?: string;
537
+ /**
538
+ * The message that these messages are in response to. They will be
539
+ * the same "order" as this message, at increasing stepOrder(s).
540
+ */
541
+ promptMessageId?: string;
542
+ /**
543
+ * The messages to save.
544
+ */
545
+ messages: CoreMessageMaybeWithId[];
546
+ /**
547
+ * Metadata to save with the messages. Each element corresponds to the
548
+ * message at the same index.
549
+ */
550
+ metadata?: Omit<MessageWithMetadata, "message">[];
551
+ /**
552
+ * If false, it will "commit" the messages immediately.
553
+ * If true, it will mark them as pending until the final step has finished.
554
+ * Defaults to false.
555
+ */
556
+ pending?: boolean;
557
+ /**
558
+ * If true, it will fail any pending steps.
559
+ * Defaults to false.
560
+ */
561
+ failPendingSteps?: boolean;
562
+ /**
563
+ * Skip generating embeddings for the messages. Useful if you're
564
+ * saving messages in a mutation where you can't run `fetch`.
565
+ * You can generate them asynchronously by using the scheduler to run an
566
+ * action later that calls `agent.generateAndSaveEmbeddings`.
567
+ */
568
+ skipEmbeddings?: boolean;
569
+ }): Promise<{
548
570
  lastMessageId: string;
571
+ messages: MessageDoc[];
572
+ }>;
573
+ /**
574
+ * List messages from a thread.
575
+ * @param ctx A ctx object from a query, mutation, or action.
576
+ * @param args.threadId The thread to list messages from.
577
+ * @param args.paginationOpts Pagination options (e.g. via usePaginatedQuery).
578
+ * @param args.excludeToolMessages Whether to exclude tool messages.
579
+ * False by default.
580
+ * @param args.statuses What statuses to include. All by default.
581
+ * @returns The MessageDoc's in a format compatible with usePaginatedQuery.
582
+ */
583
+ listMessages(ctx: RunQueryCtx, args: {
584
+ threadId: string;
585
+ paginationOpts: PaginationOptions;
586
+ excludeToolMessages?: boolean;
587
+ statuses?: MessageStatus[];
588
+ }): Promise<PaginationResult<MessageDoc>>;
589
+ /**
590
+ * A function that handles fetching stream deltas, used with the React hooks
591
+ * `useThreadMessages` or `useStreamingThreadMessages`.
592
+ * @param ctx A ctx object from a query, mutation, or action.
593
+ * @param args.threadId The thread to sync streams for.
594
+ * @param args.streamArgs The stream arguments with per-stream cursors.
595
+ * @returns The deltas for each stream from their existing cursor.
596
+ */
597
+ syncStreams(ctx: RunQueryCtx, args: {
598
+ threadId: string;
599
+ streamArgs: StreamArgs | undefined;
600
+ }): Promise<SyncStreamsReturnValue | undefined>;
601
+ /**
602
+ * Fetch the context messages for a thread.
603
+ * @param ctx Either a query, mutation, or action ctx.
604
+ * If it is not an action context, you can't do text or
605
+ * vector search.
606
+ * @param args The associated thread, user, message
607
+ * @returns
608
+ */
609
+ fetchContextMessages(ctx: RunQueryCtx | RunActionCtx, args: {
610
+ userId: string | undefined;
611
+ threadId: string | undefined;
612
+ messages: CoreMessage[];
613
+ /**
614
+ * If provided, it will search for messages up to and including this message.
615
+ * Note: if this is far in the past, text and vector search results may be more
616
+ * limited, as it's post-filtering the results.
617
+ */
618
+ upToAndIncludingMessageId?: string;
619
+ contextOptions: ContextOptions | undefined;
620
+ }): Promise<MessageDoc[]>;
621
+ /**
622
+ * Get the metadata for a thread.
623
+ * @param ctx A ctx object from a query, mutation, or action.
624
+ * @param args.threadId The thread to get the metadata for.
625
+ * @returns The metadata for the thread.
626
+ */
627
+ getThreadMetadata(ctx: RunQueryCtx, args: {
628
+ threadId: string;
629
+ }): Promise<ThreadDoc>;
630
+ /**
631
+ * Update the metadata for a thread.
632
+ * @param ctx A ctx object from a mutation or action.
633
+ * @param args.threadId The thread to update the metadata for.
634
+ * @param args.patch The patch to apply to the thread.
635
+ * @returns The updated thread metadata.
636
+ */
637
+ updateThreadMetadata(ctx: RunMutationCtx, args: {
638
+ threadId: string;
639
+ patch: Partial<WithoutSystemFields<ThreadDoc>>;
640
+ }): Promise<ThreadDoc>;
641
+ /**
642
+ * Get the embeddings for a set of messages.
643
+ * @param messages The messages to get the embeddings for.
644
+ * @returns The embeddings for the messages.
645
+ */
646
+ generateEmbeddings(ctx: RunActionCtx, { userId, threadId, }: {
647
+ userId: string | undefined;
648
+ threadId: string | undefined;
649
+ }, messages: CoreMessage[]): Promise<{
650
+ vectors: (number[] | null)[];
651
+ dimension: VectorDimension;
652
+ model: string;
653
+ } | undefined>;
654
+ /**
655
+ * Generate embeddings for a set of messages, and save them to the database.
656
+ * It will not generate or save embeddings for messages that already have an
657
+ * embedding.
658
+ * @param ctx The ctx parameter to an action.
659
+ * @param args The messageIds to generate embeddings for.
660
+ */
661
+ generateAndSaveEmbeddings(ctx: RunActionCtx, args: {
549
662
  messageIds: string[];
550
- }>>;
663
+ }): Promise<void>;
551
664
  /**
552
665
  * Explicitly save a "step" created by the AI SDK.
553
666
  * @param ctx The ctx argument to a mutation or action.
554
667
  * @param args The Step generated by the AI SDK.
555
668
  */
556
- saveStep<TOOLS extends ToolSet>(ctx: RunMutationCtx, args: {
669
+ saveStep<TOOLS extends ToolSet>(ctx: ActionCtx, args: {
557
670
  userId?: string;
558
671
  threadId: string;
559
672
  /**
@@ -574,7 +687,24 @@ export declare class Agent<AgentTools extends ToolSet> {
574
687
  * Defaults to the chat provider for the Agent.
575
688
  */
576
689
  provider?: string;
577
- }): Promise<MessageDoc[]>;
690
+ }): Promise<{
691
+ messages: MessageDoc[];
692
+ pending?: MessageDoc;
693
+ }>;
694
+ /**
695
+ * Manually save the result of a generateObject call to the thread.
696
+ * This happens automatically when using {@link generateObject} or {@link streamObject}
697
+ * from the `thread` object created by {@link continueThread} or {@link createThread}.
698
+ * @param ctx The context passed from the mutation or action function calling this.
699
+ * @param args The arguments to the saveObject function.
700
+ */
701
+ saveObject(ctx: RunActionCtx, args: {
702
+ userId: string | undefined;
703
+ threadId: string;
704
+ promptMessageId: string;
705
+ result: GenerateObjectResult<unknown>;
706
+ metadata?: Omit<MessageWithMetadata, "message">;
707
+ }): Promise<void>;
578
708
  /**
579
709
  * Commit or rollback a message that was pending.
580
710
  * This is done automatically when saving messages by default.
@@ -593,68 +723,6 @@ export declare class Agent<AgentTools extends ToolSet> {
593
723
  kind: "success";
594
724
  };
595
725
  }): Promise<void>;
596
- /**
597
- * This behaves like {@link generateText} from the "ai" package except that
598
- * it add context based on the userId and threadId and saves the input and
599
- * resulting messages to the thread, if specified.
600
- * Use {@link continueThread} to get a version of this function already scoped
601
- * to a thread (and optionally userId).
602
- * @param ctx The context passed from the action function calling this.
603
- * @param { userId, threadId }: The user and thread to associate the message with
604
- * @param args The arguments to the generateText function, along with extra controls
605
- * for the {@link ContextOptions} and {@link StorageOptions}.
606
- * @returns The result of the generateText function.
607
- */
608
- generateText<TOOLS extends ToolSet | undefined = undefined, OUTPUT = never, OUTPUT_PARTIAL = never>(ctx: RunActionCtx, { userId: argsUserId, threadId, usageHandler, tools: threadTools, }: {
609
- userId?: string;
610
- threadId?: string;
611
- /**
612
- * The usage handler to use for this thread. Overrides any handler
613
- * set in the agent constructor.
614
- */
615
- usageHandler?: UsageHandler;
616
- /** @deprecated Pass `tools` in the next parameter instead. This is only intended to pass through thread-default tools. */
617
- tools?: ToolSet;
618
- }, args: TextArgs<AgentTools, TOOLS, OUTPUT, OUTPUT_PARTIAL>, options?: Options): Promise<GenerateTextResult<TOOLS extends undefined ? AgentTools : TOOLS, OUTPUT> & GenerationOutputMetadata>;
619
- /**
620
- * This behaves like {@link streamText} from the "ai" package except that
621
- * it add context based on the userId and threadId and saves the input and
622
- * resulting messages to the thread, if specified.
623
- * Use {@link continueThread} to get a version of this function already scoped
624
- * to a thread (and optionally userId).
625
- */
626
- streamText<TOOLS extends ToolSet | undefined = undefined, OUTPUT = never, PARTIAL_OUTPUT = never>(ctx: RunActionCtx, { userId: argsUserId, threadId, usageHandler,
627
- /**
628
- * @deprecated Pass `tools` in the next parameter instead.
629
- * This is only intended to pass through thread-default tools.
630
- */
631
- tools: threadTools, }: {
632
- userId?: string;
633
- threadId?: string;
634
- usageHandler?: UsageHandler;
635
- tools?: ToolSet;
636
- },
637
- /**
638
- * The arguments to the streamText function, similar to the ai `streamText` function.
639
- */
640
- args: StreamingTextArgs<AgentTools, TOOLS, OUTPUT, PARTIAL_OUTPUT>,
641
- /**
642
- * The {@link ContextOptions} and {@link StorageOptions}
643
- * options to use for fetching contextual messages and saving input/output messages.
644
- */
645
- options?: Options & {
646
- /**
647
- * Whether to save incremental data (deltas) from streaming responses.
648
- * Defaults to false.
649
- * If false, it will not save any deltas to the database.
650
- * If true, it will save deltas with {@link DEFAULT_STREAMING_OPTIONS}.
651
- *
652
- * Regardless of this option, when streaming you are able to use this
653
- * `streamText` function as you would with the "ai" package's version:
654
- * iterating over the text, streaming it over HTTP, etc.
655
- */
656
- saveStreamDeltas?: boolean | StreamingOptions;
657
- }): Promise<StreamTextResult<TOOLS extends undefined ? AgentTools : TOOLS, PARTIAL_OUTPUT> & GenerationOutputMetadata>;
658
726
  _saveMessagesAndFetchContext<T extends {
659
727
  id?: string;
660
728
  prompt?: string;
@@ -675,64 +743,24 @@ export declare class Agent<AgentTools extends ToolSet> {
675
743
  order: number | undefined;
676
744
  stepOrder: number | undefined;
677
745
  }>;
678
- /**
679
- * This behaves like {@link generateObject} from the "ai" package except that
680
- * it add context based on the userId and threadId and saves the input and
681
- * resulting messages to the thread, if specified.
682
- * Use {@link continueThread} to get a version of this function already scoped
683
- * to a thread (and optionally userId).
684
- */
685
- generateObject<T>(ctx: RunActionCtx, { userId: argsUserId, threadId, usageHandler, }: {
686
- userId?: string;
687
- threadId?: string;
688
- usageHandler?: UsageHandler;
689
- },
690
- /**
691
- * The arguments to the generateObject function, similar to the ai.generateObject function.
692
- */
693
- args: OurObjectArgs<T>,
694
- /**
695
- * The {@link ContextOptions} and {@link StorageOptions}
696
- * options to use for fetching contextual messages and saving input/output messages.
697
- */
698
- options?: Options): Promise<GenerateObjectResult<T> & GenerationOutputMetadata>;
699
- /**
700
- * This behaves like `streamObject` from the "ai" package except that
701
- * it add context based on the userId and threadId and saves the input and
702
- * resulting messages to the thread, if specified.
703
- * Use {@link continueThread} to get a version of this function already scoped
704
- * to a thread (and optionally userId).
705
- */
706
- streamObject<T>(ctx: RunActionCtx, { userId: argsUserId, threadId, usageHandler, }: {
746
+ _shouldSaveOutputMessages(storageOpts?: StorageOptions): boolean;
747
+ _mergedContextOptions(opts: ContextOptions | undefined): ContextOptions;
748
+ _searchOptionsWithEmbeddingAndDefaults(ctx: RunActionCtx, { userId, threadId }: {
707
749
  userId?: string;
708
750
  threadId?: string;
709
- usageHandler?: UsageHandler;
710
- },
711
- /**
712
- * The arguments to the streamObject function, similar to the ai `streamObject` function.
713
- */
714
- args: OurStreamObjectArgs<T>,
715
- /**
716
- * The {@link ContextOptions} and {@link StorageOptions}
717
- * options to use for fetching contextual messages and saving input/output messages.
718
- */
719
- options?: Options): Promise<StreamObjectResult<DeepPartial<T>, T, never> & GenerationOutputMetadata>;
751
+ }, contextOptions: ContextOptions, messages: CoreMessage[]): Promise<SearchOptions>;
752
+ doEmbed(ctx: RunActionCtx, options: {
753
+ userId: string | undefined;
754
+ threadId: string | undefined;
755
+ values: string[];
756
+ abortSignal?: AbortSignal;
757
+ headers?: Record<string, string | undefined>;
758
+ }): Promise<{
759
+ embeddings: number[][];
760
+ }>;
720
761
  /**
721
- * Manually save the result of a generateObject call to the thread.
722
- * This happens automatically when using {@link generateObject} or {@link streamObject}
723
- * from the `thread` object created by {@link continueThread} or {@link createThread}.
724
- * @param ctx The context passed from the mutation or action function calling this.
725
- * @param args The arguments to the saveObject function.
762
+ * WORKFLOW UTILITIES
726
763
  */
727
- saveObject(ctx: RunMutationCtx, args: {
728
- userId: string | undefined;
729
- threadId: string;
730
- promptMessageId: string;
731
- result: GenerateObjectResult<unknown>;
732
- metadata?: Omit<MessageWithMetadata, "message">;
733
- }): Promise<void>;
734
- _mergedContextOptions(opts: ContextOptions | undefined): ContextOptions;
735
- _searchOptionsWithDefaults(contextOptions: ContextOptions, messages: CoreMessage[]): Promise<SearchOptions>;
736
764
  /**
737
765
  * Create a mutation that creates a thread so you can call it from a Workflow.
738
766
  * e.g.
@@ -877,7 +905,7 @@ export declare class Agent<AgentTools extends ToolSet> {
877
905
  seed?: number | undefined;
878
906
  maxRetries?: number | undefined;
879
907
  stream?: boolean | undefined;
880
- toolChoice?: "required" | "auto" | "none" | {
908
+ toolChoice?: "required" | "none" | "auto" | {
881
909
  type: "tool";
882
910
  toolName: string;
883
911
  } | undefined;
@@ -900,9 +928,10 @@ export declare class Agent<AgentTools extends ToolSet> {
900
928
  searchOtherThreads?: boolean | undefined;
901
929
  } | undefined;
902
930
  storageOptions?: {
903
- saveAllInputMessages?: boolean | undefined;
904
- saveAnyInputMessages?: boolean | undefined;
905
- saveOutputMessages?: boolean | undefined;
931
+ saveMessages?: "all" | "none" | "promptAndOutput";
932
+ saveAllInputMessages?: boolean;
933
+ saveAnyInputMessages?: boolean;
934
+ saveOutputMessages?: boolean;
906
935
  } | undefined;
907
936
  }, Promise<{
908
937
  text: string;
@@ -1025,18 +1054,167 @@ export declare class Agent<AgentTools extends ToolSet> {
1025
1054
  searchOtherThreads?: boolean | undefined;
1026
1055
  } | undefined;
1027
1056
  storageOptions?: {
1028
- saveAllInputMessages?: boolean | undefined;
1029
- saveAnyInputMessages?: boolean | undefined;
1030
- saveOutputMessages?: boolean | undefined;
1057
+ saveMessages?: "all" | "none" | "promptAndOutput";
1058
+ saveAllInputMessages?: boolean;
1059
+ saveAnyInputMessages?: boolean;
1060
+ saveOutputMessages?: boolean;
1031
1061
  } | undefined;
1032
1062
  }, Promise<{
1033
1063
  object: T;
1034
1064
  }>>;
1065
+ /**
1066
+ * Save messages to the thread.
1067
+ * Useful as a step in Workflows, e.g.
1068
+ * ```ts
1069
+ * const saveMessages = agent.asSaveMessagesMutation();
1070
+ *
1071
+ * const myWorkflow = workflow.define({
1072
+ * args: {...},
1073
+ * handler: async (step, args) => {
1074
+ * // do things to create (but not save)messages
1075
+ * const { messageIds } = await step.runMutation(internal.foo.saveMessages, {
1076
+ * threadId: args.threadId,
1077
+ * messages: args.messages,
1078
+ * });
1079
+ * // ...
1080
+ * },
1081
+ * })
1082
+ * ```
1083
+ * @returns A mutation that can be used to save messages to the thread.
1084
+ */
1085
+ asSaveMessagesMutation(): import("convex/server").RegisteredMutation<"internal", {
1086
+ userId?: string | undefined;
1087
+ pending?: boolean | undefined;
1088
+ promptMessageId?: string | undefined;
1089
+ failPendingSteps?: boolean | undefined;
1090
+ threadId: string;
1091
+ messages: {
1092
+ id?: string | undefined;
1093
+ fileIds?: string[] | undefined;
1094
+ error?: string | undefined;
1095
+ model?: string | undefined;
1096
+ provider?: string | undefined;
1097
+ text?: string | undefined;
1098
+ reasoning?: string | undefined;
1099
+ usage?: {
1100
+ promptTokens: number;
1101
+ completionTokens: number;
1102
+ totalTokens: number;
1103
+ } | undefined;
1104
+ providerMetadata?: Record<string, Record<string, any>> | undefined;
1105
+ sources?: {
1106
+ title?: string | undefined;
1107
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1108
+ id: string;
1109
+ sourceType: "url";
1110
+ url: string;
1111
+ }[] | undefined;
1112
+ reasoningDetails?: ({
1113
+ signature?: string | undefined;
1114
+ type: "text";
1115
+ text: string;
1116
+ } | {
1117
+ type: "redacted";
1118
+ data: string;
1119
+ })[] | undefined;
1120
+ warnings?: ({
1121
+ details?: string | undefined;
1122
+ type: "unsupported-setting";
1123
+ setting: string;
1124
+ } | {
1125
+ details?: string | undefined;
1126
+ type: "unsupported-tool";
1127
+ tool: any;
1128
+ } | {
1129
+ type: "other";
1130
+ message: string;
1131
+ })[] | undefined;
1132
+ finishReason?: "length" | "error" | "other" | "stop" | "content-filter" | "tool-calls" | "unknown" | undefined;
1133
+ message: {
1134
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1135
+ role: "user";
1136
+ content: string | ({
1137
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1138
+ type: "text";
1139
+ text: string;
1140
+ } | {
1141
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1142
+ mimeType?: string | undefined;
1143
+ type: "image";
1144
+ image: string | ArrayBuffer;
1145
+ } | {
1146
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1147
+ filename?: string | undefined;
1148
+ type: "file";
1149
+ mimeType: string;
1150
+ data: string | ArrayBuffer;
1151
+ })[];
1152
+ } | {
1153
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1154
+ role: "assistant";
1155
+ content: string | ({
1156
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1157
+ type: "text";
1158
+ text: string;
1159
+ } | {
1160
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1161
+ filename?: string | undefined;
1162
+ type: "file";
1163
+ mimeType: string;
1164
+ data: string | ArrayBuffer;
1165
+ } | {
1166
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1167
+ signature?: string | undefined;
1168
+ type: "reasoning";
1169
+ text: string;
1170
+ } | {
1171
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1172
+ type: "redacted-reasoning";
1173
+ data: string;
1174
+ } | {
1175
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1176
+ type: "tool-call";
1177
+ toolCallId: string;
1178
+ toolName: string;
1179
+ args: any;
1180
+ })[];
1181
+ } | {
1182
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1183
+ role: "tool";
1184
+ content: {
1185
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1186
+ args?: any;
1187
+ experimental_content?: ({
1188
+ type: "text";
1189
+ text: string;
1190
+ } | {
1191
+ mimeType?: string | undefined;
1192
+ type: "image";
1193
+ data: string;
1194
+ })[] | undefined;
1195
+ isError?: boolean | undefined;
1196
+ type: "tool-result";
1197
+ toolCallId: string;
1198
+ toolName: string;
1199
+ result: any;
1200
+ }[];
1201
+ } | {
1202
+ providerOptions?: Record<string, Record<string, any>> | undefined;
1203
+ role: "system";
1204
+ content: string;
1205
+ };
1206
+ }[];
1207
+ }, Promise<{
1208
+ lastMessageId: string;
1209
+ messageIds: string[];
1210
+ }>>;
1035
1211
  }
1036
1212
  export declare function filterOutOrphanedToolMessages(docs: MessageDoc[]): {
1037
1213
  id?: string | undefined;
1038
1214
  userId?: string | undefined;
1039
1215
  embeddingId?: string | undefined;
1216
+ fileIds?: string[] | undefined;
1217
+ files?: any[] | undefined;
1040
1218
  error?: string | undefined;
1041
1219
  agentName?: string | undefined;
1042
1220
  model?: string | undefined;
@@ -1117,12 +1295,6 @@ export declare function filterOutOrphanedToolMessages(docs: MessageDoc[]): {
1117
1295
  } | undefined;
1118
1296
  text?: string | undefined;
1119
1297
  reasoning?: string | undefined;
1120
- files?: {
1121
- data?: string | ArrayBuffer | undefined;
1122
- url?: string | undefined;
1123
- fileId?: string | undefined;
1124
- mimeType: string;
1125
- }[] | undefined;
1126
1298
  usage?: {
1127
1299
  promptTokens: number;
1128
1300
  completionTokens: number;
@@ -1133,8 +1305,8 @@ export declare function filterOutOrphanedToolMessages(docs: MessageDoc[]): {
1133
1305
  title?: string | undefined;
1134
1306
  providerOptions?: Record<string, Record<string, any>> | undefined;
1135
1307
  id: string;
1136
- url: string;
1137
1308
  sourceType: "url";
1309
+ url: string;
1138
1310
  }[] | undefined;
1139
1311
  reasoningDetails?: ({
1140
1312
  signature?: string | undefined;
@@ -1165,7 +1337,6 @@ export declare function filterOutOrphanedToolMessages(docs: MessageDoc[]): {
1165
1337
  stepOrder: number;
1166
1338
  tool: boolean;
1167
1339
  }[];
1168
- type MessageWithMetadata = OpaqueIds<InnerMessageWithMetadata>;
1169
1340
  type CoreMessageMaybeWithId = CoreMessage & {
1170
1341
  id?: string | undefined;
1171
1342
  };