@absolutejs/voice 0.0.22-beta.540 → 0.0.22-beta.542
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/dist/core/types.d.ts +2 -2
- package/dist/index.js +21 -13
- package/dist/testing/index.js +9 -5
- package/package.json +1 -1
package/dist/core/types.d.ts
CHANGED
|
@@ -737,7 +737,7 @@ export type VoiceSurfaceConfig<O> = false | O | (Record<string, never> extends O
|
|
|
737
737
|
export type VoicePluginConfig<TContext = unknown, TSession extends VoiceSessionRecord = VoiceSessionRecord, TResult = unknown> = {
|
|
738
738
|
costTelemetry?: VoiceCostTelemetryConfig<TContext, TSession, TResult>;
|
|
739
739
|
path: string;
|
|
740
|
-
greeting?: string;
|
|
740
|
+
greeting?: string | (() => string | Promise<string>);
|
|
741
741
|
languageStrategy?: VoiceLanguageStrategy;
|
|
742
742
|
lexicon?: VoiceLexiconEntry[] | VoiceLexiconResolver<TContext>;
|
|
743
743
|
phraseHints?: VoicePhraseHint[] | VoicePhraseHintResolver<TContext>;
|
|
@@ -851,7 +851,7 @@ export type CreateVoiceSessionOptions<TContext = unknown, TSession extends Voice
|
|
|
851
851
|
id: string;
|
|
852
852
|
context: TContext;
|
|
853
853
|
socket: VoiceSocket;
|
|
854
|
-
greeting?: string;
|
|
854
|
+
greeting?: string | (() => string | Promise<string>);
|
|
855
855
|
stt?: STTAdapter;
|
|
856
856
|
realtime?: RealtimeAdapter;
|
|
857
857
|
realtimeInputFormat?: AudioFormat;
|
package/dist/index.js
CHANGED
|
@@ -5577,7 +5577,7 @@ var createVoiceSession = (options) => {
|
|
|
5577
5577
|
kickCallSilenceWatchdog();
|
|
5578
5578
|
startAmdEvaluationTimer();
|
|
5579
5579
|
if (shouldFireOnSession && options.greeting && session.turns.length === 0) {
|
|
5580
|
-
const greetingText = options.greeting;
|
|
5580
|
+
const greetingText = typeof options.greeting === "function" ? await options.greeting() : options.greeting;
|
|
5581
5581
|
const greetingTurnId = createId();
|
|
5582
5582
|
await send({
|
|
5583
5583
|
text: greetingText,
|
|
@@ -24261,6 +24261,7 @@ var createTwilioMediaStreamBridge = (socket, options) => {
|
|
|
24261
24261
|
audioConditioning,
|
|
24262
24262
|
context: options.context,
|
|
24263
24263
|
costTelemetry: options.costTelemetry,
|
|
24264
|
+
greeting: options.greeting,
|
|
24264
24265
|
id: bridgeState.sessionId,
|
|
24265
24266
|
languageStrategy: options.languageStrategy,
|
|
24266
24267
|
lexicon,
|
|
@@ -24277,6 +24278,7 @@ var createTwilioMediaStreamBridge = (socket, options) => {
|
|
|
24277
24278
|
tts: options.tts,
|
|
24278
24279
|
turnDetection
|
|
24279
24280
|
});
|
|
24281
|
+
await sessionHandle.connect(voiceSocket);
|
|
24280
24282
|
return sessionHandle;
|
|
24281
24283
|
};
|
|
24282
24284
|
return {
|
|
@@ -24429,12 +24431,14 @@ var createTwilioVoiceRoutes = (options) => {
|
|
|
24429
24431
|
});
|
|
24430
24432
|
}).ws(streamPath, {
|
|
24431
24433
|
close: async (ws, _code, reason) => {
|
|
24432
|
-
const
|
|
24433
|
-
bridges.
|
|
24434
|
+
const key = ws.raw ?? ws;
|
|
24435
|
+
const bridge = bridges.get(key);
|
|
24436
|
+
bridges.delete(key);
|
|
24434
24437
|
await bridge?.close(reason);
|
|
24435
24438
|
},
|
|
24436
24439
|
message: async (ws, raw) => {
|
|
24437
|
-
|
|
24440
|
+
const key = ws.raw ?? ws;
|
|
24441
|
+
let bridge = bridges.get(key);
|
|
24438
24442
|
if (!bridge) {
|
|
24439
24443
|
bridge = createTwilioMediaStreamBridge({
|
|
24440
24444
|
close: (code, reason) => {
|
|
@@ -24444,7 +24448,7 @@ var createTwilioVoiceRoutes = (options) => {
|
|
|
24444
24448
|
ws.send(data);
|
|
24445
24449
|
}
|
|
24446
24450
|
}, options);
|
|
24447
|
-
bridges.set(
|
|
24451
|
+
bridges.set(key, bridge);
|
|
24448
24452
|
}
|
|
24449
24453
|
await bridge.handleMessage(raw);
|
|
24450
24454
|
}
|
|
@@ -25088,8 +25092,9 @@ var createPlivoVoiceRoutes = (options = {}) => {
|
|
|
25088
25092
|
});
|
|
25089
25093
|
}).ws(streamPath, {
|
|
25090
25094
|
close: async (ws, _code, reason) => {
|
|
25091
|
-
const
|
|
25092
|
-
bridges.
|
|
25095
|
+
const key = ws.raw ?? ws;
|
|
25096
|
+
const bridge = bridges.get(key);
|
|
25097
|
+
bridges.delete(key);
|
|
25093
25098
|
await bridge?.close(reason);
|
|
25094
25099
|
},
|
|
25095
25100
|
message: async (ws, raw) => {
|
|
@@ -25097,7 +25102,8 @@ var createPlivoVoiceRoutes = (options = {}) => {
|
|
|
25097
25102
|
ws.close(1011, "Plivo media bridge is not configured.");
|
|
25098
25103
|
return;
|
|
25099
25104
|
}
|
|
25100
|
-
|
|
25105
|
+
const key = ws.raw ?? ws;
|
|
25106
|
+
let bridge = bridges.get(key);
|
|
25101
25107
|
if (!bridge) {
|
|
25102
25108
|
bridge = createPlivoMediaStreamBridge({
|
|
25103
25109
|
close: (code, reason) => {
|
|
@@ -25107,7 +25113,7 @@ var createPlivoVoiceRoutes = (options = {}) => {
|
|
|
25107
25113
|
ws.send(data);
|
|
25108
25114
|
}
|
|
25109
25115
|
}, options.bridge);
|
|
25110
|
-
bridges.set(
|
|
25116
|
+
bridges.set(key, bridge);
|
|
25111
25117
|
}
|
|
25112
25118
|
await bridge.handleMessage(raw);
|
|
25113
25119
|
}
|
|
@@ -25702,8 +25708,9 @@ var createTelnyxVoiceRoutes = (options = {}) => {
|
|
|
25702
25708
|
});
|
|
25703
25709
|
}).ws(streamPath, {
|
|
25704
25710
|
close: async (ws, _code, reason) => {
|
|
25705
|
-
const
|
|
25706
|
-
bridges.
|
|
25711
|
+
const key = ws.raw ?? ws;
|
|
25712
|
+
const bridge = bridges.get(key);
|
|
25713
|
+
bridges.delete(key);
|
|
25707
25714
|
await bridge?.close(reason);
|
|
25708
25715
|
},
|
|
25709
25716
|
message: async (ws, raw) => {
|
|
@@ -25711,7 +25718,8 @@ var createTelnyxVoiceRoutes = (options = {}) => {
|
|
|
25711
25718
|
ws.close(1011, "Telnyx media bridge is not configured.");
|
|
25712
25719
|
return;
|
|
25713
25720
|
}
|
|
25714
|
-
|
|
25721
|
+
const key = ws.raw ?? ws;
|
|
25722
|
+
let bridge = bridges.get(key);
|
|
25715
25723
|
if (!bridge) {
|
|
25716
25724
|
bridge = createTelnyxMediaStreamBridge({
|
|
25717
25725
|
close: (code, reason) => {
|
|
@@ -25721,7 +25729,7 @@ var createTelnyxVoiceRoutes = (options = {}) => {
|
|
|
25721
25729
|
ws.send(data);
|
|
25722
25730
|
}
|
|
25723
25731
|
}, options.bridge);
|
|
25724
|
-
bridges.set(
|
|
25732
|
+
bridges.set(key, bridge);
|
|
25725
25733
|
}
|
|
25726
25734
|
await bridge.handleMessage(raw);
|
|
25727
25735
|
}
|
package/dist/testing/index.js
CHANGED
|
@@ -7439,7 +7439,7 @@ var createVoiceSession = (options) => {
|
|
|
7439
7439
|
kickCallSilenceWatchdog();
|
|
7440
7440
|
startAmdEvaluationTimer();
|
|
7441
7441
|
if (shouldFireOnSession && options.greeting && session.turns.length === 0) {
|
|
7442
|
-
const greetingText = options.greeting;
|
|
7442
|
+
const greetingText = typeof options.greeting === "function" ? await options.greeting() : options.greeting;
|
|
7443
7443
|
const greetingTurnId = createId();
|
|
7444
7444
|
await send({
|
|
7445
7445
|
text: greetingText,
|
|
@@ -12939,6 +12939,7 @@ var createTwilioMediaStreamBridge = (socket, options) => {
|
|
|
12939
12939
|
audioConditioning,
|
|
12940
12940
|
context: options.context,
|
|
12941
12941
|
costTelemetry: options.costTelemetry,
|
|
12942
|
+
greeting: options.greeting,
|
|
12942
12943
|
id: bridgeState.sessionId,
|
|
12943
12944
|
languageStrategy: options.languageStrategy,
|
|
12944
12945
|
lexicon,
|
|
@@ -12955,6 +12956,7 @@ var createTwilioMediaStreamBridge = (socket, options) => {
|
|
|
12955
12956
|
tts: options.tts,
|
|
12956
12957
|
turnDetection
|
|
12957
12958
|
});
|
|
12959
|
+
await sessionHandle.connect(voiceSocket);
|
|
12958
12960
|
return sessionHandle;
|
|
12959
12961
|
};
|
|
12960
12962
|
return {
|
|
@@ -13107,12 +13109,14 @@ var createTwilioVoiceRoutes = (options) => {
|
|
|
13107
13109
|
});
|
|
13108
13110
|
}).ws(streamPath, {
|
|
13109
13111
|
close: async (ws, _code, reason) => {
|
|
13110
|
-
const
|
|
13111
|
-
bridges.
|
|
13112
|
+
const key = ws.raw ?? ws;
|
|
13113
|
+
const bridge = bridges.get(key);
|
|
13114
|
+
bridges.delete(key);
|
|
13112
13115
|
await bridge?.close(reason);
|
|
13113
13116
|
},
|
|
13114
13117
|
message: async (ws, raw) => {
|
|
13115
|
-
|
|
13118
|
+
const key = ws.raw ?? ws;
|
|
13119
|
+
let bridge = bridges.get(key);
|
|
13116
13120
|
if (!bridge) {
|
|
13117
13121
|
bridge = createTwilioMediaStreamBridge({
|
|
13118
13122
|
close: (code, reason) => {
|
|
@@ -13122,7 +13126,7 @@ var createTwilioVoiceRoutes = (options) => {
|
|
|
13122
13126
|
ws.send(data);
|
|
13123
13127
|
}
|
|
13124
13128
|
}, options);
|
|
13125
|
-
bridges.set(
|
|
13129
|
+
bridges.set(key, bridge);
|
|
13126
13130
|
}
|
|
13127
13131
|
await bridge.handleMessage(raw);
|
|
13128
13132
|
}
|