'use strict';

var v4 = require('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 = v4.z.date().describe("Database record creation time");
var updatedAtField = v4.z.date().describe("Database record last update time");
var dbTimestamps = {
  createdAt: createdAtField,
  updatedAt: updatedAtField.nullable()
};
var paginationArgsSchema = 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 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", "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()
};
var spanContextFields = {
  ...contextFieldsBase,
  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");
var logRecordInputSchema = v4.z.object({
  level: logLevelSchema,
  message: messageField,
  data: logDataField.optional(),
  tags: tagsField.optional()
}).describe("User-provided log input");
var createLogRecordSchema = logRecordSchema;
var batchCreateLogsArgsSchema = 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");
var listLogsArgsSchema = v4.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 = v4.z.object({
  pagination: paginationInfoSchema,
  logs: v4.z.array(logRecordSchema)
});
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");
var scoreInputSchema = 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;
var createScoreArgsSchema = 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");
var batchCreateScoresArgsSchema = 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");
var listScoresArgsSchema = v4.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 = v4.z.object({
  pagination: paginationInfoSchema,
  scores: v4.z.array(scoreRecordSchema)
});
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")
});
var feedbackInputSchema = v4.z.object(feedbackInputObjectSchema.shape).describe("User-provided feedback input");
var createFeedbackRecordSchema = feedbackRecordSchema;
var createFeedbackArgsSchema = 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");
var batchCreateFeedbackArgsSchema = 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");
var listFeedbackArgsSchema = v4.z.object({
  filters: v4.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 = v4.z.object({
  pagination: paginationInfoSchema,
  feedback: v4.z.array(feedbackRecordSchema)
});
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
        })
      )
    })
  )
});
var metricTypeSchema = 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");
var metricInputSchema = v4.z.object({
  name: metricNameField,
  value: metricValueField,
  labels: labelsField.optional()
}).describe("User-provided metric input");
var createMetricRecordSchema = metricRecordSchema;
var batchCreateMetricsArgsSchema = v4.z.object({
  metrics: v4.z.array(createMetricRecordSchema)
}).describe("Arguments for batch recording metrics");
var metricsAggregationSchema = 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");
var listMetricsArgsSchema = v4.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 = v4.z.object({
  pagination: paginationInfoSchema,
  metrics: v4.z.array(metricRecordSchema)
});
var getMetricAggregateArgsSchema = v4.z.object({
  name: v4.z.array(v4.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 = 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,
  filters: metricsFilterSchema.optional()
}).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,
  filters: metricsFilterSchema.optional(),
  groupBy: groupBySchema.optional()
}).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.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.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")
});
var getEntityTypesArgsSchema = 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")
});
var getServiceNamesArgsSchema = 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")
});
var getEnvironmentsArgsSchema = 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")
});

// 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 || {});

exports.EntityType = EntityType;
exports.InternalSpans = InternalSpans;
exports.SpanType = SpanType;
exports.TracingEventType = TracingEventType;
exports.aggregationIntervalSchema = aggregationIntervalSchema;
exports.aggregationTypeSchema = aggregationTypeSchema;
exports.batchCreateFeedbackArgsSchema = batchCreateFeedbackArgsSchema;
exports.batchCreateLogsArgsSchema = batchCreateLogsArgsSchema;
exports.batchCreateMetricsArgsSchema = batchCreateMetricsArgsSchema;
exports.batchCreateScoresArgsSchema = batchCreateScoresArgsSchema;
exports.commonFilterFields = commonFilterFields;
exports.comparePeriodSchema = comparePeriodSchema;
exports.contextFields = contextFields;
exports.createFeedbackArgsSchema = createFeedbackArgsSchema;
exports.createFeedbackBodySchema = createFeedbackBodySchema;
exports.createFeedbackRecordSchema = createFeedbackRecordSchema;
exports.createFeedbackResponseSchema = createFeedbackResponseSchema;
exports.createLogRecordSchema = createLogRecordSchema;
exports.createMetricRecordSchema = createMetricRecordSchema;
exports.createScoreArgsSchema = createScoreArgsSchema;
exports.createScoreBodySchema = createScoreBodySchema;
exports.createScoreRecordSchema = createScoreRecordSchema;
exports.createScoreResponseSchema = createScoreResponseSchema;
exports.createdAtField = createdAtField;
exports.dateRangeSchema = dateRangeSchema;
exports.dbTimestamps = dbTimestamps;
exports.entityIdField = entityIdField;
exports.entityNameField = entityNameField;
exports.entityTypeField = entityTypeField;
exports.environmentField = environmentField;
exports.executionSourceField = executionSourceField;
exports.experimentIdField = experimentIdField;
exports.feedbackFilterSchema = feedbackFilterSchema;
exports.feedbackInputSchema = feedbackInputSchema;
exports.feedbackOrderByFieldSchema = feedbackOrderByFieldSchema;
exports.feedbackOrderBySchema = feedbackOrderBySchema;
exports.feedbackRecordSchema = feedbackRecordSchema;
exports.getEntityNamesArgsSchema = getEntityNamesArgsSchema;
exports.getEntityNamesResponseSchema = getEntityNamesResponseSchema;
exports.getEntityTypesArgsSchema = getEntityTypesArgsSchema;
exports.getEntityTypesResponseSchema = getEntityTypesResponseSchema;
exports.getEnvironmentsArgsSchema = getEnvironmentsArgsSchema;
exports.getEnvironmentsResponseSchema = getEnvironmentsResponseSchema;
exports.getFeedbackAggregateArgsSchema = getFeedbackAggregateArgsSchema;
exports.getFeedbackAggregateResponseSchema = getFeedbackAggregateResponseSchema;
exports.getFeedbackBreakdownArgsSchema = getFeedbackBreakdownArgsSchema;
exports.getFeedbackBreakdownResponseSchema = getFeedbackBreakdownResponseSchema;
exports.getFeedbackPercentilesArgsSchema = getFeedbackPercentilesArgsSchema;
exports.getFeedbackPercentilesResponseSchema = getFeedbackPercentilesResponseSchema;
exports.getFeedbackTimeSeriesArgsSchema = getFeedbackTimeSeriesArgsSchema;
exports.getFeedbackTimeSeriesResponseSchema = getFeedbackTimeSeriesResponseSchema;
exports.getMetricAggregateArgsSchema = getMetricAggregateArgsSchema;
exports.getMetricAggregateResponseSchema = getMetricAggregateResponseSchema;
exports.getMetricBreakdownArgsSchema = getMetricBreakdownArgsSchema;
exports.getMetricBreakdownResponseSchema = getMetricBreakdownResponseSchema;
exports.getMetricLabelKeysArgsSchema = getMetricLabelKeysArgsSchema;
exports.getMetricLabelKeysResponseSchema = getMetricLabelKeysResponseSchema;
exports.getMetricLabelValuesArgsSchema = getMetricLabelValuesArgsSchema;
exports.getMetricLabelValuesResponseSchema = getMetricLabelValuesResponseSchema;
exports.getMetricNamesArgsSchema = getMetricNamesArgsSchema;
exports.getMetricNamesResponseSchema = getMetricNamesResponseSchema;
exports.getMetricPercentilesArgsSchema = getMetricPercentilesArgsSchema;
exports.getMetricPercentilesResponseSchema = getMetricPercentilesResponseSchema;
exports.getMetricTimeSeriesArgsSchema = getMetricTimeSeriesArgsSchema;
exports.getMetricTimeSeriesResponseSchema = getMetricTimeSeriesResponseSchema;
exports.getScoreAggregateArgsSchema = getScoreAggregateArgsSchema;
exports.getScoreAggregateResponseSchema = getScoreAggregateResponseSchema;
exports.getScoreBreakdownArgsSchema = getScoreBreakdownArgsSchema;
exports.getScoreBreakdownResponseSchema = getScoreBreakdownResponseSchema;
exports.getScorePercentilesArgsSchema = getScorePercentilesArgsSchema;
exports.getScorePercentilesResponseSchema = getScorePercentilesResponseSchema;
exports.getScoreTimeSeriesArgsSchema = getScoreTimeSeriesArgsSchema;
exports.getScoreTimeSeriesResponseSchema = getScoreTimeSeriesResponseSchema;
exports.getServiceNamesArgsSchema = getServiceNamesArgsSchema;
exports.getServiceNamesResponseSchema = getServiceNamesResponseSchema;
exports.getTagsArgsSchema = getTagsArgsSchema;
exports.getTagsResponseSchema = getTagsResponseSchema;
exports.listFeedbackArgsSchema = listFeedbackArgsSchema;
exports.listFeedbackResponseSchema = listFeedbackResponseSchema;
exports.listLogsArgsSchema = listLogsArgsSchema;
exports.listLogsResponseSchema = listLogsResponseSchema;
exports.listMetricsArgsSchema = listMetricsArgsSchema;
exports.listMetricsResponseSchema = listMetricsResponseSchema;
exports.listScoresArgsSchema = listScoresArgsSchema;
exports.listScoresResponseSchema = listScoresResponseSchema;
exports.logLevelSchema = logLevelSchema;
exports.logRecordInputSchema = logRecordInputSchema;
exports.logRecordSchema = logRecordSchema;
exports.logsFilterSchema = logsFilterSchema;
exports.logsOrderByFieldSchema = logsOrderByFieldSchema;
exports.logsOrderBySchema = logsOrderBySchema;
exports.metadataField = metadataField;
exports.metricInputSchema = metricInputSchema;
exports.metricRecordSchema = metricRecordSchema;
exports.metricTypeSchema = metricTypeSchema;
exports.metricsAggregationSchema = metricsAggregationSchema;
exports.metricsFilterSchema = metricsFilterSchema;
exports.metricsOrderByFieldSchema = metricsOrderByFieldSchema;
exports.metricsOrderBySchema = metricsOrderBySchema;
exports.organizationIdField = organizationIdField;
exports.paginationArgsSchema = paginationArgsSchema;
exports.paginationInfoSchema = paginationInfoSchema;
exports.parentEntityIdField = parentEntityIdField;
exports.parentEntityNameField = parentEntityNameField;
exports.parentEntityTypeField = parentEntityTypeField;
exports.requestIdField = requestIdField;
exports.resourceIdField = resourceIdField;
exports.rootEntityIdField = rootEntityIdField;
exports.rootEntityNameField = rootEntityNameField;
exports.rootEntityTypeField = rootEntityTypeField;
exports.runIdField = runIdField;
exports.scopeField = scopeField;
exports.scoreInputSchema = scoreInputSchema;
exports.scoreRecordSchema = scoreRecordSchema;
exports.scoresFilterSchema = scoresFilterSchema;
exports.scoresOrderByFieldSchema = scoresOrderByFieldSchema;
exports.scoresOrderBySchema = scoresOrderBySchema;
exports.serviceNameField = serviceNameField;
exports.sessionIdField = sessionIdField;
exports.sortDirectionSchema = sortDirectionSchema;
exports.sourceField = sourceField;
exports.spanContextFields = spanContextFields;
exports.spanIdField = spanIdField;
exports.tagsField = tagsField;
exports.threadIdField = threadIdField;
exports.traceIdField = traceIdField;
exports.updatedAtField = updatedAtField;
exports.userIdField = userIdField;
//# sourceMappingURL=chunk-BFGOVBEN.cjs.map
//# sourceMappingURL=chunk-BFGOVBEN.cjs.map