@convex-dev/agent 0.6.0 → 0.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (184) hide show
  1. package/dist/UIMessages.d.ts +46 -0
  2. package/dist/UIMessages.d.ts.map +1 -0
  3. package/dist/UIMessages.js +634 -0
  4. package/dist/UIMessages.js.map +1 -0
  5. package/dist/client/createTool.d.ts +167 -0
  6. package/dist/client/createTool.d.ts.map +1 -0
  7. package/dist/client/createTool.js +116 -0
  8. package/dist/client/createTool.js.map +1 -0
  9. package/dist/client/defaultComponent.d.ts +11 -0
  10. package/dist/client/defaultComponent.d.ts.map +1 -0
  11. package/dist/client/defaultComponent.js +7 -0
  12. package/dist/client/defaultComponent.js.map +1 -0
  13. package/dist/client/definePlaygroundAPI.d.ts +1725 -0
  14. package/dist/client/definePlaygroundAPI.d.ts.map +1 -0
  15. package/dist/client/definePlaygroundAPI.js +271 -0
  16. package/dist/client/definePlaygroundAPI.js.map +1 -0
  17. package/dist/client/files.d.ts +69 -0
  18. package/dist/client/files.d.ts.map +1 -0
  19. package/dist/client/files.js +181 -0
  20. package/dist/client/files.js.map +1 -0
  21. package/dist/client/index.d.ts +2091 -0
  22. package/dist/client/index.d.ts.map +1 -0
  23. package/dist/client/index.js +929 -0
  24. package/dist/client/index.js.map +1 -0
  25. package/dist/client/messages.d.ts +461 -0
  26. package/dist/client/messages.d.ts.map +1 -0
  27. package/dist/client/messages.js +106 -0
  28. package/dist/client/messages.js.map +1 -0
  29. package/dist/client/mockModel.d.ts +42 -0
  30. package/dist/client/mockModel.d.ts.map +1 -0
  31. package/dist/client/mockModel.js +182 -0
  32. package/dist/client/mockModel.js.map +1 -0
  33. package/dist/client/saveInputMessages.d.ts +20 -0
  34. package/dist/client/saveInputMessages.d.ts.map +1 -0
  35. package/dist/client/saveInputMessages.js +58 -0
  36. package/dist/client/saveInputMessages.js.map +1 -0
  37. package/dist/client/search.d.ts +493 -0
  38. package/dist/client/search.d.ts.map +1 -0
  39. package/dist/client/search.js +435 -0
  40. package/dist/client/search.js.map +1 -0
  41. package/dist/client/start.d.ts +84 -0
  42. package/dist/client/start.d.ts.map +1 -0
  43. package/dist/client/start.js +185 -0
  44. package/dist/client/start.js.map +1 -0
  45. package/dist/client/streamText.d.ts +46 -0
  46. package/dist/client/streamText.d.ts.map +1 -0
  47. package/dist/client/streamText.js +127 -0
  48. package/dist/client/streamText.js.map +1 -0
  49. package/dist/client/streaming.d.ts +3778 -0
  50. package/dist/client/streaming.d.ts.map +1 -0
  51. package/dist/client/streaming.js +330 -0
  52. package/dist/client/streaming.js.map +1 -0
  53. package/dist/client/threads.d.ts +46 -0
  54. package/dist/client/threads.d.ts.map +1 -0
  55. package/dist/client/threads.js +49 -0
  56. package/dist/client/threads.js.map +1 -0
  57. package/dist/client/types.d.ts +461 -0
  58. package/dist/client/types.d.ts.map +1 -0
  59. package/dist/client/types.js +2 -0
  60. package/dist/client/types.js.map +1 -0
  61. package/dist/client/utils.d.ts +4 -0
  62. package/dist/client/utils.d.ts.map +1 -0
  63. package/dist/client/utils.js +21 -0
  64. package/dist/client/utils.js.map +1 -0
  65. package/dist/component/_generated/api.d.ts +48 -0
  66. package/dist/component/_generated/api.d.ts.map +1 -0
  67. package/dist/component/_generated/api.js +31 -0
  68. package/dist/component/_generated/api.js.map +1 -0
  69. package/dist/component/_generated/component.d.ts +3120 -0
  70. package/dist/component/_generated/component.d.ts.map +1 -0
  71. package/dist/component/_generated/component.js +11 -0
  72. package/dist/component/_generated/component.js.map +1 -0
  73. package/dist/component/_generated/dataModel.d.ts +46 -0
  74. package/dist/component/_generated/dataModel.d.ts.map +1 -0
  75. package/dist/component/_generated/dataModel.js +11 -0
  76. package/dist/component/_generated/dataModel.js.map +1 -0
  77. package/dist/component/_generated/server.d.ts +121 -0
  78. package/dist/component/_generated/server.d.ts.map +1 -0
  79. package/dist/component/_generated/server.js +78 -0
  80. package/dist/component/_generated/server.js.map +1 -0
  81. package/dist/component/apiKeys.d.ts +11 -0
  82. package/dist/component/apiKeys.d.ts.map +1 -0
  83. package/dist/component/apiKeys.js +69 -0
  84. package/dist/component/apiKeys.js.map +1 -0
  85. package/dist/component/convex.config.d.ts +3 -0
  86. package/dist/component/convex.config.d.ts.map +1 -0
  87. package/dist/component/convex.config.js +3 -0
  88. package/dist/component/convex.config.js.map +1 -0
  89. package/dist/component/files.d.ts +97 -0
  90. package/dist/component/files.d.ts.map +1 -0
  91. package/dist/component/files.js +190 -0
  92. package/dist/component/files.js.map +1 -0
  93. package/dist/component/messages.d.ts +3851 -0
  94. package/dist/component/messages.d.ts.map +1 -0
  95. package/dist/component/messages.js +757 -0
  96. package/dist/component/messages.js.map +1 -0
  97. package/dist/component/schema.d.ts +8029 -0
  98. package/dist/component/schema.d.ts.map +1 -0
  99. package/dist/component/schema.js +147 -0
  100. package/dist/component/schema.js.map +1 -0
  101. package/dist/component/streams.d.ts +128 -0
  102. package/dist/component/streams.d.ts.map +1 -0
  103. package/dist/component/streams.js +413 -0
  104. package/dist/component/streams.js.map +1 -0
  105. package/dist/component/threads.d.ts +115 -0
  106. package/dist/component/threads.d.ts.map +1 -0
  107. package/dist/component/threads.js +208 -0
  108. package/dist/component/threads.js.map +1 -0
  109. package/dist/component/users.d.ts +52 -0
  110. package/dist/component/users.d.ts.map +1 -0
  111. package/dist/component/users.js +229 -0
  112. package/dist/component/users.js.map +1 -0
  113. package/dist/component/vector/index.d.ts +61 -0
  114. package/dist/component/vector/index.d.ts.map +1 -0
  115. package/dist/component/vector/index.js +146 -0
  116. package/dist/component/vector/index.js.map +1 -0
  117. package/dist/component/vector/tables.d.ts +58 -0
  118. package/dist/component/vector/tables.d.ts.map +1 -0
  119. package/dist/component/vector/tables.js +56 -0
  120. package/dist/component/vector/tables.js.map +1 -0
  121. package/dist/deltas.d.ts +43 -0
  122. package/dist/deltas.d.ts.map +1 -0
  123. package/dist/deltas.js +446 -0
  124. package/dist/deltas.js.map +1 -0
  125. package/dist/mapping.d.ts +76 -0
  126. package/dist/mapping.d.ts.map +1 -0
  127. package/dist/mapping.js +720 -0
  128. package/dist/mapping.js.map +1 -0
  129. package/dist/react/SmoothText.d.ts +5 -0
  130. package/dist/react/SmoothText.d.ts.map +1 -0
  131. package/dist/react/SmoothText.js +6 -0
  132. package/dist/react/SmoothText.js.map +1 -0
  133. package/dist/react/index.d.ts +25 -0
  134. package/dist/react/index.d.ts.map +1 -0
  135. package/dist/react/index.js +70 -0
  136. package/dist/react/index.js.map +1 -0
  137. package/dist/react/optimisticallySendMessage.d.ts +42 -0
  138. package/dist/react/optimisticallySendMessage.d.ts.map +1 -0
  139. package/dist/react/optimisticallySendMessage.js +74 -0
  140. package/dist/react/optimisticallySendMessage.js.map +1 -0
  141. package/dist/react/types.d.ts +12 -0
  142. package/dist/react/types.d.ts.map +1 -0
  143. package/dist/react/types.js +2 -0
  144. package/dist/react/types.js.map +1 -0
  145. package/dist/react/useDeltaStreams.d.ts +10 -0
  146. package/dist/react/useDeltaStreams.d.ts.map +1 -0
  147. package/dist/react/useDeltaStreams.js +106 -0
  148. package/dist/react/useDeltaStreams.js.map +1 -0
  149. package/dist/react/useSmoothText.d.ts +27 -0
  150. package/dist/react/useSmoothText.d.ts.map +1 -0
  151. package/dist/react/useSmoothText.js +68 -0
  152. package/dist/react/useSmoothText.js.map +1 -0
  153. package/dist/react/useStreamingUIMessages.d.ts +22 -0
  154. package/dist/react/useStreamingUIMessages.d.ts.map +1 -0
  155. package/dist/react/useStreamingUIMessages.js +92 -0
  156. package/dist/react/useStreamingUIMessages.js.map +1 -0
  157. package/dist/react/useThreadMessages.d.ts +104 -0
  158. package/dist/react/useThreadMessages.d.ts.map +1 -0
  159. package/dist/react/useThreadMessages.js +148 -0
  160. package/dist/react/useThreadMessages.js.map +1 -0
  161. package/dist/react/useUIMessages.d.ts +96 -0
  162. package/dist/react/useUIMessages.d.ts.map +1 -0
  163. package/dist/react/useUIMessages.js +108 -0
  164. package/dist/react/useUIMessages.js.map +1 -0
  165. package/dist/shared.d.ts +26 -0
  166. package/dist/shared.d.ts.map +1 -0
  167. package/dist/shared.js +67 -0
  168. package/dist/shared.js.map +1 -0
  169. package/dist/validators.d.ts +24516 -0
  170. package/dist/validators.d.ts.map +1 -0
  171. package/dist/validators.js +475 -0
  172. package/dist/validators.js.map +1 -0
  173. package/package.json +39 -39
  174. package/src/UIMessages.ts +0 -9
  175. package/src/client/approval.test.ts +144 -0
  176. package/src/client/index.ts +17 -9
  177. package/src/client/search.ts +0 -29
  178. package/src/client/start.ts +2 -2
  179. package/src/client/streamText.ts +9 -0
  180. package/src/client/streaming.ts +30 -23
  181. package/src/component/_generated/dataModel.ts +1 -1
  182. package/src/component/_generated/server.ts +0 -5
  183. package/src/mapping.ts +38 -22
  184. package/src/node_modules/.vite/vitest/da39a3ee5e6b4b0d3255bfef95601890afd80709/results.json +1 -0
@@ -0,0 +1,493 @@
1
+ import { type EmbeddingModel, type ModelMessage } from "ai";
2
+ import type { MessageDoc } from "../validators.js";
3
+ import { type VectorDimension } from "../component/vector/tables.js";
4
+ import type { Message } from "../validators.js";
5
+ import type { AgentComponent, Config, ContextOptions, Options, QueryCtx, MutationCtx, ActionCtx } from "./types.js";
6
+ export type GetEmbedding = (text: string) => Promise<{
7
+ embedding: number[];
8
+ /** @deprecated Use embeddingModel instead. */
9
+ textEmbeddingModel: string | EmbeddingModel;
10
+ embeddingModel?: string | EmbeddingModel;
11
+ } | {
12
+ embedding: number[];
13
+ /** @deprecated Use embeddingModel instead. */
14
+ textEmbeddingModel?: string | EmbeddingModel;
15
+ embeddingModel: string | EmbeddingModel;
16
+ }>;
17
+ /**
18
+ * Fetch the context messages for a thread.
19
+ * @param ctx Either a query, mutation, or action ctx.
20
+ * If it is not an action context, you can't do text or
21
+ * vector search.
22
+ * @param args The associated thread, user, message
23
+ * @returns
24
+ */
25
+ export declare function fetchContextMessages(ctx: QueryCtx | MutationCtx | ActionCtx, component: AgentComponent, args: {
26
+ userId: string | undefined;
27
+ threadId: string | undefined;
28
+ /**
29
+ * If targetMessageId is not provided, this text will be used
30
+ * for text and vector search
31
+ */
32
+ searchText?: string;
33
+ /**
34
+ * If provided, it will use this message for text/vector search (if enabled)
35
+ * and will only fetch messages up to (and including) this message's "order"
36
+ */
37
+ targetMessageId?: string;
38
+ /**
39
+ * @deprecated use searchText and targetMessageId instead
40
+ */
41
+ messages?: (ModelMessage | Message)[];
42
+ /**
43
+ * @deprecated use targetMessageId instead
44
+ */
45
+ upToAndIncludingMessageId?: string;
46
+ contextOptions: ContextOptions;
47
+ getEmbedding?: GetEmbedding;
48
+ }): Promise<MessageDoc[]>;
49
+ export declare function fetchRecentAndSearchMessages(ctx: QueryCtx | MutationCtx | ActionCtx, component: AgentComponent, args: {
50
+ userId: string | undefined;
51
+ threadId: string | undefined;
52
+ /**
53
+ * If targetMessageId is not provided, this text will be used
54
+ * for text and vector search
55
+ */
56
+ searchText?: string;
57
+ /**
58
+ * If provided, it will use this message for text/vector search (if enabled)
59
+ * and will only fetch messages up to (and including) this message's "order"
60
+ */
61
+ targetMessageId?: string;
62
+ /**
63
+ * @deprecated use searchText and targetMessageId instead
64
+ */
65
+ messages?: (ModelMessage | Message)[];
66
+ /**
67
+ * @deprecated use targetMessageId instead
68
+ */
69
+ upToAndIncludingMessageId?: string;
70
+ contextOptions: ContextOptions;
71
+ getEmbedding?: GetEmbedding;
72
+ }): Promise<{
73
+ recentMessages: MessageDoc[];
74
+ searchMessages: MessageDoc[];
75
+ }>;
76
+ /**
77
+ * Filter out tool messages that don't have both a tool call and response.
78
+ * For the approval workflow, tool calls with approval responses (but no tool-results yet)
79
+ * should also be kept.
80
+ * @param docs The messages to filter.
81
+ * @returns The filtered messages.
82
+ */
83
+ export declare function filterOutOrphanedToolMessages(docs: MessageDoc[]): {
84
+ id?: string | undefined;
85
+ userId?: string | undefined;
86
+ embeddingId?: string | undefined;
87
+ fileIds?: string[] | undefined;
88
+ error?: string | undefined;
89
+ agentName?: string | undefined;
90
+ model?: string | undefined;
91
+ provider?: string | undefined;
92
+ providerOptions?: Record<string, Record<string, any>> | undefined;
93
+ message?: {
94
+ providerOptions?: Record<string, Record<string, any>> | undefined;
95
+ role: "user";
96
+ content: string | ({
97
+ providerOptions?: Record<string, Record<string, any>> | undefined;
98
+ providerMetadata?: Record<string, Record<string, any>> | undefined;
99
+ type: "text";
100
+ text: string;
101
+ } | {
102
+ providerOptions?: Record<string, Record<string, any>> | undefined;
103
+ mediaType?: string | undefined;
104
+ mimeType?: string | undefined;
105
+ type: "image";
106
+ image: string | ArrayBuffer;
107
+ } | {
108
+ providerOptions?: Record<string, Record<string, any>> | undefined;
109
+ providerMetadata?: Record<string, Record<string, any>> | undefined;
110
+ mediaType?: string | undefined;
111
+ mimeType?: string | undefined;
112
+ filename?: string | undefined;
113
+ type: "file";
114
+ data: string | ArrayBuffer;
115
+ })[];
116
+ } | {
117
+ providerOptions?: Record<string, Record<string, any>> | undefined;
118
+ role: "assistant";
119
+ content: string | ({
120
+ providerOptions?: Record<string, Record<string, any>> | undefined;
121
+ providerMetadata?: Record<string, Record<string, any>> | undefined;
122
+ type: "text";
123
+ text: string;
124
+ } | {
125
+ providerOptions?: Record<string, Record<string, any>> | undefined;
126
+ providerMetadata?: Record<string, Record<string, any>> | undefined;
127
+ mediaType?: string | undefined;
128
+ mimeType?: string | undefined;
129
+ filename?: string | undefined;
130
+ type: "file";
131
+ data: string | ArrayBuffer;
132
+ } | {
133
+ providerOptions?: Record<string, Record<string, any>> | undefined;
134
+ providerMetadata?: Record<string, Record<string, any>> | undefined;
135
+ signature?: string | undefined;
136
+ type: "reasoning";
137
+ text: string;
138
+ } | {
139
+ providerOptions?: Record<string, Record<string, any>> | undefined;
140
+ providerMetadata?: Record<string, Record<string, any>> | undefined;
141
+ type: "redacted-reasoning";
142
+ data: string;
143
+ } | {
144
+ providerOptions?: Record<string, Record<string, any>> | undefined;
145
+ providerMetadata?: Record<string, Record<string, any>> | undefined;
146
+ args?: any;
147
+ providerExecuted?: boolean | undefined;
148
+ type: "tool-call";
149
+ toolCallId: string;
150
+ toolName: string;
151
+ input: any;
152
+ } | {
153
+ providerOptions?: Record<string, Record<string, any>> | undefined;
154
+ providerMetadata?: Record<string, Record<string, any>> | undefined;
155
+ input?: any;
156
+ providerExecuted?: boolean | undefined;
157
+ type: "tool-call";
158
+ toolCallId: string;
159
+ toolName: string;
160
+ args: any;
161
+ } | {
162
+ providerOptions?: Record<string, Record<string, any>> | undefined;
163
+ providerMetadata?: Record<string, Record<string, any>> | undefined;
164
+ args?: any;
165
+ providerExecuted?: boolean | undefined;
166
+ output?: {
167
+ providerOptions?: Record<string, Record<string, any>> | undefined;
168
+ type: "text";
169
+ value: string;
170
+ } | {
171
+ providerOptions?: Record<string, Record<string, any>> | undefined;
172
+ type: "json";
173
+ value: any;
174
+ } | {
175
+ providerOptions?: Record<string, Record<string, any>> | undefined;
176
+ type: "error-text";
177
+ value: string;
178
+ } | {
179
+ providerOptions?: Record<string, Record<string, any>> | undefined;
180
+ type: "error-json";
181
+ value: any;
182
+ } | {
183
+ providerOptions?: Record<string, Record<string, any>> | undefined;
184
+ reason?: string | undefined;
185
+ type: "execution-denied";
186
+ } | {
187
+ type: "content";
188
+ value: ({
189
+ providerOptions?: Record<string, Record<string, any>> | undefined;
190
+ type: "text";
191
+ text: string;
192
+ } | {
193
+ type: "media";
194
+ mediaType: string;
195
+ data: string;
196
+ } | {
197
+ providerOptions?: Record<string, Record<string, any>> | undefined;
198
+ filename?: string | undefined;
199
+ type: "file-data";
200
+ mediaType: string;
201
+ data: string;
202
+ } | {
203
+ providerOptions?: Record<string, Record<string, any>> | undefined;
204
+ type: "file-url";
205
+ url: string;
206
+ } | {
207
+ providerOptions?: Record<string, Record<string, any>> | undefined;
208
+ type: "file-id";
209
+ fileId: string | Record<string, string>;
210
+ } | {
211
+ providerOptions?: Record<string, Record<string, any>> | undefined;
212
+ type: "image-data";
213
+ mediaType: string;
214
+ data: string;
215
+ } | {
216
+ providerOptions?: Record<string, Record<string, any>> | undefined;
217
+ type: "image-url";
218
+ url: string;
219
+ } | {
220
+ providerOptions?: Record<string, Record<string, any>> | undefined;
221
+ type: "image-file-id";
222
+ fileId: string | Record<string, string>;
223
+ } | {
224
+ providerOptions?: Record<string, Record<string, any>> | undefined;
225
+ type: "custom";
226
+ })[];
227
+ } | undefined;
228
+ result?: any;
229
+ isError?: boolean | undefined;
230
+ experimental_content?: ({
231
+ type: "text";
232
+ text: string;
233
+ } | {
234
+ mimeType?: string | undefined;
235
+ type: "image";
236
+ data: string;
237
+ })[] | undefined;
238
+ type: "tool-result";
239
+ toolCallId: string;
240
+ toolName: string;
241
+ } | {
242
+ title?: string | undefined;
243
+ providerOptions?: Record<string, Record<string, any>> | undefined;
244
+ providerMetadata?: Record<string, Record<string, any>> | undefined;
245
+ id: string;
246
+ type: "source";
247
+ url: string;
248
+ sourceType: "url";
249
+ } | {
250
+ providerOptions?: Record<string, Record<string, any>> | undefined;
251
+ providerMetadata?: Record<string, Record<string, any>> | undefined;
252
+ filename?: string | undefined;
253
+ id: string;
254
+ title: string;
255
+ type: "source";
256
+ mediaType: string;
257
+ sourceType: "document";
258
+ } | {
259
+ providerOptions?: Record<string, Record<string, any>> | undefined;
260
+ providerMetadata?: Record<string, Record<string, any>> | undefined;
261
+ type: "tool-approval-request";
262
+ toolCallId: string;
263
+ approvalId: string;
264
+ })[];
265
+ } | {
266
+ providerOptions?: Record<string, Record<string, any>> | undefined;
267
+ role: "tool";
268
+ content: ({
269
+ providerOptions?: Record<string, Record<string, any>> | undefined;
270
+ providerMetadata?: Record<string, Record<string, any>> | undefined;
271
+ args?: any;
272
+ providerExecuted?: boolean | undefined;
273
+ output?: {
274
+ providerOptions?: Record<string, Record<string, any>> | undefined;
275
+ type: "text";
276
+ value: string;
277
+ } | {
278
+ providerOptions?: Record<string, Record<string, any>> | undefined;
279
+ type: "json";
280
+ value: any;
281
+ } | {
282
+ providerOptions?: Record<string, Record<string, any>> | undefined;
283
+ type: "error-text";
284
+ value: string;
285
+ } | {
286
+ providerOptions?: Record<string, Record<string, any>> | undefined;
287
+ type: "error-json";
288
+ value: any;
289
+ } | {
290
+ providerOptions?: Record<string, Record<string, any>> | undefined;
291
+ reason?: string | undefined;
292
+ type: "execution-denied";
293
+ } | {
294
+ type: "content";
295
+ value: ({
296
+ providerOptions?: Record<string, Record<string, any>> | undefined;
297
+ type: "text";
298
+ text: string;
299
+ } | {
300
+ type: "media";
301
+ mediaType: string;
302
+ data: string;
303
+ } | {
304
+ providerOptions?: Record<string, Record<string, any>> | undefined;
305
+ filename?: string | undefined;
306
+ type: "file-data";
307
+ mediaType: string;
308
+ data: string;
309
+ } | {
310
+ providerOptions?: Record<string, Record<string, any>> | undefined;
311
+ type: "file-url";
312
+ url: string;
313
+ } | {
314
+ providerOptions?: Record<string, Record<string, any>> | undefined;
315
+ type: "file-id";
316
+ fileId: string | Record<string, string>;
317
+ } | {
318
+ providerOptions?: Record<string, Record<string, any>> | undefined;
319
+ type: "image-data";
320
+ mediaType: string;
321
+ data: string;
322
+ } | {
323
+ providerOptions?: Record<string, Record<string, any>> | undefined;
324
+ type: "image-url";
325
+ url: string;
326
+ } | {
327
+ providerOptions?: Record<string, Record<string, any>> | undefined;
328
+ type: "image-file-id";
329
+ fileId: string | Record<string, string>;
330
+ } | {
331
+ providerOptions?: Record<string, Record<string, any>> | undefined;
332
+ type: "custom";
333
+ })[];
334
+ } | undefined;
335
+ result?: any;
336
+ isError?: boolean | undefined;
337
+ experimental_content?: ({
338
+ type: "text";
339
+ text: string;
340
+ } | {
341
+ mimeType?: string | undefined;
342
+ type: "image";
343
+ data: string;
344
+ })[] | undefined;
345
+ type: "tool-result";
346
+ toolCallId: string;
347
+ toolName: string;
348
+ } | {
349
+ providerOptions?: Record<string, Record<string, any>> | undefined;
350
+ providerMetadata?: Record<string, Record<string, any>> | undefined;
351
+ providerExecuted?: boolean | undefined;
352
+ reason?: string | undefined;
353
+ type: "tool-approval-response";
354
+ approvalId: string;
355
+ approved: boolean;
356
+ })[];
357
+ } | {
358
+ providerOptions?: Record<string, Record<string, any>> | undefined;
359
+ role: "system";
360
+ content: string;
361
+ } | undefined;
362
+ text?: string | undefined;
363
+ providerMetadata?: Record<string, Record<string, any>> | undefined;
364
+ reasoning?: string | undefined;
365
+ usage?: {
366
+ reasoningTokens?: number | undefined;
367
+ cachedInputTokens?: number | undefined;
368
+ promptTokens: number;
369
+ completionTokens: number;
370
+ totalTokens: number;
371
+ } | undefined;
372
+ sources?: ({
373
+ title?: string | undefined;
374
+ type?: "source" | undefined;
375
+ providerOptions?: Record<string, Record<string, any>> | undefined;
376
+ providerMetadata?: Record<string, Record<string, any>> | undefined;
377
+ id: string;
378
+ url: string;
379
+ sourceType: "url";
380
+ } | {
381
+ providerOptions?: Record<string, Record<string, any>> | undefined;
382
+ providerMetadata?: Record<string, Record<string, any>> | undefined;
383
+ filename?: string | undefined;
384
+ id: string;
385
+ title: string;
386
+ type: "source";
387
+ mediaType: string;
388
+ sourceType: "document";
389
+ })[] | undefined;
390
+ warnings?: ({
391
+ details?: string | undefined;
392
+ type: "unsupported-setting";
393
+ setting: string;
394
+ } | {
395
+ details?: string | undefined;
396
+ type: "unsupported-tool";
397
+ tool: any;
398
+ } | {
399
+ type: "other";
400
+ message: string;
401
+ })[] | undefined;
402
+ finishReason?: "error" | "length" | "other" | "stop" | "content-filter" | "tool-calls" | "unknown" | undefined;
403
+ reasoningDetails?: ({
404
+ providerOptions?: Record<string, Record<string, any>> | undefined;
405
+ providerMetadata?: Record<string, Record<string, any>> | undefined;
406
+ signature?: string | undefined;
407
+ type: "reasoning";
408
+ text: string;
409
+ } | {
410
+ signature?: string | undefined;
411
+ type: "text";
412
+ text: string;
413
+ } | {
414
+ type: "redacted";
415
+ data: string;
416
+ })[] | undefined;
417
+ status: "pending" | "success" | "failed";
418
+ order: number;
419
+ _creationTime: number;
420
+ threadId: string;
421
+ stepOrder: number;
422
+ tool: boolean;
423
+ _id: string;
424
+ }[];
425
+ /**
426
+ * Embed a list of messages, including calling any usage handler.
427
+ * This will not save the embeddings to the database.
428
+ */
429
+ export declare function embedMessages(ctx: ActionCtx, { userId, threadId, ...options }: {
430
+ userId: string | undefined;
431
+ threadId: string | undefined;
432
+ agentName?: string;
433
+ } & Pick<Config, "usageHandler" | "textEmbeddingModel" | "embeddingModel" | "callSettings">, messages: (ModelMessage | Message)[]): Promise<{
434
+ vectors: (number[] | null)[];
435
+ dimension: VectorDimension;
436
+ model: string;
437
+ } | undefined>;
438
+ /**
439
+ * Embeds many strings, calling any usage handler.
440
+ * @param ctx The ctx parameter to an action.
441
+ * @param args Arguments to AI SDK's embedMany, and context for the embedding,
442
+ * passed to the usage handler.
443
+ * @returns The embeddings for the strings, matching the order of the values.
444
+ */
445
+ export declare function embedMany(ctx: ActionCtx, args: {
446
+ userId: string | undefined;
447
+ threadId: string | undefined;
448
+ values: string[];
449
+ abortSignal?: AbortSignal;
450
+ headers?: Record<string, string>;
451
+ agentName?: string;
452
+ } & Pick<Config, "usageHandler" | "textEmbeddingModel" | "embeddingModel" | "callSettings">): Promise<{
453
+ embeddings: number[][];
454
+ }>;
455
+ /**
456
+ * Embed a list of messages, and save the embeddings to the database.
457
+ * @param ctx The ctx parameter to an action.
458
+ * @param component The agent component, usually components.agent.
459
+ * @param args The context for the embedding, passed to the usage handler.
460
+ * @param messages The messages to embed, in the Agent MessageDoc format.
461
+ */
462
+ export declare function generateAndSaveEmbeddings(ctx: ActionCtx, component: AgentComponent, args: {
463
+ threadId: string | undefined;
464
+ userId: string | undefined;
465
+ agentName?: string;
466
+ /**
467
+ * @deprecated Use embeddingModel instead.
468
+ */
469
+ textEmbeddingModel?: EmbeddingModel;
470
+ embeddingModel?: EmbeddingModel;
471
+ } & Pick<Config, "usageHandler" | "callSettings">, messages: MessageDoc[]): Promise<void>;
472
+ /**
473
+ * Similar to fetchContextMessages, but also combines the input messages,
474
+ * with search context, recent messages, input messages, then prompt messages.
475
+ * If there is a promptMessageId and prompt message(s) provided, it will splice
476
+ * the prompt messages into the history to replace the promptMessageId message,
477
+ * but still be followed by any existing messages that were in response to the
478
+ * promptMessageId message.
479
+ */
480
+ export declare function fetchContextWithPrompt(ctx: ActionCtx, component: AgentComponent, args: {
481
+ prompt: string | (ModelMessage | Message)[] | undefined;
482
+ messages: (ModelMessage | Message)[] | undefined;
483
+ promptMessageId: string | undefined;
484
+ userId: string | undefined;
485
+ threadId: string | undefined;
486
+ agentName?: string;
487
+ } & Options & Config): Promise<{
488
+ messages: ModelMessage[];
489
+ order: number | undefined;
490
+ stepOrder: number | undefined;
491
+ }>;
492
+ export declare function getPromptArray(prompt: string | (ModelMessage | Message)[] | undefined): (ModelMessage | Message)[];
493
+ //# sourceMappingURL=search.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"search.d.ts","sourceRoot":"","sources":["../../src/client/search.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,cAAc,EACnB,KAAK,YAAY,EAClB,MAAM,IAAI,CAAC;AAEZ,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAEL,KAAK,eAAe,EACrB,MAAM,+BAA+B,CAAC;AAUvC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,KAAK,EACV,cAAc,EACd,MAAM,EACN,cAAc,EACd,OAAO,EACP,QAAQ,EACR,WAAW,EACX,SAAS,EACV,MAAM,YAAY,CAAC;AAapB,MAAM,MAAM,YAAY,GAAG,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAChD;IACE,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,8CAA8C;IAC9C,kBAAkB,EAAE,MAAM,GAAG,cAAc,CAAC;IAC5C,cAAc,CAAC,EAAE,MAAM,GAAG,cAAc,CAAC;CAC1C,GACD;IACE,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,8CAA8C;IAC9C,kBAAkB,CAAC,EAAE,MAAM,GAAG,cAAc,CAAC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