import { defaultOptionsSchema } from './chunk-TKP6FJQ3.js';
import { tracingOptionsSchema, coreMessageSchema, messageResponseSchema } from './chunk-2YY3EMMS.js';
import { z } from 'zod/v4';

var jsonValueSchema = z.lazy(
  () => z.union([
    z.string(),
    z.number(),
    z.boolean(),
    z.null(),
    z.array(jsonValueSchema),
    z.record(z.string(), jsonValueSchema)
  ])
);
var jsonRecordSchema = z.record(z.string(), jsonValueSchema);
var commonMessageFieldsSchema = {
  id: z.string().optional(),
  name: z.string().optional(),
  metadata: jsonRecordSchema.optional(),
  providerMetadata: jsonRecordSchema.optional(),
  providerOptions: jsonRecordSchema.optional(),
  experimental_providerMetadata: jsonRecordSchema.optional()
};
var textContentPartSchema = z.object({
  ...commonMessageFieldsSchema,
  type: z.literal("text"),
  text: z.string()
});
var imageContentPartSchema = z.object({
  ...commonMessageFieldsSchema,
  type: z.literal("image"),
  image: z.union([z.string(), jsonRecordSchema]),
  mediaType: z.string().optional(),
  mimeType: z.string().optional()
});
var fileContentPartSchema = z.object({
  ...commonMessageFieldsSchema,
  type: z.literal("file"),
  data: z.union([z.string(), jsonRecordSchema]).optional(),
  file: z.union([z.string(), jsonRecordSchema]).optional(),
  url: z.string().optional(),
  mediaType: z.string().optional(),
  mimeType: z.string().optional(),
  filename: z.string().optional()
});
var toolCallContentPartSchema = z.object({
  ...commonMessageFieldsSchema,
  type: z.literal("tool-call"),
  toolCallId: z.string(),
  toolName: z.string(),
  args: jsonValueSchema.optional(),
  input: jsonValueSchema.optional()
});
var toolResultContentPartSchema = z.object({
  ...commonMessageFieldsSchema,
  type: z.literal("tool-result"),
  toolCallId: z.string(),
  toolName: z.string().optional(),
  result: jsonValueSchema.optional(),
  output: jsonValueSchema.optional()
});
var messageContentPartSchema = z.union([
  textContentPartSchema,
  imageContentPartSchema,
  fileContentPartSchema,
  toolCallContentPartSchema,
  toolResultContentPartSchema
]);
var messageContentSchema = z.union([z.string(), z.array(messageContentPartSchema)]);
var modelMessageSchema = z.object({
  ...commonMessageFieldsSchema,
  role: z.enum(["system", "user", "assistant", "tool"]),
  content: messageContentSchema
});
var uiMessageSchema = z.object({
  ...commonMessageFieldsSchema,
  role: z.enum(["system", "user", "assistant", "tool", "data"]),
  content: messageContentSchema.optional(),
  parts: z.array(messageContentPartSchema).optional(),
  createdAt: z.union([z.string(), z.date()]).optional()
});
var mastraDBMessagePartSchema = z.object({ type: z.string() }).passthrough();
var mastraDBMessageContentSchema = z.object({
  format: z.literal(2),
  parts: z.array(mastraDBMessagePartSchema),
  content: messageContentSchema.optional(),
  experimental_attachments: z.array(jsonRecordSchema).optional(),
  toolInvocations: z.array(jsonRecordSchema).optional(),
  reasoning: z.string().optional(),
  annotations: z.array(jsonValueSchema).optional(),
  metadata: jsonRecordSchema.optional(),
  providerMetadata: jsonRecordSchema.optional()
}).passthrough();
var mastraDBMessageSchema = z.object({
  id: z.string(),
  role: z.enum(["system", "user", "assistant", "signal"]),
  createdAt: z.union([z.string(), z.date()]),
  threadId: z.string().optional(),
  resourceId: z.string().optional(),
  type: z.string().optional(),
  content: mastraDBMessageContentSchema
});
var messageInputSchema = z.union([modelMessageSchema, uiMessageSchema, mastraDBMessageSchema]);
var messageListInputSchema = z.union([
  z.string(),
  z.array(z.string()),
  messageInputSchema,
  z.array(messageInputSchema)
]);
var signalAttributesSchema = z.record(
  z.string(),
  z.union([z.string(), z.number(), z.boolean(), z.null(), z.undefined()])
);
var baseSignalSchema = z.object({
  id: z.string().optional(),
  createdAt: z.union([z.string(), z.date()]).optional(),
  metadata: jsonRecordSchema.optional(),
  attributes: signalAttributesSchema.optional()
});
var userMessageSignalSchema = baseSignalSchema.extend({
  type: z.literal("user-message"),
  contents: messageListInputSchema
});
var contextSignalSchema = baseSignalSchema.extend({
  type: z.string().refine((type) => type !== "user-message", {
    message: 'non-user-message signals must not use type "user-message"'
  }),
  contents: z.string()
});
var agentSignalSchema = z.union([userMessageSignalSchema, contextSignalSchema]);
var agentIdPathParams = z.object({
  agentId: z.string().describe("Unique identifier for the agent")
});
var agentVersionQuerySchema = z.object({
  status: z.enum(["draft", "published"]).optional().describe(
    "Which stored config version to resolve: draft (latest, default) or published (active version). Mutually exclusive with versionId."
  ),
  versionId: z.string().optional().describe(
    "Specific version ID to resolve. Mutually exclusive with status \u2014 if both are provided, versionId takes precedence."
  )
});
var toolIdPathParams = z.object({
  toolId: z.string().describe("Unique identifier for the tool")
});
var agentToolPathParams = agentIdPathParams.extend({
  toolId: z.string().describe("Unique identifier for the tool")
});
var agentSkillPathParams = agentIdPathParams.extend({
  skillName: z.string().describe("Name of the skill")
});
var modelConfigIdPathParams = agentIdPathParams.extend({
  modelConfigId: z.string().describe("Unique identifier for the model configuration")
});
var serializedProcessorSchema = z.object({
  id: z.string(),
  name: z.string().optional()
});
var serializedToolSchema = z.object({
  id: z.string(),
  description: z.string().optional(),
  inputSchema: z.string().optional(),
  outputSchema: z.string().optional(),
  requireApproval: z.boolean().optional()
});
var serializedWorkflowSchema = z.object({
  name: z.string(),
  steps: z.record(
    z.string(),
    z.object({
      id: z.string(),
      description: z.string().optional()
    })
  ).optional()
});
var serializedAgentDefinitionSchema = z.object({
  id: z.string(),
  name: z.string()
});
var systemMessageSchema = z.union([
  z.string(),
  z.array(z.string()),
  z.any(),
  // CoreSystemMessage or SystemModelMessage
  z.array(z.any())
]);
var modelConfigSchema = z.object({
  model: z.object({
    modelId: z.string(),
    provider: z.string(),
    modelVersion: z.string()
  })
  // Additional fields from AgentModelManagerConfig can be added here
});
var serializedAgentSchema = z.object({
  name: z.string(),
  description: z.string().optional(),
  metadata: z.record(z.string(), z.unknown()).optional(),
  instructions: systemMessageSchema.optional(),
  tools: z.record(z.string(), serializedToolSchema),
  agents: z.record(z.string(), serializedAgentDefinitionSchema),
  workflows: z.record(z.string(), serializedWorkflowSchema),
  inputProcessors: z.array(serializedProcessorSchema),
  outputProcessors: z.array(serializedProcessorSchema),
  provider: z.string().optional(),
  modelId: z.string().optional(),
  modelVersion: z.string().optional(),
  modelList: z.array(modelConfigSchema).optional(),
  defaultOptions: defaultOptionsSchema.optional(),
  defaultGenerateOptionsLegacy: z.record(z.string(), z.any()).optional(),
  defaultStreamOptionsLegacy: z.record(z.string(), z.any()).optional(),
  status: z.enum(["draft", "published", "archived"]).optional(),
  activeVersionId: z.string().optional(),
  hasDraft: z.boolean().optional()
});
var serializedAgentWithIdSchema = serializedAgentSchema.extend({
  id: z.string()
});
var providerSchema = z.object({
  id: z.string(),
  name: z.string(),
  label: z.string().optional(),
  description: z.string().optional()
});
var providersResponseSchema = z.object({
  providers: z.array(providerSchema)
});
var listAgentsResponseSchema = z.record(z.string(), serializedAgentSchema);
var listToolsResponseSchema = z.record(z.string(), serializedToolSchema);
var agentMemoryOptionSchema = z.object({
  thread: z.union([z.string(), z.object({ id: z.string() }).passthrough()]),
  resource: z.string(),
  options: z.record(z.string(), z.any()).optional(),
  readOnly: z.boolean().optional()
});
var toolChoiceSchema = z.union([
  z.enum(["auto", "none", "required"]),
  z.object({ type: z.literal("tool"), toolName: z.string() })
]);
var agentExecutionBodySchema = z.object({
  // REQUIRED
  messages: z.union([
    z.array(coreMessageSchema),
    // Array of messages
    z.string()
    // Single user message shorthand
  ]),
  // Message Configuration
  instructions: systemMessageSchema.optional(),
  system: systemMessageSchema.optional(),
  context: z.array(coreMessageSchema).optional(),
  // Memory & Persistence
  memory: agentMemoryOptionSchema.optional(),
  runId: z.string().optional(),
  savePerStep: z.boolean().optional(),
  // Request Context (handler-specific field - merged with server's requestContext)
  requestContext: z.record(z.string(), z.any()).optional(),
  // Version overrides for sub-agents (and future primitives)
  versions: z.object({
    agents: z.record(
      z.string(),
      z.union([z.object({ versionId: z.string() }), z.object({ status: z.enum(["draft", "published"]) })])
    ).optional()
  }).optional(),
  // Execution Control
  maxSteps: z.number().optional(),
  stopWhen: z.any().optional(),
  // Model Configuration
  providerOptions: z.object({
    anthropic: z.record(z.string(), z.any()).optional(),
    google: z.record(z.string(), z.any()).optional(),
    openai: z.record(z.string(), z.any()).optional(),
    xai: z.record(z.string(), z.any()).optional()
  }).optional(),
  modelSettings: z.any().optional(),
  // Tool Configuration
  activeTools: z.array(z.string()).optional(),
  toolsets: z.record(z.string(), z.any()).optional(),
  clientTools: z.record(z.string(), z.any()).optional(),
  toolChoice: toolChoiceSchema.optional(),
  requireToolApproval: z.boolean().optional(),
  // Evaluation
  scorers: z.union([
    z.record(z.string(), z.any()),
    z.record(
      z.string(),
      z.object({
        scorer: z.string(),
        sampling: z.any().optional()
      })
    )
  ]).optional(),
  returnScorerData: z.boolean().optional(),
  // Observability
  tracingOptions: tracingOptionsSchema.optional(),
  // Structured Output
  output: z.any().optional(),
  // Zod schema, JSON schema, or structured output object
  structuredOutput: z.object({
    schema: z.object({}).passthrough(),
    model: z.union([z.string(), z.any()]).optional(),
    instructions: z.string().optional(),
    jsonPromptInjection: z.boolean().optional(),
    errorStrategy: z.enum(["strict", "warn", "fallback"]).optional(),
    fallbackValue: z.any().optional()
  }).optional()
}).passthrough();
var agentExecutionLegacyBodySchema = agentExecutionBodySchema.extend({
  resourceId: z.string().optional(),
  resourceid: z.string().optional(),
  // lowercase variant
  threadId: z.string().optional()
});
var streamUntilIdleBodySchema = agentExecutionBodySchema.extend({
  maxIdleMs: z.number().int().positive().optional()
});
var resumeStreamUntilIdleBodySchema = agentExecutionBodySchema.omit({ messages: true }).extend({
  runId: z.string(),
  resumeData: z.unknown().refine((x) => x !== void 0, { message: "resumeData is required" }),
  toolCallId: z.string().optional(),
  maxIdleMs: z.number().int().positive().optional()
});
var executeToolDataBodySchema = z.object({
  data: z.unknown().refine((x) => x !== void 0, { message: "data is required" })
});
var executeToolBodySchema = executeToolDataBodySchema.extend({
  requestContext: z.record(z.string(), z.any()).optional()
});
var executeToolContextBodySchema = executeToolDataBodySchema.extend({
  requestContext: z.record(z.string(), z.any()).optional()
});
var voiceSpeakersResponseSchema = z.array(
  z.object({
    voiceId: z.string()
  }).passthrough()
  // Allow provider-specific fields like name, language, etc.
);
var toolCallActionBodySchema = z.object({
  runId: z.string(),
  requestContext: z.record(z.string(), z.any()).optional(),
  toolCallId: z.string(),
  format: z.string().optional()
});
var networkToolCallActionBodySchema = z.object({
  runId: z.string(),
  requestContext: z.record(z.string(), z.any()).optional(),
  format: z.string().optional()
});
var approveToolCallBodySchema = toolCallActionBodySchema;
var declineToolCallBodySchema = toolCallActionBodySchema;
var approveNetworkToolCallBodySchema = networkToolCallActionBodySchema;
var declineNetworkToolCallBodySchema = networkToolCallActionBodySchema;
var toolCallResponseSchema = z.object({
  fullStream: z.any()
  // ReadableStream
});
var resumeStreamBodySchema = agentExecutionBodySchema.omit({ messages: true }).extend({
  runId: z.string(),
  resumeData: z.unknown().refine((x) => x !== void 0, { message: "resumeData is required" }),
  toolCallId: z.string().optional()
});
var updateAgentModelBodySchema = z.object({
  modelId: z.string(),
  provider: z.string()
});
var reorderAgentModelListBodySchema = z.object({
  reorderedModelIds: z.array(z.string())
});
var updateAgentModelInModelListBodySchema = z.object({
  model: z.object({
    modelId: z.string(),
    provider: z.string()
  }).optional(),
  maxRetries: z.number().optional(),
  enabled: z.boolean().optional()
});
var modelManagementResponseSchema = messageResponseSchema;
var generateSpeechBodySchema = z.object({
  text: z.string(),
  speakerId: z.string().optional()
});
var transcribeSpeechBodySchema = z.object({
  audio: z.any(),
  // Buffer
  options: z.record(z.string(), z.any()).optional()
});
var transcribeSpeechResponseSchema = z.object({
  text: z.string()
});
var getListenerResponseSchema = z.any();
var generateResponseSchema = z.any();
var streamResponseSchema = z.any();
var speakResponseSchema = z.any();
var executeToolResponseSchema = z.any();
var enhanceInstructionsBodySchema = z.object({
  instructions: z.string().describe("The current agent instructions to enhance"),
  comment: z.string().describe("User comment describing how to enhance the instructions")
});
var enhanceInstructionsResponseSchema = z.object({
  explanation: z.string().describe("Explanation of the changes made"),
  new_prompt: z.string().describe("The enhanced instructions")
});
var observeAgentBodySchema = z.object({
  runId: z.string().describe("The run ID to observe/reconnect to"),
  offset: z.number().optional().describe("Resume from this event index (0-based). If omitted, replays all events.")
});
var signalActiveBehaviorSchema = z.enum(["deliver", "persist", "discard"]);
var signalIdleBehaviorSchema = z.enum(["wake", "persist", "discard"]);
var sendAgentSignalBaseBodySchema = z.object({
  signal: agentSignalSchema,
  ifActive: z.object({
    behavior: signalActiveBehaviorSchema.optional()
  }).optional()
});
var sendAgentSignalBodySchema = z.union([
  sendAgentSignalBaseBodySchema.extend({
    runId: z.string(),
    resourceId: z.string().optional(),
    threadId: z.string().optional(),
    ifIdle: z.undefined().optional()
  }),
  sendAgentSignalBaseBodySchema.extend({
    runId: z.string().optional(),
    resourceId: z.string(),
    threadId: z.string(),
    ifIdle: z.object({
      behavior: signalIdleBehaviorSchema.optional(),
      streamOptions: agentExecutionBodySchema.omit({ messages: true }).optional()
    }).optional()
  })
]);
var subscribeAgentThreadBodySchema = z.object({
  resourceId: z.string().optional(),
  threadId: z.string()
});
var observeAgentResponseSchema = z.any();

export { agentExecutionBodySchema, agentExecutionLegacyBodySchema, agentIdPathParams, agentSkillPathParams, agentToolPathParams, agentVersionQuerySchema, approveNetworkToolCallBodySchema, approveToolCallBodySchema, declineNetworkToolCallBodySchema, declineToolCallBodySchema, enhanceInstructionsBodySchema, enhanceInstructionsResponseSchema, executeToolBodySchema, executeToolContextBodySchema, executeToolResponseSchema, generateResponseSchema, generateSpeechBodySchema, getListenerResponseSchema, listAgentsResponseSchema, listToolsResponseSchema, modelConfigIdPathParams, modelManagementResponseSchema, observeAgentBodySchema, observeAgentResponseSchema, providerSchema, providersResponseSchema, reorderAgentModelListBodySchema, resumeStreamBodySchema, resumeStreamUntilIdleBodySchema, sendAgentSignalBodySchema, serializedAgentDefinitionSchema, serializedAgentSchema, serializedAgentWithIdSchema, serializedProcessorSchema, serializedToolSchema, serializedWorkflowSchema, speakResponseSchema, streamResponseSchema, streamUntilIdleBodySchema, subscribeAgentThreadBodySchema, toolCallResponseSchema, toolIdPathParams, transcribeSpeechBodySchema, transcribeSpeechResponseSchema, updateAgentModelBodySchema, updateAgentModelInModelListBodySchema, voiceSpeakersResponseSchema };
//# sourceMappingURL=chunk-HPSSFPDP.js.map
//# sourceMappingURL=chunk-HPSSFPDP.js.map