/**
 * Mock Agent Executor
 *
 * Deterministic executor for E2E tests. Returns predictable responses
 * so tests can assert on exact slugs, names, and descriptions.
 *
 * Activated via SHEP_MOCK_EXECUTOR=1 environment variable.
 */
function toSlug(text) {
    return text
        .toLowerCase()
        .replace(/[^a-z0-9\s-]/g, '')
        .replace(/\s+/g, '-')
        .replace(/-+/g, '-')
        .replace(/^-|-$/g, '');
}
function toTitleCase(text) {
    return text.replace(/\b\w/g, (c) => c.toUpperCase());
}
/**
 * Extract the quoted user input from the metadata generation prompt.
 * Prompt format: `...User request:\n"<input>"\n...`
 */
function extractUserInput(prompt) {
    const match = prompt.match(/User request:\n"(.+?)"\n/s);
    return match ? match[1] : null;
}
export class MockAgentExecutorService {
    agentType = 'claude-code';
    async execute(prompt, _options) {
        const userInput = extractUserInput(prompt);
        if (userInput) {
            const slug = toSlug(userInput);
            const name = toTitleCase(userInput);
            return {
                result: JSON.stringify({ slug, name, description: userInput }),
            };
        }
        // Default fallback for any other prompt
        return { result: '{}' };
    }
    async *executeStream(prompt, options) {
        const result = await this.execute(prompt, options);
        yield { type: 'result', content: result.result, timestamp: new Date() };
    }
    supportsFeature(_feature) {
        return false;
    }
}
