@camstack/server 1.2.739 → 1.2.741

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 (92) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/api/trpc/generated-cap-routers.js +9 -0
  3. package/package.json +14 -12
  4. package/system/dist/addon-utils.mjs +1 -1
  5. package/system/dist/{agent-https-Dwec4v5Z.mjs → agent-https-BtTMjLgk.mjs} +1 -1
  6. package/system/dist/{agent-https-DX_ypzVA.js → agent-https-CNf7_i1z.js} +1 -1
  7. package/system/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.js +1 -1
  8. package/system/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.mjs +4 -4
  9. package/system/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.js +1 -1
  10. package/system/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.mjs +5 -5
  11. package/system/dist/builtins/alerts/alerts.addon.js +1 -1
  12. package/system/dist/builtins/alerts/alerts.addon.mjs +1 -1
  13. package/system/dist/builtins/autotrack/index.js +1 -1
  14. package/system/dist/builtins/autotrack/index.mjs +1 -1
  15. package/system/dist/builtins/backup-orchestrator/backup-orchestrator.addon.js +2 -2
  16. package/system/dist/builtins/backup-orchestrator/backup-orchestrator.addon.mjs +5 -5
  17. package/system/dist/builtins/calendars/calendars.addon.js +1 -1
  18. package/system/dist/builtins/calendars/calendars.addon.mjs +1 -1
  19. package/system/dist/builtins/camera-grid/index.js +1 -1
  20. package/system/dist/builtins/camera-grid/index.mjs +1 -1
  21. package/system/dist/builtins/composer/composer.addon.js +3 -3
  22. package/system/dist/builtins/composer/composer.addon.mjs +3 -3
  23. package/system/dist/builtins/console-logging/index.js +1 -1
  24. package/system/dist/builtins/console-logging/index.mjs +1 -1
  25. package/system/dist/builtins/core-blocks/core-blocks.addon.js +2 -2
  26. package/system/dist/builtins/core-blocks/core-blocks.addon.mjs +2 -2
  27. package/system/dist/builtins/device-history/device-history.addon.js +2 -2
  28. package/system/dist/builtins/device-history/device-history.addon.mjs +2 -2
  29. package/system/dist/builtins/device-manager/device-manager.addon.js +1 -1
  30. package/system/dist/builtins/device-manager/device-manager.addon.mjs +1 -1
  31. package/system/dist/builtins/hub-forwarder/index.js +1 -1
  32. package/system/dist/builtins/hub-forwarder/index.mjs +1 -1
  33. package/system/dist/builtins/keychain/index.js +3 -3
  34. package/system/dist/builtins/keychain/index.mjs +3 -3
  35. package/system/dist/builtins/liveness-monitor/liveness-monitor.addon.js +1 -1
  36. package/system/dist/builtins/liveness-monitor/liveness-monitor.addon.mjs +1 -1
  37. package/system/dist/builtins/local-auth/local-auth.addon.js +2 -2
  38. package/system/dist/builtins/local-auth/local-auth.addon.mjs +5 -5
  39. package/system/dist/builtins/local-network/local-network.addon.js +2 -2
  40. package/system/dist/builtins/local-network/local-network.addon.mjs +2 -2
  41. package/system/dist/builtins/loki-logging/index.js +127 -32
  42. package/system/dist/builtins/loki-logging/index.mjs +127 -32
  43. package/system/dist/builtins/loki-logging/loki-logging.addon.d.ts +8 -0
  44. package/system/dist/builtins/loki-logging/loki-record-kinds.d.ts +2 -0
  45. package/system/dist/builtins/loki-logging/migrations/index.d.ts +4 -1
  46. package/system/dist/builtins/loki-logging/migrations/registry-toggle-to-record.d.ts +26 -0
  47. package/system/dist/builtins/native-metrics/native-metrics.addon.js +1 -1
  48. package/system/dist/builtins/native-metrics/native-metrics.addon.mjs +10 -10
  49. package/system/dist/builtins/platform-probe/index.js +1 -1
  50. package/system/dist/builtins/platform-probe/index.mjs +10 -10
  51. package/system/dist/builtins/record-entries/index.js +1 -1
  52. package/system/dist/builtins/record-entries/index.mjs +1 -1
  53. package/system/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.js +1 -1
  54. package/system/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.mjs +1 -1
  55. package/system/dist/builtins/snapshot/index.js +3 -3
  56. package/system/dist/builtins/snapshot/index.mjs +3 -3
  57. package/system/dist/builtins/sqlite-storage/filesystem-storage.addon.js +1 -1
  58. package/system/dist/builtins/sqlite-storage/filesystem-storage.addon.mjs +20 -20
  59. package/system/dist/builtins/sqlite-storage/index.js +1 -1
  60. package/system/dist/builtins/sqlite-storage/index.mjs +1 -1
  61. package/system/dist/builtins/sqlite-storage/migrations/installed-runner-resolver.d.ts +3 -0
  62. package/system/dist/builtins/sqlite-storage/sqlite-settings.addon.js +59 -3
  63. package/system/dist/builtins/sqlite-storage/sqlite-settings.addon.mjs +60 -4
  64. package/system/dist/builtins/storage-orchestrator/storage-orchestrator.addon.js +1 -1
  65. package/system/dist/builtins/storage-orchestrator/storage-orchestrator.addon.mjs +1 -1
  66. package/system/dist/builtins/system-config/system-config.addon.js +3 -3
  67. package/system/dist/builtins/system-config/system-config.addon.mjs +285 -285
  68. package/system/dist/builtins/winston-logging/index.js +1 -1
  69. package/system/dist/builtins/winston-logging/index.mjs +1 -1
  70. package/system/dist/{composition-sources-jF-eMoO5.js → composition-sources-D9GBwT5d.js} +1 -1
  71. package/system/dist/{composition-sources-6UWb8sIp.mjs → composition-sources-DUmnnLrw.mjs} +1 -1
  72. package/system/dist/{constants-v7B-_yzi.mjs → constants-BkiDA8Cf.mjs} +1 -1
  73. package/system/dist/{constants-dJ_YPC9D.js → constants-Cy5svHxz.js} +1 -1
  74. package/system/dist/{coral-accelerators-DBlgWB8k.mjs → coral-accelerators-BW3OcrLD.mjs} +6 -6
  75. package/system/dist/{custom-action-registry-oHl1xltx.mjs → custom-action-registry-BIJZBObd.mjs} +37 -37
  76. package/system/dist/{device-ca-CImkiiR-.js → device-ca-CxlqxrvG.js} +1 -1
  77. package/system/dist/{device-ca-BVaCxlFs.mjs → device-ca-Cxu7j6aY.mjs} +1 -1
  78. package/system/dist/{dist-BvHqoBym.mjs → dist-C5sQPOZX.mjs} +136 -11
  79. package/system/dist/{dist-BXWXN1Dl.js → dist-Cyc4oyGh.js} +141 -10
  80. package/system/dist/file-host-worker.js +1 -1
  81. package/system/dist/file-host-worker.mjs +1 -1
  82. package/system/dist/{hub-mdns-ciao-B_ldgRYZ.mjs → hub-mdns-ciao-CTPWSgwo.mjs} +2 -2
  83. package/system/dist/{hub-mdns-ciao-B7wwnU92.js → hub-mdns-ciao-YxQ97aHW.js} +2 -2
  84. package/system/dist/index.js +7 -7
  85. package/system/dist/index.mjs +218 -218
  86. package/system/dist/{restore-archive-CLfRtdYG.mjs → restore-archive-08Uthry1.mjs} +150 -150
  87. package/system/dist/{restore-archive-ne_KESE9.js → restore-archive-b5rBXY1e.js} +1 -1
  88. package/system/dist/{retention--waznpBD.js → retention-DWCHp91p.js} +1 -1
  89. package/system/dist/{retention-MD1lPsHB.mjs → retention-i8aZ6vE5.mjs} +1 -1
  90. package/system/dist/{wal-maintenance-D8DIMgjl.mjs → wal-maintenance-CEi8PqMh.mjs} +0 -0
  91. package/system/dist/{wal-maintenance-DmhOVavh.js → wal-maintenance-DNE7RTcS.js} +0 -0
  92. 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-BXWXN1Dl.js");
6
+ const require_dist = require("../../dist-Cyc4oyGh.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
@@ -649,7 +649,8 @@ var LokiDestinationBodySchema = zod.z.object({
649
649
  password: zod.z.string().optional().meta({ secret: true }),
650
650
  batchIntervalMs: zod.z.number().int().min(LOKI_BOUNDS.batchIntervalMs.min).max(LOKI_BOUNDS.batchIntervalMs.max),
651
651
  batchSize: zod.z.number().int().min(LOKI_BOUNDS.batchSize.min).max(LOKI_BOUNDS.batchSize.max),
652
- timeoutMs: zod.z.number().int().min(LOKI_BOUNDS.timeoutMs.min).max(LOKI_BOUNDS.timeoutMs.max)
652
+ timeoutMs: zod.z.number().int().min(LOKI_BOUNDS.timeoutMs.min).max(LOKI_BOUNDS.timeoutMs.max),
653
+ enabled: zod.z.boolean().optional()
653
654
  });
654
655
  var lokiDestinationsKind = require_dist.defineEntryKind("destinations", {
655
656
  title: "Loki destinations",
@@ -801,40 +802,83 @@ async function confirmRecordHoldsLegacy(ports, stored) {
801
802
  if (legacyPassword && !record.hasPassword) return refuse("the record holds no password");
802
803
  }
803
804
  //#endregion
805
+ //#region src/builtins/loki-logging/migrations/registry-toggle-to-record.ts
806
+ async function moveRegistryToggleToRecord(ports) {
807
+ const state = await ports.readRegistryState();
808
+ if (state === "active") return {
809
+ outcome: "already-done",
810
+ summary: { carried: false }
811
+ };
812
+ if (state === "unregistered") throw new Error("the log-destination provider is not registered yet");
813
+ const record = await ports.findToggleRecord();
814
+ if (record === null) return {
815
+ outcome: "already-done",
816
+ summary: { carried: false }
817
+ };
818
+ if (record.enabled) await ports.disableRecord(record.id);
819
+ await ports.enableRegistry();
820
+ return {
821
+ outcome: "done",
822
+ summary: {
823
+ carried: true,
824
+ integrationId: record.id
825
+ }
826
+ };
827
+ }
828
+ //#endregion
804
829
  //#region src/builtins/loki-logging/migrations/index.ts
805
830
  var CONNECTION_TO_RECORDS_ID = "loki-logging/2026-11-02-connection-to-records";
806
831
  /** The `loki-logging` catalogue (D987): offered to the engine when the hub-resident addon initialises. */
807
- var ADDON_MIGRATIONS = [{
808
- meta: {
809
- id: CONNECTION_TO_RECORDS_ID,
810
- owner: "loki-logging",
811
- level: "addon-state",
812
- seq: 1,
813
- dependsOn: [],
814
- store: "settings",
815
- scope: "cluster",
816
- onFailure: "block-owner",
817
- bodyKind: "procedure",
818
- description: "Move the Loki connection (url, credentials, labels, batching) from the addon settings into a destinations record under an integrations row",
819
- fixtureMark: "the D777 retirement marker the migration does not know"
832
+ var ADDON_MIGRATIONS = [
833
+ {
834
+ meta: {
835
+ id: CONNECTION_TO_RECORDS_ID,
836
+ owner: "loki-logging",
837
+ level: "addon-state",
838
+ seq: 1,
839
+ dependsOn: [],
840
+ store: "settings",
841
+ scope: "cluster",
842
+ onFailure: "block-owner",
843
+ bodyKind: "procedure",
844
+ description: "Move the Loki connection (url, credentials, labels, batching) from the addon settings into a destinations record under an integrations row",
845
+ fixtureMark: "the D777 retirement marker the migration does not know"
846
+ },
847
+ procedure: moveConnectionToRecord
820
848
  },
821
- procedure: moveConnectionToRecord
822
- }, {
823
- meta: {
824
- id: "loki-logging/2026-11-02-drop-moved-settings",
825
- owner: "loki-logging",
826
- level: "addon-state",
827
- seq: 2,
828
- dependsOn: [CONNECTION_TO_RECORDS_ID],
829
- store: "settings",
830
- scope: "cluster",
831
- onFailure: "block-owner",
832
- bodyKind: "plan",
833
- description: "Delete the connection keys that moved into the destinations record",
834
- fixtureMark: "the D777 retirement marker the migration does not know"
849
+ {
850
+ meta: {
851
+ id: "loki-logging/2026-11-02-drop-moved-settings",
852
+ owner: "loki-logging",
853
+ level: "addon-state",
854
+ seq: 2,
855
+ dependsOn: [CONNECTION_TO_RECORDS_ID],
856
+ store: "settings",
857
+ scope: "cluster",
858
+ onFailure: "block-owner",
859
+ bodyKind: "plan",
860
+ description: "Delete the connection keys that moved into the destinations record",
861
+ fixtureMark: "the D777 retirement marker the migration does not know"
862
+ },
863
+ plan: planDropMovedSettings
835
864
  },
836
- plan: planDropMovedSettings
837
- }];
865
+ {
866
+ meta: {
867
+ id: "loki-logging/2026-11-02-registry-toggle-to-record",
868
+ owner: "loki-logging",
869
+ level: "addon-state",
870
+ seq: 3,
871
+ dependsOn: [CONNECTION_TO_RECORDS_ID],
872
+ store: "settings",
873
+ scope: "cluster",
874
+ onFailure: "tolerate",
875
+ bodyKind: "procedure",
876
+ description: "Carry a Loki provider switched off at the log-destination registry toggle to a destinations record that is off, and turn the registry toggle back on",
877
+ fixtureMark: "a destinations record field the migration does not know (the job)"
878
+ },
879
+ procedure: moveRegistryToggleToRecord
880
+ }
881
+ ];
838
882
  //#endregion
839
883
  //#region src/builtins/loki-logging/retire-enabled-flag.ts
840
884
  /** The retired settings key. */
@@ -1048,6 +1092,28 @@ var LokiLoggingAddon = class extends require_dist.BaseAddon {
1048
1092
  }
1049
1093
  return "created";
1050
1094
  },
1095
+ readRegistryState: async () => {
1096
+ const own = (await this.ctx.api.addons.listCapabilityProviders.query({ capName: require_dist.logDestinationCapability.name })).find((p) => p.addonId === this.ctx.id);
1097
+ if (own === void 0) return "unregistered";
1098
+ return own.isActive ? "active" : "inactive";
1099
+ },
1100
+ findToggleRecord: async () => {
1101
+ const [first] = await instances.listResolved();
1102
+ return first === void 0 ? null : {
1103
+ id: first.id,
1104
+ enabled: first.enabled
1105
+ };
1106
+ },
1107
+ disableRecord: async (id) => {
1108
+ await handle.patch(id, { enabled: false });
1109
+ },
1110
+ enableRegistry: async () => {
1111
+ await this.ctx.api.addons.setCapabilityProviderEnabled.mutate({
1112
+ capName: require_dist.logDestinationCapability.name,
1113
+ addonId: this.ctx.id,
1114
+ enabled: true
1115
+ });
1116
+ },
1051
1117
  clearOldPassword: async () => {
1052
1118
  await this.clearSecrets(["password"]);
1053
1119
  }
@@ -1104,6 +1170,13 @@ var LokiLoggingAddon = class extends require_dist.BaseAddon {
1104
1170
  outcome = await retireEnabledFlag({
1105
1171
  readStoredKey: (key) => this.readStoredGlobalKey(key),
1106
1172
  disableAtCapability: async () => {
1173
+ const instances = this.instances;
1174
+ const [first] = instances === null ? [] : await instances.listResolved();
1175
+ if (first !== void 0 && this.ctx.records !== void 0) {
1176
+ await this.ctx.records.kind(lokiDestinationsKind).patch(first.id, { enabled: false });
1177
+ await this.refreshFromRecord();
1178
+ return;
1179
+ }
1107
1180
  await this.ctx.api.addons.setCapabilityProviderEnabled.mutate({
1108
1181
  capName: require_dist.logDestinationCapability.name,
1109
1182
  addonId: this.ctx.id,
@@ -1142,6 +1215,28 @@ var LokiLoggingAddon = class extends require_dist.BaseAddon {
1142
1215
  }, delay);
1143
1216
  this.retirementTimer.unref?.();
1144
1217
  }
1218
+ /**
1219
+ * Registration is done: the hub calls this after the providers are registered, so
1220
+ * `listCapabilityProviders` now sees Loki. The registry-toggle migration cannot decide before
1221
+ * that (the pass inside `onInitialize` fails, tolerated), so it runs ONCE here, hub-only. A
1222
+ * failure is logged and writes nothing; the `tolerate` ledger row keeps it for the next boot.
1223
+ */
1224
+ postBrokerStart() {
1225
+ super.postBrokerStart();
1226
+ if (!this.isHub() || this.instances === null || this.shuttingDown) return;
1227
+ this.runRegistryToggleMigration();
1228
+ }
1229
+ async runRegistryToggleMigration() {
1230
+ try {
1231
+ if ((await this.runMigrations(require_dist.defineAddonMigrations(ADDON_MIGRATIONS, this.migrationPorts()))).failed.includes("loki-logging/2026-11-02-registry-toggle-to-record")) {
1232
+ this.ctx.logger.warn("Loki logging: the registry-toggle migration is kept for next boot");
1233
+ return;
1234
+ }
1235
+ await this.refreshFromRecord();
1236
+ } catch (err) {
1237
+ this.ctx.logger.warn("Loki logging: the registry-toggle migration could not run", { meta: { error: err instanceof Error ? err.message : String(err) } });
1238
+ }
1239
+ }
1145
1240
  async onShutdown() {
1146
1241
  this.shuttingDown = true;
1147
1242
  if (this.retirementTimer !== null) clearTimeout(this.retirementTimer);
@@ -1178,7 +1273,7 @@ var LokiLoggingAddon = class extends require_dist.BaseAddon {
1178
1273
  name: ""
1179
1274
  };
1180
1275
  return {
1181
- enabled: true,
1276
+ enabled: body.enabled !== false,
1182
1277
  url: body.url,
1183
1278
  job: body.job,
1184
1279
  node: this.ctx.kernel.localNodeId ?? "hub",
@@ -1,4 +1,4 @@
1
- import { Bo as RevConflictError, Cs as isSecretFieldView, Dr as integrationInstancesCapability, Oi as preconditionOf, Pt as RecordIntegrationInstances, Qr as logDestinationCapability, as as defineAddonMigrations, po as BaseAddon, ss as defineEntryKind, ws as isSecretMarker } from "../../dist-BvHqoBym.mjs";
1
+ import { Dr as integrationInstancesCapability, Oi as preconditionOf, Pt as RecordIntegrationInstances, Qr as logDestinationCapability, Ts as isSecretMarker, Vo as RevConflictError, cs as defineEntryKind, mo as BaseAddon, os as defineAddonMigrations, ws as isSecretFieldView } from "../../dist-C5sQPOZX.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
@@ -646,7 +646,8 @@ var lokiDestinationsKind = defineEntryKind("destinations", {
646
646
  password: z.string().optional().meta({ secret: true }),
647
647
  batchIntervalMs: z.number().int().min(LOKI_BOUNDS.batchIntervalMs.min).max(LOKI_BOUNDS.batchIntervalMs.max),
648
648
  batchSize: z.number().int().min(LOKI_BOUNDS.batchSize.min).max(LOKI_BOUNDS.batchSize.max),
649
- timeoutMs: z.number().int().min(LOKI_BOUNDS.timeoutMs.min).max(LOKI_BOUNDS.timeoutMs.max)
649
+ timeoutMs: z.number().int().min(LOKI_BOUNDS.timeoutMs.min).max(LOKI_BOUNDS.timeoutMs.max),
650
+ enabled: z.boolean().optional()
650
651
  })
651
652
  });
652
653
  var LOKI_DEFAULT_BODY = {
@@ -794,40 +795,83 @@ async function confirmRecordHoldsLegacy(ports, stored) {
794
795
  if (legacyPassword && !record.hasPassword) return refuse("the record holds no password");
795
796
  }
796
797
  //#endregion
798
+ //#region src/builtins/loki-logging/migrations/registry-toggle-to-record.ts
799
+ async function moveRegistryToggleToRecord(ports) {
800
+ const state = await ports.readRegistryState();
801
+ if (state === "active") return {
802
+ outcome: "already-done",
803
+ summary: { carried: false }
804
+ };
805
+ if (state === "unregistered") throw new Error("the log-destination provider is not registered yet");
806
+ const record = await ports.findToggleRecord();
807
+ if (record === null) return {
808
+ outcome: "already-done",
809
+ summary: { carried: false }
810
+ };
811
+ if (record.enabled) await ports.disableRecord(record.id);
812
+ await ports.enableRegistry();
813
+ return {
814
+ outcome: "done",
815
+ summary: {
816
+ carried: true,
817
+ integrationId: record.id
818
+ }
819
+ };
820
+ }
821
+ //#endregion
797
822
  //#region src/builtins/loki-logging/migrations/index.ts
798
823
  var CONNECTION_TO_RECORDS_ID = "loki-logging/2026-11-02-connection-to-records";
799
824
  /** The `loki-logging` catalogue (D987): offered to the engine when the hub-resident addon initialises. */
800
- var ADDON_MIGRATIONS = [{
801
- meta: {
802
- id: CONNECTION_TO_RECORDS_ID,
803
- owner: "loki-logging",
804
- level: "addon-state",
805
- seq: 1,
806
- dependsOn: [],
807
- store: "settings",
808
- scope: "cluster",
809
- onFailure: "block-owner",
810
- bodyKind: "procedure",
811
- description: "Move the Loki connection (url, credentials, labels, batching) from the addon settings into a destinations record under an integrations row",
812
- fixtureMark: "the D777 retirement marker the migration does not know"
825
+ var ADDON_MIGRATIONS = [
826
+ {
827
+ meta: {
828
+ id: CONNECTION_TO_RECORDS_ID,
829
+ owner: "loki-logging",
830
+ level: "addon-state",
831
+ seq: 1,
832
+ dependsOn: [],
833
+ store: "settings",
834
+ scope: "cluster",
835
+ onFailure: "block-owner",
836
+ bodyKind: "procedure",
837
+ description: "Move the Loki connection (url, credentials, labels, batching) from the addon settings into a destinations record under an integrations row",
838
+ fixtureMark: "the D777 retirement marker the migration does not know"
839
+ },
840
+ procedure: moveConnectionToRecord
813
841
  },
814
- procedure: moveConnectionToRecord
815
- }, {
816
- meta: {
817
- id: "loki-logging/2026-11-02-drop-moved-settings",
818
- owner: "loki-logging",
819
- level: "addon-state",
820
- seq: 2,
821
- dependsOn: [CONNECTION_TO_RECORDS_ID],
822
- store: "settings",
823
- scope: "cluster",
824
- onFailure: "block-owner",
825
- bodyKind: "plan",
826
- description: "Delete the connection keys that moved into the destinations record",
827
- fixtureMark: "the D777 retirement marker the migration does not know"
842
+ {
843
+ meta: {
844
+ id: "loki-logging/2026-11-02-drop-moved-settings",
845
+ owner: "loki-logging",
846
+ level: "addon-state",
847
+ seq: 2,
848
+ dependsOn: [CONNECTION_TO_RECORDS_ID],
849
+ store: "settings",
850
+ scope: "cluster",
851
+ onFailure: "block-owner",
852
+ bodyKind: "plan",
853
+ description: "Delete the connection keys that moved into the destinations record",
854
+ fixtureMark: "the D777 retirement marker the migration does not know"
855
+ },
856
+ plan: planDropMovedSettings
828
857
  },
829
- plan: planDropMovedSettings
830
- }];
858
+ {
859
+ meta: {
860
+ id: "loki-logging/2026-11-02-registry-toggle-to-record",
861
+ owner: "loki-logging",
862
+ level: "addon-state",
863
+ seq: 3,
864
+ dependsOn: [CONNECTION_TO_RECORDS_ID],
865
+ store: "settings",
866
+ scope: "cluster",
867
+ onFailure: "tolerate",
868
+ bodyKind: "procedure",
869
+ description: "Carry a Loki provider switched off at the log-destination registry toggle to a destinations record that is off, and turn the registry toggle back on",
870
+ fixtureMark: "a destinations record field the migration does not know (the job)"
871
+ },
872
+ procedure: moveRegistryToggleToRecord
873
+ }
874
+ ];
831
875
  //#endregion
832
876
  //#region src/builtins/loki-logging/retire-enabled-flag.ts
833
877
  /** The retired settings key. */
@@ -1041,6 +1085,28 @@ var LokiLoggingAddon = class extends BaseAddon {
1041
1085
  }
1042
1086
  return "created";
1043
1087
  },
1088
+ readRegistryState: async () => {
1089
+ const own = (await this.ctx.api.addons.listCapabilityProviders.query({ capName: logDestinationCapability.name })).find((p) => p.addonId === this.ctx.id);
1090
+ if (own === void 0) return "unregistered";
1091
+ return own.isActive ? "active" : "inactive";
1092
+ },
1093
+ findToggleRecord: async () => {
1094
+ const [first] = await instances.listResolved();
1095
+ return first === void 0 ? null : {
1096
+ id: first.id,
1097
+ enabled: first.enabled
1098
+ };
1099
+ },
1100
+ disableRecord: async (id) => {
1101
+ await handle.patch(id, { enabled: false });
1102
+ },
1103
+ enableRegistry: async () => {
1104
+ await this.ctx.api.addons.setCapabilityProviderEnabled.mutate({
1105
+ capName: logDestinationCapability.name,
1106
+ addonId: this.ctx.id,
1107
+ enabled: true
1108
+ });
1109
+ },
1044
1110
  clearOldPassword: async () => {
1045
1111
  await this.clearSecrets(["password"]);
1046
1112
  }
@@ -1097,6 +1163,13 @@ var LokiLoggingAddon = class extends BaseAddon {
1097
1163
  outcome = await retireEnabledFlag({
1098
1164
  readStoredKey: (key) => this.readStoredGlobalKey(key),
1099
1165
  disableAtCapability: async () => {
1166
+ const instances = this.instances;
1167
+ const [first] = instances === null ? [] : await instances.listResolved();
1168
+ if (first !== void 0 && this.ctx.records !== void 0) {
1169
+ await this.ctx.records.kind(lokiDestinationsKind).patch(first.id, { enabled: false });
1170
+ await this.refreshFromRecord();
1171
+ return;
1172
+ }
1100
1173
  await this.ctx.api.addons.setCapabilityProviderEnabled.mutate({
1101
1174
  capName: logDestinationCapability.name,
1102
1175
  addonId: this.ctx.id,
@@ -1135,6 +1208,28 @@ var LokiLoggingAddon = class extends BaseAddon {
1135
1208
  }, delay);
1136
1209
  this.retirementTimer.unref?.();
1137
1210
  }
1211
+ /**
1212
+ * Registration is done: the hub calls this after the providers are registered, so
1213
+ * `listCapabilityProviders` now sees Loki. The registry-toggle migration cannot decide before
1214
+ * that (the pass inside `onInitialize` fails, tolerated), so it runs ONCE here, hub-only. A
1215
+ * failure is logged and writes nothing; the `tolerate` ledger row keeps it for the next boot.
1216
+ */
1217
+ postBrokerStart() {
1218
+ super.postBrokerStart();
1219
+ if (!this.isHub() || this.instances === null || this.shuttingDown) return;
1220
+ this.runRegistryToggleMigration();
1221
+ }
1222
+ async runRegistryToggleMigration() {
1223
+ try {
1224
+ if ((await this.runMigrations(defineAddonMigrations(ADDON_MIGRATIONS, this.migrationPorts()))).failed.includes("loki-logging/2026-11-02-registry-toggle-to-record")) {
1225
+ this.ctx.logger.warn("Loki logging: the registry-toggle migration is kept for next boot");
1226
+ return;
1227
+ }
1228
+ await this.refreshFromRecord();
1229
+ } catch (err) {
1230
+ this.ctx.logger.warn("Loki logging: the registry-toggle migration could not run", { meta: { error: err instanceof Error ? err.message : String(err) } });
1231
+ }
1232
+ }
1138
1233
  async onShutdown() {
1139
1234
  this.shuttingDown = true;
1140
1235
  if (this.retirementTimer !== null) clearTimeout(this.retirementTimer);
@@ -1171,7 +1266,7 @@ var LokiLoggingAddon = class extends BaseAddon {
1171
1266
  name: ""
1172
1267
  };
1173
1268
  return {
1174
- enabled: true,
1269
+ enabled: body.enabled !== false,
1175
1270
  url: body.url,
1176
1271
  job: body.job,
1177
1272
  node: this.ctx.kernel.localNodeId ?? "hub",
@@ -48,6 +48,14 @@ export declare class LokiLoggingAddon extends BaseAddon<LokiAddonConfig> {
48
48
  private probe;
49
49
  /** One attempt of the D777 carry-over; reschedules itself while deferred. */
50
50
  private attemptEnabledFlagRetirement;
51
+ /**
52
+ * Registration is done: the hub calls this after the providers are registered, so
53
+ * `listCapabilityProviders` now sees Loki. The registry-toggle migration cannot decide before
54
+ * that (the pass inside `onInitialize` fails, tolerated), so it runs ONCE here, hub-only. A
55
+ * failure is logged and writes nothing; the `tolerate` ledger row keeps it for the next boot.
56
+ */
57
+ override postBrokerStart(): void;
58
+ private runRegistryToggleMigration;
51
59
  protected onShutdown(): Promise<void>;
52
60
  /**
53
61
  * React to a settings change (URL, level, batching) without a
@@ -25,6 +25,8 @@ export type LokiDestinationBody = {
25
25
  readonly batchIntervalMs: number;
26
26
  readonly batchSize: number;
27
27
  readonly timeoutMs: number;
28
+ /** The instance's own switch (D996). Absent means on, so no data migration was needed. */
29
+ readonly enabled?: boolean | undefined;
28
30
  };
29
31
  /** The schema is checked against the interface by its annotation: a drifted field fails the typecheck. */
30
32
  export declare const LokiDestinationBodySchema: z.ZodType<LokiDestinationBody>;
@@ -1,8 +1,11 @@
1
1
  import type { AddonMigration } from "@camstack/types";
2
2
  import { type DropMovedSettingsPorts, type LokiMigrationPorts } from "./connection-to-records.js";
3
+ import { type RegistryToggleMigrationPorts } from "./registry-toggle-to-record.js";
4
+ export type { RegistryState, RegistryToggleMigrationPorts } from "./registry-toggle-to-record.js";
3
5
  export type { DropMovedSettingsPorts, LokiMigrationLog, LokiMigrationPorts, LokiRecordState } from "./connection-to-records.js";
4
6
  /** Both bodies read through ONE port object, so the addon binds the catalogue once. */
5
- export type LokiCataloguePorts = LokiMigrationPorts & DropMovedSettingsPorts;
7
+ export type LokiCataloguePorts = LokiMigrationPorts & DropMovedSettingsPorts & RegistryToggleMigrationPorts;
6
8
  export declare const CONNECTION_TO_RECORDS_ID = "loki-logging/2026-11-02-connection-to-records";
9
+ export declare const REGISTRY_TOGGLE_TO_RECORD_ID = "loki-logging/2026-11-02-registry-toggle-to-record";
7
10
  /** The `loki-logging` catalogue (D987): offered to the engine when the hub-resident addon initialises. */
8
11
  export declare const ADDON_MIGRATIONS: readonly AddonMigration<LokiCataloguePorts>[];
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Loki's on/off moves from the `log-destination` registry toggle (D777) to the record's own
3
+ * `enabled` (D996). A provider the registry holds OFF is carried to a record that is off, and the
4
+ * registry toggle is turned back on, so the operator has ONE switch and it is the visible one.
5
+ *
6
+ * Idempotent and crash-safe: the record is written first (a rerun sees it already off and only
7
+ * turns the registry on); a registry that cannot be read writes nothing (D49); a provider that is
8
+ * not registered yet FAILS the migration (tolerated) so the addon retries after registration.
9
+ */
10
+ import type { MigrationProcedureResult } from "@camstack/types";
11
+ /** What the hub's capability registry says about Loki's `log-destination` provider. */
12
+ export type RegistryState = "active" | "inactive" | "unregistered";
13
+ export interface RegistryToggleMigrationPorts {
14
+ /** The registry state of this addon's `log-destination` provider. Throws when it cannot be read. */
15
+ readRegistryState(): Promise<RegistryState>;
16
+ /** The destinations record, or null when there is none. */
17
+ findToggleRecord(): Promise<{
18
+ readonly id: string;
19
+ readonly enabled: boolean;
20
+ } | null>;
21
+ /** Patch the record to `enabled: false`. */
22
+ disableRecord(id: string): Promise<void>;
23
+ /** Turn the registry toggle back on. */
24
+ enableRegistry(): Promise<void>;
25
+ }
26
+ export declare function moveRegistryToggleToRecord(ports: RegistryToggleMigrationPorts): Promise<MigrationProcedureResult>;
@@ -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-BXWXN1Dl.js");
6
+ const require_dist = require("../../dist-Cyc4oyGh.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,9 +1,9 @@
1
- import { $s as errMsg, $t as UNATTRIBUTED_BUCKET_KEY, Bi as resolveBucketMs, Nt as ROOT_BUCKET_KEY, Pi as reducePoints, ec as EventCategory, oi as metricsProviderCapability, po as BaseAddon, rs as createEvent, xr as foldSnapshotByFunction } from "../../dist-BvHqoBym.mjs";
1
+ import { $t as UNATTRIBUTED_BUCKET_KEY, Bi as resolveBucketMs, Nt as ROOT_BUCKET_KEY, Pi as reducePoints, ec as errMsg, is as createEvent, mo as BaseAddon, oi as metricsProviderCapability, tc as EventCategory, xr as foldSnapshotByFunction } from "../../dist-C5sQPOZX.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";
5
5
  import { platform } from "node:os";
6
- import * as fs$1 from "node:fs";
6
+ import * as fs from "node:fs";
7
7
  import { constants, readFileSync } from "node:fs";
8
8
  import { execFile } from "node:child_process";
9
9
  //#region src/builtins/native-metrics/cgroup-memory.ts
@@ -1686,7 +1686,7 @@ var NativeMetricsProvider = class {
1686
1686
  let swapUsedBytes = 0;
1687
1687
  let swapTotalBytes = 0;
1688
1688
  if (IS_LINUX) try {
1689
- const meminfo = fs$1.readFileSync("/proc/meminfo", "utf-8");
1689
+ const meminfo = fs.readFileSync("/proc/meminfo", "utf-8");
1690
1690
  const availKb = meminfo.match(/MemAvailable:\s+(\d+)/)?.[1];
1691
1691
  if (availKb !== void 0) available = parseInt(availKb, 10) * 1024;
1692
1692
  const swapTotal = parseInt(meminfo.match(/SwapTotal:\s+(\d+)/)?.[1] ?? "0", 10) * 1024;
@@ -1779,7 +1779,7 @@ async function sampleMacMemory(provider) {
1779
1779
  }
1780
1780
  function getDiskSpaceInternal(dirPath) {
1781
1781
  return new Promise((resolve, reject) => {
1782
- fs$1.statfs(dirPath, (err, stats) => {
1782
+ fs.statfs(dirPath, (err, stats) => {
1783
1783
  if (err) return reject(err);
1784
1784
  const totalBytes = stats.blocks * stats.bsize;
1785
1785
  const availableBytes = stats.bavail * stats.bsize;
@@ -1797,7 +1797,7 @@ function getDiskSpaceInternal(dirPath) {
1797
1797
  async function takeDiskIoSnapshot() {
1798
1798
  const now = Date.now();
1799
1799
  if (IS_LINUX) try {
1800
- const data = fs$1.readFileSync("/proc/diskstats", "utf-8");
1800
+ const data = fs.readFileSync("/proc/diskstats", "utf-8");
1801
1801
  let readOps = 0, readBytes = 0, writeOps = 0, writeBytes = 0;
1802
1802
  for (const line of data.split("\n")) {
1803
1803
  const parts = line.trim().split(/\s+/);
@@ -1828,7 +1828,7 @@ async function takeDiskIoSnapshot() {
1828
1828
  async function takeNetworkIoSnapshot() {
1829
1829
  const now = Date.now();
1830
1830
  if (IS_LINUX) try {
1831
- const data = fs$1.readFileSync("/proc/net/dev", "utf-8");
1831
+ const data = fs.readFileSync("/proc/net/dev", "utf-8");
1832
1832
  let rxBytes = 0, txBytes = 0, rxPackets = 0, txPackets = 0, rxErrors = 0, txErrors = 0;
1833
1833
  for (const line of data.split("\n")) {
1834
1834
  const match = line.match(/^\s*(\w+):\s+(.+)$/);
@@ -1889,7 +1889,7 @@ async function takeNetworkIoSnapshot() {
1889
1889
  }
1890
1890
  async function getCpuTemperatureInternal() {
1891
1891
  if (IS_LINUX) for (const p of ["/sys/class/thermal/thermal_zone0/temp", "/sys/class/hwmon/hwmon0/temp1_input"]) try {
1892
- const raw = fs$1.readFileSync(p, "utf-8").trim();
1892
+ const raw = fs.readFileSync(p, "utf-8").trim();
1893
1893
  const millideg = parseInt(raw, 10);
1894
1894
  if (!isNaN(millideg)) return Math.round(millideg / 100) / 10;
1895
1895
  } catch {
@@ -1940,10 +1940,10 @@ function getProcessResources() {
1940
1940
  let threadCount = 0;
1941
1941
  if (IS_LINUX) {
1942
1942
  try {
1943
- openFds = fs$1.readdirSync(`/proc/${process.pid}/fd`).length;
1943
+ openFds = fs.readdirSync(`/proc/${process.pid}/fd`).length;
1944
1944
  } catch {}
1945
1945
  try {
1946
- const match = fs$1.readFileSync(`/proc/${process.pid}/status`, "utf-8").match(/Threads:\s+(\d+)/);
1946
+ const match = fs.readFileSync(`/proc/${process.pid}/status`, "utf-8").match(/Threads:\s+(\d+)/);
1947
1947
  if (match) threadCount = parseInt(match[1], 10);
1948
1948
  } catch {}
1949
1949
  }
@@ -1958,7 +1958,7 @@ function getProcessResources() {
1958
1958
  function getPressure(resource) {
1959
1959
  if (!IS_LINUX) return null;
1960
1960
  try {
1961
- const data = fs$1.readFileSync(`/proc/pressure/${resource}`, "utf-8");
1961
+ const data = fs.readFileSync(`/proc/pressure/${resource}`, "utf-8");
1962
1962
  const parseLine = (prefix) => {
1963
1963
  const match = data.match(new RegExp(`${prefix} avg10=(\\d+\\.\\d+) avg60=(\\d+\\.\\d+) avg300=(\\d+\\.\\d+)`));
1964
1964
  if (!match) return null;
@@ -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-BXWXN1Dl.js");
6
+ const require_dist = require("../../dist-Cyc4oyGh.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,10 +1,10 @@
1
1
  import { o as __toESM, r as __exportAll } from "../../chunk-CNf5ZN-e.mjs";
2
- import { $s as errMsg, Ti as platformProbeCapability, bi as parseAcceleratorFactsJson, ec as EventCategory, po as BaseAddon, sr as enumerateInferenceDevices, ta as scoreRuntimes, us as emitReadiness } from "../../dist-BvHqoBym.mjs";
3
- import { n as detectCoralAccelerator, r as nodeCoralFs } from "../../coral-accelerators-DBlgWB8k.mjs";
2
+ import { Ti as platformProbeCapability, bi as parseAcceleratorFactsJson, ds as emitReadiness, ec as errMsg, mo as BaseAddon, na as scoreRuntimes, sr as enumerateInferenceDevices, tc as EventCategory } from "../../dist-C5sQPOZX.mjs";
3
+ import { n as detectCoralAccelerator, r as nodeCoralFs } from "../../coral-accelerators-BW3OcrLD.mjs";
4
4
  import * as path$1 from "node:path";
5
5
  import { promisify } from "node:util";
6
6
  import * as os$1 from "node:os";
7
- import * as fs$1 from "node:fs";
7
+ import * as fs from "node:fs";
8
8
  import { execFile } from "node:child_process";
9
9
  //#region src/builtins/platform-probe/accelerator-reprobe.ts
10
10
  /**
@@ -492,14 +492,14 @@ var PlatformScorer = class {
492
492
  if (nvidia) gpu = nvidia;
493
493
  const listRenderNodes = () => {
494
494
  try {
495
- return fs$1.readdirSync("/dev/dri").filter((n) => n.startsWith("renderD")).map((n) => `/dev/dri/${n}`);
495
+ return fs.readdirSync("/dev/dri").filter((n) => n.startsWith("renderD")).map((n) => `/dev/dri/${n}`);
496
496
  } catch {
497
497
  return [];
498
498
  }
499
499
  };
500
500
  const readDrmAttr = (node, attr) => {
501
501
  try {
502
- return fs$1.readFileSync(`/sys/class/drm/${node.split("/").pop()}/device/${attr}`, "utf8");
502
+ return fs.readFileSync(`/sys/class/drm/${node.split("/").pop()}/device/${attr}`, "utf8");
503
503
  } catch {
504
504
  return "";
505
505
  }
@@ -525,12 +525,12 @@ var PlatformScorer = class {
525
525
  }
526
526
  const listDir = (p) => {
527
527
  try {
528
- return fs$1.readdirSync(p);
528
+ return fs.readdirSync(p);
529
529
  } catch {
530
530
  return [];
531
531
  }
532
532
  };
533
- const exists = (p) => fs$1.existsSync(p);
533
+ const exists = (p) => fs.existsSync(p);
534
534
  if (!npu) {
535
535
  const { classifyIntelNpu } = await import("../../intel-npu-C8HKvRQF.mjs");
536
536
  npu = classifyIntelNpu({
@@ -558,7 +558,7 @@ var PlatformScorer = class {
558
558
  exists,
559
559
  readFile: (p) => {
560
560
  try {
561
- return fs$1.readFileSync(p, "utf8");
561
+ return fs.readFileSync(p, "utf8");
562
562
  } catch {
563
563
  return "";
564
564
  }
@@ -844,7 +844,7 @@ function jsonValue(text) {
844
844
  function readPublishedAcceleratorFacts(filePath) {
845
845
  let text;
846
846
  try {
847
- text = fs$1.readFileSync(filePath, "utf8");
847
+ text = fs.readFileSync(filePath, "utf8");
848
848
  } catch {
849
849
  return null;
850
850
  }
@@ -859,7 +859,7 @@ function findAcceleratorFactsScript(dataDir, cwd = process.cwd()) {
859
859
  const candidates = [];
860
860
  if (typeof dataDir === "string" && dataDir !== "") candidates.push(path$1.join(dataDir, "addons", "@camstack", "addon-pipeline", "python", "accelerator_facts.py"));
861
861
  candidates.push(path$1.join(cwd, "packages", "addon-pipeline", "python", "accelerator_facts.py"));
862
- for (const candidate of candidates) if (fs$1.existsSync(candidate)) return candidate;
862
+ for (const candidate of candidates) if (fs.existsSync(candidate)) return candidate;
863
863
  return null;
864
864
  }
865
865
  async function defaultExec(command, args, timeoutMs) {