realtime-voice-agents 2.0.1 → 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/README.md +58 -2
  2. package/dist/{BaseRealtimeProvider-BehPNT1r.d.cts → BaseRealtimeProvider-BL75_HHh.d.cts} +53 -3
  3. package/dist/{BaseRealtimeProvider-DI4pKtOb.cjs → BaseRealtimeProvider-C2mRn1V_.cjs} +10 -0
  4. package/dist/{BaseRealtimeProvider-BQigr5mB.mjs → BaseRealtimeProvider-C9C3s8jx.mjs} +10 -0
  5. package/dist/{BaseRealtimeProvider-ClP8Wx1X.d.mts → BaseRealtimeProvider-CWJ81HIt.d.mts} +53 -3
  6. package/dist/{GeminiLiveProvider-DvkTgzjG.d.cts → GeminiLiveProvider-Cc1dkxW6.d.cts} +1 -1
  7. package/dist/{GeminiLiveProvider-x2nyx5aO.d.mts → GeminiLiveProvider-TvY_cQQZ.d.mts} +1 -1
  8. package/dist/{OpenAICompatibleProvider-Bdtl-UXH.mjs → OpenAICompatibleProvider-D-2OOVBU.mjs} +98 -11
  9. package/dist/{OpenAICompatibleProvider-NS4cKVQj.cjs → OpenAICompatibleProvider-Mp0Mefbh.cjs} +98 -11
  10. package/dist/audio.cjs +9 -6
  11. package/dist/audio.d.cts +51 -1
  12. package/dist/audio.d.mts +51 -1
  13. package/dist/audio.mjs +2 -2
  14. package/dist/gemini.cjs +16 -6
  15. package/dist/gemini.d.cts +8 -3
  16. package/dist/gemini.d.mts +8 -3
  17. package/dist/gemini.mjs +16 -6
  18. package/dist/index.cjs +356 -16
  19. package/dist/index.d.cts +211 -2
  20. package/dist/index.d.mts +211 -2
  21. package/dist/index.mjs +355 -16
  22. package/dist/{BackgroundAudioPlayer-iMcivjis.mjs → noise-CJ789zzj.mjs} +94 -1
  23. package/dist/{BackgroundAudioPlayer-jfRULWKC.cjs → noise-D9jKottW.cjs} +111 -0
  24. package/dist/openai.cjs +22 -8
  25. package/dist/openai.d.cts +31 -3
  26. package/dist/openai.d.mts +31 -3
  27. package/dist/openai.mjs +22 -8
  28. package/dist/{session-config-BVLl7-ha.mjs → session-config-CbifLlkV.mjs} +1 -1
  29. package/dist/{session-config-c8sOw1XL.cjs → session-config-CqJm2Kxz.cjs} +1 -1
  30. package/dist/testing.cjs +29 -2
  31. package/dist/testing.d.cts +31 -1
  32. package/dist/testing.d.mts +31 -1
  33. package/dist/testing.mjs +29 -2
  34. package/dist/xai.cjs +23 -9
  35. package/dist/xai.d.cts +7 -2
  36. package/dist/xai.d.mts +7 -2
  37. package/dist/xai.mjs +23 -9
  38. package/package.json +1 -1
package/dist/audio.cjs CHANGED
@@ -1,21 +1,24 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_mulaw = require("./mulaw-DLUObjdP.cjs");
3
- const require_BackgroundAudioPlayer = require("./BackgroundAudioPlayer-jfRULWKC.cjs");
3
+ const require_noise = require("./noise-D9jKottW.cjs");
4
4
  const require_transcode = require("./transcode-C9aJG7_W.cjs");
5
- exports.BackgroundAudioPlayer = require_BackgroundAudioPlayer.BackgroundAudioPlayer;
5
+ exports.BackgroundAudioPlayer = require_noise.BackgroundAudioPlayer;
6
6
  exports.InboundTranscoder = require_transcode.InboundTranscoder;
7
7
  exports.MULAW_FRAME_BYTES_20MS = require_mulaw.MULAW_FRAME_BYTES_20MS;
8
8
  exports.MULAW_SAMPLE_RATE = require_mulaw.MULAW_SAMPLE_RATE;
9
9
  exports.MULAW_SILENCE_BYTE = require_mulaw.MULAW_SILENCE_BYTE;
10
+ exports.NOISE_DBFS_FLOOR = require_noise.NOISE_DBFS_FLOOR;
11
+ exports.NoiseFloorEstimator = require_noise.NoiseFloorEstimator;
10
12
  exports.OutboundTranscoder = require_transcode.OutboundTranscoder;
11
13
  exports.Resampler = require_transcode.Resampler;
12
14
  exports.base64ByteLength = require_mulaw.base64ByteLength;
13
- exports.fadeMulaw = require_BackgroundAudioPlayer.fadeMulaw;
14
- exports.isPresetName = require_BackgroundAudioPlayer.isPresetName;
15
- exports.loadBackgroundAudio = require_BackgroundAudioPlayer.loadBackgroundAudio;
15
+ exports.fadeMulaw = require_noise.fadeMulaw;
16
+ exports.isPresetName = require_noise.isPresetName;
17
+ exports.loadBackgroundAudio = require_noise.loadBackgroundAudio;
16
18
  exports.mulawBytesToMs = require_mulaw.mulawBytesToMs;
17
19
  exports.mulawDecodeSample = require_mulaw.mulawDecodeSample;
18
20
  exports.mulawEncodeSample = require_mulaw.mulawEncodeSample;
21
+ exports.mulawFrameDbfs = require_noise.mulawFrameDbfs;
19
22
  exports.mulawToPcm16 = require_mulaw.mulawToPcm16;
20
23
  exports.pcm16ToMulaw = require_mulaw.pcm16ToMulaw;
21
- exports.scaleMulaw = require_BackgroundAudioPlayer.scaleMulaw;
24
+ exports.scaleMulaw = require_noise.scaleMulaw;
package/dist/audio.d.cts CHANGED
@@ -25,6 +25,56 @@ declare function mulawBytesToMs(bytes: number): number;
25
25
  /** Byte length of a base64 string without decoding it. */
26
26
  declare function base64ByteLength(base64: string): number;
27
27
  //#endregion
28
+ //#region src/audio/noise.d.ts
29
+ /**
30
+ * Inbound noise metering: μ-law frames → dBFS levels → a sliding noise-floor
31
+ * estimate. Pure DSP — no timers, no audio-path buffering, no base64. The
32
+ * caller decides which frames to feed (exclusion policy lives upstream), so
33
+ * the estimator stays reusable outside the bridge.
34
+ */
35
+ /** Clamp for silent/near-silent frames (all-0xFF μ-law decodes to 0). */
36
+ declare const NOISE_DBFS_FLOOR = -100;
37
+ /**
38
+ * RMS level of a μ-law frame in dBFS relative to PCM16 full scale (32768).
39
+ * μ-law's max decoded magnitude is 32124, so a full-scale μ-law tone reads
40
+ * ≈ −0.17 dBFS instead of 0 — negligible, and the numbers stay comparable to
41
+ * any standard PCM16 meter.
42
+ */
43
+ declare function mulawFrameDbfs(mulaw: Uint8Array): number;
44
+ interface NoiseFloorEstimatorOptions {
45
+ /** Sliding window of analyzed audio. Default 5000. */
46
+ windowMs?: number;
47
+ /** Percentile of per-slot RMS taken as the floor. Default 0.2. */
48
+ percentile?: number;
49
+ }
50
+ /**
51
+ * Sliding-window noise-floor estimator over 20 ms μ-law slots.
52
+ *
53
+ * The floor is a low percentile of per-slot RMS: speech bursts sit above it
54
+ * without inflating it, and genuine quiet pauses pull it down. With the
55
+ * default p20, `floorDb() ≥ T` means at least 80% of the window sits at or
56
+ * above T — pervasive line noise, not a loud caller. O(1) per slot: a 1 dB
57
+ * histogram plus a ring buffer of bucket indices.
58
+ */
59
+ declare class NoiseFloorEstimator {
60
+ private readonly windowFrames;
61
+ private readonly percentile;
62
+ private readonly histogram;
63
+ private readonly ring;
64
+ private ringIndex;
65
+ private count;
66
+ /** <20 ms tail carried between addAudio calls (real Twilio frames are exactly 160 bytes). */
67
+ private residual;
68
+ constructor(options?: NoiseFloorEstimatorOptions);
69
+ /** Feed raw μ-law bytes (any length; 20 ms slotting + residual carry inside). */
70
+ addAudio(mulaw: Uint8Array): void;
71
+ /** True once a full window of analyzed audio has been observed. */
72
+ get isWarm(): boolean;
73
+ /** Noise floor over the window, dBFS in [NOISE_DBFS_FLOOR, 0]. */
74
+ floorDb(): number;
75
+ private addSlot;
76
+ }
77
+ //#endregion
28
78
  //#region src/audio/resampler.d.ts
29
79
  /**
30
80
  * Stateful polyphase FIR sample-rate converter.
@@ -162,4 +212,4 @@ declare function isPresetName(spec: BackgroundAudioSpec): spec is BackgroundAudi
162
212
  /** Resolve a spec to raw μ-law bytes (cached per preset/path). */
163
213
  declare function loadBackgroundAudio(spec: BackgroundAudioSpec): Buffer;
164
214
  //#endregion
165
- export { type BackgroundAudioOptions, BackgroundAudioPlayer, type BackgroundAudioPlayerDeps, type BackgroundAudioPreset, type BackgroundAudioSpec, InboundTranscoder, MULAW_FRAME_BYTES_20MS, MULAW_SAMPLE_RATE, MULAW_SILENCE_BYTE, OutboundTranscoder, Resampler, type ResamplerOptions, base64ByteLength, fadeMulaw, isPresetName, loadBackgroundAudio, mulawBytesToMs, mulawDecodeSample, mulawEncodeSample, mulawToPcm16, pcm16ToMulaw, scaleMulaw };
215
+ export { type BackgroundAudioOptions, BackgroundAudioPlayer, type BackgroundAudioPlayerDeps, type BackgroundAudioPreset, type BackgroundAudioSpec, InboundTranscoder, MULAW_FRAME_BYTES_20MS, MULAW_SAMPLE_RATE, MULAW_SILENCE_BYTE, NOISE_DBFS_FLOOR, NoiseFloorEstimator, type NoiseFloorEstimatorOptions, OutboundTranscoder, Resampler, type ResamplerOptions, base64ByteLength, fadeMulaw, isPresetName, loadBackgroundAudio, mulawBytesToMs, mulawDecodeSample, mulawEncodeSample, mulawFrameDbfs, mulawToPcm16, pcm16ToMulaw, scaleMulaw };
package/dist/audio.d.mts CHANGED
@@ -25,6 +25,56 @@ declare function mulawBytesToMs(bytes: number): number;
25
25
  /** Byte length of a base64 string without decoding it. */
26
26
  declare function base64ByteLength(base64: string): number;
27
27
  //#endregion
28
+ //#region src/audio/noise.d.ts
29
+ /**
30
+ * Inbound noise metering: μ-law frames → dBFS levels → a sliding noise-floor
31
+ * estimate. Pure DSP — no timers, no audio-path buffering, no base64. The
32
+ * caller decides which frames to feed (exclusion policy lives upstream), so
33
+ * the estimator stays reusable outside the bridge.
34
+ */
35
+ /** Clamp for silent/near-silent frames (all-0xFF μ-law decodes to 0). */
36
+ declare const NOISE_DBFS_FLOOR = -100;
37
+ /**
38
+ * RMS level of a μ-law frame in dBFS relative to PCM16 full scale (32768).
39
+ * μ-law's max decoded magnitude is 32124, so a full-scale μ-law tone reads
40
+ * ≈ −0.17 dBFS instead of 0 — negligible, and the numbers stay comparable to
41
+ * any standard PCM16 meter.
42
+ */
43
+ declare function mulawFrameDbfs(mulaw: Uint8Array): number;
44
+ interface NoiseFloorEstimatorOptions {
45
+ /** Sliding window of analyzed audio. Default 5000. */
46
+ windowMs?: number;
47
+ /** Percentile of per-slot RMS taken as the floor. Default 0.2. */
48
+ percentile?: number;
49
+ }
50
+ /**
51
+ * Sliding-window noise-floor estimator over 20 ms μ-law slots.
52
+ *
53
+ * The floor is a low percentile of per-slot RMS: speech bursts sit above it
54
+ * without inflating it, and genuine quiet pauses pull it down. With the
55
+ * default p20, `floorDb() ≥ T` means at least 80% of the window sits at or
56
+ * above T — pervasive line noise, not a loud caller. O(1) per slot: a 1 dB
57
+ * histogram plus a ring buffer of bucket indices.
58
+ */
59
+ declare class NoiseFloorEstimator {
60
+ private readonly windowFrames;
61
+ private readonly percentile;
62
+ private readonly histogram;
63
+ private readonly ring;
64
+ private ringIndex;
65
+ private count;
66
+ /** <20 ms tail carried between addAudio calls (real Twilio frames are exactly 160 bytes). */
67
+ private residual;
68
+ constructor(options?: NoiseFloorEstimatorOptions);
69
+ /** Feed raw μ-law bytes (any length; 20 ms slotting + residual carry inside). */
70
+ addAudio(mulaw: Uint8Array): void;
71
+ /** True once a full window of analyzed audio has been observed. */
72
+ get isWarm(): boolean;
73
+ /** Noise floor over the window, dBFS in [NOISE_DBFS_FLOOR, 0]. */
74
+ floorDb(): number;
75
+ private addSlot;
76
+ }
77
+ //#endregion
28
78
  //#region src/audio/resampler.d.ts
29
79
  /**
30
80
  * Stateful polyphase FIR sample-rate converter.
@@ -162,4 +212,4 @@ declare function isPresetName(spec: BackgroundAudioSpec): spec is BackgroundAudi
162
212
  /** Resolve a spec to raw μ-law bytes (cached per preset/path). */
163
213
  declare function loadBackgroundAudio(spec: BackgroundAudioSpec): Buffer;
164
214
  //#endregion
165
- export { type BackgroundAudioOptions, BackgroundAudioPlayer, type BackgroundAudioPlayerDeps, type BackgroundAudioPreset, type BackgroundAudioSpec, InboundTranscoder, MULAW_FRAME_BYTES_20MS, MULAW_SAMPLE_RATE, MULAW_SILENCE_BYTE, OutboundTranscoder, Resampler, type ResamplerOptions, base64ByteLength, fadeMulaw, isPresetName, loadBackgroundAudio, mulawBytesToMs, mulawDecodeSample, mulawEncodeSample, mulawToPcm16, pcm16ToMulaw, scaleMulaw };
215
+ export { type BackgroundAudioOptions, BackgroundAudioPlayer, type BackgroundAudioPlayerDeps, type BackgroundAudioPreset, type BackgroundAudioSpec, InboundTranscoder, MULAW_FRAME_BYTES_20MS, MULAW_SAMPLE_RATE, MULAW_SILENCE_BYTE, NOISE_DBFS_FLOOR, NoiseFloorEstimator, type NoiseFloorEstimatorOptions, OutboundTranscoder, Resampler, type ResamplerOptions, base64ByteLength, fadeMulaw, isPresetName, loadBackgroundAudio, mulawBytesToMs, mulawDecodeSample, mulawEncodeSample, mulawFrameDbfs, mulawToPcm16, pcm16ToMulaw, scaleMulaw };
package/dist/audio.mjs CHANGED
@@ -1,4 +1,4 @@
1
1
  import { a as mulawBytesToMs, c as mulawToPcm16, i as base64ByteLength, l as pcm16ToMulaw, n as MULAW_SAMPLE_RATE, o as mulawDecodeSample, r as MULAW_SILENCE_BYTE, s as mulawEncodeSample, t as MULAW_FRAME_BYTES_20MS } from "./mulaw--cwU2c9L.mjs";
2
- import { a as scaleMulaw, i as fadeMulaw, n as isPresetName, r as loadBackgroundAudio, t as BackgroundAudioPlayer } from "./BackgroundAudioPlayer-iMcivjis.mjs";
2
+ import { a as isPresetName, c as scaleMulaw, i as BackgroundAudioPlayer, n as NoiseFloorEstimator, o as loadBackgroundAudio, r as mulawFrameDbfs, s as fadeMulaw, t as NOISE_DBFS_FLOOR } from "./noise-CJ789zzj.mjs";
3
3
  import { n as OutboundTranscoder, r as Resampler, t as InboundTranscoder } from "./transcode-CsAp97G9.mjs";
4
- export { BackgroundAudioPlayer, InboundTranscoder, MULAW_FRAME_BYTES_20MS, MULAW_SAMPLE_RATE, MULAW_SILENCE_BYTE, OutboundTranscoder, Resampler, base64ByteLength, fadeMulaw, isPresetName, loadBackgroundAudio, mulawBytesToMs, mulawDecodeSample, mulawEncodeSample, mulawToPcm16, pcm16ToMulaw, scaleMulaw };
4
+ export { BackgroundAudioPlayer, InboundTranscoder, MULAW_FRAME_BYTES_20MS, MULAW_SAMPLE_RATE, MULAW_SILENCE_BYTE, NOISE_DBFS_FLOOR, NoiseFloorEstimator, OutboundTranscoder, Resampler, base64ByteLength, fadeMulaw, isPresetName, loadBackgroundAudio, mulawBytesToMs, mulawDecodeSample, mulawEncodeSample, mulawFrameDbfs, mulawToPcm16, pcm16ToMulaw, scaleMulaw };
package/dist/gemini.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_BaseRealtimeProvider = require("./BaseRealtimeProvider-DI4pKtOb.cjs");
2
+ const require_BaseRealtimeProvider = require("./BaseRealtimeProvider-C2mRn1V_.cjs");
3
3
  const require_env = require("./env-DSnGaERV.cjs");
4
4
  const require_transcode = require("./transcode-C9aJG7_W.cjs");
5
5
  //#region src/providers/gemini/GeminiLiveProvider.ts
@@ -125,6 +125,7 @@ var GeminiLiveProvider = class extends require_BaseRealtimeProvider.BaseRealtime
125
125
  throw setupError ?? (error instanceof Error ? error : new Error(String(error)));
126
126
  }
127
127
  await setupDone;
128
+ this.effectiveVadValue = init.vad !== void 0 ? init.vad : this.config.defaultVad;
128
129
  } finally {
129
130
  clearTimeout(timer);
130
131
  }
@@ -372,12 +373,14 @@ const GEMINI_VOICES = [
372
373
  "Kore",
373
374
  "Puck"
374
375
  ];
375
- /** Create a Gemini Live provider factory for the bridge. */
376
+ /**
377
+ * Create a Gemini Live provider factory for the bridge. Credentials are
378
+ * resolved per call (see `openaiRealtime` — missing credentials fail that
379
+ * call's connect so a fallback chain can absorb it, instead of crashing
380
+ * config construction).
381
+ */
376
382
  function geminiLive(options = {}) {
377
- const apiKey = require_env.resolveApiKey(options.apiKey, GEMINI_KEY_ENV_VARS);
378
- if (!apiKey && !options.vertex && !options.connector) throw new Error(`geminiLive: credentials missing (pass apiKey, set one of ${GEMINI_KEY_ENV_VARS.join("/")}, or configure vertex)`);
379
383
  const config = {
380
- apiKey,
381
384
  vertex: options.vertex,
382
385
  model: options.model ?? "gemini-2.5-flash-native-audio-preview-12-2025",
383
386
  voice: options.voice ?? "Aoede",
@@ -390,7 +393,14 @@ function geminiLive(options = {}) {
390
393
  connectTimeoutMs: options.connectTimeoutMs,
391
394
  connector: options.connector
392
395
  };
393
- return ({ logger }) => new GeminiLiveProvider(config, logger);
396
+ return ({ logger }) => {
397
+ const apiKey = require_env.resolveApiKey(options.apiKey, GEMINI_KEY_ENV_VARS);
398
+ if (!apiKey && !options.vertex && !options.connector) throw new Error(`geminiLive: credentials missing (pass apiKey, set one of ${GEMINI_KEY_ENV_VARS.join("/")}, or configure vertex)`);
399
+ return new GeminiLiveProvider({
400
+ ...config,
401
+ apiKey
402
+ }, logger);
403
+ };
394
404
  }
395
405
  //#endregion
396
406
  exports.GEMINI_DEFAULT_MODEL = GEMINI_DEFAULT_MODEL;
package/dist/gemini.d.cts CHANGED
@@ -1,5 +1,5 @@
1
- import { c as VadConfig, n as ProviderFactory } from "./BaseRealtimeProvider-BehPNT1r.cjs";
2
- import { a as GeminiLiveSessionLike, i as GeminiLiveProviderConfig, n as GeminiLiveConnector, r as GeminiLiveProvider, t as GeminiConnectParams } from "./GeminiLiveProvider-DvkTgzjG.cjs";
1
+ import { l as VadConfig, n as ProviderFactory } from "./BaseRealtimeProvider-BL75_HHh.cjs";
2
+ import { a as GeminiLiveSessionLike, i as GeminiLiveProviderConfig, n as GeminiLiveConnector, r as GeminiLiveProvider, t as GeminiConnectParams } from "./GeminiLiveProvider-Cc1dkxW6.cjs";
3
3
  //#region src/gemini.d.ts
4
4
  /** Env vars checked (in order) when no explicit apiKey is passed. */
5
5
  declare const GEMINI_KEY_ENV_VARS: readonly ["GOOGLE_API_KEY", "GEMINI_API_KEY", "GOOGLE_GENAI_API_KEY"];
@@ -35,7 +35,12 @@ interface GeminiLiveOptions {
35
35
  /** Test seam: replaces the @google/genai live connection. */
36
36
  connector?: GeminiLiveConnector;
37
37
  }
38
- /** Create a Gemini Live provider factory for the bridge. */
38
+ /**
39
+ * Create a Gemini Live provider factory for the bridge. Credentials are
40
+ * resolved per call (see `openaiRealtime` — missing credentials fail that
41
+ * call's connect so a fallback chain can absorb it, instead of crashing
42
+ * config construction).
43
+ */
39
44
  declare function geminiLive(options?: GeminiLiveOptions): ProviderFactory;
40
45
  //#endregion
41
46
  export { GEMINI_DEFAULT_MODEL, GEMINI_DEFAULT_VOICE, GEMINI_KEY_ENV_VARS, GEMINI_VOICES, type GeminiConnectParams, type GeminiLiveConnector, GeminiLiveOptions, GeminiLiveProvider, type GeminiLiveProviderConfig, type GeminiLiveSessionLike, geminiLive };
package/dist/gemini.d.mts CHANGED
@@ -1,5 +1,5 @@
1
- import { c as VadConfig, n as ProviderFactory } from "./BaseRealtimeProvider-ClP8Wx1X.mjs";
2
- import { a as GeminiLiveSessionLike, i as GeminiLiveProviderConfig, n as GeminiLiveConnector, r as GeminiLiveProvider, t as GeminiConnectParams } from "./GeminiLiveProvider-x2nyx5aO.mjs";
1
+ import { l as VadConfig, n as ProviderFactory } from "./BaseRealtimeProvider-CWJ81HIt.mjs";
2
+ import { a as GeminiLiveSessionLike, i as GeminiLiveProviderConfig, n as GeminiLiveConnector, r as GeminiLiveProvider, t as GeminiConnectParams } from "./GeminiLiveProvider-TvY_cQQZ.mjs";
3
3
  //#region src/gemini.d.ts
4
4
  /** Env vars checked (in order) when no explicit apiKey is passed. */
5
5
  declare const GEMINI_KEY_ENV_VARS: readonly ["GOOGLE_API_KEY", "GEMINI_API_KEY", "GOOGLE_GENAI_API_KEY"];
@@ -35,7 +35,12 @@ interface GeminiLiveOptions {
35
35
  /** Test seam: replaces the @google/genai live connection. */
36
36
  connector?: GeminiLiveConnector;
37
37
  }
38
- /** Create a Gemini Live provider factory for the bridge. */
38
+ /**
39
+ * Create a Gemini Live provider factory for the bridge. Credentials are
40
+ * resolved per call (see `openaiRealtime` — missing credentials fail that
41
+ * call's connect so a fallback chain can absorb it, instead of crashing
42
+ * config construction).
43
+ */
39
44
  declare function geminiLive(options?: GeminiLiveOptions): ProviderFactory;
40
45
  //#endregion
41
46
  export { GEMINI_DEFAULT_MODEL, GEMINI_DEFAULT_VOICE, GEMINI_KEY_ENV_VARS, GEMINI_VOICES, type GeminiConnectParams, type GeminiLiveConnector, GeminiLiveOptions, GeminiLiveProvider, type GeminiLiveProviderConfig, type GeminiLiveSessionLike, geminiLive };
package/dist/gemini.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { a as noopLogger, n as deepMerge, t as BaseRealtimeProvider } from "./BaseRealtimeProvider-BQigr5mB.mjs";
1
+ import { a as noopLogger, n as deepMerge, t as BaseRealtimeProvider } from "./BaseRealtimeProvider-C9C3s8jx.mjs";
2
2
  import { t as resolveApiKey } from "./env-DUwUWTsg.mjs";
3
3
  import { n as OutboundTranscoder, t as InboundTranscoder } from "./transcode-CsAp97G9.mjs";
4
4
  //#region src/providers/gemini/GeminiLiveProvider.ts
@@ -124,6 +124,7 @@ var GeminiLiveProvider = class extends BaseRealtimeProvider {
124
124
  throw setupError ?? (error instanceof Error ? error : new Error(String(error)));
125
125
  }
126
126
  await setupDone;
127
+ this.effectiveVadValue = init.vad !== void 0 ? init.vad : this.config.defaultVad;
127
128
  } finally {
128
129
  clearTimeout(timer);
129
130
  }
@@ -371,12 +372,14 @@ const GEMINI_VOICES = [
371
372
  "Kore",
372
373
  "Puck"
373
374
  ];
374
- /** Create a Gemini Live provider factory for the bridge. */
375
+ /**
376
+ * Create a Gemini Live provider factory for the bridge. Credentials are
377
+ * resolved per call (see `openaiRealtime` — missing credentials fail that
378
+ * call's connect so a fallback chain can absorb it, instead of crashing
379
+ * config construction).
380
+ */
375
381
  function geminiLive(options = {}) {
376
- const apiKey = resolveApiKey(options.apiKey, GEMINI_KEY_ENV_VARS);
377
- if (!apiKey && !options.vertex && !options.connector) throw new Error(`geminiLive: credentials missing (pass apiKey, set one of ${GEMINI_KEY_ENV_VARS.join("/")}, or configure vertex)`);
378
382
  const config = {
379
- apiKey,
380
383
  vertex: options.vertex,
381
384
  model: options.model ?? "gemini-2.5-flash-native-audio-preview-12-2025",
382
385
  voice: options.voice ?? "Aoede",
@@ -389,7 +392,14 @@ function geminiLive(options = {}) {
389
392
  connectTimeoutMs: options.connectTimeoutMs,
390
393
  connector: options.connector
391
394
  };
392
- return ({ logger }) => new GeminiLiveProvider(config, logger);
395
+ return ({ logger }) => {
396
+ const apiKey = resolveApiKey(options.apiKey, GEMINI_KEY_ENV_VARS);
397
+ if (!apiKey && !options.vertex && !options.connector) throw new Error(`geminiLive: credentials missing (pass apiKey, set one of ${GEMINI_KEY_ENV_VARS.join("/")}, or configure vertex)`);
398
+ return new GeminiLiveProvider({
399
+ ...config,
400
+ apiKey
401
+ }, logger);
402
+ };
393
403
  }
394
404
  //#endregion
395
405
  export { GEMINI_DEFAULT_MODEL, GEMINI_DEFAULT_VOICE, GEMINI_KEY_ENV_VARS, GEMINI_VOICES, GeminiLiveProvider, geminiLive };