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.

349 KB
Raw Blame
/**
 * Auto-generated from the Django backend OpenAPI schema.
 * MCP service uses these Zod schemas for generated tool handlers.
 * To regenerate: hogli build:openapi
 *
 * PostHog API - MCP 84 enabled ops
 * OpenAPI spec version: 1.0.0
 */
import * as zod from 'zod'

/**
 * @summary Get your activity summary
 */
export const SignalsActivitySummaryListParams = () => zod.object({
    project_id: zod
        .string()
        .describe(
            "Project ID of the project you're trying to access. To find the ID of the project, make a call to \/api\/projects\/."
        ),
})

/**
 * @summary List your activity summary versions
 */
export const SignalsActivitySummaryVersionsRetrieveParams = () => zod.object({
    project_id: zod
        .string()
        .describe(
            "Project ID of the project you're trying to access. To find the ID of the project, make a call to \/api\/projects\/."
        ),
})

export const signalsActivitySummaryVersionsRetrieveQueryLimitDefault = 5

export const SignalsActivitySummaryVersionsRetrieveQueryParams = () => zod.object({
    limit: zod
        .number()
        .min(1)
        .default(signalsActivitySummaryVersionsRetrieveQueryLimitDefault)
        .describe('The most versions to return, newest first. Capped at the number of versions kept.'),
    version: zod
        .number()
        .min(1)
        .optional()
        .describe('Return only this version, with its full profile. Returns 404 when the version does not exist.'),
})

/**
 * Find the project members whose activity summary matches a topic, an object or a product, including people who only open the work and never edit it. Returns 404 when the search is not available for this project.
 * @summary Search member activity summaries
 */
export const SignalsActivitySummaryMembersSearchParams = () => zod.object({
    project_id: zod
        .string()
        .describe(
            "Project ID of the project you're trying to access. To find the ID of the project, make a call to \/api\/projects\/."
        ),
})

export const signalsActivitySummaryMembersSearchQueryIncludeProfileDefault = false
export const signalsActivitySummaryMembersSearchQueryLimitDefault = 10
export const signalsActivitySummaryMembersSearchQueryLimitMax = 25

export const signalsActivitySummaryMembersSearchQueryQueryMax = 500

export const signalsActivitySummaryMembersSearchQuerySearchModeDefault = `hybrid`

export const SignalsActivitySummaryMembersSearchQueryParams = () => zod.object({
    exclude_user_uuids: zod
        .array(zod.string())
        .optional()
        .describe('Members to leave out, such as people you already checked.'),
    include_profile: zod
        .boolean()
        .default(signalsActivitySummaryMembersSearchQueryIncludeProfileDefault)
        .describe('Add the one-page markdown profile to each result. Set it only for the people you want to read.'),
    limit: zod
        .number()
        .min(1)
        .max(signalsActivitySummaryMembersSearchQueryLimitMax)
        .default(signalsActivitySummaryMembersSearchQueryLimitDefault)
        .describe('The most results to return, best match first.'),
    product: zod
        .enum([
            'product_analytics',
            'dashboards',
            'web_analytics',
            'session_replay',
            'heatmaps',
            'error_tracking',
            'experiments',
            'feature_flags',
            'early_access_features',
            'surveys',
            'product_tours',
            'notebooks',
            'cohorts',
            'persons',
            'data_management',
            'data_warehouse',
            'data_pipelines',
            'workflows',
            'ai_observability',
            'mcp_analytics',
            'logs',
            'tracing',
            'endpoints',
            'revenue_analytics',
            'customer_analytics',
            'inbox',
            'canvases',
            'support',
        ])
        .optional()
        .describe(
            'Only members who work in or visit this product.\n\n\* `product_analytics` - Product Analytics\n\* `dashboards` - Dashboards\n\* `web_analytics` - Web Analytics\n\* `session_replay` - Session Replay\n\* `heatmaps` - Heatmaps\n\* `error_tracking` - Error Tracking\n\* `experiments` - Experiments\n\* `feature_flags` - Feature Flags\n\* `early_access_features` - Early Access Features\n\* `surveys` - Surveys\n\* `product_tours` - Product Tours\n\* `notebooks` - Notebooks\n\* `cohorts` - Cohorts\n\* `persons` - Persons\n\* `data_management` - Data Management\n\* `data_warehouse` - Data Warehouse\n\* `data_pipelines` - Data Pipelines\n\* `workflows` - Workflows\n\* `ai_observability` - Ai Observability\n\* `mcp_analytics` - Mcp Analytics\n\* `logs` - Logs\n\* `tracing` - Tracing\n\* `endpoints` - Endpoints\n\* `revenue_analytics` - Revenue Analytics\n\* `customer_analytics` - Customer Analytics\n\* `inbox` - Inbox\n\* `canvases` - Canvases\n\* `support` - Support'
        ),
    query: zod
        .string()
        .max(signalsActivitySummaryMembersSearchQueryQueryMax)
        .optional()
        .describe(
            'Natural language or keywords, such as an object name, a topic or a product area. Without a query, the search lists members with a summary, the newest summary first.'
        ),
    search_mode: zod
        .enum(['hybrid', 'semantic', 'keyword'])
        .default(signalsActivitySummaryMembersSearchQuerySearchModeDefault)
        .describe(
            '`hybrid` merges the keyword and semantic rankings. `semantic` ranks by meaning only, and returns 503 when the vector search fails. `keyword` matches query terms in the profile, the headline, the theme labels and the names of owned and watched objects.\n\n\* `hybrid` - Hybrid\n\* `semantic` - Semantic\n\* `keyword` - Keyword'
        ),
})

/**
 * Read-only anomaly rates of the saved trends insights that anomaly scoring checks.
 * @summary Get the scored anomaly history of an insight
 */
export const SignalsAnomaliesInsightRetrieveParams = () => zod.object({
    project_id: zod
        .string()
        .describe(
            "Project ID of the project you're trying to access. To find the ID of the project, make a call to \/api\/projects\/."
        ),
})

export const signalsAnomaliesInsightRetrieveQueryDateFromDefault = `-30d`

export const signalsAnomaliesInsightRetrieveQueryIncludeBucketsDefault = true
export const signalsAnomaliesInsightRetrieveQueryIncludeWarmupDefault = false

export const SignalsAnomaliesInsightRetrieveQueryParams = () => zod.object({
    date_from: zod
        .string()
        .min(1)
        .default(signalsAnomaliesInsightRetrieveQueryDateFromDefault)
        .describe('Earliest bucket start in the range. A relative date such as `-30d`, or an ISO 8601 date.'),
    date_to: zod
        .string()
        .min(1)
        .optional()
        .describe('Latest bucket start in the range. A relative date or an ISO 8601 date. Defaults to now.'),
    include_buckets: zod
        .boolean()
        .default(signalsAnomaliesInsightRetrieveQueryIncludeBucketsDefault)
        .describe('Return the buckets of each series. Set false for the per-series summary only.'),
    include_warmup: zod
        .boolean()
        .default(signalsAnomaliesInsightRetrieveQueryIncludeWarmupDefault)
        .describe(
            'Include warm-up buckets: scored rows with a null score and flag, written while the detector still lacks history. When false, a warm-up bucket shows as `scored: false`.'
        ),
    insight_id: zod.number().describe('The insight, by numeric id.'),
    series_key: zod
        .string()
        .min(1)
        .optional()
        .describe('Only this series, by the `series_key` of an anomaly search row.'),
})

/**
 * Read-only anomaly rates of the saved trends insights that anomaly scoring checks.
 * @summary Search anomalous insight series
 */
export const SignalsAnomaliesSearchRetrieveParams = () => zod.object({
    project_id: zod
        .string()
        .describe(
            "Project ID of the project you're trying to access. To find the ID of the project, make a call to \/api\/projects\/."
        ),
})

export const signalsAnomaliesSearchRetrieveQueryDateFromDefault = `-7d`

export const signalsAnomaliesSearchRetrieveQueryGroupByDefault = `series`
export const signalsAnomaliesSearchRetrieveQueryLimitDefault = 25
export const signalsAnomaliesSearchRetrieveQueryLimitMax = 100

export const signalsAnomaliesSearchRetrieveQueryOnlyFlaggedDefault = true

export const SignalsAnomaliesSearchRetrieveQueryParams = () => zod.object({
    dashboard_id: zod.number().optional().describe('Only the series of the insights on this dashboard, by numeric id.'),
    date_from: zod
        .string()
        .min(1)
        .default(signalsAnomaliesSearchRetrieveQueryDateFromDefault)
        .describe('Earliest bucket start in the range. A relative date such as `-7d` or `-24h`, or an ISO 8601 date.'),
    date_to: zod
        .string()
        .min(1)
        .optional()
        .describe('Latest bucket start in the range. A relative date or an ISO 8601 date. Defaults to now.'),
    group_by: zod
        .enum(['series', 'insight'])
        .default(signalsAnomaliesSearchRetrieveQueryGroupByDefault)
        .describe(
            '`series` returns one row per series in `series`. `insight` returns one row per insight in `insights`.\n\n\* `series` - Series\n\* `insight` - Insight'
        ),
    insight_id: zod.number().optional().describe('Only the series of this insight, by numeric id.'),
    interval: zod
        .enum(['hour', 'day', 'week', 'month'])
        .optional()
        .describe(
            'Only series with this interval.\n\n\* `hour` - Hour\n\* `day` - Day\n\* `week` - Week\n\* `month` - Month'
        ),
    limit: zod
        .number()
        .min(1)
        .max(signalsAnomaliesSearchRetrieveQueryLimitMax)
        .default(signalsAnomaliesSearchRetrieveQueryLimitDefault)
        .describe('The most rows to return.'),
    only_flagged: zod
        .boolean()
        .default(signalsAnomaliesSearchRetrieveQueryOnlyFlaggedDefault)
        .describe(
            'Only series, or insights, with at least one flagged bucket in the range. Set false to also list quiet ones.'
        ),
})

/**
 * Team-level signal autonomy config (singleton per team).
 *
 * GET  /signals/config/  → retrieve
 * POST /signals/config/  → update
 * @summary Read the project's signals config
 */
export const SignalsConfigListParams = () => zod.object({
    project_id: zod
        .string()
        .describe(
            "Project ID of the project you're trying to access. To find the ID of the project, make a call to \/api\/projects\/."
        ),
})

/**
 * Partial update of the per-project singleton. Omitted fields keep their value.
 * @summary Update the project's signals config
 */
export const SignalsConfigCreateParams = () => zod.object({
    project_id: zod
        .string()
        .describe(
            "Project ID of the project you're trying to access. To find the ID of the project, make a call to \/api\/projects\/."
        ),
})

export const signalsConfigCreateBodyDefaultSlackNotificationChannelMax = 255

export const signalsConfigCreateBodyAutostartBaseBranchesMaxOne = 255

export const signalsConfigCreateBodyScoutInstructionsMax = 20000

export const signalsConfigCreateBodyResearchInstructionsMax = 20000

export const signalsConfigCreateBodyImplementationInstructionsMax = 20000

export const signalsConfigCreateBodyIssueTrackingConfigMaxOne = 255

export const signalsConfigCreateBodyMaxReportsPerDayMax = 2147483647

export const signalsConfigCreateBodyPullRequestLabelMax = 50

export const signalsConfigCreateBodyImplementationRepositoriesItemMax = 255

export const signalsConfigCreateBodyImplementationRepositoriesMax = 20

export const SignalsConfigCreateBody = () => zod.object({
    autostart_enabled: zod
        .boolean()
        .nullish()
        .describe(
            'Master switch for autonomous inbox PRs. Null (never set) leaves autostart on; set false to opt out, so actionable reports still generate and notify but the team never auto-starts an implementation task or opens a PR — reviewers open PRs manually.'
        ),
    default_autostart_priority: zod
        .enum(['P0', 'P1', 'P2', 'P3', 'P4'])
        .optional()
        .describe('\* `P0` - P0\n\* `P1` - P1\n\* `P2` - P2\n\* `P3` - P3\n\* `P4` - P4'),
    default_slack_notification_channel: zod
        .string()
        .max(signalsConfigCreateBodyDefaultSlackNotificationChannelMax)
        .nullish()
        .describe(
            "Default Slack channel for this team's signal inbox notifications, in the same `channel_id|#channel-name` shape PostHog uses elsewhere (only the channel id is required). Null means no team-level default; per-user channels still apply."
        ),
    default_slack_notification_integration: zod
        .number()
        .nullish()
        .describe(
            "Connected Slack integration that owns `default_slack_notification_channel`. Send it together with the channel. A channel saved without it is routed through the team's oldest Slack integration, and clearing the channel clears this too."
        ),
    autostart_base_branches: zod
        .record(zod.string(), zod.string().max(signalsConfigCreateBodyAutostartBaseBranchesMaxOne))
        .optional()
        .describe(
            "Per-repository base branch overrides for auto-started inbox PRs, keyed by 'organization\/repository'. The branch is what the auto-PR targets; omit a repo (or send {}) to keep targeting the repo default branch."
        ),
    scout_instructions: zod
        .string()
        .max(signalsConfigCreateBodyScoutInstructionsMax)
        .optional()
        .describe(
            "Project-level instructions added to every scout run, alongside project instructions and the scout's own brief. Blank uses project instructions only."
        ),
    research_instructions: zod
        .string()
        .max(signalsConfigCreateBodyResearchInstructionsMax)
        .optional()
        .describe(
            'Project-level instructions for the dedicated signal report research stage. Other agent roles do not receive them. Blank uses project instructions only.'
        ),
    implementation_instructions: zod
        .string()
        .max(signalsConfigCreateBodyImplementationInstructionsMax)
        .optional()
        .describe(
            'Project-level instructions for agents implementing signal reports. Other agent roles do not receive them. Blank uses project instructions only.'
        ),
    issue_tracking_integration: zod
        .number()
        .nullish()
        .describe(
            'Connected GitHub, GitLab, Linear, or Jira integration that self-driving opens a tracker issue in for each pull request it makes. Null turns tracker issues off, which is the default.'
        ),
    issue_tracking_config: zod
        .record(zod.string(), zod.string().max(signalsConfigCreateBodyIssueTrackingConfigMaxOne))
        .optional()
        .describe(
            "Where in the tracker the issues land. Required keys depend on the integration kind: github -> {repository}; linear -> {team_id}; jira -> {project_key}; gitlab needs none, because its integration is already bound to one project. An optional 'label' is applied to created GitHub issues."
        ),
    max_reports_per_day: zod
        .number()
        .min(1)
        .max(signalsConfigCreateBodyMaxReportsPerDayMax)
        .nullish()
        .describe(
            "Daily cap on new reports surfacing to the inbox, counted per calendar day in the project's timezone. Once reached, signal ingestion, scout runs, and report research pause until local midnight. Null means unlimited."
        ),
    default_open_pull_request_ready: zod
        .boolean()
        .optional()
        .describe(
            "Whether self-driving pull requests open ready for review instead of draft, so the full CI matrix starts when the pull request is created. False by default. A reviewer's own github_open_pull_request_ready overrides this for reports that suggest them as reviewer."
        ),
    github_issue_writeback_enabled: zod
        .boolean()
        .optional()
        .describe(
            "Whether self-driving comments back on a GitHub issue that raised a report, linking to the report so everybody watching the issue knows it is being researched. The comment is public on the issue thread and carries a link only, never report content. False by default. Needs a GitHub integration that can reach the issue's repository."
        ),
    pull_request_label_enabled: zod
        .boolean()
        .optional()
        .describe(
            'Whether self-driving adds a label to every pull request it opens, so GitHub search, saved searches, and notification rules can separate them from other automation on the repository. False by default. Needs a GitHub integration that can reach the repository.'
        ),
    pull_request_label: zod
        .string()
        .max(signalsConfigCreateBodyPullRequestLabelMax)
        .nullish()
        .describe(
            "The label name self-driving applies, at most 50 characters. Null or blank means 'self-driving'. The label is created in the repository when it does not exist yet. Only used while pull_request_label_enabled is true."
        ),
    implementation_repositories: zod
        .array(zod.string().max(signalsConfigCreateBodyImplementationRepositoriesItemMax))
        .max(signalsConfigCreateBodyImplementationRepositoriesMax)
        .optional()
        .describe(
            "Extra GitHub repositories, as 'organization\/repository', that self-driving implementation tasks can read and write within the connected GitHub App's permissions, for example an assets repository for PR screenshots. A task gets only the entries with the same owner as its selected repository. They are not cloned, and the PR still targets the selected repository. Each new entry must be reachable through one of the project's GitHub installations. Changes apply to tasks started afterwards. Empty by default."
        ),
    anomaly_scoring_enabled: zod
        .boolean()
        .optional()
        .describe(
            "Whether anomaly scoring runs while the Product analytics source (analytics \/ anomaly_investigation) is on. Scoring checks this project's active trends insights for anomalies and writes the results as $anomaly_score events, which are not billed. True by default. False stops new scores and keeps alert signals; events written before stay. Turning the source off stops scoring whatever this value is, and turning the source on again keeps this value. Turning it on does not enroll a project that anomaly_scoring_available reports as not covered."
        ),
})

export const SignalsReportsListParams = () => zod.object({
    project_id: zod
        .string()
        .describe(
            "Project ID of the project you're trying to access. To find the ID of the project, make a call to \/api\/projects\/."
        ),
})

export const signalsReportsListQueryCountOnlyDefault = false
export const signalsReportsListQueryExcludeMax = 100

export const signalsReportsListQueryIncludeSourceMetadataDefault = true
export const signalsReportsListQueryIncludeUnlistedDefault = false
export const signalsReportsListQueryLimitMax = 1000

export const SignalsReportsListQueryParams = () => zod.object({
    actionability: zod
        .string()
        .optional()
        .describe(
            'Comma-separated actionability judgments to include. Valid values: immediately_actionable, requires_human_input, not_actionable. Reports without a judgment are excluded.'
        ),
    already_addressed: zod
        .boolean()
        .optional()
        .describe(
            'Filter by whether the latest actionability judgment says the issue is already being handled. False also includes older reports where that judgment did not record a value.'
        ),
    assignee: zod
        .enum(['me', 'mine'])
        .optional()
        .describe(
            "'me' returns reports claimed by exactly the requesting actor: the user, the internal task, or the MCP agent. 'mine' returns every report the requesting user claimed: their own claims and claims by MCP agents acting for them. Internal task claims are not included."
        ),
    channel_id: zod
        .string()
        .optional()
        .describe(
            'Narrow to reports assigned to one space (channel). Absent or empty means all reports regardless of assignment.'
        ),
    count_only: zod
        .boolean()
        .default(signalsReportsListQueryCountOnlyDefault)
        .describe(
            'Return the filtered total with an empty results page. Skips report ordering, serialization, and decorative metadata lookups. Defaults to false.'
        ),
    created_after: zod.iso
        .datetime({ offset: true })
        .optional()
        .describe('ISO 8601 datetime. Keeps reports created at or after this time.'),
    created_before: zod.iso
        .datetime({ offset: true })
        .optional()
        .describe(
            'ISO 8601 datetime. Keeps reports created before this time. Use it for reports older than a cutoff, instead of reading every page.'
        ),
    exclude: zod
        .array(zod.string())
        .max(signalsReportsListQueryExcludeMax)
        .optional()
        .describe(
            'Report ids to leave out of the results and counts, for example the reports a client already shows, as repeated parameters or comma-separated. The other reports keep their order. At most 100.'
        ),
    has_implementation_pr: zod
        .boolean()
        .optional()
        .describe(
            "Filter reports by whether an implementation pull request is attached. 'true' keeps only reports with a PR; 'false' keeps only those without. Pair with count_only=true to return only the filtered total."
        ),
    include_all_statuses: zod
        .boolean()
        .optional()
        .describe(
            "When true, the list includes reports in every status with no default exclusions applied — currently that adds suppressed (dismissed) reports, which are otherwise hidden. Use it to see the full inbox state (e.g. deduplicating before creating a report) and read each row's status (plus dismissal_reason\/dismissal_note on dismissed rows) before acting. Deleted reports are terminal and never returned. Defaults to false, which keeps the existing default exclusions. Ignored when an explicit 'status' filter is set — that filter alone decides which statuses are returned."
        ),
    include_source_metadata: zod
        .boolean()
        .default(signalsReportsListQueryIncludeSourceMetadataDefault)
        .describe(
            'Fill `source_products` and `scout_name` on each row. These come from ClickHouse, so pass false to skip that lookup and get the page from Postgres only: rows then carry an empty `source_products` and a null `scout_name`. Load them after with `source_metadata`. Defaults to true.'
        ),
    include_unlisted: zod
        .boolean()
        .default(signalsReportsListQueryIncludeUnlistedDefault)
        .describe(
            'Include reports kept out of the shared inbox. A report is kept out when the scout that authored it turned off its `inbox` output destination. Defaults to false. Fetching a report by id always works, whatever this value is.'
        ),
    limit: zod
        .number()
        .max(signalsReportsListQueryLimitMax)
        .optional()
        .describe('Number of results to return per page.'),
    offset: zod.number().optional().describe('The initial index from which to return the results.'),
    ordering: zod
        .string()
        .optional()
        .describe(
            "Comma-separated ordering clauses. Each clause is a field name optionally prefixed with '-' for descending. Allowed fields: status, is_suggested_reviewer, signal_count, total_weight, priority, created_at, updated_at, id, ranking_open, ranking_action, ranking_fix. Defaults to '-is_suggested_reviewer,status,-updated_at'. Each ranking_<outcome> field sorts by the served ranking model's probability for that public outcome, with unscored reports last in either direction. Read inbox-ranking-outcomes-list for what each outcome means. The ranking fields need staff or the inbox model sort rollout: other users get a 400."
        ),
    priority: zod
        .string()
        .optional()
        .describe(
            'Comma-separated list of priorities to include. Valid values: P0, P1, P2, P3, P4. Reports without a priority assignment are excluded when this filter is set.'
        ),
    ranking_id: zod
        .string()
        .optional()
        .describe(
            'For sort=personal: the ranking_id of the first page. Pass it on later pages, so a new personal ranking does not reorder them. When that ranking no longer exists, the latest one applies.'
        ),
    ranking_min_lift: zod
        .string()
        .optional()
        .describe(
            'Comma-separated <outcome>:<lift> pairs, e.g. fix:2,open:1.5. Keeps reports whose served ranking lift is at least the value for every named outcome. Outcomes: open, action, fix. Read inbox-ranking-outcomes-list for what each outcome means. Unscored and stale reports never match. Needs staff or the inbox model sort rollout: other users get a 400.'
        ),
    ranking_min_probability: zod
        .string()
        .optional()
        .describe(
            'Comma-separated <outcome>:<probability> pairs, e.g. fix:0.3. Keeps reports whose served ranking probability is at least the value for every named outcome. Outcomes: open, action, fix. Read inbox-ranking-outcomes-list for what each outcome means. Unscored and stale reports never match. Needs staff or the inbox model sort rollout: other users get a 400.'
        ),
    scope: zod
        .string()
        .optional()
        .describe('Reviewer scope: for_me, entire_project, or teammate. Pass teammate_uuid with teammate.'),
    scout: zod
        .string()
        .optional()
        .describe(
            'Comma-separated list of scout skill_name slugs (e.g. signals-scout-error-tracking). Reports are kept if at least one of their contributing signals was authored by one of these scouts. Combines with source_product as an AND.'
        ),
    scout_prefix: zod
        .string()
        .optional()
        .describe(
            'Scout skill_name prefix (e.g. signals-scout-customer-analytics). Reports are kept if at least one of their contributing signals was authored by a scout whose skill_name starts with this prefix — new scouts in the family match without callers listing every name. Combines with the other filters as an AND.'
        ),
    search: zod.string().optional().describe('Case-insensitive substring match against report title and summary.'),
    sort: zod
        .string()
        .optional()
        .describe(
            "Inbox sort preset: priority, recommended, personal, last_updated, newest, or oldest. Ignored when ordering is supplied. recommended resolves per user to a ranker: the priority order, or the open, action or fix outcome of the served ranking model, highest score first, with unscored and stale reports in priority order after the scored ones. The response's ranker field names the one used, and its ranking_pill field says whether to show score pills. personal puts the reports of your stored personal ranking first, by rank, then the reports it folded, then every other report in your recommended order. It only reads the stored ranking and never starts a build. With no stored personal ranking, it is the recommended order."
        ),
    source_id: zod
        .string()
        .optional()
        .describe(
            "Comma-separated list of source record ids. Reports are kept if at least one of their contributing signals came from one of these records — e.g. pass a support ticket's UUID to see what the inbox already found for that ticket. Requires exactly one source_product, since a source id is only unique within its product."
        ),
    source_product: zod
        .string()
        .optional()
        .describe(
            'Comma-separated list of source products to include. Reports are kept if at least one of their contributing signals comes from one of these products (e.g. error_tracking, session_replay).'
        ),
    status: zod
        .string()
        .optional()
        .describe(
            'Comma-separated list of statuses to include. Valid values: potential, candidate, in_progress, pending_input, ready, resolved, failed, suppressed. Defaults to all statuses except suppressed.'
        ),
    suggested_reviewers: zod
        .string()
        .optional()
        .describe(
            'Comma-separated list of PostHog user UUIDs. Reports are kept if their suggested reviewers include any of the given users.'
        ),
    task_id: zod
        .string()
        .optional()
        .describe("Only reports associated with this task (via the report's task associations)."),
    teammate_uuid: zod.string().optional().describe('PostHog user UUID used when scope=teammate.'),
    unclaimed: zod
        .boolean()
        .optional()
        .describe(
            'Filter by whether the report has no owner and no draft, open, or unknown PR. Resolved reports are never unclaimed.'
        ),
    unread: zod.boolean().optional().describe("Filter by the current user's report read state."),
    use_priority_preference: zod
        .boolean()
        .optional()
        .describe(
            "When true and priority is omitted, include priorities at or above the requesting user's personal PR-generation threshold, falling back to the project threshold."
        ),
    view: zod
        .string()
        .optional()
        .describe(
            "Apply an inbox view: actionable, for_you, needs_input, needs_decision, monitoring, resolved, dismissed, held_back, not_actionable, or all. Each view applies the corresponding status, actionability, and implementation-PR filters. for_you holds the open, actionable reports that wait for the requesting user's input, that they claimed, or that name them as a suggested reviewer. needs_decision also includes failed reports without a judgment. dismissed and held_back split the suppressed reports: dismissed holds the ones a person or agent dismissed, merged, or whose pull request closed without merging; held_back holds the ones the safety or actionability judge suppressed before anyone saw them. Each row's suppression_source says which."
        ),
})

/**
 * File a complete inbox report yourself, with the same validation and safety judge a scout report passes. The report surfaces at the status `actionability` implies, or is suppressed. It never starts an implementation run or opens a pull request on its own, now or after a later edit: start one from the report's actions. Safe to retry: a resend returns the first report with `idempotent_replay` true. Each person can file a limited number of reports per project per day.
 * @summary File an inbox report
 */
export const SignalsReportsCreateParams = () => zod.object({
    project_id: zod
        .string()
        .describe(
            "Project ID of the project you're trying to access. To find the ID of the project, make a call to \/api\/projects\/."
        ),
})

export const signalsReportsCreateBodyTitleMax = 300

export const signalsReportsCreateBodyEvidenceItemDescriptionMax = 4000

export const signalsReportsCreateBodyAlreadyAddressedDefault = false
export const signalsReportsCreateBodySuggestedReviewersItemGithubLoginMax = 200

export const signalsReportsCreateBodySuggestedReviewersItemReasonMax = 500

export const signalsReportsCreateBodySuggestedReviewersMax = 10

export const signalsReportsCreateBodyChartsItemChartIdMax = 100

export const signalsReportsCreateBodyChartsItemTitleMax = 200

export const signalsReportsCreateBodyChartsItemCaptionMax = 500

export const signalsReportsCreateBodyChartsMax = 20

export const signalsReportsCreateBodySuggestedPromptsItemMax = 200

export const signalsReportsCreateBodySuggestedPromptsMax = 3

export const signalsReportsCreateBodyLinksItemReasonMax = 500

export const signalsReportsCreateBodyLinksMax = 10

export const signalsReportsCreateBodySourceIssuesItemUrlMax = 500

export const signalsReportsCreateBodySourceIssuesMax = 5

export const signalsReportsCreateBodyTagsMax = 10

export const signalsReportsCreateBodyIdempotencyKeyMax = 200

export const SignalsReportsCreateBody = () => zod
    .object({
        title: zod
            .string()
            .max(signalsReportsCreateBodyTitleMax)
            .describe(
                'One-line report title the inbox shows. Conventional-commit style (`type(scope): description`, e.g. `fix(insights): missing series color`) renders with type\/scope styling.'
            ),
        summary: zod
            .string()
            .describe(
                'The report body the inbox shows. Markdown is supported (headings, lists, code, links; images are not rendered). Lead with one plain declarative sentence — the inbox card uses your first line verbatim as the headline (~140 chars, emphasis stripped), then renders the full markdown in the detail view. A heading, or a bold label on a line of its own with a blank line above it, marks a section that a threaded Slack delivery splits into its own reply.'
            ),
        evidence: zod
            .array(
                zod
                    .object({
                        description: zod
                            .string()
                            .max(signalsReportsCreateBodyEvidenceItemDescriptionMax)
                            .describe(
                                'Prose for this observation. Embedded and rendered to the safety\/research surfaces.'
                            ),
                        source_id: zod
                            .string()
                            .describe(
                                'Stable id for this observation within the report (lets a later edit address it).'
                            ),
                    })
                    .describe('One observation backing an authored report — becomes a bound signal row on the report.')
            )
            .min(1)
            .describe('The observations backing the report — each becomes a bound signal. At least one.'),
        actionability_explanation: zod
            .string()
            .describe('2-3 sentence evidence-grounded justification for the actionability call below.'),
        actionability: zod
            .enum(['immediately_actionable', 'requires_human_input', 'not_actionable'])
            .describe(
                '\* `immediately_actionable` - immediately_actionable\n\* `requires_human_input` - requires_human_input\n\* `not_actionable` - not_actionable'
            )
            .describe(
                "The scout's actionability call: `immediately_actionable` -> the report surfaces READY; `requires_human_input` -> PENDING_INPUT; `not_actionable` -> suppressed. A safety-judge failure suppresses the report regardless. A root cause you have not found is not human input: a report that names the evidence, the code surface, or a reproducible failure path is `immediately_actionable`, because investigating it is the action. Reserve `requires_human_input` for a report blocked on a decision only a person can make.\n\n\* `immediately_actionable` - immediately_actionable\n\* `requires_human_input` - requires_human_input\n\* `not_actionable` - not_actionable"
            ),
        already_addressed: zod
            .boolean()
            .default(signalsReportsCreateBodyAlreadyAddressedDefault)
            .describe(
                'Whether the issue is already being handled — fixed in recent changes, or with a fix in flight (an open PR, a recently active branch, an assigned \/ in-progress issue or agent task). Gates autostart of a scout report, so a wrong `false` opens a duplicate PR. Tracked separately.'
            ),
        repository: zod
            .string()
            .nullish()
            .describe(
                "Optional repo for opening a draft PR, by autostart of a scout report or by a person from the inbox. Pass `owner\/repo` whenever you can say where a fix would land. Omit the field when you can't, which triggers free-form selection across the team's repos (the slow path on a many-repo team). Keep the `NO_REPO` sentinel for the rare report where nothing under version control could change, since a skill body, a config file, or a doc still lives in a repo."
            ),
        priority: zod
            .union([
                zod
                    .enum(['P0', 'P1', 'P2', 'P3', 'P4'])
                    .describe('\* `P0` - P0\n\* `P1` - P1\n\* `P2` - P2\n\* `P3` - P3\n\* `P4` - P4'),
                zod.null(),
            ])
            .optional()
            .describe(
                'Optional priority (`P0`-`P4`). Required for autostart; pair with `priority_explanation`.\n\n\* `P0` - P0\n\* `P1` - P1\n\* `P2` - P2\n\* `P3` - P3\n\* `P4` - P4'
            ),
        priority_explanation: zod
            .string()
            .nullish()
            .describe('2-3 sentence justification for `priority`. Required when `priority` is set.'),
        suggested_reviewers: zod
            .array(
                zod
                    .object({
                        github_login: zod
                            .string()
                            .max(signalsReportsCreateBodySuggestedReviewersItemGithubLoginMax)
                            .optional()
                            .describe(
                                'GitHub login (case-insensitive, stored lowercased) — e.g. `octocat`, no `@`, no display name. Resolve one via `scout-members-list` (each member row carries a resolved `github_login`) or git history when you only have a name.'
                            ),
                        user_uuid: zod
                            .string()
                            .optional()
                            .describe(
                                "PostHog user UUID (e.g. from `scout-members-list`, or an entity's `created_by`). Use this when you know the PostHog user, whether or not they have a GitHub handle — every member is routable this way. Must be a concrete UUID; the `@me` alias is not valid here."
                            ),
                        reason: zod
                            .string()
                            .max(signalsReportsCreateBodySuggestedReviewersItemReasonMax)
                            .nullish()
                            .describe(
                                "One sentence of evidence for WHY this person: what ties them to the affected surface (e.g. 'authored 4 of the last 10 commits touching products\/tracing\/mcp\/', 'human correction routed the prior tracing report to them'). Persisted on the report so the routing is auditable — always set it when you can name the evidence; 'precedent' alone is weak, prefer code-derived ownership."
                            ),
                    })
                    .describe(
                        "One suggested reviewer — identified by `github_login`, `user_uuid`, or both.\n\nA reviewer is a PostHog user, so a `user_uuid` only has to name an org member of this team: a\nmember with no linked GitHub account routes the report like anyone else. A `user_uuid` that\nisn't an org member of this team is rejected — so a reviewer is never silently dropped."
                    )
            )
            .max(signalsReportsCreateBodySuggestedReviewersMax)
            .optional()
            .describe(
                "Optional reviewers to route the report to (each a `github_login` and\/or `user_uuid`). This is the primary way a report reaches a human — the inbox floats a reviewer's own reports to the top of their inbox even when no PR is involved — so set it whenever you can name a plausible owner. On a scout report it also gates autostart: a PR opens only if at least one reviewer clears their autonomy threshold. A report a person files never autostarts."
            ),
        charts: zod
            .array(
                zod
                    .object({
                        chart_id: zod
                            .string()
                            .max(signalsReportsCreateBodyChartsItemChartIdMax)
                            .describe(
                                "Stable slug for this chart within the report (lowercase letters, numbers, underscores, hyphens; must start with a letter or number). Reference it from `summary` as a markdown link with a `chart:` target — `[Daily signups](chart:signups-drop)` — to place the chart at that point in the body. A chart you don't reference still renders, below the summary."
                            ),
                        title: zod
                            .string()
                            .max(signalsReportsCreateBodyChartsItemTitleMax)
                            .describe('Short heading shown above the chart.'),
                        query: zod
                            .unknown()
                            .describe(
                                'The query node to render. `kind` must be `InsightVizNode` (an ad-hoc product analytics chart), `DataVisualizationNode` (a SQL series — a `HogQLQuery` source plus a `display`), or `SavedInsightNode` (an existing insight by `shortId`). Pin the window to absolute dates where the node supports it, so the reader sees the data you wrote about rather than whatever a relative range resolves to when they open the report.'
                            ),
                        caption: zod
                            .string()
                            .max(signalsReportsCreateBodyChartsItemCaptionMax)
                            .nullish()
                            .describe('Optional one-line note on what to look at in the chart.'),
                        size: zod
                            .union([
                                zod
                                    .enum(['small', 'medium', 'large'])
                                    .describe('\* `small` - small\n\* `medium` - medium\n\* `large` - large'),
                                zod.null(),
                            ])
                            .optional()
                            .describe(
                                'How much height the chart gets: `small` for a single number or a short series, `medium` for an ordinary graph, `large` when there are rows or a grid to read (retention, paths, a wide breakdown). Leave it out unless the default looks wrong — the inbox sizes a chart from its query, and two charts referenced from the same paragraph sit side by side.\n\n\* `small` - small\n\* `medium` - medium\n\* `large` - large'
                            ),
                    })
                    .describe(
                        'One chart attached to a report — rendered in the inbox and referenceable from the summary.'
                    )
            )
            .max(signalsReportsCreateBodyChartsMax)
            .optional()
            .describe(
                'Optional charts to attach to the report — the inbox renders them inline, so a metric move is something the reader sees rather than a number they take on trust. Attach one whenever the finding rests on a trend, a spike, or a comparison you already queried. Reference a chart from `summary` as `[label](chart:<chart_id>)` to place it in the body; an unreferenced chart renders below the summary.'
            ),
        suggested_prompts: zod
            .array(zod.string().max(signalsReportsCreateBodySuggestedPromptsItemMax))
            .max(signalsReportsCreateBodySuggestedPromptsMax)
            .optional()
            .describe(
                "Optional follow-up prompts to offer above the report's `Ask AI` box: questions to ask, or next-step actions to request (e.g. carrying out the report's recommendation). The reader clicks one to fill the box with it, then sends or edits it. Write the prompts your own research left open, phrased as the reader would send them."
            ),
        links: zod
            .array(
                zod
                    .object({
                        kind: zod
                            .enum(['depends_on', 'part_of', 'follow_up_of', 'duplicate_of', 'recurrence_of'])
                            .describe(
                                '\* `depends_on` - Depends on\n\* `part_of` - Part of\n\* `follow_up_of` - Follow-up of\n\* `duplicate_of` - Duplicate of\n\* `recurrence_of` - Recurrence of'
                            )
                            .describe(
                                "How this report relates to `report_id`. `depends_on` for work that cannot land until the other report's fix does, `part_of` for one piece of a larger report, `follow_up_of` for work the other report left behind, `duplicate_of` for the same problem filed twice, and `recurrence_of` for a problem a resolved report already covered.\n\n\* `depends_on` - Depends on\n\* `part_of` - Part of\n\* `follow_up_of` - Follow-up of\n\* `duplicate_of` - Duplicate of\n\* `recurrence_of` - Recurrence of"
                            ),
                        report_id: zod
                            .string()
                            .describe('Id of the report to link to. Must be another report in this project.'),
                        reason: zod
                            .string()
                            .max(signalsReportsCreateBodyLinksItemReasonMax)
                            .optional()
                            .describe('Optional one-line note on why the reports are linked this way.'),
                    })
                    .describe('One typed, directed link to write on the report being emitted or edited.')
            )
            .max(signalsReportsCreateBodyLinksMax)
            .optional()
            .describe(
                'Typed, directed links from the new report to reports that already exist. Send them here, not in a later `edit-report` call, because autostart reads them when the report is created: a `duplicate_of` link to a report that already has a pull request, or a `depends_on` link to a report with no pull request yet, stops a second draft PR. Only the new report gets a row, so link from the side the sentence starts at. Links of the same kind must stay acyclic and every report must be in this project.'
            ),
        source_issues: zod
            .array(
                zod
                    .object({
                        url: zod
                            .string()
                            .max(signalsReportsCreateBodySourceIssuesItemUrlMax)
                            .describe(
                                "The issue's URL, `https:\/\/github.com\/<owner>\/<repo>\/issues\/<number>`. Only GitHub issues are accepted today. Pull request URLs are rejected."
                            ),
                    })
                    .describe('One external issue the report is about.')
            )
            .max(signalsReportsCreateBodySourceIssuesMax)
            .optional()
            .describe(
                'The GitHub issues this report is about, when the finding came from an issue tracker. Pass the issue whenever the report is about one, so the report links back to it: a GitHub issue signal for the same issue then joins this report instead of opening a second one. When the project turned on GitHub issue comments, the issue gets one comment that links the report once its GitHub source ingests the issue. At most 5 per call.'
            ),
        tags: zod
            .array(zod.string())
            .max(signalsReportsCreateBodyTagsMax)
            .optional()
            .describe(
                'Optional slug tags that group the report with related ones, at most 10. Write lowercase kebab-case slugs that name the category of the report (`cost-spike`, `tracking-gap`), not the specific entity. Reuse a slug the project already uses before you coin a new one. Near-miss formats are normalized to slugs, and a tag that is empty or longer than 50 characters after normalization is rejected.'
            ),
        idempotency_key: zod
            .string()
            .max(signalsReportsCreateBodyIdempotencyKeyMax)
            .nullish()
            .describe(
                "Optional name for this emission, unique within a scout's run or within a person's own reports. Reuse it verbatim to retry a call whose outcome you don't know (a timeout, a dropped connection): the retry returns the report the first call authored, with `idempotent_replay` true, instead of a second report. Omit it and the report's own content is the key, which covers a retry of the identical call — pass one when a retry might reword the report."
            ),
    })
    .describe(
        'Request body for the scout `emit-report` action and the inbox report `create` action. A scout run is\ntaken from the URL path; a person is the authenticated caller.'
    )

export const SignalsReportsRetrieveParams = () => zod.object({
    id: zod.string().describe('A UUID string identifying this signal report.'),
    project_id: zod
        .string()
        .describe(
            "Project ID of the project you're trying to access. To find the ID of the project, make a call to \/api\/projects\/."
        ),
})

/**
 * Edit the human-facing title and/or summary (description) of a signal report, addressed by id. Both fields are optional — supply only the ones you want to change; at least one is required. Every other report field (status, weights, judgments) is managed by the signals pipeline and cannot be set here. Returns the full updated report.
 * @summary Edit a report's title or summary
 */
export const SignalsReportsPartialUpdateParams = () => zod.object({
    id: zod.string().describe('A UUID string identifying this signal report.'),
    project_id: zod
        .string()
        .describe(
            "Project ID of the project you're trying to access. To find the ID of the project, make a call to \/api\/projects\/."
        ),
})

export const signalsReportsPartialUpdateBodyTitleMax = 300

export const signalsReportsPartialUpdateBodySummaryMax = 10000

export const SignalsReportsPartialUpdateBody = () => zod
    .object({
        title: zod
            .string()
            .min(1)
            .max(signalsReportsPartialUpdateBodyTitleMax)
            .optional()
            .describe('New human-facing title for the report. Omit to leave the title unchanged.'),
        summary: zod
            .string()
            .min(1)
            .max(signalsReportsPartialUpdateBodySummaryMax)
            .optional()
            .describe(
                "New summary (the report's description) explaining what the report is about. Omit to leave the summary unchanged."
            ),
    })
    .describe(
        'Editable human-facing fields on a signal report (PATCH).\n\nBoth fields are optional so a caller can change either independently, but at least one\nmust be supplied. Every other report field — status, weights, judgments — is owned by the\nsignals pipeline and is deliberately not writable here.'
    )

/**
 * List the actions on this report that start an agent run, read from the report's current state. `get_it_merged` is available only while the report has an open, approved pull request. `make_it_green` is available only while CI fails on the report's open pull request. `suggested_prompt` has one entry per prompt the report suggests. Start one with the run endpoint.
 * @summary List the report actions that start an agent run
 */
export const SignalsReportsActionsListParams = () => zod.object({
    id: zod.string().describe('A UUID string identifying this signal report.'),
    project_id: zod
        .string()
        .describe(
            "Project ID of the project you're trying to access. To find the ID of the project, make a call to \/api\/projects\/."
        ),
})

/**
 * Create a task linked to the report and start its first run in the background, with the instructions the inbox uses for the same action. `ask` sends your own message with the framing of the inbox's Ask AI. The run shows in the report's runs and counts toward the report's task limit. Nobody can answer questions in a background run, so the agent writes a note to the report's work log when it needs a decision.
 * @summary Start a report action as a background agent run
 */
export const SignalsReportsActionsRunCreateParams = () => zod.object({
    id: zod.string().describe('A UUID string identifying this signal report.'),
    project_id: zod
        .string()
        .describe(
            "Project ID of the project you're trying to access. To find the ID of the project, make a call to \/api\/projects\/."
        ),
})

export const signalsReportsActionsRunCreateBodySuggestedPromptIndexMin = 0

export const signalsReportsActionsRunCreateBodyMessageMax = 2000

export const SignalsReportsActionsRunCreateBody = () => zod.object({
    action: zod
        .enum(['get_it_merged', 'make_it_green', 'suggested_prompt', 'ask'])
        .describe(
            '\* `get_it_merged` - Get it merged\n\* `make_it_green` - Make it green\n\* `suggested_prompt` - Suggested prompt\n\* `ask` - Ask'
        )
        .describe(
            'The action to run. Use a value from the actions list, or `ask` to send your own `message`.\n\n\* `get_it_merged` - Get it merged\n\* `make_it_green` - Make it green\n\* `suggested_prompt` - Suggested prompt\n\* `ask` - Ask'
        ),
    suggested_prompt_index: zod
        .number()
        .min(signalsReportsActionsRunCreateBodySuggestedPromptIndexMin)
        .optional()
        .describe('Required for `suggested_prompt`: the `suggested_prompt_index` from the actions list.'),
    message: zod
        .string()
        .max(signalsReportsActionsRunCreateBodyMessageMax)
        .optional()
        .describe(
            "Your own request for the run. Required for `ask`, where it is the question or the work you want done on the report. Optional for `get_it_merged` and `make_it_green`, where it replaces the action's fixed request and keeps its instructions and gates: pass it when you know something the report does not, such as a merge order, a failure that is already on the base branch, or an expected conflict. Not accepted for `suggested_prompt`."
        ),
})

/**
 * Start or update work for the current user, internal task, or external agent. Supply claim_id to resume, pull_requests to add PRs, takeover=true to explicitly take ownership, or release=true to end ownership while preserving work history and PR links. Adding PRs needs task:write as well as inbox:write.
 * @summary Claim or release a signal report
 */
export const SignalsReportsClaimParams = () => zod.object({
    id: zod.string().describe('A UUID string identifying this signal report.'),
    project_id: zod
        .string()
        .describe(
            "Project ID of the project you're trying to access. To find the ID of the project, make a call to \/api\/projects\/."
        ),
})

export const signalsReportsClaimBodyPullRequestsItemMax = 2048

export const signalsReportsClaimBodyPullRequestsMax = 50

export const signalsReportsClaimBodyTakeoverDefault = false
export const signalsReportsClaimBodyReleaseDefault = false

export const SignalsReportsClaimBody = () => zod.object({
    claim_id: zod
        .string()
        .optional()
        .describe('Active claim ID returned by an earlier call. Stale claims are rejected.'),
    pull_requests: zod
        .array(zod.url().max(signalsReportsClaimBodyPullRequestsItemMax))
        .max(signalsReportsClaimBodyPullRequestsMax)
        .optional()
        .describe("GitHub PR URLs to add to this report's work. Additive and deduplicated; may span repositories."),
    takeover: zod
        .boolean()
        .default(signalsReportsClaimBodyTakeoverDefault)
        .describe("Explicitly end another actor's claim and take ownership."),
    takeover_claim_id: zod
        .string()
        .optional()
        .describe(
            'With takeover, the claim the caller expects to replace. The takeover is rejected when a different claim is active, so a takeover based on a stale read cannot replace a newer claim. Required to take over a claim that another person holds, directly or through their agent. That person is notified.'
        ),
    pr_url: zod
        .url()
        .optional()
        .describe('Compatibility alias for adding one PR. Prefer pull_requests for new callers.'),
    release: zod
        .boolean()
        .default(signalsReportsClaimBodyReleaseDefault)
        .describe('Release ownership while preserving any attached pull request.'),
})

/**
 * Record the thumbs rating at the end of a report, with an optional note. For browser-session requests the rating is persisted as a per-person report action, which counts as consumption evidence for the scout that authored the report (scouts whose output nobody consumes are eventually paused); requests authenticated any other way record no action. When a note is present and the report was authored by a scout, the note is also forwarded to that scout as a steering note it reads on its next run; for any other report there is nothing to steer. The report's state is never changed.
 * @summary Leave feedback on a report
 */
export const SignalsReportsFeedbackCreateParams = () => zod.object({
    id: zod.string().describe('A UUID string identifying this signal report.'),
    project_id: zod
        .string()
        .describe(
            "Project ID of the project you're trying to access. To find the ID of the project, make a call to \/api\/projects\/."
        ),
})

export const signalsReportsFeedbackCreateBodyNoteDefault = ``
export const signalsReportsFeedbackCreateBodyNoteMax = 4000

export const SignalsReportsFeedbackCreateBody = () => zod.object({
    sentiment: zod
        .union([
            zod.enum(['positive', 'negative']).describe('\* `positive` - positive\n\* `negative` - negative'),
            zod.null(),
        ])
        .describe(
            "The report rating: 'positive' (thumbs up), 'negative' (thumbs down), or null to clear it.\n\n\* `positive` - positive\n\* `negative` - negative"
        ),
    note: zod
        .string()
        .max(signalsReportsFeedbackCreateBodyNoteMax)
        .default(signalsReportsFeedbackCreateBodyNoteDefault)
        .describe(
            'Free-form note explaining the rating. Capped at 4000 characters. Optional — a bare thumb carries none. When present and the report was authored by a scout, the note is forwarded to that scout as a steering note.'
        ),
})

/**
 * Fold one or more duplicate reports into this report, which survives. The sources' signals, work-log artefacts, pull requests, task runs and checks move onto the survivor, the survivor's signal counters take on theirs, and each source is archived with a 'duplicate of' link back to the survivor. A source's open pull request stays open, because the survivor holds it after the move. Pick the survivor deliberately: prefer the older report, and prefer the one with an open implementation PR or an active claim. Any active claim on a source is released, so re-claim the survivor if you were working on one. Titles and summaries are not combined, so edit it afterwards if it needs a rewrite. A merged report keeps its URL but cannot be restored, because its signals now belong to the survivor.
 * @summary Merge duplicate reports into this one
 */
export const SignalsReportsMergeCreateParams = () => zod.object({
    id: zod.string().describe('A UUID string identifying this signal report.'),
    project_id: zod
        .string()
        .describe(
            "Project ID of the project you're trying to access. To find the ID of the project, make a call to \/api\/projects\/."
        ),
})

export const signalsReportsMergeCreateBodySourceReportIdsMax = 10

export const signalsReportsMergeCreateBodyReasonMax = 500

export const SignalsReportsMergeCreateBody = () => zod.object({
    source_report_ids: zod
        .array(zod.string())
        .min(1)
        .max(signalsReportsMergeCreateBodySourceReportIdsMax)
        .describe(
            "Ids of the duplicate reports to fold into this one (1–10). Each must be a live report in this project: a resolved, archived or deleted report is rejected with 409, as is the survivor's own id. Duplicates in the list are de-duplicated. The whole merge applies or none of it does."
        ),
    reason: zod
        .string()
        .max(signalsReportsMergeCreateBodyReasonMax)
        .optional()
        .describe(
            "Optional one-line explanation of why these reports are the same issue. Recorded on each source's 'duplicate of' link and on the note left on the survivor. Capped at 500 characters."
        ),
})

/**
 * Apply a human reviewer edit, including on reports without a reviewer artefact.
 * @summary Set a report's suggested reviewers
 */
export const SignalsReportsReviewersUpdateParams = () => zod.object({
    id: zod.string().describe('A UUID string identifying this signal report.'),
    project_id: zod
        .string()
        .describe(
            "Project ID of the project you're trying to access. To find the ID of the project, make a call to \/api\/projects\/."
        ),
})

export const signalsReportsReviewersUpdateBodyActionDefault = `replace`
export const signalsReportsReviewersUpdateBodyContentItemGithubLoginMax = 200

export const signalsReportsReviewersUpdateBodyContentItemGithubNameMax = 200

export const signalsReportsReviewersUpdateBodyContentItemReasonMax = 500

export const signalsReportsReviewersUpdateBodyContentMax = 10

export const signalsReportsReviewersUpdateBodyTargetsItemGithubLoginMax = 200

export const signalsReportsReviewersUpdateBodyTargetsItemGithubNameMax = 200

export const signalsReportsReviewersUpdateBodyTargetsItemReasonMax = 500

export const signalsReportsReviewersUpdateBodyTargetsMax = 10

export const signalsReportsReviewersUpdateBodyRemovalNoteMax = 500

export const SignalsReportsReviewersUpdateBody = () => zod.object({
    action: zod
        .enum(['add', 'remove', 'replace', 'confirm'])
        .describe('\* `add` - Add\n\* `remove` - Remove\n\* `replace` - Replace\n\* `confirm` - Confirm')
        .default(signalsReportsReviewersUpdateBodyActionDefault)
        .describe(
            'Add or remove only the supplied people, replace the list, or explicitly confirm it.\n\n\* `add` - Add\n\* `remove` - Remove\n\* `replace` - Replace\n\* `confirm` - Confirm'
        ),
    expected_reviewers: zod
        .object({
            reviewers_id: zod
                .string()
                .nullable()
                .describe('Current reviewer artefact ID, or null before the first list.'),
            corrections_id: zod
                .string()
                .nullable()
                .describe('Current corrections artefact ID, or null before corrections are stored.'),
        })
        .optional()
        .describe('State from the last read. Required for replacement and confirmation when corrections are enabled.'),
    content: zod
        .array(
            zod
                .object({
                    github_login: zod
                        .string()
                        .max(signalsReportsReviewersUpdateBodyContentItemGithubLoginMax)
                        .optional()
                        .describe(
                            'GitHub login (case-insensitive). Stored lowercased. Required unless `user_uuid` is given.'
                        ),
                    user_uuid: zod
                        .string()
                        .optional()
                        .describe(
                            "PostHog user UUID. Must be an org member on this team; a linked GitHub account is not required. Required unless `github_login` is given. If supplied together with `github_login`, the user's own identity wins."
                        ),
                    github_name: zod
                        .string()
                        .max(signalsReportsReviewersUpdateBodyContentItemGithubNameMax)
                        .optional()
                        .describe('Optional human-readable display name. Not backfilled from GitHub by the server.'),
                    reason: zod
                        .string()
                        .max(signalsReportsReviewersUpdateBodyContentItemReasonMax)
                        .nullish()
                        .describe(
                            'Optional short evidence for why this reviewer was chosen. Omitted entries keep the prior reason for reviewers already on the report.'
                        ),
                })
                .describe(
                    'Single entry in a PUT body for a `suggested_reviewers` artefact.\n\nEach entry must identify a reviewer by at least one of `github_login` or `user_uuid`. A\n`user_uuid` only has to name an org member on this team — a member with no linked GitHub\naccount is stored by uuid and routes like any other reviewer.'
                )
        )
        .max(signalsReportsReviewersUpdateBodyContentMax)
        .describe('People to add, remove, or keep in a replacement. Send an empty list for confirmation.'),
    targets: zod
        .array(
            zod
                .object({
                    github_login: zod
                        .string()
                        .max(signalsReportsReviewersUpdateBodyTargetsItemGithubLoginMax)
                        .optional()
                        .describe(
                            'GitHub login (case-insensitive). Stored lowercased. Required unless `user_uuid` is given.'
                        ),
                    user_uuid: zod
                        .string()
                        .optional()
                        .describe(
                            "PostHog user UUID. Must be an org member on this team; a linked GitHub account is not required. Required unless `github_login` is given. If supplied together with `github_login`, the user's own identity wins."
                        ),
                    github_name: zod
                        .string()
                        .max(signalsReportsReviewersUpdateBodyTargetsItemGithubNameMax)
                        .optional()
                        .describe('Optional human-readable display name. Not backfilled from GitHub by the server.'),
                    reason: zod
                        .string()
                        .max(signalsReportsReviewersUpdateBodyTargetsItemReasonMax)
                        .nullish()
                        .describe(
                            'Optional short evidence for why this reviewer was chosen. Omitted entries keep the prior reason for reviewers already on the report.'
                        ),
                })
                .describe(
                    'Single entry in a PUT body for a `suggested_reviewers` artefact.\n\nEach entry must identify a reviewer by at least one of `github_login` or `user_uuid`. A\n`user_uuid` only has to name an org member on this team — a member with no linked GitHub\naccount is stored by uuid and routes like any other reviewer.'
                )
        )
        .max(signalsReportsReviewersUpdateBodyTargetsMax)
        .optional()
        .describe('Explicit add or remove targets. When supplied, content is only a fallback for older servers.'),
    removal_reason: zod
        .enum(['wrong_area', 'already_covered', 'unavailable', 'other'])
        .describe(
            '\* `wrong_area` - Not their area\n\* `already_covered` - Someone else is on it\n\* `unavailable` - No bandwidth\n\* `other` - Other'
        )
        .optional()
        .describe(
            "Why the people in `targets` are removed. Remove action only. 'wrong_area': the work should not be on them, because it is outside their area, they moved off it, or someone else owns it. 'already_covered': another reviewer already covers the report. 'unavailable': they do not have bandwidth right now. The last two say nothing about ownership. 'other': explain in removal_note. Research and scouts read the reason when they pick reviewers for later reports.\n\n\* `wrong_area` - Not their area\n\* `already_covered` - Someone else is on it\n\* `unavailable` - No bandwidth\n\* `other` - Other"
        ),
    removal_note: zod
        .string()
        .max(signalsReportsReviewersUpdateBodyRemovalNoteMax)
        .optional()
        .describe(
            'Optional context for the removal, such as the area the person does not work on. Remove action only.'
        ),
})

/**
 * Take the calling user off this report's suggested reviewers, and record why. The other reviewers stay, and the report stays open. Succeeds whether or not the caller was on the list.
 * @summary Step off a report's suggested reviewers, with a reason
 */
export const SignalsReportsReviewersMeCreateParams = () => zod.object({
    id: zod.string().describe('A UUID string identifying this signal report.'),
    project_id: zod
        .string()
        .describe(
            "Project ID of the project you're trying to access. To find the ID of the project, make a call to \/api\/projects\/."
        ),
})

export const signalsReportsReviewersMeCreateBodyRemovalNoteMax = 500

export const SignalsReportsReviewersMeCreateBody = () => zod.object({
    removal_reason: zod
        .enum(['wrong_area', 'already_covered', 'unavailable', 'other'])
        .describe(
            '\* `wrong_area` - Not their area\n\* `already_covered` - Someone else is on it\n\* `unavailable` - No bandwidth\n\* `other` - Other'
        )
        .optional()
        .describe(
            "Why the user steps off. 'wrong_area': the work should not be on them, for example they moved off the area or left the team. 'already_covered': someone else is on it. 'unavailable': they do not have bandwidth right now. 'other': explain in removal_note. Research reads the reason when it picks reviewers for later reports.\n\n\* `wrong_area` - Not their area\n\* `already_covered` - Someone else is on it\n\* `unavailable` - No bandwidth\n\* `other` - Other"
        ),
    removal_note: zod
        .string()
        .max(signalsReportsReviewersMeCreateBodyRemovalNoteMax)
        .optional()
        .describe(
            'The user\'s own words for why, such as \"I\'m not on the payments team any more\". Scouts read it when they route later reports.'
        ),
})

/**
 * Transition a report to a new state. The model validates allowed transitions, except that a
 * verdict the report already holds (dismissing a suppressed report, resolving a resolved one)
 * is a 200 that records the dismissal feedback without touching the status.
 *
 * The request body is validated by SignalReportStateRequestSerializer — only the
 * fields it declares (state, dismissal_reason, dismissal_note, corrected_repository,
 * snooze_for) are read, and only snooze_for is ever forwarded to transition_to. Any
 * other key is ignored, so internal transition_to kwargs (reset_weight, error, ...)
 * can't be injected.
 *
 * Body: {
 *     "state": "suppressed" | "potential" | "resolved",
 *     # Optional dismissal feedback (honored when state == "suppressed", "potential", or "resolved"):
 *     "dismissal_reason": "<canonical reason code, see SIGNAL_REPORT_DISMISSAL_REASON_CHOICES>",
 *     "dismissal_note": "free-form text",
 *     # Optional, only allowed with dismissal_reason == "wrong_repo":
 *     "corrected_repository": "owner/repo the report should have targeted",
 *     # Optional, only honored for state == "potential":
 *     "snooze_for": <number of additional signals before re-promotion>,
 * }
 */
export const SignalsReportsStateCreateParams = () => zod.object({
    id: zod.string().describe('A UUID string identifying this signal report.'),
    project_id: zod
        .string()
        .describe(
            "Project ID of the project you're trying to access. To find the ID of the project, make a call to \/api\/projects\/."
        ),
})

export const signalsReportsStateCreateBodyDismissalNoteMax = 4000

export const signalsReportsStateCreateBodyCorrectedRepositoryMax = 140

export const signalsReportsStateCreateBodySnoozeForMax = 100000

export const SignalsReportsStateCreateBody = () => zod.object({
    state: zod
        .enum(['suppressed', 'potential', 'resolved', 'monitoring'])
        .describe(
            '\* `suppressed` - suppressed\n\* `potential` - potential\n\* `resolved` - resolved\n\* `monitoring` - monitoring'
        )
        .describe(
            "Target state for the report. Use 'suppressed' to dismiss the report from the inbox, 'potential' to snooze\/reopen it for later review, or 'resolved' when the report is finished. Resolving is allowed from ready, pending_input, failed, closed, or monitoring, or from a suppressed report that previously held one of those statuses or resolved. Resolving an already resolved report succeeds. Other statuses return 409 (skipped in bulk). Dismissing or resolving closes the report's open implementation PR, if it has one. Use 'monitoring' when implementation is complete and outcome verification is pending. Entry requires the organization rollout and snapshots this report's pending or active, unexpired checks. Without applicable checks the report resolves directly. Manual completion records caller attribution, stops remaining follow-up checks, and does not claim automatic verification or an evidence amendment.\n\n\* `suppressed` - suppressed\n\* `potential` - potential\n\* `resolved` - resolved\n\* `monitoring` - monitoring"
        ),
    dismissal_reason: zod
        .enum([
            'already_fixed',
            'report_unclear',
            'analysis_wrong',
            'wrong_assignee',
            'wrong_repo',
            'wontfix_intentional',
            'wontfix_irrelevant',
            'fixed_outside_posthog',
            'verified_manually',
            'no_action_needed',
            'pr_merged',
            'other',
        ])
        .describe(
            "\* `already_fixed` - Already fixed\n\* `report_unclear` - Report is unclear to me\n\* `analysis_wrong` - Agent's analysis is wrong\n\* `wrong_assignee` - Wrong assignee\n\* `wrong_repo` - Agent picked the wrong repository\n\* `wontfix_intentional` - Won't fix - intentional behavior\n\* `wontfix_irrelevant` - Not relevant to this project\n\* `fixed_outside_posthog` - Fixed outside PostHog\n\* `verified_manually` - Verified manually\n\* `no_action_needed` - No action needed\n\* `pr_merged` - PR was merged\n\* `other` - Something else…"
        )
        .optional()
        .describe(
            "Optional canonical reason code recorded with the transition. Must be one of: already_fixed, report_unclear, analysis_wrong, wrong_assignee, wrong_repo, wontfix_intentional, wontfix_irrelevant, fixed_outside_posthog, verified_manually, no_action_needed, pr_merged, other — these match the inbox UI so the rationale renders as a labelled chip rather than a raw code. When the work this report asked for is done, the honest transition is state='resolved' with 'fixed_outside_posthog' (the fix landed without a pull request), 'pr_merged' (a pull request with the fix was merged but did not resolve the report on its own), or 'already_fixed' (it was fixed before the report was filed). Use 'no_action_needed' with state='resolved' when the report was useful but needs no implementation. A report that failed in processing resolves too, so a fix that landed is recorded as a fix rather than as a dismissal. These three codes claim the issue is gone, so a later signal about the same issue starts a fresh report linked to this one. Fixed reason codes require state='suppressed' or state='resolved', not 'potential'. The dismissal codes (report_unclear, analysis_wrong, wrong_assignee, wontfix_\*) go with state='suppressed' and absorb later signals silently. 'wrong_assignee' is accepted from older clients, but a report sent to the wrong person still holds work: remove the person from the report's reviewers with a removal_reason instead of suppressing it. 'wrong_repo' when the agent picked the wrong repository for this report, ideally with corrected_repository naming the right one. The report stays suppressed, but a later matching signal starts a fresh linked report with a new repository selection informed by the project's correction feedback, even when no corrected_repository was supplied. Use 'verified_manually' with state='resolved' to stop Monitoring after manual verification. It requires Monitoring to be enabled and a report with a Monitoring period, and records no automatic verification result or evidence amendment. Use 'other' together with a dismissal_note for anything that doesn't fit a code.\n\n\* `already_fixed` - Already fixed\n\* `report_unclear` - Report is unclear to me\n\* `analysis_wrong` - Agent's analysis is wrong\n\* `wrong_assignee` - Wrong assignee\n\* `wrong_repo` - Agent picked the wrong repository\n\* `wontfix_intentional` - Won't fix - intentional behavior\n\* `wontfix_irrelevant` - Not relevant to this project\n\* `fixed_outside_posthog` - Fixed outside PostHog\n\* `verified_manually` - Verified manually\n\* `no_action_needed` - No action needed\n\* `pr_merged` - PR was merged\n\* `other` - Something else…"
        ),
    dismissal_note: zod
        .string()
        .max(signalsReportsStateCreateBodyDismissalNoteMax)
        .optional()
        .describe('Optional free-form note explaining the dismissal. Capped at 4000 characters.'),
    corrected_repository: zod
        .string()
        .min(1)
        .max(signalsReportsStateCreateBodyCorrectedRepositoryMax)
        .optional()
        .describe(
            "Optional, only allowed with dismissal_reason='wrong_repo'. The repository this report should have targeted, in 'owner\/repo' format (case-insensitive). It is recorded with the dismissal and fed into future repository selection for this project. When the repository is connected to the project, it also becomes the report's corrected repo selection, so restoring the report re-researches against it."
        ),
    snooze_for: zod
        .number()
        .min(1)
        .max(signalsReportsStateCreateBodySnoozeForMax)
        .optional()
        .describe(
            "Optional, only honored when state is 'potential'. Number of additional signals the report must accumulate before it is re-promoted into the pipeline — effectively snoozing it until then. Omit to let the report re-enter the pipeline on the next matching signal."
        ),
})

/**
 * List every artefact on a report — the full work log: signal findings (the evidence behind the report), status judgments (safety / actionability / priority, repo selection, suggested reviewers — the newest row of each status type is canonical), and log entries (code references, commits, task runs, notes). `suggested_reviewers` content is enriched with PostHog user info at read time. `ranking_score` content keeps only the head fields of each model's metadata; get the artefact by id for the full metadata.
 * @summary List a report's artefacts
 */
export const SignalsReportArtefactsListParams = () => zod.object({
    project_id: zod
        .string()
        .describe(
            "Project ID of the project you're trying to access. To find the ID of the project, make a call to \/api\/projects\/."
        ),
    report_id: zod
        .string()
        .describe(
            "UUID of the report whose artefacts you're addressing. This must be a report id (the report's own UUID), not a signal id such as `sig_praise` — a non-report id returns 404."
        ),
})

export const SignalsReportArtefactsListQueryParams = () => zod.object({
    limit: zod.number().optional().describe('Number of results to return per page.'),
    offset: zod.number().optional().describe('The initial index from which to return the results.'),
})

/**
 * Append an artefact to a report (see artefact_type for the writable types). Everything is append-only: log entries (code reference, commit, task run, note) accumulate, while status types (safety / actionability / priority judgments, repo selection, suggested reviewers, channel assignments) are latest-wins — appending a new version supersedes the previous one as the report's canonical status. Content is validated against the type's schema.
 * @summary Append an artefact to a report
 */
export const SignalsReportArtefactsCreateParams = () => zod.object({
    project_id: zod
        .string()
        .describe(
            "Project ID of the project you're trying to access. To find the ID of the project, make a call to \/api\/projects\/."
        ),
    report_id: zod
        .string()
        .describe(
            "UUID of the report whose artefacts you're addressing. This must be a report id (the report's own UUID), not a signal id such as `sig_praise` — a non-report id returns 404."
        ),
})

export const SignalsReportArtefactsCreateHeader = () => zod.object({
    'X-PostHog-Task-Id': zod
        .string()
        .optional()
        .describe(
            'Task to attribute the artefact to (must belong to this project). Set automatically for sandbox agents; when absent the artefact is attributed to the requesting user.'
        ),
})

export const signalsReportArtefactsCreateBodyReviewerRetryReasonMax = 500

export const SignalsReportArtefactsCreateBody = () => zod
    .object({
        expected_reviewers: zod
            .object({
                reviewers_id: zod
                    .string()
                    .nullable()
                    .describe('Current reviewer artefact ID, or null before the first list.'),
                corrections_id: zod
                    .string()
                    .nullable()
                    .describe('Current corrections artefact ID, or null before corrections are stored.'),
            })
            .optional()
            .describe(
                'Report reviewer_assignment.state read before selection began. Required when reviewer corrections are enabled.'
            ),
        reviewer_outcome: zod
            .enum(['selected', 'no_suitable_owner', 'lookup_failed'])
            .describe(
                '\* `selected` - Selected\n\* `no_suitable_owner` - No suitable owner\n\* `lookup_failed` - Lookup failed'
            )
            .optional()
            .describe(
                'A successful selection, a deliberate empty result, or an unavailable lookup. Defaults to selected when omitted.\n\n\* `selected` - Selected\n\* `no_suitable_owner` - No suitable owner\n\* `lookup_failed` - Lookup failed'
            ),
        reviewer_retry_reason: zod
            .string()
            .max(signalsReportArtefactsCreateBodyReviewerRetryReasonMax)
            .optional()
            .describe('Reason the reviewer lookup failed.'),
        claim_id: zod
            .string()
            .optional()
            .describe('Active claim to attribute this work to. Must belong to the caller and report.'),
        artefact_type: zod
            .string()
            .describe(
                "The artefact type. One of: actionability_judgment, channel_assignment, code_reference, commit, dismissal, note, priority_judgment, related_to, repo_selection, safety_judgment, signal_finding, source_suggestion, suggested_reviewers. Log types accumulate; status types (safety_judgment, actionability_judgment, priority_judgment, repo_selection, suggested_reviewers, channel_assignment, source_suggestion) are latest-wins — appending a new version supersedes the previous one as the report's canonical status."
            ),
        content: zod
            .unknown()
            .describe(
                'The artefact payload as a JSON object or array; shape depends on artefact_type and is validated against its schema.'
            ),
    })
    .describe(
        "Body for appending an artefact to a report.\n\nEverything is append-only: log artefacts accumulate, status artefacts supersede the previous\nversion (latest-wins). The `content` shape depends on `artefact_type` and is validated\nagainst the type's schema (see `products\/signals\/backend\/artefact_schemas.py`)."
    )

/**
 * Get one artefact by id, content parsed (and reviewers enriched) the same way as the list. A `ranking_score` keeps its full model metadata.
 * @summary Get a single artefact
 */
export const SignalsReportArtefactsRetrieveParams = () => zod.object({
    id: zod.string().describe('A UUID string identifying this signal report artefact.'),
    project_id: zod
        .string()
        .describe(
            "Project ID of the project you're trying to access. To find the ID of the project, make a call to \/api\/projects\/."
        ),
    report_id: zod
        .string()
        .describe(
            "UUID of the report whose artefacts you're addressing. This must be a report id (the report's own UUID), not a signal id such as `sig_praise` — a non-report id returns 404."
        ),
})

/**
 * Replace the content of an existing artefact, addressed by id. The new content is validated against the artefact's type schema. Editing the latest row of a status type changes the report's canonical status (latest-wins); to re-assess while keeping history, append a new artefact instead. Attribution is creation-time only — edits don't reassign it.
 * @summary Replace an artefact's content
 */
export const SignalsReportArtefactsPartialUpdateParams = () => zod.object({
    id: zod.string().describe('A UUID string identifying this signal report artefact.'),
    project_id: zod
        .string()
        .describe(
            "Project ID of the project you're trying to access. To find the ID of the project, make a call to \/api\/projects\/."
        ),
    report_id: zod
        .string()
        .describe(
            "UUID of the report whose artefacts you're addressing. This must be a report id (the report's own UUID), not a signal id such as `sig_praise` — a non-report id returns 404."
        ),
})

export const SignalsReportArtefactsPartialUpdateBody = () => zod
    .object({
        content: zod
            .unknown()
            .optional()
            .describe("The new artefact payload as a JSON object or array, matching the artefact type's schema."),
    })
    .describe(
        "Body for replacing the content of an existing artefact (addressed by id).\n\nPer-type schema validation happens in the view, which knows the artefact's type."
    )

/**
 * Delete an artefact, addressed by id. Deleting the latest row of a status type reverts the report's canonical status to the previous version (latest-wins over what remains). `task_run` artefacts are an append-only work log and cannot be deleted. Neither can the types this API cannot write, which the pipeline owns: `autostart_skip`, `check_authoring`, `check_cancelled`, `check_expired`, `check_observation`, `check_result`, `check_scheduled`, `code_review`, `impact_measurement_plan`, `implementation_decision`, `implementation_dispatch`, `implementation_handover`, `implementation_replacement`, `pr_owner_assignment`, `pull_request`, `ranking_score`, `report_link`, `reviewer_corrections`, `scout_note_left`, `source_issue`, `summary_change`, `task_run`, `title_change`, `video_segment`, `work_claim`, `work_release`.
 * @summary Delete an artefact
 */
export const SignalsReportArtefactsDestroyParams = () => zod.object({
    id: zod.string().describe('A UUID string identifying this signal report artefact.'),
    project_id: zod
        .string()
        .describe(
            "Project ID of the project you're trying to access. To find the ID of the project, make a call to \/api\/projects\/."
        ),
    report_id: zod
        .string()
        .describe(
            "UUID of the report whose artefacts you're addressing. This must be a report id (the report's own UUID), not a signal id such as `sig_praise` — a non-report id returns 404."
        ),
})

/**
 * List the forward-looking checks on a report. A check says what must stay true after the report was acted on, and the coordinator records each verdict as a `check_result` artefact on the report.
 * @summary List a report's checks
 */
export const SignalsReportChecksListParams = () => zod.object({
    project_id: zod
        .string()
        .describe(
            "Project ID of the project you're trying to access. To find the ID of the project, make a call to \/api\/projects\/."
        ),
    report_id: zod
        .string()
        .describe(
            "UUID of the report whose artefacts you're addressing. This must be a report id (the report's own UUID), not a signal id such as `sig_praise` — a non-report id returns 404."
        ),
})

export const SignalsReportChecksListQueryParams = () => zod.object({
    limit: zod.number().optional().describe('Number of results to return per page.'),
    offset: zod.number().optional().describe('The initial index from which to return the results.'),
})

/**
 * Checks attached to a signal report: read, approve, replace metrics, and cancel.
 *
 * There is no create here. A check is authored by a scout run or by the research pipeline, both
 * through `report_check_authoring.create_check`. An `agent` check puts its author's prose in front
 * of a privileged scout run, and `task:write` does not authorize that, so no caller-facing
 * endpoint accepts one. Anyone who can read the report can read its checks, and a person can
 * still stop one.
 *
 * There is no in-place update: a check is a claim about the future, and editing its threshold
 * after a result would make the recorded verdict unreadable. Replacing an open metric check
 * cancels the old row and creates a new one in one transaction.
 * @summary Get a single check
 */
export const SignalsReportChecksRetrieveParams = () => zod.object({
    id: zod.string().describe('A UUID string identifying this Signal report check.'),
    project_id: zod
        .string()
        .describe(
            "Project ID of the project you're trying to access. To find the ID of the project, make a call to \/api\/projects\/."
        ),
    report_id: zod
        .string()
        .describe(
            "UUID of the report whose artefacts you're addressing. This must be a report id (the report's own UUID), not a signal id such as `sig_praise` — a non-report id returns 404."
        ),
})

/**
 * Atomically replace an open agent or metric check with a metric check. The old check stays live if the new one is invalid.
 * @summary Replace a follow-up check with a metric
 */
export const SignalsReportChecksReplaceCreateParams = () => zod.object({
    id: zod.string().describe('A UUID string identifying this Signal report check.'),
    project_id: zod
        .string()
        .describe(
            "Project ID of the project you're trying to access. To find the ID of the project, make a call to \/api\/projects\/."
        ),
    report_id: zod.string(),
})

export const signalsReportChecksReplaceCreateBodyTitleMax = 200

export const signalsReportChecksReplaceCreateBodyRationaleMax = 2000

export const signalsReportChecksReplaceCreateBodyConfigOneMonitoringPurposeDefault = `expectation`
export const signalsReportChecksReplaceCreateBodyConfigOneMonitoringReferencePeriodMinutesExclusiveMin = 0
export const signalsReportChecksReplaceCreateBodyConfigOneMonitoringReferencePeriodMinutesMax = 527040

export const signalsReportChecksReplaceCreateBodyConfigOneMonitoringBaselinePeriodMinutesOneExclusiveMin = 0
export const signalsReportChecksReplaceCreateBodyConfigOneMonitoringBaselinePeriodMinutesOneMax = 527040

export const signalsReportChecksReplaceCreateBodyConfigOneUnitOneMax = 40

export const signalsReportChecksReplaceCreateBodySoakMinutesMin = 0
export const signalsReportChecksReplaceCreateBodySoakMinutesMax = 43200

export const signalsReportChecksReplaceCreateBodyRunIntervalMinutesMin = 360
export const signalsReportChecksReplaceCreateBodyRunIntervalMinutesMax = 129600

export const signalsReportChecksReplaceCreateBodyRunsRemainingMax = 1

export const SignalsReportChecksReplaceCreateBody = () => zod.object({
    title: zod.string().max(signalsReportChecksReplaceCreateBodyTitleMax).describe('Label for the new metric check.'),
    rationale: zod
        .string()
        .max(signalsReportChecksReplaceCreateBodyRationaleMax)
        .optional()
        .describe('Why this check is better.'),
    config: zod
        .object({
            metric_id: zod
                .union([zod.string(), zod.null()])
                .optional()
                .describe(
                    "Identifier of a metric on the report whose query this check measures. The metric's query is copied into `query` when the check is created."
                ),
            query: zod
                .union([zod.record(zod.string(), zod.unknown()), zod.null()])
                .optional()
                .describe(
                    'Live InsightVizNode wrapping one TrendsQuery: supplied by the caller, or copied from the named metric when the check is created. `dateRange.date_from` must be a relative window such as `-13d`, and `date_to` must be empty, so the check measures the days before each run rather than the days before it was written. The query must produce exactly one output series: use one event or action series, or combine up to ten of them with exactly one formula. Use no breakdown and no compare mode. A `trendsFilter.display` of `Metric` turns compare mode on, so `metricShowChange` is switched off for you unless `metricSummary` is `latest`, which keeps compare mode off already.'
                ),
            monitoring: zod
                .object({
                    purpose: zod
                        .enum(['expectation', 'minimum_evidence'])
                        .default(signalsReportChecksReplaceCreateBodyConfigOneMonitoringPurposeDefault)
                        .describe(
                            '`expectation` evaluates whether the implementation met its target. `minimum_evidence` checks a fixed minimum sample count: meeting it passes the guard; missing it is inconclusive and requires assessment, never an implementation failure. Use a positive whole-number `gte` target on one unsampled raw count.'
                        ),
                    reference_period_minutes: zod
                        .number()
                        .gt(signalsReportChecksReplaceCreateBodyConfigOneMonitoringReferencePeriodMinutesExclusiveMin)
                        .max(signalsReportChecksReplaceCreateBodyConfigOneMonitoringReferencePeriodMinutesMax)
                        .describe(
                            'The period the comparison target describes, in minutes. Independent of the soak and run schedule.'
                        ),
                    threshold_scaling: zod
                        .enum(['linear', 'fixed'])
                        .describe(
                            'How the target applies to a measurement from Monitoring start to the observation time. `linear` multiplies the target by elapsed minutes \/ reference_period_minutes and requires an additive event count or property sum. `fixed` keeps the target unchanged, including for rates and averages. This definition does not enable Monitoring execution.'
                        ),
                    baseline_period_minutes: zod
                        .union([
                            zod
                                .number()
                                .gt(
                                    signalsReportChecksReplaceCreateBodyConfigOneMonitoringBaselinePeriodMinutesOneExclusiveMin
                                )
                                .max(
                                    signalsReportChecksReplaceCreateBodyConfigOneMonitoringBaselinePeriodMinutesOneMax
                                ),
                            zod.null(),
                        ])
                        .optional()
                        .describe(
                            'The actual period measured by baseline_value, in minutes. Required when a baseline is supplied.'
                        ),
                })
                .describe(
                    'Monitoring definition for the replacement, including the target reference period and scaling policy.'
                ),
            comparison: zod
                .object({
                    operator: zod.enum(['lte', 'gte', 'between']).describe('`lte`, `gte`, or `between`.'),
                    value: zod
                        .union([zod.number(), zod.null()])
                        .optional()
                        .describe('The bound for `lte` and `gte`; unused by `between`.'),
                    bounds: zod
                        .union([
                            zod.object({
                                lower: zod.number(),
                                upper: zod.number(),
                            }),
                            zod.null(),
                        ])
                        .optional()
                        .describe('The inclusive range for `between`; unused by `lte` and `gte`.'),
                })
                .describe('What the measured value must satisfy to pass.'),
            baseline_value: zod
                .union([zod.number(), zod.null()])
                .optional()
                .describe('The value observed when the check was written, recorded on each result for context.'),
            metric_kind: zod
                .union([
                    zod.enum([
                        'affected_users',
                        'affected_sessions',
                        'occurrences',
                        'conversion_rate',
                        'error_rate',
                        'duration',
                        'revenue',
                        'custom',
                    ]),
                    zod.null(),
                ])
                .optional()
                .describe('How to draw this measurement; copied from a referenced metric.'),
            value_format: zod
                .union([
                    zod.enum(['number', 'count', 'percentage', 'percentage_scaled', 'duration', 'currency']),
                    zod.null(),
                ])
                .optional()
                .describe('How to format measured values; copied from a referenced metric.'),
            unit: zod
                .union([zod.string().max(signalsReportChecksReplaceCreateBodyConfigOneUnitOneMax), zod.null()])
                .optional()
                .describe('Optional value suffix.'),
        })
        .describe(
            'Metric threshold configuration, including a bounded query, comparison, and required Monitoring definition.'
        ),
    soak_minutes: zod
        .number()
        .min(signalsReportChecksReplaceCreateBodySoakMinutesMin)
        .max(signalsReportChecksReplaceCreateBodySoakMinutesMax)
        .optional()
        .describe(
            'Observation window in minutes from Monitoring start. Omission preserves the existing window, including zero. Replacing a check during Monitoring restarts the period for all open checks.'
        ),
    run_interval_minutes: zod
        .number()
        .min(signalsReportChecksReplaceCreateBodyRunIntervalMinutesMin)
        .max(signalsReportChecksReplaceCreateBodyRunIntervalMinutesMax)
        .optional()
        .describe(
            'Minutes between interim Monitoring measurements. Must be at least six hours and shorter than the observation window. Omit to use a quarter of the window, bounded to six hours through one day. Windows of six hours or less have no interim samples.'
        ),
    runs_remaining: zod
        .number()
        .min(1)
        .max(signalsReportChecksReplaceCreateBodyRunsRemainingMax)
        .optional()
        .describe(
            'Monitoring performs one terminal evaluation. Omit or set to 1; higher counts are not supported. Interim measurements do not consume this count.'
        ),
})

/**
 * Transition many reports to a new state in one call.
 *
 * Each id is processed independently: a report whose transition isn't allowed from its
 * current status is reported as `skipped` (a 409 on the single-report endpoint) and the
 * rest still go through. Returns one result per requested id (in request order, after
 * de-duplication) plus per-outcome counts. The whole call is 200 even on partial failure —
 * inspect `results` / the counts to see what happened.
 */
export const SignalsReportsBulkStateCreateParams = () => zod.object({
    project_id: zod
        .string()
        .describe(
            "Project ID of the project you're trying to access. To find the ID of the project, make a call to \/api\/projects\/."
        ),
})

export const signalsReportsBulkStateCreateBodyDismissalNoteMax = 4000

export const signalsReportsBulkStateCreateBodyCorrectedRepositoryMax = 140

export const signalsReportsBulkStateCreateBodySnoozeForMax = 100000

export const signalsReportsBulkStateCreateBodyIdsMax = 100

export const SignalsReportsBulkStateCreateBody = () => zod.object({
    state: zod
        .enum(['suppressed', 'potential', 'resolved', 'monitoring'])
        .describe(
            '\* `suppressed` - suppressed\n\* `potential` - potential\n\* `resolved` - resolved\n\* `monitoring` - monitoring'
        )
        .describe(
            "Target state for the report. Use 'suppressed' to dismiss the report from the inbox, 'potential' to snooze\/reopen it for later review, or 'resolved' when the report is finished. Resolving is allowed from ready, pending_input, failed, closed, or monitoring, or from a suppressed report that previously held one of those statuses or resolved. Resolving an already resolved report succeeds. Other statuses return 409 (skipped in bulk). Dismissing or resolving closes the report's open implementation PR, if it has one. Use 'monitoring' when implementation is complete and outcome verification is pending. Entry requires the organization rollout and snapshots this report's pending or active, unexpired checks. Without applicable checks the report resolves directly. Manual completion records caller attribution, stops remaining follow-up checks, and does not claim automatic verification or an evidence amendment.\n\n\* `suppressed` - suppressed\n\* `potential` - potential\n\* `resolved` - resolved\n\* `monitoring` - monitoring"
        ),
    dismissal_reason: zod
        .enum([
            'already_fixed',
            'report_unclear',
            'analysis_wrong',
            'wrong_assignee',
            'wrong_repo',
            'wontfix_intentional',
            'wontfix_irrelevant',
            'fixed_outside_posthog',
            'verified_manually',
            'no_action_needed',
            'pr_merged',
            'other',
        ])
        .describe(
            "\* `already_fixed` - Already fixed\n\* `report_unclear` - Report is unclear to me\n\* `analysis_wrong` - Agent's analysis is wrong\n\* `wrong_assignee` - Wrong assignee\n\* `wrong_repo` - Agent picked the wrong repository\n\* `wontfix_intentional` - Won't fix - intentional behavior\n\* `wontfix_irrelevant` - Not relevant to this project\n\* `fixed_outside_posthog` - Fixed outside PostHog\n\* `verified_manually` - Verified manually\n\* `no_action_needed` - No action needed\n\* `pr_merged` - PR was merged\n\* `other` - Something else…"
        )
        .optional()
        .describe(
            "Optional canonical reason code recorded with the transition. Must be one of: already_fixed, report_unclear, analysis_wrong, wrong_assignee, wrong_repo, wontfix_intentional, wontfix_irrelevant, fixed_outside_posthog, verified_manually, no_action_needed, pr_merged, other — these match the inbox UI so the rationale renders as a labelled chip rather than a raw code. When the work this report asked for is done, the honest transition is state='resolved' with 'fixed_outside_posthog' (the fix landed without a pull request), 'pr_merged' (a pull request with the fix was merged but did not resolve the report on its own), or 'already_fixed' (it was fixed before the report was filed). Use 'no_action_needed' with state='resolved' when the report was useful but needs no implementation. A report that failed in processing resolves too, so a fix that landed is recorded as a fix rather than as a dismissal. These three codes claim the issue is gone, so a later signal about the same issue starts a fresh report linked to this one. Fixed reason codes require state='suppressed' or state='resolved', not 'potential'. The dismissal codes (report_unclear, analysis_wrong, wrong_assignee, wontfix_\*) go with state='suppressed' and absorb later signals silently. 'wrong_assignee' is accepted from older clients, but a report sent to the wrong person still holds work: remove the person from the report's reviewers with a removal_reason instead of suppressing it. 'wrong_repo' when the agent picked the wrong repository for this report, ideally with corrected_repository naming the right one. The report stays suppressed, but a later matching signal starts a fresh linked report with a new repository selection informed by the project's correction feedback, even when no corrected_repository was supplied. Use 'verified_manually' with state='resolved' to stop Monitoring after manual verification. It requires Monitoring to be enabled and a report with a Monitoring period, and records no automatic verification result or evidence amendment. Use 'other' together with a dismissal_note for anything that doesn't fit a code.\n\n\* `already_fixed` - Already fixed\n\* `report_unclear` - Report is unclear to me\n\* `analysis_wrong` - Agent's analysis is wrong\n\* `wrong_assignee` - Wrong assignee\n\* `wrong_repo` - Agent picked the wrong repository\n\* `wontfix_intentional` - Won't fix - intentional behavior\n\* `wontfix_irrelevant` - Not relevant to this project\n\* `fixed_outside_posthog` - Fixed outside PostHog\n\* `verified_manually` - Verified manually\n\* `no_action_needed` - No action needed\n\* `pr_merged` - PR was merged\n\* `other` - Something else…"
        ),
    dismissal_note: zod
        .string()
        .max(signalsReportsBulkStateCreateBodyDismissalNoteMax)
        .optional()
        .describe('Optional free-form note explaining the dismissal. Capped at 4000 characters.'),
    corrected_repository: zod
        .string()
        .min(1)
        .max(signalsReportsBulkStateCreateBodyCorrectedRepositoryMax)
        .optional()
        .describe(
            "Optional, only allowed with dismissal_reason='wrong_repo'. The repository this report should have targeted, in 'owner\/repo' format (case-insensitive). It is recorded with the dismissal and fed into future repository selection for this project. When the repository is connected to the project, it also becomes the report's corrected repo selection, so restoring the report re-researches against it."
        ),
    snooze_for: zod
        .number()
        .min(1)
        .max(signalsReportsBulkStateCreateBodySnoozeForMax)
        .optional()
        .describe(
            "Optional, only honored when state is 'potential'. Number of additional signals the report must accumulate before it is re-promoted into the pipeline — effectively snoozing it until then. Omit to let the report re-enter the pipeline on the next matching signal."
        ),
    ids: zod
        .array(zod.string())
        .max(signalsReportsBulkStateCreateBodyIdsMax)
        .describe(
            'Report ids to transition to `state` in one call (1–100). Duplicates are de-duplicated; each id is processed independently so one disallowed transition does not block the rest. `dismissal_reason`, `dismissal_note`, `corrected_repository` and `snooze_for` apply to every id.'
        ),
})

/**
 * Your open inbox reports, ranked for you by one language model call over your activity summary, the reports that need you and the ranking model's predictions. Each entry has a reason and a compact report. The request never waits on the model. By default it returns the last stored list quickly, and `checked_at` says how current it is. Pass `max_age_minutes` to check an older list against every candidate report, which can take some seconds. `refresh`, `focus` and your first request start a background build and set `building: true`. With no stored list, the request returns your reports in inbox order with `fallback_reason: building`. Pass `wait_seconds` to wait a short time for the new list. Only the user the list is about can read it.
 * @summary Get your personal ranked inbox
 */
export const SignalsReportsForMeRetrieveParams = () => zod.object({
    project_id: zod
        .string()
        .describe(
            "Project ID of the project you're trying to access. To find the ID of the project, make a call to \/api\/projects\/."
        ),
})

export const signalsReportsForMeRetrieveQueryFocusMax = 2000

export const signalsReportsForMeRetrieveQueryLimitMax = 100

export const signalsReportsForMeRetrieveQueryMaxAgeMinutesMin = 0
export const signalsReportsForMeRetrieveQueryMaxAgeMinutesMax = 10080

export const signalsReportsForMeRetrieveQueryRefreshDefault = false
export const signalsReportsForMeRetrieveQueryWaitSecondsDefault = 0
export const signalsReportsForMeRetrieveQueryWaitSecondsMin = 0
export const signalsReportsForMeRetrieveQueryWaitSecondsMax = 30

export const SignalsReportsForMeRetrieveQueryParams = () => zod.object({
    focus: zod
        .string()
        .max(signalsReportsForMeRetrieveQueryFocusMax)
        .optional()
        .describe(
            'Free text about what to put first, such as `error tracking` or `billing reports`. A request with focus always starts a new build, and an unfocused request never reuses it. Pass `wait_seconds` to wait for it.'
        ),
    limit: zod
        .number()
        .min(1)
        .max(signalsReportsForMeRetrieveQueryLimitMax)
        .optional()
        .describe(
            'The most reports to return, best first. Defaults to 25. Values above the configured maximum (50) use the maximum.'
        ),
    max_age_minutes: zod
        .number()
        .min(signalsReportsForMeRetrieveQueryMaxAgeMinutesMin)
        .max(signalsReportsForMeRetrieveQueryMaxAgeMinutesMax)
        .optional()
        .describe(
            'The oldest `checked_at` you accept. When the stored list is older, the request reads every candidate report, which can take some seconds, and starts a build if your inbox changed. Leave it out to get the stored list quickly. A new report then joins the list at the next scheduled build.'
        ),
    refresh: zod
        .boolean()
        .default(signalsReportsForMeRetrieveQueryRefreshDefault)
        .describe(
            'Start a new build even when the stored one is current. The build runs in the background, so the response has `building: true`. Pass `wait_seconds` to wait for it.'
        ),
    wait_seconds: zod
        .number()
        .min(signalsReportsForMeRetrieveQueryWaitSecondsMin)
        .max(signalsReportsForMeRetrieveQueryWaitSecondsMax)
        .default(signalsReportsForMeRetrieveQueryWaitSecondsDefault)
        .describe(
            'When the request starts a build or one is running, wait for its list until this many seconds after the request started. Defaults to 0, which does not wait. A build usually takes 10 to 60 seconds.'
        ),
})

/**
 * What each public outcome of the served ranking model predicts, with its horizon, cohort, base rate and readability from the model that scored this project's reports. Users who cannot see the ranking model get status not_available and no outcomes.
 * @summary List the ranking model's public outcomes
 */
export const SignalsReportsRankingOutcomesListParams = () => zod.object({
    project_id: zod
        .string()
        .describe(
            "Project ID of the project you're trying to access. To find the ID of the project, make a call to \/api\/projects\/."
        ),
})

/**
 * List the standing instructions that keep you off automatic reviewer selection, active and revoked.
 * @summary List your reviewer exclusions
 */
export const SignalsReviewerExclusionsListParams = () => zod.object({
    project_id: zod
        .string()
        .describe(
            "Project ID of the project you're trying to access. To find the ID of the project, make a call to \/api\/projects\/."
        ),
})

/**
 * @summary Stay off automatic reviewer selection in an area
 */
export const SignalsReviewerExclusionsCreateParams = () => zod.object({
    project_id: zod
        .string()
        .describe(
            "Project ID of the project you're trying to access. To find the ID of the project, make a call to \/api\/projects\/."
        ),
})

export const signalsReviewerExclusionsCreateBodyRepositoryMax = 200

export const signalsReviewerExclusionsCreateBodyPathPrefixMax = 500

export const signalsReviewerExclusionsCreateBodyInstructionMax = 2000

export const SignalsReviewerExclusionsCreateBody = () => zod.object({
    repository: zod
        .string()
        .max(signalsReviewerExclusionsCreateBodyRepositoryMax)
        .optional()
        .describe('Repository in `owner\/name` form. Leave empty to cover every repository.'),
    path_prefix: zod
        .string()
        .max(signalsReviewerExclusionsCreateBodyPathPrefixMax)
        .optional()
        .describe('Path inside the repository, such as `src\/billing`. Needs a repository.'),
    instruction: zod
        .string()
        .max(signalsReviewerExclusionsCreateBodyInstructionMax)
        .describe('Why you stay off this area, for the people who read it later.'),
    report_id: zod
        .string()
        .optional()
        .describe(
            'Optional report to take you off first. The report removal and the instruction save are separate steps.'
        ),
})

/**
 * @summary Get one of your reviewer exclusions
 */
export const SignalsReviewerExclusionsRetrieveParams = () => zod.object({
    id: zod.string().describe('A UUID string identifying this signal reviewer exclusion.'),
    project_id: zod
        .string()
        .describe(
            "Project ID of the project you're trying to access. To find the ID of the project, make a call to \/api\/projects\/."
        ),
})

/**
 * @summary Change one of your reviewer exclusions
 */
export const SignalsReviewerExclusionsPartialUpdateParams = () => zod.object({
    id: zod.string().describe('A UUID string identifying this signal reviewer exclusion.'),
    project_id: zod
        .string()
        .describe(
            "Project ID of the project you're trying to access. To find the ID of the project, make a call to \/api\/projects\/."
        ),
})

export const signalsReviewerExclusionsPartialUpdateBodyRepositoryMax = 200

export const signalsReviewerExclusionsPartialUpdateBodyPathPrefixMax = 500

export const signalsReviewerExclusionsPartialUpdateBodyInstructionMax = 2000

export const SignalsReviewerExclusionsPartialUpdateBody = () => zod.object({
    repository: zod
        .string()
        .max(signalsReviewerExclusionsPartialUpdateBodyRepositoryMax)
        .optional()
        .describe('Repository in `owner\/name` form. Leave empty to cover every repository.'),
    path_prefix: zod
        .string()
        .max(signalsReviewerExclusionsPartialUpdateBodyPathPrefixMax)
        .optional()
        .describe('Path inside the repository, such as `src\/billing`. Needs a repository.'),
    instruction: zod
        .string()
        .max(signalsReviewerExclusionsPartialUpdateBodyInstructionMax)
        .optional()
        .describe('New text for the instruction.'),
})

/**
 * Make you eligible for automatic reviewer selection in this area again. Revoking does not add you to any report, and it does not change old reports.
 * @summary Revoke one of your reviewer exclusions
 */
export const SignalsReviewerExclusionsRevokeCreateParams = () => zod.object({
    id: zod.string().describe('A UUID string identifying this signal reviewer exclusion.'),
    project_id: zod
        .string()
        .describe(
            "Project ID of the project you're trying to access. To find the ID of the project, make a call to \/api\/projects\/."
        ),
})

/**
 * Create a scout skill and its runnable config atomically. Give it a `display_name` — the label people read, kept exactly as written — and the scout's permanent skill name is generated from it, with a numeric suffix when that name is taken, so two scouts may share a label without sharing an identity. Pass `name` instead to pick that identifier yourself; any valid skill name works, since the config row is what makes a skill a scout. The skill always receives the report-channel tools. The optional config controls schedule, enablement, dry-run posture, network access, and typed destinations such as Slack. Repeating the same definition is safe and applies any supplied config fields; reusing an explicit `name` for a different definition returns 409.
 * @summary Create a scout
 */
export const SignalsScoutCreateParams = () => zod.object({
    project_id: zod
        .string()
        .describe(
            "Project ID of the project you're trying to access. To find the ID of the project, make a call to \/api\/projects\/."
        ),
})

export const signalsScoutCreateBodyDisplayNameMax = 200

export const signalsScoutCreateBodyNameMax = 64

export const signalsScoutCreateBodyDescriptionMax = 1024

export const signalsScoutCreateBodyFilesItemPathMax = 500

export const signalsScoutCreateBodyFilesItemContentTypeDefault = `text/plain`
export const signalsScoutCreateBodyFilesItemContentTypeMax = 100

export const signalsScoutCreateBodyConfigOneModelMax = 200

export const signalsScoutCreateBodyConfigOneTagsMax = 10

export const signalsScoutCreateBodyConfigOneMcpGatewayServerIdsMax = 100

export const signalsScoutCreateBodyConfigOneRepositoriesItemMax = 255

export const signalsScoutCreateBodyConfigOneRepositoriesMax = 10

export const signalsScoutCreateBodyConfigOneWriteScopesMax = 15

export const signalsScoutCreateBodyConfigOnePrecheckQueryMax = 10000

export const signalsScoutCreateBodyConfigOneRunIntervalMinutesMin = 30
export const signalsScoutCreateBodyConfigOneRunIntervalMinutesMax = 43200

export const signalsScoutCreateBodyConfigOneOutputDestinationsOneSlackOneChannelMax = 255

export const signalsScoutCreateBodyConfigOneOutputDestinationsOneSlackOneUsersItemMax = 255

export const signalsScoutCreateBodyConfigOneOutputDestinationsOneSlackOneUsersItemRegExp = new RegExp(
    '^[UW][A-Z0-9]{4,}\\s\*(\\|.\*)?$'
)
export const signalsScoutCreateBodyConfigOneOutputDestinationsOneSlackOneUsersMax = 5

export const signalsScoutCreateBodyConfigOneOutputDestinationsOneSlackOneThreadReportsDefault = true
export const signalsScoutCreateBodyConfigOneRunCronScheduleMax = 100

export const SignalsScoutCreateBody = () => zod
    .object({
        display_name: zod
            .string()
            .max(signalsScoutCreateBodyDisplayNameMax)
            .optional()
            .describe(
                "Name shown wherever people identify this scout, written however you want it — spaces, capitalization, and acronyms are kept as typed, and two scouts may share one. It does not change the scout's skill name, which stays its identity, so renaming a scout keeps its schedule, run history, notes, memory, and links. At most 200 characters; blank means the scout has no name of its own and is labelled from its skill name instead."
            ),
        name: zod
            .string()
            .max(signalsScoutCreateBodyNameMax)
            .optional()
            .describe(
                'Optional skill name for the scout — its permanent identifier, containing only lowercase letters, numbers, and hyphens. Omit it and one is generated from `display_name` (`My APM scout` becomes `my-apm-scout`), with a numeric suffix when that name is taken. Pass it to pick the identifier yourself, or to keep a client written before display names working unchanged. The `signals-scout-` prefix is optional.'
            ),
        description: zod
            .string()
            .max(signalsScoutCreateBodyDescriptionMax)
            .describe('Short description of the signal or behavior this scout investigates.'),
        body: zod
            .string()
            .describe(
                'Complete markdown prompt executed on every scout run. Include any project-specific signal names, thresholds, investigation steps, and report criteria here.'
            ),
        files: zod
            .array(
                zod.object({
                    path: zod
                        .string()
                        .max(signalsScoutCreateBodyFilesItemPathMax)
                        .describe(
                            "File path relative to skill root, e.g. 'scripts\/setup.sh' or 'references\/guide.md'."
                        ),
                    content: zod.string().describe('Text content of the file.'),
                    content_type: zod
                        .string()
                        .max(signalsScoutCreateBodyFilesItemContentTypeMax)
                        .default(signalsScoutCreateBodyFilesItemContentTypeDefault)
                        .describe('MIME type of the file content.'),
                })
            )
            .optional()
            .describe('Optional reference files bundled with the scout prompt.'),
        config: zod
            .object({
                model: zod
                    .string()
                    .max(signalsScoutCreateBodyConfigOneModelMax)
                    .nullish()
                    .describe(
                        "Optional model id this scout's runs are pinned to, e.g. `claude-opus-4-5`. Must be one of the platform's agent models; an invalid id is rejected with the available ones listed. Null keeps the default model, chosen by the platform. Early access: the pin can only be set on projects enrolled in the scout model preview, and only takes effect there. Set null to clear it."
                    ),
                tags: zod
                    .array(zod.string())
                    .max(signalsScoutCreateBodyConfigOneTagsMax)
                    .optional()
                    .describe(
                        'Free-form labels for grouping the fleet, e.g. `[\"revenue\", \"on-call\"]`. Normalized to lowercase kebab-case (`On Call` and `on_call` both become `on-call`), deduped, and stored sorted; at most 10 tags, each at most 50 characters once normalized. Pass the full desired set — a write replaces the existing tags rather than merging into them. Filter the config list with the `tags` query parameter.'
                    ),
                structured_output_schema: zod
                    .record(zod.string(), zod.unknown())
                    .nullish()
                    .describe(
                        'Optional JSON Schema (draft 2020-12) describing ONE structured record this scout produces via `scout-record-output` — e.g. a per-report quality judgment (`{\"type\": \"object\", \"properties\": {\"verdict\": {\"enum\": [\"good\", \"bad\", \"unsure\"]}, \"reason\": {\"type\": \"string\"}}, \"required\": [\"verdict\", \"reason\"]}`). The root must be `\"type\": \"object\"`. Setting a schema turns the structured-output channel on: the run prompt renders the schema and every submitted record is validated against it and recorded in the project as a `$scout_structured_output` event, queryable like any event. The channel also requires emit — a dry-run scout has nowhere to record to. Cardinality is the scout\'s call (one record per run, one per judged entity, ...). Null = channel off. Setting a schema requires skill-authoring authorization (the `llm_skill:write` scope and skill editor access) since the scout reads it verbatim in its prompt; clearing it needs only the config write. Records validate against the schema in force when the run was dispatched.'
                    ),
                mcp_gateway_server_ids: zod
                    .array(zod.string())
                    .max(signalsScoutCreateBodyConfigOneMcpGatewayServerIdsMax)
                    .optional()
                    .describe(
                        "MCP gateway servers (by id) this scout's runs may use, chosen from the connections members shared to the whole team. Selection is per scout: an empty list gives the scout no MCP servers. Applies from the scout's next run."
                    ),
                repositories: zod
                    .array(zod.string().max(signalsScoutCreateBodyConfigOneRepositoriesItemMax))
                    .max(signalsScoutCreateBodyConfigOneRepositoriesMax)
                    .optional()
                    .describe(
                        "GitHub repositories this scout clones into its sandbox, each in `organization\/repo` format. Set them for a scout that reads code, so it can search the tree and run the project's own tests instead of reading files one API call at a time. Empty (the default) leaves the sandbox without a checkout. The scout's GitHub access stays read-only either way, so a repository listed here is never writable from a run. At most 10, each reachable through the project's GitHub connection. Applies from the scout's next run."
                    ),
                write_scopes: zod
                    .array(zod.string())
                    .max(signalsScoutCreateBodyConfigOneWriteScopesMax)
                    .optional()
                    .describe(
                        "Write access granted to this one scout, as scope strings. The grantable set is `alert:write`, `annotation:write`, `canvas:write`, `customer_task:write`, `dashboard:write`, `event_definition:write`, `experiment:write`, `hog_flow_proposal:write`, `insight:write`, `llm_skill:write`, `notebook:write`, `replay_scanner:write`, `ticket:write`, `warehouse_table:write`, `warehouse_view:write`. A new scout starts with `notebook:write` when this field is omitted. Empty means the scout reads the project and writes only its findings and its own memory. Each scope is project-wide and object-level, so a scout holding `dashboard:write` can update or delete any dashboard in the project, not only ones it made. `ticket:write` lets the scout update tickets, manage saved views, and add private notes. Scouts cannot send public replies, compose emails, change existing notes, or change customer identity fields. Ticket changes can start workflows that message customers. `event_definition:write` lets the scout change the tags on event definitions and nothing else. Grant only what this scout maintains. Only the person the scout's runs act as (whoever authored it) or a project admin can set it, and a scoped API key must itself carry each scope it grants. A dry run (`emit=false`) never holds the grant, and a run that acts as a project member other than the author holds only the default scopes. Applies from the scout's next run."
                    ),
                lifecycle_locked: zod
                    .boolean()
                    .optional()
                    .describe(
                        "Opt-in guard on this scout's lifecycle. Off by default, so anyone with scout write access may pause, resume, switch the scout to dry run, or delete it. On, only the person the scout's runs act as or a project admin may do any of those, or change this flag. Use it on a scout whose output people depend on: `signal_scout:write` is a project-wide scope held by people and by unattended agents alike, and a resume has to pass the project's enabled-scout maximum that a pause does not, so a bulk pause is not undone in one step. The lock never stops an automatic pause, such as the inactivity sweep or the repeated-failure breaker."
                    ),
                allowed_mcp_tools: zod
                    .array(zod.string())
                    .nullish()
                    .describe(
                        'Exact MCP tool names selected for this scout, excluding its built-in run context tools. Null means no tool restriction; an empty list selects no additional tools. Write access is derived from selected write tools. Clearing to null preserves the last write scopes. Send this field or tool_preset, never both. Requires the scouts-tool-access feature flag.'
                    ),
                tool_preset: zod
                    .enum(['read_only', 'support_notes'])
                    .describe('\* `read_only` - Read only\n\* `support_notes` - Support notes')
                    .optional()
                    .describe(
                        'Expand this named preset into a saved tool list. Later preset changes do not alter the saved list. Send this field or allowed_mcp_tools, never both. Requires the scouts-tool-access feature flag.\n\n\* `read_only` - Read only\n\* `support_notes` - Support notes'
                    ),
                precheck_query: zod
                    .string()
                    .max(signalsScoutCreateBodyConfigOnePrecheckQueryMax)
                    .nullish()
                    .describe(
                        "Optional HogQL `SELECT` a scheduled run evaluates before it starts. When it returns no rows, or one row with one false value (`false`, `0`, null or empty), the run is skipped: no sandbox, no model call, and no run row. Any other result starts the run, and the scout reads the rows. A query error also starts the run. Use `{since}` (the start of the last run that ran, or when the scout was created) and `{now}` to look only at what is new, e.g. `SELECT count() FROM events WHERE event = '$exception' AND timestamp > {since}`. To run at least once a week however quiet it is, add `OR {since} < {now} - INTERVAL 7 DAY` to the condition. Only scheduled runs evaluate it: a manual or workflow run always starts. `{interval_minutes}` is the gap between two scheduled runs, so a backstop can follow the schedule: `{since} < {now} - toIntervalMinute(greatest(1440, 2 \* {interval_minutes}))` runs at least daily and never more often than every two intervals. The query stops after 10 seconds and reads at most 50 rows. Try a query with `scout-config-precheck-test` before you save it. Null or blank uses the default pre-check the scout's skill ships, if any. To turn every pre-check off, set `precheck_disabled`."
                    ),
                enabled: zod
                    .boolean()
                    .optional()
                    .describe('Whether this scout runs on its schedule. Defaults to true.'),
                emit: zod
                    .boolean()
                    .optional()
                    .describe(
                        'Whether the scout writes findings to the inbox. False = dry-run: it runs and logs but emits nothing. Defaults to true.'
                    ),
                run_interval_minutes: zod
                    .number()
                    .min(signalsScoutCreateBodyConfigOneRunIntervalMinutesMin)
                    .max(signalsScoutCreateBodyConfigOneRunIntervalMinutesMax)
                    .optional()
                    .describe('Minutes between runs (30–43200). Defaults to 1440 (every 24 hours).'),
                output_destinations: zod
                    .object({
                        slack: zod
                            .union([
                                zod.object({
                                    integration_id: zod
                                        .number()
                                        .min(1)
                                        .describe(
                                            "ID of the Slack integration whose bot posts this scout's findings and reports."
                                        ),
                                    channel: zod
                                        .string()
                                        .max(signalsScoutCreateBodyConfigOneOutputDestinationsOneSlackOneChannelMax)
                                        .nullish()
                                        .describe(
                                            "Slack channel target in the channel picker's `channel_id|#channel-name` format. Null while choosing a channel; no messages are sent until a channel or user is set."
                                        ),
                                    users: zod
                                        .array(
                                            zod
                                                .string()
                                                .max(
                                                    signalsScoutCreateBodyConfigOneOutputDestinationsOneSlackOneUsersItemMax
                                                )
                                                .regex(
                                                    signalsScoutCreateBodyConfigOneOutputDestinationsOneSlackOneUsersItemRegExp
                                                )
                                        )
                                        .min(1)
                                        .max(signalsScoutCreateBodyConfigOneOutputDestinationsOneSlackOneUsersMax)
                                        .nullish()
                                        .describe(
                                            'Slack members to send output to as direct messages, each in `member_id|@display-name` format (a bare member ID like `U0123ABC456` also works). Each member gets their own DM from the PostHog app; at most 5. Set either this or `channel`, not both. Useful for personal scouts where a DM beats a channel.'
                                        ),
                                    thread_reports: zod
                                        .boolean()
                                        .default(
                                            signalsScoutCreateBodyConfigOneOutputDestinationsOneSlackOneThreadReportsDefault
                                        )
                                        .describe(
                                            "When true, post a report as a thread: a short lead in the channel and the rest split into replies at the summary's section labels, which can be Markdown headings or bold labels. Keeps a long summary from being clipped at Slack's section limit. On by default; set it false to post a single message, which can truncate a long summary. It does not change how findings post."
                                        ),
                                }),
                                zod.null(),
                            ])
                            .optional()
                            .describe(
                                'Slack destination for each emitted scout finding or report. Null or omitted disables Slack delivery.'
                            ),
                        webhook: zod
                            .union([
                                zod.object({
                                    hog_function_id: zod
                                        .string()
                                        .describe(
                                            "Id of the CDP destination delivering this scout's reports. Set by the product that provisioned it, so it can find that destination again to update or remove it."
                                        ),
                                }),
                                zod.null(),
                            ])
                            .optional()
                            .describe(
                                "The CDP destination another product provisioned for this scout's reports. Null or omitted means no webhook. Unlike Slack, Signals does not deliver this itself: the reference lives here so the owning product can manage the destination's lifecycle."
                            ),
                        inbox: zod
                            .boolean()
                            .optional()
                            .describe(
                                "Whether this scout's reports appear in the shared inbox. Defaults to true. Set false to keep the reports this scout authors out of the inbox and its Slack notifications, for example for a digest scout read in Slack. Reports this scout only edits are not affected. An update that omits this key keeps the stored value."
                            ),
                    })
                    .optional()
                    .describe('Destinations that receive each finding or report this scout emits. Empty by default.'),
                network_access: zod
                    .enum(['trusted', 'full'])
                    .describe('\* `trusted` - Trusted domains only\n\* `full` - Full')
                    .optional()
                    .describe(
                        "What the scout's sandbox can reach over the network while it runs. Defaults to `trusted`, the platform's trusted-domain allowlist (PostHog, GitHub, common package registries). Set `full` to let this scout reach any site, for skills that read external sources such as documentation or papers.\n\n\* `trusted` - Trusted domains only\n\* `full` - Full"
                    ),
                auto_pause_exempt: zod
                    .boolean()
                    .optional()
                    .describe(
                        'Exempt this scout from the inactivity pause, which otherwise switches off a scout that goes a fortnight without surfacing anything anyone engages with. Set it on watchdog scouts whose value is staying quiet. Defaults to false.'
                    ),
                run_cron_schedule: zod
                    .string()
                    .max(signalsScoutCreateBodyConfigOneRunCronScheduleMax)
                    .nullish()
                    .describe(
                        "Optional five-field cron expression, e.g. '30 9 \* \* \*' (daily at 09:30), '0 9,17 \* \* \*' (twice daily), or '0 9 \* \* 1-5' (weekday mornings). Evaluated in the project timezone. Takes precedence over `run_interval_minutes`; occurrences must be at least 30 minutes apart."
                    ),
            })
            .describe('Schedule, enablement, and delivery options accepted while creating a scout.')
            .optional()
            .describe(
                'Optional schedule, enablement, dry-run posture, and delivery settings. Defaults to an enabled, emitting scout on the daily interval with no external destination.'
            ),
    })
    .describe('Create a runnable custom scout and its config in one atomic request.')

/**
 * List the per-(team, skill) scout configs for this project. Each row includes its `display_name` (the label people read), its `skill_name` (the permanent identifier), its schedule (rolling `run_interval_minutes`, or a project-local `run_cron_schedule` when set), `enabled`, `emit` posture, and `tags`. A freshly authored scout skill appears here once its config is registered, either explicitly via create or by the coordinator's next tick. Pass `tags` to narrow the fleet to the scouts carrying at least one of the given labels, and `search` to narrow it to the scouts matching a substring of either name.
 * @summary List scout configs
 */
export const SignalsScoutConfigListParams = () => zod.object({
    project_id: zod
        .string()
        .describe(
            "Project ID of the project you're trying to access. To find the ID of the project, make a call to \/api\/projects\/."
        ),
})

export const SignalsScoutConfigListQueryParams = () => zod.object({
    search: zod
        .string()
        .min(1)
        .optional()
        .describe(
            "Case-insensitive substring filter over a scout's display name and its skill name. A scout matches on either, so a person who knows the label and a caller who knows the identifier both find it. Omit for the whole fleet."
        ),
    tags: zod
        .string()
        .min(1)
        .optional()
        .describe(
            'Comma-separated tags, e.g. `revenue,on-call`. Returns the scouts carrying at least one of them. Values are normalized the same way stored tags are, so `On Call` matches `on-call`. Omit for the whole fleet.'
        ),
})

/**
 * Register the config for a skill immediately, without waiting for the coordinator to auto-register it — and the way to make a skill without the `signals-scout-` prefix a scout at all. The same call can optionally set `run_interval_minutes`, a cron `run_cron_schedule`, `enabled`, `emit`, `network_access`, and output destinations. The skill must already exist on this project. Upsert: if a config already exists for the skill, the provided fields are applied to it. Registering puts the skill's body on the schedule as the scout's prompt, so this call needs `llm_skill:write` and editor access to skills on top of `signal_scout:write`, like creating a scout.
 * @summary Create a scout config
 */
export const SignalsScoutConfigCreateParams = () => zod.object({
    project_id: zod
        .string()
        .describe(
            "Project ID of the project you're trying to access. To find the ID of the project, make a call to \/api\/projects\/."
        ),
})

export const signalsScoutConfigCreateBodyModelMax = 200

export const signalsScoutConfigCreateBodyTagsMax = 10

export const signalsScoutConfigCreateBodyMcpGatewayServerIdsMax = 100

export const signalsScoutConfigCreateBodyRepositoriesItemMax = 255

export const signalsScoutConfigCreateBodyRepositoriesMax = 10

export const signalsScoutConfigCreateBodyWriteScopesMax = 15

export const signalsScoutConfigCreateBodyPrecheckQueryMax = 10000

export const signalsScoutConfigCreateBodyRunIntervalMinutesMin = 30
export const signalsScoutConfigCreateBodyRunIntervalMinutesMax = 43200

export const signalsScoutConfigCreateBodyOutputDestinationsOneSlackOneChannelMax = 255

export const signalsScoutConfigCreateBodyOutputDestinationsOneSlackOneUsersItemMax = 255

export const signalsScoutConfigCreateBodyOutputDestinationsOneSlackOneUsersItemRegExp = new RegExp(
    '^[UW][A-Z0-9]{4,}\\s\*(\\|.\*)?$'
)
export const signalsScoutConfigCreateBodyOutputDestinationsOneSlackOneUsersMax = 5

export const signalsScoutConfigCreateBodyOutputDestinationsOneSlackOneThreadReportsDefault = true
export const signalsScoutConfigCreateBodyRunCronScheduleMax = 100

export const signalsScoutConfigCreateBodyDisplayNameMax = 200

export const signalsScoutConfigCreateBodySkillNameMax = 200

export const SignalsScoutConfigCreateBody = () => zod
    .object({
        model: zod
            .string()
            .max(signalsScoutConfigCreateBodyModelMax)
            .nullish()
            .describe(
                "Optional model id this scout's runs are pinned to, e.g. `claude-opus-4-5`. Must be one of the platform's agent models; an invalid id is rejected with the available ones listed. Null keeps the default model, chosen by the platform. Early access: the pin can only be set on projects enrolled in the scout model preview, and only takes effect there. Set null to clear it."
            ),
        tags: zod
            .array(zod.string())
            .max(signalsScoutConfigCreateBodyTagsMax)
            .optional()
            .describe(
                'Free-form labels for grouping the fleet, e.g. `[\"revenue\", \"on-call\"]`. Normalized to lowercase kebab-case (`On Call` and `on_call` both become `on-call`), deduped, and stored sorted; at most 10 tags, each at most 50 characters once normalized. Pass the full desired set — a write replaces the existing tags rather than merging into them. Filter the config list with the `tags` query parameter.'
            ),
        structured_output_schema: zod
            .record(zod.string(), zod.unknown())
            .nullish()
            .describe(
                'Optional JSON Schema (draft 2020-12) describing ONE structured record this scout produces via `scout-record-output` — e.g. a per-report quality judgment (`{\"type\": \"object\", \"properties\": {\"verdict\": {\"enum\": [\"good\", \"bad\", \"unsure\"]}, \"reason\": {\"type\": \"string\"}}, \"required\": [\"verdict\", \"reason\"]}`). The root must be `\"type\": \"object\"`. Setting a schema turns the structured-output channel on: the run prompt renders the schema and every submitted record is validated against it and recorded in the project as a `$scout_structured_output` event, queryable like any event. The channel also requires emit — a dry-run scout has nowhere to record to. Cardinality is the scout\'s call (one record per run, one per judged entity, ...). Null = channel off. Setting a schema requires skill-authoring authorization (the `llm_skill:write` scope and skill editor access) since the scout reads it verbatim in its prompt; clearing it needs only the config write. Records validate against the schema in force when the run was dispatched.'
            ),
        mcp_gateway_server_ids: zod
            .array(zod.string())
            .max(signalsScoutConfigCreateBodyMcpGatewayServerIdsMax)
            .optional()
            .describe(
                "MCP gateway servers (by id) this scout's runs may use, chosen from the connections members shared to the whole team. Selection is per scout: an empty list gives the scout no MCP servers. Applies from the scout's next run."
            ),
        repositories: zod
            .array(zod.string().max(signalsScoutConfigCreateBodyRepositoriesItemMax))
            .max(signalsScoutConfigCreateBodyRepositoriesMax)
            .optional()
            .describe(
                "GitHub repositories this scout clones into its sandbox, each in `organization\/repo` format. Set them for a scout that reads code, so it can search the tree and run the project's own tests instead of reading files one API call at a time. Empty (the default) leaves the sandbox without a checkout. The scout's GitHub access stays read-only either way, so a repository listed here is never writable from a run. At most 10, each reachable through the project's GitHub connection. Applies from the scout's next run."
            ),
        write_scopes: zod
            .array(zod.string())
            .max(signalsScoutConfigCreateBodyWriteScopesMax)
            .optional()
            .describe(
                "Write access granted to this one scout, as scope strings. The grantable set is `alert:write`, `annotation:write`, `canvas:write`, `customer_task:write`, `dashboard:write`, `event_definition:write`, `experiment:write`, `hog_flow_proposal:write`, `insight:write`, `llm_skill:write`, `notebook:write`, `replay_scanner:write`, `ticket:write`, `warehouse_table:write`, `warehouse_view:write`. A new scout starts with `notebook:write` when this field is omitted. Empty means the scout reads the project and writes only its findings and its own memory. Each scope is project-wide and object-level, so a scout holding `dashboard:write` can update or delete any dashboard in the project, not only ones it made. `ticket:write` lets the scout update tickets, manage saved views, and add private notes. Scouts cannot send public replies, compose emails, change existing notes, or change customer identity fields. Ticket changes can start workflows that message customers. `event_definition:write` lets the scout change the tags on event definitions and nothing else. Grant only what this scout maintains. Only the person the scout's runs act as (whoever authored it) or a project admin can set it, and a scoped API key must itself carry each scope it grants. A dry run (`emit=false`) never holds the grant, and a run that acts as a project member other than the author holds only the default scopes. Applies from the scout's next run."
            ),
        lifecycle_locked: zod
            .boolean()
            .optional()
            .describe(
                "Opt-in guard on this scout's lifecycle. Off by default, so anyone with scout write access may pause, resume, switch the scout to dry run, or delete it. On, only the person the scout's runs act as or a project admin may do any of those, or change this flag. Use it on a scout whose output people depend on: `signal_scout:write` is a project-wide scope held by people and by unattended agents alike, and a resume has to pass the project's enabled-scout maximum that a pause does not, so a bulk pause is not undone in one step. The lock never stops an automatic pause, such as the inactivity sweep or the repeated-failure breaker."
            ),
        allowed_mcp_tools: zod
            .array(zod.string())
            .nullish()
            .describe(
                'Exact MCP tool names selected for this scout, excluding its built-in run context tools. Null means no tool restriction; an empty list selects no additional tools. Write access is derived from selected write tools. Clearing to null preserves the last write scopes. Send this field or tool_preset, never both. Requires the scouts-tool-access feature flag.'
            ),
        tool_preset: zod
            .enum(['read_only', 'support_notes'])
            .describe('\* `read_only` - Read only\n\* `support_notes` - Support notes')
            .optional()
            .describe(
                'Expand this named preset into a saved tool list. Later preset changes do not alter the saved list. Send this field or allowed_mcp_tools, never both. Requires the scouts-tool-access feature flag.\n\n\* `read_only` - Read only\n\* `support_notes` - Support notes'
            ),
        precheck_query: zod
            .string()
            .max(signalsScoutConfigCreateBodyPrecheckQueryMax)
            .nullish()
            .describe(
                "Optional HogQL `SELECT` a scheduled run evaluates before it starts. When it returns no rows, or one row with one false value (`false`, `0`, null or empty), the run is skipped: no sandbox, no model call, and no run row. Any other result starts the run, and the scout reads the rows. A query error also starts the run. Use `{since}` (the start of the last run that ran, or when the scout was created) and `{now}` to look only at what is new, e.g. `SELECT count() FROM events WHERE event = '$exception' AND timestamp > {since}`. To run at least once a week however quiet it is, add `OR {since} < {now} - INTERVAL 7 DAY` to the condition. Only scheduled runs evaluate it: a manual or workflow run always starts. `{interval_minutes}` is the gap between two scheduled runs, so a backstop can follow the schedule: `{since} < {now} - toIntervalMinute(greatest(1440, 2 \* {interval_minutes}))` runs at least daily and never more often than every two intervals. The query stops after 10 seconds and reads at most 50 rows. Try a query with `scout-config-precheck-test` before you save it. Null or blank uses the default pre-check the scout's skill ships, if any. To turn every pre-check off, set `precheck_disabled`."
            ),
        enabled: zod.boolean().optional().describe('Whether this scout runs on its schedule. Defaults to true.'),
        emit: zod
            .boolean()
            .optional()
            .describe(
                'Whether the scout writes findings to the inbox. False = dry-run: it runs and logs but emits nothing. Defaults to true.'
            ),
        run_interval_minutes: zod
            .number()
            .min(signalsScoutConfigCreateBodyRunIntervalMinutesMin)
            .max(signalsScoutConfigCreateBodyRunIntervalMinutesMax)
            .optional()
            .describe('Minutes between runs (30–43200). Defaults to 1440 (every 24 hours).'),
        output_destinations: zod
            .object({
                slack: zod
                    .union([
                        zod.object({
                            integration_id: zod
                                .number()
                                .min(1)
                                .describe(
                                    "ID of the Slack integration whose bot posts this scout's findings and reports."
                                ),
                            channel: zod
                                .string()
                                .max(signalsScoutConfigCreateBodyOutputDestinationsOneSlackOneChannelMax)
                                .nullish()
                                .describe(
                                    "Slack channel target in the channel picker's `channel_id|#channel-name` format. Null while choosing a channel; no messages are sent until a channel or user is set."
                                ),
                            users: zod
                                .array(
                                    zod
                                        .string()
                                        .max(signalsScoutConfigCreateBodyOutputDestinationsOneSlackOneUsersItemMax)
                                        .regex(signalsScoutConfigCreateBodyOutputDestinationsOneSlackOneUsersItemRegExp)
                                )
                                .min(1)
                                .max(signalsScoutConfigCreateBodyOutputDestinationsOneSlackOneUsersMax)
                                .nullish()
                                .describe(
                                    'Slack members to send output to as direct messages, each in `member_id|@display-name` format (a bare member ID like `U0123ABC456` also works). Each member gets their own DM from the PostHog app; at most 5. Set either this or `channel`, not both. Useful for personal scouts where a DM beats a channel.'
                                ),
                            thread_reports: zod
                                .boolean()
                                .default(signalsScoutConfigCreateBodyOutputDestinationsOneSlackOneThreadReportsDefault)
                                .describe(
                                    "When true, post a report as a thread: a short lead in the channel and the rest split into replies at the summary's section labels, which can be Markdown headings or bold labels. Keeps a long summary from being clipped at Slack's section limit. On by default; set it false to post a single message, which can truncate a long summary. It does not change how findings post."
                                ),
                        }),
                        zod.null(),
                    ])
                    .optional()
                    .describe(
                        'Slack destination for each emitted scout finding or report. Null or omitted disables Slack delivery.'
                    ),
                webhook: zod
                    .union([
                        zod.object({
                            hog_function_id: zod
                                .string()
                                .describe(
                                    "Id of the CDP destination delivering this scout's reports. Set by the product that provisioned it, so it can find that destination again to update or remove it."
                                ),
                        }),
                        zod.null(),
                    ])
                    .optional()
                    .describe(
                        "The CDP destination another product provisioned for this scout's reports. Null or omitted means no webhook. Unlike Slack, Signals does not deliver this itself: the reference lives here so the owning product can manage the destination's lifecycle."
                    ),
                inbox: zod
                    .boolean()
                    .optional()
                    .describe(
                        "Whether this scout's reports appear in the shared inbox. Defaults to true. Set false to keep the reports this scout authors out of the inbox and its Slack notifications, for example for a digest scout read in Slack. Reports this scout only edits are not affected. An update that omits this key keeps the stored value."
                    ),
            })
            .optional()
            .describe('Destinations that receive each finding or report this scout emits. Empty by default.'),
        network_access: zod
            .enum(['trusted', 'full'])
            .describe('\* `trusted` - Trusted domains only\n\* `full` - Full')
            .optional()
            .describe(
                "What the scout's sandbox can reach over the network while it runs. Defaults to `trusted`, the platform's trusted-domain allowlist (PostHog, GitHub, common package registries). Set `full` to let this scout reach any site, for skills that read external sources such as documentation or papers.\n\n\* `trusted` - Trusted domains only\n\* `full` - Full"
            ),
        auto_pause_exempt: zod
            .boolean()
            .optional()
            .describe(
                'Exempt this scout from the inactivity pause, which otherwise switches off a scout that goes a fortnight without surfacing anything anyone engages with. Set it on watchdog scouts whose value is staying quiet. Defaults to false.'
            ),
        run_cron_schedule: zod
            .string()
            .max(signalsScoutConfigCreateBodyRunCronScheduleMax)
            .nullish()
            .describe(
                "Optional five-field cron expression, e.g. '30 9 \* \* \*' (daily at 09:30), '0 9,17 \* \* \*' (twice daily), or '0 9 \* \* 1-5' (weekday mornings). Evaluated in the project timezone. Takes precedence over `run_interval_minutes`; occurrences must be at least 30 minutes apart."
            ),
        display_name: zod
            .string()
            .max(signalsScoutConfigCreateBodyDisplayNameMax)
            .optional()
            .describe(
                "Name shown wherever people identify this scout, written however you want it — spaces, capitalization, and acronyms are kept as typed, and two scouts may share one. It does not change the scout's skill name, which stays its identity, so renaming a scout keeps its schedule, run history, notes, memory, and links. At most 200 characters; blank means the scout has no name of its own and is labelled from its skill name instead."
            ),
        skill_name: zod
            .string()
            .max(signalsScoutConfigCreateBodySkillNameMax)
            .describe(
                'The skill to register a config for. Any valid skill name works — the config row is what makes a skill a scout. The skill must already exist on this project — author it via the skills store first.'
            ),
    })
    .describe(
        'Request body for registering a scout config without waiting for the coordinator tick.\n\nUpsert keyed on `skill_name`: if the coordinator (or a concurrent caller) already\nregistered the row, the provided tunables are applied to it instead.'
    )

/**
 * Tune one scout: change its schedule (rolling `run_interval_minutes`, or a cron `run_cron_schedule` that takes precedence when set), `enabled`, `emit` (dry-run) posture, `network_access` (trusted-domain allowlist vs full access for the scout's sandbox), or output destinations. `skill_name` is fixed. Enabling records `enabled_by` and is activity-logged since it drives spend.
 * @summary Update a scout config
 */
export const SignalsScoutConfigUpdateParams = () => zod.object({
    id: zod.string().describe('A UUID string identifying this Signal scout config.'),
    project_id: zod
        .string()
        .describe(
            "Project ID of the project you're trying to access. To find the ID of the project, make a call to \/api\/projects\/."
        ),
})

export const signalsScoutConfigUpdateBodyDisplayNameMax = 200

export const signalsScoutConfigUpdateBodyRunIntervalMinutesMin = 30
export const signalsScoutConfigUpdateBodyRunIntervalMinutesMax = 43200

export const signalsScoutConfigUpdateBodyRunCronScheduleMax = 100

export const signalsScoutConfigUpdateBodyOutputDestinationsOneSlackOneChannelMax = 255

export const signalsScoutConfigUpdateBodyOutputDestinationsOneSlackOneUsersItemMax = 255

export const signalsScoutConfigUpdateBodyOutputDestinationsOneSlackOneUsersItemRegExp = new RegExp(
    '^[UW][A-Z0-9]{4,}\\s\*(\\|.\*)?$'
)
export const signalsScoutConfigUpdateBodyOutputDestinationsOneSlackOneUsersMax = 5

export const signalsScoutConfigUpdateBodyModelMax = 200

export const signalsScoutConfigUpdateBodyTagsMax = 10

export const signalsScoutConfigUpdateBodyMcpGatewayServerIdsMax = 100

export const signalsScoutConfigUpdateBodyRepositoriesItemMax = 255

export const signalsScoutConfigUpdateBodyRepositoriesMax = 10

export const signalsScoutConfigUpdateBodyWriteScopesMax = 15

export const signalsScoutConfigUpdateBodyPrecheckQueryMax = 10000

export const signalsScoutConfigUpdateBodySuggestionIdMax = 64

export const SignalsScoutConfigUpdateBody = () => zod
    .object({
        display_name: zod
            .string()
            .max(signalsScoutConfigUpdateBodyDisplayNameMax)
            .optional()
            .describe(
                "Name shown wherever people identify this scout, written however you want it — spaces, capitalization, and acronyms are kept as typed, and two scouts may share one. It does not change the scout's skill name, which stays its identity, so renaming a scout keeps its schedule, run history, notes, memory, and links. At most 200 characters; blank means the scout has no name of its own and is labelled from its skill name instead."
            ),
        enabled: zod
            .boolean()
            .optional()
            .describe(
                'Whether this scout runs on its schedule. Disabled scouts are skipped by the coordinator. Turning this off records a user pause (`status` becomes `paused_by_user`, which the system never overrides); turning it on resumes the scout from any pause. Only a change of value is a lifecycle action: re-sending the current value leaves the existing status and its ownership untouched.'
            ),
        emit: zod
            .boolean()
            .optional()
            .describe(
                'Whether the scout writes findings to the inbox. False = dry-run: it runs and logs but emits nothing.'
            ),
        run_interval_minutes: zod
            .number()
            .min(signalsScoutConfigUpdateBodyRunIntervalMinutesMin)
            .max(signalsScoutConfigUpdateBodyRunIntervalMinutesMax)
            .optional()
            .describe('Minutes between runs (30–43200). Use 1440 for a daily schedule.'),
        run_cron_schedule: zod
            .string()
            .max(signalsScoutConfigUpdateBodyRunCronScheduleMax)
            .nullish()
            .describe(
                "Optional five-field cron expression, e.g. '30 9 \* \* \*' (daily at 09:30), '0 9,17 \* \* \*' (twice daily), or '0 9 \* \* 1-5' (weekday mornings). Evaluated in the project timezone. Takes precedence over `run_interval_minutes`; occurrences must be at least 30 minutes apart. Set null to return to the rolling interval schedule."
            ),
        output_destinations: zod
            .object({
                slack: zod
                    .union([
                        zod.object({
                            integration_id: zod
                                .number()
                                .min(1)
                                .describe(
                                    "ID of the Slack integration whose bot posts this scout's findings and reports."
                                ),
                            channel: zod
                                .string()
                                .max(signalsScoutConfigUpdateBodyOutputDestinationsOneSlackOneChannelMax)
                                .nullish()
                                .describe(
                                    "Slack channel target in the channel picker's `channel_id|#channel-name` format. Null while choosing a channel; no messages are sent until a channel or user is set."
                                ),
                            users: zod
                                .array(
                                    zod
                                        .string()
                                        .max(signalsScoutConfigUpdateBodyOutputDestinationsOneSlackOneUsersItemMax)
                                        .regex(signalsScoutConfigUpdateBodyOutputDestinationsOneSlackOneUsersItemRegExp)
                                )
                                .min(1)
                                .max(signalsScoutConfigUpdateBodyOutputDestinationsOneSlackOneUsersMax)
                                .nullish()
                                .describe(
                                    'Slack members to send output to as direct messages, each in `member_id|@display-name` format (a bare member ID like `U0123ABC456` also works). Each member gets their own DM from the PostHog app; at most 5. Set either this or `channel`, not both. Useful for personal scouts where a DM beats a channel.'
                                ),
                            thread_reports: zod
                                .boolean()
                                .optional()
                                .describe(
                                    "When true, post a report as a thread: a short lead in the channel and the rest split into replies at the summary's section labels, which can be Markdown headings or bold labels. Keeps a long summary from being clipped at Slack's section limit. On by default; set it false to post a single message, which can truncate a long summary. It does not change how findings post."
                                ),
                        }),
                        zod.null(),
                    ])
                    .optional()
                    .describe(
                        'Slack destination for each emitted scout finding or report. Null or omitted disables Slack delivery.'
                    ),
                webhook: zod
                    .union([
                        zod.object({
                            hog_function_id: zod
                                .string()
                                .describe(
                                    "Id of the CDP destination delivering this scout's reports. Set by the product that provisioned it, so it can find that destination again to update or remove it."
                                ),
                        }),
                        zod.null(),
                    ])
                    .optional()
                    .describe(
                        "The CDP destination another product provisioned for this scout's reports. Null or omitted means no webhook. Unlike Slack, Signals does not deliver this itself: the reference lives here so the owning product can manage the destination's lifecycle."
                    ),
                inbox: zod
                    .boolean()
                    .optional()
                    .describe(
                        "Whether this scout's reports appear in the shared inbox. Defaults to true. Set false to keep the reports this scout authors out of the inbox and its Slack notifications, for example for a digest scout read in Slack. Reports this scout only edits are not affected. An update that omits this key keeps the stored value."
                    ),
            })
            .optional()
            .describe(
                'Destinations that receive each finding or report this scout emits. Pass an empty object to disable delivery.'
            ),
        structured_output_schema: zod
            .record(zod.string(), zod.unknown())
            .nullish()
            .describe(
                'Optional JSON Schema (draft 2020-12) describing ONE structured record this scout produces via `scout-record-output` — e.g. a per-report quality judgment (`{\"type\": \"object\", \"properties\": {\"verdict\": {\"enum\": [\"good\", \"bad\", \"unsure\"]}, \"reason\": {\"type\": \"string\"}}, \"required\": [\"verdict\", \"reason\"]}`). The root must be `\"type\": \"object\"`. Setting a schema turns the structured-output channel on: the run prompt renders the schema and every submitted record is validated against it and recorded in the project as a `$scout_structured_output` event, queryable like any event. The channel also requires emit — a dry-run scout has nowhere to record to. Cardinality is the scout\'s call (one record per run, one per judged entity, ...). Null = channel off. Setting a schema requires skill-authoring authorization (the `llm_skill:write` scope and skill editor access) since the scout reads it verbatim in its prompt; clearing it needs only the config write. Records validate against the schema in force when the run was dispatched.'
            ),
        network_access: zod
            .enum(['trusted', 'full'])
            .describe('\* `trusted` - Trusted domains only\n\* `full` - Full')
            .optional()
            .describe(
                "What the scout's sandbox can reach over the network while it runs. `trusted` (the default) restricts runs to the platform's trusted-domain allowlist (PostHog, GitHub, common package registries). Set `full` to let this scout reach any site, for skills that read external sources such as documentation or papers. Applies from the scout's next run.\n\n\* `trusted` - Trusted domains only\n\* `full` - Full"
            ),
        model: zod
            .string()
            .max(signalsScoutConfigUpdateBodyModelMax)
            .nullish()
            .describe(
                "Optional model id this scout's runs are pinned to, e.g. `claude-opus-4-5`. Must be one of the platform's agent models; an invalid id is rejected with the available ones listed. Null keeps the default model, chosen by the platform. Early access: the pin can only be set on projects enrolled in the scout model preview, and only takes effect there. Set null to clear it."
            ),
        auto_pause_exempt: zod
            .boolean()
            .optional()
            .describe(
                'Exempt this scout from the inactivity sweep, meaning both the `ignored` pause and the `no_output` quiet warning. Set it on watchdog scouts whose value is staying quiet.'
            ),
        tags: zod
            .array(zod.string())
            .max(signalsScoutConfigUpdateBodyTagsMax)
            .optional()
            .describe(
                'Free-form labels for grouping the fleet, e.g. `[\"revenue\", \"on-call\"]`. Normalized to lowercase kebab-case (`On Call` and `on_call` both become `on-call`), deduped, and stored sorted; at most 10 tags, each at most 50 characters once normalized. Pass the full desired set — a write replaces the existing tags rather than merging into them. Filter the config list with the `tags` query parameter.'
            ),
        mcp_gateway_server_ids: zod
            .array(zod.string())
            .max(signalsScoutConfigUpdateBodyMcpGatewayServerIdsMax)
            .optional()
            .describe(
                "MCP gateway servers (by id) this scout's runs may use, chosen from the connections members shared to the whole team. Selection is per scout: an empty list gives the scout no MCP servers. Applies from the scout's next run."
            ),
        repositories: zod
            .array(zod.string().max(signalsScoutConfigUpdateBodyRepositoriesItemMax))
            .max(signalsScoutConfigUpdateBodyRepositoriesMax)
            .optional()
            .describe(
                "GitHub repositories this scout clones into its sandbox, each in `organization\/repo` format. Set them for a scout that reads code, so it can search the tree and run the project's own tests instead of reading files one API call at a time. Empty (the default) leaves the sandbox without a checkout. The scout's GitHub access stays read-only either way, so a repository listed here is never writable from a run. At most 10, each reachable through the project's GitHub connection. Applies from the scout's next run."
            ),
        write_scopes: zod
            .array(zod.string())
            .max(signalsScoutConfigUpdateBodyWriteScopesMax)
            .optional()
            .describe(
                "Write access granted to this one scout, as scope strings. The grantable set is `alert:write`, `annotation:write`, `canvas:write`, `customer_task:write`, `dashboard:write`, `event_definition:write`, `experiment:write`, `hog_flow_proposal:write`, `insight:write`, `llm_skill:write`, `notebook:write`, `replay_scanner:write`, `ticket:write`, `warehouse_table:write`, `warehouse_view:write`. A new scout starts with `notebook:write` when this field is omitted. Empty means the scout reads the project and writes only its findings and its own memory. Each scope is project-wide and object-level, so a scout holding `dashboard:write` can update or delete any dashboard in the project, not only ones it made. `ticket:write` lets the scout update tickets, manage saved views, and add private notes. Scouts cannot send public replies, compose emails, change existing notes, or change customer identity fields. Ticket changes can start workflows that message customers. `event_definition:write` lets the scout change the tags on event definitions and nothing else. Grant only what this scout maintains. Only the person the scout's runs act as (whoever authored it) or a project admin can set it, and a scoped API key must itself carry each scope it grants. A dry run (`emit=false`) never holds the grant, and a run that acts as a project member other than the author holds only the default scopes. Applies from the scout's next run."
            ),
        precheck_query: zod
            .string()
            .max(signalsScoutConfigUpdateBodyPrecheckQueryMax)
            .nullish()
            .describe(
                "Optional HogQL `SELECT` a scheduled run evaluates before it starts. When it returns no rows, or one row with one false value (`false`, `0`, null or empty), the run is skipped: no sandbox, no model call, and no run row. Any other result starts the run, and the scout reads the rows. A query error also starts the run. Use `{since}` (the start of the last run that ran, or when the scout was created) and `{now}` to look only at what is new, e.g. `SELECT count() FROM events WHERE event = '$exception' AND timestamp > {since}`. To run at least once a week however quiet it is, add `OR {since} < {now} - INTERVAL 7 DAY` to the condition. Only scheduled runs evaluate it: a manual or workflow run always starts. `{interval_minutes}` is the gap between two scheduled runs, so a backstop can follow the schedule: `{since} < {now} - toIntervalMinute(greatest(1440, 2 \* {interval_minutes}))` runs at least daily and never more often than every two intervals. The query stops after 10 seconds and reads at most 50 rows. Try a query with `scout-config-precheck-test` before you save it. Null or blank uses the default pre-check the scout's skill ships, if any. To turn every pre-check off, set `precheck_disabled`."
            ),
        precheck_disabled: zod
            .boolean()
            .optional()
            .describe(
                'True turns off the pre-check, both `precheck_query` and the default the skill ships, so every scheduled run starts. False (the default) uses `precheck_query`, or the skill default when that is null.'
            ),
        suggestion_id: zod
            .string()
            .max(signalsScoutConfigUpdateBodySuggestionIdMax)
            .optional()
            .describe(
                "Optional id of the canonical scout suggestion this request turns on. It records that the scout came from that suggestion. An id this project's batch does not hold is ignored."
            ),
        lifecycle_locked: zod
            .boolean()
            .optional()
            .describe(
                "Opt-in guard on this scout's lifecycle. Off by default, so anyone with scout write access may pause, resume, switch the scout to dry run, or delete it. On, only the person the scout's runs act as or a project admin may do any of those, or change this flag. Use it on a scout whose output people depend on: `signal_scout:write` is a project-wide scope held by people and by unattended agents alike, and a resume has to pass the project's enabled-scout maximum that a pause does not, so a bulk pause is not undone in one step. The lock never stops an automatic pause, such as the inactivity sweep or the repeated-failure breaker."
            ),
        allowed_mcp_tools: zod
            .array(zod.string())
            .nullish()
            .describe(
                'Exact MCP tool names selected for this scout, excluding its built-in run context tools. Null means no tool restriction; an empty list selects no additional tools. Write access is derived from selected write tools. Clearing to null preserves the last write scopes. Send this field or tool_preset, never both. Requires the scouts-tool-access feature flag.'
            ),
        tool_preset: zod
            .enum(['read_only', 'support_notes'])
            .describe('\* `read_only` - Read only\n\* `support_notes` - Support notes')
            .optional()
            .describe(
                'Expand this named preset into a saved tool list. Later preset changes do not alter the saved list. Send this field or allowed_mcp_tools, never both. Requires the scouts-tool-access feature flag.\n\n\* `read_only` - Read only\n\* `support_notes` - Support notes'
            ),
    })
    .describe('Editable display name, schedule, enablement, and emit posture for one scout config.')

/**
 * Delete one scout config by its `id`, removing the per-(team, skill) schedule/emit row outright. The point is cleaning up an orphaned config whose skill was archived or deleted — it lingers in `list` with an empty `description`, never runs (the coordinator skips it and the skill can't load), but can't otherwise be removed over the API. Deletion is activity-logged. Note: auto-registration only scans live `signals-scout-*` skills, so a config deleted for one of those is back on the coordinator's next tick. A scout under any other name does not come back on its own: its config stays deleted until you re-register it, and its skill still reads as a scout meanwhile. To retire a live scout, archive its skill (or set `enabled=false` to make it inert) rather than deleting the config. A scout whose `scout_role` is `operational` cannot be deleted: it is part of the self-driving system rather than the project's own fleet.
 * @summary Delete a scout config
 */
export const SignalsScoutConfigDestroyParams = () => zod.object({
    id: zod.string().describe('A UUID string identifying this Signal scout config.'),
    project_id: zod
        .string()
        .describe(
            "Project ID of the project you're trying to access. To find the ID of the project, make a call to \/api\/projects\/."
        ),
})

/**
 * Run a scout's pre-check query once and return its rows, without starting a run and without saving anything. The query gets the same `{since}` and `{now}` values the next scheduled run would get, so the result says whether that run would start or skip. Pass `precheck_query` to try a query before you save it, or omit it to try the effective one: the saved query, or the default the scout's skill ships. A query error comes back in the `error` field with a 200, because a scheduled run treats it as a reason to run.
 * @summary Test a scout pre-check
 */
export const SignalsScoutConfigPrecheckTestParams = () => zod.object({
    id: zod.string().describe('A UUID string identifying this Signal scout config.'),
    project_id: zod
        .string()
        .describe(
            "Project ID of the project you're trying to access. To find the ID of the project, make a call to \/api\/projects\/."
        ),
})

export const signalsScoutConfigPrecheckTestBodyPrecheckQueryMax = 10000

export const SignalsScoutConfigPrecheckTestBody = () => zod.object({
    precheck_query: zod
        .string()
        .max(signalsScoutConfigPrecheckTestBodyPrecheckQueryMax)
        .nullish()
        .describe(
            "HogQL `SELECT` to try, with the same `{since}`, `{now}` and `{interval_minutes}` placeholders a saved pre-check gets. Omit it, or pass null or blank, to try the scout's effective query: its own `precheck_query`, or the default its skill ships."
        ),
})

/**
 * Dispatch one on-demand run of this scout immediately, regardless of its schedule. Useful to test a scout right after authoring it, or to refresh its findings on demand. The run executes asynchronously on the worker and inherits every guard the scheduled path has: it is forbidden if scouts are not enabled for the project (403), and skipped if self-driving is paused at the project's pull request limit, or the project is over its daily report limit or daily run budget (429), or a run for this scout is already in progress (409). A manual run counts against the same daily run budget as scheduled runs, so repeated manual runs of the same scout can exhaust the project's daily allowance. A manual run does not change the scout's schedule or `last_run_at`. A disabled scout can still be run this way (to test before enabling). Pass an optional `note` to steer this one run without leaving a scout note that would steer every later run too. Returns immediately with the workflow id: poll the scout's runs for the result.
 * @summary Run a scout now
 */
export const SignalsScoutConfigRunParams = () => zod.object({
    id: zod.string().describe('A UUID string identifying this Signal scout config.'),
    project_id: zod
        .string()
        .describe(
            "Project ID of the project you're trying to access. To find the ID of the project, make a call to \/api\/projects\/."
        ),
})

export const signalsScoutConfigRunBodyNoteMax = 1000

export const SignalsScoutConfigRunBody = () => zod
    .object({
        note: zod
            .string()
            .max(signalsScoutConfigRunBodyNoteMax)
            .optional()
            .describe(
                "Optional steering for this run only, such as 'focus on the checkout regression' or 'skip the staging traffic today'. The agent reads it alongside the scout's durable notes and weighs it the same way: it directs attention, it never forces a finding. Use it instead of leaving a scout note that would also steer every later scheduled run. The note is kept on the run for history and is never read by another run. Because the agent reads it verbatim while holding privileged tools, a run that carries one needs `llm_skill:write` on top of `signal_scout:write`, plus editor access to skills, the same bar as leaving a note."
            ),
    })
    .describe(
        'Request body for an on-demand (`run now`) scout dispatch.\n\nEvery field is optional: a plain trigger sends no body at all.'
    )

/**
 * Run a prompt, model, or effort variant against live data with private memory and report capture.
 * @summary Run a private scout variant
 */
export const SignalsScoutConfigTrialParams = () => zod.object({
    id: zod.string().describe('A UUID string identifying this Signal scout config.'),
    project_id: zod
        .string()
        .describe(
            "Project ID of the project you're trying to access. To find the ID of the project, make a call to \/api\/projects\/."
        ),
})

export const signalsScoutConfigTrialBodyVariantMax = 100

export const signalsScoutConfigTrialBodySkillBodyMax = 100000

export const signalsScoutConfigTrialBodyModelMax = 200

export const signalsScoutConfigTrialBodyReasoningEffortMax = 20

export const signalsScoutConfigTrialBodyNoteMax = 1000

export const SignalsScoutConfigTrialBody = () => zod.object({
    launch_id: zod.string().describe('Unique launch ID. Reuse it only when retrying this exact request.'),
    context_id: zod.string().optional().describe('Saved starting context from a previous launch in this comparison.'),
    variant: zod
        .string()
        .max(signalsScoutConfigTrialBodyVariantMax)
        .optional()
        .describe('Operator label for this variant.'),
    skill_body: zod
        .string()
        .max(signalsScoutConfigTrialBodySkillBodyMax)
        .optional()
        .describe('Replacement skill body for this run. Supporting files and tool permissions stay pinned.'),
    model: zod.string().max(signalsScoutConfigTrialBodyModelMax).optional().describe('Model identifier for this run.'),
    reasoning_effort: zod
        .string()
        .max(signalsScoutConfigTrialBodyReasoningEffortMax)
        .optional()
        .describe(
            'Reasoning effort supported by the selected model. Required when the saved source has no pinned effort.'
        ),
    note: zod
        .string()
        .max(signalsScoutConfigTrialBodyNoteMax)
        .optional()
        .describe('Common investigation note, saved before applying any variant overrides.'),
})

/**
 * Freeze variants and the reviewed rubric, then run scouts and judge their results in the background.
 * @summary Run and judge a private scout comparison
 */
export const SignalsScoutConfigTrialComparisonCreateParams = () => zod.object({
    id: zod.string().describe('A UUID string identifying this Signal scout config.'),
    project_id: zod
        .string()
        .describe(
            "Project ID of the project you're trying to access. To find the ID of the project, make a call to \/api\/projects\/."
        ),
})

export const signalsScoutConfigTrialComparisonCreateBodyVariantsItemLabelMax = 100

export const signalsScoutConfigTrialComparisonCreateBodyVariantsItemLaunchIdsMax = 20

export const signalsScoutConfigTrialComparisonCreateBodyVariantsItemModelMax = 200

export const signalsScoutConfigTrialComparisonCreateBodyVariantsItemReasoningEffortMax = 20

export const signalsScoutConfigTrialComparisonCreateBodyVariantsItemSkillBodyMax = 100000

export const signalsScoutConfigTrialComparisonCreateBodyNoteMax = 1000

export const SignalsScoutConfigTrialComparisonCreateBody = () => zod.object({
    comparison_id: zod.string().describe('Stable comparison ID. Reuse for an exact request retry.'),
    baseline_variant_id: zod.string().describe('Variant used as the comparison baseline.'),
    variants: zod
        .array(
            zod.object({
                id: zod.string().describe('Stable variant identity within this comparison.'),
                label: zod
                    .string()
                    .max(signalsScoutConfigTrialComparisonCreateBodyVariantsItemLabelMax)
                    .describe('Variant name shown in the report.'),
                launch_ids: zod
                    .array(zod.string())
                    .min(1)
                    .max(signalsScoutConfigTrialComparisonCreateBodyVariantsItemLaunchIdsMax)
                    .describe("Stable run IDs for this variant's repeats."),
                model: zod
                    .string()
                    .max(signalsScoutConfigTrialComparisonCreateBodyVariantsItemModelMax)
                    .describe('Scout model to run.'),
                reasoning_effort: zod
                    .string()
                    .max(signalsScoutConfigTrialComparisonCreateBodyVariantsItemReasoningEffortMax)
                    .describe('Reasoning effort supported by this model.'),
                skill_body: zod
                    .string()
                    .max(signalsScoutConfigTrialComparisonCreateBodyVariantsItemSkillBodyMax)
                    .optional()
                    .describe('Replacement scout instructions. Omit to use the saved source instructions.'),
            })
        )
        .describe('Up to 20 variants, each with up to 20 scout runs.'),
    note: zod
        .string()
        .max(signalsScoutConfigTrialComparisonCreateBodyNoteMax)
        .optional()
        .describe('Shared investigation note.'),
    expected_skill_version: zod
        .number()
        .min(1)
        .optional()
        .describe('Source version shown in the editor. Refuse a new trial if the instructions changed since setup.'),
})

/**
 * Hide a finished trial from history or restore it without deleting results or starting any work.
 * @summary Archive or restore a saved scout trial
 */
export const SignalsScoutConfigTrialComparisonArchiveParams = () => zod.object({
    id: zod.string().describe('A UUID string identifying this Signal scout config.'),
    project_id: zod
        .string()
        .describe(
            "Project ID of the project you're trying to access. To find the ID of the project, make a call to \/api\/projects\/."
        ),
})

export const SignalsScoutConfigTrialComparisonArchiveBody = () => zod.object({
    comparison_id: zod.string().describe('Saved comparison identity.'),
    archived: zod.boolean().describe('Hide a finished trial from history, or restore it without rerunning it.'),
})

/**
 * Read recent comparisons, including those saved before any scout run started.
 * @summary List your saved scout comparisons
 */
export const SignalsScoutConfigTrialComparisonHistoryParams = () => zod.object({
    id: zod.string().describe('A UUID string identifying this Signal scout config.'),
    project_id: zod
        .string()
        .describe(
            "Project ID of the project you're trying to access. To find the ID of the project, make a call to \/api\/projects\/."
        ),
})

export const signalsScoutConfigTrialComparisonHistoryQueryCursorRegExp = new RegExp('^[0-9]{19}-[0-9a-f-]{36}\\.json$')
export const signalsScoutConfigTrialComparisonHistoryQueryIncludeArchivedDefault = false
export const signalsScoutConfigTrialComparisonHistoryQueryLimitDefault = 30
export const signalsScoutConfigTrialComparisonHistoryQueryLimitMax = 100

export const SignalsScoutConfigTrialComparisonHistoryQueryParams = () => zod.object({
    cursor: zod
        .string()
        .min(1)
        .regex(signalsScoutConfigTrialComparisonHistoryQueryCursorRegExp)
        .optional()
        .describe('Cursor returned by the previous history page. Omit to read the newest trials.'),
    include_archived: zod
        .boolean()
        .default(signalsScoutConfigTrialComparisonHistoryQueryIncludeArchivedDefault)
        .describe('Include archived trials in the history.'),
    limit: zod
        .number()
        .min(1)
        .max(signalsScoutConfigTrialComparisonHistoryQueryLimitMax)
        .default(signalsScoutConfigTrialComparisonHistoryQueryLimitDefault)
        .describe('Maximum number of recent private runs to return.'),
})

/**
 * Read comparison progress and its saved report without starting any scout or judge calls.
 * @summary Read a saved scout comparison
 */
export const SignalsScoutConfigTrialComparisonRetrieveParams = () => zod.object({
    id: zod.string().describe('A UUID string identifying this Signal scout config.'),
    project_id: zod
        .string()
        .describe(
            "Project ID of the project you're trying to access. To find the ID of the project, make a call to \/api\/projects\/."
        ),
})

export const SignalsScoutConfigTrialComparisonRetrieveQueryParams = () => zod.object({
    comparison_id: zod.string().describe('Saved comparison identity.'),
})

/**
 * Recover the same comparison without repeating saved scout runs or judge attempts.
 * @summary Resume a saved scout comparison
 */
export const SignalsScoutConfigTrialComparisonResumeParams = () => zod.object({
    id: zod.string().describe('A UUID string identifying this Signal scout config.'),
    project_id: zod
        .string()
        .describe(
            "Project ID of the project you're trying to access. To find the ID of the project, make a call to \/api\/projects\/."
        ),
})

export const SignalsScoutConfigTrialComparisonResumeBody = () => zod.object({
    comparison_id: zod.string().describe('Saved comparison identity.'),
})

/**
 * Read a trial's existing run status and its privately captured reports and memory changes.
 * @summary Read a private scout trial result
 */
export const SignalsScoutConfigTrialResultParams = () => zod.object({
    id: zod.string().describe('A UUID string identifying this Signal scout config.'),
    project_id: zod
        .string()
        .describe(
            "Project ID of the project you're trying to access. To find the ID of the project, make a call to \/api\/projects\/."
        ),
})

export const SignalsScoutConfigTrialResultQueryParams = () => zod.object({
    launch_id: zod.string().describe('Launch identity returned by the trial action.'),
})

/**
 * Read comparison readiness and source settings for the internal comparison editor.
 * @summary Inspect a private scout comparison
 */
export const SignalsScoutConfigTrialSetupParams = () => zod.object({
    id: zod.string().describe('A UUID string identifying this Signal scout config.'),
    project_id: zod
        .string()
        .describe(
            "Project ID of the project you're trying to access. To find the ID of the project, make a call to \/api\/projects\/."
        ),
})

export const SignalsScoutConfigTrialSetupQueryParams = () => zod.object({
    context_id: zod
        .string()
        .optional()
        .describe('Saved comparison context to inspect instead of the current source skill.'),
})

/**
 * Materialize the scout fleet for this project on demand (idempotent): seed the canonical `signals-scout-*` skills, create a default-schedule config for any scout lacking one, retire the skills whose canonical scout no longer ships, and return all scout configs. Normally the Temporal coordinator does this on its next tick; this action exists so the scout UIs and setup flows (e.g. the wizard's self-driving program) can hand the user a tunable fleet immediately. With surface=onboarding, new configs stay disabled until explicitly activated.
 * @summary Sync scout configs
 */
export const SignalsScoutConfigSyncParams = () => zod.object({
    project_id: zod
        .string()
        .describe(
            "Project ID of the project you're trying to access. To find the ID of the project, make a call to \/api\/projects\/."
        ),
})

export const SignalsScoutConfigSyncQueryParams = () => zod.object({
    surface: zod
        .enum(['roster', 'desktop', 'wizard', 'onboarding'])
        .optional()
        .describe(
            "Which surface asked for the materialization, recorded on the `signals_scout_fleet_synced` analytics event so a fleet a person's tab-open delivered is separable from one the coordinator was going to deliver anyway. The onboarding surface creates new configs disabled until the user activates them. Omitted means unknown.\n\n\* `roster` - roster\n\* `desktop` - desktop\n\* `wizard` - wizard\n\* `onboarding` - onboarding"
        ),
})

/**
 * Return the people who can review work on this project — one row per member with access to it, each with their `user_uuid`, `email`, `first_name`/`last_name`, resolved GitHub `login` (null when they have no linked GitHub identity), and the `teams` they're on. The cold-start reviewer-routing path: when a finding's owner can't be read off a fetched entity's `created_by` and there's no cached `reviewer:<area>` memory or inbox precedent, list members, match the owner by email/name, then put their resolved `github_login` in `suggested_reviewers` on `emit-report` / `edit-report`. Pass `team` to resolve a team slug to the people on it, maintainers first. Pass `search` to narrow a large roster; the result is capped at 200. When `search` or `team` narrows the result to 10 members or fewer, each row also carries `activity`: the member's recent work, so you can check they are close to the affected area. Strictly team-scoped.
 * @summary List project members for reviewer routing
 */
export const SignalsScoutMembersListParams = () => zod.object({
    project_id: zod
        .string()
        .describe(
            "Project ID of the project you're trying to access. To find the ID of the project, make a call to \/api\/projects\/."
        ),
})

export const SignalsScoutMembersListQueryParams = () => zod.object({
    search: zod
        .string()
        .min(1)
        .optional()
        .describe(
            "Case-insensitive substring filter over member email and first\/last name. Use it to narrow a large project's roster to the owner you're trying to match instead of pulling every member."
        ),
    team: zod
        .string()
        .min(1)
        .optional()
        .describe(
            'Team slug (case-insensitive, no `@org\/` prefix), for example `team-desktop`. Narrows the roster to the members on that team, maintainers first, so a slug from a scout note, CODEOWNERS, or an owners file resolves to people you can route to. Returns an error, not an empty list, when the project has no synced team roster or the roster holds no rows for the slug. Rosters sync team by team, so a slug with no rows usually means that team is not synced here, not that it does not exist.'
        ),
})

/**
 * Return the project's scout metadata: whether it is enrolled, the current announcement banner (e.g. an alpha run-limit notice, or null when unset), and the enforced run limits with current usage. Limits reflect what the coordinator actually applies at dispatch, so a user can see the real throttle rather than what they assume they set. All values come from the `signals-scout` flag payload, so the banner and caps can change with no deploy.
 * @summary Get scout metadata
 */
export const SignalsScoutMetadataGetParams = () => zod.object({
    project_id: zod
        .string()
        .describe(
            "Project ID of the project you're trying to access. To find the ID of the project, make a call to \/api\/projects\/."
        ),
})

/**
 * Return the steering notes left for this project's scouts, newest first. Pass `skill_name` to get the notes addressed to one scout (or one pipeline audience, e.g. `pipeline:report-research`) plus the general (blank-target) fleet-wide notes — the shape a scout run reads at cold start. Omit `skill_name` to browse every note. Expired notes are excluded unless `include_expired=true`; `only_without_expiry=true` keeps only the standing notes that have no `expires_at`. `date_from` / `date_to` are a half-open window on `created_at` (`>= date_from`, `< date_to`); pass `date_to` (the `created_at` of the oldest note seen) to walk past the cap. Pass `text` to keep only the notes whose content contains it, case-insensitively. Results capped at 500.
 * @summary List scout notes
 */
export const SignalsScoutNotesListParams = () => zod.object({
    project_id: zod
        .string()
        .describe(
            "Project ID of the project you're trying to access. To find the ID of the project, make a call to \/api\/projects\/."
        ),
})

export const signalsScoutNotesListQueryContentMaxCharsMin = 0

export const signalsScoutNotesListQueryIncludeExpiredDefault = false
export const signalsScoutNotesListQueryIncludeGeneralDefault = true
export const signalsScoutNotesListQueryLimitMax = 500

export const signalsScoutNotesListQueryOnlyWithoutExpiryDefault = false
export const signalsScoutNotesListQueryTextMax = 200

export const SignalsScoutNotesListQueryParams = () => zod.object({
    content_max_chars: zod
        .number()
        .min(signalsScoutNotesListQueryContentMaxCharsMin)
        .optional()
        .describe(
            "Truncate each note's `content` to the first N characters (a preview). Omit for the full body — use this on wide scans so stacked notes can't dominate your context."
        ),
    date_from: zod.iso
        .datetime({ offset: true })
        .optional()
        .describe('ISO-8601 inclusive lower bound on `created_at`. Omit to skip the lower bound.'),
    date_to: zod.iso
        .datetime({ offset: true })
        .optional()
        .describe(
            'ISO-8601 exclusive upper bound on `created_at`. Pass the `created_at` of the oldest note from the prior page to walk back past the result cap.'
        ),
    include_expired: zod
        .boolean()
        .default(signalsScoutNotesListQueryIncludeExpiredDefault)
        .describe('Include notes whose `expires_at` has passed. Off by default so time-boxed steering retires itself.'),
    include_general: zod
        .boolean()
        .default(signalsScoutNotesListQueryIncludeGeneralDefault)
        .describe(
            "Only meaningful with `skill_name`: when false, exclude the general fleet-wide notes and return the target's own notes only."
        ),
    limit: zod
        .number()
        .min(1)
        .max(signalsScoutNotesListQueryLimitMax)
        .optional()
        .describe('Max rows to return (default 20, hard cap 500).'),
    only_without_expiry: zod
        .boolean()
        .default(signalsScoutNotesListQueryOnlyWithoutExpiryDefault)
        .describe(
            'Return only the standing notes, which have no `expires_at`. Pair it with `date_from` to re-read the standing notes of a recent window that the newest-first cap would hide.'
        ),
    skill_name: zod
        .string()
        .min(1)
        .optional()
        .describe(
            "Return the notes addressed to this target plus the general (blank-target) notes for the whole fleet. Pass a configured scout's skill name or a pipeline audience (`pipeline:report-research`). Omit to browse every note on the project."
        ),
    text: zod
        .string()
        .min(1)
        .max(signalsScoutNotesListQueryTextMax)
        .optional()
        .describe(
            'Return only the notes whose content contains this text, case-insensitively. Pass an entity (an error id, a flag key, a page path, an event name) to find the notes about it, including older ones the newest-first cap would hide.'
        ),
})

/**
 * Leave a steering note the scout fleet reads on its next runs. Address it to one scout via `skill_name` (a configured scout), to one stage of the report pipeline via a reserved audience (`pipeline:report-research`), or omit it for a general note every scout sees. Each call creates a new note (no upsert); delete retires one. Attributed to the authenticated user.
 * @summary Leave a note for the scouts
 */
export const SignalsScoutNotesCreateParams = () => zod.object({
    project_id: zod
        .string()
        .describe(
            "Project ID of the project you're trying to access. To find the ID of the project, make a call to \/api\/projects\/."
        ),
})

export const signalsScoutNotesCreateBodyContentMax = 10000

export const signalsScoutNotesCreateBodySkillNameMax = 200

export const SignalsScoutNotesCreateBody = () => zod
    .object({
        content: zod
            .string()
            .max(signalsScoutNotesCreateBodyContentMax)
            .describe(
                "The note's prose — feedback, a pointer, or a nudge for the scout(s) to weigh on their next runs (e.g. 'we shipped a new checkout on Tuesday, watch conversion closely', 'stop flagging the staging traffic spike'). Write it in Markdown; the run reads it verbatim."
            ),
        skill_name: zod
            .string()
            .max(signalsScoutNotesCreateBodySkillNameMax)
            .optional()
            .describe(
                'Address the note to one scout by its skill name (exact match against a configured scout on the project — check `scout-config-list` for the roster), or to one stage of the report pipeline by its reserved audience (`pipeline:report-research`); any other `pipeline:\*` value is rejected. Use a pipeline audience for guidance about how reports get researched, judged, and routed rather than about what the scouts watch, so it reaches that stage and no scout. Omit or leave blank for a general note every scout sees.'
            ),
        report_id: zod
            .string()
            .nullish()
            .describe(
                "Optional id of the inbox report this note is about. The note then names the report so a scout can fetch it, and the report's activity log records that the note was left. Requires edit access to inbox reports, and the report must belong to this project. The report reference shares the note's character budget, so `content` is capped at 9938 characters when this is set."
            ),
        expires_at: zod
            .string()
            .nullish()
            .describe(
                "Optional ISO-8601 expiry. After this time the note drops out of the default list view, so time-boxed steering ('watch closely this week') retires itself. Omit for a note that stays active until deleted. Best-effort — a value that can't be parsed or is already in the past is dropped (the note stays active), not rejected, so the note is never lost."
            ),
    })
    .describe('Request body for `notes-create`.')

/**
 * Delete one note by its `id`, retiring it from every scout's view. Use this when a note has been acted on or no longer applies; time-boxed notes can instead carry an `expires_at` and retire themselves.
 * @summary Delete a scout note
 */
export const SignalsScoutNotesDestroyParams = () => zod.object({
    id: zod.string(),
    project_id: zod
        .string()
        .describe(
            "Project ID of the project you're trying to access. To find the ID of the project, make a call to \/api\/projects\/."
        ),
})

/**
 * Return the team's deterministic project profile. The response opens with a compact `summary` envelope carrying the emit gate and the inbox report counts, then the full `payload`. The inventory runs to tens of kilobytes, so a client that truncates a long tool result still keeps the gate. Pass `summary_only=true` to omit `payload` entirely. For the internal scout token the response reflects the newest non-expired cached row or a freshly-built one (lazy compute on cache miss); `force_refresh=true` skips the cache and rebuilds from authoritative sources. Public read callers (session auth or a `signal_scout:read` PAK) get the newest stored profile whatever its age, with `stale=true` when it is past `expires_at`. They never build inline: when the team has no profile, the call starts a background build and returns 404, so retry in a minute. Read this at the start of a run to orient on the team's product mix, integrations, warehouse sources, signal coverage, and existing inbox surface.
 * @summary Get the current project profile
 */
export const SignalsScoutProjectProfileGetParams = () => zod.object({
    project_id: zod
        .string()
        .describe(
            "Project ID of the project you're trying to access. To find the ID of the project, make a call to \/api\/projects\/."
        ),
})

export const signalsScoutProjectProfileGetQueryForceRefreshDefault = false
export const signalsScoutProjectProfileGetQuerySummaryOnlyDefault = false

export const SignalsScoutProjectProfileGetQueryParams = () => zod.object({
    force_refresh: zod
        .boolean()
        .default(signalsScoutProjectProfileGetQueryForceRefreshDefault)
        .describe(
            "When true, skip the cache and rebuild the profile from authoritative sources before responding. Use after seeding events, importing data, or any other change the caller knows just landed but hasn't surfaced through natural cache expiry yet. Honored only for the internal scout token — public read callers get the cached profile regardless. Concurrent forced rebuilds are serialized by the team-keyed advisory lock — at most one extra `build_inventory` per simultaneous request."
        ),
    run_id: zod
        .string()
        .nullish()
        .describe(
            "The run whose scout's write posture `emit_eligibility` should answer for. A scout sandbox never needs this: its token is bound to the task that dispatched the run, and that binding is what the endpoint reads, so it wins over any value passed here. Pass it to inspect one scout's effective eligibility from outside a run — a run id from another project is ignored."
        ),
    summary_only: zod
        .boolean()
        .default(signalsScoutProjectProfileGetQuerySummaryOnlyDefault)
        .describe(
            'When true, respond with the cache metadata and the `summary` envelope only, and omit `payload` entirely. Use it when you need the emit gate and the inbox counts but not the full inventory. The full profile runs to tens of kilobytes, which a client can truncate. Costs nothing extra: the profile is read or built the same way either way.'
        ),
})

export const SignalsScoutRubricsRetrieveParams = () => zod.object({
    id: zod.string().describe('A UUID string identifying this Signal scout config.'),
    project_id: zod
        .string()
        .describe(
            "Project ID of the project you're trying to access. To find the ID of the project, make a call to \/api\/projects\/."
        ),
})

export const SignalsScoutRubricsUpdateParams = () => zod.object({
    id: zod.string().describe('A UUID string identifying this Signal scout config.'),
    project_id: zod
        .string()
        .describe(
            "Project ID of the project you're trying to access. To find the ID of the project, make a call to \/api\/projects\/."
        ),
})

export const signalsScoutRubricsUpdateBodyRevisionMin = 0

export const signalsScoutRubricsUpdateBodyCriteriaItemIdMax = 80

export const signalsScoutRubricsUpdateBodyCriteriaItemIdRegExp = new RegExp('^[a-z][a-z0-9_-]{0,79}$')
export const signalsScoutRubricsUpdateBodyCriteriaItemTitleMax = 120

export const signalsScoutRubricsUpdateBodyCriteriaItemDescriptionMax = 1000

export const signalsScoutRubricsUpdateBodyCriteriaItemPassConditionMax = 2000

export const signalsScoutRubricsUpdateBodyCriteriaItemApplicabilityMax = 1000

export const SignalsScoutRubricsUpdateBody = () => zod.object({
    revision: zod
        .number()
        .min(signalsScoutRubricsUpdateBodyRevisionMin)
        .describe('Revision read by the editor; stale saves return 409.'),
    criteria: zod
        .array(
            zod.object({
                id: zod
                    .string()
                    .max(signalsScoutRubricsUpdateBodyCriteriaItemIdMax)
                    .regex(signalsScoutRubricsUpdateBodyCriteriaItemIdRegExp)
                    .describe('Stable criterion identifier.'),
                title: zod
                    .string()
                    .max(signalsScoutRubricsUpdateBodyCriteriaItemTitleMax)
                    .describe('Short name for the criterion.'),
                description: zod
                    .string()
                    .max(signalsScoutRubricsUpdateBodyCriteriaItemDescriptionMax)
                    .describe('What this criterion measures.'),
                pass_condition: zod
                    .string()
                    .max(signalsScoutRubricsUpdateBodyCriteriaItemPassConditionMax)
                    .describe('The evidence needed to pass this criterion.'),
                applicability: zod
                    .string()
                    .max(signalsScoutRubricsUpdateBodyCriteriaItemApplicabilityMax)
                    .describe('When this criterion applies or cannot be assessed.'),
                enabled: zod.boolean().describe('Whether future evaluations should use this criterion.'),
                source: zod
                    .enum(['default', 'custom'])
                    .describe('\* `default` - Default\n\* `custom` - Custom')
                    .describe(
                        'Shared default or scout-specific criterion.\n\n\* `default` - Default\n\* `custom` - Custom'
                    ),
            })
        )
        .describe('Complete set of criteria to save.'),
    adopt_generation_id: zod
        .string()
        .nullish()
        .describe(
            "Use this completed generation's governing source for the whole saved rubric. Omit to keep its source."
        ),
})

export const SignalsScoutRubricsGenerateParams = () => zod.object({
    id: zod.string().describe('A UUID string identifying this Signal scout config.'),
    project_id: zod
        .string()
        .describe(
            "Project ID of the project you're trying to access. To find the ID of the project, make a call to \/api\/projects\/."
        ),
})

export const signalsScoutRubricsGenerateBodyContextDefault = ``
export const signalsScoutRubricsGenerateBodyContextMax = 2000

export const SignalsScoutRubricsGenerateBody = () => zod.object({
    context: zod
        .string()
        .max(signalsScoutRubricsGenerateBodyContextMax)
        .default(signalsScoutRubricsGenerateBodyContextDefault)
        .describe("Optional priorities for this generation. Suggestions still cover the scout's full job."),
})

/**
 * Return the most recent `SignalScoutRun` summaries for this project, newest first. Used by the headless scout to dedupe against work other runs already covered. ILIKE matches on `summary`. `date_from` / `date_to` are a half-open window on `created_at` (`>= date_from`, `< date_to`); pass `date_to` on subsequent calls to walk past the 100-row cap. Pass `emitted=true` to see only runs that surfaced at least one finding. Pass `skill_name` (optionally with `skill_version`) to scope to a single scout. Results capped at 100.
 * @summary Search recent agent runs
 */
export const SignalsScoutRunsListParams = () => zod.object({
    project_id: zod
        .string()
        .describe(
            "Project ID of the project you're trying to access. To find the ID of the project, make a call to \/api\/projects\/."
        ),
})

export const signalsScoutRunsListQueryLimitMax = 100

export const SignalsScoutRunsListQueryParams = () => zod.object({
    date_from: zod.iso
        .datetime({ offset: true })
        .optional()
        .describe('ISO-8601 inclusive lower bound on `created_at`. Omit to skip the lower bound.'),
    date_to: zod.iso
        .datetime({ offset: true })
        .optional()
        .describe(
            'ISO-8601 exclusive upper bound on `created_at`. Pass to walk back past the result cap on subsequent calls (cursor-style: set to the `created_at` of the oldest run from the prior page).'
        ),
    emitted: zod
        .boolean()
        .nullish()
        .describe(
            'Filter by emit outcome. `true` returns only runs that emitted at least one finding (`emitted_count > 0`); `false` returns only runs that emitted nothing. Omit for both.'
        ),
    limit: zod
        .number()
        .min(1)
        .max(signalsScoutRunsListQueryLimitMax)
        .optional()
        .describe('Max rows to return (default 20, hard cap 100).'),
    skill_name: zod
        .string()
        .min(1)
        .optional()
        .describe(
            'Exact-match filter on the scout skill (e.g. `signals-scout-errors`). Narrows the run dump to a single scout — the primary scoping path when a specialist dedupes against its own past runs. Omit to span every scout on the team.'
        ),
    skill_version: zod
        .number()
        .min(1)
        .optional()
        .describe('Exact-match filter on the skill version. Pair with `skill_name` to pin one version; omit for all.'),
    text: zod
        .string()
        .min(1)
        .optional()
        .describe("Case-insensitive substring match on the scout's end-of-run `summary`. Omit to skip the filter."),
})

/**
 * Return the full `SignalScoutRun` row. Status, timing, and error flow from the linked `tasks.TaskRun`. Strictly team-scoped — a UUID belonging to another team returns 404.
 * @summary Get a run by ID
 */
export const SignalsScoutRunsRetrieveParams = () => zod.object({
    project_id: zod
        .string()
        .describe(
            "Project ID of the project you're trying to access. To find the ID of the project, make a call to \/api\/projects\/."
        ),
    run_id: zod.string().describe('UUID of the `SignalScoutRun` bridge row.'),
})

/**
 * Close the follow-up check this run was dispatched to answer. The run note carries the check id and what to establish; this call is the only thing that records the answer, so a run that investigates and says nothing leaves the check unanswered. The verdict lands on the report as a `check_result` entry people read in the inbox. `failed` retires the check, `passed` re-arms a recurring one, and `errored` retries it. `inconclusive` with the `awaiting_data` reason looks again later, and any other reason ends the check. Send the outcome you actually reached rather than the one that closes the loop. A run may close the check it was dispatched for, or a check on its own scout that is due or waiting on a run.
 * @summary Record the verdict on a report check
 */
export const SignalsScoutRecordCheckResultParams = () => zod.object({
    project_id: zod
        .string()
        .describe(
            "Project ID of the project you're trying to access. To find the ID of the project, make a call to \/api\/projects\/."
        ),
    run_id: zod.string().describe('UUID of the `SignalScoutRun` bridge row.'),
})

export const signalsScoutRecordCheckResultBodyExplanationMax = 1000

export const SignalsScoutRecordCheckResultBody = () => zod
    .object({
        check_id: zod.string().describe('The check this run was dispatched to answer, as given in the run note.'),
        outcome: zod
            .enum(['passed', 'failed', 'errored', 'inconclusive'])
            .describe(
                '\* `passed` - Passed\n\* `failed` - Failed\n\* `errored` - Errored\n\* `inconclusive` - Inconclusive'
            )
            .describe(
                "`passed` when the evidence meets the check's stated bar and the expectation holds, `failed` when the evidence meets the bar and the expectation does not hold. `inconclusive` when your tools worked but the evidence cannot settle the question; give a `reason`. `errored` only when a tool, query, or model call failed. Reserve `failed` for a conclusion, not a suspicion.\n\n\* `passed` - Passed\n\* `failed` - Failed\n\* `errored` - Errored\n\* `inconclusive` - Inconclusive"
            ),
        reason: zod
            .union([
                zod
                    .enum(['awaiting_data', 'unmeasurable', 'needs_manual_verification', 'no_fix_to_measure'])
                    .describe(
                        '\* `awaiting_data` - Awaiting Data\n\* `unmeasurable` - Unmeasurable\n\* `needs_manual_verification` - Needs Manual Verification\n\* `no_fix_to_measure` - No Fix To Measure'
                    ),
                zod.null(),
            ])
            .optional()
            .describe(
                'Required with `inconclusive`, and refused with any other outcome. `awaiting_data`: the data can still arrive (a rollout lag, a soak not complete, too few samples so far). `unmeasurable`: the data the check needs is not captured. `needs_manual_verification`: only a person or another environment can verify it. `no_fix_to_measure`: nothing was changed to fix the claim, so no window after a fix exists. A report resolved without a pull request still has a window that starts when it resolved.\n\n\* `awaiting_data` - Awaiting Data\n\* `unmeasurable` - Unmeasurable\n\* `needs_manual_verification` - Needs Manual Verification\n\* `no_fix_to_measure` - No Fix To Measure'
            ),
        explanation: zod
            .string()
            .max(signalsScoutRecordCheckResultBodyExplanationMax)
            .describe(
                'One or two sentences on what you looked at and what it showed. This is what a person reads on the report, so write it for them, with the numbers or entities you checked.'
            ),
        observed_value: zod
            .number()
            .nullish()
            .describe('The number you measured, when the check came down to one. Leave it out otherwise.'),
    })
    .describe('Request body for `scout-check-record-result`: the verdict on one dispatched report check.')

/**
 * Rewrite a report's title/summary, append a note or fresh evidence, set its suggested reviewers, and/or point it at another repository. Can target ANY of the project's inbox reports, not just scout-authored ones — so the edit is attributed to this scout. Reviewers and repository are how you rescue a report that surfaced routed to no one or against the wrong codebase: each replaces what the report holds and re-runs autostart, so a report that was missing a qualifying reviewer or a repository can open a draft PR. The response carries the repository the report holds after the edit, and the call fails when a repository it named did not land. Set `actionability` and/or `priority` (each with its explanation) when new evidence changed your judgment: each replaces the report's decision and re-runs autostart, without changing the report's inbox status. `tags` replaces the report's slug tags, and an omitted `tags` keeps them. Title/summary edits are best-effort: the pipeline may later re-research them. Set `supersedes_implementation` alongside a rewrite when the fix changed. Verified automated predecessor PRs close only after the replacement completes with verified open PRs.
 * @summary Edit an existing report for a run
 */
export const SignalsScoutEditReportParams = () => zod.object({
    project_id: zod
        .string()
        .describe(
            "Project ID of the project you're trying to access. To find the ID of the project, make a call to \/api\/projects\/."
        ),
    run_id: zod.string().describe('UUID of the `SignalScoutRun` bridge row.'),
})

export const signalsScoutEditReportBodyReviewerRetryReasonMax = 500

export const signalsScoutEditReportBodyReviewerOutcomeReasonMax = 500

export const signalsScoutEditReportBodyTitleMax = 300

export const signalsScoutEditReportBodySummaryMax = 20000

export const signalsScoutEditReportBodyAppendNoteMax = 10000

export const signalsScoutEditReportBodyAppendEvidenceItemDescriptionMax = 4000

export const signalsScoutEditReportBodyAppendEvidenceMax = 50

export const signalsScoutEditReportBodySuggestedReviewersItemGithubLoginMax = 200

export const signalsScoutEditReportBodySuggestedReviewersItemReasonMax = 500

export const signalsScoutEditReportBodySuggestedReviewersMax = 10

export const signalsScoutEditReportBodyChartsItemChartIdMax = 100

export const signalsScoutEditReportBodyChartsItemTitleMax = 200

export const signalsScoutEditReportBodyChartsItemCaptionMax = 500

export const signalsScoutEditReportBodyChartsMax = 20

export const signalsScoutEditReportBodyMetricsItemMetricIdMax = 100

export const signalsScoutEditReportBodyMetricsItemTitleMax = 200

export const signalsScoutEditReportBodyMetricsItemRoleDefault = `supporting`
export const signalsScoutEditReportBodyMetricsItemSeriesMax = 14

export const signalsScoutEditReportBodyMetricsItemValueFormatDefault = `number`
export const signalsScoutEditReportBodyMetricsItemUnitMax = 40

export const signalsScoutEditReportBodyMetricsItemCaptionMax = 500

export const signalsScoutEditReportBodyMetricsItemComparisonOneLabelMax = 40

export const signalsScoutEditReportBodyMetricsMax = 6

export const signalsScoutEditReportBodySuggestedPromptsItemMax = 200

export const signalsScoutEditReportBodySuggestedPromptsMax = 3

export const signalsScoutEditReportBodyLinksItemReasonMax = 500

export const signalsScoutEditReportBodyLinksMax = 10

export const signalsScoutEditReportBodySourceIssuesItemUrlMax = 500

export const signalsScoutEditReportBodySourceIssuesMax = 5

export const signalsScoutEditReportBodyTagsMax = 10

export const SignalsScoutEditReportBody = () => zod
    .object({
        expected_reviewers: zod
            .object({
                reviewers_id: zod
                    .string()
                    .nullable()
                    .describe('Current reviewer artefact ID, or null before the first list.'),
                corrections_id: zod
                    .string()
                    .nullable()
                    .describe('Current corrections artefact ID, or null before corrections are stored.'),
            })
            .optional()
            .describe(
                'Report reviewer_assignment.state read before selection began. Required when reviewer corrections are enabled.'
            ),
        reviewer_outcome: zod
            .enum(['selected', 'no_suitable_owner', 'lookup_failed'])
            .describe(
                '\* `selected` - Selected\n\* `no_suitable_owner` - No suitable owner\n\* `lookup_failed` - Lookup failed'
            )
            .optional()
            .describe(
                'A successful selection, a deliberate empty result, or an unavailable lookup. Defaults to selected when omitted.\n\n\* `selected` - Selected\n\* `no_suitable_owner` - No suitable owner\n\* `lookup_failed` - Lookup failed'
            ),
        reviewer_retry_reason: zod
            .string()
            .max(signalsScoutEditReportBodyReviewerRetryReasonMax)
            .optional()
            .describe('Reason the reviewer lookup failed.'),
        reviewer_outcome_reason: zod
            .string()
            .max(signalsScoutEditReportBodyReviewerOutcomeReasonMax)
            .optional()
            .describe(
                "Why no suitable owner exists, with `reviewer_outcome: no_suitable_owner`. Required to clear a report that already has suggested reviewers: without it the current reviewers stay and the response carries a warning. The reason is recorded in the report's work log."
            ),
        report_id: zod.string().describe('Id of the report to edit (must belong to this project).'),
        title: zod
            .string()
            .max(signalsScoutEditReportBodyTitleMax)
            .nullish()
            .describe(
                'Optional new title. Conventional-commit style (`type(scope): description`) renders with type\/scope styling. The pipeline may later re-research and overwrite it.'
            ),
        summary: zod
            .string()
            .max(signalsScoutEditReportBodySummaryMax)
            .nullish()
            .describe(
                'Optional new summary. Markdown is supported (headings, lists, code, links; images are not rendered); lead with one plain declarative sentence — it becomes the inbox card headline. A heading, or a bold label on a line of its own with a blank line above it, marks a section that a threaded Slack delivery splits into its own reply. The pipeline may later re-research and overwrite it.'
            ),
        append_note: zod
            .string()
            .max(signalsScoutEditReportBodyAppendNoteMax)
            .nullish()
            .describe(
                "Optional free-form note to append to the report's work log, attributed to this scout. Prefer it over rewriting a report you did not author: a note is additive and keeps the audit trail."
            ),
        corroboration_only: zod
            .boolean()
            .optional()
            .describe(
                "Set only when `append_note` confirms the finding with no new information. The first four confirmations stay in the work log as entries; later ones only raise the report's corroboration count. Other notes always stay in the work log."
            ),
        append_evidence: zod
            .array(
                zod
                    .object({
                        description: zod
                            .string()
                            .max(signalsScoutEditReportBodyAppendEvidenceItemDescriptionMax)
                            .describe(
                                'Prose for this observation. Embedded and rendered to the safety\/research surfaces.'
                            ),
                        source_id: zod
                            .string()
                            .describe(
                                'Stable id for this observation within the report (lets a later edit address it).'
                            ),
                    })
                    .describe('One observation backing an authored report — becomes a bound signal row on the report.')
            )
            .max(signalsScoutEditReportBodyAppendEvidenceMax)
            .nullish()
            .describe(
                "Optional observations to add to the report's evidence rail, each becoming a bound signal attributed to this scout — adds to the report's evidence rather than replacing it. Use this for a new observation a reader should be able to check, and `append_note` for commentary (the owning team knows, a deploy fixed it). The report's signal count and weight move with the appended rows. Emit plus every append share a cap of 50 signals per report."
            ),
        suggested_reviewers: zod
            .array(
                zod
                    .object({
                        github_login: zod
                            .string()
                            .max(signalsScoutEditReportBodySuggestedReviewersItemGithubLoginMax)
                            .optional()
                            .describe(
                                'GitHub login (case-insensitive, stored lowercased) — e.g. `octocat`, no `@`, no display name. Resolve one via `scout-members-list` (each member row carries a resolved `github_login`) or git history when you only have a name.'
                            ),
                        user_uuid: zod
                            .string()
                            .optional()
                            .describe(
                                "PostHog user UUID (e.g. from `scout-members-list`, or an entity's `created_by`). Use this when you know the PostHog user, whether or not they have a GitHub handle — every member is routable this way. Must be a concrete UUID; the `@me` alias is not valid here."
                            ),
                        reason: zod
                            .string()
                            .max(signalsScoutEditReportBodySuggestedReviewersItemReasonMax)
                            .nullish()
                            .describe(
                                "One sentence of evidence for WHY this person: what ties them to the affected surface (e.g. 'authored 4 of the last 10 commits touching products\/tracing\/mcp\/', 'human correction routed the prior tracing report to them'). Persisted on the report so the routing is auditable — always set it when you can name the evidence; 'precedent' alone is weak, prefer code-derived ownership."
                            ),
                    })
                    .describe(
                        "One suggested reviewer — identified by `github_login`, `user_uuid`, or both.\n\nA reviewer is a PostHog user, so a `user_uuid` only has to name an org member of this team: a\nmember with no linked GitHub account routes the report like anyone else. A `user_uuid` that\nisn't an org member of this team is rejected — so a reviewer is never silently dropped."
                    )
            )
            .max(signalsScoutEditReportBodySuggestedReviewersMax)
            .optional()
            .describe(
                'Optional reviewers to set on the report (each a `github_login` and\/or `user_uuid`), replacing any existing list. Use this to route a report that surfaced with no reviewer — it re-runs autostart, so a report that was missing a qualifying reviewer can now open a draft PR. An empty list clears automatic reviewers when correction rules are enabled. Pins, exclusions, and confirmed lists are preserved. Pass expected_reviewers from the report reviewer_assignment.state read before selection.'
            ),
        repository: zod
            .string()
            .nullish()
            .describe(
                "Optional repository to point the report at, as `owner\/repo` — the fix for a report that surfaced against the wrong codebase, so you correct it in place instead of filing a duplicate. It replaces the report's current target and re-runs autostart, so a report that had no repository to open a PR against can now open a draft PR. Omit the field to leave the target as it is, and pass the `NO_REPO` sentinel for a report where nothing under version control could change. The response's `repository` reads the target back from the report, and the call fails when the target you named did not land."
            ),
        charts: zod
            .array(
                zod
                    .object({
                        chart_id: zod
                            .string()
                            .max(signalsScoutEditReportBodyChartsItemChartIdMax)
                            .describe(
                                "Stable slug for this chart within the report (lowercase letters, numbers, underscores, hyphens; must start with a letter or number). Reference it from `summary` as a markdown link with a `chart:` target — `[Daily signups](chart:signups-drop)` — to place the chart at that point in the body. A chart you don't reference still renders, below the summary."
                            ),
                        title: zod
                            .string()
                            .max(signalsScoutEditReportBodyChartsItemTitleMax)
                            .describe('Short heading shown above the chart.'),
                        query: zod
                            .unknown()
                            .describe(
                                'The query node to render. `kind` must be `InsightVizNode` (an ad-hoc product analytics chart), `DataVisualizationNode` (a SQL series — a `HogQLQuery` source plus a `display`), or `SavedInsightNode` (an existing insight by `shortId`). Pin the window to absolute dates where the node supports it, so the reader sees the data you wrote about rather than whatever a relative range resolves to when they open the report.'
                            ),
                        caption: zod
                            .string()
                            .max(signalsScoutEditReportBodyChartsItemCaptionMax)
                            .nullish()
                            .describe('Optional one-line note on what to look at in the chart.'),
                        size: zod
                            .union([
                                zod
                                    .enum(['small', 'medium', 'large'])
                                    .describe('\* `small` - small\n\* `medium` - medium\n\* `large` - large'),
                                zod.null(),
                            ])
                            .optional()
                            .describe(
                                'How much height the chart gets: `small` for a single number or a short series, `medium` for an ordinary graph, `large` when there are rows or a grid to read (retention, paths, a wide breakdown). Leave it out unless the default looks wrong — the inbox sizes a chart from its query, and two charts referenced from the same paragraph sit side by side.\n\n\* `small` - small\n\* `medium` - medium\n\* `large` - large'
                            ),
                    })
                    .describe(
                        'One chart attached to a report — rendered in the inbox and referenceable from the summary.'
                    )
            )
            .max(signalsScoutEditReportBodyChartsMax)
            .nullish()
            .describe(
                "The full set of charts the report should show. Replaces the report's charts rather than adding to them, the way `summary` replaces the summary — so read the report first and send every chart you want kept. Omit the field (or send null) to leave the report's existing charts untouched, and send an empty list to take them all down."
            ),
        metrics: zod
            .array(
                zod
                    .object({
                        metric_id: zod
                            .string()
                            .max(signalsScoutEditReportBodyMetricsItemMetricIdMax)
                            .describe(
                                'Stable slug for this metric within the report: lowercase letters, numbers, underscores, and hyphens, starting with a letter or number.'
                            ),
                        title: zod
                            .string()
                            .max(signalsScoutEditReportBodyMetricsItemTitleMax)
                            .describe('Short human-readable label for the measurement.'),
                        kind: zod
                            .enum([
                                'affected_users',
                                'affected_sessions',
                                'occurrences',
                                'conversion_rate',
                                'error_rate',
                                'duration',
                                'revenue',
                                'custom',
                            ])
                            .describe(
                                '\* `affected_users` - affected_users\n\* `affected_sessions` - affected_sessions\n\* `occurrences` - occurrences\n\* `conversion_rate` - conversion_rate\n\* `error_rate` - error_rate\n\* `duration` - duration\n\* `revenue` - revenue\n\* `custom` - custom'
                            )
                            .describe(
                                'What the value measures, independent of how it is formatted or drawn.\n\n\* `affected_users` - affected_users\n\* `affected_sessions` - affected_sessions\n\* `occurrences` - occurrences\n\* `conversion_rate` - conversion_rate\n\* `error_rate` - error_rate\n\* `duration` - duration\n\* `revenue` - revenue\n\* `custom` - custom'
                            ),
                        role: zod
                            .enum(['primary', 'supporting'])
                            .describe('\* `primary` - primary\n\* `supporting` - supporting')
                            .default(signalsScoutEditReportBodyMetricsItemRoleDefault)
                            .describe(
                                "`primary` for the report's key observation, otherwise `supporting`.\n\n\* `primary` - primary\n\* `supporting` - supporting"
                            ),
                        value: zod
                            .number()
                            .nullish()
                            .describe(
                                'Latest saved snapshot, initially observed during authoring and replaced when a person opens the inbox or the report. Null means no snapshot is available to this viewer; it never means zero. The required live query remains the source of truth.'
                            ),
                        value_at: zod.iso
                            .datetime({ offset: true })
                            .nullish()
                            .describe('When the visible snapshot value was measured; null when value is null.'),
                        series: zod
                            .array(zod.number())
                            .max(signalsScoutEditReportBodyMetricsItemSeriesMax)
                            .nullish()
                            .describe(
                                'Trailing per-bucket values of the live query, oldest first, saved with the value snapshot so a list row can draw the trend without running the query; at most 14 points. Null when no snapshot series is available to this viewer.'
                            ),
                        value_format: zod
                            .enum(['number', 'count', 'percentage', 'percentage_scaled', 'duration', 'currency'])
                            .describe(
                                '\* `number` - number\n\* `count` - count\n\* `percentage` - percentage\n\* `percentage_scaled` - percentage_scaled\n\* `duration` - duration\n\* `currency` - currency'
                            )
                            .default(signalsScoutEditReportBodyMetricsItemValueFormatDefault)
                            .describe(
                                'How to format the numeric value; semantic meaning remains in kind. `percentage` uses percentage points, so 34 renders as 34%; `percentage_scaled` uses a 0–1 ratio, so 0.34 renders as 34%. Sessions and occurrences use count; duration uses duration with an ms\/s unit; revenue uses currency with an ISO currency unit.\n\n\* `number` - number\n\* `count` - count\n\* `percentage` - percentage\n\* `percentage_scaled` - percentage_scaled\n\* `duration` - duration\n\* `currency` - currency'
                            ),
                        unit: zod
                            .string()
                            .max(signalsScoutEditReportBodyMetricsItemUnitMax)
                            .nullish()
                            .describe('Optional short suffix or currency code, such as `users`, `ms`, or `USD`.'),
                        query: zod
                            .unknown()
                            .describe(
                                'Required when authoring: a live InsightVizNode wrapping one bounded TrendsQuery. Consumers derive a BoldNumber execution for the whole-window aggregate and an ActionsBar execution for longitudinal buckets. The query must produce exactly one output series and no more than 1000 estimated longitudinal points; one formula may combine up to ten event or action source series. An affected_users metric uses exactly one source with `math: dau`; never sum its per-bucket unique-user values. A response omits this on list or redacts it to null on detail when the viewer lacks access to the definition.'
                            ),
                        caption: zod
                            .string()
                            .max(signalsScoutEditReportBodyMetricsItemCaptionMax)
                            .nullish()
                            .describe(
                                'Optional context the tile cannot show, such as a filter that narrows the count or a caveat on the data. Omit it rather than restate the title, unit, or window.'
                            ),
                        comparison: zod
                            .union([
                                zod.object({
                                    value: zod
                                        .number()
                                        .describe('Baseline or previous value, formatted like the current value.'),
                                    label: zod
                                        .string()
                                        .max(signalsScoutEditReportBodyMetricsItemComparisonOneLabelMax)
                                        .describe('Short context for the comparison, such as `Previous period`.'),
                                }),
                                zod.null(),
                            ])
                            .optional()
                            .describe('Legacy optional comparison. New report metrics must omit it.'),
                    })
                    .describe('Authoring shape: unlike a read response, the live query cannot be absent or redacted.')
            )
            .max(signalsScoutEditReportBodyMetricsMax)
            .nullish()
            .describe(
                "The report's full impact-metric set, at most 6. Omit it or send null to keep the current set, send an empty list to clear it, or send the complete replacement. Mark one metric `primary` for the key observation and the rest `supporting`, for users, sessions, occurrences, conversion, latency, or revenue. Every metric needs a live `query`: an InsightVizNode wrapping one bounded TrendsQuery built only from EventsNode or ActionsNode sources, with at most 1000 estimated longitudinal points. An affected-users metric counts distinct people through one series with `math: dau`; never sum its buckets. A `value`\/`value_at` snapshot is only an optional cached fallback, and a metric without a query is invalid."
            ),
        suggested_prompts: zod
            .array(zod.string().max(signalsScoutEditReportBodySuggestedPromptsItemMax))
            .max(signalsScoutEditReportBodySuggestedPromptsMax)
            .nullish()
            .describe(
                "The full set of follow-up prompts (questions or next-step actions) the report should offer above its `Ask AI` box. Replaces the report's prompts rather than adding to them, so send every one you want kept. Omit the field (or send null) to leave them untouched, and send an empty list to take them down, which is what you want once a rewrite has left them pointing at the old report."
            ),
        links: zod
            .array(
                zod
                    .object({
                        kind: zod
                            .enum(['depends_on', 'part_of', 'follow_up_of', 'duplicate_of', 'recurrence_of'])
                            .describe(
                                '\* `depends_on` - Depends on\n\* `part_of` - Part of\n\* `follow_up_of` - Follow-up of\n\* `duplicate_of` - Duplicate of\n\* `recurrence_of` - Recurrence of'
                            )
                            .describe(
                                "How this report relates to `report_id`. `depends_on` for work that cannot land until the other report's fix does, `part_of` for one piece of a larger report, `follow_up_of` for work the other report left behind, `duplicate_of` for the same problem filed twice, and `recurrence_of` for a problem a resolved report already covered.\n\n\* `depends_on` - Depends on\n\* `part_of` - Part of\n\* `follow_up_of` - Follow-up of\n\* `duplicate_of` - Duplicate of\n\* `recurrence_of` - Recurrence of"
                            ),
                        report_id: zod
                            .string()
                            .describe('Id of the report to link to. Must be another report in this project.'),
                        reason: zod
                            .string()
                            .max(signalsScoutEditReportBodyLinksItemReasonMax)
                            .optional()
                            .describe('Optional one-line note on why the reports are linked this way.'),
                    })
                    .describe('One typed, directed link to write on the report being emitted or edited.')
            )
            .max(signalsScoutEditReportBodyLinksMax)
            .optional()
            .describe(
                "Typed, directed links from this report to others, recording how the work relates. Use `depends_on` when you split one finding into a stack and the second report's fix cannot land until the first one's does, so the order is recorded rather than left to a reader of the diffs. Additive: links join what the report already has rather than replacing them, and only this report gets a row, so link from the side the sentence starts at. Links of the same kind must stay acyclic and every report must be in this project."
            ),
        source_issues: zod
            .array(
                zod
                    .object({
                        url: zod
                            .string()
                            .max(signalsScoutEditReportBodySourceIssuesItemUrlMax)
                            .describe(
                                "The issue's URL, `https:\/\/github.com\/<owner>\/<repo>\/issues\/<number>`. Only GitHub issues are accepted today. Pull request URLs are rejected."
                            ),
                    })
                    .describe('One external issue the report is about.')
            )
            .max(signalsScoutEditReportBodySourceIssuesMax)
            .optional()
            .describe(
                'The GitHub issues this report is about, when the finding came from an issue tracker. Pass the issue whenever the report is about one, so the report links back to it: a GitHub issue signal for the same issue then joins this report instead of opening a second one. When the project turned on GitHub issue comments, the issue gets one comment that links the report once its GitHub source ingests the issue. At most 5 per call. Additive: issues join the ones the report already names, and an issue it already names is skipped. Only a newly added issue gets a comment.'
            ),
        tags: zod
            .array(zod.string())
            .max(signalsScoutEditReportBodyTagsMax)
            .nullish()
            .describe(
                "The report's full set of slug tags, at most 10. Replaces the report's tags rather than adding to them, so send every tag you want kept. Omit the field (or send null) to leave them untouched, and send an empty list to remove them. Reuse a slug the project already uses before you coin a new one."
            ),
        supersedes_implementation: zod
            .boolean()
            .optional()
            .describe(
                "Set this only when your rewrite changes what the fix should be: a different root cause, a different file or layer, a materially wider or narrower scope. More evidence for the same fix is not a reason, because the report's open pull request already implements it: put that in `append_note`. Setting it true records a replacement decision for a ready report. Policy and eligibility checks gate the replacement. The existing pull request closes only after a successful, verified replacement. Technical failures retry automatically; policy blocks wait for a new edit or research trigger. Only honored alongside a `title` or `summary` that actually changes, and only within the first four content revisions, including revisions that did not request replacement. When the flag is not applied, `warnings` says why."
            ),
        actionability: zod
            .union([
                zod
                    .enum(['immediately_actionable', 'requires_human_input', 'not_actionable'])
                    .describe(
                        '\* `immediately_actionable` - immediately_actionable\n\* `requires_human_input` - requires_human_input\n\* `not_actionable` - not_actionable'
                    ),
                zod.null(),
            ])
            .optional()
            .describe(
                "Optional new actionability call, for when new evidence changed your judgment. Replaces the report's actionability decision and re-runs autostart: `immediately_actionable` can open a draft PR, `requires_human_input` and `not_actionable` stop autostart from opening one. The report's inbox status does not change. Send it with `actionability_explanation`, and with `already_addressed` when the issue is handled, since the three replace the decision as one unit.\n\n\* `immediately_actionable` - immediately_actionable\n\* `requires_human_input` - requires_human_input\n\* `not_actionable` - not_actionable"
            ),
        actionability_explanation: zod
            .string()
            .nullish()
            .describe('2-3 sentence evidence-grounded justification for `actionability`. Required when you set it.'),
        already_addressed: zod
            .boolean()
            .nullish()
            .describe(
                'Whether the issue is already handled: fixed, or with a fix in flight. Part of the actionability decision, so it requires `actionability` and `actionability_explanation` too; omitted means false. Set it when a fix lands or starts, so autostart does not open a duplicate PR.'
            ),
        priority: zod
            .union([
                zod
                    .enum(['P0', 'P1', 'P2', 'P3', 'P4'])
                    .describe('\* `P0` - P0\n\* `P1` - P1\n\* `P2` - P2\n\* `P3` - P3\n\* `P4` - P4'),
                zod.null(),
            ])
            .optional()
            .describe(
                "Optional new priority (`P0`-`P4`), for when the issue escalated or eased. Replaces the report's priority and re-runs autostart, which needs a priority to open a draft PR. Requires `priority_explanation`.\n\n\* `P0` - P0\n\* `P1` - P1\n\* `P2` - P2\n\* `P3` - P3\n\* `P4` - P4"
            ),
        priority_explanation: zod
            .string()
            .nullish()
            .describe('2-3 sentence justification for `priority`. Required when `priority` is set.'),
    })
    .describe(
        "Request body for `edit-report`. Can target ANY of the team's inbox reports, not just scout-authored ones."
    )

/**
 * Return the findings a `SignalScoutRun` emitted to the inbox, newest first — one row per emit with its `description` (the finding text as surfaced), `severity`, and the deterministic `source_id` that joins back to the underlying signal. Lets a team and its agents see *what* a run surfaced without parsing `emitted_finding_ids` or scanning the signal store. Strictly team-scoped — a run UUID belonging to another team returns 404.
 * @summary List a run's emitted findings
 */
export const SignalsScoutRunsEmissionsParams = () => zod.object({
    project_id: zod
        .string()
        .describe(
            "Project ID of the project you're trying to access. To find the ID of the project, make a call to \/api\/projects\/."
        ),
    run_id: zod.string().describe('UUID of the `SignalScoutRun` bridge row.'),
})

/**
 * Best-effort reverse of the report -> signals link. For each finding the run emitted, resolve the inbox `SignalReport` (if any) its underlying signal grouped into by walking the deterministic `source_id` back through the signal store. `report` is null when the finding hasn't grouped into a report yet, was de-duplicated away, or its signal was deleted. Lets the scout UI surface which inbox report a finding contributed to — the reverse of the report's evidence list. Strictly team-scoped — a run UUID belonging to another team returns 404.
 * @summary List the inbox reports a run's findings linked to
 */
export const SignalsScoutRunsEmissionReportsParams = () => zod.object({
    project_id: zod
        .string()
        .describe(
            "Project ID of the project you're trying to access. To find the ID of the project, make a call to \/api\/projects\/."
        ),
    run_id: zod.string().describe('UUID of the `SignalScoutRun` bridge row.'),
})

/**
 * The second emit channel: author a complete `SignalReport` directly instead of emitting a weak signal. The report passes the safety judge, then surfaces at the status the scout's `actionability` call implies (or is suppressed). Backing `evidence` is written as bound signals so the report behaves like a pipeline report. Safe to retry: resending an emission returns the report the first call authored (`idempotent_replay` true) rather than a second one, keyed on `idempotency_key` or, without one, on the report's content. Use `reports` to find a report from an earlier run and `edit-report` to update it instead of authoring a near-duplicate.
 * @summary Author a full report for a run
 */
export const SignalsScoutEmitReportParams = () => zod.object({
    project_id: zod
        .string()
        .describe(
            "Project ID of the project you're trying to access. To find the ID of the project, make a call to \/api\/projects\/."
        ),
    run_id: zod.string().describe('UUID of the `SignalScoutRun` bridge row.'),
})

export const signalsScoutEmitReportBodyTitleMax = 300

export const signalsScoutEmitReportBodyEvidenceItemDescriptionMax = 4000

export const signalsScoutEmitReportBodyAlreadyAddressedDefault = false
export const signalsScoutEmitReportBodySuggestedReviewersItemGithubLoginMax = 200

export const signalsScoutEmitReportBodySuggestedReviewersItemReasonMax = 500

export const signalsScoutEmitReportBodySuggestedReviewersMax = 10

export const signalsScoutEmitReportBodyChartsItemChartIdMax = 100

export const signalsScoutEmitReportBodyChartsItemTitleMax = 200

export const signalsScoutEmitReportBodyChartsItemCaptionMax = 500

export const signalsScoutEmitReportBodyChartsMax = 20

export const signalsScoutEmitReportBodyMetricsItemMetricIdMax = 100

export const signalsScoutEmitReportBodyMetricsItemTitleMax = 200

export const signalsScoutEmitReportBodyMetricsItemRoleDefault = `supporting`
export const signalsScoutEmitReportBodyMetricsItemSeriesMax = 14

export const signalsScoutEmitReportBodyMetricsItemValueFormatDefault = `number`
export const signalsScoutEmitReportBodyMetricsItemUnitMax = 40

export const signalsScoutEmitReportBodyMetricsItemCaptionMax = 500

export const signalsScoutEmitReportBodyMetricsItemComparisonOneLabelMax = 40

export const signalsScoutEmitReportBodyMetricsMax = 6

export const signalsScoutEmitReportBodySuggestedPromptsItemMax = 200

export const signalsScoutEmitReportBodySuggestedPromptsMax = 3

export const signalsScoutEmitReportBodyLinksItemReasonMax = 500

export const signalsScoutEmitReportBodyLinksMax = 10

export const signalsScoutEmitReportBodySourceIssuesItemUrlMax = 500

export const signalsScoutEmitReportBodySourceIssuesMax = 5

export const signalsScoutEmitReportBodyTagsMax = 10

export const signalsScoutEmitReportBodyIdempotencyKeyMax = 200

export const SignalsScoutEmitReportBody = () => zod
    .object({
        title: zod
            .string()
            .max(signalsScoutEmitReportBodyTitleMax)
            .describe(
                'One-line report title the inbox shows. Conventional-commit style (`type(scope): description`, e.g. `fix(insights): missing series color`) renders with type\/scope styling.'
            ),
        summary: zod
            .string()
            .describe(
                'The report body the inbox shows. Markdown is supported (headings, lists, code, links; images are not rendered). Lead with one plain declarative sentence — the inbox card uses your first line verbatim as the headline (~140 chars, emphasis stripped), then renders the full markdown in the detail view. A heading, or a bold label on a line of its own with a blank line above it, marks a section that a threaded Slack delivery splits into its own reply.'
            ),
        evidence: zod
            .array(
                zod
                    .object({
                        description: zod
                            .string()
                            .max(signalsScoutEmitReportBodyEvidenceItemDescriptionMax)
                            .describe(
                                'Prose for this observation. Embedded and rendered to the safety\/research surfaces.'
                            ),
                        source_id: zod
                            .string()
                            .describe(
                                'Stable id for this observation within the report (lets a later edit address it).'
                            ),
                    })
                    .describe('One observation backing an authored report — becomes a bound signal row on the report.')
            )
            .min(1)
            .describe('The observations backing the report — each becomes a bound signal. At least one.'),
        actionability_explanation: zod
            .string()
            .describe('2-3 sentence evidence-grounded justification for the actionability call below.'),
        actionability: zod
            .enum(['immediately_actionable', 'requires_human_input', 'not_actionable'])
            .describe(
                '\* `immediately_actionable` - immediately_actionable\n\* `requires_human_input` - requires_human_input\n\* `not_actionable` - not_actionable'
            )
            .describe(
                "The scout's actionability call: `immediately_actionable` -> the report surfaces READY; `requires_human_input` -> PENDING_INPUT; `not_actionable` -> suppressed. A safety-judge failure suppresses the report regardless. A root cause you have not found is not human input: a report that names the evidence, the code surface, or a reproducible failure path is `immediately_actionable`, because investigating it is the action. Reserve `requires_human_input` for a report blocked on a decision only a person can make.\n\n\* `immediately_actionable` - immediately_actionable\n\* `requires_human_input` - requires_human_input\n\* `not_actionable` - not_actionable"
            ),
        already_addressed: zod
            .boolean()
            .default(signalsScoutEmitReportBodyAlreadyAddressedDefault)
            .describe(
                'Whether the issue is already being handled — fixed in recent changes, or with a fix in flight (an open PR, a recently active branch, an assigned \/ in-progress issue or agent task). Gates autostart of a scout report, so a wrong `false` opens a duplicate PR. Tracked separately.'
            ),
        repository: zod
            .string()
            .nullish()
            .describe(
                "Optional repo for opening a draft PR, by autostart of a scout report or by a person from the inbox. Pass `owner\/repo` whenever you can say where a fix would land. Omit the field when you can't, which triggers free-form selection across the team's repos (the slow path on a many-repo team). Keep the `NO_REPO` sentinel for the rare report where nothing under version control could change, since a skill body, a config file, or a doc still lives in a repo."
            ),
        priority: zod
            .union([
                zod
                    .enum(['P0', 'P1', 'P2', 'P3', 'P4'])
                    .describe('\* `P0` - P0\n\* `P1` - P1\n\* `P2` - P2\n\* `P3` - P3\n\* `P4` - P4'),
                zod.null(),
            ])
            .optional()
            .describe(
                'Optional priority (`P0`-`P4`). Required for autostart; pair with `priority_explanation`.\n\n\* `P0` - P0\n\* `P1` - P1\n\* `P2` - P2\n\* `P3` - P3\n\* `P4` - P4'
            ),
        priority_explanation: zod
            .string()
            .nullish()
            .describe('2-3 sentence justification for `priority`. Required when `priority` is set.'),
        suggested_reviewers: zod
            .array(
                zod
                    .object({
                        github_login: zod
                            .string()
                            .max(signalsScoutEmitReportBodySuggestedReviewersItemGithubLoginMax)
                            .optional()
                            .describe(
                                'GitHub login (case-insensitive, stored lowercased) — e.g. `octocat`, no `@`, no display name. Resolve one via `scout-members-list` (each member row carries a resolved `github_login`) or git history when you only have a name.'
                            ),
                        user_uuid: zod
                            .string()
                            .optional()
                            .describe(
                                "PostHog user UUID (e.g. from `scout-members-list`, or an entity's `created_by`). Use this when you know the PostHog user, whether or not they have a GitHub handle — every member is routable this way. Must be a concrete UUID; the `@me` alias is not valid here."
                            ),
                        reason: zod
                            .string()
                            .max(signalsScoutEmitReportBodySuggestedReviewersItemReasonMax)
                            .nullish()
                            .describe(
                                "One sentence of evidence for WHY this person: what ties them to the affected surface (e.g. 'authored 4 of the last 10 commits touching products\/tracing\/mcp\/', 'human correction routed the prior tracing report to them'). Persisted on the report so the routing is auditable — always set it when you can name the evidence; 'precedent' alone is weak, prefer code-derived ownership."
                            ),
                    })
                    .describe(
                        "One suggested reviewer — identified by `github_login`, `user_uuid`, or both.\n\nA reviewer is a PostHog user, so a `user_uuid` only has to name an org member of this team: a\nmember with no linked GitHub account routes the report like anyone else. A `user_uuid` that\nisn't an org member of this team is rejected — so a reviewer is never silently dropped."
                    )
            )
            .max(signalsScoutEmitReportBodySuggestedReviewersMax)
            .optional()
            .describe(
                "Optional reviewers to route the report to (each a `github_login` and\/or `user_uuid`). This is the primary way a report reaches a human — the inbox floats a reviewer's own reports to the top of their inbox even when no PR is involved — so set it whenever you can name a plausible owner. On a scout report it also gates autostart: a PR opens only if at least one reviewer clears their autonomy threshold. A report a person files never autostarts."
            ),
        charts: zod
            .array(
                zod
                    .object({
                        chart_id: zod
                            .string()
                            .max(signalsScoutEmitReportBodyChartsItemChartIdMax)
                            .describe(
                                "Stable slug for this chart within the report (lowercase letters, numbers, underscores, hyphens; must start with a letter or number). Reference it from `summary` as a markdown link with a `chart:` target — `[Daily signups](chart:signups-drop)` — to place the chart at that point in the body. A chart you don't reference still renders, below the summary."
                            ),
                        title: zod
                            .string()
                            .max(signalsScoutEmitReportBodyChartsItemTitleMax)
                            .describe('Short heading shown above the chart.'),
                        query: zod
                            .unknown()
                            .describe(
                                'The query node to render. `kind` must be `InsightVizNode` (an ad-hoc product analytics chart), `DataVisualizationNode` (a SQL series — a `HogQLQuery` source plus a `display`), or `SavedInsightNode` (an existing insight by `shortId`). Pin the window to absolute dates where the node supports it, so the reader sees the data you wrote about rather than whatever a relative range resolves to when they open the report.'
                            ),
                        caption: zod
                            .string()
                            .max(signalsScoutEmitReportBodyChartsItemCaptionMax)
                            .nullish()
                            .describe('Optional one-line note on what to look at in the chart.'),
                        size: zod
                            .union([
                                zod
                                    .enum(['small', 'medium', 'large'])
                                    .describe('\* `small` - small\n\* `medium` - medium\n\* `large` - large'),
                                zod.null(),
                            ])
                            .optional()
                            .describe(
                                'How much height the chart gets: `small` for a single number or a short series, `medium` for an ordinary graph, `large` when there are rows or a grid to read (retention, paths, a wide breakdown). Leave it out unless the default looks wrong — the inbox sizes a chart from its query, and two charts referenced from the same paragraph sit side by side.\n\n\* `small` - small\n\* `medium` - medium\n\* `large` - large'
                            ),
                    })
                    .describe(
                        'One chart attached to a report — rendered in the inbox and referenceable from the summary.'
                    )
            )
            .max(signalsScoutEmitReportBodyChartsMax)
            .optional()
            .describe(
                'Optional charts to attach to the report — the inbox renders them inline, so a metric move is something the reader sees rather than a number they take on trust. Attach one whenever the finding rests on a trend, a spike, or a comparison you already queried. Reference a chart from `summary` as `[label](chart:<chart_id>)` to place it in the body; an unreferenced chart renders below the summary.'
            ),
        metrics: zod
            .array(
                zod
                    .object({
                        metric_id: zod
                            .string()
                            .max(signalsScoutEmitReportBodyMetricsItemMetricIdMax)
                            .describe(
                                'Stable slug for this metric within the report: lowercase letters, numbers, underscores, and hyphens, starting with a letter or number.'
                            ),
                        title: zod
                            .string()
                            .max(signalsScoutEmitReportBodyMetricsItemTitleMax)
                            .describe('Short human-readable label for the measurement.'),
                        kind: zod
                            .enum([
                                'affected_users',
                                'affected_sessions',
                                'occurrences',
                                'conversion_rate',
                                'error_rate',
                                'duration',
                                'revenue',
                                'custom',
                            ])
                            .describe(
                                '\* `affected_users` - affected_users\n\* `affected_sessions` - affected_sessions\n\* `occurrences` - occurrences\n\* `conversion_rate` - conversion_rate\n\* `error_rate` - error_rate\n\* `duration` - duration\n\* `revenue` - revenue\n\* `custom` - custom'
                            )
                            .describe(
                                'What the value measures, independent of how it is formatted or drawn.\n\n\* `affected_users` - affected_users\n\* `affected_sessions` - affected_sessions\n\* `occurrences` - occurrences\n\* `conversion_rate` - conversion_rate\n\* `error_rate` - error_rate\n\* `duration` - duration\n\* `revenue` - revenue\n\* `custom` - custom'
                            ),
                        role: zod
                            .enum(['primary', 'supporting'])
                            .describe('\* `primary` - primary\n\* `supporting` - supporting')
                            .default(signalsScoutEmitReportBodyMetricsItemRoleDefault)
                            .describe(
                                "`primary` for the report's key observation, otherwise `supporting`.\n\n\* `primary` - primary\n\* `supporting` - supporting"
                            ),
                        value: zod
                            .number()
                            .nullish()
                            .describe(
                                'Latest saved snapshot, initially observed during authoring and replaced when a person opens the inbox or the report. Null means no snapshot is available to this viewer; it never means zero. The required live query remains the source of truth.'
                            ),
                        value_at: zod.iso
                            .datetime({ offset: true })
                            .nullish()
                            .describe('When the visible snapshot value was measured; null when value is null.'),
                        series: zod
                            .array(zod.number())
                            .max(signalsScoutEmitReportBodyMetricsItemSeriesMax)
                            .nullish()
                            .describe(
                                'Trailing per-bucket values of the live query, oldest first, saved with the value snapshot so a list row can draw the trend without running the query; at most 14 points. Null when no snapshot series is available to this viewer.'
                            ),
                        value_format: zod
                            .enum(['number', 'count', 'percentage', 'percentage_scaled', 'duration', 'currency'])
                            .describe(
                                '\* `number` - number\n\* `count` - count\n\* `percentage` - percentage\n\* `percentage_scaled` - percentage_scaled\n\* `duration` - duration\n\* `currency` - currency'
                            )
                            .default(signalsScoutEmitReportBodyMetricsItemValueFormatDefault)
                            .describe(
                                'How to format the numeric value; semantic meaning remains in kind. `percentage` uses percentage points, so 34 renders as 34%; `percentage_scaled` uses a 0–1 ratio, so 0.34 renders as 34%. Sessions and occurrences use count; duration uses duration with an ms\/s unit; revenue uses currency with an ISO currency unit.\n\n\* `number` - number\n\* `count` - count\n\* `percentage` - percentage\n\* `percentage_scaled` - percentage_scaled\n\* `duration` - duration\n\* `currency` - currency'
                            ),
                        unit: zod
                            .string()
                            .max(signalsScoutEmitReportBodyMetricsItemUnitMax)
                            .nullish()
                            .describe('Optional short suffix or currency code, such as `users`, `ms`, or `USD`.'),
                        query: zod
                            .unknown()
                            .describe(
                                'Required when authoring: a live InsightVizNode wrapping one bounded TrendsQuery. Consumers derive a BoldNumber execution for the whole-window aggregate and an ActionsBar execution for longitudinal buckets. The query must produce exactly one output series and no more than 1000 estimated longitudinal points; one formula may combine up to ten event or action source series. An affected_users metric uses exactly one source with `math: dau`; never sum its per-bucket unique-user values. A response omits this on list or redacts it to null on detail when the viewer lacks access to the definition.'
                            ),
                        caption: zod
                            .string()
                            .max(signalsScoutEmitReportBodyMetricsItemCaptionMax)
                            .nullish()
                            .describe(
                                'Optional context the tile cannot show, such as a filter that narrows the count or a caveat on the data. Omit it rather than restate the title, unit, or window.'
                            ),
                        comparison: zod
                            .union([
                                zod.object({
                                    value: zod
                                        .number()
                                        .describe('Baseline or previous value, formatted like the current value.'),
                                    label: zod
                                        .string()
                                        .max(signalsScoutEmitReportBodyMetricsItemComparisonOneLabelMax)
                                        .describe('Short context for the comparison, such as `Previous period`.'),
                                }),
                                zod.null(),
                            ])
                            .optional()
                            .describe('Legacy optional comparison. New report metrics must omit it.'),
                    })
                    .describe('Authoring shape: unlike a read response, the live query cannot be absent or redacted.')
            )
            .max(signalsScoutEmitReportBodyMetricsMax)
            .optional()
            .describe(
                'Optional typed impact measurements, at most 6. Mark one metric `primary` for the key observation and the rest `supporting`, for users, sessions, occurrences, conversion, latency, or revenue. Every metric needs a live `query`: an InsightVizNode wrapping one bounded TrendsQuery built only from EventsNode or ActionsNode sources, with at most 1000 estimated longitudinal points. An affected-users metric counts distinct people through one series with `math: dau`; never sum its buckets. A `value`\/`value_at` snapshot is only an optional cached fallback, and a metric without a query is invalid.'
            ),
        suggested_prompts: zod
            .array(zod.string().max(signalsScoutEmitReportBodySuggestedPromptsItemMax))
            .max(signalsScoutEmitReportBodySuggestedPromptsMax)
            .optional()
            .describe(
                "Optional follow-up prompts to offer above the report's `Ask AI` box: questions to ask, or next-step actions to request (e.g. carrying out the report's recommendation). The reader clicks one to fill the box with it, then sends or edits it. Write the prompts your own research left open, phrased as the reader would send them."
            ),
        links: zod
            .array(
                zod
                    .object({
                        kind: zod
                            .enum(['depends_on', 'part_of', 'follow_up_of', 'duplicate_of', 'recurrence_of'])
                            .describe(
                                '\* `depends_on` - Depends on\n\* `part_of` - Part of\n\* `follow_up_of` - Follow-up of\n\* `duplicate_of` - Duplicate of\n\* `recurrence_of` - Recurrence of'
                            )
                            .describe(
                                "How this report relates to `report_id`. `depends_on` for work that cannot land until the other report's fix does, `part_of` for one piece of a larger report, `follow_up_of` for work the other report left behind, `duplicate_of` for the same problem filed twice, and `recurrence_of` for a problem a resolved report already covered.\n\n\* `depends_on` - Depends on\n\* `part_of` - Part of\n\* `follow_up_of` - Follow-up of\n\* `duplicate_of` - Duplicate of\n\* `recurrence_of` - Recurrence of"
                            ),
                        report_id: zod
                            .string()
                            .describe('Id of the report to link to. Must be another report in this project.'),
                        reason: zod
                            .string()
                            .max(signalsScoutEmitReportBodyLinksItemReasonMax)
                            .optional()
                            .describe('Optional one-line note on why the reports are linked this way.'),
                    })
                    .describe('One typed, directed link to write on the report being emitted or edited.')
            )
            .max(signalsScoutEmitReportBodyLinksMax)
            .optional()
            .describe(
                'Typed, directed links from the new report to reports that already exist. Send them here, not in a later `edit-report` call, because autostart reads them when the report is created: a `duplicate_of` link to a report that already has a pull request, or a `depends_on` link to a report with no pull request yet, stops a second draft PR. Only the new report gets a row, so link from the side the sentence starts at. Links of the same kind must stay acyclic and every report must be in this project.'
            ),
        source_issues: zod
            .array(
                zod
                    .object({
                        url: zod
                            .string()
                            .max(signalsScoutEmitReportBodySourceIssuesItemUrlMax)
                            .describe(
                                "The issue's URL, `https:\/\/github.com\/<owner>\/<repo>\/issues\/<number>`. Only GitHub issues are accepted today. Pull request URLs are rejected."
                            ),
                    })
                    .describe('One external issue the report is about.')
            )
            .max(signalsScoutEmitReportBodySourceIssuesMax)
            .optional()
            .describe(
                'The GitHub issues this report is about, when the finding came from an issue tracker. Pass the issue whenever the report is about one, so the report links back to it: a GitHub issue signal for the same issue then joins this report instead of opening a second one. When the project turned on GitHub issue comments, the issue gets one comment that links the report once its GitHub source ingests the issue. At most 5 per call.'
            ),
        tags: zod
            .array(zod.string())
            .max(signalsScoutEmitReportBodyTagsMax)
            .optional()
            .describe(
                'Optional slug tags that group the report with related ones, at most 10. Write lowercase kebab-case slugs that name the category of the report (`cost-spike`, `tracking-gap`), not the specific entity. Reuse a slug the project already uses before you coin a new one. Near-miss formats are normalized to slugs, and a tag that is empty or longer than 50 characters after normalization is rejected.'
            ),
        idempotency_key: zod
            .string()
            .max(signalsScoutEmitReportBodyIdempotencyKeyMax)
            .nullish()
            .describe(
                "Optional name for this emission, unique within a scout's run or within a person's own reports. Reuse it verbatim to retry a call whose outcome you don't know (a timeout, a dropped connection): the retry returns the report the first call authored, with `idempotent_replay` true, instead of a second report. Omit it and the report's own content is the key, which covers a retry of the identical call — pass one when a retry might reword the report."
            ),
    })
    .describe(
        'Request body for the scout `emit-report` action and the inbox report `create` action. A scout run is\ntaken from the URL path; a person is the authenticated caller.'
    )

/**
 * Fire `emit_signal` with `source_product = signals_scout`. The `finding_id` is baked into the deterministic `Signal.source_id = run:<id>:finding:<id>` for traceability, but this is NOT idempotent — a second call with the same `finding_id` emits a second signal, so do not retry an emit that may have already succeeded.
 * @summary Emit a finding for a run
 */
export const SignalsScoutEmitSignalParams = () => zod.object({
    project_id: zod
        .string()
        .describe(
            "Project ID of the project you're trying to access. To find the ID of the project, make a call to \/api\/projects\/."
        ),
    run_id: zod.string().describe('UUID of the `SignalScoutRun` bridge row.'),
})

export const signalsScoutEmitSignalBodyDescriptionMax = 50000

export const signalsScoutEmitSignalBodyEvidenceMax = 20

export const signalsScoutEmitSignalBodyTagsItemMax = 50

export const signalsScoutEmitSignalBodyTagsMax = 10

export const signalsScoutEmitSignalBodyFindingIdMax = 100

export const SignalsScoutEmitSignalBody = () => zod
    .object({
        description: zod
            .string()
            .max(signalsScoutEmitSignalBodyDescriptionMax)
            .describe("Canonical evidence-bundle prose. Becomes the signal's `description`."),
        evidence: zod
            .array(
                zod
                    .object({
                        source_product: zod
                            .string()
                            .describe(
                                'Source the citation came from (`error_tracking`, `session_replay`, `logs`, ...).'
                            ),
                        summary: zod
                            .string()
                            .describe('One-sentence prose about why this evidence supports the finding.'),
                        entity_id: zod
                            .string()
                            .nullish()
                            .describe('Optional ID of the cited entity (issue id, recording id, log query id).'),
                    })
                    .describe('One citation attached to a finding. Mirrors `SignalsScoutEvidenceEntry`.')
            )
            .max(signalsScoutEmitSignalBodyEvidenceMax)
            .describe('Citations supporting the finding. Capped at 20 entries.'),
        hypothesis: zod.string().nullish().describe('Optional one-line hypothesis the finding tests.'),
        severity: zod
            .union([
                zod
                    .enum(['P0', 'P1', 'P2', 'P3', 'P4'])
                    .describe('\* `P0` - P0\n\* `P1` - P1\n\* `P2` - P2\n\* `P3` - P3\n\* `P4` - P4'),
                zod.null(),
            ])
            .optional()
            .describe(
                'Optional severity tag — one of P0, P1, P2, P3, P4. Informational only.\n\n\* `P0` - P0\n\* `P1` - P1\n\* `P2` - P2\n\* `P3` - P3\n\* `P4` - P4'
            ),
        dedupe_keys: zod
            .array(zod.string())
            .optional()
            .describe('Optional keys for downstream dedupe (e.g. `error_tracking_issue:<id>`).'),
        tags: zod
            .array(zod.string().max(signalsScoutEmitSignalBodyTagsItemMax))
            .max(signalsScoutEmitSignalBodyTagsMax)
            .optional()
            .describe(
                "Optional category tags as lowercase kebab-case slugs (e.g. `cost-spike`, `silent-failure`), max 10. Reuse the vocabulary in your `tags:<domain>:taxonomy` scratchpad entry when a tag fits; coin a new slug when a genuinely new category emerges. Near-miss formats are normalized to slugs; persisted in the signal's `extra.tags` and on the emission row."
            ),
        time_range: zod
            .union([
                zod.object({
                    date_from: zod.string().describe("ISO-8601 inclusive lower bound for the finding's window."),
                    date_to: zod.string().describe("ISO-8601 inclusive upper bound for the finding's window."),
                }),
                zod.null(),
            ])
            .optional()
            .describe('Optional time window the finding refers to.'),
        mcp_trace_id: zod.string().nullish().describe('Optional MCP trace id for cross-system debugging.'),
        finding_id: zod
            .string()
            .max(signalsScoutEmitSignalBodyFindingIdMax)
            .nullish()
            .describe(
                "Stable id for this finding, baked into the signal's source_id for traceability. NOT a dedupe key — re-emitting the same id creates another signal."
            ),
    })
    .describe('Request body for `emit-finding`. Run attribution is taken from the URL path.')

/**
 * Load one page in a real browser and return what makes it slow — most usefully the element the browser chose as the Largest Contentful Paint, and where the LCP time went. Field data says a route is slow; this says which element and why, so a finding can name it instead of guessing from source. Restricted to public PostHog pages: the browser signs in to nothing, so a page behind a login would report the login screen's numbers. One throttled cold load is not a p75 over real users — corroborate a field finding with it, never replace one. Capped at 5 audits per run.
 * @summary Run a Lighthouse audit for a run
 */
export const SignalsScoutLighthouseAuditParams = () => zod.object({
    project_id: zod
        .string()
        .describe(
            "Project ID of the project you're trying to access. To find the ID of the project, make a call to \/api\/projects\/."
        ),
    run_id: zod.string().describe('UUID of the `SignalScoutRun` bridge row.'),
})

export const signalsScoutLighthouseAuditBodyUrlMax = 2000

export const signalsScoutLighthouseAuditBodyFormFactorDefault = `desktop`

export const SignalsScoutLighthouseAuditBody = () => zod
    .object({
        url: zod
            .url()
            .max(signalsScoutLighthouseAuditBodyUrlMax)
            .describe(
                "The page to audit. Must be an https url on an allowed host — public PostHog pages only. Pages behind a login cannot be audited: the browser signs in to nothing, so it would measure the login screen and report its numbers as the page's. A url that redirects off the allowed hosts is rejected for the same reason."
            ),
        form_factor: zod
            .enum(['desktop', 'mobile'])
            .describe('\* `desktop` - desktop\n\* `mobile` - mobile')
            .default(signalsScoutLighthouseAuditBodyFormFactorDefault)
            .describe(
                'Which device profile to emulate. Desktop and mobile produce different numbers, so audit the one whose field data you are explaining.\n\n\* `desktop` - desktop\n\* `mobile` - mobile'
            ),
    })
    .describe('Request body for `scout-lighthouse-audit`: one page, one device profile.')

/**
 * Submit the assigned Monitoring check's evidence and verdict while the scout is running. Only the owning Monitoring scout can call this endpoint. The server derives the check, attempt, definition, and fixed window from the run. Validation errors record nothing: correct the fields and retry in the same run. An identical accepted submission is idempotent. This records an evaluation and leaves the report in Monitoring.
 * @summary Submit the result of an authored Monitoring check
 */
export const SignalsScoutSubmitMonitoringResultParams = () => zod.object({
    project_id: zod
        .string()
        .describe(
            "Project ID of the project you're trying to access. To find the ID of the project, make a call to \/api\/projects\/."
        ),
    run_id: zod.string().describe('UUID of the `SignalScoutRun` bridge row.'),
})

export const signalsScoutSubmitMonitoringResultBodyEvidenceReasonMax = 2000

export const signalsScoutSubmitMonitoringResultBodyExplanationMax = 16000

export const signalsScoutSubmitMonitoringResultBodyEvidenceRefsMax = 50

export const SignalsScoutSubmitMonitoringResultBody = () => zod.object({
    evidence_status: zod
        .enum(['sufficient', 'insufficient', 'unsupported', 'errored'])
        .describe(
            '\* `sufficient` - Sufficient\n\* `insufficient` - Insufficient\n\* `unsupported` - Unsupported\n\* `errored` - Errored'
        )
        .describe(
            'Whether the fixed-window evidence is sufficient, insufficient, unsupported, or errored.\n\n\* `sufficient` - Sufficient\n\* `insufficient` - Insufficient\n\* `unsupported` - Unsupported\n\* `errored` - Errored'
        ),
    evidence_reason: zod
        .string()
        .min(1)
        .max(signalsScoutSubmitMonitoringResultBodyEvidenceReasonMax)
        .describe('Explain why the evidence supports this qualification. Must not be blank.'),
    expectation_matches: zod
        .boolean()
        .nullable()
        .describe(
            'Whether the authored expectation holds: a boolean for sufficient evidence, null for unsupported or errored evidence.'
        ),
    explanation: zod
        .string()
        .min(1)
        .max(signalsScoutSubmitMonitoringResultBodyExplanationMax)
        .describe("Explain the conclusion using evidence from the assignment's fixed window."),
    evidence_refs: zod
        .array(zod.string().min(1))
        .max(signalsScoutSubmitMonitoringResultBodyEvidenceRefsMax)
        .describe('Evidence references supporting the conclusion, or an empty list when none are available.'),
})

/**
 * The structured-output channel: record schema-validated records this run produced. Opt-in via the scout config's `structured_output_schema` (a JSON Schema describing one record) — without it the call fails closed, as it does for a dry-run scout (emit off). All-or-nothing: any invalid record fails the whole call with nothing written, so fix and resubmit the batch. Each accepted record lands in the project's event stream as a `$scout_structured_output` event — query them like any event (insights, SQL over `events`). Recording is idempotent: event ids are deterministic, so resubmitting an identical batch (e.g. retrying after a 503) cannot double-count.
 * @summary Record structured output for a run
 */
export const SignalsScoutRecordOutputParams = () => zod.object({
    project_id: zod
        .string()
        .describe(
            "Project ID of the project you're trying to access. To find the ID of the project, make a call to \/api\/projects\/."
        ),
    run_id: zod.string().describe('UUID of the `SignalScoutRun` bridge row.'),
})

export const signalsScoutRecordOutputBodyRecordsItemSubjectMax = 200

export const signalsScoutRecordOutputBodyRecordsMax = 100

export const SignalsScoutRecordOutputBody = () => zod
    .object({
        records: zod
            .array(
                zod
                    .object({
                        payload: zod
                            .record(zod.string(), zod.unknown())
                            .describe(
                                "The record itself, as a JSON object. Must validate against the scout config's `structured_output_schema` (shown in the run prompt); any invalid record fails the whole call with nothing written."
                            ),
                        subject: zod
                            .string()
                            .max(signalsScoutRecordOutputBodyRecordsItemSubjectMax)
                            .nullish()
                            .describe(
                                "Optional key naming what this record is about — a report id, URL, account key — so per-entity lookups don't need to parse `payload`. Omit for a run-level record."
                            ),
                    })
                    .describe('One record submitted through `scout-record-output`.')
            )
            .min(1)
            .max(signalsScoutRecordOutputBodyRecordsMax)
            .describe(
                "Records to record, each validated against the scout config's `structured_output_schema`. All-or-nothing: if any record fails validation, nothing is written and the error names the failing records. Capped at 100 per call; batch per-entity judgments rather than calling once per record."
            ),
    })
    .describe('Request body for `scout-record-output`: a batch of schema-validated records.')

/**
 * Stop a check that is no longer worth running — the claim it re-measures has changed, or a better check replaces it. Results it already recorded stay on the report. A check that has already finished cannot be cancelled.
 * @summary Cancel a follow-up check
 */
export const SignalsScoutReportCheckCancelParams = () => zod.object({
    project_id: zod
        .string()
        .describe(
            "Project ID of the project you're trying to access. To find the ID of the project, make a call to \/api\/projects\/."
        ),
    run_id: zod.string().describe('UUID of the `SignalScoutRun` bridge row.'),
})

export const SignalsScoutReportCheckCancelBody = () => zod
    .object({
        check_id: zod.string().describe('The check to stop. Its recorded results stay on the report.'),
    })
    .describe('Request body for `scout-report-check-cancel`.')

/**
 * Schedule a re-measurement of a report's claim, so whether the fix held becomes a stored fact instead of something a future run has to remember to look for. A `metric_threshold` check runs one bounded Trends query and compares the result. An `agent` check runs a scout instead, for a claim no single number settles.
 * @summary Write a follow-up check on a report
 */
export const SignalsScoutReportCheckCreateParams = () => zod.object({
    project_id: zod
        .string()
        .describe(
            "Project ID of the project you're trying to access. To find the ID of the project, make a call to \/api\/projects\/."
        ),
    run_id: zod.string().describe('UUID of the `SignalScoutRun` bridge row.'),
})

export const signalsScoutReportCheckCreateBodyTitleMax = 200

export const signalsScoutReportCheckCreateBodyRationaleMax = 2000

export const signalsScoutReportCheckCreateBodyConfigOneOneMonitoringOnePurposeDefault = `expectation`
export const signalsScoutReportCheckCreateBodyConfigOneOneMonitoringOneReferencePeriodMinutesExclusiveMin = 0
export const signalsScoutReportCheckCreateBodyConfigOneOneMonitoringOneReferencePeriodMinutesMax = 527040

export const signalsScoutReportCheckCreateBodyConfigOneOneMonitoringOneBaselinePeriodMinutesOneExclusiveMin = 0
export const signalsScoutReportCheckCreateBodyConfigOneOneMonitoringOneBaselinePeriodMinutesOneMax = 527040

export const signalsScoutReportCheckCreateBodyConfigOneOneUnitOneMax = 40

export const signalsScoutReportCheckCreateBodyConfigOneTwoInstructionsMax = 2000

export const signalsScoutReportCheckCreateBodyConfigOneTwoSkillNameOneMax = 200

export const signalsScoutReportCheckCreateBodyConfigOneTwoProbeHintsMax = 5

export const signalsScoutReportCheckCreateBodyRunIntervalMinutesMin = 360
export const signalsScoutReportCheckCreateBodyRunIntervalMinutesMax = 129600

export const signalsScoutReportCheckCreateBodyRunsRemainingMax = 10

export const SignalsScoutReportCheckCreateBody = () => zod
    .object({
        title: zod
            .string()
            .max(signalsScoutReportCheckCreateBodyTitleMax)
            .describe('Short label for the expectation, e.g. `Checkout 500s stay below 10 a day`.'),
        rationale: zod
            .string()
            .max(signalsScoutReportCheckCreateBodyRationaleMax)
            .optional()
            .describe('Why the check is worth running.'),
        kind: zod
            .enum(['metric_threshold', 'agent'])
            .describe('\* `metric_threshold` - Metric Threshold\n\* `agent` - Agent')
            .describe('How the check is evaluated.\n\n\* `metric_threshold` - Metric Threshold\n\* `agent` - Agent'),
        config: zod
            .union([
                zod
                    .object({
                        metric_id: zod
                            .union([zod.string(), zod.null()])
                            .optional()
                            .describe(
                                "Identifier of a metric on the report whose query this check measures. The metric's query is copied into `query` when the check is created."
                            ),
                        query: zod
                            .union([zod.record(zod.string(), zod.unknown()), zod.null()])
                            .optional()
                            .describe(
                                'Live InsightVizNode wrapping one TrendsQuery: supplied by the caller, or copied from the named metric when the check is created. `dateRange.date_from` must be a relative window such as `-13d`, and `date_to` must be empty, so the check measures the days before each run rather than the days before it was written. The query must produce exactly one output series: use one event or action series, or combine up to ten of them with exactly one formula. Use no breakdown and no compare mode. A `trendsFilter.display` of `Metric` turns compare mode on, so `metricShowChange` is switched off for you unless `metricSummary` is `latest`, which keeps compare mode off already.'
                            ),
                        monitoring: zod
                            .union([
                                zod.object({
                                    purpose: zod
                                        .enum(['expectation', 'minimum_evidence'])
                                        .default(
                                            signalsScoutReportCheckCreateBodyConfigOneOneMonitoringOnePurposeDefault
                                        )
                                        .describe(
                                            '`expectation` evaluates whether the implementation met its target. `minimum_evidence` checks a fixed minimum sample count: meeting it passes the guard; missing it is inconclusive and requires assessment, never an implementation failure. Use a positive whole-number `gte` target on one unsampled raw count.'
                                        ),
                                    reference_period_minutes: zod
                                        .number()
                                        .gt(
                                            signalsScoutReportCheckCreateBodyConfigOneOneMonitoringOneReferencePeriodMinutesExclusiveMin
                                        )
                                        .max(
                                            signalsScoutReportCheckCreateBodyConfigOneOneMonitoringOneReferencePeriodMinutesMax
                                        )
                                        .describe(
                                            'The period the comparison target describes, in minutes. Independent of the soak and run schedule.'
                                        ),
                                    threshold_scaling: zod
                                        .enum(['linear', 'fixed'])
                                        .describe(
                                            'How the target applies to a measurement from Monitoring start to the observation time. `linear` multiplies the target by elapsed minutes \/ reference_period_minutes and requires an additive event count or property sum. `fixed` keeps the target unchanged, including for rates and averages. This definition does not enable Monitoring execution.'
                                        ),
                                    baseline_period_minutes: zod
                                        .union([
                                            zod
                                                .number()
                                                .gt(
                                                    signalsScoutReportCheckCreateBodyConfigOneOneMonitoringOneBaselinePeriodMinutesOneExclusiveMin
                                                )
                                                .max(
                                                    signalsScoutReportCheckCreateBodyConfigOneOneMonitoringOneBaselinePeriodMinutesOneMax
                                                ),
                                            zod.null(),
                                        ])
                                        .optional()
                                        .describe(
                                            'The actual period measured by baseline_value, in minutes. Required when a baseline is supplied.'
                                        ),
                                }),
                                zod.null(),
                            ])
                            .optional()
                            .describe(
                                "Optional Monitoring measurement definition, available only with the organization's Monitoring rollout. Measurements cover Monitoring start through the observation time. Omit for existing whole-window checks."
                            ),
                        comparison: zod
                            .object({
                                operator: zod.enum(['lte', 'gte', 'between']).describe('`lte`, `gte`, or `between`.'),
                                value: zod
                                    .union([zod.number(), zod.null()])
                                    .optional()
                                    .describe('The bound for `lte` and `gte`; unused by `between`.'),
                                bounds: zod
                                    .union([
                                        zod.object({
                                            lower: zod.number(),
                                            upper: zod.number(),
                                        }),
                                        zod.null(),
                                    ])
                                    .optional()
                                    .describe('The inclusive range for `between`; unused by `lte` and `gte`.'),
                            })
                            .describe('What the measured value must satisfy to pass.'),
                        baseline_value: zod
                            .union([zod.number(), zod.null()])
                            .optional()
                            .describe(
                                'The value observed when the check was written, recorded on each result for context.'
                            ),
                        metric_kind: zod
                            .union([
                                zod.enum([
                                    'affected_users',
                                    'affected_sessions',
                                    'occurrences',
                                    'conversion_rate',
                                    'error_rate',
                                    'duration',
                                    'revenue',
                                    'custom',
                                ]),
                                zod.null(),
                            ])
                            .optional()
                            .describe('How to draw this measurement; copied from a referenced metric.'),
                        value_format: zod
                            .union([
                                zod.enum([
                                    'number',
                                    'count',
                                    'percentage',
                                    'percentage_scaled',
                                    'duration',
                                    'currency',
                                ]),
                                zod.null(),
                            ])
                            .optional()
                            .describe('How to format measured values; copied from a referenced metric.'),
                        unit: zod
                            .union([
                                zod.string().max(signalsScoutReportCheckCreateBodyConfigOneOneUnitOneMax),
                                zod.null(),
                            ])
                            .optional()
                            .describe('Optional value suffix.'),
                    })
                    .describe(
                        "A deterministic check: measure one number, compare it, record the verdict.\n\nThe number comes either from a metric the report already shows (``metric_id``) or from a query\nthe author supplies. Both end up in the same runner, so a supplied query must satisfy the live\nmetric contract — the node allowlist, the bounded window, and the single-output-series rule.\n\nA caller names one source. When it names a metric, the create path copies that metric's query\ninto ``query`` before the row is stored, so the check keeps measuring what its author saw even if\nthe report's metric is later rewritten under the same id; ``metric_id`` stays as provenance.\n\nUnknown keys are refused rather than ignored, so a misspelled field name is reported instead of\nbeing dropped in silence and stored as it arrived."
                    ),
                zod
                    .object({
                        instructions: zod
                            .string()
                            .max(signalsScoutReportCheckCreateBodyConfigOneTwoInstructionsMax)
                            .describe("What the run must establish, in the author's own words."),
                        skill_name: zod
                            .union([
                                zod.string().max(signalsScoutReportCheckCreateBodyConfigOneTwoSkillNameOneMax),
                                zod.null(),
                            ])
                            .optional()
                            .describe(
                                "Scout skill that runs the check. Omit it to run on the fleet's follow-up scout, which is the right lane for a report no scout authored."
                            ),
                        probe_hints: zod
                            .array(zod.string())
                            .max(signalsScoutReportCheckCreateBodyConfigOneTwoProbeHintsMax)
                            .optional()
                            .describe(
                                'Concrete places to look, such as an issue id, a service name, or a query to repeat.'
                            ),
                    })
                    .describe(
                        'A check a scout run answers: re-probe the report\'s claim and record one verdict.\n\nThe kind for a claim no single number settles. A resolved error-tracking report is the usual\ncase: \"did the exception stop?\" needs the issue looked up, its recent events read, and the\nstack compared against what the fix changed, which is a run rather than a comparison.\n\nEverything here is prompt material a scout reads, so it is untrusted by construction: it renders\nin the run block the agent is told to weigh, never in the instructions it is told to follow. The\nverdict still comes back through `scout-check-record-result`, so instructions cannot widen what\na check run may write.\n\n``skill_name`` names the lane. Most reports are pipeline-authored and have no scout behind them,\nso it is optional: a check that names none runs on the fleet\'s follow-up scout\n(see ``report_check_agent.FALLBACK_CHECK_SKILL_NAME``).'
                    ),
            ])
            .describe('What the check measures and what the result must satisfy; the shape depends on `kind`.'),
        next_run_at: zod.iso
            .datetime({ offset: true })
            .optional()
            .describe(
                'When to first evaluate the check. Must be in the future and within 90 days. Defaults to 7 days from now.'
            ),
        run_interval_minutes: zod
            .number()
            .min(signalsScoutReportCheckCreateBodyRunIntervalMinutesMin)
            .max(signalsScoutReportCheckCreateBodyRunIntervalMinutesMax)
            .nullish()
            .describe(
                'Gap between runs for a recurring check, between 360 and 129600 minutes. Omit for a one-shot check.'
            ),
        runs_remaining: zod
            .number()
            .min(1)
            .max(signalsScoutReportCheckCreateBodyRunsRemainingMax)
            .optional()
            .describe('How many times to evaluate the check, at most 10. Defaults to 1.'),
        expires_at: zod.iso
            .datetime({ offset: true })
            .optional()
            .describe(
                'Horizon after which the check retires unrun. Defaults to 30 days after the last scheduled run, or the 90-day horizon if that comes first.'
            ),
        report_id: zod.string().describe('The report the check attaches to.'),
    })
    .describe(
        'Request body for `scout-report-check-create`: one forward-looking check on a report.\n\nThe REST body plus the report it attaches to. Subclassed rather than restated so the schedule\nbounds a scout writes under are the ones the endpoint enforces, with no second copy to drift.'
    )

/**
 * Return the team's recently emitted scout findings across *every* run, newest first — the cross-run counterpart to the per-run `emissions` action. Each row carries its `run_id`, so you can regroup by run without first listing runs and fanning out one `emissions` call each. Pass `skill_name` to scope to a single scout, and `date_from` / `date_to` (a half-open window on `emitted_at`) to bound or paginate — set `date_to` to the oldest emission's `emitted_at` to walk back past the limit. Pure Postgres, no ClickHouse round-trip. Capped at 200 rows (default 50).
 * @summary List recent emitted findings across all runs
 */
export const SignalsScoutRunsRecentEmissionsParams = () => zod.object({
    project_id: zod
        .string()
        .describe(
            "Project ID of the project you're trying to access. To find the ID of the project, make a call to \/api\/projects\/."
        ),
})

export const signalsScoutRunsRecentEmissionsQueryLimitMax = 200

export const SignalsScoutRunsRecentEmissionsQueryParams = () => zod.object({
    date_from: zod.iso
        .datetime({ offset: true })
        .optional()
        .describe('ISO-8601 inclusive lower bound on `emitted_at`. Omit to skip the lower bound.'),
    date_to: zod.iso
        .datetime({ offset: true })
        .optional()
        .describe(
            'ISO-8601 exclusive upper bound on `emitted_at`. Pass to walk back past the result cap on subsequent calls (cursor-style: set to the `emitted_at` of the oldest emission from the prior page).'
        ),
    limit: zod
        .number()
        .min(1)
        .max(signalsScoutRunsRecentEmissionsQueryLimitMax)
        .optional()
        .describe('Max rows to return (default 50, hard cap 200).'),
    skill_name: zod
        .string()
        .min(1)
        .optional()
        .describe(
            "Exact-match filter on the emitting scout's skill (e.g. `signals-scout-errors`). Narrows to findings one specialist surfaced; omit to span every scout on the team."
        ),
})

/**
 * Every check on one report, newest first. The `report_id` is the only input. Read this before writing one: a report already carrying a check for the same claim needs no second one, and a report holds at most five open checks at a time.
 * @summary List a report's follow-up checks
 */
export const SignalsScoutReportCheckListParams = () => zod.object({
    project_id: zod
        .string()
        .describe(
            "Project ID of the project you're trying to access. To find the ID of the project, make a call to \/api\/projects\/."
        ),
})

export const SignalsScoutReportCheckListQueryParams = () => zod.object({
    report_id: zod.string().describe('The report whose checks to list.'),
})

/**
 * Return `SignalScratchpad` entries for this project, newest-first. ILIKE matches on `content` and `key`; pass `key` instead for an exact single-entry lookup, and `skill_name` to keep the entries one scout (or `pipeline:*` stage) created. `date_from` / `date_to` are a half-open window on `updated_at` (`>= date_from`, `< date_to`); pass `date_to` (the `updated_at` of the oldest entry seen) on subsequent calls to walk past the cap. Entries whose `expires_at` has passed are excluded unless `include_expired=true`, and are hard-deleted by a daily janitor once their expiry is more than two weeks in the past. Pass `keys_only=true` to scan keys without pulling entry bodies, or `content_max_chars` to cap each `content` to a preview — both keep a wide orientation scan from returning every entry's full prose. Results capped at 1000.
 * @summary Search the scout scratchpad
 */
export const SignalsScoutScratchpadSearchParams = () => zod.object({
    project_id: zod
        .string()
        .describe(
            "Project ID of the project you're trying to access. To find the ID of the project, make a call to \/api\/projects\/."
        ),
})

export const signalsScoutScratchpadSearchQueryContentMaxCharsMin = 0

export const signalsScoutScratchpadSearchQueryIncludeExpiredDefault = false
export const signalsScoutScratchpadSearchQueryLimitMax = 1000

export const SignalsScoutScratchpadSearchQueryParams = () => zod.object({
    content_max_chars: zod
        .number()
        .min(signalsScoutScratchpadSearchQueryContentMaxCharsMin)
        .optional()
        .describe(
            "Truncate each entry's `content` to the first N characters (a preview). Omit for the full body. Ignored when `keys_only=true`."
        ),
    date_from: zod.iso
        .datetime({ offset: true })
        .optional()
        .describe('ISO-8601 inclusive lower bound on `updated_at`. Omit to skip the lower bound.'),
    date_to: zod.iso
        .datetime({ offset: true })
        .optional()
        .describe(
            'ISO-8601 exclusive upper bound on `updated_at`. Pass to walk back past the result cap on subsequent calls (cursor-style: set to the `updated_at` of the oldest entry from the prior page).'
        ),
    include_expired: zod
        .boolean()
        .default(signalsScoutScratchpadSearchQueryIncludeExpiredDefault)
        .describe(
            'Include entries whose `expires_at` has passed. Off by default so a time-boxed memory retires itself; turn it on to audit what the fleet remembered and when it lapsed.'
        ),
    key: zod
        .string()
        .min(1)
        .optional()
        .describe(
            'Exact key match — returns the single entry with this key, or nothing. Use this to re-read a known entry; `text` searches key \*and\* content, so it can push the row you asked for past the limit.'
        ),
    keys_only: zod
        .boolean()
        .optional()
        .describe(
            "When true, blank each entry's `content` and return only keys + metadata. Use to scan which memories exist without pulling their (potentially large) bodies, then re-query the ones worth a full read. Takes precedence over `content_max_chars`."
        ),
    limit: zod
        .number()
        .min(1)
        .max(signalsScoutScratchpadSearchQueryLimitMax)
        .optional()
        .describe('Max rows to return (default 20, hard cap 1000).'),
    skill_name: zod
        .string()
        .optional()
        .describe(
            'Return only the entries this writer created, matched against `created_by_skill` (a scout skill name or a `pipeline:\*` identity). Omit to return entries from every writer.'
        ),
    text: zod
        .string()
        .optional()
        .describe(
            'ILIKE substring match against `content` and `key`. Must contain 3 letters or digits in a row, or 2 next to a symbol such as `ai_` or `pr:`. Omit to return the most recent entries.'
        ),
})

/**
 * Upsert a memory keyed on `(team, key)`. Re-using a key updates the existing entry in place. A write carries the entry's whole state, so `expires_at` is set when passed and cleared when omitted.
 * @summary Remember a scratchpad entry
 */
export const SignalsScoutScratchpadRememberParams = () => zod.object({
    project_id: zod
        .string()
        .describe(
            "Project ID of the project you're trying to access. To find the ID of the project, make a call to \/api\/projects\/."
        ),
})

export const signalsScoutScratchpadRememberBodyKeyMax = 300

export const signalsScoutScratchpadRememberBodyContentMax = 50000

export const SignalsScoutScratchpadRememberBody = () => zod
    .object({
        key: zod
            .string()
            .max(signalsScoutScratchpadRememberBodyKeyMax)
            .describe(
                "Agent-chosen semantic key, unique per team; re-using a key overwrites the entry in place. Key off the \*stable identity\* of what you're tracking — never embed a date, timestamp, or run id (that mints a new row every run and breaks dedupe). For run state\/cursors, use one fixed key and keep the timestamp in `content`."
            ),
        content: zod
            .string()
            .max(signalsScoutScratchpadRememberBodyContentMax)
            .describe(
                'Markdown to write. Future prompts read it verbatim and people read it directly, so structured Markdown (headings, bullets, inline code for ids) is easier to skim than a wall of prose.'
            ),
        run_id: zod
            .string()
            .nullish()
            .describe(
                "Run that authored this memory; persisted as `created_by_run_id` for lineage. Best-effort — a `run_id` that is unparseable, or that isn't a run on this project, is dropped rather than rejected, so the memory write is never lost. Omit it and the lineage still lands: a write from a scout sandbox is attributed to that sandbox's own run. A report-pipeline caller is attributed by its stage and does not pass one."
            ),
        expires_at: zod
            .string()
            .nullish()
            .describe(
                "Optional ISO-8601 expiry for a memory that's only true for a while (a cooldown, a window you're watching). After this time the entry drops out of searches, so you don't have to come back and forget it. Omit for a durable memory — every write sets the whole entry, so omitting it on a later write clears an expiry set earlier. Best-effort — a value that can't be parsed or is already in the past is dropped (the memory stays durable), not rejected, so the memory write is never lost."
            ),
    })
    .describe('Request body for `remember`.')

/**
 * Delete an entry by key. Returns `deleted=false` if no row matched.
 * @summary Forget a scratchpad entry by key
 */
export const SignalsScoutScratchpadForgetParams = () => zod.object({
    project_id: zod
        .string()
        .describe(
            "Project ID of the project you're trying to access. To find the ID of the project, make a call to \/api\/projects\/."
        ),
})

export const signalsScoutScratchpadForgetBodyKeyMax = 300

export const SignalsScoutScratchpadForgetBody = () => zod
    .object({
        key: zod.string().max(signalsScoutScratchpadForgetBodyKeyMax).describe('Memory key to delete.'),
    })
    .describe('Request body for `forget`.')

export const SignalsSourceConfigsListParams = () => zod.object({
    project_id: zod
        .string()
        .describe(
            "Project ID of the project you're trying to access. To find the ID of the project, make a call to \/api\/projects\/."
        ),
})

export const SignalsSourceConfigsListQueryParams = () => zod.object({
    limit: zod.number().optional().describe('Number of results to return per page.'),
    offset: zod.number().optional().describe('The initial index from which to return the results.'),
})

export const SignalsSourceConfigsCreateParams = () => zod.object({
    project_id: zod
        .string()
        .describe(
            "Project ID of the project you're trying to access. To find the ID of the project, make a call to \/api\/projects\/."
        ),
})

export const SignalsSourceConfigsCreateBody = () => zod.object({
    source_product: zod
        .enum([
            'session_replay',
            'llm_analytics',
            'github',
            'linear',
            'jira',
            'zendesk',
            'conversations',
            'error_tracking',
            'pganalyze',
            'signals_scout',
            'signals_check',
            'user_authored',
            'logs',
            'health_checks',
            'endpoints',
            'replay_vision',
            'analytics',
            'freshdesk',
            'freshservice',
            'front',
            'gorgias',
            'kustomer',
            'dixa',
            'plain',
            'gitlab',
            'gitea',
            'shortcut',
            'sentry',
            'rollbar',
            'bugsnag',
            'honeybadger',
            'raygun',
            'datadog',
            'snyk',
            'sonarqube',
            'semgrep',
            'rapid7_insightvm',
            'featurebase',
            'frill',
            'aha',
            'uservoice',
            'productboard',
            'canny',
            'asknicely',
            'retently',
            'appfigures',
            'appfollow',
            'judgeme_reviews',
            'intercom',
            'hubspot',
            'engineering_analytics',
            'google_search_console',
            'pagerduty',
            'opsgenie',
            'incident_io',
            'firehydrant',
            'squadcast',
            'servicenow',
            'solarwinds_service_desk',
            'grafana_irm',
            'xmatters',
            'betterstack',
            'newrelic',
            'trigger_dev',
            'checkly',
            'roark',
            'monte_carlo',
            'bigeye',
            'aws_security_hub',
            'aws_guardduty',
            'aws_inspector',
            'microsoft_defender_cloud_apps',
            'clickup',
            'wrike',
            'trello',
            'bugherd',
            'dynamics365',
            'zoho_crm',
            'planhat',
            'trustpilot',
            'okendo',
            'sleekplan',
            'bettermode',
            'discourse',
            'mintlify',
            'langsmith',
            'sprig',
            'gainsight_px',
            'dynatrace',
            'statuspage',
            'cronitor',
            'instatus',
            'asana',
            'monday',
            'plane',
            'azure_devops',
            'helpscout',
            'decagon',
            'vitally',
            'usersnap',
            'typeform',
            'qualtrics',
            'surveymonkey',
            'formbricks',
            'survicate',
            'surveysparrow',
            'lacework',
            'orca_security',
            'tenable_vulnerability_management',
            'google_play_console',
            'azure_application_insights',
            'appsignal',
            'cursor',
        ])
        .describe(
            '\* `session_replay` - Session replay\n\* `llm_analytics` - LLM analytics\n\* `github` - GitHub\n\* `linear` - Linear\n\* `jira` - Jira\n\* `zendesk` - Zendesk\n\* `conversations` - Conversations\n\* `error_tracking` - Error tracking\n\* `pganalyze` - pganalyze\n\* `signals_scout` - Signals scout\n\* `signals_check` - Report check\n\* `user_authored` - Team member\n\* `logs` - Logs\n\* `health_checks` - Health checks\n\* `endpoints` - Endpoints\n\* `replay_vision` - Replay Vision\n\* `analytics` - Product analytics\n\* `freshdesk` - Freshdesk\n\* `freshservice` - Freshservice\n\* `front` - Front\n\* `gorgias` - Gorgias\n\* `kustomer` - Kustomer\n\* `dixa` - Dixa\n\* `plain` - Plain\n\* `gitlab` - GitLab\n\* `gitea` - Gitea\n\* `shortcut` - Shortcut\n\* `sentry` - Sentry\n\* `rollbar` - Rollbar\n\* `bugsnag` - Bugsnag\n\* `honeybadger` - Honeybadger\n\* `raygun` - Raygun\n\* `datadog` - Datadog\n\* `snyk` - Snyk\n\* `sonarqube` - SonarQube\n\* `semgrep` - Semgrep\n\* `rapid7_insightvm` - Rapid7 InsightVM\n\* `featurebase` - Featurebase\n\* `frill` - Frill\n\* `aha` - Aha\n\* `uservoice` - UserVoice\n\* `productboard` - Productboard\n\* `canny` - Canny\n\* `asknicely` - AskNicely\n\* `retently` - Retently\n\* `appfigures` - Appfigures\n\* `appfollow` - AppFollow\n\* `judgeme_reviews` - Judge.me\n\* `intercom` - Intercom\n\* `hubspot` - HubSpot\n\* `engineering_analytics` - Engineering analytics\n\* `google_search_console` - Google Search Console\n\* `pagerduty` - PagerDuty\n\* `opsgenie` - Opsgenie\n\* `incident_io` - incident.io\n\* `firehydrant` - FireHydrant\n\* `squadcast` - Squadcast\n\* `servicenow` - ServiceNow\n\* `solarwinds_service_desk` - SolarWinds Service Desk\n\* `grafana_irm` - Grafana IRM\n\* `xmatters` - xMatters\n\* `betterstack` - Better Stack\n\* `newrelic` - New Relic\n\* `trigger_dev` - Trigger.dev\n\* `checkly` - Checkly\n\* `roark` - Roark\n\* `monte_carlo` - Monte Carlo\n\* `bigeye` - Bigeye\n\* `aws_security_hub` - AWS Security Hub\n\* `aws_guardduty` - AWS GuardDuty\n\* `aws_inspector` - AWS Inspector\n\* `microsoft_defender_cloud_apps` - Microsoft Defender for Cloud Apps\n\* `clickup` - ClickUp\n\* `wrike` - Wrike\n\* `trello` - Trello\n\* `bugherd` - BugHerd\n\* `dynamics365` - Dynamics 365\n\* `zoho_crm` - Zoho CRM\n\* `planhat` - Planhat\n\* `trustpilot` - Trustpilot\n\* `okendo` - Okendo\n\* `sleekplan` - Sleekplan\n\* `bettermode` - Bettermode\n\* `discourse` - Discourse\n\* `mintlify` - Mintlify\n\* `langsmith` - LangSmith\n\* `sprig` - Sprig\n\* `gainsight_px` - Gainsight PX\n\* `dynatrace` - Dynatrace\n\* `statuspage` - Statuspage\n\* `cronitor` - Cronitor\n\* `instatus` - Instatus\n\* `asana` - Asana\n\* `monday` - monday.com\n\* `plane` - Plane\n\* `azure_devops` - Azure DevOps\n\* `helpscout` - Help Scout\n\* `decagon` - Decagon\n\* `vitally` - Vitally\n\* `usersnap` - Usersnap\n\* `typeform` - Typeform\n\* `qualtrics` - Qualtrics\n\* `surveymonkey` - SurveyMonkey\n\* `formbricks` - Formbricks\n\* `survicate` - Survicate\n\* `surveysparrow` - SurveySparrow\n\* `lacework` - Lacework\n\* `orca_security` - Orca Security\n\* `tenable_vulnerability_management` - Tenable Vulnerability Management\n\* `google_play_console` - Google Play Console\n\* `azure_application_insights` - Azure Application Insights\n\* `appsignal` - AppSignal\n\* `cursor` - Cursor'
        ),
    source_type: zod
        .enum([
            'session_analysis_cluster',
            'evaluation_report',
            'issue',
            'ticket',
            'issue_created',
            'issue_reopened',
            'issue_spiking',
            'cross_source_issue',
            'alert_state_change',
            'health_issue',
            'endpoint_execution_failed',
            'endpoint_breakdown_limit_exceeded',
            'scanner_finding',
            'anomaly_investigation',
            'feedback',
            'review',
            'ci_flaky_check',
            'ci_broken_default_branch',
            'ci_duration_regression',
            'search_opportunity',
            'incident',
        ])
        .describe(
            '\* `session_analysis_cluster` - Session analysis cluster\n\* `evaluation_report` - Evaluation report\n\* `issue` - Issue\n\* `ticket` - Ticket\n\* `issue_created` - Issue created\n\* `issue_reopened` - Issue reopened\n\* `issue_spiking` - Issue spiking\n\* `cross_source_issue` - Cross source issue\n\* `alert_state_change` - Alert state change\n\* `health_issue` - Health issue\n\* `endpoint_execution_failed` - Endpoint execution failed\n\* `endpoint_breakdown_limit_exceeded` - Endpoint breakdown limit exceeded\n\* `scanner_finding` - Scanner finding\n\* `anomaly_investigation` - Anomaly investigation\n\* `feedback` - Feedback\n\* `review` - Review\n\* `ci_flaky_check` - CI flaky check\n\* `ci_broken_default_branch` - CI broken default branch\n\* `ci_duration_regression` - CI duration regression\n\* `search_opportunity` - Search opportunity\n\* `incident` - Incident'
        ),
    enabled: zod.boolean().optional(),
    config: zod
        .record(zod.string(), zod.unknown())
        .optional()
        .describe(
            "Per-source settings as a JSON object. Keys read by the emission actionability gate on sources that define one (most data warehouse imports, and Conversations): `steering` (string, max 2000 characters) holds the team's preferences about this source's records in plain language: what matters, what to skip, what's out of scope. The emission actionability gate applies it when deciding which records become signals; rules apply from the next sync and nothing already emitted is retracted. `default_not_actionable` (boolean, default false) flips the gate's default: instead of keeping every record the steering rules don't exclude, only records that clearly match the team's preferences are kept. Other sources store these keys without reading them yet; future pipeline stages will consume the same steering text. Some sources read additional keys, for example `recording_filters` and `sample_rate` for session analysis. The Linear issue source (`source_product=linear`, `source_type=issue`) reads `linear_team_ids` (list of Linear team id strings, max 100): the warehouse still syncs the whole Linear workspace, but only issues from those teams become signals. Omit the key or pass an empty list to use every team. Get the ids from the Linear integration's teams endpoint. The product analytics source (`source_product=analytics`, `source_type=anomaly_investigation`) accepts `alert_scope`: `investigated_only` (default) turns only insight alerts that the investigation agent confirmed into signals, `all_firing_alerts` also includes alerts without the investigation agent, and `off` turns no alerts into signals. Alert checks, notifications, and investigations still run with `off`. It also accepts `alert_allow_patterns` and `alert_block_patterns` (lists of up to 20 regex patterns, max 200 characters each). A pattern matches when it finds a match anywhere in the alert name or the insight name, and matching is case sensitive unless the pattern uses the `(?i)` flag. When allow patterns are set, an alert must match one of them. An alert that matches a block pattern is dropped, also when it matches an allow pattern. Patterns use RE2 syntax, which has no lookaround and no backreferences. Both keys apply to either `all_firing_alerts` or `investigated_only`. Other sources reject these keys."
        ),
    config_set: zod
        .record(zod.string(), zod.unknown())
        .optional()
        .describe(
            'Top-level config keys to set atomically on update. Unspecified keys are preserved. Cannot be combined with config.'
        ),
    config_remove: zod
        .array(zod.string())
        .optional()
        .describe(
            'Top-level config keys to remove atomically on update. Missing keys are ignored. Cannot overlap config_set or be combined with config.'
        ),
})

export const SignalsSourceConfigsRetrieveParams = () => zod.object({
    id: zod.string().describe('A UUID string identifying this signal source config.'),
    project_id: zod
        .string()
        .describe(
            "Project ID of the project you're trying to access. To find the ID of the project, make a call to \/api\/projects\/."
        ),
})

export const SignalsSourceConfigsUpdateParams = () => zod.object({
    id: zod.string().describe('A UUID string identifying this signal source config.'),
    project_id: zod
        .string()
        .describe(
            "Project ID of the project you're trying to access. To find the ID of the project, make a call to \/api\/projects\/."
        ),
})

export const SignalsSourceConfigsUpdateBody = () => zod.object({
    source_product: zod
        .enum([
            'session_replay',
            'llm_analytics',
            'github',
            'linear',
            'jira',
            'zendesk',
            'conversations',
            'error_tracking',
            'pganalyze',
            'signals_scout',
            'signals_check',
            'user_authored',
            'logs',
            'health_checks',
            'endpoints',
            'replay_vision',
            'analytics',
            'freshdesk',
            'freshservice',
            'front',
            'gorgias',
            'kustomer',
            'dixa',
            'plain',
            'gitlab',
            'gitea',
            'shortcut',
            'sentry',
            'rollbar',
            'bugsnag',
            'honeybadger',
            'raygun',
            'datadog',
            'snyk',
            'sonarqube',
            'semgrep',
            'rapid7_insightvm',
            'featurebase',
            'frill',
            'aha',
            'uservoice',
            'productboard',
            'canny',
            'asknicely',
            'retently',
            'appfigures',
            'appfollow',
            'judgeme_reviews',
            'intercom',
            'hubspot',
            'engineering_analytics',
            'google_search_console',
            'pagerduty',
            'opsgenie',
            'incident_io',
            'firehydrant',
            'squadcast',
            'servicenow',
            'solarwinds_service_desk',
            'grafana_irm',
            'xmatters',
            'betterstack',
            'newrelic',
            'trigger_dev',
            'checkly',
            'roark',
            'monte_carlo',
            'bigeye',
            'aws_security_hub',
            'aws_guardduty',
            'aws_inspector',
            'microsoft_defender_cloud_apps',
            'clickup',
            'wrike',
            'trello',
            'bugherd',
            'dynamics365',
            'zoho_crm',
            'planhat',
            'trustpilot',
            'okendo',
            'sleekplan',
            'bettermode',
            'discourse',
            'mintlify',
            'langsmith',
            'sprig',
            'gainsight_px',
            'dynatrace',
            'statuspage',
            'cronitor',
            'instatus',
            'asana',
            'monday',
            'plane',
            'azure_devops',
            'helpscout',
            'decagon',
            'vitally',
            'usersnap',
            'typeform',
            'qualtrics',
            'surveymonkey',
            'formbricks',
            'survicate',
            'surveysparrow',
            'lacework',
            'orca_security',
            'tenable_vulnerability_management',
            'google_play_console',
            'azure_application_insights',
            'appsignal',
            'cursor',
        ])
        .describe(
            '\* `session_replay` - Session replay\n\* `llm_analytics` - LLM analytics\n\* `github` - GitHub\n\* `linear` - Linear\n\* `jira` - Jira\n\* `zendesk` - Zendesk\n\* `conversations` - Conversations\n\* `error_tracking` - Error tracking\n\* `pganalyze` - pganalyze\n\* `signals_scout` - Signals scout\n\* `signals_check` - Report check\n\* `user_authored` - Team member\n\* `logs` - Logs\n\* `health_checks` - Health checks\n\* `endpoints` - Endpoints\n\* `replay_vision` - Replay Vision\n\* `analytics` - Product analytics\n\* `freshdesk` - Freshdesk\n\* `freshservice` - Freshservice\n\* `front` - Front\n\* `gorgias` - Gorgias\n\* `kustomer` - Kustomer\n\* `dixa` - Dixa\n\* `plain` - Plain\n\* `gitlab` - GitLab\n\* `gitea` - Gitea\n\* `shortcut` - Shortcut\n\* `sentry` - Sentry\n\* `rollbar` - Rollbar\n\* `bugsnag` - Bugsnag\n\* `honeybadger` - Honeybadger\n\* `raygun` - Raygun\n\* `datadog` - Datadog\n\* `snyk` - Snyk\n\* `sonarqube` - SonarQube\n\* `semgrep` - Semgrep\n\* `rapid7_insightvm` - Rapid7 InsightVM\n\* `featurebase` - Featurebase\n\* `frill` - Frill\n\* `aha` - Aha\n\* `uservoice` - UserVoice\n\* `productboard` - Productboard\n\* `canny` - Canny\n\* `asknicely` - AskNicely\n\* `retently` - Retently\n\* `appfigures` - Appfigures\n\* `appfollow` - AppFollow\n\* `judgeme_reviews` - Judge.me\n\* `intercom` - Intercom\n\* `hubspot` - HubSpot\n\* `engineering_analytics` - Engineering analytics\n\* `google_search_console` - Google Search Console\n\* `pagerduty` - PagerDuty\n\* `opsgenie` - Opsgenie\n\* `incident_io` - incident.io\n\* `firehydrant` - FireHydrant\n\* `squadcast` - Squadcast\n\* `servicenow` - ServiceNow\n\* `solarwinds_service_desk` - SolarWinds Service Desk\n\* `grafana_irm` - Grafana IRM\n\* `xmatters` - xMatters\n\* `betterstack` - Better Stack\n\* `newrelic` - New Relic\n\* `trigger_dev` - Trigger.dev\n\* `checkly` - Checkly\n\* `roark` - Roark\n\* `monte_carlo` - Monte Carlo\n\* `bigeye` - Bigeye\n\* `aws_security_hub` - AWS Security Hub\n\* `aws_guardduty` - AWS GuardDuty\n\* `aws_inspector` - AWS Inspector\n\* `microsoft_defender_cloud_apps` - Microsoft Defender for Cloud Apps\n\* `clickup` - ClickUp\n\* `wrike` - Wrike\n\* `trello` - Trello\n\* `bugherd` - BugHerd\n\* `dynamics365` - Dynamics 365\n\* `zoho_crm` - Zoho CRM\n\* `planhat` - Planhat\n\* `trustpilot` - Trustpilot\n\* `okendo` - Okendo\n\* `sleekplan` - Sleekplan\n\* `bettermode` - Bettermode\n\* `discourse` - Discourse\n\* `mintlify` - Mintlify\n\* `langsmith` - LangSmith\n\* `sprig` - Sprig\n\* `gainsight_px` - Gainsight PX\n\* `dynatrace` - Dynatrace\n\* `statuspage` - Statuspage\n\* `cronitor` - Cronitor\n\* `instatus` - Instatus\n\* `asana` - Asana\n\* `monday` - monday.com\n\* `plane` - Plane\n\* `azure_devops` - Azure DevOps\n\* `helpscout` - Help Scout\n\* `decagon` - Decagon\n\* `vitally` - Vitally\n\* `usersnap` - Usersnap\n\* `typeform` - Typeform\n\* `qualtrics` - Qualtrics\n\* `surveymonkey` - SurveyMonkey\n\* `formbricks` - Formbricks\n\* `survicate` - Survicate\n\* `surveysparrow` - SurveySparrow\n\* `lacework` - Lacework\n\* `orca_security` - Orca Security\n\* `tenable_vulnerability_management` - Tenable Vulnerability Management\n\* `google_play_console` - Google Play Console\n\* `azure_application_insights` - Azure Application Insights\n\* `appsignal` - AppSignal\n\* `cursor` - Cursor'
        ),
    source_type: zod
        .enum([
            'session_analysis_cluster',
            'evaluation_report',
            'issue',
            'ticket',
            'issue_created',
            'issue_reopened',
            'issue_spiking',
            'cross_source_issue',
            'alert_state_change',
            'health_issue',
            'endpoint_execution_failed',
            'endpoint_breakdown_limit_exceeded',
            'scanner_finding',
            'anomaly_investigation',
            'feedback',
            'review',
            'ci_flaky_check',
            'ci_broken_default_branch',
            'ci_duration_regression',
            'search_opportunity',
            'incident',
        ])
        .describe(
            '\* `session_analysis_cluster` - Session analysis cluster\n\* `evaluation_report` - Evaluation report\n\* `issue` - Issue\n\* `ticket` - Ticket\n\* `issue_created` - Issue created\n\* `issue_reopened` - Issue reopened\n\* `issue_spiking` - Issue spiking\n\* `cross_source_issue` - Cross source issue\n\* `alert_state_change` - Alert state change\n\* `health_issue` - Health issue\n\* `endpoint_execution_failed` - Endpoint execution failed\n\* `endpoint_breakdown_limit_exceeded` - Endpoint breakdown limit exceeded\n\* `scanner_finding` - Scanner finding\n\* `anomaly_investigation` - Anomaly investigation\n\* `feedback` - Feedback\n\* `review` - Review\n\* `ci_flaky_check` - CI flaky check\n\* `ci_broken_default_branch` - CI broken default branch\n\* `ci_duration_regression` - CI duration regression\n\* `search_opportunity` - Search opportunity\n\* `incident` - Incident'
        ),
    enabled: zod.boolean().optional(),
    config: zod
        .record(zod.string(), zod.unknown())
        .optional()
        .describe(
            "Per-source settings as a JSON object. Keys read by the emission actionability gate on sources that define one (most data warehouse imports, and Conversations): `steering` (string, max 2000 characters) holds the team's preferences about this source's records in plain language: what matters, what to skip, what's out of scope. The emission actionability gate applies it when deciding which records become signals; rules apply from the next sync and nothing already emitted is retracted. `default_not_actionable` (boolean, default false) flips the gate's default: instead of keeping every record the steering rules don't exclude, only records that clearly match the team's preferences are kept. Other sources store these keys without reading them yet; future pipeline stages will consume the same steering text. Some sources read additional keys, for example `recording_filters` and `sample_rate` for session analysis. The Linear issue source (`source_product=linear`, `source_type=issue`) reads `linear_team_ids` (list of Linear team id strings, max 100): the warehouse still syncs the whole Linear workspace, but only issues from those teams become signals. Omit the key or pass an empty list to use every team. Get the ids from the Linear integration's teams endpoint. The product analytics source (`source_product=analytics`, `source_type=anomaly_investigation`) accepts `alert_scope`: `investigated_only` (default) turns only insight alerts that the investigation agent confirmed into signals, `all_firing_alerts` also includes alerts without the investigation agent, and `off` turns no alerts into signals. Alert checks, notifications, and investigations still run with `off`. It also accepts `alert_allow_patterns` and `alert_block_patterns` (lists of up to 20 regex patterns, max 200 characters each). A pattern matches when it finds a match anywhere in the alert name or the insight name, and matching is case sensitive unless the pattern uses the `(?i)` flag. When allow patterns are set, an alert must match one of them. An alert that matches a block pattern is dropped, also when it matches an allow pattern. Patterns use RE2 syntax, which has no lookaround and no backreferences. Both keys apply to either `all_firing_alerts` or `investigated_only`. Other sources reject these keys."
        ),
    config_set: zod
        .record(zod.string(), zod.unknown())
        .optional()
        .describe(
            'Top-level config keys to set atomically on update. Unspecified keys are preserved. Cannot be combined with config.'
        ),
    config_remove: zod
        .array(zod.string())
        .optional()
        .describe(
            'Top-level config keys to remove atomically on update. Missing keys are ignored. Cannot overlap config_set or be combined with config.'
        ),
})

export const SignalsSourceConfigsPartialUpdateParams = () => zod.object({
    id: zod.string().describe('A UUID string identifying this signal source config.'),
    project_id: zod
        .string()
        .describe(
            "Project ID of the project you're trying to access. To find the ID of the project, make a call to \/api\/projects\/."
        ),
})

export const SignalsSourceConfigsPartialUpdateBody = () => zod.object({
    source_product: zod
        .enum([
            'session_replay',
            'llm_analytics',
            'github',
            'linear',
            'jira',
            'zendesk',
            'conversations',
            'error_tracking',
            'pganalyze',
            'signals_scout',
            'signals_check',
            'user_authored',
            'logs',
            'health_checks',
            'endpoints',
            'replay_vision',
            'analytics',
            'freshdesk',
            'freshservice',
            'front',
            'gorgias',
            'kustomer',
            'dixa',
            'plain',
            'gitlab',
            'gitea',
            'shortcut',
            'sentry',
            'rollbar',
            'bugsnag',
            'honeybadger',
            'raygun',
            'datadog',
            'snyk',
            'sonarqube',
            'semgrep',
            'rapid7_insightvm',
            'featurebase',
            'frill',
            'aha',
            'uservoice',
            'productboard',
            'canny',
            'asknicely',
            'retently',
            'appfigures',
            'appfollow',
            'judgeme_reviews',
            'intercom',
            'hubspot',
            'engineering_analytics',
            'google_search_console',
            'pagerduty',
            'opsgenie',
            'incident_io',
            'firehydrant',
            'squadcast',
            'servicenow',
            'solarwinds_service_desk',
            'grafana_irm',
            'xmatters',
            'betterstack',
            'newrelic',
            'trigger_dev',
            'checkly',
            'roark',
            'monte_carlo',
            'bigeye',
            'aws_security_hub',
            'aws_guardduty',
            'aws_inspector',
            'microsoft_defender_cloud_apps',
            'clickup',
            'wrike',
            'trello',
            'bugherd',
            'dynamics365',
            'zoho_crm',
            'planhat',
            'trustpilot',
            'okendo',
            'sleekplan',
            'bettermode',
            'discourse',
            'mintlify',
            'langsmith',
            'sprig',
            'gainsight_px',
            'dynatrace',
            'statuspage',
            'cronitor',
            'instatus',
            'asana',
            'monday',
            'plane',
            'azure_devops',
            'helpscout',
            'decagon',
            'vitally',
            'usersnap',
            'typeform',
            'qualtrics',
            'surveymonkey',
            'formbricks',
            'survicate',
            'surveysparrow',
            'lacework',
            'orca_security',
            'tenable_vulnerability_management',
            'google_play_console',
            'azure_application_insights',
            'appsignal',
            'cursor',
        ])
        .optional()
        .describe(
            '\* `session_replay` - Session replay\n\* `llm_analytics` - LLM analytics\n\* `github` - GitHub\n\* `linear` - Linear\n\* `jira` - Jira\n\* `zendesk` - Zendesk\n\* `conversations` - Conversations\n\* `error_tracking` - Error tracking\n\* `pganalyze` - pganalyze\n\* `signals_scout` - Signals scout\n\* `signals_check` - Report check\n\* `user_authored` - Team member\n\* `logs` - Logs\n\* `health_checks` - Health checks\n\* `endpoints` - Endpoints\n\* `replay_vision` - Replay Vision\n\* `analytics` - Product analytics\n\* `freshdesk` - Freshdesk\n\* `freshservice` - Freshservice\n\* `front` - Front\n\* `gorgias` - Gorgias\n\* `kustomer` - Kustomer\n\* `dixa` - Dixa\n\* `plain` - Plain\n\* `gitlab` - GitLab\n\* `gitea` - Gitea\n\* `shortcut` - Shortcut\n\* `sentry` - Sentry\n\* `rollbar` - Rollbar\n\* `bugsnag` - Bugsnag\n\* `honeybadger` - Honeybadger\n\* `raygun` - Raygun\n\* `datadog` - Datadog\n\* `snyk` - Snyk\n\* `sonarqube` - SonarQube\n\* `semgrep` - Semgrep\n\* `rapid7_insightvm` - Rapid7 InsightVM\n\* `featurebase` - Featurebase\n\* `frill` - Frill\n\* `aha` - Aha\n\* `uservoice` - UserVoice\n\* `productboard` - Productboard\n\* `canny` - Canny\n\* `asknicely` - AskNicely\n\* `retently` - Retently\n\* `appfigures` - Appfigures\n\* `appfollow` - AppFollow\n\* `judgeme_reviews` - Judge.me\n\* `intercom` - Intercom\n\* `hubspot` - HubSpot\n\* `engineering_analytics` - Engineering analytics\n\* `google_search_console` - Google Search Console\n\* `pagerduty` - PagerDuty\n\* `opsgenie` - Opsgenie\n\* `incident_io` - incident.io\n\* `firehydrant` - FireHydrant\n\* `squadcast` - Squadcast\n\* `servicenow` - ServiceNow\n\* `solarwinds_service_desk` - SolarWinds Service Desk\n\* `grafana_irm` - Grafana IRM\n\* `xmatters` - xMatters\n\* `betterstack` - Better Stack\n\* `newrelic` - New Relic\n\* `trigger_dev` - Trigger.dev\n\* `checkly` - Checkly\n\* `roark` - Roark\n\* `monte_carlo` - Monte Carlo\n\* `bigeye` - Bigeye\n\* `aws_security_hub` - AWS Security Hub\n\* `aws_guardduty` - AWS GuardDuty\n\* `aws_inspector` - AWS Inspector\n\* `microsoft_defender_cloud_apps` - Microsoft Defender for Cloud Apps\n\* `clickup` - ClickUp\n\* `wrike` - Wrike\n\* `trello` - Trello\n\* `bugherd` - BugHerd\n\* `dynamics365` - Dynamics 365\n\* `zoho_crm` - Zoho CRM\n\* `planhat` - Planhat\n\* `trustpilot` - Trustpilot\n\* `okendo` - Okendo\n\* `sleekplan` - Sleekplan\n\* `bettermode` - Bettermode\n\* `discourse` - Discourse\n\* `mintlify` - Mintlify\n\* `langsmith` - LangSmith\n\* `sprig` - Sprig\n\* `gainsight_px` - Gainsight PX\n\* `dynatrace` - Dynatrace\n\* `statuspage` - Statuspage\n\* `cronitor` - Cronitor\n\* `instatus` - Instatus\n\* `asana` - Asana\n\* `monday` - monday.com\n\* `plane` - Plane\n\* `azure_devops` - Azure DevOps\n\* `helpscout` - Help Scout\n\* `decagon` - Decagon\n\* `vitally` - Vitally\n\* `usersnap` - Usersnap\n\* `typeform` - Typeform\n\* `qualtrics` - Qualtrics\n\* `surveymonkey` - SurveyMonkey\n\* `formbricks` - Formbricks\n\* `survicate` - Survicate\n\* `surveysparrow` - SurveySparrow\n\* `lacework` - Lacework\n\* `orca_security` - Orca Security\n\* `tenable_vulnerability_management` - Tenable Vulnerability Management\n\* `google_play_console` - Google Play Console\n\* `azure_application_insights` - Azure Application Insights\n\* `appsignal` - AppSignal\n\* `cursor` - Cursor'
        ),
    source_type: zod
        .enum([
            'session_analysis_cluster',
            'evaluation_report',
            'issue',
            'ticket',
            'issue_created',
            'issue_reopened',
            'issue_spiking',
            'cross_source_issue',
            'alert_state_change',
            'health_issue',
            'endpoint_execution_failed',
            'endpoint_breakdown_limit_exceeded',
            'scanner_finding',
            'anomaly_investigation',
            'feedback',
            'review',
            'ci_flaky_check',
            'ci_broken_default_branch',
            'ci_duration_regression',
            'search_opportunity',
            'incident',
        ])
        .optional()
        .describe(
            '\* `session_analysis_cluster` - Session analysis cluster\n\* `evaluation_report` - Evaluation report\n\* `issue` - Issue\n\* `ticket` - Ticket\n\* `issue_created` - Issue created\n\* `issue_reopened` - Issue reopened\n\* `issue_spiking` - Issue spiking\n\* `cross_source_issue` - Cross source issue\n\* `alert_state_change` - Alert state change\n\* `health_issue` - Health issue\n\* `endpoint_execution_failed` - Endpoint execution failed\n\* `endpoint_breakdown_limit_exceeded` - Endpoint breakdown limit exceeded\n\* `scanner_finding` - Scanner finding\n\* `anomaly_investigation` - Anomaly investigation\n\* `feedback` - Feedback\n\* `review` - Review\n\* `ci_flaky_check` - CI flaky check\n\* `ci_broken_default_branch` - CI broken default branch\n\* `ci_duration_regression` - CI duration regression\n\* `search_opportunity` - Search opportunity\n\* `incident` - Incident'
        ),
    enabled: zod.boolean().optional(),
    config: zod
        .record(zod.string(), zod.unknown())
        .optional()
        .describe(
            "Per-source settings as a JSON object. Keys read by the emission actionability gate on sources that define one (most data warehouse imports, and Conversations): `steering` (string, max 2000 characters) holds the team's preferences about this source's records in plain language: what matters, what to skip, what's out of scope. The emission actionability gate applies it when deciding which records become signals; rules apply from the next sync and nothing already emitted is retracted. `default_not_actionable` (boolean, default false) flips the gate's default: instead of keeping every record the steering rules don't exclude, only records that clearly match the team's preferences are kept. Other sources store these keys without reading them yet; future pipeline stages will consume the same steering text. Some sources read additional keys, for example `recording_filters` and `sample_rate` for session analysis. The Linear issue source (`source_product=linear`, `source_type=issue`) reads `linear_team_ids` (list of Linear team id strings, max 100): the warehouse still syncs the whole Linear workspace, but only issues from those teams become signals. Omit the key or pass an empty list to use every team. Get the ids from the Linear integration's teams endpoint. The product analytics source (`source_product=analytics`, `source_type=anomaly_investigation`) accepts `alert_scope`: `investigated_only` (default) turns only insight alerts that the investigation agent confirmed into signals, `all_firing_alerts` also includes alerts without the investigation agent, and `off` turns no alerts into signals. Alert checks, notifications, and investigations still run with `off`. It also accepts `alert_allow_patterns` and `alert_block_patterns` (lists of up to 20 regex patterns, max 200 characters each). A pattern matches when it finds a match anywhere in the alert name or the insight name, and matching is case sensitive unless the pattern uses the `(?i)` flag. When allow patterns are set, an alert must match one of them. An alert that matches a block pattern is dropped, also when it matches an allow pattern. Patterns use RE2 syntax, which has no lookaround and no backreferences. Both keys apply to either `all_firing_alerts` or `investigated_only`. Other sources reject these keys."
        ),
    config_set: zod
        .record(zod.string(), zod.unknown())
        .optional()
        .describe(
            'Top-level config keys to set atomically on update. Unspecified keys are preserved. Cannot be combined with config.'
        ),
    config_remove: zod
        .array(zod.string())
        .optional()
        .describe(
            'Top-level config keys to remove atomically on update. Missing keys are ignored. Cannot overlap config_set or be combined with config.'
        ),
})

export const SignalsMonthlyUsageParams = () => zod.object({
    project_id: zod
        .string()
        .describe(
            "Project ID of the project you're trying to access. To find the ID of the project, make a call to \/api\/projects\/."
        ),
})

export const signalsMonthlyUsageQueryMonthRegExp = new RegExp('^[0-9]{4}-(0[1-9]|1[0-2])$')

export const SignalsMonthlyUsageQueryParams = () => zod.object({
    month: zod
        .string()
        .min(1)
        .regex(signalsMonthlyUsageQueryMonthRegExp)
        .optional()
        .describe(
            'UTC calendar month in YYYY-MM format, from 2026-10 onward. Defaults to the current month. Usage is grouped by finalization time.'
        ),
})