export type ScheduledTaskType = 'cron' | 'once' | 'interval'; export type ScheduledTaskStatus = 'success' | 'error' | 'running'; export type ScheduledTaskModelConfig = { provider: string; model: string; thinkingLevel?: 'off' | 'minimal' | 'low' | 'medium' | 'high' | 'xhigh'; authProfileId?: string; reasoning?: boolean; }; export type ScheduledTaskRunHistoryEntry = { id: string; status: ScheduledTaskStatus | 'paused' | 'resumed'; createdAt: string; sessionId?: string; message?: string; }; export type ScheduledTaskRunContext = { historyEntryId: string; sessionId: string; startedAt: string; }; export type ScheduledTask = { id: string; tenantId?: string; userId?: string; workspaceId?: string; sessionId: string; name?: string; prompt: string; type: ScheduledTaskType; schedule: string; intervalSeconds: number; enabled: boolean; model: ScheduledTaskModelConfig; toolPolicyProfile: string; workspaceDir?: string; description?: string; createdAt: string; updatedAt: string; lastRunAt?: string; nextRunAt?: string; runCount: number; timeoutMs?: number; lastStatus?: ScheduledTaskStatus; lastError?: string; runHistory?: ScheduledTaskRunHistoryEntry[]; }; export type ScheduledTaskCreateInput = Omit; export type ScheduledTaskUpdate = Partial> & { name?: string | undefined; description?: string | undefined; workspaceDir?: string | undefined; }; export type TaskSchedulerStatus = { active: boolean; pid: number; taskCount: number; scheduledTimerCount: number; scheduledCronCount: number; runningTaskIds: string[]; lock: { path: string; acquired: boolean; holderPid?: number; }; }; export type TaskSchedulerScope = { tenantId?: string; userId?: string; }; export interface TaskScheduler { list(scope?: TaskSchedulerScope): Promise; get(taskId: string, scope?: TaskSchedulerScope): Promise; status(): Promise; isActive(): boolean; create(input: ScheduledTaskCreateInput): Promise; update(taskId: string, input: ScheduledTaskUpdate, scope?: TaskSchedulerScope): Promise; delete(taskId: string, scope?: TaskSchedulerScope): Promise; runNow(taskId: string, scope?: TaskSchedulerScope): Promise; start(): Promise; stop(): Promise; } export interface ScheduledTaskStore { list(scope?: TaskSchedulerScope): Promise; get(taskId: string, scope?: TaskSchedulerScope): Promise; create(task: ScheduledTask): Promise; update(taskId: string, task: ScheduledTask, scope?: TaskSchedulerScope): Promise; delete(taskId: string, scope?: TaskSchedulerScope): Promise; } export interface SchedulerLock { readonly path: string; acquire(): boolean | Promise; release(): void | Promise; isAcquired(): boolean; holderPid(): number | undefined | Promise; extend?(): boolean | Promise; } export type ScheduledTaskRunner = (task: ScheduledTask, run: ScheduledTaskRunContext) => Promise; export type TaskSchedulerRunEvent = { task: ScheduledTask; run: ScheduledTaskRunContext; timestamp: string; }; export type TaskSchedulerFailureEvent = TaskSchedulerRunEvent & { error: string; }; export type TaskSchedulerLifecycleEvent = { timestamp: string; status: TaskSchedulerStatus; }; export type TaskSchedulerHooks = { onTaskStarted?: (event: TaskSchedulerRunEvent) => void | Promise; onTaskCompleted?: (event: TaskSchedulerRunEvent) => void | Promise; onTaskFailed?: (event: TaskSchedulerFailureEvent) => void | Promise; onSchedulerStarted?: (event: TaskSchedulerLifecycleEvent) => void | Promise; onSchedulerStopped?: (event: TaskSchedulerLifecycleEvent) => void | Promise; }; export type PersistentTaskSchedulerOptions = { store: ScheduledTaskStore; lock: SchedulerLock; runner: ScheduledTaskRunner; hooks?: TaskSchedulerHooks; lockHeartbeatMs?: number; }; export declare class PersistentTaskScheduler implements TaskScheduler { private readonly options; private readonly timers; private readonly crons; private readonly runningTaskIds; private active; private lockHeartbeat; constructor(options: PersistentTaskSchedulerOptions); list(scope?: TaskSchedulerScope): Promise; get(taskId: string, scope?: TaskSchedulerScope): Promise; status(): Promise; isActive(): boolean; create(input: ScheduledTaskCreateInput): Promise; update(taskId: string, input: ScheduledTaskUpdate, scope?: TaskSchedulerScope): Promise; delete(taskId: string, scope?: TaskSchedulerScope): Promise; runNow(taskId: string, scope?: TaskSchedulerScope): Promise; start(): Promise; stop(): Promise; private schedule; private execute; private unschedule; private refreshNextRun; private markScheduleError; private startLockHeartbeat; private emitSchedulerStarted; private emitSchedulerStopped; private emitHook; } export declare function resolveScheduledTaskDefinition(input: { type?: ScheduledTaskType; schedule?: string; }): Pick; export declare function normalizeScheduledTask(rawTask: ScheduledTask): ScheduledTask; export declare function computeNextRunAt(task: ScheduledTask): string | undefined; export declare function createTaskHistoryEntry(status: ScheduledTaskRunHistoryEntry['status'], message?: string, options?: { createdAt?: string; sessionId?: string; }): ScheduledTaskRunHistoryEntry; export declare function appendTaskHistory(history: ScheduledTaskRunHistoryEntry[] | undefined, entry: ScheduledTaskRunHistoryEntry): ScheduledTaskRunHistoryEntry[]; export declare function updateTaskHistoryEntry(history: ScheduledTaskRunHistoryEntry[] | undefined, entryId: string, patch: Pick & Pick, 'message'>): ScheduledTaskRunHistoryEntry[]; export declare function createScheduledTaskRunSessionId(): string; export declare function scheduleExpressionForCroner(value: string): string; export { default } from './extension.js'; export { FileSchedulerLock, JsonScheduledTaskStore } from './stores.js'; export { createSchedulerTools } from './tools.js'; //# sourceMappingURL=index.d.ts.map