export type JsonSchema = { readonly type: "object" | "array" | "string" | "number" | "integer" | "boolean" | "null"; readonly properties?: Readonly>; readonly required?: readonly string[]; readonly additionalProperties?: boolean; readonly items?: JsonSchema; readonly enum?: readonly unknown[]; readonly minLength?: number; readonly maxLength?: number; readonly minimum?: number; readonly maximum?: number; readonly maxItems?: number; readonly description?: string; readonly title?: string; }; type RequiredSchemaKeys = S extends { required: readonly (infer K)[]; } ? Extract : never; type ObjectSchemaValue = S extends { properties: infer P extends Readonly>; } ? (keyof P extends never ? S extends { additionalProperties: true; } ? Record : Record : { -readonly [K in keyof P as K extends RequiredSchemaKeys ? K : never]-?: InferJsonSchema; } & { -readonly [K in keyof P as K extends RequiredSchemaKeys ? never : K]?: InferJsonSchema; } & (S extends { additionalProperties: true; } ? Record : unknown)) : S extends { additionalProperties: true; } ? Record : Record; type SchemaValue = S extends { type: "object"; } ? ObjectSchemaValue : S extends { type: "array"; items: infer I extends JsonSchema; } ? Array> : S extends { type: "string"; } ? string : S extends { type: "number" | "integer"; } ? number : S extends { type: "boolean"; } ? boolean : S extends { type: "null"; } ? null : unknown; /** Values are inferred from the schema, not asserted with an unrelated generic. */ export type InferJsonSchema = JsonSchema extends S ? unknown : SchemaValue & (S extends { enum: readonly (infer E)[]; } ? E : unknown); export interface WorkflowInputContract { readonly name: string; readonly schema: S; } export interface MapReference { mapId: string; revision: string; } export interface ActionReference extends MapReference { stateId: string; actionId: string; } export interface EntryReference extends MapReference { entryId: string; } export interface Recognition { kind: "known" | "unknown" | "ambiguous" | "unverified"; state_id: string; candidates: string[]; } export interface Observation { observation_id: string; session_id: string; map_id: string; revision: string; operation_id: string; document_generation: string; sequence: number; captured_at: string; control_epoch: number; recognition: Recognition; surface: { success?: boolean; error?: string; context?: Record; controls?: Record[]; content?: Record[]; }; } export type TextRead = { status: "present" | "missing" | "unavailable"; value: string; }; export type WaitCondition = { any: Array<{ state: string; } | { text: { selector: string; equals?: string; contains?: string; allowExisting?: boolean; }; }>; }; export interface SessionInfo { session_id: string; slot_id: string; status: string; map_id: string; map_revision: string; controller_id: string; control_epoch: number; active_job_id?: string; active_operation_id?: string; active_recording_id?: string; observation?: Observation; recording?: Record; workflow?: Record; [key: string]: any; } export interface BrowserOperation { operation_id: string; session_id: string; status: string; kind: string; message?: string; updated_at?: string; error?: string; stages?: Array<{ at: string; message: string; }>; result?: Record; } export interface WorkflowVersion { version_id: string; name: string; maps: MapReference[]; inputs: JsonSchema; result: JsonSchema; artifact_digest: string; source?: string; } export interface WorkflowJob { job_id: string; session_id: string; version_id: string; status: string; error?: string; result?: unknown; name: string; inputs: unknown; [key: string]: any; } export interface WorkflowInputRequestFields { key: string; label?: string; secret?: boolean; timeoutMs?: number; } export type WorkflowInputRequest = WorkflowInputRequestFields & ({ contract: WorkflowInputContract; schema?: never; } | { schema?: S; contract?: never; }); export interface PendingWorkflowInput extends WorkflowInputRequestFields { schema: JsonSchema; attempt: number; } export interface WorkflowInputSubmissionOptions { attempt: number; submissionId?: string; /** The already-read request avoids a redundant GET; policy still fences stale attempts. */ waitingInput?: PendingWorkflowInput; } export interface WorkflowDefinition { name: string; maps: MapReference[]; inputs: JsonSchema; result: JsonSchema; run(context: { session: import("./browser-sessions.js").BrowserSession; /** Recognized starting page supplied by policy after workflow control is ready. */ page: import("./browser-sessions.js").PageObservation; maps: import("./workflow-maps.js").MapsResource; input: Input; note(message: string): Promise; /** Last explicitly saved continuation. Never a replay of an interrupted click. */ resume: Record | null; /** Save non-secret progress and the state IDs where a new job may resume. */ checkpoint(value: Record): Promise; waitForInput(request: WorkflowInputRequest): Promise>; }): Promise; } export declare function defineWorkflow(definition: WorkflowDefinition): WorkflowDefinition; export {};