@convex-dev/agent 0.5.0-alpha.1 → 0.6.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (233) hide show
  1. package/README.md +32 -27
  2. package/dist/UIMessages.d.ts +46 -0
  3. package/dist/UIMessages.d.ts.map +1 -0
  4. package/dist/UIMessages.js +546 -0
  5. package/dist/UIMessages.js.map +1 -0
  6. package/dist/client/createTool.d.ts +129 -27
  7. package/dist/client/createTool.d.ts.map +1 -1
  8. package/dist/client/createTool.js +66 -12
  9. package/dist/client/createTool.js.map +1 -1
  10. package/dist/client/defaultComponent.d.ts +11 -0
  11. package/dist/client/defaultComponent.d.ts.map +1 -0
  12. package/dist/client/defaultComponent.js +7 -0
  13. package/dist/client/defaultComponent.js.map +1 -0
  14. package/dist/client/definePlaygroundAPI.d.ts +1323 -192
  15. package/dist/client/definePlaygroundAPI.d.ts.map +1 -1
  16. package/dist/client/definePlaygroundAPI.js +52 -28
  17. package/dist/client/definePlaygroundAPI.js.map +1 -1
  18. package/dist/client/files.d.ts +20 -7
  19. package/dist/client/files.d.ts.map +1 -1
  20. package/dist/client/files.js +68 -11
  21. package/dist/client/files.js.map +1 -1
  22. package/dist/client/index.d.ts +1056 -965
  23. package/dist/client/index.d.ts.map +1 -1
  24. package/dist/client/index.js +242 -748
  25. package/dist/client/index.js.map +1 -1
  26. package/dist/client/messages.d.ts +461 -0
  27. package/dist/client/messages.d.ts.map +1 -0
  28. package/dist/client/messages.js +106 -0
  29. package/dist/client/messages.js.map +1 -0
  30. package/dist/client/mockModel.d.ts +42 -0
  31. package/dist/client/mockModel.d.ts.map +1 -0
  32. package/dist/client/mockModel.js +175 -0
  33. package/dist/client/mockModel.js.map +1 -0
  34. package/dist/client/saveInputMessages.d.ts +20 -0
  35. package/dist/client/saveInputMessages.d.ts.map +1 -0
  36. package/dist/client/saveInputMessages.js +58 -0
  37. package/dist/client/saveInputMessages.js.map +1 -0
  38. package/dist/client/search.d.ts +346 -35
  39. package/dist/client/search.d.ts.map +1 -1
  40. package/dist/client/search.js +350 -39
  41. package/dist/client/search.js.map +1 -1
  42. package/dist/client/start.d.ts +84 -0
  43. package/dist/client/start.d.ts.map +1 -0
  44. package/dist/client/start.js +171 -0
  45. package/dist/client/start.js.map +1 -0
  46. package/dist/client/streamText.d.ts +46 -0
  47. package/dist/client/streamText.d.ts.map +1 -0
  48. package/dist/client/streamText.js +93 -0
  49. package/dist/client/streamText.js.map +1 -0
  50. package/dist/client/streaming.d.ts +3705 -32
  51. package/dist/client/streaming.d.ts.map +1 -1
  52. package/dist/client/streaming.js +141 -59
  53. package/dist/client/streaming.js.map +1 -1
  54. package/dist/client/threads.d.ts +46 -0
  55. package/dist/client/threads.d.ts.map +1 -0
  56. package/dist/client/threads.js +49 -0
  57. package/dist/client/threads.js.map +1 -0
  58. package/dist/client/types.d.ts +265 -128
  59. package/dist/client/types.d.ts.map +1 -1
  60. package/dist/client/utils.d.ts +4 -0
  61. package/dist/client/utils.d.ts.map +1 -0
  62. package/dist/client/utils.js +21 -0
  63. package/dist/client/utils.js.map +1 -0
  64. package/dist/component/_generated/api.d.ts +24 -2178
  65. package/dist/component/_generated/api.d.ts.map +1 -1
  66. package/dist/component/_generated/api.js +10 -1
  67. package/dist/component/_generated/api.js.map +1 -1
  68. package/dist/component/_generated/component.d.ts +3119 -0
  69. package/dist/component/_generated/component.d.ts.map +1 -0
  70. package/dist/component/_generated/component.js +11 -0
  71. package/dist/component/_generated/component.js.map +1 -0
  72. package/dist/component/_generated/dataModel.d.ts +4 -18
  73. package/dist/component/_generated/dataModel.d.ts.map +1 -0
  74. package/dist/component/_generated/dataModel.js +11 -0
  75. package/dist/component/_generated/dataModel.js.map +1 -0
  76. package/dist/component/_generated/server.d.ts +10 -38
  77. package/dist/component/_generated/server.d.ts.map +1 -1
  78. package/dist/component/_generated/server.js +9 -5
  79. package/dist/component/_generated/server.js.map +1 -1
  80. package/dist/component/files.d.ts +16 -10
  81. package/dist/component/files.d.ts.map +1 -1
  82. package/dist/component/files.js +10 -2
  83. package/dist/component/files.js.map +1 -1
  84. package/dist/component/messages.d.ts +2553 -342
  85. package/dist/component/messages.d.ts.map +1 -1
  86. package/dist/component/messages.js +387 -154
  87. package/dist/component/messages.js.map +1 -1
  88. package/dist/component/schema.d.ts +5697 -3584
  89. package/dist/component/schema.d.ts.map +1 -1
  90. package/dist/component/schema.js +18 -41
  91. package/dist/component/schema.js.map +1 -1
  92. package/dist/component/streams.d.ts +35 -335
  93. package/dist/component/streams.d.ts.map +1 -1
  94. package/dist/component/streams.js +114 -73
  95. package/dist/component/streams.js.map +1 -1
  96. package/dist/component/threads.d.ts +16 -16
  97. package/dist/component/users.d.ts +4 -4
  98. package/dist/component/vector/index.d.ts +1 -1
  99. package/dist/component/vector/index.d.ts.map +1 -1
  100. package/dist/component/vector/index.js +1 -3
  101. package/dist/component/vector/index.js.map +1 -1
  102. package/dist/deltas.d.ts +43 -0
  103. package/dist/deltas.d.ts.map +1 -0
  104. package/dist/deltas.js +447 -0
  105. package/dist/deltas.js.map +1 -0
  106. package/dist/mapping.d.ts +20 -20
  107. package/dist/mapping.d.ts.map +1 -1
  108. package/dist/mapping.js +313 -96
  109. package/dist/mapping.js.map +1 -1
  110. package/dist/react/SmoothText.d.ts +5 -0
  111. package/dist/react/SmoothText.d.ts.map +1 -0
  112. package/dist/react/SmoothText.js +6 -0
  113. package/dist/react/SmoothText.js.map +1 -0
  114. package/dist/react/index.d.ts +5 -77
  115. package/dist/react/index.d.ts.map +1 -1
  116. package/dist/react/index.js +6 -160
  117. package/dist/react/index.js.map +1 -1
  118. package/dist/react/optimisticallySendMessage.d.ts +36 -3
  119. package/dist/react/optimisticallySendMessage.d.ts.map +1 -1
  120. package/dist/react/optimisticallySendMessage.js +35 -9
  121. package/dist/react/optimisticallySendMessage.js.map +1 -1
  122. package/dist/react/types.d.ts +4 -18
  123. package/dist/react/types.d.ts.map +1 -1
  124. package/dist/react/useDeltaStreams.d.ts +10 -0
  125. package/dist/react/useDeltaStreams.d.ts.map +1 -0
  126. package/dist/react/useDeltaStreams.js +101 -0
  127. package/dist/react/useDeltaStreams.js.map +1 -0
  128. package/dist/react/useSmoothText.d.ts +13 -12
  129. package/dist/react/useSmoothText.d.ts.map +1 -1
  130. package/dist/react/useSmoothText.js +32 -15
  131. package/dist/react/useSmoothText.js.map +1 -1
  132. package/dist/react/useStreamingUIMessages.d.ts +22 -0
  133. package/dist/react/useStreamingUIMessages.d.ts.map +1 -0
  134. package/dist/react/useStreamingUIMessages.js +92 -0
  135. package/dist/react/useStreamingUIMessages.js.map +1 -0
  136. package/dist/react/useThreadMessages.d.ts +104 -0
  137. package/dist/react/useThreadMessages.d.ts.map +1 -0
  138. package/dist/react/useThreadMessages.js +148 -0
  139. package/dist/react/useThreadMessages.js.map +1 -0
  140. package/dist/react/useUIMessages.d.ts +96 -0
  141. package/dist/react/useUIMessages.d.ts.map +1 -0
  142. package/dist/react/useUIMessages.js +108 -0
  143. package/dist/react/useUIMessages.js.map +1 -0
  144. package/dist/shared.d.ts +20 -4
  145. package/dist/shared.d.ts.map +1 -1
  146. package/dist/shared.js +45 -8
  147. package/dist/shared.js.map +1 -1
  148. package/dist/validators.d.ts +22981 -5666
  149. package/dist/validators.d.ts.map +1 -1
  150. package/dist/validators.js +245 -137
  151. package/dist/validators.js.map +1 -1
  152. package/package.json +98 -50
  153. package/src/UIMessages.combineUIMessages.test.ts +239 -0
  154. package/src/UIMessages.test.ts +273 -0
  155. package/src/UIMessages.ts +739 -0
  156. package/src/client/createTool.ts +293 -76
  157. package/src/client/defaultComponent.ts +17 -0
  158. package/src/client/definePlaygroundAPI.ts +67 -31
  159. package/src/client/files.ts +100 -20
  160. package/src/client/index.test.ts +40 -85
  161. package/src/client/index.ts +520 -1290
  162. package/src/client/messages.ts +237 -0
  163. package/src/client/mockModel.ts +245 -0
  164. package/src/client/saveInputMessages.test.ts +583 -0
  165. package/src/client/saveInputMessages.ts +101 -0
  166. package/src/client/search.test.ts +1207 -0
  167. package/src/client/search.ts +577 -70
  168. package/src/client/start.ts +310 -0
  169. package/src/client/streamText.ts +163 -0
  170. package/src/client/streaming.test.ts +186 -0
  171. package/src/client/streaming.ts +219 -97
  172. package/src/client/threads.ts +83 -0
  173. package/src/client/types.ts +368 -219
  174. package/src/client/utils.ts +27 -0
  175. package/src/component/_generated/api.ts +64 -0
  176. package/src/component/_generated/component.ts +4913 -0
  177. package/src/component/_generated/{server.d.ts → server.ts} +33 -21
  178. package/src/component/files.ts +11 -2
  179. package/src/component/messages.test.ts +195 -51
  180. package/src/component/messages.ts +490 -201
  181. package/src/component/schema.ts +20 -46
  182. package/src/component/setup.test.ts +7 -0
  183. package/src/component/streams.ts +184 -83
  184. package/src/component/users.test.ts +0 -1
  185. package/src/component/vector/index.ts +1 -3
  186. package/src/deltas.test.ts +626 -0
  187. package/src/deltas.ts +570 -0
  188. package/src/fromUIMessages.test.ts +497 -0
  189. package/src/mapping.test.ts +103 -6
  190. package/src/mapping.ts +422 -161
  191. package/src/react/SmoothText.tsx +9 -0
  192. package/src/react/index.ts +10 -230
  193. package/src/react/optimisticallySendMessage.ts +55 -12
  194. package/src/react/types.ts +6 -39
  195. package/src/react/useDeltaStreams.ts +154 -0
  196. package/src/react/useSmoothText.ts +56 -36
  197. package/src/react/useStreamingUIMessages.ts +143 -0
  198. package/src/react/useThreadMessages.ts +262 -0
  199. package/src/react/useUIMessages.test.ts +255 -0
  200. package/src/react/useUIMessages.ts +195 -0
  201. package/src/shared.ts +88 -12
  202. package/src/test.ts +18 -0
  203. package/src/toUIMessages.test.ts +1269 -0
  204. package/src/validators.test.ts +18 -19
  205. package/src/validators.ts +325 -185
  206. package/dist/client/_generated/_ignore.d.ts +0 -1
  207. package/dist/client/_generated/_ignore.d.ts.map +0 -1
  208. package/dist/client/_generated/_ignore.js +0 -3
  209. package/dist/client/_generated/_ignore.js.map +0 -1
  210. package/dist/client/listMessages.d.ts +0 -22
  211. package/dist/client/listMessages.d.ts.map +0 -1
  212. package/dist/client/listMessages.js +0 -25
  213. package/dist/client/listMessages.js.map +0 -1
  214. package/dist/package.json +0 -3
  215. package/dist/react/deltas.d.ts +0 -26
  216. package/dist/react/deltas.d.ts.map +0 -1
  217. package/dist/react/deltas.js +0 -384
  218. package/dist/react/deltas.js.map +0 -1
  219. package/dist/react/toUIMessages.d.ts +0 -15
  220. package/dist/react/toUIMessages.d.ts.map +0 -1
  221. package/dist/react/toUIMessages.js +0 -211
  222. package/dist/react/toUIMessages.js.map +0 -1
  223. package/src/client/listMessages.ts +0 -38
  224. package/src/component/_generated/api.d.ts +0 -2202
  225. package/src/component/_generated/api.js +0 -23
  226. package/src/component/_generated/server.js +0 -90
  227. package/src/node_modules/.vite/vitest/da39a3ee5e6b4b0d3255bfef95601890afd80709/results.json +0 -1
  228. package/src/react/deltas.test.ts +0 -315
  229. package/src/react/deltas.ts +0 -478
  230. package/src/react/toUIMessages.test.ts +0 -420
  231. package/src/react/toUIMessages.ts +0 -253
  232. package/src/vitest.config.ts +0 -7
  233. /package/src/component/_generated/{dataModel.d.ts → dataModel.ts} +0 -0
@@ -1,10 +1,18 @@
1
- import type { AgentComponent, ContextOptions, RunActionCtx, RunQueryCtx } from "./types.js";
2
- import type { MessageDoc } from "../component/schema.js";
3
- import type { ModelMessage } from "ai";
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
4
  import type { Message } from "../validators.js";
5
+ import type { AgentComponent, Config, ContextOptions, Options, QueryCtx, MutationCtx, ActionCtx } from "./types.js";
5
6
  export type GetEmbedding = (text: string) => Promise<{
6
7
  embedding: number[];
7
- embeddingModel: string;
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;
8
16
  }>;
9
17
  /**
10
18
  * Fetch the context messages for a thread.
@@ -14,21 +22,61 @@ export type GetEmbedding = (text: string) => Promise<{
14
22
  * @param args The associated thread, user, message
15
23
  * @returns
16
24
  */
17
- export declare function fetchContextMessages(ctx: RunQueryCtx | RunActionCtx, component: AgentComponent, args: {
25
+ export declare function fetchContextMessages(ctx: QueryCtx | MutationCtx | ActionCtx, component: AgentComponent, args: {
18
26
  userId: string | undefined;
19
27
  threadId: string | undefined;
20
- messages: (ModelMessage | Message)[];
21
28
  /**
22
- * If provided, it will search for messages up to and including this message.
23
- * Note: if this is far in the past, text and vector search results may be more
24
- * limited, as it's post-filtering the results.
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
25
44
  */
26
45
  upToAndIncludingMessageId?: string;
27
46
  contextOptions: ContextOptions;
28
47
  getEmbedding?: GetEmbedding;
29
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
+ }>;
30
76
  /**
31
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.
32
80
  * @param docs The messages to filter.
33
81
  * @returns The filtered messages.
34
82
  */
@@ -47,18 +95,22 @@ export declare function filterOutOrphanedToolMessages(docs: MessageDoc[]): {
47
95
  role: "user";
48
96
  content: string | ({
49
97
  providerOptions?: Record<string, Record<string, any>> | undefined;
98
+ providerMetadata?: Record<string, Record<string, any>> | undefined;
50
99
  type: "text";
51
100
  text: string;
52
101
  } | {
53
102
  providerOptions?: Record<string, Record<string, any>> | undefined;
103
+ mediaType?: string | undefined;
54
104
  mimeType?: string | undefined;
55
105
  type: "image";
56
106
  image: string | ArrayBuffer;
57
107
  } | {
58
108
  providerOptions?: Record<string, Record<string, any>> | undefined;
109
+ providerMetadata?: Record<string, Record<string, any>> | undefined;
110
+ mediaType?: string | undefined;
111
+ mimeType?: string | undefined;
59
112
  filename?: string | undefined;
60
113
  type: "file";
61
- mimeType: string;
62
114
  data: string | ArrayBuffer;
63
115
  })[];
64
116
  } | {
@@ -66,39 +118,221 @@ export declare function filterOutOrphanedToolMessages(docs: MessageDoc[]): {
66
118
  role: "assistant";
67
119
  content: string | ({
68
120
  providerOptions?: Record<string, Record<string, any>> | undefined;
121
+ providerMetadata?: Record<string, Record<string, any>> | undefined;
69
122
  type: "text";
70
123
  text: string;
71
124
  } | {
72
125
  providerOptions?: Record<string, Record<string, any>> | undefined;
126
+ providerMetadata?: Record<string, Record<string, any>> | undefined;
127
+ mediaType?: string | undefined;
128
+ mimeType?: string | undefined;
73
129
  filename?: string | undefined;
74
130
  type: "file";
75
- mimeType: string;
76
131
  data: string | ArrayBuffer;
77
132
  } | {
78
133
  providerOptions?: Record<string, Record<string, any>> | undefined;
134
+ providerMetadata?: Record<string, Record<string, any>> | undefined;
79
135
  signature?: string | undefined;
80
- state?: "streaming" | "done" | undefined;
81
136
  type: "reasoning";
82
137
  text: string;
83
138
  } | {
84
139
  providerOptions?: Record<string, Record<string, any>> | undefined;
140
+ providerMetadata?: Record<string, Record<string, any>> | undefined;
85
141
  type: "redacted-reasoning";
86
142
  data: string;
87
143
  } | {
88
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;
89
156
  providerExecuted?: boolean | undefined;
90
157
  type: "tool-call";
91
158
  toolCallId: string;
92
159
  toolName: string;
93
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;
94
264
  })[];
95
265
  } | {
96
266
  providerOptions?: Record<string, Record<string, any>> | undefined;
97
267
  role: "tool";
98
- content: {
268
+ content: ({
99
269
  providerOptions?: Record<string, Record<string, any>> | undefined;
270
+ providerMetadata?: Record<string, Record<string, any>> | undefined;
100
271
  args?: any;
101
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;
102
336
  isError?: boolean | undefined;
103
337
  experimental_content?: ({
104
338
  type: "text";
@@ -111,14 +345,22 @@ export declare function filterOutOrphanedToolMessages(docs: MessageDoc[]): {
111
345
  type: "tool-result";
112
346
  toolCallId: string;
113
347
  toolName: string;
114
- result: any;
115
- }[];
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
+ })[];
116
357
  } | {
117
358
  providerOptions?: Record<string, Record<string, any>> | undefined;
118
359
  role: "system";
119
360
  content: string;
120
361
  } | undefined;
121
362
  text?: string | undefined;
363
+ providerMetadata?: Record<string, Record<string, any>> | undefined;
122
364
  reasoning?: string | undefined;
123
365
  usage?: {
124
366
  reasoningTokens?: number | undefined;
@@ -127,27 +369,41 @@ export declare function filterOutOrphanedToolMessages(docs: MessageDoc[]): {
127
369
  completionTokens: number;
128
370
  totalTokens: number;
129
371
  } | undefined;
130
- providerMetadata?: Record<string, Record<string, any>> | undefined;
131
372
  sources?: ({
132
373
  title?: string | undefined;
133
374
  type?: "source" | undefined;
134
375
  providerOptions?: Record<string, Record<string, any>> | undefined;
135
- url?: string | undefined;
376
+ providerMetadata?: Record<string, Record<string, any>> | undefined;
136
377
  id: string;
378
+ url: string;
137
379
  sourceType: "url";
138
380
  } | {
139
- filename?: string | undefined;
381
+ providerOptions?: Record<string, Record<string, any>> | undefined;
140
382
  providerMetadata?: Record<string, Record<string, any>> | undefined;
383
+ filename?: string | undefined;
141
384
  id: string;
142
385
  title: string;
143
386
  type: "source";
144
- sourceType: "document";
145
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;
146
401
  })[] | undefined;
402
+ finishReason?: "error" | "length" | "other" | "stop" | "content-filter" | "tool-calls" | "unknown" | undefined;
147
403
  reasoningDetails?: ({
148
404
  providerOptions?: Record<string, Record<string, any>> | undefined;
405
+ providerMetadata?: Record<string, Record<string, any>> | undefined;
149
406
  signature?: string | undefined;
150
- state?: "streaming" | "done" | undefined;
151
407
  type: "reasoning";
152
408
  text: string;
153
409
  } | {
@@ -158,25 +414,80 @@ export declare function filterOutOrphanedToolMessages(docs: MessageDoc[]): {
158
414
  type: "redacted";
159
415
  data: string;
160
416
  })[] | undefined;
161
- warnings?: ({
162
- details?: string | undefined;
163
- type: "unsupported-setting";
164
- setting: string;
165
- } | {
166
- details?: string | undefined;
167
- type: "unsupported-tool";
168
- tool: any;
169
- } | {
170
- type: "other";
171
- message: string;
172
- })[] | undefined;
173
- finishReason?: "length" | "error" | "other" | "stop" | "content-filter" | "tool-calls" | "unknown" | undefined;
174
- _id: string;
175
- _creationTime: number;
176
417
  status: "pending" | "success" | "failed";
177
418
  order: number;
419
+ _creationTime: number;
178
420
  threadId: string;
179
421
  stepOrder: number;
180
422
  tool: boolean;
423
+ _id: string;
181
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)[];
182
493
  //# sourceMappingURL=search.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"search.d.ts","sourceRoot":"","sources":["../../src/client/search.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,cAAc,EACd,YAAY,EACZ,WAAW,EACZ,MAAM,YAAY,CAAC;AACpB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,IAAI,CAAC;AAOvC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAIhD,MAAM,MAAM,YAAY,GAAG,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC;IACnD,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,cAAc,EAAE,MAAM,CAAC;CACxB,CAAC,CAAC;AAEH;;;;;;;GAOG;AACH,wBAAsB,oBAAoB,CACxC,GAAG,EAAE,WAAW,GAAG,YAAY,EAC/B,SAAS,EAAE,cAAc,EACzB,IAAI,EAAE;IACJ,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;IAC7B,QAAQ,EAAE,CAAC,YAAY,GAAG,OAAO,CAAC,EAAE,CAAC;IACrC;;;;OAIG;IACH,yBAAyB,CAAC,EAAE,MAAM,CAAC;IACnC,cAAc,EAAE,cAAc,CAAC;IAC/B,YAAY,CAAC,EAAE,YAAY,CAAC;CAC7B,GACA,OAAO,CAAC,UAAU,EAAE,CAAC,CA6FvB;AAED;;;;GAIG;AACH,wBAAgB,6BAA6B,CAAC,IAAI,EAAE,UAAU,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAyB/D"}
1
+ {"version":3,"file":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