import type { CounterfactualAnalysis, LeavePlacement, PlanOutcome, PlanningExplanation, PlanningOutcome, PlanningReason, PlanningSnapshot, PlanningStateSnapshot, } from './leave-planner.service'; import type { PlanningArtifacts } from './leave-planner.core'; // Message contract shared by the planning coordinator and its worker; types only. export type WorkerPlanningRequest = { calculationDate?: string; declaredDays?: unknown; horizon?: { start?: unknown; end?: unknown }; balances?: unknown; rules?: unknown; identities?: unknown; labels?: unknown; deadlineMs?: unknown; progress?: unknown; }; export type WorkerRequest = | { type: 'plan'; request: WorkerPlanningRequest; } | { type: 'cancel' } | { type: 'counterfactual'; request: PlanningSnapshot; plan: PlanOutcome; placement: LeavePlacement; state?: PlanningStateSnapshot; } | { type: 'explain-checkpoint'; request: PlanningSnapshot; plan: PlanOutcome; state: PlanningStateSnapshot; interruption: PlanningReason; }; export type WorkerResponse = | { type: 'heartbeat' } | { type: 'progress'; stage: string } | { type: 'checkpoint'; plan: PlanOutcome; state?: PlanningStateSnapshot } | { type: 'result'; outcome: PlanningOutcome } | { type: 'artifacts'; artifacts: PlanningArtifacts } | { type: 'explanation'; explanation?: PlanningExplanation; explanationError?: PlanningReason; finalState?: PlanningStateSnapshot; } | { type: 'counterfactual-result'; analysis: CounterfactualAnalysis } | { type: 'error'; code?: string; message: string };