@rapidaai/react 1.1.50 → 1.1.52
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-2EMDIAFM.mjs → chunk-ZLKWKS6B.mjs} +121 -35
- package/dist/chunk-ZLKWKS6B.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 +120 -34
- package/dist/components/device-selector.js.map +1 -1
- package/dist/components/device-selector.mjs +1 -1
- package/dist/{device-selector-D2B4ipII.d.mts → device-selector-CJXc1lG8.d.mts} +12 -2
- package/dist/{device-selector-D2B4ipII.d.ts → device-selector-CJXc1lG8.d.ts} +12 -2
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +184 -34
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +65 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +11 -2
- package/dist/chunk-2EMDIAFM.mjs.map +0 -1
|
@@ -6562,9 +6562,11 @@ var require_common_pb = __commonJS({
|
|
|
6562
6562
|
};
|
|
6563
6563
|
proto.AssistantConversationAction.toObject = function(includeInstance, msg) {
|
|
6564
6564
|
var f, obj = {
|
|
6565
|
-
|
|
6566
|
-
|
|
6567
|
-
|
|
6565
|
+
id: jspb.Message.getFieldWithDefault(msg, 1, ""),
|
|
6566
|
+
name: jspb.Message.getFieldWithDefault(msg, 2, ""),
|
|
6567
|
+
action: jspb.Message.getFieldWithDefault(msg, 3, 0),
|
|
6568
|
+
argsMap: (f = msg.getArgsMap()) ? f.toObject(includeInstance, proto.google.protobuf.Any.toObject) : [],
|
|
6569
|
+
time: (f = msg.getTime()) && google_protobuf_timestamp_pb.Timestamp.toObject(includeInstance, f)
|
|
6568
6570
|
};
|
|
6569
6571
|
if (includeInstance) {
|
|
6570
6572
|
obj.$jspbMessageInstance = msg;
|
|
@@ -6589,21 +6591,33 @@ var require_common_pb = __commonJS({
|
|
|
6589
6591
|
/** @type {string} */
|
|
6590
6592
|
reader.readString()
|
|
6591
6593
|
);
|
|
6592
|
-
msg.
|
|
6594
|
+
msg.setId(value);
|
|
6593
6595
|
break;
|
|
6594
6596
|
case 2:
|
|
6597
|
+
var value = (
|
|
6598
|
+
/** @type {string} */
|
|
6599
|
+
reader.readString()
|
|
6600
|
+
);
|
|
6601
|
+
msg.setName(value);
|
|
6602
|
+
break;
|
|
6603
|
+
case 3:
|
|
6595
6604
|
var value = (
|
|
6596
6605
|
/** @type {!proto.AssistantConversationAction.ActionType} */
|
|
6597
6606
|
reader.readEnum()
|
|
6598
6607
|
);
|
|
6599
6608
|
msg.setAction(value);
|
|
6600
6609
|
break;
|
|
6601
|
-
case
|
|
6610
|
+
case 4:
|
|
6602
6611
|
var value = msg.getArgsMap();
|
|
6603
6612
|
reader.readMessage(value, function(message, reader2) {
|
|
6604
6613
|
jspb.Map.deserializeBinary(message, reader2, jspb.BinaryReader.prototype.readString, jspb.BinaryReader.prototype.readMessage, proto.google.protobuf.Any.deserializeBinaryFromReader, "", new proto.google.protobuf.Any());
|
|
6605
6614
|
});
|
|
6606
6615
|
break;
|
|
6616
|
+
case 5:
|
|
6617
|
+
var value = new google_protobuf_timestamp_pb.Timestamp();
|
|
6618
|
+
reader.readMessage(value, google_protobuf_timestamp_pb.Timestamp.deserializeBinaryFromReader);
|
|
6619
|
+
msg.setTime(value);
|
|
6620
|
+
break;
|
|
6607
6621
|
default:
|
|
6608
6622
|
reader.skipField();
|
|
6609
6623
|
break;
|
|
@@ -6618,57 +6632,81 @@ var require_common_pb = __commonJS({
|
|
|
6618
6632
|
};
|
|
6619
6633
|
proto.AssistantConversationAction.serializeBinaryToWriter = function(message, writer) {
|
|
6620
6634
|
var f = void 0;
|
|
6621
|
-
f = message.
|
|
6635
|
+
f = message.getId();
|
|
6622
6636
|
if (f.length > 0) {
|
|
6623
6637
|
writer.writeString(
|
|
6624
6638
|
1,
|
|
6625
6639
|
f
|
|
6626
6640
|
);
|
|
6627
6641
|
}
|
|
6642
|
+
f = message.getName();
|
|
6643
|
+
if (f.length > 0) {
|
|
6644
|
+
writer.writeString(
|
|
6645
|
+
2,
|
|
6646
|
+
f
|
|
6647
|
+
);
|
|
6648
|
+
}
|
|
6628
6649
|
f = message.getAction();
|
|
6629
6650
|
if (f !== 0) {
|
|
6630
6651
|
writer.writeEnum(
|
|
6631
|
-
|
|
6652
|
+
3,
|
|
6632
6653
|
f
|
|
6633
6654
|
);
|
|
6634
6655
|
}
|
|
6635
6656
|
f = message.getArgsMap(true);
|
|
6636
6657
|
if (f && f.getLength() > 0) {
|
|
6637
|
-
f.serializeBinary(
|
|
6658
|
+
f.serializeBinary(4, writer, jspb.BinaryWriter.prototype.writeString, jspb.BinaryWriter.prototype.writeMessage, proto.google.protobuf.Any.serializeBinaryToWriter);
|
|
6659
|
+
}
|
|
6660
|
+
f = message.getTime();
|
|
6661
|
+
if (f != null) {
|
|
6662
|
+
writer.writeMessage(
|
|
6663
|
+
5,
|
|
6664
|
+
f,
|
|
6665
|
+
google_protobuf_timestamp_pb.Timestamp.serializeBinaryToWriter
|
|
6666
|
+
);
|
|
6638
6667
|
}
|
|
6639
6668
|
};
|
|
6640
6669
|
proto.AssistantConversationAction.ActionType = {
|
|
6641
6670
|
ACTION_UNSPECIFIED: 0,
|
|
6642
6671
|
KNOWLEDGE_RETRIEVAL: 1,
|
|
6643
6672
|
API_REQUEST: 2,
|
|
6644
|
-
|
|
6645
|
-
|
|
6646
|
-
|
|
6673
|
+
ENDPOINT_REQUEST: 3,
|
|
6674
|
+
END_CONVERSATION: 5,
|
|
6675
|
+
TRANSFER_CONVERSATION: 6
|
|
6647
6676
|
};
|
|
6648
|
-
proto.AssistantConversationAction.prototype.
|
|
6677
|
+
proto.AssistantConversationAction.prototype.getId = function() {
|
|
6649
6678
|
return (
|
|
6650
6679
|
/** @type {string} */
|
|
6651
6680
|
jspb.Message.getFieldWithDefault(this, 1, "")
|
|
6652
6681
|
);
|
|
6653
6682
|
};
|
|
6654
|
-
proto.AssistantConversationAction.prototype.
|
|
6683
|
+
proto.AssistantConversationAction.prototype.setId = function(value) {
|
|
6655
6684
|
return jspb.Message.setProto3StringField(this, 1, value);
|
|
6656
6685
|
};
|
|
6686
|
+
proto.AssistantConversationAction.prototype.getName = function() {
|
|
6687
|
+
return (
|
|
6688
|
+
/** @type {string} */
|
|
6689
|
+
jspb.Message.getFieldWithDefault(this, 2, "")
|
|
6690
|
+
);
|
|
6691
|
+
};
|
|
6692
|
+
proto.AssistantConversationAction.prototype.setName = function(value) {
|
|
6693
|
+
return jspb.Message.setProto3StringField(this, 2, value);
|
|
6694
|
+
};
|
|
6657
6695
|
proto.AssistantConversationAction.prototype.getAction = function() {
|
|
6658
6696
|
return (
|
|
6659
6697
|
/** @type {!proto.AssistantConversationAction.ActionType} */
|
|
6660
|
-
jspb.Message.getFieldWithDefault(this,
|
|
6698
|
+
jspb.Message.getFieldWithDefault(this, 3, 0)
|
|
6661
6699
|
);
|
|
6662
6700
|
};
|
|
6663
6701
|
proto.AssistantConversationAction.prototype.setAction = function(value) {
|
|
6664
|
-
return jspb.Message.setProto3EnumField(this,
|
|
6702
|
+
return jspb.Message.setProto3EnumField(this, 3, value);
|
|
6665
6703
|
};
|
|
6666
6704
|
proto.AssistantConversationAction.prototype.getArgsMap = function(opt_noLazyCreate) {
|
|
6667
6705
|
return (
|
|
6668
6706
|
/** @type {!jspb.Map<string,!proto.google.protobuf.Any>} */
|
|
6669
6707
|
jspb.Message.getMapField(
|
|
6670
6708
|
this,
|
|
6671
|
-
|
|
6709
|
+
4,
|
|
6672
6710
|
opt_noLazyCreate,
|
|
6673
6711
|
proto.google.protobuf.Any
|
|
6674
6712
|
)
|
|
@@ -6678,6 +6716,21 @@ var require_common_pb = __commonJS({
|
|
|
6678
6716
|
this.getArgsMap().clear();
|
|
6679
6717
|
return this;
|
|
6680
6718
|
};
|
|
6719
|
+
proto.AssistantConversationAction.prototype.getTime = function() {
|
|
6720
|
+
return (
|
|
6721
|
+
/** @type{?proto.google.protobuf.Timestamp} */
|
|
6722
|
+
jspb.Message.getWrapperField(this, google_protobuf_timestamp_pb.Timestamp, 5)
|
|
6723
|
+
);
|
|
6724
|
+
};
|
|
6725
|
+
proto.AssistantConversationAction.prototype.setTime = function(value) {
|
|
6726
|
+
return jspb.Message.setWrapperField(this, 5, value);
|
|
6727
|
+
};
|
|
6728
|
+
proto.AssistantConversationAction.prototype.clearTime = function() {
|
|
6729
|
+
return this.setTime(void 0);
|
|
6730
|
+
};
|
|
6731
|
+
proto.AssistantConversationAction.prototype.hasTime = function() {
|
|
6732
|
+
return jspb.Message.getField(this, 5) != null;
|
|
6733
|
+
};
|
|
6681
6734
|
if (jspb.Message.GENERATE_TO_OBJECT) {
|
|
6682
6735
|
proto.AssistantConversationInterruption.prototype.toObject = function(opt_includeInstance) {
|
|
6683
6736
|
return proto.AssistantConversationInterruption.toObject(opt_includeInstance, this);
|
|
@@ -27337,6 +27390,9 @@ var import_moment = __toESM(require("moment"));
|
|
|
27337
27390
|
function isSafari() {
|
|
27338
27391
|
return getBrowser()?.name === "Safari";
|
|
27339
27392
|
}
|
|
27393
|
+
function isChrome() {
|
|
27394
|
+
return getBrowser()?.name === "Chrome";
|
|
27395
|
+
}
|
|
27340
27396
|
function toDate(timestamp) {
|
|
27341
27397
|
const seconds = timestamp.getSeconds();
|
|
27342
27398
|
const nanos = timestamp.getNanos();
|
|
@@ -28293,6 +28349,24 @@ registerProcessor("raw-audio-processor", RawAudioProcessor);
|
|
|
28293
28349
|
|
|
28294
28350
|
// src/audio/input.ts
|
|
28295
28351
|
var LIBSAMPLERATE_JS = "https://cdn.jsdelivr.net/npm/@alexanderolsen/libsamplerate-js@2.1.2/dist/libsamplerate.worklet.js";
|
|
28352
|
+
function getAudioConstraints(sampleRate) {
|
|
28353
|
+
if (isChrome()) {
|
|
28354
|
+
return {
|
|
28355
|
+
sampleRate: { ideal: sampleRate },
|
|
28356
|
+
echoCancellation: true,
|
|
28357
|
+
noiseSuppression: true,
|
|
28358
|
+
autoGainControl: true,
|
|
28359
|
+
// Chrome-specific: helps with consistent audio quality
|
|
28360
|
+
channelCount: { ideal: 1 }
|
|
28361
|
+
};
|
|
28362
|
+
}
|
|
28363
|
+
return {
|
|
28364
|
+
sampleRate: { ideal: sampleRate },
|
|
28365
|
+
echoCancellation: { ideal: true },
|
|
28366
|
+
noiseSuppression: { ideal: true },
|
|
28367
|
+
autoGainControl: { ideal: true }
|
|
28368
|
+
};
|
|
28369
|
+
}
|
|
28296
28370
|
var Input = class _Input {
|
|
28297
28371
|
constructor(context, analyser, worklet, inputStream) {
|
|
28298
28372
|
this.context = context;
|
|
@@ -28300,18 +28374,10 @@ var Input = class _Input {
|
|
|
28300
28374
|
this.worklet = worklet;
|
|
28301
28375
|
this.inputStream = inputStream;
|
|
28302
28376
|
}
|
|
28303
|
-
static async create({
|
|
28304
|
-
sampleRate,
|
|
28305
|
-
format
|
|
28306
|
-
}) {
|
|
28377
|
+
static async create({ sampleRate, format }, existingStream) {
|
|
28307
28378
|
let context = null;
|
|
28308
28379
|
let inputStream = null;
|
|
28309
28380
|
try {
|
|
28310
|
-
const options = {
|
|
28311
|
-
sampleRate: { ideal: sampleRate },
|
|
28312
|
-
echoCancellation: { ideal: true },
|
|
28313
|
-
noiseSuppression: { ideal: true }
|
|
28314
|
-
};
|
|
28315
28381
|
const supportsSampleRateConstraint = navigator.mediaDevices.getSupportedConstraints().sampleRate;
|
|
28316
28382
|
context = new window.AudioContext(
|
|
28317
28383
|
supportsSampleRateConstraint ? { sampleRate } : {}
|
|
@@ -28321,9 +28387,14 @@ var Input = class _Input {
|
|
|
28321
28387
|
await context.audioWorklet.addModule(LIBSAMPLERATE_JS);
|
|
28322
28388
|
}
|
|
28323
28389
|
await loadRawAudioProcessor(context.audioWorklet);
|
|
28324
|
-
|
|
28325
|
-
|
|
28326
|
-
}
|
|
28390
|
+
if (existingStream) {
|
|
28391
|
+
inputStream = existingStream;
|
|
28392
|
+
} else {
|
|
28393
|
+
const options = getAudioConstraints(sampleRate);
|
|
28394
|
+
inputStream = await navigator.mediaDevices.getUserMedia({
|
|
28395
|
+
audio: options
|
|
28396
|
+
});
|
|
28397
|
+
}
|
|
28327
28398
|
const source = context.createMediaStreamSource(inputStream);
|
|
28328
28399
|
const worklet = new AudioWorkletNode(context, "raw-audio-processor");
|
|
28329
28400
|
worklet.port.postMessage({ type: "setFormat", format, sampleRate });
|
|
@@ -28576,13 +28647,14 @@ var VoiceAgent = class extends Agent {
|
|
|
28576
28647
|
connectDevice = async () => {
|
|
28577
28648
|
try {
|
|
28578
28649
|
this.preliminaryInputStream = await this.waitForUserMediaPermission();
|
|
28579
|
-
|
|
28580
|
-
|
|
28581
|
-
|
|
28582
|
-
|
|
28650
|
+
this.output = await Output.create(this.agentConfig.outputOptions.playerOption);
|
|
28651
|
+
this.input = await Input.create(
|
|
28652
|
+
this.agentConfig.inputOptions.recorderOption,
|
|
28653
|
+
this.preliminaryInputStream
|
|
28654
|
+
// Reuse the same MediaStream
|
|
28655
|
+
);
|
|
28583
28656
|
this.input.worklet.port.onmessage = this.onInputWorkletMessage;
|
|
28584
28657
|
this.output.worklet.port.onmessage = this.onOutputWorkletMessage;
|
|
28585
|
-
this.preliminaryInputStream?.getTracks().forEach((track) => track.stop());
|
|
28586
28658
|
this.preliminaryInputStream = null;
|
|
28587
28659
|
} catch (error) {
|
|
28588
28660
|
await this.disconnectAudio();
|
|
@@ -28592,7 +28664,20 @@ var VoiceAgent = class extends Agent {
|
|
|
28592
28664
|
// Helper method to handle media permissions:
|
|
28593
28665
|
waitForUserMediaPermission = async () => {
|
|
28594
28666
|
try {
|
|
28595
|
-
|
|
28667
|
+
const sampleRate = this.agentConfig.inputOptions.recorderOption.sampleRate;
|
|
28668
|
+
const options = isChrome() ? {
|
|
28669
|
+
sampleRate: { ideal: sampleRate },
|
|
28670
|
+
echoCancellation: true,
|
|
28671
|
+
noiseSuppression: true,
|
|
28672
|
+
autoGainControl: true,
|
|
28673
|
+
channelCount: { ideal: 1 }
|
|
28674
|
+
} : {
|
|
28675
|
+
sampleRate: { ideal: sampleRate },
|
|
28676
|
+
echoCancellation: { ideal: true },
|
|
28677
|
+
noiseSuppression: { ideal: true },
|
|
28678
|
+
autoGainControl: { ideal: true }
|
|
28679
|
+
};
|
|
28680
|
+
return await navigator.mediaDevices.getUserMedia({ audio: options });
|
|
28596
28681
|
} catch (error) {
|
|
28597
28682
|
console.error(
|
|
28598
28683
|
"Permission denied or error while requesting microphone access:",
|
|
@@ -28864,6 +28949,7 @@ var VoiceAgent = class extends Agent {
|
|
|
28864
28949
|
const audioData = content.getContent_asU8();
|
|
28865
28950
|
this.addAudioChunk(new Uint8Array(audioData).buffer);
|
|
28866
28951
|
}
|
|
28952
|
+
break;
|
|
28867
28953
|
case import_common_pb8.AssistantConversationAssistantMessage.MessageCase.TEXT:
|
|
28868
28954
|
const systemTranscript = systemContent.getText()?.getContent();
|
|
28869
28955
|
if (systemTranscript) {
|