'use strict';

var chunkQOW24SR2_cjs = require('./chunk-QOW24SR2.cjs');
var chunkZNP74O27_cjs = require('./chunk-ZNP74O27.cjs');
var chunkZ7LCIYK7_cjs = require('./chunk-Z7LCIYK7.cjs');
var chunkN54Q3AQR_cjs = require('./chunk-N54Q3AQR.cjs');
var chunk64ITUOXI_cjs = require('./chunk-64ITUOXI.cjs');
var v4 = require('zod/v4');
var features = require('@mastra/core/features');
var observability = require('@mastra/core/observability');

var EntityType = /* @__PURE__ */ ((EntityType2) => {
  EntityType2["AGENT"] = "agent";
  EntityType2["SCORER"] = "scorer";
  EntityType2["RAG_INGESTION"] = "rag_ingestion";
  EntityType2["TRAJECTORY"] = "trajectory";
  EntityType2["INPUT_PROCESSOR"] = "input_processor";
  EntityType2["INPUT_STEP_PROCESSOR"] = "input_step_processor";
  EntityType2["OUTPUT_PROCESSOR"] = "output_processor";
  EntityType2["OUTPUT_STEP_PROCESSOR"] = "output_step_processor";
  EntityType2["WORKFLOW_STEP"] = "workflow_step";
  EntityType2["TOOL"] = "tool";
  EntityType2["WORKFLOW_RUN"] = "workflow_run";
  EntityType2["MEMORY"] = "memory";
  return EntityType2;
})(EntityType || {});
v4.z.date().describe("Database record creation time");
var updatedAtField = v4.z.date().describe("Database record last update time");
({
  updatedAt: updatedAtField.nullable()
});
var paginationArgsSchema2 = v4.z.object({
  page: v4.z.coerce.number().int().min(0).optional().default(0).describe("Zero-indexed page number"),
  perPage: v4.z.coerce.number().int().min(1).max(100).optional().default(10).describe("Number of items per page")
}).describe("Pagination options for list queries");
var paginationInfoSchema = v4.z.object({
  total: v4.z.number().describe("Total number of items available"),
  page: v4.z.number().describe("Current page"),
  perPage: v4.z.union([v4.z.number(), v4.z.literal(false)]).describe("Number of items per page, or false if pagination is disabled"),
  hasMore: v4.z.boolean().describe("True if more pages are available")
});
var deltaCursorSchema = v4.z.string().min(1).describe("Opaque cursor value for incremental polling");
var listModeSchema = v4.z.enum(["page", "delta"]).describe("List mode: 'page' | 'delta', defaults to 'page' when omitted.");
var deltaLimitSchema = v4.z.coerce.number().int().min(1).max(100).optional().describe("Maximum number of updates to return in one delta poll");
var defaultPaginationArgs = {
  page: 0,
  perPage: 10
};
var defaultDeltaLimit = 10;
function refineObservabilityListMode(value, ctx) {
  if (value.mode === "delta") {
    if (value.pagination !== void 0) {
      ctx.addIssue({ code: "custom", path: ["pagination"], message: "pagination is not allowed in delta mode" });
    }
    if (value.orderBy !== void 0) {
      ctx.addIssue({ code: "custom", path: ["orderBy"], message: "orderBy is not allowed in delta mode" });
    }
    return;
  }
  if (value.after !== void 0) {
    ctx.addIssue({ code: "custom", path: ["after"], message: "after is only allowed in delta mode" });
  }
  if (value.limit !== void 0) {
    ctx.addIssue({ code: "custom", path: ["limit"], message: "limit is only allowed in delta mode" });
  }
}
function normalizeObservabilityListArgs(value, defaults) {
  return {
    mode: value.mode === "delta" ? "delta" : "page",
    filters: value.filters,
    pagination: value.pagination ?? defaults.pagination ?? defaultPaginationArgs,
    orderBy: value.orderBy ?? defaults.orderBy,
    after: value.after,
    limit: value.limit ?? defaults.limit ?? defaultDeltaLimit
  };
}
var deltaInfoSchema = v4.z.object({
  limit: v4.z.number().describe("Maximum number of updates requested for this delta poll"),
  hasMore: v4.z.boolean().describe("True when more matching updates remain after this response")
}).describe("Incremental polling metadata");
var dateRangeSchema = v4.z.object({
  start: v4.z.coerce.date().optional().describe("Start of date range (inclusive by default)"),
  end: v4.z.coerce.date().optional().describe("End of date range (inclusive by default)"),
  startExclusive: v4.z.boolean().optional().describe("When true, excludes the start date from results (uses > instead of >=)"),
  endExclusive: v4.z.boolean().optional().describe("When true, excludes the end date from results (uses < instead of <=)")
}).describe("Date range filter for timestamps");
var sortDirectionSchema = v4.z.enum(["ASC", "DESC"]).describe("Sort direction: 'ASC' | 'DESC'");
var aggregationTypeSchema = v4.z.enum(["sum", "avg", "min", "max", "count", "count_distinct", "last"]).describe("Aggregation function");
var aggregationIntervalSchema = v4.z.enum(["1m", "5m", "15m", "1h", "1d"]).describe("Time bucket interval");
var comparePeriodSchema = v4.z.enum(["previous_period", "previous_day", "previous_week"]).describe("Comparison period for aggregate queries");
var groupBySchema = v4.z.array(v4.z.string()).min(1).describe("Fields to group by");
var percentilesSchema = v4.z.array(v4.z.number().min(0).max(1)).min(1).describe("Percentile values (0-1)");
var aggregateResponseFields = {
  value: v4.z.number().nullable().describe("Aggregated value"),
  previousValue: v4.z.number().nullable().optional().describe("Value from comparison period"),
  changePercent: v4.z.number().nullable().optional().describe("Percentage change from comparison period")
};
var dimensionsField = v4.z.record(v4.z.string(), v4.z.string().nullable()).describe("Dimension values for this group");
var aggregatedValueField = v4.z.number().describe("Aggregated value");
var bucketTimestampField = v4.z.date().describe("Bucket timestamp");
var percentileField = v4.z.number().describe("Percentile value");
var percentileBucketValueField = v4.z.number().describe("Percentile value at this bucket");
var entityTypeField = v4.z.nativeEnum(EntityType).describe(`Entity type (e.g., 'agent' | 'processor' | 'tool' | 'workflow')`);
var entityIdField = v4.z.string().describe('ID of the entity (e.g., "weatherAgent", "orderWorkflow")');
var entityNameField = v4.z.string().describe("Name of the entity");
var userIdField = v4.z.string().describe("Human end-user who triggered execution");
var organizationIdField = v4.z.string().describe("Multi-tenant organization/account");
var resourceIdField = v4.z.string().describe("Broader resource context (Mastra memory compatibility)");
var runIdField = v4.z.string().describe("Unique execution run identifier");
var sessionIdField = v4.z.string().describe("Session identifier for grouping traces");
var threadIdField = v4.z.string().describe("Conversation thread identifier");
var requestIdField = v4.z.string().describe("HTTP request ID for log correlation");
var environmentField = v4.z.string().describe(`Environment (e.g., "production" | "staging" | "development")`);
var sourceField = v4.z.string().describe(`Source of execution (e.g., "local" | "cloud" | "ci")`);
var executionSourceField = v4.z.string().describe(`Source of execution (e.g., "local" | "cloud" | "ci")`);
var serviceNameField = v4.z.string().describe("Name of the service");
var parentEntityTypeField = v4.z.nativeEnum(EntityType).describe("Entity type of the parent entity");
var parentEntityIdField = v4.z.string().describe("ID of the parent entity");
var parentEntityNameField = v4.z.string().describe("Name of the parent entity");
var rootEntityTypeField = v4.z.nativeEnum(EntityType).describe("Entity type of the root entity");
var rootEntityIdField = v4.z.string().describe("ID of the root entity");
var rootEntityNameField = v4.z.string().describe("Name of the root entity");
var entityVersionIdField = v4.z.string().describe("Version ID of the entity that produced this signal (e.g., agent version, workflow version)");
var parentEntityVersionIdField = v4.z.string().describe("Version ID of the parent entity that produced this signal");
var rootEntityVersionIdField = v4.z.string().describe("Version ID of the root entity that produced this signal");
var experimentIdField = v4.z.string().describe("Experiment or eval run identifier");
var scopeField = v4.z.record(v4.z.string(), v4.z.unknown()).describe('Arbitrary package/app version info (e.g., {"core": "1.0.0", "memory": "1.0.0", "gitSha": "abcd1234"})');
var metadataField = v4.z.record(v4.z.string(), v4.z.unknown()).describe("User-defined metadata for custom filtering");
var tagsField = v4.z.array(v4.z.string()).describe("Labels for filtering");
var contextFieldsBase = {
  // Entity identification
  entityType: entityTypeField.nullish(),
  entityId: entityIdField.nullish(),
  entityName: entityNameField.nullish(),
  // Parent entity hierarchy
  parentEntityType: parentEntityTypeField.nullish(),
  parentEntityId: parentEntityIdField.nullish(),
  parentEntityName: parentEntityNameField.nullish(),
  // Root entity hierarchy
  rootEntityType: rootEntityTypeField.nullish(),
  rootEntityId: rootEntityIdField.nullish(),
  rootEntityName: rootEntityNameField.nullish(),
  // Identity & tenancy
  userId: userIdField.nullish(),
  organizationId: organizationIdField.nullish(),
  resourceId: resourceIdField.nullish(),
  // Correlation IDs
  runId: runIdField.nullish(),
  sessionId: sessionIdField.nullish(),
  threadId: threadIdField.nullish(),
  requestId: requestIdField.nullish(),
  // Deployment context
  environment: environmentField.nullish(),
  serviceName: serviceNameField.nullish(),
  scope: scopeField.nullish(),
  // Entity versioning
  entityVersionId: entityVersionIdField.nullish(),
  parentEntityVersionId: parentEntityVersionIdField.nullish(),
  rootEntityVersionId: rootEntityVersionIdField.nullish(),
  // Experimentation
  experimentId: experimentIdField.nullish()
};
var contextFields = {
  ...contextFieldsBase,
  executionSource: executionSourceField.nullish(),
  tags: tagsField.nullish()
};
({
  source: sourceField.nullish()
});
var commonFilterFields = {
  timestamp: dateRangeSchema.optional().describe("Filter by timestamp range"),
  traceId: v4.z.string().optional().describe("Filter by trace ID"),
  spanId: v4.z.string().optional().describe("Filter by span ID"),
  entityType: entityTypeField.optional(),
  entityName: entityNameField.optional(),
  entityVersionId: entityVersionIdField.optional(),
  parentEntityVersionId: parentEntityVersionIdField.optional(),
  rootEntityVersionId: rootEntityVersionIdField.optional(),
  userId: userIdField.optional(),
  organizationId: organizationIdField.optional(),
  experimentId: experimentIdField.optional(),
  serviceName: serviceNameField.optional(),
  environment: environmentField.optional(),
  parentEntityType: parentEntityTypeField.optional(),
  parentEntityName: parentEntityNameField.optional(),
  rootEntityType: rootEntityTypeField.optional(),
  rootEntityName: rootEntityNameField.optional(),
  resourceId: resourceIdField.optional(),
  runId: runIdField.optional(),
  sessionId: sessionIdField.optional(),
  threadId: threadIdField.optional(),
  requestId: requestIdField.optional(),
  executionSource: executionSourceField.optional(),
  tags: v4.z.array(v4.z.string()).optional().describe("Filter by tags (must have all specified tags)")
};
var traceIdField = v4.z.string().describe("Unique trace identifier");
var spanIdField = v4.z.string().describe("Unique span identifier within a trace");
var logLevelSchema = v4.z.enum(["debug", "info", "warn", "error", "fatal"]);
var messageField = v4.z.string().describe("Log message");
var logDataField = v4.z.record(v4.z.string(), v4.z.unknown()).describe("Structured data attached to the log");
var logRecordSchema = v4.z.object({
  logId: v4.z.string().nullish().describe("Unique id for this log event"),
  timestamp: v4.z.date().describe("When the log was created"),
  level: logLevelSchema.describe("Log severity level"),
  message: messageField,
  data: logDataField.nullish(),
  // Correlation
  traceId: traceIdField.nullish(),
  spanId: spanIdField.nullish(),
  // Context fields
  ...contextFields,
  /**
   * @deprecated Use `executionSource` instead.
   */
  source: v4.z.string().nullish().describe("Execution source"),
  metadata: metadataField.nullish()
}).describe("Log record as stored in the database");
v4.z.object({
  level: logLevelSchema,
  message: messageField,
  data: logDataField.optional(),
  tags: tagsField.optional()
}).describe("User-provided log input");
var createLogRecordSchema = logRecordSchema;
v4.z.object({
  logs: v4.z.array(createLogRecordSchema)
}).describe("Arguments for batch creating logs");
var logsFilterSchema = v4.z.object({
  ...commonFilterFields,
  // Log-specific filters
  /**
   * @deprecated Use `executionSource` instead.
   */
  source: v4.z.string().optional().describe("Filter by execution source"),
  level: v4.z.union([logLevelSchema, v4.z.array(logLevelSchema)]).optional().describe("Filter by log level(s)")
}).describe("Filters for querying logs");
var logsOrderByFieldSchema = v4.z.enum(["timestamp"]).describe("Field to order by: 'timestamp'");
var logsOrderBySchema = v4.z.object({
  field: logsOrderByFieldSchema.default("timestamp").describe("Field to order by"),
  direction: sortDirectionSchema.default("DESC").describe("Sort direction")
}).describe("Order by configuration");
v4.z.object({
  mode: listModeSchema.optional(),
  filters: logsFilterSchema.optional().describe("Optional filters to apply"),
  pagination: paginationArgsSchema2.optional(),
  orderBy: logsOrderBySchema.optional(),
  after: deltaCursorSchema.optional(),
  limit: deltaLimitSchema
}).strict().superRefine(refineObservabilityListMode).transform(
  (value) => normalizeObservabilityListArgs(value, {
    orderBy: { field: "timestamp", direction: "DESC" }
  })
).describe("Arguments for listing logs");
var listLogsResponseSchema = v4.z.object({
  pagination: paginationInfoSchema.optional(),
  delta: deltaInfoSchema.optional(),
  deltaCursor: deltaCursorSchema.optional(),
  logs: v4.z.array(logRecordSchema)
}).describe("Response from listing logs");
var scorerIdField = v4.z.string().describe("Identifier of the scorer (e.g., relevance, accuracy)");
var scorerNameField = v4.z.string().describe("Display name of the scorer");
var scorerVersionField = v4.z.string().describe("Version of the scorer");
var scoreSourceField = v4.z.string().describe("How the score was produced (e.g., manual, automated, experiment)");
var scoreValueField = v4.z.number().describe("Score value (range defined by scorer)");
var scoreReasonField = v4.z.string().describe("Explanation for the score");
var scoreRecordSchema = v4.z.object({
  scoreId: v4.z.string().nullish().describe("Unique id for this score event"),
  timestamp: v4.z.date().describe("When the score was recorded"),
  // Target
  traceId: traceIdField.nullish().describe("Trace that anchors the scored target when available"),
  spanId: spanIdField.nullish().describe("Span ID this score applies to"),
  // Score data
  scorerId: scorerIdField,
  scorerName: scorerNameField.nullish(),
  scorerVersion: scorerVersionField.nullish(),
  scoreSource: scoreSourceField.nullish(),
  /**
   * @deprecated Use `scoreSource` instead.
   */
  source: scoreSourceField.nullish(),
  score: scoreValueField,
  reason: scoreReasonField.nullish(),
  // Context (entity hierarchy, identity, correlation, deployment, experimentation)
  ...contextFields,
  /** Trace ID of the scoring run (links to trace that generated this score) */
  scoreTraceId: v4.z.string().nullish().describe("Trace ID of the scoring run for debugging score generation"),
  // User-defined metadata (context fields stored here)
  metadata: v4.z.record(v4.z.string(), v4.z.unknown()).nullish().describe("User-defined metadata")
}).describe("Score record as stored in the database");
v4.z.object({
  scorerId: scorerIdField,
  scorerName: scorerNameField.optional(),
  scorerVersion: scorerVersionField.optional(),
  scoreSource: scoreSourceField.optional(),
  /**
   * @deprecated Use `scoreSource` instead.
   */
  source: scoreSourceField.optional(),
  score: scoreValueField,
  reason: scoreReasonField.optional(),
  metadata: v4.z.record(v4.z.string(), v4.z.unknown()).optional().describe("Additional scorer-specific metadata"),
  experimentId: experimentIdField.optional(),
  scoreTraceId: v4.z.string().optional().describe("Trace ID of the scoring run for debugging score generation"),
  targetEntityType: entityTypeField.optional().describe("Entity type the scorer evaluated when known")
}).describe("User-provided score input");
var createScoreRecordSchema = scoreRecordSchema;
v4.z.object({
  score: createScoreRecordSchema
}).describe("Arguments for creating a score");
var createScoreBodySchema = v4.z.object({
  score: createScoreRecordSchema.omit({ timestamp: true })
}).describe("Arguments for creating a score");
var createScoreResponseSchema = v4.z.object({ success: v4.z.boolean() }).describe("Response from creating a score");
v4.z.object({
  scores: v4.z.array(createScoreRecordSchema)
}).describe("Arguments for batch recording scores");
var scoresFilterSchema = v4.z.object({
  ...commonFilterFields,
  // Score-specific filters
  scorerId: v4.z.union([v4.z.string(), v4.z.array(v4.z.string())]).optional().describe("Filter by scorer ID(s)"),
  scoreSource: scoreSourceField.optional().describe("Filter by how the score was produced"),
  /**
   * @deprecated Use `scoreSource` instead.
   */
  source: scoreSourceField.optional().describe("Filter by how the score was produced")
}).describe("Filters for querying scores");
var scoresOrderByFieldSchema = v4.z.enum(["timestamp", "score"]).describe("Field to order by: 'timestamp' | 'score'");
var scoresOrderBySchema = v4.z.object({
  field: scoresOrderByFieldSchema.default("timestamp").describe("Field to order by"),
  direction: sortDirectionSchema.default("DESC").describe("Sort direction")
}).describe("Order by configuration");
v4.z.object({
  mode: listModeSchema.optional(),
  filters: scoresFilterSchema.optional(),
  pagination: paginationArgsSchema2.optional(),
  orderBy: scoresOrderBySchema.optional(),
  after: deltaCursorSchema.optional(),
  limit: deltaLimitSchema
}).strict().superRefine(refineObservabilityListMode).transform(
  (value) => normalizeObservabilityListArgs(value, {
    orderBy: { field: "timestamp", direction: "DESC" }
  })
).describe("Arguments for listing scores");
var listScoresResponseSchema = v4.z.object({
  pagination: paginationInfoSchema.optional(),
  delta: deltaInfoSchema.optional(),
  deltaCursor: deltaCursorSchema.optional(),
  scores: v4.z.array(scoreRecordSchema)
}).describe("Response from listing scores");
var getScoreAggregateArgsSchema = v4.z.object({
  scorerId: scorerIdField,
  scoreSource: scoreSourceField.optional(),
  aggregation: aggregationTypeSchema,
  filters: scoresFilterSchema.optional(),
  comparePeriod: comparePeriodSchema.optional()
}).describe("Arguments for getting a score aggregate");
var getScoreAggregateResponseSchema = v4.z.object(aggregateResponseFields);
var getScoreBreakdownArgsSchema = v4.z.object({
  scorerId: scorerIdField,
  scoreSource: scoreSourceField.optional(),
  groupBy: groupBySchema,
  aggregation: aggregationTypeSchema,
  filters: scoresFilterSchema.optional()
}).describe("Arguments for getting a score breakdown");
var getScoreBreakdownResponseSchema = v4.z.object({
  groups: v4.z.array(
    v4.z.object({
      dimensions: dimensionsField,
      value: aggregatedValueField
    })
  )
});
var getScoreTimeSeriesArgsSchema = v4.z.object({
  scorerId: scorerIdField,
  scoreSource: scoreSourceField.optional(),
  interval: aggregationIntervalSchema,
  aggregation: aggregationTypeSchema,
  filters: scoresFilterSchema.optional(),
  groupBy: groupBySchema.optional()
}).describe("Arguments for getting score time series");
var getScoreTimeSeriesResponseSchema = v4.z.object({
  series: v4.z.array(
    v4.z.object({
      name: v4.z.string().describe("Series name (scorer ID or group key)"),
      points: v4.z.array(
        v4.z.object({
          timestamp: bucketTimestampField,
          value: aggregatedValueField
        })
      )
    })
  )
});
var getScorePercentilesArgsSchema = v4.z.object({
  scorerId: scorerIdField,
  scoreSource: scoreSourceField.optional(),
  percentiles: percentilesSchema,
  interval: aggregationIntervalSchema,
  filters: scoresFilterSchema.optional()
}).describe("Arguments for getting score percentiles");
var getScorePercentilesResponseSchema = v4.z.object({
  series: v4.z.array(
    v4.z.object({
      percentile: percentileField,
      points: v4.z.array(
        v4.z.object({
          timestamp: bucketTimestampField,
          value: percentileBucketValueField
        })
      )
    })
  )
});
var feedbackSourceField = v4.z.string().describe("Source of feedback (e.g., 'user', 'system', 'manual')");
var feedbackTypeField = v4.z.string().describe("Type of feedback (e.g., 'thumbs', 'rating', 'correction')");
var feedbackValueField = v4.z.union([v4.z.number(), v4.z.string()]).describe("Feedback value (rating number or correction text)");
var feedbackCommentField = v4.z.string().describe("Additional comment or context");
var feedbackUserIdField = v4.z.string().describe("User who provided the feedback");
function normalizeLegacyFeedbackActor(input) {
  if (!input || typeof input !== "object" || Array.isArray(input)) {
    return input;
  }
  const record = { ...input };
  if (typeof record.userId === "string" && record.feedbackUserId == null) {
    record.feedbackUserId = record.userId;
    delete record.userId;
  }
  return record;
}
var feedbackRecordObjectSchema = v4.z.object({
  feedbackId: v4.z.string().nullish().describe("Unique id for this feedback event"),
  timestamp: v4.z.date().describe("When the feedback was recorded"),
  // Target
  traceId: traceIdField.nullish().describe("Trace that anchors the feedback target when available"),
  spanId: spanIdField.nullish().describe("Span ID this feedback applies to"),
  // Feedback data
  feedbackSource: feedbackSourceField.nullish(),
  /**
   * @deprecated Use `feedbackSource` instead.
   */
  source: feedbackSourceField.nullish(),
  feedbackType: feedbackTypeField,
  value: feedbackValueField,
  comment: feedbackCommentField.nullish(),
  // Feedback actor identity
  feedbackUserId: feedbackUserIdField.nullish(),
  // Context (entity hierarchy, identity, correlation, deployment, experimentation)
  ...contextFields,
  // Source linkage (e.g. dataset item result ID)
  sourceId: v4.z.string().nullish().describe("ID of the source record this feedback is linked to (e.g. experiment result ID)"),
  // User-defined metadata (context fields stored here)
  metadata: v4.z.record(v4.z.string(), v4.z.unknown()).nullish().describe("User-defined metadata")
});
var feedbackRecordSchema = v4.z.object(feedbackRecordObjectSchema.shape).describe("Feedback record as stored in the database");
var feedbackInputObjectSchema = v4.z.object({
  feedbackSource: feedbackSourceField.optional(),
  /**
   * @deprecated Use `feedbackSource` instead.
   */
  source: feedbackSourceField.optional(),
  feedbackType: feedbackTypeField,
  value: feedbackValueField,
  comment: feedbackCommentField.optional(),
  feedbackUserId: feedbackUserIdField.optional(),
  /**
   * @deprecated Use `feedbackUserId` instead.
   */
  userId: feedbackUserIdField.optional(),
  metadata: v4.z.record(v4.z.string(), v4.z.unknown()).optional().describe("Additional feedback-specific metadata"),
  experimentId: experimentIdField.optional(),
  sourceId: v4.z.string().optional().describe("ID of the source record this feedback is linked to")
});
v4.z.object(feedbackInputObjectSchema.shape).describe("User-provided feedback input");
v4.z.object({
  feedback: v4.z.preprocess(normalizeLegacyFeedbackActor, feedbackRecordObjectSchema)
}).describe("Arguments for creating feedback");
var createFeedbackBodySchema = v4.z.object({
  feedback: feedbackRecordObjectSchema.omit({ timestamp: true })
}).describe("Arguments for creating feedback");
var createFeedbackResponseSchema = v4.z.object({ success: v4.z.boolean() }).describe("Response from creating feedback");
v4.z.object({
  feedbacks: v4.z.array(v4.z.preprocess(normalizeLegacyFeedbackActor, feedbackRecordObjectSchema))
}).describe("Arguments for batch recording feedback");
var feedbackFilterObjectSchema = v4.z.object({
  ...commonFilterFields,
  // Feedback-specific filters
  feedbackType: v4.z.union([v4.z.string(), v4.z.array(v4.z.string())]).optional().describe("Filter by feedback type(s)"),
  feedbackSource: feedbackSourceField.optional(),
  /**
   * @deprecated Use `feedbackSource` instead.
   */
  source: feedbackSourceField.optional(),
  feedbackUserId: feedbackUserIdField.optional()
});
var feedbackFilterSchema = v4.z.object(feedbackFilterObjectSchema.shape).describe("Filters for querying feedback");
var feedbackOrderByFieldSchema = v4.z.enum(["timestamp"]).describe("Field to order by: 'timestamp'");
var feedbackOrderBySchema = v4.z.object({
  field: feedbackOrderByFieldSchema.default("timestamp").describe("Field to order by"),
  direction: sortDirectionSchema.default("DESC").describe("Sort direction")
}).describe("Order by configuration");
v4.z.object({
  mode: listModeSchema.optional(),
  filters: v4.z.preprocess(normalizeLegacyFeedbackActor, feedbackFilterObjectSchema).optional(),
  pagination: paginationArgsSchema2.optional(),
  orderBy: feedbackOrderBySchema.optional(),
  after: deltaCursorSchema.optional(),
  limit: deltaLimitSchema
}).strict().superRefine(refineObservabilityListMode).transform(
  (value) => normalizeObservabilityListArgs(value, {
    orderBy: { field: "timestamp", direction: "DESC" }
  })
).describe("Arguments for listing feedback");
var listFeedbackResponseSchema = v4.z.object({
  pagination: paginationInfoSchema.optional(),
  delta: deltaInfoSchema.optional(),
  deltaCursor: deltaCursorSchema.optional(),
  feedback: v4.z.array(feedbackRecordSchema)
}).describe("Response from listing feedback");
var getFeedbackAggregateArgsSchema = v4.z.object({
  feedbackType: feedbackTypeField,
  feedbackSource: feedbackSourceField.optional(),
  aggregation: aggregationTypeSchema,
  filters: feedbackFilterSchema.optional(),
  comparePeriod: comparePeriodSchema.optional()
}).describe("Arguments for getting a feedback aggregate over numeric values");
var getFeedbackAggregateResponseSchema = v4.z.object(aggregateResponseFields);
var getFeedbackBreakdownArgsSchema = v4.z.object({
  feedbackType: feedbackTypeField,
  feedbackSource: feedbackSourceField.optional(),
  groupBy: groupBySchema,
  aggregation: aggregationTypeSchema,
  filters: feedbackFilterSchema.optional()
}).describe("Arguments for getting a feedback breakdown over numeric values");
var getFeedbackBreakdownResponseSchema = v4.z.object({
  groups: v4.z.array(
    v4.z.object({
      dimensions: dimensionsField,
      value: aggregatedValueField
    })
  )
});
var getFeedbackTimeSeriesArgsSchema = v4.z.object({
  feedbackType: feedbackTypeField,
  feedbackSource: feedbackSourceField.optional(),
  interval: aggregationIntervalSchema,
  aggregation: aggregationTypeSchema,
  filters: feedbackFilterSchema.optional(),
  groupBy: groupBySchema.optional()
}).describe("Arguments for getting feedback time series over numeric values");
var getFeedbackTimeSeriesResponseSchema = v4.z.object({
  series: v4.z.array(
    v4.z.object({
      name: v4.z.string().describe("Series name (feedback type or group key)"),
      points: v4.z.array(
        v4.z.object({
          timestamp: bucketTimestampField,
          value: aggregatedValueField
        })
      )
    })
  )
});
var getFeedbackPercentilesArgsSchema = v4.z.object({
  feedbackType: feedbackTypeField,
  feedbackSource: feedbackSourceField.optional(),
  percentiles: percentilesSchema,
  interval: aggregationIntervalSchema,
  filters: feedbackFilterSchema.optional()
}).describe("Arguments for getting feedback percentiles over numeric values");
var getFeedbackPercentilesResponseSchema = v4.z.object({
  series: v4.z.array(
    v4.z.object({
      percentile: percentileField,
      points: v4.z.array(
        v4.z.object({
          timestamp: bucketTimestampField,
          value: percentileBucketValueField
        })
      )
    })
  )
});
v4.z.enum(["counter", "gauge", "histogram"]);
var metricNameField = v4.z.string().describe("Metric name (e.g., mastra_agent_duration_ms)");
var metricValueField = v4.z.number().describe("Metric value");
var labelsField = v4.z.record(v4.z.string(), v4.z.string()).describe("Metric labels for dimensional filtering");
var providerField = v4.z.string().describe("Model provider");
var modelField = v4.z.string().describe("Model");
var estimatedCostField = v4.z.number().describe("Estimated cost");
var costUnitField = v4.z.string().describe("Unit for the estimated cost (e.g., usd)");
var costMetadField = v4.z.record(v4.z.string(), v4.z.unknown()).nullish().describe("Structured costing metadata");
var metricRecordSchema = v4.z.object({
  metricId: v4.z.string().nullish().describe("Unique id for this metric event"),
  timestamp: v4.z.date().describe("When the metric was recorded"),
  name: metricNameField,
  value: metricValueField,
  // Correlation
  traceId: traceIdField.nullish(),
  spanId: spanIdField.nullish(),
  // Context (entity hierarchy, identity, correlation, deployment, experimentation)
  ...contextFields,
  /**
   * @deprecated Use `executionSource` instead.
   */
  source: v4.z.string().nullish().describe("Execution source"),
  // Canonical costing fields
  provider: providerField.nullish(),
  model: modelField.nullish(),
  // Estimated cost related fields
  estimatedCost: estimatedCostField.nullish(),
  costUnit: costUnitField.nullish(),
  costMetadata: costMetadField.nullish(),
  // User-defined labels used for filtering
  labels: labelsField.default({}),
  // User-defined metadata
  metadata: metadataField.nullish()
}).describe("Metric record as stored in the database");
v4.z.object({
  name: metricNameField,
  value: metricValueField,
  labels: labelsField.optional()
}).describe("User-provided metric input");
var createMetricRecordSchema = metricRecordSchema;
v4.z.object({
  metrics: v4.z.array(createMetricRecordSchema)
}).describe("Arguments for batch recording metrics");
v4.z.object({
  type: aggregationTypeSchema,
  interval: aggregationIntervalSchema.optional(),
  groupBy: groupBySchema.optional()
}).describe("Metrics aggregation configuration");
var metricsFilterSchema = v4.z.object({
  ...commonFilterFields,
  // Metric identification
  name: v4.z.array(v4.z.string()).nonempty().optional().describe("Filter by metric name(s)"),
  /**
   * @deprecated Use `executionSource` instead.
   */
  source: v4.z.string().optional().describe("Filter by execution source"),
  // Canonical costing filters
  provider: providerField.optional(),
  model: modelField.optional(),
  costUnit: costUnitField.optional(),
  // Label filters (exact match on label values)
  labels: v4.z.record(v4.z.string(), v4.z.string()).optional().describe("Exact match on label key-value pairs")
}).describe("Filters for querying metrics");
var metricsOrderByFieldSchema = v4.z.enum(["timestamp"]).describe("Field to order by: 'timestamp'");
var metricsOrderBySchema = v4.z.object({
  field: metricsOrderByFieldSchema.default("timestamp").describe("Field to order by"),
  direction: sortDirectionSchema.default("DESC").describe("Sort direction")
}).describe("Order by configuration");
v4.z.object({
  mode: listModeSchema.optional(),
  filters: metricsFilterSchema.optional(),
  pagination: paginationArgsSchema2.optional(),
  orderBy: metricsOrderBySchema.optional(),
  after: deltaCursorSchema.optional(),
  limit: deltaLimitSchema
}).strict().superRefine(refineObservabilityListMode).transform(
  (value) => normalizeObservabilityListArgs(value, {
    orderBy: { field: "timestamp", direction: "DESC" }
  })
).describe("Arguments for listing metrics");
var listMetricsResponseSchema = v4.z.object({
  pagination: paginationInfoSchema.optional(),
  delta: deltaInfoSchema.optional(),
  deltaCursor: deltaCursorSchema.optional(),
  metrics: v4.z.array(metricRecordSchema)
}).describe("Response from listing metrics");
var METRIC_DISTINCT_COLUMNS = [
  "entityType",
  "entityName",
  "parentEntityType",
  "parentEntityName",
  "rootEntityType",
  "rootEntityName",
  "name",
  "provider",
  "model",
  "environment",
  "executionSource",
  "serviceName",
  "threadId",
  "resourceId"
];
var distinctColumnSchema = v4.z.enum(METRIC_DISTINCT_COLUMNS).optional().describe(
  "Column to apply count_distinct over (required when aggregation is 'count_distinct'). Restricted to allowlisted metric dimensions."
);
var requireDistinctColumnRefinement = {
  check: (data) => data.aggregation !== "count_distinct" || data.distinctColumn !== void 0,
  options: {
    message: "distinctColumn is required when aggregation is 'count_distinct'",
    path: ["distinctColumn"]
  }
};
var getMetricAggregateArgsSchema = v4.z.object({
  name: v4.z.array(v4.z.string()).nonempty().describe("Metric name(s) to aggregate"),
  aggregation: aggregationTypeSchema,
  distinctColumn: distinctColumnSchema,
  filters: metricsFilterSchema.optional(),
  comparePeriod: comparePeriodSchema.optional()
}).refine(requireDistinctColumnRefinement.check, requireDistinctColumnRefinement.options).describe("Arguments for getting a metric aggregate");
var getMetricAggregateResponseSchema = v4.z.object({
  ...aggregateResponseFields,
  estimatedCost: v4.z.number().nullable().optional().describe("Aggregated estimated cost from the same filtered row set"),
  costUnit: v4.z.string().nullable().optional().describe("Shared cost unit for the aggregated rows, or null when mixed/unknown"),
  previousEstimatedCost: v4.z.number().nullable().optional().describe("Aggregated estimated cost from the comparison period"),
  costChangePercent: v4.z.number().nullable().optional().describe("Percentage change in estimated cost from comparison period")
});
var getMetricBreakdownArgsSchema = v4.z.object({
  name: v4.z.array(v4.z.string()).nonempty().describe("Metric name(s) to break down"),
  groupBy: groupBySchema,
  aggregation: aggregationTypeSchema,
  distinctColumn: distinctColumnSchema,
  filters: metricsFilterSchema.optional(),
  limit: v4.z.number().int().positive().max(1e3).optional().describe("Maximum number of groups to return (server-side TopK). Required for high-cardinality groupBy."),
  orderDirection: sortDirectionSchema.optional().describe(
    "Sort direction for the aggregated value (defaults to 'DESC' at the storage layer; pairs with limit for top/bottom-N)."
  )
}).refine(requireDistinctColumnRefinement.check, requireDistinctColumnRefinement.options).describe("Arguments for getting a metric breakdown");
var getMetricBreakdownResponseSchema = v4.z.object({
  groups: v4.z.array(
    v4.z.object({
      dimensions: dimensionsField,
      value: aggregatedValueField,
      estimatedCost: v4.z.number().nullable().optional().describe("Summed estimated cost for this group"),
      costUnit: v4.z.string().nullable().optional().describe("Shared cost unit for this group, or null when mixed/unknown")
    })
  )
});
var getMetricTimeSeriesArgsSchema = v4.z.object({
  name: v4.z.array(v4.z.string()).nonempty().describe("Metric name(s)"),
  interval: aggregationIntervalSchema,
  aggregation: aggregationTypeSchema,
  distinctColumn: distinctColumnSchema,
  filters: metricsFilterSchema.optional(),
  groupBy: groupBySchema.optional()
}).refine(requireDistinctColumnRefinement.check, requireDistinctColumnRefinement.options).describe("Arguments for getting metric time series");
var getMetricTimeSeriesResponseSchema = v4.z.object({
  series: v4.z.array(
    v4.z.object({
      name: v4.z.string().describe("Series name (metric name or group key)"),
      costUnit: v4.z.string().nullable().optional().describe("Shared cost unit for this series, or null when mixed/unknown"),
      points: v4.z.array(
        v4.z.object({
          timestamp: bucketTimestampField,
          value: aggregatedValueField,
          estimatedCost: v4.z.number().nullable().optional().describe("Summed estimated cost in this bucket")
        })
      )
    })
  )
});
var getMetricPercentilesArgsSchema = v4.z.object({
  name: v4.z.string().describe("Metric name"),
  percentiles: percentilesSchema,
  interval: aggregationIntervalSchema,
  filters: metricsFilterSchema.optional()
}).describe("Arguments for getting metric percentiles");
var getMetricPercentilesResponseSchema = v4.z.object({
  series: v4.z.array(
    v4.z.object({
      percentile: percentileField,
      points: v4.z.array(
        v4.z.object({
          timestamp: bucketTimestampField,
          value: percentileBucketValueField
        })
      )
    })
  )
});
var getMetricNamesArgsSchema = v4.z.object({
  prefix: v4.z.string().optional().describe("Filter metric names by prefix"),
  limit: v4.z.coerce.number().int().min(1).optional().describe("Maximum number of names to return")
}).describe("Arguments for getting metric names");
var getMetricNamesResponseSchema = v4.z.object({
  names: v4.z.array(v4.z.string()).describe("Distinct metric names")
});
var getMetricLabelKeysArgsSchema = v4.z.object({
  metricName: v4.z.string().describe("Metric name to get label keys for")
}).describe("Arguments for getting metric label keys");
var getMetricLabelKeysResponseSchema = v4.z.object({
  keys: v4.z.array(v4.z.string()).describe("Distinct label keys for the metric")
});
var getMetricLabelValuesArgsSchema = v4.z.object({
  metricName: v4.z.string().describe("Metric name"),
  labelKey: v4.z.string().describe("Label key to get values for"),
  prefix: v4.z.string().optional().describe("Filter values by prefix"),
  limit: v4.z.coerce.number().int().min(1).optional().describe("Maximum number of values to return")
}).describe("Arguments for getting label values");
var getMetricLabelValuesResponseSchema = v4.z.object({
  values: v4.z.array(v4.z.string()).describe("Distinct label values")
});
v4.z.object({}).describe("Arguments for getting entity types");
var getEntityTypesResponseSchema = v4.z.object({
  entityTypes: v4.z.array(entityTypeField).describe("Distinct entity types")
});
var getEntityNamesArgsSchema = v4.z.object({
  entityType: entityTypeField.optional().describe("Optional entity type filter")
}).describe("Arguments for getting entity names");
var getEntityNamesResponseSchema = v4.z.object({
  names: v4.z.array(v4.z.string()).describe("Distinct entity names")
});
v4.z.object({}).describe("Arguments for getting service names");
var getServiceNamesResponseSchema = v4.z.object({
  serviceNames: v4.z.array(v4.z.string()).describe("Distinct service names")
});
v4.z.object({}).describe("Arguments for getting environments");
var getEnvironmentsResponseSchema = v4.z.object({
  environments: v4.z.array(v4.z.string()).describe("Distinct environments")
});
var getTagsArgsSchema = v4.z.object({
  entityType: entityTypeField.optional().describe("Optional entity type filter")
}).describe("Arguments for getting tags");
var getTagsResponseSchema = v4.z.object({
  tags: v4.z.array(v4.z.string()).describe("Distinct tags")
});
function createNewRoute(def, config) {
  const { handler, ...schemas } = config;
  return chunkN54Q3AQR_cjs.createRoute({
    ...def,
    ...schemas,
    responseType: "json",
    tags: ["Observability"],
    requiresAuth: true,
    handler: (async (params) => {
      try {
        if (!features.coreFeatures.has("observability:v1.13.2")) {
          throw new chunk64ITUOXI_cjs.HTTPException(501, {
            message: "New observability endpoints require @mastra/core >= 1.13.2, please upgrade."
          });
        }
        return await handler(params);
      } catch (error) {
        return chunkZ7LCIYK7_cjs.handleError(error, `Error calling: '${def.summary.toLocaleLowerCase()}'`);
      }
    })
  });
}
var LIST_LOGS = createNewRoute(chunkQOW24SR2_cjs.NEW_ROUTE_DEFS.LIST_LOGS, {
  queryParamSchema: chunkQOW24SR2_cjs.createObservabilityListQuerySchema(logsFilterSchema, logsOrderBySchema),
  responseSchema: listLogsResponseSchema,
  handler: async ({ mastra, mode, after, limit, ...params }) => {
    const filters = chunkN54Q3AQR_cjs.pickParams(logsFilterSchema, params);
    const observabilityStore = await chunkQOW24SR2_cjs.getObservabilityStore(mastra);
    if (mode === "delta") {
      chunkQOW24SR2_cjs.assertObservabilityDeltaSupported(observabilityStore, chunkQOW24SR2_cjs.OBSERVABILITY_LIST_ENDPOINTS.logs);
      return await observabilityStore.listLogs({
        mode,
        filters,
        after: typeof after === "string" ? after : void 0,
        limit
      });
    }
    const pagination = chunkN54Q3AQR_cjs.pickParams(chunkZNP74O27_cjs.paginationArgsSchema, params);
    const orderBy = chunkN54Q3AQR_cjs.pickParams(logsOrderBySchema, params);
    return await observabilityStore.listLogs(
      mode === "page" ? { mode, filters, pagination, orderBy } : { filters, pagination, orderBy }
    );
  }
});
var LIST_SCORES = createNewRoute(chunkQOW24SR2_cjs.NEW_ROUTE_DEFS.LIST_SCORES, {
  queryParamSchema: chunkQOW24SR2_cjs.createObservabilityListQuerySchema(scoresFilterSchema, scoresOrderBySchema),
  responseSchema: listScoresResponseSchema,
  handler: async ({ mastra, mode, after, limit, ...params }) => {
    const filters = chunkN54Q3AQR_cjs.pickParams(scoresFilterSchema, params);
    const observabilityStore = await chunkQOW24SR2_cjs.getObservabilityStore(mastra);
    if (mode === "delta") {
      chunkQOW24SR2_cjs.assertObservabilityDeltaSupported(observabilityStore, chunkQOW24SR2_cjs.OBSERVABILITY_LIST_ENDPOINTS.scores);
      return await observabilityStore.listScores({
        mode,
        filters,
        after: typeof after === "string" ? after : void 0,
        limit
      });
    }
    const pagination = chunkN54Q3AQR_cjs.pickParams(chunkZNP74O27_cjs.paginationArgsSchema, params);
    const orderBy = chunkN54Q3AQR_cjs.pickParams(scoresOrderBySchema, params);
    return await observabilityStore.listScores(
      mode === "page" ? { mode, filters, pagination, orderBy } : { filters, pagination, orderBy }
    );
  }
});
var CREATE_SCORE = createNewRoute(chunkQOW24SR2_cjs.NEW_ROUTE_DEFS.CREATE_SCORE, {
  bodySchema: createScoreBodySchema,
  responseSchema: createScoreResponseSchema,
  handler: async ({ mastra, score }) => {
    const observabilityStore = await chunkQOW24SR2_cjs.getObservabilityStore(mastra);
    await observabilityStore.createScore({
      score: { ...score, scoreId: score.scoreId ?? observability.generateSignalId(), timestamp: /* @__PURE__ */ new Date() }
    });
    return { success: true };
  }
});
var GET_SCORE = createNewRoute(chunkQOW24SR2_cjs.NEW_ROUTE_DEFS.GET_SCORE, {
  pathParamSchema: v4.z.object({ scoreId: v4.z.string() }),
  responseSchema: v4.z.object({ score: scoreRecordSchema.nullable() }),
  handler: async ({ mastra, scoreId }) => {
    const observabilityStore = await chunkQOW24SR2_cjs.getObservabilityStore(mastra);
    const score = await observabilityStore.getScoreById(scoreId);
    return { score: score ?? null };
  }
});
var GET_SCORE_AGGREGATE = createNewRoute(chunkQOW24SR2_cjs.NEW_ROUTE_DEFS.GET_SCORE_AGGREGATE, {
  bodySchema: getScoreAggregateArgsSchema,
  responseSchema: getScoreAggregateResponseSchema,
  handler: async ({ mastra, ...params }) => {
    const args = chunkN54Q3AQR_cjs.pickParams(getScoreAggregateArgsSchema, params);
    const observabilityStore = await chunkQOW24SR2_cjs.getObservabilityStore(mastra);
    return await observabilityStore.getScoreAggregate(args);
  }
});
var GET_SCORE_BREAKDOWN = createNewRoute(chunkQOW24SR2_cjs.NEW_ROUTE_DEFS.GET_SCORE_BREAKDOWN, {
  bodySchema: getScoreBreakdownArgsSchema,
  responseSchema: getScoreBreakdownResponseSchema,
  handler: async ({ mastra, ...params }) => {
    const args = chunkN54Q3AQR_cjs.pickParams(getScoreBreakdownArgsSchema, params);
    const observabilityStore = await chunkQOW24SR2_cjs.getObservabilityStore(mastra);
    return await observabilityStore.getScoreBreakdown(args);
  }
});
var GET_SCORE_TIME_SERIES = createNewRoute(chunkQOW24SR2_cjs.NEW_ROUTE_DEFS.GET_SCORE_TIME_SERIES, {
  bodySchema: getScoreTimeSeriesArgsSchema,
  responseSchema: getScoreTimeSeriesResponseSchema,
  handler: async ({ mastra, ...params }) => {
    const args = chunkN54Q3AQR_cjs.pickParams(getScoreTimeSeriesArgsSchema, params);
    const observabilityStore = await chunkQOW24SR2_cjs.getObservabilityStore(mastra);
    return await observabilityStore.getScoreTimeSeries(args);
  }
});
var GET_SCORE_PERCENTILES = createNewRoute(chunkQOW24SR2_cjs.NEW_ROUTE_DEFS.GET_SCORE_PERCENTILES, {
  bodySchema: getScorePercentilesArgsSchema,
  responseSchema: getScorePercentilesResponseSchema,
  handler: async ({ mastra, ...params }) => {
    const args = chunkN54Q3AQR_cjs.pickParams(getScorePercentilesArgsSchema, params);
    const observabilityStore = await chunkQOW24SR2_cjs.getObservabilityStore(mastra);
    return await observabilityStore.getScorePercentiles(args);
  }
});
var LIST_FEEDBACK = createNewRoute(chunkQOW24SR2_cjs.NEW_ROUTE_DEFS.LIST_FEEDBACK, {
  queryParamSchema: chunkQOW24SR2_cjs.createObservabilityListQuerySchema(feedbackFilterSchema, feedbackOrderBySchema),
  responseSchema: listFeedbackResponseSchema,
  handler: async ({ mastra, mode, after, limit, ...params }) => {
    const filters = chunkN54Q3AQR_cjs.pickParams(feedbackFilterSchema, params);
    const observabilityStore = await chunkQOW24SR2_cjs.getObservabilityStore(mastra);
    if (mode === "delta") {
      chunkQOW24SR2_cjs.assertObservabilityDeltaSupported(observabilityStore, chunkQOW24SR2_cjs.OBSERVABILITY_LIST_ENDPOINTS.feedback);
      return await observabilityStore.listFeedback({
        mode,
        filters,
        after: typeof after === "string" ? after : void 0,
        limit
      });
    }
    const pagination = chunkN54Q3AQR_cjs.pickParams(chunkZNP74O27_cjs.paginationArgsSchema, params);
    const orderBy = chunkN54Q3AQR_cjs.pickParams(feedbackOrderBySchema, params);
    return await observabilityStore.listFeedback(
      mode === "page" ? { mode, filters, pagination, orderBy } : { filters, pagination, orderBy }
    );
  }
});
var CREATE_FEEDBACK = createNewRoute(chunkQOW24SR2_cjs.NEW_ROUTE_DEFS.CREATE_FEEDBACK, {
  bodySchema: createFeedbackBodySchema,
  responseSchema: createFeedbackResponseSchema,
  handler: async ({ mastra, feedback }) => {
    const observabilityStore = await chunkQOW24SR2_cjs.getObservabilityStore(mastra);
    await observabilityStore.createFeedback({
      feedback: { ...feedback, feedbackId: feedback.feedbackId ?? observability.generateSignalId(), timestamp: /* @__PURE__ */ new Date() }
    });
    return { success: true };
  }
});
var GET_FEEDBACK_AGGREGATE = createNewRoute(chunkQOW24SR2_cjs.NEW_ROUTE_DEFS.GET_FEEDBACK_AGGREGATE, {
  bodySchema: getFeedbackAggregateArgsSchema,
  responseSchema: getFeedbackAggregateResponseSchema,
  handler: async ({ mastra, ...params }) => {
    const args = chunkN54Q3AQR_cjs.pickParams(getFeedbackAggregateArgsSchema, params);
    const observabilityStore = await chunkQOW24SR2_cjs.getObservabilityStore(mastra);
    return await observabilityStore.getFeedbackAggregate(args);
  }
});
var GET_FEEDBACK_BREAKDOWN = createNewRoute(chunkQOW24SR2_cjs.NEW_ROUTE_DEFS.GET_FEEDBACK_BREAKDOWN, {
  bodySchema: getFeedbackBreakdownArgsSchema,
  responseSchema: getFeedbackBreakdownResponseSchema,
  handler: async ({ mastra, ...params }) => {
    const args = chunkN54Q3AQR_cjs.pickParams(getFeedbackBreakdownArgsSchema, params);
    const observabilityStore = await chunkQOW24SR2_cjs.getObservabilityStore(mastra);
    return await observabilityStore.getFeedbackBreakdown(args);
  }
});
var GET_FEEDBACK_TIME_SERIES = createNewRoute(chunkQOW24SR2_cjs.NEW_ROUTE_DEFS.GET_FEEDBACK_TIME_SERIES, {
  bodySchema: getFeedbackTimeSeriesArgsSchema,
  responseSchema: getFeedbackTimeSeriesResponseSchema,
  handler: async ({ mastra, ...params }) => {
    const args = chunkN54Q3AQR_cjs.pickParams(getFeedbackTimeSeriesArgsSchema, params);
    const observabilityStore = await chunkQOW24SR2_cjs.getObservabilityStore(mastra);
    return await observabilityStore.getFeedbackTimeSeries(args);
  }
});
var GET_FEEDBACK_PERCENTILES = createNewRoute(chunkQOW24SR2_cjs.NEW_ROUTE_DEFS.GET_FEEDBACK_PERCENTILES, {
  bodySchema: getFeedbackPercentilesArgsSchema,
  responseSchema: getFeedbackPercentilesResponseSchema,
  handler: async ({ mastra, ...params }) => {
    const args = chunkN54Q3AQR_cjs.pickParams(getFeedbackPercentilesArgsSchema, params);
    const observabilityStore = await chunkQOW24SR2_cjs.getObservabilityStore(mastra);
    return await observabilityStore.getFeedbackPercentiles(args);
  }
});
var LIST_METRICS = createNewRoute(chunkQOW24SR2_cjs.NEW_ROUTE_DEFS.LIST_METRICS, {
  queryParamSchema: chunkQOW24SR2_cjs.createObservabilityListQuerySchema(metricsFilterSchema, metricsOrderBySchema),
  responseSchema: listMetricsResponseSchema,
  handler: async ({ mastra, mode, after, limit, ...params }) => {
    const filters = chunkN54Q3AQR_cjs.pickParams(metricsFilterSchema, params);
    const observabilityStore = await chunkQOW24SR2_cjs.getObservabilityStore(mastra);
    if (mode === "delta") {
      chunkQOW24SR2_cjs.assertObservabilityDeltaSupported(observabilityStore, chunkQOW24SR2_cjs.OBSERVABILITY_LIST_ENDPOINTS.metrics);
      return await observabilityStore.listMetrics({
        mode,
        filters,
        after: typeof after === "string" ? after : void 0,
        limit
      });
    }
    const pagination = chunkN54Q3AQR_cjs.pickParams(chunkZNP74O27_cjs.paginationArgsSchema, params);
    const orderBy = chunkN54Q3AQR_cjs.pickParams(metricsOrderBySchema, params);
    return await observabilityStore.listMetrics(
      mode === "page" ? { mode, filters, pagination, orderBy } : { filters, pagination, orderBy }
    );
  }
});
var GET_METRIC_AGGREGATE = createNewRoute(chunkQOW24SR2_cjs.NEW_ROUTE_DEFS.GET_METRIC_AGGREGATE, {
  bodySchema: getMetricAggregateArgsSchema,
  responseSchema: getMetricAggregateResponseSchema,
  handler: async ({ mastra, ...params }) => {
    const args = chunkN54Q3AQR_cjs.pickParams(getMetricAggregateArgsSchema, params);
    const observabilityStore = await chunkQOW24SR2_cjs.getObservabilityStore(mastra);
    return await observabilityStore.getMetricAggregate(args);
  }
});
var GET_METRIC_BREAKDOWN = createNewRoute(chunkQOW24SR2_cjs.NEW_ROUTE_DEFS.GET_METRIC_BREAKDOWN, {
  bodySchema: getMetricBreakdownArgsSchema,
  responseSchema: getMetricBreakdownResponseSchema,
  handler: async ({ mastra, ...params }) => {
    const args = chunkN54Q3AQR_cjs.pickParams(getMetricBreakdownArgsSchema, params);
    const observabilityStore = await chunkQOW24SR2_cjs.getObservabilityStore(mastra);
    return await observabilityStore.getMetricBreakdown(args);
  }
});
var GET_METRIC_TIME_SERIES = createNewRoute(chunkQOW24SR2_cjs.NEW_ROUTE_DEFS.GET_METRIC_TIME_SERIES, {
  bodySchema: getMetricTimeSeriesArgsSchema,
  responseSchema: getMetricTimeSeriesResponseSchema,
  handler: async ({ mastra, ...params }) => {
    const args = chunkN54Q3AQR_cjs.pickParams(getMetricTimeSeriesArgsSchema, params);
    const observabilityStore = await chunkQOW24SR2_cjs.getObservabilityStore(mastra);
    return await observabilityStore.getMetricTimeSeries(args);
  }
});
var GET_METRIC_PERCENTILES = createNewRoute(chunkQOW24SR2_cjs.NEW_ROUTE_DEFS.GET_METRIC_PERCENTILES, {
  bodySchema: getMetricPercentilesArgsSchema,
  responseSchema: getMetricPercentilesResponseSchema,
  handler: async ({ mastra, ...params }) => {
    const args = chunkN54Q3AQR_cjs.pickParams(getMetricPercentilesArgsSchema, params);
    const observabilityStore = await chunkQOW24SR2_cjs.getObservabilityStore(mastra);
    return await observabilityStore.getMetricPercentiles(args);
  }
});
var GET_METRIC_NAMES = createNewRoute(chunkQOW24SR2_cjs.NEW_ROUTE_DEFS.GET_METRIC_NAMES, {
  queryParamSchema: chunkN54Q3AQR_cjs.wrapSchemaForQueryParams(getMetricNamesArgsSchema.partial()),
  responseSchema: getMetricNamesResponseSchema,
  handler: async ({ mastra, ...params }) => {
    const args = getMetricNamesArgsSchema.parse(chunkN54Q3AQR_cjs.pickParams(getMetricNamesArgsSchema, params));
    const observabilityStore = await chunkQOW24SR2_cjs.getObservabilityStore(mastra);
    return await observabilityStore.getMetricNames(args);
  }
});
var GET_METRIC_LABEL_KEYS = createNewRoute(chunkQOW24SR2_cjs.NEW_ROUTE_DEFS.GET_METRIC_LABEL_KEYS, {
  queryParamSchema: chunkN54Q3AQR_cjs.wrapSchemaForQueryParams(getMetricLabelKeysArgsSchema),
  responseSchema: getMetricLabelKeysResponseSchema,
  handler: async ({ mastra, ...params }) => {
    const args = getMetricLabelKeysArgsSchema.parse(chunkN54Q3AQR_cjs.pickParams(getMetricLabelKeysArgsSchema, params));
    const observabilityStore = await chunkQOW24SR2_cjs.getObservabilityStore(mastra);
    return await observabilityStore.getMetricLabelKeys(args);
  }
});
var GET_METRIC_LABEL_VALUES = createNewRoute(chunkQOW24SR2_cjs.NEW_ROUTE_DEFS.GET_METRIC_LABEL_VALUES, {
  queryParamSchema: chunkN54Q3AQR_cjs.wrapSchemaForQueryParams(getMetricLabelValuesArgsSchema),
  responseSchema: getMetricLabelValuesResponseSchema,
  handler: async ({ mastra, ...params }) => {
    const args = getMetricLabelValuesArgsSchema.parse(chunkN54Q3AQR_cjs.pickParams(getMetricLabelValuesArgsSchema, params));
    const observabilityStore = await chunkQOW24SR2_cjs.getObservabilityStore(mastra);
    return await observabilityStore.getMetricLabelValues(args);
  }
});
var GET_ENTITY_TYPES = createNewRoute(chunkQOW24SR2_cjs.NEW_ROUTE_DEFS.GET_ENTITY_TYPES, {
  responseSchema: getEntityTypesResponseSchema,
  handler: async ({ mastra }) => {
    const observabilityStore = await chunkQOW24SR2_cjs.getObservabilityStore(mastra);
    return await observabilityStore.getEntityTypes({});
  }
});
var GET_ENTITY_NAMES = createNewRoute(chunkQOW24SR2_cjs.NEW_ROUTE_DEFS.GET_ENTITY_NAMES, {
  queryParamSchema: chunkN54Q3AQR_cjs.wrapSchemaForQueryParams(getEntityNamesArgsSchema.partial()),
  responseSchema: getEntityNamesResponseSchema,
  handler: async ({ mastra, ...params }) => {
    const args = getEntityNamesArgsSchema.parse(chunkN54Q3AQR_cjs.pickParams(getEntityNamesArgsSchema, params));
    const observabilityStore = await chunkQOW24SR2_cjs.getObservabilityStore(mastra);
    return await observabilityStore.getEntityNames(args);
  }
});
var GET_SERVICE_NAMES = createNewRoute(chunkQOW24SR2_cjs.NEW_ROUTE_DEFS.GET_SERVICE_NAMES, {
  responseSchema: getServiceNamesResponseSchema,
  handler: async ({ mastra }) => {
    const observabilityStore = await chunkQOW24SR2_cjs.getObservabilityStore(mastra);
    return await observabilityStore.getServiceNames({});
  }
});
var GET_ENVIRONMENTS = createNewRoute(chunkQOW24SR2_cjs.NEW_ROUTE_DEFS.GET_ENVIRONMENTS, {
  responseSchema: getEnvironmentsResponseSchema,
  handler: async ({ mastra }) => {
    const observabilityStore = await chunkQOW24SR2_cjs.getObservabilityStore(mastra);
    return await observabilityStore.getEnvironments({});
  }
});
var GET_TAGS = createNewRoute(chunkQOW24SR2_cjs.NEW_ROUTE_DEFS.GET_TAGS, {
  queryParamSchema: chunkN54Q3AQR_cjs.wrapSchemaForQueryParams(getTagsArgsSchema.partial()),
  responseSchema: getTagsResponseSchema,
  handler: async ({ mastra, ...params }) => {
    const args = getTagsArgsSchema.parse(chunkN54Q3AQR_cjs.pickParams(getTagsArgsSchema, params));
    const observabilityStore = await chunkQOW24SR2_cjs.getObservabilityStore(mastra);
    try {
      return await observabilityStore.getTags(args);
    } catch (error) {
      if (error instanceof Error && error.message.includes("does not support tag discovery")) {
        return { tags: [] };
      }
      throw error;
    }
  }
});
var NEW_ROUTES = {
  LIST_LOGS,
  LIST_SCORES,
  CREATE_SCORE,
  GET_SCORE,
  GET_SCORE_AGGREGATE,
  GET_SCORE_BREAKDOWN,
  GET_SCORE_TIME_SERIES,
  GET_SCORE_PERCENTILES,
  LIST_FEEDBACK,
  CREATE_FEEDBACK,
  GET_FEEDBACK_AGGREGATE,
  GET_FEEDBACK_BREAKDOWN,
  GET_FEEDBACK_TIME_SERIES,
  GET_FEEDBACK_PERCENTILES,
  LIST_METRICS,
  GET_METRIC_AGGREGATE,
  GET_METRIC_BREAKDOWN,
  GET_METRIC_TIME_SERIES,
  GET_METRIC_PERCENTILES,
  GET_METRIC_NAMES,
  GET_METRIC_LABEL_KEYS,
  GET_METRIC_LABEL_VALUES,
  GET_ENTITY_TYPES,
  GET_ENTITY_NAMES,
  GET_SERVICE_NAMES,
  GET_ENVIRONMENTS,
  GET_TAGS
};

exports.CREATE_FEEDBACK = CREATE_FEEDBACK;
exports.CREATE_SCORE = CREATE_SCORE;
exports.GET_ENTITY_NAMES = GET_ENTITY_NAMES;
exports.GET_ENTITY_TYPES = GET_ENTITY_TYPES;
exports.GET_ENVIRONMENTS = GET_ENVIRONMENTS;
exports.GET_FEEDBACK_AGGREGATE = GET_FEEDBACK_AGGREGATE;
exports.GET_FEEDBACK_BREAKDOWN = GET_FEEDBACK_BREAKDOWN;
exports.GET_FEEDBACK_PERCENTILES = GET_FEEDBACK_PERCENTILES;
exports.GET_FEEDBACK_TIME_SERIES = GET_FEEDBACK_TIME_SERIES;
exports.GET_METRIC_AGGREGATE = GET_METRIC_AGGREGATE;
exports.GET_METRIC_BREAKDOWN = GET_METRIC_BREAKDOWN;
exports.GET_METRIC_LABEL_KEYS = GET_METRIC_LABEL_KEYS;
exports.GET_METRIC_LABEL_VALUES = GET_METRIC_LABEL_VALUES;
exports.GET_METRIC_NAMES = GET_METRIC_NAMES;
exports.GET_METRIC_PERCENTILES = GET_METRIC_PERCENTILES;
exports.GET_METRIC_TIME_SERIES = GET_METRIC_TIME_SERIES;
exports.GET_SCORE = GET_SCORE;
exports.GET_SCORE_AGGREGATE = GET_SCORE_AGGREGATE;
exports.GET_SCORE_BREAKDOWN = GET_SCORE_BREAKDOWN;
exports.GET_SCORE_PERCENTILES = GET_SCORE_PERCENTILES;
exports.GET_SCORE_TIME_SERIES = GET_SCORE_TIME_SERIES;
exports.GET_SERVICE_NAMES = GET_SERVICE_NAMES;
exports.GET_TAGS = GET_TAGS;
exports.LIST_FEEDBACK = LIST_FEEDBACK;
exports.LIST_LOGS = LIST_LOGS;
exports.LIST_METRICS = LIST_METRICS;
exports.LIST_SCORES = LIST_SCORES;
exports.NEW_ROUTES = NEW_ROUTES;
//# sourceMappingURL=chunk-46D4LXPJ.cjs.map
//# sourceMappingURL=chunk-46D4LXPJ.cjs.map