@mastra/server 1.77.0-alpha.2 → 1.77.0-alpha.4
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.
- package/dist/_types/@mastra_schema-compat/dist/schema.types.d.ts +4 -4
- package/dist/{api-schema-manifest-CJFJVu6Q.js → api-schema-manifest-BQOonczJ.js} +2 -2
- package/dist/{api-schema-manifest-CJFJVu6Q.js.map → api-schema-manifest-BQOonczJ.js.map} +1 -1
- package/dist/{api-schema-manifest-D8uhDn9F.cjs → api-schema-manifest-DC45FBI7.cjs} +2 -2
- package/dist/{api-schema-manifest-D8uhDn9F.cjs.map → api-schema-manifest-DC45FBI7.cjs.map} +1 -1
- package/dist/{dist-D0yst49-.cjs → dist-Cfv3ewR4.cjs} +7 -4
- package/dist/{dist-D0yst49-.cjs.map → dist-Cfv3ewR4.cjs.map} +1 -1
- package/dist/{dist-C6Y74AMV.js → dist-aAfueiQI.js} +7 -4
- package/dist/{dist-C6Y74AMV.js.map → dist-aAfueiQI.js.map} +1 -1
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/{routes-IIMXw7Iv.js → routes-DhwMARHw.js} +3 -3
- package/dist/{routes-IIMXw7Iv.js.map → routes-DhwMARHw.js.map} +1 -1
- package/dist/{routes-DCDI9nh-.cjs → routes-Dl6lzZIQ.cjs} +3 -3
- package/dist/{routes-DCDI9nh-.cjs.map → routes-Dl6lzZIQ.cjs.map} +1 -1
- package/dist/{schedules-OiPV0jLY.js → schedules-C4uNWRwW.js} +7 -3
- package/dist/schedules-C4uNWRwW.js.map +1 -0
- package/dist/{schedules-Buunf_MT.cjs → schedules-QNH7CUxG.cjs} +7 -3
- package/dist/schedules-QNH7CUxG.cjs.map +1 -0
- package/dist/server/handlers/agent-builder.cjs +1 -1
- package/dist/server/handlers/agent-builder.js +1 -1
- package/dist/server/handlers/agent-controller.cjs +30 -12
- package/dist/server/handlers/agent-controller.cjs.map +1 -1
- package/dist/server/handlers/agent-controller.d.ts +20 -0
- package/dist/server/handlers/agent-controller.d.ts.map +1 -1
- package/dist/server/handlers/agent-controller.js +30 -12
- package/dist/server/handlers/agent-controller.js.map +1 -1
- package/dist/server/handlers/agents.cjs +1 -1
- package/dist/server/handlers/agents.js +1 -1
- package/dist/server/handlers/conversations.cjs +1 -1
- package/dist/server/handlers/conversations.js +1 -1
- package/dist/server/handlers/error.cjs +9 -4
- package/dist/server/handlers/error.cjs.map +1 -1
- package/dist/server/handlers/error.d.ts.map +1 -1
- package/dist/server/handlers/error.js +9 -4
- package/dist/server/handlers/error.js.map +1 -1
- package/dist/server/handlers/logs.cjs +1 -1
- package/dist/server/handlers/logs.js +1 -1
- package/dist/server/handlers/memory.cjs +1 -1
- package/dist/server/handlers/memory.js +1 -1
- package/dist/server/handlers/plans.cjs +1 -1
- package/dist/server/handlers/plans.js +1 -1
- package/dist/server/handlers/responses.cjs +1 -1
- package/dist/server/handlers/responses.js +1 -1
- package/dist/server/handlers/responses.storage.cjs +1 -1
- package/dist/server/handlers/responses.storage.js +1 -1
- package/dist/server/handlers/schedules.cjs +1 -1
- package/dist/server/handlers/schedules.d.ts.map +1 -1
- package/dist/server/handlers/schedules.js +1 -1
- package/dist/server/handlers/system.cjs +1 -1
- package/dist/server/handlers/system.js +1 -1
- package/dist/server/handlers/tools.cjs +1 -1
- package/dist/server/handlers/tools.js +1 -1
- package/dist/server/handlers/utils.cjs +2 -1
- package/dist/server/handlers/utils.d.ts +9 -0
- package/dist/server/handlers/utils.d.ts.map +1 -1
- package/dist/server/handlers/utils.js +2 -2
- package/dist/server/handlers/workflow-builder.cjs +1 -1
- package/dist/server/handlers/workflow-builder.js +1 -1
- package/dist/server/handlers/workflows.cjs +2 -6
- package/dist/server/handlers/workflows.cjs.map +1 -1
- package/dist/server/handlers/workflows.d.ts.map +1 -1
- package/dist/server/handlers/workflows.js +2 -6
- package/dist/server/handlers/workflows.js.map +1 -1
- package/dist/server/server-adapter/index.cjs +1 -1
- package/dist/server/server-adapter/index.js +1 -1
- package/dist/{utils-BQA09BCt.cjs → utils-BD7aRZ1o.cjs} +17 -1
- package/dist/utils-BD7aRZ1o.cjs.map +1 -0
- package/dist/{utils-kaP2cyIO.js → utils-UwDFLi8y.js} +12 -2
- package/dist/utils-UwDFLi8y.js.map +1 -0
- package/dist/{workflow-builder-8Rcql7QH.cjs → workflow-builder-DPTDL6sn.cjs} +2 -2
- package/dist/{workflow-builder-8Rcql7QH.cjs.map → workflow-builder-DPTDL6sn.cjs.map} +1 -1
- package/dist/{workflow-builder-DMTslavM.js → workflow-builder-DwApMkS3.js} +2 -2
- package/dist/{workflow-builder-DMTslavM.js.map → workflow-builder-DwApMkS3.js.map} +1 -1
- package/package.json +5 -5
- package/dist/schedules-Buunf_MT.cjs.map +0 -1
- package/dist/schedules-OiPV0jLY.js.map +0 -1
- package/dist/utils-BQA09BCt.cjs.map +0 -1
- package/dist/utils-kaP2cyIO.js.map +0 -1
|
@@ -20,9 +20,14 @@ const WORKFLOW_SCHEMA_VALIDATION_FAILED_CODE = "WORKFLOW_SCHEMA_VALIDATION_FAILE
|
|
|
20
20
|
function isWorkflowSchemaValidationError(error) {
|
|
21
21
|
return error instanceof Error && error.id === WORKFLOW_SCHEMA_VALIDATION_FAILED_CODE;
|
|
22
22
|
}
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
const RESUME_ALREADY_CLAIMED_CODES = /* @__PURE__ */ new Set([
|
|
24
|
+
"WORKFLOW_RESUME_ALREADY_CLAIMED",
|
|
25
|
+
"AGENT_RESUME_ALREADY_CLAIMED",
|
|
26
|
+
"WORKFLOW_RUN_NOT_SUSPENDED",
|
|
27
|
+
"AGENT_RESUME_RUN_NOT_SUSPENDED"
|
|
28
|
+
]);
|
|
29
|
+
function isResumeAlreadyClaimedError(error) {
|
|
30
|
+
return error instanceof Error && RESUME_ALREADY_CLAIMED_CODES.has(error.id);
|
|
26
31
|
}
|
|
27
32
|
/**
|
|
28
33
|
* Durable agent errors for a request that conflicts with the run's state:
|
|
@@ -100,7 +105,7 @@ function handleError(error, defaultMessage) {
|
|
|
100
105
|
cause: error
|
|
101
106
|
});
|
|
102
107
|
}
|
|
103
|
-
if (
|
|
108
|
+
if (isResumeAlreadyClaimedError(error) || isDurableRunConflictError(error)) throw new require_http_exception.HTTPException(409, {
|
|
104
109
|
message: error.message,
|
|
105
110
|
stack: error.stack,
|
|
106
111
|
cause: error
|
|
@@ -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
|
|
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,U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cAAc,KAAK;EAC3B,SAAS,MAAM;EACf,OAAO,MAAM;EACb,OAAO;CACT,CAAC;CASH,IAAI,0CAA0C,KAAK,GACjD,MAAM,IAAIA,uBAAAA,cAAc,KAAK;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;
|
|
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
|
|
22
|
-
|
|
23
|
-
|
|
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 (
|
|
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
|
|
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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I;EAClE,SAAS,EAAE;CACb,EAAE;CAEF,OAAO;EACL,OAAO,WAAW;EAClB;CACF;AACF;AAGA,SAAgB,YAAY,OAAgB,gBAA+B;CACzE,IAAI,uBAAuB,KAAK,GAAG;EACjC,MAAM,OAAO,EACX,OAAO;GACL,MAAM,MAAM;GACZ,SAAS,MAAM;GACf,SAAS,MAAM;GACf,WAAW,MAAM;GACjB,gBAAgB,MAAM;EACxB,EACF;EAKA,MAAM,IAAI,cAAc,KAAK;GAC3B,KAAA,IALc,SAAS,KAAK,UAAU,IAAI,GAAG;IAC7C,QAAQ;IACR,SAAS,EAAE,gBAAgB,mBAAmB;GAChD,CAEI;GACF,SAAS,MAAM;GACf,OAAO;EACT,CAAC;CACH;CAKA,IAAI,4BAA4B,KAAK,KAAK,0BAA0B,KAAK,GACvE,MAAM,IAAI,cAAc,KAAK;EAC3B,SAAS,MAAM;EACf,OAAO,MAAM;EACb,OAAO;CACT,CAAC;CAKH,IAAI,oCAAoC,KAAK,GAC3C,MAAM,IAAI,cAAc,KAAK;EAC3B,SAAS,MAAM;EACf,OAAO,MAAM;EACb,OAAO;CACT,CAAC;CAGH,IAAI,gCAAgC,KAAK,GACvC,MAAM,IAAI,cAAc,KAAK;EAC3B,SAAS,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"}
|
|
@@ -3,7 +3,7 @@ const require_rolldown_runtime = require("../../rolldown-runtime-Bd6kNlEP.cjs");
|
|
|
3
3
|
const require_common = require("../../common-DhKNoXGp.cjs");
|
|
4
4
|
const require_route_builder = require("../../route-builder-2yrD15TL.cjs");
|
|
5
5
|
const require_server_handlers_error = require("./error.cjs");
|
|
6
|
-
const require_utils = require("../../utils-
|
|
6
|
+
const require_utils = require("../../utils-BD7aRZ1o.cjs");
|
|
7
7
|
const require_logs = require("../../logs-CY8AGOCO.cjs");
|
|
8
8
|
//#region src/server/handlers/logs.ts
|
|
9
9
|
var logs_exports = /* @__PURE__ */ require_rolldown_runtime.__exportAll({
|
|
@@ -2,7 +2,7 @@ import { r as __exportAll } from "../../rolldown-runtime-maW3aOIk.js";
|
|
|
2
2
|
import { u as runIdSchema } from "../../common-Y30XtCyr.js";
|
|
3
3
|
import { n as createRoute } from "../../route-builder-lBil8Cvo.js";
|
|
4
4
|
import { handleError } from "./error.js";
|
|
5
|
-
import {
|
|
5
|
+
import { f as validateBody, s as parseFilters } from "../../utils-UwDFLi8y.js";
|
|
6
6
|
import { n as listLogsQuerySchema, r as listLogsResponseSchema, t as listLogTransportsResponseSchema } from "../../logs-Bd_xpsYw.js";
|
|
7
7
|
//#region src/server/handlers/logs.ts
|
|
8
8
|
var logs_exports = /* @__PURE__ */ __exportAll({
|
|
@@ -3,7 +3,7 @@ const require_rolldown_runtime = require("../../rolldown-runtime-Bd6kNlEP.cjs");
|
|
|
3
3
|
const require_http_exception = require("../../http-exception-CKDHupKw.cjs");
|
|
4
4
|
const require_route_builder = require("../../route-builder-2yrD15TL.cjs");
|
|
5
5
|
const require_server_handlers_error = require("./error.cjs");
|
|
6
|
-
const require_utils = require("../../utils-
|
|
6
|
+
const require_utils = require("../../utils-BD7aRZ1o.cjs");
|
|
7
7
|
const require_memory = require("../../memory-CizEIbl1.cjs");
|
|
8
8
|
const require_server_handlers_gateway_memory_client = require("./gateway-memory-client.cjs");
|
|
9
9
|
let _mastra_core_agent = require("@mastra/core/agent");
|
|
@@ -2,7 +2,7 @@ import { r as __exportAll } from "../../rolldown-runtime-maW3aOIk.js";
|
|
|
2
2
|
import { t as HTTPException } from "../../http-exception-CyfxZB6W.js";
|
|
3
3
|
import { n as createRoute } from "../../route-builder-lBil8Cvo.js";
|
|
4
4
|
import { handleError } from "./error.js";
|
|
5
|
-
import {
|
|
5
|
+
import { f as validateBody, h as MastraFGAPermissions, i as getEffectiveThreadId, n as getContextResourceId, r as getEffectiveResourceId, t as enforceThreadAccess } from "../../utils-UwDFLi8y.js";
|
|
6
6
|
import { A as listThreadsNetworkQuerySchema, B as searchMemoryQuerySchema, C as getThreadByIdResponseSchema, D as listMessagesNetworkQuerySchema, G as updateThreadBodySchema, H as threadIdPathParams, I as optionalAgentIdQuerySchema, J as updateWorkingMemoryResponseSchema, K as updateThreadNetworkQuerySchema, L as saveMessagesBodySchema, M as listThreadsResponseSchema, N as memoryConfigResponseSchema, O as listMessagesQuerySchema, P as memoryStatusResponseSchema, R as saveMessagesNetworkQuerySchema, S as getThreadByIdQuerySchema, T as getWorkingMemoryResponseSchema, U as transferThreadBodySchema, V as searchMemoryResponseSchema, W as transferThreadResponseSchema, _ as getMemoryStatusNetworkQuerySchema, a as cloneThreadResponseSchema, b as getObservationalMemoryResponseSchema, c as deleteMessagesBodySchema, d as deleteMessagesResponseSchema, f as deleteThreadNetworkQuerySchema, g as getMemoryConfigQuerySchema, i as cloneThreadBodySchema, j as listThreadsQuerySchema, k as listMessagesResponseSchema, l as deleteMessagesNetworkQuerySchema, m as deleteThreadResponseSchema, n as awaitBufferStatusBodySchema, o as createThreadBodySchema, p as deleteThreadQuerySchema, q as updateWorkingMemoryBodySchema, r as awaitBufferStatusResponseSchema, s as createThreadNetworkQuerySchema, t as agentIdQuerySchema, u as deleteMessagesQuerySchema, v as getMemoryStatusQuerySchema, w as getWorkingMemoryQuerySchema, x as getThreadByIdNetworkQuerySchema, y as getObservationalMemoryQuerySchema, z as saveMessagesResponseSchema } from "../../memory-B58Q2LgU.js";
|
|
7
7
|
import { getGatewayClient, isGatewayAgentAsync, toLocalMessage, toLocalOMRecord, toLocalThread } from "./gateway-memory-client.js";
|
|
8
8
|
import { Agent } from "@mastra/core/agent";
|
|
@@ -4,7 +4,7 @@ const require_http_exception = require("../../http-exception-CKDHupKw.cjs");
|
|
|
4
4
|
const require_agents = require("../../agents-CKSEPpk1.cjs");
|
|
5
5
|
const require_route_builder = require("../../route-builder-2yrD15TL.cjs");
|
|
6
6
|
const require_server_handlers_error = require("./error.cjs");
|
|
7
|
-
const require_utils = require("../../utils-
|
|
7
|
+
const require_utils = require("../../utils-BD7aRZ1o.cjs");
|
|
8
8
|
const require_server_handlers_agents = require("./agents.cjs");
|
|
9
9
|
let _mastra_core_tools = require("@mastra/core/tools");
|
|
10
10
|
//#region src/server/handlers/plans.ts
|
|
@@ -3,7 +3,7 @@ import { t as HTTPException } from "../../http-exception-CyfxZB6W.js";
|
|
|
3
3
|
import { a as agentIdPathParams, o as agentPlanQuerySchema, s as agentPlanResponseSchema } from "../../agents-CW_JJZOf.js";
|
|
4
4
|
import { n as createRoute } from "../../route-builder-lBil8Cvo.js";
|
|
5
5
|
import { handleError } from "./error.js";
|
|
6
|
-
import {
|
|
6
|
+
import { h as MastraFGAPermissions } from "../../utils-UwDFLi8y.js";
|
|
7
7
|
import { getAgentFromSystem } from "./agents.js";
|
|
8
8
|
import { submitPlanTool } from "@mastra/core/tools";
|
|
9
9
|
//#region src/server/handlers/plans.ts
|
|
@@ -3,7 +3,7 @@ const require_rolldown_runtime = require("../../rolldown-runtime-Bd6kNlEP.cjs");
|
|
|
3
3
|
const require_http_exception = require("../../http-exception-CKDHupKw.cjs");
|
|
4
4
|
const require_route_builder = require("../../route-builder-2yrD15TL.cjs");
|
|
5
5
|
const require_server_handlers_error = require("./error.cjs");
|
|
6
|
-
const require_utils = require("../../utils-
|
|
6
|
+
const require_utils = require("../../utils-BD7aRZ1o.cjs");
|
|
7
7
|
const require_server_handlers_agents = require("./agents.cjs");
|
|
8
8
|
const require_responses = require("../../responses-CKNdSRkS.cjs");
|
|
9
9
|
const require_server_handlers_responses_adapter = require("./responses.adapter.cjs");
|
|
@@ -2,7 +2,7 @@ import { r as __exportAll } from "../../rolldown-runtime-maW3aOIk.js";
|
|
|
2
2
|
import { t as HTTPException } from "../../http-exception-CyfxZB6W.js";
|
|
3
3
|
import { n as createRoute } from "../../route-builder-lBil8Cvo.js";
|
|
4
4
|
import { handleError } from "./error.js";
|
|
5
|
-
import {
|
|
5
|
+
import { h as MastraFGAPermissions, i as getEffectiveThreadId, r as getEffectiveResourceId, t as enforceThreadAccess } from "../../utils-UwDFLi8y.js";
|
|
6
6
|
import { getAgentFromSystem } from "./agents.js";
|
|
7
7
|
import { a as deleteResponseSchema, i as createResponseBodySchema, o as responseIdPathParams, u as responseObjectSchema } from "../../responses-DJNJgCTg.js";
|
|
8
8
|
import { buildCompletedResponse, buildInProgressResponse, createMessageId, createOutputTextPart, createResponseStreamEventTranslator, formatSseEvent, mapMastraToolsToResponseTools, mapResponseInputToExecutionMessages, mapResponseTurnRecordToResponse, toResponseStatus, toResponseUsage } from "./responses.adapter.js";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
require("../../rolldown-runtime-Bd6kNlEP.cjs");
|
|
3
3
|
const require_http_exception = require("../../http-exception-CKDHupKw.cjs");
|
|
4
|
-
const require_utils = require("../../utils-
|
|
4
|
+
const require_utils = require("../../utils-BD7aRZ1o.cjs");
|
|
5
5
|
//#region src/server/handlers/responses.storage.ts
|
|
6
6
|
function isPlainObject(value) {
|
|
7
7
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as HTTPException } from "../../http-exception-CyfxZB6W.js";
|
|
2
|
-
import {
|
|
2
|
+
import { m as validateThreadOwnership, r as getEffectiveResourceId } from "../../utils-UwDFLi8y.js";
|
|
3
3
|
//#region src/server/handlers/responses.storage.ts
|
|
4
4
|
function isPlainObject(value) {
|
|
5
5
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
require("../../rolldown-runtime-Bd6kNlEP.cjs");
|
|
3
|
-
const require_schedules = require("../../schedules-
|
|
3
|
+
const require_schedules = require("../../schedules-QNH7CUxG.cjs");
|
|
4
4
|
exports.CREATE_SCHEDULE_ROUTE = require_schedules.CREATE_SCHEDULE_ROUTE;
|
|
5
5
|
exports.DELETE_SCHEDULE_ROUTE = require_schedules.DELETE_SCHEDULE_ROUTE;
|
|
6
6
|
exports.GET_SCHEDULE_ROUTE = require_schedules.GET_SCHEDULE_ROUTE;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schedules.d.ts","sourceRoot":"","sources":["../../../src/server/handlers/schedules.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"schedules.d.ts","sourceRoot":"","sources":["../../../src/server/handlers/schedules.ts"],"names":[],"mappings":"AA0FA,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAqB/B,CAAC;AAEH,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAc7B,CAAC;AAEH,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAmCvC,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as LIST_SCHEDULE_TRIGGERS_ROUTE, c as RUN_SCHEDULE_ROUTE, i as LIST_SCHEDULES_ROUTE, l as UPDATE_SCHEDULE_ROUTE, n as DELETE_SCHEDULE_ROUTE, o as PAUSE_SCHEDULE_ROUTE, r as GET_SCHEDULE_ROUTE, s as RESUME_SCHEDULE_ROUTE, t as CREATE_SCHEDULE_ROUTE } from "../../schedules-
|
|
1
|
+
import { a as LIST_SCHEDULE_TRIGGERS_ROUTE, c as RUN_SCHEDULE_ROUTE, i as LIST_SCHEDULES_ROUTE, l as UPDATE_SCHEDULE_ROUTE, n as DELETE_SCHEDULE_ROUTE, o as PAUSE_SCHEDULE_ROUTE, r as GET_SCHEDULE_ROUTE, s as RESUME_SCHEDULE_ROUTE, t as CREATE_SCHEDULE_ROUTE } from "../../schedules-C4uNWRwW.js";
|
|
2
2
|
export { CREATE_SCHEDULE_ROUTE, DELETE_SCHEDULE_ROUTE, GET_SCHEDULE_ROUTE, LIST_SCHEDULES_ROUTE, LIST_SCHEDULE_TRIGGERS_ROUTE, PAUSE_SCHEDULE_ROUTE, RESUME_SCHEDULE_ROUTE, RUN_SCHEDULE_ROUTE, UPDATE_SCHEDULE_ROUTE };
|
|
@@ -90,7 +90,7 @@ const GET_API_SCHEMA_ROUTE = require_route_builder.createRoute({
|
|
|
90
90
|
tags: ["System"],
|
|
91
91
|
requiresAuth: true,
|
|
92
92
|
handler: async () => {
|
|
93
|
-
const { buildApiSchemaManifest } = await Promise.resolve().then(() => require("../../api-schema-manifest-
|
|
93
|
+
const { buildApiSchemaManifest } = await Promise.resolve().then(() => require("../../api-schema-manifest-DC45FBI7.cjs"));
|
|
94
94
|
return buildApiSchemaManifest();
|
|
95
95
|
}
|
|
96
96
|
});
|
|
@@ -88,7 +88,7 @@ const GET_API_SCHEMA_ROUTE = createRoute({
|
|
|
88
88
|
tags: ["System"],
|
|
89
89
|
requiresAuth: true,
|
|
90
90
|
handler: async () => {
|
|
91
|
-
const { buildApiSchemaManifest } = await import("../../api-schema-manifest-
|
|
91
|
+
const { buildApiSchemaManifest } = await import("../../api-schema-manifest-BQOonczJ.js");
|
|
92
92
|
return buildApiSchemaManifest();
|
|
93
93
|
}
|
|
94
94
|
});
|
|
@@ -8,7 +8,7 @@ const require_route_builder = require("../../route-builder-2yrD15TL.cjs");
|
|
|
8
8
|
require("../../schema-BVcoNfni.cjs");
|
|
9
9
|
const require_utils = require("../../utils-CfF-SHpC.cjs");
|
|
10
10
|
const require_server_handlers_error = require("./error.cjs");
|
|
11
|
-
const require_utils$1 = require("../../utils-
|
|
11
|
+
const require_utils$1 = require("../../utils-BD7aRZ1o.cjs");
|
|
12
12
|
const require_server_handlers_tool_schema_overrides = require("./tool-schema-overrides.cjs");
|
|
13
13
|
const require_server_handlers_agents = require("./agents.cjs");
|
|
14
14
|
let _mastra_core_tools = require("@mastra/core/tools");
|
|
@@ -7,7 +7,7 @@ import { n as createRoute } from "../../route-builder-lBil8Cvo.js";
|
|
|
7
7
|
import "../../schema-Xxr5X5Je.js";
|
|
8
8
|
import { l as stringify } from "../../utils-DTgkpEdc.js";
|
|
9
9
|
import { handleError } from "./error.js";
|
|
10
|
-
import {
|
|
10
|
+
import { f as validateBody, h as MastraFGAPermissions } from "../../utils-UwDFLi8y.js";
|
|
11
11
|
import { stripInjectedToolOverrideFields } from "./tool-schema-overrides.js";
|
|
12
12
|
import { getAgentFromSystem } from "./agents.js";
|
|
13
13
|
import { isProviderDefinedTool, isVercelTool } from "@mastra/core/tools";
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
require("../../rolldown-runtime-Bd6kNlEP.cjs");
|
|
3
|
-
const require_utils = require("../../utils-
|
|
3
|
+
const require_utils = require("../../utils-BD7aRZ1o.cjs");
|
|
4
4
|
exports.enforceThreadAccess = require_utils.enforceThreadAccess;
|
|
5
5
|
exports.getContextResourceId = require_utils.getContextResourceId;
|
|
6
6
|
exports.getEffectiveResourceId = require_utils.getEffectiveResourceId;
|
|
7
7
|
exports.getEffectiveThreadId = require_utils.getEffectiveThreadId;
|
|
8
|
+
exports.getPublicWorkflowById = require_utils.getPublicWorkflowById;
|
|
8
9
|
exports.mergeBodyRequestContext = require_utils.mergeBodyRequestContext;
|
|
9
10
|
exports.parseFilters = require_utils.parseFilters;
|
|
10
11
|
exports.parsePerPage = require_utils.parsePerPage;
|
|
@@ -1,5 +1,14 @@
|
|
|
1
|
+
import type { Mastra } from '@mastra/core';
|
|
1
2
|
import type { MastraFGAPermissionInput } from '@mastra/core/auth/ee';
|
|
2
3
|
import type { RequestContext } from '@mastra/core/di';
|
|
4
|
+
import type { Workflow } from '@mastra/core/workflows';
|
|
5
|
+
/**
|
|
6
|
+
* Resolves a workflow by id or registration key from the set Mastra exposes
|
|
7
|
+
* publicly. Unlike `mastra.getWorkflowById`, this excludes hidden internal
|
|
8
|
+
* workflows (e.g. a durable agent's backing loop), which must never be
|
|
9
|
+
* runnable through HTTP routes.
|
|
10
|
+
*/
|
|
11
|
+
export declare function getPublicWorkflowById(mastra: Mastra, workflowId: string): Workflow | undefined;
|
|
3
12
|
export declare function validateBody(body: Record<string, unknown>): void;
|
|
4
13
|
/**
|
|
5
14
|
* sanitizes the body by removing disallowed keys.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/server/handlers/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AACrE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":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@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as
|
|
2
|
-
export { enforceThreadAccess, getContextResourceId, getEffectiveResourceId, getEffectiveThreadId, mergeBodyRequestContext, parseFilters, parsePerPage, requireEffectiveResourceId, sanitizeBody, stripClientCredentialHeaders, validateBody, validateRunOwnership, validateThreadOwnership };
|
|
1
|
+
import { a as getPublicWorkflowById, c as parsePerPage, d as stripClientCredentialHeaders, f as validateBody, i as getEffectiveThreadId, l as requireEffectiveResourceId, m as validateThreadOwnership, n as getContextResourceId, o as mergeBodyRequestContext, p as validateRunOwnership, r as getEffectiveResourceId, s as parseFilters, t as enforceThreadAccess, u as sanitizeBody } from "../../utils-UwDFLi8y.js";
|
|
2
|
+
export { enforceThreadAccess, getContextResourceId, getEffectiveResourceId, getEffectiveThreadId, getPublicWorkflowById, mergeBodyRequestContext, parseFilters, parsePerPage, requireEffectiveResourceId, sanitizeBody, stripClientCredentialHeaders, validateBody, validateRunOwnership, validateThreadOwnership };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
require("../../rolldown-runtime-Bd6kNlEP.cjs");
|
|
3
|
-
const require_workflow_builder = require("../../workflow-builder-
|
|
3
|
+
const require_workflow_builder = require("../../workflow-builder-DPTDL6sn.cjs");
|
|
4
4
|
exports.GET_WORKFLOW_BUILDER_SETTINGS_ROUTE = require_workflow_builder.GET_WORKFLOW_BUILDER_SETTINGS_ROUTE;
|
|
5
5
|
exports.STREAM_WORKFLOW_BUILDER_ROUTE = require_workflow_builder.STREAM_WORKFLOW_BUILDER_ROUTE;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as STREAM_WORKFLOW_BUILDER_ROUTE, t as GET_WORKFLOW_BUILDER_SETTINGS_ROUTE } from "../../workflow-builder-
|
|
1
|
+
import { n as STREAM_WORKFLOW_BUILDER_ROUTE, t as GET_WORKFLOW_BUILDER_SETTINGS_ROUTE } from "../../workflow-builder-DwApMkS3.js";
|
|
2
2
|
export { GET_WORKFLOW_BUILDER_SETTINGS_ROUTE, STREAM_WORKFLOW_BUILDER_ROUTE };
|
|
@@ -7,7 +7,7 @@ const require_agents = require("../../agents-CKSEPpk1.cjs");
|
|
|
7
7
|
const require_route_builder = require("../../route-builder-2yrD15TL.cjs");
|
|
8
8
|
const require_utils = require("../../utils-CfF-SHpC.cjs");
|
|
9
9
|
const require_server_handlers_error = require("./error.cjs");
|
|
10
|
-
const require_utils$1 = require("../../utils-
|
|
10
|
+
const require_utils$1 = require("../../utils-BD7aRZ1o.cjs");
|
|
11
11
|
let zod_v4 = require("zod/v4");
|
|
12
12
|
let _mastra_core_stream = require("@mastra/core/stream");
|
|
13
13
|
//#region src/server/handlers/workflows.ts
|
|
@@ -95,11 +95,7 @@ async function listWorkflowsFromSystem({ mastra, workflowId }) {
|
|
|
95
95
|
if (!workflowId) throw new require_http_exception.HTTPException(400, { message: "Workflow ID is required" });
|
|
96
96
|
let workflow;
|
|
97
97
|
workflow = require_utils.WorkflowRegistry.getWorkflow(workflowId);
|
|
98
|
-
if (!workflow)
|
|
99
|
-
workflow = mastra.getWorkflowById(workflowId);
|
|
100
|
-
} catch (error) {
|
|
101
|
-
logger.debug("Error getting workflow, searching agents for workflow", error);
|
|
102
|
-
}
|
|
98
|
+
if (!workflow) workflow = require_utils$1.getPublicWorkflowById(mastra, workflowId);
|
|
103
99
|
if (!workflow) {
|
|
104
100
|
logger.debug("Workflow not found, searching agents for workflow", { workflowId });
|
|
105
101
|
const agents = mastra.listAgents();
|