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