import type { AgentEngine } from "../agent/engine/types.js"; import { type ActionEntry } from "../agent/production-agent.js"; import { type Resource } from "../resources/store.js"; export interface JobFrontmatter { schedule: string; enabled: boolean; createdBy?: string; orgId?: string; runAs?: "creator" | "shared"; lastRun?: string; lastStatus?: "success" | "error" | "running" | "skipped"; lastError?: string; nextRun?: string; originScopeId?: string; deliveryPlatform?: string; deliveryDestination?: string; deliveryThreadRef?: string; deliveryTenantId?: string; model?: string; /** Explicit MCP tool capabilities available to this background run. */ mcpTools?: string[]; } /** * Normalize the non-secret MCP capability references persisted with a job. * Tool names are opaque framework identifiers; URLs and credentials never * belong in job frontmatter. */ export declare function normalizeJobMcpTools(value: unknown): string[] | undefined; export declare function parseJobFrontmatter(content: string): { meta: JobFrontmatter; body: string; }; export declare function buildJobContent(meta: JobFrontmatter, body: string): string; export interface RecurringJobContext { name: string; meta: JobFrontmatter; body: string; resource: Resource; } export interface SchedulerDeps { getActions: (job?: RecurringJobContext) => Record; getSystemPrompt: (owner: string) => Promise; /** * Tool names to expose on the FIRST engine request for a job run. When * provided, every other action returned by `getActions()` is deferred * behind an attached `tool-search` entry instead of being serialized on * every scheduled tick — `runAgentLoop`'s mid-run tool expansion * (`expandActiveTools`) still lets the model discover and call them after * a search. Omit to keep the full `getActions()` set visible up front * (current behavior). The caller (not this module) knows which of the * merged actions are the app's own vs. framework additions, so this must * be supplied explicitly rather than inferred here. */ getInitialToolNames?: (job?: RecurringJobContext) => string[] | undefined; /** Optional engine override. Defaults to the resolved request engine. */ engine?: AgentEngine; apiKey?: string; model?: string; /** App/template id used for org-scoped per-app model defaults. */ appId?: string; } /** * Process all due recurring jobs. Called every 60 seconds. * Sequential execution with 5-minute timeout per job. */ export declare function processRecurringJobs(deps: SchedulerDeps): Promise; /** * A soft-timeout / no-progress checkpoint is a continuation boundary, not a * finish — but `terminalStatusForEvent` maps `auto_continue` to status * "completed". A scheduled job has no client to drive that continuation, so * without this check a truncated half-answer is recorded as a success and * shipped to the job's delivery target. Only the LAST terminal event decides: * an earlier boundary the in-invocation resume already recovered from is * followed by `done`, and that job really did finish. */ export declare function jobRunCutOffReason(run: { events?: readonly { event: { type: string; reason?: string; }; }[]; }): string | null; //# sourceMappingURL=scheduler.d.ts.map