import type { AutomationTemplateEventSource, AutomationTemplateSchedule, AutomationTemplateTrigger, CreateAutomationTemplateRequest, EventSource, ScheduledTask, WorkspaceAutomationTemplate } from "@opengeni/sdk"; import type { OpenGeniText } from "../../messages/runtime.js"; import { type CadenceValue } from "../../ui/cadence-picker.js"; import { type AutomationDraft } from "./automation-model.js"; import { type EventSourceChoice } from "./event-source-model.js"; import { type EventTriggersDraft } from "./event-trigger-model.js"; /** A template a person can start an automation from: built in, the host's own, or saved in the workspace. */ export interface AutomationTemplate { /** Unique among the templates offered together. */ id: string; name: string; /** One sentence: what it does. */ description: string; /** What the agent does on each run. */ instructions: string; /** Null: it runs only on its events or with Run now. */ schedule: AutomationTemplateSchedule | null; triggers: readonly AutomationTemplateTrigger[]; /** The storm guard for event runs; omitted or null takes the default. */ maxRunsPerHour?: number | null | undefined; /** When it runs, for its card: "When a pull request opens". Default: said from its schedule and triggers. */ when?: string | undefined; } /** * The templates that ship with Opengeni, in the host's language. Event * templates listen on GitHub, Linear and this workspace's meetings; offer * them where those sources can be added. */ export declare function builtinAutomationTemplates(t: OpenGeniText): AutomationTemplate[]; /** * The templates a place can offer: one with event triggers only where events * run, and one on this workspace's own events only where those are offered. */ export declare function automationTemplatesFor(templates: readonly AutomationTemplate[], options: { eventTriggers: boolean; workspaceEvents?: boolean | undefined; }): AutomationTemplate[]; /** A template saved in the workspace, as the list and the form use it. */ export declare function automationTemplateOfSaved(saved: WorkspaceAutomationTemplate): AutomationTemplate; /** The kind of source a template trigger asks for, as "Add a source" offers it. */ export declare function automationTemplateSourceChoice(source: AutomationTemplateEventSource): EventSourceChoice; /** When a template runs, for its card: its own words, else its schedule or first trigger. */ export declare function automationTemplateWhenWords(t: OpenGeniText, template: AutomationTemplate, now: Date): string; /** A template's schedule in the person's time zone, as the form edits it. */ export declare function automationTemplateCadence(schedule: AutomationTemplateSchedule, timeZone: string): CadenceValue; /** * The schedule a template keeps: the time of day and days without the time * zone, or the interval without its start. A one-time run has none. */ export declare function automationTemplateSchedule(cadence: CadenceValue | null, now: Date): AutomationTemplateSchedule | null; /** Whether `source` is of the kind a template trigger asks for. */ export declare function eventSourceFitsTemplate(wanted: AutomationTemplateEventSource, source: Pick & Partial>): boolean; /** * The source a template trigger listens on for this person: the source the * template names when they can use it, else their first active source of its * kind; empty when they have none yet. */ export declare function automationTemplateSourceId(wanted: AutomationTemplateEventSource, sources: readonly EventSource[]): string; /** * Triggers still waiting for a source get one once sources load. Returns the * same draft when nothing changed, so it is safe to run on every load. */ export declare function withTemplateSources(events: EventTriggersDraft, sources: readonly EventSource[] | undefined): EventTriggersDraft; /** * The draft a template starts: its name, message, schedule in the person's * time zone, and triggers on their own sources. A trigger whose source isn't * there yet remembers what it asks for, so `withTemplateSources` can fill it * when sources load and the editor can offer to add one. */ export declare function automationDraftFromTemplate(template: AutomationTemplate, options?: { sources?: readonly EventSource[] | undefined; timeZone?: string | undefined; }): AutomationDraft; /** * The template an automation saves as: its message, schedule and triggers. * A trigger keeps the kind of its source, and names the source only when it * is shared with the workspace; a trigger on a source the saver can't see is * left out, since its kind can't be told. */ export declare function automationTemplateFromTask(t: OpenGeniText, task: Pick, sources: readonly EventSource[], input: { name?: string | undefined; description?: string | undefined; now: Date; }): CreateAutomationTemplateRequest;