@coasys/ad4m 0.13.0-test-5 → 0.13.0-test-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.
package/lib/index.js CHANGED
@@ -551,13 +551,13 @@ class AgentStatus {
551
551
  }
552
552
  }
553
553
 
554
- var __classPrivateFieldSet$b = (undefined && undefined.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
554
+ var __classPrivateFieldSet$c = (undefined && undefined.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
555
555
  if (kind === "m") throw new TypeError("Private method is not writable");
556
556
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
557
557
  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");
558
558
  return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
559
559
  };
560
- var __classPrivateFieldGet$b = (undefined && undefined.__classPrivateFieldGet) || function (receiver, state, kind, f) {
560
+ var __classPrivateFieldGet$c = (undefined && undefined.__classPrivateFieldGet) || function (receiver, state, kind, f) {
561
561
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
562
562
  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");
563
563
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
@@ -567,41 +567,41 @@ class NeighbourhoodProxy {
567
567
  constructor(client, pID) {
568
568
  _NeighbourhoodProxy_client.set(this, void 0);
569
569
  _NeighbourhoodProxy_pID.set(this, void 0);
570
- __classPrivateFieldSet$b(this, _NeighbourhoodProxy_client, client, "f");
571
- __classPrivateFieldSet$b(this, _NeighbourhoodProxy_pID, pID, "f");
570
+ __classPrivateFieldSet$c(this, _NeighbourhoodProxy_client, client, "f");
571
+ __classPrivateFieldSet$c(this, _NeighbourhoodProxy_pID, pID, "f");
572
572
  }
573
573
  async otherAgents() {
574
- return await __classPrivateFieldGet$b(this, _NeighbourhoodProxy_client, "f").otherAgents(__classPrivateFieldGet$b(this, _NeighbourhoodProxy_pID, "f"));
574
+ return await __classPrivateFieldGet$c(this, _NeighbourhoodProxy_client, "f").otherAgents(__classPrivateFieldGet$c(this, _NeighbourhoodProxy_pID, "f"));
575
575
  }
576
576
  async hasTelepresenceAdapter() {
577
- return await __classPrivateFieldGet$b(this, _NeighbourhoodProxy_client, "f").hasTelepresenceAdapter(__classPrivateFieldGet$b(this, _NeighbourhoodProxy_pID, "f"));
577
+ return await __classPrivateFieldGet$c(this, _NeighbourhoodProxy_client, "f").hasTelepresenceAdapter(__classPrivateFieldGet$c(this, _NeighbourhoodProxy_pID, "f"));
578
578
  }
579
579
  async onlineAgents() {
580
- return await __classPrivateFieldGet$b(this, _NeighbourhoodProxy_client, "f").onlineAgents(__classPrivateFieldGet$b(this, _NeighbourhoodProxy_pID, "f"));
580
+ return await __classPrivateFieldGet$c(this, _NeighbourhoodProxy_client, "f").onlineAgents(__classPrivateFieldGet$c(this, _NeighbourhoodProxy_pID, "f"));
581
581
  }
582
582
  async setOnlineStatus(status) {
583
- return await __classPrivateFieldGet$b(this, _NeighbourhoodProxy_client, "f").setOnlineStatus(__classPrivateFieldGet$b(this, _NeighbourhoodProxy_pID, "f"), status);
583
+ return await __classPrivateFieldGet$c(this, _NeighbourhoodProxy_client, "f").setOnlineStatus(__classPrivateFieldGet$c(this, _NeighbourhoodProxy_pID, "f"), status);
584
584
  }
585
585
  async setOnlineStatusU(status) {
586
- return await __classPrivateFieldGet$b(this, _NeighbourhoodProxy_client, "f").setOnlineStatusU(__classPrivateFieldGet$b(this, _NeighbourhoodProxy_pID, "f"), status);
586
+ return await __classPrivateFieldGet$c(this, _NeighbourhoodProxy_client, "f").setOnlineStatusU(__classPrivateFieldGet$c(this, _NeighbourhoodProxy_pID, "f"), status);
587
587
  }
588
588
  async sendSignal(remoteAgentDid, payload) {
589
- return await __classPrivateFieldGet$b(this, _NeighbourhoodProxy_client, "f").sendSignal(__classPrivateFieldGet$b(this, _NeighbourhoodProxy_pID, "f"), remoteAgentDid, payload);
589
+ return await __classPrivateFieldGet$c(this, _NeighbourhoodProxy_client, "f").sendSignal(__classPrivateFieldGet$c(this, _NeighbourhoodProxy_pID, "f"), remoteAgentDid, payload);
590
590
  }
591
591
  async sendSignalU(remoteAgentDid, payload) {
592
- return await __classPrivateFieldGet$b(this, _NeighbourhoodProxy_client, "f").sendSignalU(__classPrivateFieldGet$b(this, _NeighbourhoodProxy_pID, "f"), remoteAgentDid, payload);
592
+ return await __classPrivateFieldGet$c(this, _NeighbourhoodProxy_client, "f").sendSignalU(__classPrivateFieldGet$c(this, _NeighbourhoodProxy_pID, "f"), remoteAgentDid, payload);
593
593
  }
594
594
  async sendBroadcast(payload, loopback = false) {
595
- return await __classPrivateFieldGet$b(this, _NeighbourhoodProxy_client, "f").sendBroadcast(__classPrivateFieldGet$b(this, _NeighbourhoodProxy_pID, "f"), payload, loopback);
595
+ return await __classPrivateFieldGet$c(this, _NeighbourhoodProxy_client, "f").sendBroadcast(__classPrivateFieldGet$c(this, _NeighbourhoodProxy_pID, "f"), payload, loopback);
596
596
  }
597
597
  async sendBroadcastU(payload, loopback = false) {
598
- return await __classPrivateFieldGet$b(this, _NeighbourhoodProxy_client, "f").sendBroadcastU(__classPrivateFieldGet$b(this, _NeighbourhoodProxy_pID, "f"), payload, loopback);
598
+ return await __classPrivateFieldGet$c(this, _NeighbourhoodProxy_client, "f").sendBroadcastU(__classPrivateFieldGet$c(this, _NeighbourhoodProxy_pID, "f"), payload, loopback);
599
599
  }
600
600
  async addSignalHandler(handler) {
601
- await __classPrivateFieldGet$b(this, _NeighbourhoodProxy_client, "f").addSignalHandler(__classPrivateFieldGet$b(this, _NeighbourhoodProxy_pID, "f"), handler);
601
+ await __classPrivateFieldGet$c(this, _NeighbourhoodProxy_client, "f").addSignalHandler(__classPrivateFieldGet$c(this, _NeighbourhoodProxy_pID, "f"), handler);
602
602
  }
603
603
  removeSignalHandler(handler) {
604
- __classPrivateFieldGet$b(this, _NeighbourhoodProxy_client, "f").removeSignalHandler(__classPrivateFieldGet$b(this, _NeighbourhoodProxy_pID, "f"), handler);
604
+ __classPrivateFieldGet$c(this, _NeighbourhoodProxy_client, "f").removeSignalHandler(__classPrivateFieldGet$c(this, _NeighbourhoodProxy_pID, "f"), handler);
605
605
  }
606
606
  }
607
607
  _NeighbourhoodProxy_client = new WeakMap(), _NeighbourhoodProxy_pID = new WeakMap();
@@ -695,13 +695,13 @@ class LinkQuery {
695
695
  }
696
696
  }
697
697
 
698
- var __classPrivateFieldSet$a = (undefined && undefined.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
698
+ var __classPrivateFieldSet$b = (undefined && undefined.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
699
699
  if (kind === "m") throw new TypeError("Private method is not writable");
700
700
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
701
701
  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");
702
702
  return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
703
703
  };
704
- var __classPrivateFieldGet$a = (undefined && undefined.__classPrivateFieldGet) || function (receiver, state, kind, f) {
704
+ var __classPrivateFieldGet$b = (undefined && undefined.__classPrivateFieldGet) || function (receiver, state, kind, f) {
705
705
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
706
706
  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");
707
707
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
@@ -722,44 +722,44 @@ class Literal {
722
722
  if (url.startsWith("literal://"))
723
723
  throw new Error("literal:// format is no longer supported. Use literal: instead.");
724
724
  const l = new Literal();
725
- __classPrivateFieldSet$a(l, _Literal_url, url, "f");
725
+ __classPrivateFieldSet$b(l, _Literal_url, url, "f");
726
726
  return l;
727
727
  }
728
728
  static from(literal) {
729
729
  const l = new Literal();
730
- __classPrivateFieldSet$a(l, _Literal_literal, literal, "f");
730
+ __classPrivateFieldSet$b(l, _Literal_literal, literal, "f");
731
731
  return l;
732
732
  }
733
733
  toUrl() {
734
- if (__classPrivateFieldGet$a(this, _Literal_url, "f") && !__classPrivateFieldGet$a(this, _Literal_literal, "f"))
735
- return __classPrivateFieldGet$a(this, _Literal_url, "f");
736
- if (!__classPrivateFieldGet$a(this, _Literal_url, "f") && (__classPrivateFieldGet$a(this, _Literal_literal, "f") === undefined || __classPrivateFieldGet$a(this, _Literal_literal, "f") === "" || __classPrivateFieldGet$a(this, _Literal_literal, "f") === null))
734
+ if (__classPrivateFieldGet$b(this, _Literal_url, "f") && !__classPrivateFieldGet$b(this, _Literal_literal, "f"))
735
+ return __classPrivateFieldGet$b(this, _Literal_url, "f");
736
+ if (!__classPrivateFieldGet$b(this, _Literal_url, "f") && (__classPrivateFieldGet$b(this, _Literal_literal, "f") === undefined || __classPrivateFieldGet$b(this, _Literal_literal, "f") === "" || __classPrivateFieldGet$b(this, _Literal_literal, "f") === null))
737
737
  throw new Error("Can't turn empty Literal into URL");
738
738
  let encoded;
739
- switch (typeof __classPrivateFieldGet$a(this, _Literal_literal, "f")) {
739
+ switch (typeof __classPrivateFieldGet$b(this, _Literal_literal, "f")) {
740
740
  case 'string':
741
- encoded = `string:${encodeRFC3986URIComponent(__classPrivateFieldGet$a(this, _Literal_literal, "f"))}`;
741
+ encoded = `string:${encodeRFC3986URIComponent(__classPrivateFieldGet$b(this, _Literal_literal, "f"))}`;
742
742
  break;
743
743
  case 'number':
744
- encoded = `number:${encodeRFC3986URIComponent(__classPrivateFieldGet$a(this, _Literal_literal, "f"))}`;
744
+ encoded = `number:${encodeRFC3986URIComponent(__classPrivateFieldGet$b(this, _Literal_literal, "f"))}`;
745
745
  break;
746
746
  case 'boolean':
747
- encoded = `boolean:${encodeRFC3986URIComponent(__classPrivateFieldGet$a(this, _Literal_literal, "f"))}`;
747
+ encoded = `boolean:${encodeRFC3986URIComponent(__classPrivateFieldGet$b(this, _Literal_literal, "f"))}`;
748
748
  break;
749
749
  case 'object':
750
- encoded = `json:${encodeRFC3986URIComponent(JSON.stringify(__classPrivateFieldGet$a(this, _Literal_literal, "f")))}`;
750
+ encoded = `json:${encodeRFC3986URIComponent(JSON.stringify(__classPrivateFieldGet$b(this, _Literal_literal, "f")))}`;
751
751
  break;
752
752
  }
753
753
  return `literal:${encoded}`;
754
754
  }
755
755
  get() {
756
- if (__classPrivateFieldGet$a(this, _Literal_literal, "f"))
757
- return __classPrivateFieldGet$a(this, _Literal_literal, "f");
758
- if (!__classPrivateFieldGet$a(this, _Literal_url, "f"))
756
+ if (__classPrivateFieldGet$b(this, _Literal_literal, "f"))
757
+ return __classPrivateFieldGet$b(this, _Literal_literal, "f");
758
+ if (!__classPrivateFieldGet$b(this, _Literal_url, "f"))
759
759
  throw new Error("Can't render empty Literal");
760
- if (!__classPrivateFieldGet$a(this, _Literal_url, "f").startsWith("literal:"))
760
+ if (!__classPrivateFieldGet$b(this, _Literal_url, "f").startsWith("literal:"))
761
761
  throw new Error("Can't render Literal from non-literal URL");
762
- const body = __classPrivateFieldGet$a(this, _Literal_url, "f").substring(8);
762
+ const body = __classPrivateFieldGet$b(this, _Literal_url, "f").substring(8);
763
763
  if (body.startsWith("string:")) {
764
764
  return decodeURIComponent(body.substring(7));
765
765
  }
@@ -3206,13 +3206,13 @@ class SHACLFlow {
3206
3206
  }
3207
3207
  }
3208
3208
 
3209
- var __classPrivateFieldSet$9 = (undefined && undefined.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
3209
+ var __classPrivateFieldSet$a = (undefined && undefined.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
3210
3210
  if (kind === "m") throw new TypeError("Private method is not writable");
3211
3211
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
3212
3212
  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");
3213
3213
  return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
3214
3214
  };
3215
- var __classPrivateFieldGet$9 = (undefined && undefined.__classPrivateFieldGet) || function (receiver, state, kind, f) {
3215
+ var __classPrivateFieldGet$a = (undefined && undefined.__classPrivateFieldGet) || function (receiver, state, kind, f) {
3216
3216
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
3217
3217
  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");
3218
3218
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
@@ -3285,56 +3285,56 @@ class QuerySubscriptionProxy {
3285
3285
  _QuerySubscriptionProxy_initReject.set(this, void 0);
3286
3286
  _QuerySubscriptionProxy_initTimeoutId.set(this, void 0);
3287
3287
  _QuerySubscriptionProxy_query.set(this, void 0);
3288
- __classPrivateFieldSet$9(this, _QuerySubscriptionProxy_uuid, uuid, "f");
3289
- __classPrivateFieldSet$9(this, _QuerySubscriptionProxy_query, query, "f");
3290
- __classPrivateFieldSet$9(this, _QuerySubscriptionProxy_client, client, "f");
3291
- __classPrivateFieldSet$9(this, _QuerySubscriptionProxy_callbacks, new Set(), "f");
3292
- __classPrivateFieldSet$9(this, _QuerySubscriptionProxy_latestResult, null, "f");
3288
+ __classPrivateFieldSet$a(this, _QuerySubscriptionProxy_uuid, uuid, "f");
3289
+ __classPrivateFieldSet$a(this, _QuerySubscriptionProxy_query, query, "f");
3290
+ __classPrivateFieldSet$a(this, _QuerySubscriptionProxy_client, client, "f");
3291
+ __classPrivateFieldSet$a(this, _QuerySubscriptionProxy_callbacks, new Set(), "f");
3292
+ __classPrivateFieldSet$a(this, _QuerySubscriptionProxy_latestResult, null, "f");
3293
3293
  // Create the promise once and store its resolve/reject
3294
- __classPrivateFieldSet$9(this, _QuerySubscriptionProxy_initialized, new Promise((resolve, reject) => {
3295
- __classPrivateFieldSet$9(this, _QuerySubscriptionProxy_initResolve, resolve, "f");
3296
- __classPrivateFieldSet$9(this, _QuerySubscriptionProxy_initReject, reject, "f");
3294
+ __classPrivateFieldSet$a(this, _QuerySubscriptionProxy_initialized, new Promise((resolve, reject) => {
3295
+ __classPrivateFieldSet$a(this, _QuerySubscriptionProxy_initResolve, resolve, "f");
3296
+ __classPrivateFieldSet$a(this, _QuerySubscriptionProxy_initReject, reject, "f");
3297
3297
  }), "f");
3298
3298
  }
3299
3299
  async subscribe() {
3300
3300
  // Clean up previous subscription attempt if retrying
3301
- if (__classPrivateFieldGet$9(this, _QuerySubscriptionProxy_unsubscribe, "f")) {
3302
- __classPrivateFieldGet$9(this, _QuerySubscriptionProxy_unsubscribe, "f").call(this);
3303
- __classPrivateFieldSet$9(this, _QuerySubscriptionProxy_unsubscribe, undefined, "f");
3301
+ if (__classPrivateFieldGet$a(this, _QuerySubscriptionProxy_unsubscribe, "f")) {
3302
+ __classPrivateFieldGet$a(this, _QuerySubscriptionProxy_unsubscribe, "f").call(this);
3303
+ __classPrivateFieldSet$a(this, _QuerySubscriptionProxy_unsubscribe, undefined, "f");
3304
3304
  }
3305
3305
  // Clear any existing timeout
3306
- if (__classPrivateFieldGet$9(this, _QuerySubscriptionProxy_initTimeoutId, "f")) {
3307
- clearTimeout(__classPrivateFieldGet$9(this, _QuerySubscriptionProxy_initTimeoutId, "f"));
3308
- __classPrivateFieldSet$9(this, _QuerySubscriptionProxy_initTimeoutId, undefined, "f");
3306
+ if (__classPrivateFieldGet$a(this, _QuerySubscriptionProxy_initTimeoutId, "f")) {
3307
+ clearTimeout(__classPrivateFieldGet$a(this, _QuerySubscriptionProxy_initTimeoutId, "f"));
3308
+ __classPrivateFieldSet$a(this, _QuerySubscriptionProxy_initTimeoutId, undefined, "f");
3309
3309
  }
3310
3310
  // Clear any existing keepalive timer to prevent accumulation
3311
- if (__classPrivateFieldGet$9(this, _QuerySubscriptionProxy_keepaliveTimer, "f")) {
3312
- clearTimeout(__classPrivateFieldGet$9(this, _QuerySubscriptionProxy_keepaliveTimer, "f"));
3313
- __classPrivateFieldSet$9(this, _QuerySubscriptionProxy_keepaliveTimer, undefined, "f");
3311
+ if (__classPrivateFieldGet$a(this, _QuerySubscriptionProxy_keepaliveTimer, "f")) {
3312
+ clearTimeout(__classPrivateFieldGet$a(this, _QuerySubscriptionProxy_keepaliveTimer, "f"));
3313
+ __classPrivateFieldSet$a(this, _QuerySubscriptionProxy_keepaliveTimer, undefined, "f");
3314
3314
  }
3315
3315
  try {
3316
3316
  // Initialize the query subscription
3317
3317
  let initialResult;
3318
- initialResult = await __classPrivateFieldGet$9(this, _QuerySubscriptionProxy_client, "f").subscribeQuery(__classPrivateFieldGet$9(this, _QuerySubscriptionProxy_uuid, "f"), __classPrivateFieldGet$9(this, _QuerySubscriptionProxy_query, "f"));
3319
- __classPrivateFieldSet$9(this, _QuerySubscriptionProxy_subscriptionId, initialResult.subscriptionId, "f");
3318
+ initialResult = await __classPrivateFieldGet$a(this, _QuerySubscriptionProxy_client, "f").subscribeQuery(__classPrivateFieldGet$a(this, _QuerySubscriptionProxy_uuid, "f"), __classPrivateFieldGet$a(this, _QuerySubscriptionProxy_query, "f"));
3319
+ __classPrivateFieldSet$a(this, _QuerySubscriptionProxy_subscriptionId, initialResult.subscriptionId, "f");
3320
3320
  // Process the initial result immediately for fast UX.
3321
3321
  // The subscribeQuery() RPC call already returns the initial result,
3322
3322
  // so treat that as successful initialization instead of waiting for a
3323
3323
  // follow-up WebSocket update that may never arrive until the query changes.
3324
3324
  if (initialResult.result !== undefined) {
3325
- __classPrivateFieldSet$9(this, _QuerySubscriptionProxy_latestResult, initialResult.result, "f");
3326
- __classPrivateFieldGet$9(this, _QuerySubscriptionProxy_instances, "m", _QuerySubscriptionProxy_notifyCallbacks).call(this, initialResult.result);
3327
- if (__classPrivateFieldGet$9(this, _QuerySubscriptionProxy_initResolve, "f")) {
3328
- __classPrivateFieldGet$9(this, _QuerySubscriptionProxy_initResolve, "f").call(this, true);
3329
- __classPrivateFieldSet$9(this, _QuerySubscriptionProxy_initResolve, undefined, "f");
3330
- __classPrivateFieldSet$9(this, _QuerySubscriptionProxy_initReject, undefined, "f");
3325
+ __classPrivateFieldSet$a(this, _QuerySubscriptionProxy_latestResult, initialResult.result, "f");
3326
+ __classPrivateFieldGet$a(this, _QuerySubscriptionProxy_instances, "m", _QuerySubscriptionProxy_notifyCallbacks).call(this, initialResult.result);
3327
+ if (__classPrivateFieldGet$a(this, _QuerySubscriptionProxy_initResolve, "f")) {
3328
+ __classPrivateFieldGet$a(this, _QuerySubscriptionProxy_initResolve, "f").call(this, true);
3329
+ __classPrivateFieldSet$a(this, _QuerySubscriptionProxy_initResolve, undefined, "f");
3330
+ __classPrivateFieldSet$a(this, _QuerySubscriptionProxy_initReject, undefined, "f");
3331
3331
  }
3332
3332
  }
3333
3333
  else {
3334
3334
  console.warn('⚠️ No initial result returned from subscribeQuery!');
3335
3335
  // Only keep the initialization timeout when the backend did not
3336
3336
  // provide an initial result up front.
3337
- __classPrivateFieldSet$9(this, _QuerySubscriptionProxy_initTimeoutId, setTimeout(() => {
3337
+ __classPrivateFieldSet$a(this, _QuerySubscriptionProxy_initTimeoutId, setTimeout(() => {
3338
3338
  console.error('Subscription initialization timed out after 30 seconds. Resubscribing...');
3339
3339
  // Recursively retry subscription, catching any errors
3340
3340
  this.subscribe().catch(error => {
@@ -3343,46 +3343,43 @@ class QuerySubscriptionProxy {
3343
3343
  }, 30000), "f");
3344
3344
  }
3345
3345
  // Subscribe to query updates
3346
- __classPrivateFieldSet$9(this, _QuerySubscriptionProxy_unsubscribe, __classPrivateFieldGet$9(this, _QuerySubscriptionProxy_client, "f").subscribeToQueryUpdates(__classPrivateFieldGet$9(this, _QuerySubscriptionProxy_subscriptionId, "f"), (updateResult) => {
3346
+ __classPrivateFieldSet$a(this, _QuerySubscriptionProxy_unsubscribe, __classPrivateFieldGet$a(this, _QuerySubscriptionProxy_client, "f").subscribeToQueryUpdates(__classPrivateFieldGet$a(this, _QuerySubscriptionProxy_subscriptionId, "f"), (updateResult) => {
3347
3347
  // Clear timeout on first message
3348
- if (__classPrivateFieldGet$9(this, _QuerySubscriptionProxy_initTimeoutId, "f")) {
3349
- clearTimeout(__classPrivateFieldGet$9(this, _QuerySubscriptionProxy_initTimeoutId, "f"));
3350
- __classPrivateFieldSet$9(this, _QuerySubscriptionProxy_initTimeoutId, undefined, "f");
3348
+ if (__classPrivateFieldGet$a(this, _QuerySubscriptionProxy_initTimeoutId, "f")) {
3349
+ clearTimeout(__classPrivateFieldGet$a(this, _QuerySubscriptionProxy_initTimeoutId, "f"));
3350
+ __classPrivateFieldSet$a(this, _QuerySubscriptionProxy_initTimeoutId, undefined, "f");
3351
3351
  }
3352
3352
  // Resolve the initialization promise (only resolves once)
3353
- if (__classPrivateFieldGet$9(this, _QuerySubscriptionProxy_initResolve, "f")) {
3354
- __classPrivateFieldGet$9(this, _QuerySubscriptionProxy_initResolve, "f").call(this, true);
3355
- __classPrivateFieldSet$9(this, _QuerySubscriptionProxy_initResolve, undefined, "f"); // Prevent double-resolve
3356
- __classPrivateFieldSet$9(this, _QuerySubscriptionProxy_initReject, undefined, "f");
3353
+ if (__classPrivateFieldGet$a(this, _QuerySubscriptionProxy_initResolve, "f")) {
3354
+ __classPrivateFieldGet$a(this, _QuerySubscriptionProxy_initResolve, "f").call(this, true);
3355
+ __classPrivateFieldSet$a(this, _QuerySubscriptionProxy_initResolve, undefined, "f"); // Prevent double-resolve
3356
+ __classPrivateFieldSet$a(this, _QuerySubscriptionProxy_initReject, undefined, "f");
3357
3357
  }
3358
- // Skip duplicate init messages
3359
- if (updateResult.isInit && __classPrivateFieldGet$9(this, _QuerySubscriptionProxy_latestResult, "f"))
3360
- return;
3361
- __classPrivateFieldSet$9(this, _QuerySubscriptionProxy_latestResult, updateResult, "f");
3362
- __classPrivateFieldGet$9(this, _QuerySubscriptionProxy_instances, "m", _QuerySubscriptionProxy_notifyCallbacks).call(this, updateResult);
3358
+ __classPrivateFieldSet$a(this, _QuerySubscriptionProxy_latestResult, updateResult, "f");
3359
+ __classPrivateFieldGet$a(this, _QuerySubscriptionProxy_instances, "m", _QuerySubscriptionProxy_notifyCallbacks).call(this, updateResult);
3363
3360
  }), "f");
3364
3361
  }
3365
3362
  catch (error) {
3366
3363
  console.error('Error setting up subscription:', error);
3367
3364
  // Reject the promise if this is the first attempt
3368
- if (__classPrivateFieldGet$9(this, _QuerySubscriptionProxy_initReject, "f")) {
3369
- __classPrivateFieldGet$9(this, _QuerySubscriptionProxy_initReject, "f").call(this, error);
3370
- __classPrivateFieldSet$9(this, _QuerySubscriptionProxy_initResolve, undefined, "f");
3371
- __classPrivateFieldSet$9(this, _QuerySubscriptionProxy_initReject, undefined, "f");
3365
+ if (__classPrivateFieldGet$a(this, _QuerySubscriptionProxy_initReject, "f")) {
3366
+ __classPrivateFieldGet$a(this, _QuerySubscriptionProxy_initReject, "f").call(this, error);
3367
+ __classPrivateFieldSet$a(this, _QuerySubscriptionProxy_initResolve, undefined, "f");
3368
+ __classPrivateFieldSet$a(this, _QuerySubscriptionProxy_initReject, undefined, "f");
3372
3369
  }
3373
3370
  throw error; // Re-throw so caller knows it failed
3374
3371
  }
3375
3372
  // Start keepalive loop using platform-agnostic setTimeout
3376
3373
  const keepaliveLoop = async () => {
3377
- if (__classPrivateFieldGet$9(this, _QuerySubscriptionProxy_disposed, "f"))
3374
+ if (__classPrivateFieldGet$a(this, _QuerySubscriptionProxy_disposed, "f"))
3378
3375
  return;
3379
3376
  try {
3380
- await __classPrivateFieldGet$9(this, _QuerySubscriptionProxy_client, "f").keepAliveQuery(__classPrivateFieldGet$9(this, _QuerySubscriptionProxy_uuid, "f"), __classPrivateFieldGet$9(this, _QuerySubscriptionProxy_subscriptionId, "f"));
3377
+ await __classPrivateFieldGet$a(this, _QuerySubscriptionProxy_client, "f").keepAliveQuery(__classPrivateFieldGet$a(this, _QuerySubscriptionProxy_uuid, "f"), __classPrivateFieldGet$a(this, _QuerySubscriptionProxy_subscriptionId, "f"));
3381
3378
  }
3382
3379
  catch (e) {
3383
3380
  console.error('Error in keepalive:', e);
3384
3381
  // try to reinitialize the subscription
3385
- console.log('Reinitializing subscription for query:', __classPrivateFieldGet$9(this, _QuerySubscriptionProxy_query, "f"));
3382
+ console.log('Reinitializing subscription for query:', __classPrivateFieldGet$a(this, _QuerySubscriptionProxy_query, "f"));
3386
3383
  try {
3387
3384
  await this.subscribe();
3388
3385
  console.log('Subscription reinitialized');
@@ -3394,12 +3391,12 @@ class QuerySubscriptionProxy {
3394
3391
  }
3395
3392
  }
3396
3393
  // Schedule next keepalive if not disposed
3397
- if (!__classPrivateFieldGet$9(this, _QuerySubscriptionProxy_disposed, "f")) {
3398
- __classPrivateFieldSet$9(this, _QuerySubscriptionProxy_keepaliveTimer, setTimeout(keepaliveLoop, 30000), "f");
3394
+ if (!__classPrivateFieldGet$a(this, _QuerySubscriptionProxy_disposed, "f")) {
3395
+ __classPrivateFieldSet$a(this, _QuerySubscriptionProxy_keepaliveTimer, setTimeout(keepaliveLoop, 30000), "f");
3399
3396
  }
3400
3397
  };
3401
3398
  // Start the first keepalive loop
3402
- __classPrivateFieldSet$9(this, _QuerySubscriptionProxy_keepaliveTimer, setTimeout(keepaliveLoop, 30000), "f");
3399
+ __classPrivateFieldSet$a(this, _QuerySubscriptionProxy_keepaliveTimer, setTimeout(keepaliveLoop, 30000), "f");
3403
3400
  }
3404
3401
  /** Get the subscription ID for this query subscription
3405
3402
  *
@@ -3410,7 +3407,7 @@ class QuerySubscriptionProxy {
3410
3407
  * @returns The subscription ID string
3411
3408
  */
3412
3409
  get id() {
3413
- return __classPrivateFieldGet$9(this, _QuerySubscriptionProxy_subscriptionId, "f");
3410
+ return __classPrivateFieldGet$a(this, _QuerySubscriptionProxy_subscriptionId, "f");
3414
3411
  }
3415
3412
  /** Promise that resolves when the subscription has received its first result
3416
3413
  * through the subscription channel. This ensures the subscription is fully
@@ -3424,7 +3421,7 @@ class QuerySubscriptionProxy {
3424
3421
  * creation methods (like subscribeInfer) already wait for initialization.
3425
3422
  */
3426
3423
  get initialized() {
3427
- return __classPrivateFieldGet$9(this, _QuerySubscriptionProxy_initialized, "f");
3424
+ return __classPrivateFieldGet$a(this, _QuerySubscriptionProxy_initialized, "f");
3428
3425
  }
3429
3426
  /** Get the latest query result
3430
3427
  *
@@ -3435,7 +3432,7 @@ class QuerySubscriptionProxy {
3435
3432
  * @returns The latest query result as a string (usually a JSON array of bindings)
3436
3433
  */
3437
3434
  get result() {
3438
- return __classPrivateFieldGet$9(this, _QuerySubscriptionProxy_latestResult, "f");
3435
+ return __classPrivateFieldGet$a(this, _QuerySubscriptionProxy_latestResult, "f");
3439
3436
  }
3440
3437
  /** Add a callback that will be called whenever new results arrive
3441
3438
  *
@@ -3457,8 +3454,8 @@ class QuerySubscriptionProxy {
3457
3454
  * ```
3458
3455
  */
3459
3456
  onResult(callback) {
3460
- __classPrivateFieldGet$9(this, _QuerySubscriptionProxy_callbacks, "f").add(callback);
3461
- return () => __classPrivateFieldGet$9(this, _QuerySubscriptionProxy_callbacks, "f").delete(callback);
3457
+ __classPrivateFieldGet$a(this, _QuerySubscriptionProxy_callbacks, "f").add(callback);
3458
+ return () => __classPrivateFieldGet$a(this, _QuerySubscriptionProxy_callbacks, "f").delete(callback);
3462
3459
  }
3463
3460
  /** Clean up the subscription and stop keepalive signals
3464
3461
  *
@@ -3472,25 +3469,25 @@ class QuerySubscriptionProxy {
3472
3469
  * will not receive any more updates. The instance should be discarded.
3473
3470
  */
3474
3471
  dispose() {
3475
- __classPrivateFieldSet$9(this, _QuerySubscriptionProxy_disposed, true, "f");
3476
- clearTimeout(__classPrivateFieldGet$9(this, _QuerySubscriptionProxy_keepaliveTimer, "f"));
3477
- if (__classPrivateFieldGet$9(this, _QuerySubscriptionProxy_unsubscribe, "f")) {
3478
- __classPrivateFieldGet$9(this, _QuerySubscriptionProxy_unsubscribe, "f").call(this);
3472
+ __classPrivateFieldSet$a(this, _QuerySubscriptionProxy_disposed, true, "f");
3473
+ clearTimeout(__classPrivateFieldGet$a(this, _QuerySubscriptionProxy_keepaliveTimer, "f"));
3474
+ if (__classPrivateFieldGet$a(this, _QuerySubscriptionProxy_unsubscribe, "f")) {
3475
+ __classPrivateFieldGet$a(this, _QuerySubscriptionProxy_unsubscribe, "f").call(this);
3479
3476
  }
3480
- __classPrivateFieldGet$9(this, _QuerySubscriptionProxy_callbacks, "f").clear();
3481
- if (__classPrivateFieldGet$9(this, _QuerySubscriptionProxy_initTimeoutId, "f")) {
3482
- clearTimeout(__classPrivateFieldGet$9(this, _QuerySubscriptionProxy_initTimeoutId, "f"));
3483
- __classPrivateFieldSet$9(this, _QuerySubscriptionProxy_initTimeoutId, undefined, "f");
3477
+ __classPrivateFieldGet$a(this, _QuerySubscriptionProxy_callbacks, "f").clear();
3478
+ if (__classPrivateFieldGet$a(this, _QuerySubscriptionProxy_initTimeoutId, "f")) {
3479
+ clearTimeout(__classPrivateFieldGet$a(this, _QuerySubscriptionProxy_initTimeoutId, "f"));
3480
+ __classPrivateFieldSet$a(this, _QuerySubscriptionProxy_initTimeoutId, undefined, "f");
3484
3481
  }
3485
3482
  // Tell the backend to dispose of the subscription
3486
- if (__classPrivateFieldGet$9(this, _QuerySubscriptionProxy_subscriptionId, "f")) {
3487
- __classPrivateFieldGet$9(this, _QuerySubscriptionProxy_client, "f").disposeQuerySubscription(__classPrivateFieldGet$9(this, _QuerySubscriptionProxy_uuid, "f"), __classPrivateFieldGet$9(this, _QuerySubscriptionProxy_subscriptionId, "f"))
3483
+ if (__classPrivateFieldGet$a(this, _QuerySubscriptionProxy_subscriptionId, "f")) {
3484
+ __classPrivateFieldGet$a(this, _QuerySubscriptionProxy_client, "f").disposeQuerySubscription(__classPrivateFieldGet$a(this, _QuerySubscriptionProxy_uuid, "f"), __classPrivateFieldGet$a(this, _QuerySubscriptionProxy_subscriptionId, "f"))
3488
3485
  .catch(e => console.error('Error disposing query subscription:', e));
3489
3486
  }
3490
3487
  }
3491
3488
  }
3492
3489
  _QuerySubscriptionProxy_uuid = new WeakMap(), _QuerySubscriptionProxy_subscriptionId = new WeakMap(), _QuerySubscriptionProxy_client = new WeakMap(), _QuerySubscriptionProxy_callbacks = new WeakMap(), _QuerySubscriptionProxy_keepaliveTimer = new WeakMap(), _QuerySubscriptionProxy_unsubscribe = new WeakMap(), _QuerySubscriptionProxy_latestResult = new WeakMap(), _QuerySubscriptionProxy_disposed = new WeakMap(), _QuerySubscriptionProxy_initialized = new WeakMap(), _QuerySubscriptionProxy_initResolve = new WeakMap(), _QuerySubscriptionProxy_initReject = new WeakMap(), _QuerySubscriptionProxy_initTimeoutId = new WeakMap(), _QuerySubscriptionProxy_query = new WeakMap(), _QuerySubscriptionProxy_instances = new WeakSet(), _QuerySubscriptionProxy_notifyCallbacks = function _QuerySubscriptionProxy_notifyCallbacks(result) {
3493
- for (const callback of __classPrivateFieldGet$9(this, _QuerySubscriptionProxy_callbacks, "f")) {
3490
+ for (const callback of __classPrivateFieldGet$a(this, _QuerySubscriptionProxy_callbacks, "f")) {
3494
3491
  try {
3495
3492
  callback(result);
3496
3493
  }
@@ -3540,7 +3537,7 @@ _QuerySubscriptionProxy_uuid = new WeakMap(), _QuerySubscriptionProxy_subscripti
3540
3537
  */
3541
3538
  class PerspectiveProxy {
3542
3539
  /** @internal Exposed for ModelQueryBuilder subscription management */
3543
- get client() { return __classPrivateFieldGet$9(this, _PerspectiveProxy_client, "f"); }
3540
+ get client() { return __classPrivateFieldGet$a(this, _PerspectiveProxy_client, "f"); }
3544
3541
  /**
3545
3542
  * Creates a new PerspectiveProxy instance.
3546
3543
  * Note: Don't create this directly, use ad4m.perspective.add() instead.
@@ -3558,31 +3555,31 @@ class PerspectiveProxy {
3558
3555
  * Note: Don't create this directly, use ad4m.perspective.add() instead.
3559
3556
  */
3560
3557
  );
3561
- __classPrivateFieldSet$9(this, _PerspectiveProxy_perspectiveLinkAddedCallbacks, [], "f");
3562
- __classPrivateFieldSet$9(this, _PerspectiveProxy_perspectiveLinkRemovedCallbacks, [], "f");
3563
- __classPrivateFieldSet$9(this, _PerspectiveProxy_perspectiveLinkUpdatedCallbacks, [], "f");
3564
- __classPrivateFieldSet$9(this, _PerspectiveProxy_perspectiveSyncStateChangeCallbacks, [], "f");
3565
- __classPrivateFieldSet$9(this, _PerspectiveProxy_handle, handle, "f");
3566
- __classPrivateFieldSet$9(this, _PerspectiveProxy_client, ad4m, "f");
3567
- this.uuid = __classPrivateFieldGet$9(this, _PerspectiveProxy_handle, "f").uuid;
3568
- this.name = __classPrivateFieldGet$9(this, _PerspectiveProxy_handle, "f").name;
3569
- this.owners = __classPrivateFieldGet$9(this, _PerspectiveProxy_handle, "f").owners;
3570
- this.sharedUrl = __classPrivateFieldGet$9(this, _PerspectiveProxy_handle, "f").sharedUrl;
3571
- this.neighbourhood = __classPrivateFieldGet$9(this, _PerspectiveProxy_handle, "f").neighbourhood;
3572
- this.state = __classPrivateFieldGet$9(this, _PerspectiveProxy_handle, "f").state;
3573
- __classPrivateFieldGet$9(this, _PerspectiveProxy_client, "f").addPerspectiveLinkAddedListener(__classPrivateFieldGet$9(this, _PerspectiveProxy_handle, "f").uuid, __classPrivateFieldGet$9(this, _PerspectiveProxy_perspectiveLinkAddedCallbacks, "f"));
3574
- __classPrivateFieldGet$9(this, _PerspectiveProxy_client, "f").addPerspectiveLinkRemovedListener(__classPrivateFieldGet$9(this, _PerspectiveProxy_handle, "f").uuid, __classPrivateFieldGet$9(this, _PerspectiveProxy_perspectiveLinkRemovedCallbacks, "f"));
3575
- __classPrivateFieldGet$9(this, _PerspectiveProxy_client, "f").addPerspectiveLinkUpdatedListener(__classPrivateFieldGet$9(this, _PerspectiveProxy_handle, "f").uuid, __classPrivateFieldGet$9(this, _PerspectiveProxy_perspectiveLinkUpdatedCallbacks, "f"));
3576
- __classPrivateFieldGet$9(this, _PerspectiveProxy_client, "f").addPerspectiveSyncStateChangeListener(__classPrivateFieldGet$9(this, _PerspectiveProxy_handle, "f").uuid, __classPrivateFieldGet$9(this, _PerspectiveProxy_perspectiveSyncStateChangeCallbacks, "f"));
3558
+ __classPrivateFieldSet$a(this, _PerspectiveProxy_perspectiveLinkAddedCallbacks, [], "f");
3559
+ __classPrivateFieldSet$a(this, _PerspectiveProxy_perspectiveLinkRemovedCallbacks, [], "f");
3560
+ __classPrivateFieldSet$a(this, _PerspectiveProxy_perspectiveLinkUpdatedCallbacks, [], "f");
3561
+ __classPrivateFieldSet$a(this, _PerspectiveProxy_perspectiveSyncStateChangeCallbacks, [], "f");
3562
+ __classPrivateFieldSet$a(this, _PerspectiveProxy_handle, handle, "f");
3563
+ __classPrivateFieldSet$a(this, _PerspectiveProxy_client, ad4m, "f");
3564
+ this.uuid = __classPrivateFieldGet$a(this, _PerspectiveProxy_handle, "f").uuid;
3565
+ this.name = __classPrivateFieldGet$a(this, _PerspectiveProxy_handle, "f").name;
3566
+ this.owners = __classPrivateFieldGet$a(this, _PerspectiveProxy_handle, "f").owners;
3567
+ this.sharedUrl = __classPrivateFieldGet$a(this, _PerspectiveProxy_handle, "f").sharedUrl;
3568
+ this.neighbourhood = __classPrivateFieldGet$a(this, _PerspectiveProxy_handle, "f").neighbourhood;
3569
+ this.state = __classPrivateFieldGet$a(this, _PerspectiveProxy_handle, "f").state;
3570
+ __classPrivateFieldGet$a(this, _PerspectiveProxy_client, "f").addPerspectiveLinkAddedListener(__classPrivateFieldGet$a(this, _PerspectiveProxy_handle, "f").uuid, __classPrivateFieldGet$a(this, _PerspectiveProxy_perspectiveLinkAddedCallbacks, "f"));
3571
+ __classPrivateFieldGet$a(this, _PerspectiveProxy_client, "f").addPerspectiveLinkRemovedListener(__classPrivateFieldGet$a(this, _PerspectiveProxy_handle, "f").uuid, __classPrivateFieldGet$a(this, _PerspectiveProxy_perspectiveLinkRemovedCallbacks, "f"));
3572
+ __classPrivateFieldGet$a(this, _PerspectiveProxy_client, "f").addPerspectiveLinkUpdatedListener(__classPrivateFieldGet$a(this, _PerspectiveProxy_handle, "f").uuid, __classPrivateFieldGet$a(this, _PerspectiveProxy_perspectiveLinkUpdatedCallbacks, "f"));
3573
+ __classPrivateFieldGet$a(this, _PerspectiveProxy_client, "f").addPerspectiveSyncStateChangeListener(__classPrivateFieldGet$a(this, _PerspectiveProxy_handle, "f").uuid, __classPrivateFieldGet$a(this, _PerspectiveProxy_perspectiveSyncStateChangeCallbacks, "f"));
3577
3574
  }
3578
3575
  /** Update the proxy's internal handle and public fields in-place.
3579
3576
  * Keeps the same object reference so all holders see the update. */
3580
3577
  updateHandle(handle) {
3581
- if (handle.uuid !== __classPrivateFieldGet$9(this, _PerspectiveProxy_handle, "f").uuid) {
3582
- throw new Error(`PerspectiveProxy.updateHandle: UUID mismatch — proxy is bound to "${__classPrivateFieldGet$9(this, _PerspectiveProxy_handle, "f").uuid}" but received handle with UUID "${handle.uuid}". ` +
3578
+ if (handle.uuid !== __classPrivateFieldGet$a(this, _PerspectiveProxy_handle, "f").uuid) {
3579
+ throw new Error(`PerspectiveProxy.updateHandle: UUID mismatch — proxy is bound to "${__classPrivateFieldGet$a(this, _PerspectiveProxy_handle, "f").uuid}" but received handle with UUID "${handle.uuid}". ` +
3583
3580
  `This would silently diverge from listeners registered under the original UUID.`);
3584
3581
  }
3585
- __classPrivateFieldSet$9(this, _PerspectiveProxy_handle, handle, "f");
3582
+ __classPrivateFieldSet$a(this, _PerspectiveProxy_handle, handle, "f");
3586
3583
  this.uuid = handle.uuid;
3587
3584
  this.name = handle.name;
3588
3585
  this.owners = handle.owners;
@@ -3663,8 +3660,8 @@ class PerspectiveProxy {
3663
3660
  * @param batchId - Optional batch ID to group this operation with others
3664
3661
  */
3665
3662
  async executeAction(actions, expression, parameters, batchId) {
3666
- const result = await __classPrivateFieldGet$9(this, _PerspectiveProxy_client, "f").executeCommands(__classPrivateFieldGet$9(this, _PerspectiveProxy_handle, "f").uuid, JSON.stringify(actions), expression, JSON.stringify(parameters), batchId);
3667
- invalidatePerspectiveCache(__classPrivateFieldGet$9(this, _PerspectiveProxy_handle, "f").uuid);
3663
+ const result = await __classPrivateFieldGet$a(this, _PerspectiveProxy_client, "f").executeCommands(__classPrivateFieldGet$a(this, _PerspectiveProxy_handle, "f").uuid, JSON.stringify(actions), expression, JSON.stringify(parameters), batchId);
3664
+ invalidatePerspectiveCache(__classPrivateFieldGet$a(this, _PerspectiveProxy_handle, "f").uuid);
3668
3665
  return result;
3669
3666
  }
3670
3667
  /**
@@ -3689,7 +3686,7 @@ class PerspectiveProxy {
3689
3686
  * ```
3690
3687
  */
3691
3688
  async get(query) {
3692
- return await __classPrivateFieldGet$9(this, _PerspectiveProxy_client, "f").queryLinks(__classPrivateFieldGet$9(this, _PerspectiveProxy_handle, "f").uuid, query);
3689
+ return await __classPrivateFieldGet$a(this, _PerspectiveProxy_client, "f").queryLinks(__classPrivateFieldGet$a(this, _PerspectiveProxy_handle, "f").uuid, query);
3693
3690
  }
3694
3691
  /**
3695
3692
  * Executes a Prolog query against the perspective's knowledge base.
@@ -3715,7 +3712,7 @@ class PerspectiveProxy {
3715
3712
  * ```
3716
3713
  */
3717
3714
  async infer(query) {
3718
- return await __classPrivateFieldGet$9(this, _PerspectiveProxy_client, "f").queryProlog(__classPrivateFieldGet$9(this, _PerspectiveProxy_handle, "f").uuid, query);
3715
+ return await __classPrivateFieldGet$a(this, _PerspectiveProxy_client, "f").queryProlog(__classPrivateFieldGet$a(this, _PerspectiveProxy_handle, "f").uuid, query);
3719
3716
  }
3720
3717
  /**
3721
3718
  * Executes a SPARQL query against the perspective's link cache.
@@ -3734,11 +3731,11 @@ class PerspectiveProxy {
3734
3731
  * @returns Query results as parsed JSON
3735
3732
  */
3736
3733
  async querySparql(query) {
3737
- const cached = getCachedResult(__classPrivateFieldGet$9(this, _PerspectiveProxy_handle, "f").uuid, query);
3734
+ const cached = getCachedResult(__classPrivateFieldGet$a(this, _PerspectiveProxy_handle, "f").uuid, query);
3738
3735
  if (cached !== undefined)
3739
3736
  return cached;
3740
- const result = await __classPrivateFieldGet$9(this, _PerspectiveProxy_client, "f").querySparql(__classPrivateFieldGet$9(this, _PerspectiveProxy_handle, "f").uuid, query);
3741
- setCachedResult(__classPrivateFieldGet$9(this, _PerspectiveProxy_handle, "f").uuid, query, result);
3737
+ const result = await __classPrivateFieldGet$a(this, _PerspectiveProxy_client, "f").querySparql(__classPrivateFieldGet$a(this, _PerspectiveProxy_handle, "f").uuid, query);
3738
+ setCachedResult(__classPrivateFieldGet$a(this, _PerspectiveProxy_handle, "f").uuid, query, result);
3742
3739
  return result;
3743
3740
  }
3744
3741
  /**
@@ -3750,7 +3747,7 @@ class PerspectiveProxy {
3750
3747
  * @returns Object with `instances` array and `totalCount`
3751
3748
  */
3752
3749
  async modelQuery(className, queryJson, shapeJson) {
3753
- return await __classPrivateFieldGet$9(this, _PerspectiveProxy_client, "f").modelQuery(__classPrivateFieldGet$9(this, _PerspectiveProxy_handle, "f").uuid, className, queryJson, shapeJson);
3750
+ return await __classPrivateFieldGet$a(this, _PerspectiveProxy_client, "f").modelQuery(__classPrivateFieldGet$a(this, _PerspectiveProxy_handle, "f").uuid, className, queryJson, shapeJson);
3754
3751
  }
3755
3752
  /**
3756
3753
  * Evaluate property getters for a batch of instances in a single RPC call.
@@ -3766,7 +3763,7 @@ class PerspectiveProxy {
3766
3763
  * @returns Map of instance ID → evaluated property values
3767
3764
  */
3768
3765
  async evaluateGetters(className, instanceIds, shapeJson, propertyNames) {
3769
- return await __classPrivateFieldGet$9(this, _PerspectiveProxy_client, "f").evaluateGetters(__classPrivateFieldGet$9(this, _PerspectiveProxy_handle, "f").uuid, className, instanceIds, shapeJson, propertyNames);
3766
+ return await __classPrivateFieldGet$a(this, _PerspectiveProxy_client, "f").evaluateGetters(__classPrivateFieldGet$a(this, _PerspectiveProxy_handle, "f").uuid, className, instanceIds, shapeJson, propertyNames);
3770
3767
  }
3771
3768
  /**
3772
3769
  * Subscribe to model query changes. Builds trigger SPARQL from the model shape
@@ -3782,7 +3779,7 @@ class PerspectiveProxy {
3782
3779
  * @returns Object with `subscriptionId` and initial `result`
3783
3780
  */
3784
3781
  async modelSubscribe(className, queryJson, shapeJson) {
3785
- return await __classPrivateFieldGet$9(this, _PerspectiveProxy_client, "f").modelSubscribe(__classPrivateFieldGet$9(this, _PerspectiveProxy_handle, "f").uuid, className, queryJson, shapeJson);
3782
+ return await __classPrivateFieldGet$a(this, _PerspectiveProxy_client, "f").modelSubscribe(__classPrivateFieldGet$a(this, _PerspectiveProxy_handle, "f").uuid, className, queryJson, shapeJson);
3786
3783
  }
3787
3784
  /**
3788
3785
  * Adds a new link to the perspective.
@@ -3810,8 +3807,8 @@ class PerspectiveProxy {
3810
3807
  * ```
3811
3808
  */
3812
3809
  async add(link, status = 'shared', batchId) {
3813
- const result = await __classPrivateFieldGet$9(this, _PerspectiveProxy_client, "f").addLink(__classPrivateFieldGet$9(this, _PerspectiveProxy_handle, "f").uuid, link, status, batchId);
3814
- invalidatePerspectiveCache(__classPrivateFieldGet$9(this, _PerspectiveProxy_handle, "f").uuid);
3810
+ const result = await __classPrivateFieldGet$a(this, _PerspectiveProxy_client, "f").addLink(__classPrivateFieldGet$a(this, _PerspectiveProxy_handle, "f").uuid, link, status, batchId);
3811
+ invalidatePerspectiveCache(__classPrivateFieldGet$a(this, _PerspectiveProxy_handle, "f").uuid);
3815
3812
  return result;
3816
3813
  }
3817
3814
  /**
@@ -3824,8 +3821,8 @@ class PerspectiveProxy {
3824
3821
  * @returns Array of created LinkExpressions
3825
3822
  */
3826
3823
  async addLinks(links, status = 'shared', batchId) {
3827
- const result = await __classPrivateFieldGet$9(this, _PerspectiveProxy_client, "f").addLinks(__classPrivateFieldGet$9(this, _PerspectiveProxy_handle, "f").uuid, links, status, batchId);
3828
- invalidatePerspectiveCache(__classPrivateFieldGet$9(this, _PerspectiveProxy_handle, "f").uuid);
3824
+ const result = await __classPrivateFieldGet$a(this, _PerspectiveProxy_client, "f").addLinks(__classPrivateFieldGet$a(this, _PerspectiveProxy_handle, "f").uuid, links, status, batchId);
3825
+ invalidatePerspectiveCache(__classPrivateFieldGet$a(this, _PerspectiveProxy_handle, "f").uuid);
3829
3826
  return result;
3830
3827
  }
3831
3828
  /**
@@ -3836,8 +3833,8 @@ class PerspectiveProxy {
3836
3833
  * @returns Array of removed LinkExpressions
3837
3834
  */
3838
3835
  async removeLinks(links, batchId) {
3839
- const result = await __classPrivateFieldGet$9(this, _PerspectiveProxy_client, "f").removeLinks(__classPrivateFieldGet$9(this, _PerspectiveProxy_handle, "f").uuid, links, batchId);
3840
- invalidatePerspectiveCache(__classPrivateFieldGet$9(this, _PerspectiveProxy_handle, "f").uuid);
3836
+ const result = await __classPrivateFieldGet$a(this, _PerspectiveProxy_client, "f").removeLinks(__classPrivateFieldGet$a(this, _PerspectiveProxy_handle, "f").uuid, links, batchId);
3837
+ invalidatePerspectiveCache(__classPrivateFieldGet$a(this, _PerspectiveProxy_handle, "f").uuid);
3841
3838
  return result;
3842
3839
  }
3843
3840
  /**
@@ -3849,8 +3846,8 @@ class PerspectiveProxy {
3849
3846
  * @returns Object containing results of the mutations
3850
3847
  */
3851
3848
  async linkMutations(mutations, status = 'shared') {
3852
- const result = await __classPrivateFieldGet$9(this, _PerspectiveProxy_client, "f").linkMutations(__classPrivateFieldGet$9(this, _PerspectiveProxy_handle, "f").uuid, mutations, status);
3853
- invalidatePerspectiveCache(__classPrivateFieldGet$9(this, _PerspectiveProxy_handle, "f").uuid);
3849
+ const result = await __classPrivateFieldGet$a(this, _PerspectiveProxy_client, "f").linkMutations(__classPrivateFieldGet$a(this, _PerspectiveProxy_handle, "f").uuid, mutations, status);
3850
+ invalidatePerspectiveCache(__classPrivateFieldGet$a(this, _PerspectiveProxy_handle, "f").uuid);
3854
3851
  return result;
3855
3852
  }
3856
3853
  /**
@@ -3862,7 +3859,7 @@ class PerspectiveProxy {
3862
3859
  * @returns The added LinkExpression
3863
3860
  */
3864
3861
  async addLinkExpression(link, status = 'shared', batchId) {
3865
- return await __classPrivateFieldGet$9(this, _PerspectiveProxy_client, "f").addLinkExpression(__classPrivateFieldGet$9(this, _PerspectiveProxy_handle, "f").uuid, link, status, batchId);
3862
+ return await __classPrivateFieldGet$a(this, _PerspectiveProxy_client, "f").addLinkExpression(__classPrivateFieldGet$a(this, _PerspectiveProxy_handle, "f").uuid, link, status, batchId);
3866
3863
  }
3867
3864
  /**
3868
3865
  * Updates an existing link with new data.
@@ -3872,8 +3869,8 @@ class PerspectiveProxy {
3872
3869
  * @param batchId - Optional batch ID to group this operation with others
3873
3870
  */
3874
3871
  async update(oldLink, newLink, batchId) {
3875
- const result = await __classPrivateFieldGet$9(this, _PerspectiveProxy_client, "f").updateLink(__classPrivateFieldGet$9(this, _PerspectiveProxy_handle, "f").uuid, oldLink, newLink, batchId);
3876
- invalidatePerspectiveCache(__classPrivateFieldGet$9(this, _PerspectiveProxy_handle, "f").uuid);
3872
+ const result = await __classPrivateFieldGet$a(this, _PerspectiveProxy_client, "f").updateLink(__classPrivateFieldGet$a(this, _PerspectiveProxy_handle, "f").uuid, oldLink, newLink, batchId);
3873
+ invalidatePerspectiveCache(__classPrivateFieldGet$a(this, _PerspectiveProxy_handle, "f").uuid);
3877
3874
  return result;
3878
3875
  }
3879
3876
  /**
@@ -3883,18 +3880,18 @@ class PerspectiveProxy {
3883
3880
  * @param batchId - Optional batch ID to group this operation with others
3884
3881
  */
3885
3882
  async remove(link, batchId) {
3886
- const result = await __classPrivateFieldGet$9(this, _PerspectiveProxy_client, "f").removeLink(__classPrivateFieldGet$9(this, _PerspectiveProxy_handle, "f").uuid, link, batchId);
3887
- invalidatePerspectiveCache(__classPrivateFieldGet$9(this, _PerspectiveProxy_handle, "f").uuid);
3883
+ const result = await __classPrivateFieldGet$a(this, _PerspectiveProxy_client, "f").removeLink(__classPrivateFieldGet$a(this, _PerspectiveProxy_handle, "f").uuid, link, batchId);
3884
+ invalidatePerspectiveCache(__classPrivateFieldGet$a(this, _PerspectiveProxy_handle, "f").uuid);
3888
3885
  return result;
3889
3886
  }
3890
3887
  /** Creates a new batch for grouping operations */
3891
3888
  async createBatch() {
3892
- return await __classPrivateFieldGet$9(this, _PerspectiveProxy_client, "f").createBatch(__classPrivateFieldGet$9(this, _PerspectiveProxy_handle, "f").uuid);
3889
+ return await __classPrivateFieldGet$a(this, _PerspectiveProxy_client, "f").createBatch(__classPrivateFieldGet$a(this, _PerspectiveProxy_handle, "f").uuid);
3893
3890
  }
3894
3891
  /** Commits a batch of operations */
3895
3892
  async commitBatch(batchId) {
3896
- const result = await __classPrivateFieldGet$9(this, _PerspectiveProxy_client, "f").commitBatch(__classPrivateFieldGet$9(this, _PerspectiveProxy_handle, "f").uuid, batchId);
3897
- invalidatePerspectiveCache(__classPrivateFieldGet$9(this, _PerspectiveProxy_handle, "f").uuid);
3893
+ const result = await __classPrivateFieldGet$a(this, _PerspectiveProxy_client, "f").commitBatch(__classPrivateFieldGet$a(this, _PerspectiveProxy_handle, "f").uuid, batchId);
3894
+ invalidatePerspectiveCache(__classPrivateFieldGet$a(this, _PerspectiveProxy_handle, "f").uuid);
3898
3895
  return result;
3899
3896
  }
3900
3897
  /**
@@ -3904,7 +3901,7 @@ class PerspectiveProxy {
3904
3901
  * @returns The rendered Expression
3905
3902
  */
3906
3903
  async getExpression(expressionURI) {
3907
- return await __classPrivateFieldGet$9(this, _PerspectiveProxy_client, "f").getExpression(expressionURI);
3904
+ return await __classPrivateFieldGet$a(this, _PerspectiveProxy_client, "f").getExpression(expressionURI);
3908
3905
  }
3909
3906
  /**
3910
3907
  * Creates a new Expression in the specified Language.
@@ -3914,7 +3911,7 @@ class PerspectiveProxy {
3914
3911
  * @returns URI of the created Expression
3915
3912
  */
3916
3913
  async createExpression(content, languageAddress) {
3917
- return await __classPrivateFieldGet$9(this, _PerspectiveProxy_client, "f").createExpression(content, languageAddress);
3914
+ return await __classPrivateFieldGet$a(this, _PerspectiveProxy_client, "f").createExpression(content, languageAddress);
3918
3915
  }
3919
3916
  /**
3920
3917
  * Subscribes to link changes in the perspective.
@@ -3937,13 +3934,13 @@ class PerspectiveProxy {
3937
3934
  */
3938
3935
  async addListener(type, cb) {
3939
3936
  if (type === 'link-added') {
3940
- __classPrivateFieldGet$9(this, _PerspectiveProxy_perspectiveLinkAddedCallbacks, "f").push(cb);
3937
+ __classPrivateFieldGet$a(this, _PerspectiveProxy_perspectiveLinkAddedCallbacks, "f").push(cb);
3941
3938
  }
3942
3939
  else if (type === 'link-removed') {
3943
- __classPrivateFieldGet$9(this, _PerspectiveProxy_perspectiveLinkRemovedCallbacks, "f").push(cb);
3940
+ __classPrivateFieldGet$a(this, _PerspectiveProxy_perspectiveLinkRemovedCallbacks, "f").push(cb);
3944
3941
  }
3945
3942
  else if (type === 'link-updated') {
3946
- __classPrivateFieldGet$9(this, _PerspectiveProxy_perspectiveLinkUpdatedCallbacks, "f").push(cb);
3943
+ __classPrivateFieldGet$a(this, _PerspectiveProxy_perspectiveLinkUpdatedCallbacks, "f").push(cb);
3947
3944
  }
3948
3945
  }
3949
3946
  /**
@@ -3959,7 +3956,7 @@ class PerspectiveProxy {
3959
3956
  * ```
3960
3957
  */
3961
3958
  async addSyncStateChangeListener(cb) {
3962
- __classPrivateFieldGet$9(this, _PerspectiveProxy_perspectiveSyncStateChangeCallbacks, "f").push(cb);
3959
+ __classPrivateFieldGet$a(this, _PerspectiveProxy_perspectiveSyncStateChangeCallbacks, "f").push(cb);
3963
3960
  }
3964
3961
  /**
3965
3962
  * Unsubscribes from link changes.
@@ -3969,16 +3966,16 @@ class PerspectiveProxy {
3969
3966
  */
3970
3967
  async removeListener(type, cb) {
3971
3968
  if (type === 'link-added') {
3972
- const index = __classPrivateFieldGet$9(this, _PerspectiveProxy_perspectiveLinkAddedCallbacks, "f").indexOf(cb);
3973
- __classPrivateFieldGet$9(this, _PerspectiveProxy_perspectiveLinkAddedCallbacks, "f").splice(index, 1);
3969
+ const index = __classPrivateFieldGet$a(this, _PerspectiveProxy_perspectiveLinkAddedCallbacks, "f").indexOf(cb);
3970
+ __classPrivateFieldGet$a(this, _PerspectiveProxy_perspectiveLinkAddedCallbacks, "f").splice(index, 1);
3974
3971
  }
3975
3972
  else if (type === 'link-removed') {
3976
- const index = __classPrivateFieldGet$9(this, _PerspectiveProxy_perspectiveLinkRemovedCallbacks, "f").indexOf(cb);
3977
- __classPrivateFieldGet$9(this, _PerspectiveProxy_perspectiveLinkRemovedCallbacks, "f").splice(index, 1);
3973
+ const index = __classPrivateFieldGet$a(this, _PerspectiveProxy_perspectiveLinkRemovedCallbacks, "f").indexOf(cb);
3974
+ __classPrivateFieldGet$a(this, _PerspectiveProxy_perspectiveLinkRemovedCallbacks, "f").splice(index, 1);
3978
3975
  }
3979
3976
  else if (type === 'link-updated') {
3980
- const index = __classPrivateFieldGet$9(this, _PerspectiveProxy_perspectiveLinkUpdatedCallbacks, "f").indexOf(cb);
3981
- __classPrivateFieldGet$9(this, _PerspectiveProxy_perspectiveLinkUpdatedCallbacks, "f").splice(index, 1);
3977
+ const index = __classPrivateFieldGet$a(this, _PerspectiveProxy_perspectiveLinkUpdatedCallbacks, "f").indexOf(cb);
3978
+ __classPrivateFieldGet$a(this, _PerspectiveProxy_perspectiveLinkUpdatedCallbacks, "f").splice(index, 1);
3982
3979
  }
3983
3980
  }
3984
3981
  /**
@@ -3988,7 +3985,7 @@ class PerspectiveProxy {
3988
3985
  * @returns Perspective object containing all links
3989
3986
  */
3990
3987
  async snapshot() {
3991
- return __classPrivateFieldGet$9(this, _PerspectiveProxy_client, "f").snapshotByUUID(__classPrivateFieldGet$9(this, _PerspectiveProxy_handle, "f").uuid);
3988
+ return __classPrivateFieldGet$a(this, _PerspectiveProxy_client, "f").snapshotByUUID(__classPrivateFieldGet$a(this, _PerspectiveProxy_handle, "f").uuid);
3992
3989
  }
3993
3990
  /**
3994
3991
  * Loads a perspective snapshot, replacing current content.
@@ -4268,7 +4265,7 @@ class PerspectiveProxy {
4268
4265
  * await perspective.addSdna('Recipe', prologCode, 'subject_class');
4269
4266
  */
4270
4267
  async addSdna(name, sdnaCode, sdnaType, shaclJson) {
4271
- return __classPrivateFieldGet$9(this, _PerspectiveProxy_client, "f").addSdna(__classPrivateFieldGet$9(this, _PerspectiveProxy_handle, "f").uuid, name, sdnaCode, sdnaType, shaclJson);
4268
+ return __classPrivateFieldGet$a(this, _PerspectiveProxy_client, "f").addSdna(__classPrivateFieldGet$a(this, _PerspectiveProxy_handle, "f").uuid, name, sdnaCode, sdnaType, shaclJson);
4272
4269
  }
4273
4270
  /**
4274
4271
  * Adds a subject class to the perspective.
@@ -4538,7 +4535,7 @@ class PerspectiveProxy {
4538
4535
  let className;
4539
4536
  if (typeof subjectClass === "string") {
4540
4537
  className = subjectClass;
4541
- await __classPrivateFieldGet$9(this, _PerspectiveProxy_client, "f").createSubject(__classPrivateFieldGet$9(this, _PerspectiveProxy_handle, "f").uuid, JSON.stringify({
4538
+ await __classPrivateFieldGet$a(this, _PerspectiveProxy_client, "f").createSubject(__classPrivateFieldGet$a(this, _PerspectiveProxy_handle, "f").uuid, JSON.stringify({
4542
4539
  className,
4543
4540
  initialValues
4544
4541
  }), exprAddr, initialValues ? JSON.stringify(initialValues) : undefined, batchId);
@@ -4550,7 +4547,7 @@ class PerspectiveProxy {
4550
4547
  if (!resolvedClassName) {
4551
4548
  throw new Error("Could not resolve subject class name from object. Use a decorated class or pass a className string.");
4552
4549
  }
4553
- await __classPrivateFieldGet$9(this, _PerspectiveProxy_client, "f").createSubject(__classPrivateFieldGet$9(this, _PerspectiveProxy_handle, "f").uuid, JSON.stringify({
4550
+ await __classPrivateFieldGet$a(this, _PerspectiveProxy_client, "f").createSubject(__classPrivateFieldGet$a(this, _PerspectiveProxy_handle, "f").uuid, JSON.stringify({
4554
4551
  className: resolvedClassName,
4555
4552
  initialValues
4556
4553
  }), exprAddr, initialValues ? JSON.stringify(initialValues) : undefined, batchId);
@@ -4565,7 +4562,7 @@ class PerspectiveProxy {
4565
4562
  }
4566
4563
  async getSubjectData(subjectClass, exprAddr) {
4567
4564
  if (typeof subjectClass === "string") {
4568
- return JSON.parse(await __classPrivateFieldGet$9(this, _PerspectiveProxy_client, "f").getSubjectData(__classPrivateFieldGet$9(this, _PerspectiveProxy_handle, "f").uuid, JSON.stringify({ className: subjectClass }), exprAddr));
4565
+ return JSON.parse(await __classPrivateFieldGet$a(this, _PerspectiveProxy_client, "f").getSubjectData(__classPrivateFieldGet$a(this, _PerspectiveProxy_handle, "f").uuid, JSON.stringify({ className: subjectClass }), exprAddr));
4569
4566
  }
4570
4567
  const obj = subjectClass;
4571
4568
  const resolvedClassName = obj.className || obj.constructor?.className || obj.constructor?.prototype?.className
@@ -4573,7 +4570,7 @@ class PerspectiveProxy {
4573
4570
  if (!resolvedClassName) {
4574
4571
  throw new Error("Could not resolve subject class name from object. Use a decorated class or pass a className string.");
4575
4572
  }
4576
- return JSON.parse(await __classPrivateFieldGet$9(this, _PerspectiveProxy_client, "f").getSubjectData(__classPrivateFieldGet$9(this, _PerspectiveProxy_handle, "f").uuid, JSON.stringify({ className: resolvedClassName }), exprAddr));
4573
+ return JSON.parse(await __classPrivateFieldGet$a(this, _PerspectiveProxy_client, "f").getSubjectData(__classPrivateFieldGet$a(this, _PerspectiveProxy_handle, "f").uuid, JSON.stringify({ className: resolvedClassName }), exprAddr));
4577
4574
  }
4578
4575
  /**
4579
4576
  * Gets actions from SHACL links for a given predicate (e.g., ad4m://constructor, ad4m://destructor).
@@ -4937,7 +4934,7 @@ class PerspectiveProxy {
4937
4934
  // Get the class name from the JS class
4938
4935
  const className = jsClass.className || jsClass.prototype?.className || jsClass.name;
4939
4936
  // Skip if already registered for this perspective instance
4940
- if (__classPrivateFieldGet$9(this, _PerspectiveProxy_ensuredSubjectClasses, "f").has(className))
4937
+ if (__classPrivateFieldGet$a(this, _PerspectiveProxy_ensuredSubjectClasses, "f").has(className))
4941
4938
  return;
4942
4939
  // Note: Duplicate checking is handled on the Rust side in add_sdna
4943
4940
  // Generate SHACL SDNA (Prolog-free)
@@ -4952,13 +4949,13 @@ class PerspectiveProxy {
4952
4949
  // Backend stores SHACL links directly
4953
4950
  await this.addSdna(className, '', 'subject_class', shaclJson);
4954
4951
  // Mark as registered for this perspective instance
4955
- __classPrivateFieldGet$9(this, _PerspectiveProxy_ensuredSubjectClasses, "f").add(className);
4952
+ __classPrivateFieldGet$a(this, _PerspectiveProxy_ensuredSubjectClasses, "f").add(className);
4956
4953
  }
4957
4954
  /** Clear the per-instance ensured subject class cache.
4958
4955
  * Call this after wiping a perspective's links so that
4959
4956
  * subsequent register() calls re-add SHACL definitions. */
4960
4957
  clearEnsuredSubjectClasses() {
4961
- __classPrivateFieldGet$9(this, _PerspectiveProxy_ensuredSubjectClasses, "f").clear();
4958
+ __classPrivateFieldGet$a(this, _PerspectiveProxy_ensuredSubjectClasses, "f").clear();
4962
4959
  }
4963
4960
  /**
4964
4961
  * Returns a list of all class names that have been registered as SHACL
@@ -5133,7 +5130,7 @@ class PerspectiveProxy {
5133
5130
  }));
5134
5131
  }
5135
5132
  getNeighbourhoodProxy() {
5136
- return __classPrivateFieldGet$9(this, _PerspectiveProxy_client, "f").getNeighbourhoodProxy(__classPrivateFieldGet$9(this, _PerspectiveProxy_handle, "f").uuid);
5133
+ return __classPrivateFieldGet$a(this, _PerspectiveProxy_client, "f").getNeighbourhoodProxy(__classPrivateFieldGet$a(this, _PerspectiveProxy_handle, "f").uuid);
5137
5134
  }
5138
5135
  /**
5139
5136
  * Returns a proxy object for working with AI capabilities.
@@ -5150,7 +5147,7 @@ class PerspectiveProxy {
5150
5147
  * ```
5151
5148
  */
5152
5149
  get ai() {
5153
- return __classPrivateFieldGet$9(this, _PerspectiveProxy_client, "f").aiClient;
5150
+ return __classPrivateFieldGet$a(this, _PerspectiveProxy_client, "f").aiClient;
5154
5151
  }
5155
5152
  /**
5156
5153
  * Creates a subscription for a Prolog query that updates in real-time.
@@ -5192,7 +5189,7 @@ class PerspectiveProxy {
5192
5189
  * ```
5193
5190
  */
5194
5191
  async subscribeInfer(query) {
5195
- const subscriptionProxy = new QuerySubscriptionProxy(this.uuid, query, __classPrivateFieldGet$9(this, _PerspectiveProxy_client, "f"));
5192
+ const subscriptionProxy = new QuerySubscriptionProxy(this.uuid, query, __classPrivateFieldGet$a(this, _PerspectiveProxy_client, "f"));
5196
5193
  // Start the subscription on the Rust side first to get the real subscription ID
5197
5194
  await subscriptionProxy.subscribe();
5198
5195
  // Wait for the initial result
@@ -5220,7 +5217,7 @@ class PerspectiveProxy {
5220
5217
  * @returns Initialized QuerySubscriptionProxy instance
5221
5218
  */
5222
5219
  async subscribeQuery(query) {
5223
- const subscriptionProxy = new QuerySubscriptionProxy(this.uuid, query, __classPrivateFieldGet$9(this, _PerspectiveProxy_client, "f"));
5220
+ const subscriptionProxy = new QuerySubscriptionProxy(this.uuid, query, __classPrivateFieldGet$a(this, _PerspectiveProxy_client, "f"));
5224
5221
  // Start the subscription on the Rust side first to get the real subscription ID
5225
5222
  await subscriptionProxy.subscribe();
5226
5223
  // Wait for the initial result
@@ -5230,13 +5227,13 @@ class PerspectiveProxy {
5230
5227
  }
5231
5228
  _PerspectiveProxy_handle = new WeakMap(), _PerspectiveProxy_client = new WeakMap(), _PerspectiveProxy_perspectiveLinkAddedCallbacks = new WeakMap(), _PerspectiveProxy_perspectiveLinkRemovedCallbacks = new WeakMap(), _PerspectiveProxy_perspectiveLinkUpdatedCallbacks = new WeakMap(), _PerspectiveProxy_perspectiveSyncStateChangeCallbacks = new WeakMap(), _PerspectiveProxy_ensuredSubjectClasses = new WeakMap();
5232
5229
 
5233
- var __classPrivateFieldSet$8 = (undefined && undefined.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
5230
+ var __classPrivateFieldSet$9 = (undefined && undefined.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
5234
5231
  if (kind === "m") throw new TypeError("Private method is not writable");
5235
5232
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
5236
5233
  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");
5237
5234
  return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
5238
5235
  };
5239
- var __classPrivateFieldGet$8 = (undefined && undefined.__classPrivateFieldGet) || function (receiver, state, kind, f) {
5236
+ var __classPrivateFieldGet$9 = (undefined && undefined.__classPrivateFieldGet) || function (receiver, state, kind, f) {
5240
5237
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
5241
5238
  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");
5242
5239
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
@@ -5244,11 +5241,6 @@ var __classPrivateFieldGet$8 = (undefined && undefined.__classPrivateFieldGet) |
5244
5241
  var _PerspectiveClient_apiClient, _PerspectiveClient_perspectiveAddedCallbacks, _PerspectiveClient_perspectiveUpdatedCallbacks, _PerspectiveClient_perspectiveRemovedCallbacks, _PerspectiveClient_perspectiveSyncStateChangeCallbacks, _PerspectiveClient_expressionClient, _PerspectiveClient_neighbourhoodClient, _PerspectiveClient_aiClient, _PerspectiveClient_unsubscribers, _PerspectiveClient_linkUnsubscribers, _PerspectiveClient_querySubscriptionUnsubscribers;
5245
5242
  function normalizeQueryResult(raw, errorContext) {
5246
5243
  let finalResult = raw;
5247
- let isInit = false;
5248
- if (typeof finalResult === 'string' && finalResult.startsWith('#init#')) {
5249
- finalResult = finalResult.substring(6);
5250
- isInit = true;
5251
- }
5252
5244
  if (typeof finalResult === 'string') {
5253
5245
  try {
5254
5246
  finalResult = JSON.parse(finalResult);
@@ -5257,10 +5249,7 @@ function normalizeQueryResult(raw, errorContext) {
5257
5249
  console.error(errorContext, e);
5258
5250
  }
5259
5251
  }
5260
- if (isInit && typeof finalResult === 'object' && finalResult !== null) {
5261
- finalResult.isInit = true;
5262
- }
5263
- return { result: finalResult, isInit };
5252
+ return finalResult;
5264
5253
  }
5265
5254
  class PerspectiveClient {
5266
5255
  constructor(baseUrl, token, subscribe = true, sharedApiClient) {
@@ -5275,14 +5264,14 @@ class PerspectiveClient {
5275
5264
  _PerspectiveClient_unsubscribers.set(this, void 0);
5276
5265
  _PerspectiveClient_linkUnsubscribers.set(this, void 0);
5277
5266
  _PerspectiveClient_querySubscriptionUnsubscribers.set(this, void 0);
5278
- __classPrivateFieldSet$8(this, _PerspectiveClient_apiClient, sharedApiClient || new ApiClient(baseUrl, token), "f");
5279
- __classPrivateFieldSet$8(this, _PerspectiveClient_perspectiveAddedCallbacks, [], "f");
5280
- __classPrivateFieldSet$8(this, _PerspectiveClient_perspectiveUpdatedCallbacks, [], "f");
5281
- __classPrivateFieldSet$8(this, _PerspectiveClient_perspectiveRemovedCallbacks, [], "f");
5282
- __classPrivateFieldSet$8(this, _PerspectiveClient_perspectiveSyncStateChangeCallbacks, [], "f");
5283
- __classPrivateFieldSet$8(this, _PerspectiveClient_unsubscribers, [], "f");
5284
- __classPrivateFieldSet$8(this, _PerspectiveClient_linkUnsubscribers, new Map(), "f");
5285
- __classPrivateFieldSet$8(this, _PerspectiveClient_querySubscriptionUnsubscribers, new Map(), "f");
5267
+ __classPrivateFieldSet$9(this, _PerspectiveClient_apiClient, sharedApiClient || new ApiClient(baseUrl, token), "f");
5268
+ __classPrivateFieldSet$9(this, _PerspectiveClient_perspectiveAddedCallbacks, [], "f");
5269
+ __classPrivateFieldSet$9(this, _PerspectiveClient_perspectiveUpdatedCallbacks, [], "f");
5270
+ __classPrivateFieldSet$9(this, _PerspectiveClient_perspectiveRemovedCallbacks, [], "f");
5271
+ __classPrivateFieldSet$9(this, _PerspectiveClient_perspectiveSyncStateChangeCallbacks, [], "f");
5272
+ __classPrivateFieldSet$9(this, _PerspectiveClient_unsubscribers, [], "f");
5273
+ __classPrivateFieldSet$9(this, _PerspectiveClient_linkUnsubscribers, new Map(), "f");
5274
+ __classPrivateFieldSet$9(this, _PerspectiveClient_querySubscriptionUnsubscribers, new Map(), "f");
5286
5275
  if (subscribe) {
5287
5276
  this.subscribePerspectiveAdded();
5288
5277
  this.subscribePerspectiveUpdated();
@@ -5290,24 +5279,24 @@ class PerspectiveClient {
5290
5279
  }
5291
5280
  }
5292
5281
  setExpressionClient(client) {
5293
- __classPrivateFieldSet$8(this, _PerspectiveClient_expressionClient, client, "f");
5282
+ __classPrivateFieldSet$9(this, _PerspectiveClient_expressionClient, client, "f");
5294
5283
  }
5295
5284
  setNeighbourhoodClient(client) {
5296
- __classPrivateFieldSet$8(this, _PerspectiveClient_neighbourhoodClient, client, "f");
5285
+ __classPrivateFieldSet$9(this, _PerspectiveClient_neighbourhoodClient, client, "f");
5297
5286
  }
5298
5287
  setAIClient(client) {
5299
- __classPrivateFieldSet$8(this, _PerspectiveClient_aiClient, client, "f");
5288
+ __classPrivateFieldSet$9(this, _PerspectiveClient_aiClient, client, "f");
5300
5289
  }
5301
5290
  get aiClient() {
5302
- return __classPrivateFieldGet$8(this, _PerspectiveClient_aiClient, "f");
5291
+ return __classPrivateFieldGet$9(this, _PerspectiveClient_aiClient, "f");
5303
5292
  }
5304
5293
  async all() {
5305
- const perspectives = await __classPrivateFieldGet$8(this, _PerspectiveClient_apiClient, "f").call('perspective.all');
5294
+ const perspectives = await __classPrivateFieldGet$9(this, _PerspectiveClient_apiClient, "f").call('perspective.all');
5306
5295
  return perspectives.map(handle => new PerspectiveProxy(handle, this));
5307
5296
  }
5308
5297
  async byUUID(uuid) {
5309
5298
  try {
5310
- const perspective = await __classPrivateFieldGet$8(this, _PerspectiveClient_apiClient, "f").call('perspective.get', { uuid });
5299
+ const perspective = await __classPrivateFieldGet$9(this, _PerspectiveClient_apiClient, "f").call('perspective.get', { uuid });
5311
5300
  if (!perspective)
5312
5301
  return null;
5313
5302
  return new PerspectiveProxy(perspective, this);
@@ -5319,10 +5308,10 @@ class PerspectiveClient {
5319
5308
  }
5320
5309
  }
5321
5310
  async snapshotByUUID(uuid) {
5322
- return __classPrivateFieldGet$8(this, _PerspectiveClient_apiClient, "f").call('perspective.snapshot', { uuid });
5311
+ return __classPrivateFieldGet$9(this, _PerspectiveClient_apiClient, "f").call('perspective.snapshot', { uuid });
5323
5312
  }
5324
5313
  async publishSnapshotByUUID(uuid) {
5325
- return __classPrivateFieldGet$8(this, _PerspectiveClient_apiClient, "f").call('perspective.publishSnapshot', { uuid });
5314
+ return __classPrivateFieldGet$9(this, _PerspectiveClient_apiClient, "f").call('perspective.publishSnapshot', { uuid });
5326
5315
  }
5327
5316
  async queryLinks(uuid, query) {
5328
5317
  const params = { uuid };
@@ -5338,59 +5327,59 @@ class PerspectiveClient {
5338
5327
  params.untilDate = query.untilDate instanceof Date ? query.untilDate.toISOString() : String(query.untilDate);
5339
5328
  if (query.limit !== undefined)
5340
5329
  params.limit = query.limit;
5341
- return __classPrivateFieldGet$8(this, _PerspectiveClient_apiClient, "f").call('perspective.queryLinks', params);
5330
+ return __classPrivateFieldGet$9(this, _PerspectiveClient_apiClient, "f").call('perspective.queryLinks', params);
5342
5331
  }
5343
5332
  async queryProlog(uuid, query) {
5344
- const result = await __classPrivateFieldGet$8(this, _PerspectiveClient_apiClient, "f").call('perspective.queryProlog', { uuid, query });
5333
+ const result = await __classPrivateFieldGet$9(this, _PerspectiveClient_apiClient, "f").call('perspective.queryProlog', { uuid, query });
5345
5334
  return JSON.parse(result);
5346
5335
  }
5347
5336
  async querySparql(uuid, query) {
5348
- const result = await __classPrivateFieldGet$8(this, _PerspectiveClient_apiClient, "f").call('perspective.querySparql', { uuid, engine: 'sparql', query });
5337
+ const result = await __classPrivateFieldGet$9(this, _PerspectiveClient_apiClient, "f").call('perspective.querySparql', { uuid, engine: 'sparql', query });
5349
5338
  return JSON.parse(result);
5350
5339
  }
5351
5340
  async subscribeQuery(uuid, query) {
5352
- const response = await __classPrivateFieldGet$8(this, _PerspectiveClient_apiClient, "f").call('perspective.subscribeQuery', { uuid, query });
5341
+ const response = await __classPrivateFieldGet$9(this, _PerspectiveClient_apiClient, "f").call('perspective.subscribeQuery', { uuid, query });
5353
5342
  const { subscriptionId, result } = response;
5354
- const normalized = normalizeQueryResult(result, 'Error parsing subscribeQuery result:');
5355
- return { subscriptionId, result: normalized.result, isInit: normalized.isInit };
5343
+ const parsed = normalizeQueryResult(result, 'Error parsing subscribeQuery result:');
5344
+ return { subscriptionId, result: parsed };
5356
5345
  }
5357
5346
  async perspectiveKeepAliveQuery(uuid, subscriptionId) {
5358
- return __classPrivateFieldGet$8(this, _PerspectiveClient_apiClient, "f").call('perspective.keepAliveQuery', { uuid, subscriptionId });
5347
+ return __classPrivateFieldGet$9(this, _PerspectiveClient_apiClient, "f").call('perspective.keepAliveQuery', { uuid, subscriptionId });
5359
5348
  }
5360
5349
  async perspectiveDisposeQuerySubscription(uuid, subscriptionId) {
5361
- return __classPrivateFieldGet$8(this, _PerspectiveClient_apiClient, "f").call('perspective.disposeQuery', { uuid, subscriptionId });
5350
+ return __classPrivateFieldGet$9(this, _PerspectiveClient_apiClient, "f").call('perspective.disposeQuery', { uuid, subscriptionId });
5362
5351
  }
5363
5352
  subscribeToQueryUpdates(subscriptionId, onData) {
5364
- const unsub = __classPrivateFieldGet$8(this, _PerspectiveClient_apiClient, "f").subscribe((data) => {
5353
+ const unsub = __classPrivateFieldGet$9(this, _PerspectiveClient_apiClient, "f").subscribe((data) => {
5365
5354
  const event = data;
5366
5355
  if (event.type !== 'query-subscription-update')
5367
5356
  return;
5368
5357
  const eventSubscriptionId = event.subscriptionId || event.subscription_id;
5369
5358
  if (eventSubscriptionId !== subscriptionId)
5370
5359
  return;
5371
- const normalized = normalizeQueryResult(event.result, 'Error parsing query subscription:');
5372
- onData(normalized.result);
5360
+ const parsed = normalizeQueryResult(event.result, 'Error parsing query subscription:');
5361
+ onData(parsed);
5373
5362
  });
5374
- __classPrivateFieldGet$8(this, _PerspectiveClient_querySubscriptionUnsubscribers, "f").set(subscriptionId, unsub);
5363
+ __classPrivateFieldGet$9(this, _PerspectiveClient_querySubscriptionUnsubscribers, "f").set(subscriptionId, unsub);
5375
5364
  return unsub;
5376
5365
  }
5377
5366
  async keepAliveQuery(uuid, subscriptionId) {
5378
- return __classPrivateFieldGet$8(this, _PerspectiveClient_apiClient, "f").call('perspective.keepAliveQuery', { uuid, subscriptionId });
5367
+ return __classPrivateFieldGet$9(this, _PerspectiveClient_apiClient, "f").call('perspective.keepAliveQuery', { uuid, subscriptionId });
5379
5368
  }
5380
5369
  async disposeQuerySubscription(uuid, subscriptionId) {
5381
- const unsub = __classPrivateFieldGet$8(this, _PerspectiveClient_querySubscriptionUnsubscribers, "f").get(subscriptionId);
5370
+ const unsub = __classPrivateFieldGet$9(this, _PerspectiveClient_querySubscriptionUnsubscribers, "f").get(subscriptionId);
5382
5371
  if (unsub) {
5383
5372
  unsub();
5384
- __classPrivateFieldGet$8(this, _PerspectiveClient_querySubscriptionUnsubscribers, "f").delete(subscriptionId);
5373
+ __classPrivateFieldGet$9(this, _PerspectiveClient_querySubscriptionUnsubscribers, "f").delete(subscriptionId);
5385
5374
  }
5386
- return __classPrivateFieldGet$8(this, _PerspectiveClient_apiClient, "f").call('perspective.disposeQuery', { uuid, subscriptionId });
5375
+ return __classPrivateFieldGet$9(this, _PerspectiveClient_apiClient, "f").call('perspective.disposeQuery', { uuid, subscriptionId });
5387
5376
  }
5388
5377
  async modelQuery(uuid, className, queryJson, shapeJson) {
5389
- const resultJson = await __classPrivateFieldGet$8(this, _PerspectiveClient_apiClient, "f").call('perspective.modelQuery', { uuid, class_name: className, query_json: queryJson, shape_json: shapeJson });
5378
+ const resultJson = await __classPrivateFieldGet$9(this, _PerspectiveClient_apiClient, "f").call('perspective.modelQuery', { uuid, class_name: className, query_json: queryJson, shape_json: shapeJson });
5390
5379
  return JSON.parse(resultJson);
5391
5380
  }
5392
5381
  async evaluateGetters(uuid, className, instanceIds, shapeJson, propertyNames) {
5393
- const resultJson = await __classPrivateFieldGet$8(this, _PerspectiveClient_apiClient, "f").call('perspective.evaluateGetters', {
5382
+ const resultJson = await __classPrivateFieldGet$9(this, _PerspectiveClient_apiClient, "f").call('perspective.evaluateGetters', {
5394
5383
  uuid,
5395
5384
  class_name: className,
5396
5385
  instance_ids: instanceIds,
@@ -5400,127 +5389,127 @@ class PerspectiveClient {
5400
5389
  return JSON.parse(resultJson);
5401
5390
  }
5402
5391
  async modelSubscribe(uuid, className, queryJson, shapeJson) {
5403
- const response = await __classPrivateFieldGet$8(this, _PerspectiveClient_apiClient, "f").call('perspective.modelSubscribe', { uuid, class_name: className, query_json: queryJson, shape_json: shapeJson });
5392
+ const response = await __classPrivateFieldGet$9(this, _PerspectiveClient_apiClient, "f").call('perspective.modelSubscribe', { uuid, class_name: className, query_json: queryJson, shape_json: shapeJson });
5404
5393
  return {
5405
5394
  subscriptionId: response.subscription_id,
5406
5395
  result: JSON.parse(response.result)
5407
5396
  };
5408
5397
  }
5409
5398
  async add(name) {
5410
- const handle = await __classPrivateFieldGet$8(this, _PerspectiveClient_apiClient, "f").call('perspective.create', { name });
5399
+ const handle = await __classPrivateFieldGet$9(this, _PerspectiveClient_apiClient, "f").call('perspective.create', { name });
5411
5400
  return new PerspectiveProxy(handle, this);
5412
5401
  }
5413
5402
  async update(uuid, name) {
5414
- const handle = await __classPrivateFieldGet$8(this, _PerspectiveClient_apiClient, "f").call('perspective.update', { uuid, name });
5403
+ const handle = await __classPrivateFieldGet$9(this, _PerspectiveClient_apiClient, "f").call('perspective.update', { uuid, name });
5415
5404
  return new PerspectiveProxy(handle, this);
5416
5405
  }
5417
5406
  async remove(uuid) {
5418
- const result = await __classPrivateFieldGet$8(this, _PerspectiveClient_apiClient, "f").call('perspective.remove', { uuid });
5407
+ const result = await __classPrivateFieldGet$9(this, _PerspectiveClient_apiClient, "f").call('perspective.remove', { uuid });
5419
5408
  return { perspectiveRemove: result };
5420
5409
  }
5421
5410
  async addLink(uuid, link, status = 'shared', batchId) {
5422
- return __classPrivateFieldGet$8(this, _PerspectiveClient_apiClient, "f").call('perspective.addLink', { uuid, link, status, batchId });
5411
+ return __classPrivateFieldGet$9(this, _PerspectiveClient_apiClient, "f").call('perspective.addLink', { uuid, link, status, batchId });
5423
5412
  }
5424
5413
  async addLinks(uuid, links, status = 'shared', batchId) {
5425
- return __classPrivateFieldGet$8(this, _PerspectiveClient_apiClient, "f").call('perspective.addLinks', { uuid, links, status, batchId });
5414
+ return __classPrivateFieldGet$9(this, _PerspectiveClient_apiClient, "f").call('perspective.addLinks', { uuid, links, status, batchId });
5426
5415
  }
5427
5416
  async removeLinks(uuid, links, batchId) {
5428
- return __classPrivateFieldGet$8(this, _PerspectiveClient_apiClient, "f").call('perspective.removeLinks', { uuid, links, batchId });
5417
+ return __classPrivateFieldGet$9(this, _PerspectiveClient_apiClient, "f").call('perspective.removeLinks', { uuid, links, batchId });
5429
5418
  }
5430
5419
  async linkMutations(uuid, mutations, status) {
5431
- return __classPrivateFieldGet$8(this, _PerspectiveClient_apiClient, "f").call('perspective.linkMutations', { uuid, mutations, status });
5420
+ return __classPrivateFieldGet$9(this, _PerspectiveClient_apiClient, "f").call('perspective.linkMutations', { uuid, mutations, status });
5432
5421
  }
5433
5422
  async addLinkExpression(uuid, link, status = 'shared', batchId) {
5434
- return __classPrivateFieldGet$8(this, _PerspectiveClient_apiClient, "f").call('perspective.addLinkExpression', { uuid, link, status, batchId });
5423
+ return __classPrivateFieldGet$9(this, _PerspectiveClient_apiClient, "f").call('perspective.addLinkExpression', { uuid, link, status, batchId });
5435
5424
  }
5436
5425
  async updateLink(uuid, oldLink, newLink, batchId) {
5437
- return __classPrivateFieldGet$8(this, _PerspectiveClient_apiClient, "f").call('perspective.updateLink', { uuid, oldLink, newLink, batchId });
5426
+ return __classPrivateFieldGet$9(this, _PerspectiveClient_apiClient, "f").call('perspective.updateLink', { uuid, oldLink, newLink, batchId });
5438
5427
  }
5439
5428
  async removeLink(uuid, link, batchId) {
5440
5429
  delete link.__typename;
5441
5430
  delete link.data.__typename;
5442
5431
  delete link.proof.__typename;
5443
5432
  delete link.status;
5444
- return __classPrivateFieldGet$8(this, _PerspectiveClient_apiClient, "f").call('perspective.removeLink', { uuid, link, batchId });
5433
+ return __classPrivateFieldGet$9(this, _PerspectiveClient_apiClient, "f").call('perspective.removeLink', { uuid, link, batchId });
5445
5434
  }
5446
5435
  async addSdna(uuid, name, sdnaCode, sdnaType, shaclJson) {
5447
- return __classPrivateFieldGet$8(this, _PerspectiveClient_apiClient, "f").call('perspective.addSdna', { uuid, name, sdnaCode: sdnaCode || "", sdnaType, shaclJson });
5436
+ return __classPrivateFieldGet$9(this, _PerspectiveClient_apiClient, "f").call('perspective.addSdna', { uuid, name, sdnaCode: sdnaCode || "", sdnaType, shaclJson });
5448
5437
  }
5449
5438
  async executeCommands(uuid, commands, expression, parameters, batchId) {
5450
- return __classPrivateFieldGet$8(this, _PerspectiveClient_apiClient, "f").call('perspective.executeCommands', { uuid, commands, expression, parameters, batchId });
5439
+ return __classPrivateFieldGet$9(this, _PerspectiveClient_apiClient, "f").call('perspective.executeCommands', { uuid, commands, expression, parameters, batchId });
5451
5440
  }
5452
5441
  async createSubject(uuid, subjectClass, expressionAddress, initialValues, batchId) {
5453
- return __classPrivateFieldGet$8(this, _PerspectiveClient_apiClient, "f").call('perspective.createSubject', { uuid, subjectClass, expressionAddress, initialValues, batchId });
5442
+ return __classPrivateFieldGet$9(this, _PerspectiveClient_apiClient, "f").call('perspective.createSubject', { uuid, subjectClass, expressionAddress, initialValues, batchId });
5454
5443
  }
5455
5444
  async getSubjectData(uuid, subjectClass, expressionAddress) {
5456
- return __classPrivateFieldGet$8(this, _PerspectiveClient_apiClient, "f").call('perspective.getSubjectData', { uuid, subjectClass, expressionAddress });
5445
+ return __classPrivateFieldGet$9(this, _PerspectiveClient_apiClient, "f").call('perspective.getSubjectData', { uuid, subjectClass, expressionAddress });
5457
5446
  }
5458
5447
  // ExpressionClient functions, needed for Subjects:
5459
5448
  async getExpression(expressionURI) {
5460
- return await __classPrivateFieldGet$8(this, _PerspectiveClient_expressionClient, "f").get(expressionURI);
5449
+ return await __classPrivateFieldGet$9(this, _PerspectiveClient_expressionClient, "f").get(expressionURI);
5461
5450
  }
5462
5451
  async createExpression(content, languageAddress) {
5463
- return await __classPrivateFieldGet$8(this, _PerspectiveClient_expressionClient, "f").create(content, languageAddress);
5452
+ return await __classPrivateFieldGet$9(this, _PerspectiveClient_expressionClient, "f").create(content, languageAddress);
5464
5453
  }
5465
5454
  // Subscriptions:
5466
5455
  addPerspectiveAddedListener(cb) {
5467
- __classPrivateFieldGet$8(this, _PerspectiveClient_perspectiveAddedCallbacks, "f").push(cb);
5456
+ __classPrivateFieldGet$9(this, _PerspectiveClient_perspectiveAddedCallbacks, "f").push(cb);
5468
5457
  }
5469
5458
  subscribePerspectiveAdded() {
5470
- const unsub = __classPrivateFieldGet$8(this, _PerspectiveClient_apiClient, "f").subscribe((data) => {
5459
+ const unsub = __classPrivateFieldGet$9(this, _PerspectiveClient_apiClient, "f").subscribe((data) => {
5471
5460
  if (data.type === 'perspective-added') {
5472
- __classPrivateFieldGet$8(this, _PerspectiveClient_perspectiveAddedCallbacks, "f").forEach(cb => cb(data.perspective));
5461
+ __classPrivateFieldGet$9(this, _PerspectiveClient_perspectiveAddedCallbacks, "f").forEach(cb => cb(data.perspective));
5473
5462
  }
5474
5463
  });
5475
- __classPrivateFieldGet$8(this, _PerspectiveClient_unsubscribers, "f").push(unsub);
5464
+ __classPrivateFieldGet$9(this, _PerspectiveClient_unsubscribers, "f").push(unsub);
5476
5465
  }
5477
5466
  addPerspectiveUpdatedListener(cb) {
5478
- __classPrivateFieldGet$8(this, _PerspectiveClient_perspectiveUpdatedCallbacks, "f").push(cb);
5467
+ __classPrivateFieldGet$9(this, _PerspectiveClient_perspectiveUpdatedCallbacks, "f").push(cb);
5479
5468
  }
5480
5469
  subscribePerspectiveUpdated() {
5481
- const unsub = __classPrivateFieldGet$8(this, _PerspectiveClient_apiClient, "f").subscribe((data) => {
5470
+ const unsub = __classPrivateFieldGet$9(this, _PerspectiveClient_apiClient, "f").subscribe((data) => {
5482
5471
  if (data.type === 'perspective-updated') {
5483
- __classPrivateFieldGet$8(this, _PerspectiveClient_perspectiveUpdatedCallbacks, "f").forEach(cb => cb(data.perspective));
5472
+ __classPrivateFieldGet$9(this, _PerspectiveClient_perspectiveUpdatedCallbacks, "f").forEach(cb => cb(data.perspective));
5484
5473
  }
5485
5474
  });
5486
- __classPrivateFieldGet$8(this, _PerspectiveClient_unsubscribers, "f").push(unsub);
5475
+ __classPrivateFieldGet$9(this, _PerspectiveClient_unsubscribers, "f").push(unsub);
5487
5476
  }
5488
5477
  addPerspectiveSyncedListener(cb) {
5489
- __classPrivateFieldGet$8(this, _PerspectiveClient_perspectiveSyncStateChangeCallbacks, "f").push(cb);
5478
+ __classPrivateFieldGet$9(this, _PerspectiveClient_perspectiveSyncStateChangeCallbacks, "f").push(cb);
5490
5479
  }
5491
5480
  async addPerspectiveSyncStateChangeListener(uuid, cb) {
5492
- const unsub = __classPrivateFieldGet$8(this, _PerspectiveClient_apiClient, "f").subscribe((data) => {
5481
+ const unsub = __classPrivateFieldGet$9(this, _PerspectiveClient_apiClient, "f").subscribe((data) => {
5493
5482
  if (data.type === 'sync-state-change' && data.uuid === uuid) {
5494
5483
  cb.forEach(c => c(data.state));
5495
5484
  }
5496
5485
  });
5497
- __classPrivateFieldGet$8(this, _PerspectiveClient_unsubscribers, "f").push(unsub);
5486
+ __classPrivateFieldGet$9(this, _PerspectiveClient_unsubscribers, "f").push(unsub);
5498
5487
  await new Promise(resolve => setTimeout(resolve, 500));
5499
5488
  }
5500
5489
  addPerspectiveRemovedListener(cb) {
5501
- __classPrivateFieldGet$8(this, _PerspectiveClient_perspectiveRemovedCallbacks, "f").push(cb);
5490
+ __classPrivateFieldGet$9(this, _PerspectiveClient_perspectiveRemovedCallbacks, "f").push(cb);
5502
5491
  }
5503
5492
  subscribePerspectiveRemoved() {
5504
- const unsub = __classPrivateFieldGet$8(this, _PerspectiveClient_apiClient, "f").subscribe((data) => {
5493
+ const unsub = __classPrivateFieldGet$9(this, _PerspectiveClient_apiClient, "f").subscribe((data) => {
5505
5494
  if (data.type === 'perspective-removed') {
5506
- __classPrivateFieldGet$8(this, _PerspectiveClient_perspectiveRemovedCallbacks, "f").forEach(cb => cb(data.uuid));
5495
+ __classPrivateFieldGet$9(this, _PerspectiveClient_perspectiveRemovedCallbacks, "f").forEach(cb => cb(data.uuid));
5507
5496
  }
5508
5497
  });
5509
- __classPrivateFieldGet$8(this, _PerspectiveClient_unsubscribers, "f").push(unsub);
5498
+ __classPrivateFieldGet$9(this, _PerspectiveClient_unsubscribers, "f").push(unsub);
5510
5499
  }
5511
5500
  async addPerspectiveLinkAddedListener(uuid, cb) {
5512
- const unsub = __classPrivateFieldGet$8(this, _PerspectiveClient_apiClient, "f").subscribe((data) => {
5501
+ const unsub = __classPrivateFieldGet$9(this, _PerspectiveClient_apiClient, "f").subscribe((data) => {
5513
5502
  if (data.type === 'link-added' && data.perspectiveUuid === uuid) {
5514
5503
  cb.forEach(c => c(data.link));
5515
5504
  }
5516
5505
  });
5517
- let existing = __classPrivateFieldGet$8(this, _PerspectiveClient_linkUnsubscribers, "f").get(uuid) || [];
5506
+ let existing = __classPrivateFieldGet$9(this, _PerspectiveClient_linkUnsubscribers, "f").get(uuid) || [];
5518
5507
  existing.push(unsub);
5519
- __classPrivateFieldGet$8(this, _PerspectiveClient_linkUnsubscribers, "f").set(uuid, existing);
5520
- await __classPrivateFieldGet$8(this, _PerspectiveClient_apiClient, "f").waitForSubscription();
5508
+ __classPrivateFieldGet$9(this, _PerspectiveClient_linkUnsubscribers, "f").set(uuid, existing);
5509
+ await __classPrivateFieldGet$9(this, _PerspectiveClient_apiClient, "f").waitForSubscription();
5521
5510
  }
5522
5511
  async addPerspectiveLinkRemovedListener(uuid, cb) {
5523
- const unsub = __classPrivateFieldGet$8(this, _PerspectiveClient_apiClient, "f").subscribe((data) => {
5512
+ const unsub = __classPrivateFieldGet$9(this, _PerspectiveClient_apiClient, "f").subscribe((data) => {
5524
5513
  if (data.type === 'link-removed' && data.perspectiveUuid === uuid) {
5525
5514
  const link = data.link;
5526
5515
  if (!link.status) {
@@ -5529,13 +5518,13 @@ class PerspectiveClient {
5529
5518
  cb.forEach(c => c(link));
5530
5519
  }
5531
5520
  });
5532
- let existing = __classPrivateFieldGet$8(this, _PerspectiveClient_linkUnsubscribers, "f").get(uuid) || [];
5521
+ let existing = __classPrivateFieldGet$9(this, _PerspectiveClient_linkUnsubscribers, "f").get(uuid) || [];
5533
5522
  existing.push(unsub);
5534
- __classPrivateFieldGet$8(this, _PerspectiveClient_linkUnsubscribers, "f").set(uuid, existing);
5535
- await __classPrivateFieldGet$8(this, _PerspectiveClient_apiClient, "f").waitForSubscription();
5523
+ __classPrivateFieldGet$9(this, _PerspectiveClient_linkUnsubscribers, "f").set(uuid, existing);
5524
+ await __classPrivateFieldGet$9(this, _PerspectiveClient_apiClient, "f").waitForSubscription();
5536
5525
  }
5537
5526
  async addPerspectiveLinkUpdatedListener(uuid, cb) {
5538
- const unsub = __classPrivateFieldGet$8(this, _PerspectiveClient_apiClient, "f").subscribe((data) => {
5527
+ const unsub = __classPrivateFieldGet$9(this, _PerspectiveClient_apiClient, "f").subscribe((data) => {
5539
5528
  if (data.type === 'link-updated' && data.perspectiveUuid === uuid) {
5540
5529
  const newLink = data.newLink;
5541
5530
  const oldLink = data.oldLink;
@@ -5548,23 +5537,163 @@ class PerspectiveClient {
5548
5537
  cb.forEach(c => c(data));
5549
5538
  }
5550
5539
  });
5551
- let existing = __classPrivateFieldGet$8(this, _PerspectiveClient_linkUnsubscribers, "f").get(uuid) || [];
5540
+ let existing = __classPrivateFieldGet$9(this, _PerspectiveClient_linkUnsubscribers, "f").get(uuid) || [];
5552
5541
  existing.push(unsub);
5553
- __classPrivateFieldGet$8(this, _PerspectiveClient_linkUnsubscribers, "f").set(uuid, existing);
5554
- await __classPrivateFieldGet$8(this, _PerspectiveClient_apiClient, "f").waitForSubscription();
5542
+ __classPrivateFieldGet$9(this, _PerspectiveClient_linkUnsubscribers, "f").set(uuid, existing);
5543
+ await __classPrivateFieldGet$9(this, _PerspectiveClient_apiClient, "f").waitForSubscription();
5555
5544
  }
5556
5545
  getNeighbourhoodProxy(uuid) {
5557
- return new NeighbourhoodProxy(__classPrivateFieldGet$8(this, _PerspectiveClient_neighbourhoodClient, "f"), uuid);
5546
+ return new NeighbourhoodProxy(__classPrivateFieldGet$9(this, _PerspectiveClient_neighbourhoodClient, "f"), uuid);
5558
5547
  }
5559
5548
  async createBatch(uuid) {
5560
- return __classPrivateFieldGet$8(this, _PerspectiveClient_apiClient, "f").call('perspective.createBatch', { uuid });
5549
+ return __classPrivateFieldGet$9(this, _PerspectiveClient_apiClient, "f").call('perspective.createBatch', { uuid });
5561
5550
  }
5562
5551
  async commitBatch(uuid, batchId) {
5563
- return __classPrivateFieldGet$8(this, _PerspectiveClient_apiClient, "f").call('perspective.commitBatch', { uuid, batchId });
5552
+ return __classPrivateFieldGet$9(this, _PerspectiveClient_apiClient, "f").call('perspective.commitBatch', { uuid, batchId });
5564
5553
  }
5565
5554
  }
5566
5555
  _PerspectiveClient_apiClient = new WeakMap(), _PerspectiveClient_perspectiveAddedCallbacks = new WeakMap(), _PerspectiveClient_perspectiveUpdatedCallbacks = new WeakMap(), _PerspectiveClient_perspectiveRemovedCallbacks = new WeakMap(), _PerspectiveClient_perspectiveSyncStateChangeCallbacks = new WeakMap(), _PerspectiveClient_expressionClient = new WeakMap(), _PerspectiveClient_neighbourhoodClient = new WeakMap(), _PerspectiveClient_aiClient = new WeakMap(), _PerspectiveClient_unsubscribers = new WeakMap(), _PerspectiveClient_linkUnsubscribers = new WeakMap(), _PerspectiveClient_querySubscriptionUnsubscribers = new WeakMap();
5567
5556
 
5557
+ /**
5558
+ * PersistentCache — two-tier persistent key-value cache abstraction.
5559
+ *
5560
+ * Provides an IndexedDB-backed implementation for browsers and a no-op
5561
+ * NullCache fallback for Node.js / environments without IndexedDB.
5562
+ *
5563
+ * Design goals:
5564
+ * - Lazy open: IDB connection is deferred until first access
5565
+ * - Fire-and-forget writes: put() resolves immediately (best-effort persistence)
5566
+ * - Graceful degradation: all IDB errors resolve (never reject), so callers
5567
+ * never need try/catch around cache operations
5568
+ * - Tree-shakeable: import only what you need
5569
+ */
5570
+ var __classPrivateFieldSet$8 = (undefined && undefined.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
5571
+ if (kind === "m") throw new TypeError("Private method is not writable");
5572
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
5573
+ 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");
5574
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
5575
+ };
5576
+ var __classPrivateFieldGet$8 = (undefined && undefined.__classPrivateFieldGet) || function (receiver, state, kind, f) {
5577
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
5578
+ 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");
5579
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
5580
+ };
5581
+ var _IDBCache_instances, _IDBCache_dbName, _IDBCache_storeName, _IDBCache_dbPromise, _IDBCache_version, _IDBCache_open;
5582
+ // ── IndexedDB Implementation ─────────────────────────────────────────
5583
+ class IDBCache {
5584
+ constructor(dbName, storeName) {
5585
+ _IDBCache_instances.add(this);
5586
+ _IDBCache_dbName.set(this, void 0);
5587
+ _IDBCache_storeName.set(this, void 0);
5588
+ _IDBCache_dbPromise.set(this, null);
5589
+ _IDBCache_version.set(this, 1);
5590
+ __classPrivateFieldSet$8(this, _IDBCache_dbName, dbName, "f");
5591
+ __classPrivateFieldSet$8(this, _IDBCache_storeName, storeName, "f");
5592
+ }
5593
+ async get(key) {
5594
+ try {
5595
+ const db = await __classPrivateFieldGet$8(this, _IDBCache_instances, "m", _IDBCache_open).call(this);
5596
+ return new Promise((resolve) => {
5597
+ const tx = db.transaction(__classPrivateFieldGet$8(this, _IDBCache_storeName, "f"), 'readonly');
5598
+ const store = tx.objectStore(__classPrivateFieldGet$8(this, _IDBCache_storeName, "f"));
5599
+ const req = store.get(key);
5600
+ req.onsuccess = () => resolve(req.result ?? undefined);
5601
+ req.onerror = () => resolve(undefined);
5602
+ });
5603
+ }
5604
+ catch {
5605
+ return undefined;
5606
+ }
5607
+ }
5608
+ async put(key, value) {
5609
+ try {
5610
+ const db = await __classPrivateFieldGet$8(this, _IDBCache_instances, "m", _IDBCache_open).call(this);
5611
+ return new Promise((resolve) => {
5612
+ const tx = db.transaction(__classPrivateFieldGet$8(this, _IDBCache_storeName, "f"), 'readwrite');
5613
+ const store = tx.objectStore(__classPrivateFieldGet$8(this, _IDBCache_storeName, "f"));
5614
+ store.put(value, key);
5615
+ tx.oncomplete = () => resolve();
5616
+ tx.onerror = () => resolve(); // fire-and-forget
5617
+ });
5618
+ }
5619
+ catch {
5620
+ // degrade gracefully
5621
+ }
5622
+ }
5623
+ async delete(key) {
5624
+ try {
5625
+ const db = await __classPrivateFieldGet$8(this, _IDBCache_instances, "m", _IDBCache_open).call(this);
5626
+ return new Promise((resolve) => {
5627
+ const tx = db.transaction(__classPrivateFieldGet$8(this, _IDBCache_storeName, "f"), 'readwrite');
5628
+ const store = tx.objectStore(__classPrivateFieldGet$8(this, _IDBCache_storeName, "f"));
5629
+ store.delete(key);
5630
+ tx.oncomplete = () => resolve();
5631
+ tx.onerror = () => resolve();
5632
+ });
5633
+ }
5634
+ catch {
5635
+ // degrade gracefully
5636
+ }
5637
+ }
5638
+ async clear() {
5639
+ try {
5640
+ const db = await __classPrivateFieldGet$8(this, _IDBCache_instances, "m", _IDBCache_open).call(this);
5641
+ return new Promise((resolve) => {
5642
+ const tx = db.transaction(__classPrivateFieldGet$8(this, _IDBCache_storeName, "f"), 'readwrite');
5643
+ const store = tx.objectStore(__classPrivateFieldGet$8(this, _IDBCache_storeName, "f"));
5644
+ store.clear();
5645
+ tx.oncomplete = () => resolve();
5646
+ tx.onerror = () => resolve();
5647
+ });
5648
+ }
5649
+ catch {
5650
+ // degrade gracefully
5651
+ }
5652
+ }
5653
+ }
5654
+ _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() {
5655
+ if (!__classPrivateFieldGet$8(this, _IDBCache_dbPromise, "f")) {
5656
+ __classPrivateFieldSet$8(this, _IDBCache_dbPromise, new Promise((resolve, reject) => {
5657
+ const storeName = __classPrivateFieldGet$8(this, _IDBCache_storeName, "f");
5658
+ const req = indexedDB.open(__classPrivateFieldGet$8(this, _IDBCache_dbName, "f"), __classPrivateFieldGet$8(this, _IDBCache_version, "f"));
5659
+ req.onupgradeneeded = () => {
5660
+ const db = req.result;
5661
+ if (!db.objectStoreNames.contains(storeName)) {
5662
+ db.createObjectStore(storeName);
5663
+ }
5664
+ };
5665
+ req.onsuccess = () => resolve(req.result);
5666
+ req.onerror = () => reject(req.error);
5667
+ }), "f");
5668
+ }
5669
+ return __classPrivateFieldGet$8(this, _IDBCache_dbPromise, "f");
5670
+ };
5671
+ // ── NullCache (no-op fallback for Node.js) ───────────────────────────
5672
+ class NullCache {
5673
+ async get(_key) { return undefined; }
5674
+ async put(_key, _value) { }
5675
+ async delete(_key) { }
5676
+ async clear() { }
5677
+ }
5678
+ // ── Factory ──────────────────────────────────────────────────────────
5679
+ /**
5680
+ * Create a PersistentCache backed by IndexedDB (browser) or NullCache (Node.js).
5681
+ *
5682
+ * @param dbName - IndexedDB database name
5683
+ * @param storeName - IndexedDB object store name
5684
+ */
5685
+ function createPersistentCache(dbName, storeName) {
5686
+ try {
5687
+ if (typeof indexedDB !== 'undefined') {
5688
+ return new IDBCache(dbName, storeName);
5689
+ }
5690
+ }
5691
+ catch {
5692
+ // indexedDB access threw (e.g. in a worker with restricted globals)
5693
+ }
5694
+ return new NullCache();
5695
+ }
5696
+
5568
5697
  var __classPrivateFieldSet$7 = (undefined && undefined.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
5569
5698
  if (kind === "m") throw new TypeError("Private method is not writable");
5570
5699
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
@@ -5576,7 +5705,7 @@ var __classPrivateFieldGet$7 = (undefined && undefined.__classPrivateFieldGet) |
5576
5705
  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");
5577
5706
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
5578
5707
  };
5579
- var _AgentClient_apiClient, _AgentClient_baseUrl, _AgentClient_token, _AgentClient_appsChangedCallback, _AgentClient_updatedCallbacks, _AgentClient_agentStatusChangedCallbacks, _AgentClient_hostingUserInfoChangedCallbacks, _AgentClient_computeLogUpdatedCallbacks, _AgentClient_unsubscribers;
5708
+ var _AgentClient_apiClient, _AgentClient_baseUrl, _AgentClient_token, _AgentClient_appsChangedCallback, _AgentClient_updatedCallbacks, _AgentClient_agentStatusChangedCallbacks, _AgentClient_hostingUserInfoChangedCallbacks, _AgentClient_computeLogUpdatedCallbacks, _AgentClient_unsubscribers, _AgentClient_memCache, _AgentClient_persistent, _AgentClient_selfDid;
5580
5709
  class AgentClient {
5581
5710
  constructor(baseUrl, token, subscribe = true, sharedApiClient) {
5582
5711
  _AgentClient_apiClient.set(this, void 0);
@@ -5588,6 +5717,13 @@ class AgentClient {
5588
5717
  _AgentClient_hostingUserInfoChangedCallbacks.set(this, void 0);
5589
5718
  _AgentClient_computeLogUpdatedCallbacks.set(this, void 0);
5590
5719
  _AgentClient_unsubscribers.set(this, void 0);
5720
+ // ── byDID cache ────────────────────────────────────────────────────
5721
+ // L1: in-memory promise cache with timestamps for TTL
5722
+ _AgentClient_memCache.set(this, new Map());
5723
+ // L2: persistent cache (IndexedDB in browser, NullCache in Node)
5724
+ _AgentClient_persistent.set(this, void 0);
5725
+ // Self-DID for event-driven invalidation (no TTL for own profile)
5726
+ _AgentClient_selfDid.set(this, null);
5591
5727
  __classPrivateFieldSet$7(this, _AgentClient_baseUrl, baseUrl, "f");
5592
5728
  __classPrivateFieldSet$7(this, _AgentClient_token, token, "f");
5593
5729
  __classPrivateFieldSet$7(this, _AgentClient_apiClient, sharedApiClient || new ApiClient(baseUrl, token), "f");
@@ -5597,6 +5733,7 @@ class AgentClient {
5597
5733
  __classPrivateFieldSet$7(this, _AgentClient_hostingUserInfoChangedCallbacks, [], "f");
5598
5734
  __classPrivateFieldSet$7(this, _AgentClient_computeLogUpdatedCallbacks, [], "f");
5599
5735
  __classPrivateFieldSet$7(this, _AgentClient_unsubscribers, [], "f");
5736
+ __classPrivateFieldSet$7(this, _AgentClient_persistent, createPersistentCache('ad4m-agent-cache', 'agents'), "f");
5600
5737
  if (subscribe) {
5601
5738
  this.subscribeAgentUpdated();
5602
5739
  this.subscribeAgentStatusChanged();
@@ -5630,7 +5767,57 @@ class AgentClient {
5630
5767
  return new AgentStatus(result);
5631
5768
  }
5632
5769
  async byDID(did) {
5633
- return __classPrivateFieldGet$7(this, _AgentClient_apiClient, "f").call('agent.byDid', { did });
5770
+ const now = Date.now();
5771
+ const cached = __classPrivateFieldGet$7(this, _AgentClient_memCache, "f").get(did);
5772
+ if (cached) {
5773
+ const isSelf = did === __classPrivateFieldGet$7(this, _AgentClient_selfDid, "f");
5774
+ // Self-DID: L1 always valid (event-driven invalidation)
5775
+ // Remote DID: L1 valid within TTL
5776
+ if (isSelf || (now - cached.ts) < AgentClient.REMOTE_AGENT_TTL_MS) {
5777
+ return cached.promise;
5778
+ }
5779
+ }
5780
+ // Deduplicate: store the promise immediately so concurrent calls share one RPC
5781
+ const promise = (async () => {
5782
+ // L2: check persistent cache before network
5783
+ const persisted = await __classPrivateFieldGet$7(this, _AgentClient_persistent, "f").get(did);
5784
+ if (persisted) {
5785
+ return persisted;
5786
+ }
5787
+ // L3: network fetch
5788
+ const result = await __classPrivateFieldGet$7(this, _AgentClient_apiClient, "f").call('agent.byDid', { did });
5789
+ __classPrivateFieldGet$7(this, _AgentClient_persistent, "f").put(did, result); // fire-and-forget write to L2
5790
+ return result;
5791
+ })();
5792
+ __classPrivateFieldGet$7(this, _AgentClient_memCache, "f").set(did, { promise, ts: now });
5793
+ // Clean up on failure so next call retries
5794
+ promise.catch(() => {
5795
+ if (__classPrivateFieldGet$7(this, _AgentClient_memCache, "f").get(did)?.promise === promise) {
5796
+ __classPrivateFieldGet$7(this, _AgentClient_memCache, "f").delete(did);
5797
+ }
5798
+ });
5799
+ return promise;
5800
+ }
5801
+ /**
5802
+ * Set the current agent's own DID.
5803
+ * The self-DID receives event-driven invalidation and is never TTL-expired.
5804
+ */
5805
+ setSelfDid(did) {
5806
+ __classPrivateFieldSet$7(this, _AgentClient_selfDid, did, "f");
5807
+ }
5808
+ /**
5809
+ * Invalidate a specific DID's cache entry in both L1 and L2.
5810
+ */
5811
+ invalidateByDid(did) {
5812
+ __classPrivateFieldGet$7(this, _AgentClient_memCache, "f").delete(did);
5813
+ __classPrivateFieldGet$7(this, _AgentClient_persistent, "f").delete(did); // fire-and-forget
5814
+ }
5815
+ /**
5816
+ * Clear the entire L1 (memory) byDID cache.
5817
+ * L2 (IndexedDB) is preserved — agent data remains valid across sessions.
5818
+ */
5819
+ clearByDidCache() {
5820
+ __classPrivateFieldGet$7(this, _AgentClient_memCache, "f").clear();
5634
5821
  }
5635
5822
  async updatePublicPerspective(perspective) {
5636
5823
  const cleanedPerspective = JSON.parse(JSON.stringify(perspective));
@@ -5691,7 +5878,16 @@ class AgentClient {
5691
5878
  subscribeAgentUpdated() {
5692
5879
  const unsub = __classPrivateFieldGet$7(this, _AgentClient_apiClient, "f").subscribe((data) => {
5693
5880
  if (data.type === 'agent-updated') {
5694
- __classPrivateFieldGet$7(this, _AgentClient_updatedCallbacks, "f").forEach((cb) => cb((data.agent || data)));
5881
+ const agent = (data.agent || data);
5882
+ // Update L1 and L2 cache from the event payload
5883
+ if (agent.did) {
5884
+ __classPrivateFieldGet$7(this, _AgentClient_memCache, "f").set(agent.did, {
5885
+ promise: Promise.resolve(agent),
5886
+ ts: Date.now(),
5887
+ });
5888
+ __classPrivateFieldGet$7(this, _AgentClient_persistent, "f").put(agent.did, agent); // fire-and-forget
5889
+ }
5890
+ __classPrivateFieldGet$7(this, _AgentClient_updatedCallbacks, "f").forEach((cb) => cb(agent));
5695
5891
  }
5696
5892
  });
5697
5893
  __classPrivateFieldGet$7(this, _AgentClient_unsubscribers, "f").push(unsub);
@@ -5790,7 +5986,9 @@ class AgentClient {
5790
5986
  return __classPrivateFieldGet$7(this, _AgentClient_apiClient, "f").call('hosting.requestPayment', { amountHOT });
5791
5987
  }
5792
5988
  }
5793
- _AgentClient_apiClient = new WeakMap(), _AgentClient_baseUrl = new WeakMap(), _AgentClient_token = new WeakMap(), _AgentClient_appsChangedCallback = new WeakMap(), _AgentClient_updatedCallbacks = new WeakMap(), _AgentClient_agentStatusChangedCallbacks = new WeakMap(), _AgentClient_hostingUserInfoChangedCallbacks = new WeakMap(), _AgentClient_computeLogUpdatedCallbacks = new WeakMap(), _AgentClient_unsubscribers = new WeakMap();
5989
+ _AgentClient_apiClient = new WeakMap(), _AgentClient_baseUrl = new WeakMap(), _AgentClient_token = new WeakMap(), _AgentClient_appsChangedCallback = new WeakMap(), _AgentClient_updatedCallbacks = new WeakMap(), _AgentClient_agentStatusChangedCallbacks = new WeakMap(), _AgentClient_hostingUserInfoChangedCallbacks = new WeakMap(), _AgentClient_computeLogUpdatedCallbacks = new WeakMap(), _AgentClient_unsubscribers = new WeakMap(), _AgentClient_memCache = new WeakMap(), _AgentClient_persistent = new WeakMap(), _AgentClient_selfDid = new WeakMap();
5990
+ /** TTL for remote (non-self) agent profiles in L1 cache (ms). */
5991
+ AgentClient.REMOTE_AGENT_TTL_MS = 5 * 60000; // 5 minutes
5794
5992
 
5795
5993
  var __classPrivateFieldSet$6 = (undefined && undefined.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
5796
5994
  if (kind === "m") throw new TypeError("Private method is not writable");
@@ -6219,13 +6417,22 @@ var __classPrivateFieldGet$3 = (undefined && undefined.__classPrivateFieldGet) |
6219
6417
  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");
6220
6418
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
6221
6419
  };
6222
- var _ExpressionClient_apiClient;
6420
+ var _ExpressionClient_instances, _ExpressionClient_apiClient, _ExpressionClient_memCache, _ExpressionClient_inflight, _ExpressionClient_totalMemBytes, _ExpressionClient_persistent, _ExpressionClient_memCacheResult;
6223
6421
  class ExpressionClient {
6224
6422
  constructor(baseUrl, token, sharedApiClient) {
6423
+ _ExpressionClient_instances.add(this);
6225
6424
  _ExpressionClient_apiClient.set(this, void 0);
6425
+ // L1: in-memory LRU cache (hot path, sub-ms)
6426
+ _ExpressionClient_memCache.set(this, new Map());
6427
+ _ExpressionClient_inflight.set(this, new Map());
6428
+ _ExpressionClient_totalMemBytes.set(this, 0);
6429
+ // L2: persistent cache (IndexedDB in browser, NullCache in Node)
6430
+ _ExpressionClient_persistent.set(this, void 0);
6226
6431
  __classPrivateFieldSet$3(this, _ExpressionClient_apiClient, sharedApiClient || new ApiClient(baseUrl, token), "f");
6432
+ __classPrivateFieldSet$3(this, _ExpressionClient_persistent, createPersistentCache('ad4m-expression-cache', 'expressions'), "f");
6227
6433
  }
6228
6434
  async get(url, alwaysGet = false) {
6435
+ // Existing literal fast-path
6229
6436
  if (!alwaysGet) {
6230
6437
  try {
6231
6438
  let literalValue = Literal.fromUrl(url).get();
@@ -6237,10 +6444,85 @@ class ExpressionClient {
6237
6444
  }
6238
6445
  catch (e) { }
6239
6446
  }
6240
- return __classPrivateFieldGet$3(this, _ExpressionClient_apiClient, "f").call('expression.get', { url });
6447
+ // L1: memory hit
6448
+ if (!alwaysGet) {
6449
+ const memHit = __classPrivateFieldGet$3(this, _ExpressionClient_memCache, "f").get(url);
6450
+ if (memHit)
6451
+ return memHit.data;
6452
+ }
6453
+ // Deduplicate in-flight requests
6454
+ if (!alwaysGet) {
6455
+ const existing = __classPrivateFieldGet$3(this, _ExpressionClient_inflight, "f").get(url);
6456
+ if (existing)
6457
+ return existing;
6458
+ }
6459
+ // L2 check + L3 network
6460
+ const promise = (async () => {
6461
+ if (!alwaysGet) {
6462
+ const persisted = await __classPrivateFieldGet$3(this, _ExpressionClient_persistent, "f").get(url);
6463
+ if (persisted) {
6464
+ __classPrivateFieldGet$3(this, _ExpressionClient_instances, "m", _ExpressionClient_memCacheResult).call(this, url, persisted); // promote to L1
6465
+ return persisted;
6466
+ }
6467
+ }
6468
+ // L3: network fetch
6469
+ const result = await __classPrivateFieldGet$3(this, _ExpressionClient_apiClient, "f").call('expression.get', { url });
6470
+ __classPrivateFieldGet$3(this, _ExpressionClient_instances, "m", _ExpressionClient_memCacheResult).call(this, url, result);
6471
+ __classPrivateFieldGet$3(this, _ExpressionClient_persistent, "f").put(url, result); // fire-and-forget write to L2
6472
+ return result;
6473
+ })();
6474
+ __classPrivateFieldGet$3(this, _ExpressionClient_inflight, "f").set(url, promise);
6475
+ try {
6476
+ return await promise;
6477
+ }
6478
+ finally {
6479
+ __classPrivateFieldGet$3(this, _ExpressionClient_inflight, "f").delete(url);
6480
+ }
6241
6481
  }
6242
6482
  async getMany(urls) {
6243
- return __classPrivateFieldGet$3(this, _ExpressionClient_apiClient, "f").call('expression.getMany', { urls });
6483
+ // Check L1 first
6484
+ const results = urls.map(u => __classPrivateFieldGet$3(this, _ExpressionClient_memCache, "f").get(u)?.data ?? null);
6485
+ let uncachedIndices = results
6486
+ .map((r, i) => r === null ? i : -1)
6487
+ .filter(i => i >= 0);
6488
+ if (uncachedIndices.length === 0)
6489
+ return results;
6490
+ // Check L2 for remaining misses
6491
+ const l2Results = await Promise.all(uncachedIndices.map(i => __classPrivateFieldGet$3(this, _ExpressionClient_persistent, "f").get(urls[i])));
6492
+ const stillMissing = [];
6493
+ for (let j = 0; j < uncachedIndices.length; j++) {
6494
+ const idx = uncachedIndices[j];
6495
+ if (l2Results[j]) {
6496
+ results[idx] = l2Results[j];
6497
+ __classPrivateFieldGet$3(this, _ExpressionClient_instances, "m", _ExpressionClient_memCacheResult).call(this, urls[idx], l2Results[j]); // promote to L1
6498
+ }
6499
+ else {
6500
+ stillMissing.push(idx);
6501
+ }
6502
+ }
6503
+ if (stillMissing.length === 0)
6504
+ return results;
6505
+ // L3: fetch only truly uncached URLs
6506
+ const uncachedUrls = stillMissing.map(i => urls[i]);
6507
+ const fetched = await __classPrivateFieldGet$3(this, _ExpressionClient_apiClient, "f").call('expression.getMany', { urls: uncachedUrls });
6508
+ for (let i = 0; i < stillMissing.length; i++) {
6509
+ const idx = stillMissing[i];
6510
+ results[idx] = fetched[i];
6511
+ if (fetched[i]) {
6512
+ __classPrivateFieldGet$3(this, _ExpressionClient_instances, "m", _ExpressionClient_memCacheResult).call(this, uncachedUrls[i], fetched[i]);
6513
+ __classPrivateFieldGet$3(this, _ExpressionClient_persistent, "f").put(uncachedUrls[i], fetched[i]); // fire-and-forget
6514
+ }
6515
+ }
6516
+ return results;
6517
+ }
6518
+ /**
6519
+ * Clear both L1 (memory) and L2 (persistent) expression caches.
6520
+ */
6521
+ clearCache() {
6522
+ __classPrivateFieldGet$3(this, _ExpressionClient_memCache, "f").clear();
6523
+ __classPrivateFieldGet$3(this, _ExpressionClient_inflight, "f").clear();
6524
+ __classPrivateFieldSet$3(this, _ExpressionClient_totalMemBytes, 0, "f");
6525
+ __classPrivateFieldGet$3(this, _ExpressionClient_persistent, "f").clear(); // fire-and-forget
6244
6526
  }
6245
6527
  async getRaw(url) {
6246
6528
  return __classPrivateFieldGet$3(this, _ExpressionClient_apiClient, "f").call('expression.get', { url, raw: true });
@@ -6253,10 +6535,33 @@ class ExpressionClient {
6253
6535
  return __classPrivateFieldGet$3(this, _ExpressionClient_apiClient, "f").call('expression.interactions', { url });
6254
6536
  }
6255
6537
  async interact(url, interactionCall) {
6256
- return __classPrivateFieldGet$3(this, _ExpressionClient_apiClient, "f").call('expression.interact', { url, interactionCall });
6538
+ const result = await __classPrivateFieldGet$3(this, _ExpressionClient_apiClient, "f").call('expression.interact', { url, interactionCall });
6539
+ // Interactions can mutate the expression — invalidate cache so next get() fetches fresh
6540
+ __classPrivateFieldGet$3(this, _ExpressionClient_memCache, "f").delete(url);
6541
+ __classPrivateFieldGet$3(this, _ExpressionClient_inflight, "f").delete(url);
6542
+ __classPrivateFieldGet$3(this, _ExpressionClient_persistent, "f").delete(url); // fire-and-forget
6543
+ return result;
6257
6544
  }
6258
6545
  }
6259
- _ExpressionClient_apiClient = new WeakMap();
6546
+ _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) {
6547
+ const size = JSON.stringify(data).length;
6548
+ // Evict oldest entries if we'd exceed limits
6549
+ while (__classPrivateFieldGet$3(this, _ExpressionClient_memCache, "f").size >= ExpressionClient.MAX_MEM_ENTRIES ||
6550
+ __classPrivateFieldGet$3(this, _ExpressionClient_totalMemBytes, "f") + size > ExpressionClient.MAX_MEM_BYTES) {
6551
+ const oldest = __classPrivateFieldGet$3(this, _ExpressionClient_memCache, "f").keys().next().value;
6552
+ if (!oldest)
6553
+ break;
6554
+ const entry = __classPrivateFieldGet$3(this, _ExpressionClient_memCache, "f").get(oldest);
6555
+ __classPrivateFieldSet$3(this, _ExpressionClient_totalMemBytes, __classPrivateFieldGet$3(this, _ExpressionClient_totalMemBytes, "f") - entry.size, "f");
6556
+ __classPrivateFieldGet$3(this, _ExpressionClient_memCache, "f").delete(oldest);
6557
+ }
6558
+ __classPrivateFieldGet$3(this, _ExpressionClient_memCache, "f").set(url, { data, size });
6559
+ __classPrivateFieldSet$3(this, _ExpressionClient_totalMemBytes, __classPrivateFieldGet$3(this, _ExpressionClient_totalMemBytes, "f") + size, "f");
6560
+ };
6561
+ /** Maximum number of entries in the L1 memory cache. */
6562
+ ExpressionClient.MAX_MEM_ENTRIES = 200;
6563
+ /** Maximum total size (in bytes) of L1 memory cache values. */
6564
+ ExpressionClient.MAX_MEM_BYTES = 5 * 1024 * 1024; // 5 MB
6260
6565
 
6261
6566
  var base64Js = {};
6262
6567
 
@@ -14621,8 +14926,14 @@ class ModelQueryBuilder {
14621
14926
  const parseResults = (raw) => {
14622
14927
  return ctor.parseModelResult(this.perspective, raw, this.queryParams.include, this.queryParams.properties);
14623
14928
  };
14624
- // Parse initial results
14625
- const initialResults = parseResults(initialModelResult);
14929
+ // Resolve non-literal (file-language) properties — handles both raw URI strings
14930
+ // and already-resolved FileData objects returned by the Rust executor.
14931
+ const resolveAndReturn = async (instances) => {
14932
+ await ctor.resolveNonLiteralProps(this.perspective, instances);
14933
+ return instances;
14934
+ };
14935
+ // Parse initial results (with non-literal resolution)
14936
+ const initialResults = await resolveAndReturn(parseResults(initialModelResult));
14626
14937
  // Track last emitted result fingerprint to suppress duplicate callbacks
14627
14938
  let lastResultFingerprint = null;
14628
14939
  const buildFingerprint = (results) => {
@@ -14634,18 +14945,16 @@ class ModelQueryBuilder {
14634
14945
  // Listen for subscription updates via the same GraphQL subscription channel.
14635
14946
  // When Rust re-runs the model query and finds changed results, it pushes them.
14636
14947
  const unsubscribe = this.perspective.client.subscribeToQueryUpdates(subscriptionId, (rawResult) => {
14637
- // Skip delayed #init# messages — initial data was already returned
14638
- // synchronously from modelSubscribe(). Late init messages contain stale
14639
- // data that would overwrite real subscription updates.
14640
- if (rawResult && rawResult.isInit)
14641
- return;
14642
14948
  try {
14643
- const results = parseResults(rawResult);
14644
- const fp = buildFingerprint(results);
14645
- if (fp === lastResultFingerprint)
14646
- return;
14647
- lastResultFingerprint = fp;
14648
- callback(results);
14949
+ resolveAndReturn(parseResults(rawResult)).then((results) => {
14950
+ const fp = buildFingerprint(results);
14951
+ if (fp === lastResultFingerprint)
14952
+ return;
14953
+ lastResultFingerprint = fp;
14954
+ callback(results);
14955
+ }).catch((e) => {
14956
+ console.error('Model subscription update resolve error:', e);
14957
+ });
14649
14958
  }
14650
14959
  catch (e) {
14651
14960
  console.error('Model subscription update parse error:', e);
@@ -14745,8 +15054,6 @@ class ModelQueryBuilder {
14745
15054
  };
14746
15055
  const initialCount = parseCount(initialModelResult);
14747
15056
  const unsubscribe = this.perspective.client.subscribeToQueryUpdates(subscriptionId, (rawResult) => {
14748
- if (rawResult && rawResult.isInit)
14749
- return;
14750
15057
  try {
14751
15058
  callback(parseCount(rawResult));
14752
15059
  }
@@ -14860,8 +15167,6 @@ class ModelQueryBuilder {
14860
15167
  callback({ results, totalCount, pageSize, pageNumber });
14861
15168
  };
14862
15169
  const unsubscribe = this.perspective.client.subscribeToQueryUpdates(subscriptionId, (rawResult) => {
14863
- if (rawResult && rawResult.isInit)
14864
- return;
14865
15170
  processResults().catch(e => console.error('Paginate subscription error:', e));
14866
15171
  });
14867
15172
  let keepaliveFailures = 0;
@@ -14915,6 +15220,48 @@ function normalizeValue(value) {
14915
15220
  return value;
14916
15221
  }
14917
15222
 
15223
+ // ---------------------------------------------------------------------------
15224
+ // Default decoder for file-storage (non-literal resolveLanguage) properties
15225
+ // ---------------------------------------------------------------------------
15226
+ /**
15227
+ * When the Rust executor resolves a non-literal expression it may return a
15228
+ * `FileData`-shaped object (`{ data_base64, file_type, ... }`) rather than a
15229
+ * raw URI string. If the model class has no custom `transform` registered
15230
+ * (e.g. it was synthesised from a SHACL shape at runtime) we still want to
15231
+ * decode the content rather than passing raw `FileData` to callers.
15232
+ *
15233
+ * Decoding rules (mirrors the JS `decodeFileAsJson` / `decodeFileAsString` helpers):
15234
+ * - `application/json` (default when `file_type` is absent) → JSON.parse
15235
+ * - anything else → raw decoded string
15236
+ *
15237
+ * If `resolved` is not a `FileData` object the value is returned unchanged so
15238
+ * that callers can use this as a safe unconditional fallback.
15239
+ */
15240
+ function defaultFileDecode(resolved) {
15241
+ if (resolved !== null &&
15242
+ typeof resolved === 'object' &&
15243
+ 'data_base64' in resolved) {
15244
+ const fd = resolved;
15245
+ let raw;
15246
+ try {
15247
+ raw = atob(fd.data_base64);
15248
+ }
15249
+ catch {
15250
+ return resolved; // malformed base64 — keep as-is
15251
+ }
15252
+ const isJson = !fd.file_type || fd.file_type === 'application/json';
15253
+ if (isJson) {
15254
+ try {
15255
+ return JSON.parse(raw);
15256
+ }
15257
+ catch {
15258
+ return raw;
15259
+ }
15260
+ }
15261
+ return raw;
15262
+ }
15263
+ return resolved;
15264
+ }
14918
15265
  // ---------------------------------------------------------------------------
14919
15266
  // Helpers for Rust-side include resolution
14920
15267
  // ---------------------------------------------------------------------------
@@ -15667,7 +16014,11 @@ class Ad4mModel {
15667
16014
  const allRelMeta = getRelationsMetadata(this);
15668
16015
  enrichShapeForIncludes(metadata, query.include, allRelMeta);
15669
16016
  }
15670
- // Pre-compute conformance getters (with where-clause support)
16017
+ // Pre-compute conformance getters for Rust-side evaluation.
16018
+ // Where clauses are NOT compiled into getter SPARQL because stored
16019
+ // property values are signed expression envelopes (literal:json:...),
16020
+ // not simple literal:string:X values. Instead, where clauses are
16021
+ // attached as metadata for Rust-side post-evaluation filtering.
15671
16022
  {
15672
16023
  const allRelMeta = getRelationsMetadata(this);
15673
16024
  for (const [relName, relMeta] of Object.entries(metadata.relations)) {
@@ -15680,43 +16031,31 @@ class Ad4mModel {
15680
16031
  try {
15681
16032
  const TargetClass = meta.target();
15682
16033
  const filter = buildConformanceFilter(meta.predicate, TargetClass);
15683
- // Compile where clauses to SPARQL when all target properties use
15684
- // literal encoding (literal:string:X etc.) which is SPARQL-matchable.
15685
- // Properties with a non-literal resolveLanguage store expression hashes
15686
- // that can't be matched by value in SPARQL.
15687
- let whereConditions = [];
16034
+ if (filter) {
16035
+ rel.getter = filter.getter;
16036
+ }
16037
+ // Attach where-clause metadata for Rust-side post-getter filtering
15688
16038
  if (rel.where) {
15689
16039
  try {
15690
16040
  const targetMetadata = TargetClass.getModelMetadata?.() ?? null;
15691
- let allSparqlFilterable = true;
15692
16041
  if (targetMetadata) {
16042
+ const predicates = {};
15693
16043
  for (const propName of Object.keys(rel.where)) {
15694
16044
  if (['id', 'author', 'timestamp'].includes(propName))
15695
16045
  continue;
15696
16046
  const propMeta = targetMetadata.properties[propName];
15697
- if (propMeta?.resolveLanguage && propMeta.resolveLanguage !== 'literal') {
15698
- allSparqlFilterable = false;
15699
- break;
16047
+ if (propMeta?.predicate) {
16048
+ predicates[propName] = propMeta.predicate;
15700
16049
  }
15701
16050
  }
15702
- }
15703
- if (allSparqlFilterable) {
15704
- whereConditions = compileWhereClause(rel.where, targetMetadata);
16051
+ if (Object.keys(predicates).length > 0) {
16052
+ rel.whereFilter = rel.where;
16053
+ rel.wherePredicates = predicates;
16054
+ }
15705
16055
  }
15706
16056
  }
15707
16057
  catch (_) { }
15708
16058
  }
15709
- if (filter) {
15710
- let getter = filter.getter;
15711
- if (whereConditions.length > 0) {
15712
- getter = getter.replace(/ \}$/, ` ${whereConditions.join(' ')} }`);
15713
- }
15714
- rel.getter = getter;
15715
- }
15716
- else if (whereConditions.length > 0) {
15717
- const escapedPred = meta.predicate.replace(/[<>"{}|\\^`\u0000-\u0020]/g, '');
15718
- rel.getter = `SELECT ?target WHERE { <Base> <${escapedPred}> ?target . ${whereConditions.join(' ')} }`;
15719
- }
15720
16059
  }
15721
16060
  catch (_) { }
15722
16061
  }
@@ -15739,6 +16078,55 @@ class Ad4mModel {
15739
16078
  return [];
15740
16079
  return arr.map((json) => jsonToModelInstance(this, perspective, json, include, properties));
15741
16080
  }
16081
+ /**
16082
+ * Resolve non-literal (file-language) properties on an array of already-constructed
16083
+ * model instances. Handles two cases:
16084
+ *
16085
+ * 1. The Rust executor returned a raw URI string → fetch via `getExpression` then apply transform.
16086
+ * 2. The Rust executor already resolved the expression and returned a `FileData` object
16087
+ * (happens when the perspective backend eagerly fetches file content) → apply transform
16088
+ * (or `defaultFileDecode` if no transform is registered on the class, e.g. for SHACL-
16089
+ * synthesised model classes).
16090
+ *
16091
+ * Extracted as a public static so `ModelQueryBuilder.subscribe()` can reuse it without
16092
+ * duplicating logic or introducing a circular dependency.
16093
+ * @internal
16094
+ */
16095
+ static async resolveNonLiteralProps(perspective, instances) {
16096
+ const propsMeta = getPropertiesMetadata(this);
16097
+ const resolveProps = Object.entries(propsMeta).filter(([, opts]) => opts.resolveLanguage != null &&
16098
+ opts.resolveLanguage !== 'literal');
16099
+ if (resolveProps.length === 0)
16100
+ return;
16101
+ await Promise.all(instances.map(async (inst) => {
16102
+ for (const [propName, opts] of resolveProps) {
16103
+ const val = inst[propName];
16104
+ const transform = opts.transform;
16105
+ const applyTransform = (resolved) => typeof transform === 'function' ? transform(resolved) : defaultFileDecode(resolved);
16106
+ if (typeof val === 'string' && val && !val.startsWith('literal:')) {
16107
+ // Case 1: raw URI — fetch from language runtime
16108
+ try {
16109
+ const expression = await perspective.getExpression(val);
16110
+ if (expression) {
16111
+ let resolved;
16112
+ try {
16113
+ resolved = JSON.parse(expression.data);
16114
+ }
16115
+ catch {
16116
+ resolved = expression.data;
16117
+ }
16118
+ inst[propName] = applyTransform(resolved);
16119
+ }
16120
+ }
16121
+ catch (_) { /* resolution failed — keep raw value */ }
16122
+ }
16123
+ else if (val !== null && val !== undefined && typeof val === 'object') {
16124
+ // Case 2: already resolved by Rust — apply transform / default decode
16125
+ inst[propName] = applyTransform(val);
16126
+ }
16127
+ }
16128
+ }));
16129
+ }
15742
16130
  // instancesFromQueryResult — removed (superseded by Rust executeModelQuery pipeline)
15743
16131
  /**
15744
16132
  * Execute a model query via the executor-side endpoint.
@@ -15849,45 +16237,33 @@ class Ad4mModel {
15849
16237
  try {
15850
16238
  const TargetClass = meta.target();
15851
16239
  const filter = buildConformanceFilter(meta.predicate, TargetClass);
15852
- // Compile where clauses to SPARQL when all target properties use
15853
- // literal encoding (literal:string:X etc.) which is SPARQL-matchable.
15854
- // Properties with a non-literal resolveLanguage store expression hashes
15855
- // that can't be matched by value in SPARQL.
15856
- let whereConditions = [];
16240
+ if (filter) {
16241
+ rel.getter = filter.getter;
16242
+ }
16243
+ // Attach where-clause metadata for Rust-side post-getter filtering.
16244
+ // Property values are signed expression envelopes (literal:json:...)
16245
+ // and cannot be matched by SPARQL FILTER on the raw IRI.
15857
16246
  if (rel.where) {
15858
16247
  try {
15859
16248
  const targetMetadata = TargetClass.getModelMetadata?.() ?? null;
15860
- let allSparqlFilterable = true;
15861
16249
  if (targetMetadata) {
16250
+ const predicates = {};
15862
16251
  for (const propName of Object.keys(rel.where)) {
15863
16252
  if (['id', 'author', 'timestamp'].includes(propName))
15864
16253
  continue;
15865
16254
  const propMeta = targetMetadata.properties[propName];
15866
- if (propMeta?.resolveLanguage && propMeta.resolveLanguage !== 'literal') {
15867
- allSparqlFilterable = false;
15868
- break;
16255
+ if (propMeta?.predicate) {
16256
+ predicates[propName] = propMeta.predicate;
15869
16257
  }
15870
16258
  }
15871
- }
15872
- if (allSparqlFilterable) {
15873
- whereConditions = compileWhereClause(rel.where, targetMetadata);
16259
+ if (Object.keys(predicates).length > 0) {
16260
+ rel.whereFilter = rel.where;
16261
+ rel.wherePredicates = predicates;
16262
+ }
15874
16263
  }
15875
16264
  }
15876
16265
  catch (_) { /* target metadata unavailable */ }
15877
16266
  }
15878
- if (filter) {
15879
- let getter = filter.getter;
15880
- if (whereConditions.length > 0) {
15881
- // Append where conditions before the closing }
15882
- getter = getter.replace(/ \}$/, ` ${whereConditions.join(' ')} }`);
15883
- }
15884
- rel.getter = getter;
15885
- }
15886
- else if (whereConditions.length > 0) {
15887
- // No conformance filter but where clause exists — build getter from where alone
15888
- const escapedPred = meta.predicate.replace(/[<>"{}|\\^`\u0000-\u0020]/g, '');
15889
- rel.getter = `SELECT ?target WHERE { <Base> <${escapedPred}> ?target . ${whereConditions.join(' ')} }`;
15890
- }
15891
16267
  }
15892
16268
  catch (e) {
15893
16269
  // Target class may not be available; skip silently
@@ -15899,13 +16275,6 @@ class Ad4mModel {
15899
16275
  // the TS decorators are the definitive source of truth.
15900
16276
  const shapeJson = JSON.stringify(metadata);
15901
16277
  const queryJson = JSON.stringify(queryInput);
15902
- // TEMP DEBUG: Log getters with where-clause filters to diagnose CI failure
15903
- for (const [relName, relMeta] of Object.entries(metadata.relations)) {
15904
- const rel = relMeta;
15905
- if (rel.where) {
15906
- console.log(`[MODEL_QUERY_DEBUG] relation="${relName}" getter=${rel.getter ?? 'NONE'} where=${JSON.stringify(rel.where)}`);
15907
- }
15908
- }
15909
16278
  const result = await perspective.modelQuery(className, queryJson, shapeJson);
15910
16279
  // Convert JSON instances to model class instances, recursively constructing
15911
16280
  // class instances for any included relations resolved by Rust.
@@ -15914,34 +16283,9 @@ class Ad4mModel {
15914
16283
  });
15915
16284
  // Resolve non-literal expressions (e.g. file languages where the stored
15916
16285
  // value is a content-addressed hash that must be fetched from the language
15917
- // runtime). The Rust endpoint returns raw target URIs; we resolve them here.
15918
- const propsMeta = getPropertiesMetadata(this);
15919
- const resolveProps = Object.entries(propsMeta).filter(([, opts]) => opts.resolveLanguage != null &&
15920
- opts.resolveLanguage !== 'literal');
15921
- if (resolveProps.length > 0) {
15922
- await Promise.all(instances.map(async (inst) => {
15923
- for (const [propName, opts] of resolveProps) {
15924
- const val = inst[propName];
15925
- if (typeof val !== 'string' || !val || val.startsWith('literal:'))
15926
- continue;
15927
- try {
15928
- const expression = await perspective.getExpression(val);
15929
- if (expression) {
15930
- let resolved;
15931
- try {
15932
- resolved = JSON.parse(expression.data);
15933
- }
15934
- catch {
15935
- resolved = expression.data;
15936
- }
15937
- const transform = opts.transform;
15938
- inst[propName] = typeof transform === 'function' ? transform(resolved) : resolved;
15939
- }
15940
- }
15941
- catch (_) { /* resolution failed — keep raw value */ }
15942
- }
15943
- }));
15944
- }
16286
+ // runtime). The Rust endpoint may return either a raw target URI (string)
16287
+ // or an already-resolved FileData object — both cases are handled here.
16288
+ await this.resolveNonLiteralProps(perspective, instances);
15945
16289
  // Take snapshots for dirty tracking
15946
16290
  const snapshotRelations = queryInput.include;
15947
16291
  for (const inst of instances) {
@@ -17010,8 +17354,9 @@ class Ad4mClient {
17010
17354
  __classPrivateFieldGet$1(this, _Ad4mClient_agentClient, "f").subscribeAgentStatusChanged();
17011
17355
  __classPrivateFieldGet$1(this, _Ad4mClient_agentClient, "f").subscribeAppsChanged();
17012
17356
  }
17013
- /** Close all event connections */
17357
+ /** Close all event connections and clear in-memory caches */
17014
17358
  close() {
17359
+ __classPrivateFieldGet$1(this, _Ad4mClient_agentClient, "f").clearByDidCache();
17015
17360
  __classPrivateFieldGet$1(this, _Ad4mClient_apiClient, "f").closeAll();
17016
17361
  }
17017
17362
  }
@@ -17486,4 +17831,4 @@ class ModelInput {
17486
17831
  class VoiceActivityParamsInput {
17487
17832
  }
17488
17833
 
17489
- export { AIClient, Model as AIModel, AIModelLoadingStatus, AIPromptExamples, AIPromptExamplesInput, AITask, AITaskInput, Ad4mClient, Ad4mModel, Agent, AgentClient, AgentExpression, AgentSignature, AgentStatus, Apps, AuthInfo, AuthInfoInput, BelongsToMany, BelongsToOne, Capability, CapabilityInput, ComputeLogEntry, EntanglementProof, EntanglementProofInput, ExceptionInfo, ExceptionType, Expression, ExpressionGeneric, ExpressionGenericInput, ExpressionProof, ExpressionProofInput, ExpressionRef, ExpressionRendered, Flag, HasMany, HasOne, HostingUserInfo, Icon, ImportResult, ImportStats, InteractionCall, InteractionMeta, InteractionParameter, LanguageExpression, LanguageHandle, LanguageLanguageInput, LanguageMeta, LanguageMetaInput, LanguageMetaInternal, LanguageRef, Link, LinkExpression, LinkExpressionInput, LinkExpressionMutations, LinkExpressionUpdated, LinkInput, LinkMutations, LinkQuery, Literal, LocalModel, LocalModelInput, Model$1 as Model, ModelApi, ModelApiInput, ModelInput, ModelQueryBuilder, Neighbourhood, NeighbourhoodExpression, NeighbourhoodProxy, Notification, NotificationInput, OnlineAgent, Optional, PaymentRequestResult, Perspective, PerspectiveDiff, PerspectiveDiffExpression, PerspectiveExpression, PerspectiveHandle, PerspectiveInput, PerspectiveProxy, PerspectiveState, PerspectiveUnsignedInput, Property, QuerySubscriptionProxy, ReadOnly, Resource, ResourceInput, RpcError as RestError, RpcError, RuntimeInfo, SHACLFlow, SHACLShape, SMART_LITERAL_CONTENT_PREDICATE, SentMessage, SmartLiteral, TokenizerSource, TokenizerSourceInput, TriggeredNotification, UserCreationResult, UserStatistics, VerificationRequestResult, VoiceActivityParamsInput, WakerSubscriptionManager, buildConformanceFilter, buildModelFromJSONSchema, buildPaginationSubquery, buildSDNA, buildSHACL, buildSPARQLOrderLimitOffset, buildSPARQLQuery, buildWhereCondition, capSentence, clearQueryCache, compileWhereClause, determineNamespace, determinePredicate, escapeQueryString, exprRef2String, formatList, formatQueryValue, formatSPARQLValue, getCachedResult, getDefaultValueForType, getMemoizedSHACL, getPropertiesMetadata, getPropertyOption, getRelationsMetadata, hasJsOnlyWhereFilters, invalidatePerspectiveCache, isArrayType, isExpression, isIncludeProjection, isLink, isNumericType, isObjectType, isSchemaType, linkEqual, normalizeNamespaceString, normalizeSchemaType, normalizeValue, parseExprUrl, queryCacheSize, resolveParentPredicate, setCachedResult, setPropertyRegistryEntry, setRelationRegistryEntry, typeDefsString };
17834
+ export { AIClient, Model as AIModel, AIModelLoadingStatus, AIPromptExamples, AIPromptExamplesInput, AITask, AITaskInput, Ad4mClient, Ad4mModel, Agent, AgentClient, AgentExpression, AgentSignature, AgentStatus, Apps, AuthInfo, AuthInfoInput, BelongsToMany, BelongsToOne, Capability, CapabilityInput, ComputeLogEntry, EntanglementProof, EntanglementProofInput, ExceptionInfo, ExceptionType, Expression, ExpressionGeneric, ExpressionGenericInput, ExpressionProof, ExpressionProofInput, ExpressionRef, ExpressionRendered, Flag, HasMany, HasOne, HostingUserInfo, IDBCache, Icon, ImportResult, ImportStats, InteractionCall, InteractionMeta, InteractionParameter, LanguageExpression, LanguageHandle, LanguageLanguageInput, LanguageMeta, LanguageMetaInput, LanguageMetaInternal, LanguageRef, Link, LinkExpression, LinkExpressionInput, LinkExpressionMutations, LinkExpressionUpdated, LinkInput, LinkMutations, LinkQuery, Literal, LocalModel, LocalModelInput, Model$1 as Model, ModelApi, ModelApiInput, ModelInput, ModelQueryBuilder, Neighbourhood, NeighbourhoodExpression, NeighbourhoodProxy, Notification, NotificationInput, NullCache, OnlineAgent, Optional, PaymentRequestResult, Perspective, PerspectiveDiff, PerspectiveDiffExpression, PerspectiveExpression, PerspectiveHandle, PerspectiveInput, PerspectiveProxy, PerspectiveState, PerspectiveUnsignedInput, Property, QuerySubscriptionProxy, ReadOnly, Resource, ResourceInput, RpcError as RestError, RpcError, RuntimeInfo, SHACLFlow, SHACLShape, SMART_LITERAL_CONTENT_PREDICATE, SentMessage, SmartLiteral, TokenizerSource, TokenizerSourceInput, TriggeredNotification, UserCreationResult, UserStatistics, VerificationRequestResult, VoiceActivityParamsInput, WakerSubscriptionManager, buildConformanceFilter, buildModelFromJSONSchema, buildPaginationSubquery, buildSDNA, buildSHACL, buildSPARQLOrderLimitOffset, buildSPARQLQuery, buildWhereCondition, capSentence, clearQueryCache, compileWhereClause, createPersistentCache, determineNamespace, determinePredicate, escapeQueryString, exprRef2String, formatList, formatQueryValue, formatSPARQLValue, getCachedResult, getDefaultValueForType, getMemoizedSHACL, getPropertiesMetadata, getPropertyOption, getRelationsMetadata, hasJsOnlyWhereFilters, invalidatePerspectiveCache, isArrayType, isExpression, isIncludeProjection, isLink, isNumericType, isObjectType, isSchemaType, linkEqual, normalizeNamespaceString, normalizeSchemaType, normalizeValue, parseExprUrl, queryCacheSize, resolveParentPredicate, setCachedResult, setPropertyRegistryEntry, setRelationRegistryEntry, typeDefsString };