@copilotkitnext/agent 0.0.0-max-changeset-20260109200053 → 0.0.0-max-umd-20260122170341
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/CHANGELOG.md +57 -2
- package/dist/index.d.mts +30 -4
- package/dist/index.d.ts +30 -4
- package/dist/index.js +31 -11
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +31 -11
- package/dist/index.mjs.map +1 -1
- package/dist/index.umd.js +2 -0
- package/dist/index.umd.js.map +1 -0
- package/eslint.config.mjs +3 -0
- package/package.json +11 -10
- package/rollup.config.mjs +45 -0
- package/src/__tests__/basic-agent.test.ts +199 -0
- package/src/index.ts +75 -15
package/CHANGELOG.md
CHANGED
|
@@ -1,7 +1,62 @@
|
|
|
1
1
|
# @copilotkitnext/agent
|
|
2
2
|
|
|
3
|
-
## 0.0.0-max-
|
|
3
|
+
## 0.0.0-max-umd-20260122170341
|
|
4
4
|
|
|
5
5
|
### Patch Changes
|
|
6
6
|
|
|
7
|
-
-
|
|
7
|
+
- d268c49: fix: add apiKey parameter to BuiltInAgentConfiguration
|
|
8
|
+
- 7f437ba: Add UMD export
|
|
9
|
+
- 29d70a5: Add new "forwardDeveloperMessages" and "forwardSystemMessages" prop to BuiltInAgent
|
|
10
|
+
|
|
11
|
+
## 1.51.3-next.2
|
|
12
|
+
|
|
13
|
+
## 1.51.3-next.1
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- 29d70a5: Add new "forwardDeveloperMessages" and "forwardSystemMessages" prop to BuiltInAgent
|
|
18
|
+
|
|
19
|
+
## 1.51.3-next.0
|
|
20
|
+
|
|
21
|
+
### Patch Changes
|
|
22
|
+
|
|
23
|
+
- d268c49: fix: add apiKey parameter to BuiltInAgentConfiguration
|
|
24
|
+
|
|
25
|
+
## 1.51.2
|
|
26
|
+
|
|
27
|
+
### Patch Changes
|
|
28
|
+
|
|
29
|
+
- e59d23f: Use deps instead of peerdeps
|
|
30
|
+
- f36b6b1: Pin rxjs dependency
|
|
31
|
+
|
|
32
|
+
## 1.51.2-next.1
|
|
33
|
+
|
|
34
|
+
### Patch Changes
|
|
35
|
+
|
|
36
|
+
- e59d23f: Use deps instead of peerdeps
|
|
37
|
+
|
|
38
|
+
## 1.51.2-next.0
|
|
39
|
+
|
|
40
|
+
### Patch Changes
|
|
41
|
+
|
|
42
|
+
- f36b6b1: Pin rxjs dependency
|
|
43
|
+
|
|
44
|
+
## 1.51.1
|
|
45
|
+
|
|
46
|
+
### Patch Changes
|
|
47
|
+
|
|
48
|
+
- 329653b: Add support for MCP Apps Middleware
|
|
49
|
+
|
|
50
|
+
## 1.51.0
|
|
51
|
+
|
|
52
|
+
### Patch Changes
|
|
53
|
+
|
|
54
|
+
- 2839a15: Update versioning strategy
|
|
55
|
+
|
|
56
|
+
## 1.51.0-next.4
|
|
57
|
+
|
|
58
|
+
## 1.51.0-next.3
|
|
59
|
+
|
|
60
|
+
## 1.51.0-next.2
|
|
61
|
+
|
|
62
|
+
## 1.51.0-next.1
|
package/dist/index.d.mts
CHANGED
|
@@ -58,9 +58,10 @@ type MCPClientConfig = MCPClientConfigHTTP | MCPClientConfigSSE;
|
|
|
58
58
|
/**
|
|
59
59
|
* Resolves a model specifier to a LanguageModel instance
|
|
60
60
|
* @param spec - Model string (e.g., "openai/gpt-4o") or LanguageModel instance
|
|
61
|
+
* @param apiKey - Optional API key to use instead of environment variables
|
|
61
62
|
* @returns LanguageModel instance
|
|
62
63
|
*/
|
|
63
|
-
declare function resolveModel(spec: ModelSpecifier): LanguageModel;
|
|
64
|
+
declare function resolveModel(spec: ModelSpecifier, apiKey?: string): LanguageModel;
|
|
64
65
|
/**
|
|
65
66
|
* Tool definition for BuiltInAgent
|
|
66
67
|
*/
|
|
@@ -84,15 +85,22 @@ declare function defineTool<TParameters extends z.ZodTypeAny>(config: {
|
|
|
84
85
|
parameters: TParameters;
|
|
85
86
|
execute: (args: z.infer<TParameters>) => Promise<unknown>;
|
|
86
87
|
}): ToolDefinition<TParameters>;
|
|
88
|
+
/**
|
|
89
|
+
* Options for converting AG-UI messages to Vercel AI SDK format
|
|
90
|
+
*/
|
|
91
|
+
interface MessageConversionOptions {
|
|
92
|
+
forwardSystemMessages?: boolean;
|
|
93
|
+
forwardDeveloperMessages?: boolean;
|
|
94
|
+
}
|
|
87
95
|
/**
|
|
88
96
|
* Converts AG-UI messages to Vercel AI SDK ModelMessage format
|
|
89
97
|
*/
|
|
90
|
-
declare function convertMessagesToVercelAISDKMessages(messages: Message[]): ModelMessage[];
|
|
98
|
+
declare function convertMessagesToVercelAISDKMessages(messages: Message[], options?: MessageConversionOptions): ModelMessage[];
|
|
91
99
|
/**
|
|
92
100
|
* JSON Schema type definition
|
|
93
101
|
*/
|
|
94
102
|
interface JsonSchema {
|
|
95
|
-
type: "object" | "string" | "number" | "boolean" | "array";
|
|
103
|
+
type: "object" | "string" | "number" | "integer" | "boolean" | "array";
|
|
96
104
|
description?: string;
|
|
97
105
|
properties?: Record<string, JsonSchema>;
|
|
98
106
|
required?: string[];
|
|
@@ -115,6 +123,14 @@ interface BuiltInAgentConfiguration {
|
|
|
115
123
|
* The model to use
|
|
116
124
|
*/
|
|
117
125
|
model: BuiltInAgentModel | LanguageModel;
|
|
126
|
+
/**
|
|
127
|
+
* API key for the model provider (OpenAI, Anthropic, Google)
|
|
128
|
+
* If not provided, falls back to environment variables:
|
|
129
|
+
* - OPENAI_API_KEY for OpenAI models
|
|
130
|
+
* - ANTHROPIC_API_KEY for Anthropic models
|
|
131
|
+
* - GOOGLE_API_KEY for Google models
|
|
132
|
+
*/
|
|
133
|
+
apiKey?: string;
|
|
118
134
|
/**
|
|
119
135
|
* Maximum number of steps/iterations for tool calling (default: 1)
|
|
120
136
|
*/
|
|
@@ -175,6 +191,16 @@ interface BuiltInAgentConfiguration {
|
|
|
175
191
|
* Optional tools available to the agent
|
|
176
192
|
*/
|
|
177
193
|
tools?: ToolDefinition[];
|
|
194
|
+
/**
|
|
195
|
+
* Forward system-role messages from input to the LLM.
|
|
196
|
+
* Default: false
|
|
197
|
+
*/
|
|
198
|
+
forwardSystemMessages?: boolean;
|
|
199
|
+
/**
|
|
200
|
+
* Forward developer-role messages from input to the LLM (as system messages).
|
|
201
|
+
* Default: false
|
|
202
|
+
*/
|
|
203
|
+
forwardDeveloperMessages?: boolean;
|
|
178
204
|
}
|
|
179
205
|
declare class BuiltInAgent extends AbstractAgent {
|
|
180
206
|
private config;
|
|
@@ -196,4 +222,4 @@ declare class BasicAgent extends BuiltInAgent {
|
|
|
196
222
|
}
|
|
197
223
|
type BasicAgentConfiguration = BuiltInAgentConfiguration;
|
|
198
224
|
|
|
199
|
-
export { BasicAgent, type BasicAgentConfiguration, BuiltInAgent, type BuiltInAgentConfiguration, type BuiltInAgentModel, type MCPClientConfig, type MCPClientConfigHTTP, type MCPClientConfigSSE, type ModelSpecifier, type OverridableProperty, type ToolDefinition, convertJsonSchemaToZodSchema, convertMessagesToVercelAISDKMessages, convertToolDefinitionsToVercelAITools, convertToolsToVercelAITools, defineTool, resolveModel };
|
|
225
|
+
export { BasicAgent, type BasicAgentConfiguration, BuiltInAgent, type BuiltInAgentConfiguration, type BuiltInAgentModel, type MCPClientConfig, type MCPClientConfigHTTP, type MCPClientConfigSSE, type MessageConversionOptions, type ModelSpecifier, type OverridableProperty, type ToolDefinition, convertJsonSchemaToZodSchema, convertMessagesToVercelAISDKMessages, convertToolDefinitionsToVercelAITools, convertToolsToVercelAITools, defineTool, resolveModel };
|
package/dist/index.d.ts
CHANGED
|
@@ -58,9 +58,10 @@ type MCPClientConfig = MCPClientConfigHTTP | MCPClientConfigSSE;
|
|
|
58
58
|
/**
|
|
59
59
|
* Resolves a model specifier to a LanguageModel instance
|
|
60
60
|
* @param spec - Model string (e.g., "openai/gpt-4o") or LanguageModel instance
|
|
61
|
+
* @param apiKey - Optional API key to use instead of environment variables
|
|
61
62
|
* @returns LanguageModel instance
|
|
62
63
|
*/
|
|
63
|
-
declare function resolveModel(spec: ModelSpecifier): LanguageModel;
|
|
64
|
+
declare function resolveModel(spec: ModelSpecifier, apiKey?: string): LanguageModel;
|
|
64
65
|
/**
|
|
65
66
|
* Tool definition for BuiltInAgent
|
|
66
67
|
*/
|
|
@@ -84,15 +85,22 @@ declare function defineTool<TParameters extends z.ZodTypeAny>(config: {
|
|
|
84
85
|
parameters: TParameters;
|
|
85
86
|
execute: (args: z.infer<TParameters>) => Promise<unknown>;
|
|
86
87
|
}): ToolDefinition<TParameters>;
|
|
88
|
+
/**
|
|
89
|
+
* Options for converting AG-UI messages to Vercel AI SDK format
|
|
90
|
+
*/
|
|
91
|
+
interface MessageConversionOptions {
|
|
92
|
+
forwardSystemMessages?: boolean;
|
|
93
|
+
forwardDeveloperMessages?: boolean;
|
|
94
|
+
}
|
|
87
95
|
/**
|
|
88
96
|
* Converts AG-UI messages to Vercel AI SDK ModelMessage format
|
|
89
97
|
*/
|
|
90
|
-
declare function convertMessagesToVercelAISDKMessages(messages: Message[]): ModelMessage[];
|
|
98
|
+
declare function convertMessagesToVercelAISDKMessages(messages: Message[], options?: MessageConversionOptions): ModelMessage[];
|
|
91
99
|
/**
|
|
92
100
|
* JSON Schema type definition
|
|
93
101
|
*/
|
|
94
102
|
interface JsonSchema {
|
|
95
|
-
type: "object" | "string" | "number" | "boolean" | "array";
|
|
103
|
+
type: "object" | "string" | "number" | "integer" | "boolean" | "array";
|
|
96
104
|
description?: string;
|
|
97
105
|
properties?: Record<string, JsonSchema>;
|
|
98
106
|
required?: string[];
|
|
@@ -115,6 +123,14 @@ interface BuiltInAgentConfiguration {
|
|
|
115
123
|
* The model to use
|
|
116
124
|
*/
|
|
117
125
|
model: BuiltInAgentModel | LanguageModel;
|
|
126
|
+
/**
|
|
127
|
+
* API key for the model provider (OpenAI, Anthropic, Google)
|
|
128
|
+
* If not provided, falls back to environment variables:
|
|
129
|
+
* - OPENAI_API_KEY for OpenAI models
|
|
130
|
+
* - ANTHROPIC_API_KEY for Anthropic models
|
|
131
|
+
* - GOOGLE_API_KEY for Google models
|
|
132
|
+
*/
|
|
133
|
+
apiKey?: string;
|
|
118
134
|
/**
|
|
119
135
|
* Maximum number of steps/iterations for tool calling (default: 1)
|
|
120
136
|
*/
|
|
@@ -175,6 +191,16 @@ interface BuiltInAgentConfiguration {
|
|
|
175
191
|
* Optional tools available to the agent
|
|
176
192
|
*/
|
|
177
193
|
tools?: ToolDefinition[];
|
|
194
|
+
/**
|
|
195
|
+
* Forward system-role messages from input to the LLM.
|
|
196
|
+
* Default: false
|
|
197
|
+
*/
|
|
198
|
+
forwardSystemMessages?: boolean;
|
|
199
|
+
/**
|
|
200
|
+
* Forward developer-role messages from input to the LLM (as system messages).
|
|
201
|
+
* Default: false
|
|
202
|
+
*/
|
|
203
|
+
forwardDeveloperMessages?: boolean;
|
|
178
204
|
}
|
|
179
205
|
declare class BuiltInAgent extends AbstractAgent {
|
|
180
206
|
private config;
|
|
@@ -196,4 +222,4 @@ declare class BasicAgent extends BuiltInAgent {
|
|
|
196
222
|
}
|
|
197
223
|
type BasicAgentConfiguration = BuiltInAgentConfiguration;
|
|
198
224
|
|
|
199
|
-
export { BasicAgent, type BasicAgentConfiguration, BuiltInAgent, type BuiltInAgentConfiguration, type BuiltInAgentModel, type MCPClientConfig, type MCPClientConfigHTTP, type MCPClientConfigSSE, type ModelSpecifier, type OverridableProperty, type ToolDefinition, convertJsonSchemaToZodSchema, convertMessagesToVercelAISDKMessages, convertToolDefinitionsToVercelAITools, convertToolsToVercelAITools, defineTool, resolveModel };
|
|
225
|
+
export { BasicAgent, type BasicAgentConfiguration, BuiltInAgent, type BuiltInAgentConfiguration, type BuiltInAgentModel, type MCPClientConfig, type MCPClientConfigHTTP, type MCPClientConfigSSE, type MessageConversionOptions, type ModelSpecifier, type OverridableProperty, type ToolDefinition, convertJsonSchemaToZodSchema, convertMessagesToVercelAISDKMessages, convertToolDefinitionsToVercelAITools, convertToolsToVercelAITools, defineTool, resolveModel };
|
package/dist/index.js
CHANGED
|
@@ -41,7 +41,7 @@ var import_crypto = require("crypto");
|
|
|
41
41
|
var import_zod = require("zod");
|
|
42
42
|
var import_streamableHttp = require("@modelcontextprotocol/sdk/client/streamableHttp.js");
|
|
43
43
|
var import_sse = require("@modelcontextprotocol/sdk/client/sse.js");
|
|
44
|
-
function resolveModel(spec) {
|
|
44
|
+
function resolveModel(spec, apiKey) {
|
|
45
45
|
if (typeof spec !== "string") {
|
|
46
46
|
return spec;
|
|
47
47
|
}
|
|
@@ -64,13 +64,13 @@ function resolveModel(spec) {
|
|
|
64
64
|
switch (provider) {
|
|
65
65
|
case "openai": {
|
|
66
66
|
const openai = (0, import_openai.createOpenAI)({
|
|
67
|
-
apiKey: process.env.OPENAI_API_KEY
|
|
67
|
+
apiKey: apiKey || process.env.OPENAI_API_KEY
|
|
68
68
|
});
|
|
69
69
|
return openai(model);
|
|
70
70
|
}
|
|
71
71
|
case "anthropic": {
|
|
72
72
|
const anthropic = (0, import_anthropic.createAnthropic)({
|
|
73
|
-
apiKey: process.env.ANTHROPIC_API_KEY
|
|
73
|
+
apiKey: apiKey || process.env.ANTHROPIC_API_KEY
|
|
74
74
|
});
|
|
75
75
|
return anthropic(model);
|
|
76
76
|
}
|
|
@@ -78,7 +78,7 @@ function resolveModel(spec) {
|
|
|
78
78
|
case "gemini":
|
|
79
79
|
case "google-gemini": {
|
|
80
80
|
const google = (0, import_google.createGoogleGenerativeAI)({
|
|
81
|
-
apiKey: process.env.GOOGLE_API_KEY
|
|
81
|
+
apiKey: apiKey || process.env.GOOGLE_API_KEY
|
|
82
82
|
});
|
|
83
83
|
return google(model);
|
|
84
84
|
}
|
|
@@ -108,10 +108,22 @@ function flattenUserMessageContent(content) {
|
|
|
108
108
|
return "";
|
|
109
109
|
}).filter((text) => text.length > 0).join("\n");
|
|
110
110
|
}
|
|
111
|
-
function convertMessagesToVercelAISDKMessages(messages) {
|
|
111
|
+
function convertMessagesToVercelAISDKMessages(messages, options = {}) {
|
|
112
112
|
const result = [];
|
|
113
113
|
for (const message of messages) {
|
|
114
|
-
if (message.role === "
|
|
114
|
+
if (message.role === "system" && options.forwardSystemMessages) {
|
|
115
|
+
const systemMsg = {
|
|
116
|
+
role: "system",
|
|
117
|
+
content: message.content ?? ""
|
|
118
|
+
};
|
|
119
|
+
result.push(systemMsg);
|
|
120
|
+
} else if (message.role === "developer" && options.forwardDeveloperMessages) {
|
|
121
|
+
const systemMsg = {
|
|
122
|
+
role: "system",
|
|
123
|
+
content: message.content ?? ""
|
|
124
|
+
};
|
|
125
|
+
result.push(systemMsg);
|
|
126
|
+
} else if (message.role === "assistant") {
|
|
115
127
|
const parts = message.content ? [{ type: "text", text: message.content }] : [];
|
|
116
128
|
for (const toolCall of message.toolCalls ?? []) {
|
|
117
129
|
const toolCallPart = {
|
|
@@ -164,6 +176,9 @@ function convertMessagesToVercelAISDKMessages(messages) {
|
|
|
164
176
|
return result;
|
|
165
177
|
}
|
|
166
178
|
function convertJsonSchemaToZodSchema(jsonSchema, required) {
|
|
179
|
+
if (!jsonSchema.type) {
|
|
180
|
+
return required ? import_zod.z.object({}) : import_zod.z.object({}).optional();
|
|
181
|
+
}
|
|
167
182
|
if (jsonSchema.type === "object") {
|
|
168
183
|
const spec = {};
|
|
169
184
|
if (!jsonSchema.properties || !Object.keys(jsonSchema.properties).length) {
|
|
@@ -177,7 +192,7 @@ function convertJsonSchemaToZodSchema(jsonSchema, required) {
|
|
|
177
192
|
} else if (jsonSchema.type === "string") {
|
|
178
193
|
let schema = import_zod.z.string().describe(jsonSchema.description ?? "");
|
|
179
194
|
return required ? schema : schema.optional();
|
|
180
|
-
} else if (jsonSchema.type === "number") {
|
|
195
|
+
} else if (jsonSchema.type === "number" || jsonSchema.type === "integer") {
|
|
181
196
|
let schema = import_zod.z.number().describe(jsonSchema.description ?? "");
|
|
182
197
|
return required ? schema : schema.optional();
|
|
183
198
|
} else if (jsonSchema.type === "boolean") {
|
|
@@ -191,12 +206,14 @@ function convertJsonSchemaToZodSchema(jsonSchema, required) {
|
|
|
191
206
|
let schema = import_zod.z.array(itemSchema).describe(jsonSchema.description ?? "");
|
|
192
207
|
return required ? schema : schema.optional();
|
|
193
208
|
}
|
|
209
|
+
console.error("Invalid JSON schema:", JSON.stringify(jsonSchema, null, 2));
|
|
194
210
|
throw new Error("Invalid JSON schema");
|
|
195
211
|
}
|
|
196
212
|
function isJsonSchema(obj) {
|
|
197
213
|
if (typeof obj !== "object" || obj === null) return false;
|
|
198
214
|
const schema = obj;
|
|
199
|
-
|
|
215
|
+
if (Object.keys(schema).length === 0) return true;
|
|
216
|
+
return typeof schema.type === "string" && ["object", "string", "number", "integer", "boolean", "array"].includes(schema.type);
|
|
200
217
|
}
|
|
201
218
|
function convertToolsToVercelAITools(tools) {
|
|
202
219
|
const result = {};
|
|
@@ -243,7 +260,7 @@ var BuiltInAgent = class _BuiltInAgent extends import_client.AbstractAgent {
|
|
|
243
260
|
runId: input.runId
|
|
244
261
|
};
|
|
245
262
|
subscriber.next(startEvent);
|
|
246
|
-
const model = resolveModel(this.config.model);
|
|
263
|
+
const model = resolveModel(this.config.model, this.config.apiKey);
|
|
247
264
|
let systemPrompt = void 0;
|
|
248
265
|
const hasPrompt = !!this.config.prompt;
|
|
249
266
|
const hasContext = input.context && input.context.length > 0;
|
|
@@ -274,7 +291,10 @@ ${JSON.stringify(input.state, null, 2)}
|
|
|
274
291
|
}
|
|
275
292
|
systemPrompt = parts.join("");
|
|
276
293
|
}
|
|
277
|
-
const messages = convertMessagesToVercelAISDKMessages(input.messages
|
|
294
|
+
const messages = convertMessagesToVercelAISDKMessages(input.messages, {
|
|
295
|
+
forwardSystemMessages: this.config.forwardSystemMessages,
|
|
296
|
+
forwardDeveloperMessages: this.config.forwardDeveloperMessages
|
|
297
|
+
});
|
|
278
298
|
if (systemPrompt) {
|
|
279
299
|
messages.unshift({
|
|
280
300
|
role: "system",
|
|
@@ -306,7 +326,7 @@ ${JSON.stringify(input.state, null, 2)}
|
|
|
306
326
|
const props = input.forwardedProps;
|
|
307
327
|
if (props.model !== void 0 && this.canOverride("model")) {
|
|
308
328
|
if (typeof props.model === "string" || typeof props.model === "object") {
|
|
309
|
-
streamTextParams.model = resolveModel(props.model);
|
|
329
|
+
streamTextParams.model = resolveModel(props.model, this.config.apiKey);
|
|
310
330
|
}
|
|
311
331
|
}
|
|
312
332
|
if (props.toolChoice !== void 0 && this.canOverride("toolChoice")) {
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import {\n AbstractAgent,\n BaseEvent,\n RunAgentInput,\n EventType,\n Message,\n RunFinishedEvent,\n RunStartedEvent,\n TextMessageChunkEvent,\n ToolCallArgsEvent,\n ToolCallEndEvent,\n ToolCallStartEvent,\n ToolCallResultEvent,\n RunErrorEvent,\n StateSnapshotEvent,\n StateDeltaEvent,\n} from \"@ag-ui/client\";\nimport {\n streamText,\n LanguageModel,\n ModelMessage,\n AssistantModelMessage,\n UserModelMessage,\n ToolModelMessage,\n ToolCallPart,\n ToolResultPart,\n TextPart,\n tool as createVercelAISDKTool,\n ToolChoice,\n ToolSet,\n stepCountIs,\n} from \"ai\";\nimport { experimental_createMCPClient as createMCPClient } from \"@ai-sdk/mcp\";\nimport { Observable } from \"rxjs\";\nimport { createOpenAI } from \"@ai-sdk/openai\";\nimport { createAnthropic } from \"@ai-sdk/anthropic\";\nimport { createGoogleGenerativeAI } from \"@ai-sdk/google\";\nimport { randomUUID } from \"crypto\";\nimport { z } from \"zod\";\nimport {\n StreamableHTTPClientTransport,\n StreamableHTTPClientTransportOptions,\n} from \"@modelcontextprotocol/sdk/client/streamableHttp.js\";\nimport { SSEClientTransport } from \"@modelcontextprotocol/sdk/client/sse.js\";\n\n/**\n * Properties that can be overridden by forwardedProps\n * These match the exact parameter names in streamText\n */\nexport type OverridableProperty =\n | \"model\"\n | \"toolChoice\"\n | \"maxOutputTokens\"\n | \"temperature\"\n | \"topP\"\n | \"topK\"\n | \"presencePenalty\"\n | \"frequencyPenalty\"\n | \"stopSequences\"\n | \"seed\"\n | \"maxRetries\"\n | \"prompt\";\n\n/**\n * Supported model identifiers for BuiltInAgent\n */\nexport type BuiltInAgentModel =\n // OpenAI models\n | \"openai/gpt-5\"\n | \"openai/gpt-5-mini\"\n | \"openai/gpt-4.1\"\n | \"openai/gpt-4.1-mini\"\n | \"openai/gpt-4.1-nano\"\n | \"openai/gpt-4o\"\n | \"openai/gpt-4o-mini\"\n // OpenAI reasoning series\n | \"openai/o3\"\n | \"openai/o3-mini\"\n | \"openai/o4-mini\"\n // Anthropic (Claude) models\n | \"anthropic/claude-sonnet-4.5\"\n | \"anthropic/claude-sonnet-4\"\n | \"anthropic/claude-3.7-sonnet\"\n | \"anthropic/claude-opus-4.1\"\n | \"anthropic/claude-opus-4\"\n | \"anthropic/claude-3.5-haiku\"\n // Google (Gemini) models\n | \"google/gemini-2.5-pro\"\n | \"google/gemini-2.5-flash\"\n | \"google/gemini-2.5-flash-lite\"\n // Allow any LanguageModel instance\n | (string & {});\n\n/**\n * Model specifier - can be a string like \"openai/gpt-4o\" or a LanguageModel instance\n */\nexport type ModelSpecifier = string | LanguageModel;\n\n/**\n * MCP Client configuration for HTTP transport\n */\nexport interface MCPClientConfigHTTP {\n /**\n * Type of MCP client\n */\n type: \"http\";\n /**\n * URL of the MCP server\n */\n url: string;\n /**\n * Optional transport options for HTTP client\n */\n options?: StreamableHTTPClientTransportOptions;\n}\n\n/**\n * MCP Client configuration for SSE transport\n */\nexport interface MCPClientConfigSSE {\n /**\n * Type of MCP client\n */\n type: \"sse\";\n /**\n * URL of the MCP server\n */\n url: string;\n /**\n * Optional HTTP headers (e.g., for authentication)\n */\n headers?: Record<string, string>;\n}\n\n/**\n * MCP Client configuration\n */\nexport type MCPClientConfig = MCPClientConfigHTTP | MCPClientConfigSSE;\n\n/**\n * Resolves a model specifier to a LanguageModel instance\n * @param spec - Model string (e.g., \"openai/gpt-4o\") or LanguageModel instance\n * @returns LanguageModel instance\n */\nexport function resolveModel(spec: ModelSpecifier): LanguageModel {\n // If already a LanguageModel instance, pass through\n if (typeof spec !== \"string\") {\n return spec;\n }\n\n // Normalize \"provider/model\" or \"provider:model\" format\n const normalized = spec.replace(\"/\", \":\").trim();\n const parts = normalized.split(\":\");\n const rawProvider = parts[0];\n const rest = parts.slice(1);\n\n if (!rawProvider) {\n throw new Error(\n `Invalid model string \"${spec}\". Use \"openai/gpt-5\", \"anthropic/claude-sonnet-4.5\", or \"google/gemini-2.5-pro\".`,\n );\n }\n\n const provider = rawProvider.toLowerCase();\n const model = rest.join(\":\").trim();\n\n if (!model) {\n throw new Error(\n `Invalid model string \"${spec}\". Use \"openai/gpt-5\", \"anthropic/claude-sonnet-4.5\", or \"google/gemini-2.5-pro\".`,\n );\n }\n\n switch (provider) {\n case \"openai\": {\n // Lazily create OpenAI provider\n const openai = createOpenAI({\n apiKey: process.env.OPENAI_API_KEY!,\n });\n // Accepts any OpenAI model id, e.g. \"gpt-4o\", \"gpt-4.1-mini\", \"o3-mini\"\n return openai(model);\n }\n\n case \"anthropic\": {\n // Lazily create Anthropic provider\n const anthropic = createAnthropic({\n apiKey: process.env.ANTHROPIC_API_KEY!,\n });\n // Accepts any Claude id, e.g. \"claude-3.7-sonnet\", \"claude-3.5-haiku\"\n return anthropic(model);\n }\n\n case \"google\":\n case \"gemini\":\n case \"google-gemini\": {\n // Lazily create Google provider\n const google = createGoogleGenerativeAI({\n apiKey: process.env.GOOGLE_API_KEY!,\n });\n // Accepts any Gemini id, e.g. \"gemini-2.5-pro\", \"gemini-2.5-flash\"\n return google(model);\n }\n\n default:\n throw new Error(`Unknown provider \"${provider}\" in \"${spec}\". Supported: openai, anthropic, google (gemini).`);\n }\n}\n\n/**\n * Tool definition for BuiltInAgent\n */\nexport interface ToolDefinition<TParameters extends z.ZodTypeAny = z.ZodTypeAny> {\n name: string;\n description: string;\n parameters: TParameters;\n execute: (args: z.infer<TParameters>) => Promise<unknown>;\n}\n\n/**\n * Define a tool for use with BuiltInAgent\n * @param name - The name of the tool\n * @param description - Description of what the tool does\n * @param parameters - Zod schema for the tool's input parameters\n * @param execute - Function to execute the tool server-side\n * @returns Tool definition\n */\nexport function defineTool<TParameters extends z.ZodTypeAny>(config: {\n name: string;\n description: string;\n parameters: TParameters;\n execute: (args: z.infer<TParameters>) => Promise<unknown>;\n}): ToolDefinition<TParameters> {\n return {\n name: config.name,\n description: config.description,\n parameters: config.parameters,\n execute: config.execute,\n };\n}\n\ntype AGUIUserMessage = Extract<Message, { role: \"user\" }>;\n\nfunction flattenUserMessageContent(content?: AGUIUserMessage[\"content\"]): string {\n if (!content) {\n return \"\";\n }\n\n if (typeof content === \"string\") {\n return content;\n }\n\n return content\n .map((part) => {\n if (\n part &&\n typeof part === \"object\" &&\n \"type\" in part &&\n (part as { type?: unknown }).type === \"text\" &&\n typeof (part as { text?: unknown }).text === \"string\"\n ) {\n return (part as { text: string }).text;\n }\n return \"\";\n })\n .filter((text) => text.length > 0)\n .join(\"\\n\");\n}\n\n/**\n * Converts AG-UI messages to Vercel AI SDK ModelMessage format\n */\nexport function convertMessagesToVercelAISDKMessages(messages: Message[]): ModelMessage[] {\n const result: ModelMessage[] = [];\n\n for (const message of messages) {\n if (message.role === \"assistant\") {\n const parts: Array<TextPart | ToolCallPart> = message.content ? [{ type: \"text\", text: message.content }] : [];\n\n for (const toolCall of message.toolCalls ?? []) {\n const toolCallPart: ToolCallPart = {\n type: \"tool-call\",\n toolCallId: toolCall.id,\n toolName: toolCall.function.name,\n input: JSON.parse(toolCall.function.arguments),\n };\n parts.push(toolCallPart);\n }\n\n const assistantMsg: AssistantModelMessage = {\n role: \"assistant\",\n content: parts,\n };\n result.push(assistantMsg);\n } else if (message.role === \"user\") {\n const userMsg: UserModelMessage = {\n role: \"user\",\n content: flattenUserMessageContent(message.content),\n };\n result.push(userMsg);\n } else if (message.role === \"tool\") {\n let toolName = \"unknown\";\n // Find the tool name from the corresponding tool call\n for (const msg of messages) {\n if (msg.role === \"assistant\") {\n for (const toolCall of msg.toolCalls ?? []) {\n if (toolCall.id === message.toolCallId) {\n toolName = toolCall.function.name;\n break;\n }\n }\n }\n }\n\n const toolResultPart: ToolResultPart = {\n type: \"tool-result\",\n toolCallId: message.toolCallId,\n toolName: toolName,\n output: {\n type: \"text\",\n value: message.content,\n },\n };\n\n const toolMsg: ToolModelMessage = {\n role: \"tool\",\n content: [toolResultPart],\n };\n result.push(toolMsg);\n }\n }\n\n return result;\n}\n\n/**\n * JSON Schema type definition\n */\ninterface JsonSchema {\n type: \"object\" | \"string\" | \"number\" | \"boolean\" | \"array\";\n description?: string;\n properties?: Record<string, JsonSchema>;\n required?: string[];\n items?: JsonSchema;\n}\n\n/**\n * Converts JSON Schema to Zod schema\n */\nexport function convertJsonSchemaToZodSchema(jsonSchema: JsonSchema, required: boolean): z.ZodSchema {\n if (jsonSchema.type === \"object\") {\n const spec: { [key: string]: z.ZodSchema } = {};\n\n if (!jsonSchema.properties || !Object.keys(jsonSchema.properties).length) {\n return !required ? z.object(spec).optional() : z.object(spec);\n }\n\n for (const [key, value] of Object.entries(jsonSchema.properties)) {\n spec[key] = convertJsonSchemaToZodSchema(value, jsonSchema.required ? jsonSchema.required.includes(key) : false);\n }\n let schema = z.object(spec).describe(jsonSchema.description ?? \"\");\n return required ? schema : schema.optional();\n } else if (jsonSchema.type === \"string\") {\n let schema = z.string().describe(jsonSchema.description ?? \"\");\n return required ? schema : schema.optional();\n } else if (jsonSchema.type === \"number\") {\n let schema = z.number().describe(jsonSchema.description ?? \"\");\n return required ? schema : schema.optional();\n } else if (jsonSchema.type === \"boolean\") {\n let schema = z.boolean().describe(jsonSchema.description ?? \"\");\n return required ? schema : schema.optional();\n } else if (jsonSchema.type === \"array\") {\n if (!jsonSchema.items) {\n throw new Error(\"Array type must have items property\");\n }\n let itemSchema = convertJsonSchemaToZodSchema(jsonSchema.items, true);\n let schema = z.array(itemSchema).describe(jsonSchema.description ?? \"\");\n return required ? schema : schema.optional();\n }\n throw new Error(\"Invalid JSON schema\");\n}\n\n/**\n * Converts AG-UI tools to Vercel AI SDK ToolSet\n */\nfunction isJsonSchema(obj: unknown): obj is JsonSchema {\n if (typeof obj !== \"object\" || obj === null) return false;\n const schema = obj as Record<string, unknown>;\n return typeof schema.type === \"string\" && [\"object\", \"string\", \"number\", \"boolean\", \"array\"].includes(schema.type);\n}\n\nexport function convertToolsToVercelAITools(tools: RunAgentInput[\"tools\"]): ToolSet {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const result: Record<string, any> = {};\n\n for (const tool of tools) {\n if (!isJsonSchema(tool.parameters)) {\n throw new Error(`Invalid JSON schema for tool ${tool.name}`);\n }\n const zodSchema = convertJsonSchemaToZodSchema(tool.parameters, true);\n result[tool.name] = createVercelAISDKTool({\n description: tool.description,\n inputSchema: zodSchema,\n });\n }\n\n return result;\n}\n\n/**\n * Converts ToolDefinition array to Vercel AI SDK ToolSet\n */\nexport function convertToolDefinitionsToVercelAITools(tools: ToolDefinition[]): ToolSet {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const result: Record<string, any> = {};\n\n for (const tool of tools) {\n result[tool.name] = createVercelAISDKTool({\n description: tool.description,\n inputSchema: tool.parameters,\n execute: tool.execute,\n });\n }\n\n return result;\n}\n\n/**\n * Configuration for BuiltInAgent\n */\nexport interface BuiltInAgentConfiguration {\n /**\n * The model to use\n */\n model: BuiltInAgentModel | LanguageModel;\n /**\n * Maximum number of steps/iterations for tool calling (default: 1)\n */\n maxSteps?: number;\n /**\n * Tool choice setting - how tools are selected for execution (default: \"auto\")\n */\n toolChoice?: ToolChoice<Record<string, unknown>>;\n /**\n * Maximum number of tokens to generate\n */\n maxOutputTokens?: number;\n /**\n * Temperature setting (range depends on provider)\n */\n temperature?: number;\n /**\n * Nucleus sampling (topP)\n */\n topP?: number;\n /**\n * Top K sampling\n */\n topK?: number;\n /**\n * Presence penalty\n */\n presencePenalty?: number;\n /**\n * Frequency penalty\n */\n frequencyPenalty?: number;\n /**\n * Sequences that will stop the generation\n */\n stopSequences?: string[];\n /**\n * Seed for deterministic results\n */\n seed?: number;\n /**\n * Maximum number of retries\n */\n maxRetries?: number;\n /**\n * Prompt for the agent\n */\n prompt?: string;\n /**\n * List of properties that can be overridden by forwardedProps.\n */\n overridableProperties?: OverridableProperty[];\n /**\n * Optional list of MCP server configurations\n */\n mcpServers?: MCPClientConfig[];\n /**\n * Optional tools available to the agent\n */\n tools?: ToolDefinition[];\n}\n\nexport class BuiltInAgent extends AbstractAgent {\n private abortController?: AbortController;\n\n constructor(private config: BuiltInAgentConfiguration) {\n super();\n }\n\n /**\n * Check if a property can be overridden by forwardedProps\n */\n canOverride(property: OverridableProperty): boolean {\n return this.config?.overridableProperties?.includes(property) ?? false;\n }\n\n run(input: RunAgentInput): Observable<BaseEvent> {\n return new Observable<BaseEvent>((subscriber) => {\n // Emit RUN_STARTED event\n const startEvent: RunStartedEvent = {\n type: EventType.RUN_STARTED,\n threadId: input.threadId,\n runId: input.runId,\n };\n subscriber.next(startEvent);\n\n // Resolve the model\n const model = resolveModel(this.config.model);\n\n // Build prompt based on conditions\n let systemPrompt: string | undefined = undefined;\n\n // Check if we should build a prompt:\n // - config.prompt is set, OR\n // - input.context is non-empty, OR\n // - input.state is non-empty and not an empty object\n const hasPrompt = !!this.config.prompt;\n const hasContext = input.context && input.context.length > 0;\n const hasState =\n input.state !== undefined &&\n input.state !== null &&\n !(typeof input.state === \"object\" && Object.keys(input.state).length === 0);\n\n if (hasPrompt || hasContext || hasState) {\n const parts: string[] = [];\n\n // First: the prompt if any\n if (hasPrompt) {\n parts.push(this.config.prompt!);\n }\n\n // Second: context from the application\n if (hasContext) {\n parts.push(\"\\n## Context from the application\\n\");\n for (const ctx of input.context) {\n parts.push(`${ctx.description}:\\n${ctx.value}\\n`);\n }\n }\n\n // Third: state from the application that can be edited\n if (hasState) {\n parts.push(\n \"\\n## Application State\\n\" +\n \"This is state from the application that you can edit by calling AGUISendStateSnapshot or AGUISendStateDelta.\\n\" +\n `\\`\\`\\`json\\n${JSON.stringify(input.state, null, 2)}\\n\\`\\`\\`\\n`,\n );\n }\n\n systemPrompt = parts.join(\"\");\n }\n\n // Convert messages and prepend system message if we have a prompt\n const messages = convertMessagesToVercelAISDKMessages(input.messages);\n if (systemPrompt) {\n messages.unshift({\n role: \"system\",\n content: systemPrompt,\n });\n }\n\n // Merge tools from input and config\n let allTools: ToolSet = convertToolsToVercelAITools(input.tools);\n if (this.config.tools && this.config.tools.length > 0) {\n const configTools = convertToolDefinitionsToVercelAITools(this.config.tools);\n allTools = { ...allTools, ...configTools };\n }\n\n const streamTextParams: Parameters<typeof streamText>[0] = {\n model,\n messages,\n tools: allTools,\n toolChoice: this.config.toolChoice,\n stopWhen: this.config.maxSteps ? stepCountIs(this.config.maxSteps) : undefined,\n maxOutputTokens: this.config.maxOutputTokens,\n temperature: this.config.temperature,\n topP: this.config.topP,\n topK: this.config.topK,\n presencePenalty: this.config.presencePenalty,\n frequencyPenalty: this.config.frequencyPenalty,\n stopSequences: this.config.stopSequences,\n seed: this.config.seed,\n maxRetries: this.config.maxRetries,\n };\n\n // Apply forwardedProps overrides (if allowed)\n if (input.forwardedProps && typeof input.forwardedProps === \"object\") {\n const props = input.forwardedProps as Record<string, unknown>;\n\n // Check and apply each overridable property\n if (props.model !== undefined && this.canOverride(\"model\")) {\n if (typeof props.model === \"string\" || typeof props.model === \"object\") {\n // Accept any string or LanguageModel instance for model override\n streamTextParams.model = resolveModel(props.model as string | LanguageModel);\n }\n }\n if (props.toolChoice !== undefined && this.canOverride(\"toolChoice\")) {\n // ToolChoice can be 'auto', 'required', 'none', or { type: 'tool', toolName: string }\n const toolChoice = props.toolChoice;\n if (\n toolChoice === \"auto\" ||\n toolChoice === \"required\" ||\n toolChoice === \"none\" ||\n (typeof toolChoice === \"object\" &&\n toolChoice !== null &&\n \"type\" in toolChoice &&\n toolChoice.type === \"tool\")\n ) {\n streamTextParams.toolChoice = toolChoice as ToolChoice<Record<string, unknown>>;\n }\n }\n if (typeof props.maxOutputTokens === \"number\" && this.canOverride(\"maxOutputTokens\")) {\n streamTextParams.maxOutputTokens = props.maxOutputTokens;\n }\n if (typeof props.temperature === \"number\" && this.canOverride(\"temperature\")) {\n streamTextParams.temperature = props.temperature;\n }\n if (typeof props.topP === \"number\" && this.canOverride(\"topP\")) {\n streamTextParams.topP = props.topP;\n }\n if (typeof props.topK === \"number\" && this.canOverride(\"topK\")) {\n streamTextParams.topK = props.topK;\n }\n if (typeof props.presencePenalty === \"number\" && this.canOverride(\"presencePenalty\")) {\n streamTextParams.presencePenalty = props.presencePenalty;\n }\n if (typeof props.frequencyPenalty === \"number\" && this.canOverride(\"frequencyPenalty\")) {\n streamTextParams.frequencyPenalty = props.frequencyPenalty;\n }\n if (Array.isArray(props.stopSequences) && this.canOverride(\"stopSequences\")) {\n // Validate all elements are strings\n if (props.stopSequences.every((item): item is string => typeof item === \"string\")) {\n streamTextParams.stopSequences = props.stopSequences;\n }\n }\n if (typeof props.seed === \"number\" && this.canOverride(\"seed\")) {\n streamTextParams.seed = props.seed;\n }\n if (typeof props.maxRetries === \"number\" && this.canOverride(\"maxRetries\")) {\n streamTextParams.maxRetries = props.maxRetries;\n }\n }\n\n // Set up MCP clients if configured and process the stream\n const mcpClients: Array<{ close: () => Promise<void> }> = [];\n\n (async () => {\n const abortController = new AbortController();\n this.abortController = abortController;\n let terminalEventEmitted = false;\n\n try {\n // Add AG-UI state update tools\n streamTextParams.tools = {\n ...streamTextParams.tools,\n AGUISendStateSnapshot: createVercelAISDKTool({\n description: \"Replace the entire application state with a new snapshot\",\n inputSchema: z.object({\n snapshot: z.any().describe(\"The complete new state object\"),\n }),\n execute: async ({ snapshot }) => {\n return { success: true, snapshot };\n },\n }),\n AGUISendStateDelta: createVercelAISDKTool({\n description: \"Apply incremental updates to application state using JSON Patch operations\",\n inputSchema: z.object({\n delta: z\n .array(\n z.object({\n op: z.enum([\"add\", \"replace\", \"remove\"]).describe(\"The operation to perform\"),\n path: z.string().describe(\"JSON Pointer path (e.g., '/foo/bar')\"),\n value: z\n .any()\n .optional()\n .describe(\n \"The value to set. Required for 'add' and 'replace' operations, ignored for 'remove'.\",\n ),\n }),\n )\n .describe(\"Array of JSON Patch operations\"),\n }),\n execute: async ({ delta }) => {\n return { success: true, delta };\n },\n }),\n };\n\n // Initialize MCP clients and get their tools\n if (this.config.mcpServers && this.config.mcpServers.length > 0) {\n for (const serverConfig of this.config.mcpServers) {\n let transport;\n\n if (serverConfig.type === \"http\") {\n const url = new URL(serverConfig.url);\n transport = new StreamableHTTPClientTransport(url, serverConfig.options);\n } else if (serverConfig.type === \"sse\") {\n transport = new SSEClientTransport(new URL(serverConfig.url), serverConfig.headers);\n }\n\n if (transport) {\n const mcpClient = await createMCPClient({ transport });\n mcpClients.push(mcpClient);\n\n // Get tools from this MCP server and merge with existing tools\n const mcpTools = await mcpClient.tools();\n streamTextParams.tools = { ...streamTextParams.tools, ...mcpTools } as ToolSet;\n }\n }\n }\n\n // Call streamText and process the stream\n const response = streamText({ ...streamTextParams, abortSignal: abortController.signal });\n\n let messageId = randomUUID();\n\n const toolCallStates = new Map<\n string,\n {\n started: boolean;\n hasArgsDelta: boolean;\n ended: boolean;\n toolName?: string;\n }\n >();\n\n const ensureToolCallState = (toolCallId: string) => {\n let state = toolCallStates.get(toolCallId);\n if (!state) {\n state = { started: false, hasArgsDelta: false, ended: false };\n toolCallStates.set(toolCallId, state);\n }\n return state;\n };\n\n // Process fullStream events\n for await (const part of response.fullStream) {\n switch (part.type) {\n case 'abort':\n const abortEndEvent: RunFinishedEvent = {\n type: EventType.RUN_FINISHED,\n threadId: input.threadId,\n runId: input.runId,\n };\n subscriber.next(abortEndEvent);\n terminalEventEmitted = true;\n\n // Complete the observable\n subscriber.complete();\n break;\n\n case \"tool-input-start\": {\n const toolCallId = part.id;\n const state = ensureToolCallState(toolCallId);\n state.toolName = part.toolName;\n if (!state.started) {\n state.started = true;\n const startEvent: ToolCallStartEvent = {\n type: EventType.TOOL_CALL_START,\n parentMessageId: messageId,\n toolCallId,\n toolCallName: part.toolName,\n };\n subscriber.next(startEvent);\n }\n break;\n }\n\n case \"tool-input-delta\": {\n const toolCallId = part.id;\n const state = ensureToolCallState(toolCallId);\n state.hasArgsDelta = true;\n const argsEvent: ToolCallArgsEvent = {\n type: EventType.TOOL_CALL_ARGS,\n toolCallId,\n delta: part.delta,\n };\n subscriber.next(argsEvent);\n break;\n }\n\n case \"tool-input-end\": {\n // No direct event – the subsequent \"tool-call\" part marks completion.\n break;\n }\n\n case \"text-start\": {\n // New text message starting - use the SDK-provided id\n // Use randomUUID() if part.id is falsy or \"0\" to prevent message merging issues\n const providedId = \"id\" in part ? part.id : undefined;\n messageId = (providedId && providedId !== \"0\") ? (providedId as typeof messageId) : randomUUID();\n break;\n }\n\n case \"text-delta\": {\n // Accumulate text content - in AI SDK 5.0, the property is 'text'\n const textDelta = \"text\" in part ? part.text : \"\";\n // Emit text chunk event\n const textEvent: TextMessageChunkEvent = {\n type: EventType.TEXT_MESSAGE_CHUNK,\n role: \"assistant\",\n messageId,\n delta: textDelta,\n };\n subscriber.next(textEvent);\n break;\n }\n\n case \"tool-call\": {\n const toolCallId = part.toolCallId;\n const state = ensureToolCallState(toolCallId);\n state.toolName = part.toolName ?? state.toolName;\n\n if (!state.started) {\n state.started = true;\n const startEvent: ToolCallStartEvent = {\n type: EventType.TOOL_CALL_START,\n parentMessageId: messageId,\n toolCallId,\n toolCallName: part.toolName,\n };\n subscriber.next(startEvent);\n }\n\n if (!state.hasArgsDelta && \"input\" in part && part.input !== undefined) {\n let serializedInput = \"\";\n if (typeof part.input === \"string\") {\n serializedInput = part.input;\n } else {\n try {\n serializedInput = JSON.stringify(part.input);\n } catch {\n serializedInput = String(part.input);\n }\n }\n\n if (serializedInput.length > 0) {\n const argsEvent: ToolCallArgsEvent = {\n type: EventType.TOOL_CALL_ARGS,\n toolCallId,\n delta: serializedInput,\n };\n subscriber.next(argsEvent);\n state.hasArgsDelta = true;\n }\n }\n\n if (!state.ended) {\n state.ended = true;\n const endEvent: ToolCallEndEvent = {\n type: EventType.TOOL_CALL_END,\n toolCallId,\n };\n subscriber.next(endEvent);\n }\n break;\n }\n\n case \"tool-result\": {\n const toolResult = \"output\" in part ? part.output : null;\n const toolName = \"toolName\" in part ? part.toolName : \"\";\n toolCallStates.delete(part.toolCallId);\n\n // Check if this is a state update tool\n if (toolName === \"AGUISendStateSnapshot\" && toolResult && typeof toolResult === \"object\") {\n // Emit StateSnapshotEvent\n const stateSnapshotEvent: StateSnapshotEvent = {\n type: EventType.STATE_SNAPSHOT,\n snapshot: toolResult.snapshot,\n };\n subscriber.next(stateSnapshotEvent);\n } else if (toolName === \"AGUISendStateDelta\" && toolResult && typeof toolResult === \"object\") {\n // Emit StateDeltaEvent\n const stateDeltaEvent: StateDeltaEvent = {\n type: EventType.STATE_DELTA,\n delta: toolResult.delta,\n };\n subscriber.next(stateDeltaEvent);\n }\n\n // Always emit the tool result event for the LLM\n const resultEvent: ToolCallResultEvent = {\n type: EventType.TOOL_CALL_RESULT,\n role: \"tool\",\n messageId: randomUUID(),\n toolCallId: part.toolCallId,\n content: JSON.stringify(toolResult),\n };\n subscriber.next(resultEvent);\n break;\n }\n\n case \"finish\":\n // Emit run finished event\n const finishedEvent: RunFinishedEvent = {\n type: EventType.RUN_FINISHED,\n threadId: input.threadId,\n runId: input.runId,\n };\n subscriber.next(finishedEvent);\n terminalEventEmitted = true;\n\n // Complete the observable\n subscriber.complete();\n break;\n\n case \"error\": {\n if (abortController.signal.aborted) {\n break;\n }\n const runErrorEvent: RunErrorEvent = {\n type: EventType.RUN_ERROR,\n message: part.error + \"\",\n };\n subscriber.next(runErrorEvent);\n terminalEventEmitted = true;\n\n // Handle error\n subscriber.error(part.error);\n break;\n }\n }\n }\n\n if (!terminalEventEmitted) {\n if (abortController.signal.aborted) {\n // Let the runner finalize the stream on stop requests so it can\n // inject consistent closing events and a RUN_FINISHED marker.\n } else {\n const finishedEvent: RunFinishedEvent = {\n type: EventType.RUN_FINISHED,\n threadId: input.threadId,\n runId: input.runId,\n };\n subscriber.next(finishedEvent);\n }\n\n terminalEventEmitted = true;\n subscriber.complete();\n }\n } catch (error) {\n if (abortController.signal.aborted) {\n subscriber.complete();\n } else {\n const runErrorEvent: RunErrorEvent = {\n type: EventType.RUN_ERROR,\n message: error + \"\",\n };\n subscriber.next(runErrorEvent);\n terminalEventEmitted = true;\n subscriber.error(error);\n }\n } finally {\n this.abortController = undefined;\n await Promise.all(mcpClients.map((client) => client.close()));\n }\n })();\n\n // Cleanup function\n return () => {\n // Cleanup MCP clients if stream is unsubscribed\n Promise.all(mcpClients.map((client) => client.close())).catch(() => {\n // Ignore cleanup errors\n });\n };\n });\n }\n\n clone() {\n const cloned = new BuiltInAgent(this.config);\n // Copy middlewares from parent class\n // @ts-expect-error - accessing protected property from parent\n cloned.middlewares = [...this.middlewares];\n return cloned;\n }\n\n abortRun(): void {\n this.abortController?.abort();\n }\n}\n\n/**\n * @deprecated Use BuiltInAgent instead\n */\nexport class BasicAgent extends BuiltInAgent {\n constructor(config: BuiltInAgentConfiguration) {\n super(config);\n console.warn(\"BasicAgent is deprecated, use BuiltInAgent instead\");\n }\n}\n\nexport type BasicAgentConfiguration = BuiltInAgentConfiguration;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAgBO;AACP,gBAcO;AACP,iBAAgE;AAChE,kBAA2B;AAC3B,oBAA6B;AAC7B,uBAAgC;AAChC,oBAAyC;AACzC,oBAA2B;AAC3B,iBAAkB;AAClB,4BAGO;AACP,iBAAmC;AAqG5B,SAAS,aAAa,MAAqC;AAEhE,MAAI,OAAO,SAAS,UAAU;AAC5B,WAAO;AAAA,EACT;AAGA,QAAM,aAAa,KAAK,QAAQ,KAAK,GAAG,EAAE,KAAK;AAC/C,QAAM,QAA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B;AACzB,gBAAI,gBAAgB,OAAO,SAAS;AAAA,YAGpC,OAAO;AACL,oBAAM,gBAAkC;AAAA,gBACtC,MAAM,wBAAU;AAAA,gBAChB,UAAU,MAAM;AAAA,gBAChB,OAAO,MAAM;AAAA,cACf;AACA,yBAAW,KAAK,aAAa;AAAA,YAC/B;AAEA,mCAAuB;AACvB,uBAAW,SAAS;AAAA,UACtB;AAAA,QACF,SAAS,OAAO;AACd,cAAI,gBAAgB,OAAO,SAAS;AAClC,uBAAW,SAAS;AAAA,UACtB,OAAO;AACL,kBAAM,gBAA+B;AAAA,cACnC,MAAM,wBAAU;AAAA,cAChB,SAAS,QAAQ;AAAA,YACnB;AACA,uBAAW,KAAK,aAAa;AAC7B,mCAAuB;AACvB,uBAAW,MAAM,KAAK;AAAA,UACxB;AAAA,QACF,UAAE;AACA,eAAK,kBAAkB;AACvB,gBAAM,QAAQ,IAAI,WAAW,IAAI,CAAC,WAAW,OAAO,MAAM,CAAC,CAAC;AAAA,QAC9D;AAAA,MACF,GAAG;AAGH,aAAO,MAAM;AAEX,gBAAQ,IAAI,WAAW,IAAI,CAAC,WAAW,OAAO,MAAM,CAAC,CAAC,EAAE,MAAM,MAAM;AAAA,QAEpE,CAAC;AAAA,MACH;AAAA,IACF,CAAC;AAAA,EACH;AAAA,EAEA,QAAQ;AACN,UAAM,SAAS,IAAI,cAAa,KAAK,MAAM;AAG3C,WAAO,cAAc,CAAC,GAAG,KAAK,WAAW;AACzC,WAAO;AAAA,EACT;AAAA,EAEA,WAAiB;AACf,SAAK,iBAAiB,MAAM;AAAA,EAC9B;AACF;AAKO,IAAM,aAAN,cAAyB,aAAa;AAAA,EAC3C,YAAY,QAAmC;AAC7C,UAAM,MAAM;AACZ,YAAQ,KAAK,oDAAoD;AAAA,EACnE;AACF;","names":["createVercelAISDKTool","createMCPClient","startEvent"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import {\n AbstractAgent,\n BaseEvent,\n RunAgentInput,\n EventType,\n Message,\n RunFinishedEvent,\n RunStartedEvent,\n TextMessageChunkEvent,\n ToolCallArgsEvent,\n ToolCallEndEvent,\n ToolCallStartEvent,\n ToolCallResultEvent,\n RunErrorEvent,\n StateSnapshotEvent,\n StateDeltaEvent,\n} from \"@ag-ui/client\";\nimport {\n streamText,\n LanguageModel,\n ModelMessage,\n AssistantModelMessage,\n UserModelMessage,\n ToolModelMessage,\n SystemModelMessage,\n ToolCallPart,\n ToolResultPart,\n TextPart,\n tool as createVercelAISDKTool,\n ToolChoice,\n ToolSet,\n stepCountIs,\n} from \"ai\";\nimport { experimental_createMCPClient as createMCPClient } from \"@ai-sdk/mcp\";\nimport { Observable } from \"rxjs\";\nimport { createOpenAI } from \"@ai-sdk/openai\";\nimport { createAnthropic } from \"@ai-sdk/anthropic\";\nimport { createGoogleGenerativeAI } from \"@ai-sdk/google\";\nimport { randomUUID } from \"crypto\";\nimport { z } from \"zod\";\nimport {\n StreamableHTTPClientTransport,\n StreamableHTTPClientTransportOptions,\n} from \"@modelcontextprotocol/sdk/client/streamableHttp.js\";\nimport { SSEClientTransport } from \"@modelcontextprotocol/sdk/client/sse.js\";\n\n/**\n * Properties that can be overridden by forwardedProps\n * These match the exact parameter names in streamText\n */\nexport type OverridableProperty =\n | \"model\"\n | \"toolChoice\"\n | \"maxOutputTokens\"\n | \"temperature\"\n | \"topP\"\n | \"topK\"\n | \"presencePenalty\"\n | \"frequencyPenalty\"\n | \"stopSequences\"\n | \"seed\"\n | \"maxRetries\"\n | \"prompt\";\n\n/**\n * Supported model identifiers for BuiltInAgent\n */\nexport type BuiltInAgentModel =\n // OpenAI models\n | \"openai/gpt-5\"\n | \"openai/gpt-5-mini\"\n | \"openai/gpt-4.1\"\n | \"openai/gpt-4.1-mini\"\n | \"openai/gpt-4.1-nano\"\n | \"openai/gpt-4o\"\n | \"openai/gpt-4o-mini\"\n // OpenAI reasoning series\n | \"openai/o3\"\n | \"openai/o3-mini\"\n | \"openai/o4-mini\"\n // Anthropic (Claude) models\n | \"anthropic/claude-sonnet-4.5\"\n | \"anthropic/claude-sonnet-4\"\n | \"anthropic/claude-3.7-sonnet\"\n | \"anthropic/claude-opus-4.1\"\n | \"anthropic/claude-opus-4\"\n | \"anthropic/claude-3.5-haiku\"\n // Google (Gemini) models\n | \"google/gemini-2.5-pro\"\n | \"google/gemini-2.5-flash\"\n | \"google/gemini-2.5-flash-lite\"\n // Allow any LanguageModel instance\n | (string & {});\n\n/**\n * Model specifier - can be a string like \"openai/gpt-4o\" or a LanguageModel instance\n */\nexport type ModelSpecifier = string | LanguageModel;\n\n/**\n * MCP Client configuration for HTTP transport\n */\nexport interface MCPClientConfigHTTP {\n /**\n * Type of MCP client\n */\n type: \"http\";\n /**\n * URL of the MCP server\n */\n url: string;\n /**\n * Optional transport options for HTTP client\n */\n options?: StreamableHTTPClientTransportOptions;\n}\n\n/**\n * MCP Client configuration for SSE transport\n */\nexport interface MCPClientConfigSSE {\n /**\n * Type of MCP client\n */\n type: \"sse\";\n /**\n * URL of the MCP server\n */\n url: string;\n /**\n * Optional HTTP headers (e.g., for authentication)\n */\n headers?: Record<string, string>;\n}\n\n/**\n * MCP Client configuration\n */\nexport type MCPClientConfig = MCPClientConfigHTTP | MCPClientConfigSSE;\n\n/**\n * Resolves a model specifier to a LanguageModel instance\n * @param spec - Model string (e.g., \"openai/gpt-4o\") or LanguageModel instance\n * @param apiKey - Optional API key to use instead of environment variables\n * @returns LanguageModel instance\n */\nexport function resolveModel(spec: ModelSpecifier, apiKey?: string): LanguageModel {\n // If already a LanguageModel instance, pass through\n if (typeof spec !== \"string\") {\n return spec;\n }\n\n // Normalize \"provider/model\" or \"provider:model\" format\n const normalized = spec.replace(\"/\", \":\").trim();\n const parts = normalized.split(\":\");\n const rawProvider = parts[0];\n const rest = parts.slice(1);\n\n if (!rawProvider) {\n throw new Error(\n `Invalid model string \"${spec}\". Use \"openai/gpt-5\", \"anthropic/claude-sonnet-4.5\", or \"google/gemini-2.5-pro\".`,\n );\n }\n\n const provider = rawProvider.toLowerCase();\n const model = rest.join(\":\").trim();\n\n if (!model) {\n throw new Error(\n `Invalid model string \"${spec}\". Use \"openai/gpt-5\", \"anthropic/claude-sonnet-4.5\", or \"google/gemini-2.5-pro\".`,\n );\n }\n\n switch (provider) {\n case \"openai\": {\n // Lazily create OpenAI provider\n // Use provided apiKey, or fall back to environment variable\n const openai = createOpenAI({\n apiKey: apiKey || process.env.OPENAI_API_KEY!,\n });\n // Accepts any OpenAI model id, e.g. \"gpt-4o\", \"gpt-4.1-mini\", \"o3-mini\"\n return openai(model);\n }\n\n case \"anthropic\": {\n // Lazily create Anthropic provider\n // Use provided apiKey, or fall back to environment variable\n const anthropic = createAnthropic({\n apiKey: apiKey || process.env.ANTHROPIC_API_KEY!,\n });\n // Accepts any Claude id, e.g. \"claude-3.7-sonnet\", \"claude-3.5-haiku\"\n return anthropic(model);\n }\n\n case \"google\":\n case \"gemini\":\n case \"google-gemini\": {\n // Lazily create Google provider\n // Use provided apiKey, or fall back to environment variable\n const google = createGoogleGenerativeAI({\n apiKey: apiKey || process.env.GOOGLE_API_KEY!,\n });\n // Accepts any Gemini id, e.g. \"gemini-2.5-pro\", \"gemini-2.5-flash\"\n return google(model);\n }\n\n default:\n throw new Error(`Unknown provider \"${provider}\" in \"${spec}\". Supported: openai, anthropic, google (gemini).`);\n }\n}\n\n/**\n * Tool definition for BuiltInAgent\n */\nexport interface ToolDefinition<TParameters extends z.ZodTypeAny = z.ZodTypeAny> {\n name: string;\n description: string;\n parameters: TParameters;\n execute: (args: z.infer<TParameters>) => Promise<unknown>;\n}\n\n/**\n * Define a tool for use with BuiltInAgent\n * @param name - The name of the tool\n * @param description - Description of what the tool does\n * @param parameters - Zod schema for the tool's input parameters\n * @param execute - Function to execute the tool server-side\n * @returns Tool definition\n */\nexport function defineTool<TParameters extends z.ZodTypeAny>(config: {\n name: string;\n description: string;\n parameters: TParameters;\n execute: (args: z.infer<TParameters>) => Promise<unknown>;\n}): ToolDefinition<TParameters> {\n return {\n name: config.name,\n description: config.description,\n parameters: config.parameters,\n execute: config.execute,\n };\n}\n\ntype AGUIUserMessage = Extract<Message, { role: \"user\" }>;\n\nfunction flattenUserMessageContent(content?: AGUIUserMessage[\"content\"]): string {\n if (!content) {\n return \"\";\n }\n\n if (typeof content === \"string\") {\n return content;\n }\n\n return content\n .map((part) => {\n if (\n part &&\n typeof part === \"object\" &&\n \"type\" in part &&\n (part as { type?: unknown }).type === \"text\" &&\n typeof (part as { text?: unknown }).text === \"string\"\n ) {\n return (part as { text: string }).text;\n }\n return \"\";\n })\n .filter((text) => text.length > 0)\n .join(\"\\n\");\n}\n\n/**\n * Options for converting AG-UI messages to Vercel AI SDK format\n */\nexport interface MessageConversionOptions {\n forwardSystemMessages?: boolean;\n forwardDeveloperMessages?: boolean;\n}\n\n/**\n * Converts AG-UI messages to Vercel AI SDK ModelMessage format\n */\nexport function convertMessagesToVercelAISDKMessages(\n messages: Message[],\n options: MessageConversionOptions = {},\n): ModelMessage[] {\n const result: ModelMessage[] = [];\n\n for (const message of messages) {\n if (message.role === \"system\" && options.forwardSystemMessages) {\n const systemMsg: SystemModelMessage = {\n role: \"system\",\n content: message.content ?? \"\",\n };\n result.push(systemMsg);\n } else if (message.role === \"developer\" && options.forwardDeveloperMessages) {\n const systemMsg: SystemModelMessage = {\n role: \"system\",\n content: message.content ?? \"\",\n };\n result.push(systemMsg);\n } else if (message.role === \"assistant\") {\n const parts: Array<TextPart | ToolCallPart> = message.content ? [{ type: \"text\", text: message.content }] : [];\n\n for (const toolCall of message.toolCalls ?? []) {\n const toolCallPart: ToolCallPart = {\n type: \"tool-call\",\n toolCallId: toolCall.id,\n toolName: toolCall.function.name,\n input: JSON.parse(toolCall.function.arguments),\n };\n parts.push(toolCallPart);\n }\n\n const assistantMsg: AssistantModelMessage = {\n role: \"assistant\",\n content: parts,\n };\n result.push(assistantMsg);\n } else if (message.role === \"user\") {\n const userMsg: UserModelMessage = {\n role: \"user\",\n content: flattenUserMessageContent(message.content),\n };\n result.push(userMsg);\n } else if (message.role === \"tool\") {\n let toolName = \"unknown\";\n // Find the tool name from the corresponding tool call\n for (const msg of messages) {\n if (msg.role === \"assistant\") {\n for (const toolCall of msg.toolCalls ?? []) {\n if (toolCall.id === message.toolCallId) {\n toolName = toolCall.function.name;\n break;\n }\n }\n }\n }\n\n const toolResultPart: ToolResultPart = {\n type: \"tool-result\",\n toolCallId: message.toolCallId,\n toolName: toolName,\n output: {\n type: \"text\",\n value: message.content,\n },\n };\n\n const toolMsg: ToolModelMessage = {\n role: \"tool\",\n content: [toolResultPart],\n };\n result.push(toolMsg);\n }\n }\n\n return result;\n}\n\n/**\n * JSON Schema type definition\n */\ninterface JsonSchema {\n type: \"object\" | \"string\" | \"number\" | \"integer\" | \"boolean\" | \"array\";\n description?: string;\n properties?: Record<string, JsonSchema>;\n required?: string[];\n items?: JsonSchema;\n}\n\n/**\n * Converts JSON Schema to Zod schema\n */\nexport function convertJsonSchemaToZodSchema(jsonSchema: JsonSchema, required: boolean): z.ZodSchema {\n // Handle empty schemas {} (no input required) - treat as empty object\n if (!jsonSchema.type) {\n return required ? z.object({}) : z.object({}).optional();\n }\n if (jsonSchema.type === \"object\") {\n const spec: { [key: string]: z.ZodSchema } = {};\n\n if (!jsonSchema.properties || !Object.keys(jsonSchema.properties).length) {\n return !required ? z.object(spec).optional() : z.object(spec);\n }\n\n for (const [key, value] of Object.entries(jsonSchema.properties)) {\n spec[key] = convertJsonSchemaToZodSchema(value, jsonSchema.required ? jsonSchema.required.includes(key) : false);\n }\n let schema = z.object(spec).describe(jsonSchema.description ?? \"\");\n return required ? schema : schema.optional();\n } else if (jsonSchema.type === \"string\") {\n let schema = z.string().describe(jsonSchema.description ?? \"\");\n return required ? schema : schema.optional();\n } else if (jsonSchema.type === \"number\" || jsonSchema.type === \"integer\") {\n let schema = z.number().describe(jsonSchema.description ?? \"\");\n return required ? schema : schema.optional();\n } else if (jsonSchema.type === \"boolean\") {\n let schema = z.boolean().describe(jsonSchema.description ?? \"\");\n return required ? schema : schema.optional();\n } else if (jsonSchema.type === \"array\") {\n if (!jsonSchema.items) {\n throw new Error(\"Array type must have items property\");\n }\n let itemSchema = convertJsonSchemaToZodSchema(jsonSchema.items, true);\n let schema = z.array(itemSchema).describe(jsonSchema.description ?? \"\");\n return required ? schema : schema.optional();\n }\n console.error(\"Invalid JSON schema:\", JSON.stringify(jsonSchema, null, 2));\n throw new Error(\"Invalid JSON schema\");\n}\n\n/**\n * Converts AG-UI tools to Vercel AI SDK ToolSet\n */\nfunction isJsonSchema(obj: unknown): obj is JsonSchema {\n if (typeof obj !== \"object\" || obj === null) return false;\n const schema = obj as Record<string, unknown>;\n // Empty objects {} are valid JSON schemas (no input required)\n if (Object.keys(schema).length === 0) return true;\n return (\n typeof schema.type === \"string\" &&\n [\"object\", \"string\", \"number\", \"integer\", \"boolean\", \"array\"].includes(schema.type)\n );\n}\n\nexport function convertToolsToVercelAITools(tools: RunAgentInput[\"tools\"]): ToolSet {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const result: Record<string, any> = {};\n\n for (const tool of tools) {\n if (!isJsonSchema(tool.parameters)) {\n throw new Error(`Invalid JSON schema for tool ${tool.name}`);\n }\n const zodSchema = convertJsonSchemaToZodSchema(tool.parameters, true);\n result[tool.name] = createVercelAISDKTool({\n description: tool.description,\n inputSchema: zodSchema,\n });\n }\n\n return result;\n}\n\n/**\n * Converts ToolDefinition array to Vercel AI SDK ToolSet\n */\nexport function convertToolDefinitionsToVercelAITools(tools: ToolDefinition[]): ToolSet {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const result: Record<string, any> = {};\n\n for (const tool of tools) {\n result[tool.name] = createVercelAISDKTool({\n description: tool.description,\n inputSchema: tool.parameters,\n execute: tool.execute,\n });\n }\n\n return result;\n}\n\n/**\n * Configuration for BuiltInAgent\n */\nexport interface BuiltInAgentConfiguration {\n /**\n * The model to use\n */\n model: BuiltInAgentModel | LanguageModel;\n /**\n * API key for the model provider (OpenAI, Anthropic, Google)\n * If not provided, falls back to environment variables:\n * - OPENAI_API_KEY for OpenAI models\n * - ANTHROPIC_API_KEY for Anthropic models\n * - GOOGLE_API_KEY for Google models\n */\n apiKey?: string;\n /**\n * Maximum number of steps/iterations for tool calling (default: 1)\n */\n maxSteps?: number;\n /**\n * Tool choice setting - how tools are selected for execution (default: \"auto\")\n */\n toolChoice?: ToolChoice<Record<string, unknown>>;\n /**\n * Maximum number of tokens to generate\n */\n maxOutputTokens?: number;\n /**\n * Temperature setting (range depends on provider)\n */\n temperature?: number;\n /**\n * Nucleus sampling (topP)\n */\n topP?: number;\n /**\n * Top K sampling\n */\n topK?: number;\n /**\n * Presence penalty\n */\n presencePenalty?: number;\n /**\n * Frequency penalty\n */\n frequencyPenalty?: number;\n /**\n * Sequences that will stop the generation\n */\n stopSequences?: string[];\n /**\n * Seed for deterministic results\n */\n seed?: number;\n /**\n * Maximum number of retries\n */\n maxRetries?: number;\n /**\n * Prompt for the agent\n */\n prompt?: string;\n /**\n * List of properties that can be overridden by forwardedProps.\n */\n overridableProperties?: OverridableProperty[];\n /**\n * Optional list of MCP server configurations\n */\n mcpServers?: MCPClientConfig[];\n /**\n * Optional tools available to the agent\n */\n tools?: ToolDefinition[];\n /**\n * Forward system-role messages from input to the LLM.\n * Default: false\n */\n forwardSystemMessages?: boolean;\n /**\n * Forward developer-role messages from input to the LLM (as system messages).\n * Default: false\n */\n forwardDeveloperMessages?: boolean;\n}\n\nexport class BuiltInAgent extends AbstractAgent {\n private abortController?: AbortController;\n\n constructor(private config: BuiltInAgentConfiguration) {\n super();\n }\n\n /**\n * Check if a property can be overridden by forwardedProps\n */\n canOverride(property: OverridableProperty): boolean {\n return this.config?.overridableProperties?.includes(property) ?? false;\n }\n\n run(input: RunAgentInput): Observable<BaseEvent> {\n return new Observable<BaseEvent>((subscriber) => {\n // Emit RUN_STARTED event\n const startEvent: RunStartedEvent = {\n type: EventType.RUN_STARTED,\n threadId: input.threadId,\n runId: input.runId,\n };\n subscriber.next(startEvent);\n\n // Resolve the model, passing API key if provided\n const model = resolveModel(this.config.model, this.config.apiKey);\n\n // Build prompt based on conditions\n let systemPrompt: string | undefined = undefined;\n\n // Check if we should build a prompt:\n // - config.prompt is set, OR\n // - input.context is non-empty, OR\n // - input.state is non-empty and not an empty object\n const hasPrompt = !!this.config.prompt;\n const hasContext = input.context && input.context.length > 0;\n const hasState =\n input.state !== undefined &&\n input.state !== null &&\n !(typeof input.state === \"object\" && Object.keys(input.state).length === 0);\n\n if (hasPrompt || hasContext || hasState) {\n const parts: string[] = [];\n\n // First: the prompt if any\n if (hasPrompt) {\n parts.push(this.config.prompt!);\n }\n\n // Second: context from the application\n if (hasContext) {\n parts.push(\"\\n## Context from the application\\n\");\n for (const ctx of input.context) {\n parts.push(`${ctx.description}:\\n${ctx.value}\\n`);\n }\n }\n\n // Third: state from the application that can be edited\n if (hasState) {\n parts.push(\n \"\\n## Application State\\n\" +\n \"This is state from the application that you can edit by calling AGUISendStateSnapshot or AGUISendStateDelta.\\n\" +\n `\\`\\`\\`json\\n${JSON.stringify(input.state, null, 2)}\\n\\`\\`\\`\\n`,\n );\n }\n\n systemPrompt = parts.join(\"\");\n }\n\n // Convert messages and prepend system message if we have a prompt\n const messages = convertMessagesToVercelAISDKMessages(input.messages, {\n forwardSystemMessages: this.config.forwardSystemMessages,\n forwardDeveloperMessages: this.config.forwardDeveloperMessages,\n });\n if (systemPrompt) {\n messages.unshift({\n role: \"system\",\n content: systemPrompt,\n });\n }\n\n // Merge tools from input and config\n let allTools: ToolSet = convertToolsToVercelAITools(input.tools);\n if (this.config.tools && this.config.tools.length > 0) {\n const configTools = convertToolDefinitionsToVercelAITools(this.config.tools);\n allTools = { ...allTools, ...configTools };\n }\n\n const streamTextParams: Parameters<typeof streamText>[0] = {\n model,\n messages,\n tools: allTools,\n toolChoice: this.config.toolChoice,\n stopWhen: this.config.maxSteps ? stepCountIs(this.config.maxSteps) : undefined,\n maxOutputTokens: this.config.maxOutputTokens,\n temperature: this.config.temperature,\n topP: this.config.topP,\n topK: this.config.topK,\n presencePenalty: this.config.presencePenalty,\n frequencyPenalty: this.config.frequencyPenalty,\n stopSequences: this.config.stopSequences,\n seed: this.config.seed,\n maxRetries: this.config.maxRetries,\n };\n\n // Apply forwardedProps overrides (if allowed)\n if (input.forwardedProps && typeof input.forwardedProps === \"object\") {\n const props = input.forwardedProps as Record<string, unknown>;\n\n // Check and apply each overridable property\n if (props.model !== undefined && this.canOverride(\"model\")) {\n if (typeof props.model === \"string\" || typeof props.model === \"object\") {\n // Accept any string or LanguageModel instance for model override\n // Use the configured API key when resolving overridden models\n streamTextParams.model = resolveModel(props.model as string | LanguageModel, this.config.apiKey);\n }\n }\n if (props.toolChoice !== undefined && this.canOverride(\"toolChoice\")) {\n // ToolChoice can be 'auto', 'required', 'none', or { type: 'tool', toolName: string }\n const toolChoice = props.toolChoice;\n if (\n toolChoice === \"auto\" ||\n toolChoice === \"required\" ||\n toolChoice === \"none\" ||\n (typeof toolChoice === \"object\" &&\n toolChoice !== null &&\n \"type\" in toolChoice &&\n toolChoice.type === \"tool\")\n ) {\n streamTextParams.toolChoice = toolChoice as ToolChoice<Record<string, unknown>>;\n }\n }\n if (typeof props.maxOutputTokens === \"number\" && this.canOverride(\"maxOutputTokens\")) {\n streamTextParams.maxOutputTokens = props.maxOutputTokens;\n }\n if (typeof props.temperature === \"number\" && this.canOverride(\"temperature\")) {\n streamTextParams.temperature = props.temperature;\n }\n if (typeof props.topP === \"number\" && this.canOverride(\"topP\")) {\n streamTextParams.topP = props.topP;\n }\n if (typeof props.topK === \"number\" && this.canOverride(\"topK\")) {\n streamTextParams.topK = props.topK;\n }\n if (typeof props.presencePenalty === \"number\" && this.canOverride(\"presencePenalty\")) {\n streamTextParams.presencePenalty = props.presencePenalty;\n }\n if (typeof props.frequencyPenalty === \"number\" && this.canOverride(\"frequencyPenalty\")) {\n streamTextParams.frequencyPenalty = props.frequencyPenalty;\n }\n if (Array.isArray(props.stopSequences) && this.canOverride(\"stopSequences\")) {\n // Validate all elements are strings\n if (props.stopSequences.every((item): item is string => typeof item === \"string\")) {\n streamTextParams.stopSequences = props.stopSequences;\n }\n }\n if (typeof props.seed === \"number\" && this.canOverride(\"seed\")) {\n streamTextParams.seed = props.seed;\n }\n if (typeof props.maxRetries === \"number\" && this.canOverride(\"maxRetries\")) {\n streamTextParams.maxRetries = props.maxRetries;\n }\n }\n\n // Set up MCP clients if configured and process the stream\n const mcpClients: Array<{ close: () => Promise<void> }> = [];\n\n (async () => {\n const abortController = new AbortController();\n this.abortController = abortController;\n let terminalEventEmitted = false;\n\n try {\n // Add AG-UI state update tools\n streamTextParams.tools = {\n ...streamTextParams.tools,\n AGUISendStateSnapshot: createVercelAISDKTool({\n description: \"Replace the entire application state with a new snapshot\",\n inputSchema: z.object({\n snapshot: z.any().describe(\"The complete new state object\"),\n }),\n execute: async ({ snapshot }) => {\n return { success: true, snapshot };\n },\n }),\n AGUISendStateDelta: createVercelAISDKTool({\n description: \"Apply incremental updates to application state using JSON Patch operations\",\n inputSchema: z.object({\n delta: z\n .array(\n z.object({\n op: z.enum([\"add\", \"replace\", \"remove\"]).describe(\"The operation to perform\"),\n path: z.string().describe(\"JSON Pointer path (e.g., '/foo/bar')\"),\n value: z\n .any()\n .optional()\n .describe(\n \"The value to set. Required for 'add' and 'replace' operations, ignored for 'remove'.\",\n ),\n }),\n )\n .describe(\"Array of JSON Patch operations\"),\n }),\n execute: async ({ delta }) => {\n return { success: true, delta };\n },\n }),\n };\n\n // Initialize MCP clients and get their tools\n if (this.config.mcpServers && this.config.mcpServers.length > 0) {\n for (const serverConfig of this.config.mcpServers) {\n let transport;\n\n if (serverConfig.type === \"http\") {\n const url = new URL(serverConfig.url);\n transport = new StreamableHTTPClientTransport(url, serverConfig.options);\n } else if (serverConfig.type === \"sse\") {\n transport = new SSEClientTransport(new URL(serverConfig.url), serverConfig.headers);\n }\n\n if (transport) {\n const mcpClient = await createMCPClient({ transport });\n mcpClients.push(mcpClient);\n\n // Get tools from this MCP server and merge with existing tools\n const mcpTools = await mcpClient.tools();\n streamTextParams.tools = { ...streamTextParams.tools, ...mcpTools } as ToolSet;\n }\n }\n }\n\n // Call streamText and process the stream\n const response = streamText({ ...streamTextParams, abortSignal: abortController.signal });\n\n let messageId = randomUUID();\n\n const toolCallStates = new Map<\n string,\n {\n started: boolean;\n hasArgsDelta: boolean;\n ended: boolean;\n toolName?: string;\n }\n >();\n\n const ensureToolCallState = (toolCallId: string) => {\n let state = toolCallStates.get(toolCallId);\n if (!state) {\n state = { started: false, hasArgsDelta: false, ended: false };\n toolCallStates.set(toolCallId, state);\n }\n return state;\n };\n\n // Process fullStream events\n for await (const part of response.fullStream) {\n switch (part.type) {\n case \"abort\":\n const abortEndEvent: RunFinishedEvent = {\n type: EventType.RUN_FINISHED,\n threadId: input.threadId,\n runId: input.runId,\n };\n subscriber.next(abortEndEvent);\n terminalEventEmitted = true;\n\n // Complete the observable\n subscriber.complete();\n break;\n\n case \"tool-input-start\": {\n const toolCallId = part.id;\n const state = ensureToolCallState(toolCallId);\n state.toolName = part.toolName;\n if (!state.started) {\n state.started = true;\n const startEvent: ToolCallStartEvent = {\n type: EventType.TOOL_CALL_START,\n parentMessageId: messageId,\n toolCallId,\n toolCallName: part.toolName,\n };\n subscriber.next(startEvent);\n }\n break;\n }\n\n case \"tool-input-delta\": {\n const toolCallId = part.id;\n const state = ensureToolCallState(toolCallId);\n state.hasArgsDelta = true;\n const argsEvent: ToolCallArgsEvent = {\n type: EventType.TOOL_CALL_ARGS,\n toolCallId,\n delta: part.delta,\n };\n subscriber.next(argsEvent);\n break;\n }\n\n case \"tool-input-end\": {\n // No direct event – the subsequent \"tool-call\" part marks completion.\n break;\n }\n\n case \"text-start\": {\n // New text message starting - use the SDK-provided id\n // Use randomUUID() if part.id is falsy or \"0\" to prevent message merging issues\n const providedId = \"id\" in part ? part.id : undefined;\n messageId = providedId && providedId !== \"0\" ? (providedId as typeof messageId) : randomUUID();\n break;\n }\n\n case \"text-delta\": {\n // Accumulate text content - in AI SDK 5.0, the property is 'text'\n const textDelta = \"text\" in part ? part.text : \"\";\n // Emit text chunk event\n const textEvent: TextMessageChunkEvent = {\n type: EventType.TEXT_MESSAGE_CHUNK,\n role: \"assistant\",\n messageId,\n delta: textDelta,\n };\n subscriber.next(textEvent);\n break;\n }\n\n case \"tool-call\": {\n const toolCallId = part.toolCallId;\n const state = ensureToolCallState(toolCallId);\n state.toolName = part.toolName ?? state.toolName;\n\n if (!state.started) {\n state.started = true;\n const startEvent: ToolCallStartEvent = {\n type: EventType.TOOL_CALL_START,\n parentMessageId: messageId,\n toolCallId,\n toolCallName: part.toolName,\n };\n subscriber.next(startEvent);\n }\n\n if (!state.hasArgsDelta && \"input\" in part && part.input !== undefined) {\n let serializedInput = \"\";\n if (typeof part.input === \"string\") {\n serializedInput = part.input;\n } else {\n try {\n serializedInput = JSON.stringify(part.input);\n } catch {\n serializedInput = String(part.input);\n }\n }\n\n if (serializedInput.length > 0) {\n const argsEvent: ToolCallArgsEvent = {\n type: EventType.TOOL_CALL_ARGS,\n toolCallId,\n delta: serializedInput,\n };\n subscriber.next(argsEvent);\n state.hasArgsDelta = true;\n }\n }\n\n if (!state.ended) {\n state.ended = true;\n const endEvent: ToolCallEndEvent = {\n type: EventType.TOOL_CALL_END,\n toolCallId,\n };\n subscriber.next(endEvent);\n }\n break;\n }\n\n case \"tool-result\": {\n const toolResult = \"output\" in part ? part.output : null;\n const toolName = \"toolName\" in part ? part.toolName : \"\";\n toolCallStates.delete(part.toolCallId);\n\n // Check if this is a state update tool\n if (toolName === \"AGUISendStateSnapshot\" && toolResult && typeof toolResult === \"object\") {\n // Emit StateSnapshotEvent\n const stateSnapshotEvent: StateSnapshotEvent = {\n type: EventType.STATE_SNAPSHOT,\n snapshot: toolResult.snapshot,\n };\n subscriber.next(stateSnapshotEvent);\n } else if (toolName === \"AGUISendStateDelta\" && toolResult && typeof toolResult === \"object\") {\n // Emit StateDeltaEvent\n const stateDeltaEvent: StateDeltaEvent = {\n type: EventType.STATE_DELTA,\n delta: toolResult.delta,\n };\n subscriber.next(stateDeltaEvent);\n }\n\n // Always emit the tool result event for the LLM\n const resultEvent: ToolCallResultEvent = {\n type: EventType.TOOL_CALL_RESULT,\n role: \"tool\",\n messageId: randomUUID(),\n toolCallId: part.toolCallId,\n content: JSON.stringify(toolResult),\n };\n subscriber.next(resultEvent);\n break;\n }\n\n case \"finish\":\n // Emit run finished event\n const finishedEvent: RunFinishedEvent = {\n type: EventType.RUN_FINISHED,\n threadId: input.threadId,\n runId: input.runId,\n };\n subscriber.next(finishedEvent);\n terminalEventEmitted = true;\n\n // Complete the observable\n subscriber.complete();\n break;\n\n case \"error\": {\n if (abortController.signal.aborted) {\n break;\n }\n const runErrorEvent: RunErrorEvent = {\n type: EventType.RUN_ERROR,\n message: part.error + \"\",\n };\n subscriber.next(runErrorEvent);\n terminalEventEmitted = true;\n\n // Handle error\n subscriber.error(part.error);\n break;\n }\n }\n }\n\n if (!terminalEventEmitted) {\n if (abortController.signal.aborted) {\n // Let the runner finalize the stream on stop requests so it can\n // inject consistent closing events and a RUN_FINISHED marker.\n } else {\n const finishedEvent: RunFinishedEvent = {\n type: EventType.RUN_FINISHED,\n threadId: input.threadId,\n runId: input.runId,\n };\n subscriber.next(finishedEvent);\n }\n\n terminalEventEmitted = true;\n subscriber.complete();\n }\n } catch (error) {\n if (abortController.signal.aborted) {\n subscriber.complete();\n } else {\n const runErrorEvent: RunErrorEvent = {\n type: EventType.RUN_ERROR,\n message: error + \"\",\n };\n subscriber.next(runErrorEvent);\n terminalEventEmitted = true;\n subscriber.error(error);\n }\n } finally {\n this.abortController = undefined;\n await Promise.all(mcpClients.map((client) => client.close()));\n }\n })();\n\n // Cleanup function\n return () => {\n // Cleanup MCP clients if stream is unsubscribed\n Promise.all(mcpClients.map((client) => client.close())).catch(() => {\n // Ignore cleanup errors\n });\n };\n });\n }\n\n clone() {\n const cloned = new BuiltInAgent(this.config);\n // Copy middlewares from parent class\n // @ts-expect-error - accessing protected property from parent\n cloned.middlewares = [...this.middlewares];\n return cloned;\n }\n\n abortRun(): void {\n this.abortController?.abort();\n }\n}\n\n/**\n * @deprecated Use BuiltInAgent instead\n */\nexport class BasicAgent extends BuiltInAgent {\n constructor(config: BuiltInAgentConfiguration) {\n super(config);\n console.warn(\"BasicAgent is deprecated, use BuiltInAgent instead\");\n }\n}\n\nexport type BasicAgentConfiguration = BuiltInAgentConfiguration;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAgBO;AACP,gBAeO;AACP,iBAAgE;AAChE,kBAA2B;AAC3B,oBAA6B;AAC7B,uBAAgC;AAChC,oBAAyC;AACzC,oBAA2B;AAC3B,iBAAkB;AAClB,4BAGO;AACP,iBAAmC;AAsG5B,SAAS,aAAa,MAAsB,QAAgC;AAEjF,MAAI,OAAO,SAAS,UAAU;AAC5B,WAAO;AAAA,EACT;AAGA,QAAM,aAAa,KAAK,QAAQ,KAAK,GAAG,EAAE,KAAK;AAC/C,QAAM,QAAQ,WAAW,MAAM,GAAG;AAClC,QAAM,cAAc,MAAM,CAAC;AAC3B,QAAM,OAAO,MAAM,MAAM,CAAC;AAE1B,MAAI,CAAC,aAAa;AAChB,UAAM,IAAI;AAAA,MACR,yBAAyB,IAAI;AAAA,IAC/B;AAAA,EACF;AAEA,QAAM,WAAW,YAAY,YAAY;AACzC,QAAM,QAAQ,KAAK,KAAK,GAAG,EAAE,KAAK;AAElC,MAAI,CAAC,OAAO;AACV,UAAM,IAAI;AAAA,MACR,yBAAyB,IAAI;AAAA,IAC/B;AAAA,EACF;AAEA,UAAQ,UAAU;AAAA,IAChB,KAAK,UAAU;AAGb,YAAM,aAAS,4BAAa;AAAA,QAC1B,QAAQ,UAAU,QAAQ,IAAI;AAAA,MAChC,CAAC;AAED,aAAO,OAAO,KA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