/**
 * Built-in Agent Provider Presets
 *
 * Data-driven configuration for all supported agent CLI providers.
 * Ported from reference/gastown/internal/config/agents.go builtinPresets.
 */

import type { AgentProviderConfig } from './types.js';

export const PROVIDER_PRESETS: Record<string, AgentProviderConfig> = {
  claude: {
    name: 'claude',
    command: 'claude',
    args: ['--dangerously-skip-permissions', '--verbose'],
    processNames: ['node', 'claude'],
    configDirEnv: 'CLAUDE_CONFIG_DIR',
    resumeFlag: '--resume',
    resumeStyle: 'flag',
    promptMode: 'native',
    // No structuredOutput - schema enforcement via prompt text + validation
    sessionId: {
      extractFrom: 'event',
      field: 'session_id',
      eventType: 'system',
    },
    nonInteractive: {
      outputFlag: '--output-format stream-json',
    },
  },

  codex: {
    name: 'codex',
    command: 'codex',
    args: ['--full-auto'],
    processNames: ['codex'],
    resumeFlag: 'resume',
    resumeStyle: 'subcommand',
    promptMode: 'native',
    structuredOutput: {
      flag: '--output-schema',
      schemaMode: 'file',
      outputFormat: 'jsonl',
    },
    sessionId: {
      extractFrom: 'event',
      field: 'thread_id',
      eventType: 'thread.started',
    },
    nonInteractive: {
      subcommand: 'exec',
      outputFlag: '--json',
    },
  },

  gemini: {
    name: 'gemini',
    command: 'gemini',
    args: ['--sandbox=off'],
    processNames: ['gemini'],
    resumeFlag: '--resume',
    resumeStyle: 'flag',
    promptMode: 'flag',
    structuredOutput: {
      flag: '--output-format',
      schemaMode: 'none',
      outputFormat: 'json',
    },
    sessionId: {
      extractFrom: 'result',
      field: 'session_id',
    },
    nonInteractive: {
      promptFlag: '-p',
      outputFlag: '--output-format json',
    },
  },

  cursor: {
    name: 'cursor',
    command: 'cursor-agent',
    args: ['-f'],
    processNames: ['cursor-agent'],
    resumeStyle: 'none',
    promptMode: 'flag',
    structuredOutput: {
      flag: '--output-format',
      schemaMode: 'none',
      outputFormat: 'json',
    },
    nonInteractive: {
      promptFlag: '-p',
      outputFlag: '--output-format json',
    },
  },

  auggie: {
    name: 'auggie',
    command: 'aug',
    args: ['--allow-indexing'],
    processNames: ['aug'],
    resumeStyle: 'none',
    promptMode: 'flag',
    nonInteractive: {
      promptFlag: '-p',
    },
  },

  amp: {
    name: 'amp',
    command: 'amp',
    args: ['--allow-all'],
    processNames: ['amp'],
    resumeFlag: '--thread',
    resumeStyle: 'flag',
    promptMode: 'flag',
    sessionId: {
      extractFrom: 'result',
      field: 'thread_id',
    },
    nonInteractive: {
      promptFlag: '-p',
      outputFlag: '--json',
    },
  },

  opencode: {
    name: 'opencode',
    command: 'opencode',
    args: [],
    env: { OPENCODE_PERMISSION: '{"*":"allow"}' },
    processNames: ['opencode', 'node', 'bun'],
    resumeStyle: 'none',
    promptMode: 'flag',
    structuredOutput: {
      flag: '--format',
      schemaMode: 'none',
      outputFormat: 'json',
    },
    nonInteractive: {
      subcommand: 'run',
      promptFlag: '-p',
      outputFlag: '--format json',
    },
  },
};
