@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
|
@@ -3650,8 +3650,8 @@ var require_common_pb = __commonJS({
|
|
|
3650
3650
|
id: jspb.Message.getFieldWithDefault(msg, 1, "0"),
|
|
3651
3651
|
messageid: jspb.Message.getFieldWithDefault(msg, 3, ""),
|
|
3652
3652
|
assistantconversationid: jspb.Message.getFieldWithDefault(msg, 2, "0"),
|
|
3653
|
-
|
|
3654
|
-
|
|
3653
|
+
role: jspb.Message.getFieldWithDefault(msg, 4, ""),
|
|
3654
|
+
body: jspb.Message.getFieldWithDefault(msg, 5, ""),
|
|
3655
3655
|
source: jspb.Message.getFieldWithDefault(msg, 9, ""),
|
|
3656
3656
|
metricsList: jspb.Message.toObjectList(
|
|
3657
3657
|
msg.getMetricsList(),
|
|
@@ -3710,15 +3710,19 @@ var require_common_pb = __commonJS({
|
|
|
3710
3710
|
);
|
|
3711
3711
|
msg.setAssistantconversationid(value);
|
|
3712
3712
|
break;
|
|
3713
|
-
case
|
|
3714
|
-
var value =
|
|
3715
|
-
|
|
3716
|
-
|
|
3713
|
+
case 4:
|
|
3714
|
+
var value = (
|
|
3715
|
+
/** @type {string} */
|
|
3716
|
+
reader.readString()
|
|
3717
|
+
);
|
|
3718
|
+
msg.setRole(value);
|
|
3717
3719
|
break;
|
|
3718
|
-
case
|
|
3719
|
-
var value =
|
|
3720
|
-
|
|
3721
|
-
|
|
3720
|
+
case 5:
|
|
3721
|
+
var value = (
|
|
3722
|
+
/** @type {string} */
|
|
3723
|
+
reader.readString()
|
|
3724
|
+
);
|
|
3725
|
+
msg.setBody(value);
|
|
3722
3726
|
break;
|
|
3723
3727
|
case 9:
|
|
3724
3728
|
var value = (
|
|
@@ -3817,20 +3821,18 @@ var require_common_pb = __commonJS({
|
|
|
3817
3821
|
f
|
|
3818
3822
|
);
|
|
3819
3823
|
}
|
|
3820
|
-
f = message.
|
|
3821
|
-
if (f
|
|
3822
|
-
writer.
|
|
3823
|
-
|
|
3824
|
-
f
|
|
3825
|
-
proto.Message.serializeBinaryToWriter
|
|
3824
|
+
f = message.getRole();
|
|
3825
|
+
if (f.length > 0) {
|
|
3826
|
+
writer.writeString(
|
|
3827
|
+
4,
|
|
3828
|
+
f
|
|
3826
3829
|
);
|
|
3827
3830
|
}
|
|
3828
|
-
f = message.
|
|
3829
|
-
if (f
|
|
3830
|
-
writer.
|
|
3831
|
-
|
|
3832
|
-
f
|
|
3833
|
-
proto.Message.serializeBinaryToWriter
|
|
3831
|
+
f = message.getBody();
|
|
3832
|
+
if (f.length > 0) {
|
|
3833
|
+
writer.writeString(
|
|
3834
|
+
5,
|
|
3835
|
+
f
|
|
3834
3836
|
);
|
|
3835
3837
|
}
|
|
3836
3838
|
f = message.getSource();
|
|
@@ -3935,35 +3937,23 @@ var require_common_pb = __commonJS({
|
|
|
3935
3937
|
proto.AssistantConversationMessage.prototype.setAssistantconversationid = function(value) {
|
|
3936
3938
|
return jspb.Message.setProto3StringIntField(this, 2, value);
|
|
3937
3939
|
};
|
|
3938
|
-
proto.AssistantConversationMessage.prototype.
|
|
3940
|
+
proto.AssistantConversationMessage.prototype.getRole = function() {
|
|
3939
3941
|
return (
|
|
3940
|
-
/** @type{
|
|
3941
|
-
jspb.Message.
|
|
3942
|
+
/** @type {string} */
|
|
3943
|
+
jspb.Message.getFieldWithDefault(this, 4, "")
|
|
3942
3944
|
);
|
|
3943
3945
|
};
|
|
3944
|
-
proto.AssistantConversationMessage.prototype.
|
|
3945
|
-
return jspb.Message.
|
|
3946
|
-
};
|
|
3947
|
-
proto.AssistantConversationMessage.prototype.clearRequest = function() {
|
|
3948
|
-
return this.setRequest(void 0);
|
|
3949
|
-
};
|
|
3950
|
-
proto.AssistantConversationMessage.prototype.hasRequest = function() {
|
|
3951
|
-
return jspb.Message.getField(this, 5) != null;
|
|
3946
|
+
proto.AssistantConversationMessage.prototype.setRole = function(value) {
|
|
3947
|
+
return jspb.Message.setProto3StringField(this, 4, value);
|
|
3952
3948
|
};
|
|
3953
|
-
proto.AssistantConversationMessage.prototype.
|
|
3949
|
+
proto.AssistantConversationMessage.prototype.getBody = function() {
|
|
3954
3950
|
return (
|
|
3955
|
-
/** @type{
|
|
3956
|
-
jspb.Message.
|
|
3951
|
+
/** @type {string} */
|
|
3952
|
+
jspb.Message.getFieldWithDefault(this, 5, "")
|
|
3957
3953
|
);
|
|
3958
3954
|
};
|
|
3959
|
-
proto.AssistantConversationMessage.prototype.
|
|
3960
|
-
return jspb.Message.
|
|
3961
|
-
};
|
|
3962
|
-
proto.AssistantConversationMessage.prototype.clearResponse = function() {
|
|
3963
|
-
return this.setResponse(void 0);
|
|
3964
|
-
};
|
|
3965
|
-
proto.AssistantConversationMessage.prototype.hasResponse = function() {
|
|
3966
|
-
return jspb.Message.getField(this, 7) != null;
|
|
3955
|
+
proto.AssistantConversationMessage.prototype.setBody = function(value) {
|
|
3956
|
+
return jspb.Message.setProto3StringField(this, 5, value);
|
|
3967
3957
|
};
|
|
3968
3958
|
proto.AssistantConversationMessage.prototype.getSource = function() {
|
|
3969
3959
|
return (
|
|
@@ -7519,14 +7509,13 @@ var require_talk_api_pb = __commonJS({
|
|
|
7519
7509
|
proto.talk_api.AssistantMessagingRequest.prototype.hasMessage = function() {
|
|
7520
7510
|
return jspb.Message.getField(this, 3) != null;
|
|
7521
7511
|
};
|
|
7522
|
-
proto.talk_api.AssistantMessagingResponse.oneofGroups_ = [[9, 10, 11, 12,
|
|
7512
|
+
proto.talk_api.AssistantMessagingResponse.oneofGroups_ = [[9, 10, 11, 12, 14, 15]];
|
|
7523
7513
|
proto.talk_api.AssistantMessagingResponse.DataCase = {
|
|
7524
7514
|
DATA_NOT_SET: 0,
|
|
7525
7515
|
CONFIGURATION: 9,
|
|
7526
7516
|
INTERRUPTION: 10,
|
|
7527
7517
|
USER: 11,
|
|
7528
7518
|
ASSISTANT: 12,
|
|
7529
|
-
MESSAGE: 13,
|
|
7530
7519
|
ACTION: 14,
|
|
7531
7520
|
ERROR: 15
|
|
7532
7521
|
};
|
|
@@ -7548,7 +7537,6 @@ var require_talk_api_pb = __commonJS({
|
|
|
7548
7537
|
interruption: (f = msg.getInterruption()) && common_pb.AssistantConversationInterruption.toObject(includeInstance, f),
|
|
7549
7538
|
user: (f = msg.getUser()) && common_pb.AssistantConversationUserMessage.toObject(includeInstance, f),
|
|
7550
7539
|
assistant: (f = msg.getAssistant()) && common_pb.AssistantConversationAssistantMessage.toObject(includeInstance, f),
|
|
7551
|
-
message: (f = msg.getMessage()) && common_pb.AssistantConversationMessage.toObject(includeInstance, f),
|
|
7552
7540
|
action: (f = msg.getAction()) && common_pb.AssistantConversationAction.toObject(includeInstance, f),
|
|
7553
7541
|
error: (f = msg.getError()) && common_pb.Error.toObject(includeInstance, f)
|
|
7554
7542
|
};
|
|
@@ -7604,11 +7592,6 @@ var require_talk_api_pb = __commonJS({
|
|
|
7604
7592
|
reader.readMessage(value, common_pb.AssistantConversationAssistantMessage.deserializeBinaryFromReader);
|
|
7605
7593
|
msg.setAssistant(value);
|
|
7606
7594
|
break;
|
|
7607
|
-
case 13:
|
|
7608
|
-
var value = new common_pb.AssistantConversationMessage();
|
|
7609
|
-
reader.readMessage(value, common_pb.AssistantConversationMessage.deserializeBinaryFromReader);
|
|
7610
|
-
msg.setMessage(value);
|
|
7611
|
-
break;
|
|
7612
7595
|
case 14:
|
|
7613
7596
|
var value = new common_pb.AssistantConversationAction();
|
|
7614
7597
|
reader.readMessage(value, common_pb.AssistantConversationAction.deserializeBinaryFromReader);
|
|
@@ -7679,14 +7662,6 @@ var require_talk_api_pb = __commonJS({
|
|
|
7679
7662
|
common_pb.AssistantConversationAssistantMessage.serializeBinaryToWriter
|
|
7680
7663
|
);
|
|
7681
7664
|
}
|
|
7682
|
-
f = message.getMessage();
|
|
7683
|
-
if (f != null) {
|
|
7684
|
-
writer.writeMessage(
|
|
7685
|
-
13,
|
|
7686
|
-
f,
|
|
7687
|
-
common_pb.AssistantConversationMessage.serializeBinaryToWriter
|
|
7688
|
-
);
|
|
7689
|
-
}
|
|
7690
7665
|
f = message.getAction();
|
|
7691
7666
|
if (f != null) {
|
|
7692
7667
|
writer.writeMessage(
|
|
@@ -7782,21 +7757,6 @@ var require_talk_api_pb = __commonJS({
|
|
|
7782
7757
|
proto.talk_api.AssistantMessagingResponse.prototype.hasAssistant = function() {
|
|
7783
7758
|
return jspb.Message.getField(this, 12) != null;
|
|
7784
7759
|
};
|
|
7785
|
-
proto.talk_api.AssistantMessagingResponse.prototype.getMessage = function() {
|
|
7786
|
-
return (
|
|
7787
|
-
/** @type{?proto.AssistantConversationMessage} */
|
|
7788
|
-
jspb.Message.getWrapperField(this, common_pb.AssistantConversationMessage, 13)
|
|
7789
|
-
);
|
|
7790
|
-
};
|
|
7791
|
-
proto.talk_api.AssistantMessagingResponse.prototype.setMessage = function(value) {
|
|
7792
|
-
return jspb.Message.setOneofWrapperField(this, 13, proto.talk_api.AssistantMessagingResponse.oneofGroups_[0], value);
|
|
7793
|
-
};
|
|
7794
|
-
proto.talk_api.AssistantMessagingResponse.prototype.clearMessage = function() {
|
|
7795
|
-
return this.setMessage(void 0);
|
|
7796
|
-
};
|
|
7797
|
-
proto.talk_api.AssistantMessagingResponse.prototype.hasMessage = function() {
|
|
7798
|
-
return jspb.Message.getField(this, 13) != null;
|
|
7799
|
-
};
|
|
7800
7760
|
proto.talk_api.AssistantMessagingResponse.prototype.getAction = function() {
|
|
7801
7761
|
return (
|
|
7802
7762
|
/** @type{?proto.AssistantConversationAction} */
|
|
@@ -27351,6 +27311,9 @@ import moment from "moment";
|
|
|
27351
27311
|
function isSafari() {
|
|
27352
27312
|
return getBrowser()?.name === "Safari";
|
|
27353
27313
|
}
|
|
27314
|
+
function isChrome() {
|
|
27315
|
+
return getBrowser()?.name === "Chrome";
|
|
27316
|
+
}
|
|
27354
27317
|
function toDate(timestamp) {
|
|
27355
27318
|
const seconds = timestamp.getSeconds();
|
|
27356
27319
|
const nanos = timestamp.getNanos();
|
|
@@ -27592,7 +27555,7 @@ var AgentEvent = /* @__PURE__ */ ((AgentEvent2) => {
|
|
|
27592
27555
|
})(AgentEvent || {});
|
|
27593
27556
|
|
|
27594
27557
|
// src/agents/voice-agent.ts
|
|
27595
|
-
var
|
|
27558
|
+
var import_common_pb8 = __toESM(require_common_pb());
|
|
27596
27559
|
|
|
27597
27560
|
// src/types/message.ts
|
|
27598
27561
|
var MessageRole = /* @__PURE__ */ ((MessageRole2) => {
|
|
@@ -29060,6 +29023,24 @@ registerProcessor("raw-audio-processor", RawAudioProcessor);
|
|
|
29060
29023
|
|
|
29061
29024
|
// src/audio/input.ts
|
|
29062
29025
|
var LIBSAMPLERATE_JS = "https://cdn.jsdelivr.net/npm/@alexanderolsen/libsamplerate-js@2.1.2/dist/libsamplerate.worklet.js";
|
|
29026
|
+
function getAudioConstraints(sampleRate) {
|
|
29027
|
+
if (isChrome()) {
|
|
29028
|
+
return {
|
|
29029
|
+
sampleRate: { ideal: sampleRate },
|
|
29030
|
+
echoCancellation: true,
|
|
29031
|
+
noiseSuppression: true,
|
|
29032
|
+
autoGainControl: true,
|
|
29033
|
+
// Chrome-specific: helps with consistent audio quality
|
|
29034
|
+
channelCount: { ideal: 1 }
|
|
29035
|
+
};
|
|
29036
|
+
}
|
|
29037
|
+
return {
|
|
29038
|
+
sampleRate: { ideal: sampleRate },
|
|
29039
|
+
echoCancellation: { ideal: true },
|
|
29040
|
+
noiseSuppression: { ideal: true },
|
|
29041
|
+
autoGainControl: { ideal: true }
|
|
29042
|
+
};
|
|
29043
|
+
}
|
|
29063
29044
|
var Input = class _Input {
|
|
29064
29045
|
constructor(context, analyser, worklet, inputStream) {
|
|
29065
29046
|
this.context = context;
|
|
@@ -29067,18 +29048,10 @@ var Input = class _Input {
|
|
|
29067
29048
|
this.worklet = worklet;
|
|
29068
29049
|
this.inputStream = inputStream;
|
|
29069
29050
|
}
|
|
29070
|
-
static async create({
|
|
29071
|
-
sampleRate,
|
|
29072
|
-
format
|
|
29073
|
-
}) {
|
|
29051
|
+
static async create({ sampleRate, format }, existingStream) {
|
|
29074
29052
|
let context = null;
|
|
29075
29053
|
let inputStream = null;
|
|
29076
29054
|
try {
|
|
29077
|
-
const options = {
|
|
29078
|
-
sampleRate: { ideal: sampleRate },
|
|
29079
|
-
echoCancellation: { ideal: true },
|
|
29080
|
-
noiseSuppression: { ideal: true }
|
|
29081
|
-
};
|
|
29082
29055
|
const supportsSampleRateConstraint = navigator.mediaDevices.getSupportedConstraints().sampleRate;
|
|
29083
29056
|
context = new window.AudioContext(
|
|
29084
29057
|
supportsSampleRateConstraint ? { sampleRate } : {}
|
|
@@ -29088,9 +29061,14 @@ var Input = class _Input {
|
|
|
29088
29061
|
await context.audioWorklet.addModule(LIBSAMPLERATE_JS);
|
|
29089
29062
|
}
|
|
29090
29063
|
await loadRawAudioProcessor(context.audioWorklet);
|
|
29091
|
-
|
|
29092
|
-
|
|
29093
|
-
}
|
|
29064
|
+
if (existingStream) {
|
|
29065
|
+
inputStream = existingStream;
|
|
29066
|
+
} else {
|
|
29067
|
+
const options = getAudioConstraints(sampleRate);
|
|
29068
|
+
inputStream = await navigator.mediaDevices.getUserMedia({
|
|
29069
|
+
audio: options
|
|
29070
|
+
});
|
|
29071
|
+
}
|
|
29094
29072
|
const source = context.createMediaStreamSource(inputStream);
|
|
29095
29073
|
const worklet = new AudioWorkletNode(context, "raw-audio-processor");
|
|
29096
29074
|
worklet.port.postMessage({ type: "setFormat", format, sampleRate });
|
|
@@ -29279,47 +29257,15 @@ function arrayBufferToUint8(arrayBuffer) {
|
|
|
29279
29257
|
}
|
|
29280
29258
|
|
|
29281
29259
|
// src/types/agent-callback.ts
|
|
29282
|
-
var import_common_pb8 = __toESM(require_common_pb());
|
|
29283
|
-
|
|
29284
|
-
// src/utils/rapida_content.ts
|
|
29285
29260
|
var import_common_pb7 = __toESM(require_common_pb());
|
|
29286
|
-
var TEXT_CONTENT_FORMAT_RAW = "raw";
|
|
29287
|
-
var AUDIO_CONTENT_FORMAT_CHUNK = "chunk";
|
|
29288
|
-
var toTextContent = (str, format) => {
|
|
29289
|
-
const cnt = new import_common_pb7.Content();
|
|
29290
|
-
if (format) cnt.setContentformat(format);
|
|
29291
|
-
else cnt.setContentformat(TEXT_CONTENT_FORMAT_RAW);
|
|
29292
|
-
cnt.setContenttype("text" /* TEXT_CONTENT */);
|
|
29293
|
-
cnt.setContent(new TextEncoder().encode(str));
|
|
29294
|
-
return cnt;
|
|
29295
|
-
};
|
|
29296
|
-
var toStreamAudioContent = (raw) => {
|
|
29297
|
-
const cnt = new import_common_pb7.Content();
|
|
29298
|
-
cnt.setContentformat(AUDIO_CONTENT_FORMAT_CHUNK);
|
|
29299
|
-
cnt.setContenttype("audio" /* AUDIO_CONTENT */);
|
|
29300
|
-
cnt.setContent(raw);
|
|
29301
|
-
return cnt;
|
|
29302
|
-
};
|
|
29303
|
-
var toContentText = (cnt) => {
|
|
29304
|
-
if (!cnt) return "";
|
|
29305
|
-
return cnt.filter((x) => x.getContenttype() === "text").map((x) => {
|
|
29306
|
-
try {
|
|
29307
|
-
return new TextDecoder().decode(x.getContent());
|
|
29308
|
-
} catch (error) {
|
|
29309
|
-
return "";
|
|
29310
|
-
}
|
|
29311
|
-
}).join(" ");
|
|
29312
|
-
};
|
|
29313
|
-
|
|
29314
|
-
// src/types/agent-callback.ts
|
|
29315
29261
|
var ConversationUserMessage = class {
|
|
29316
29262
|
constructor(config) {
|
|
29317
29263
|
if (config) {
|
|
29318
29264
|
Object.assign(this, config.toObject());
|
|
29319
29265
|
switch (config.getMessageCase()) {
|
|
29320
|
-
case
|
|
29321
|
-
case
|
|
29322
|
-
case
|
|
29266
|
+
case import_common_pb7.AssistantConversationUserMessage.MessageCase.MESSAGE_NOT_SET:
|
|
29267
|
+
case import_common_pb7.AssistantConversationUserMessage.MessageCase.AUDIO:
|
|
29268
|
+
case import_common_pb7.AssistantConversationUserMessage.MessageCase.TEXT:
|
|
29323
29269
|
this.messageText = config.getText()?.getContent();
|
|
29324
29270
|
}
|
|
29325
29271
|
}
|
|
@@ -29330,25 +29276,14 @@ var ConversationAssistantMessage = class {
|
|
|
29330
29276
|
if (config) {
|
|
29331
29277
|
Object.assign(this, config.toObject());
|
|
29332
29278
|
switch (config.getMessageCase()) {
|
|
29333
|
-
case
|
|
29334
|
-
case
|
|
29335
|
-
case
|
|
29279
|
+
case import_common_pb7.AssistantConversationUserMessage.MessageCase.MESSAGE_NOT_SET:
|
|
29280
|
+
case import_common_pb7.AssistantConversationUserMessage.MessageCase.AUDIO:
|
|
29281
|
+
case import_common_pb7.AssistantConversationUserMessage.MessageCase.TEXT:
|
|
29336
29282
|
this.messageText = config.getText()?.getContent();
|
|
29337
29283
|
}
|
|
29338
29284
|
}
|
|
29339
29285
|
}
|
|
29340
29286
|
};
|
|
29341
|
-
var ConversationMessage = class {
|
|
29342
|
-
constructor(config) {
|
|
29343
|
-
if (config) {
|
|
29344
|
-
Object.assign(this, config.toObject());
|
|
29345
|
-
this.userMessage = toContentText(config.getRequest()?.getContentsList());
|
|
29346
|
-
this.systemMessage = toContentText(
|
|
29347
|
-
config.getResponse()?.getContentsList()
|
|
29348
|
-
);
|
|
29349
|
-
}
|
|
29350
|
-
}
|
|
29351
|
-
};
|
|
29352
29287
|
|
|
29353
29288
|
// src/agents/voice-agent.ts
|
|
29354
29289
|
var VoiceAgent = class extends Agent {
|
|
@@ -29386,13 +29321,14 @@ var VoiceAgent = class extends Agent {
|
|
|
29386
29321
|
connectDevice = async () => {
|
|
29387
29322
|
try {
|
|
29388
29323
|
this.preliminaryInputStream = await this.waitForUserMediaPermission();
|
|
29389
|
-
|
|
29390
|
-
|
|
29391
|
-
|
|
29392
|
-
|
|
29324
|
+
this.output = await Output.create(this.agentConfig.outputOptions.playerOption);
|
|
29325
|
+
this.input = await Input.create(
|
|
29326
|
+
this.agentConfig.inputOptions.recorderOption,
|
|
29327
|
+
this.preliminaryInputStream
|
|
29328
|
+
// Reuse the same MediaStream
|
|
29329
|
+
);
|
|
29393
29330
|
this.input.worklet.port.onmessage = this.onInputWorkletMessage;
|
|
29394
29331
|
this.output.worklet.port.onmessage = this.onOutputWorkletMessage;
|
|
29395
|
-
this.preliminaryInputStream?.getTracks().forEach((track) => track.stop());
|
|
29396
29332
|
this.preliminaryInputStream = null;
|
|
29397
29333
|
} catch (error) {
|
|
29398
29334
|
await this.disconnectAudio();
|
|
@@ -29402,7 +29338,20 @@ var VoiceAgent = class extends Agent {
|
|
|
29402
29338
|
// Helper method to handle media permissions:
|
|
29403
29339
|
waitForUserMediaPermission = async () => {
|
|
29404
29340
|
try {
|
|
29405
|
-
|
|
29341
|
+
const sampleRate = this.agentConfig.inputOptions.recorderOption.sampleRate;
|
|
29342
|
+
const options = isChrome() ? {
|
|
29343
|
+
sampleRate: { ideal: sampleRate },
|
|
29344
|
+
echoCancellation: true,
|
|
29345
|
+
noiseSuppression: true,
|
|
29346
|
+
autoGainControl: true,
|
|
29347
|
+
channelCount: { ideal: 1 }
|
|
29348
|
+
} : {
|
|
29349
|
+
sampleRate: { ideal: sampleRate },
|
|
29350
|
+
echoCancellation: { ideal: true },
|
|
29351
|
+
noiseSuppression: { ideal: true },
|
|
29352
|
+
autoGainControl: { ideal: true }
|
|
29353
|
+
};
|
|
29354
|
+
return await navigator.mediaDevices.getUserMedia({ audio: options });
|
|
29406
29355
|
} catch (error) {
|
|
29407
29356
|
console.error(
|
|
29408
29357
|
"Permission denied or error while requesting microphone access:",
|
|
@@ -29600,13 +29549,13 @@ var VoiceAgent = class extends Agent {
|
|
|
29600
29549
|
onHandleInterruption = (interruptionData) => {
|
|
29601
29550
|
if (interruptionData) {
|
|
29602
29551
|
switch (interruptionData.getType()) {
|
|
29603
|
-
case
|
|
29552
|
+
case import_common_pb8.AssistantConversationInterruption.InterruptionType.INTERRUPTION_TYPE_UNSPECIFIED:
|
|
29604
29553
|
console.log("Unspecified interruption type");
|
|
29605
29554
|
break;
|
|
29606
|
-
case
|
|
29555
|
+
case import_common_pb8.AssistantConversationInterruption.InterruptionType.INTERRUPTION_TYPE_VAD:
|
|
29607
29556
|
this.fadeOutAudio();
|
|
29608
29557
|
break;
|
|
29609
|
-
case
|
|
29558
|
+
case import_common_pb8.AssistantConversationInterruption.InterruptionType.INTERRUPTION_TYPE_WORD:
|
|
29610
29559
|
if (this.agentMessages.length > 0) {
|
|
29611
29560
|
const lastIndex = this.agentMessages.length - 1;
|
|
29612
29561
|
this.agentMessages[lastIndex] = {
|
|
@@ -29633,9 +29582,9 @@ var VoiceAgent = class extends Agent {
|
|
|
29633
29582
|
onHandleUser = (userContent) => {
|
|
29634
29583
|
if (userContent) {
|
|
29635
29584
|
switch (userContent.getMessageCase()) {
|
|
29636
|
-
case
|
|
29637
|
-
case
|
|
29638
|
-
case
|
|
29585
|
+
case import_common_pb8.AssistantConversationUserMessage.MessageCase.MESSAGE_NOT_SET:
|
|
29586
|
+
case import_common_pb8.AssistantConversationUserMessage.MessageCase.AUDIO:
|
|
29587
|
+
case import_common_pb8.AssistantConversationUserMessage.MessageCase.TEXT:
|
|
29639
29588
|
const agentTranscript = userContent.getText()?.getContent();
|
|
29640
29589
|
if (agentTranscript) {
|
|
29641
29590
|
if (this.agentMessages.length > 0) {
|
|
@@ -29667,14 +29616,15 @@ var VoiceAgent = class extends Agent {
|
|
|
29667
29616
|
onHandleAssistant = (systemContent) => {
|
|
29668
29617
|
if (systemContent) {
|
|
29669
29618
|
switch (systemContent.getMessageCase()) {
|
|
29670
|
-
case
|
|
29671
|
-
case
|
|
29619
|
+
case import_common_pb8.AssistantConversationAssistantMessage.MessageCase.MESSAGE_NOT_SET:
|
|
29620
|
+
case import_common_pb8.AssistantConversationAssistantMessage.MessageCase.AUDIO:
|
|
29672
29621
|
const content = systemContent.getAudio();
|
|
29673
29622
|
if (content) {
|
|
29674
29623
|
const audioData = content.getContent_asU8();
|
|
29675
29624
|
this.addAudioChunk(new Uint8Array(audioData).buffer);
|
|
29676
29625
|
}
|
|
29677
|
-
|
|
29626
|
+
break;
|
|
29627
|
+
case import_common_pb8.AssistantConversationAssistantMessage.MessageCase.TEXT:
|
|
29678
29628
|
const systemTranscript = systemContent.getText()?.getContent();
|
|
29679
29629
|
if (systemTranscript) {
|
|
29680
29630
|
if (systemContent.getCompleted()) {
|
|
@@ -29758,8 +29708,6 @@ var VoiceAgent = class extends Agent {
|
|
|
29758
29708
|
const conversation = response.getConfiguration();
|
|
29759
29709
|
if (!conversation?.getAssistantconversationid()) return;
|
|
29760
29710
|
break;
|
|
29761
|
-
case import_talk_api_pb2.AssistantMessagingResponse.DataCase.MESSAGE:
|
|
29762
|
-
break;
|
|
29763
29711
|
default:
|
|
29764
29712
|
break;
|
|
29765
29713
|
}
|
|
@@ -29774,7 +29722,7 @@ var VoiceAgent = class extends Agent {
|
|
|
29774
29722
|
case import_talk_api_pb2.AssistantMessagingResponse.DataCase.DATA_NOT_SET:
|
|
29775
29723
|
break;
|
|
29776
29724
|
case import_talk_api_pb2.AssistantMessagingResponse.DataCase.ACTION:
|
|
29777
|
-
if (response.getAction()?.getAction() ===
|
|
29725
|
+
if (response.getAction()?.getAction() === import_common_pb8.AssistantConversationAction.ActionType.END_CONVERSATION) {
|
|
29778
29726
|
await this.disconnect();
|
|
29779
29727
|
}
|
|
29780
29728
|
if (agentCallback && agentCallback?.onAction) {
|
|
@@ -29809,13 +29757,6 @@ var VoiceAgent = class extends Agent {
|
|
|
29809
29757
|
const cnvId = response.getConfiguration()?.getAssistantconversationid();
|
|
29810
29758
|
if (cnvId) this.changeConversation(cnvId);
|
|
29811
29759
|
break;
|
|
29812
|
-
case import_talk_api_pb2.AssistantMessagingResponse.DataCase.MESSAGE:
|
|
29813
|
-
if (agentCallback && agentCallback?.onMessage) {
|
|
29814
|
-
agentCallback.onMessage(
|
|
29815
|
-
new ConversationMessage(response.getMessage())
|
|
29816
|
-
);
|
|
29817
|
-
}
|
|
29818
|
-
break;
|
|
29819
29760
|
default:
|
|
29820
29761
|
break;
|
|
29821
29762
|
}
|
|
@@ -30201,9 +30142,6 @@ export {
|
|
|
30201
30142
|
DeleteAssistantKnowledge,
|
|
30202
30143
|
GetAssistantToolLog,
|
|
30203
30144
|
GetAllAssistantToolLog,
|
|
30204
|
-
toTextContent,
|
|
30205
|
-
toStreamAudioContent,
|
|
30206
|
-
toContentText,
|
|
30207
30145
|
VoiceAgent,
|
|
30208
30146
|
useObservableState,
|
|
30209
30147
|
agentEventSelector,
|
|
@@ -30213,4 +30151,4 @@ export {
|
|
|
30213
30151
|
useSelectInputDeviceAgent,
|
|
30214
30152
|
DeviceSelectorComponent
|
|
30215
30153
|
};
|
|
30216
|
-
//# sourceMappingURL=chunk-
|
|
30154
|
+
//# sourceMappingURL=chunk-A2PCWS4P.mjs.map
|