UNPKG

@mastra/core

Version:
1 lines 82.7 kB
{"version":3,"file":"utils-CNiGU0Uf.cjs","names":["z"],"sources":["../../_internal-core/dist/storage/index.js","../src/observability/utils.ts"],"sourcesContent":["import { z } from \"zod/v4\";\n//#region src/storage/domains/shared.ts\n/** Types of entities that can produce observability spans. */\nlet EntityType = /* @__PURE__ */ function(EntityType) {\n\t/** Agent/Model execution */\n\tEntityType[\"AGENT\"] = \"agent\";\n\t/** Scorer definition/execution */\n\tEntityType[\"SCORER\"] = \"scorer\";\n\t/** RAG ingestion pipeline execution */\n\tEntityType[\"RAG_INGESTION\"] = \"rag_ingestion\";\n\t/** Trajectory evaluation target */\n\tEntityType[\"TRAJECTORY\"] = \"trajectory\";\n\t/** Input Processor */\n\tEntityType[\"INPUT_PROCESSOR\"] = \"input_processor\";\n\t/** Input Step Processor */\n\tEntityType[\"INPUT_STEP_PROCESSOR\"] = \"input_step_processor\";\n\t/** Output Processor */\n\tEntityType[\"OUTPUT_PROCESSOR\"] = \"output_processor\";\n\t/** Output Step Processor */\n\tEntityType[\"OUTPUT_STEP_PROCESSOR\"] = \"output_step_processor\";\n\t/** Tool Result Processor */\n\tEntityType[\"TOOL_RESULT_PROCESSOR\"] = \"tool_result_processor\";\n\t/** Workflow Step */\n\tEntityType[\"WORKFLOW_STEP\"] = \"workflow_step\";\n\t/** Tool */\n\tEntityType[\"TOOL\"] = \"tool\";\n\t/** Workflow */\n\tEntityType[\"WORKFLOW_RUN\"] = \"workflow_run\";\n\t/** Memory */\n\tEntityType[\"MEMORY\"] = \"memory\";\n\treturn EntityType;\n}({});\n/**\n* Common DB fields\n*/\nconst createdAtField = z.date().describe(\"Database record creation time\");\nconst updatedAtField = z.date().describe(\"Database record last update time\");\nconst dbTimestamps = {\n\tcreatedAt: createdAtField,\n\tupdatedAt: updatedAtField.nullable()\n};\n/**\n* Pagination arguments for list queries (page and perPage only)\n* Uses z.coerce to handle string → number conversion from query params\n*/\nconst paginationArgsSchema = z.object({\n\tpage: z.coerce.number().int().min(0).optional().default(0).describe(\"Zero-indexed page number\"),\n\tperPage: z.coerce.number().int().min(1).max(100).optional().default(10).describe(\"Number of items per page\")\n}).describe(\"Pagination options for list queries\");\n/**\n* Pagination response info\n* Used across all paginated endpoints\n*/\nconst paginationInfoSchema = z.object({\n\ttotal: z.number().describe(\"Total number of items available\"),\n\tpage: z.number().describe(\"Current page\"),\n\tperPage: z.union([z.number(), z.literal(false)]).describe(\"Number of items per page, or false if pagination is disabled\"),\n\thasMore: z.boolean().describe(\"True if more pages are available\")\n});\n/** Opaque cursor used to resume incremental polling for observability list endpoints. */\nconst deltaCursorSchema = z.string().min(1).describe(\"Opaque cursor value for incremental polling\");\n/** Explicit list mode selector for observability list endpoints. */\nconst listModeSchema = z.enum([\"page\", \"delta\"]).describe(\"List mode: 'page' | 'delta', defaults to 'page' when omitted.\");\n/** Max number of updates returned from a delta poll window. */\nconst deltaLimitSchema = z.coerce.number().int().min(1).max(100).optional().describe(\"Maximum number of updates to return in one delta poll\");\n/** Default page-mode pagination used to preserve legacy list arg behavior. */\nconst defaultPaginationArgs = {\n\tpage: 0,\n\tperPage: 10\n};\n/** Default number of updates returned when delta mode does not specify a limit. */\nconst defaultDeltaLimit = 10;\n/**\n* Enforces the shared page-vs-delta parameter rules for observability list endpoints.\n* Keeps validation centralized while allowing endpoints to keep their own filters and orderBy schemas.\n*/\nfunction refineObservabilityListMode(value, ctx) {\n\tif (value.mode === \"delta\") {\n\t\tif (value.pagination !== void 0) ctx.addIssue({\n\t\t\tcode: \"custom\",\n\t\t\tpath: [\"pagination\"],\n\t\t\tmessage: \"pagination is not allowed in delta mode\"\n\t\t});\n\t\tif (value.orderBy !== void 0) ctx.addIssue({\n\t\t\tcode: \"custom\",\n\t\t\tpath: [\"orderBy\"],\n\t\t\tmessage: \"orderBy is not allowed in delta mode\"\n\t\t});\n\t\treturn;\n\t}\n\tif (value.after !== void 0) ctx.addIssue({\n\t\tcode: \"custom\",\n\t\tpath: [\"after\"],\n\t\tmessage: \"after is only allowed in delta mode\"\n\t});\n\tif (value.limit !== void 0) ctx.addIssue({\n\t\tcode: \"custom\",\n\t\tpath: [\"limit\"],\n\t\tmessage: \"limit is only allowed in delta mode\"\n\t});\n}\n/**\n* Normalizes observability list args into the legacy-friendly shape expected by existing stores.\n* Page mode remains the default, and pagination/orderBy/limit are always populated.\n*/\nfunction normalizeObservabilityListArgs(value, defaults) {\n\treturn {\n\t\tmode: value.mode === \"delta\" ? \"delta\" : \"page\",\n\t\tfilters: value.filters,\n\t\tpagination: value.pagination ?? defaults.pagination ?? defaultPaginationArgs,\n\t\torderBy: value.orderBy ?? defaults.orderBy,\n\t\tafter: value.after,\n\t\tlimit: value.limit ?? defaults.limit ?? 10\n\t};\n}\n/** Metadata returned for a delta poll window. */\nconst deltaInfoSchema = z.object({\n\tlimit: z.number().describe(\"Maximum number of updates requested for this delta poll\"),\n\thasMore: z.boolean().describe(\"True when more matching updates remain after this response\")\n}).describe(\"Incremental polling metadata\");\n/**\n* Date range for filtering by time\n* Uses z.coerce to handle ISO string → Date conversion from query params\n*/\nconst dateRangeSchema = z.object({\n\tstart: z.coerce.date().optional().describe(\"Start of date range (inclusive by default)\"),\n\tend: z.coerce.date().optional().describe(\"End of date range (inclusive by default)\"),\n\tstartExclusive: z.boolean().optional().describe(\"When true, excludes the start date from results (uses > instead of >=)\"),\n\tendExclusive: z.boolean().optional().describe(\"When true, excludes the end date from results (uses < instead of <=)\")\n}).describe(\"Date range filter for timestamps\");\nconst sortDirectionSchema = z.enum([\"ASC\", \"DESC\"]).describe(\"Sort direction: 'ASC' | 'DESC'\");\n/** Aggregation type schema shared across OLAP-style observability queries. */\nconst aggregationTypeSchema = z.enum([\n\t\"sum\",\n\t\"avg\",\n\t\"min\",\n\t\"max\",\n\t\"count\",\n\t\"count_distinct\",\n\t\"last\"\n]).describe(\"Aggregation function\");\n/** Aggregation interval schema shared across OLAP-style observability queries. */\nconst aggregationIntervalSchema = z.enum([\n\t\"1m\",\n\t\"5m\",\n\t\"15m\",\n\t\"1h\",\n\t\"1d\"\n]).describe(\"Time bucket interval\");\n/** Compare period for aggregate queries with period-over-period comparison. */\nconst comparePeriodSchema = z.enum([\n\t\"previous_period\",\n\t\"previous_day\",\n\t\"previous_week\"\n]).describe(\"Comparison period for aggregate queries\");\n/** Shared groupBy schema for OLAP-style breakdown and time-series queries. */\nconst groupBySchema = z.array(z.string()).min(1).describe(\"Fields to group by\");\n/** Shared percentiles schema for percentile queries. */\nconst percentilesSchema = z.array(z.number().min(0).max(1)).min(1).describe(\"Percentile values (0-1)\");\n/** Shared fields for aggregate OLAP responses across observability signals. */\nconst aggregateResponseFields = {\n\tvalue: z.number().nullable().describe(\"Aggregated value\"),\n\tpreviousValue: z.number().nullable().optional().describe(\"Value from comparison period\"),\n\tchangePercent: z.number().nullable().optional().describe(\"Percentage change from comparison period\")\n};\n/** Shared field for OLAP breakdown dimension values. */\nconst dimensionsField = z.record(z.string(), z.string().nullable()).describe(\"Dimension values for this group\");\n/** Shared field for non-null OLAP aggregated values. */\nconst aggregatedValueField = z.number().describe(\"Aggregated value\");\n/** Shared field for OLAP bucket timestamps. */\nconst bucketTimestampField = z.date().describe(\"Bucket timestamp\");\n/** Shared field for percentile identifiers in OLAP responses. */\nconst percentileField = z.number().describe(\"Percentile value\");\n/** Shared field for percentile values within a time bucket. */\nconst percentileBucketValueField = z.number().describe(\"Percentile value at this bucket\");\nconst entityTypeField = z.nativeEnum(EntityType).describe(`Entity type (e.g., 'agent' | 'processor' | 'tool' | 'workflow')`);\nconst entityIdField = z.string().describe(\"ID of the entity (e.g., \\\"weatherAgent\\\", \\\"orderWorkflow\\\")\");\nconst entityNameField = z.string().describe(\"Name of the entity\");\nconst userIdField = z.string().describe(\"Human end-user who triggered execution\");\nconst organizationIdField = z.string().describe(\"Multi-tenant organization/account\");\nconst resourceIdField = z.string().describe(\"Broader resource context (Mastra memory compatibility)\");\nconst runIdField = z.string().describe(\"Unique execution run identifier\");\nconst sessionIdField = z.string().describe(\"Session identifier for grouping traces\");\nconst threadIdField = z.string().describe(\"Conversation thread identifier\");\nconst requestIdField = z.string().describe(\"HTTP request ID for log correlation\");\nconst environmentField = z.string().describe(`Environment (e.g., \"production\" | \"staging\" | \"development\")`);\nconst sourceField = z.string().describe(`Source of execution (e.g., \"local\" | \"cloud\" | \"ci\")`);\nconst executionSourceField = z.string().describe(`Source of execution (e.g., \"local\" | \"cloud\" | \"ci\")`);\nconst serviceNameField = z.string().describe(\"Name of the service\");\nconst parentEntityTypeField = z.nativeEnum(EntityType).describe(\"Entity type of the parent entity\");\nconst parentEntityIdField = z.string().describe(\"ID of the parent entity\");\nconst parentEntityNameField = z.string().describe(\"Name of the parent entity\");\nconst rootEntityTypeField = z.nativeEnum(EntityType).describe(\"Entity type of the root entity\");\nconst rootEntityIdField = z.string().describe(\"ID of the root entity\");\nconst rootEntityNameField = z.string().describe(\"Name of the root entity\");\nconst entityVersionIdField = z.string().describe(\"Version ID of the entity that produced this signal (e.g., agent version, workflow version)\");\nconst parentEntityVersionIdField = z.string().describe(\"Version ID of the parent entity that produced this signal\");\nconst rootEntityVersionIdField = z.string().describe(\"Version ID of the root entity that produced this signal\");\nconst experimentIdField = z.string().describe(\"Experiment or eval run identifier\");\nconst scopeField = z.record(z.string(), z.unknown()).describe(\"Arbitrary package/app version info (e.g., {\\\"core\\\": \\\"1.0.0\\\", \\\"memory\\\": \\\"1.0.0\\\", \\\"gitSha\\\": \\\"abcd1234\\\"})\");\nconst metadataField = z.record(z.string(), z.unknown()).describe(\"User-defined metadata for custom filtering\");\nconst tagsField = z.array(z.string()).describe(\"Labels for filtering\");\n/**\n* Base context fields shared across tracing and non-tracing observability records.\n* Source/provenance is intentionally excluded because tracing uses `source`\n* while signals use `executionSource`.\n*/\nconst contextFieldsBase = {\n\tentityType: entityTypeField.nullish(),\n\tentityId: entityIdField.nullish(),\n\tentityName: entityNameField.nullish(),\n\tparentEntityType: parentEntityTypeField.nullish(),\n\tparentEntityId: parentEntityIdField.nullish(),\n\tparentEntityName: parentEntityNameField.nullish(),\n\trootEntityType: rootEntityTypeField.nullish(),\n\trootEntityId: rootEntityIdField.nullish(),\n\trootEntityName: rootEntityNameField.nullish(),\n\tuserId: userIdField.nullish(),\n\torganizationId: organizationIdField.nullish(),\n\tresourceId: resourceIdField.nullish(),\n\trunId: runIdField.nullish(),\n\tsessionId: sessionIdField.nullish(),\n\tthreadId: threadIdField.nullish(),\n\trequestId: requestIdField.nullish(),\n\tenvironment: environmentField.nullish(),\n\tserviceName: serviceNameField.nullish(),\n\tscope: scopeField.nullish(),\n\tentityVersionId: entityVersionIdField.nullish(),\n\tparentEntityVersionId: parentEntityVersionIdField.nullish(),\n\trootEntityVersionId: rootEntityVersionIdField.nullish(),\n\texperimentId: experimentIdField.nullish()\n};\n/**\n* Context fields shared across observability signals other than spans (metrics, logs, scores, feedback).\n* These use `executionSource` to avoid colliding with signal-specific provenance fields.\n*/\nconst contextFields = {\n\t...contextFieldsBase,\n\texecutionSource: executionSourceField.nullish(),\n\ttags: tagsField.nullish()\n};\n/**\n* Context fields used by tracing/span records.\n* Tracing continues to expose execution provenance as `source`.\n*/\nconst spanContextFields = {\n\t...contextFieldsBase,\n\tsource: sourceField.nullish()\n};\n/**\n* Common filter fields shared across observability signal filters (metrics, logs, scores, feedback).\n* All fields are optional — each signal extends this with signal-specific filters.\n*/\nconst commonFilterFields = {\n\ttimestamp: dateRangeSchema.optional().describe(\"Filter by timestamp range\"),\n\ttraceId: z.string().optional().describe(\"Filter by trace ID\"),\n\tspanId: z.string().optional().describe(\"Filter by span ID\"),\n\tentityType: entityTypeField.optional(),\n\tentityName: entityNameField.optional(),\n\tentityVersionId: entityVersionIdField.optional(),\n\tparentEntityVersionId: parentEntityVersionIdField.optional(),\n\trootEntityVersionId: rootEntityVersionIdField.optional(),\n\tuserId: userIdField.optional(),\n\torganizationId: organizationIdField.optional(),\n\texperimentId: experimentIdField.optional(),\n\tserviceName: serviceNameField.optional(),\n\tenvironment: environmentField.optional(),\n\tparentEntityType: parentEntityTypeField.optional(),\n\tparentEntityName: parentEntityNameField.optional(),\n\trootEntityType: rootEntityTypeField.optional(),\n\trootEntityName: rootEntityNameField.optional(),\n\tresourceId: resourceIdField.optional(),\n\trunId: runIdField.optional(),\n\tsessionId: sessionIdField.optional(),\n\tthreadId: threadIdField.optional(),\n\trequestId: requestIdField.optional(),\n\texecutionSource: executionSourceField.optional(),\n\ttags: z.array(z.string()).optional().describe(\"Filter by tags (must have all specified tags)\")\n};\n/** Zod schema for trace ID field */\nconst traceIdField = z.string().describe(\"Unique trace identifier\");\n/** Zod schema for span ID field */\nconst spanIdField = z.string().describe(\"Unique span identifier within a trace\");\n//#endregion\n//#region src/storage/domains/observability/logs.ts\n/** Log level schema for validation */\nconst logLevelSchema = z.enum([\n\t\"debug\",\n\t\"info\",\n\t\"warn\",\n\t\"error\",\n\t\"fatal\"\n]);\nconst messageField = z.string().describe(\"Log message\");\nconst logDataField = z.record(z.string(), z.unknown()).describe(\"Structured data attached to the log\");\n/**\n* Schema for logs as stored in the database.\n* Includes all fields from ExportedLog plus storage-specific fields.\n*/\nconst logRecordSchema = z.object({\n\tlogId: z.string().nullish().describe(\"Unique id for this log event\"),\n\ttimestamp: z.date().describe(\"When the log was created\"),\n\tlevel: logLevelSchema.describe(\"Log severity level\"),\n\tmessage: messageField,\n\tdata: logDataField.nullish(),\n\ttraceId: traceIdField.nullish(),\n\tspanId: spanIdField.nullish(),\n\t...contextFields,\n\t/**\n\t* @deprecated Use `executionSource` instead.\n\t*/\n\tsource: z.string().nullish().describe(\"Execution source\"),\n\tmetadata: metadataField.nullish()\n}).describe(\"Log record as stored in the database\");\n/**\n* Schema for user-provided log input (minimal required fields).\n* The logger enriches this with context before emitting ExportedLog.\n*/\nconst logRecordInputSchema = z.object({\n\tlevel: logLevelSchema,\n\tmessage: messageField,\n\tdata: logDataField.optional(),\n\ttags: tagsField.optional()\n}).describe(\"User-provided log input\");\n/** Schema for creating a log record */\nconst createLogRecordSchema = logRecordSchema;\n/** Schema for batchCreateLogs operation arguments */\nconst batchCreateLogsArgsSchema = z.object({ logs: z.array(createLogRecordSchema) }).describe(\"Arguments for batch creating logs\");\n/** Schema for filtering logs in list queries */\nconst logsFilterSchema = z.object({\n\t...commonFilterFields,\n\t/**\n\t* @deprecated Use `executionSource` instead.\n\t*/\n\tsource: z.string().optional().describe(\"Filter by execution source\"),\n\tlevel: z.union([logLevelSchema, z.array(logLevelSchema)]).optional().describe(\"Filter by log level(s)\")\n}).describe(\"Filters for querying logs\");\n/** Fields available for ordering log results */\nconst logsOrderByFieldSchema = z.enum([\"timestamp\"]).describe(\"Field to order by: 'timestamp'\");\n/** Order by configuration for log queries */\nconst logsOrderBySchema = z.object({\n\tfield: logsOrderByFieldSchema.default(\"timestamp\").describe(\"Field to order by\"),\n\tdirection: sortDirectionSchema.default(\"DESC\").describe(\"Sort direction\")\n}).describe(\"Order by configuration\");\n/** Schema for listLogs operation arguments */\nconst listLogsArgsSchema = z.object({\n\tmode: listModeSchema.optional(),\n\tfilters: logsFilterSchema.optional().describe(\"Optional filters to apply\"),\n\tpagination: paginationArgsSchema.optional(),\n\torderBy: logsOrderBySchema.optional(),\n\tafter: deltaCursorSchema.optional(),\n\tlimit: deltaLimitSchema\n}).strict().superRefine(refineObservabilityListMode).transform((value) => normalizeObservabilityListArgs(value, { orderBy: {\n\tfield: \"timestamp\",\n\tdirection: \"DESC\"\n} })).describe(\"Arguments for listing logs\");\n/** Schema for listLogs operation response */\nconst listLogsResponseSchema = z.object({\n\tpagination: paginationInfoSchema.optional(),\n\tdelta: deltaInfoSchema.optional(),\n\tdeltaCursor: deltaCursorSchema.optional(),\n\tlogs: z.array(logRecordSchema)\n}).describe(\"Response from listing logs\");\n//#endregion\n//#region src/storage/domains/observability/scores.ts\nconst scorerIdField = z.string().describe(\"Identifier of the scorer (e.g., relevance, accuracy)\");\nconst scorerNameField = z.string().describe(\"Display name of the scorer\");\nconst scorerVersionField = z.string().describe(\"Version of the scorer\");\nconst scoreSourceField = z.string().describe(\"How the score was produced (e.g., manual, automated, experiment)\");\nconst scoreValueField = z.number().describe(\"Score value (range defined by scorer)\");\nconst scoreReasonField = z.string().describe(\"Explanation for the score\");\n/**\n* Schema for scores as stored in the database.\n* Includes all fields from ExportedScore plus storage-specific fields.\n*/\nconst scoreRecordSchema = z.object({\n\tscoreId: z.string().nullish().describe(\"Unique id for this score event\"),\n\ttimestamp: z.date().describe(\"When the score was recorded\"),\n\ttraceId: traceIdField.nullish().describe(\"Trace that anchors the scored target when available\"),\n\tspanId: spanIdField.nullish().describe(\"Span ID this score applies to\"),\n\tscorerId: scorerIdField,\n\tscorerName: scorerNameField.nullish(),\n\tscorerVersion: scorerVersionField.nullish(),\n\tscoreSource: scoreSourceField.nullish(),\n\t/**\n\t* @deprecated Use `scoreSource` instead.\n\t*/\n\tsource: scoreSourceField.nullish(),\n\tscore: scoreValueField,\n\treason: scoreReasonField.nullish(),\n\t...contextFields,\n\t/** Trace ID of the scoring run (links to trace that generated this score) */\n\tscoreTraceId: z.string().nullish().describe(\"Trace ID of the scoring run for debugging score generation\"),\n\tmetadata: z.record(z.string(), z.unknown()).nullish().describe(\"User-defined metadata\")\n}).describe(\"Score record as stored in the database\");\n/**\n* Schema for user-provided score input (minimal required fields).\n* The span/trace context adds traceId/spanId before emitting ExportedScore.\n*/\nconst scoreInputSchema = z.object({\n\tscorerId: scorerIdField,\n\tscorerName: scorerNameField.optional(),\n\tscorerVersion: scorerVersionField.optional(),\n\tscoreSource: scoreSourceField.optional(),\n\t/**\n\t* @deprecated Use `scoreSource` instead.\n\t*/\n\tsource: scoreSourceField.optional(),\n\tscore: scoreValueField,\n\treason: scoreReasonField.optional(),\n\tmetadata: z.record(z.string(), z.unknown()).optional().describe(\"Additional scorer-specific metadata\"),\n\texperimentId: experimentIdField.optional(),\n\tscoreTraceId: z.string().optional().describe(\"Trace ID of the scoring run for debugging score generation\"),\n\ttargetEntityType: entityTypeField.optional().describe(\"Entity type the scorer evaluated when known\")\n}).describe(\"User-provided score input\");\n/** Schema for creating a score record */\nconst createScoreRecordSchema = scoreRecordSchema;\n/** Schema for createScore operation arguments */\nconst createScoreArgsSchema = z.object({ score: createScoreRecordSchema }).describe(\"Arguments for creating a score\");\n/** Schema for createScore operation body in client/server */\nconst createScoreBodySchema = z.object({ score: createScoreRecordSchema.omit({ timestamp: true }) }).describe(\"Arguments for creating a score\");\n/** Schema for createScore operation response */\nconst createScoreResponseSchema = z.object({ success: z.boolean() }).describe(\"Response from creating a score\");\n/** Schema for batchCreateScores operation arguments */\nconst batchCreateScoresArgsSchema = z.object({ scores: z.array(createScoreRecordSchema) }).describe(\"Arguments for batch recording scores\");\n/** Schema for filtering scores in list queries */\nconst scoresFilterSchema = z.object({\n\t...commonFilterFields,\n\tscorerId: z.union([z.string(), z.array(z.string())]).optional().describe(\"Filter by scorer ID(s)\"),\n\tscoreSource: scoreSourceField.optional().describe(\"Filter by how the score was produced\"),\n\t/**\n\t* @deprecated Use `scoreSource` instead.\n\t*/\n\tsource: scoreSourceField.optional().describe(\"Filter by how the score was produced\")\n}).describe(\"Filters for querying scores\");\n/** Fields available for ordering score results */\nconst scoresOrderByFieldSchema = z.enum([\"timestamp\", \"score\"]).describe(\"Field to order by: 'timestamp' | 'score'\");\n/** Order by configuration for score queries */\nconst scoresOrderBySchema = z.object({\n\tfield: scoresOrderByFieldSchema.default(\"timestamp\").describe(\"Field to order by\"),\n\tdirection: sortDirectionSchema.default(\"DESC\").describe(\"Sort direction\")\n}).describe(\"Order by configuration\");\nconst listScoresArgsSchema = z.object({\n\tmode: listModeSchema.optional(),\n\tfilters: scoresFilterSchema.optional(),\n\tpagination: paginationArgsSchema.optional(),\n\torderBy: scoresOrderBySchema.optional(),\n\tafter: deltaCursorSchema.optional(),\n\tlimit: deltaLimitSchema\n}).strict().superRefine(refineObservabilityListMode).transform((value) => normalizeObservabilityListArgs(value, { orderBy: {\n\tfield: \"timestamp\",\n\tdirection: \"DESC\"\n} })).describe(\"Arguments for listing scores\");\n/** Schema for listScores operation response */\nconst listScoresResponseSchema = z.object({\n\tpagination: paginationInfoSchema.optional(),\n\tdelta: deltaInfoSchema.optional(),\n\tdeltaCursor: deltaCursorSchema.optional(),\n\tscores: z.array(scoreRecordSchema)\n}).describe(\"Response from listing scores\");\nconst getScoreAggregateArgsSchema = z.object({\n\tscorerId: scorerIdField,\n\tscoreSource: scoreSourceField.optional(),\n\taggregation: aggregationTypeSchema,\n\tfilters: scoresFilterSchema.optional(),\n\tcomparePeriod: comparePeriodSchema.optional()\n}).describe(\"Arguments for getting a score aggregate\");\nconst getScoreAggregateResponseSchema = z.object(aggregateResponseFields);\nconst getScoreBreakdownArgsSchema = z.object({\n\tscorerId: scorerIdField,\n\tscoreSource: scoreSourceField.optional(),\n\tgroupBy: groupBySchema,\n\taggregation: aggregationTypeSchema,\n\tfilters: scoresFilterSchema.optional()\n}).describe(\"Arguments for getting a score breakdown\");\nconst getScoreBreakdownResponseSchema = z.object({ groups: z.array(z.object({\n\tdimensions: dimensionsField,\n\tvalue: aggregatedValueField\n})) });\nconst getScoreTimeSeriesArgsSchema = z.object({\n\tscorerId: scorerIdField,\n\tscoreSource: scoreSourceField.optional(),\n\tinterval: aggregationIntervalSchema,\n\taggregation: aggregationTypeSchema,\n\tfilters: scoresFilterSchema.optional(),\n\tgroupBy: groupBySchema.optional()\n}).describe(\"Arguments for getting score time series\");\nconst getScoreTimeSeriesResponseSchema = z.object({ series: z.array(z.object({\n\tname: z.string().describe(\"Series name (scorer ID or group key)\"),\n\tpoints: z.array(z.object({\n\t\ttimestamp: bucketTimestampField,\n\t\tvalue: aggregatedValueField\n\t}))\n})) });\nconst getScorePercentilesArgsSchema = z.object({\n\tscorerId: scorerIdField,\n\tscoreSource: scoreSourceField.optional(),\n\tpercentiles: percentilesSchema,\n\tinterval: aggregationIntervalSchema,\n\tfilters: scoresFilterSchema.optional()\n}).describe(\"Arguments for getting score percentiles\");\nconst getScorePercentilesResponseSchema = z.object({ series: z.array(z.object({\n\tpercentile: percentileField,\n\tpoints: z.array(z.object({\n\t\ttimestamp: bucketTimestampField,\n\t\tvalue: percentileBucketValueField\n\t}))\n})) });\n//#endregion\n//#region src/storage/domains/observability/feedback.ts\nconst feedbackSourceField = z.string().describe(\"Source of feedback (e.g., 'user', 'system', 'manual')\");\nconst feedbackTypeField = z.string().describe(\"Type of feedback (e.g., 'thumbs', 'rating', 'correction')\");\nconst feedbackValueField = z.union([z.number(), z.string()]).describe(\"Feedback value (rating number or correction text)\");\nconst feedbackCommentField = z.string().describe(\"Additional comment or context\");\nconst feedbackUserIdField = z.string().describe(\"User who provided the feedback\");\nfunction normalizeLegacyFeedbackActor(input) {\n\tif (!input || typeof input !== \"object\" || Array.isArray(input)) return input;\n\tconst record = { ...input };\n\tif (typeof record.userId === \"string\" && record.feedbackUserId == null) {\n\t\trecord.feedbackUserId = record.userId;\n\t\tdelete record.userId;\n\t}\n\treturn record;\n}\n/**\n* Schema for feedback as stored in the database.\n* Includes all fields from ExportedFeedback plus storage-specific fields.\n*/\nconst feedbackRecordObjectSchema = z.object({\n\tfeedbackId: z.string().nullish().describe(\"Unique id for this feedback event\"),\n\ttimestamp: z.date().describe(\"When the feedback was recorded\"),\n\ttraceId: traceIdField.nullish().describe(\"Trace that anchors the feedback target when available\"),\n\tspanId: spanIdField.nullish().describe(\"Span ID this feedback applies to\"),\n\tfeedbackSource: feedbackSourceField.nullish(),\n\t/**\n\t* @deprecated Use `feedbackSource` instead.\n\t*/\n\tsource: feedbackSourceField.nullish(),\n\tfeedbackType: feedbackTypeField,\n\tvalue: feedbackValueField,\n\tcomment: feedbackCommentField.nullish(),\n\tfeedbackUserId: feedbackUserIdField.nullish(),\n\t...contextFields,\n\tsourceId: z.string().nullish().describe(\"ID of the source record this feedback is linked to (e.g. experiment result ID)\"),\n\tmetadata: z.record(z.string(), z.unknown()).nullish().describe(\"User-defined metadata\")\n});\nconst feedbackRecordSchema = z.object(feedbackRecordObjectSchema.shape).describe(\"Feedback record as stored in the database\");\n/**\n* Schema for user-provided feedback input (minimal required fields).\n* The span/trace context adds traceId/spanId before emitting ExportedFeedback.\n*/\nconst feedbackInputObjectSchema = z.object({\n\tfeedbackSource: feedbackSourceField.optional(),\n\t/**\n\t* @deprecated Use `feedbackSource` instead.\n\t*/\n\tsource: feedbackSourceField.optional(),\n\tfeedbackType: feedbackTypeField,\n\tvalue: feedbackValueField,\n\tcomment: feedbackCommentField.optional(),\n\tfeedbackUserId: feedbackUserIdField.optional(),\n\t/**\n\t* @deprecated Use `feedbackUserId` instead.\n\t*/\n\tuserId: feedbackUserIdField.optional(),\n\tmetadata: z.record(z.string(), z.unknown()).optional().describe(\"Additional feedback-specific metadata\"),\n\texperimentId: experimentIdField.optional(),\n\tsourceId: z.string().optional().describe(\"ID of the source record this feedback is linked to\")\n});\nconst feedbackInputSchema = z.object(feedbackInputObjectSchema.shape).describe(\"User-provided feedback input\");\n/** Schema for creating a feedback record */\nconst createFeedbackRecordSchema = feedbackRecordSchema;\n/** Schema for createFeedback operation arguments */\nconst createFeedbackArgsSchema = z.object({ feedback: z.preprocess(normalizeLegacyFeedbackActor, feedbackRecordObjectSchema) }).describe(\"Arguments for creating feedback\");\n/** Schema for createFeedback operation body in client/server */\nconst createFeedbackBodySchema = z.object({ feedback: feedbackRecordObjectSchema.omit({ timestamp: true }) }).describe(\"Arguments for creating feedback\");\n/** Schema for createFeedback operation response */\nconst createFeedbackResponseSchema = z.object({ success: z.boolean() }).describe(\"Response from creating feedback\");\n/** Schema for batchCreateFeedback operation arguments */\nconst batchCreateFeedbackArgsSchema = z.object({ feedbacks: z.array(z.preprocess(normalizeLegacyFeedbackActor, feedbackRecordObjectSchema)) }).describe(\"Arguments for batch recording feedback\");\n/** Schema for filtering feedback in list queries */\nconst feedbackFilterObjectSchema = z.object({\n\t...commonFilterFields,\n\tfeedbackType: z.union([z.string(), z.array(z.string())]).optional().describe(\"Filter by feedback type(s)\"),\n\tfeedbackSource: feedbackSourceField.optional(),\n\t/**\n\t* @deprecated Use `feedbackSource` instead.\n\t*/\n\tsource: feedbackSourceField.optional(),\n\tfeedbackUserId: feedbackUserIdField.optional()\n});\nconst feedbackFilterSchema = z.object(feedbackFilterObjectSchema.shape).describe(\"Filters for querying feedback\");\n/** Fields available for ordering feedback results */\nconst feedbackOrderByFieldSchema = z.enum([\"timestamp\"]).describe(\"Field to order by: 'timestamp'\");\n/** Order by configuration for feedback queries */\nconst feedbackOrderBySchema = z.object({\n\tfield: feedbackOrderByFieldSchema.default(\"timestamp\").describe(\"Field to order by\"),\n\tdirection: sortDirectionSchema.default(\"DESC\").describe(\"Sort direction\")\n}).describe(\"Order by configuration\");\nconst listFeedbackArgsSchema = z.object({\n\tmode: listModeSchema.optional(),\n\tfilters: z.preprocess(normalizeLegacyFeedbackActor, feedbackFilterObjectSchema).optional(),\n\tpagination: paginationArgsSchema.optional(),\n\torderBy: feedbackOrderBySchema.optional(),\n\tafter: deltaCursorSchema.optional(),\n\tlimit: deltaLimitSchema\n}).strict().superRefine(refineObservabilityListMode).transform((value) => normalizeObservabilityListArgs(value, { orderBy: {\n\tfield: \"timestamp\",\n\tdirection: \"DESC\"\n} })).describe(\"Arguments for listing feedback\");\n/** Schema for listFeedback operation response */\nconst listFeedbackResponseSchema = z.object({\n\tpagination: paginationInfoSchema.optional(),\n\tdelta: deltaInfoSchema.optional(),\n\tdeltaCursor: deltaCursorSchema.optional(),\n\tfeedback: z.array(feedbackRecordSchema)\n}).describe(\"Response from listing feedback\");\nconst getFeedbackAggregateArgsSchema = z.object({\n\tfeedbackType: feedbackTypeField,\n\tfeedbackSource: feedbackSourceField.optional(),\n\taggregation: aggregationTypeSchema,\n\tfilters: feedbackFilterSchema.optional(),\n\tcomparePeriod: comparePeriodSchema.optional()\n}).describe(\"Arguments for getting a feedback aggregate over numeric values\");\nconst getFeedbackAggregateResponseSchema = z.object(aggregateResponseFields);\nconst getFeedbackBreakdownArgsSchema = z.object({\n\tfeedbackType: feedbackTypeField,\n\tfeedbackSource: feedbackSourceField.optional(),\n\tgroupBy: groupBySchema,\n\taggregation: aggregationTypeSchema,\n\tfilters: feedbackFilterSchema.optional()\n}).describe(\"Arguments for getting a feedback breakdown over numeric values\");\nconst getFeedbackBreakdownResponseSchema = z.object({ groups: z.array(z.object({\n\tdimensions: dimensionsField,\n\tvalue: aggregatedValueField\n})) });\nconst getFeedbackTimeSeriesArgsSchema = z.object({\n\tfeedbackType: feedbackTypeField,\n\tfeedbackSource: feedbackSourceField.optional(),\n\tinterval: aggregationIntervalSchema,\n\taggregation: aggregationTypeSchema,\n\tfilters: feedbackFilterSchema.optional(),\n\tgroupBy: groupBySchema.optional()\n}).describe(\"Arguments for getting feedback time series over numeric values\");\nconst getFeedbackTimeSeriesResponseSchema = z.object({ series: z.array(z.object({\n\tname: z.string().describe(\"Series name (feedback type or group key)\"),\n\tpoints: z.array(z.object({\n\t\ttimestamp: bucketTimestampField,\n\t\tvalue: aggregatedValueField\n\t}))\n})) });\nconst getFeedbackPercentilesArgsSchema = z.object({\n\tfeedbackType: feedbackTypeField,\n\tfeedbackSource: feedbackSourceField.optional(),\n\tpercentiles: percentilesSchema,\n\tinterval: aggregationIntervalSchema,\n\tfilters: feedbackFilterSchema.optional()\n}).describe(\"Arguments for getting feedback percentiles over numeric values\");\nconst getFeedbackPercentilesResponseSchema = z.object({ series: z.array(z.object({\n\tpercentile: percentileField,\n\tpoints: z.array(z.object({\n\t\ttimestamp: bucketTimestampField,\n\t\tvalue: percentileBucketValueField\n\t}))\n})) });\n//#endregion\n//#region src/storage/domains/observability/metrics.ts\n/**\n* @deprecated MetricType is no longer stored. All metrics are raw events\n* with aggregation determined at query time.\n*/\nconst metricTypeSchema = z.enum([\n\t\"counter\",\n\t\"gauge\",\n\t\"histogram\"\n]);\nconst metricNameField = z.string().describe(\"Metric name (e.g., mastra_agent_duration_ms)\");\nconst metricValueField = z.number().describe(\"Metric value\");\nconst labelsField = z.record(z.string(), z.string()).describe(\"Metric labels for dimensional filtering\");\nconst providerField = z.string().describe(\"Model provider\");\nconst modelField = z.string().describe(\"Model\");\nconst estimatedCostField = z.number().describe(\"Estimated cost\");\nconst costUnitField = z.string().describe(\"Unit for the estimated cost (e.g., usd)\");\nconst costMetadField = z.record(z.string(), z.unknown()).nullish().describe(\"Structured costing metadata\");\n/**\n* Schema for metrics as stored in the database.\n* Each record is a single metric observation.\n*/\nconst metricRecordSchema = z.object({\n\tmetricId: z.string().nullish().describe(\"Unique id for this metric event\"),\n\ttimestamp: z.date().describe(\"When the metric was recorded\"),\n\tname: metricNameField,\n\tvalue: metricValueField,\n\ttraceId: traceIdField.nullish(),\n\tspanId: spanIdField.nullish(),\n\t...contextFields,\n\t/**\n\t* @deprecated Use `executionSource` instead.\n\t*/\n\tsource: z.string().nullish().describe(\"Execution source\"),\n\tprovider: providerField.nullish(),\n\tmodel: modelField.nullish(),\n\testimatedCost: estimatedCostField.nullish(),\n\tcostUnit: costUnitField.nullish(),\n\tcostMetadata: costMetadField.nullish(),\n\tlabels: labelsField.default({}),\n\tmetadata: metadataField.nullish()\n}).describe(\"Metric record as stored in the database\");\n/**\n* Schema for user-provided metric input (minimal required fields).\n* The metrics context enriches this with environment before emitting ExportedMetric.\n*/\nconst metricInputSchema = z.object({\n\tname: metricNameField,\n\tvalue: metricValueField,\n\tlabels: labelsField.optional()\n}).describe(\"User-provided metric input\");\n/** Schema for creating a metric record (without db timestamps) */\nconst createMetricRecordSchema = metricRecordSchema;\n/** Schema for batchCreateMetrics operation arguments */\nconst batchCreateMetricsArgsSchema = z.object({ metrics: z.array(createMetricRecordSchema) }).describe(\"Arguments for batch recording metrics\");\n/** Schema for metric aggregation configuration */\nconst metricsAggregationSchema = z.object({\n\ttype: aggregationTypeSchema,\n\tinterval: aggregationIntervalSchema.optional(),\n\tgroupBy: groupBySchema.optional()\n}).describe(\"Metrics aggregation configuration\");\n/** Schema for filtering metrics in queries */\nconst metricsFilterSchema = z.object({\n\t...commonFilterFields,\n\ttraceIds: z.array(traceIdField).nonempty().max(1e3).optional().describe(\"Filter by one or more trace IDs\"),\n\tname: z.array(z.string()).nonempty().optional().describe(\"Filter by metric name(s)\"),\n\t/**\n\t* @deprecated Use `executionSource` instead.\n\t*/\n\tsource: z.string().optional().describe(\"Filter by execution source\"),\n\tprovider: providerField.optional(),\n\tmodel: modelField.optional(),\n\tcostUnit: costUnitField.optional(),\n\tlabels: z.record(z.string(), z.string()).optional().describe(\"Exact match on label key-value pairs\")\n}).describe(\"Filters for querying metrics\");\n/** Fields available for ordering metric list results */\nconst metricsOrderByFieldSchema = z.enum([\"timestamp\"]).describe(\"Field to order by: 'timestamp'\");\n/** Order by configuration for metric list queries */\nconst metricsOrderBySchema = z.object({\n\tfield: metricsOrderByFieldSchema.default(\"timestamp\").describe(\"Field to order by\"),\n\tdirection: sortDirectionSchema.default(\"DESC\").describe(\"Sort direction\")\n}).describe(\"Order by configuration\");\nconst listMetricsArgsSchema = z.object({\n\tmode: listModeSchema.optional(),\n\tfilters: metricsFilterSchema.optional(),\n\tpagination: paginationArgsSchema.optional(),\n\torderBy: metricsOrderBySchema.optional(),\n\tafter: deltaCursorSchema.optional(),\n\tlimit: deltaLimitSchema\n}).strict().superRefine(refineObservabilityListMode).transform((value) => normalizeObservabilityListArgs(value, { orderBy: {\n\tfield: \"timestamp\",\n\tdirection: \"DESC\"\n} })).describe(\"Arguments for listing metrics\");\n/** Schema for listMetrics operation response */\nconst listMetricsResponseSchema = z.object({\n\tpagination: paginationInfoSchema.optional(),\n\tdelta: deltaInfoSchema.optional(),\n\tdeltaCursor: deltaCursorSchema.optional(),\n\tmetrics: z.array(metricRecordSchema)\n}).describe(\"Response from listing metrics\");\n/**\n* Columns eligible for `count_distinct`.\n*\n* Restricted to low/medium-cardinality categorical attributes. ID columns are\n* intentionally excluded — approximate distinct count over near-unique values\n* converges to the row count and is rarely a useful KPI.\n*/\nconst METRIC_DISTINCT_COLUMNS = [\n\t\"entityType\",\n\t\"entityName\",\n\t\"parentEntityType\",\n\t\"parentEntityName\",\n\t\"rootEntityType\",\n\t\"rootEntityName\",\n\t\"name\",\n\t\"provider\",\n\t\"model\",\n\t\"environment\",\n\t\"executionSource\",\n\t\"serviceName\",\n\t\"threadId\",\n\t\"resourceId\"\n];\nconst distinctColumnSchema = z.enum(METRIC_DISTINCT_COLUMNS).optional().describe(\"Column to apply count_distinct over (required when aggregation is 'count_distinct'). Restricted to allowlisted metric dimensions.\");\nconst requireDistinctColumnRefinement = {\n\tcheck: (data) => data.aggregation !== \"count_distinct\" || data.distinctColumn !== void 0,\n\toptions: {\n\t\tmessage: \"distinctColumn is required when aggregation is 'count_distinct'\",\n\t\tpath: [\"distinctColumn\"]\n\t}\n};\nconst getMetricAggregateArgsSchema = z.object({\n\tname: z.array(z.string()).nonempty().describe(\"Metric name(s) to aggregate\"),\n\taggregation: aggregationTypeSchema,\n\tdistinctColumn: distinctColumnSchema,\n\tfilters: metricsFilterSchema.optional(),\n\tcomparePeriod: comparePeriodSchema.optional()\n}).refine(requireDistinctColumnRefinement.check, requireDistinctColumnRefinement.options).describe(\"Arguments for getting a metric aggregate\");\nconst getMetricAggregateResponseSchema = z.object({\n\t...aggregateResponseFields,\n\testimatedCost: z.number().nullable().optional().describe(\"Aggregated estimated cost from the same filtered row set\"),\n\tcostUnit: z.string().nullable().optional().describe(\"Shared cost unit for the aggregated rows, or null when mixed/unknown\"),\n\tpreviousEstimatedCost: z.number().nullable().optional().describe(\"Aggregated estimated cost from the comparison period\"),\n\tcostChangePercent: z.number().nullable().optional().describe(\"Percentage change in estimated cost from comparison period\")\n});\nconst getMetricBreakdownArgsSchema = z.object({\n\tname: z.array(z.string()).nonempty().describe(\"Metric name(s) to break down\"),\n\tgroupBy: groupBySchema,\n\taggregation: aggregationTypeSchema,\n\tdistinctColumn: distinctColumnSchema,\n\tfilters: metricsFilterSchema.optional(),\n\tlimit: z.number().int().positive().max(1e3).optional().describe(\"Maximum number of groups to return (server-side TopK). Required for high-cardinality groupBy.\"),\n\torderDirection: sortDirectionSchema.optional().describe(\"Sort direction for the aggregated value (defaults to 'DESC' at the storage layer; pairs with limit for top/bottom-N).\")\n}).refine(requireDistinctColumnRefinement.check, requireDistinctColumnRefinement.options).describe(\"Arguments for getting a metric breakdown\");\nconst getMetricBreakdownResponseSchema = z.object({ groups: z.array(z.object({\n\tdimensions: dimensionsField,\n\tvalue: aggregatedValueField,\n\testimatedCost: z.number().nullable().optional().describe(\"Summed estimated cost for this group\"),\n\tcostUnit: z.string().nullable().optional().describe(\"Shared cost unit for this group, or null when mixed/unknown\")\n})) });\nconst getMetricTimeSeriesArgsSchema = z.object({\n\tname: z.array(z.string()).nonempty().describe(\"Metric name(s)\"),\n\tinterval: aggregationIntervalSchema,\n\taggregation: aggregationTypeSchema,\n\tdistinctColumn: distinctColumnSchema,\n\tfilters: metricsFilterSchema.optional(),\n\tgroupBy: groupBySchema.optional()\n}).refine(requireDistinctColumnRefinement.check, requireDistinctColumnRefinement.options).describe(\"Arguments for getting metric time series\");\nconst getMetricTimeSeriesResponseSchema = z.object({ series: z.array(z.object({\n\tname: z.string().describe(\"Series name (metric name or group key)\"),\n\tcostUnit: z.string().nullable().optional().describe(\"Shared cost unit for this series, or null when mixed/unknown\"),\n\tpoints: z.array(z.object({\n\t\ttimestamp: bucketTimestampField,\n\t\tvalue: aggregatedValueField,\n\t\testimatedCost: z.number().nullable().optional().describe(\"Summed estimated cost in this bucket\")\n\t}))\n})) });\nconst getMetricPercentilesArgsSchema = z.object({\n\tname: z.string().describe(\"Metric name\"),\n\tpercentiles: percentilesSchema,\n\tinterval: aggregationIntervalSchema,\n\tfilters: metricsFilterSchema.optional()\n}).describe(\"Arguments for getting metric percentiles\");\nconst getMetricPercentilesResponseSchema = z.object({ series: z.array(z.object({\n\tpercentile: percentileField,\n\tpoints: z.array(z.object({\n\t\ttimestamp: bucketTimestampField,\n\t\tvalue: percentileBucketValueField\n\t}))\n})) });\n//#endregion\n//#region src/storage/domains/observability/discovery.ts\nconst getMetricNamesArgsSchema = z.object({\n\tprefix: z.string().optional().describe(\"Filter metric names by prefix\"),\n\tlimit: z.coerce.number().int().min(1).optional().describe(\"Maximum number of names to return\")\n}).describe(\"Arguments for getting metric names\");\nconst getMetricNamesResponseSchema = z.object({ names: z.array(z.string()).describe(\"Distinct metric names\") });\nconst getMetricLabelKeysArgsSchema = z.object({ metricName: z.string().describe(\"Metric name to get label keys for\") }).describe(\"Arguments for getting metric label keys\");\nconst getMetricLabelKeysResponseSchema = z.object({ keys: z.array(z.string()).describe(\"Distinct label keys for the metric\") });\nconst getMetricLabelValuesArgsSchema = z.object({\n\tmetricName: z.string().describe(\"Metric name\"),\n\tlabelKey: z.string().describe(\"Label key to get values for\"),\n\tprefix: z.string().optional().describe(\"Filter values by prefix\"),\n\tlimit: z.coerce.number().int().min(1).optional().describe(\"Maximum number of values to return\")\n}).describe(\"Arguments for getting label values\");\nconst getMetricLabelValuesResponseSchema = z.object({ values: z.array(z.string()).describe(\"Distinct label values\") });\nconst getEntityTypesArgsSchema = z.object({}).describe(\"Arguments for getting entity types\");\nconst getEntityTypesResponseSchema = z.object({ entityTypes: z.array(entityTypeField).describe(\"Distinct entity types\") });\nconst getEntityNamesArgsSchema = z.object({ entityType: entityTypeField.optional().describe(\"Optional entity type filter\") }).describe(\"Arguments for getting entity names\");\nconst getEntityNamesResponseSchema = z.object({ names: z.array(z.string()).describe(\"Distinct entity names\") });\nconst getServiceNamesArgsSchema = z.object({}).describe(\"Arguments for getting service names\");\nconst getServiceNamesResponseSchema = z.object({ serviceNames: z.array(z.string()).describe(\"Distinct service names\") });\nconst getEnvironmentsArgsSchema = z.object({}).describe(\"Arguments for getting environments\");\nconst getEnvironmentsResponseSchema = z.object({ environments: z.array(z.string()).describe(\"Distinct environments\") });\nconst getTagsArgsSchema = z.object({ entityType: entityTypeField.optional().describe(\"Optional entity type filter\") }).describe(\"Arguments for getting tags\");\nconst getTagsResponseSchema = z.object({ tags: z.array(z.string()).describe(\"Distinct tags\") });\n//#endregion\nexport { EntityType, METRIC_DISTINCT_COLUMNS, aggregateResponseFields, aggregatedValueField, aggregationIntervalSchema, aggregationTypeSchema, batchCreateFeedbackArgsSchema, batchCreateLogsArgsSchema, batchCreateMetricsArgsSchema, batchCreateScoresArgsSchema, bucketTimestampField, commonFilterFields, comparePeriodSchema, contextFields, createFeedbackArgsSchema, createFeedbackBodySchema, createFeedbackRecordSchema, createFeedbackResponseSchema, createLogRecordSchema, createMetricRecordSchema, createScoreArgsSchema, createScoreBodySchema, createScoreRecordSchema, createScoreResponseSchema, createdAtField, dateRangeSchema, dbTimestamps, defaultDeltaLimit, defaultPaginationArgs, deltaCursorSchema, deltaInfoSchema, deltaLimitSchema, dimensionsField, distinctColumnSchema, entityIdField, entityNameField, entityTypeField, entityVersionIdField, environmentField, executionSourceField, experimentIdField, feedbackFilterSchema, feedbackInputSchema, feedbackOrderByFieldSchema, feedbackOrderBySchema, feedbackRecordSchema, getEntityNamesArgsSchema, getEntityNamesResponseSchema, getEntityTypesArgsSchema, getEntityTypesResponseSchema, getEnvironmentsArgsSchema, getEnvironmentsResponseSchema, getFeedbackAggregateArgsSchema, getFeedbackAggregateResponseSchema, getFeedbackBreakdownArgsSchema, getFeedbackBreakdownResponseSchema, getFeedbackPercentilesArgsSchema, getFeedbackPercentilesResponseSchema, getFeedbackTimeSeriesArgsSchema, getFeedbackTimeSeriesResponseSchema, getMetricAggregateArgsSchema, getMetricAggregateResponseSchema, getMetricBreakdownArgsSchema, getMetricBreakdownResponseSchema, getMetricLabelKeysArgsSchema, getMetricLabelKeysResponseSchema, getMetricLabelValuesArgsSchema, getMetricLabelValuesResponseSchema, getMetricNamesArgsSchema, getMetricNamesResponseSchema, getMetricPercentilesArgsSchema, getMetricPercentilesResponseSchema, getMetricTimeSeriesArgsSchema, getMetricTimeSeriesResponseSchema, getScoreAggregateArgsSchema, getScoreAggregateResponseSchema, getScoreBreakdownArgsSchema, getScoreBreakdownResponseSchema, getScorePercentilesArgsSchema, getScorePercentilesResponseSchema, getScoreTimeSeriesArgsSchema, getScoreTimeSeriesResponseSchema, getServiceNamesArgsSchema, getServiceNamesResponseSchema, getTagsArgsSchema, getTagsResponseSchema, groupBySchema, listFeedbackArgsSchema, listFeedbackResponseSchema, listLogsArgsSchema, listLogsResponseSchema, listMetricsArgsSchema, listMetricsResponseSchema, listModeSchema, listScoresArgsSchema, listScoresResponseSchema, logLevelSchema, logRecordInputSchema, logRecordSchema, logsFilterSchema, logsOrderByFieldSchema, logsOrderBySchema, metadataField, metricInputSchema, metricRecordSchema, metricTypeSchema, metricsAggregationSchema, metricsFilterSchema, metricsOrderByFieldSchema, metricsOrderBySchema, normalizeObservabilityListArgs, organizationIdField, paginationArgsSchema, paginationInfoSchema, parentEntityIdField, parentEntityNameField, parentEntityTypeField, parentEntityVersionIdField, percentileBucketValueField, percentileField, percentilesSchema, refineObservabilityListMode, requestIdField, resourceIdField, rootEntityIdField, rootEntityNameField, rootEntityTypeField, rootEntityVersionIdField, runIdField, scopeField, scoreInputSchema, scoreRecordSchema, scoresFilterSchema, scoresOrderByFieldSchema, scoresOrderBySchema, serviceNameField, sessionIdField, sortDirectionSchema, sourceField, spanContextFields, spanIdField, tagsField, threadIdField, traceIdField, updatedAtField, userIdField };\n\n//# sourceMappingURL=index.js.map","/**\n * Browser-safe observability utilities.\n *\n * Functions that depend on AsyncLocalStorage (getCurrentSpan, executeWithContext,\n * executeWithContextSync) are in context-storage.ts and should only be imported\n * by server-side code.\n */\n\nimport { EntityType, SpanType } from './types';\nimport type { Span, GetOrCreateSpanOptions, AnySpan } from './types';\n\nconst entityTypeValues = new Set<EntityType>(Object.values(EntityType));\nlet currentSpanResolver: (() => AnySpan | undefined) | undefined;\n\nexport function setCurrentSpanResolver(resolver: (() => AnySpan | undefined) | undefined): void {\n currentSpanResolver = resolver;\n}\n\nexport function resolveCurrentSpan(): AnySpan | undefined {\n return currentSpanResolver?.();\n}\n\n/** Generate a unique id for an observability signal (log, met