import { z } from 'zod'; import { JsonStore } from '../json-store.js'; import { type InboxItem } from '../../../shared/inbox.js'; export interface WakeQueueSeenMarker { kind: string; settledAt: string; } export interface WakeQueueFile { items: Record; seen: Record; } export declare const WAKE_SEEN_RETENTION_MS: number; export declare const WAKE_SEEN_MAX_ENTRIES = 4096; export declare const WakeQueueFileSchema: z.ZodPreprocess; appendedToItemId: z.ZodOptional; completedAt: z.ZodOptional; createdAt: z.ZodString; drainRequestedAt: z.ZodOptional; drainTimeoutMs: z.ZodOptional; failedAt: z.ZodOptional; queuedAt: z.ZodOptional; resumeReason: z.ZodOptional>; settledAt: z.ZodOptional; stagedAt: z.ZodOptional; startedAt: z.ZodOptional; status: z.ZodEnum<{ completed: "completed"; failed: "failed"; queued: "queued"; running: "running"; }>; stopRequestedAt: z.ZodOptional; updatedAt: z.ZodString; workerId: z.ZodOptional; }, z.core.$strip>; id: z.ZodString; receivedAt: z.ZodString; actor: z.ZodOptional; handle: z.ZodOptional; isBot: z.ZodOptional; realName: z.ZodOptional; timezone: z.ZodOptional; name: z.ZodString; offsetSeconds: z.ZodOptional; }, z.core.$strip>>; userId: z.ZodOptional; }, z.core.$strip>>; attentionSuggestion: z.ZodOptional; channelId: z.ZodString; channelName: z.ZodOptional; files: z.ZodOptional; id: z.ZodString; mimetype: z.ZodString; name: z.ZodString; sizeBytes: z.ZodNumber; }, z.core.$strip>>>; kind: z.ZodLiteral<"slack">; messageTs: z.ZodString; permalink: z.ZodOptional; previews: z.ZodOptional; authorName: z.ZodOptional; authorSubname: z.ZodOptional; channelId: z.ZodOptional; files: z.ZodOptional; id: z.ZodString; mimetype: z.ZodString; name: z.ZodString; sizeBytes: z.ZodNumber; permalink: z.ZodOptional; }, z.core.$strip>>>; fromUrl: z.ZodOptional; isPrivate: z.ZodOptional; messageTs: z.ZodOptional; text: z.ZodString; }, z.core.$strip>>>; teamId: z.ZodString; text: z.ZodString; threadTs: z.ZodOptional; wakeReason: z.ZodOptional>; }, z.core.$strip>, z.ZodObject<{ handling: z.ZodObject<{ appendedAt: z.ZodOptional; appendedToItemId: z.ZodOptional; completedAt: z.ZodOptional; createdAt: z.ZodString; drainRequestedAt: z.ZodOptional; drainTimeoutMs: z.ZodOptional; failedAt: z.ZodOptional; queuedAt: z.ZodOptional; resumeReason: z.ZodOptional>; settledAt: z.ZodOptional; stagedAt: z.ZodOptional; startedAt: z.ZodOptional; status: z.ZodEnum<{ completed: "completed"; failed: "failed"; queued: "queued"; running: "running"; }>; stopRequestedAt: z.ZodOptional; updatedAt: z.ZodString; workerId: z.ZodOptional; }, z.core.$strip>; id: z.ZodString; receivedAt: z.ZodString; actor: z.ZodOptional; openId: z.ZodOptional; senderType: z.ZodOptional; unionId: z.ZodOptional; userId: z.ZodOptional; }, z.core.$strip>>; attentionSuggestion: z.ZodOptional; appId: z.ZodOptional; chatId: z.ZodString; chatName: z.ZodOptional; chatType: z.ZodString; files: z.ZodOptional; id: z.ZodString; mimetype: z.ZodString; name: z.ZodString; sizeBytes: z.ZodNumber; }, z.core.$strip>>>; kind: z.ZodLiteral<"feishu">; messageId: z.ZodString; parentId: z.ZodOptional; quotedMessage: z.ZodOptional>; rawContent: z.ZodOptional; rootId: z.ZodOptional; tenantKey: z.ZodOptional; text: z.ZodString; threadId: z.ZodOptional; wakeReason: z.ZodOptional>; }, z.core.$strip>, z.ZodObject<{ handling: z.ZodObject<{ appendedAt: z.ZodOptional; appendedToItemId: z.ZodOptional; completedAt: z.ZodOptional; createdAt: z.ZodString; drainRequestedAt: z.ZodOptional; drainTimeoutMs: z.ZodOptional; failedAt: z.ZodOptional; queuedAt: z.ZodOptional; resumeReason: z.ZodOptional>; settledAt: z.ZodOptional; stagedAt: z.ZodOptional; startedAt: z.ZodOptional; status: z.ZodEnum<{ completed: "completed"; failed: "failed"; queued: "queued"; running: "running"; }>; stopRequestedAt: z.ZodOptional; updatedAt: z.ZodString; workerId: z.ZodOptional; }, z.core.$strip>; id: z.ZodString; receivedAt: z.ZodString; kind: z.ZodLiteral<"feishu_onboarding">; owner: z.ZodObject<{ openId: z.ZodString; tenantBrand: z.ZodOptional>; }, z.core.$strict>; target: z.ZodObject<{ platform: z.ZodLiteral<"feishu">; receiveId: z.ZodString; receiveIdType: z.ZodLiteral<"open_id">; }, z.core.$strict>; text: z.ZodString; }, z.core.$strip>, z.ZodObject<{ handling: z.ZodObject<{ appendedAt: z.ZodOptional; appendedToItemId: z.ZodOptional; completedAt: z.ZodOptional; createdAt: z.ZodString; drainRequestedAt: z.ZodOptional; drainTimeoutMs: z.ZodOptional; failedAt: z.ZodOptional; queuedAt: z.ZodOptional; resumeReason: z.ZodOptional>; settledAt: z.ZodOptional; stagedAt: z.ZodOptional; startedAt: z.ZodOptional; status: z.ZodEnum<{ completed: "completed"; failed: "failed"; queued: "queued"; running: "running"; }>; stopRequestedAt: z.ZodOptional; updatedAt: z.ZodString; workerId: z.ZodOptional; }, z.core.$strip>; id: z.ZodString; receivedAt: z.ZodString; kind: z.ZodLiteral<"reminder">; preflightEvidence: z.ZodOptional; reminderId: z.ZodString; scheduledAt: z.ZodOptional; title: z.ZodOptional; }, z.core.$strip>, z.ZodObject<{ handling: z.ZodObject<{ appendedAt: z.ZodOptional; appendedToItemId: z.ZodOptional; completedAt: z.ZodOptional; createdAt: z.ZodString; drainRequestedAt: z.ZodOptional; drainTimeoutMs: z.ZodOptional; failedAt: z.ZodOptional; queuedAt: z.ZodOptional; resumeReason: z.ZodOptional>; settledAt: z.ZodOptional; stagedAt: z.ZodOptional; startedAt: z.ZodOptional; status: z.ZodEnum<{ completed: "completed"; failed: "failed"; queued: "queued"; running: "running"; }>; stopRequestedAt: z.ZodOptional; updatedAt: z.ZodString; workerId: z.ZodOptional; }, z.core.$strip>; id: z.ZodString; receivedAt: z.ZodString; kind: z.ZodLiteral<"memory_coherence">; scheduledSlotAt: z.ZodString; scheduledSlotLabel: z.ZodString; }, z.core.$strip>, z.ZodObject<{ handling: z.ZodObject<{ appendedAt: z.ZodOptional; appendedToItemId: z.ZodOptional; completedAt: z.ZodOptional; createdAt: z.ZodString; drainRequestedAt: z.ZodOptional; drainTimeoutMs: z.ZodOptional; failedAt: z.ZodOptional; queuedAt: z.ZodOptional; resumeReason: z.ZodOptional>; settledAt: z.ZodOptional; stagedAt: z.ZodOptional; startedAt: z.ZodOptional; status: z.ZodEnum<{ completed: "completed"; failed: "failed"; queued: "queued"; running: "running"; }>; stopRequestedAt: z.ZodOptional; updatedAt: z.ZodString; workerId: z.ZodOptional; }, z.core.$strip>; id: z.ZodString; receivedAt: z.ZodString; channelId: z.ZodString; kind: z.ZodLiteral<"onboarding">; operator: z.ZodObject<{ displayName: z.ZodString; handle: z.ZodOptional; slackUserId: z.ZodString; }, z.core.$strict>; teamId: z.ZodString; text: z.ZodString; }, z.core.$strip>, z.ZodObject<{ handling: z.ZodObject<{ appendedAt: z.ZodOptional; appendedToItemId: z.ZodOptional; completedAt: z.ZodOptional; createdAt: z.ZodString; drainRequestedAt: z.ZodOptional; drainTimeoutMs: z.ZodOptional; failedAt: z.ZodOptional; queuedAt: z.ZodOptional; resumeReason: z.ZodOptional>; settledAt: z.ZodOptional; stagedAt: z.ZodOptional; startedAt: z.ZodOptional; status: z.ZodEnum<{ completed: "completed"; failed: "failed"; queued: "queued"; running: "running"; }>; stopRequestedAt: z.ZodOptional; updatedAt: z.ZodString; workerId: z.ZodOptional; }, z.core.$strip>; id: z.ZodString; receivedAt: z.ZodString; answeredBy: z.ZodObject<{ displayName: z.ZodOptional; handle: z.ZodOptional; slackUserId: z.ZodString; }, z.core.$strict>; askId: z.ZodString; channelId: z.ZodString; channelName: z.ZodOptional; kind: z.ZodLiteral<"choice_response">; messageTs: z.ZodString; optionId: z.ZodString; optionLabel: z.ZodString; question: z.ZodString; teamId: z.ZodString; threadTs: z.ZodString; }, z.core.$strip>], "kind">>; seen: z.ZodRecord>; }, z.core.$strip>>; export declare const getWakeQueueFileStore: (agentId: string) => JsonStore; interface WakeQueueFilePersistence { read(): Promise; update(op: (current: WakeQueueFile) => WakeQueueFile | Promise): Promise; } export interface TakeNextRunnableInput { currentWorkerId?: string; isWorkerAlive: (workerId: string) => boolean; now?: Date; staleRunningMs?: number; workerId: string; } export interface TakeNextRunnableResult { item?: InboxItem; recovered: InboxItem[]; } export declare class WakeQueueStore { readonly agentId: string; private readonly store; constructor(agentId: string, store?: WakeQueueFilePersistence); find(itemId: string): Promise; /** True when the id is active work or a settled dedupe marker. */ has(itemId: string): Promise; insertIfAbsent(event: InboxItem): Promise<{ inserted: boolean; item: InboxItem; }>; /** * Clear `stagedAt` so workers may claim. No-op if missing, claimed, or already published. */ publishStaged(itemId: string): Promise; /** * Remove an unclaimed queued item and record it as seen. Used to compensate * an enqueue that later turns out to be a duplicate (legacy ledger horizon). * Returns undefined when the item is absent or already claimed. */ withdrawQueued(itemId: string): Promise; /** * Atomically settle a set of still-claimable queued items (no worker, not * staged) to seen. Used by cursor-delivery same-surface coalescing so the * selected set moves in one queue-store update. */ withdrawQueuedBatch(itemIds: string[]): Promise; /** * Drop an uncommitted staged row without a seen tombstone so the same fire id * can be staged again after cancel/snooze. No-op if missing, published, or claimed. */ abandonStaged(itemId: string): Promise; replaceItem(item: InboxItem): Promise; replaceQueuedItem(item: InboxItem): Promise; list(): Promise; takeNextRunnable(input: TakeNextRunnableInput): Promise; complete(itemId: string): Promise; fail(itemId: string): Promise; completeAppendedTo(parentItemId: string): Promise; failAppendedTo(parentItemId: string): Promise; takeQueuedBatch(input: { activeItemId: string; itemIds: string[]; workerId: string; }): Promise; requestDrain(input: { itemId: string; timeoutMs: number; }): Promise; clearDrainRequest(itemId: string): Promise; requeue(itemId: string, options?: { resumeReason?: 'runtime_restart'; }): Promise; requeueBatch(itemIds: string[]): Promise; requeueAppendedTo(parentItemId: string, options?: { resumeReason?: 'runtime_restart'; }): Promise; requestStop(itemId: string): Promise; markRunning(input: { itemId: string; startedAt?: string; workerId: string; }): Promise; markAppended(input: { itemId: string; parentItemId: string; workerId: string; }): Promise; markAppendedBatch(input: { itemIds: string[]; parentItemId: string; workerId: string; }): Promise; markSettled(input: { itemId: string; workerId: string; }): Promise; private settleItem; private settleAppendedTo; private updateAppendedTo; private updateItem; private updateItemIfPresent; private read; private update; } export {}; //# sourceMappingURL=wake-queue.store.d.ts.map