Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

172 KB
Raw Blame
/**
 * Auto-generated Zod validation schemas from the Django backend OpenAPI schema.
 * To modify these schemas, update the Django serializers or views, then run:
 *   hogli build:openapi
 * Questions or issues? #team-devex on Slack
 *
 * PostHog API - generated
 * OpenAPI spec version: 1.0.0
 */
import * as zod from 'zod'

/**
 * Mark a check as not applicable to this project.
 */
export const AiObservabilityInstrumentationChecklistDismissCreateBody = /* @__PURE__ */ zod.object({
    check: zod
        .enum(['sessions', 'tool_calls', 'user_identity', 'trace_structure'])
        .describe(
            '\* `sessions` - sessions\n\* `tool_calls` - tool_calls\n\* `user_identity` - user_identity\n\* `trace_structure` - trace_structure'
        )
        .describe(
            'Key of the check to dismiss or restore.\n\n\* `sessions` - sessions\n\* `tool_calls` - tool_calls\n\* `user_identity` - user_identity\n\* `trace_structure` - trace_structure'
        ),
})

/**
 * Bring a dismissed check back into grading.
 */
export const AiObservabilityInstrumentationChecklistRestoreCreateBody = /* @__PURE__ */ zod.object({
    check: zod
        .enum(['sessions', 'tool_calls', 'user_identity', 'trace_structure'])
        .describe(
            '\* `sessions` - sessions\n\* `tool_calls` - tool_calls\n\* `user_identity` - user_identity\n\* `trace_structure` - trace_structure'
        )
        .describe(
            'Key of the check to dismiss or restore.\n\n\* `sessions` - sessions\n\* `tool_calls` - tool_calls\n\* `user_identity` - user_identity\n\* `trace_structure` - trace_structure'
        ),
})

export const aiObservabilityOfflineExperimentsCreateBodyNameMax = 400

export const aiObservabilityOfflineExperimentsCreateBodyExpectedItemCountMin = 0
export const aiObservabilityOfflineExperimentsCreateBodyExpectedItemCountMax = 2147483647

export const aiObservabilityOfflineExperimentsCreateBodyExpectedResultCountMin = 0
export const aiObservabilityOfflineExperimentsCreateBodyExpectedResultCountMax = 2147483647

export const aiObservabilityOfflineExperimentsCreateBodySuiteKeyMax = 255

export const aiObservabilityOfflineExperimentsCreateBodyDatasetSourceMax = 255

export const aiObservabilityOfflineExperimentsCreateBodyDatasetIdentifierMax = 255

export const aiObservabilityOfflineExperimentsCreateBodyDatasetRevisionIdentifierMax = 255

export const aiObservabilityOfflineExperimentsCreateBodyApplicationVersionMax = 255

export const aiObservabilityOfflineExperimentsCreateBodyModelVersionMax = 255

export const aiObservabilityOfflineExperimentsCreateBodyPromptVersionMax = 255

export const AiObservabilityOfflineExperimentsCreateBody = /* @__PURE__ */ zod.object({
    id: zod.uuid().describe('Caller-generated experiment UUID. Reuse it for exact retries.'),
    name: zod
        .string()
        .max(aiObservabilityOfflineExperimentsCreateBodyNameMax)
        .describe('Display name for this experiment execution.'),
    started_at: zod.iso
        .datetime({ offset: true })
        .describe('Execution start time in ISO 8601 format, supplied by the caller.'),
    run_source: zod
        .union([
            zod
                .enum(['ci', 'local', 'scheduled'])
                .describe('\* `ci` - CI\n\* `local` - Local\n\* `scheduled` - Scheduled'),
            zod.null(),
        ])
        .optional()
        .describe(
            'Where the execution started: ci, local, or scheduled. Omit or use null when unknown.\n\n\* `ci` - CI\n\* `local` - Local\n\* `scheduled` - Scheduled'
        ),
    expected_item_count: zod
        .number()
        .min(aiObservabilityOfflineExperimentsCreateBodyExpectedItemCountMin)
        .max(aiObservabilityOfflineExperimentsCreateBodyExpectedItemCountMax)
        .nullish()
        .describe('Expected number of distinct items. Completion must match this count when supplied.'),
    expected_result_count: zod
        .number()
        .min(aiObservabilityOfflineExperimentsCreateBodyExpectedResultCountMin)
        .max(aiObservabilityOfflineExperimentsCreateBodyExpectedResultCountMax)
        .nullish()
        .describe('Expected number of distinct item\/scorer-version results, including non-success statuses.'),
    suite_key: zod
        .string()
        .max(aiObservabilityOfflineExperimentsCreateBodySuiteKeyMax)
        .nullish()
        .describe('Stable identifier for comparing executions of the same evaluation suite.'),
    dataset_source: zod
        .string()
        .max(aiObservabilityOfflineExperimentsCreateBodyDatasetSourceMax)
        .nullish()
        .describe('Source of an external dataset. Hosted dataset provenance is derived from its revision.'),
    dataset_identifier: zod
        .string()
        .max(aiObservabilityOfflineExperimentsCreateBodyDatasetIdentifierMax)
        .nullish()
        .describe('Stable identifier for the external dataset.'),
    dataset_revision_identifier: zod
        .string()
        .max(aiObservabilityOfflineExperimentsCreateBodyDatasetRevisionIdentifierMax)
        .nullish()
        .describe('Pinned revision identifier of the external dataset.'),
    dataset_revision_id: zod.uuid().nullish().describe('UUID of a hosted dataset revision in this project.'),
    application_version: zod
        .string()
        .max(aiObservabilityOfflineExperimentsCreateBodyApplicationVersionMax)
        .nullish()
        .describe('Version of the application under evaluation.'),
    model_version: zod
        .string()
        .max(aiObservabilityOfflineExperimentsCreateBodyModelVersionMax)
        .nullish()
        .describe('Version of the model under evaluation.'),
    prompt_version: zod
        .string()
        .max(aiObservabilityOfflineExperimentsCreateBodyPromptVersionMax)
        .nullish()
        .describe('Version of the prompt under evaluation.'),
})

export const aiObservabilityOfflineExperimentsPartialUpdateBodyTagsItemMax = 255

export const aiObservabilityOfflineExperimentsPartialUpdateBodyTagsMax = 100

export const AiObservabilityOfflineExperimentsPartialUpdateBody = /* @__PURE__ */ zod.object({
    tags: zod
        .array(zod.string().max(aiObservabilityOfflineExperimentsPartialUpdateBodyTagsItemMax))
        .max(aiObservabilityOfflineExperimentsPartialUpdateBodyTagsMax)
        .optional()
        .describe('Tag names. Replaces existing tags; send [] to remove all tags. Names are trimmed and lowercased.'),
})

export const aiObservabilityOfflineExperimentsUploadCreateBodyItemsItemModelVersionMax = 255

export const aiObservabilityOfflineExperimentsUploadCreateBodyItemsItemCaseKeyMax = 255

export const aiObservabilityOfflineExperimentsUploadCreateBodyItemsItemTrialMax = 255

export const aiObservabilityOfflineExperimentsUploadCreateBodyItemsItemDatasetItemIdentifierMax = 255

export const aiObservabilityOfflineExperimentsUploadCreateBodyItemsItemDatasetItemVersionIdentifierMax = 255

export const aiObservabilityOfflineExperimentsUploadCreateBodyItemsItemApplicationTraceIdMax = 255

export const aiObservabilityOfflineExperimentsUploadCreateBodyItemsMax = 1000

export const aiObservabilityOfflineExperimentsUploadCreateBodyResultsItemValueThreeItemMax = 128

export const aiObservabilityOfflineExperimentsUploadCreateBodyResultsItemErrorCodeMax = 128

export const aiObservabilityOfflineExperimentsUploadCreateBodyResultsItemEvaluatorTraceIdMax = 255

export const aiObservabilityOfflineExperimentsUploadCreateBodyResultsMax = 1000

export const AiObservabilityOfflineExperimentsUploadCreateBody = /* @__PURE__ */ zod.object({
    items: zod
        .array(
            zod.object({
                id: zod
                    .uuid()
                    .describe('Caller-generated UUID for one input\/output execution. Reuse for exact retries.'),
                model_version: zod
                    .string()
                    .max(aiObservabilityOfflineExperimentsUploadCreateBodyItemsItemModelVersionMax)
                    .nullish()
                    .describe("Model used for this item. Omitted or null values inherit the experiment's model."),
                case_key: zod
                    .string()
                    .max(aiObservabilityOfflineExperimentsUploadCreateBodyItemsItemCaseKeyMax)
                    .nullish()
                    .describe('Stable case identifier for matching inputs across experiments.'),
                trial: zod
                    .string()
                    .max(aiObservabilityOfflineExperimentsUploadCreateBodyItemsItemTrialMax)
                    .nullish()
                    .describe('Identifier for a repeated execution of the same case.'),
                dataset_item_identifier: zod
                    .string()
                    .max(aiObservabilityOfflineExperimentsUploadCreateBodyItemsItemDatasetItemIdentifierMax)
                    .nullish()
                    .describe('Stable item identifier in an external dataset.'),
                dataset_item_version_identifier: zod
                    .string()
                    .max(aiObservabilityOfflineExperimentsUploadCreateBodyItemsItemDatasetItemVersionIdentifierMax)
                    .nullish()
                    .describe('Pinned item-version identifier in an external dataset.'),
                dataset_item_version_id: zod
                    .uuid()
                    .nullish()
                    .describe("UUID of the hosted item version in the experiment's dataset revision."),
                application_trace_id: zod
                    .string()
                    .max(aiObservabilityOfflineExperimentsUploadCreateBodyItemsItemApplicationTraceIdMax)
                    .nullish()
                    .describe('Trace identifier for the application execution that produced this output.'),
                payload: zod
                    .object({
                        input: zod
                            .union([
                                zod.record(zod.string(), zod.unknown()),
                                zod.array(zod.unknown()),
                                zod.string(),
                                zod.number(),
                                zod.boolean(),
                                zod.null(),
                            ])
                            .optional(),
                        output: zod
                            .union([
                                zod.record(zod.string(), zod.unknown()),
                                zod.array(zod.unknown()),
                                zod.string(),
                                zod.number(),
                                zod.boolean(),
                                zod.null(),
                            ])
                            .optional(),
                        expected_output: zod
                            .union([
                                zod.record(zod.string(), zod.unknown()),
                                zod.array(zod.unknown()),
                                zod.string(),
                                zod.number(),
                                zod.boolean(),
                                zod.null(),
                            ])
                            .optional(),
                        metadata: zod.record(zod.string(), zod.unknown()).nullish(),
                    })
                    .optional()
                    .describe(
                        'Optional input\/output payload, up to 1 MiB and 32 JSON levels. Omission, {} and null properties differ.'
                    ),
            })
        )
        .max(aiObservabilityOfflineExperimentsUploadCreateBodyItemsMax)
        .optional()
        .describe(
            'Complete immutable declarations for referenced items. Omit existing items to reuse them without a payload.'
        ),
    results: zod
        .array(
            zod.object({
                item_id: zod
                    .uuid()
                    .describe('UUID of an item declared in this request or already accepted in this experiment.'),
                scorer_version_id: zod.uuid().describe('Exact UUID of an existing scorer version in this project.'),
                status: zod
                    .enum(['ok', 'error', 'skipped', 'not_applicable'])
                    .describe(
                        '\* `ok` - OK\n\* `error` - Error\n\* `skipped` - Skipped\n\* `not_applicable` - Not applicable'
                    )
                    .describe(
                        'Outcome of this scorer execution.\n\n\* `ok` - OK\n\* `error` - Error\n\* `skipped` - Skipped\n\* `not_applicable` - Not applicable'
                    ),
                value: zod
                    .union([
                        zod.number(),
                        zod.boolean(),
                        zod
                            .array(
                                zod
                                    .string()
                                    .max(aiObservabilityOfflineExperimentsUploadCreateBodyResultsItemValueThreeItemMax)
                            )
                            .min(1),
                        zod.null(),
                    ])
                    .optional()
                    .describe(
                        'Required for ok: finite number, boolean, or distinct category keys matching the scorer version.'
                    ),
                error_code: zod
                    .string()
                    .max(aiObservabilityOfflineExperimentsUploadCreateBodyResultsItemErrorCodeMax)
                    .nullish()
                    .describe('Optional stable error code, permitted only for error outcomes.'),
                evaluator_trace_id: zod
                    .string()
                    .max(aiObservabilityOfflineExperimentsUploadCreateBodyResultsItemEvaluatorTraceIdMax)
                    .nullish()
                    .describe('Trace identifier of the evaluator that produced this result.'),
                evaluated_at: zod.iso
                    .datetime({ offset: true })
                    .nullish()
                    .describe('Caller-supplied evaluation time in ISO 8601 format.'),
                payload: zod
                    .object({
                        reasoning: zod.string().nullish(),
                        error_message: zod.string().nullish(),
                        metadata: zod.record(zod.string(), zod.unknown()).nullish(),
                    })
                    .optional()
                    .describe('Optional reasoning, error message, and metadata, up to 256 KiB and 32 JSON levels.'),
            })
        )
        .min(1)
        .max(aiObservabilityOfflineExperimentsUploadCreateBodyResultsMax)
        .describe('One to 1,000 unique item\/scorer-version results. The entire request commits atomically.'),
})

/**
 * Starts writing the trace and every node, inputs and outputs included, to a JSON file. Poll the export until it completes, then download it.
 */
export const AiObservabilityTracesExportsCreateBody = /* @__PURE__ */ zod.object({
    timestamp_hint: zod.iso
        .datetime({ offset: true })
        .optional()
        .describe(
            'When the trace happened, as carried by links into it. Lets a trace older than the AI events retention load from the shared events table.'
        ),
})

/**
 * Request an AI summary of the trace. A ready summary is returned as is unless `regenerate` is set; otherwise a job starts writing one, or the request joins the job already writing it.
 */
export const aiObservabilityTracesSummaryCreateBodyRegenerateDefault = false

export const AiObservabilityTracesSummaryCreateBody = /* @__PURE__ */ zod.object({
    regenerate: zod
        .boolean()
        .default(aiObservabilityTracesSummaryCreateBodyRegenerateDefault)
        .describe('Replace a ready summary with a new one. A pending summary is never replaced.'),
})

export const aiObservabilityTracesAvailabilityCreateBodyTraceIdsItemMax = 255

export const aiObservabilityTracesAvailabilityCreateBodyTraceIdsMax = 2

export const AiObservabilityTracesAvailabilityCreateBody = /* @__PURE__ */ zod.object({
    trace_ids: zod
        .array(zod.string().max(aiObservabilityTracesAvailabilityCreateBodyTraceIdsItemMax))
        .min(1)
        .max(aiObservabilityTracesAvailabilityCreateBodyTraceIdsMax)
        .describe('Application and evaluator trace IDs to check without loading trace contents.'),
})

/**
 * Create an item and its first immutable version. An identical client item ID retry returns the existing item. A different payload or an archived match returns a conflict.
 */
export const datasetItemsCreateBodyClientItemIdMax = 255

export const datasetItemsCreateBodySourceTraceIdMax = 255

export const datasetItemsCreateBodySourceEventIdMax = 255

export const DatasetItemsCreateBody = /* @__PURE__ */ zod.object({
    dataset: zod.uuid().describe('Dataset that will own the item.'),
    client_item_id: zod
        .string()
        .max(datasetItemsCreateBodyClientItemIdMax)
        .nullish()
        .describe('Optional case-sensitive stable key used for idempotent creates. It cannot be changed.'),
    input: zod
        .union([
            zod.record(zod.string(), zod.unknown()),
            zod.array(zod.unknown()),
            zod.string(),
            zod.number(),
            zod.boolean(),
        ])
        .describe('Input supplied to the system under test. Any non-null JSON value is accepted.'),
    expected_output: zod
        .union([
            zod.union([
                zod.record(zod.string(), zod.unknown()),
                zod.array(zod.unknown()),
                zod.string(),
                zod.number(),
                zod.boolean(),
            ]),
            zod.null(),
        ])
        .optional()
        .describe('Optional user-authored expected output.'),
    source_output: zod
        .union([
            zod.union([
                zod.record(zod.string(), zod.unknown()),
                zod.array(zod.unknown()),
                zod.string(),
                zod.number(),
                zod.boolean(),
            ]),
            zod.null(),
        ])
        .optional()
        .describe('Optional actual output captured from the source trace.'),
    metadata: zod.record(zod.string(), zod.unknown()).optional().describe('Optional JSON object with item metadata.'),
    source_trace_id: zod
        .string()
        .max(datasetItemsCreateBodySourceTraceIdMax)
        .nullish()
        .describe('Trace ID copied from the source event.'),
    source_event_id: zod
        .string()
        .max(datasetItemsCreateBodySourceEventIdMax)
        .nullish()
        .describe('Event ID copied from the source trace.'),
    source_timestamp: zod.iso
        .datetime({ offset: true })
        .nullish()
        .describe('Timestamp needed to retrieve the event-backed source trace.'),
})

/**
 * Create a new immutable item version from editable fields.
 */

export const DatasetItemsPartialUpdateBody = /* @__PURE__ */ zod.object({
    base_version: zod.number().min(1).describe('Current item version observed by the caller.'),
    input: zod
        .union([
            zod.record(zod.string(), zod.unknown()),
            zod.array(zod.unknown()),
            zod.string(),
            zod.number(),
            zod.boolean(),
        ])
        .optional()
        .describe('Replacement input. Omit to keep the current value.'),
    expected_output: zod
        .union([
            zod.record(zod.string(), zod.unknown()),
            zod.array(zod.unknown()),
            zod.string(),
            zod.number(),
            zod.boolean(),
            zod.null(),
        ])
        .optional()
        .describe('Replacement expected output. Send null to clear it.'),
    metadata: zod
        .record(zod.string(), zod.unknown())
        .optional()
        .describe('Replacement metadata object. Send an empty object to clear it.'),
})

/**
 * Archive an active item by creating a new immutable version.
 */

export const DatasetItemsArchiveBody = /* @__PURE__ */ zod.object({
    base_version: zod.number().min(1).describe('Current item version observed by the caller.'),
})

/**
 * Restore an archived item by copying content into a new immutable version.
 */

export const DatasetItemsRestoreBody = /* @__PURE__ */ zod.object({
    base_version: zod.number().min(1).describe('Current item version observed by the caller.'),
    source_version: zod
        .number()
        .min(1)
        .nullish()
        .describe("Historical version to copy. Omit to restore the archived version's content."),
})

/**
 * Create an empty dataset. Its first revision is created with its first item.
 */
export const datasetsCreateBodyTagsItemMax = 255

export const datasetsCreateBodyTagsMax = 100

export const datasetsCreateBodyNameMax = 400

export const datasetsCreateBodyDescriptionDefault = ``
export const datasetsCreateBodyDescriptionMax = 10000

export const DatasetsCreateBody = /* @__PURE__ */ zod.object({
    tags: zod
        .array(zod.string().max(datasetsCreateBodyTagsItemMax))
        .max(datasetsCreateBodyTagsMax)
        .optional()
        .describe('Tag names. Replaces existing tags; send [] to remove all tags. Names are trimmed and lowercased.'),
    name: zod.string().max(datasetsCreateBodyNameMax).describe('Dataset name. Names are unique within a project.'),
    description: zod
        .string()
        .max(datasetsCreateBodyDescriptionMax)
        .default(datasetsCreateBodyDescriptionDefault)
        .describe('Optional description of what the dataset contains.'),
    metadata: zod
        .record(zod.string(), zod.unknown())
        .optional()
        .describe('Optional JSON object with descriptive dataset metadata.'),
})

/**
 * Update descriptive dataset fields without changing its revision.
 */
export const datasetsPartialUpdateBodyTagsItemMax = 255

export const datasetsPartialUpdateBodyTagsMax = 100

export const datasetsPartialUpdateBodyNameMax = 400

export const datasetsPartialUpdateBodyDescriptionMax = 10000

export const DatasetsPartialUpdateBody = /* @__PURE__ */ zod.object({
    tags: zod
        .array(zod.string().max(datasetsPartialUpdateBodyTagsItemMax))
        .max(datasetsPartialUpdateBodyTagsMax)
        .optional()
        .describe('Tag names. Replaces existing tags; send [] to remove all tags. Names are trimmed and lowercased.'),
    name: zod
        .string()
        .max(datasetsPartialUpdateBodyNameMax)
        .optional()
        .describe('New dataset name. Names are unique within a project.'),
    description: zod
        .string()
        .max(datasetsPartialUpdateBodyDescriptionMax)
        .optional()
        .describe('New dataset description.'),
    metadata: zod
        .record(zod.string(), zod.unknown())
        .optional()
        .describe('Replacement JSON object for descriptive dataset metadata.'),
})

/**
 * Create an asynchronous JSONL export pinned to an immutable dataset revision.
 */

export const DatasetsExportsCreateBody = /* @__PURE__ */ zod.object({
    revision: zod
        .number()
        .min(1)
        .optional()
        .describe('Dataset revision to export. Defaults to the latest revision when the export is created.'),
})

export const evaluationDirectoriesCreateBodyNameMax = 400

export const EvaluationDirectoriesCreateBody = /* @__PURE__ */ zod.object({
    name: zod
        .string()
        .max(evaluationDirectoriesCreateBodyNameMax)
        .describe('Directory name shown in the online evals list.'),
})

export const evaluationDirectoriesPartialUpdateBodyNameMax = 400

export const EvaluationDirectoriesPartialUpdateBody = /* @__PURE__ */ zod.object({
    name: zod
        .string()
        .max(evaluationDirectoriesPartialUpdateBodyNameMax)
        .optional()
        .describe('Directory name shown in the online evals list.'),
})

/**
 * Create a new evaluation run.
 *
 * This endpoint validates the request and enqueues a Temporal workflow
 * to asynchronously execute the evaluation.
 */
export const evaluationRunsCreateBodyEventDefault = `$ai_generation`

export const EvaluationRunsCreateBody = /* @__PURE__ */ zod.object({
    evaluation_id: zod.uuid().describe('UUID of the evaluation to run.'),
    target_event_id: zod.uuid().describe('UUID of the $ai_generation event to evaluate.'),
    timestamp: zod.iso
        .datetime({ offset: true })
        .describe('ISO 8601 timestamp of the target event (needed for efficient ClickHouse lookup).'),
    event: zod
        .string()
        .default(evaluationRunsCreateBodyEventDefault)
        .describe("Event name. Defaults to '$ai_generation'."),
    distinct_id: zod.string().nullish().describe('Distinct ID of the event (optional, improves lookup performance).'),
})

export const evaluationsCreateBodyNameMax = 400

export const evaluationsCreateBodyEvaluationConfigThreeSourceDefault = `user_messages`
export const evaluationsCreateBodyOutputConfigDecisionThresholdMin = 0
export const evaluationsCreateBodyOutputConfigDecisionThresholdMax = 1

export const evaluationsCreateBodyOutputConfigStepExclusiveMin = 0

export const evaluationsCreateBodyOutputConfigOptionsItemKeyMax = 128

export const evaluationsCreateBodyOutputConfigOptionsItemKeyRegExp = new RegExp('^[a-z0-9]+(?:[_-][a-z0-9]+)\*$')
export const evaluationsCreateBodyOutputConfigOptionsItemLabelMax = 256

export const evaluationsCreateBodyOutputConfigOptionsMax = 100

export const evaluationsCreateBodyConditionsItemIdMax = 100

export const evaluationsCreateBodyConditionsItemRolloutPercentageDefault = 100
export const evaluationsCreateBodyConditionsItemRolloutPercentageMin = 0
export const evaluationsCreateBodyConditionsItemRolloutPercentageMax = 100

export const evaluationsCreateBodyTargetConfigWindowSecondsMin = 10
export const evaluationsCreateBodyTargetConfigWindowSecondsMax = 604800

export const evaluationsCreateBodyTargetConfigQuietPeriodSecondsMin = 10
export const evaluationsCreateBodyTargetConfigQuietPeriodSecondsMax = 86400

export const evaluationsCreateBodyTargetConfigMaxAgeSecondsMin = 60
export const evaluationsCreateBodyTargetConfigMaxAgeSecondsMax = 604800

export const evaluationsCreateBodyModelConfigurationOneModelMax = 100

export const EvaluationsCreateBody = /* @__PURE__ */ zod
    .object({
        name: zod.string().max(evaluationsCreateBodyNameMax).describe('Name of the evaluation.'),
        description: zod.string().optional().describe('Optional description of what this evaluation checks.'),
        directory_id: zod
            .uuid()
            .nullish()
            .describe('Directory containing the evaluation. Pass null to move the evaluation to the top level.'),
        enabled: zod
            .boolean()
            .optional()
            .describe('Whether the evaluation runs automatically on new $ai_generation events.'),
        evaluation_type: zod
            .enum(['llm_judge', 'hog', 'sentiment'])
            .describe('\* `llm_judge` - LLM as a judge\n\* `hog` - Hog\n\* `sentiment` - Sentiment analysis')
            .describe(
                "'llm_judge' uses an LLM to score outputs against a prompt; 'hog' runs deterministic Hog code; 'sentiment' classifies user-message sentiment (trained on English, so use 'llm_judge' for multilingual agents).\n\n\* `llm_judge` - LLM as a judge\n\* `hog` - Hog\n\* `sentiment` - Sentiment analysis"
            ),
        evaluation_config: zod
            .union([
                zod.object({
                    prompt: zod
                        .string()
                        .min(1)
                        .describe('Evaluation criteria for the LLM judge. Describe what makes a good vs bad response.'),
                    judge_method: zod
                        .enum(['llm', 'decision'])
                        .nullish()
                        .describe('Judge method. Omit to keep the saved method; null restores automatic routing.'),
                    include_media: zod.boolean().optional().describe('Set to false to judge text only.'),
                    reasoning_level: zod
                        .enum(['minimal', 'low', 'medium', 'high'])
                        .nullish()
                        .describe(
                            "How much the judge model reasons before it answers. Only Anthropic and OpenAI reasoning models with the 'llm' judge method support it. Omit to keep the saved level; null uses the model's default."
                        ),
                }),
                zod.object({
                    source: zod
                        .string()
                        .min(1)
                        .describe(
                            'Hog source code. Return a boolean, finite number, or category keys matching output_type. Categorical single selection accepts one key or a one-item list; multiple selection accepts a list, including []. Return null only for allowed N\/A. Output settings determine which boolean counts as a failure.'
                        ),
                }),
                zod.object({
                    source: zod
                        .enum(['user_messages'])
                        .default(evaluationsCreateBodyEvaluationConfigThreeSourceDefault)
                        .describe(
                            "Classify sentiment from user messages in the generation input. The classifier is trained on English, so labels are unreliable for other languages; use an 'llm_judge' evaluation for multilingual agents."
                        ),
                }),
            ])
            .optional()
            .describe(
                "Configuration dict. For 'llm_judge': {prompt}; for 'hog': {source}; for 'sentiment': {source: 'user_messages'}."
            ),
        output_type: zod
            .enum(['boolean', 'numeric', 'categorical', 'sentiment'])
            .describe(
                '\* `boolean` - Boolean (Pass\/Fail)\n\* `numeric` - Numeric\n\* `categorical` - Categorical\n\* `sentiment` - Sentiment'
            )
            .describe(
                "Output format: 'boolean', 'numeric' for a finite score, 'categorical' for category keys, or 'sentiment' for sentiment analysis.\n\n\* `boolean` - Boolean (Pass\/Fail)\n\* `numeric` - Numeric\n\* `categorical` - Categorical\n\* `sentiment` - Sentiment"
            ),
        output_config: zod
            .object({
                allows_na: zod
                    .boolean()
                    .optional()
                    .describe('Whether the evaluation can return N\/A for non-applicable generations.'),
                true_is_failure: zod
                    .boolean()
                    .optional()
                    .describe(
                        'Boolean output only. Omit for numeric, categorical, and sentiment output. Whether a true result means the evaluation found a problem. False (the default) suits pass\/fail evaluations, where a true result satisfied the criteria. Set it to true for detector-style evaluations, so a true result is counted and labeled as a fail.'
                    ),
                decision_threshold: zod
                    .number()
                    .min(evaluationsCreateBodyOutputConfigDecisionThresholdMin)
                    .max(evaluationsCreateBodyOutputConfigDecisionThresholdMax)
                    .nullish()
                    .describe(
                        'Boolean decision-model judges only. Minimum probability of true required for a true result, inclusive. Omit or set null to use 0.5. Applies to new runs; historical results are unchanged.'
                    ),
                min: zod
                    .number()
                    .nullish()
                    .describe(
                        'Inclusive minimum numeric score. Omit for no lower bound. Required for numeric decision models.'
                    ),
                max: zod
                    .number()
                    .nullish()
                    .describe(
                        'Inclusive maximum numeric score. Omit for no upper bound. Required for numeric decision models and must exceed min.'
                    ),
                step: zod
                    .number()
                    .gt(evaluationsCreateBodyOutputConfigStepExclusiveMin)
                    .nullish()
                    .describe('Optional positive input increment. Does not round evaluation results.'),
                options: zod
                    .array(
                        zod.object({
                            key: zod
                                .string()
                                .min(1)
                                .max(evaluationsCreateBodyOutputConfigOptionsItemKeyMax)
                                .regex(evaluationsCreateBodyOutputConfigOptionsItemKeyRegExp)
                                .describe('Stable category key.'),
                            label: zod
                                .string()
                                .min(1)
                                .max(evaluationsCreateBodyOutputConfigOptionsItemLabelMax)
                                .describe('Category display label.'),
                        })
                    )
                    .min(1)
                    .max(evaluationsCreateBodyOutputConfigOptionsMax)
                    .optional()
                    .describe(
                        'Categorical output options. Keys identify stored results; labels are displayed to users.'
                    ),
                selection_mode: zod
                    .enum(['single', 'multiple'])
                    .optional()
                    .describe(
                        'Select one category or multiple categories. Multiple selection allows an empty result. Defaults to single.'
                    ),
                passing_rule: zod
                    .union([
                        zod.object({
                            operator: zod
                                .enum(['gte', 'lte'])
                                .describe('Pass at or above (gte), or at or below (lte), the threshold.'),
                            threshold: zod
                                .number()
                                .describe('Finite passing threshold within any configured score bounds.'),
                        }),
                        zod.object({
                            categories: zod
                                .array(zod.string())
                                .describe(
                                    'Passing category keys. With keys selected, results must be non-empty and contain only these keys. If no passing keys are selected, only an empty result passes.'
                                ),
                        }),
                        zod.null(),
                    ])
                    .optional()
                    .describe(
                        'Optional numeric or categorical passing rule. Null removes the rule; historical results use the current rule.'
                    ),
            })
            .optional()
            .describe(
                "Output config. For 'boolean' output_type: {allows_na} to permit N\/A results, and {true_is_failure} to declare that a true result means the evaluation found a problem. For boolean decision-model judges, decision_threshold is a probability from 0 to 1 (default 0.5). For 'numeric': only min\/max\/step, allows_na, and passing_rule {operator: 'gte'|'lte', threshold}. For 'categorical': options [{key, label}], selection_mode (single or multiple), allows_na, and optional passing_rule {categories: [key]}. Do not send true_is_failure for numeric or categorical output. For 'sentiment': {}."
            ),
        conditions: zod
            .array(
                zod
                    .object({
                        id: zod
                            .string()
                            .max(evaluationsCreateBodyConditionsItemIdMax)
                            .describe('Stable identifier for this condition set.'),
                        rollout_percentage: zod
                            .number()
                            .min(evaluationsCreateBodyConditionsItemRolloutPercentageMin)
                            .max(evaluationsCreateBodyConditionsItemRolloutPercentageMax)
                            .default(evaluationsCreateBodyConditionsItemRolloutPercentageDefault)
                            .describe(
                                'Percentage (0-100) of matching events to sample for this evaluation. Defaults to 100.'
                            ),
                        properties: zod
                            .array(zod.record(zod.string(), zod.unknown()))
                            .optional()
                            .describe(
                                'Property filters (event or person) that scope which generations match this condition set.'
                            ),
                    })
                    .describe('A trigger condition set controlling which generations an evaluation runs on.')
            )
            .optional()
            .describe(
                'Trigger conditions that filter which events are evaluated. OR between condition sets, AND within each. Each set is {id, rollout_percentage, properties[]} — `rollout_percentage` (0-100, defaults to 100) is the sampling field the dispatcher reads.'
            ),
        target: zod
            .enum(['generation', 'trace', 'session'])
            .describe('\* `generation` - Generation\n\* `trace` - Trace\n\* `session` - Session')
            .optional()
            .describe(
                "What the evaluation runs on. 'generation' evaluates each matching $ai_generation event individually. 'trace' evaluates the whole trace once and 'session' the whole $ai_session_id session once: the first matching generation schedules a run that waits for the unit to settle, then evaluates all of its events together. Condition filters still match individual generations — a unit is evaluated when any of its generations matches, and sampling applies per unit. A 'session' evaluation only fires for generations that carry $ai_session_id. When and how the run fires is controlled by target_config's settle strategy.\n\n\* `generation` - Generation\n\* `trace` - Trace\n\* `session` - Session"
            ),
        target_config: zod
            .object({
                strategy: zod
                    .enum(['fixed_window', 'inactivity'])
                    .optional()
                    .describe(
                        "'fixed_window' waits a fixed window after the first matching generation, then evaluates. 'inactivity' evaluates once the unit has had no new activity for the quiet period. Omit it to use the target's default: 'fixed_window' for 'trace', 'inactivity' for 'session'."
                    ),
                window_seconds: zod
                    .number()
                    .min(evaluationsCreateBodyTargetConfigWindowSecondsMin)
                    .max(evaluationsCreateBodyTargetConfigWindowSecondsMax)
                    .optional()
                    .describe(
                        "fixed_window only. Seconds to wait after the first matching generation before evaluating the whole unit. Captured when the run is scheduled — editing it does not change runs already in flight. The accepted range depends on `target`: 10–7200 for 'trace', 10–604800 for 'session'. The default also depends on `target`; see the field-level help_text."
                    ),
                quiet_period_seconds: zod
                    .number()
                    .min(evaluationsCreateBodyTargetConfigQuietPeriodSecondsMin)
                    .max(evaluationsCreateBodyTargetConfigQuietPeriodSecondsMax)
                    .optional()
                    .describe(
                        "inactivity only. Seconds without new activity before the unit counts as settled. The accepted range depends on `target`: 10–1800 for 'trace', 10–86400 for 'session'. The default also depends on `target`; see the field-level help_text."
                    ),
                max_age_seconds: zod
                    .number()
                    .min(evaluationsCreateBodyTargetConfigMaxAgeSecondsMin)
                    .max(evaluationsCreateBodyTargetConfigMaxAgeSecondsMax)
                    .optional()
                    .describe(
                        "inactivity only. Hard cap in seconds on the total wait from the first matching generation, even if the unit stays active. Must be at least quiet_period_seconds. The accepted range depends on `target`: 60–7200 for 'trace', 60–604800 for 'session'. The default also depends on `target`; see the field-level help_text."
                    ),
            })
            .optional()
            .describe(
                "Target-specific config. Send {} or omit it for 'generation'. For 'trace' and 'session' targets: a settle config, either 'fixed_window' {window_seconds} or 'inactivity' {quiet_period_seconds, max_age_seconds}. Omit `strategy` to use the target's default. The server fills in any other field you omit, using per-target defaults, and the accepted bounds also depend on `target`."
            ),
        model_configuration: zod
            .union([
                zod
                    .object({
                        provider: zod
                            .enum([
                                'openai',
                                'anthropic',
                                'gemini',
                                'openrouter',
                                'fireworks',
                                'azure_openai',
                                'together_ai',
                                'minimax',
                                'system_one',
                                'openai_compatible',
                            ])
                            .describe(
                                '\* `openai` - Openai\n\* `anthropic` - Anthropic\n\* `gemini` - Gemini\n\* `openrouter` - Openrouter\n\* `fireworks` - Fireworks\n\* `azure_openai` - Azure OpenAI\n\* `together_ai` - Together AI\n\* `minimax` - MiniMax\n\* `system_one` - System One\n\* `openai_compatible` - OpenAI-compatible'
                            ),
                        model: zod.string().max(evaluationsCreateBodyModelConfigurationOneModelMax),
                        provider_key_id: zod
                            .uuid()
                            .nullish()
                            .describe(
                                'Optional team provider key to run this evaluation with; it must use the same provider. May be null when no key is pinned or after the selected key is removed.'
                            ),
                        provider_key_name: zod.string().nullable(),
                    })
                    .describe('Nested serializer for model configuration.'),
                zod.null(),
            ])
            .optional()
            .describe(
                'Provider and model for an llm_judge evaluation. Required when creating or switching to llm_judge. To add or replace a model, provide both provider and model. On an existing configured llm_judge, omit this field to keep the current model; null is rejected. When switching an llm_judge to hog or sentiment, set this field to null. Legacy llm_judge evaluations without a model remain editable without adding one. The nested provider_key_id may be null.'
            ),
        deleted: zod.boolean().optional().describe('Set to true to soft-delete the evaluation.'),
    })
    .describe('An evaluation that scores LLM generations, traces, or sessions.')

/**
 * Create a backfill: freeze the conditions, count the units, start the walk.
 */
export const evaluationsBackfillsCreateBodyConditionsItemIdMax = 100

export const evaluationsBackfillsCreateBodyConditionsItemRolloutPercentageDefault = 100
export const evaluationsBackfillsCreateBodyConditionsItemRolloutPercentageMin = 0
export const evaluationsBackfillsCreateBodyConditionsItemRolloutPercentageMax = 100

export const evaluationsBackfillsCreateBodyRerunExistingDefault = false

export const EvaluationsBackfillsCreateBody = /* @__PURE__ */ zod.object({
    window_start: zod.iso.datetime({ offset: true }).describe('Inclusive start of the window, by unit timestamp.'),
    window_end: zod.iso
        .datetime({ offset: true })
        .describe('Exclusive end of the window. Values in the future are clamped to now.'),
    conditions: zod
        .array(
            zod
                .object({
                    id: zod
                        .string()
                        .max(evaluationsBackfillsCreateBodyConditionsItemIdMax)
                        .describe('Stable identifier for this condition set.'),
                    rollout_percentage: zod
                        .number()
                        .min(evaluationsBackfillsCreateBodyConditionsItemRolloutPercentageMin)
                        .max(evaluationsBackfillsCreateBodyConditionsItemRolloutPercentageMax)
                        .default(evaluationsBackfillsCreateBodyConditionsItemRolloutPercentageDefault)
                        .describe(
                            'Percentage (0-100) of matching events to sample for this evaluation. Defaults to 100.'
                        ),
                    properties: zod
                        .array(zod.record(zod.string(), zod.unknown()))
                        .optional()
                        .describe(
                            'Property filters (event or person) that scope which generations match this condition set.'
                        ),
                })
                .describe('A trigger condition set controlling which generations an evaluation runs on.')
        )
        .optional()
        .describe("Condition sets to match. Defaults to the evaluation's own condition sets."),
    rerun_existing: zod
        .boolean()
        .default(evaluationsBackfillsCreateBodyRerunExistingDefault)
        .describe('Evaluate units again even when this evaluation already has a result for them.'),
})

/**
 * Count what a backfill over the given window would evaluate, without creating one.
 */
export const evaluationsBackfillsEstimateCreateBodyConditionsItemIdMax = 100

export const evaluationsBackfillsEstimateCreateBodyConditionsItemRolloutPercentageDefault = 100
export const evaluationsBackfillsEstimateCreateBodyConditionsItemRolloutPercentageMin = 0
export const evaluationsBackfillsEstimateCreateBodyConditionsItemRolloutPercentageMax = 100

export const evaluationsBackfillsEstimateCreateBodyRerunExistingDefault = false

export const EvaluationsBackfillsEstimateCreateBody = /* @__PURE__ */ zod.object({
    window_start: zod.iso.datetime({ offset: true }).describe('Inclusive start of the window, by unit timestamp.'),
    window_end: zod.iso
        .datetime({ offset: true })
        .describe('Exclusive end of the window. Values in the future are clamped to now.'),
    conditions: zod
        .array(
            zod
                .object({
                    id: zod
                        .string()
                        .max(evaluationsBackfillsEstimateCreateBodyConditionsItemIdMax)
                        .describe('Stable identifier for this condition set.'),
                    rollout_percentage: zod
                        .number()
                        .min(evaluationsBackfillsEstimateCreateBodyConditionsItemRolloutPercentageMin)
                        .max(evaluationsBackfillsEstimateCreateBodyConditionsItemRolloutPercentageMax)
                        .default(evaluationsBackfillsEstimateCreateBodyConditionsItemRolloutPercentageDefault)
                        .describe(
                            'Percentage (0-100) of matching events to sample for this evaluation. Defaults to 100.'
                        ),
                    properties: zod
                        .array(zod.record(zod.string(), zod.unknown()))
                        .optional()
                        .describe(
                            'Property filters (event or person) that scope which generations match this condition set.'
                        ),
                })
                .describe('A trigger condition set controlling which generations an evaluation runs on.')
        )
        .optional()
        .describe("Condition sets to match. Defaults to the evaluation's own condition sets."),
    rerun_existing: zod
        .boolean()
        .default(evaluationsBackfillsEstimateCreateBodyRerunExistingDefault)
        .describe('Evaluate units again even when this evaluation already has a result for them.'),
})

export const evaluationsUpdateBodyNameMax = 400

export const evaluationsUpdateBodyEvaluationConfigThreeSourceDefault = `user_messages`
export const evaluationsUpdateBodyOutputConfigDecisionThresholdMin = 0
export const evaluationsUpdateBodyOutputConfigDecisionThresholdMax = 1

export const evaluationsUpdateBodyOutputConfigStepExclusiveMin = 0

export const evaluationsUpdateBodyOutputConfigOptionsItemKeyMax = 128

export const evaluationsUpdateBodyOutputConfigOptionsItemKeyRegExp = new RegExp('^[a-z0-9]+(?:[_-][a-z0-9]+)\*$')
export const evaluationsUpdateBodyOutputConfigOptionsItemLabelMax = 256

export const evaluationsUpdateBodyOutputConfigOptionsMax = 100

export const evaluationsUpdateBodyConditionsItemIdMax = 100

export const evaluationsUpdateBodyConditionsItemRolloutPercentageDefault = 100
export const evaluationsUpdateBodyConditionsItemRolloutPercentageMin = 0
export const evaluationsUpdateBodyConditionsItemRolloutPercentageMax = 100

export const evaluationsUpdateBodyTargetConfigWindowSecondsMin = 10
export const evaluationsUpdateBodyTargetConfigWindowSecondsMax = 604800

export const evaluationsUpdateBodyTargetConfigQuietPeriodSecondsMin = 10
export const evaluationsUpdateBodyTargetConfigQuietPeriodSecondsMax = 86400

export const evaluationsUpdateBodyTargetConfigMaxAgeSecondsMin = 60
export const evaluationsUpdateBodyTargetConfigMaxAgeSecondsMax = 604800

export const evaluationsUpdateBodyModelConfigurationOneModelMax = 100

export const EvaluationsUpdateBody = /* @__PURE__ */ zod
    .object({
        name: zod.string().max(evaluationsUpdateBodyNameMax).describe('Name of the evaluation.'),
        description: zod.string().optional().describe('Optional description of what this evaluation checks.'),
        directory_id: zod
            .uuid()
            .nullish()
            .describe('Directory containing the evaluation. Pass null to move the evaluation to the top level.'),
        enabled: zod
            .boolean()
            .optional()
            .describe('Whether the evaluation runs automatically on new $ai_generation events.'),
        evaluation_type: zod
            .enum(['llm_judge', 'hog', 'sentiment'])
            .describe('\* `llm_judge` - LLM as a judge\n\* `hog` - Hog\n\* `sentiment` - Sentiment analysis')
            .describe(
                "'llm_judge' uses an LLM to score outputs against a prompt; 'hog' runs deterministic Hog code; 'sentiment' classifies user-message sentiment (trained on English, so use 'llm_judge' for multilingual agents).\n\n\* `llm_judge` - LLM as a judge\n\* `hog` - Hog\n\* `sentiment` - Sentiment analysis"
            ),
        evaluation_config: zod
            .union([
                zod.object({
                    prompt: zod
                        .string()
                        .min(1)
                        .describe('Evaluation criteria for the LLM judge. Describe what makes a good vs bad response.'),
                    judge_method: zod
                        .enum(['llm', 'decision'])
                        .nullish()
                        .describe('Judge method. Omit to keep the saved method; null restores automatic routing.'),
                    include_media: zod.boolean().optional().describe('Set to false to judge text only.'),
                    reasoning_level: zod
                        .enum(['minimal', 'low', 'medium', 'high'])
                        .nullish()
                        .describe(
                            "How much the judge model reasons before it answers. Only Anthropic and OpenAI reasoning models with the 'llm' judge method support it. Omit to keep the saved level; null uses the model's default."
                        ),
                }),
                zod.object({
                    source: zod
                        .string()
                        .min(1)
                        .describe(
                            'Hog source code. Return a boolean, finite number, or category keys matching output_type. Categorical single selection accepts one key or a one-item list; multiple selection accepts a list, including []. Return null only for allowed N\/A. Output settings determine which boolean counts as a failure.'
                        ),
                }),
                zod.object({
                    source: zod
                        .enum(['user_messages'])
                        .default(evaluationsUpdateBodyEvaluationConfigThreeSourceDefault)
                        .describe(
                            "Classify sentiment from user messages in the generation input. The classifier is trained on English, so labels are unreliable for other languages; use an 'llm_judge' evaluation for multilingual agents."
                        ),
                }),
            ])
            .optional()
            .describe(
                "Configuration dict. For 'llm_judge': {prompt}; for 'hog': {source}; for 'sentiment': {source: 'user_messages'}."
            ),
        output_type: zod
            .enum(['boolean', 'numeric', 'categorical', 'sentiment'])
            .describe(
                '\* `boolean` - Boolean (Pass\/Fail)\n\* `numeric` - Numeric\n\* `categorical` - Categorical\n\* `sentiment` - Sentiment'
            )
            .describe(
                "Output format: 'boolean', 'numeric' for a finite score, 'categorical' for category keys, or 'sentiment' for sentiment analysis.\n\n\* `boolean` - Boolean (Pass\/Fail)\n\* `numeric` - Numeric\n\* `categorical` - Categorical\n\* `sentiment` - Sentiment"
            ),
        output_config: zod
            .object({
                allows_na: zod
                    .boolean()
                    .optional()
                    .describe('Whether the evaluation can return N\/A for non-applicable generations.'),
                true_is_failure: zod
                    .boolean()
                    .optional()
                    .describe(
                        'Boolean output only. Omit for numeric, categorical, and sentiment output. Whether a true result means the evaluation found a problem. False (the default) suits pass\/fail evaluations, where a true result satisfied the criteria. Set it to true for detector-style evaluations, so a true result is counted and labeled as a fail.'
                    ),
                decision_threshold: zod
                    .number()
                    .min(evaluationsUpdateBodyOutputConfigDecisionThresholdMin)
                    .max(evaluationsUpdateBodyOutputConfigDecisionThresholdMax)
                    .nullish()
                    .describe(
                        'Boolean decision-model judges only. Minimum probability of true required for a true result, inclusive. Omit or set null to use 0.5. Applies to new runs; historical results are unchanged.'
                    ),
                min: zod
                    .number()
                    .nullish()
                    .describe(
                        'Inclusive minimum numeric score. Omit for no lower bound. Required for numeric decision models.'
                    ),
                max: zod
                    .number()
                    .nullish()
                    .describe(
                        'Inclusive maximum numeric score. Omit for no upper bound. Required for numeric decision models and must exceed min.'
                    ),
                step: zod
                    .number()
                    .gt(evaluationsUpdateBodyOutputConfigStepExclusiveMin)
                    .nullish()
                    .describe('Optional positive input increment. Does not round evaluation results.'),
                options: zod
                    .array(
                        zod.object({
                            key: zod
                                .string()
                                .min(1)
                                .max(evaluationsUpdateBodyOutputConfigOptionsItemKeyMax)
                                .regex(evaluationsUpdateBodyOutputConfigOptionsItemKeyRegExp)
                                .describe('Stable category key.'),
                            label: zod
                                .string()
                                .min(1)
                                .max(evaluationsUpdateBodyOutputConfigOptionsItemLabelMax)
                                .describe('Category display label.'),
                        })
                    )
                    .min(1)
                    .max(evaluationsUpdateBodyOutputConfigOptionsMax)
                    .optional()
                    .describe(
                        'Categorical output options. Keys identify stored results; labels are displayed to users.'
                    ),
                selection_mode: zod
                    .enum(['single', 'multiple'])
                    .optional()
                    .describe(
                        'Select one category or multiple categories. Multiple selection allows an empty result. Defaults to single.'
                    ),
                passing_rule: zod
                    .union([
                        zod.object({
                            operator: zod
                                .enum(['gte', 'lte'])
                                .describe('Pass at or above (gte), or at or below (lte), the threshold.'),
                            threshold: zod
                                .number()
                                .describe('Finite passing threshold within any configured score bounds.'),
                        }),
                        zod.object({
                            categories: zod
                                .array(zod.string())
                                .describe(
                                    'Passing category keys. With keys selected, results must be non-empty and contain only these keys. If no passing keys are selected, only an empty result passes.'
                                ),
                        }),
                        zod.null(),
                    ])
                    .optional()
                    .describe(
                        'Optional numeric or categorical passing rule. Null removes the rule; historical results use the current rule.'
                    ),
            })
            .optional()
            .describe(
                "Output config. For 'boolean' output_type: {allows_na} to permit N\/A results, and {true_is_failure} to declare that a true result means the evaluation found a problem. For boolean decision-model judges, decision_threshold is a probability from 0 to 1 (default 0.5). For 'numeric': only min\/max\/step, allows_na, and passing_rule {operator: 'gte'|'lte', threshold}. For 'categorical': options [{key, label}], selection_mode (single or multiple), allows_na, and optional passing_rule {categories: [key]}. Do not send true_is_failure for numeric or categorical output. For 'sentiment': {}."
            ),
        conditions: zod
            .array(
                zod
                    .object({
                        id: zod
                            .string()
                            .max(evaluationsUpdateBodyConditionsItemIdMax)
                            .describe('Stable identifier for this condition set.'),
                        rollout_percentage: zod
                            .number()
                            .min(evaluationsUpdateBodyConditionsItemRolloutPercentageMin)
                            .max(evaluationsUpdateBodyConditionsItemRolloutPercentageMax)
                            .default(evaluationsUpdateBodyConditionsItemRolloutPercentageDefault)
                            .describe(
                                'Percentage (0-100) of matching events to sample for this evaluation. Defaults to 100.'
                            ),
                        properties: zod
                            .array(zod.record(zod.string(), zod.unknown()))
                            .optional()
                            .describe(
                                'Property filters (event or person) that scope which generations match this condition set.'
                            ),
                    })
                    .describe('A trigger condition set controlling which generations an evaluation runs on.')
            )
            .optional()
            .describe(
                'Trigger conditions that filter which events are evaluated. OR between condition sets, AND within each. Each set is {id, rollout_percentage, properties[]} — `rollout_percentage` (0-100, defaults to 100) is the sampling field the dispatcher reads.'
            ),
        target: zod
            .enum(['generation', 'trace', 'session'])
            .describe('\* `generation` - Generation\n\* `trace` - Trace\n\* `session` - Session')
            .optional()
            .describe(
                "What the evaluation runs on. 'generation' evaluates each matching $ai_generation event individually. 'trace' evaluates the whole trace once and 'session' the whole $ai_session_id session once: the first matching generation schedules a run that waits for the unit to settle, then evaluates all of its events together. Condition filters still match individual generations — a unit is evaluated when any of its generations matches, and sampling applies per unit. A 'session' evaluation only fires for generations that carry $ai_session_id. When and how the run fires is controlled by target_config's settle strategy.\n\n\* `generation` - Generation\n\* `trace` - Trace\n\* `session` - Session"
            ),
        target_config: zod
            .object({
                strategy: zod
                    .enum(['fixed_window', 'inactivity'])
                    .optional()
                    .describe(
                        "'fixed_window' waits a fixed window after the first matching generation, then evaluates. 'inactivity' evaluates once the unit has had no new activity for the quiet period. Omit it to use the target's default: 'fixed_window' for 'trace', 'inactivity' for 'session'."
                    ),
                window_seconds: zod
                    .number()
                    .min(evaluationsUpdateBodyTargetConfigWindowSecondsMin)
                    .max(evaluationsUpdateBodyTargetConfigWindowSecondsMax)
                    .optional()
                    .describe(
                        "fixed_window only. Seconds to wait after the first matching generation before evaluating the whole unit. Captured when the run is scheduled — editing it does not change runs already in flight. The accepted range depends on `target`: 10–7200 for 'trace', 10–604800 for 'session'. The default also depends on `target`; see the field-level help_text."
                    ),
                quiet_period_seconds: zod
                    .number()
                    .min(evaluationsUpdateBodyTargetConfigQuietPeriodSecondsMin)
                    .max(evaluationsUpdateBodyTargetConfigQuietPeriodSecondsMax)
                    .optional()
                    .describe(
                        "inactivity only. Seconds without new activity before the unit counts as settled. The accepted range depends on `target`: 10–1800 for 'trace', 10–86400 for 'session'. The default also depends on `target`; see the field-level help_text."
                    ),
                max_age_seconds: zod
                    .number()
                    .min(evaluationsUpdateBodyTargetConfigMaxAgeSecondsMin)
                    .max(evaluationsUpdateBodyTargetConfigMaxAgeSecondsMax)
                    .optional()
                    .describe(
                        "inactivity only. Hard cap in seconds on the total wait from the first matching generation, even if the unit stays active. Must be at least quiet_period_seconds. The accepted range depends on `target`: 60–7200 for 'trace', 60–604800 for 'session'. The default also depends on `target`; see the field-level help_text."
                    ),
            })
            .optional()
            .describe(
                "Target-specific config. Send {} or omit it for 'generation'. For 'trace' and 'session' targets: a settle config, either 'fixed_window' {window_seconds} or 'inactivity' {quiet_period_seconds, max_age_seconds}. Omit `strategy` to use the target's default. The server fills in any other field you omit, using per-target defaults, and the accepted bounds also depend on `target`."
            ),
        model_configuration: zod
            .union([
                zod
                    .object({
                        provider: zod
                            .enum([
                                'openai',
                                'anthropic',
                                'gemini',
                                'openrouter',
                                'fireworks',
                                'azure_openai',
                                'together_ai',
                                'minimax',
                                'system_one',
                                'openai_compatible',
                            ])
                            .describe(
                                '\* `openai` - Openai\n\* `anthropic` - Anthropic\n\* `gemini` - Gemini\n\* `openrouter` - Openrouter\n\* `fireworks` - Fireworks\n\* `azure_openai` - Azure OpenAI\n\* `together_ai` - Together AI\n\* `minimax` - MiniMax\n\* `system_one` - System One\n\* `openai_compatible` - OpenAI-compatible'
                            ),
                        model: zod.string().max(evaluationsUpdateBodyModelConfigurationOneModelMax),
                        provider_key_id: zod
                            .uuid()
                            .nullish()
                            .describe(
                                'Optional team provider key to run this evaluation with; it must use the same provider. May be null when no key is pinned or after the selected key is removed.'
                            ),
                        provider_key_name: zod.string().nullable(),
                    })
                    .describe('Nested serializer for model configuration.'),
                zod.null(),
            ])
            .optional()
            .describe(
                'Provider and model for an llm_judge evaluation. Required when creating or switching to llm_judge. To add or replace a model, provide both provider and model. On an existing configured llm_judge, omit this field to keep the current model; null is rejected. When switching an llm_judge to hog or sentiment, set this field to null. Legacy llm_judge evaluations without a model remain editable without adding one. The nested provider_key_id may be null.'
            ),
        deleted: zod.boolean().optional().describe('Set to true to soft-delete the evaluation.'),
    })
    .describe('An evaluation that scores LLM generations, traces, or sessions.')

export const evaluationsPartialUpdateBodyNameMax = 400

export const evaluationsPartialUpdateBodyEvaluationConfigThreeSourceDefault = `user_messages`
export const evaluationsPartialUpdateBodyOutputConfigDecisionThresholdMin = 0
export const evaluationsPartialUpdateBodyOutputConfigDecisionThresholdMax = 1

export const evaluationsPartialUpdateBodyOutputConfigStepExclusiveMin = 0

export const evaluationsPartialUpdateBodyOutputConfigOptionsItemKeyMax = 128

export const evaluationsPartialUpdateBodyOutputConfigOptionsItemKeyRegExp = new RegExp('^[a-z0-9]+(?:[_-][a-z0-9]+)\*$')
export const evaluationsPartialUpdateBodyOutputConfigOptionsItemLabelMax = 256

export const evaluationsPartialUpdateBodyOutputConfigOptionsMax = 100

export const evaluationsPartialUpdateBodyConditionsItemIdMax = 100

export const evaluationsPartialUpdateBodyConditionsItemRolloutPercentageDefault = 100
export const evaluationsPartialUpdateBodyConditionsItemRolloutPercentageMin = 0
export const evaluationsPartialUpdateBodyConditionsItemRolloutPercentageMax = 100

export const evaluationsPartialUpdateBodyTargetConfigWindowSecondsMin = 10
export const evaluationsPartialUpdateBodyTargetConfigWindowSecondsMax = 604800

export const evaluationsPartialUpdateBodyTargetConfigQuietPeriodSecondsMin = 10
export const evaluationsPartialUpdateBodyTargetConfigQuietPeriodSecondsMax = 86400

export const evaluationsPartialUpdateBodyTargetConfigMaxAgeSecondsMin = 60
export const evaluationsPartialUpdateBodyTargetConfigMaxAgeSecondsMax = 604800

export const evaluationsPartialUpdateBodyModelConfigurationOneModelMax = 100

export const EvaluationsPartialUpdateBody = /* @__PURE__ */ zod
    .object({
        name: zod.string().max(evaluationsPartialUpdateBodyNameMax).optional().describe('Name of the evaluation.'),
        description: zod.string().optional().describe('Optional description of what this evaluation checks.'),
        directory_id: zod
            .uuid()
            .nullish()
            .describe('Directory containing the evaluation. Pass null to move the evaluation to the top level.'),
        enabled: zod
            .boolean()
            .optional()
            .describe('Whether the evaluation runs automatically on new $ai_generation events.'),
        evaluation_type: zod
            .enum(['llm_judge', 'hog', 'sentiment'])
            .describe('\* `llm_judge` - LLM as a judge\n\* `hog` - Hog\n\* `sentiment` - Sentiment analysis')
            .optional()
            .describe(
                "'llm_judge' uses an LLM to score outputs against a prompt; 'hog' runs deterministic Hog code; 'sentiment' classifies user-message sentiment (trained on English, so use 'llm_judge' for multilingual agents).\n\n\* `llm_judge` - LLM as a judge\n\* `hog` - Hog\n\* `sentiment` - Sentiment analysis"
            ),
        evaluation_config: zod
            .union([
                zod.object({
                    prompt: zod
                        .string()
                        .min(1)
                        .describe('Evaluation criteria for the LLM judge. Describe what makes a good vs bad response.'),
                    judge_method: zod
                        .enum(['llm', 'decision'])
                        .nullish()
                        .describe('Judge method. Omit to keep the saved method; null restores automatic routing.'),
                    include_media: zod.boolean().optional().describe('Set to false to judge text only.'),
                    reasoning_level: zod
                        .enum(['minimal', 'low', 'medium', 'high'])
                        .nullish()
                        .describe(
                            "How much the judge model reasons before it answers. Only Anthropic and OpenAI reasoning models with the 'llm' judge method support it. Omit to keep the saved level; null uses the model's default."
                        ),
                }),
                zod.object({
                    source: zod
                        .string()
                        .min(1)
                        .describe(
                            'Hog source code. Return a boolean, finite number, or category keys matching output_type. Categorical single selection accepts one key or a one-item list; multiple selection accepts a list, including []. Return null only for allowed N\/A. Output settings determine which boolean counts as a failure.'
                        ),
                }),
                zod.object({
                    source: zod
                        .enum(['user_messages'])
                        .default(evaluationsPartialUpdateBodyEvaluationConfigThreeSourceDefault)
                        .describe(
                            "Classify sentiment from user messages in the generation input. The classifier is trained on English, so labels are unreliable for other languages; use an 'llm_judge' evaluation for multilingual agents."
                        ),
                }),
            ])
            .optional()
            .describe(
                "Configuration dict. For 'llm_judge': {prompt}; for 'hog': {source}; for 'sentiment': {source: 'user_messages'}."
            ),
        output_type: zod
            .enum(['boolean', 'numeric', 'categorical', 'sentiment'])
            .describe(
                '\* `boolean` - Boolean (Pass\/Fail)\n\* `numeric` - Numeric\n\* `categorical` - Categorical\n\* `sentiment` - Sentiment'
            )
            .optional()
            .describe(
                "Output format: 'boolean', 'numeric' for a finite score, 'categorical' for category keys, or 'sentiment' for sentiment analysis.\n\n\* `boolean` - Boolean (Pass\/Fail)\n\* `numeric` - Numeric\n\* `categorical` - Categorical\n\* `sentiment` - Sentiment"
            ),
        output_config: zod
            .object({
                allows_na: zod
                    .boolean()
                    .optional()
                    .describe('Whether the evaluation can return N\/A for non-applicable generations.'),
                true_is_failure: zod
                    .boolean()
                    .optional()
                    .describe(
                        'Boolean output only. Omit for numeric, categorical, and sentiment output. Whether a true result means the evaluation found a problem. False (the default) suits pass\/fail evaluations, where a true result satisfied the criteria. Set it to true for detector-style evaluations, so a true result is counted and labeled as a fail.'
                    ),
                decision_threshold: zod
                    .number()
                    .min(evaluationsPartialUpdateBodyOutputConfigDecisionThresholdMin)
                    .max(evaluationsPartialUpdateBodyOutputConfigDecisionThresholdMax)
                    .nullish()
                    .describe(
                        'Boolean decision-model judges only. Minimum probability of true required for a true result, inclusive. Omit or set null to use 0.5. Applies to new runs; historical results are unchanged.'
                    ),
                min: zod
                    .number()
                    .nullish()
                    .describe(
                        'Inclusive minimum numeric score. Omit for no lower bound. Required for numeric decision models.'
                    ),
                max: zod
                    .number()
                    .nullish()
                    .describe(
                        'Inclusive maximum numeric score. Omit for no upper bound. Required for numeric decision models and must exceed min.'
                    ),
                step: zod
                    .number()
                    .gt(evaluationsPartialUpdateBodyOutputConfigStepExclusiveMin)
                    .nullish()
                    .describe('Optional positive input increment. Does not round evaluation results.'),
                options: zod
                    .array(
                        zod.object({
                            key: zod
                                .string()
                                .min(1)
                                .max(evaluationsPartialUpdateBodyOutputConfigOptionsItemKeyMax)
                                .regex(evaluationsPartialUpdateBodyOutputConfigOptionsItemKeyRegExp)
                                .describe('Stable category key.'),
                            label: zod
                                .string()
                                .min(1)
                                .max(evaluationsPartialUpdateBodyOutputConfigOptionsItemLabelMax)
                                .describe('Category display label.'),
                        })
                    )
                    .min(1)
                    .max(evaluationsPartialUpdateBodyOutputConfigOptionsMax)
                    .optional()
                    .describe(
                        'Categorical output options. Keys identify stored results; labels are displayed to users.'
                    ),
                selection_mode: zod
                    .enum(['single', 'multiple'])
                    .optional()
                    .describe(
                        'Select one category or multiple categories. Multiple selection allows an empty result. Defaults to single.'
                    ),
                passing_rule: zod
                    .union([
                        zod.object({
                            operator: zod
                                .enum(['gte', 'lte'])
                                .describe('Pass at or above (gte), or at or below (lte), the threshold.'),
                            threshold: zod
                                .number()
                                .describe('Finite passing threshold within any configured score bounds.'),
                        }),
                        zod.object({
                            categories: zod
                                .array(zod.string())
                                .describe(
                                    'Passing category keys. With keys selected, results must be non-empty and contain only these keys. If no passing keys are selected, only an empty result passes.'
                                ),
                        }),
                        zod.null(),
                    ])
                    .optional()
                    .describe(
                        'Optional numeric or categorical passing rule. Null removes the rule; historical results use the current rule.'
                    ),
            })
            .optional()
            .describe(
                "Output config. For 'boolean' output_type: {allows_na} to permit N\/A results, and {true_is_failure} to declare that a true result means the evaluation found a problem. For boolean decision-model judges, decision_threshold is a probability from 0 to 1 (default 0.5). For 'numeric': only min\/max\/step, allows_na, and passing_rule {operator: 'gte'|'lte', threshold}. For 'categorical': options [{key, label}], selection_mode (single or multiple), allows_na, and optional passing_rule {categories: [key]}. Do not send true_is_failure for numeric or categorical output. For 'sentiment': {}."
            ),
        conditions: zod
            .array(
                zod
                    .object({
                        id: zod
                            .string()
                            .max(evaluationsPartialUpdateBodyConditionsItemIdMax)
                            .describe('Stable identifier for this condition set.'),
                        rollout_percentage: zod
                            .number()
                            .min(evaluationsPartialUpdateBodyConditionsItemRolloutPercentageMin)
                            .max(evaluationsPartialUpdateBodyConditionsItemRolloutPercentageMax)
                            .default(evaluationsPartialUpdateBodyConditionsItemRolloutPercentageDefault)
                            .describe(
                                'Percentage (0-100) of matching events to sample for this evaluation. Defaults to 100.'
                            ),
                        properties: zod
                            .array(zod.record(zod.string(), zod.unknown()))
                            .optional()
                            .describe(
                                'Property filters (event or person) that scope which generations match this condition set.'
                            ),
                    })
                    .describe('A trigger condition set controlling which generations an evaluation runs on.')
            )
            .optional()
            .describe(
                'Trigger conditions that filter which events are evaluated. OR between condition sets, AND within each. Each set is {id, rollout_percentage, properties[]} — `rollout_percentage` (0-100, defaults to 100) is the sampling field the dispatcher reads.'
            ),
        target: zod
            .enum(['generation', 'trace', 'session'])
            .describe('\* `generation` - Generation\n\* `trace` - Trace\n\* `session` - Session')
            .optional()
            .describe(
                "What the evaluation runs on. 'generation' evaluates each matching $ai_generation event individually. 'trace' evaluates the whole trace once and 'session' the whole $ai_session_id session once: the first matching generation schedules a run that waits for the unit to settle, then evaluates all of its events together. Condition filters still match individual generations — a unit is evaluated when any of its generations matches, and sampling applies per unit. A 'session' evaluation only fires for generations that carry $ai_session_id. When and how the run fires is controlled by target_config's settle strategy.\n\n\* `generation` - Generation\n\* `trace` - Trace\n\* `session` - Session"
            ),
        target_config: zod
            .object({
                strategy: zod
                    .enum(['fixed_window', 'inactivity'])
                    .optional()
                    .describe(
                        "'fixed_window' waits a fixed window after the first matching generation, then evaluates. 'inactivity' evaluates once the unit has had no new activity for the quiet period. Omit it to use the target's default: 'fixed_window' for 'trace', 'inactivity' for 'session'."
                    ),
                window_seconds: zod
                    .number()
                    .min(evaluationsPartialUpdateBodyTargetConfigWindowSecondsMin)
                    .max(evaluationsPartialUpdateBodyTargetConfigWindowSecondsMax)
                    .optional()
                    .describe(
                        "fixed_window only. Seconds to wait after the first matching generation before evaluating the whole unit. Captured when the run is scheduled — editing it does not change runs already in flight. The accepted range depends on `target`: 10–7200 for 'trace', 10–604800 for 'session'. The default also depends on `target`; see the field-level help_text."
                    ),
                quiet_period_seconds: zod
                    .number()
                    .min(evaluationsPartialUpdateBodyTargetConfigQuietPeriodSecondsMin)
                    .max(evaluationsPartialUpdateBodyTargetConfigQuietPeriodSecondsMax)
                    .optional()
                    .describe(
                        "inactivity only. Seconds without new activity before the unit counts as settled. The accepted range depends on `target`: 10–1800 for 'trace', 10–86400 for 'session'. The default also depends on `target`; see the field-level help_text."
                    ),
                max_age_seconds: zod
                    .number()
                    .min(evaluationsPartialUpdateBodyTargetConfigMaxAgeSecondsMin)
                    .max(evaluationsPartialUpdateBodyTargetConfigMaxAgeSecondsMax)
                    .optional()
                    .describe(
                        "inactivity only. Hard cap in seconds on the total wait from the first matching generation, even if the unit stays active. Must be at least quiet_period_seconds. The accepted range depends on `target`: 60–7200 for 'trace', 60–604800 for 'session'. The default also depends on `target`; see the field-level help_text."
                    ),
            })
            .optional()
            .describe(
                "Target-specific config. Send {} or omit it for 'generation'. For 'trace' and 'session' targets: a settle config, either 'fixed_window' {window_seconds} or 'inactivity' {quiet_period_seconds, max_age_seconds}. Omit `strategy` to use the target's default. The server fills in any other field you omit, using per-target defaults, and the accepted bounds also depend on `target`."
            ),
        model_configuration: zod
            .union([
                zod
                    .object({
                        provider: zod
                            .enum([
                                'openai',
                                'anthropic',
                                'gemini',
                                'openrouter',
                                'fireworks',
                                'azure_openai',
                                'together_ai',
                                'minimax',
                                'system_one',
                                'openai_compatible',
                            ])
                            .describe(
                                '\* `openai` - Openai\n\* `anthropic` - Anthropic\n\* `gemini` - Gemini\n\* `openrouter` - Openrouter\n\* `fireworks` - Fireworks\n\* `azure_openai` - Azure OpenAI\n\* `together_ai` - Together AI\n\* `minimax` - MiniMax\n\* `system_one` - System One\n\* `openai_compatible` - OpenAI-compatible'
                            ),
                        model: zod.string().max(evaluationsPartialUpdateBodyModelConfigurationOneModelMax),
                        provider_key_id: zod
                            .uuid()
                            .nullish()
                            .describe(
                                'Optional team provider key to run this evaluation with; it must use the same provider. May be null when no key is pinned or after the selected key is removed.'
                            ),
                        provider_key_name: zod.string().nullable(),
                    })
                    .describe('Nested serializer for model configuration.'),
                zod.null(),
            ])
            .optional()
            .describe(
                'Provider and model for an llm_judge evaluation. Required when creating or switching to llm_judge. To add or replace a model, provide both provider and model. On an existing configured llm_judge, omit this field to keep the current model; null is rejected. When switching an llm_judge to hog or sentiment, set this field to null. Legacy llm_judge evaluations without a model remain editable without adding one. The nested provider_key_id may be null.'
            ),
        deleted: zod.boolean().optional().describe('Set to true to soft-delete the evaluation.'),
    })
    .describe('An evaluation that scores LLM generations, traces, or sessions.')

/**
 * Test Hog evaluation code against sample events without saving.
 */
export const evaluationsTestHogCreateBodyOutputTypeDefault = `boolean`
export const evaluationsTestHogCreateBodyOutputConfigDecisionThresholdMin = 0
export const evaluationsTestHogCreateBodyOutputConfigDecisionThresholdMax = 1

export const evaluationsTestHogCreateBodyOutputConfigStepExclusiveMin = 0

export const evaluationsTestHogCreateBodyOutputConfigOptionsItemKeyMax = 128

export const evaluationsTestHogCreateBodyOutputConfigOptionsItemKeyRegExp = new RegExp('^[a-z0-9]+(?:[_-][a-z0-9]+)\*$')
export const evaluationsTestHogCreateBodyOutputConfigOptionsItemLabelMax = 256

export const evaluationsTestHogCreateBodyOutputConfigOptionsMax = 100

export const evaluationsTestHogCreateBodySampleCountDefault = 5
export const evaluationsTestHogCreateBodySampleCountMax = 10

export const evaluationsTestHogCreateBodyAllowsNaDefault = false
export const evaluationsTestHogCreateBodyTargetDefault = `generation`
export const evaluationsTestHogCreateBodyTargetConfigOneWindowSecondsDefault = 1800
export const evaluationsTestHogCreateBodyTargetConfigOneWindowSecondsMin = 10
export const evaluationsTestHogCreateBodyTargetConfigOneWindowSecondsMax = 7200

export const evaluationsTestHogCreateBodyTargetConfigOneQuietPeriodSecondsDefault = 3600
export const evaluationsTestHogCreateBodyTargetConfigOneQuietPeriodSecondsMin = 10
export const evaluationsTestHogCreateBodyTargetConfigOneQuietPeriodSecondsMax = 86400

export const EvaluationsTestHogCreateBody = /* @__PURE__ */ zod.object({
    output_type: zod
        .enum(['boolean', 'numeric', 'categorical'])
        .describe('\* `boolean` - Boolean (Pass\/Fail)\n\* `numeric` - Numeric\n\* `categorical` - Categorical')
        .default(evaluationsTestHogCreateBodyOutputTypeDefault)
        .describe(
            'Expected output: boolean, numeric, or categorical. Sentiment is not supported by Hog.\n\n\* `boolean` - Boolean (Pass\/Fail)\n\* `numeric` - Numeric\n\* `categorical` - Categorical'
        ),
    output_config: zod
        .object({
            allows_na: zod
                .boolean()
                .optional()
                .describe('Whether the evaluation can return N\/A for non-applicable generations.'),
            true_is_failure: zod
                .boolean()
                .optional()
                .describe(
                    'Boolean output only. Omit for numeric, categorical, and sentiment output. Whether a true result means the evaluation found a problem. False (the default) suits pass\/fail evaluations, where a true result satisfied the criteria. Set it to true for detector-style evaluations, so a true result is counted and labeled as a fail.'
                ),
            decision_threshold: zod
                .number()
                .min(evaluationsTestHogCreateBodyOutputConfigDecisionThresholdMin)
                .max(evaluationsTestHogCreateBodyOutputConfigDecisionThresholdMax)
                .nullish()
                .describe(
                    'Boolean decision-model judges only. Minimum probability of true required for a true result, inclusive. Omit or set null to use 0.5. Applies to new runs; historical results are unchanged.'
                ),
            min: zod
                .number()
                .nullish()
                .describe(
                    'Inclusive minimum numeric score. Omit for no lower bound. Required for numeric decision models.'
                ),
            max: zod
                .number()
                .nullish()
                .describe(
                    'Inclusive maximum numeric score. Omit for no upper bound. Required for numeric decision models and must exceed min.'
                ),
            step: zod
                .number()
                .gt(evaluationsTestHogCreateBodyOutputConfigStepExclusiveMin)
                .nullish()
                .describe('Optional positive input increment. Does not round evaluation results.'),
            options: zod
                .array(
                    zod.object({
                        key: zod
                            .string()
                            .min(1)
                            .max(evaluationsTestHogCreateBodyOutputConfigOptionsItemKeyMax)
                            .regex(evaluationsTestHogCreateBodyOutputConfigOptionsItemKeyRegExp)
                            .describe('Stable category key.'),
                        label: zod
                            .string()
                            .min(1)
                            .max(evaluationsTestHogCreateBodyOutputConfigOptionsItemLabelMax)
                            .describe('Category display label.'),
                    })
                )
                .min(1)
                .max(evaluationsTestHogCreateBodyOutputConfigOptionsMax)
                .optional()
                .describe('Categorical output options. Keys identify stored results; labels are displayed to users.'),
            selection_mode: zod
                .enum(['single', 'multiple'])
                .optional()
                .describe(
                    'Select one category or multiple categories. Multiple selection allows an empty result. Defaults to single.'
                ),
            passing_rule: zod
                .union([
                    zod.object({
                        operator: zod
                            .enum(['gte', 'lte'])
                            .describe('Pass at or above (gte), or at or below (lte), the threshold.'),
                        threshold: zod
                            .number()
                            .describe('Finite passing threshold within any configured score bounds.'),
                    }),
                    zod.object({
                        categories: zod
                            .array(zod.string())
                            .describe(
                                'Passing category keys. With keys selected, results must be non-empty and contain only these keys. If no passing keys are selected, only an empty result passes.'
                            ),
                    }),
                    zod.null(),
                ])
                .optional()
                .describe(
                    'Optional numeric or categorical passing rule. Null removes the rule; historical results use the current rule.'
                ),
        })
        .optional()
        .describe('Output settings used to validate the preview, including bounds, categories, and allows_na.'),
    source: zod
        .string()
        .min(1)
        .describe(
            'Hog source code to test. Return a boolean, finite number, or category keys matching output_type. Categorical single selection accepts one key or a one-item list; multiple selection accepts a list, including []. Return null only for allowed N\/A. Output settings determine which boolean counts as a failure.'
        ),
    sample_count: zod
        .number()
        .min(1)
        .max(evaluationsTestHogCreateBodySampleCountMax)
        .default(evaluationsTestHogCreateBodySampleCountDefault)
        .describe('Number of recent $ai_generation events to test against (1–10, default 5).'),
    allows_na: zod
        .boolean()
        .default(evaluationsTestHogCreateBodyAllowsNaDefault)
        .describe('Whether the evaluation can return N\/A for non-applicable generations.'),
    conditions: zod
        .array(zod.record(zod.string(), zod.unknown()))
        .optional()
        .describe('Optional trigger conditions to filter which events are sampled.'),
    target: zod
        .enum(['generation', 'trace', 'session'])
        .describe('\* `generation` - Generation\n\* `trace` - Trace\n\* `session` - Session')
        .default(evaluationsTestHogCreateBodyTargetDefault)
        .describe(
            "What the evaluation runs against: 'generation' samples individual generations, 'trace' samples whole traces, and 'session' samples whole sessions that have gone quiet. Each target runs against the same globals it would run against online.\n\n\* `generation` - Generation\n\* `trace` - Trace\n\* `session` - Session"
        ),
    target_config: zod
        .object({
            window_seconds: zod
                .number()
                .min(evaluationsTestHogCreateBodyTargetConfigOneWindowSecondsMin)
                .max(evaluationsTestHogCreateBodyTargetConfigOneWindowSecondsMax)
                .default(evaluationsTestHogCreateBodyTargetConfigOneWindowSecondsDefault)
                .describe('Aggregation window for trace samples, in seconds.'),
            quiet_period_seconds: zod
                .number()
                .min(evaluationsTestHogCreateBodyTargetConfigOneQuietPeriodSecondsMin)
                .max(evaluationsTestHogCreateBodyTargetConfigOneQuietPeriodSecondsMax)
                .default(evaluationsTestHogCreateBodyTargetConfigOneQuietPeriodSecondsDefault)
                .describe(
                    'For session samples: only sessions with no activity for this long are previewed, matching when a session evaluation would actually run.'
                ),
        })
        .optional()
        .describe('Target-specific preview settings. For a trace target, set window_seconds between 10 and 7200.'),
})

/**
 * Team-level clustering configuration (event filters for automated pipelines).
 */
export const LlmAnalyticsClusteringConfigSetEventFiltersCreateBody = /* @__PURE__ */ zod.object({
    event_filters: zod
        .array(zod.record(zod.string(), zod.unknown()))
        .describe(
            'PostHog property filters to save for automated clustering jobs. Pass an empty array to clear filters.'
        ),
})

/**
 * CRUD for clustering job configurations (max 10 per team).
 */
export const llmAnalyticsClusteringJobsCreateBodyNameMax = 100

export const LlmAnalyticsClusteringJobsCreateBody = /* @__PURE__ */ zod.object({
    name: zod.string().max(llmAnalyticsClusteringJobsCreateBodyNameMax),
    analysis_level: zod
        .enum(['trace', 'generation', 'evaluation'])
        .describe('\* `trace` - trace\n\* `generation` - generation\n\* `evaluation` - evaluation'),
    event_filters: zod
        .array(zod.record(zod.string(), zod.unknown()))
        .optional()
        .describe('PostHog property filters that scope this clustering job. Empty array means no filters.'),
    enabled: zod.boolean().optional(),
})

/**
 * CRUD for clustering job configurations (max 10 per team).
 */
export const llmAnalyticsClusteringJobsUpdateBodyNameMax = 100

export const LlmAnalyticsClusteringJobsUpdateBody = /* @__PURE__ */ zod.object({
    name: zod.string().max(llmAnalyticsClusteringJobsUpdateBodyNameMax),
    analysis_level: zod
        .enum(['trace', 'generation', 'evaluation'])
        .describe('\* `trace` - trace\n\* `generation` - generation\n\* `evaluation` - evaluation'),
    event_filters: zod
        .array(zod.record(zod.string(), zod.unknown()))
        .optional()
        .describe('PostHog property filters that scope this clustering job. Empty array means no filters.'),
    enabled: zod.boolean().optional(),
})

/**
 * CRUD for clustering job configurations (max 10 per team).
 */
export const llmAnalyticsClusteringJobsPartialUpdateBodyNameMax = 100

export const LlmAnalyticsClusteringJobsPartialUpdateBody = /* @__PURE__ */ zod.object({
    name: zod.string().max(llmAnalyticsClusteringJobsPartialUpdateBodyNameMax).optional(),
    analysis_level: zod
        .enum(['trace', 'generation', 'evaluation'])
        .optional()
        .describe('\* `trace` - trace\n\* `generation` - generation\n\* `evaluation` - evaluation'),
    event_filters: zod
        .array(zod.record(zod.string(), zod.unknown()))
        .optional()
        .describe('PostHog property filters that scope this clustering job. Empty array means no filters.'),
    enabled: zod.boolean().optional(),
})

/**
 * Trigger a new clustering workflow run.
 *
 * This endpoint validates the request parameters and starts a Temporal workflow
 * to perform trace clustering with the specified configuration.
 */
export const llmAnalyticsClusteringRunsCreateBodyLookbackDaysDefault = 7
export const llmAnalyticsClusteringRunsCreateBodyLookbackDaysMax = 90

export const llmAnalyticsClusteringRunsCreateBodyMaxSamplesDefault = 1500
export const llmAnalyticsClusteringRunsCreateBodyMaxSamplesMin = 20
export const llmAnalyticsClusteringRunsCreateBodyMaxSamplesMax = 10000

export const llmAnalyticsClusteringRunsCreateBodyEmbeddingNormalizationDefault = `none`
export const llmAnalyticsClusteringRunsCreateBodyDimensionalityReductionMethodDefault = `umap`
export const llmAnalyticsClusteringRunsCreateBodyDimensionalityReductionNdimsDefault = 100
export const llmAnalyticsClusteringRunsCreateBodyDimensionalityReductionNdimsMin = 2
export const llmAnalyticsClusteringRunsCreateBodyDimensionalityReductionNdimsMax = 500

export const llmAnalyticsClusteringRunsCreateBodyClusteringMethodDefault = `hdbscan`
export const llmAnalyticsClusteringRunsCreateBodyMinClusterSizeFractionDefault = 0.02
export const llmAnalyticsClusteringRunsCreateBodyMinClusterSizeFractionMin = 0.02
export const llmAnalyticsClusteringRunsCreateBodyMinClusterSizeFractionMax = 0.5

export const llmAnalyticsClusteringRunsCreateBodyHdbscanMinSamplesDefault = 5
export const llmAnalyticsClusteringRunsCreateBodyHdbscanMinSamplesMax = 100

export const llmAnalyticsClusteringRunsCreateBodyKmeansMinKDefault = 2
export const llmAnalyticsClusteringRunsCreateBodyKmeansMinKMin = 2
export const llmAnalyticsClusteringRunsCreateBodyKmeansMinKMax = 50

export const llmAnalyticsClusteringRunsCreateBodyKmeansMaxKDefault = 20
export const llmAnalyticsClusteringRunsCreateBodyKmeansMaxKMin = 2
export const llmAnalyticsClusteringRunsCreateBodyKmeansMaxKMax = 100

export const llmAnalyticsClusteringRunsCreateBodyRunLabelDefault = ``
export const llmAnalyticsClusteringRunsCreateBodyRunLabelMax = 50

export const llmAnalyticsClusteringRunsCreateBodyVisualizationMethodDefault = `umap`

export const LlmAnalyticsClusteringRunsCreateBody = /* @__PURE__ */ zod
    .object({
        lookback_days: zod
            .number()
            .min(1)
            .max(llmAnalyticsClusteringRunsCreateBodyLookbackDaysMax)
            .default(llmAnalyticsClusteringRunsCreateBodyLookbackDaysDefault)
            .describe('Number of days to look back for traces'),
        max_samples: zod
            .number()
            .min(llmAnalyticsClusteringRunsCreateBodyMaxSamplesMin)
            .max(llmAnalyticsClusteringRunsCreateBodyMaxSamplesMax)
            .default(llmAnalyticsClusteringRunsCreateBodyMaxSamplesDefault)
            .describe('Maximum number of traces to sample for clustering'),
        embedding_normalization: zod
            .enum(['none', 'l2'])
            .describe('\* `none` - none\n\* `l2` - l2')
            .default(llmAnalyticsClusteringRunsCreateBodyEmbeddingNormalizationDefault)
            .describe(
                "Embedding normalization method: 'none' (raw embeddings) or 'l2' (L2 normalize before clustering)\n\n\* `none` - none\n\* `l2` - l2"
            ),
        dimensionality_reduction_method: zod
            .enum(['none', 'umap', 'pca'])
            .describe('\* `none` - none\n\* `umap` - umap\n\* `pca` - pca')
            .default(llmAnalyticsClusteringRunsCreateBodyDimensionalityReductionMethodDefault)
            .describe(
                "Dimensionality reduction method: 'none' (cluster on raw), 'umap', or 'pca'\n\n\* `none` - none\n\* `umap` - umap\n\* `pca` - pca"
            ),
        dimensionality_reduction_ndims: zod
            .number()
            .min(llmAnalyticsClusteringRunsCreateBodyDimensionalityReductionNdimsMin)
            .max(llmAnalyticsClusteringRunsCreateBodyDimensionalityReductionNdimsMax)
            .default(llmAnalyticsClusteringRunsCreateBodyDimensionalityReductionNdimsDefault)
            .describe("Target dimensions for dimensionality reduction (ignored if method is 'none')"),
        clustering_method: zod
            .enum(['hdbscan', 'kmeans'])
            .describe('\* `hdbscan` - hdbscan\n\* `kmeans` - kmeans')
            .default(llmAnalyticsClusteringRunsCreateBodyClusteringMethodDefault)
            .describe(
                "Clustering algorithm: 'hdbscan' (density-based, auto-determines k) or 'kmeans' (centroid-based)\n\n\* `hdbscan` - hdbscan\n\* `kmeans` - kmeans"
            ),
        min_cluster_size_fraction: zod
            .number()
            .min(llmAnalyticsClusteringRunsCreateBodyMinClusterSizeFractionMin)
            .max(llmAnalyticsClusteringRunsCreateBodyMinClusterSizeFractionMax)
            .default(llmAnalyticsClusteringRunsCreateBodyMinClusterSizeFractionDefault)
            .describe('Minimum cluster size as fraction of total samples (e.g., 0.02 = 2%)'),
        hdbscan_min_samples: zod
            .number()
            .min(1)
            .max(llmAnalyticsClusteringRunsCreateBodyHdbscanMinSamplesMax)
            .default(llmAnalyticsClusteringRunsCreateBodyHdbscanMinSamplesDefault)
            .describe('HDBSCAN min_samples parameter (higher = more conservative clustering)'),
        kmeans_min_k: zod
            .number()
            .min(llmAnalyticsClusteringRunsCreateBodyKmeansMinKMin)
            .max(llmAnalyticsClusteringRunsCreateBodyKmeansMinKMax)
            .default(llmAnalyticsClusteringRunsCreateBodyKmeansMinKDefault)
            .describe('Minimum number of clusters to try for k-means'),
        kmeans_max_k: zod
            .number()
            .min(llmAnalyticsClusteringRunsCreateBodyKmeansMaxKMin)
            .max(llmAnalyticsClusteringRunsCreateBodyKmeansMaxKMax)
            .default(llmAnalyticsClusteringRunsCreateBodyKmeansMaxKDefault)
            .describe('Maximum number of clusters to try for k-means'),
        run_label: zod
            .string()
            .max(llmAnalyticsClusteringRunsCreateBodyRunLabelMax)
            .default(llmAnalyticsClusteringRunsCreateBodyRunLabelDefault)
            .describe('Optional label\/tag for the clustering run (used as suffix in run_id for tracking experiments)'),
        visualization_method: zod
            .enum(['umap', 'pca', 'tsne'])
            .describe('\* `umap` - umap\n\* `pca` - pca\n\* `tsne` - tsne')
            .default(llmAnalyticsClusteringRunsCreateBodyVisualizationMethodDefault)
            .describe(
                "Method for 2D scatter plot visualization: 'umap', 'pca', or 'tsne'\n\n\* `umap` - umap\n\* `pca` - pca\n\* `tsne` - tsne"
            ),
        event_filters: zod
            .array(zod.record(zod.string(), zod.unknown()))
            .optional()
            .describe('Property filters to scope which traces are included in clustering (PostHog standard format)'),
        clustering_job_id: zod
            .uuid()
            .nullish()
            .describe(
                "If provided, use this clustering job's analysis_level and event_filters instead of request params"
            ),
    })
    .describe('Serializer for clustering workflow request parameters.')

/**
 * Set the active provider key for evaluations
 */
export const LlmAnalyticsEvaluationConfigSetActiveKeyCreateBody = /* @__PURE__ */ zod.object({
    key_id: zod
        .uuid()
        .describe(
            "UUID of an existing LLM provider key (state must be 'ok') to mark as the active key for running llm_judge evaluations team-wide."
        ),
})

/**
 * CRUD for evaluation report configurations + report run history.
 */
export const llmAnalyticsEvaluationReportsCreateBodyMaxSampleSizeMin = -2147483648
export const llmAnalyticsEvaluationReportsCreateBodyMaxSampleSizeMax = 2147483647

export const llmAnalyticsEvaluationReportsCreateBodyTriggerThresholdMin = 100
export const llmAnalyticsEvaluationReportsCreateBodyTriggerThresholdMax = 10000

export const llmAnalyticsEvaluationReportsCreateBodyCooldownMinutesMin = 60
export const llmAnalyticsEvaluationReportsCreateBodyCooldownMinutesMax = 1440

export const llmAnalyticsEvaluationReportsCreateBodyDailyRunCapMax = 24

export const LlmAnalyticsEvaluationReportsCreateBody = /* @__PURE__ */ zod.object({
    evaluation: zod.uuid().describe('UUID of the evaluation this report config belongs to.'),
    frequency: zod
        .enum(['scheduled', 'every_n'])
        .describe('\* `scheduled` - Scheduled\n\* `every_n` - Every N')
        .optional()
        .describe(
            "How report generation is triggered. 'every_n' fires once N new evaluation results have accumulated (subject to cooldown_minutes and daily_run_cap). 'scheduled' fires on the cadence defined by rrule.\n\n\* `scheduled` - Scheduled\n\* `every_n` - Every N"
        ),
    rrule: zod
        .string()
        .optional()
        .describe(
            "RFC 5545 recurrence rule string for scheduled reports. Only daily and weekly cadences are supported: use 'FREQ=DAILY' or 'FREQ=WEEKLY;BYDAY=MO,FR'. Required when frequency is 'scheduled'; ignored otherwise."
        ),
    delivery_targets: zod
        .unknown()
        .optional()
        .describe(
            "List of delivery targets. Each entry is either {type: 'email', value: '[email protected]'} or {type: 'slack', integration_id: <int>, channel: '<channel>'}. Slack integration_id must belong to this team."
        ),
    max_sample_size: zod
        .number()
        .min(llmAnalyticsEvaluationReportsCreateBodyMaxSampleSizeMin)
        .max(llmAnalyticsEvaluationReportsCreateBodyMaxSampleSizeMax)
        .optional()
        .describe('Maximum number of evaluation runs included in each report. Defaults to 200.'),
    enabled: zod.boolean().optional().describe('Whether report delivery is active. Disabled configs do not fire.'),
    report_prompt_guidance: zod
        .string()
        .optional()
        .describe(
            'Optional custom instructions appended to the AI report prompt to steer focus, scope, or section choices without modifying the base prompt.'
        ),
    trigger_threshold: zod
        .number()
        .min(llmAnalyticsEvaluationReportsCreateBodyTriggerThresholdMin)
        .max(llmAnalyticsEvaluationReportsCreateBodyTriggerThresholdMax)
        .nullish()
        .describe(
            "Number of new evaluation results that triggers a report (every_n mode only). Min 100, max 10000. Defaults to 100. Required when frequency is 'every_n'."
        ),
    cooldown_minutes: zod
        .number()
        .min(llmAnalyticsEvaluationReportsCreateBodyCooldownMinutesMin)
        .max(llmAnalyticsEvaluationReportsCreateBodyCooldownMinutesMax)
        .optional()
        .describe(
            'Minimum minutes between count-triggered reports to prevent spam (every_n mode only). Min 60, max 1440 (24 hours). Defaults to 60.'
        ),
    daily_run_cap: zod
        .number()
        .min(1)
        .max(llmAnalyticsEvaluationReportsCreateBodyDailyRunCapMax)
        .optional()
        .describe(
            'Maximum count-triggered report runs per calendar day (UTC). Min 1, max 24 (one per cooldown window). Defaults to 10.'
        ),
})

/**
 * CRUD for evaluation report configurations + report run history.
 */
export const llmAnalyticsEvaluationReportsUpdateBodyMaxSampleSizeMin = -2147483648
export const llmAnalyticsEvaluationReportsUpdateBodyMaxSampleSizeMax = 2147483647

export const llmAnalyticsEvaluationReportsUpdateBodyTriggerThresholdMin = 100
export const llmAnalyticsEvaluationReportsUpdateBodyTriggerThresholdMax = 10000

export const llmAnalyticsEvaluationReportsUpdateBodyCooldownMinutesMin = 60
export const llmAnalyticsEvaluationReportsUpdateBodyCooldownMinutesMax = 1440

export const llmAnalyticsEvaluationReportsUpdateBodyDailyRunCapMax = 24

export const LlmAnalyticsEvaluationReportsUpdateBody = /* @__PURE__ */ zod.object({
    frequency: zod
        .enum(['scheduled', 'every_n'])
        .describe('\* `scheduled` - Scheduled\n\* `every_n` - Every N')
        .optional()
        .describe(
            "How report generation is triggered. 'every_n' fires once N new evaluation results have accumulated (subject to cooldown_minutes and daily_run_cap). 'scheduled' fires on the cadence defined by rrule.\n\n\* `scheduled` - Scheduled\n\* `every_n` - Every N"
        ),
    rrule: zod
        .string()
        .optional()
        .describe(
            "RFC 5545 recurrence rule string for scheduled reports. Only daily and weekly cadences are supported: use 'FREQ=DAILY' or 'FREQ=WEEKLY;BYDAY=MO,FR'. Required when frequency is 'scheduled'; ignored otherwise."
        ),
    delivery_targets: zod
        .unknown()
        .optional()
        .describe(
            "List of delivery targets. Each entry is either {type: 'email', value: '[email protected]'} or {type: 'slack', integration_id: <int>, channel: '<channel>'}. Slack integration_id must belong to this team."
        ),
    max_sample_size: zod
        .number()
        .min(llmAnalyticsEvaluationReportsUpdateBodyMaxSampleSizeMin)
        .max(llmAnalyticsEvaluationReportsUpdateBodyMaxSampleSizeMax)
        .optional()
        .describe('Maximum number of evaluation runs included in each report. Defaults to 200.'),
    enabled: zod.boolean().optional().describe('Whether report delivery is active. Disabled configs do not fire.'),
    report_prompt_guidance: zod
        .string()
        .optional()
        .describe(
            'Optional custom instructions appended to the AI report prompt to steer focus, scope, or section choices without modifying the base prompt.'
        ),
    trigger_threshold: zod
        .number()
        .min(llmAnalyticsEvaluationReportsUpdateBodyTriggerThresholdMin)
        .max(llmAnalyticsEvaluationReportsUpdateBodyTriggerThresholdMax)
        .nullish()
        .describe(
            "Number of new evaluation results that triggers a report (every_n mode only). Min 100, max 10000. Defaults to 100. Required when frequency is 'every_n'."
        ),
    cooldown_minutes: zod
        .number()
        .min(llmAnalyticsEvaluationReportsUpdateBodyCooldownMinutesMin)
        .max(llmAnalyticsEvaluationReportsUpdateBodyCooldownMinutesMax)
        .optional()
        .describe(
            'Minimum minutes between count-triggered reports to prevent spam (every_n mode only). Min 60, max 1440 (24 hours). Defaults to 60.'
        ),
    daily_run_cap: zod
        .number()
        .min(1)
        .max(llmAnalyticsEvaluationReportsUpdateBodyDailyRunCapMax)
        .optional()
        .describe(
            'Maximum count-triggered report runs per calendar day (UTC). Min 1, max 24 (one per cooldown window). Defaults to 10.'
        ),
})

/**
 * CRUD for evaluation report configurations + report run history.
 */
export const llmAnalyticsEvaluationReportsPartialUpdateBodyMaxSampleSizeMin = -2147483648
export const llmAnalyticsEvaluationReportsPartialUpdateBodyMaxSampleSizeMax = 2147483647

export const llmAnalyticsEvaluationReportsPartialUpdateBodyTriggerThresholdMin = 100
export const llmAnalyticsEvaluationReportsPartialUpdateBodyTriggerThresholdMax = 10000

export const llmAnalyticsEvaluationReportsPartialUpdateBodyCooldownMinutesMin = 60
export const llmAnalyticsEvaluationReportsPartialUpdateBodyCooldownMinutesMax = 1440

export const llmAnalyticsEvaluationReportsPartialUpdateBodyDailyRunCapMax = 24

export const LlmAnalyticsEvaluationReportsPartialUpdateBody = /* @__PURE__ */ zod.object({
    frequency: zod
        .enum(['scheduled', 'every_n'])
        .describe('\* `scheduled` - Scheduled\n\* `every_n` - Every N')
        .optional()
        .describe(
            "How report generation is triggered. 'every_n' fires once N new evaluation results have accumulated (subject to cooldown_minutes and daily_run_cap). 'scheduled' fires on the cadence defined by rrule.\n\n\* `scheduled` - Scheduled\n\* `every_n` - Every N"
        ),
    rrule: zod
        .string()
        .optional()
        .describe(
            "RFC 5545 recurrence rule string for scheduled reports. Only daily and weekly cadences are supported: use 'FREQ=DAILY' or 'FREQ=WEEKLY;BYDAY=MO,FR'. Required when frequency is 'scheduled'; ignored otherwise."
        ),
    delivery_targets: zod
        .unknown()
        .optional()
        .describe(
            "List of delivery targets. Each entry is either {type: 'email', value: '[email protected]'} or {type: 'slack', integration_id: <int>, channel: '<channel>'}. Slack integration_id must belong to this team."
        ),
    max_sample_size: zod
        .number()
        .min(llmAnalyticsEvaluationReportsPartialUpdateBodyMaxSampleSizeMin)
        .max(llmAnalyticsEvaluationReportsPartialUpdateBodyMaxSampleSizeMax)
        .optional()
        .describe('Maximum number of evaluation runs included in each report. Defaults to 200.'),
    enabled: zod.boolean().optional().describe('Whether report delivery is active. Disabled configs do not fire.'),
    report_prompt_guidance: zod
        .string()
        .optional()
        .describe(
            'Optional custom instructions appended to the AI report prompt to steer focus, scope, or section choices without modifying the base prompt.'
        ),
    trigger_threshold: zod
        .number()
        .min(llmAnalyticsEvaluationReportsPartialUpdateBodyTriggerThresholdMin)
        .max(llmAnalyticsEvaluationReportsPartialUpdateBodyTriggerThresholdMax)
        .nullish()
        .describe(
            "Number of new evaluation results that triggers a report (every_n mode only). Min 100, max 10000. Defaults to 100. Required when frequency is 'every_n'."
        ),
    cooldown_minutes: zod
        .number()
        .min(llmAnalyticsEvaluationReportsPartialUpdateBodyCooldownMinutesMin)
        .max(llmAnalyticsEvaluationReportsPartialUpdateBodyCooldownMinutesMax)
        .optional()
        .describe(
            'Minimum minutes between count-triggered reports to prevent spam (every_n mode only). Min 60, max 1440 (24 hours). Defaults to 60.'
        ),
    daily_run_cap: zod
        .number()
        .min(1)
        .max(llmAnalyticsEvaluationReportsPartialUpdateBodyDailyRunCapMax)
        .optional()
        .describe(
            'Maximum count-triggered report runs per calendar day (UTC). Min 1, max 24 (one per cooldown window). Defaults to 10.'
        ),
})

export const llmAnalyticsParserRecipesCreateBodyNameMax = 255

export const llmAnalyticsParserRecipesCreateBodySourceMax = 100000

export const LlmAnalyticsParserRecipesCreateBody = /* @__PURE__ */ zod.object({
    name: zod
        .string()
        .max(llmAnalyticsParserRecipesCreateBodyNameMax)
        .describe('Human-readable recipe name shown in the editor.'),
    source: zod
        .string()
        .max(llmAnalyticsParserRecipesCreateBodySourceMax)
        .describe(
            'Raw YAML recipe source. Must parse as YAML; recipe semantics are compiled and validated client-side.'
        ),
})

export const llmAnalyticsParserRecipesPartialUpdateBodyNameMax = 255

export const llmAnalyticsParserRecipesPartialUpdateBodySourceMax = 100000

export const LlmAnalyticsParserRecipesPartialUpdateBody = /* @__PURE__ */ zod.object({
    name: zod
        .string()
        .max(llmAnalyticsParserRecipesPartialUpdateBodyNameMax)
        .optional()
        .describe('Human-readable recipe name shown in the editor.'),
    source: zod
        .string()
        .max(llmAnalyticsParserRecipesPartialUpdateBodySourceMax)
        .optional()
        .describe(
            'Raw YAML recipe source. Must parse as YAML; recipe semantics are compiled and validated client-side.'
        ),
})

export const llmAnalyticsProviderKeysCreateBodyNameMax = 255

export const llmAnalyticsProviderKeysCreateBodySystemOneModelMax = 100

export const llmAnalyticsProviderKeysCreateBodyApiVersionMax = 20

export const llmAnalyticsProviderKeysCreateBodySetAsActiveDefault = false

export const LlmAnalyticsProviderKeysCreateBody = /* @__PURE__ */ zod.object({
    provider: zod
        .enum([
            'openai',
            'anthropic',
            'gemini',
            'openrouter',
            'fireworks',
            'azure_openai',
            'together_ai',
            'minimax',
            'system_one',
            'openai_compatible',
        ])
        .describe(
            '\* `openai` - Openai\n\* `anthropic` - Anthropic\n\* `gemini` - Gemini\n\* `openrouter` - Openrouter\n\* `fireworks` - Fireworks\n\* `azure_openai` - Azure OpenAI\n\* `together_ai` - Together AI\n\* `minimax` - MiniMax\n\* `system_one` - System One\n\* `openai_compatible` - OpenAI-compatible'
        ),
    name: zod.string().max(llmAnalyticsProviderKeysCreateBodyNameMax),
    api_key: zod.string().optional(),
    base_url: zod
        .url()
        .optional()
        .describe(
            'Public HTTPS base URL of an OpenAI-compatible or System One API. For System One, end before \/systemone.'
        ),
    system_one_model: zod
        .string()
        .max(llmAnalyticsProviderKeysCreateBodySystemOneModelMax)
        .optional()
        .describe('Model ID served by the System One endpoint.'),
    azure_endpoint: zod
        .url()
        .optional()
        .describe(
            'Azure OpenAI endpoint URL. For an Anthropic key, the endpoint of the Microsoft Foundry resource that serves Claude, e.g. https:\/\/my-resource.services.ai.azure.com\/. Omit it for a key from the Anthropic API.'
        ),
    api_version: zod
        .string()
        .max(llmAnalyticsProviderKeysCreateBodyApiVersionMax)
        .optional()
        .describe('Azure OpenAI API version'),
    set_as_active: zod.boolean().default(llmAnalyticsProviderKeysCreateBodySetAsActiveDefault),
})

export const llmAnalyticsProviderKeysUpdateBodyNameMax = 255

export const llmAnalyticsProviderKeysUpdateBodySystemOneModelMax = 100

export const llmAnalyticsProviderKeysUpdateBodyApiVersionMax = 20

export const llmAnalyticsProviderKeysUpdateBodySetAsActiveDefault = false

export const LlmAnalyticsProviderKeysUpdateBody = /* @__PURE__ */ zod.object({
    provider: zod
        .enum([
            'openai',
            'anthropic',
            'gemini',
            'openrouter',
            'fireworks',
            'azure_openai',
            'together_ai',
            'minimax',
            'system_one',
            'openai_compatible',
        ])
        .describe(
            '\* `openai` - Openai\n\* `anthropic` - Anthropic\n\* `gemini` - Gemini\n\* `openrouter` - Openrouter\n\* `fireworks` - Fireworks\n\* `azure_openai` - Azure OpenAI\n\* `together_ai` - Together AI\n\* `minimax` - MiniMax\n\* `system_one` - System One\n\* `openai_compatible` - OpenAI-compatible'
        ),
    name: zod.string().max(llmAnalyticsProviderKeysUpdateBodyNameMax),
    api_key: zod.string().optional(),
    base_url: zod
        .url()
        .optional()
        .describe(
            'Public HTTPS base URL of an OpenAI-compatible or System One API. For System One, end before \/systemone.'
        ),
    system_one_model: zod
        .string()
        .max(llmAnalyticsProviderKeysUpdateBodySystemOneModelMax)
        .optional()
        .describe('Model ID served by the System One endpoint.'),
    azure_endpoint: zod
        .url()
        .optional()
        .describe(
            'Azure OpenAI endpoint URL. For an Anthropic key, the endpoint of the Microsoft Foundry resource that serves Claude, e.g. https:\/\/my-resource.services.ai.azure.com\/. Omit it for a key from the Anthropic API.'
        ),
    api_version: zod
        .string()
        .max(llmAnalyticsProviderKeysUpdateBodyApiVersionMax)
        .optional()
        .describe('Azure OpenAI API version'),
    set_as_active: zod.boolean().default(llmAnalyticsProviderKeysUpdateBodySetAsActiveDefault),
})

export const llmAnalyticsProviderKeysPartialUpdateBodyNameMax = 255

export const llmAnalyticsProviderKeysPartialUpdateBodySystemOneModelMax = 100

export const llmAnalyticsProviderKeysPartialUpdateBodyApiVersionMax = 20

export const llmAnalyticsProviderKeysPartialUpdateBodySetAsActiveDefault = false

export const LlmAnalyticsProviderKeysPartialUpdateBody = /* @__PURE__ */ zod.object({
    provider: zod
        .enum([
            'openai',
            'anthropic',
            'gemini',
            'openrouter',
            'fireworks',
            'azure_openai',
            'together_ai',
            'minimax',
            'system_one',
            'openai_compatible',
        ])
        .optional()
        .describe(
            '\* `openai` - Openai\n\* `anthropic` - Anthropic\n\* `gemini` - Gemini\n\* `openrouter` - Openrouter\n\* `fireworks` - Fireworks\n\* `azure_openai` - Azure OpenAI\n\* `together_ai` - Together AI\n\* `minimax` - MiniMax\n\* `system_one` - System One\n\* `openai_compatible` - OpenAI-compatible'
        ),
    name: zod.string().max(llmAnalyticsProviderKeysPartialUpdateBodyNameMax).optional(),
    api_key: zod.string().optional(),
    base_url: zod
        .url()
        .optional()
        .describe(
            'Public HTTPS base URL of an OpenAI-compatible or System One API. For System One, end before \/systemone.'
        ),
    system_one_model: zod
        .string()
        .max(llmAnalyticsProviderKeysPartialUpdateBodySystemOneModelMax)
        .optional()
        .describe('Model ID served by the System One endpoint.'),
    azure_endpoint: zod
        .url()
        .optional()
        .describe(
            'Azure OpenAI endpoint URL. For an Anthropic key, the endpoint of the Microsoft Foundry resource that serves Claude, e.g. https:\/\/my-resource.services.ai.azure.com\/. Omit it for a key from the Anthropic API.'
        ),
    api_version: zod
        .string()
        .max(llmAnalyticsProviderKeysPartialUpdateBodyApiVersionMax)
        .optional()
        .describe('Azure OpenAI API version'),
    set_as_active: zod.boolean().default(llmAnalyticsProviderKeysPartialUpdateBodySetAsActiveDefault),
})

export const llmAnalyticsProviderKeysValidateCreateBodyNameMax = 255

export const llmAnalyticsProviderKeysValidateCreateBodySystemOneModelMax = 100

export const llmAnalyticsProviderKeysValidateCreateBodyApiVersionMax = 20

export const llmAnalyticsProviderKeysValidateCreateBodySetAsActiveDefault = false

export const LlmAnalyticsProviderKeysValidateCreateBody = /* @__PURE__ */ zod.object({
    provider: zod
        .enum([
            'openai',
            'anthropic',
            'gemini',
            'openrouter',
            'fireworks',
            'azure_openai',
            'together_ai',
            'minimax',
            'system_one',
            'openai_compatible',
        ])
        .describe(
            '\* `openai` - Openai\n\* `anthropic` - Anthropic\n\* `gemini` - Gemini\n\* `openrouter` - Openrouter\n\* `fireworks` - Fireworks\n\* `azure_openai` - Azure OpenAI\n\* `together_ai` - Together AI\n\* `minimax` - MiniMax\n\* `system_one` - System One\n\* `openai_compatible` - OpenAI-compatible'
        ),
    name: zod.string().max(llmAnalyticsProviderKeysValidateCreateBodyNameMax),
    api_key: zod.string().optional(),
    base_url: zod
        .url()
        .optional()
        .describe(
            'Public HTTPS base URL of an OpenAI-compatible or System One API. For System One, end before \/systemone.'
        ),
    system_one_model: zod
        .string()
        .max(llmAnalyticsProviderKeysValidateCreateBodySystemOneModelMax)
        .optional()
        .describe('Model ID served by the System One endpoint.'),
    azure_endpoint: zod
        .url()
        .optional()
        .describe(
            'Azure OpenAI endpoint URL. For an Anthropic key, the endpoint of the Microsoft Foundry resource that serves Claude, e.g. https:\/\/my-resource.services.ai.azure.com\/. Omit it for a key from the Anthropic API.'
        ),
    api_version: zod
        .string()
        .max(llmAnalyticsProviderKeysValidateCreateBodyApiVersionMax)
        .optional()
        .describe('Azure OpenAI API version'),
    set_as_active: zod.boolean().default(llmAnalyticsProviderKeysValidateCreateBodySetAsActiveDefault),
})

export const llmAnalyticsReviewQueueItemsCreateBodyTraceIdMax = 255

export const LlmAnalyticsReviewQueueItemsCreateBody = /* @__PURE__ */ zod.object({
    queue_id: zod.uuid().describe('Review queue ID that should own this pending trace.'),
    trace_id: zod
        .string()
        .max(llmAnalyticsReviewQueueItemsCreateBodyTraceIdMax)
        .describe('Trace ID to add to the selected review queue.'),
})

export const LlmAnalyticsReviewQueueItemsPartialUpdateBody = /* @__PURE__ */ zod.object({
    queue_id: zod.uuid().optional().describe('Review queue ID that should own this pending trace.'),
})

export const llmAnalyticsReviewQueuesCreateBodyNameMax = 255

export const LlmAnalyticsReviewQueuesCreateBody = /* @__PURE__ */ zod.object({
    name: zod.string().max(llmAnalyticsReviewQueuesCreateBodyNameMax).describe('Human-readable queue name.'),
})

export const llmAnalyticsReviewQueuesPartialUpdateBodyNameMax = 255

export const LlmAnalyticsReviewQueuesPartialUpdateBody = /* @__PURE__ */ zod.object({
    name: zod
        .string()
        .max(llmAnalyticsReviewQueuesPartialUpdateBodyNameMax)
        .optional()
        .describe('Human-readable queue name.'),
})

export const llmAnalyticsScoreDefinitionsCreateBodyTagsItemMax = 255

export const llmAnalyticsScoreDefinitionsCreateBodyTagsMax = 100

export const llmAnalyticsScoreDefinitionsCreateBodyNameMax = 255

export const llmAnalyticsScoreDefinitionsCreateBodyShortNameMax = 40

export const llmAnalyticsScoreDefinitionsCreateBodyArchivedDefault = false
export const llmAnalyticsScoreDefinitionsCreateBodyConfigOneOneOptionsItemKeyMax = 128

export const llmAnalyticsScoreDefinitionsCreateBodyConfigOneOneOptionsItemLabelMax = 256

export const llmAnalyticsScoreDefinitionsCreateBodyConfigOneOnePassingRuleOneCategoriesItemMax = 128

export const LlmAnalyticsScoreDefinitionsCreateBody = /* @__PURE__ */ zod.object({
    tags: zod
        .array(zod.string().max(llmAnalyticsScoreDefinitionsCreateBodyTagsItemMax))
        .max(llmAnalyticsScoreDefinitionsCreateBodyTagsMax)
        .optional()
        .describe('Tag names. Replaces existing tags; send [] to remove all tags. Names are trimmed and lowercased.'),
    name: zod.string().max(llmAnalyticsScoreDefinitionsCreateBodyNameMax).describe('Human-readable scorer name.'),
    short_name: zod
        .string()
        .max(llmAnalyticsScoreDefinitionsCreateBodyShortNameMax)
        .optional()
        .describe('Optional compact label. Blank uses the full name.'),
    description: zod.string().nullish().describe('Optional human-readable description.'),
    kind: zod
        .enum(['categorical', 'numeric', 'boolean'])
        .describe('\* `categorical` - categorical\n\* `numeric` - numeric\n\* `boolean` - boolean')
        .describe(
            'Scorer kind. This cannot be changed after creation.\n\n\* `categorical` - categorical\n\* `numeric` - numeric\n\* `boolean` - boolean'
        ),
    archived: zod
        .boolean()
        .default(llmAnalyticsScoreDefinitionsCreateBodyArchivedDefault)
        .describe('New scorers are always created as active.'),
    config: zod
        .union([
            zod.object({
                options: zod
                    .array(
                        zod.object({
                            key: zod
                                .string()
                                .max(llmAnalyticsScoreDefinitionsCreateBodyConfigOneOneOptionsItemKeyMax)
                                .describe(
                                    'Stable option key. Use lowercase letters, numbers, underscores, or hyphens.'
                                ),
                            label: zod
                                .string()
                                .max(llmAnalyticsScoreDefinitionsCreateBodyConfigOneOneOptionsItemLabelMax)
                                .describe('Human-readable option label.'),
                        })
                    )
                    .describe('Ordered categorical options available to the scorer.'),
                selection_mode: zod
                    .enum(['single', 'multiple'])
                    .describe('\* `single` - single\n\* `multiple` - multiple')
                    .optional()
                    .describe(
                        'Whether reviewers can select one option or multiple options. Defaults to `single`.\n\n\* `single` - single\n\* `multiple` - multiple'
                    ),
                min_selections: zod
                    .number()
                    .min(1)
                    .nullish()
                    .describe(
                        'Optional minimum number of options that can be selected when `selection_mode` is `multiple`.'
                    ),
                max_selections: zod
                    .number()
                    .min(1)
                    .nullish()
                    .describe(
                        'Optional maximum number of options that can be selected when `selection_mode` is `multiple`.'
                    ),
                passing_rule: zod
                    .union([
                        zod.object({
                            categories: zod
                                .array(
                                    zod
                                        .string()
                                        .max(
                                            llmAnalyticsScoreDefinitionsCreateBodyConfigOneOnePassingRuleOneCategoriesItemMax
                                        )
                                )
                                .describe(
                                    'Passing category keys. Every returned category must be included. An empty list makes all accepted offline results fail.'
                                ),
                        }),
                        zod.null(),
                    ])
                    .optional()
                    .describe(
                        'Optional passing categories. Omit or set null for neutral scores. Each scorer version keeps its own rule.'
                    ),
            }),
            zod.object({
                min: zod.number().nullish().describe('Optional inclusive minimum score.'),
                max: zod.number().nullish().describe('Optional inclusive maximum score.'),
                step: zod
                    .number()
                    .nullish()
                    .describe('Optional increment step for numeric input, for example 1 or 0.5.'),
                passing_rule: zod
                    .union([
                        zod.object({
                            operator: zod
                                .enum(['gte', 'lte'])
                                .describe('\* `gte` - At or above\n\* `lte` - At or below')
                                .describe(
                                    'Pass at or above (gte), or at or below (lte), the threshold.\n\n\* `gte` - At or above\n\* `lte` - At or below'
                                ),
                            threshold: zod
                                .number()
                                .describe('Finite passing threshold within any configured score bounds.'),
                        }),
                        zod.null(),
                    ])
                    .optional()
                    .describe(
                        'Optional passing rule. Omit or set null for neutral scores. Each scorer version keeps its own rule.'
                    ),
            }),
            zod.object({
                true_is_failure: zod
                    .boolean()
                    .nullish()
                    .describe(
                        'Whether true means failure. False, omitted, or null means true passes in offline evaluations.'
                    ),
                true_label: zod.string().optional().describe('Optional label for a true value.'),
                false_label: zod.string().optional().describe('Optional label for a false value.'),
            }),
        ])
        .describe('Initial immutable scorer configuration.'),
})

export const llmAnalyticsScoreDefinitionsPartialUpdateBodyTagsItemMax = 255

export const llmAnalyticsScoreDefinitionsPartialUpdateBodyTagsMax = 100

export const llmAnalyticsScoreDefinitionsPartialUpdateBodyNameMax = 255

export const llmAnalyticsScoreDefinitionsPartialUpdateBodyShortNameMax = 40

export const LlmAnalyticsScoreDefinitionsPartialUpdateBody = /* @__PURE__ */ zod.object({
    tags: zod
        .array(zod.string().max(llmAnalyticsScoreDefinitionsPartialUpdateBodyTagsItemMax))
        .max(llmAnalyticsScoreDefinitionsPartialUpdateBodyTagsMax)
        .optional()
        .describe('Tag names. Replaces existing tags; send [] to remove all tags. Names are trimmed and lowercased.'),
    name: zod
        .string()
        .max(llmAnalyticsScoreDefinitionsPartialUpdateBodyNameMax)
        .optional()
        .describe('Updated scorer name.'),
    short_name: zod
        .string()
        .max(llmAnalyticsScoreDefinitionsPartialUpdateBodyShortNameMax)
        .optional()
        .describe('Updated compact label. Blank uses the full name.'),
    description: zod.string().nullish().describe('Updated scorer description.'),
    archived: zod.boolean().optional().describe('Whether the scorer is archived.'),
})

export const llmAnalyticsScoreDefinitionsNewVersionCreateBodyShortNameMax = 40

export const llmAnalyticsScoreDefinitionsNewVersionCreateBodyNameMax = 255

export const llmAnalyticsScoreDefinitionsNewVersionCreateBodyConfigOneOneOptionsItemKeyMax = 128

export const llmAnalyticsScoreDefinitionsNewVersionCreateBodyConfigOneOneOptionsItemLabelMax = 256

export const llmAnalyticsScoreDefinitionsNewVersionCreateBodyConfigOneOnePassingRuleOneCategoriesItemMax = 128

export const LlmAnalyticsScoreDefinitionsNewVersionCreateBody = /* @__PURE__ */ zod.object({
    short_name: zod
        .string()
        .max(llmAnalyticsScoreDefinitionsNewVersionCreateBodyShortNameMax)
        .optional()
        .describe('Updated compact label, saved with this version.'),
    name: zod
        .string()
        .max(llmAnalyticsScoreDefinitionsNewVersionCreateBodyNameMax)
        .optional()
        .describe('Updated scorer name, saved with this version.'),
    description: zod.string().nullish().describe('Updated scorer description, saved with this version.'),
    config: zod
        .union([
            zod.object({
                options: zod
                    .array(
                        zod.object({
                            key: zod
                                .string()
                                .max(llmAnalyticsScoreDefinitionsNewVersionCreateBodyConfigOneOneOptionsItemKeyMax)
                                .describe(
                                    'Stable option key. Use lowercase letters, numbers, underscores, or hyphens.'
                                ),
                            label: zod
                                .string()
                                .max(llmAnalyticsScoreDefinitionsNewVersionCreateBodyConfigOneOneOptionsItemLabelMax)
                                .describe('Human-readable option label.'),
                        })
                    )
                    .describe('Ordered categorical options available to the scorer.'),
                selection_mode: zod
                    .enum(['single', 'multiple'])
                    .describe('\* `single` - single\n\* `multiple` - multiple')
                    .optional()
                    .describe(
                        'Whether reviewers can select one option or multiple options. Defaults to `single`.\n\n\* `single` - single\n\* `multiple` - multiple'
                    ),
                min_selections: zod
                    .number()
                    .min(1)
                    .nullish()
                    .describe(
                        'Optional minimum number of options that can be selected when `selection_mode` is `multiple`.'
                    ),
                max_selections: zod
                    .number()
                    .min(1)
                    .nullish()
                    .describe(
                        'Optional maximum number of options that can be selected when `selection_mode` is `multiple`.'
                    ),
                passing_rule: zod
                    .union([
                        zod.object({
                            categories: zod
                                .array(
                                    zod
                                        .string()
                                        .max(
                                            llmAnalyticsScoreDefinitionsNewVersionCreateBodyConfigOneOnePassingRuleOneCategoriesItemMax
                                        )
                                )
                                .describe(
                                    'Passing category keys. Every returned category must be included. An empty list makes all accepted offline results fail.'
                                ),
                        }),
                        zod.null(),
                    ])
                    .optional()
                    .describe(
                        'Optional passing categories. Omit or set null for neutral scores. Each scorer version keeps its own rule.'
                    ),
            }),
            zod.object({
                min: zod.number().nullish().describe('Optional inclusive minimum score.'),
                max: zod.number().nullish().describe('Optional inclusive maximum score.'),
                step: zod
                    .number()
                    .nullish()
                    .describe('Optional increment step for numeric input, for example 1 or 0.5.'),
                passing_rule: zod
                    .union([
                        zod.object({
                            operator: zod
                                .enum(['gte', 'lte'])
                                .describe('\* `gte` - At or above\n\* `lte` - At or below')
                                .describe(
                                    'Pass at or above (gte), or at or below (lte), the threshold.\n\n\* `gte` - At or above\n\* `lte` - At or below'
                                ),
                            threshold: zod
                                .number()
                                .describe('Finite passing threshold within any configured score bounds.'),
                        }),
                        zod.null(),
                    ])
                    .optional()
                    .describe(
                        'Optional passing rule. Omit or set null for neutral scores. Each scorer version keeps its own rule.'
                    ),
            }),
            zod.object({
                true_is_failure: zod
                    .boolean()
                    .nullish()
                    .describe(
                        'Whether true means failure. False, omitted, or null means true passes in offline evaluations.'
                    ),
                true_label: zod.string().optional().describe('Optional label for a true value.'),
                false_label: zod.string().optional().describe('Optional label for a false value.'),
            }),
        ])
        .describe('Next immutable scorer configuration.'),
    base_version: zod
        .number()
        .min(1)
        .optional()
        .describe(
            "Version number the caller observed before requesting this bump. If provided and it does not match the scorer's current version, the request fails with 409. Omit to skip the optimistic-concurrency check."
        ),
})

/**
 *
 * Generate an AI-powered summary of an LLM trace or event.
 *
 * This endpoint analyzes the provided trace/event, generates a line-numbered text
 * representation, and uses an LLM to create a concise summary with line references.
 *
 * **Two ways to use this endpoint:**
 *
 * 1. **By ID (recommended):** Pass `trace_id` or `generation_id` with an optional `date_from`/`date_to`.
 *    The backend fetches the data automatically. `summarize_type` is inferred.
 * 2. **By data:** Pass the full trace/event data blob in `data` with `summarize_type`.
 *    This is how the frontend uses it.
 *
 * **Summary Format:**
 * - Title (concise, max 10 words)
 * - Mermaid flow diagram showing the main flow
 * - 3-10 summary bullets with line references
 * - "Interesting Notes" section for failures, successes, or unusual patterns
 * - Line references in [L45] or [L45-52] format pointing to relevant sections
 *
 * The response includes the structured summary, the text representation, and metadata.
 *
 */
export const llmAnalyticsSummarizationCreateBodyModeDefault = `minimal`
export const llmAnalyticsSummarizationCreateBodyForceRefreshDefault = false
export const llmAnalyticsSummarizationCreateBodyCompactContextDefault = false

export const LlmAnalyticsSummarizationCreateBody = /* @__PURE__ */ zod.object({
    summarize_type: zod
        .enum(['trace', 'event'])
        .describe('\* `trace` - trace\n\* `event` - event')
        .optional()
        .describe(
            'Type of entity to summarize. Inferred automatically when using trace_id or generation_id.\n\n\* `trace` - trace\n\* `event` - event'
        ),
    mode: zod
        .enum(['minimal', 'detailed'])
        .describe('\* `minimal` - minimal\n\* `detailed` - detailed')
        .default(llmAnalyticsSummarizationCreateBodyModeDefault)
        .describe(
            "Summary detail level: 'minimal' for 3-5 points, 'detailed' for 5-10 points\n\n\* `minimal` - minimal\n\* `detailed` - detailed"
        ),
    data: zod
        .unknown()
        .optional()
        .describe(
            'Data to summarize. For traces: {trace, hierarchy}. For events: {event}. Not required when using trace_id or generation_id.'
        ),
    force_refresh: zod
        .boolean()
        .default(llmAnalyticsSummarizationCreateBodyForceRefreshDefault)
        .describe('Force regenerate summary, bypassing cache'),
    compact_context: zod
        .boolean()
        .default(llmAnalyticsSummarizationCreateBodyCompactContextDefault)
        .describe(
            'Bound the input to a cost-conscious size instead of the full model context window. Use it when you summarize many traces at once and need only a short result such as the title.'
        ),
    model: zod.string().nullish().describe('LLM model to use (defaults based on provider)'),
    trace_id: zod
        .string()
        .optional()
        .describe(
            'Trace ID to summarize. The backend fetches the trace data automatically. Requires date_from for efficient lookup.'
        ),
    generation_id: zod
        .string()
        .optional()
        .describe(
            'Generation event UUID to summarize. The backend fetches the event data automatically. Requires date_from for efficient lookup.'
        ),
    date_from: zod
        .string()
        .nullish()
        .describe("Start of date range for ID-based lookup (e.g. '-7d' or '2026-01-01'). Defaults to -30d."),
    date_to: zod.string().nullish().describe('End of date range for ID-based lookup. Defaults to now.'),
})

/**
 *
 * Check which traces have cached summaries available.
 *
 * This endpoint allows batch checking of multiple trace IDs to see which ones
 * have cached summaries. Returns only the traces that have cached summaries
 * with their titles.
 *
 * **Use Cases:**
 * - Load cached summaries on session view load
 * - Avoid unnecessary LLM calls for already-summarized traces
 * - Display summary previews without generating new summaries
 *
 */
export const llmAnalyticsSummarizationBatchCheckCreateBodyTraceIdsMax = 100

export const llmAnalyticsSummarizationBatchCheckCreateBodyModeDefault = `minimal`

export const LlmAnalyticsSummarizationBatchCheckCreateBody = /* @__PURE__ */ zod.object({
    trace_ids: zod
        .array(zod.string())
        .max(llmAnalyticsSummarizationBatchCheckCreateBodyTraceIdsMax)
        .describe('List of trace IDs to check for cached summaries'),
    mode: zod
        .enum(['minimal', 'detailed'])
        .describe('\* `minimal` - minimal\n\* `detailed` - detailed')
        .default(llmAnalyticsSummarizationBatchCheckCreateBodyModeDefault)
        .describe('Summary detail level to check for\n\n\* `minimal` - minimal\n\* `detailed` - detailed'),
    model: zod.string().nullish().describe('LLM model used for cached summaries'),
})

/**
 *
 * Generate a human-readable text representation of an LLM trace event.
 *
 * This endpoint converts AI observability events ($ai_generation, $ai_span, $ai_embedding, or $ai_trace)
 * into formatted text representations suitable for display, logging, or analysis.
 *
 * **Supported Event Types:**
 * - `$ai_generation`: Individual LLM API calls with input/output messages
 * - `$ai_span`: Logical spans with state transitions
 * - `$ai_embedding`: Embedding generation events (text input → vector)
 * - `$ai_trace`: Full traces with hierarchical structure
 *
 * **Options:**
 * - `max_length`: Maximum character count (default: 2000000)
 * - `truncated`: Enable middle-content truncation within events (default: true)
 * - `truncate_buffer`: Characters at start/end when truncating (default: 1000)
 * - `include_markers`: Use interactive markers vs plain text indicators (default: true)
 *   - Frontend: set true for `<<<TRUNCATED|base64|...>>>` markers
 *   - Backend/LLM: set false for `... (X chars truncated) ...` text
 * - `collapsed`: Show summary vs full trace tree (default: false)
 * - `include_hierarchy`: Include tree structure for traces (default: true)
 * - `max_depth`: Maximum depth for hierarchical rendering (default: unlimited)
 * - `tools_collapse_threshold`: Number of tools before auto-collapsing list (default: 5)
 *   - Tool lists >5 items show `<<<TOOLS_EXPANDABLE|...>>>` marker for frontend
 *   - Or `[+] AVAILABLE TOOLS: N` for backend when `include_markers: false`
 * - `include_line_numbers`: Prefix each line with line number like L001:, L010: (default: false)
 *
 * **Use Cases:**
 * - Frontend display: `truncated: true, include_markers: true, include_line_numbers: true`
 * - Backend LLM context (summary): `truncated: true, include_markers: false, collapsed: true`
 * - Backend LLM context (full): `truncated: false`
 *
 * The response includes the formatted text and metadata about the rendering.
 *
 */
export const LlmAnalyticsTextReprCreateBody = /* @__PURE__ */ zod.object({
    event_type: zod
        .enum(['$ai_generation', '$ai_span', '$ai_embedding', '$ai_trace'])
        .describe(
            '\* `$ai_generation` - $ai_generation\n\* `$ai_span` - $ai_span\n\* `$ai_embedding` - $ai_embedding\n\* `$ai_trace` - $ai_trace'
        )
        .describe(
            'Type of LLM event to stringify\n\n\* `$ai_generation` - $ai_generation\n\* `$ai_span` - $ai_span\n\* `$ai_embedding` - $ai_embedding\n\* `$ai_trace` - $ai_trace'
        ),
    data: zod.unknown().describe("Event data to stringify. For traces, should include 'trace' and 'hierarchy' fields."),
    options: zod
        .object({
            max_length: zod.number().optional().describe('Maximum length of generated text (default: 2000000)'),
            truncated: zod
                .boolean()
                .optional()
                .describe('Use truncation for long content within events (default: true)'),
            truncate_buffer: zod
                .number()
                .optional()
                .describe('Characters to show at start\/end when truncating (default: 1000)'),
            include_markers: zod
                .boolean()
                .optional()
                .describe('Use interactive markers for frontend vs plain text for backend\/LLM (default: true)'),
            collapsed: zod
                .boolean()
                .optional()
                .describe('Show summary vs full tree hierarchy for traces (default: false)'),
            include_metadata: zod.boolean().optional().describe('Include metadata in response'),
            include_hierarchy: zod.boolean().optional().describe('Include hierarchy information (for traces)'),
            max_depth: zod.number().optional().describe('Maximum depth for hierarchical rendering'),
            tools_collapse_threshold: zod
                .number()
                .optional()
                .describe('Number of tools before collapsing the list (default: 5)'),
            include_line_numbers: zod
                .boolean()
                .optional()
                .describe('Prefix each line with line number (default: false)'),
        })
        .optional()
        .describe('Optional configuration for text generation'),
})

export const llmAnalyticsTraceReviewsCreateBodyTraceIdMax = 255

export const llmAnalyticsTraceReviewsCreateBodyScoresItemCategoricalValuesItemMax = 128

export const llmAnalyticsTraceReviewsCreateBodyScoresItemNumericValueRegExp = new RegExp('^-?\\d{0,6}(?:\\.\\d{0,6})?$')

export const LlmAnalyticsTraceReviewsCreateBody = /* @__PURE__ */ zod.object({
    trace_id: zod
        .string()
        .max(llmAnalyticsTraceReviewsCreateBodyTraceIdMax)
        .describe('Trace ID for the review. Only one active review can exist per trace and team.'),
    comment: zod.string().nullish().describe('Optional comment or reasoning for the review.'),
    scores: zod
        .array(
            zod.object({
                definition_id: zod.uuid().describe('Stable scorer definition ID.'),
                definition_version_id: zod
                    .uuid()
                    .nullish()
                    .describe("Optional immutable scorer version ID. Defaults to the scorer's current version."),
                categorical_values: zod
                    .array(zod.string().max(llmAnalyticsTraceReviewsCreateBodyScoresItemCategoricalValuesItemMax))
                    .min(1)
                    .nullish()
                    .describe('Categorical option keys selected for this score.'),
                numeric_value: zod
                    .stringFormat('decimal', llmAnalyticsTraceReviewsCreateBodyScoresItemNumericValueRegExp)
                    .nullish()
                    .describe('Numeric value selected for this score.'),
                boolean_value: zod.boolean().nullish().describe('Boolean value selected for this score.'),
            })
        )
        .optional()
        .describe('Full desired score set for this review. Omit scorers you want to leave blank.'),
    queue_id: zod
        .uuid()
        .nullish()
        .describe(
            'Optional review queue ID for queue-context saves. When provided, the matching pending queue item is cleared after the review is saved. If omitted, any pending queue item for the same trace is cleared.'
        ),
})

export const llmAnalyticsTraceReviewsPartialUpdateBodyTraceIdMax = 255

export const llmAnalyticsTraceReviewsPartialUpdateBodyScoresItemCategoricalValuesItemMax = 128

export const llmAnalyticsTraceReviewsPartialUpdateBodyScoresItemNumericValueRegExp = new RegExp(
    '^-?\\d{0,6}(?:\\.\\d{0,6})?$'
)

export const LlmAnalyticsTraceReviewsPartialUpdateBody = /* @__PURE__ */ zod.object({
    trace_id: zod
        .string()
        .max(llmAnalyticsTraceReviewsPartialUpdateBodyTraceIdMax)
        .optional()
        .describe('Trace ID for the review. Only one active review can exist per trace and team.'),
    comment: zod.string().nullish().describe('Optional comment or reasoning for the review.'),
    scores: zod
        .array(
            zod.object({
                definition_id: zod.uuid().describe('Stable scorer definition ID.'),
                definition_version_id: zod
                    .uuid()
                    .nullish()
                    .describe("Optional immutable scorer version ID. Defaults to the scorer's current version."),
                categorical_values: zod
                    .array(
                        zod.string().max(llmAnalyticsTraceReviewsPartialUpdateBodyScoresItemCategoricalValuesItemMax)
                    )
                    .min(1)
                    .nullish()
                    .describe('Categorical option keys selected for this score.'),
                numeric_value: zod
                    .stringFormat('decimal', llmAnalyticsTraceReviewsPartialUpdateBodyScoresItemNumericValueRegExp)
                    .nullish()
                    .describe('Numeric value selected for this score.'),
                boolean_value: zod.boolean().nullish().describe('Boolean value selected for this score.'),
            })
        )
        .optional()
        .describe('Full desired score set for this review. Omit scorers you want to leave blank.'),
    queue_id: zod
        .uuid()
        .nullish()
        .describe(
            'Optional review queue ID for queue-context saves. When provided, the matching pending queue item is cleared after the review is saved. If omitted, any pending queue item for the same trace is cleared.'
        ),
})

/**
 * Translate text to target language.
 */
export const llmAnalyticsTranslateCreateBodyTextMax = 10000

export const llmAnalyticsTranslateCreateBodyTargetLanguageDefault = `en`
export const llmAnalyticsTranslateCreateBodyTargetLanguageMax = 10

export const LlmAnalyticsTranslateCreateBody = /* @__PURE__ */ zod.object({
    text: zod.string().max(llmAnalyticsTranslateCreateBodyTextMax).describe('The text to translate'),
    target_language: zod
        .string()
        .max(llmAnalyticsTranslateCreateBodyTargetLanguageMax)
        .default(llmAnalyticsTranslateCreateBodyTargetLanguageDefault)
        .describe("Target language code (default: 'en' for English)"),
})

export const llmPromptsCreateBodyNameMax = 255

export const llmPromptsCreateBodyVersionDescriptionMax = 400

export const LlmPromptsCreateBody = /* @__PURE__ */ zod.object({
    name: zod
        .string()
        .max(llmPromptsCreateBodyNameMax)
        .describe('Unique prompt name using letters, numbers, hyphens, and underscores only.'),
    prompt: zod.unknown().describe('Prompt payload as JSON or string data.'),
    config: zod
        .looseObject({})
        .nullish()
        .describe(
            "Optional JSON object with model parameters or any agent configuration (e.g. model, temperature, tools). Versioned with the prompt and returned as-is when fetching it. Don't store secrets here: config is returned to anyone who can read the prompt."
        ),
    version_description: zod
        .string()
        .max(llmPromptsCreateBodyVersionDescriptionMax)
        .nullish()
        .describe('Optional note describing what changed in this version. Set when the version is published.'),
})

export const llmPromptsNamePartialUpdateBodyVersionDescriptionMax = 400

export const LlmPromptsNamePartialUpdateBody = /* @__PURE__ */ zod.object({
    prompt: zod
        .unknown()
        .optional()
        .describe('Full prompt payload to publish as a new version. Mutually exclusive with edits.'),
    edits: zod
        .array(
            zod.object({
                old: zod.string().describe('Text to find in the current prompt. Must match exactly once.'),
                new: zod.string().describe('Replacement text.'),
            })
        )
        .optional()
        .describe(
            "List of find\/replace operations to apply to the current prompt version. Each edit's 'old' text must match exactly once. Edits are applied sequentially. Mutually exclusive with prompt."
        ),
    config: zod
        .looseObject({})
        .nullish()
        .describe(
            "JSON object with model parameters or any agent configuration to store with this version. If omitted, the current version's config is carried forward; pass null to clear it. Can be combined with either prompt or edits. Don't store secrets here: config is returned to anyone who can read the prompt."
        ),
    base_version: zod
        .number()
        .min(1)
        .optional()
        .describe('Latest version you are editing from. Used for optimistic concurrency checks.'),
    version_description: zod
        .string()
        .max(llmPromptsNamePartialUpdateBodyVersionDescriptionMax)
        .optional()
        .describe('Optional note describing what changed in this version. Shown in the version history.'),
})

export const llmPromptsNameDuplicateCreateBodyNewNameMax = 255

export const LlmPromptsNameDuplicateCreateBody = /* @__PURE__ */ zod.object({
    new_name: zod
        .string()
        .max(llmPromptsNameDuplicateCreateBodyNewNameMax)
        .describe(
            'Name for the duplicated prompt. Must be unique and use only letters, numbers, hyphens, and underscores.'
        ),
})

export const LlmPromptsNameLabelsUpdateBody = /* @__PURE__ */ zod.object({
    version: zod
        .number()
        .min(1)
        .describe(
            'Prompt version this label should point to. If the label already exists on another version of the prompt, it is moved there.'
        ),
})

export const taggersUpdateBodyNameMax = 400

export const taggersUpdateBodyTaggerTypeDefault = `llm`
export const taggersUpdateBodyTaggerConfigOneOneTagsItemNameMax = 100

export const taggersUpdateBodyTaggerConfigOneOneTagsItemDescriptionDefault = ``
export const taggersUpdateBodyTaggerConfigOneOneTagsItemDescriptionMax = 500

export const taggersUpdateBodyTaggerConfigOneOneMinTagsDefault = 0
export const taggersUpdateBodyTaggerConfigOneOneMinTagsMin = 0

export const taggersUpdateBodyTaggerConfigOneTwoTagsItemNameMax = 100

export const taggersUpdateBodyTaggerConfigOneTwoTagsItemDescriptionDefault = ``
export const taggersUpdateBodyTaggerConfigOneTwoTagsItemDescriptionMax = 500

export const taggersUpdateBodyConditionsItemIdMax = 100

export const taggersUpdateBodyConditionsItemRolloutPercentageDefault = 100
export const taggersUpdateBodyConditionsItemRolloutPercentageMin = 0
export const taggersUpdateBodyConditionsItemRolloutPercentageMax = 100

export const taggersUpdateBodyModelConfigurationOneModelMax = 100

export const TaggersUpdateBody = /* @__PURE__ */ zod.object({
    name: zod.string().max(taggersUpdateBodyNameMax),
    description: zod.string().optional(),
    enabled: zod.boolean().optional(),
    tagger_type: zod
        .enum(['llm', 'hog'])
        .describe('\* `llm` - LLM\n\* `hog` - Hog')
        .default(taggersUpdateBodyTaggerTypeDefault),
    tagger_config: zod
        .union([
            zod.object({
                prompt: zod.string().min(1).describe('Prompt instructing the LLM how to tag generations'),
                tags: zod
                    .array(
                        zod.object({
                            name: zod
                                .string()
                                .max(taggersUpdateBodyTaggerConfigOneOneTagsItemNameMax)
                                .describe('Tag identifier'),
                            description: zod
                                .string()
                                .max(taggersUpdateBodyTaggerConfigOneOneTagsItemDescriptionMax)
                                .default(taggersUpdateBodyTaggerConfigOneOneTagsItemDescriptionDefault)
                                .describe('Description to help the LLM classify'),
                        })
                    )
                    .describe('Available tags the LLM can assign'),
                min_tags: zod
                    .number()
                    .min(taggersUpdateBodyTaggerConfigOneOneMinTagsMin)
                    .default(taggersUpdateBodyTaggerConfigOneOneMinTagsDefault)
                    .describe('Minimum number of tags to apply'),
                max_tags: zod.number().min(1).nullish().describe('Maximum number of tags to apply (null = no limit)'),
            }),
            zod.object({
                source: zod.string().min(1).describe('Hog source code to classify a generation into tags.'),
                tags: zod
                    .array(
                        zod.object({
                            name: zod
                                .string()
                                .max(taggersUpdateBodyTaggerConfigOneTwoTagsItemNameMax)
                                .describe('Tag identifier'),
                            description: zod
                                .string()
                                .max(taggersUpdateBodyTaggerConfigOneTwoTagsItemDescriptionMax)
                                .default(taggersUpdateBodyTaggerConfigOneTwoTagsItemDescriptionDefault)
                                .describe('Description to help the LLM classify'),
                        })
                    )
                    .optional()
                    .describe('Optional tag whitelist. Leave empty to allow any tag returned by the Hog code.'),
            }),
        ])
        .describe(
            "Tagger configuration. For tagger_type 'llm': {prompt, tags, min_tags?, max_tags?}. For tagger_type 'hog': {source, tags?}."
        ),
    conditions: zod
        .array(
            zod.object({
                id: zod
                    .string()
                    .max(taggersUpdateBodyConditionsItemIdMax)
                    .describe('Stable identifier for this condition'),
                rollout_percentage: zod
                    .number()
                    .min(taggersUpdateBodyConditionsItemRolloutPercentageMin)
                    .max(taggersUpdateBodyConditionsItemRolloutPercentageMax)
                    .default(taggersUpdateBodyConditionsItemRolloutPercentageDefault)
                    .describe('Percentage of matching events to apply this condition to'),
                properties: zod
                    .array(zod.record(zod.string(), zod.unknown()))
                    .optional()
                    .describe('Property filters that scope when this condition fires'),
            })
        )
        .optional()
        .describe('Conditions that scope when the tagger runs'),
    model_configuration: zod
        .union([
            zod.object({
                provider: zod
                    .enum([
                        'openai',
                        'anthropic',
                        'gemini',
                        'openrouter',
                        'fireworks',
                        'azure_openai',
                        'together_ai',
                        'minimax',
                        'openai_compatible',
                    ])
                    .describe(
                        '\* `openai` - Openai\n\* `anthropic` - Anthropic\n\* `gemini` - Gemini\n\* `openrouter` - Openrouter\n\* `fireworks` - Fireworks\n\* `azure_openai` - Azure OpenAI\n\* `together_ai` - Together AI\n\* `minimax` - MiniMax\n\* `openai_compatible` - OpenAI-compatible'
                    )
                    .describe(
                        'LLM provider to use for this tagger.\n\n\* `openai` - Openai\n\* `anthropic` - Anthropic\n\* `gemini` - Gemini\n\* `openrouter` - Openrouter\n\* `fireworks` - Fireworks\n\* `azure_openai` - Azure OpenAI\n\* `together_ai` - Together AI\n\* `minimax` - MiniMax\n\* `openai_compatible` - OpenAI-compatible'
                    ),
                model: zod
                    .string()
                    .max(taggersUpdateBodyModelConfigurationOneModelMax)
                    .describe('Provider model identifier to use for this tagger.'),
                provider_key_id: zod
                    .uuid()
                    .nullish()
                    .describe(
                        'Existing LLM provider key UUID for the current project. Do not invent this value; use a real provider key ID returned by PostHog, or omit\/null when no provider key should be pinned.'
                    ),
            }),
            zod.null(),
        ])
        .optional(),
    deleted: zod.boolean().optional(),
})

export const taggersPartialUpdateBodyNameMax = 400

export const taggersPartialUpdateBodyTaggerTypeDefault = `llm`
export const taggersPartialUpdateBodyTaggerConfigOneOneTagsItemNameMax = 100

export const taggersPartialUpdateBodyTaggerConfigOneOneTagsItemDescriptionDefault = ``
export const taggersPartialUpdateBodyTaggerConfigOneOneTagsItemDescriptionMax = 500

export const taggersPartialUpdateBodyTaggerConfigOneOneMinTagsDefault = 0
export const taggersPartialUpdateBodyTaggerConfigOneOneMinTagsMin = 0

export const taggersPartialUpdateBodyTaggerConfigOneTwoTagsItemNameMax = 100

export const taggersPartialUpdateBodyTaggerConfigOneTwoTagsItemDescriptionDefault = ``
export const taggersPartialUpdateBodyTaggerConfigOneTwoTagsItemDescriptionMax = 500

export const taggersPartialUpdateBodyConditionsItemIdMax = 100

export const taggersPartialUpdateBodyConditionsItemRolloutPercentageDefault = 100
export const taggersPartialUpdateBodyConditionsItemRolloutPercentageMin = 0
export const taggersPartialUpdateBodyConditionsItemRolloutPercentageMax = 100

export const taggersPartialUpdateBodyModelConfigurationOneModelMax = 100

export const TaggersPartialUpdateBody = /* @__PURE__ */ zod.object({
    name: zod.string().max(taggersPartialUpdateBodyNameMax).optional(),
    description: zod.string().optional(),
    enabled: zod.boolean().optional(),
    tagger_type: zod
        .enum(['llm', 'hog'])
        .describe('\* `llm` - LLM\n\* `hog` - Hog')
        .default(taggersPartialUpdateBodyTaggerTypeDefault),
    tagger_config: zod
        .union([
            zod.object({
                prompt: zod.string().min(1).describe('Prompt instructing the LLM how to tag generations'),
                tags: zod
                    .array(
                        zod.object({
                            name: zod
                                .string()
                                .max(taggersPartialUpdateBodyTaggerConfigOneOneTagsItemNameMax)
                                .describe('Tag identifier'),
                            description: zod
                                .string()
                                .max(taggersPartialUpdateBodyTaggerConfigOneOneTagsItemDescriptionMax)
                                .default(taggersPartialUpdateBodyTaggerConfigOneOneTagsItemDescriptionDefault)
                                .describe('Description to help the LLM classify'),
                        })
                    )
                    .describe('Available tags the LLM can assign'),
                min_tags: zod
                    .number()
                    .min(taggersPartialUpdateBodyTaggerConfigOneOneMinTagsMin)
                    .default(taggersPartialUpdateBodyTaggerConfigOneOneMinTagsDefault)
                    .describe('Minimum number of tags to apply'),
                max_tags: zod.number().min(1).nullish().describe('Maximum number of tags to apply (null = no limit)'),
            }),
            zod.object({
                source: zod.string().min(1).describe('Hog source code to classify a generation into tags.'),
                tags: zod
                    .array(
                        zod.object({
                            name: zod
                                .string()
                                .max(taggersPartialUpdateBodyTaggerConfigOneTwoTagsItemNameMax)
                                .describe('Tag identifier'),
                            description: zod
                                .string()
                                .max(taggersPartialUpdateBodyTaggerConfigOneTwoTagsItemDescriptionMax)
                                .default(taggersPartialUpdateBodyTaggerConfigOneTwoTagsItemDescriptionDefault)
                                .describe('Description to help the LLM classify'),
                        })
                    )
                    .optional()
                    .describe('Optional tag whitelist. Leave empty to allow any tag returned by the Hog code.'),
            }),
        ])
        .optional()
        .describe(
            "Tagger configuration. For tagger_type 'llm': {prompt, tags, min_tags?, max_tags?}. For tagger_type 'hog': {source, tags?}."
        ),
    conditions: zod
        .array(
            zod.object({
                id: zod
                    .string()
                    .max(taggersPartialUpdateBodyConditionsItemIdMax)
                    .describe('Stable identifier for this condition'),
                rollout_percentage: zod
                    .number()
                    .min(taggersPartialUpdateBodyConditionsItemRolloutPercentageMin)
                    .max(taggersPartialUpdateBodyConditionsItemRolloutPercentageMax)
                    .default(taggersPartialUpdateBodyConditionsItemRolloutPercentageDefault)
                    .describe('Percentage of matching events to apply this condition to'),
                properties: zod
                    .array(zod.record(zod.string(), zod.unknown()))
                    .optional()
                    .describe('Property filters that scope when this condition fires'),
            })
        )
        .optional()
        .describe('Conditions that scope when the tagger runs'),
    model_configuration: zod
        .union([
            zod.object({
                provider: zod
                    .enum([
                        'openai',
                        'anthropic',
                        'gemini',
                        'openrouter',
                        'fireworks',
                        'azure_openai',
                        'together_ai',
                        'minimax',
                        'openai_compatible',
                    ])
                    .describe(
                        '\* `openai` - Openai\n\* `anthropic` - Anthropic\n\* `gemini` - Gemini\n\* `openrouter` - Openrouter\n\* `fireworks` - Fireworks\n\* `azure_openai` - Azure OpenAI\n\* `together_ai` - Together AI\n\* `minimax` - MiniMax\n\* `openai_compatible` - OpenAI-compatible'
                    )
                    .describe(
                        'LLM provider to use for this tagger.\n\n\* `openai` - Openai\n\* `anthropic` - Anthropic\n\* `gemini` - Gemini\n\* `openrouter` - Openrouter\n\* `fireworks` - Fireworks\n\* `azure_openai` - Azure OpenAI\n\* `together_ai` - Together AI\n\* `minimax` - MiniMax\n\* `openai_compatible` - OpenAI-compatible'
                    ),
                model: zod
                    .string()
                    .max(taggersPartialUpdateBodyModelConfigurationOneModelMax)
                    .describe('Provider model identifier to use for this tagger.'),
                provider_key_id: zod
                    .uuid()
                    .nullish()
                    .describe(
                        'Existing LLM provider key UUID for the current project. Do not invent this value; use a real provider key ID returned by PostHog, or omit\/null when no provider key should be pinned.'
                    ),
            }),
            zod.null(),
        ])
        .optional(),
    deleted: zod.boolean().optional(),
})

/**
 * Test Hog tagger code against sample events without saving.
 */

export const taggersTestHogCreateBodySampleCountDefault = 5
export const taggersTestHogCreateBodySampleCountMax = 10

export const taggersTestHogCreateBodyTagsItemNameMax = 100

export const taggersTestHogCreateBodyTagsItemDescriptionDefault = ``
export const taggersTestHogCreateBodyTagsItemDescriptionMax = 500

export const TaggersTestHogCreateBody = /* @__PURE__ */ zod.object({
    source: zod
        .string()
        .min(1)
        .describe('Hog source code to test. Return a tag name string, a list of tag name strings, or null.'),
    sample_count: zod
        .number()
        .min(1)
        .max(taggersTestHogCreateBodySampleCountMax)
        .default(taggersTestHogCreateBodySampleCountDefault)
        .describe('Number of recent $ai_generation events to test against (1-10, default 5).'),
    tags: zod
        .array(
            zod.object({
                name: zod
                    .string()
                    .max(taggersTestHogCreateBodyTagsItemNameMax)
                    .describe('Tag identifier to allow in Hog test results.'),
                description: zod
                    .string()
                    .max(taggersTestHogCreateBodyTagsItemDescriptionMax)
                    .default(taggersTestHogCreateBodyTagsItemDescriptionDefault)
                    .describe('Optional description for the tag.'),
            })
        )
        .optional()
        .describe('Optional tag whitelist. Returned tags outside this list are filtered out.'),
})