@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
|
@@ -6537,9 +6537,11 @@ var require_common_pb = __commonJS({
|
|
|
6537
6537
|
};
|
|
6538
6538
|
proto.AssistantConversationAction.toObject = function(includeInstance, msg) {
|
|
6539
6539
|
var f, obj = {
|
|
6540
|
-
|
|
6541
|
-
|
|
6542
|
-
|
|
6540
|
+
id: jspb.Message.getFieldWithDefault(msg, 1, ""),
|
|
6541
|
+
name: jspb.Message.getFieldWithDefault(msg, 2, ""),
|
|
6542
|
+
action: jspb.Message.getFieldWithDefault(msg, 3, 0),
|
|
6543
|
+
argsMap: (f = msg.getArgsMap()) ? f.toObject(includeInstance, proto.google.protobuf.Any.toObject) : [],
|
|
6544
|
+
time: (f = msg.getTime()) && google_protobuf_timestamp_pb.Timestamp.toObject(includeInstance, f)
|
|
6543
6545
|
};
|
|
6544
6546
|
if (includeInstance) {
|
|
6545
6547
|
obj.$jspbMessageInstance = msg;
|
|
@@ -6564,21 +6566,33 @@ var require_common_pb = __commonJS({
|
|
|
6564
6566
|
/** @type {string} */
|
|
6565
6567
|
reader.readString()
|
|
6566
6568
|
);
|
|
6567
|
-
msg.
|
|
6569
|
+
msg.setId(value);
|
|
6568
6570
|
break;
|
|
6569
6571
|
case 2:
|
|
6572
|
+
var value = (
|
|
6573
|
+
/** @type {string} */
|
|
6574
|
+
reader.readString()
|
|
6575
|
+
);
|
|
6576
|
+
msg.setName(value);
|
|
6577
|
+
break;
|
|
6578
|
+
case 3:
|
|
6570
6579
|
var value = (
|
|
6571
6580
|
/** @type {!proto.AssistantConversationAction.ActionType} */
|
|
6572
6581
|
reader.readEnum()
|
|
6573
6582
|
);
|
|
6574
6583
|
msg.setAction(value);
|
|
6575
6584
|
break;
|
|
6576
|
-
case
|
|
6585
|
+
case 4:
|
|
6577
6586
|
var value = msg.getArgsMap();
|
|
6578
6587
|
reader.readMessage(value, function(message, reader2) {
|
|
6579
6588
|
jspb.Map.deserializeBinary(message, reader2, jspb.BinaryReader.prototype.readString, jspb.BinaryReader.prototype.readMessage, proto.google.protobuf.Any.deserializeBinaryFromReader, "", new proto.google.protobuf.Any());
|
|
6580
6589
|
});
|
|
6581
6590
|
break;
|
|
6591
|
+
case 5:
|
|
6592
|
+
var value = new google_protobuf_timestamp_pb.Timestamp();
|
|
6593
|
+
reader.readMessage(value, google_protobuf_timestamp_pb.Timestamp.deserializeBinaryFromReader);
|
|
6594
|
+
msg.setTime(value);
|
|
6595
|
+
break;
|
|
6582
6596
|
default:
|
|
6583
6597
|
reader.skipField();
|
|
6584
6598
|
break;
|
|
@@ -6593,57 +6607,81 @@ var require_common_pb = __commonJS({
|
|
|
6593
6607
|
};
|
|
6594
6608
|
proto.AssistantConversationAction.serializeBinaryToWriter = function(message, writer) {
|
|
6595
6609
|
var f = void 0;
|
|
6596
|
-
f = message.
|
|
6610
|
+
f = message.getId();
|
|
6597
6611
|
if (f.length > 0) {
|
|
6598
6612
|
writer.writeString(
|
|
6599
6613
|
1,
|
|
6600
6614
|
f
|
|
6601
6615
|
);
|
|
6602
6616
|
}
|
|
6617
|
+
f = message.getName();
|
|
6618
|
+
if (f.length > 0) {
|
|
6619
|
+
writer.writeString(
|
|
6620
|
+
2,
|
|
6621
|
+
f
|
|
6622
|
+
);
|
|
6623
|
+
}
|
|
6603
6624
|
f = message.getAction();
|
|
6604
6625
|
if (f !== 0) {
|
|
6605
6626
|
writer.writeEnum(
|
|
6606
|
-
|
|
6627
|
+
3,
|
|
6607
6628
|
f
|
|
6608
6629
|
);
|
|
6609
6630
|
}
|
|
6610
6631
|
f = message.getArgsMap(true);
|
|
6611
6632
|
if (f && f.getLength() > 0) {
|
|
6612
|
-
f.serializeBinary(
|
|
6633
|
+
f.serializeBinary(4, writer, jspb.BinaryWriter.prototype.writeString, jspb.BinaryWriter.prototype.writeMessage, proto.google.protobuf.Any.serializeBinaryToWriter);
|
|
6634
|
+
}
|
|
6635
|
+
f = message.getTime();
|
|
6636
|
+
if (f != null) {
|
|
6637
|
+
writer.writeMessage(
|
|
6638
|
+
5,
|
|
6639
|
+
f,
|
|
6640
|
+
google_protobuf_timestamp_pb.Timestamp.serializeBinaryToWriter
|
|
6641
|
+
);
|
|
6613
6642
|
}
|
|
6614
6643
|
};
|
|
6615
6644
|
proto.AssistantConversationAction.ActionType = {
|
|
6616
6645
|
ACTION_UNSPECIFIED: 0,
|
|
6617
6646
|
KNOWLEDGE_RETRIEVAL: 1,
|
|
6618
6647
|
API_REQUEST: 2,
|
|
6619
|
-
|
|
6620
|
-
|
|
6621
|
-
|
|
6648
|
+
ENDPOINT_REQUEST: 3,
|
|
6649
|
+
END_CONVERSATION: 5,
|
|
6650
|
+
TRANSFER_CONVERSATION: 6
|
|
6622
6651
|
};
|
|
6623
|
-
proto.AssistantConversationAction.prototype.
|
|
6652
|
+
proto.AssistantConversationAction.prototype.getId = function() {
|
|
6624
6653
|
return (
|
|
6625
6654
|
/** @type {string} */
|
|
6626
6655
|
jspb.Message.getFieldWithDefault(this, 1, "")
|
|
6627
6656
|
);
|
|
6628
6657
|
};
|
|
6629
|
-
proto.AssistantConversationAction.prototype.
|
|
6658
|
+
proto.AssistantConversationAction.prototype.setId = function(value) {
|
|
6630
6659
|
return jspb.Message.setProto3StringField(this, 1, value);
|
|
6631
6660
|
};
|
|
6661
|
+
proto.AssistantConversationAction.prototype.getName = function() {
|
|
6662
|
+
return (
|
|
6663
|
+
/** @type {string} */
|
|
6664
|
+
jspb.Message.getFieldWithDefault(this, 2, "")
|
|
6665
|
+
);
|
|
6666
|
+
};
|
|
6667
|
+
proto.AssistantConversationAction.prototype.setName = function(value) {
|
|
6668
|
+
return jspb.Message.setProto3StringField(this, 2, value);
|
|
6669
|
+
};
|
|
6632
6670
|
proto.AssistantConversationAction.prototype.getAction = function() {
|
|
6633
6671
|
return (
|
|
6634
6672
|
/** @type {!proto.AssistantConversationAction.ActionType} */
|
|
6635
|
-
jspb.Message.getFieldWithDefault(this,
|
|
6673
|
+
jspb.Message.getFieldWithDefault(this, 3, 0)
|
|
6636
6674
|
);
|
|
6637
6675
|
};
|
|
6638
6676
|
proto.AssistantConversationAction.prototype.setAction = function(value) {
|
|
6639
|
-
return jspb.Message.setProto3EnumField(this,
|
|
6677
|
+
return jspb.Message.setProto3EnumField(this, 3, value);
|
|
6640
6678
|
};
|
|
6641
6679
|
proto.AssistantConversationAction.prototype.getArgsMap = function(opt_noLazyCreate) {
|
|
6642
6680
|
return (
|
|
6643
6681
|
/** @type {!jspb.Map<string,!proto.google.protobuf.Any>} */
|
|
6644
6682
|
jspb.Message.getMapField(
|
|
6645
6683
|
this,
|
|
6646
|
-
|
|
6684
|
+
4,
|
|
6647
6685
|
opt_noLazyCreate,
|
|
6648
6686
|
proto.google.protobuf.Any
|
|
6649
6687
|
)
|
|
@@ -6653,6 +6691,21 @@ var require_common_pb = __commonJS({
|
|
|
6653
6691
|
this.getArgsMap().clear();
|
|
6654
6692
|
return this;
|
|
6655
6693
|
};
|
|
6694
|
+
proto.AssistantConversationAction.prototype.getTime = function() {
|
|
6695
|
+
return (
|
|
6696
|
+
/** @type{?proto.google.protobuf.Timestamp} */
|
|
6697
|
+
jspb.Message.getWrapperField(this, google_protobuf_timestamp_pb.Timestamp, 5)
|
|
6698
|
+
);
|
|
6699
|
+
};
|
|
6700
|
+
proto.AssistantConversationAction.prototype.setTime = function(value) {
|
|
6701
|
+
return jspb.Message.setWrapperField(this, 5, value);
|
|
6702
|
+
};
|
|
6703
|
+
proto.AssistantConversationAction.prototype.clearTime = function() {
|
|
6704
|
+
return this.setTime(void 0);
|
|
6705
|
+
};
|
|
6706
|
+
proto.AssistantConversationAction.prototype.hasTime = function() {
|
|
6707
|
+
return jspb.Message.getField(this, 5) != null;
|
|
6708
|
+
};
|
|
6656
6709
|
if (jspb.Message.GENERATE_TO_OBJECT) {
|
|
6657
6710
|
proto.AssistantConversationInterruption.prototype.toObject = function(opt_includeInstance) {
|
|
6658
6711
|
return proto.AssistantConversationInterruption.toObject(opt_includeInstance, this);
|
|
@@ -27311,6 +27364,9 @@ import moment from "moment";
|
|
|
27311
27364
|
function isSafari() {
|
|
27312
27365
|
return getBrowser()?.name === "Safari";
|
|
27313
27366
|
}
|
|
27367
|
+
function isChrome() {
|
|
27368
|
+
return getBrowser()?.name === "Chrome";
|
|
27369
|
+
}
|
|
27314
27370
|
function toDate(timestamp) {
|
|
27315
27371
|
const seconds = timestamp.getSeconds();
|
|
27316
27372
|
const nanos = timestamp.getNanos();
|
|
@@ -29020,6 +29076,24 @@ registerProcessor("raw-audio-processor", RawAudioProcessor);
|
|
|
29020
29076
|
|
|
29021
29077
|
// src/audio/input.ts
|
|
29022
29078
|
var LIBSAMPLERATE_JS = "https://cdn.jsdelivr.net/npm/@alexanderolsen/libsamplerate-js@2.1.2/dist/libsamplerate.worklet.js";
|
|
29079
|
+
function getAudioConstraints(sampleRate) {
|
|
29080
|
+
if (isChrome()) {
|
|
29081
|
+
return {
|
|
29082
|
+
sampleRate: { ideal: sampleRate },
|
|
29083
|
+
echoCancellation: true,
|
|
29084
|
+
noiseSuppression: true,
|
|
29085
|
+
autoGainControl: true,
|
|
29086
|
+
// Chrome-specific: helps with consistent audio quality
|
|
29087
|
+
channelCount: { ideal: 1 }
|
|
29088
|
+
};
|
|
29089
|
+
}
|
|
29090
|
+
return {
|
|
29091
|
+
sampleRate: { ideal: sampleRate },
|
|
29092
|
+
echoCancellation: { ideal: true },
|
|
29093
|
+
noiseSuppression: { ideal: true },
|
|
29094
|
+
autoGainControl: { ideal: true }
|
|
29095
|
+
};
|
|
29096
|
+
}
|
|
29023
29097
|
var Input = class _Input {
|
|
29024
29098
|
constructor(context, analyser, worklet, inputStream) {
|
|
29025
29099
|
this.context = context;
|
|
@@ -29027,18 +29101,10 @@ var Input = class _Input {
|
|
|
29027
29101
|
this.worklet = worklet;
|
|
29028
29102
|
this.inputStream = inputStream;
|
|
29029
29103
|
}
|
|
29030
|
-
static async create({
|
|
29031
|
-
sampleRate,
|
|
29032
|
-
format
|
|
29033
|
-
}) {
|
|
29104
|
+
static async create({ sampleRate, format }, existingStream) {
|
|
29034
29105
|
let context = null;
|
|
29035
29106
|
let inputStream = null;
|
|
29036
29107
|
try {
|
|
29037
|
-
const options = {
|
|
29038
|
-
sampleRate: { ideal: sampleRate },
|
|
29039
|
-
echoCancellation: { ideal: true },
|
|
29040
|
-
noiseSuppression: { ideal: true }
|
|
29041
|
-
};
|
|
29042
29108
|
const supportsSampleRateConstraint = navigator.mediaDevices.getSupportedConstraints().sampleRate;
|
|
29043
29109
|
context = new window.AudioContext(
|
|
29044
29110
|
supportsSampleRateConstraint ? { sampleRate } : {}
|
|
@@ -29048,9 +29114,14 @@ var Input = class _Input {
|
|
|
29048
29114
|
await context.audioWorklet.addModule(LIBSAMPLERATE_JS);
|
|
29049
29115
|
}
|
|
29050
29116
|
await loadRawAudioProcessor(context.audioWorklet);
|
|
29051
|
-
|
|
29052
|
-
|
|
29053
|
-
}
|
|
29117
|
+
if (existingStream) {
|
|
29118
|
+
inputStream = existingStream;
|
|
29119
|
+
} else {
|
|
29120
|
+
const options = getAudioConstraints(sampleRate);
|
|
29121
|
+
inputStream = await navigator.mediaDevices.getUserMedia({
|
|
29122
|
+
audio: options
|
|
29123
|
+
});
|
|
29124
|
+
}
|
|
29054
29125
|
const source = context.createMediaStreamSource(inputStream);
|
|
29055
29126
|
const worklet = new AudioWorkletNode(context, "raw-audio-processor");
|
|
29056
29127
|
worklet.port.postMessage({ type: "setFormat", format, sampleRate });
|
|
@@ -29303,13 +29374,14 @@ var VoiceAgent = class extends Agent {
|
|
|
29303
29374
|
connectDevice = async () => {
|
|
29304
29375
|
try {
|
|
29305
29376
|
this.preliminaryInputStream = await this.waitForUserMediaPermission();
|
|
29306
|
-
|
|
29307
|
-
|
|
29308
|
-
|
|
29309
|
-
|
|
29377
|
+
this.output = await Output.create(this.agentConfig.outputOptions.playerOption);
|
|
29378
|
+
this.input = await Input.create(
|
|
29379
|
+
this.agentConfig.inputOptions.recorderOption,
|
|
29380
|
+
this.preliminaryInputStream
|
|
29381
|
+
// Reuse the same MediaStream
|
|
29382
|
+
);
|
|
29310
29383
|
this.input.worklet.port.onmessage = this.onInputWorkletMessage;
|
|
29311
29384
|
this.output.worklet.port.onmessage = this.onOutputWorkletMessage;
|
|
29312
|
-
this.preliminaryInputStream?.getTracks().forEach((track) => track.stop());
|
|
29313
29385
|
this.preliminaryInputStream = null;
|
|
29314
29386
|
} catch (error) {
|
|
29315
29387
|
await this.disconnectAudio();
|
|
@@ -29319,7 +29391,20 @@ var VoiceAgent = class extends Agent {
|
|
|
29319
29391
|
// Helper method to handle media permissions:
|
|
29320
29392
|
waitForUserMediaPermission = async () => {
|
|
29321
29393
|
try {
|
|
29322
|
-
|
|
29394
|
+
const sampleRate = this.agentConfig.inputOptions.recorderOption.sampleRate;
|
|
29395
|
+
const options = isChrome() ? {
|
|
29396
|
+
sampleRate: { ideal: sampleRate },
|
|
29397
|
+
echoCancellation: true,
|
|
29398
|
+
noiseSuppression: true,
|
|
29399
|
+
autoGainControl: true,
|
|
29400
|
+
channelCount: { ideal: 1 }
|
|
29401
|
+
} : {
|
|
29402
|
+
sampleRate: { ideal: sampleRate },
|
|
29403
|
+
echoCancellation: { ideal: true },
|
|
29404
|
+
noiseSuppression: { ideal: true },
|
|
29405
|
+
autoGainControl: { ideal: true }
|
|
29406
|
+
};
|
|
29407
|
+
return await navigator.mediaDevices.getUserMedia({ audio: options });
|
|
29323
29408
|
} catch (error) {
|
|
29324
29409
|
console.error(
|
|
29325
29410
|
"Permission denied or error while requesting microphone access:",
|
|
@@ -29591,6 +29676,7 @@ var VoiceAgent = class extends Agent {
|
|
|
29591
29676
|
const audioData = content.getContent_asU8();
|
|
29592
29677
|
this.addAudioChunk(new Uint8Array(audioData).buffer);
|
|
29593
29678
|
}
|
|
29679
|
+
break;
|
|
29594
29680
|
case import_common_pb8.AssistantConversationAssistantMessage.MessageCase.TEXT:
|
|
29595
29681
|
const systemTranscript = systemContent.getText()?.getContent();
|
|
29596
29682
|
if (systemTranscript) {
|
|
@@ -30118,4 +30204,4 @@ export {
|
|
|
30118
30204
|
useSelectInputDeviceAgent,
|
|
30119
30205
|
DeviceSelectorComponent
|
|
30120
30206
|
};
|
|
30121
|
-
//# sourceMappingURL=chunk-
|
|
30207
|
+
//# sourceMappingURL=chunk-ZLKWKS6B.mjs.map
|