@copilotkitnext/agent 1.51.5-next.0 → 1.51.5-next.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1,701 +1,603 @@
1
- // src/index.ts
2
- import {
3
- AbstractAgent,
4
- EventType
5
- } from "@ag-ui/client";
6
- import {
7
- streamText,
8
- tool as createVercelAISDKTool,
9
- stepCountIs
10
- } from "ai";
11
- import { experimental_createMCPClient as createMCPClient } from "@ai-sdk/mcp";
1
+ import { AbstractAgent, EventType } from "@ag-ui/client";
2
+ import { stepCountIs, streamText, tool } from "ai";
3
+ import { experimental_createMCPClient } from "@ai-sdk/mcp";
12
4
  import { Observable } from "rxjs";
13
5
  import { createOpenAI } from "@ai-sdk/openai";
14
6
  import { createAnthropic } from "@ai-sdk/anthropic";
15
7
  import { createGoogleGenerativeAI } from "@ai-sdk/google";
16
8
  import { randomUUID } from "crypto";
17
9
  import { z } from "zod";
18
- import {
19
- StreamableHTTPClientTransport
20
- } from "@modelcontextprotocol/sdk/client/streamableHttp.js";
10
+ import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js";
21
11
  import { SSEClientTransport } from "@modelcontextprotocol/sdk/client/sse.js";
12
+
13
+ //#region src/index.ts
14
+ /**
15
+ * Resolves a model specifier to a LanguageModel instance
16
+ * @param spec - Model string (e.g., "openai/gpt-4o") or LanguageModel instance
17
+ * @param apiKey - Optional API key to use instead of environment variables
18
+ * @returns LanguageModel instance
19
+ */
22
20
  function resolveModel(spec, apiKey) {
23
- if (typeof spec !== "string") {
24
- return spec;
25
- }
26
- const normalized = spec.replace("/", ":").trim();
27
- const parts = normalized.split(":");
28
- const rawProvider = parts[0];
29
- const rest = parts.slice(1);
30
- if (!rawProvider) {
31
- throw new Error(
32
- `Invalid model string "${spec}". Use "openai/gpt-5", "anthropic/claude-sonnet-4.5", or "google/gemini-2.5-pro".`
33
- );
34
- }
35
- const provider = rawProvider.toLowerCase();
36
- const model = rest.join(":").trim();
37
- if (!model) {
38
- throw new Error(
39
- `Invalid model string "${spec}". Use "openai/gpt-5", "anthropic/claude-sonnet-4.5", or "google/gemini-2.5-pro".`
40
- );
41
- }
42
- switch (provider) {
43
- case "openai": {
44
- const openai = createOpenAI({
45
- apiKey: apiKey || process.env.OPENAI_API_KEY
46
- });
47
- return openai(model);
48
- }
49
- case "anthropic": {
50
- const anthropic = createAnthropic({
51
- apiKey: apiKey || process.env.ANTHROPIC_API_KEY
52
- });
53
- return anthropic(model);
54
- }
55
- case "google":
56
- case "gemini":
57
- case "google-gemini": {
58
- const google = createGoogleGenerativeAI({
59
- apiKey: apiKey || process.env.GOOGLE_API_KEY
60
- });
61
- return google(model);
62
- }
63
- default:
64
- throw new Error(
65
- `Unknown provider "${provider}" in "${spec}". Supported: openai, anthropic, google (gemini).`
66
- );
67
- }
21
+ if (typeof spec !== "string") return spec;
22
+ const parts = spec.replace("/", ":").trim().split(":");
23
+ const rawProvider = parts[0];
24
+ const rest = parts.slice(1);
25
+ if (!rawProvider) throw new Error(`Invalid model string "${spec}". Use "openai/gpt-5", "anthropic/claude-sonnet-4.5", or "google/gemini-2.5-pro".`);
26
+ const provider = rawProvider.toLowerCase();
27
+ const model = rest.join(":").trim();
28
+ if (!model) throw new Error(`Invalid model string "${spec}". Use "openai/gpt-5", "anthropic/claude-sonnet-4.5", or "google/gemini-2.5-pro".`);
29
+ switch (provider) {
30
+ case "openai": return createOpenAI({ apiKey: apiKey || process.env.OPENAI_API_KEY })(model);
31
+ case "anthropic": return createAnthropic({ apiKey: apiKey || process.env.ANTHROPIC_API_KEY })(model);
32
+ case "google":
33
+ case "gemini":
34
+ case "google-gemini": return createGoogleGenerativeAI({ apiKey: apiKey || process.env.GOOGLE_API_KEY })(model);
35
+ default: throw new Error(`Unknown provider "${provider}" in "${spec}". Supported: openai, anthropic, google (gemini).`);
36
+ }
68
37
  }
38
+ /**
39
+ * Define a tool for use with BuiltInAgent
40
+ * @param name - The name of the tool
41
+ * @param description - Description of what the tool does
42
+ * @param parameters - Zod schema for the tool's input parameters
43
+ * @param execute - Function to execute the tool server-side
44
+ * @returns Tool definition
45
+ */
69
46
  function defineTool(config) {
70
- return {
71
- name: config.name,
72
- description: config.description,
73
- parameters: config.parameters,
74
- execute: config.execute
75
- };
47
+ return {
48
+ name: config.name,
49
+ description: config.description,
50
+ parameters: config.parameters,
51
+ execute: config.execute
52
+ };
76
53
  }
77
54
  function flattenUserMessageContent(content) {
78
- if (!content) {
79
- return "";
80
- }
81
- if (typeof content === "string") {
82
- return content;
83
- }
84
- return content.map((part) => {
85
- if (part && typeof part === "object" && "type" in part && part.type === "text" && typeof part.text === "string") {
86
- return part.text;
87
- }
88
- return "";
89
- }).filter((text) => text.length > 0).join("\n");
55
+ if (!content) return "";
56
+ if (typeof content === "string") return content;
57
+ return content.map((part) => {
58
+ if (part && typeof part === "object" && "type" in part && part.type === "text" && typeof part.text === "string") return part.text;
59
+ return "";
60
+ }).filter((text) => text.length > 0).join("\n");
90
61
  }
62
+ /**
63
+ * Converts AG-UI messages to Vercel AI SDK ModelMessage format
64
+ */
91
65
  function convertMessagesToVercelAISDKMessages(messages, options = {}) {
92
- const result = [];
93
- for (const message of messages) {
94
- if (message.role === "system" && options.forwardSystemMessages) {
95
- const systemMsg = {
96
- role: "system",
97
- content: message.content ?? ""
98
- };
99
- result.push(systemMsg);
100
- } else if (message.role === "developer" && options.forwardDeveloperMessages) {
101
- const systemMsg = {
102
- role: "system",
103
- content: message.content ?? ""
104
- };
105
- result.push(systemMsg);
106
- } else if (message.role === "assistant") {
107
- const parts = message.content ? [{ type: "text", text: message.content }] : [];
108
- for (const toolCall of message.toolCalls ?? []) {
109
- const toolCallPart = {
110
- type: "tool-call",
111
- toolCallId: toolCall.id,
112
- toolName: toolCall.function.name,
113
- input: JSON.parse(toolCall.function.arguments)
114
- };
115
- parts.push(toolCallPart);
116
- }
117
- const assistantMsg = {
118
- role: "assistant",
119
- content: parts
120
- };
121
- result.push(assistantMsg);
122
- } else if (message.role === "user") {
123
- const userMsg = {
124
- role: "user",
125
- content: flattenUserMessageContent(message.content)
126
- };
127
- result.push(userMsg);
128
- } else if (message.role === "tool") {
129
- let toolName = "unknown";
130
- for (const msg of messages) {
131
- if (msg.role === "assistant") {
132
- for (const toolCall of msg.toolCalls ?? []) {
133
- if (toolCall.id === message.toolCallId) {
134
- toolName = toolCall.function.name;
135
- break;
136
- }
137
- }
138
- }
139
- }
140
- const toolResultPart = {
141
- type: "tool-result",
142
- toolCallId: message.toolCallId,
143
- toolName,
144
- output: {
145
- type: "text",
146
- value: message.content
147
- }
148
- };
149
- const toolMsg = {
150
- role: "tool",
151
- content: [toolResultPart]
152
- };
153
- result.push(toolMsg);
154
- }
155
- }
156
- return result;
66
+ const result = [];
67
+ for (const message of messages) if (message.role === "system" && options.forwardSystemMessages) {
68
+ const systemMsg = {
69
+ role: "system",
70
+ content: message.content ?? ""
71
+ };
72
+ result.push(systemMsg);
73
+ } else if (message.role === "developer" && options.forwardDeveloperMessages) {
74
+ const systemMsg = {
75
+ role: "system",
76
+ content: message.content ?? ""
77
+ };
78
+ result.push(systemMsg);
79
+ } else if (message.role === "assistant") {
80
+ const parts = message.content ? [{
81
+ type: "text",
82
+ text: message.content
83
+ }] : [];
84
+ for (const toolCall of message.toolCalls ?? []) {
85
+ const toolCallPart = {
86
+ type: "tool-call",
87
+ toolCallId: toolCall.id,
88
+ toolName: toolCall.function.name,
89
+ input: JSON.parse(toolCall.function.arguments)
90
+ };
91
+ parts.push(toolCallPart);
92
+ }
93
+ const assistantMsg = {
94
+ role: "assistant",
95
+ content: parts
96
+ };
97
+ result.push(assistantMsg);
98
+ } else if (message.role === "user") {
99
+ const userMsg = {
100
+ role: "user",
101
+ content: flattenUserMessageContent(message.content)
102
+ };
103
+ result.push(userMsg);
104
+ } else if (message.role === "tool") {
105
+ let toolName = "unknown";
106
+ for (const msg of messages) if (msg.role === "assistant") {
107
+ for (const toolCall of msg.toolCalls ?? []) if (toolCall.id === message.toolCallId) {
108
+ toolName = toolCall.function.name;
109
+ break;
110
+ }
111
+ }
112
+ const toolMsg = {
113
+ role: "tool",
114
+ content: [{
115
+ type: "tool-result",
116
+ toolCallId: message.toolCallId,
117
+ toolName,
118
+ output: {
119
+ type: "text",
120
+ value: message.content
121
+ }
122
+ }]
123
+ };
124
+ result.push(toolMsg);
125
+ }
126
+ return result;
157
127
  }
128
+ /**
129
+ * Converts JSON Schema to Zod schema
130
+ */
158
131
  function convertJsonSchemaToZodSchema(jsonSchema, required) {
159
- if (!jsonSchema.type) {
160
- return required ? z.object({}) : z.object({}).optional();
161
- }
162
- if (jsonSchema.type === "object") {
163
- const spec = {};
164
- if (!jsonSchema.properties || !Object.keys(jsonSchema.properties).length) {
165
- return !required ? z.object(spec).optional() : z.object(spec);
166
- }
167
- for (const [key, value] of Object.entries(jsonSchema.properties)) {
168
- spec[key] = convertJsonSchemaToZodSchema(
169
- value,
170
- jsonSchema.required ? jsonSchema.required.includes(key) : false
171
- );
172
- }
173
- let schema = z.object(spec).describe(jsonSchema.description ?? "");
174
- return required ? schema : schema.optional();
175
- } else if (jsonSchema.type === "string") {
176
- let schema = z.string().describe(jsonSchema.description ?? "");
177
- return required ? schema : schema.optional();
178
- } else if (jsonSchema.type === "number" || jsonSchema.type === "integer") {
179
- let schema = z.number().describe(jsonSchema.description ?? "");
180
- return required ? schema : schema.optional();
181
- } else if (jsonSchema.type === "boolean") {
182
- let schema = z.boolean().describe(jsonSchema.description ?? "");
183
- return required ? schema : schema.optional();
184
- } else if (jsonSchema.type === "array") {
185
- if (!jsonSchema.items) {
186
- throw new Error("Array type must have items property");
187
- }
188
- let itemSchema = convertJsonSchemaToZodSchema(jsonSchema.items, true);
189
- let schema = z.array(itemSchema).describe(jsonSchema.description ?? "");
190
- return required ? schema : schema.optional();
191
- }
192
- console.error("Invalid JSON schema:", JSON.stringify(jsonSchema, null, 2));
193
- throw new Error("Invalid JSON schema");
132
+ if (!jsonSchema.type) return required ? z.object({}) : z.object({}).optional();
133
+ if (jsonSchema.type === "object") {
134
+ const spec = {};
135
+ if (!jsonSchema.properties || !Object.keys(jsonSchema.properties).length) return !required ? z.object(spec).optional() : z.object(spec);
136
+ for (const [key, value] of Object.entries(jsonSchema.properties)) spec[key] = convertJsonSchemaToZodSchema(value, jsonSchema.required ? jsonSchema.required.includes(key) : false);
137
+ let schema = z.object(spec).describe(jsonSchema.description ?? "");
138
+ return required ? schema : schema.optional();
139
+ } else if (jsonSchema.type === "string") {
140
+ let schema = z.string().describe(jsonSchema.description ?? "");
141
+ return required ? schema : schema.optional();
142
+ } else if (jsonSchema.type === "number" || jsonSchema.type === "integer") {
143
+ let schema = z.number().describe(jsonSchema.description ?? "");
144
+ return required ? schema : schema.optional();
145
+ } else if (jsonSchema.type === "boolean") {
146
+ let schema = z.boolean().describe(jsonSchema.description ?? "");
147
+ return required ? schema : schema.optional();
148
+ } else if (jsonSchema.type === "array") {
149
+ if (!jsonSchema.items) throw new Error("Array type must have items property");
150
+ let itemSchema = convertJsonSchemaToZodSchema(jsonSchema.items, true);
151
+ let schema = z.array(itemSchema).describe(jsonSchema.description ?? "");
152
+ return required ? schema : schema.optional();
153
+ }
154
+ console.error("Invalid JSON schema:", JSON.stringify(jsonSchema, null, 2));
155
+ throw new Error("Invalid JSON schema");
194
156
  }
157
+ /**
158
+ * Converts AG-UI tools to Vercel AI SDK ToolSet
159
+ */
195
160
  function isJsonSchema(obj) {
196
- if (typeof obj !== "object" || obj === null) return false;
197
- const schema = obj;
198
- if (Object.keys(schema).length === 0) return true;
199
- return typeof schema.type === "string" && ["object", "string", "number", "integer", "boolean", "array"].includes(
200
- schema.type
201
- );
161
+ if (typeof obj !== "object" || obj === null) return false;
162
+ const schema = obj;
163
+ if (Object.keys(schema).length === 0) return true;
164
+ return typeof schema.type === "string" && [
165
+ "object",
166
+ "string",
167
+ "number",
168
+ "integer",
169
+ "boolean",
170
+ "array"
171
+ ].includes(schema.type);
202
172
  }
203
173
  function convertToolsToVercelAITools(tools) {
204
- const result = {};
205
- for (const tool of tools) {
206
- if (!isJsonSchema(tool.parameters)) {
207
- throw new Error(`Invalid JSON schema for tool ${tool.name}`);
208
- }
209
- const zodSchema = convertJsonSchemaToZodSchema(tool.parameters, true);
210
- result[tool.name] = createVercelAISDKTool({
211
- description: tool.description,
212
- inputSchema: zodSchema
213
- });
214
- }
215
- return result;
174
+ const result = {};
175
+ for (const tool$1 of tools) {
176
+ if (!isJsonSchema(tool$1.parameters)) throw new Error(`Invalid JSON schema for tool ${tool$1.name}`);
177
+ const zodSchema = convertJsonSchemaToZodSchema(tool$1.parameters, true);
178
+ result[tool$1.name] = tool({
179
+ description: tool$1.description,
180
+ inputSchema: zodSchema
181
+ });
182
+ }
183
+ return result;
216
184
  }
185
+ /**
186
+ * Converts ToolDefinition array to Vercel AI SDK ToolSet
187
+ */
217
188
  function convertToolDefinitionsToVercelAITools(tools) {
218
- const result = {};
219
- for (const tool of tools) {
220
- result[tool.name] = createVercelAISDKTool({
221
- description: tool.description,
222
- inputSchema: tool.parameters,
223
- execute: tool.execute
224
- });
225
- }
226
- return result;
189
+ const result = {};
190
+ for (const tool$2 of tools) result[tool$2.name] = tool({
191
+ description: tool$2.description,
192
+ inputSchema: tool$2.parameters,
193
+ execute: tool$2.execute
194
+ });
195
+ return result;
227
196
  }
228
- var BuiltInAgent = class _BuiltInAgent extends AbstractAgent {
229
- constructor(config) {
230
- super();
231
- this.config = config;
232
- }
233
- abortController;
234
- /**
235
- * Check if a property can be overridden by forwardedProps
236
- */
237
- canOverride(property) {
238
- return this.config?.overridableProperties?.includes(property) ?? false;
239
- }
240
- run(input) {
241
- return new Observable((subscriber) => {
242
- const startEvent = {
243
- type: EventType.RUN_STARTED,
244
- threadId: input.threadId,
245
- runId: input.runId
246
- };
247
- subscriber.next(startEvent);
248
- const model = resolveModel(this.config.model, this.config.apiKey);
249
- let systemPrompt = void 0;
250
- const hasPrompt = !!this.config.prompt;
251
- const hasContext = input.context && input.context.length > 0;
252
- const hasState = input.state !== void 0 && input.state !== null && !(typeof input.state === "object" && Object.keys(input.state).length === 0);
253
- if (hasPrompt || hasContext || hasState) {
254
- const parts = [];
255
- if (hasPrompt) {
256
- parts.push(this.config.prompt);
257
- }
258
- if (hasContext) {
259
- parts.push("\n## Context from the application\n");
260
- for (const ctx of input.context) {
261
- parts.push(`${ctx.description}:
262
- ${ctx.value}
263
- `);
264
- }
265
- }
266
- if (hasState) {
267
- parts.push(
268
- `
197
+ var BuiltInAgent = class BuiltInAgent extends AbstractAgent {
198
+ abortController;
199
+ constructor(config) {
200
+ super();
201
+ this.config = config;
202
+ }
203
+ /**
204
+ * Check if a property can be overridden by forwardedProps
205
+ */
206
+ canOverride(property) {
207
+ return this.config?.overridableProperties?.includes(property) ?? false;
208
+ }
209
+ run(input) {
210
+ return new Observable((subscriber) => {
211
+ const startEvent = {
212
+ type: EventType.RUN_STARTED,
213
+ threadId: input.threadId,
214
+ runId: input.runId
215
+ };
216
+ subscriber.next(startEvent);
217
+ const model = resolveModel(this.config.model, this.config.apiKey);
218
+ let systemPrompt = void 0;
219
+ const hasPrompt = !!this.config.prompt;
220
+ const hasContext = input.context && input.context.length > 0;
221
+ const hasState = input.state !== void 0 && input.state !== null && !(typeof input.state === "object" && Object.keys(input.state).length === 0);
222
+ if (hasPrompt || hasContext || hasState) {
223
+ const parts = [];
224
+ if (hasPrompt) parts.push(this.config.prompt);
225
+ if (hasContext) {
226
+ parts.push("\n## Context from the application\n");
227
+ for (const ctx of input.context) parts.push(`${ctx.description}:\n${ctx.value}\n`);
228
+ }
229
+ if (hasState) parts.push(`
269
230
  ## Application State
270
231
  This is state from the application that you can edit by calling AGUISendStateSnapshot or AGUISendStateDelta.
271
- \`\`\`json
272
- ${JSON.stringify(input.state, null, 2)}
273
- \`\`\`
274
- `
275
- );
276
- }
277
- systemPrompt = parts.join("");
278
- }
279
- const messages = convertMessagesToVercelAISDKMessages(input.messages, {
280
- forwardSystemMessages: this.config.forwardSystemMessages,
281
- forwardDeveloperMessages: this.config.forwardDeveloperMessages
282
- });
283
- if (systemPrompt) {
284
- messages.unshift({
285
- role: "system",
286
- content: systemPrompt
287
- });
288
- }
289
- let allTools = convertToolsToVercelAITools(input.tools);
290
- if (this.config.tools && this.config.tools.length > 0) {
291
- const configTools = convertToolDefinitionsToVercelAITools(
292
- this.config.tools
293
- );
294
- allTools = { ...allTools, ...configTools };
295
- }
296
- const streamTextParams = {
297
- model,
298
- messages,
299
- tools: allTools,
300
- toolChoice: this.config.toolChoice,
301
- stopWhen: this.config.maxSteps ? stepCountIs(this.config.maxSteps) : void 0,
302
- maxOutputTokens: this.config.maxOutputTokens,
303
- temperature: this.config.temperature,
304
- topP: this.config.topP,
305
- topK: this.config.topK,
306
- presencePenalty: this.config.presencePenalty,
307
- frequencyPenalty: this.config.frequencyPenalty,
308
- stopSequences: this.config.stopSequences,
309
- seed: this.config.seed,
310
- providerOptions: this.config.providerOptions,
311
- maxRetries: this.config.maxRetries
312
- };
313
- if (input.forwardedProps && typeof input.forwardedProps === "object") {
314
- const props = input.forwardedProps;
315
- if (props.model !== void 0 && this.canOverride("model")) {
316
- if (typeof props.model === "string" || typeof props.model === "object") {
317
- streamTextParams.model = resolveModel(
318
- props.model,
319
- this.config.apiKey
320
- );
321
- }
322
- }
323
- if (props.toolChoice !== void 0 && this.canOverride("toolChoice")) {
324
- const toolChoice = props.toolChoice;
325
- if (toolChoice === "auto" || toolChoice === "required" || toolChoice === "none" || typeof toolChoice === "object" && toolChoice !== null && "type" in toolChoice && toolChoice.type === "tool") {
326
- streamTextParams.toolChoice = toolChoice;
327
- }
328
- }
329
- if (typeof props.maxOutputTokens === "number" && this.canOverride("maxOutputTokens")) {
330
- streamTextParams.maxOutputTokens = props.maxOutputTokens;
331
- }
332
- if (typeof props.temperature === "number" && this.canOverride("temperature")) {
333
- streamTextParams.temperature = props.temperature;
334
- }
335
- if (typeof props.topP === "number" && this.canOverride("topP")) {
336
- streamTextParams.topP = props.topP;
337
- }
338
- if (typeof props.topK === "number" && this.canOverride("topK")) {
339
- streamTextParams.topK = props.topK;
340
- }
341
- if (typeof props.presencePenalty === "number" && this.canOverride("presencePenalty")) {
342
- streamTextParams.presencePenalty = props.presencePenalty;
343
- }
344
- if (typeof props.frequencyPenalty === "number" && this.canOverride("frequencyPenalty")) {
345
- streamTextParams.frequencyPenalty = props.frequencyPenalty;
346
- }
347
- if (Array.isArray(props.stopSequences) && this.canOverride("stopSequences")) {
348
- if (props.stopSequences.every(
349
- (item) => typeof item === "string"
350
- )) {
351
- streamTextParams.stopSequences = props.stopSequences;
352
- }
353
- }
354
- if (typeof props.seed === "number" && this.canOverride("seed")) {
355
- streamTextParams.seed = props.seed;
356
- }
357
- if (typeof props.maxRetries === "number" && this.canOverride("maxRetries")) {
358
- streamTextParams.maxRetries = props.maxRetries;
359
- }
360
- if (props.providerOptions !== void 0 && this.canOverride("providerOptions")) {
361
- if (typeof props.providerOptions === "object" && props.providerOptions !== null) {
362
- streamTextParams.providerOptions = props.providerOptions;
363
- }
364
- }
365
- }
366
- const mcpClients = [];
367
- (async () => {
368
- const abortController = new AbortController();
369
- this.abortController = abortController;
370
- let terminalEventEmitted = false;
371
- try {
372
- streamTextParams.tools = {
373
- ...streamTextParams.tools,
374
- AGUISendStateSnapshot: createVercelAISDKTool({
375
- description: "Replace the entire application state with a new snapshot",
376
- inputSchema: z.object({
377
- snapshot: z.any().describe("The complete new state object")
378
- }),
379
- execute: async ({ snapshot }) => {
380
- return { success: true, snapshot };
381
- }
382
- }),
383
- AGUISendStateDelta: createVercelAISDKTool({
384
- description: "Apply incremental updates to application state using JSON Patch operations",
385
- inputSchema: z.object({
386
- delta: z.array(
387
- z.object({
388
- op: z.enum(["add", "replace", "remove"]).describe("The operation to perform"),
389
- path: z.string().describe("JSON Pointer path (e.g., '/foo/bar')"),
390
- value: z.any().optional().describe(
391
- "The value to set. Required for 'add' and 'replace' operations, ignored for 'remove'."
392
- )
393
- })
394
- ).describe("Array of JSON Patch operations")
395
- }),
396
- execute: async ({ delta }) => {
397
- return { success: true, delta };
398
- }
399
- })
400
- };
401
- if (this.config.mcpServers && this.config.mcpServers.length > 0) {
402
- for (const serverConfig of this.config.mcpServers) {
403
- let transport;
404
- if (serverConfig.type === "http") {
405
- const url = new URL(serverConfig.url);
406
- transport = new StreamableHTTPClientTransport(
407
- url,
408
- serverConfig.options
409
- );
410
- } else if (serverConfig.type === "sse") {
411
- transport = new SSEClientTransport(
412
- new URL(serverConfig.url),
413
- serverConfig.headers
414
- );
415
- }
416
- if (transport) {
417
- const mcpClient = await createMCPClient({ transport });
418
- mcpClients.push(mcpClient);
419
- const mcpTools = await mcpClient.tools();
420
- streamTextParams.tools = {
421
- ...streamTextParams.tools,
422
- ...mcpTools
423
- };
424
- }
425
- }
426
- }
427
- const response = streamText({
428
- ...streamTextParams,
429
- abortSignal: abortController.signal
430
- });
431
- let messageId = randomUUID();
432
- let reasoningMessageId = randomUUID();
433
- const toolCallStates = /* @__PURE__ */ new Map();
434
- const ensureToolCallState = (toolCallId) => {
435
- let state = toolCallStates.get(toolCallId);
436
- if (!state) {
437
- state = { started: false, hasArgsDelta: false, ended: false };
438
- toolCallStates.set(toolCallId, state);
439
- }
440
- return state;
441
- };
442
- for await (const part of response.fullStream) {
443
- switch (part.type) {
444
- case "abort": {
445
- const abortEndEvent = {
446
- type: EventType.RUN_FINISHED,
447
- threadId: input.threadId,
448
- runId: input.runId
449
- };
450
- subscriber.next(abortEndEvent);
451
- terminalEventEmitted = true;
452
- subscriber.complete();
453
- break;
454
- }
455
- case "reasoning-start": {
456
- const providedId = "id" in part ? part.id : void 0;
457
- if (providedId && providedId !== "0") {
458
- reasoningMessageId = providedId;
459
- }
460
- const reasoningStartEvent = {
461
- type: EventType.REASONING_START,
462
- messageId: reasoningMessageId
463
- };
464
- subscriber.next(reasoningStartEvent);
465
- const reasoningMessageStart = {
466
- type: EventType.REASONING_MESSAGE_START,
467
- messageId: reasoningMessageId,
468
- role: "reasoning"
469
- };
470
- subscriber.next(reasoningMessageStart);
471
- break;
472
- }
473
- case "reasoning-delta": {
474
- const reasoningDeltaEvent = {
475
- type: EventType.REASONING_MESSAGE_CONTENT,
476
- messageId: reasoningMessageId,
477
- delta: ("text" in part ? part.text : part.delta) ?? ""
478
- };
479
- subscriber.next(reasoningDeltaEvent);
480
- break;
481
- }
482
- case "reasoning-end": {
483
- const reasoningMessageEnd = {
484
- type: EventType.REASONING_MESSAGE_END,
485
- messageId: reasoningMessageId
486
- };
487
- subscriber.next(reasoningMessageEnd);
488
- const reasoningEndEvent = {
489
- type: EventType.REASONING_END,
490
- messageId: reasoningMessageId
491
- };
492
- subscriber.next(reasoningEndEvent);
493
- break;
494
- }
495
- case "tool-input-start": {
496
- const toolCallId = part.id;
497
- const state = ensureToolCallState(toolCallId);
498
- state.toolName = part.toolName;
499
- if (!state.started) {
500
- state.started = true;
501
- const startEvent2 = {
502
- type: EventType.TOOL_CALL_START,
503
- parentMessageId: messageId,
504
- toolCallId,
505
- toolCallName: part.toolName
506
- };
507
- subscriber.next(startEvent2);
508
- }
509
- break;
510
- }
511
- case "tool-input-delta": {
512
- const toolCallId = part.id;
513
- const state = ensureToolCallState(toolCallId);
514
- state.hasArgsDelta = true;
515
- const argsEvent = {
516
- type: EventType.TOOL_CALL_ARGS,
517
- toolCallId,
518
- delta: part.delta
519
- };
520
- subscriber.next(argsEvent);
521
- break;
522
- }
523
- case "tool-input-end": {
524
- break;
525
- }
526
- case "text-start": {
527
- const providedId = "id" in part ? part.id : void 0;
528
- messageId = providedId && providedId !== "0" ? providedId : randomUUID();
529
- break;
530
- }
531
- case "text-delta": {
532
- const textDelta = "text" in part ? part.text : "";
533
- const textEvent = {
534
- type: EventType.TEXT_MESSAGE_CHUNK,
535
- role: "assistant",
536
- messageId,
537
- delta: textDelta
538
- };
539
- subscriber.next(textEvent);
540
- break;
541
- }
542
- case "tool-call": {
543
- const toolCallId = part.toolCallId;
544
- const state = ensureToolCallState(toolCallId);
545
- state.toolName = part.toolName ?? state.toolName;
546
- if (!state.started) {
547
- state.started = true;
548
- const startEvent2 = {
549
- type: EventType.TOOL_CALL_START,
550
- parentMessageId: messageId,
551
- toolCallId,
552
- toolCallName: part.toolName
553
- };
554
- subscriber.next(startEvent2);
555
- }
556
- if (!state.hasArgsDelta && "input" in part && part.input !== void 0) {
557
- let serializedInput = "";
558
- if (typeof part.input === "string") {
559
- serializedInput = part.input;
560
- } else {
561
- try {
562
- serializedInput = JSON.stringify(part.input);
563
- } catch {
564
- serializedInput = String(part.input);
565
- }
566
- }
567
- if (serializedInput.length > 0) {
568
- const argsEvent = {
569
- type: EventType.TOOL_CALL_ARGS,
570
- toolCallId,
571
- delta: serializedInput
572
- };
573
- subscriber.next(argsEvent);
574
- state.hasArgsDelta = true;
575
- }
576
- }
577
- if (!state.ended) {
578
- state.ended = true;
579
- const endEvent = {
580
- type: EventType.TOOL_CALL_END,
581
- toolCallId
582
- };
583
- subscriber.next(endEvent);
584
- }
585
- break;
586
- }
587
- case "tool-result": {
588
- const toolResult = "output" in part ? part.output : null;
589
- const toolName = "toolName" in part ? part.toolName : "";
590
- toolCallStates.delete(part.toolCallId);
591
- if (toolName === "AGUISendStateSnapshot" && toolResult && typeof toolResult === "object") {
592
- const stateSnapshotEvent = {
593
- type: EventType.STATE_SNAPSHOT,
594
- snapshot: toolResult.snapshot
595
- };
596
- subscriber.next(stateSnapshotEvent);
597
- } else if (toolName === "AGUISendStateDelta" && toolResult && typeof toolResult === "object") {
598
- const stateDeltaEvent = {
599
- type: EventType.STATE_DELTA,
600
- delta: toolResult.delta
601
- };
602
- subscriber.next(stateDeltaEvent);
603
- }
604
- const resultEvent = {
605
- type: EventType.TOOL_CALL_RESULT,
606
- role: "tool",
607
- messageId: randomUUID(),
608
- toolCallId: part.toolCallId,
609
- content: JSON.stringify(toolResult)
610
- };
611
- subscriber.next(resultEvent);
612
- break;
613
- }
614
- case "finish": {
615
- const finishedEvent = {
616
- type: EventType.RUN_FINISHED,
617
- threadId: input.threadId,
618
- runId: input.runId
619
- };
620
- subscriber.next(finishedEvent);
621
- terminalEventEmitted = true;
622
- subscriber.complete();
623
- break;
624
- }
625
- case "error": {
626
- if (abortController.signal.aborted) {
627
- break;
628
- }
629
- const runErrorEvent = {
630
- type: EventType.RUN_ERROR,
631
- message: part.error + ""
632
- };
633
- subscriber.next(runErrorEvent);
634
- terminalEventEmitted = true;
635
- subscriber.error(part.error);
636
- break;
637
- }
638
- }
639
- }
640
- if (!terminalEventEmitted) {
641
- if (abortController.signal.aborted) {
642
- } else {
643
- const finishedEvent = {
644
- type: EventType.RUN_FINISHED,
645
- threadId: input.threadId,
646
- runId: input.runId
647
- };
648
- subscriber.next(finishedEvent);
649
- }
650
- terminalEventEmitted = true;
651
- subscriber.complete();
652
- }
653
- } catch (error) {
654
- if (abortController.signal.aborted) {
655
- subscriber.complete();
656
- } else {
657
- const runErrorEvent = {
658
- type: EventType.RUN_ERROR,
659
- message: error + ""
660
- };
661
- subscriber.next(runErrorEvent);
662
- terminalEventEmitted = true;
663
- subscriber.error(error);
664
- }
665
- } finally {
666
- this.abortController = void 0;
667
- await Promise.all(mcpClients.map((client) => client.close()));
668
- }
669
- })();
670
- return () => {
671
- Promise.all(mcpClients.map((client) => client.close())).catch(() => {
672
- });
673
- };
674
- });
675
- }
676
- clone() {
677
- const cloned = new _BuiltInAgent(this.config);
678
- cloned.middlewares = [...this.middlewares];
679
- return cloned;
680
- }
681
- abortRun() {
682
- this.abortController?.abort();
683
- }
232
+ \`\`\`json\n${JSON.stringify(input.state, null, 2)}\n\`\`\`\n`);
233
+ systemPrompt = parts.join("");
234
+ }
235
+ const messages = convertMessagesToVercelAISDKMessages(input.messages, {
236
+ forwardSystemMessages: this.config.forwardSystemMessages,
237
+ forwardDeveloperMessages: this.config.forwardDeveloperMessages
238
+ });
239
+ if (systemPrompt) messages.unshift({
240
+ role: "system",
241
+ content: systemPrompt
242
+ });
243
+ let allTools = convertToolsToVercelAITools(input.tools);
244
+ if (this.config.tools && this.config.tools.length > 0) {
245
+ const configTools = convertToolDefinitionsToVercelAITools(this.config.tools);
246
+ allTools = {
247
+ ...allTools,
248
+ ...configTools
249
+ };
250
+ }
251
+ const streamTextParams = {
252
+ model,
253
+ messages,
254
+ tools: allTools,
255
+ toolChoice: this.config.toolChoice,
256
+ stopWhen: this.config.maxSteps ? stepCountIs(this.config.maxSteps) : void 0,
257
+ maxOutputTokens: this.config.maxOutputTokens,
258
+ temperature: this.config.temperature,
259
+ topP: this.config.topP,
260
+ topK: this.config.topK,
261
+ presencePenalty: this.config.presencePenalty,
262
+ frequencyPenalty: this.config.frequencyPenalty,
263
+ stopSequences: this.config.stopSequences,
264
+ seed: this.config.seed,
265
+ providerOptions: this.config.providerOptions,
266
+ maxRetries: this.config.maxRetries
267
+ };
268
+ if (input.forwardedProps && typeof input.forwardedProps === "object") {
269
+ const props = input.forwardedProps;
270
+ if (props.model !== void 0 && this.canOverride("model")) {
271
+ if (typeof props.model === "string" || typeof props.model === "object") streamTextParams.model = resolveModel(props.model, this.config.apiKey);
272
+ }
273
+ if (props.toolChoice !== void 0 && this.canOverride("toolChoice")) {
274
+ const toolChoice = props.toolChoice;
275
+ if (toolChoice === "auto" || toolChoice === "required" || toolChoice === "none" || typeof toolChoice === "object" && toolChoice !== null && "type" in toolChoice && toolChoice.type === "tool") streamTextParams.toolChoice = toolChoice;
276
+ }
277
+ if (typeof props.maxOutputTokens === "number" && this.canOverride("maxOutputTokens")) streamTextParams.maxOutputTokens = props.maxOutputTokens;
278
+ if (typeof props.temperature === "number" && this.canOverride("temperature")) streamTextParams.temperature = props.temperature;
279
+ if (typeof props.topP === "number" && this.canOverride("topP")) streamTextParams.topP = props.topP;
280
+ if (typeof props.topK === "number" && this.canOverride("topK")) streamTextParams.topK = props.topK;
281
+ if (typeof props.presencePenalty === "number" && this.canOverride("presencePenalty")) streamTextParams.presencePenalty = props.presencePenalty;
282
+ if (typeof props.frequencyPenalty === "number" && this.canOverride("frequencyPenalty")) streamTextParams.frequencyPenalty = props.frequencyPenalty;
283
+ if (Array.isArray(props.stopSequences) && this.canOverride("stopSequences")) {
284
+ if (props.stopSequences.every((item) => typeof item === "string")) streamTextParams.stopSequences = props.stopSequences;
285
+ }
286
+ if (typeof props.seed === "number" && this.canOverride("seed")) streamTextParams.seed = props.seed;
287
+ if (typeof props.maxRetries === "number" && this.canOverride("maxRetries")) streamTextParams.maxRetries = props.maxRetries;
288
+ if (props.providerOptions !== void 0 && this.canOverride("providerOptions")) {
289
+ if (typeof props.providerOptions === "object" && props.providerOptions !== null) streamTextParams.providerOptions = props.providerOptions;
290
+ }
291
+ }
292
+ const mcpClients = [];
293
+ (async () => {
294
+ const abortController = new AbortController();
295
+ this.abortController = abortController;
296
+ let terminalEventEmitted = false;
297
+ try {
298
+ streamTextParams.tools = {
299
+ ...streamTextParams.tools,
300
+ AGUISendStateSnapshot: tool({
301
+ description: "Replace the entire application state with a new snapshot",
302
+ inputSchema: z.object({ snapshot: z.any().describe("The complete new state object") }),
303
+ execute: async ({ snapshot }) => {
304
+ return {
305
+ success: true,
306
+ snapshot
307
+ };
308
+ }
309
+ }),
310
+ AGUISendStateDelta: tool({
311
+ description: "Apply incremental updates to application state using JSON Patch operations",
312
+ inputSchema: z.object({ delta: z.array(z.object({
313
+ op: z.enum([
314
+ "add",
315
+ "replace",
316
+ "remove"
317
+ ]).describe("The operation to perform"),
318
+ path: z.string().describe("JSON Pointer path (e.g., '/foo/bar')"),
319
+ value: z.any().optional().describe("The value to set. Required for 'add' and 'replace' operations, ignored for 'remove'.")
320
+ })).describe("Array of JSON Patch operations") }),
321
+ execute: async ({ delta }) => {
322
+ return {
323
+ success: true,
324
+ delta
325
+ };
326
+ }
327
+ })
328
+ };
329
+ if (this.config.mcpServers && this.config.mcpServers.length > 0) for (const serverConfig of this.config.mcpServers) {
330
+ let transport;
331
+ if (serverConfig.type === "http") transport = new StreamableHTTPClientTransport(new URL(serverConfig.url), serverConfig.options);
332
+ else if (serverConfig.type === "sse") transport = new SSEClientTransport(new URL(serverConfig.url), serverConfig.headers);
333
+ if (transport) {
334
+ const mcpClient = await experimental_createMCPClient({ transport });
335
+ mcpClients.push(mcpClient);
336
+ const mcpTools = await mcpClient.tools();
337
+ streamTextParams.tools = {
338
+ ...streamTextParams.tools,
339
+ ...mcpTools
340
+ };
341
+ }
342
+ }
343
+ const response = streamText({
344
+ ...streamTextParams,
345
+ abortSignal: abortController.signal
346
+ });
347
+ let messageId = randomUUID();
348
+ let reasoningMessageId = randomUUID();
349
+ const toolCallStates = /* @__PURE__ */ new Map();
350
+ const ensureToolCallState = (toolCallId) => {
351
+ let state = toolCallStates.get(toolCallId);
352
+ if (!state) {
353
+ state = {
354
+ started: false,
355
+ hasArgsDelta: false,
356
+ ended: false
357
+ };
358
+ toolCallStates.set(toolCallId, state);
359
+ }
360
+ return state;
361
+ };
362
+ for await (const part of response.fullStream) switch (part.type) {
363
+ case "abort": {
364
+ const abortEndEvent = {
365
+ type: EventType.RUN_FINISHED,
366
+ threadId: input.threadId,
367
+ runId: input.runId
368
+ };
369
+ subscriber.next(abortEndEvent);
370
+ terminalEventEmitted = true;
371
+ subscriber.complete();
372
+ break;
373
+ }
374
+ case "reasoning-start": {
375
+ const providedId = "id" in part ? part.id : void 0;
376
+ if (providedId && providedId !== "0") reasoningMessageId = providedId;
377
+ const reasoningStartEvent = {
378
+ type: EventType.REASONING_START,
379
+ messageId: reasoningMessageId
380
+ };
381
+ subscriber.next(reasoningStartEvent);
382
+ const reasoningMessageStart = {
383
+ type: EventType.REASONING_MESSAGE_START,
384
+ messageId: reasoningMessageId,
385
+ role: "reasoning"
386
+ };
387
+ subscriber.next(reasoningMessageStart);
388
+ break;
389
+ }
390
+ case "reasoning-delta": {
391
+ const reasoningDeltaEvent = {
392
+ type: EventType.REASONING_MESSAGE_CONTENT,
393
+ messageId: reasoningMessageId,
394
+ delta: ("text" in part ? part.text : part.delta) ?? ""
395
+ };
396
+ subscriber.next(reasoningDeltaEvent);
397
+ break;
398
+ }
399
+ case "reasoning-end": {
400
+ const reasoningMessageEnd = {
401
+ type: EventType.REASONING_MESSAGE_END,
402
+ messageId: reasoningMessageId
403
+ };
404
+ subscriber.next(reasoningMessageEnd);
405
+ const reasoningEndEvent = {
406
+ type: EventType.REASONING_END,
407
+ messageId: reasoningMessageId
408
+ };
409
+ subscriber.next(reasoningEndEvent);
410
+ break;
411
+ }
412
+ case "tool-input-start": {
413
+ const toolCallId = part.id;
414
+ const state = ensureToolCallState(toolCallId);
415
+ state.toolName = part.toolName;
416
+ if (!state.started) {
417
+ state.started = true;
418
+ const startEvent = {
419
+ type: EventType.TOOL_CALL_START,
420
+ parentMessageId: messageId,
421
+ toolCallId,
422
+ toolCallName: part.toolName
423
+ };
424
+ subscriber.next(startEvent);
425
+ }
426
+ break;
427
+ }
428
+ case "tool-input-delta": {
429
+ const toolCallId = part.id;
430
+ const state = ensureToolCallState(toolCallId);
431
+ state.hasArgsDelta = true;
432
+ const argsEvent = {
433
+ type: EventType.TOOL_CALL_ARGS,
434
+ toolCallId,
435
+ delta: part.delta
436
+ };
437
+ subscriber.next(argsEvent);
438
+ break;
439
+ }
440
+ case "tool-input-end": break;
441
+ case "text-start": {
442
+ const providedId = "id" in part ? part.id : void 0;
443
+ messageId = providedId && providedId !== "0" ? providedId : randomUUID();
444
+ break;
445
+ }
446
+ case "text-delta": {
447
+ const textDelta = "text" in part ? part.text : "";
448
+ const textEvent = {
449
+ type: EventType.TEXT_MESSAGE_CHUNK,
450
+ role: "assistant",
451
+ messageId,
452
+ delta: textDelta
453
+ };
454
+ subscriber.next(textEvent);
455
+ break;
456
+ }
457
+ case "tool-call": {
458
+ const toolCallId = part.toolCallId;
459
+ const state = ensureToolCallState(toolCallId);
460
+ state.toolName = part.toolName ?? state.toolName;
461
+ if (!state.started) {
462
+ state.started = true;
463
+ const startEvent = {
464
+ type: EventType.TOOL_CALL_START,
465
+ parentMessageId: messageId,
466
+ toolCallId,
467
+ toolCallName: part.toolName
468
+ };
469
+ subscriber.next(startEvent);
470
+ }
471
+ if (!state.hasArgsDelta && "input" in part && part.input !== void 0) {
472
+ let serializedInput = "";
473
+ if (typeof part.input === "string") serializedInput = part.input;
474
+ else try {
475
+ serializedInput = JSON.stringify(part.input);
476
+ } catch {
477
+ serializedInput = String(part.input);
478
+ }
479
+ if (serializedInput.length > 0) {
480
+ const argsEvent = {
481
+ type: EventType.TOOL_CALL_ARGS,
482
+ toolCallId,
483
+ delta: serializedInput
484
+ };
485
+ subscriber.next(argsEvent);
486
+ state.hasArgsDelta = true;
487
+ }
488
+ }
489
+ if (!state.ended) {
490
+ state.ended = true;
491
+ const endEvent = {
492
+ type: EventType.TOOL_CALL_END,
493
+ toolCallId
494
+ };
495
+ subscriber.next(endEvent);
496
+ }
497
+ break;
498
+ }
499
+ case "tool-result": {
500
+ const toolResult = "output" in part ? part.output : null;
501
+ const toolName = "toolName" in part ? part.toolName : "";
502
+ toolCallStates.delete(part.toolCallId);
503
+ if (toolName === "AGUISendStateSnapshot" && toolResult && typeof toolResult === "object") {
504
+ const stateSnapshotEvent = {
505
+ type: EventType.STATE_SNAPSHOT,
506
+ snapshot: toolResult.snapshot
507
+ };
508
+ subscriber.next(stateSnapshotEvent);
509
+ } else if (toolName === "AGUISendStateDelta" && toolResult && typeof toolResult === "object") {
510
+ const stateDeltaEvent = {
511
+ type: EventType.STATE_DELTA,
512
+ delta: toolResult.delta
513
+ };
514
+ subscriber.next(stateDeltaEvent);
515
+ }
516
+ const resultEvent = {
517
+ type: EventType.TOOL_CALL_RESULT,
518
+ role: "tool",
519
+ messageId: randomUUID(),
520
+ toolCallId: part.toolCallId,
521
+ content: JSON.stringify(toolResult)
522
+ };
523
+ subscriber.next(resultEvent);
524
+ break;
525
+ }
526
+ case "finish": {
527
+ const finishedEvent = {
528
+ type: EventType.RUN_FINISHED,
529
+ threadId: input.threadId,
530
+ runId: input.runId
531
+ };
532
+ subscriber.next(finishedEvent);
533
+ terminalEventEmitted = true;
534
+ subscriber.complete();
535
+ break;
536
+ }
537
+ case "error": {
538
+ if (abortController.signal.aborted) break;
539
+ const runErrorEvent = {
540
+ type: EventType.RUN_ERROR,
541
+ message: part.error + ""
542
+ };
543
+ subscriber.next(runErrorEvent);
544
+ terminalEventEmitted = true;
545
+ subscriber.error(part.error);
546
+ break;
547
+ }
548
+ }
549
+ if (!terminalEventEmitted) {
550
+ if (abortController.signal.aborted) {} else {
551
+ const finishedEvent = {
552
+ type: EventType.RUN_FINISHED,
553
+ threadId: input.threadId,
554
+ runId: input.runId
555
+ };
556
+ subscriber.next(finishedEvent);
557
+ }
558
+ terminalEventEmitted = true;
559
+ subscriber.complete();
560
+ }
561
+ } catch (error) {
562
+ if (abortController.signal.aborted) subscriber.complete();
563
+ else {
564
+ const runErrorEvent = {
565
+ type: EventType.RUN_ERROR,
566
+ message: error + ""
567
+ };
568
+ subscriber.next(runErrorEvent);
569
+ terminalEventEmitted = true;
570
+ subscriber.error(error);
571
+ }
572
+ } finally {
573
+ this.abortController = void 0;
574
+ await Promise.all(mcpClients.map((client) => client.close()));
575
+ }
576
+ })();
577
+ return () => {
578
+ Promise.all(mcpClients.map((client) => client.close())).catch(() => {});
579
+ };
580
+ });
581
+ }
582
+ clone() {
583
+ const cloned = new BuiltInAgent(this.config);
584
+ cloned.middlewares = [...this.middlewares];
585
+ return cloned;
586
+ }
587
+ abortRun() {
588
+ this.abortController?.abort();
589
+ }
684
590
  };
591
+ /**
592
+ * @deprecated Use BuiltInAgent instead
593
+ */
685
594
  var BasicAgent = class extends BuiltInAgent {
686
- constructor(config) {
687
- super(config);
688
- console.warn("BasicAgent is deprecated, use BuiltInAgent instead");
689
- }
690
- };
691
- export {
692
- BasicAgent,
693
- BuiltInAgent,
694
- convertJsonSchemaToZodSchema,
695
- convertMessagesToVercelAISDKMessages,
696
- convertToolDefinitionsToVercelAITools,
697
- convertToolsToVercelAITools,
698
- defineTool,
699
- resolveModel
595
+ constructor(config) {
596
+ super(config);
597
+ console.warn("BasicAgent is deprecated, use BuiltInAgent instead");
598
+ }
700
599
  };
600
+
601
+ //#endregion
602
+ export { BasicAgent, BuiltInAgent, convertJsonSchemaToZodSchema, convertMessagesToVercelAISDKMessages, convertToolDefinitionsToVercelAITools, convertToolsToVercelAITools, defineTool, resolveModel };
701
603
  //# sourceMappingURL=index.mjs.map