import { LIST_WORKFLOWS_ROUTE, GET_WORKFLOW_BY_ID_ROUTE, LIST_WORKFLOW_RUNS_ROUTE, GET_WORKFLOW_RUN_BY_ID_ROUTE, CREATE_WORKFLOW_RUN_ROUTE, STREAM_WORKFLOW_ROUTE, START_ASYNC_WORKFLOW_ROUTE, START_WORKFLOW_RUN_ROUTE, OBSERVE_STREAM_WORKFLOW_ROUTE, RESUME_ASYNC_WORKFLOW_ROUTE, RESUME_NO_WAIT_WORKFLOW_ROUTE, RESUME_WORKFLOW_ROUTE, RESUME_STREAM_WORKFLOW_ROUTE, CANCEL_WORKFLOW_RUN_ROUTE, STREAM_LEGACY_WORKFLOW_ROUTE, OBSERVE_STREAM_LEGACY_WORKFLOW_ROUTE } from './chunk-TQBIGT3Q.js';
import { actionIdPathParams, actionRunPathParams, streamAgentBuilderBodySchema, startAsyncAgentBuilderBodySchema, resumeAgentBuilderBodySchema, streamLegacyAgentBuilderBodySchema } from './chunk-6SZGOLAP.js';
import { listWorkflowsResponseSchema, workflowInfoSchema, workflowRunsResponseSchema, listWorkflowRunsQuerySchema, workflowRunResultSchema, workflowRunResultQuerySchema, createWorkflowRunResponseSchema, workflowExecutionResultSchema, workflowControlResponseSchema } from './chunk-K4HCNNHA.js';
import { streamResponseSchema } from './chunk-R3KUPFCO.js';
import { optionalRunIdSchema, runIdSchema } from './chunk-2YY3EMMS.js';
import { WorkflowRegistry } from './chunk-QIQWHDPH.js';
import { handleError } from './chunk-7ZWJX3AN.js';
import { createRoute } from './chunk-PIKPS6Q6.js';
import { HTTPException } from './chunk-6QWQZI4Q.js';
import { __export } from './chunk-PR4QN5HX.js';

// src/server/handlers/agent-builder.ts
var agent_builder_exports = {};
__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-JSC2CQVL.js').then((mod) => mod.agentBuilderWorkflows);
  return agentBuilderWorkflowsPromise;
}
async function registerAgentBuilderWorkflows(mastra) {
  const agentBuilderWorkflows = await loadAgentBuilderWorkflows();
  WorkflowRegistry.registerTemporaryWorkflows(agentBuilderWorkflows, mastra);
  return agentBuilderWorkflows;
}
var LIST_AGENT_BUILDER_ACTIONS_ROUTE = createRoute({
  method: "GET",
  path: "/agent-builder",
  responseType: "json",
  responseSchema: 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 LIST_WORKFLOWS_ROUTE.handler(ctx);
    } catch (error) {
      logger.error("Error listing agent builder actions", { error });
      return handleError(error, "Error getting agent builder workflows");
    } finally {
      WorkflowRegistry.cleanup();
    }
  }
});
var GET_AGENT_BUILDER_ACTION_BY_ID_ROUTE = createRoute({
  method: "GET",
  path: "/agent-builder/:actionId",
  responseType: "json",
  pathParamSchema: actionIdPathParams,
  responseSchema: 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 && !WorkflowRegistry.isAgentBuilderWorkflow(actionId)) {
        throw new 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 GET_WORKFLOW_BY_ID_ROUTE.handler({ ...ctx, workflowId: actionId });
    } catch (error) {
      logger.error("Error getting agent builder action by ID", { error, actionId });
      return handleError(error, "Error getting agent builder action");
    } finally {
      WorkflowRegistry.cleanup();
    }
  }
});
var LIST_AGENT_BUILDER_ACTION_RUNS_ROUTE = createRoute({
  method: "GET",
  path: "/agent-builder/:actionId/runs",
  responseType: "json",
  pathParamSchema: actionIdPathParams,
  queryParamSchema: listWorkflowRunsQuerySchema,
  responseSchema: 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 && !WorkflowRegistry.isAgentBuilderWorkflow(actionId)) {
        throw new HTTPException(400, { message: `Invalid agent-builder action: ${actionId}` });
      }
      logger.info("Listing agent builder action runs", { actionId });
      return await LIST_WORKFLOW_RUNS_ROUTE.handler({
        ...ctx,
        workflowId: actionId
      });
    } catch (error) {
      logger.error("Error listing agent builder action runs", { error, actionId });
      return handleError(error, "Error getting agent builder action runs");
    } finally {
      WorkflowRegistry.cleanup();
    }
  }
});
var GET_AGENT_BUILDER_ACTION_RUN_BY_ID_ROUTE = createRoute({
  method: "GET",
  path: "/agent-builder/:actionId/runs/:runId",
  responseType: "json",
  pathParamSchema: actionRunPathParams,
  queryParamSchema: workflowRunResultQuerySchema,
  responseSchema: 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 && !WorkflowRegistry.isAgentBuilderWorkflow(actionId)) {
        throw new HTTPException(400, { message: `Invalid agent-builder action: ${actionId}` });
      }
      logger.info("Getting agent builder action run by ID", { actionId, runId });
      return await GET_WORKFLOW_RUN_BY_ID_ROUTE.handler({
        ...ctx,
        workflowId: actionId
      });
    } catch (error) {
      logger.error("Error getting agent builder action run", { error, actionId, runId });
      return handleError(error, "Error getting agent builder action run");
    } finally {
      WorkflowRegistry.cleanup();
    }
  }
});
var CREATE_AGENT_BUILDER_ACTION_RUN_ROUTE = createRoute({
  method: "POST",
  path: "/agent-builder/:actionId/create-run",
  responseType: "json",
  pathParamSchema: actionIdPathParams,
  queryParamSchema: optionalRunIdSchema,
  responseSchema: 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 && !WorkflowRegistry.isAgentBuilderWorkflow(actionId)) {
        throw new HTTPException(400, { message: `Invalid agent-builder action: ${actionId}` });
      }
      logger.info("Creating agent builder action run", { actionId, runId });
      return await CREATE_WORKFLOW_RUN_ROUTE.handler({
        ...ctx,
        workflowId: actionId
      });
    } catch (error) {
      logger.error("Error creating agent builder action run", { error, actionId });
      return handleError(error, "Error creating agent builder action run");
    } finally {
      WorkflowRegistry.cleanup();
    }
  }
});
var STREAM_AGENT_BUILDER_ACTION_ROUTE = createRoute({
  method: "POST",
  path: "/agent-builder/:actionId/stream",
  responseType: "stream",
  pathParamSchema: actionIdPathParams,
  queryParamSchema: runIdSchema,
  bodySchema: streamAgentBuilderBodySchema,
  responseSchema: 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 && !WorkflowRegistry.isAgentBuilderWorkflow(actionId)) {
        throw new HTTPException(400, { message: `Invalid agent-builder action: ${actionId}` });
      }
      logger.info("Streaming agent builder action", { actionId, runId });
      return await STREAM_WORKFLOW_ROUTE.handler({
        ...ctx,
        workflowId: actionId,
        requestContext
      });
    } catch (error) {
      logger.error("Error streaming agent builder action", { error, actionId });
      return handleError(error, "Error streaming agent builder action");
    } finally {
      WorkflowRegistry.cleanup();
    }
  }
});
var START_ASYNC_AGENT_BUILDER_ACTION_ROUTE = createRoute({
  method: "POST",
  path: "/agent-builder/:actionId/start-async",
  responseType: "json",
  pathParamSchema: actionIdPathParams,
  queryParamSchema: optionalRunIdSchema,
  bodySchema: startAsyncAgentBuilderBodySchema,
  responseSchema: 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 && !WorkflowRegistry.isAgentBuilderWorkflow(actionId)) {
        throw new HTTPException(400, { message: `Invalid agent-builder action: ${actionId}` });
      }
      logger.info("Starting agent builder action asynchronously", { actionId, runId });
      return await START_ASYNC_WORKFLOW_ROUTE.handler({
        ...ctx,
        workflowId: actionId,
        requestContext
      });
    } catch (error) {
      logger.error("Error starting agent builder action asynchronously", { error, actionId });
      return handleError(error, "Error starting agent builder action");
    } finally {
      WorkflowRegistry.cleanup();
    }
  }
});
var START_AGENT_BUILDER_ACTION_RUN_ROUTE = createRoute({
  method: "POST",
  path: "/agent-builder/:actionId/start",
  responseType: "json",
  pathParamSchema: actionIdPathParams,
  queryParamSchema: runIdSchema,
  bodySchema: startAsyncAgentBuilderBodySchema,
  responseSchema: 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 && !WorkflowRegistry.isAgentBuilderWorkflow(actionId)) {
        throw new HTTPException(400, { message: `Invalid agent-builder action: ${actionId}` });
      }
      logger.info("Starting specific agent builder action run", { actionId, runId });
      return await START_WORKFLOW_RUN_ROUTE.handler({
        ...ctx,
        workflowId: actionId,
        requestContext
      });
    } catch (error) {
      logger.error("Error starting agent builder action run", { error, actionId });
      return handleError(error, "Error starting agent builder action run");
    } finally {
      WorkflowRegistry.cleanup();
    }
  }
});
var OBSERVE_STREAM_AGENT_BUILDER_ACTION_ROUTE = createRoute({
  method: "POST",
  path: "/agent-builder/:actionId/observe",
  responseType: "stream",
  pathParamSchema: actionIdPathParams,
  queryParamSchema: runIdSchema,
  responseSchema: 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 && !WorkflowRegistry.isAgentBuilderWorkflow(actionId)) {
        throw new HTTPException(400, { message: `Invalid agent-builder action: ${actionId}` });
      }
      logger.info("Observing agent builder action stream", { actionId, runId });
      return await OBSERVE_STREAM_WORKFLOW_ROUTE.handler({
        ...ctx,
        workflowId: actionId
      });
    } catch (error) {
      logger.error("Error observing agent builder action stream", { error, actionId });
      return handleError(error, "Error observing agent builder action stream");
    } finally {
      WorkflowRegistry.cleanup();
    }
  }
});
var RESUME_ASYNC_AGENT_BUILDER_ACTION_ROUTE = createRoute({
  method: "POST",
  path: "/agent-builder/:actionId/resume-async",
  responseType: "json",
  pathParamSchema: actionIdPathParams,
  queryParamSchema: runIdSchema,
  bodySchema: resumeAgentBuilderBodySchema,
  responseSchema: 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 && !WorkflowRegistry.isAgentBuilderWorkflow(actionId)) {
        throw new HTTPException(400, { message: `Invalid agent-builder action: ${actionId}` });
      }
      logger.info("Resuming agent builder action asynchronously", { actionId, runId, step });
      return await RESUME_ASYNC_WORKFLOW_ROUTE.handler({
        ...ctx,
        workflowId: actionId,
        requestContext
      });
    } catch (error) {
      logger.error("Error resuming agent builder action asynchronously", { error, actionId });
      return handleError(error, "Error resuming agent builder action");
    } finally {
      WorkflowRegistry.cleanup();
    }
  }
});
var RESUME_NO_WAIT_AGENT_BUILDER_ACTION_ROUTE = createRoute({
  method: "POST",
  path: "/agent-builder/:actionId/resume-no-wait",
  responseType: "json",
  pathParamSchema: actionIdPathParams,
  queryParamSchema: runIdSchema,
  bodySchema: resumeAgentBuilderBodySchema,
  responseSchema: 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 && !WorkflowRegistry.isAgentBuilderWorkflow(actionId)) {
        throw new HTTPException(400, { message: `Invalid agent-builder action: ${actionId}` });
      }
      logger.info("Resuming agent builder action without waiting", { actionId, runId, step });
      return await RESUME_NO_WAIT_WORKFLOW_ROUTE.handler({
        ...ctx,
        workflowId: actionId,
        requestContext
      });
    } catch (error) {
      logger.error("Error resuming agent builder action without waiting", { error, actionId });
      return handleError(error, "Error resuming agent builder action");
    } finally {
      WorkflowRegistry.cleanup();
    }
  }
});
var RESUME_AGENT_BUILDER_ACTION_ROUTE = createRoute({
  method: "POST",
  path: "/agent-builder/:actionId/resume",
  responseType: "json",
  pathParamSchema: actionIdPathParams,
  queryParamSchema: runIdSchema,
  bodySchema: resumeAgentBuilderBodySchema,
  responseSchema: 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 && !WorkflowRegistry.isAgentBuilderWorkflow(actionId)) {
        throw new HTTPException(400, { message: `Invalid agent-builder action: ${actionId}` });
      }
      logger.info("Resuming agent builder action", { actionId, runId, step });
      return await RESUME_WORKFLOW_ROUTE.handler({
        ...ctx,
        workflowId: actionId,
        requestContext
      });
    } catch (error) {
      logger.error("Error resuming agent builder action", { error, actionId });
      return handleError(error, "Error resuming agent builder action");
    } finally {
      WorkflowRegistry.cleanup();
    }
  }
});
var RESUME_STREAM_AGENT_BUILDER_ACTION_ROUTE = createRoute({
  method: "POST",
  path: "/agent-builder/:actionId/resume-stream",
  responseType: "stream",
  pathParamSchema: actionIdPathParams,
  queryParamSchema: runIdSchema,
  bodySchema: resumeAgentBuilderBodySchema,
  responseSchema: 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 && !WorkflowRegistry.isAgentBuilderWorkflow(actionId)) {
        throw new HTTPException(400, { message: `Invalid agent-builder action: ${actionId}` });
      }
      logger.info("Resuming agent builder action stream", { actionId, runId, step });
      return await RESUME_STREAM_WORKFLOW_ROUTE.handler({
        ...ctx,
        workflowId: actionId,
        requestContext
      });
    } catch (error) {
      logger.error("Error resuming agent builder action stream", { error, actionId });
      return handleError(error, "Error resuming agent builder action stream");
    } finally {
      WorkflowRegistry.cleanup();
    }
  }
});
var CANCEL_AGENT_BUILDER_ACTION_RUN_ROUTE = createRoute({
  method: "POST",
  path: "/agent-builder/:actionId/runs/:runId/cancel",
  responseType: "json",
  pathParamSchema: actionRunPathParams,
  responseSchema: 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 && !WorkflowRegistry.isAgentBuilderWorkflow(actionId)) {
        throw new HTTPException(400, { message: `Invalid agent-builder action: ${actionId}` });
      }
      logger.info("Cancelling agent builder action run", { actionId, runId });
      return await CANCEL_WORKFLOW_RUN_ROUTE.handler({
        ...ctx,
        workflowId: actionId
      });
    } catch (error) {
      logger.error("Error cancelling agent builder action run", { error, actionId });
      return handleError(error, "Error cancelling agent builder action run");
    } finally {
      WorkflowRegistry.cleanup();
    }
  }
});
var STREAM_LEGACY_AGENT_BUILDER_ACTION_ROUTE = createRoute({
  method: "POST",
  path: "/agent-builder/:actionId/stream-legacy",
  responseType: "stream",
  pathParamSchema: actionIdPathParams,
  queryParamSchema: runIdSchema,
  bodySchema: streamLegacyAgentBuilderBodySchema,
  responseSchema: 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 && !WorkflowRegistry.isAgentBuilderWorkflow(actionId)) {
        throw new HTTPException(400, { message: `Invalid agent-builder action: ${actionId}` });
      }
      logger.info("Streaming agent builder action (legacy)", { actionId, runId });
      return await STREAM_LEGACY_WORKFLOW_ROUTE.handler({
        ...ctx,
        workflowId: actionId,
        requestContext
      });
    } catch (error) {
      logger.error("Error streaming agent builder action (legacy)", { error, actionId });
      return handleError(error, "Error streaming agent builder action");
    } finally {
      WorkflowRegistry.cleanup();
    }
  }
});
var OBSERVE_STREAM_LEGACY_AGENT_BUILDER_ACTION_ROUTE = createRoute({
  method: "POST",
  path: "/agent-builder/:actionId/observe-stream-legacy",
  responseType: "stream",
  pathParamSchema: actionIdPathParams,
  queryParamSchema: runIdSchema,
  responseSchema: 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 && !WorkflowRegistry.isAgentBuilderWorkflow(actionId)) {
        throw new HTTPException(400, { message: `Invalid agent-builder action: ${actionId}` });
      }
      logger.info("Observing agent builder action stream (legacy)", { actionId, runId });
      return await OBSERVE_STREAM_LEGACY_WORKFLOW_ROUTE.handler({
        ...ctx,
        workflowId: actionId
      });
    } catch (error) {
      logger.error("Error observing agent builder action stream (legacy)", { error, actionId });
      return handleError(error, "Error observing agent builder action stream");
    } finally {
      WorkflowRegistry.cleanup();
    }
  }
});

export { CANCEL_AGENT_BUILDER_ACTION_RUN_ROUTE, CREATE_AGENT_BUILDER_ACTION_RUN_ROUTE, GET_AGENT_BUILDER_ACTION_BY_ID_ROUTE, GET_AGENT_BUILDER_ACTION_RUN_BY_ID_ROUTE, LIST_AGENT_BUILDER_ACTIONS_ROUTE, LIST_AGENT_BUILDER_ACTION_RUNS_ROUTE, OBSERVE_STREAM_AGENT_BUILDER_ACTION_ROUTE, OBSERVE_STREAM_LEGACY_AGENT_BUILDER_ACTION_ROUTE, RESUME_AGENT_BUILDER_ACTION_ROUTE, RESUME_ASYNC_AGENT_BUILDER_ACTION_ROUTE, RESUME_NO_WAIT_AGENT_BUILDER_ACTION_ROUTE, RESUME_STREAM_AGENT_BUILDER_ACTION_ROUTE, START_AGENT_BUILDER_ACTION_RUN_ROUTE, START_ASYNC_AGENT_BUILDER_ACTION_ROUTE, STREAM_AGENT_BUILDER_ACTION_ROUTE, STREAM_LEGACY_AGENT_BUILDER_ACTION_ROUTE, agent_builder_exports };
//# sourceMappingURL=chunk-ETVWGZSU.js.map
//# sourceMappingURL=chunk-ETVWGZSU.js.map