/** * TG-05/TG-06: the single production boundary for all owner-report modes. * * Digest, scheduled full, and on-demand full owner reports flow through this * coordinator (docs/development/telegram-outbound-context-inbox-design.md, * Decisions 1-3). It reserves durable report context in the messenger SQLite * database BEFORE any Telegram API call, executes exactly one send per CAS * attempt lease, and returns typed outcomes. No caller may swallow coordinator * persistence failure and report success. */ import type { ReportContextTarget, TelegramReportContextStore } from '../gateways/telegram-report-context-store.js'; import { type PendingReportDelivery } from './pending-report-store.js'; export type ReportDeliveryOutcome = { status: 'delivered'; } | { status: 'retry_scheduled'; nextAttemptAt: string; } | { status: 'definite_rejection'; reason: string; } | { status: 'cancelled'; reason: string; } /** * Live capacity refused the reservation BEFORE any Telegram send (design * Decision 5). Typed, not thrown: a full inbox must degrade the report leg * loudly, never abort the caller's whole tick. */ | { status: 'capacity_full'; reason: string; }; export interface ReportDeliveryPort { deliverPrepared(report: PendingReportDelivery): Promise; } export interface ReportDeliveryBinding { deliveryId: string; target: ReportContextTarget; payloadIdentity: string; text: string; } export interface ReportDeliveryLease { deliveryId: string; } export type TypedTelegramDeliveryOutcome = { kind: 'confirmed'; } | { kind: 'retryable'; detail: string; } | { kind: 'definite_rejection'; reason: string; }; /** * Narrow Telegram-ledger control surface (intentionally smaller than the * ledger itself): pin a delivery entry against TTL/count pruning before the * send, send the pinned entry, and release or reconcile pins. */ export interface TelegramReportDeliveryControl { claimAndPin(binding: ReportDeliveryBinding): Promise; sendPinned(lease: ReportDeliveryLease): Promise; releasePin(deliveryId: string): Promise; reconcilePins(nonterminalIds: string[], terminalIds: string[]): Promise; } export interface ReportDeliveryCoordinatorOptions { store: TelegramReportContextStore; control: TelegramReportDeliveryControl; ownerTarget: ReportContextTarget; executorId: string; nowIso?: () => string; attemptLeaseMs?: number; } export declare class ReportDeliveryCoordinator implements ReportDeliveryPort { private readonly opts; private readonly nowIso; private readonly attemptLeaseMs; constructor(opts: ReportDeliveryCoordinatorOptions); deliverPrepared(report: PendingReportDelivery): Promise; private verifyBinding; } //# sourceMappingURL=report-delivery-coordinator.d.ts.map