import type { ProvenanceBlock } from '../receipts/schema'; export type WorkflowState = | 'active' | 'paused' | 'cancelled' | 'completed' | 'budget_capped' | 'duration_capped'; export type ReviewerVerdict = 'approve' | 'block' | 'revise' | null; export interface WorkflowConfig { name: string; budget_cap_usd: number; duration_cap_hours: number; checkpoint_every_outcomes?: number; parent_outcomes?: string[]; resume_if_exists?: boolean; metadata?: Record; user_id?: string; api_base_url?: string; license_key?: string; signingKeys?: { /** 32-byte Ed25519 secret seed. */ privateKey: Uint8Array; /** 32-byte Ed25519 public key. */ publicKey: Uint8Array; }; post_json?: (url: string, body: unknown, headers: Record) => Promise; get_json?: (url: string, headers: Record) => Promise; } export interface ReviewerCascadeEvidence { triggered: boolean; drafter_model: string | null; reviewer_model: string | null; drafter_output_hash: string | null; reviewer_verdict: ReviewerVerdict; reviewer_reasoning_hash: string | null; review_started_at: string | null; review_completed_at: string | null; } export interface ReceiptV2 { receipt_id: string; schema_version: 2; outcome_name: string; user_id: string; cost_usd: number; signed_at: string; signature: string; public_key_fingerprint: string; public_key_hex: string; workflow_id: string | null; parent_receipt_id: string | null; chain_validation_hash: string | null; workflow_checkpoint_idx: number | null; workflow_total_spend_usd_to_date: number | null; is_checkpoint: boolean; checkpoint_label: string | null; reviewer_cascade: ReviewerCascadeEvidence | null; receipt_type?: 'outcome' | 'checkpoint' | 'cancel' | 'cap_hit' | 'completed'; cancelled_reason?: string | null; } export interface CheckpointReceipt extends ReceiptV2 { is_checkpoint: true; } export interface WorkflowStatus { workflow_id: string; state: WorkflowState; total_spend_usd: number; budget_cap_usd: number; budget_remaining_usd: number; budget_pct_used: number; outcome_count: number; last_receipt_id: string | null; last_checkpoint_id: string | null; last_chain_hash: string | null; duration_elapsed_ms: number; duration_cap_ms: number; duration_remaining_ms: number; } export interface ValidationResult { ok: true; } export interface ValidationFailure { ok: false; broken_at: number; reason: 'signature_invalid' | 'chain_hash_mismatch' | 'parent_reference_mismatch'; } export type ChainValidationResult = ValidationResult | ValidationFailure; export interface ReceiptV3 extends Omit { schema_version: 3; provenance: ProvenanceBlock; }