/** * Durable single-card delivery for v3 workflow progress. * * Runtime state remains `journal.ndjson`; the sidecar below stores only Lark * delivery intent/checkpoints. All failures are reported through `onError` and * collapse to `false` so chat transport can never fail a workflow. */ import { type V3ProgressView } from '../../workflows/v3/progress-projection.js'; import { type LoadedAuthorizedV3Run } from '../../workflows/v3/run-envelope.js'; export declare const V3_PROGRESS_SIDECAR = "lark-progress-card.json"; declare const SIDECAR_SCHEMA_VERSION: 1; type ProgressTarget = { kind: 'reply' | 'chat'; id: string; }; type DeliveryState = 'pending' | 'active' | 'freeze_pending' | 'frozen' | 'withdrawn' | 'uncertain'; export interface V3ProgressCardSidecar { schemaVersion: typeof SIDECAR_SCHEMA_VERSION; runId: string; larkAppId: string; target: ProgressTarget; deliveryUuid: string; delivery: DeliveryState; messageId?: string; createdAt: string; lastProjection?: { journalEventCount: number; cardSha256: string; patchedAt: string; }; } export interface V3ProgressCardTransport { reply(larkAppId: string, rootMessageId: string, cardJson: string, uuid: string): Promise; send(larkAppId: string, chatId: string, cardJson: string, uuid: string): Promise; patch(larkAppId: string, messageId: string, cardJson: string): Promise; } export interface V3ProgressCardManagerDeps { baseDir: string; transport: V3ProgressCardTransport; buildCard(view: V3ProgressView, loaded: LoadedAuthorizedV3Run): string; onError?: (runId: string, error: unknown) => void; now?: () => Date; pollIntervalMs?: number; } export declare class V3ProgressCardManager { private readonly deps; private readonly refreshes; private readonly observers; constructor(deps: V3ProgressCardManagerDeps); /** Start a polling observer and schedule an immediate best-effort refresh. */ observe(runId: string): void; /** Stop polling and persist the latest suspended/terminal projection. */ stopAndRefresh(runId: string): Promise; /** Terminal refresh. Returns true only when one active card represents it. */ finalize(runId: string): Promise; stop(runId: string): void; close(): void; /** * Startup recovery refreshes the durable snapshot once; terminal history is * only patched when a sidecar proves that this daemon already owned one. * Continuous polling is attached exclusively by onDriveBegin. Recovery may * re-drive a journal-only attempt through the durable attempt barrier, but * cold attach itself must still avoid leaking a permanent observer timer. */ coldAttach(ownerLarkAppId: string): Promise; refresh(runId: string, options: { allowCreate: boolean; }): Promise; private runRefreshLoop; private refreshOnce; } /** * A terminal action replaced the progress card in-place (warning confirmation * or saved result). Freeze delivery so cold attach can never PATCH an older * progress projection over that user-facing terminal state. */ export declare function freezeV3ProgressCard(runDir: string): Promise; export {}; //# sourceMappingURL=v3-progress-card-manager.d.ts.map