@camstack/server 1.2.773 → 1.2.775

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/closure-patches/patch-reach.json +0 -17
  3. package/package.json +19 -9
  4. package/system/dist/{agent-https-CyrCmRxJ.mjs → agent-https-D7XFlCS4.mjs} +1 -1
  5. package/system/dist/{agent-https-DOsuGpqh.js → agent-https-DN3SiDdO.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.d.ts +2 -1
  11. package/system/dist/builtins/alerts/alerts.addon.js +6 -2
  12. package/system/dist/builtins/alerts/alerts.addon.mjs +6 -2
  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 +2 -2
  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/console-logging.addon.d.ts +2 -1
  24. package/system/dist/builtins/console-logging/index.js +6 -2
  25. package/system/dist/builtins/console-logging/index.mjs +6 -2
  26. package/system/dist/builtins/core-blocks/core-blocks.addon.js +3 -3
  27. package/system/dist/builtins/core-blocks/core-blocks.addon.mjs +3 -3
  28. package/system/dist/builtins/device-history/device-history.addon.d.ts +2 -1
  29. package/system/dist/builtins/device-history/device-history.addon.js +7 -3
  30. package/system/dist/builtins/device-history/device-history.addon.mjs +7 -3
  31. package/system/dist/builtins/device-manager/device-manager.addon.js +7 -3
  32. package/system/dist/builtins/device-manager/device-manager.addon.mjs +7 -3
  33. package/system/dist/builtins/hub-forwarder/index.js +1 -1
  34. package/system/dist/builtins/hub-forwarder/index.mjs +1 -1
  35. package/system/dist/builtins/keychain/index.js +4 -4
  36. package/system/dist/builtins/keychain/index.mjs +4 -4
  37. package/system/dist/builtins/liveness-monitor/liveness-monitor.addon.js +1 -1
  38. package/system/dist/builtins/liveness-monitor/liveness-monitor.addon.mjs +1 -1
  39. package/system/dist/builtins/local-auth/local-auth.addon.js +2 -2
  40. package/system/dist/builtins/local-auth/local-auth.addon.mjs +2 -2
  41. package/system/dist/builtins/local-network/local-network.addon.d.ts +1 -0
  42. package/system/dist/builtins/local-network/local-network.addon.js +5 -2
  43. package/system/dist/builtins/local-network/local-network.addon.mjs +5 -2
  44. package/system/dist/builtins/loki-logging/index.js +1 -1
  45. package/system/dist/builtins/loki-logging/index.mjs +1 -1
  46. package/system/dist/builtins/native-metrics/native-metrics.addon.d.ts +2 -1
  47. package/system/dist/builtins/native-metrics/native-metrics.addon.js +6 -2
  48. package/system/dist/builtins/native-metrics/native-metrics.addon.mjs +6 -2
  49. package/system/dist/builtins/platform-probe/index.js +1 -1
  50. package/system/dist/builtins/platform-probe/index.mjs +1 -1
  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 +6 -2
  56. package/system/dist/builtins/snapshot/index.mjs +6 -2
  57. package/system/dist/builtins/snapshot/snapshot.addon.d.ts +2 -1
  58. package/system/dist/builtins/sqlite-storage/filesystem-storage.addon.js +1 -1
  59. package/system/dist/builtins/sqlite-storage/filesystem-storage.addon.mjs +1 -1
  60. package/system/dist/builtins/sqlite-storage/index.js +1 -1
  61. package/system/dist/builtins/sqlite-storage/index.mjs +1 -1
  62. package/system/dist/builtins/sqlite-storage/sqlite-settings.addon.js +3 -3
  63. package/system/dist/builtins/sqlite-storage/sqlite-settings.addon.mjs +3 -3
  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 +284 -284
  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/{capture-engine-J4EdEUb-.mjs → capture-engine-GMG1X2TN.mjs} +1 -1
  71. package/system/dist/{capture-engine-DfJefQzh.js → capture-engine-b-6U50tb.js} +1 -1
  72. package/system/dist/{composition-sources--RXFM6JO.js → composition-sources-B4d51O_D.js} +1 -1
  73. package/system/dist/{composition-sources-CAIR3OwR.mjs → composition-sources-Cn00-OEM.mjs} +1 -1
  74. package/system/dist/{constants-JeT80ws5.js → constants-CQ6aJD-7.js} +1 -1
  75. package/system/dist/{constants-DrfuDfO3.mjs → constants-nF0GL2ol.mjs} +1 -1
  76. package/system/dist/{device-ca-CTrahP2b.mjs → device-ca-BO_1Fnqk.mjs} +1 -1
  77. package/system/dist/{device-ca-DdIoGE_e.js → device-ca-DDPuTmrn.js} +1 -1
  78. package/system/dist/{dist-nYcZlEKK.mjs → dist-C-reEuab.mjs} +134 -29
  79. package/system/dist/{dist-BPFZFbaX.js → dist-DyI9u0b7.js} +134 -29
  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-DMT5fohb.js → hub-mdns-ciao-BnTtLjAw.js} +2 -2
  83. package/system/dist/{hub-mdns-ciao-wztymuRC.mjs → hub-mdns-ciao-vybj30s5.mjs} +2 -2
  84. package/system/dist/index.js +15 -9
  85. package/system/dist/index.mjs +15 -9
  86. package/system/dist/{legacy-integration-rows-door-D9tflm8o.mjs → legacy-integration-rows-door-5eYHOgk7.mjs} +1 -1
  87. package/system/dist/{legacy-integration-rows-door-BBY9d3Ge.js → legacy-integration-rows-door-uTtKNkuI.js} +1 -1
  88. package/system/dist/{restore-archive-NtX8oJFn.js → restore-archive-BYOloNIq.js} +1 -1
  89. package/system/dist/{restore-archive-C5V_cQNq.mjs → restore-archive-DYn0lsQl.mjs} +82 -82
  90. package/system/dist/{wal-maintenance-CbDxJRRy.js → wal-maintenance-CfBfW_kE.js} +0 -0
  91. package/system/dist/{wal-maintenance-CLcPsCoy.mjs → wal-maintenance-D2ztRFn-.mjs} +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
  const require_chunk = require("../../chunk-Cek0wNdY.js");
6
- const require_dist = require("../../dist-BPFZFbaX.js");
6
+ const require_dist = require("../../dist-DyI9u0b7.js");
7
7
  const require_formatter = require("../../formatter-xbxeV4GD.js");
8
8
  const require_log_file_read_protocol = require("../../log-file-read-protocol-D0WcLbIV.js");
9
9
  let node_path = require("node:path");
@@ -1,4 +1,4 @@
1
- import { To as BaseAddon, ri as logDestinationCapability } from "../../dist-nYcZlEKK.mjs";
1
+ import { To as BaseAddon, ri as logDestinationCapability } from "../../dist-C-reEuab.mjs";
2
2
  import { t as formatLogLine } from "../../formatter-DkYZ4LXp.mjs";
3
3
  import { a as LogFileIndexStore, i as serveRead, n as isFromReader, t as CancelBook } from "../../log-file-read-protocol-B7M3X3bT.mjs";
4
4
  import { createRequire } from "node:module";
@@ -1,4 +1,4 @@
1
- import { Es as historyItemFieldPath, Po as HISTORY_DEFAULT_MIN_INTERVAL_MS, uc as DeviceType } from "./dist-nYcZlEKK.mjs";
1
+ import { Es as historyItemFieldPath, Po as HISTORY_DEFAULT_MIN_INTERVAL_MS, uc as DeviceType } from "./dist-C-reEuab.mjs";
2
2
  //#region src/builtins/device-history/store/series-registry.ts
3
3
  function subjectIdOf(subject) {
4
4
  return subject.kind === "device" ? `d:${subject.deviceId}` : `n:${subject.nodeId}`;
@@ -1,4 +1,4 @@
1
- const require_dist = require("./dist-BPFZFbaX.js");
1
+ const require_dist = require("./dist-DyI9u0b7.js");
2
2
  //#region src/builtins/device-history/store/series-registry.ts
3
3
  function subjectIdOf(subject) {
4
4
  return subject.kind === "device" ? `d:${subject.deviceId}` : `n:${subject.nodeId}`;
@@ -1,4 +1,4 @@
1
- const require_dist = require("./dist-BPFZFbaX.js");
1
+ const require_dist = require("./dist-DyI9u0b7.js");
2
2
  //#region src/builtins/shared/device-state-changed.ts
3
3
  /** Structural narrowing helper for untrusted bus payloads. */
4
4
  function isRecord(value) {
@@ -1,4 +1,4 @@
1
- import { dc as errMsg, so as compositionSourceKey } from "./dist-nYcZlEKK.mjs";
1
+ import { dc as errMsg, so as compositionSourceKey } from "./dist-C-reEuab.mjs";
2
2
  //#region src/builtins/shared/device-state-changed.ts
3
3
  /** Structural narrowing helper for untrusted bus payloads. */
4
4
  function isRecord(value) {
@@ -1,5 +1,5 @@
1
1
  /** `secret://system/global/meshCaKey` — EC P-256 PKCS#8 PEM of the hub mesh CA. */
2
- var MESH_CA_KEY_REF = require("./dist-BPFZFbaX.js").buildSecretRef({
2
+ var MESH_CA_KEY_REF = require("./dist-DyI9u0b7.js").buildSecretRef({
3
3
  owner: "system",
4
4
  scope: { kind: "global" },
5
5
  fieldPath: "meshCaKey"
@@ -1,4 +1,4 @@
1
- import { us as buildSecretRef } from "./dist-nYcZlEKK.mjs";
1
+ import { us as buildSecretRef } from "./dist-C-reEuab.mjs";
2
2
  /** `secret://system/global/meshCaKey` — EC P-256 PKCS#8 PEM of the hub mesh CA. */
3
3
  var MESH_CA_KEY_REF = buildSecretRef({
4
4
  owner: "system",
@@ -1,4 +1,4 @@
1
- import { H as DEVICE_SAN_CREDENTIAL_PREFIX, U as DEVICE_SAN_USER_PREFIX, us as buildSecretRef } from "./dist-nYcZlEKK.mjs";
1
+ import { H as DEVICE_SAN_CREDENTIAL_PREFIX, U as DEVICE_SAN_USER_PREFIX, us as buildSecretRef } from "./dist-C-reEuab.mjs";
2
2
  import { C as backdatedNotBefore, S as withUtcTimeEncoding, a as KeyUsageFlags, d as SubjectKeyIdentifierExtension, f as X509Certificate$1, m as cryptoProvider, n as BasicConstraintsExtension, o as KeyUsagesExtension, p as X509CertificateGenerator, r as ExtendedKeyUsageExtension, s as PemConverter, t as AuthorityKeyIdentifierExtension, u as SubjectAlternativeNameExtension } from "./x509.es-BRiJgOvu.mjs";
3
3
  import { X509Certificate, createPublicKey, randomBytes, verify, webcrypto } from "node:crypto";
4
4
  //#region src/auth/jwt-signing-key.ts
@@ -1,4 +1,4 @@
1
- const require_dist = require("./dist-BPFZFbaX.js");
1
+ const require_dist = require("./dist-DyI9u0b7.js");
2
2
  const require_x509_es = require("./x509.es-WtnRNyYS.js");
3
3
  let node_crypto = require("node:crypto");
4
4
  //#region src/auth/jwt-signing-key.ts
@@ -1171,7 +1171,7 @@ var DeviceRole = /* @__PURE__ */ function(DeviceRole) {
1171
1171
  return DeviceRole;
1172
1172
  }({});
1173
1173
  //#endregion
1174
- //#region ../types/dist/sleep-9TIHFj1w.mjs
1174
+ //#region ../types/dist/sleep-DEZaLbiu.mjs
1175
1175
  /**
1176
1176
  * The audio chunk plane's byte format, and the ONE expansion from a coded
1177
1177
  * window to float samples (D455).
@@ -2044,6 +2044,23 @@ function projectStore(store, perNodeKeys, nodeId) {
2044
2044
  }
2045
2045
  return out;
2046
2046
  }
2047
+ /** Every scope, in the order the guard and the docs list them. */
2048
+ var SCOPED_SETTINGS_SCOPES = [
2049
+ "cluster",
2050
+ "device-defaults",
2051
+ "node"
2052
+ ];
2053
+ /**
2054
+ * The node id a node-scoped KEY carries: the part after the `@`. `null` for a key with no `@`
2055
+ * (a cluster or fleet-default key) or an empty node id. A schema key never contains `@`
2056
+ * (guard `check-scoped-settings-declared`), so the first `@` is the separator.
2057
+ */
2058
+ function nodeIdOfScopedKey(key) {
2059
+ const at = key.indexOf("@");
2060
+ if (at <= 0) return null;
2061
+ const nodeId = key.slice(at + 1);
2062
+ return nodeId === "" ? null : nodeId;
2063
+ }
2047
2064
  /**
2048
2065
  * The address of one keychain value: `secret://<owner>/<scope>/<fieldPath>`.
2049
2066
  *
@@ -2948,6 +2965,13 @@ var BaseAddon = class {
2948
2965
  */
2949
2966
  secretStatePaths = [];
2950
2967
  _addonSecretTree = null;
2968
+ /**
2969
+ * D986 M4: the scoped schemas this addon declared, resolved once per capability
2970
+ * (`loadScopedSchemas`) so the sync readers (`perNodeKeys`, the secret tree, the restart check)
2971
+ * see them. Empty until loaded: the readers then fall back to {@link globalSettingsSchema}.
2972
+ */
2973
+ _scopedByCap = /* @__PURE__ */ new Map();
2974
+ _nodeKeysByCap = /* @__PURE__ */ new Map();
2951
2975
  _deviceSecretTree = null;
2952
2976
  /** Refs the last resolved config pointed at — a change to one re-resolves. */
2953
2977
  _configSecretRefs = /* @__PURE__ */ new Set();
@@ -3017,6 +3041,7 @@ var BaseAddon = class {
3017
3041
  this._ctx = context;
3018
3042
  this._secretSettings = null;
3019
3043
  }
3044
+ await this.loadScopedSchemas();
3020
3045
  await this.resolveConfig();
3021
3046
  if (secrets !== void 0) this._secretChangeUnsub = secrets.onChange((ref) => {
3022
3047
  if (this._configSecretRefs.has(ref)) this.scheduleSecretReresolve(SECRET_CHANGE_DEBOUNCE_MS);
@@ -3026,6 +3051,7 @@ var BaseAddon = class {
3026
3051
  const normalized = normalizeAddonInitResult(result);
3027
3052
  const providers = normalized && "providers" in normalized && normalized.providers ? normalized.providers : [];
3028
3053
  this._registeredCapNames = providers.map((p) => p.capability.name);
3054
+ await this.loadScopedSchemas();
3029
3055
  return normalized;
3030
3056
  }
3031
3057
  /**
@@ -3114,6 +3140,16 @@ var BaseAddon = class {
3114
3140
  schema(schema) {
3115
3141
  return schema;
3116
3142
  }
3143
+ /**
3144
+ * The capability names whose scoped settings schemas ({@link clusterSettingsSchema},
3145
+ * {@link nodeSettingsSchema}, {@link deviceDefaultsSchema}) this addon declares. Read BEFORE
3146
+ * `onInitialize`, when the providers it registers are not known yet: the first config resolve
3147
+ * must already know which keys are per node. Names the providers register at init are added
3148
+ * once known.
3149
+ */
3150
+ scopedSettingsCapabilities() {
3151
+ return [];
3152
+ }
3117
3153
  /** Override to provide global-level settings UI schema. */
3118
3154
  globalSettingsSchema(_cap) {
3119
3155
  return null;
@@ -3157,7 +3193,8 @@ var BaseAddon = class {
3157
3193
  return [];
3158
3194
  }
3159
3195
  async getGlobalSettings(overlay, cap, nodeId) {
3160
- const schema = this.globalSettingsSchema(cap);
3196
+ await this.loadScopedSchemas(cap);
3197
+ const schema = this.globalSettingsSchema(cap) ?? this.scopedFormSchema(cap);
3161
3198
  if (!schema) return { sections: [] };
3162
3199
  const projected = await this.readRawProjectedStore(nodeId, cap);
3163
3200
  return hydrateSchema(schema, overlay ? await this.overlayKeepingMarkers(projected, overlay) : projected, { inlineSecretsAsViews: true });
@@ -3288,6 +3325,7 @@ var BaseAddon = class {
3288
3325
  * resolved blob back is a no-op for every unchanged secret.
3289
3326
  */
3290
3327
  async resolveGlobalStore(nodeId, cap) {
3328
+ await this.loadScopedSchemas(cap);
3291
3329
  const raw = await this._ctx?.settings?.readAddonStore() ?? {};
3292
3330
  return this.projectForNode(raw, nodeId, cap);
3293
3331
  }
@@ -3298,6 +3336,7 @@ var BaseAddon = class {
3298
3336
  }
3299
3337
  /** The PROJECTED store with its markers — the form hydrate only (D798). */
3300
3338
  async readRawProjectedStore(nodeId, cap) {
3339
+ await this.loadScopedSchemas(cap);
3301
3340
  const raw = await this.rawSettings()?.readAddonStore() ?? {};
3302
3341
  return this.projectForNode(raw, nodeId, cap);
3303
3342
  }
@@ -3400,6 +3439,7 @@ var BaseAddon = class {
3400
3439
  await this.applyGlobalPatch(patch, nodeId);
3401
3440
  }
3402
3441
  async applyGlobalPatch(barePatch, nodeId) {
3442
+ await this.loadScopedSchemas();
3403
3443
  const keys = this.perNodeKeys();
3404
3444
  const localNode = normalizeNodeId(this._ctx?.kernel?.localNodeId);
3405
3445
  const target = normalizeNodeId(nodeId ?? this._ctx?.kernel?.localNodeId);
@@ -3413,7 +3453,8 @@ var BaseAddon = class {
3413
3453
  await this.resolveConfig();
3414
3454
  await this.onConfigChanged();
3415
3455
  this.emitLifecycle(EventCategory.AddonUpdated, { level: "global" });
3416
- this.maybeAutoRestart(Object.keys(barePatch), this.globalSettingsSchema());
3456
+ const legacy = this.globalSettingsSchema();
3457
+ this.maybeAutoRestart(Object.keys(barePatch), [...legacy === null ? [] : [legacy], ...this.loadedScopedSchemas().map((entry) => entry.schema)]);
3417
3458
  }
3418
3459
  /**
3419
3460
  * The set of field keys the global settings schema declares `perNode: true`
@@ -3421,14 +3462,67 @@ var BaseAddon = class {
3421
3462
  * declarations). Empty set ⇒ every per-node code path is bypassed and the
3422
3463
  * settings API behaves exactly like the legacy node-agnostic one.
3423
3464
  */
3424
- _perNodeKeysCache = /* @__PURE__ */ new Map();
3465
+ /**
3466
+ * Load the scoped schemas of every capability this addon declares (the override and the
3467
+ * providers registered at init, plus `extraCap`) that is not loaded yet, then drop what was
3468
+ * derived from the previous set. Idempotent.
3469
+ */
3470
+ async loadScopedSchemas(extraCap) {
3471
+ const caps = new Set([
3472
+ ...this.scopedSettingsCapabilities(),
3473
+ ...this._registeredCapNames,
3474
+ ...extraCap === void 0 ? [] : [extraCap]
3475
+ ]);
3476
+ let added = false;
3477
+ for (const cap of caps) {
3478
+ if (this._scopedByCap.has(cap)) continue;
3479
+ const loaded = [];
3480
+ for (const scope of SCOPED_SETTINGS_SCOPES) {
3481
+ const schema = await this.getScopedSettingsSchema(scope, cap);
3482
+ if (schema !== null) loaded.push({
3483
+ scope,
3484
+ schema
3485
+ });
3486
+ }
3487
+ this._scopedByCap.set(cap, loaded);
3488
+ added = true;
3489
+ }
3490
+ if (!added) return;
3491
+ this._nodeKeysByCap = /* @__PURE__ */ new Map();
3492
+ this._addonSecretTree = null;
3493
+ }
3494
+ /**
3495
+ * The form the settings API serves while an addon declares no {@link globalSettingsSchema}: the
3496
+ * sections of its scoped schemas, so dropping the old hook does not blank the form.
3497
+ */
3498
+ scopedFormSchema(cap) {
3499
+ const byId = /* @__PURE__ */ new Map();
3500
+ for (const entry of this.loadedScopedSchemas(cap)) for (const section of entry.schema.sections) if (!byId.has(section.id)) byId.set(section.id, section);
3501
+ return byId.size === 0 ? null : { sections: [...byId.values()] };
3502
+ }
3503
+ /** Every loaded scoped schema of `cap`, or of every loaded capability. */
3504
+ loadedScopedSchemas(cap) {
3505
+ if (cap !== void 0) return this._scopedByCap.get(cap) ?? [];
3506
+ return [...this._scopedByCap.values()].flat();
3507
+ }
3508
+ /**
3509
+ * The field keys that are stored per node: every field of a {@link nodeSettingsSchema}, plus
3510
+ * the fields the legacy {@link globalSettingsSchema} still marks `perNode: true`. Derived once
3511
+ * per `cap` argument and memoized (schemas are static declarations). Empty set ⇒ every
3512
+ * per-node code path is bypassed and the settings API behaves like the node-agnostic one.
3513
+ * Call {@link loadScopedSchemas} first (the async seams do).
3514
+ */
3425
3515
  perNodeKeys(cap) {
3426
3516
  const cacheKey = cap ?? "";
3427
- const cached = this._perNodeKeysCache.get(cacheKey);
3517
+ const cached = this._nodeKeysByCap.get(cacheKey);
3428
3518
  if (cached) return cached;
3429
- const schema = this.globalSettingsSchema(cap);
3430
- const keys = new Set(schema ? schema.sections.flatMap((section) => collectPerNodeFieldKeys(section.fields)) : []);
3431
- this._perNodeKeysCache.set(cacheKey, keys);
3519
+ const legacy = this.globalSettingsSchema(cap);
3520
+ const keys = new Set(legacy ? legacy.sections.flatMap((section) => collectPerNodeFieldKeys(section.fields)) : []);
3521
+ for (const { scope, schema } of this.loadedScopedSchemas(cap)) {
3522
+ if (scope !== "node") continue;
3523
+ for (const section of schema.sections) for (const key of collectValueFieldKeys(section.fields)) keys.add(key);
3524
+ }
3525
+ this._nodeKeysByCap.set(cacheKey, keys);
3432
3526
  return keys;
3433
3527
  }
3434
3528
  /**
@@ -3438,10 +3532,9 @@ var BaseAddon = class {
3438
3532
  * time to return its response before the addon is torn down and
3439
3533
  * re-initialised by `AddonRegistryService.restartAddon`.
3440
3534
  */
3441
- maybeAutoRestart(patchKeys, schema) {
3442
- if (!schema) return;
3535
+ maybeAutoRestart(patchKeys, schemas) {
3443
3536
  const restartKeys = /* @__PURE__ */ new Set();
3444
- for (const section of schema.sections) for (const field of section.fields) {
3537
+ for (const schema of schemas) for (const section of schema.sections) for (const field of section.fields) {
3445
3538
  if (field.type === "separator" || field.type === "info") continue;
3446
3539
  if (field.requiresRestart) restartKeys.add(field.key);
3447
3540
  }
@@ -3637,12 +3730,14 @@ var BaseAddon = class {
3637
3730
  * here, in the addon's own process, so the hub keeps no copy of it.
3638
3731
  */
3639
3732
  async getDeclaredSettingsKeys() {
3733
+ await this.loadScopedSchemas();
3640
3734
  return { keys: [...this.declaredKeySet()].toSorted() };
3641
3735
  }
3642
3736
  declaredKeySet() {
3643
3737
  const keys = new Set(Object.keys(this.defaults));
3644
3738
  const schema = this.globalSettingsSchema();
3645
3739
  if (schema) for (const section of schema.sections) for (const key of collectFieldKeys(section.fields)) keys.add(key);
3740
+ for (const { schema: scoped } of this.loadedScopedSchemas()) for (const section of scoped.sections) for (const key of collectFieldKeys(section.fields)) keys.add(key);
3646
3741
  for (const key of this._declaredStateKeys) keys.add(key);
3647
3742
  for (const path of this.secretStatePaths) {
3648
3743
  const root = path.split(/[.[]/, 1)[0];
@@ -3738,7 +3833,11 @@ var BaseAddon = class {
3738
3833
  }
3739
3834
  /** The addon store's secret tree: schema fields by TYPE, plus `secretStatePaths`. */
3740
3835
  addonSecretTree() {
3741
- this._addonSecretTree ??= mergeSecretStatePaths(secretTreeFromSchema(this.globalSettingsSchema()), this.secretStatePaths);
3836
+ if (this._addonSecretTree === null) {
3837
+ const tree = new Map(secretTreeFromSchema(this.globalSettingsSchema()));
3838
+ for (const { schema } of this.loadedScopedSchemas()) for (const [key, node] of secretTreeFromSchema(schema)) tree.set(key, node);
3839
+ this._addonSecretTree = mergeSecretStatePaths(tree, this.secretStatePaths);
3840
+ }
3742
3841
  return this._addonSecretTree;
3743
3842
  }
3744
3843
  deviceSecretTree() {
@@ -3988,6 +4087,23 @@ function dropPerNodeFields(fields) {
3988
4087
  }
3989
4088
  return kept;
3990
4089
  }
4090
+ /** The keys of the value-holding fields, recursing into layout containers. */
4091
+ function collectValueFieldKeys(fields) {
4092
+ const collected = [];
4093
+ for (const field of fields) {
4094
+ if (field.type === "group") {
4095
+ collected.push(...collectValueFieldKeys(field.fields));
4096
+ continue;
4097
+ }
4098
+ if (field.type === "sub-tabs") {
4099
+ for (const tab of field.tabs) collected.push(...collectValueFieldKeys(tab.fields));
4100
+ continue;
4101
+ }
4102
+ if (field.type === "separator" || field.type === "info") continue;
4103
+ if ("key" in field && typeof field.key === "string") collected.push(field.key);
4104
+ }
4105
+ return collected;
4106
+ }
3991
4107
  function collectFieldKeys(fields) {
3992
4108
  const collected = [];
3993
4109
  for (const field of fields) {
@@ -4033,17 +4149,6 @@ function normalizeAddonInitResult(result) {
4033
4149
  if (Array.isArray(result)) return { providers: result };
4034
4150
  return result;
4035
4151
  }
4036
- /**
4037
- * The node id a node-scoped KEY carries: the part after the `@`. `null` for a key with no `@`
4038
- * (a cluster or fleet-default key) or an empty node id. A schema key never contains `@`
4039
- * (guard `check-scoped-settings-declared`), so the first `@` is the separator.
4040
- */
4041
- function nodeIdOfScopedKey(key) {
4042
- const at = key.indexOf("@");
4043
- if (at <= 0) return null;
4044
- const nodeId = key.slice(at + 1);
4045
- return nodeId === "" ? null : nodeId;
4046
- }
4047
4152
  var PREFIX = "records/";
4048
4153
  /** The base of every records failure. `detail` is the human part of the message. */
4049
4154
  var RecordsError = class extends Error {
@@ -56589,12 +56694,12 @@ var deviceExportCapability = {
56589
56694
  kind: "poll"
56590
56695
  },
56591
56696
  /**
56592
- * Each export provider contributes its own per-device "Export" panel
56593
- * (enabled toggle, preferred stream, addon-specific knobs like the
56594
- * HA-MQTT discovery prefix). The three framework methods
56595
- * `getDeviceSettingsContribution` / `getDeviceLiveContribution` /
56596
- * `applyDeviceSettingsPatch` are auto-injected on the provider
56597
- * interface and routed to the device-details aggregator.
56697
+ * Each export provider MAY contribute its own per-device "Export" panel
56698
+ * (enabled toggle, preferred stream, addon-specific knobs). The three
56699
+ * framework methods are mounted on the cap router when present.
56700
+ * `IDeviceExportProvider` leaves them optional: an exporter with no
56701
+ * per-device panel omits them (a `deviceConfig` cap's UI is derived and
56702
+ * never hand-written — D14 — and an exporter is not one of those).
56598
56703
  */
56599
56704
  exposesDeviceSettings: true,
56600
56705
  methods: {
@@ -1171,7 +1171,7 @@ var DeviceRole = /* @__PURE__ */ function(DeviceRole) {
1171
1171
  return DeviceRole;
1172
1172
  }({});
1173
1173
  //#endregion
1174
- //#region ../types/dist/sleep-9TIHFj1w.mjs
1174
+ //#region ../types/dist/sleep-DEZaLbiu.mjs
1175
1175
  /**
1176
1176
  * The audio chunk plane's byte format, and the ONE expansion from a coded
1177
1177
  * window to float samples (D455).
@@ -2044,6 +2044,23 @@ function projectStore(store, perNodeKeys, nodeId) {
2044
2044
  }
2045
2045
  return out;
2046
2046
  }
2047
+ /** Every scope, in the order the guard and the docs list them. */
2048
+ var SCOPED_SETTINGS_SCOPES = [
2049
+ "cluster",
2050
+ "device-defaults",
2051
+ "node"
2052
+ ];
2053
+ /**
2054
+ * The node id a node-scoped KEY carries: the part after the `@`. `null` for a key with no `@`
2055
+ * (a cluster or fleet-default key) or an empty node id. A schema key never contains `@`
2056
+ * (guard `check-scoped-settings-declared`), so the first `@` is the separator.
2057
+ */
2058
+ function nodeIdOfScopedKey(key) {
2059
+ const at = key.indexOf("@");
2060
+ if (at <= 0) return null;
2061
+ const nodeId = key.slice(at + 1);
2062
+ return nodeId === "" ? null : nodeId;
2063
+ }
2047
2064
  /**
2048
2065
  * The address of one keychain value: `secret://<owner>/<scope>/<fieldPath>`.
2049
2066
  *
@@ -2948,6 +2965,13 @@ var BaseAddon = class {
2948
2965
  */
2949
2966
  secretStatePaths = [];
2950
2967
  _addonSecretTree = null;
2968
+ /**
2969
+ * D986 M4: the scoped schemas this addon declared, resolved once per capability
2970
+ * (`loadScopedSchemas`) so the sync readers (`perNodeKeys`, the secret tree, the restart check)
2971
+ * see them. Empty until loaded: the readers then fall back to {@link globalSettingsSchema}.
2972
+ */
2973
+ _scopedByCap = /* @__PURE__ */ new Map();
2974
+ _nodeKeysByCap = /* @__PURE__ */ new Map();
2951
2975
  _deviceSecretTree = null;
2952
2976
  /** Refs the last resolved config pointed at — a change to one re-resolves. */
2953
2977
  _configSecretRefs = /* @__PURE__ */ new Set();
@@ -3017,6 +3041,7 @@ var BaseAddon = class {
3017
3041
  this._ctx = context;
3018
3042
  this._secretSettings = null;
3019
3043
  }
3044
+ await this.loadScopedSchemas();
3020
3045
  await this.resolveConfig();
3021
3046
  if (secrets !== void 0) this._secretChangeUnsub = secrets.onChange((ref) => {
3022
3047
  if (this._configSecretRefs.has(ref)) this.scheduleSecretReresolve(SECRET_CHANGE_DEBOUNCE_MS);
@@ -3026,6 +3051,7 @@ var BaseAddon = class {
3026
3051
  const normalized = normalizeAddonInitResult(result);
3027
3052
  const providers = normalized && "providers" in normalized && normalized.providers ? normalized.providers : [];
3028
3053
  this._registeredCapNames = providers.map((p) => p.capability.name);
3054
+ await this.loadScopedSchemas();
3029
3055
  return normalized;
3030
3056
  }
3031
3057
  /**
@@ -3114,6 +3140,16 @@ var BaseAddon = class {
3114
3140
  schema(schema) {
3115
3141
  return schema;
3116
3142
  }
3143
+ /**
3144
+ * The capability names whose scoped settings schemas ({@link clusterSettingsSchema},
3145
+ * {@link nodeSettingsSchema}, {@link deviceDefaultsSchema}) this addon declares. Read BEFORE
3146
+ * `onInitialize`, when the providers it registers are not known yet: the first config resolve
3147
+ * must already know which keys are per node. Names the providers register at init are added
3148
+ * once known.
3149
+ */
3150
+ scopedSettingsCapabilities() {
3151
+ return [];
3152
+ }
3117
3153
  /** Override to provide global-level settings UI schema. */
3118
3154
  globalSettingsSchema(_cap) {
3119
3155
  return null;
@@ -3157,7 +3193,8 @@ var BaseAddon = class {
3157
3193
  return [];
3158
3194
  }
3159
3195
  async getGlobalSettings(overlay, cap, nodeId) {
3160
- const schema = this.globalSettingsSchema(cap);
3196
+ await this.loadScopedSchemas(cap);
3197
+ const schema = this.globalSettingsSchema(cap) ?? this.scopedFormSchema(cap);
3161
3198
  if (!schema) return { sections: [] };
3162
3199
  const projected = await this.readRawProjectedStore(nodeId, cap);
3163
3200
  return hydrateSchema(schema, overlay ? await this.overlayKeepingMarkers(projected, overlay) : projected, { inlineSecretsAsViews: true });
@@ -3288,6 +3325,7 @@ var BaseAddon = class {
3288
3325
  * resolved blob back is a no-op for every unchanged secret.
3289
3326
  */
3290
3327
  async resolveGlobalStore(nodeId, cap) {
3328
+ await this.loadScopedSchemas(cap);
3291
3329
  const raw = await this._ctx?.settings?.readAddonStore() ?? {};
3292
3330
  return this.projectForNode(raw, nodeId, cap);
3293
3331
  }
@@ -3298,6 +3336,7 @@ var BaseAddon = class {
3298
3336
  }
3299
3337
  /** The PROJECTED store with its markers — the form hydrate only (D798). */
3300
3338
  async readRawProjectedStore(nodeId, cap) {
3339
+ await this.loadScopedSchemas(cap);
3301
3340
  const raw = await this.rawSettings()?.readAddonStore() ?? {};
3302
3341
  return this.projectForNode(raw, nodeId, cap);
3303
3342
  }
@@ -3400,6 +3439,7 @@ var BaseAddon = class {
3400
3439
  await this.applyGlobalPatch(patch, nodeId);
3401
3440
  }
3402
3441
  async applyGlobalPatch(barePatch, nodeId) {
3442
+ await this.loadScopedSchemas();
3403
3443
  const keys = this.perNodeKeys();
3404
3444
  const localNode = normalizeNodeId(this._ctx?.kernel?.localNodeId);
3405
3445
  const target = normalizeNodeId(nodeId ?? this._ctx?.kernel?.localNodeId);
@@ -3413,7 +3453,8 @@ var BaseAddon = class {
3413
3453
  await this.resolveConfig();
3414
3454
  await this.onConfigChanged();
3415
3455
  this.emitLifecycle(EventCategory.AddonUpdated, { level: "global" });
3416
- this.maybeAutoRestart(Object.keys(barePatch), this.globalSettingsSchema());
3456
+ const legacy = this.globalSettingsSchema();
3457
+ this.maybeAutoRestart(Object.keys(barePatch), [...legacy === null ? [] : [legacy], ...this.loadedScopedSchemas().map((entry) => entry.schema)]);
3417
3458
  }
3418
3459
  /**
3419
3460
  * The set of field keys the global settings schema declares `perNode: true`
@@ -3421,14 +3462,67 @@ var BaseAddon = class {
3421
3462
  * declarations). Empty set ⇒ every per-node code path is bypassed and the
3422
3463
  * settings API behaves exactly like the legacy node-agnostic one.
3423
3464
  */
3424
- _perNodeKeysCache = /* @__PURE__ */ new Map();
3465
+ /**
3466
+ * Load the scoped schemas of every capability this addon declares (the override and the
3467
+ * providers registered at init, plus `extraCap`) that is not loaded yet, then drop what was
3468
+ * derived from the previous set. Idempotent.
3469
+ */
3470
+ async loadScopedSchemas(extraCap) {
3471
+ const caps = new Set([
3472
+ ...this.scopedSettingsCapabilities(),
3473
+ ...this._registeredCapNames,
3474
+ ...extraCap === void 0 ? [] : [extraCap]
3475
+ ]);
3476
+ let added = false;
3477
+ for (const cap of caps) {
3478
+ if (this._scopedByCap.has(cap)) continue;
3479
+ const loaded = [];
3480
+ for (const scope of SCOPED_SETTINGS_SCOPES) {
3481
+ const schema = await this.getScopedSettingsSchema(scope, cap);
3482
+ if (schema !== null) loaded.push({
3483
+ scope,
3484
+ schema
3485
+ });
3486
+ }
3487
+ this._scopedByCap.set(cap, loaded);
3488
+ added = true;
3489
+ }
3490
+ if (!added) return;
3491
+ this._nodeKeysByCap = /* @__PURE__ */ new Map();
3492
+ this._addonSecretTree = null;
3493
+ }
3494
+ /**
3495
+ * The form the settings API serves while an addon declares no {@link globalSettingsSchema}: the
3496
+ * sections of its scoped schemas, so dropping the old hook does not blank the form.
3497
+ */
3498
+ scopedFormSchema(cap) {
3499
+ const byId = /* @__PURE__ */ new Map();
3500
+ for (const entry of this.loadedScopedSchemas(cap)) for (const section of entry.schema.sections) if (!byId.has(section.id)) byId.set(section.id, section);
3501
+ return byId.size === 0 ? null : { sections: [...byId.values()] };
3502
+ }
3503
+ /** Every loaded scoped schema of `cap`, or of every loaded capability. */
3504
+ loadedScopedSchemas(cap) {
3505
+ if (cap !== void 0) return this._scopedByCap.get(cap) ?? [];
3506
+ return [...this._scopedByCap.values()].flat();
3507
+ }
3508
+ /**
3509
+ * The field keys that are stored per node: every field of a {@link nodeSettingsSchema}, plus
3510
+ * the fields the legacy {@link globalSettingsSchema} still marks `perNode: true`. Derived once
3511
+ * per `cap` argument and memoized (schemas are static declarations). Empty set ⇒ every
3512
+ * per-node code path is bypassed and the settings API behaves like the node-agnostic one.
3513
+ * Call {@link loadScopedSchemas} first (the async seams do).
3514
+ */
3425
3515
  perNodeKeys(cap) {
3426
3516
  const cacheKey = cap ?? "";
3427
- const cached = this._perNodeKeysCache.get(cacheKey);
3517
+ const cached = this._nodeKeysByCap.get(cacheKey);
3428
3518
  if (cached) return cached;
3429
- const schema = this.globalSettingsSchema(cap);
3430
- const keys = new Set(schema ? schema.sections.flatMap((section) => collectPerNodeFieldKeys(section.fields)) : []);
3431
- this._perNodeKeysCache.set(cacheKey, keys);
3519
+ const legacy = this.globalSettingsSchema(cap);
3520
+ const keys = new Set(legacy ? legacy.sections.flatMap((section) => collectPerNodeFieldKeys(section.fields)) : []);
3521
+ for (const { scope, schema } of this.loadedScopedSchemas(cap)) {
3522
+ if (scope !== "node") continue;
3523
+ for (const section of schema.sections) for (const key of collectValueFieldKeys(section.fields)) keys.add(key);
3524
+ }
3525
+ this._nodeKeysByCap.set(cacheKey, keys);
3432
3526
  return keys;
3433
3527
  }
3434
3528
  /**
@@ -3438,10 +3532,9 @@ var BaseAddon = class {
3438
3532
  * time to return its response before the addon is torn down and
3439
3533
  * re-initialised by `AddonRegistryService.restartAddon`.
3440
3534
  */
3441
- maybeAutoRestart(patchKeys, schema) {
3442
- if (!schema) return;
3535
+ maybeAutoRestart(patchKeys, schemas) {
3443
3536
  const restartKeys = /* @__PURE__ */ new Set();
3444
- for (const section of schema.sections) for (const field of section.fields) {
3537
+ for (const schema of schemas) for (const section of schema.sections) for (const field of section.fields) {
3445
3538
  if (field.type === "separator" || field.type === "info") continue;
3446
3539
  if (field.requiresRestart) restartKeys.add(field.key);
3447
3540
  }
@@ -3637,12 +3730,14 @@ var BaseAddon = class {
3637
3730
  * here, in the addon's own process, so the hub keeps no copy of it.
3638
3731
  */
3639
3732
  async getDeclaredSettingsKeys() {
3733
+ await this.loadScopedSchemas();
3640
3734
  return { keys: [...this.declaredKeySet()].toSorted() };
3641
3735
  }
3642
3736
  declaredKeySet() {
3643
3737
  const keys = new Set(Object.keys(this.defaults));
3644
3738
  const schema = this.globalSettingsSchema();
3645
3739
  if (schema) for (const section of schema.sections) for (const key of collectFieldKeys(section.fields)) keys.add(key);
3740
+ for (const { schema: scoped } of this.loadedScopedSchemas()) for (const section of scoped.sections) for (const key of collectFieldKeys(section.fields)) keys.add(key);
3646
3741
  for (const key of this._declaredStateKeys) keys.add(key);
3647
3742
  for (const path of this.secretStatePaths) {
3648
3743
  const root = path.split(/[.[]/, 1)[0];
@@ -3738,7 +3833,11 @@ var BaseAddon = class {
3738
3833
  }
3739
3834
  /** The addon store's secret tree: schema fields by TYPE, plus `secretStatePaths`. */
3740
3835
  addonSecretTree() {
3741
- this._addonSecretTree ??= mergeSecretStatePaths(secretTreeFromSchema(this.globalSettingsSchema()), this.secretStatePaths);
3836
+ if (this._addonSecretTree === null) {
3837
+ const tree = new Map(secretTreeFromSchema(this.globalSettingsSchema()));
3838
+ for (const { schema } of this.loadedScopedSchemas()) for (const [key, node] of secretTreeFromSchema(schema)) tree.set(key, node);
3839
+ this._addonSecretTree = mergeSecretStatePaths(tree, this.secretStatePaths);
3840
+ }
3742
3841
  return this._addonSecretTree;
3743
3842
  }
3744
3843
  deviceSecretTree() {
@@ -3988,6 +4087,23 @@ function dropPerNodeFields(fields) {
3988
4087
  }
3989
4088
  return kept;
3990
4089
  }
4090
+ /** The keys of the value-holding fields, recursing into layout containers. */
4091
+ function collectValueFieldKeys(fields) {
4092
+ const collected = [];
4093
+ for (const field of fields) {
4094
+ if (field.type === "group") {
4095
+ collected.push(...collectValueFieldKeys(field.fields));
4096
+ continue;
4097
+ }
4098
+ if (field.type === "sub-tabs") {
4099
+ for (const tab of field.tabs) collected.push(...collectValueFieldKeys(tab.fields));
4100
+ continue;
4101
+ }
4102
+ if (field.type === "separator" || field.type === "info") continue;
4103
+ if ("key" in field && typeof field.key === "string") collected.push(field.key);
4104
+ }
4105
+ return collected;
4106
+ }
3991
4107
  function collectFieldKeys(fields) {
3992
4108
  const collected = [];
3993
4109
  for (const field of fields) {
@@ -4033,17 +4149,6 @@ function normalizeAddonInitResult(result) {
4033
4149
  if (Array.isArray(result)) return { providers: result };
4034
4150
  return result;
4035
4151
  }
4036
- /**
4037
- * The node id a node-scoped KEY carries: the part after the `@`. `null` for a key with no `@`
4038
- * (a cluster or fleet-default key) or an empty node id. A schema key never contains `@`
4039
- * (guard `check-scoped-settings-declared`), so the first `@` is the separator.
4040
- */
4041
- function nodeIdOfScopedKey(key) {
4042
- const at = key.indexOf("@");
4043
- if (at <= 0) return null;
4044
- const nodeId = key.slice(at + 1);
4045
- return nodeId === "" ? null : nodeId;
4046
- }
4047
4152
  var PREFIX = "records/";
4048
4153
  /** The base of every records failure. `detail` is the human part of the message. */
4049
4154
  var RecordsError = class extends Error {
@@ -56589,12 +56694,12 @@ var deviceExportCapability = {
56589
56694
  kind: "poll"
56590
56695
  },
56591
56696
  /**
56592
- * Each export provider contributes its own per-device "Export" panel
56593
- * (enabled toggle, preferred stream, addon-specific knobs like the
56594
- * HA-MQTT discovery prefix). The three framework methods
56595
- * `getDeviceSettingsContribution` / `getDeviceLiveContribution` /
56596
- * `applyDeviceSettingsPatch` are auto-injected on the provider
56597
- * interface and routed to the device-details aggregator.
56697
+ * Each export provider MAY contribute its own per-device "Export" panel
56698
+ * (enabled toggle, preferred stream, addon-specific knobs). The three
56699
+ * framework methods are mounted on the cap router when present.
56700
+ * `IDeviceExportProvider` leaves them optional: an exporter with no
56701
+ * per-device panel omits them (a `deviceConfig` cap's UI is derived and
56702
+ * never hand-written — D14 — and an exporter is not one of those).
56598
56703
  */
56599
56704
  exposesDeviceSettings: true,
56600
56705
  methods: {