"use strict";
var import_vitest = require("vitest");
var import_detector = require("../inference/eot/detector.cjs");
var import_vad = require("../vad.cjs");
var import_agent_session = require("./agent_session.cjs");
class FakeVAD extends import_vad.VAD {
  label = "FakeVAD";
  constructor() {
    super({ updateInterval: 32 });
  }
  stream() {
    throw new Error("not used in this test");
  }
}
(0, import_vitest.describe)("AgentSession default VAD", () => {
  (0, import_vitest.it)("auto-provisions a default VAD when none passed", async () => {
    const session = new import_agent_session.AgentSession();
    try {
      (0, import_vitest.expect)(session.vad).toBeDefined();
      (0, import_vitest.expect)(session._usingDefaultVad).toBe(true);
    } finally {
      await session.close().catch(() => {
      });
    }
  });
  (0, import_vitest.it)("explicit `vad: null` opts out", async () => {
    const session = new import_agent_session.AgentSession({ vad: null });
    try {
      (0, import_vitest.expect)(session.vad).toBeUndefined();
      (0, import_vitest.expect)(session._usingDefaultVad).toBe(false);
    } finally {
      await session.close().catch(() => {
      });
    }
  });
  (0, import_vitest.it)("user-supplied VAD keeps _usingDefaultVad false", async () => {
    const userVad = new FakeVAD();
    const session = new import_agent_session.AgentSession({ vad: userVad });
    try {
      (0, import_vitest.expect)(session.vad).toBe(userVad);
      (0, import_vitest.expect)(session._usingDefaultVad).toBe(false);
    } finally {
      await session.close().catch(() => {
      });
    }
  });
});
(0, import_vitest.describe)("AgentSession default turn detection", () => {
  (0, import_vitest.it)("auto-provisions a default TurnDetector when none given", async () => {
    const session = new import_agent_session.AgentSession();
    try {
      (0, import_vitest.expect)(session.turnDetection).toBeInstanceOf(import_detector.TurnDetector);
    } finally {
      await session.close().catch(() => {
      });
    }
  });
  (0, import_vitest.it)("explicit `turnDetection: null` opts out (no default detector built)", async () => {
    const session = new import_agent_session.AgentSession({ turnHandling: { turnDetection: null } });
    try {
      (0, import_vitest.expect)(session.turnDetection).toBeUndefined();
    } finally {
      await session.close().catch(() => {
      });
    }
  });
  (0, import_vitest.it)("passes a user-supplied turn detector through unchanged", async () => {
    const userDetector = new import_detector.TurnDetector({ version: "v1-mini" });
    const session = new import_agent_session.AgentSession({ turnHandling: { turnDetection: userDetector } });
    try {
      (0, import_vitest.expect)(session.turnDetection).toBe(userDetector);
    } finally {
      await session.close().catch(() => {
      });
    }
  });
});
//# sourceMappingURL=agent_session_default_vad.test.cjs.map