@fishjam-cloud/js-server-sdk 0.22.0 → 0.23.0
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-6DZX6EAA.mjs +37 -0
- package/dist/index.d.mts +27 -5
- package/dist/index.d.ts +27 -5
- package/dist/index.js +43 -6
- package/dist/index.mjs +73 -62
- package/dist/integrations/gemini.d.mts +39 -0
- package/dist/integrations/gemini.d.ts +39 -0
- package/dist/integrations/gemini.js +154 -0
- package/dist/integrations/gemini.mjs +135 -0
- package/package.json +14 -4
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
8
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
9
|
+
}) : x)(function(x) {
|
|
10
|
+
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
11
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
12
|
+
});
|
|
13
|
+
var __commonJS = (cb, mod) => function __require2() {
|
|
14
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
15
|
+
};
|
|
16
|
+
var __copyProps = (to, from, except, desc) => {
|
|
17
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
18
|
+
for (let key of __getOwnPropNames(from))
|
|
19
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
20
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
21
|
+
}
|
|
22
|
+
return to;
|
|
23
|
+
};
|
|
24
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
25
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
26
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
27
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
28
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
29
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
30
|
+
mod
|
|
31
|
+
));
|
|
32
|
+
|
|
33
|
+
export {
|
|
34
|
+
__require,
|
|
35
|
+
__commonJS,
|
|
36
|
+
__toESM
|
|
37
|
+
};
|
package/dist/index.d.mts
CHANGED
|
@@ -643,6 +643,10 @@ type FishjamConfig = {
|
|
|
643
643
|
};
|
|
644
644
|
type ErrorEventHandler = (msg: Event) => void;
|
|
645
645
|
type CloseEventHandler = (code: number, reason: string) => void;
|
|
646
|
+
type AgentCallbacks = {
|
|
647
|
+
onError?: ErrorEventHandler;
|
|
648
|
+
onClose?: CloseEventHandler;
|
|
649
|
+
};
|
|
646
650
|
|
|
647
651
|
type WithRoomId<T> = {
|
|
648
652
|
[P in keyof T]: NonNullable<T[P]> extends {
|
|
@@ -713,7 +717,9 @@ type IncomingTrackData = Omit<NonNullable<AgentResponse_TrackData>, 'peerId'> &
|
|
|
713
717
|
type OutgoingTrackData = Omit<NonNullable<AgentRequest_TrackData>, 'peerId'> & {
|
|
714
718
|
peerId: PeerId;
|
|
715
719
|
};
|
|
716
|
-
type AgentTrack = Track
|
|
720
|
+
type AgentTrack = Omit<Track, 'id'> & {
|
|
721
|
+
id: TrackId;
|
|
722
|
+
};
|
|
717
723
|
type TrackType = 'audio' | 'video';
|
|
718
724
|
type AudioCodecParameters = {
|
|
719
725
|
encoding: 'opus' | 'pcm16';
|
|
@@ -731,12 +737,27 @@ type AgentEvents = {
|
|
|
731
737
|
declare const FishjamAgent_base: new () => TypedEventEmitter<AgentEvents>;
|
|
732
738
|
declare class FishjamAgent extends FishjamAgent_base {
|
|
733
739
|
private readonly client;
|
|
734
|
-
|
|
740
|
+
private resolveConnectionPromise;
|
|
741
|
+
private readonly connectionPromise;
|
|
742
|
+
constructor(config: FishjamConfig, agentToken: string, callbacks?: AgentCallbacks);
|
|
743
|
+
/**
|
|
744
|
+
* Await Agent connection to Fishjam.
|
|
745
|
+
*/
|
|
746
|
+
awaitConnected(): Promise<void>;
|
|
735
747
|
/**
|
|
736
748
|
* Creates an outgoing audio track for the agent
|
|
737
749
|
* @returns a new audio track
|
|
738
750
|
*/
|
|
739
751
|
createTrack(codecParameters: AudioCodecParameters, metadata?: object): AgentTrack;
|
|
752
|
+
/**
|
|
753
|
+
* Interrupt track indentified by `trackId`.
|
|
754
|
+
*
|
|
755
|
+
* Any audio that has been sent by the agent, but not played
|
|
756
|
+
* by Fishjam will be cleared and be prevented from playing.
|
|
757
|
+
*
|
|
758
|
+
* Audio sent after the interrupt will be played normally.
|
|
759
|
+
*/
|
|
760
|
+
interruptTrack(trackId: TrackId): void;
|
|
740
761
|
/**
|
|
741
762
|
* Deletes an outgoing audio track for the agent
|
|
742
763
|
*/
|
|
@@ -745,6 +766,7 @@ declare class FishjamAgent extends FishjamAgent_base {
|
|
|
745
766
|
* Send audio data for the given track
|
|
746
767
|
*/
|
|
747
768
|
sendData(trackId: TrackId, data: Uint8Array): void;
|
|
769
|
+
disconnect(): void;
|
|
748
770
|
private dispatchNotification;
|
|
749
771
|
private setupConnection;
|
|
750
772
|
private isExpectedEvent;
|
|
@@ -787,14 +809,14 @@ declare class FishjamClient {
|
|
|
787
809
|
/**
|
|
788
810
|
* Create a new peer assigned to a room.
|
|
789
811
|
*/
|
|
790
|
-
createPeer(roomId: RoomId, options?:
|
|
812
|
+
createPeer(roomId: RoomId, options?: PeerOptionsWebRTC): Promise<{
|
|
791
813
|
peer: Peer;
|
|
792
814
|
peerToken: string;
|
|
793
815
|
}>;
|
|
794
816
|
/**
|
|
795
817
|
* Create a new agent assigned to a room.
|
|
796
818
|
*/
|
|
797
|
-
createAgent(roomId: RoomId, options
|
|
819
|
+
createAgent(roomId: RoomId, options?: PeerOptionsAgent, callbacks?: AgentCallbacks): Promise<{
|
|
798
820
|
agent: FishjamAgent;
|
|
799
821
|
peer: Peer;
|
|
800
822
|
}>;
|
|
@@ -860,4 +882,4 @@ declare class ServiceUnavailableException extends FishjamBaseException {
|
|
|
860
882
|
declare class UnknownException extends FishjamBaseException {
|
|
861
883
|
}
|
|
862
884
|
|
|
863
|
-
export { type AgentEvents, type AgentTrack, type AudioCodecParameters, BadRequestException, type Brand, type CloseEventHandler, type ErrorEventHandler, type ExpectedAgentEvents, type ExpectedEvents, FishjamAgent, FishjamBaseException, FishjamClient, type FishjamConfig, FishjamNotFoundException, FishjamWSNotifier, ForbiddenException, type IncomingTrackData, MissingFishjamIdException, type NotificationEvents, type OutgoingTrackData, type Peer, type PeerAdded, type PeerConnected, type PeerCrashed, type PeerDeleted, type PeerDisconnected, type PeerId, type PeerMetadataUpdated, PeerNotFoundException, type PeerOptions, PeerStatus, type Room, type RoomConfig, RoomConfigRoomTypeEnum, RoomConfigVideoCodecEnum, type RoomCrashed, type RoomCreated, type RoomDeleted, type RoomId, RoomNotFoundException, ServerMessage, ServiceUnavailableException, type StreamConnected, type StreamDisconnected, type StreamerToken, type TrackAdded, type TrackId, type TrackMetadataUpdated, type TrackRemoved, type TrackType, UnauthorizedException, UnknownException, type ViewerConnected, type ViewerDisconnected, type ViewerToken };
|
|
885
|
+
export { type AgentCallbacks, type AgentEvents, type AgentTrack, type AudioCodecParameters, BadRequestException, type Brand, type CloseEventHandler, type ErrorEventHandler, type ExpectedAgentEvents, type ExpectedEvents, FishjamAgent, FishjamBaseException, FishjamClient, type FishjamConfig, FishjamNotFoundException, FishjamWSNotifier, ForbiddenException, type IncomingTrackData, MissingFishjamIdException, type NotificationEvents, type OutgoingTrackData, type Peer, type PeerAdded, type PeerConnected, type PeerCrashed, type PeerDeleted, type PeerDisconnected, type PeerId, type PeerMetadataUpdated, PeerNotFoundException, type PeerOptions, type PeerOptionsAgent, type PeerOptionsWebRTC, PeerStatus, type Room, type RoomConfig, RoomConfigRoomTypeEnum, RoomConfigVideoCodecEnum, type RoomCrashed, type RoomCreated, type RoomDeleted, type RoomId, RoomNotFoundException, ServerMessage, ServiceUnavailableException, type StreamConnected, type StreamDisconnected, type StreamerToken, type TrackAdded, type TrackId, type TrackMetadataUpdated, type TrackRemoved, type TrackType, UnauthorizedException, UnknownException, type ViewerConnected, type ViewerDisconnected, type ViewerToken };
|
package/dist/index.d.ts
CHANGED
|
@@ -643,6 +643,10 @@ type FishjamConfig = {
|
|
|
643
643
|
};
|
|
644
644
|
type ErrorEventHandler = (msg: Event) => void;
|
|
645
645
|
type CloseEventHandler = (code: number, reason: string) => void;
|
|
646
|
+
type AgentCallbacks = {
|
|
647
|
+
onError?: ErrorEventHandler;
|
|
648
|
+
onClose?: CloseEventHandler;
|
|
649
|
+
};
|
|
646
650
|
|
|
647
651
|
type WithRoomId<T> = {
|
|
648
652
|
[P in keyof T]: NonNullable<T[P]> extends {
|
|
@@ -713,7 +717,9 @@ type IncomingTrackData = Omit<NonNullable<AgentResponse_TrackData>, 'peerId'> &
|
|
|
713
717
|
type OutgoingTrackData = Omit<NonNullable<AgentRequest_TrackData>, 'peerId'> & {
|
|
714
718
|
peerId: PeerId;
|
|
715
719
|
};
|
|
716
|
-
type AgentTrack = Track
|
|
720
|
+
type AgentTrack = Omit<Track, 'id'> & {
|
|
721
|
+
id: TrackId;
|
|
722
|
+
};
|
|
717
723
|
type TrackType = 'audio' | 'video';
|
|
718
724
|
type AudioCodecParameters = {
|
|
719
725
|
encoding: 'opus' | 'pcm16';
|
|
@@ -731,12 +737,27 @@ type AgentEvents = {
|
|
|
731
737
|
declare const FishjamAgent_base: new () => TypedEventEmitter<AgentEvents>;
|
|
732
738
|
declare class FishjamAgent extends FishjamAgent_base {
|
|
733
739
|
private readonly client;
|
|
734
|
-
|
|
740
|
+
private resolveConnectionPromise;
|
|
741
|
+
private readonly connectionPromise;
|
|
742
|
+
constructor(config: FishjamConfig, agentToken: string, callbacks?: AgentCallbacks);
|
|
743
|
+
/**
|
|
744
|
+
* Await Agent connection to Fishjam.
|
|
745
|
+
*/
|
|
746
|
+
awaitConnected(): Promise<void>;
|
|
735
747
|
/**
|
|
736
748
|
* Creates an outgoing audio track for the agent
|
|
737
749
|
* @returns a new audio track
|
|
738
750
|
*/
|
|
739
751
|
createTrack(codecParameters: AudioCodecParameters, metadata?: object): AgentTrack;
|
|
752
|
+
/**
|
|
753
|
+
* Interrupt track indentified by `trackId`.
|
|
754
|
+
*
|
|
755
|
+
* Any audio that has been sent by the agent, but not played
|
|
756
|
+
* by Fishjam will be cleared and be prevented from playing.
|
|
757
|
+
*
|
|
758
|
+
* Audio sent after the interrupt will be played normally.
|
|
759
|
+
*/
|
|
760
|
+
interruptTrack(trackId: TrackId): void;
|
|
740
761
|
/**
|
|
741
762
|
* Deletes an outgoing audio track for the agent
|
|
742
763
|
*/
|
|
@@ -745,6 +766,7 @@ declare class FishjamAgent extends FishjamAgent_base {
|
|
|
745
766
|
* Send audio data for the given track
|
|
746
767
|
*/
|
|
747
768
|
sendData(trackId: TrackId, data: Uint8Array): void;
|
|
769
|
+
disconnect(): void;
|
|
748
770
|
private dispatchNotification;
|
|
749
771
|
private setupConnection;
|
|
750
772
|
private isExpectedEvent;
|
|
@@ -787,14 +809,14 @@ declare class FishjamClient {
|
|
|
787
809
|
/**
|
|
788
810
|
* Create a new peer assigned to a room.
|
|
789
811
|
*/
|
|
790
|
-
createPeer(roomId: RoomId, options?:
|
|
812
|
+
createPeer(roomId: RoomId, options?: PeerOptionsWebRTC): Promise<{
|
|
791
813
|
peer: Peer;
|
|
792
814
|
peerToken: string;
|
|
793
815
|
}>;
|
|
794
816
|
/**
|
|
795
817
|
* Create a new agent assigned to a room.
|
|
796
818
|
*/
|
|
797
|
-
createAgent(roomId: RoomId, options
|
|
819
|
+
createAgent(roomId: RoomId, options?: PeerOptionsAgent, callbacks?: AgentCallbacks): Promise<{
|
|
798
820
|
agent: FishjamAgent;
|
|
799
821
|
peer: Peer;
|
|
800
822
|
}>;
|
|
@@ -860,4 +882,4 @@ declare class ServiceUnavailableException extends FishjamBaseException {
|
|
|
860
882
|
declare class UnknownException extends FishjamBaseException {
|
|
861
883
|
}
|
|
862
884
|
|
|
863
|
-
export { type AgentEvents, type AgentTrack, type AudioCodecParameters, BadRequestException, type Brand, type CloseEventHandler, type ErrorEventHandler, type ExpectedAgentEvents, type ExpectedEvents, FishjamAgent, FishjamBaseException, FishjamClient, type FishjamConfig, FishjamNotFoundException, FishjamWSNotifier, ForbiddenException, type IncomingTrackData, MissingFishjamIdException, type NotificationEvents, type OutgoingTrackData, type Peer, type PeerAdded, type PeerConnected, type PeerCrashed, type PeerDeleted, type PeerDisconnected, type PeerId, type PeerMetadataUpdated, PeerNotFoundException, type PeerOptions, PeerStatus, type Room, type RoomConfig, RoomConfigRoomTypeEnum, RoomConfigVideoCodecEnum, type RoomCrashed, type RoomCreated, type RoomDeleted, type RoomId, RoomNotFoundException, ServerMessage, ServiceUnavailableException, type StreamConnected, type StreamDisconnected, type StreamerToken, type TrackAdded, type TrackId, type TrackMetadataUpdated, type TrackRemoved, type TrackType, UnauthorizedException, UnknownException, type ViewerConnected, type ViewerDisconnected, type ViewerToken };
|
|
885
|
+
export { type AgentCallbacks, type AgentEvents, type AgentTrack, type AudioCodecParameters, BadRequestException, type Brand, type CloseEventHandler, type ErrorEventHandler, type ExpectedAgentEvents, type ExpectedEvents, FishjamAgent, FishjamBaseException, FishjamClient, type FishjamConfig, FishjamNotFoundException, FishjamWSNotifier, ForbiddenException, type IncomingTrackData, MissingFishjamIdException, type NotificationEvents, type OutgoingTrackData, type Peer, type PeerAdded, type PeerConnected, type PeerCrashed, type PeerDeleted, type PeerDisconnected, type PeerId, type PeerMetadataUpdated, PeerNotFoundException, type PeerOptions, type PeerOptionsAgent, type PeerOptionsWebRTC, PeerStatus, type Room, type RoomConfig, RoomConfigRoomTypeEnum, RoomConfigVideoCodecEnum, type RoomCrashed, type RoomCreated, type RoomDeleted, type RoomId, RoomNotFoundException, ServerMessage, ServiceUnavailableException, type StreamConnected, type StreamDisconnected, type StreamerToken, type TrackAdded, type TrackId, type TrackMetadataUpdated, type TrackRemoved, type TrackType, UnauthorizedException, UnknownException, type ViewerConnected, type ViewerDisconnected, type ViewerToken };
|
package/dist/index.js
CHANGED
|
@@ -19424,6 +19424,8 @@ __export(index_exports, {
|
|
|
19424
19424
|
MissingFishjamIdException: () => MissingFishjamIdException,
|
|
19425
19425
|
PeerNotFoundException: () => PeerNotFoundException,
|
|
19426
19426
|
PeerOptions: () => import_fishjam_openapi2.PeerOptions,
|
|
19427
|
+
PeerOptionsAgent: () => import_fishjam_openapi2.PeerOptionsAgent,
|
|
19428
|
+
PeerOptionsWebRTC: () => import_fishjam_openapi2.PeerOptionsWebRTC,
|
|
19427
19429
|
PeerStatus: () => import_fishjam_openapi2.PeerStatus,
|
|
19428
19430
|
RoomConfig: () => import_fishjam_openapi2.RoomConfig,
|
|
19429
19431
|
RoomConfigRoomTypeEnum: () => import_fishjam_openapi2.RoomConfigRoomTypeEnum,
|
|
@@ -19519,6 +19521,7 @@ var FishjamWSNotifier = class extends import_events.EventEmitter {
|
|
|
19519
19521
|
const fishjamUrl = getFishjamUrl(config);
|
|
19520
19522
|
const websocketUrl = `${httpToWebsocket(fishjamUrl)}/socket/server/websocket`;
|
|
19521
19523
|
this.client = new WebSocket(websocketUrl);
|
|
19524
|
+
this.client.binaryType = "arraybuffer";
|
|
19522
19525
|
this.client.onerror = (message) => onError(message);
|
|
19523
19526
|
this.client.onclose = (message) => onClose(message.code, message.reason);
|
|
19524
19527
|
this.client.onmessage = (message) => this.dispatchNotification(message);
|
|
@@ -19526,7 +19529,8 @@ var FishjamWSNotifier = class extends import_events.EventEmitter {
|
|
|
19526
19529
|
}
|
|
19527
19530
|
dispatchNotification(message) {
|
|
19528
19531
|
try {
|
|
19529
|
-
const
|
|
19532
|
+
const data = new Uint8Array(message.data);
|
|
19533
|
+
const decodedMessage = import_fishjam_proto.ServerMessage.decode(data);
|
|
19530
19534
|
const [notification, msg] = Object.entries(decodedMessage).find(([_k, v]) => v);
|
|
19531
19535
|
if (!this.isExpectedEvent(notification)) return;
|
|
19532
19536
|
this.emit(notification, msg);
|
|
@@ -19554,16 +19558,27 @@ var import_fishjam_proto2 = __toESM(require_dist2());
|
|
|
19554
19558
|
var expectedEventsList2 = ["trackData"];
|
|
19555
19559
|
var FishjamAgent = class extends import_events2.EventEmitter {
|
|
19556
19560
|
client;
|
|
19557
|
-
|
|
19561
|
+
resolveConnectionPromise = null;
|
|
19562
|
+
connectionPromise;
|
|
19563
|
+
constructor(config, agentToken, callbacks) {
|
|
19558
19564
|
super();
|
|
19559
19565
|
const fishjamUrl = getFishjamUrl(config);
|
|
19560
19566
|
const websocketUrl = `${httpToWebsocket(fishjamUrl)}/socket/agent/websocket`;
|
|
19561
19567
|
this.client = new WebSocket(websocketUrl);
|
|
19562
19568
|
this.client.binaryType = "arraybuffer";
|
|
19563
|
-
this.client.
|
|
19564
|
-
this.client.
|
|
19569
|
+
this.client.onclose = (message) => callbacks?.onClose?.(message.code, message.reason);
|
|
19570
|
+
this.client.onerror = (message) => callbacks?.onError?.(message);
|
|
19565
19571
|
this.client.onmessage = (message) => this.dispatchNotification(message);
|
|
19566
19572
|
this.client.onopen = () => this.setupConnection(agentToken);
|
|
19573
|
+
this.connectionPromise = new Promise((resolve) => {
|
|
19574
|
+
this.resolveConnectionPromise = resolve;
|
|
19575
|
+
});
|
|
19576
|
+
}
|
|
19577
|
+
/**
|
|
19578
|
+
* Await Agent connection to Fishjam.
|
|
19579
|
+
*/
|
|
19580
|
+
async awaitConnected() {
|
|
19581
|
+
return this.connectionPromise;
|
|
19567
19582
|
}
|
|
19568
19583
|
/**
|
|
19569
19584
|
* Creates an outgoing audio track for the agent
|
|
@@ -19580,6 +19595,18 @@ var FishjamAgent = class extends import_events2.EventEmitter {
|
|
|
19580
19595
|
this.client.send(addTrack);
|
|
19581
19596
|
return track;
|
|
19582
19597
|
}
|
|
19598
|
+
/**
|
|
19599
|
+
* Interrupt track indentified by `trackId`.
|
|
19600
|
+
*
|
|
19601
|
+
* Any audio that has been sent by the agent, but not played
|
|
19602
|
+
* by Fishjam will be cleared and be prevented from playing.
|
|
19603
|
+
*
|
|
19604
|
+
* Audio sent after the interrupt will be played normally.
|
|
19605
|
+
*/
|
|
19606
|
+
interruptTrack(trackId) {
|
|
19607
|
+
const msg = import_fishjam_proto2.AgentRequest.encode({ interruptTrack: { trackId } }).finish();
|
|
19608
|
+
this.client.send(msg);
|
|
19609
|
+
}
|
|
19583
19610
|
/**
|
|
19584
19611
|
* Deletes an outgoing audio track for the agent
|
|
19585
19612
|
*/
|
|
@@ -19594,6 +19621,9 @@ var FishjamAgent = class extends import_events2.EventEmitter {
|
|
|
19594
19621
|
const trackData = import_fishjam_proto2.AgentRequest.encode({ trackData: { trackId, data } }).finish();
|
|
19595
19622
|
this.client.send(trackData);
|
|
19596
19623
|
}
|
|
19624
|
+
disconnect() {
|
|
19625
|
+
this.client.close();
|
|
19626
|
+
}
|
|
19597
19627
|
dispatchNotification(message) {
|
|
19598
19628
|
try {
|
|
19599
19629
|
const data = new Uint8Array(message.data);
|
|
@@ -19608,6 +19638,10 @@ var FishjamAgent = class extends import_events2.EventEmitter {
|
|
|
19608
19638
|
setupConnection(agentToken) {
|
|
19609
19639
|
const auth = import_fishjam_proto2.AgentRequest.encode({ authRequest: { token: agentToken } }).finish();
|
|
19610
19640
|
this.client.send(auth);
|
|
19641
|
+
if (this.resolveConnectionPromise) {
|
|
19642
|
+
this.resolveConnectionPromise();
|
|
19643
|
+
this.resolveConnectionPromise = null;
|
|
19644
|
+
}
|
|
19611
19645
|
}
|
|
19612
19646
|
isExpectedEvent(notification) {
|
|
19613
19647
|
return expectedEventsList2.includes(notification);
|
|
@@ -19738,7 +19772,7 @@ var FishjamClient = class {
|
|
|
19738
19772
|
/**
|
|
19739
19773
|
* Create a new agent assigned to a room.
|
|
19740
19774
|
*/
|
|
19741
|
-
async createAgent(roomId, options = {},
|
|
19775
|
+
async createAgent(roomId, options = {}, callbacks) {
|
|
19742
19776
|
try {
|
|
19743
19777
|
const response = await this.roomApi.addPeer(roomId, {
|
|
19744
19778
|
type: "agent",
|
|
@@ -19747,7 +19781,8 @@ var FishjamClient = class {
|
|
|
19747
19781
|
const {
|
|
19748
19782
|
data: { data }
|
|
19749
19783
|
} = response;
|
|
19750
|
-
const agent = new FishjamAgent(this.fishjamConfig, data.token,
|
|
19784
|
+
const agent = new FishjamAgent(this.fishjamConfig, data.token, callbacks);
|
|
19785
|
+
await agent.awaitConnected();
|
|
19751
19786
|
return { agent, peer: data.peer };
|
|
19752
19787
|
} catch (error) {
|
|
19753
19788
|
throw mapException(error);
|
|
@@ -19846,6 +19881,8 @@ var FishjamClient = class {
|
|
|
19846
19881
|
MissingFishjamIdException,
|
|
19847
19882
|
PeerNotFoundException,
|
|
19848
19883
|
PeerOptions,
|
|
19884
|
+
PeerOptionsAgent,
|
|
19885
|
+
PeerOptionsWebRTC,
|
|
19849
19886
|
PeerStatus,
|
|
19850
19887
|
RoomConfig,
|
|
19851
19888
|
RoomConfigRoomTypeEnum,
|
package/dist/index.mjs
CHANGED
|
@@ -1,69 +1,43 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
8
|
-
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
9
|
-
}) : x)(function(x) {
|
|
10
|
-
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
11
|
-
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
12
|
-
});
|
|
13
|
-
var __commonJS = (cb, mod) => function __require2() {
|
|
14
|
-
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
15
|
-
};
|
|
16
|
-
var __copyProps = (to, from, except, desc) => {
|
|
17
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
18
|
-
for (let key of __getOwnPropNames(from))
|
|
19
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
20
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
21
|
-
}
|
|
22
|
-
return to;
|
|
23
|
-
};
|
|
24
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
25
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
26
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
27
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
28
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
29
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
30
|
-
mod
|
|
31
|
-
));
|
|
1
|
+
import {
|
|
2
|
+
__commonJS,
|
|
3
|
+
__require,
|
|
4
|
+
__toESM
|
|
5
|
+
} from "./chunk-6DZX6EAA.mjs";
|
|
32
6
|
|
|
33
7
|
// ../fishjam-openapi/dist/index.js
|
|
34
8
|
var require_dist = __commonJS({
|
|
35
9
|
"../fishjam-openapi/dist/index.js"(exports, module) {
|
|
36
10
|
"use strict";
|
|
37
|
-
var
|
|
38
|
-
var
|
|
39
|
-
var
|
|
40
|
-
var
|
|
41
|
-
var
|
|
42
|
-
var
|
|
11
|
+
var __create = Object.create;
|
|
12
|
+
var __defProp = Object.defineProperty;
|
|
13
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
14
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
15
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
16
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
43
17
|
var __commonJS2 = (cb, mod) => function __require2() {
|
|
44
|
-
return mod || (0, cb[
|
|
18
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
45
19
|
};
|
|
46
20
|
var __export = (target, all3) => {
|
|
47
21
|
for (var name in all3)
|
|
48
|
-
|
|
22
|
+
__defProp(target, name, { get: all3[name], enumerable: true });
|
|
49
23
|
};
|
|
50
|
-
var
|
|
24
|
+
var __copyProps = (to, from, except, desc) => {
|
|
51
25
|
if (from && typeof from === "object" || typeof from === "function") {
|
|
52
|
-
for (let key of
|
|
53
|
-
if (!
|
|
54
|
-
|
|
26
|
+
for (let key of __getOwnPropNames(from))
|
|
27
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
28
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
55
29
|
}
|
|
56
30
|
return to;
|
|
57
31
|
};
|
|
58
|
-
var __toESM2 = (mod, isNodeMode, target) => (target = mod != null ?
|
|
32
|
+
var __toESM2 = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
59
33
|
// If the importer is in node compatibility mode or this is not an ESM
|
|
60
34
|
// file that has been converted to a CommonJS file using a Babel-
|
|
61
35
|
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
62
36
|
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
63
|
-
isNodeMode || !mod || !mod.__esModule ?
|
|
37
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
64
38
|
mod
|
|
65
39
|
));
|
|
66
|
-
var __toCommonJS = (mod) =>
|
|
40
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
67
41
|
var require_delayed_stream = __commonJS2({
|
|
68
42
|
"../../node_modules/delayed-stream/lib/delayed_stream.js"(exports2, module2) {
|
|
69
43
|
"use strict";
|
|
@@ -15459,23 +15433,23 @@ var require_dist = __commonJS({
|
|
|
15459
15433
|
var require_dist2 = __commonJS({
|
|
15460
15434
|
"../fishjam-proto/dist/index.js"(exports, module) {
|
|
15461
15435
|
"use strict";
|
|
15462
|
-
var
|
|
15463
|
-
var
|
|
15464
|
-
var
|
|
15465
|
-
var
|
|
15436
|
+
var __defProp = Object.defineProperty;
|
|
15437
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
15438
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
15439
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
15466
15440
|
var __export = (target, all) => {
|
|
15467
15441
|
for (var name in all)
|
|
15468
|
-
|
|
15442
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
15469
15443
|
};
|
|
15470
|
-
var
|
|
15444
|
+
var __copyProps = (to, from, except, desc) => {
|
|
15471
15445
|
if (from && typeof from === "object" || typeof from === "function") {
|
|
15472
|
-
for (let key of
|
|
15473
|
-
if (!
|
|
15474
|
-
|
|
15446
|
+
for (let key of __getOwnPropNames(from))
|
|
15447
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15448
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15475
15449
|
}
|
|
15476
15450
|
return to;
|
|
15477
15451
|
};
|
|
15478
|
-
var __toCommonJS = (mod) =>
|
|
15452
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15479
15453
|
var index_exports = {};
|
|
15480
15454
|
__export(index_exports, {
|
|
15481
15455
|
AgentRequest: () => AgentRequest2,
|
|
@@ -19494,6 +19468,7 @@ var FishjamWSNotifier = class extends EventEmitter {
|
|
|
19494
19468
|
const fishjamUrl = getFishjamUrl(config);
|
|
19495
19469
|
const websocketUrl = `${httpToWebsocket(fishjamUrl)}/socket/server/websocket`;
|
|
19496
19470
|
this.client = new WebSocket(websocketUrl);
|
|
19471
|
+
this.client.binaryType = "arraybuffer";
|
|
19497
19472
|
this.client.onerror = (message) => onError(message);
|
|
19498
19473
|
this.client.onclose = (message) => onClose(message.code, message.reason);
|
|
19499
19474
|
this.client.onmessage = (message) => this.dispatchNotification(message);
|
|
@@ -19501,7 +19476,8 @@ var FishjamWSNotifier = class extends EventEmitter {
|
|
|
19501
19476
|
}
|
|
19502
19477
|
dispatchNotification(message) {
|
|
19503
19478
|
try {
|
|
19504
|
-
const
|
|
19479
|
+
const data = new Uint8Array(message.data);
|
|
19480
|
+
const decodedMessage = import_fishjam_proto.ServerMessage.decode(data);
|
|
19505
19481
|
const [notification, msg] = Object.entries(decodedMessage).find(([_k, v]) => v);
|
|
19506
19482
|
if (!this.isExpectedEvent(notification)) return;
|
|
19507
19483
|
this.emit(notification, msg);
|
|
@@ -19529,16 +19505,27 @@ import { v4 as uuid4 } from "uuid";
|
|
|
19529
19505
|
var expectedEventsList2 = ["trackData"];
|
|
19530
19506
|
var FishjamAgent = class extends EventEmitter2 {
|
|
19531
19507
|
client;
|
|
19532
|
-
|
|
19508
|
+
resolveConnectionPromise = null;
|
|
19509
|
+
connectionPromise;
|
|
19510
|
+
constructor(config, agentToken, callbacks) {
|
|
19533
19511
|
super();
|
|
19534
19512
|
const fishjamUrl = getFishjamUrl(config);
|
|
19535
19513
|
const websocketUrl = `${httpToWebsocket(fishjamUrl)}/socket/agent/websocket`;
|
|
19536
19514
|
this.client = new WebSocket(websocketUrl);
|
|
19537
19515
|
this.client.binaryType = "arraybuffer";
|
|
19538
|
-
this.client.
|
|
19539
|
-
this.client.
|
|
19516
|
+
this.client.onclose = (message) => callbacks?.onClose?.(message.code, message.reason);
|
|
19517
|
+
this.client.onerror = (message) => callbacks?.onError?.(message);
|
|
19540
19518
|
this.client.onmessage = (message) => this.dispatchNotification(message);
|
|
19541
19519
|
this.client.onopen = () => this.setupConnection(agentToken);
|
|
19520
|
+
this.connectionPromise = new Promise((resolve) => {
|
|
19521
|
+
this.resolveConnectionPromise = resolve;
|
|
19522
|
+
});
|
|
19523
|
+
}
|
|
19524
|
+
/**
|
|
19525
|
+
* Await Agent connection to Fishjam.
|
|
19526
|
+
*/
|
|
19527
|
+
async awaitConnected() {
|
|
19528
|
+
return this.connectionPromise;
|
|
19542
19529
|
}
|
|
19543
19530
|
/**
|
|
19544
19531
|
* Creates an outgoing audio track for the agent
|
|
@@ -19555,6 +19542,18 @@ var FishjamAgent = class extends EventEmitter2 {
|
|
|
19555
19542
|
this.client.send(addTrack);
|
|
19556
19543
|
return track;
|
|
19557
19544
|
}
|
|
19545
|
+
/**
|
|
19546
|
+
* Interrupt track indentified by `trackId`.
|
|
19547
|
+
*
|
|
19548
|
+
* Any audio that has been sent by the agent, but not played
|
|
19549
|
+
* by Fishjam will be cleared and be prevented from playing.
|
|
19550
|
+
*
|
|
19551
|
+
* Audio sent after the interrupt will be played normally.
|
|
19552
|
+
*/
|
|
19553
|
+
interruptTrack(trackId) {
|
|
19554
|
+
const msg = import_fishjam_proto2.AgentRequest.encode({ interruptTrack: { trackId } }).finish();
|
|
19555
|
+
this.client.send(msg);
|
|
19556
|
+
}
|
|
19558
19557
|
/**
|
|
19559
19558
|
* Deletes an outgoing audio track for the agent
|
|
19560
19559
|
*/
|
|
@@ -19569,6 +19568,9 @@ var FishjamAgent = class extends EventEmitter2 {
|
|
|
19569
19568
|
const trackData = import_fishjam_proto2.AgentRequest.encode({ trackData: { trackId, data } }).finish();
|
|
19570
19569
|
this.client.send(trackData);
|
|
19571
19570
|
}
|
|
19571
|
+
disconnect() {
|
|
19572
|
+
this.client.close();
|
|
19573
|
+
}
|
|
19572
19574
|
dispatchNotification(message) {
|
|
19573
19575
|
try {
|
|
19574
19576
|
const data = new Uint8Array(message.data);
|
|
@@ -19583,6 +19585,10 @@ var FishjamAgent = class extends EventEmitter2 {
|
|
|
19583
19585
|
setupConnection(agentToken) {
|
|
19584
19586
|
const auth = import_fishjam_proto2.AgentRequest.encode({ authRequest: { token: agentToken } }).finish();
|
|
19585
19587
|
this.client.send(auth);
|
|
19588
|
+
if (this.resolveConnectionPromise) {
|
|
19589
|
+
this.resolveConnectionPromise();
|
|
19590
|
+
this.resolveConnectionPromise = null;
|
|
19591
|
+
}
|
|
19586
19592
|
}
|
|
19587
19593
|
isExpectedEvent(notification) {
|
|
19588
19594
|
return expectedEventsList2.includes(notification);
|
|
@@ -19713,7 +19719,7 @@ var FishjamClient = class {
|
|
|
19713
19719
|
/**
|
|
19714
19720
|
* Create a new agent assigned to a room.
|
|
19715
19721
|
*/
|
|
19716
|
-
async createAgent(roomId, options = {},
|
|
19722
|
+
async createAgent(roomId, options = {}, callbacks) {
|
|
19717
19723
|
try {
|
|
19718
19724
|
const response = await this.roomApi.addPeer(roomId, {
|
|
19719
19725
|
type: "agent",
|
|
@@ -19722,7 +19728,8 @@ var FishjamClient = class {
|
|
|
19722
19728
|
const {
|
|
19723
19729
|
data: { data }
|
|
19724
19730
|
} = response;
|
|
19725
|
-
const agent = new FishjamAgent(this.fishjamConfig, data.token,
|
|
19731
|
+
const agent = new FishjamAgent(this.fishjamConfig, data.token, callbacks);
|
|
19732
|
+
await agent.awaitConnected();
|
|
19726
19733
|
return { agent, peer: data.peer };
|
|
19727
19734
|
} catch (error) {
|
|
19728
19735
|
throw mapException(error);
|
|
@@ -19810,6 +19817,8 @@ var FishjamClient = class {
|
|
|
19810
19817
|
}
|
|
19811
19818
|
};
|
|
19812
19819
|
var export_PeerOptions = import_fishjam_openapi2.PeerOptions;
|
|
19820
|
+
var export_PeerOptionsAgent = import_fishjam_openapi2.PeerOptionsAgent;
|
|
19821
|
+
var export_PeerOptionsWebRTC = import_fishjam_openapi2.PeerOptionsWebRTC;
|
|
19813
19822
|
var export_PeerStatus = import_fishjam_openapi2.PeerStatus;
|
|
19814
19823
|
var export_RoomConfig = import_fishjam_openapi2.RoomConfig;
|
|
19815
19824
|
var export_RoomConfigRoomTypeEnum = import_fishjam_openapi2.RoomConfigRoomTypeEnum;
|
|
@@ -19828,6 +19837,8 @@ export {
|
|
|
19828
19837
|
MissingFishjamIdException,
|
|
19829
19838
|
PeerNotFoundException,
|
|
19830
19839
|
export_PeerOptions as PeerOptions,
|
|
19840
|
+
export_PeerOptionsAgent as PeerOptionsAgent,
|
|
19841
|
+
export_PeerOptionsWebRTC as PeerOptionsWebRTC,
|
|
19831
19842
|
export_PeerStatus as PeerStatus,
|
|
19832
19843
|
export_RoomConfig as RoomConfig,
|
|
19833
19844
|
export_RoomConfigRoomTypeEnum as RoomConfigRoomTypeEnum,
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { GoogleGenAIOptions, GoogleGenAI } from '@google/genai';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* A collection of settings for Google Gemini integration.
|
|
5
|
+
*/
|
|
6
|
+
declare const _default: {
|
|
7
|
+
/**
|
|
8
|
+
* Creates a GoogleGenAI client.
|
|
9
|
+
* This function dynamically imports the "@google/genai" module,
|
|
10
|
+
* so it will only be loaded when this function is called.
|
|
11
|
+
*
|
|
12
|
+
* @param options Configuration for the GoogleGenAI client.
|
|
13
|
+
* @returns A GoogleGenAI instance.
|
|
14
|
+
*/
|
|
15
|
+
createClient: (options: GoogleGenAIOptions) => GoogleGenAI;
|
|
16
|
+
/**
|
|
17
|
+
* Predefined audio settings for the agent's output track,
|
|
18
|
+
* configured for Gemini's 24kHz audio output.
|
|
19
|
+
*/
|
|
20
|
+
geminiOutputAudioSettings: {
|
|
21
|
+
readonly encoding: "pcm16";
|
|
22
|
+
readonly channels: 1;
|
|
23
|
+
readonly sampleRate: 24000;
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Predefined audio settings for subscribing to room audio,
|
|
27
|
+
* configured for Gemini's 16kHz audio input.
|
|
28
|
+
*/
|
|
29
|
+
geminiInputAudioSettings: {
|
|
30
|
+
readonly audioFormat: "pcm16";
|
|
31
|
+
readonly audioSampleRate: 16000;
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* The MIME type for the audio data sent to Gemini.
|
|
35
|
+
*/
|
|
36
|
+
inputMimeType: "audio/pcm;rate=16000";
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export { _default as default };
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { GoogleGenAIOptions, GoogleGenAI } from '@google/genai';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* A collection of settings for Google Gemini integration.
|
|
5
|
+
*/
|
|
6
|
+
declare const _default: {
|
|
7
|
+
/**
|
|
8
|
+
* Creates a GoogleGenAI client.
|
|
9
|
+
* This function dynamically imports the "@google/genai" module,
|
|
10
|
+
* so it will only be loaded when this function is called.
|
|
11
|
+
*
|
|
12
|
+
* @param options Configuration for the GoogleGenAI client.
|
|
13
|
+
* @returns A GoogleGenAI instance.
|
|
14
|
+
*/
|
|
15
|
+
createClient: (options: GoogleGenAIOptions) => GoogleGenAI;
|
|
16
|
+
/**
|
|
17
|
+
* Predefined audio settings for the agent's output track,
|
|
18
|
+
* configured for Gemini's 24kHz audio output.
|
|
19
|
+
*/
|
|
20
|
+
geminiOutputAudioSettings: {
|
|
21
|
+
readonly encoding: "pcm16";
|
|
22
|
+
readonly channels: 1;
|
|
23
|
+
readonly sampleRate: 24000;
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Predefined audio settings for subscribing to room audio,
|
|
27
|
+
* configured for Gemini's 16kHz audio input.
|
|
28
|
+
*/
|
|
29
|
+
geminiInputAudioSettings: {
|
|
30
|
+
readonly audioFormat: "pcm16";
|
|
31
|
+
readonly audioSampleRate: 16000;
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* The MIME type for the audio data sent to Gemini.
|
|
35
|
+
*/
|
|
36
|
+
inputMimeType: "audio/pcm;rate=16000";
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export { _default as default };
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/integrations/gemini.ts
|
|
21
|
+
var gemini_exports = {};
|
|
22
|
+
__export(gemini_exports, {
|
|
23
|
+
default: () => gemini_default
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(gemini_exports);
|
|
26
|
+
|
|
27
|
+
// package.json
|
|
28
|
+
var package_default = {
|
|
29
|
+
name: "@fishjam-cloud/js-server-sdk",
|
|
30
|
+
version: "0.23.0",
|
|
31
|
+
description: "Fishjam server SDK for JavaScript",
|
|
32
|
+
homepage: "https://github.com/fishjam-cloud/js-server-sdk",
|
|
33
|
+
author: "Fishjam Team",
|
|
34
|
+
repository: {
|
|
35
|
+
type: "git",
|
|
36
|
+
url: "https://github.com/fishjam-cloud/js-server-sdk.git"
|
|
37
|
+
},
|
|
38
|
+
bugs: {
|
|
39
|
+
url: "https://github.com/fishjam-cloud/js-server-sdk/issues"
|
|
40
|
+
},
|
|
41
|
+
license: "Apache-2.0",
|
|
42
|
+
keywords: [
|
|
43
|
+
"webrtc",
|
|
44
|
+
"fishjam",
|
|
45
|
+
"server",
|
|
46
|
+
"membrane"
|
|
47
|
+
],
|
|
48
|
+
main: "./dist/index.js",
|
|
49
|
+
types: "./dist/index.d.ts",
|
|
50
|
+
files: [
|
|
51
|
+
"dist"
|
|
52
|
+
],
|
|
53
|
+
exports: {
|
|
54
|
+
".": "./dist/index.js",
|
|
55
|
+
"./gemini": "./dist/integrations/gemini.js"
|
|
56
|
+
},
|
|
57
|
+
scripts: {
|
|
58
|
+
build: "tsup --dts-resolve",
|
|
59
|
+
format: "prettier --write .",
|
|
60
|
+
"format:check": "prettier --check .",
|
|
61
|
+
typecheck: "tsc --noEmit",
|
|
62
|
+
lint: "eslint . --fix",
|
|
63
|
+
"lint:check": "eslint . "
|
|
64
|
+
},
|
|
65
|
+
tsup: {
|
|
66
|
+
entry: [
|
|
67
|
+
"src/index.ts",
|
|
68
|
+
"src/integrations/gemini.ts",
|
|
69
|
+
"src/proto.ts"
|
|
70
|
+
],
|
|
71
|
+
noExternal: [
|
|
72
|
+
"fishjam-openapi",
|
|
73
|
+
"fishjam-proto"
|
|
74
|
+
],
|
|
75
|
+
minify: false,
|
|
76
|
+
format: [
|
|
77
|
+
"cjs",
|
|
78
|
+
"esm"
|
|
79
|
+
],
|
|
80
|
+
outDir: "dist"
|
|
81
|
+
},
|
|
82
|
+
dependencies: {
|
|
83
|
+
axios: "^1.7.9",
|
|
84
|
+
uuid: "^11.1.0"
|
|
85
|
+
},
|
|
86
|
+
peerDependencies: {
|
|
87
|
+
"@google/genai": "^1.0.0"
|
|
88
|
+
},
|
|
89
|
+
peerDependenciesMeta: {
|
|
90
|
+
"@google/genai": {
|
|
91
|
+
optional: true
|
|
92
|
+
}
|
|
93
|
+
},
|
|
94
|
+
devDependencies: {
|
|
95
|
+
"@fishjam-cloud/fishjam-openapi": "workspace:*",
|
|
96
|
+
"@fishjam-cloud/fishjam-proto": "workspace:*",
|
|
97
|
+
"@openapitools/openapi-generator-cli": "^2.18.4",
|
|
98
|
+
"@types/node": "^22.13.16",
|
|
99
|
+
"@types/websocket": "^1.0.10",
|
|
100
|
+
eslint: "^9.33.0",
|
|
101
|
+
prettier: "^3.6.2",
|
|
102
|
+
tsup: "^8.4.0",
|
|
103
|
+
"typed-emitter": "^2.1.0"
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
// src/integrations/gemini.ts
|
|
108
|
+
var SDK_NAME = "fishjam-js-server-sdk";
|
|
109
|
+
var gemini_default = {
|
|
110
|
+
/**
|
|
111
|
+
* Creates a GoogleGenAI client.
|
|
112
|
+
* This function dynamically imports the "@google/genai" module,
|
|
113
|
+
* so it will only be loaded when this function is called.
|
|
114
|
+
*
|
|
115
|
+
* @param options Configuration for the GoogleGenAI client.
|
|
116
|
+
* @returns A GoogleGenAI instance.
|
|
117
|
+
*/
|
|
118
|
+
createClient: (options) => {
|
|
119
|
+
const { GoogleGenAI } = require("@google/genai");
|
|
120
|
+
const trackingHeader = { "X-Goog-Api-Client": `${SDK_NAME}/${package_default.version}` };
|
|
121
|
+
const finalOptions = {
|
|
122
|
+
...options,
|
|
123
|
+
httpOptions: {
|
|
124
|
+
...options.httpOptions,
|
|
125
|
+
headers: {
|
|
126
|
+
...options.httpOptions?.headers,
|
|
127
|
+
...trackingHeader
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
|
+
return new GoogleGenAI(finalOptions);
|
|
132
|
+
},
|
|
133
|
+
/**
|
|
134
|
+
* Predefined audio settings for the agent's output track,
|
|
135
|
+
* configured for Gemini's 24kHz audio output.
|
|
136
|
+
*/
|
|
137
|
+
geminiOutputAudioSettings: {
|
|
138
|
+
encoding: "pcm16",
|
|
139
|
+
channels: 1,
|
|
140
|
+
sampleRate: 24e3
|
|
141
|
+
},
|
|
142
|
+
/**
|
|
143
|
+
* Predefined audio settings for subscribing to room audio,
|
|
144
|
+
* configured for Gemini's 16kHz audio input.
|
|
145
|
+
*/
|
|
146
|
+
geminiInputAudioSettings: {
|
|
147
|
+
audioFormat: "pcm16",
|
|
148
|
+
audioSampleRate: 16e3
|
|
149
|
+
},
|
|
150
|
+
/**
|
|
151
|
+
* The MIME type for the audio data sent to Gemini.
|
|
152
|
+
*/
|
|
153
|
+
inputMimeType: "audio/pcm;rate=16000"
|
|
154
|
+
};
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import {
|
|
2
|
+
__require
|
|
3
|
+
} from "../chunk-6DZX6EAA.mjs";
|
|
4
|
+
|
|
5
|
+
// package.json
|
|
6
|
+
var package_default = {
|
|
7
|
+
name: "@fishjam-cloud/js-server-sdk",
|
|
8
|
+
version: "0.23.0",
|
|
9
|
+
description: "Fishjam server SDK for JavaScript",
|
|
10
|
+
homepage: "https://github.com/fishjam-cloud/js-server-sdk",
|
|
11
|
+
author: "Fishjam Team",
|
|
12
|
+
repository: {
|
|
13
|
+
type: "git",
|
|
14
|
+
url: "https://github.com/fishjam-cloud/js-server-sdk.git"
|
|
15
|
+
},
|
|
16
|
+
bugs: {
|
|
17
|
+
url: "https://github.com/fishjam-cloud/js-server-sdk/issues"
|
|
18
|
+
},
|
|
19
|
+
license: "Apache-2.0",
|
|
20
|
+
keywords: [
|
|
21
|
+
"webrtc",
|
|
22
|
+
"fishjam",
|
|
23
|
+
"server",
|
|
24
|
+
"membrane"
|
|
25
|
+
],
|
|
26
|
+
main: "./dist/index.js",
|
|
27
|
+
types: "./dist/index.d.ts",
|
|
28
|
+
files: [
|
|
29
|
+
"dist"
|
|
30
|
+
],
|
|
31
|
+
exports: {
|
|
32
|
+
".": "./dist/index.js",
|
|
33
|
+
"./gemini": "./dist/integrations/gemini.js"
|
|
34
|
+
},
|
|
35
|
+
scripts: {
|
|
36
|
+
build: "tsup --dts-resolve",
|
|
37
|
+
format: "prettier --write .",
|
|
38
|
+
"format:check": "prettier --check .",
|
|
39
|
+
typecheck: "tsc --noEmit",
|
|
40
|
+
lint: "eslint . --fix",
|
|
41
|
+
"lint:check": "eslint . "
|
|
42
|
+
},
|
|
43
|
+
tsup: {
|
|
44
|
+
entry: [
|
|
45
|
+
"src/index.ts",
|
|
46
|
+
"src/integrations/gemini.ts",
|
|
47
|
+
"src/proto.ts"
|
|
48
|
+
],
|
|
49
|
+
noExternal: [
|
|
50
|
+
"fishjam-openapi",
|
|
51
|
+
"fishjam-proto"
|
|
52
|
+
],
|
|
53
|
+
minify: false,
|
|
54
|
+
format: [
|
|
55
|
+
"cjs",
|
|
56
|
+
"esm"
|
|
57
|
+
],
|
|
58
|
+
outDir: "dist"
|
|
59
|
+
},
|
|
60
|
+
dependencies: {
|
|
61
|
+
axios: "^1.7.9",
|
|
62
|
+
uuid: "^11.1.0"
|
|
63
|
+
},
|
|
64
|
+
peerDependencies: {
|
|
65
|
+
"@google/genai": "^1.0.0"
|
|
66
|
+
},
|
|
67
|
+
peerDependenciesMeta: {
|
|
68
|
+
"@google/genai": {
|
|
69
|
+
optional: true
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
devDependencies: {
|
|
73
|
+
"@fishjam-cloud/fishjam-openapi": "workspace:*",
|
|
74
|
+
"@fishjam-cloud/fishjam-proto": "workspace:*",
|
|
75
|
+
"@openapitools/openapi-generator-cli": "^2.18.4",
|
|
76
|
+
"@types/node": "^22.13.16",
|
|
77
|
+
"@types/websocket": "^1.0.10",
|
|
78
|
+
eslint: "^9.33.0",
|
|
79
|
+
prettier: "^3.6.2",
|
|
80
|
+
tsup: "^8.4.0",
|
|
81
|
+
"typed-emitter": "^2.1.0"
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
// src/integrations/gemini.ts
|
|
86
|
+
var SDK_NAME = "fishjam-js-server-sdk";
|
|
87
|
+
var gemini_default = {
|
|
88
|
+
/**
|
|
89
|
+
* Creates a GoogleGenAI client.
|
|
90
|
+
* This function dynamically imports the "@google/genai" module,
|
|
91
|
+
* so it will only be loaded when this function is called.
|
|
92
|
+
*
|
|
93
|
+
* @param options Configuration for the GoogleGenAI client.
|
|
94
|
+
* @returns A GoogleGenAI instance.
|
|
95
|
+
*/
|
|
96
|
+
createClient: (options) => {
|
|
97
|
+
const { GoogleGenAI } = __require("@google/genai");
|
|
98
|
+
const trackingHeader = { "X-Goog-Api-Client": `${SDK_NAME}/${package_default.version}` };
|
|
99
|
+
const finalOptions = {
|
|
100
|
+
...options,
|
|
101
|
+
httpOptions: {
|
|
102
|
+
...options.httpOptions,
|
|
103
|
+
headers: {
|
|
104
|
+
...options.httpOptions?.headers,
|
|
105
|
+
...trackingHeader
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
return new GoogleGenAI(finalOptions);
|
|
110
|
+
},
|
|
111
|
+
/**
|
|
112
|
+
* Predefined audio settings for the agent's output track,
|
|
113
|
+
* configured for Gemini's 24kHz audio output.
|
|
114
|
+
*/
|
|
115
|
+
geminiOutputAudioSettings: {
|
|
116
|
+
encoding: "pcm16",
|
|
117
|
+
channels: 1,
|
|
118
|
+
sampleRate: 24e3
|
|
119
|
+
},
|
|
120
|
+
/**
|
|
121
|
+
* Predefined audio settings for subscribing to room audio,
|
|
122
|
+
* configured for Gemini's 16kHz audio input.
|
|
123
|
+
*/
|
|
124
|
+
geminiInputAudioSettings: {
|
|
125
|
+
audioFormat: "pcm16",
|
|
126
|
+
audioSampleRate: 16e3
|
|
127
|
+
},
|
|
128
|
+
/**
|
|
129
|
+
* The MIME type for the audio data sent to Gemini.
|
|
130
|
+
*/
|
|
131
|
+
inputMimeType: "audio/pcm;rate=16000"
|
|
132
|
+
};
|
|
133
|
+
export {
|
|
134
|
+
gemini_default as default
|
|
135
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fishjam-cloud/js-server-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.23.0",
|
|
4
4
|
"description": "Fishjam server SDK for JavaScript",
|
|
5
5
|
"homepage": "https://github.com/fishjam-cloud/js-server-sdk",
|
|
6
6
|
"author": "Fishjam Team",
|
|
@@ -24,7 +24,8 @@
|
|
|
24
24
|
"dist"
|
|
25
25
|
],
|
|
26
26
|
"exports": {
|
|
27
|
-
".": "./dist/index.js"
|
|
27
|
+
".": "./dist/index.js",
|
|
28
|
+
"./gemini": "./dist/integrations/gemini.js"
|
|
28
29
|
},
|
|
29
30
|
"scripts": {
|
|
30
31
|
"build": "tsup --dts-resolve",
|
|
@@ -37,6 +38,7 @@
|
|
|
37
38
|
"tsup": {
|
|
38
39
|
"entry": [
|
|
39
40
|
"src/index.ts",
|
|
41
|
+
"src/integrations/gemini.ts",
|
|
40
42
|
"src/proto.ts"
|
|
41
43
|
],
|
|
42
44
|
"noExternal": [
|
|
@@ -54,9 +56,17 @@
|
|
|
54
56
|
"axios": "^1.7.9",
|
|
55
57
|
"uuid": "^11.1.0"
|
|
56
58
|
},
|
|
59
|
+
"peerDependencies": {
|
|
60
|
+
"@google/genai": "^1.0.0"
|
|
61
|
+
},
|
|
62
|
+
"peerDependenciesMeta": {
|
|
63
|
+
"@google/genai": {
|
|
64
|
+
"optional": true
|
|
65
|
+
}
|
|
66
|
+
},
|
|
57
67
|
"devDependencies": {
|
|
58
|
-
"@fishjam-cloud/fishjam-openapi": "0.
|
|
59
|
-
"@fishjam-cloud/fishjam-proto": "0.
|
|
68
|
+
"@fishjam-cloud/fishjam-openapi": "0.23.0",
|
|
69
|
+
"@fishjam-cloud/fishjam-proto": "0.23.0",
|
|
60
70
|
"@openapitools/openapi-generator-cli": "^2.18.4",
|
|
61
71
|
"@types/node": "^22.13.16",
|
|
62
72
|
"@types/websocket": "^1.0.10",
|