/**
 * Agent Provider Configuration Types
 *
 * Data-driven configuration for multi-provider agent spawning.
 * Each provider (Claude, Codex, Gemini, etc.) has a config that describes
 * how to invoke its CLI, pass prompts, extract session IDs, and resume.
 */

export interface StructuredOutputConfig {
  /** CLI flag for structured output (e.g. "--json-schema", "--output-schema") */
  flag: string;
  /** How to pass the schema: inline JSON string, file path, or not supported */
  schemaMode: 'inline' | 'file' | 'none';
  /** Format of CLI output: single JSON object, JSONL stream, or raw text */
  outputFormat: 'json' | 'jsonl' | 'text';
}

export interface SessionIdConfig {
  /** Where to find the session ID in CLI output */
  extractFrom: 'result' | 'event';
  /** Field name containing the session ID */
  field: string;
  /** For JSONL: which event type contains the session ID */
  eventType?: string;
}

export interface NonInteractiveConfig {
  /** Subcommand for non-interactive mode (e.g. "exec" for codex, "run" for opencode) */
  subcommand?: string;
  /** Flag to pass the prompt (e.g. "-p" for gemini/cursor) */
  promptFlag?: string;
  /** Flag(s) for JSON output (e.g. "--json", "--output-format json") */
  outputFlag?: string;
}

export interface AgentProviderConfig {
  /** Provider name identifier */
  name: string;
  /** CLI binary command */
  command: string;
  /** Default autonomous-mode args */
  args: string[];
  /** Extra environment variables to set */
  env?: Record<string, string>;
  /** Process names for detection (ps matching) */
  processNames: string[];
  /** Env var name for config dir isolation (e.g. "CLAUDE_CONFIG_DIR") */
  configDirEnv?: string;
  /** Flag or subcommand for resume (e.g. "--resume", "resume") */
  resumeFlag?: string;
  /** How resume works: flag-based, subcommand-based, or unsupported */
  resumeStyle: 'flag' | 'subcommand' | 'none';
  /** How prompts are passed: native (-p built-in), flag (use nonInteractive.promptFlag), or none */
  promptMode: 'native' | 'flag' | 'none';
  /** Structured output configuration */
  structuredOutput?: StructuredOutputConfig;
  /** Session ID extraction configuration */
  sessionId?: SessionIdConfig;
  /** Non-interactive mode configuration */
  nonInteractive?: NonInteractiveConfig;
}
