@voicethere/agent 0.7.2 → 0.7.3
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/agent.js +73 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/protocol.d.ts +89 -2
- package/dist/protocol.d.ts.map +1 -1
- package/dist/protocol.js.map +1 -1
- package/dist/runtime.d.ts +37 -1
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +266 -0
- package/dist/runtime.js.map +1 -1
- package/dist/templates/echo/agent.js +79 -1
- package/dist/templates/echo-dc/agent.js +79 -1
- package/dist/templates/game-sync/agent.js +79 -1
- package/dist/templates/positional-tts/agent.js +79 -1
- package/dist/templates/recording-consent/agent.js +79 -1
- package/dist/templates/voice-showcase/agent.js +79 -1
- package/dist/templates/voice-starter/agent.js +79 -1
- package/dist/templates/webhooks/agent.js +79 -1
- package/dist/templates/webhooks-redis/agent.js +79 -1
- package/package.json +4 -4
- package/templates/mix-smoke.ts +72 -1
|
@@ -130,6 +130,24 @@ var SessionSerialQueue = class {
|
|
|
130
130
|
var SESSION_START_INIT_DELAY_ENABLED_ENV = "AGENT_SESSION_START_INIT_DELAY_ENABLED";
|
|
131
131
|
var SESSION_START_INIT_DELAY_MS_ENV = "AGENT_SESSION_START_INIT_DELAY_MS";
|
|
132
132
|
var DEFAULT_SESSION_START_INIT_DELAY_MS = 500;
|
|
133
|
+
function isPlayAckMessage(value) {
|
|
134
|
+
if (!value || typeof value !== "object")
|
|
135
|
+
return false;
|
|
136
|
+
const msg = value;
|
|
137
|
+
return msg.type === "play_ack" && typeof msg.requestId === "string";
|
|
138
|
+
}
|
|
139
|
+
function isPlayStatusAckMessage(value) {
|
|
140
|
+
if (!value || typeof value !== "object")
|
|
141
|
+
return false;
|
|
142
|
+
const msg = value;
|
|
143
|
+
return msg.type === "play_status_ack" && typeof msg.requestId === "string";
|
|
144
|
+
}
|
|
145
|
+
function isPlayStopAckMessage(value) {
|
|
146
|
+
if (!value || typeof value !== "object")
|
|
147
|
+
return false;
|
|
148
|
+
const msg = value;
|
|
149
|
+
return msg.type === "play_stop_ack" && typeof msg.requestId === "string";
|
|
150
|
+
}
|
|
133
151
|
function isRecordingControlAckMessage(value) {
|
|
134
152
|
if (!value || typeof value !== "object")
|
|
135
153
|
return false;
|
|
@@ -190,7 +208,7 @@ function isParentMessage(value) {
|
|
|
190
208
|
if (!value || typeof value !== "object")
|
|
191
209
|
return false;
|
|
192
210
|
const msg = value;
|
|
193
|
-
return msg.type === "session_start" || msg.type === "speech_event" || msg.type === "session_end" || msg.type === "data_channel_message" || msg.type === "data_channel_binary" || msg.type === "idle_timeout" || msg.type === "recording_control_ack" || msg.type === "mix_control_ack" || msg.type === "stt_control_ack" || msg.type === "webhook";
|
|
211
|
+
return msg.type === "session_start" || msg.type === "speech_event" || msg.type === "session_end" || msg.type === "data_channel_message" || msg.type === "data_channel_binary" || msg.type === "idle_timeout" || msg.type === "recording_control_ack" || msg.type === "play_ack" || msg.type === "play_status_ack" || msg.type === "play_stop_ack" || msg.type === "mix_control_ack" || msg.type === "stt_control_ack" || msg.type === "webhook";
|
|
194
212
|
}
|
|
195
213
|
function isSessionScopedParentMessage(value) {
|
|
196
214
|
return isParentMessage(value) && !isWebhookMessage(value);
|
|
@@ -207,7 +225,11 @@ var recordingAvailableBySessionId = /* @__PURE__ */ new Map();
|
|
|
207
225
|
var mixAvailableBySessionId = /* @__PURE__ */ new Map();
|
|
208
226
|
var ttsPoseAvailableBySessionId = /* @__PURE__ */ new Map();
|
|
209
227
|
var endedSessionIds = /* @__PURE__ */ new Set();
|
|
228
|
+
var PLAY_BYTES_MAX_DECODED_LENGTH = 64 * 1024;
|
|
210
229
|
var pendingRecordingAcks = /* @__PURE__ */ new Map();
|
|
230
|
+
var pendingPlayAcks = /* @__PURE__ */ new Map();
|
|
231
|
+
var pendingPlayStatusAcks = /* @__PURE__ */ new Map();
|
|
232
|
+
var pendingPlayStopAcks = /* @__PURE__ */ new Map();
|
|
211
233
|
var pendingMixAcks = /* @__PURE__ */ new Map();
|
|
212
234
|
var pendingSttAcks = /* @__PURE__ */ new Map();
|
|
213
235
|
function handleRecordingControlAck(message) {
|
|
@@ -222,6 +244,46 @@ function handleRecordingControlAck(message) {
|
|
|
222
244
|
requestId: message.requestId
|
|
223
245
|
});
|
|
224
246
|
}
|
|
247
|
+
function handlePlayAck(message) {
|
|
248
|
+
const pending = pendingPlayAcks.get(message.requestId);
|
|
249
|
+
if (!pending)
|
|
250
|
+
return;
|
|
251
|
+
clearTimeout(pending.timer);
|
|
252
|
+
pendingPlayAcks.delete(message.requestId);
|
|
253
|
+
pending.resolve({
|
|
254
|
+
ok: message.ok,
|
|
255
|
+
...message.playId ? { playId: message.playId } : {},
|
|
256
|
+
reason: message.reason,
|
|
257
|
+
requestId: message.requestId
|
|
258
|
+
});
|
|
259
|
+
}
|
|
260
|
+
function handlePlayStatusAck(message) {
|
|
261
|
+
const pending = pendingPlayStatusAcks.get(message.requestId);
|
|
262
|
+
if (!pending)
|
|
263
|
+
return;
|
|
264
|
+
clearTimeout(pending.timer);
|
|
265
|
+
pendingPlayStatusAcks.delete(message.requestId);
|
|
266
|
+
pending.resolve({
|
|
267
|
+
ok: message.ok,
|
|
268
|
+
playId: message.playId,
|
|
269
|
+
...message.status ? { status: message.status } : {},
|
|
270
|
+
reason: message.reason,
|
|
271
|
+
requestId: message.requestId
|
|
272
|
+
});
|
|
273
|
+
}
|
|
274
|
+
function handlePlayStopAck(message) {
|
|
275
|
+
const pending = pendingPlayStopAcks.get(message.requestId);
|
|
276
|
+
if (!pending)
|
|
277
|
+
return;
|
|
278
|
+
clearTimeout(pending.timer);
|
|
279
|
+
pendingPlayStopAcks.delete(message.requestId);
|
|
280
|
+
pending.resolve({
|
|
281
|
+
ok: message.ok,
|
|
282
|
+
playId: message.playId,
|
|
283
|
+
reason: message.reason,
|
|
284
|
+
requestId: message.requestId
|
|
285
|
+
});
|
|
286
|
+
}
|
|
225
287
|
function handleMixControlAck(message) {
|
|
226
288
|
const pending = pendingMixAcks.get(message.requestId);
|
|
227
289
|
if (!pending)
|
|
@@ -307,6 +369,10 @@ function sendParentMessage(message) {
|
|
|
307
369
|
process.send?.(message);
|
|
308
370
|
return;
|
|
309
371
|
}
|
|
372
|
+
if (msgType === "play" || msgType === "play_status" || msgType === "play_stop") {
|
|
373
|
+
process.send?.(message);
|
|
374
|
+
return;
|
|
375
|
+
}
|
|
310
376
|
const sessionId = message && typeof message === "object" && "sessionId" in message && typeof message.sessionId === "string" ? message.sessionId : void 0;
|
|
311
377
|
if (!allowOutboundForSession(sessionId))
|
|
312
378
|
return;
|
|
@@ -458,6 +524,18 @@ function defineAgent(handlers) {
|
|
|
458
524
|
handleRecordingControlAck(message);
|
|
459
525
|
return;
|
|
460
526
|
}
|
|
527
|
+
if (isPlayAckMessage(message)) {
|
|
528
|
+
handlePlayAck(message);
|
|
529
|
+
return;
|
|
530
|
+
}
|
|
531
|
+
if (isPlayStatusAckMessage(message)) {
|
|
532
|
+
handlePlayStatusAck(message);
|
|
533
|
+
return;
|
|
534
|
+
}
|
|
535
|
+
if (isPlayStopAckMessage(message)) {
|
|
536
|
+
handlePlayStopAck(message);
|
|
537
|
+
return;
|
|
538
|
+
}
|
|
461
539
|
if (isMixControlAckMessage(message)) {
|
|
462
540
|
handleMixControlAck(message);
|
|
463
541
|
return;
|
|
@@ -10884,6 +10884,24 @@ var SessionSerialQueue = class {
|
|
|
10884
10884
|
var SESSION_START_INIT_DELAY_ENABLED_ENV = "AGENT_SESSION_START_INIT_DELAY_ENABLED";
|
|
10885
10885
|
var SESSION_START_INIT_DELAY_MS_ENV = "AGENT_SESSION_START_INIT_DELAY_MS";
|
|
10886
10886
|
var DEFAULT_SESSION_START_INIT_DELAY_MS = 500;
|
|
10887
|
+
function isPlayAckMessage(value) {
|
|
10888
|
+
if (!value || typeof value !== "object")
|
|
10889
|
+
return false;
|
|
10890
|
+
const msg = value;
|
|
10891
|
+
return msg.type === "play_ack" && typeof msg.requestId === "string";
|
|
10892
|
+
}
|
|
10893
|
+
function isPlayStatusAckMessage(value) {
|
|
10894
|
+
if (!value || typeof value !== "object")
|
|
10895
|
+
return false;
|
|
10896
|
+
const msg = value;
|
|
10897
|
+
return msg.type === "play_status_ack" && typeof msg.requestId === "string";
|
|
10898
|
+
}
|
|
10899
|
+
function isPlayStopAckMessage(value) {
|
|
10900
|
+
if (!value || typeof value !== "object")
|
|
10901
|
+
return false;
|
|
10902
|
+
const msg = value;
|
|
10903
|
+
return msg.type === "play_stop_ack" && typeof msg.requestId === "string";
|
|
10904
|
+
}
|
|
10887
10905
|
function isRecordingControlAckMessage(value) {
|
|
10888
10906
|
if (!value || typeof value !== "object")
|
|
10889
10907
|
return false;
|
|
@@ -10944,7 +10962,7 @@ function isParentMessage(value) {
|
|
|
10944
10962
|
if (!value || typeof value !== "object")
|
|
10945
10963
|
return false;
|
|
10946
10964
|
const msg = value;
|
|
10947
|
-
return msg.type === "session_start" || msg.type === "speech_event" || msg.type === "session_end" || msg.type === "data_channel_message" || msg.type === "data_channel_binary" || msg.type === "idle_timeout" || msg.type === "recording_control_ack" || msg.type === "mix_control_ack" || msg.type === "stt_control_ack" || msg.type === "webhook";
|
|
10965
|
+
return msg.type === "session_start" || msg.type === "speech_event" || msg.type === "session_end" || msg.type === "data_channel_message" || msg.type === "data_channel_binary" || msg.type === "idle_timeout" || msg.type === "recording_control_ack" || msg.type === "play_ack" || msg.type === "play_status_ack" || msg.type === "play_stop_ack" || msg.type === "mix_control_ack" || msg.type === "stt_control_ack" || msg.type === "webhook";
|
|
10948
10966
|
}
|
|
10949
10967
|
function isSessionScopedParentMessage(value) {
|
|
10950
10968
|
return isParentMessage(value) && !isWebhookMessage(value);
|
|
@@ -10961,7 +10979,11 @@ var recordingAvailableBySessionId = /* @__PURE__ */ new Map();
|
|
|
10961
10979
|
var mixAvailableBySessionId = /* @__PURE__ */ new Map();
|
|
10962
10980
|
var ttsPoseAvailableBySessionId = /* @__PURE__ */ new Map();
|
|
10963
10981
|
var endedSessionIds = /* @__PURE__ */ new Set();
|
|
10982
|
+
var PLAY_BYTES_MAX_DECODED_LENGTH = 64 * 1024;
|
|
10964
10983
|
var pendingRecordingAcks = /* @__PURE__ */ new Map();
|
|
10984
|
+
var pendingPlayAcks = /* @__PURE__ */ new Map();
|
|
10985
|
+
var pendingPlayStatusAcks = /* @__PURE__ */ new Map();
|
|
10986
|
+
var pendingPlayStopAcks = /* @__PURE__ */ new Map();
|
|
10965
10987
|
var pendingMixAcks = /* @__PURE__ */ new Map();
|
|
10966
10988
|
var pendingSttAcks = /* @__PURE__ */ new Map();
|
|
10967
10989
|
function handleRecordingControlAck(message) {
|
|
@@ -10976,6 +10998,46 @@ function handleRecordingControlAck(message) {
|
|
|
10976
10998
|
requestId: message.requestId
|
|
10977
10999
|
});
|
|
10978
11000
|
}
|
|
11001
|
+
function handlePlayAck(message) {
|
|
11002
|
+
const pending = pendingPlayAcks.get(message.requestId);
|
|
11003
|
+
if (!pending)
|
|
11004
|
+
return;
|
|
11005
|
+
clearTimeout(pending.timer);
|
|
11006
|
+
pendingPlayAcks.delete(message.requestId);
|
|
11007
|
+
pending.resolve({
|
|
11008
|
+
ok: message.ok,
|
|
11009
|
+
...message.playId ? { playId: message.playId } : {},
|
|
11010
|
+
reason: message.reason,
|
|
11011
|
+
requestId: message.requestId
|
|
11012
|
+
});
|
|
11013
|
+
}
|
|
11014
|
+
function handlePlayStatusAck(message) {
|
|
11015
|
+
const pending = pendingPlayStatusAcks.get(message.requestId);
|
|
11016
|
+
if (!pending)
|
|
11017
|
+
return;
|
|
11018
|
+
clearTimeout(pending.timer);
|
|
11019
|
+
pendingPlayStatusAcks.delete(message.requestId);
|
|
11020
|
+
pending.resolve({
|
|
11021
|
+
ok: message.ok,
|
|
11022
|
+
playId: message.playId,
|
|
11023
|
+
...message.status ? { status: message.status } : {},
|
|
11024
|
+
reason: message.reason,
|
|
11025
|
+
requestId: message.requestId
|
|
11026
|
+
});
|
|
11027
|
+
}
|
|
11028
|
+
function handlePlayStopAck(message) {
|
|
11029
|
+
const pending = pendingPlayStopAcks.get(message.requestId);
|
|
11030
|
+
if (!pending)
|
|
11031
|
+
return;
|
|
11032
|
+
clearTimeout(pending.timer);
|
|
11033
|
+
pendingPlayStopAcks.delete(message.requestId);
|
|
11034
|
+
pending.resolve({
|
|
11035
|
+
ok: message.ok,
|
|
11036
|
+
playId: message.playId,
|
|
11037
|
+
reason: message.reason,
|
|
11038
|
+
requestId: message.requestId
|
|
11039
|
+
});
|
|
11040
|
+
}
|
|
10979
11041
|
function handleMixControlAck(message) {
|
|
10980
11042
|
const pending = pendingMixAcks.get(message.requestId);
|
|
10981
11043
|
if (!pending)
|
|
@@ -11061,6 +11123,10 @@ function sendParentMessage(message) {
|
|
|
11061
11123
|
process.send?.(message);
|
|
11062
11124
|
return;
|
|
11063
11125
|
}
|
|
11126
|
+
if (msgType === "play" || msgType === "play_status" || msgType === "play_stop") {
|
|
11127
|
+
process.send?.(message);
|
|
11128
|
+
return;
|
|
11129
|
+
}
|
|
11064
11130
|
const sessionId = message && typeof message === "object" && "sessionId" in message && typeof message.sessionId === "string" ? message.sessionId : void 0;
|
|
11065
11131
|
if (!allowOutboundForSession(sessionId))
|
|
11066
11132
|
return;
|
|
@@ -11212,6 +11278,18 @@ function defineAgent(handlers) {
|
|
|
11212
11278
|
handleRecordingControlAck(message);
|
|
11213
11279
|
return;
|
|
11214
11280
|
}
|
|
11281
|
+
if (isPlayAckMessage(message)) {
|
|
11282
|
+
handlePlayAck(message);
|
|
11283
|
+
return;
|
|
11284
|
+
}
|
|
11285
|
+
if (isPlayStatusAckMessage(message)) {
|
|
11286
|
+
handlePlayStatusAck(message);
|
|
11287
|
+
return;
|
|
11288
|
+
}
|
|
11289
|
+
if (isPlayStopAckMessage(message)) {
|
|
11290
|
+
handlePlayStopAck(message);
|
|
11291
|
+
return;
|
|
11292
|
+
}
|
|
11215
11293
|
if (isMixControlAckMessage(message)) {
|
|
11216
11294
|
handleMixControlAck(message);
|
|
11217
11295
|
return;
|
|
@@ -133,6 +133,24 @@ var SessionSerialQueue = class {
|
|
|
133
133
|
var SESSION_START_INIT_DELAY_ENABLED_ENV = "AGENT_SESSION_START_INIT_DELAY_ENABLED";
|
|
134
134
|
var SESSION_START_INIT_DELAY_MS_ENV = "AGENT_SESSION_START_INIT_DELAY_MS";
|
|
135
135
|
var DEFAULT_SESSION_START_INIT_DELAY_MS = 500;
|
|
136
|
+
function isPlayAckMessage(value) {
|
|
137
|
+
if (!value || typeof value !== "object")
|
|
138
|
+
return false;
|
|
139
|
+
const msg = value;
|
|
140
|
+
return msg.type === "play_ack" && typeof msg.requestId === "string";
|
|
141
|
+
}
|
|
142
|
+
function isPlayStatusAckMessage(value) {
|
|
143
|
+
if (!value || typeof value !== "object")
|
|
144
|
+
return false;
|
|
145
|
+
const msg = value;
|
|
146
|
+
return msg.type === "play_status_ack" && typeof msg.requestId === "string";
|
|
147
|
+
}
|
|
148
|
+
function isPlayStopAckMessage(value) {
|
|
149
|
+
if (!value || typeof value !== "object")
|
|
150
|
+
return false;
|
|
151
|
+
const msg = value;
|
|
152
|
+
return msg.type === "play_stop_ack" && typeof msg.requestId === "string";
|
|
153
|
+
}
|
|
136
154
|
function isRecordingControlAckMessage(value) {
|
|
137
155
|
if (!value || typeof value !== "object")
|
|
138
156
|
return false;
|
|
@@ -193,7 +211,7 @@ function isParentMessage(value) {
|
|
|
193
211
|
if (!value || typeof value !== "object")
|
|
194
212
|
return false;
|
|
195
213
|
const msg = value;
|
|
196
|
-
return msg.type === "session_start" || msg.type === "speech_event" || msg.type === "session_end" || msg.type === "data_channel_message" || msg.type === "data_channel_binary" || msg.type === "idle_timeout" || msg.type === "recording_control_ack" || msg.type === "mix_control_ack" || msg.type === "stt_control_ack" || msg.type === "webhook";
|
|
214
|
+
return msg.type === "session_start" || msg.type === "speech_event" || msg.type === "session_end" || msg.type === "data_channel_message" || msg.type === "data_channel_binary" || msg.type === "idle_timeout" || msg.type === "recording_control_ack" || msg.type === "play_ack" || msg.type === "play_status_ack" || msg.type === "play_stop_ack" || msg.type === "mix_control_ack" || msg.type === "stt_control_ack" || msg.type === "webhook";
|
|
197
215
|
}
|
|
198
216
|
function isSessionScopedParentMessage(value) {
|
|
199
217
|
return isParentMessage(value) && !isWebhookMessage(value);
|
|
@@ -210,7 +228,11 @@ var recordingAvailableBySessionId = /* @__PURE__ */ new Map();
|
|
|
210
228
|
var mixAvailableBySessionId = /* @__PURE__ */ new Map();
|
|
211
229
|
var ttsPoseAvailableBySessionId = /* @__PURE__ */ new Map();
|
|
212
230
|
var endedSessionIds = /* @__PURE__ */ new Set();
|
|
231
|
+
var PLAY_BYTES_MAX_DECODED_LENGTH = 64 * 1024;
|
|
213
232
|
var pendingRecordingAcks = /* @__PURE__ */ new Map();
|
|
233
|
+
var pendingPlayAcks = /* @__PURE__ */ new Map();
|
|
234
|
+
var pendingPlayStatusAcks = /* @__PURE__ */ new Map();
|
|
235
|
+
var pendingPlayStopAcks = /* @__PURE__ */ new Map();
|
|
214
236
|
var MIX_CONTROL_ACK_TIMEOUT_MS = 5e3;
|
|
215
237
|
var pendingMixAcks = /* @__PURE__ */ new Map();
|
|
216
238
|
var pendingSttAcks = /* @__PURE__ */ new Map();
|
|
@@ -226,6 +248,46 @@ function handleRecordingControlAck(message) {
|
|
|
226
248
|
requestId: message.requestId
|
|
227
249
|
});
|
|
228
250
|
}
|
|
251
|
+
function handlePlayAck(message) {
|
|
252
|
+
const pending = pendingPlayAcks.get(message.requestId);
|
|
253
|
+
if (!pending)
|
|
254
|
+
return;
|
|
255
|
+
clearTimeout(pending.timer);
|
|
256
|
+
pendingPlayAcks.delete(message.requestId);
|
|
257
|
+
pending.resolve({
|
|
258
|
+
ok: message.ok,
|
|
259
|
+
...message.playId ? { playId: message.playId } : {},
|
|
260
|
+
reason: message.reason,
|
|
261
|
+
requestId: message.requestId
|
|
262
|
+
});
|
|
263
|
+
}
|
|
264
|
+
function handlePlayStatusAck(message) {
|
|
265
|
+
const pending = pendingPlayStatusAcks.get(message.requestId);
|
|
266
|
+
if (!pending)
|
|
267
|
+
return;
|
|
268
|
+
clearTimeout(pending.timer);
|
|
269
|
+
pendingPlayStatusAcks.delete(message.requestId);
|
|
270
|
+
pending.resolve({
|
|
271
|
+
ok: message.ok,
|
|
272
|
+
playId: message.playId,
|
|
273
|
+
...message.status ? { status: message.status } : {},
|
|
274
|
+
reason: message.reason,
|
|
275
|
+
requestId: message.requestId
|
|
276
|
+
});
|
|
277
|
+
}
|
|
278
|
+
function handlePlayStopAck(message) {
|
|
279
|
+
const pending = pendingPlayStopAcks.get(message.requestId);
|
|
280
|
+
if (!pending)
|
|
281
|
+
return;
|
|
282
|
+
clearTimeout(pending.timer);
|
|
283
|
+
pendingPlayStopAcks.delete(message.requestId);
|
|
284
|
+
pending.resolve({
|
|
285
|
+
ok: message.ok,
|
|
286
|
+
playId: message.playId,
|
|
287
|
+
reason: message.reason,
|
|
288
|
+
requestId: message.requestId
|
|
289
|
+
});
|
|
290
|
+
}
|
|
229
291
|
function handleMixControlAck(message) {
|
|
230
292
|
const pending = pendingMixAcks.get(message.requestId);
|
|
231
293
|
if (!pending)
|
|
@@ -326,6 +388,10 @@ function sendParentMessage(message) {
|
|
|
326
388
|
process.send?.(message);
|
|
327
389
|
return;
|
|
328
390
|
}
|
|
391
|
+
if (msgType === "play" || msgType === "play_status" || msgType === "play_stop") {
|
|
392
|
+
process.send?.(message);
|
|
393
|
+
return;
|
|
394
|
+
}
|
|
329
395
|
const sessionId = message && typeof message === "object" && "sessionId" in message && typeof message.sessionId === "string" ? message.sessionId : void 0;
|
|
330
396
|
if (!allowOutboundForSession(sessionId))
|
|
331
397
|
return;
|
|
@@ -477,6 +543,18 @@ function defineAgent(handlers) {
|
|
|
477
543
|
handleRecordingControlAck(message);
|
|
478
544
|
return;
|
|
479
545
|
}
|
|
546
|
+
if (isPlayAckMessage(message)) {
|
|
547
|
+
handlePlayAck(message);
|
|
548
|
+
return;
|
|
549
|
+
}
|
|
550
|
+
if (isPlayStatusAckMessage(message)) {
|
|
551
|
+
handlePlayStatusAck(message);
|
|
552
|
+
return;
|
|
553
|
+
}
|
|
554
|
+
if (isPlayStopAckMessage(message)) {
|
|
555
|
+
handlePlayStopAck(message);
|
|
556
|
+
return;
|
|
557
|
+
}
|
|
480
558
|
if (isMixControlAckMessage(message)) {
|
|
481
559
|
handleMixControlAck(message);
|
|
482
560
|
return;
|
|
@@ -130,6 +130,24 @@ var SessionSerialQueue = class {
|
|
|
130
130
|
var SESSION_START_INIT_DELAY_ENABLED_ENV = "AGENT_SESSION_START_INIT_DELAY_ENABLED";
|
|
131
131
|
var SESSION_START_INIT_DELAY_MS_ENV = "AGENT_SESSION_START_INIT_DELAY_MS";
|
|
132
132
|
var DEFAULT_SESSION_START_INIT_DELAY_MS = 500;
|
|
133
|
+
function isPlayAckMessage(value) {
|
|
134
|
+
if (!value || typeof value !== "object")
|
|
135
|
+
return false;
|
|
136
|
+
const msg = value;
|
|
137
|
+
return msg.type === "play_ack" && typeof msg.requestId === "string";
|
|
138
|
+
}
|
|
139
|
+
function isPlayStatusAckMessage(value) {
|
|
140
|
+
if (!value || typeof value !== "object")
|
|
141
|
+
return false;
|
|
142
|
+
const msg = value;
|
|
143
|
+
return msg.type === "play_status_ack" && typeof msg.requestId === "string";
|
|
144
|
+
}
|
|
145
|
+
function isPlayStopAckMessage(value) {
|
|
146
|
+
if (!value || typeof value !== "object")
|
|
147
|
+
return false;
|
|
148
|
+
const msg = value;
|
|
149
|
+
return msg.type === "play_stop_ack" && typeof msg.requestId === "string";
|
|
150
|
+
}
|
|
133
151
|
function isRecordingControlAckMessage(value) {
|
|
134
152
|
if (!value || typeof value !== "object")
|
|
135
153
|
return false;
|
|
@@ -190,7 +208,7 @@ function isParentMessage(value) {
|
|
|
190
208
|
if (!value || typeof value !== "object")
|
|
191
209
|
return false;
|
|
192
210
|
const msg = value;
|
|
193
|
-
return msg.type === "session_start" || msg.type === "speech_event" || msg.type === "session_end" || msg.type === "data_channel_message" || msg.type === "data_channel_binary" || msg.type === "idle_timeout" || msg.type === "recording_control_ack" || msg.type === "mix_control_ack" || msg.type === "stt_control_ack" || msg.type === "webhook";
|
|
211
|
+
return msg.type === "session_start" || msg.type === "speech_event" || msg.type === "session_end" || msg.type === "data_channel_message" || msg.type === "data_channel_binary" || msg.type === "idle_timeout" || msg.type === "recording_control_ack" || msg.type === "play_ack" || msg.type === "play_status_ack" || msg.type === "play_stop_ack" || msg.type === "mix_control_ack" || msg.type === "stt_control_ack" || msg.type === "webhook";
|
|
194
212
|
}
|
|
195
213
|
function isSessionScopedParentMessage(value) {
|
|
196
214
|
return isParentMessage(value) && !isWebhookMessage(value);
|
|
@@ -208,7 +226,11 @@ var mixAvailableBySessionId = /* @__PURE__ */ new Map();
|
|
|
208
226
|
var ttsPoseAvailableBySessionId = /* @__PURE__ */ new Map();
|
|
209
227
|
var endedSessionIds = /* @__PURE__ */ new Set();
|
|
210
228
|
var RECORDING_CONTROL_ACK_TIMEOUT_MS = 5e3;
|
|
229
|
+
var PLAY_BYTES_MAX_DECODED_LENGTH = 64 * 1024;
|
|
211
230
|
var pendingRecordingAcks = /* @__PURE__ */ new Map();
|
|
231
|
+
var pendingPlayAcks = /* @__PURE__ */ new Map();
|
|
232
|
+
var pendingPlayStatusAcks = /* @__PURE__ */ new Map();
|
|
233
|
+
var pendingPlayStopAcks = /* @__PURE__ */ new Map();
|
|
212
234
|
var pendingMixAcks = /* @__PURE__ */ new Map();
|
|
213
235
|
var pendingSttAcks = /* @__PURE__ */ new Map();
|
|
214
236
|
function handleRecordingControlAck(message) {
|
|
@@ -223,6 +245,46 @@ function handleRecordingControlAck(message) {
|
|
|
223
245
|
requestId: message.requestId
|
|
224
246
|
});
|
|
225
247
|
}
|
|
248
|
+
function handlePlayAck(message) {
|
|
249
|
+
const pending = pendingPlayAcks.get(message.requestId);
|
|
250
|
+
if (!pending)
|
|
251
|
+
return;
|
|
252
|
+
clearTimeout(pending.timer);
|
|
253
|
+
pendingPlayAcks.delete(message.requestId);
|
|
254
|
+
pending.resolve({
|
|
255
|
+
ok: message.ok,
|
|
256
|
+
...message.playId ? { playId: message.playId } : {},
|
|
257
|
+
reason: message.reason,
|
|
258
|
+
requestId: message.requestId
|
|
259
|
+
});
|
|
260
|
+
}
|
|
261
|
+
function handlePlayStatusAck(message) {
|
|
262
|
+
const pending = pendingPlayStatusAcks.get(message.requestId);
|
|
263
|
+
if (!pending)
|
|
264
|
+
return;
|
|
265
|
+
clearTimeout(pending.timer);
|
|
266
|
+
pendingPlayStatusAcks.delete(message.requestId);
|
|
267
|
+
pending.resolve({
|
|
268
|
+
ok: message.ok,
|
|
269
|
+
playId: message.playId,
|
|
270
|
+
...message.status ? { status: message.status } : {},
|
|
271
|
+
reason: message.reason,
|
|
272
|
+
requestId: message.requestId
|
|
273
|
+
});
|
|
274
|
+
}
|
|
275
|
+
function handlePlayStopAck(message) {
|
|
276
|
+
const pending = pendingPlayStopAcks.get(message.requestId);
|
|
277
|
+
if (!pending)
|
|
278
|
+
return;
|
|
279
|
+
clearTimeout(pending.timer);
|
|
280
|
+
pendingPlayStopAcks.delete(message.requestId);
|
|
281
|
+
pending.resolve({
|
|
282
|
+
ok: message.ok,
|
|
283
|
+
playId: message.playId,
|
|
284
|
+
reason: message.reason,
|
|
285
|
+
requestId: message.requestId
|
|
286
|
+
});
|
|
287
|
+
}
|
|
226
288
|
function handleMixControlAck(message) {
|
|
227
289
|
const pending = pendingMixAcks.get(message.requestId);
|
|
228
290
|
if (!pending)
|
|
@@ -311,6 +373,10 @@ function sendParentMessage(message) {
|
|
|
311
373
|
process.send?.(message);
|
|
312
374
|
return;
|
|
313
375
|
}
|
|
376
|
+
if (msgType === "play" || msgType === "play_status" || msgType === "play_stop") {
|
|
377
|
+
process.send?.(message);
|
|
378
|
+
return;
|
|
379
|
+
}
|
|
314
380
|
const sessionId = message && typeof message === "object" && "sessionId" in message && typeof message.sessionId === "string" ? message.sessionId : void 0;
|
|
315
381
|
if (!allowOutboundForSession(sessionId))
|
|
316
382
|
return;
|
|
@@ -462,6 +528,18 @@ function defineAgent(handlers) {
|
|
|
462
528
|
handleRecordingControlAck(message);
|
|
463
529
|
return;
|
|
464
530
|
}
|
|
531
|
+
if (isPlayAckMessage(message)) {
|
|
532
|
+
handlePlayAck(message);
|
|
533
|
+
return;
|
|
534
|
+
}
|
|
535
|
+
if (isPlayStatusAckMessage(message)) {
|
|
536
|
+
handlePlayStatusAck(message);
|
|
537
|
+
return;
|
|
538
|
+
}
|
|
539
|
+
if (isPlayStopAckMessage(message)) {
|
|
540
|
+
handlePlayStopAck(message);
|
|
541
|
+
return;
|
|
542
|
+
}
|
|
465
543
|
if (isMixControlAckMessage(message)) {
|
|
466
544
|
handleMixControlAck(message);
|
|
467
545
|
return;
|
|
@@ -130,6 +130,24 @@ var SessionSerialQueue = class {
|
|
|
130
130
|
var SESSION_START_INIT_DELAY_ENABLED_ENV = "AGENT_SESSION_START_INIT_DELAY_ENABLED";
|
|
131
131
|
var SESSION_START_INIT_DELAY_MS_ENV = "AGENT_SESSION_START_INIT_DELAY_MS";
|
|
132
132
|
var DEFAULT_SESSION_START_INIT_DELAY_MS = 500;
|
|
133
|
+
function isPlayAckMessage(value) {
|
|
134
|
+
if (!value || typeof value !== "object")
|
|
135
|
+
return false;
|
|
136
|
+
const msg = value;
|
|
137
|
+
return msg.type === "play_ack" && typeof msg.requestId === "string";
|
|
138
|
+
}
|
|
139
|
+
function isPlayStatusAckMessage(value) {
|
|
140
|
+
if (!value || typeof value !== "object")
|
|
141
|
+
return false;
|
|
142
|
+
const msg = value;
|
|
143
|
+
return msg.type === "play_status_ack" && typeof msg.requestId === "string";
|
|
144
|
+
}
|
|
145
|
+
function isPlayStopAckMessage(value) {
|
|
146
|
+
if (!value || typeof value !== "object")
|
|
147
|
+
return false;
|
|
148
|
+
const msg = value;
|
|
149
|
+
return msg.type === "play_stop_ack" && typeof msg.requestId === "string";
|
|
150
|
+
}
|
|
133
151
|
function isRecordingControlAckMessage(value) {
|
|
134
152
|
if (!value || typeof value !== "object")
|
|
135
153
|
return false;
|
|
@@ -190,7 +208,7 @@ function isParentMessage(value) {
|
|
|
190
208
|
if (!value || typeof value !== "object")
|
|
191
209
|
return false;
|
|
192
210
|
const msg = value;
|
|
193
|
-
return msg.type === "session_start" || msg.type === "speech_event" || msg.type === "session_end" || msg.type === "data_channel_message" || msg.type === "data_channel_binary" || msg.type === "idle_timeout" || msg.type === "recording_control_ack" || msg.type === "mix_control_ack" || msg.type === "stt_control_ack" || msg.type === "webhook";
|
|
211
|
+
return msg.type === "session_start" || msg.type === "speech_event" || msg.type === "session_end" || msg.type === "data_channel_message" || msg.type === "data_channel_binary" || msg.type === "idle_timeout" || msg.type === "recording_control_ack" || msg.type === "play_ack" || msg.type === "play_status_ack" || msg.type === "play_stop_ack" || msg.type === "mix_control_ack" || msg.type === "stt_control_ack" || msg.type === "webhook";
|
|
194
212
|
}
|
|
195
213
|
function isSessionScopedParentMessage(value) {
|
|
196
214
|
return isParentMessage(value) && !isWebhookMessage(value);
|
|
@@ -207,7 +225,11 @@ var recordingAvailableBySessionId = /* @__PURE__ */ new Map();
|
|
|
207
225
|
var mixAvailableBySessionId = /* @__PURE__ */ new Map();
|
|
208
226
|
var ttsPoseAvailableBySessionId = /* @__PURE__ */ new Map();
|
|
209
227
|
var endedSessionIds = /* @__PURE__ */ new Set();
|
|
228
|
+
var PLAY_BYTES_MAX_DECODED_LENGTH = 64 * 1024;
|
|
210
229
|
var pendingRecordingAcks = /* @__PURE__ */ new Map();
|
|
230
|
+
var pendingPlayAcks = /* @__PURE__ */ new Map();
|
|
231
|
+
var pendingPlayStatusAcks = /* @__PURE__ */ new Map();
|
|
232
|
+
var pendingPlayStopAcks = /* @__PURE__ */ new Map();
|
|
211
233
|
var pendingMixAcks = /* @__PURE__ */ new Map();
|
|
212
234
|
var pendingSttAcks = /* @__PURE__ */ new Map();
|
|
213
235
|
function handleRecordingControlAck(message) {
|
|
@@ -222,6 +244,46 @@ function handleRecordingControlAck(message) {
|
|
|
222
244
|
requestId: message.requestId
|
|
223
245
|
});
|
|
224
246
|
}
|
|
247
|
+
function handlePlayAck(message) {
|
|
248
|
+
const pending = pendingPlayAcks.get(message.requestId);
|
|
249
|
+
if (!pending)
|
|
250
|
+
return;
|
|
251
|
+
clearTimeout(pending.timer);
|
|
252
|
+
pendingPlayAcks.delete(message.requestId);
|
|
253
|
+
pending.resolve({
|
|
254
|
+
ok: message.ok,
|
|
255
|
+
...message.playId ? { playId: message.playId } : {},
|
|
256
|
+
reason: message.reason,
|
|
257
|
+
requestId: message.requestId
|
|
258
|
+
});
|
|
259
|
+
}
|
|
260
|
+
function handlePlayStatusAck(message) {
|
|
261
|
+
const pending = pendingPlayStatusAcks.get(message.requestId);
|
|
262
|
+
if (!pending)
|
|
263
|
+
return;
|
|
264
|
+
clearTimeout(pending.timer);
|
|
265
|
+
pendingPlayStatusAcks.delete(message.requestId);
|
|
266
|
+
pending.resolve({
|
|
267
|
+
ok: message.ok,
|
|
268
|
+
playId: message.playId,
|
|
269
|
+
...message.status ? { status: message.status } : {},
|
|
270
|
+
reason: message.reason,
|
|
271
|
+
requestId: message.requestId
|
|
272
|
+
});
|
|
273
|
+
}
|
|
274
|
+
function handlePlayStopAck(message) {
|
|
275
|
+
const pending = pendingPlayStopAcks.get(message.requestId);
|
|
276
|
+
if (!pending)
|
|
277
|
+
return;
|
|
278
|
+
clearTimeout(pending.timer);
|
|
279
|
+
pendingPlayStopAcks.delete(message.requestId);
|
|
280
|
+
pending.resolve({
|
|
281
|
+
ok: message.ok,
|
|
282
|
+
playId: message.playId,
|
|
283
|
+
reason: message.reason,
|
|
284
|
+
requestId: message.requestId
|
|
285
|
+
});
|
|
286
|
+
}
|
|
225
287
|
function handleMixControlAck(message) {
|
|
226
288
|
const pending = pendingMixAcks.get(message.requestId);
|
|
227
289
|
if (!pending)
|
|
@@ -307,6 +369,10 @@ function sendParentMessage(message) {
|
|
|
307
369
|
process.send?.(message);
|
|
308
370
|
return;
|
|
309
371
|
}
|
|
372
|
+
if (msgType === "play" || msgType === "play_status" || msgType === "play_stop") {
|
|
373
|
+
process.send?.(message);
|
|
374
|
+
return;
|
|
375
|
+
}
|
|
310
376
|
const sessionId = message && typeof message === "object" && "sessionId" in message && typeof message.sessionId === "string" ? message.sessionId : void 0;
|
|
311
377
|
if (!allowOutboundForSession(sessionId))
|
|
312
378
|
return;
|
|
@@ -458,6 +524,18 @@ function defineAgent(handlers) {
|
|
|
458
524
|
handleRecordingControlAck(message);
|
|
459
525
|
return;
|
|
460
526
|
}
|
|
527
|
+
if (isPlayAckMessage(message)) {
|
|
528
|
+
handlePlayAck(message);
|
|
529
|
+
return;
|
|
530
|
+
}
|
|
531
|
+
if (isPlayStatusAckMessage(message)) {
|
|
532
|
+
handlePlayStatusAck(message);
|
|
533
|
+
return;
|
|
534
|
+
}
|
|
535
|
+
if (isPlayStopAckMessage(message)) {
|
|
536
|
+
handlePlayStopAck(message);
|
|
537
|
+
return;
|
|
538
|
+
}
|
|
461
539
|
if (isMixControlAckMessage(message)) {
|
|
462
540
|
handleMixControlAck(message);
|
|
463
541
|
return;
|