@camstack/server 1.2.753 → 1.2.755

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (86) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/api/trpc/generated-cap-routers.js +5 -3
  3. package/package.json +4 -7
  4. package/system/dist/{agent-https-cxghRfum.mjs → agent-https-BFphJVi1.mjs} +1 -1
  5. package/system/dist/{agent-https-B0bjQVfy.js → agent-https-Cmg4_OkK.js} +1 -1
  6. package/system/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.js +1 -1
  7. package/system/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.mjs +1 -1
  8. package/system/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.js +1 -1
  9. package/system/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.mjs +1 -1
  10. package/system/dist/builtins/alerts/alerts.addon.js +1 -1
  11. package/system/dist/builtins/alerts/alerts.addon.mjs +1 -1
  12. package/system/dist/builtins/autotrack/index.js +1 -1
  13. package/system/dist/builtins/autotrack/index.mjs +1 -1
  14. package/system/dist/builtins/backup-orchestrator/backup-orchestrator.addon.js +2 -2
  15. package/system/dist/builtins/backup-orchestrator/backup-orchestrator.addon.mjs +2 -2
  16. package/system/dist/builtins/calendars/calendars.addon.js +1 -1
  17. package/system/dist/builtins/calendars/calendars.addon.mjs +1 -1
  18. package/system/dist/builtins/camera-grid/index.js +1 -1
  19. package/system/dist/builtins/camera-grid/index.mjs +1 -1
  20. package/system/dist/builtins/composer/composer.addon.js +3 -3
  21. package/system/dist/builtins/composer/composer.addon.mjs +3 -3
  22. package/system/dist/builtins/console-logging/index.js +1 -1
  23. package/system/dist/builtins/console-logging/index.mjs +1 -1
  24. package/system/dist/builtins/core-blocks/core-blocks.addon.js +3 -3
  25. package/system/dist/builtins/core-blocks/core-blocks.addon.mjs +3 -3
  26. package/system/dist/builtins/device-history/device-history.addon.js +2 -2
  27. package/system/dist/builtins/device-history/device-history.addon.mjs +2 -2
  28. package/system/dist/builtins/device-manager/device-manager.addon.js +1 -1
  29. package/system/dist/builtins/device-manager/device-manager.addon.mjs +1 -1
  30. package/system/dist/builtins/hub-forwarder/index.js +1 -1
  31. package/system/dist/builtins/hub-forwarder/index.mjs +1 -1
  32. package/system/dist/builtins/keychain/index.js +3 -3
  33. package/system/dist/builtins/keychain/index.mjs +3 -3
  34. package/system/dist/builtins/liveness-monitor/liveness-monitor.addon.js +1 -1
  35. package/system/dist/builtins/liveness-monitor/liveness-monitor.addon.mjs +1 -1
  36. package/system/dist/builtins/local-auth/local-auth.addon.js +2 -2
  37. package/system/dist/builtins/local-auth/local-auth.addon.mjs +2 -2
  38. package/system/dist/builtins/local-network/local-network.addon.js +2 -2
  39. package/system/dist/builtins/local-network/local-network.addon.mjs +2 -2
  40. package/system/dist/builtins/loki-logging/index.js +135 -25
  41. package/system/dist/builtins/loki-logging/index.mjs +135 -25
  42. package/system/dist/builtins/loki-logging/loki-destination-set.d.ts +47 -0
  43. package/system/dist/builtins/loki-logging/loki-logging.addon.d.ts +10 -5
  44. package/system/dist/builtins/native-metrics/native-metrics.addon.js +1 -1
  45. package/system/dist/builtins/native-metrics/native-metrics.addon.mjs +1 -1
  46. package/system/dist/builtins/platform-probe/index.js +1 -1
  47. package/system/dist/builtins/platform-probe/index.mjs +1 -1
  48. package/system/dist/builtins/record-entries/index.js +1 -1
  49. package/system/dist/builtins/record-entries/index.mjs +1 -1
  50. package/system/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.js +1 -1
  51. package/system/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.mjs +1 -1
  52. package/system/dist/builtins/snapshot/index.js +1 -1
  53. package/system/dist/builtins/snapshot/index.mjs +1 -1
  54. package/system/dist/builtins/sqlite-storage/filesystem-storage.addon.js +1 -1
  55. package/system/dist/builtins/sqlite-storage/filesystem-storage.addon.mjs +1 -1
  56. package/system/dist/builtins/sqlite-storage/index.js +1 -1
  57. package/system/dist/builtins/sqlite-storage/index.mjs +1 -1
  58. package/system/dist/builtins/sqlite-storage/sqlite-settings.addon.js +2 -2
  59. package/system/dist/builtins/sqlite-storage/sqlite-settings.addon.mjs +2 -2
  60. package/system/dist/builtins/storage-orchestrator/storage-orchestrator.addon.js +1 -1
  61. package/system/dist/builtins/storage-orchestrator/storage-orchestrator.addon.mjs +1 -1
  62. package/system/dist/builtins/system-config/system-config.addon.js +3 -3
  63. package/system/dist/builtins/system-config/system-config.addon.mjs +3 -3
  64. package/system/dist/builtins/winston-logging/index.js +1 -1
  65. package/system/dist/builtins/winston-logging/index.mjs +1 -1
  66. package/system/dist/{capture-engine-eRAebXP1.js → capture-engine-D1fFhBsZ.js} +1 -1
  67. package/system/dist/{capture-engine-CfJdhMTH.mjs → capture-engine-DszgvkMP.mjs} +1 -1
  68. package/system/dist/{composition-sources-BvDYLpw_.js → composition-sources-BbiBPC0x.js} +1 -1
  69. package/system/dist/{composition-sources-ChtkMq1Q.mjs → composition-sources-qqbLY33z.mjs} +1 -1
  70. package/system/dist/{constants-DkC9-VOa.js → constants-C_sardew.js} +1 -1
  71. package/system/dist/{constants-CYNsr0lM.mjs → constants-DMRqwVBi.mjs} +1 -1
  72. package/system/dist/{device-ca-BxInMpK2.js → device-ca-CGBOO9s8.js} +1 -1
  73. package/system/dist/{device-ca-CQg3PTnE.mjs → device-ca-ECBQF6U4.mjs} +1 -1
  74. package/system/dist/{dist-C5eIFTMo.mjs → dist-Cn8xk9RA.mjs} +8 -1
  75. package/system/dist/{dist-DFWnAzAY.js → dist-LlcIu2lh.js} +8 -1
  76. package/system/dist/file-host-worker.js +1 -1
  77. package/system/dist/file-host-worker.mjs +1 -1
  78. package/system/dist/{hub-mdns-ciao-DW_g42El.mjs → hub-mdns-ciao-DQejl__M.mjs} +2 -2
  79. package/system/dist/{hub-mdns-ciao-BQDdPkPO.js → hub-mdns-ciao-Dk5BxEm4.js} +2 -2
  80. package/system/dist/index.js +7 -7
  81. package/system/dist/index.mjs +7 -7
  82. package/system/dist/{restore-archive-CFGGJCfV.mjs → restore-archive-B3m84Rku.mjs} +1 -1
  83. package/system/dist/{restore-archive-DRjYgh6D.js → restore-archive-C5ZF5jqP.js} +1 -1
  84. package/system/dist/{wal-maintenance-xYk-FpJW.mjs → wal-maintenance-D7ddH6JT.mjs} +0 -0
  85. package/system/dist/{wal-maintenance-D0zSmIwJ.js → wal-maintenance-Jjwq3CZm.js} +0 -0
  86. package/system/package.json +1 -1
@@ -3,7 +3,7 @@ Object.defineProperties(exports, {
3
3
  [Symbol.toStringTag]: { value: "Module" }
4
4
  });
5
5
  require("../../chunk-Cek0wNdY.js");
6
- const require_dist = require("../../dist-DFWnAzAY.js");
6
+ const require_dist = require("../../dist-LlcIu2lh.js");
7
7
  const require_log_read_filter = require("../../log-read-filter-Bi066jwU.js");
8
8
  let zod = require("zod");
9
9
  //#region src/builtins/loki-logging/loki-payload.ts
@@ -609,6 +609,110 @@ var LokiDestination = class {
609
609
  }
610
610
  };
611
611
  //#endregion
612
+ //#region src/builtins/loki-logging/loki-destination-set.ts
613
+ var INERT_STATUS = {
614
+ enabled: false,
615
+ configured: false,
616
+ queued: 0,
617
+ pushed: 0,
618
+ dropped: 0,
619
+ failures: 0,
620
+ lastError: null,
621
+ lastPushAtMs: null
622
+ };
623
+ var LokiDestinationSet = class {
624
+ deps;
625
+ members = /* @__PURE__ */ new Map();
626
+ constructor(deps) {
627
+ this.deps = deps;
628
+ }
629
+ async initialize() {}
630
+ /** The ids this set currently holds, in record-id order. */
631
+ ids() {
632
+ return [...this.members.keys()].sort();
633
+ }
634
+ /**
635
+ * Reconcile the set with `configs` (record id to config): add the new, reconfigure the
636
+ * existing, close the ones no longer there. An id in `keep` is left exactly as it is —
637
+ * its config could not be read this time (a locked keychain), so the previous one stands.
638
+ */
639
+ async apply(configs, keep = /* @__PURE__ */ new Set()) {
640
+ for (const [id, member] of [...this.members]) {
641
+ if (configs.has(id) || keep.has(id)) continue;
642
+ this.members.delete(id);
643
+ await member.shutdown();
644
+ }
645
+ for (const [id, config] of configs) {
646
+ const existing = this.members.get(id);
647
+ if (existing !== void 0) {
648
+ await existing.reconfigure(config);
649
+ continue;
650
+ }
651
+ const member = new LokiDestination(this.deps);
652
+ await member.initialize(config);
653
+ this.members.set(id, member);
654
+ }
655
+ }
656
+ write(entry) {
657
+ for (const member of this.members.values()) member.write(entry);
658
+ }
659
+ async flush() {
660
+ await Promise.all([...this.members.values()].map((m) => m.flush()));
661
+ }
662
+ /** The status of one instance; without an id, the first one (an inert status when none). */
663
+ getStatus(instanceId) {
664
+ const id = instanceId ?? this.ids()[0];
665
+ return (id === void 0 ? void 0 : this.members.get(id))?.getStatus() ?? INERT_STATUS;
666
+ }
667
+ getStatuses() {
668
+ return this.ids().map((instanceId) => ({
669
+ instanceId,
670
+ ...this.members.get(instanceId)?.getStatus() ?? INERT_STATUS
671
+ }));
672
+ }
673
+ /** The named instance, or the first one that can be read; null when none can. */
674
+ async readable(selector) {
675
+ if (selector?.instanceId !== void 0) return this.members.get(selector.instanceId) ?? null;
676
+ for (const id of this.ids()) {
677
+ const member = this.members.get(id);
678
+ if (member !== void 0 && (await member.describeRead()).readable) return member;
679
+ }
680
+ return null;
681
+ }
682
+ async describeRead(selector) {
683
+ const member = await this.readable(selector);
684
+ if (member !== null) return member.describeRead();
685
+ return {
686
+ readable: false,
687
+ reason: selector?.instanceId !== void 0 ? `No Loki destination ${selector.instanceId}` : "Loki is not enabled or has no URL",
688
+ filters: {
689
+ deviceId: true,
690
+ addonId: true,
691
+ nodeId: true,
692
+ tags: true,
693
+ level: true,
694
+ text: true,
695
+ timeRange: true
696
+ },
697
+ retentionDays: null
698
+ };
699
+ }
700
+ async read(query) {
701
+ const member = await this.readable(query);
702
+ if (member === null) throw new Error("Loki is not enabled or has no URL");
703
+ return member.read(query);
704
+ }
705
+ async cancelRead(input) {
706
+ for (const member of this.members.values()) if ((await member.cancelRead(input)).cancelled) return { cancelled: true };
707
+ return { cancelled: false };
708
+ }
709
+ async shutdown() {
710
+ const all = [...this.members.values()];
711
+ this.members.clear();
712
+ await Promise.all(all.map((m) => m.shutdown()));
713
+ }
714
+ };
715
+ //#endregion
612
716
  //#region src/builtins/loki-logging/loki-record-kinds.ts
613
717
  /**
614
718
  * The Loki connection as a record (D985): one `destinations` row per Loki instance, owned by
@@ -951,12 +1055,12 @@ var READY_PATH = "/ready";
951
1055
  var LokiLoggingAddon = class extends require_dist.BaseAddon {
952
1056
  destination = null;
953
1057
  instances = null;
954
- current = null;
955
1058
  refreshTimer = null;
956
1059
  retirementTimer = null;
957
1060
  shuttingDown = false;
958
1061
  declared = false;
959
- secretsWarned = false;
1062
+ /** Instances whose keychain lock was already warned about — once per lock, per instance. */
1063
+ secretsWarned = /* @__PURE__ */ new Set();
960
1064
  constructor() {
961
1065
  super({});
962
1066
  }
@@ -964,7 +1068,7 @@ var LokiLoggingAddon = class extends require_dist.BaseAddon {
964
1068
  return (this.ctx.kernel.localNodeId ?? "hub") === "hub";
965
1069
  }
966
1070
  async onInitialize() {
967
- this.destination = new LokiDestination();
1071
+ this.destination = new LokiDestinationSet();
968
1072
  this.shuttingDown = false;
969
1073
  const registrations = [{
970
1074
  capability: require_dist.logDestinationCapability,
@@ -977,7 +1081,7 @@ var LokiLoggingAddon = class extends require_dist.BaseAddon {
977
1081
  else await this.ensureDeclaredQuietly();
978
1082
  this.instances = new require_dist.RecordIntegrationInstances(records, lokiDestinationsKind, {
979
1083
  description: {
980
- instanceMode: "single",
1084
+ instanceMode: "multiple",
981
1085
  kind: "destination",
982
1086
  canTest: true
983
1087
  },
@@ -1004,9 +1108,9 @@ var LokiLoggingAddon = class extends require_dist.BaseAddon {
1004
1108
  }
1005
1109
  await this.refreshFromRecord();
1006
1110
  }
1007
- await this.destination.initialize(this.destinationConfig());
1008
- const url = this.current?.url ?? "";
1009
- this.ctx.logger.info(url.length > 0 ? `Loki logging initialized → ${url}` : "Loki logging registered but inactive (no URL set)");
1111
+ await this.destination.initialize();
1112
+ const urls = this.destination.getStatuses().filter((status) => status.configured).map((status) => status.instanceId);
1113
+ this.ctx.logger.info(urls.length > 0 ? `Loki logging initialized with ${String(urls.length)} destination(s): ${urls.join(", ")}` : "Loki logging registered but inactive (no destination configured)");
1010
1114
  this.attemptEnabledFlagRetirement(0);
1011
1115
  return registrations;
1012
1116
  }
@@ -1023,27 +1127,37 @@ var LokiLoggingAddon = class extends require_dist.BaseAddon {
1023
1127
  this.ctx.logger.warn("Loki logging: the connection kind could not be declared yet", { meta: { error: err instanceof Error ? err.message : String(err) } });
1024
1128
  }
1025
1129
  }
1026
- /** Re-read the connection record and apply it to the live destination. */
1130
+ /**
1131
+ * Re-read every connection record and reconcile the live destinations with them: a new record
1132
+ * starts one, an edit reconfigures it, a deleted record closes its client. A record whose
1133
+ * secret cannot be read (locked keychain) keeps the configuration it had (D49) and is skipped
1134
+ * if it never had one; the others are unaffected.
1135
+ */
1027
1136
  async refreshFromRecord() {
1028
1137
  if (this.instances === null || this.shuttingDown) return;
1029
- let first;
1138
+ let resolved;
1030
1139
  try {
1031
1140
  if (!this.declared) await this.ensureDeclared();
1032
- [first] = await this.instances.listResolved();
1141
+ resolved = await this.instances.listResolved();
1033
1142
  } catch (err) {
1034
- this.ctx.logger.warn("Loki logging: the connection record could not be read", { meta: { error: err instanceof Error ? err.message : String(err) } });
1143
+ this.ctx.logger.warn("Loki logging: the connection records could not be read", { meta: { error: err instanceof Error ? err.message : String(err) } });
1035
1144
  return;
1036
1145
  }
1037
- if (first?.secrets === "unavailable") {
1038
- if (!this.secretsWarned) {
1039
- this.secretsWarned = true;
1040
- this.ctx.logger.warn("Loki logging: the keychain is locked; the destination keeps its previous configuration");
1146
+ const configs = /* @__PURE__ */ new Map();
1147
+ const keep = /* @__PURE__ */ new Set();
1148
+ for (const instance of resolved) {
1149
+ if (instance.secrets === "unavailable") {
1150
+ keep.add(instance.id);
1151
+ if (!this.secretsWarned.has(instance.id)) {
1152
+ this.secretsWarned.add(instance.id);
1153
+ this.ctx.logger.warn(`Loki logging: the keychain is locked; destination ${instance.id} keeps its previous configuration`);
1154
+ }
1155
+ continue;
1041
1156
  }
1042
- return;
1157
+ this.secretsWarned.delete(instance.id);
1158
+ configs.set(instance.id, this.destinationConfig(instance.body));
1043
1159
  }
1044
- this.secretsWarned = false;
1045
- this.current = first?.body ?? null;
1046
- await this.destination?.reconfigure(this.destinationConfig());
1160
+ await this.destination?.apply(configs, keep);
1047
1161
  }
1048
1162
  /**
1049
1163
  * The catalogue to offer while initialising. Seq 3 cannot decide before registration, so it is
@@ -1270,11 +1384,7 @@ var LokiLoggingAddon = class extends require_dist.BaseAddon {
1270
1384
  * different signature is a type error — usefully, since silently overriding it
1271
1385
  * would have broken this addon's settings reload.
1272
1386
  */
1273
- destinationConfig() {
1274
- const body = this.current ?? {
1275
- ...LOKI_DEFAULT_BODY,
1276
- name: ""
1277
- };
1387
+ destinationConfig(body) {
1278
1388
  return {
1279
1389
  enabled: body.enabled !== false,
1280
1390
  url: body.url,
@@ -1,4 +1,4 @@
1
- import { Fs as isSecretMarker, Lt as RecordIntegrationInstances, Pi as preconditionOf, Ps as isSecretFieldView, Wr as isSameAddonId, Zo as RevConflictError, gs as defineAddonMigrations, jr as integrationInstancesCapability, ri as logDestinationCapability, vn as bareAddonId, vs as defineEntryKind, wo as BaseAddon } from "../../dist-C5eIFTMo.mjs";
1
+ import { Fs as isSecretMarker, Lt as RecordIntegrationInstances, Pi as preconditionOf, Ps as isSecretFieldView, Wr as isSameAddonId, Zo as RevConflictError, gs as defineAddonMigrations, jr as integrationInstancesCapability, ri as logDestinationCapability, vn as bareAddonId, vs as defineEntryKind, wo as BaseAddon } from "../../dist-Cn8xk9RA.mjs";
2
2
  import { n as compileLogFilter, o as lineMatches } from "../../log-read-filter-D7Ev3zm-.mjs";
3
3
  import { z } from "zod";
4
4
  //#region src/builtins/loki-logging/loki-payload.ts
@@ -604,6 +604,110 @@ var LokiDestination = class {
604
604
  }
605
605
  };
606
606
  //#endregion
607
+ //#region src/builtins/loki-logging/loki-destination-set.ts
608
+ var INERT_STATUS = {
609
+ enabled: false,
610
+ configured: false,
611
+ queued: 0,
612
+ pushed: 0,
613
+ dropped: 0,
614
+ failures: 0,
615
+ lastError: null,
616
+ lastPushAtMs: null
617
+ };
618
+ var LokiDestinationSet = class {
619
+ deps;
620
+ members = /* @__PURE__ */ new Map();
621
+ constructor(deps) {
622
+ this.deps = deps;
623
+ }
624
+ async initialize() {}
625
+ /** The ids this set currently holds, in record-id order. */
626
+ ids() {
627
+ return [...this.members.keys()].sort();
628
+ }
629
+ /**
630
+ * Reconcile the set with `configs` (record id to config): add the new, reconfigure the
631
+ * existing, close the ones no longer there. An id in `keep` is left exactly as it is —
632
+ * its config could not be read this time (a locked keychain), so the previous one stands.
633
+ */
634
+ async apply(configs, keep = /* @__PURE__ */ new Set()) {
635
+ for (const [id, member] of [...this.members]) {
636
+ if (configs.has(id) || keep.has(id)) continue;
637
+ this.members.delete(id);
638
+ await member.shutdown();
639
+ }
640
+ for (const [id, config] of configs) {
641
+ const existing = this.members.get(id);
642
+ if (existing !== void 0) {
643
+ await existing.reconfigure(config);
644
+ continue;
645
+ }
646
+ const member = new LokiDestination(this.deps);
647
+ await member.initialize(config);
648
+ this.members.set(id, member);
649
+ }
650
+ }
651
+ write(entry) {
652
+ for (const member of this.members.values()) member.write(entry);
653
+ }
654
+ async flush() {
655
+ await Promise.all([...this.members.values()].map((m) => m.flush()));
656
+ }
657
+ /** The status of one instance; without an id, the first one (an inert status when none). */
658
+ getStatus(instanceId) {
659
+ const id = instanceId ?? this.ids()[0];
660
+ return (id === void 0 ? void 0 : this.members.get(id))?.getStatus() ?? INERT_STATUS;
661
+ }
662
+ getStatuses() {
663
+ return this.ids().map((instanceId) => ({
664
+ instanceId,
665
+ ...this.members.get(instanceId)?.getStatus() ?? INERT_STATUS
666
+ }));
667
+ }
668
+ /** The named instance, or the first one that can be read; null when none can. */
669
+ async readable(selector) {
670
+ if (selector?.instanceId !== void 0) return this.members.get(selector.instanceId) ?? null;
671
+ for (const id of this.ids()) {
672
+ const member = this.members.get(id);
673
+ if (member !== void 0 && (await member.describeRead()).readable) return member;
674
+ }
675
+ return null;
676
+ }
677
+ async describeRead(selector) {
678
+ const member = await this.readable(selector);
679
+ if (member !== null) return member.describeRead();
680
+ return {
681
+ readable: false,
682
+ reason: selector?.instanceId !== void 0 ? `No Loki destination ${selector.instanceId}` : "Loki is not enabled or has no URL",
683
+ filters: {
684
+ deviceId: true,
685
+ addonId: true,
686
+ nodeId: true,
687
+ tags: true,
688
+ level: true,
689
+ text: true,
690
+ timeRange: true
691
+ },
692
+ retentionDays: null
693
+ };
694
+ }
695
+ async read(query) {
696
+ const member = await this.readable(query);
697
+ if (member === null) throw new Error("Loki is not enabled or has no URL");
698
+ return member.read(query);
699
+ }
700
+ async cancelRead(input) {
701
+ for (const member of this.members.values()) if ((await member.cancelRead(input)).cancelled) return { cancelled: true };
702
+ return { cancelled: false };
703
+ }
704
+ async shutdown() {
705
+ const all = [...this.members.values()];
706
+ this.members.clear();
707
+ await Promise.all(all.map((m) => m.shutdown()));
708
+ }
709
+ };
710
+ //#endregion
607
711
  //#region src/builtins/loki-logging/loki-record-kinds.ts
608
712
  /**
609
713
  * The Loki connection as a record (D985): one `destinations` row per Loki instance, owned by
@@ -944,12 +1048,12 @@ var READY_PATH = "/ready";
944
1048
  var LokiLoggingAddon = class extends BaseAddon {
945
1049
  destination = null;
946
1050
  instances = null;
947
- current = null;
948
1051
  refreshTimer = null;
949
1052
  retirementTimer = null;
950
1053
  shuttingDown = false;
951
1054
  declared = false;
952
- secretsWarned = false;
1055
+ /** Instances whose keychain lock was already warned about — once per lock, per instance. */
1056
+ secretsWarned = /* @__PURE__ */ new Set();
953
1057
  constructor() {
954
1058
  super({});
955
1059
  }
@@ -957,7 +1061,7 @@ var LokiLoggingAddon = class extends BaseAddon {
957
1061
  return (this.ctx.kernel.localNodeId ?? "hub") === "hub";
958
1062
  }
959
1063
  async onInitialize() {
960
- this.destination = new LokiDestination();
1064
+ this.destination = new LokiDestinationSet();
961
1065
  this.shuttingDown = false;
962
1066
  const registrations = [{
963
1067
  capability: logDestinationCapability,
@@ -970,7 +1074,7 @@ var LokiLoggingAddon = class extends BaseAddon {
970
1074
  else await this.ensureDeclaredQuietly();
971
1075
  this.instances = new RecordIntegrationInstances(records, lokiDestinationsKind, {
972
1076
  description: {
973
- instanceMode: "single",
1077
+ instanceMode: "multiple",
974
1078
  kind: "destination",
975
1079
  canTest: true
976
1080
  },
@@ -997,9 +1101,9 @@ var LokiLoggingAddon = class extends BaseAddon {
997
1101
  }
998
1102
  await this.refreshFromRecord();
999
1103
  }
1000
- await this.destination.initialize(this.destinationConfig());
1001
- const url = this.current?.url ?? "";
1002
- this.ctx.logger.info(url.length > 0 ? `Loki logging initialized → ${url}` : "Loki logging registered but inactive (no URL set)");
1104
+ await this.destination.initialize();
1105
+ const urls = this.destination.getStatuses().filter((status) => status.configured).map((status) => status.instanceId);
1106
+ this.ctx.logger.info(urls.length > 0 ? `Loki logging initialized with ${String(urls.length)} destination(s): ${urls.join(", ")}` : "Loki logging registered but inactive (no destination configured)");
1003
1107
  this.attemptEnabledFlagRetirement(0);
1004
1108
  return registrations;
1005
1109
  }
@@ -1016,27 +1120,37 @@ var LokiLoggingAddon = class extends BaseAddon {
1016
1120
  this.ctx.logger.warn("Loki logging: the connection kind could not be declared yet", { meta: { error: err instanceof Error ? err.message : String(err) } });
1017
1121
  }
1018
1122
  }
1019
- /** Re-read the connection record and apply it to the live destination. */
1123
+ /**
1124
+ * Re-read every connection record and reconcile the live destinations with them: a new record
1125
+ * starts one, an edit reconfigures it, a deleted record closes its client. A record whose
1126
+ * secret cannot be read (locked keychain) keeps the configuration it had (D49) and is skipped
1127
+ * if it never had one; the others are unaffected.
1128
+ */
1020
1129
  async refreshFromRecord() {
1021
1130
  if (this.instances === null || this.shuttingDown) return;
1022
- let first;
1131
+ let resolved;
1023
1132
  try {
1024
1133
  if (!this.declared) await this.ensureDeclared();
1025
- [first] = await this.instances.listResolved();
1134
+ resolved = await this.instances.listResolved();
1026
1135
  } catch (err) {
1027
- this.ctx.logger.warn("Loki logging: the connection record could not be read", { meta: { error: err instanceof Error ? err.message : String(err) } });
1136
+ this.ctx.logger.warn("Loki logging: the connection records could not be read", { meta: { error: err instanceof Error ? err.message : String(err) } });
1028
1137
  return;
1029
1138
  }
1030
- if (first?.secrets === "unavailable") {
1031
- if (!this.secretsWarned) {
1032
- this.secretsWarned = true;
1033
- this.ctx.logger.warn("Loki logging: the keychain is locked; the destination keeps its previous configuration");
1139
+ const configs = /* @__PURE__ */ new Map();
1140
+ const keep = /* @__PURE__ */ new Set();
1141
+ for (const instance of resolved) {
1142
+ if (instance.secrets === "unavailable") {
1143
+ keep.add(instance.id);
1144
+ if (!this.secretsWarned.has(instance.id)) {
1145
+ this.secretsWarned.add(instance.id);
1146
+ this.ctx.logger.warn(`Loki logging: the keychain is locked; destination ${instance.id} keeps its previous configuration`);
1147
+ }
1148
+ continue;
1034
1149
  }
1035
- return;
1150
+ this.secretsWarned.delete(instance.id);
1151
+ configs.set(instance.id, this.destinationConfig(instance.body));
1036
1152
  }
1037
- this.secretsWarned = false;
1038
- this.current = first?.body ?? null;
1039
- await this.destination?.reconfigure(this.destinationConfig());
1153
+ await this.destination?.apply(configs, keep);
1040
1154
  }
1041
1155
  /**
1042
1156
  * The catalogue to offer while initialising. Seq 3 cannot decide before registration, so it is
@@ -1263,11 +1377,7 @@ var LokiLoggingAddon = class extends BaseAddon {
1263
1377
  * different signature is a type error — usefully, since silently overriding it
1264
1378
  * would have broken this addon's settings reload.
1265
1379
  */
1266
- destinationConfig() {
1267
- const body = this.current ?? {
1268
- ...LOKI_DEFAULT_BODY,
1269
- name: ""
1270
- };
1380
+ destinationConfig(body) {
1271
1381
  return {
1272
1382
  enabled: body.enabled !== false,
1273
1383
  url: body.url,
@@ -0,0 +1,47 @@
1
+ /**
2
+ * The Loki destinations of one node: one `LokiDestination` per `destinations` record (planning#408).
3
+ *
4
+ * `write` fans out to every one of them; each keeps its own queue, flush timer, counters and
5
+ * client, so one unreachable Loki never delays another. `read` / `describeRead` take an optional
6
+ * `instanceId`; without it the first READABLE instance answers (ordered by record id, so the
7
+ * answer is stable). The set never logs: it is registered as a log destination, and a line it
8
+ * wrote would feed itself. The addon logs around it.
9
+ */
10
+ import type { ILogDestination, LogEntry, LogReadCapabilities, LogReadQuery, LogReadResult } from "@camstack/types";
11
+ import { type LokiConfig, type LokiDestinationDeps, type LokiStatus } from "./loki-destination.js";
12
+ export interface LokiInstanceStatus extends LokiStatus {
13
+ readonly instanceId: string;
14
+ }
15
+ /** What a read or a capability probe may name. */
16
+ export interface LokiInstanceSelector {
17
+ readonly instanceId?: string | undefined;
18
+ }
19
+ export declare class LokiDestinationSet implements ILogDestination {
20
+ private readonly deps?;
21
+ private readonly members;
22
+ constructor(deps?: LokiDestinationDeps);
23
+ initialize(): Promise<void>;
24
+ /** The ids this set currently holds, in record-id order. */
25
+ ids(): readonly string[];
26
+ /**
27
+ * Reconcile the set with `configs` (record id to config): add the new, reconfigure the
28
+ * existing, close the ones no longer there. An id in `keep` is left exactly as it is —
29
+ * its config could not be read this time (a locked keychain), so the previous one stands.
30
+ */
31
+ apply(configs: ReadonlyMap<string, LokiConfig>, keep?: ReadonlySet<string>): Promise<void>;
32
+ write(entry: LogEntry): void;
33
+ flush(): Promise<void>;
34
+ /** The status of one instance; without an id, the first one (an inert status when none). */
35
+ getStatus(instanceId?: string): LokiStatus;
36
+ getStatuses(): readonly LokiInstanceStatus[];
37
+ /** The named instance, or the first one that can be read; null when none can. */
38
+ private readable;
39
+ describeRead(selector?: LokiInstanceSelector): Promise<LogReadCapabilities>;
40
+ read(query: LogReadQuery): Promise<LogReadResult>;
41
+ cancelRead(input: {
42
+ readonly requestId: string;
43
+ }): Promise<{
44
+ readonly cancelled: boolean;
45
+ }>;
46
+ shutdown(): Promise<void>;
47
+ }
@@ -18,7 +18,7 @@
18
18
  */
19
19
  import type { ProviderRegistration } from "@camstack/types";
20
20
  import { BaseAddon } from "@camstack/types";
21
- import { LokiDestination } from "./loki-destination.js";
21
+ import { LokiDestinationSet } from "./loki-destination-set.js";
22
22
  /**
23
23
  * The addon keeps NO connection setting of its own (D985): the connection is a `destinations`
24
24
  * record. What remains in the settings store is the D777 retirement marker only.
@@ -29,18 +29,23 @@ export declare function stripUserinfo(message: string, typedUrl: string): string
29
29
  export declare class LokiLoggingAddon extends BaseAddon<LokiAddonConfig> {
30
30
  private destination;
31
31
  private instances;
32
- private current;
33
32
  private refreshTimer;
34
33
  private retirementTimer;
35
34
  private shuttingDown;
36
35
  private declared;
37
- private secretsWarned;
36
+ /** Instances whose keychain lock was already warned about — once per lock, per instance. */
37
+ private readonly secretsWarned;
38
38
  constructor();
39
39
  private isHub;
40
40
  protected onInitialize(): Promise<ProviderRegistration[]>;
41
41
  private ensureDeclared;
42
42
  private ensureDeclaredQuietly;
43
- /** Re-read the connection record and apply it to the live destination. */
43
+ /**
44
+ * Re-read every connection record and reconcile the live destinations with them: a new record
45
+ * starts one, an edit reconfigures it, a deleted record closes its client. A record whose
46
+ * secret cannot be read (locked keychain) keeps the configuration it had (D49) and is skipped
47
+ * if it never had one; the others are unaffected.
48
+ */
44
49
  private refreshFromRecord;
45
50
  /**
46
51
  * The catalogue to offer while initialising. Seq 3 cannot decide before registration, so it is
@@ -84,7 +89,7 @@ export declare class LokiLoggingAddon extends BaseAddon<LokiAddonConfig> {
84
89
  * would have broken this addon's settings reload.
85
90
  */
86
91
  private destinationConfig;
87
- getDestination(): LokiDestination;
92
+ getDestination(): LokiDestinationSet;
88
93
  private connectionForm;
89
94
  }
90
95
  export {};
@@ -3,7 +3,7 @@ Object.defineProperties(exports, {
3
3
  [Symbol.toStringTag]: { value: "Module" }
4
4
  });
5
5
  const require_chunk = require("../../chunk-Cek0wNdY.js");
6
- const require_dist = require("../../dist-DFWnAzAY.js");
6
+ const require_dist = require("../../dist-LlcIu2lh.js");
7
7
  let node_fs_promises = require("node:fs/promises");
8
8
  let node_util = require("node:util");
9
9
  let node_os = require("node:os");
@@ -1,4 +1,4 @@
1
- import { It as ROOT_BUCKET_KEY, Tr as foldSnapshotByFunction, Vi as reducePoints, dc as EventCategory, fi as metricsProviderCapability, ms as createEvent, nn as UNATTRIBUTED_BUCKET_KEY, qi as resolveBucketMs, uc as errMsg, wo as BaseAddon } from "../../dist-C5eIFTMo.mjs";
1
+ import { It as ROOT_BUCKET_KEY, Tr as foldSnapshotByFunction, Vi as reducePoints, dc as EventCategory, fi as metricsProviderCapability, ms as createEvent, nn as UNATTRIBUTED_BUCKET_KEY, qi as resolveBucketMs, uc as errMsg, wo as BaseAddon } from "../../dist-Cn8xk9RA.mjs";
2
2
  import { access, readFile, readdir } from "node:fs/promises";
3
3
  import { promisify } from "node:util";
4
4
  import * as os$1 from "node:os";
@@ -3,7 +3,7 @@ Object.defineProperties(exports, {
3
3
  [Symbol.toStringTag]: { value: "Module" }
4
4
  });
5
5
  const require_chunk = require("../../chunk-Cek0wNdY.js");
6
- const require_dist = require("../../dist-DFWnAzAY.js");
6
+ const require_dist = require("../../dist-LlcIu2lh.js");
7
7
  const require_coral_accelerators = require("../../coral-accelerators-BSVsBVzt.js");
8
8
  let node_path = require("node:path");
9
9
  node_path = require_chunk.__toESM(node_path);
@@ -1,5 +1,5 @@
1
1
  import { o as __toESM, r as __exportAll } from "../../chunk-CNf5ZN-e.mjs";
2
- import { Ei as parseAcceleratorFactsJson, dc as EventCategory, dr as enumerateInferenceDevices, ji as platformProbeCapability, la as scoreRuntimes, uc as errMsg, wo as BaseAddon, xs as emitReadiness } from "../../dist-C5eIFTMo.mjs";
2
+ import { Ei as parseAcceleratorFactsJson, dc as EventCategory, dr as enumerateInferenceDevices, ji as platformProbeCapability, la as scoreRuntimes, uc as errMsg, wo as BaseAddon, xs as emitReadiness } from "../../dist-Cn8xk9RA.mjs";
3
3
  import { n as detectCoralAccelerator, r as nodeCoralFs } from "../../coral-accelerators-DBlgWB8k.mjs";
4
4
  import * as path$1 from "node:path";
5
5
  import { promisify } from "node:util";
@@ -3,7 +3,7 @@ Object.defineProperties(exports, {
3
3
  [Symbol.toStringTag]: { value: "Module" }
4
4
  });
5
5
  require("../../chunk-Cek0wNdY.js");
6
- const require_dist = require("../../dist-DFWnAzAY.js");
6
+ const require_dist = require("../../dist-LlcIu2lh.js");
7
7
  let zod = require("zod");
8
8
  let node_crypto = require("node:crypto");
9
9
  //#region src/builtins/record-entries/entries-service.ts
@@ -1,4 +1,4 @@
1
- import { Po as InvalidRecordError, ec as secretViewsOf, ns as UnknownRecordKindError, wo as BaseAddon, zi as recordEntriesCapability } from "../../dist-C5eIFTMo.mjs";
1
+ import { Po as InvalidRecordError, ec as secretViewsOf, ns as UnknownRecordKindError, wo as BaseAddon, zi as recordEntriesCapability } from "../../dist-Cn8xk9RA.mjs";
2
2
  import { z } from "zod";
3
3
  import { randomUUID } from "node:crypto";
4
4
  //#region src/builtins/record-entries/entries-service.ts
@@ -3,7 +3,7 @@ Object.defineProperties(exports, {
3
3
  [Symbol.toStringTag]: { value: "Module" }
4
4
  });
5
5
  require("../../chunk-Cek0wNdY.js");
6
- const require_dist = require("../../dist-DFWnAzAY.js");
6
+ const require_dist = require("../../dist-LlcIu2lh.js");
7
7
  //#region src/builtins/remote-access-orchestrator/enabled-providers-reconcile.ts
8
8
  /**
9
9
  * Reconcile the durable `enabledProviders` set against authoritative
@@ -1,4 +1,4 @@
1
- import { dc as EventCategory, wo as BaseAddon } from "../../dist-C5eIFTMo.mjs";
1
+ import { dc as EventCategory, wo as BaseAddon } from "../../dist-Cn8xk9RA.mjs";
2
2
  //#region src/builtins/remote-access-orchestrator/enabled-providers-reconcile.ts
3
3
  /**
4
4
  * Reconcile the durable `enabledProviders` set against authoritative
@@ -3,7 +3,7 @@ Object.defineProperties(exports, {
3
3
  [Symbol.toStringTag]: { value: "Module" }
4
4
  });
5
5
  const require_chunk = require("../../chunk-Cek0wNdY.js");
6
- const require_dist = require("../../dist-DFWnAzAY.js");
6
+ const require_dist = require("../../dist-LlcIu2lh.js");
7
7
  const require_snapshot_courtesy = require("../../snapshot-courtesy-D_C5-nC0.js");
8
8
  let zod = require("zod");
9
9
  let node_crypto = require("node:crypto");
@@ -1,4 +1,4 @@
1
- import { Ta as streamQualityLabel, Vs as nodePin, _a as snapshotCapability, dc as EventCategory, h as BatteryStatusSchema, lc as DeviceType, sc as DeviceFeature, tr as deriveBatteryPresence, uc as errMsg, ui as memoizePinnedFfmpeg, vn as bareAddonId, wo as BaseAddon, yn as batteryCapability } from "../../dist-C5eIFTMo.mjs";
1
+ import { Ta as streamQualityLabel, Vs as nodePin, _a as snapshotCapability, dc as EventCategory, h as BatteryStatusSchema, lc as DeviceType, sc as DeviceFeature, tr as deriveBatteryPresence, uc as errMsg, ui as memoizePinnedFfmpeg, vn as bareAddonId, wo as BaseAddon, yn as batteryCapability } from "../../dist-Cn8xk9RA.mjs";
2
2
  import { i as renderCourtesyOverlayJpeg, n as courtesyCacheKey, r as renderCourtesyJpeg } from "../../snapshot-courtesy-CyFs1M3I.mjs";
3
3
  import { z } from "zod";
4
4
  import { randomUUID } from "node:crypto";
@@ -3,7 +3,7 @@ Object.defineProperties(exports, {
3
3
  [Symbol.toStringTag]: { value: "Module" }
4
4
  });
5
5
  const require_chunk = require("../../chunk-Cek0wNdY.js");
6
- const require_dist = require("../../dist-DFWnAzAY.js");
6
+ const require_dist = require("../../dist-LlcIu2lh.js");
7
7
  let node_crypto = require("node:crypto");
8
8
  let node_fs_promises = require("node:fs/promises");
9
9
  let node_path = require("node:path");
@@ -1,4 +1,4 @@
1
- import { Ca as storageProviderCapability, wo as BaseAddon, wr as filesystemBrowseCapability } from "../../dist-C5eIFTMo.mjs";
1
+ import { Ca as storageProviderCapability, wo as BaseAddon, wr as filesystemBrowseCapability } from "../../dist-Cn8xk9RA.mjs";
2
2
  import { randomUUID } from "node:crypto";
3
3
  import { mkdir, readdir, realpath, statfs } from "node:fs/promises";
4
4
  import * as path$1 from "node:path";
@@ -4,7 +4,7 @@ Object.defineProperties(exports, {
4
4
  });
5
5
  require("../../chunk-Cek0wNdY.js");
6
6
  const require_builtins_sqlite_storage_filesystem_storage_addon = require("./filesystem-storage.addon.js");
7
- const require_wal_maintenance = require("../../wal-maintenance-D0zSmIwJ.js");
7
+ const require_wal_maintenance = require("../../wal-maintenance-Jjwq3CZm.js");
8
8
  const require_builtins_sqlite_storage_sqlite_settings_addon = require("./sqlite-settings.addon.js");
9
9
  //#region src/builtins/sqlite-storage/config-store.ts
10
10
  var ConfigStore = class {