/**
 * Forge Prompts — types (V3 B1)
 *
 * A Prompt is a stored body for `body_kind='prompt'` schedules. The schedule
 * references it by name; the actual configuration (text + executor) lives
 * in `<dataDir>/prompts/<name>.yaml`. Same external-file pattern Pipeline
 * uses, so prompt fields can evolve without DB migrations.
 *
 * Wired into scheduler dispatch in B2 (#263).
 */

export interface PromptExecutorRetry {
  /** 0 = don't retry (default). Failed prompt tasks just wait for the next tick. */
  max: number;
  backoff?: 'linear' | 'exponential';
  /** Seconds before first retry. */
  initial_delay?: number;
}

export interface PromptExecutorConfig {
  /** Task timeout in seconds. Falls through to system default if unset. */
  timeout?: number;
  retry?: PromptExecutorRetry;
}

export interface PromptExecutor {
  /** Agent id from Settings. null = use system default. */
  agent: string | null;
  /** Skills attached to the dispatched task; typically includes
   *  `ai-orchestration` so the agent can discover + call connectors. */
  skills: string[];
  config?: PromptExecutorConfig;
}

export interface Prompt {
  name: string;
  /** User-authored prompt text. MUST be preserved verbatim — no LLM rewrites. */
  prompt: string;
  executor: PromptExecutor;
  created_at: string;
  updated_at: string;
}

export interface CreatePromptInput {
  name: string;
  prompt: string;
  executor?: Partial<PromptExecutor>;
}

export interface UpdatePromptInput {
  prompt?: string;
  executor?: Partial<PromptExecutor>;
}
