/**
 * Run Agent Use Case
 *
 * Executes a named agent workflow by resolving it from the registry
 * and delegating to the agent runner.
 *
 * Business Rules:
 * - Agent must be registered in the registry before running
 * - Error messages include available agent names for discoverability
 * - Options are passed through to the runner as-is
 */
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 { injectable, inject } from 'tsyringe';
/**
 * Use case for running a named agent workflow.
 *
 * Algorithm:
 * 1. Validate agent exists in the registry
 * 2. Delegate to agent runner with name, prompt, and options
 * 3. Return the resulting AgentRun record
 */
let RunAgentUseCase = class RunAgentUseCase {
    agentRunner;
    agentRegistry;
    constructor(agentRunner, agentRegistry) {
        this.agentRunner = agentRunner;
        this.agentRegistry = agentRegistry;
    }
    /**
     * Execute the run agent use case.
     *
     * @param input - Agent run input including name, prompt, and options
     * @returns AgentRun record tracking the execution
     * @throws Error if the agent name is not registered
     */
    async execute(input) {
        const definition = this.agentRegistry.get(input.agentName);
        if (!definition) {
            const available = this.agentRegistry.list().map((a) => a.name);
            throw new Error(`Unknown agent: "${input.agentName}". Available agents: ${available.join(', ') || 'none'}`);
        }
        return this.agentRunner.runAgent(input.agentName, input.prompt, input.options);
    }
    /**
     * Execute the run agent use case with streaming events.
     *
     * @param input - Agent run input including name, prompt, and options
     * @returns An async iterable of agent run events
     * @throws Error if the agent name is not registered
     */
    async *executeStream(input) {
        const definition = this.agentRegistry.get(input.agentName);
        if (!definition) {
            const available = this.agentRegistry.list().map((a) => a.name);
            throw new Error(`Unknown agent: "${input.agentName}". Available agents: ${available.join(', ') || 'none'}`);
        }
        yield* this.agentRunner.runAgentStream(input.agentName, input.prompt, input.options);
    }
};
RunAgentUseCase = __decorate([
    injectable(),
    __param(0, inject('IAgentRunner')),
    __param(1, inject('IAgentRegistry')),
    __metadata("design:paramtypes", [Object, Object])
], RunAgentUseCase);
export { RunAgentUseCase };
