@whereby.com/assistant-sdk 0.0.0-canary-20250912144626 → 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 +46 -53
- package/dist/index.d.mts +46 -53
- package/dist/index.d.ts +46 -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
|
@@ -36,50 +36,8 @@ declare global {
|
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
declare const AUDIO_STREAM_READY = "AUDIO_STREAM_READY";
|
|
40
|
-
type AssistantEvents = {
|
|
41
|
-
[AUDIO_STREAM_READY]: [{
|
|
42
|
-
stream: MediaStream;
|
|
43
|
-
track: MediaStreamTrack;
|
|
44
|
-
}];
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
type AssistantOptions = {
|
|
48
|
-
assistantKey: string;
|
|
49
|
-
startCombinedAudioStream?: boolean;
|
|
50
|
-
startLocalMedia?: boolean;
|
|
51
|
-
};
|
|
52
|
-
declare class Assistant extends EventEmitter<AssistantEvents> {
|
|
53
|
-
private assistantKey;
|
|
54
|
-
private client;
|
|
55
|
-
private roomConnection;
|
|
56
|
-
private localMedia;
|
|
57
|
-
private mediaStream;
|
|
58
|
-
private audioSource;
|
|
59
|
-
private combinedStream;
|
|
60
|
-
constructor({ assistantKey, startCombinedAudioStream, startLocalMedia }: AssistantOptions);
|
|
61
|
-
joinRoom(roomUrl: string): Promise<void>;
|
|
62
|
-
startLocalMedia(): void;
|
|
63
|
-
getLocalMediaStream(): MediaStream | null;
|
|
64
|
-
getLocalAudioSource(): wrtc__default.nonstandard.RTCAudioSource | null;
|
|
65
|
-
getRoomConnection(): RoomConnectionClient;
|
|
66
|
-
getCombinedAudioStream(): MediaStream | null;
|
|
67
|
-
getRemoteParticipants(): RemoteParticipantState[];
|
|
68
|
-
startCloudRecording(): void;
|
|
69
|
-
stopCloudRecording(): void;
|
|
70
|
-
sendChatMessage(message: string): void;
|
|
71
|
-
spotlightParticipant(participantId: string): void;
|
|
72
|
-
removeSpotlight(participantId: string): void;
|
|
73
|
-
requestAudioEnable(participantId: string, enable: boolean): void;
|
|
74
|
-
requestVideoEnable(participantId: string, enable: boolean): void;
|
|
75
|
-
acceptWaitingParticipant(participantId: string): void;
|
|
76
|
-
rejectWaitingParticipant(participantId: string): void;
|
|
77
|
-
subscribeToRemoteParticipants(callback: (participants: RemoteParticipantState[]) => void): () => void;
|
|
78
|
-
subscribeToChatMessages(callback: (messages: ChatMessage[]) => void): () => void;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
39
|
type WebhookType = "room.client.joined" | "room.client.left" | "room.session.started" | "room.session.ended";
|
|
82
|
-
declare const
|
|
40
|
+
declare const TRIGGER_EVENT_SUCCESS = "trigger_event_success";
|
|
83
41
|
interface WherebyWebhookBase {
|
|
84
42
|
type: WebhookType;
|
|
85
43
|
apiVersion: "1.0";
|
|
@@ -117,10 +75,9 @@ interface WherebyWebhookRoomSessionEnded extends WherebyWebhookBase {
|
|
|
117
75
|
data: WherebyWebhookInRoom;
|
|
118
76
|
}
|
|
119
77
|
type TriggerEvents = {
|
|
120
|
-
[
|
|
78
|
+
[TRIGGER_EVENT_SUCCESS]: [{
|
|
121
79
|
roomUrl: string;
|
|
122
80
|
triggerWebhook: WherebyWebhookType;
|
|
123
|
-
assistant: Assistant;
|
|
124
81
|
}];
|
|
125
82
|
};
|
|
126
83
|
type WherebyWebhookType = WherebyWebhookRoomClientJoined | WherebyWebhookRoomClientLeft | WherebyWebhookRoomSessionStarted | WherebyWebhookRoomSessionEnded;
|
|
@@ -134,20 +91,56 @@ type WherebyWebhookTriggers = Partial<{
|
|
|
134
91
|
[Type in keyof WherebyWebhookTriggerTypes]: (data: WherebyWebhookTriggerTypes[Type]) => boolean;
|
|
135
92
|
}>;
|
|
136
93
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
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 = {
|
|
140
103
|
assistantKey: string;
|
|
141
104
|
startCombinedAudioStream?: boolean;
|
|
142
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;
|
|
143
139
|
}
|
|
144
140
|
declare class Trigger extends EventEmitter$1<TriggerEvents> {
|
|
145
141
|
private webhookTriggers;
|
|
146
142
|
private port;
|
|
147
|
-
|
|
148
|
-
private startCombinedAudioStream;
|
|
149
|
-
private startLocalMedia;
|
|
150
|
-
constructor({ webhookTriggers, port, assistantKey, startCombinedAudioStream, startLocalMedia, }: TriggerOptions);
|
|
143
|
+
constructor({ webhookTriggers, port }: TriggerOptions);
|
|
151
144
|
start(): void;
|
|
152
145
|
}
|
|
153
146
|
|
|
@@ -166,4 +159,4 @@ declare class AudioSink extends wrtc__default.nonstandard.RTCAudioSink {
|
|
|
166
159
|
}) => void): () => void;
|
|
167
160
|
}
|
|
168
161
|
|
|
169
|
-
export {
|
|
162
|
+
export { AUDIO_STREAM_READY, Assistant, AudioSink, AudioSource, TRIGGER_EVENT_SUCCESS, Trigger };
|
package/dist/index.d.mts
CHANGED
|
@@ -36,50 +36,8 @@ declare global {
|
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
declare const AUDIO_STREAM_READY = "AUDIO_STREAM_READY";
|
|
40
|
-
type AssistantEvents = {
|
|
41
|
-
[AUDIO_STREAM_READY]: [{
|
|
42
|
-
stream: MediaStream;
|
|
43
|
-
track: MediaStreamTrack;
|
|
44
|
-
}];
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
type AssistantOptions = {
|
|
48
|
-
assistantKey: string;
|
|
49
|
-
startCombinedAudioStream?: boolean;
|
|
50
|
-
startLocalMedia?: boolean;
|
|
51
|
-
};
|
|
52
|
-
declare class Assistant extends EventEmitter<AssistantEvents> {
|
|
53
|
-
private assistantKey;
|
|
54
|
-
private client;
|
|
55
|
-
private roomConnection;
|
|
56
|
-
private localMedia;
|
|
57
|
-
private mediaStream;
|
|
58
|
-
private audioSource;
|
|
59
|
-
private combinedStream;
|
|
60
|
-
constructor({ assistantKey, startCombinedAudioStream, startLocalMedia }: AssistantOptions);
|
|
61
|
-
joinRoom(roomUrl: string): Promise<void>;
|
|
62
|
-
startLocalMedia(): void;
|
|
63
|
-
getLocalMediaStream(): MediaStream | null;
|
|
64
|
-
getLocalAudioSource(): wrtc__default.nonstandard.RTCAudioSource | null;
|
|
65
|
-
getRoomConnection(): RoomConnectionClient;
|
|
66
|
-
getCombinedAudioStream(): MediaStream | null;
|
|
67
|
-
getRemoteParticipants(): RemoteParticipantState[];
|
|
68
|
-
startCloudRecording(): void;
|
|
69
|
-
stopCloudRecording(): void;
|
|
70
|
-
sendChatMessage(message: string): void;
|
|
71
|
-
spotlightParticipant(participantId: string): void;
|
|
72
|
-
removeSpotlight(participantId: string): void;
|
|
73
|
-
requestAudioEnable(participantId: string, enable: boolean): void;
|
|
74
|
-
requestVideoEnable(participantId: string, enable: boolean): void;
|
|
75
|
-
acceptWaitingParticipant(participantId: string): void;
|
|
76
|
-
rejectWaitingParticipant(participantId: string): void;
|
|
77
|
-
subscribeToRemoteParticipants(callback: (participants: RemoteParticipantState[]) => void): () => void;
|
|
78
|
-
subscribeToChatMessages(callback: (messages: ChatMessage[]) => void): () => void;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
39
|
type WebhookType = "room.client.joined" | "room.client.left" | "room.session.started" | "room.session.ended";
|
|
82
|
-
declare const
|
|
40
|
+
declare const TRIGGER_EVENT_SUCCESS = "trigger_event_success";
|
|
83
41
|
interface WherebyWebhookBase {
|
|
84
42
|
type: WebhookType;
|
|
85
43
|
apiVersion: "1.0";
|
|
@@ -117,10 +75,9 @@ interface WherebyWebhookRoomSessionEnded extends WherebyWebhookBase {
|
|
|
117
75
|
data: WherebyWebhookInRoom;
|
|
118
76
|
}
|
|
119
77
|
type TriggerEvents = {
|
|
120
|
-
[
|
|
78
|
+
[TRIGGER_EVENT_SUCCESS]: [{
|
|
121
79
|
roomUrl: string;
|
|
122
80
|
triggerWebhook: WherebyWebhookType;
|
|
123
|
-
assistant: Assistant;
|
|
124
81
|
}];
|
|
125
82
|
};
|
|
126
83
|
type WherebyWebhookType = WherebyWebhookRoomClientJoined | WherebyWebhookRoomClientLeft | WherebyWebhookRoomSessionStarted | WherebyWebhookRoomSessionEnded;
|
|
@@ -134,20 +91,56 @@ type WherebyWebhookTriggers = Partial<{
|
|
|
134
91
|
[Type in keyof WherebyWebhookTriggerTypes]: (data: WherebyWebhookTriggerTypes[Type]) => boolean;
|
|
135
92
|
}>;
|
|
136
93
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
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 = {
|
|
140
103
|
assistantKey: string;
|
|
141
104
|
startCombinedAudioStream?: boolean;
|
|
142
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;
|
|
143
139
|
}
|
|
144
140
|
declare class Trigger extends EventEmitter$1<TriggerEvents> {
|
|
145
141
|
private webhookTriggers;
|
|
146
142
|
private port;
|
|
147
|
-
|
|
148
|
-
private startCombinedAudioStream;
|
|
149
|
-
private startLocalMedia;
|
|
150
|
-
constructor({ webhookTriggers, port, assistantKey, startCombinedAudioStream, startLocalMedia, }: TriggerOptions);
|
|
143
|
+
constructor({ webhookTriggers, port }: TriggerOptions);
|
|
151
144
|
start(): void;
|
|
152
145
|
}
|
|
153
146
|
|
|
@@ -166,4 +159,4 @@ declare class AudioSink extends wrtc__default.nonstandard.RTCAudioSink {
|
|
|
166
159
|
}) => void): () => void;
|
|
167
160
|
}
|
|
168
161
|
|
|
169
|
-
export {
|
|
162
|
+
export { AUDIO_STREAM_READY, Assistant, AudioSink, AudioSource, TRIGGER_EVENT_SUCCESS, Trigger };
|
package/dist/index.d.ts
CHANGED
|
@@ -36,50 +36,8 @@ declare global {
|
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
declare const AUDIO_STREAM_READY = "AUDIO_STREAM_READY";
|
|
40
|
-
type AssistantEvents = {
|
|
41
|
-
[AUDIO_STREAM_READY]: [{
|
|
42
|
-
stream: MediaStream;
|
|
43
|
-
track: MediaStreamTrack;
|
|
44
|
-
}];
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
type AssistantOptions = {
|
|
48
|
-
assistantKey: string;
|
|
49
|
-
startCombinedAudioStream?: boolean;
|
|
50
|
-
startLocalMedia?: boolean;
|
|
51
|
-
};
|
|
52
|
-
declare class Assistant extends EventEmitter<AssistantEvents> {
|
|
53
|
-
private assistantKey;
|
|
54
|
-
private client;
|
|
55
|
-
private roomConnection;
|
|
56
|
-
private localMedia;
|
|
57
|
-
private mediaStream;
|
|
58
|
-
private audioSource;
|
|
59
|
-
private combinedStream;
|
|
60
|
-
constructor({ assistantKey, startCombinedAudioStream, startLocalMedia }: AssistantOptions);
|
|
61
|
-
joinRoom(roomUrl: string): Promise<void>;
|
|
62
|
-
startLocalMedia(): void;
|
|
63
|
-
getLocalMediaStream(): MediaStream | null;
|
|
64
|
-
getLocalAudioSource(): wrtc__default.nonstandard.RTCAudioSource | null;
|
|
65
|
-
getRoomConnection(): RoomConnectionClient;
|
|
66
|
-
getCombinedAudioStream(): MediaStream | null;
|
|
67
|
-
getRemoteParticipants(): RemoteParticipantState[];
|
|
68
|
-
startCloudRecording(): void;
|
|
69
|
-
stopCloudRecording(): void;
|
|
70
|
-
sendChatMessage(message: string): void;
|
|
71
|
-
spotlightParticipant(participantId: string): void;
|
|
72
|
-
removeSpotlight(participantId: string): void;
|
|
73
|
-
requestAudioEnable(participantId: string, enable: boolean): void;
|
|
74
|
-
requestVideoEnable(participantId: string, enable: boolean): void;
|
|
75
|
-
acceptWaitingParticipant(participantId: string): void;
|
|
76
|
-
rejectWaitingParticipant(participantId: string): void;
|
|
77
|
-
subscribeToRemoteParticipants(callback: (participants: RemoteParticipantState[]) => void): () => void;
|
|
78
|
-
subscribeToChatMessages(callback: (messages: ChatMessage[]) => void): () => void;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
39
|
type WebhookType = "room.client.joined" | "room.client.left" | "room.session.started" | "room.session.ended";
|
|
82
|
-
declare const
|
|
40
|
+
declare const TRIGGER_EVENT_SUCCESS = "trigger_event_success";
|
|
83
41
|
interface WherebyWebhookBase {
|
|
84
42
|
type: WebhookType;
|
|
85
43
|
apiVersion: "1.0";
|
|
@@ -117,10 +75,9 @@ interface WherebyWebhookRoomSessionEnded extends WherebyWebhookBase {
|
|
|
117
75
|
data: WherebyWebhookInRoom;
|
|
118
76
|
}
|
|
119
77
|
type TriggerEvents = {
|
|
120
|
-
[
|
|
78
|
+
[TRIGGER_EVENT_SUCCESS]: [{
|
|
121
79
|
roomUrl: string;
|
|
122
80
|
triggerWebhook: WherebyWebhookType;
|
|
123
|
-
assistant: Assistant;
|
|
124
81
|
}];
|
|
125
82
|
};
|
|
126
83
|
type WherebyWebhookType = WherebyWebhookRoomClientJoined | WherebyWebhookRoomClientLeft | WherebyWebhookRoomSessionStarted | WherebyWebhookRoomSessionEnded;
|
|
@@ -134,20 +91,56 @@ type WherebyWebhookTriggers = Partial<{
|
|
|
134
91
|
[Type in keyof WherebyWebhookTriggerTypes]: (data: WherebyWebhookTriggerTypes[Type]) => boolean;
|
|
135
92
|
}>;
|
|
136
93
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
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 = {
|
|
140
103
|
assistantKey: string;
|
|
141
104
|
startCombinedAudioStream?: boolean;
|
|
142
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;
|
|
143
139
|
}
|
|
144
140
|
declare class Trigger extends EventEmitter$1<TriggerEvents> {
|
|
145
141
|
private webhookTriggers;
|
|
146
142
|
private port;
|
|
147
|
-
|
|
148
|
-
private startCombinedAudioStream;
|
|
149
|
-
private startLocalMedia;
|
|
150
|
-
constructor({ webhookTriggers, port, assistantKey, startCombinedAudioStream, startLocalMedia, }: TriggerOptions);
|
|
143
|
+
constructor({ webhookTriggers, port }: TriggerOptions);
|
|
151
144
|
start(): void;
|
|
152
145
|
}
|
|
153
146
|
|
|
@@ -166,4 +159,4 @@ declare class AudioSink extends wrtc__default.nonstandard.RTCAudioSink {
|
|
|
166
159
|
}) => void): () => void;
|
|
167
160
|
}
|
|
168
161
|
|
|
169
|
-
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": {
|