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.
- package/README.md +58 -2
- package/dist/{BaseRealtimeProvider-BehPNT1r.d.cts → BaseRealtimeProvider-BL75_HHh.d.cts} +53 -3
- package/dist/{BaseRealtimeProvider-DI4pKtOb.cjs → BaseRealtimeProvider-C2mRn1V_.cjs} +10 -0
- package/dist/{BaseRealtimeProvider-BQigr5mB.mjs → BaseRealtimeProvider-C9C3s8jx.mjs} +10 -0
- package/dist/{BaseRealtimeProvider-ClP8Wx1X.d.mts → BaseRealtimeProvider-CWJ81HIt.d.mts} +53 -3
- package/dist/{GeminiLiveProvider-DvkTgzjG.d.cts → GeminiLiveProvider-Cc1dkxW6.d.cts} +1 -1
- package/dist/{GeminiLiveProvider-x2nyx5aO.d.mts → GeminiLiveProvider-TvY_cQQZ.d.mts} +1 -1
- package/dist/{OpenAICompatibleProvider-Bdtl-UXH.mjs → OpenAICompatibleProvider-D-2OOVBU.mjs} +98 -11
- package/dist/{OpenAICompatibleProvider-NS4cKVQj.cjs → OpenAICompatibleProvider-Mp0Mefbh.cjs} +98 -11
- package/dist/audio.cjs +9 -6
- package/dist/audio.d.cts +51 -1
- package/dist/audio.d.mts +51 -1
- package/dist/audio.mjs +2 -2
- package/dist/gemini.cjs +16 -6
- package/dist/gemini.d.cts +8 -3
- package/dist/gemini.d.mts +8 -3
- package/dist/gemini.mjs +16 -6
- package/dist/index.cjs +356 -16
- package/dist/index.d.cts +211 -2
- package/dist/index.d.mts +211 -2
- package/dist/index.mjs +355 -16
- package/dist/{BackgroundAudioPlayer-iMcivjis.mjs → noise-CJ789zzj.mjs} +94 -1
- package/dist/{BackgroundAudioPlayer-jfRULWKC.cjs → noise-D9jKottW.cjs} +111 -0
- package/dist/openai.cjs +22 -8
- package/dist/openai.d.cts +31 -3
- package/dist/openai.d.mts +31 -3
- package/dist/openai.mjs +22 -8
- package/dist/{session-config-BVLl7-ha.mjs → session-config-CbifLlkV.mjs} +1 -1
- package/dist/{session-config-c8sOw1XL.cjs → session-config-CqJm2Kxz.cjs} +1 -1
- package/dist/testing.cjs +29 -2
- package/dist/testing.d.cts +31 -1
- package/dist/testing.d.mts +31 -1
- package/dist/testing.mjs +29 -2
- package/dist/xai.cjs +23 -9
- package/dist/xai.d.cts +7 -2
- package/dist/xai.d.mts +7 -2
- package/dist/xai.mjs +23 -9
- 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
|
|
3
|
+
const require_noise = require("./noise-D9jKottW.cjs");
|
|
4
4
|
const require_transcode = require("./transcode-C9aJG7_W.cjs");
|
|
5
|
-
exports.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 =
|
|
14
|
-
exports.isPresetName =
|
|
15
|
-
exports.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 =
|
|
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
|
|
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-
|
|
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
|
-
/**
|
|
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 }) =>
|
|
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 {
|
|
2
|
-
import { a as GeminiLiveSessionLike, i as GeminiLiveProviderConfig, n as GeminiLiveConnector, r as GeminiLiveProvider, t as GeminiConnectParams } from "./GeminiLiveProvider-
|
|
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
|
-
/**
|
|
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 {
|
|
2
|
-
import { a as GeminiLiveSessionLike, i as GeminiLiveProviderConfig, n as GeminiLiveConnector, r as GeminiLiveProvider, t as GeminiConnectParams } from "./GeminiLiveProvider-
|
|
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
|
-
/**
|
|
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-
|
|
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
|
-
/**
|
|
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 }) =>
|
|
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 };
|