@mastra/server 1.70.0-alpha.1 → 1.70.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.
- package/dist/{api-schema-manifest-CeiI0HER.cjs → api-schema-manifest-CE2lXPKH.cjs} +2 -2
- package/dist/{api-schema-manifest-CeiI0HER.cjs.map → api-schema-manifest-CE2lXPKH.cjs.map} +1 -1
- package/dist/{api-schema-manifest-BvIpcxxq.js → api-schema-manifest-D0_Q8UhK.js} +2 -2
- package/dist/{api-schema-manifest-BvIpcxxq.js.map → api-schema-manifest-D0_Q8UhK.js.map} +1 -1
- package/dist/{dist-DcTSQIB2.js → dist-B3wkDytS.js} +104 -53
- package/dist/dist-B3wkDytS.js.map +1 -0
- package/dist/{dist-1bGgLbxg.cjs → dist-pojdOe9l.cjs} +104 -53
- package/dist/dist-pojdOe9l.cjs.map +1 -0
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/docs/references/reference-observability-tracing-trace-query.md +17 -1
- package/dist/{observability-new-endpoints-BIoS0_PJ.cjs → observability-new-endpoints-DJYL-Y5A.cjs} +5 -2
- package/dist/observability-new-endpoints-DJYL-Y5A.cjs.map +1 -0
- package/dist/{observability-new-endpoints-0hQR-aWF.js → observability-new-endpoints-DQHOnzNX.js} +6 -3
- package/dist/observability-new-endpoints-DQHOnzNX.js.map +1 -0
- package/dist/{routes-BU_1NO20.js → routes-CeJQfjk5.js} +2 -2
- package/dist/{routes-BU_1NO20.js.map → routes-CeJQfjk5.js.map} +1 -1
- package/dist/{routes-Czb2jV4R.cjs → routes-l-SxuNkD.cjs} +2 -2
- package/dist/{routes-Czb2jV4R.cjs.map → routes-l-SxuNkD.cjs.map} +1 -1
- package/dist/server/handlers/agent-builder.cjs +1 -1
- package/dist/server/handlers/agent-builder.js +1 -1
- package/dist/server/handlers/observability-new-endpoints.cjs +1 -1
- package/dist/server/handlers/observability-new-endpoints.d.ts.map +1 -1
- package/dist/server/handlers/observability-new-endpoints.js +1 -1
- package/dist/server/handlers/observability-shared.cjs +17 -0
- package/dist/server/handlers/observability-shared.cjs.map +1 -1
- package/dist/server/handlers/observability-shared.d.ts +3 -1
- package/dist/server/handlers/observability-shared.d.ts.map +1 -1
- package/dist/server/handlers/observability-shared.js +16 -1
- package/dist/server/handlers/observability-shared.js.map +1 -1
- package/dist/server/handlers/observability.cjs +1 -1
- package/dist/server/handlers/observability.js +1 -1
- package/dist/server/handlers/system.cjs +1 -1
- package/dist/server/handlers/system.js +1 -1
- package/dist/server/server-adapter/index.cjs +1 -1
- package/dist/server/server-adapter/index.js +1 -1
- package/package.json +6 -6
- package/dist/dist-1bGgLbxg.cjs.map +0 -1
- package/dist/dist-DcTSQIB2.js.map +0 -1
- package/dist/observability-new-endpoints-0hQR-aWF.js.map +0 -1
- package/dist/observability-new-endpoints-BIoS0_PJ.cjs.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"observability-shared.cjs","names":["coreStorage","candidate","HTTPException","coreFeatures","z","paginationArgsSchema","wrapSchemaForQueryParams","listModeSchema","deltaCursorSchema","deltaLimitSchema"],"sources":["../../../src/server/handlers/observability-shared.ts"],"sourcesContent":["import type { Mastra } from '@mastra/core';\nimport { coreFeatures } from '@mastra/core/features';\nimport type { MastraCompositeStore, ObservabilityStorage, ScoresStorage } from '@mastra/core/storage';\nimport * as coreStorage from '@mastra/core/storage';\nimport { z } from 'zod/v4';\nimport { HTTPException } from '../http-exception';\nimport type { ServerRoute } from '../server-adapter/routes';\nimport { wrapSchemaForQueryParams } from '../server-adapter/routes/route-builder';\nimport {\n deltaCursorSchema,\n deltaLimitSchema,\n listModeSchema,\n paginationArgsSchema,\n} from './observability-list-query-schemas';\n\nexport const OBSERVABILITY_DELTA_POLLING_FEATURE = 'observability-delta-polling';\nexport const OBSERVABILITY_DELTA_POLLING_UPGRADE_MESSAGE =\n 'Delta polling requires a newer @mastra/core with observability delta polling support. Please upgrade.';\nconst OBSERVABILITY_TRACE_QUERY_STORAGE_FEATURE = 'trace-query';\nconst OBSERVABILITY_TRACE_QUERY_DISCOVERY_STORAGE_FEATURE = 'trace-query-discovery';\nconst OBSERVABILITY_THREAD_QUERY_STORAGE_FEATURE = 'thread-query';\nconst OBSERVABILITY_TRACE_QUERY_TENANT_SCOPE_STORAGE_FEATURE = 'trace-query-tenant-scope';\nexport const OBSERVABILITY_TRACE_QUERY_TENANT_SCOPE_CORE_FEATURE = 'observability-trace-query-tenant-scope';\nexport const OBSERVABILITY_TRACE_QUERY_TENANT_SCOPE_UPGRADE_MESSAGE =\n 'Trusted tenant scope requires a newer @mastra/core with trace-query tenant scope support. Please upgrade.';\n\nexport function supportsTraceQueryDiscoveryCore() {\n return (\n coreStorage.getTraceQueryFieldsArgsSchema !== undefined &&\n coreStorage.getTraceQueryFieldsResponseSchema !== undefined &&\n coreStorage.getTraceQueryValuesArgsSchema !== undefined &&\n coreStorage.getTraceQueryValuesResponseSchema !== undefined &&\n typeof coreStorage.planTraceQueryObservedFields === 'function' &&\n typeof coreStorage.planTraceQueryValues === 'function' &&\n typeof coreStorage.getTraceQueryCanonicalFieldDescriptors === 'function' &&\n typeof coreStorage.TraceQueryResourceLimitError === 'function'\n );\n}\n\nexport const OBSERVABILITY_LIST_ENDPOINTS = {\n traces: 'traces',\n branches: 'branches',\n logs: 'logs',\n metrics: 'metrics',\n scores: 'scores',\n feedback: 'feedback',\n} as const;\n\nexport type ObservabilityListEndpoint =\n (typeof OBSERVABILITY_LIST_ENDPOINTS)[keyof typeof OBSERVABILITY_LIST_ENDPOINTS];\nconst OBSERVABILITY_DELTA_POLLING_STORAGE_FEATURE = 'delta-polling';\n\nfunction getFeatures(observabilityStore: ObservabilityStorage): readonly string[] | undefined {\n const candidate = observabilityStore as ObservabilityStorage & {\n getFeatures?: () => readonly string[] | undefined;\n };\n return candidate.getFeatures?.();\n}\n\n/** Retrieves MastraCompositeStore or throws 500 if unavailable. */\nexport function getStorage(mastra: Mastra): MastraCompositeStore {\n const storage = mastra.getStorage();\n if (!storage) {\n throw new HTTPException(500, { message: 'Storage is not available' });\n }\n return storage;\n}\n\n/** Retrieves the observability storage domain or throws 501 if unavailable. */\nexport async function getObservabilityStore(mastra: Mastra): Promise<ObservabilityStorage> {\n const storage = getStorage(mastra);\n const observability = await storage.getStore('observability');\n if (!observability) {\n // 501, not 500: a missing or explicitly disabled observability domain\n // (e.g. `domains: { observability: false }`) is a capability gap, not a\n // server failure — matching the other 501s in this file.\n throw new HTTPException(501, { message: 'Observability storage domain is not available' });\n }\n return observability;\n}\n\n/** Retrieves the scores storage domain or throws 501 if unavailable. */\nexport async function getScoresStore(mastra: Mastra): Promise<ScoresStorage> {\n const storage = getStorage(mastra);\n const scores = await storage.getStore('scores');\n if (!scores) {\n throw new HTTPException(501, { message: 'Scores storage domain is not available' });\n }\n return scores;\n}\n\nexport function assertObservabilityTraceQuerySupported(observabilityStore: ObservabilityStorage) {\n if (getFeatures(observabilityStore)?.includes(OBSERVABILITY_TRACE_QUERY_STORAGE_FEATURE)) return;\n\n throw new HTTPException(501, {\n message: 'Advanced trace queries are not supported by the configured observability store',\n });\n}\n\nexport function assertObservabilityTraceQueryDiscoverySupported(observabilityStore: ObservabilityStorage) {\n if (getFeatures(observabilityStore)?.includes(OBSERVABILITY_TRACE_QUERY_DISCOVERY_STORAGE_FEATURE)) return;\n\n throw new HTTPException(501, {\n message: 'Trace query discovery is not supported by the configured observability store',\n });\n}\n\n/**\n * A scoped request must never run unscoped: a store that predates tenant scope would\n * silently ignore `plan.scope` and return every tenant's rows, so it is rejected instead.\n * Unscoped requests are unaffected.\n */\nexport function assertObservabilityTraceQueryTenantScopeSupported(\n observabilityStore: ObservabilityStorage,\n scope: coreStorage.TraceQueryTenantScope | undefined,\n) {\n if (scope === undefined) return;\n if (getFeatures(observabilityStore)?.includes(OBSERVABILITY_TRACE_QUERY_TENANT_SCOPE_STORAGE_FEATURE)) return;\n\n throw new HTTPException(501, {\n message: 'The configured observability store cannot enforce the trusted tenant scope',\n });\n}\n\nexport function assertObservabilityThreadQuerySupported(observabilityStore: ObservabilityStorage) {\n if (getFeatures(observabilityStore)?.includes(OBSERVABILITY_THREAD_QUERY_STORAGE_FEATURE)) return;\n\n throw new HTTPException(501, {\n message: 'Advanced thread queries are not supported by the configured observability store',\n });\n}\n\nexport function assertObservabilityDeltaSupported(\n observabilityStore: ObservabilityStorage,\n endpoint: ObservabilityListEndpoint,\n) {\n if (!coreFeatures.has(OBSERVABILITY_DELTA_POLLING_FEATURE)) {\n throw new HTTPException(501, {\n message: `${OBSERVABILITY_DELTA_POLLING_UPGRADE_MESSAGE} (endpoint: ${endpoint})`,\n });\n }\n\n if (getFeatures(observabilityStore)?.includes(OBSERVABILITY_DELTA_POLLING_STORAGE_FEATURE)) {\n return;\n }\n\n throw new HTTPException(501, {\n message: `Delta polling is not supported by the configured observability store for ${endpoint}`,\n });\n}\n\nexport interface RouteDetails {\n method: ServerRoute['method'];\n path: `/${string}`;\n summary: string;\n description: string;\n requiresPermission?: ServerRoute['requiresPermission'];\n}\n\nexport const NEW_ROUTE_DEFS = {\n QUERY_TRACES: {\n method: 'POST',\n path: '/observability/traces/query',\n summary: 'Query traces',\n description:\n 'Returns completed logical traces or distinct thread groups matching an advanced trace query. Thread grouping remains supported but is deprecated; use queryTraceThreads instead.',\n requiresPermission: 'observability:read',\n },\n\n QUERY_THREADS: {\n method: 'POST',\n path: '/observability/threads/query',\n summary: 'Query threads',\n description: 'Returns thread identities matching eligible trace and cross-trace predicates',\n requiresPermission: 'observability:read',\n },\n\n GET_TRACE_QUERY_FIELDS: {\n method: 'POST',\n path: '/observability/traces/query/fields',\n summary: 'Discover trace query fields',\n description: 'Returns canonical query fields and observed top-level string metadata fields',\n requiresPermission: 'observability:read',\n },\n\n GET_TRACE_QUERY_VALUES: {\n method: 'POST',\n path: '/observability/traces/query/values',\n summary: 'Discover trace query values',\n description: 'Returns bounded string value suggestions and occurrence counts for one eligible query field',\n requiresPermission: 'observability:read',\n },\n\n LIST_METRICS: {\n method: 'GET',\n path: '/observability/metrics',\n summary: 'List metrics',\n description: 'Returns a paginated list of metrics with optional filtering and sorting',\n },\n\n LIST_LOGS: {\n method: 'GET',\n path: '/observability/logs',\n summary: 'List logs',\n description: 'Returns a paginated list of logs with optional filtering and sorting',\n },\n\n LIST_SCORES: {\n method: 'GET',\n path: '/observability/scores',\n summary: 'List scores',\n description: 'Returns a paginated list of scores with optional filtering and sorting',\n },\n\n CREATE_SCORE: {\n method: 'POST',\n path: '/observability/scores',\n summary: 'Create a score',\n description: 'Creates a single score record in the observability store',\n },\n\n DELETE_SCORES: {\n method: 'DELETE',\n path: '/observability/scores',\n summary: 'Delete scores',\n description: 'Deletes score records by scoreId, optionally scoped to a tenant',\n requiresPermission: 'observability:delete',\n },\n\n GET_SCORE: {\n method: 'GET',\n path: '/observability/scores/:scoreId',\n summary: 'Get score',\n description: 'Returns a single score by scoreId',\n },\n\n GET_SCORE_AGGREGATE: {\n method: 'POST',\n path: '/observability/scores/aggregate',\n summary: 'Get score aggregate',\n description: 'Returns an aggregated score value with optional period-over-period comparison',\n requiresPermission: 'observability:read',\n },\n\n GET_SCORE_BREAKDOWN: {\n method: 'POST',\n path: '/observability/scores/breakdown',\n summary: 'Get score breakdown',\n description: 'Returns score values grouped by specified dimensions',\n requiresPermission: 'observability:read',\n },\n\n GET_SCORE_TIME_SERIES: {\n method: 'POST',\n path: '/observability/scores/timeseries',\n summary: 'Get score time series',\n description: 'Returns score values bucketed by time interval with optional grouping',\n requiresPermission: 'observability:read',\n },\n\n GET_SCORE_PERCENTILES: {\n method: 'POST',\n path: '/observability/scores/percentiles',\n summary: 'Get score percentiles',\n description: 'Returns percentile values for a score bucketed by time interval',\n requiresPermission: 'observability:read',\n },\n\n LIST_FEEDBACK: {\n method: 'GET',\n path: '/observability/feedback',\n summary: 'List feedback',\n description: 'Returns a paginated list of feedback with optional filtering and sorting',\n },\n\n CREATE_FEEDBACK: {\n method: 'POST',\n path: '/observability/feedback',\n summary: 'Create feedback',\n description: 'Creates a single feedback record in the observability store',\n },\n\n DELETE_FEEDBACK: {\n method: 'DELETE',\n path: '/observability/feedback',\n summary: 'Delete feedback',\n description: 'Deletes feedback records by feedbackId, optionally scoped to a tenant',\n requiresPermission: 'observability:delete',\n },\n\n UPDATE_FEEDBACK_REVIEW_STATUS: {\n method: 'PATCH',\n path: '/observability/feedback/:feedbackId/review-status',\n summary: 'Update feedback review status',\n description: \"Updates a feedback record's review workflow status\",\n requiresPermission: 'observability:write',\n },\n\n GET_FEEDBACK_AGGREGATE: {\n method: 'POST',\n path: '/observability/feedback/aggregate',\n summary: 'Get feedback aggregate',\n description: 'Returns an aggregated numeric feedback value with optional period-over-period comparison',\n requiresPermission: 'observability:read',\n },\n\n GET_FEEDBACK_BREAKDOWN: {\n method: 'POST',\n path: '/observability/feedback/breakdown',\n summary: 'Get feedback breakdown',\n description: 'Returns numeric feedback values grouped by specified dimensions',\n requiresPermission: 'observability:read',\n },\n\n GET_FEEDBACK_TIME_SERIES: {\n method: 'POST',\n path: '/observability/feedback/timeseries',\n summary: 'Get feedback time series',\n description: 'Returns numeric feedback values bucketed by time interval with optional grouping',\n requiresPermission: 'observability:read',\n },\n\n GET_FEEDBACK_PERCENTILES: {\n method: 'POST',\n path: '/observability/feedback/percentiles',\n summary: 'Get feedback percentiles',\n description: 'Returns percentile values for numeric feedback bucketed by time interval',\n requiresPermission: 'observability:read',\n },\n\n GET_METRIC_AGGREGATE: {\n method: 'POST',\n path: '/observability/metrics/aggregate',\n summary: 'Get metric aggregate',\n description: 'Returns an aggregated metric value with optional period-over-period comparison',\n requiresPermission: 'observability:read',\n },\n\n GET_METRIC_BREAKDOWN: {\n method: 'POST',\n path: '/observability/metrics/breakdown',\n summary: 'Get metric breakdown',\n description: 'Returns metric values grouped by specified dimensions',\n requiresPermission: 'observability:read',\n },\n\n GET_METRIC_TIME_SERIES: {\n method: 'POST',\n path: '/observability/metrics/timeseries',\n summary: 'Get metric time series',\n description: 'Returns metric values bucketed by time interval with optional grouping',\n requiresPermission: 'observability:read',\n },\n\n GET_METRIC_PERCENTILES: {\n method: 'POST',\n path: '/observability/metrics/percentiles',\n summary: 'Get metric percentiles',\n description: 'Returns percentile values for a metric bucketed by time interval',\n requiresPermission: 'observability:read',\n },\n\n GET_METRIC_NAMES: {\n method: 'GET',\n path: '/observability/discovery/metric-names',\n summary: 'Get metric names',\n description: 'Returns distinct metric names with optional prefix filtering',\n },\n\n GET_METRIC_LABEL_KEYS: {\n method: 'GET',\n path: '/observability/discovery/metric-label-keys',\n summary: 'Get metric label keys',\n description: 'Returns distinct label keys for a given metric',\n },\n\n GET_METRIC_LABEL_VALUES: {\n method: 'GET',\n path: '/observability/discovery/metric-label-values',\n summary: 'Get label values',\n description: 'Returns distinct values for a given metric label key',\n },\n\n GET_ENTITY_TYPES: {\n method: 'GET',\n path: '/observability/discovery/entity-types',\n summary: 'Get entity types',\n description: 'Returns distinct entity types from observability data',\n },\n\n GET_ENTITY_NAMES: {\n method: 'GET',\n path: '/observability/discovery/entity-names',\n summary: 'Get entity names',\n description: 'Returns distinct entity names with optional type filtering',\n },\n\n GET_SERVICE_NAMES: {\n method: 'GET',\n path: '/observability/discovery/service-names',\n summary: 'Get service names',\n description: 'Returns distinct service names from observability data',\n },\n\n GET_ENVIRONMENTS: {\n method: 'GET',\n path: '/observability/discovery/environments',\n summary: 'Get environments',\n description: 'Returns distinct environments from observability data',\n },\n\n GET_TAGS: {\n method: 'GET',\n path: '/observability/discovery/tags',\n summary: 'Get tags',\n description: 'Returns distinct tags with optional entity type filtering',\n },\n} as const satisfies Record<string, RouteDetails>;\n\nexport type NewRoutesKey = keyof typeof NEW_ROUTE_DEFS;\nexport type NewRoutesDefinitions = (typeof NEW_ROUTE_DEFS)[NewRoutesKey];\n\nexport function createObservabilityListQuerySchema<\n TFilter extends z.ZodObject<z.ZodRawShape>,\n TOrderBy extends z.ZodObject<z.ZodRawShape>,\n>(filterSchema: TFilter, orderBySchema: TOrderBy) {\n const unwrapDefault = (schema: unknown) => {\n const zodSchema = schema as z.ZodTypeAny;\n return zodSchema instanceof z.ZodDefault ? zodSchema.unwrap() : zodSchema;\n };\n const paginationShape = paginationArgsSchema.shape as unknown as Record<string, z.ZodTypeAny>;\n const orderByShape = orderBySchema.shape as unknown as Record<string, z.ZodTypeAny>;\n\n const pageSchema = unwrapDefault(paginationShape.page);\n const perPageSchema = unwrapDefault(paginationShape.perPage);\n const fieldSchema = orderByShape.field ? unwrapDefault(orderByShape.field) : z.never().optional();\n const directionSchema = orderByShape.direction ? unwrapDefault(orderByShape.direction) : z.never().optional();\n\n return wrapSchemaForQueryParams(\n z\n .object({\n ...filterSchema.shape,\n page: pageSchema,\n perPage: perPageSchema,\n field: fieldSchema,\n direction: directionSchema,\n mode: listModeSchema.optional(),\n after: deltaCursorSchema.optional(),\n limit: deltaLimitSchema,\n })\n .partial(),\n ).superRefine((value, ctx) => {\n const isDelta = value.mode === 'delta';\n const hasPagination = value.page !== undefined || value.perPage !== undefined;\n const hasOrderBy = value.field !== undefined || value.direction !== undefined;\n const hasAfter = value.after !== undefined;\n const hasLimit = value.limit !== undefined;\n\n if (isDelta) {\n if (hasPagination) {\n if (value.page !== undefined) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['page'],\n message: '`page` is not allowed when `mode=delta`',\n });\n }\n if (value.perPage !== undefined) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['perPage'],\n message: '`perPage` is not allowed when `mode=delta`',\n });\n }\n }\n if (hasOrderBy) {\n if (value.field !== undefined) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['field'],\n message: '`field` is not allowed when `mode=delta`',\n });\n }\n if (value.direction !== undefined) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['direction'],\n message: '`direction` is not allowed when `mode=delta`',\n });\n }\n }\n return;\n }\n\n if (hasAfter) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['after'],\n message: '`after` is only allowed when `mode=delta`',\n });\n }\n if (hasLimit) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['limit'],\n message: '`limit` is only allowed when `mode=delta`',\n });\n }\n });\n}\n"],"mappings":";;;;;;;;;;AAeA,MAAa,sCAAsC;AACnD,MAAa,8CACX;AACF,MAAM,4CAA4C;AAClD,MAAM,sDAAsD;AAC5D,MAAM,6CAA6C;AACnD,MAAM,yDAAyD;AAC/D,MAAa,sDAAsD;AACnE,MAAa,yDACX;AAEF,SAAgB,kCAAkC;CAChD,OACEA,qBAAY,kCAAkC,KAAA,KAC9CA,qBAAY,sCAAsC,KAAA,KAClDA,qBAAY,kCAAkC,KAAA,KAC9CA,qBAAY,sCAAsC,KAAA,KAClD,OAAOA,qBAAY,iCAAiC,cACpD,OAAOA,qBAAY,yBAAyB,cAC5C,OAAOA,qBAAY,2CAA2C,cAC9D,OAAOA,qBAAY,iCAAiC;AAExD;AAEA,MAAa,+BAA+B;CAC1C,QAAQ;CACR,UAAU;CACV,MAAM;CACN,SAAS;CACT,QAAQ;CACR,UAAU;AACZ;AAIA,MAAM,8CAA8C;AAEpD,SAAS,YAAY,oBAAyE;CAI5F,OAAOC,mBAAU,cAAc;AACjC;;AAGA,SAAgB,WAAW,QAAsC;CAC/D,MAAM,UAAU,OAAO,WAAW;CAClC,IAAI,CAAC,SACH,MAAM,IAAIC,uBAAAA,cAAc,KAAK,EAAE,SAAS,2BAA2B,CAAC;CAEtE,OAAO;AACT;;AAGA,eAAsB,sBAAsB,QAA+C;CAEzF,MAAM,gBAAgB,MADN,WAAW,MACO,CAAC,CAAC,SAAS,eAAe;CAC5D,IAAI,CAAC,eAIH,MAAM,IAAIA,uBAAAA,cAAc,KAAK,EAAE,SAAS,gDAAgD,CAAC;CAE3F,OAAO;AACT;;AAGA,eAAsB,eAAe,QAAwC;CAE3E,MAAM,SAAS,MADC,WAAW,MACA,CAAC,CAAC,SAAS,QAAQ;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AAC,OAAO;KACd,SAAS;IACX,CAAC;IAEH,IAAI,MAAM,cAAc,KAAA,GACtB,IAAI,SAAS;KACX,MAAMA,OAAAA,EAAE,aAAa;KACrB,MAAM,CAAC,WAAW;KAClB,SAAS;IACX,CAAC;GAEL;GACA;EACF;EAEA,IAAI,UACF,IAAI,SAAS;GACX,MAAMA,OAAAA,EAAE,aAAa;GACrB,MAAM,CAAC,OAAO;GACd,SAAS;EACX,CAAC;EAEH,IAAI,UACF,IAAI,SAAS;GACX,MAAMA,OAAAA,EAAE,aAAa;GACrB,MAAM,CAAC,OAAO;GACd,SAAS;EACX,CAAC;CAEL,CAAC;AACH"}
|
|
1
|
+
{"version":3,"file":"observability-shared.cjs","names":["coreStorage","candidate","HTTPException","coreFeatures","z","paginationArgsSchema","wrapSchemaForQueryParams","listModeSchema","deltaCursorSchema","deltaLimitSchema"],"sources":["../../../src/server/handlers/observability-shared.ts"],"sourcesContent":["import type { Mastra } from '@mastra/core';\nimport { coreFeatures } from '@mastra/core/features';\nimport type {\n MastraCompositeStore,\n ObservabilityStorage,\n ScoresStorage,\n TrustedThreadPredicate,\n TrustedTraceQueryPredicate,\n} from '@mastra/core/storage';\nimport * as coreStorage from '@mastra/core/storage';\nimport { z } from 'zod/v4';\nimport { HTTPException } from '../http-exception';\nimport type { ServerRoute } from '../server-adapter/routes';\nimport { wrapSchemaForQueryParams } from '../server-adapter/routes/route-builder';\nimport {\n deltaCursorSchema,\n deltaLimitSchema,\n listModeSchema,\n paginationArgsSchema,\n} from './observability-list-query-schemas';\n\nexport const OBSERVABILITY_DELTA_POLLING_FEATURE = 'observability-delta-polling';\nexport const OBSERVABILITY_DELTA_POLLING_UPGRADE_MESSAGE =\n 'Delta polling requires a newer @mastra/core with observability delta polling support. Please upgrade.';\nconst OBSERVABILITY_TRACE_QUERY_STORAGE_FEATURE = 'trace-query';\nconst OBSERVABILITY_TRACE_QUERY_ROOT_DURATION_STORAGE_FEATURE = 'trace-query-root-duration';\nconst OBSERVABILITY_TRACE_QUERY_DISCOVERY_STORAGE_FEATURE = 'trace-query-discovery';\nconst OBSERVABILITY_THREAD_QUERY_STORAGE_FEATURE = 'thread-query';\nconst OBSERVABILITY_TRACE_QUERY_TENANT_SCOPE_STORAGE_FEATURE = 'trace-query-tenant-scope';\nexport const OBSERVABILITY_TRACE_QUERY_TENANT_SCOPE_CORE_FEATURE = 'observability-trace-query-tenant-scope';\nexport const OBSERVABILITY_TRACE_QUERY_TENANT_SCOPE_UPGRADE_MESSAGE =\n 'Trusted tenant scope requires a newer @mastra/core with trace-query tenant scope support. Please upgrade.';\n\nexport function supportsTraceQueryDiscoveryCore() {\n return (\n coreStorage.getTraceQueryFieldsArgsSchema !== undefined &&\n coreStorage.getTraceQueryFieldsResponseSchema !== undefined &&\n coreStorage.getTraceQueryValuesArgsSchema !== undefined &&\n coreStorage.getTraceQueryValuesResponseSchema !== undefined &&\n typeof coreStorage.planTraceQueryObservedFields === 'function' &&\n typeof coreStorage.planTraceQueryValues === 'function' &&\n typeof coreStorage.getTraceQueryCanonicalFieldDescriptors === 'function' &&\n typeof coreStorage.TraceQueryResourceLimitError === 'function'\n );\n}\n\nexport const OBSERVABILITY_LIST_ENDPOINTS = {\n traces: 'traces',\n branches: 'branches',\n logs: 'logs',\n metrics: 'metrics',\n scores: 'scores',\n feedback: 'feedback',\n} as const;\n\nexport type ObservabilityListEndpoint =\n (typeof OBSERVABILITY_LIST_ENDPOINTS)[keyof typeof OBSERVABILITY_LIST_ENDPOINTS];\nconst OBSERVABILITY_DELTA_POLLING_STORAGE_FEATURE = 'delta-polling';\n\nfunction getFeatures(observabilityStore: ObservabilityStorage): readonly string[] | undefined {\n const candidate = observabilityStore as ObservabilityStorage & {\n getFeatures?: () => readonly string[] | undefined;\n };\n return candidate.getFeatures?.();\n}\n\n/** Retrieves MastraCompositeStore or throws 500 if unavailable. */\nexport function getStorage(mastra: Mastra): MastraCompositeStore {\n const storage = mastra.getStorage();\n if (!storage) {\n throw new HTTPException(500, { message: 'Storage is not available' });\n }\n return storage;\n}\n\n/** Retrieves the observability storage domain or throws 501 if unavailable. */\nexport async function getObservabilityStore(mastra: Mastra): Promise<ObservabilityStorage> {\n const storage = getStorage(mastra);\n const observability = await storage.getStore('observability');\n if (!observability) {\n // 501, not 500: a missing or explicitly disabled observability domain\n // (e.g. `domains: { observability: false }`) is a capability gap, not a\n // server failure — matching the other 501s in this file.\n throw new HTTPException(501, { message: 'Observability storage domain is not available' });\n }\n return observability;\n}\n\n/** Retrieves the scores storage domain or throws 501 if unavailable. */\nexport async function getScoresStore(mastra: Mastra): Promise<ScoresStorage> {\n const storage = getStorage(mastra);\n const scores = await storage.getStore('scores');\n if (!scores) {\n throw new HTTPException(501, { message: 'Scores storage domain is not available' });\n }\n return scores;\n}\n\nexport function assertObservabilityTraceQuerySupported(observabilityStore: ObservabilityStorage) {\n if (getFeatures(observabilityStore)?.includes(OBSERVABILITY_TRACE_QUERY_STORAGE_FEATURE)) return;\n\n throw new HTTPException(501, {\n message: 'Advanced trace queries are not supported by the configured observability store',\n });\n}\n\nfunction usesRootDuration(predicate: TrustedTraceQueryPredicate | TrustedThreadPredicate | undefined): boolean {\n if (!predicate) return false;\n if (predicate.type === 'boolean') return predicate.args.some(usesRootDuration);\n if (predicate.type === 'not') return usesRootDuration(predicate.arg);\n if (predicate.type === 'relation') {\n return predicate.collection === 'traces' && usesRootDuration(predicate.predicate);\n }\n return predicate.field === 'durationMs';\n}\n\nexport function supportsObservabilityTraceQueryRootDuration(observabilityStore: ObservabilityStorage) {\n return getFeatures(observabilityStore)?.includes(OBSERVABILITY_TRACE_QUERY_ROOT_DURATION_STORAGE_FEATURE) === true;\n}\n\nexport function assertObservabilityTraceQueryRootDurationSupported(\n observabilityStore: ObservabilityStorage,\n predicate: TrustedTraceQueryPredicate | TrustedThreadPredicate | undefined,\n) {\n if (!usesRootDuration(predicate) || supportsObservabilityTraceQueryRootDuration(observabilityStore)) return;\n\n throw new HTTPException(501, {\n message: 'Root duration predicates are not supported by the configured observability store',\n });\n}\n\nexport function assertObservabilityTraceQueryDiscoverySupported(observabilityStore: ObservabilityStorage) {\n if (getFeatures(observabilityStore)?.includes(OBSERVABILITY_TRACE_QUERY_DISCOVERY_STORAGE_FEATURE)) return;\n\n throw new HTTPException(501, {\n message: 'Trace query discovery is not supported by the configured observability store',\n });\n}\n\n/**\n * A scoped request must never run unscoped: a store that predates tenant scope would\n * silently ignore `plan.scope` and return every tenant's rows, so it is rejected instead.\n * Unscoped requests are unaffected.\n */\nexport function assertObservabilityTraceQueryTenantScopeSupported(\n observabilityStore: ObservabilityStorage,\n scope: coreStorage.TraceQueryTenantScope | undefined,\n) {\n if (scope === undefined) return;\n if (getFeatures(observabilityStore)?.includes(OBSERVABILITY_TRACE_QUERY_TENANT_SCOPE_STORAGE_FEATURE)) return;\n\n throw new HTTPException(501, {\n message: 'The configured observability store cannot enforce the trusted tenant scope',\n });\n}\n\nexport function assertObservabilityThreadQuerySupported(observabilityStore: ObservabilityStorage) {\n if (getFeatures(observabilityStore)?.includes(OBSERVABILITY_THREAD_QUERY_STORAGE_FEATURE)) return;\n\n throw new HTTPException(501, {\n message: 'Advanced thread queries are not supported by the configured observability store',\n });\n}\n\nexport function assertObservabilityDeltaSupported(\n observabilityStore: ObservabilityStorage,\n endpoint: ObservabilityListEndpoint,\n) {\n if (!coreFeatures.has(OBSERVABILITY_DELTA_POLLING_FEATURE)) {\n throw new HTTPException(501, {\n message: `${OBSERVABILITY_DELTA_POLLING_UPGRADE_MESSAGE} (endpoint: ${endpoint})`,\n });\n }\n\n if (getFeatures(observabilityStore)?.includes(OBSERVABILITY_DELTA_POLLING_STORAGE_FEATURE)) {\n return;\n }\n\n throw new HTTPException(501, {\n message: `Delta polling is not supported by the configured observability store for ${endpoint}`,\n });\n}\n\nexport interface RouteDetails {\n method: ServerRoute['method'];\n path: `/${string}`;\n summary: string;\n description: string;\n requiresPermission?: ServerRoute['requiresPermission'];\n}\n\nexport const NEW_ROUTE_DEFS = {\n QUERY_TRACES: {\n method: 'POST',\n path: '/observability/traces/query',\n summary: 'Query traces',\n description:\n 'Returns completed logical traces or distinct thread groups matching an advanced trace query. Thread grouping remains supported but is deprecated; use queryTraceThreads instead.',\n requiresPermission: 'observability:read',\n },\n\n QUERY_THREADS: {\n method: 'POST',\n path: '/observability/threads/query',\n summary: 'Query threads',\n description: 'Returns thread identities matching eligible trace and cross-trace predicates',\n requiresPermission: 'observability:read',\n },\n\n GET_TRACE_QUERY_FIELDS: {\n method: 'POST',\n path: '/observability/traces/query/fields',\n summary: 'Discover trace query fields',\n description: 'Returns canonical query fields and observed top-level string metadata fields',\n requiresPermission: 'observability:read',\n },\n\n GET_TRACE_QUERY_VALUES: {\n method: 'POST',\n path: '/observability/traces/query/values',\n summary: 'Discover trace query values',\n description: 'Returns bounded string value suggestions and occurrence counts for one eligible query field',\n requiresPermission: 'observability:read',\n },\n\n LIST_METRICS: {\n method: 'GET',\n path: '/observability/metrics',\n summary: 'List metrics',\n description: 'Returns a paginated list of metrics with optional filtering and sorting',\n },\n\n LIST_LOGS: {\n method: 'GET',\n path: '/observability/logs',\n summary: 'List logs',\n description: 'Returns a paginated list of logs with optional filtering and sorting',\n },\n\n LIST_SCORES: {\n method: 'GET',\n path: '/observability/scores',\n summary: 'List scores',\n description: 'Returns a paginated list of scores with optional filtering and sorting',\n },\n\n CREATE_SCORE: {\n method: 'POST',\n path: '/observability/scores',\n summary: 'Create a score',\n description: 'Creates a single score record in the observability store',\n },\n\n DELETE_SCORES: {\n method: 'DELETE',\n path: '/observability/scores',\n summary: 'Delete scores',\n description: 'Deletes score records by scoreId, optionally scoped to a tenant',\n requiresPermission: 'observability:delete',\n },\n\n GET_SCORE: {\n method: 'GET',\n path: '/observability/scores/:scoreId',\n summary: 'Get score',\n description: 'Returns a single score by scoreId',\n },\n\n GET_SCORE_AGGREGATE: {\n method: 'POST',\n path: '/observability/scores/aggregate',\n summary: 'Get score aggregate',\n description: 'Returns an aggregated score value with optional period-over-period comparison',\n requiresPermission: 'observability:read',\n },\n\n GET_SCORE_BREAKDOWN: {\n method: 'POST',\n path: '/observability/scores/breakdown',\n summary: 'Get score breakdown',\n description: 'Returns score values grouped by specified dimensions',\n requiresPermission: 'observability:read',\n },\n\n GET_SCORE_TIME_SERIES: {\n method: 'POST',\n path: '/observability/scores/timeseries',\n summary: 'Get score time series',\n description: 'Returns score values bucketed by time interval with optional grouping',\n requiresPermission: 'observability:read',\n },\n\n GET_SCORE_PERCENTILES: {\n method: 'POST',\n path: '/observability/scores/percentiles',\n summary: 'Get score percentiles',\n description: 'Returns percentile values for a score bucketed by time interval',\n requiresPermission: 'observability:read',\n },\n\n LIST_FEEDBACK: {\n method: 'GET',\n path: '/observability/feedback',\n summary: 'List feedback',\n description: 'Returns a paginated list of feedback with optional filtering and sorting',\n },\n\n CREATE_FEEDBACK: {\n method: 'POST',\n path: '/observability/feedback',\n summary: 'Create feedback',\n description: 'Creates a single feedback record in the observability store',\n },\n\n DELETE_FEEDBACK: {\n method: 'DELETE',\n path: '/observability/feedback',\n summary: 'Delete feedback',\n description: 'Deletes feedback records by feedbackId, optionally scoped to a tenant',\n requiresPermission: 'observability:delete',\n },\n\n UPDATE_FEEDBACK_REVIEW_STATUS: {\n method: 'PATCH',\n path: '/observability/feedback/:feedbackId/review-status',\n summary: 'Update feedback review status',\n description: \"Updates a feedback record's review workflow status\",\n requiresPermission: 'observability:write',\n },\n\n GET_FEEDBACK_AGGREGATE: {\n method: 'POST',\n path: '/observability/feedback/aggregate',\n summary: 'Get feedback aggregate',\n description: 'Returns an aggregated numeric feedback value with optional period-over-period comparison',\n requiresPermission: 'observability:read',\n },\n\n GET_FEEDBACK_BREAKDOWN: {\n method: 'POST',\n path: '/observability/feedback/breakdown',\n summary: 'Get feedback breakdown',\n description: 'Returns numeric feedback values grouped by specified dimensions',\n requiresPermission: 'observability:read',\n },\n\n GET_FEEDBACK_TIME_SERIES: {\n method: 'POST',\n path: '/observability/feedback/timeseries',\n summary: 'Get feedback time series',\n description: 'Returns numeric feedback values bucketed by time interval with optional grouping',\n requiresPermission: 'observability:read',\n },\n\n GET_FEEDBACK_PERCENTILES: {\n method: 'POST',\n path: '/observability/feedback/percentiles',\n summary: 'Get feedback percentiles',\n description: 'Returns percentile values for numeric feedback bucketed by time interval',\n requiresPermission: 'observability:read',\n },\n\n GET_METRIC_AGGREGATE: {\n method: 'POST',\n path: '/observability/metrics/aggregate',\n summary: 'Get metric aggregate',\n description: 'Returns an aggregated metric value with optional period-over-period comparison',\n requiresPermission: 'observability:read',\n },\n\n GET_METRIC_BREAKDOWN: {\n method: 'POST',\n path: '/observability/metrics/breakdown',\n summary: 'Get metric breakdown',\n description: 'Returns metric values grouped by specified dimensions',\n requiresPermission: 'observability:read',\n },\n\n GET_METRIC_TIME_SERIES: {\n method: 'POST',\n path: '/observability/metrics/timeseries',\n summary: 'Get metric time series',\n description: 'Returns metric values bucketed by time interval with optional grouping',\n requiresPermission: 'observability:read',\n },\n\n GET_METRIC_PERCENTILES: {\n method: 'POST',\n path: '/observability/metrics/percentiles',\n summary: 'Get metric percentiles',\n description: 'Returns percentile values for a metric bucketed by time interval',\n requiresPermission: 'observability:read',\n },\n\n GET_METRIC_NAMES: {\n method: 'GET',\n path: '/observability/discovery/metric-names',\n summary: 'Get metric names',\n description: 'Returns distinct metric names with optional prefix filtering',\n },\n\n GET_METRIC_LABEL_KEYS: {\n method: 'GET',\n path: '/observability/discovery/metric-label-keys',\n summary: 'Get metric label keys',\n description: 'Returns distinct label keys for a given metric',\n },\n\n GET_METRIC_LABEL_VALUES: {\n method: 'GET',\n path: '/observability/discovery/metric-label-values',\n summary: 'Get label values',\n description: 'Returns distinct values for a given metric label key',\n },\n\n GET_ENTITY_TYPES: {\n method: 'GET',\n path: '/observability/discovery/entity-types',\n summary: 'Get entity types',\n description: 'Returns distinct entity types from observability data',\n },\n\n GET_ENTITY_NAMES: {\n method: 'GET',\n path: '/observability/discovery/entity-names',\n summary: 'Get entity names',\n description: 'Returns distinct entity names with optional type filtering',\n },\n\n GET_SERVICE_NAMES: {\n method: 'GET',\n path: '/observability/discovery/service-names',\n summary: 'Get service names',\n description: 'Returns distinct service names from observability data',\n },\n\n GET_ENVIRONMENTS: {\n method: 'GET',\n path: '/observability/discovery/environments',\n summary: 'Get environments',\n description: 'Returns distinct environments from observability data',\n },\n\n GET_TAGS: {\n method: 'GET',\n path: '/observability/discovery/tags',\n summary: 'Get tags',\n description: 'Returns distinct tags with optional entity type filtering',\n },\n} as const satisfies Record<string, RouteDetails>;\n\nexport type NewRoutesKey = keyof typeof NEW_ROUTE_DEFS;\nexport type NewRoutesDefinitions = (typeof NEW_ROUTE_DEFS)[NewRoutesKey];\n\nexport function createObservabilityListQuerySchema<\n TFilter extends z.ZodObject<z.ZodRawShape>,\n TOrderBy extends z.ZodObject<z.ZodRawShape>,\n>(filterSchema: TFilter, orderBySchema: TOrderBy) {\n const unwrapDefault = (schema: unknown) => {\n const zodSchema = schema as z.ZodTypeAny;\n return zodSchema instanceof z.ZodDefault ? zodSchema.unwrap() : zodSchema;\n };\n const paginationShape = paginationArgsSchema.shape as unknown as Record<string, z.ZodTypeAny>;\n const orderByShape = orderBySchema.shape as unknown as Record<string, z.ZodTypeAny>;\n\n const pageSchema = unwrapDefault(paginationShape.page);\n const perPageSchema = unwrapDefault(paginationShape.perPage);\n const fieldSchema = orderByShape.field ? unwrapDefault(orderByShape.field) : z.never().optional();\n const directionSchema = orderByShape.direction ? unwrapDefault(orderByShape.direction) : z.never().optional();\n\n return wrapSchemaForQueryParams(\n z\n .object({\n ...filterSchema.shape,\n page: pageSchema,\n perPage: perPageSchema,\n field: fieldSchema,\n direction: directionSchema,\n mode: listModeSchema.optional(),\n after: deltaCursorSchema.optional(),\n limit: deltaLimitSchema,\n })\n .partial(),\n ).superRefine((value, ctx) => {\n const isDelta = value.mode === 'delta';\n const hasPagination = value.page !== undefined || value.perPage !== undefined;\n const hasOrderBy = value.field !== undefined || value.direction !== undefined;\n const hasAfter = value.after !== undefined;\n const hasLimit = value.limit !== undefined;\n\n if (isDelta) {\n if (hasPagination) {\n if (value.page !== undefined) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['page'],\n message: '`page` is not allowed when `mode=delta`',\n });\n }\n if (value.perPage !== undefined) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['perPage'],\n message: '`perPage` is not allowed when `mode=delta`',\n });\n }\n }\n if (hasOrderBy) {\n if (value.field !== undefined) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['field'],\n message: '`field` is not allowed when `mode=delta`',\n });\n }\n if (value.direction !== undefined) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['direction'],\n message: '`direction` is not allowed when `mode=delta`',\n });\n }\n }\n return;\n }\n\n if (hasAfter) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['after'],\n message: '`after` is only allowed when `mode=delta`',\n });\n }\n if (hasLimit) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['limit'],\n message: '`limit` is only allowed when `mode=delta`',\n });\n }\n });\n}\n"],"mappings":";;;;;;;;;;AAqBA,MAAa,sCAAsC;AACnD,MAAa,8CACX;AACF,MAAM,4CAA4C;AAClD,MAAM,0DAA0D;AAChE,MAAM,sDAAsD;AAC5D,MAAM,6CAA6C;AACnD,MAAM,yDAAyD;AAC/D,MAAa,sDAAsD;AACnE,MAAa,yDACX;AAEF,SAAgB,kCAAkC;CAChD,OACEA,qBAAY,kCAAkC,KAAA,KAC9CA,qBAAY,sCAAsC,KAAA,KAClDA,qBAAY,kCAAkC,KAAA,KAC9CA,qBAAY,sCAAsC,KAAA,KAClD,OAAOA,qBAAY,iCAAiC,cACpD,OAAOA,qBAAY,yBAAyB,cAC5C,OAAOA,qBAAY,2CAA2C,cAC9D,OAAOA,qBAAY,iCAAiC;AAExD;AAEA,MAAa,+BAA+B;CAC1C,QAAQ;CACR,UAAU;CACV,MAAM;CACN,SAAS;CACT,QAA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;IACX,CAAC;GAEL;GACA;EACF;EAEA,IAAI,UACF,IAAI,SAAS;GACX,MAAMA,OAAAA,EAAE,aAAa;GACrB,MAAM,CAAC,OAAO;GACd,SAAS;EACX,CAAC;EAEH,IAAI,UACF,IAAI,SAAS;GACX,MAAMA,OAAAA,EAAE,aAAa;GACrB,MAAM,CAAC,OAAO;GACd,SAAS;EACX,CAAC;CAEL,CAAC;AACH"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Mastra } from '@mastra/core';
|
|
2
|
-
import type { MastraCompositeStore, ObservabilityStorage, ScoresStorage } from '@mastra/core/storage';
|
|
2
|
+
import type { MastraCompositeStore, ObservabilityStorage, ScoresStorage, TrustedThreadPredicate, TrustedTraceQueryPredicate } from '@mastra/core/storage';
|
|
3
3
|
import * as coreStorage from '@mastra/core/storage';
|
|
4
4
|
import { z } from 'zod/v4';
|
|
5
5
|
import type { ServerRoute } from '../server-adapter/routes/index.js';
|
|
@@ -24,6 +24,8 @@ export declare function getObservabilityStore(mastra: Mastra): Promise<Observabi
|
|
|
24
24
|
/** Retrieves the scores storage domain or throws 501 if unavailable. */
|
|
25
25
|
export declare function getScoresStore(mastra: Mastra): Promise<ScoresStorage>;
|
|
26
26
|
export declare function assertObservabilityTraceQuerySupported(observabilityStore: ObservabilityStorage): void;
|
|
27
|
+
export declare function supportsObservabilityTraceQueryRootDuration(observabilityStore: ObservabilityStorage): boolean;
|
|
28
|
+
export declare function assertObservabilityTraceQueryRootDurationSupported(observabilityStore: ObservabilityStorage, predicate: TrustedTraceQueryPredicate | TrustedThreadPredicate | undefined): void;
|
|
27
29
|
export declare function assertObservabilityTraceQueryDiscoverySupported(observabilityStore: ObservabilityStorage): void;
|
|
28
30
|
/**
|
|
29
31
|
* A scoped request must never run unscoped: a store that predates tenant scope would
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"observability-shared.d.ts","sourceRoot":"","sources":["../../../src/server/handlers/observability-shared.ts"],"names":[],"mappings":"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AAE,mBAAmB;iBAC5B,WAAW,EAAE,wDAAwD;;;iBAIrE,MAAM,EAAE,KAAK;iBACb,IAAI,EAAE,uCAAuC;iBAC7C,OAAO,EAAE,kBAAkB;iBAC3B,WAAW,EAAE,uDAAuD;;;iBAIpE,MAAM,EAAE,KAAK;iBACb,IAAI,EAAE,+BAA+B;iBACrC,OAAO,EAAE,UAAU;iBACnB,WAAW,EAAE,2DAA2D;;CAE3B,CAAC;AAElD,MAAM,MAAM,YAAY,GAAG,MAAM,OAAO,cAAc,CAAC;AACvD,MAAM,MAAM,oBAAoB,GAAG,CAAC,OAAO,cAAc,CAAC,CAAC,YAAY,CAAC,CAAC;AAEzE,wBAAgB,kCAAkC,CAChD,OAAO,SAAS,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,WAAW,CAAC,EAC1C,QAAQ,SAAS,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,WAAW,CAAC,EAC3C,YAAY,EAAE,OAAO,EAAE,aAAa,EAAE,QAAQ;;mBAoF/C"}
|
|
@@ -8,6 +8,7 @@ import { coreFeatures } from "@mastra/core/features";
|
|
|
8
8
|
const OBSERVABILITY_DELTA_POLLING_FEATURE = "observability-delta-polling";
|
|
9
9
|
const OBSERVABILITY_DELTA_POLLING_UPGRADE_MESSAGE = "Delta polling requires a newer @mastra/core with observability delta polling support. Please upgrade.";
|
|
10
10
|
const OBSERVABILITY_TRACE_QUERY_STORAGE_FEATURE = "trace-query";
|
|
11
|
+
const OBSERVABILITY_TRACE_QUERY_ROOT_DURATION_STORAGE_FEATURE = "trace-query-root-duration";
|
|
11
12
|
const OBSERVABILITY_TRACE_QUERY_DISCOVERY_STORAGE_FEATURE = "trace-query-discovery";
|
|
12
13
|
const OBSERVABILITY_THREAD_QUERY_STORAGE_FEATURE = "thread-query";
|
|
13
14
|
const OBSERVABILITY_TRACE_QUERY_TENANT_SCOPE_STORAGE_FEATURE = "trace-query-tenant-scope";
|
|
@@ -50,6 +51,20 @@ function assertObservabilityTraceQuerySupported(observabilityStore) {
|
|
|
50
51
|
if (getFeatures(observabilityStore)?.includes(OBSERVABILITY_TRACE_QUERY_STORAGE_FEATURE)) return;
|
|
51
52
|
throw new HTTPException(501, { message: "Advanced trace queries are not supported by the configured observability store" });
|
|
52
53
|
}
|
|
54
|
+
function usesRootDuration(predicate) {
|
|
55
|
+
if (!predicate) return false;
|
|
56
|
+
if (predicate.type === "boolean") return predicate.args.some(usesRootDuration);
|
|
57
|
+
if (predicate.type === "not") return usesRootDuration(predicate.arg);
|
|
58
|
+
if (predicate.type === "relation") return predicate.collection === "traces" && usesRootDuration(predicate.predicate);
|
|
59
|
+
return predicate.field === "durationMs";
|
|
60
|
+
}
|
|
61
|
+
function supportsObservabilityTraceQueryRootDuration(observabilityStore) {
|
|
62
|
+
return getFeatures(observabilityStore)?.includes(OBSERVABILITY_TRACE_QUERY_ROOT_DURATION_STORAGE_FEATURE) === true;
|
|
63
|
+
}
|
|
64
|
+
function assertObservabilityTraceQueryRootDurationSupported(observabilityStore, predicate) {
|
|
65
|
+
if (!usesRootDuration(predicate) || supportsObservabilityTraceQueryRootDuration(observabilityStore)) return;
|
|
66
|
+
throw new HTTPException(501, { message: "Root duration predicates are not supported by the configured observability store" });
|
|
67
|
+
}
|
|
53
68
|
function assertObservabilityTraceQueryDiscoverySupported(observabilityStore) {
|
|
54
69
|
if (getFeatures(observabilityStore)?.includes(OBSERVABILITY_TRACE_QUERY_DISCOVERY_STORAGE_FEATURE)) return;
|
|
55
70
|
throw new HTTPException(501, { message: "Trace query discovery is not supported by the configured observability store" });
|
|
@@ -364,6 +379,6 @@ function createObservabilityListQuerySchema(filterSchema, orderBySchema) {
|
|
|
364
379
|
});
|
|
365
380
|
}
|
|
366
381
|
//#endregion
|
|
367
|
-
export { NEW_ROUTE_DEFS, OBSERVABILITY_DELTA_POLLING_FEATURE, OBSERVABILITY_DELTA_POLLING_UPGRADE_MESSAGE, OBSERVABILITY_LIST_ENDPOINTS, OBSERVABILITY_TRACE_QUERY_TENANT_SCOPE_CORE_FEATURE, OBSERVABILITY_TRACE_QUERY_TENANT_SCOPE_UPGRADE_MESSAGE, assertObservabilityDeltaSupported, assertObservabilityThreadQuerySupported, assertObservabilityTraceQueryDiscoverySupported, assertObservabilityTraceQuerySupported, assertObservabilityTraceQueryTenantScopeSupported, createObservabilityListQuerySchema, getObservabilityStore, getScoresStore, getStorage, supportsTraceQueryDiscoveryCore };
|
|
382
|
+
export { NEW_ROUTE_DEFS, OBSERVABILITY_DELTA_POLLING_FEATURE, OBSERVABILITY_DELTA_POLLING_UPGRADE_MESSAGE, OBSERVABILITY_LIST_ENDPOINTS, OBSERVABILITY_TRACE_QUERY_TENANT_SCOPE_CORE_FEATURE, OBSERVABILITY_TRACE_QUERY_TENANT_SCOPE_UPGRADE_MESSAGE, assertObservabilityDeltaSupported, assertObservabilityThreadQuerySupported, assertObservabilityTraceQueryDiscoverySupported, assertObservabilityTraceQueryRootDurationSupported, assertObservabilityTraceQuerySupported, assertObservabilityTraceQueryTenantScopeSupported, createObservabilityListQuerySchema, getObservabilityStore, getScoresStore, getStorage, supportsObservabilityTraceQueryRootDuration, supportsTraceQueryDiscoveryCore };
|
|
368
383
|
|
|
369
384
|
//# sourceMappingURL=observability-shared.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"observability-shared.js","names":["candidate"],"sources":["../../../src/server/handlers/observability-shared.ts"],"sourcesContent":["import type { Mastra } from '@mastra/core';\nimport { coreFeatures } from '@mastra/core/features';\nimport type { MastraCompositeStore, ObservabilityStorage, ScoresStorage } from '@mastra/core/storage';\nimport * as coreStorage from '@mastra/core/storage';\nimport { z } from 'zod/v4';\nimport { HTTPException } from '../http-exception';\nimport type { ServerRoute } from '../server-adapter/routes';\nimport { wrapSchemaForQueryParams } from '../server-adapter/routes/route-builder';\nimport {\n deltaCursorSchema,\n deltaLimitSchema,\n listModeSchema,\n paginationArgsSchema,\n} from './observability-list-query-schemas';\n\nexport const OBSERVABILITY_DELTA_POLLING_FEATURE = 'observability-delta-polling';\nexport const OBSERVABILITY_DELTA_POLLING_UPGRADE_MESSAGE =\n 'Delta polling requires a newer @mastra/core with observability delta polling support. Please upgrade.';\nconst OBSERVABILITY_TRACE_QUERY_STORAGE_FEATURE = 'trace-query';\nconst OBSERVABILITY_TRACE_QUERY_DISCOVERY_STORAGE_FEATURE = 'trace-query-discovery';\nconst OBSERVABILITY_THREAD_QUERY_STORAGE_FEATURE = 'thread-query';\nconst OBSERVABILITY_TRACE_QUERY_TENANT_SCOPE_STORAGE_FEATURE = 'trace-query-tenant-scope';\nexport const OBSERVABILITY_TRACE_QUERY_TENANT_SCOPE_CORE_FEATURE = 'observability-trace-query-tenant-scope';\nexport const OBSERVABILITY_TRACE_QUERY_TENANT_SCOPE_UPGRADE_MESSAGE =\n 'Trusted tenant scope requires a newer @mastra/core with trace-query tenant scope support. Please upgrade.';\n\nexport function supportsTraceQueryDiscoveryCore() {\n return (\n coreStorage.getTraceQueryFieldsArgsSchema !== undefined &&\n coreStorage.getTraceQueryFieldsResponseSchema !== undefined &&\n coreStorage.getTraceQueryValuesArgsSchema !== undefined &&\n coreStorage.getTraceQueryValuesResponseSchema !== undefined &&\n typeof coreStorage.planTraceQueryObservedFields === 'function' &&\n typeof coreStorage.planTraceQueryValues === 'function' &&\n typeof coreStorage.getTraceQueryCanonicalFieldDescriptors === 'function' &&\n typeof coreStorage.TraceQueryResourceLimitError === 'function'\n );\n}\n\nexport const OBSERVABILITY_LIST_ENDPOINTS = {\n traces: 'traces',\n branches: 'branches',\n logs: 'logs',\n metrics: 'metrics',\n scores: 'scores',\n feedback: 'feedback',\n} as const;\n\nexport type ObservabilityListEndpoint =\n (typeof OBSERVABILITY_LIST_ENDPOINTS)[keyof typeof OBSERVABILITY_LIST_ENDPOINTS];\nconst OBSERVABILITY_DELTA_POLLING_STORAGE_FEATURE = 'delta-polling';\n\nfunction getFeatures(observabilityStore: ObservabilityStorage): readonly string[] | undefined {\n const candidate = observabilityStore as ObservabilityStorage & {\n getFeatures?: () => readonly string[] | undefined;\n };\n return candidate.getFeatures?.();\n}\n\n/** Retrieves MastraCompositeStore or throws 500 if unavailable. */\nexport function getStorage(mastra: Mastra): MastraCompositeStore {\n const storage = mastra.getStorage();\n if (!storage) {\n throw new HTTPException(500, { message: 'Storage is not available' });\n }\n return storage;\n}\n\n/** Retrieves the observability storage domain or throws 501 if unavailable. */\nexport async function getObservabilityStore(mastra: Mastra): Promise<ObservabilityStorage> {\n const storage = getStorage(mastra);\n const observability = await storage.getStore('observability');\n if (!observability) {\n // 501, not 500: a missing or explicitly disabled observability domain\n // (e.g. `domains: { observability: false }`) is a capability gap, not a\n // server failure — matching the other 501s in this file.\n throw new HTTPException(501, { message: 'Observability storage domain is not available' });\n }\n return observability;\n}\n\n/** Retrieves the scores storage domain or throws 501 if unavailable. */\nexport async function getScoresStore(mastra: Mastra): Promise<ScoresStorage> {\n const storage = getStorage(mastra);\n const scores = await storage.getStore('scores');\n if (!scores) {\n throw new HTTPException(501, { message: 'Scores storage domain is not available' });\n }\n return scores;\n}\n\nexport function assertObservabilityTraceQuerySupported(observabilityStore: ObservabilityStorage) {\n if (getFeatures(observabilityStore)?.includes(OBSERVABILITY_TRACE_QUERY_STORAGE_FEATURE)) return;\n\n throw new HTTPException(501, {\n message: 'Advanced trace queries are not supported by the configured observability store',\n });\n}\n\nexport function assertObservabilityTraceQueryDiscoverySupported(observabilityStore: ObservabilityStorage) {\n if (getFeatures(observabilityStore)?.includes(OBSERVABILITY_TRACE_QUERY_DISCOVERY_STORAGE_FEATURE)) return;\n\n throw new HTTPException(501, {\n message: 'Trace query discovery is not supported by the configured observability store',\n });\n}\n\n/**\n * A scoped request must never run unscoped: a store that predates tenant scope would\n * silently ignore `plan.scope` and return every tenant's rows, so it is rejected instead.\n * Unscoped requests are unaffected.\n */\nexport function assertObservabilityTraceQueryTenantScopeSupported(\n observabilityStore: ObservabilityStorage,\n scope: coreStorage.TraceQueryTenantScope | undefined,\n) {\n if (scope === undefined) return;\n if (getFeatures(observabilityStore)?.includes(OBSERVABILITY_TRACE_QUERY_TENANT_SCOPE_STORAGE_FEATURE)) return;\n\n throw new HTTPException(501, {\n message: 'The configured observability store cannot enforce the trusted tenant scope',\n });\n}\n\nexport function assertObservabilityThreadQuerySupported(observabilityStore: ObservabilityStorage) {\n if (getFeatures(observabilityStore)?.includes(OBSERVABILITY_THREAD_QUERY_STORAGE_FEATURE)) return;\n\n throw new HTTPException(501, {\n message: 'Advanced thread queries are not supported by the configured observability store',\n });\n}\n\nexport function assertObservabilityDeltaSupported(\n observabilityStore: ObservabilityStorage,\n endpoint: ObservabilityListEndpoint,\n) {\n if (!coreFeatures.has(OBSERVABILITY_DELTA_POLLING_FEATURE)) {\n throw new HTTPException(501, {\n message: `${OBSERVABILITY_DELTA_POLLING_UPGRADE_MESSAGE} (endpoint: ${endpoint})`,\n });\n }\n\n if (getFeatures(observabilityStore)?.includes(OBSERVABILITY_DELTA_POLLING_STORAGE_FEATURE)) {\n return;\n }\n\n throw new HTTPException(501, {\n message: `Delta polling is not supported by the configured observability store for ${endpoint}`,\n });\n}\n\nexport interface RouteDetails {\n method: ServerRoute['method'];\n path: `/${string}`;\n summary: string;\n description: string;\n requiresPermission?: ServerRoute['requiresPermission'];\n}\n\nexport const NEW_ROUTE_DEFS = {\n QUERY_TRACES: {\n method: 'POST',\n path: '/observability/traces/query',\n summary: 'Query traces',\n description:\n 'Returns completed logical traces or distinct thread groups matching an advanced trace query. Thread grouping remains supported but is deprecated; use queryTraceThreads instead.',\n requiresPermission: 'observability:read',\n },\n\n QUERY_THREADS: {\n method: 'POST',\n path: '/observability/threads/query',\n summary: 'Query threads',\n description: 'Returns thread identities matching eligible trace and cross-trace predicates',\n requiresPermission: 'observability:read',\n },\n\n GET_TRACE_QUERY_FIELDS: {\n method: 'POST',\n path: '/observability/traces/query/fields',\n summary: 'Discover trace query fields',\n description: 'Returns canonical query fields and observed top-level string metadata fields',\n requiresPermission: 'observability:read',\n },\n\n GET_TRACE_QUERY_VALUES: {\n method: 'POST',\n path: '/observability/traces/query/values',\n summary: 'Discover trace query values',\n description: 'Returns bounded string value suggestions and occurrence counts for one eligible query field',\n requiresPermission: 'observability:read',\n },\n\n LIST_METRICS: {\n method: 'GET',\n path: '/observability/metrics',\n summary: 'List metrics',\n description: 'Returns a paginated list of metrics with optional filtering and sorting',\n },\n\n LIST_LOGS: {\n method: 'GET',\n path: '/observability/logs',\n summary: 'List logs',\n description: 'Returns a paginated list of logs with optional filtering and sorting',\n },\n\n LIST_SCORES: {\n method: 'GET',\n path: '/observability/scores',\n summary: 'List scores',\n description: 'Returns a paginated list of scores with optional filtering and sorting',\n },\n\n CREATE_SCORE: {\n method: 'POST',\n path: '/observability/scores',\n summary: 'Create a score',\n description: 'Creates a single score record in the observability store',\n },\n\n DELETE_SCORES: {\n method: 'DELETE',\n path: '/observability/scores',\n summary: 'Delete scores',\n description: 'Deletes score records by scoreId, optionally scoped to a tenant',\n requiresPermission: 'observability:delete',\n },\n\n GET_SCORE: {\n method: 'GET',\n path: '/observability/scores/:scoreId',\n summary: 'Get score',\n description: 'Returns a single score by scoreId',\n },\n\n GET_SCORE_AGGREGATE: {\n method: 'POST',\n path: '/observability/scores/aggregate',\n summary: 'Get score aggregate',\n description: 'Returns an aggregated score value with optional period-over-period comparison',\n requiresPermission: 'observability:read',\n },\n\n GET_SCORE_BREAKDOWN: {\n method: 'POST',\n path: '/observability/scores/breakdown',\n summary: 'Get score breakdown',\n description: 'Returns score values grouped by specified dimensions',\n requiresPermission: 'observability:read',\n },\n\n GET_SCORE_TIME_SERIES: {\n method: 'POST',\n path: '/observability/scores/timeseries',\n summary: 'Get score time series',\n description: 'Returns score values bucketed by time interval with optional grouping',\n requiresPermission: 'observability:read',\n },\n\n GET_SCORE_PERCENTILES: {\n method: 'POST',\n path: '/observability/scores/percentiles',\n summary: 'Get score percentiles',\n description: 'Returns percentile values for a score bucketed by time interval',\n requiresPermission: 'observability:read',\n },\n\n LIST_FEEDBACK: {\n method: 'GET',\n path: '/observability/feedback',\n summary: 'List feedback',\n description: 'Returns a paginated list of feedback with optional filtering and sorting',\n },\n\n CREATE_FEEDBACK: {\n method: 'POST',\n path: '/observability/feedback',\n summary: 'Create feedback',\n description: 'Creates a single feedback record in the observability store',\n },\n\n DELETE_FEEDBACK: {\n method: 'DELETE',\n path: '/observability/feedback',\n summary: 'Delete feedback',\n description: 'Deletes feedback records by feedbackId, optionally scoped to a tenant',\n requiresPermission: 'observability:delete',\n },\n\n UPDATE_FEEDBACK_REVIEW_STATUS: {\n method: 'PATCH',\n path: '/observability/feedback/:feedbackId/review-status',\n summary: 'Update feedback review status',\n description: \"Updates a feedback record's review workflow status\",\n requiresPermission: 'observability:write',\n },\n\n GET_FEEDBACK_AGGREGATE: {\n method: 'POST',\n path: '/observability/feedback/aggregate',\n summary: 'Get feedback aggregate',\n description: 'Returns an aggregated numeric feedback value with optional period-over-period comparison',\n requiresPermission: 'observability:read',\n },\n\n GET_FEEDBACK_BREAKDOWN: {\n method: 'POST',\n path: '/observability/feedback/breakdown',\n summary: 'Get feedback breakdown',\n description: 'Returns numeric feedback values grouped by specified dimensions',\n requiresPermission: 'observability:read',\n },\n\n GET_FEEDBACK_TIME_SERIES: {\n method: 'POST',\n path: '/observability/feedback/timeseries',\n summary: 'Get feedback time series',\n description: 'Returns numeric feedback values bucketed by time interval with optional grouping',\n requiresPermission: 'observability:read',\n },\n\n GET_FEEDBACK_PERCENTILES: {\n method: 'POST',\n path: '/observability/feedback/percentiles',\n summary: 'Get feedback percentiles',\n description: 'Returns percentile values for numeric feedback bucketed by time interval',\n requiresPermission: 'observability:read',\n },\n\n GET_METRIC_AGGREGATE: {\n method: 'POST',\n path: '/observability/metrics/aggregate',\n summary: 'Get metric aggregate',\n description: 'Returns an aggregated metric value with optional period-over-period comparison',\n requiresPermission: 'observability:read',\n },\n\n GET_METRIC_BREAKDOWN: {\n method: 'POST',\n path: '/observability/metrics/breakdown',\n summary: 'Get metric breakdown',\n description: 'Returns metric values grouped by specified dimensions',\n requiresPermission: 'observability:read',\n },\n\n GET_METRIC_TIME_SERIES: {\n method: 'POST',\n path: '/observability/metrics/timeseries',\n summary: 'Get metric time series',\n description: 'Returns metric values bucketed by time interval with optional grouping',\n requiresPermission: 'observability:read',\n },\n\n GET_METRIC_PERCENTILES: {\n method: 'POST',\n path: '/observability/metrics/percentiles',\n summary: 'Get metric percentiles',\n description: 'Returns percentile values for a metric bucketed by time interval',\n requiresPermission: 'observability:read',\n },\n\n GET_METRIC_NAMES: {\n method: 'GET',\n path: '/observability/discovery/metric-names',\n summary: 'Get metric names',\n description: 'Returns distinct metric names with optional prefix filtering',\n },\n\n GET_METRIC_LABEL_KEYS: {\n method: 'GET',\n path: '/observability/discovery/metric-label-keys',\n summary: 'Get metric label keys',\n description: 'Returns distinct label keys for a given metric',\n },\n\n GET_METRIC_LABEL_VALUES: {\n method: 'GET',\n path: '/observability/discovery/metric-label-values',\n summary: 'Get label values',\n description: 'Returns distinct values for a given metric label key',\n },\n\n GET_ENTITY_TYPES: {\n method: 'GET',\n path: '/observability/discovery/entity-types',\n summary: 'Get entity types',\n description: 'Returns distinct entity types from observability data',\n },\n\n GET_ENTITY_NAMES: {\n method: 'GET',\n path: '/observability/discovery/entity-names',\n summary: 'Get entity names',\n description: 'Returns distinct entity names with optional type filtering',\n },\n\n GET_SERVICE_NAMES: {\n method: 'GET',\n path: '/observability/discovery/service-names',\n summary: 'Get service names',\n description: 'Returns distinct service names from observability data',\n },\n\n GET_ENVIRONMENTS: {\n method: 'GET',\n path: '/observability/discovery/environments',\n summary: 'Get environments',\n description: 'Returns distinct environments from observability data',\n },\n\n GET_TAGS: {\n method: 'GET',\n path: '/observability/discovery/tags',\n summary: 'Get tags',\n description: 'Returns distinct tags with optional entity type filtering',\n },\n} as const satisfies Record<string, RouteDetails>;\n\nexport type NewRoutesKey = keyof typeof NEW_ROUTE_DEFS;\nexport type NewRoutesDefinitions = (typeof NEW_ROUTE_DEFS)[NewRoutesKey];\n\nexport function createObservabilityListQuerySchema<\n TFilter extends z.ZodObject<z.ZodRawShape>,\n TOrderBy extends z.ZodObject<z.ZodRawShape>,\n>(filterSchema: TFilter, orderBySchema: TOrderBy) {\n const unwrapDefault = (schema: unknown) => {\n const zodSchema = schema as z.ZodTypeAny;\n return zodSchema instanceof z.ZodDefault ? zodSchema.unwrap() : zodSchema;\n };\n const paginationShape = paginationArgsSchema.shape as unknown as Record<string, z.ZodTypeAny>;\n const orderByShape = orderBySchema.shape as unknown as Record<string, z.ZodTypeAny>;\n\n const pageSchema = unwrapDefault(paginationShape.page);\n const perPageSchema = unwrapDefault(paginationShape.perPage);\n const fieldSchema = orderByShape.field ? unwrapDefault(orderByShape.field) : z.never().optional();\n const directionSchema = orderByShape.direction ? unwrapDefault(orderByShape.direction) : z.never().optional();\n\n return wrapSchemaForQueryParams(\n z\n .object({\n ...filterSchema.shape,\n page: pageSchema,\n perPage: perPageSchema,\n field: fieldSchema,\n direction: directionSchema,\n mode: listModeSchema.optional(),\n after: deltaCursorSchema.optional(),\n limit: deltaLimitSchema,\n })\n .partial(),\n ).superRefine((value, ctx) => {\n const isDelta = value.mode === 'delta';\n const hasPagination = value.page !== undefined || value.perPage !== undefined;\n const hasOrderBy = value.field !== undefined || value.direction !== undefined;\n const hasAfter = value.after !== undefined;\n const hasLimit = value.limit !== undefined;\n\n if (isDelta) {\n if (hasPagination) {\n if (value.page !== undefined) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['page'],\n message: '`page` is not allowed when `mode=delta`',\n });\n }\n if (value.perPage !== undefined) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['perPage'],\n message: '`perPage` is not allowed when `mode=delta`',\n });\n }\n }\n if (hasOrderBy) {\n if (value.field !== undefined) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['field'],\n message: '`field` is not allowed when `mode=delta`',\n });\n }\n if (value.direction !== undefined) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['direction'],\n message: '`direction` is not allowed when `mode=delta`',\n });\n }\n }\n return;\n }\n\n if (hasAfter) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['after'],\n message: '`after` is only allowed when `mode=delta`',\n });\n }\n if (hasLimit) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['limit'],\n message: '`limit` is only allowed when `mode=delta`',\n });\n }\n });\n}\n"],"mappings":";;;;;;;AAeA,MAAa,sCAAsC;AACnD,MAAa,8CACX;AACF,MAAM,4CAA4C;AAClD,MAAM,sDAAsD;AAC5D,MAAM,6CAA6C;AACnD,MAAM,yDAAyD;AAC/D,MAAa,sDAAsD;AACnE,MAAa,yDACX;AAEF,SAAgB,kCAAkC;CAChD,OACE,YAAY,kCAAkC,KAAA,KAC9C,YAAY,sCAAsC,KAAA,KAClD,YAAY,kCAAkC,KAAA,KAC9C,YAAY,sCAAsC,KAAA,KAClD,OAAO,YAAY,iCAAiC,cACpD,OAAO,YAAY,yBAAyB,cAC5C,OAAO,YAAY,2CAA2C,cAC9D,OAAO,YAAY,iCAAiC;AAExD;AAEA,MAAa,+BAA+B;CAC1C,QAAQ;CACR,UAAU;CACV,MAAM;CACN,SAAS;CACT,QAAQ;CACR,UAAU;AACZ;AAIA,MAAM,8CAA8C;AAEpD,SAAS,YAAY,oBAAyE;CAI5F,OAAOA,mBAAU,cAAc;AACjC;;AAGA,SAAgB,WAAW,QAAsC;CAC/D,MAAM,UAAU,OAAO,WAAW;CAClC,IAAI,CAAC,SACH,MAAM,IAAI,cAAc,KAAK,EAAE,SAAS,2BAA2B,CAAC;CAEtE,OAAO;AACT;;AAGA,eAAsB,sBAAsB,QAA+C;CAEzF,MAAM,gBAAgB,MADN,WAAW,MACO,CAAC,CAAC,SAAS,eAAe;CAC5D,IAAI,CAAC,eAIH,MAAM,IAAI,cAAc,KAAK,EAAE,SAAS,gDAAgD,CAAC;CAE3F,OAAO;AACT;;AAGA,eAAsB,eAA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MAAM,CAAC,WAAW;KAClB,SAAS;IACX,CAAC;GAEL;GACA;EACF;EAEA,IAAI,UACF,IAAI,SAAS;GACX,MAAM,EAAE,aAAa;GACrB,MAAM,CAAC,OAAO;GACd,SAAS;EACX,CAAC;EAEH,IAAI,UACF,IAAI,SAAS;GACX,MAAM,EAAE,aAAa;GACrB,MAAM,CAAC,OAAO;GACd,SAAS;EACX,CAAC;CAEL,CAAC;AACH"}
|
|
1
|
+
{"version":3,"file":"observability-shared.js","names":["candidate"],"sources":["../../../src/server/handlers/observability-shared.ts"],"sourcesContent":["import type { Mastra } from '@mastra/core';\nimport { coreFeatures } from '@mastra/core/features';\nimport type {\n MastraCompositeStore,\n ObservabilityStorage,\n ScoresStorage,\n TrustedThreadPredicate,\n TrustedTraceQueryPredicate,\n} from '@mastra/core/storage';\nimport * as coreStorage from '@mastra/core/storage';\nimport { z } from 'zod/v4';\nimport { HTTPException } from '../http-exception';\nimport type { ServerRoute } from '../server-adapter/routes';\nimport { wrapSchemaForQueryParams } from '../server-adapter/routes/route-builder';\nimport {\n deltaCursorSchema,\n deltaLimitSchema,\n listModeSchema,\n paginationArgsSchema,\n} from './observability-list-query-schemas';\n\nexport const OBSERVABILITY_DELTA_POLLING_FEATURE = 'observability-delta-polling';\nexport const OBSERVABILITY_DELTA_POLLING_UPGRADE_MESSAGE =\n 'Delta polling requires a newer @mastra/core with observability delta polling support. Please upgrade.';\nconst OBSERVABILITY_TRACE_QUERY_STORAGE_FEATURE = 'trace-query';\nconst OBSERVABILITY_TRACE_QUERY_ROOT_DURATION_STORAGE_FEATURE = 'trace-query-root-duration';\nconst OBSERVABILITY_TRACE_QUERY_DISCOVERY_STORAGE_FEATURE = 'trace-query-discovery';\nconst OBSERVABILITY_THREAD_QUERY_STORAGE_FEATURE = 'thread-query';\nconst OBSERVABILITY_TRACE_QUERY_TENANT_SCOPE_STORAGE_FEATURE = 'trace-query-tenant-scope';\nexport const OBSERVABILITY_TRACE_QUERY_TENANT_SCOPE_CORE_FEATURE = 'observability-trace-query-tenant-scope';\nexport const OBSERVABILITY_TRACE_QUERY_TENANT_SCOPE_UPGRADE_MESSAGE =\n 'Trusted tenant scope requires a newer @mastra/core with trace-query tenant scope support. Please upgrade.';\n\nexport function supportsTraceQueryDiscoveryCore() {\n return (\n coreStorage.getTraceQueryFieldsArgsSchema !== undefined &&\n coreStorage.getTraceQueryFieldsResponseSchema !== undefined &&\n coreStorage.getTraceQueryValuesArgsSchema !== undefined &&\n coreStorage.getTraceQueryValuesResponseSchema !== undefined &&\n typeof coreStorage.planTraceQueryObservedFields === 'function' &&\n typeof coreStorage.planTraceQueryValues === 'function' &&\n typeof coreStorage.getTraceQueryCanonicalFieldDescriptors === 'function' &&\n typeof coreStorage.TraceQueryResourceLimitError === 'function'\n );\n}\n\nexport const OBSERVABILITY_LIST_ENDPOINTS = {\n traces: 'traces',\n branches: 'branches',\n logs: 'logs',\n metrics: 'metrics',\n scores: 'scores',\n feedback: 'feedback',\n} as const;\n\nexport type ObservabilityListEndpoint =\n (typeof OBSERVABILITY_LIST_ENDPOINTS)[keyof typeof OBSERVABILITY_LIST_ENDPOINTS];\nconst OBSERVABILITY_DELTA_POLLING_STORAGE_FEATURE = 'delta-polling';\n\nfunction getFeatures(observabilityStore: ObservabilityStorage): readonly string[] | undefined {\n const candidate = observabilityStore as ObservabilityStorage & {\n getFeatures?: () => readonly string[] | undefined;\n };\n return candidate.getFeatures?.();\n}\n\n/** Retrieves MastraCompositeStore or throws 500 if unavailable. */\nexport function getStorage(mastra: Mastra): MastraCompositeStore {\n const storage = mastra.getStorage();\n if (!storage) {\n throw new HTTPException(500, { message: 'Storage is not available' });\n }\n return storage;\n}\n\n/** Retrieves the observability storage domain or throws 501 if unavailable. */\nexport async function getObservabilityStore(mastra: Mastra): Promise<ObservabilityStorage> {\n const storage = getStorage(mastra);\n const observability = await storage.getStore('observability');\n if (!observability) {\n // 501, not 500: a missing or explicitly disabled observability domain\n // (e.g. `domains: { observability: false }`) is a capability gap, not a\n // server failure — matching the other 501s in this file.\n throw new HTTPException(501, { message: 'Observability storage domain is not available' });\n }\n return observability;\n}\n\n/** Retrieves the scores storage domain or throws 501 if unavailable. */\nexport async function getScoresStore(mastra: Mastra): Promise<ScoresStorage> {\n const storage = getStorage(mastra);\n const scores = await storage.getStore('scores');\n if (!scores) {\n throw new HTTPException(501, { message: 'Scores storage domain is not available' });\n }\n return scores;\n}\n\nexport function assertObservabilityTraceQuerySupported(observabilityStore: ObservabilityStorage) {\n if (getFeatures(observabilityStore)?.includes(OBSERVABILITY_TRACE_QUERY_STORAGE_FEATURE)) return;\n\n throw new HTTPException(501, {\n message: 'Advanced trace queries are not supported by the configured observability store',\n });\n}\n\nfunction usesRootDuration(predicate: TrustedTraceQueryPredicate | TrustedThreadPredicate | undefined): boolean {\n if (!predicate) return false;\n if (predicate.type === 'boolean') return predicate.args.some(usesRootDuration);\n if (predicate.type === 'not') return usesRootDuration(predicate.arg);\n if (predicate.type === 'relation') {\n return predicate.collection === 'traces' && usesRootDuration(predicate.predicate);\n }\n return predicate.field === 'durationMs';\n}\n\nexport function supportsObservabilityTraceQueryRootDuration(observabilityStore: ObservabilityStorage) {\n return getFeatures(observabilityStore)?.includes(OBSERVABILITY_TRACE_QUERY_ROOT_DURATION_STORAGE_FEATURE) === true;\n}\n\nexport function assertObservabilityTraceQueryRootDurationSupported(\n observabilityStore: ObservabilityStorage,\n predicate: TrustedTraceQueryPredicate | TrustedThreadPredicate | undefined,\n) {\n if (!usesRootDuration(predicate) || supportsObservabilityTraceQueryRootDuration(observabilityStore)) return;\n\n throw new HTTPException(501, {\n message: 'Root duration predicates are not supported by the configured observability store',\n });\n}\n\nexport function assertObservabilityTraceQueryDiscoverySupported(observabilityStore: ObservabilityStorage) {\n if (getFeatures(observabilityStore)?.includes(OBSERVABILITY_TRACE_QUERY_DISCOVERY_STORAGE_FEATURE)) return;\n\n throw new HTTPException(501, {\n message: 'Trace query discovery is not supported by the configured observability store',\n });\n}\n\n/**\n * A scoped request must never run unscoped: a store that predates tenant scope would\n * silently ignore `plan.scope` and return every tenant's rows, so it is rejected instead.\n * Unscoped requests are unaffected.\n */\nexport function assertObservabilityTraceQueryTenantScopeSupported(\n observabilityStore: ObservabilityStorage,\n scope: coreStorage.TraceQueryTenantScope | undefined,\n) {\n if (scope === undefined) return;\n if (getFeatures(observabilityStore)?.includes(OBSERVABILITY_TRACE_QUERY_TENANT_SCOPE_STORAGE_FEATURE)) return;\n\n throw new HTTPException(501, {\n message: 'The configured observability store cannot enforce the trusted tenant scope',\n });\n}\n\nexport function assertObservabilityThreadQuerySupported(observabilityStore: ObservabilityStorage) {\n if (getFeatures(observabilityStore)?.includes(OBSERVABILITY_THREAD_QUERY_STORAGE_FEATURE)) return;\n\n throw new HTTPException(501, {\n message: 'Advanced thread queries are not supported by the configured observability store',\n });\n}\n\nexport function assertObservabilityDeltaSupported(\n observabilityStore: ObservabilityStorage,\n endpoint: ObservabilityListEndpoint,\n) {\n if (!coreFeatures.has(OBSERVABILITY_DELTA_POLLING_FEATURE)) {\n throw new HTTPException(501, {\n message: `${OBSERVABILITY_DELTA_POLLING_UPGRADE_MESSAGE} (endpoint: ${endpoint})`,\n });\n }\n\n if (getFeatures(observabilityStore)?.includes(OBSERVABILITY_DELTA_POLLING_STORAGE_FEATURE)) {\n return;\n }\n\n throw new HTTPException(501, {\n message: `Delta polling is not supported by the configured observability store for ${endpoint}`,\n });\n}\n\nexport interface RouteDetails {\n method: ServerRoute['method'];\n path: `/${string}`;\n summary: string;\n description: string;\n requiresPermission?: ServerRoute['requiresPermission'];\n}\n\nexport const NEW_ROUTE_DEFS = {\n QUERY_TRACES: {\n method: 'POST',\n path: '/observability/traces/query',\n summary: 'Query traces',\n description:\n 'Returns completed logical traces or distinct thread groups matching an advanced trace query. Thread grouping remains supported but is deprecated; use queryTraceThreads instead.',\n requiresPermission: 'observability:read',\n },\n\n QUERY_THREADS: {\n method: 'POST',\n path: '/observability/threads/query',\n summary: 'Query threads',\n description: 'Returns thread identities matching eligible trace and cross-trace predicates',\n requiresPermission: 'observability:read',\n },\n\n GET_TRACE_QUERY_FIELDS: {\n method: 'POST',\n path: '/observability/traces/query/fields',\n summary: 'Discover trace query fields',\n description: 'Returns canonical query fields and observed top-level string metadata fields',\n requiresPermission: 'observability:read',\n },\n\n GET_TRACE_QUERY_VALUES: {\n method: 'POST',\n path: '/observability/traces/query/values',\n summary: 'Discover trace query values',\n description: 'Returns bounded string value suggestions and occurrence counts for one eligible query field',\n requiresPermission: 'observability:read',\n },\n\n LIST_METRICS: {\n method: 'GET',\n path: '/observability/metrics',\n summary: 'List metrics',\n description: 'Returns a paginated list of metrics with optional filtering and sorting',\n },\n\n LIST_LOGS: {\n method: 'GET',\n path: '/observability/logs',\n summary: 'List logs',\n description: 'Returns a paginated list of logs with optional filtering and sorting',\n },\n\n LIST_SCORES: {\n method: 'GET',\n path: '/observability/scores',\n summary: 'List scores',\n description: 'Returns a paginated list of scores with optional filtering and sorting',\n },\n\n CREATE_SCORE: {\n method: 'POST',\n path: '/observability/scores',\n summary: 'Create a score',\n description: 'Creates a single score record in the observability store',\n },\n\n DELETE_SCORES: {\n method: 'DELETE',\n path: '/observability/scores',\n summary: 'Delete scores',\n description: 'Deletes score records by scoreId, optionally scoped to a tenant',\n requiresPermission: 'observability:delete',\n },\n\n GET_SCORE: {\n method: 'GET',\n path: '/observability/scores/:scoreId',\n summary: 'Get score',\n description: 'Returns a single score by scoreId',\n },\n\n GET_SCORE_AGGREGATE: {\n method: 'POST',\n path: '/observability/scores/aggregate',\n summary: 'Get score aggregate',\n description: 'Returns an aggregated score value with optional period-over-period comparison',\n requiresPermission: 'observability:read',\n },\n\n GET_SCORE_BREAKDOWN: {\n method: 'POST',\n path: '/observability/scores/breakdown',\n summary: 'Get score breakdown',\n description: 'Returns score values grouped by specified dimensions',\n requiresPermission: 'observability:read',\n },\n\n GET_SCORE_TIME_SERIES: {\n method: 'POST',\n path: '/observability/scores/timeseries',\n summary: 'Get score time series',\n description: 'Returns score values bucketed by time interval with optional grouping',\n requiresPermission: 'observability:read',\n },\n\n GET_SCORE_PERCENTILES: {\n method: 'POST',\n path: '/observability/scores/percentiles',\n summary: 'Get score percentiles',\n description: 'Returns percentile values for a score bucketed by time interval',\n requiresPermission: 'observability:read',\n },\n\n LIST_FEEDBACK: {\n method: 'GET',\n path: '/observability/feedback',\n summary: 'List feedback',\n description: 'Returns a paginated list of feedback with optional filtering and sorting',\n },\n\n CREATE_FEEDBACK: {\n method: 'POST',\n path: '/observability/feedback',\n summary: 'Create feedback',\n description: 'Creates a single feedback record in the observability store',\n },\n\n DELETE_FEEDBACK: {\n method: 'DELETE',\n path: '/observability/feedback',\n summary: 'Delete feedback',\n description: 'Deletes feedback records by feedbackId, optionally scoped to a tenant',\n requiresPermission: 'observability:delete',\n },\n\n UPDATE_FEEDBACK_REVIEW_STATUS: {\n method: 'PATCH',\n path: '/observability/feedback/:feedbackId/review-status',\n summary: 'Update feedback review status',\n description: \"Updates a feedback record's review workflow status\",\n requiresPermission: 'observability:write',\n },\n\n GET_FEEDBACK_AGGREGATE: {\n method: 'POST',\n path: '/observability/feedback/aggregate',\n summary: 'Get feedback aggregate',\n description: 'Returns an aggregated numeric feedback value with optional period-over-period comparison',\n requiresPermission: 'observability:read',\n },\n\n GET_FEEDBACK_BREAKDOWN: {\n method: 'POST',\n path: '/observability/feedback/breakdown',\n summary: 'Get feedback breakdown',\n description: 'Returns numeric feedback values grouped by specified dimensions',\n requiresPermission: 'observability:read',\n },\n\n GET_FEEDBACK_TIME_SERIES: {\n method: 'POST',\n path: '/observability/feedback/timeseries',\n summary: 'Get feedback time series',\n description: 'Returns numeric feedback values bucketed by time interval with optional grouping',\n requiresPermission: 'observability:read',\n },\n\n GET_FEEDBACK_PERCENTILES: {\n method: 'POST',\n path: '/observability/feedback/percentiles',\n summary: 'Get feedback percentiles',\n description: 'Returns percentile values for numeric feedback bucketed by time interval',\n requiresPermission: 'observability:read',\n },\n\n GET_METRIC_AGGREGATE: {\n method: 'POST',\n path: '/observability/metrics/aggregate',\n summary: 'Get metric aggregate',\n description: 'Returns an aggregated metric value with optional period-over-period comparison',\n requiresPermission: 'observability:read',\n },\n\n GET_METRIC_BREAKDOWN: {\n method: 'POST',\n path: '/observability/metrics/breakdown',\n summary: 'Get metric breakdown',\n description: 'Returns metric values grouped by specified dimensions',\n requiresPermission: 'observability:read',\n },\n\n GET_METRIC_TIME_SERIES: {\n method: 'POST',\n path: '/observability/metrics/timeseries',\n summary: 'Get metric time series',\n description: 'Returns metric values bucketed by time interval with optional grouping',\n requiresPermission: 'observability:read',\n },\n\n GET_METRIC_PERCENTILES: {\n method: 'POST',\n path: '/observability/metrics/percentiles',\n summary: 'Get metric percentiles',\n description: 'Returns percentile values for a metric bucketed by time interval',\n requiresPermission: 'observability:read',\n },\n\n GET_METRIC_NAMES: {\n method: 'GET',\n path: '/observability/discovery/metric-names',\n summary: 'Get metric names',\n description: 'Returns distinct metric names with optional prefix filtering',\n },\n\n GET_METRIC_LABEL_KEYS: {\n method: 'GET',\n path: '/observability/discovery/metric-label-keys',\n summary: 'Get metric label keys',\n description: 'Returns distinct label keys for a given metric',\n },\n\n GET_METRIC_LABEL_VALUES: {\n method: 'GET',\n path: '/observability/discovery/metric-label-values',\n summary: 'Get label values',\n description: 'Returns distinct values for a given metric label key',\n },\n\n GET_ENTITY_TYPES: {\n method: 'GET',\n path: '/observability/discovery/entity-types',\n summary: 'Get entity types',\n description: 'Returns distinct entity types from observability data',\n },\n\n GET_ENTITY_NAMES: {\n method: 'GET',\n path: '/observability/discovery/entity-names',\n summary: 'Get entity names',\n description: 'Returns distinct entity names with optional type filtering',\n },\n\n GET_SERVICE_NAMES: {\n method: 'GET',\n path: '/observability/discovery/service-names',\n summary: 'Get service names',\n description: 'Returns distinct service names from observability data',\n },\n\n GET_ENVIRONMENTS: {\n method: 'GET',\n path: '/observability/discovery/environments',\n summary: 'Get environments',\n description: 'Returns distinct environments from observability data',\n },\n\n GET_TAGS: {\n method: 'GET',\n path: '/observability/discovery/tags',\n summary: 'Get tags',\n description: 'Returns distinct tags with optional entity type filtering',\n },\n} as const satisfies Record<string, RouteDetails>;\n\nexport type NewRoutesKey = keyof typeof NEW_ROUTE_DEFS;\nexport type NewRoutesDefinitions = (typeof NEW_ROUTE_DEFS)[NewRoutesKey];\n\nexport function createObservabilityListQuerySchema<\n TFilter extends z.ZodObject<z.ZodRawShape>,\n TOrderBy extends z.ZodObject<z.ZodRawShape>,\n>(filterSchema: TFilter, orderBySchema: TOrderBy) {\n const unwrapDefault = (schema: unknown) => {\n const zodSchema = schema as z.ZodTypeAny;\n return zodSchema instanceof z.ZodDefault ? zodSchema.unwrap() : zodSchema;\n };\n const paginationShape = paginationArgsSchema.shape as unknown as Record<string, z.ZodTypeAny>;\n const orderByShape = orderBySchema.shape as unknown as Record<string, z.ZodTypeAny>;\n\n const pageSchema = unwrapDefault(paginationShape.page);\n const perPageSchema = unwrapDefault(paginationShape.perPage);\n const fieldSchema = orderByShape.field ? unwrapDefault(orderByShape.field) : z.never().optional();\n const directionSchema = orderByShape.direction ? unwrapDefault(orderByShape.direction) : z.never().optional();\n\n return wrapSchemaForQueryParams(\n z\n .object({\n ...filterSchema.shape,\n page: pageSchema,\n perPage: perPageSchema,\n field: fieldSchema,\n direction: directionSchema,\n mode: listModeSchema.optional(),\n after: deltaCursorSchema.optional(),\n limit: deltaLimitSchema,\n })\n .partial(),\n ).superRefine((value, ctx) => {\n const isDelta = value.mode === 'delta';\n const hasPagination = value.page !== undefined || value.perPage !== undefined;\n const hasOrderBy = value.field !== undefined || value.direction !== undefined;\n const hasAfter = value.after !== undefined;\n const hasLimit = value.limit !== undefined;\n\n if (isDelta) {\n if (hasPagination) {\n if (value.page !== undefined) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['page'],\n message: '`page` is not allowed when `mode=delta`',\n });\n }\n if (value.perPage !== undefined) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['perPage'],\n message: '`perPage` is not allowed when `mode=delta`',\n });\n }\n }\n if (hasOrderBy) {\n if (value.field !== undefined) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['field'],\n message: '`field` is not allowed when `mode=delta`',\n });\n }\n if (value.direction !== undefined) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['direction'],\n message: '`direction` is not allowed when `mode=delta`',\n });\n }\n }\n return;\n }\n\n if (hasAfter) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['after'],\n message: '`after` is only allowed when `mode=delta`',\n });\n }\n if (hasLimit) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['limit'],\n message: '`limit` is only allowed when `mode=delta`',\n });\n }\n });\n}\n"],"mappings":";;;;;;;AAqBA,MAAa,sCAAsC;AACnD,MAAa,8CACX;AACF,MAAM,4CAA4C;AAClD,MAAM,0DAA0D;AAChE,MAAM,sDAAsD;AAC5D,MAAM,6CAA6C;AACnD,MAAM,yDAAyD;AAC/D,MAAa,sDAAsD;AACnE,MAAa,yDACX;AAEF,SAAgB,kCAAkC;CAChD,OACE,YAAY,kCAAkC,KAAA,KAC9C,YAAY,sCAAsC,KAAA,KAClD,YAAY,kCAAkC,KAAA,KAC9C,YAAY,sCAAsC,KAAA,KAClD,OAAO,YAAY,iCAAiC,cACpD,OAAO,YAAY,yBAAyB,cAC5C,OAAO,YAAY,2CAA2C,cAC9D,OAAO,YAAY,iCAAiC;AAExD;AAEA,MAAa,+BAA+B;CAC1C,QAAQ;CACR,UAAU;CACV,MAAM;CACN,SAAS;CACT,QAAQ;CACR,UAAU;AACZ;AAIA,MAAM,8CAA8C;AAEpD,SAAS,YAAY,oBAAyE;CAI5F,OAAOA,mBAAU,cAAc;AACjC;;AAGA,SAAgB,WAAW,QAAsC;CAC/D,MAAM,UAAU,OAAO,WAAW;CAClC,IAAI,CAAC,SACH,MAAM,IAAI,cAAc,KAAK,EAAE,SAAS,2BAA2B,CAAC;CAEtE,OAAO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,CAAC,aAAa,OAAO,QAAQ;EAC5B,MAAM,UAAU,MAAM,SAAS;EAC/B,MAAM,gBAAgB,MAAM,SAAS,KAAA,KAAa,MAAM,YAAY,KAAA;EACpE,MAAM,aAAa,MAAM,UAAU,KAAA,KAAa,MAAM,cAAc,KAAA;EACpE,MAAM,WAAW,MAAM,UAAU,KAAA;EACjC,MAAM,WAAW,MAAM,UAAU,KAAA;EAEjC,IAAI,SAAS;GACX,IAAI,eAAe;IACjB,IAAI,MAAM,SAAS,KAAA,GACjB,IAAI,SAAS;KACX,MAAM,EAAE,aAAa;KACrB,MAAM,CAAC,MAAM;KACb,SAAS;IACX,CAAC;IAEH,IAAI,MAAM,YAAY,KAAA,GACpB,IAAI,SAAS;KACX,MAAM,EAAE,aAAa;KACrB,MAAM,CAAC,SAAS;KAChB,SAAS;IACX,CAAC;GAEL;GACA,IAAI,YAAY;IACd,IAAI,MAAM,UAAU,KAAA,GAClB,IAAI,SAAS;KACX,MAAM,EAAE,aAAa;KACrB,MAAM,CAAC,OAAO;KACd,SAAS;IACX,CAAC;IAEH,IAAI,MAAM,cAAc,KAAA,GACtB,IAAI,SAAS;KACX,MAAM,EAAE,aAAa;KACrB,MAAM,CAAC,WAAW;KAClB,SAAS;IACX,CAAC;GAEL;GACA;EACF;EAEA,IAAI,UACF,IAAI,SAAS;GACX,MAAM,EAAE,aAAa;GACrB,MAAM,CAAC,OAAO;GACd,SAAS;EACX,CAAC;EAEH,IAAI,UACF,IAAI,SAAS;GACX,MAAM,EAAE,aAAa;GACrB,MAAM,CAAC,OAAO;GACd,SAAS;EACX,CAAC;CAEL,CAAC;AACH"}
|
|
@@ -6,7 +6,7 @@ const require_server_handlers_error = require("./error.cjs");
|
|
|
6
6
|
const require_server_handlers_observability_list_query_schemas = require("./observability-list-query-schemas.cjs");
|
|
7
7
|
const require_server_handlers_observability_shared = require("./observability-shared.cjs");
|
|
8
8
|
const require_server_handlers_observability_storage_schemas = require("./observability-storage-schemas.cjs");
|
|
9
|
-
const require_observability_new_endpoints = require("../../observability-new-endpoints-
|
|
9
|
+
const require_observability_new_endpoints = require("../../observability-new-endpoints-DJYL-Y5A.cjs");
|
|
10
10
|
let zod_v4 = require("zod/v4");
|
|
11
11
|
let _mastra_core_evals = require("@mastra/core/evals");
|
|
12
12
|
let _mastra_core_evals_scoreTraces = require("@mastra/core/evals/scoreTraces");
|
|
@@ -5,7 +5,7 @@ import { handleError } from "./error.js";
|
|
|
5
5
|
import { paginationArgsSchema } from "./observability-list-query-schemas.js";
|
|
6
6
|
import { OBSERVABILITY_LIST_ENDPOINTS, assertObservabilityDeltaSupported, createObservabilityListQuerySchema, getObservabilityStore, getScoresStore, getStorage } from "./observability-shared.js";
|
|
7
7
|
import { batchDeleteTracesArgsSchema, batchDeleteTracesResponseSchema, branchesFilterSchema, branchesOrderBySchema, getBranchArgsSchema, getBranchResponseSchema, listBranchesResponseSchema, listTracesLightResponseSchema } from "./observability-storage-schemas.js";
|
|
8
|
-
import { A as LIST_METRICS, C as GET_SCORE_TIME_SERIES, D as GET_TRACE_QUERY_VALUES, E as GET_TRACE_QUERY_FIELDS, F as UPDATE_FEEDBACK_REVIEW_STATUS, M as NEW_ROUTES, N as QUERY_THREADS, O as LIST_FEEDBACK, P as QUERY_TRACES, S as GET_SCORE_PERCENTILES, T as GET_TAGS, _ as GET_METRIC_PERCENTILES, a as GET_ENTITY_NAMES, b as GET_SCORE_AGGREGATE, c as GET_FEEDBACK_AGGREGATE, d as GET_FEEDBACK_TIME_SERIES, f as GET_METRIC_AGGREGATE, g as GET_METRIC_NAMES, h as GET_METRIC_LABEL_VALUES, i as DELETE_SCORES, j as LIST_SCORES, k as LIST_LOGS, l as GET_FEEDBACK_BREAKDOWN, m as GET_METRIC_LABEL_KEYS, n as CREATE_SCORE, o as GET_ENTITY_TYPES, p as GET_METRIC_BREAKDOWN, r as DELETE_FEEDBACK, s as GET_ENVIRONMENTS, t as CREATE_FEEDBACK, u as GET_FEEDBACK_PERCENTILES, v as GET_METRIC_TIME_SERIES, w as GET_SERVICE_NAMES, x as GET_SCORE_BREAKDOWN, y as GET_SCORE } from "../../observability-new-endpoints-
|
|
8
|
+
import { A as LIST_METRICS, C as GET_SCORE_TIME_SERIES, D as GET_TRACE_QUERY_VALUES, E as GET_TRACE_QUERY_FIELDS, F as UPDATE_FEEDBACK_REVIEW_STATUS, M as NEW_ROUTES, N as QUERY_THREADS, O as LIST_FEEDBACK, P as QUERY_TRACES, S as GET_SCORE_PERCENTILES, T as GET_TAGS, _ as GET_METRIC_PERCENTILES, a as GET_ENTITY_NAMES, b as GET_SCORE_AGGREGATE, c as GET_FEEDBACK_AGGREGATE, d as GET_FEEDBACK_TIME_SERIES, f as GET_METRIC_AGGREGATE, g as GET_METRIC_NAMES, h as GET_METRIC_LABEL_VALUES, i as DELETE_SCORES, j as LIST_SCORES, k as LIST_LOGS, l as GET_FEEDBACK_BREAKDOWN, m as GET_METRIC_LABEL_KEYS, n as CREATE_SCORE, o as GET_ENTITY_TYPES, p as GET_METRIC_BREAKDOWN, r as DELETE_FEEDBACK, s as GET_ENVIRONMENTS, t as CREATE_FEEDBACK, u as GET_FEEDBACK_PERCENTILES, v as GET_METRIC_TIME_SERIES, w as GET_SERVICE_NAMES, x as GET_SCORE_BREAKDOWN, y as GET_SCORE } from "../../observability-new-endpoints-DQHOnzNX.js";
|
|
9
9
|
import { z } from "zod/v4";
|
|
10
10
|
import { extractTrajectoryFromTrace, listScoresResponseSchema } from "@mastra/core/evals";
|
|
11
11
|
import { scoreTraces } from "@mastra/core/evals/scoreTraces";
|
|
@@ -89,7 +89,7 @@ const GET_API_SCHEMA_ROUTE = require_route_builder.createRoute({
|
|
|
89
89
|
tags: ["System"],
|
|
90
90
|
requiresAuth: true,
|
|
91
91
|
handler: async () => {
|
|
92
|
-
const { buildApiSchemaManifest } = await Promise.resolve().then(() => require("../../api-schema-manifest-
|
|
92
|
+
const { buildApiSchemaManifest } = await Promise.resolve().then(() => require("../../api-schema-manifest-CE2lXPKH.cjs"));
|
|
93
93
|
return buildApiSchemaManifest();
|
|
94
94
|
}
|
|
95
95
|
});
|
|
@@ -87,7 +87,7 @@ const GET_API_SCHEMA_ROUTE = createRoute({
|
|
|
87
87
|
tags: ["System"],
|
|
88
88
|
requiresAuth: true,
|
|
89
89
|
handler: async () => {
|
|
90
|
-
const { buildApiSchemaManifest } = await import("../../api-schema-manifest-
|
|
90
|
+
const { buildApiSchemaManifest } = await import("../../api-schema-manifest-D0_Q8UhK.js");
|
|
91
91
|
return buildApiSchemaManifest();
|
|
92
92
|
}
|
|
93
93
|
});
|
|
@@ -6,7 +6,7 @@ const require_utils = require("../../utils-DFQixxkO.cjs");
|
|
|
6
6
|
const require_constants = require("../../constants-4IJp_uzj.cjs");
|
|
7
7
|
const require_server_handlers_error = require("../handlers/error.cjs");
|
|
8
8
|
const require_helpers = require("../../helpers-8jl_xtug.cjs");
|
|
9
|
-
const require_routes = require("../../routes-
|
|
9
|
+
const require_routes = require("../../routes-l-SxuNkD.cjs");
|
|
10
10
|
let zod_v4 = require("zod/v4");
|
|
11
11
|
let stream = require("stream");
|
|
12
12
|
let _mastra_core_request_context = require("@mastra/core/request-context");
|
|
@@ -4,7 +4,7 @@ import { o as normalizeRoutePath, t as WorkflowRegistry } from "../../utils-BJm0
|
|
|
4
4
|
import { i as MASTRA_IS_STUDIO_KEY, l as MASTRA_USER_KEY, m as isStudioClientTypeHeader, n as MASTRA_AUTH_TOKEN_KEY, o as MASTRA_RESOURCE_ID_KEY$1, p as isReservedRequestContextKey, r as MASTRA_CLIENT_TYPE_HEADER, s as MASTRA_STUDIO_CLIENT_TYPE, t as MASTRA_AUTH_MODE_KEY } from "../../constants-0jFCWoex.js";
|
|
5
5
|
import { formatZodError, isZodError } from "../handlers/error.js";
|
|
6
6
|
import { d as pathMatchesPattern, i as findMatchingCustomRoute, o as isCustomRoutePublic, r as coreAuthMiddleware } from "../../helpers-610L0lwQ.js";
|
|
7
|
-
import { t as SERVER_ROUTES } from "../../routes-
|
|
7
|
+
import { t as SERVER_ROUTES } from "../../routes-CeJQfjk5.js";
|
|
8
8
|
import { z } from "zod/v4";
|
|
9
9
|
import { Readable } from "stream";
|
|
10
10
|
import { RequestContext } from "@mastra/core/request-context";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/server",
|
|
3
|
-
"version": "1.70.0-alpha.
|
|
3
|
+
"version": "1.70.0-alpha.3",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
@@ -116,15 +116,15 @@
|
|
|
116
116
|
"vitest": "4.1.11",
|
|
117
117
|
"zod": "^4.6.4",
|
|
118
118
|
"zod-to-ts": "^2.1.0",
|
|
119
|
-
"@internal/core": "0.1.2",
|
|
120
119
|
"@internal/storage-test-utils": "0.0.131",
|
|
120
|
+
"@internal/core": "0.1.2",
|
|
121
121
|
"@internal/lint": "0.0.135",
|
|
122
|
-
"@internal/test-utils": "0.0.71",
|
|
123
122
|
"@internal/types-builder": "0.0.110",
|
|
124
|
-
"@
|
|
125
|
-
"@mastra/schema-compat": "1.3.11",
|
|
123
|
+
"@internal/test-utils": "0.0.71",
|
|
126
124
|
"@internal/voice": "0.0.33",
|
|
127
|
-
"@mastra/
|
|
125
|
+
"@mastra/agent-builder": "1.1.21-alpha.1",
|
|
126
|
+
"@mastra/schema-compat": "1.3.11",
|
|
127
|
+
"@mastra/core": "1.70.0-alpha.3"
|
|
128
128
|
},
|
|
129
129
|
"homepage": "https://mastra.ai",
|
|
130
130
|
"repository": {
|