@coasys/ad4m 0.13.1-staging.7 → 0.13.1-staging.9

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.
Files changed (93) hide show
  1. package/lib/index.cjs +652 -147
  2. package/lib/index.js +648 -148
  3. package/lib/src/agent/AgentClient.d.ts +6 -0
  4. package/lib/src/agent/AgentClient.js +17 -0
  5. package/lib/src/agent/AgentKind.d.ts +17 -0
  6. package/lib/src/agent/AgentKind.js +21 -0
  7. package/lib/src/apiClient.d.ts +4 -1
  8. package/lib/src/apiClient.js +13 -4
  9. package/lib/src/generated/api/CallSessionInfo.d.ts +1 -1
  10. package/lib/src/generated/api/Events.d.ts +2 -0
  11. package/lib/src/generated/api/PerspectiveModelSubscribeParams.d.ts +11 -0
  12. package/lib/src/generated/api/PerspectiveModelSubscribeParams.js +2 -0
  13. package/lib/src/generated/api/PerspectiveSubscribeQueryParams.d.ts +9 -0
  14. package/lib/src/generated/api/PerspectiveSubscribeQueryParams.js +2 -0
  15. package/lib/src/generated/api/RpcMethods.d.ts +10 -4
  16. package/lib/src/generated/api/RpcMethods.js +5 -0
  17. package/lib/src/generated/api/SfuAddIceCandidateParams.d.ts +4 -0
  18. package/lib/src/generated/api/SfuAnswerServerOfferParams.d.ts +4 -0
  19. package/lib/src/generated/api/SfuCallJoinParams.d.ts +13 -0
  20. package/lib/src/generated/api/SfuCallLeaveParams.d.ts +12 -0
  21. package/lib/src/generated/api/SfuCallLeaveParams.js +2 -0
  22. package/lib/src/generated/api/SfuCallRenegotiationOffer.d.ts +5 -0
  23. package/lib/src/generated/api/SfuDataMessage.d.ts +6 -0
  24. package/lib/src/generated/api/SfuQualityPreferenceParams.d.ts +4 -0
  25. package/lib/src/generated/api/SfuRestartIceParams.d.ts +12 -0
  26. package/lib/src/generated/api/SfuRestartIceParams.js +2 -0
  27. package/lib/src/generated/api/SfuRoomParticipantInfo.d.ts +4 -0
  28. package/lib/src/generated/api/SfuRoomRoster.d.ts +6 -2
  29. package/lib/src/generated/api/SfuRoomRoster.js +0 -1
  30. package/lib/src/generated/api/SfuRosterParticipant.d.ts +7 -0
  31. package/lib/src/generated/api/SfuRosterParticipant.js +2 -0
  32. package/lib/src/generated/api/SfuSendDataParams.d.ts +4 -0
  33. package/lib/src/generated/api/SfuSessionReplaced.d.ts +15 -0
  34. package/lib/src/generated/api/SfuSessionReplaced.js +2 -0
  35. package/lib/src/generated/api/SubscribeQueryRequest.d.ts +4 -0
  36. package/lib/src/generated/api/TrackMapEntry.d.ts +6 -1
  37. package/lib/src/generated/api/index.d.ts +1 -1
  38. package/lib/src/generated/api/index.js +1 -1
  39. package/lib/src/index.d.ts +1 -0
  40. package/lib/src/index.js +1 -0
  41. package/lib/src/neighbourhood/MeshManager.d.ts +19 -2
  42. package/lib/src/neighbourhood/MeshManager.js +55 -8
  43. package/lib/src/neighbourhood/NeighbourhoodClient.d.ts +34 -13
  44. package/lib/src/neighbourhood/NeighbourhoodClient.js +44 -14
  45. package/lib/src/neighbourhood/NeighbourhoodProxy.d.ts +15 -7
  46. package/lib/src/neighbourhood/NeighbourhoodProxy.js +26 -13
  47. package/lib/src/neighbourhood/Session.d.ts +24 -5
  48. package/lib/src/neighbourhood/Session.js +179 -35
  49. package/lib/src/neighbourhood/SfuManager.d.ts +98 -28
  50. package/lib/src/neighbourhood/SfuManager.js +258 -71
  51. package/lib/src/neighbourhood/SfuTypes.d.ts +4 -0
  52. package/lib/src/perspectives/PerspectiveClient.js +33 -4
  53. package/package.json +2 -2
  54. package/src/Ad4mClient.test.ts +5 -5
  55. package/src/agent/AgentClient.ts +20 -0
  56. package/src/agent/AgentKind.ts +28 -0
  57. package/src/agent/mutatePublicPerspective.test.ts +72 -0
  58. package/src/apiClient.test.ts +46 -0
  59. package/src/apiClient.ts +16 -5
  60. package/src/generated/api/CallSessionInfo.ts +1 -1
  61. package/src/generated/api/Events.ts +2 -0
  62. package/src/generated/api/PerspectiveModelSubscribeParams.ts +7 -0
  63. package/src/generated/api/PerspectiveSubscribeQueryParams.ts +7 -0
  64. package/src/generated/api/RpcMethods.ts +14 -4
  65. package/src/generated/api/SfuAddIceCandidateParams.ts +4 -0
  66. package/src/generated/api/SfuAnswerServerOfferParams.ts +4 -0
  67. package/src/generated/api/SfuCallJoinParams.ts +13 -0
  68. package/src/generated/api/SfuCallLeaveParams.ts +11 -0
  69. package/src/generated/api/SfuCallRenegotiationOffer.ts +6 -1
  70. package/src/generated/api/SfuDataMessage.ts +7 -1
  71. package/src/generated/api/SfuQualityPreferenceParams.ts +4 -0
  72. package/src/generated/api/SfuRestartIceParams.ts +11 -0
  73. package/src/generated/api/SfuRoomParticipantInfo.ts +5 -1
  74. package/src/generated/api/SfuRoomRoster.ts +6 -2
  75. package/src/generated/api/SfuRosterParticipant.ts +6 -0
  76. package/src/generated/api/SfuSendDataParams.ts +5 -1
  77. package/src/generated/api/SfuSessionReplaced.ts +13 -0
  78. package/src/generated/api/SubscribeQueryRequest.ts +5 -1
  79. package/src/generated/api/TrackMapEntry.ts +6 -1
  80. package/src/generated/api/index.ts +1 -1
  81. package/src/index.ts +1 -0
  82. package/src/neighbourhood/MeshManager.test.ts +101 -25
  83. package/src/neighbourhood/MeshManager.ts +56 -7
  84. package/src/neighbourhood/NeighbourhoodClient.test.ts +45 -15
  85. package/src/neighbourhood/NeighbourhoodClient.ts +49 -9
  86. package/src/neighbourhood/NeighbourhoodProxy.ts +29 -6
  87. package/src/neighbourhood/Session.test.ts +388 -36
  88. package/src/neighbourhood/Session.ts +185 -38
  89. package/src/neighbourhood/SfuManager.test.ts +626 -20
  90. package/src/neighbourhood/SfuManager.ts +275 -67
  91. package/src/neighbourhood/SfuTypes.ts +4 -0
  92. package/src/perspectives/PerspectiveClient.ts +36 -4
  93. package/src/perspectives/abandoned-subscribe.test.ts +219 -0
@@ -46,6 +46,12 @@ export declare class AgentClient {
46
46
  clearByDidCache(): void;
47
47
  updatePublicPerspective(perspective: PerspectiveInput): Promise<Agent>;
48
48
  mutatePublicPerspective({ additions, removals }: LinkMutations): Promise<Agent>;
49
+ /**
50
+ * Say what kind of agent this is in its public perspective (`AGENT_KIND`; a bot is
51
+ * `AGENT_KIND_BOT`), replacing any kind it said before, or say none with `null`. Changes
52
+ * nothing when the perspective already says exactly that, so it can be called on every start.
53
+ */
54
+ setKind(kind: string | null): Promise<Agent>;
49
55
  updateDirectMessageLanguage(directMessageLanguage: string): Promise<Agent>;
50
56
  addEntanglementProofs(proofs: EntanglementProofInput[]): Promise<EntanglementProof[]>;
51
57
  deleteEntanglementProofs(proofs: EntanglementProofInput[]): Promise<EntanglementProof[]>;
@@ -14,6 +14,7 @@ import { ApiClient } from '../apiClient';
14
14
  import { Agent, } from "./Agent";
15
15
  import { HostingUserInfo } from "../runtime/RuntimeTypes";
16
16
  import { AgentStatus } from "./AgentStatus";
17
+ import { AGENT_KIND } from "./AgentKind";
17
18
  import { LinkExpression, linkEqual } from "../links/Links";
18
19
  import { createPersistentCache } from "../cache/PersistentCache";
19
20
  function toAgent(data) {
@@ -147,6 +148,22 @@ export class AgentClient {
147
148
  const kept = (perspective?.links ?? []).filter(link => !removals.some(r => linkEqual(link, r)));
148
149
  return this.updatePublicPerspective({ links: [...kept, ...added] });
149
150
  }
151
+ /**
152
+ * Say what kind of agent this is in its public perspective (`AGENT_KIND`; a bot is
153
+ * `AGENT_KIND_BOT`), replacing any kind it said before, or say none with `null`. Changes
154
+ * nothing when the perspective already says exactly that, so it can be called on every start.
155
+ */
156
+ async setKind(kind) {
157
+ const me = await this.me();
158
+ const said = (me.perspective?.links ?? []).filter((l) => l.data.source === me.did && l.data.predicate === AGENT_KIND);
159
+ if ((kind === null && said.length === 0) || (said.length === 1 && said[0].data.target === kind)) {
160
+ return me;
161
+ }
162
+ return this.mutatePublicPerspective({
163
+ additions: kind === null ? [] : [{ source: me.did, predicate: AGENT_KIND, target: kind }],
164
+ removals: said,
165
+ });
166
+ }
150
167
  async updateDirectMessageLanguage(directMessageLanguage) {
151
168
  const agent = toAgent(await __classPrivateFieldGet(this, _AgentClient_apiClient, "f").call('agent.updateProfile', { dmLanguage: directMessageLanguage }));
152
169
  // Immediately update byDID cache so subsequent byDID() calls
@@ -0,0 +1,17 @@
1
+ import type { Agent } from "./Agent";
2
+ /**
3
+ * What kind of agent this is, as the agent says itself: one link in its public perspective,
4
+ * `<its did> ad4m://agent_kind <kind>`.
5
+ *
6
+ * Only the agent can write its public perspective, so the kind is its own claim, the same in
7
+ * every space and every app. Nothing checks it: a bot that leaves it out reads as an agent of no
8
+ * declared kind. It exists so an app can tell a program speaking from a person without each
9
+ * community marking its bots by hand.
10
+ */
11
+ export declare const AGENT_KIND = "ad4m://agent_kind";
12
+ /** The kind of an agent that is a program acting by itself: a bot, an AI agent, an integration. */
13
+ export declare const AGENT_KIND_BOT = "ad4m://bot";
14
+ /** The kind `agent` declares in its public perspective, or `undefined` when it declares none. */
15
+ export declare function agentKind(agent: Pick<Agent, "did" | "perspective"> | null | undefined): string | undefined;
16
+ /** Whether `agent` says it is a bot. */
17
+ export declare function isBot(agent: Pick<Agent, "did" | "perspective"> | null | undefined): boolean;
@@ -0,0 +1,21 @@
1
+ /**
2
+ * What kind of agent this is, as the agent says itself: one link in its public perspective,
3
+ * `<its did> ad4m://agent_kind <kind>`.
4
+ *
5
+ * Only the agent can write its public perspective, so the kind is its own claim, the same in
6
+ * every space and every app. Nothing checks it: a bot that leaves it out reads as an agent of no
7
+ * declared kind. It exists so an app can tell a program speaking from a person without each
8
+ * community marking its bots by hand.
9
+ */
10
+ export const AGENT_KIND = "ad4m://agent_kind";
11
+ /** The kind of an agent that is a program acting by itself: a bot, an AI agent, an integration. */
12
+ export const AGENT_KIND_BOT = "ad4m://bot";
13
+ /** The kind `agent` declares in its public perspective, or `undefined` when it declares none. */
14
+ export function agentKind(agent) {
15
+ const link = agent?.perspective?.links?.find((l) => l.data.source === agent.did && l.data.predicate === AGENT_KIND);
16
+ return link?.data.target || undefined;
17
+ }
18
+ /** Whether `agent` says it is a bot. */
19
+ export function isBot(agent) {
20
+ return agentKind(agent) === AGENT_KIND_BOT;
21
+ }
@@ -21,7 +21,10 @@ export interface CallOptions {
21
21
  */
22
22
  signal?: AbortSignal;
23
23
  /** Timeout in ms, from the call to the reply. Defaults to 30 s, or
24
- * {@link LONG_TIMEOUT_MS} for a method the executor marks long. */
24
+ * {@link LONG_TIMEOUT_MS} for a method the executor marks long. A call
25
+ * that opens something on the executor (`OPENS_METHODS`, a live query) is
26
+ * cancelled there when it times out, as when `signal` aborts it; any other
27
+ * call that times out still runs to its end. */
25
28
  timeoutMs?: number;
26
29
  }
27
30
  /** Narrows an {@link ApiClient.on} handler to one perspective's events. */
@@ -1,5 +1,5 @@
1
1
  import { callSafely } from './notifyListeners';
2
- import { LONG_METHODS, READ_METHODS } from './generated/api/RpcMethods';
2
+ import { LONG_METHODS, OPENS_METHODS, READ_METHODS } from './generated/api/RpcMethods';
3
3
  /** Error thrown by ApiClient when an RPC call fails. */
4
4
  export class RpcError extends Error {
5
5
  constructor(status, body) {
@@ -484,7 +484,18 @@ export class ApiClient {
484
484
  signal?.removeEventListener('abort', onAbort);
485
485
  fn();
486
486
  };
487
+ // Tell the executor the call is no longer wanted, so it stops the work. A late
488
+ // reply finds no pending call and is dropped.
489
+ const cancel = () => {
490
+ if (pending.sent && this._ws?.readyState === 1 /* OPEN */) {
491
+ this._send(this._ws, JSON.stringify({ id: nextId(), type: 'request.cancel', params: { targetId: id } }));
492
+ }
493
+ };
487
494
  const timer = setTimeout(() => {
495
+ // Only a call that opens something is cancelled on timeout: a write that
496
+ // timed out still runs to its end on the executor, as it always has.
497
+ if (OPENS_METHODS.has(type))
498
+ cancel();
488
499
  settle(() => reject(new RpcError(408, `RPC call '${type}' timed out after ${timeoutMs}ms`)));
489
500
  // A connect that never completes (a black-holed port) would hold every later
490
501
  // call. Drop it once no call waits on it, so the next call dials again.
@@ -495,9 +506,7 @@ export class ApiClient {
495
506
  }
496
507
  }, timeoutMs);
497
508
  const onAbort = () => {
498
- if (pending.sent && this._ws?.readyState === 1 /* OPEN */) {
499
- this._send(this._ws, JSON.stringify({ id: nextId(), type: 'request.cancel', params: { targetId: id } }));
500
- }
509
+ cancel();
501
510
  settle(() => reject(new DOMException('Aborted', 'AbortError')));
502
511
  };
503
512
  const pending = {
@@ -15,7 +15,7 @@ export type CallSessionInfo = {
15
15
  redirectTo?: string;
16
16
  /**
17
17
  * Roster of existing participants at join time, format:
18
- * `"participantId:did"` (local) or `"remote-did:did"` (cascade).
18
+ * `"participantId:did"`.
19
19
  * For track-to-DID attribution, use the `track_mapping` field on
20
20
  * each renegotiation offer — the SDP mids are assigned there.
21
21
  */
@@ -20,6 +20,7 @@ import type { SfuCallRenegotiationOffer } from "./SfuCallRenegotiationOffer";
20
20
  import type { SfuDataMessage } from "./SfuDataMessage";
21
21
  import type { SfuMigrateEvent } from "./SfuMigrateEvent";
22
22
  import type { SfuRoomRoster } from "./SfuRoomRoster";
23
+ import type { SfuSessionReplaced } from "./SfuSessionReplaced";
23
24
  import type { TranscriptionTextFilter } from "./TranscriptionTextFilter";
24
25
  /** Every event the executor emits: its payload (the message without `type`). */
25
26
  export interface EventMap {
@@ -46,6 +47,7 @@ export interface EventMap {
46
47
  "sfu-migrate": SfuMigrateEvent;
47
48
  "sfu-data": SfuDataMessage;
48
49
  "sfu-room-roster": SfuRoomRoster;
50
+ "sfu-session-replaced": SfuSessionReplaced;
49
51
  "flow-state-changed": FlowStateChangedEvent;
50
52
  "identity-fork": IdentityForkEvent;
51
53
  }
@@ -0,0 +1,11 @@
1
+ /**
2
+ * `perspective.modelSubscribe`: [`PerspectiveModelQueryParams`] and the client's
3
+ * subscription id (see [`PerspectiveSubscribeQueryParams`]).
4
+ */
5
+ export type PerspectiveModelSubscribeParams = {
6
+ uuid: string;
7
+ class_name?: string;
8
+ class_names?: Array<string>;
9
+ query_json: string;
10
+ subscriptionId: string;
11
+ };
@@ -0,0 +1,2 @@
1
+ // This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
2
+ export {};
@@ -0,0 +1,9 @@
1
+ /**
2
+ * `perspective.subscribeQuery`: the subscription id is the client's, so it can end the
3
+ * subscription without the reply (after a timeout or an abort).
4
+ */
5
+ export type PerspectiveSubscribeQueryParams = {
6
+ uuid: string;
7
+ query: string;
8
+ subscriptionId: string;
9
+ };
@@ -0,0 +1,2 @@
1
+ // This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
2
+ export {};
@@ -113,6 +113,7 @@ import type { PerspectiveLinkMutationsParams } from "./PerspectiveLinkMutationsP
113
113
  import type { PerspectiveMintFlowReceiptParams } from "./PerspectiveMintFlowReceiptParams";
114
114
  import type { PerspectiveMintFlowReceiptResult } from "./PerspectiveMintFlowReceiptResult";
115
115
  import type { PerspectiveModelQueryParams } from "./PerspectiveModelQueryParams";
116
+ import type { PerspectiveModelSubscribeParams } from "./PerspectiveModelSubscribeParams";
116
117
  import type { PerspectiveNamedShacl } from "./PerspectiveNamedShacl";
117
118
  import type { PerspectiveProposeFlowTransitionParams } from "./PerspectiveProposeFlowTransitionParams";
118
119
  import type { PerspectiveQueryLinksParams } from "./PerspectiveQueryLinksParams";
@@ -128,6 +129,7 @@ import type { PerspectiveShacl } from "./PerspectiveShacl";
128
129
  import type { PerspectiveShaclNameParams } from "./PerspectiveShaclNameParams";
129
130
  import type { PerspectiveSparqlParams } from "./PerspectiveSparqlParams";
130
131
  import type { PerspectiveSubjectClassesOfParams } from "./PerspectiveSubjectClassesOfParams";
132
+ import type { PerspectiveSubscribeQueryParams } from "./PerspectiveSubscribeQueryParams";
131
133
  import type { PerspectiveSubscribed } from "./PerspectiveSubscribed";
132
134
  import type { PerspectiveSubscriptionParams } from "./PerspectiveSubscriptionParams";
133
135
  import type { PerspectiveUpdateLinkParams } from "./PerspectiveUpdateLinkParams";
@@ -168,6 +170,7 @@ import type { SetUserFreeAccessRequest } from "./SetUserFreeAccessRequest";
168
170
  import type { SfuAddIceCandidateParams } from "./SfuAddIceCandidateParams";
169
171
  import type { SfuAnswerServerOfferParams } from "./SfuAnswerServerOfferParams";
170
172
  import type { SfuCallJoinParams } from "./SfuCallJoinParams";
173
+ import type { SfuCallLeaveParams } from "./SfuCallLeaveParams";
171
174
  import type { SfuCascadeStatus } from "./SfuCascadeStatus";
172
175
  import type { SfuConfig } from "./SfuConfig";
173
176
  import type { SfuEnsureMembershipParams } from "./SfuEnsureMembershipParams";
@@ -175,6 +178,7 @@ import type { SfuNeighbourhoodParams } from "./SfuNeighbourhoodParams";
175
178
  import type { SfuParticipantQualityPreference } from "./SfuParticipantQualityPreference";
176
179
  import type { SfuPerspectiveParams } from "./SfuPerspectiveParams";
177
180
  import type { SfuQualityPreferenceParams } from "./SfuQualityPreferenceParams";
181
+ import type { SfuRestartIceParams } from "./SfuRestartIceParams";
178
182
  import type { SfuRoomInfo } from "./SfuRoomInfo";
179
183
  import type { SfuRoomParams } from "./SfuRoomParams";
180
184
  import type { SfuSendDataParams } from "./SfuSendDataParams";
@@ -646,7 +650,7 @@ export interface RpcMethods {
646
650
  result: string;
647
651
  };
648
652
  "perspective.modelSubscribe": {
649
- params: PerspectiveModelQueryParams;
653
+ params: PerspectiveModelSubscribeParams;
650
654
  result: PerspectiveSubscribed;
651
655
  };
652
656
  "perspective.proposeFlowTransition": {
@@ -724,7 +728,7 @@ export interface RpcMethods {
724
728
  };
725
729
  };
726
730
  "perspective.subscribeQuery": {
727
- params: PerspectiveQueryParams;
731
+ params: PerspectiveSubscribeQueryParams;
728
732
  result: PerspectiveSubscribed;
729
733
  };
730
734
  "perspective.subscribeSparql": {
@@ -920,11 +924,11 @@ export interface RpcMethods {
920
924
  result: CallSessionInfo;
921
925
  };
922
926
  "sfu.callLeave": {
923
- params: SfuRoomParams;
927
+ params: SfuCallLeaveParams;
924
928
  result: boolean;
925
929
  };
926
930
  "sfu.callRestartIce": {
927
- params: SfuRoomParams;
931
+ params: SfuRestartIceParams;
928
932
  result: boolean;
929
933
  };
930
934
  "sfu.callSetQualityPreference": {
@@ -1041,3 +1045,5 @@ export type RpcMethod = keyof RpcMethods;
1041
1045
  export declare const READ_METHODS: ReadonlySet<RpcMethod>;
1042
1046
  /** Calls that can run for minutes: the client's default timeout is its long one. */
1043
1047
  export declare const LONG_METHODS: ReadonlySet<RpcMethod>;
1048
+ /** Calls that open something on the executor that outlives them (a live query): the client cancels one that timed out, as one it aborted. */
1049
+ export declare const OPENS_METHODS: ReadonlySet<RpcMethod>;
@@ -103,3 +103,8 @@ export const LONG_METHODS = new Set([
103
103
  "perspective.runInterpretationWithHarness",
104
104
  "runtime.restartHolochain",
105
105
  ]);
106
+ /** Calls that open something on the executor that outlives them (a live query): the client cancels one that timed out, as one it aborted. */
107
+ export const OPENS_METHODS = new Set([
108
+ "perspective.modelSubscribe",
109
+ "perspective.subscribeQuery",
110
+ ]);
@@ -1,6 +1,10 @@
1
1
  export type SfuAddIceCandidateParams = {
2
2
  neighbourhoodUrl: string;
3
3
  roomName: string;
4
+ /**
5
+ * The caller's session, as its join returned it.
6
+ */
7
+ participantId: string;
4
8
  /**
5
9
  * The candidate's SDP attribute line.
6
10
  */
@@ -1,6 +1,10 @@
1
1
  export type SfuAnswerServerOfferParams = {
2
2
  neighbourhoodUrl: string;
3
3
  roomName: string;
4
+ /**
5
+ * The caller's session, as its join returned it.
6
+ */
7
+ participantId: string;
4
8
  /**
5
9
  * JSON-encoded `RTCSessionDescriptionInit`.
6
10
  */
@@ -5,6 +5,19 @@ export type SfuCallJoinParams = {
5
5
  * JSON-encoded `RTCSessionDescriptionInit`.
6
6
  */
7
7
  sdpOffer: string;
8
+ /**
9
+ * The device the caller joins from (an opaque id, 1 to 128 characters).
10
+ * The caller's session from the same device is replaced; one from
11
+ * another device stays beside it.
12
+ */
13
+ deviceId: string;
14
+ /**
15
+ * The client's random key for this call session (1 to 128 characters,
16
+ * never published). A rebuild of the session sends it again and
17
+ * replaces its own dead session; a join whose key a later join from the
18
+ * same device replaced is refused with 409: that session must stop.
19
+ */
20
+ sessionKey: string;
8
21
  /**
9
22
  * The caller can reach other cascade nodes, so a busy room may answer
10
23
  * with `redirectTo` instead of a session. Off by default: an SDK client
@@ -0,0 +1,12 @@
1
+ /**
2
+ * `sfu.callLeave`: the session to leave, as its join returned it.
3
+ */
4
+ export type SfuCallLeaveParams = {
5
+ neighbourhoodUrl: string;
6
+ roomName: string;
7
+ /**
8
+ * The `participantId` the join returned. Only the caller's own session
9
+ * is left; any other id leaves nothing (`false`).
10
+ */
11
+ participantId: string;
12
+ };
@@ -0,0 +1,2 @@
1
+ // This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
2
+ export {};
@@ -13,6 +13,11 @@ export type SfuCallRenegotiationOffer = {
13
13
  * events_ws fanout to filter per-user.
14
14
  */
15
15
  targetDid: string;
16
+ /**
17
+ * The session the offer is for. Every session of `target_did` gets
18
+ * it; only this one applies it.
19
+ */
20
+ participantId: string;
16
21
  neighbourhoodUrl: string;
17
22
  roomName: string;
18
23
  /**
@@ -7,6 +7,12 @@ export type SfuDataMessage = {
7
7
  * DID of the participant who sent the data.
8
8
  */
9
9
  senderDid: string;
10
+ /**
11
+ * The session that sent it. A message reaches the sender's agent when
12
+ * it is in the call on another device too; the sending session itself
13
+ * drops it by this id.
14
+ */
15
+ senderParticipantId: string;
10
16
  neighbourhoodUrl: string;
11
17
  roomName: string;
12
18
  /**
@@ -1,6 +1,10 @@
1
1
  export type SfuQualityPreferenceParams = {
2
2
  neighbourhoodUrl: string;
3
3
  roomName: string;
4
+ /**
5
+ * The caller's session, as its join returned it.
6
+ */
7
+ participantId: string;
4
8
  /**
5
9
  * The service rejects any other value.
6
10
  */
@@ -0,0 +1,12 @@
1
+ /**
2
+ * `sfu.callRestartIce`: the session whose ICE to restart.
3
+ */
4
+ export type SfuRestartIceParams = {
5
+ neighbourhoodUrl: string;
6
+ roomName: string;
7
+ /**
8
+ * The caller's session, as its join returned it. Any other id, even
9
+ * another device of the same agent, is refused.
10
+ */
11
+ participantId: string;
12
+ };
@@ -0,0 +1,2 @@
1
+ // This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
2
+ export {};
@@ -4,6 +4,10 @@
4
4
  * `MediaStream`.
5
5
  */
6
6
  export type SfuRoomParticipantInfo = {
7
+ /**
8
+ * The session: an agent in the call from two devices is two participants.
9
+ */
10
+ participantId: string;
7
11
  agentDid: string;
8
12
  hasAudio: boolean;
9
13
  hasVideo: boolean;
@@ -1,3 +1,4 @@
1
+ import type { SfuRosterParticipant } from "./SfuRosterParticipant";
1
2
  /**
2
3
  * Who is in a call room now. Published whenever the room's participants
3
4
  * change, and delivered to each of them, so a client knows who joined and
@@ -7,7 +8,10 @@ export type SfuRoomRoster = {
7
8
  neighbourhoodUrl: string;
8
9
  roomName: string;
9
10
  /**
10
- * DIDs of the room's participants on this node, sorted.
11
+ * The room's sessions, sorted by DID, then participant id: this node's,
12
+ * and those the other cascade nodes in the room announced, whose ids
13
+ * name their node (`P3@did:key:...`). An agent in the call from two
14
+ * devices is listed twice.
11
15
  */
12
- participants: Array<string>;
16
+ participants: Array<SfuRosterParticipant>;
13
17
  };
@@ -1,2 +1 @@
1
- // This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
2
1
  export {};
@@ -0,0 +1,7 @@
1
+ /**
2
+ * One session in an [`SfuRoomRoster`].
3
+ */
4
+ export type SfuRosterParticipant = {
5
+ agentDid: string;
6
+ participantId: string;
7
+ };
@@ -0,0 +1,2 @@
1
+ // This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
2
+ export {};
@@ -1,6 +1,10 @@
1
1
  export type SfuSendDataParams = {
2
2
  neighbourhoodUrl: string;
3
3
  roomName: string;
4
+ /**
5
+ * The caller's session, as its join returned it.
6
+ */
7
+ participantId: string;
4
8
  channelLabel: string;
5
9
  /**
6
10
  * UTF-8 text, or base64 when `binary` is true.
@@ -0,0 +1,15 @@
1
+ /**
2
+ * A later join from the same device (another tab) replaced one of this
3
+ * agent's call sessions: the executor has dropped it. Delivered to the
4
+ * agent (`targetDid`); the session whose participant id it names stops and
5
+ * does not rejoin.
6
+ */
7
+ export type SfuSessionReplaced = {
8
+ targetDid: string;
9
+ neighbourhoodUrl: string;
10
+ roomName: string;
11
+ /**
12
+ * The replaced session.
13
+ */
14
+ participantId: string;
15
+ };
@@ -0,0 +1,2 @@
1
+ // This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
2
+ export {};
@@ -1,3 +1,7 @@
1
1
  export type SubscribeQueryRequest = {
2
2
  query: string;
3
+ /**
4
+ * Minted by the client, so it can end the subscription without the reply.
5
+ */
6
+ subscriptionId: string;
3
7
  };
@@ -1,11 +1,16 @@
1
1
  /**
2
- * Maps one outbound SDP m-line to the originating participant's DID.
2
+ * Maps one outbound SDP m-line to the originating participant.
3
3
  */
4
4
  export type TrackMapEntry = {
5
5
  /**
6
6
  * The SDP mid (media-line identifier) in the offer.
7
7
  */
8
8
  mid: string;
9
+ /**
10
+ * The session whose media this m-line carries: one agent on two
11
+ * devices sends two.
12
+ */
13
+ participantId: string;
9
14
  /**
10
15
  * DID of the participant whose media this m-line carries.
11
16
  */
@@ -90,7 +90,7 @@ export type { SignedRequest } from "./SignedRequest";
90
90
  export type { SkippedSource } from "./SkippedSource";
91
91
  export type { StoreBehind } from "./StoreBehind";
92
92
  export type { StoreInfo } from "./StoreInfo";
93
- export { READ_METHODS, LONG_METHODS } from "./RpcMethods";
93
+ export { READ_METHODS, LONG_METHODS, OPENS_METHODS } from "./RpcMethods";
94
94
  export type { RpcMethods, RpcMethod } from "./RpcMethods";
95
95
  export { SCOPED_EVENTS } from "./Events";
96
96
  export type { EventMap, EventName, ScopedEventName } from "./Events";
@@ -5,5 +5,5 @@
5
5
  // Note: Domain types (Link, LinkInput, LinkExpression, etc.) are NOT re-exported
6
6
  // here to avoid conflicts with the hand-written domain classes in the SDK.
7
7
  // Only request/response types are exported.
8
- export { READ_METHODS, LONG_METHODS } from "./RpcMethods";
8
+ export { READ_METHODS, LONG_METHODS, OPENS_METHODS } from "./RpcMethods";
9
9
  export { SCOPED_EVENTS } from "./Events";
@@ -2,6 +2,7 @@ export * from "./Ad4mClient";
2
2
  export * from "./Address";
3
3
  export * from "./agent/Agent";
4
4
  export * from "./agent/AgentStatus";
5
+ export * from "./agent/AgentKind";
5
6
  export * from "./cache/PersistentCache";
6
7
  export * from "./Exception";
7
8
  export * from "./expression/Expression";
package/lib/src/index.js CHANGED
@@ -2,6 +2,7 @@ export * from "./Ad4mClient";
2
2
  export * from "./Address";
3
3
  export * from "./agent/Agent";
4
4
  export * from "./agent/AgentStatus";
5
+ export * from "./agent/AgentKind";
5
6
  export * from "./cache/PersistentCache";
6
7
  export * from "./Exception";
7
8
  export * from "./expression/Expression";
@@ -156,9 +156,26 @@ export interface TelepresenceProxy {
156
156
  addSignalHandler(handler: (payload: PerspectiveExpression) => void): Promise<void>;
157
157
  removeSignalHandler(handler: (payload: PerspectiveExpression) => void): void;
158
158
  }
159
+ /**
160
+ * A mesh peer: one agent on one device. An agent calling from two devices is
161
+ * two peers, each with its own connection to everyone else, so neither device's
162
+ * media or teardown can stand in for the other's.
163
+ */
164
+ export declare function meshPeerId(did: string, device: string): string;
165
+ /** The agent a mesh peer id belongs to. */
166
+ export declare function agentOfMeshPeer(peerId: string): string;
159
167
  /**
160
168
  * Bridge NeighbourhoodProxy telepresence to the SignallingChannel
161
- * the mesh consumes.
169
+ * the mesh consumes, as the peer `selfDid` on `selfDevice`.
170
+ *
171
+ * ## Peers are devices
172
+ *
173
+ * The sender a message reports is a {@link meshPeerId}: the link's author,
174
+ * which the executor verified, and the device the author's payload names. A
175
+ * device is only the author's own claim, so it can tell this agent's devices
176
+ * apart but never speak for another agent. Only this device's own echo is
177
+ * dropped: a broadcast from another device of this agent — the executor hands
178
+ * one to every client of the agent — is a peer like any other.
162
179
  *
163
180
  * ## Why unicast runs emulated over broadcast
164
181
  *
@@ -168,7 +185,7 @@ export interface TelepresenceProxy {
168
185
  * receivers drop anything not addressed to them. That provides
169
186
  * **addressing, not privacy** — every peer still receives the payload.
170
187
  */
171
- export declare function createTelepresenceChannel(proxy: TelepresenceProxy, selfDid: string): SignallingChannel;
188
+ export declare function createTelepresenceChannel(proxy: TelepresenceProxy, selfDid: string, selfDevice: string): SignallingChannel;
172
189
  export type MeshEvent = "participant-joined" | "participant-left"
173
190
  /** A participant's stream object or the liveness of its tracks changed:
174
191
  * a rebuilt connection, or a remote track muted or unmuted. */