@coasys/ad4m 0.13.1-staging.1 → 0.13.1-staging.2
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/lib/index.cjs +3789 -1192
- package/lib/index.js +3783 -1193
- package/lib/src/generated/api/AgentsByDidsRequest.d.ts +3 -0
- package/lib/src/generated/api/CallSessionInfo.d.ts +23 -0
- package/lib/src/generated/api/DiscardBatchRequest.d.ts +3 -0
- package/lib/src/generated/api/Events.d.ts +13 -3
- package/lib/src/generated/api/Events.js +1 -0
- package/lib/src/generated/api/FlowStateChangedEvent.d.ts +38 -0
- package/lib/src/generated/api/FlowStateEntry.d.ts +18 -0
- package/lib/src/generated/api/FlowStateEntry.js +2 -0
- package/lib/src/generated/api/IceServer.d.ts +18 -0
- package/lib/src/generated/api/IceServer.js +2 -0
- package/lib/src/generated/api/OnlineAgent.d.ts +4 -0
- package/lib/src/generated/api/PerspectiveDiscardBatchParams.d.ts +4 -0
- package/lib/src/generated/api/PerspectiveDiscardBatchParams.js +2 -0
- package/lib/src/generated/api/PerspectiveFlowFiredParams.d.ts +8 -0
- package/lib/src/generated/api/PerspectiveFlowFiredParams.js +2 -0
- package/lib/src/generated/api/PerspectiveFlowStatesParams.d.ts +11 -0
- package/lib/src/generated/api/PerspectiveFlowStatesParams.js +2 -0
- package/lib/src/generated/api/PerspectiveGetAllShaclParams.d.ts +7 -0
- package/lib/src/generated/api/PerspectiveGetAllShaclParams.js +2 -0
- package/lib/src/generated/api/PerspectiveModelQueryParams.d.ts +6 -1
- package/lib/src/generated/api/PerspectiveRemoveSubjectParams.d.ts +6 -0
- package/lib/src/generated/api/PerspectiveRemoveSubjectParams.js +2 -0
- package/lib/src/generated/api/PerspectiveResynced.d.ts +8 -0
- package/lib/src/generated/api/PerspectiveResynced.js +2 -0
- package/lib/src/generated/api/PerspectiveSubscribed.d.ts +10 -0
- package/lib/src/generated/api/PerspectiveSubscribed.js +2 -0
- package/lib/src/generated/api/PerspectiveUpdateSubjectParams.d.ts +10 -0
- package/lib/src/generated/api/PerspectiveUpdateSubjectParams.js +2 -0
- package/lib/src/generated/api/QuerySubscriptionUpdate.d.ts +19 -0
- package/lib/src/generated/api/QuerySubscriptionUpdate.js +2 -0
- package/lib/src/generated/api/QuerySubscriptionUpdateEvent.d.ts +7 -0
- package/lib/src/generated/api/QuerySubscriptionUpdateEvent.js +1 -0
- package/lib/src/generated/api/QueryUpdatesLagged.d.ts +7 -0
- package/lib/src/generated/api/QueryUpdatesLagged.js +2 -0
- package/lib/src/generated/api/RemoveSubjectRequest.d.ts +9 -0
- package/lib/src/generated/api/RemoveSubjectRequest.js +2 -0
- package/lib/src/generated/api/ResyncSubscriptionRequest.d.ts +3 -0
- package/lib/src/generated/api/ResyncSubscriptionRequest.js +2 -0
- package/lib/src/generated/api/RpcMethods.d.ts +134 -14
- package/lib/src/generated/api/RpcMethods.js +12 -0
- package/lib/src/generated/api/SfuAddIceCandidateParams.d.ts +8 -0
- package/lib/src/generated/api/SfuAddIceCandidateParams.js +2 -0
- package/lib/src/generated/api/SfuAnswerServerOfferParams.d.ts +8 -0
- package/lib/src/generated/api/SfuAnswerServerOfferParams.js +2 -0
- package/lib/src/generated/api/SfuCallJoinParams.d.ts +14 -0
- package/lib/src/generated/api/SfuCallJoinParams.js +2 -0
- package/lib/src/generated/api/SfuCallRenegotiationOffer.d.ts +30 -0
- package/lib/src/generated/api/SfuCallRenegotiationOffer.js +1 -0
- package/lib/src/generated/api/SfuCascadePipe.d.ts +4 -0
- package/lib/src/generated/api/SfuCascadePipe.js +2 -0
- package/lib/src/generated/api/SfuCascadeStatus.d.ts +8 -0
- package/lib/src/generated/api/SfuCascadeStatus.js +1 -0
- package/lib/src/generated/api/SfuConfig.d.ts +52 -0
- package/lib/src/generated/api/SfuConfig.js +1 -0
- package/lib/src/generated/api/SfuDataMessage.d.ts +24 -0
- package/lib/src/generated/api/SfuDataMessage.js +2 -0
- package/lib/src/generated/api/SfuEnsureMembershipParams.d.ts +4 -0
- package/lib/src/generated/api/SfuEnsureMembershipParams.js +2 -0
- package/lib/src/generated/api/SfuMigrateEvent.d.ts +21 -0
- package/lib/src/generated/api/SfuMigrateEvent.js +2 -0
- package/lib/src/generated/api/SfuNeighbourhoodParams.d.ts +3 -0
- package/lib/src/generated/api/SfuNeighbourhoodParams.js +2 -0
- package/lib/src/generated/api/SfuParticipantQualityPreference.d.ts +7 -0
- package/lib/src/generated/api/SfuParticipantQualityPreference.js +2 -0
- package/lib/src/generated/api/SfuPerspectiveParams.d.ts +6 -0
- package/lib/src/generated/api/SfuPerspectiveParams.js +2 -0
- package/lib/src/generated/api/SfuQualityPreferenceParams.d.ts +8 -0
- package/lib/src/generated/api/SfuQualityPreferenceParams.js +2 -0
- package/lib/src/generated/api/SfuRoomInfo.d.ts +11 -0
- package/lib/src/generated/api/SfuRoomInfo.js +1 -0
- package/lib/src/generated/api/SfuRoomParams.d.ts +4 -0
- package/lib/src/generated/api/SfuRoomParams.js +2 -0
- package/lib/src/generated/api/SfuRoomParticipantInfo.d.ts +11 -0
- package/lib/src/generated/api/SfuRoomParticipantInfo.js +2 -0
- package/lib/src/generated/api/SfuRoomRoster.d.ts +13 -0
- package/lib/src/generated/api/SfuRoomRoster.js +2 -0
- package/lib/src/generated/api/SfuSendDataParams.d.ts +10 -0
- package/lib/src/generated/api/SfuSendDataParams.js +2 -0
- package/lib/src/generated/api/SfuSetConfigParams.d.ts +5 -0
- package/lib/src/generated/api/SfuSetConfigParams.js +1 -0
- package/lib/src/generated/api/SfuStatus.d.ts +24 -0
- package/lib/src/generated/api/SfuStatus.js +2 -0
- package/lib/src/generated/api/TrackMapEntry.d.ts +17 -0
- package/lib/src/generated/api/TrackMapEntry.js +2 -0
- package/lib/src/generated/api/UpdateSubjectRequest.d.ts +12 -0
- package/lib/src/generated/api/UpdateSubjectRequest.js +2 -0
- package/lib/src/generated/api/index.d.ts +3 -0
- package/lib/src/index.d.ts +7 -0
- package/lib/src/index.js +4 -0
- package/lib/src/model/Ad4mModel.d.ts +84 -0
- package/lib/src/model/Ad4mModel.js +234 -4
- package/lib/src/model/ModelQueryBuilder.d.ts +16 -35
- package/lib/src/model/ModelQueryBuilder.js +88 -270
- package/lib/src/model/decorators.d.ts +32 -0
- package/lib/src/model/decorators.js +40 -1
- package/lib/src/model/shacl-gen.d.ts +3 -1
- package/lib/src/model/shacl-gen.js +13 -1
- package/lib/src/model/types.d.ts +7 -0
- package/lib/src/neighbourhood/MeshManager.d.ts +384 -0
- package/lib/src/neighbourhood/MeshManager.js +1144 -0
- package/lib/src/neighbourhood/NeighbourhoodClient.d.ts +91 -0
- package/lib/src/neighbourhood/NeighbourhoodClient.js +196 -0
- package/lib/src/neighbourhood/NeighbourhoodProxy.d.ts +55 -1
- package/lib/src/neighbourhood/NeighbourhoodProxy.js +170 -3
- package/lib/src/neighbourhood/Session.d.ts +105 -0
- package/lib/src/neighbourhood/Session.js +412 -0
- package/lib/src/neighbourhood/SfuManager.d.ts +174 -0
- package/lib/src/neighbourhood/SfuManager.js +619 -0
- package/lib/src/neighbourhood/SfuTypes.d.ts +35 -0
- package/lib/src/neighbourhood/SfuTypes.js +8 -0
- package/lib/src/perspectives/FlowInstance.d.ts +63 -24
- package/lib/src/perspectives/FlowInstance.js +74 -31
- package/lib/src/perspectives/FlowModels.d.ts +0 -16
- package/lib/src/perspectives/FlowModels.js +8 -16
- package/lib/src/perspectives/LiveQuery.d.ts +49 -0
- package/lib/src/perspectives/LiveQuery.js +169 -0
- package/lib/src/perspectives/PerspectiveClient.d.ts +24 -15
- package/lib/src/perspectives/PerspectiveClient.js +33 -36
- package/lib/src/perspectives/PerspectiveProxy.d.ts +67 -167
- package/lib/src/perspectives/PerspectiveProxy.js +121 -475
- package/lib/src/perspectives/TextContent.d.ts +31 -0
- package/lib/src/perspectives/TextContent.js +52 -0
- package/lib/src/perspectives/WakerSubscriptionManager.d.ts +23 -0
- package/lib/src/perspectives/WakerSubscriptionManager.js +58 -17
- package/lib/src/shacl/SHACLFlow.d.ts +7 -4
- package/lib/src/shacl/SHACLFlow.js +7 -4
- package/lib/src/shacl/SHACLShape.d.ts +9 -0
- package/lib/src/shacl/SHACLShape.js +37 -0
- package/package.json +2 -2
- package/pnpm-workspace.yaml +4 -1
- package/src/Ad4mClient.test.ts +89 -17
- package/src/generated/api/AgentsByDidsRequest.ts +3 -0
- package/src/generated/api/CallSessionInfo.ts +20 -0
- package/src/generated/api/DiscardBatchRequest.ts +3 -0
- package/src/generated/api/Events.ts +14 -3
- package/src/generated/api/FlowStateChangedEvent.ts +36 -0
- package/src/generated/api/FlowStateEntry.ts +18 -0
- package/src/generated/api/IceServer.ts +19 -0
- package/src/generated/api/OnlineAgent.ts +6 -1
- package/src/generated/api/PerspectiveDiscardBatchParams.ts +3 -0
- package/src/generated/api/PerspectiveFlowFiredParams.ts +7 -0
- package/src/generated/api/PerspectiveFlowStatesParams.ts +11 -0
- package/src/generated/api/PerspectiveGetAllShaclParams.ts +6 -0
- package/src/generated/api/PerspectiveModelQueryParams.ts +5 -1
- package/src/generated/api/PerspectiveRemoveSubjectParams.ts +3 -0
- package/src/generated/api/PerspectiveResynced.ts +7 -0
- package/src/generated/api/PerspectiveSubscribed.ts +8 -0
- package/src/generated/api/PerspectiveUpdateSubjectParams.ts +7 -0
- package/src/generated/api/QuerySubscriptionUpdate.ts +10 -0
- package/src/generated/api/QuerySubscriptionUpdateEvent.ts +9 -0
- package/src/generated/api/QueryUpdatesLagged.ts +7 -0
- package/src/generated/api/RemoveSubjectRequest.ts +7 -0
- package/src/generated/api/ResyncSubscriptionRequest.ts +3 -0
- package/src/generated/api/RpcMethods.ts +68 -8
- package/src/generated/api/SfuAddIceCandidateParams.ts +7 -0
- package/src/generated/api/SfuAnswerServerOfferParams.ts +7 -0
- package/src/generated/api/SfuCallJoinParams.ts +13 -0
- package/src/generated/api/SfuCallRenegotiationOffer.ts +29 -0
- package/src/generated/api/SfuCascadePipe.ts +3 -0
- package/src/generated/api/SfuCascadeStatus.ts +7 -0
- package/src/generated/api/SfuConfig.ts +53 -0
- package/src/generated/api/SfuDataMessage.ts +23 -0
- package/src/generated/api/SfuEnsureMembershipParams.ts +3 -0
- package/src/generated/api/SfuMigrateEvent.ts +20 -0
- package/src/generated/api/{KeepAliveQueryRequest.ts → SfuNeighbourhoodParams.ts} +1 -1
- package/src/generated/api/SfuParticipantQualityPreference.ts +6 -0
- package/src/generated/api/{PerspectiveSubscribeQueryResult.ts → SfuPerspectiveParams.ts} +4 -1
- package/src/generated/api/SfuQualityPreferenceParams.ts +7 -0
- package/src/generated/api/SfuRoomInfo.ts +7 -0
- package/src/generated/api/SfuRoomParams.ts +3 -0
- package/src/generated/api/SfuRoomParticipantInfo.ts +8 -0
- package/src/generated/api/SfuRoomRoster.ts +12 -0
- package/src/generated/api/SfuSendDataParams.ts +7 -0
- package/src/generated/api/SfuSetConfigParams.ts +4 -0
- package/src/generated/api/SfuStatus.ts +24 -0
- package/src/generated/api/TrackMapEntry.ts +18 -0
- package/src/generated/api/UpdateSubjectRequest.ts +10 -0
- package/src/generated/api/index.ts +3 -0
- package/src/index.ts +7 -0
- package/src/model/Ad4mModel.test.ts +255 -231
- package/src/model/Ad4mModel.ts +271 -4
- package/src/model/ModelQueryBuilder.ts +103 -310
- package/src/model/abstract-classes.test.ts +225 -0
- package/src/model/decorators.ts +81 -0
- package/src/model/shacl-gen.ts +13 -0
- package/src/model/types.ts +7 -0
- package/src/neighbourhood/MeshManager.test.ts +2640 -0
- package/src/neighbourhood/MeshManager.ts +1350 -0
- package/src/neighbourhood/NeighbourhoodClient.ts +271 -0
- package/src/neighbourhood/NeighbourhoodProxy.test.ts +23 -0
- package/src/neighbourhood/NeighbourhoodProxy.ts +247 -1
- package/src/neighbourhood/Session.test.ts +800 -0
- package/src/neighbourhood/Session.ts +525 -0
- package/src/neighbourhood/SfuManager.test.ts +677 -0
- package/src/neighbourhood/SfuManager.ts +803 -0
- package/src/neighbourhood/SfuTypes.ts +40 -0
- package/src/perspectives/FlowInstance.ts +108 -31
- package/src/perspectives/FlowModels.ts +8 -18
- package/src/perspectives/LiveQuery.test.ts +197 -0
- package/src/perspectives/LiveQuery.ts +189 -0
- package/src/perspectives/PerspectiveClient.ts +51 -51
- package/src/perspectives/PerspectiveProxy.test.ts +85 -401
- package/src/perspectives/PerspectiveProxy.ts +126 -536
- package/src/perspectives/TextContent.test.ts +123 -0
- package/src/perspectives/TextContent.ts +36 -0
- package/src/perspectives/WakerSubscriptionManager.test.ts +88 -6
- package/src/perspectives/WakerSubscriptionManager.ts +69 -18
- package/src/shacl/SHACLFlow.ts +7 -4
- package/src/shacl/SHACLShape.test.ts +2 -1
- package/src/shacl/SHACLShape.ts +49 -0
- package/lib/src/generated/api/KeepAliveQueryRequest.d.ts +0 -3
- package/lib/src/generated/api/PerspectiveModelSubscribeResult.d.ts +0 -7
- package/lib/src/generated/api/PerspectiveQuerySubscriptionFilter.d.ts +0 -6
- package/lib/src/generated/api/PerspectiveSubscribeQueryResult.d.ts +0 -4
- package/src/generated/api/PerspectiveModelSubscribeResult.ts +0 -6
- package/src/generated/api/PerspectiveQuerySubscriptionFilter.ts +0 -3
- /package/lib/src/generated/api/{KeepAliveQueryRequest.js → AgentsByDidsRequest.js} +0 -0
- /package/lib/src/generated/api/{PerspectiveModelSubscribeResult.js → CallSessionInfo.js} +0 -0
- /package/lib/src/generated/api/{PerspectiveQuerySubscriptionFilter.js → DiscardBatchRequest.js} +0 -0
- /package/lib/src/generated/api/{PerspectiveSubscribeQueryResult.js → FlowStateChangedEvent.js} +0 -0
|
@@ -4,6 +4,7 @@ import { DID } from "../DID";
|
|
|
4
4
|
import { OnlineAgent, TelepresenceSignalCallback } from "../language/Language";
|
|
5
5
|
import { Perspective, PerspectiveExpression, PerspectiveUnsignedInput } from "../perspectives/Perspective";
|
|
6
6
|
import { PerspectiveHandle } from "../perspectives/PerspectiveHandle";
|
|
7
|
+
import type { CallSessionInfo, SfuCallRenegotiationOffer, SfuCascadeStatus, SfuConfig, SfuDataMessage, SfuMigrateEvent, SfuParticipantQualityPreference, SfuQualityPreference, SfuRoomInfo, SfuRoomRoster, SfuStatus } from "./SfuTypes";
|
|
7
8
|
export declare class NeighbourhoodClient {
|
|
8
9
|
#private;
|
|
9
10
|
constructor(baseUrl: string, token?: string, sharedApiClient?: ApiClient);
|
|
@@ -12,6 +13,8 @@ export declare class NeighbourhoodClient {
|
|
|
12
13
|
otherAgents(perspectiveUUID: string): Promise<DID[]>;
|
|
13
14
|
hasTelepresenceAdapter(perspectiveUUID: string): Promise<boolean>;
|
|
14
15
|
onlineAgents(perspectiveUUID: string): Promise<OnlineAgent[]>;
|
|
16
|
+
/** The caller's own online status, as it last set it on this executor, or `null`. */
|
|
17
|
+
ownOnlineStatus(perspectiveUUID: string): Promise<PerspectiveExpression | null>;
|
|
15
18
|
setOnlineStatus(perspectiveUUID: string, status: Perspective): Promise<boolean>;
|
|
16
19
|
setOnlineStatusU(perspectiveUUID: string, status: PerspectiveUnsignedInput): Promise<boolean>;
|
|
17
20
|
sendSignal(perspectiveUUID: string, remoteAgentDid: string, payload: Perspective): Promise<boolean>;
|
|
@@ -22,4 +25,92 @@ export declare class NeighbourhoodClient {
|
|
|
22
25
|
subscribeToSignals(perspectiveUUID: string): Promise<void>;
|
|
23
26
|
addSignalHandler(perspectiveUUID: string, handler: TelepresenceSignalCallback): Promise<void>;
|
|
24
27
|
removeSignalHandler(perspectiveUUID: string, handler: TelepresenceSignalCallback): void;
|
|
28
|
+
sfuStartRoom(neighbourhoodUrl: string, roomName: string): Promise<SfuRoomInfo>;
|
|
29
|
+
sfuStopRoom(neighbourhoodUrl: string, roomName: string): Promise<boolean>;
|
|
30
|
+
sfuListRooms(): Promise<SfuRoomInfo[]>;
|
|
31
|
+
sfuCallJoin(neighbourhoodUrl: string, roomName: string, sdpOffer: string): Promise<CallSessionInfo>;
|
|
32
|
+
sfuCallLeave(neighbourhoodUrl: string, roomName: string): Promise<boolean>;
|
|
33
|
+
sfuCallSetQualityPreference(neighbourhoodUrl: string, roomName: string, preference: SfuQualityPreference): Promise<boolean>;
|
|
34
|
+
sfuCallAnswerServerOffer(neighbourhoodUrl: string, roomName: string, sdpAnswer: string): Promise<boolean>;
|
|
35
|
+
sfuGetConfig(neighbourhoodUrl: string): Promise<SfuConfig>;
|
|
36
|
+
sfuSetConfig(neighbourhoodUrl: string, config: SfuConfig): Promise<boolean>;
|
|
37
|
+
sfuPeerForNeighbourhood(neighbourhoodUrl: string): Promise<string | null>;
|
|
38
|
+
sfuPeersForNeighbourhood(neighbourhoodUrl: string): Promise<string[]>;
|
|
39
|
+
/**
|
|
40
|
+
* Add a remote ICE candidate to an existing SFU call. Enables
|
|
41
|
+
* trickle ICE: the client sends its SDP offer immediately after
|
|
42
|
+
* `setLocalDescription` and then calls this method for each
|
|
43
|
+
* candidate as it arrives, rather than waiting for gathering to
|
|
44
|
+
* complete (which can take up to 8 seconds on restrictive
|
|
45
|
+
* networks).
|
|
46
|
+
*/
|
|
47
|
+
sfuAddIceCandidate(neighbourhoodUrl: string, roomName: string, candidate: string): Promise<boolean>;
|
|
48
|
+
/**
|
|
49
|
+
* Send data through the SFU to all other participants in the room.
|
|
50
|
+
* The server relays it to their matching data channel and
|
|
51
|
+
* publishes it as an `sfu-data` event.
|
|
52
|
+
*/
|
|
53
|
+
sfuSendData(neighbourhoodUrl: string, roomName: string, channelLabel: string, data: string, binary?: boolean): Promise<boolean>;
|
|
54
|
+
/**
|
|
55
|
+
* Subscribe to SFU data channel messages. Returns an unsubscribe
|
|
56
|
+
* function. Messages arrive for every participant in the room;
|
|
57
|
+
* filter by `senderDid` if needed.
|
|
58
|
+
*/
|
|
59
|
+
subscribeSfuDataChannel(callback: (message: SfuDataMessage) => void): () => void;
|
|
60
|
+
/** Subscribe to the rosters of the call rooms this agent is in: who is in each, whenever that changes. */
|
|
61
|
+
subscribeSfuRoomRoster(callback: (roster: SfuRoomRoster) => void): () => void;
|
|
62
|
+
/**
|
|
63
|
+
* Subscribe to server-pushed SFU SDP renegotiation offers. The
|
|
64
|
+
* server publishes an `sfu-call-renegotiation-offer` event every
|
|
65
|
+
* time the relay's outbound track set changes for `targetDid`.
|
|
66
|
+
* Callers apply the offer to their `RTCPeerConnection`, generate an
|
|
67
|
+
* answer, and post it via `sfuCallAnswerServerOffer`.
|
|
68
|
+
*
|
|
69
|
+
* The executor already sends each socket only its own DID's offers;
|
|
70
|
+
* this subscription additionally filters on `targetDid` for safety.
|
|
71
|
+
* Returns an unsubscribe function.
|
|
72
|
+
*/
|
|
73
|
+
subscribeSfuCallRenegotiationOffer(targetDid: string, callback: (payload: SfuCallRenegotiationOffer) => void): () => void;
|
|
74
|
+
/**
|
|
75
|
+
* Subscribe to cascade rebalance migration events for `targetDid`.
|
|
76
|
+
* The server publishes an `sfu-migrate` event when the cascade
|
|
77
|
+
* rebalancer decides a participant should move to a less-loaded
|
|
78
|
+
* node. Returns an unsubscribe function.
|
|
79
|
+
*/
|
|
80
|
+
subscribeSfuMigrateEvent(targetDid: string, callback: (payload: SfuMigrateEvent) => void): () => void;
|
|
81
|
+
/**
|
|
82
|
+
* Whether every member of the neighbourhood is hosted on this
|
|
83
|
+
* executor — the members its SFU can serve. A call's "auto" topology
|
|
84
|
+
* uses the SFU only then: anyone else could not join the same room.
|
|
85
|
+
*
|
|
86
|
+
* @param perspectiveId The neighbourhood's perspective handle UUID.
|
|
87
|
+
*/
|
|
88
|
+
sfuServesAllMembers(perspectiveId: string): Promise<boolean>;
|
|
89
|
+
/** The calling agent's own DID — the user's, for a user token. */
|
|
90
|
+
callerDid(): Promise<string | null>;
|
|
91
|
+
/**
|
|
92
|
+
* Read-only: SFU service status including public reachability.
|
|
93
|
+
* Returns whether this executor can relay media to remote
|
|
94
|
+
* participants (public), sits behind NAT (nat), or could not
|
|
95
|
+
* determine its reachability (unknown).
|
|
96
|
+
*/
|
|
97
|
+
sfuStatus(): Promise<SfuStatus>;
|
|
98
|
+
/**
|
|
99
|
+
* Read-only: how many SFU↔SFU pipe transports are fully established,
|
|
100
|
+
* plus the list of pipes. Useful for diagnostics and wind-tunnel
|
|
101
|
+
* assertions.
|
|
102
|
+
*/
|
|
103
|
+
sfuCascadeStatus(): Promise<SfuCascadeStatus>;
|
|
104
|
+
/**
|
|
105
|
+
* Read-only: per-participant quality preferences the SFU event loop
|
|
106
|
+
* currently holds. Returns `[{participantId, preference}, ...]`.
|
|
107
|
+
*/
|
|
108
|
+
sfuQualityPreferences(): Promise<SfuParticipantQualityPreference[]>;
|
|
109
|
+
/**
|
|
110
|
+
* Register a DID as a neighbourhood member on this executor.
|
|
111
|
+
* In production the neighbourhood join flow handles this
|
|
112
|
+
* automatically; this RPC exists for test harnesses and bridge
|
|
113
|
+
* deployments.
|
|
114
|
+
*/
|
|
115
|
+
sfuEnsureMembership(neighbourhoodUrl: string, did: string): Promise<boolean>;
|
|
25
116
|
}
|
|
@@ -38,6 +38,11 @@ export class NeighbourhoodClient {
|
|
|
38
38
|
const agents = await __classPrivateFieldGet(this, _NeighbourhoodClient_apiClient, "f").call('neighbourhood.onlineAgents', { uuid: perspectiveUUID });
|
|
39
39
|
return agents.map(({ did, status }) => ({ did, status: PerspectiveExpression.fromWire(status) }));
|
|
40
40
|
}
|
|
41
|
+
/** The caller's own online status, as it last set it on this executor, or `null`. */
|
|
42
|
+
async ownOnlineStatus(perspectiveUUID) {
|
|
43
|
+
const status = await __classPrivateFieldGet(this, _NeighbourhoodClient_apiClient, "f").call('neighbourhood.ownOnlineStatus', { uuid: perspectiveUUID });
|
|
44
|
+
return status ? PerspectiveExpression.fromWire(status) : null;
|
|
45
|
+
}
|
|
41
46
|
async setOnlineStatus(perspectiveUUID, status) {
|
|
42
47
|
return __classPrivateFieldGet(this, _NeighbourhoodClient_apiClient, "f").call('neighbourhood.setOnlineStatus', { uuid: perspectiveUUID, status: Perspective.toWire(status) });
|
|
43
48
|
}
|
|
@@ -111,5 +116,196 @@ export class NeighbourhoodClient {
|
|
|
111
116
|
}
|
|
112
117
|
}
|
|
113
118
|
}
|
|
119
|
+
// ── SFU (Selective Forwarding Unit) ─────────────────────────────────
|
|
120
|
+
//
|
|
121
|
+
// These wrap the `sfu.*` WS RPC handlers in
|
|
122
|
+
// `rust-executor/src/api/sfu_ws.rs`. The transport is the same
|
|
123
|
+
// shared `ApiClient`; the only twist is that `callJoin` returns a
|
|
124
|
+
// structured `CallSessionInfo` (SDP answer + optional cascade
|
|
125
|
+
// redirect + stream mapping).
|
|
126
|
+
async sfuStartRoom(neighbourhoodUrl, roomName) {
|
|
127
|
+
return __classPrivateFieldGet(this, _NeighbourhoodClient_apiClient, "f").call("sfu.startRoom", { neighbourhoodUrl, roomName });
|
|
128
|
+
}
|
|
129
|
+
async sfuStopRoom(neighbourhoodUrl, roomName) {
|
|
130
|
+
return __classPrivateFieldGet(this, _NeighbourhoodClient_apiClient, "f").call("sfu.stopRoom", { neighbourhoodUrl, roomName });
|
|
131
|
+
}
|
|
132
|
+
async sfuListRooms() {
|
|
133
|
+
return __classPrivateFieldGet(this, _NeighbourhoodClient_apiClient, "f").call("sfu.listRooms", {});
|
|
134
|
+
}
|
|
135
|
+
async sfuCallJoin(neighbourhoodUrl, roomName, sdpOffer) {
|
|
136
|
+
return __classPrivateFieldGet(this, _NeighbourhoodClient_apiClient, "f").call("sfu.callJoin", {
|
|
137
|
+
neighbourhoodUrl,
|
|
138
|
+
roomName,
|
|
139
|
+
sdpOffer,
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
async sfuCallLeave(neighbourhoodUrl, roomName) {
|
|
143
|
+
return __classPrivateFieldGet(this, _NeighbourhoodClient_apiClient, "f").call("sfu.callLeave", { neighbourhoodUrl, roomName });
|
|
144
|
+
}
|
|
145
|
+
async sfuCallSetQualityPreference(neighbourhoodUrl, roomName, preference) {
|
|
146
|
+
return __classPrivateFieldGet(this, _NeighbourhoodClient_apiClient, "f").call("sfu.callSetQualityPreference", {
|
|
147
|
+
neighbourhoodUrl,
|
|
148
|
+
roomName,
|
|
149
|
+
preference,
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
async sfuCallAnswerServerOffer(neighbourhoodUrl, roomName, sdpAnswer) {
|
|
153
|
+
return __classPrivateFieldGet(this, _NeighbourhoodClient_apiClient, "f").call("sfu.callAnswerServerOffer", {
|
|
154
|
+
neighbourhoodUrl,
|
|
155
|
+
roomName,
|
|
156
|
+
sdpAnswer,
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
async sfuGetConfig(neighbourhoodUrl) {
|
|
160
|
+
return __classPrivateFieldGet(this, _NeighbourhoodClient_apiClient, "f").call("sfu.getConfig", { neighbourhoodUrl });
|
|
161
|
+
}
|
|
162
|
+
async sfuSetConfig(neighbourhoodUrl, config) {
|
|
163
|
+
return __classPrivateFieldGet(this, _NeighbourhoodClient_apiClient, "f").call("sfu.setConfig", { neighbourhoodUrl, config });
|
|
164
|
+
}
|
|
165
|
+
async sfuPeerForNeighbourhood(neighbourhoodUrl) {
|
|
166
|
+
return __classPrivateFieldGet(this, _NeighbourhoodClient_apiClient, "f").call("sfu.sfuPeerForNeighbourhood", { neighbourhoodUrl });
|
|
167
|
+
}
|
|
168
|
+
async sfuPeersForNeighbourhood(neighbourhoodUrl) {
|
|
169
|
+
return __classPrivateFieldGet(this, _NeighbourhoodClient_apiClient, "f").call("sfu.sfuPeersForNeighbourhood", { neighbourhoodUrl });
|
|
170
|
+
}
|
|
171
|
+
// ── Trickle ICE ───────────────────────────────────────────────────
|
|
172
|
+
/**
|
|
173
|
+
* Add a remote ICE candidate to an existing SFU call. Enables
|
|
174
|
+
* trickle ICE: the client sends its SDP offer immediately after
|
|
175
|
+
* `setLocalDescription` and then calls this method for each
|
|
176
|
+
* candidate as it arrives, rather than waiting for gathering to
|
|
177
|
+
* complete (which can take up to 8 seconds on restrictive
|
|
178
|
+
* networks).
|
|
179
|
+
*/
|
|
180
|
+
async sfuAddIceCandidate(neighbourhoodUrl, roomName, candidate) {
|
|
181
|
+
return __classPrivateFieldGet(this, _NeighbourhoodClient_apiClient, "f").call("sfu.addIceCandidate", {
|
|
182
|
+
neighbourhoodUrl,
|
|
183
|
+
roomName,
|
|
184
|
+
candidate,
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
// ── Data channel relay ────────────────────────────────────────────
|
|
188
|
+
/**
|
|
189
|
+
* Send data through the SFU to all other participants in the room.
|
|
190
|
+
* The server relays it to their matching data channel and
|
|
191
|
+
* publishes it as an `sfu-data` event.
|
|
192
|
+
*/
|
|
193
|
+
async sfuSendData(neighbourhoodUrl, roomName, channelLabel, data, binary = false) {
|
|
194
|
+
return __classPrivateFieldGet(this, _NeighbourhoodClient_apiClient, "f").call("sfu.sendData", {
|
|
195
|
+
neighbourhoodUrl,
|
|
196
|
+
roomName,
|
|
197
|
+
channelLabel,
|
|
198
|
+
data,
|
|
199
|
+
binary,
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Subscribe to SFU data channel messages. Returns an unsubscribe
|
|
204
|
+
* function. Messages arrive for every participant in the room;
|
|
205
|
+
* filter by `senderDid` if needed.
|
|
206
|
+
*/
|
|
207
|
+
subscribeSfuDataChannel(callback) {
|
|
208
|
+
// A fresh handler per call: `on` merges a repeated handler, and
|
|
209
|
+
// each subscription must own its unsubscribe.
|
|
210
|
+
return __classPrivateFieldGet(this, _NeighbourhoodClient_apiClient, "f").on("sfu-data", (message) => callback(message));
|
|
211
|
+
}
|
|
212
|
+
/** Subscribe to the rosters of the call rooms this agent is in: who is in each, whenever that changes. */
|
|
213
|
+
subscribeSfuRoomRoster(callback) {
|
|
214
|
+
return __classPrivateFieldGet(this, _NeighbourhoodClient_apiClient, "f").on("sfu-room-roster", (roster) => callback(roster));
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* Subscribe to server-pushed SFU SDP renegotiation offers. The
|
|
218
|
+
* server publishes an `sfu-call-renegotiation-offer` event every
|
|
219
|
+
* time the relay's outbound track set changes for `targetDid`.
|
|
220
|
+
* Callers apply the offer to their `RTCPeerConnection`, generate an
|
|
221
|
+
* answer, and post it via `sfuCallAnswerServerOffer`.
|
|
222
|
+
*
|
|
223
|
+
* The executor already sends each socket only its own DID's offers;
|
|
224
|
+
* this subscription additionally filters on `targetDid` for safety.
|
|
225
|
+
* Returns an unsubscribe function.
|
|
226
|
+
*/
|
|
227
|
+
subscribeSfuCallRenegotiationOffer(targetDid, callback) {
|
|
228
|
+
return __classPrivateFieldGet(this, _NeighbourhoodClient_apiClient, "f").on("sfu-call-renegotiation-offer", (event) => {
|
|
229
|
+
if (event.targetDid !== targetDid)
|
|
230
|
+
return;
|
|
231
|
+
callback({
|
|
232
|
+
targetDid: event.targetDid,
|
|
233
|
+
neighbourhoodUrl: event.neighbourhoodUrl,
|
|
234
|
+
roomName: event.roomName,
|
|
235
|
+
sdpOffer: event.sdpOffer,
|
|
236
|
+
trackMapping: event.trackMapping,
|
|
237
|
+
});
|
|
238
|
+
});
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* Subscribe to cascade rebalance migration events for `targetDid`.
|
|
242
|
+
* The server publishes an `sfu-migrate` event when the cascade
|
|
243
|
+
* rebalancer decides a participant should move to a less-loaded
|
|
244
|
+
* node. Returns an unsubscribe function.
|
|
245
|
+
*/
|
|
246
|
+
subscribeSfuMigrateEvent(targetDid, callback) {
|
|
247
|
+
return __classPrivateFieldGet(this, _NeighbourhoodClient_apiClient, "f").on("sfu-migrate", (event) => {
|
|
248
|
+
if (event.targetDid !== targetDid)
|
|
249
|
+
return;
|
|
250
|
+
callback({
|
|
251
|
+
targetDid: event.targetDid,
|
|
252
|
+
neighbourhoodUrl: event.neighbourhoodUrl,
|
|
253
|
+
roomName: event.roomName,
|
|
254
|
+
migrateToDid: event.migrateToDid,
|
|
255
|
+
});
|
|
256
|
+
});
|
|
257
|
+
}
|
|
258
|
+
// ── SFU topology ───────────────────────────────────────────────────
|
|
259
|
+
/**
|
|
260
|
+
* Whether every member of the neighbourhood is hosted on this
|
|
261
|
+
* executor — the members its SFU can serve. A call's "auto" topology
|
|
262
|
+
* uses the SFU only then: anyone else could not join the same room.
|
|
263
|
+
*
|
|
264
|
+
* @param perspectiveId The neighbourhood's perspective handle UUID.
|
|
265
|
+
*/
|
|
266
|
+
async sfuServesAllMembers(perspectiveId) {
|
|
267
|
+
return __classPrivateFieldGet(this, _NeighbourhoodClient_apiClient, "f").call("sfu.servesAllMembers", { uuid: perspectiveId });
|
|
268
|
+
}
|
|
269
|
+
// ── SFU diagnostic / test-harness endpoints ────────────────────────
|
|
270
|
+
/** The calling agent's own DID — the user's, for a user token. */
|
|
271
|
+
async callerDid() {
|
|
272
|
+
return (await __classPrivateFieldGet(this, _NeighbourhoodClient_apiClient, "f").call("agent.status", {})).did;
|
|
273
|
+
}
|
|
274
|
+
/**
|
|
275
|
+
* Read-only: SFU service status including public reachability.
|
|
276
|
+
* Returns whether this executor can relay media to remote
|
|
277
|
+
* participants (public), sits behind NAT (nat), or could not
|
|
278
|
+
* determine its reachability (unknown).
|
|
279
|
+
*/
|
|
280
|
+
async sfuStatus() {
|
|
281
|
+
return __classPrivateFieldGet(this, _NeighbourhoodClient_apiClient, "f").call("sfu.status", {});
|
|
282
|
+
}
|
|
283
|
+
/**
|
|
284
|
+
* Read-only: how many SFU↔SFU pipe transports are fully established,
|
|
285
|
+
* plus the list of pipes. Useful for diagnostics and wind-tunnel
|
|
286
|
+
* assertions.
|
|
287
|
+
*/
|
|
288
|
+
async sfuCascadeStatus() {
|
|
289
|
+
return __classPrivateFieldGet(this, _NeighbourhoodClient_apiClient, "f").call("sfu.cascadeStatus", {});
|
|
290
|
+
}
|
|
291
|
+
/**
|
|
292
|
+
* Read-only: per-participant quality preferences the SFU event loop
|
|
293
|
+
* currently holds. Returns `[{participantId, preference}, ...]`.
|
|
294
|
+
*/
|
|
295
|
+
async sfuQualityPreferences() {
|
|
296
|
+
return __classPrivateFieldGet(this, _NeighbourhoodClient_apiClient, "f").call("sfu.qualityPreferences", {});
|
|
297
|
+
}
|
|
298
|
+
/**
|
|
299
|
+
* Register a DID as a neighbourhood member on this executor.
|
|
300
|
+
* In production the neighbourhood join flow handles this
|
|
301
|
+
* automatically; this RPC exists for test harnesses and bridge
|
|
302
|
+
* deployments.
|
|
303
|
+
*/
|
|
304
|
+
async sfuEnsureMembership(neighbourhoodUrl, did) {
|
|
305
|
+
return __classPrivateFieldGet(this, _NeighbourhoodClient_apiClient, "f").call("sfu.ensureMembership", {
|
|
306
|
+
neighbourhoodUrl,
|
|
307
|
+
did,
|
|
308
|
+
});
|
|
309
|
+
}
|
|
114
310
|
}
|
|
115
311
|
_NeighbourhoodClient_apiClient = new WeakMap(), _NeighbourhoodClient_signalHandlers = new WeakMap(), _NeighbourhoodClient_signalUnsubscribers = new WeakMap();
|
|
@@ -2,18 +2,72 @@ import { DID } from "../DID";
|
|
|
2
2
|
import { OnlineAgent } from "../language/Language";
|
|
3
3
|
import { Perspective, PerspectiveExpression, PerspectiveUnsignedInput } from "../perspectives/Perspective";
|
|
4
4
|
import { NeighbourhoodClient } from "./NeighbourhoodClient";
|
|
5
|
+
import type { CallSessionInfo, SfuCallRenegotiationOffer, SfuCascadeStatus, SfuConfig, SfuDataMessage, SfuMigrateEvent, SfuParticipantQualityPreference, SfuQualityPreference, SfuRoomInfo } from "./SfuTypes";
|
|
6
|
+
import { type Session, type SessionCreateOptions } from "./Session";
|
|
5
7
|
export declare class NeighbourhoodProxy {
|
|
6
8
|
#private;
|
|
7
|
-
constructor(client: NeighbourhoodClient, pID: string);
|
|
9
|
+
constructor(client: NeighbourhoodClient, pID: string, agentDid?: string);
|
|
10
|
+
/** List DIDs of agents who have joined this neighbourhood. */
|
|
8
11
|
otherAgents(): Promise<DID[]>;
|
|
12
|
+
/** Check whether the neighbourhood's link language supports telepresence. */
|
|
9
13
|
hasTelepresenceAdapter(): Promise<boolean>;
|
|
14
|
+
/** List agents currently online in this neighbourhood. */
|
|
10
15
|
onlineAgents(): Promise<OnlineAgent[]>;
|
|
16
|
+
/** This agent's own online status, as it last set it on this executor, or `null`. */
|
|
17
|
+
ownOnlineStatus(): Promise<PerspectiveExpression | null>;
|
|
18
|
+
/** Set this agent's online status with a signed perspective payload. */
|
|
11
19
|
setOnlineStatus(status: Perspective): Promise<boolean>;
|
|
20
|
+
/** Set this agent's online status with an unsigned perspective payload. */
|
|
12
21
|
setOnlineStatusU(status: PerspectiveUnsignedInput): Promise<boolean>;
|
|
22
|
+
/** Send a signed signal to a specific remote agent via the link language. */
|
|
13
23
|
sendSignal(remoteAgentDid: string, payload: Perspective): Promise<boolean>;
|
|
24
|
+
/** Send an unsigned signal to a specific remote agent via the link language. */
|
|
14
25
|
sendSignalU(remoteAgentDid: string, payload: PerspectiveUnsignedInput): Promise<boolean>;
|
|
26
|
+
/** Broadcast a signed signal to all agents in the neighbourhood. */
|
|
15
27
|
sendBroadcast(payload: Perspective, loopback?: boolean): Promise<boolean>;
|
|
28
|
+
/** Broadcast an unsigned signal to all agents in the neighbourhood. */
|
|
16
29
|
sendBroadcastU(payload: PerspectiveUnsignedInput, loopback?: boolean): Promise<boolean>;
|
|
30
|
+
/** Register a handler for incoming telepresence signals. */
|
|
17
31
|
addSignalHandler(handler: (payload: PerspectiveExpression) => void): Promise<void>;
|
|
32
|
+
/** Remove a previously registered signal handler. */
|
|
18
33
|
removeSignalHandler(handler: (payload: PerspectiveExpression) => void): void;
|
|
34
|
+
/** Active sessions in this neighbourhood. Destroyed sessions remove themselves. */
|
|
35
|
+
get sessions(): ReadonlyArray<Session>;
|
|
36
|
+
/**
|
|
37
|
+
* Create a WebRTC media session. Call `session.join(localStream)` to connect.
|
|
38
|
+
*
|
|
39
|
+
* Fetches the local executor's SFU status (cached after the first
|
|
40
|
+
* call): with `topology: "auto"`, a session uses the SFU only when it
|
|
41
|
+
* is public and hosts every member of the neighbourhood.
|
|
42
|
+
*/
|
|
43
|
+
createSession(roomName: string, options?: SessionCreateOptions): Promise<Session>;
|
|
44
|
+
sfuConfig(neighbourhoodUrl: string): Promise<SfuConfig>;
|
|
45
|
+
setSfuConfig(neighbourhoodUrl: string, config: SfuConfig): Promise<boolean>;
|
|
46
|
+
sfuPeer(neighbourhoodUrl: string): Promise<string | null>;
|
|
47
|
+
sfuPeers(neighbourhoodUrl: string): Promise<string[]>;
|
|
48
|
+
sfuStartRoom(neighbourhoodUrl: string, roomName: string): Promise<SfuRoomInfo>;
|
|
49
|
+
sfuStopRoom(neighbourhoodUrl: string, roomName: string): Promise<boolean>;
|
|
50
|
+
sfuListRooms(): Promise<SfuRoomInfo[]>;
|
|
51
|
+
callJoin(neighbourhoodUrl: string, roomName: string, sdpOffer: string): Promise<CallSessionInfo>;
|
|
52
|
+
callLeave(neighbourhoodUrl: string, roomName: string): Promise<boolean>;
|
|
53
|
+
callSetQualityPreference(neighbourhoodUrl: string, roomName: string, preference: SfuQualityPreference): Promise<boolean>;
|
|
54
|
+
callAnswerServerOffer(neighbourhoodUrl: string, roomName: string, sdpAnswer: string): Promise<boolean>;
|
|
55
|
+
/**
|
|
56
|
+
* Subscribe to server-pushed renegotiation offers for `targetDid`.
|
|
57
|
+
* Returns an unsubscribe function. See
|
|
58
|
+
* `NeighbourhoodClient.subscribeSfuCallRenegotiationOffer` for the
|
|
59
|
+
* underlying mechanism.
|
|
60
|
+
*/
|
|
61
|
+
subscribeCallRenegotiationOffer(targetDid: string, callback: (payload: SfuCallRenegotiationOffer) => void): () => void;
|
|
62
|
+
/**
|
|
63
|
+
* Subscribe to cascade rebalance migration events for `targetDid`.
|
|
64
|
+
* Returns an unsubscribe function.
|
|
65
|
+
*/
|
|
66
|
+
subscribeMigrateEvent(targetDid: string, callback: (event: SfuMigrateEvent) => void): () => void;
|
|
67
|
+
addIceCandidate(neighbourhoodUrl: string, roomName: string, candidate: string): Promise<boolean>;
|
|
68
|
+
sendData(neighbourhoodUrl: string, roomName: string, channelLabel: string, data: string, binary?: boolean): Promise<boolean>;
|
|
69
|
+
subscribeDataChannel(callback: (message: SfuDataMessage) => void): () => void;
|
|
70
|
+
sfuCascadeStatus(): Promise<SfuCascadeStatus>;
|
|
71
|
+
sfuQualityPreferences(): Promise<SfuParticipantQualityPreference[]>;
|
|
72
|
+
sfuEnsureMembership(neighbourhoodUrl: string, did: string): Promise<boolean>;
|
|
19
73
|
}
|
|
@@ -9,46 +9,213 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
9
9
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
10
10
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
11
11
|
};
|
|
12
|
-
var _NeighbourhoodProxy_client, _NeighbourhoodProxy_pID;
|
|
12
|
+
var _NeighbourhoodProxy_client, _NeighbourhoodProxy_pID, _NeighbourhoodProxy_agentDid, _NeighbourhoodProxy_sessions, _NeighbourhoodProxy_sfuStatusCache;
|
|
13
|
+
import { createSession } from "./Session";
|
|
14
|
+
import { createTelepresenceChannel } from "./MeshManager";
|
|
13
15
|
export class NeighbourhoodProxy {
|
|
14
|
-
constructor(client, pID) {
|
|
16
|
+
constructor(client, pID, agentDid = "") {
|
|
15
17
|
_NeighbourhoodProxy_client.set(this, void 0);
|
|
16
18
|
_NeighbourhoodProxy_pID.set(this, void 0);
|
|
19
|
+
_NeighbourhoodProxy_agentDid.set(this, void 0);
|
|
20
|
+
_NeighbourhoodProxy_sessions.set(this, []
|
|
21
|
+
/** Cached SFU status — fetched once per proxy lifetime. */
|
|
22
|
+
);
|
|
23
|
+
/** Cached SFU status — fetched once per proxy lifetime. */
|
|
24
|
+
_NeighbourhoodProxy_sfuStatusCache.set(this, null);
|
|
17
25
|
__classPrivateFieldSet(this, _NeighbourhoodProxy_client, client, "f");
|
|
18
26
|
__classPrivateFieldSet(this, _NeighbourhoodProxy_pID, pID, "f");
|
|
27
|
+
__classPrivateFieldSet(this, _NeighbourhoodProxy_agentDid, agentDid, "f");
|
|
19
28
|
}
|
|
29
|
+
// ── Telepresence ────────────────────────────────────────────────────
|
|
30
|
+
//
|
|
31
|
+
// Link-language ephemeral messaging: presence, signalling, broadcast.
|
|
32
|
+
// Routes through the neighbourhood's link language.
|
|
33
|
+
/** List DIDs of agents who have joined this neighbourhood. */
|
|
20
34
|
async otherAgents() {
|
|
21
35
|
return await __classPrivateFieldGet(this, _NeighbourhoodProxy_client, "f").otherAgents(__classPrivateFieldGet(this, _NeighbourhoodProxy_pID, "f"));
|
|
22
36
|
}
|
|
37
|
+
/** Check whether the neighbourhood's link language supports telepresence. */
|
|
23
38
|
async hasTelepresenceAdapter() {
|
|
24
39
|
return await __classPrivateFieldGet(this, _NeighbourhoodProxy_client, "f").hasTelepresenceAdapter(__classPrivateFieldGet(this, _NeighbourhoodProxy_pID, "f"));
|
|
25
40
|
}
|
|
41
|
+
/** List agents currently online in this neighbourhood. */
|
|
26
42
|
async onlineAgents() {
|
|
27
43
|
return await __classPrivateFieldGet(this, _NeighbourhoodProxy_client, "f").onlineAgents(__classPrivateFieldGet(this, _NeighbourhoodProxy_pID, "f"));
|
|
28
44
|
}
|
|
45
|
+
/** This agent's own online status, as it last set it on this executor, or `null`. */
|
|
46
|
+
async ownOnlineStatus() {
|
|
47
|
+
return await __classPrivateFieldGet(this, _NeighbourhoodProxy_client, "f").ownOnlineStatus(__classPrivateFieldGet(this, _NeighbourhoodProxy_pID, "f"));
|
|
48
|
+
}
|
|
49
|
+
/** Set this agent's online status with a signed perspective payload. */
|
|
29
50
|
async setOnlineStatus(status) {
|
|
30
51
|
return await __classPrivateFieldGet(this, _NeighbourhoodProxy_client, "f").setOnlineStatus(__classPrivateFieldGet(this, _NeighbourhoodProxy_pID, "f"), status);
|
|
31
52
|
}
|
|
53
|
+
/** Set this agent's online status with an unsigned perspective payload. */
|
|
32
54
|
async setOnlineStatusU(status) {
|
|
33
55
|
return await __classPrivateFieldGet(this, _NeighbourhoodProxy_client, "f").setOnlineStatusU(__classPrivateFieldGet(this, _NeighbourhoodProxy_pID, "f"), status);
|
|
34
56
|
}
|
|
57
|
+
/** Send a signed signal to a specific remote agent via the link language. */
|
|
35
58
|
async sendSignal(remoteAgentDid, payload) {
|
|
36
59
|
return await __classPrivateFieldGet(this, _NeighbourhoodProxy_client, "f").sendSignal(__classPrivateFieldGet(this, _NeighbourhoodProxy_pID, "f"), remoteAgentDid, payload);
|
|
37
60
|
}
|
|
61
|
+
/** Send an unsigned signal to a specific remote agent via the link language. */
|
|
38
62
|
async sendSignalU(remoteAgentDid, payload) {
|
|
39
63
|
return await __classPrivateFieldGet(this, _NeighbourhoodProxy_client, "f").sendSignalU(__classPrivateFieldGet(this, _NeighbourhoodProxy_pID, "f"), remoteAgentDid, payload);
|
|
40
64
|
}
|
|
65
|
+
/** Broadcast a signed signal to all agents in the neighbourhood. */
|
|
41
66
|
async sendBroadcast(payload, loopback = false) {
|
|
42
67
|
return await __classPrivateFieldGet(this, _NeighbourhoodProxy_client, "f").sendBroadcast(__classPrivateFieldGet(this, _NeighbourhoodProxy_pID, "f"), payload, loopback);
|
|
43
68
|
}
|
|
69
|
+
/** Broadcast an unsigned signal to all agents in the neighbourhood. */
|
|
44
70
|
async sendBroadcastU(payload, loopback = false) {
|
|
45
71
|
return await __classPrivateFieldGet(this, _NeighbourhoodProxy_client, "f").sendBroadcastU(__classPrivateFieldGet(this, _NeighbourhoodProxy_pID, "f"), payload, loopback);
|
|
46
72
|
}
|
|
73
|
+
/** Register a handler for incoming telepresence signals. */
|
|
47
74
|
async addSignalHandler(handler) {
|
|
48
75
|
await __classPrivateFieldGet(this, _NeighbourhoodProxy_client, "f").addSignalHandler(__classPrivateFieldGet(this, _NeighbourhoodProxy_pID, "f"), handler);
|
|
49
76
|
}
|
|
77
|
+
/** Remove a previously registered signal handler. */
|
|
50
78
|
removeSignalHandler(handler) {
|
|
51
79
|
__classPrivateFieldGet(this, _NeighbourhoodProxy_client, "f").removeSignalHandler(__classPrivateFieldGet(this, _NeighbourhoodProxy_pID, "f"), handler);
|
|
52
80
|
}
|
|
81
|
+
// ── Sessions ────────────────────────────────────────────────────────
|
|
82
|
+
//
|
|
83
|
+
// WebRTC media sessions wrapping mesh and SFU topologies.
|
|
84
|
+
// The session surface handles topology resolution, SDP negotiation,
|
|
85
|
+
// cascade redirects, and failover internally.
|
|
86
|
+
/** Active sessions in this neighbourhood. Destroyed sessions remove themselves. */
|
|
87
|
+
get sessions() {
|
|
88
|
+
return __classPrivateFieldGet(this, _NeighbourhoodProxy_sessions, "f");
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Create a WebRTC media session. Call `session.join(localStream)` to connect.
|
|
92
|
+
*
|
|
93
|
+
* Fetches the local executor's SFU status (cached after the first
|
|
94
|
+
* call): with `topology: "auto"`, a session uses the SFU only when it
|
|
95
|
+
* is public and hosts every member of the neighbourhood.
|
|
96
|
+
*/
|
|
97
|
+
async createSession(roomName, options) {
|
|
98
|
+
// `perspective.getNeighbourhoodProxy()` builds the proxy without a DID; the session needs
|
|
99
|
+
// the caller's own, so ask the executor once.
|
|
100
|
+
if (!__classPrivateFieldGet(this, _NeighbourhoodProxy_agentDid, "f")) {
|
|
101
|
+
__classPrivateFieldSet(this, _NeighbourhoodProxy_agentDid, (await __classPrivateFieldGet(this, _NeighbourhoodProxy_client, "f").callerDid()) ?? "", "f");
|
|
102
|
+
}
|
|
103
|
+
if (!__classPrivateFieldGet(this, _NeighbourhoodProxy_agentDid, "f")) {
|
|
104
|
+
throw new Error("Cannot create a call session: the executor reports no agent DID");
|
|
105
|
+
}
|
|
106
|
+
// Fetch SFU status once — reachability only changes at executor restart.
|
|
107
|
+
if (!__classPrivateFieldGet(this, _NeighbourhoodProxy_sfuStatusCache, "f")) {
|
|
108
|
+
try {
|
|
109
|
+
__classPrivateFieldSet(this, _NeighbourhoodProxy_sfuStatusCache, await __classPrivateFieldGet(this, _NeighbourhoodProxy_client, "f").sfuStatus(), "f");
|
|
110
|
+
}
|
|
111
|
+
catch {
|
|
112
|
+
// Non-fatal — session works without SFU advertisement.
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
const proxy = this;
|
|
116
|
+
const session = createSession({
|
|
117
|
+
api: __classPrivateFieldGet(this, _NeighbourhoodProxy_client, "f"),
|
|
118
|
+
roomId: roomName,
|
|
119
|
+
agentDid: __classPrivateFieldGet(this, _NeighbourhoodProxy_agentDid, "f"),
|
|
120
|
+
neighbourhoodUrl: options?.neighbourhoodUrl ?? "",
|
|
121
|
+
topology: options?.topology ?? "auto",
|
|
122
|
+
sfuConfig: options?.sfuConfig,
|
|
123
|
+
iceServers: options?.iceServers,
|
|
124
|
+
localSfuStatus: __classPrivateFieldGet(this, _NeighbourhoodProxy_sfuStatusCache, "f") ?? undefined,
|
|
125
|
+
sfuServesAllMembers: () => __classPrivateFieldGet(proxy, _NeighbourhoodProxy_client, "f").sfuServesAllMembers(__classPrivateFieldGet(proxy, _NeighbourhoodProxy_pID, "f")),
|
|
126
|
+
// Mesh needs a signalling channel and presence callbacks.
|
|
127
|
+
// SFU ignores these — they remain unused when the resolved
|
|
128
|
+
// topology selects the SFU path.
|
|
129
|
+
channel: createTelepresenceChannel(proxy, __classPrivateFieldGet(proxy, _NeighbourhoodProxy_agentDid, "f")),
|
|
130
|
+
ownOnlineStatus: () => proxy.ownOnlineStatus(),
|
|
131
|
+
setOnlineStatus: (status) => proxy.setOnlineStatusU(status),
|
|
132
|
+
onlineAgents: () => proxy.onlineAgents(),
|
|
133
|
+
});
|
|
134
|
+
__classPrivateFieldGet(this, _NeighbourhoodProxy_sessions, "f").push(session);
|
|
135
|
+
session.on("state-changed", (state) => {
|
|
136
|
+
if (state === "closed") {
|
|
137
|
+
const idx = __classPrivateFieldGet(this, _NeighbourhoodProxy_sessions, "f").indexOf(session);
|
|
138
|
+
if (idx !== -1)
|
|
139
|
+
__classPrivateFieldGet(this, _NeighbourhoodProxy_sessions, "f").splice(idx, 1);
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
return session;
|
|
143
|
+
}
|
|
144
|
+
// ── SFU (Selective Forwarding Unit) ─────────────────────────────────
|
|
145
|
+
//
|
|
146
|
+
// Thin pass-through to `NeighbourhoodClient.sfu*`. Each method takes
|
|
147
|
+
// the neighbourhood URL explicitly — the proxy is per-perspective,
|
|
148
|
+
// not per-neighbourhood, and the URL is owned by the consumer (Flux's
|
|
149
|
+
// call context, the WE UI, etc).
|
|
150
|
+
async sfuConfig(neighbourhoodUrl) {
|
|
151
|
+
return await __classPrivateFieldGet(this, _NeighbourhoodProxy_client, "f").sfuGetConfig(neighbourhoodUrl);
|
|
152
|
+
}
|
|
153
|
+
async setSfuConfig(neighbourhoodUrl, config) {
|
|
154
|
+
return await __classPrivateFieldGet(this, _NeighbourhoodProxy_client, "f").sfuSetConfig(neighbourhoodUrl, config);
|
|
155
|
+
}
|
|
156
|
+
async sfuPeer(neighbourhoodUrl) {
|
|
157
|
+
return await __classPrivateFieldGet(this, _NeighbourhoodProxy_client, "f").sfuPeerForNeighbourhood(neighbourhoodUrl);
|
|
158
|
+
}
|
|
159
|
+
async sfuPeers(neighbourhoodUrl) {
|
|
160
|
+
return await __classPrivateFieldGet(this, _NeighbourhoodProxy_client, "f").sfuPeersForNeighbourhood(neighbourhoodUrl);
|
|
161
|
+
}
|
|
162
|
+
async sfuStartRoom(neighbourhoodUrl, roomName) {
|
|
163
|
+
return await __classPrivateFieldGet(this, _NeighbourhoodProxy_client, "f").sfuStartRoom(neighbourhoodUrl, roomName);
|
|
164
|
+
}
|
|
165
|
+
async sfuStopRoom(neighbourhoodUrl, roomName) {
|
|
166
|
+
return await __classPrivateFieldGet(this, _NeighbourhoodProxy_client, "f").sfuStopRoom(neighbourhoodUrl, roomName);
|
|
167
|
+
}
|
|
168
|
+
async sfuListRooms() {
|
|
169
|
+
return await __classPrivateFieldGet(this, _NeighbourhoodProxy_client, "f").sfuListRooms();
|
|
170
|
+
}
|
|
171
|
+
async callJoin(neighbourhoodUrl, roomName, sdpOffer) {
|
|
172
|
+
return await __classPrivateFieldGet(this, _NeighbourhoodProxy_client, "f").sfuCallJoin(neighbourhoodUrl, roomName, sdpOffer);
|
|
173
|
+
}
|
|
174
|
+
async callLeave(neighbourhoodUrl, roomName) {
|
|
175
|
+
return await __classPrivateFieldGet(this, _NeighbourhoodProxy_client, "f").sfuCallLeave(neighbourhoodUrl, roomName);
|
|
176
|
+
}
|
|
177
|
+
async callSetQualityPreference(neighbourhoodUrl, roomName, preference) {
|
|
178
|
+
return await __classPrivateFieldGet(this, _NeighbourhoodProxy_client, "f").sfuCallSetQualityPreference(neighbourhoodUrl, roomName, preference);
|
|
179
|
+
}
|
|
180
|
+
async callAnswerServerOffer(neighbourhoodUrl, roomName, sdpAnswer) {
|
|
181
|
+
return await __classPrivateFieldGet(this, _NeighbourhoodProxy_client, "f").sfuCallAnswerServerOffer(neighbourhoodUrl, roomName, sdpAnswer);
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Subscribe to server-pushed renegotiation offers for `targetDid`.
|
|
185
|
+
* Returns an unsubscribe function. See
|
|
186
|
+
* `NeighbourhoodClient.subscribeSfuCallRenegotiationOffer` for the
|
|
187
|
+
* underlying mechanism.
|
|
188
|
+
*/
|
|
189
|
+
subscribeCallRenegotiationOffer(targetDid, callback) {
|
|
190
|
+
return __classPrivateFieldGet(this, _NeighbourhoodProxy_client, "f").subscribeSfuCallRenegotiationOffer(targetDid, callback);
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Subscribe to cascade rebalance migration events for `targetDid`.
|
|
194
|
+
* Returns an unsubscribe function.
|
|
195
|
+
*/
|
|
196
|
+
subscribeMigrateEvent(targetDid, callback) {
|
|
197
|
+
return __classPrivateFieldGet(this, _NeighbourhoodProxy_client, "f").subscribeSfuMigrateEvent(targetDid, callback);
|
|
198
|
+
}
|
|
199
|
+
// ── SFU trickle ICE ─────────────────────────────────────────────────
|
|
200
|
+
async addIceCandidate(neighbourhoodUrl, roomName, candidate) {
|
|
201
|
+
return await __classPrivateFieldGet(this, _NeighbourhoodProxy_client, "f").sfuAddIceCandidate(neighbourhoodUrl, roomName, candidate);
|
|
202
|
+
}
|
|
203
|
+
// ── SFU data channel relay ────────────────────────────────────────
|
|
204
|
+
async sendData(neighbourhoodUrl, roomName, channelLabel, data, binary = false) {
|
|
205
|
+
return await __classPrivateFieldGet(this, _NeighbourhoodProxy_client, "f").sfuSendData(neighbourhoodUrl, roomName, channelLabel, data, binary);
|
|
206
|
+
}
|
|
207
|
+
subscribeDataChannel(callback) {
|
|
208
|
+
return __classPrivateFieldGet(this, _NeighbourhoodProxy_client, "f").subscribeSfuDataChannel(callback);
|
|
209
|
+
}
|
|
210
|
+
// ── SFU diagnostic / test-harness ──────────────────────────────────
|
|
211
|
+
async sfuCascadeStatus() {
|
|
212
|
+
return await __classPrivateFieldGet(this, _NeighbourhoodProxy_client, "f").sfuCascadeStatus();
|
|
213
|
+
}
|
|
214
|
+
async sfuQualityPreferences() {
|
|
215
|
+
return await __classPrivateFieldGet(this, _NeighbourhoodProxy_client, "f").sfuQualityPreferences();
|
|
216
|
+
}
|
|
217
|
+
async sfuEnsureMembership(neighbourhoodUrl, did) {
|
|
218
|
+
return await __classPrivateFieldGet(this, _NeighbourhoodProxy_client, "f").sfuEnsureMembership(neighbourhoodUrl, did);
|
|
219
|
+
}
|
|
53
220
|
}
|
|
54
|
-
_NeighbourhoodProxy_client = new WeakMap(), _NeighbourhoodProxy_pID = new WeakMap();
|
|
221
|
+
_NeighbourhoodProxy_client = new WeakMap(), _NeighbourhoodProxy_pID = new WeakMap(), _NeighbourhoodProxy_agentDid = new WeakMap(), _NeighbourhoodProxy_sessions = new WeakMap(), _NeighbourhoodProxy_sfuStatusCache = new WeakMap();
|