import { z } from 'zod'; /** * The Robots API version a job, run or directive belongs to. Mux keeps each on the version that * created it, and reading it through the other one is a 404. */ export type RobotsApiVersion = 'v0' | 'v1'; /** Robots v1 links each listed job and directive to its own route, such as `/robots/v0/jobs/…`. */ export declare function apiVersionFromHref(href: unknown): RobotsApiVersion | undefined; export declare const ROBOTS_DIRECTIVES_MIGRATION_URL = "https://www.mux.com/docs/guides/robots-migrate-directives-to-v1"; export type RobotsJobStatus = 'pending' | 'processing' | 'completed' | 'errored' | 'cancelled'; export type RobotsRunStatus = 'pending' | 'dispatching' | 'running' | 'waiting' | 'completed' | 'partial' | 'errored'; /** * A row whose create hasn't been matched to a Mux job or run yet: `requested` while the plugin waits * for Mux's answer, `unconfirmed` when that answer never came. */ export type RobotsPlaceholderStatus = 'requested' | 'unconfirmed'; export declare const PLACEHOLDER_STATUSES: RobotsPlaceholderStatus[]; export declare const isPlaceholderStatus: (status: unknown) => status is RobotsPlaceholderStatus; export declare const isTerminalJobStatus: (status: unknown) => status is RobotsJobStatus; export declare const isTerminalRow: (row: Pick) => boolean; export declare const statusRank: (row: { status?: string | null; is_directive_run?: boolean | null; }) => number; /** One step of a directive run, as Mux reports it in `node_states`: v1 and v0 names both. */ export interface RobotsNodeState { reference_id?: string; status?: 'dispatched' | 'failed' | 'waiting_for_resources' | 'waiting_for_source_bindings' | 'waiting_for_source_workflow' | string; /** v1. */ workflow?: string; /** v0. */ workflow_name?: string; /** `dispatched` only. */ job_id?: string; /** `failed` only. */ reason?: string; /** v1 `waiting_for_source_bindings`: binding reference ids, not workflows. */ source_bindings?: string[]; /** v0 `waiting_for_source_workflow`. */ source_workflows?: string[]; } export interface RobotsRunData { node_states?: RobotsNodeState[]; /** Unix seconds, as Mux sends them. */ started_at?: number | null; completed_at?: number | null; } export interface RobotsJobError { type?: string; message?: string; messages?: string[]; retryable?: boolean; } /** A row of the hidden `mux-robot-job` collection: a Robots job, a directive run, or a placeholder. */ export interface RobotsJobRow { id: number; /** `rjob_…` or `drvrun_…`; null while a create is unconfirmed. */ mux_id: string | null; /** * The Robots version that created it, which every later read and cancel must use. Null on rows * stored before 4.0, which didn't record it: those are read on v0, then on v1 after a 404. */ api_version: RobotsApiVersion | null; is_directive_run: boolean; /** Catalog key, e.g. `generate-premium-captions`. Null for directive runs. */ workflow: string | null; /** On runs, and on jobs a directive dispatched. */ directive_id: string | null; /** On jobs a directive run dispatched. */ directive_run_id: string | null; status: RobotsJobStatus | RobotsRunStatus | RobotsPlaceholderStatus | string; /** The Mux asset id: what the Robots tab queries by. */ asset_id: string | null; parameters: Record | null; /** The whole `outputs` object, as Mux sent it. */ outputs: Record | null; errors: RobotsJobError[] | null; units_consumed: number | null; run_data: RobotsRunData | null; mux_created_at: string | null; mux_updated_at: string | null; /** Outputs and units are stored: the job's detail was read, from a webhook or from Mux. */ detail_loaded: boolean | null; /** Placeholders only. Never sent to Mux. */ request_id: string | null; requested_at: string | null; /** Admin user id of whoever ran it from this Strapi. */ requested_by: number | null; /** When this Strapi stored the row. */ createdAt?: string | null; } /** The newest completed summarize on an asset, as stored in `robots_outputs.summarize`. */ export interface RobotsSummarizeOutput { job_id: string; completed_at?: string; title?: string; description?: string; tags?: string[]; } export interface RobotsModerateOutput { job_id: string; completed_at?: string; exceeds_threshold?: boolean; max_scores?: Record; } /** * The newest completed analyze-structure on an asset, as stored in `robots_outputs.analyze_structure`: * only what Apply summary uses. Chapters, scenes and key moments stay on the job row, since scenes * repeat the transcript and would grow the asset with every run. */ export interface RobotsAnalyzeStructureOutput { job_id: string; completed_at?: string; title?: string; summary?: string; tags?: string[]; } /** * `mux-asset.robots_outputs`: one slot per workflow, the newest completed job winning. Only these * workflows are kept on the asset; the others' results live on the Mux asset itself (tracks, * chapters, thumbnail) or in the job rows. */ export interface RobotsOutputs { summarize?: RobotsSummarizeOutput; moderate?: RobotsModerateOutput; analyze_structure?: RobotsAnalyzeStructureOutput; } /** What Apply summary offers: the newer of the Summarize and Analyze structure slots. */ export interface RobotsSummary { source: 'summarize' | 'analyze-structure'; job_id: string; completed_at?: string; title?: string; description?: string; tags?: string[]; } /** Missing or unreadable reads as oldest, so a damaged slot can't pin itself forever. */ export declare const slotCompletionMs: (slot: { completed_at?: unknown; } | null | undefined) => number; /** * Whether `candidate` is newer than `current`: the later completion, ties going to the greater job * id, so every order of delivery settles on the same answer. */ export declare function isNewerSlot(current: { job_id?: unknown; completed_at?: unknown; } | null | undefined, candidate: { job_id: string; completed_at?: unknown; }): boolean; /** The summary Apply summary uses: the newest of the asset's Summarize and Analyze structure results. */ export declare function newestSummary(outputs: RobotsOutputs | null | undefined): RobotsSummary | undefined; /** Why Mux refused or couldn't be asked. The admin decides what to show from this, never from Mux's status. */ export type RobotsErrorReason = 'scope-missing' | 'not-enabled' | 'units-exhausted' | 'conflict' /** The video, or the caption track a workflow reads, is still being prepared. */ | 'not-ready' | 'invalid-parameters' | 'mux-error' | 'unconfirmed' | 'create-pending'; export interface RobotsErrorBody { error: { reason: RobotsErrorReason; message: string; termsUrl?: string; }; } export type RobotsCapability = 'ok' | 'scope-missing' | 'not-enabled'; export interface RobotsSyncResponse { capability: RobotsCapability; termsUrl?: string; rows: RobotsJobRow[]; /** Set when Mux couldn't be read for another reason; the stored rows are still returned. */ error?: RobotsErrorBody['error']; } export interface RobotsRowsResponse { rows: RobotsJobRow[]; } export interface RobotsRowResponse { row: RobotsJobRow; /** The create's outcome is unknown: Mux didn't answer. */ unconfirmed?: boolean; } export interface RobotsDirectiveSummary { id: string; name: string; /** Unknown when Mux's listing didn't link it. Only v1 directives can be run from Strapi. */ api_version?: RobotsApiVersion; } export interface RobotsDirectivesResponse { directives: RobotsDirectiveSummary[]; /** False when Mux has more directives than one listing returns, so a missing id proves nothing. */ complete: boolean; defaultDirectiveIds: string[]; /** Set when Mux couldn't be read: `directives` is then empty and incomplete. */ error?: RobotsErrorBody['error']; } export declare const RobotsCreateJobBody: z.ZodObject<{ workflow: z.ZodString; /** The run form's values, keyed by catalog field name. */ values: z.ZodDefault>; }, "strip", z.ZodTypeAny, { values?: Record; workflow?: string; }, { values?: Record; workflow?: string; }>; export declare const RobotsRunDirectiveBody: z.ZodObject<{ directive_id: z.ZodString; }, "strip", z.ZodTypeAny, { directive_id?: string; }, { directive_id?: string; }>; /** How long the tab keeps polling an unfinished job or run before deciding Mux has lost it. */ export declare const ROBOTS_STALE_MS: number; /** A placeholder reads "Starting…" this long after its request, then "Not confirmed". */ export declare const ROBOTS_CONFIRM_GRACE_MS: number; export declare const isPlaceholderRow: (row: Pick) => boolean; /** * Stays "starting" through the grace period even once the server knows Mux didn't answer: Mux may * still have received the create, so a re-run isn't offered straight away. */ export declare function placeholderPhase(row: Pick, nowMs?: number): 'starting' | 'unconfirmed'; /** A job or run Mux is still working on, recent enough that polling for it is worth it. */ export declare function isUnfinishedRow(row: RobotsJobRow, nowMs?: number): boolean; export type RobotsUnitsState = { kind: 'count'; units: number; } | { kind: 'not-charged'; } | { kind: 'not-counted-yet'; } | { kind: 'not-loaded'; } | { kind: 'not-reported'; }; /** What the Mux AI units column says. Every blank says why it's blank. */ export declare function unitsState(row: RobotsJobRow): RobotsUnitsState; /** The first error message Mux gave for a job, whichever shape `errors` has. */ export declare function firstErrorMessage(errors: unknown): string | undefined; /** A `temporary_*_url` in a job's outputs: Mux's link to a file it made, such as the captions. */ export interface RobotsTemporaryDownload { /** The output it came from, e.g. `temporary_vtt_url`. */ key: string; url: string; /** Unknown when neither the link nor the job says when it was made. */ expiresAtMs?: number; } /** * The download links in a job's outputs, each with when it expires: what the link itself says, or else * 7 days after the job's last update, as Mux documents. Only `https:` links, since they become `href`s. */ export declare function temporaryDownloads(row: Pick): RobotsTemporaryDownload[]; /** A Mux video an entry links to, for the Content Manager's Apply summary panel. */ export interface RobotsEntryVideo { id: number; title: string; asset_id: string | null; summary: RobotsSummary | null; } export interface RobotsEntryVideosResponse { /** One per top-level relation to Mux assets, in the content type's order. */ fields: Array<{ name: string; videos: RobotsEntryVideo[]; }>; }