import { paginationInfoSchema } from './chunk-2YY3EMMS.js';
import { z } from 'zod/v4';

var jsonSchemaObject = z.lazy(() => z.record(z.string(), z.unknown()));
var jsonSchemaField = z.union([jsonSchemaObject, z.null()]).optional();
var expectedStepBase = {
  name: z.string().describe("Step name to match"),
  durationMs: z.number().optional(),
  metadata: z.record(z.string(), z.unknown()).optional(),
  children: z.any().optional().describe("Nested trajectory expectation (untyped at this depth)")
};
var expectedToolCallStepSchema = z.object({
  ...expectedStepBase,
  stepType: z.literal("tool_call"),
  toolArgs: z.record(z.string(), z.unknown()).optional(),
  toolResult: z.record(z.string(), z.unknown()).optional(),
  success: z.boolean().optional()
});
var expectedMcpToolCallStepSchema = z.object({
  ...expectedStepBase,
  stepType: z.literal("mcp_tool_call"),
  toolArgs: z.record(z.string(), z.unknown()).optional(),
  toolResult: z.record(z.string(), z.unknown()).optional(),
  mcpServer: z.string().optional(),
  success: z.boolean().optional()
});
var expectedModelGenerationStepSchema = z.object({
  ...expectedStepBase,
  stepType: z.literal("model_generation"),
  modelId: z.string().optional(),
  promptTokens: z.number().optional(),
  completionTokens: z.number().optional(),
  finishReason: z.string().optional()
});
var expectedAgentRunStepSchema = z.object({
  ...expectedStepBase,
  stepType: z.literal("agent_run"),
  agentId: z.string().optional()
});
var expectedWorkflowStepStepSchema = z.object({
  ...expectedStepBase,
  stepType: z.literal("workflow_step"),
  stepId: z.string().optional(),
  status: z.string().optional(),
  output: z.record(z.string(), z.unknown()).optional()
});
var expectedWorkflowRunStepSchema = z.object({
  ...expectedStepBase,
  stepType: z.literal("workflow_run"),
  workflowId: z.string().optional(),
  status: z.string().optional()
});
var expectedWorkflowConditionalStepSchema = z.object({
  ...expectedStepBase,
  stepType: z.literal("workflow_conditional"),
  conditionCount: z.number().optional(),
  selectedSteps: z.array(z.string()).optional()
});
var expectedWorkflowParallelStepSchema = z.object({
  ...expectedStepBase,
  stepType: z.literal("workflow_parallel"),
  branchCount: z.number().optional(),
  parallelSteps: z.array(z.string()).optional()
});
var expectedWorkflowLoopStepSchema = z.object({
  ...expectedStepBase,
  stepType: z.literal("workflow_loop"),
  loopType: z.string().optional(),
  totalIterations: z.number().optional()
});
var expectedWorkflowSleepStepSchema = z.object({
  ...expectedStepBase,
  stepType: z.literal("workflow_sleep"),
  sleepDurationMs: z.number().optional(),
  sleepType: z.string().optional()
});
var expectedWorkflowWaitEventStepSchema = z.object({
  ...expectedStepBase,
  stepType: z.literal("workflow_wait_event"),
  eventName: z.string().optional(),
  eventReceived: z.boolean().optional()
});
var expectedProcessorRunStepSchema = z.object({
  ...expectedStepBase,
  stepType: z.literal("processor_run"),
  processorId: z.string().optional()
});
var expectedGenericStepSchema = z.object({
  ...expectedStepBase,
  stepType: z.undefined().optional()
});
var expectedStepSchema = z.union([
  z.discriminatedUnion("stepType", [
    expectedToolCallStepSchema,
    expectedMcpToolCallStepSchema,
    expectedModelGenerationStepSchema,
    expectedAgentRunStepSchema,
    expectedWorkflowStepStepSchema,
    expectedWorkflowRunStepSchema,
    expectedWorkflowConditionalStepSchema,
    expectedWorkflowParallelStepSchema,
    expectedWorkflowLoopStepSchema,
    expectedWorkflowSleepStepSchema,
    expectedWorkflowWaitEventStepSchema,
    expectedProcessorRunStepSchema
  ]),
  expectedGenericStepSchema
]);
var trajectoryExpectationSchema = z.object({
  // Accuracy
  steps: z.array(expectedStepSchema).optional().describe("Expected steps for accuracy checking"),
  ordering: z.enum(["strict", "relaxed", "unordered"]).optional().describe("How to compare step ordering (default: relaxed)"),
  allowRepeatedSteps: z.boolean().optional().describe("Whether to allow repeated steps (default: true)"),
  // Efficiency
  maxSteps: z.number().int().optional().describe("Maximum number of steps allowed"),
  maxTotalTokens: z.number().int().optional().describe("Maximum total tokens across all model_generation steps"),
  maxTotalDurationMs: z.number().optional().describe("Maximum total duration in milliseconds"),
  noRedundantCalls: z.boolean().optional().describe("Whether to penalize redundant calls (same tool + same args consecutively, default: true)"),
  // Blacklist
  blacklistedTools: z.array(z.string()).optional().describe("Tool names that should never appear"),
  blacklistedSequences: z.array(z.array(z.string())).optional().describe("Tool name sequences that should never appear"),
  // Tool failure tolerance
  maxRetriesPerTool: z.number().int().optional().describe("Maximum retries per tool before penalizing (default: 2)")
}).optional().nullable().describe("Expected trajectory configuration for trajectory scoring");
var datasetItemSourceSchema = z.object({
  type: z.enum(["csv", "json", "trace", "llm", "experiment-result", "candidate-screener"]).describe("How this item was created"),
  referenceId: z.string().optional().describe("Reference identifier (e.g., trace id, csv filename)")
}).optional().describe("Source/provenance of this dataset item");
var itemToolMockSchema = z.object({
  toolName: z.string().describe("Name of the tool this mock applies to"),
  args: z.record(z.string(), z.unknown()).describe("Arguments to match against the tool call"),
  output: z.unknown().describe("Output served to the agent when matched"),
  matchArgs: z.enum(["strict", "ignore"]).optional().describe("Argument matching mode. 'strict' (default) deep-equals args; 'ignore' matches on toolName only")
});
var toolMocksSchema = z.array(itemToolMockSchema).optional().describe("Ordered item-level static tool mocks served in place of executing the real tool");
var toolMockReportSchema = z.object({
  served: z.array(z.object({ mockIndex: z.number().int(), toolName: z.string(), args: z.unknown() })),
  unconsumed: z.array(z.object({ mockIndex: z.number().int(), toolName: z.string(), args: z.unknown() })),
  liveCalls: z.array(z.object({ toolName: z.string(), args: z.unknown() })),
  failure: z.object({
    code: z.enum(["TOOL_MOCK_MISMATCH", "TOOL_MOCK_EXHAUSTED"]),
    toolName: z.string(),
    args: z.unknown()
  }).optional()
}).optional().describe("Diagnostic receipt for item-level tool mocks");
var datasetIdPathParams = z.object({
  datasetId: z.string().describe("Unique identifier for the dataset")
});
var experimentIdPathParams = z.object({
  experimentId: z.string().describe("Unique identifier for the experiment")
});
var itemIdPathParams = z.object({
  itemId: z.string().describe("Unique identifier for the dataset item")
});
var datasetAndExperimentIdPathParams = z.object({
  datasetId: z.string().describe("Unique identifier for the dataset"),
  experimentId: z.string().describe("Unique identifier for the experiment")
});
var experimentResultIdPathParams = z.object({
  datasetId: z.string().describe("Unique identifier for the dataset"),
  experimentId: z.string().describe("Unique identifier for the experiment"),
  resultId: z.string().describe("Unique identifier for the experiment result")
});
var datasetAndItemIdPathParams = z.object({
  datasetId: z.string().describe("Unique identifier for the dataset"),
  itemId: z.string().describe("Unique identifier for the dataset item")
});
var paginationQuerySchema = z.object({
  page: z.coerce.number().optional().default(0),
  perPage: z.coerce.number().optional().default(10)
});
var tenancyQuerySchema = z.object({
  organizationId: z.string().optional().describe("Restrict lookup to the given organization"),
  projectId: z.string().optional().describe("Restrict lookup to the given project")
});
var listItemsQuerySchema = z.object({
  page: z.coerce.number().optional().default(0),
  perPage: z.coerce.number().optional().default(10),
  version: z.coerce.number().int().optional(),
  // Optional version filter for snapshot semantics
  search: z.string().optional()
});
var createDatasetBodySchema = z.object({
  name: z.string().describe("Name of the dataset"),
  description: z.string().optional().describe("Description of the dataset"),
  metadata: z.record(z.string(), z.unknown()).optional().describe("Additional metadata"),
  inputSchema: jsonSchemaField.describe("JSON Schema for validating item input"),
  groundTruthSchema: jsonSchemaField.describe("JSON Schema for validating item groundTruth"),
  requestContextSchema: jsonSchemaField.describe("JSON Schema describing expected request context shape"),
  targetType: z.string().optional().describe("Target entity type (e.g. agent, workflow, scorer)"),
  targetIds: z.array(z.string()).optional().describe("IDs of target entities this dataset is attached to"),
  scorerIds: z.array(z.string()).optional().describe("IDs of scorers attached to this dataset")
});
var updateDatasetBodySchema = z.object({
  name: z.string().optional().describe("Name of the dataset"),
  description: z.string().optional().describe("Description of the dataset"),
  metadata: z.record(z.string(), z.unknown()).optional().describe("Additional metadata"),
  inputSchema: jsonSchemaField.describe("JSON Schema for validating item input"),
  groundTruthSchema: jsonSchemaField.describe("JSON Schema for validating item groundTruth"),
  requestContextSchema: jsonSchemaField.describe("JSON Schema describing expected request context shape"),
  tags: z.array(z.string()).optional().describe("Tag definitions for categorizing experiment results"),
  targetType: z.string().optional().describe("Target entity type (e.g. agent, workflow, scorer)"),
  targetIds: z.array(z.string()).optional().describe("IDs of target entities this dataset is attached to"),
  scorerIds: z.array(z.string()).optional().nullable().describe("IDs of scorers attached to this dataset")
});
var addItemBodySchema = z.object({
  input: z.unknown().describe("Input data for the dataset item"),
  groundTruth: z.unknown().optional().describe("Expected output for comparison"),
  expectedTrajectory: trajectoryExpectationSchema,
  toolMocks: toolMocksSchema,
  requestContext: z.record(z.string(), z.unknown()).optional().describe("Request context preset for this item"),
  metadata: z.record(z.string(), z.unknown()).optional().describe("Additional metadata"),
  source: datasetItemSourceSchema
});
var updateItemBodySchema = z.object({
  input: z.unknown().optional().describe("Input data for the dataset item"),
  groundTruth: z.unknown().optional().describe("Expected output for comparison"),
  expectedTrajectory: trajectoryExpectationSchema,
  toolMocks: toolMocksSchema,
  requestContext: z.record(z.string(), z.unknown()).optional().describe("Request context preset for this item"),
  metadata: z.record(z.string(), z.unknown()).optional().describe("Additional metadata"),
  source: datasetItemSourceSchema
});
var triggerExperimentBodySchema = z.object({
  targetType: z.enum(["agent", "workflow", "scorer"]).describe("Type of target to run against"),
  targetId: z.string().describe("ID of the target"),
  scorerIds: z.array(z.string()).optional().describe("IDs of scorers to apply"),
  version: z.coerce.number().int().optional().describe("Pin to specific dataset version"),
  agentVersion: z.string().optional().describe("Agent version ID to use for experiment"),
  maxConcurrency: z.number().optional().describe("Maximum concurrent executions"),
  requestContext: z.record(z.string(), z.unknown()).optional().describe("Global request context passed to the target"),
  versions: z.object({
    agents: z.record(
      z.string(),
      z.union([z.object({ versionId: z.string() }), z.object({ status: z.enum(["draft", "published"]) })])
    ).optional(),
    defaultStatus: z.enum(["draft", "published"]).optional()
  }).optional().describe("Version overrides for sub-agent delegation during experiment execution")
});
var compareExperimentsBodySchema = z.object({
  experimentIdA: z.string().describe("ID of baseline experiment"),
  experimentIdB: z.string().describe("ID of candidate experiment")
});
var datasetResponseSchema = z.object({
  id: z.string(),
  name: z.string(),
  description: z.string().optional().nullable(),
  metadata: z.record(z.string(), z.unknown()).optional().nullable(),
  inputSchema: z.record(z.string(), z.unknown()).optional(),
  groundTruthSchema: z.record(z.string(), z.unknown()).optional(),
  requestContextSchema: z.record(z.string(), z.unknown()).optional(),
  tags: z.array(z.string()).optional().nullable(),
  targetType: z.string().optional().nullable(),
  targetIds: z.array(z.string()).optional().nullable(),
  scorerIds: z.array(z.string()).optional().nullable(),
  version: z.number().int(),
  createdAt: z.coerce.date(),
  updatedAt: z.coerce.date()
});
var datasetItemResponseSchema = z.object({
  id: z.string(),
  datasetId: z.string(),
  datasetVersion: z.number().int(),
  input: z.unknown(),
  groundTruth: z.unknown().optional(),
  expectedTrajectory: z.unknown().optional(),
  toolMocks: toolMocksSchema,
  requestContext: z.record(z.string(), z.unknown()).optional(),
  metadata: z.record(z.string(), z.unknown()).optional(),
  source: datasetItemSourceSchema,
  createdAt: z.coerce.date(),
  updatedAt: z.coerce.date()
});
var experimentResponseSchema = z.object({
  id: z.string(),
  datasetId: z.string().nullable(),
  datasetVersion: z.number().int().nullable(),
  agentVersion: z.string().nullable().optional(),
  targetType: z.enum(["agent", "workflow", "scorer", "processor"]),
  targetId: z.string(),
  name: z.string().optional(),
  description: z.string().optional(),
  metadata: z.record(z.string(), z.unknown()).optional(),
  status: z.enum(["pending", "running", "completed", "failed"]),
  totalItems: z.number(),
  succeededCount: z.number(),
  failedCount: z.number(),
  skippedCount: z.number(),
  startedAt: z.coerce.date().nullable(),
  completedAt: z.coerce.date().nullable(),
  createdAt: z.coerce.date(),
  updatedAt: z.coerce.date()
});
var scorerResultSchema = z.object({
  scorerId: z.string(),
  scorerName: z.string(),
  score: z.number().nullable(),
  reason: z.string().nullable(),
  error: z.string().nullable()
});
var experimentResultResponseSchema = z.object({
  id: z.string(),
  experimentId: z.string(),
  itemId: z.string(),
  itemDatasetVersion: z.number().int().nullable(),
  input: z.unknown(),
  output: z.unknown().nullable(),
  groundTruth: z.unknown().nullable(),
  expectedTrajectory: z.unknown().optional(),
  error: z.object({
    message: z.string(),
    stack: z.string().optional(),
    code: z.string().optional()
  }).nullable(),
  startedAt: z.coerce.date(),
  completedAt: z.coerce.date(),
  retryCount: z.number(),
  traceId: z.string().nullable(),
  status: z.enum(["needs-review", "reviewed", "complete"]).nullable().optional(),
  tags: z.array(z.string()).nullable().optional(),
  toolMockReport: toolMockReportSchema.nullable(),
  createdAt: z.coerce.date()
});
var updateExperimentResultBodySchema = z.object({
  status: z.enum(["needs-review", "reviewed", "complete"]).nullable().optional(),
  tags: z.array(z.string()).optional()
});
var comparisonItemSchema = z.object({
  itemId: z.string(),
  input: z.unknown().nullable(),
  groundTruth: z.unknown().nullable(),
  results: z.record(
    z.string(),
    z.object({
      output: z.unknown().nullable(),
      scores: z.record(z.string(), z.number().nullable())
    }).nullable()
  )
});
var comparisonResponseSchema = z.object({
  baselineId: z.string(),
  items: z.array(comparisonItemSchema)
});
var experimentSummaryResponseSchema = z.object({
  experimentId: z.string(),
  status: z.enum(["pending", "running", "completed", "failed"]),
  totalItems: z.number(),
  succeededCount: z.number(),
  failedCount: z.number(),
  startedAt: z.coerce.date(),
  completedAt: z.coerce.date().nullable(),
  results: z.array(
    z.object({
      itemId: z.string(),
      itemDatasetVersion: z.number().int().nullable(),
      input: z.unknown(),
      output: z.unknown().nullable(),
      groundTruth: z.unknown().nullable(),
      error: z.string().nullable(),
      startedAt: z.coerce.date(),
      completedAt: z.coerce.date(),
      retryCount: z.number(),
      toolMockReport: toolMockReportSchema.nullable(),
      scores: z.array(
        z.object({
          scorerId: z.string(),
          scorerName: z.string(),
          score: z.number().nullable(),
          reason: z.string().nullable(),
          error: z.string().nullable()
        })
      )
    })
  )
});
var listDatasetsResponseSchema = z.object({
  datasets: z.array(datasetResponseSchema),
  pagination: paginationInfoSchema
});
var listItemsResponseSchema = z.object({
  items: z.array(datasetItemResponseSchema),
  pagination: paginationInfoSchema
});
var listExperimentsResponseSchema = z.object({
  experiments: z.array(experimentResponseSchema),
  pagination: paginationInfoSchema
});
var listExperimentResultsResponseSchema = z.object({
  results: z.array(experimentResultResponseSchema),
  pagination: paginationInfoSchema
});
var experimentReviewCountsSchema = z.object({
  experimentId: z.string(),
  total: z.number().int(),
  needsReview: z.number().int(),
  reviewed: z.number().int(),
  complete: z.number().int()
});
var reviewSummaryResponseSchema = z.object({
  counts: z.array(experimentReviewCountsSchema)
});
var datasetItemVersionPathParams = z.object({
  datasetId: z.string().describe("Unique identifier for the dataset"),
  itemId: z.string().describe("Unique identifier for the dataset item"),
  datasetVersion: z.coerce.number().int().describe("Dataset version number")
});
var itemVersionResponseSchema = z.object({
  id: z.string(),
  datasetId: z.string(),
  datasetVersion: z.number().int(),
  input: z.unknown(),
  groundTruth: z.unknown().optional(),
  expectedTrajectory: z.unknown().optional(),
  toolMocks: toolMocksSchema,
  metadata: z.record(z.string(), z.unknown()).optional(),
  validTo: z.number().int().nullable(),
  isDeleted: z.boolean(),
  createdAt: z.coerce.date(),
  updatedAt: z.coerce.date()
});
var listItemVersionsResponseSchema = z.object({
  history: z.array(itemVersionResponseSchema)
});
var datasetVersionResponseSchema = z.object({
  id: z.string(),
  datasetId: z.string(),
  version: z.number().int(),
  createdAt: z.coerce.date()
});
var listDatasetVersionsResponseSchema = z.object({
  versions: z.array(datasetVersionResponseSchema),
  pagination: paginationInfoSchema
});
var batchInsertItemsBodySchema = z.object({
  items: z.array(
    z.object({
      input: z.unknown(),
      groundTruth: z.unknown().optional(),
      expectedTrajectory: trajectoryExpectationSchema,
      toolMocks: toolMocksSchema,
      requestContext: z.record(z.string(), z.unknown()).optional(),
      metadata: z.record(z.string(), z.unknown()).optional(),
      source: datasetItemSourceSchema
    })
  )
});
var batchInsertItemsResponseSchema = z.object({
  items: z.array(datasetItemResponseSchema),
  count: z.number()
});
var batchDeleteItemsBodySchema = z.object({
  itemIds: z.array(z.string())
});
var batchDeleteItemsResponseSchema = z.object({
  success: z.boolean(),
  deletedCount: z.number()
});
var generateItemsBodySchema = z.object({
  modelId: z.string().describe('Model identifier in "provider/model" format (e.g., "openai/gpt-4o")'),
  prompt: z.string().describe("Description of the kind of test data to generate"),
  count: z.number().int().min(1).max(50).default(5).describe("Number of items to generate"),
  agentContext: z.object({
    description: z.string().optional(),
    instructions: z.string().optional(),
    tools: z.array(z.string()).optional()
  }).optional().describe("Context about the agent to generate relevant test data")
});
var generatedItemSchema = z.object({
  input: z.unknown(),
  groundTruth: z.unknown().optional()
});
var generateItemsResponseSchema = z.object({
  items: z.array(generatedItemSchema)
});
var clusterFailuresBodySchema = z.object({
  modelId: z.string().describe('Model identifier in "provider/model" format (e.g., "openai/gpt-4o")'),
  items: z.array(
    z.object({
      id: z.string(),
      input: z.unknown(),
      output: z.unknown().optional(),
      error: z.string().optional(),
      scores: z.record(z.string(), z.number()).optional(),
      existingTags: z.array(z.string()).optional().describe("Tags already applied to this item")
    })
  ).min(1).max(200).describe("Failure items to cluster"),
  availableTags: z.array(z.string()).optional().describe("Existing tag vocabulary from the dataset. The LLM should prefer reusing these tags when applicable."),
  prompt: z.string().optional().describe('Optional user instructions to guide the analysis (e.g., "focus on tool usage failures")')
});
var failureClusterSchema = z.object({
  id: z.string().describe("A unique cluster identifier"),
  label: z.string().describe("Short label for this failure pattern"),
  description: z.string().describe("Description of the common pattern"),
  itemIds: z.array(z.string()).describe("IDs of items belonging to this cluster")
});
var clusterFailuresResponseSchema = z.object({
  clusters: z.array(failureClusterSchema),
  /** Per-item proposed tag assignments. Each entry maps an item ID to the tags the LLM suggests adding. */
  proposedTags: z.array(
    z.object({
      itemId: z.string(),
      tags: z.array(z.string()),
      reason: z.string().describe("Brief explanation of why these tags were assigned to this item")
    })
  ).optional()
});

export { addItemBodySchema, batchDeleteItemsBodySchema, batchDeleteItemsResponseSchema, batchInsertItemsBodySchema, batchInsertItemsResponseSchema, clusterFailuresBodySchema, clusterFailuresResponseSchema, compareExperimentsBodySchema, comparisonResponseSchema, createDatasetBodySchema, datasetAndExperimentIdPathParams, datasetAndItemIdPathParams, datasetIdPathParams, datasetItemResponseSchema, datasetItemVersionPathParams, datasetResponseSchema, datasetVersionResponseSchema, experimentIdPathParams, experimentResponseSchema, experimentResultIdPathParams, experimentResultResponseSchema, experimentReviewCountsSchema, experimentSummaryResponseSchema, generateItemsBodySchema, generateItemsResponseSchema, itemIdPathParams, itemVersionResponseSchema, listDatasetVersionsResponseSchema, listDatasetsResponseSchema, listExperimentResultsResponseSchema, listExperimentsResponseSchema, listItemVersionsResponseSchema, listItemsQuerySchema, listItemsResponseSchema, paginationQuerySchema, reviewSummaryResponseSchema, scorerResultSchema, tenancyQuerySchema, triggerExperimentBodySchema, updateDatasetBodySchema, updateExperimentResultBodySchema, updateItemBodySchema };
//# sourceMappingURL=chunk-RRQZAJDZ.js.map
//# sourceMappingURL=chunk-RRQZAJDZ.js.map