/**
 * AgentCliAvailabilityDiagnostic
 *
 * Reports whether at least one supported agent CLI (Claude Code, Cursor,
 * Gemini, Codex, Copilot) is authenticated. Shep needs at least one
 * available agent to drive any feature flow; this check warns rather than
 * fails so a contributor can still run `shep doctor` itself before signing
 * in to any provider.
 */
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var __param = (this && this.__param) || function (paramIndex, decorator) {
    return function (target, key) { decorator(target, key, paramIndex); }
};
import { inject, injectable } from 'tsyringe';
import { AgentType, DiagnosticStatus } from '../../../../domain/generated/output.js';
const AGENT_PROBES = [
    { type: AgentType.ClaudeCode, binary: null, label: 'Claude Code' },
    { type: AgentType.Cursor, binary: 'cursor', label: 'Cursor' },
    { type: AgentType.GeminiCli, binary: 'gemini', label: 'Gemini CLI' },
    { type: AgentType.CodexCli, binary: 'codex', label: 'Codex CLI' },
    { type: AgentType.CopilotCli, binary: 'gh', label: 'Copilot CLI' },
];
let AgentCliAvailabilityDiagnostic = class AgentCliAvailabilityDiagnostic {
    authDetector;
    name = 'agent-cli-availability';
    constructor(authDetector) {
        this.authDetector = authDetector;
    }
    async run() {
        const settled = await Promise.all(AGENT_PROBES.map(async (probe) => ({
            probe,
            ok: await this.authDetector.isAuthenticated(probe.type, probe.binary).catch(() => false),
        })));
        const authed = settled.filter((s) => s.ok).map((s) => s.probe.label);
        if (authed.length === 0) {
            return {
                name: this.name,
                status: DiagnosticStatus.Warn,
                detail: 'No agent CLI is authenticated (Claude Code / Cursor / Gemini / Codex / Copilot)',
                fixHint: 'Sign in to at least one agent (e.g. `claude auth login` or `gh auth login`)',
            };
        }
        return {
            name: this.name,
            status: DiagnosticStatus.Ok,
            detail: `Authenticated agents: ${authed.join(', ')}`,
        };
    }
};
AgentCliAvailabilityDiagnostic = __decorate([
    injectable(),
    __param(0, inject('IAgentAuthDetectorService')),
    __metadata("design:paramtypes", [Object])
], AgentCliAvailabilityDiagnostic);
export { AgentCliAvailabilityDiagnostic };
