import type { AgentId } from '../../../core/agent.ts'
import { detectClaudeCode } from './claude-code.ts'
import { detectCodex } from './codex.ts'
import { detectHermes } from './hermes.ts'
import { detectOpenClaw } from './openclaw.ts'
import type { ActionForDetection, OutcomeEvent } from './types.ts'

type Detector = (action: ActionForDetection) => OutcomeEvent[]

const REGISTRY: Record<string, Detector> = {
  'claude-code': detectClaudeCode,
  codex: detectCodex,
  openclaw: detectOpenClaw,
  hermes: detectHermes,
}

/** Returns the detector for a given agent, or a no-op if unsupported. */
export function detectorFor(agent: AgentId | string): Detector {
  return REGISTRY[agent] ?? (() => [])
}

export type { OutcomeEvent, ActionForDetection } from './types.ts'
