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