import type { Encodable } from "@automate.ax/codec" import type { FormField } from "@automate.ax/catalog" /** * Describes an automation — the function that the runtime executes in plan, * execute, deploy, and authorization contexts. */ export interface AutomationDescriptor { (parameterValues?: Readonly>): Promise | void description: string parameters?: readonly FormField[] } /** Public selector accepted by automation-targeting callables. */ export type AutomationSelector = AutomationDescriptor | string /** * Returns whether a value is an automation descriptor. * * @param value - Candidate public selector value. */ export function isAutomationDescriptor( value: unknown, ): value is AutomationDescriptor { return ( typeof value === "function" && "description" in value && typeof value.description === "string" ) } /** * Converts a public automation selector into its transport value. * * @param selector - Descriptor, description, or ID. */ export function normalizeAutomationSelector(selector: AutomationSelector) { return isAutomationDescriptor(selector) ? selector.description || "No description" : selector }