{"version":3,"sources":["../src/server/handlers/workflows.ts"],"names":["__export","HTTPException","WorkflowRegistry","createRoute","z","listWorkflowsResponseSchema","getWorkflowInfo","MastraFGAPermissions","handleError","workflowIdPathParams","workflowInfoSchema","listWorkflowRunsQuerySchema","workflowRunsResponseSchema","getEffectiveResourceId","workflowRunPathParams","workflowRunResultQuerySchema","workflowRunResultSchema","validateRunOwnership","workflowControlResponseSchema","optionalRunIdSchema","createWorkflowRunBodySchema","createWorkflowRunResponseSchema","runIdSchema","streamWorkflowBodySchema","createCachingTransformStream","resumeBodySchema","streamResponseSchema","startAsyncWorkflowBodySchema","workflowExecutionResultSchema","observeWorkflowQuerySchema","createReplayStream","restartBodySchema","timeTravelBodySchema"],"mappings":";;;;;;;;;;;;;;;AAAA,IAAA,iBAAA,GAAA;AAAAA,0BAAA,CAAA,iBAAA,EAAA;AAAA,EAAA,yBAAA,EAAA,MAAA,yBAAA;AAAA,EAAA,yBAAA,EAAA,MAAA,yBAAA;AAAA,EAAA,+BAAA,EAAA,MAAA,+BAAA;AAAA,EAAA,2BAAA,EAAA,MAAA,2BAAA;AAAA,EAAA,wBAAA,EAAA,MAAA,wBAAA;AAAA,EAAA,4BAAA,EAAA,MAAA,4BAAA;AAAA,EAAA,oBAAA,EAAA,MAAA,oBAAA;AAAA,EAAA,wBAAA,EAAA,MAAA,wBAAA;AAAA,EAAA,oCAAA,EAAA,MAAA,oCAAA;AAAA,EAAA,6BAAA,EAAA,MAAA,6BAAA;AAAA,EAAA,4BAAA,EAAA,MAAA,4BAAA;AAAA,EAAA,4CAAA,EAAA,MAAA,4CAAA;AAAA,EAAA,sCAAA,EAAA,MAAA,sCAAA;AAAA,EAAA,4BAAA,EAAA,MAAA,4BAAA;AAAA,EAAA,sBAAA,EAAA,MAAA,sBAAA;AAAA,EAAA,2BAAA,EAAA,MAAA,2BAAA;AAAA,EAAA,6BAAA,EAAA,MAAA,6BAAA;AAAA,EAAA,4BAAA,EAAA,MAAA,4BAAA;AAAA,EAA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cAAA,EAAgB,kCAAA;AAAA,EAChB,OAAA,EAAS,kDAAA;AAAA,EACT,WAAA,EACE,mLAAA;AAAA,EACF,IAAA,EAAM,CAAC,WAAA,EAAa,QAAQ,CAAA;AAAA,EAC5B,YAAA,EAAc,IAAA;AAAA;AAAA;AAAA;AAAA,EAId,kBAAA,EAAoB,CAAC,iBAAA,EAAmB,mBAAmB,CAAA;AAAA,EAC3D,OAAA,GAAU,OAAO,EAAE,MAAA,EAAQ,OAAM,KAAuC;AACtE,IAAA,IAAI;AAGF,MAAA,MAAM,eAAgB,KAAA,CAA4C,SAAA;AAClE,MAAA,MAAM,YAAY,YAAA,YAAwB,IAAA,GAAO,YAAA,GAAe,IAAI,KAAK,YAAsB,CAAA;AAC/F,MAAA,IAAI,MAAA,CAAO,KAAA,CAAM,SAAA,CAAU,OAAA,EAAS,CAAA,EAAG;AACrC,QAAA,MAAM,IAAIF,+BAAA,CAAc,GAAA,EAAK,EAAE,OAAA,EAAS,qBAAqB,CAAA;AAAA,MAC/D;AACA,MAAA,OAAO,MAAM,MAAA,CAAO,mBAAA,CAAoB,EAAE,GAAG,KAAA,EAAO,WAAW,CAAA;AAAA,IACjE,SAAS,KAAA,EAAO;AACd,MAAA,OAAOO,6BAAA,CAAY,OAAO,gCAAgC,CAAA;AAAA,IAC5D;AAAA,EACF,CAAA;AACF,CAAC","file":"chunk-U72IZ5BP.cjs","sourcesContent":["import type { Mastra } from '@mastra/core';\nimport type { RequestContext } from '@mastra/core/di';\nimport type { Event } from '@mastra/core/events';\nimport { createCachingTransformStream, createReplayStream } from '@mastra/core/stream';\nimport type { WorkflowInfo, ChunkType, StreamEvent, WorkflowStateField } from '@mastra/core/workflows';\nimport { z } from 'zod/v4';\nimport { MastraFGAPermissions } from '../fga-permissions';\nimport { HTTPException } from '../http-exception';\nimport { streamResponseSchema } from '../schemas/agents';\nimport { optionalRunIdSchema, runIdSchema } from '../schemas/common';\nimport {\n createWorkflowRunBodySchema,\n createWorkflowRunResponseSchema,\n listWorkflowRunsQuerySchema,\n listWorkflowsResponseSchema,\n restartBodySchema,\n timeTravelBodySchema,\n resumeBodySchema,\n startAsyncWorkflowBodySchema,\n streamWorkflowBodySchema,\n workflowControlResponseSchema,\n workflowExecutionResultSchema,\n workflowIdPathParams,\n workflowInfoSchema,\n workflowRunPathParams,\n workflowRunsResponseSchema,\n workflowRunResultQuerySchema,\n workflowRunResultSchema,\n observeWorkflowQuerySchema,\n} from '../schemas/workflows';\nimport { createRoute } from '../server-adapter/routes/route-builder';\nimport type { Context } from '../types';\nimport { getWorkflowInfo, WorkflowRegistry } from '../utils';\nimport { handleError } from './error';\nimport { getEffectiveResourceId, validateRunOwnership } from './utils';\n\nexport interface WorkflowContext extends Context {\n workflowId?: string;\n runId?: string;\n requestContext?: RequestContext;\n}\n\nasync function listWorkflowsFromSystem({ mastra, workflowId }: WorkflowContext) {\n const logger = mastra.getLogger();\n\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n let workflow;\n\n // First check registry for temporary workflows\n workflow = WorkflowRegistry.getWorkflow(workflowId);\n\n if (!workflow) {\n try {\n workflow = mastra.getWorkflowById(workflowId);\n } catch (error) {\n logger.debug('Error getting workflow, searching agents for workflow', error);\n }\n }\n\n if (!workflow) {\n logger.debug('Workflow not found, searching agents for workflow', { workflowId });\n const agents = mastra.listAgents();\n\n if (Object.keys(agents || {}).length) {\n for (const [_, agent] of Object.entries(agents)) {\n try {\n const workflows = await agent.listWorkflows();\n\n if (workflows[workflowId]) {\n workflow = workflows[workflowId];\n break;\n }\n } catch (error) {\n logger.debug('Error getting workflow from agent', error);\n }\n }\n }\n }\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n return { workflow };\n}\n\n// ============================================================================\n// Route Definitions (new pattern - handlers defined inline with createRoute)\n// ============================================================================\n\nexport const LIST_WORKFLOWS_ROUTE = createRoute({\n method: 'GET',\n path: '/workflows',\n responseType: 'json',\n queryParamSchema: z.object({\n partial: z.string().optional(),\n }),\n responseSchema: listWorkflowsResponseSchema,\n summary: 'List all workflows',\n description: 'Returns a list of all available workflows in the system',\n tags: ['Workflows'],\n requiresAuth: true,\n handler: (async ({ mastra, partial, requestContext }: any) => {\n try {\n const workflows = mastra.listWorkflows({ serialized: false });\n const isPartial = partial === 'true';\n const _workflows = Object.entries(workflows).reduce>((acc, [key, workflow]) => {\n acc[key] = getWorkflowInfo(workflow as any, isPartial);\n return acc;\n }, {});\n\n // Filter workflows by FGA if configured\n const fgaProvider = mastra.getServer?.()?.fga;\n const user = requestContext?.get('user');\n if (fgaProvider) {\n if (!user) {\n return {};\n }\n const workflowList = Object.entries(_workflows).map(([id, w]) => ({ id, ...w }));\n const accessible = await fgaProvider.filterAccessible(\n user,\n workflowList,\n 'workflow',\n MastraFGAPermissions.WORKFLOWS_READ,\n );\n const accessibleSet = new Set(accessible.map((w: any) => w.id));\n for (const id of Object.keys(_workflows)) {\n if (!accessibleSet.has(id)) {\n delete _workflows[id];\n }\n }\n }\n\n return _workflows;\n } catch (error) {\n return handleError(error, 'Error getting workflows');\n }\n }) as any,\n});\n\nexport const GET_WORKFLOW_BY_ID_ROUTE = createRoute({\n method: 'GET',\n path: '/workflows/:workflowId',\n responseType: 'json',\n pathParamSchema: workflowIdPathParams,\n responseSchema: workflowInfoSchema,\n summary: 'Get workflow by ID',\n description: 'Returns details for a specific workflow',\n tags: ['Workflows'],\n requiresAuth: true,\n handler: (async ({ mastra, workflowId }: any) => {\n try {\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });\n return getWorkflowInfo(workflow);\n } catch (error) {\n return handleError(error, 'Error getting workflow');\n }\n }) as any,\n});\n\nexport const LIST_WORKFLOW_RUNS_ROUTE = createRoute({\n method: 'GET',\n path: '/workflows/:workflowId/runs',\n responseType: 'json',\n pathParamSchema: workflowIdPathParams,\n queryParamSchema: listWorkflowRunsQuerySchema,\n responseSchema: workflowRunsResponseSchema,\n summary: 'List workflow runs',\n description: 'Returns a paginated list of execution runs for the specified workflow',\n tags: ['Workflows'],\n requiresAuth: true,\n handler: async ({\n mastra,\n workflowId,\n fromDate,\n toDate,\n page,\n perPage,\n limit,\n offset,\n resourceId,\n status,\n requestContext,\n }) => {\n try {\n // Use effective resourceId (context key takes precedence over client-provided value)\n const effectiveResourceId = getEffectiveResourceId(requestContext, resourceId);\n\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n // Support both page/perPage and limit/offset for backwards compatibility\n // If page/perPage provided, use directly; otherwise convert from limit/offset\n let finalPage = page;\n let finalPerPage = perPage;\n\n if (finalPerPage === undefined && limit !== undefined) {\n finalPerPage = limit;\n }\n if (finalPage === undefined && offset !== undefined && finalPerPage !== undefined && finalPerPage > 0) {\n finalPage = Math.floor(offset / finalPerPage);\n }\n\n if (\n finalPerPage !== undefined &&\n (typeof finalPerPage !== 'number' || !Number.isInteger(finalPerPage) || finalPerPage <= 0)\n ) {\n throw new HTTPException(400, { message: 'perPage must be a positive integer' });\n }\n if (finalPage !== undefined && (!Number.isInteger(finalPage) || finalPage < 0)) {\n throw new HTTPException(400, { message: 'page must be a non-negative integer' });\n }\n const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n const workflowRuns = (await workflow.listWorkflowRuns({\n fromDate: fromDate ? (typeof fromDate === 'string' ? new Date(fromDate) : fromDate) : undefined,\n toDate: toDate ? (typeof toDate === 'string' ? new Date(toDate) : toDate) : undefined,\n perPage: finalPerPage,\n page: finalPage,\n resourceId: effectiveResourceId,\n status,\n })) || {\n runs: [],\n total: 0,\n };\n return workflowRuns;\n } catch (error) {\n return handleError(error, 'Error getting workflow runs');\n }\n },\n});\n\nexport const GET_WORKFLOW_RUN_BY_ID_ROUTE = createRoute({\n method: 'GET',\n path: '/workflows/:workflowId/runs/:runId',\n responseType: 'json',\n pathParamSchema: workflowRunPathParams,\n queryParamSchema: workflowRunResultQuerySchema,\n responseSchema: workflowRunResultSchema,\n summary: 'Get workflow run by ID',\n description:\n 'Returns a workflow run with metadata and processed execution state. Use the fields query parameter to reduce payload size by requesting only specific fields (e.g., ?fields=status,result,metadata)',\n tags: ['Workflows'],\n requiresAuth: true,\n handler: async ({ mastra, workflowId, runId, fields, withNestedWorkflows, requestContext }) => {\n try {\n const effectiveResourceId = getEffectiveResourceId(requestContext, undefined);\n\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n if (!runId) {\n throw new HTTPException(400, { message: 'Run ID is required' });\n }\n\n const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n // Parse fields parameter (comma-separated string)\n const fieldList = fields ? (fields.split(',').map((f: string) => f.trim()) as WorkflowStateField[]) : undefined;\n\n const run = await workflow.getWorkflowRunById(runId, {\n withNestedWorkflows: withNestedWorkflows !== 'false', // Default to true unless explicitly 'false'\n fields: fieldList,\n });\n\n if (!run) {\n throw new HTTPException(404, { message: 'Workflow run not found' });\n }\n\n await validateRunOwnership(run, effectiveResourceId);\n\n return run;\n } catch (error) {\n return handleError(error, 'Error getting workflow run');\n }\n },\n});\n\nexport const DELETE_WORKFLOW_RUN_BY_ID_ROUTE = createRoute({\n method: 'DELETE',\n path: '/workflows/:workflowId/runs/:runId',\n responseType: 'json',\n pathParamSchema: workflowRunPathParams,\n responseSchema: workflowControlResponseSchema,\n summary: 'Delete workflow run by ID',\n description: 'Deletes a specific workflow run by ID',\n tags: ['Workflows'],\n requiresAuth: true,\n handler: async ({ mastra, workflowId, runId, requestContext }) => {\n try {\n const effectiveResourceId = getEffectiveResourceId(requestContext, undefined);\n\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n if (!runId) {\n throw new HTTPException(400, { message: 'Run ID is required' });\n }\n\n const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n // Validate ownership before deletion\n const run = await workflow.getWorkflowRunById(runId);\n if (!run) {\n throw new HTTPException(404, { message: 'Workflow run not found' });\n }\n await validateRunOwnership(run, effectiveResourceId);\n\n await workflow.deleteWorkflowRunById(runId);\n\n return { message: 'Workflow run deleted' };\n } catch (error) {\n return handleError(error, 'Error deleting workflow run');\n }\n },\n});\n\nexport const CREATE_WORKFLOW_RUN_ROUTE = createRoute({\n method: 'POST',\n path: '/workflows/:workflowId/create-run',\n responseType: 'json',\n pathParamSchema: workflowIdPathParams,\n queryParamSchema: optionalRunIdSchema,\n bodySchema: createWorkflowRunBodySchema,\n responseSchema: createWorkflowRunResponseSchema,\n summary: 'Create workflow run',\n description: 'Creates a new workflow execution instance with an optional custom run ID',\n tags: ['Workflows'],\n requiresAuth: true,\n // Creating a run is part of the execute flow (Studio/UI calls this before\n // starting/streaming a workflow), so allow either permission. `write` is kept\n // for back-compat with roles that already grant it.\n requiresPermission: ['workflows:write', 'workflows:execute'],\n handler: async ({ mastra, workflowId, runId, resourceId, disableScorers, requestContext }) => {\n try {\n // Use effective resourceId (context key takes precedence over client-provided value)\n const effectiveResourceId = getEffectiveResourceId(requestContext, resourceId);\n\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n const run = await workflow.createRun({ runId, resourceId: effectiveResourceId, disableScorers });\n\n return { runId: run.runId };\n } catch (error) {\n return handleError(error, 'Error creating workflow run');\n }\n },\n});\n\nexport const STREAM_WORKFLOW_ROUTE = createRoute({\n method: 'POST',\n path: '/workflows/:workflowId/stream',\n responseType: 'stream',\n pathParamSchema: workflowIdPathParams,\n queryParamSchema: runIdSchema,\n bodySchema: streamWorkflowBodySchema,\n summary: 'Stream workflow execution',\n description: 'Executes a workflow and streams the results in real-time',\n tags: ['Workflows'],\n requiresAuth: true,\n handler: async ({ mastra, workflowId, runId, resourceId, requestContext, ...params }) => {\n try {\n // Use effective resourceId (context key takes precedence over client-provided value)\n const effectiveResourceId = getEffectiveResourceId(requestContext, resourceId);\n\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n if (!runId) {\n throw new HTTPException(400, { message: 'runId required to stream workflow' });\n }\n\n const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n const serverCache = mastra.getServerCache();\n\n const run = await workflow.createRun({ runId, resourceId: effectiveResourceId });\n const result = run.stream({ ...params, requestContext });\n\n if (serverCache) {\n const { transform } = createCachingTransformStream({\n cache: serverCache,\n cacheKey: runId,\n });\n return result.fullStream.pipeThrough(transform);\n }\n\n return result.fullStream;\n } catch (error) {\n return handleError(error, 'Error streaming workflow');\n }\n },\n});\n\nexport const RESUME_STREAM_WORKFLOW_ROUTE = createRoute({\n method: 'POST',\n path: '/workflows/:workflowId/resume-stream',\n responseType: 'stream',\n pathParamSchema: workflowIdPathParams,\n queryParamSchema: runIdSchema,\n bodySchema: resumeBodySchema,\n responseSchema: streamResponseSchema,\n summary: 'Resume workflow stream',\n description: 'Resumes a suspended workflow execution and continues streaming results',\n tags: ['Workflows'],\n requiresAuth: true,\n handler: async ({ mastra, workflowId, runId, requestContext, ...params }) => {\n try {\n const effectiveResourceId = getEffectiveResourceId(requestContext, undefined);\n\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n if (!runId) {\n throw new HTTPException(400, { message: 'runId required to resume workflow' });\n }\n\n const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n const run = await workflow.getWorkflowRunById(runId);\n\n if (!run) {\n throw new HTTPException(404, { message: 'Workflow run not found' });\n }\n\n await validateRunOwnership(run, effectiveResourceId);\n\n const _run = await workflow.createRun({ runId, resourceId: run.resourceId });\n const serverCache = mastra.getServerCache();\n\n const resumeResult = _run.resumeStream({ ...params, requestContext });\n\n if (serverCache) {\n const { transform } = createCachingTransformStream({\n cache: serverCache,\n cacheKey: runId,\n });\n return resumeResult.fullStream.pipeThrough(transform);\n }\n\n return resumeResult.fullStream;\n } catch (error) {\n return handleError(error, 'Error resuming workflow');\n }\n },\n});\n\nexport const START_ASYNC_WORKFLOW_ROUTE = createRoute({\n method: 'POST',\n path: '/workflows/:workflowId/start-async',\n responseType: 'json',\n pathParamSchema: workflowIdPathParams,\n queryParamSchema: optionalRunIdSchema,\n bodySchema: startAsyncWorkflowBodySchema,\n responseSchema: workflowExecutionResultSchema,\n summary: 'Start workflow asynchronously',\n description: 'Starts a workflow execution asynchronously without streaming results',\n tags: ['Workflows'],\n requiresAuth: true,\n handler: async ({ mastra, workflowId, runId, resourceId, requestContext, ...params }) => {\n try {\n // Use effective resourceId (context key takes precedence over client-provided value)\n const effectiveResourceId = getEffectiveResourceId(requestContext, resourceId);\n\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n const _run = await workflow.createRun({ runId, resourceId: effectiveResourceId });\n const result = await _run.start({ ...params, requestContext });\n return result;\n } catch (error) {\n return handleError(error, 'Error starting async workflow');\n }\n },\n});\n\nexport const START_WORKFLOW_RUN_ROUTE = createRoute({\n method: 'POST',\n path: '/workflows/:workflowId/start',\n responseType: 'json',\n pathParamSchema: workflowIdPathParams,\n queryParamSchema: runIdSchema,\n bodySchema: startAsyncWorkflowBodySchema,\n responseSchema: workflowControlResponseSchema,\n summary: 'Start specific workflow run',\n description: 'Starts execution of a specific workflow run by ID',\n tags: ['Workflows'],\n requiresAuth: true,\n handler: async ({ mastra, workflowId, runId, requestContext, ...params }) => {\n try {\n const effectiveResourceId = getEffectiveResourceId(requestContext, undefined);\n\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n if (!runId) {\n throw new HTTPException(400, { message: 'runId required to start run' });\n }\n\n const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n const run = await workflow.getWorkflowRunById(runId);\n\n if (!run) {\n throw new HTTPException(404, { message: 'Workflow run not found' });\n }\n\n await validateRunOwnership(run, effectiveResourceId);\n\n const _run = await workflow.createRun({ runId, resourceId: run.resourceId });\n void _run.start({\n ...params,\n requestContext,\n });\n\n return { message: 'Workflow run started' };\n } catch (e) {\n return handleError(e, 'Error starting workflow run');\n }\n },\n});\n\nexport const OBSERVE_STREAM_WORKFLOW_ROUTE = createRoute({\n method: 'POST',\n path: '/workflows/:workflowId/observe',\n responseType: 'stream',\n pathParamSchema: workflowIdPathParams,\n queryParamSchema: observeWorkflowQuerySchema,\n responseSchema: streamResponseSchema,\n summary: 'Observe workflow stream',\n description:\n 'Observes and streams updates from an already running workflow execution. Supports position-based resume with offset for efficient reconnection.',\n tags: ['Workflows'],\n requiresAuth: true,\n handler: async ({ mastra, workflowId, runId, offset, requestContext }) => {\n try {\n const effectiveResourceId = getEffectiveResourceId(requestContext, undefined);\n\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n if (!runId) {\n throw new HTTPException(400, { message: 'runId required to observe workflow stream' });\n }\n\n const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n const run = await workflow.getWorkflowRunById(runId);\n\n if (!run) {\n throw new HTTPException(404, { message: 'Workflow run not found' });\n }\n\n await validateRunOwnership(run, effectiveResourceId);\n\n const _run = await workflow.createRun({ runId, resourceId: run.resourceId });\n const serverCache = mastra.getServerCache();\n if (!serverCache) {\n throw new HTTPException(500, { message: 'Server cache not found' });\n }\n\n // Get cached chunks from the specified index (or 0 if not specified)\n const startIndex = offset ?? 0;\n const cachedRunChunks = (await serverCache.listFromTo(runId, startIndex)) as ChunkType[];\n const liveStream = _run.observeStream();\n\n return createReplayStream({\n history: cachedRunChunks,\n liveSource: liveStream,\n });\n } catch (error) {\n return handleError(error, 'Error observing workflow stream');\n }\n },\n});\n\nexport const RESUME_ASYNC_WORKFLOW_ROUTE = createRoute({\n method: 'POST',\n path: '/workflows/:workflowId/resume-async',\n responseType: 'json',\n pathParamSchema: workflowIdPathParams,\n queryParamSchema: runIdSchema,\n bodySchema: resumeBodySchema,\n responseSchema: workflowExecutionResultSchema,\n summary: 'Resume workflow asynchronously',\n description: 'Resumes a suspended workflow execution asynchronously without streaming',\n tags: ['Workflows'],\n requiresAuth: true,\n handler: async ({ mastra, workflowId, runId, requestContext, ...params }) => {\n try {\n const effectiveResourceId = getEffectiveResourceId(requestContext, undefined);\n\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n if (!runId) {\n throw new HTTPException(400, { message: 'runId required to resume workflow' });\n }\n\n const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n const run = await workflow.getWorkflowRunById(runId);\n\n if (!run) {\n throw new HTTPException(404, { message: 'Workflow run not found' });\n }\n\n await validateRunOwnership(run, effectiveResourceId);\n\n const _run = await workflow.createRun({ runId, resourceId: run.resourceId });\n const result = await _run.resume({ ...params, requestContext });\n\n return result;\n } catch (error) {\n return handleError(error, 'Error resuming workflow step');\n }\n },\n});\n\n/**\n * Fire-and-forget resume: dispatches the resume and returns immediately with the runId,\n * without waiting for the workflow to complete. For Inngest-backed workflows this avoids\n * the `getRunOutput()` polling race that the awaiting `resume-async` route can hit.\n *\n * TODO(v2): in Mastra v2 this fire-and-forget behavior should become the behavior of the\n * `resume-async` route (and `Run.resumeAsync()`), and this route should be removed. It is\n * kept separate in v1 to avoid a breaking change to the existing `resume-async` response\n * contract (which returns the full workflow result).\n */\nexport const RESUME_NO_WAIT_WORKFLOW_ROUTE = createRoute({\n method: 'POST',\n path: '/workflows/:workflowId/resume-no-wait',\n responseType: 'json',\n pathParamSchema: workflowIdPathParams,\n queryParamSchema: runIdSchema,\n bodySchema: resumeBodySchema,\n responseSchema: createWorkflowRunResponseSchema,\n summary: 'Resume workflow without waiting',\n description:\n 'Resumes a suspended workflow execution without waiting (fire-and-forget) and returns immediately with the runId. The workflow continues executing in the background.',\n tags: ['Workflows'],\n requiresAuth: true,\n handler: async ({ mastra, workflowId, runId, requestContext, ...params }) => {\n try {\n const effectiveResourceId = getEffectiveResourceId(requestContext, undefined);\n\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n if (!runId) {\n throw new HTTPException(400, { message: 'runId required to resume workflow' });\n }\n\n const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n const run = await workflow.getWorkflowRunById(runId);\n\n if (!run) {\n throw new HTTPException(404, { message: 'Workflow run not found' });\n }\n\n await validateRunOwnership(run, effectiveResourceId);\n\n const _run = await workflow.createRun({ runId, resourceId: run.resourceId });\n const result = await _run.resumeAsync({ ...params, requestContext });\n\n return result;\n } catch (error) {\n return handleError(error, 'Error resuming workflow step');\n }\n },\n});\n\nexport const RESUME_WORKFLOW_ROUTE = createRoute({\n method: 'POST',\n path: '/workflows/:workflowId/resume',\n responseType: 'json',\n pathParamSchema: workflowIdPathParams,\n queryParamSchema: runIdSchema,\n bodySchema: resumeBodySchema,\n responseSchema: workflowControlResponseSchema,\n summary: 'Resume workflow',\n description: 'Resumes a suspended workflow execution from a specific step',\n tags: ['Workflows'],\n requiresAuth: true,\n handler: async ({ mastra, workflowId, runId, requestContext, ...params }) => {\n try {\n const effectiveResourceId = getEffectiveResourceId(requestContext, undefined);\n\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n if (!runId) {\n throw new HTTPException(400, { message: 'runId required to resume workflow' });\n }\n\n const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n const run = await workflow.getWorkflowRunById(runId);\n\n if (!run) {\n throw new HTTPException(404, { message: 'Workflow run not found' });\n }\n\n await validateRunOwnership(run, effectiveResourceId);\n\n const _run = await workflow.createRun({ runId, resourceId: run.resourceId });\n\n void _run.resume({ ...params, requestContext });\n\n return { message: 'Workflow run resumed' };\n } catch (error) {\n return handleError(error, 'Error resuming workflow');\n }\n },\n});\n\nexport const RESTART_ASYNC_WORKFLOW_ROUTE = createRoute({\n method: 'POST',\n path: '/workflows/:workflowId/restart-async',\n responseType: 'json',\n pathParamSchema: workflowIdPathParams,\n queryParamSchema: runIdSchema,\n bodySchema: restartBodySchema,\n responseSchema: workflowExecutionResultSchema,\n summary: 'Restart workflow asynchronously',\n description: 'Restarts an active workflow execution asynchronously',\n tags: ['Workflows'],\n requiresAuth: true,\n handler: async ({ mastra, workflowId, runId, requestContext, ...params }) => {\n try {\n const effectiveResourceId = getEffectiveResourceId(requestContext, undefined);\n\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n if (!runId) {\n throw new HTTPException(400, { message: 'runId required to restart workflow' });\n }\n\n const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n const run = await workflow.getWorkflowRunById(runId);\n\n if (!run) {\n throw new HTTPException(404, { message: 'Workflow run not found' });\n }\n\n await validateRunOwnership(run, effectiveResourceId);\n\n const _run = await workflow.createRun({ runId, resourceId: run.resourceId });\n const result = await _run.restart({ ...params, requestContext });\n\n return result;\n } catch (error) {\n return handleError(error, 'Error restarting workflow');\n }\n },\n});\n\nexport const RESTART_WORKFLOW_ROUTE = createRoute({\n method: 'POST',\n path: '/workflows/:workflowId/restart',\n responseType: 'json',\n pathParamSchema: workflowIdPathParams,\n queryParamSchema: runIdSchema,\n bodySchema: restartBodySchema,\n responseSchema: workflowControlResponseSchema,\n summary: 'Restart workflow',\n description: 'Restarts an active workflow execution',\n tags: ['Workflows'],\n requiresAuth: true,\n handler: async ({ mastra, workflowId, runId, requestContext, ...params }) => {\n try {\n const effectiveResourceId = getEffectiveResourceId(requestContext, undefined);\n\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n if (!runId) {\n throw new HTTPException(400, { message: 'runId required to restart workflow' });\n }\n\n const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n const run = await workflow.getWorkflowRunById(runId);\n\n if (!run) {\n throw new HTTPException(404, { message: 'Workflow run not found' });\n }\n\n await validateRunOwnership(run, effectiveResourceId);\n\n const _run = await workflow.createRun({ runId, resourceId: run.resourceId });\n\n void _run.restart({ ...params, requestContext });\n\n return { message: 'Workflow run restarted' };\n } catch (error) {\n return handleError(error, 'Error restarting workflow');\n }\n },\n});\n\nexport const RESTART_ALL_ACTIVE_WORKFLOW_RUNS_ASYNC_ROUTE = createRoute({\n method: 'POST',\n path: '/workflows/:workflowId/restart-all-active-workflow-runs-async',\n responseType: 'json',\n pathParamSchema: workflowIdPathParams,\n responseSchema: workflowControlResponseSchema,\n summary: 'Restart all active workflow runs asynchronously',\n description: 'Restarts all active workflow runs asynchronously',\n tags: ['Workflows'],\n requiresAuth: true,\n handler: async ({ mastra, workflowId }) => {\n try {\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n await workflow.restartAllActiveWorkflowRuns();\n\n return { message: 'All active workflow runs restarted' };\n } catch (error) {\n return handleError(error, 'Error restarting workflow');\n }\n },\n});\n\nexport const RESTART_ALL_ACTIVE_WORKFLOW_RUNS_ROUTE = createRoute({\n method: 'POST',\n path: '/workflows/:workflowId/restart-all-active-workflow-runs',\n responseType: 'json',\n pathParamSchema: workflowIdPathParams,\n responseSchema: workflowControlResponseSchema,\n summary: 'Restart all active workflow runs',\n description: 'Restarts all active workflow runs',\n tags: ['Workflows'],\n requiresAuth: true,\n handler: async ({ mastra, workflowId }) => {\n try {\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n void workflow.restartAllActiveWorkflowRuns();\n\n return { message: 'All active workflow runs restarted' };\n } catch (error) {\n return handleError(error, 'Error restarting workflow');\n }\n },\n});\n\nexport const TIME_TRAVEL_ASYNC_WORKFLOW_ROUTE = createRoute({\n method: 'POST',\n path: '/workflows/:workflowId/time-travel-async',\n responseType: 'json',\n pathParamSchema: workflowIdPathParams,\n queryParamSchema: runIdSchema,\n bodySchema: timeTravelBodySchema,\n responseSchema: workflowExecutionResultSchema,\n summary: 'Time travel workflow asynchronously',\n description: 'Time travels a workflow run asynchronously without streaming',\n tags: ['Workflows'],\n requiresAuth: true,\n handler: async ({ mastra, workflowId, runId, requestContext, ...params }) => {\n try {\n const effectiveResourceId = getEffectiveResourceId(requestContext, undefined);\n\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n if (!runId) {\n throw new HTTPException(400, { message: 'runId required to time travel workflow' });\n }\n\n const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n const run = await workflow.getWorkflowRunById(runId);\n\n if (!run) {\n throw new HTTPException(404, { message: 'Workflow run not found' });\n }\n\n await validateRunOwnership(run, effectiveResourceId);\n\n const _run = await workflow.createRun({ runId, resourceId: run.resourceId });\n const result = await _run.timeTravel({ ...params, requestContext });\n\n return result;\n } catch (error) {\n return handleError(error, 'Error time traveling workflow');\n }\n },\n});\n\nexport const TIME_TRAVEL_WORKFLOW_ROUTE = createRoute({\n method: 'POST',\n path: '/workflows/:workflowId/time-travel',\n responseType: 'json',\n pathParamSchema: workflowIdPathParams,\n queryParamSchema: runIdSchema,\n bodySchema: timeTravelBodySchema,\n responseSchema: workflowControlResponseSchema,\n summary: 'Time travel workflow',\n description: 'Time travels a workflow run, starting from a specific step',\n tags: ['Workflows'],\n requiresAuth: true,\n handler: async ({ mastra, workflowId, runId, requestContext, ...params }) => {\n try {\n const effectiveResourceId = getEffectiveResourceId(requestContext, undefined);\n\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n if (!runId) {\n throw new HTTPException(400, { message: 'runId required to time travel workflow' });\n }\n\n const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n const run = await workflow.getWorkflowRunById(runId);\n\n if (!run) {\n throw new HTTPException(404, { message: 'Workflow run not found' });\n }\n\n await validateRunOwnership(run, effectiveResourceId);\n\n const _run = await workflow.createRun({ runId, resourceId: run.resourceId });\n\n void _run.timeTravel({ ...params, requestContext });\n\n return { message: 'Workflow run time travel started' };\n } catch (error) {\n return handleError(error, 'Error time traveling workflow');\n }\n },\n});\n\nexport const TIME_TRAVEL_STREAM_WORKFLOW_ROUTE = createRoute({\n method: 'POST',\n path: '/workflows/:workflowId/time-travel-stream',\n responseType: 'stream',\n pathParamSchema: workflowIdPathParams,\n queryParamSchema: runIdSchema,\n bodySchema: timeTravelBodySchema,\n summary: 'Time travel workflow stream',\n description: 'Time travels a workflow run, starting from a specific step, and streams the results in real-time',\n tags: ['Workflows'],\n requiresAuth: true,\n handler: async ({ mastra, workflowId, runId, requestContext, ...params }) => {\n try {\n const effectiveResourceId = getEffectiveResourceId(requestContext, undefined);\n\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n if (!runId) {\n throw new HTTPException(400, { message: 'runId required to time travel workflow stream' });\n }\n\n const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n // Validate ownership of existing run before time traveling\n const existingRun = await workflow.getWorkflowRunById(runId);\n if (!existingRun) {\n throw new HTTPException(404, { message: 'Workflow run not found' });\n }\n await validateRunOwnership(existingRun, effectiveResourceId);\n\n const serverCache = mastra.getServerCache();\n\n const run = await workflow.createRun({ runId, resourceId: existingRun.resourceId });\n const result = run.timeTravelStream({ ...params, requestContext });\n\n if (serverCache) {\n const { transform } = createCachingTransformStream({\n cache: serverCache,\n cacheKey: runId,\n });\n return result.fullStream.pipeThrough(transform);\n }\n\n return result.fullStream;\n } catch (error) {\n return handleError(error, 'Error time traveling workflow stream');\n }\n },\n});\n\nexport const CANCEL_WORKFLOW_RUN_ROUTE = createRoute({\n method: 'POST',\n path: '/workflows/:workflowId/runs/:runId/cancel',\n responseType: 'json',\n pathParamSchema: workflowRunPathParams,\n responseSchema: workflowControlResponseSchema,\n summary: 'Cancel workflow run',\n description: 'Cancels an in-progress workflow execution',\n tags: ['Workflows'],\n requiresAuth: true,\n handler: async ({ mastra, workflowId, runId, requestContext }) => {\n try {\n const effectiveResourceId = getEffectiveResourceId(requestContext, undefined);\n\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n if (!runId) {\n throw new HTTPException(400, { message: 'runId required to cancel workflow run' });\n }\n\n const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n const run = await workflow.getWorkflowRunById(runId);\n\n if (!run) {\n throw new HTTPException(404, { message: 'Workflow run not found' });\n }\n\n await validateRunOwnership(run, effectiveResourceId);\n\n const _run = await workflow.createRun({ runId, resourceId: run.resourceId });\n\n await _run.cancel();\n\n return { message: 'Workflow run cancelled' };\n } catch (error) {\n return handleError(error, 'Error canceling workflow run');\n }\n },\n});\n\n// Legacy routes (deprecated)\nexport const STREAM_LEGACY_WORKFLOW_ROUTE = createRoute({\n method: 'POST',\n path: '/workflows/:workflowId/stream-legacy',\n responseType: 'stream',\n pathParamSchema: workflowIdPathParams,\n queryParamSchema: runIdSchema,\n bodySchema: streamWorkflowBodySchema,\n responseSchema: streamResponseSchema,\n summary: '[DEPRECATED] Stream workflow with legacy format',\n description: 'Legacy endpoint for streaming workflow execution. Use /workflows/:workflowId/stream instead.',\n tags: ['Workflows', 'Legacy'],\n requiresAuth: true,\n handler: async ({ mastra, workflowId, runId, resourceId, requestContext, ...params }) => {\n try {\n const effectiveResourceId = getEffectiveResourceId(requestContext, resourceId);\n\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n if (!runId) {\n throw new HTTPException(400, { message: 'runId required to resume workflow' });\n }\n\n const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n const serverCache = mastra.getServerCache();\n\n const run = await workflow.createRun({ runId, resourceId: effectiveResourceId });\n const result = run.streamLegacy({\n ...params,\n requestContext,\n onChunk: async chunk => {\n if (serverCache) {\n const cacheKey = runId;\n await serverCache.listPush(cacheKey, chunk);\n }\n },\n });\n\n return result.stream;\n } catch (error) {\n return handleError(error, 'Error executing workflow');\n }\n },\n});\n\nexport const OBSERVE_STREAM_LEGACY_WORKFLOW_ROUTE = createRoute({\n method: 'POST',\n path: '/workflows/:workflowId/observe-stream-legacy',\n responseType: 'stream',\n pathParamSchema: workflowIdPathParams,\n queryParamSchema: runIdSchema,\n responseSchema: streamResponseSchema,\n summary: '[DEPRECATED] Observe workflow stream with legacy format',\n description: 'Legacy endpoint for observing workflow stream. Use /workflows/:workflowId/observe instead.',\n tags: ['Workflows', 'Legacy'],\n requiresAuth: true,\n handler: async ({ mastra, workflowId, runId, requestContext }) => {\n try {\n const effectiveResourceId = getEffectiveResourceId(requestContext, undefined);\n\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n if (!runId) {\n throw new HTTPException(400, { message: 'runId required to observe workflow stream' });\n }\n\n const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n const run = await workflow.getWorkflowRunById(runId);\n\n if (!run) {\n throw new HTTPException(404, { message: 'Workflow run not found' });\n }\n\n await validateRunOwnership(run, effectiveResourceId);\n\n const _run = await workflow.createRun({ runId, resourceId: run.resourceId });\n const serverCache = mastra.getServerCache();\n if (!serverCache) {\n throw new HTTPException(500, { message: 'Server cache not found' });\n }\n\n // Get cached chunks and create replay stream\n const cachedRunChunks = (await serverCache.listFromTo(runId, 0)) as StreamEvent[];\n const result = _run.observeStreamLegacy();\n\n if (!result.stream) {\n throw new HTTPException(500, { message: 'Failed to create observe stream' });\n }\n\n return createReplayStream({\n history: cachedRunChunks,\n liveSource: result.stream,\n });\n } catch (error) {\n return handleError(error, 'Error observing workflow stream');\n }\n },\n});\n\n// ============================================================================\n// Worker Step Execution Endpoint\n// Used by standalone OrchestrationWorker instances with HttpRemoteStrategy.\n// ============================================================================\n\n// `workflowId` and `runId` are taken from path params (single source of\n// truth); they are intentionally omitted from the request body schema.\nconst stepExecutionBodySchema = z.object({\n stepId: z.string(),\n executionPath: z.array(z.number().int().nonnegative()),\n stepResults: z.record(z.string(), z.any()),\n state: z.record(z.string(), z.any()),\n requestContext: z.record(z.string(), z.any()),\n input: z.any().optional(),\n resumeData: z.any().optional(),\n retryCount: z.number().int().nonnegative().optional(),\n foreachIdx: z.number().int().nonnegative().optional(),\n format: z.enum(['legacy', 'vnext']).optional(),\n perStep: z.boolean().optional(),\n validateInputs: z.boolean().optional(),\n});\n\ntype StepExecutionBody = z.infer;\n\ninterface StepExecutionHandlerArgs extends StepExecutionBody {\n mastra: Mastra;\n workflowId: string;\n runId: string;\n}\n\n// Reuse the InProcessStrategy across requests for a given Mastra instance.\n// The strategy is stateless beyond its mastra reference, but allocating it\n// per request triggers a dynamic import on the hot path.\n//\n// The dynamic import is required by `pnpm --filter ./packages/server\n// check:core-imports`: `@mastra/core/worker` is a new subpath that older\n// peer-dep floors don't expose, so a static import would fail the check.\n// Once the floor is bumped, this can become a static import.\ntype StepStrategy = { executeStep: (p: unknown) => Promise };\nconst strategyByMastra = new WeakMap();\n\nasync function getStepStrategy(mastra: Mastra): Promise {\n let cached = strategyByMastra.get(mastra);\n if (!cached) {\n const { InProcessStrategy } = await import('@mastra/core/worker');\n cached = new InProcessStrategy({ mastra }) as unknown as StepStrategy;\n strategyByMastra.set(mastra, cached);\n }\n return cached;\n}\n\n// Step execution returns the worker's StepResult. Its shape is dynamic\n// (depends on the step's output schema), so we use a permissive z.any().\nconst stepExecutionResponseSchema = z.any();\n\nexport const EXECUTE_WORKFLOW_STEP_ROUTE = createRoute({\n method: 'POST',\n path: '/workflows/:workflowId/runs/:runId/steps/execute',\n responseType: 'json',\n pathParamSchema: workflowRunPathParams,\n bodySchema: stepExecutionBodySchema,\n responseSchema: stepExecutionResponseSchema,\n summary: 'Execute a workflow step',\n description:\n 'Internal endpoint used by standalone OrchestrationWorker instances to execute workflow steps remotely via HttpRemoteStrategy.',\n tags: ['Workflows', 'Worker'],\n requiresAuth: true,\n handler: (async ({ mastra, workflowId, runId, ...body }: StepExecutionHandlerArgs) => {\n try {\n // Auth is enforced by the framework via `requiresAuth: true` and the\n // deployer's `authenticateToken` provider. Note that when NO auth\n // provider is configured, the framework currently treats the route\n // as public (see ServerAdapter.checkRouteAuth). Operators deploying\n // standalone workers must configure an auth provider to gate this\n // endpoint — there is no implicit fail-closed.\n const strategy = await getStepStrategy(mastra);\n const result = await strategy.executeStep({\n workflowId,\n runId,\n stepId: body.stepId,\n executionPath: body.executionPath,\n stepResults: body.stepResults,\n state: body.state,\n requestContext: body.requestContext,\n input: body.input,\n resumeData: body.resumeData,\n retryCount: body.retryCount,\n foreachIdx: body.foreachIdx,\n format: body.format,\n perStep: body.perStep,\n validateInputs: body.validateInputs,\n });\n\n return result;\n } catch (error) {\n return handleError(error, 'Error executing workflow step');\n }\n }) as any,\n});\n\n// Wire shape of an Event delivered through a push-mode broker. Validates the\n// fields `WorkflowEventProcessor` depends on; broker envelopes routinely carry\n// extra metadata that isn't part of `Event` itself, so we passthrough the rest.\n// `createdAt` is an ISO timestamp on the wire — the handler converts it to a\n// `Date` before forwarding to `Mastra.handleWorkflowEvent`.\nconst workflowEventSchema = z.object({\n id: z.string(),\n type: z.string(),\n data: z.unknown(),\n runId: z.string(),\n createdAt: z.string(),\n index: z.number().optional(),\n deliveryAttempt: z.number().optional(),\n});\n\nconst receiveWorkflowEventBodySchema = z.object({\n event: workflowEventSchema.passthrough(),\n});\n\nconst receiveWorkflowEventResponseSchema = z.object({\n ok: z.boolean(),\n retry: z.boolean().optional(),\n});\n\ninterface ReceiveWorkflowEventHandlerArgs {\n mastra: Mastra;\n event: Event;\n}\n\n/**\n * Generic push receive endpoint for workflow events. A push-mode broker\n * (GCP Pub/Sub push subscription, SNS, EventBridge) — or a per-broker adapter\n * that decodes the broker's envelope first — POSTs each event here and the\n * response code tells the broker whether to retry:\n *\n * - 200/204 → ack\n * - 5xx → transient, retry with backoff\n * - 4xx → poison, drop / send to DLQ\n *\n * Auth is enforced through the framework's standard `requiresAuth` flow.\n * Operators MUST configure an `authenticateToken` provider that recognizes\n * whatever credential the broker attaches (e.g. a Google-signed OIDC token\n * for GCP Pub/Sub push). Without an auth provider the endpoint is effectively\n * public — same caveat as `EXECUTE_WORKFLOW_STEP_ROUTE`.\n */\nexport const RECEIVE_WORKFLOW_EVENT_ROUTE = createRoute({\n method: 'POST',\n path: '/workflows/events',\n responseType: 'json',\n bodySchema: receiveWorkflowEventBodySchema,\n responseSchema: receiveWorkflowEventResponseSchema,\n summary: 'Receive a workflow event from a push-mode broker',\n description:\n 'Push-mode entry point for workflow events. Brokers (GCP Pub/Sub push, SNS, EventBridge) POST each event here; Mastra processes it through the same pipeline as pull-mode workers.',\n tags: ['Workflows', 'Worker'],\n requiresAuth: true,\n // Broker push endpoint: it advances runtime state rather than editing\n // definitions, so `workflows:execute` is the more accurate fit. `write` is\n // kept for back-compat with service principals that already grant it.\n requiresPermission: ['workflows:write', 'workflows:execute'],\n handler: (async ({ mastra, event }: ReceiveWorkflowEventHandlerArgs) => {\n try {\n // The wire schema carries `createdAt` as a string; coerce to Date here\n // before handing off to the in-process pipeline, which expects an `Event`.\n const rawCreatedAt = (event as unknown as { createdAt: unknown }).createdAt;\n const createdAt = rawCreatedAt instanceof Date ? rawCreatedAt : new Date(rawCreatedAt as string);\n if (Number.isNaN(createdAt.getTime())) {\n throw new HTTPException(400, { message: 'Invalid createdAt' });\n }\n return await mastra.handleWorkflowEvent({ ...event, createdAt });\n } catch (error) {\n return handleError(error, 'Error receiving workflow event');\n }\n }) as any,\n});\n"]}