@convex-dev/agent 0.6.4 → 0.7.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/MIGRATION.md +60 -116
- package/dist/client/messages.d.ts +1 -398
- package/dist/client/messages.d.ts.map +1 -1
- package/dist/client/messages.js +3 -47
- package/dist/client/messages.js.map +1 -1
- package/dist/client/types.d.ts +1 -455
- package/dist/client/types.d.ts.map +1 -1
- package/dist/component/_generated/component.d.ts +805 -45
- package/dist/component/_generated/component.d.ts.map +1 -1
- package/dist/component/messages.d.ts +1252 -201
- package/dist/component/messages.d.ts.map +1 -1
- package/dist/component/messages.js +49 -23
- package/dist/component/messages.js.map +1 -1
- package/dist/component/schema.d.ts +2593 -332
- package/dist/component/schema.d.ts.map +1 -1
- package/dist/component/streams.d.ts +7 -1
- package/dist/component/streams.d.ts.map +1 -1
- package/dist/component/streams.js +24 -30
- package/dist/component/streams.js.map +1 -1
- package/dist/component/threads.d.ts.map +1 -1
- package/dist/component/threads.js +1 -2
- package/dist/component/threads.js.map +1 -1
- package/dist/react/index.d.ts +5 -5
- package/dist/react/index.d.ts.map +1 -1
- package/dist/react/index.js +5 -5
- package/dist/react/index.js.map +1 -1
- package/dist/shared.d.ts +19 -7
- package/dist/shared.d.ts.map +1 -1
- package/dist/shared.js +4 -4
- package/dist/shared.js.map +1 -1
- package/dist/streaming/materializePersistedUIMessageChunks.d.ts +16 -0
- package/dist/streaming/materializePersistedUIMessageChunks.d.ts.map +1 -0
- package/dist/streaming/materializePersistedUIMessageChunks.js +302 -0
- package/dist/streaming/materializePersistedUIMessageChunks.js.map +1 -0
- package/dist/streaming/persistedUIMessageChunks.d.ts +106 -0
- package/dist/streaming/persistedUIMessageChunks.d.ts.map +1 -0
- package/dist/streaming/persistedUIMessageChunks.js +475 -0
- package/dist/streaming/persistedUIMessageChunks.js.map +1 -0
- package/dist/validators.d.ts +10026 -1055
- package/dist/validators.d.ts.map +1 -1
- package/dist/validators.js +71 -9
- package/dist/validators.js.map +1 -1
- package/dist/{UIMessages.d.ts → vercel/UIMessages.d.ts} +1 -1
- package/dist/vercel/UIMessages.d.ts.map +1 -0
- package/dist/{UIMessages.js → vercel/UIMessages.js} +63 -1
- package/dist/vercel/UIMessages.js.map +1 -0
- package/dist/{client → vercel/client}/createTool.d.ts +23 -16
- package/dist/vercel/client/createTool.d.ts.map +1 -0
- package/dist/{client → vercel/client}/createTool.js +2 -0
- package/dist/vercel/client/createTool.js.map +1 -0
- package/dist/{client → vercel/client}/definePlaygroundAPI.d.ts +533 -79
- package/dist/{client → vercel/client}/definePlaygroundAPI.d.ts.map +1 -1
- package/dist/{client → vercel/client}/definePlaygroundAPI.js +8 -7
- package/dist/vercel/client/definePlaygroundAPI.js.map +1 -0
- package/dist/{client → vercel/client}/files.d.ts +2 -2
- package/dist/vercel/client/files.d.ts.map +1 -0
- package/dist/vercel/client/files.js.map +1 -0
- package/dist/vercel/client/messages.d.ts +542 -0
- package/dist/vercel/client/messages.d.ts.map +1 -0
- package/dist/vercel/client/messages.js +66 -0
- package/dist/vercel/client/messages.js.map +1 -0
- package/dist/{client → vercel/client}/mockModel.d.ts +17 -17
- package/dist/vercel/client/mockModel.d.ts.map +1 -0
- package/dist/{client → vercel/client}/mockModel.js +12 -13
- package/dist/vercel/client/mockModel.js.map +1 -0
- package/dist/{client → vercel/client}/saveInputMessages.d.ts +2 -2
- package/dist/vercel/client/saveInputMessages.d.ts.map +1 -0
- package/dist/vercel/client/saveInputMessages.js.map +1 -0
- package/dist/{client → vercel/client}/search.d.ts +119 -22
- package/dist/vercel/client/search.d.ts.map +1 -0
- package/dist/{client → vercel/client}/search.js +2 -2
- package/dist/vercel/client/search.js.map +1 -0
- package/dist/{client → vercel/client}/start.d.ts +26 -11
- package/dist/vercel/client/start.d.ts.map +1 -0
- package/dist/{client → vercel/client}/start.js +64 -22
- package/dist/vercel/client/start.js.map +1 -0
- package/dist/{client → vercel/client}/streamText.d.ts +13 -12
- package/dist/vercel/client/streamText.d.ts.map +1 -0
- package/dist/{client → vercel/client}/streamText.js +43 -9
- package/dist/vercel/client/streamText.js.map +1 -0
- package/dist/{client → vercel/client}/streaming.d.ts +1410 -183
- package/dist/vercel/client/streaming.d.ts.map +1 -0
- package/dist/{client → vercel/client}/streaming.js +120 -52
- package/dist/vercel/client/streaming.js.map +1 -0
- package/dist/vercel/client/types.d.ts +456 -0
- package/dist/vercel/client/types.d.ts.map +1 -0
- package/dist/vercel/client/types.js +3 -0
- package/dist/vercel/client/types.js.map +1 -0
- package/dist/{client → vercel/client}/utils.d.ts +3 -2
- package/dist/vercel/client/utils.d.ts.map +1 -0
- package/dist/{client → vercel/client}/utils.js +2 -2
- package/dist/vercel/client/utils.js.map +1 -0
- package/dist/{deltas.d.ts → vercel/deltas.d.ts} +3 -4
- package/dist/vercel/deltas.d.ts.map +1 -0
- package/dist/{deltas.js → vercel/deltas.js} +195 -99
- package/dist/vercel/deltas.js.map +1 -0
- package/dist/{client → vercel}/index.d.ts +482 -106
- package/dist/vercel/index.d.ts.map +1 -0
- package/dist/{client → vercel}/index.js +64 -46
- package/dist/vercel/index.js.map +1 -0
- package/dist/{mapping.d.ts → vercel/mapping.d.ts} +5 -19
- package/dist/vercel/mapping.d.ts.map +1 -0
- package/dist/{mapping.js → vercel/mapping.js} +411 -114
- package/dist/vercel/mapping.js.map +1 -0
- package/dist/{react → vercel/react}/optimisticallySendMessage.d.ts +2 -2
- package/dist/vercel/react/optimisticallySendMessage.d.ts.map +1 -0
- package/dist/vercel/react/optimisticallySendMessage.js.map +1 -0
- package/dist/{react → vercel/react}/types.d.ts +1 -1
- package/dist/vercel/react/types.d.ts.map +1 -0
- package/dist/{react → vercel/react}/types.js.map +1 -1
- package/dist/{react → vercel/react}/useDeltaStreams.d.ts +1 -1
- package/dist/vercel/react/useDeltaStreams.d.ts.map +1 -0
- package/dist/{react → vercel/react}/useDeltaStreams.js +1 -1
- package/dist/vercel/react/useDeltaStreams.js.map +1 -0
- package/dist/{react → vercel/react}/useStreamingUIMessages.d.ts +1 -1
- package/dist/vercel/react/useStreamingUIMessages.d.ts.map +1 -0
- package/dist/{react → vercel/react}/useStreamingUIMessages.js +7 -3
- package/dist/vercel/react/useStreamingUIMessages.js.map +1 -0
- package/dist/{react → vercel/react}/useThreadMessages.d.ts +1 -1
- package/dist/vercel/react/useThreadMessages.d.ts.map +1 -0
- package/dist/{react → vercel/react}/useThreadMessages.js +1 -1
- package/dist/vercel/react/useThreadMessages.js.map +1 -0
- package/dist/{react → vercel/react}/useUIMessages.d.ts +1 -1
- package/dist/vercel/react/useUIMessages.d.ts.map +1 -0
- package/dist/{react → vercel/react}/useUIMessages.js +1 -1
- package/dist/vercel/react/useUIMessages.js.map +1 -0
- package/package.json +29 -22
- package/src/client/messages.ts +5 -107
- package/src/client/types.ts +0 -608
- package/src/component/_generated/component.ts +1089 -48
- package/src/component/messages.test.ts +273 -1
- package/src/component/messages.ts +62 -32
- package/src/component/streams.ts +47 -47
- package/src/component/threads.ts +5 -2
- package/src/eslintConfig.test.ts +44 -0
- package/src/react/index.ts +8 -5
- package/src/shared.ts +26 -36
- package/src/streaming/materializePersistedUIMessageChunks.test.ts +513 -0
- package/src/streaming/materializePersistedUIMessageChunks.ts +398 -0
- package/src/streaming/persistedUIMessageChunks.test.ts +205 -0
- package/src/streaming/persistedUIMessageChunks.ts +658 -0
- package/src/validators.test.ts +4 -1
- package/src/validators.ts +89 -8
- package/src/{UIMessages.combineUIMessages.test.ts → vercel/UIMessages.combineUIMessages.test.ts} +4 -1
- package/src/{UIMessages.ts → vercel/UIMessages.ts} +95 -3
- package/src/{client → vercel/client}/approval.test.ts +23 -13
- package/src/{client → vercel/client}/createTool.ts +62 -22
- package/src/{client → vercel/client}/definePlaygroundAPI.ts +15 -16
- package/src/{client → vercel/client}/files.ts +2 -2
- package/src/{client → vercel/client}/index.test.ts +99 -31
- package/src/vercel/client/messages.ts +182 -0
- package/src/{client → vercel/client}/mockModel.ts +38 -39
- package/src/{client → vercel/client}/saveInputMessages.test.ts +1 -1
- package/src/{client → vercel/client}/saveInputMessages.ts +3 -3
- package/src/{client → vercel/client}/search.test.ts +3 -3
- package/src/{client → vercel/client}/search.ts +4 -4
- package/src/{client → vercel/client}/setup.test.ts +6 -3
- package/src/vercel/client/start.test.ts +14 -0
- package/src/{client → vercel/client}/start.ts +147 -36
- package/src/vercel/client/streamText.test.ts +223 -0
- package/src/{client → vercel/client}/streamText.ts +102 -31
- package/src/{client → vercel/client}/streaming.integration.test.ts +6 -3
- package/src/{client → vercel/client}/streaming.test.ts +178 -4
- package/src/{client → vercel/client}/streaming.ts +114 -52
- package/src/vercel/client/types.test.ts +13 -0
- package/src/vercel/client/types.ts +679 -0
- package/src/{client → vercel/client}/utils.ts +13 -7
- package/src/{deltas.test.ts → vercel/deltas.test.ts} +384 -93
- package/src/{deltas.ts → vercel/deltas.ts} +218 -115
- package/src/{fromUIMessages.test.ts → vercel/fromUIMessages.test.ts} +17 -1
- package/src/{client → vercel}/index.ts +167 -84
- package/src/{mapping.test.ts → vercel/mapping.test.ts} +377 -92
- package/src/{mapping.ts → vercel/mapping.ts} +501 -137
- package/src/{react → vercel/react}/optimisticallySendMessage.ts +2 -2
- package/src/{react → vercel/react}/types.ts +1 -1
- package/src/{react → vercel/react}/useDeltaStreams.ts +6 -2
- package/src/{react → vercel/react}/useStreamingUIMessages.ts +7 -3
- package/src/{react → vercel/react}/useThreadMessages.ts +2 -2
- package/src/{react → vercel/react}/useUIMessages.ts +2 -2
- package/src/{toUIMessages.test.ts → vercel/toUIMessages.test.ts} +49 -2
- package/dist/UIMessages.d.ts.map +0 -1
- package/dist/UIMessages.js.map +0 -1
- package/dist/client/createTool.d.ts.map +0 -1
- package/dist/client/createTool.js.map +0 -1
- package/dist/client/definePlaygroundAPI.js.map +0 -1
- package/dist/client/files.d.ts.map +0 -1
- package/dist/client/files.js.map +0 -1
- package/dist/client/index.d.ts.map +0 -1
- package/dist/client/index.js.map +0 -1
- package/dist/client/mockModel.d.ts.map +0 -1
- package/dist/client/mockModel.js.map +0 -1
- package/dist/client/saveInputMessages.d.ts.map +0 -1
- package/dist/client/saveInputMessages.js.map +0 -1
- package/dist/client/search.d.ts.map +0 -1
- package/dist/client/search.js.map +0 -1
- package/dist/client/start.d.ts.map +0 -1
- package/dist/client/start.js.map +0 -1
- package/dist/client/streamText.d.ts.map +0 -1
- package/dist/client/streamText.js.map +0 -1
- package/dist/client/streaming.d.ts.map +0 -1
- package/dist/client/streaming.js.map +0 -1
- package/dist/client/utils.d.ts.map +0 -1
- package/dist/client/utils.js.map +0 -1
- package/dist/deltas.d.ts.map +0 -1
- package/dist/deltas.js.map +0 -1
- package/dist/mapping.d.ts.map +0 -1
- package/dist/mapping.js.map +0 -1
- package/dist/react/optimisticallySendMessage.d.ts.map +0 -1
- package/dist/react/optimisticallySendMessage.js.map +0 -1
- package/dist/react/types.d.ts.map +0 -1
- package/dist/react/useDeltaStreams.d.ts.map +0 -1
- package/dist/react/useDeltaStreams.js.map +0 -1
- package/dist/react/useStreamingUIMessages.d.ts.map +0 -1
- package/dist/react/useStreamingUIMessages.js.map +0 -1
- package/dist/react/useThreadMessages.d.ts.map +0 -1
- package/dist/react/useThreadMessages.js.map +0 -1
- package/dist/react/useUIMessages.d.ts.map +0 -1
- package/dist/react/useUIMessages.js.map +0 -1
- package/src/client/streamText.test.ts +0 -102
- /package/dist/{client → vercel/client}/files.js +0 -0
- /package/dist/{client → vercel/client}/saveInputMessages.js +0 -0
- /package/dist/{react → vercel/react}/optimisticallySendMessage.js +0 -0
- /package/dist/{react → vercel/react}/types.js +0 -0
- /package/src/{UIMessages.test.ts → vercel/UIMessages.test.ts} +0 -0
- /package/src/{react → vercel/react}/useUIMessages.test.ts +0 -0
|
@@ -0,0 +1,456 @@
|
|
|
1
|
+
import type { Context, FlexibleSchema, InferSchema, ModelMessage, ProviderOptions } from "@ai-sdk/provider-utils";
|
|
2
|
+
import type { JSONValue } from "@ai-sdk/provider";
|
|
3
|
+
import type { EmbeddingModel, GenerateObjectResult, generateText, GenerateTextResult, Instructions, LanguageModelCallOptions, LanguageModelRequestMetadata, LanguageModelResponseMetadata, LanguageModelUsage, LanguageModel, Output as AISDKOutput, streamObject, streamText, StreamTextResult, ToolSet, RequestOptions, generateObject } from "ai";
|
|
4
|
+
import type { GenericActionCtx, GenericDataModel, WithoutSystemFields } from "convex/server";
|
|
5
|
+
import type { MessageDoc, ProviderMetadata, StreamDelta, StreamMessage, ThreadDoc } from "../../validators.js";
|
|
6
|
+
import type { StreamingOptions } from "./streaming.js";
|
|
7
|
+
import type { ActionCtx } from "../../client/types.js";
|
|
8
|
+
export type { ActionCtx, AgentComponent, MutationCtx, QueryCtx, } from "../../client/types.js";
|
|
9
|
+
/**
|
|
10
|
+
* Type-level check that ensures models are from AI SDK v7.
|
|
11
|
+
* If a v5 model (LanguageModelV2) is passed, TypeScript will show the error message string.
|
|
12
|
+
*/
|
|
13
|
+
type AssertAISDKv7<T> = T extends string ? T : T extends {
|
|
14
|
+
specificationVersion: "v4";
|
|
15
|
+
} ? T : "⚠️ @convex-dev/agent requires AI SDK v7. Update your dependencies: npm install ai@^7.0.0 @ai-sdk/openai@^4.0.0 (or other provider).";
|
|
16
|
+
export type AgentPrompt = {
|
|
17
|
+
/**
|
|
18
|
+
* System message to include in the prompt. Overwrites Agent instructions.
|
|
19
|
+
*/
|
|
20
|
+
system?: Instructions;
|
|
21
|
+
instructions?: Instructions;
|
|
22
|
+
/**
|
|
23
|
+
* A prompt. It can be either a text prompt or a list of messages.
|
|
24
|
+
* If used with `promptMessageId`, it will be used in place of that
|
|
25
|
+
* prompt message and no input messages will be saved.
|
|
26
|
+
* Otherwise, if used with the storageOptions "promptAndOutput" (default),
|
|
27
|
+
* it will be the only message saved.
|
|
28
|
+
* If a string is provided, it will be a user message.
|
|
29
|
+
*/
|
|
30
|
+
prompt?: string | Array<ModelMessage> | undefined;
|
|
31
|
+
/**
|
|
32
|
+
* A list of messages to use as context before the prompt.
|
|
33
|
+
* If used with `prompt`, these will precede the prompt.
|
|
34
|
+
* If used with the storageOptions "promptAndOutput" (default),
|
|
35
|
+
* none of these messages will be saved.
|
|
36
|
+
*/
|
|
37
|
+
messages?: Array<ModelMessage> | undefined;
|
|
38
|
+
/**
|
|
39
|
+
* If provided, it uses this existing message to anchor the prompt:
|
|
40
|
+
* - The specified message will be included, unless `prompt` is also
|
|
41
|
+
* provided, in which case that will be inserted in place of this
|
|
42
|
+
* specified message.
|
|
43
|
+
* - Recent and search messages will not include messages after this
|
|
44
|
+
* message's order.
|
|
45
|
+
* - If there are already responses on the same order,
|
|
46
|
+
* for example, tool calls and responses,
|
|
47
|
+
* those will be included automatically.
|
|
48
|
+
*
|
|
49
|
+
* Note: if this is provided, no input messages will be saved by default.
|
|
50
|
+
*/
|
|
51
|
+
promptMessageId?: string | undefined;
|
|
52
|
+
/**
|
|
53
|
+
* The model to use for the LLM calls. This will override the languageModel
|
|
54
|
+
* specified in the Agent config.
|
|
55
|
+
*/
|
|
56
|
+
model?: AssertAISDKv7<LanguageModel>;
|
|
57
|
+
};
|
|
58
|
+
export type Config = {
|
|
59
|
+
/**
|
|
60
|
+
* The LLM model to use for generating / streaming text and objects.
|
|
61
|
+
* Requires AI SDK v7 (@ai-sdk/* packages v4.x).
|
|
62
|
+
*
|
|
63
|
+
* @example
|
|
64
|
+
* import { openai } from "@ai-sdk/openai"
|
|
65
|
+
* const myAgent = new Agent(components.agent, {
|
|
66
|
+
* languageModel: openai.chat("gpt-4o-mini"),
|
|
67
|
+
* })
|
|
68
|
+
*/
|
|
69
|
+
languageModel?: AssertAISDKv7<LanguageModel>;
|
|
70
|
+
/**
|
|
71
|
+
* @deprecated Use `embeddingModel` instead.
|
|
72
|
+
*/
|
|
73
|
+
textEmbeddingModel?: EmbeddingModel;
|
|
74
|
+
/**
|
|
75
|
+
* The model to use for text embeddings. Optional.
|
|
76
|
+
* If specified, it will use this for generating vector embeddings
|
|
77
|
+
* of chats, and can opt-in to doing vector search for automatic context
|
|
78
|
+
* on generateText, etc.
|
|
79
|
+
* e.g.
|
|
80
|
+
* import { openai } from "@ai-sdk/openai"
|
|
81
|
+
* const myAgent = new Agent(components.agent, {
|
|
82
|
+
* ...
|
|
83
|
+
* embeddingModel: openai.embedding("text-embedding-3-small")
|
|
84
|
+
*/
|
|
85
|
+
embeddingModel?: EmbeddingModel;
|
|
86
|
+
/**
|
|
87
|
+
* Options to determine what messages are included as context in message
|
|
88
|
+
* generation. To disable any messages automatically being added, pass:
|
|
89
|
+
* { recentMessages: 0 }
|
|
90
|
+
*/
|
|
91
|
+
contextOptions?: ContextOptions;
|
|
92
|
+
/**
|
|
93
|
+
* Determines whether messages are automatically stored when passed as
|
|
94
|
+
* arguments or generated.
|
|
95
|
+
*/
|
|
96
|
+
storageOptions?: StorageOptions;
|
|
97
|
+
/**
|
|
98
|
+
* The usage handler to use for this agent.
|
|
99
|
+
*/
|
|
100
|
+
usageHandler?: UsageHandler;
|
|
101
|
+
/**
|
|
102
|
+
* By default, messages are ordered with context in `fetchContextWithPrompt`,
|
|
103
|
+
* but you can override this by providing a context handler. Here you can
|
|
104
|
+
* filter, modify, or enrich the context messages. If provided, the default
|
|
105
|
+
* ordering will not apply. This excludes the system message / instructions.
|
|
106
|
+
*/
|
|
107
|
+
contextHandler?: ContextHandler;
|
|
108
|
+
/**
|
|
109
|
+
* Called for each LLM request/response, so you can do things like
|
|
110
|
+
* log the raw request body or response headers to a table, or logs.
|
|
111
|
+
*/
|
|
112
|
+
rawRequestResponseHandler?: RawRequestResponseHandler;
|
|
113
|
+
/**
|
|
114
|
+
* @deprecated Reach out if you use this. Otherwise will be removed soon.
|
|
115
|
+
* Default provider options to pass for the LLM calls.
|
|
116
|
+
* This can be overridden at each generate/stream callsite on a per-field
|
|
117
|
+
* basis. To clear a default setting, you'll need to pass `undefined`.
|
|
118
|
+
*/
|
|
119
|
+
providerOptions?: ProviderOptions;
|
|
120
|
+
/**
|
|
121
|
+
* The default settings to use for the LLM calls.
|
|
122
|
+
* This can be overridden at each generate/stream callsite on a per-field
|
|
123
|
+
* basis. To clear a default setting, you'll need to pass `undefined`.
|
|
124
|
+
*/
|
|
125
|
+
callSettings?: AgentCallSettings;
|
|
126
|
+
/**
|
|
127
|
+
* The maximum number of steps to allow for a single generation.
|
|
128
|
+
*
|
|
129
|
+
* For example, if an agent wants to call a tool, that call and tool response
|
|
130
|
+
* will be one step. Generating a response based on the tool call & response
|
|
131
|
+
* will be a second step.
|
|
132
|
+
* If it runs out of steps, it will return the last step result, which may
|
|
133
|
+
* not be an assistant message.
|
|
134
|
+
|
|
135
|
+
* This becomes the default value when `stopWhen` is not specified in the
|
|
136
|
+
* Agent or generation callsite.
|
|
137
|
+
* AI SDK v5 removed the `maxSteps` argument, but this is kept here for
|
|
138
|
+
* convenience and backwards compatibility.
|
|
139
|
+
* Defaults to 1.
|
|
140
|
+
*/
|
|
141
|
+
maxSteps?: number;
|
|
142
|
+
};
|
|
143
|
+
export type AgentCallSettings = LanguageModelCallOptions & Omit<RequestOptions, "timeout">;
|
|
144
|
+
/**
|
|
145
|
+
* Options to configure what messages are fetched as context,
|
|
146
|
+
* automatically with thread.generateText, or directly via search.
|
|
147
|
+
*/
|
|
148
|
+
export type ContextOptions = {
|
|
149
|
+
/**
|
|
150
|
+
* Whether to include tool messages in the context.
|
|
151
|
+
* By default, tool calls and results are not included.
|
|
152
|
+
*/
|
|
153
|
+
excludeToolMessages?: boolean;
|
|
154
|
+
/**
|
|
155
|
+
* How many recent messages to include. These are added after the search
|
|
156
|
+
* messages, and do not count against the search limit.
|
|
157
|
+
* Default: 100
|
|
158
|
+
*/
|
|
159
|
+
recentMessages?: number;
|
|
160
|
+
/**
|
|
161
|
+
* Options for searching messages.
|
|
162
|
+
*/
|
|
163
|
+
searchOptions?: {
|
|
164
|
+
/**
|
|
165
|
+
* The maximum number of messages to fetch. Default is 10.
|
|
166
|
+
*/
|
|
167
|
+
limit: number;
|
|
168
|
+
/**
|
|
169
|
+
* Whether to use text search to find messages. Default is false.
|
|
170
|
+
*/
|
|
171
|
+
textSearch?: boolean;
|
|
172
|
+
/**
|
|
173
|
+
* Whether to use vector search to find messages. Default is false.
|
|
174
|
+
* At least one of textSearch or vectorSearch must be true.
|
|
175
|
+
*/
|
|
176
|
+
vectorSearch?: boolean;
|
|
177
|
+
/**
|
|
178
|
+
* The score threshold for vector search. Default is 0.0.
|
|
179
|
+
*/
|
|
180
|
+
vectorScoreThreshold?: number;
|
|
181
|
+
/**
|
|
182
|
+
* What messages around the search results to include.
|
|
183
|
+
* Default: { before: 2, after: 1 }
|
|
184
|
+
* (two before, and one after each message found in the search)
|
|
185
|
+
* Note, this is after the limit is applied.
|
|
186
|
+
* By default this will quadruple the number of messages fetched.
|
|
187
|
+
*/
|
|
188
|
+
messageRange?: {
|
|
189
|
+
before: number;
|
|
190
|
+
after: number;
|
|
191
|
+
};
|
|
192
|
+
};
|
|
193
|
+
/**
|
|
194
|
+
* Whether to search across other threads for relevant messages.
|
|
195
|
+
* By default, only the current thread is searched.
|
|
196
|
+
*/
|
|
197
|
+
searchOtherThreads?: boolean;
|
|
198
|
+
};
|
|
199
|
+
/**
|
|
200
|
+
* Options to configure the automatic saving of messages
|
|
201
|
+
* when generating text / objects in a thread.
|
|
202
|
+
*/
|
|
203
|
+
export type StorageOptions = {
|
|
204
|
+
/**
|
|
205
|
+
* Whether to save messages to the thread history.
|
|
206
|
+
* Pass "all" to save all input and output messages.
|
|
207
|
+
* Pass "none" to not save any input or output messages.
|
|
208
|
+
* Pass "promptAndOutput" to save the prompt and all output messages.
|
|
209
|
+
* If you pass {messages} but no {prompt}, it will assume messages.at(-1) is
|
|
210
|
+
* the prompt.
|
|
211
|
+
* Defaults to "promptAndOutput".
|
|
212
|
+
*/
|
|
213
|
+
saveMessages?: "all" | "none" | "promptAndOutput";
|
|
214
|
+
};
|
|
215
|
+
export type GenerationOutputMetadata = {
|
|
216
|
+
/**
|
|
217
|
+
* The ID of the prompt message for the generation.
|
|
218
|
+
*/
|
|
219
|
+
promptMessageId?: string;
|
|
220
|
+
/**
|
|
221
|
+
* The order of the prompt message and responses for the generation.
|
|
222
|
+
* Each order starts with a user message, then followed by agent responses.
|
|
223
|
+
* If a promptMessageId is provided, that dictates the order.
|
|
224
|
+
*/
|
|
225
|
+
order?: number;
|
|
226
|
+
/**
|
|
227
|
+
* The messages saved for the generation - both saved input and output.
|
|
228
|
+
* If you passed promptMessageId, it will not include that message.
|
|
229
|
+
*/
|
|
230
|
+
savedMessages?: MessageDoc[];
|
|
231
|
+
/**
|
|
232
|
+
* @deprecated Use promptMessageId instead.
|
|
233
|
+
* The ID of the prompt message for the generation.
|
|
234
|
+
*/
|
|
235
|
+
messageId?: string;
|
|
236
|
+
};
|
|
237
|
+
export type UsageHandler = (ctx: ActionCtx, args: {
|
|
238
|
+
userId: string | undefined;
|
|
239
|
+
threadId: string | undefined;
|
|
240
|
+
agentName: string | undefined;
|
|
241
|
+
usage: LanguageModelUsage;
|
|
242
|
+
providerMetadata: ProviderMetadata | undefined;
|
|
243
|
+
model: string;
|
|
244
|
+
provider: string;
|
|
245
|
+
}) => void | Promise<void>;
|
|
246
|
+
/**
|
|
247
|
+
* By default, messages are ordered with context in `fetchContextWithPrompt`,
|
|
248
|
+
* but you can override this by providing a context handler. Here you can filter
|
|
249
|
+
* out, add in, or reorder messages.
|
|
250
|
+
*/
|
|
251
|
+
export type ContextHandler = (ctx: ActionCtx, args: {
|
|
252
|
+
/**
|
|
253
|
+
* All messages in the default order.
|
|
254
|
+
*/
|
|
255
|
+
allMessages: ModelMessage[];
|
|
256
|
+
/**
|
|
257
|
+
* The messages fetched from search.
|
|
258
|
+
*/
|
|
259
|
+
search: ModelMessage[];
|
|
260
|
+
/**
|
|
261
|
+
* The recent messages already in the thread history,
|
|
262
|
+
* excluding any messages that came after promptMessageId.
|
|
263
|
+
*/
|
|
264
|
+
recent: ModelMessage[];
|
|
265
|
+
/**
|
|
266
|
+
* The messages passed as the `messages` argument to e.g. generateText.
|
|
267
|
+
*/
|
|
268
|
+
inputMessages: ModelMessage[];
|
|
269
|
+
/**
|
|
270
|
+
* The message(s) passed as the `prompt` argument to e.g. generateText.
|
|
271
|
+
* Otherwise, if `promptMessageId` was provided, the message at that id.
|
|
272
|
+
* `prompt` will override the message at `promptMessageId`.
|
|
273
|
+
*/
|
|
274
|
+
inputPrompt: ModelMessage[];
|
|
275
|
+
/**
|
|
276
|
+
* Any messages on the same `order` as the promptMessageId message after the
|
|
277
|
+
* prompt message. These are presumably existing responses to the prompt
|
|
278
|
+
* message.
|
|
279
|
+
*/
|
|
280
|
+
existingResponses: ModelMessage[];
|
|
281
|
+
/**
|
|
282
|
+
* The user associated with the generation, if any.
|
|
283
|
+
*/
|
|
284
|
+
userId: string | undefined;
|
|
285
|
+
/**
|
|
286
|
+
* The thread associated with the generation, if any.
|
|
287
|
+
*/
|
|
288
|
+
threadId: string | undefined;
|
|
289
|
+
}) => ModelMessage[] | Promise<ModelMessage[]>;
|
|
290
|
+
export type RawRequestResponseHandler = (ctx: ActionCtx, args: {
|
|
291
|
+
userId: string | undefined;
|
|
292
|
+
threadId: string | undefined;
|
|
293
|
+
agentName: string | undefined;
|
|
294
|
+
request: LanguageModelRequestMetadata;
|
|
295
|
+
response: LanguageModelResponseMetadata | Omit<LanguageModelResponseMetadata, "messages">;
|
|
296
|
+
}) => void | Promise<void>;
|
|
297
|
+
export type TextArgs<AgentTools extends ToolSet, TOOLS extends ToolSet | undefined = undefined, OUTPUT extends AISDKOutput.Output<any, any, any> = AISDKOutput.Output<string, string>, RUNTIME_CONTEXT extends Context = Context> = Omit<Parameters<typeof generateText<TOOLS extends undefined ? AgentTools : TOOLS, RUNTIME_CONTEXT, OUTPUT>>[0], "model" | "prompt" | "messages" | "system" | "onStepFinish"> & {
|
|
298
|
+
/**
|
|
299
|
+
* The tools to use for the tool calls. This will override tools specified
|
|
300
|
+
* in the Agent constructor or createThread / continueThread.
|
|
301
|
+
*/
|
|
302
|
+
tools?: TOOLS;
|
|
303
|
+
/** @deprecated Use onStepEnd. */
|
|
304
|
+
onStepFinish?: Parameters<typeof generateText<TOOLS extends undefined ? AgentTools : TOOLS, RUNTIME_CONTEXT, OUTPUT>>[0]["onStepEnd"];
|
|
305
|
+
} & AgentPrompt;
|
|
306
|
+
export type StreamingTextArgs<AgentTools extends ToolSet, TOOLS extends ToolSet | undefined = undefined, OUTPUT extends AISDKOutput.Output<any, any, any> = AISDKOutput.Output<string, string, never>, RUNTIME_CONTEXT extends Context = Context> = Omit<Parameters<typeof streamText<TOOLS extends undefined ? AgentTools : TOOLS, RUNTIME_CONTEXT, OUTPUT>>[0], "model" | "prompt" | "messages" | "system" | "onStepFinish"> & {
|
|
307
|
+
/**
|
|
308
|
+
* The tools to use for the tool calls. This will override tools specified
|
|
309
|
+
* in the Agent constructor or createThread / continueThread.
|
|
310
|
+
*/
|
|
311
|
+
tools?: TOOLS;
|
|
312
|
+
/** @deprecated Use onStepEnd. */
|
|
313
|
+
onStepFinish?: Parameters<typeof streamText<TOOLS extends undefined ? AgentTools : TOOLS, RUNTIME_CONTEXT, OUTPUT>>[0]["onStepEnd"];
|
|
314
|
+
} & AgentPrompt;
|
|
315
|
+
export type ObjectMode = "object" | "array" | "enum" | "no-schema";
|
|
316
|
+
export type GenerateObjectArgs<SCHEMA extends FlexibleSchema<unknown> = FlexibleSchema<JSONValue>, OUTPUT extends ObjectMode = InferSchema<SCHEMA> extends string ? "enum" : "object", RESULT = OUTPUT extends "array" ? Array<InferSchema<SCHEMA>> : InferSchema<SCHEMA>> = AgentPrompt & Omit<Parameters<typeof generateObject<SCHEMA, OUTPUT, RESULT>>[0], "model" | "prompt" | "messages" | "system"> & {
|
|
317
|
+
schema?: SCHEMA;
|
|
318
|
+
enum?: Array<RESULT>;
|
|
319
|
+
};
|
|
320
|
+
export type StreamObjectArgs<SCHEMA extends FlexibleSchema<unknown> = FlexibleSchema<JSONValue>, OUTPUT extends ObjectMode = InferSchema<SCHEMA> extends string ? "enum" : "object", RESULT = OUTPUT extends "array" ? Array<InferSchema<SCHEMA>> : InferSchema<SCHEMA>> = AgentPrompt & Omit<Parameters<typeof streamObject<SCHEMA, OUTPUT, RESULT>>[0], "model" | "prompt" | "messages" | "system"> & {
|
|
321
|
+
schema?: SCHEMA;
|
|
322
|
+
enum?: Array<RESULT>;
|
|
323
|
+
};
|
|
324
|
+
export type MaybeCustomCtx<CustomCtx, DataModel extends GenericDataModel, AgentTools extends ToolSet> = CustomCtx extends Record<string, unknown> ? {
|
|
325
|
+
/**
|
|
326
|
+
* If you have a custom ctx that you use with the Agent
|
|
327
|
+
* (e.g. new Agent<{ orgId: string }>(...))
|
|
328
|
+
* you need to provide this function to add any extra fields.
|
|
329
|
+
* e.g.
|
|
330
|
+
* ```ts
|
|
331
|
+
* const myAgent = new Agent<{ orgId: string }>(...);
|
|
332
|
+
* const myAction = myAgent.asTextAction({
|
|
333
|
+
* customCtx: (ctx: ActionCtx, target, llmArgs) => {
|
|
334
|
+
* const orgId = await lookupOrgId(ctx, target.threadId);
|
|
335
|
+
* return { orgId };
|
|
336
|
+
* },
|
|
337
|
+
* });
|
|
338
|
+
* ```
|
|
339
|
+
* Then, in your tools, you can
|
|
340
|
+
*/
|
|
341
|
+
customCtx: (ctx: GenericActionCtx<DataModel>, target: {
|
|
342
|
+
userId?: string | undefined;
|
|
343
|
+
threadId?: string | undefined;
|
|
344
|
+
}, llmArgs: TextArgs<AgentTools, AgentTools>) => CustomCtx;
|
|
345
|
+
} : {
|
|
346
|
+
customCtx?: never;
|
|
347
|
+
};
|
|
348
|
+
type ThreadOutputMetadata = Required<GenerationOutputMetadata>;
|
|
349
|
+
/**
|
|
350
|
+
* The interface for a thread returned from {@link createThread} or {@link continueThread}.
|
|
351
|
+
* This is contextual to a thread and/or user.
|
|
352
|
+
*/
|
|
353
|
+
export interface Thread<DefaultTools extends ToolSet> {
|
|
354
|
+
/**
|
|
355
|
+
* The target threadId, from the startThread or continueThread initializers.
|
|
356
|
+
*/
|
|
357
|
+
threadId: string;
|
|
358
|
+
/**
|
|
359
|
+
* Get the metadata for the thread.
|
|
360
|
+
*/
|
|
361
|
+
getMetadata: () => Promise<ThreadDoc>;
|
|
362
|
+
/**
|
|
363
|
+
* Update the metadata for the thread.
|
|
364
|
+
*/
|
|
365
|
+
updateMetadata: (patch: Partial<WithoutSystemFields<ThreadDoc>>) => Promise<ThreadDoc>;
|
|
366
|
+
/**
|
|
367
|
+
* This behaves like {@link generateText} from the "ai" package except that
|
|
368
|
+
* it add context based on the userId and threadId and saves the input and
|
|
369
|
+
* resulting messages to the thread, if specified.
|
|
370
|
+
* Use {@link continueThread} to get a version of this function already scoped
|
|
371
|
+
* to a thread (and optionally userId).
|
|
372
|
+
* @param args The arguments to the generateText function, along with extra controls
|
|
373
|
+
* for the {@link ContextOptions} and {@link StorageOptions}.
|
|
374
|
+
* @returns The result of the generateText function.
|
|
375
|
+
*/
|
|
376
|
+
generateText<TOOLS extends ToolSet | undefined = undefined, OUTPUT extends AISDKOutput.Output<any, any, any> = AISDKOutput.Output<string, string>, RUNTIME_CONTEXT extends Context = Context>(generateTextArgs: TextArgs<TOOLS extends undefined ? DefaultTools : TOOLS, TOOLS, OUTPUT, RUNTIME_CONTEXT>, options?: Options): Promise<GenerateTextResult<TOOLS extends undefined ? DefaultTools : TOOLS, RUNTIME_CONTEXT, OUTPUT> & ThreadOutputMetadata>;
|
|
377
|
+
/**
|
|
378
|
+
* This behaves like {@link streamText} from the "ai" package except that
|
|
379
|
+
* it add context based on the userId and threadId and saves the input and
|
|
380
|
+
* resulting messages to the thread, if specified.
|
|
381
|
+
* Use {@link continueThread} to get a version of this function already scoped
|
|
382
|
+
* to a thread (and optionally userId).
|
|
383
|
+
* @param args The arguments to the streamText function, along with extra controls
|
|
384
|
+
* for the {@link ContextOptions} and {@link StorageOptions}.
|
|
385
|
+
* @returns The result of the streamText function.
|
|
386
|
+
*/
|
|
387
|
+
streamText<TOOLS extends ToolSet | undefined = undefined, OUTPUT extends AISDKOutput.Output<any, any, any> = AISDKOutput.Output<string, string, never>, RUNTIME_CONTEXT extends Context = Context>(streamTextArgs: StreamingTextArgs<TOOLS extends undefined ? DefaultTools : TOOLS, TOOLS, OUTPUT, RUNTIME_CONTEXT>, options?: Options & {
|
|
388
|
+
/**
|
|
389
|
+
* Whether to save incremental data (deltas) from streaming responses.
|
|
390
|
+
* Defaults to false.
|
|
391
|
+
* If false, it will not save any deltas to the database.
|
|
392
|
+
* If true, it will save deltas with {@link DEFAULT_STREAMING_OPTIONS}.
|
|
393
|
+
*
|
|
394
|
+
* Regardless of this option, when streaming you are able to use this
|
|
395
|
+
* `streamText` function as you would with the "ai" package's version:
|
|
396
|
+
* iterating over the text, streaming it over HTTP, etc.
|
|
397
|
+
*/
|
|
398
|
+
saveStreamDeltas?: boolean | StreamingOptions;
|
|
399
|
+
}): Promise<StreamTextResult<TOOLS extends undefined ? DefaultTools : TOOLS, RUNTIME_CONTEXT, OUTPUT> & ThreadOutputMetadata>;
|
|
400
|
+
/**
|
|
401
|
+
* This behaves like {@link generateObject} from the "ai" package except that
|
|
402
|
+
* it add context based on the userId and threadId and saves the input and
|
|
403
|
+
* resulting messages to the thread, if specified. This overload is for objects, arrays, and enums.
|
|
404
|
+
* Use {@link continueThread} to get a version of this function already scoped
|
|
405
|
+
* to a thread (and optionally userId).
|
|
406
|
+
* @param args The arguments to the generateObject function, along with extra controls
|
|
407
|
+
* for the {@link ContextOptions} and {@link StorageOptions}.
|
|
408
|
+
* @returns The result of the generateObject function.
|
|
409
|
+
*/
|
|
410
|
+
generateObject<SCHEMA extends FlexibleSchema<unknown> = FlexibleSchema<JSONValue>, OUTPUT extends ObjectMode = InferSchema<SCHEMA> extends string ? "enum" : "object", RESULT = OUTPUT extends "array" ? Array<InferSchema<SCHEMA>> : InferSchema<SCHEMA>>(generateObjectArgs: GenerateObjectArgs<SCHEMA, OUTPUT, RESULT>, options?: Options): Promise<GenerateObjectResult<RESULT> & ThreadOutputMetadata>;
|
|
411
|
+
/**
|
|
412
|
+
* This behaves like {@link streamObject} from the "ai" package except that
|
|
413
|
+
* it add context based on the userId and threadId and saves the input and
|
|
414
|
+
* resulting messages to the thread, if specified.
|
|
415
|
+
* Use {@link continueThread} to get a version of this function already scoped
|
|
416
|
+
* to a thread (and optionally userId).
|
|
417
|
+
* @param args The arguments to the streamObject function, along with extra controls
|
|
418
|
+
* for the {@link ContextOptions} and {@link StorageOptions}.
|
|
419
|
+
* @returns The result of the streamObject function.
|
|
420
|
+
*/
|
|
421
|
+
streamObject<SCHEMA extends FlexibleSchema<unknown> = FlexibleSchema<JSONValue>, OUTPUT extends ObjectMode = InferSchema<SCHEMA> extends string ? "enum" : "object", RESULT = OUTPUT extends "array" ? Array<InferSchema<SCHEMA>> : InferSchema<SCHEMA>>(
|
|
422
|
+
/**
|
|
423
|
+
* The same arguments you'd pass to "ai" sdk {@link streamObject}.
|
|
424
|
+
*/
|
|
425
|
+
streamObjectArgs: StreamObjectArgs<SCHEMA, OUTPUT, RESULT>, options?: Options): Promise<ReturnType<typeof streamObject<SCHEMA, OUTPUT, RESULT>> & ThreadOutputMetadata>;
|
|
426
|
+
}
|
|
427
|
+
export type Options = {
|
|
428
|
+
/**
|
|
429
|
+
* The context options to use for passing in message history to the LLM.
|
|
430
|
+
*/
|
|
431
|
+
contextOptions?: ContextOptions;
|
|
432
|
+
/**
|
|
433
|
+
* The storage options to use for saving the input and output messages to the thread.
|
|
434
|
+
*/
|
|
435
|
+
storageOptions?: StorageOptions;
|
|
436
|
+
/**
|
|
437
|
+
* The usage handler to use for this thread. Overrides any handler
|
|
438
|
+
* set in the agent constructor.
|
|
439
|
+
*/
|
|
440
|
+
usageHandler?: UsageHandler;
|
|
441
|
+
/**
|
|
442
|
+
* By default, messages are ordered with context in `fetchContextWithPrompt`,
|
|
443
|
+
* but you can override this by providing a context handler. Here you can
|
|
444
|
+
* filter, modify, or enrich the context messages. If provided, the default
|
|
445
|
+
* ordering will not apply. This excludes the system message / instructions.
|
|
446
|
+
*/
|
|
447
|
+
contextHandler?: ContextHandler;
|
|
448
|
+
};
|
|
449
|
+
export type SyncStreamsReturnValue = {
|
|
450
|
+
kind: "list";
|
|
451
|
+
messages: StreamMessage[];
|
|
452
|
+
} | {
|
|
453
|
+
kind: "deltas";
|
|
454
|
+
deltas: StreamDelta[];
|
|
455
|
+
} | undefined;
|
|
456
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/vercel/client/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,OAAO,EACP,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,YAAY,EACZ,wBAAwB,EACxB,4BAA4B,EAC5B,6BAA6B,EAC7B,kBAAkB,EAClB,aAAa,EACb,MAAM,IAAI,WAAW,EACrB,YAAY,EACZ,UAAU,EACV,gBAAgB,EAChB,OAAO,EACP,cAAc,EACd,cAAc,EACf,MAAM,IAAI,CAAC;AAEZ,OAAO,KAAK,EACV,gBAAgB,EAChB,gBAAgB,EAChB,mBAAmB,EACpB,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,EACV,UAAU,EACV,gBAAgB,EAChB,WAAW,EACX,aAAa,EACb,SAAS,EACV,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AACvD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAEvD,YAAY,EACV,SAAS,EACT,cAAc,EACd,WAAW,EACX,QAAQ,GACT,MAAM,uBAAuB,CAAC;AAE/B;;;GAGG;AACH,KAAK,aAAa,CAAC,CAAC,IAAI,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ceRoot":"","sources":["../../../src/vercel/client/types.ts"],"names":[],"mappings":";AAsqBA,uBAAuB"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Context } from "@ai-sdk/provider-utils";
|
|
2
|
+
import type { StepResult, StopCondition, ToolSet } from "ai";
|
|
2
3
|
/**
|
|
3
4
|
* A stop condition that only matches tool calls which completed
|
|
4
5
|
* successfully (i.e. produced a `tool-result`, not a `tool-error`).
|
|
@@ -7,6 +8,6 @@ import type { StepResult, StopCondition } from "ai";
|
|
|
7
8
|
* agent to retry on argument validation failures rather than stopping.
|
|
8
9
|
*/
|
|
9
10
|
export declare function hasSuccessfulToolCall(toolName: string): StopCondition<any>;
|
|
10
|
-
export declare function willContinue(steps: StepResult<
|
|
11
|
+
export declare function willContinue<TOOLS extends ToolSet, RUNTIME_CONTEXT extends Context>(steps: StepResult<TOOLS, RUNTIME_CONTEXT>[], stopWhen: StopCondition<TOOLS, RUNTIME_CONTEXT> | Array<StopCondition<TOOLS, RUNTIME_CONTEXT>> | undefined): Promise<boolean>;
|
|
11
12
|
export declare function errorToString(error: unknown): string;
|
|
12
13
|
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/vercel/client/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,KAAK,EAAE,UAAU,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,IAAI,CAAC;AAE7D;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,MAAM,GAAG,aAAa,CAAC,GAAG,CAAC,CAK1E;AAED,wBAAsB,YAAY,CAChC,KAAK,SAAS,OAAO,EACrB,eAAe,SAAS,OAAO,EAE/B,KAAK,EAAE,UAAU,CAAC,KAAK,EAAE,eAAe,CAAC,EAAE,EAC3C,QAAQ,EACJ,aAAa,CAAC,KAAK,EAAE,eAAe,CAAC,GACrC,KAAK,CAAC,aAAa,CAAC,KAAK,EAAE,eAAe,CAAC,CAAC,GAC5C,SAAS,GACZ,OAAO,CAAC,OAAO,CAAC,CAoBlB;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAKpD"}
|
|
@@ -15,8 +15,8 @@ export async function willContinue(steps, stopWhen) {
|
|
|
15
15
|
if (step.finishReason !== "tool-calls")
|
|
16
16
|
return false;
|
|
17
17
|
// Count both successful results and errors as completed outputs.
|
|
18
|
-
//
|
|
19
|
-
//
|
|
18
|
+
// Failed tool calls are represented as tool-error content parts, so only
|
|
19
|
+
// checking toolResults misses them.
|
|
20
20
|
const completedOutputs = step.content?.filter((p) => p.type === "tool-result" || p.type === "tool-error").length ?? step.toolResults.length;
|
|
21
21
|
// we don't have a tool result, so we'll wait for more
|
|
22
22
|
if (step.toolCalls.length > completedOutputs)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/vercel/client/utils.ts"],"names":[],"mappings":"AAGA;;;;;;GAMG;AACH,MAAM,UAAU,qBAAqB,CAAC,QAAgB;IACpD,OAAO,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CACnB,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,EAAE,WAAW,EAAE,IAAI,CACxC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,QAAQ,KAAK,QAAQ,CACzC,IAAI,KAAK,CAAC;AACf,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,YAAY,CAIhC,KAA2C,EAC3C,QAGa;IAEb,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,iEAAiE;IACjE,yEAAyE;IACzE,oCAAoC;IACpC,MAAM,gBAAgB,GACpB,IAAI,CAAC,OAAO,EAAE,MAAM,CAClB,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,aAAa,IAAI,CAAC,CAAC,IAAI,KAAK,YAAY,CAC3D,CAAC,MAAM,IAAI,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC;IACtC,sDAAsD;IACtD,IAAI,IAAI,CAAC,SAAS,CAAC,MAAM,GAAG,gBAAgB;QAAE,OAAO,KAAK,CAAC;IAC3D,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,11 +1,10 @@
|
|
|
1
1
|
import { type UIMessageChunk } from "ai";
|
|
2
2
|
import { type UIMessage } from "./UIMessages.js";
|
|
3
|
-
import { type MessageStatus, type StreamDelta, type StreamMessage } from "
|
|
3
|
+
import { type MessageStatus, type StreamDelta, type StreamMessage } from "../validators.js";
|
|
4
4
|
export declare function blankUIMessage<METADATA = unknown>(streamMessage: StreamMessage & {
|
|
5
5
|
metadata?: METADATA;
|
|
6
6
|
}, threadId: string): UIMessage<METADATA>;
|
|
7
7
|
export declare function statusFromStreamStatus(status: StreamMessage["status"]): MessageStatus | "streaming";
|
|
8
|
-
export declare function updateFromUIMessageChunks(uiMessage: UIMessage, parts: UIMessageChunk[]): Promise<UIMessage>;
|
|
9
8
|
export type IncrementalStreamState = {
|
|
10
9
|
activeText: Record<string, number>;
|
|
11
10
|
activeReasoning: Record<string, number>;
|
|
@@ -20,8 +19,8 @@ export declare function emptyIncrementalStreamState(): IncrementalStreamState;
|
|
|
20
19
|
* indices stay stable across the structuredClone between batches. Behavior
|
|
21
20
|
* mirrors the AI SDK's processUIMessageStream.
|
|
22
21
|
*/
|
|
23
|
-
export declare function applyUIMessageChunksIncremental(uiMessage: UIMessage, newParts: UIMessageChunk[], prev: IncrementalStreamState): {
|
|
24
|
-
message: UIMessage
|
|
22
|
+
export declare function applyUIMessageChunksIncremental<METADATA = unknown, DATA_PARTS extends import("ai").UIDataTypes = import("ai").UIDataTypes, TOOLS extends import("ai").UITools = import("ai").UITools>(uiMessage: UIMessage<METADATA, DATA_PARTS, TOOLS>, newParts: UIMessageChunk[], prev: IncrementalStreamState): {
|
|
23
|
+
message: UIMessage<METADATA, DATA_PARTS, TOOLS>;
|
|
25
24
|
streamState: IncrementalStreamState;
|
|
26
25
|
};
|
|
27
26
|
export declare function deriveUIMessagesFromDeltas(threadId: string, streamMessages: StreamMessage[], allDeltas: StreamDelta[]): Promise<UIMessage[]>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deltas.d.ts","sourceRoot":"","sources":["../../src/vercel/deltas.ts"],"names":[],"mappings":"AAAA,OAAO,EAQL,KAAK,cAAc,EACpB,MAAM,IAAI,CAAC;AACZ,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAEjD,OAAO,EACL,KAAK,aAAa,EAClB,KAAK,WAAW,EAChB,KAAK,aAAa,EACnB,MAAM,kBAAkB,CAAC;AAE1B,wBAAg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