@convex-dev/agent 0.2.12 → 0.3.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 (102) hide show
  1. package/dist/client/createTool.d.ts.map +1 -1
  2. package/dist/client/createTool.js +0 -2
  3. package/dist/client/createTool.js.map +1 -1
  4. package/dist/client/definePlaygroundAPI.d.ts +10 -10
  5. package/dist/client/files.d.ts +5 -2
  6. package/dist/client/files.d.ts.map +1 -1
  7. package/dist/client/files.js.map +1 -1
  8. package/dist/client/index.d.ts.map +1 -1
  9. package/dist/client/index.js +1 -8
  10. package/dist/client/index.js.map +1 -1
  11. package/dist/client/messages.d.ts +2 -2
  12. package/dist/client/messages.d.ts.map +1 -1
  13. package/dist/client/messages.js.map +1 -1
  14. package/dist/client/saveInputMessages.d.ts.map +1 -1
  15. package/dist/client/saveInputMessages.js +1 -0
  16. package/dist/client/saveInputMessages.js.map +1 -1
  17. package/dist/client/search.d.ts +1 -1
  18. package/dist/client/search.d.ts.map +1 -1
  19. package/dist/client/start.d.ts.map +1 -1
  20. package/dist/client/start.js.map +1 -1
  21. package/dist/client/streaming.d.ts +3 -3
  22. package/dist/client/streaming.d.ts.map +1 -1
  23. package/dist/client/streaming.js.map +1 -1
  24. package/dist/client/threads.d.ts +6 -6
  25. package/dist/client/threads.d.ts.map +1 -1
  26. package/dist/client/threads.js.map +1 -1
  27. package/dist/client/types.d.ts +6 -25
  28. package/dist/client/types.d.ts.map +1 -1
  29. package/dist/component/_generated/api.d.ts +24 -2563
  30. package/dist/component/_generated/api.d.ts.map +1 -1
  31. package/dist/component/_generated/api.js +10 -1
  32. package/dist/component/_generated/api.js.map +1 -1
  33. package/dist/component/_generated/component.d.ts +2276 -0
  34. package/dist/component/_generated/component.d.ts.map +1 -0
  35. package/dist/component/_generated/component.js +11 -0
  36. package/dist/component/_generated/component.js.map +1 -0
  37. package/dist/component/_generated/dataModel.d.ts +4 -18
  38. package/dist/component/_generated/dataModel.d.ts.map +1 -0
  39. package/dist/component/_generated/dataModel.js +11 -0
  40. package/dist/component/_generated/dataModel.js.map +1 -0
  41. package/dist/component/_generated/server.d.ts +10 -38
  42. package/dist/component/_generated/server.d.ts.map +1 -1
  43. package/dist/component/_generated/server.js +9 -5
  44. package/dist/component/_generated/server.js.map +1 -1
  45. package/dist/component/messages.d.ts +59 -3
  46. package/dist/component/messages.d.ts.map +1 -1
  47. package/dist/component/messages.js +157 -39
  48. package/dist/component/messages.js.map +1 -1
  49. package/dist/component/streams.d.ts +1 -1
  50. package/dist/component/threads.d.ts +4 -4
  51. package/dist/component/users.d.ts +3 -3
  52. package/dist/component/vector/index.d.ts.map +1 -1
  53. package/dist/component/vector/index.js +1 -3
  54. package/dist/component/vector/index.js.map +1 -1
  55. package/dist/deltas.js +1 -1
  56. package/dist/deltas.js.map +1 -1
  57. package/dist/mapping.d.ts.map +1 -1
  58. package/dist/mapping.js +1 -5
  59. package/dist/mapping.js.map +1 -1
  60. package/dist/react/useDeltaStreams.d.ts.map +1 -1
  61. package/dist/react/useDeltaStreams.js.map +1 -1
  62. package/dist/react/useStreamingUIMessages.d.ts.map +1 -1
  63. package/dist/react/useStreamingUIMessages.js +0 -1
  64. package/dist/react/useStreamingUIMessages.js.map +1 -1
  65. package/dist/react/useThreadMessages.d.ts.map +1 -1
  66. package/dist/react/useThreadMessages.js +1 -2
  67. package/dist/react/useThreadMessages.js.map +1 -1
  68. package/dist/react/useUIMessages.d.ts.map +1 -1
  69. package/dist/react/useUIMessages.js +1 -2
  70. package/dist/react/useUIMessages.js.map +1 -1
  71. package/package.json +29 -31
  72. package/src/client/createTool.ts +0 -2
  73. package/src/client/files.ts +3 -2
  74. package/src/client/index.test.ts +0 -1
  75. package/src/client/index.ts +4 -9
  76. package/src/client/messages.ts +2 -2
  77. package/src/client/saveInputMessages.test.ts +0 -1
  78. package/src/client/saveInputMessages.ts +1 -0
  79. package/src/client/search.test.ts +0 -1
  80. package/src/client/search.ts +1 -1
  81. package/src/client/start.ts +3 -8
  82. package/src/client/streaming.ts +2 -2
  83. package/src/client/threads.ts +2 -2
  84. package/src/client/types.ts +13 -61
  85. package/src/component/_generated/api.ts +64 -0
  86. package/src/component/_generated/component.ts +2922 -0
  87. package/src/component/_generated/{server.d.ts → server.ts} +33 -21
  88. package/src/component/messages.ts +209 -52
  89. package/src/component/vector/index.ts +1 -3
  90. package/src/deltas.ts +1 -1
  91. package/src/mapping.ts +1 -4
  92. package/src/react/useDeltaStreams.ts +0 -1
  93. package/src/react/useStreamingUIMessages.ts +0 -2
  94. package/src/react/useThreadMessages.ts +3 -10
  95. package/src/react/useUIMessages.ts +2 -6
  96. package/src/test.ts +2 -1
  97. package/src/validators.test.ts +14 -7
  98. package/src/component/_generated/api.d.ts +0 -2587
  99. package/src/component/_generated/api.js +0 -23
  100. package/src/component/_generated/server.js +0 -90
  101. package/src/vitest.config.ts +0 -7
  102. /package/src/component/_generated/{dataModel.d.ts → dataModel.ts} +0 -0
@@ -0,0 +1,2922 @@
1
+ /* eslint-disable */
2
+ /**
3
+ * Generated `ComponentApi` utility.
4
+ *
5
+ * THIS CODE IS AUTOMATICALLY GENERATED.
6
+ *
7
+ * To regenerate, run `npx convex dev`.
8
+ * @module
9
+ */
10
+
11
+ import type { FunctionReference } from "convex/server";
12
+
13
+ /**
14
+ * A utility for referencing a Convex component's exposed API.
15
+ *
16
+ * Useful when expecting a parameter like `components.myComponent`.
17
+ * Usage:
18
+ * ```ts
19
+ * async function myFunction(ctx: QueryCtx, component: ComponentApi) {
20
+ * return ctx.runQuery(component.someFile.someQuery, { ...args });
21
+ * }
22
+ * ```
23
+ */
24
+ export type ComponentApi<Name extends string | undefined = string | undefined> =
25
+ {
26
+ apiKeys: {
27
+ destroy: FunctionReference<
28
+ "mutation",
29
+ "internal",
30
+ { apiKey?: string; name?: string },
31
+ | "missing"
32
+ | "deleted"
33
+ | "name mismatch"
34
+ | "must provide either apiKey or name",
35
+ Name
36
+ >;
37
+ issue: FunctionReference<
38
+ "mutation",
39
+ "internal",
40
+ { name?: string },
41
+ string,
42
+ Name
43
+ >;
44
+ validate: FunctionReference<
45
+ "query",
46
+ "internal",
47
+ { apiKey: string },
48
+ boolean,
49
+ Name
50
+ >;
51
+ };
52
+ files: {
53
+ addFile: FunctionReference<
54
+ "mutation",
55
+ "internal",
56
+ {
57
+ filename?: string;
58
+ hash: string;
59
+ mimeType: string;
60
+ storageId: string;
61
+ },
62
+ { fileId: string; storageId: string },
63
+ Name
64
+ >;
65
+ copyFile: FunctionReference<
66
+ "mutation",
67
+ "internal",
68
+ { fileId: string },
69
+ null,
70
+ Name
71
+ >;
72
+ deleteFiles: FunctionReference<
73
+ "mutation",
74
+ "internal",
75
+ { fileIds: Array<string>; force?: boolean },
76
+ Array<string>,
77
+ Name
78
+ >;
79
+ get: FunctionReference<
80
+ "query",
81
+ "internal",
82
+ { fileId: string },
83
+ null | {
84
+ _creationTime: number;
85
+ _id: string;
86
+ filename?: string;
87
+ hash: string;
88
+ lastTouchedAt: number;
89
+ mimeType: string;
90
+ refcount: number;
91
+ storageId: string;
92
+ },
93
+ Name
94
+ >;
95
+ getFilesToDelete: FunctionReference<
96
+ "query",
97
+ "internal",
98
+ {
99
+ paginationOpts: {
100
+ cursor: string | null;
101
+ endCursor?: string | null;
102
+ id?: number;
103
+ maximumBytesRead?: number;
104
+ maximumRowsRead?: number;
105
+ numItems: number;
106
+ };
107
+ },
108
+ {
109
+ continueCursor: string;
110
+ isDone: boolean;
111
+ page: Array<{
112
+ _creationTime: number;
113
+ _id: string;
114
+ filename?: string;
115
+ hash: string;
116
+ lastTouchedAt: number;
117
+ mimeType: string;
118
+ refcount: number;
119
+ storageId: string;
120
+ }>;
121
+ },
122
+ Name
123
+ >;
124
+ useExistingFile: FunctionReference<
125
+ "mutation",
126
+ "internal",
127
+ { filename?: string; hash: string },
128
+ null | { fileId: string; storageId: string },
129
+ Name
130
+ >;
131
+ };
132
+ messages: {
133
+ addMessages: FunctionReference<
134
+ "mutation",
135
+ "internal",
136
+ {
137
+ agentName?: string;
138
+ embeddings?: {
139
+ dimension:
140
+ | 128
141
+ | 256
142
+ | 512
143
+ | 768
144
+ | 1024
145
+ | 1408
146
+ | 1536
147
+ | 2048
148
+ | 3072
149
+ | 4096;
150
+ model: string;
151
+ vectors: Array<Array<number> | null>;
152
+ };
153
+ failPendingSteps?: boolean;
154
+ hideFromUserIdSearch?: boolean;
155
+ messages: Array<{
156
+ error?: string;
157
+ fileIds?: Array<string>;
158
+ finishReason?:
159
+ | "stop"
160
+ | "length"
161
+ | "content-filter"
162
+ | "tool-calls"
163
+ | "error"
164
+ | "other"
165
+ | "unknown";
166
+ message:
167
+ | {
168
+ content:
169
+ | string
170
+ | Array<
171
+ | {
172
+ providerMetadata?: Record<
173
+ string,
174
+ Record<string, any>
175
+ >;
176
+ providerOptions?: Record<
177
+ string,
178
+ Record<string, any>
179
+ >;
180
+ text: string;
181
+ type: "text";
182
+ }
183
+ | {
184
+ image: string | ArrayBuffer;
185
+ mimeType?: string;
186
+ providerOptions?: Record<
187
+ string,
188
+ Record<string, any>
189
+ >;
190
+ type: "image";
191
+ }
192
+ | {
193
+ data: string | ArrayBuffer;
194
+ filename?: string;
195
+ mimeType: string;
196
+ providerMetadata?: Record<
197
+ string,
198
+ Record<string, any>
199
+ >;
200
+ providerOptions?: Record<
201
+ string,
202
+ Record<string, any>
203
+ >;
204
+ type: "file";
205
+ }
206
+ >;
207
+ providerOptions?: Record<string, Record<string, any>>;
208
+ role: "user";
209
+ }
210
+ | {
211
+ content:
212
+ | string
213
+ | Array<
214
+ | {
215
+ providerMetadata?: Record<
216
+ string,
217
+ Record<string, any>
218
+ >;
219
+ providerOptions?: Record<
220
+ string,
221
+ Record<string, any>
222
+ >;
223
+ text: string;
224
+ type: "text";
225
+ }
226
+ | {
227
+ data: string | ArrayBuffer;
228
+ filename?: string;
229
+ mimeType: string;
230
+ providerMetadata?: Record<
231
+ string,
232
+ Record<string, any>
233
+ >;
234
+ providerOptions?: Record<
235
+ string,
236
+ Record<string, any>
237
+ >;
238
+ type: "file";
239
+ }
240
+ | {
241
+ providerMetadata?: Record<
242
+ string,
243
+ Record<string, any>
244
+ >;
245
+ providerOptions?: Record<
246
+ string,
247
+ Record<string, any>
248
+ >;
249
+ signature?: string;
250
+ text: string;
251
+ type: "reasoning";
252
+ }
253
+ | {
254
+ data: string;
255
+ providerMetadata?: Record<
256
+ string,
257
+ Record<string, any>
258
+ >;
259
+ providerOptions?: Record<
260
+ string,
261
+ Record<string, any>
262
+ >;
263
+ type: "redacted-reasoning";
264
+ }
265
+ | {
266
+ args: any;
267
+ providerExecuted?: boolean;
268
+ providerMetadata?: Record<
269
+ string,
270
+ Record<string, any>
271
+ >;
272
+ providerOptions?: Record<
273
+ string,
274
+ Record<string, any>
275
+ >;
276
+ toolCallId: string;
277
+ toolName: string;
278
+ type: "tool-call";
279
+ }
280
+ | {
281
+ args?: any;
282
+ experimental_content?: Array<
283
+ | { text: string; type: "text" }
284
+ | {
285
+ data: string;
286
+ mimeType?: string;
287
+ type: "image";
288
+ }
289
+ >;
290
+ isError?: boolean;
291
+ output?:
292
+ | { type: "text"; value: string }
293
+ | { type: "json"; value: any }
294
+ | { type: "error-text"; value: string }
295
+ | { type: "error-json"; value: any }
296
+ | {
297
+ type: "content";
298
+ value: Array<
299
+ | { text: string; type: "text" }
300
+ | {
301
+ data: string;
302
+ mediaType: string;
303
+ type: "media";
304
+ }
305
+ >;
306
+ };
307
+ providerExecuted?: boolean;
308
+ providerMetadata?: Record<
309
+ string,
310
+ Record<string, any>
311
+ >;
312
+ providerOptions?: Record<
313
+ string,
314
+ Record<string, any>
315
+ >;
316
+ result?: any;
317
+ toolCallId: string;
318
+ toolName: string;
319
+ type: "tool-result";
320
+ }
321
+ | {
322
+ id: string;
323
+ providerMetadata?: Record<
324
+ string,
325
+ Record<string, any>
326
+ >;
327
+ providerOptions?: Record<
328
+ string,
329
+ Record<string, any>
330
+ >;
331
+ sourceType: "url";
332
+ title?: string;
333
+ type: "source";
334
+ url: string;
335
+ }
336
+ | {
337
+ filename?: string;
338
+ id: string;
339
+ mediaType: string;
340
+ providerMetadata?: Record<
341
+ string,
342
+ Record<string, any>
343
+ >;
344
+ providerOptions?: Record<
345
+ string,
346
+ Record<string, any>
347
+ >;
348
+ sourceType: "document";
349
+ title: string;
350
+ type: "source";
351
+ }
352
+ >;
353
+ providerOptions?: Record<string, Record<string, any>>;
354
+ role: "assistant";
355
+ }
356
+ | {
357
+ content: Array<{
358
+ args?: any;
359
+ experimental_content?: Array<
360
+ | { text: string; type: "text" }
361
+ | { data: string; mimeType?: string; type: "image" }
362
+ >;
363
+ isError?: boolean;
364
+ output?:
365
+ | { type: "text"; value: string }
366
+ | { type: "json"; value: any }
367
+ | { type: "error-text"; value: string }
368
+ | { type: "error-json"; value: any }
369
+ | {
370
+ type: "content";
371
+ value: Array<
372
+ | { text: string; type: "text" }
373
+ | { data: string; mediaType: string; type: "media" }
374
+ >;
375
+ };
376
+ providerExecuted?: boolean;
377
+ providerMetadata?: Record<string, Record<string, any>>;
378
+ providerOptions?: Record<string, Record<string, any>>;
379
+ result?: any;
380
+ toolCallId: string;
381
+ toolName: string;
382
+ type: "tool-result";
383
+ }>;
384
+ providerOptions?: Record<string, Record<string, any>>;
385
+ role: "tool";
386
+ }
387
+ | {
388
+ content: string;
389
+ providerOptions?: Record<string, Record<string, any>>;
390
+ role: "system";
391
+ };
392
+ model?: string;
393
+ provider?: string;
394
+ providerMetadata?: Record<string, Record<string, any>>;
395
+ reasoning?: string;
396
+ reasoningDetails?: Array<
397
+ | {
398
+ providerMetadata?: Record<string, Record<string, any>>;
399
+ providerOptions?: Record<string, Record<string, any>>;
400
+ signature?: string;
401
+ text: string;
402
+ type: "reasoning";
403
+ }
404
+ | { signature?: string; text: string; type: "text" }
405
+ | { data: string; type: "redacted" }
406
+ >;
407
+ sources?: Array<
408
+ | {
409
+ id: string;
410
+ providerMetadata?: Record<string, Record<string, any>>;
411
+ providerOptions?: Record<string, Record<string, any>>;
412
+ sourceType: "url";
413
+ title?: string;
414
+ type?: "source";
415
+ url: string;
416
+ }
417
+ | {
418
+ filename?: string;
419
+ id: string;
420
+ mediaType: string;
421
+ providerMetadata?: Record<string, Record<string, any>>;
422
+ providerOptions?: Record<string, Record<string, any>>;
423
+ sourceType: "document";
424
+ title: string;
425
+ type: "source";
426
+ }
427
+ >;
428
+ status?: "pending" | "success" | "failed";
429
+ text?: string;
430
+ usage?: {
431
+ cachedInputTokens?: number;
432
+ completionTokens: number;
433
+ promptTokens: number;
434
+ reasoningTokens?: number;
435
+ totalTokens: number;
436
+ };
437
+ warnings?: Array<
438
+ | {
439
+ details?: string;
440
+ setting: string;
441
+ type: "unsupported-setting";
442
+ }
443
+ | { details?: string; tool: any; type: "unsupported-tool" }
444
+ | { message: string; type: "other" }
445
+ >;
446
+ }>;
447
+ pendingMessageId?: string;
448
+ promptMessageId?: string;
449
+ threadId: string;
450
+ userId?: string;
451
+ },
452
+ {
453
+ messages: Array<{
454
+ _creationTime: number;
455
+ _id: string;
456
+ agentName?: string;
457
+ embeddingId?: string;
458
+ error?: string;
459
+ fileIds?: Array<string>;
460
+ finishReason?:
461
+ | "stop"
462
+ | "length"
463
+ | "content-filter"
464
+ | "tool-calls"
465
+ | "error"
466
+ | "other"
467
+ | "unknown";
468
+ id?: string;
469
+ message?:
470
+ | {
471
+ content:
472
+ | string
473
+ | Array<
474
+ | {
475
+ providerMetadata?: Record<
476
+ string,
477
+ Record<string, any>
478
+ >;
479
+ providerOptions?: Record<
480
+ string,
481
+ Record<string, any>
482
+ >;
483
+ text: string;
484
+ type: "text";
485
+ }
486
+ | {
487
+ image: string | ArrayBuffer;
488
+ mimeType?: string;
489
+ providerOptions?: Record<
490
+ string,
491
+ Record<string, any>
492
+ >;
493
+ type: "image";
494
+ }
495
+ | {
496
+ data: string | ArrayBuffer;
497
+ filename?: string;
498
+ mimeType: string;
499
+ providerMetadata?: Record<
500
+ string,
501
+ Record<string, any>
502
+ >;
503
+ providerOptions?: Record<
504
+ string,
505
+ Record<string, any>
506
+ >;
507
+ type: "file";
508
+ }
509
+ >;
510
+ providerOptions?: Record<string, Record<string, any>>;
511
+ role: "user";
512
+ }
513
+ | {
514
+ content:
515
+ | string
516
+ | Array<
517
+ | {
518
+ providerMetadata?: Record<
519
+ string,
520
+ Record<string, any>
521
+ >;
522
+ providerOptions?: Record<
523
+ string,
524
+ Record<string, any>
525
+ >;
526
+ text: string;
527
+ type: "text";
528
+ }
529
+ | {
530
+ data: string | ArrayBuffer;
531
+ filename?: string;
532
+ mimeType: string;
533
+ providerMetadata?: Record<
534
+ string,
535
+ Record<string, any>
536
+ >;
537
+ providerOptions?: Record<
538
+ string,
539
+ Record<string, any>
540
+ >;
541
+ type: "file";
542
+ }
543
+ | {
544
+ providerMetadata?: Record<
545
+ string,
546
+ Record<string, any>
547
+ >;
548
+ providerOptions?: Record<
549
+ string,
550
+ Record<string, any>
551
+ >;
552
+ signature?: string;
553
+ text: string;
554
+ type: "reasoning";
555
+ }
556
+ | {
557
+ data: string;
558
+ providerMetadata?: Record<
559
+ string,
560
+ Record<string, any>
561
+ >;
562
+ providerOptions?: Record<
563
+ string,
564
+ Record<string, any>
565
+ >;
566
+ type: "redacted-reasoning";
567
+ }
568
+ | {
569
+ args: any;
570
+ providerExecuted?: boolean;
571
+ providerMetadata?: Record<
572
+ string,
573
+ Record<string, any>
574
+ >;
575
+ providerOptions?: Record<
576
+ string,
577
+ Record<string, any>
578
+ >;
579
+ toolCallId: string;
580
+ toolName: string;
581
+ type: "tool-call";
582
+ }
583
+ | {
584
+ args?: any;
585
+ experimental_content?: Array<
586
+ | { text: string; type: "text" }
587
+ | {
588
+ data: string;
589
+ mimeType?: string;
590
+ type: "image";
591
+ }
592
+ >;
593
+ isError?: boolean;
594
+ output?:
595
+ | { type: "text"; value: string }
596
+ | { type: "json"; value: any }
597
+ | { type: "error-text"; value: string }
598
+ | { type: "error-json"; value: any }
599
+ | {
600
+ type: "content";
601
+ value: Array<
602
+ | { text: string; type: "text" }
603
+ | {
604
+ data: string;
605
+ mediaType: string;
606
+ type: "media";
607
+ }
608
+ >;
609
+ };
610
+ providerExecuted?: boolean;
611
+ providerMetadata?: Record<
612
+ string,
613
+ Record<string, any>
614
+ >;
615
+ providerOptions?: Record<
616
+ string,
617
+ Record<string, any>
618
+ >;
619
+ result?: any;
620
+ toolCallId: string;
621
+ toolName: string;
622
+ type: "tool-result";
623
+ }
624
+ | {
625
+ id: string;
626
+ providerMetadata?: Record<
627
+ string,
628
+ Record<string, any>
629
+ >;
630
+ providerOptions?: Record<
631
+ string,
632
+ Record<string, any>
633
+ >;
634
+ sourceType: "url";
635
+ title?: string;
636
+ type: "source";
637
+ url: string;
638
+ }
639
+ | {
640
+ filename?: string;
641
+ id: string;
642
+ mediaType: string;
643
+ providerMetadata?: Record<
644
+ string,
645
+ Record<string, any>
646
+ >;
647
+ providerOptions?: Record<
648
+ string,
649
+ Record<string, any>
650
+ >;
651
+ sourceType: "document";
652
+ title: string;
653
+ type: "source";
654
+ }
655
+ >;
656
+ providerOptions?: Record<string, Record<string, any>>;
657
+ role: "assistant";
658
+ }
659
+ | {
660
+ content: Array<{
661
+ args?: any;
662
+ experimental_content?: Array<
663
+ | { text: string; type: "text" }
664
+ | { data: string; mimeType?: string; type: "image" }
665
+ >;
666
+ isError?: boolean;
667
+ output?:
668
+ | { type: "text"; value: string }
669
+ | { type: "json"; value: any }
670
+ | { type: "error-text"; value: string }
671
+ | { type: "error-json"; value: any }
672
+ | {
673
+ type: "content";
674
+ value: Array<
675
+ | { text: string; type: "text" }
676
+ | { data: string; mediaType: string; type: "media" }
677
+ >;
678
+ };
679
+ providerExecuted?: boolean;
680
+ providerMetadata?: Record<string, Record<string, any>>;
681
+ providerOptions?: Record<string, Record<string, any>>;
682
+ result?: any;
683
+ toolCallId: string;
684
+ toolName: string;
685
+ type: "tool-result";
686
+ }>;
687
+ providerOptions?: Record<string, Record<string, any>>;
688
+ role: "tool";
689
+ }
690
+ | {
691
+ content: string;
692
+ providerOptions?: Record<string, Record<string, any>>;
693
+ role: "system";
694
+ };
695
+ model?: string;
696
+ order: number;
697
+ provider?: string;
698
+ providerMetadata?: Record<string, Record<string, any>>;
699
+ providerOptions?: Record<string, Record<string, any>>;
700
+ reasoning?: string;
701
+ reasoningDetails?: Array<
702
+ | {
703
+ providerMetadata?: Record<string, Record<string, any>>;
704
+ providerOptions?: Record<string, Record<string, any>>;
705
+ signature?: string;
706
+ text: string;
707
+ type: "reasoning";
708
+ }
709
+ | { signature?: string; text: string; type: "text" }
710
+ | { data: string; type: "redacted" }
711
+ >;
712
+ sources?: Array<
713
+ | {
714
+ id: string;
715
+ providerMetadata?: Record<string, Record<string, any>>;
716
+ providerOptions?: Record<string, Record<string, any>>;
717
+ sourceType: "url";
718
+ title?: string;
719
+ type?: "source";
720
+ url: string;
721
+ }
722
+ | {
723
+ filename?: string;
724
+ id: string;
725
+ mediaType: string;
726
+ providerMetadata?: Record<string, Record<string, any>>;
727
+ providerOptions?: Record<string, Record<string, any>>;
728
+ sourceType: "document";
729
+ title: string;
730
+ type: "source";
731
+ }
732
+ >;
733
+ status: "pending" | "success" | "failed";
734
+ stepOrder: number;
735
+ text?: string;
736
+ threadId: string;
737
+ tool: boolean;
738
+ usage?: {
739
+ cachedInputTokens?: number;
740
+ completionTokens: number;
741
+ promptTokens: number;
742
+ reasoningTokens?: number;
743
+ totalTokens: number;
744
+ };
745
+ userId?: string;
746
+ warnings?: Array<
747
+ | {
748
+ details?: string;
749
+ setting: string;
750
+ type: "unsupported-setting";
751
+ }
752
+ | { details?: string; tool: any; type: "unsupported-tool" }
753
+ | { message: string; type: "other" }
754
+ >;
755
+ }>;
756
+ },
757
+ Name
758
+ >;
759
+ cloneThread: FunctionReference<
760
+ "action",
761
+ "internal",
762
+ {
763
+ batchSize?: number;
764
+ copyUserIdForVectorSearch?: boolean;
765
+ excludeToolMessages?: boolean;
766
+ insertAtOrder?: number;
767
+ limit?: number;
768
+ sourceThreadId: string;
769
+ statuses?: Array<"pending" | "success" | "failed">;
770
+ targetThreadId: string;
771
+ upToAndIncludingMessageId?: string;
772
+ },
773
+ number,
774
+ Name
775
+ >;
776
+ deleteByIds: FunctionReference<
777
+ "mutation",
778
+ "internal",
779
+ { messageIds: Array<string> },
780
+ Array<string>,
781
+ Name
782
+ >;
783
+ deleteByOrder: FunctionReference<
784
+ "mutation",
785
+ "internal",
786
+ {
787
+ endOrder: number;
788
+ endStepOrder?: number;
789
+ startOrder: number;
790
+ startStepOrder?: number;
791
+ threadId: string;
792
+ },
793
+ { isDone: boolean; lastOrder?: number; lastStepOrder?: number },
794
+ Name
795
+ >;
796
+ finalizeMessage: FunctionReference<
797
+ "mutation",
798
+ "internal",
799
+ {
800
+ messageId: string;
801
+ result: { status: "success" } | { error: string; status: "failed" };
802
+ },
803
+ null,
804
+ Name
805
+ >;
806
+ getMessagesByIds: FunctionReference<
807
+ "query",
808
+ "internal",
809
+ { messageIds: Array<string> },
810
+ Array<null | {
811
+ _creationTime: number;
812
+ _id: string;
813
+ agentName?: string;
814
+ embeddingId?: string;
815
+ error?: string;
816
+ fileIds?: Array<string>;
817
+ finishReason?:
818
+ | "stop"
819
+ | "length"
820
+ | "content-filter"
821
+ | "tool-calls"
822
+ | "error"
823
+ | "other"
824
+ | "unknown";
825
+ id?: string;
826
+ message?:
827
+ | {
828
+ content:
829
+ | string
830
+ | Array<
831
+ | {
832
+ providerMetadata?: Record<
833
+ string,
834
+ Record<string, any>
835
+ >;
836
+ providerOptions?: Record<string, Record<string, any>>;
837
+ text: string;
838
+ type: "text";
839
+ }
840
+ | {
841
+ image: string | ArrayBuffer;
842
+ mimeType?: string;
843
+ providerOptions?: Record<string, Record<string, any>>;
844
+ type: "image";
845
+ }
846
+ | {
847
+ data: string | ArrayBuffer;
848
+ filename?: string;
849
+ mimeType: string;
850
+ providerMetadata?: Record<
851
+ string,
852
+ Record<string, any>
853
+ >;
854
+ providerOptions?: Record<string, Record<string, any>>;
855
+ type: "file";
856
+ }
857
+ >;
858
+ providerOptions?: Record<string, Record<string, any>>;
859
+ role: "user";
860
+ }
861
+ | {
862
+ content:
863
+ | string
864
+ | Array<
865
+ | {
866
+ providerMetadata?: Record<
867
+ string,
868
+ Record<string, any>
869
+ >;
870
+ providerOptions?: Record<string, Record<string, any>>;
871
+ text: string;
872
+ type: "text";
873
+ }
874
+ | {
875
+ data: string | ArrayBuffer;
876
+ filename?: string;
877
+ mimeType: string;
878
+ providerMetadata?: Record<
879
+ string,
880
+ Record<string, any>
881
+ >;
882
+ providerOptions?: Record<string, Record<string, any>>;
883
+ type: "file";
884
+ }
885
+ | {
886
+ providerMetadata?: Record<
887
+ string,
888
+ Record<string, any>
889
+ >;
890
+ providerOptions?: Record<string, Record<string, any>>;
891
+ signature?: string;
892
+ text: string;
893
+ type: "reasoning";
894
+ }
895
+ | {
896
+ data: string;
897
+ providerMetadata?: Record<
898
+ string,
899
+ Record<string, any>
900
+ >;
901
+ providerOptions?: Record<string, Record<string, any>>;
902
+ type: "redacted-reasoning";
903
+ }
904
+ | {
905
+ args: any;
906
+ providerExecuted?: boolean;
907
+ providerMetadata?: Record<
908
+ string,
909
+ Record<string, any>
910
+ >;
911
+ providerOptions?: Record<string, Record<string, any>>;
912
+ toolCallId: string;
913
+ toolName: string;
914
+ type: "tool-call";
915
+ }
916
+ | {
917
+ args?: any;
918
+ experimental_content?: Array<
919
+ | { text: string; type: "text" }
920
+ | { data: string; mimeType?: string; type: "image" }
921
+ >;
922
+ isError?: boolean;
923
+ output?:
924
+ | { type: "text"; value: string }
925
+ | { type: "json"; value: any }
926
+ | { type: "error-text"; value: string }
927
+ | { type: "error-json"; value: any }
928
+ | {
929
+ type: "content";
930
+ value: Array<
931
+ | { text: string; type: "text" }
932
+ | {
933
+ data: string;
934
+ mediaType: string;
935
+ type: "media";
936
+ }
937
+ >;
938
+ };
939
+ providerExecuted?: boolean;
940
+ providerMetadata?: Record<
941
+ string,
942
+ Record<string, any>
943
+ >;
944
+ providerOptions?: Record<string, Record<string, any>>;
945
+ result?: any;
946
+ toolCallId: string;
947
+ toolName: string;
948
+ type: "tool-result";
949
+ }
950
+ | {
951
+ id: string;
952
+ providerMetadata?: Record<
953
+ string,
954
+ Record<string, any>
955
+ >;
956
+ providerOptions?: Record<string, Record<string, any>>;
957
+ sourceType: "url";
958
+ title?: string;
959
+ type: "source";
960
+ url: string;
961
+ }
962
+ | {
963
+ filename?: string;
964
+ id: string;
965
+ mediaType: string;
966
+ providerMetadata?: Record<
967
+ string,
968
+ Record<string, any>
969
+ >;
970
+ providerOptions?: Record<string, Record<string, any>>;
971
+ sourceType: "document";
972
+ title: string;
973
+ type: "source";
974
+ }
975
+ >;
976
+ providerOptions?: Record<string, Record<string, any>>;
977
+ role: "assistant";
978
+ }
979
+ | {
980
+ content: Array<{
981
+ args?: any;
982
+ experimental_content?: Array<
983
+ | { text: string; type: "text" }
984
+ | { data: string; mimeType?: string; type: "image" }
985
+ >;
986
+ isError?: boolean;
987
+ output?:
988
+ | { type: "text"; value: string }
989
+ | { type: "json"; value: any }
990
+ | { type: "error-text"; value: string }
991
+ | { type: "error-json"; value: any }
992
+ | {
993
+ type: "content";
994
+ value: Array<
995
+ | { text: string; type: "text" }
996
+ | { data: string; mediaType: string; type: "media" }
997
+ >;
998
+ };
999
+ providerExecuted?: boolean;
1000
+ providerMetadata?: Record<string, Record<string, any>>;
1001
+ providerOptions?: Record<string, Record<string, any>>;
1002
+ result?: any;
1003
+ toolCallId: string;
1004
+ toolName: string;
1005
+ type: "tool-result";
1006
+ }>;
1007
+ providerOptions?: Record<string, Record<string, any>>;
1008
+ role: "tool";
1009
+ }
1010
+ | {
1011
+ content: string;
1012
+ providerOptions?: Record<string, Record<string, any>>;
1013
+ role: "system";
1014
+ };
1015
+ model?: string;
1016
+ order: number;
1017
+ provider?: string;
1018
+ providerMetadata?: Record<string, Record<string, any>>;
1019
+ providerOptions?: Record<string, Record<string, any>>;
1020
+ reasoning?: string;
1021
+ reasoningDetails?: Array<
1022
+ | {
1023
+ providerMetadata?: Record<string, Record<string, any>>;
1024
+ providerOptions?: Record<string, Record<string, any>>;
1025
+ signature?: string;
1026
+ text: string;
1027
+ type: "reasoning";
1028
+ }
1029
+ | { signature?: string; text: string; type: "text" }
1030
+ | { data: string; type: "redacted" }
1031
+ >;
1032
+ sources?: Array<
1033
+ | {
1034
+ id: string;
1035
+ providerMetadata?: Record<string, Record<string, any>>;
1036
+ providerOptions?: Record<string, Record<string, any>>;
1037
+ sourceType: "url";
1038
+ title?: string;
1039
+ type?: "source";
1040
+ url: string;
1041
+ }
1042
+ | {
1043
+ filename?: string;
1044
+ id: string;
1045
+ mediaType: string;
1046
+ providerMetadata?: Record<string, Record<string, any>>;
1047
+ providerOptions?: Record<string, Record<string, any>>;
1048
+ sourceType: "document";
1049
+ title: string;
1050
+ type: "source";
1051
+ }
1052
+ >;
1053
+ status: "pending" | "success" | "failed";
1054
+ stepOrder: number;
1055
+ text?: string;
1056
+ threadId: string;
1057
+ tool: boolean;
1058
+ usage?: {
1059
+ cachedInputTokens?: number;
1060
+ completionTokens: number;
1061
+ promptTokens: number;
1062
+ reasoningTokens?: number;
1063
+ totalTokens: number;
1064
+ };
1065
+ userId?: string;
1066
+ warnings?: Array<
1067
+ | { details?: string; setting: string; type: "unsupported-setting" }
1068
+ | { details?: string; tool: any; type: "unsupported-tool" }
1069
+ | { message: string; type: "other" }
1070
+ >;
1071
+ }>,
1072
+ Name
1073
+ >;
1074
+ getMessageSearchFields: FunctionReference<
1075
+ "query",
1076
+ "internal",
1077
+ { messageId: string },
1078
+ { embedding?: Array<number>; embeddingModel?: string; text?: string },
1079
+ Name
1080
+ >;
1081
+ listMessagesByThreadId: FunctionReference<
1082
+ "query",
1083
+ "internal",
1084
+ {
1085
+ excludeToolMessages?: boolean;
1086
+ order: "asc" | "desc";
1087
+ paginationOpts?: {
1088
+ cursor: string | null;
1089
+ endCursor?: string | null;
1090
+ id?: number;
1091
+ maximumBytesRead?: number;
1092
+ maximumRowsRead?: number;
1093
+ numItems: number;
1094
+ };
1095
+ statuses?: Array<"pending" | "success" | "failed">;
1096
+ threadId: string;
1097
+ upToAndIncludingMessageId?: string;
1098
+ },
1099
+ {
1100
+ continueCursor: string;
1101
+ isDone: boolean;
1102
+ page: Array<{
1103
+ _creationTime: number;
1104
+ _id: string;
1105
+ agentName?: string;
1106
+ embeddingId?: string;
1107
+ error?: string;
1108
+ fileIds?: Array<string>;
1109
+ finishReason?:
1110
+ | "stop"
1111
+ | "length"
1112
+ | "content-filter"
1113
+ | "tool-calls"
1114
+ | "error"
1115
+ | "other"
1116
+ | "unknown";
1117
+ id?: string;
1118
+ message?:
1119
+ | {
1120
+ content:
1121
+ | string
1122
+ | Array<
1123
+ | {
1124
+ providerMetadata?: Record<
1125
+ string,
1126
+ Record<string, any>
1127
+ >;
1128
+ providerOptions?: Record<
1129
+ string,
1130
+ Record<string, any>
1131
+ >;
1132
+ text: string;
1133
+ type: "text";
1134
+ }
1135
+ | {
1136
+ image: string | ArrayBuffer;
1137
+ mimeType?: string;
1138
+ providerOptions?: Record<
1139
+ string,
1140
+ Record<string, any>
1141
+ >;
1142
+ type: "image";
1143
+ }
1144
+ | {
1145
+ data: string | ArrayBuffer;
1146
+ filename?: string;
1147
+ mimeType: string;
1148
+ providerMetadata?: Record<
1149
+ string,
1150
+ Record<string, any>
1151
+ >;
1152
+ providerOptions?: Record<
1153
+ string,
1154
+ Record<string, any>
1155
+ >;
1156
+ type: "file";
1157
+ }
1158
+ >;
1159
+ providerOptions?: Record<string, Record<string, any>>;
1160
+ role: "user";
1161
+ }
1162
+ | {
1163
+ content:
1164
+ | string
1165
+ | Array<
1166
+ | {
1167
+ providerMetadata?: Record<
1168
+ string,
1169
+ Record<string, any>
1170
+ >;
1171
+ providerOptions?: Record<
1172
+ string,
1173
+ Record<string, any>
1174
+ >;
1175
+ text: string;
1176
+ type: "text";
1177
+ }
1178
+ | {
1179
+ data: string | ArrayBuffer;
1180
+ filename?: string;
1181
+ mimeType: string;
1182
+ providerMetadata?: Record<
1183
+ string,
1184
+ Record<string, any>
1185
+ >;
1186
+ providerOptions?: Record<
1187
+ string,
1188
+ Record<string, any>
1189
+ >;
1190
+ type: "file";
1191
+ }
1192
+ | {
1193
+ providerMetadata?: Record<
1194
+ string,
1195
+ Record<string, any>
1196
+ >;
1197
+ providerOptions?: Record<
1198
+ string,
1199
+ Record<string, any>
1200
+ >;
1201
+ signature?: string;
1202
+ text: string;
1203
+ type: "reasoning";
1204
+ }
1205
+ | {
1206
+ data: string;
1207
+ providerMetadata?: Record<
1208
+ string,
1209
+ Record<string, any>
1210
+ >;
1211
+ providerOptions?: Record<
1212
+ string,
1213
+ Record<string, any>
1214
+ >;
1215
+ type: "redacted-reasoning";
1216
+ }
1217
+ | {
1218
+ args: any;
1219
+ providerExecuted?: boolean;
1220
+ providerMetadata?: Record<
1221
+ string,
1222
+ Record<string, any>
1223
+ >;
1224
+ providerOptions?: Record<
1225
+ string,
1226
+ Record<string, any>
1227
+ >;
1228
+ toolCallId: string;
1229
+ toolName: string;
1230
+ type: "tool-call";
1231
+ }
1232
+ | {
1233
+ args?: any;
1234
+ experimental_content?: Array<
1235
+ | { text: string; type: "text" }
1236
+ | {
1237
+ data: string;
1238
+ mimeType?: string;
1239
+ type: "image";
1240
+ }
1241
+ >;
1242
+ isError?: boolean;
1243
+ output?:
1244
+ | { type: "text"; value: string }
1245
+ | { type: "json"; value: any }
1246
+ | { type: "error-text"; value: string }
1247
+ | { type: "error-json"; value: any }
1248
+ | {
1249
+ type: "content";
1250
+ value: Array<
1251
+ | { text: string; type: "text" }
1252
+ | {
1253
+ data: string;
1254
+ mediaType: string;
1255
+ type: "media";
1256
+ }
1257
+ >;
1258
+ };
1259
+ providerExecuted?: boolean;
1260
+ providerMetadata?: Record<
1261
+ string,
1262
+ Record<string, any>
1263
+ >;
1264
+ providerOptions?: Record<
1265
+ string,
1266
+ Record<string, any>
1267
+ >;
1268
+ result?: any;
1269
+ toolCallId: string;
1270
+ toolName: string;
1271
+ type: "tool-result";
1272
+ }
1273
+ | {
1274
+ id: string;
1275
+ providerMetadata?: Record<
1276
+ string,
1277
+ Record<string, any>
1278
+ >;
1279
+ providerOptions?: Record<
1280
+ string,
1281
+ Record<string, any>
1282
+ >;
1283
+ sourceType: "url";
1284
+ title?: string;
1285
+ type: "source";
1286
+ url: string;
1287
+ }
1288
+ | {
1289
+ filename?: string;
1290
+ id: string;
1291
+ mediaType: string;
1292
+ providerMetadata?: Record<
1293
+ string,
1294
+ Record<string, any>
1295
+ >;
1296
+ providerOptions?: Record<
1297
+ string,
1298
+ Record<string, any>
1299
+ >;
1300
+ sourceType: "document";
1301
+ title: string;
1302
+ type: "source";
1303
+ }
1304
+ >;
1305
+ providerOptions?: Record<string, Record<string, any>>;
1306
+ role: "assistant";
1307
+ }
1308
+ | {
1309
+ content: Array<{
1310
+ args?: any;
1311
+ experimental_content?: Array<
1312
+ | { text: string; type: "text" }
1313
+ | { data: string; mimeType?: string; type: "image" }
1314
+ >;
1315
+ isError?: boolean;
1316
+ output?:
1317
+ | { type: "text"; value: string }
1318
+ | { type: "json"; value: any }
1319
+ | { type: "error-text"; value: string }
1320
+ | { type: "error-json"; value: any }
1321
+ | {
1322
+ type: "content";
1323
+ value: Array<
1324
+ | { text: string; type: "text" }
1325
+ | { data: string; mediaType: string; type: "media" }
1326
+ >;
1327
+ };
1328
+ providerExecuted?: boolean;
1329
+ providerMetadata?: Record<string, Record<string, any>>;
1330
+ providerOptions?: Record<string, Record<string, any>>;
1331
+ result?: any;
1332
+ toolCallId: string;
1333
+ toolName: string;
1334
+ type: "tool-result";
1335
+ }>;
1336
+ providerOptions?: Record<string, Record<string, any>>;
1337
+ role: "tool";
1338
+ }
1339
+ | {
1340
+ content: string;
1341
+ providerOptions?: Record<string, Record<string, any>>;
1342
+ role: "system";
1343
+ };
1344
+ model?: string;
1345
+ order: number;
1346
+ provider?: string;
1347
+ providerMetadata?: Record<string, Record<string, any>>;
1348
+ providerOptions?: Record<string, Record<string, any>>;
1349
+ reasoning?: string;
1350
+ reasoningDetails?: Array<
1351
+ | {
1352
+ providerMetadata?: Record<string, Record<string, any>>;
1353
+ providerOptions?: Record<string, Record<string, any>>;
1354
+ signature?: string;
1355
+ text: string;
1356
+ type: "reasoning";
1357
+ }
1358
+ | { signature?: string; text: string; type: "text" }
1359
+ | { data: string; type: "redacted" }
1360
+ >;
1361
+ sources?: Array<
1362
+ | {
1363
+ id: string;
1364
+ providerMetadata?: Record<string, Record<string, any>>;
1365
+ providerOptions?: Record<string, Record<string, any>>;
1366
+ sourceType: "url";
1367
+ title?: string;
1368
+ type?: "source";
1369
+ url: string;
1370
+ }
1371
+ | {
1372
+ filename?: string;
1373
+ id: string;
1374
+ mediaType: string;
1375
+ providerMetadata?: Record<string, Record<string, any>>;
1376
+ providerOptions?: Record<string, Record<string, any>>;
1377
+ sourceType: "document";
1378
+ title: string;
1379
+ type: "source";
1380
+ }
1381
+ >;
1382
+ status: "pending" | "success" | "failed";
1383
+ stepOrder: number;
1384
+ text?: string;
1385
+ threadId: string;
1386
+ tool: boolean;
1387
+ usage?: {
1388
+ cachedInputTokens?: number;
1389
+ completionTokens: number;
1390
+ promptTokens: number;
1391
+ reasoningTokens?: number;
1392
+ totalTokens: number;
1393
+ };
1394
+ userId?: string;
1395
+ warnings?: Array<
1396
+ | {
1397
+ details?: string;
1398
+ setting: string;
1399
+ type: "unsupported-setting";
1400
+ }
1401
+ | { details?: string; tool: any; type: "unsupported-tool" }
1402
+ | { message: string; type: "other" }
1403
+ >;
1404
+ }>;
1405
+ pageStatus?: "SplitRecommended" | "SplitRequired" | null;
1406
+ splitCursor?: string | null;
1407
+ },
1408
+ Name
1409
+ >;
1410
+ searchMessages: FunctionReference<
1411
+ "action",
1412
+ "internal",
1413
+ {
1414
+ embedding?: Array<number>;
1415
+ embeddingModel?: string;
1416
+ limit: number;
1417
+ messageRange?: { after: number; before: number };
1418
+ searchAllMessagesForUserId?: string;
1419
+ targetMessageId?: string;
1420
+ text?: string;
1421
+ textSearch?: boolean;
1422
+ threadId?: string;
1423
+ vectorScoreThreshold?: number;
1424
+ vectorSearch?: boolean;
1425
+ },
1426
+ Array<{
1427
+ _creationTime: number;
1428
+ _id: string;
1429
+ agentName?: string;
1430
+ embeddingId?: string;
1431
+ error?: string;
1432
+ fileIds?: Array<string>;
1433
+ finishReason?:
1434
+ | "stop"
1435
+ | "length"
1436
+ | "content-filter"
1437
+ | "tool-calls"
1438
+ | "error"
1439
+ | "other"
1440
+ | "unknown";
1441
+ id?: string;
1442
+ message?:
1443
+ | {
1444
+ content:
1445
+ | string
1446
+ | Array<
1447
+ | {
1448
+ providerMetadata?: Record<
1449
+ string,
1450
+ Record<string, any>
1451
+ >;
1452
+ providerOptions?: Record<string, Record<string, any>>;
1453
+ text: string;
1454
+ type: "text";
1455
+ }
1456
+ | {
1457
+ image: string | ArrayBuffer;
1458
+ mimeType?: string;
1459
+ providerOptions?: Record<string, Record<string, any>>;
1460
+ type: "image";
1461
+ }
1462
+ | {
1463
+ data: string | ArrayBuffer;
1464
+ filename?: string;
1465
+ mimeType: string;
1466
+ providerMetadata?: Record<
1467
+ string,
1468
+ Record<string, any>
1469
+ >;
1470
+ providerOptions?: Record<string, Record<string, any>>;
1471
+ type: "file";
1472
+ }
1473
+ >;
1474
+ providerOptions?: Record<string, Record<string, any>>;
1475
+ role: "user";
1476
+ }
1477
+ | {
1478
+ content:
1479
+ | string
1480
+ | Array<
1481
+ | {
1482
+ providerMetadata?: Record<
1483
+ string,
1484
+ Record<string, any>
1485
+ >;
1486
+ providerOptions?: Record<string, Record<string, any>>;
1487
+ text: string;
1488
+ type: "text";
1489
+ }
1490
+ | {
1491
+ data: string | ArrayBuffer;
1492
+ filename?: string;
1493
+ mimeType: string;
1494
+ providerMetadata?: Record<
1495
+ string,
1496
+ Record<string, any>
1497
+ >;
1498
+ providerOptions?: Record<string, Record<string, any>>;
1499
+ type: "file";
1500
+ }
1501
+ | {
1502
+ providerMetadata?: Record<
1503
+ string,
1504
+ Record<string, any>
1505
+ >;
1506
+ providerOptions?: Record<string, Record<string, any>>;
1507
+ signature?: string;
1508
+ text: string;
1509
+ type: "reasoning";
1510
+ }
1511
+ | {
1512
+ data: string;
1513
+ providerMetadata?: Record<
1514
+ string,
1515
+ Record<string, any>
1516
+ >;
1517
+ providerOptions?: Record<string, Record<string, any>>;
1518
+ type: "redacted-reasoning";
1519
+ }
1520
+ | {
1521
+ args: any;
1522
+ providerExecuted?: boolean;
1523
+ providerMetadata?: Record<
1524
+ string,
1525
+ Record<string, any>
1526
+ >;
1527
+ providerOptions?: Record<string, Record<string, any>>;
1528
+ toolCallId: string;
1529
+ toolName: string;
1530
+ type: "tool-call";
1531
+ }
1532
+ | {
1533
+ args?: any;
1534
+ experimental_content?: Array<
1535
+ | { text: string; type: "text" }
1536
+ | { data: string; mimeType?: string; type: "image" }
1537
+ >;
1538
+ isError?: boolean;
1539
+ output?:
1540
+ | { type: "text"; value: string }
1541
+ | { type: "json"; value: any }
1542
+ | { type: "error-text"; value: string }
1543
+ | { type: "error-json"; value: any }
1544
+ | {
1545
+ type: "content";
1546
+ value: Array<
1547
+ | { text: string; type: "text" }
1548
+ | {
1549
+ data: string;
1550
+ mediaType: string;
1551
+ type: "media";
1552
+ }
1553
+ >;
1554
+ };
1555
+ providerExecuted?: boolean;
1556
+ providerMetadata?: Record<
1557
+ string,
1558
+ Record<string, any>
1559
+ >;
1560
+ providerOptions?: Record<string, Record<string, any>>;
1561
+ result?: any;
1562
+ toolCallId: string;
1563
+ toolName: string;
1564
+ type: "tool-result";
1565
+ }
1566
+ | {
1567
+ id: string;
1568
+ providerMetadata?: Record<
1569
+ string,
1570
+ Record<string, any>
1571
+ >;
1572
+ providerOptions?: Record<string, Record<string, any>>;
1573
+ sourceType: "url";
1574
+ title?: string;
1575
+ type: "source";
1576
+ url: string;
1577
+ }
1578
+ | {
1579
+ filename?: string;
1580
+ id: string;
1581
+ mediaType: string;
1582
+ providerMetadata?: Record<
1583
+ string,
1584
+ Record<string, any>
1585
+ >;
1586
+ providerOptions?: Record<string, Record<string, any>>;
1587
+ sourceType: "document";
1588
+ title: string;
1589
+ type: "source";
1590
+ }
1591
+ >;
1592
+ providerOptions?: Record<string, Record<string, any>>;
1593
+ role: "assistant";
1594
+ }
1595
+ | {
1596
+ content: Array<{
1597
+ args?: any;
1598
+ experimental_content?: Array<
1599
+ | { text: string; type: "text" }
1600
+ | { data: string; mimeType?: string; type: "image" }
1601
+ >;
1602
+ isError?: boolean;
1603
+ output?:
1604
+ | { type: "text"; value: string }
1605
+ | { type: "json"; value: any }
1606
+ | { type: "error-text"; value: string }
1607
+ | { type: "error-json"; value: any }
1608
+ | {
1609
+ type: "content";
1610
+ value: Array<
1611
+ | { text: string; type: "text" }
1612
+ | { data: string; mediaType: string; type: "media" }
1613
+ >;
1614
+ };
1615
+ providerExecuted?: boolean;
1616
+ providerMetadata?: Record<string, Record<string, any>>;
1617
+ providerOptions?: Record<string, Record<string, any>>;
1618
+ result?: any;
1619
+ toolCallId: string;
1620
+ toolName: string;
1621
+ type: "tool-result";
1622
+ }>;
1623
+ providerOptions?: Record<string, Record<string, any>>;
1624
+ role: "tool";
1625
+ }
1626
+ | {
1627
+ content: string;
1628
+ providerOptions?: Record<string, Record<string, any>>;
1629
+ role: "system";
1630
+ };
1631
+ model?: string;
1632
+ order: number;
1633
+ provider?: string;
1634
+ providerMetadata?: Record<string, Record<string, any>>;
1635
+ providerOptions?: Record<string, Record<string, any>>;
1636
+ reasoning?: string;
1637
+ reasoningDetails?: Array<
1638
+ | {
1639
+ providerMetadata?: Record<string, Record<string, any>>;
1640
+ providerOptions?: Record<string, Record<string, any>>;
1641
+ signature?: string;
1642
+ text: string;
1643
+ type: "reasoning";
1644
+ }
1645
+ | { signature?: string; text: string; type: "text" }
1646
+ | { data: string; type: "redacted" }
1647
+ >;
1648
+ sources?: Array<
1649
+ | {
1650
+ id: string;
1651
+ providerMetadata?: Record<string, Record<string, any>>;
1652
+ providerOptions?: Record<string, Record<string, any>>;
1653
+ sourceType: "url";
1654
+ title?: string;
1655
+ type?: "source";
1656
+ url: string;
1657
+ }
1658
+ | {
1659
+ filename?: string;
1660
+ id: string;
1661
+ mediaType: string;
1662
+ providerMetadata?: Record<string, Record<string, any>>;
1663
+ providerOptions?: Record<string, Record<string, any>>;
1664
+ sourceType: "document";
1665
+ title: string;
1666
+ type: "source";
1667
+ }
1668
+ >;
1669
+ status: "pending" | "success" | "failed";
1670
+ stepOrder: number;
1671
+ text?: string;
1672
+ threadId: string;
1673
+ tool: boolean;
1674
+ usage?: {
1675
+ cachedInputTokens?: number;
1676
+ completionTokens: number;
1677
+ promptTokens: number;
1678
+ reasoningTokens?: number;
1679
+ totalTokens: number;
1680
+ };
1681
+ userId?: string;
1682
+ warnings?: Array<
1683
+ | { details?: string; setting: string; type: "unsupported-setting" }
1684
+ | { details?: string; tool: any; type: "unsupported-tool" }
1685
+ | { message: string; type: "other" }
1686
+ >;
1687
+ }>,
1688
+ Name
1689
+ >;
1690
+ textSearch: FunctionReference<
1691
+ "query",
1692
+ "internal",
1693
+ {
1694
+ limit: number;
1695
+ searchAllMessagesForUserId?: string;
1696
+ targetMessageId?: string;
1697
+ text?: string;
1698
+ threadId?: string;
1699
+ },
1700
+ Array<{
1701
+ _creationTime: number;
1702
+ _id: string;
1703
+ agentName?: string;
1704
+ embeddingId?: string;
1705
+ error?: string;
1706
+ fileIds?: Array<string>;
1707
+ finishReason?:
1708
+ | "stop"
1709
+ | "length"
1710
+ | "content-filter"
1711
+ | "tool-calls"
1712
+ | "error"
1713
+ | "other"
1714
+ | "unknown";
1715
+ id?: string;
1716
+ message?:
1717
+ | {
1718
+ content:
1719
+ | string
1720
+ | Array<
1721
+ | {
1722
+ providerMetadata?: Record<
1723
+ string,
1724
+ Record<string, any>
1725
+ >;
1726
+ providerOptions?: Record<string, Record<string, any>>;
1727
+ text: string;
1728
+ type: "text";
1729
+ }
1730
+ | {
1731
+ image: string | ArrayBuffer;
1732
+ mimeType?: string;
1733
+ providerOptions?: Record<string, Record<string, any>>;
1734
+ type: "image";
1735
+ }
1736
+ | {
1737
+ data: string | ArrayBuffer;
1738
+ filename?: string;
1739
+ mimeType: string;
1740
+ providerMetadata?: Record<
1741
+ string,
1742
+ Record<string, any>
1743
+ >;
1744
+ providerOptions?: Record<string, Record<string, any>>;
1745
+ type: "file";
1746
+ }
1747
+ >;
1748
+ providerOptions?: Record<string, Record<string, any>>;
1749
+ role: "user";
1750
+ }
1751
+ | {
1752
+ content:
1753
+ | string
1754
+ | Array<
1755
+ | {
1756
+ providerMetadata?: Record<
1757
+ string,
1758
+ Record<string, any>
1759
+ >;
1760
+ providerOptions?: Record<string, Record<string, any>>;
1761
+ text: string;
1762
+ type: "text";
1763
+ }
1764
+ | {
1765
+ data: string | ArrayBuffer;
1766
+ filename?: string;
1767
+ mimeType: string;
1768
+ providerMetadata?: Record<
1769
+ string,
1770
+ Record<string, any>
1771
+ >;
1772
+ providerOptions?: Record<string, Record<string, any>>;
1773
+ type: "file";
1774
+ }
1775
+ | {
1776
+ providerMetadata?: Record<
1777
+ string,
1778
+ Record<string, any>
1779
+ >;
1780
+ providerOptions?: Record<string, Record<string, any>>;
1781
+ signature?: string;
1782
+ text: string;
1783
+ type: "reasoning";
1784
+ }
1785
+ | {
1786
+ data: string;
1787
+ providerMetadata?: Record<
1788
+ string,
1789
+ Record<string, any>
1790
+ >;
1791
+ providerOptions?: Record<string, Record<string, any>>;
1792
+ type: "redacted-reasoning";
1793
+ }
1794
+ | {
1795
+ args: any;
1796
+ providerExecuted?: boolean;
1797
+ providerMetadata?: Record<
1798
+ string,
1799
+ Record<string, any>
1800
+ >;
1801
+ providerOptions?: Record<string, Record<string, any>>;
1802
+ toolCallId: string;
1803
+ toolName: string;
1804
+ type: "tool-call";
1805
+ }
1806
+ | {
1807
+ args?: any;
1808
+ experimental_content?: Array<
1809
+ | { text: string; type: "text" }
1810
+ | { data: string; mimeType?: string; type: "image" }
1811
+ >;
1812
+ isError?: boolean;
1813
+ output?:
1814
+ | { type: "text"; value: string }
1815
+ | { type: "json"; value: any }
1816
+ | { type: "error-text"; value: string }
1817
+ | { type: "error-json"; value: any }
1818
+ | {
1819
+ type: "content";
1820
+ value: Array<
1821
+ | { text: string; type: "text" }
1822
+ | {
1823
+ data: string;
1824
+ mediaType: string;
1825
+ type: "media";
1826
+ }
1827
+ >;
1828
+ };
1829
+ providerExecuted?: boolean;
1830
+ providerMetadata?: Record<
1831
+ string,
1832
+ Record<string, any>
1833
+ >;
1834
+ providerOptions?: Record<string, Record<string, any>>;
1835
+ result?: any;
1836
+ toolCallId: string;
1837
+ toolName: string;
1838
+ type: "tool-result";
1839
+ }
1840
+ | {
1841
+ id: string;
1842
+ providerMetadata?: Record<
1843
+ string,
1844
+ Record<string, any>
1845
+ >;
1846
+ providerOptions?: Record<string, Record<string, any>>;
1847
+ sourceType: "url";
1848
+ title?: string;
1849
+ type: "source";
1850
+ url: string;
1851
+ }
1852
+ | {
1853
+ filename?: string;
1854
+ id: string;
1855
+ mediaType: string;
1856
+ providerMetadata?: Record<
1857
+ string,
1858
+ Record<string, any>
1859
+ >;
1860
+ providerOptions?: Record<string, Record<string, any>>;
1861
+ sourceType: "document";
1862
+ title: string;
1863
+ type: "source";
1864
+ }
1865
+ >;
1866
+ providerOptions?: Record<string, Record<string, any>>;
1867
+ role: "assistant";
1868
+ }
1869
+ | {
1870
+ content: Array<{
1871
+ args?: any;
1872
+ experimental_content?: Array<
1873
+ | { text: string; type: "text" }
1874
+ | { data: string; mimeType?: string; type: "image" }
1875
+ >;
1876
+ isError?: boolean;
1877
+ output?:
1878
+ | { type: "text"; value: string }
1879
+ | { type: "json"; value: any }
1880
+ | { type: "error-text"; value: string }
1881
+ | { type: "error-json"; value: any }
1882
+ | {
1883
+ type: "content";
1884
+ value: Array<
1885
+ | { text: string; type: "text" }
1886
+ | { data: string; mediaType: string; type: "media" }
1887
+ >;
1888
+ };
1889
+ providerExecuted?: boolean;
1890
+ providerMetadata?: Record<string, Record<string, any>>;
1891
+ providerOptions?: Record<string, Record<string, any>>;
1892
+ result?: any;
1893
+ toolCallId: string;
1894
+ toolName: string;
1895
+ type: "tool-result";
1896
+ }>;
1897
+ providerOptions?: Record<string, Record<string, any>>;
1898
+ role: "tool";
1899
+ }
1900
+ | {
1901
+ content: string;
1902
+ providerOptions?: Record<string, Record<string, any>>;
1903
+ role: "system";
1904
+ };
1905
+ model?: string;
1906
+ order: number;
1907
+ provider?: string;
1908
+ providerMetadata?: Record<string, Record<string, any>>;
1909
+ providerOptions?: Record<string, Record<string, any>>;
1910
+ reasoning?: string;
1911
+ reasoningDetails?: Array<
1912
+ | {
1913
+ providerMetadata?: Record<string, Record<string, any>>;
1914
+ providerOptions?: Record<string, Record<string, any>>;
1915
+ signature?: string;
1916
+ text: string;
1917
+ type: "reasoning";
1918
+ }
1919
+ | { signature?: string; text: string; type: "text" }
1920
+ | { data: string; type: "redacted" }
1921
+ >;
1922
+ sources?: Array<
1923
+ | {
1924
+ id: string;
1925
+ providerMetadata?: Record<string, Record<string, any>>;
1926
+ providerOptions?: Record<string, Record<string, any>>;
1927
+ sourceType: "url";
1928
+ title?: string;
1929
+ type?: "source";
1930
+ url: string;
1931
+ }
1932
+ | {
1933
+ filename?: string;
1934
+ id: string;
1935
+ mediaType: string;
1936
+ providerMetadata?: Record<string, Record<string, any>>;
1937
+ providerOptions?: Record<string, Record<string, any>>;
1938
+ sourceType: "document";
1939
+ title: string;
1940
+ type: "source";
1941
+ }
1942
+ >;
1943
+ status: "pending" | "success" | "failed";
1944
+ stepOrder: number;
1945
+ text?: string;
1946
+ threadId: string;
1947
+ tool: boolean;
1948
+ usage?: {
1949
+ cachedInputTokens?: number;
1950
+ completionTokens: number;
1951
+ promptTokens: number;
1952
+ reasoningTokens?: number;
1953
+ totalTokens: number;
1954
+ };
1955
+ userId?: string;
1956
+ warnings?: Array<
1957
+ | { details?: string; setting: string; type: "unsupported-setting" }
1958
+ | { details?: string; tool: any; type: "unsupported-tool" }
1959
+ | { message: string; type: "other" }
1960
+ >;
1961
+ }>,
1962
+ Name
1963
+ >;
1964
+ updateMessage: FunctionReference<
1965
+ "mutation",
1966
+ "internal",
1967
+ {
1968
+ messageId: string;
1969
+ patch: {
1970
+ error?: string;
1971
+ fileIds?: Array<string>;
1972
+ finishReason?:
1973
+ | "stop"
1974
+ | "length"
1975
+ | "content-filter"
1976
+ | "tool-calls"
1977
+ | "error"
1978
+ | "other"
1979
+ | "unknown";
1980
+ message?:
1981
+ | {
1982
+ content:
1983
+ | string
1984
+ | Array<
1985
+ | {
1986
+ providerMetadata?: Record<
1987
+ string,
1988
+ Record<string, any>
1989
+ >;
1990
+ providerOptions?: Record<
1991
+ string,
1992
+ Record<string, any>
1993
+ >;
1994
+ text: string;
1995
+ type: "text";
1996
+ }
1997
+ | {
1998
+ image: string | ArrayBuffer;
1999
+ mimeType?: string;
2000
+ providerOptions?: Record<
2001
+ string,
2002
+ Record<string, any>
2003
+ >;
2004
+ type: "image";
2005
+ }
2006
+ | {
2007
+ data: string | ArrayBuffer;
2008
+ filename?: string;
2009
+ mimeType: string;
2010
+ providerMetadata?: Record<
2011
+ string,
2012
+ Record<string, any>
2013
+ >;
2014
+ providerOptions?: Record<
2015
+ string,
2016
+ Record<string, any>
2017
+ >;
2018
+ type: "file";
2019
+ }
2020
+ >;
2021
+ providerOptions?: Record<string, Record<string, any>>;
2022
+ role: "user";
2023
+ }
2024
+ | {
2025
+ content:
2026
+ | string
2027
+ | Array<
2028
+ | {
2029
+ providerMetadata?: Record<
2030
+ string,
2031
+ Record<string, any>
2032
+ >;
2033
+ providerOptions?: Record<
2034
+ string,
2035
+ Record<string, any>
2036
+ >;
2037
+ text: string;
2038
+ type: "text";
2039
+ }
2040
+ | {
2041
+ data: string | ArrayBuffer;
2042
+ filename?: string;
2043
+ mimeType: string;
2044
+ providerMetadata?: Record<
2045
+ string,
2046
+ Record<string, any>
2047
+ >;
2048
+ providerOptions?: Record<
2049
+ string,
2050
+ Record<string, any>
2051
+ >;
2052
+ type: "file";
2053
+ }
2054
+ | {
2055
+ providerMetadata?: Record<
2056
+ string,
2057
+ Record<string, any>
2058
+ >;
2059
+ providerOptions?: Record<
2060
+ string,
2061
+ Record<string, any>
2062
+ >;
2063
+ signature?: string;
2064
+ text: string;
2065
+ type: "reasoning";
2066
+ }
2067
+ | {
2068
+ data: string;
2069
+ providerMetadata?: Record<
2070
+ string,
2071
+ Record<string, any>
2072
+ >;
2073
+ providerOptions?: Record<
2074
+ string,
2075
+ Record<string, any>
2076
+ >;
2077
+ type: "redacted-reasoning";
2078
+ }
2079
+ | {
2080
+ args: any;
2081
+ providerExecuted?: boolean;
2082
+ providerMetadata?: Record<
2083
+ string,
2084
+ Record<string, any>
2085
+ >;
2086
+ providerOptions?: Record<
2087
+ string,
2088
+ Record<string, any>
2089
+ >;
2090
+ toolCallId: string;
2091
+ toolName: string;
2092
+ type: "tool-call";
2093
+ }
2094
+ | {
2095
+ args?: any;
2096
+ experimental_content?: Array<
2097
+ | { text: string; type: "text" }
2098
+ | {
2099
+ data: string;
2100
+ mimeType?: string;
2101
+ type: "image";
2102
+ }
2103
+ >;
2104
+ isError?: boolean;
2105
+ output?:
2106
+ | { type: "text"; value: string }
2107
+ | { type: "json"; value: any }
2108
+ | { type: "error-text"; value: string }
2109
+ | { type: "error-json"; value: any }
2110
+ | {
2111
+ type: "content";
2112
+ value: Array<
2113
+ | { text: string; type: "text" }
2114
+ | {
2115
+ data: string;
2116
+ mediaType: string;
2117
+ type: "media";
2118
+ }
2119
+ >;
2120
+ };
2121
+ providerExecuted?: boolean;
2122
+ providerMetadata?: Record<
2123
+ string,
2124
+ Record<string, any>
2125
+ >;
2126
+ providerOptions?: Record<
2127
+ string,
2128
+ Record<string, any>
2129
+ >;
2130
+ result?: any;
2131
+ toolCallId: string;
2132
+ toolName: string;
2133
+ type: "tool-result";
2134
+ }
2135
+ | {
2136
+ id: string;
2137
+ providerMetadata?: Record<
2138
+ string,
2139
+ Record<string, any>
2140
+ >;
2141
+ providerOptions?: Record<
2142
+ string,
2143
+ Record<string, any>
2144
+ >;
2145
+ sourceType: "url";
2146
+ title?: string;
2147
+ type: "source";
2148
+ url: string;
2149
+ }
2150
+ | {
2151
+ filename?: string;
2152
+ id: string;
2153
+ mediaType: string;
2154
+ providerMetadata?: Record<
2155
+ string,
2156
+ Record<string, any>
2157
+ >;
2158
+ providerOptions?: Record<
2159
+ string,
2160
+ Record<string, any>
2161
+ >;
2162
+ sourceType: "document";
2163
+ title: string;
2164
+ type: "source";
2165
+ }
2166
+ >;
2167
+ providerOptions?: Record<string, Record<string, any>>;
2168
+ role: "assistant";
2169
+ }
2170
+ | {
2171
+ content: Array<{
2172
+ args?: any;
2173
+ experimental_content?: Array<
2174
+ | { text: string; type: "text" }
2175
+ | { data: string; mimeType?: string; type: "image" }
2176
+ >;
2177
+ isError?: boolean;
2178
+ output?:
2179
+ | { type: "text"; value: string }
2180
+ | { type: "json"; value: any }
2181
+ | { type: "error-text"; value: string }
2182
+ | { type: "error-json"; value: any }
2183
+ | {
2184
+ type: "content";
2185
+ value: Array<
2186
+ | { text: string; type: "text" }
2187
+ | { data: string; mediaType: string; type: "media" }
2188
+ >;
2189
+ };
2190
+ providerExecuted?: boolean;
2191
+ providerMetadata?: Record<string, Record<string, any>>;
2192
+ providerOptions?: Record<string, Record<string, any>>;
2193
+ result?: any;
2194
+ toolCallId: string;
2195
+ toolName: string;
2196
+ type: "tool-result";
2197
+ }>;
2198
+ providerOptions?: Record<string, Record<string, any>>;
2199
+ role: "tool";
2200
+ }
2201
+ | {
2202
+ content: string;
2203
+ providerOptions?: Record<string, Record<string, any>>;
2204
+ role: "system";
2205
+ };
2206
+ model?: string;
2207
+ provider?: string;
2208
+ providerOptions?: Record<string, Record<string, any>>;
2209
+ status?: "pending" | "success" | "failed";
2210
+ };
2211
+ },
2212
+ {
2213
+ _creationTime: number;
2214
+ _id: string;
2215
+ agentName?: string;
2216
+ embeddingId?: string;
2217
+ error?: string;
2218
+ fileIds?: Array<string>;
2219
+ finishReason?:
2220
+ | "stop"
2221
+ | "length"
2222
+ | "content-filter"
2223
+ | "tool-calls"
2224
+ | "error"
2225
+ | "other"
2226
+ | "unknown";
2227
+ id?: string;
2228
+ message?:
2229
+ | {
2230
+ content:
2231
+ | string
2232
+ | Array<
2233
+ | {
2234
+ providerMetadata?: Record<
2235
+ string,
2236
+ Record<string, any>
2237
+ >;
2238
+ providerOptions?: Record<string, Record<string, any>>;
2239
+ text: string;
2240
+ type: "text";
2241
+ }
2242
+ | {
2243
+ image: string | ArrayBuffer;
2244
+ mimeType?: string;
2245
+ providerOptions?: Record<string, Record<string, any>>;
2246
+ type: "image";
2247
+ }
2248
+ | {
2249
+ data: string | ArrayBuffer;
2250
+ filename?: string;
2251
+ mimeType: string;
2252
+ providerMetadata?: Record<
2253
+ string,
2254
+ Record<string, any>
2255
+ >;
2256
+ providerOptions?: Record<string, Record<string, any>>;
2257
+ type: "file";
2258
+ }
2259
+ >;
2260
+ providerOptions?: Record<string, Record<string, any>>;
2261
+ role: "user";
2262
+ }
2263
+ | {
2264
+ content:
2265
+ | string
2266
+ | Array<
2267
+ | {
2268
+ providerMetadata?: Record<
2269
+ string,
2270
+ Record<string, any>
2271
+ >;
2272
+ providerOptions?: Record<string, Record<string, any>>;
2273
+ text: string;
2274
+ type: "text";
2275
+ }
2276
+ | {
2277
+ data: string | ArrayBuffer;
2278
+ filename?: string;
2279
+ mimeType: string;
2280
+ providerMetadata?: Record<
2281
+ string,
2282
+ Record<string, any>
2283
+ >;
2284
+ providerOptions?: Record<string, Record<string, any>>;
2285
+ type: "file";
2286
+ }
2287
+ | {
2288
+ providerMetadata?: Record<
2289
+ string,
2290
+ Record<string, any>
2291
+ >;
2292
+ providerOptions?: Record<string, Record<string, any>>;
2293
+ signature?: string;
2294
+ text: string;
2295
+ type: "reasoning";
2296
+ }
2297
+ | {
2298
+ data: string;
2299
+ providerMetadata?: Record<
2300
+ string,
2301
+ Record<string, any>
2302
+ >;
2303
+ providerOptions?: Record<string, Record<string, any>>;
2304
+ type: "redacted-reasoning";
2305
+ }
2306
+ | {
2307
+ args: any;
2308
+ providerExecuted?: boolean;
2309
+ providerMetadata?: Record<
2310
+ string,
2311
+ Record<string, any>
2312
+ >;
2313
+ providerOptions?: Record<string, Record<string, any>>;
2314
+ toolCallId: string;
2315
+ toolName: string;
2316
+ type: "tool-call";
2317
+ }
2318
+ | {
2319
+ args?: any;
2320
+ experimental_content?: Array<
2321
+ | { text: string; type: "text" }
2322
+ | { data: string; mimeType?: string; type: "image" }
2323
+ >;
2324
+ isError?: boolean;
2325
+ output?:
2326
+ | { type: "text"; value: string }
2327
+ | { type: "json"; value: any }
2328
+ | { type: "error-text"; value: string }
2329
+ | { type: "error-json"; value: any }
2330
+ | {
2331
+ type: "content";
2332
+ value: Array<
2333
+ | { text: string; type: "text" }
2334
+ | {
2335
+ data: string;
2336
+ mediaType: string;
2337
+ type: "media";
2338
+ }
2339
+ >;
2340
+ };
2341
+ providerExecuted?: boolean;
2342
+ providerMetadata?: Record<
2343
+ string,
2344
+ Record<string, any>
2345
+ >;
2346
+ providerOptions?: Record<string, Record<string, any>>;
2347
+ result?: any;
2348
+ toolCallId: string;
2349
+ toolName: string;
2350
+ type: "tool-result";
2351
+ }
2352
+ | {
2353
+ id: string;
2354
+ providerMetadata?: Record<
2355
+ string,
2356
+ Record<string, any>
2357
+ >;
2358
+ providerOptions?: Record<string, Record<string, any>>;
2359
+ sourceType: "url";
2360
+ title?: string;
2361
+ type: "source";
2362
+ url: string;
2363
+ }
2364
+ | {
2365
+ filename?: string;
2366
+ id: string;
2367
+ mediaType: string;
2368
+ providerMetadata?: Record<
2369
+ string,
2370
+ Record<string, any>
2371
+ >;
2372
+ providerOptions?: Record<string, Record<string, any>>;
2373
+ sourceType: "document";
2374
+ title: string;
2375
+ type: "source";
2376
+ }
2377
+ >;
2378
+ providerOptions?: Record<string, Record<string, any>>;
2379
+ role: "assistant";
2380
+ }
2381
+ | {
2382
+ content: Array<{
2383
+ args?: any;
2384
+ experimental_content?: Array<
2385
+ | { text: string; type: "text" }
2386
+ | { data: string; mimeType?: string; type: "image" }
2387
+ >;
2388
+ isError?: boolean;
2389
+ output?:
2390
+ | { type: "text"; value: string }
2391
+ | { type: "json"; value: any }
2392
+ | { type: "error-text"; value: string }
2393
+ | { type: "error-json"; value: any }
2394
+ | {
2395
+ type: "content";
2396
+ value: Array<
2397
+ | { text: string; type: "text" }
2398
+ | { data: string; mediaType: string; type: "media" }
2399
+ >;
2400
+ };
2401
+ providerExecuted?: boolean;
2402
+ providerMetadata?: Record<string, Record<string, any>>;
2403
+ providerOptions?: Record<string, Record<string, any>>;
2404
+ result?: any;
2405
+ toolCallId: string;
2406
+ toolName: string;
2407
+ type: "tool-result";
2408
+ }>;
2409
+ providerOptions?: Record<string, Record<string, any>>;
2410
+ role: "tool";
2411
+ }
2412
+ | {
2413
+ content: string;
2414
+ providerOptions?: Record<string, Record<string, any>>;
2415
+ role: "system";
2416
+ };
2417
+ model?: string;
2418
+ order: number;
2419
+ provider?: string;
2420
+ providerMetadata?: Record<string, Record<string, any>>;
2421
+ providerOptions?: Record<string, Record<string, any>>;
2422
+ reasoning?: string;
2423
+ reasoningDetails?: Array<
2424
+ | {
2425
+ providerMetadata?: Record<string, Record<string, any>>;
2426
+ providerOptions?: Record<string, Record<string, any>>;
2427
+ signature?: string;
2428
+ text: string;
2429
+ type: "reasoning";
2430
+ }
2431
+ | { signature?: string; text: string; type: "text" }
2432
+ | { data: string; type: "redacted" }
2433
+ >;
2434
+ sources?: Array<
2435
+ | {
2436
+ id: string;
2437
+ providerMetadata?: Record<string, Record<string, any>>;
2438
+ providerOptions?: Record<string, Record<string, any>>;
2439
+ sourceType: "url";
2440
+ title?: string;
2441
+ type?: "source";
2442
+ url: string;
2443
+ }
2444
+ | {
2445
+ filename?: string;
2446
+ id: string;
2447
+ mediaType: string;
2448
+ providerMetadata?: Record<string, Record<string, any>>;
2449
+ providerOptions?: Record<string, Record<string, any>>;
2450
+ sourceType: "document";
2451
+ title: string;
2452
+ type: "source";
2453
+ }
2454
+ >;
2455
+ status: "pending" | "success" | "failed";
2456
+ stepOrder: number;
2457
+ text?: string;
2458
+ threadId: string;
2459
+ tool: boolean;
2460
+ usage?: {
2461
+ cachedInputTokens?: number;
2462
+ completionTokens: number;
2463
+ promptTokens: number;
2464
+ reasoningTokens?: number;
2465
+ totalTokens: number;
2466
+ };
2467
+ userId?: string;
2468
+ warnings?: Array<
2469
+ | { details?: string; setting: string; type: "unsupported-setting" }
2470
+ | { details?: string; tool: any; type: "unsupported-tool" }
2471
+ | { message: string; type: "other" }
2472
+ >;
2473
+ },
2474
+ Name
2475
+ >;
2476
+ };
2477
+ streams: {
2478
+ abort: FunctionReference<
2479
+ "mutation",
2480
+ "internal",
2481
+ {
2482
+ finalDelta?: {
2483
+ end: number;
2484
+ parts: Array<any>;
2485
+ start: number;
2486
+ streamId: string;
2487
+ };
2488
+ reason: string;
2489
+ streamId: string;
2490
+ },
2491
+ boolean,
2492
+ Name
2493
+ >;
2494
+ abortByOrder: FunctionReference<
2495
+ "mutation",
2496
+ "internal",
2497
+ { order: number; reason: string; threadId: string },
2498
+ boolean,
2499
+ Name
2500
+ >;
2501
+ addDelta: FunctionReference<
2502
+ "mutation",
2503
+ "internal",
2504
+ { end: number; parts: Array<any>; start: number; streamId: string },
2505
+ boolean,
2506
+ Name
2507
+ >;
2508
+ create: FunctionReference<
2509
+ "mutation",
2510
+ "internal",
2511
+ {
2512
+ agentName?: string;
2513
+ format?: "UIMessageChunk" | "TextStreamPart";
2514
+ model?: string;
2515
+ order: number;
2516
+ provider?: string;
2517
+ providerOptions?: Record<string, Record<string, any>>;
2518
+ stepOrder: number;
2519
+ threadId: string;
2520
+ userId?: string;
2521
+ },
2522
+ string,
2523
+ Name
2524
+ >;
2525
+ deleteAllStreamsForThreadIdAsync: FunctionReference<
2526
+ "mutation",
2527
+ "internal",
2528
+ { deltaCursor?: string; streamOrder?: number; threadId: string },
2529
+ { deltaCursor?: string; isDone: boolean; streamOrder?: number },
2530
+ Name
2531
+ >;
2532
+ deleteAllStreamsForThreadIdSync: FunctionReference<
2533
+ "action",
2534
+ "internal",
2535
+ { threadId: string },
2536
+ null,
2537
+ Name
2538
+ >;
2539
+ deleteStreamAsync: FunctionReference<
2540
+ "mutation",
2541
+ "internal",
2542
+ { cursor?: string; streamId: string },
2543
+ null,
2544
+ Name
2545
+ >;
2546
+ deleteStreamSync: FunctionReference<
2547
+ "mutation",
2548
+ "internal",
2549
+ { streamId: string },
2550
+ null,
2551
+ Name
2552
+ >;
2553
+ finish: FunctionReference<
2554
+ "mutation",
2555
+ "internal",
2556
+ {
2557
+ finalDelta?: {
2558
+ end: number;
2559
+ parts: Array<any>;
2560
+ start: number;
2561
+ streamId: string;
2562
+ };
2563
+ streamId: string;
2564
+ },
2565
+ null,
2566
+ Name
2567
+ >;
2568
+ heartbeat: FunctionReference<
2569
+ "mutation",
2570
+ "internal",
2571
+ { streamId: string },
2572
+ null,
2573
+ Name
2574
+ >;
2575
+ list: FunctionReference<
2576
+ "query",
2577
+ "internal",
2578
+ {
2579
+ startOrder?: number;
2580
+ statuses?: Array<"streaming" | "finished" | "aborted">;
2581
+ threadId: string;
2582
+ },
2583
+ Array<{
2584
+ agentName?: string;
2585
+ format?: "UIMessageChunk" | "TextStreamPart";
2586
+ model?: string;
2587
+ order: number;
2588
+ provider?: string;
2589
+ providerOptions?: Record<string, Record<string, any>>;
2590
+ status: "streaming" | "finished" | "aborted";
2591
+ stepOrder: number;
2592
+ streamId: string;
2593
+ userId?: string;
2594
+ }>,
2595
+ Name
2596
+ >;
2597
+ listDeltas: FunctionReference<
2598
+ "query",
2599
+ "internal",
2600
+ {
2601
+ cursors: Array<{ cursor: number; streamId: string }>;
2602
+ threadId: string;
2603
+ },
2604
+ Array<{
2605
+ end: number;
2606
+ parts: Array<any>;
2607
+ start: number;
2608
+ streamId: string;
2609
+ }>,
2610
+ Name
2611
+ >;
2612
+ };
2613
+ threads: {
2614
+ createThread: FunctionReference<
2615
+ "mutation",
2616
+ "internal",
2617
+ {
2618
+ defaultSystemPrompt?: string;
2619
+ parentThreadIds?: Array<string>;
2620
+ summary?: string;
2621
+ title?: string;
2622
+ userId?: string;
2623
+ },
2624
+ {
2625
+ _creationTime: number;
2626
+ _id: string;
2627
+ status: "active" | "archived";
2628
+ summary?: string;
2629
+ title?: string;
2630
+ userId?: string;
2631
+ },
2632
+ Name
2633
+ >;
2634
+ deleteAllForThreadIdAsync: FunctionReference<
2635
+ "mutation",
2636
+ "internal",
2637
+ {
2638
+ cursor?: string;
2639
+ deltaCursor?: string;
2640
+ limit?: number;
2641
+ messagesDone?: boolean;
2642
+ streamOrder?: number;
2643
+ streamsDone?: boolean;
2644
+ threadId: string;
2645
+ },
2646
+ { isDone: boolean },
2647
+ Name
2648
+ >;
2649
+ deleteAllForThreadIdSync: FunctionReference<
2650
+ "action",
2651
+ "internal",
2652
+ { limit?: number; threadId: string },
2653
+ null,
2654
+ Name
2655
+ >;
2656
+ getThread: FunctionReference<
2657
+ "query",
2658
+ "internal",
2659
+ { threadId: string },
2660
+ {
2661
+ _creationTime: number;
2662
+ _id: string;
2663
+ status: "active" | "archived";
2664
+ summary?: string;
2665
+ title?: string;
2666
+ userId?: string;
2667
+ } | null,
2668
+ Name
2669
+ >;
2670
+ listThreadsByUserId: FunctionReference<
2671
+ "query",
2672
+ "internal",
2673
+ {
2674
+ order?: "asc" | "desc";
2675
+ paginationOpts?: {
2676
+ cursor: string | null;
2677
+ endCursor?: string | null;
2678
+ id?: number;
2679
+ maximumBytesRead?: number;
2680
+ maximumRowsRead?: number;
2681
+ numItems: number;
2682
+ };
2683
+ userId?: string;
2684
+ },
2685
+ {
2686
+ continueCursor: string;
2687
+ isDone: boolean;
2688
+ page: Array<{
2689
+ _creationTime: number;
2690
+ _id: string;
2691
+ status: "active" | "archived";
2692
+ summary?: string;
2693
+ title?: string;
2694
+ userId?: string;
2695
+ }>;
2696
+ pageStatus?: "SplitRecommended" | "SplitRequired" | null;
2697
+ splitCursor?: string | null;
2698
+ },
2699
+ Name
2700
+ >;
2701
+ searchThreadTitles: FunctionReference<
2702
+ "query",
2703
+ "internal",
2704
+ { limit: number; query: string; userId?: string | null },
2705
+ Array<{
2706
+ _creationTime: number;
2707
+ _id: string;
2708
+ status: "active" | "archived";
2709
+ summary?: string;
2710
+ title?: string;
2711
+ userId?: string;
2712
+ }>,
2713
+ Name
2714
+ >;
2715
+ updateThread: FunctionReference<
2716
+ "mutation",
2717
+ "internal",
2718
+ {
2719
+ patch: {
2720
+ status?: "active" | "archived";
2721
+ summary?: string;
2722
+ title?: string;
2723
+ userId?: string;
2724
+ };
2725
+ threadId: string;
2726
+ },
2727
+ {
2728
+ _creationTime: number;
2729
+ _id: string;
2730
+ status: "active" | "archived";
2731
+ summary?: string;
2732
+ title?: string;
2733
+ userId?: string;
2734
+ },
2735
+ Name
2736
+ >;
2737
+ };
2738
+ users: {
2739
+ deleteAllForUserId: FunctionReference<
2740
+ "action",
2741
+ "internal",
2742
+ { userId: string },
2743
+ null,
2744
+ Name
2745
+ >;
2746
+ deleteAllForUserIdAsync: FunctionReference<
2747
+ "mutation",
2748
+ "internal",
2749
+ { userId: string },
2750
+ boolean,
2751
+ Name
2752
+ >;
2753
+ listUsersWithThreads: FunctionReference<
2754
+ "query",
2755
+ "internal",
2756
+ {
2757
+ paginationOpts: {
2758
+ cursor: string | null;
2759
+ endCursor?: string | null;
2760
+ id?: number;
2761
+ maximumBytesRead?: number;
2762
+ maximumRowsRead?: number;
2763
+ numItems: number;
2764
+ };
2765
+ },
2766
+ {
2767
+ continueCursor: string;
2768
+ isDone: boolean;
2769
+ page: Array<string>;
2770
+ pageStatus?: "SplitRecommended" | "SplitRequired" | null;
2771
+ splitCursor?: string | null;
2772
+ },
2773
+ Name
2774
+ >;
2775
+ };
2776
+ vector: {
2777
+ index: {
2778
+ deleteBatch: FunctionReference<
2779
+ "mutation",
2780
+ "internal",
2781
+ {
2782
+ ids: Array<
2783
+ | string
2784
+ | string
2785
+ | string
2786
+ | string
2787
+ | string
2788
+ | string
2789
+ | string
2790
+ | string
2791
+ | string
2792
+ | string
2793
+ >;
2794
+ },
2795
+ null,
2796
+ Name
2797
+ >;
2798
+ deleteBatchForThread: FunctionReference<
2799
+ "mutation",
2800
+ "internal",
2801
+ {
2802
+ cursor?: string;
2803
+ limit: number;
2804
+ model: string;
2805
+ threadId: string;
2806
+ vectorDimension:
2807
+ | 128
2808
+ | 256
2809
+ | 512
2810
+ | 768
2811
+ | 1024
2812
+ | 1408
2813
+ | 1536
2814
+ | 2048
2815
+ | 3072
2816
+ | 4096;
2817
+ },
2818
+ { continueCursor: string; isDone: boolean },
2819
+ Name
2820
+ >;
2821
+ insertBatch: FunctionReference<
2822
+ "mutation",
2823
+ "internal",
2824
+ {
2825
+ vectorDimension:
2826
+ | 128
2827
+ | 256
2828
+ | 512
2829
+ | 768
2830
+ | 1024
2831
+ | 1408
2832
+ | 1536
2833
+ | 2048
2834
+ | 3072
2835
+ | 4096;
2836
+ vectors: Array<{
2837
+ messageId?: string;
2838
+ model: string;
2839
+ table: string;
2840
+ threadId?: string;
2841
+ userId?: string;
2842
+ vector: Array<number>;
2843
+ }>;
2844
+ },
2845
+ Array<
2846
+ | string
2847
+ | string
2848
+ | string
2849
+ | string
2850
+ | string
2851
+ | string
2852
+ | string
2853
+ | string
2854
+ | string
2855
+ | string
2856
+ >,
2857
+ Name
2858
+ >;
2859
+ paginate: FunctionReference<
2860
+ "query",
2861
+ "internal",
2862
+ {
2863
+ cursor?: string;
2864
+ limit: number;
2865
+ table?: string;
2866
+ targetModel: string;
2867
+ vectorDimension:
2868
+ | 128
2869
+ | 256
2870
+ | 512
2871
+ | 768
2872
+ | 1024
2873
+ | 1408
2874
+ | 1536
2875
+ | 2048
2876
+ | 3072
2877
+ | 4096;
2878
+ },
2879
+ {
2880
+ continueCursor: string;
2881
+ ids: Array<
2882
+ | string
2883
+ | string
2884
+ | string
2885
+ | string
2886
+ | string
2887
+ | string
2888
+ | string
2889
+ | string
2890
+ | string
2891
+ | string
2892
+ >;
2893
+ isDone: boolean;
2894
+ },
2895
+ Name
2896
+ >;
2897
+ updateBatch: FunctionReference<
2898
+ "mutation",
2899
+ "internal",
2900
+ {
2901
+ vectors: Array<{
2902
+ id:
2903
+ | string
2904
+ | string
2905
+ | string
2906
+ | string
2907
+ | string
2908
+ | string
2909
+ | string
2910
+ | string
2911
+ | string
2912
+ | string;
2913
+ model: string;
2914
+ vector: Array<number>;
2915
+ }>;
2916
+ },
2917
+ null,
2918
+ Name
2919
+ >;
2920
+ };
2921
+ };
2922
+ };