@convex-dev/agent 0.6.0-alpha.0 → 0.6.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 (192) hide show
  1. package/MIGRATION.md +153 -0
  2. package/package.json +4 -2
  3. package/src/UIMessages.ts +135 -0
  4. package/src/client/approval.test.ts +350 -0
  5. package/src/client/createTool.ts +50 -52
  6. package/src/client/index.ts +162 -1
  7. package/src/client/mockModel.ts +9 -2
  8. package/src/client/search.test.ts +4 -5
  9. package/src/client/search.ts +47 -2
  10. package/src/client/start.ts +41 -24
  11. package/src/client/streamText.ts +27 -3
  12. package/src/client/streaming.integration.test.ts +1206 -0
  13. package/src/client/streaming.ts +41 -12
  14. package/src/client/types.ts +14 -12
  15. package/src/component/_generated/component.ts +53 -64
  16. package/src/component/messages.ts +12 -2
  17. package/src/deltas.ts +0 -1
  18. package/src/mapping.test.ts +143 -1
  19. package/src/mapping.ts +115 -6
  20. package/src/react/useDeltaStreams.ts +6 -0
  21. package/dist/UIMessages.d.ts +0 -46
  22. package/dist/UIMessages.d.ts.map +0 -1
  23. package/dist/UIMessages.js +0 -546
  24. package/dist/UIMessages.js.map +0 -1
  25. package/dist/client/createTool.d.ts +0 -170
  26. package/dist/client/createTool.d.ts.map +0 -1
  27. package/dist/client/createTool.js +0 -115
  28. package/dist/client/createTool.js.map +0 -1
  29. package/dist/client/defaultComponent.d.ts +0 -11
  30. package/dist/client/defaultComponent.d.ts.map +0 -1
  31. package/dist/client/defaultComponent.js +0 -7
  32. package/dist/client/defaultComponent.js.map +0 -1
  33. package/dist/client/definePlaygroundAPI.d.ts +0 -1725
  34. package/dist/client/definePlaygroundAPI.d.ts.map +0 -1
  35. package/dist/client/definePlaygroundAPI.js +0 -271
  36. package/dist/client/definePlaygroundAPI.js.map +0 -1
  37. package/dist/client/files.d.ts +0 -69
  38. package/dist/client/files.d.ts.map +0 -1
  39. package/dist/client/files.js +0 -181
  40. package/dist/client/files.js.map +0 -1
  41. package/dist/client/index.d.ts +0 -2044
  42. package/dist/client/index.d.ts.map +0 -1
  43. package/dist/client/index.js +0 -804
  44. package/dist/client/index.js.map +0 -1
  45. package/dist/client/messages.d.ts +0 -461
  46. package/dist/client/messages.d.ts.map +0 -1
  47. package/dist/client/messages.js +0 -106
  48. package/dist/client/messages.js.map +0 -1
  49. package/dist/client/mockModel.d.ts +0 -42
  50. package/dist/client/mockModel.d.ts.map +0 -1
  51. package/dist/client/mockModel.js +0 -175
  52. package/dist/client/mockModel.js.map +0 -1
  53. package/dist/client/saveInputMessages.d.ts +0 -20
  54. package/dist/client/saveInputMessages.d.ts.map +0 -1
  55. package/dist/client/saveInputMessages.js +0 -58
  56. package/dist/client/saveInputMessages.js.map +0 -1
  57. package/dist/client/search.d.ts +0 -493
  58. package/dist/client/search.d.ts.map +0 -1
  59. package/dist/client/search.js +0 -425
  60. package/dist/client/search.js.map +0 -1
  61. package/dist/client/start.d.ts +0 -84
  62. package/dist/client/start.d.ts.map +0 -1
  63. package/dist/client/start.js +0 -171
  64. package/dist/client/start.js.map +0 -1
  65. package/dist/client/streamText.d.ts +0 -46
  66. package/dist/client/streamText.d.ts.map +0 -1
  67. package/dist/client/streamText.js +0 -93
  68. package/dist/client/streamText.js.map +0 -1
  69. package/dist/client/streaming.d.ts +0 -3767
  70. package/dist/client/streaming.d.ts.map +0 -1
  71. package/dist/client/streaming.js +0 -294
  72. package/dist/client/streaming.js.map +0 -1
  73. package/dist/client/threads.d.ts +0 -46
  74. package/dist/client/threads.d.ts.map +0 -1
  75. package/dist/client/threads.js +0 -49
  76. package/dist/client/threads.js.map +0 -1
  77. package/dist/client/types.d.ts +0 -460
  78. package/dist/client/types.d.ts.map +0 -1
  79. package/dist/client/types.js +0 -2
  80. package/dist/client/types.js.map +0 -1
  81. package/dist/client/utils.d.ts +0 -4
  82. package/dist/client/utils.d.ts.map +0 -1
  83. package/dist/client/utils.js +0 -21
  84. package/dist/client/utils.js.map +0 -1
  85. package/dist/component/_generated/api.d.ts +0 -48
  86. package/dist/component/_generated/api.d.ts.map +0 -1
  87. package/dist/component/_generated/api.js +0 -31
  88. package/dist/component/_generated/api.js.map +0 -1
  89. package/dist/component/_generated/component.d.ts +0 -3119
  90. package/dist/component/_generated/component.d.ts.map +0 -1
  91. package/dist/component/_generated/component.js +0 -11
  92. package/dist/component/_generated/component.js.map +0 -1
  93. package/dist/component/_generated/dataModel.d.ts +0 -46
  94. package/dist/component/_generated/dataModel.d.ts.map +0 -1
  95. package/dist/component/_generated/dataModel.js +0 -11
  96. package/dist/component/_generated/dataModel.js.map +0 -1
  97. package/dist/component/_generated/server.d.ts +0 -121
  98. package/dist/component/_generated/server.d.ts.map +0 -1
  99. package/dist/component/_generated/server.js +0 -78
  100. package/dist/component/_generated/server.js.map +0 -1
  101. package/dist/component/apiKeys.d.ts +0 -11
  102. package/dist/component/apiKeys.d.ts.map +0 -1
  103. package/dist/component/apiKeys.js +0 -69
  104. package/dist/component/apiKeys.js.map +0 -1
  105. package/dist/component/convex.config.d.ts +0 -3
  106. package/dist/component/convex.config.d.ts.map +0 -1
  107. package/dist/component/convex.config.js +0 -3
  108. package/dist/component/convex.config.js.map +0 -1
  109. package/dist/component/files.d.ts +0 -97
  110. package/dist/component/files.d.ts.map +0 -1
  111. package/dist/component/files.js +0 -190
  112. package/dist/component/files.js.map +0 -1
  113. package/dist/component/messages.d.ts +0 -3850
  114. package/dist/component/messages.d.ts.map +0 -1
  115. package/dist/component/messages.js +0 -747
  116. package/dist/component/messages.js.map +0 -1
  117. package/dist/component/schema.d.ts +0 -8026
  118. package/dist/component/schema.d.ts.map +0 -1
  119. package/dist/component/schema.js +0 -147
  120. package/dist/component/schema.js.map +0 -1
  121. package/dist/component/streams.d.ts +0 -128
  122. package/dist/component/streams.d.ts.map +0 -1
  123. package/dist/component/streams.js +0 -413
  124. package/dist/component/streams.js.map +0 -1
  125. package/dist/component/threads.d.ts +0 -115
  126. package/dist/component/threads.d.ts.map +0 -1
  127. package/dist/component/threads.js +0 -208
  128. package/dist/component/threads.js.map +0 -1
  129. package/dist/component/users.d.ts +0 -52
  130. package/dist/component/users.d.ts.map +0 -1
  131. package/dist/component/users.js +0 -229
  132. package/dist/component/users.js.map +0 -1
  133. package/dist/component/vector/index.d.ts +0 -61
  134. package/dist/component/vector/index.d.ts.map +0 -1
  135. package/dist/component/vector/index.js +0 -146
  136. package/dist/component/vector/index.js.map +0 -1
  137. package/dist/component/vector/tables.d.ts +0 -58
  138. package/dist/component/vector/tables.d.ts.map +0 -1
  139. package/dist/component/vector/tables.js +0 -56
  140. package/dist/component/vector/tables.js.map +0 -1
  141. package/dist/deltas.d.ts +0 -43
  142. package/dist/deltas.d.ts.map +0 -1
  143. package/dist/deltas.js +0 -447
  144. package/dist/deltas.js.map +0 -1
  145. package/dist/mapping.d.ts +0 -54
  146. package/dist/mapping.d.ts.map +0 -1
  147. package/dist/mapping.js +0 -626
  148. package/dist/mapping.js.map +0 -1
  149. package/dist/react/SmoothText.d.ts +0 -5
  150. package/dist/react/SmoothText.d.ts.map +0 -1
  151. package/dist/react/SmoothText.js +0 -6
  152. package/dist/react/SmoothText.js.map +0 -1
  153. package/dist/react/index.d.ts +0 -25
  154. package/dist/react/index.d.ts.map +0 -1
  155. package/dist/react/index.js +0 -70
  156. package/dist/react/index.js.map +0 -1
  157. package/dist/react/optimisticallySendMessage.d.ts +0 -42
  158. package/dist/react/optimisticallySendMessage.d.ts.map +0 -1
  159. package/dist/react/optimisticallySendMessage.js +0 -74
  160. package/dist/react/optimisticallySendMessage.js.map +0 -1
  161. package/dist/react/types.d.ts +0 -12
  162. package/dist/react/types.d.ts.map +0 -1
  163. package/dist/react/types.js +0 -2
  164. package/dist/react/types.js.map +0 -1
  165. package/dist/react/useDeltaStreams.d.ts +0 -10
  166. package/dist/react/useDeltaStreams.d.ts.map +0 -1
  167. package/dist/react/useDeltaStreams.js +0 -101
  168. package/dist/react/useDeltaStreams.js.map +0 -1
  169. package/dist/react/useSmoothText.d.ts +0 -27
  170. package/dist/react/useSmoothText.d.ts.map +0 -1
  171. package/dist/react/useSmoothText.js +0 -68
  172. package/dist/react/useSmoothText.js.map +0 -1
  173. package/dist/react/useStreamingUIMessages.d.ts +0 -22
  174. package/dist/react/useStreamingUIMessages.d.ts.map +0 -1
  175. package/dist/react/useStreamingUIMessages.js +0 -92
  176. package/dist/react/useStreamingUIMessages.js.map +0 -1
  177. package/dist/react/useThreadMessages.d.ts +0 -104
  178. package/dist/react/useThreadMessages.d.ts.map +0 -1
  179. package/dist/react/useThreadMessages.js +0 -148
  180. package/dist/react/useThreadMessages.js.map +0 -1
  181. package/dist/react/useUIMessages.d.ts +0 -96
  182. package/dist/react/useUIMessages.d.ts.map +0 -1
  183. package/dist/react/useUIMessages.js +0 -108
  184. package/dist/react/useUIMessages.js.map +0 -1
  185. package/dist/shared.d.ts +0 -26
  186. package/dist/shared.d.ts.map +0 -1
  187. package/dist/shared.js +0 -67
  188. package/dist/shared.js.map +0 -1
  189. package/dist/validators.d.ts +0 -24516
  190. package/dist/validators.d.ts.map +0 -1
  191. package/dist/validators.js +0 -475
  192. package/dist/validators.js.map +0 -1
@@ -1,460 +0,0 @@
1
- import type { FlexibleSchema, InferSchema, ModelMessage, ProviderOptions } from "@ai-sdk/provider-utils";
2
- import type { JSONValue } from "@ai-sdk/provider";
3
- import type { EmbeddingModel, GenerateObjectResult, generateText, GenerateTextResult, LanguageModelRequestMetadata, LanguageModelResponseMetadata, LanguageModelUsage, LanguageModel, streamObject, streamText, StreamTextResult, ToolSet, CallSettings, generateObject } from "ai";
4
- export interface Output<_T = any, _P = any, _E = any> {
5
- name: string;
6
- responseFormat: any;
7
- parseCompleteOutput: any;
8
- parsePartialOutput: any;
9
- createElementStreamTransform: any;
10
- }
11
- import type { GenericActionCtx, GenericDataModel, GenericMutationCtx, GenericQueryCtx, WithoutSystemFields } from "convex/server";
12
- import type { MessageDoc, ProviderMetadata, StreamDelta, StreamMessage, ThreadDoc } from "../validators.js";
13
- import type { StreamingOptions } from "./streaming.js";
14
- import type { ComponentApi } from "../component/_generated/component.js";
15
- export type AgentPrompt = {
16
- /**
17
- * System message to include in the prompt. Overwrites Agent instructions.
18
- */
19
- system?: string;
20
- /**
21
- * A prompt. It can be either a text prompt or a list of messages.
22
- * If used with `promptMessageId`, it will be used in place of that
23
- * prompt message and no input messages will be saved.
24
- * Otherwise, if used with the storageOptions "promptAndOutput" (default),
25
- * it will be the only message saved.
26
- * If a string is provided, it will be a user message.
27
- */
28
- prompt?: string | Array<ModelMessage> | undefined;
29
- /**
30
- * A list of messages to use as context before the prompt.
31
- * If used with `prompt`, these will precede the prompt.
32
- * If used with the storageOptions "promptAndOutput" (default),
33
- * none of these messages will be saved.
34
- */
35
- messages?: Array<ModelMessage> | undefined;
36
- /**
37
- * If provided, it uses this existing message to anchor the prompt:
38
- * - The specified message will be included, unless `prompt` is also
39
- * provided, in which case that will be inserted in place of this
40
- * specified message.
41
- * - Recent and search messages will not include messages after this
42
- * message's order.
43
- * - If there are already responses on the same order,
44
- * for example, tool calls and responses,
45
- * those will be included automatically.
46
- *
47
- * Note: if this is provided, no input messages will be saved by default.
48
- */
49
- promptMessageId?: string | undefined;
50
- /**
51
- * The model to use for the LLM calls. This will override the languageModel
52
- * specified in the Agent config.
53
- */
54
- model?: LanguageModel;
55
- };
56
- export type Config = {
57
- /**
58
- * The LLM model to use for generating / streaming text and objects.
59
- * e.g.
60
- * import { openai } from "@ai-sdk/openai"
61
- * const myAgent = new Agent(components.agent, {
62
- * languageModel: openai.chat("gpt-4o-mini"),
63
- */
64
- languageModel?: LanguageModel;
65
- /**
66
- * The model to use for text embeddings. Optional.
67
- * If specified, it will use this for generating vector embeddings
68
- * of chats, and can opt-in to doing vector search for automatic context
69
- * on generateText, etc.
70
- * e.g.
71
- * import { openai } from "@ai-sdk/openai"
72
- * const myAgent = new Agent(components.agent, {
73
- * ...
74
- * textEmbeddingModel: openai.embedding("text-embedding-3-small")
75
- * @deprecated — Use embeddingModel instead.
76
- */
77
- textEmbeddingModel?: EmbeddingModel;
78
- /**
79
- * The model to use for text embeddings. Optional.
80
- * If specified, it will use this for generating vector embeddings
81
- * of chats, and can opt-in to doing vector search for automatic context
82
- * on generateText, etc.
83
- * e.g.
84
- * import { openai } from "@ai-sdk/openai"
85
- * const myAgent = new Agent(components.agent, {
86
- * ...
87
- * embeddingModel: openai.embedding("text-embedding-3-small")
88
- */
89
- embeddingModel?: EmbeddingModel;
90
- /**
91
- * Options to determine what messages are included as context in message
92
- * generation. To disable any messages automatically being added, pass:
93
- * { recentMessages: 0 }
94
- */
95
- contextOptions?: ContextOptions;
96
- /**
97
- * Determines whether messages are automatically stored when passed as
98
- * arguments or generated.
99
- */
100
- storageOptions?: StorageOptions;
101
- /**
102
- * The usage handler to use for this agent.
103
- */
104
- usageHandler?: UsageHandler;
105
- /**
106
- * By default, messages are ordered with context in `fetchContextWithPrompt`,
107
- * but you can override this by providing a context handler. Here you can
108
- * filter, modify, or enrich the context messages. If provided, the default
109
- * ordering will not apply. This excludes the system message / instructions.
110
- */
111
- contextHandler?: ContextHandler;
112
- /**
113
- * Called for each LLM request/response, so you can do things like
114
- * log the raw request body or response headers to a table, or logs.
115
- */
116
- rawRequestResponseHandler?: RawRequestResponseHandler;
117
- /**
118
- * @deprecated Reach out if you use this. Otherwise will be removed soon.
119
- * Default provider options to pass for the LLM calls.
120
- * This can be overridden at each generate/stream callsite on a per-field
121
- * basis. To clear a default setting, you'll need to pass `undefined`.
122
- */
123
- providerOptions?: ProviderOptions;
124
- /**
125
- * The default settings to use for the LLM calls.
126
- * This can be overridden at each generate/stream callsite on a per-field
127
- * basis. To clear a default setting, you'll need to pass `undefined`.
128
- */
129
- callSettings?: CallSettings;
130
- /**
131
- * The maximum number of steps to allow for a single generation.
132
- *
133
- * For example, if an agent wants to call a tool, that call and tool response
134
- * will be one step. Generating a response based on the tool call & response
135
- * will be a second step.
136
- * If it runs out of steps, it will return the last step result, which may
137
- * not be an assistant message.
138
-
139
- * This becomes the default value when `stopWhen` is not specified in the
140
- * Agent or generation callsite.
141
- * AI SDK v5 removed the `maxSteps` argument, but this is kept here for
142
- * convenience and backwards compatibility.
143
- * Defaults to 1.
144
- */
145
- maxSteps?: number;
146
- };
147
- /**
148
- * Options to configure what messages are fetched as context,
149
- * automatically with thread.generateText, or directly via search.
150
- */
151
- export type ContextOptions = {
152
- /**
153
- * Whether to include tool messages in the context.
154
- * By default, tool calls and results are not included.
155
- */
156
- excludeToolMessages?: boolean;
157
- /**
158
- * How many recent messages to include. These are added after the search
159
- * messages, and do not count against the search limit.
160
- * Default: 100
161
- */
162
- recentMessages?: number;
163
- /**
164
- * Options for searching messages.
165
- */
166
- searchOptions?: {
167
- /**
168
- * The maximum number of messages to fetch. Default is 10.
169
- */
170
- limit: number;
171
- /**
172
- * Whether to use text search to find messages. Default is false.
173
- */
174
- textSearch?: boolean;
175
- /**
176
- * Whether to use vector search to find messages. Default is false.
177
- * At least one of textSearch or vectorSearch must be true.
178
- */
179
- vectorSearch?: boolean;
180
- /**
181
- * The score threshold for vector search. Default is 0.0.
182
- */
183
- vectorScoreThreshold?: number;
184
- /**
185
- * What messages around the search results to include.
186
- * Default: { before: 2, after: 1 }
187
- * (two before, and one after each message found in the search)
188
- * Note, this is after the limit is applied.
189
- * By default this will quadruple the number of messages fetched.
190
- */
191
- messageRange?: {
192
- before: number;
193
- after: number;
194
- };
195
- };
196
- /**
197
- * Whether to search across other threads for relevant messages.
198
- * By default, only the current thread is searched.
199
- */
200
- searchOtherThreads?: boolean;
201
- };
202
- /**
203
- * Options to configure the automatic saving of messages
204
- * when generating text / objects in a thread.
205
- */
206
- export type StorageOptions = {
207
- /**
208
- * Whether to save messages to the thread history.
209
- * Pass "all" to save all input and output messages.
210
- * Pass "none" to not save any input or output messages.
211
- * Pass "promptAndOutput" to save the prompt and all output messages.
212
- * If you pass {messages} but no {prompt}, it will assume messages.at(-1) is
213
- * the prompt.
214
- * Defaults to "promptAndOutput".
215
- */
216
- saveMessages?: "all" | "none" | "promptAndOutput";
217
- };
218
- export type GenerationOutputMetadata = {
219
- /**
220
- * The ID of the prompt message for the generation.
221
- */
222
- promptMessageId?: string;
223
- /**
224
- * The order of the prompt message and responses for the generation.
225
- * Each order starts with a user message, then followed by agent responses.
226
- * If a promptMessageId is provided, that dictates the order.
227
- */
228
- order?: number;
229
- /**
230
- * The messages saved for the generation - both saved input and output.
231
- * If you passed promptMessageId, it will not include that message.
232
- */
233
- savedMessages?: MessageDoc[];
234
- /**
235
- * @deprecated Use promptMessageId instead.
236
- * The ID of the prompt message for the generation.
237
- */
238
- messageId?: string;
239
- };
240
- export type UsageHandler = (ctx: ActionCtx, args: {
241
- userId: string | undefined;
242
- threadId: string | undefined;
243
- agentName: string | undefined;
244
- usage: LanguageModelUsage;
245
- providerMetadata: ProviderMetadata | undefined;
246
- model: string;
247
- provider: string;
248
- }) => void | Promise<void>;
249
- /**
250
- * By default, messages are ordered with context in `fetchContextWithPrompt`,
251
- * but you can override this by providing a context handler. Here you can filter
252
- * out, add in, or reorder messages.
253
- */
254
- export type ContextHandler = (ctx: ActionCtx, args: {
255
- /**
256
- * All messages in the default order.
257
- */
258
- allMessages: ModelMessage[];
259
- /**
260
- * The messages fetched from search.
261
- */
262
- search: ModelMessage[];
263
- /**
264
- * The recent messages already in the thread history,
265
- * excluding any messages that came after promptMessageId.
266
- */
267
- recent: ModelMessage[];
268
- /**
269
- * The messages passed as the `messages` argument to e.g. generateText.
270
- */
271
- inputMessages: ModelMessage[];
272
- /**
273
- * The message(s) passed as the `prompt` argument to e.g. generateText.
274
- * Otherwise, if `promptMessageId` was provided, the message at that id.
275
- * `prompt` will override the message at `promptMessageId`.
276
- */
277
- inputPrompt: ModelMessage[];
278
- /**
279
- * Any messages on the same `order` as the promptMessageId message after the
280
- * prompt message. These are presumably existing responses to the prompt
281
- * message.
282
- */
283
- existingResponses: ModelMessage[];
284
- /**
285
- * The user associated with the generation, if any.
286
- */
287
- userId: string | undefined;
288
- /**
289
- * The thread associated with the generation, if any.
290
- */
291
- threadId: string | undefined;
292
- }) => ModelMessage[] | Promise<ModelMessage[]>;
293
- export type RawRequestResponseHandler = (ctx: ActionCtx, args: {
294
- userId: string | undefined;
295
- threadId: string | undefined;
296
- agentName: string | undefined;
297
- request: LanguageModelRequestMetadata;
298
- response: LanguageModelResponseMetadata;
299
- }) => void | Promise<void>;
300
- export type AgentComponent = ComponentApi;
301
- export type TextArgs<AgentTools extends ToolSet, TOOLS extends ToolSet | undefined = undefined, OUTPUT extends Output<any, any, any> = never> = Omit<Parameters<typeof generateText<TOOLS extends undefined ? AgentTools : TOOLS, OUTPUT>>[0], "model" | "prompt" | "messages"> & {
302
- /**
303
- * The tools to use for the tool calls. This will override tools specified
304
- * in the Agent constructor or createThread / continueThread.
305
- */
306
- tools?: TOOLS;
307
- } & AgentPrompt;
308
- export type StreamingTextArgs<AgentTools extends ToolSet, TOOLS extends ToolSet | undefined = undefined, OUTPUT extends Output<any, any, any> = never> = Omit<Parameters<typeof streamText<TOOLS extends undefined ? AgentTools : TOOLS, OUTPUT>>[0], "model" | "prompt" | "messages"> & {
309
- /**
310
- * The tools to use for the tool calls. This will override tools specified
311
- * in the Agent constructor or createThread / continueThread.
312
- */
313
- tools?: TOOLS;
314
- } & AgentPrompt;
315
- export type ObjectMode = "object" | "array" | "enum" | "no-schema";
316
- export type GenerateObjectArgs<SCHEMA extends FlexibleSchema<unknown> = FlexibleSchema<JSONValue>, OUTPUT extends ObjectMode = InferSchema<SCHEMA> extends string ? "enum" : "object", RESULT = OUTPUT extends "array" ? Array<InferSchema<SCHEMA>> : InferSchema<SCHEMA>> = AgentPrompt & Omit<Parameters<typeof generateObject<SCHEMA, OUTPUT, RESULT>>[0], "model" | "prompt" | "messages"> & {
317
- schema?: SCHEMA;
318
- enum?: Array<RESULT>;
319
- };
320
- export type StreamObjectArgs<SCHEMA extends FlexibleSchema<unknown> = FlexibleSchema<JSONValue>, OUTPUT extends ObjectMode = InferSchema<SCHEMA> extends string ? "enum" : "object", RESULT = OUTPUT extends "array" ? Array<InferSchema<SCHEMA>> : InferSchema<SCHEMA>> = AgentPrompt & Omit<Parameters<typeof streamObject<SCHEMA, OUTPUT, RESULT>>[0], "model" | "prompt" | "messages"> & {
321
- schema?: SCHEMA;
322
- enum?: Array<RESULT>;
323
- };
324
- export type MaybeCustomCtx<CustomCtx, DataModel extends GenericDataModel, AgentTools extends ToolSet> = CustomCtx extends Record<string, unknown> ? {
325
- /**
326
- * If you have a custom ctx that you use with the Agent
327
- * (e.g. new Agent<{ orgId: string }>(...))
328
- * you need to provide this function to add any extra fields.
329
- * e.g.
330
- * ```ts
331
- * const myAgent = new Agent<{ orgId: string }>(...);
332
- * const myAction = myAgent.asTextAction({
333
- * customCtx: (ctx: ActionCtx, target, llmArgs) => {
334
- * const orgId = await lookupOrgId(ctx, target.threadId);
335
- * return { orgId };
336
- * },
337
- * });
338
- * ```
339
- * Then, in your tools, you can
340
- */
341
- customCtx: (ctx: GenericActionCtx<DataModel>, target: {
342
- userId?: string | undefined;
343
- threadId?: string | undefined;
344
- }, llmArgs: TextArgs<AgentTools>) => CustomCtx;
345
- } : {
346
- customCtx?: never;
347
- };
348
- type ThreadOutputMetadata = Required<GenerationOutputMetadata>;
349
- /**
350
- * The interface for a thread returned from {@link createThread} or {@link continueThread}.
351
- * This is contextual to a thread and/or user.
352
- */
353
- export interface Thread<DefaultTools extends ToolSet> {
354
- /**
355
- * The target threadId, from the startThread or continueThread initializers.
356
- */
357
- threadId: string;
358
- /**
359
- * Get the metadata for the thread.
360
- */
361
- getMetadata: () => Promise<ThreadDoc>;
362
- /**
363
- * Update the metadata for the thread.
364
- */
365
- updateMetadata: (patch: Partial<WithoutSystemFields<ThreadDoc>>) => Promise<ThreadDoc>;
366
- /**
367
- * This behaves like {@link generateText} from the "ai" package except that
368
- * it add context based on the userId and threadId and saves the input and
369
- * resulting messages to the thread, if specified.
370
- * Use {@link continueThread} to get a version of this function already scoped
371
- * to a thread (and optionally userId).
372
- * @param args The arguments to the generateText function, along with extra controls
373
- * for the {@link ContextOptions} and {@link StorageOptions}.
374
- * @returns The result of the generateText function.
375
- */
376
- generateText<TOOLS extends ToolSet | undefined = undefined, OUTPUT extends Output<any, any, any> = never>(generateTextArgs: AgentPrompt & TextArgs<TOOLS extends undefined ? DefaultTools : TOOLS, TOOLS, OUTPUT>, options?: Options): Promise<GenerateTextResult<TOOLS extends undefined ? DefaultTools : TOOLS, OUTPUT> & ThreadOutputMetadata>;
377
- /**
378
- * This behaves like {@link streamText} from the "ai" package except that
379
- * it add context based on the userId and threadId and saves the input and
380
- * resulting messages to the thread, if specified.
381
- * Use {@link continueThread} to get a version of this function already scoped
382
- * to a thread (and optionally userId).
383
- * @param args The arguments to the streamText function, along with extra controls
384
- * for the {@link ContextOptions} and {@link StorageOptions}.
385
- * @returns The result of the streamText function.
386
- */
387
- streamText<TOOLS extends ToolSet | undefined = undefined, OUTPUT extends Output<any, any, any> = never>(streamTextArgs: AgentPrompt & StreamingTextArgs<TOOLS extends undefined ? DefaultTools : TOOLS, TOOLS, OUTPUT>, options?: Options & {
388
- /**
389
- * Whether to save incremental data (deltas) from streaming responses.
390
- * Defaults to false.
391
- * If false, it will not save any deltas to the database.
392
- * If true, it will save deltas with {@link DEFAULT_STREAMING_OPTIONS}.
393
- *
394
- * Regardless of this option, when streaming you are able to use this
395
- * `streamText` function as you would with the "ai" package's version:
396
- * iterating over the text, streaming it over HTTP, etc.
397
- */
398
- saveStreamDeltas?: boolean | StreamingOptions;
399
- }): Promise<StreamTextResult<TOOLS extends undefined ? DefaultTools : TOOLS, OUTPUT> & ThreadOutputMetadata>;
400
- /**
401
- * This behaves like {@link generateObject} from the "ai" package except that
402
- * it add context based on the userId and threadId and saves the input and
403
- * resulting messages to the thread, if specified. This overload is for objects, arrays, and enums.
404
- * Use {@link continueThread} to get a version of this function already scoped
405
- * to a thread (and optionally userId).
406
- * @param args The arguments to the generateObject function, along with extra controls
407
- * for the {@link ContextOptions} and {@link StorageOptions}.
408
- * @returns The result of the generateObject function.
409
- */
410
- generateObject<SCHEMA extends FlexibleSchema<unknown> = FlexibleSchema<JSONValue>, OUTPUT extends ObjectMode = InferSchema<SCHEMA> extends string ? "enum" : "object", RESULT = OUTPUT extends "array" ? Array<InferSchema<SCHEMA>> : InferSchema<SCHEMA>>(generateObjectArgs: AgentPrompt & GenerateObjectArgs<SCHEMA, OUTPUT, RESULT>, options?: Options): Promise<GenerateObjectResult<RESULT> & ThreadOutputMetadata>;
411
- /**
412
- * This behaves like {@link streamObject} from the "ai" package except that
413
- * it add context based on the userId and threadId and saves the input and
414
- * resulting messages to the thread, if specified.
415
- * Use {@link continueThread} to get a version of this function already scoped
416
- * to a thread (and optionally userId).
417
- * @param args The arguments to the streamObject function, along with extra controls
418
- * for the {@link ContextOptions} and {@link StorageOptions}.
419
- * @returns The result of the streamObject function.
420
- */
421
- streamObject<SCHEMA extends FlexibleSchema<unknown> = FlexibleSchema<JSONValue>, OUTPUT extends ObjectMode = InferSchema<SCHEMA> extends string ? "enum" : "object", RESULT = OUTPUT extends "array" ? Array<InferSchema<SCHEMA>> : InferSchema<SCHEMA>>(
422
- /**
423
- * The same arguments you'd pass to "ai" sdk {@link streamObject}.
424
- */
425
- streamObjectArgs: AgentPrompt & StreamObjectArgs<SCHEMA, OUTPUT, RESULT>, options?: Options): Promise<ReturnType<typeof streamObject<SCHEMA, OUTPUT, RESULT>> & ThreadOutputMetadata>;
426
- }
427
- export type Options = {
428
- /**
429
- * The context options to use for passing in message history to the LLM.
430
- */
431
- contextOptions?: ContextOptions;
432
- /**
433
- * The storage options to use for saving the input and output messages to the thread.
434
- */
435
- storageOptions?: StorageOptions;
436
- /**
437
- * The usage handler to use for this thread. Overrides any handler
438
- * set in the agent constructor.
439
- */
440
- usageHandler?: UsageHandler;
441
- /**
442
- * By default, messages are ordered with context in `fetchContextWithPrompt`,
443
- * but you can override this by providing a context handler. Here you can
444
- * filter, modify, or enrich the context messages. If provided, the default
445
- * ordering will not apply. This excludes the system message / instructions.
446
- */
447
- contextHandler?: ContextHandler;
448
- };
449
- export type SyncStreamsReturnValue = {
450
- kind: "list";
451
- messages: StreamMessage[];
452
- } | {
453
- kind: "deltas";
454
- deltas: StreamDelta[];
455
- } | undefined;
456
- export type QueryCtx = Pick<GenericQueryCtx<GenericDataModel>, "runQuery">;
457
- export type MutationCtx = Pick<GenericMutationCtx<GenericDataModel>, "runQuery" | "runMutation">;
458
- export type ActionCtx = Pick<GenericActionCtx<GenericDataModel>, "runQuery" | "runMutation" | "runAction" | "storage" | "auth">;
459
- export {};
460
- //# sourceMappingURL=types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/client/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,WAAW,EACX,YAAY,EACZ,eAAe,EAChB,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,KAAK,EACV,cAAc,EACd,oBAAoB,EACpB,YAAY,EACZ,kBAAkB,EAClB,4BAA4B,EAC5B,6BAA6B,EAC7B,kBAAkB,EAClB,aAAa,EACb,YAAY,EACZ,UAAU,EACV,gBAAgB,EAChB,OAAO,EACP,YAAY,EACZ,cAAc,EACf,MAAM,IAAI,CAAC;AAEZ,MAAM,WAAW,MAAM,CAAC,EAAE,GAAG,GAAG,EAAE,EAAE,GAAG,GAAG,EAAE,EAAE,GAAG,GAAG;IAClD,IAAI,EAAE,MAAM,CAAC;IACb,cAAc,EAAE,GAAG,CAAC;IACpB,mBAAmB,EAAE,GAAG,CAAC;IACzB,kBAAkB,EAAE,GAAG,CAAC;IACxB,4BAA4B,EAAE,GAAG,CAAC;CACnC;AACD,OAAO,KAAK,EACV,gBAAgB,EAChB,gBAAgB,EAChB,kBAAkB,EAClB,eAAe,EACf,mBAAmB,EACpB,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,EACV,UAAU,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C,EAAE,cAAc,CAAC;CACjC,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAC9B;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,aAAa,EAAE,CAAA;CAAE,GAC3C;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,MAAM,EAAE,WAAW,EAAE,CAAA;CAAE,GACzC,SAAS,CAAC;AAGd,MAAM,MAAM,QAAQ,GAAG,IAAI,CAAC,eAAe,CAAC,gBAAgB,CAAC,EAAE,UAAU,CAAC,CAAC;AAC3E,MAAM,MAAM,WAAW,GAAG,IAAI,CAC5B,kBAAkB,CAAC,gBAAgB,CAAC,EACpC,UAAU,GAAG,aAAa,CAC3B,CAAC;AACF,MAAM,MAAM,SAAS,GAAG,IAAI,CAC1B,gBAAgB,CAAC,gBAAgB,CAAC,EAClC,UAAU,GAAG,aAAa,GAAG,WAAW,GAAG,SAAS,GAAG,MAAM,CAC9D,CAAC"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/client/types.ts"],"names":[],"mappings":""}
@@ -1,4 +0,0 @@
1
- import type { StepResult, StopCondition } from "ai";
2
- export declare function willContinue(steps: StepResult<any>[], stopWhen: StopCondition<any> | Array<StopCondition<any>> | undefined): Promise<boolean>;
3
- export declare function errorToString(error: unknown): string;
4
- //# sourceMappingURL=utils.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/client/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,IAAI,CAAC;AAEpD,wBAAsB,YAAY,CAChC,KAAK,EAAE,UAAU,CAAC,GAAG,CAAC,EAAE,EAExB,QAAQ,EAAE,aAAa,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC,GAAG,SAAS,GACnE,OAAO,CAAC,OAAO,CAAC,CAalB;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAKpD"}
@@ -1,21 +0,0 @@
1
- export async function willContinue(steps, stopWhen) {
2
- const step = steps.at(-1);
3
- // we aren't doing another round after a tool result
4
- // TODO: whether to handle continuing after too much context used..
5
- if (step.finishReason !== "tool-calls")
6
- return false;
7
- // we don't have a tool result, so we'll wait for more
8
- if (step.toolCalls.length > step.toolResults.length)
9
- return false;
10
- if (Array.isArray(stopWhen)) {
11
- return (await Promise.all(stopWhen.map(async (s) => s({ steps })))).every((stop) => !stop);
12
- }
13
- return !!stopWhen && !(await stopWhen({ steps }));
14
- }
15
- export function errorToString(error) {
16
- if (error instanceof Error) {
17
- return error.message;
18
- }
19
- return String(error);
20
- }
21
- //# sourceMappingURL=utils.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/client/utils.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,KAAwB,EAExB,QAAoE;IAEpE,MAAM,IAAI,GAAG,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,CAAE,CAAC;IAC3B,oDAAoD;IACpD,mEAAmE;IACnE,IAAI,IAAI,CAAC,YAAY,KAAK,YAAY;QAAE,OAAO,KAAK,CAAC;IACrD,sDAAsD;IACtD,IAAI,IAAI,CAAC,SAAS,CAAC,MAAM,GAAG,IAAI,CAAC,WAAW,CAAC,MAAM;QAAE,OAAO,KAAK,CAAC;IAClE,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC5B,OAAO,CAAC,MAAM,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CACvE,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,IAAI,CAChB,CAAC;IACJ,CAAC;IACD,OAAO,CAAC,CAAC,QAAQ,IAAI,CAAC,CAAC,MAAM,QAAQ,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC;AACpD,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,KAAc;IAC1C,IAAI,KAAK,YAAY,KAAK,EAAE,CAAC;QAC3B,OAAO,KAAK,CAAC,OAAO,CAAC;IACvB,CAAC;IACD,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;AACvB,CAAC"}
@@ -1,48 +0,0 @@
1
- /**
2
- * Generated `api` utility.
3
- *
4
- * THIS CODE IS AUTOMATICALLY GENERATED.
5
- *
6
- * To regenerate, run `npx convex dev`.
7
- * @module
8
- */
9
- import type * as apiKeys from "../apiKeys.js";
10
- import type * as files from "../files.js";
11
- import type * as messages from "../messages.js";
12
- import type * as streams from "../streams.js";
13
- import type * as threads from "../threads.js";
14
- import type * as users from "../users.js";
15
- import type * as vector_index from "../vector/index.js";
16
- import type * as vector_tables from "../vector/tables.js";
17
- import type { ApiFromModules, FilterApi, FunctionReference } from "convex/server";
18
- declare const fullApi: ApiFromModules<{
19
- apiKeys: typeof apiKeys;
20
- files: typeof files;
21
- messages: typeof messages;
22
- streams: typeof streams;
23
- threads: typeof threads;
24
- users: typeof users;
25
- "vector/index": typeof vector_index;
26
- "vector/tables": typeof vector_tables;
27
- }>;
28
- /**
29
- * A utility for referencing Convex functions in your app's public API.
30
- *
31
- * Usage:
32
- * ```js
33
- * const myFunctionReference = api.myModule.myFunction;
34
- * ```
35
- */
36
- export declare const api: FilterApi<typeof fullApi, FunctionReference<any, "public">>;
37
- /**
38
- * A utility for referencing Convex functions in your app's internal API.
39
- *
40
- * Usage:
41
- * ```js
42
- * const myFunctionReference = internal.myModule.myFunction;
43
- * ```
44
- */
45
- export declare const internal: FilterApi<typeof fullApi, FunctionReference<any, "internal">>;
46
- export declare const components: {};
47
- export {};
48
- //# sourceMappingURL=api.d.ts.map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C,EAAE,CAAC"}
@@ -1,31 +0,0 @@
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
- import { anyApi, componentsGeneric } from "convex/server";
11
- const fullApi = anyApi;
12
- /**
13
- * A utility for referencing Convex functions in your app's public API.
14
- *
15
- * Usage:
16
- * ```js
17
- * const myFunctionReference = api.myModule.myFunction;
18
- * ```
19
- */
20
- export const api = anyApi;
21
- /**
22
- * A utility for referencing Convex functions in your app's internal API.
23
- *
24
- * Usage:
25
- * ```js
26
- * const myFunctionReference = internal.myModule.myFunction;
27
- * ```
28
- */
29
- export const internal = anyApi;
30
- export const components = componentsGeneric();
31
- //# sourceMappingURL=api.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"api.js","sourceRoot":"","sources":["../../../src/component/_generated/api.ts"],"names":[],"mappings":"AAAA,oBAAoB;AACpB;;;;;;;GAOG;AAgBH,OAAO,EAAE,MAAM,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAE1D,MAAM,OAAO,GASR,MAAa,CAAC;AAEnB;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,GAAG,GAGZ,MAAa,CAAC;AAElB;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,QAAQ,GAGjB,MAAa,CAAC;AAElB,MAAM,CAAC,MAAM,UAAU,GAAG,iBAAiB,EAAmB,CAAC"}