@mastra/server 1.77.0-alpha.1 → 1.77.0-alpha.3

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 (30) hide show
  1. package/dist/{dist-B6B4Cxda.js → dist-C6Y74AMV.js} +8 -8
  2. package/dist/dist-C6Y74AMV.js.map +1 -0
  3. package/dist/{dist-BGfXR4Xj.cjs → dist-D0yst49-.cjs} +8 -8
  4. package/dist/dist-D0yst49-.cjs.map +1 -0
  5. package/dist/docs/SKILL.md +1 -1
  6. package/dist/docs/assets/SOURCE_MAP.json +1 -1
  7. package/dist/server/handlers/agent-builder.cjs +1 -1
  8. package/dist/server/handlers/agent-builder.js +1 -1
  9. package/dist/server/handlers/agent-controller.cjs +20 -7
  10. package/dist/server/handlers/agent-controller.cjs.map +1 -1
  11. package/dist/server/handlers/agent-controller.d.ts +2 -0
  12. package/dist/server/handlers/agent-controller.d.ts.map +1 -1
  13. package/dist/server/handlers/agent-controller.js +20 -7
  14. package/dist/server/handlers/agent-controller.js.map +1 -1
  15. package/dist/server/handlers/error.cjs +9 -4
  16. package/dist/server/handlers/error.cjs.map +1 -1
  17. package/dist/server/handlers/error.d.ts.map +1 -1
  18. package/dist/server/handlers/error.js +9 -4
  19. package/dist/server/handlers/error.js.map +1 -1
  20. package/dist/server/handlers/workflows.cjs +8 -0
  21. package/dist/server/handlers/workflows.cjs.map +1 -1
  22. package/dist/server/handlers/workflows.d.ts +8 -0
  23. package/dist/server/handlers/workflows.d.ts.map +1 -1
  24. package/dist/server/handlers/workflows.js +8 -0
  25. package/dist/server/handlers/workflows.js.map +1 -1
  26. package/dist/server/server-adapter/routes/workflows.d.ts +2 -0
  27. package/dist/server/server-adapter/routes/workflows.d.ts.map +1 -1
  28. package/package.json +7 -7
  29. package/dist/dist-B6B4Cxda.js.map +0 -1
  30. package/dist/dist-BGfXR4Xj.cjs.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"error.cjs","names":["HTTPException"],"sources":["../../../src/server/handlers/error.ts"],"sourcesContent":["import type { ZodError } from 'zod';\n\nimport { HTTPException } from '../http-exception';\nimport type { StatusCode } from '../http-exception';\nimport type { ApiError } from '../types';\n\n/**\n * Duck-typed interface for ZodError-like objects.\n * Note: Zod v4 uses PropertyKey[] (string | number | symbol) for path.\n */\nexport interface ZodErrorLike {\n issues: Array<{\n path: PropertyKey[];\n message: string;\n }>;\n}\n\n/**\n * Recognition for `ModelNotAllowedError` from `@mastra/core/agent-builder/ee`.\n *\n * Inlined as a duck check rather than imported so that `handleError` (wired\n * into every route) does not force a load-time dependency on the\n * `@mastra/core/agent-builder/ee` subpath. That subpath only ships in\n * `@mastra/core >= 1.34.0`; deploys whose bundled `@mastra/server` resolves\n * against an older core would otherwise crash at startup with\n * `ERR_MODULE_NOT_FOUND` on `@mastra/core/dist/agent-builder/ee/index.js`.\n */\nconst MODEL_NOT_ALLOWED_CODE = 'MODEL_NOT_ALLOWED';\n\ninterface ModelNotAllowedErrorLike extends Error {\n code: typeof MODEL_NOT_ALLOWED_CODE;\n allowed?: unknown;\n attempted?: unknown;\n offendingLabel?: string;\n}\n\nfunction isModelNotAllowedError(error: unknown): error is ModelNotAllowedErrorLike {\n return error instanceof Error && (error as { code?: unknown }).code === MODEL_NOT_ALLOWED_CODE;\n}\n\nconst WORKFLOW_SCHEMA_VALIDATION_FAILED_CODE = 'WORKFLOW_SCHEMA_VALIDATION_FAILED';\n\nfunction isWorkflowSchemaValidationError(error: unknown): error is Error {\n return error instanceof Error && (error as { id?: unknown }).id === WORKFLOW_SCHEMA_VALIDATION_FAILED_CODE;\n}\n\nconst WORKFLOW_RESUME_ALREADY_CLAIMED_CODE = 'WORKFLOW_RESUME_ALREADY_CLAIMED';\n\nfunction isWorkflowResumeAlreadyClaimedError(error: unknown): error is Error {\n return error instanceof Error && (error as { id?: unknown }).id === WORKFLOW_RESUME_ALREADY_CLAIMED_CODE;\n}\n\n/**\n * Durable agent errors for a request that conflicts with the run's state:\n * another execution owns the run, it is already being recovered, it lost a\n * concurrent claim, or it is suspended (recover). Matched by id, like the\n * other checks here, so the server doesn't depend on core exporting them.\n */\nconst DURABLE_RUN_CONFLICT_CODES = new Set([\n 'DURABLE_AGENT_RUN_ACTIVE',\n 'DURABLE_AGENT_RECOVER_RUN_ACTIVE_LOCALLY',\n 'DURABLE_AGENT_RECOVER_ALREADY_IN_PROGRESS',\n 'DURABLE_AGENT_RECOVER_RUN_SUSPENDED',\n 'DURABLE_AGENT_EXECUTION_CONFLICT',\n]);\n\nfunction isDurableRunConflictError(error: unknown): error is Error {\n const id = (error as { id?: unknown } | undefined)?.id;\n return error instanceof Error && typeof id === 'string' && DURABLE_RUN_CONFLICT_CODES.has(id);\n}\n\nconst FEEDBACK_REVIEW_STATUS_CONFLICT_CODE = 'OBSERVABILITY_UPDATE_FEEDBACK_REVIEW_STATUS_CONFLICT';\n\nfunction isFeedbackReviewStatusConflictError(error: unknown): error is Error {\n return error instanceof Error && (error as { id?: unknown }).id === FEEDBACK_REVIEW_STATUS_CONFLICT_CODE;\n}\n\n/**\n * Matches the `OBSERVABILITY_STORAGE_*_NOT_IMPLEMENTED` MastraError the base\n * observability store throws for every optional method a store doesn't\n * implement. Checked by id (not `instanceof`) so it holds across duplicated\n * `@mastra/core` installs.\n */\nfunction isObservabilityStorageNotImplementedError(error: unknown): error is Error {\n const id = error && typeof error === 'object' && 'id' in error ? error.id : undefined;\n return typeof id === 'string' && id.startsWith('OBSERVABILITY_STORAGE_') && id.endsWith('_NOT_IMPLEMENTED');\n}\n\n/**\n * Structural check for ZodError instances.\n *\n * Avoids `instanceof ZodError` because consumers can resolve `'zod'` to a\n * different package instance (e.g. `zod@^3`) than the one a server adapter is\n * bundled with (`zod@^4`). In that case `instanceof` is false and validation\n * errors fall through to a generic response that drops field-path information.\n *\n * See https://github.com/mastra-ai/mastra/issues/17167.\n */\nexport function isZodError(error: unknown): error is ZodError<any> {\n return (\n !!error &&\n typeof error === 'object' &&\n (error as { name?: unknown }).name === 'ZodError' &&\n Array.isArray((error as { issues?: unknown }).issues)\n );\n}\n\n/**\n * Formats a ZodError into a structured validation error response.\n * Returns an object with an error message and an array of field-specific issues.\n */\nexport function formatZodError(\n error: ZodErrorLike,\n context: string,\n): { error: string; issues: Array<{ field: string; message: string }> } {\n const issues = error.issues.map(e => ({\n field: e.path.length > 0 ? e.path.map(p => String(p)).join('.') : 'root',\n message: e.message,\n }));\n\n return {\n error: `Invalid ${context}`,\n issues,\n };\n}\n\n// Helper to handle errors consistently\nexport function handleError(error: unknown, defaultMessage: string): never {\n if (isModelNotAllowedError(error)) {\n const body = {\n error: {\n code: error.code,\n message: error.message,\n allowed: error.allowed,\n attempted: error.attempted,\n offendingLabel: error.offendingLabel,\n },\n };\n const res = new Response(JSON.stringify(body), {\n status: 422,\n headers: { 'content-type': 'application/json' },\n });\n throw new HTTPException(422, {\n res,\n message: error.message,\n cause: error,\n });\n }\n\n // A losing concurrent resume, or a recover of a run that is live or suspended, is a conflict on\n // run state, not a malformed request, so it maps to 409 and clients can distinguish it from a\n // 400/500 and re-read the run.\n if (isWorkflowResumeAlreadyClaimedError(error) || isDurableRunConflictError(error)) {\n throw new HTTPException(409, {\n message: error.message,\n stack: error.stack,\n cause: error,\n });\n }\n\n // The feedback row changed under a review-status update, so the caller re-reads and retries;\n // that is a conflict, not a broken store.\n if (isFeedbackReviewStatusConflictError(error)) {\n throw new HTTPException(409, {\n message: error.message,\n stack: error.stack,\n cause: error,\n });\n }\n\n if (isWorkflowSchemaValidationError(error)) {\n throw new HTTPException(400, {\n message: error.message,\n stack: error.stack,\n cause: error,\n });\n }\n\n // Optional observability APIs (feedback, metrics, logs, scores, ...) throw\n // `*_NOT_IMPLEMENTED` on stores that don't support them. That's a missing\n // capability, not a server fault, so it maps to 501 — which server adapters\n // log as a warning instead of an error. The message is preserved because\n // clients match on it to detect unsupported operations. Clients should check\n // `GET /observability/capabilities` before calling optional routes.\n if (isObservabilityStorageNotImplementedError(error)) {\n throw new HTTPException(501, {\n message: error.message,\n stack: error.stack,\n cause: error,\n });\n }\n\n const apiError = error as ApiError;\n\n const apiErrorStatus = apiError.status || apiError.details?.status || 500;\n\n throw new HTTPException(apiErrorStatus as StatusCode, {\n message: apiError.message || defaultMessage,\n stack: apiError.stack,\n cause: apiError.cause,\n });\n}\n"],"mappings":";;;;;;;;;;;;;;AA2BA,MAAM,yBAAyB;AAS/B,SAAS,uBAAuB,OAAmD;CACjF,OAAO,iBAAiB,SAAU,MAA6B,SAAS;AAC1E;AAEA,MAAM,yCAAyC;AAE/C,SAAS,gCAAgC,OAAgC;CACvE,OAAO,iBAAiB,SAAU,MAA2B,OAAO;AACtE;AAEA,MAAM,uCAAuC;AAE7C,SAAS,oCAAoC,OAAgC;CAC3E,OAAO,iBAAiB,SAAU,MAA2B,OAAO;AACtE;;;;;;;AAQA,MAAM,6CAA6B,IAAI,IAAI;CACzC;CACA;CACA;CACA;CACA;AACF,CAAC;AAED,SAAS,0BAA0B,OAAgC;CACjE,MAAM,KAAM,OAAwC;CACpD,OAAO,iBAAiB,SAAS,OAAO,OAAO,YAAY,2BAA2B,IAAI,EAAE;AAC9F;AAEA,MAAM,uCAAuC;AAE7C,SAAS,oCAAoC,OAAgC;CAC3E,OAAO,iBAAiB,SAAU,MAA2B,OAAO;AACtE;;;;;;;AAQA,SAAS,0CAA0C,OAAgC;CACjF,MAAM,KAAK,SAAS,OAAO,UAAU,YAAY,QAAQ,QAAQ,MAAM,KAAK,KAAA;CAC5E,OAAO,OAAO,OAAO,YAAY,GAAG,WAAW,wBAAwB,KAAK,GAAG,SAAS,kBAAkB;AAC5G;;;;;;;;;;;AAYA,SAAgB,WAAW,OAAwC;CACjE,OACE,CAAC,CAAC,SACF,OAAO,UAAU,YAChB,MAA6B,SAAS,cACvC,MAAM,QAAS,MAA+B,MAAM;AAExD;;;;;AAMA,SAAgB,eACd,OACA,SACsE;CACtE,MAAM,SAAS,MAAM,OAAO,KAAI,OAAM;EACpC,OAAO,EAAE,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AACH"}
1
+ {"version":3,"file":"error.cjs","names":["HTTPException"],"sources":["../../../src/server/handlers/error.ts"],"sourcesContent":["import type { ZodError } from 'zod';\n\nimport { HTTPException } from '../http-exception';\nimport type { StatusCode } from '../http-exception';\nimport type { ApiError } from '../types';\n\n/**\n * Duck-typed interface for ZodError-like objects.\n * Note: Zod v4 uses PropertyKey[] (string | number | symbol) for path.\n */\nexport interface ZodErrorLike {\n issues: Array<{\n path: PropertyKey[];\n message: string;\n }>;\n}\n\n/**\n * Recognition for `ModelNotAllowedError` from `@mastra/core/agent-builder/ee`.\n *\n * Inlined as a duck check rather than imported so that `handleError` (wired\n * into every route) does not force a load-time dependency on the\n * `@mastra/core/agent-builder/ee` subpath. That subpath only ships in\n * `@mastra/core >= 1.34.0`; deploys whose bundled `@mastra/server` resolves\n * against an older core would otherwise crash at startup with\n * `ERR_MODULE_NOT_FOUND` on `@mastra/core/dist/agent-builder/ee/index.js`.\n */\nconst MODEL_NOT_ALLOWED_CODE = 'MODEL_NOT_ALLOWED';\n\ninterface ModelNotAllowedErrorLike extends Error {\n code: typeof MODEL_NOT_ALLOWED_CODE;\n allowed?: unknown;\n attempted?: unknown;\n offendingLabel?: string;\n}\n\nfunction isModelNotAllowedError(error: unknown): error is ModelNotAllowedErrorLike {\n return error instanceof Error && (error as { code?: unknown }).code === MODEL_NOT_ALLOWED_CODE;\n}\n\nconst WORKFLOW_SCHEMA_VALIDATION_FAILED_CODE = 'WORKFLOW_SCHEMA_VALIDATION_FAILED';\n\nfunction isWorkflowSchemaValidationError(error: unknown): error is Error {\n return error instanceof Error && (error as { id?: unknown }).id === WORKFLOW_SCHEMA_VALIDATION_FAILED_CODE;\n}\n\n// A resume the run can't accept: another resume claimed it, or it isn't waiting to be resumed.\nconst RESUME_ALREADY_CLAIMED_CODES = new Set([\n 'WORKFLOW_RESUME_ALREADY_CLAIMED',\n 'AGENT_RESUME_ALREADY_CLAIMED',\n 'WORKFLOW_RUN_NOT_SUSPENDED',\n 'AGENT_RESUME_RUN_NOT_SUSPENDED',\n]);\n\nfunction isResumeAlreadyClaimedError(error: unknown): error is Error {\n return error instanceof Error && RESUME_ALREADY_CLAIMED_CODES.has((error as { id?: unknown }).id as string);\n}\n\n/**\n * Durable agent errors for a request that conflicts with the run's state:\n * another execution owns the run, it is already being recovered, it lost a\n * concurrent claim, or it is suspended (recover). Matched by id, like the\n * other checks here, so the server doesn't depend on core exporting them.\n */\nconst DURABLE_RUN_CONFLICT_CODES = new Set([\n 'DURABLE_AGENT_RUN_ACTIVE',\n 'DURABLE_AGENT_RECOVER_RUN_ACTIVE_LOCALLY',\n 'DURABLE_AGENT_RECOVER_ALREADY_IN_PROGRESS',\n 'DURABLE_AGENT_RECOVER_RUN_SUSPENDED',\n 'DURABLE_AGENT_EXECUTION_CONFLICT',\n]);\n\nfunction isDurableRunConflictError(error: unknown): error is Error {\n const id = (error as { id?: unknown } | undefined)?.id;\n return error instanceof Error && typeof id === 'string' && DURABLE_RUN_CONFLICT_CODES.has(id);\n}\n\nconst FEEDBACK_REVIEW_STATUS_CONFLICT_CODE = 'OBSERVABILITY_UPDATE_FEEDBACK_REVIEW_STATUS_CONFLICT';\n\nfunction isFeedbackReviewStatusConflictError(error: unknown): error is Error {\n return error instanceof Error && (error as { id?: unknown }).id === FEEDBACK_REVIEW_STATUS_CONFLICT_CODE;\n}\n\n/**\n * Matches the `OBSERVABILITY_STORAGE_*_NOT_IMPLEMENTED` MastraError the base\n * observability store throws for every optional method a store doesn't\n * implement. Checked by id (not `instanceof`) so it holds across duplicated\n * `@mastra/core` installs.\n */\nfunction isObservabilityStorageNotImplementedError(error: unknown): error is Error {\n const id = error && typeof error === 'object' && 'id' in error ? error.id : undefined;\n return typeof id === 'string' && id.startsWith('OBSERVABILITY_STORAGE_') && id.endsWith('_NOT_IMPLEMENTED');\n}\n\n/**\n * Structural check for ZodError instances.\n *\n * Avoids `instanceof ZodError` because consumers can resolve `'zod'` to a\n * different package instance (e.g. `zod@^3`) than the one a server adapter is\n * bundled with (`zod@^4`). In that case `instanceof` is false and validation\n * errors fall through to a generic response that drops field-path information.\n *\n * See https://github.com/mastra-ai/mastra/issues/17167.\n */\nexport function isZodError(error: unknown): error is ZodError<any> {\n return (\n !!error &&\n typeof error === 'object' &&\n (error as { name?: unknown }).name === 'ZodError' &&\n Array.isArray((error as { issues?: unknown }).issues)\n );\n}\n\n/**\n * Formats a ZodError into a structured validation error response.\n * Returns an object with an error message and an array of field-specific issues.\n */\nexport function formatZodError(\n error: ZodErrorLike,\n context: string,\n): { error: string; issues: Array<{ field: string; message: string }> } {\n const issues = error.issues.map(e => ({\n field: e.path.length > 0 ? e.path.map(p => String(p)).join('.') : 'root',\n message: e.message,\n }));\n\n return {\n error: `Invalid ${context}`,\n issues,\n };\n}\n\n// Helper to handle errors consistently\nexport function handleError(error: unknown, defaultMessage: string): never {\n if (isModelNotAllowedError(error)) {\n const body = {\n error: {\n code: error.code,\n message: error.message,\n allowed: error.allowed,\n attempted: error.attempted,\n offendingLabel: error.offendingLabel,\n },\n };\n const res = new Response(JSON.stringify(body), {\n status: 422,\n headers: { 'content-type': 'application/json' },\n });\n throw new HTTPException(422, {\n res,\n message: error.message,\n cause: error,\n });\n }\n\n // A losing concurrent resume, or a recover of a run that is live or suspended, is a conflict on\n // run state, not a malformed request, so it maps to 409 and clients can distinguish it from a\n // 400/500 and re-read the run.\n if (isResumeAlreadyClaimedError(error) || isDurableRunConflictError(error)) {\n throw new HTTPException(409, {\n message: error.message,\n stack: error.stack,\n cause: error,\n });\n }\n\n // The feedback row changed under a review-status update, so the caller re-reads and retries;\n // that is a conflict, not a broken store.\n if (isFeedbackReviewStatusConflictError(error)) {\n throw new HTTPException(409, {\n message: error.message,\n stack: error.stack,\n cause: error,\n });\n }\n\n if (isWorkflowSchemaValidationError(error)) {\n throw new HTTPException(400, {\n message: error.message,\n stack: error.stack,\n cause: error,\n });\n }\n\n // Optional observability APIs (feedback, metrics, logs, scores, ...) throw\n // `*_NOT_IMPLEMENTED` on stores that don't support them. That's a missing\n // capability, not a server fault, so it maps to 501 — which server adapters\n // log as a warning instead of an error. The message is preserved because\n // clients match on it to detect unsupported operations. Clients should check\n // `GET /observability/capabilities` before calling optional routes.\n if (isObservabilityStorageNotImplementedError(error)) {\n throw new HTTPException(501, {\n message: error.message,\n stack: error.stack,\n cause: error,\n });\n }\n\n const apiError = error as ApiError;\n\n const apiErrorStatus = apiError.status || apiError.details?.status || 500;\n\n throw new HTTPException(apiErrorStatus as StatusCode, {\n message: apiError.message || defaultMessage,\n stack: apiError.stack,\n cause: apiError.cause,\n });\n}\n"],"mappings":";;;;;;;;;;;;;;AA2BA,MAAM,yBAAyB;AAS/B,SAAS,uBAAuB,OAAmD;CACjF,OAAO,iBAAiB,SAAU,MAA6B,SAAS;AAC1E;AAEA,MAAM,yCAAyC;AAE/C,SAAS,gCAAgC,OAAgC;CACvE,OAAO,iBAAiB,SAAU,MAA2B,OAAO;AACtE;AAGA,MAAM,+CAA+B,IAAI,IAAI;CAC3C;CACA;CACA;CACA;AACF,CAAC;AAED,SAAS,4BAA4B,OAAgC;CACnE,OAAO,iBAAiB,SAAS,6BAA6B,IAAK,MAA2B,EAAY;AAC5G;;;;;;;AAQA,MAAM,6CAA6B,IAAI,IAAI;CACzC;CACA;CACA;CACA;CACA;AACF,CAAC;AAED,SAAS,0BAA0B,OAAgC;CACjE,MAAM,KAAM,OAAwC;CACpD,OAAO,iBAAiB,SAAS,OAAO,OAAO,YAAY,2BAA2B,IAAI,EAAE;AAC9F;AAEA,MAAM,uCAAuC;AAE7C,SAAS,oCAAoC,OAAgC;CAC3E,OAAO,iBAAiB,SAAU,MAA2B,OAAO;AACtE;;;;;;;AAQA,SAAS,0CAA0C,OAAgC;CACjF,MAAM,KAAK,SAAS,OAAO,UAAU,YAAY,QAAQ,QAAQ,MAAM,KAAK,KAAA;CAC5E,OAAO,OAAO,OAAO,YAAY,GAAG,WAAW,wBAAwB,KAAK,GAAG,SAAS,kBAAkB;AAC5G;;;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AK;EAC3B,SAAS,MAAM;EACf,OAAO,MAAM;EACb,OAAO;CACT,CAAC;CAGH,MAAM,WAAW;CAIjB,MAAM,IAAIA,uBAAAA,cAFa,SAAS,UAAU,SAAS,SAAS,UAAU,KAEhB;EACpD,SAAS,SAAS,WAAW;EAC7B,OAAO,SAAS;EAChB,OAAO,SAAS;CAClB,CAAC;AACH"}
@@ -1 +1 @@
1
- {"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../../../src/server/handlers/error.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,KAAK,CAAC;AAMpC;;;GAGG;AACH,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,KAAK,CAAC;QACZ,IAAI,EAAE,WAAW,EAAE,CAAC;QACpB,OAAO,EAAE,MAAM,CAAC;KACjB,CAAC,CAAC;CACJ;AAyED;;;;;;;;;GASG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,QAAQ,CAAC,GAAG,CAAC,CAOjE;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAC5B,KAAK,EAAE,YAAY,EACnB,OAAO,EAAE,MAAM,GACd;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,KAAK,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;CAAE,CAUtE;AAGD,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,GAAG,KAAK,CA0EzE"}
1
+ {"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../../../src/server/handlers/error.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,KAAK,CAAC;AAMpC;;;GAGG;AACH,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,KAAK,CAAC;QACZ,IAAI,EAAE,WAAW,EAAE,CAAC;QACpB,OAAO,EAAE,MAAM,CAAC;KACjB,CAAC,CAAC;CACJ;AA+ED;;;;;;;;;GASG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,QAAQ,CAAC,GAAG,CAAC,CAOjE;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAC5B,KAAK,EAAE,YAAY,EACnB,OAAO,EAAE,MAAM,GACd;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,KAAK,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;CAAE,CAUtE;AAGD,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,GAAG,KAAK,CA0EzE"}
@@ -18,9 +18,14 @@ const WORKFLOW_SCHEMA_VALIDATION_FAILED_CODE = "WORKFLOW_SCHEMA_VALIDATION_FAILE
18
18
  function isWorkflowSchemaValidationError(error) {
19
19
  return error instanceof Error && error.id === WORKFLOW_SCHEMA_VALIDATION_FAILED_CODE;
20
20
  }
21
- const WORKFLOW_RESUME_ALREADY_CLAIMED_CODE = "WORKFLOW_RESUME_ALREADY_CLAIMED";
22
- function isWorkflowResumeAlreadyClaimedError(error) {
23
- return error instanceof Error && error.id === WORKFLOW_RESUME_ALREADY_CLAIMED_CODE;
21
+ const RESUME_ALREADY_CLAIMED_CODES = /* @__PURE__ */ new Set([
22
+ "WORKFLOW_RESUME_ALREADY_CLAIMED",
23
+ "AGENT_RESUME_ALREADY_CLAIMED",
24
+ "WORKFLOW_RUN_NOT_SUSPENDED",
25
+ "AGENT_RESUME_RUN_NOT_SUSPENDED"
26
+ ]);
27
+ function isResumeAlreadyClaimedError(error) {
28
+ return error instanceof Error && RESUME_ALREADY_CLAIMED_CODES.has(error.id);
24
29
  }
25
30
  /**
26
31
  * Durable agent errors for a request that conflicts with the run's state:
@@ -98,7 +103,7 @@ function handleError(error, defaultMessage) {
98
103
  cause: error
99
104
  });
100
105
  }
101
- if (isWorkflowResumeAlreadyClaimedError(error) || isDurableRunConflictError(error)) throw new HTTPException(409, {
106
+ if (isResumeAlreadyClaimedError(error) || isDurableRunConflictError(error)) throw new HTTPException(409, {
102
107
  message: error.message,
103
108
  stack: error.stack,
104
109
  cause: error
@@ -1 +1 @@
1
- {"version":3,"file":"error.js","names":[],"sources":["../../../src/server/handlers/error.ts"],"sourcesContent":["import type { ZodError } from 'zod';\n\nimport { HTTPException } from '../http-exception';\nimport type { StatusCode } from '../http-exception';\nimport type { ApiError } from '../types';\n\n/**\n * Duck-typed interface for ZodError-like objects.\n * Note: Zod v4 uses PropertyKey[] (string | number | symbol) for path.\n */\nexport interface ZodErrorLike {\n issues: Array<{\n path: PropertyKey[];\n message: string;\n }>;\n}\n\n/**\n * Recognition for `ModelNotAllowedError` from `@mastra/core/agent-builder/ee`.\n *\n * Inlined as a duck check rather than imported so that `handleError` (wired\n * into every route) does not force a load-time dependency on the\n * `@mastra/core/agent-builder/ee` subpath. That subpath only ships in\n * `@mastra/core >= 1.34.0`; deploys whose bundled `@mastra/server` resolves\n * against an older core would otherwise crash at startup with\n * `ERR_MODULE_NOT_FOUND` on `@mastra/core/dist/agent-builder/ee/index.js`.\n */\nconst MODEL_NOT_ALLOWED_CODE = 'MODEL_NOT_ALLOWED';\n\ninterface ModelNotAllowedErrorLike extends Error {\n code: typeof MODEL_NOT_ALLOWED_CODE;\n allowed?: unknown;\n attempted?: unknown;\n offendingLabel?: string;\n}\n\nfunction isModelNotAllowedError(error: unknown): error is ModelNotAllowedErrorLike {\n return error instanceof Error && (error as { code?: unknown }).code === MODEL_NOT_ALLOWED_CODE;\n}\n\nconst WORKFLOW_SCHEMA_VALIDATION_FAILED_CODE = 'WORKFLOW_SCHEMA_VALIDATION_FAILED';\n\nfunction isWorkflowSchemaValidationError(error: unknown): error is Error {\n return error instanceof Error && (error as { id?: unknown }).id === WORKFLOW_SCHEMA_VALIDATION_FAILED_CODE;\n}\n\nconst WORKFLOW_RESUME_ALREADY_CLAIMED_CODE = 'WORKFLOW_RESUME_ALREADY_CLAIMED';\n\nfunction isWorkflowResumeAlreadyClaimedError(error: unknown): error is Error {\n return error instanceof Error && (error as { id?: unknown }).id === WORKFLOW_RESUME_ALREADY_CLAIMED_CODE;\n}\n\n/**\n * Durable agent errors for a request that conflicts with the run's state:\n * another execution owns the run, it is already being recovered, it lost a\n * concurrent claim, or it is suspended (recover). Matched by id, like the\n * other checks here, so the server doesn't depend on core exporting them.\n */\nconst DURABLE_RUN_CONFLICT_CODES = new Set([\n 'DURABLE_AGENT_RUN_ACTIVE',\n 'DURABLE_AGENT_RECOVER_RUN_ACTIVE_LOCALLY',\n 'DURABLE_AGENT_RECOVER_ALREADY_IN_PROGRESS',\n 'DURABLE_AGENT_RECOVER_RUN_SUSPENDED',\n 'DURABLE_AGENT_EXECUTION_CONFLICT',\n]);\n\nfunction isDurableRunConflictError(error: unknown): error is Error {\n const id = (error as { id?: unknown } | undefined)?.id;\n return error instanceof Error && typeof id === 'string' && DURABLE_RUN_CONFLICT_CODES.has(id);\n}\n\nconst FEEDBACK_REVIEW_STATUS_CONFLICT_CODE = 'OBSERVABILITY_UPDATE_FEEDBACK_REVIEW_STATUS_CONFLICT';\n\nfunction isFeedbackReviewStatusConflictError(error: unknown): error is Error {\n return error instanceof Error && (error as { id?: unknown }).id === FEEDBACK_REVIEW_STATUS_CONFLICT_CODE;\n}\n\n/**\n * Matches the `OBSERVABILITY_STORAGE_*_NOT_IMPLEMENTED` MastraError the base\n * observability store throws for every optional method a store doesn't\n * implement. Checked by id (not `instanceof`) so it holds across duplicated\n * `@mastra/core` installs.\n */\nfunction isObservabilityStorageNotImplementedError(error: unknown): error is Error {\n const id = error && typeof error === 'object' && 'id' in error ? error.id : undefined;\n return typeof id === 'string' && id.startsWith('OBSERVABILITY_STORAGE_') && id.endsWith('_NOT_IMPLEMENTED');\n}\n\n/**\n * Structural check for ZodError instances.\n *\n * Avoids `instanceof ZodError` because consumers can resolve `'zod'` to a\n * different package instance (e.g. `zod@^3`) than the one a server adapter is\n * bundled with (`zod@^4`). In that case `instanceof` is false and validation\n * errors fall through to a generic response that drops field-path information.\n *\n * See https://github.com/mastra-ai/mastra/issues/17167.\n */\nexport function isZodError(error: unknown): error is ZodError<any> {\n return (\n !!error &&\n typeof error === 'object' &&\n (error as { name?: unknown }).name === 'ZodError' &&\n Array.isArray((error as { issues?: unknown }).issues)\n );\n}\n\n/**\n * Formats a ZodError into a structured validation error response.\n * Returns an object with an error message and an array of field-specific issues.\n */\nexport function formatZodError(\n error: ZodErrorLike,\n context: string,\n): { error: string; issues: Array<{ field: string; message: string }> } {\n const issues = error.issues.map(e => ({\n field: e.path.length > 0 ? e.path.map(p => String(p)).join('.') : 'root',\n message: e.message,\n }));\n\n return {\n error: `Invalid ${context}`,\n issues,\n };\n}\n\n// Helper to handle errors consistently\nexport function handleError(error: unknown, defaultMessage: string): never {\n if (isModelNotAllowedError(error)) {\n const body = {\n error: {\n code: error.code,\n message: error.message,\n allowed: error.allowed,\n attempted: error.attempted,\n offendingLabel: error.offendingLabel,\n },\n };\n const res = new Response(JSON.stringify(body), {\n status: 422,\n headers: { 'content-type': 'application/json' },\n });\n throw new HTTPException(422, {\n res,\n message: error.message,\n cause: error,\n });\n }\n\n // A losing concurrent resume, or a recover of a run that is live or suspended, is a conflict on\n // run state, not a malformed request, so it maps to 409 and clients can distinguish it from a\n // 400/500 and re-read the run.\n if (isWorkflowResumeAlreadyClaimedError(error) || isDurableRunConflictError(error)) {\n throw new HTTPException(409, {\n message: error.message,\n stack: error.stack,\n cause: error,\n });\n }\n\n // The feedback row changed under a review-status update, so the caller re-reads and retries;\n // that is a conflict, not a broken store.\n if (isFeedbackReviewStatusConflictError(error)) {\n throw new HTTPException(409, {\n message: error.message,\n stack: error.stack,\n cause: error,\n });\n }\n\n if (isWorkflowSchemaValidationError(error)) {\n throw new HTTPException(400, {\n message: error.message,\n stack: error.stack,\n cause: error,\n });\n }\n\n // Optional observability APIs (feedback, metrics, logs, scores, ...) throw\n // `*_NOT_IMPLEMENTED` on stores that don't support them. That's a missing\n // capability, not a server fault, so it maps to 501 — which server adapters\n // log as a warning instead of an error. The message is preserved because\n // clients match on it to detect unsupported operations. Clients should check\n // `GET /observability/capabilities` before calling optional routes.\n if (isObservabilityStorageNotImplementedError(error)) {\n throw new HTTPException(501, {\n message: error.message,\n stack: error.stack,\n cause: error,\n });\n }\n\n const apiError = error as ApiError;\n\n const apiErrorStatus = apiError.status || apiError.details?.status || 500;\n\n throw new HTTPException(apiErrorStatus as StatusCode, {\n message: apiError.message || defaultMessage,\n stack: apiError.stack,\n cause: apiError.cause,\n });\n}\n"],"mappings":";;;;;;;;;;;;AA2BA,MAAM,yBAAyB;AAS/B,SAAS,uBAAuB,OAAmD;CACjF,OAAO,iBAAiB,SAAU,MAA6B,SAAS;AAC1E;AAEA,MAAM,yCAAyC;AAE/C,SAAS,gCAAgC,OAAgC;CACvE,OAAO,iBAAiB,SAAU,MAA2B,OAAO;AACtE;AAEA,MAAM,uCAAuC;AAE7C,SAAS,oCAAoC,OAAgC;CAC3E,OAAO,iBAAiB,SAAU,MAA2B,OAAO;AACtE;;;;;;;AAQA,MAAM,6CAA6B,IAAI,IAAI;CACzC;CACA;CACA;CACA;CACA;AACF,CAAC;AAED,SAAS,0BAA0B,OAAgC;CACjE,MAAM,KAAM,OAAwC;CACpD,OAAO,iBAAiB,SAAS,OAAO,OAAO,YAAY,2BAA2B,IAAI,EAAE;AAC9F;AAEA,MAAM,uCAAuC;AAE7C,SAAS,oCAAoC,OAAgC;CAC3E,OAAO,iBAAiB,SAAU,MAA2B,OAAO;AACtE;;;;;;;AAQA,SAAS,0CAA0C,OAAgC;CACjF,MAAM,KAAK,SAAS,OAAO,UAAU,YAAY,QAAQ,QAAQ,MAAM,KAAK,KAAA;CAC5E,OAAO,OAAO,OAAO,YAAY,GAAG,WAAW,wBAAwB,KAAK,GAAG,SAAS,kBAAkB;AAC5G;;;;;;;;;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,CAAC;CAGH,MAAM,WAAW;CAIjB,MAAM,IAAI,cAFa,SAAS,UAAU,SAAS,SAAS,UAAU,KAEhB;EACpD,SAAS,SAAS,WAAW;EAC7B,OAAO,SAAS;EAChB,OAAO,SAAS;CAClB,CAAC;AACH"}
1
+ {"version":3,"file":"error.js","names":[],"sources":["../../../src/server/handlers/error.ts"],"sourcesContent":["import type { ZodError } from 'zod';\n\nimport { HTTPException } from '../http-exception';\nimport type { StatusCode } from '../http-exception';\nimport type { ApiError } from '../types';\n\n/**\n * Duck-typed interface for ZodError-like objects.\n * Note: Zod v4 uses PropertyKey[] (string | number | symbol) for path.\n */\nexport interface ZodErrorLike {\n issues: Array<{\n path: PropertyKey[];\n message: string;\n }>;\n}\n\n/**\n * Recognition for `ModelNotAllowedError` from `@mastra/core/agent-builder/ee`.\n *\n * Inlined as a duck check rather than imported so that `handleError` (wired\n * into every route) does not force a load-time dependency on the\n * `@mastra/core/agent-builder/ee` subpath. That subpath only ships in\n * `@mastra/core >= 1.34.0`; deploys whose bundled `@mastra/server` resolves\n * against an older core would otherwise crash at startup with\n * `ERR_MODULE_NOT_FOUND` on `@mastra/core/dist/agent-builder/ee/index.js`.\n */\nconst MODEL_NOT_ALLOWED_CODE = 'MODEL_NOT_ALLOWED';\n\ninterface ModelNotAllowedErrorLike extends Error {\n code: typeof MODEL_NOT_ALLOWED_CODE;\n allowed?: unknown;\n attempted?: unknown;\n offendingLabel?: string;\n}\n\nfunction isModelNotAllowedError(error: unknown): error is ModelNotAllowedErrorLike {\n return error instanceof Error && (error as { code?: unknown }).code === MODEL_NOT_ALLOWED_CODE;\n}\n\nconst WORKFLOW_SCHEMA_VALIDATION_FAILED_CODE = 'WORKFLOW_SCHEMA_VALIDATION_FAILED';\n\nfunction isWorkflowSchemaValidationError(error: unknown): error is Error {\n return error instanceof Error && (error as { id?: unknown }).id === WORKFLOW_SCHEMA_VALIDATION_FAILED_CODE;\n}\n\n// A resume the run can't accept: another resume claimed it, or it isn't waiting to be resumed.\nconst RESUME_ALREADY_CLAIMED_CODES = new Set([\n 'WORKFLOW_RESUME_ALREADY_CLAIMED',\n 'AGENT_RESUME_ALREADY_CLAIMED',\n 'WORKFLOW_RUN_NOT_SUSPENDED',\n 'AGENT_RESUME_RUN_NOT_SUSPENDED',\n]);\n\nfunction isResumeAlreadyClaimedError(error: unknown): error is Error {\n return error instanceof Error && RESUME_ALREADY_CLAIMED_CODES.has((error as { id?: unknown }).id as string);\n}\n\n/**\n * Durable agent errors for a request that conflicts with the run's state:\n * another execution owns the run, it is already being recovered, it lost a\n * concurrent claim, or it is suspended (recover). Matched by id, like the\n * other checks here, so the server doesn't depend on core exporting them.\n */\nconst DURABLE_RUN_CONFLICT_CODES = new Set([\n 'DURABLE_AGENT_RUN_ACTIVE',\n 'DURABLE_AGENT_RECOVER_RUN_ACTIVE_LOCALLY',\n 'DURABLE_AGENT_RECOVER_ALREADY_IN_PROGRESS',\n 'DURABLE_AGENT_RECOVER_RUN_SUSPENDED',\n 'DURABLE_AGENT_EXECUTION_CONFLICT',\n]);\n\nfunction isDurableRunConflictError(error: unknown): error is Error {\n const id = (error as { id?: unknown } | undefined)?.id;\n return error instanceof Error && typeof id === 'string' && DURABLE_RUN_CONFLICT_CODES.has(id);\n}\n\nconst FEEDBACK_REVIEW_STATUS_CONFLICT_CODE = 'OBSERVABILITY_UPDATE_FEEDBACK_REVIEW_STATUS_CONFLICT';\n\nfunction isFeedbackReviewStatusConflictError(error: unknown): error is Error {\n return error instanceof Error && (error as { id?: unknown }).id === FEEDBACK_REVIEW_STATUS_CONFLICT_CODE;\n}\n\n/**\n * Matches the `OBSERVABILITY_STORAGE_*_NOT_IMPLEMENTED` MastraError the base\n * observability store throws for every optional method a store doesn't\n * implement. Checked by id (not `instanceof`) so it holds across duplicated\n * `@mastra/core` installs.\n */\nfunction isObservabilityStorageNotImplementedError(error: unknown): error is Error {\n const id = error && typeof error === 'object' && 'id' in error ? error.id : undefined;\n return typeof id === 'string' && id.startsWith('OBSERVABILITY_STORAGE_') && id.endsWith('_NOT_IMPLEMENTED');\n}\n\n/**\n * Structural check for ZodError instances.\n *\n * Avoids `instanceof ZodError` because consumers can resolve `'zod'` to a\n * different package instance (e.g. `zod@^3`) than the one a server adapter is\n * bundled with (`zod@^4`). In that case `instanceof` is false and validation\n * errors fall through to a generic response that drops field-path information.\n *\n * See https://github.com/mastra-ai/mastra/issues/17167.\n */\nexport function isZodError(error: unknown): error is ZodError<any> {\n return (\n !!error &&\n typeof error === 'object' &&\n (error as { name?: unknown }).name === 'ZodError' &&\n Array.isArray((error as { issues?: unknown }).issues)\n );\n}\n\n/**\n * Formats a ZodError into a structured validation error response.\n * Returns an object with an error message and an array of field-specific issues.\n */\nexport function formatZodError(\n error: ZodErrorLike,\n context: string,\n): { error: string; issues: Array<{ field: string; message: string }> } {\n const issues = error.issues.map(e => ({\n field: e.path.length > 0 ? e.path.map(p => String(p)).join('.') : 'root',\n message: e.message,\n }));\n\n return {\n error: `Invalid ${context}`,\n issues,\n };\n}\n\n// Helper to handle errors consistently\nexport function handleError(error: unknown, defaultMessage: string): never {\n if (isModelNotAllowedError(error)) {\n const body = {\n error: {\n code: error.code,\n message: error.message,\n allowed: error.allowed,\n attempted: error.attempted,\n offendingLabel: error.offendingLabel,\n },\n };\n const res = new Response(JSON.stringify(body), {\n status: 422,\n headers: { 'content-type': 'application/json' },\n });\n throw new HTTPException(422, {\n res,\n message: error.message,\n cause: error,\n });\n }\n\n // A losing concurrent resume, or a recover of a run that is live or suspended, is a conflict on\n // run state, not a malformed request, so it maps to 409 and clients can distinguish it from a\n // 400/500 and re-read the run.\n if (isResumeAlreadyClaimedError(error) || isDurableRunConflictError(error)) {\n throw new HTTPException(409, {\n message: error.message,\n stack: error.stack,\n cause: error,\n });\n }\n\n // The feedback row changed under a review-status update, so the caller re-reads and retries;\n // that is a conflict, not a broken store.\n if (isFeedbackReviewStatusConflictError(error)) {\n throw new HTTPException(409, {\n message: error.message,\n stack: error.stack,\n cause: error,\n });\n }\n\n if (isWorkflowSchemaValidationError(error)) {\n throw new HTTPException(400, {\n message: error.message,\n stack: error.stack,\n cause: error,\n });\n }\n\n // Optional observability APIs (feedback, metrics, logs, scores, ...) throw\n // `*_NOT_IMPLEMENTED` on stores that don't support them. That's a missing\n // capability, not a server fault, so it maps to 501 — which server adapters\n // log as a warning instead of an error. The message is preserved because\n // clients match on it to detect unsupported operations. Clients should check\n // `GET /observability/capabilities` before calling optional routes.\n if (isObservabilityStorageNotImplementedError(error)) {\n throw new HTTPException(501, {\n message: error.message,\n stack: error.stack,\n cause: error,\n });\n }\n\n const apiError = error as ApiError;\n\n const apiErrorStatus = apiError.status || apiError.details?.status || 500;\n\n throw new HTTPException(apiErrorStatus as StatusCode, {\n message: apiError.message || defaultMessage,\n stack: apiError.stack,\n cause: apiError.cause,\n });\n}\n"],"mappings":";;;;;;;;;;;;AA2BA,MAAM,yBAAyB;AAS/B,SAAS,uBAAuB,OAAmD;CACjF,OAAO,iBAAiB,SAAU,MAA6B,SAAS;AAC1E;AAEA,MAAM,yCAAyC;AAE/C,SAAS,gCAAgC,OAAgC;CACvE,OAAO,iBAAiB,SAAU,MAA2B,OAAO;AACtE;AAGA,MAAM,+CAA+B,IAAI,IAAI;CAC3C;CACA;CACA;CACA;AACF,CAAC;AAED,SAAS,4BAA4B,OAAgC;CACnE,OAAO,iBAAiB,SAAS,6BAA6B,IAAK,MAA2B,EAAY;AAC5G;;;;;;;AAQA,MAAM,6CAA6B,IAAI,IAAI;CACzC;CACA;CACA;CACA;CACA;AACF,CAAC;AAED,SAAS,0BAA0B,OAAgC;CACjE,MAAM,KAAM,OAAwC;CACpD,OAAO,iBAAiB,SAAS,OAAO,OAAO,YAAY,2BAA2B,IAAI,EAAE;AAC9F;AAEA,MAAM,uCAAuC;AAE7C,SAAS,oCAAoC,OAAgC;CAC3E,OAAO,iBAAiB,SAAU,MAA2B,OAAO;AACtE;;;;;;;AAQA,SAAS,0CAA0C,OAAgC;CACjF,MAAM,K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AAS,MAAM;EACf,OAAO,MAAM;EACb,OAAO;CACT,CAAC;CASH,IAAI,0CAA0C,KAAK,GACjD,MAAM,IAAI,cAAc,KAAK;EAC3B,SAAS,MAAM;EACf,OAAO,MAAM;EACb,OAAO;CACT,CAAC;CAGH,MAAM,WAAW;CAIjB,MAAM,IAAI,cAFa,SAAS,UAAU,SAAS,SAAS,UAAU,KAEhB;EACpD,SAAS,SAAS,WAAW;EAC7B,OAAO,SAAS;EAChB,OAAO,SAAS;CAClB,CAAC;AACH"}
@@ -1120,9 +1120,16 @@ const OBSERVE_STREAM_LEGACY_WORKFLOW_ROUTE = require_route_builder.createRoute({
1120
1120
  }
1121
1121
  }
1122
1122
  });
1123
+ const stepExecutionParentWorkflowSchema = zod_v4.z.lazy(() => zod_v4.z.object({
1124
+ workflowId: zod_v4.z.string(),
1125
+ runId: zod_v4.z.string(),
1126
+ executionPath: zod_v4.z.array(zod_v4.z.number().int().nonnegative()),
1127
+ parentWorkflow: stepExecutionParentWorkflowSchema.optional()
1128
+ }));
1123
1129
  const stepExecutionBodySchema = zod_v4.z.object({
1124
1130
  stepId: zod_v4.z.string(),
1125
1131
  executionPath: zod_v4.z.array(zod_v4.z.number().int().nonnegative()),
1132
+ parentWorkflow: stepExecutionParentWorkflowSchema.optional(),
1126
1133
  stepResults: zod_v4.z.record(zod_v4.z.string(), zod_v4.z.unknown()),
1127
1134
  state: zod_v4.z.record(zod_v4.z.string(), zod_v4.z.unknown()),
1128
1135
  requestContext: zod_v4.z.record(zod_v4.z.string(), zod_v4.z.unknown()),
@@ -1163,6 +1170,7 @@ const EXECUTE_WORKFLOW_STEP_ROUTE = require_route_builder.createRoute({
1163
1170
  runId,
1164
1171
  stepId: body.stepId,
1165
1172
  executionPath: body.executionPath,
1173
+ parentWorkflow: body.parentWorkflow,
1166
1174
  stepResults: body.stepResults,
1167
1175
  state: body.state,
1168
1176
  requestContext: body.requestContext,