//#region src/types.d.ts type JobKind = "workflow" | "agent" | "trigger" | "trigger-overview" | "workflow-canvas-annotations" | "workflow-overview" | "runtime" | "maintenance"; type JobTrigger = "api" | "cron" | "webhook" | "poll" | "retry" | "prompt"; /** * Identifies a run that dispatched this job as a child. The parent metadata * survives the queue boundary so the child can resume its parent at a terminal * outcome without treating the child as a separately-billable dispatch. */ type JobParent = { kind: "workflow" | "agent"; runId: string; targetId: string; correlationId?: string; }; type JobPayload = { kind: JobKind; targetId: string; runId: string; trigger: JobTrigger; payload: unknown; attempt: number; maxAttempts: number; /** True when this delivery is the final retry attempt. */ exhaustedRetries?: boolean; scheduledAt: Date; jobId: string; /** Project scope for org-wide worker queues. */ projectId?: string; /** Parent run that dispatched this child job, when applicable. */ parent?: JobParent; /** Optional W3C trace context carrier (sibling of user payload). */ traceContext?: Record; }; type EnqueueInput = { kind: JobKind; targetId: string; runId: string; trigger: JobTrigger; payload?: unknown; scheduledAt?: Date; attempt?: number; maxAttempts?: number; /** Dedupe key — pg-boss singletonKey / BullMQ jobId. */ dedupeKey?: string; /** Project scope for org-wide worker queues. */ projectId?: string; /** Parent run that dispatched this child job, when applicable. */ parent?: JobParent; /** Optional W3C trace context carrier (sibling of user payload). */ traceContext?: Record; }; type JobHandler = (job: JobPayload) => Promise; type CancelHandler = (runId: string) => void | Promise; type StopFn = () => Promise | void; type WorkerOptions = { workerId?: string; pollIntervalMs?: number; leaseSweepIntervalMs?: number; }; type JobQueue = { enqueue(input: EnqueueInput): Promise; startWorker(handler: JobHandler, options?: WorkerOptions): Promise; /** * Temporarily lends a worker slot to a child while an agent job waits on it. * Backends without a hard concurrency cap may omit it. */ withLentSlot?(fn: () => Promise): Promise; publishCancel(runId: string): Promise; subscribeCancel(handler: CancelHandler): Promise; }; type CreateJobQueueOptions = { url?: string; dialect?: "postgres" | "sqlite"; adapter?: JobQueue; plugin?: SchedulerPlugin; scope?: SchedulerScope; projectId?: string; organizationId?: string; }; type ScheduleSyncOptions = { schedules: TriggerScheduleSpec[]; scheduleOverrides?: { global?: string; byTrigger?: Record; }; }; type ScheduleTickerOptions = { pollIntervalMs?: number; batchSize?: number; /** When `organization`, claims due schedules across all projects in the org schema. */ scope?: "project" | "organization"; }; type Scheduler = JobQueue & { syncTriggerSchedules(options: ScheduleSyncOptions): Promise; startScheduleTicker(options?: ScheduleTickerOptions): Promise; fireDueSchedules(asOf?: Date): Promise; upsertTriggerSchedule?(spec: TriggerScheduleSpec, overrides?: ScheduleSyncOptions["scheduleOverrides"]): Promise; removeTriggerSchedule?(triggerSlug: string, projectId?: string): Promise; }; type CreateSchedulerOptions = CreateJobQueueOptions; declare const DEFAULT_RETRY_DELAY_MS = 5000; declare function retryDelayMs(attempt: number): number; //#endregion //#region src/contract.d.ts /** * Inlined to keep the contract database-free — structurally identical to * `@keystrokehq/database`'s `DatabaseDialect`. Importing it from the database * package would re-introduce the dependency `./contract` exists to avoid. */ type DatabaseDialect = "postgres" | "sqlite"; type SchedulerScope = "platform" | "project" | "organization"; type SchedulerPluginContext = { scope: SchedulerScope; url?: string; dialect?: DatabaseDialect; projectId?: string; organizationId?: string; }; type TriggerScheduleSpec = { triggerSlug: string; kind: "cron" | "poll"; schedule: string; /** IANA timezone for schedule wall-clock fields. When omitted, UTC. */ timezone?: string; /** Project scope for org-wide worker queues. */ projectId?: string; }; type TriggerScheduleSyncOptions = { schedules: TriggerScheduleSpec[]; scheduleOverrides?: { global?: string; byTrigger?: Record; }; }; type TriggerSchedulerStartOptions = { pollIntervalMs?: number; batchSize?: number; /** When `organization`, claims due schedules across all projects in the org schema. */ scope?: "project" | "organization"; }; type TriggerScheduler = { sync(options: TriggerScheduleSyncOptions): Promise; start(options?: TriggerSchedulerStartOptions): Promise; /** Register or refresh one trigger schedule in the firing backend. */ upsert?(spec: TriggerScheduleSpec, overrides?: TriggerScheduleSyncOptions["scheduleOverrides"]): Promise; remove?(triggerSlug: string, projectId?: string): Promise; fireDue?(asOf?: Date): Promise; }; type SchedulerPlugin = { name: string; createJobQueue(ctx: SchedulerPluginContext): Promise; createTriggerScheduler?(ctx: SchedulerPluginContext, queue: JobQueue): Promise; }; declare function defineSchedulerPlugin(plugin: SchedulerPlugin): SchedulerPlugin; //#endregion export { Scheduler as C, retryDelayMs as E, ScheduleTickerOptions as S, WorkerOptions as T, JobParent as _, TriggerScheduleSpec as a, JobTrigger as b, TriggerSchedulerStartOptions as c, CreateJobQueueOptions as d, CreateSchedulerOptions as f, JobKind as g, JobHandler as h, SchedulerScope as i, defineSchedulerPlugin as l, EnqueueInput as m, SchedulerPlugin as n, TriggerScheduleSyncOptions as o, DEFAULT_RETRY_DELAY_MS as p, SchedulerPluginContext as r, TriggerScheduler as s, DatabaseDialect as t, CancelHandler as u, JobPayload as v, StopFn as w, ScheduleSyncOptions as x, JobQueue as y }; //# sourceMappingURL=contract-GpxHe4g6.d.cts.map