import { type ReasoningEffort } from "../shared/reasoning-effort.js"; export type JobLastStatus = "success" | "error" | "running" | "skipped" | "paused"; export type JobTriggerType = "schedule" | "event" | "manual" | "webhook"; export type JobExecutionMode = "agentic" | "deterministic"; export interface JobFrontmatter { schedule: string; enabled: boolean; timezone?: string; createdBy?: string; orgId?: string; runAs?: "creator" | "shared"; /** Sticky provenance: MCP edits cannot inherit unattended action approval. */ mcpManaged?: boolean; lastRun?: string; lastHistoryId?: string; lastRunManual?: boolean; lastRunAdvanceSchedule?: boolean; lastCheck?: string; lastStatus?: JobLastStatus; lastError?: string; /** Typed code of the last failure; `consecutiveFailures` counts this code. */ lastErrorCode?: string; consecutiveFailures?: number; /** The event whose failure the streak last counted; its retries do not count again. */ lastFailedEventId?: string; /** * Set together with `enabled: false` when the framework paused the * automation after repeated identical failures. Absent for a pause the * owner chose. */ pausedReason?: string; pausedAt?: string; nextRun?: string; originScopeId?: string; deliveryPlatform?: string; deliveryDestination?: string; deliveryThreadRef?: string; deliveryTenantId?: string; model?: string; reasoningEffort?: ReasoningEffort; maxIterations?: number; maxRunInputTokens?: number; mcpTools?: string[]; triggerType?: JobTriggerType; event?: string; webhookToken?: string; condition?: string; mode?: JobExecutionMode; domain?: string; appId?: string; executionHostId?: string; /** Id of a job runner registered with `registerJobRunner`; absent means the agent loop. */ runner?: string; executionEngine?: string; executionCwd?: string; remoteRequestId?: string; remoteCommandId?: string; remoteRunId?: string; remoteAutomationRunId?: string; remoteAdvanceSchedule?: boolean; delegatedPolicyId?: string; } export declare function jobBelongsToApp(meta: Pick, appId: string | null | undefined, additionalAppIds?: readonly string[]): boolean; export declare function recoveredFactoryOwnerOrgId(meta: Pick, path: string, owner: string | null | undefined): string | null; export declare function isRecoveredFactoryJob(meta: Pick, path: string, actorAppId: string | null | undefined, owner: string | null | undefined): boolean; export interface JobResourceClassification { kind: "job" | "automation"; hasExplicitTriggerType: boolean; triggerType: JobTriggerType; } export interface ParsedJobResource { meta: JobFrontmatter; body: string; classification: JobResourceClassification; } export declare function assertDelegatedPolicyId(value: string | undefined): void; export declare function assertJobExecutionTargetFields(meta: Pick): void; /** * A runner job executes in this process; a remote host would run its stub body * as an agent prompt. Raw resource edits skip this check, so the scheduler * refuses the pair again at run time. */ export declare function assertJobRunnerTarget(meta: Pick): void; /** * 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 classifyJobFrontmatter(meta: JobFrontmatter): JobResourceClassification; export declare function parseJobResource(content: string): ParsedJobResource; export declare function classifyJobResource(content: string): JobResourceClassification; export declare function buildJobResourceContent(meta: JobFrontmatter, body: string): string; export type JobExecutionFrontmatterPatch = { lastRun?: string; lastHistoryId?: string; lastRunManual?: boolean; lastRunAdvanceSchedule?: boolean; lastCheck?: string; lastStatus?: JobLastStatus; lastError?: string; lastErrorCode?: string; consecutiveFailures?: number; lastFailedEventId?: string; pausedReason?: string; pausedAt?: string; nextRun?: string; remoteRequestId?: string; remoteCommandId?: string; remoteRunId?: string; remoteAutomationRunId?: string; remoteAdvanceSchedule?: boolean; }; export declare const JOB_EXECUTION_FRONTMATTER_KEYS: ReadonlySet; /** * Frontmatter keys present in `before` and gone from `after`, ignoring the * execution bookkeeping a run adds and clears. A job whose file loses its * editor-owned fields still schedules and runs, so nothing else notices. */ export declare function droppedJobFrontmatterKeys(before: string, after: string): string[]; export type JobFrontmatterPatchValue = string | number | boolean | readonly string[] | undefined; export type JobFrontmatterPatch = { [key: string]: JobFrontmatterPatchValue; }; export declare function patchJobFrontmatterFields(content: string, fields: JobFrontmatterPatch): string; export declare function replaceJobResourceBody(content: string, body: string): string;