'use strict';

var chunkPFKYMKIH_cjs = require('./chunk-PFKYMKIH.cjs');
var chunkDIG2K5CV_cjs = require('./chunk-DIG2K5CV.cjs');
var v4 = require('zod/v4');

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

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