import { z } from 'zod/v4';

// ../_internal-core/dist/index.js
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 || {});
var createdAtField = z.date().describe("Database record creation time");
var updatedAtField = z.date().describe("Database record last update time");
var dbTimestamps = {
  createdAt: createdAtField,
  updatedAt: updatedAtField.nullable()
};
var paginationArgsSchema = z.object({
  page: z.coerce.number().int().min(0).optional().default(0).describe("Zero-indexed page number"),
  perPage: 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 = z.object({
  total: z.number().describe("Total number of items available"),
  page: z.number().describe("Current page"),
  perPage: z.union([z.number(), z.literal(false)]).describe("Number of items per page, or false if pagination is disabled"),
  hasMore: z.boolean().describe("True if more pages are available")
});
var dateRangeSchema = z.object({
  start: z.coerce.date().optional().describe("Start of date range (inclusive by default)"),
  end: z.coerce.date().optional().describe("End of date range (inclusive by default)"),
  startExclusive: z.boolean().optional().describe("When true, excludes the start date from results (uses > instead of >=)"),
  endExclusive: z.boolean().optional().describe("When true, excludes the end date from results (uses < instead of <=)")
}).describe("Date range filter for timestamps");
var sortDirectionSchema = z.enum(["ASC", "DESC"]).describe("Sort direction: 'ASC' | 'DESC'");
var aggregationTypeSchema = z.enum(["sum", "avg", "min", "max", "count", "last"]).describe("Aggregation function");
var aggregationIntervalSchema = z.enum(["1m", "5m", "15m", "1h", "1d"]).describe("Time bucket interval");
var comparePeriodSchema = z.enum(["previous_period", "previous_day", "previous_week"]).describe("Comparison period for aggregate queries");
var groupBySchema = z.array(z.string()).min(1).describe("Fields to group by");
var percentilesSchema = z.array(z.number().min(0).max(1)).min(1).describe("Percentile values (0-1)");
var aggregateResponseFields = {
  value: z.number().nullable().describe("Aggregated value"),
  previousValue: z.number().nullable().optional().describe("Value from comparison period"),
  changePercent: z.number().nullable().optional().describe("Percentage change from comparison period")
};
var dimensionsField = z.record(z.string(), z.string().nullable()).describe("Dimension values for this group");
var aggregatedValueField = z.number().describe("Aggregated value");
var bucketTimestampField = z.date().describe("Bucket timestamp");
var percentileField = z.number().describe("Percentile value");
var percentileBucketValueField = z.number().describe("Percentile value at this bucket");
var entityTypeField = z.nativeEnum(EntityType).describe(`Entity type (e.g., 'agent' | 'processor' | 'tool' | 'workflow')`);
var entityIdField = z.string().describe('ID of the entity (e.g., "weatherAgent", "orderWorkflow")');
var entityNameField = z.string().describe("Name of the entity");
var userIdField = z.string().describe("Human end-user who triggered execution");
var organizationIdField = z.string().describe("Multi-tenant organization/account");
var resourceIdField = z.string().describe("Broader resource context (Mastra memory compatibility)");
var runIdField = z.string().describe("Unique execution run identifier");
var sessionIdField = z.string().describe("Session identifier for grouping traces");
var threadIdField = z.string().describe("Conversation thread identifier");
var requestIdField = z.string().describe("HTTP request ID for log correlation");
var environmentField = z.string().describe(`Environment (e.g., "production" | "staging" | "development")`);
var sourceField = z.string().describe(`Source of execution (e.g., "local" | "cloud" | "ci")`);
var executionSourceField = z.string().describe(`Source of execution (e.g., "local" | "cloud" | "ci")`);
var serviceNameField = z.string().describe("Name of the service");
var parentEntityTypeField = z.nativeEnum(EntityType).describe("Entity type of the parent entity");
var parentEntityIdField = z.string().describe("ID of the parent entity");
var parentEntityNameField = z.string().describe("Name of the parent entity");
var rootEntityTypeField = z.nativeEnum(EntityType).describe("Entity type of the root entity");
var rootEntityIdField = z.string().describe("ID of the root entity");
var rootEntityNameField = z.string().describe("Name of the root entity");
var entityVersionIdField = z.string().describe("Version ID of the entity that produced this signal (e.g., agent version, workflow version)");
var parentEntityVersionIdField = z.string().describe("Version ID of the parent entity that produced this signal");
var rootEntityVersionIdField = z.string().describe("Version ID of the root entity that produced this signal");
var experimentIdField = z.string().describe("Experiment or eval run identifier");
var 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"})');
var metadataField = z.record(z.string(), z.unknown()).describe("User-defined metadata for custom filtering");
var tagsField = z.array(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()
};
var spanContextFields = {
  ...contextFieldsBase,
  source: sourceField.nullish()
};
var commonFilterFields = {
  timestamp: dateRangeSchema.optional().describe("Filter by timestamp range"),
  traceId: z.string().optional().describe("Filter by trace ID"),
  spanId: 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: z.array(z.string()).optional().describe("Filter by tags (must have all specified tags)")
};
var traceIdField = z.string().describe("Unique trace identifier");
var spanIdField = z.string().describe("Unique span identifier within a trace");
var logLevelSchema = z.enum(["debug", "info", "warn", "error", "fatal"]);
var messageField = z.string().describe("Log message");
var logDataField = z.record(z.string(), z.unknown()).describe("Structured data attached to the log");
var logRecordSchema = z.object({
  logId: z.string().nullish().describe("Unique id for this log event"),
  timestamp: 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: z.string().nullish().describe("Execution source"),
  metadata: metadataField.nullish()
}).describe("Log record as stored in the database");
var logRecordInputSchema = z.object({
  level: logLevelSchema,
  message: messageField,
  data: logDataField.optional(),
  tags: tagsField.optional()
}).describe("User-provided log input");
var createLogRecordSchema = logRecordSchema;
var batchCreateLogsArgsSchema = z.object({
  logs: z.array(createLogRecordSchema)
}).describe("Arguments for batch creating logs");
var logsFilterSchema = z.object({
  ...commonFilterFields,
  // Log-specific filters
  /**
   * @deprecated Use `executionSource` instead.
   */
  source: z.string().optional().describe("Filter by execution source"),
  level: z.union([logLevelSchema, z.array(logLevelSchema)]).optional().describe("Filter by log level(s)")
}).describe("Filters for querying logs");
var logsOrderByFieldSchema = z.enum(["timestamp"]).describe("Field to order by: 'timestamp'");
var logsOrderBySchema = z.object({
  field: logsOrderByFieldSchema.default("timestamp").describe("Field to order by"),
  direction: sortDirectionSchema.default("DESC").describe("Sort direction")
}).describe("Order by configuration");
var listLogsArgsSchema = z.object({
  filters: logsFilterSchema.optional().describe("Optional filters to apply"),
  pagination: paginationArgsSchema.default({ page: 0, perPage: 10 }).describe("Pagination settings"),
  orderBy: logsOrderBySchema.default({ field: "timestamp", direction: "DESC" }).describe("Ordering configuration (defaults to timestamp desc)")
}).describe("Arguments for listing logs");
var listLogsResponseSchema = z.object({
  pagination: paginationInfoSchema,
  logs: z.array(logRecordSchema)
});
var scorerIdField = z.string().describe("Identifier of the scorer (e.g., relevance, accuracy)");
var scorerNameField = z.string().describe("Display name of the scorer");
var scorerVersionField = z.string().describe("Version of the scorer");
var scoreSourceField = z.string().describe("How the score was produced (e.g., manual, automated, experiment)");
var scoreValueField = z.number().describe("Score value (range defined by scorer)");
var scoreReasonField = z.string().describe("Explanation for the score");
var scoreRecordSchema = z.object({
  scoreId: z.string().nullish().describe("Unique id for this score event"),
  timestamp: 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: z.string().nullish().describe("Trace ID of the scoring run for debugging score generation"),
  // User-defined metadata (context fields stored here)
  metadata: z.record(z.string(), z.unknown()).nullish().describe("User-defined metadata")
}).describe("Score record as stored in the database");
var scoreInputSchema = 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: z.record(z.string(), z.unknown()).optional().describe("Additional scorer-specific metadata"),
  experimentId: experimentIdField.optional(),
  scoreTraceId: 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;
var createScoreArgsSchema = z.object({
  score: createScoreRecordSchema
}).describe("Arguments for creating a score");
var createScoreBodySchema = z.object({
  score: createScoreRecordSchema.omit({ timestamp: true })
}).describe("Arguments for creating a score");
var createScoreResponseSchema = z.object({ success: z.boolean() }).describe("Response from creating a score");
var batchCreateScoresArgsSchema = z.object({
  scores: z.array(createScoreRecordSchema)
}).describe("Arguments for batch recording scores");
var scoresFilterSchema = z.object({
  ...commonFilterFields,
  // Score-specific filters
  scorerId: z.union([z.string(), z.array(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 = z.enum(["timestamp", "score"]).describe("Field to order by: 'timestamp' | 'score'");
var scoresOrderBySchema = z.object({
  field: scoresOrderByFieldSchema.default("timestamp").describe("Field to order by"),
  direction: sortDirectionSchema.default("DESC").describe("Sort direction")
}).describe("Order by configuration");
var listScoresArgsSchema = z.object({
  filters: scoresFilterSchema.optional(),
  pagination: paginationArgsSchema.default({ page: 0, perPage: 10 }).describe("Pagination settings"),
  orderBy: scoresOrderBySchema.default({ field: "timestamp", direction: "DESC" }).describe("Ordering configuration (defaults to timestamp desc)")
}).describe("Arguments for listing scores");
var listScoresResponseSchema = z.object({
  pagination: paginationInfoSchema,
  scores: z.array(scoreRecordSchema)
});
var getScoreAggregateArgsSchema = z.object({
  scorerId: scorerIdField,
  scoreSource: scoreSourceField.optional(),
  aggregation: aggregationTypeSchema,
  filters: scoresFilterSchema.optional(),
  comparePeriod: comparePeriodSchema.optional()
}).describe("Arguments for getting a score aggregate");
var getScoreAggregateResponseSchema = z.object(aggregateResponseFields);
var getScoreBreakdownArgsSchema = z.object({
  scorerId: scorerIdField,
  scoreSource: scoreSourceField.optional(),
  groupBy: groupBySchema,
  aggregation: aggregationTypeSchema,
  filters: scoresFilterSchema.optional()
}).describe("Arguments for getting a score breakdown");
var getScoreBreakdownResponseSchema = z.object({
  groups: z.array(
    z.object({
      dimensions: dimensionsField,
      value: aggregatedValueField
    })
  )
});
var getScoreTimeSeriesArgsSchema = 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 = z.object({
  series: z.array(
    z.object({
      name: z.string().describe("Series name (scorer ID or group key)"),
      points: z.array(
        z.object({
          timestamp: bucketTimestampField,
          value: aggregatedValueField
        })
      )
    })
  )
});
var getScorePercentilesArgsSchema = z.object({
  scorerId: scorerIdField,
  scoreSource: scoreSourceField.optional(),
  percentiles: percentilesSchema,
  interval: aggregationIntervalSchema,
  filters: scoresFilterSchema.optional()
}).describe("Arguments for getting score percentiles");
var getScorePercentilesResponseSchema = z.object({
  series: z.array(
    z.object({
      percentile: percentileField,
      points: z.array(
        z.object({
          timestamp: bucketTimestampField,
          value: percentileBucketValueField
        })
      )
    })
  )
});
var feedbackSourceField = z.string().describe("Source of feedback (e.g., 'user', 'system', 'manual')");
var feedbackTypeField = z.string().describe("Type of feedback (e.g., 'thumbs', 'rating', 'correction')");
var feedbackValueField = z.union([z.number(), z.string()]).describe("Feedback value (rating number or correction text)");
var feedbackCommentField = z.string().describe("Additional comment or context");
var feedbackUserIdField = 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 = z.object({
  feedbackId: z.string().nullish().describe("Unique id for this feedback event"),
  timestamp: 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: 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: z.record(z.string(), z.unknown()).nullish().describe("User-defined metadata")
});
var feedbackRecordSchema = z.object(feedbackRecordObjectSchema.shape).describe("Feedback record as stored in the database");
var feedbackInputObjectSchema = 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: z.record(z.string(), z.unknown()).optional().describe("Additional feedback-specific metadata"),
  experimentId: experimentIdField.optional(),
  sourceId: z.string().optional().describe("ID of the source record this feedback is linked to")
});
var feedbackInputSchema = z.object(feedbackInputObjectSchema.shape).describe("User-provided feedback input");
var createFeedbackRecordSchema = feedbackRecordSchema;
var createFeedbackArgsSchema = z.object({
  feedback: z.preprocess(normalizeLegacyFeedbackActor, feedbackRecordObjectSchema)
}).describe("Arguments for creating feedback");
var createFeedbackBodySchema = z.object({
  feedback: feedbackRecordObjectSchema.omit({ timestamp: true })
}).describe("Arguments for creating feedback");
var createFeedbackResponseSchema = z.object({ success: z.boolean() }).describe("Response from creating feedback");
var batchCreateFeedbackArgsSchema = z.object({
  feedbacks: z.array(z.preprocess(normalizeLegacyFeedbackActor, feedbackRecordObjectSchema))
}).describe("Arguments for batch recording feedback");
var feedbackFilterObjectSchema = z.object({
  ...commonFilterFields,
  // Feedback-specific filters
  feedbackType: z.union([z.string(), z.array(z.string())]).optional().describe("Filter by feedback type(s)"),
  feedbackSource: feedbackSourceField.optional(),
  /**
   * @deprecated Use `feedbackSource` instead.
   */
  source: feedbackSourceField.optional(),
  feedbackUserId: feedbackUserIdField.optional()
});
var feedbackFilterSchema = z.object(feedbackFilterObjectSchema.shape).describe("Filters for querying feedback");
var feedbackOrderByFieldSchema = z.enum(["timestamp"]).describe("Field to order by: 'timestamp'");
var feedbackOrderBySchema = z.object({
  field: feedbackOrderByFieldSchema.default("timestamp").describe("Field to order by"),
  direction: sortDirectionSchema.default("DESC").describe("Sort direction")
}).describe("Order by configuration");
var listFeedbackArgsSchema = z.object({
  filters: z.preprocess(normalizeLegacyFeedbackActor, feedbackFilterObjectSchema).optional().describe("Optional filters to apply"),
  pagination: paginationArgsSchema.default({ page: 0, perPage: 10 }).describe("Pagination settings"),
  orderBy: feedbackOrderBySchema.default({ field: "timestamp", direction: "DESC" }).describe("Ordering configuration (defaults to timestamp desc)")
}).describe("Arguments for listing feedback");
var listFeedbackResponseSchema = z.object({
  pagination: paginationInfoSchema,
  feedback: z.array(feedbackRecordSchema)
});
var getFeedbackAggregateArgsSchema = 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 = z.object(aggregateResponseFields);
var getFeedbackBreakdownArgsSchema = 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 = z.object({
  groups: z.array(
    z.object({
      dimensions: dimensionsField,
      value: aggregatedValueField
    })
  )
});
var getFeedbackTimeSeriesArgsSchema = 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 = z.object({
  series: z.array(
    z.object({
      name: z.string().describe("Series name (feedback type or group key)"),
      points: z.array(
        z.object({
          timestamp: bucketTimestampField,
          value: aggregatedValueField
        })
      )
    })
  )
});
var getFeedbackPercentilesArgsSchema = 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 = z.object({
  series: z.array(
    z.object({
      percentile: percentileField,
      points: z.array(
        z.object({
          timestamp: bucketTimestampField,
          value: percentileBucketValueField
        })
      )
    })
  )
});
var metricTypeSchema = z.enum(["counter", "gauge", "histogram"]);
var metricNameField = z.string().describe("Metric name (e.g., mastra_agent_duration_ms)");
var metricValueField = z.number().describe("Metric value");
var labelsField = z.record(z.string(), z.string()).describe("Metric labels for dimensional filtering");
var providerField = z.string().describe("Model provider");
var modelField = z.string().describe("Model");
var estimatedCostField = z.number().describe("Estimated cost");
var costUnitField = z.string().describe("Unit for the estimated cost (e.g., usd)");
var costMetadField = z.record(z.string(), z.unknown()).nullish().describe("Structured costing metadata");
var metricRecordSchema = z.object({
  metricId: z.string().nullish().describe("Unique id for this metric event"),
  timestamp: 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: 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");
var metricInputSchema = z.object({
  name: metricNameField,
  value: metricValueField,
  labels: labelsField.optional()
}).describe("User-provided metric input");
var createMetricRecordSchema = metricRecordSchema;
var batchCreateMetricsArgsSchema = z.object({
  metrics: z.array(createMetricRecordSchema)
}).describe("Arguments for batch recording metrics");
var metricsAggregationSchema = z.object({
  type: aggregationTypeSchema,
  interval: aggregationIntervalSchema.optional(),
  groupBy: groupBySchema.optional()
}).describe("Metrics aggregation configuration");
var metricsFilterSchema = z.object({
  ...commonFilterFields,
  // Metric identification
  name: z.array(z.string()).nonempty().optional().describe("Filter by metric name(s)"),
  /**
   * @deprecated Use `executionSource` instead.
   */
  source: 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: z.record(z.string(), z.string()).optional().describe("Exact match on label key-value pairs")
}).describe("Filters for querying metrics");
var metricsOrderByFieldSchema = z.enum(["timestamp"]).describe("Field to order by: 'timestamp'");
var metricsOrderBySchema = z.object({
  field: metricsOrderByFieldSchema.default("timestamp").describe("Field to order by"),
  direction: sortDirectionSchema.default("DESC").describe("Sort direction")
}).describe("Order by configuration");
var listMetricsArgsSchema = z.object({
  filters: metricsFilterSchema.optional(),
  pagination: paginationArgsSchema.default({ page: 0, perPage: 10 }).describe("Pagination settings"),
  orderBy: metricsOrderBySchema.default({ field: "timestamp", direction: "DESC" }).describe("Ordering configuration (defaults to timestamp desc)")
}).describe("Arguments for listing metrics");
var listMetricsResponseSchema = z.object({
  pagination: paginationInfoSchema,
  metrics: z.array(metricRecordSchema)
});
var getMetricAggregateArgsSchema = z.object({
  name: z.array(z.string()).nonempty().describe("Metric name(s) to aggregate"),
  aggregation: aggregationTypeSchema,
  filters: metricsFilterSchema.optional(),
  comparePeriod: comparePeriodSchema.optional()
}).describe("Arguments for getting a metric aggregate");
var getMetricAggregateResponseSchema = z.object({
  ...aggregateResponseFields,
  estimatedCost: z.number().nullable().optional().describe("Aggregated estimated cost from the same filtered row set"),
  costUnit: z.string().nullable().optional().describe("Shared cost unit for the aggregated rows, or null when mixed/unknown"),
  previousEstimatedCost: z.number().nullable().optional().describe("Aggregated estimated cost from the comparison period"),
  costChangePercent: z.number().nullable().optional().describe("Percentage change in estimated cost from comparison period")
});
var getMetricBreakdownArgsSchema = z.object({
  name: z.array(z.string()).nonempty().describe("Metric name(s) to break down"),
  groupBy: groupBySchema,
  aggregation: aggregationTypeSchema,
  filters: metricsFilterSchema.optional()
}).describe("Arguments for getting a metric breakdown");
var getMetricBreakdownResponseSchema = z.object({
  groups: z.array(
    z.object({
      dimensions: dimensionsField,
      value: aggregatedValueField,
      estimatedCost: z.number().nullable().optional().describe("Summed estimated cost for this group"),
      costUnit: z.string().nullable().optional().describe("Shared cost unit for this group, or null when mixed/unknown")
    })
  )
});
var getMetricTimeSeriesArgsSchema = z.object({
  name: z.array(z.string()).nonempty().describe("Metric name(s)"),
  interval: aggregationIntervalSchema,
  aggregation: aggregationTypeSchema,
  filters: metricsFilterSchema.optional(),
  groupBy: groupBySchema.optional()
}).describe("Arguments for getting metric time series");
var getMetricTimeSeriesResponseSchema = z.object({
  series: z.array(
    z.object({
      name: z.string().describe("Series name (metric name or group key)"),
      costUnit: z.string().nullable().optional().describe("Shared cost unit for this series, or null when mixed/unknown"),
      points: z.array(
        z.object({
          timestamp: bucketTimestampField,
          value: aggregatedValueField,
          estimatedCost: z.number().nullable().optional().describe("Summed estimated cost in this bucket")
        })
      )
    })
  )
});
var getMetricPercentilesArgsSchema = z.object({
  name: z.string().describe("Metric name"),
  percentiles: percentilesSchema,
  interval: aggregationIntervalSchema,
  filters: metricsFilterSchema.optional()
}).describe("Arguments for getting metric percentiles");
var getMetricPercentilesResponseSchema = z.object({
  series: z.array(
    z.object({
      percentile: percentileField,
      points: z.array(
        z.object({
          timestamp: bucketTimestampField,
          value: percentileBucketValueField
        })
      )
    })
  )
});
var getMetricNamesArgsSchema = z.object({
  prefix: z.string().optional().describe("Filter metric names by prefix"),
  limit: z.number().int().min(1).optional().describe("Maximum number of names to return")
}).describe("Arguments for getting metric names");
var getMetricNamesResponseSchema = z.object({
  names: z.array(z.string()).describe("Distinct metric names")
});
var getMetricLabelKeysArgsSchema = z.object({
  metricName: z.string().describe("Metric name to get label keys for")
}).describe("Arguments for getting metric label keys");
var getMetricLabelKeysResponseSchema = z.object({
  keys: z.array(z.string()).describe("Distinct label keys for the metric")
});
var getMetricLabelValuesArgsSchema = z.object({
  metricName: z.string().describe("Metric name"),
  labelKey: z.string().describe("Label key to get values for"),
  prefix: z.string().optional().describe("Filter values by prefix"),
  limit: z.number().int().min(1).optional().describe("Maximum number of values to return")
}).describe("Arguments for getting label values");
var getMetricLabelValuesResponseSchema = z.object({
  values: z.array(z.string()).describe("Distinct label values")
});
var getEntityTypesArgsSchema = z.object({}).describe("Arguments for getting entity types");
var getEntityTypesResponseSchema = z.object({
  entityTypes: z.array(entityTypeField).describe("Distinct entity types")
});
var getEntityNamesArgsSchema = z.object({
  entityType: entityTypeField.optional().describe("Optional entity type filter")
}).describe("Arguments for getting entity names");
var getEntityNamesResponseSchema = z.object({
  names: z.array(z.string()).describe("Distinct entity names")
});
var getServiceNamesArgsSchema = z.object({}).describe("Arguments for getting service names");
var getServiceNamesResponseSchema = z.object({
  serviceNames: z.array(z.string()).describe("Distinct service names")
});
var getEnvironmentsArgsSchema = z.object({}).describe("Arguments for getting environments");
var getEnvironmentsResponseSchema = z.object({
  environments: z.array(z.string()).describe("Distinct environments")
});
var getTagsArgsSchema = z.object({
  entityType: entityTypeField.optional().describe("Optional entity type filter")
}).describe("Arguments for getting tags");
var getTagsResponseSchema = z.object({
  tags: z.array(z.string()).describe("Distinct tags")
});

// src/observability/types/tracing.ts
var SpanType = /* @__PURE__ */ ((SpanType2) => {
  SpanType2["AGENT_RUN"] = "agent_run";
  SpanType2["SCORER_RUN"] = "scorer_run";
  SpanType2["SCORER_STEP"] = "scorer_step";
  SpanType2["GENERIC"] = "generic";
  SpanType2["MODEL_GENERATION"] = "model_generation";
  SpanType2["MODEL_STEP"] = "model_step";
  SpanType2["MODEL_CHUNK"] = "model_chunk";
  SpanType2["MCP_TOOL_CALL"] = "mcp_tool_call";
  SpanType2["PROCESSOR_RUN"] = "processor_run";
  SpanType2["TOOL_CALL"] = "tool_call";
  SpanType2["WORKFLOW_RUN"] = "workflow_run";
  SpanType2["WORKFLOW_STEP"] = "workflow_step";
  SpanType2["WORKFLOW_CONDITIONAL"] = "workflow_conditional";
  SpanType2["WORKFLOW_CONDITIONAL_EVAL"] = "workflow_conditional_eval";
  SpanType2["WORKFLOW_PARALLEL"] = "workflow_parallel";
  SpanType2["WORKFLOW_LOOP"] = "workflow_loop";
  SpanType2["WORKFLOW_SLEEP"] = "workflow_sleep";
  SpanType2["WORKFLOW_WAIT_EVENT"] = "workflow_wait_event";
  SpanType2["MEMORY_OPERATION"] = "memory_operation";
  SpanType2["WORKSPACE_ACTION"] = "workspace_action";
  SpanType2["RAG_INGESTION"] = "rag_ingestion";
  SpanType2["RAG_EMBEDDING"] = "rag_embedding";
  SpanType2["RAG_VECTOR_OPERATION"] = "rag_vector_operation";
  SpanType2["RAG_ACTION"] = "rag_action";
  SpanType2["GRAPH_ACTION"] = "graph_action";
  return SpanType2;
})(SpanType || {});
var InternalSpans = /* @__PURE__ */ ((InternalSpans2) => {
  InternalSpans2[InternalSpans2["NONE"] = 0] = "NONE";
  InternalSpans2[InternalSpans2["WORKFLOW"] = 1] = "WORKFLOW";
  InternalSpans2[InternalSpans2["AGENT"] = 2] = "AGENT";
  InternalSpans2[InternalSpans2["TOOL"] = 4] = "TOOL";
  InternalSpans2[InternalSpans2["MODEL"] = 8] = "MODEL";
  InternalSpans2[InternalSpans2["ALL"] = 15] = "ALL";
  return InternalSpans2;
})(InternalSpans || {});
var TracingEventType = /* @__PURE__ */ ((TracingEventType2) => {
  TracingEventType2["SPAN_STARTED"] = "span_started";
  TracingEventType2["SPAN_UPDATED"] = "span_updated";
  TracingEventType2["SPAN_ENDED"] = "span_ended";
  return TracingEventType2;
})(TracingEventType || {});

export { EntityType, InternalSpans, SpanType, TracingEventType, aggregationIntervalSchema, aggregationTypeSchema, batchCreateFeedbackArgsSchema, batchCreateLogsArgsSchema, batchCreateMetricsArgsSchema, batchCreateScoresArgsSchema, commonFilterFields, comparePeriodSchema, contextFields, createFeedbackArgsSchema, createFeedbackBodySchema, createFeedbackRecordSchema, createFeedbackResponseSchema, createLogRecordSchema, createMetricRecordSchema, createScoreArgsSchema, createScoreBodySchema, createScoreRecordSchema, createScoreResponseSchema, createdAtField, dateRangeSchema, dbTimestamps, entityIdField, entityNameField, entityTypeField, 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, listFeedbackArgsSchema, listFeedbackResponseSchema, listLogsArgsSchema, listLogsResponseSchema, listMetricsArgsSchema, listMetricsResponseSchema, listScoresArgsSchema, listScoresResponseSchema, logLevelSchema, logRecordInputSchema, logRecordSchema, logsFilterSchema, logsOrderByFieldSchema, logsOrderBySchema, metadataField, metricInputSchema, metricRecordSchema, metricTypeSchema, metricsAggregationSchema, metricsFilterSchema, metricsOrderByFieldSchema, metricsOrderBySchema, organizationIdField, paginationArgsSchema, paginationInfoSchema, parentEntityIdField, parentEntityNameField, parentEntityTypeField, requestIdField, resourceIdField, rootEntityIdField, rootEntityNameField, rootEntityTypeField, runIdField, scopeField, scoreInputSchema, scoreRecordSchema, scoresFilterSchema, scoresOrderByFieldSchema, scoresOrderBySchema, serviceNameField, sessionIdField, sortDirectionSchema, sourceField, spanContextFields, spanIdField, tagsField, threadIdField, traceIdField, updatedAtField, userIdField };
//# sourceMappingURL=chunk-2PBCTS3B.js.map
//# sourceMappingURL=chunk-2PBCTS3B.js.map