/** * Session-Scoped Loop Scheduler * * Pushes natural-language prompts into the main agent interaction on a * schedule, as if the user had typed them. This gives loop jobs full * agent capabilities (tool use, reasoning, multi-step tasks) instead of * being limited to simple shell commands. * * Key behaviour: * - When a job fires and the agent is **idle**, the prompt is injected * into the conversation automatically. * - When the agent is **busy**, the execution is skipped (recorded as * "skipped: agent busy") to avoid conflicts. * - All jobs are session-scoped and cleaned up on process exit. * * Supports: * - Fixed interval (every N seconds/minutes/hours) * - Hourly at specific minute (e.g. "every hour at :15") * - Cron expressions (minute hour day month weekday) */ import { type Tool } from '@modelcontextprotocol/sdk/types.js'; export interface LoopJob { id: string; schedule: string; /** Natural-language prompt injected into the agent conversation */ prompt: string; cwd?: string; /** If true, clear conversation context before each loop iteration */ clear?: boolean; createdAt: string; lastRunAt: string | null; nextRunAt: string | null; runCount: number; skipCount: number; lastResult: { success: boolean; summary: string; } | null; status: 'active' | 'paused'; } export interface LoopPromptEvent { jobId: string; prompt: string; cwd?: string; schedule: string; /** If true, the consumer should clear conversation context before processing */ clear?: boolean; } /** * Register a callback that fires whenever a loop job wants to inject a * prompt into the main agent conversation. * Returns an unsubscribe function. */ export declare function onLoopPrompt(callback: (event: LoopPromptEvent) => void): () => void; /** * Register a function that the scheduler calls before injecting a prompt. * If it returns `true`, the prompt is skipped for that tick. */ export declare function setAgentBusyChecker(checker: () => boolean): void; export declare function getLoopToolDefinitions(): Tool[]; export declare const LOOP_TOOL_NAMES: Set; export declare function executeLoopTool(toolName: string, args: Record): Promise; /** * Get all active loop jobs count (for status display) */ export declare function getActiveLoopCount(): number; /** * Remove all loop jobs (for testing or session cleanup) */ export declare function clearAllLoopJobs(): void; /** @deprecated Use LoopJob instead */ export type CronJob = LoopJob; /** @deprecated Use LoopPromptEvent instead */ export type CronPromptEvent = LoopPromptEvent; /** @deprecated Use getLoopToolDefinitions instead */ export declare const getCronToolDefinitions: typeof getLoopToolDefinitions; /** @deprecated Use executeLoopTool instead */ export declare const executeCronTool: typeof executeLoopTool; /** @deprecated Use LOOP_TOOL_NAMES instead */ export declare const CRON_TOOL_NAMES: Set; /** @deprecated Use onLoopPrompt instead */ export declare const onCronPrompt: typeof onLoopPrompt; /** @deprecated Use getActiveLoopCount instead */ export declare const getActiveCronCount: typeof getActiveLoopCount; /** @deprecated Use clearAllLoopJobs instead */ export declare const clearAllCronJobs: typeof clearAllLoopJobs; //# sourceMappingURL=loop.d.ts.map