@rapidaai/react 1.1.49 → 1.1.51
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/{chunk-JA65S2AA.mjs → chunk-A2PCWS4P.mjs} +104 -166
- package/dist/chunk-A2PCWS4P.mjs.map +1 -0
- package/dist/components/device-selector.d.mts +1 -1
- package/dist/components/device-selector.d.ts +1 -1
- package/dist/components/device-selector.js +103 -145
- package/dist/components/device-selector.js.map +1 -1
- package/dist/components/device-selector.mjs +1 -1
- package/dist/{device-selector-o07ACCD6.d.mts → device-selector-D2B4ipII.d.mts} +6 -31
- package/dist/{device-selector-o07ACCD6.d.ts → device-selector-D2B4ipII.d.ts} +6 -31
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +133 -162
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +102 -75
- package/dist/index.mjs.map +1 -1
- package/package.json +11 -2
- package/dist/chunk-JA65S2AA.mjs.map +0 -1
|
@@ -3675,8 +3675,8 @@ var require_common_pb = __commonJS({
|
|
|
3675
3675
|
id: jspb.Message.getFieldWithDefault(msg, 1, "0"),
|
|
3676
3676
|
messageid: jspb.Message.getFieldWithDefault(msg, 3, ""),
|
|
3677
3677
|
assistantconversationid: jspb.Message.getFieldWithDefault(msg, 2, "0"),
|
|
3678
|
-
|
|
3679
|
-
|
|
3678
|
+
role: jspb.Message.getFieldWithDefault(msg, 4, ""),
|
|
3679
|
+
body: jspb.Message.getFieldWithDefault(msg, 5, ""),
|
|
3680
3680
|
source: jspb.Message.getFieldWithDefault(msg, 9, ""),
|
|
3681
3681
|
metricsList: jspb.Message.toObjectList(
|
|
3682
3682
|
msg.getMetricsList(),
|
|
@@ -3735,15 +3735,19 @@ var require_common_pb = __commonJS({
|
|
|
3735
3735
|
);
|
|
3736
3736
|
msg.setAssistantconversationid(value);
|
|
3737
3737
|
break;
|
|
3738
|
-
case
|
|
3739
|
-
var value =
|
|
3740
|
-
|
|
3741
|
-
|
|
3738
|
+
case 4:
|
|
3739
|
+
var value = (
|
|
3740
|
+
/** @type {string} */
|
|
3741
|
+
reader.readString()
|
|
3742
|
+
);
|
|
3743
|
+
msg.setRole(value);
|
|
3742
3744
|
break;
|
|
3743
|
-
case
|
|
3744
|
-
var value =
|
|
3745
|
-
|
|
3746
|
-
|
|
3745
|
+
case 5:
|
|
3746
|
+
var value = (
|
|
3747
|
+
/** @type {string} */
|
|
3748
|
+
reader.readString()
|
|
3749
|
+
);
|
|
3750
|
+
msg.setBody(value);
|
|
3747
3751
|
break;
|
|
3748
3752
|
case 9:
|
|
3749
3753
|
var value = (
|
|
@@ -3842,20 +3846,18 @@ var require_common_pb = __commonJS({
|
|
|
3842
3846
|
f
|
|
3843
3847
|
);
|
|
3844
3848
|
}
|
|
3845
|
-
f = message.
|
|
3846
|
-
if (f
|
|
3847
|
-
writer.
|
|
3848
|
-
|
|
3849
|
-
f
|
|
3850
|
-
proto.Message.serializeBinaryToWriter
|
|
3849
|
+
f = message.getRole();
|
|
3850
|
+
if (f.length > 0) {
|
|
3851
|
+
writer.writeString(
|
|
3852
|
+
4,
|
|
3853
|
+
f
|
|
3851
3854
|
);
|
|
3852
3855
|
}
|
|
3853
|
-
f = message.
|
|
3854
|
-
if (f
|
|
3855
|
-
writer.
|
|
3856
|
-
|
|
3857
|
-
f
|
|
3858
|
-
proto.Message.serializeBinaryToWriter
|
|
3856
|
+
f = message.getBody();
|
|
3857
|
+
if (f.length > 0) {
|
|
3858
|
+
writer.writeString(
|
|
3859
|
+
5,
|
|
3860
|
+
f
|
|
3859
3861
|
);
|
|
3860
3862
|
}
|
|
3861
3863
|
f = message.getSource();
|
|
@@ -3960,35 +3962,23 @@ var require_common_pb = __commonJS({
|
|
|
3960
3962
|
proto.AssistantConversationMessage.prototype.setAssistantconversationid = function(value) {
|
|
3961
3963
|
return jspb.Message.setProto3StringIntField(this, 2, value);
|
|
3962
3964
|
};
|
|
3963
|
-
proto.AssistantConversationMessage.prototype.
|
|
3965
|
+
proto.AssistantConversationMessage.prototype.getRole = function() {
|
|
3964
3966
|
return (
|
|
3965
|
-
/** @type{
|
|
3966
|
-
jspb.Message.
|
|
3967
|
+
/** @type {string} */
|
|
3968
|
+
jspb.Message.getFieldWithDefault(this, 4, "")
|
|
3967
3969
|
);
|
|
3968
3970
|
};
|
|
3969
|
-
proto.AssistantConversationMessage.prototype.
|
|
3970
|
-
return jspb.Message.
|
|
3971
|
-
};
|
|
3972
|
-
proto.AssistantConversationMessage.prototype.clearRequest = function() {
|
|
3973
|
-
return this.setRequest(void 0);
|
|
3974
|
-
};
|
|
3975
|
-
proto.AssistantConversationMessage.prototype.hasRequest = function() {
|
|
3976
|
-
return jspb.Message.getField(this, 5) != null;
|
|
3971
|
+
proto.AssistantConversationMessage.prototype.setRole = function(value) {
|
|
3972
|
+
return jspb.Message.setProto3StringField(this, 4, value);
|
|
3977
3973
|
};
|
|
3978
|
-
proto.AssistantConversationMessage.prototype.
|
|
3974
|
+
proto.AssistantConversationMessage.prototype.getBody = function() {
|
|
3979
3975
|
return (
|
|
3980
|
-
/** @type{
|
|
3981
|
-
jspb.Message.
|
|
3976
|
+
/** @type {string} */
|
|
3977
|
+
jspb.Message.getFieldWithDefault(this, 5, "")
|
|
3982
3978
|
);
|
|
3983
3979
|
};
|
|
3984
|
-
proto.AssistantConversationMessage.prototype.
|
|
3985
|
-
return jspb.Message.
|
|
3986
|
-
};
|
|
3987
|
-
proto.AssistantConversationMessage.prototype.clearResponse = function() {
|
|
3988
|
-
return this.setResponse(void 0);
|
|
3989
|
-
};
|
|
3990
|
-
proto.AssistantConversationMessage.prototype.hasResponse = function() {
|
|
3991
|
-
return jspb.Message.getField(this, 7) != null;
|
|
3980
|
+
proto.AssistantConversationMessage.prototype.setBody = function(value) {
|
|
3981
|
+
return jspb.Message.setProto3StringField(this, 5, value);
|
|
3992
3982
|
};
|
|
3993
3983
|
proto.AssistantConversationMessage.prototype.getSource = function() {
|
|
3994
3984
|
return (
|
|
@@ -7544,14 +7534,13 @@ var require_talk_api_pb = __commonJS({
|
|
|
7544
7534
|
proto.talk_api.AssistantMessagingRequest.prototype.hasMessage = function() {
|
|
7545
7535
|
return jspb.Message.getField(this, 3) != null;
|
|
7546
7536
|
};
|
|
7547
|
-
proto.talk_api.AssistantMessagingResponse.oneofGroups_ = [[9, 10, 11, 12,
|
|
7537
|
+
proto.talk_api.AssistantMessagingResponse.oneofGroups_ = [[9, 10, 11, 12, 14, 15]];
|
|
7548
7538
|
proto.talk_api.AssistantMessagingResponse.DataCase = {
|
|
7549
7539
|
DATA_NOT_SET: 0,
|
|
7550
7540
|
CONFIGURATION: 9,
|
|
7551
7541
|
INTERRUPTION: 10,
|
|
7552
7542
|
USER: 11,
|
|
7553
7543
|
ASSISTANT: 12,
|
|
7554
|
-
MESSAGE: 13,
|
|
7555
7544
|
ACTION: 14,
|
|
7556
7545
|
ERROR: 15
|
|
7557
7546
|
};
|
|
@@ -7573,7 +7562,6 @@ var require_talk_api_pb = __commonJS({
|
|
|
7573
7562
|
interruption: (f = msg.getInterruption()) && common_pb.AssistantConversationInterruption.toObject(includeInstance, f),
|
|
7574
7563
|
user: (f = msg.getUser()) && common_pb.AssistantConversationUserMessage.toObject(includeInstance, f),
|
|
7575
7564
|
assistant: (f = msg.getAssistant()) && common_pb.AssistantConversationAssistantMessage.toObject(includeInstance, f),
|
|
7576
|
-
message: (f = msg.getMessage()) && common_pb.AssistantConversationMessage.toObject(includeInstance, f),
|
|
7577
7565
|
action: (f = msg.getAction()) && common_pb.AssistantConversationAction.toObject(includeInstance, f),
|
|
7578
7566
|
error: (f = msg.getError()) && common_pb.Error.toObject(includeInstance, f)
|
|
7579
7567
|
};
|
|
@@ -7629,11 +7617,6 @@ var require_talk_api_pb = __commonJS({
|
|
|
7629
7617
|
reader.readMessage(value, common_pb.AssistantConversationAssistantMessage.deserializeBinaryFromReader);
|
|
7630
7618
|
msg.setAssistant(value);
|
|
7631
7619
|
break;
|
|
7632
|
-
case 13:
|
|
7633
|
-
var value = new common_pb.AssistantConversationMessage();
|
|
7634
|
-
reader.readMessage(value, common_pb.AssistantConversationMessage.deserializeBinaryFromReader);
|
|
7635
|
-
msg.setMessage(value);
|
|
7636
|
-
break;
|
|
7637
7620
|
case 14:
|
|
7638
7621
|
var value = new common_pb.AssistantConversationAction();
|
|
7639
7622
|
reader.readMessage(value, common_pb.AssistantConversationAction.deserializeBinaryFromReader);
|
|
@@ -7704,14 +7687,6 @@ var require_talk_api_pb = __commonJS({
|
|
|
7704
7687
|
common_pb.AssistantConversationAssistantMessage.serializeBinaryToWriter
|
|
7705
7688
|
);
|
|
7706
7689
|
}
|
|
7707
|
-
f = message.getMessage();
|
|
7708
|
-
if (f != null) {
|
|
7709
|
-
writer.writeMessage(
|
|
7710
|
-
13,
|
|
7711
|
-
f,
|
|
7712
|
-
common_pb.AssistantConversationMessage.serializeBinaryToWriter
|
|
7713
|
-
);
|
|
7714
|
-
}
|
|
7715
7690
|
f = message.getAction();
|
|
7716
7691
|
if (f != null) {
|
|
7717
7692
|
writer.writeMessage(
|
|
@@ -7807,21 +7782,6 @@ var require_talk_api_pb = __commonJS({
|
|
|
7807
7782
|
proto.talk_api.AssistantMessagingResponse.prototype.hasAssistant = function() {
|
|
7808
7783
|
return jspb.Message.getField(this, 12) != null;
|
|
7809
7784
|
};
|
|
7810
|
-
proto.talk_api.AssistantMessagingResponse.prototype.getMessage = function() {
|
|
7811
|
-
return (
|
|
7812
|
-
/** @type{?proto.AssistantConversationMessage} */
|
|
7813
|
-
jspb.Message.getWrapperField(this, common_pb.AssistantConversationMessage, 13)
|
|
7814
|
-
);
|
|
7815
|
-
};
|
|
7816
|
-
proto.talk_api.AssistantMessagingResponse.prototype.setMessage = function(value) {
|
|
7817
|
-
return jspb.Message.setOneofWrapperField(this, 13, proto.talk_api.AssistantMessagingResponse.oneofGroups_[0], value);
|
|
7818
|
-
};
|
|
7819
|
-
proto.talk_api.AssistantMessagingResponse.prototype.clearMessage = function() {
|
|
7820
|
-
return this.setMessage(void 0);
|
|
7821
|
-
};
|
|
7822
|
-
proto.talk_api.AssistantMessagingResponse.prototype.hasMessage = function() {
|
|
7823
|
-
return jspb.Message.getField(this, 13) != null;
|
|
7824
|
-
};
|
|
7825
7785
|
proto.talk_api.AssistantMessagingResponse.prototype.getAction = function() {
|
|
7826
7786
|
return (
|
|
7827
7787
|
/** @type{?proto.AssistantConversationAction} */
|
|
@@ -27377,6 +27337,9 @@ var import_moment = __toESM(require("moment"));
|
|
|
27377
27337
|
function isSafari() {
|
|
27378
27338
|
return getBrowser()?.name === "Safari";
|
|
27379
27339
|
}
|
|
27340
|
+
function isChrome() {
|
|
27341
|
+
return getBrowser()?.name === "Chrome";
|
|
27342
|
+
}
|
|
27380
27343
|
function toDate(timestamp) {
|
|
27381
27344
|
const seconds = timestamp.getSeconds();
|
|
27382
27345
|
const nanos = timestamp.getNanos();
|
|
@@ -27603,7 +27566,7 @@ var DeviceManager = class _DeviceManager {
|
|
|
27603
27566
|
|
|
27604
27567
|
// src/agents/voice-agent.ts
|
|
27605
27568
|
var import_talk_api_pb2 = __toESM(require_talk_api_pb());
|
|
27606
|
-
var
|
|
27569
|
+
var import_common_pb8 = __toESM(require_common_pb());
|
|
27607
27570
|
|
|
27608
27571
|
// src/agents/index.ts
|
|
27609
27572
|
var import_talk_api_pb = __toESM(require_talk_api_pb());
|
|
@@ -28333,6 +28296,24 @@ registerProcessor("raw-audio-processor", RawAudioProcessor);
|
|
|
28333
28296
|
|
|
28334
28297
|
// src/audio/input.ts
|
|
28335
28298
|
var LIBSAMPLERATE_JS = "https://cdn.jsdelivr.net/npm/@alexanderolsen/libsamplerate-js@2.1.2/dist/libsamplerate.worklet.js";
|
|
28299
|
+
function getAudioConstraints(sampleRate) {
|
|
28300
|
+
if (isChrome()) {
|
|
28301
|
+
return {
|
|
28302
|
+
sampleRate: { ideal: sampleRate },
|
|
28303
|
+
echoCancellation: true,
|
|
28304
|
+
noiseSuppression: true,
|
|
28305
|
+
autoGainControl: true,
|
|
28306
|
+
// Chrome-specific: helps with consistent audio quality
|
|
28307
|
+
channelCount: { ideal: 1 }
|
|
28308
|
+
};
|
|
28309
|
+
}
|
|
28310
|
+
return {
|
|
28311
|
+
sampleRate: { ideal: sampleRate },
|
|
28312
|
+
echoCancellation: { ideal: true },
|
|
28313
|
+
noiseSuppression: { ideal: true },
|
|
28314
|
+
autoGainControl: { ideal: true }
|
|
28315
|
+
};
|
|
28316
|
+
}
|
|
28336
28317
|
var Input = class _Input {
|
|
28337
28318
|
constructor(context, analyser, worklet, inputStream) {
|
|
28338
28319
|
this.context = context;
|
|
@@ -28340,18 +28321,10 @@ var Input = class _Input {
|
|
|
28340
28321
|
this.worklet = worklet;
|
|
28341
28322
|
this.inputStream = inputStream;
|
|
28342
28323
|
}
|
|
28343
|
-
static async create({
|
|
28344
|
-
sampleRate,
|
|
28345
|
-
format
|
|
28346
|
-
}) {
|
|
28324
|
+
static async create({ sampleRate, format }, existingStream) {
|
|
28347
28325
|
let context = null;
|
|
28348
28326
|
let inputStream = null;
|
|
28349
28327
|
try {
|
|
28350
|
-
const options = {
|
|
28351
|
-
sampleRate: { ideal: sampleRate },
|
|
28352
|
-
echoCancellation: { ideal: true },
|
|
28353
|
-
noiseSuppression: { ideal: true }
|
|
28354
|
-
};
|
|
28355
28328
|
const supportsSampleRateConstraint = navigator.mediaDevices.getSupportedConstraints().sampleRate;
|
|
28356
28329
|
context = new window.AudioContext(
|
|
28357
28330
|
supportsSampleRateConstraint ? { sampleRate } : {}
|
|
@@ -28361,9 +28334,14 @@ var Input = class _Input {
|
|
|
28361
28334
|
await context.audioWorklet.addModule(LIBSAMPLERATE_JS);
|
|
28362
28335
|
}
|
|
28363
28336
|
await loadRawAudioProcessor(context.audioWorklet);
|
|
28364
|
-
|
|
28365
|
-
|
|
28366
|
-
}
|
|
28337
|
+
if (existingStream) {
|
|
28338
|
+
inputStream = existingStream;
|
|
28339
|
+
} else {
|
|
28340
|
+
const options = getAudioConstraints(sampleRate);
|
|
28341
|
+
inputStream = await navigator.mediaDevices.getUserMedia({
|
|
28342
|
+
audio: options
|
|
28343
|
+
});
|
|
28344
|
+
}
|
|
28367
28345
|
const source = context.createMediaStreamSource(inputStream);
|
|
28368
28346
|
const worklet = new AudioWorkletNode(context, "raw-audio-processor");
|
|
28369
28347
|
worklet.port.postMessage({ type: "setFormat", format, sampleRate });
|
|
@@ -28552,30 +28530,15 @@ function arrayBufferToUint8(arrayBuffer) {
|
|
|
28552
28530
|
}
|
|
28553
28531
|
|
|
28554
28532
|
// src/types/agent-callback.ts
|
|
28555
|
-
var import_common_pb8 = __toESM(require_common_pb());
|
|
28556
|
-
|
|
28557
|
-
// src/utils/rapida_content.ts
|
|
28558
28533
|
var import_common_pb7 = __toESM(require_common_pb());
|
|
28559
|
-
var toContentText = (cnt) => {
|
|
28560
|
-
if (!cnt) return "";
|
|
28561
|
-
return cnt.filter((x) => x.getContenttype() === "text").map((x) => {
|
|
28562
|
-
try {
|
|
28563
|
-
return new TextDecoder().decode(x.getContent());
|
|
28564
|
-
} catch (error) {
|
|
28565
|
-
return "";
|
|
28566
|
-
}
|
|
28567
|
-
}).join(" ");
|
|
28568
|
-
};
|
|
28569
|
-
|
|
28570
|
-
// src/types/agent-callback.ts
|
|
28571
28534
|
var ConversationUserMessage = class {
|
|
28572
28535
|
constructor(config) {
|
|
28573
28536
|
if (config) {
|
|
28574
28537
|
Object.assign(this, config.toObject());
|
|
28575
28538
|
switch (config.getMessageCase()) {
|
|
28576
|
-
case
|
|
28577
|
-
case
|
|
28578
|
-
case
|
|
28539
|
+
case import_common_pb7.AssistantConversationUserMessage.MessageCase.MESSAGE_NOT_SET:
|
|
28540
|
+
case import_common_pb7.AssistantConversationUserMessage.MessageCase.AUDIO:
|
|
28541
|
+
case import_common_pb7.AssistantConversationUserMessage.MessageCase.TEXT:
|
|
28579
28542
|
this.messageText = config.getText()?.getContent();
|
|
28580
28543
|
}
|
|
28581
28544
|
}
|
|
@@ -28586,25 +28549,14 @@ var ConversationAssistantMessage = class {
|
|
|
28586
28549
|
if (config) {
|
|
28587
28550
|
Object.assign(this, config.toObject());
|
|
28588
28551
|
switch (config.getMessageCase()) {
|
|
28589
|
-
case
|
|
28590
|
-
case
|
|
28591
|
-
case
|
|
28552
|
+
case import_common_pb7.AssistantConversationUserMessage.MessageCase.MESSAGE_NOT_SET:
|
|
28553
|
+
case import_common_pb7.AssistantConversationUserMessage.MessageCase.AUDIO:
|
|
28554
|
+
case import_common_pb7.AssistantConversationUserMessage.MessageCase.TEXT:
|
|
28592
28555
|
this.messageText = config.getText()?.getContent();
|
|
28593
28556
|
}
|
|
28594
28557
|
}
|
|
28595
28558
|
}
|
|
28596
28559
|
};
|
|
28597
|
-
var ConversationMessage = class {
|
|
28598
|
-
constructor(config) {
|
|
28599
|
-
if (config) {
|
|
28600
|
-
Object.assign(this, config.toObject());
|
|
28601
|
-
this.userMessage = toContentText(config.getRequest()?.getContentsList());
|
|
28602
|
-
this.systemMessage = toContentText(
|
|
28603
|
-
config.getResponse()?.getContentsList()
|
|
28604
|
-
);
|
|
28605
|
-
}
|
|
28606
|
-
}
|
|
28607
|
-
};
|
|
28608
28560
|
|
|
28609
28561
|
// src/agents/voice-agent.ts
|
|
28610
28562
|
var VoiceAgent = class extends Agent {
|
|
@@ -28642,13 +28594,14 @@ var VoiceAgent = class extends Agent {
|
|
|
28642
28594
|
connectDevice = async () => {
|
|
28643
28595
|
try {
|
|
28644
28596
|
this.preliminaryInputStream = await this.waitForUserMediaPermission();
|
|
28645
|
-
|
|
28646
|
-
|
|
28647
|
-
|
|
28648
|
-
|
|
28597
|
+
this.output = await Output.create(this.agentConfig.outputOptions.playerOption);
|
|
28598
|
+
this.input = await Input.create(
|
|
28599
|
+
this.agentConfig.inputOptions.recorderOption,
|
|
28600
|
+
this.preliminaryInputStream
|
|
28601
|
+
// Reuse the same MediaStream
|
|
28602
|
+
);
|
|
28649
28603
|
this.input.worklet.port.onmessage = this.onInputWorkletMessage;
|
|
28650
28604
|
this.output.worklet.port.onmessage = this.onOutputWorkletMessage;
|
|
28651
|
-
this.preliminaryInputStream?.getTracks().forEach((track) => track.stop());
|
|
28652
28605
|
this.preliminaryInputStream = null;
|
|
28653
28606
|
} catch (error) {
|
|
28654
28607
|
await this.disconnectAudio();
|
|
@@ -28658,7 +28611,20 @@ var VoiceAgent = class extends Agent {
|
|
|
28658
28611
|
// Helper method to handle media permissions:
|
|
28659
28612
|
waitForUserMediaPermission = async () => {
|
|
28660
28613
|
try {
|
|
28661
|
-
|
|
28614
|
+
const sampleRate = this.agentConfig.inputOptions.recorderOption.sampleRate;
|
|
28615
|
+
const options = isChrome() ? {
|
|
28616
|
+
sampleRate: { ideal: sampleRate },
|
|
28617
|
+
echoCancellation: true,
|
|
28618
|
+
noiseSuppression: true,
|
|
28619
|
+
autoGainControl: true,
|
|
28620
|
+
channelCount: { ideal: 1 }
|
|
28621
|
+
} : {
|
|
28622
|
+
sampleRate: { ideal: sampleRate },
|
|
28623
|
+
echoCancellation: { ideal: true },
|
|
28624
|
+
noiseSuppression: { ideal: true },
|
|
28625
|
+
autoGainControl: { ideal: true }
|
|
28626
|
+
};
|
|
28627
|
+
return await navigator.mediaDevices.getUserMedia({ audio: options });
|
|
28662
28628
|
} catch (error) {
|
|
28663
28629
|
console.error(
|
|
28664
28630
|
"Permission denied or error while requesting microphone access:",
|
|
@@ -28856,13 +28822,13 @@ var VoiceAgent = class extends Agent {
|
|
|
28856
28822
|
onHandleInterruption = (interruptionData) => {
|
|
28857
28823
|
if (interruptionData) {
|
|
28858
28824
|
switch (interruptionData.getType()) {
|
|
28859
|
-
case
|
|
28825
|
+
case import_common_pb8.AssistantConversationInterruption.InterruptionType.INTERRUPTION_TYPE_UNSPECIFIED:
|
|
28860
28826
|
console.log("Unspecified interruption type");
|
|
28861
28827
|
break;
|
|
28862
|
-
case
|
|
28828
|
+
case import_common_pb8.AssistantConversationInterruption.InterruptionType.INTERRUPTION_TYPE_VAD:
|
|
28863
28829
|
this.fadeOutAudio();
|
|
28864
28830
|
break;
|
|
28865
|
-
case
|
|
28831
|
+
case import_common_pb8.AssistantConversationInterruption.InterruptionType.INTERRUPTION_TYPE_WORD:
|
|
28866
28832
|
if (this.agentMessages.length > 0) {
|
|
28867
28833
|
const lastIndex = this.agentMessages.length - 1;
|
|
28868
28834
|
this.agentMessages[lastIndex] = {
|
|
@@ -28889,9 +28855,9 @@ var VoiceAgent = class extends Agent {
|
|
|
28889
28855
|
onHandleUser = (userContent) => {
|
|
28890
28856
|
if (userContent) {
|
|
28891
28857
|
switch (userContent.getMessageCase()) {
|
|
28892
|
-
case
|
|
28893
|
-
case
|
|
28894
|
-
case
|
|
28858
|
+
case import_common_pb8.AssistantConversationUserMessage.MessageCase.MESSAGE_NOT_SET:
|
|
28859
|
+
case import_common_pb8.AssistantConversationUserMessage.MessageCase.AUDIO:
|
|
28860
|
+
case import_common_pb8.AssistantConversationUserMessage.MessageCase.TEXT:
|
|
28895
28861
|
const agentTranscript = userContent.getText()?.getContent();
|
|
28896
28862
|
if (agentTranscript) {
|
|
28897
28863
|
if (this.agentMessages.length > 0) {
|
|
@@ -28923,14 +28889,15 @@ var VoiceAgent = class extends Agent {
|
|
|
28923
28889
|
onHandleAssistant = (systemContent) => {
|
|
28924
28890
|
if (systemContent) {
|
|
28925
28891
|
switch (systemContent.getMessageCase()) {
|
|
28926
|
-
case
|
|
28927
|
-
case
|
|
28892
|
+
case import_common_pb8.AssistantConversationAssistantMessage.MessageCase.MESSAGE_NOT_SET:
|
|
28893
|
+
case import_common_pb8.AssistantConversationAssistantMessage.MessageCase.AUDIO:
|
|
28928
28894
|
const content = systemContent.getAudio();
|
|
28929
28895
|
if (content) {
|
|
28930
28896
|
const audioData = content.getContent_asU8();
|
|
28931
28897
|
this.addAudioChunk(new Uint8Array(audioData).buffer);
|
|
28932
28898
|
}
|
|
28933
|
-
|
|
28899
|
+
break;
|
|
28900
|
+
case import_common_pb8.AssistantConversationAssistantMessage.MessageCase.TEXT:
|
|
28934
28901
|
const systemTranscript = systemContent.getText()?.getContent();
|
|
28935
28902
|
if (systemTranscript) {
|
|
28936
28903
|
if (systemContent.getCompleted()) {
|
|
@@ -29014,8 +28981,6 @@ var VoiceAgent = class extends Agent {
|
|
|
29014
28981
|
const conversation = response.getConfiguration();
|
|
29015
28982
|
if (!conversation?.getAssistantconversationid()) return;
|
|
29016
28983
|
break;
|
|
29017
|
-
case import_talk_api_pb2.AssistantMessagingResponse.DataCase.MESSAGE:
|
|
29018
|
-
break;
|
|
29019
28984
|
default:
|
|
29020
28985
|
break;
|
|
29021
28986
|
}
|
|
@@ -29030,7 +28995,7 @@ var VoiceAgent = class extends Agent {
|
|
|
29030
28995
|
case import_talk_api_pb2.AssistantMessagingResponse.DataCase.DATA_NOT_SET:
|
|
29031
28996
|
break;
|
|
29032
28997
|
case import_talk_api_pb2.AssistantMessagingResponse.DataCase.ACTION:
|
|
29033
|
-
if (response.getAction()?.getAction() ===
|
|
28998
|
+
if (response.getAction()?.getAction() === import_common_pb8.AssistantConversationAction.ActionType.END_CONVERSATION) {
|
|
29034
28999
|
await this.disconnect();
|
|
29035
29000
|
}
|
|
29036
29001
|
if (agentCallback && agentCallback?.onAction) {
|
|
@@ -29065,13 +29030,6 @@ var VoiceAgent = class extends Agent {
|
|
|
29065
29030
|
const cnvId = response.getConfiguration()?.getAssistantconversationid();
|
|
29066
29031
|
if (cnvId) this.changeConversation(cnvId);
|
|
29067
29032
|
break;
|
|
29068
|
-
case import_talk_api_pb2.AssistantMessagingResponse.DataCase.MESSAGE:
|
|
29069
|
-
if (agentCallback && agentCallback?.onMessage) {
|
|
29070
|
-
agentCallback.onMessage(
|
|
29071
|
-
new ConversationMessage(response.getMessage())
|
|
29072
|
-
);
|
|
29073
|
-
}
|
|
29074
|
-
break;
|
|
29075
29033
|
default:
|
|
29076
29034
|
break;
|
|
29077
29035
|
}
|