@pipecat-ai/daily-transport 0.3.5 → 0.3.6
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/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +76 -25
- package/dist/index.js.map +1 -1
- package/dist/index.module.js +76 -25
- package/dist/index.module.js.map +1 -1
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DailyFactoryOptions, DailyMediaDeviceInfo } from "@daily-co/daily-js";
|
|
1
|
+
import { DailyCall, DailyFactoryOptions, DailyMediaDeviceInfo } from "@daily-co/daily-js";
|
|
2
2
|
import { RTVIClientOptions, RTVIMessage, Tracks, Transport, TransportState } from "@pipecat-ai/client-js";
|
|
3
3
|
export interface DailyTransportAuthBundle {
|
|
4
4
|
room_url: string;
|
|
@@ -17,6 +17,7 @@ export class DailyTransport extends Transport {
|
|
|
17
17
|
handleUserAudioStream(data: ArrayBuffer): void;
|
|
18
18
|
_sendAudioBatch(dataBatch: ArrayBuffer[]): void;
|
|
19
19
|
initialize(options: RTVIClientOptions, messageHandler: (ev: RTVIMessage) => void): void;
|
|
20
|
+
get dailyCallClient(): DailyCall;
|
|
20
21
|
get state(): TransportState;
|
|
21
22
|
private set state(value);
|
|
22
23
|
getAllCams(): Promise<DailyMediaDeviceInfo[]>;
|
|
@@ -35,6 +36,7 @@ export class DailyTransport extends Transport {
|
|
|
35
36
|
enableScreenShare(enable: boolean): void;
|
|
36
37
|
get isSharingScreen(): boolean;
|
|
37
38
|
tracks(): Tracks;
|
|
39
|
+
preAuth(dailyFactoryOptions: DailyFactoryOptions): Promise<void>;
|
|
38
40
|
initDevices(): Promise<void>;
|
|
39
41
|
connect(authBundle: DailyTransportAuthBundle, abortController: AbortController): Promise<void>;
|
|
40
42
|
sendReadyMessage(): Promise<void>;
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
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,gBAAgB,IAAI,OAAO,CAAC,IAAI,CAAC;IA2DjC,UAAU;IAYT,WAAW,CAAC,OAAO,EAAE,WAAW;CA0KxC","sources":["transports/lib/wavtools/lib/wav_packer.js","transports/lib/wavtools/lib/analysis/constants.js","transports/lib/wavtools/lib/analysis/audio_analysis.js","transports/lib/wavtools/lib/worklets/stream_processor.js","transports/lib/wavtools/lib/wav_stream_player.js","transports/lib/wavtools/lib/worklets/audio_processor.js","transports/lib/wavtools/lib/wav_recorder.js","transports/lib/wavtools/lib/mediastream_recorder.js","transports/lib/wavtools/index.js","transports/daily/src/src/transport.ts","transports/daily/src/src/index.ts","transports/daily/src/index.ts"],"sourcesContent":[null,null,null,null,null,null,null,null,null,null,null,"export * from \"./transport\";\n"],"names":[],"version":3,"file":"index.d.ts.map"}
|
package/dist/index.js
CHANGED
|
@@ -1448,6 +1448,49 @@ var $28bdeb35415d61e8$export$ef180de88fd317cc;
|
|
|
1448
1448
|
DailyRTVIMessageType["AUDIO_BUFFERING_STARTED"] = "audio-buffering-started";
|
|
1449
1449
|
DailyRTVIMessageType["AUDIO_BUFFERING_STOPPED"] = "audio-buffering-stopped";
|
|
1450
1450
|
})($28bdeb35415d61e8$export$ef180de88fd317cc || ($28bdeb35415d61e8$export$ef180de88fd317cc = {}));
|
|
1451
|
+
class $28bdeb35415d61e8$var$DailyCallWrapper {
|
|
1452
|
+
constructor(daily){
|
|
1453
|
+
this._daily = daily;
|
|
1454
|
+
this._proxy = new Proxy(this._daily, {
|
|
1455
|
+
get: (target, prop, receiver)=>{
|
|
1456
|
+
if (typeof target[prop] === "function") {
|
|
1457
|
+
let errMsg;
|
|
1458
|
+
switch(String(prop)){
|
|
1459
|
+
// Disable methods that modify the lifecycle of the call. These operations
|
|
1460
|
+
// should be performed via the RTVI client in order to keep state in sync.
|
|
1461
|
+
case "preAuth":
|
|
1462
|
+
errMsg = `Calls to preAuth() are disabled. Please use Transport.preAuth()`;
|
|
1463
|
+
break;
|
|
1464
|
+
case "startCamera":
|
|
1465
|
+
errMsg = `Calls to startCamera() are disabled. Please use RTVIClient.initDevices() or Transport.initDevices()`;
|
|
1466
|
+
break;
|
|
1467
|
+
case "join":
|
|
1468
|
+
errMsg = `Calls to join() are disabled. Please use RTVIClient.connect()`;
|
|
1469
|
+
break;
|
|
1470
|
+
case "leave":
|
|
1471
|
+
errMsg = `Calls to leave() are disabled. Please use RTVIClient.disconnect()`;
|
|
1472
|
+
break;
|
|
1473
|
+
case "destroy":
|
|
1474
|
+
errMsg = `Calls to destroy() are disabled.`;
|
|
1475
|
+
break;
|
|
1476
|
+
}
|
|
1477
|
+
if (errMsg) return ()=>{
|
|
1478
|
+
throw new Error(errMsg);
|
|
1479
|
+
};
|
|
1480
|
+
// Forward other method calls
|
|
1481
|
+
return (...args)=>{
|
|
1482
|
+
return target[prop](...args);
|
|
1483
|
+
};
|
|
1484
|
+
}
|
|
1485
|
+
// Forward property access
|
|
1486
|
+
return Reflect.get(target, prop, receiver);
|
|
1487
|
+
}
|
|
1488
|
+
});
|
|
1489
|
+
}
|
|
1490
|
+
get proxy() {
|
|
1491
|
+
return this._proxy;
|
|
1492
|
+
}
|
|
1493
|
+
}
|
|
1451
1494
|
class $28bdeb35415d61e8$export$b1ca982aa1e488c1 extends (0, $jrPAn$pipecataiclientjs.Transport) {
|
|
1452
1495
|
constructor({ dailyFactoryOptions: dailyFactoryOptions = {}, bufferLocalAudioUntilBotReady: bufferLocalAudioUntilBotReady = false } = {}){
|
|
1453
1496
|
super();
|
|
@@ -1457,8 +1500,14 @@ class $28bdeb35415d61e8$export$b1ca982aa1e488c1 extends (0, $jrPAn$pipecataiclie
|
|
|
1457
1500
|
this._selectedSpeaker = {};
|
|
1458
1501
|
this._currentAudioTrack = null;
|
|
1459
1502
|
this._audioQueue = [];
|
|
1503
|
+
this._callbacks = {};
|
|
1460
1504
|
this._dailyFactoryOptions = dailyFactoryOptions;
|
|
1461
1505
|
this._bufferLocalAudioUntilBotReady = bufferLocalAudioUntilBotReady;
|
|
1506
|
+
this._daily = (0, ($parcel$interopDefault($jrPAn$dailycodailyjs))).createCallObject({
|
|
1507
|
+
...this._dailyFactoryOptions,
|
|
1508
|
+
allowMultipleCallInstances: true
|
|
1509
|
+
});
|
|
1510
|
+
this._dailyWrapper = new $28bdeb35415d61e8$var$DailyCallWrapper(this._daily);
|
|
1462
1511
|
}
|
|
1463
1512
|
setupRecorder() {
|
|
1464
1513
|
this._mediaStreamRecorder = new (0, $7cef7a69bdf8f84d$export$2934cf2d25c67a48)({
|
|
@@ -1488,9 +1537,9 @@ class $28bdeb35415d61e8$export$b1ca982aa1e488c1 extends (0, $jrPAn$pipecataiclie
|
|
|
1488
1537
|
return btoa(String.fromCharCode(...pcmByteArray));
|
|
1489
1538
|
});
|
|
1490
1539
|
const rtviMessage = {
|
|
1491
|
-
id:
|
|
1492
|
-
label:
|
|
1493
|
-
type:
|
|
1540
|
+
id: "raw-audio-batch",
|
|
1541
|
+
label: "rtvi-ai",
|
|
1542
|
+
type: "raw-audio-batch",
|
|
1494
1543
|
data: {
|
|
1495
1544
|
base64AudioBatch: encodedBatch,
|
|
1496
1545
|
sampleRate: $28bdeb35415d61e8$export$b1ca982aa1e488c1.RECORDER_SAMPLE_RATE,
|
|
@@ -1503,20 +1552,17 @@ class $28bdeb35415d61e8$export$b1ca982aa1e488c1 extends (0, $jrPAn$pipecataiclie
|
|
|
1503
1552
|
if (this._bufferLocalAudioUntilBotReady) this.setupRecorder();
|
|
1504
1553
|
this._callbacks = options.callbacks ?? {};
|
|
1505
1554
|
this._onMessage = messageHandler;
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
this.
|
|
1509
|
-
|
|
1510
|
-
// Default is cam off
|
|
1511
|
-
startVideoOff: options.enableCam != true,
|
|
1512
|
-
// Default is mic on
|
|
1513
|
-
startAudioOff: options.enableMic == false,
|
|
1514
|
-
allowMultipleCallInstances: true
|
|
1515
|
-
});
|
|
1555
|
+
if (this._dailyFactoryOptions.startVideoOff == null || options.enableCam != null) // Default is cam off
|
|
1556
|
+
this._dailyFactoryOptions.startVideoOff = !(options.enableCam ?? false);
|
|
1557
|
+
if (this._dailyFactoryOptions.startAudioOff == null || options.enableMic != null) // Default is mic on
|
|
1558
|
+
this._dailyFactoryOptions.startAudioOff = !(options.enableMic ?? true);
|
|
1516
1559
|
this.attachEventListeners();
|
|
1517
1560
|
this.state = "disconnected";
|
|
1518
1561
|
(0, $jrPAn$pipecataiclientjs.logger).debug("[RTVI Transport] Initialized");
|
|
1519
1562
|
}
|
|
1563
|
+
get dailyCallClient() {
|
|
1564
|
+
return this._dailyWrapper.proxy;
|
|
1565
|
+
}
|
|
1520
1566
|
get state() {
|
|
1521
1567
|
return this._state;
|
|
1522
1568
|
}
|
|
@@ -1587,7 +1633,7 @@ class $28bdeb35415d61e8$export$b1ca982aa1e488c1 extends (0, $jrPAn$pipecataiclie
|
|
|
1587
1633
|
return this._daily.localScreenAudio() || this._daily.localScreenVideo();
|
|
1588
1634
|
}
|
|
1589
1635
|
tracks() {
|
|
1590
|
-
const participants = this._daily
|
|
1636
|
+
const participants = this._daily.participants() ?? {};
|
|
1591
1637
|
const bot = participants?.[this._botId];
|
|
1592
1638
|
const tracks = {
|
|
1593
1639
|
local: {
|
|
@@ -1605,7 +1651,7 @@ class $28bdeb35415d61e8$export$b1ca982aa1e488c1 extends (0, $jrPAn$pipecataiclie
|
|
|
1605
1651
|
}
|
|
1606
1652
|
async startRecording() {
|
|
1607
1653
|
try {
|
|
1608
|
-
(0, $jrPAn$pipecataiclientjs.logger).info(
|
|
1654
|
+
(0, $jrPAn$pipecataiclientjs.logger).info("[RTVI Transport] Initializing recording");
|
|
1609
1655
|
await this._mediaStreamRecorder.record((data)=>{
|
|
1610
1656
|
this.handleUserAudioStream(data.mono);
|
|
1611
1657
|
}, $28bdeb35415d61e8$export$b1ca982aa1e488c1.RECORDER_CHUNK_SIZE);
|
|
@@ -1613,12 +1659,16 @@ class $28bdeb35415d61e8$export$b1ca982aa1e488c1 extends (0, $jrPAn$pipecataiclie
|
|
|
1613
1659
|
type: $28bdeb35415d61e8$export$ef180de88fd317cc.AUDIO_BUFFERING_STARTED,
|
|
1614
1660
|
data: {}
|
|
1615
1661
|
});
|
|
1616
|
-
(0, $jrPAn$pipecataiclientjs.logger).info(
|
|
1662
|
+
(0, $jrPAn$pipecataiclientjs.logger).info("[RTVI Transport] Recording Initialized");
|
|
1617
1663
|
} catch (e) {
|
|
1618
1664
|
const err = e;
|
|
1619
1665
|
if (!err.message.includes("Already recording")) (0, $jrPAn$pipecataiclientjs.logger).error("Error starting recording", e);
|
|
1620
1666
|
}
|
|
1621
1667
|
}
|
|
1668
|
+
async preAuth(dailyFactoryOptions) {
|
|
1669
|
+
this._dailyFactoryOptions = dailyFactoryOptions;
|
|
1670
|
+
await this._daily.preAuth(dailyFactoryOptions);
|
|
1671
|
+
}
|
|
1622
1672
|
async initDevices() {
|
|
1623
1673
|
if (!this._daily) throw new (0, $jrPAn$pipecataiclientjs.RTVIError)("Transport instance not initialized");
|
|
1624
1674
|
this.state = "initializing";
|
|
@@ -1627,14 +1677,14 @@ class $28bdeb35415d61e8$export$b1ca982aa1e488c1 extends (0, $jrPAn$pipecataiclie
|
|
|
1627
1677
|
const cams = devices.filter((d)=>d.kind === "videoinput");
|
|
1628
1678
|
const mics = devices.filter((d)=>d.kind === "audioinput");
|
|
1629
1679
|
const speakers = devices.filter((d)=>d.kind === "audiooutput");
|
|
1680
|
+
this._selectedCam = infos.camera;
|
|
1681
|
+
this._selectedMic = infos.mic;
|
|
1682
|
+
this._selectedSpeaker = infos.speaker;
|
|
1630
1683
|
this._callbacks.onAvailableCamsUpdated?.(cams);
|
|
1631
1684
|
this._callbacks.onAvailableMicsUpdated?.(mics);
|
|
1632
1685
|
this._callbacks.onAvailableSpeakersUpdated?.(speakers);
|
|
1633
|
-
this._selectedCam = infos.camera;
|
|
1634
1686
|
this._callbacks.onCamUpdated?.(infos.camera);
|
|
1635
|
-
this._selectedMic = infos.mic;
|
|
1636
1687
|
this._callbacks.onMicUpdated?.(infos.mic);
|
|
1637
|
-
this._selectedSpeaker = infos.speaker;
|
|
1638
1688
|
this._callbacks.onSpeakerUpdated?.(infos.speaker);
|
|
1639
1689
|
// Instantiate audio observers
|
|
1640
1690
|
if (!this._daily.isLocalAudioLevelObserverRunning()) await this._daily.startLocalAudioLevelObserver(100);
|
|
@@ -1645,14 +1695,15 @@ class $28bdeb35415d61e8$export$b1ca982aa1e488c1 extends (0, $jrPAn$pipecataiclie
|
|
|
1645
1695
|
if (!this._daily) throw new (0, $jrPAn$pipecataiclientjs.RTVIError)("Transport instance not initialized");
|
|
1646
1696
|
if (abortController.signal.aborted) return;
|
|
1647
1697
|
this.state = "connecting";
|
|
1698
|
+
const opts = this._dailyFactoryOptions;
|
|
1699
|
+
opts.url = authBundle.room_url ?? opts.url;
|
|
1700
|
+
if (authBundle.token != null) opts.token = authBundle.token;
|
|
1648
1701
|
try {
|
|
1649
|
-
await this._daily.join(
|
|
1650
|
-
url: authBundle.room_url,
|
|
1651
|
-
token: authBundle.token
|
|
1652
|
-
});
|
|
1702
|
+
await this._daily.join(opts);
|
|
1653
1703
|
const room = await this._daily.room();
|
|
1654
1704
|
if (room && "id" in room) this._expiry = room.config?.exp;
|
|
1655
1705
|
} catch (e) {
|
|
1706
|
+
(0, $jrPAn$pipecataiclientjs.logger).error("Failed to join room", e);
|
|
1656
1707
|
this.state = "error";
|
|
1657
1708
|
throw new (0, $jrPAn$pipecataiclientjs.TransportStartError)();
|
|
1658
1709
|
}
|
|
@@ -1701,13 +1752,13 @@ class $28bdeb35415d61e8$export$b1ca982aa1e488c1 extends (0, $jrPAn$pipecataiclie
|
|
|
1701
1752
|
this._daily.on("nonfatal-error", this.handleNonFatalError.bind(this));
|
|
1702
1753
|
}
|
|
1703
1754
|
async disconnect() {
|
|
1755
|
+
this.state = "disconnecting";
|
|
1704
1756
|
this._daily.stopLocalAudioLevelObserver();
|
|
1705
1757
|
this._daily.stopRemoteParticipantsAudioLevelObserver();
|
|
1706
1758
|
this._audioQueue = [];
|
|
1707
1759
|
this._currentAudioTrack = null;
|
|
1708
1760
|
this.stopRecording();
|
|
1709
1761
|
await this._daily.leave();
|
|
1710
|
-
await this._daily.destroy();
|
|
1711
1762
|
}
|
|
1712
1763
|
sendMessage(message) {
|
|
1713
1764
|
this._daily.sendAppMessage(message, "*");
|
|
@@ -1799,7 +1850,7 @@ class $28bdeb35415d61e8$export$b1ca982aa1e488c1 extends (0, $jrPAn$pipecataiclie
|
|
|
1799
1850
|
}
|
|
1800
1851
|
}
|
|
1801
1852
|
handleLeftMeeting() {
|
|
1802
|
-
this.state = "
|
|
1853
|
+
this.state = "disconnected";
|
|
1803
1854
|
this._botId = "";
|
|
1804
1855
|
this._callbacks.onDisconnected?.();
|
|
1805
1856
|
}
|