'use strict';

var chunkRJPRSDIS_cjs = require('./chunk-RJPRSDIS.cjs');
var chunkS6TNTR3A_cjs = require('./chunk-S6TNTR3A.cjs');
var chunkPTPMBE6M_cjs = require('./chunk-PTPMBE6M.cjs');
var chunkZQ4GVMYG_cjs = require('./chunk-ZQ4GVMYG.cjs');
var chunkDIG2K5CV_cjs = require('./chunk-DIG2K5CV.cjs');
var chunkDRDVJ35H_cjs = require('./chunk-DRDVJ35H.cjs');
var chunkZ7LCIYK7_cjs = require('./chunk-Z7LCIYK7.cjs');
var chunkN54Q3AQR_cjs = require('./chunk-N54Q3AQR.cjs');
var chunk64ITUOXI_cjs = require('./chunk-64ITUOXI.cjs');
var chunkO7I5CWRX_cjs = require('./chunk-O7I5CWRX.cjs');

// src/server/handlers/agent-builder.ts
var agent_builder_exports = {};
chunkO7I5CWRX_cjs.__export(agent_builder_exports, {
  CANCEL_AGENT_BUILDER_ACTION_RUN_ROUTE: () => CANCEL_AGENT_BUILDER_ACTION_RUN_ROUTE,
  CREATE_AGENT_BUILDER_ACTION_RUN_ROUTE: () => CREATE_AGENT_BUILDER_ACTION_RUN_ROUTE,
  GET_AGENT_BUILDER_ACTION_BY_ID_ROUTE: () => GET_AGENT_BUILDER_ACTION_BY_ID_ROUTE,
  GET_AGENT_BUILDER_ACTION_RUN_BY_ID_ROUTE: () => GET_AGENT_BUILDER_ACTION_RUN_BY_ID_ROUTE,
  LIST_AGENT_BUILDER_ACTIONS_ROUTE: () => LIST_AGENT_BUILDER_ACTIONS_ROUTE,
  LIST_AGENT_BUILDER_ACTION_RUNS_ROUTE: () => LIST_AGENT_BUILDER_ACTION_RUNS_ROUTE,
  OBSERVE_STREAM_AGENT_BUILDER_ACTION_ROUTE: () => OBSERVE_STREAM_AGENT_BUILDER_ACTION_ROUTE,
  OBSERVE_STREAM_LEGACY_AGENT_BUILDER_ACTION_ROUTE: () => OBSERVE_STREAM_LEGACY_AGENT_BUILDER_ACTION_ROUTE,
  RESUME_AGENT_BUILDER_ACTION_ROUTE: () => RESUME_AGENT_BUILDER_ACTION_ROUTE,
  RESUME_ASYNC_AGENT_BUILDER_ACTION_ROUTE: () => RESUME_ASYNC_AGENT_BUILDER_ACTION_ROUTE,
  RESUME_NO_WAIT_AGENT_BUILDER_ACTION_ROUTE: () => RESUME_NO_WAIT_AGENT_BUILDER_ACTION_ROUTE,
  RESUME_STREAM_AGENT_BUILDER_ACTION_ROUTE: () => RESUME_STREAM_AGENT_BUILDER_ACTION_ROUTE,
  START_AGENT_BUILDER_ACTION_RUN_ROUTE: () => START_AGENT_BUILDER_ACTION_RUN_ROUTE,
  START_ASYNC_AGENT_BUILDER_ACTION_ROUTE: () => START_ASYNC_AGENT_BUILDER_ACTION_ROUTE,
  STREAM_AGENT_BUILDER_ACTION_ROUTE: () => STREAM_AGENT_BUILDER_ACTION_ROUTE,
  STREAM_LEGACY_AGENT_BUILDER_ACTION_ROUTE: () => STREAM_LEGACY_AGENT_BUILDER_ACTION_ROUTE
});
var agentBuilderWorkflowsPromise;
async function loadAgentBuilderWorkflows() {
  agentBuilderWorkflowsPromise ??= import('./dist-RKXUXSLD.cjs').then((mod) => mod.agentBuilderWorkflows);
  return agentBuilderWorkflowsPromise;
}
async function registerAgentBuilderWorkflows(mastra) {
  const agentBuilderWorkflows = await loadAgentBuilderWorkflows();
  chunkDRDVJ35H_cjs.WorkflowRegistry.registerTemporaryWorkflows(agentBuilderWorkflows, mastra);
  return agentBuilderWorkflows;
}
var LIST_AGENT_BUILDER_ACTIONS_ROUTE = chunkN54Q3AQR_cjs.createRoute({
  method: "GET",
  path: "/agent-builder",
  responseType: "json",
  responseSchema: chunkPTPMBE6M_cjs.listWorkflowsResponseSchema,
  summary: "List agent-builder actions",
  description: "Returns a list of all available agent-builder actions",
  tags: ["Agent Builder"],
  requiresAuth: true,
  handler: async (ctx) => {
    const { mastra } = ctx;
    const logger = mastra.getLogger();
    try {
      await registerAgentBuilderWorkflows(mastra);
      logger.info("Listing agent builder actions");
      return await chunkRJPRSDIS_cjs.LIST_WORKFLOWS_ROUTE.handler(ctx);
    } catch (error) {
      logger.error("Error listing agent builder actions", { error });
      return chunkZ7LCIYK7_cjs.handleError(error, "Error getting agent builder workflows");
    } finally {
      chunkDRDVJ35H_cjs.WorkflowRegistry.cleanup();
    }
  }
});
var GET_AGENT_BUILDER_ACTION_BY_ID_ROUTE = chunkN54Q3AQR_cjs.createRoute({
  method: "GET",
  path: "/agent-builder/:actionId",
  responseType: "json",
  pathParamSchema: chunkS6TNTR3A_cjs.actionIdPathParams,
  responseSchema: chunkPTPMBE6M_cjs.workflowInfoSchema,
  summary: "Get action by ID",
  description: "Returns details for a specific agent-builder action",
  tags: ["Agent Builder"],
  requiresAuth: true,
  handler: async (ctx) => {
    const { mastra, actionId } = ctx;
    const logger = mastra.getLogger();
    try {
      const agentBuilderWorkflows = await registerAgentBuilderWorkflows(mastra);
      if (actionId && !chunkDRDVJ35H_cjs.WorkflowRegistry.isAgentBuilderWorkflow(actionId)) {
        throw new chunk64ITUOXI_cjs.HTTPException(400, {
          message: `Invalid agent-builder action: ${actionId}. Valid actions are: ${Object.keys(agentBuilderWorkflows).join(", ")}`
        });
      }
      logger.info("Getting agent builder action by ID", { actionId });
      return await chunkRJPRSDIS_cjs.GET_WORKFLOW_BY_ID_ROUTE.handler({ ...ctx, workflowId: actionId });
    } catch (error) {
      logger.error("Error getting agent builder action by ID", { error, actionId });
      return chunkZ7LCIYK7_cjs.handleError(error, "Error getting agent builder action");
    } finally {
      chunkDRDVJ35H_cjs.WorkflowRegistry.cleanup();
    }
  }
});
var LIST_AGENT_BUILDER_ACTION_RUNS_ROUTE = chunkN54Q3AQR_cjs.createRoute({
  method: "GET",
  path: "/agent-builder/:actionId/runs",
  responseType: "json",
  pathParamSchema: chunkS6TNTR3A_cjs.actionIdPathParams,
  queryParamSchema: chunkPTPMBE6M_cjs.listWorkflowRunsQuerySchema,
  responseSchema: chunkPTPMBE6M_cjs.workflowRunsResponseSchema,
  summary: "List action runs",
  description: "Returns a paginated list of execution runs for the specified action",
  tags: ["Agent Builder"],
  requiresAuth: true,
  handler: async (ctx) => {
    const { mastra, actionId } = ctx;
    const logger = mastra.getLogger();
    try {
      await registerAgentBuilderWorkflows(mastra);
      if (actionId && !chunkDRDVJ35H_cjs.WorkflowRegistry.isAgentBuilderWorkflow(actionId)) {
        throw new chunk64ITUOXI_cjs.HTTPException(400, { message: `Invalid agent-builder action: ${actionId}` });
      }
      logger.info("Listing agent builder action runs", { actionId });
      return await chunkRJPRSDIS_cjs.LIST_WORKFLOW_RUNS_ROUTE.handler({
        ...ctx,
        workflowId: actionId
      });
    } catch (error) {
      logger.error("Error listing agent builder action runs", { error, actionId });
      return chunkZ7LCIYK7_cjs.handleError(error, "Error getting agent builder action runs");
    } finally {
      chunkDRDVJ35H_cjs.WorkflowRegistry.cleanup();
    }
  }
});
var GET_AGENT_BUILDER_ACTION_RUN_BY_ID_ROUTE = chunkN54Q3AQR_cjs.createRoute({
  method: "GET",
  path: "/agent-builder/:actionId/runs/:runId",
  responseType: "json",
  pathParamSchema: chunkS6TNTR3A_cjs.actionRunPathParams,
  queryParamSchema: chunkPTPMBE6M_cjs.workflowRunResultQuerySchema,
  responseSchema: chunkPTPMBE6M_cjs.workflowRunResultSchema,
  summary: "Get action run by ID",
  description: "Returns details for a specific action run with metadata and processed execution state. Use the fields query parameter to reduce payload size.",
  tags: ["Agent Builder"],
  requiresAuth: true,
  handler: async (ctx) => {
    const { mastra, actionId, runId } = ctx;
    const logger = mastra.getLogger();
    try {
      await registerAgentBuilderWorkflows(mastra);
      if (actionId && !chunkDRDVJ35H_cjs.WorkflowRegistry.isAgentBuilderWorkflow(actionId)) {
        throw new chunk64ITUOXI_cjs.HTTPException(400, { message: `Invalid agent-builder action: ${actionId}` });
      }
      logger.info("Getting agent builder action run by ID", { actionId, runId });
      return await chunkRJPRSDIS_cjs.GET_WORKFLOW_RUN_BY_ID_ROUTE.handler({
        ...ctx,
        workflowId: actionId
      });
    } catch (error) {
      logger.error("Error getting agent builder action run", { error, actionId, runId });
      return chunkZ7LCIYK7_cjs.handleError(error, "Error getting agent builder action run");
    } finally {
      chunkDRDVJ35H_cjs.WorkflowRegistry.cleanup();
    }
  }
});
var CREATE_AGENT_BUILDER_ACTION_RUN_ROUTE = chunkN54Q3AQR_cjs.createRoute({
  method: "POST",
  path: "/agent-builder/:actionId/create-run",
  responseType: "json",
  pathParamSchema: chunkS6TNTR3A_cjs.actionIdPathParams,
  queryParamSchema: chunkDIG2K5CV_cjs.optionalRunIdSchema,
  responseSchema: chunkPTPMBE6M_cjs.createWorkflowRunResponseSchema,
  summary: "Create action run",
  description: "Creates a new action execution instance with an optional custom run ID",
  tags: ["Agent Builder"],
  requiresAuth: true,
  handler: async (ctx) => {
    const { mastra, actionId, runId } = ctx;
    const logger = mastra.getLogger();
    try {
      await registerAgentBuilderWorkflows(mastra);
      if (actionId && !chunkDRDVJ35H_cjs.WorkflowRegistry.isAgentBuilderWorkflow(actionId)) {
        throw new chunk64ITUOXI_cjs.HTTPException(400, { message: `Invalid agent-builder action: ${actionId}` });
      }
      logger.info("Creating agent builder action run", { actionId, runId });
      return await chunkRJPRSDIS_cjs.CREATE_WORKFLOW_RUN_ROUTE.handler({
        ...ctx,
        workflowId: actionId
      });
    } catch (error) {
      logger.error("Error creating agent builder action run", { error, actionId });
      return chunkZ7LCIYK7_cjs.handleError(error, "Error creating agent builder action run");
    } finally {
      chunkDRDVJ35H_cjs.WorkflowRegistry.cleanup();
    }
  }
});
var STREAM_AGENT_BUILDER_ACTION_ROUTE = chunkN54Q3AQR_cjs.createRoute({
  method: "POST",
  path: "/agent-builder/:actionId/stream",
  responseType: "stream",
  pathParamSchema: chunkS6TNTR3A_cjs.actionIdPathParams,
  queryParamSchema: chunkDIG2K5CV_cjs.runIdSchema,
  bodySchema: chunkS6TNTR3A_cjs.streamAgentBuilderBodySchema,
  responseSchema: chunkZQ4GVMYG_cjs.streamResponseSchema,
  summary: "Stream action execution",
  description: "Executes an action and streams the results in real-time",
  tags: ["Agent Builder"],
  requiresAuth: true,
  handler: async (ctx) => {
    const { mastra, actionId, runId, requestContext } = ctx;
    const logger = mastra.getLogger();
    try {
      await registerAgentBuilderWorkflows(mastra);
      if (actionId && !chunkDRDVJ35H_cjs.WorkflowRegistry.isAgentBuilderWorkflow(actionId)) {
        throw new chunk64ITUOXI_cjs.HTTPException(400, { message: `Invalid agent-builder action: ${actionId}` });
      }
      logger.info("Streaming agent builder action", { actionId, runId });
      return await chunkRJPRSDIS_cjs.STREAM_WORKFLOW_ROUTE.handler({
        ...ctx,
        workflowId: actionId,
        requestContext
      });
    } catch (error) {
      logger.error("Error streaming agent builder action", { error, actionId });
      return chunkZ7LCIYK7_cjs.handleError(error, "Error streaming agent builder action");
    } finally {
      chunkDRDVJ35H_cjs.WorkflowRegistry.cleanup();
    }
  }
});
var START_ASYNC_AGENT_BUILDER_ACTION_ROUTE = chunkN54Q3AQR_cjs.createRoute({
  method: "POST",
  path: "/agent-builder/:actionId/start-async",
  responseType: "json",
  pathParamSchema: chunkS6TNTR3A_cjs.actionIdPathParams,
  queryParamSchema: chunkDIG2K5CV_cjs.optionalRunIdSchema,
  bodySchema: chunkS6TNTR3A_cjs.startAsyncAgentBuilderBodySchema,
  responseSchema: chunkPTPMBE6M_cjs.workflowExecutionResultSchema,
  summary: "Start action asynchronously",
  description: "Starts an action execution asynchronously without streaming results",
  tags: ["Agent Builder"],
  requiresAuth: true,
  handler: async (ctx) => {
    const { mastra, actionId, runId, requestContext } = ctx;
    const logger = mastra.getLogger();
    try {
      await registerAgentBuilderWorkflows(mastra);
      if (actionId && !chunkDRDVJ35H_cjs.WorkflowRegistry.isAgentBuilderWorkflow(actionId)) {
        throw new chunk64ITUOXI_cjs.HTTPException(400, { message: `Invalid agent-builder action: ${actionId}` });
      }
      logger.info("Starting agent builder action asynchronously", { actionId, runId });
      return await chunkRJPRSDIS_cjs.START_ASYNC_WORKFLOW_ROUTE.handler({
        ...ctx,
        workflowId: actionId,
        requestContext
      });
    } catch (error) {
      logger.error("Error starting agent builder action asynchronously", { error, actionId });
      return chunkZ7LCIYK7_cjs.handleError(error, "Error starting agent builder action");
    } finally {
      chunkDRDVJ35H_cjs.WorkflowRegistry.cleanup();
    }
  }
});
var START_AGENT_BUILDER_ACTION_RUN_ROUTE = chunkN54Q3AQR_cjs.createRoute({
  method: "POST",
  path: "/agent-builder/:actionId/start",
  responseType: "json",
  pathParamSchema: chunkS6TNTR3A_cjs.actionIdPathParams,
  queryParamSchema: chunkDIG2K5CV_cjs.runIdSchema,
  bodySchema: chunkS6TNTR3A_cjs.startAsyncAgentBuilderBodySchema,
  responseSchema: chunkPTPMBE6M_cjs.workflowControlResponseSchema,
  summary: "Start specific action run",
  description: "Starts execution of a specific action run by ID",
  tags: ["Agent Builder"],
  requiresAuth: true,
  handler: async (ctx) => {
    const { mastra, actionId, runId, requestContext } = ctx;
    const logger = mastra.getLogger();
    try {
      await registerAgentBuilderWorkflows(mastra);
      if (actionId && !chunkDRDVJ35H_cjs.WorkflowRegistry.isAgentBuilderWorkflow(actionId)) {
        throw new chunk64ITUOXI_cjs.HTTPException(400, { message: `Invalid agent-builder action: ${actionId}` });
      }
      logger.info("Starting specific agent builder action run", { actionId, runId });
      return await chunkRJPRSDIS_cjs.START_WORKFLOW_RUN_ROUTE.handler({
        ...ctx,
        workflowId: actionId,
        requestContext
      });
    } catch (error) {
      logger.error("Error starting agent builder action run", { error, actionId });
      return chunkZ7LCIYK7_cjs.handleError(error, "Error starting agent builder action run");
    } finally {
      chunkDRDVJ35H_cjs.WorkflowRegistry.cleanup();
    }
  }
});
var OBSERVE_STREAM_AGENT_BUILDER_ACTION_ROUTE = chunkN54Q3AQR_cjs.createRoute({
  method: "POST",
  path: "/agent-builder/:actionId/observe",
  responseType: "stream",
  pathParamSchema: chunkS6TNTR3A_cjs.actionIdPathParams,
  queryParamSchema: chunkDIG2K5CV_cjs.runIdSchema,
  responseSchema: chunkZQ4GVMYG_cjs.streamResponseSchema,
  summary: "Observe action stream",
  description: "Observes and streams updates from an already running action execution",
  tags: ["Agent Builder"],
  requiresAuth: true,
  handler: async (ctx) => {
    const { mastra, actionId, runId } = ctx;
    const logger = mastra.getLogger();
    try {
      await registerAgentBuilderWorkflows(mastra);
      if (actionId && !chunkDRDVJ35H_cjs.WorkflowRegistry.isAgentBuilderWorkflow(actionId)) {
        throw new chunk64ITUOXI_cjs.HTTPException(400, { message: `Invalid agent-builder action: ${actionId}` });
      }
      logger.info("Observing agent builder action stream", { actionId, runId });
      return await chunkRJPRSDIS_cjs.OBSERVE_STREAM_WORKFLOW_ROUTE.handler({
        ...ctx,
        workflowId: actionId
      });
    } catch (error) {
      logger.error("Error observing agent builder action stream", { error, actionId });
      return chunkZ7LCIYK7_cjs.handleError(error, "Error observing agent builder action stream");
    } finally {
      chunkDRDVJ35H_cjs.WorkflowRegistry.cleanup();
    }
  }
});
var RESUME_ASYNC_AGENT_BUILDER_ACTION_ROUTE = chunkN54Q3AQR_cjs.createRoute({
  method: "POST",
  path: "/agent-builder/:actionId/resume-async",
  responseType: "json",
  pathParamSchema: chunkS6TNTR3A_cjs.actionIdPathParams,
  queryParamSchema: chunkDIG2K5CV_cjs.runIdSchema,
  bodySchema: chunkS6TNTR3A_cjs.resumeAgentBuilderBodySchema,
  responseSchema: chunkPTPMBE6M_cjs.workflowExecutionResultSchema,
  summary: "Resume action asynchronously",
  description: "Resumes a suspended action execution asynchronously without streaming",
  tags: ["Agent Builder"],
  requiresAuth: true,
  handler: async (ctx) => {
    const { mastra, actionId, runId, step, requestContext } = ctx;
    const logger = mastra.getLogger();
    try {
      await registerAgentBuilderWorkflows(mastra);
      if (actionId && !chunkDRDVJ35H_cjs.WorkflowRegistry.isAgentBuilderWorkflow(actionId)) {
        throw new chunk64ITUOXI_cjs.HTTPException(400, { message: `Invalid agent-builder action: ${actionId}` });
      }
      logger.info("Resuming agent builder action asynchronously", { actionId, runId, step });
      return await chunkRJPRSDIS_cjs.RESUME_ASYNC_WORKFLOW_ROUTE.handler({
        ...ctx,
        workflowId: actionId,
        requestContext
      });
    } catch (error) {
      logger.error("Error resuming agent builder action asynchronously", { error, actionId });
      return chunkZ7LCIYK7_cjs.handleError(error, "Error resuming agent builder action");
    } finally {
      chunkDRDVJ35H_cjs.WorkflowRegistry.cleanup();
    }
  }
});
var RESUME_NO_WAIT_AGENT_BUILDER_ACTION_ROUTE = chunkN54Q3AQR_cjs.createRoute({
  method: "POST",
  path: "/agent-builder/:actionId/resume-no-wait",
  responseType: "json",
  pathParamSchema: chunkS6TNTR3A_cjs.actionIdPathParams,
  queryParamSchema: chunkDIG2K5CV_cjs.runIdSchema,
  bodySchema: chunkS6TNTR3A_cjs.resumeAgentBuilderBodySchema,
  responseSchema: chunkPTPMBE6M_cjs.createWorkflowRunResponseSchema,
  summary: "Resume action without waiting",
  description: "Resumes a suspended action execution without waiting (fire-and-forget) and returns immediately with the runId. The action continues executing in the background.",
  tags: ["Agent Builder"],
  requiresAuth: true,
  handler: async (ctx) => {
    const { mastra, actionId, runId, step, requestContext } = ctx;
    const logger = mastra.getLogger();
    try {
      await registerAgentBuilderWorkflows(mastra);
      if (actionId && !chunkDRDVJ35H_cjs.WorkflowRegistry.isAgentBuilderWorkflow(actionId)) {
        throw new chunk64ITUOXI_cjs.HTTPException(400, { message: `Invalid agent-builder action: ${actionId}` });
      }
      logger.info("Resuming agent builder action without waiting", { actionId, runId, step });
      return await chunkRJPRSDIS_cjs.RESUME_NO_WAIT_WORKFLOW_ROUTE.handler({
        ...ctx,
        workflowId: actionId,
        requestContext
      });
    } catch (error) {
      logger.error("Error resuming agent builder action without waiting", { error, actionId });
      return chunkZ7LCIYK7_cjs.handleError(error, "Error resuming agent builder action");
    } finally {
      chunkDRDVJ35H_cjs.WorkflowRegistry.cleanup();
    }
  }
});
var RESUME_AGENT_BUILDER_ACTION_ROUTE = chunkN54Q3AQR_cjs.createRoute({
  method: "POST",
  path: "/agent-builder/:actionId/resume",
  responseType: "json",
  pathParamSchema: chunkS6TNTR3A_cjs.actionIdPathParams,
  queryParamSchema: chunkDIG2K5CV_cjs.runIdSchema,
  bodySchema: chunkS6TNTR3A_cjs.resumeAgentBuilderBodySchema,
  responseSchema: chunkPTPMBE6M_cjs.workflowControlResponseSchema,
  summary: "Resume action",
  description: "Resumes a suspended action execution from a specific step",
  tags: ["Agent Builder"],
  requiresAuth: true,
  handler: async (ctx) => {
    const { mastra, actionId, runId, step, requestContext } = ctx;
    const logger = mastra.getLogger();
    try {
      await registerAgentBuilderWorkflows(mastra);
      if (actionId && !chunkDRDVJ35H_cjs.WorkflowRegistry.isAgentBuilderWorkflow(actionId)) {
        throw new chunk64ITUOXI_cjs.HTTPException(400, { message: `Invalid agent-builder action: ${actionId}` });
      }
      logger.info("Resuming agent builder action", { actionId, runId, step });
      return await chunkRJPRSDIS_cjs.RESUME_WORKFLOW_ROUTE.handler({
        ...ctx,
        workflowId: actionId,
        requestContext
      });
    } catch (error) {
      logger.error("Error resuming agent builder action", { error, actionId });
      return chunkZ7LCIYK7_cjs.handleError(error, "Error resuming agent builder action");
    } finally {
      chunkDRDVJ35H_cjs.WorkflowRegistry.cleanup();
    }
  }
});
var RESUME_STREAM_AGENT_BUILDER_ACTION_ROUTE = chunkN54Q3AQR_cjs.createRoute({
  method: "POST",
  path: "/agent-builder/:actionId/resume-stream",
  responseType: "stream",
  pathParamSchema: chunkS6TNTR3A_cjs.actionIdPathParams,
  queryParamSchema: chunkDIG2K5CV_cjs.runIdSchema,
  bodySchema: chunkS6TNTR3A_cjs.resumeAgentBuilderBodySchema,
  responseSchema: chunkZQ4GVMYG_cjs.streamResponseSchema,
  summary: "Resume action stream",
  description: "Resumes a suspended action execution and continues streaming results",
  tags: ["Agent Builder"],
  requiresAuth: true,
  handler: async (ctx) => {
    const { mastra, actionId, runId, step, requestContext } = ctx;
    const logger = mastra.getLogger();
    try {
      await registerAgentBuilderWorkflows(mastra);
      if (actionId && !chunkDRDVJ35H_cjs.WorkflowRegistry.isAgentBuilderWorkflow(actionId)) {
        throw new chunk64ITUOXI_cjs.HTTPException(400, { message: `Invalid agent-builder action: ${actionId}` });
      }
      logger.info("Resuming agent builder action stream", { actionId, runId, step });
      return await chunkRJPRSDIS_cjs.RESUME_STREAM_WORKFLOW_ROUTE.handler({
        ...ctx,
        workflowId: actionId,
        requestContext
      });
    } catch (error) {
      logger.error("Error resuming agent builder action stream", { error, actionId });
      return chunkZ7LCIYK7_cjs.handleError(error, "Error resuming agent builder action stream");
    } finally {
      chunkDRDVJ35H_cjs.WorkflowRegistry.cleanup();
    }
  }
});
var CANCEL_AGENT_BUILDER_ACTION_RUN_ROUTE = chunkN54Q3AQR_cjs.createRoute({
  method: "POST",
  path: "/agent-builder/:actionId/runs/:runId/cancel",
  responseType: "json",
  pathParamSchema: chunkS6TNTR3A_cjs.actionRunPathParams,
  responseSchema: chunkPTPMBE6M_cjs.workflowControlResponseSchema,
  summary: "Cancel action run",
  description: "Cancels an in-progress action execution",
  tags: ["Agent Builder"],
  requiresAuth: true,
  handler: async (ctx) => {
    const { mastra, actionId, runId } = ctx;
    const logger = mastra.getLogger();
    try {
      await registerAgentBuilderWorkflows(mastra);
      if (actionId && !chunkDRDVJ35H_cjs.WorkflowRegistry.isAgentBuilderWorkflow(actionId)) {
        throw new chunk64ITUOXI_cjs.HTTPException(400, { message: `Invalid agent-builder action: ${actionId}` });
      }
      logger.info("Cancelling agent builder action run", { actionId, runId });
      return await chunkRJPRSDIS_cjs.CANCEL_WORKFLOW_RUN_ROUTE.handler({
        ...ctx,
        workflowId: actionId
      });
    } catch (error) {
      logger.error("Error cancelling agent builder action run", { error, actionId });
      return chunkZ7LCIYK7_cjs.handleError(error, "Error cancelling agent builder action run");
    } finally {
      chunkDRDVJ35H_cjs.WorkflowRegistry.cleanup();
    }
  }
});
var STREAM_LEGACY_AGENT_BUILDER_ACTION_ROUTE = chunkN54Q3AQR_cjs.createRoute({
  method: "POST",
  path: "/agent-builder/:actionId/stream-legacy",
  responseType: "stream",
  pathParamSchema: chunkS6TNTR3A_cjs.actionIdPathParams,
  queryParamSchema: chunkDIG2K5CV_cjs.runIdSchema,
  bodySchema: chunkS6TNTR3A_cjs.streamLegacyAgentBuilderBodySchema,
  responseSchema: chunkZQ4GVMYG_cjs.streamResponseSchema,
  summary: "[DEPRECATED] Stream agent-builder action with legacy format",
  description: "Legacy endpoint for streaming agent-builder action execution. Use /agent-builder/:actionId/stream instead.",
  tags: ["Agent Builder", "Legacy"],
  requiresAuth: true,
  handler: async (ctx) => {
    const { mastra, actionId, runId, requestContext } = ctx;
    const logger = mastra.getLogger();
    try {
      await registerAgentBuilderWorkflows(mastra);
      if (actionId && !chunkDRDVJ35H_cjs.WorkflowRegistry.isAgentBuilderWorkflow(actionId)) {
        throw new chunk64ITUOXI_cjs.HTTPException(400, { message: `Invalid agent-builder action: ${actionId}` });
      }
      logger.info("Streaming agent builder action (legacy)", { actionId, runId });
      return await chunkRJPRSDIS_cjs.STREAM_LEGACY_WORKFLOW_ROUTE.handler({
        ...ctx,
        workflowId: actionId,
        requestContext
      });
    } catch (error) {
      logger.error("Error streaming agent builder action (legacy)", { error, actionId });
      return chunkZ7LCIYK7_cjs.handleError(error, "Error streaming agent builder action");
    } finally {
      chunkDRDVJ35H_cjs.WorkflowRegistry.cleanup();
    }
  }
});
var OBSERVE_STREAM_LEGACY_AGENT_BUILDER_ACTION_ROUTE = chunkN54Q3AQR_cjs.createRoute({
  method: "POST",
  path: "/agent-builder/:actionId/observe-stream-legacy",
  responseType: "stream",
  pathParamSchema: chunkS6TNTR3A_cjs.actionIdPathParams,
  queryParamSchema: chunkDIG2K5CV_cjs.runIdSchema,
  responseSchema: chunkZQ4GVMYG_cjs.streamResponseSchema,
  summary: "[DEPRECATED] Observe agent-builder action stream with legacy format",
  description: "Legacy endpoint for observing agent-builder action stream. Use /agent-builder/:actionId/observe instead.",
  tags: ["Agent Builder", "Legacy"],
  requiresAuth: true,
  handler: async (ctx) => {
    const { mastra, actionId, runId } = ctx;
    const logger = mastra.getLogger();
    try {
      await registerAgentBuilderWorkflows(mastra);
      if (actionId && !chunkDRDVJ35H_cjs.WorkflowRegistry.isAgentBuilderWorkflow(actionId)) {
        throw new chunk64ITUOXI_cjs.HTTPException(400, { message: `Invalid agent-builder action: ${actionId}` });
      }
      logger.info("Observing agent builder action stream (legacy)", { actionId, runId });
      return await chunkRJPRSDIS_cjs.OBSERVE_STREAM_LEGACY_WORKFLOW_ROUTE.handler({
        ...ctx,
        workflowId: actionId
      });
    } catch (error) {
      logger.error("Error observing agent builder action stream (legacy)", { error, actionId });
      return chunkZ7LCIYK7_cjs.handleError(error, "Error observing agent builder action stream");
    } finally {
      chunkDRDVJ35H_cjs.WorkflowRegistry.cleanup();
    }
  }
});

exports.CANCEL_AGENT_BUILDER_ACTION_RUN_ROUTE = CANCEL_AGENT_BUILDER_ACTION_RUN_ROUTE;
exports.CREATE_AGENT_BUILDER_ACTION_RUN_ROUTE = CREATE_AGENT_BUILDER_ACTION_RUN_ROUTE;
exports.GET_AGENT_BUILDER_ACTION_BY_ID_ROUTE = GET_AGENT_BUILDER_ACTION_BY_ID_ROUTE;
exports.GET_AGENT_BUILDER_ACTION_RUN_BY_ID_ROUTE = GET_AGENT_BUILDER_ACTION_RUN_BY_ID_ROUTE;
exports.LIST_AGENT_BUILDER_ACTIONS_ROUTE = LIST_AGENT_BUILDER_ACTIONS_ROUTE;
exports.LIST_AGENT_BUILDER_ACTION_RUNS_ROUTE = LIST_AGENT_BUILDER_ACTION_RUNS_ROUTE;
exports.OBSERVE_STREAM_AGENT_BUILDER_ACTION_ROUTE = OBSERVE_STREAM_AGENT_BUILDER_ACTION_ROUTE;
exports.OBSERVE_STREAM_LEGACY_AGENT_BUILDER_ACTION_ROUTE = OBSERVE_STREAM_LEGACY_AGENT_BUILDER_ACTION_ROUTE;
exports.RESUME_AGENT_BUILDER_ACTION_ROUTE = RESUME_AGENT_BUILDER_ACTION_ROUTE;
exports.RESUME_ASYNC_AGENT_BUILDER_ACTION_ROUTE = RESUME_ASYNC_AGENT_BUILDER_ACTION_ROUTE;
exports.RESUME_NO_WAIT_AGENT_BUILDER_ACTION_ROUTE = RESUME_NO_WAIT_AGENT_BUILDER_ACTION_ROUTE;
exports.RESUME_STREAM_AGENT_BUILDER_ACTION_ROUTE = RESUME_STREAM_AGENT_BUILDER_ACTION_ROUTE;
exports.START_AGENT_BUILDER_ACTION_RUN_ROUTE = START_AGENT_BUILDER_ACTION_RUN_ROUTE;
exports.START_ASYNC_AGENT_BUILDER_ACTION_ROUTE = START_ASYNC_AGENT_BUILDER_ACTION_ROUTE;
exports.STREAM_AGENT_BUILDER_ACTION_ROUTE = STREAM_AGENT_BUILDER_ACTION_ROUTE;
exports.STREAM_LEGACY_AGENT_BUILDER_ACTION_ROUTE = STREAM_LEGACY_AGENT_BUILDER_ACTION_ROUTE;
exports.agent_builder_exports = agent_builder_exports;
//# sourceMappingURL=chunk-Q56NQYUJ.cjs.map
//# sourceMappingURL=chunk-Q56NQYUJ.cjs.map