/**
 * Mock LLMManager : renvoie des sorties déterministes selon l'input,
 * et peut simuler des erreurs transitoires (429/500) via flags.
 */
export class MockLLMManager {
  constructor({failTimes=0, failCode=429} = {}) {
    this.failTimes = failTimes;
    this.failCode = failCode;
    this.calls = [];
  }
  async callModel({provider='mock', model='mock-1', input}) {
    this.calls.push({provider, model, input});
    if (this.failTimes > 0) {
      this.failTimes--;
      const err = new Error(`Mock transient ${this.failCode}`);
      err.statusCode = this.failCode;
      throw err;
    }
    // sortie déterministe simple
    const text = (typeof input === 'string' ? input : JSON.stringify(input));
    const completion = `MOCK[${model}]::` + text.slice(0, 60);
    return { completion, usage: { prompt_tokens: 100, completion_tokens: 200 } };
  }
}
