import type { IsoTime } from './common.js'; import type { InboxPageDTO, PageResponsesDTO, TicketSourceDTO } from './inbox.js'; /** Daemon-minted request identity. Inbox presentation has a separate opaque ticket id. */ export type HumanRequestIdDTO = string; /** The complete authored page text, inline — never a path. */ export interface HumanRequestPageDTO { dialect: 'jsx' | 'html'; source: string; } export interface HumanRequestDeliveryDTO { placement: 'inline' | 'panel'; inbox: boolean; reply: boolean; } /** Frozen at creation: the action name and its opaque payload. An omitted * `payload` is frozen as JSON null, so the completion document always carries it. */ export interface HumanRequestActionDTO { name: string; payload?: unknown; } export interface CreateHumanRequestRequest { page: HumanRequestPageDTO; delivery?: HumanRequestDeliveryDTO; source?: TicketSourceDTO; /** The one node that receives the terminal result. Required for reply-bearing pages. */ requester_node_id?: string | null; creator_cwd: string; action?: HumanRequestActionDTO; } export type HumanRequestState = 'pending' | 'answered' | 'dismissed' | 'canceled'; export type HumanRequestDeliveryState = 'none' | 'pending' | 'running' | 'accepted' | 'permanent_failed'; export interface CreateHumanRequestDTO { request_id: HumanRequestIdDTO; /** Daemon-owned directory where the request's rendered page is projected. */ request_dir: string; state: 'pending'; /** Omitted entirely when the request carries no action binding. */ action?: { name: string; }; delivery_state: HumanRequestDeliveryState; } export interface HumanRequestDeliveryFailureDTO { kind: 'exit' | 'signal' | 'timeout' | 'spawn_error'; exit_code?: number; signal?: string; message?: string; /** A bounded tail, not full output. */ stderr?: string; } export interface HumanRequestDeliveryDetailDTO { state: HumanRequestDeliveryState; /** Attempts started. */ attempt: number; /** Present only while pending after a retryable failure. */ next_attempt_at?: IsoTime; accepted_at?: IsoTime; permanent_failed_at?: IsoTime; last_failure?: HumanRequestDeliveryFailureDTO; } export interface HumanRequestDTO { request_id: HumanRequestIdDTO; /** Opaque inbox identity for inbox-only routes. */ inbox_ticket_id: string; /** Daemon-owned directory where the request's rendered page is projected. */ request_dir: string; kind: 'page' | 'review'; state: HumanRequestState; title: string; subtitle?: string; source: TicketSourceDTO; emitted_at: IsoTime; /** Present unless pending. */ settled_at?: IsoTime; /** Present only when `state` is `answered`. */ responses?: PageResponsesDTO; reason?: string; actor?: string; /** `action` and `delivery` are both omitted when no action is bound. */ action?: { name: string; payload: unknown; }; delivery?: HumanRequestDeliveryDetailDTO; /** Present exactly when this request is a page. */ page?: InboxPageDTO; } export interface ReplaceHumanRequestRequest { page: HumanRequestPageDTO; delivery?: HumanRequestDeliveryDTO; } export interface RespondHumanRequestRequest { responses: PageResponsesDTO; actor?: string; } export interface SettleHumanRequestRequest { reason?: string; actor?: string; }