@coasys/ad4m-connect 0.13.1-staging.4 → 0.13.1-staging.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/core.js CHANGED
@@ -39,7 +39,7 @@ var __async = (__this, __arguments, generator) => {
39
39
  };
40
40
 
41
41
  // ../package.json
42
- var version = "0.13.1-staging.4";
42
+ var version = "0.13.1-staging.6";
43
43
 
44
44
  // src/utils.ts
45
45
  function isEmbedded() {
@@ -349,6 +349,7 @@ var LONG_METHODS = /* @__PURE__ */ new Set([
349
349
  "language.publish",
350
350
  "neighbourhood.join",
351
351
  "neighbourhood.publish",
352
+ "perspective.runAgent",
352
353
  "perspective.runInterpretation",
353
354
  "perspective.runInterpretationWithHarness",
354
355
  "runtime.restartHolochain"
@@ -367,6 +368,18 @@ var INITIAL_RECONNECT_DELAY_MS = 500;
367
368
  var MAX_RECONNECT_DELAY_MS = 3e4;
368
369
  var WATCH_RETRY_DELAY_MS = 1e3;
369
370
  var MAX_WATCH_RETRIES = 5;
371
+ var PING_INTERVAL_MS = 1e4;
372
+ var SLOWEST_LINK_BYTES_PER_MS = 16;
373
+ var PONG_RETURN_MS = 5e3;
374
+ function utf8Length(text) {
375
+ let bytes = text.length;
376
+ for (let i = 0; i < text.length; i++) {
377
+ const unit = text.charCodeAt(i);
378
+ if (unit >= 128)
379
+ bytes += unit < 2048 || unit >= 55296 && unit <= 57343 ? 1 : 2;
380
+ }
381
+ return bytes;
382
+ }
370
383
  var _idCounter2 = 0;
371
384
  function nextId() {
372
385
  return String(++_idCounter2);
@@ -388,12 +401,21 @@ var ApiClient = class {
388
401
  this._wsReconnectTimer = null;
389
402
  this._wsReconnectDelay = INITIAL_RECONNECT_DELAY_MS;
390
403
  this._wsPingTimer = null;
404
+ this._wsPingedAt = null;
405
+ this._wsPingArrivesBy = 0;
406
+ this._wsSentBy = 0;
391
407
  this._watching = "{}";
392
408
  this._watchScheduled = false;
393
409
  this._watchDone = Promise.resolve();
394
410
  this._watchSent = Promise.resolve();
395
411
  this._watchRetries = 0;
396
412
  this._watchRetryTimer = null;
413
+ this._wakeListening = false;
414
+ this._onWake = (event) => {
415
+ if (event.type === "visibilitychange" && typeof document !== "undefined" && document.visibilityState !== "visible")
416
+ return;
417
+ this.reconnectNow();
418
+ };
397
419
  this.baseUrl = baseUrl;
398
420
  this.token = token;
399
421
  this._webSocketImpl = webSocketImpl;
@@ -418,6 +440,7 @@ var ApiClient = class {
418
440
  return;
419
441
  if (this._authFailed !== null)
420
442
  throw new RpcError(401, this._authFailed);
443
+ this._cancelReconnect();
421
444
  const WsImpl = this._webSocketImpl ?? globalThis.WebSocket;
422
445
  const ws = new WsImpl(this._getWsUrl());
423
446
  this._ws = ws;
@@ -438,6 +461,8 @@ var ApiClient = class {
438
461
  this._wsOpen.catch(() => {
439
462
  });
440
463
  ws.onmessage = (event) => {
464
+ if (this._ws === ws)
465
+ this._wsPingedAt = null;
441
466
  let parsed;
442
467
  try {
443
468
  parsed = JSON.parse(event.data);
@@ -460,7 +485,7 @@ var ApiClient = class {
460
485
  this._failAuth(rpcError.body);
461
486
  return;
462
487
  }
463
- if (parsed.type === "pong")
488
+ if (parsed.type === "pong" || this._ws !== ws)
464
489
  return;
465
490
  const perspective = parsed.perspectiveUuid;
466
491
  const regs = this._handlers.get(parsed.type);
@@ -480,13 +505,13 @@ var ApiClient = class {
480
505
  if (this._ws !== ws)
481
506
  return;
482
507
  this._wsReconnectDelay = INITIAL_RECONNECT_DELAY_MS;
483
- this._startPing();
508
+ this._startPing(ws);
484
509
  this._watching = "{}";
485
510
  this._watchRetries = 0;
486
511
  this._flushWatch();
487
512
  for (const pending of this._pendingCalls.values()) {
488
513
  if (!pending.sent) {
489
- ws.send(pending.message);
514
+ this._send(ws, pending.message);
490
515
  pending.sent = true;
491
516
  }
492
517
  }
@@ -531,13 +556,36 @@ var ApiClient = class {
531
556
  for (const cb of [...this._authFailedCallbacks])
532
557
  callSafely(cb, "Error in auth-failed callback:", reason);
533
558
  }
534
- _startPing() {
559
+ _startPing(ws) {
535
560
  this._stopPing();
561
+ this._wsPingedAt = null;
562
+ this._wsSentBy = 0;
536
563
  this._wsPingTimer = setInterval(() => {
537
- if (this._ws?.readyState === 1) {
538
- this._ws.send(JSON.stringify({ type: "ping" }));
564
+ if (this._ws !== ws)
565
+ return;
566
+ const ping = JSON.stringify({ type: "ping" });
567
+ if (this._wsPingedAt === null) {
568
+ this._wsPingedAt = performance.now();
569
+ this._send(ws, ping);
570
+ this._wsPingArrivesBy = this._wsSentBy;
571
+ return;
572
+ }
573
+ if (performance.now() >= Math.max(this._wsPingedAt + PING_INTERVAL_MS, this._wsPingArrivesBy + PONG_RETURN_MS)) {
574
+ this._dropSilentSocket(ws);
575
+ return;
539
576
  }
540
- }, 3e4);
577
+ this._send(ws, ping);
578
+ }, PING_INTERVAL_MS);
579
+ }
580
+ _send(ws, text) {
581
+ if (this._ws === ws)
582
+ this._wsSentBy = Math.max(this._wsSentBy, performance.now()) + utf8Length(text) / SLOWEST_LINK_BYTES_PER_MS;
583
+ ws.send(text);
584
+ }
585
+ _dropSilentSocket(ws) {
586
+ console.warn(`WebSocket silent for ${performance.now() - (this._wsPingedAt ?? performance.now())} ms after a ping; reconnecting`);
587
+ this._onClose(ws);
588
+ ws.close();
541
589
  }
542
590
  _stopPing() {
543
591
  if (this._wsPingTimer) {
@@ -552,8 +600,40 @@ var ApiClient = class {
552
600
  this._wsReconnectDelay = Math.min(this._wsReconnectDelay * 2, MAX_RECONNECT_DELAY_MS);
553
601
  this._wsReconnectTimer = setTimeout(() => {
554
602
  this._wsReconnectTimer = null;
603
+ this._listenForWake(false);
555
604
  this._ensureWs();
556
605
  }, delay);
606
+ this._listenForWake(true);
607
+ }
608
+ _cancelReconnect() {
609
+ if (this._wsReconnectTimer) {
610
+ clearTimeout(this._wsReconnectTimer);
611
+ this._wsReconnectTimer = null;
612
+ }
613
+ this._listenForWake(false);
614
+ }
615
+ reconnectNow() {
616
+ if (!this._wsReconnectTimer || this._ws || this._authFailed !== null)
617
+ return;
618
+ this._cancelReconnect();
619
+ this._wsReconnectDelay = INITIAL_RECONNECT_DELAY_MS;
620
+ this._ensureWs();
621
+ }
622
+ _listenForWake(on) {
623
+ if (on === this._wakeListening)
624
+ return;
625
+ const win = typeof window !== "undefined" ? window : void 0;
626
+ if (typeof win?.addEventListener !== "function")
627
+ return;
628
+ const doc = typeof document !== "undefined" && typeof document.addEventListener === "function" ? document : void 0;
629
+ this._wakeListening = on;
630
+ if (on) {
631
+ win.addEventListener("online", this._onWake);
632
+ doc?.addEventListener("visibilitychange", this._onWake);
633
+ } else {
634
+ win.removeEventListener("online", this._onWake);
635
+ doc?.removeEventListener("visibilitychange", this._onWake);
636
+ }
557
637
  }
558
638
  call(method, params, options) {
559
639
  this._flushWatch();
@@ -585,7 +665,7 @@ var ApiClient = class {
585
665
  }, timeoutMs);
586
666
  const onAbort = () => {
587
667
  if (pending.sent && this._ws?.readyState === 1) {
588
- this._ws.send(JSON.stringify({ id: nextId(), type: "request.cancel", params: { targetId: id } }));
668
+ this._send(this._ws, JSON.stringify({ id: nextId(), type: "request.cancel", params: { targetId: id } }));
589
669
  }
590
670
  settle(() => reject(new DOMException("Aborted", "AbortError")));
591
671
  };
@@ -607,7 +687,7 @@ var ApiClient = class {
607
687
  return;
608
688
  }
609
689
  if (this._ws.readyState === 1) {
610
- this._ws.send(message);
690
+ this._send(this._ws, message);
611
691
  pending.sent = true;
612
692
  }
613
693
  });
@@ -707,10 +787,7 @@ var ApiClient = class {
707
787
  clearTimeout(this._watchRetryTimer);
708
788
  this._watchRetryTimer = null;
709
789
  }
710
- if (this._wsReconnectTimer) {
711
- clearTimeout(this._wsReconnectTimer);
712
- this._wsReconnectTimer = null;
713
- }
790
+ this._cancelReconnect();
714
791
  const ws = this._ws;
715
792
  this._ws = null;
716
793
  this._wsOpen = null;
@@ -1628,6 +1705,7 @@ var SfuManager = class {
1628
1705
  this.rosterUnsubscribe = null;
1629
1706
  this.dataChannelUnsubscribe = null;
1630
1707
  this.disconnectedTimer = null;
1708
+ this.unlistedTimer = null;
1631
1709
  this.neighbourhood = neighbourhood;
1632
1710
  this.neighbourhoodUrl = neighbourhoodUrl || "";
1633
1711
  this.roomId = roomId;
@@ -1851,6 +1929,28 @@ var SfuManager = class {
1851
1929
  this.renegotiationUnsubscribe = null;
1852
1930
  this.rosterUnsubscribe?.();
1853
1931
  this.rosterUnsubscribe = null;
1932
+ this.clearUnlistedTimer();
1933
+ }
1934
+ clearUnlistedTimer() {
1935
+ if (this.unlistedTimer) {
1936
+ clearTimeout(this.unlistedTimer);
1937
+ this.unlistedTimer = null;
1938
+ }
1939
+ }
1940
+ noticeRoster(pc, dids) {
1941
+ if (dids.includes(this.agentDid)) {
1942
+ this.clearUnlistedTimer();
1943
+ return;
1944
+ }
1945
+ if (this.unlistedTimer)
1946
+ return;
1947
+ this.unlistedTimer = setTimeout(() => {
1948
+ this.unlistedTimer = null;
1949
+ if (this.state.peerConnection !== pc)
1950
+ return;
1951
+ console.info("SFU: the room no longer lists this session, rebuilding the call");
1952
+ void this.reconnect();
1953
+ }, SfuManager.UNLISTED_GRACE_MS);
1854
1954
  }
1855
1955
  abandon(pc) {
1856
1956
  this.releaseServerEvents();
@@ -1870,8 +1970,10 @@ var SfuManager = class {
1870
1970
  if (!ours(roster) || this.state.peerConnection !== pc)
1871
1971
  return;
1872
1972
  void joined.then(() => {
1873
- if (this.state.peerConnection === pc)
1874
- this.applyRoster(roster.participants, true);
1973
+ if (this.state.peerConnection !== pc)
1974
+ return;
1975
+ this.applyRoster(roster.participants, true);
1976
+ this.noticeRoster(pc, roster.participants);
1875
1977
  });
1876
1978
  });
1877
1979
  for (const unsubscribe of previous)
@@ -2037,6 +2139,7 @@ var SfuManager = class {
2037
2139
  SfuManager.MAX_RECONNECTS = 3;
2038
2140
  SfuManager.REJOIN_WINDOW_MS = 12e4;
2039
2141
  SfuManager.DISCONNECT_GRACE_MS = 1e4;
2142
+ SfuManager.UNLISTED_GRACE_MS = 3e3;
2040
2143
  var CALL_PROTOCOL_VERSION = 1;
2041
2144
  function parseCallMessage(payload) {
2042
2145
  if (typeof payload !== "object" || payload === null)
@@ -4822,10 +4925,23 @@ var _LiveQuery_latest;
4822
4925
  var _LiveQuery_buffer;
4823
4926
  var _LiveQuery_unlisten;
4824
4927
  var _LiveQuery_unreconnect;
4928
+ var _LiveQuery_opening;
4929
+ var _LiveQuery_retryTimer;
4930
+ var _LiveQuery_reopening;
4931
+ var _LiveQuery_statusListeners;
4825
4932
  var _LiveQuery_start;
4933
+ var _LiveQuery_reopen;
4934
+ var _LiveQuery_clearRetry;
4935
+ var _LiveQuery_emit;
4826
4936
  var _LiveQuery_replace;
4827
4937
  var _LiveQuery_receive;
4828
4938
  var _LiveQuery_resync;
4939
+ var REOPEN_BASE_DELAY_MS = 1e3;
4940
+ var REOPEN_MAX_DELAY_MS = 6e4;
4941
+ function reopenDelay(failures, random = Math.random) {
4942
+ const ceiling = Math.min(REOPEN_BASE_DELAY_MS * 2 ** Math.max(0, failures - 1), REOPEN_MAX_DELAY_MS);
4943
+ return ceiling / 2 + random() * ceiling / 2;
4944
+ }
4829
4945
  function applyUpdate(result, update) {
4830
4946
  if ("result" in update)
4831
4947
  return update.result;
@@ -4872,14 +4988,19 @@ var LiveQuery = class {
4872
4988
  _LiveQuery_buffer.set(this, null);
4873
4989
  _LiveQuery_unlisten.set(this, void 0);
4874
4990
  _LiveQuery_unreconnect.set(this, void 0);
4991
+ _LiveQuery_opening.set(this, void 0);
4992
+ _LiveQuery_retryTimer.set(this, void 0);
4993
+ _LiveQuery_reopening.set(this, false);
4994
+ _LiveQuery_statusListeners.set(
4995
+ this,
4996
+ /* @__PURE__ */ new Set()
4997
+ );
4875
4998
  __classPrivateFieldSet$7(this, _LiveQuery_client, client, "f");
4876
4999
  __classPrivateFieldSet$7(this, _LiveQuery_uuid, uuid, "f");
4877
5000
  __classPrivateFieldSet$7(this, _LiveQuery_open, open, "f");
4878
5001
  __classPrivateFieldSet$7(this, _LiveQuery_onResult, onResult, "f");
4879
5002
  __classPrivateFieldSet$7(this, _LiveQuery_unlisten, client.onQueryUpdate((update) => __classPrivateFieldGet$7(this, _LiveQuery_instances, "m", _LiveQuery_receive).call(this, update)), "f");
4880
- __classPrivateFieldSet$7(this, _LiveQuery_unreconnect, client.onReconnect(() => {
4881
- this.start().catch((e) => console.error("Error re-opening live query after reconnect:", e));
4882
- }), "f");
5003
+ __classPrivateFieldSet$7(this, _LiveQuery_unreconnect, client.onReconnect(() => __classPrivateFieldGet$7(this, _LiveQuery_instances, "m", _LiveQuery_reopen).call(this)), "f");
4883
5004
  }
4884
5005
  get id() {
4885
5006
  return __classPrivateFieldGet$7(this, _LiveQuery_id, "f");
@@ -4887,31 +5008,48 @@ var LiveQuery = class {
4887
5008
  get result() {
4888
5009
  return __classPrivateFieldGet$7(this, _LiveQuery_result, "f");
4889
5010
  }
5011
+ get reopening() {
5012
+ return __classPrivateFieldGet$7(this, _LiveQuery_reopening, "f");
5013
+ }
5014
+ onStatus(listener) {
5015
+ __classPrivateFieldGet$7(this, _LiveQuery_statusListeners, "f").add(listener);
5016
+ return () => __classPrivateFieldGet$7(this, _LiveQuery_statusListeners, "f").delete(listener);
5017
+ }
4890
5018
  start() {
4891
5019
  var _a;
5020
+ __classPrivateFieldGet$7(this, _LiveQuery_instances, "m", _LiveQuery_clearRetry).call(this);
4892
5021
  __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");
4893
5022
  return __classPrivateFieldGet$7(this, _LiveQuery_latest, "f");
4894
5023
  }
4895
- dispose() {
5024
+ dispose(options = {}) {
4896
5025
  var _a;
4897
5026
  __classPrivateFieldSet$7(this, _LiveQuery_disposed, true, "f");
4898
5027
  __classPrivateFieldSet$7(this, _LiveQuery_generation, (_a = __classPrivateFieldGet$7(this, _LiveQuery_generation, "f"), _a++, _a), "f");
5028
+ __classPrivateFieldGet$7(this, _LiveQuery_instances, "m", _LiveQuery_clearRetry).call(this);
5029
+ __classPrivateFieldGet$7(this, _LiveQuery_statusListeners, "f").clear();
4899
5030
  __classPrivateFieldGet$7(this, _LiveQuery_unlisten, "f").call(this);
4900
5031
  __classPrivateFieldGet$7(this, _LiveQuery_unreconnect, "f").call(this);
5032
+ if (options.cancelOpening)
5033
+ __classPrivateFieldGet$7(this, _LiveQuery_opening, "f")?.abort();
4901
5034
  if (__classPrivateFieldGet$7(this, _LiveQuery_id, "f"))
4902
5035
  __classPrivateFieldGet$7(this, _LiveQuery_client, "f").disposeQuerySubscription(__classPrivateFieldGet$7(this, _LiveQuery_uuid, "f"), __classPrivateFieldGet$7(this, _LiveQuery_id, "f")).catch(() => {
4903
5036
  });
4904
5037
  }
4905
5038
  };
4906
- _LiveQuery_client = /* @__PURE__ */ new WeakMap(), _LiveQuery_uuid = /* @__PURE__ */ new WeakMap(), _LiveQuery_open = /* @__PURE__ */ new WeakMap(), _LiveQuery_onResult = /* @__PURE__ */ new WeakMap(), _LiveQuery_id = /* @__PURE__ */ new WeakMap(), _LiveQuery_revision = /* @__PURE__ */ new WeakMap(), _LiveQuery_result = /* @__PURE__ */ new WeakMap(), _LiveQuery_started = /* @__PURE__ */ new WeakMap(), _LiveQuery_disposed = /* @__PURE__ */ new WeakMap(), _LiveQuery_generation = /* @__PURE__ */ new WeakMap(), _LiveQuery_latest = /* @__PURE__ */ new WeakMap(), _LiveQuery_buffer = /* @__PURE__ */ new WeakMap(), _LiveQuery_unlisten = /* @__PURE__ */ new WeakMap(), _LiveQuery_unreconnect = /* @__PURE__ */ new WeakMap(), _LiveQuery_instances = /* @__PURE__ */ new WeakSet(), _LiveQuery_start = async function _LiveQuery_start2(generation) {
5039
+ _LiveQuery_client = /* @__PURE__ */ new WeakMap(), _LiveQuery_uuid = /* @__PURE__ */ new WeakMap(), _LiveQuery_open = /* @__PURE__ */ new WeakMap(), _LiveQuery_onResult = /* @__PURE__ */ new WeakMap(), _LiveQuery_id = /* @__PURE__ */ new WeakMap(), _LiveQuery_revision = /* @__PURE__ */ new WeakMap(), _LiveQuery_result = /* @__PURE__ */ new WeakMap(), _LiveQuery_started = /* @__PURE__ */ new WeakMap(), _LiveQuery_disposed = /* @__PURE__ */ new WeakMap(), _LiveQuery_generation = /* @__PURE__ */ new WeakMap(), _LiveQuery_latest = /* @__PURE__ */ new WeakMap(), _LiveQuery_buffer = /* @__PURE__ */ new WeakMap(), _LiveQuery_unlisten = /* @__PURE__ */ new WeakMap(), _LiveQuery_unreconnect = /* @__PURE__ */ new WeakMap(), _LiveQuery_opening = /* @__PURE__ */ new WeakMap(), _LiveQuery_retryTimer = /* @__PURE__ */ new WeakMap(), _LiveQuery_reopening = /* @__PURE__ */ new WeakMap(), _LiveQuery_statusListeners = /* @__PURE__ */ new WeakMap(), _LiveQuery_instances = /* @__PURE__ */ new WeakSet(), _LiveQuery_start = async function _LiveQuery_start2(generation) {
4907
5040
  __classPrivateFieldSet$7(this, _LiveQuery_buffer, [], "f");
5041
+ const opening = new AbortController();
5042
+ __classPrivateFieldSet$7(this, _LiveQuery_opening, opening, "f");
4908
5043
  let subscribed;
4909
5044
  try {
4910
- subscribed = await __classPrivateFieldGet$7(this, _LiveQuery_open, "f").call(this);
5045
+ subscribed = await __classPrivateFieldGet$7(this, _LiveQuery_open, "f").call(this, opening.signal);
4911
5046
  } catch (e) {
4912
5047
  if (generation === __classPrivateFieldGet$7(this, _LiveQuery_generation, "f"))
4913
5048
  __classPrivateFieldSet$7(this, _LiveQuery_buffer, null, "f");
4914
5049
  throw e;
5050
+ } finally {
5051
+ if (__classPrivateFieldGet$7(this, _LiveQuery_opening, "f") === opening)
5052
+ __classPrivateFieldSet$7(this, _LiveQuery_opening, void 0, "f");
4915
5053
  }
4916
5054
  if (__classPrivateFieldGet$7(this, _LiveQuery_disposed, "f") || generation !== __classPrivateFieldGet$7(this, _LiveQuery_generation, "f")) {
4917
5055
  __classPrivateFieldGet$7(this, _LiveQuery_client, "f").disposeQuerySubscription(__classPrivateFieldGet$7(this, _LiveQuery_uuid, "f"), subscribed.subscriptionId).catch(() => {
@@ -4921,6 +5059,44 @@ _LiveQuery_client = /* @__PURE__ */ new WeakMap(), _LiveQuery_uuid = /* @__PURE_
4921
5059
  __classPrivateFieldSet$7(this, _LiveQuery_id, subscribed.subscriptionId, "f");
4922
5060
  __classPrivateFieldGet$7(this, _LiveQuery_instances, "m", _LiveQuery_replace).call(this, subscribed.revision, subscribed.result);
4923
5061
  return __classPrivateFieldGet$7(this, _LiveQuery_result, "f");
5062
+ }, _LiveQuery_reopen = function _LiveQuery_reopen2(failures = 0) {
5063
+ if (__classPrivateFieldGet$7(this, _LiveQuery_disposed, "f"))
5064
+ return;
5065
+ const reopened = this.start();
5066
+ const generation = __classPrivateFieldGet$7(this, _LiveQuery_generation, "f");
5067
+ reopened.then(() => {
5068
+ if (__classPrivateFieldGet$7(this, _LiveQuery_disposed, "f") || generation !== __classPrivateFieldGet$7(this, _LiveQuery_generation, "f") || !__classPrivateFieldGet$7(this, _LiveQuery_reopening, "f"))
5069
+ return;
5070
+ __classPrivateFieldSet$7(this, _LiveQuery_reopening, false, "f");
5071
+ __classPrivateFieldGet$7(this, _LiveQuery_instances, "m", _LiveQuery_emit).call(this, { state: "open" });
5072
+ }, (error) => {
5073
+ if (__classPrivateFieldGet$7(this, _LiveQuery_disposed, "f") || generation !== __classPrivateFieldGet$7(this, _LiveQuery_generation, "f"))
5074
+ return;
5075
+ const retryInMs = reopenDelay(failures + 1);
5076
+ console.error(`Error re-opening live query (attempt ${failures + 1}), retrying in ${Math.round(retryInMs)}ms:`, error);
5077
+ __classPrivateFieldSet$7(this, _LiveQuery_reopening, true, "f");
5078
+ __classPrivateFieldGet$7(this, _LiveQuery_instances, "m", _LiveQuery_emit).call(this, { state: "reopening", error, retryInMs });
5079
+ const timer = setTimeout(() => {
5080
+ __classPrivateFieldSet$7(this, _LiveQuery_retryTimer, void 0, "f");
5081
+ __classPrivateFieldGet$7(this, _LiveQuery_instances, "m", _LiveQuery_reopen2).call(this, failures + 1);
5082
+ }, retryInMs);
5083
+ if (typeof timer?.unref === "function")
5084
+ timer.unref();
5085
+ __classPrivateFieldSet$7(this, _LiveQuery_retryTimer, timer, "f");
5086
+ });
5087
+ }, _LiveQuery_clearRetry = function _LiveQuery_clearRetry2() {
5088
+ if (__classPrivateFieldGet$7(this, _LiveQuery_retryTimer, "f") === void 0)
5089
+ return;
5090
+ clearTimeout(__classPrivateFieldGet$7(this, _LiveQuery_retryTimer, "f"));
5091
+ __classPrivateFieldSet$7(this, _LiveQuery_retryTimer, void 0, "f");
5092
+ }, _LiveQuery_emit = function _LiveQuery_emit2(status) {
5093
+ for (const listener of [...__classPrivateFieldGet$7(this, _LiveQuery_statusListeners, "f")]) {
5094
+ try {
5095
+ listener(status);
5096
+ } catch (e) {
5097
+ console.error("Error in live query status listener:", e);
5098
+ }
5099
+ }
4924
5100
  }, _LiveQuery_replace = function _LiveQuery_replace2(revision, result) {
4925
5101
  __classPrivateFieldSet$7(this, _LiveQuery_revision, revision, "f");
4926
5102
  __classPrivateFieldSet$7(this, _LiveQuery_result, result, "f");
@@ -4968,7 +5144,7 @@ _LiveQuery_client = /* @__PURE__ */ new WeakMap(), _LiveQuery_uuid = /* @__PURE_
4968
5144
  if (!__classPrivateFieldGet$7(this, _LiveQuery_disposed, "f") && generation === __classPrivateFieldGet$7(this, _LiveQuery_generation, "f")) {
4969
5145
  __classPrivateFieldGet$7(this, _LiveQuery_client, "f").disposeQuerySubscription(__classPrivateFieldGet$7(this, _LiveQuery_uuid, "f"), id).catch(() => {
4970
5146
  });
4971
- this.start().catch((e) => console.error("Error re-opening live query:", e));
5147
+ __classPrivateFieldGet$7(this, _LiveQuery_instances, "m", _LiveQuery_reopen).call(this);
4972
5148
  }
4973
5149
  });
4974
5150
  };
@@ -5474,7 +5650,7 @@ var QuerySubscriptionProxy = class {
5474
5650
  _QuerySubscriptionProxy_initialized.set(this, void 0);
5475
5651
  _QuerySubscriptionProxy_initResolve.set(this, void 0);
5476
5652
  _QuerySubscriptionProxy_initReject.set(this, void 0);
5477
- const open = className === void 0 ? () => client.subscribeQuery(uuid, query) : () => client.modelSubscribe(uuid, className, query);
5653
+ const open = className === void 0 ? (signal) => client.subscribeQuery(uuid, query, { signal }) : (signal) => client.modelSubscribe(uuid, className, query, { signal });
5478
5654
  __classPrivateFieldSet$6(this, _QuerySubscriptionProxy_live, new LiveQuery(client, uuid, open, (result) => __classPrivateFieldGet$6(this, _QuerySubscriptionProxy_instances, "m", _QuerySubscriptionProxy_deliver).call(this, result)), "f");
5479
5655
  __classPrivateFieldSet$6(this, _QuerySubscriptionProxy_initialized, new Promise((resolve, reject) => {
5480
5656
  __classPrivateFieldSet$6(this, _QuerySubscriptionProxy_initResolve, resolve, "f");
@@ -5505,8 +5681,14 @@ var QuerySubscriptionProxy = class {
5505
5681
  __classPrivateFieldGet$6(this, _QuerySubscriptionProxy_callbacks, "f").add(callback);
5506
5682
  return () => __classPrivateFieldGet$6(this, _QuerySubscriptionProxy_callbacks, "f").delete(callback);
5507
5683
  }
5508
- dispose() {
5509
- __classPrivateFieldGet$6(this, _QuerySubscriptionProxy_live, "f").dispose();
5684
+ get reopening() {
5685
+ return __classPrivateFieldGet$6(this, _QuerySubscriptionProxy_live, "f").reopening;
5686
+ }
5687
+ onStatus(listener) {
5688
+ return __classPrivateFieldGet$6(this, _QuerySubscriptionProxy_live, "f").onStatus(listener);
5689
+ }
5690
+ dispose(options = {}) {
5691
+ __classPrivateFieldGet$6(this, _QuerySubscriptionProxy_live, "f").dispose(options);
5510
5692
  __classPrivateFieldGet$6(this, _QuerySubscriptionProxy_callbacks, "f").clear();
5511
5693
  }
5512
5694
  };
@@ -5576,6 +5758,9 @@ var PerspectiveProxy = class {
5576
5758
  async runInterpretationWithHarness(transcript, basePrefix, maxToolCalls, classes, modelOverride, observationId, emitDebugEvents, options) {
5577
5759
  return await __classPrivateFieldGet$6(this, _PerspectiveProxy_client, "f").runInterpretationWithHarness(__classPrivateFieldGet$6(this, _PerspectiveProxy_handle, "f").uuid, transcript, basePrefix, maxToolCalls, classes, modelOverride, void 0, observationId, emitDebugEvents, options);
5578
5760
  }
5761
+ async runAgent(messages2, settings, options) {
5762
+ return await __classPrivateFieldGet$6(this, _PerspectiveProxy_client, "f").runAgent(__classPrivateFieldGet$6(this, _PerspectiveProxy_handle, "f").uuid, messages2, settings, options);
5763
+ }
5579
5764
  async addAutoProcessor(config) {
5580
5765
  return await __classPrivateFieldGet$6(this, _PerspectiveProxy_client, "f").addAutoProcessor(__classPrivateFieldGet$6(this, _PerspectiveProxy_handle, "f").uuid, config);
5581
5766
  }
@@ -5976,14 +6161,8 @@ var PerspectiveProxy = class {
5976
6161
  async stringOrTemplateObjectToSubjectClassName(subjectClass) {
5977
6162
  if (typeof subjectClass === "string")
5978
6163
  return subjectClass;
5979
- else {
5980
- let subjectClasses = await this.subjectClassesByTemplate(subjectClass);
5981
- if (subjectClasses[0]) {
5982
- return subjectClasses[0];
5983
- } else {
5984
- return subjectClass.className;
5985
- }
5986
- }
6164
+ const obj = subjectClass;
6165
+ return obj.className || obj.constructor?.className || obj.constructor?.prototype?.className || (await this.subjectClassesByTemplate(obj))[0];
5987
6166
  }
5988
6167
  async createSubject(subjectClass, exprAddr, initialValues, batchId) {
5989
6168
  let className;
@@ -6432,7 +6611,12 @@ var PerspectiveProxy = class {
6432
6611
  }
6433
6612
  async subscribeQuery(query) {
6434
6613
  const subscription = new QuerySubscriptionProxy(this.uuid, query, __classPrivateFieldGet$6(this, _PerspectiveProxy_client, "f"));
6435
- await subscription.subscribe();
6614
+ try {
6615
+ await subscription.subscribe();
6616
+ } catch (e) {
6617
+ subscription.dispose({ cancelOpening: true });
6618
+ throw e;
6619
+ }
6436
6620
  return subscription;
6437
6621
  }
6438
6622
  };
@@ -6528,8 +6712,8 @@ var PerspectiveClient = class {
6528
6712
  const result = await __classPrivateFieldGet$5(this, _PerspectiveClient_apiClient, "f").call("perspective.querySparql", { uuid, engine: "sparql", query }, options);
6529
6713
  return JSON.parse(result);
6530
6714
  }
6531
- async subscribeQuery(uuid, query) {
6532
- return __classPrivateFieldGet$5(this, _PerspectiveClient_apiClient, "f").call("perspective.subscribeQuery", { uuid, query });
6715
+ async subscribeQuery(uuid, query, options) {
6716
+ return __classPrivateFieldGet$5(this, _PerspectiveClient_apiClient, "f").call("perspective.subscribeQuery", { uuid, query }, options);
6533
6717
  }
6534
6718
  onQueryUpdate(cb) {
6535
6719
  return __classPrivateFieldGet$5(this, _PerspectiveClient_apiClient, "f").on("query-subscription-update", cb);
@@ -6556,8 +6740,8 @@ var PerspectiveClient = class {
6556
6740
  });
6557
6741
  return JSON.parse(resultJson);
6558
6742
  }
6559
- async modelSubscribe(uuid, className, queryJson) {
6560
- return __classPrivateFieldGet$5(this, _PerspectiveClient_apiClient, "f").call("perspective.modelSubscribe", { uuid, ...classParams(className), query_json: queryJson });
6743
+ async modelSubscribe(uuid, className, queryJson, options) {
6744
+ return __classPrivateFieldGet$5(this, _PerspectiveClient_apiClient, "f").call("perspective.modelSubscribe", { uuid, ...classParams(className), query_json: queryJson }, options);
6561
6745
  }
6562
6746
  async add(name) {
6563
6747
  const handle = await __classPrivateFieldGet$5(this, _PerspectiveClient_apiClient, "f").call("perspective.create", { name });
@@ -6612,6 +6796,9 @@ var PerspectiveClient = class {
6612
6796
  emitDebugEvents
6613
6797
  }, options);
6614
6798
  }
6799
+ async runAgent(uuid, messages2, settings, options) {
6800
+ return __classPrivateFieldGet$5(this, _PerspectiveClient_apiClient, "f").call("perspective.runAgent", { uuid, messages: messages2, ...settings }, options);
6801
+ }
6615
6802
  async addAutoProcessor(uuid, config) {
6616
6803
  return __classPrivateFieldGet$5(this, _PerspectiveClient_apiClient, "f").call("perspective.addAutoProcessor", { ...config, uuid });
6617
6804
  }
@@ -12030,6 +12217,7 @@ function buildSPARQLWhereFilters(metadata, _allRelationsMetadata, where) {
12030
12217
  }
12031
12218
  return { joins, filters };
12032
12219
  }
12220
+ var fingerprint = (value) => JSON.stringify(value, (_, v) => typeof v === "function" ? void 0 : v);
12033
12221
  var ModelQueryBuilder = class {
12034
12222
  constructor(perspective, ctor, query, unionClasses) {
12035
12223
  this.queryParams = {};
@@ -12061,6 +12249,9 @@ var ModelQueryBuilder = class {
12061
12249
  }
12062
12250
  return this.ctor.parseModelResult(this.perspective, raw, include, properties);
12063
12251
  }
12252
+ takeSnapshots(instances) {
12253
+ this.ctor.takeSnapshots(instances, this.queryParams.include);
12254
+ }
12064
12255
  dispose() {
12065
12256
  if (this.currentSubscription) {
12066
12257
  this.currentSubscription.dispose();
@@ -12166,7 +12357,6 @@ var ModelQueryBuilder = class {
12166
12357
  async subscribe(callback) {
12167
12358
  this.dispose();
12168
12359
  const parseResults = (raw) => this.parse(raw);
12169
- const fingerprint = (results) => JSON.stringify(results, (_, v) => typeof v === "function" ? void 0 : v);
12170
12360
  let lastFingerprint = null;
12171
12361
  const { initial } = await this.live(this.queryParams, (raw) => {
12172
12362
  try {
@@ -12215,53 +12405,33 @@ var ModelQueryBuilder = class {
12215
12405
  }
12216
12406
  async paginateSubscribe(pageSize, pageNumber, callback) {
12217
12407
  this.dispose();
12218
- const subscriptionParams = { ...this.queryParams || {} };
12219
- delete subscriptionParams.limit;
12220
- delete subscriptionParams.offset;
12221
12408
  const paginatedQuery = {
12222
12409
  ...this.queryParams || {},
12223
12410
  limit: pageSize,
12224
12411
  offset: pageSize * (pageNumber - 1),
12225
12412
  count: true
12226
12413
  };
12227
- let disposed = false;
12228
- let fetching = false;
12229
- let pending = false;
12230
- const processResults = async () => {
12231
- if (disposed)
12232
- return;
12233
- if (fetching) {
12234
- pending = true;
12235
- return;
12236
- }
12237
- fetching = true;
12414
+ let lastFingerprint = null;
12415
+ const toPage = (raw) => {
12416
+ const results = this.parse(raw);
12417
+ const fp2 = fingerprint([results, raw?.totalCount]);
12418
+ this.takeSnapshots(results);
12419
+ return { page: { results, totalCount: raw?.totalCount, pageSize, pageNumber }, fp: fp2 };
12420
+ };
12421
+ const { initial } = await this.live(paginatedQuery, (raw) => {
12238
12422
  try {
12239
- const { results: results2, totalCount: totalCount2 } = await this.execute(paginatedQuery);
12240
- if (!disposed)
12241
- callback({ results: results2, totalCount: totalCount2, pageSize, pageNumber });
12242
- } finally {
12243
- fetching = false;
12244
- if (pending) {
12245
- pending = false;
12246
- processResults().catch((e) => console.error("Paginate subscription error:", e));
12247
- }
12423
+ const { page: page2, fp: fp2 } = toPage(raw);
12424
+ if (fp2 === lastFingerprint)
12425
+ return;
12426
+ lastFingerprint = fp2;
12427
+ callback(page2);
12428
+ } catch (e) {
12429
+ console.error("Paginate subscription error:", e);
12248
12430
  }
12249
- };
12250
- const { live } = await this.live(subscriptionParams, () => {
12251
- processResults().catch((e) => console.error("Paginate subscription error:", e));
12252
12431
  });
12253
- if (this.currentSubscription === live) {
12254
- this.currentSubscription = {
12255
- dispose: () => {
12256
- disposed = true;
12257
- live.dispose();
12258
- }
12259
- };
12260
- } else {
12261
- disposed = true;
12262
- }
12263
- const { results, totalCount } = await this.execute(paginatedQuery);
12264
- return { results, totalCount, pageSize, pageNumber };
12432
+ const { page, fp } = toPage(initial);
12433
+ lastFingerprint = fp;
12434
+ return page;
12265
12435
  }
12266
12436
  async paginateSubscribeSparql(pageSize, pageNumber, callback) {
12267
12437
  return await this.paginateSubscribe(pageSize, pageNumber, callback);
@@ -12858,6 +13028,12 @@ var Ad4mModel = class {
12858
13028
  return [];
12859
13029
  return arr.map((json) => jsonToModelInstance(this, perspective, json, include, properties));
12860
13030
  }
13031
+ static takeSnapshots(instances, include) {
13032
+ const relations = include ? Object.fromEntries(Object.entries(include).filter(([k]) => !k.startsWith("$"))) : void 0;
13033
+ const snapshot = relations && Object.keys(relations).length > 0 ? relations : void 0;
13034
+ for (const inst of instances)
13035
+ inst.takeSnapshot?.(snapshot);
13036
+ }
12861
13037
  static prepareUnionQueryParams(classes, query = {}) {
12862
13038
  if (!classes.length)
12863
13039
  throw new Error("A query over several classes needs at least one class");
@@ -12930,10 +13106,7 @@ var Ad4mModel = class {
12930
13106
  const { classNames, queryJson } = Ad4mModel.prepareUnionQueryParams(classes, query);
12931
13107
  const result = await perspective.modelQuery(classNames, queryJson, options);
12932
13108
  const results = Ad4mModel.parseUnionResult(classes, perspective, result, query.include, query.properties);
12933
- const snapshotRelations = query.include ? Object.fromEntries(Object.entries(query.include).filter(([k]) => !k.startsWith("$"))) : void 0;
12934
- for (const inst of results) {
12935
- inst.takeSnapshot?.(snapshotRelations && Object.keys(snapshotRelations).length > 0 ? snapshotRelations : void 0);
12936
- }
13109
+ Ad4mModel.takeSnapshots(results, query.include);
12937
13110
  return { results, totalCount: result.totalCount };
12938
13111
  }
12939
13112
  static async findAllOf(perspective, classes, query, options) {
@@ -12949,10 +13122,7 @@ var Ad4mModel = class {
12949
13122
  const instances = result.instances.map((json) => {
12950
13123
  return jsonToModelInstance(this, perspective, json, query.include, query.properties);
12951
13124
  });
12952
- const snapshotRelations = query.include ? Object.fromEntries(Object.entries(query.include).filter(([k]) => !k.startsWith("$"))) : void 0;
12953
- for (const inst of instances) {
12954
- inst.takeSnapshot(snapshotRelations && Object.keys(snapshotRelations).length > 0 ? snapshotRelations : void 0);
12955
- }
13125
+ Ad4mModel.takeSnapshots(instances, query.include);
12956
13126
  return {
12957
13127
  results: instances,
12958
13128
  totalCount: result.totalCount
@@ -13505,6 +13675,9 @@ var Ad4mClient = class {
13505
13675
  onAuthFailed(callback) {
13506
13676
  return __classPrivateFieldGet$1(this, _Ad4mClient_apiClient, "f").onAuthFailed(callback);
13507
13677
  }
13678
+ reconnectNow() {
13679
+ __classPrivateFieldGet$1(this, _Ad4mClient_apiClient, "f").reconnectNow();
13680
+ }
13508
13681
  close() {
13509
13682
  __classPrivateFieldGet$1(this, _Ad4mClient_agentClient, "f").clearByDidCache();
13510
13683
  __classPrivateFieldGet$1(this, _Ad4mClient_apiClient, "f").closeAll();
@@ -13521,7 +13694,7 @@ var ExceptionType;
13521
13694
  })(ExceptionType || (ExceptionType = {}));
13522
13695
  var LanguageExpression = class extends ExpressionGeneric() {
13523
13696
  };
13524
- var __decorate$3 = function(decorators, target, key, desc) {
13697
+ var __decorate$4 = function(decorators, target, key, desc) {
13525
13698
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
13526
13699
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
13527
13700
  r = Reflect.decorate(decorators, target, key, desc);
@@ -13531,7 +13704,7 @@ var __decorate$3 = function(decorators, target, key, desc) {
13531
13704
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
13532
13705
  return c > 3 && r && Object.defineProperty(target, key, r), r;
13533
13706
  };
13534
- var __metadata$3 = function(k, v) {
13707
+ var __metadata$4 = function(k, v) {
13535
13708
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
13536
13709
  return Reflect.metadata(k, v);
13537
13710
  };
@@ -13547,71 +13720,71 @@ var AutoProcessorConfig = class AutoProcessorConfig2 extends Ad4mModel {
13547
13720
  this.claimTtlMs = "60000";
13548
13721
  }
13549
13722
  };
13550
- __decorate$3([
13723
+ __decorate$4([
13551
13724
  Property({ through: "ad4m://processor_id", required: true, identity: true }),
13552
- __metadata$3("design:type", String)
13725
+ __metadata$4("design:type", String)
13553
13726
  ], AutoProcessorConfig.prototype, "processorId", void 0);
13554
- __decorate$3([
13727
+ __decorate$4([
13555
13728
  Property({ through: "ad4m://source_scope_query", required: true }),
13556
- __metadata$3("design:type", String)
13729
+ __metadata$4("design:type", String)
13557
13730
  ], AutoProcessorConfig.prototype, "sourceScopeQuery", void 0);
13558
- __decorate$3([
13731
+ __decorate$4([
13559
13732
  Optional({ through: "ad4m://base_prefix" }),
13560
- __metadata$3("design:type", String)
13733
+ __metadata$4("design:type", String)
13561
13734
  ], AutoProcessorConfig.prototype, "basePrefix", void 0);
13562
- __decorate$3([
13735
+ __decorate$4([
13563
13736
  HasMany({ through: "ad4m://interpretation_class", datatype: "xsd:string" }),
13564
- __metadata$3("design:type", Array)
13737
+ __metadata$4("design:type", Array)
13565
13738
  ], AutoProcessorConfig.prototype, "interpretationClasses", void 0);
13566
- __decorate$3([
13739
+ __decorate$4([
13567
13740
  HasMany({ through: "ad4m://flow", datatype: "xsd:string" }),
13568
- __metadata$3("design:type", Array)
13741
+ __metadata$4("design:type", Array)
13569
13742
  ], AutoProcessorConfig.prototype, "flows", void 0);
13570
- __decorate$3([
13743
+ __decorate$4([
13571
13744
  Property({ through: "ad4m://debounce_ms", required: true }),
13572
- __metadata$3("design:type", String)
13745
+ __metadata$4("design:type", String)
13573
13746
  ], AutoProcessorConfig.prototype, "debounceMs", void 0);
13574
- __decorate$3([
13747
+ __decorate$4([
13575
13748
  Optional({ through: "ad4m://batch_min" }),
13576
- __metadata$3("design:type", String)
13749
+ __metadata$4("design:type", String)
13577
13750
  ], AutoProcessorConfig.prototype, "batchMin", void 0);
13578
- __decorate$3([
13751
+ __decorate$4([
13579
13752
  Property({ through: "ad4m://batch_max", required: true }),
13580
- __metadata$3("design:type", String)
13753
+ __metadata$4("design:type", String)
13581
13754
  ], AutoProcessorConfig.prototype, "batchMax", void 0);
13582
- __decorate$3([
13755
+ __decorate$4([
13583
13756
  Optional({ through: "ad4m://max_wait_ms" }),
13584
- __metadata$3("design:type", String)
13757
+ __metadata$4("design:type", String)
13585
13758
  ], AutoProcessorConfig.prototype, "maxWaitMs", void 0);
13586
- __decorate$3([
13759
+ __decorate$4([
13587
13760
  Property({ through: "ad4m://claim_ttl_ms", required: true }),
13588
- __metadata$3("design:type", String)
13761
+ __metadata$4("design:type", String)
13589
13762
  ], AutoProcessorConfig.prototype, "claimTtlMs", void 0);
13590
- __decorate$3([
13763
+ __decorate$4([
13591
13764
  Optional({ through: "ad4m://source_window_ms" }),
13592
- __metadata$3("design:type", String)
13765
+ __metadata$4("design:type", String)
13593
13766
  ], AutoProcessorConfig.prototype, "sourceWindowMs", void 0);
13594
- __decorate$3([
13767
+ __decorate$4([
13595
13768
  Optional({ through: "ad4m://dedup_strategy" }),
13596
- __metadata$3("design:type", String)
13769
+ __metadata$4("design:type", String)
13597
13770
  ], AutoProcessorConfig.prototype, "dedupStrategy", void 0);
13598
- __decorate$3([
13771
+ __decorate$4([
13599
13772
  Optional({ through: "ad4m://existing_scope" }),
13600
- __metadata$3("design:type", String)
13773
+ __metadata$4("design:type", String)
13601
13774
  ], AutoProcessorConfig.prototype, "existingScope", void 0);
13602
- __decorate$3([
13775
+ __decorate$4([
13603
13776
  Optional({ through: "ad4m://mint_scope" }),
13604
- __metadata$3("design:type", String)
13777
+ __metadata$4("design:type", String)
13605
13778
  ], AutoProcessorConfig.prototype, "mintScope", void 0);
13606
- __decorate$3([
13779
+ __decorate$4([
13607
13780
  Optional({ through: "ad4m://max_tool_calls" }),
13608
- __metadata$3("design:type", String)
13781
+ __metadata$4("design:type", String)
13609
13782
  ], AutoProcessorConfig.prototype, "maxToolCalls", void 0);
13610
- __decorate$3([
13783
+ __decorate$4([
13611
13784
  Optional({ through: "ad4m://emit_debug_events", resolveLanguage: "literal" }),
13612
- __metadata$3("design:type", String)
13785
+ __metadata$4("design:type", String)
13613
13786
  ], AutoProcessorConfig.prototype, "emitDebugEvents", void 0);
13614
- AutoProcessorConfig = __decorate$3([
13787
+ AutoProcessorConfig = __decorate$4([
13615
13788
  Model$1({ name: "AutoProcessor" })
13616
13789
  ], AutoProcessorConfig);
13617
13790
  var InterpretationRun = class InterpretationRun2 extends Ad4mModel {
@@ -13621,39 +13794,39 @@ var InterpretationRun = class InterpretationRun2 extends Ad4mModel {
13621
13794
  this.sources = [];
13622
13795
  }
13623
13796
  };
13624
- __decorate$3([
13797
+ __decorate$4([
13625
13798
  Property({ through: "ad4m://interp/run_id", required: true, identity: true }),
13626
- __metadata$3("design:type", String)
13799
+ __metadata$4("design:type", String)
13627
13800
  ], InterpretationRun.prototype, "runId", void 0);
13628
- __decorate$3([
13801
+ __decorate$4([
13629
13802
  Optional({ through: "ad4m://interp/model" }),
13630
- __metadata$3("design:type", String)
13803
+ __metadata$4("design:type", String)
13631
13804
  ], InterpretationRun.prototype, "model", void 0);
13632
- __decorate$3([
13805
+ __decorate$4([
13633
13806
  Optional({ through: "ad4m://interp/prompt_version" }),
13634
- __metadata$3("design:type", String)
13807
+ __metadata$4("design:type", String)
13635
13808
  ], InterpretationRun.prototype, "promptVersion", void 0);
13636
- __decorate$3([
13809
+ __decorate$4([
13637
13810
  Optional({ through: "ad4m://interp/ran_at" }),
13638
- __metadata$3("design:type", String)
13811
+ __metadata$4("design:type", String)
13639
13812
  ], InterpretationRun.prototype, "ranAt", void 0);
13640
- __decorate$3([
13813
+ __decorate$4([
13641
13814
  Optional({ through: "ad4m://interp/processor" }),
13642
- __metadata$3("design:type", String)
13815
+ __metadata$4("design:type", String)
13643
13816
  ], InterpretationRun.prototype, "processor", void 0);
13644
- __decorate$3([
13817
+ __decorate$4([
13645
13818
  HasMany({ through: "ad4m://interp/sources", datatype: "xsd:string" }),
13646
- __metadata$3("design:type", Array)
13819
+ __metadata$4("design:type", Array)
13647
13820
  ], InterpretationRun.prototype, "sources", void 0);
13648
- __decorate$3([
13821
+ __decorate$4([
13649
13822
  Optional({ through: "ad4m://interp/debug_prompt", resolveLanguage: "literal" }),
13650
- __metadata$3("design:type", String)
13823
+ __metadata$4("design:type", String)
13651
13824
  ], InterpretationRun.prototype, "debugPrompt", void 0);
13652
- __decorate$3([
13825
+ __decorate$4([
13653
13826
  Optional({ through: "ad4m://interp/debug_response", resolveLanguage: "literal" }),
13654
- __metadata$3("design:type", String)
13827
+ __metadata$4("design:type", String)
13655
13828
  ], InterpretationRun.prototype, "debugResponse", void 0);
13656
- InterpretationRun = __decorate$3([
13829
+ InterpretationRun = __decorate$4([
13657
13830
  Model$1({ name: "InterpretationRun" })
13658
13831
  ], InterpretationRun);
13659
13832
  var InterpretationOverlay = class InterpretationOverlay2 extends Ad4mModel {
@@ -13662,18 +13835,18 @@ var InterpretationOverlay = class InterpretationOverlay2 extends Ad4mModel {
13662
13835
  this.kind = "";
13663
13836
  }
13664
13837
  };
13665
- __decorate$3([
13838
+ __decorate$4([
13666
13839
  Property({ through: "ad4m://interp/kind", required: true }),
13667
- __metadata$3("design:type", String)
13840
+ __metadata$4("design:type", String)
13668
13841
  ], InterpretationOverlay.prototype, "kind", void 0);
13669
- __decorate$3([
13842
+ __decorate$4([
13670
13843
  Optional({ through: "ad4m://interp/run" }),
13671
- __metadata$3("design:type", String)
13844
+ __metadata$4("design:type", String)
13672
13845
  ], InterpretationOverlay.prototype, "run", void 0);
13673
- InterpretationOverlay = __decorate$3([
13846
+ InterpretationOverlay = __decorate$4([
13674
13847
  Model$1({ name: "InterpretationOverlay" })
13675
13848
  ], InterpretationOverlay);
13676
- var __decorate$2 = function(decorators, target, key, desc) {
13849
+ var __decorate$3 = function(decorators, target, key, desc) {
13677
13850
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
13678
13851
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
13679
13852
  r = Reflect.decorate(decorators, target, key, desc);
@@ -13683,7 +13856,7 @@ var __decorate$2 = function(decorators, target, key, desc) {
13683
13856
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
13684
13857
  return c > 3 && r && Object.defineProperty(target, key, r), r;
13685
13858
  };
13686
- var __metadata$2 = function(k, v) {
13859
+ var __metadata$3 = function(k, v) {
13687
13860
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
13688
13861
  return Reflect.metadata(k, v);
13689
13862
  };
@@ -13704,55 +13877,55 @@ var FlowTransitionProposal = class FlowTransitionProposal2 extends Ad4mModel {
13704
13877
  this.acceptedBy = [];
13705
13878
  }
13706
13879
  };
13707
- __decorate$2([
13880
+ __decorate$3([
13708
13881
  Property({ through: "ad4m://flow/instance", required: true, identity: true }),
13709
- __metadata$2("design:type", String)
13882
+ __metadata$3("design:type", String)
13710
13883
  ], FlowTransitionProposal.prototype, "flowInstance", void 0);
13711
- __decorate$2([
13884
+ __decorate$3([
13712
13885
  Property({ through: "ad4m://flow/from_state", required: true }),
13713
- __metadata$2("design:type", String)
13886
+ __metadata$3("design:type", String)
13714
13887
  ], FlowTransitionProposal.prototype, "fromState", void 0);
13715
- __decorate$2([
13888
+ __decorate$3([
13716
13889
  Property({ through: "ad4m://flow/to_state", required: true }),
13717
- __metadata$2("design:type", String)
13890
+ __metadata$3("design:type", String)
13718
13891
  ], FlowTransitionProposal.prototype, "toState", void 0);
13719
- __decorate$2([
13892
+ __decorate$3([
13720
13893
  Property({ through: "ad4m://flow/proposer", required: true, getter: PROPOSER_GETTER, datatype: "xsd:string" }),
13721
- __metadata$2("design:type", String)
13894
+ __metadata$3("design:type", String)
13722
13895
  ], FlowTransitionProposal.prototype, "proposer", void 0);
13723
- __decorate$2([
13896
+ __decorate$3([
13724
13897
  HasMany({ through: "ad4m://flow/evidence", datatype: "xsd:string" }),
13725
- __metadata$2("design:type", Array)
13898
+ __metadata$3("design:type", Array)
13726
13899
  ], FlowTransitionProposal.prototype, "evidence", void 0);
13727
- __decorate$2([
13900
+ __decorate$3([
13728
13901
  Property({ through: "ad4m://flow/evidence_hashes", required: true }),
13729
- __metadata$2("design:type", String)
13902
+ __metadata$3("design:type", String)
13730
13903
  ], FlowTransitionProposal.prototype, "evidenceHashes", void 0);
13731
- __decorate$2([
13904
+ __decorate$3([
13732
13905
  HasMany({ through: "ad4m://flow/output", datatype: "xsd:string" }),
13733
- __metadata$2("design:type", Array)
13906
+ __metadata$3("design:type", Array)
13734
13907
  ], FlowTransitionProposal.prototype, "outputs", void 0);
13735
- __decorate$2([
13908
+ __decorate$3([
13736
13909
  Property({ through: "ad4m://flow/outputs_hash" }),
13737
- __metadata$2("design:type", String)
13910
+ __metadata$3("design:type", String)
13738
13911
  ], FlowTransitionProposal.prototype, "outputsHash", void 0);
13739
- __decorate$2([
13912
+ __decorate$3([
13740
13913
  Property({ through: "ad4m://flow/nonce" }),
13741
- __metadata$2("design:type", String)
13914
+ __metadata$3("design:type", String)
13742
13915
  ], FlowTransitionProposal.prototype, "nonce", void 0);
13743
- __decorate$2([
13916
+ __decorate$3([
13744
13917
  Optional({ through: "ad4m://flow/run_uri" }),
13745
- __metadata$2("design:type", String)
13918
+ __metadata$3("design:type", String)
13746
13919
  ], FlowTransitionProposal.prototype, "runUri", void 0);
13747
- __decorate$2([
13920
+ __decorate$3([
13748
13921
  Optional({ through: "ad4m://flow/rationale" }),
13749
- __metadata$2("design:type", String)
13922
+ __metadata$3("design:type", String)
13750
13923
  ], FlowTransitionProposal.prototype, "rationale", void 0);
13751
- __decorate$2([
13924
+ __decorate$3([
13752
13925
  HasMany({ through: "ad4m://acceptedBy", getter: ACCEPTED_BY_GETTER, readOnly: true }),
13753
- __metadata$2("design:type", Array)
13926
+ __metadata$3("design:type", Array)
13754
13927
  ], FlowTransitionProposal.prototype, "acceptedBy", void 0);
13755
- FlowTransitionProposal = __decorate$2([
13928
+ FlowTransitionProposal = __decorate$3([
13756
13929
  Model$1({ name: "FlowTransitionProposal" })
13757
13930
  ], FlowTransitionProposal);
13758
13931
  var FlowInstanceRecord = class FlowInstanceRecord2 extends Ad4mModel {
@@ -13762,18 +13935,18 @@ var FlowInstanceRecord = class FlowInstanceRecord2 extends Ad4mModel {
13762
13935
  this.subject = "";
13763
13936
  }
13764
13937
  };
13765
- __decorate$2([
13938
+ __decorate$3([
13766
13939
  Property({ through: "ad4m://flow/flow_uri", required: true, identity: true }),
13767
- __metadata$2("design:type", String)
13940
+ __metadata$3("design:type", String)
13768
13941
  ], FlowInstanceRecord.prototype, "flowUri", void 0);
13769
- __decorate$2([
13942
+ __decorate$3([
13770
13943
  Property({ through: "ad4m://flow/base", required: true }),
13771
- __metadata$2("design:type", String)
13944
+ __metadata$3("design:type", String)
13772
13945
  ], FlowInstanceRecord.prototype, "subject", void 0);
13773
- FlowInstanceRecord = __decorate$2([
13946
+ FlowInstanceRecord = __decorate$3([
13774
13947
  Model$1({ name: "FlowInstance" })
13775
13948
  ], FlowInstanceRecord);
13776
- var __decorate$1 = function(decorators, target, key, desc) {
13949
+ var __decorate$2 = function(decorators, target, key, desc) {
13777
13950
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
13778
13951
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
13779
13952
  r = Reflect.decorate(decorators, target, key, desc);
@@ -13783,7 +13956,7 @@ var __decorate$1 = function(decorators, target, key, desc) {
13783
13956
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
13784
13957
  return c > 3 && r && Object.defineProperty(target, key, r), r;
13785
13958
  };
13786
- var __metadata$1 = function(k, v) {
13959
+ var __metadata$2 = function(k, v) {
13787
13960
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
13788
13961
  return Reflect.metadata(k, v);
13789
13962
  };
@@ -13794,13 +13967,41 @@ var TextContent = class TextContent2 extends Ad4mModel {
13794
13967
  }
13795
13968
  };
13796
13969
  TextContent.builtinUri = "ad4m://TextContent";
13797
- __decorate$1([
13970
+ __decorate$2([
13798
13971
  Property({ through: "ad4m://text" }),
13799
- __metadata$1("design:type", String)
13972
+ __metadata$2("design:type", String)
13800
13973
  ], TextContent.prototype, "text", void 0);
13801
- TextContent = __decorate$1([
13974
+ TextContent = __decorate$2([
13802
13975
  Model$1({ name: "TextContent", abstract: true })
13803
13976
  ], TextContent);
13977
+ var __decorate$1 = function(decorators, target, key, desc) {
13978
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
13979
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
13980
+ r = Reflect.decorate(decorators, target, key, desc);
13981
+ else
13982
+ for (var i = decorators.length - 1; i >= 0; i--)
13983
+ if (d = decorators[i])
13984
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
13985
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
13986
+ };
13987
+ var __metadata$1 = function(k, v) {
13988
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
13989
+ return Reflect.metadata(k, v);
13990
+ };
13991
+ var Mentioning = class Mentioning2 extends Ad4mModel {
13992
+ constructor() {
13993
+ super(...arguments);
13994
+ this.mentions = [];
13995
+ }
13996
+ };
13997
+ Mentioning.builtinUri = "ad4m://Mentioning";
13998
+ __decorate$1([
13999
+ HasMany({ through: "ad4m://mentions" }),
14000
+ __metadata$1("design:type", Array)
14001
+ ], Mentioning.prototype, "mentions", void 0);
14002
+ Mentioning = __decorate$1([
14003
+ Model$1({ name: "Mentioning", abstract: true })
14004
+ ], Mentioning);
13804
14005
  var __decorate = function(decorators, target, key, desc) {
13805
14006
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
13806
14007
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")