@voltagent/core 1.0.0 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -1,9 +1,9 @@
1
+ import { ModelMessage, DataContent as DataContent$1, UserContent, AssistantContent, ToolContent, ProviderOptions as ProviderOptions$1 } from '@ai-sdk/provider-utils';
2
+ export { AssistantContent, FilePart, ImagePart, TextPart, ToolContent, UserContent } from '@ai-sdk/provider-utils';
1
3
  import { TextStreamPart, generateText, UIMessage, StreamTextResult, LanguageModel, CallSettings, ToolSet, GenerateTextResult, GenerateObjectResult, AsyncIterableStream as AsyncIterableStream$1, CallWarning, LanguageModelUsage, FinishReason, EmbeddingModel } from 'ai';
2
4
  export { hasToolCall, stepCountIs } from 'ai';
3
5
  import * as zod from 'zod';
4
6
  import { z } from 'zod';
5
- import { ModelMessage, DataContent as DataContent$1, UserContent, AssistantContent, ToolContent, ProviderOptions as ProviderOptions$1 } from '@ai-sdk/provider-utils';
6
- export { AssistantContent, FilePart, ImagePart, TextPart, ToolContent, UserContent } from '@ai-sdk/provider-utils';
7
7
  import { AsyncIterableStream } from '@voltagent/internal/utils';
8
8
  export { AsyncIterableStream, createAsyncIterableStream } from '@voltagent/internal/utils';
9
9
  import { Logger, LogFn, LogBuffer } from '@voltagent/internal';
@@ -2585,7 +2585,7 @@ interface TraceContextOptions {
2585
2585
  operationId: string;
2586
2586
  parentSpan?: Span;
2587
2587
  parentAgentId?: string;
2588
- input?: string | UIMessage[];
2588
+ input?: string | UIMessage[] | BaseMessage[];
2589
2589
  }
2590
2590
  declare class AgentTraceContext {
2591
2591
  private rootSpan;
@@ -3335,19 +3335,19 @@ declare class Agent {
3335
3335
  /**
3336
3336
  * Generate text response
3337
3337
  */
3338
- generateText(input: string | UIMessage[], options?: GenerateTextOptions): Promise<GenerateTextResultWithContext>;
3338
+ generateText(input: string | UIMessage[] | BaseMessage[], options?: GenerateTextOptions): Promise<GenerateTextResultWithContext>;
3339
3339
  /**
3340
3340
  * Stream text response
3341
3341
  */
3342
- streamText(input: string | UIMessage[], options?: StreamTextOptions): Promise<StreamTextResultWithContext>;
3342
+ streamText(input: string | UIMessage[] | BaseMessage[], options?: StreamTextOptions): Promise<StreamTextResultWithContext>;
3343
3343
  /**
3344
3344
  * Generate structured object
3345
3345
  */
3346
- generateObject<T extends z.ZodType>(input: string | UIMessage[], schema: T, options?: GenerateObjectOptions): Promise<GenerateObjectResultWithContext<z.infer<T>>>;
3346
+ generateObject<T extends z.ZodType>(input: string | UIMessage[] | BaseMessage[], schema: T, options?: GenerateObjectOptions): Promise<GenerateObjectResultWithContext<z.infer<T>>>;
3347
3347
  /**
3348
3348
  * Stream structured object
3349
3349
  */
3350
- streamObject<T extends z.ZodType>(input: string | UIMessage[], schema: T, options?: StreamObjectOptions): Promise<StreamObjectResultWithContext<z.infer<T>>>;
3350
+ streamObject<T extends z.ZodType>(input: string | UIMessage[] | BaseMessage[], schema: T, options?: StreamObjectOptions): Promise<StreamObjectResultWithContext<z.infer<T>>>;
3351
3351
  /**
3352
3352
  * Common preparation for all execution methods
3353
3353
  */
@@ -3788,7 +3788,7 @@ type WorkflowHooks<DATA, RESULT> = {
3788
3788
  */
3789
3789
  onEnd?: (state: WorkflowState<DATA, RESULT>) => Promise<void>;
3790
3790
  };
3791
- type WorkflowInput<INPUT_SCHEMA extends InternalBaseWorkflowInputSchema> = TF.IsUnknown<INPUT_SCHEMA> extends true ? BaseMessage | BaseMessage[] | string : INPUT_SCHEMA extends z.ZodTypeAny ? z.infer<INPUT_SCHEMA> : undefined;
3791
+ type WorkflowInput<INPUT_SCHEMA extends InternalBaseWorkflowInputSchema> = TF.IsUnknown<INPUT_SCHEMA> extends true ? BaseMessage | BaseMessage[] | UIMessage | UIMessage[] | string : INPUT_SCHEMA extends z.ZodTypeAny ? z.infer<INPUT_SCHEMA> : undefined;
3792
3792
  type WorkflowResult<RESULT_SCHEMA extends z.ZodTypeAny> = RESULT_SCHEMA extends z.ZodTypeAny ? z.infer<RESULT_SCHEMA> : RESULT_SCHEMA;
3793
3793
  type WorkflowConfig<INPUT_SCHEMA extends InternalBaseWorkflowInputSchema, RESULT_SCHEMA extends z.ZodTypeAny, SUSPEND_SCHEMA extends z.ZodTypeAny = z.ZodAny, RESUME_SCHEMA extends z.ZodTypeAny = z.ZodAny> = {
3794
3794
  /**
@@ -4226,7 +4226,7 @@ interface WorkflowStepContext {
4226
4226
  * The base input type for the workflow
4227
4227
  * @private - INTERNAL USE ONLY
4228
4228
  */
4229
- type InternalBaseWorkflowInputSchema = z.ZodTypeAny | BaseMessage | BaseMessage[] | string;
4229
+ type InternalBaseWorkflowInputSchema = z.ZodTypeAny | BaseMessage | BaseMessage[] | UIMessage | UIMessage[] | string;
4230
4230
  /**
4231
4231
  * The state parameter for the workflow, used to pass the state to a step or other function (i.e. hooks)
4232
4232
  * @private - INTERNAL USE ONLY
@@ -4338,7 +4338,7 @@ type InternalAnyWorkflowStep<INPUT = DangerouslyAllowAny, DATA = DangerouslyAllo
4338
4338
  type InternalInferWorkflowStepsResult<STEPS extends ReadonlyArray<InternalAnyWorkflowStep<any, any, any, any, any>>> = {
4339
4339
  [K in keyof STEPS]: ExtractExecuteResult<STEPS[K]>;
4340
4340
  };
4341
- type InternalExtractWorkflowInputData<T> = TF.IsUnknown<T> extends true ? BaseMessage | BaseMessage[] | string : TF.IsAny<T> extends true ? BaseMessage | BaseMessage[] | string : T extends z.ZodType ? z.infer<T> : T;
4341
+ type InternalExtractWorkflowInputData<T> = TF.IsUnknown<T> extends true ? BaseMessage | BaseMessage[] | UIMessage | UIMessage[] | string : TF.IsAny<T> extends true ? BaseMessage | BaseMessage[] | UIMessage | UIMessage[] | string : T extends z.ZodType ? z.infer<T> : T;
4342
4342
  type ExtractExecuteResult<T> = T extends {
4343
4343
  execute: (...args: any[]) => infer R;
4344
4344
  } ? R extends Promise<infer U> ? U : R : never;
@@ -4369,7 +4369,7 @@ type AgentConfig$1<SCHEMA extends z.ZodTypeAny> = BaseGenerationOptions & {
4369
4369
  * @param config - The config for the agent (schema) `generateObject` call
4370
4370
  * @returns A workflow step that executes the agent with the task
4371
4371
  */
4372
- declare function andAgent<INPUT, DATA, SCHEMA extends z.ZodTypeAny>(task: UIMessage[] | string | InternalWorkflowFunc<INPUT, DATA, UIMessage[] | string, any, any>, agent: Agent, config: AgentConfig$1<SCHEMA>): {
4372
+ declare function andAgent<INPUT, DATA, SCHEMA extends z.ZodTypeAny>(task: UIMessage[] | ModelMessage[] | string | InternalWorkflowFunc<INPUT, DATA, UIMessage[] | ModelMessage[] | string, any, any>, agent: Agent, config: AgentConfig$1<SCHEMA>): {
4373
4373
  type: "agent";
4374
4374
  id: string;
4375
4375
  name: string;
@@ -4856,7 +4856,7 @@ declare class WorkflowChain<INPUT_SCHEMA extends InternalBaseWorkflowInputSchema
4856
4856
  * @param config - The config for the agent (schema) `generateObject` call
4857
4857
  * @returns A workflow step that executes the agent with the task
4858
4858
  */
4859
- andAgent<SCHEMA extends z.ZodTypeAny>(task: string | InternalWorkflowFunc<INPUT_SCHEMA, CURRENT_DATA, string, any, any>, agent: Agent, config: AgentConfig<SCHEMA>): WorkflowChain<INPUT_SCHEMA, RESULT_SCHEMA, z.infer<SCHEMA>, SUSPEND_SCHEMA, RESUME_SCHEMA>;
4859
+ andAgent<SCHEMA extends z.ZodTypeAny>(task: string | UIMessage[] | ModelMessage[] | InternalWorkflowFunc<INPUT_SCHEMA, CURRENT_DATA, string | UIMessage[] | ModelMessage[], any, any>, agent: Agent, config: AgentConfig<SCHEMA>): WorkflowChain<INPUT_SCHEMA, RESULT_SCHEMA, z.infer<SCHEMA>, SUSPEND_SCHEMA, RESUME_SCHEMA>;
4860
4860
  /**
4861
4861
  * Add a function step to the workflow with both input and output schemas
4862
4862
  * @param config - Step configuration with schemas
package/dist/index.d.ts CHANGED
@@ -1,9 +1,9 @@
1
+ import { ModelMessage, DataContent as DataContent$1, UserContent, AssistantContent, ToolContent, ProviderOptions as ProviderOptions$1 } from '@ai-sdk/provider-utils';
2
+ export { AssistantContent, FilePart, ImagePart, TextPart, ToolContent, UserContent } from '@ai-sdk/provider-utils';
1
3
  import { TextStreamPart, generateText, UIMessage, StreamTextResult, LanguageModel, CallSettings, ToolSet, GenerateTextResult, GenerateObjectResult, AsyncIterableStream as AsyncIterableStream$1, CallWarning, LanguageModelUsage, FinishReason, EmbeddingModel } from 'ai';
2
4
  export { hasToolCall, stepCountIs } from 'ai';
3
5
  import * as zod from 'zod';
4
6
  import { z } from 'zod';
5
- import { ModelMessage, DataContent as DataContent$1, UserContent, AssistantContent, ToolContent, ProviderOptions as ProviderOptions$1 } from '@ai-sdk/provider-utils';
6
- export { AssistantContent, FilePart, ImagePart, TextPart, ToolContent, UserContent } from '@ai-sdk/provider-utils';
7
7
  import { AsyncIterableStream } from '@voltagent/internal/utils';
8
8
  export { AsyncIterableStream, createAsyncIterableStream } from '@voltagent/internal/utils';
9
9
  import { Logger, LogFn, LogBuffer } from '@voltagent/internal';
@@ -2585,7 +2585,7 @@ interface TraceContextOptions {
2585
2585
  operationId: string;
2586
2586
  parentSpan?: Span;
2587
2587
  parentAgentId?: string;
2588
- input?: string | UIMessage[];
2588
+ input?: string | UIMessage[] | BaseMessage[];
2589
2589
  }
2590
2590
  declare class AgentTraceContext {
2591
2591
  private rootSpan;
@@ -3335,19 +3335,19 @@ declare class Agent {
3335
3335
  /**
3336
3336
  * Generate text response
3337
3337
  */
3338
- generateText(input: string | UIMessage[], options?: GenerateTextOptions): Promise<GenerateTextResultWithContext>;
3338
+ generateText(input: string | UIMessage[] | BaseMessage[], options?: GenerateTextOptions): Promise<GenerateTextResultWithContext>;
3339
3339
  /**
3340
3340
  * Stream text response
3341
3341
  */
3342
- streamText(input: string | UIMessage[], options?: StreamTextOptions): Promise<StreamTextResultWithContext>;
3342
+ streamText(input: string | UIMessage[] | BaseMessage[], options?: StreamTextOptions): Promise<StreamTextResultWithContext>;
3343
3343
  /**
3344
3344
  * Generate structured object
3345
3345
  */
3346
- generateObject<T extends z.ZodType>(input: string | UIMessage[], schema: T, options?: GenerateObjectOptions): Promise<GenerateObjectResultWithContext<z.infer<T>>>;
3346
+ generateObject<T extends z.ZodType>(input: string | UIMessage[] | BaseMessage[], schema: T, options?: GenerateObjectOptions): Promise<GenerateObjectResultWithContext<z.infer<T>>>;
3347
3347
  /**
3348
3348
  * Stream structured object
3349
3349
  */
3350
- streamObject<T extends z.ZodType>(input: string | UIMessage[], schema: T, options?: StreamObjectOptions): Promise<StreamObjectResultWithContext<z.infer<T>>>;
3350
+ streamObject<T extends z.ZodType>(input: string | UIMessage[] | BaseMessage[], schema: T, options?: StreamObjectOptions): Promise<StreamObjectResultWithContext<z.infer<T>>>;
3351
3351
  /**
3352
3352
  * Common preparation for all execution methods
3353
3353
  */
@@ -3788,7 +3788,7 @@ type WorkflowHooks<DATA, RESULT> = {
3788
3788
  */
3789
3789
  onEnd?: (state: WorkflowState<DATA, RESULT>) => Promise<void>;
3790
3790
  };
3791
- type WorkflowInput<INPUT_SCHEMA extends InternalBaseWorkflowInputSchema> = TF.IsUnknown<INPUT_SCHEMA> extends true ? BaseMessage | BaseMessage[] | string : INPUT_SCHEMA extends z.ZodTypeAny ? z.infer<INPUT_SCHEMA> : undefined;
3791
+ type WorkflowInput<INPUT_SCHEMA extends InternalBaseWorkflowInputSchema> = TF.IsUnknown<INPUT_SCHEMA> extends true ? BaseMessage | BaseMessage[] | UIMessage | UIMessage[] | string : INPUT_SCHEMA extends z.ZodTypeAny ? z.infer<INPUT_SCHEMA> : undefined;
3792
3792
  type WorkflowResult<RESULT_SCHEMA extends z.ZodTypeAny> = RESULT_SCHEMA extends z.ZodTypeAny ? z.infer<RESULT_SCHEMA> : RESULT_SCHEMA;
3793
3793
  type WorkflowConfig<INPUT_SCHEMA extends InternalBaseWorkflowInputSchema, RESULT_SCHEMA extends z.ZodTypeAny, SUSPEND_SCHEMA extends z.ZodTypeAny = z.ZodAny, RESUME_SCHEMA extends z.ZodTypeAny = z.ZodAny> = {
3794
3794
  /**
@@ -4226,7 +4226,7 @@ interface WorkflowStepContext {
4226
4226
  * The base input type for the workflow
4227
4227
  * @private - INTERNAL USE ONLY
4228
4228
  */
4229
- type InternalBaseWorkflowInputSchema = z.ZodTypeAny | BaseMessage | BaseMessage[] | string;
4229
+ type InternalBaseWorkflowInputSchema = z.ZodTypeAny | BaseMessage | BaseMessage[] | UIMessage | UIMessage[] | string;
4230
4230
  /**
4231
4231
  * The state parameter for the workflow, used to pass the state to a step or other function (i.e. hooks)
4232
4232
  * @private - INTERNAL USE ONLY
@@ -4338,7 +4338,7 @@ type InternalAnyWorkflowStep<INPUT = DangerouslyAllowAny, DATA = DangerouslyAllo
4338
4338
  type InternalInferWorkflowStepsResult<STEPS extends ReadonlyArray<InternalAnyWorkflowStep<any, any, any, any, any>>> = {
4339
4339
  [K in keyof STEPS]: ExtractExecuteResult<STEPS[K]>;
4340
4340
  };
4341
- type InternalExtractWorkflowInputData<T> = TF.IsUnknown<T> extends true ? BaseMessage | BaseMessage[] | string : TF.IsAny<T> extends true ? BaseMessage | BaseMessage[] | string : T extends z.ZodType ? z.infer<T> : T;
4341
+ type InternalExtractWorkflowInputData<T> = TF.IsUnknown<T> extends true ? BaseMessage | BaseMessage[] | UIMessage | UIMessage[] | string : TF.IsAny<T> extends true ? BaseMessage | BaseMessage[] | UIMessage | UIMessage[] | string : T extends z.ZodType ? z.infer<T> : T;
4342
4342
  type ExtractExecuteResult<T> = T extends {
4343
4343
  execute: (...args: any[]) => infer R;
4344
4344
  } ? R extends Promise<infer U> ? U : R : never;
@@ -4369,7 +4369,7 @@ type AgentConfig$1<SCHEMA extends z.ZodTypeAny> = BaseGenerationOptions & {
4369
4369
  * @param config - The config for the agent (schema) `generateObject` call
4370
4370
  * @returns A workflow step that executes the agent with the task
4371
4371
  */
4372
- declare function andAgent<INPUT, DATA, SCHEMA extends z.ZodTypeAny>(task: UIMessage[] | string | InternalWorkflowFunc<INPUT, DATA, UIMessage[] | string, any, any>, agent: Agent, config: AgentConfig$1<SCHEMA>): {
4372
+ declare function andAgent<INPUT, DATA, SCHEMA extends z.ZodTypeAny>(task: UIMessage[] | ModelMessage[] | string | InternalWorkflowFunc<INPUT, DATA, UIMessage[] | ModelMessage[] | string, any, any>, agent: Agent, config: AgentConfig$1<SCHEMA>): {
4373
4373
  type: "agent";
4374
4374
  id: string;
4375
4375
  name: string;
@@ -4856,7 +4856,7 @@ declare class WorkflowChain<INPUT_SCHEMA extends InternalBaseWorkflowInputSchema
4856
4856
  * @param config - The config for the agent (schema) `generateObject` call
4857
4857
  * @returns A workflow step that executes the agent with the task
4858
4858
  */
4859
- andAgent<SCHEMA extends z.ZodTypeAny>(task: string | InternalWorkflowFunc<INPUT_SCHEMA, CURRENT_DATA, string, any, any>, agent: Agent, config: AgentConfig<SCHEMA>): WorkflowChain<INPUT_SCHEMA, RESULT_SCHEMA, z.infer<SCHEMA>, SUSPEND_SCHEMA, RESUME_SCHEMA>;
4859
+ andAgent<SCHEMA extends z.ZodTypeAny>(task: string | UIMessage[] | ModelMessage[] | InternalWorkflowFunc<INPUT_SCHEMA, CURRENT_DATA, string | UIMessage[] | ModelMessage[], any, any>, agent: Agent, config: AgentConfig<SCHEMA>): WorkflowChain<INPUT_SCHEMA, RESULT_SCHEMA, z.infer<SCHEMA>, SUSPEND_SCHEMA, RESUME_SCHEMA>;
4860
4860
  /**
4861
4861
  * Add a function step to the workflow with both input and output schemas
4862
4862
  * @param config - Step configuration with schemas
package/dist/index.js CHANGED
@@ -7197,6 +7197,148 @@ async function convertResponseMessagesToUIMessages(responseMessages) {
7197
7197
  return uiMessage.parts.length > 0 ? [uiMessage] : [];
7198
7198
  }
7199
7199
  __name(convertResponseMessagesToUIMessages, "convertResponseMessagesToUIMessages");
7200
+ function convertModelMessagesToUIMessages(messages) {
7201
+ const uiMessages = [];
7202
+ for (const message of messages) {
7203
+ if (message.role === "tool") {
7204
+ if (Array.isArray(message.content)) {
7205
+ for (const part of message.content) {
7206
+ if (part.type === "tool-result") {
7207
+ uiMessages.push({
7208
+ id: crypto3.randomUUID(),
7209
+ role: "assistant",
7210
+ parts: [
7211
+ {
7212
+ type: `tool-${part.toolName}`,
7213
+ toolCallId: part.toolCallId,
7214
+ state: "output-available",
7215
+ input: {},
7216
+ output: part.output,
7217
+ providerExecuted: true
7218
+ }
7219
+ ]
7220
+ });
7221
+ }
7222
+ }
7223
+ }
7224
+ continue;
7225
+ }
7226
+ const ui = {
7227
+ id: crypto3.randomUUID(),
7228
+ role: message.role,
7229
+ parts: []
7230
+ };
7231
+ if (typeof message.content === "string") {
7232
+ if (message.content.trim().length > 0) {
7233
+ ui.parts.push({ type: "text", text: message.content });
7234
+ }
7235
+ uiMessages.push(ui);
7236
+ continue;
7237
+ }
7238
+ for (const contentPart of message.content || []) {
7239
+ switch (contentPart.type) {
7240
+ case "text": {
7241
+ if (contentPart.text && contentPart.text.length > 0) {
7242
+ const prev = ui.parts.at(-1);
7243
+ if (message.role === "assistant" && prev && typeof prev?.type === "string" && prev.type.startsWith("tool-") && prev.state === "output-available") {
7244
+ ui.parts.push({ type: "step-start" });
7245
+ }
7246
+ ui.parts.push({
7247
+ type: "text",
7248
+ text: contentPart.text,
7249
+ ...contentPart.providerOptions ? { providerMetadata: contentPart.providerOptions } : {}
7250
+ });
7251
+ }
7252
+ break;
7253
+ }
7254
+ case "reasoning": {
7255
+ if (contentPart.text && contentPart.text.length > 0) {
7256
+ ui.parts.push({
7257
+ type: "reasoning",
7258
+ text: contentPart.text,
7259
+ ...contentPart.providerOptions ? { providerMetadata: contentPart.providerOptions } : {}
7260
+ });
7261
+ }
7262
+ break;
7263
+ }
7264
+ case "tool-call": {
7265
+ ui.parts.push({
7266
+ type: `tool-${contentPart.toolName}`,
7267
+ toolCallId: contentPart.toolCallId,
7268
+ state: "input-available",
7269
+ input: contentPart.input || {},
7270
+ ...contentPart.providerOptions ? { callProviderMetadata: contentPart.providerOptions } : {},
7271
+ ...contentPart.providerExecuted != null ? { providerExecuted: contentPart.providerExecuted } : {}
7272
+ });
7273
+ break;
7274
+ }
7275
+ case "tool-result": {
7276
+ ui.parts.push({
7277
+ type: `tool-${contentPart.toolName}`,
7278
+ toolCallId: contentPart.toolCallId,
7279
+ state: "output-available",
7280
+ input: {},
7281
+ output: contentPart.output,
7282
+ providerExecuted: true
7283
+ });
7284
+ break;
7285
+ }
7286
+ case "image": {
7287
+ let url;
7288
+ const mediaType = contentPart.mediaType || "image/png";
7289
+ const img = contentPart.image;
7290
+ if (img instanceof URL) {
7291
+ url = img.toString();
7292
+ } else if (typeof img === "string") {
7293
+ if (/^(https?:\/\/|data:)/i.test(img)) {
7294
+ url = img;
7295
+ } else {
7296
+ url = `data:${mediaType};base64,${img}`;
7297
+ }
7298
+ } else {
7299
+ const uint8 = img;
7300
+ const base64 = Buffer.from(uint8).toString("base64");
7301
+ url = `data:${mediaType};base64,${base64}`;
7302
+ }
7303
+ ui.parts.push({
7304
+ type: "file",
7305
+ mediaType,
7306
+ url,
7307
+ ...contentPart.providerOptions ? { providerMetadata: contentPart.providerOptions } : {}
7308
+ });
7309
+ break;
7310
+ }
7311
+ case "file": {
7312
+ let url;
7313
+ if (contentPart.data instanceof URL) {
7314
+ url = contentPart.data.toString();
7315
+ } else if (typeof contentPart.data === "string") {
7316
+ if (/^(https?:\/\/|data:)/i.test(contentPart.data)) {
7317
+ url = contentPart.data;
7318
+ } else {
7319
+ url = `data:${contentPart.mediaType};base64,${contentPart.data}`;
7320
+ }
7321
+ } else {
7322
+ const base64 = Buffer.from(contentPart.data).toString("base64");
7323
+ url = `data:${contentPart.mediaType};base64,${base64}`;
7324
+ }
7325
+ ui.parts.push({
7326
+ type: "file",
7327
+ mediaType: contentPart.mediaType,
7328
+ url,
7329
+ ...contentPart.providerOptions ? { providerMetadata: contentPart.providerOptions } : {}
7330
+ });
7331
+ break;
7332
+ }
7333
+ default:
7334
+ break;
7335
+ }
7336
+ }
7337
+ uiMessages.push(ui);
7338
+ }
7339
+ return uiMessages;
7340
+ }
7341
+ __name(convertModelMessagesToUIMessages, "convertModelMessagesToUIMessages");
7200
7342
 
7201
7343
  // src/voltops/prompt-api-client.ts
7202
7344
  var VoltOpsPromptApiClient = class {
@@ -9620,16 +9762,24 @@ var Agent = class {
9620
9762
  if (typeof input === "string") {
9621
9763
  return input;
9622
9764
  }
9765
+ if (!Array.isArray(input) || input.length === 0) return void 0;
9766
+ const isUI = /* @__PURE__ */ __name((msg) => Array.isArray(msg?.parts), "isUI");
9623
9767
  const userMessages = input.filter((msg) => msg.role === "user");
9624
9768
  const lastUserMessage = userMessages.at(-1);
9625
- if (lastUserMessage?.parts) {
9626
- const textParts = lastUserMessage.parts.filter((part) => part.type === "text" && "text" in part).map((part) => part.text).filter((text) => text).map((text) => text.trim());
9769
+ if (!lastUserMessage) return void 0;
9770
+ if (isUI(lastUserMessage)) {
9771
+ const textParts = lastUserMessage.parts.filter((part) => part.type === "text" && typeof part.text === "string").map((part) => part.text.trim()).filter(Boolean);
9627
9772
  if (textParts.length > 0) return textParts.join(" ");
9773
+ return void 0;
9628
9774
  }
9629
- if (lastUserMessage?.content && typeof lastUserMessage.content === "string") {
9775
+ if (typeof lastUserMessage.content === "string") {
9630
9776
  const content = lastUserMessage.content.trim();
9631
9777
  return content.length > 0 ? content : void 0;
9632
9778
  }
9779
+ if (Array.isArray(lastUserMessage.content)) {
9780
+ const textParts = lastUserMessage.content.filter((part) => part.type === "text" && typeof part.text === "string").map((part) => part.text.trim()).filter(Boolean);
9781
+ if (textParts.length > 0) return textParts.join(" ");
9782
+ }
9633
9783
  return void 0;
9634
9784
  }
9635
9785
  /**
@@ -9701,9 +9851,10 @@ var Agent = class {
9701
9851
  }
9702
9852
  );
9703
9853
  }
9854
+ const inputForMemory = typeof input === "string" ? input : Array.isArray(input) && input[0]?.parts ? input : convertModelMessagesToUIMessages(input);
9704
9855
  const result = await this.memoryManager.prepareConversationContext(
9705
9856
  oc,
9706
- input,
9857
+ inputForMemory,
9707
9858
  oc.userId,
9708
9859
  oc.conversationId,
9709
9860
  options?.contextLimit
@@ -9723,7 +9874,8 @@ var Agent = class {
9723
9874
  messages.push(...memoryResult);
9724
9875
  if (isSemanticSearch && oc.userId && oc.conversationId) {
9725
9876
  try {
9726
- this.memoryManager.queueSaveInput(oc, input, oc.userId, oc.conversationId);
9877
+ const inputForMemory = typeof input === "string" ? input : Array.isArray(input) && input[0]?.parts ? input : convertModelMessagesToUIMessages(input);
9878
+ this.memoryManager.queueSaveInput(oc, inputForMemory, oc.userId, oc.conversationId);
9727
9879
  } catch (_e) {
9728
9880
  }
9729
9881
  }
@@ -9741,8 +9893,13 @@ var Agent = class {
9741
9893
  role: "user",
9742
9894
  parts: [{ type: "text", text: input }]
9743
9895
  });
9744
- } else {
9745
- messages.push(...input);
9896
+ } else if (Array.isArray(input)) {
9897
+ const first = input[0];
9898
+ if (first && Array.isArray(first.parts)) {
9899
+ messages.push(...input);
9900
+ } else {
9901
+ messages.push(...convertModelMessagesToUIMessages(input));
9902
+ }
9746
9903
  }
9747
9904
  const hooks = this.getMergedHooks(options);
9748
9905
  if (hooks.onPrepareMessages) {
@@ -9957,7 +10114,7 @@ ${toolkit.instructions}`;
9957
10114
  }
9958
10115
  });
9959
10116
  try {
9960
- const retrieverInput = typeof input === "string" ? input : (0, import_ai.convertToModelMessages)(input);
10117
+ const retrieverInput = typeof input === "string" ? input : Array.isArray(input) && input[0]?.content !== void 0 ? input : (0, import_ai.convertToModelMessages)(input);
9961
10118
  const retrievedContent = await oc.traceContext.withSpan(retrieverSpan, async () => {
9962
10119
  if (!this.retriever) return null;
9963
10120
  return await this.retriever.retrieve(retrieverInput, {
@@ -12701,7 +12858,6 @@ var VoltAgent = class {
12701
12858
  agentRegistry: this.registry,
12702
12859
  workflowRegistry: this.workflowRegistry,
12703
12860
  logger: this.logger,
12704
- // telemetryExporter removed - migrated to OpenTelemetry
12705
12861
  voltOpsClient: this.registry.getGlobalVoltOpsClient(),
12706
12862
  observability: this.observability
12707
12863
  });