import { describe, expect, it } from "vitest";
import { AgentSdkASRClient, } from "../services/agentSdkASRClient";
describe("AgentSdkASRClient", () => {
    it("streams audio blobs through agent-sdk and returns final text", async () => {
        const seen = {
            blobSizes: [],
        };
        const client = new AgentSdkASRClient({
            client: {
                stream(request) {
                    seen.agentId = request.agentId;
                    seen.lang = String(request.params?.lang ?? "");
                    seen.token = String(request.params?.token ?? "");
                    return {
                        async finish() {
                            for await (const chunk of request.stream) {
                                seen.blobSizes.push(chunk.size);
                            }
                            return "transcribed text";
                        },
                    };
                },
            },
            agentId: "agent:transcribe",
            tokenResolver: {
                getToken: () => "user-token",
            },
            minChunkSizeBytes: 0,
        });
        const result = await client.transcribe(new Blob(["voice-bytes"]), {
            lang: "en",
        });
        expect(result.text).toBe("transcribed text");
        expect(seen.agentId).toBe("agent:transcribe");
        expect(seen.lang).toBe("en");
        expect(seen.token).toBe("user-token");
        expect(seen.blobSizes).toEqual([11]);
    });
});
