import { AsyncStream } from "@pmate/utils";
export class AgentSdkASRClient {
    options;
    constructor(options) {
        this.options = options;
    }
    async transcribe(blob, input) {
        const token = this.options.tokenResolver?.getToken() ?? "";
        const stream = new AsyncStream();
        const task = this.options.client.stream({
            agentId: this.options.agentId,
            stream,
            params: {
                lang: input?.lang ?? "auto",
                token,
            },
            minChunkSizeBytes: this.options.minChunkSizeBytes ?? 0,
        });
        stream.push(blob);
        stream.end();
        return {
            text: String((await task.finish()) ?? "").trim(),
        };
    }
}
