export interface Contact { phone: string; channel: "whatsapp" | "telegram" } /** Контракт канала связи (WhatsApp/Telegram). */ export interface ChannelAdapter { send(to: Contact, text: string): Promise; } export interface ScreenState { vacancyTitle: string; answers: string[]; } export type ScreenStep = | { kind: "ask"; question: string } | { kind: "done"; suitable: boolean; readyForTraining: boolean }; /** Контракт ведущего скрининг (реальная реализация — LLM). */ export interface Screener { next(state: ScreenState): Promise; } export class MockChannelAdapter implements ChannelAdapter { readonly sent: { to: Contact; text: string }[] = []; async send(to: Contact, text: string): Promise { this.sent.push({ to, text }); } } /** Мок скрининга: два фиксированных вопроса; годен и готов, если на оба ответ начинается с «да». */ export class MockScreener implements Screener { static readonly questions = ["Вам подходит работа в смену? (да/нет)", "Готовы выйти на обучение? (да/нет)"]; async next(state: ScreenState): Promise { const q = MockScreener.questions[state.answers.length]; if (q) return { kind: "ask", question: q }; const yes = (s?: string) => /^\s*да/i.test(s ?? ""); return { kind: "done", suitable: yes(state.answers[0]), readyForTraining: yes(state.answers[0]) && yes(state.answers[1]) }; } }