/** * Scheduling Notes from here. * * Substack's own composer can schedule a Note (since April 2026). This queue adds * scheduling from an AI tool or the command line, in batches, with a list you can * check and cancel. A timer in this process publishes each Note when it comes due. * * It only fires while a server is running. A Note scheduled for 9am publishes at * 9am if the machine is awake with an MCP client open, and otherwise on the next * start after that time, marked late. For Notes that must go out on time with the * laptop shut, run the server over HTTP or in Docker, or schedule in Substack. * * Several servers can share one queue: every AI tool you open starts its own. So * the queue is changed only under a lock file, a Note is claimed before it is * sent so no other server sends it again, and every write lands whole or not at * all. A queue file that cannot be read is kept and reported, never overwritten. */ export type ScheduledNote = { id: string; text: string; publish_at: string; publication_url: string; /** * scheduled: waiting for its time, or for its next try. * publishing: claimed by a server that is sending it right now. * check: it may or may not have gone out (a timeout, or a server that stopped * mid-send). Look at your Notes before scheduling it again. */ status: "scheduled" | "publishing" | "published" | "failed" | "check" | "canceled"; created_at: string; published_at?: string; published_late?: boolean; note_id?: number; error?: string; attempts?: number; next_attempt_at?: string; claimed_at?: string; claimed_by?: string; }; /** A claim this old means its server stopped mid-send. */ export declare const STALE_CLAIM_MS: number; /** Tries in all, and the wait before each retry. */ export declare const MAX_ATTEMPTS = 4; export declare class QueueError extends Error { } export declare function listScheduled(status?: ScheduledNote["status"]): ScheduledNote[]; export declare function schedule(text: string, publishAt: Date, publicationUrl: string): ScheduledNote; export declare function cancel(id: string): ScheduledNote | null; export type Publisher = (note: ScheduledNote) => Promise<{ id?: number; }>; /** * Publish every Note that is due, once. Started when the server boots and then * every minute. Notes are claimed under the lock before any is sent, so two * servers, or two overlapping runs of one, never send the same Note. They go * out one at a time, in order: firing them together invites rate limits. */ export declare function drain(publish: Publisher, now?: () => number): Promise; export declare class NoteScheduler { private timer?; private running; private readonly publish; constructor(publish: Publisher); /** One run at a time in this process: a slow send never overlaps the next tick. */ private tick; start(intervalMs?: number): void; stop(): void; }