@whereby.com/assistant-sdk 0.0.0-canary-20250912142319 → 0.0.0-canary-20250916072551
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.cjs +6 -11
- package/dist/index.d.cts +78 -53
- package/dist/index.d.mts +78 -53
- package/dist/index.d.ts +78 -53
- package/dist/index.mjs +6 -11
- package/dist/legacy-esm.js +6 -11
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -30,7 +30,7 @@ function _interopNamespaceDefault(e) {
|
|
|
30
30
|
|
|
31
31
|
var dotenv__namespace = /*#__PURE__*/_interopNamespaceDefault(dotenv);
|
|
32
32
|
|
|
33
|
-
const
|
|
33
|
+
const TRIGGER_EVENT_SUCCESS = "trigger_event_success";
|
|
34
34
|
|
|
35
35
|
const AUDIO_STREAM_READY = "AUDIO_STREAM_READY";
|
|
36
36
|
|
|
@@ -649,7 +649,7 @@ function buildRoomUrl(roomPath, wherebySubdomain, baseDomain = "whereby.com") {
|
|
|
649
649
|
return `https://${wherebyDomain}${roomPath}`;
|
|
650
650
|
}
|
|
651
651
|
|
|
652
|
-
const webhookRouter = (webhookTriggers, emitter
|
|
652
|
+
const webhookRouter = (webhookTriggers, emitter) => {
|
|
653
653
|
const router = express.Router();
|
|
654
654
|
const jsonParser = bodyParser.json();
|
|
655
655
|
router.get("/", (_, res) => {
|
|
@@ -663,9 +663,7 @@ const webhookRouter = (webhookTriggers, emitter, assistantKey, startCombinedAudi
|
|
|
663
663
|
const shouldTriggerOnReceivedWebhook = (_a = webhookTriggers[req.body.type]) === null || _a === void 0 ? void 0 : _a.call(webhookTriggers, req.body);
|
|
664
664
|
if (shouldTriggerOnReceivedWebhook) {
|
|
665
665
|
const roomUrl = buildRoomUrl(req.body.data.roomName, req.body.data.subdomain);
|
|
666
|
-
|
|
667
|
-
assistant.joinRoom(roomUrl);
|
|
668
|
-
emitter.emit(ASSISTANT_JOIN_SUCCESS, { roomUrl, triggerWebhook: req.body, assistant });
|
|
666
|
+
emitter.emit(TRIGGER_EVENT_SUCCESS, { roomUrl, triggerWebhook: req.body });
|
|
669
667
|
}
|
|
670
668
|
res.status(200);
|
|
671
669
|
res.end();
|
|
@@ -673,17 +671,14 @@ const webhookRouter = (webhookTriggers, emitter, assistantKey, startCombinedAudi
|
|
|
673
671
|
return router;
|
|
674
672
|
};
|
|
675
673
|
class Trigger extends EventEmitter.EventEmitter {
|
|
676
|
-
constructor({ webhookTriggers = {}, port = 8080
|
|
674
|
+
constructor({ webhookTriggers = {}, port = 8080 }) {
|
|
677
675
|
super();
|
|
678
676
|
this.webhookTriggers = webhookTriggers;
|
|
679
677
|
this.port = port;
|
|
680
|
-
this.assistantKey = assistantKey;
|
|
681
|
-
this.startCombinedAudioStream = startCombinedAudioStream !== null && startCombinedAudioStream !== void 0 ? startCombinedAudioStream : false;
|
|
682
|
-
this.startLocalMedia = startLocalMedia !== null && startLocalMedia !== void 0 ? startLocalMedia : false;
|
|
683
678
|
}
|
|
684
679
|
start() {
|
|
685
680
|
const app = express();
|
|
686
|
-
const router = webhookRouter(this.webhookTriggers, this
|
|
681
|
+
const router = webhookRouter(this.webhookTriggers, this);
|
|
687
682
|
app.use(router);
|
|
688
683
|
const server = app.listen(this.port, () => {
|
|
689
684
|
// console.log(`Bot trigger server now running on port[${this.port}]`);
|
|
@@ -694,9 +689,9 @@ class Trigger extends EventEmitter.EventEmitter {
|
|
|
694
689
|
}
|
|
695
690
|
}
|
|
696
691
|
|
|
697
|
-
exports.ASSISTANT_JOIN_SUCCESS = ASSISTANT_JOIN_SUCCESS;
|
|
698
692
|
exports.AUDIO_STREAM_READY = AUDIO_STREAM_READY;
|
|
699
693
|
exports.Assistant = Assistant;
|
|
700
694
|
exports.AudioSink = AudioSink;
|
|
701
695
|
exports.AudioSource = AudioSource;
|
|
696
|
+
exports.TRIGGER_EVENT_SUCCESS = TRIGGER_EVENT_SUCCESS;
|
|
702
697
|
exports.Trigger = Trigger;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,53 +1,43 @@
|
|
|
1
|
+
import * as wrtc from '@roamhq/wrtc';
|
|
2
|
+
import wrtc__default from '@roamhq/wrtc';
|
|
1
3
|
import { RoomConnectionClient, RemoteParticipantState, ChatMessage } from '@whereby.com/core';
|
|
2
4
|
export { RemoteParticipantState } from '@whereby.com/core';
|
|
3
|
-
import wrtc from '@roamhq/wrtc';
|
|
4
5
|
import EventEmitter, { EventEmitter as EventEmitter$1 } from 'events';
|
|
5
6
|
import { PassThrough } from 'stream';
|
|
6
7
|
|
|
7
|
-
declare
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
startCloudRecording(): void;
|
|
37
|
-
stopCloudRecording(): void;
|
|
38
|
-
sendChatMessage(message: string): void;
|
|
39
|
-
spotlightParticipant(participantId: string): void;
|
|
40
|
-
removeSpotlight(participantId: string): void;
|
|
41
|
-
requestAudioEnable(participantId: string, enable: boolean): void;
|
|
42
|
-
requestVideoEnable(participantId: string, enable: boolean): void;
|
|
43
|
-
acceptWaitingParticipant(participantId: string): void;
|
|
44
|
-
rejectWaitingParticipant(participantId: string): void;
|
|
45
|
-
subscribeToRemoteParticipants(callback: (participants: RemoteParticipantState[]) => void): () => void;
|
|
46
|
-
subscribeToChatMessages(callback: (messages: ChatMessage[]) => void): () => void;
|
|
8
|
+
declare global {
|
|
9
|
+
interface MediaStream extends wrtc.MediaStream {
|
|
10
|
+
}
|
|
11
|
+
interface MediaStreamTrack extends wrtc.MediaStreamTrack {
|
|
12
|
+
}
|
|
13
|
+
interface RTCDataChannel extends wrtc.RTCDataChannel {
|
|
14
|
+
}
|
|
15
|
+
interface RTCDataChannelEvent extends wrtc.RTCDataChannelEvent {
|
|
16
|
+
}
|
|
17
|
+
interface RTCDtlsTransport extends wrtc.RTCDtlsTransport {
|
|
18
|
+
}
|
|
19
|
+
interface RTCIceCandidate extends wrtc.RTCIceCandidate {
|
|
20
|
+
}
|
|
21
|
+
interface RTCIceTransport extends wrtc.RTCIceTransport {
|
|
22
|
+
}
|
|
23
|
+
interface RTCPeerConnection extends wrtc.RTCPeerConnection {
|
|
24
|
+
}
|
|
25
|
+
interface RTCPeerConnectionIceEvent extends wrtc.RTCPeerConnectionIceEvent {
|
|
26
|
+
}
|
|
27
|
+
interface RTCRtpReceiver extends wrtc.RTCRtpReceiver {
|
|
28
|
+
}
|
|
29
|
+
interface RTCRtpSender extends wrtc.RTCRtpSender {
|
|
30
|
+
}
|
|
31
|
+
interface RTCRtpTransceiver extends wrtc.RTCRtpTransceiver {
|
|
32
|
+
}
|
|
33
|
+
interface RTCSctpTransport extends wrtc.RTCSctpTransport {
|
|
34
|
+
}
|
|
35
|
+
interface RTCSessionDescription extends wrtc.RTCSessionDescription {
|
|
36
|
+
}
|
|
47
37
|
}
|
|
48
38
|
|
|
49
39
|
type WebhookType = "room.client.joined" | "room.client.left" | "room.session.started" | "room.session.ended";
|
|
50
|
-
declare const
|
|
40
|
+
declare const TRIGGER_EVENT_SUCCESS = "trigger_event_success";
|
|
51
41
|
interface WherebyWebhookBase {
|
|
52
42
|
type: WebhookType;
|
|
53
43
|
apiVersion: "1.0";
|
|
@@ -85,10 +75,9 @@ interface WherebyWebhookRoomSessionEnded extends WherebyWebhookBase {
|
|
|
85
75
|
data: WherebyWebhookInRoom;
|
|
86
76
|
}
|
|
87
77
|
type TriggerEvents = {
|
|
88
|
-
[
|
|
78
|
+
[TRIGGER_EVENT_SUCCESS]: [{
|
|
89
79
|
roomUrl: string;
|
|
90
80
|
triggerWebhook: WherebyWebhookType;
|
|
91
|
-
assistant: Assistant;
|
|
92
81
|
}];
|
|
93
82
|
};
|
|
94
83
|
type WherebyWebhookType = WherebyWebhookRoomClientJoined | WherebyWebhookRoomClientLeft | WherebyWebhookRoomSessionStarted | WherebyWebhookRoomSessionEnded;
|
|
@@ -102,27 +91,63 @@ type WherebyWebhookTriggers = Partial<{
|
|
|
102
91
|
[Type in keyof WherebyWebhookTriggerTypes]: (data: WherebyWebhookTriggerTypes[Type]) => boolean;
|
|
103
92
|
}>;
|
|
104
93
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
94
|
+
declare const AUDIO_STREAM_READY = "AUDIO_STREAM_READY";
|
|
95
|
+
type AssistantEvents = {
|
|
96
|
+
[AUDIO_STREAM_READY]: [{
|
|
97
|
+
stream: MediaStream;
|
|
98
|
+
track: MediaStreamTrack;
|
|
99
|
+
}];
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
type AssistantOptions = {
|
|
108
103
|
assistantKey: string;
|
|
109
104
|
startCombinedAudioStream?: boolean;
|
|
110
105
|
startLocalMedia?: boolean;
|
|
106
|
+
};
|
|
107
|
+
declare class Assistant extends EventEmitter<AssistantEvents> {
|
|
108
|
+
private assistantKey;
|
|
109
|
+
private client;
|
|
110
|
+
private roomConnection;
|
|
111
|
+
private localMedia;
|
|
112
|
+
private mediaStream;
|
|
113
|
+
private audioSource;
|
|
114
|
+
private combinedStream;
|
|
115
|
+
constructor({ assistantKey, startCombinedAudioStream, startLocalMedia }: AssistantOptions);
|
|
116
|
+
joinRoom(roomUrl: string): Promise<void>;
|
|
117
|
+
startLocalMedia(): void;
|
|
118
|
+
getLocalMediaStream(): MediaStream | null;
|
|
119
|
+
getLocalAudioSource(): wrtc__default.nonstandard.RTCAudioSource | null;
|
|
120
|
+
getRoomConnection(): RoomConnectionClient;
|
|
121
|
+
getCombinedAudioStream(): MediaStream | null;
|
|
122
|
+
getRemoteParticipants(): RemoteParticipantState[];
|
|
123
|
+
startCloudRecording(): void;
|
|
124
|
+
stopCloudRecording(): void;
|
|
125
|
+
sendChatMessage(message: string): void;
|
|
126
|
+
spotlightParticipant(participantId: string): void;
|
|
127
|
+
removeSpotlight(participantId: string): void;
|
|
128
|
+
requestAudioEnable(participantId: string, enable: boolean): void;
|
|
129
|
+
requestVideoEnable(participantId: string, enable: boolean): void;
|
|
130
|
+
acceptWaitingParticipant(participantId: string): void;
|
|
131
|
+
rejectWaitingParticipant(participantId: string): void;
|
|
132
|
+
subscribeToRemoteParticipants(callback: (participants: RemoteParticipantState[]) => void): () => void;
|
|
133
|
+
subscribeToChatMessages(callback: (messages: ChatMessage[]) => void): () => void;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
interface TriggerOptions {
|
|
137
|
+
webhookTriggers: WherebyWebhookTriggers;
|
|
138
|
+
port?: number;
|
|
111
139
|
}
|
|
112
140
|
declare class Trigger extends EventEmitter$1<TriggerEvents> {
|
|
113
141
|
private webhookTriggers;
|
|
114
142
|
private port;
|
|
115
|
-
|
|
116
|
-
private startCombinedAudioStream;
|
|
117
|
-
private startLocalMedia;
|
|
118
|
-
constructor({ webhookTriggers, port, assistantKey, startCombinedAudioStream, startLocalMedia, }: TriggerOptions);
|
|
143
|
+
constructor({ webhookTriggers, port }: TriggerOptions);
|
|
119
144
|
start(): void;
|
|
120
145
|
}
|
|
121
146
|
|
|
122
147
|
declare class AudioSource extends PassThrough {
|
|
123
148
|
constructor();
|
|
124
149
|
}
|
|
125
|
-
declare class AudioSink extends
|
|
150
|
+
declare class AudioSink extends wrtc__default.nonstandard.RTCAudioSink {
|
|
126
151
|
private _sink;
|
|
127
152
|
constructor(track: MediaStreamTrack);
|
|
128
153
|
subscribe(cb: (d: {
|
|
@@ -134,4 +159,4 @@ declare class AudioSink extends wrtc.nonstandard.RTCAudioSink {
|
|
|
134
159
|
}) => void): () => void;
|
|
135
160
|
}
|
|
136
161
|
|
|
137
|
-
export {
|
|
162
|
+
export { AUDIO_STREAM_READY, Assistant, AudioSink, AudioSource, TRIGGER_EVENT_SUCCESS, Trigger };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,53 +1,43 @@
|
|
|
1
|
+
import * as wrtc from '@roamhq/wrtc';
|
|
2
|
+
import wrtc__default from '@roamhq/wrtc';
|
|
1
3
|
import { RoomConnectionClient, RemoteParticipantState, ChatMessage } from '@whereby.com/core';
|
|
2
4
|
export { RemoteParticipantState } from '@whereby.com/core';
|
|
3
|
-
import wrtc from '@roamhq/wrtc';
|
|
4
5
|
import EventEmitter, { EventEmitter as EventEmitter$1 } from 'events';
|
|
5
6
|
import { PassThrough } from 'stream';
|
|
6
7
|
|
|
7
|
-
declare
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
startCloudRecording(): void;
|
|
37
|
-
stopCloudRecording(): void;
|
|
38
|
-
sendChatMessage(message: string): void;
|
|
39
|
-
spotlightParticipant(participantId: string): void;
|
|
40
|
-
removeSpotlight(participantId: string): void;
|
|
41
|
-
requestAudioEnable(participantId: string, enable: boolean): void;
|
|
42
|
-
requestVideoEnable(participantId: string, enable: boolean): void;
|
|
43
|
-
acceptWaitingParticipant(participantId: string): void;
|
|
44
|
-
rejectWaitingParticipant(participantId: string): void;
|
|
45
|
-
subscribeToRemoteParticipants(callback: (participants: RemoteParticipantState[]) => void): () => void;
|
|
46
|
-
subscribeToChatMessages(callback: (messages: ChatMessage[]) => void): () => void;
|
|
8
|
+
declare global {
|
|
9
|
+
interface MediaStream extends wrtc.MediaStream {
|
|
10
|
+
}
|
|
11
|
+
interface MediaStreamTrack extends wrtc.MediaStreamTrack {
|
|
12
|
+
}
|
|
13
|
+
interface RTCDataChannel extends wrtc.RTCDataChannel {
|
|
14
|
+
}
|
|
15
|
+
interface RTCDataChannelEvent extends wrtc.RTCDataChannelEvent {
|
|
16
|
+
}
|
|
17
|
+
interface RTCDtlsTransport extends wrtc.RTCDtlsTransport {
|
|
18
|
+
}
|
|
19
|
+
interface RTCIceCandidate extends wrtc.RTCIceCandidate {
|
|
20
|
+
}
|
|
21
|
+
interface RTCIceTransport extends wrtc.RTCIceTransport {
|
|
22
|
+
}
|
|
23
|
+
interface RTCPeerConnection extends wrtc.RTCPeerConnection {
|
|
24
|
+
}
|
|
25
|
+
interface RTCPeerConnectionIceEvent extends wrtc.RTCPeerConnectionIceEvent {
|
|
26
|
+
}
|
|
27
|
+
interface RTCRtpReceiver extends wrtc.RTCRtpReceiver {
|
|
28
|
+
}
|
|
29
|
+
interface RTCRtpSender extends wrtc.RTCRtpSender {
|
|
30
|
+
}
|
|
31
|
+
interface RTCRtpTransceiver extends wrtc.RTCRtpTransceiver {
|
|
32
|
+
}
|
|
33
|
+
interface RTCSctpTransport extends wrtc.RTCSctpTransport {
|
|
34
|
+
}
|
|
35
|
+
interface RTCSessionDescription extends wrtc.RTCSessionDescription {
|
|
36
|
+
}
|
|
47
37
|
}
|
|
48
38
|
|
|
49
39
|
type WebhookType = "room.client.joined" | "room.client.left" | "room.session.started" | "room.session.ended";
|
|
50
|
-
declare const
|
|
40
|
+
declare const TRIGGER_EVENT_SUCCESS = "trigger_event_success";
|
|
51
41
|
interface WherebyWebhookBase {
|
|
52
42
|
type: WebhookType;
|
|
53
43
|
apiVersion: "1.0";
|
|
@@ -85,10 +75,9 @@ interface WherebyWebhookRoomSessionEnded extends WherebyWebhookBase {
|
|
|
85
75
|
data: WherebyWebhookInRoom;
|
|
86
76
|
}
|
|
87
77
|
type TriggerEvents = {
|
|
88
|
-
[
|
|
78
|
+
[TRIGGER_EVENT_SUCCESS]: [{
|
|
89
79
|
roomUrl: string;
|
|
90
80
|
triggerWebhook: WherebyWebhookType;
|
|
91
|
-
assistant: Assistant;
|
|
92
81
|
}];
|
|
93
82
|
};
|
|
94
83
|
type WherebyWebhookType = WherebyWebhookRoomClientJoined | WherebyWebhookRoomClientLeft | WherebyWebhookRoomSessionStarted | WherebyWebhookRoomSessionEnded;
|
|
@@ -102,27 +91,63 @@ type WherebyWebhookTriggers = Partial<{
|
|
|
102
91
|
[Type in keyof WherebyWebhookTriggerTypes]: (data: WherebyWebhookTriggerTypes[Type]) => boolean;
|
|
103
92
|
}>;
|
|
104
93
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
94
|
+
declare const AUDIO_STREAM_READY = "AUDIO_STREAM_READY";
|
|
95
|
+
type AssistantEvents = {
|
|
96
|
+
[AUDIO_STREAM_READY]: [{
|
|
97
|
+
stream: MediaStream;
|
|
98
|
+
track: MediaStreamTrack;
|
|
99
|
+
}];
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
type AssistantOptions = {
|
|
108
103
|
assistantKey: string;
|
|
109
104
|
startCombinedAudioStream?: boolean;
|
|
110
105
|
startLocalMedia?: boolean;
|
|
106
|
+
};
|
|
107
|
+
declare class Assistant extends EventEmitter<AssistantEvents> {
|
|
108
|
+
private assistantKey;
|
|
109
|
+
private client;
|
|
110
|
+
private roomConnection;
|
|
111
|
+
private localMedia;
|
|
112
|
+
private mediaStream;
|
|
113
|
+
private audioSource;
|
|
114
|
+
private combinedStream;
|
|
115
|
+
constructor({ assistantKey, startCombinedAudioStream, startLocalMedia }: AssistantOptions);
|
|
116
|
+
joinRoom(roomUrl: string): Promise<void>;
|
|
117
|
+
startLocalMedia(): void;
|
|
118
|
+
getLocalMediaStream(): MediaStream | null;
|
|
119
|
+
getLocalAudioSource(): wrtc__default.nonstandard.RTCAudioSource | null;
|
|
120
|
+
getRoomConnection(): RoomConnectionClient;
|
|
121
|
+
getCombinedAudioStream(): MediaStream | null;
|
|
122
|
+
getRemoteParticipants(): RemoteParticipantState[];
|
|
123
|
+
startCloudRecording(): void;
|
|
124
|
+
stopCloudRecording(): void;
|
|
125
|
+
sendChatMessage(message: string): void;
|
|
126
|
+
spotlightParticipant(participantId: string): void;
|
|
127
|
+
removeSpotlight(participantId: string): void;
|
|
128
|
+
requestAudioEnable(participantId: string, enable: boolean): void;
|
|
129
|
+
requestVideoEnable(participantId: string, enable: boolean): void;
|
|
130
|
+
acceptWaitingParticipant(participantId: string): void;
|
|
131
|
+
rejectWaitingParticipant(participantId: string): void;
|
|
132
|
+
subscribeToRemoteParticipants(callback: (participants: RemoteParticipantState[]) => void): () => void;
|
|
133
|
+
subscribeToChatMessages(callback: (messages: ChatMessage[]) => void): () => void;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
interface TriggerOptions {
|
|
137
|
+
webhookTriggers: WherebyWebhookTriggers;
|
|
138
|
+
port?: number;
|
|
111
139
|
}
|
|
112
140
|
declare class Trigger extends EventEmitter$1<TriggerEvents> {
|
|
113
141
|
private webhookTriggers;
|
|
114
142
|
private port;
|
|
115
|
-
|
|
116
|
-
private startCombinedAudioStream;
|
|
117
|
-
private startLocalMedia;
|
|
118
|
-
constructor({ webhookTriggers, port, assistantKey, startCombinedAudioStream, startLocalMedia, }: TriggerOptions);
|
|
143
|
+
constructor({ webhookTriggers, port }: TriggerOptions);
|
|
119
144
|
start(): void;
|
|
120
145
|
}
|
|
121
146
|
|
|
122
147
|
declare class AudioSource extends PassThrough {
|
|
123
148
|
constructor();
|
|
124
149
|
}
|
|
125
|
-
declare class AudioSink extends
|
|
150
|
+
declare class AudioSink extends wrtc__default.nonstandard.RTCAudioSink {
|
|
126
151
|
private _sink;
|
|
127
152
|
constructor(track: MediaStreamTrack);
|
|
128
153
|
subscribe(cb: (d: {
|
|
@@ -134,4 +159,4 @@ declare class AudioSink extends wrtc.nonstandard.RTCAudioSink {
|
|
|
134
159
|
}) => void): () => void;
|
|
135
160
|
}
|
|
136
161
|
|
|
137
|
-
export {
|
|
162
|
+
export { AUDIO_STREAM_READY, Assistant, AudioSink, AudioSource, TRIGGER_EVENT_SUCCESS, Trigger };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,53 +1,43 @@
|
|
|
1
|
+
import * as wrtc from '@roamhq/wrtc';
|
|
2
|
+
import wrtc__default from '@roamhq/wrtc';
|
|
1
3
|
import { RoomConnectionClient, RemoteParticipantState, ChatMessage } from '@whereby.com/core';
|
|
2
4
|
export { RemoteParticipantState } from '@whereby.com/core';
|
|
3
|
-
import wrtc from '@roamhq/wrtc';
|
|
4
5
|
import EventEmitter, { EventEmitter as EventEmitter$1 } from 'events';
|
|
5
6
|
import { PassThrough } from 'stream';
|
|
6
7
|
|
|
7
|
-
declare
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
startCloudRecording(): void;
|
|
37
|
-
stopCloudRecording(): void;
|
|
38
|
-
sendChatMessage(message: string): void;
|
|
39
|
-
spotlightParticipant(participantId: string): void;
|
|
40
|
-
removeSpotlight(participantId: string): void;
|
|
41
|
-
requestAudioEnable(participantId: string, enable: boolean): void;
|
|
42
|
-
requestVideoEnable(participantId: string, enable: boolean): void;
|
|
43
|
-
acceptWaitingParticipant(participantId: string): void;
|
|
44
|
-
rejectWaitingParticipant(participantId: string): void;
|
|
45
|
-
subscribeToRemoteParticipants(callback: (participants: RemoteParticipantState[]) => void): () => void;
|
|
46
|
-
subscribeToChatMessages(callback: (messages: ChatMessage[]) => void): () => void;
|
|
8
|
+
declare global {
|
|
9
|
+
interface MediaStream extends wrtc.MediaStream {
|
|
10
|
+
}
|
|
11
|
+
interface MediaStreamTrack extends wrtc.MediaStreamTrack {
|
|
12
|
+
}
|
|
13
|
+
interface RTCDataChannel extends wrtc.RTCDataChannel {
|
|
14
|
+
}
|
|
15
|
+
interface RTCDataChannelEvent extends wrtc.RTCDataChannelEvent {
|
|
16
|
+
}
|
|
17
|
+
interface RTCDtlsTransport extends wrtc.RTCDtlsTransport {
|
|
18
|
+
}
|
|
19
|
+
interface RTCIceCandidate extends wrtc.RTCIceCandidate {
|
|
20
|
+
}
|
|
21
|
+
interface RTCIceTransport extends wrtc.RTCIceTransport {
|
|
22
|
+
}
|
|
23
|
+
interface RTCPeerConnection extends wrtc.RTCPeerConnection {
|
|
24
|
+
}
|
|
25
|
+
interface RTCPeerConnectionIceEvent extends wrtc.RTCPeerConnectionIceEvent {
|
|
26
|
+
}
|
|
27
|
+
interface RTCRtpReceiver extends wrtc.RTCRtpReceiver {
|
|
28
|
+
}
|
|
29
|
+
interface RTCRtpSender extends wrtc.RTCRtpSender {
|
|
30
|
+
}
|
|
31
|
+
interface RTCRtpTransceiver extends wrtc.RTCRtpTransceiver {
|
|
32
|
+
}
|
|
33
|
+
interface RTCSctpTransport extends wrtc.RTCSctpTransport {
|
|
34
|
+
}
|
|
35
|
+
interface RTCSessionDescription extends wrtc.RTCSessionDescription {
|
|
36
|
+
}
|
|
47
37
|
}
|
|
48
38
|
|
|
49
39
|
type WebhookType = "room.client.joined" | "room.client.left" | "room.session.started" | "room.session.ended";
|
|
50
|
-
declare const
|
|
40
|
+
declare const TRIGGER_EVENT_SUCCESS = "trigger_event_success";
|
|
51
41
|
interface WherebyWebhookBase {
|
|
52
42
|
type: WebhookType;
|
|
53
43
|
apiVersion: "1.0";
|
|
@@ -85,10 +75,9 @@ interface WherebyWebhookRoomSessionEnded extends WherebyWebhookBase {
|
|
|
85
75
|
data: WherebyWebhookInRoom;
|
|
86
76
|
}
|
|
87
77
|
type TriggerEvents = {
|
|
88
|
-
[
|
|
78
|
+
[TRIGGER_EVENT_SUCCESS]: [{
|
|
89
79
|
roomUrl: string;
|
|
90
80
|
triggerWebhook: WherebyWebhookType;
|
|
91
|
-
assistant: Assistant;
|
|
92
81
|
}];
|
|
93
82
|
};
|
|
94
83
|
type WherebyWebhookType = WherebyWebhookRoomClientJoined | WherebyWebhookRoomClientLeft | WherebyWebhookRoomSessionStarted | WherebyWebhookRoomSessionEnded;
|
|
@@ -102,27 +91,63 @@ type WherebyWebhookTriggers = Partial<{
|
|
|
102
91
|
[Type in keyof WherebyWebhookTriggerTypes]: (data: WherebyWebhookTriggerTypes[Type]) => boolean;
|
|
103
92
|
}>;
|
|
104
93
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
94
|
+
declare const AUDIO_STREAM_READY = "AUDIO_STREAM_READY";
|
|
95
|
+
type AssistantEvents = {
|
|
96
|
+
[AUDIO_STREAM_READY]: [{
|
|
97
|
+
stream: MediaStream;
|
|
98
|
+
track: MediaStreamTrack;
|
|
99
|
+
}];
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
type AssistantOptions = {
|
|
108
103
|
assistantKey: string;
|
|
109
104
|
startCombinedAudioStream?: boolean;
|
|
110
105
|
startLocalMedia?: boolean;
|
|
106
|
+
};
|
|
107
|
+
declare class Assistant extends EventEmitter<AssistantEvents> {
|
|
108
|
+
private assistantKey;
|
|
109
|
+
private client;
|
|
110
|
+
private roomConnection;
|
|
111
|
+
private localMedia;
|
|
112
|
+
private mediaStream;
|
|
113
|
+
private audioSource;
|
|
114
|
+
private combinedStream;
|
|
115
|
+
constructor({ assistantKey, startCombinedAudioStream, startLocalMedia }: AssistantOptions);
|
|
116
|
+
joinRoom(roomUrl: string): Promise<void>;
|
|
117
|
+
startLocalMedia(): void;
|
|
118
|
+
getLocalMediaStream(): MediaStream | null;
|
|
119
|
+
getLocalAudioSource(): wrtc__default.nonstandard.RTCAudioSource | null;
|
|
120
|
+
getRoomConnection(): RoomConnectionClient;
|
|
121
|
+
getCombinedAudioStream(): MediaStream | null;
|
|
122
|
+
getRemoteParticipants(): RemoteParticipantState[];
|
|
123
|
+
startCloudRecording(): void;
|
|
124
|
+
stopCloudRecording(): void;
|
|
125
|
+
sendChatMessage(message: string): void;
|
|
126
|
+
spotlightParticipant(participantId: string): void;
|
|
127
|
+
removeSpotlight(participantId: string): void;
|
|
128
|
+
requestAudioEnable(participantId: string, enable: boolean): void;
|
|
129
|
+
requestVideoEnable(participantId: string, enable: boolean): void;
|
|
130
|
+
acceptWaitingParticipant(participantId: string): void;
|
|
131
|
+
rejectWaitingParticipant(participantId: string): void;
|
|
132
|
+
subscribeToRemoteParticipants(callback: (participants: RemoteParticipantState[]) => void): () => void;
|
|
133
|
+
subscribeToChatMessages(callback: (messages: ChatMessage[]) => void): () => void;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
interface TriggerOptions {
|
|
137
|
+
webhookTriggers: WherebyWebhookTriggers;
|
|
138
|
+
port?: number;
|
|
111
139
|
}
|
|
112
140
|
declare class Trigger extends EventEmitter$1<TriggerEvents> {
|
|
113
141
|
private webhookTriggers;
|
|
114
142
|
private port;
|
|
115
|
-
|
|
116
|
-
private startCombinedAudioStream;
|
|
117
|
-
private startLocalMedia;
|
|
118
|
-
constructor({ webhookTriggers, port, assistantKey, startCombinedAudioStream, startLocalMedia, }: TriggerOptions);
|
|
143
|
+
constructor({ webhookTriggers, port }: TriggerOptions);
|
|
119
144
|
start(): void;
|
|
120
145
|
}
|
|
121
146
|
|
|
122
147
|
declare class AudioSource extends PassThrough {
|
|
123
148
|
constructor();
|
|
124
149
|
}
|
|
125
|
-
declare class AudioSink extends
|
|
150
|
+
declare class AudioSink extends wrtc__default.nonstandard.RTCAudioSink {
|
|
126
151
|
private _sink;
|
|
127
152
|
constructor(track: MediaStreamTrack);
|
|
128
153
|
subscribe(cb: (d: {
|
|
@@ -134,4 +159,4 @@ declare class AudioSink extends wrtc.nonstandard.RTCAudioSink {
|
|
|
134
159
|
}) => void): () => void;
|
|
135
160
|
}
|
|
136
161
|
|
|
137
|
-
export {
|
|
162
|
+
export { AUDIO_STREAM_READY, Assistant, AudioSink, AudioSource, TRIGGER_EVENT_SUCCESS, Trigger };
|
package/dist/index.mjs
CHANGED
|
@@ -9,7 +9,7 @@ import bodyParser from 'body-parser';
|
|
|
9
9
|
import { networkInterfaces } from 'os';
|
|
10
10
|
import * as dotenv from 'dotenv';
|
|
11
11
|
|
|
12
|
-
const
|
|
12
|
+
const TRIGGER_EVENT_SUCCESS = "trigger_event_success";
|
|
13
13
|
|
|
14
14
|
const AUDIO_STREAM_READY = "AUDIO_STREAM_READY";
|
|
15
15
|
|
|
@@ -628,7 +628,7 @@ function buildRoomUrl(roomPath, wherebySubdomain, baseDomain = "whereby.com") {
|
|
|
628
628
|
return `https://${wherebyDomain}${roomPath}`;
|
|
629
629
|
}
|
|
630
630
|
|
|
631
|
-
const webhookRouter = (webhookTriggers, emitter
|
|
631
|
+
const webhookRouter = (webhookTriggers, emitter) => {
|
|
632
632
|
const router = express.Router();
|
|
633
633
|
const jsonParser = bodyParser.json();
|
|
634
634
|
router.get("/", (_, res) => {
|
|
@@ -642,9 +642,7 @@ const webhookRouter = (webhookTriggers, emitter, assistantKey, startCombinedAudi
|
|
|
642
642
|
const shouldTriggerOnReceivedWebhook = (_a = webhookTriggers[req.body.type]) === null || _a === void 0 ? void 0 : _a.call(webhookTriggers, req.body);
|
|
643
643
|
if (shouldTriggerOnReceivedWebhook) {
|
|
644
644
|
const roomUrl = buildRoomUrl(req.body.data.roomName, req.body.data.subdomain);
|
|
645
|
-
|
|
646
|
-
assistant.joinRoom(roomUrl);
|
|
647
|
-
emitter.emit(ASSISTANT_JOIN_SUCCESS, { roomUrl, triggerWebhook: req.body, assistant });
|
|
645
|
+
emitter.emit(TRIGGER_EVENT_SUCCESS, { roomUrl, triggerWebhook: req.body });
|
|
648
646
|
}
|
|
649
647
|
res.status(200);
|
|
650
648
|
res.end();
|
|
@@ -652,17 +650,14 @@ const webhookRouter = (webhookTriggers, emitter, assistantKey, startCombinedAudi
|
|
|
652
650
|
return router;
|
|
653
651
|
};
|
|
654
652
|
class Trigger extends EventEmitter {
|
|
655
|
-
constructor({ webhookTriggers = {}, port = 8080
|
|
653
|
+
constructor({ webhookTriggers = {}, port = 8080 }) {
|
|
656
654
|
super();
|
|
657
655
|
this.webhookTriggers = webhookTriggers;
|
|
658
656
|
this.port = port;
|
|
659
|
-
this.assistantKey = assistantKey;
|
|
660
|
-
this.startCombinedAudioStream = startCombinedAudioStream !== null && startCombinedAudioStream !== void 0 ? startCombinedAudioStream : false;
|
|
661
|
-
this.startLocalMedia = startLocalMedia !== null && startLocalMedia !== void 0 ? startLocalMedia : false;
|
|
662
657
|
}
|
|
663
658
|
start() {
|
|
664
659
|
const app = express();
|
|
665
|
-
const router = webhookRouter(this.webhookTriggers, this
|
|
660
|
+
const router = webhookRouter(this.webhookTriggers, this);
|
|
666
661
|
app.use(router);
|
|
667
662
|
const server = app.listen(this.port, () => {
|
|
668
663
|
// console.log(`Bot trigger server now running on port[${this.port}]`);
|
|
@@ -673,4 +668,4 @@ class Trigger extends EventEmitter {
|
|
|
673
668
|
}
|
|
674
669
|
}
|
|
675
670
|
|
|
676
|
-
export {
|
|
671
|
+
export { AUDIO_STREAM_READY, Assistant, AudioSink, AudioSource, TRIGGER_EVENT_SUCCESS, Trigger };
|
package/dist/legacy-esm.js
CHANGED
|
@@ -9,7 +9,7 @@ import bodyParser from 'body-parser';
|
|
|
9
9
|
import { networkInterfaces } from 'os';
|
|
10
10
|
import * as dotenv from 'dotenv';
|
|
11
11
|
|
|
12
|
-
const
|
|
12
|
+
const TRIGGER_EVENT_SUCCESS = "trigger_event_success";
|
|
13
13
|
|
|
14
14
|
const AUDIO_STREAM_READY = "AUDIO_STREAM_READY";
|
|
15
15
|
|
|
@@ -628,7 +628,7 @@ function buildRoomUrl(roomPath, wherebySubdomain, baseDomain = "whereby.com") {
|
|
|
628
628
|
return `https://${wherebyDomain}${roomPath}`;
|
|
629
629
|
}
|
|
630
630
|
|
|
631
|
-
const webhookRouter = (webhookTriggers, emitter
|
|
631
|
+
const webhookRouter = (webhookTriggers, emitter) => {
|
|
632
632
|
const router = express.Router();
|
|
633
633
|
const jsonParser = bodyParser.json();
|
|
634
634
|
router.get("/", (_, res) => {
|
|
@@ -642,9 +642,7 @@ const webhookRouter = (webhookTriggers, emitter, assistantKey, startCombinedAudi
|
|
|
642
642
|
const shouldTriggerOnReceivedWebhook = (_a = webhookTriggers[req.body.type]) === null || _a === void 0 ? void 0 : _a.call(webhookTriggers, req.body);
|
|
643
643
|
if (shouldTriggerOnReceivedWebhook) {
|
|
644
644
|
const roomUrl = buildRoomUrl(req.body.data.roomName, req.body.data.subdomain);
|
|
645
|
-
|
|
646
|
-
assistant.joinRoom(roomUrl);
|
|
647
|
-
emitter.emit(ASSISTANT_JOIN_SUCCESS, { roomUrl, triggerWebhook: req.body, assistant });
|
|
645
|
+
emitter.emit(TRIGGER_EVENT_SUCCESS, { roomUrl, triggerWebhook: req.body });
|
|
648
646
|
}
|
|
649
647
|
res.status(200);
|
|
650
648
|
res.end();
|
|
@@ -652,17 +650,14 @@ const webhookRouter = (webhookTriggers, emitter, assistantKey, startCombinedAudi
|
|
|
652
650
|
return router;
|
|
653
651
|
};
|
|
654
652
|
class Trigger extends EventEmitter {
|
|
655
|
-
constructor({ webhookTriggers = {}, port = 8080
|
|
653
|
+
constructor({ webhookTriggers = {}, port = 8080 }) {
|
|
656
654
|
super();
|
|
657
655
|
this.webhookTriggers = webhookTriggers;
|
|
658
656
|
this.port = port;
|
|
659
|
-
this.assistantKey = assistantKey;
|
|
660
|
-
this.startCombinedAudioStream = startCombinedAudioStream !== null && startCombinedAudioStream !== void 0 ? startCombinedAudioStream : false;
|
|
661
|
-
this.startLocalMedia = startLocalMedia !== null && startLocalMedia !== void 0 ? startLocalMedia : false;
|
|
662
657
|
}
|
|
663
658
|
start() {
|
|
664
659
|
const app = express();
|
|
665
|
-
const router = webhookRouter(this.webhookTriggers, this
|
|
660
|
+
const router = webhookRouter(this.webhookTriggers, this);
|
|
666
661
|
app.use(router);
|
|
667
662
|
const server = app.listen(this.port, () => {
|
|
668
663
|
// console.log(`Bot trigger server now running on port[${this.port}]`);
|
|
@@ -673,4 +668,4 @@ class Trigger extends EventEmitter {
|
|
|
673
668
|
}
|
|
674
669
|
}
|
|
675
670
|
|
|
676
|
-
export {
|
|
671
|
+
export { AUDIO_STREAM_READY, Assistant, AudioSink, AudioSource, TRIGGER_EVENT_SUCCESS, Trigger };
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@whereby.com/assistant-sdk",
|
|
3
3
|
"description": "Assistant SDK for whereby.com",
|
|
4
4
|
"author": "Whereby AS",
|
|
5
|
-
"version": "0.0.0-canary-
|
|
5
|
+
"version": "0.0.0-canary-20250916072551",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"files": [
|
|
8
8
|
"dist",
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
"dotenv": "^16.4.5",
|
|
64
64
|
"uuid": "^11.0.3",
|
|
65
65
|
"ws": "^8.18.0",
|
|
66
|
-
"@whereby.com/core": "0.0.0-canary-
|
|
66
|
+
"@whereby.com/core": "0.0.0-canary-20250916072551"
|
|
67
67
|
},
|
|
68
68
|
"prettier": "@whereby.com/prettier-config",
|
|
69
69
|
"scripts": {
|