@convex-dev/agent 0.1.10 → 0.1.11
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.
- package/dist/esm/client/index.d.ts.map +1 -1
- package/dist/esm/client/index.js +25 -24
- package/dist/esm/client/index.js.map +1 -1
- package/dist/esm/mapping.d.ts +1 -0
- package/dist/esm/mapping.d.ts.map +1 -1
- package/dist/esm/mapping.js +2 -2
- package/dist/esm/mapping.js.map +1 -1
- package/dist/esm.tsbuildinfo +1 -1
- package/package.json +23 -53
- package/src/client/index.ts +27 -27
- package/src/mapping.ts +9 -2
- package/dist/commonjs/client/_generated/_ignore.d.ts +0 -1
- package/dist/commonjs/client/_generated/_ignore.d.ts.map +0 -1
- package/dist/commonjs/client/_generated/_ignore.js +0 -3
- package/dist/commonjs/client/_generated/_ignore.js.map +0 -1
- package/dist/commonjs/client/createTool.d.ts +0 -47
- package/dist/commonjs/client/createTool.d.ts.map +0 -1
- package/dist/commonjs/client/createTool.js +0 -49
- package/dist/commonjs/client/createTool.js.map +0 -1
- package/dist/commonjs/client/files.d.ts +0 -56
- package/dist/commonjs/client/files.d.ts.map +0 -1
- package/dist/commonjs/client/files.js +0 -129
- package/dist/commonjs/client/files.js.map +0 -1
- package/dist/commonjs/client/index.d.ts +0 -1355
- package/dist/commonjs/client/index.d.ts.map +0 -1
- package/dist/commonjs/client/index.js +0 -1169
- package/dist/commonjs/client/index.js.map +0 -1
- package/dist/commonjs/client/streaming.d.ts +0 -57
- package/dist/commonjs/client/streaming.d.ts.map +0 -1
- package/dist/commonjs/client/streaming.js +0 -148
- package/dist/commonjs/client/streaming.js.map +0 -1
- package/dist/commonjs/client/types.d.ts +0 -352
- package/dist/commonjs/client/types.d.ts.map +0 -1
- package/dist/commonjs/client/types.js +0 -3
- package/dist/commonjs/client/types.js.map +0 -1
- package/dist/commonjs/component/_generated/api.d.ts +0 -1938
- package/dist/commonjs/component/_generated/api.d.ts.map +0 -1
- package/dist/commonjs/component/_generated/api.js +0 -25
- package/dist/commonjs/component/_generated/api.js.map +0 -1
- package/dist/commonjs/component/_generated/dataModel.d.ts +0 -60
- package/dist/commonjs/component/_generated/server.d.ts +0 -149
- package/dist/commonjs/component/_generated/server.d.ts.map +0 -1
- package/dist/commonjs/component/_generated/server.js +0 -77
- package/dist/commonjs/component/_generated/server.js.map +0 -1
- package/dist/commonjs/component/apiKeys.d.ts +0 -11
- package/dist/commonjs/component/apiKeys.d.ts.map +0 -1
- package/dist/commonjs/component/apiKeys.js +0 -72
- package/dist/commonjs/component/apiKeys.js.map +0 -1
- package/dist/commonjs/component/convex.config.d.ts +0 -3
- package/dist/commonjs/component/convex.config.d.ts.map +0 -1
- package/dist/commonjs/component/convex.config.js +0 -5
- package/dist/commonjs/component/convex.config.js.map +0 -1
- package/dist/commonjs/component/files.d.ts +0 -90
- package/dist/commonjs/component/files.d.ts.map +0 -1
- package/dist/commonjs/component/files.js +0 -157
- package/dist/commonjs/component/files.js.map +0 -1
- package/dist/commonjs/component/messages.d.ts +0 -1479
- package/dist/commonjs/component/messages.d.ts.map +0 -1
- package/dist/commonjs/component/messages.js +0 -483
- package/dist/commonjs/component/messages.js.map +0 -1
- package/dist/commonjs/component/schema.d.ts +0 -4582
- package/dist/commonjs/component/schema.d.ts.map +0 -1
- package/dist/commonjs/component/schema.js +0 -167
- package/dist/commonjs/component/schema.js.map +0 -1
- package/dist/commonjs/component/streams.d.ts +0 -242
- package/dist/commonjs/component/streams.d.ts.map +0 -1
- package/dist/commonjs/component/streams.js +0 -323
- package/dist/commonjs/component/streams.js.map +0 -1
- package/dist/commonjs/component/threads.d.ts +0 -101
- package/dist/commonjs/component/threads.d.ts.map +0 -1
- package/dist/commonjs/component/threads.js +0 -188
- package/dist/commonjs/component/threads.js.map +0 -1
- package/dist/commonjs/component/users.d.ts +0 -52
- package/dist/commonjs/component/users.d.ts.map +0 -1
- package/dist/commonjs/component/users.js +0 -233
- package/dist/commonjs/component/users.js.map +0 -1
- package/dist/commonjs/component/vector/index.d.ts +0 -61
- package/dist/commonjs/component/vector/index.d.ts.map +0 -1
- package/dist/commonjs/component/vector/index.js +0 -153
- package/dist/commonjs/component/vector/index.js.map +0 -1
- package/dist/commonjs/component/vector/tables.d.ts +0 -58
- package/dist/commonjs/component/vector/tables.d.ts.map +0 -1
- package/dist/commonjs/component/vector/tables.js +0 -62
- package/dist/commonjs/component/vector/tables.js.map +0 -1
- package/dist/commonjs/mapping.d.ts +0 -50
- package/dist/commonjs/mapping.d.ts.map +0 -1
- package/dist/commonjs/mapping.js +0 -272
- package/dist/commonjs/mapping.js.map +0 -1
- package/dist/commonjs/package.json +0 -3
- package/dist/commonjs/react/deltas.d.ts +0 -29
- package/dist/commonjs/react/deltas.d.ts.map +0 -1
- package/dist/commonjs/react/deltas.js +0 -274
- package/dist/commonjs/react/deltas.js.map +0 -1
- package/dist/commonjs/react/index.d.ts +0 -95
- package/dist/commonjs/react/index.d.ts.map +0 -1
- package/dist/commonjs/react/index.js +0 -219
- package/dist/commonjs/react/index.js.map +0 -1
- package/dist/commonjs/react/optimisticallySendMessage.d.ts +0 -8
- package/dist/commonjs/react/optimisticallySendMessage.d.ts.map +0 -1
- package/dist/commonjs/react/optimisticallySendMessage.js +0 -43
- package/dist/commonjs/react/optimisticallySendMessage.js.map +0 -1
- package/dist/commonjs/react/toUIMessages.d.ts +0 -13
- package/dist/commonjs/react/toUIMessages.d.ts.map +0 -1
- package/dist/commonjs/react/toUIMessages.js +0 -149
- package/dist/commonjs/react/toUIMessages.js.map +0 -1
- package/dist/commonjs/react/types.d.ts +0 -26
- package/dist/commonjs/react/types.d.ts.map +0 -1
- package/dist/commonjs/react/types.js +0 -3
- package/dist/commonjs/react/types.js.map +0 -1
- package/dist/commonjs/react/useSmoothText.d.ts +0 -20
- package/dist/commonjs/react/useSmoothText.d.ts.map +0 -1
- package/dist/commonjs/react/useSmoothText.js +0 -54
- package/dist/commonjs/react/useSmoothText.js.map +0 -1
- package/dist/commonjs/shared.d.ts +0 -10
- package/dist/commonjs/shared.d.ts.map +0 -1
- package/dist/commonjs/shared.js +0 -35
- package/dist/commonjs/shared.js.map +0 -1
- package/dist/commonjs/validators.d.ts +0 -5716
- package/dist/commonjs/validators.d.ts.map +0 -1
- package/dist/commonjs/validators.js +0 -319
- package/dist/commonjs/validators.js.map +0 -1
- package/dist/commonjs/vitest.config.d.ts +0 -3
- package/dist/commonjs/vitest.config.d.ts.map +0 -1
- package/dist/commonjs/vitest.config.js +0 -9
- package/dist/commonjs/vitest.config.js.map +0 -1
- package/dist/commonjs.tsbuildinfo +0 -1
- package/dist/esm/vitest.config.d.ts +0 -3
- package/dist/esm/vitest.config.d.ts.map +0 -1
- package/dist/esm/vitest.config.js +0 -7
- package/dist/esm/vitest.config.js.map +0 -1
- package/react/package.json +0 -5
- package/validators/package.json +0 -5
|
@@ -1,1355 +0,0 @@
|
|
|
1
|
-
import type { EmbeddingModelV1, LanguageModelV1 } from "@ai-sdk/provider";
|
|
2
|
-
import type { CoreMessage, DeepPartial, GenerateObjectResult, GenerateTextResult, StepResult, StreamObjectResult, StreamTextResult, ToolSet } from "ai";
|
|
3
|
-
import { type PaginationOptions, type PaginationResult, type WithoutSystemFields } from "convex/server";
|
|
4
|
-
import type { MessageDoc, ThreadDoc } from "../component/schema.js";
|
|
5
|
-
import { type VectorDimension } from "../component/vector/tables.js";
|
|
6
|
-
import { type AIMessageWithoutId } from "../mapping.js";
|
|
7
|
-
import { extractText, isTool } from "../shared.js";
|
|
8
|
-
import { type MessageWithMetadata, type MessageStatus, type ProviderMetadata, type SearchOptions, type StreamArgs, type Usage } from "../validators.js";
|
|
9
|
-
import { createTool } from "./createTool.js";
|
|
10
|
-
import { type StreamingOptions } from "./streaming.js";
|
|
11
|
-
import type { AgentComponent, ContextOptions, GenerationOutputMetadata, Options, OurObjectArgs, OurStreamObjectArgs, RawRequestResponseHandler, RunActionCtx, RunMutationCtx, RunQueryCtx, ActionCtx, StorageOptions, StreamingTextArgs, SyncStreamsReturnValue, TextArgs, Thread, UsageHandler } from "./types.js";
|
|
12
|
-
export { storeFile, getFile } from "./files.js";
|
|
13
|
-
export { serializeDataOrUrl } from "../mapping.js";
|
|
14
|
-
export { vMessageDoc, vThreadDoc } from "../component/schema.js";
|
|
15
|
-
export { vAssistantMessage, vContextOptions, vMessage, vPaginationResult, vProviderMetadata, vStorageOptions, vStreamArgs, vSystemMessage, vToolMessage, vUsage, vUserMessage, } from "../validators.js";
|
|
16
|
-
export type { ToolCtx } from "./createTool.js";
|
|
17
|
-
export { createTool, extractText, isTool };
|
|
18
|
-
export type { AgentComponent, ContextOptions, MessageDoc, ProviderMetadata, StorageOptions, SyncStreamsReturnValue, Thread, ThreadDoc, Usage, UsageHandler, };
|
|
19
|
-
export declare class Agent<AgentTools extends ToolSet> {
|
|
20
|
-
component: AgentComponent;
|
|
21
|
-
options: {
|
|
22
|
-
/**
|
|
23
|
-
* The name for the agent. This will be attributed on each message
|
|
24
|
-
* created by this agent.
|
|
25
|
-
*/
|
|
26
|
-
name?: string;
|
|
27
|
-
/**
|
|
28
|
-
* The LLM model to use for generating / streaming text and objects.
|
|
29
|
-
* e.g.
|
|
30
|
-
* import { openai } from "@ai-sdk/openai"
|
|
31
|
-
* const myAgent = new Agent(components.agent, {
|
|
32
|
-
* chat: openai.chat("gpt-4o-mini"),
|
|
33
|
-
*/
|
|
34
|
-
chat: LanguageModelV1;
|
|
35
|
-
/**
|
|
36
|
-
* The model to use for text embeddings. Optional.
|
|
37
|
-
* If specified, it will use this for generating vector embeddings
|
|
38
|
-
* of chats, and can opt-in to doing vector search for automatic context
|
|
39
|
-
* on generateText, etc.
|
|
40
|
-
* e.g.
|
|
41
|
-
* import { openai } from "@ai-sdk/openai"
|
|
42
|
-
* const myAgent = new Agent(components.agent, {
|
|
43
|
-
* textEmbedding: openai.embedding("text-embedding-3-small")
|
|
44
|
-
*/
|
|
45
|
-
textEmbedding?: EmbeddingModelV1<string>;
|
|
46
|
-
/**
|
|
47
|
-
* The default system prompt to put in each request.
|
|
48
|
-
* Override per-prompt by passing the "system" parameter.
|
|
49
|
-
*/
|
|
50
|
-
instructions?: string;
|
|
51
|
-
/**
|
|
52
|
-
* Tools that the agent can call out to and get responses from.
|
|
53
|
-
* They can be AI SDK tools (import {tool} from "ai")
|
|
54
|
-
* or tools that have Convex context
|
|
55
|
-
* (import { createTool } from "@convex-dev/agent")
|
|
56
|
-
*/
|
|
57
|
-
tools?: AgentTools;
|
|
58
|
-
/**
|
|
59
|
-
* Options to determine what messages are included as context in message
|
|
60
|
-
* generation. To disable any messages automatically being added, pass:
|
|
61
|
-
* { recentMessages: 0 }
|
|
62
|
-
*/
|
|
63
|
-
contextOptions?: ContextOptions;
|
|
64
|
-
/**
|
|
65
|
-
* Determines whether messages are automatically stored when passed as
|
|
66
|
-
* arguments or generated.
|
|
67
|
-
*/
|
|
68
|
-
storageOptions?: StorageOptions;
|
|
69
|
-
/**
|
|
70
|
-
* When generating or streaming text with tools available, this
|
|
71
|
-
* determines the default max number of iterations.
|
|
72
|
-
*/
|
|
73
|
-
maxSteps?: number;
|
|
74
|
-
/**
|
|
75
|
-
* The maximum number of calls to make to an LLM in case it fails.
|
|
76
|
-
* This can be overridden at each generate/stream callsite.
|
|
77
|
-
*/
|
|
78
|
-
maxRetries?: number;
|
|
79
|
-
/**
|
|
80
|
-
* The usage handler to use for this agent.
|
|
81
|
-
*/
|
|
82
|
-
usageHandler?: UsageHandler;
|
|
83
|
-
/**
|
|
84
|
-
* Called for each LLM request/response, so you can do things like
|
|
85
|
-
* log the raw request body or response headers to a table, or logs.
|
|
86
|
-
*/
|
|
87
|
-
rawRequestResponseHandler?: RawRequestResponseHandler;
|
|
88
|
-
};
|
|
89
|
-
constructor(component: AgentComponent, options: {
|
|
90
|
-
/**
|
|
91
|
-
* The name for the agent. This will be attributed on each message
|
|
92
|
-
* created by this agent.
|
|
93
|
-
*/
|
|
94
|
-
name?: string;
|
|
95
|
-
/**
|
|
96
|
-
* The LLM model to use for generating / streaming text and objects.
|
|
97
|
-
* e.g.
|
|
98
|
-
* import { openai } from "@ai-sdk/openai"
|
|
99
|
-
* const myAgent = new Agent(components.agent, {
|
|
100
|
-
* chat: openai.chat("gpt-4o-mini"),
|
|
101
|
-
*/
|
|
102
|
-
chat: LanguageModelV1;
|
|
103
|
-
/**
|
|
104
|
-
* The model to use for text embeddings. Optional.
|
|
105
|
-
* If specified, it will use this for generating vector embeddings
|
|
106
|
-
* of chats, and can opt-in to doing vector search for automatic context
|
|
107
|
-
* on generateText, etc.
|
|
108
|
-
* e.g.
|
|
109
|
-
* import { openai } from "@ai-sdk/openai"
|
|
110
|
-
* const myAgent = new Agent(components.agent, {
|
|
111
|
-
* textEmbedding: openai.embedding("text-embedding-3-small")
|
|
112
|
-
*/
|
|
113
|
-
textEmbedding?: EmbeddingModelV1<string>;
|
|
114
|
-
/**
|
|
115
|
-
* The default system prompt to put in each request.
|
|
116
|
-
* Override per-prompt by passing the "system" parameter.
|
|
117
|
-
*/
|
|
118
|
-
instructions?: string;
|
|
119
|
-
/**
|
|
120
|
-
* Tools that the agent can call out to and get responses from.
|
|
121
|
-
* They can be AI SDK tools (import {tool} from "ai")
|
|
122
|
-
* or tools that have Convex context
|
|
123
|
-
* (import { createTool } from "@convex-dev/agent")
|
|
124
|
-
*/
|
|
125
|
-
tools?: AgentTools;
|
|
126
|
-
/**
|
|
127
|
-
* Options to determine what messages are included as context in message
|
|
128
|
-
* generation. To disable any messages automatically being added, pass:
|
|
129
|
-
* { recentMessages: 0 }
|
|
130
|
-
*/
|
|
131
|
-
contextOptions?: ContextOptions;
|
|
132
|
-
/**
|
|
133
|
-
* Determines whether messages are automatically stored when passed as
|
|
134
|
-
* arguments or generated.
|
|
135
|
-
*/
|
|
136
|
-
storageOptions?: StorageOptions;
|
|
137
|
-
/**
|
|
138
|
-
* When generating or streaming text with tools available, this
|
|
139
|
-
* determines the default max number of iterations.
|
|
140
|
-
*/
|
|
141
|
-
maxSteps?: number;
|
|
142
|
-
/**
|
|
143
|
-
* The maximum number of calls to make to an LLM in case it fails.
|
|
144
|
-
* This can be overridden at each generate/stream callsite.
|
|
145
|
-
*/
|
|
146
|
-
maxRetries?: number;
|
|
147
|
-
/**
|
|
148
|
-
* The usage handler to use for this agent.
|
|
149
|
-
*/
|
|
150
|
-
usageHandler?: UsageHandler;
|
|
151
|
-
/**
|
|
152
|
-
* Called for each LLM request/response, so you can do things like
|
|
153
|
-
* log the raw request body or response headers to a table, or logs.
|
|
154
|
-
*/
|
|
155
|
-
rawRequestResponseHandler?: RawRequestResponseHandler;
|
|
156
|
-
});
|
|
157
|
-
/**
|
|
158
|
-
* Start a new thread with the agent. This will have a fresh history, though if
|
|
159
|
-
* you pass in a userId you can have it search across other threads for relevant
|
|
160
|
-
* messages as context for the LLM calls.
|
|
161
|
-
* @param ctx The context of the Convex function. From an action, you can thread
|
|
162
|
-
* with the agent. From a mutation, you can start a thread and save the threadId
|
|
163
|
-
* to pass to continueThread later.
|
|
164
|
-
* @param args The thread metadata.
|
|
165
|
-
* @returns The threadId of the new thread and the thread object.
|
|
166
|
-
*/
|
|
167
|
-
createThread<ThreadTools extends ToolSet | undefined = undefined>(ctx: RunActionCtx, args?: {
|
|
168
|
-
/**
|
|
169
|
-
* The userId to associate with the thread. If not provided, the thread will be
|
|
170
|
-
* anonymous.
|
|
171
|
-
*/
|
|
172
|
-
userId?: string;
|
|
173
|
-
/**
|
|
174
|
-
* The title of the thread. Not currently used for anything.
|
|
175
|
-
*/
|
|
176
|
-
title?: string;
|
|
177
|
-
/**
|
|
178
|
-
* The summary of the thread. Not currently used for anything.
|
|
179
|
-
*/
|
|
180
|
-
summary?: string;
|
|
181
|
-
/**
|
|
182
|
-
* The usage handler to use for this thread. Overrides any handler
|
|
183
|
-
* set in the agent constructor.
|
|
184
|
-
*/
|
|
185
|
-
usageHandler?: UsageHandler;
|
|
186
|
-
/**
|
|
187
|
-
* The tools to use for this thread.
|
|
188
|
-
* Overrides any tools passed in the agent constructor.
|
|
189
|
-
*/
|
|
190
|
-
tools?: ThreadTools;
|
|
191
|
-
}): Promise<{
|
|
192
|
-
threadId: string;
|
|
193
|
-
thread: Thread<ThreadTools extends undefined ? AgentTools : ThreadTools>;
|
|
194
|
-
}>;
|
|
195
|
-
/**
|
|
196
|
-
* Start a new thread with the agent. This will have a fresh history, though if
|
|
197
|
-
* you pass in a userId you can have it search across other threads for relevant
|
|
198
|
-
* messages as context for the LLM calls.
|
|
199
|
-
* @param ctx The context of the Convex function. From a mutation, you can
|
|
200
|
-
* start a thread and save the threadId to pass to continueThread later.
|
|
201
|
-
* @param args The thread metadata.
|
|
202
|
-
* @returns The threadId of the new thread.
|
|
203
|
-
*/
|
|
204
|
-
createThread<ThreadTools extends ToolSet | undefined = undefined>(ctx: RunMutationCtx, args?: {
|
|
205
|
-
/**
|
|
206
|
-
* The userId to associate with the thread. If not provided, the thread will be
|
|
207
|
-
* anonymous.
|
|
208
|
-
*/
|
|
209
|
-
userId?: string;
|
|
210
|
-
/**
|
|
211
|
-
* The title of the thread. Not currently used for anything.
|
|
212
|
-
*/
|
|
213
|
-
title?: string;
|
|
214
|
-
/**
|
|
215
|
-
* The summary of the thread. Not currently used for anything.
|
|
216
|
-
*/
|
|
217
|
-
summary?: string;
|
|
218
|
-
/**
|
|
219
|
-
* The usage handler to use for this thread. Overrides any handler
|
|
220
|
-
* set in the agent constructor.
|
|
221
|
-
*/
|
|
222
|
-
usageHandler?: UsageHandler;
|
|
223
|
-
/**
|
|
224
|
-
* The tools to use for this thread.
|
|
225
|
-
* Overrides any tools passed in the agent constructor.
|
|
226
|
-
*/
|
|
227
|
-
tools?: ThreadTools;
|
|
228
|
-
}): Promise<{
|
|
229
|
-
threadId: string;
|
|
230
|
-
}>;
|
|
231
|
-
/**
|
|
232
|
-
* Continues a thread using this agent. Note: threads can be continued
|
|
233
|
-
* by different agents. This is a convenience around calling the various
|
|
234
|
-
* generate and stream functions with explicit userId and threadId parameters.
|
|
235
|
-
* @param ctx The ctx object passed to the action handler
|
|
236
|
-
* @param { threadId, userId }: the thread and user to associate the messages with.
|
|
237
|
-
* @returns Functions bound to the userId and threadId on a `{thread}` object.
|
|
238
|
-
*/
|
|
239
|
-
continueThread<ThreadTools extends ToolSet | undefined = undefined>(ctx: ActionCtx, args: {
|
|
240
|
-
/**
|
|
241
|
-
* The associated thread created by {@link createThread}
|
|
242
|
-
*/
|
|
243
|
-
threadId: string;
|
|
244
|
-
/**
|
|
245
|
-
* If supplied, the userId can be used to search across other threads for
|
|
246
|
-
* relevant messages from the same user as context for the LLM calls.
|
|
247
|
-
*/
|
|
248
|
-
userId?: string;
|
|
249
|
-
/**
|
|
250
|
-
* The usage handler to use for this thread. Overrides any handler
|
|
251
|
-
* set in the agent constructor.
|
|
252
|
-
*/
|
|
253
|
-
usageHandler?: UsageHandler;
|
|
254
|
-
/**
|
|
255
|
-
* The tools to use for this thread.
|
|
256
|
-
* Overrides any tools passed in the agent constructor.
|
|
257
|
-
*/
|
|
258
|
-
tools?: ThreadTools;
|
|
259
|
-
}): Promise<{
|
|
260
|
-
thread: Thread<ThreadTools extends undefined ? AgentTools : ThreadTools>;
|
|
261
|
-
}>;
|
|
262
|
-
/**
|
|
263
|
-
* This behaves like {@link generateText} from the "ai" package except that
|
|
264
|
-
* it add context based on the userId and threadId and saves the input and
|
|
265
|
-
* resulting messages to the thread, if specified.
|
|
266
|
-
* Use {@link continueThread} to get a version of this function already scoped
|
|
267
|
-
* to a thread (and optionally userId).
|
|
268
|
-
* @param ctx The context passed from the action function calling this.
|
|
269
|
-
* @param { userId, threadId }: The user and thread to associate the message with
|
|
270
|
-
* @param args The arguments to the generateText function, along with extra controls
|
|
271
|
-
* for the {@link ContextOptions} and {@link StorageOptions}.
|
|
272
|
-
* @returns The result of the generateText function.
|
|
273
|
-
*/
|
|
274
|
-
generateText<TOOLS extends ToolSet | undefined = undefined, OUTPUT = never, OUTPUT_PARTIAL = never>(ctx: ActionCtx, { userId: argsUserId, threadId, usageHandler, tools: threadTools, }: {
|
|
275
|
-
userId?: string;
|
|
276
|
-
threadId?: string;
|
|
277
|
-
/**
|
|
278
|
-
* The usage handler to use for this thread. Overrides any handler
|
|
279
|
-
* set in the agent constructor.
|
|
280
|
-
*/
|
|
281
|
-
usageHandler?: UsageHandler;
|
|
282
|
-
/** @deprecated Pass `tools` in the next parameter instead. This is only intended to pass through thread-default tools. */
|
|
283
|
-
tools?: ToolSet;
|
|
284
|
-
}, args: TextArgs<AgentTools, TOOLS, OUTPUT, OUTPUT_PARTIAL>, options?: Options): Promise<GenerateTextResult<TOOLS extends undefined ? AgentTools : TOOLS, OUTPUT> & GenerationOutputMetadata>;
|
|
285
|
-
/**
|
|
286
|
-
* This behaves like {@link streamText} from the "ai" package except that
|
|
287
|
-
* it add context based on the userId and threadId and saves the input and
|
|
288
|
-
* resulting messages to the thread, if specified.
|
|
289
|
-
* Use {@link continueThread} to get a version of this function already scoped
|
|
290
|
-
* to a thread (and optionally userId).
|
|
291
|
-
*/
|
|
292
|
-
streamText<TOOLS extends ToolSet | undefined = undefined, OUTPUT = never, PARTIAL_OUTPUT = never>(ctx: ActionCtx, { userId: argsUserId, threadId, usageHandler,
|
|
293
|
-
/**
|
|
294
|
-
* @deprecated Pass `tools` in the next parameter instead.
|
|
295
|
-
* This is only intended to pass through thread-default tools.
|
|
296
|
-
*/
|
|
297
|
-
tools: threadTools, }: {
|
|
298
|
-
userId?: string;
|
|
299
|
-
threadId?: string;
|
|
300
|
-
usageHandler?: UsageHandler;
|
|
301
|
-
tools?: ToolSet;
|
|
302
|
-
},
|
|
303
|
-
/**
|
|
304
|
-
* The arguments to the streamText function, similar to the ai `streamText` function.
|
|
305
|
-
*/
|
|
306
|
-
args: StreamingTextArgs<AgentTools, TOOLS, OUTPUT, PARTIAL_OUTPUT>,
|
|
307
|
-
/**
|
|
308
|
-
* The {@link ContextOptions} and {@link StorageOptions}
|
|
309
|
-
* options to use for fetching contextual messages and saving input/output messages.
|
|
310
|
-
*/
|
|
311
|
-
options?: Options & {
|
|
312
|
-
/**
|
|
313
|
-
* Whether to save incremental data (deltas) from streaming responses.
|
|
314
|
-
* Defaults to false.
|
|
315
|
-
* If false, it will not save any deltas to the database.
|
|
316
|
-
* If true, it will save deltas with {@link DEFAULT_STREAMING_OPTIONS}.
|
|
317
|
-
*
|
|
318
|
-
* Regardless of this option, when streaming you are able to use this
|
|
319
|
-
* `streamText` function as you would with the "ai" package's version:
|
|
320
|
-
* iterating over the text, streaming it over HTTP, etc.
|
|
321
|
-
*/
|
|
322
|
-
saveStreamDeltas?: boolean | StreamingOptions;
|
|
323
|
-
}): Promise<StreamTextResult<TOOLS extends undefined ? AgentTools : TOOLS, PARTIAL_OUTPUT> & GenerationOutputMetadata>;
|
|
324
|
-
/**
|
|
325
|
-
* This behaves like {@link generateObject} from the "ai" package except that
|
|
326
|
-
* it add context based on the userId and threadId and saves the input and
|
|
327
|
-
* resulting messages to the thread, if specified.
|
|
328
|
-
* Use {@link continueThread} to get a version of this function already scoped
|
|
329
|
-
* to a thread (and optionally userId).
|
|
330
|
-
*/
|
|
331
|
-
generateObject<T>(ctx: ActionCtx, { userId: argsUserId, threadId, usageHandler, }: {
|
|
332
|
-
userId?: string;
|
|
333
|
-
threadId?: string;
|
|
334
|
-
usageHandler?: UsageHandler;
|
|
335
|
-
},
|
|
336
|
-
/**
|
|
337
|
-
* The arguments to the generateObject function, similar to the ai.generateObject function.
|
|
338
|
-
*/
|
|
339
|
-
args: OurObjectArgs<T>,
|
|
340
|
-
/**
|
|
341
|
-
* The {@link ContextOptions} and {@link StorageOptions}
|
|
342
|
-
* options to use for fetching contextual messages and saving input/output messages.
|
|
343
|
-
*/
|
|
344
|
-
options?: Options): Promise<GenerateObjectResult<T> & GenerationOutputMetadata>;
|
|
345
|
-
/**
|
|
346
|
-
* This behaves like `streamObject` from the "ai" package except that
|
|
347
|
-
* it add context based on the userId and threadId and saves the input and
|
|
348
|
-
* resulting messages to the thread, if specified.
|
|
349
|
-
* Use {@link continueThread} to get a version of this function already scoped
|
|
350
|
-
* to a thread (and optionally userId).
|
|
351
|
-
*/
|
|
352
|
-
streamObject<T>(ctx: ActionCtx, { userId: argsUserId, threadId, usageHandler, }: {
|
|
353
|
-
userId?: string;
|
|
354
|
-
threadId?: string;
|
|
355
|
-
usageHandler?: UsageHandler;
|
|
356
|
-
},
|
|
357
|
-
/**
|
|
358
|
-
* The arguments to the streamObject function, similar to the ai `streamObject` function.
|
|
359
|
-
*/
|
|
360
|
-
args: OurStreamObjectArgs<T>,
|
|
361
|
-
/**
|
|
362
|
-
* The {@link ContextOptions} and {@link StorageOptions}
|
|
363
|
-
* options to use for fetching contextual messages and saving input/output messages.
|
|
364
|
-
*/
|
|
365
|
-
options?: Options): Promise<StreamObjectResult<DeepPartial<T>, T, never> & GenerationOutputMetadata>;
|
|
366
|
-
/**
|
|
367
|
-
* Save a message to the thread.
|
|
368
|
-
* @param ctx A ctx object from a mutation or action.
|
|
369
|
-
* @param args The message and what to associate it with (user / thread)
|
|
370
|
-
* You can pass extra metadata alongside the message, e.g. associated fileIds.
|
|
371
|
-
* @returns The messageId of the saved message.
|
|
372
|
-
*/
|
|
373
|
-
saveMessage(ctx: RunMutationCtx, args: {
|
|
374
|
-
threadId: string;
|
|
375
|
-
userId?: string;
|
|
376
|
-
/**
|
|
377
|
-
* Metadata to save with the messages. Each element corresponds to the
|
|
378
|
-
* message at the same index.
|
|
379
|
-
*/
|
|
380
|
-
metadata?: Omit<MessageWithMetadata, "message">;
|
|
381
|
-
/**
|
|
382
|
-
* If true, it will not generate embeddings for the message.
|
|
383
|
-
* Useful if you're saving messages in a mutation where you can't run `fetch`.
|
|
384
|
-
* You can generate them asynchronously by using the scheduler to run an
|
|
385
|
-
* action later that calls `agent.generateAndSaveEmbeddings`.
|
|
386
|
-
*/
|
|
387
|
-
skipEmbeddings?: boolean;
|
|
388
|
-
} & ({
|
|
389
|
-
prompt?: undefined;
|
|
390
|
-
/**
|
|
391
|
-
* The message to save.
|
|
392
|
-
*/
|
|
393
|
-
message: CoreMessage;
|
|
394
|
-
} | {
|
|
395
|
-
prompt: string;
|
|
396
|
-
message?: undefined;
|
|
397
|
-
})): Promise<{
|
|
398
|
-
messageId: string;
|
|
399
|
-
message: {
|
|
400
|
-
id?: string | undefined;
|
|
401
|
-
userId?: string | undefined;
|
|
402
|
-
embeddingId?: string | undefined;
|
|
403
|
-
fileIds?: string[] | undefined;
|
|
404
|
-
error?: string | undefined;
|
|
405
|
-
agentName?: string | undefined;
|
|
406
|
-
model?: string | undefined;
|
|
407
|
-
provider?: string | undefined;
|
|
408
|
-
providerOptions?: Record<string, Record<string, any>> | undefined;
|
|
409
|
-
message?: {
|
|
410
|
-
providerOptions?: Record<string, Record<string, any>> | undefined;
|
|
411
|
-
role: "user";
|
|
412
|
-
content: string | ({
|
|
413
|
-
providerOptions?: Record<string, Record<string, any>> | undefined;
|
|
414
|
-
type: "text";
|
|
415
|
-
text: string;
|
|
416
|
-
} | {
|
|
417
|
-
providerOptions?: Record<string, Record<string, any>> | undefined;
|
|
418
|
-
mimeType?: string | undefined;
|
|
419
|
-
type: "image";
|
|
420
|
-
image: string | ArrayBuffer;
|
|
421
|
-
} | {
|
|
422
|
-
providerOptions?: Record<string, Record<string, any>> | undefined;
|
|
423
|
-
filename?: string | undefined;
|
|
424
|
-
type: "file";
|
|
425
|
-
mimeType: string;
|
|
426
|
-
data: string | ArrayBuffer;
|
|
427
|
-
})[];
|
|
428
|
-
} | {
|
|
429
|
-
providerOptions?: Record<string, Record<string, any>> | undefined;
|
|
430
|
-
role: "assistant";
|
|
431
|
-
content: string | ({
|
|
432
|
-
providerOptions?: Record<string, Record<string, any>> | undefined;
|
|
433
|
-
type: "text";
|
|
434
|
-
text: string;
|
|
435
|
-
} | {
|
|
436
|
-
providerOptions?: Record<string, Record<string, any>> | undefined;
|
|
437
|
-
filename?: string | undefined;
|
|
438
|
-
type: "file";
|
|
439
|
-
mimeType: string;
|
|
440
|
-
data: string | ArrayBuffer;
|
|
441
|
-
} | {
|
|
442
|
-
providerOptions?: Record<string, Record<string, any>> | undefined;
|
|
443
|
-
signature?: string | undefined;
|
|
444
|
-
type: "reasoning";
|
|
445
|
-
text: string;
|
|
446
|
-
} | {
|
|
447
|
-
providerOptions?: Record<string, Record<string, any>> | undefined;
|
|
448
|
-
type: "redacted-reasoning";
|
|
449
|
-
data: string;
|
|
450
|
-
} | {
|
|
451
|
-
providerOptions?: Record<string, Record<string, any>> | undefined;
|
|
452
|
-
type: "tool-call";
|
|
453
|
-
toolCallId: string;
|
|
454
|
-
toolName: string;
|
|
455
|
-
args: any;
|
|
456
|
-
})[];
|
|
457
|
-
} | {
|
|
458
|
-
providerOptions?: Record<string, Record<string, any>> | undefined;
|
|
459
|
-
role: "tool";
|
|
460
|
-
content: {
|
|
461
|
-
providerOptions?: Record<string, Record<string, any>> | undefined;
|
|
462
|
-
args?: any;
|
|
463
|
-
experimental_content?: ({
|
|
464
|
-
type: "text";
|
|
465
|
-
text: string;
|
|
466
|
-
} | {
|
|
467
|
-
mimeType?: string | undefined;
|
|
468
|
-
type: "image";
|
|
469
|
-
data: string;
|
|
470
|
-
})[] | undefined;
|
|
471
|
-
isError?: boolean | undefined;
|
|
472
|
-
type: "tool-result";
|
|
473
|
-
toolCallId: string;
|
|
474
|
-
toolName: string;
|
|
475
|
-
result: any;
|
|
476
|
-
}[];
|
|
477
|
-
} | {
|
|
478
|
-
providerOptions?: Record<string, Record<string, any>> | undefined;
|
|
479
|
-
role: "system";
|
|
480
|
-
content: string;
|
|
481
|
-
} | undefined;
|
|
482
|
-
text?: string | undefined;
|
|
483
|
-
reasoning?: string | undefined;
|
|
484
|
-
usage?: {
|
|
485
|
-
promptTokens: number;
|
|
486
|
-
completionTokens: number;
|
|
487
|
-
totalTokens: number;
|
|
488
|
-
} | undefined;
|
|
489
|
-
providerMetadata?: Record<string, Record<string, any>> | undefined;
|
|
490
|
-
sources?: {
|
|
491
|
-
title?: string | undefined;
|
|
492
|
-
providerOptions?: Record<string, Record<string, any>> | undefined;
|
|
493
|
-
id: string;
|
|
494
|
-
sourceType: "url";
|
|
495
|
-
url: string;
|
|
496
|
-
}[] | undefined;
|
|
497
|
-
reasoningDetails?: ({
|
|
498
|
-
signature?: string | undefined;
|
|
499
|
-
type: "text";
|
|
500
|
-
text: string;
|
|
501
|
-
} | {
|
|
502
|
-
type: "redacted";
|
|
503
|
-
data: string;
|
|
504
|
-
})[] | undefined;
|
|
505
|
-
warnings?: ({
|
|
506
|
-
details?: string | undefined;
|
|
507
|
-
type: "unsupported-setting";
|
|
508
|
-
setting: string;
|
|
509
|
-
} | {
|
|
510
|
-
details?: string | undefined;
|
|
511
|
-
type: "unsupported-tool";
|
|
512
|
-
tool: any;
|
|
513
|
-
} | {
|
|
514
|
-
type: "other";
|
|
515
|
-
message: string;
|
|
516
|
-
})[] | undefined;
|
|
517
|
-
finishReason?: "length" | "error" | "other" | "stop" | "content-filter" | "tool-calls" | "unknown" | undefined;
|
|
518
|
-
_id: string;
|
|
519
|
-
_creationTime: number;
|
|
520
|
-
status: "pending" | "success" | "failed";
|
|
521
|
-
order: number;
|
|
522
|
-
threadId: string;
|
|
523
|
-
stepOrder: number;
|
|
524
|
-
tool: boolean;
|
|
525
|
-
};
|
|
526
|
-
}>;
|
|
527
|
-
/**
|
|
528
|
-
* Explicitly save messages associated with the thread (& user if provided)
|
|
529
|
-
* @param ctx The ctx parameter to a mutation or action.
|
|
530
|
-
* @param args The messages and context to save
|
|
531
|
-
* @returns
|
|
532
|
-
*/
|
|
533
|
-
saveMessages(ctx: RunMutationCtx | RunActionCtx, args: {
|
|
534
|
-
threadId: string;
|
|
535
|
-
userId?: string;
|
|
536
|
-
/**
|
|
537
|
-
* The message that these messages are in response to. They will be
|
|
538
|
-
* the same "order" as this message, at increasing stepOrder(s).
|
|
539
|
-
*/
|
|
540
|
-
promptMessageId?: string;
|
|
541
|
-
/**
|
|
542
|
-
* The messages to save.
|
|
543
|
-
*/
|
|
544
|
-
messages: CoreMessageMaybeWithId[];
|
|
545
|
-
/**
|
|
546
|
-
* Metadata to save with the messages. Each element corresponds to the
|
|
547
|
-
* message at the same index.
|
|
548
|
-
*/
|
|
549
|
-
metadata?: Omit<MessageWithMetadata, "message">[];
|
|
550
|
-
/**
|
|
551
|
-
* If false, it will "commit" the messages immediately.
|
|
552
|
-
* If true, it will mark them as pending until the final step has finished.
|
|
553
|
-
* Defaults to false.
|
|
554
|
-
*/
|
|
555
|
-
pending?: boolean;
|
|
556
|
-
/**
|
|
557
|
-
* If true, it will fail any pending steps.
|
|
558
|
-
* Defaults to false.
|
|
559
|
-
*/
|
|
560
|
-
failPendingSteps?: boolean;
|
|
561
|
-
/**
|
|
562
|
-
* Skip generating embeddings for the messages. Useful if you're
|
|
563
|
-
* saving messages in a mutation where you can't run `fetch`.
|
|
564
|
-
* You can generate them asynchronously by using the scheduler to run an
|
|
565
|
-
* action later that calls `agent.generateAndSaveEmbeddings`.
|
|
566
|
-
*/
|
|
567
|
-
skipEmbeddings?: boolean;
|
|
568
|
-
}): Promise<{
|
|
569
|
-
lastMessageId: string;
|
|
570
|
-
messages: MessageDoc[];
|
|
571
|
-
}>;
|
|
572
|
-
/**
|
|
573
|
-
* List messages from a thread.
|
|
574
|
-
* @param ctx A ctx object from a query, mutation, or action.
|
|
575
|
-
* @param args.threadId The thread to list messages from.
|
|
576
|
-
* @param args.paginationOpts Pagination options (e.g. via usePaginatedQuery).
|
|
577
|
-
* @param args.excludeToolMessages Whether to exclude tool messages.
|
|
578
|
-
* False by default.
|
|
579
|
-
* @param args.statuses What statuses to include. All by default.
|
|
580
|
-
* @returns The MessageDoc's in a format compatible with usePaginatedQuery.
|
|
581
|
-
*/
|
|
582
|
-
listMessages(ctx: RunQueryCtx, args: {
|
|
583
|
-
threadId: string;
|
|
584
|
-
paginationOpts: PaginationOptions;
|
|
585
|
-
excludeToolMessages?: boolean;
|
|
586
|
-
statuses?: MessageStatus[];
|
|
587
|
-
}): Promise<PaginationResult<MessageDoc>>;
|
|
588
|
-
/**
|
|
589
|
-
* A function that handles fetching stream deltas, used with the React hooks
|
|
590
|
-
* `useThreadMessages` or `useStreamingThreadMessages`.
|
|
591
|
-
* @param ctx A ctx object from a query, mutation, or action.
|
|
592
|
-
* @param args.threadId The thread to sync streams for.
|
|
593
|
-
* @param args.streamArgs The stream arguments with per-stream cursors.
|
|
594
|
-
* @returns The deltas for each stream from their existing cursor.
|
|
595
|
-
*/
|
|
596
|
-
syncStreams(ctx: RunQueryCtx, args: {
|
|
597
|
-
threadId: string;
|
|
598
|
-
streamArgs: StreamArgs | undefined;
|
|
599
|
-
}): Promise<SyncStreamsReturnValue | undefined>;
|
|
600
|
-
/**
|
|
601
|
-
* Fetch the context messages for a thread.
|
|
602
|
-
* @param ctx Either a query, mutation, or action ctx.
|
|
603
|
-
* If it is not an action context, you can't do text or
|
|
604
|
-
* vector search.
|
|
605
|
-
* @param args The associated thread, user, message
|
|
606
|
-
* @returns
|
|
607
|
-
*/
|
|
608
|
-
fetchContextMessages(ctx: RunQueryCtx | RunActionCtx, args: {
|
|
609
|
-
userId: string | undefined;
|
|
610
|
-
threadId: string | undefined;
|
|
611
|
-
messages: CoreMessage[];
|
|
612
|
-
/**
|
|
613
|
-
* If provided, it will search for messages up to and including this message.
|
|
614
|
-
* Note: if this is far in the past, text and vector search results may be more
|
|
615
|
-
* limited, as it's post-filtering the results.
|
|
616
|
-
*/
|
|
617
|
-
upToAndIncludingMessageId?: string;
|
|
618
|
-
contextOptions: ContextOptions | undefined;
|
|
619
|
-
}): Promise<MessageDoc[]>;
|
|
620
|
-
/**
|
|
621
|
-
* Get the metadata for a thread.
|
|
622
|
-
* @param ctx A ctx object from a query, mutation, or action.
|
|
623
|
-
* @param args.threadId The thread to get the metadata for.
|
|
624
|
-
* @returns The metadata for the thread.
|
|
625
|
-
*/
|
|
626
|
-
getThreadMetadata(ctx: RunQueryCtx, args: {
|
|
627
|
-
threadId: string;
|
|
628
|
-
}): Promise<ThreadDoc>;
|
|
629
|
-
/**
|
|
630
|
-
* Update the metadata for a thread.
|
|
631
|
-
* @param ctx A ctx object from a mutation or action.
|
|
632
|
-
* @param args.threadId The thread to update the metadata for.
|
|
633
|
-
* @param args.patch The patch to apply to the thread.
|
|
634
|
-
* @returns The updated thread metadata.
|
|
635
|
-
*/
|
|
636
|
-
updateThreadMetadata(ctx: RunMutationCtx, args: {
|
|
637
|
-
threadId: string;
|
|
638
|
-
patch: Partial<WithoutSystemFields<ThreadDoc>>;
|
|
639
|
-
}): Promise<ThreadDoc>;
|
|
640
|
-
/**
|
|
641
|
-
* Get the embeddings for a set of messages.
|
|
642
|
-
* @param messages The messages to get the embeddings for.
|
|
643
|
-
* @returns The embeddings for the messages.
|
|
644
|
-
*/
|
|
645
|
-
generateEmbeddings(ctx: RunActionCtx, { userId, threadId, }: {
|
|
646
|
-
userId: string | undefined;
|
|
647
|
-
threadId: string | undefined;
|
|
648
|
-
}, messages: CoreMessage[]): Promise<{
|
|
649
|
-
vectors: (number[] | null)[];
|
|
650
|
-
dimension: VectorDimension;
|
|
651
|
-
model: string;
|
|
652
|
-
} | undefined>;
|
|
653
|
-
/**
|
|
654
|
-
* Generate embeddings for a set of messages, and save them to the database.
|
|
655
|
-
* It will not generate or save embeddings for messages that already have an
|
|
656
|
-
* embedding.
|
|
657
|
-
* @param ctx The ctx parameter to an action.
|
|
658
|
-
* @param args The messageIds to generate embeddings for.
|
|
659
|
-
*/
|
|
660
|
-
generateAndSaveEmbeddings(ctx: RunActionCtx, args: {
|
|
661
|
-
messageIds: string[];
|
|
662
|
-
}): Promise<void>;
|
|
663
|
-
/**
|
|
664
|
-
* Explicitly save a "step" created by the AI SDK.
|
|
665
|
-
* @param ctx The ctx argument to a mutation or action.
|
|
666
|
-
* @param args The Step generated by the AI SDK.
|
|
667
|
-
*/
|
|
668
|
-
saveStep<TOOLS extends ToolSet>(ctx: ActionCtx, args: {
|
|
669
|
-
userId?: string;
|
|
670
|
-
threadId: string;
|
|
671
|
-
/**
|
|
672
|
-
* The message this step is in response to.
|
|
673
|
-
*/
|
|
674
|
-
promptMessageId: string;
|
|
675
|
-
/**
|
|
676
|
-
* The step to save, possibly including multiple tool calls.
|
|
677
|
-
*/
|
|
678
|
-
step: StepResult<TOOLS>;
|
|
679
|
-
/**
|
|
680
|
-
* The model used to generate the step.
|
|
681
|
-
* Defaults to the chat model for the Agent.
|
|
682
|
-
*/
|
|
683
|
-
model?: string;
|
|
684
|
-
/**
|
|
685
|
-
* The provider of the model used to generate the step.
|
|
686
|
-
* Defaults to the chat provider for the Agent.
|
|
687
|
-
*/
|
|
688
|
-
provider?: string;
|
|
689
|
-
}): Promise<{
|
|
690
|
-
messages: MessageDoc[];
|
|
691
|
-
pending?: MessageDoc;
|
|
692
|
-
}>;
|
|
693
|
-
/**
|
|
694
|
-
* Manually save the result of a generateObject call to the thread.
|
|
695
|
-
* This happens automatically when using {@link generateObject} or {@link streamObject}
|
|
696
|
-
* from the `thread` object created by {@link continueThread} or {@link createThread}.
|
|
697
|
-
* @param ctx The context passed from the mutation or action function calling this.
|
|
698
|
-
* @param args The arguments to the saveObject function.
|
|
699
|
-
*/
|
|
700
|
-
saveObject(ctx: ActionCtx, args: {
|
|
701
|
-
userId: string | undefined;
|
|
702
|
-
threadId: string;
|
|
703
|
-
promptMessageId: string;
|
|
704
|
-
result: GenerateObjectResult<unknown>;
|
|
705
|
-
metadata?: Omit<MessageWithMetadata, "message">;
|
|
706
|
-
}): Promise<void>;
|
|
707
|
-
/**
|
|
708
|
-
* Commit or rollback a message that was pending.
|
|
709
|
-
* This is done automatically when saving messages by default.
|
|
710
|
-
* If creating pending messages, you can call this when the full "transaction" is done.
|
|
711
|
-
* @param ctx The ctx argument to your mutation or action.
|
|
712
|
-
* @param args What message to save. Generally the parent message sent into
|
|
713
|
-
* the generateText call.
|
|
714
|
-
*/
|
|
715
|
-
completeMessage(ctx: RunMutationCtx, args: {
|
|
716
|
-
threadId: string;
|
|
717
|
-
messageId: string;
|
|
718
|
-
result: {
|
|
719
|
-
kind: "error";
|
|
720
|
-
error: string;
|
|
721
|
-
} | {
|
|
722
|
-
kind: "success";
|
|
723
|
-
};
|
|
724
|
-
}): Promise<void>;
|
|
725
|
-
_saveMessagesAndFetchContext<T extends {
|
|
726
|
-
id?: string;
|
|
727
|
-
prompt?: string;
|
|
728
|
-
messages?: CoreMessage[] | AIMessageWithoutId[];
|
|
729
|
-
system?: string;
|
|
730
|
-
promptMessageId?: string;
|
|
731
|
-
model?: LanguageModelV1;
|
|
732
|
-
maxRetries?: number;
|
|
733
|
-
}>(ctx: RunActionCtx, args: T, { userId: argsUserId, threadId, contextOptions, storageOptions, }: {
|
|
734
|
-
userId: string | undefined;
|
|
735
|
-
threadId: string | undefined;
|
|
736
|
-
} & Options): Promise<{
|
|
737
|
-
args: T & {
|
|
738
|
-
model: LanguageModelV1;
|
|
739
|
-
};
|
|
740
|
-
userId: string | undefined;
|
|
741
|
-
messageId: string | undefined;
|
|
742
|
-
order: number | undefined;
|
|
743
|
-
stepOrder: number | undefined;
|
|
744
|
-
}>;
|
|
745
|
-
_shouldSaveOutputMessages(storageOpts?: StorageOptions): boolean;
|
|
746
|
-
_mergedContextOptions(opts: ContextOptions | undefined): ContextOptions;
|
|
747
|
-
_searchOptionsWithEmbeddingAndDefaults(ctx: RunActionCtx, { userId, threadId }: {
|
|
748
|
-
userId?: string;
|
|
749
|
-
threadId?: string;
|
|
750
|
-
}, contextOptions: ContextOptions, messages: CoreMessage[]): Promise<SearchOptions>;
|
|
751
|
-
doEmbed(ctx: RunActionCtx, options: {
|
|
752
|
-
userId: string | undefined;
|
|
753
|
-
threadId: string | undefined;
|
|
754
|
-
values: string[];
|
|
755
|
-
abortSignal?: AbortSignal;
|
|
756
|
-
headers?: Record<string, string | undefined>;
|
|
757
|
-
}): Promise<{
|
|
758
|
-
embeddings: number[][];
|
|
759
|
-
}>;
|
|
760
|
-
/**
|
|
761
|
-
* Process messages to inline file and image URLs that point to localhost
|
|
762
|
-
* by converting them to base64. This solves the problem of LLMs not being
|
|
763
|
-
* able to access localhost URLs.
|
|
764
|
-
*/
|
|
765
|
-
private _inlineMessagesFiles;
|
|
766
|
-
/**
|
|
767
|
-
* Check if a URL points to localhost
|
|
768
|
-
*/
|
|
769
|
-
private _isLocalhostUrl;
|
|
770
|
-
/**
|
|
771
|
-
* Download a file from a URL
|
|
772
|
-
*/
|
|
773
|
-
private _downloadFile;
|
|
774
|
-
/**
|
|
775
|
-
* WORKFLOW UTILITIES
|
|
776
|
-
*/
|
|
777
|
-
/**
|
|
778
|
-
* Create a mutation that creates a thread so you can call it from a Workflow.
|
|
779
|
-
* e.g.
|
|
780
|
-
* ```ts
|
|
781
|
-
* // in convex/foo.ts
|
|
782
|
-
* export const createThread = weatherAgent.createThreadMutation();
|
|
783
|
-
*
|
|
784
|
-
* const workflow = new WorkflowManager(components.workflow);
|
|
785
|
-
* export const myWorkflow = workflow.define({
|
|
786
|
-
* args: {},
|
|
787
|
-
* handler: async (step) => {
|
|
788
|
-
* const { threadId } = await step.runMutation(internal.foo.createThread);
|
|
789
|
-
* // use the threadId to generate text, object, etc.
|
|
790
|
-
* },
|
|
791
|
-
* });
|
|
792
|
-
* ```
|
|
793
|
-
* @returns A mutation that creates a thread.
|
|
794
|
-
*/
|
|
795
|
-
createThreadMutation(): import("convex/server").RegisteredMutation<"internal", {
|
|
796
|
-
userId?: string | undefined;
|
|
797
|
-
title?: string | undefined;
|
|
798
|
-
summary?: string | undefined;
|
|
799
|
-
}, Promise<{
|
|
800
|
-
threadId: string;
|
|
801
|
-
}>>;
|
|
802
|
-
/**
|
|
803
|
-
* Create an action out of this agent so you can call it from workflows or other actions
|
|
804
|
-
* without a wrapping function.
|
|
805
|
-
* @param spec Configuration for the agent acting as an action, including
|
|
806
|
-
* {@link ContextOptions}, {@link StorageOptions}, and maxSteps.
|
|
807
|
-
*/
|
|
808
|
-
asTextAction(spec?: {
|
|
809
|
-
/**
|
|
810
|
-
* The maximum number of steps to take in this action.
|
|
811
|
-
* Defaults to the {@link Agent.maxSteps} option.
|
|
812
|
-
*/
|
|
813
|
-
maxSteps?: number;
|
|
814
|
-
/**
|
|
815
|
-
* The {@link ContextOptions} to use for fetching contextual messages and
|
|
816
|
-
* saving input/output messages.
|
|
817
|
-
* Defaults to the {@link Agent.contextOptions} option.
|
|
818
|
-
*/
|
|
819
|
-
contextOptions?: ContextOptions;
|
|
820
|
-
/**
|
|
821
|
-
* The {@link StorageOptions} to use for saving input/output messages.
|
|
822
|
-
* Defaults to the {@link Agent.storageOptions} option.
|
|
823
|
-
*/
|
|
824
|
-
storageOptions?: StorageOptions;
|
|
825
|
-
/**
|
|
826
|
-
* Whether to stream the text.
|
|
827
|
-
* If false, it will generate the text in a single call. (default)
|
|
828
|
-
* If true or {@link StreamingOptions}, it will stream the text from the LLM
|
|
829
|
-
* and save the chunks to the database with the options you specify, or the
|
|
830
|
-
* defaults if you pass true.
|
|
831
|
-
*/
|
|
832
|
-
stream?: boolean | StreamingOptions;
|
|
833
|
-
}): import("convex/server").RegisteredAction<"internal", {
|
|
834
|
-
userId?: string | undefined;
|
|
835
|
-
threadId?: string | undefined;
|
|
836
|
-
providerOptions?: Record<string, Record<string, any>> | undefined;
|
|
837
|
-
system?: string | undefined;
|
|
838
|
-
messages?: ({
|
|
839
|
-
providerOptions?: Record<string, Record<string, any>> | undefined;
|
|
840
|
-
role: "user";
|
|
841
|
-
content: string | ({
|
|
842
|
-
providerOptions?: Record<string, Record<string, any>> | undefined;
|
|
843
|
-
type: "text";
|
|
844
|
-
text: string;
|
|
845
|
-
} | {
|
|
846
|
-
providerOptions?: Record<string, Record<string, any>> | undefined;
|
|
847
|
-
mimeType?: string | undefined;
|
|
848
|
-
type: "image";
|
|
849
|
-
image: string | ArrayBuffer;
|
|
850
|
-
} | {
|
|
851
|
-
providerOptions?: Record<string, Record<string, any>> | undefined;
|
|
852
|
-
filename?: string | undefined;
|
|
853
|
-
type: "file";
|
|
854
|
-
mimeType: string;
|
|
855
|
-
data: string | ArrayBuffer;
|
|
856
|
-
})[];
|
|
857
|
-
} | {
|
|
858
|
-
providerOptions?: Record<string, Record<string, any>> | undefined;
|
|
859
|
-
role: "assistant";
|
|
860
|
-
content: string | ({
|
|
861
|
-
providerOptions?: Record<string, Record<string, any>> | undefined;
|
|
862
|
-
type: "text";
|
|
863
|
-
text: string;
|
|
864
|
-
} | {
|
|
865
|
-
providerOptions?: Record<string, Record<string, any>> | undefined;
|
|
866
|
-
filename?: string | undefined;
|
|
867
|
-
type: "file";
|
|
868
|
-
mimeType: string;
|
|
869
|
-
data: string | ArrayBuffer;
|
|
870
|
-
} | {
|
|
871
|
-
providerOptions?: Record<string, Record<string, any>> | undefined;
|
|
872
|
-
signature?: string | undefined;
|
|
873
|
-
type: "reasoning";
|
|
874
|
-
text: string;
|
|
875
|
-
} | {
|
|
876
|
-
providerOptions?: Record<string, Record<string, any>> | undefined;
|
|
877
|
-
type: "redacted-reasoning";
|
|
878
|
-
data: string;
|
|
879
|
-
} | {
|
|
880
|
-
providerOptions?: Record<string, Record<string, any>> | undefined;
|
|
881
|
-
type: "tool-call";
|
|
882
|
-
toolCallId: string;
|
|
883
|
-
toolName: string;
|
|
884
|
-
args: any;
|
|
885
|
-
})[];
|
|
886
|
-
} | {
|
|
887
|
-
providerOptions?: Record<string, Record<string, any>> | undefined;
|
|
888
|
-
role: "tool";
|
|
889
|
-
content: {
|
|
890
|
-
providerOptions?: Record<string, Record<string, any>> | undefined;
|
|
891
|
-
args?: any;
|
|
892
|
-
experimental_content?: ({
|
|
893
|
-
type: "text";
|
|
894
|
-
text: string;
|
|
895
|
-
} | {
|
|
896
|
-
mimeType?: string | undefined;
|
|
897
|
-
type: "image";
|
|
898
|
-
data: string;
|
|
899
|
-
})[] | undefined;
|
|
900
|
-
isError?: boolean | undefined;
|
|
901
|
-
type: "tool-result";
|
|
902
|
-
toolCallId: string;
|
|
903
|
-
toolName: string;
|
|
904
|
-
result: any;
|
|
905
|
-
}[];
|
|
906
|
-
} | {
|
|
907
|
-
providerOptions?: Record<string, Record<string, any>> | undefined;
|
|
908
|
-
role: "system";
|
|
909
|
-
content: string;
|
|
910
|
-
})[] | undefined;
|
|
911
|
-
headers?: Record<string, string> | undefined;
|
|
912
|
-
maxTokens?: number | undefined;
|
|
913
|
-
temperature?: number | undefined;
|
|
914
|
-
topP?: number | undefined;
|
|
915
|
-
topK?: number | undefined;
|
|
916
|
-
presencePenalty?: number | undefined;
|
|
917
|
-
frequencyPenalty?: number | undefined;
|
|
918
|
-
seed?: number | undefined;
|
|
919
|
-
maxRetries?: number | undefined;
|
|
920
|
-
stream?: boolean | undefined;
|
|
921
|
-
toolChoice?: "required" | "none" | "auto" | {
|
|
922
|
-
type: "tool";
|
|
923
|
-
toolName: string;
|
|
924
|
-
} | undefined;
|
|
925
|
-
maxSteps?: number | undefined;
|
|
926
|
-
experimental_continueSteps?: boolean | undefined;
|
|
927
|
-
prompt?: string | undefined;
|
|
928
|
-
promptMessageId?: string | undefined;
|
|
929
|
-
contextOptions?: {
|
|
930
|
-
excludeToolMessages?: boolean | undefined;
|
|
931
|
-
recentMessages?: number | undefined;
|
|
932
|
-
searchOptions?: {
|
|
933
|
-
messageRange?: {
|
|
934
|
-
before: number;
|
|
935
|
-
after: number;
|
|
936
|
-
} | undefined;
|
|
937
|
-
textSearch?: boolean | undefined;
|
|
938
|
-
vectorSearch?: boolean | undefined;
|
|
939
|
-
limit: number;
|
|
940
|
-
} | undefined;
|
|
941
|
-
searchOtherThreads?: boolean | undefined;
|
|
942
|
-
} | undefined;
|
|
943
|
-
storageOptions?: {
|
|
944
|
-
saveMessages?: "all" | "none" | "promptAndOutput";
|
|
945
|
-
saveAllInputMessages?: boolean;
|
|
946
|
-
saveAnyInputMessages?: boolean;
|
|
947
|
-
saveOutputMessages?: boolean;
|
|
948
|
-
} | undefined;
|
|
949
|
-
}, Promise<{
|
|
950
|
-
text: string;
|
|
951
|
-
finishReason: import("@ai-sdk/provider").LanguageModelV1FinishReason;
|
|
952
|
-
messageId: string | undefined;
|
|
953
|
-
}>>;
|
|
954
|
-
/**
|
|
955
|
-
* Create an action that generates an object out of this agent so you can call
|
|
956
|
-
* it from workflows or other actions without a wrapping function.
|
|
957
|
-
* @param spec Configuration for the agent acting as an action, including
|
|
958
|
-
* the normal parameters to {@link generateObject}, plus {@link ContextOptions}
|
|
959
|
-
* and maxSteps.
|
|
960
|
-
*/
|
|
961
|
-
asObjectAction<T>(spec: OurObjectArgs<T> & {
|
|
962
|
-
maxSteps?: number;
|
|
963
|
-
}, options?: {
|
|
964
|
-
contextOptions?: ContextOptions;
|
|
965
|
-
storageOptions?: StorageOptions;
|
|
966
|
-
}): import("convex/server").RegisteredAction<"internal", {
|
|
967
|
-
userId?: string | undefined;
|
|
968
|
-
threadId?: string | undefined;
|
|
969
|
-
providerOptions?: Record<string, Record<string, any>> | undefined;
|
|
970
|
-
system?: string | undefined;
|
|
971
|
-
messages?: ({
|
|
972
|
-
providerOptions?: Record<string, Record<string, any>> | undefined;
|
|
973
|
-
role: "user";
|
|
974
|
-
content: string | ({
|
|
975
|
-
providerOptions?: Record<string, Record<string, any>> | undefined;
|
|
976
|
-
type: "text";
|
|
977
|
-
text: string;
|
|
978
|
-
} | {
|
|
979
|
-
providerOptions?: Record<string, Record<string, any>> | undefined;
|
|
980
|
-
mimeType?: string | undefined;
|
|
981
|
-
type: "image";
|
|
982
|
-
image: string | ArrayBuffer;
|
|
983
|
-
} | {
|
|
984
|
-
providerOptions?: Record<string, Record<string, any>> | undefined;
|
|
985
|
-
filename?: string | undefined;
|
|
986
|
-
type: "file";
|
|
987
|
-
mimeType: string;
|
|
988
|
-
data: string | ArrayBuffer;
|
|
989
|
-
})[];
|
|
990
|
-
} | {
|
|
991
|
-
providerOptions?: Record<string, Record<string, any>> | undefined;
|
|
992
|
-
role: "assistant";
|
|
993
|
-
content: string | ({
|
|
994
|
-
providerOptions?: Record<string, Record<string, any>> | undefined;
|
|
995
|
-
type: "text";
|
|
996
|
-
text: string;
|
|
997
|
-
} | {
|
|
998
|
-
providerOptions?: Record<string, Record<string, any>> | undefined;
|
|
999
|
-
filename?: string | undefined;
|
|
1000
|
-
type: "file";
|
|
1001
|
-
mimeType: string;
|
|
1002
|
-
data: string | ArrayBuffer;
|
|
1003
|
-
} | {
|
|
1004
|
-
providerOptions?: Record<string, Record<string, any>> | undefined;
|
|
1005
|
-
signature?: string | undefined;
|
|
1006
|
-
type: "reasoning";
|
|
1007
|
-
text: string;
|
|
1008
|
-
} | {
|
|
1009
|
-
providerOptions?: Record<string, Record<string, any>> | undefined;
|
|
1010
|
-
type: "redacted-reasoning";
|
|
1011
|
-
data: string;
|
|
1012
|
-
} | {
|
|
1013
|
-
providerOptions?: Record<string, Record<string, any>> | undefined;
|
|
1014
|
-
type: "tool-call";
|
|
1015
|
-
toolCallId: string;
|
|
1016
|
-
toolName: string;
|
|
1017
|
-
args: any;
|
|
1018
|
-
})[];
|
|
1019
|
-
} | {
|
|
1020
|
-
providerOptions?: Record<string, Record<string, any>> | undefined;
|
|
1021
|
-
role: "tool";
|
|
1022
|
-
content: {
|
|
1023
|
-
providerOptions?: Record<string, Record<string, any>> | undefined;
|
|
1024
|
-
args?: any;
|
|
1025
|
-
experimental_content?: ({
|
|
1026
|
-
type: "text";
|
|
1027
|
-
text: string;
|
|
1028
|
-
} | {
|
|
1029
|
-
mimeType?: string | undefined;
|
|
1030
|
-
type: "image";
|
|
1031
|
-
data: string;
|
|
1032
|
-
})[] | undefined;
|
|
1033
|
-
isError?: boolean | undefined;
|
|
1034
|
-
type: "tool-result";
|
|
1035
|
-
toolCallId: string;
|
|
1036
|
-
toolName: string;
|
|
1037
|
-
result: any;
|
|
1038
|
-
}[];
|
|
1039
|
-
} | {
|
|
1040
|
-
providerOptions?: Record<string, Record<string, any>> | undefined;
|
|
1041
|
-
role: "system";
|
|
1042
|
-
content: string;
|
|
1043
|
-
})[] | undefined;
|
|
1044
|
-
headers?: Record<string, string> | undefined;
|
|
1045
|
-
maxTokens?: number | undefined;
|
|
1046
|
-
temperature?: number | undefined;
|
|
1047
|
-
topP?: number | undefined;
|
|
1048
|
-
topK?: number | undefined;
|
|
1049
|
-
presencePenalty?: number | undefined;
|
|
1050
|
-
frequencyPenalty?: number | undefined;
|
|
1051
|
-
seed?: number | undefined;
|
|
1052
|
-
maxRetries?: number | undefined;
|
|
1053
|
-
prompt?: string | undefined;
|
|
1054
|
-
promptMessageId?: string | undefined;
|
|
1055
|
-
contextOptions?: {
|
|
1056
|
-
excludeToolMessages?: boolean | undefined;
|
|
1057
|
-
recentMessages?: number | undefined;
|
|
1058
|
-
searchOptions?: {
|
|
1059
|
-
messageRange?: {
|
|
1060
|
-
before: number;
|
|
1061
|
-
after: number;
|
|
1062
|
-
} | undefined;
|
|
1063
|
-
textSearch?: boolean | undefined;
|
|
1064
|
-
vectorSearch?: boolean | undefined;
|
|
1065
|
-
limit: number;
|
|
1066
|
-
} | undefined;
|
|
1067
|
-
searchOtherThreads?: boolean | undefined;
|
|
1068
|
-
} | undefined;
|
|
1069
|
-
storageOptions?: {
|
|
1070
|
-
saveMessages?: "all" | "none" | "promptAndOutput";
|
|
1071
|
-
saveAllInputMessages?: boolean;
|
|
1072
|
-
saveAnyInputMessages?: boolean;
|
|
1073
|
-
saveOutputMessages?: boolean;
|
|
1074
|
-
} | undefined;
|
|
1075
|
-
}, Promise<{
|
|
1076
|
-
object: T;
|
|
1077
|
-
}>>;
|
|
1078
|
-
/**
|
|
1079
|
-
* Save messages to the thread.
|
|
1080
|
-
* Useful as a step in Workflows, e.g.
|
|
1081
|
-
* ```ts
|
|
1082
|
-
* const saveMessages = agent.asSaveMessagesMutation();
|
|
1083
|
-
*
|
|
1084
|
-
* const myWorkflow = workflow.define({
|
|
1085
|
-
* args: {...},
|
|
1086
|
-
* handler: async (step, args) => {
|
|
1087
|
-
* // do things to create (but not save)messages
|
|
1088
|
-
* const { messageIds } = await step.runMutation(internal.foo.saveMessages, {
|
|
1089
|
-
* threadId: args.threadId,
|
|
1090
|
-
* messages: args.messages,
|
|
1091
|
-
* });
|
|
1092
|
-
* // ...
|
|
1093
|
-
* },
|
|
1094
|
-
* })
|
|
1095
|
-
* ```
|
|
1096
|
-
* @returns A mutation that can be used to save messages to the thread.
|
|
1097
|
-
*/
|
|
1098
|
-
asSaveMessagesMutation(): import("convex/server").RegisteredMutation<"internal", {
|
|
1099
|
-
userId?: string | undefined;
|
|
1100
|
-
pending?: boolean | undefined;
|
|
1101
|
-
promptMessageId?: string | undefined;
|
|
1102
|
-
failPendingSteps?: boolean | undefined;
|
|
1103
|
-
threadId: string;
|
|
1104
|
-
messages: {
|
|
1105
|
-
id?: string | undefined;
|
|
1106
|
-
fileIds?: string[] | undefined;
|
|
1107
|
-
error?: string | undefined;
|
|
1108
|
-
model?: string | undefined;
|
|
1109
|
-
provider?: string | undefined;
|
|
1110
|
-
text?: string | undefined;
|
|
1111
|
-
reasoning?: string | undefined;
|
|
1112
|
-
usage?: {
|
|
1113
|
-
promptTokens: number;
|
|
1114
|
-
completionTokens: number;
|
|
1115
|
-
totalTokens: number;
|
|
1116
|
-
} | undefined;
|
|
1117
|
-
providerMetadata?: Record<string, Record<string, any>> | undefined;
|
|
1118
|
-
sources?: {
|
|
1119
|
-
title?: string | undefined;
|
|
1120
|
-
providerOptions?: Record<string, Record<string, any>> | undefined;
|
|
1121
|
-
id: string;
|
|
1122
|
-
sourceType: "url";
|
|
1123
|
-
url: string;
|
|
1124
|
-
}[] | undefined;
|
|
1125
|
-
reasoningDetails?: ({
|
|
1126
|
-
signature?: string | undefined;
|
|
1127
|
-
type: "text";
|
|
1128
|
-
text: string;
|
|
1129
|
-
} | {
|
|
1130
|
-
type: "redacted";
|
|
1131
|
-
data: string;
|
|
1132
|
-
})[] | undefined;
|
|
1133
|
-
warnings?: ({
|
|
1134
|
-
details?: string | undefined;
|
|
1135
|
-
type: "unsupported-setting";
|
|
1136
|
-
setting: string;
|
|
1137
|
-
} | {
|
|
1138
|
-
details?: string | undefined;
|
|
1139
|
-
type: "unsupported-tool";
|
|
1140
|
-
tool: any;
|
|
1141
|
-
} | {
|
|
1142
|
-
type: "other";
|
|
1143
|
-
message: string;
|
|
1144
|
-
})[] | undefined;
|
|
1145
|
-
finishReason?: "length" | "error" | "other" | "stop" | "content-filter" | "tool-calls" | "unknown" | undefined;
|
|
1146
|
-
message: {
|
|
1147
|
-
providerOptions?: Record<string, Record<string, any>> | undefined;
|
|
1148
|
-
role: "user";
|
|
1149
|
-
content: string | ({
|
|
1150
|
-
providerOptions?: Record<string, Record<string, any>> | undefined;
|
|
1151
|
-
type: "text";
|
|
1152
|
-
text: string;
|
|
1153
|
-
} | {
|
|
1154
|
-
providerOptions?: Record<string, Record<string, any>> | undefined;
|
|
1155
|
-
mimeType?: string | undefined;
|
|
1156
|
-
type: "image";
|
|
1157
|
-
image: string | ArrayBuffer;
|
|
1158
|
-
} | {
|
|
1159
|
-
providerOptions?: Record<string, Record<string, any>> | undefined;
|
|
1160
|
-
filename?: string | undefined;
|
|
1161
|
-
type: "file";
|
|
1162
|
-
mimeType: string;
|
|
1163
|
-
data: string | ArrayBuffer;
|
|
1164
|
-
})[];
|
|
1165
|
-
} | {
|
|
1166
|
-
providerOptions?: Record<string, Record<string, any>> | undefined;
|
|
1167
|
-
role: "assistant";
|
|
1168
|
-
content: string | ({
|
|
1169
|
-
providerOptions?: Record<string, Record<string, any>> | undefined;
|
|
1170
|
-
type: "text";
|
|
1171
|
-
text: string;
|
|
1172
|
-
} | {
|
|
1173
|
-
providerOptions?: Record<string, Record<string, any>> | undefined;
|
|
1174
|
-
filename?: string | undefined;
|
|
1175
|
-
type: "file";
|
|
1176
|
-
mimeType: string;
|
|
1177
|
-
data: string | ArrayBuffer;
|
|
1178
|
-
} | {
|
|
1179
|
-
providerOptions?: Record<string, Record<string, any>> | undefined;
|
|
1180
|
-
signature?: string | undefined;
|
|
1181
|
-
type: "reasoning";
|
|
1182
|
-
text: string;
|
|
1183
|
-
} | {
|
|
1184
|
-
providerOptions?: Record<string, Record<string, any>> | undefined;
|
|
1185
|
-
type: "redacted-reasoning";
|
|
1186
|
-
data: string;
|
|
1187
|
-
} | {
|
|
1188
|
-
providerOptions?: Record<string, Record<string, any>> | undefined;
|
|
1189
|
-
type: "tool-call";
|
|
1190
|
-
toolCallId: string;
|
|
1191
|
-
toolName: string;
|
|
1192
|
-
args: any;
|
|
1193
|
-
})[];
|
|
1194
|
-
} | {
|
|
1195
|
-
providerOptions?: Record<string, Record<string, any>> | undefined;
|
|
1196
|
-
role: "tool";
|
|
1197
|
-
content: {
|
|
1198
|
-
providerOptions?: Record<string, Record<string, any>> | undefined;
|
|
1199
|
-
args?: any;
|
|
1200
|
-
experimental_content?: ({
|
|
1201
|
-
type: "text";
|
|
1202
|
-
text: string;
|
|
1203
|
-
} | {
|
|
1204
|
-
mimeType?: string | undefined;
|
|
1205
|
-
type: "image";
|
|
1206
|
-
data: string;
|
|
1207
|
-
})[] | undefined;
|
|
1208
|
-
isError?: boolean | undefined;
|
|
1209
|
-
type: "tool-result";
|
|
1210
|
-
toolCallId: string;
|
|
1211
|
-
toolName: string;
|
|
1212
|
-
result: any;
|
|
1213
|
-
}[];
|
|
1214
|
-
} | {
|
|
1215
|
-
providerOptions?: Record<string, Record<string, any>> | undefined;
|
|
1216
|
-
role: "system";
|
|
1217
|
-
content: string;
|
|
1218
|
-
};
|
|
1219
|
-
}[];
|
|
1220
|
-
}, Promise<{
|
|
1221
|
-
lastMessageId: string;
|
|
1222
|
-
messageIds: string[];
|
|
1223
|
-
}>>;
|
|
1224
|
-
}
|
|
1225
|
-
export declare function filterOutOrphanedToolMessages(docs: MessageDoc[]): {
|
|
1226
|
-
id?: string | undefined;
|
|
1227
|
-
userId?: string | undefined;
|
|
1228
|
-
embeddingId?: string | undefined;
|
|
1229
|
-
fileIds?: string[] | undefined;
|
|
1230
|
-
error?: string | undefined;
|
|
1231
|
-
agentName?: string | undefined;
|
|
1232
|
-
model?: string | undefined;
|
|
1233
|
-
provider?: string | undefined;
|
|
1234
|
-
providerOptions?: Record<string, Record<string, any>> | undefined;
|
|
1235
|
-
message?: {
|
|
1236
|
-
providerOptions?: Record<string, Record<string, any>> | undefined;
|
|
1237
|
-
role: "user";
|
|
1238
|
-
content: string | ({
|
|
1239
|
-
providerOptions?: Record<string, Record<string, any>> | undefined;
|
|
1240
|
-
type: "text";
|
|
1241
|
-
text: string;
|
|
1242
|
-
} | {
|
|
1243
|
-
providerOptions?: Record<string, Record<string, any>> | undefined;
|
|
1244
|
-
mimeType?: string | undefined;
|
|
1245
|
-
type: "image";
|
|
1246
|
-
image: string | ArrayBuffer;
|
|
1247
|
-
} | {
|
|
1248
|
-
providerOptions?: Record<string, Record<string, any>> | undefined;
|
|
1249
|
-
filename?: string | undefined;
|
|
1250
|
-
type: "file";
|
|
1251
|
-
mimeType: string;
|
|
1252
|
-
data: string | ArrayBuffer;
|
|
1253
|
-
})[];
|
|
1254
|
-
} | {
|
|
1255
|
-
providerOptions?: Record<string, Record<string, any>> | undefined;
|
|
1256
|
-
role: "assistant";
|
|
1257
|
-
content: string | ({
|
|
1258
|
-
providerOptions?: Record<string, Record<string, any>> | undefined;
|
|
1259
|
-
type: "text";
|
|
1260
|
-
text: string;
|
|
1261
|
-
} | {
|
|
1262
|
-
providerOptions?: Record<string, Record<string, any>> | undefined;
|
|
1263
|
-
filename?: string | undefined;
|
|
1264
|
-
type: "file";
|
|
1265
|
-
mimeType: string;
|
|
1266
|
-
data: string | ArrayBuffer;
|
|
1267
|
-
} | {
|
|
1268
|
-
providerOptions?: Record<string, Record<string, any>> | undefined;
|
|
1269
|
-
signature?: string | undefined;
|
|
1270
|
-
type: "reasoning";
|
|
1271
|
-
text: string;
|
|
1272
|
-
} | {
|
|
1273
|
-
providerOptions?: Record<string, Record<string, any>> | undefined;
|
|
1274
|
-
type: "redacted-reasoning";
|
|
1275
|
-
data: string;
|
|
1276
|
-
} | {
|
|
1277
|
-
providerOptions?: Record<string, Record<string, any>> | undefined;
|
|
1278
|
-
type: "tool-call";
|
|
1279
|
-
toolCallId: string;
|
|
1280
|
-
toolName: string;
|
|
1281
|
-
args: any;
|
|
1282
|
-
})[];
|
|
1283
|
-
} | {
|
|
1284
|
-
providerOptions?: Record<string, Record<string, any>> | undefined;
|
|
1285
|
-
role: "tool";
|
|
1286
|
-
content: {
|
|
1287
|
-
providerOptions?: Record<string, Record<string, any>> | undefined;
|
|
1288
|
-
args?: any;
|
|
1289
|
-
experimental_content?: ({
|
|
1290
|
-
type: "text";
|
|
1291
|
-
text: string;
|
|
1292
|
-
} | {
|
|
1293
|
-
mimeType?: string | undefined;
|
|
1294
|
-
type: "image";
|
|
1295
|
-
data: string;
|
|
1296
|
-
})[] | undefined;
|
|
1297
|
-
isError?: boolean | undefined;
|
|
1298
|
-
type: "tool-result";
|
|
1299
|
-
toolCallId: string;
|
|
1300
|
-
toolName: string;
|
|
1301
|
-
result: any;
|
|
1302
|
-
}[];
|
|
1303
|
-
} | {
|
|
1304
|
-
providerOptions?: Record<string, Record<string, any>> | undefined;
|
|
1305
|
-
role: "system";
|
|
1306
|
-
content: string;
|
|
1307
|
-
} | undefined;
|
|
1308
|
-
text?: string | undefined;
|
|
1309
|
-
reasoning?: string | undefined;
|
|
1310
|
-
usage?: {
|
|
1311
|
-
promptTokens: number;
|
|
1312
|
-
completionTokens: number;
|
|
1313
|
-
totalTokens: number;
|
|
1314
|
-
} | undefined;
|
|
1315
|
-
providerMetadata?: Record<string, Record<string, any>> | undefined;
|
|
1316
|
-
sources?: {
|
|
1317
|
-
title?: string | undefined;
|
|
1318
|
-
providerOptions?: Record<string, Record<string, any>> | undefined;
|
|
1319
|
-
id: string;
|
|
1320
|
-
sourceType: "url";
|
|
1321
|
-
url: string;
|
|
1322
|
-
}[] | undefined;
|
|
1323
|
-
reasoningDetails?: ({
|
|
1324
|
-
signature?: string | undefined;
|
|
1325
|
-
type: "text";
|
|
1326
|
-
text: string;
|
|
1327
|
-
} | {
|
|
1328
|
-
type: "redacted";
|
|
1329
|
-
data: string;
|
|
1330
|
-
})[] | undefined;
|
|
1331
|
-
warnings?: ({
|
|
1332
|
-
details?: string | undefined;
|
|
1333
|
-
type: "unsupported-setting";
|
|
1334
|
-
setting: string;
|
|
1335
|
-
} | {
|
|
1336
|
-
details?: string | undefined;
|
|
1337
|
-
type: "unsupported-tool";
|
|
1338
|
-
tool: any;
|
|
1339
|
-
} | {
|
|
1340
|
-
type: "other";
|
|
1341
|
-
message: string;
|
|
1342
|
-
})[] | undefined;
|
|
1343
|
-
finishReason?: "length" | "error" | "other" | "stop" | "content-filter" | "tool-calls" | "unknown" | undefined;
|
|
1344
|
-
_id: string;
|
|
1345
|
-
_creationTime: number;
|
|
1346
|
-
status: "pending" | "success" | "failed";
|
|
1347
|
-
order: number;
|
|
1348
|
-
threadId: string;
|
|
1349
|
-
stepOrder: number;
|
|
1350
|
-
tool: boolean;
|
|
1351
|
-
}[];
|
|
1352
|
-
type CoreMessageMaybeWithId = CoreMessage & {
|
|
1353
|
-
id?: string | undefined;
|
|
1354
|
-
};
|
|
1355
|
-
//# sourceMappingURL=index.d.ts.map
|