@mastra/server 1.65.0-alpha.8 → 1.65.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (78) hide show
  1. package/dist/{api-schema-manifest-Dk_mN3ub.cjs → api-schema-manifest-Dkxez6Mn.cjs} +2 -2
  2. package/dist/{api-schema-manifest-Dk_mN3ub.cjs.map → api-schema-manifest-Dkxez6Mn.cjs.map} +1 -1
  3. package/dist/{api-schema-manifest-BHT0tcvI.js → api-schema-manifest-DxEVjj1H.js} +2 -2
  4. package/dist/{api-schema-manifest-BHT0tcvI.js.map → api-schema-manifest-DxEVjj1H.js.map} +1 -1
  5. package/dist/{datasets-C63D44YJ.cjs → datasets-BVbtevHd.cjs} +12 -12
  6. package/dist/datasets-BVbtevHd.cjs.map +1 -0
  7. package/dist/{datasets-DFPCu6ID.js → datasets-D0C0V2kk.js} +12 -12
  8. package/dist/datasets-D0C0V2kk.js.map +1 -0
  9. package/dist/docs/SKILL.md +1 -1
  10. package/dist/docs/assets/SOURCE_MAP.json +1 -1
  11. package/dist/docs/references/docs-server-middleware.md +17 -7
  12. package/dist/docs/references/reference-server-routes.md +44 -19
  13. package/dist/{helpers-DBAYsA50.js → helpers-610L0lwQ.js} +6 -2
  14. package/dist/helpers-610L0lwQ.js.map +1 -0
  15. package/dist/{helpers-BWxRRShz.cjs → helpers-8jl_xtug.cjs} +6 -2
  16. package/dist/helpers-8jl_xtug.cjs.map +1 -0
  17. package/dist/route-builder-BveLN9LU.js.map +1 -1
  18. package/dist/route-builder-C8n4ugUf.cjs.map +1 -1
  19. package/dist/{routes-CxuspiM8.js → routes-DD3joMdw.js} +5 -2
  20. package/dist/routes-DD3joMdw.js.map +1 -0
  21. package/dist/{routes-BqrG1FfY.cjs → routes-KL4Vw4qy.cjs} +4 -1
  22. package/dist/routes-KL4Vw4qy.cjs.map +1 -0
  23. package/dist/server/auth/helpers.d.ts.map +1 -1
  24. package/dist/server/auth/index.cjs +1 -1
  25. package/dist/server/auth/index.js +1 -1
  26. package/dist/server/handlers/agents.cjs +101 -40
  27. package/dist/server/handlers/agents.cjs.map +1 -1
  28. package/dist/server/handlers/agents.d.ts.map +1 -1
  29. package/dist/server/handlers/agents.js +101 -40
  30. package/dist/server/handlers/agents.js.map +1 -1
  31. package/dist/server/handlers/auth.cjs +1 -1
  32. package/dist/server/handlers/auth.js +1 -1
  33. package/dist/server/handlers/datasets.cjs +103 -1
  34. package/dist/server/handlers/datasets.cjs.map +1 -1
  35. package/dist/server/handlers/datasets.d.ts +211 -102
  36. package/dist/server/handlers/datasets.d.ts.map +1 -1
  37. package/dist/server/handlers/datasets.js +101 -2
  38. package/dist/server/handlers/datasets.js.map +1 -1
  39. package/dist/server/handlers/mcp-client-versions.cjs +1 -1
  40. package/dist/server/handlers/mcp-client-versions.js +1 -1
  41. package/dist/server/handlers/memory.cjs +2 -2
  42. package/dist/server/handlers/memory.cjs.map +1 -1
  43. package/dist/server/handlers/memory.js +2 -2
  44. package/dist/server/handlers/memory.js.map +1 -1
  45. package/dist/server/handlers/prompt-block-versions.cjs +1 -1
  46. package/dist/server/handlers/prompt-block-versions.js +1 -1
  47. package/dist/server/handlers/scorer-versions.cjs +1 -1
  48. package/dist/server/handlers/scorer-versions.js +1 -1
  49. package/dist/server/handlers/stored-mcp-clients.cjs +1 -1
  50. package/dist/server/handlers/stored-mcp-clients.js +1 -1
  51. package/dist/server/handlers/stored-prompt-blocks.cjs +1 -1
  52. package/dist/server/handlers/stored-prompt-blocks.js +1 -1
  53. package/dist/server/handlers/stored-scorers.cjs +1 -1
  54. package/dist/server/handlers/stored-scorers.js +1 -1
  55. package/dist/server/handlers/stored-skill-favorites.cjs +1 -1
  56. package/dist/server/handlers/stored-skill-favorites.js +1 -1
  57. package/dist/server/handlers/stored-skills.cjs +1 -1
  58. package/dist/server/handlers/stored-skills.js +1 -1
  59. package/dist/server/handlers/system.cjs +1 -1
  60. package/dist/server/handlers/system.js +1 -1
  61. package/dist/server/handlers/workflows.cjs +1 -1
  62. package/dist/server/handlers/workflows.cjs.map +1 -1
  63. package/dist/server/handlers/workflows.js +1 -1
  64. package/dist/server/handlers/workflows.js.map +1 -1
  65. package/dist/server/schemas/datasets.d.ts +41 -41
  66. package/dist/server/schemas/index.cjs +2 -2
  67. package/dist/server/schemas/index.js +2 -2
  68. package/dist/server/server-adapter/index.cjs +3 -3
  69. package/dist/server/server-adapter/index.js +3 -3
  70. package/dist/server/server-adapter/routes/datasets.d.ts +208 -102
  71. package/dist/server/server-adapter/routes/datasets.d.ts.map +1 -1
  72. package/package.json +9 -9
  73. package/dist/datasets-C63D44YJ.cjs.map +0 -1
  74. package/dist/datasets-DFPCu6ID.js.map +0 -1
  75. package/dist/helpers-BWxRRShz.cjs.map +0 -1
  76. package/dist/helpers-DBAYsA50.js.map +0 -1
  77. package/dist/routes-BqrG1FfY.cjs.map +0 -1
  78. package/dist/routes-CxuspiM8.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"workflows.js","names":[],"sources":["../../../src/server/handlers/workflows.ts"],"sourcesContent":["import type { Mastra } from '@mastra/core';\nimport type { MastraServerCache } from '@mastra/core/cache';\nimport type { RequestContext } from '@mastra/core/di';\nimport type { Event } from '@mastra/core/events';\nimport { createReplayStream } from '@mastra/core/stream';\nimport type {\n WorkflowInfo,\n ChunkType,\n StreamEvent,\n WorkflowStateField,\n WorkflowRunStatus,\n} 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 workflowRunCountsResponseSchema,\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\n/**\n * Statuses a run cannot come back from. Streaming one of these runIds again would\n * start a fresh execution under the same runId and overwrite its stored snapshot —\n * the in-memory de-dupe that protects concurrent streams only covers runs still held\n * in the workflow's run map, and a finished run has already been dropped from it.\n */\nconst TERMINAL_RUN_STATUSES: WorkflowRunStatus[] = ['success', 'failed', 'canceled', 'tripwire'];\n\n/**\n * Runs whose chunks are already being written to the cache in this process,\n * keyed by runId. A run has exactly one writer: without this, two concurrent\n * requests for the same runId each cache every chunk and the replayed history\n * comes back duplicated.\n */\nconst activeRunStreamCachers = new Set<string>();\n\n/**\n * Cache a run's chunks for later replay and return the stream to hand the client.\n *\n * The cached history belongs to the run, not to whoever happens to be watching,\n * so the caching side is driven by its own reader rather than by the client's\n * consumption. If the client disconnects mid-run its branch is cancelled while\n * this reader keeps draining, so `/observe` still replays a complete history —\n * the failure that makes reconnection necessary is exactly the one the cache has\n * to survive. Chunks buffer in the tee while a client lags, bounded by the run's\n * own length.\n */\nfunction cacheRunStream({\n cache,\n runId,\n source,\n}: {\n cache: MastraServerCache;\n runId: string;\n source: ReadableStream<ChunkType>;\n}): ReadableStream<ChunkType> {\n if (activeRunStreamCachers.has(runId)) {\n return source;\n }\n\n const [toCache, toClient] = source.tee();\n activeRunStreamCachers.add(runId);\n\n void (async () => {\n const reader = toCache.getReader();\n try {\n while (true) {\n const { done, value } = await reader.read();\n if (done) break;\n // Cache failures must not take down the run being streamed.\n await cache.listPush(runId, value).catch(() => {});\n }\n } catch {\n // The source errored; the client's branch surfaces it.\n } finally {\n reader.releaseLock();\n activeRunStreamCachers.delete(runId);\n }\n })();\n\n return toClient;\n}\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<Record<string, WorkflowInfo>>((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\ntype WorkflowRunCounts = { running: number; suspended: number };\n\nconst RUN_COUNTS_CACHE_TTL_MS = 5_000;\n// Keyed by Mastra instance so multiple apps in one process never share counts.\nconst runCountsCache = new WeakMap<object, { at: number; value: Record<string, WorkflowRunCounts> }>();\nlet runCountsNow: () => number = () => Date.now();\n\n/** Test seam — lets TTL expiry be tested without wall-clock waits. */\nexport function __setWorkflowRunCountsNow(now?: () => number) {\n runCountsNow = now ?? (() => Date.now());\n}\n\nexport const LIST_WORKFLOW_RUN_COUNTS_ROUTE = createRoute({\n method: 'GET',\n path: '/workflows/run-counts',\n responseType: 'json',\n responseSchema: workflowRunCountsResponseSchema,\n summary: 'List workflow run counts',\n description:\n 'Returns per-workflow counts of currently running and suspended (awaiting resume) runs, keyed by the workflow registry key used in the Mastra config',\n tags: ['Workflows'],\n requiresAuth: true,\n handler: (async ({ mastra, requestContext }: any) => {\n try {\n const fgaProvider = mastra.getServer?.()?.fga;\n const user = requestContext?.get('user');\n // FGA with no user can never see anything — answer before touching storage.\n if (fgaProvider && !user) {\n return {};\n }\n\n const workflows = mastra.listWorkflows({ serialized: false });\n\n const counts: Record<string, WorkflowRunCounts> = {};\n const workflowIdToRegistryKey = new Map<string, string>();\n for (const [registryKey, workflow] of Object.entries(workflows)) {\n counts[registryKey] = { running: 0, suspended: 0 };\n workflowIdToRegistryKey.set((workflow as any).id, registryKey);\n }\n\n // Runs are scoped to the caller like the runs-listing endpoint: the\n // reserved request-context resource id takes precedence for security.\n const effectiveResourceId = getEffectiveResourceId(requestContext, undefined);\n\n // The shared cache holds the unscoped, unfiltered map — usable only when\n // neither per-user FGA filtering nor a resource scope applies.\n const cacheable = !fgaProvider && !effectiveResourceId;\n if (cacheable) {\n const cached = runCountsCache.get(mastra);\n if (cached && runCountsNow() - cached.at < RUN_COUNTS_CACHE_TTL_MS) {\n return cached.value;\n }\n }\n\n const storage = mastra.getStorage();\n const workflowsStore = storage ? await storage.getStore('workflows') : undefined;\n if (workflowsStore) {\n // Cross-workflow, engine-agnostic: both execution engines persist run\n // status into the same store. Deliberately not listActiveWorkflowRuns,\n // which means running+waiting and covers the default engine only.\n const [running, suspended] = await Promise.all([\n workflowsStore.listWorkflowRuns({ status: 'running', resourceId: effectiveResourceId }),\n workflowsStore.listWorkflowRuns({ status: 'suspended', resourceId: effectiveResourceId }),\n ]);\n for (const run of running.runs) {\n const registryKey = workflowIdToRegistryKey.get(run.workflowName);\n const entry = registryKey ? counts[registryKey] : undefined;\n if (entry) entry.running++;\n }\n for (const run of suspended.runs) {\n const registryKey = workflowIdToRegistryKey.get(run.workflowName);\n const entry = registryKey ? counts[registryKey] : undefined;\n if (entry) entry.suspended++;\n }\n }\n\n if (fgaProvider) {\n const workflowList = Object.keys(counts).map(id => ({ id }));\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(counts)) {\n if (!accessibleSet.has(id)) {\n delete counts[id];\n }\n }\n return counts;\n }\n\n if (cacheable) {\n runCountsCache.set(mastra, { at: runCountsNow(), value: counts });\n }\n return counts;\n } catch (error) {\n return handleError(error, 'Error getting workflow run counts');\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, false);\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\n const existingRun = await workflow.getWorkflowRunById(runId, { withNestedWorkflows: false });\n\n if (existingRun && TERMINAL_RUN_STATUSES.includes(existingRun.status)) {\n throw new HTTPException(409, {\n message:\n `Workflow run ${runId} already finished with status \"${existingRun.status}\". ` +\n `Use /observe to read its stream back, or stream a new runId.`,\n });\n }\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 return cacheRunStream({ cache: serverCache, runId, source: result.fullStream });\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 return cacheRunStream({ cache: serverCache, runId, source: resumeResult.fullStream });\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 // Fire-and-forget: attach .catch so a rejected start (e.g. invalid input\n // schema) cannot become an unhandledRejection and tear down the process.\n void _run\n .start({\n ...params,\n requestContext,\n })\n .catch(error => {\n mastra.getLogger().error('Failed to start workflow run', { error, workflowId, runId });\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<ChunkType>({\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 // Fire-and-forget: attach .catch so a rejected resume cannot become an\n // unhandledRejection and tear down the process.\n void _run.resume({ ...params, requestContext }).catch(error => {\n mastra.getLogger().error('Failed to resume workflow run', { error, workflowId, runId });\n });\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 }).catch(error => {\n mastra.getLogger().error('Failed to restart workflow run in background', { error, workflowId, runId });\n });\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().catch(error => {\n mastra.getLogger().error('Failed to restart active workflow runs', { error, workflowId });\n });\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 // Fire-and-forget: attach .catch so a rejected time travel cannot become\n // an unhandledRejection and tear down the process.\n void _run.timeTravel({ ...params, requestContext }).catch(error => {\n mastra.getLogger().error('Failed to time travel workflow run', { error, workflowId, runId });\n });\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 return cacheRunStream({ cache: serverCache, runId, source: result.fullStream });\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<StreamEvent>({\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.unknown()),\n state: z.record(z.string(), z.unknown()),\n requestContext: z.record(z.string(), z.unknown()),\n input: z.unknown().optional(),\n resumeData: z.unknown().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<typeof stepExecutionBodySchema>;\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<unknown> };\nconst strategyByMastra = new WeakMap<Mastra, StepStrategy>();\n\nasync function getStepStrategy(mastra: Mastra): Promise<StepStrategy> {\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// and depends on the step's output schema.\nconst stepExecutionResponseSchema = z.unknown();\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"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkDA,MAAM,wBAA6C;CAAC;CAAW;CAAU;CAAY;AAAU;;;;;;;AAQ/F,MAAM,yCAAyB,IAAI,IAAY;;;;;;;;;;;;AAa/C,SAAS,eAAe,EACtB,OACA,OACA,UAK4B;CAC5B,IAAI,uBAAuB,IAAI,KAAK,GAClC,OAAO;CAGT,MAAM,CAAC,SAAS,YAAY,OAAO,IAAI;CACvC,uBAAuB,IAAI,KAAK;CAEhC,CAAM,YAAY;EAChB,MAAM,SAAS,QAAQ,UAAU;EACjC,IAAI;GACF,OAAO,MAAM;IACX,MAAM,EAAE,MAAM,UAAU,MAAM,OAAO,KAAK;IAC1C,IAAI,MAAM;IAEV,MAAM,MAAM,SAAS,OAAO,KAAK,CAAC,CAAC,YAAY,CAAC,CAAC;GACnD;EACF,QAAQ,CAER,UAAU;GACR,OAAO,YAAY;GACnB,uBAAuB,OAAO,KAAK;EACrC;CACF,EAAA,CAAG;CAEH,OAAO;AACT;AAQA,eAAe,wBAAwB,EAAE,QAAQ,cAA+B;CAC9E,MAAM,SAAS,OAAO,UAAU;CAEhC,IAAI,CAAC,YACH,MAAM,IAAI,cAAc,KAAK,EAAE,SAAS,0BAA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pB,OAAO,EAAE,OAAO,CAAC,CAAC,SAAS;CAC3B,iBAAiB,EAAE,OAAO,CAAC,CAAC,SAAS;AACvC,CAAC;;;;;;;;;;;;;;;;;AAgCD,MAAa,+BAA+B,YAAY;CACtD,QAAQ;CACR,MAAM;CACN,cAAc;CACd,YAlCqC,EAAE,OAAO,EAC9C,OAAO,oBAAoB,YAAY,EACzC,CAgCc;CACZ,gBA/ByC,EAAE,OAAO;EAClD,IAAI,EAAE,QAAQ;EACd,OAAO,EAAE,QAAQ,CAAC,CAAC,SAAS;CAC9B,CA4BkB;CAChB,SAAS;CACT,aACE;CACF,MAAM,CAAC,aAAa,QAAQ;CAC5B,cAAc;CAId,oBAAoB,CAAC,mBAAmB,mBAAmB;CAC3D,UAAU,OAAO,EAAE,QAAQ,YAA6C;EACtE,IAAI;GAGF,MAAM,eAAgB,MAA4C;GAClE,MAAM,YAAY,wBAAwB,OAAO,eAAe,IAAI,KAAK,YAAsB;GAC/F,IAAI,OAAO,MAAM,UAAU,QAAQ,CAAC,GAClC,MAAM,IAAI,cAAc,KAAK,EAAE,SAAS,oBAAoB,CAAC;GAE/D,OAAO,MAAM,OAAO,oBAAoB;IAAE,GAAG;IAAO;GAAU,CAAC;EACjE,SAAS,OAAO;GACd,OAAO,YAAY,OAAO,gCAAgC;EAC5D;CACF;AACF,CAAC"}
1
+ {"version":3,"file":"workflows.js","names":[],"sources":["../../../src/server/handlers/workflows.ts"],"sourcesContent":["import type { Mastra } from '@mastra/core';\nimport type { MastraServerCache } from '@mastra/core/cache';\nimport type { RequestContext } from '@mastra/core/di';\nimport type { Event } from '@mastra/core/events';\nimport { createReplayStream } from '@mastra/core/stream';\nimport type {\n WorkflowInfo,\n ChunkType,\n StreamEvent,\n WorkflowStateField,\n WorkflowRunStatus,\n} 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 workflowRunCountsResponseSchema,\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\n/**\n * Statuses a run cannot come back from. Streaming one of these runIds again would\n * start a fresh execution under the same runId and overwrite its stored snapshot —\n * the in-memory de-dupe that protects concurrent streams only covers runs still held\n * in the workflow's run map, and a finished run has already been dropped from it.\n */\nconst TERMINAL_RUN_STATUSES: WorkflowRunStatus[] = ['success', 'failed', 'canceled', 'tripwire'];\n\n/**\n * Runs whose chunks are already being written to the cache in this process,\n * keyed by runId. A run has exactly one writer: without this, two concurrent\n * requests for the same runId each cache every chunk and the replayed history\n * comes back duplicated.\n */\nconst activeRunStreamCachers = new Set<string>();\n\n/**\n * Cache a run's chunks for later replay and return the stream to hand the client.\n *\n * The cached history belongs to the run, not to whoever happens to be watching,\n * so the caching side is driven by its own reader rather than by the client's\n * consumption. If the client disconnects mid-run its branch is cancelled while\n * this reader keeps draining, so `/observe` still replays a complete history —\n * the failure that makes reconnection necessary is exactly the one the cache has\n * to survive. Chunks buffer in the tee while a client lags, bounded by the run's\n * own length.\n */\nfunction cacheRunStream({\n cache,\n runId,\n source,\n}: {\n cache: MastraServerCache;\n runId: string;\n source: ReadableStream<ChunkType>;\n}): ReadableStream<ChunkType> {\n if (activeRunStreamCachers.has(runId)) {\n return source;\n }\n\n const [toCache, toClient] = source.tee();\n activeRunStreamCachers.add(runId);\n\n void (async () => {\n const reader = toCache.getReader();\n try {\n while (true) {\n const { done, value } = await reader.read();\n if (done) break;\n // Cache failures must not take down the run being streamed.\n await cache.listPush(runId, value).catch(() => {});\n }\n } catch {\n // The source errored; the client's branch surfaces it.\n } finally {\n reader.releaseLock();\n activeRunStreamCachers.delete(runId);\n }\n })();\n\n return toClient;\n}\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<Record<string, WorkflowInfo>>((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\ntype WorkflowRunCounts = { running: number; suspended: number };\n\nconst RUN_COUNTS_CACHE_TTL_MS = 5_000;\n// Keyed by Mastra instance so multiple apps in one process never share counts.\nconst runCountsCache = new WeakMap<object, { at: number; value: Record<string, WorkflowRunCounts> }>();\nlet runCountsNow: () => number = () => Date.now();\n\n/** Test seam — lets TTL expiry be tested without wall-clock waits. */\nexport function __setWorkflowRunCountsNow(now?: () => number) {\n runCountsNow = now ?? (() => Date.now());\n}\n\nexport const LIST_WORKFLOW_RUN_COUNTS_ROUTE = createRoute({\n method: 'GET',\n path: '/workflows/run-counts',\n responseType: 'json',\n responseSchema: workflowRunCountsResponseSchema,\n summary: 'List workflow run counts',\n description:\n 'Returns per-workflow counts of currently running and suspended (awaiting resume) runs, keyed by the workflow registry key used in the Mastra config',\n tags: ['Workflows'],\n requiresAuth: true,\n handler: (async ({ mastra, requestContext }: any) => {\n try {\n const fgaProvider = mastra.getServer?.()?.fga;\n const user = requestContext?.get('user');\n // FGA with no user can never see anything — answer before touching storage.\n if (fgaProvider && !user) {\n return {};\n }\n\n const workflows = mastra.listWorkflows({ serialized: false });\n\n const counts: Record<string, WorkflowRunCounts> = {};\n const workflowIdToRegistryKey = new Map<string, string>();\n for (const [registryKey, workflow] of Object.entries(workflows)) {\n counts[registryKey] = { running: 0, suspended: 0 };\n workflowIdToRegistryKey.set((workflow as any).id, registryKey);\n }\n\n // Runs are scoped to the caller like the runs-listing endpoint: the\n // reserved request-context resource id takes precedence for security.\n const effectiveResourceId = getEffectiveResourceId(requestContext, undefined);\n\n // The shared cache holds the unscoped, unfiltered map — usable only when\n // neither per-user FGA filtering nor a resource scope applies.\n const cacheable = !fgaProvider && !effectiveResourceId;\n if (cacheable) {\n const cached = runCountsCache.get(mastra);\n if (cached && runCountsNow() - cached.at < RUN_COUNTS_CACHE_TTL_MS) {\n return cached.value;\n }\n }\n\n const storage = mastra.getStorage();\n const workflowsStore = storage ? await storage.getStore('workflows') : undefined;\n if (workflowsStore) {\n // Cross-workflow, engine-agnostic: both execution engines persist run\n // status into the same store. Deliberately not listActiveWorkflowRuns,\n // which means running+waiting and covers the default engine only.\n const [running, suspended] = await Promise.all([\n workflowsStore.listWorkflowRuns({ status: 'running', resourceId: effectiveResourceId }),\n workflowsStore.listWorkflowRuns({ status: 'suspended', resourceId: effectiveResourceId }),\n ]);\n for (const run of running.runs) {\n const registryKey = workflowIdToRegistryKey.get(run.workflowName);\n const entry = registryKey ? counts[registryKey] : undefined;\n if (entry) entry.running++;\n }\n for (const run of suspended.runs) {\n const registryKey = workflowIdToRegistryKey.get(run.workflowName);\n const entry = registryKey ? counts[registryKey] : undefined;\n if (entry) entry.suspended++;\n }\n }\n\n if (fgaProvider) {\n const workflowList = Object.keys(counts).map(id => ({ id }));\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(counts)) {\n if (!accessibleSet.has(id)) {\n delete counts[id];\n }\n }\n return counts;\n }\n\n if (cacheable) {\n runCountsCache.set(mastra, { at: runCountsNow(), value: counts });\n }\n return counts;\n } catch (error) {\n return handleError(error, 'Error getting workflow run counts');\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, false);\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=result,steps). Available fields: result, error, payload, steps, activeStepsPath, serializedStepGraph. Metadata fields (runId, workflowName, resourceId, createdAt, updatedAt) and status are always included.',\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\n const existingRun = await workflow.getWorkflowRunById(runId, { withNestedWorkflows: false });\n\n if (existingRun && TERMINAL_RUN_STATUSES.includes(existingRun.status)) {\n throw new HTTPException(409, {\n message:\n `Workflow run ${runId} already finished with status \"${existingRun.status}\". ` +\n `Use /observe to read its stream back, or stream a new runId.`,\n });\n }\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 return cacheRunStream({ cache: serverCache, runId, source: result.fullStream });\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 return cacheRunStream({ cache: serverCache, runId, source: resumeResult.fullStream });\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 // Fire-and-forget: attach .catch so a rejected start (e.g. invalid input\n // schema) cannot become an unhandledRejection and tear down the process.\n void _run\n .start({\n ...params,\n requestContext,\n })\n .catch(error => {\n mastra.getLogger().error('Failed to start workflow run', { error, workflowId, runId });\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<ChunkType>({\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 // Fire-and-forget: attach .catch so a rejected resume cannot become an\n // unhandledRejection and tear down the process.\n void _run.resume({ ...params, requestContext }).catch(error => {\n mastra.getLogger().error('Failed to resume workflow run', { error, workflowId, runId });\n });\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 }).catch(error => {\n mastra.getLogger().error('Failed to restart workflow run in background', { error, workflowId, runId });\n });\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().catch(error => {\n mastra.getLogger().error('Failed to restart active workflow runs', { error, workflowId });\n });\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 // Fire-and-forget: attach .catch so a rejected time travel cannot become\n // an unhandledRejection and tear down the process.\n void _run.timeTravel({ ...params, requestContext }).catch(error => {\n mastra.getLogger().error('Failed to time travel workflow run', { error, workflowId, runId });\n });\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 return cacheRunStream({ cache: serverCache, runId, source: result.fullStream });\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<StreamEvent>({\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.unknown()),\n state: z.record(z.string(), z.unknown()),\n requestContext: z.record(z.string(), z.unknown()),\n input: z.unknown().optional(),\n resumeData: z.unknown().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<typeof stepExecutionBodySchema>;\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<unknown> };\nconst strategyByMastra = new WeakMap<Mastra, StepStrategy>();\n\nasync function getStepStrategy(mastra: Mastra): Promise<StepStrategy> {\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// and depends on the step's output schema.\nconst stepExecutionResponseSchema = z.unknown();\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"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkDA,MAAM,wBAA6C;CAAC;CAAW;CAAU;CAAY;AAAU;;;;;;;AAQ/F,MAAM,yCAAyB,IAAI,IAAY;;;;;;;;;;;;AAa/C,SAAS,eAAe,EACtB,OACA,OACA,UAK4B;CAC5B,IAAI,uBAAuB,IAAI,KAAK,GAClC,OAAO;CAGT,MAAM,CAAC,SAAS,YAAY,OAAO,IAAI;CACvC,uBAAuB,IAAI,KAAK;CAEhC,CAAM,YAAY;EAChB,MAAM,SAAS,QAAQ,UAAU;EACjC,IAAI;GACF,OAAO,MAAM;IACX,MAAM,EAAE,MAAM,UAAU,MAAM,OAAO,KAAK;IAC1C,IAAI,MAAM;IAEV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ZodOptional<z.ZodUnknown>;
483
483
  expectedTrajectory: z.ZodOptional<z.ZodUnknown>;
484
- toolMocks: z.ZodOptional<z.ZodArray<z.ZodObject<{
484
+ toolMocks: z.ZodNullable<z.ZodOptional<z.ZodArray<z.ZodObject<{
485
485
  toolName: z.ZodString;
486
486
  args: z.ZodRecord<z.ZodString, z.ZodUnknown>;
487
487
  output: z.ZodUnknown;
@@ -489,15 +489,15 @@ export declare const datasetItemResponseSchema: z.ZodObject<{
489
489
  ignore: "ignore";
490
490
  strict: "strict";
491
491
  }>>;
492
- }, z.core.$strip>>>;
493
- unmockedToolPolicy: z.ZodOptional<z.ZodEnum<{
492
+ }, z.core.$strip>>>>;
493
+ unmockedToolPolicy: z.ZodNullable<z.ZodOptional<z.ZodEnum<{
494
494
  allow: "allow";
495
495
  deny: "deny";
496
- }>>;
497
- scorerIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
498
- requestContext: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
499
- metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
500
- source: z.ZodOptional<z.ZodObject<{
496
+ }>>>;
497
+ scorerIds: z.ZodNullable<z.ZodOptional<z.ZodArray<z.ZodString>>>;
498
+ requestContext: z.ZodNullable<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
499
+ metadata: z.ZodNullable<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
500
+ source: z.ZodNullable<z.ZodOptional<z.ZodObject<{
501
501
  type: z.ZodEnum<{
502
502
  "candidate-screener": "candidate-screener";
503
503
  csv: "csv";
@@ -507,7 +507,7 @@ export declare const datasetItemResponseSchema: z.ZodObject<{
507
507
  trace: "trace";
508
508
  }>;
509
509
  referenceId: z.ZodOptional<z.ZodString>;
510
- }, z.core.$strip>>;
510
+ }, z.core.$strip>>>;
511
511
  createdAt: z.ZodCoercedDate<unknown>;
512
512
  updatedAt: z.ZodCoercedDate<unknown>;
513
513
  }, z.core.$strip>;
@@ -801,7 +801,7 @@ export declare const listItemsResponseSchema: z.ZodObject<{
801
801
  input: z.ZodUnknown;
802
802
  groundTruth: z.ZodOptional<z.ZodUnknown>;
803
803
  expectedTrajectory: z.ZodOptional<z.ZodUnknown>;
804
- toolMocks: z.ZodOptional<z.ZodArray<z.ZodObject<{
804
+ toolMocks: z.ZodNullable<z.ZodOptional<z.ZodArray<z.ZodObject<{
805
805
  toolName: z.ZodString;
806
806
  args: z.ZodRecord<z.ZodString, z.ZodUnknown>;
807
807
  output: z.ZodUnknown;
@@ -809,15 +809,15 @@ export declare const listItemsResponseSchema: z.ZodObject<{
809
809
  ignore: "ignore";
810
810
  strict: "strict";
811
811
  }>>;
812
- }, z.core.$strip>>>;
813
- unmockedToolPolicy: z.ZodOptional<z.ZodEnum<{
812
+ }, z.core.$strip>>>>;
813
+ unmockedToolPolicy: z.ZodNullable<z.ZodOptional<z.ZodEnum<{
814
814
  allow: "allow";
815
815
  deny: "deny";
816
- }>>;
817
- scorerIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
818
- requestContext: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
819
- metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
820
- source: z.ZodOptional<z.ZodObject<{
816
+ }>>>;
817
+ scorerIds: z.ZodNullable<z.ZodOptional<z.ZodArray<z.ZodString>>>;
818
+ requestContext: z.ZodNullable<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
819
+ metadata: z.ZodNullable<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
820
+ source: z.ZodNullable<z.ZodOptional<z.ZodObject<{
821
821
  type: z.ZodEnum<{
822
822
  "candidate-screener": "candidate-screener";
823
823
  csv: "csv";
@@ -827,7 +827,7 @@ export declare const listItemsResponseSchema: z.ZodObject<{
827
827
  trace: "trace";
828
828
  }>;
829
829
  referenceId: z.ZodOptional<z.ZodString>;
830
- }, z.core.$strip>>;
830
+ }, z.core.$strip>>>;
831
831
  createdAt: z.ZodCoercedDate<unknown>;
832
832
  updatedAt: z.ZodCoercedDate<unknown>;
833
833
  }, z.core.$strip>>;
@@ -982,7 +982,7 @@ export declare const itemVersionResponseSchema: z.ZodObject<{
982
982
  input: z.ZodUnknown;
983
983
  groundTruth: z.ZodOptional<z.ZodUnknown>;
984
984
  expectedTrajectory: z.ZodOptional<z.ZodUnknown>;
985
- toolMocks: z.ZodOptional<z.ZodArray<z.ZodObject<{
985
+ toolMocks: z.ZodNullable<z.ZodOptional<z.ZodArray<z.ZodObject<{
986
986
  toolName: z.ZodString;
987
987
  args: z.ZodRecord<z.ZodString, z.ZodUnknown>;
988
988
  output: z.ZodUnknown;
@@ -990,14 +990,14 @@ export declare const itemVersionResponseSchema: z.ZodObject<{
990
990
  ignore: "ignore";
991
991
  strict: "strict";
992
992
  }>>;
993
- }, z.core.$strip>>>;
994
- unmockedToolPolicy: z.ZodOptional<z.ZodEnum<{
993
+ }, z.core.$strip>>>>;
994
+ unmockedToolPolicy: z.ZodNullable<z.ZodOptional<z.ZodEnum<{
995
995
  allow: "allow";
996
996
  deny: "deny";
997
- }>>;
998
- scorerIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
999
- requestContext: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
1000
- metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
997
+ }>>>;
998
+ scorerIds: z.ZodNullable<z.ZodOptional<z.ZodArray<z.ZodString>>>;
999
+ requestContext: z.ZodNullable<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
1000
+ metadata: z.ZodNullable<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
1001
1001
  validTo: z.ZodNullable<z.ZodNumber>;
1002
1002
  isDeleted: z.ZodBoolean;
1003
1003
  createdAt: z.ZodCoercedDate<unknown>;
@@ -1011,7 +1011,7 @@ export declare const listItemVersionsResponseSchema: z.ZodObject<{
1011
1011
  input: z.ZodUnknown;
1012
1012
  groundTruth: z.ZodOptional<z.ZodUnknown>;
1013
1013
  expectedTrajectory: z.ZodOptional<z.ZodUnknown>;
1014
- toolMocks: z.ZodOptional<z.ZodArray<z.ZodObject<{
1014
+ toolMocks: z.ZodNullable<z.ZodOptional<z.ZodArray<z.ZodObject<{
1015
1015
  toolName: z.ZodString;
1016
1016
  args: z.ZodRecord<z.ZodString, z.ZodUnknown>;
1017
1017
  output: z.ZodUnknown;
@@ -1019,14 +1019,14 @@ export declare const listItemVersionsResponseSchema: z.ZodObject<{
1019
1019
  ignore: "ignore";
1020
1020
  strict: "strict";
1021
1021
  }>>;
1022
- }, z.core.$strip>>>;
1023
- unmockedToolPolicy: z.ZodOptional<z.ZodEnum<{
1022
+ }, z.core.$strip>>>>;
1023
+ unmockedToolPolicy: z.ZodNullable<z.ZodOptional<z.ZodEnum<{
1024
1024
  allow: "allow";
1025
1025
  deny: "deny";
1026
- }>>;
1027
- scorerIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
1028
- requestContext: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
1029
- metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
1026
+ }>>>;
1027
+ scorerIds: z.ZodNullable<z.ZodOptional<z.ZodArray<z.ZodString>>>;
1028
+ requestContext: z.ZodNullable<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
1029
+ metadata: z.ZodNullable<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
1030
1030
  validTo: z.ZodNullable<z.ZodNumber>;
1031
1031
  isDeleted: z.ZodBoolean;
1032
1032
  createdAt: z.ZodCoercedDate<unknown>;
@@ -1218,7 +1218,7 @@ export declare const batchInsertItemsResponseSchema: z.ZodObject<{
1218
1218
  input: z.ZodUnknown;
1219
1219
  groundTruth: z.ZodOptional<z.ZodUnknown>;
1220
1220
  expectedTrajectory: z.ZodOptional<z.ZodUnknown>;
1221
- toolMocks: z.ZodOptional<z.ZodArray<z.ZodObject<{
1221
+ toolMocks: z.ZodNullable<z.ZodOptional<z.ZodArray<z.ZodObject<{
1222
1222
  toolName: z.ZodString;
1223
1223
  args: z.ZodRecord<z.ZodString, z.ZodUnknown>;
1224
1224
  output: z.ZodUnknown;
@@ -1226,15 +1226,15 @@ export declare const batchInsertItemsResponseSchema: z.ZodObject<{
1226
1226
  ignore: "ignore";
1227
1227
  strict: "strict";
1228
1228
  }>>;
1229
- }, z.core.$strip>>>;
1230
- unmockedToolPolicy: z.ZodOptional<z.ZodEnum<{
1229
+ }, z.core.$strip>>>>;
1230
+ unmockedToolPolicy: z.ZodNullable<z.ZodOptional<z.ZodEnum<{
1231
1231
  allow: "allow";
1232
1232
  deny: "deny";
1233
- }>>;
1234
- scorerIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
1235
- requestContext: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
1236
- metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
1237
- source: z.ZodOptional<z.ZodObject<{
1233
+ }>>>;
1234
+ scorerIds: z.ZodNullable<z.ZodOptional<z.ZodArray<z.ZodString>>>;
1235
+ requestContext: z.ZodNullable<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
1236
+ metadata: z.ZodNullable<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
1237
+ source: z.ZodNullable<z.ZodOptional<z.ZodObject<{
1238
1238
  type: z.ZodEnum<{
1239
1239
  "candidate-screener": "candidate-screener";
1240
1240
  csv: "csv";
@@ -1244,7 +1244,7 @@ export declare const batchInsertItemsResponseSchema: z.ZodObject<{
1244
1244
  trace: "trace";
1245
1245
  }>;
1246
1246
  referenceId: z.ZodOptional<z.ZodString>;
1247
- }, z.core.$strip>>;
1247
+ }, z.core.$strip>>>;
1248
1248
  createdAt: z.ZodCoercedDate<unknown>;
1249
1249
  updatedAt: z.ZodCoercedDate<unknown>;
1250
1250
  }, z.core.$strip>>;