import { URI } from "../../../../../base/common/uri.js"; import { ThemeIcon } from "../../../../../base/common/themables.js"; import type { AutomationTrigger } from "../../../../../platform/github/common/missionControl/automations.js"; import type { JsonPrimitive } from "../../../../../platform/agentHost/common/state/protocol/state.js"; /** * How often an automation runs. `hourly` fires every hour from creation/update; * `daily`/`weekly` fire at the configured hour/minute (and day-of-week); * `weekdays` fires Monday-Friday at the configured local wall-clock hour/minute; * `cron` uses the Agent Host's five-field cron grammar. */ export type AutomationInterval = "manual" | "hourly" | "daily" | "weekdays" | "weekly" | "cron" | "custom"; /** * Describes the cadence at which an automation should fire. * * Fields are local wall-clock values unless timeZone is UTC. Presentation * may convert UTC fields, but provider definitions retain their original zone. */ export interface IAutomationSchedule { readonly interval: AutomationInterval; /** Absent for Agent Host local-time semantics. */ readonly timeZone?: "UTC"; /** Five-field AHP cron expression. Required for `cron`. */ readonly cronExpression?: string; /** Preserved host time zone for `cron`; defaults to the local time zone on creation. */ readonly cronTimeZone?: string; /** Hour-of-day, 0-23. Ignored for `manual`, `hourly` and `cron`. */ readonly scheduleHour: number; /** Minute-of-hour, 0-59. Ignored for `manual`, `hourly` and `cron`. */ readonly scheduleMinute: number; /** Day-of-week, 0 (Sunday) through 6 (Saturday). Only used for `weekly`. */ readonly scheduleDay: number; } /** Repository isolation for a workspace-backed Automation target. */ export type AutomationWorkspaceIsolation = { readonly kind: "default"; } | { readonly kind: "folder"; } | { readonly kind: "worktree"; readonly branch: string; }; /** The mutually exclusive execution targets an Automation can use. */ export type AutomationTarget = { readonly kind: "workspace"; readonly folderUri: URI; readonly providerId?: string; readonly sessionTypeId?: string; readonly isolation: AutomationWorkspaceIsolation; } | { readonly kind: "quickChat"; readonly providerId: string; readonly sessionTypeId: string; }; /** Provider-owned values used to create each Automation run session. */ export interface IAutomationSessionTemplate { /** Optional language model identifier. */ readonly modelId?: string; /** Model-specific preferences, independent of provider session configuration. */ readonly modelConfiguration?: Readonly>; /** Optional custom agent selection. */ readonly agent?: { readonly uri: string; }; /** Provider-owned session configuration values. */ readonly config?: Readonly>; } export declare function isAutomationModelConfiguration(value: unknown, allowUndefined?: false): value is NonNullable; export declare function isAutomationModelConfiguration(value: unknown, allowUndefined: true): value is Readonly>; export declare function assertAutomationSessionTemplate(template: IAutomationSessionTemplate | undefined): void; /** Cloud-owned event configuration, retained independently of its schedule projection. */ export interface IAutomationCloudTrigger { readonly triggers: Readonly>; readonly requireActorWritePermission?: boolean; } /** A single automation with immutable identity and provider-owned execution configuration. */ export interface IAutomationDescriptor { /** Opaque identifier, unique across concrete providers as well as within one host. */ readonly id: string; readonly name: string; readonly prompt: string; readonly schedule: IAutomationSchedule; readonly cloudTrigger?: IAutomationCloudTrigger; /** Explicit workspace-backed or workspace-less execution target. */ readonly target: AutomationTarget; /** Provider-owned display metadata for targets whose URI basename is not a useful label. */ readonly targetDisplay?: { readonly label: string; readonly icon: ThemeIcon; }; readonly externalResource?: URI; readonly ownership?: "user" | "repository"; /** Complete provider-owned session template. */ readonly sessionTemplate?: IAutomationSessionTemplate; /** @deprecated Legacy decode alias. New Automations store this in {@link sessionTemplate}. */ readonly modelId?: string; /** @deprecated Legacy decode alias. New Automations store this in {@link sessionTemplate}. */ readonly mode?: string; /** @deprecated Legacy decode alias. New Automations store this in {@link sessionTemplate}. */ readonly permissionLevel?: string; readonly enabled: boolean; /** ISO-8601 UTC timestamp. */ readonly createdAt: string; readonly updatedAt: string; readonly lastRunAt?: string; /** ISO-8601 UTC timestamp; `undefined` when interval is `manual`. */ readonly nextRunAt?: string; readonly readOnlyReason?: string; } /** * Lifecycle of an automation run. A run stays `running` while its agent session * is active or needs input, and becomes terminal when the owning Agent Host * reports completion, failure, cancellation, or timeout. */ export type AutomationRunStatus = "pending" | "running" | "completed" | "failed"; /** * What kicked off a run. `catch_up` reflects the host's misfire policy for a * due-time that passed while the host was not running. */ export type AutomationRunTrigger = "schedule" | "catch_up" | "manual" | "external"; export interface IAutomationRun { /** Opaque identifier, unique across concrete providers and historical archives. */ readonly id: string; readonly automationId: string; readonly status: AutomationRunStatus; readonly trigger: AutomationRunTrigger; /** Session resource URI, recorded as soon as the committed session is available. */ readonly sessionResource?: URI; readonly externalResource?: URI; readonly startedAt: string; readonly updatedAt?: string; readonly completedAt?: string; readonly errorMessage?: string; readonly needsInput?: boolean; readonly statusDescription?: string; }