import { type ResolvedCodexNotifierConfig } from './config.js'; import { type CodexNotifierOutboxItem } from './outbox.js'; import { type CodexNotifierWorkerLease } from './worker-lock.js'; export type CodexNotifierDisposition = 'accepted' | 'duplicate'; export declare const CODEX_NOTIFIER_WORKER_STALE_MS = 90000; export interface CodexNotifierWorkerState { schemaVersion: 1; heartbeatAt: string; pendingCount: number; lastDeliveredAt: string | null; lastDisposition: CodexNotifierDisposition | null; lastError: { at: string; message: string; retryAt: string; } | null; stats: { accepted: number; duplicate: number; failed: number; }; } /** 读取 worker 的非敏感运行摘要,供 Dashboard 和诊断 CLI 展示。 */ export declare function readCodexNotifierWorkerState(dataDir: string): CodexNotifierWorkerState | null; /** Dashboard 只把近期持续刷新的 heartbeat 视为 worker 在线。 */ export declare function isCodexNotifierWorkerStateFresh(state: CodexNotifierWorkerState | null, now?: number, staleMs?: number): boolean; export interface CodexNotifierOutboxWorkerOptions { dataDir: string; emit: (item: CodexNotifierOutboxItem) => Promise; runProducer?: (signal: AbortSignal) => Promise; signal?: AbortSignal; now?: () => number; logger?: Pick; readConfig?: () => ResolvedCodexNotifierConfig; pollIntervalMs?: number; maxBatchMs?: number; } /** Dashboard 单例持有的可靠 outbox worker。 */ export declare class CodexNotifierOutboxWorker { private readonly options; private readonly statePath; private readonly retry; private readonly now; private readonly logger; private readonly readConfig; private readonly pollIntervalMs; private readonly maxBatchMs; private readonly stats; private lastDeliveredAt; private lastDisposition; private lastError; private lastStateWriteAt; constructor(options: CodexNotifierOutboxWorkerOptions); private writeState; processOnce(): Promise<{ accepted: number; duplicate: number; failed: number; deferred: number; }>; /** 常驻轮询 outbox;目标 daemon 离线时保留文件并指数退避。 */ run(): Promise; } export interface CodexNotifierWorkerSupervisorOptions extends CodexNotifierOutboxWorkerOptions { acquireLease?: (dataDir: string) => CodexNotifierWorkerLease; leaseRetryMs?: number; onLeaseUnavailable?: (path: string) => void; } /** Dashboard 重叠重启时持续争抢 lease,直到本进程接管或退出。 */ export declare function runCodexNotifierWorkerSupervisor(options: CodexNotifierWorkerSupervisorOptions): Promise; //# sourceMappingURL=outbox-worker.d.ts.map