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

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 (193) hide show
  1. package/lib/index.cjs +1518 -739
  2. package/lib/index.js +1515 -740
  3. package/lib/src/Ad4mClient.d.ts +9 -0
  4. package/lib/src/Ad4mClient.js +17 -2
  5. package/lib/src/agent/Agent.d.ts +5 -1
  6. package/lib/src/agent/Agent.js +3 -0
  7. package/lib/src/agent/AgentClient.d.ts +3 -0
  8. package/lib/src/agent/AgentClient.js +3 -0
  9. package/lib/src/agent/AgentStatus.d.ts +2 -0
  10. package/lib/src/agent/AgentStatus.js +2 -0
  11. package/lib/src/apiClient.d.ts +73 -0
  12. package/lib/src/apiClient.js +269 -13
  13. package/lib/src/generated/api/AgentStatus.d.ts +5 -0
  14. package/lib/src/generated/api/AgentWithIdentity.d.ts +14 -0
  15. package/lib/src/generated/api/AgentWithIdentity.js +1 -0
  16. package/lib/src/generated/api/BotView.d.ts +7 -0
  17. package/lib/src/generated/api/BotView.js +2 -0
  18. package/lib/src/generated/api/ClaimOfferParams.d.ts +13 -0
  19. package/lib/src/generated/api/ClaimOfferParams.js +2 -0
  20. package/lib/src/generated/api/ClaimOfferResult.d.ts +14 -0
  21. package/lib/src/generated/api/ClaimOfferResult.js +1 -0
  22. package/lib/src/generated/api/ClaimView.d.ts +11 -0
  23. package/lib/src/generated/api/ClaimView.js +2 -0
  24. package/lib/src/generated/api/CosignInceptParams.d.ts +10 -0
  25. package/lib/src/generated/api/CosignInceptParams.js +1 -0
  26. package/lib/src/generated/api/DeviceView.d.ts +17 -0
  27. package/lib/src/generated/api/DeviceView.js +1 -0
  28. package/lib/src/generated/api/DidBotScope.d.ts +7 -0
  29. package/lib/src/generated/api/DidBotScope.js +2 -0
  30. package/lib/src/generated/api/DidDocument.d.ts +16 -0
  31. package/lib/src/generated/api/DidDocument.js +1 -0
  32. package/lib/src/generated/api/DidDocumentMetadata.d.ts +18 -0
  33. package/lib/src/generated/api/DidDocumentMetadata.js +2 -0
  34. package/lib/src/generated/api/DidResolutionMetadata.d.ts +51 -0
  35. package/lib/src/generated/api/DidResolutionMetadata.js +1 -0
  36. package/lib/src/generated/api/DidResolutionResult.d.ts +16 -0
  37. package/lib/src/generated/api/DidResolutionResult.js +1 -0
  38. package/lib/src/generated/api/DidVerificationMethod.d.ts +17 -0
  39. package/lib/src/generated/api/DidVerificationMethod.js +1 -0
  40. package/lib/src/generated/api/Events.d.ts +2 -0
  41. package/lib/src/generated/api/ForkRecord.d.ts +11 -0
  42. package/lib/src/generated/api/ForkRecord.js +2 -0
  43. package/lib/src/generated/api/IdentityForkEvent.d.ts +10 -0
  44. package/lib/src/generated/api/IdentityForkEvent.js +2 -0
  45. package/lib/src/generated/api/IdentityLog.d.ts +18 -0
  46. package/lib/src/generated/api/IdentityLog.js +1 -0
  47. package/lib/src/generated/api/IdentityStatus.d.ts +48 -0
  48. package/lib/src/generated/api/IdentityStatus.js +1 -0
  49. package/lib/src/generated/api/JoinStatus.d.ts +10 -0
  50. package/lib/src/generated/api/JoinStatus.js +2 -0
  51. package/lib/src/generated/api/JoinStatusParams.d.ts +6 -0
  52. package/lib/src/generated/api/JoinStatusParams.js +2 -0
  53. package/lib/src/generated/api/LogParams.d.ts +17 -0
  54. package/lib/src/generated/api/LogParams.js +2 -0
  55. package/lib/src/generated/api/Offer.d.ts +14 -0
  56. package/lib/src/generated/api/Offer.js +1 -0
  57. package/lib/src/generated/api/OfferKind.d.ts +4 -0
  58. package/lib/src/generated/api/OfferKind.js +2 -0
  59. package/lib/src/generated/api/OfferListing.d.ts +9 -0
  60. package/lib/src/generated/api/OfferListing.js +1 -0
  61. package/lib/src/generated/api/OfferOpened.d.ts +6 -0
  62. package/lib/src/generated/api/OfferOpened.js +2 -0
  63. package/lib/src/generated/api/OfferState.d.ts +21 -0
  64. package/lib/src/generated/api/OfferState.js +1 -0
  65. package/lib/src/generated/api/OffersParams.d.ts +11 -0
  66. package/lib/src/generated/api/OffersParams.js +1 -0
  67. package/lib/src/generated/api/OpenOfferParams.d.ts +7 -0
  68. package/lib/src/generated/api/OpenOfferParams.js +1 -0
  69. package/lib/src/generated/api/PublishParams.d.ts +11 -0
  70. package/lib/src/generated/api/PublishParams.js +1 -0
  71. package/lib/src/generated/api/RequestBody.d.ts +15 -0
  72. package/lib/src/generated/api/RequestBody.js +2 -0
  73. package/lib/src/generated/api/ResetLogParams.d.ts +9 -0
  74. package/lib/src/generated/api/ResetLogParams.js +2 -0
  75. package/lib/src/generated/api/ResolveParams.d.ts +18 -0
  76. package/lib/src/generated/api/ResolveParams.js +2 -0
  77. package/lib/src/generated/api/RpcMethods.d.ts +68 -1
  78. package/lib/src/generated/api/RpcMethods.js +6 -0
  79. package/lib/src/generated/api/SignedBy.d.ts +8 -0
  80. package/lib/src/generated/api/SignedBy.js +2 -0
  81. package/lib/src/generated/api/SignedHead.d.ts +14 -0
  82. package/lib/src/generated/api/SignedHead.js +2 -0
  83. package/lib/src/generated/api/SignedOffer.d.ts +10 -0
  84. package/lib/src/generated/api/SignedOffer.js +1 -0
  85. package/lib/src/generated/api/SignedRequest.d.ts +8 -0
  86. package/lib/src/generated/api/SignedRequest.js +1 -0
  87. package/lib/src/generated/api/SkippedSource.d.ts +7 -0
  88. package/lib/src/generated/api/SkippedSource.js +2 -0
  89. package/lib/src/generated/api/StoreBehind.d.ts +13 -0
  90. package/lib/src/generated/api/StoreBehind.js +2 -0
  91. package/lib/src/generated/api/StoreInfo.d.ts +15 -0
  92. package/lib/src/generated/api/StoreInfo.js +2 -0
  93. package/lib/src/generated/api/index.d.ts +38 -0
  94. package/lib/src/identity/IdentityClient.d.ts +70 -0
  95. package/lib/src/identity/IdentityClient.js +97 -0
  96. package/lib/src/index.d.ts +1 -0
  97. package/lib/src/index.js +1 -0
  98. package/lib/src/model/Ad4mModel.d.ts +11 -0
  99. package/lib/src/model/Ad4mModel.js +28 -14
  100. package/lib/src/model/ModelQueryBuilder.d.ts +2 -0
  101. package/lib/src/model/ModelQueryBuilder.js +36 -57
  102. package/lib/src/neighbourhood/MeshManager.d.ts +24 -0
  103. package/lib/src/neighbourhood/MeshManager.js +42 -1
  104. package/lib/src/neighbourhood/NeighbourhoodClient.d.ts +10 -0
  105. package/lib/src/neighbourhood/NeighbourhoodClient.js +16 -0
  106. package/lib/src/neighbourhood/Session.js +2 -0
  107. package/lib/src/neighbourhood/SfuManager.d.ts +30 -3
  108. package/lib/src/neighbourhood/SfuManager.js +78 -41
  109. package/lib/src/perspectives/FlowInstance.js +6 -4
  110. package/lib/src/perspectives/LiveQuery.d.ts +40 -4
  111. package/lib/src/perspectives/LiveQuery.js +94 -10
  112. package/lib/src/perspectives/PerspectiveClient.d.ts +4 -2
  113. package/lib/src/perspectives/PerspectiveClient.js +6 -4
  114. package/lib/src/perspectives/PerspectiveProxy.d.ts +15 -3
  115. package/lib/src/perspectives/PerspectiveProxy.js +33 -16
  116. package/lib/src/perspectives/WakerSubscriptionManager.d.ts +35 -2
  117. package/lib/src/perspectives/WakerSubscriptionManager.js +93 -9
  118. package/lib/src/shacl/SHACLFlow.d.ts +5 -3
  119. package/lib/src/shacl/SHACLFlow.js +121 -5
  120. package/package.json +2 -2
  121. package/src/Ad4mClient.test.ts +64 -4
  122. package/src/Ad4mClient.ts +17 -0
  123. package/src/agent/Agent.ts +9 -1
  124. package/src/agent/AgentClient.ts +5 -1
  125. package/src/agent/AgentStatus.ts +4 -0
  126. package/src/apiClient.test.ts +769 -3
  127. package/src/apiClient.ts +268 -13
  128. package/src/generated/api/AgentStatus.ts +6 -1
  129. package/src/generated/api/AgentWithIdentity.ts +12 -0
  130. package/src/generated/api/BotView.ts +6 -0
  131. package/src/generated/api/ClaimOfferParams.ts +14 -0
  132. package/src/generated/api/ClaimOfferResult.ts +11 -0
  133. package/src/generated/api/ClaimView.ts +6 -0
  134. package/src/generated/api/CosignInceptParams.ts +11 -0
  135. package/src/generated/api/DeviceView.ts +12 -0
  136. package/src/generated/api/DidBotScope.ts +6 -0
  137. package/src/generated/api/DidDocument.ts +8 -0
  138. package/src/generated/api/DidDocumentMetadata.ts +19 -0
  139. package/src/generated/api/DidResolutionMetadata.ts +52 -0
  140. package/src/generated/api/DidResolutionResult.ts +13 -0
  141. package/src/generated/api/DidVerificationMethod.ts +15 -0
  142. package/src/generated/api/Events.ts +2 -0
  143. package/src/generated/api/ForkRecord.ts +9 -0
  144. package/src/generated/api/IdentityForkEvent.ts +7 -0
  145. package/src/generated/api/IdentityLog.ts +17 -0
  146. package/src/generated/api/IdentityStatus.ts +49 -0
  147. package/src/generated/api/JoinStatus.ts +7 -0
  148. package/src/generated/api/JoinStatusParams.ts +6 -0
  149. package/src/generated/api/LogParams.ts +18 -0
  150. package/src/generated/api/Offer.ts +8 -0
  151. package/src/generated/api/OfferKind.ts +6 -0
  152. package/src/generated/api/OfferListing.ts +8 -0
  153. package/src/generated/api/OfferOpened.ts +6 -0
  154. package/src/generated/api/OfferState.ts +7 -0
  155. package/src/generated/api/OffersParams.ts +11 -0
  156. package/src/generated/api/OpenOfferParams.ts +7 -0
  157. package/src/generated/api/PublishParams.ts +12 -0
  158. package/src/generated/api/RequestBody.ts +7 -0
  159. package/src/generated/api/ResetLogParams.ts +10 -0
  160. package/src/generated/api/ResolveParams.ts +19 -0
  161. package/src/generated/api/RpcMethods.ts +38 -1
  162. package/src/generated/api/SignedBy.ts +6 -0
  163. package/src/generated/api/SignedHead.ts +10 -0
  164. package/src/generated/api/SignedOffer.ts +8 -0
  165. package/src/generated/api/SignedRequest.ts +7 -0
  166. package/src/generated/api/SkippedSource.ts +6 -0
  167. package/src/generated/api/StoreBehind.ts +14 -0
  168. package/src/generated/api/StoreInfo.ts +16 -0
  169. package/src/generated/api/index.ts +39 -0
  170. package/src/identity/IdentityClient.ts +111 -0
  171. package/src/index.ts +1 -0
  172. package/src/model/Ad4mModel.test.ts +128 -364
  173. package/src/model/Ad4mModel.ts +27 -18
  174. package/src/model/ModelQueryBuilder.ts +39 -59
  175. package/src/model/write-round-trips.test.ts +324 -0
  176. package/src/neighbourhood/MeshManager.test.ts +87 -0
  177. package/src/neighbourhood/MeshManager.ts +50 -1
  178. package/src/neighbourhood/NeighbourhoodClient.test.ts +27 -0
  179. package/src/neighbourhood/NeighbourhoodClient.ts +19 -0
  180. package/src/neighbourhood/Session.test.ts +5 -0
  181. package/src/neighbourhood/Session.ts +2 -0
  182. package/src/neighbourhood/SfuManager.test.ts +293 -0
  183. package/src/neighbourhood/SfuManager.ts +92 -45
  184. package/src/perspectives/FlowInstance.ts +6 -4
  185. package/src/perspectives/LiveQuery.test.ts +173 -1
  186. package/src/perspectives/LiveQuery.ts +110 -10
  187. package/src/perspectives/PerspectiveClient.ts +6 -4
  188. package/src/perspectives/PerspectiveProxy.test.ts +24 -2
  189. package/src/perspectives/PerspectiveProxy.ts +35 -16
  190. package/src/perspectives/WakerSubscriptionManager.test.ts +225 -1
  191. package/src/perspectives/WakerSubscriptionManager.ts +97 -10
  192. package/src/shacl/SHACLFlow.test.ts +221 -0
  193. package/src/shacl/SHACLFlow.ts +121 -5
package/lib/index.js CHANGED
@@ -36,6 +36,12 @@ const READ_METHODS = new Set([
36
36
  "hosting.info",
37
37
  "hosting.wallet",
38
38
  "hosting.walletHistory",
39
+ "identity.devices",
40
+ "identity.joinStatus",
41
+ "identity.log",
42
+ "identity.offers",
43
+ "identity.resolve",
44
+ "identity.status",
39
45
  "language.all",
40
46
  "language.get",
41
47
  "language.meta",
@@ -129,6 +135,40 @@ const MAX_RECONNECT_DELAY_MS = 30000;
129
135
  * MAX_WATCH_RETRIES times in a row. */
130
136
  const WATCH_RETRY_DELAY_MS = 1000;
131
137
  const MAX_WATCH_RETRIES = 5;
138
+ /** An open socket sends a ping this often, and must deliver some message
139
+ * (the pong will do) within an interval of the first ping it left
140
+ * unanswered. After a network switch a socket can stay OPEN for minutes with
141
+ * no close event, since no FIN or RST ever arrives; this notices it within
142
+ * two intervals. */
143
+ const PING_INTERVAL_MS = 10000;
144
+ /** The slowest link a socket is given time for. The executor reads a ping
145
+ * only after the frames sent before it, so a ping left unanswered counts as
146
+ * silence only once everything the socket sent before that ping could have
147
+ * crossed this link and PONG_RETURN_MS more have passed, if that takes longer
148
+ * than PING_INTERVAL_MS. Messages that come in meanwhile do not shorten this:
149
+ * they say nothing about how far an upload has got. */
150
+ const SLOWEST_LINK_BYTES_PER_MS = 16; // 16 kB/s
151
+ /** How long a pong gets to come back after its ping could have been read
152
+ * behind a large write. Shorter than PING_INTERVAL_MS, so the few ms a small
153
+ * frame adds before a ping on an idle socket never cost a ping interval. */
154
+ const PONG_RETURN_MS = 5000;
155
+ /** How long `checkConnection` waits for the open socket to say anything
156
+ * after its ping. If a large write sent before it may still be on the way,
157
+ * the wait lasts until that write could have crossed, as for the periodic
158
+ * ping, and half of this more for the pong. On a working path the pong is
159
+ * one round trip away. */
160
+ const CHECK_CONNECTION_DEADLINE_MS = 2000;
161
+ /** The bytes `text` takes as UTF-8, as a WebSocket text frame sends it. */
162
+ function utf8Length(text) {
163
+ let bytes = text.length;
164
+ for (let i = 0; i < text.length; i++) {
165
+ const unit = text.charCodeAt(i);
166
+ // A surrogate is half of a 4-byte pair: 2 units, 2 extra bytes.
167
+ if (unit >= 0x80)
168
+ bytes += unit < 0x800 || (unit >= 0xd800 && unit <= 0xdfff) ? 1 : 2;
169
+ }
170
+ return bytes;
171
+ }
132
172
  let _idCounter = 0;
133
173
  function nextId() {
134
174
  return String(++_idCounter);
@@ -163,6 +203,16 @@ class ApiClient {
163
203
  this._wsReconnectTimer = null;
164
204
  this._wsReconnectDelay = INITIAL_RECONNECT_DELAY_MS;
165
205
  this._wsPingTimer = null;
206
+ /** When the open socket was first pinged since it last delivered a message; null while none is unanswered. */
207
+ this._wsPingedAt = null;
208
+ /** When that ping could have reached the executor, which reads it only after what the socket sent before it. */
209
+ this._wsPingArrivesBy = 0;
210
+ /** When everything the open socket sent so far could have crossed a SLOWEST_LINK_BYTES_PER_MS link.
211
+ * A message from the socket does not move it back: hearing from the executor says nothing
212
+ * about how much of a large upload has reached it. */
213
+ this._wsSentBy = 0;
214
+ /** A `checkConnection` probe waiting for the open socket to say anything; null when none. */
215
+ this._wsProbeTimer = null;
166
216
  // The executor sends a socket only the events it asked for (`events.watch`).
167
217
  // What the executor has for the open socket, as sent; a new socket has `{}`.
168
218
  this._watching = '{}';
@@ -172,6 +222,20 @@ class ApiClient {
172
222
  this._watchSent = Promise.resolve();
173
223
  this._watchRetries = 0;
174
224
  this._watchRetryTimer = null;
225
+ this._networkCallbacks = new Set();
226
+ /** Removes the network-change listeners; null while not listening. */
227
+ this._unlistenNetwork = null;
228
+ /** A network change waits for its socket to open, then tells `onNetworkChange`. */
229
+ this._networkChanged = false;
230
+ /** The socket dialled for the last network change. */
231
+ this._networkDial = null;
232
+ this._wakeListening = false;
233
+ /** `online` always; `visibilitychange` only when the page became visible. */
234
+ this._onWake = (event) => {
235
+ if (event.type === 'visibilitychange' && typeof document !== 'undefined' && document.visibilityState !== 'visible')
236
+ return;
237
+ this.reconnectNow();
238
+ };
175
239
  this.baseUrl = baseUrl;
176
240
  this.token = token;
177
241
  this._webSocketImpl = webSocketImpl;
@@ -195,6 +259,10 @@ class ApiClient {
195
259
  return;
196
260
  if (this._authFailed !== null)
197
261
  throw new RpcError(401, this._authFailed);
262
+ this._listenForNetworkChanges();
263
+ // A dial ends any wait for one: a call or subscriber that dials during the backoff
264
+ // leaves no timer behind to swallow the retry after this socket's own drop.
265
+ this._cancelReconnect();
198
266
  const WsImpl = this._webSocketImpl ?? globalThis.WebSocket;
199
267
  const ws = new WsImpl(this._getWsUrl());
200
268
  this._ws = ws;
@@ -219,6 +287,10 @@ class ApiClient {
219
287
  // Only watchApplied() awaits this; a close before open is not an error otherwise.
220
288
  this._wsOpen.catch(() => { });
221
289
  ws.onmessage = (event) => {
290
+ if (this._ws === ws) {
291
+ this._wsPingedAt = null;
292
+ this._endProbe();
293
+ }
222
294
  let parsed;
223
295
  try {
224
296
  parsed = JSON.parse(event.data);
@@ -244,7 +316,8 @@ class ApiClient {
244
316
  this._failAuth(rpcError.body);
245
317
  return;
246
318
  }
247
- if (parsed.type === 'pong')
319
+ // A dropped socket's events are not this client's any more: its successor watches again.
320
+ if (parsed.type === 'pong' || this._ws !== ws)
248
321
  return;
249
322
  const perspective = parsed.perspectiveUuid;
250
323
  const regs = this._handlers.get(parsed.type);
@@ -267,14 +340,14 @@ class ApiClient {
267
340
  if (this._ws !== ws)
268
341
  return;
269
342
  this._wsReconnectDelay = INITIAL_RECONNECT_DELAY_MS;
270
- this._startPing();
343
+ this._startPing(ws);
271
344
  // The watch goes out before the queued calls, so the events they cause reach listeners.
272
345
  this._watching = '{}';
273
346
  this._watchRetries = 0;
274
347
  this._flushWatch();
275
348
  for (const pending of this._pendingCalls.values()) {
276
349
  if (!pending.sent) {
277
- ws.send(pending.message);
350
+ this._send(ws, pending.message);
278
351
  pending.sent = true;
279
352
  }
280
353
  }
@@ -289,6 +362,70 @@ class ApiClient {
289
362
  }
290
363
  }
291
364
  this._hasConnectedOnce = true;
365
+ if (this._networkChanged) {
366
+ this._networkChanged = false;
367
+ this._notifyNetworkChange();
368
+ }
369
+ }
370
+ /**
371
+ * Hear of network changes where the platform says so: `online` on the
372
+ * global object (browsers, Deno) redials at once, and `change` on
373
+ * `navigator.connection` (Chromium) runs `checkConnection`. Elsewhere,
374
+ * e.g. Node, nothing is heard and the ping deadline notices a dead
375
+ * socket on its own.
376
+ */
377
+ _listenForNetworkChanges() {
378
+ if (this._unlistenNetwork)
379
+ return;
380
+ const handler = () => this._onNetworkChange();
381
+ const removers = [];
382
+ const target = globalThis;
383
+ if (typeof target.addEventListener === 'function') {
384
+ target.addEventListener('online', handler);
385
+ removers.push(() => target.removeEventListener?.('online', handler));
386
+ }
387
+ const connection = globalThis.navigator?.connection;
388
+ if (typeof connection?.addEventListener === 'function') {
389
+ // `change` also fires when Chromium's downlink or rtt estimate
390
+ // moves, as a busy call makes it do: probe rather than drop.
391
+ const probe = () => this.checkConnection();
392
+ connection.addEventListener('change', probe);
393
+ removers.push(() => connection.removeEventListener?.('change', probe));
394
+ }
395
+ this._unlistenNetwork = () => { for (const remove of removers)
396
+ remove(); };
397
+ }
398
+ /**
399
+ * The network changed: the open socket most likely runs over a path that
400
+ * is gone, and nothing would say so before the ping deadline. Drop it as
401
+ * a silent socket is dropped and dial the next one now, without backoff.
402
+ * `onNetworkChange` callbacks fire once that socket opens.
403
+ */
404
+ _onNetworkChange() {
405
+ if (this._authFailed !== null)
406
+ return;
407
+ const ws = this._ws;
408
+ // A socket dialled for an earlier change is on the new network already.
409
+ if (ws && ws === this._networkDial && ws.readyState === 0 /* CONNECTING */)
410
+ return;
411
+ if (ws) {
412
+ console.info('Network changed; reconnecting the WebSocket');
413
+ this._onClose(ws);
414
+ ws.close();
415
+ }
416
+ this._cancelReconnect();
417
+ this._wsReconnectDelay = INITIAL_RECONNECT_DELAY_MS;
418
+ if (this._handlers.size === 0 && this._pendingCalls.size === 0) {
419
+ this._notifyNetworkChange();
420
+ return;
421
+ }
422
+ this._networkChanged = true;
423
+ this._ensureWs();
424
+ this._networkDial = this._ws;
425
+ }
426
+ _notifyNetworkChange() {
427
+ for (const cb of [...this._networkCallbacks])
428
+ callSafely(cb, 'Error in network-change callback:');
292
429
  }
293
430
  /** `reason` is set when the executor asked to try again later; calls that fail carry it. */
294
431
  _onClose(ws, reason) {
@@ -325,19 +462,56 @@ class ApiClient {
325
462
  for (const cb of [...this._authFailedCallbacks])
326
463
  callSafely(cb, 'Error in auth-failed callback:', reason);
327
464
  }
328
- _startPing() {
465
+ _startPing(ws) {
329
466
  this._stopPing();
467
+ this._wsPingedAt = null;
468
+ this._wsSentBy = 0;
330
469
  this._wsPingTimer = setInterval(() => {
331
- if (this._ws?.readyState === 1 /* OPEN */) {
332
- this._ws.send(JSON.stringify({ type: 'ping' }));
470
+ if (this._ws !== ws)
471
+ return;
472
+ // A probe has its own, shorter deadline and decides for this ping.
473
+ if (this._wsProbeTimer)
474
+ return;
475
+ const ping = JSON.stringify({ type: 'ping' });
476
+ if (this._wsPingedAt === null) {
477
+ this._wsPingedAt = performance.now();
478
+ this._send(ws, ping);
479
+ this._wsPingArrivesBy = this._wsSentBy;
480
+ return;
481
+ }
482
+ if (performance.now() >= Math.max(this._wsPingedAt + PING_INTERVAL_MS, this._wsPingArrivesBy + PONG_RETURN_MS)) {
483
+ this._dropSilentSocket(ws);
484
+ return;
333
485
  }
334
- }, 30000);
486
+ this._send(ws, ping);
487
+ }, PING_INTERVAL_MS);
488
+ }
489
+ /** Send on `ws`, counting how long what the open socket sent could take to cross the slowest link. */
490
+ _send(ws, text) {
491
+ if (this._ws === ws)
492
+ this._wsSentBy = Math.max(this._wsSentBy, performance.now()) + utf8Length(text) / SLOWEST_LINK_BYTES_PER_MS;
493
+ ws.send(text);
494
+ }
495
+ /** The socket answered nothing for a whole ping interval: treat it as
496
+ * closed now. Its close event can take minutes on a dead connection,
497
+ * since the close frame gets no answer either; `_onClose` ignores it then. */
498
+ _dropSilentSocket(ws) {
499
+ console.warn(`WebSocket silent for ${performance.now() - (this._wsPingedAt ?? performance.now())} ms after a ping; reconnecting`);
500
+ this._onClose(ws);
501
+ ws.close();
335
502
  }
336
503
  _stopPing() {
337
504
  if (this._wsPingTimer) {
338
505
  clearInterval(this._wsPingTimer);
339
506
  this._wsPingTimer = null;
340
507
  }
508
+ this._endProbe();
509
+ }
510
+ _endProbe() {
511
+ if (this._wsProbeTimer) {
512
+ clearTimeout(this._wsProbeTimer);
513
+ this._wsProbeTimer = null;
514
+ }
341
515
  }
342
516
  _scheduleReconnect() {
343
517
  if (this._wsReconnectTimer || this._authFailed !== null)
@@ -346,8 +520,54 @@ class ApiClient {
346
520
  this._wsReconnectDelay = Math.min(this._wsReconnectDelay * 2, MAX_RECONNECT_DELAY_MS);
347
521
  this._wsReconnectTimer = setTimeout(() => {
348
522
  this._wsReconnectTimer = null;
523
+ this._listenForWake(false);
349
524
  this._ensureWs();
350
525
  }, delay);
526
+ this._listenForWake(true);
527
+ }
528
+ /** End the wait for the next dial, if one is pending, without dialling. */
529
+ _cancelReconnect() {
530
+ if (this._wsReconnectTimer) {
531
+ clearTimeout(this._wsReconnectTimer);
532
+ this._wsReconnectTimer = null;
533
+ }
534
+ this._listenForWake(false);
535
+ }
536
+ /**
537
+ * Dial now if the client is waiting out its reconnect backoff (up to 30 s)
538
+ * instead of letting the wait run out. For the moments the host knows the
539
+ * executor may be reachable again: an executor it restarted is up, the
540
+ * device woke. In a browser the client does this itself on `online` and when
541
+ * the page becomes visible. Does nothing while a socket is open or
542
+ * connecting, after `closeAll()` with nothing to reconnect, or once the
543
+ * executor refused the token.
544
+ */
545
+ reconnectNow() {
546
+ if (!this._wsReconnectTimer || this._ws || this._authFailed !== null)
547
+ return;
548
+ this._cancelReconnect();
549
+ // The executor is likely back, so a failure now starts the backoff over.
550
+ this._wsReconnectDelay = INITIAL_RECONNECT_DELAY_MS;
551
+ this._ensureWs();
552
+ }
553
+ /** Listen for `online` and `visibilitychange` exactly while a reconnect
554
+ * timer is pending. Outside a browser (no `window`) it registers nothing. */
555
+ _listenForWake(on) {
556
+ if (on === this._wakeListening)
557
+ return;
558
+ const win = typeof window !== 'undefined' ? window : undefined;
559
+ if (typeof win?.addEventListener !== 'function')
560
+ return;
561
+ const doc = typeof document !== 'undefined' && typeof document.addEventListener === 'function' ? document : undefined;
562
+ this._wakeListening = on;
563
+ if (on) {
564
+ win.addEventListener('online', this._onWake);
565
+ doc?.addEventListener('visibilitychange', this._onWake);
566
+ }
567
+ else {
568
+ win.removeEventListener('online', this._onWake);
569
+ doc?.removeEventListener('visibilitychange', this._onWake);
570
+ }
351
571
  }
352
572
  // ── RPC call method ─────────────────────────────────────────────────────
353
573
  /**
@@ -393,7 +613,7 @@ class ApiClient {
393
613
  }, timeoutMs);
394
614
  const onAbort = () => {
395
615
  if (pending.sent && this._ws?.readyState === 1 /* OPEN */) {
396
- this._ws.send(JSON.stringify({ id: nextId(), type: 'request.cancel', params: { targetId: id } }));
616
+ this._send(this._ws, JSON.stringify({ id: nextId(), type: 'request.cancel', params: { targetId: id } }));
397
617
  }
398
618
  settle(() => reject(new DOMException('Aborted', 'AbortError')));
399
619
  };
@@ -416,7 +636,7 @@ class ApiClient {
416
636
  return;
417
637
  }
418
638
  if (this._ws.readyState === 1 /* OPEN */) {
419
- this._ws.send(message);
639
+ this._send(this._ws, message);
420
640
  pending.sent = true;
421
641
  }
422
642
  });
@@ -537,10 +757,7 @@ class ApiClient {
537
757
  clearTimeout(this._watchRetryTimer);
538
758
  this._watchRetryTimer = null;
539
759
  }
540
- if (this._wsReconnectTimer) {
541
- clearTimeout(this._wsReconnectTimer);
542
- this._wsReconnectTimer = null;
543
- }
760
+ this._cancelReconnect();
544
761
  const ws = this._ws;
545
762
  this._ws = null;
546
763
  this._wsOpen = null;
@@ -553,6 +770,46 @@ class ApiClient {
553
770
  this._reconnectCallbacks.add(callback);
554
771
  return () => { this._reconnectCallbacks.delete(callback); };
555
772
  }
773
+ /** Register a callback that fires after the network changed (`online`,
774
+ * or a socket that failed `checkConnection`), once the socket dialled for the
775
+ * new network is open and its event watch sent. Calls made from it go
776
+ * out on that socket. Returns an unsubscribe function. */
777
+ onNetworkChange(callback) {
778
+ this._networkCallbacks.add(callback);
779
+ this._listenForNetworkChanges();
780
+ return () => { this._networkCallbacks.delete(callback); };
781
+ }
782
+ /**
783
+ * Check the open socket now rather than at the next ping: send a ping,
784
+ * and if nothing at all arrives on that socket within `deadlineMs`,
785
+ * treat it as a network change (drop it, dial the next one at once,
786
+ * `onNetworkChange` callbacks fire when it opens). Any message keeps it.
787
+ * For a caller that has seen its network path break, e.g. ICE going
788
+ * disconnected, where the platform fired no `online` event. Without an
789
+ * open socket, or while a check runs, this does nothing.
790
+ */
791
+ checkConnection(deadlineMs = CHECK_CONNECTION_DEADLINE_MS) {
792
+ const ws = this._ws;
793
+ if (!ws || ws.readyState !== 1 /* OPEN */ || this._wsProbeTimer)
794
+ return;
795
+ const first = this._wsPingedAt === null;
796
+ if (first)
797
+ this._wsPingedAt = performance.now();
798
+ this._send(ws, JSON.stringify({ type: 'ping' }));
799
+ if (first)
800
+ this._wsPingArrivesBy = this._wsSentBy;
801
+ // Any message from the socket ends the probe (`onmessage` → `_endProbe`).
802
+ // The ping reaches the executor only after what was sent before it,
803
+ // and its pong gets half the deadline to come back after that.
804
+ const wait = Math.max(deadlineMs, this._wsSentBy - performance.now() + deadlineMs / 2);
805
+ this._wsProbeTimer = setTimeout(() => {
806
+ this._wsProbeTimer = null;
807
+ if (this._ws !== ws)
808
+ return;
809
+ console.warn(`WebSocket silent for ${wait} ms after a check; reconnecting`);
810
+ this._onNetworkChange();
811
+ }, wait);
812
+ }
556
813
  /** Register a callback that fires once when the executor refuses this
557
814
  * client's token: a 401 reply, or a socket closed with code 1008. Every
558
815
  * call then fails with a 401 `RpcError` and the client does not reconnect;
@@ -570,6 +827,11 @@ class ApiClient {
570
827
  this._handlers.clear();
571
828
  this._reconnectCallbacks.clear();
572
829
  this._authFailedCallbacks.clear();
830
+ this._networkCallbacks.clear();
831
+ this._unlistenNetwork?.();
832
+ this._unlistenNetwork = null;
833
+ this._networkChanged = false;
834
+ this._networkDial = null;
573
835
  // A reused client must not fire onReconnect on its next first open.
574
836
  this._hasConnectedOnce = false;
575
837
  }
@@ -831,6 +1093,9 @@ class Agent {
831
1093
  static fromWire(wire) {
832
1094
  const agent = new Agent(wire.did, Perspective.fromWire(wire.perspective));
833
1095
  agent.directMessageLanguage = wire.directMessageLanguage;
1096
+ if ("identity" in wire && wire.identity) {
1097
+ agent.identity = wire.identity;
1098
+ }
834
1099
  return agent;
835
1100
  }
836
1101
  }
@@ -986,6 +1251,8 @@ class AgentStatus {
986
1251
  this.didDocument = obj.didDocument;
987
1252
  //@ts-ignore
988
1253
  this.error = obj.error;
1254
+ //@ts-ignore
1255
+ this.identity = obj.identity ?? null;
989
1256
  }
990
1257
  else {
991
1258
  this.isInitialized = false;
@@ -1007,13 +1274,13 @@ class AgentStatus {
1007
1274
  * never need try/catch around cache operations
1008
1275
  * - Tree-shakeable: import only what you need
1009
1276
  */
1010
- var __classPrivateFieldSet$d = (undefined && undefined.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
1277
+ var __classPrivateFieldSet$e = (undefined && undefined.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
1011
1278
  if (kind === "m") throw new TypeError("Private method is not writable");
1012
1279
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
1013
1280
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
1014
1281
  return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
1015
1282
  };
1016
- var __classPrivateFieldGet$d = (undefined && undefined.__classPrivateFieldGet) || function (receiver, state, kind, f) {
1283
+ var __classPrivateFieldGet$e = (undefined && undefined.__classPrivateFieldGet) || function (receiver, state, kind, f) {
1017
1284
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
1018
1285
  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");
1019
1286
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
@@ -1027,15 +1294,15 @@ class IDBCache {
1027
1294
  _IDBCache_storeName.set(this, void 0);
1028
1295
  _IDBCache_dbPromise.set(this, null);
1029
1296
  _IDBCache_version.set(this, 1);
1030
- __classPrivateFieldSet$d(this, _IDBCache_dbName, dbName, "f");
1031
- __classPrivateFieldSet$d(this, _IDBCache_storeName, storeName, "f");
1297
+ __classPrivateFieldSet$e(this, _IDBCache_dbName, dbName, "f");
1298
+ __classPrivateFieldSet$e(this, _IDBCache_storeName, storeName, "f");
1032
1299
  }
1033
1300
  async get(key) {
1034
1301
  try {
1035
- const db = await __classPrivateFieldGet$d(this, _IDBCache_instances, "m", _IDBCache_open).call(this);
1302
+ const db = await __classPrivateFieldGet$e(this, _IDBCache_instances, "m", _IDBCache_open).call(this);
1036
1303
  return new Promise((resolve) => {
1037
- const tx = db.transaction(__classPrivateFieldGet$d(this, _IDBCache_storeName, "f"), 'readonly');
1038
- const store = tx.objectStore(__classPrivateFieldGet$d(this, _IDBCache_storeName, "f"));
1304
+ const tx = db.transaction(__classPrivateFieldGet$e(this, _IDBCache_storeName, "f"), 'readonly');
1305
+ const store = tx.objectStore(__classPrivateFieldGet$e(this, _IDBCache_storeName, "f"));
1039
1306
  const req = store.get(key);
1040
1307
  req.onsuccess = () => resolve(req.result ?? undefined);
1041
1308
  req.onerror = () => resolve(undefined);
@@ -1047,10 +1314,10 @@ class IDBCache {
1047
1314
  }
1048
1315
  async put(key, value) {
1049
1316
  try {
1050
- const db = await __classPrivateFieldGet$d(this, _IDBCache_instances, "m", _IDBCache_open).call(this);
1317
+ const db = await __classPrivateFieldGet$e(this, _IDBCache_instances, "m", _IDBCache_open).call(this);
1051
1318
  return new Promise((resolve) => {
1052
- const tx = db.transaction(__classPrivateFieldGet$d(this, _IDBCache_storeName, "f"), 'readwrite');
1053
- const store = tx.objectStore(__classPrivateFieldGet$d(this, _IDBCache_storeName, "f"));
1319
+ const tx = db.transaction(__classPrivateFieldGet$e(this, _IDBCache_storeName, "f"), 'readwrite');
1320
+ const store = tx.objectStore(__classPrivateFieldGet$e(this, _IDBCache_storeName, "f"));
1054
1321
  store.put(value, key);
1055
1322
  tx.oncomplete = () => resolve();
1056
1323
  tx.onerror = () => resolve(); // fire-and-forget
@@ -1062,10 +1329,10 @@ class IDBCache {
1062
1329
  }
1063
1330
  async delete(key) {
1064
1331
  try {
1065
- const db = await __classPrivateFieldGet$d(this, _IDBCache_instances, "m", _IDBCache_open).call(this);
1332
+ const db = await __classPrivateFieldGet$e(this, _IDBCache_instances, "m", _IDBCache_open).call(this);
1066
1333
  return new Promise((resolve) => {
1067
- const tx = db.transaction(__classPrivateFieldGet$d(this, _IDBCache_storeName, "f"), 'readwrite');
1068
- const store = tx.objectStore(__classPrivateFieldGet$d(this, _IDBCache_storeName, "f"));
1334
+ const tx = db.transaction(__classPrivateFieldGet$e(this, _IDBCache_storeName, "f"), 'readwrite');
1335
+ const store = tx.objectStore(__classPrivateFieldGet$e(this, _IDBCache_storeName, "f"));
1069
1336
  store.delete(key);
1070
1337
  tx.oncomplete = () => resolve();
1071
1338
  tx.onerror = () => resolve();
@@ -1077,10 +1344,10 @@ class IDBCache {
1077
1344
  }
1078
1345
  async clear() {
1079
1346
  try {
1080
- const db = await __classPrivateFieldGet$d(this, _IDBCache_instances, "m", _IDBCache_open).call(this);
1347
+ const db = await __classPrivateFieldGet$e(this, _IDBCache_instances, "m", _IDBCache_open).call(this);
1081
1348
  return new Promise((resolve) => {
1082
- const tx = db.transaction(__classPrivateFieldGet$d(this, _IDBCache_storeName, "f"), 'readwrite');
1083
- const store = tx.objectStore(__classPrivateFieldGet$d(this, _IDBCache_storeName, "f"));
1349
+ const tx = db.transaction(__classPrivateFieldGet$e(this, _IDBCache_storeName, "f"), 'readwrite');
1350
+ const store = tx.objectStore(__classPrivateFieldGet$e(this, _IDBCache_storeName, "f"));
1084
1351
  store.clear();
1085
1352
  tx.oncomplete = () => resolve();
1086
1353
  tx.onerror = () => resolve();
@@ -1092,10 +1359,10 @@ class IDBCache {
1092
1359
  }
1093
1360
  }
1094
1361
  _IDBCache_dbName = new WeakMap(), _IDBCache_storeName = new WeakMap(), _IDBCache_dbPromise = new WeakMap(), _IDBCache_version = new WeakMap(), _IDBCache_instances = new WeakSet(), _IDBCache_open = function _IDBCache_open() {
1095
- if (!__classPrivateFieldGet$d(this, _IDBCache_dbPromise, "f")) {
1096
- __classPrivateFieldSet$d(this, _IDBCache_dbPromise, new Promise((resolve, reject) => {
1097
- const storeName = __classPrivateFieldGet$d(this, _IDBCache_storeName, "f");
1098
- const req = indexedDB.open(__classPrivateFieldGet$d(this, _IDBCache_dbName, "f"), __classPrivateFieldGet$d(this, _IDBCache_version, "f"));
1362
+ if (!__classPrivateFieldGet$e(this, _IDBCache_dbPromise, "f")) {
1363
+ __classPrivateFieldSet$e(this, _IDBCache_dbPromise, new Promise((resolve, reject) => {
1364
+ const storeName = __classPrivateFieldGet$e(this, _IDBCache_storeName, "f");
1365
+ const req = indexedDB.open(__classPrivateFieldGet$e(this, _IDBCache_dbName, "f"), __classPrivateFieldGet$e(this, _IDBCache_version, "f"));
1099
1366
  req.onupgradeneeded = () => {
1100
1367
  const db = req.result;
1101
1368
  if (!db.objectStoreNames.contains(storeName)) {
@@ -1106,7 +1373,7 @@ _IDBCache_dbName = new WeakMap(), _IDBCache_storeName = new WeakMap(), _IDBCache
1106
1373
  req.onerror = () => reject(req.error);
1107
1374
  }), "f");
1108
1375
  }
1109
- return __classPrivateFieldGet$d(this, _IDBCache_dbPromise, "f");
1376
+ return __classPrivateFieldGet$e(this, _IDBCache_dbPromise, "f");
1110
1377
  };
1111
1378
  // ── NullCache (no-op fallback for Node.js) ───────────────────────────
1112
1379
  class NullCache {
@@ -1134,13 +1401,13 @@ function createPersistentCache(dbName, storeName) {
1134
1401
  return new NullCache();
1135
1402
  }
1136
1403
 
1137
- var __classPrivateFieldSet$c = (undefined && undefined.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
1404
+ var __classPrivateFieldSet$d = (undefined && undefined.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
1138
1405
  if (kind === "m") throw new TypeError("Private method is not writable");
1139
1406
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
1140
1407
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
1141
1408
  return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
1142
1409
  };
1143
- var __classPrivateFieldGet$c = (undefined && undefined.__classPrivateFieldGet) || function (receiver, state, kind, f) {
1410
+ var __classPrivateFieldGet$d = (undefined && undefined.__classPrivateFieldGet) || function (receiver, state, kind, f) {
1144
1411
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
1145
1412
  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");
1146
1413
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
@@ -1162,47 +1429,50 @@ class AgentClient {
1162
1429
  // Self-DID for event-driven invalidation (no TTL for own profile)
1163
1430
  _AgentClient_selfDid.set(this, null);
1164
1431
  _AgentClient_onAgentUpdated.set(this, (event) => {
1165
- __classPrivateFieldGet$c(this, _AgentClient_instances, "m", _AgentClient_cacheAgent).call(this, Agent.fromWire(event.agent));
1432
+ __classPrivateFieldGet$d(this, _AgentClient_instances, "m", _AgentClient_cacheAgent).call(this, Agent.fromWire(event.agent));
1166
1433
  });
1167
- __classPrivateFieldSet$c(this, _AgentClient_apiClient, sharedApiClient || new ApiClient(baseUrl, token), "f");
1168
- __classPrivateFieldSet$c(this, _AgentClient_persistent, createPersistentCache('ad4m-agent-cache', 'agents'), "f");
1434
+ __classPrivateFieldSet$d(this, _AgentClient_apiClient, sharedApiClient || new ApiClient(baseUrl, token), "f");
1435
+ __classPrivateFieldSet$d(this, _AgentClient_persistent, createPersistentCache('ad4m-agent-cache', 'agents'), "f");
1169
1436
  }
1170
1437
  async me() {
1171
- const agentObject = toAgent(await __classPrivateFieldGet$c(this, _AgentClient_apiClient, "f").call('agent.get', {}));
1438
+ const agentObject = toAgent(await __classPrivateFieldGet$d(this, _AgentClient_apiClient, "f").call('agent.get', {}));
1172
1439
  // Auto-set selfDid so event-driven cache invalidation works
1173
1440
  // without requiring apps to call setSelfDid() manually
1174
- if (agentObject.did && !__classPrivateFieldGet$c(this, _AgentClient_selfDid, "f")) {
1175
- __classPrivateFieldSet$c(this, _AgentClient_selfDid, agentObject.did, "f");
1441
+ if (agentObject.did && !__classPrivateFieldGet$d(this, _AgentClient_selfDid, "f")) {
1442
+ __classPrivateFieldSet$d(this, _AgentClient_selfDid, agentObject.did, "f");
1176
1443
  }
1177
1444
  return agentObject;
1178
1445
  }
1179
1446
  async status() {
1180
- const agentStatus = await __classPrivateFieldGet$c(this, _AgentClient_apiClient, "f").call('agent.status', {});
1447
+ const agentStatus = await __classPrivateFieldGet$d(this, _AgentClient_apiClient, "f").call('agent.status', {});
1181
1448
  return new AgentStatus(agentStatus);
1182
1449
  }
1450
+ /** Creates the agent's keys and DID on first run. The executor refuses (409)
1451
+ * an agent that is already initialised — {@link unlock} it instead; a second
1452
+ * `generate` never replaces the existing keys and DID. */
1183
1453
  async generate(passphrase, options) {
1184
- const result = await __classPrivateFieldGet$c(this, _AgentClient_apiClient, "f").call('agent.generate', { passphrase }, options);
1454
+ const result = await __classPrivateFieldGet$d(this, _AgentClient_apiClient, "f").call('agent.generate', { passphrase }, options);
1185
1455
  return new AgentStatus(result);
1186
1456
  }
1187
1457
  async import(args) {
1188
- const result = await __classPrivateFieldGet$c(this, _AgentClient_apiClient, "f").call('agent.import', { ...args });
1458
+ const result = await __classPrivateFieldGet$d(this, _AgentClient_apiClient, "f").call('agent.import', { ...args });
1189
1459
  return new AgentStatus(result);
1190
1460
  }
1191
1461
  async lock(passphrase) {
1192
- const result = await __classPrivateFieldGet$c(this, _AgentClient_apiClient, "f").call('agent.lock', { passphrase });
1462
+ const result = await __classPrivateFieldGet$d(this, _AgentClient_apiClient, "f").call('agent.lock', { passphrase });
1193
1463
  return new AgentStatus(result);
1194
1464
  }
1195
1465
  async unlock(passphrase, holochain = true, options) {
1196
- const result = await __classPrivateFieldGet$c(this, _AgentClient_apiClient, "f").call('agent.unlock', { passphrase, holochain }, options);
1466
+ const result = await __classPrivateFieldGet$d(this, _AgentClient_apiClient, "f").call('agent.unlock', { passphrase, holochain }, options);
1197
1467
  return new AgentStatus(result);
1198
1468
  }
1199
1469
  async byDID(did) {
1200
1470
  // agent-updated events keep cached entries fresh (the self-DID entry has no TTL).
1201
- __classPrivateFieldGet$c(this, _AgentClient_instances, "m", _AgentClient_listen).call(this);
1471
+ __classPrivateFieldGet$d(this, _AgentClient_instances, "m", _AgentClient_listen).call(this);
1202
1472
  const now = Date.now();
1203
- const cached = __classPrivateFieldGet$c(this, _AgentClient_memCache, "f").get(did);
1473
+ const cached = __classPrivateFieldGet$d(this, _AgentClient_memCache, "f").get(did);
1204
1474
  if (cached) {
1205
- const isSelf = did === __classPrivateFieldGet$c(this, _AgentClient_selfDid, "f");
1475
+ const isSelf = did === __classPrivateFieldGet$d(this, _AgentClient_selfDid, "f");
1206
1476
  // Self-DID: L1 always valid (event-driven invalidation)
1207
1477
  // Remote DID: L1 valid within TTL
1208
1478
  if (isSelf || (now - cached.ts) < AgentClient.REMOTE_AGENT_TTL_MS) {
@@ -1212,21 +1482,21 @@ class AgentClient {
1212
1482
  // Deduplicate: store the promise immediately so concurrent calls share one RPC
1213
1483
  const promise = (async () => {
1214
1484
  // L2: check persistent cache before network
1215
- const entry = await __classPrivateFieldGet$c(this, _AgentClient_persistent, "f").get(did);
1485
+ const entry = await __classPrivateFieldGet$d(this, _AgentClient_persistent, "f").get(did);
1216
1486
  // entry.agent may be undefined for pre-TTL cache entries (migration) — treat as expired
1217
1487
  if (entry?.agent && (now - (entry.ts ?? 0)) < AgentClient.REMOTE_AGENT_TTL_L2_MS) {
1218
1488
  return entry.agent;
1219
1489
  }
1220
1490
  // L3: network fetch
1221
- const result = toAgent(await __classPrivateFieldGet$c(this, _AgentClient_apiClient, "f").call('agent.byDid', { did }));
1222
- __classPrivateFieldGet$c(this, _AgentClient_persistent, "f").put(did, { agent: result, ts: Date.now() }); // fire-and-forget write to L2
1491
+ const result = toAgent(await __classPrivateFieldGet$d(this, _AgentClient_apiClient, "f").call('agent.byDid', { did }));
1492
+ __classPrivateFieldGet$d(this, _AgentClient_persistent, "f").put(did, { agent: result, ts: Date.now() }); // fire-and-forget write to L2
1223
1493
  return result;
1224
1494
  })();
1225
- __classPrivateFieldGet$c(this, _AgentClient_memCache, "f").set(did, { promise, ts: now });
1495
+ __classPrivateFieldGet$d(this, _AgentClient_memCache, "f").set(did, { promise, ts: now });
1226
1496
  // Clean up on failure so next call retries
1227
1497
  promise.catch(() => {
1228
- if (__classPrivateFieldGet$c(this, _AgentClient_memCache, "f").get(did)?.promise === promise) {
1229
- __classPrivateFieldGet$c(this, _AgentClient_memCache, "f").delete(did);
1498
+ if (__classPrivateFieldGet$d(this, _AgentClient_memCache, "f").get(did)?.promise === promise) {
1499
+ __classPrivateFieldGet$d(this, _AgentClient_memCache, "f").delete(did);
1230
1500
  }
1231
1501
  });
1232
1502
  return promise;
@@ -1236,21 +1506,21 @@ class AgentClient {
1236
1506
  * The self-DID receives event-driven invalidation and is never TTL-expired.
1237
1507
  */
1238
1508
  setSelfDid(did) {
1239
- __classPrivateFieldSet$c(this, _AgentClient_selfDid, did, "f");
1509
+ __classPrivateFieldSet$d(this, _AgentClient_selfDid, did, "f");
1240
1510
  }
1241
1511
  /**
1242
1512
  * Invalidate a specific DID's cache entry in both L1 and L2.
1243
1513
  */
1244
1514
  invalidateByDid(did) {
1245
- __classPrivateFieldGet$c(this, _AgentClient_memCache, "f").delete(did);
1246
- __classPrivateFieldGet$c(this, _AgentClient_persistent, "f").delete(did); // fire-and-forget
1515
+ __classPrivateFieldGet$d(this, _AgentClient_memCache, "f").delete(did);
1516
+ __classPrivateFieldGet$d(this, _AgentClient_persistent, "f").delete(did); // fire-and-forget
1247
1517
  }
1248
1518
  /**
1249
1519
  * Clear the entire L1 (memory) byDID cache.
1250
1520
  * L2 (IndexedDB) is preserved — agent data remains valid across sessions.
1251
1521
  */
1252
1522
  clearByDidCache() {
1253
- __classPrivateFieldGet$c(this, _AgentClient_memCache, "f").clear();
1523
+ __classPrivateFieldGet$d(this, _AgentClient_memCache, "f").clear();
1254
1524
  }
1255
1525
  async updatePublicPerspective(perspective) {
1256
1526
  // Send only the signed fields: the public perspective carries no link status.
@@ -1262,36 +1532,36 @@ class AgentClient {
1262
1532
  proof: { key: proof.key, signature: proof.signature, valid: proof.valid, invalid: proof.invalid },
1263
1533
  })),
1264
1534
  };
1265
- const agent = toAgent(await __classPrivateFieldGet$c(this, _AgentClient_apiClient, "f").call('agent.updateProfile', { publicPerspective }));
1535
+ const agent = toAgent(await __classPrivateFieldGet$d(this, _AgentClient_apiClient, "f").call('agent.updateProfile', { publicPerspective }));
1266
1536
  // Immediately update byDID cache so subsequent byDID() calls
1267
1537
  // return fresh data without waiting for the agent-updated event
1268
- __classPrivateFieldGet$c(this, _AgentClient_instances, "m", _AgentClient_cacheAgent).call(this, agent);
1538
+ __classPrivateFieldGet$d(this, _AgentClient_instances, "m", _AgentClient_cacheAgent).call(this, agent);
1269
1539
  return agent;
1270
1540
  }
1271
1541
  async mutatePublicPerspective({ additions, removals }) {
1272
- const added = additions.length > 0 ? await __classPrivateFieldGet$c(this, _AgentClient_instances, "m", _AgentClient_signLinks).call(this, additions) : [];
1542
+ const added = additions.length > 0 ? await __classPrivateFieldGet$d(this, _AgentClient_instances, "m", _AgentClient_signLinks).call(this, additions) : [];
1273
1543
  const { perspective } = await this.me();
1274
1544
  const kept = (perspective?.links ?? []).filter(link => !removals.some(r => linkEqual(link, r)));
1275
1545
  return this.updatePublicPerspective({ links: [...kept, ...added] });
1276
1546
  }
1277
1547
  async updateDirectMessageLanguage(directMessageLanguage) {
1278
- const agent = toAgent(await __classPrivateFieldGet$c(this, _AgentClient_apiClient, "f").call('agent.updateProfile', { dmLanguage: directMessageLanguage }));
1548
+ const agent = toAgent(await __classPrivateFieldGet$d(this, _AgentClient_apiClient, "f").call('agent.updateProfile', { dmLanguage: directMessageLanguage }));
1279
1549
  // Immediately update byDID cache so subsequent byDID() calls
1280
1550
  // return fresh data without waiting for the agent-updated event
1281
- __classPrivateFieldGet$c(this, _AgentClient_instances, "m", _AgentClient_cacheAgent).call(this, agent);
1551
+ __classPrivateFieldGet$d(this, _AgentClient_instances, "m", _AgentClient_cacheAgent).call(this, agent);
1282
1552
  return agent;
1283
1553
  }
1284
1554
  async addEntanglementProofs(proofs) {
1285
- return __classPrivateFieldGet$c(this, _AgentClient_apiClient, "f").call('agent.addEntanglementProofs', { proofs });
1555
+ return __classPrivateFieldGet$d(this, _AgentClient_apiClient, "f").call('agent.addEntanglementProofs', { proofs });
1286
1556
  }
1287
1557
  async deleteEntanglementProofs(proofs) {
1288
- return __classPrivateFieldGet$c(this, _AgentClient_apiClient, "f").call('agent.deleteEntanglementProofs', { proofs });
1558
+ return __classPrivateFieldGet$d(this, _AgentClient_apiClient, "f").call('agent.deleteEntanglementProofs', { proofs });
1289
1559
  }
1290
1560
  async getEntanglementProofs() {
1291
- return __classPrivateFieldGet$c(this, _AgentClient_apiClient, "f").call('agent.getEntanglementProofs', {});
1561
+ return __classPrivateFieldGet$d(this, _AgentClient_apiClient, "f").call('agent.getEntanglementProofs', {});
1292
1562
  }
1293
1563
  async entanglementProofPreFlight(deviceKey, deviceKeyType) {
1294
- return __classPrivateFieldGet$c(this, _AgentClient_apiClient, "f").call('agent.entanglementProofPreflight', { deviceKey, deviceKeyType });
1564
+ return __classPrivateFieldGet$d(this, _AgentClient_apiClient, "f").call('agent.entanglementProofPreflight', { deviceKey, deviceKeyType });
1295
1565
  }
1296
1566
  /**
1297
1567
  * Asks the executor for a capability token. `agent` names the agent the token will act
@@ -1301,45 +1571,45 @@ class AgentClient {
1301
1571
  * six-digit code.
1302
1572
  */
1303
1573
  async requestCapability(authInfo, agent) {
1304
- return __classPrivateFieldGet$c(this, _AgentClient_apiClient, "f").call('agent.requestCapability', agent === undefined ? { authInfo } : { authInfo, agent });
1574
+ return __classPrivateFieldGet$d(this, _AgentClient_apiClient, "f").call('agent.requestCapability', agent === undefined ? { authInfo } : { authInfo, agent });
1305
1575
  }
1306
1576
  async permitCapability(auth) {
1307
- return __classPrivateFieldGet$c(this, _AgentClient_apiClient, "f").call('agent.permitCapability', { auth });
1577
+ return __classPrivateFieldGet$d(this, _AgentClient_apiClient, "f").call('agent.permitCapability', { auth });
1308
1578
  }
1309
1579
  async generateJwt(requestId, rand) {
1310
- return __classPrivateFieldGet$c(this, _AgentClient_apiClient, "f").call('agent.generateJwt', { requestId, rand });
1580
+ return __classPrivateFieldGet$d(this, _AgentClient_apiClient, "f").call('agent.generateJwt', { requestId, rand });
1311
1581
  }
1312
1582
  async getApps() {
1313
- return __classPrivateFieldGet$c(this, _AgentClient_apiClient, "f").call('agent.getApps', {});
1583
+ return __classPrivateFieldGet$d(this, _AgentClient_apiClient, "f").call('agent.getApps', {});
1314
1584
  }
1315
1585
  async removeApp(requestId) {
1316
- return __classPrivateFieldGet$c(this, _AgentClient_apiClient, "f").call('agent.removeApp', { id: requestId });
1586
+ return __classPrivateFieldGet$d(this, _AgentClient_apiClient, "f").call('agent.removeApp', { id: requestId });
1317
1587
  }
1318
1588
  async revokeToken(requestId) {
1319
- return __classPrivateFieldGet$c(this, _AgentClient_apiClient, "f").call('agent.revokeToken', { token: requestId });
1589
+ return __classPrivateFieldGet$d(this, _AgentClient_apiClient, "f").call('agent.revokeToken', { token: requestId });
1320
1590
  }
1321
1591
  async isLocked() {
1322
- return __classPrivateFieldGet$c(this, _AgentClient_apiClient, "f").call('agent.isLocked', {});
1592
+ return __classPrivateFieldGet$d(this, _AgentClient_apiClient, "f").call('agent.isLocked', {});
1323
1593
  }
1324
1594
  async signMessage(message) {
1325
- return __classPrivateFieldGet$c(this, _AgentClient_apiClient, "f").call('agent.sign', { message });
1595
+ return __classPrivateFieldGet$d(this, _AgentClient_apiClient, "f").call('agent.sign', { message });
1326
1596
  }
1327
1597
  // Multi-user methods
1328
1598
  async createUser(email, password) {
1329
- return __classPrivateFieldGet$c(this, _AgentClient_apiClient, "f").call('user.create', { email, password });
1599
+ return __classPrivateFieldGet$d(this, _AgentClient_apiClient, "f").call('user.create', { email, password });
1330
1600
  }
1331
1601
  async loginUser(email, password) {
1332
- return __classPrivateFieldGet$c(this, _AgentClient_apiClient, "f").call('user.login', { email, password });
1602
+ return __classPrivateFieldGet$d(this, _AgentClient_apiClient, "f").call('user.login', { email, password });
1333
1603
  }
1334
1604
  async requestLoginVerification(email, appInfo) {
1335
- return __classPrivateFieldGet$c(this, _AgentClient_apiClient, "f").call('user.requestVerification', { email, appInfo });
1605
+ return __classPrivateFieldGet$d(this, _AgentClient_apiClient, "f").call('user.requestVerification', { email, appInfo });
1336
1606
  }
1337
1607
  async verifyEmailCode(email, code, verificationType) {
1338
- return __classPrivateFieldGet$c(this, _AgentClient_apiClient, "f").call('user.verifyEmail', { email, code, verificationType });
1608
+ return __classPrivateFieldGet$d(this, _AgentClient_apiClient, "f").call('user.verifyEmail', { email, code, verificationType });
1339
1609
  }
1340
1610
  /** Revokes this client's user token. The executor then closes the client's sockets. */
1341
1611
  async logout() {
1342
- return __classPrivateFieldGet$c(this, _AgentClient_apiClient, "f").call('user.logout', {});
1612
+ return __classPrivateFieldGet$d(this, _AgentClient_apiClient, "f").call('user.logout', {});
1343
1613
  }
1344
1614
  /**
1345
1615
  * Revokes every token of a user issued up to now, this client's own included, and closes
@@ -1347,43 +1617,43 @@ class AgentClient {
1347
1617
  * user. Needs AGENT_UPDATE, which a login holds. Tokens from a later login work.
1348
1618
  */
1349
1619
  async revokeAllSessions(email) {
1350
- return __classPrivateFieldGet$c(this, _AgentClient_apiClient, "f").call('user.revokeAllSessions', email === undefined ? {} : { email });
1620
+ return __classPrivateFieldGet$d(this, _AgentClient_apiClient, "f").call('user.revokeAllSessions', email === undefined ? {} : { email });
1351
1621
  }
1352
1622
  // Hosting methods
1353
1623
  async hostingUserInfo() {
1354
- const info = (await __classPrivateFieldGet$c(this, _AgentClient_apiClient, "f").call('hosting.info', {})).userInfo ?? {
1624
+ const info = (await __classPrivateFieldGet$d(this, _AgentClient_apiClient, "f").call('hosting.info', {})).userInfo ?? {
1355
1625
  email: '', credits: null, hotWalletAddress: null, freeAccess: false,
1356
1626
  };
1357
1627
  return new HostingUserInfo(info.email, info.freeAccess ? 'unlimited' : String(info.credits ?? 0), info.hotWalletAddress || undefined, !!info.freeAccess);
1358
1628
  }
1359
1629
  async computeLog(since, limit, userEmail) {
1360
- return __classPrivateFieldGet$c(this, _AgentClient_apiClient, "f").call('runtime.computeLog', { since, limit, userEmail });
1630
+ return __classPrivateFieldGet$d(this, _AgentClient_apiClient, "f").call('runtime.computeLog', { since, limit, userEmail });
1361
1631
  }
1362
1632
  async setHotWalletAddress(address) {
1363
- return __classPrivateFieldGet$c(this, _AgentClient_apiClient, "f").call('hosting.setHotWallet', { address });
1633
+ return __classPrivateFieldGet$d(this, _AgentClient_apiClient, "f").call('hosting.setHotWallet', { address });
1364
1634
  }
1365
1635
  async requestPayment(amountHOT) {
1366
- return __classPrivateFieldGet$c(this, _AgentClient_apiClient, "f").call('hosting.requestPayment', { amountHOT });
1636
+ return __classPrivateFieldGet$d(this, _AgentClient_apiClient, "f").call('hosting.requestPayment', { amountHOT });
1367
1637
  }
1368
1638
  }
1369
1639
  _AgentClient_apiClient = new WeakMap(), _AgentClient_memCache = new WeakMap(), _AgentClient_persistent = new WeakMap(), _AgentClient_selfDid = new WeakMap(), _AgentClient_onAgentUpdated = new WeakMap(), _AgentClient_instances = new WeakSet(), _AgentClient_cacheAgent = function _AgentClient_cacheAgent(agent) {
1370
1640
  if (!agent.did)
1371
1641
  return;
1372
- __classPrivateFieldGet$c(this, _AgentClient_memCache, "f").set(agent.did, { promise: Promise.resolve(agent), ts: Date.now() });
1373
- __classPrivateFieldGet$c(this, _AgentClient_persistent, "f").put(agent.did, { agent, ts: Date.now() }); // fire-and-forget
1374
- __classPrivateFieldGet$c(this, _AgentClient_instances, "m", _AgentClient_listen).call(this);
1642
+ __classPrivateFieldGet$d(this, _AgentClient_memCache, "f").set(agent.did, { promise: Promise.resolve(agent), ts: Date.now() });
1643
+ __classPrivateFieldGet$d(this, _AgentClient_persistent, "f").put(agent.did, { agent, ts: Date.now() }); // fire-and-forget
1644
+ __classPrivateFieldGet$d(this, _AgentClient_instances, "m", _AgentClient_listen).call(this);
1375
1645
  }, _AgentClient_signLinks =
1376
1646
  /** Has the executor sign `links` as this agent, in a throwaway perspective. */
1377
1647
  async function _AgentClient_signLinks(links) {
1378
- const { uuid } = await __classPrivateFieldGet$c(this, _AgentClient_apiClient, "f").call('perspective.create', { name: 'Agent Perspective Proxy' });
1648
+ const { uuid } = await __classPrivateFieldGet$d(this, _AgentClient_apiClient, "f").call('perspective.create', { name: 'Agent Perspective Proxy' });
1379
1649
  try {
1380
- return (await __classPrivateFieldGet$c(this, _AgentClient_apiClient, "f").call('perspective.addLinks', { uuid, links, status: 'SHARED' })).map(LinkExpression.fromWire);
1650
+ return (await __classPrivateFieldGet$d(this, _AgentClient_apiClient, "f").call('perspective.addLinks', { uuid, links, status: 'SHARED' })).map(LinkExpression.fromWire);
1381
1651
  }
1382
1652
  finally {
1383
- await __classPrivateFieldGet$c(this, _AgentClient_apiClient, "f").call('perspective.remove', { uuid });
1653
+ await __classPrivateFieldGet$d(this, _AgentClient_apiClient, "f").call('perspective.remove', { uuid });
1384
1654
  }
1385
1655
  }, _AgentClient_listen = function _AgentClient_listen() {
1386
- __classPrivateFieldGet$c(this, _AgentClient_apiClient, "f").on('agent-updated', __classPrivateFieldGet$c(this, _AgentClient_onAgentUpdated, "f"));
1656
+ __classPrivateFieldGet$d(this, _AgentClient_apiClient, "f").on('agent-updated', __classPrivateFieldGet$d(this, _AgentClient_onAgentUpdated, "f"));
1387
1657
  };
1388
1658
  /** TTL for remote (non-self) agent profiles in L1 cache (ms). */
1389
1659
  AgentClient.REMOTE_AGENT_TTL_MS = 5 * 60000; // 5 minutes
@@ -1391,13 +1661,13 @@ AgentClient.REMOTE_AGENT_TTL_MS = 5 * 60000; // 5 minutes
1391
1661
  * After this window any restart triggers a fresh network fetch. */
1392
1662
  AgentClient.REMOTE_AGENT_TTL_L2_MS = 5 * 60000; // 5 minutes
1393
1663
 
1394
- var __classPrivateFieldSet$b = (undefined && undefined.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
1664
+ var __classPrivateFieldSet$c = (undefined && undefined.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
1395
1665
  if (kind === "m") throw new TypeError("Private method is not writable");
1396
1666
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
1397
1667
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
1398
1668
  return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
1399
1669
  };
1400
- var __classPrivateFieldGet$b = (undefined && undefined.__classPrivateFieldGet) || function (receiver, state, kind, f) {
1670
+ var __classPrivateFieldGet$c = (undefined && undefined.__classPrivateFieldGet) || function (receiver, state, kind, f) {
1401
1671
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
1402
1672
  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");
1403
1673
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
@@ -1406,34 +1676,34 @@ var _LanguageClient_apiClient;
1406
1676
  class LanguageClient {
1407
1677
  constructor(baseUrl, token, sharedApiClient) {
1408
1678
  _LanguageClient_apiClient.set(this, void 0);
1409
- __classPrivateFieldSet$b(this, _LanguageClient_apiClient, sharedApiClient || new ApiClient(baseUrl, token), "f");
1679
+ __classPrivateFieldSet$c(this, _LanguageClient_apiClient, sharedApiClient || new ApiClient(baseUrl, token), "f");
1410
1680
  }
1411
1681
  async byAddress(address) {
1412
- return __classPrivateFieldGet$b(this, _LanguageClient_apiClient, "f").call('language.get', { address });
1682
+ return __classPrivateFieldGet$c(this, _LanguageClient_apiClient, "f").call('language.get', { address });
1413
1683
  }
1414
1684
  async byFilter(filter) {
1415
- return __classPrivateFieldGet$b(this, _LanguageClient_apiClient, "f").call('language.all', { filter });
1685
+ return __classPrivateFieldGet$c(this, _LanguageClient_apiClient, "f").call('language.all', { filter });
1416
1686
  }
1417
1687
  async all() {
1418
- return __classPrivateFieldGet$b(this, _LanguageClient_apiClient, "f").call('language.all', {});
1688
+ return __classPrivateFieldGet$c(this, _LanguageClient_apiClient, "f").call('language.all', {});
1419
1689
  }
1420
1690
  async writeSettings(languageAddress, settings) {
1421
- return __classPrivateFieldGet$b(this, _LanguageClient_apiClient, "f").call('language.writeSettings', { address: languageAddress, settings });
1691
+ return __classPrivateFieldGet$c(this, _LanguageClient_apiClient, "f").call('language.writeSettings', { address: languageAddress, settings });
1422
1692
  }
1423
1693
  async applyTemplateAndPublish(sourceLanguageHash, templateData, options) {
1424
- return __classPrivateFieldGet$b(this, _LanguageClient_apiClient, "f").call('language.applyTemplate', { sourceLanguageHash, templateData }, options);
1694
+ return __classPrivateFieldGet$c(this, _LanguageClient_apiClient, "f").call('language.applyTemplate', { sourceLanguageHash, templateData }, options);
1425
1695
  }
1426
1696
  async publish(languagePath, languageMeta, options) {
1427
- return __classPrivateFieldGet$b(this, _LanguageClient_apiClient, "f").call('language.publish', { languagePath, languageMeta }, options);
1697
+ return __classPrivateFieldGet$c(this, _LanguageClient_apiClient, "f").call('language.publish', { languagePath, languageMeta }, options);
1428
1698
  }
1429
1699
  async meta(address) {
1430
- return __classPrivateFieldGet$b(this, _LanguageClient_apiClient, "f").call('language.meta', { address });
1700
+ return __classPrivateFieldGet$c(this, _LanguageClient_apiClient, "f").call('language.meta', { address });
1431
1701
  }
1432
1702
  async source(address) {
1433
- return __classPrivateFieldGet$b(this, _LanguageClient_apiClient, "f").call('language.source', { address });
1703
+ return __classPrivateFieldGet$c(this, _LanguageClient_apiClient, "f").call('language.source', { address });
1434
1704
  }
1435
1705
  async remove(address) {
1436
- return __classPrivateFieldGet$b(this, _LanguageClient_apiClient, "f").call('language.remove', { address });
1706
+ return __classPrivateFieldGet$c(this, _LanguageClient_apiClient, "f").call('language.remove', { address });
1437
1707
  }
1438
1708
  }
1439
1709
  _LanguageClient_apiClient = new WeakMap();
@@ -1485,13 +1755,13 @@ function neighbourhoodExpressionFromWire(wire) {
1485
1755
  return new NeighbourhoodExpression(wire.author, wire.timestamp, new Neighbourhood(wire.data.linkLanguage, meta), wire.proof);
1486
1756
  }
1487
1757
 
1488
- var __classPrivateFieldSet$a = (undefined && undefined.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
1758
+ var __classPrivateFieldSet$b = (undefined && undefined.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
1489
1759
  if (kind === "m") throw new TypeError("Private method is not writable");
1490
1760
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
1491
1761
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
1492
1762
  return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
1493
1763
  };
1494
- var __classPrivateFieldGet$a = (undefined && undefined.__classPrivateFieldGet) || function (receiver, state, kind, f) {
1764
+ var __classPrivateFieldGet$b = (undefined && undefined.__classPrivateFieldGet) || function (receiver, state, kind, f) {
1495
1765
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
1496
1766
  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");
1497
1767
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
@@ -1502,59 +1772,59 @@ class NeighbourhoodClient {
1502
1772
  _NeighbourhoodClient_apiClient.set(this, void 0);
1503
1773
  _NeighbourhoodClient_signalHandlers.set(this, new Map());
1504
1774
  _NeighbourhoodClient_signalUnsubscribers.set(this, new Map());
1505
- __classPrivateFieldSet$a(this, _NeighbourhoodClient_apiClient, sharedApiClient || new ApiClient(baseUrl, token), "f");
1775
+ __classPrivateFieldSet$b(this, _NeighbourhoodClient_apiClient, sharedApiClient || new ApiClient(baseUrl, token), "f");
1506
1776
  }
1507
1777
  async publishFromPerspective(perspectiveUUID, linkLanguage, meta, options) {
1508
- return __classPrivateFieldGet$a(this, _NeighbourhoodClient_apiClient, "f").call('neighbourhood.publish', {
1778
+ return __classPrivateFieldGet$b(this, _NeighbourhoodClient_apiClient, "f").call('neighbourhood.publish', {
1509
1779
  perspectiveUuid: perspectiveUUID, linkLanguage, meta: Perspective.toWire(meta)
1510
1780
  }, options);
1511
1781
  }
1512
1782
  async joinFromUrl(url, options) {
1513
- return PerspectiveHandle.fromWire(await __classPrivateFieldGet$a(this, _NeighbourhoodClient_apiClient, "f").call('neighbourhood.join', { url }, options));
1783
+ return PerspectiveHandle.fromWire(await __classPrivateFieldGet$b(this, _NeighbourhoodClient_apiClient, "f").call('neighbourhood.join', { url }, options));
1514
1784
  }
1515
1785
  async otherAgents(perspectiveUUID) {
1516
- return __classPrivateFieldGet$a(this, _NeighbourhoodClient_apiClient, "f").call('neighbourhood.otherAgents', { uuid: perspectiveUUID });
1786
+ return __classPrivateFieldGet$b(this, _NeighbourhoodClient_apiClient, "f").call('neighbourhood.otherAgents', { uuid: perspectiveUUID });
1517
1787
  }
1518
1788
  async hasTelepresenceAdapter(perspectiveUUID) {
1519
- return __classPrivateFieldGet$a(this, _NeighbourhoodClient_apiClient, "f").call('neighbourhood.hasTelepresence', { uuid: perspectiveUUID });
1789
+ return __classPrivateFieldGet$b(this, _NeighbourhoodClient_apiClient, "f").call('neighbourhood.hasTelepresence', { uuid: perspectiveUUID });
1520
1790
  }
1521
1791
  async onlineAgents(perspectiveUUID) {
1522
- const agents = await __classPrivateFieldGet$a(this, _NeighbourhoodClient_apiClient, "f").call('neighbourhood.onlineAgents', { uuid: perspectiveUUID });
1792
+ const agents = await __classPrivateFieldGet$b(this, _NeighbourhoodClient_apiClient, "f").call('neighbourhood.onlineAgents', { uuid: perspectiveUUID });
1523
1793
  return agents.map(({ did, status }) => ({ did, status: PerspectiveExpression.fromWire(status) }));
1524
1794
  }
1525
1795
  /** The caller's own online status, as it last set it on this executor, or `null`. */
1526
1796
  async ownOnlineStatus(perspectiveUUID) {
1527
- const status = await __classPrivateFieldGet$a(this, _NeighbourhoodClient_apiClient, "f").call('neighbourhood.ownOnlineStatus', { uuid: perspectiveUUID });
1797
+ const status = await __classPrivateFieldGet$b(this, _NeighbourhoodClient_apiClient, "f").call('neighbourhood.ownOnlineStatus', { uuid: perspectiveUUID });
1528
1798
  return status ? PerspectiveExpression.fromWire(status) : null;
1529
1799
  }
1530
1800
  async setOnlineStatus(perspectiveUUID, status) {
1531
- return __classPrivateFieldGet$a(this, _NeighbourhoodClient_apiClient, "f").call('neighbourhood.setOnlineStatus', { uuid: perspectiveUUID, status: Perspective.toWire(status) });
1801
+ return __classPrivateFieldGet$b(this, _NeighbourhoodClient_apiClient, "f").call('neighbourhood.setOnlineStatus', { uuid: perspectiveUUID, status: Perspective.toWire(status) });
1532
1802
  }
1533
1803
  async setOnlineStatusU(perspectiveUUID, status) {
1534
- return __classPrivateFieldGet$a(this, _NeighbourhoodClient_apiClient, "f").call('neighbourhood.setOnlineStatus', { uuid: perspectiveUUID, status, signed: false });
1804
+ return __classPrivateFieldGet$b(this, _NeighbourhoodClient_apiClient, "f").call('neighbourhood.setOnlineStatus', { uuid: perspectiveUUID, status, signed: false });
1535
1805
  }
1536
1806
  async sendSignal(perspectiveUUID, remoteAgentDid, payload) {
1537
- return __classPrivateFieldGet$a(this, _NeighbourhoodClient_apiClient, "f").call('neighbourhood.sendSignal', {
1807
+ return __classPrivateFieldGet$b(this, _NeighbourhoodClient_apiClient, "f").call('neighbourhood.sendSignal', {
1538
1808
  uuid: perspectiveUUID, remoteAgentDid, payload: Perspective.toWire(payload)
1539
1809
  });
1540
1810
  }
1541
1811
  async sendSignalU(perspectiveUUID, remoteAgentDid, payload) {
1542
- return __classPrivateFieldGet$a(this, _NeighbourhoodClient_apiClient, "f").call('neighbourhood.sendSignal', {
1812
+ return __classPrivateFieldGet$b(this, _NeighbourhoodClient_apiClient, "f").call('neighbourhood.sendSignal', {
1543
1813
  uuid: perspectiveUUID, remoteAgentDid, payload, signed: false
1544
1814
  });
1545
1815
  }
1546
1816
  async sendBroadcast(perspectiveUUID, payload, loopback = false) {
1547
- return __classPrivateFieldGet$a(this, _NeighbourhoodClient_apiClient, "f").call('neighbourhood.sendBroadcast', {
1817
+ return __classPrivateFieldGet$b(this, _NeighbourhoodClient_apiClient, "f").call('neighbourhood.sendBroadcast', {
1548
1818
  uuid: perspectiveUUID, payload: Perspective.toWire(payload), loopback
1549
1819
  });
1550
1820
  }
1551
1821
  async sendBroadcastU(perspectiveUUID, payload, loopback = false) {
1552
- return __classPrivateFieldGet$a(this, _NeighbourhoodClient_apiClient, "f").call('neighbourhood.sendBroadcast', {
1822
+ return __classPrivateFieldGet$b(this, _NeighbourhoodClient_apiClient, "f").call('neighbourhood.sendBroadcast', {
1553
1823
  uuid: perspectiveUUID, payload, loopback, signed: false
1554
1824
  });
1555
1825
  }
1556
1826
  dispatchSignal(perspectiveUUID, signal) {
1557
- const handlers = __classPrivateFieldGet$a(this, _NeighbourhoodClient_signalHandlers, "f").get(perspectiveUUID);
1827
+ const handlers = __classPrivateFieldGet$b(this, _NeighbourhoodClient_signalHandlers, "f").get(perspectiveUUID);
1558
1828
  if (handlers) {
1559
1829
  for (const handler of handlers) {
1560
1830
  try {
@@ -1567,15 +1837,15 @@ class NeighbourhoodClient {
1567
1837
  }
1568
1838
  }
1569
1839
  async subscribeToSignals(perspectiveUUID) {
1570
- const unsub = __classPrivateFieldGet$a(this, _NeighbourhoodClient_apiClient, "f").on('signal', (event) => this.dispatchSignal(perspectiveUUID, PerspectiveExpression.fromWire(event.signal)), { perspective: perspectiveUUID });
1571
- __classPrivateFieldGet$a(this, _NeighbourhoodClient_signalUnsubscribers, "f").set(perspectiveUUID, unsub);
1572
- await __classPrivateFieldGet$a(this, _NeighbourhoodClient_apiClient, "f").watchApplied();
1840
+ const unsub = __classPrivateFieldGet$b(this, _NeighbourhoodClient_apiClient, "f").on('signal', (event) => this.dispatchSignal(perspectiveUUID, PerspectiveExpression.fromWire(event.signal)), { perspective: perspectiveUUID });
1841
+ __classPrivateFieldGet$b(this, _NeighbourhoodClient_signalUnsubscribers, "f").set(perspectiveUUID, unsub);
1842
+ await __classPrivateFieldGet$b(this, _NeighbourhoodClient_apiClient, "f").watchApplied();
1573
1843
  }
1574
1844
  async addSignalHandler(perspectiveUUID, handler) {
1575
- let handlersForPerspective = __classPrivateFieldGet$a(this, _NeighbourhoodClient_signalHandlers, "f").get(perspectiveUUID);
1845
+ let handlersForPerspective = __classPrivateFieldGet$b(this, _NeighbourhoodClient_signalHandlers, "f").get(perspectiveUUID);
1576
1846
  if (!handlersForPerspective) {
1577
1847
  handlersForPerspective = [];
1578
- __classPrivateFieldGet$a(this, _NeighbourhoodClient_signalHandlers, "f").set(perspectiveUUID, handlersForPerspective);
1848
+ __classPrivateFieldGet$b(this, _NeighbourhoodClient_signalHandlers, "f").set(perspectiveUUID, handlersForPerspective);
1579
1849
  handlersForPerspective.push(handler);
1580
1850
  await this.subscribeToSignals(perspectiveUUID);
1581
1851
  }
@@ -1584,18 +1854,18 @@ class NeighbourhoodClient {
1584
1854
  }
1585
1855
  }
1586
1856
  removeSignalHandler(perspectiveUUID, handler) {
1587
- const handlersForPerspective = __classPrivateFieldGet$a(this, _NeighbourhoodClient_signalHandlers, "f").get(perspectiveUUID);
1857
+ const handlersForPerspective = __classPrivateFieldGet$b(this, _NeighbourhoodClient_signalHandlers, "f").get(perspectiveUUID);
1588
1858
  if (handlersForPerspective) {
1589
1859
  const index = handlersForPerspective.indexOf(handler);
1590
1860
  if (index > -1) {
1591
1861
  handlersForPerspective.splice(index, 1);
1592
1862
  }
1593
1863
  if (handlersForPerspective.length === 0) {
1594
- __classPrivateFieldGet$a(this, _NeighbourhoodClient_signalHandlers, "f").delete(perspectiveUUID);
1595
- const unsub = __classPrivateFieldGet$a(this, _NeighbourhoodClient_signalUnsubscribers, "f").get(perspectiveUUID);
1864
+ __classPrivateFieldGet$b(this, _NeighbourhoodClient_signalHandlers, "f").delete(perspectiveUUID);
1865
+ const unsub = __classPrivateFieldGet$b(this, _NeighbourhoodClient_signalUnsubscribers, "f").get(perspectiveUUID);
1596
1866
  if (unsub) {
1597
1867
  unsub();
1598
- __classPrivateFieldGet$a(this, _NeighbourhoodClient_signalUnsubscribers, "f").delete(perspectiveUUID);
1868
+ __classPrivateFieldGet$b(this, _NeighbourhoodClient_signalUnsubscribers, "f").delete(perspectiveUUID);
1599
1869
  }
1600
1870
  }
1601
1871
  }
@@ -1608,49 +1878,65 @@ class NeighbourhoodClient {
1608
1878
  // structured `CallSessionInfo` (SDP answer + optional cascade
1609
1879
  // redirect + stream mapping).
1610
1880
  async sfuStartRoom(neighbourhoodUrl, roomName) {
1611
- return __classPrivateFieldGet$a(this, _NeighbourhoodClient_apiClient, "f").call("sfu.startRoom", { neighbourhoodUrl, roomName });
1881
+ return __classPrivateFieldGet$b(this, _NeighbourhoodClient_apiClient, "f").call("sfu.startRoom", { neighbourhoodUrl, roomName });
1612
1882
  }
1613
1883
  async sfuStopRoom(neighbourhoodUrl, roomName) {
1614
- return __classPrivateFieldGet$a(this, _NeighbourhoodClient_apiClient, "f").call("sfu.stopRoom", { neighbourhoodUrl, roomName });
1884
+ return __classPrivateFieldGet$b(this, _NeighbourhoodClient_apiClient, "f").call("sfu.stopRoom", { neighbourhoodUrl, roomName });
1615
1885
  }
1616
1886
  async sfuListRooms() {
1617
- return __classPrivateFieldGet$a(this, _NeighbourhoodClient_apiClient, "f").call("sfu.listRooms", {});
1887
+ return __classPrivateFieldGet$b(this, _NeighbourhoodClient_apiClient, "f").call("sfu.listRooms", {});
1618
1888
  }
1619
1889
  async sfuCallJoin(neighbourhoodUrl, roomName, sdpOffer) {
1620
- return __classPrivateFieldGet$a(this, _NeighbourhoodClient_apiClient, "f").call("sfu.callJoin", {
1890
+ return __classPrivateFieldGet$b(this, _NeighbourhoodClient_apiClient, "f").call("sfu.callJoin", {
1621
1891
  neighbourhoodUrl,
1622
1892
  roomName,
1623
1893
  sdpOffer,
1624
1894
  });
1625
1895
  }
1626
1896
  async sfuCallLeave(neighbourhoodUrl, roomName) {
1627
- return __classPrivateFieldGet$a(this, _NeighbourhoodClient_apiClient, "f").call("sfu.callLeave", { neighbourhoodUrl, roomName });
1897
+ return __classPrivateFieldGet$b(this, _NeighbourhoodClient_apiClient, "f").call("sfu.callLeave", { neighbourhoodUrl, roomName });
1628
1898
  }
1629
1899
  async sfuCallSetQualityPreference(neighbourhoodUrl, roomName, preference) {
1630
- return __classPrivateFieldGet$a(this, _NeighbourhoodClient_apiClient, "f").call("sfu.callSetQualityPreference", {
1900
+ return __classPrivateFieldGet$b(this, _NeighbourhoodClient_apiClient, "f").call("sfu.callSetQualityPreference", {
1631
1901
  neighbourhoodUrl,
1632
1902
  roomName,
1633
1903
  preference,
1634
1904
  });
1635
1905
  }
1636
1906
  async sfuCallAnswerServerOffer(neighbourhoodUrl, roomName, sdpAnswer) {
1637
- return __classPrivateFieldGet$a(this, _NeighbourhoodClient_apiClient, "f").call("sfu.callAnswerServerOffer", {
1907
+ return __classPrivateFieldGet$b(this, _NeighbourhoodClient_apiClient, "f").call("sfu.callAnswerServerOffer", {
1638
1908
  neighbourhoodUrl,
1639
1909
  roomName,
1640
1910
  sdpAnswer,
1641
1911
  });
1642
1912
  }
1913
+ /** Ask the SFU to restart ICE on this agent's call connection. The offer
1914
+ * arrives as an `sfu-call-renegotiation-offer` event; answer it with
1915
+ * {@link sfuCallAnswerServerOffer}. */
1916
+ async sfuCallRestartIce(neighbourhoodUrl, roomName) {
1917
+ return __classPrivateFieldGet$b(this, _NeighbourhoodClient_apiClient, "f").call("sfu.callRestartIce", { neighbourhoodUrl, roomName });
1918
+ }
1919
+ /** Fires after a network change, once the client's socket is back on
1920
+ * the new network. See {@link ApiClient.onNetworkChange}. */
1921
+ onNetworkChange(callback) {
1922
+ return __classPrivateFieldGet$b(this, _NeighbourhoodClient_apiClient, "f").onNetworkChange(callback);
1923
+ }
1924
+ /** Check the client's socket now: one that says nothing within a
1925
+ * deadline is treated as a network change. See {@link ApiClient.checkConnection}. */
1926
+ checkConnection() {
1927
+ __classPrivateFieldGet$b(this, _NeighbourhoodClient_apiClient, "f").checkConnection();
1928
+ }
1643
1929
  async sfuGetConfig(neighbourhoodUrl) {
1644
- return __classPrivateFieldGet$a(this, _NeighbourhoodClient_apiClient, "f").call("sfu.getConfig", { neighbourhoodUrl });
1930
+ return __classPrivateFieldGet$b(this, _NeighbourhoodClient_apiClient, "f").call("sfu.getConfig", { neighbourhoodUrl });
1645
1931
  }
1646
1932
  async sfuSetConfig(neighbourhoodUrl, config) {
1647
- return __classPrivateFieldGet$a(this, _NeighbourhoodClient_apiClient, "f").call("sfu.setConfig", { neighbourhoodUrl, config });
1933
+ return __classPrivateFieldGet$b(this, _NeighbourhoodClient_apiClient, "f").call("sfu.setConfig", { neighbourhoodUrl, config });
1648
1934
  }
1649
1935
  async sfuPeerForNeighbourhood(neighbourhoodUrl) {
1650
- return __classPrivateFieldGet$a(this, _NeighbourhoodClient_apiClient, "f").call("sfu.sfuPeerForNeighbourhood", { neighbourhoodUrl });
1936
+ return __classPrivateFieldGet$b(this, _NeighbourhoodClient_apiClient, "f").call("sfu.sfuPeerForNeighbourhood", { neighbourhoodUrl });
1651
1937
  }
1652
1938
  async sfuPeersForNeighbourhood(neighbourhoodUrl) {
1653
- return __classPrivateFieldGet$a(this, _NeighbourhoodClient_apiClient, "f").call("sfu.sfuPeersForNeighbourhood", { neighbourhoodUrl });
1939
+ return __classPrivateFieldGet$b(this, _NeighbourhoodClient_apiClient, "f").call("sfu.sfuPeersForNeighbourhood", { neighbourhoodUrl });
1654
1940
  }
1655
1941
  // ── Trickle ICE ───────────────────────────────────────────────────
1656
1942
  /**
@@ -1662,7 +1948,7 @@ class NeighbourhoodClient {
1662
1948
  * networks).
1663
1949
  */
1664
1950
  async sfuAddIceCandidate(neighbourhoodUrl, roomName, candidate) {
1665
- return __classPrivateFieldGet$a(this, _NeighbourhoodClient_apiClient, "f").call("sfu.addIceCandidate", {
1951
+ return __classPrivateFieldGet$b(this, _NeighbourhoodClient_apiClient, "f").call("sfu.addIceCandidate", {
1666
1952
  neighbourhoodUrl,
1667
1953
  roomName,
1668
1954
  candidate,
@@ -1675,7 +1961,7 @@ class NeighbourhoodClient {
1675
1961
  * publishes it as an `sfu-data` event.
1676
1962
  */
1677
1963
  async sfuSendData(neighbourhoodUrl, roomName, channelLabel, data, binary = false) {
1678
- return __classPrivateFieldGet$a(this, _NeighbourhoodClient_apiClient, "f").call("sfu.sendData", {
1964
+ return __classPrivateFieldGet$b(this, _NeighbourhoodClient_apiClient, "f").call("sfu.sendData", {
1679
1965
  neighbourhoodUrl,
1680
1966
  roomName,
1681
1967
  channelLabel,
@@ -1691,11 +1977,11 @@ class NeighbourhoodClient {
1691
1977
  subscribeSfuDataChannel(callback) {
1692
1978
  // A fresh handler per call: `on` merges a repeated handler, and
1693
1979
  // each subscription must own its unsubscribe.
1694
- return __classPrivateFieldGet$a(this, _NeighbourhoodClient_apiClient, "f").on("sfu-data", (message) => callback(message));
1980
+ return __classPrivateFieldGet$b(this, _NeighbourhoodClient_apiClient, "f").on("sfu-data", (message) => callback(message));
1695
1981
  }
1696
1982
  /** Subscribe to the rosters of the call rooms this agent is in: who is in each, whenever that changes. */
1697
1983
  subscribeSfuRoomRoster(callback) {
1698
- return __classPrivateFieldGet$a(this, _NeighbourhoodClient_apiClient, "f").on("sfu-room-roster", (roster) => callback(roster));
1984
+ return __classPrivateFieldGet$b(this, _NeighbourhoodClient_apiClient, "f").on("sfu-room-roster", (roster) => callback(roster));
1699
1985
  }
1700
1986
  /**
1701
1987
  * Subscribe to server-pushed SFU SDP renegotiation offers. The
@@ -1709,7 +1995,7 @@ class NeighbourhoodClient {
1709
1995
  * Returns an unsubscribe function.
1710
1996
  */
1711
1997
  subscribeSfuCallRenegotiationOffer(targetDid, callback) {
1712
- return __classPrivateFieldGet$a(this, _NeighbourhoodClient_apiClient, "f").on("sfu-call-renegotiation-offer", (event) => {
1998
+ return __classPrivateFieldGet$b(this, _NeighbourhoodClient_apiClient, "f").on("sfu-call-renegotiation-offer", (event) => {
1713
1999
  if (event.targetDid !== targetDid)
1714
2000
  return;
1715
2001
  callback({
@@ -1728,7 +2014,7 @@ class NeighbourhoodClient {
1728
2014
  * node. Returns an unsubscribe function.
1729
2015
  */
1730
2016
  subscribeSfuMigrateEvent(targetDid, callback) {
1731
- return __classPrivateFieldGet$a(this, _NeighbourhoodClient_apiClient, "f").on("sfu-migrate", (event) => {
2017
+ return __classPrivateFieldGet$b(this, _NeighbourhoodClient_apiClient, "f").on("sfu-migrate", (event) => {
1732
2018
  if (event.targetDid !== targetDid)
1733
2019
  return;
1734
2020
  callback({
@@ -1748,12 +2034,12 @@ class NeighbourhoodClient {
1748
2034
  * @param perspectiveId The neighbourhood's perspective handle UUID.
1749
2035
  */
1750
2036
  async sfuServesAllMembers(perspectiveId) {
1751
- return __classPrivateFieldGet$a(this, _NeighbourhoodClient_apiClient, "f").call("sfu.servesAllMembers", { uuid: perspectiveId });
2037
+ return __classPrivateFieldGet$b(this, _NeighbourhoodClient_apiClient, "f").call("sfu.servesAllMembers", { uuid: perspectiveId });
1752
2038
  }
1753
2039
  // ── SFU diagnostic / test-harness endpoints ────────────────────────
1754
2040
  /** The calling agent's own DID — the user's, for a user token. */
1755
2041
  async callerDid() {
1756
- return (await __classPrivateFieldGet$a(this, _NeighbourhoodClient_apiClient, "f").call("agent.status", {})).did;
2042
+ return (await __classPrivateFieldGet$b(this, _NeighbourhoodClient_apiClient, "f").call("agent.status", {})).did;
1757
2043
  }
1758
2044
  /**
1759
2045
  * Read-only: SFU service status including public reachability.
@@ -1762,7 +2048,7 @@ class NeighbourhoodClient {
1762
2048
  * determine its reachability (unknown).
1763
2049
  */
1764
2050
  async sfuStatus() {
1765
- return __classPrivateFieldGet$a(this, _NeighbourhoodClient_apiClient, "f").call("sfu.status", {});
2051
+ return __classPrivateFieldGet$b(this, _NeighbourhoodClient_apiClient, "f").call("sfu.status", {});
1766
2052
  }
1767
2053
  /**
1768
2054
  * Read-only: how many SFU↔SFU pipe transports are fully established,
@@ -1770,14 +2056,14 @@ class NeighbourhoodClient {
1770
2056
  * assertions.
1771
2057
  */
1772
2058
  async sfuCascadeStatus() {
1773
- return __classPrivateFieldGet$a(this, _NeighbourhoodClient_apiClient, "f").call("sfu.cascadeStatus", {});
2059
+ return __classPrivateFieldGet$b(this, _NeighbourhoodClient_apiClient, "f").call("sfu.cascadeStatus", {});
1774
2060
  }
1775
2061
  /**
1776
2062
  * Read-only: per-participant quality preferences the SFU event loop
1777
2063
  * currently holds. Returns `[{participantId, preference}, ...]`.
1778
2064
  */
1779
2065
  async sfuQualityPreferences() {
1780
- return __classPrivateFieldGet$a(this, _NeighbourhoodClient_apiClient, "f").call("sfu.qualityPreferences", {});
2066
+ return __classPrivateFieldGet$b(this, _NeighbourhoodClient_apiClient, "f").call("sfu.qualityPreferences", {});
1781
2067
  }
1782
2068
  /**
1783
2069
  * Register a DID as a neighbourhood member on this executor.
@@ -1786,7 +2072,7 @@ class NeighbourhoodClient {
1786
2072
  * deployments.
1787
2073
  */
1788
2074
  async sfuEnsureMembership(neighbourhoodUrl, did) {
1789
- return __classPrivateFieldGet$a(this, _NeighbourhoodClient_apiClient, "f").call("sfu.ensureMembership", {
2075
+ return __classPrivateFieldGet$b(this, _NeighbourhoodClient_apiClient, "f").call("sfu.ensureMembership", {
1790
2076
  neighbourhoodUrl,
1791
2077
  did,
1792
2078
  });
@@ -1838,10 +2124,17 @@ class SfuManager {
1838
2124
  this.qualityPreference = null;
1839
2125
  /** Server offers waiting to be applied, in arrival order, one at a time. */
1840
2126
  this.offerQueue = Promise.resolve();
2127
+ /** The last server offer answered. The executor sends an unanswered
2128
+ * restart offer again when asked twice; one that was answered meanwhile
2129
+ * must not be answered again, or that answer lands on its next offer. */
2130
+ this.answeredOffer = null;
1841
2131
  this.renegotiationUnsubscribe = null;
1842
2132
  this.rosterUnsubscribe = null;
1843
2133
  this.dataChannelUnsubscribe = null;
1844
- this.disconnectedTimer = null;
2134
+ /** An ICE restart is in flight until this fires: ICE going disconnected
2135
+ * again joins it, a network change replaces it. */
2136
+ this.restartTimer = null;
2137
+ this.networkUnsubscribe = null;
1845
2138
  /** Running while the room's roster leaves this agent out: see `noticeRoster`. */
1846
2139
  this.unlistedTimer = null;
1847
2140
  this.neighbourhood = neighbourhood;
@@ -1896,6 +2189,7 @@ class SfuManager {
1896
2189
  }
1897
2190
  console.info(`SFU: connection failed, reconnecting (${this.reconnectAttempts}/${SfuManager.MAX_RECONNECTS})`);
1898
2191
  this.reconnecting = true;
2192
+ this.endRestart();
1899
2193
  try {
1900
2194
  const deadline = Date.now() + SfuManager.REJOIN_WINDOW_MS;
1901
2195
  for (let delay = 1000;; delay = Math.min(delay * 2, 10000)) {
@@ -1938,6 +2232,38 @@ class SfuManager {
1938
2232
  this.reconnecting = false;
1939
2233
  }
1940
2234
  }
2235
+ /**
2236
+ * Repair the connection in place: the SFU offers new ICE credentials
2237
+ * (`sfuCallRestartIce`), the offer is answered like any server offer,
2238
+ * and the browser gathers candidates on whatever network it has now.
2239
+ * DTLS, tracks and the room slot stay. If the connection is not back
2240
+ * within `RESTART_TIMEOUT_MS`, the call is rebuilt. One restart at a
2241
+ * time: a call while one is in flight does nothing.
2242
+ */
2243
+ restartIce(pc) {
2244
+ if (this.restartTimer || this.reconnecting || this.state.peerConnection !== pc)
2245
+ return;
2246
+ console.info("SFU: restarting ICE");
2247
+ this.restartTimer = setTimeout(() => {
2248
+ this.restartTimer = null;
2249
+ if (this.state.peerConnection !== pc)
2250
+ return;
2251
+ if (pc.iceConnectionState === "connected" || pc.iceConnectionState === "completed")
2252
+ return;
2253
+ void this.reconnect();
2254
+ }, SfuManager.RESTART_TIMEOUT_MS);
2255
+ // A refusal (an executor without the method, or one that lost this
2256
+ // session) leaves the decision to the timeout: a blip may still heal.
2257
+ this.neighbourhood.sfuCallRestartIce(this.neighbourhoodUrl, this.roomId).catch((err) => {
2258
+ console.warn("SFU: ICE restart refused:", err);
2259
+ });
2260
+ }
2261
+ endRestart() {
2262
+ if (this.restartTimer) {
2263
+ clearTimeout(this.restartTimer);
2264
+ this.restartTimer = null;
2265
+ }
2266
+ }
1941
2267
  on(event, callback) {
1942
2268
  if (!this.callbacks.has(event)) {
1943
2269
  this.callbacks.set(event, []);
@@ -1976,48 +2302,45 @@ class SfuManager {
1976
2302
  this.state.localStream = localStream;
1977
2303
  const pc = new RTCPeerConnection({ iceServers: this.iceServers });
1978
2304
  this.state.peerConnection = pc;
1979
- // ICE state monitoring for reconnecting.
1980
- // "disconnected" is often transient (network blip, route change):
1981
- // the connection gets the same grace the server gives it before
1982
- // dropping the peer, and a rebuild only follows once the server
1983
- // would have dropped it anyway. "failed" reconnects at once.
2305
+ // ICE state monitoring for recovery. "disconnected" (a route change,
2306
+ // a network switch, a blip) restarts ICE on this connection at once;
2307
+ // "failed" rebuilds the call at once.
1984
2308
  pc.oniceconnectionstatechange = () => {
1985
2309
  if (this.state.peerConnection !== pc)
1986
2310
  return; // superseded
1987
2311
  if (pc.iceConnectionState === "failed") {
1988
- if (this.disconnectedTimer) {
1989
- clearTimeout(this.disconnectedTimer);
1990
- this.disconnectedTimer = null;
1991
- }
1992
- this.reconnect();
2312
+ this.endRestart();
2313
+ void this.reconnect();
1993
2314
  }
1994
2315
  else if (pc.iceConnectionState === "disconnected") {
1995
- if (!this.disconnectedTimer) {
1996
- this.disconnectedTimer = setTimeout(() => {
1997
- this.disconnectedTimer = null;
1998
- // Only reconnect if this pc is still the active one
1999
- // and still disconnected.
2000
- if (this.state.peerConnection === pc &&
2001
- pc.iceConnectionState === "disconnected") {
2002
- this.reconnect();
2003
- }
2004
- }, SfuManager.DISCONNECT_GRACE_MS);
2005
- }
2316
+ // The path may be gone with no `online` event; the restart
2317
+ // needs a live socket, and a dead one is redialled in seconds.
2318
+ this.neighbourhood.checkConnection();
2319
+ this.restartIce(pc);
2006
2320
  }
2007
- else {
2008
- // Any other state (connected, completed, checking) cancels
2009
- // the pending disconnected timer; a working path ends a run
2010
- // of reconnects.
2011
- if (pc.iceConnectionState === "connected" ||
2012
- pc.iceConnectionState === "completed") {
2013
- this.reconnectAttempts = 0;
2014
- }
2015
- if (this.disconnectedTimer) {
2016
- clearTimeout(this.disconnectedTimer);
2017
- this.disconnectedTimer = null;
2018
- }
2321
+ else if (pc.iceConnectionState === "connected" ||
2322
+ pc.iceConnectionState === "completed") {
2323
+ // A working path ends a restart and a run of reconnects.
2324
+ this.reconnectAttempts = 0;
2325
+ this.endRestart();
2019
2326
  }
2020
2327
  };
2328
+ // A network change: the path ICE uses is likely gone, though ICE may
2329
+ // not have noticed yet. Restart it now, on the socket the change
2330
+ // reconnected, with its own timeout. If a restart's offer is still
2331
+ // unanswered (it went out over the old network and may never have
2332
+ // arrived), the executor sends it again and, once it is answered,
2333
+ // restarts again for this network. Listened to once per call, not
2334
+ // per rebuild.
2335
+ if (!this.networkUnsubscribe) {
2336
+ this.networkUnsubscribe = this.neighbourhood.onNetworkChange(() => {
2337
+ const current = this.state.peerConnection;
2338
+ if (!current || this.reconnecting)
2339
+ return;
2340
+ this.endRestart();
2341
+ this.restartIce(current);
2342
+ });
2343
+ }
2021
2344
  // Both kinds of local media, send-only, declared now whether or not a
2022
2345
  // track exists yet: the SFU only ever receives on these sections, and a
2023
2346
  // camera or screen started later replaces an empty track with no
@@ -2206,7 +2529,7 @@ class SfuManager {
2206
2529
  }
2207
2530
  /** Apply one server offer to `pc` and answer it, unless `pc` is no longer the call's. */
2208
2531
  async applyServerOffer(pc, event) {
2209
- if (this.state.peerConnection !== pc)
2532
+ if (this.state.peerConnection !== pc || event.sdpOffer === this.answeredOffer)
2210
2533
  return;
2211
2534
  // The mapping first: the tracks this offer adds arrive while it is applied.
2212
2535
  for (const entry of event.trackMapping ?? []) {
@@ -2216,6 +2539,7 @@ class SfuManager {
2216
2539
  await pc.setRemoteDescription(new RTCSessionDescription(JSON.parse(event.sdpOffer)));
2217
2540
  await pc.setLocalDescription(await pc.createAnswer());
2218
2541
  await this.neighbourhood.sfuCallAnswerServerOffer(this.neighbourhoodUrl, event.roomName, JSON.stringify(pc.localDescription));
2542
+ this.answeredOffer = event.sdpOffer;
2219
2543
  }
2220
2544
  catch (err) {
2221
2545
  if (this.state.peerConnection !== pc)
@@ -2276,10 +2600,9 @@ class SfuManager {
2276
2600
  async leave() {
2277
2601
  this.generation++;
2278
2602
  this.releaseServerEvents();
2279
- if (this.disconnectedTimer) {
2280
- clearTimeout(this.disconnectedTimer);
2281
- this.disconnectedTimer = null;
2282
- }
2603
+ this.endRestart();
2604
+ this.networkUnsubscribe?.();
2605
+ this.networkUnsubscribe = null;
2283
2606
  this.senders.clear();
2284
2607
  this.replacedTracks.clear();
2285
2608
  this.qualityPreference = null;
@@ -2410,8 +2733,8 @@ class SfuManager {
2410
2733
  SfuManager.MAX_RECONNECTS = 3;
2411
2734
  /** How long one rebuild keeps retrying a join the executor cannot take yet. */
2412
2735
  SfuManager.REJOIN_WINDOW_MS = 120000;
2413
- /** How long ICE may stay disconnected before a rebuild: the executor's `ICE_DISCONNECT_GRACE`. */
2414
- SfuManager.DISCONNECT_GRACE_MS = 10000;
2736
+ /** How long an ICE restart has to bring the connection back before a rebuild. */
2737
+ SfuManager.RESTART_TIMEOUT_MS = 5000;
2415
2738
  /** How long the roster may leave this agent out before the call is rebuilt. */
2416
2739
  SfuManager.UNLISTED_GRACE_MS = 3000;
2417
2740
 
@@ -2723,6 +3046,7 @@ class MeshManager {
2723
3046
  * Cleared only when a renegotiation is answered.
2724
3047
  */
2725
3048
  this.renegotiationRepairs = new Map();
3049
+ this.unwatchNetwork = null;
2726
3050
  this.channel = options.channel;
2727
3051
  this.callId = options.callId;
2728
3052
  this.selfId = options.selfId;
@@ -2736,6 +3060,8 @@ class MeshManager {
2736
3060
  ?? ((configuration) => new RTCPeerConnection(configuration));
2737
3061
  this.now = options.now ?? (() => Date.now());
2738
3062
  this.sweepMs = options.sweepMs ?? SWEEP_INTERVAL_MS;
3063
+ this.onNetworkChange = options.onNetworkChange;
3064
+ this.checkConnection = options.checkConnection;
2739
3065
  }
2740
3066
  // ── Events ──────────────────────────────────────────────────────
2741
3067
  on(event, callback) {
@@ -2838,6 +3164,7 @@ class MeshManager {
2838
3164
  this.publish({ v: CALL_PROTOCOL_VERSION, call: this.callId, warm: true });
2839
3165
  if (this.sweepMs > 0)
2840
3166
  this.sweep = setInterval(() => this.tick(), this.sweepMs);
3167
+ this.unwatchNetwork = this.onNetworkChange?.(() => this.restartAll()) ?? null;
2841
3168
  }
2842
3169
  async leave() {
2843
3170
  this.closed = true;
@@ -2845,6 +3172,8 @@ class MeshManager {
2845
3172
  clearInterval(this.sweep);
2846
3173
  this.sweep = null;
2847
3174
  }
3175
+ this.unwatchNetwork?.();
3176
+ this.unwatchNetwork = null;
2848
3177
  this.unwatchPublish?.();
2849
3178
  this.unwatchPublish = null;
2850
3179
  if (this.channelUnsubscribe) {
@@ -3160,8 +3489,10 @@ class MeshManager {
3160
3489
  if (slot.offerDeferred && pc.signalingState === "stable")
3161
3490
  void negotiate();
3162
3491
  }
3163
- if (state === "disconnected" && !slot.disconnectedAt)
3492
+ if (state === "disconnected" && !slot.disconnectedAt) {
3164
3493
  slot.disconnectedAt = this.now();
3494
+ this.checkConnection?.();
3495
+ }
3165
3496
  if (state === "connected" || state === "failed")
3166
3497
  slot.disconnectedAt = 0;
3167
3498
  this.emit("peer-state", peerId, state);
@@ -3499,6 +3830,39 @@ class MeshManager {
3499
3830
  slot.attempts = attempts - 1;
3500
3831
  this.rebuild(peerId, { announce: true, rung: "rebuild" });
3501
3832
  }
3833
+ /**
3834
+ * The network changed: every pair's path is likely gone, though ICE has
3835
+ * noticed on none yet. Each negotiated pair takes the ladder's first rung
3836
+ * now, all at once — an ICE restart is one offer per pair, and waiting
3837
+ * for each to time out costs seconds of silence. Pairs still negotiating
3838
+ * have nothing to restart; the sweep keeps looking after them.
3839
+ *
3840
+ * It skips the sweep's guards (`outstanding`, one pair per sweep) on
3841
+ * purpose. They stop the sweep reading a slow send as a lost one and
3842
+ * escalating every pair at once. Here nothing is judged lost, and the
3843
+ * rung is the first one: one offer per pair, each to a different peer.
3844
+ * A restart offer that is lost falls to the sweep, guards and all.
3845
+ */
3846
+ restartAll() {
3847
+ if (this.closed)
3848
+ return;
3849
+ const at = this.now();
3850
+ for (const [peerId, slot] of this.slots) {
3851
+ if (!slot.remoteReady || typeof slot.pc.restartIce !== "function")
3852
+ continue;
3853
+ // Spaced from the sweep's next rung, but not charged to the pair's
3854
+ // budget: a network change judges no pair lost.
3855
+ slot.lastAttempt = at;
3856
+ try {
3857
+ slot.pc.restartIce();
3858
+ this.emit("peer-recovery", peerId, { rung: "ice-restart", attempts: slot.attempts });
3859
+ }
3860
+ catch (error) {
3861
+ this.fail(`restarting ice with ${peerId}`, error);
3862
+ }
3863
+ }
3864
+ this.lastRepairAt = at;
3865
+ }
3502
3866
  /** Whether this pair has been given long enough, and whether it is this side's turn to act. */
3503
3867
  dueForRepair(peerId, slot, at) {
3504
3868
  const state = slot.pc.connectionState;
@@ -3800,6 +4164,8 @@ function createSession(config) {
3800
4164
  callId: roomId,
3801
4165
  selfId: agentDid,
3802
4166
  ...(meshIce.length > 0 ? { iceServers: meshIce } : {}),
4167
+ onNetworkChange: (cb) => api.onNetworkChange(cb),
4168
+ checkConnection: () => api.checkConnection(),
3803
4169
  });
3804
4170
  meshManager = mesh;
3805
4171
  wireMeshEvents(mesh);
@@ -3971,13 +4337,13 @@ function createSession(config) {
3971
4337
  return session;
3972
4338
  }
3973
4339
 
3974
- var __classPrivateFieldSet$9 = (undefined && undefined.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
4340
+ var __classPrivateFieldSet$a = (undefined && undefined.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
3975
4341
  if (kind === "m") throw new TypeError("Private method is not writable");
3976
4342
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
3977
4343
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
3978
4344
  return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
3979
4345
  };
3980
- var __classPrivateFieldGet$9 = (undefined && undefined.__classPrivateFieldGet) || function (receiver, state, kind, f) {
4346
+ var __classPrivateFieldGet$a = (undefined && undefined.__classPrivateFieldGet) || function (receiver, state, kind, f) {
3981
4347
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
3982
4348
  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");
3983
4349
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
@@ -3993,9 +4359,9 @@ class NeighbourhoodProxy {
3993
4359
  );
3994
4360
  /** Cached SFU status — fetched once per proxy lifetime. */
3995
4361
  _NeighbourhoodProxy_sfuStatusCache.set(this, null);
3996
- __classPrivateFieldSet$9(this, _NeighbourhoodProxy_client, client, "f");
3997
- __classPrivateFieldSet$9(this, _NeighbourhoodProxy_pID, pID, "f");
3998
- __classPrivateFieldSet$9(this, _NeighbourhoodProxy_agentDid, agentDid, "f");
4362
+ __classPrivateFieldSet$a(this, _NeighbourhoodProxy_client, client, "f");
4363
+ __classPrivateFieldSet$a(this, _NeighbourhoodProxy_pID, pID, "f");
4364
+ __classPrivateFieldSet$a(this, _NeighbourhoodProxy_agentDid, agentDid, "f");
3999
4365
  }
4000
4366
  // ── Telepresence ────────────────────────────────────────────────────
4001
4367
  //
@@ -4003,51 +4369,51 @@ class NeighbourhoodProxy {
4003
4369
  // Routes through the neighbourhood's link language.
4004
4370
  /** List DIDs of agents who have joined this neighbourhood. */
4005
4371
  async otherAgents() {
4006
- return await __classPrivateFieldGet$9(this, _NeighbourhoodProxy_client, "f").otherAgents(__classPrivateFieldGet$9(this, _NeighbourhoodProxy_pID, "f"));
4372
+ return await __classPrivateFieldGet$a(this, _NeighbourhoodProxy_client, "f").otherAgents(__classPrivateFieldGet$a(this, _NeighbourhoodProxy_pID, "f"));
4007
4373
  }
4008
4374
  /** Check whether the neighbourhood's link language supports telepresence. */
4009
4375
  async hasTelepresenceAdapter() {
4010
- return await __classPrivateFieldGet$9(this, _NeighbourhoodProxy_client, "f").hasTelepresenceAdapter(__classPrivateFieldGet$9(this, _NeighbourhoodProxy_pID, "f"));
4376
+ return await __classPrivateFieldGet$a(this, _NeighbourhoodProxy_client, "f").hasTelepresenceAdapter(__classPrivateFieldGet$a(this, _NeighbourhoodProxy_pID, "f"));
4011
4377
  }
4012
4378
  /** List agents currently online in this neighbourhood. */
4013
4379
  async onlineAgents() {
4014
- return await __classPrivateFieldGet$9(this, _NeighbourhoodProxy_client, "f").onlineAgents(__classPrivateFieldGet$9(this, _NeighbourhoodProxy_pID, "f"));
4380
+ return await __classPrivateFieldGet$a(this, _NeighbourhoodProxy_client, "f").onlineAgents(__classPrivateFieldGet$a(this, _NeighbourhoodProxy_pID, "f"));
4015
4381
  }
4016
4382
  /** This agent's own online status, as it last set it on this executor, or `null`. */
4017
4383
  async ownOnlineStatus() {
4018
- return await __classPrivateFieldGet$9(this, _NeighbourhoodProxy_client, "f").ownOnlineStatus(__classPrivateFieldGet$9(this, _NeighbourhoodProxy_pID, "f"));
4384
+ return await __classPrivateFieldGet$a(this, _NeighbourhoodProxy_client, "f").ownOnlineStatus(__classPrivateFieldGet$a(this, _NeighbourhoodProxy_pID, "f"));
4019
4385
  }
4020
4386
  /** Set this agent's online status with a signed perspective payload. */
4021
4387
  async setOnlineStatus(status) {
4022
- return await __classPrivateFieldGet$9(this, _NeighbourhoodProxy_client, "f").setOnlineStatus(__classPrivateFieldGet$9(this, _NeighbourhoodProxy_pID, "f"), status);
4388
+ return await __classPrivateFieldGet$a(this, _NeighbourhoodProxy_client, "f").setOnlineStatus(__classPrivateFieldGet$a(this, _NeighbourhoodProxy_pID, "f"), status);
4023
4389
  }
4024
4390
  /** Set this agent's online status with an unsigned perspective payload. */
4025
4391
  async setOnlineStatusU(status) {
4026
- return await __classPrivateFieldGet$9(this, _NeighbourhoodProxy_client, "f").setOnlineStatusU(__classPrivateFieldGet$9(this, _NeighbourhoodProxy_pID, "f"), status);
4392
+ return await __classPrivateFieldGet$a(this, _NeighbourhoodProxy_client, "f").setOnlineStatusU(__classPrivateFieldGet$a(this, _NeighbourhoodProxy_pID, "f"), status);
4027
4393
  }
4028
4394
  /** Send a signed signal to a specific remote agent via the link language. */
4029
4395
  async sendSignal(remoteAgentDid, payload) {
4030
- return await __classPrivateFieldGet$9(this, _NeighbourhoodProxy_client, "f").sendSignal(__classPrivateFieldGet$9(this, _NeighbourhoodProxy_pID, "f"), remoteAgentDid, payload);
4396
+ return await __classPrivateFieldGet$a(this, _NeighbourhoodProxy_client, "f").sendSignal(__classPrivateFieldGet$a(this, _NeighbourhoodProxy_pID, "f"), remoteAgentDid, payload);
4031
4397
  }
4032
4398
  /** Send an unsigned signal to a specific remote agent via the link language. */
4033
4399
  async sendSignalU(remoteAgentDid, payload) {
4034
- return await __classPrivateFieldGet$9(this, _NeighbourhoodProxy_client, "f").sendSignalU(__classPrivateFieldGet$9(this, _NeighbourhoodProxy_pID, "f"), remoteAgentDid, payload);
4400
+ return await __classPrivateFieldGet$a(this, _NeighbourhoodProxy_client, "f").sendSignalU(__classPrivateFieldGet$a(this, _NeighbourhoodProxy_pID, "f"), remoteAgentDid, payload);
4035
4401
  }
4036
4402
  /** Broadcast a signed signal to all agents in the neighbourhood. */
4037
4403
  async sendBroadcast(payload, loopback = false) {
4038
- return await __classPrivateFieldGet$9(this, _NeighbourhoodProxy_client, "f").sendBroadcast(__classPrivateFieldGet$9(this, _NeighbourhoodProxy_pID, "f"), payload, loopback);
4404
+ return await __classPrivateFieldGet$a(this, _NeighbourhoodProxy_client, "f").sendBroadcast(__classPrivateFieldGet$a(this, _NeighbourhoodProxy_pID, "f"), payload, loopback);
4039
4405
  }
4040
4406
  /** Broadcast an unsigned signal to all agents in the neighbourhood. */
4041
4407
  async sendBroadcastU(payload, loopback = false) {
4042
- return await __classPrivateFieldGet$9(this, _NeighbourhoodProxy_client, "f").sendBroadcastU(__classPrivateFieldGet$9(this, _NeighbourhoodProxy_pID, "f"), payload, loopback);
4408
+ return await __classPrivateFieldGet$a(this, _NeighbourhoodProxy_client, "f").sendBroadcastU(__classPrivateFieldGet$a(this, _NeighbourhoodProxy_pID, "f"), payload, loopback);
4043
4409
  }
4044
4410
  /** Register a handler for incoming telepresence signals. */
4045
4411
  async addSignalHandler(handler) {
4046
- await __classPrivateFieldGet$9(this, _NeighbourhoodProxy_client, "f").addSignalHandler(__classPrivateFieldGet$9(this, _NeighbourhoodProxy_pID, "f"), handler);
4412
+ await __classPrivateFieldGet$a(this, _NeighbourhoodProxy_client, "f").addSignalHandler(__classPrivateFieldGet$a(this, _NeighbourhoodProxy_pID, "f"), handler);
4047
4413
  }
4048
4414
  /** Remove a previously registered signal handler. */
4049
4415
  removeSignalHandler(handler) {
4050
- __classPrivateFieldGet$9(this, _NeighbourhoodProxy_client, "f").removeSignalHandler(__classPrivateFieldGet$9(this, _NeighbourhoodProxy_pID, "f"), handler);
4416
+ __classPrivateFieldGet$a(this, _NeighbourhoodProxy_client, "f").removeSignalHandler(__classPrivateFieldGet$a(this, _NeighbourhoodProxy_pID, "f"), handler);
4051
4417
  }
4052
4418
  // ── Sessions ────────────────────────────────────────────────────────
4053
4419
  //
@@ -4056,7 +4422,7 @@ class NeighbourhoodProxy {
4056
4422
  // cascade redirects, and failover internally.
4057
4423
  /** Active sessions in this neighbourhood. Destroyed sessions remove themselves. */
4058
4424
  get sessions() {
4059
- return __classPrivateFieldGet$9(this, _NeighbourhoodProxy_sessions, "f");
4425
+ return __classPrivateFieldGet$a(this, _NeighbourhoodProxy_sessions, "f");
4060
4426
  }
4061
4427
  /**
4062
4428
  * Create a WebRTC media session. Call `session.join(localStream)` to connect.
@@ -4068,16 +4434,16 @@ class NeighbourhoodProxy {
4068
4434
  async createSession(roomName, options) {
4069
4435
  // `perspective.getNeighbourhoodProxy()` builds the proxy without a DID; the session needs
4070
4436
  // the caller's own, so ask the executor once.
4071
- if (!__classPrivateFieldGet$9(this, _NeighbourhoodProxy_agentDid, "f")) {
4072
- __classPrivateFieldSet$9(this, _NeighbourhoodProxy_agentDid, (await __classPrivateFieldGet$9(this, _NeighbourhoodProxy_client, "f").callerDid()) ?? "", "f");
4437
+ if (!__classPrivateFieldGet$a(this, _NeighbourhoodProxy_agentDid, "f")) {
4438
+ __classPrivateFieldSet$a(this, _NeighbourhoodProxy_agentDid, (await __classPrivateFieldGet$a(this, _NeighbourhoodProxy_client, "f").callerDid()) ?? "", "f");
4073
4439
  }
4074
- if (!__classPrivateFieldGet$9(this, _NeighbourhoodProxy_agentDid, "f")) {
4440
+ if (!__classPrivateFieldGet$a(this, _NeighbourhoodProxy_agentDid, "f")) {
4075
4441
  throw new Error("Cannot create a call session: the executor reports no agent DID");
4076
4442
  }
4077
4443
  // Fetch SFU status once — reachability only changes at executor restart.
4078
- if (!__classPrivateFieldGet$9(this, _NeighbourhoodProxy_sfuStatusCache, "f")) {
4444
+ if (!__classPrivateFieldGet$a(this, _NeighbourhoodProxy_sfuStatusCache, "f")) {
4079
4445
  try {
4080
- __classPrivateFieldSet$9(this, _NeighbourhoodProxy_sfuStatusCache, await __classPrivateFieldGet$9(this, _NeighbourhoodProxy_client, "f").sfuStatus(), "f");
4446
+ __classPrivateFieldSet$a(this, _NeighbourhoodProxy_sfuStatusCache, await __classPrivateFieldGet$a(this, _NeighbourhoodProxy_client, "f").sfuStatus(), "f");
4081
4447
  }
4082
4448
  catch {
4083
4449
  // Non-fatal — session works without SFU advertisement.
@@ -4085,29 +4451,29 @@ class NeighbourhoodProxy {
4085
4451
  }
4086
4452
  const proxy = this;
4087
4453
  const session = createSession({
4088
- api: __classPrivateFieldGet$9(this, _NeighbourhoodProxy_client, "f"),
4454
+ api: __classPrivateFieldGet$a(this, _NeighbourhoodProxy_client, "f"),
4089
4455
  roomId: roomName,
4090
- agentDid: __classPrivateFieldGet$9(this, _NeighbourhoodProxy_agentDid, "f"),
4456
+ agentDid: __classPrivateFieldGet$a(this, _NeighbourhoodProxy_agentDid, "f"),
4091
4457
  neighbourhoodUrl: options?.neighbourhoodUrl ?? "",
4092
4458
  topology: options?.topology ?? "auto",
4093
4459
  sfuConfig: options?.sfuConfig,
4094
4460
  iceServers: options?.iceServers,
4095
- localSfuStatus: __classPrivateFieldGet$9(this, _NeighbourhoodProxy_sfuStatusCache, "f") ?? undefined,
4096
- sfuServesAllMembers: () => __classPrivateFieldGet$9(proxy, _NeighbourhoodProxy_client, "f").sfuServesAllMembers(__classPrivateFieldGet$9(proxy, _NeighbourhoodProxy_pID, "f")),
4461
+ localSfuStatus: __classPrivateFieldGet$a(this, _NeighbourhoodProxy_sfuStatusCache, "f") ?? undefined,
4462
+ sfuServesAllMembers: () => __classPrivateFieldGet$a(proxy, _NeighbourhoodProxy_client, "f").sfuServesAllMembers(__classPrivateFieldGet$a(proxy, _NeighbourhoodProxy_pID, "f")),
4097
4463
  // Mesh needs a signalling channel and presence callbacks.
4098
4464
  // SFU ignores these — they remain unused when the resolved
4099
4465
  // topology selects the SFU path.
4100
- channel: createTelepresenceChannel(proxy, __classPrivateFieldGet$9(proxy, _NeighbourhoodProxy_agentDid, "f")),
4466
+ channel: createTelepresenceChannel(proxy, __classPrivateFieldGet$a(proxy, _NeighbourhoodProxy_agentDid, "f")),
4101
4467
  ownOnlineStatus: () => proxy.ownOnlineStatus(),
4102
4468
  setOnlineStatus: (status) => proxy.setOnlineStatusU(status),
4103
4469
  onlineAgents: () => proxy.onlineAgents(),
4104
4470
  });
4105
- __classPrivateFieldGet$9(this, _NeighbourhoodProxy_sessions, "f").push(session);
4471
+ __classPrivateFieldGet$a(this, _NeighbourhoodProxy_sessions, "f").push(session);
4106
4472
  session.on("state-changed", (state) => {
4107
4473
  if (state === "closed") {
4108
- const idx = __classPrivateFieldGet$9(this, _NeighbourhoodProxy_sessions, "f").indexOf(session);
4474
+ const idx = __classPrivateFieldGet$a(this, _NeighbourhoodProxy_sessions, "f").indexOf(session);
4109
4475
  if (idx !== -1)
4110
- __classPrivateFieldGet$9(this, _NeighbourhoodProxy_sessions, "f").splice(idx, 1);
4476
+ __classPrivateFieldGet$a(this, _NeighbourhoodProxy_sessions, "f").splice(idx, 1);
4111
4477
  }
4112
4478
  });
4113
4479
  return session;
@@ -4119,37 +4485,37 @@ class NeighbourhoodProxy {
4119
4485
  // not per-neighbourhood, and the URL is owned by the consumer (Flux's
4120
4486
  // call context, the WE UI, etc).
4121
4487
  async sfuConfig(neighbourhoodUrl) {
4122
- return await __classPrivateFieldGet$9(this, _NeighbourhoodProxy_client, "f").sfuGetConfig(neighbourhoodUrl);
4488
+ return await __classPrivateFieldGet$a(this, _NeighbourhoodProxy_client, "f").sfuGetConfig(neighbourhoodUrl);
4123
4489
  }
4124
4490
  async setSfuConfig(neighbourhoodUrl, config) {
4125
- return await __classPrivateFieldGet$9(this, _NeighbourhoodProxy_client, "f").sfuSetConfig(neighbourhoodUrl, config);
4491
+ return await __classPrivateFieldGet$a(this, _NeighbourhoodProxy_client, "f").sfuSetConfig(neighbourhoodUrl, config);
4126
4492
  }
4127
4493
  async sfuPeer(neighbourhoodUrl) {
4128
- return await __classPrivateFieldGet$9(this, _NeighbourhoodProxy_client, "f").sfuPeerForNeighbourhood(neighbourhoodUrl);
4494
+ return await __classPrivateFieldGet$a(this, _NeighbourhoodProxy_client, "f").sfuPeerForNeighbourhood(neighbourhoodUrl);
4129
4495
  }
4130
4496
  async sfuPeers(neighbourhoodUrl) {
4131
- return await __classPrivateFieldGet$9(this, _NeighbourhoodProxy_client, "f").sfuPeersForNeighbourhood(neighbourhoodUrl);
4497
+ return await __classPrivateFieldGet$a(this, _NeighbourhoodProxy_client, "f").sfuPeersForNeighbourhood(neighbourhoodUrl);
4132
4498
  }
4133
4499
  async sfuStartRoom(neighbourhoodUrl, roomName) {
4134
- return await __classPrivateFieldGet$9(this, _NeighbourhoodProxy_client, "f").sfuStartRoom(neighbourhoodUrl, roomName);
4500
+ return await __classPrivateFieldGet$a(this, _NeighbourhoodProxy_client, "f").sfuStartRoom(neighbourhoodUrl, roomName);
4135
4501
  }
4136
4502
  async sfuStopRoom(neighbourhoodUrl, roomName) {
4137
- return await __classPrivateFieldGet$9(this, _NeighbourhoodProxy_client, "f").sfuStopRoom(neighbourhoodUrl, roomName);
4503
+ return await __classPrivateFieldGet$a(this, _NeighbourhoodProxy_client, "f").sfuStopRoom(neighbourhoodUrl, roomName);
4138
4504
  }
4139
4505
  async sfuListRooms() {
4140
- return await __classPrivateFieldGet$9(this, _NeighbourhoodProxy_client, "f").sfuListRooms();
4506
+ return await __classPrivateFieldGet$a(this, _NeighbourhoodProxy_client, "f").sfuListRooms();
4141
4507
  }
4142
4508
  async callJoin(neighbourhoodUrl, roomName, sdpOffer) {
4143
- return await __classPrivateFieldGet$9(this, _NeighbourhoodProxy_client, "f").sfuCallJoin(neighbourhoodUrl, roomName, sdpOffer);
4509
+ return await __classPrivateFieldGet$a(this, _NeighbourhoodProxy_client, "f").sfuCallJoin(neighbourhoodUrl, roomName, sdpOffer);
4144
4510
  }
4145
4511
  async callLeave(neighbourhoodUrl, roomName) {
4146
- return await __classPrivateFieldGet$9(this, _NeighbourhoodProxy_client, "f").sfuCallLeave(neighbourhoodUrl, roomName);
4512
+ return await __classPrivateFieldGet$a(this, _NeighbourhoodProxy_client, "f").sfuCallLeave(neighbourhoodUrl, roomName);
4147
4513
  }
4148
4514
  async callSetQualityPreference(neighbourhoodUrl, roomName, preference) {
4149
- return await __classPrivateFieldGet$9(this, _NeighbourhoodProxy_client, "f").sfuCallSetQualityPreference(neighbourhoodUrl, roomName, preference);
4515
+ return await __classPrivateFieldGet$a(this, _NeighbourhoodProxy_client, "f").sfuCallSetQualityPreference(neighbourhoodUrl, roomName, preference);
4150
4516
  }
4151
4517
  async callAnswerServerOffer(neighbourhoodUrl, roomName, sdpAnswer) {
4152
- return await __classPrivateFieldGet$9(this, _NeighbourhoodProxy_client, "f").sfuCallAnswerServerOffer(neighbourhoodUrl, roomName, sdpAnswer);
4518
+ return await __classPrivateFieldGet$a(this, _NeighbourhoodProxy_client, "f").sfuCallAnswerServerOffer(neighbourhoodUrl, roomName, sdpAnswer);
4153
4519
  }
4154
4520
  /**
4155
4521
  * Subscribe to server-pushed renegotiation offers for `targetDid`.
@@ -4158,35 +4524,35 @@ class NeighbourhoodProxy {
4158
4524
  * underlying mechanism.
4159
4525
  */
4160
4526
  subscribeCallRenegotiationOffer(targetDid, callback) {
4161
- return __classPrivateFieldGet$9(this, _NeighbourhoodProxy_client, "f").subscribeSfuCallRenegotiationOffer(targetDid, callback);
4527
+ return __classPrivateFieldGet$a(this, _NeighbourhoodProxy_client, "f").subscribeSfuCallRenegotiationOffer(targetDid, callback);
4162
4528
  }
4163
4529
  /**
4164
4530
  * Subscribe to cascade rebalance migration events for `targetDid`.
4165
4531
  * Returns an unsubscribe function.
4166
4532
  */
4167
4533
  subscribeMigrateEvent(targetDid, callback) {
4168
- return __classPrivateFieldGet$9(this, _NeighbourhoodProxy_client, "f").subscribeSfuMigrateEvent(targetDid, callback);
4534
+ return __classPrivateFieldGet$a(this, _NeighbourhoodProxy_client, "f").subscribeSfuMigrateEvent(targetDid, callback);
4169
4535
  }
4170
4536
  // ── SFU trickle ICE ─────────────────────────────────────────────────
4171
4537
  async addIceCandidate(neighbourhoodUrl, roomName, candidate) {
4172
- return await __classPrivateFieldGet$9(this, _NeighbourhoodProxy_client, "f").sfuAddIceCandidate(neighbourhoodUrl, roomName, candidate);
4538
+ return await __classPrivateFieldGet$a(this, _NeighbourhoodProxy_client, "f").sfuAddIceCandidate(neighbourhoodUrl, roomName, candidate);
4173
4539
  }
4174
4540
  // ── SFU data channel relay ────────────────────────────────────────
4175
4541
  async sendData(neighbourhoodUrl, roomName, channelLabel, data, binary = false) {
4176
- return await __classPrivateFieldGet$9(this, _NeighbourhoodProxy_client, "f").sfuSendData(neighbourhoodUrl, roomName, channelLabel, data, binary);
4542
+ return await __classPrivateFieldGet$a(this, _NeighbourhoodProxy_client, "f").sfuSendData(neighbourhoodUrl, roomName, channelLabel, data, binary);
4177
4543
  }
4178
4544
  subscribeDataChannel(callback) {
4179
- return __classPrivateFieldGet$9(this, _NeighbourhoodProxy_client, "f").subscribeSfuDataChannel(callback);
4545
+ return __classPrivateFieldGet$a(this, _NeighbourhoodProxy_client, "f").subscribeSfuDataChannel(callback);
4180
4546
  }
4181
4547
  // ── SFU diagnostic / test-harness ──────────────────────────────────
4182
4548
  async sfuCascadeStatus() {
4183
- return await __classPrivateFieldGet$9(this, _NeighbourhoodProxy_client, "f").sfuCascadeStatus();
4549
+ return await __classPrivateFieldGet$a(this, _NeighbourhoodProxy_client, "f").sfuCascadeStatus();
4184
4550
  }
4185
4551
  async sfuQualityPreferences() {
4186
- return await __classPrivateFieldGet$9(this, _NeighbourhoodProxy_client, "f").sfuQualityPreferences();
4552
+ return await __classPrivateFieldGet$a(this, _NeighbourhoodProxy_client, "f").sfuQualityPreferences();
4187
4553
  }
4188
4554
  async sfuEnsureMembership(neighbourhoodUrl, did) {
4189
- return await __classPrivateFieldGet$9(this, _NeighbourhoodProxy_client, "f").sfuEnsureMembership(neighbourhoodUrl, did);
4555
+ return await __classPrivateFieldGet$a(this, _NeighbourhoodProxy_client, "f").sfuEnsureMembership(neighbourhoodUrl, did);
4190
4556
  }
4191
4557
  }
4192
4558
  _NeighbourhoodProxy_client = new WeakMap(), _NeighbourhoodProxy_pID = new WeakMap(), _NeighbourhoodProxy_agentDid = new WeakMap(), _NeighbourhoodProxy_sessions = new WeakMap(), _NeighbourhoodProxy_sfuStatusCache = new WeakMap();
@@ -4231,13 +4597,13 @@ class LinkQuery {
4231
4597
  }
4232
4598
  }
4233
4599
 
4234
- var __classPrivateFieldSet$8 = (undefined && undefined.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
4600
+ var __classPrivateFieldSet$9 = (undefined && undefined.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
4235
4601
  if (kind === "m") throw new TypeError("Private method is not writable");
4236
4602
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
4237
4603
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
4238
4604
  return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
4239
4605
  };
4240
- var __classPrivateFieldGet$8 = (undefined && undefined.__classPrivateFieldGet) || function (receiver, state, kind, f) {
4606
+ var __classPrivateFieldGet$9 = (undefined && undefined.__classPrivateFieldGet) || function (receiver, state, kind, f) {
4241
4607
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
4242
4608
  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");
4243
4609
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
@@ -4258,44 +4624,44 @@ class Literal {
4258
4624
  if (url.startsWith("literal://"))
4259
4625
  throw new Error("literal:// format is no longer supported. Use literal: instead.");
4260
4626
  const l = new Literal();
4261
- __classPrivateFieldSet$8(l, _Literal_url, url, "f");
4627
+ __classPrivateFieldSet$9(l, _Literal_url, url, "f");
4262
4628
  return l;
4263
4629
  }
4264
4630
  static from(literal) {
4265
4631
  const l = new Literal();
4266
- __classPrivateFieldSet$8(l, _Literal_literal, literal, "f");
4632
+ __classPrivateFieldSet$9(l, _Literal_literal, literal, "f");
4267
4633
  return l;
4268
4634
  }
4269
4635
  toUrl() {
4270
- if (__classPrivateFieldGet$8(this, _Literal_url, "f") && __classPrivateFieldGet$8(this, _Literal_literal, "f") === undefined)
4271
- return __classPrivateFieldGet$8(this, _Literal_url, "f");
4272
- if (__classPrivateFieldGet$8(this, _Literal_literal, "f") === undefined)
4636
+ if (__classPrivateFieldGet$9(this, _Literal_url, "f") && __classPrivateFieldGet$9(this, _Literal_literal, "f") === undefined)
4637
+ return __classPrivateFieldGet$9(this, _Literal_url, "f");
4638
+ if (__classPrivateFieldGet$9(this, _Literal_literal, "f") === undefined)
4273
4639
  throw new Error("Can't turn empty Literal into URL");
4274
4640
  let encoded;
4275
- switch (typeof __classPrivateFieldGet$8(this, _Literal_literal, "f")) {
4641
+ switch (typeof __classPrivateFieldGet$9(this, _Literal_literal, "f")) {
4276
4642
  case 'string':
4277
- encoded = `string:${encodeRFC3986URIComponent(__classPrivateFieldGet$8(this, _Literal_literal, "f"))}`;
4643
+ encoded = `string:${encodeRFC3986URIComponent(__classPrivateFieldGet$9(this, _Literal_literal, "f"))}`;
4278
4644
  break;
4279
4645
  case 'number':
4280
- encoded = `number:${encodeRFC3986URIComponent(__classPrivateFieldGet$8(this, _Literal_literal, "f"))}`;
4646
+ encoded = `number:${encodeRFC3986URIComponent(__classPrivateFieldGet$9(this, _Literal_literal, "f"))}`;
4281
4647
  break;
4282
4648
  case 'boolean':
4283
- encoded = `boolean:${encodeRFC3986URIComponent(__classPrivateFieldGet$8(this, _Literal_literal, "f"))}`;
4649
+ encoded = `boolean:${encodeRFC3986URIComponent(__classPrivateFieldGet$9(this, _Literal_literal, "f"))}`;
4284
4650
  break;
4285
4651
  case 'object':
4286
- encoded = `json:${encodeRFC3986URIComponent(JSON.stringify(__classPrivateFieldGet$8(this, _Literal_literal, "f")))}`;
4652
+ encoded = `json:${encodeRFC3986URIComponent(JSON.stringify(__classPrivateFieldGet$9(this, _Literal_literal, "f")))}`;
4287
4653
  break;
4288
4654
  }
4289
4655
  return `literal:${encoded}`;
4290
4656
  }
4291
4657
  get() {
4292
- if (__classPrivateFieldGet$8(this, _Literal_literal, "f") !== undefined)
4293
- return __classPrivateFieldGet$8(this, _Literal_literal, "f");
4294
- if (!__classPrivateFieldGet$8(this, _Literal_url, "f"))
4658
+ if (__classPrivateFieldGet$9(this, _Literal_literal, "f") !== undefined)
4659
+ return __classPrivateFieldGet$9(this, _Literal_literal, "f");
4660
+ if (!__classPrivateFieldGet$9(this, _Literal_url, "f"))
4295
4661
  throw new Error("Can't render empty Literal");
4296
- if (!__classPrivateFieldGet$8(this, _Literal_url, "f").startsWith("literal:"))
4662
+ if (!__classPrivateFieldGet$9(this, _Literal_url, "f").startsWith("literal:"))
4297
4663
  throw new Error("Can't render Literal from non-literal URL");
4298
- const body = __classPrivateFieldGet$8(this, _Literal_url, "f").substring(8);
4664
+ const body = __classPrivateFieldGet$9(this, _Literal_url, "f").substring(8);
4299
4665
  if (body.startsWith("string:")) {
4300
4666
  return decodeURIComponent(body.substring(7));
4301
4667
  }
@@ -6678,18 +7044,30 @@ function queryCacheSize() {
6678
7044
  return cache.size;
6679
7045
  }
6680
7046
 
6681
- var __classPrivateFieldSet$7 = (undefined && undefined.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
7047
+ var __classPrivateFieldSet$8 = (undefined && undefined.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
6682
7048
  if (kind === "m") throw new TypeError("Private method is not writable");
6683
7049
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
6684
7050
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
6685
7051
  return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
6686
7052
  };
6687
- var __classPrivateFieldGet$7 = (undefined && undefined.__classPrivateFieldGet) || function (receiver, state, kind, f) {
7053
+ var __classPrivateFieldGet$8 = (undefined && undefined.__classPrivateFieldGet) || function (receiver, state, kind, f) {
6688
7054
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
6689
7055
  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");
6690
7056
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
6691
7057
  };
6692
- var _LiveQuery_instances, _LiveQuery_client, _LiveQuery_uuid, _LiveQuery_open, _LiveQuery_onResult, _LiveQuery_id, _LiveQuery_revision, _LiveQuery_result, _LiveQuery_started, _LiveQuery_disposed, _LiveQuery_generation, _LiveQuery_latest, _LiveQuery_buffer, _LiveQuery_unlisten, _LiveQuery_unreconnect, _LiveQuery_start, _LiveQuery_replace, _LiveQuery_receive, _LiveQuery_resync;
7058
+ var _LiveQuery_instances, _LiveQuery_client, _LiveQuery_uuid, _LiveQuery_open, _LiveQuery_onResult, _LiveQuery_id, _LiveQuery_revision, _LiveQuery_result, _LiveQuery_started, _LiveQuery_disposed, _LiveQuery_generation, _LiveQuery_latest, _LiveQuery_buffer, _LiveQuery_unlisten, _LiveQuery_unreconnect, _LiveQuery_opening, _LiveQuery_retryTimer, _LiveQuery_reopening, _LiveQuery_statusListeners, _LiveQuery_start, _LiveQuery_reopen, _LiveQuery_clearRetry, _LiveQuery_emit, _LiveQuery_replace, _LiveQuery_receive, _LiveQuery_resync;
7059
+ /** Delay before the first retry of a failed re-open; it doubles per failure. */
7060
+ const REOPEN_BASE_DELAY_MS = 1000;
7061
+ /** Longest delay between two re-open attempts. */
7062
+ const REOPEN_MAX_DELAY_MS = 60000;
7063
+ /** The delay before re-open attempt `failures + 1`: between half and all of
7064
+ * `REOPEN_BASE_DELAY_MS * 2^(failures - 1)`, capped at
7065
+ * `REOPEN_MAX_DELAY_MS`. The random half spreads the clients of a restarted
7066
+ * executor apart. */
7067
+ function reopenDelay(failures, random = Math.random) {
7068
+ const ceiling = Math.min(REOPEN_BASE_DELAY_MS * 2 ** Math.max(0, failures - 1), REOPEN_MAX_DELAY_MS);
7069
+ return ceiling / 2 + random() * ceiling / 2;
7070
+ }
6693
7071
  /** Apply one update to the last result. Query rows are a multiset: added rows are appended.
6694
7072
  * Throws when the update names an instance that neither the last result nor
6695
7073
  * the update holds: the last result was wrong, and the caller must resync. */
@@ -6726,10 +7104,14 @@ function applyUpdate(result, update) {
6726
7104
  * One live query on the executor. Holds the last result, applies each update
6727
7105
  * to it, calls `resyncSubscription` when a revision is missing, and opens a
6728
7106
  * new subscription after a reconnect (the executor ends a socket's
6729
- * subscriptions when it closes). `onResult` gets every result after the
6730
- * first; `start()` returns the first.
7107
+ * subscriptions when it closes). A re-open that fails (the executor is
7108
+ * still loading the perspective after a restart) is retried with backoff
7109
+ * until it succeeds or the query is disposed; `onStatus` listeners hear
7110
+ * about it (#1595). `onResult` gets every result after the first; `start()`
7111
+ * returns the first.
6731
7112
  */
6732
7113
  class LiveQuery {
7114
+ /** `open` subscribes on the executor; aborting its signal cancels the call. */
6733
7115
  constructor(client, uuid, open, onResult) {
6734
7116
  _LiveQuery_instances.add(this);
6735
7117
  _LiveQuery_client.set(this, void 0);
@@ -6747,107 +7129,250 @@ class LiveQuery {
6747
7129
  _LiveQuery_buffer.set(this, null);
6748
7130
  _LiveQuery_unlisten.set(this, void 0);
6749
7131
  _LiveQuery_unreconnect.set(this, void 0);
6750
- __classPrivateFieldSet$7(this, _LiveQuery_client, client, "f");
6751
- __classPrivateFieldSet$7(this, _LiveQuery_uuid, uuid, "f");
6752
- __classPrivateFieldSet$7(this, _LiveQuery_open, open, "f");
6753
- __classPrivateFieldSet$7(this, _LiveQuery_onResult, onResult, "f");
6754
- __classPrivateFieldSet$7(this, _LiveQuery_unlisten, client.onQueryUpdate(update => __classPrivateFieldGet$7(this, _LiveQuery_instances, "m", _LiveQuery_receive).call(this, update)), "f");
6755
- __classPrivateFieldSet$7(this, _LiveQuery_unreconnect, client.onReconnect(() => {
6756
- this.start().catch(e => console.error('Error re-opening live query after reconnect:', e));
6757
- }), "f");
7132
+ // Aborts the subscribe call still in flight, for `dispose({ cancelOpening })`.
7133
+ _LiveQuery_opening.set(this, void 0);
7134
+ _LiveQuery_retryTimer.set(this, void 0);
7135
+ _LiveQuery_reopening.set(this, false);
7136
+ _LiveQuery_statusListeners.set(this, new Set()
7137
+ /** `open` subscribes on the executor; aborting its signal cancels the call. */
7138
+ );
7139
+ __classPrivateFieldSet$8(this, _LiveQuery_client, client, "f");
7140
+ __classPrivateFieldSet$8(this, _LiveQuery_uuid, uuid, "f");
7141
+ __classPrivateFieldSet$8(this, _LiveQuery_open, open, "f");
7142
+ __classPrivateFieldSet$8(this, _LiveQuery_onResult, onResult, "f");
7143
+ __classPrivateFieldSet$8(this, _LiveQuery_unlisten, client.onQueryUpdate(update => __classPrivateFieldGet$8(this, _LiveQuery_instances, "m", _LiveQuery_receive).call(this, update)), "f");
7144
+ __classPrivateFieldSet$8(this, _LiveQuery_unreconnect, client.onReconnect(() => __classPrivateFieldGet$8(this, _LiveQuery_instances, "m", _LiveQuery_reopen).call(this)), "f");
7145
+ }
7146
+ get id() { return __classPrivateFieldGet$8(this, _LiveQuery_id, "f"); }
7147
+ get result() { return __classPrivateFieldGet$8(this, _LiveQuery_result, "f"); }
7148
+ /** Whether a re-open failed and the query is waiting to retry it. */
7149
+ get reopening() { return __classPrivateFieldGet$8(this, _LiveQuery_reopening, "f"); }
7150
+ /** Call `listener` on each failed re-open and when a re-open succeeds
7151
+ * after one failed. Returns a remover. */
7152
+ onStatus(listener) {
7153
+ __classPrivateFieldGet$8(this, _LiveQuery_statusListeners, "f").add(listener);
7154
+ return () => __classPrivateFieldGet$8(this, _LiveQuery_statusListeners, "f").delete(listener);
6758
7155
  }
6759
- get id() { return __classPrivateFieldGet$7(this, _LiveQuery_id, "f"); }
6760
- get result() { return __classPrivateFieldGet$7(this, _LiveQuery_result, "f"); }
6761
7156
  /** Open the subscription (again) and return its initial result. A start
6762
7157
  * that a newer one overtakes resolves with the newer one's result. */
6763
7158
  start() {
6764
7159
  var _a;
6765
- __classPrivateFieldSet$7(this, _LiveQuery_latest, __classPrivateFieldGet$7(this, _LiveQuery_instances, "m", _LiveQuery_start).call(this, __classPrivateFieldSet$7(this, _LiveQuery_generation, (_a = __classPrivateFieldGet$7(this, _LiveQuery_generation, "f"), ++_a), "f")), "f");
6766
- return __classPrivateFieldGet$7(this, _LiveQuery_latest, "f");
6767
- }
6768
- dispose() {
7160
+ __classPrivateFieldGet$8(this, _LiveQuery_instances, "m", _LiveQuery_clearRetry).call(this);
7161
+ __classPrivateFieldSet$8(this, _LiveQuery_latest, __classPrivateFieldGet$8(this, _LiveQuery_instances, "m", _LiveQuery_start).call(this, __classPrivateFieldSet$8(this, _LiveQuery_generation, (_a = __classPrivateFieldGet$8(this, _LiveQuery_generation, "f"), ++_a), "f")), "f");
7162
+ return __classPrivateFieldGet$8(this, _LiveQuery_latest, "f");
7163
+ }
7164
+ /** End the subscription. With `cancelOpening`, a subscribe call still in
7165
+ * flight is cancelled too, so the executor stops computing a first result
7166
+ * nobody waits for (#1595); the pending `start()` then rejects instead of
7167
+ * resolving with that result. */
7168
+ dispose(options = {}) {
6769
7169
  var _a;
6770
- __classPrivateFieldSet$7(this, _LiveQuery_disposed, true, "f");
6771
- __classPrivateFieldSet$7(this, _LiveQuery_generation, (_a = __classPrivateFieldGet$7(this, _LiveQuery_generation, "f"), _a++, _a), "f");
6772
- __classPrivateFieldGet$7(this, _LiveQuery_unlisten, "f").call(this);
6773
- __classPrivateFieldGet$7(this, _LiveQuery_unreconnect, "f").call(this);
6774
- if (__classPrivateFieldGet$7(this, _LiveQuery_id, "f"))
6775
- __classPrivateFieldGet$7(this, _LiveQuery_client, "f").disposeQuerySubscription(__classPrivateFieldGet$7(this, _LiveQuery_uuid, "f"), __classPrivateFieldGet$7(this, _LiveQuery_id, "f")).catch(() => { });
7170
+ __classPrivateFieldSet$8(this, _LiveQuery_disposed, true, "f");
7171
+ __classPrivateFieldSet$8(this, _LiveQuery_generation, (_a = __classPrivateFieldGet$8(this, _LiveQuery_generation, "f"), _a++, _a), "f");
7172
+ __classPrivateFieldGet$8(this, _LiveQuery_instances, "m", _LiveQuery_clearRetry).call(this);
7173
+ __classPrivateFieldGet$8(this, _LiveQuery_statusListeners, "f").clear();
7174
+ __classPrivateFieldGet$8(this, _LiveQuery_unlisten, "f").call(this);
7175
+ __classPrivateFieldGet$8(this, _LiveQuery_unreconnect, "f").call(this);
7176
+ if (options.cancelOpening)
7177
+ __classPrivateFieldGet$8(this, _LiveQuery_opening, "f")?.abort();
7178
+ if (__classPrivateFieldGet$8(this, _LiveQuery_id, "f"))
7179
+ __classPrivateFieldGet$8(this, _LiveQuery_client, "f").disposeQuerySubscription(__classPrivateFieldGet$8(this, _LiveQuery_uuid, "f"), __classPrivateFieldGet$8(this, _LiveQuery_id, "f")).catch(() => { });
6776
7180
  }
6777
7181
  }
6778
- _LiveQuery_client = new WeakMap(), _LiveQuery_uuid = new WeakMap(), _LiveQuery_open = new WeakMap(), _LiveQuery_onResult = new WeakMap(), _LiveQuery_id = new WeakMap(), _LiveQuery_revision = new WeakMap(), _LiveQuery_result = new WeakMap(), _LiveQuery_started = new WeakMap(), _LiveQuery_disposed = new WeakMap(), _LiveQuery_generation = new WeakMap(), _LiveQuery_latest = new WeakMap(), _LiveQuery_buffer = new WeakMap(), _LiveQuery_unlisten = new WeakMap(), _LiveQuery_unreconnect = new WeakMap(), _LiveQuery_instances = new WeakSet(), _LiveQuery_start = async function _LiveQuery_start(generation) {
6779
- __classPrivateFieldSet$7(this, _LiveQuery_buffer, [], "f");
7182
+ _LiveQuery_client = new WeakMap(), _LiveQuery_uuid = new WeakMap(), _LiveQuery_open = new WeakMap(), _LiveQuery_onResult = new WeakMap(), _LiveQuery_id = new WeakMap(), _LiveQuery_revision = new WeakMap(), _LiveQuery_result = new WeakMap(), _LiveQuery_started = new WeakMap(), _LiveQuery_disposed = new WeakMap(), _LiveQuery_generation = new WeakMap(), _LiveQuery_latest = new WeakMap(), _LiveQuery_buffer = new WeakMap(), _LiveQuery_unlisten = new WeakMap(), _LiveQuery_unreconnect = new WeakMap(), _LiveQuery_opening = new WeakMap(), _LiveQuery_retryTimer = new WeakMap(), _LiveQuery_reopening = new WeakMap(), _LiveQuery_statusListeners = new WeakMap(), _LiveQuery_instances = new WeakSet(), _LiveQuery_start = async function _LiveQuery_start(generation) {
7183
+ __classPrivateFieldSet$8(this, _LiveQuery_buffer, [], "f");
7184
+ const opening = new AbortController();
7185
+ __classPrivateFieldSet$8(this, _LiveQuery_opening, opening, "f");
6780
7186
  let subscribed;
6781
7187
  try {
6782
- subscribed = await __classPrivateFieldGet$7(this, _LiveQuery_open, "f").call(this);
7188
+ subscribed = await __classPrivateFieldGet$8(this, _LiveQuery_open, "f").call(this, opening.signal);
6783
7189
  }
6784
7190
  catch (e) {
6785
- if (generation === __classPrivateFieldGet$7(this, _LiveQuery_generation, "f"))
6786
- __classPrivateFieldSet$7(this, _LiveQuery_buffer, null, "f");
7191
+ if (generation === __classPrivateFieldGet$8(this, _LiveQuery_generation, "f"))
7192
+ __classPrivateFieldSet$8(this, _LiveQuery_buffer, null, "f");
6787
7193
  throw e;
6788
7194
  }
6789
- if (__classPrivateFieldGet$7(this, _LiveQuery_disposed, "f") || generation !== __classPrivateFieldGet$7(this, _LiveQuery_generation, "f")) {
6790
- __classPrivateFieldGet$7(this, _LiveQuery_client, "f").disposeQuerySubscription(__classPrivateFieldGet$7(this, _LiveQuery_uuid, "f"), subscribed.subscriptionId).catch(() => { });
7195
+ finally {
7196
+ if (__classPrivateFieldGet$8(this, _LiveQuery_opening, "f") === opening)
7197
+ __classPrivateFieldSet$8(this, _LiveQuery_opening, undefined, "f");
7198
+ }
7199
+ if (__classPrivateFieldGet$8(this, _LiveQuery_disposed, "f") || generation !== __classPrivateFieldGet$8(this, _LiveQuery_generation, "f")) {
7200
+ __classPrivateFieldGet$8(this, _LiveQuery_client, "f").disposeQuerySubscription(__classPrivateFieldGet$8(this, _LiveQuery_uuid, "f"), subscribed.subscriptionId).catch(() => { });
6791
7201
  // Disposed while opening (e.g. a newer subscribe() on the same
6792
7202
  // builder): the caller still gets the snapshot that was read.
6793
- return __classPrivateFieldGet$7(this, _LiveQuery_disposed, "f") ? (__classPrivateFieldGet$7(this, _LiveQuery_result, "f") ?? subscribed.result) : __classPrivateFieldGet$7(this, _LiveQuery_latest, "f");
7203
+ return __classPrivateFieldGet$8(this, _LiveQuery_disposed, "f") ? (__classPrivateFieldGet$8(this, _LiveQuery_result, "f") ?? subscribed.result) : __classPrivateFieldGet$8(this, _LiveQuery_latest, "f");
7204
+ }
7205
+ __classPrivateFieldSet$8(this, _LiveQuery_id, subscribed.subscriptionId, "f");
7206
+ __classPrivateFieldGet$8(this, _LiveQuery_instances, "m", _LiveQuery_replace).call(this, subscribed.revision, subscribed.result);
7207
+ return __classPrivateFieldGet$8(this, _LiveQuery_result, "f");
7208
+ }, _LiveQuery_reopen = function _LiveQuery_reopen(failures = 0) {
7209
+ if (__classPrivateFieldGet$8(this, _LiveQuery_disposed, "f"))
7210
+ return;
7211
+ const reopened = this.start();
7212
+ const generation = __classPrivateFieldGet$8(this, _LiveQuery_generation, "f");
7213
+ reopened.then(() => {
7214
+ if (__classPrivateFieldGet$8(this, _LiveQuery_disposed, "f") || generation !== __classPrivateFieldGet$8(this, _LiveQuery_generation, "f") || !__classPrivateFieldGet$8(this, _LiveQuery_reopening, "f"))
7215
+ return;
7216
+ __classPrivateFieldSet$8(this, _LiveQuery_reopening, false, "f");
7217
+ __classPrivateFieldGet$8(this, _LiveQuery_instances, "m", _LiveQuery_emit).call(this, { state: 'open' });
7218
+ }, error => {
7219
+ if (__classPrivateFieldGet$8(this, _LiveQuery_disposed, "f") || generation !== __classPrivateFieldGet$8(this, _LiveQuery_generation, "f"))
7220
+ return;
7221
+ const retryInMs = reopenDelay(failures + 1);
7222
+ console.error(`Error re-opening live query (attempt ${failures + 1}), retrying in ${Math.round(retryInMs)}ms:`, error);
7223
+ __classPrivateFieldSet$8(this, _LiveQuery_reopening, true, "f");
7224
+ __classPrivateFieldGet$8(this, _LiveQuery_instances, "m", _LiveQuery_emit).call(this, { state: 'reopening', error, retryInMs });
7225
+ const timer = setTimeout(() => {
7226
+ __classPrivateFieldSet$8(this, _LiveQuery_retryTimer, undefined, "f");
7227
+ __classPrivateFieldGet$8(this, _LiveQuery_instances, "m", _LiveQuery_reopen).call(this, failures + 1);
7228
+ }, retryInMs);
7229
+ // Node: a pending retry must not keep the process alive.
7230
+ if (typeof timer?.unref === 'function')
7231
+ timer.unref();
7232
+ __classPrivateFieldSet$8(this, _LiveQuery_retryTimer, timer, "f");
7233
+ });
7234
+ }, _LiveQuery_clearRetry = function _LiveQuery_clearRetry() {
7235
+ if (__classPrivateFieldGet$8(this, _LiveQuery_retryTimer, "f") === undefined)
7236
+ return;
7237
+ clearTimeout(__classPrivateFieldGet$8(this, _LiveQuery_retryTimer, "f"));
7238
+ __classPrivateFieldSet$8(this, _LiveQuery_retryTimer, undefined, "f");
7239
+ }, _LiveQuery_emit = function _LiveQuery_emit(status) {
7240
+ for (const listener of [...__classPrivateFieldGet$8(this, _LiveQuery_statusListeners, "f")]) {
7241
+ try {
7242
+ listener(status);
7243
+ }
7244
+ catch (e) {
7245
+ console.error('Error in live query status listener:', e);
7246
+ }
6794
7247
  }
6795
- __classPrivateFieldSet$7(this, _LiveQuery_id, subscribed.subscriptionId, "f");
6796
- __classPrivateFieldGet$7(this, _LiveQuery_instances, "m", _LiveQuery_replace).call(this, subscribed.revision, subscribed.result);
6797
- return __classPrivateFieldGet$7(this, _LiveQuery_result, "f");
6798
7248
  }, _LiveQuery_replace = function _LiveQuery_replace(revision, result) {
6799
- __classPrivateFieldSet$7(this, _LiveQuery_revision, revision, "f");
6800
- __classPrivateFieldSet$7(this, _LiveQuery_result, result, "f");
6801
- const buffered = __classPrivateFieldGet$7(this, _LiveQuery_buffer, "f") ?? [];
6802
- __classPrivateFieldSet$7(this, _LiveQuery_buffer, null, "f");
6803
- if (__classPrivateFieldGet$7(this, _LiveQuery_started, "f"))
6804
- __classPrivateFieldGet$7(this, _LiveQuery_onResult, "f").call(this, result);
6805
- __classPrivateFieldSet$7(this, _LiveQuery_started, true, "f");
7249
+ __classPrivateFieldSet$8(this, _LiveQuery_revision, revision, "f");
7250
+ __classPrivateFieldSet$8(this, _LiveQuery_result, result, "f");
7251
+ const buffered = __classPrivateFieldGet$8(this, _LiveQuery_buffer, "f") ?? [];
7252
+ __classPrivateFieldSet$8(this, _LiveQuery_buffer, null, "f");
7253
+ if (__classPrivateFieldGet$8(this, _LiveQuery_started, "f"))
7254
+ __classPrivateFieldGet$8(this, _LiveQuery_onResult, "f").call(this, result);
7255
+ __classPrivateFieldSet$8(this, _LiveQuery_started, true, "f");
6806
7256
  for (const update of buffered)
6807
- __classPrivateFieldGet$7(this, _LiveQuery_instances, "m", _LiveQuery_receive).call(this, update);
7257
+ __classPrivateFieldGet$8(this, _LiveQuery_instances, "m", _LiveQuery_receive).call(this, update);
6808
7258
  }, _LiveQuery_receive = function _LiveQuery_receive(update) {
6809
- if (__classPrivateFieldGet$7(this, _LiveQuery_buffer, "f")) {
6810
- __classPrivateFieldGet$7(this, _LiveQuery_buffer, "f").push(update);
7259
+ if (__classPrivateFieldGet$8(this, _LiveQuery_buffer, "f")) {
7260
+ __classPrivateFieldGet$8(this, _LiveQuery_buffer, "f").push(update);
6811
7261
  return;
6812
7262
  }
6813
7263
  if ('lagged' in update) {
6814
- if (__classPrivateFieldGet$7(this, _LiveQuery_id, "f"))
6815
- __classPrivateFieldGet$7(this, _LiveQuery_instances, "m", _LiveQuery_resync).call(this);
7264
+ if (__classPrivateFieldGet$8(this, _LiveQuery_id, "f"))
7265
+ __classPrivateFieldGet$8(this, _LiveQuery_instances, "m", _LiveQuery_resync).call(this);
6816
7266
  return;
6817
7267
  }
6818
- if (update.subscriptionId !== __classPrivateFieldGet$7(this, _LiveQuery_id, "f") || update.revision <= __classPrivateFieldGet$7(this, _LiveQuery_revision, "f"))
7268
+ if (update.subscriptionId !== __classPrivateFieldGet$8(this, _LiveQuery_id, "f") || update.revision <= __classPrivateFieldGet$8(this, _LiveQuery_revision, "f"))
6819
7269
  return;
6820
- if (update.revision !== __classPrivateFieldGet$7(this, _LiveQuery_revision, "f") + 1) {
6821
- __classPrivateFieldGet$7(this, _LiveQuery_instances, "m", _LiveQuery_resync).call(this);
7270
+ if (update.revision !== __classPrivateFieldGet$8(this, _LiveQuery_revision, "f") + 1) {
7271
+ __classPrivateFieldGet$8(this, _LiveQuery_instances, "m", _LiveQuery_resync).call(this);
6822
7272
  return;
6823
7273
  }
6824
7274
  let result;
6825
7275
  try {
6826
- result = applyUpdate(__classPrivateFieldGet$7(this, _LiveQuery_result, "f"), update);
7276
+ result = applyUpdate(__classPrivateFieldGet$8(this, _LiveQuery_result, "f"), update);
6827
7277
  }
6828
7278
  catch {
6829
- __classPrivateFieldGet$7(this, _LiveQuery_instances, "m", _LiveQuery_resync).call(this);
7279
+ __classPrivateFieldGet$8(this, _LiveQuery_instances, "m", _LiveQuery_resync).call(this);
6830
7280
  return;
6831
7281
  }
6832
- __classPrivateFieldSet$7(this, _LiveQuery_revision, update.revision, "f");
6833
- __classPrivateFieldSet$7(this, _LiveQuery_result, result, "f");
6834
- __classPrivateFieldGet$7(this, _LiveQuery_onResult, "f").call(this, __classPrivateFieldGet$7(this, _LiveQuery_result, "f"));
7282
+ __classPrivateFieldSet$8(this, _LiveQuery_revision, update.revision, "f");
7283
+ __classPrivateFieldSet$8(this, _LiveQuery_result, result, "f");
7284
+ __classPrivateFieldGet$8(this, _LiveQuery_onResult, "f").call(this, __classPrivateFieldGet$8(this, _LiveQuery_result, "f"));
6835
7285
  }, _LiveQuery_resync = function _LiveQuery_resync() {
6836
- const generation = __classPrivateFieldGet$7(this, _LiveQuery_generation, "f");
6837
- const id = __classPrivateFieldGet$7(this, _LiveQuery_id, "f");
6838
- __classPrivateFieldSet$7(this, _LiveQuery_buffer, [], "f");
6839
- __classPrivateFieldGet$7(this, _LiveQuery_client, "f").resyncSubscription(__classPrivateFieldGet$7(this, _LiveQuery_uuid, "f"), id).then(({ revision, result }) => {
6840
- if (!__classPrivateFieldGet$7(this, _LiveQuery_disposed, "f") && generation === __classPrivateFieldGet$7(this, _LiveQuery_generation, "f"))
6841
- __classPrivateFieldGet$7(this, _LiveQuery_instances, "m", _LiveQuery_replace).call(this, revision, result);
7286
+ const generation = __classPrivateFieldGet$8(this, _LiveQuery_generation, "f");
7287
+ const id = __classPrivateFieldGet$8(this, _LiveQuery_id, "f");
7288
+ __classPrivateFieldSet$8(this, _LiveQuery_buffer, [], "f");
7289
+ __classPrivateFieldGet$8(this, _LiveQuery_client, "f").resyncSubscription(__classPrivateFieldGet$8(this, _LiveQuery_uuid, "f"), id).then(({ revision, result }) => {
7290
+ if (!__classPrivateFieldGet$8(this, _LiveQuery_disposed, "f") && generation === __classPrivateFieldGet$8(this, _LiveQuery_generation, "f"))
7291
+ __classPrivateFieldGet$8(this, _LiveQuery_instances, "m", _LiveQuery_replace).call(this, revision, result);
6842
7292
  }, () => {
6843
7293
  // Replace the subscription with a new one.
6844
- if (!__classPrivateFieldGet$7(this, _LiveQuery_disposed, "f") && generation === __classPrivateFieldGet$7(this, _LiveQuery_generation, "f")) {
6845
- __classPrivateFieldGet$7(this, _LiveQuery_client, "f").disposeQuerySubscription(__classPrivateFieldGet$7(this, _LiveQuery_uuid, "f"), id).catch(() => { });
6846
- this.start().catch(e => console.error('Error re-opening live query:', e));
7294
+ if (!__classPrivateFieldGet$8(this, _LiveQuery_disposed, "f") && generation === __classPrivateFieldGet$8(this, _LiveQuery_generation, "f")) {
7295
+ __classPrivateFieldGet$8(this, _LiveQuery_client, "f").disposeQuerySubscription(__classPrivateFieldGet$8(this, _LiveQuery_uuid, "f"), id).catch(() => { });
7296
+ __classPrivateFieldGet$8(this, _LiveQuery_instances, "m", _LiveQuery_reopen).call(this);
6847
7297
  }
6848
7298
  });
6849
7299
  };
6850
7300
 
7301
+ /**
7302
+ * Compare two strings by Unicode code point, ascending. This is the order
7303
+ * Rust's `String::cmp` produces (UTF-8 bytes sort in code-point order), so
7304
+ * a sort keyed on it here and in `rust-executor` agrees for every name, not
7305
+ * only ASCII. `<` on JS strings compares UTF-16 code units instead, which
7306
+ * puts U+E000–U+FFFF after the supplementary planes.
7307
+ *
7308
+ * Used by `fromLinks` to break state-value ties (#1202).
7309
+ */
7310
+ function compareCodePoints(a, b) {
7311
+ const as = Array.from(a);
7312
+ const bs = Array.from(b);
7313
+ const n = Math.min(as.length, bs.length);
7314
+ for (let i = 0; i < n; i++) {
7315
+ const d = as[i].codePointAt(0) - bs[i].codePointAt(0);
7316
+ if (d !== 0)
7317
+ return d;
7318
+ }
7319
+ return as.length - bs.length;
7320
+ }
7321
+ /**
7322
+ * Decode a state's `stateValue` link target into the number the state sort
7323
+ * keys on. **One grammar, shared verbatim with `decode_state_value` in
7324
+ * `rust-executor/src/perspectives/shacl_parser.rs`; a change to one is a
7325
+ * change to both**, and the `state value decoder matches rust` test here and
7326
+ * `state_value_decoder_matches_ts` there hold the two to the same answers.
7327
+ *
7328
+ * Not `Literal.fromUrl(target).get()`: that is `parseFloat`, which reads
7329
+ * `1abc` as 1 and `inf` as NaN, while Rust's `str::parse::<f64>` does the
7330
+ * reverse — so before #1202 the two runtimes could decode the same links to
7331
+ * different values and pick different initial states. The grammar:
7332
+ *
7333
+ * 1. The target must be a `literal:number:` literal. Anything else is NaN.
7334
+ * 2. The payload is percent-decoded: `Literal.toUrl` writes `1e21` as
7335
+ * `1e%2B21`. A payload that does not decode is NaN.
7336
+ * 3. A plain decimal — `[+-]?([0-9]+.?[0-9]*|.[0-9]+)([eE][+-]?[0-9]+)?`,
7337
+ * ASCII digits only — parses with `Number`; both runtimes' parsers agree
7338
+ * on this set. `-0` decodes to `-0`, which the sort treats as `0`.
7339
+ * 4. `inf` / `infinity`, any ASCII case, optional sign, is ±Infinity.
7340
+ * Rust's `parse_flow_to_links` writes `-inf`, `Literal.toUrl` writes
7341
+ * `-Infinity`; both runtimes read both.
7342
+ * 5. Everything else is NaN, which the sort puts last: `NaN`, an empty
7343
+ * payload, `1abc`, ` 1`, `0x10`, non-ASCII digits.
7344
+ *
7345
+ * A *missing* `stateValue` link is not this function's case: `fromLinks`
7346
+ * reads it as `0`, as Rust does.
7347
+ *
7348
+ * `STATE_VALUE_DECIMAL` is rule 3's grammar with the dot and the digits after
7349
+ * it grouped, `[0-9]+(\.[0-9]*)?`. Same strings, but a digit run can no longer
7350
+ * split between two digit classes, so V8 does not backtrack quadratically on a
7351
+ * long run that fails at the end. Rust's `regex` crate matches in linear time
7352
+ * either way.
7353
+ */
7354
+ const STATE_VALUE_DECIMAL = /^[+-]?(?:[0-9]+(?:\.[0-9]*)?|\.[0-9]+)(?:[eE][+-]?[0-9]+)?$/;
7355
+ const STATE_VALUE_INFINITE = /^[+-]?[iI][nN][fF](?:[iI][nN][iI][tT][yY])?$/;
7356
+ function decodeStateValue(target) {
7357
+ const payload = target.startsWith("literal:number:")
7358
+ ? target.slice("literal:number:".length)
7359
+ : undefined;
7360
+ if (payload === undefined)
7361
+ return NaN;
7362
+ let decoded;
7363
+ try {
7364
+ decoded = decodeURIComponent(payload);
7365
+ }
7366
+ catch {
7367
+ return NaN;
7368
+ }
7369
+ if (STATE_VALUE_DECIMAL.test(decoded))
7370
+ return Number(decoded);
7371
+ if (STATE_VALUE_INFINITE.test(decoded)) {
7372
+ return decoded.startsWith("-") ? -Infinity : Infinity;
7373
+ }
7374
+ return NaN;
7375
+ }
6851
7376
  /**
6852
7377
  * Runtime shape check for a decoded `ModelQuery`. Deserialization paths use
6853
7378
  * this to guard against malformed guard arrays leaking into flow metadata
@@ -6965,11 +7490,13 @@ class SHACLFlow {
6965
7490
  * States in this flow.
6966
7491
  *
6967
7492
  * **Ordering convention (James PR #929 R9):** the array is stored sorted
6968
- * ascending by `value`. `states[0]` is the initial state — the one
7493
+ * ascending by `value`, ties broken by state name ascending (code-point
7494
+ * order), NaN values last. `states[0]` is the initial state — the one
6969
7495
  * {@link FlowInstance.start} mints a fresh instance into. A flow author
6970
7496
  * who wants a specific state as the entry point must give it the lowest
6971
- * `value` in the set. `fromLinks` enforces this sort, so link-order on
6972
- * the graph never dictates the initial state.
7497
+ * `value` in the set; two states sharing the lowest value start in the
7498
+ * one whose name sorts first (#1202). `fromLinks` enforces this sort, so
7499
+ * link-order on the graph never dictates the initial state.
6973
7500
  */
6974
7501
  this._states = [];
6975
7502
  /** Transitions between states */
@@ -7335,7 +7862,9 @@ class SHACLFlow {
7335
7862
  stateUriToName.set(stateUri, stateName);
7336
7863
  // Get state value
7337
7864
  const valueLink = links.find(l => l.source === stateUri && l.predicate === "ad4m://stateValue");
7338
- const stateValue = valueLink ? Literal.fromUrl(valueLink.target).get() : 0;
7865
+ // Missing link: 0, as in Rust. Present link: the shared strict grammar
7866
+ // (`decodeStateValue`), NaN when it does not fit.
7867
+ const stateValue = valueLink ? decodeStateValue(valueLink.target) : 0;
7339
7868
  // Get per-state interpretation hint (optional). Same non-empty-string
7340
7869
  // guard as the flow-level hint.
7341
7870
  const hintLink = links.find(l => l.source === stateUri && l.predicate === "ad4m://interpretationHint");
@@ -7413,8 +7942,45 @@ class SHACLFlow {
7413
7942
  // was randomly one of the round-tripped states. Sort by `value` ascending
7414
7943
  // so the "initial state = states[0]" convention (used by
7415
7944
  // `FlowInstance.start`) survives a fromGraph round trip.
7945
+ //
7946
+ // This comparator must stay identical to the one in rust-executor's
7947
+ // `parse_flow_from_links` (`rust-executor/src/perspectives/shacl_parser.rs`):
7948
+ // both runtimes read `states[0]` as the genesis state, and a Rust-side
7949
+ // spawn, `derive_state` and `verify_receipt` all start from it. So must
7950
+ // its input: `decodeStateValue` above and Rust `decode_state_value` read
7951
+ // the `stateValue` literal with one grammar, so the same links decode to
7952
+ // the same numbers before this sort ever runs.
7953
+ //
7954
+ // - NaN sorts last. `decodeStateValue` returns NaN for every payload
7955
+ // outside its grammar (a literal `NaN`, an empty payload, `1abc`, …),
7956
+ // so NaN is the common case for a malformed definition; `a.value -
7957
+ // b.value` would then be NaN, which `Array.prototype.sort` treats as
7958
+ // "equal" in an engine-defined way that also scrambles the finite
7959
+ // states around it. A state whose ordering value is undecodable has
7960
+ // no claim to being first.
7961
+ // - Equal values break on state name, ascending by Unicode code point
7962
+ // (`compareCodePoints`), which is the order Rust's `String::cmp` gives
7963
+ // over UTF-8 bytes (#1202). Without this, `sort` is stable and a tie
7964
+ // kept link-discovery order, which differs between replicas: two
7965
+ // nodes loading the same definition could mint instances in
7966
+ // different initial states.
7416
7967
  // The `states` getter returns a defensive copy, so mutate `_states` directly.
7417
- flow._states.sort((a, b) => a.value - b.value);
7968
+ flow._states.sort((a, b) => {
7969
+ const aNaN = Number.isNaN(a.value);
7970
+ const bNaN = Number.isNaN(b.value);
7971
+ if (aNaN !== bNaN)
7972
+ return aNaN ? 1 : -1;
7973
+ if (!aNaN && a.value !== b.value)
7974
+ return a.value < b.value ? -1 : 1;
7975
+ return compareCodePoints(a.name, b.name);
7976
+ });
7977
+ if (flow._states.length > 1 &&
7978
+ !Number.isNaN(flow._states[0].value) &&
7979
+ flow._states[0].value === flow._states[1].value) {
7980
+ console.warn(`flow \`${flowUri}\`: states \`${flow._states[0].name}\` and \`${flow._states[1].name}\` ` +
7981
+ `tie on the lowest value ${flow._states[0].value}; ` +
7982
+ `\`${flow._states[0].name}\` is the initial state by name order (#1202)`);
7983
+ }
7418
7984
  // Find transitions
7419
7985
  const transitionLinks = links.filter(l => l.source === flowUri && l.predicate === "ad4m://hasTransition");
7420
7986
  for (const transitionLink of transitionLinks) {
@@ -7574,12 +8140,12 @@ SHACLFlow.STATE_AND_TRANSITION_PREDICATES = [
7574
8140
  "ad4m://transitionActions",
7575
8141
  ];
7576
8142
 
7577
- var __classPrivateFieldGet$6 = (undefined && undefined.__classPrivateFieldGet) || function (receiver, state, kind, f) {
8143
+ var __classPrivateFieldGet$7 = (undefined && undefined.__classPrivateFieldGet) || function (receiver, state, kind, f) {
7578
8144
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
7579
8145
  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");
7580
8146
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
7581
8147
  };
7582
- var __classPrivateFieldSet$6 = (undefined && undefined.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
8148
+ var __classPrivateFieldSet$7 = (undefined && undefined.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
7583
8149
  if (kind === "m") throw new TypeError("Private method is not writable");
7584
8150
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
7585
8151
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
@@ -7624,55 +8190,69 @@ class QuerySubscriptionProxy {
7624
8190
  _QuerySubscriptionProxy_initResolve.set(this, void 0);
7625
8191
  _QuerySubscriptionProxy_initReject.set(this, void 0);
7626
8192
  const open = className === undefined
7627
- ? () => client.subscribeQuery(uuid, query)
7628
- : () => client.modelSubscribe(uuid, className, query);
7629
- __classPrivateFieldSet$6(this, _QuerySubscriptionProxy_live, new LiveQuery(client, uuid, open, result => __classPrivateFieldGet$6(this, _QuerySubscriptionProxy_instances, "m", _QuerySubscriptionProxy_deliver).call(this, result)), "f");
7630
- __classPrivateFieldSet$6(this, _QuerySubscriptionProxy_initialized, new Promise((resolve, reject) => {
7631
- __classPrivateFieldSet$6(this, _QuerySubscriptionProxy_initResolve, resolve, "f");
7632
- __classPrivateFieldSet$6(this, _QuerySubscriptionProxy_initReject, reject, "f");
8193
+ ? (signal) => client.subscribeQuery(uuid, query, { signal })
8194
+ : (signal) => client.modelSubscribe(uuid, className, query, { signal });
8195
+ __classPrivateFieldSet$7(this, _QuerySubscriptionProxy_live, new LiveQuery(client, uuid, open, result => __classPrivateFieldGet$7(this, _QuerySubscriptionProxy_instances, "m", _QuerySubscriptionProxy_deliver).call(this, result)), "f");
8196
+ __classPrivateFieldSet$7(this, _QuerySubscriptionProxy_initialized, new Promise((resolve, reject) => {
8197
+ __classPrivateFieldSet$7(this, _QuerySubscriptionProxy_initResolve, resolve, "f");
8198
+ __classPrivateFieldSet$7(this, _QuerySubscriptionProxy_initReject, reject, "f");
7633
8199
  }), "f");
7634
8200
  // `subscribe()` throws the same error, so a caller who never reads
7635
8201
  // `initialized` must not get an unhandled rejection from it.
7636
- __classPrivateFieldGet$6(this, _QuerySubscriptionProxy_initialized, "f").catch(() => { });
8202
+ __classPrivateFieldGet$7(this, _QuerySubscriptionProxy_initialized, "f").catch(() => { });
7637
8203
  }
7638
8204
  /** Open the query; resolves with the first result delivered. */
7639
8205
  async subscribe() {
7640
8206
  try {
7641
- __classPrivateFieldGet$6(this, _QuerySubscriptionProxy_instances, "m", _QuerySubscriptionProxy_deliver).call(this, await __classPrivateFieldGet$6(this, _QuerySubscriptionProxy_live, "f").start());
8207
+ __classPrivateFieldGet$7(this, _QuerySubscriptionProxy_instances, "m", _QuerySubscriptionProxy_deliver).call(this, await __classPrivateFieldGet$7(this, _QuerySubscriptionProxy_live, "f").start());
7642
8208
  }
7643
8209
  catch (error) {
7644
- __classPrivateFieldGet$6(this, _QuerySubscriptionProxy_initReject, "f")?.call(this, error);
7645
- __classPrivateFieldSet$6(this, _QuerySubscriptionProxy_initResolve, __classPrivateFieldSet$6(this, _QuerySubscriptionProxy_initReject, undefined, "f"), "f");
8210
+ __classPrivateFieldGet$7(this, _QuerySubscriptionProxy_initReject, "f")?.call(this, error);
8211
+ __classPrivateFieldSet$7(this, _QuerySubscriptionProxy_initResolve, __classPrivateFieldSet$7(this, _QuerySubscriptionProxy_initReject, undefined, "f"), "f");
7646
8212
  throw error;
7647
8213
  }
7648
8214
  }
7649
8215
  /** The executor's id for this subscription. */
7650
8216
  get id() {
7651
- return __classPrivateFieldGet$6(this, _QuerySubscriptionProxy_live, "f").id;
8217
+ return __classPrivateFieldGet$7(this, _QuerySubscriptionProxy_live, "f").id;
7652
8218
  }
7653
8219
  /** Resolves once the first result has arrived. */
7654
8220
  get initialized() {
7655
- return __classPrivateFieldGet$6(this, _QuerySubscriptionProxy_initialized, "f");
8221
+ return __classPrivateFieldGet$7(this, _QuerySubscriptionProxy_initialized, "f");
7656
8222
  }
7657
8223
  /** The latest result. */
7658
8224
  get result() {
7659
- return __classPrivateFieldGet$6(this, _QuerySubscriptionProxy_live, "f").result;
8225
+ return __classPrivateFieldGet$7(this, _QuerySubscriptionProxy_live, "f").result;
7660
8226
  }
7661
8227
  /** Call `callback` with every later result. Returns a remover. */
7662
8228
  onResult(callback) {
7663
- __classPrivateFieldGet$6(this, _QuerySubscriptionProxy_callbacks, "f").add(callback);
7664
- return () => __classPrivateFieldGet$6(this, _QuerySubscriptionProxy_callbacks, "f").delete(callback);
7665
- }
7666
- /** End the subscription on the executor and drop all callbacks. */
7667
- dispose() {
7668
- __classPrivateFieldGet$6(this, _QuerySubscriptionProxy_live, "f").dispose();
7669
- __classPrivateFieldGet$6(this, _QuerySubscriptionProxy_callbacks, "f").clear();
8229
+ __classPrivateFieldGet$7(this, _QuerySubscriptionProxy_callbacks, "f").add(callback);
8230
+ return () => __classPrivateFieldGet$7(this, _QuerySubscriptionProxy_callbacks, "f").delete(callback);
8231
+ }
8232
+ /** Whether the query lost its subscription (a reconnect, a failed
8233
+ * resync), could not open it again yet and is retrying: `result` is then
8234
+ * not live. */
8235
+ get reopening() {
8236
+ return __classPrivateFieldGet$7(this, _QuerySubscriptionProxy_live, "f").reopening;
8237
+ }
8238
+ /** Call `listener` on each failed re-open of the subscription and when a
8239
+ * re-open succeeds after one failed (see {@link LiveQueryStatus}).
8240
+ * Returns a remover. */
8241
+ onStatus(listener) {
8242
+ return __classPrivateFieldGet$7(this, _QuerySubscriptionProxy_live, "f").onStatus(listener);
8243
+ }
8244
+ /** End the subscription on the executor and drop all callbacks. With
8245
+ * `cancelOpening`, a `subscribe()` still waiting on the executor is
8246
+ * cancelled too, and rejects. */
8247
+ dispose(options = {}) {
8248
+ __classPrivateFieldGet$7(this, _QuerySubscriptionProxy_live, "f").dispose(options);
8249
+ __classPrivateFieldGet$7(this, _QuerySubscriptionProxy_callbacks, "f").clear();
7670
8250
  }
7671
8251
  }
7672
8252
  _QuerySubscriptionProxy_live = new WeakMap(), _QuerySubscriptionProxy_callbacks = new WeakMap(), _QuerySubscriptionProxy_initialized = new WeakMap(), _QuerySubscriptionProxy_initResolve = new WeakMap(), _QuerySubscriptionProxy_initReject = new WeakMap(), _QuerySubscriptionProxy_instances = new WeakSet(), _QuerySubscriptionProxy_deliver = function _QuerySubscriptionProxy_deliver(result) {
7673
- __classPrivateFieldGet$6(this, _QuerySubscriptionProxy_initResolve, "f")?.call(this, true);
7674
- __classPrivateFieldSet$6(this, _QuerySubscriptionProxy_initResolve, __classPrivateFieldSet$6(this, _QuerySubscriptionProxy_initReject, undefined, "f"), "f");
7675
- for (const callback of __classPrivateFieldGet$6(this, _QuerySubscriptionProxy_callbacks, "f")) {
8253
+ __classPrivateFieldGet$7(this, _QuerySubscriptionProxy_initResolve, "f")?.call(this, true);
8254
+ __classPrivateFieldSet$7(this, _QuerySubscriptionProxy_initResolve, __classPrivateFieldSet$7(this, _QuerySubscriptionProxy_initReject, undefined, "f"), "f");
8255
+ for (const callback of __classPrivateFieldGet$7(this, _QuerySubscriptionProxy_callbacks, "f")) {
7676
8256
  try {
7677
8257
  callback(result);
7678
8258
  }
@@ -7722,7 +8302,7 @@ _QuerySubscriptionProxy_live = new WeakMap(), _QuerySubscriptionProxy_callbacks
7722
8302
  */
7723
8303
  class PerspectiveProxy {
7724
8304
  /** @internal Exposed for ModelQueryBuilder subscription management */
7725
- get client() { return __classPrivateFieldGet$6(this, _PerspectiveProxy_client, "f"); }
8305
+ get client() { return __classPrivateFieldGet$7(this, _PerspectiveProxy_client, "f"); }
7726
8306
  /**
7727
8307
  * Creates a new PerspectiveProxy instance.
7728
8308
  * Note: Don't create this directly, use ad4m.perspective.add() instead.
@@ -7742,23 +8322,23 @@ class PerspectiveProxy {
7742
8322
  * Note: Don't create this directly, use ad4m.perspective.add() instead.
7743
8323
  */
7744
8324
  );
7745
- __classPrivateFieldSet$6(this, _PerspectiveProxy_handle, handle, "f");
7746
- __classPrivateFieldSet$6(this, _PerspectiveProxy_client, ad4m, "f");
7747
- this.uuid = __classPrivateFieldGet$6(this, _PerspectiveProxy_handle, "f").uuid;
7748
- this.name = __classPrivateFieldGet$6(this, _PerspectiveProxy_handle, "f").name;
7749
- this.owners = __classPrivateFieldGet$6(this, _PerspectiveProxy_handle, "f").owners;
7750
- this.sharedUrl = __classPrivateFieldGet$6(this, _PerspectiveProxy_handle, "f").sharedUrl;
7751
- this.neighbourhood = __classPrivateFieldGet$6(this, _PerspectiveProxy_handle, "f").neighbourhood;
7752
- this.state = __classPrivateFieldGet$6(this, _PerspectiveProxy_handle, "f").state;
8325
+ __classPrivateFieldSet$7(this, _PerspectiveProxy_handle, handle, "f");
8326
+ __classPrivateFieldSet$7(this, _PerspectiveProxy_client, ad4m, "f");
8327
+ this.uuid = __classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid;
8328
+ this.name = __classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").name;
8329
+ this.owners = __classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").owners;
8330
+ this.sharedUrl = __classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").sharedUrl;
8331
+ this.neighbourhood = __classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").neighbourhood;
8332
+ this.state = __classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").state;
7753
8333
  }
7754
8334
  /** Update the proxy's internal handle and public fields in-place.
7755
8335
  * Keeps the same object reference so all holders see the update. */
7756
8336
  updateHandle(handle) {
7757
- if (handle.uuid !== __classPrivateFieldGet$6(this, _PerspectiveProxy_handle, "f").uuid) {
7758
- throw new Error(`PerspectiveProxy.updateHandle: UUID mismatch — proxy is bound to "${__classPrivateFieldGet$6(this, _PerspectiveProxy_handle, "f").uuid}" but received handle with UUID "${handle.uuid}". ` +
8337
+ if (handle.uuid !== __classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid) {
8338
+ throw new Error(`PerspectiveProxy.updateHandle: UUID mismatch — proxy is bound to "${__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid}" but received handle with UUID "${handle.uuid}". ` +
7759
8339
  `This would silently diverge from listeners registered under the original UUID.`);
7760
8340
  }
7761
- __classPrivateFieldSet$6(this, _PerspectiveProxy_handle, handle, "f");
8341
+ __classPrivateFieldSet$7(this, _PerspectiveProxy_handle, handle, "f");
7762
8342
  this.uuid = handle.uuid;
7763
8343
  this.name = handle.name;
7764
8344
  this.owners = handle.owners;
@@ -7839,8 +8419,8 @@ class PerspectiveProxy {
7839
8419
  * @param batchId - Optional batch ID to group this operation with others
7840
8420
  */
7841
8421
  async executeAction(actions, expression, parameters, batchId) {
7842
- const result = await __classPrivateFieldGet$6(this, _PerspectiveProxy_client, "f").executeCommands(__classPrivateFieldGet$6(this, _PerspectiveProxy_handle, "f").uuid, JSON.stringify(actions), expression, JSON.stringify(parameters), batchId);
7843
- invalidatePerspectiveCache(__classPrivateFieldGet$6(this, _PerspectiveProxy_handle, "f").uuid);
8422
+ const result = await __classPrivateFieldGet$7(this, _PerspectiveProxy_client, "f").executeCommands(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid, JSON.stringify(actions), expression, JSON.stringify(parameters), batchId);
8423
+ invalidatePerspectiveCache(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid);
7844
8424
  return result;
7845
8425
  }
7846
8426
  /**
@@ -7865,7 +8445,7 @@ class PerspectiveProxy {
7865
8445
  * ```
7866
8446
  */
7867
8447
  async get(query, options) {
7868
- return await __classPrivateFieldGet$6(this, _PerspectiveProxy_client, "f").queryLinks(__classPrivateFieldGet$6(this, _PerspectiveProxy_handle, "f").uuid, query, options);
8448
+ return await __classPrivateFieldGet$7(this, _PerspectiveProxy_client, "f").queryLinks(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid, query, options);
7869
8449
  }
7870
8450
  /**
7871
8451
  * Runs generic LLM interpretation over a conversation transcript, turning it
@@ -7888,7 +8468,7 @@ class PerspectiveProxy {
7888
8468
  // sixth positional parameter would have made `undefined, undefined, { … }` the normal way
7889
8469
  // to ask for the only one of them most callers want.
7890
8470
  const { existingScope, mintScope, observe, ...callOptions } = options ?? {};
7891
- return await __classPrivateFieldGet$6(this, _PerspectiveProxy_client, "f").runInterpretation(__classPrivateFieldGet$6(this, _PerspectiveProxy_handle, "f").uuid, transcript, basePrefix, classes, existingScope, mintScope, observe, callOptions);
8471
+ return await __classPrivateFieldGet$7(this, _PerspectiveProxy_client, "f").runInterpretation(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid, transcript, basePrefix, classes, existingScope, mintScope, observe, callOptions);
7892
8472
  }
7893
8473
  /**
7894
8474
  * Harness-dispatched interpretation pass over this perspective (design v3
@@ -7915,7 +8495,7 @@ class PerspectiveProxy {
7915
8495
  // `on('auto-processor-event')` to render the harness loop
7916
8496
  // live in a UI. Absent = fast headless path (no telemetry cost).
7917
8497
  observationId, emitDebugEvents, options) {
7918
- return await __classPrivateFieldGet$6(this, _PerspectiveProxy_client, "f").runInterpretationWithHarness(__classPrivateFieldGet$6(this, _PerspectiveProxy_handle, "f").uuid, transcript, basePrefix, maxToolCalls, classes, modelOverride, undefined, observationId, emitDebugEvents, options);
8498
+ return await __classPrivateFieldGet$7(this, _PerspectiveProxy_client, "f").runInterpretationWithHarness(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid, transcript, basePrefix, maxToolCalls, classes, modelOverride, undefined, observationId, emitDebugEvents, options);
7919
8499
  }
7920
8500
  /**
7921
8501
  * Ask a model something about this perspective, or ask it to change something, with the
@@ -7928,7 +8508,7 @@ class PerspectiveProxy {
7928
8508
  * @param options `signal` / `timeoutMs` (default {@link LONG_TIMEOUT_MS})
7929
8509
  */
7930
8510
  async runAgent(messages, settings, options) {
7931
- return await __classPrivateFieldGet$6(this, _PerspectiveProxy_client, "f").runAgent(__classPrivateFieldGet$6(this, _PerspectiveProxy_handle, "f").uuid, messages, settings, options);
8511
+ return await __classPrivateFieldGet$7(this, _PerspectiveProxy_client, "f").runAgent(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid, messages, settings, options);
7932
8512
  }
7933
8513
  /**
7934
8514
  * Register a neighbourhood auto-processor on this perspective. The executor
@@ -7937,7 +8517,7 @@ class PerspectiveProxy {
7937
8517
  * processor id. Subscribe to progress via `on('auto-processor-event')`.
7938
8518
  */
7939
8519
  async addAutoProcessor(config) {
7940
- return await __classPrivateFieldGet$6(this, _PerspectiveProxy_client, "f").addAutoProcessor(__classPrivateFieldGet$6(this, _PerspectiveProxy_handle, "f").uuid, config);
8520
+ return await __classPrivateFieldGet$7(this, _PerspectiveProxy_client, "f").addAutoProcessor(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid, config);
7941
8521
  }
7942
8522
  /**
7943
8523
  * Stop an auto-processor by deleting its config.
@@ -7955,7 +8535,7 @@ class PerspectiveProxy {
7955
8535
  * one left off rather than re-reading every turn.
7956
8536
  */
7957
8537
  async removeAutoProcessor(processorId) {
7958
- return await __classPrivateFieldGet$6(this, _PerspectiveProxy_client, "f").removeAutoProcessor(__classPrivateFieldGet$6(this, _PerspectiveProxy_handle, "f").uuid, processorId);
8538
+ return await __classPrivateFieldGet$7(this, _PerspectiveProxy_client, "f").removeAutoProcessor(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid, processorId);
7959
8539
  }
7960
8540
  /**
7961
8541
  * Pending interpretation overlays on this perspective — LLM suggestions the
@@ -7969,17 +8549,17 @@ class PerspectiveProxy {
7969
8549
  * Each caller gets its own copy of the array.
7970
8550
  */
7971
8551
  async interpretationOverlays() {
7972
- if (__classPrivateFieldGet$6(this, _PerspectiveProxy_overlaysInFlight, "f")) {
7973
- return [...(await __classPrivateFieldGet$6(this, _PerspectiveProxy_overlaysInFlight, "f"))];
8552
+ if (__classPrivateFieldGet$7(this, _PerspectiveProxy_overlaysInFlight, "f")) {
8553
+ return [...(await __classPrivateFieldGet$7(this, _PerspectiveProxy_overlaysInFlight, "f"))];
7974
8554
  }
7975
- const pending = __classPrivateFieldGet$6(this, _PerspectiveProxy_client, "f").interpretationOverlays(__classPrivateFieldGet$6(this, _PerspectiveProxy_handle, "f").uuid);
7976
- __classPrivateFieldSet$6(this, _PerspectiveProxy_overlaysInFlight, pending, "f");
8555
+ const pending = __classPrivateFieldGet$7(this, _PerspectiveProxy_client, "f").interpretationOverlays(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid);
8556
+ __classPrivateFieldSet$7(this, _PerspectiveProxy_overlaysInFlight, pending, "f");
7977
8557
  try {
7978
8558
  return [...(await pending)];
7979
8559
  }
7980
8560
  finally {
7981
- if (__classPrivateFieldGet$6(this, _PerspectiveProxy_overlaysInFlight, "f") === pending) {
7982
- __classPrivateFieldSet$6(this, _PerspectiveProxy_overlaysInFlight, null, "f");
8561
+ if (__classPrivateFieldGet$7(this, _PerspectiveProxy_overlaysInFlight, "f") === pending) {
8562
+ __classPrivateFieldSet$7(this, _PerspectiveProxy_overlaysInFlight, null, "f");
7983
8563
  }
7984
8564
  }
7985
8565
  }
@@ -7990,11 +8570,11 @@ class PerspectiveProxy {
7990
8570
  */
7991
8571
  async acceptInterpretation(base, property) {
7992
8572
  try {
7993
- return await __classPrivateFieldGet$6(this, _PerspectiveProxy_client, "f").acceptInterpretation(__classPrivateFieldGet$6(this, _PerspectiveProxy_handle, "f").uuid, base, property);
8573
+ return await __classPrivateFieldGet$7(this, _PerspectiveProxy_client, "f").acceptInterpretation(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid, base, property);
7994
8574
  }
7995
8575
  finally {
7996
8576
  // A read already in flight may predate this write; later callers must not join it.
7997
- __classPrivateFieldSet$6(this, _PerspectiveProxy_overlaysInFlight, null, "f");
8577
+ __classPrivateFieldSet$7(this, _PerspectiveProxy_overlaysInFlight, null, "f");
7998
8578
  }
7999
8579
  }
8000
8580
  /**
@@ -8004,11 +8584,11 @@ class PerspectiveProxy {
8004
8584
  */
8005
8585
  async rejectInterpretation(base, property) {
8006
8586
  try {
8007
- return await __classPrivateFieldGet$6(this, _PerspectiveProxy_client, "f").rejectInterpretation(__classPrivateFieldGet$6(this, _PerspectiveProxy_handle, "f").uuid, base, property);
8587
+ return await __classPrivateFieldGet$7(this, _PerspectiveProxy_client, "f").rejectInterpretation(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid, base, property);
8008
8588
  }
8009
8589
  finally {
8010
8590
  // A read already in flight may predate this write; later callers must not join it.
8011
- __classPrivateFieldSet$6(this, _PerspectiveProxy_overlaysInFlight, null, "f");
8591
+ __classPrivateFieldSet$7(this, _PerspectiveProxy_overlaysInFlight, null, "f");
8012
8592
  }
8013
8593
  }
8014
8594
  /**
@@ -8019,14 +8599,14 @@ class PerspectiveProxy {
8019
8599
  * for a non-terminal state is refused.
8020
8600
  */
8021
8601
  async proposeFlowTransition(instanceUri, toState, rationale, outputs) {
8022
- return await __classPrivateFieldGet$6(this, _PerspectiveProxy_client, "f").proposeFlowTransition(__classPrivateFieldGet$6(this, _PerspectiveProxy_handle, "f").uuid, instanceUri, toState, rationale, outputs);
8602
+ return await __classPrivateFieldGet$7(this, _PerspectiveProxy_client, "f").proposeFlowTransition(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid, instanceUri, toState, rationale, outputs);
8023
8603
  }
8024
8604
  async acceptFlowProposal(proposalUri) {
8025
- return await __classPrivateFieldGet$6(this, _PerspectiveProxy_client, "f").acceptFlowProposal(__classPrivateFieldGet$6(this, _PerspectiveProxy_handle, "f").uuid, proposalUri);
8605
+ return await __classPrivateFieldGet$7(this, _PerspectiveProxy_client, "f").acceptFlowProposal(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid, proposalUri);
8026
8606
  }
8027
8607
  /** Withdraw our own links from a proposal; resolves to how many went. */
8028
8608
  async rejectFlowProposal(proposalUri) {
8029
- return await __classPrivateFieldGet$6(this, _PerspectiveProxy_client, "f").rejectFlowProposal(__classPrivateFieldGet$6(this, _PerspectiveProxy_handle, "f").uuid, proposalUri);
8609
+ return await __classPrivateFieldGet$7(this, _PerspectiveProxy_client, "f").rejectFlowProposal(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid, proposalUri);
8030
8610
  }
8031
8611
  /**
8032
8612
  * Re-decide a flow receipt under this perspective's own flow catalogue.
@@ -8034,7 +8614,7 @@ class PerspectiveProxy {
8034
8614
  * `outcome`, never on a boolean you derive from it.
8035
8615
  */
8036
8616
  async verifyFlowReceipt(receipt) {
8037
- return await __classPrivateFieldGet$6(this, _PerspectiveProxy_client, "f").verifyFlowReceipt(__classPrivateFieldGet$6(this, _PerspectiveProxy_handle, "f").uuid, receipt);
8617
+ return await __classPrivateFieldGet$7(this, _PerspectiveProxy_client, "f").verifyFlowReceipt(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid, receipt);
8038
8618
  }
8039
8619
  /**
8040
8620
  * Which instances are, as they stand, valid outputs of `flow`?
@@ -8051,7 +8631,7 @@ class PerspectiveProxy {
8051
8631
  * "no valid outputs". The filter rejects the same way.
8052
8632
  */
8053
8633
  async flowValidOutputs(flow, state) {
8054
- return await __classPrivateFieldGet$6(this, _PerspectiveProxy_client, "f").flowValidOutputs(__classPrivateFieldGet$6(this, _PerspectiveProxy_handle, "f").uuid, flow, state);
8634
+ return await __classPrivateFieldGet$7(this, _PerspectiveProxy_client, "f").flowValidOutputs(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid, flow, state);
8055
8635
  }
8056
8636
  /**
8057
8637
  * The state each flow instance is in, as **this agent's** executor last
@@ -8066,7 +8646,7 @@ class PerspectiveProxy {
8066
8646
  * `FlowInstance.findAll` / `start` call this for you.
8067
8647
  */
8068
8648
  async flowStates(instances) {
8069
- return await __classPrivateFieldGet$6(this, _PerspectiveProxy_client, "f").flowStates(__classPrivateFieldGet$6(this, _PerspectiveProxy_handle, "f").uuid, instances);
8649
+ return await __classPrivateFieldGet$7(this, _PerspectiveProxy_client, "f").flowStates(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid, instances);
8070
8650
  }
8071
8651
  /**
8072
8652
  * The proposals of `instance` whose votes settled an edge, as this
@@ -8074,7 +8654,7 @@ class PerspectiveProxy {
8074
8654
  * Replaces the `resolvedAs` property proposals used to carry.
8075
8655
  */
8076
8656
  async flowFired(instance) {
8077
- return await __classPrivateFieldGet$6(this, _PerspectiveProxy_client, "f").flowFired(__classPrivateFieldGet$6(this, _PerspectiveProxy_handle, "f").uuid, instance);
8657
+ return await __classPrivateFieldGet$7(this, _PerspectiveProxy_client, "f").flowFired(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid, instance);
8078
8658
  }
8079
8659
  /**
8080
8660
  * Called whenever a flow instance on this perspective changes state on
@@ -8095,7 +8675,7 @@ class PerspectiveProxy {
8095
8675
  }
8096
8676
  /** Mint and store the receipt for a completed flow run. */
8097
8677
  async mintFlowReceipt(instanceUri) {
8098
- return await __classPrivateFieldGet$6(this, _PerspectiveProxy_client, "f").mintFlowReceipt(__classPrivateFieldGet$6(this, _PerspectiveProxy_handle, "f").uuid, instanceUri);
8678
+ return await __classPrivateFieldGet$7(this, _PerspectiveProxy_client, "f").mintFlowReceipt(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid, instanceUri);
8099
8679
  }
8100
8680
  /**
8101
8681
  * Executes a Prolog query against the perspective's knowledge base.
@@ -8121,7 +8701,7 @@ class PerspectiveProxy {
8121
8701
  * ```
8122
8702
  */
8123
8703
  async infer(query, options) {
8124
- return await __classPrivateFieldGet$6(this, _PerspectiveProxy_client, "f").queryProlog(__classPrivateFieldGet$6(this, _PerspectiveProxy_handle, "f").uuid, query, options);
8704
+ return await __classPrivateFieldGet$7(this, _PerspectiveProxy_client, "f").queryProlog(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid, query, options);
8125
8705
  }
8126
8706
  /**
8127
8707
  * Executes a SPARQL query against the perspective's link cache.
@@ -8146,11 +8726,11 @@ class PerspectiveProxy {
8146
8726
  * @returns Query results as parsed JSON
8147
8727
  */
8148
8728
  async querySparql(query, options) {
8149
- const cached = getCachedResult(__classPrivateFieldGet$6(this, _PerspectiveProxy_handle, "f").uuid, query);
8729
+ const cached = getCachedResult(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid, query);
8150
8730
  if (cached !== undefined)
8151
8731
  return cached;
8152
- const result = await __classPrivateFieldGet$6(this, _PerspectiveProxy_client, "f").querySparql(__classPrivateFieldGet$6(this, _PerspectiveProxy_handle, "f").uuid, query, options);
8153
- setCachedResult(__classPrivateFieldGet$6(this, _PerspectiveProxy_handle, "f").uuid, query, result);
8732
+ const result = await __classPrivateFieldGet$7(this, _PerspectiveProxy_client, "f").querySparql(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid, query, options);
8733
+ setCachedResult(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid, query, result);
8154
8734
  return result;
8155
8735
  }
8156
8736
  /**
@@ -8167,7 +8747,7 @@ class PerspectiveProxy {
8167
8747
  * @returns Object with `instances` array and `totalCount`
8168
8748
  */
8169
8749
  async modelQuery(className, queryJson, options) {
8170
- return await __classPrivateFieldGet$6(this, _PerspectiveProxy_client, "f").modelQuery(__classPrivateFieldGet$6(this, _PerspectiveProxy_handle, "f").uuid, className, queryJson, options);
8750
+ return await __classPrivateFieldGet$7(this, _PerspectiveProxy_client, "f").modelQuery(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid, className, queryJson, options);
8171
8751
  }
8172
8752
  /** Resolve each URI to the names of every subject class it is an instance of.
8173
8753
  *
@@ -8202,7 +8782,7 @@ class PerspectiveProxy {
8202
8782
  async subjectClassesOf(uris) {
8203
8783
  if (uris.length === 0)
8204
8784
  return {};
8205
- return await __classPrivateFieldGet$6(this, _PerspectiveProxy_client, "f").subjectClassesOf(__classPrivateFieldGet$6(this, _PerspectiveProxy_handle, "f").uuid, uris);
8785
+ return await __classPrivateFieldGet$7(this, _PerspectiveProxy_client, "f").subjectClassesOf(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid, uris);
8206
8786
  }
8207
8787
  /**
8208
8788
  * Evaluate property getters for a batch of instances in a single RPC call.
@@ -8217,7 +8797,7 @@ class PerspectiveProxy {
8217
8797
  * @returns Map of instance ID → evaluated property values
8218
8798
  */
8219
8799
  async evaluateGetters(className, instanceIds, propertyNames) {
8220
- return await __classPrivateFieldGet$6(this, _PerspectiveProxy_client, "f").evaluateGetters(__classPrivateFieldGet$6(this, _PerspectiveProxy_handle, "f").uuid, className, instanceIds, propertyNames);
8800
+ return await __classPrivateFieldGet$7(this, _PerspectiveProxy_client, "f").evaluateGetters(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid, className, instanceIds, propertyNames);
8221
8801
  }
8222
8802
  /**
8223
8803
  * Open a live model query on the executor. Later changes arrive as
@@ -8230,7 +8810,7 @@ class PerspectiveProxy {
8230
8810
  * @returns `subscriptionId`, initial `result` and `revision` (0)
8231
8811
  */
8232
8812
  async modelSubscribe(className, queryJson) {
8233
- return await __classPrivateFieldGet$6(this, _PerspectiveProxy_client, "f").modelSubscribe(__classPrivateFieldGet$6(this, _PerspectiveProxy_handle, "f").uuid, className, queryJson);
8813
+ return await __classPrivateFieldGet$7(this, _PerspectiveProxy_client, "f").modelSubscribe(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid, className, queryJson);
8234
8814
  }
8235
8815
  /**
8236
8816
  * Adds a new link to the perspective.
@@ -8258,8 +8838,8 @@ class PerspectiveProxy {
8258
8838
  * ```
8259
8839
  */
8260
8840
  async add(link, status = 'shared', batchId) {
8261
- const result = await __classPrivateFieldGet$6(this, _PerspectiveProxy_client, "f").addLink(__classPrivateFieldGet$6(this, _PerspectiveProxy_handle, "f").uuid, link, status, batchId);
8262
- invalidatePerspectiveCache(__classPrivateFieldGet$6(this, _PerspectiveProxy_handle, "f").uuid);
8841
+ const result = await __classPrivateFieldGet$7(this, _PerspectiveProxy_client, "f").addLink(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid, link, status, batchId);
8842
+ invalidatePerspectiveCache(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid);
8263
8843
  return result;
8264
8844
  }
8265
8845
  /**
@@ -8272,8 +8852,8 @@ class PerspectiveProxy {
8272
8852
  * @returns Array of created LinkExpressions
8273
8853
  */
8274
8854
  async addLinks(links, status = 'shared', batchId) {
8275
- const result = await __classPrivateFieldGet$6(this, _PerspectiveProxy_client, "f").addLinks(__classPrivateFieldGet$6(this, _PerspectiveProxy_handle, "f").uuid, links, status, batchId);
8276
- invalidatePerspectiveCache(__classPrivateFieldGet$6(this, _PerspectiveProxy_handle, "f").uuid);
8855
+ const result = await __classPrivateFieldGet$7(this, _PerspectiveProxy_client, "f").addLinks(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid, links, status, batchId);
8856
+ invalidatePerspectiveCache(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid);
8277
8857
  return result;
8278
8858
  }
8279
8859
  /**
@@ -8284,8 +8864,8 @@ class PerspectiveProxy {
8284
8864
  * @returns Array of removed LinkExpressions
8285
8865
  */
8286
8866
  async removeLinks(links, batchId) {
8287
- const result = await __classPrivateFieldGet$6(this, _PerspectiveProxy_client, "f").removeLinks(__classPrivateFieldGet$6(this, _PerspectiveProxy_handle, "f").uuid, links, batchId);
8288
- invalidatePerspectiveCache(__classPrivateFieldGet$6(this, _PerspectiveProxy_handle, "f").uuid);
8867
+ const result = await __classPrivateFieldGet$7(this, _PerspectiveProxy_client, "f").removeLinks(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid, links, batchId);
8868
+ invalidatePerspectiveCache(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid);
8289
8869
  return result;
8290
8870
  }
8291
8871
  /**
@@ -8297,8 +8877,8 @@ class PerspectiveProxy {
8297
8877
  * @returns Object containing results of the mutations
8298
8878
  */
8299
8879
  async linkMutations(mutations, status = 'shared') {
8300
- const result = await __classPrivateFieldGet$6(this, _PerspectiveProxy_client, "f").linkMutations(__classPrivateFieldGet$6(this, _PerspectiveProxy_handle, "f").uuid, mutations, status);
8301
- invalidatePerspectiveCache(__classPrivateFieldGet$6(this, _PerspectiveProxy_handle, "f").uuid);
8880
+ const result = await __classPrivateFieldGet$7(this, _PerspectiveProxy_client, "f").linkMutations(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid, mutations, status);
8881
+ invalidatePerspectiveCache(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid);
8302
8882
  return result;
8303
8883
  }
8304
8884
  /**
@@ -8316,7 +8896,7 @@ class PerspectiveProxy {
8316
8896
  * @returns The added LinkExpression
8317
8897
  */
8318
8898
  async addLinkExpression(link, status = 'shared', batchId) {
8319
- return await __classPrivateFieldGet$6(this, _PerspectiveProxy_client, "f").addLinkExpression(__classPrivateFieldGet$6(this, _PerspectiveProxy_handle, "f").uuid, link, status, batchId);
8899
+ return await __classPrivateFieldGet$7(this, _PerspectiveProxy_client, "f").addLinkExpression(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid, link, status, batchId);
8320
8900
  }
8321
8901
  /**
8322
8902
  * Updates an existing link with new data.
@@ -8326,8 +8906,8 @@ class PerspectiveProxy {
8326
8906
  * @param batchId - Optional batch ID to group this operation with others
8327
8907
  */
8328
8908
  async update(oldLink, newLink, batchId) {
8329
- const result = await __classPrivateFieldGet$6(this, _PerspectiveProxy_client, "f").updateLink(__classPrivateFieldGet$6(this, _PerspectiveProxy_handle, "f").uuid, oldLink, newLink, batchId);
8330
- invalidatePerspectiveCache(__classPrivateFieldGet$6(this, _PerspectiveProxy_handle, "f").uuid);
8909
+ const result = await __classPrivateFieldGet$7(this, _PerspectiveProxy_client, "f").updateLink(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid, oldLink, newLink, batchId);
8910
+ invalidatePerspectiveCache(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid);
8331
8911
  return result;
8332
8912
  }
8333
8913
  /**
@@ -8374,18 +8954,18 @@ class PerspectiveProxy {
8374
8954
  else {
8375
8955
  resolvedLink = link;
8376
8956
  }
8377
- const result = await __classPrivateFieldGet$6(this, _PerspectiveProxy_client, "f").removeLink(__classPrivateFieldGet$6(this, _PerspectiveProxy_handle, "f").uuid, resolvedLink, batchId);
8378
- invalidatePerspectiveCache(__classPrivateFieldGet$6(this, _PerspectiveProxy_handle, "f").uuid);
8957
+ const result = await __classPrivateFieldGet$7(this, _PerspectiveProxy_client, "f").removeLink(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid, resolvedLink, batchId);
8958
+ invalidatePerspectiveCache(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid);
8379
8959
  return result;
8380
8960
  }
8381
8961
  /** Creates a new batch for grouping operations */
8382
8962
  async createBatch() {
8383
- return await __classPrivateFieldGet$6(this, _PerspectiveProxy_client, "f").createBatch(__classPrivateFieldGet$6(this, _PerspectiveProxy_handle, "f").uuid);
8963
+ return await __classPrivateFieldGet$7(this, _PerspectiveProxy_client, "f").createBatch(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid);
8384
8964
  }
8385
8965
  /** Commits a batch of operations */
8386
8966
  async commitBatch(batchId) {
8387
- const result = await __classPrivateFieldGet$6(this, _PerspectiveProxy_client, "f").commitBatch(__classPrivateFieldGet$6(this, _PerspectiveProxy_handle, "f").uuid, batchId);
8388
- invalidatePerspectiveCache(__classPrivateFieldGet$6(this, _PerspectiveProxy_handle, "f").uuid);
8967
+ const result = await __classPrivateFieldGet$7(this, _PerspectiveProxy_client, "f").commitBatch(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid, batchId);
8968
+ invalidatePerspectiveCache(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid);
8389
8969
  return result;
8390
8970
  }
8391
8971
  /**
@@ -8395,7 +8975,7 @@ class PerspectiveProxy {
8395
8975
  * @returns The rendered Expression
8396
8976
  */
8397
8977
  async getExpression(expressionURI) {
8398
- return await __classPrivateFieldGet$6(this, _PerspectiveProxy_client, "f").getExpression(expressionURI);
8978
+ return await __classPrivateFieldGet$7(this, _PerspectiveProxy_client, "f").getExpression(expressionURI);
8399
8979
  }
8400
8980
  /**
8401
8981
  * Creates a new Expression in the specified Language.
@@ -8405,7 +8985,7 @@ class PerspectiveProxy {
8405
8985
  * @returns URI of the created Expression
8406
8986
  */
8407
8987
  async createExpression(content, languageAddress) {
8408
- return await __classPrivateFieldGet$6(this, _PerspectiveProxy_client, "f").createExpression(content, languageAddress);
8988
+ return await __classPrivateFieldGet$7(this, _PerspectiveProxy_client, "f").createExpression(content, languageAddress);
8409
8989
  }
8410
8990
  /**
8411
8991
  * Call `handler` with every `type` event about this perspective, until the
@@ -8421,18 +9001,18 @@ class PerspectiveProxy {
8421
9001
  on(type, handler) {
8422
9002
  // A registration of this proxy's own, so dispose() cannot release another proxy's
8423
9003
  // registration of the same function (on() treats equal handlers as one).
8424
- const release = __classPrivateFieldGet$6(this, _PerspectiveProxy_client, "f").on(type, (event) => handler(event), { perspective: __classPrivateFieldGet$6(this, _PerspectiveProxy_handle, "f").uuid });
9004
+ const release = __classPrivateFieldGet$7(this, _PerspectiveProxy_client, "f").on(type, (event) => handler(event), { perspective: __classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid });
8425
9005
  const releaseOnce = () => {
8426
- if (__classPrivateFieldGet$6(this, _PerspectiveProxy_releases, "f").delete(releaseOnce))
9006
+ if (__classPrivateFieldGet$7(this, _PerspectiveProxy_releases, "f").delete(releaseOnce))
8427
9007
  release();
8428
9008
  };
8429
- __classPrivateFieldGet$6(this, _PerspectiveProxy_releases, "f").add(releaseOnce);
9009
+ __classPrivateFieldGet$7(this, _PerspectiveProxy_releases, "f").add(releaseOnce);
8430
9010
  return releaseOnce;
8431
9011
  }
8432
9012
  /** Removes every handler this proxy registered. Other proxies for the same
8433
9013
  * perspective keep theirs. */
8434
9014
  dispose() {
8435
- for (const release of [...__classPrivateFieldGet$6(this, _PerspectiveProxy_releases, "f")])
9015
+ for (const release of [...__classPrivateFieldGet$7(this, _PerspectiveProxy_releases, "f")])
8436
9016
  release();
8437
9017
  }
8438
9018
  /**
@@ -8442,7 +9022,7 @@ class PerspectiveProxy {
8442
9022
  * @returns Perspective object containing all links
8443
9023
  */
8444
9024
  async snapshot() {
8445
- return __classPrivateFieldGet$6(this, _PerspectiveProxy_client, "f").snapshotByUUID(__classPrivateFieldGet$6(this, _PerspectiveProxy_handle, "f").uuid);
9025
+ return __classPrivateFieldGet$7(this, _PerspectiveProxy_client, "f").snapshotByUUID(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid);
8446
9026
  }
8447
9027
  /**
8448
9028
  * Loads a perspective snapshot, replacing current content.
@@ -8646,14 +9226,14 @@ class PerspectiveProxy {
8646
9226
  * await perspective.addSdna('Recipe', prologCode, 'subject_class');
8647
9227
  */
8648
9228
  async addSdna(name, sdnaCode, sdnaType, shaclJson) {
8649
- return __classPrivateFieldGet$6(this, _PerspectiveProxy_client, "f").addSdna(__classPrivateFieldGet$6(this, _PerspectiveProxy_handle, "f").uuid, name, sdnaCode, sdnaType, shaclJson);
9229
+ return __classPrivateFieldGet$7(this, _PerspectiveProxy_client, "f").addSdna(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid, name, sdnaCode, sdnaType, shaclJson);
8650
9230
  }
8651
9231
  /**
8652
9232
  * Batch variant of addSdna — registers multiple SDNA entries in a single RPC call.
8653
9233
  * Acquires the Rust-side mutex once for the entire batch.
8654
9234
  */
8655
9235
  async addSdnaAll(entries) {
8656
- return __classPrivateFieldGet$6(this, _PerspectiveProxy_client, "f").addSdnaBatch(__classPrivateFieldGet$6(this, _PerspectiveProxy_handle, "f").uuid, entries);
9236
+ return __classPrivateFieldGet$7(this, _PerspectiveProxy_client, "f").addSdnaBatch(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid, entries);
8657
9237
  }
8658
9238
  /**
8659
9239
  * Batch-registers multiple model classes as SHACL subject classes in a single RPC call.
@@ -8666,7 +9246,7 @@ class PerspectiveProxy {
8666
9246
  if (Object.prototype.hasOwnProperty.call(jsClass, 'builtinUri'))
8667
9247
  continue;
8668
9248
  const className = jsClass.className || jsClass.prototype?.className || jsClass.name;
8669
- if (__classPrivateFieldGet$6(this, _PerspectiveProxy_ensuredSubjectClasses, "f").has(className))
9249
+ if (__classPrivateFieldGet$7(this, _PerspectiveProxy_ensuredSubjectClasses, "f").has(className))
8670
9250
  continue;
8671
9251
  if (!jsClass.generateSHACL) {
8672
9252
  throw new Error(`Class ${jsClass.name} must have generateSHACL(). Use @Model decorator.`);
@@ -8682,7 +9262,7 @@ class PerspectiveProxy {
8682
9262
  return;
8683
9263
  await this.addSdnaAll(entries);
8684
9264
  for (const entry of entries) {
8685
- __classPrivateFieldGet$6(this, _PerspectiveProxy_ensuredSubjectClasses, "f").add(entry.name);
9265
+ __classPrivateFieldGet$7(this, _PerspectiveProxy_ensuredSubjectClasses, "f").add(entry.name);
8686
9266
  }
8687
9267
  }
8688
9268
  /**
@@ -8722,7 +9302,7 @@ class PerspectiveProxy {
8722
9302
  * in-process and returns link triples for client-side reconstruction.
8723
9303
  */
8724
9304
  async getShacl(name) {
8725
- const result = await __classPrivateFieldGet$6(this, _PerspectiveProxy_client, "f").getShacl(__classPrivateFieldGet$6(this, _PerspectiveProxy_handle, "f").uuid, name);
9305
+ const result = await __classPrivateFieldGet$7(this, _PerspectiveProxy_client, "f").getShacl(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid, name);
8726
9306
  if (!result)
8727
9307
  return null;
8728
9308
  return SHACLShape.fromLinks(result.links, result.shapeUri);
@@ -8731,7 +9311,7 @@ class PerspectiveProxy {
8731
9311
  * List the names of every SHACL shape stored in this Perspective (one RPC call).
8732
9312
  */
8733
9313
  async getShaclNames() {
8734
- return __classPrivateFieldGet$6(this, _PerspectiveProxy_client, "f").getShaclNames(__classPrivateFieldGet$6(this, _PerspectiveProxy_handle, "f").uuid);
9314
+ return __classPrivateFieldGet$7(this, _PerspectiveProxy_client, "f").getShaclNames(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid);
8735
9315
  }
8736
9316
  /**
8737
9317
  * Resolve a shape's `sh:targetClass` by name (one RPC call).
@@ -8742,7 +9322,7 @@ class PerspectiveProxy {
8742
9322
  * so this method is a pure passthrough.
8743
9323
  */
8744
9324
  async getShaclTargetClass(name) {
8745
- return __classPrivateFieldGet$6(this, _PerspectiveProxy_client, "f").getShaclTargetClass(__classPrivateFieldGet$6(this, _PerspectiveProxy_handle, "f").uuid, name);
9325
+ return __classPrivateFieldGet$7(this, _PerspectiveProxy_client, "f").getShaclTargetClass(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid, name);
8746
9326
  }
8747
9327
  /**
8748
9328
  * Get all SHACL shapes stored in this Perspective (one RPC call).
@@ -8751,7 +9331,7 @@ class PerspectiveProxy {
8751
9331
  * does not hide the others.
8752
9332
  */
8753
9333
  async getAllShacl() {
8754
- const entries = await __classPrivateFieldGet$6(this, _PerspectiveProxy_client, "f").getAllShacl(__classPrivateFieldGet$6(this, _PerspectiveProxy_handle, "f").uuid);
9334
+ const entries = await __classPrivateFieldGet$7(this, _PerspectiveProxy_client, "f").getAllShacl(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid);
8755
9335
  const shapes = [];
8756
9336
  for (const { name, shapeUri, links } of entries) {
8757
9337
  try {
@@ -8938,16 +9518,11 @@ class PerspectiveProxy {
8938
9518
  async stringOrTemplateObjectToSubjectClassName(subjectClass) {
8939
9519
  if (typeof subjectClass === "string")
8940
9520
  return subjectClass;
8941
- else {
8942
- let subjectClasses = await this.subjectClassesByTemplate(subjectClass);
8943
- if (subjectClasses[0]) {
8944
- return subjectClasses[0];
8945
- }
8946
- else {
8947
- //@ts-ignore
8948
- return subjectClass.className;
8949
- }
8950
- }
9521
+ // The @Model decorator names the class, as in createSubject: no lookup.
9522
+ // Only an undecorated object is matched by its properties.
9523
+ const obj = subjectClass;
9524
+ return obj.className || obj.constructor?.className || obj.constructor?.prototype?.className
9525
+ || (await this.subjectClassesByTemplate(obj))[0];
8951
9526
  }
8952
9527
  /**
8953
9528
  * Creates a new subject instance of the given subject class
@@ -8967,7 +9542,7 @@ class PerspectiveProxy {
8967
9542
  let className;
8968
9543
  if (typeof subjectClass === "string") {
8969
9544
  className = subjectClass;
8970
- await __classPrivateFieldGet$6(this, _PerspectiveProxy_client, "f").createSubject(__classPrivateFieldGet$6(this, _PerspectiveProxy_handle, "f").uuid, JSON.stringify({
9545
+ await __classPrivateFieldGet$7(this, _PerspectiveProxy_client, "f").createSubject(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid, JSON.stringify({
8971
9546
  className,
8972
9547
  initialValues
8973
9548
  }), exprAddr, initialValues ? JSON.stringify(initialValues) : undefined, batchId);
@@ -8979,7 +9554,7 @@ class PerspectiveProxy {
8979
9554
  if (!resolvedClassName) {
8980
9555
  throw new Error("Could not resolve subject class name from object. Use a decorated class or pass a className string.");
8981
9556
  }
8982
- await __classPrivateFieldGet$6(this, _PerspectiveProxy_client, "f").createSubject(__classPrivateFieldGet$6(this, _PerspectiveProxy_handle, "f").uuid, JSON.stringify({
9557
+ await __classPrivateFieldGet$7(this, _PerspectiveProxy_client, "f").createSubject(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid, JSON.stringify({
8983
9558
  className: resolvedClassName,
8984
9559
  initialValues
8985
9560
  }), exprAddr, initialValues ? JSON.stringify(initialValues) : undefined, batchId);
@@ -8996,12 +9571,12 @@ class PerspectiveProxy {
8996
9571
  * abstract class (#1435), each value is written by every class of the
8997
9572
  * record that the abstract class reads, under its own name. */
8998
9573
  async updateSubject(className, exprAddr, values, batchId) {
8999
- await __classPrivateFieldGet$6(this, _PerspectiveProxy_client, "f").updateSubject(__classPrivateFieldGet$6(this, _PerspectiveProxy_handle, "f").uuid, className, exprAddr, JSON.stringify(values), batchId);
9000
- invalidatePerspectiveCache(__classPrivateFieldGet$6(this, _PerspectiveProxy_handle, "f").uuid);
9574
+ await __classPrivateFieldGet$7(this, _PerspectiveProxy_client, "f").updateSubject(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid, className, exprAddr, JSON.stringify(values), batchId);
9575
+ invalidatePerspectiveCache(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid);
9001
9576
  }
9002
9577
  async getSubjectData(subjectClass, exprAddr) {
9003
9578
  if (typeof subjectClass === "string") {
9004
- return JSON.parse(await __classPrivateFieldGet$6(this, _PerspectiveProxy_client, "f").getSubjectData(__classPrivateFieldGet$6(this, _PerspectiveProxy_handle, "f").uuid, JSON.stringify({ className: subjectClass }), exprAddr));
9579
+ return JSON.parse(await __classPrivateFieldGet$7(this, _PerspectiveProxy_client, "f").getSubjectData(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid, JSON.stringify({ className: subjectClass }), exprAddr));
9005
9580
  }
9006
9581
  const obj = subjectClass;
9007
9582
  const resolvedClassName = obj.className || obj.constructor?.className || obj.constructor?.prototype?.className
@@ -9009,7 +9584,7 @@ class PerspectiveProxy {
9009
9584
  if (!resolvedClassName) {
9010
9585
  throw new Error("Could not resolve subject class name from object. Use a decorated class or pass a className string.");
9011
9586
  }
9012
- return JSON.parse(await __classPrivateFieldGet$6(this, _PerspectiveProxy_client, "f").getSubjectData(__classPrivateFieldGet$6(this, _PerspectiveProxy_handle, "f").uuid, JSON.stringify({ className: resolvedClassName }), exprAddr));
9587
+ return JSON.parse(await __classPrivateFieldGet$7(this, _PerspectiveProxy_client, "f").getSubjectData(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid, JSON.stringify({ className: resolvedClassName }), exprAddr));
9013
9588
  }
9014
9589
  /**
9015
9590
  * Gets actions from SHACL links for a given predicate (e.g., ad4m://constructor, ad4m://destructor).
@@ -9060,8 +9635,8 @@ class PerspectiveProxy {
9060
9635
  // so it has no marker: the executor dispatches it by its URI.
9061
9636
  const ctor = subjectClass?.constructor;
9062
9637
  if (typeof subjectClass === "object" && ctor && Object.prototype.hasOwnProperty.call(ctor, 'builtinUri')) {
9063
- await __classPrivateFieldGet$6(this, _PerspectiveProxy_client, "f").removeSubject(__classPrivateFieldGet$6(this, _PerspectiveProxy_handle, "f").uuid, ctor.builtinUri, exprAddr, batchId);
9064
- invalidatePerspectiveCache(__classPrivateFieldGet$6(this, _PerspectiveProxy_handle, "f").uuid);
9638
+ await __classPrivateFieldGet$7(this, _PerspectiveProxy_client, "f").removeSubject(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid, ctor.builtinUri, exprAddr, batchId);
9639
+ invalidatePerspectiveCache(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid);
9065
9640
  return;
9066
9641
  }
9067
9642
  let className = await this.stringOrTemplateObjectToSubjectClassName(subjectClass);
@@ -9070,8 +9645,8 @@ class PerspectiveProxy {
9070
9645
  const shapePattern = new RegExp(`[/:#]${this.escapeRegExp(className)}Shape$`);
9071
9646
  const markers = await this.get(new LinkQuery({ predicate: "ad4m://abstract" }));
9072
9647
  if (markers.some((link) => shapePattern.test(link.data.source))) {
9073
- await __classPrivateFieldGet$6(this, _PerspectiveProxy_client, "f").removeSubject(__classPrivateFieldGet$6(this, _PerspectiveProxy_handle, "f").uuid, className, exprAddr, batchId);
9074
- invalidatePerspectiveCache(__classPrivateFieldGet$6(this, _PerspectiveProxy_handle, "f").uuid);
9648
+ await __classPrivateFieldGet$7(this, _PerspectiveProxy_client, "f").removeSubject(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid, className, exprAddr, batchId);
9649
+ invalidatePerspectiveCache(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid);
9075
9650
  return;
9076
9651
  }
9077
9652
  // Get destructor actions from SHACL links (Prolog-free)
@@ -9393,7 +9968,7 @@ class PerspectiveProxy {
9393
9968
  // Get the class name from the JS class
9394
9969
  const className = jsClass.className || jsClass.prototype?.className || jsClass.name;
9395
9970
  // Skip if already registered for this perspective instance
9396
- if (__classPrivateFieldGet$6(this, _PerspectiveProxy_ensuredSubjectClasses, "f").has(className))
9971
+ if (__classPrivateFieldGet$7(this, _PerspectiveProxy_ensuredSubjectClasses, "f").has(className))
9397
9972
  return;
9398
9973
  // Note: Duplicate checking is handled on the Rust side in add_sdna
9399
9974
  // Generate SHACL SDNA (Prolog-free)
@@ -9408,13 +9983,13 @@ class PerspectiveProxy {
9408
9983
  // Backend stores SHACL links directly
9409
9984
  await this.addSdna(className, '', 'subject_class', shaclJson);
9410
9985
  // Mark as registered for this perspective instance
9411
- __classPrivateFieldGet$6(this, _PerspectiveProxy_ensuredSubjectClasses, "f").add(className);
9986
+ __classPrivateFieldGet$7(this, _PerspectiveProxy_ensuredSubjectClasses, "f").add(className);
9412
9987
  }
9413
9988
  /** Clear the per-instance ensured subject class cache.
9414
9989
  * Call this after wiping a perspective's links so that
9415
9990
  * subsequent register() calls re-add SHACL definitions. */
9416
9991
  clearEnsuredSubjectClasses() {
9417
- __classPrivateFieldGet$6(this, _PerspectiveProxy_ensuredSubjectClasses, "f").clear();
9992
+ __classPrivateFieldGet$7(this, _PerspectiveProxy_ensuredSubjectClasses, "f").clear();
9418
9993
  }
9419
9994
  /**
9420
9995
  * Returns a list of all class names that have been registered as SHACL
@@ -9589,7 +10164,7 @@ class PerspectiveProxy {
9589
10164
  }));
9590
10165
  }
9591
10166
  getNeighbourhoodProxy() {
9592
- return __classPrivateFieldGet$6(this, _PerspectiveProxy_client, "f").getNeighbourhoodProxy(__classPrivateFieldGet$6(this, _PerspectiveProxy_handle, "f").uuid);
10167
+ return __classPrivateFieldGet$7(this, _PerspectiveProxy_client, "f").getNeighbourhoodProxy(__classPrivateFieldGet$7(this, _PerspectiveProxy_handle, "f").uuid);
9593
10168
  }
9594
10169
  /**
9595
10170
  * Returns a proxy object for working with AI capabilities.
@@ -9606,26 +10181,34 @@ class PerspectiveProxy {
9606
10181
  * ```
9607
10182
  */
9608
10183
  get ai() {
9609
- return __classPrivateFieldGet$6(this, _PerspectiveProxy_client, "f").aiClient;
10184
+ return __classPrivateFieldGet$7(this, _PerspectiveProxy_client, "f").aiClient;
9610
10185
  }
9611
10186
  /** Live SPARQL query: resolves once the first result is in.
9612
10187
  * Call `dispose()` on the returned proxy when done. The executor
9613
10188
  * refuses a Prolog query (400): Prolog live queries are not supported. */
9614
10189
  async subscribeQuery(query) {
9615
- const subscription = new QuerySubscriptionProxy(this.uuid, query, __classPrivateFieldGet$6(this, _PerspectiveProxy_client, "f"));
9616
- await subscription.subscribe();
10190
+ const subscription = new QuerySubscriptionProxy(this.uuid, query, __classPrivateFieldGet$7(this, _PerspectiveProxy_client, "f"));
10191
+ try {
10192
+ await subscription.subscribe();
10193
+ }
10194
+ catch (e) {
10195
+ // Nobody gets the proxy, so nobody can dispose it: left as is, it
10196
+ // would re-open on every reconnect and retry for good (#1595).
10197
+ subscription.dispose({ cancelOpening: true });
10198
+ throw e;
10199
+ }
9617
10200
  return subscription;
9618
10201
  }
9619
10202
  }
9620
10203
  _PerspectiveProxy_handle = new WeakMap(), _PerspectiveProxy_client = new WeakMap(), _PerspectiveProxy_releases = new WeakMap(), _PerspectiveProxy_ensuredSubjectClasses = new WeakMap(), _PerspectiveProxy_overlaysInFlight = new WeakMap();
9621
10204
 
9622
- var __classPrivateFieldSet$5 = (undefined && undefined.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
10205
+ var __classPrivateFieldSet$6 = (undefined && undefined.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
9623
10206
  if (kind === "m") throw new TypeError("Private method is not writable");
9624
10207
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
9625
10208
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
9626
10209
  return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
9627
10210
  };
9628
- var __classPrivateFieldGet$5 = (undefined && undefined.__classPrivateFieldGet) || function (receiver, state, kind, f) {
10211
+ var __classPrivateFieldGet$6 = (undefined && undefined.__classPrivateFieldGet) || function (receiver, state, kind, f) {
9629
10212
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
9630
10213
  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");
9631
10214
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
@@ -9641,27 +10224,27 @@ class PerspectiveClient {
9641
10224
  _PerspectiveClient_expressionClient.set(this, void 0);
9642
10225
  _PerspectiveClient_neighbourhoodClient.set(this, void 0);
9643
10226
  _PerspectiveClient_aiClient.set(this, void 0);
9644
- __classPrivateFieldSet$5(this, _PerspectiveClient_apiClient, sharedApiClient || new ApiClient(baseUrl, token), "f");
10227
+ __classPrivateFieldSet$6(this, _PerspectiveClient_apiClient, sharedApiClient || new ApiClient(baseUrl, token), "f");
9645
10228
  }
9646
10229
  setExpressionClient(client) {
9647
- __classPrivateFieldSet$5(this, _PerspectiveClient_expressionClient, client, "f");
10230
+ __classPrivateFieldSet$6(this, _PerspectiveClient_expressionClient, client, "f");
9648
10231
  }
9649
10232
  setNeighbourhoodClient(client) {
9650
- __classPrivateFieldSet$5(this, _PerspectiveClient_neighbourhoodClient, client, "f");
10233
+ __classPrivateFieldSet$6(this, _PerspectiveClient_neighbourhoodClient, client, "f");
9651
10234
  }
9652
10235
  setAIClient(client) {
9653
- __classPrivateFieldSet$5(this, _PerspectiveClient_aiClient, client, "f");
10236
+ __classPrivateFieldSet$6(this, _PerspectiveClient_aiClient, client, "f");
9654
10237
  }
9655
10238
  get aiClient() {
9656
- return __classPrivateFieldGet$5(this, _PerspectiveClient_aiClient, "f");
10239
+ return __classPrivateFieldGet$6(this, _PerspectiveClient_aiClient, "f");
9657
10240
  }
9658
10241
  async all() {
9659
- const perspectives = await __classPrivateFieldGet$5(this, _PerspectiveClient_apiClient, "f").call('perspective.all', {});
10242
+ const perspectives = await __classPrivateFieldGet$6(this, _PerspectiveClient_apiClient, "f").call('perspective.all', {});
9660
10243
  return perspectives.map(handle => new PerspectiveProxy(PerspectiveHandle.fromWire(handle), this));
9661
10244
  }
9662
10245
  async byUUID(uuid) {
9663
10246
  try {
9664
- const perspective = await __classPrivateFieldGet$5(this, _PerspectiveClient_apiClient, "f").call('perspective.get', { uuid });
10247
+ const perspective = await __classPrivateFieldGet$6(this, _PerspectiveClient_apiClient, "f").call('perspective.get', { uuid });
9665
10248
  if (!perspective)
9666
10249
  return null;
9667
10250
  return new PerspectiveProxy(PerspectiveHandle.fromWire(perspective), this);
@@ -9673,11 +10256,11 @@ class PerspectiveClient {
9673
10256
  }
9674
10257
  }
9675
10258
  async snapshotByUUID(uuid) {
9676
- const snapshot = await __classPrivateFieldGet$5(this, _PerspectiveClient_apiClient, "f").call('perspective.snapshot', { uuid });
10259
+ const snapshot = await __classPrivateFieldGet$6(this, _PerspectiveClient_apiClient, "f").call('perspective.snapshot', { uuid });
9677
10260
  return snapshot ? new Perspective(snapshot.links.map(LinkExpression.fromWire)) : null;
9678
10261
  }
9679
10262
  async publishSnapshotByUUID(uuid) {
9680
- return __classPrivateFieldGet$5(this, _PerspectiveClient_apiClient, "f").call('perspective.publishSnapshot', { uuid });
10263
+ return __classPrivateFieldGet$6(this, _PerspectiveClient_apiClient, "f").call('perspective.publishSnapshot', { uuid });
9681
10264
  }
9682
10265
  async queryLinks(uuid, query, options) {
9683
10266
  const params = { uuid };
@@ -9693,44 +10276,45 @@ class PerspectiveClient {
9693
10276
  params.untilDate = query.untilDate instanceof Date ? query.untilDate.toISOString() : String(query.untilDate);
9694
10277
  if (query.limit !== undefined)
9695
10278
  params.limit = query.limit;
9696
- const links = await __classPrivateFieldGet$5(this, _PerspectiveClient_apiClient, "f").call('perspective.queryLinks', params, options);
10279
+ const links = await __classPrivateFieldGet$6(this, _PerspectiveClient_apiClient, "f").call('perspective.queryLinks', params, options);
9697
10280
  return links.map(LinkExpression.fromWire);
9698
10281
  }
9699
10282
  async queryProlog(uuid, query, options) {
9700
- const result = await __classPrivateFieldGet$5(this, _PerspectiveClient_apiClient, "f").call('perspective.queryProlog', { uuid, query }, options);
10283
+ const result = await __classPrivateFieldGet$6(this, _PerspectiveClient_apiClient, "f").call('perspective.queryProlog', { uuid, query }, options);
9701
10284
  return JSON.parse(result);
9702
10285
  }
9703
10286
  async querySparql(uuid, query, options) {
9704
- const result = await __classPrivateFieldGet$5(this, _PerspectiveClient_apiClient, "f").call('perspective.querySparql', { uuid, engine: 'sparql', query }, options);
10287
+ const result = await __classPrivateFieldGet$6(this, _PerspectiveClient_apiClient, "f").call('perspective.querySparql', { uuid, engine: 'sparql', query }, options);
9705
10288
  return JSON.parse(result);
9706
10289
  }
9707
10290
  /** Open a live SPARQL query. Updates arrive through {@link onQueryUpdate}. */
9708
- async subscribeQuery(uuid, query) {
9709
- return __classPrivateFieldGet$5(this, _PerspectiveClient_apiClient, "f").call('perspective.subscribeQuery', { uuid, query });
10291
+ /** `options.signal` cancels the call, and the executor stops computing the first result. */
10292
+ async subscribeQuery(uuid, query, options) {
10293
+ return __classPrivateFieldGet$6(this, _PerspectiveClient_apiClient, "f").call('perspective.subscribeQuery', { uuid, query }, options);
9710
10294
  }
9711
10295
  /** Every `query-subscription-update` event on this client's socket. */
9712
10296
  onQueryUpdate(cb) {
9713
- return __classPrivateFieldGet$5(this, _PerspectiveClient_apiClient, "f").on('query-subscription-update', cb);
10297
+ return __classPrivateFieldGet$6(this, _PerspectiveClient_apiClient, "f").on('query-subscription-update', cb);
9714
10298
  }
9715
10299
  /** The current result and revision of a live query, after a revision gap. */
9716
10300
  async resyncSubscription(uuid, subscriptionId) {
9717
- return __classPrivateFieldGet$5(this, _PerspectiveClient_apiClient, "f").call('perspective.resyncSubscription', { uuid, subscriptionId });
10301
+ return __classPrivateFieldGet$6(this, _PerspectiveClient_apiClient, "f").call('perspective.resyncSubscription', { uuid, subscriptionId });
9718
10302
  }
9719
10303
  /** Ends the subscription on the executor. The caller releases its local listener
9720
10304
  * with the function {@link onQueryUpdate} returned. */
9721
10305
  async disposeQuerySubscription(uuid, subscriptionId) {
9722
- return __classPrivateFieldGet$5(this, _PerspectiveClient_apiClient, "f").call('perspective.disposeQuery', { uuid, subscriptionId });
10306
+ return __classPrivateFieldGet$6(this, _PerspectiveClient_apiClient, "f").call('perspective.disposeQuery', { uuid, subscriptionId });
9723
10307
  }
9724
10308
  /** `className` may name several classes: one query over their union (#1238). */
9725
10309
  async modelQuery(uuid, className, queryJson, options) {
9726
- const resultJson = await __classPrivateFieldGet$5(this, _PerspectiveClient_apiClient, "f").call('perspective.modelQuery', { uuid, ...classParams(className), query_json: queryJson }, options);
10310
+ const resultJson = await __classPrivateFieldGet$6(this, _PerspectiveClient_apiClient, "f").call('perspective.modelQuery', { uuid, ...classParams(className), query_json: queryJson }, options);
9727
10311
  return JSON.parse(resultJson);
9728
10312
  }
9729
10313
  async subjectClassesOf(uuid, uris) {
9730
- return await __classPrivateFieldGet$5(this, _PerspectiveClient_apiClient, "f").call('perspective.subjectClassesOf', { uuid, uris });
10314
+ return await __classPrivateFieldGet$6(this, _PerspectiveClient_apiClient, "f").call('perspective.subjectClassesOf', { uuid, uris });
9731
10315
  }
9732
10316
  async evaluateGetters(uuid, className, instanceIds, propertyNames) {
9733
- const resultJson = await __classPrivateFieldGet$5(this, _PerspectiveClient_apiClient, "f").call('perspective.evaluateGetters', {
10317
+ const resultJson = await __classPrivateFieldGet$6(this, _PerspectiveClient_apiClient, "f").call('perspective.evaluateGetters', {
9734
10318
  uuid,
9735
10319
  class_name: className,
9736
10320
  instance_ids: instanceIds,
@@ -9739,35 +10323,36 @@ class PerspectiveClient {
9739
10323
  return JSON.parse(resultJson);
9740
10324
  }
9741
10325
  /** Open a live model query over one class or several. Updates arrive through {@link onQueryUpdate}. */
9742
- async modelSubscribe(uuid, className, queryJson) {
9743
- return __classPrivateFieldGet$5(this, _PerspectiveClient_apiClient, "f").call('perspective.modelSubscribe', { uuid, ...classParams(className), query_json: queryJson });
10326
+ /** `options.signal` cancels the call, and the executor stops computing the first result. */
10327
+ async modelSubscribe(uuid, className, queryJson, options) {
10328
+ return __classPrivateFieldGet$6(this, _PerspectiveClient_apiClient, "f").call('perspective.modelSubscribe', { uuid, ...classParams(className), query_json: queryJson }, options);
9744
10329
  }
9745
10330
  async add(name) {
9746
- const handle = await __classPrivateFieldGet$5(this, _PerspectiveClient_apiClient, "f").call('perspective.create', { name });
10331
+ const handle = await __classPrivateFieldGet$6(this, _PerspectiveClient_apiClient, "f").call('perspective.create', { name });
9747
10332
  return new PerspectiveProxy(PerspectiveHandle.fromWire(handle), this);
9748
10333
  }
9749
10334
  async update(uuid, name) {
9750
- const handle = await __classPrivateFieldGet$5(this, _PerspectiveClient_apiClient, "f").call('perspective.update', { uuid, name });
10335
+ const handle = await __classPrivateFieldGet$6(this, _PerspectiveClient_apiClient, "f").call('perspective.update', { uuid, name });
9751
10336
  return new PerspectiveProxy(PerspectiveHandle.fromWire(handle), this);
9752
10337
  }
9753
10338
  async remove(uuid) {
9754
- const result = await __classPrivateFieldGet$5(this, _PerspectiveClient_apiClient, "f").call('perspective.remove', { uuid });
10339
+ const result = await __classPrivateFieldGet$6(this, _PerspectiveClient_apiClient, "f").call('perspective.remove', { uuid });
9755
10340
  return { perspectiveRemove: result };
9756
10341
  }
9757
10342
  async addLink(uuid, link, status = 'shared', batchId) {
9758
- const added = await __classPrivateFieldGet$5(this, _PerspectiveClient_apiClient, "f").call('perspective.addLink', { uuid, link, status, batchId });
10343
+ const added = await __classPrivateFieldGet$6(this, _PerspectiveClient_apiClient, "f").call('perspective.addLink', { uuid, link, status, batchId });
9759
10344
  return LinkExpression.fromWire(added);
9760
10345
  }
9761
10346
  async addLinks(uuid, links, status = 'shared', batchId) {
9762
- const added = await __classPrivateFieldGet$5(this, _PerspectiveClient_apiClient, "f").call('perspective.addLinks', { uuid, links, status, batchId });
10347
+ const added = await __classPrivateFieldGet$6(this, _PerspectiveClient_apiClient, "f").call('perspective.addLinks', { uuid, links, status, batchId });
9763
10348
  return added.map(LinkExpression.fromWire);
9764
10349
  }
9765
10350
  async removeLinks(uuid, links, batchId) {
9766
- const removed = await __classPrivateFieldGet$5(this, _PerspectiveClient_apiClient, "f").call('perspective.removeLinks', { uuid, links: links.map(linkExpressionInputToWire), batchId });
10351
+ const removed = await __classPrivateFieldGet$6(this, _PerspectiveClient_apiClient, "f").call('perspective.removeLinks', { uuid, links: links.map(linkExpressionInputToWire), batchId });
9767
10352
  return removed.map(LinkExpression.fromWire);
9768
10353
  }
9769
10354
  async linkMutations(uuid, mutations, status) {
9770
- const diff = await __classPrivateFieldGet$5(this, _PerspectiveClient_apiClient, "f").call('perspective.linkMutations', { uuid, mutations: linkMutationsToWire(mutations), status });
10355
+ const diff = await __classPrivateFieldGet$6(this, _PerspectiveClient_apiClient, "f").call('perspective.linkMutations', { uuid, mutations: linkMutationsToWire(mutations), status });
9771
10356
  return LinkExpressionMutations.fromWire(diff);
9772
10357
  }
9773
10358
  /**
@@ -9787,7 +10372,7 @@ class PerspectiveClient {
9787
10372
  * are NOT re-parented — same rule as the watcher).
9788
10373
  */
9789
10374
  async runInterpretation(uuid, transcript, basePrefix, classes, existingScope, mintScope, observe, options) {
9790
- return __classPrivateFieldGet$5(this, _PerspectiveClient_apiClient, "f").call('perspective.runInterpretation', {
10375
+ return __classPrivateFieldGet$6(this, _PerspectiveClient_apiClient, "f").call('perspective.runInterpretation', {
9791
10376
  uuid, transcript, basePrefix, classes, existingScope, mintScope,
9792
10377
  observationId: observe?.observationId,
9793
10378
  emitDebugEvents: observe?.emitDebugEvents,
@@ -9814,7 +10399,7 @@ class PerspectiveClient {
9814
10399
  // `emitDebugEvents` is a dead-letter without an observationId
9815
10400
  // (nothing to key against); the server gates on both.
9816
10401
  observationId, emitDebugEvents, options) {
9817
- return __classPrivateFieldGet$5(this, _PerspectiveClient_apiClient, "f").call('perspective.runInterpretationWithHarness', {
10402
+ return __classPrivateFieldGet$6(this, _PerspectiveClient_apiClient, "f").call('perspective.runInterpretationWithHarness', {
9818
10403
  uuid,
9819
10404
  transcript,
9820
10405
  basePrefix,
@@ -9837,7 +10422,7 @@ class PerspectiveClient {
9837
10422
  * calls before it answers.
9838
10423
  */
9839
10424
  async runAgent(uuid, messages, settings, options) {
9840
- return __classPrivateFieldGet$5(this, _PerspectiveClient_apiClient, "f").call('perspective.runAgent', { uuid, messages, ...settings }, options);
10425
+ return __classPrivateFieldGet$6(this, _PerspectiveClient_apiClient, "f").call('perspective.runAgent', { uuid, messages, ...settings }, options);
9841
10426
  }
9842
10427
  /**
9843
10428
  * Register a neighbourhood auto-processor on this perspective. The executor's
@@ -9848,15 +10433,15 @@ class PerspectiveClient {
9848
10433
  * Returns the processor id.
9849
10434
  */
9850
10435
  async addAutoProcessor(uuid, config) {
9851
- return __classPrivateFieldGet$5(this, _PerspectiveClient_apiClient, "f").call('perspective.addAutoProcessor', { ...config, uuid });
10436
+ return __classPrivateFieldGet$6(this, _PerspectiveClient_apiClient, "f").call('perspective.addAutoProcessor', { ...config, uuid });
9852
10437
  }
9853
10438
  /** Delete an auto-processor's config. `false` when there was none to delete. */
9854
10439
  async removeAutoProcessor(uuid, processorId) {
9855
- return __classPrivateFieldGet$5(this, _PerspectiveClient_apiClient, "f").call('perspective.removeAutoProcessor', { uuid, processorId });
10440
+ return __classPrivateFieldGet$6(this, _PerspectiveClient_apiClient, "f").call('perspective.removeAutoProcessor', { uuid, processorId });
9856
10441
  }
9857
10442
  /** Pending interpretation overlays (LLM suggestions awaiting human accept/reject). */
9858
10443
  async interpretationOverlays(uuid) {
9859
- const overlays = await __classPrivateFieldGet$5(this, _PerspectiveClient_apiClient, "f").call('perspective.interpretationOverlays', { uuid });
10444
+ const overlays = await __classPrivateFieldGet$6(this, _PerspectiveClient_apiClient, "f").call('perspective.interpretationOverlays', { uuid });
9860
10445
  return overlays.map(({ base, kind, run, inferred }) => ({
9861
10446
  base, run, inferred, kind: kind === 'create' ? 'create' : 'update',
9862
10447
  }));
@@ -9864,18 +10449,18 @@ class PerspectiveClient {
9864
10449
  /** Accept an overlay's suggestion(s): the LLM value becomes the real value and
9865
10450
  * the overlay is deleted. Omit `property` to accept the whole base. */
9866
10451
  async acceptInterpretation(uuid, base, property) {
9867
- return __classPrivateFieldGet$5(this, _PerspectiveClient_apiClient, "f").call('perspective.acceptInterpretation', { uuid, base, property });
10452
+ return __classPrivateFieldGet$6(this, _PerspectiveClient_apiClient, "f").call('perspective.acceptInterpretation', { uuid, base, property });
9868
10453
  }
9869
10454
  /** Reject an overlay's suggestion(s). Omit `property` to reject the whole base
9870
10455
  * (a rejected `create` deletes the suggested instance). */
9871
10456
  async rejectInterpretation(uuid, base, property) {
9872
- return __classPrivateFieldGet$5(this, _PerspectiveClient_apiClient, "f").call('perspective.rejectInterpretation', { uuid, base, property });
10457
+ return __classPrivateFieldGet$6(this, _PerspectiveClient_apiClient, "f").call('perspective.rejectInterpretation', { uuid, base, property });
9873
10458
  }
9874
10459
  async proposeFlowTransition(uuid, instanceUri, toState, rationale, outputs) {
9875
- return __classPrivateFieldGet$5(this, _PerspectiveClient_apiClient, "f").call('perspective.proposeFlowTransition', { uuid, instanceUri, toState, rationale, outputs });
10460
+ return __classPrivateFieldGet$6(this, _PerspectiveClient_apiClient, "f").call('perspective.proposeFlowTransition', { uuid, instanceUri, toState, rationale, outputs });
9876
10461
  }
9877
10462
  async acceptFlowProposal(uuid, proposalUri) {
9878
- return __classPrivateFieldGet$5(this, _PerspectiveClient_apiClient, "f").call('perspective.acceptFlowProposal', { uuid, proposalUri });
10463
+ return __classPrivateFieldGet$6(this, _PerspectiveClient_apiClient, "f").call('perspective.acceptFlowProposal', { uuid, proposalUri });
9879
10464
  }
9880
10465
  /**
9881
10466
  * Withdraw this agent's own links from a proposal. Resolves to how many
@@ -9883,69 +10468,69 @@ class PerspectiveClient {
9883
10468
  * proposal this agent opened.
9884
10469
  */
9885
10470
  async rejectFlowProposal(uuid, proposalUri) {
9886
- const result = await __classPrivateFieldGet$5(this, _PerspectiveClient_apiClient, "f").call('perspective.rejectFlowProposal', { uuid, proposalUri });
10471
+ const result = await __classPrivateFieldGet$6(this, _PerspectiveClient_apiClient, "f").call('perspective.rejectFlowProposal', { uuid, proposalUri });
9887
10472
  return result.retractedLinks;
9888
10473
  }
9889
10474
  /** Re-decide a flow receipt under this perspective's own flow catalogue. */
9890
10475
  async verifyFlowReceipt(uuid, receipt) {
9891
- return __classPrivateFieldGet$5(this, _PerspectiveClient_apiClient, "f").call('perspective.verifyFlowReceipt', { uuid, receipt });
10476
+ return __classPrivateFieldGet$6(this, _PerspectiveClient_apiClient, "f").call('perspective.verifyFlowReceipt', { uuid, receipt });
9892
10477
  }
9893
10478
  /** The instances that are, as they stand, valid outputs of `flow`
9894
10479
  * (optionally: of runs settled into terminal state `state`). */
9895
10480
  async flowValidOutputs(uuid, flow, state) {
9896
- return __classPrivateFieldGet$5(this, _PerspectiveClient_apiClient, "f").call('perspective.flowValidOutputs', { uuid, flow, state });
10481
+ return __classPrivateFieldGet$6(this, _PerspectiveClient_apiClient, "f").call('perspective.flowValidOutputs', { uuid, flow, state });
9897
10482
  }
9898
10483
  /** The calling agent's recorded state of each flow instance it has
9899
10484
  * derived, optionally narrowed to `instances`. */
9900
10485
  async flowStates(uuid, instances) {
9901
- return __classPrivateFieldGet$5(this, _PerspectiveClient_apiClient, "f").call('perspective.flowStates', { uuid, instances });
10486
+ return __classPrivateFieldGet$6(this, _PerspectiveClient_apiClient, "f").call('perspective.flowStates', { uuid, instances });
9902
10487
  }
9903
10488
  /** The proposals of `instance` the calling agent's replica recorded as
9904
10489
  * fired, sorted. */
9905
10490
  async flowFired(uuid, instance) {
9906
- return __classPrivateFieldGet$5(this, _PerspectiveClient_apiClient, "f").call('perspective.flowFired', { uuid, instance });
10491
+ return __classPrivateFieldGet$6(this, _PerspectiveClient_apiClient, "f").call('perspective.flowFired', { uuid, instance });
9907
10492
  }
9908
10493
  /** Mint and store the receipt for a completed flow run. Fails while the
9909
10494
  * run has not settled into a terminal state, and when an output's
9910
10495
  * content no longer matches what the quorum committed to. */
9911
10496
  async mintFlowReceipt(uuid, instanceUri) {
9912
- return __classPrivateFieldGet$5(this, _PerspectiveClient_apiClient, "f").call('perspective.mintFlowReceipt', { uuid, instanceUri });
10497
+ return __classPrivateFieldGet$6(this, _PerspectiveClient_apiClient, "f").call('perspective.mintFlowReceipt', { uuid, instanceUri });
9913
10498
  }
9914
10499
  async addLinkExpression(uuid, link, status = 'shared', batchId) {
9915
- const added = await __classPrivateFieldGet$5(this, _PerspectiveClient_apiClient, "f").call('perspective.addLinkExpression', { uuid, link: linkExpressionToWire(link), status, batchId });
10500
+ const added = await __classPrivateFieldGet$6(this, _PerspectiveClient_apiClient, "f").call('perspective.addLinkExpression', { uuid, link: linkExpressionToWire(link), status, batchId });
9916
10501
  return LinkExpression.fromWire(added);
9917
10502
  }
9918
10503
  async updateLink(uuid, oldLink, newLink, batchId) {
9919
- const updated = await __classPrivateFieldGet$5(this, _PerspectiveClient_apiClient, "f").call('perspective.updateLink', { uuid, oldLink: linkExpressionInputToWire(oldLink), newLink, batchId });
10504
+ const updated = await __classPrivateFieldGet$6(this, _PerspectiveClient_apiClient, "f").call('perspective.updateLink', { uuid, oldLink: linkExpressionInputToWire(oldLink), newLink, batchId });
9920
10505
  return LinkExpression.fromWire(updated);
9921
10506
  }
9922
10507
  async removeLink(uuid, link, batchId) {
9923
10508
  const { status, ...wire } = linkExpressionInputToWire(link);
9924
- return __classPrivateFieldGet$5(this, _PerspectiveClient_apiClient, "f").call('perspective.removeLink', { uuid, link: wire, batchId });
10509
+ return __classPrivateFieldGet$6(this, _PerspectiveClient_apiClient, "f").call('perspective.removeLink', { uuid, link: wire, batchId });
9925
10510
  }
9926
10511
  async addSdna(uuid, name, sdnaCode, sdnaType, shaclJson) {
9927
- const result = await __classPrivateFieldGet$5(this, _PerspectiveClient_apiClient, "f").call('perspective.addSdna', { uuid, name, sdnaCode: sdnaCode || "", sdnaType, shaclJson });
10512
+ const result = await __classPrivateFieldGet$6(this, _PerspectiveClient_apiClient, "f").call('perspective.addSdna', { uuid, name, sdnaCode: sdnaCode || "", sdnaType, shaclJson });
9928
10513
  return typeof result === 'boolean' ? result : result.every(Boolean);
9929
10514
  }
9930
10515
  async addSdnaBatch(uuid, entries) {
9931
- const result = await __classPrivateFieldGet$5(this, _PerspectiveClient_apiClient, "f").call('perspective.addSdna', { uuid, entries: entries.map(e => ({ ...e, sdnaCode: e.sdnaCode || "" })) });
10516
+ const result = await __classPrivateFieldGet$6(this, _PerspectiveClient_apiClient, "f").call('perspective.addSdna', { uuid, entries: entries.map(e => ({ ...e, sdnaCode: e.sdnaCode || "" })) });
9932
10517
  return typeof result === 'boolean' ? [result] : result;
9933
10518
  }
9934
10519
  async executeCommands(uuid, commands, expression, parameters, batchId) {
9935
- return __classPrivateFieldGet$5(this, _PerspectiveClient_apiClient, "f").call('perspective.executeCommands', { uuid, commands, expression, parameters, batchId });
10520
+ return __classPrivateFieldGet$6(this, _PerspectiveClient_apiClient, "f").call('perspective.executeCommands', { uuid, commands, expression, parameters, batchId });
9936
10521
  }
9937
10522
  async createSubject(uuid, subjectClass, expressionAddress, initialValues, batchId) {
9938
- return __classPrivateFieldGet$5(this, _PerspectiveClient_apiClient, "f").call('perspective.createSubject', { uuid, subjectClass, expressionAddress, initialValues, batchId });
10523
+ return __classPrivateFieldGet$6(this, _PerspectiveClient_apiClient, "f").call('perspective.createSubject', { uuid, subjectClass, expressionAddress, initialValues, batchId });
9939
10524
  }
9940
10525
  /** Through an abstract class (#1435), the executor writes to the record's own classes. */
9941
10526
  async updateSubject(uuid, subjectClass, expressionAddress, values, batchId) {
9942
- return __classPrivateFieldGet$5(this, _PerspectiveClient_apiClient, "f").call('perspective.updateSubject', { uuid, subjectClass, expressionAddress, values, batchId });
10527
+ return __classPrivateFieldGet$6(this, _PerspectiveClient_apiClient, "f").call('perspective.updateSubject', { uuid, subjectClass, expressionAddress, values, batchId });
9943
10528
  }
9944
10529
  async removeSubject(uuid, subjectClass, expressionAddress, batchId) {
9945
- return __classPrivateFieldGet$5(this, _PerspectiveClient_apiClient, "f").call('perspective.removeSubject', { uuid, subjectClass, expressionAddress, batchId });
10530
+ return __classPrivateFieldGet$6(this, _PerspectiveClient_apiClient, "f").call('perspective.removeSubject', { uuid, subjectClass, expressionAddress, batchId });
9946
10531
  }
9947
10532
  async getSubjectData(uuid, subjectClass, expressionAddress) {
9948
- return __classPrivateFieldGet$5(this, _PerspectiveClient_apiClient, "f").call('perspective.getSubjectData', { uuid, subjectClass, expressionAddress });
10533
+ return __classPrivateFieldGet$6(this, _PerspectiveClient_apiClient, "f").call('perspective.getSubjectData', { uuid, subjectClass, expressionAddress });
9949
10534
  }
9950
10535
  // ── SHACL resolution (server-side) ─────────────────────────────────────────
9951
10536
  // These methods delegate shape resolution to the executor, which reads links
@@ -9953,7 +10538,7 @@ class PerspectiveClient {
9953
10538
  // `queryLinks` sequences the old PerspectiveProxy methods performed.
9954
10539
  /** List the names of every SHACL shape stored in a perspective (one RPC call). */
9955
10540
  async getShaclNames(uuid) {
9956
- return __classPrivateFieldGet$5(this, _PerspectiveClient_apiClient, "f").call('perspective.getShaclNames', { uuid });
10541
+ return __classPrivateFieldGet$6(this, _PerspectiveClient_apiClient, "f").call('perspective.getShaclNames', { uuid });
9957
10542
  }
9958
10543
  /**
9959
10544
  * Resolve a shape's `sh:targetClass` by name (one RPC call).
@@ -9966,7 +10551,7 @@ class PerspectiveClient {
9966
10551
  * than pushing the null one layer further up. PR #935 review r3897752023.
9967
10552
  */
9968
10553
  async getShaclTargetClass(uuid, name) {
9969
- const result = await __classPrivateFieldGet$5(this, _PerspectiveClient_apiClient, "f").call('perspective.getShaclTargetClass', { uuid, name });
10554
+ const result = await __classPrivateFieldGet$6(this, _PerspectiveClient_apiClient, "f").call('perspective.getShaclTargetClass', { uuid, name });
9970
10555
  return result ?? undefined;
9971
10556
  }
9972
10557
  /**
@@ -9975,51 +10560,51 @@ class PerspectiveClient {
9975
10560
  * or `null` if no shape with that name exists.
9976
10561
  */
9977
10562
  async getShacl(uuid, name) {
9978
- return __classPrivateFieldGet$5(this, _PerspectiveClient_apiClient, "f").call('perspective.getShacl', { uuid, name });
10563
+ return __classPrivateFieldGet$6(this, _PerspectiveClient_apiClient, "f").call('perspective.getShacl', { uuid, name });
9979
10564
  }
9980
10565
  /**
9981
10566
  * Retrieve all SHACL shapes in one call. Returns an array of
9982
10567
  * `{name, shapeUri, links}` — one entry per shape (one RPC call).
9983
10568
  */
9984
10569
  async getAllShacl(uuid) {
9985
- return __classPrivateFieldGet$5(this, _PerspectiveClient_apiClient, "f").call('perspective.getAllShacl', { uuid });
10570
+ return __classPrivateFieldGet$6(this, _PerspectiveClient_apiClient, "f").call('perspective.getAllShacl', { uuid });
9986
10571
  }
9987
10572
  // ExpressionClient functions, needed for Subjects:
9988
10573
  async getExpression(expressionURI) {
9989
- return await __classPrivateFieldGet$5(this, _PerspectiveClient_expressionClient, "f").get(expressionURI);
10574
+ return await __classPrivateFieldGet$6(this, _PerspectiveClient_expressionClient, "f").get(expressionURI);
9990
10575
  }
9991
10576
  async createExpression(content, languageAddress) {
9992
- return await __classPrivateFieldGet$5(this, _PerspectiveClient_expressionClient, "f").create(content, languageAddress);
10577
+ return await __classPrivateFieldGet$6(this, _PerspectiveClient_expressionClient, "f").create(content, languageAddress);
9993
10578
  }
9994
10579
  /** The client's event bus; see {@link ApiClient.on}. */
9995
10580
  on(type, handler, filter) {
9996
- return __classPrivateFieldGet$5(this, _PerspectiveClient_apiClient, "f").on(type, handler, filter);
10581
+ return __classPrivateFieldGet$6(this, _PerspectiveClient_apiClient, "f").on(type, handler, filter);
9997
10582
  }
9998
10583
  getNeighbourhoodProxy(uuid) {
9999
- return new NeighbourhoodProxy(__classPrivateFieldGet$5(this, _PerspectiveClient_neighbourhoodClient, "f"), uuid);
10584
+ return new NeighbourhoodProxy(__classPrivateFieldGet$6(this, _PerspectiveClient_neighbourhoodClient, "f"), uuid);
10000
10585
  }
10001
10586
  async createBatch(uuid) {
10002
- return __classPrivateFieldGet$5(this, _PerspectiveClient_apiClient, "f").call('perspective.createBatch', { uuid });
10587
+ return __classPrivateFieldGet$6(this, _PerspectiveClient_apiClient, "f").call('perspective.createBatch', { uuid });
10003
10588
  }
10004
10589
  async commitBatch(uuid, batchId) {
10005
- const diff = await __classPrivateFieldGet$5(this, _PerspectiveClient_apiClient, "f").call('perspective.commitBatch', { uuid, batchId });
10590
+ const diff = await __classPrivateFieldGet$6(this, _PerspectiveClient_apiClient, "f").call('perspective.commitBatch', { uuid, batchId });
10006
10591
  return LinkExpressionMutations.fromWire(diff);
10007
10592
  }
10008
10593
  /** Register a callback that fires after a successful WebSocket reconnect.
10009
10594
  * Passes through to ApiClient.onReconnect(). Returns an unsubscribe function. */
10010
10595
  onReconnect(callback) {
10011
- return __classPrivateFieldGet$5(this, _PerspectiveClient_apiClient, "f").onReconnect(callback);
10596
+ return __classPrivateFieldGet$6(this, _PerspectiveClient_apiClient, "f").onReconnect(callback);
10012
10597
  }
10013
10598
  }
10014
10599
  _PerspectiveClient_apiClient = new WeakMap(), _PerspectiveClient_expressionClient = new WeakMap(), _PerspectiveClient_neighbourhoodClient = new WeakMap(), _PerspectiveClient_aiClient = new WeakMap();
10015
10600
 
10016
- var __classPrivateFieldSet$4 = (undefined && undefined.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
10601
+ var __classPrivateFieldSet$5 = (undefined && undefined.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
10017
10602
  if (kind === "m") throw new TypeError("Private method is not writable");
10018
10603
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
10019
10604
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
10020
10605
  return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
10021
10606
  };
10022
- var __classPrivateFieldGet$4 = (undefined && undefined.__classPrivateFieldGet) || function (receiver, state, kind, f) {
10607
+ var __classPrivateFieldGet$5 = (undefined && undefined.__classPrivateFieldGet) || function (receiver, state, kind, f) {
10023
10608
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
10024
10609
  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");
10025
10610
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
@@ -10028,197 +10613,197 @@ var _RuntimeClient_apiClient;
10028
10613
  class RuntimeClient {
10029
10614
  constructor(baseUrl, token, sharedApiClient) {
10030
10615
  _RuntimeClient_apiClient.set(this, void 0);
10031
- __classPrivateFieldSet$4(this, _RuntimeClient_apiClient, sharedApiClient || new ApiClient(baseUrl, token), "f");
10616
+ __classPrivateFieldSet$5(this, _RuntimeClient_apiClient, sharedApiClient || new ApiClient(baseUrl, token), "f");
10032
10617
  }
10033
10618
  async info() {
10034
- return __classPrivateFieldGet$4(this, _RuntimeClient_apiClient, "f").call('runtime.info', {});
10619
+ return __classPrivateFieldGet$5(this, _RuntimeClient_apiClient, "f").call('runtime.info', {});
10035
10620
  }
10036
10621
  async tlsDomain() {
10037
- return __classPrivateFieldGet$4(this, _RuntimeClient_apiClient, "f").call('runtime.tlsDomain', {});
10622
+ return __classPrivateFieldGet$5(this, _RuntimeClient_apiClient, "f").call('runtime.tlsDomain', {});
10038
10623
  }
10039
10624
  async quit() {
10040
- return __classPrivateFieldGet$4(this, _RuntimeClient_apiClient, "f").call('runtime.quit', {});
10625
+ return __classPrivateFieldGet$5(this, _RuntimeClient_apiClient, "f").call('runtime.quit', {});
10041
10626
  }
10042
10627
  async openLink(url) {
10043
- return __classPrivateFieldGet$4(this, _RuntimeClient_apiClient, "f").call('runtime.openLink', { url });
10628
+ return __classPrivateFieldGet$5(this, _RuntimeClient_apiClient, "f").call('runtime.openLink', { url });
10044
10629
  }
10045
10630
  async addTrustedAgents(agents) {
10046
- return __classPrivateFieldGet$4(this, _RuntimeClient_apiClient, "f").call('agent.addTrustedAgents', { agents });
10631
+ return __classPrivateFieldGet$5(this, _RuntimeClient_apiClient, "f").call('agent.addTrustedAgents', { agents });
10047
10632
  }
10048
10633
  async deleteTrustedAgents(agents) {
10049
- return __classPrivateFieldGet$4(this, _RuntimeClient_apiClient, "f").call('agent.deleteTrustedAgents', { agents });
10634
+ return __classPrivateFieldGet$5(this, _RuntimeClient_apiClient, "f").call('agent.deleteTrustedAgents', { agents });
10050
10635
  }
10051
10636
  async getTrustedAgents() {
10052
- return __classPrivateFieldGet$4(this, _RuntimeClient_apiClient, "f").call('agent.getTrustedAgents', {});
10637
+ return __classPrivateFieldGet$5(this, _RuntimeClient_apiClient, "f").call('agent.getTrustedAgents', {});
10053
10638
  }
10054
10639
  async addKnownLinkLanguageTemplates(addresses) {
10055
- return __classPrivateFieldGet$4(this, _RuntimeClient_apiClient, "f").call('runtime.addLinkLanguageTemplates', { addresses });
10640
+ return __classPrivateFieldGet$5(this, _RuntimeClient_apiClient, "f").call('runtime.addLinkLanguageTemplates', { addresses });
10056
10641
  }
10057
10642
  async removeKnownLinkLanguageTemplates(addresses) {
10058
- return __classPrivateFieldGet$4(this, _RuntimeClient_apiClient, "f").call('runtime.removeLinkLanguageTemplates', { addresses });
10643
+ return __classPrivateFieldGet$5(this, _RuntimeClient_apiClient, "f").call('runtime.removeLinkLanguageTemplates', { addresses });
10059
10644
  }
10060
10645
  /** Every link-language template the executor knows, with its meta (name, description,
10061
10646
  * `possibleTemplateParams`). A template whose meta cannot be read is left out. */
10062
10647
  async knownLinkLanguageTemplates() {
10063
- return __classPrivateFieldGet$4(this, _RuntimeClient_apiClient, "f").call('runtime.linkLanguageTemplates', {});
10648
+ return __classPrivateFieldGet$5(this, _RuntimeClient_apiClient, "f").call('runtime.linkLanguageTemplates', {});
10064
10649
  }
10065
10650
  async addFriends(dids) {
10066
- return __classPrivateFieldGet$4(this, _RuntimeClient_apiClient, "f").call('runtime.addFriends', { dids });
10651
+ return __classPrivateFieldGet$5(this, _RuntimeClient_apiClient, "f").call('runtime.addFriends', { dids });
10067
10652
  }
10068
10653
  async removeFriends(dids) {
10069
- return __classPrivateFieldGet$4(this, _RuntimeClient_apiClient, "f").call('runtime.removeFriends', { dids });
10654
+ return __classPrivateFieldGet$5(this, _RuntimeClient_apiClient, "f").call('runtime.removeFriends', { dids });
10070
10655
  }
10071
10656
  async friends() {
10072
- return __classPrivateFieldGet$4(this, _RuntimeClient_apiClient, "f").call('runtime.friends', {});
10657
+ return __classPrivateFieldGet$5(this, _RuntimeClient_apiClient, "f").call('runtime.friends', {});
10073
10658
  }
10074
10659
  async hcAgentInfos() {
10075
- return __classPrivateFieldGet$4(this, _RuntimeClient_apiClient, "f").call('runtime.hcAgentInfos', {});
10660
+ return __classPrivateFieldGet$5(this, _RuntimeClient_apiClient, "f").call('runtime.hcAgentInfos', {});
10076
10661
  }
10077
10662
  async getNetworkMetrics() {
10078
- return __classPrivateFieldGet$4(this, _RuntimeClient_apiClient, "f").call('runtime.networkMetrics', {});
10663
+ return __classPrivateFieldGet$5(this, _RuntimeClient_apiClient, "f").call('runtime.networkMetrics', {});
10079
10664
  }
10080
10665
  async restartHolochain(options) {
10081
- return __classPrivateFieldGet$4(this, _RuntimeClient_apiClient, "f").call('runtime.restartHolochain', {}, options);
10666
+ return __classPrivateFieldGet$5(this, _RuntimeClient_apiClient, "f").call('runtime.restartHolochain', {}, options);
10082
10667
  }
10083
10668
  async hcAddAgentInfos(agentInfos) {
10084
- return __classPrivateFieldGet$4(this, _RuntimeClient_apiClient, "f").call('runtime.addHcAgentInfos', { agentInfos });
10669
+ return __classPrivateFieldGet$5(this, _RuntimeClient_apiClient, "f").call('runtime.addHcAgentInfos', { agentInfos });
10085
10670
  }
10086
10671
  async verifyStringSignedByDid(did, didSigningKeyId, data, signedData) {
10087
10672
  // The executor resolves the key from the DID document; `didSigningKeyId` goes unused.
10088
- return __classPrivateFieldGet$4(this, _RuntimeClient_apiClient, "f").call('runtime.verifySignature', { did, data, signedData });
10673
+ return __classPrivateFieldGet$5(this, _RuntimeClient_apiClient, "f").call('runtime.verifySignature', { did, data, signedData });
10089
10674
  }
10090
10675
  async setStatus(perspective) {
10091
- return __classPrivateFieldGet$4(this, _RuntimeClient_apiClient, "f").call('runtime.setStatus', { status: Perspective.toWire(perspective) });
10676
+ return __classPrivateFieldGet$5(this, _RuntimeClient_apiClient, "f").call('runtime.setStatus', { status: Perspective.toWire(perspective) });
10092
10677
  }
10093
10678
  async friendStatus(did) {
10094
- const status = await __classPrivateFieldGet$4(this, _RuntimeClient_apiClient, "f").call('runtime.friendStatus', { did });
10679
+ const status = await __classPrivateFieldGet$5(this, _RuntimeClient_apiClient, "f").call('runtime.friendStatus', { did });
10095
10680
  return status ? PerspectiveExpression.fromWire(status) : null;
10096
10681
  }
10097
10682
  async friendSendMessage(did, message) {
10098
- return __classPrivateFieldGet$4(this, _RuntimeClient_apiClient, "f").call('runtime.sendFriendMessage', { did, message: Perspective.toWire(message) });
10683
+ return __classPrivateFieldGet$5(this, _RuntimeClient_apiClient, "f").call('runtime.sendFriendMessage', { did, message: Perspective.toWire(message) });
10099
10684
  }
10100
10685
  async messageInbox() {
10101
- return (await __classPrivateFieldGet$4(this, _RuntimeClient_apiClient, "f").call('runtime.inbox', {})).map(PerspectiveExpression.fromWire);
10686
+ return (await __classPrivateFieldGet$5(this, _RuntimeClient_apiClient, "f").call('runtime.inbox', {})).map(PerspectiveExpression.fromWire);
10102
10687
  }
10103
10688
  async messageOutbox() {
10104
- const sent = await __classPrivateFieldGet$4(this, _RuntimeClient_apiClient, "f").call('runtime.outbox', {});
10689
+ const sent = await __classPrivateFieldGet$5(this, _RuntimeClient_apiClient, "f").call('runtime.outbox', {});
10105
10690
  return sent.map(({ recipient, message }) => ({ recipient, message: PerspectiveExpression.fromWire(message) }));
10106
10691
  }
10107
10692
  async requestInstallNotification(notification) {
10108
- return __classPrivateFieldGet$4(this, _RuntimeClient_apiClient, "f").call('runtime.createNotification', { ...notification });
10693
+ return __classPrivateFieldGet$5(this, _RuntimeClient_apiClient, "f").call('runtime.createNotification', { ...notification });
10109
10694
  }
10110
10695
  async grantNotification(id) {
10111
- return __classPrivateFieldGet$4(this, _RuntimeClient_apiClient, "f").call('runtime.grantNotification', { id, granted: true });
10696
+ return __classPrivateFieldGet$5(this, _RuntimeClient_apiClient, "f").call('runtime.grantNotification', { id, granted: true });
10112
10697
  }
10113
10698
  async exportDb(filePath) {
10114
- return __classPrivateFieldGet$4(this, _RuntimeClient_apiClient, "f").call('runtime.exportData', { type: "db", filePath });
10699
+ return __classPrivateFieldGet$5(this, _RuntimeClient_apiClient, "f").call('runtime.exportData', { type: "db", filePath });
10115
10700
  }
10116
10701
  async importDb(filePath) {
10117
- const result = await __classPrivateFieldGet$4(this, _RuntimeClient_apiClient, "f").call('runtime.importData', { type: "db", filePath });
10702
+ const result = await __classPrivateFieldGet$5(this, _RuntimeClient_apiClient, "f").call('runtime.importData', { type: "db", filePath });
10118
10703
  if ('success' in result)
10119
10704
  throw new Error('runtime.importData answered a perspective import for type "db"');
10120
10705
  return result;
10121
10706
  }
10122
10707
  async notifications() {
10123
- return __classPrivateFieldGet$4(this, _RuntimeClient_apiClient, "f").call('runtime.notifications', {});
10708
+ return __classPrivateFieldGet$5(this, _RuntimeClient_apiClient, "f").call('runtime.notifications', {});
10124
10709
  }
10125
10710
  async updateNotification(id, notification) {
10126
- return __classPrivateFieldGet$4(this, _RuntimeClient_apiClient, "f").call('runtime.updateNotification', { ...notification, id });
10711
+ return __classPrivateFieldGet$5(this, _RuntimeClient_apiClient, "f").call('runtime.updateNotification', { ...notification, id });
10127
10712
  }
10128
10713
  async removeNotification(id) {
10129
- return __classPrivateFieldGet$4(this, _RuntimeClient_apiClient, "f").call('runtime.deleteNotification', { id });
10714
+ return __classPrivateFieldGet$5(this, _RuntimeClient_apiClient, "f").call('runtime.deleteNotification', { id });
10130
10715
  }
10131
10716
  async exportPerspective(uuid, filePath) {
10132
- return __classPrivateFieldGet$4(this, _RuntimeClient_apiClient, "f").call('runtime.exportData', { type: "perspective", perspectiveUuid: uuid, filePath });
10717
+ return __classPrivateFieldGet$5(this, _RuntimeClient_apiClient, "f").call('runtime.exportData', { type: "perspective", perspectiveUuid: uuid, filePath });
10133
10718
  }
10134
10719
  async importPerspective(filePath) {
10135
- const result = await __classPrivateFieldGet$4(this, _RuntimeClient_apiClient, "f").call('runtime.importData', { type: "perspective", filePath });
10720
+ const result = await __classPrivateFieldGet$5(this, _RuntimeClient_apiClient, "f").call('runtime.importData', { type: "perspective", filePath });
10136
10721
  return 'success' in result && result.success;
10137
10722
  }
10138
10723
  async multiUserEnabled() {
10139
- return __classPrivateFieldGet$4(this, _RuntimeClient_apiClient, "f").call('user.multiUserEnabled', {});
10724
+ return __classPrivateFieldGet$5(this, _RuntimeClient_apiClient, "f").call('user.multiUserEnabled', {});
10140
10725
  }
10141
10726
  async setMultiUserEnabled(enabled) {
10142
- return __classPrivateFieldGet$4(this, _RuntimeClient_apiClient, "f").call('user.setMultiUserEnabled', { enabled });
10727
+ return __classPrivateFieldGet$5(this, _RuntimeClient_apiClient, "f").call('user.setMultiUserEnabled', { enabled });
10143
10728
  }
10144
10729
  async freeHostingEnabled() {
10145
- return __classPrivateFieldGet$4(this, _RuntimeClient_apiClient, "f").call('runtime.freeHostingEnabled', {});
10730
+ return __classPrivateFieldGet$5(this, _RuntimeClient_apiClient, "f").call('runtime.freeHostingEnabled', {});
10146
10731
  }
10147
10732
  async setFreeHostingEnabled(enabled) {
10148
- return __classPrivateFieldGet$4(this, _RuntimeClient_apiClient, "f").call('runtime.setFreeHostingEnabled', { enabled });
10733
+ return __classPrivateFieldGet$5(this, _RuntimeClient_apiClient, "f").call('runtime.setFreeHostingEnabled', { enabled });
10149
10734
  }
10150
10735
  async listUsers() {
10151
- return __classPrivateFieldGet$4(this, _RuntimeClient_apiClient, "f").call('user.list', {});
10736
+ return __classPrivateFieldGet$5(this, _RuntimeClient_apiClient, "f").call('user.list', {});
10152
10737
  }
10153
10738
  async userWalletAddress(email) {
10154
- return __classPrivateFieldGet$4(this, _RuntimeClient_apiClient, "f").call('user.wallet', { email });
10739
+ return __classPrivateFieldGet$5(this, _RuntimeClient_apiClient, "f").call('user.wallet', { email });
10155
10740
  }
10156
10741
  async emailTestModeEnable() {
10157
- return (await __classPrivateFieldGet$4(this, _RuntimeClient_apiClient, "f").call('user.emailTest', { action: 'enable' })) === true;
10742
+ return (await __classPrivateFieldGet$5(this, _RuntimeClient_apiClient, "f").call('user.emailTest', { action: 'enable' })) === true;
10158
10743
  }
10159
10744
  async emailTestModeDisable() {
10160
- return (await __classPrivateFieldGet$4(this, _RuntimeClient_apiClient, "f").call('user.emailTest', { action: 'disable' })) === true;
10745
+ return (await __classPrivateFieldGet$5(this, _RuntimeClient_apiClient, "f").call('user.emailTest', { action: 'disable' })) === true;
10161
10746
  }
10162
10747
  async emailTestGetCode(email) {
10163
- const code = await __classPrivateFieldGet$4(this, _RuntimeClient_apiClient, "f").call('user.emailTest', { action: 'get-code', email });
10748
+ const code = await __classPrivateFieldGet$5(this, _RuntimeClient_apiClient, "f").call('user.emailTest', { action: 'get-code', email });
10164
10749
  return typeof code === 'string' ? code : null;
10165
10750
  }
10166
10751
  async emailTestClearCodes() {
10167
- return (await __classPrivateFieldGet$4(this, _RuntimeClient_apiClient, "f").call('user.emailTest', { action: 'clear-codes' })) === true;
10752
+ return (await __classPrivateFieldGet$5(this, _RuntimeClient_apiClient, "f").call('user.emailTest', { action: 'clear-codes' })) === true;
10168
10753
  }
10169
10754
  async emailTestSetExpiry(email, verificationType, expiresAt) {
10170
- return (await __classPrivateFieldGet$4(this, _RuntimeClient_apiClient, "f").call('user.emailTest', { action: 'set-expiry', email, verificationType, expiresAt })) === true;
10755
+ return (await __classPrivateFieldGet$5(this, _RuntimeClient_apiClient, "f").call('user.emailTest', { action: 'set-expiry', email, verificationType, expiresAt })) === true;
10171
10756
  }
10172
10757
  // ---- Unyt / mHOT methods ----
10173
10758
  async unytAgentKey() {
10174
- return __classPrivateFieldGet$4(this, _RuntimeClient_apiClient, "f").call('runtime.unytAgentKey', {});
10759
+ return __classPrivateFieldGet$5(this, _RuntimeClient_apiClient, "f").call('runtime.unytAgentKey', {});
10175
10760
  }
10176
10761
  async unytHotAgentPubkey() {
10177
- return __classPrivateFieldGet$4(this, _RuntimeClient_apiClient, "f").call('runtime.unytHotAgentPubkey', {});
10762
+ return __classPrivateFieldGet$5(this, _RuntimeClient_apiClient, "f").call('runtime.unytHotAgentPubkey', {});
10178
10763
  }
10179
10764
  async unytWalletBalance() {
10180
- return __classPrivateFieldGet$4(this, _RuntimeClient_apiClient, "f").call('runtime.unytWalletBalance', {});
10765
+ return __classPrivateFieldGet$5(this, _RuntimeClient_apiClient, "f").call('runtime.unytWalletBalance', {});
10181
10766
  }
10182
10767
  async unytWalletHistory(page, perPage) {
10183
- return __classPrivateFieldGet$4(this, _RuntimeClient_apiClient, "f").call('runtime.unytWalletHistory', { page, perPage });
10768
+ return __classPrivateFieldGet$5(this, _RuntimeClient_apiClient, "f").call('runtime.unytWalletHistory', { page, perPage });
10184
10769
  }
10185
10770
  /** Installed and bundled DNA versions, and why the last install failed (`installError`). */
10186
10771
  async unytVersionInfo() {
10187
- return __classPrivateFieldGet$4(this, _RuntimeClient_apiClient, "f").call('runtime.unytVersionInfo', {});
10772
+ return __classPrivateFieldGet$5(this, _RuntimeClient_apiClient, "f").call('runtime.unytVersionInfo', {});
10188
10773
  }
10189
10774
  /** Stores the membrane proof (base64); the executor then installs the Unyt DNA in the
10190
10775
  * background. Poll {@link unytVersionInfo} for the outcome. */
10191
10776
  async setUnytMembraneProof(proof) {
10192
- return __classPrivateFieldGet$4(this, _RuntimeClient_apiClient, "f").call('runtime.setUnytMembraneProof', { proof });
10777
+ return __classPrivateFieldGet$5(this, _RuntimeClient_apiClient, "f").call('runtime.setUnytMembraneProof', { proof });
10193
10778
  }
10194
10779
  async unytReinstallDna() {
10195
- return __classPrivateFieldGet$4(this, _RuntimeClient_apiClient, "f").call('runtime.unytReinstallDna', {});
10780
+ return __classPrivateFieldGet$5(this, _RuntimeClient_apiClient, "f").call('runtime.unytReinstallDna', {});
10196
10781
  }
10197
10782
  async unytSendHot(recipient, amount) {
10198
- return __classPrivateFieldGet$4(this, _RuntimeClient_apiClient, "f").call('runtime.unytSendHot', { recipient, amount });
10783
+ return __classPrivateFieldGet$5(this, _RuntimeClient_apiClient, "f").call('runtime.unytSendHot', { recipient, amount });
10199
10784
  }
10200
10785
  async setUserCredits(email, amount) {
10201
- return __classPrivateFieldGet$4(this, _RuntimeClient_apiClient, "f").call('user.credits', { email, amount });
10786
+ return __classPrivateFieldGet$5(this, _RuntimeClient_apiClient, "f").call('user.credits', { email, amount });
10202
10787
  }
10203
10788
  async setUserFreeAccess(email, enabled) {
10204
- return __classPrivateFieldGet$4(this, _RuntimeClient_apiClient, "f").call('user.freeAccess', { email, enabled });
10789
+ return __classPrivateFieldGet$5(this, _RuntimeClient_apiClient, "f").call('user.freeAccess', { email, enabled });
10205
10790
  }
10206
10791
  async setHostRates(rates) {
10207
- return __classPrivateFieldGet$4(this, _RuntimeClient_apiClient, "f").call('runtime.setHostRates', { rates });
10792
+ return __classPrivateFieldGet$5(this, _RuntimeClient_apiClient, "f").call('runtime.setHostRates', { rates });
10208
10793
  }
10209
10794
  async hostRates() {
10210
- return __classPrivateFieldGet$4(this, _RuntimeClient_apiClient, "f").call('runtime.hostRates', {});
10795
+ return __classPrivateFieldGet$5(this, _RuntimeClient_apiClient, "f").call('runtime.hostRates', {});
10211
10796
  }
10212
10797
  }
10213
10798
  _RuntimeClient_apiClient = new WeakMap();
10214
10799
 
10215
- var __classPrivateFieldSet$3 = (undefined && undefined.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
10800
+ var __classPrivateFieldSet$4 = (undefined && undefined.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
10216
10801
  if (kind === "m") throw new TypeError("Private method is not writable");
10217
10802
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
10218
10803
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
10219
10804
  return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
10220
10805
  };
10221
- var __classPrivateFieldGet$3 = (undefined && undefined.__classPrivateFieldGet) || function (receiver, state, kind, f) {
10806
+ var __classPrivateFieldGet$4 = (undefined && undefined.__classPrivateFieldGet) || function (receiver, state, kind, f) {
10222
10807
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
10223
10808
  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");
10224
10809
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
@@ -10234,8 +10819,8 @@ class ExpressionClient {
10234
10819
  _ExpressionClient_totalMemBytes.set(this, 0);
10235
10820
  // L2: persistent cache (IndexedDB in browser, NullCache in Node)
10236
10821
  _ExpressionClient_persistent.set(this, void 0);
10237
- __classPrivateFieldSet$3(this, _ExpressionClient_apiClient, sharedApiClient || new ApiClient(baseUrl, token), "f");
10238
- __classPrivateFieldSet$3(this, _ExpressionClient_persistent, createPersistentCache('ad4m-expression-cache', 'expressions'), "f");
10822
+ __classPrivateFieldSet$4(this, _ExpressionClient_apiClient, sharedApiClient || new ApiClient(baseUrl, token), "f");
10823
+ __classPrivateFieldSet$4(this, _ExpressionClient_persistent, createPersistentCache('ad4m-expression-cache', 'expressions'), "f");
10239
10824
  }
10240
10825
  async get(url, alwaysGet = false) {
10241
10826
  // Existing literal fast-path
@@ -10252,55 +10837,55 @@ class ExpressionClient {
10252
10837
  }
10253
10838
  // L1: memory hit
10254
10839
  if (!alwaysGet) {
10255
- const memHit = __classPrivateFieldGet$3(this, _ExpressionClient_memCache, "f").get(url);
10840
+ const memHit = __classPrivateFieldGet$4(this, _ExpressionClient_memCache, "f").get(url);
10256
10841
  if (memHit)
10257
10842
  return memHit.data;
10258
10843
  }
10259
10844
  // Deduplicate in-flight requests
10260
10845
  if (!alwaysGet) {
10261
- const existing = __classPrivateFieldGet$3(this, _ExpressionClient_inflight, "f").get(url);
10846
+ const existing = __classPrivateFieldGet$4(this, _ExpressionClient_inflight, "f").get(url);
10262
10847
  if (existing)
10263
10848
  return existing;
10264
10849
  }
10265
10850
  // L2 check + L3 network
10266
10851
  const promise = (async () => {
10267
10852
  if (!alwaysGet) {
10268
- const persisted = await __classPrivateFieldGet$3(this, _ExpressionClient_persistent, "f").get(url);
10853
+ const persisted = await __classPrivateFieldGet$4(this, _ExpressionClient_persistent, "f").get(url);
10269
10854
  if (persisted) {
10270
- __classPrivateFieldGet$3(this, _ExpressionClient_instances, "m", _ExpressionClient_memCacheResult).call(this, url, persisted); // promote to L1
10855
+ __classPrivateFieldGet$4(this, _ExpressionClient_instances, "m", _ExpressionClient_memCacheResult).call(this, url, persisted); // promote to L1
10271
10856
  return persisted;
10272
10857
  }
10273
10858
  }
10274
10859
  // L3: network fetch
10275
- const result = await __classPrivateFieldGet$3(this, _ExpressionClient_apiClient, "f").call('expression.get', { url });
10276
- __classPrivateFieldGet$3(this, _ExpressionClient_instances, "m", _ExpressionClient_memCacheResult).call(this, url, result);
10277
- __classPrivateFieldGet$3(this, _ExpressionClient_persistent, "f").put(url, result); // fire-and-forget write to L2
10860
+ const result = await __classPrivateFieldGet$4(this, _ExpressionClient_apiClient, "f").call('expression.get', { url });
10861
+ __classPrivateFieldGet$4(this, _ExpressionClient_instances, "m", _ExpressionClient_memCacheResult).call(this, url, result);
10862
+ __classPrivateFieldGet$4(this, _ExpressionClient_persistent, "f").put(url, result); // fire-and-forget write to L2
10278
10863
  return result;
10279
10864
  })();
10280
- __classPrivateFieldGet$3(this, _ExpressionClient_inflight, "f").set(url, promise);
10865
+ __classPrivateFieldGet$4(this, _ExpressionClient_inflight, "f").set(url, promise);
10281
10866
  try {
10282
10867
  return await promise;
10283
10868
  }
10284
10869
  finally {
10285
- __classPrivateFieldGet$3(this, _ExpressionClient_inflight, "f").delete(url);
10870
+ __classPrivateFieldGet$4(this, _ExpressionClient_inflight, "f").delete(url);
10286
10871
  }
10287
10872
  }
10288
10873
  async getMany(urls) {
10289
10874
  // Check L1 first
10290
- const results = urls.map(u => __classPrivateFieldGet$3(this, _ExpressionClient_memCache, "f").get(u)?.data ?? null);
10875
+ const results = urls.map(u => __classPrivateFieldGet$4(this, _ExpressionClient_memCache, "f").get(u)?.data ?? null);
10291
10876
  let uncachedIndices = results
10292
10877
  .map((r, i) => r === null ? i : -1)
10293
10878
  .filter(i => i >= 0);
10294
10879
  if (uncachedIndices.length === 0)
10295
10880
  return results;
10296
10881
  // Check L2 for remaining misses
10297
- const l2Results = await Promise.all(uncachedIndices.map(i => __classPrivateFieldGet$3(this, _ExpressionClient_persistent, "f").get(urls[i])));
10882
+ const l2Results = await Promise.all(uncachedIndices.map(i => __classPrivateFieldGet$4(this, _ExpressionClient_persistent, "f").get(urls[i])));
10298
10883
  const stillMissing = [];
10299
10884
  for (let j = 0; j < uncachedIndices.length; j++) {
10300
10885
  const idx = uncachedIndices[j];
10301
10886
  if (l2Results[j]) {
10302
10887
  results[idx] = l2Results[j];
10303
- __classPrivateFieldGet$3(this, _ExpressionClient_instances, "m", _ExpressionClient_memCacheResult).call(this, urls[idx], l2Results[j]); // promote to L1
10888
+ __classPrivateFieldGet$4(this, _ExpressionClient_instances, "m", _ExpressionClient_memCacheResult).call(this, urls[idx], l2Results[j]); // promote to L1
10304
10889
  }
10305
10890
  else {
10306
10891
  stillMissing.push(idx);
@@ -10310,13 +10895,13 @@ class ExpressionClient {
10310
10895
  return results;
10311
10896
  // L3: fetch only truly uncached URLs
10312
10897
  const uncachedUrls = stillMissing.map(i => urls[i]);
10313
- const fetched = await __classPrivateFieldGet$3(this, _ExpressionClient_apiClient, "f").call('expression.getMany', { urls: uncachedUrls });
10898
+ const fetched = await __classPrivateFieldGet$4(this, _ExpressionClient_apiClient, "f").call('expression.getMany', { urls: uncachedUrls });
10314
10899
  for (let i = 0; i < stillMissing.length; i++) {
10315
10900
  const idx = stillMissing[i];
10316
10901
  results[idx] = fetched[i];
10317
10902
  if (fetched[i]) {
10318
- __classPrivateFieldGet$3(this, _ExpressionClient_instances, "m", _ExpressionClient_memCacheResult).call(this, uncachedUrls[i], fetched[i]);
10319
- __classPrivateFieldGet$3(this, _ExpressionClient_persistent, "f").put(uncachedUrls[i], fetched[i]); // fire-and-forget
10903
+ __classPrivateFieldGet$4(this, _ExpressionClient_instances, "m", _ExpressionClient_memCacheResult).call(this, uncachedUrls[i], fetched[i]);
10904
+ __classPrivateFieldGet$4(this, _ExpressionClient_persistent, "f").put(uncachedUrls[i], fetched[i]); // fire-and-forget
10320
10905
  }
10321
10906
  }
10322
10907
  return results;
@@ -10325,44 +10910,44 @@ class ExpressionClient {
10325
10910
  * Clear both L1 (memory) and L2 (persistent) expression caches.
10326
10911
  */
10327
10912
  clearCache() {
10328
- __classPrivateFieldGet$3(this, _ExpressionClient_memCache, "f").clear();
10329
- __classPrivateFieldGet$3(this, _ExpressionClient_inflight, "f").clear();
10330
- __classPrivateFieldSet$3(this, _ExpressionClient_totalMemBytes, 0, "f");
10331
- __classPrivateFieldGet$3(this, _ExpressionClient_persistent, "f").clear(); // fire-and-forget
10913
+ __classPrivateFieldGet$4(this, _ExpressionClient_memCache, "f").clear();
10914
+ __classPrivateFieldGet$4(this, _ExpressionClient_inflight, "f").clear();
10915
+ __classPrivateFieldSet$4(this, _ExpressionClient_totalMemBytes, 0, "f");
10916
+ __classPrivateFieldGet$4(this, _ExpressionClient_persistent, "f").clear(); // fire-and-forget
10332
10917
  }
10333
10918
  async getRaw(url) {
10334
- return __classPrivateFieldGet$3(this, _ExpressionClient_apiClient, "f").call('expression.getRaw', { url });
10919
+ return __classPrivateFieldGet$4(this, _ExpressionClient_apiClient, "f").call('expression.getRaw', { url });
10335
10920
  }
10336
10921
  async create(content, languageAddress) {
10337
10922
  const serialized = JSON.stringify(content);
10338
- return __classPrivateFieldGet$3(this, _ExpressionClient_apiClient, "f").call('expression.create', { content: serialized, languageAddress });
10923
+ return __classPrivateFieldGet$4(this, _ExpressionClient_apiClient, "f").call('expression.create', { content: serialized, languageAddress });
10339
10924
  }
10340
10925
  async interactions(url) {
10341
- return __classPrivateFieldGet$3(this, _ExpressionClient_apiClient, "f").call('expression.interactions', { url });
10926
+ return __classPrivateFieldGet$4(this, _ExpressionClient_apiClient, "f").call('expression.interactions', { url });
10342
10927
  }
10343
10928
  async interact(url, interactionCall) {
10344
- const result = await __classPrivateFieldGet$3(this, _ExpressionClient_apiClient, "f").call('expression.interact', { url, interactionCall });
10929
+ const result = await __classPrivateFieldGet$4(this, _ExpressionClient_apiClient, "f").call('expression.interact', { url, interactionCall });
10345
10930
  // Interactions can mutate the expression — invalidate cache so next get() fetches fresh
10346
- __classPrivateFieldGet$3(this, _ExpressionClient_memCache, "f").delete(url);
10347
- __classPrivateFieldGet$3(this, _ExpressionClient_inflight, "f").delete(url);
10348
- __classPrivateFieldGet$3(this, _ExpressionClient_persistent, "f").delete(url); // fire-and-forget
10931
+ __classPrivateFieldGet$4(this, _ExpressionClient_memCache, "f").delete(url);
10932
+ __classPrivateFieldGet$4(this, _ExpressionClient_inflight, "f").delete(url);
10933
+ __classPrivateFieldGet$4(this, _ExpressionClient_persistent, "f").delete(url); // fire-and-forget
10349
10934
  return result;
10350
10935
  }
10351
10936
  }
10352
10937
  _ExpressionClient_apiClient = new WeakMap(), _ExpressionClient_memCache = new WeakMap(), _ExpressionClient_inflight = new WeakMap(), _ExpressionClient_totalMemBytes = new WeakMap(), _ExpressionClient_persistent = new WeakMap(), _ExpressionClient_instances = new WeakSet(), _ExpressionClient_memCacheResult = function _ExpressionClient_memCacheResult(url, data) {
10353
10938
  const size = JSON.stringify(data).length;
10354
10939
  // Evict oldest entries if we'd exceed limits
10355
- while (__classPrivateFieldGet$3(this, _ExpressionClient_memCache, "f").size >= ExpressionClient.MAX_MEM_ENTRIES ||
10356
- __classPrivateFieldGet$3(this, _ExpressionClient_totalMemBytes, "f") + size > ExpressionClient.MAX_MEM_BYTES) {
10357
- const oldest = __classPrivateFieldGet$3(this, _ExpressionClient_memCache, "f").keys().next().value;
10940
+ while (__classPrivateFieldGet$4(this, _ExpressionClient_memCache, "f").size >= ExpressionClient.MAX_MEM_ENTRIES ||
10941
+ __classPrivateFieldGet$4(this, _ExpressionClient_totalMemBytes, "f") + size > ExpressionClient.MAX_MEM_BYTES) {
10942
+ const oldest = __classPrivateFieldGet$4(this, _ExpressionClient_memCache, "f").keys().next().value;
10358
10943
  if (!oldest)
10359
10944
  break;
10360
- const entry = __classPrivateFieldGet$3(this, _ExpressionClient_memCache, "f").get(oldest);
10361
- __classPrivateFieldSet$3(this, _ExpressionClient_totalMemBytes, __classPrivateFieldGet$3(this, _ExpressionClient_totalMemBytes, "f") - entry.size, "f");
10362
- __classPrivateFieldGet$3(this, _ExpressionClient_memCache, "f").delete(oldest);
10945
+ const entry = __classPrivateFieldGet$4(this, _ExpressionClient_memCache, "f").get(oldest);
10946
+ __classPrivateFieldSet$4(this, _ExpressionClient_totalMemBytes, __classPrivateFieldGet$4(this, _ExpressionClient_totalMemBytes, "f") - entry.size, "f");
10947
+ __classPrivateFieldGet$4(this, _ExpressionClient_memCache, "f").delete(oldest);
10363
10948
  }
10364
- __classPrivateFieldGet$3(this, _ExpressionClient_memCache, "f").set(url, { data, size });
10365
- __classPrivateFieldSet$3(this, _ExpressionClient_totalMemBytes, __classPrivateFieldGet$3(this, _ExpressionClient_totalMemBytes, "f") + size, "f");
10949
+ __classPrivateFieldGet$4(this, _ExpressionClient_memCache, "f").set(url, { data, size });
10950
+ __classPrivateFieldSet$4(this, _ExpressionClient_totalMemBytes, __classPrivateFieldGet$4(this, _ExpressionClient_totalMemBytes, "f") + size, "f");
10366
10951
  };
10367
10952
  /** Maximum number of entries in the L1 memory cache. */
10368
10953
  ExpressionClient.MAX_MEM_ENTRIES = 200;
@@ -17438,13 +18023,13 @@ class AIModelLoadingStatus {
17438
18023
  }
17439
18024
  }
17440
18025
 
17441
- var __classPrivateFieldSet$2 = (undefined && undefined.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
18026
+ var __classPrivateFieldSet$3 = (undefined && undefined.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
17442
18027
  if (kind === "m") throw new TypeError("Private method is not writable");
17443
18028
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
17444
18029
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
17445
18030
  return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
17446
18031
  };
17447
- var __classPrivateFieldGet$2 = (undefined && undefined.__classPrivateFieldGet) || function (receiver, state, kind, f) {
18032
+ var __classPrivateFieldGet$3 = (undefined && undefined.__classPrivateFieldGet) || function (receiver, state, kind, f) {
17448
18033
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
17449
18034
  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");
17450
18035
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
@@ -17455,14 +18040,14 @@ class AIClient {
17455
18040
  _AIClient_apiClient.set(this, void 0);
17456
18041
  _AIClient_transcriptionUnsubscribers.set(this, new Map());
17457
18042
  _AIClient_pendingStreamIds.set(this, new Set());
17458
- __classPrivateFieldSet$2(this, _AIClient_apiClient, sharedApiClient || new ApiClient(baseUrl, token), "f");
18043
+ __classPrivateFieldSet$3(this, _AIClient_apiClient, sharedApiClient || new ApiClient(baseUrl, token), "f");
17459
18044
  }
17460
18045
  /** The executor names the model type `type`. */
17461
18046
  serializeModelInput({ modelType, ...model }) {
17462
18047
  return { ...model, type: modelType };
17463
18048
  }
17464
18049
  async getModels() {
17465
- return __classPrivateFieldGet$2(this, _AIClient_apiClient, "f").call('ai.models', {});
18050
+ return __classPrivateFieldGet$3(this, _AIClient_apiClient, "f").call('ai.models', {});
17466
18051
  }
17467
18052
  /**
17468
18053
  * Ask a remote endpoint which models it serves, before adding one.
@@ -17477,35 +18062,35 @@ class AIClient {
17477
18062
  * that is not Anthropic speaks.
17478
18063
  */
17479
18064
  async discoverModels(baseUrl, apiKey, apiType) {
17480
- return __classPrivateFieldGet$2(this, _AIClient_apiClient, "f").call('ai.discoverModels', { baseUrl, apiKey, apiType });
18065
+ return __classPrivateFieldGet$3(this, _AIClient_apiClient, "f").call('ai.discoverModels', { baseUrl, apiKey, apiType });
17481
18066
  }
17482
18067
  async addModel(model, options) {
17483
- return __classPrivateFieldGet$2(this, _AIClient_apiClient, "f").call('ai.addModel', { model: this.serializeModelInput(model) }, options);
18068
+ return __classPrivateFieldGet$3(this, _AIClient_apiClient, "f").call('ai.addModel', { model: this.serializeModelInput(model) }, options);
17484
18069
  }
17485
18070
  async updateModel(modelId, model) {
17486
- return __classPrivateFieldGet$2(this, _AIClient_apiClient, "f").call('ai.updateModel', { id: modelId, model: this.serializeModelInput(model) });
18071
+ return __classPrivateFieldGet$3(this, _AIClient_apiClient, "f").call('ai.updateModel', { id: modelId, model: this.serializeModelInput(model) });
17487
18072
  }
17488
18073
  async removeModel(modelId) {
17489
- return __classPrivateFieldGet$2(this, _AIClient_apiClient, "f").call('ai.removeModel', { id: modelId });
18074
+ return __classPrivateFieldGet$3(this, _AIClient_apiClient, "f").call('ai.removeModel', { id: modelId });
17490
18075
  }
17491
18076
  async setDefaultModel(modelType, modelId) {
17492
- return __classPrivateFieldGet$2(this, _AIClient_apiClient, "f").call('ai.setDefaultModel', { id: modelId, modelType });
18077
+ return __classPrivateFieldGet$3(this, _AIClient_apiClient, "f").call('ai.setDefaultModel', { id: modelId, modelType });
17493
18078
  }
17494
18079
  async getDefaultModel(modelType) {
17495
- return __classPrivateFieldGet$2(this, _AIClient_apiClient, "f").call('ai.getDefaultModel', { modelType });
18080
+ return __classPrivateFieldGet$3(this, _AIClient_apiClient, "f").call('ai.getDefaultModel', { modelType });
17496
18081
  }
17497
18082
  async tasks() {
17498
- return __classPrivateFieldGet$2(this, _AIClient_apiClient, "f").call('ai.tasks', {});
18083
+ return __classPrivateFieldGet$3(this, _AIClient_apiClient, "f").call('ai.tasks', {});
17499
18084
  }
17500
18085
  async addTask(name, modelId, systemPrompt, promptExamples, metaData) {
17501
18086
  const task = new AITaskInput(name, modelId, systemPrompt, promptExamples, metaData);
17502
- return __classPrivateFieldGet$2(this, _AIClient_apiClient, "f").call('ai.addTask', { task });
18087
+ return __classPrivateFieldGet$3(this, _AIClient_apiClient, "f").call('ai.addTask', { task });
17503
18088
  }
17504
18089
  async removeTask(taskId) {
17505
- return __classPrivateFieldGet$2(this, _AIClient_apiClient, "f").call('ai.removeTask', { id: taskId });
18090
+ return __classPrivateFieldGet$3(this, _AIClient_apiClient, "f").call('ai.removeTask', { id: taskId });
17506
18091
  }
17507
18092
  async updateTask(taskId, task) {
17508
- return __classPrivateFieldGet$2(this, _AIClient_apiClient, "f").call('ai.updateTask', {
18093
+ return __classPrivateFieldGet$3(this, _AIClient_apiClient, "f").call('ai.updateTask', {
17509
18094
  task: {
17510
18095
  taskId,
17511
18096
  name: task.name,
@@ -17519,13 +18104,13 @@ class AIClient {
17519
18104
  });
17520
18105
  }
17521
18106
  async modelLoadingStatus(model) {
17522
- return __classPrivateFieldGet$2(this, _AIClient_apiClient, "f").call('ai.modelLoadingStatus', { model });
18107
+ return __classPrivateFieldGet$3(this, _AIClient_apiClient, "f").call('ai.modelLoadingStatus', { model });
17523
18108
  }
17524
18109
  async prompt(taskId, prompt, options) {
17525
- return __classPrivateFieldGet$2(this, _AIClient_apiClient, "f").call('ai.prompt', { taskId, prompt }, options);
18110
+ return __classPrivateFieldGet$3(this, _AIClient_apiClient, "f").call('ai.prompt', { taskId, prompt }, options);
17526
18111
  }
17527
18112
  async embed(modelId, text, options) {
17528
- const aiEmbed = await __classPrivateFieldGet$2(this, _AIClient_apiClient, "f").call('ai.embed', { modelId, text }, options);
18113
+ const aiEmbed = await __classPrivateFieldGet$3(this, _AIClient_apiClient, "f").call('ai.embed', { modelId, text }, options);
17529
18114
  const compressed = base64Js.toByteArray(aiEmbed);
17530
18115
  // NB: pako v1 accepts `{ to: 'string' }`, pako v2 wants `{ toText: true }`,
17531
18116
  // pako v3 also drops that overload from its bundled types. Call the
@@ -17536,22 +18121,22 @@ class AIClient {
17536
18121
  return decompressed;
17537
18122
  }
17538
18123
  async openTranscriptionStream(modelId, streamCallback, params) {
17539
- const streamId = await __classPrivateFieldGet$2(this, _AIClient_apiClient, "f").call('ai.transcriptionOpen', { modelId, params });
17540
- const unsub = __classPrivateFieldGet$2(this, _AIClient_apiClient, "f").on('transcription-text', (event) => {
18124
+ const streamId = await __classPrivateFieldGet$3(this, _AIClient_apiClient, "f").call('ai.transcriptionOpen', { modelId, params });
18125
+ const unsub = __classPrivateFieldGet$3(this, _AIClient_apiClient, "f").on('transcription-text', (event) => {
17541
18126
  if (event.streamId === streamId && event.text)
17542
18127
  streamCallback(event.text);
17543
18128
  });
17544
- __classPrivateFieldGet$2(this, _AIClient_transcriptionUnsubscribers, "f").set(streamId, unsub);
18129
+ __classPrivateFieldGet$3(this, _AIClient_transcriptionUnsubscribers, "f").set(streamId, unsub);
17545
18130
  return streamId;
17546
18131
  }
17547
18132
  async closeTranscriptionStream(streamId) {
17548
- __classPrivateFieldGet$2(this, _AIClient_pendingStreamIds, "f").delete(streamId);
18133
+ __classPrivateFieldGet$3(this, _AIClient_pendingStreamIds, "f").delete(streamId);
17549
18134
  try {
17550
- await __classPrivateFieldGet$2(this, _AIClient_apiClient, "f").call('ai.transcriptionClose', { streamId });
18135
+ await __classPrivateFieldGet$3(this, _AIClient_apiClient, "f").call('ai.transcriptionClose', { streamId });
17551
18136
  }
17552
18137
  finally {
17553
- __classPrivateFieldGet$2(this, _AIClient_transcriptionUnsubscribers, "f").get(streamId)?.();
17554
- __classPrivateFieldGet$2(this, _AIClient_transcriptionUnsubscribers, "f").delete(streamId);
18138
+ __classPrivateFieldGet$3(this, _AIClient_transcriptionUnsubscribers, "f").get(streamId)?.();
18139
+ __classPrivateFieldGet$3(this, _AIClient_transcriptionUnsubscribers, "f").delete(streamId);
17555
18140
  }
17556
18141
  }
17557
18142
  /**
@@ -17573,12 +18158,12 @@ class AIClient {
17573
18158
  if (ids.length === 0 || typedAudio.length === 0) {
17574
18159
  return;
17575
18160
  }
17576
- const baseUrl = __classPrivateFieldGet$2(this, _AIClient_apiClient, "f").getBaseUrl();
17577
- const token = __classPrivateFieldGet$2(this, _AIClient_apiClient, "f").getToken();
18161
+ const baseUrl = __classPrivateFieldGet$3(this, _AIClient_apiClient, "f").getBaseUrl();
18162
+ const token = __classPrivateFieldGet$3(this, _AIClient_apiClient, "f").getToken();
17578
18163
  // Use slice to get only the relevant portion of the underlying ArrayBuffer
17579
18164
  // (Float32Array may be a view over a larger buffer)
17580
18165
  const bodyBuffer = typedAudio.buffer.slice(typedAudio.byteOffset, typedAudio.byteOffset + typedAudio.byteLength);
17581
- const response = await __classPrivateFieldGet$2(this, _AIClient_apiClient, "f").doFetch(`${baseUrl}/api/v1/ai/transcription/feed`, {
18166
+ const response = await __classPrivateFieldGet$3(this, _AIClient_apiClient, "f").doFetch(`${baseUrl}/api/v1/ai/transcription/feed`, {
17582
18167
  method: 'POST',
17583
18168
  headers: {
17584
18169
  'Content-Type': 'application/octet-stream',
@@ -17595,6 +18180,103 @@ class AIClient {
17595
18180
  }
17596
18181
  _AIClient_apiClient = new WeakMap(), _AIClient_transcriptionUnsubscribers = new WeakMap(), _AIClient_pendingStreamIds = new WeakMap();
17597
18182
 
18183
+ var __classPrivateFieldSet$2 = (undefined && undefined.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
18184
+ if (kind === "m") throw new TypeError("Private method is not writable");
18185
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
18186
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
18187
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
18188
+ };
18189
+ var __classPrivateFieldGet$2 = (undefined && undefined.__classPrivateFieldGet) || function (receiver, state, kind, f) {
18190
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
18191
+ 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");
18192
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
18193
+ };
18194
+ var _IdentityClient_apiClient;
18195
+ /**
18196
+ * The executor's `did:scid:coasys:1` calls.
18197
+ *
18198
+ * The executor holds device keys only. Master keys and the 12 words stay with the app
18199
+ * (`ad4m-identity-client`), which signs the events and offers these calls pass on.
18200
+ * `agent.status()` and `agent.me()` carry `identity`, the `did:scid` the agent speaks for.
18201
+ */
18202
+ class IdentityClient {
18203
+ constructor(baseUrl, token, sharedApiClient) {
18204
+ _IdentityClient_apiClient.set(this, void 0);
18205
+ __classPrivateFieldSet$2(this, _IdentityClient_apiClient, sharedApiClient || new ApiClient(baseUrl, token), "f");
18206
+ }
18207
+ /**
18208
+ * This agent's identity, device key, `enc` key and the cached head. `storeBehind` is set
18209
+ * (`{ since, seq }`) while the configured store answers the log behind the executor's cache,
18210
+ * and `null` once it catches up. `store` is the identity store this executor uses
18211
+ * (`{ url, trusted }`: its config's, else its network's) and whether it trusts a key for it;
18212
+ * `null` when its network has no store, so identities cannot be created or linked there.
18213
+ */
18214
+ async status() {
18215
+ return __classPrivateFieldGet$2(this, _IdentityClient_apiClient, "f").call("identity.status", {});
18216
+ }
18217
+ /** A log through the executor's cache; `fresh` refreshes it from the store first. */
18218
+ async log(did, from, fresh) {
18219
+ return __classPrivateFieldGet$2(this, _IdentityClient_apiClient, "f").call("identity.log", { did, from, fresh });
18220
+ }
18221
+ /**
18222
+ * Resolves a `did:scid:coasys:1` DID URL (`?src=`, `?versionId=`, `#d1`) or a bare device
18223
+ * `did:key` to a W3C DID Core resolution result. The executor answers from its key-log
18224
+ * cache unless `fresh`, or the cache lacks the log or the asked version. A refusal comes
18225
+ * back as `didResolutionMetadata.error` (`invalidDid`, `invalidDidUrl`, `notFound`, …), not
18226
+ * as a thrown error. With a fragment, `didDocument` is null and `verificationMethod` holds
18227
+ * that method. For a `did:key`, `didResolutionMetadata["coasys:keyId"]` and
18228
+ * `["coasys:keyValid"]` say which key of the person's log it is and whether it is valid.
18229
+ */
18230
+ async resolve(didUrl, options = {}) {
18231
+ return __classPrivateFieldGet$2(this, _IdentityClient_apiClient, "f").call("identity.resolve", {
18232
+ didUrl,
18233
+ fresh: options.fresh,
18234
+ accept: options.accept,
18235
+ });
18236
+ }
18237
+ /**
18238
+ * Drops this executor's cached copy of `did`'s log (its events, accepted head and recorded
18239
+ * forks); the next read refreshes from the configured store and takes the store's branch.
18240
+ * The way out of an `identity-fork`. The operator (admin credential) only.
18241
+ */
18242
+ async resetLog(did) {
18243
+ return __classPrivateFieldGet$2(this, _IdentityClient_apiClient, "f").call("identity.resetLog", { did });
18244
+ }
18245
+ /**
18246
+ * Adds this agent's device-key proof to an `incept` that lists its key. For the main
18247
+ * agent the admin credential only; a user's session for its own agent.
18248
+ */
18249
+ async cosignIncept(event) {
18250
+ return __classPrivateFieldGet$2(this, _IdentityClient_apiClient, "f").call("identity.cosignIncept", { event: event });
18251
+ }
18252
+ /**
18253
+ * Appends signed events through the agent language. For the main agent the admin
18254
+ * credential only; a user's session for its own agent.
18255
+ */
18256
+ async publish(events) {
18257
+ return __classPrivateFieldGet$2(this, _IdentityClient_apiClient, "f").call("identity.publish", { events: events });
18258
+ }
18259
+ async openOffer(signedOffer) {
18260
+ return __classPrivateFieldGet$2(this, _IdentityClient_apiClient, "f").call("identity.openOffer", { signedOffer });
18261
+ }
18262
+ /** The identity's open and claimed offers, for a request signed by its current master key. */
18263
+ async offers(request, wait) {
18264
+ return __classPrivateFieldGet$2(this, _IdentityClient_apiClient, "f").call("identity.offers", { request, wait });
18265
+ }
18266
+ /** Claims an offer link for this executor (the operator only). */
18267
+ async claimOffer(offer, hint) {
18268
+ return __classPrivateFieldGet$2(this, _IdentityClient_apiClient, "f").call("identity.claimOffer", { offer, hint });
18269
+ }
18270
+ async joinStatus(offerId) {
18271
+ return __classPrivateFieldGet$2(this, _IdentityClient_apiClient, "f").call("identity.joinStatus", { offerId });
18272
+ }
18273
+ /** The identity's device keys, from its log. */
18274
+ async devices() {
18275
+ return __classPrivateFieldGet$2(this, _IdentityClient_apiClient, "f").call("identity.devices", {});
18276
+ }
18277
+ }
18278
+ _IdentityClient_apiClient = new WeakMap();
18279
+
17598
18280
  /**
17599
18281
  * Shared type definitions for the Ad4mModel system.
17600
18282
  *
@@ -18629,6 +19311,9 @@ function buildSPARQLWhereFilters(metadata, _allRelationsMetadata, where) {
18629
19311
  * Allows building queries with a chainable interface and either
18630
19312
  * running them once or subscribing to real-time updates.
18631
19313
  */
19314
+ /** What a subscription compares to skip a callback whose results equal the
19315
+ * last ones emitted (a resync or a reconnect re-open of an unchanged result). */
19316
+ const fingerprint = (value) => JSON.stringify(value, (_, v) => (typeof v === 'function' ? undefined : v));
18632
19317
  /** Query builder for Ad4mModel queries.
18633
19318
  * Allows building queries with a fluent interface and either running them once
18634
19319
  * or subscribing to updates.
@@ -18683,6 +19368,10 @@ class ModelQueryBuilder {
18683
19368
  }
18684
19369
  return this.ctor.parseModelResult(this.perspective, raw, include, properties);
18685
19370
  }
19371
+ /** Snapshot instances for dirty tracking, as `execute` does for its rows. */
19372
+ takeSnapshots(instances) {
19373
+ this.ctor.takeSnapshots(instances, this.queryParams.include);
19374
+ }
18686
19375
  /** Ends the current subscription, if any, on the client and the executor. */
18687
19376
  dispose() {
18688
19377
  if (this.currentSubscription) {
@@ -19052,7 +19741,6 @@ class ModelQueryBuilder {
19052
19741
  this.dispose();
19053
19742
  const parseResults = (raw) => this.parse(raw);
19054
19743
  // Suppress callbacks whose parsed results equal the last ones emitted.
19055
- const fingerprint = (results) => JSON.stringify(results, (_, v) => (typeof v === 'function' ? undefined : v));
19056
19744
  let lastFingerprint = null;
19057
19745
  const { initial } = await this.live(this.queryParams, (raw) => {
19058
19746
  try {
@@ -19203,73 +19891,46 @@ class ModelQueryBuilder {
19203
19891
  *
19204
19892
  */
19205
19893
  async paginateSubscribe(pageSize, pageNumber, callback) {
19206
- // Clean up any existing subscription
19207
19894
  this.dispose();
19208
- // Subscribe to the full result set (no limit/offset) so the subscription
19209
- // detects changes anywhere in the dataset; each change re-reads the page.
19210
- const subscriptionParams = { ...(this.queryParams || {}) };
19211
- delete subscriptionParams.limit;
19212
- delete subscriptionParams.offset;
19213
- // Build the paginated query for Rust endpoint (count: true fetches both results and totalCount in one call)
19895
+ // Subscribe to the page itself. Since #1237 the executor re-runs a paged
19896
+ // subscription when a record outside the page starts or stops matching
19897
+ // (the `joins` and `scan` trigger rules), and a model result carries
19898
+ // `totalCount`, so a write outside the page still changes the result and
19899
+ // is pushed. Each page is built from the pushed rows: no second query, and
19900
+ // the executor hydrates one page per change rather than every match.
19901
+ // Pushes arrive in revision order, so the last callback is the latest
19902
+ // state (#1051). After dispose() the live query delivers nothing.
19214
19903
  const paginatedQuery = {
19215
19904
  ...(this.queryParams || {}),
19216
19905
  limit: pageSize,
19217
19906
  offset: pageSize * (pageNumber - 1),
19218
19907
  count: true,
19219
19908
  };
19220
- // One read in flight. A dispatch while a read is running sets `pending`
19221
- // so a fetch always completes after the last dispatch. The generation
19222
- // counter from #1020 dropped superseded fetches, but ordered them by
19223
- // start time rather than by how fresh the data they read was — two
19224
- // back-to-back dispatches could keep the fetch that saw 1 model and
19225
- // drop the one that saw 2, after which the server has nothing further
19226
- // to say (issue #1051 / CI: "Paginate callback did not see second model save").
19227
- // After dispose() no read starts and no result is delivered, including
19228
- // a read that was already in flight when dispose() ran.
19229
- let disposed = false;
19230
- let fetching = false;
19231
- let pending = false;
19232
- const processResults = async () => {
19233
- if (disposed)
19234
- return;
19235
- if (fetching) {
19236
- pending = true;
19237
- return;
19238
- }
19239
- fetching = true;
19909
+ // As subscribe(): a callback fires only when the rows or totalCount
19910
+ // differ from the last page emitted, not on a resync or a reconnect
19911
+ // re-open of an unchanged page.
19912
+ let lastFingerprint = null;
19913
+ const toPage = (raw) => {
19914
+ const results = this.parse(raw);
19915
+ const fp = fingerprint([results, raw?.totalCount]);
19916
+ this.takeSnapshots(results);
19917
+ return { page: { results, totalCount: raw?.totalCount, pageSize, pageNumber }, fp };
19918
+ };
19919
+ const { initial } = await this.live(paginatedQuery, (raw) => {
19240
19920
  try {
19241
- const { results, totalCount } = await this.execute(paginatedQuery);
19242
- if (!disposed)
19243
- callback({ results, totalCount, pageSize, pageNumber });
19921
+ const { page, fp } = toPage(raw);
19922
+ if (fp === lastFingerprint)
19923
+ return;
19924
+ lastFingerprint = fp;
19925
+ callback(page);
19244
19926
  }
19245
- finally {
19246
- fetching = false;
19247
- if (pending) {
19248
- pending = false;
19249
- // Detached from the caller's promise: needs its own handler, or a
19250
- // rejection here is unhandled.
19251
- processResults().catch(e => console.error('Paginate subscription error:', e));
19252
- }
19927
+ catch (e) {
19928
+ console.error('Paginate subscription error:', e);
19253
19929
  }
19254
- };
19255
- const { live } = await this.live(subscriptionParams, () => {
19256
- processResults().catch(e => console.error('Paginate subscription error:', e));
19257
19930
  });
19258
- if (this.currentSubscription === live) {
19259
- this.currentSubscription = {
19260
- dispose: () => {
19261
- disposed = true;
19262
- live.dispose();
19263
- },
19264
- };
19265
- }
19266
- else {
19267
- // Disposed, or overtaken by a later subscribe, while opening: deliver nothing.
19268
- disposed = true;
19269
- }
19270
- // Initial fetch (single call with count: true)
19271
- const { results, totalCount } = await this.execute(paginatedQuery);
19272
- return { results, totalCount, pageSize, pageNumber };
19931
+ const { page, fp } = toPage(initial);
19932
+ lastFingerprint = fp;
19933
+ return page;
19273
19934
  }
19274
19935
  /**
19275
19936
  * Subscribes to paginated results updates using SPARQL.
@@ -19968,6 +20629,10 @@ class Ad4mModel {
19968
20629
  */
19969
20630
  constructor(perspective, baseExpression) {
19970
20631
  this._snapshot = null;
20632
+ /** True when the constructor minted the id: no record can hold links yet. */
20633
+ this._idMinted = false;
20634
+ /** Predicates this instance has already written relation links under (`add*`/`set*`), so they may hold links. */
20635
+ this._relationsWritten = new Set();
19971
20636
  // Use a dedicated `ad4m://obj/<id>` scheme for auto-generated
19972
20637
  // baseExpressions instead of `Literal.from(...).toUrl()`'s
19973
20638
  // `literal:string:<id>`. After typed-literal storage lands, the storage
@@ -19978,6 +20643,7 @@ class Ad4mModel {
19978
20643
  // IRIs, so relation links like `<post> --has_comment--> <comment-id>`
19979
20644
  // round-trip correctly through the SPARQL store.
19980
20645
  this._baseExpression = baseExpression ? baseExpression : `ad4m://obj/${makeRandomId(24)}`;
20646
+ this._idMinted = !baseExpression;
19981
20647
  this._perspective = perspective;
19982
20648
  }
19983
20649
  /**
@@ -20431,6 +21097,20 @@ class Ad4mModel {
20431
21097
  return [];
20432
21098
  return arr.map((json) => jsonToModelInstance(this, perspective, json, include, properties));
20433
21099
  }
21100
+ /**
21101
+ * Snapshot freshly built instances for dirty tracking, with the relations
21102
+ * `include` loaded (its `$`-prefixed projection keys are not relations).
21103
+ * Used by every query path, and by ModelQueryBuilder for pushed results.
21104
+ * @internal
21105
+ */
21106
+ static takeSnapshots(instances, include) {
21107
+ const relations = include
21108
+ ? Object.fromEntries(Object.entries(include).filter(([k]) => !k.startsWith('$')))
21109
+ : undefined;
21110
+ const snapshot = relations && Object.keys(relations).length > 0 ? relations : undefined;
21111
+ for (const inst of instances)
21112
+ inst.takeSnapshot?.(snapshot);
21113
+ }
20434
21114
  // ── One query over several classes (#1238) ────────────────────────────────
20435
21115
  /**
20436
21116
  * Build the wire parameters for one query over several classes.
@@ -20532,12 +21212,7 @@ class Ad4mModel {
20532
21212
  const { classNames, queryJson } = Ad4mModel.prepareUnionQueryParams(classes, query);
20533
21213
  const result = await perspective.modelQuery(classNames, queryJson, options);
20534
21214
  const results = Ad4mModel.parseUnionResult(classes, perspective, result, query.include, query.properties);
20535
- const snapshotRelations = query.include
20536
- ? Object.fromEntries(Object.entries(query.include).filter(([k]) => !k.startsWith('$')))
20537
- : undefined;
20538
- for (const inst of results) {
20539
- inst.takeSnapshot?.(snapshotRelations && Object.keys(snapshotRelations).length > 0 ? snapshotRelations : undefined);
20540
- }
21215
+ Ad4mModel.takeSnapshots(results, query.include);
20541
21216
  return { results, totalCount: result.totalCount };
20542
21217
  }
20543
21218
  /**
@@ -20603,13 +21278,7 @@ class Ad4mModel {
20603
21278
  const instances = result.instances.map((json) => {
20604
21279
  return jsonToModelInstance(this, perspective, json, query.include, query.properties);
20605
21280
  });
20606
- // Take snapshots for dirty tracking (exclude $-prefixed projection keys)
20607
- const snapshotRelations = query.include
20608
- ? Object.fromEntries(Object.entries(query.include).filter(([k]) => !k.startsWith('$')))
20609
- : undefined;
20610
- for (const inst of instances) {
20611
- inst.takeSnapshot(snapshotRelations && Object.keys(snapshotRelations).length > 0 ? snapshotRelations : undefined);
20612
- }
21281
+ Ad4mModel.takeSnapshots(instances, query.include);
20613
21282
  return {
20614
21283
  results: instances,
20615
21284
  totalCount: result.totalCount,
@@ -20793,6 +21462,7 @@ class Ad4mModel {
20793
21462
  console.warn(`Relation "${key}" has no metadata, skipping`);
20794
21463
  return;
20795
21464
  }
21465
+ this._relationsWritten.add(metadata.predicate);
20796
21466
  const abstractName = this.abstractName();
20797
21467
  if (abstractName) {
20798
21468
  if (value != null)
@@ -20816,6 +21486,7 @@ class Ad4mModel {
20816
21486
  console.warn(`Relation "${key}" has no metadata, skipping`);
20817
21487
  return;
20818
21488
  }
21489
+ this._relationsWritten.add(metadata.predicate);
20819
21490
  const abstractName = this.abstractName();
20820
21491
  if (abstractName) {
20821
21492
  if (value != null)
@@ -21064,7 +21735,11 @@ class Ad4mModel {
21064
21735
  }
21065
21736
  }
21066
21737
  else if (Array.isArray(value)) {
21067
- // Handle all arrays as relations, including empty ones (which clears the relation)
21738
+ // Handle all arrays as relations, including empty ones (which clears the relation).
21739
+ // A record being created under an id minted here has no links to
21740
+ // clear, so an empty relation there costs a round trip and writes nothing.
21741
+ if (value.length === 0 && !this._snapshot && this._idMinted && !this._relationsWritten.has(this.getRelationOptions(key)?.predicate ?? key))
21742
+ continue;
21068
21743
  await this.setRelationValues(key, value, batchId);
21069
21744
  }
21070
21745
  else if (value !== undefined && value !== null && value !== "") {
@@ -21668,7 +22343,7 @@ var __classPrivateFieldGet$1 = (undefined && undefined.__classPrivateFieldGet) |
21668
22343
  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");
21669
22344
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
21670
22345
  };
21671
- var _Ad4mClient_baseUrl, _Ad4mClient_token, _Ad4mClient_apiClient, _Ad4mClient_agentClient, _Ad4mClient_expressionClient, _Ad4mClient_languageClient, _Ad4mClient_neighbourhoodClient, _Ad4mClient_perspectiveClient, _Ad4mClient_runtimeClient, _Ad4mClient_aiClient;
22346
+ var _Ad4mClient_baseUrl, _Ad4mClient_token, _Ad4mClient_apiClient, _Ad4mClient_agentClient, _Ad4mClient_expressionClient, _Ad4mClient_languageClient, _Ad4mClient_neighbourhoodClient, _Ad4mClient_perspectiveClient, _Ad4mClient_runtimeClient, _Ad4mClient_aiClient, _Ad4mClient_identityClient;
21672
22347
  /**
21673
22348
  * Client for the Ad4m interface wrapping WebSocket RPC calls
21674
22349
  * for convenient use in user facing code.
@@ -21692,6 +22367,7 @@ class Ad4mClient {
21692
22367
  _Ad4mClient_perspectiveClient.set(this, void 0);
21693
22368
  _Ad4mClient_runtimeClient.set(this, void 0);
21694
22369
  _Ad4mClient_aiClient.set(this, void 0);
22370
+ _Ad4mClient_identityClient.set(this, void 0);
21695
22371
  __classPrivateFieldSet$1(this, _Ad4mClient_baseUrl, baseUrl, "f");
21696
22372
  __classPrivateFieldSet$1(this, _Ad4mClient_token, token, "f");
21697
22373
  __classPrivateFieldSet$1(this, _Ad4mClient_apiClient, new ApiClient(baseUrl, token, options?.webSocketImpl, options?.fetchImpl), "f");
@@ -21705,6 +22381,7 @@ class Ad4mClient {
21705
22381
  __classPrivateFieldGet$1(this, _Ad4mClient_perspectiveClient, "f").setNeighbourhoodClient(__classPrivateFieldGet$1(this, _Ad4mClient_neighbourhoodClient, "f"));
21706
22382
  __classPrivateFieldGet$1(this, _Ad4mClient_perspectiveClient, "f").setAIClient(__classPrivateFieldGet$1(this, _Ad4mClient_aiClient, "f"));
21707
22383
  __classPrivateFieldSet$1(this, _Ad4mClient_runtimeClient, new RuntimeClient(baseUrl, token, __classPrivateFieldGet$1(this, _Ad4mClient_apiClient, "f")), "f");
22384
+ __classPrivateFieldSet$1(this, _Ad4mClient_identityClient, new IdentityClient(baseUrl, token, __classPrivateFieldGet$1(this, _Ad4mClient_apiClient, "f")), "f");
21708
22385
  // Register with AD4M DevTools if the bridge is installed (e.g. browser extension)
21709
22386
  try {
21710
22387
  const dt = globalThis.__AD4M_DEVTOOLS__;
@@ -21736,6 +22413,10 @@ class Ad4mClient {
21736
22413
  get ai() {
21737
22414
  return __classPrivateFieldGet$1(this, _Ad4mClient_aiClient, "f");
21738
22415
  }
22416
+ /** The executor's identity calls (`did:scid:coasys:1`). */
22417
+ get identity() {
22418
+ return __classPrivateFieldGet$1(this, _Ad4mClient_identityClient, "f");
22419
+ }
21739
22420
  /**
21740
22421
  * Call `handler` with every `type` event, or only those about
21741
22422
  * `filter.perspective`. The payload is typed by the executor's event
@@ -21754,13 +22435,21 @@ class Ad4mClient {
21754
22435
  onAuthFailed(callback) {
21755
22436
  return __classPrivateFieldGet$1(this, _Ad4mClient_apiClient, "f").onAuthFailed(callback);
21756
22437
  }
22438
+ /**
22439
+ * Reconnect now if the connection to the executor dropped and the client is
22440
+ * waiting out its backoff: for a host that knows the executor is back (it
22441
+ * restarted it, or the device woke). A no-op while connected or connecting.
22442
+ */
22443
+ reconnectNow() {
22444
+ __classPrivateFieldGet$1(this, _Ad4mClient_apiClient, "f").reconnectNow();
22445
+ }
21757
22446
  /** Close all event connections and clear in-memory caches */
21758
22447
  close() {
21759
22448
  __classPrivateFieldGet$1(this, _Ad4mClient_agentClient, "f").clearByDidCache();
21760
22449
  __classPrivateFieldGet$1(this, _Ad4mClient_apiClient, "f").closeAll();
21761
22450
  }
21762
22451
  }
21763
- _Ad4mClient_baseUrl = new WeakMap(), _Ad4mClient_token = new WeakMap(), _Ad4mClient_apiClient = new WeakMap(), _Ad4mClient_agentClient = new WeakMap(), _Ad4mClient_expressionClient = new WeakMap(), _Ad4mClient_languageClient = new WeakMap(), _Ad4mClient_neighbourhoodClient = new WeakMap(), _Ad4mClient_perspectiveClient = new WeakMap(), _Ad4mClient_runtimeClient = new WeakMap(), _Ad4mClient_aiClient = new WeakMap();
22452
+ _Ad4mClient_baseUrl = new WeakMap(), _Ad4mClient_token = new WeakMap(), _Ad4mClient_apiClient = new WeakMap(), _Ad4mClient_agentClient = new WeakMap(), _Ad4mClient_expressionClient = new WeakMap(), _Ad4mClient_languageClient = new WeakMap(), _Ad4mClient_neighbourhoodClient = new WeakMap(), _Ad4mClient_perspectiveClient = new WeakMap(), _Ad4mClient_runtimeClient = new WeakMap(), _Ad4mClient_aiClient = new WeakMap(), _Ad4mClient_identityClient = new WeakMap();
21764
22453
 
21765
22454
  var ExceptionType;
21766
22455
  (function (ExceptionType) {
@@ -22716,10 +23405,12 @@ class FlowInstance {
22716
23405
  // synthetic hydration field and would be silently shadowed on read).
22717
23406
  // No explicit start-time field: Ad4mModel synthesises `createdAt` on
22718
23407
  // hydration from the earliest link timestamp on the instance's URI.
22719
- // Convention: `SHACLFlow.states` is stored sorted ascending by `value`
22720
- // (enforced by `fromLinks`), so `states[0]` is the initial state. A
22721
- // flow author who wants a specific state as the entry point must give
22722
- // it the lowest `value` in the set.
23408
+ // Convention: `SHACLFlow.states` is stored sorted ascending by `value`,
23409
+ // ties broken by state name (enforced by `fromLinks`, same key as
23410
+ // rust-executor — #1202), so `states[0]` is the initial state. A flow
23411
+ // author who wants a specific state as the entry point must give it
23412
+ // the lowest `value` in the set, and not share that value with another
23413
+ // state unless the name order is the intended one.
22723
23414
  //
22724
23415
  // A run already on this subject for this flow is the one to return:
22725
23416
  // minting another would leave two runs, each with its own state, and
@@ -23368,6 +24059,17 @@ class WakerSubscriptionManager {
23368
24059
  /** Subscriptions the executor rejected, waiting to be re-attempted. */
23369
24060
  this.pendingSubscriptions = new Map();
23370
24061
  this.retryTimer = null;
24062
+ /** Re-attempt rounds in a row that left something pending, for the backoff. */
24063
+ this.retryRounds = 0;
24064
+ /**
24065
+ * Subscriptions that were active until one of their live queries lost its
24066
+ * executor subscription (a reconnect, a failed resync) and failed to open it
24067
+ * again, with the proxies still re-opening. The query retries on its own,
24068
+ * with backoff, so the manager does not subscribe them again; it reports
24069
+ * them as pending instead of active until every proxy is open again, and
24070
+ * keeps persisting them so a restart restores them (#1595).
24071
+ */
24072
+ this.reopening = new Map();
23371
24073
  /**
23372
24074
  * Cancellation tokens for in-flight `subscribe()` calls.
23373
24075
  *
@@ -23407,6 +24109,7 @@ class WakerSubscriptionManager {
23407
24109
  this.QuerySubscriptionProxyCtor = options.QuerySubscriptionProxy ?? null;
23408
24110
  this.previousSeenMessages = options.previousSeenMessages ?? {};
23409
24111
  this.retryPendingMs = options.retryPendingMs ?? 30000;
24112
+ this.maxRetryPendingMs = Math.max(this.retryPendingMs, options.maxRetryPendingMs ?? 300000);
23410
24113
  this.subscribeTimeoutMs = options.subscribeTimeoutMs ?? 15000;
23411
24114
  this.retryWakeMs = options.retryWakeMs ?? 5000;
23412
24115
  }
@@ -23425,8 +24128,9 @@ class WakerSubscriptionManager {
23425
24128
  * If a subscription with the same id already exists, it is disposed first.
23426
24129
  */
23427
24130
  async subscribe(sub) {
23428
- // Dispose existing subscription with same id if any
23429
- this.dispose(sub.id, false);
24131
+ // Dispose existing subscription with same id if any. Not `dispose()`: a
24132
+ // re-attempt must not start the backoff over.
24133
+ this.release(sub.id, false);
23430
24134
  const token = this.beginAttempt(sub.id);
23431
24135
  if (!this.QuerySubscriptionProxyCtor) {
23432
24136
  throw new Error("WakerSubscriptionManager: QuerySubscriptionProxy must be provided via constructor options");
@@ -23452,10 +24156,13 @@ class WakerSubscriptionManager {
23452
24156
  ? new QuerySubscriptionProxy(sub.perspective, sub.mentionQuery, this.perspectiveClient, sub.mentionClass)
23453
24157
  : undefined;
23454
24158
  const proxies = mentionProxy ? [proxy, mentionProxy] : [proxy];
24159
+ // `cancelOpening`: a handshake given up on must not keep the executor
24160
+ // computing a first result nobody reads; abandoned ones piled up into
24161
+ // hundreds of busy executor threads on staging (#1595).
23455
24162
  const disposeProxies = () => {
23456
24163
  for (const p of proxies) {
23457
24164
  try {
23458
- p.dispose();
24165
+ p.dispose({ cancelOpening: true });
23459
24166
  }
23460
24167
  catch { }
23461
24168
  }
@@ -23507,7 +24214,7 @@ class WakerSubscriptionManager {
23507
24214
  // turn this into an error result instead of a false "Subscribed" reply.
23508
24215
  throw new Error(`Waker subscription ${sub.id} failed: ${msg}${hintFor(msg)}` +
23509
24216
  (this.retryPendingMs > 0
23510
- ? `. Not listening yet — re-attempting every ${Math.round(this.retryPendingMs / 1000)}s; check ad4m_list_waker_subscriptions.`
24217
+ ? `. Not listening yet — re-attempting within ${Math.round(this.retryCeiling() / 1000)}s, then less often (at most every ${Math.round(this.maxRetryPendingMs / 1000)}s); check ad4m_list_waker_subscriptions.`
23511
24218
  : ""));
23512
24219
  }
23513
24220
  if (this.isStale(sub.id, token)) {
@@ -23515,6 +24222,8 @@ class WakerSubscriptionManager {
23515
24222
  return;
23516
24223
  }
23517
24224
  this.pendingSubscriptions.delete(sub.id);
24225
+ if (this.pendingSubscriptions.size === 0)
24226
+ this.retryRounds = 0;
23518
24227
  this.logger.info(`[waker] ${sub.id}: subscription initialized successfully`);
23519
24228
  // Seed from persisted seen messages so we don't re-wake after restart
23520
24229
  const restored = Object.prototype.hasOwnProperty.call(this.previousSeenMessages, sub.id);
@@ -23608,6 +24317,9 @@ class WakerSubscriptionManager {
23608
24317
  };
23609
24318
  proxy.onResult((result) => handleResult(result));
23610
24319
  mentionProxy?.onResult((result) => handleResult(result, false, " (mention query)"));
24320
+ for (const p of proxies) {
24321
+ p.onStatus?.((status) => this.onReopenStatus(sub, proxies, p, status));
24322
+ }
23611
24323
  if (this.isStale(sub.id, token)) {
23612
24324
  disposeProxies();
23613
24325
  return;
@@ -23630,6 +24342,51 @@ class WakerSubscriptionManager {
23630
24342
  this.persist();
23631
24343
  this.logger.info(`[waker] Subscription ${sub.id} active (type=${sub.type}, perspective=${sub.perspective})`);
23632
24344
  }
24345
+ /**
24346
+ * A proxy of `sub` failed to re-open its live query, or re-opened it after
24347
+ * failing. `sub` counts as active again once none of its proxies is still
24348
+ * re-opening. `proxies` tells a status of a replaced subscription apart.
24349
+ */
24350
+ onReopenStatus(sub, proxies, proxy, status) {
24351
+ if (this.proxies.get(sub.id) !== proxies)
24352
+ return;
24353
+ if (status?.state === "reopening") {
24354
+ const entry = this.reopening.get(sub.id) ?? { sub, proxies: new Set() };
24355
+ entry.proxies.add(proxy);
24356
+ if (!this.reopening.has(sub.id)) {
24357
+ this.reopening.set(sub.id, entry);
24358
+ this.activeSubscriptions.delete(sub.id);
24359
+ this.logger.warn(`[waker] ${sub.id}: live query lost after a reconnect and could not be re-opened (${status.error?.message ?? status.error}); not listening, retrying in ${Math.round((status.retryInMs ?? 0) / 1000)}s`);
24360
+ }
24361
+ return;
24362
+ }
24363
+ if (status?.state !== "open")
24364
+ return;
24365
+ const entry = this.reopening.get(sub.id);
24366
+ if (!entry)
24367
+ return;
24368
+ entry.proxies.delete(proxy);
24369
+ if (entry.proxies.size > 0)
24370
+ return;
24371
+ this.reopening.delete(sub.id);
24372
+ this.activeSubscriptions.set(sub.id, sub);
24373
+ this.logger.info(`[waker] ${sub.id}: live query re-opened, listening again`);
24374
+ // Wakes held back while it was not active go out now, not with the next mention.
24375
+ if (this.undelivered.get(sub.id)?.size)
24376
+ this.scheduleMentionWake(sub, proxy.result, this.debounceMs);
24377
+ }
24378
+ /** The wait before the next re-attempt round: `retryPendingMs` doubled per
24379
+ * round in a row that left something pending, capped at
24380
+ * `maxRetryPendingMs`, and between half and all of that, so wakers of a
24381
+ * restarted executor do not all retry at once. */
24382
+ nextRetryDelay() {
24383
+ const ceiling = this.retryCeiling();
24384
+ return ceiling / 2 + Math.random() * (ceiling / 2);
24385
+ }
24386
+ /** The longest the next re-attempt round waits. */
24387
+ retryCeiling() {
24388
+ return Math.min(this.retryPendingMs * 2 ** this.retryRounds, this.maxRetryPendingMs);
24389
+ }
23633
24390
  /** Arm the re-attempt timer if pending subscriptions are waiting. */
23634
24391
  scheduleRetry() {
23635
24392
  if (this.retryPendingMs <= 0)
@@ -23638,8 +24395,9 @@ class WakerSubscriptionManager {
23638
24395
  return;
23639
24396
  this.retryTimer = setTimeout(() => {
23640
24397
  this.retryTimer = null;
24398
+ this.retryRounds++;
23641
24399
  void this.retryPending();
23642
- }, this.retryPendingMs);
24400
+ }, this.nextRetryDelay());
23643
24401
  if (typeof this.retryTimer.unref === "function")
23644
24402
  this.retryTimer.unref();
23645
24403
  }
@@ -23673,26 +24431,39 @@ class WakerSubscriptionManager {
23673
24431
  }
23674
24432
  }
23675
24433
  }
23676
- /** Subscriptions that were rejected and are waiting to be re-attempted. */
24434
+ /** Subscriptions that are not listening and are being re-attempted: the
24435
+ * ones the executor rejected, and active ones whose live query is
24436
+ * re-opening after a reconnect. */
23677
24437
  getPending() {
23678
- return Array.from(this.pendingSubscriptions.values());
24438
+ return [
24439
+ ...this.pendingSubscriptions.values(),
24440
+ ...Array.from(this.reopening.values(), (entry) => entry.sub),
24441
+ ];
23679
24442
  }
23680
24443
  /**
23681
24444
  * Dispose a single subscription.
23682
24445
  * @param persist — if false, skip calling onPersist (used during batch cleanup).
23683
24446
  */
23684
24447
  dispose(id, persist = true) {
24448
+ this.release(id, persist);
24449
+ if (this.pendingSubscriptions.size === 0)
24450
+ this.retryRounds = 0;
24451
+ }
24452
+ /** Drop everything held for `id`, as `dispose()` does, but leave the
24453
+ * re-attempt backoff as it is. */
24454
+ release(id, persist) {
23685
24455
  // Invalidate any subscribe() for this id that is still awaiting.
23686
24456
  this.generations.set(id, (this.generations.get(id) ?? 0) + 1);
23687
24457
  for (const proxy of this.proxies.get(id) ?? []) {
23688
24458
  try {
23689
- proxy.dispose();
24459
+ proxy.dispose({ cancelOpening: true });
23690
24460
  }
23691
24461
  catch {
23692
24462
  /* ignore */
23693
24463
  }
23694
24464
  }
23695
24465
  this.proxies.delete(id);
24466
+ this.reopening.delete(id);
23696
24467
  const timer = this.debounceTimers.get(id);
23697
24468
  if (timer) {
23698
24469
  clearTimeout(timer);
@@ -23765,6 +24536,8 @@ class WakerSubscriptionManager {
23765
24536
  this.dispose(id, false);
23766
24537
  }
23767
24538
  this.pendingSubscriptions.clear();
24539
+ this.reopening.clear();
24540
+ this.retryRounds = 0;
23768
24541
  if (this.retryTimer) {
23769
24542
  clearTimeout(this.retryTimer);
23770
24543
  this.retryTimer = null;
@@ -23824,7 +24597,9 @@ class WakerSubscriptionManager {
23824
24597
  for (const [id, set] of this.delivered) {
23825
24598
  seen[id] = Array.from(set);
23826
24599
  }
23827
- this.onPersist(this.getActive(), seen);
24600
+ // A subscription that is re-opening was enrolled and is coming back: a
24601
+ // restart in the meantime must restore it.
24602
+ this.onPersist([...this.getActive(), ...Array.from(this.reopening.values(), (entry) => entry.sub)], seen);
23828
24603
  }
23829
24604
  }
23830
24605
  }
@@ -24269,4 +25044,4 @@ const SCOPED_EVENTS = new Set([
24269
25044
  "flow-state-changed",
24270
25045
  ]);
24271
25046
 
24272
- export { ACCEPTED_BY_GETTER, AIClient, Model as AIModel, AIModelLoadingStatus, AIPromptExamples, AIPromptExamplesInput, AITask, AITaskInput, Ad4mClient, Ad4mModel, Agent, AgentClient, AgentExpression, AgentSignature, AgentStatus, Apps, AuthInfo, AuthInfoInput, AutoProcessorConfig, BelongsToMany, BelongsToOne, CALL_PROTOCOL_VERSION, Capability, CapabilityInput, ComputeLogEntry, Container, DEFAULT_ICE_SERVERS, EntanglementProof, EntanglementProofInput, ExceptionInfo, ExceptionType, Expression, ExpressionGeneric, ExpressionGenericInput, ExpressionProof, ExpressionProofInput, ExpressionRef, ExpressionRendered, Flag, FlowInstance, FlowInstanceRecord, FlowTransitionProposal, HasMany, HasOne, HostingUserInfo, IDBCache, Icon, ImportResult, ImportStats, InteractionCall, InteractionMeta, InteractionParameter, InterpretationOverlay, InterpretationRun, LONG_METHODS, LONG_TIMEOUT_MS, LanguageExpression, LanguageHandle, LanguageLanguageInput, LanguageMeta, LanguageMetaInput, LanguageMetaInternal, LanguageRef, Link, LinkExpression, LinkExpressionInput, LinkExpressionMutations, LinkExpressionUpdated, LinkInput, LinkMutations, LinkQuery, Literal, LiveQuery, LocalModel, LocalModelInput, MENTION_TEXT_LIMIT, Mentioning, MeshManager, Model$1 as Model, ModelApi, ModelApiInput, ModelInput, ModelQueryBuilder, Neighbourhood, NeighbourhoodExpression, NeighbourhoodProxy, Notification, NotificationInput, NullCache, OnlineAgent, Optional, PROPOSER_GETTER, PaymentRequestResult, Perspective, PerspectiveDiff, PerspectiveDiffExpression, PerspectiveExpression, PerspectiveHandle, PerspectiveInput, PerspectiveProxy, PerspectiveState, PerspectiveUnsignedInput, Property, QuerySubscriptionProxy, READ_METHODS, ReadOnly, Resource, ResourceInput, RpcError, RuntimeInfo, SCOPED_EVENTS, SHACLFlow, SHACLShape, SMART_LITERAL_CONTENT_PREDICATE, SentMessage, SmartLiteral, TextContent, TokenizerSource, TokenizerSourceInput, TriggeredNotification, UserCreationResult, UserStatistics, VerificationRequestResult, VoiceActivityParamsInput, WakerSubscriptionManager, applyUpdate, buildConformanceFilter, buildModelFromJSONSchema, buildPaginationSubquery, buildSDNA, buildSHACL, buildSPARQLQuery, buildWhereCondition, capSentence, clearQueryCache, coalesce, compileWhereClause, concat, createPersistentCache, createTelepresenceChannel, determineNamespace, determinePredicate, effectiveLiteralStorage, escapeQueryString, exists, exprRef2String, fileToDataUri, fn, focus, formatList, formatQueryValue, formatSPARQLValue, getCachedResult, getDefaultValueForType, getMemoizedSHACL, getPropertiesMetadata, getPropertyOption, getRelationsMetadata, hasJsOnlyWhereFilters, hintFor, holdsAWholeWordTerm, ifExpr, invalidatePerspectiveCache, isArrayType, isContainedScope, isContainmentTraversal, isExpression, isIncludeProjection, isLink, isNodeExpression, isNumericType, isObjectType, isSchemaType, isTraverseScope, linkEqual, linkExpressionInputToWire, linkExpressionToWire, linkMutationsToWire, literal, looksLikeUri, mentionOf, neighbourhoodExpressionFromWire, normalizeNamespaceString, normalizeSchemaType, normalizeValue, normalizeWhereForSparql, parseCallMessage, parseExprUrl, parseLit, parseLitBoolean, parseLitNumber, parseSparqlCount, path, queryCacheSize, requireSingleParent, resolveParentPredicate, setCachedResult, setPropertyRegistryEntry, setRelationRegistryEntry, typeDefsString, valueToLiteralIri };
25047
+ export { ACCEPTED_BY_GETTER, AIClient, Model as AIModel, AIModelLoadingStatus, AIPromptExamples, AIPromptExamplesInput, AITask, AITaskInput, Ad4mClient, Ad4mModel, Agent, AgentClient, AgentExpression, AgentSignature, AgentStatus, Apps, AuthInfo, AuthInfoInput, AutoProcessorConfig, BelongsToMany, BelongsToOne, CALL_PROTOCOL_VERSION, Capability, CapabilityInput, ComputeLogEntry, Container, DEFAULT_ICE_SERVERS, EntanglementProof, EntanglementProofInput, ExceptionInfo, ExceptionType, Expression, ExpressionGeneric, ExpressionGenericInput, ExpressionProof, ExpressionProofInput, ExpressionRef, ExpressionRendered, Flag, FlowInstance, FlowInstanceRecord, FlowTransitionProposal, HasMany, HasOne, HostingUserInfo, IDBCache, Icon, IdentityClient, ImportResult, ImportStats, InteractionCall, InteractionMeta, InteractionParameter, InterpretationOverlay, InterpretationRun, LONG_METHODS, LONG_TIMEOUT_MS, LanguageExpression, LanguageHandle, LanguageLanguageInput, LanguageMeta, LanguageMetaInput, LanguageMetaInternal, LanguageRef, Link, LinkExpression, LinkExpressionInput, LinkExpressionMutations, LinkExpressionUpdated, LinkInput, LinkMutations, LinkQuery, Literal, LiveQuery, LocalModel, LocalModelInput, MENTION_TEXT_LIMIT, Mentioning, MeshManager, Model$1 as Model, ModelApi, ModelApiInput, ModelInput, ModelQueryBuilder, Neighbourhood, NeighbourhoodExpression, NeighbourhoodProxy, Notification, NotificationInput, NullCache, OnlineAgent, Optional, PROPOSER_GETTER, PaymentRequestResult, Perspective, PerspectiveDiff, PerspectiveDiffExpression, PerspectiveExpression, PerspectiveHandle, PerspectiveInput, PerspectiveProxy, PerspectiveState, PerspectiveUnsignedInput, Property, QuerySubscriptionProxy, READ_METHODS, REOPEN_BASE_DELAY_MS, REOPEN_MAX_DELAY_MS, ReadOnly, Resource, ResourceInput, RpcError, RuntimeInfo, SCOPED_EVENTS, SHACLFlow, SHACLShape, SMART_LITERAL_CONTENT_PREDICATE, SentMessage, SmartLiteral, TextContent, TokenizerSource, TokenizerSourceInput, TriggeredNotification, UserCreationResult, UserStatistics, VerificationRequestResult, VoiceActivityParamsInput, WakerSubscriptionManager, applyUpdate, buildConformanceFilter, buildModelFromJSONSchema, buildPaginationSubquery, buildSDNA, buildSHACL, buildSPARQLQuery, buildWhereCondition, capSentence, clearQueryCache, coalesce, compileWhereClause, concat, createPersistentCache, createTelepresenceChannel, determineNamespace, determinePredicate, effectiveLiteralStorage, escapeQueryString, exists, exprRef2String, fileToDataUri, fn, focus, formatList, formatQueryValue, formatSPARQLValue, getCachedResult, getDefaultValueForType, getMemoizedSHACL, getPropertiesMetadata, getPropertyOption, getRelationsMetadata, hasJsOnlyWhereFilters, hintFor, holdsAWholeWordTerm, ifExpr, invalidatePerspectiveCache, isArrayType, isContainedScope, isContainmentTraversal, isExpression, isIncludeProjection, isLink, isNodeExpression, isNumericType, isObjectType, isSchemaType, isTraverseScope, linkEqual, linkExpressionInputToWire, linkExpressionToWire, linkMutationsToWire, literal, looksLikeUri, mentionOf, neighbourhoodExpressionFromWire, normalizeNamespaceString, normalizeSchemaType, normalizeValue, normalizeWhereForSparql, parseCallMessage, parseExprUrl, parseLit, parseLitBoolean, parseLitNumber, parseSparqlCount, path, queryCacheSize, reopenDelay, requireSingleParent, resolveParentPredicate, setCachedResult, setPropertyRegistryEntry, setRelationRegistryEntry, typeDefsString, valueToLiteralIri };