@camstack/addon-provider-homematic 1.2.135 → 1.2.137

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 (3) hide show
  1. package/dist/addon.js +1759 -141
  2. package/dist/addon.mjs +1759 -141
  3. package/package.json +1 -1
package/dist/addon.mjs CHANGED
@@ -9,7 +9,7 @@ import { join } from "path";
9
9
  var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
10
10
  var __require = /* @__PURE__ */ createRequire(import.meta.url);
11
11
  //#endregion
12
- //#region ../types/dist/event-category-C4hVnRo8.mjs
12
+ //#region ../types/dist/event-category-BvOFi6PY.mjs
13
13
  var EventCategory = /* @__PURE__ */ function(EventCategory) {
14
14
  EventCategory["SystemBoot"] = "system.boot";
15
15
  EventCategory["SystemAddonsReady"] = "system.addons-ready";
@@ -73,6 +73,24 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
73
73
  * consumes this category and maps it to the `addon-crash-loop` kind.
74
74
  */
75
75
  EventCategory["AddonRunnerFailed"] = "addon.runner-failed";
76
+ /**
77
+ * A runner whose addon refused to start with a typed reason (D877) - parked
78
+ * in `refused`, never counted by the crash breaker, retried on operator
79
+ * action. One event per refusal.
80
+ */
81
+ EventCategory["AddonRunnerRefused"] = "addon.runner-refused";
82
+ /**
83
+ * A runner settled on a state (D877): `running` (READY), `crashed`, `failed` or
84
+ * `refused`. In-process telemetry for the boot check (re-evaluate while any
85
+ * runner is still pending) and the alert centre (close a recovered runner).
86
+ */
87
+ EventCategory["ProcessStateChanged"] = "process.state-changed";
88
+ /**
89
+ * The node's one-shot runner boot check (D877): planned runners against the
90
+ * process service, `degraded` when any is failed, refused or missing. The
91
+ * alert centre turns it into one alert and a direct critical push.
92
+ */
93
+ EventCategory["SystemRunnerCheck"] = "system.runner-check";
76
94
  EventCategory["AddonError"] = "addon.error";
77
95
  EventCategory["AddonPageReady"] = "addon.page-ready";
78
96
  EventCategory["AddonWidgetReady"] = "addon.widget-ready";
@@ -4115,6 +4133,12 @@ var numberProcessor = (schema, ctx, _json, _params) => {
4115
4133
  var booleanProcessor = (_schema, _ctx, json, _params) => {
4116
4134
  json.type = "boolean";
4117
4135
  };
4136
+ var bigintProcessor = (_schema, ctx, _json, _params) => {
4137
+ if (ctx.unrepresentable === "throw") throw new Error("BigInt cannot be represented in JSON Schema");
4138
+ };
4139
+ var symbolProcessor = (_schema, ctx, _json, _params) => {
4140
+ if (ctx.unrepresentable === "throw") throw new Error("Symbols cannot be represented in JSON Schema");
4141
+ };
4118
4142
  var nullProcessor = (_schema, ctx, json, _params) => {
4119
4143
  if (ctx.target === "openapi-3.0") {
4120
4144
  json.type = "string";
@@ -4122,12 +4146,17 @@ var nullProcessor = (_schema, ctx, json, _params) => {
4122
4146
  json.enum = [null];
4123
4147
  } else json.type = "null";
4124
4148
  };
4149
+ var undefinedProcessor = (_schema, ctx, _json, _params) => {
4150
+ if (ctx.unrepresentable === "throw") throw new Error("Undefined cannot be represented in JSON Schema");
4151
+ };
4125
4152
  var voidProcessor = (_schema, ctx, _json, _params) => {
4126
4153
  if (ctx.unrepresentable === "throw") throw new Error("Void cannot be represented in JSON Schema");
4127
4154
  };
4128
4155
  var neverProcessor = (_schema, _ctx, json, _params) => {
4129
4156
  json.not = {};
4130
4157
  };
4158
+ var anyProcessor = (_schema, _ctx, _json, _params) => {};
4159
+ var unknownProcessor = (_schema, _ctx, _json, _params) => {};
4131
4160
  var dateProcessor = (_schema, ctx, _json, _params) => {
4132
4161
  if (ctx.unrepresentable === "throw") throw new Error("Date cannot be represented in JSON Schema");
4133
4162
  };
@@ -4159,12 +4188,53 @@ var literalProcessor = (schema, ctx, json, _params) => {
4159
4188
  json.enum = vals;
4160
4189
  }
4161
4190
  };
4191
+ var nanProcessor = (_schema, ctx, _json, _params) => {
4192
+ if (ctx.unrepresentable === "throw") throw new Error("NaN cannot be represented in JSON Schema");
4193
+ };
4194
+ var templateLiteralProcessor = (schema, _ctx, json, _params) => {
4195
+ const _json = json;
4196
+ const pattern = schema._zod.pattern;
4197
+ if (!pattern) throw new Error("Pattern not found in template literal");
4198
+ _json.type = "string";
4199
+ _json.pattern = pattern.source;
4200
+ };
4201
+ var fileProcessor = (schema, _ctx, json, _params) => {
4202
+ const _json = json;
4203
+ const file = {
4204
+ type: "string",
4205
+ format: "binary",
4206
+ contentEncoding: "binary"
4207
+ };
4208
+ const { minimum, maximum, mime } = schema._zod.bag;
4209
+ if (minimum !== void 0) file.minLength = minimum;
4210
+ if (maximum !== void 0) file.maxLength = maximum;
4211
+ if (mime) if (mime.length === 1) {
4212
+ file.contentMediaType = mime[0];
4213
+ Object.assign(_json, file);
4214
+ } else {
4215
+ Object.assign(_json, file);
4216
+ _json.anyOf = mime.map((m) => ({ contentMediaType: m }));
4217
+ }
4218
+ else Object.assign(_json, file);
4219
+ };
4220
+ var successProcessor = (_schema, _ctx, json, _params) => {
4221
+ json.type = "boolean";
4222
+ };
4162
4223
  var customProcessor = (_schema, ctx, _json, _params) => {
4163
4224
  if (ctx.unrepresentable === "throw") throw new Error("Custom types cannot be represented in JSON Schema");
4164
4225
  };
4226
+ var functionProcessor = (_schema, ctx, _json, _params) => {
4227
+ if (ctx.unrepresentable === "throw") throw new Error("Function types cannot be represented in JSON Schema");
4228
+ };
4165
4229
  var transformProcessor = (_schema, ctx, _json, _params) => {
4166
4230
  if (ctx.unrepresentable === "throw") throw new Error("Transforms cannot be represented in JSON Schema");
4167
4231
  };
4232
+ var mapProcessor = (_schema, ctx, _json, _params) => {
4233
+ if (ctx.unrepresentable === "throw") throw new Error("Map cannot be represented in JSON Schema");
4234
+ };
4235
+ var setProcessor = (_schema, ctx, _json, _params) => {
4236
+ if (ctx.unrepresentable === "throw") throw new Error("Set cannot be represented in JSON Schema");
4237
+ };
4168
4238
  var arrayProcessor = (schema, ctx, _json, params) => {
4169
4239
  const json = _json;
4170
4240
  const def = schema._zod.def;
@@ -4369,6 +4439,12 @@ var readonlyProcessor = (schema, ctx, json, params) => {
4369
4439
  seen.ref = def.innerType;
4370
4440
  json.readOnly = true;
4371
4441
  };
4442
+ var promiseProcessor = (schema, ctx, _json, params) => {
4443
+ const def = schema._zod.def;
4444
+ process$1(def.innerType, ctx, params);
4445
+ const seen = ctx.seen.get(schema);
4446
+ seen.ref = def.innerType;
4447
+ };
4372
4448
  var optionalProcessor = (schema, ctx, _json, params) => {
4373
4449
  const def = schema._zod.def;
4374
4450
  process$1(def.innerType, ctx, params);
@@ -4381,6 +4457,81 @@ var lazyProcessor = (schema, ctx, _json, params) => {
4381
4457
  const seen = ctx.seen.get(schema);
4382
4458
  seen.ref = innerType;
4383
4459
  };
4460
+ var allProcessors = {
4461
+ string: stringProcessor,
4462
+ number: numberProcessor,
4463
+ boolean: booleanProcessor,
4464
+ bigint: bigintProcessor,
4465
+ symbol: symbolProcessor,
4466
+ null: nullProcessor,
4467
+ undefined: undefinedProcessor,
4468
+ void: voidProcessor,
4469
+ never: neverProcessor,
4470
+ any: anyProcessor,
4471
+ unknown: unknownProcessor,
4472
+ date: dateProcessor,
4473
+ enum: enumProcessor,
4474
+ literal: literalProcessor,
4475
+ nan: nanProcessor,
4476
+ template_literal: templateLiteralProcessor,
4477
+ file: fileProcessor,
4478
+ success: successProcessor,
4479
+ custom: customProcessor,
4480
+ function: functionProcessor,
4481
+ transform: transformProcessor,
4482
+ map: mapProcessor,
4483
+ set: setProcessor,
4484
+ array: arrayProcessor,
4485
+ object: objectProcessor,
4486
+ union: unionProcessor,
4487
+ intersection: intersectionProcessor,
4488
+ tuple: tupleProcessor,
4489
+ record: recordProcessor,
4490
+ nullable: nullableProcessor,
4491
+ nonoptional: nonoptionalProcessor,
4492
+ default: defaultProcessor,
4493
+ prefault: prefaultProcessor,
4494
+ catch: catchProcessor,
4495
+ pipe: pipeProcessor,
4496
+ readonly: readonlyProcessor,
4497
+ promise: promiseProcessor,
4498
+ optional: optionalProcessor,
4499
+ lazy: lazyProcessor
4500
+ };
4501
+ function toJSONSchema(input, params) {
4502
+ if ("_idmap" in input) {
4503
+ const registry = input;
4504
+ const ctx = initializeContext({
4505
+ ...params,
4506
+ processors: allProcessors
4507
+ });
4508
+ const defs = {};
4509
+ for (const entry of registry._idmap.entries()) {
4510
+ const [_, schema] = entry;
4511
+ process$1(schema, ctx);
4512
+ }
4513
+ const schemas = {};
4514
+ ctx.external = {
4515
+ registry,
4516
+ uri: params?.uri,
4517
+ defs
4518
+ };
4519
+ for (const entry of registry._idmap.entries()) {
4520
+ const [key, schema] = entry;
4521
+ extractDefs(ctx, schema);
4522
+ schemas[key] = finalize(ctx, schema);
4523
+ }
4524
+ if (Object.keys(defs).length > 0) schemas.__shared = { [ctx.target === "draft-2020-12" ? "$defs" : "definitions"]: defs };
4525
+ return { schemas };
4526
+ }
4527
+ const ctx = initializeContext({
4528
+ ...params,
4529
+ processors: allProcessors
4530
+ });
4531
+ process$1(input, ctx);
4532
+ extractDefs(ctx, input);
4533
+ return finalize(ctx, input);
4534
+ }
4384
4535
  //#endregion
4385
4536
  //#region ../../node_modules/zod/v4/classic/iso.js
4386
4537
  var ZodISODateTime = /*@__PURE__*/ $constructor("ZodISODateTime", (inst, def) => {
@@ -5397,7 +5548,7 @@ var ZodIssueCode = {
5397
5548
  var ZodFirstPartyTypeKind;
5398
5549
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
5399
5550
  //#endregion
5400
- //#region ../types/dist/sleep-DRqxtc0C.mjs
5551
+ //#region ../types/dist/sleep-BOjuyoPC.mjs
5401
5552
  /**
5402
5553
  * The audio chunk plane's byte format, and the ONE expansion from a coded
5403
5554
  * window to float samples (D455).
@@ -5514,7 +5665,7 @@ function isKeychainStoredField(field) {
5514
5665
  var SECRET_CLEAR = { $secretClear: true };
5515
5666
  /** The `'***'` token D634 redaction writes for non-admins. */
5516
5667
  var LEGACY_DEVICE_REDACTION = "***";
5517
- function isRecord$2(value) {
5668
+ function isRecord$5(value) {
5518
5669
  return typeof value === "object" && value !== null && !Array.isArray(value);
5519
5670
  }
5520
5671
  function makeSecretMarker(ref) {
@@ -5525,12 +5676,12 @@ function makeSecretMarker(ref) {
5525
5676
  }
5526
5677
  /** A stored marker: an object whose `$secret` is a non-empty string. */
5527
5678
  function isSecretMarker(value) {
5528
- if (!isRecord$2(value)) return false;
5679
+ if (!isRecord$5(value)) return false;
5529
5680
  const ref = value["$secret"];
5530
5681
  return typeof ref === "string" && ref.length > 0;
5531
5682
  }
5532
5683
  function isSecretClear(value) {
5533
- return isRecord$2(value) && value["$secretClear"] === true;
5684
+ return isRecord$5(value) && value["$secretClear"] === true;
5534
5685
  }
5535
5686
  /**
5536
5687
  * The UI view of a stored secret field value: a marker becomes "set", inline
@@ -6140,7 +6291,7 @@ var KeychainWriteRefusedError = class extends Error {
6140
6291
  }
6141
6292
  };
6142
6293
  var KEEP = { kind: "keep" };
6143
- function isRecord$1(value) {
6294
+ function isRecord$4(value) {
6144
6295
  return typeof value === "object" && value !== null && !Array.isArray(value);
6145
6296
  }
6146
6297
  function defaultMintId() {
@@ -6153,7 +6304,7 @@ function collectSecretMarkerRefs(value, out = []) {
6153
6304
  return out;
6154
6305
  }
6155
6306
  if (Array.isArray(value)) for (const item of value) collectSecretMarkerRefs(item, out);
6156
- else if (isRecord$1(value)) for (const child of Object.values(value)) collectSecretMarkerRefs(child, out);
6307
+ else if (isRecord$4(value)) for (const child of Object.values(value)) collectSecretMarkerRefs(child, out);
6157
6308
  return out;
6158
6309
  }
6159
6310
  async function storedValueEquals(secrets, marker, candidate) {
@@ -6208,7 +6359,7 @@ function rowId(row, idKey) {
6208
6359
  return null;
6209
6360
  }
6210
6361
  async function writeArray(ctx, node, incoming, stored, fieldPath) {
6211
- const storedRows = Array.isArray(stored) ? stored.filter(isRecord$1) : [];
6362
+ const storedRows = Array.isArray(stored) ? stored.filter(isRecord$4) : [];
6212
6363
  if (!Array.isArray(incoming)) {
6213
6364
  ctx.deletes.push(...collectSecretMarkerRefs(storedRows));
6214
6365
  return {
@@ -6224,7 +6375,7 @@ async function writeArray(ctx, node, incoming, stored, fieldPath) {
6224
6375
  const kept = /* @__PURE__ */ new Set();
6225
6376
  const rows = [];
6226
6377
  for (const row of incoming) {
6227
- if (!isRecord$1(row)) {
6378
+ if (!isRecord$4(row)) {
6228
6379
  rows.push(row);
6229
6380
  continue;
6230
6381
  }
@@ -6249,7 +6400,7 @@ async function writeNode(ctx, node, incoming, stored, fieldPath) {
6249
6400
  case "leaf": return writeLeaf(ctx, incoming, stored, fieldPath);
6250
6401
  case "array": return writeArray(ctx, node, incoming, stored, fieldPath);
6251
6402
  case "object": {
6252
- if (!isRecord$1(incoming)) {
6403
+ if (!isRecord$4(incoming)) {
6253
6404
  if (incoming === void 0) return KEEP;
6254
6405
  ctx.deletes.push(...collectSecretMarkerRefs(stored));
6255
6406
  return {
@@ -6257,7 +6408,7 @@ async function writeNode(ctx, node, incoming, stored, fieldPath) {
6257
6408
  value: incoming
6258
6409
  };
6259
6410
  }
6260
- const storedObj = isRecord$1(stored) ? stored : {};
6411
+ const storedObj = isRecord$4(stored) ? stored : {};
6261
6412
  return {
6262
6413
  kind: "value",
6263
6414
  value: await writeMembers(ctx, node.children, incoming, storedObj, (m) => `${fieldPath}.${m}`)
@@ -6380,7 +6531,7 @@ async function resolveSecretMarkers(value, secrets, options = {}) {
6380
6531
  value: items
6381
6532
  };
6382
6533
  }
6383
- if (isRecord$1(v)) {
6534
+ if (isRecord$4(v)) {
6384
6535
  const out = {};
6385
6536
  for (const [k, child] of Object.entries(v)) {
6386
6537
  const s = substitute(child);
@@ -6648,7 +6799,6 @@ function createHandle(raw, opts) {
6648
6799
  const writeAddon = (patch) => write("addon", opts.addonTree(), void 0, patch, () => readStoredAddonBlob(raw), (p) => raw.writeAddonStore(p));
6649
6800
  const readAddonStoreResult = raw.readAddonStoreResult;
6650
6801
  const readAddonStoreKeyResult = raw.readAddonStoreKeyResult;
6651
- const readDeviceStoreBatch = raw.readDeviceStoreBatch;
6652
6802
  const overrides = {
6653
6803
  readAddonStore: async () => resolveRead("addon", await raw.readAddonStore()),
6654
6804
  ...readAddonStoreResult !== void 0 ? { readAddonStoreResult: async () => {
@@ -6672,12 +6822,12 @@ function createHandle(raw, opts) {
6672
6822
  };
6673
6823
  } } : {},
6674
6824
  readDeviceStore: async (deviceId) => resolveRead(`device:${deviceId}`, await raw.readDeviceStore(deviceId)),
6675
- ...readDeviceStoreBatch !== void 0 ? { readDeviceStoreBatch: async (deviceIds) => {
6676
- const rows = await readDeviceStoreBatch.call(raw, deviceIds);
6825
+ readDeviceStoreBatch: async (deviceIds) => {
6826
+ const rows = await raw.readDeviceStoreBatch(deviceIds);
6677
6827
  const out = /* @__PURE__ */ new Map();
6678
6828
  for (const [deviceId, blob] of rows) out.set(deviceId, await resolveRead(`device:${deviceId}`, blob));
6679
6829
  return out;
6680
- } } : {},
6830
+ },
6681
6831
  writeAddonStore: async (patch) => {
6682
6832
  await writeAddon(patch);
6683
6833
  },
@@ -7304,7 +7454,7 @@ var BaseAddon = class {
7304
7454
  if (!ctx) return;
7305
7455
  const addonId = ctx.id;
7306
7456
  setImmediate(() => {
7307
- ctx.api.addons?.restartAddon?.mutate({ addonId }).then(() => {
7457
+ ctx.api.addons.restartAddon.mutate({ addonId }).then(() => {
7308
7458
  ctx.logger.info("addon auto-restart triggered by restart-required setting change", { meta: { changedFields: patchKeys.filter((k) => restartKeys.has(k)) } });
7309
7459
  }).catch((err) => {
7310
7460
  ctx.logger.error("addon auto-restart failed", { meta: { error: err instanceof Error ? err.message : String(err) } });
@@ -7504,7 +7654,7 @@ var BaseAddon = class {
7504
7654
  return this._addonSecretTree;
7505
7655
  }
7506
7656
  deviceSecretTree() {
7507
- this._deviceSecretTree ??= secretTreeFromSchema(this.deviceSettingsSchema());
7657
+ this._deviceSecretTree ??= mergeSecretStatePaths(secretTreeFromSchema(this.deviceSettingsSchema()), this.secretStatePaths);
7508
7658
  return this._deviceSecretTree;
7509
7659
  }
7510
7660
  /**
@@ -7580,42 +7730,135 @@ var BaseAddon = class {
7580
7730
  this[timerOf] = timer;
7581
7731
  }
7582
7732
  /**
7583
- * Wrap `ctx.settings.readAddonStore()` with a short retry budget so a
7584
- * transient settings-store outage (mid-restart of sqlite-settings, tsx-watch
7585
- * swap, or any race where the SqliteSettingsBackend is between shutdown and
7586
- * re-initialize) doesn't propagate up into `initialize()` and leave the
7733
+ * Wrap `ctx.settings.readAddonStore()` with a retry budget so a transient
7734
+ * settings-store outage doesn't propagate up into `initialize()` and leave the
7587
7735
  * addon permanently broken.
7588
7736
  *
7589
- * Retry only the two known infra fingerprints. Anything else propagates so
7590
- * real bugs surface immediately. After the budget expires we fall back to
7591
- * `{}` (defaults) — the addon's first successful patch will rehydrate.
7737
+ * Two kinds of outage, two budgets:
7738
+ * - the store's own restart fingerprints (`SqliteSettingsBackend not
7739
+ * initialized`, `provider not available`): a short budget, then the addon
7740
+ * falls back to `{}` (defaults) - its first successful patch rehydrates;
7741
+ * - a TRANSPORT failure (the hub is restarting while this runner boots:
7742
+ * `discovery deadline exceeded`, `parent could not route`, a refused or
7743
+ * timed-out connection). Since D870 a runner's settings read THROWS instead
7744
+ * of answering `{}`, so without a budget a hub restart ends in a respawn
7745
+ * loop. A long, bounded budget; only after it the error propagates - the
7746
+ * addon never runs on defaults for a store it could not ask.
7747
+ * Anything else propagates immediately so real bugs surface.
7592
7748
  */
7593
7749
  async readAddonStoreWithRetry() {
7594
7750
  const settings = this.rawSettings();
7595
7751
  if (!settings) return {};
7596
- const delaysMs = [
7597
- 150,
7598
- 350,
7599
- 600,
7600
- 900
7601
- ];
7602
7752
  let lastErr;
7603
- for (let attempt = 0; attempt <= delaysMs.length; attempt++) try {
7753
+ for (let attempt = 0;; attempt++) try {
7604
7754
  const stored = await settings.readAddonStore() ?? {};
7605
7755
  this.settingsStoreReady = true;
7606
7756
  return stored;
7607
7757
  } catch (err) {
7608
7758
  lastErr = err;
7609
- const msg = err instanceof Error ? err.message : String(err);
7610
- if (!(msg.includes("SqliteSettingsBackend not initialized") || msg.includes("provider not available"))) throw err;
7611
- if (attempt === delaysMs.length) break;
7612
- await new Promise((r) => setTimeout(r, delaysMs[attempt]));
7759
+ const kind = classifyStoreError(err);
7760
+ if (kind === "permanent") throw err;
7761
+ const delay = (kind === "transport" ? TRANSPORT_RETRY_DELAYS_MS : RESTART_RETRY_DELAYS_MS)[attempt];
7762
+ if (delay === void 0) {
7763
+ if (kind === "transport") throw err;
7764
+ break;
7765
+ }
7766
+ await new Promise((r) => setTimeout(r, delay));
7613
7767
  }
7614
7768
  this.settingsStoreReady = false;
7615
7769
  this._ctx?.logger?.warn?.("readAddonStore: settings-store unavailable after retries — using defaults", { meta: { error: lastErr instanceof Error ? lastErr.message : String(lastErr) } });
7616
7770
  return {};
7617
7771
  }
7618
7772
  };
7773
+ /** The settings store's own restart fingerprints. */
7774
+ var RESTART_RETRY_DELAYS_MS = [
7775
+ 150,
7776
+ 350,
7777
+ 600,
7778
+ 900
7779
+ ];
7780
+ /** A hub restarting under a booting runner: ~100 s in total. */
7781
+ var TRANSPORT_RETRY_DELAYS_MS = [
7782
+ 150,
7783
+ 350,
7784
+ 600,
7785
+ 900,
7786
+ 2e3,
7787
+ 5e3,
7788
+ 1e4,
7789
+ 2e4,
7790
+ 3e4,
7791
+ 3e4
7792
+ ];
7793
+ var RESTART_FINGERPRINTS = ["SqliteSettingsBackend not initialized", "provider not available"];
7794
+ /** Node / socket error codes of a connection that did not happen or broke. */
7795
+ var TRANSPORT_CODES = new Set([
7796
+ "ECONNREFUSED",
7797
+ "ECONNRESET",
7798
+ "ETIMEDOUT",
7799
+ "EPIPE",
7800
+ "EHOSTUNREACH",
7801
+ "ENETUNREACH"
7802
+ ]);
7803
+ /** tRPC error codes that mean "the other side is not answering now", not "your call is wrong". */
7804
+ var UNAVAILABLE_TRPC_CODES = new Set([
7805
+ "TIMEOUT",
7806
+ "SERVICE_UNAVAILABLE",
7807
+ "BAD_GATEWAY",
7808
+ "GATEWAY_TIMEOUT"
7809
+ ]);
7810
+ /** The exact phrases OUR transport raises when it cannot reach the hub. */
7811
+ var TRANSPORT_PHRASES = [
7812
+ "discovery deadline exceeded",
7813
+ "parent could not route child unowned cap call",
7814
+ "UDS request timed out after",
7815
+ "channel closed"
7816
+ ];
7817
+ /** Moleculer error `type`s of a call that could not be served right now. */
7818
+ var MOLECULER_TRANSIENT_TYPES = new Set([
7819
+ "REQUEST_TIMEOUT",
7820
+ "SERVICE_NOT_FOUND",
7821
+ "SERVICE_NOT_AVAILABLE",
7822
+ "REQUEST_REJECTED",
7823
+ "BROKER_DISCONNECTED"
7824
+ ]);
7825
+ function stringProp(value, key) {
7826
+ if (typeof value !== "object" || value === null) return void 0;
7827
+ const found = Reflect.get(value, key);
7828
+ return typeof found === "string" ? found : void 0;
7829
+ }
7830
+ /** The code an error carries: its own, its cause's, or a tRPC `data.code`. */
7831
+ function errorCode(err) {
7832
+ const out = {};
7833
+ const cause = typeof err === "object" && err !== null ? Reflect.get(err, "cause") : void 0;
7834
+ const data = typeof err === "object" && err !== null ? Reflect.get(err, "data") : void 0;
7835
+ const node = stringProp(err, "code") ?? stringProp(cause, "code");
7836
+ if (node !== void 0) out.node = node;
7837
+ const trpc = stringProp(data, "code");
7838
+ if (trpc !== void 0) out.trpc = trpc;
7839
+ return out;
7840
+ }
7841
+ /**
7842
+ * Is a settings read failure worth retrying, and with which budget? Only
7843
+ * EXPLICIT signals count: a socket error code, a tRPC "unavailable" code, or
7844
+ * one of the exact phrases our own transport raises. A message that merely
7845
+ * contains "timed out" or "unreachable" is not evidence of anything, and
7846
+ * `settings store not wired` is a wiring bug that retrying cannot fix.
7847
+ */
7848
+ function classifyStoreError(err) {
7849
+ const message = err instanceof Error ? err.message : String(err);
7850
+ if (RESTART_FINGERPRINTS.some((f) => message.includes(f))) return "restart";
7851
+ const code = errorCode(err);
7852
+ if (code.node !== void 0 && TRANSPORT_CODES.has(code.node)) return "transport";
7853
+ if (code.trpc !== void 0 && UNAVAILABLE_TRPC_CODES.has(code.trpc)) return "transport";
7854
+ if (typeof err === "object" && err !== null) {
7855
+ if (Reflect.get(err, "retryable") === true) return "transport";
7856
+ const type = stringProp(err, "type");
7857
+ if (type !== void 0 && MOLECULER_TRANSIENT_TYPES.has(type)) return "transport";
7858
+ }
7859
+ if (TRANSPORT_PHRASES.some((f) => message.includes(f))) return "transport";
7860
+ return "permanent";
7861
+ }
7619
7862
  /**
7620
7863
  * Collect the keys of every field marked `perNode: true`, recursing into
7621
7864
  * layout containers (`group` fields and `sub-tabs` tabs) the same way
@@ -7705,6 +7948,356 @@ var PeerBytesTicketSchema = object({
7705
7948
  */
7706
7949
  declaredBytes: number().int().nonnegative().nullable()
7707
7950
  });
7951
+ /** Limits and names of `ctx.records` (D881). One authority; the engine and the facade read it. */
7952
+ /** The files a kind may live in. `history` is device-history's (D850), never records. */
7953
+ var RECORD_DATABASES = ["settings", "events"];
7954
+ /** The classes of a kind: the `@durable` vocabulary, one authority (replaces the annotation). */
7955
+ var RECORD_CLASSES = [
7956
+ "config",
7957
+ "ledger",
7958
+ "audit",
7959
+ "mirror",
7960
+ "ephemeral"
7961
+ ];
7962
+ var RECORD_DEFAULT_MAX_DATA_BYTES = 64 * 1024;
7963
+ var RECORD_MAX_DATA_BYTES = 1024 * 1024;
7964
+ var RECORD_BATCH_MAX = 1e3;
7965
+ var RECORD_QUERY_MAX = 1e3;
7966
+ /** A kind in the `settings` file may not bound itself above this (D447: high volume is `events`). */
7967
+ var RECORD_SETTINGS_MAX_ROWS = 5e4;
7968
+ var PREFIX = "records/";
7969
+ /** The base of every records failure. `detail` is the human part of the message. */
7970
+ var RecordsError = class extends Error {
7971
+ code;
7972
+ detail;
7973
+ constructor(code, detail) {
7974
+ super(`${PREFIX}${code}: ${detail}`);
7975
+ this.name = "RecordsError";
7976
+ this.code = code;
7977
+ this.detail = detail;
7978
+ }
7979
+ };
7980
+ /** The keychain could not store or serve a value: explicit, never an empty string. */
7981
+ var RecordSecretUnavailableError = class extends RecordsError {
7982
+ constructor(detail) {
7983
+ super("secret-unavailable", detail);
7984
+ this.name = "RecordSecretUnavailableError";
7985
+ }
7986
+ };
7987
+ var InvalidRecordError = class extends RecordsError {
7988
+ constructor(detail) {
7989
+ super("invalid-record", detail);
7990
+ this.name = "InvalidRecordError";
7991
+ }
7992
+ };
7993
+ /** A kind declaration the engine refuses (non-additive change, bad shape, wrong file). */
7994
+ var DeclarationRefusedError = class extends RecordsError {
7995
+ constructor(detail) {
7996
+ super("declaration-refused", detail);
7997
+ this.name = "DeclarationRefusedError";
7998
+ }
7999
+ };
8000
+ function defOf(schema) {
8001
+ const zodBag = Reflect.get(schema, "_zod");
8002
+ if (typeof zodBag !== "object" || zodBag === null) return {};
8003
+ const def = Reflect.get(zodBag, "def");
8004
+ if (typeof def !== "object" || def === null) return {};
8005
+ return def;
8006
+ }
8007
+ function declaredHere(schema) {
8008
+ return globalRegistry.get(schema)?.secret === true;
8009
+ }
8010
+ /** Wrapper kinds whose `innerType` is the field itself. */
8011
+ var WRAPPERS = new Set([
8012
+ "optional",
8013
+ "nullable",
8014
+ "default",
8015
+ "prefault",
8016
+ "catch",
8017
+ "readonly",
8018
+ "nonoptional"
8019
+ ]);
8020
+ /**
8021
+ * The schema layers that make up ONE field: the schema itself and every
8022
+ * wrapper below it (optional / default / nullable / readonly / catch), plus
8023
+ * both sides of a pipe (`z.preprocess` puts the real schema on `out`,
8024
+ * `.transform` on `in`).
8025
+ */
8026
+ function layersOf(schema) {
8027
+ const out = [];
8028
+ const queue = [schema];
8029
+ while (queue.length > 0) {
8030
+ const s = queue.shift();
8031
+ if (!s || out.includes(s)) continue;
8032
+ out.push(s);
8033
+ const def = defOf(s);
8034
+ if (def.type !== void 0 && WRAPPERS.has(def.type) && def.innerType) queue.push(def.innerType);
8035
+ if (def.type === "pipe") {
8036
+ if (def.in) queue.push(def.in);
8037
+ if (def.out) queue.push(def.out);
8038
+ }
8039
+ }
8040
+ return out;
8041
+ }
8042
+ /** True when any layer of this field declares `.meta({ secret: true })`. */
8043
+ function isZodSecret(schema) {
8044
+ return layersOf(schema).some(declaredHere);
8045
+ }
8046
+ /**
8047
+ * Every declared secret path in a config schema: dotted keys, `[]` for "each
8048
+ * element of this array" (`connection.password`, `rows[].token`). A declared
8049
+ * object or array is reported as one path and not descended into — everything
8050
+ * under it is secret.
8051
+ */
8052
+ function collectZodSecretPaths(schema, prefix = "") {
8053
+ if (isZodSecret(schema)) return prefix.length > 0 ? [prefix] : [];
8054
+ const paths = [];
8055
+ for (const layer of layersOf(schema)) {
8056
+ const def = defOf(layer);
8057
+ if (def.type === "object" && def.shape) for (const [key, child] of Object.entries(def.shape)) paths.push(...collectZodSecretPaths(child, prefix ? `${prefix}.${key}` : key));
8058
+ else if (def.type === "array" && def.element) paths.push(...collectZodSecretPaths(def.element, `${prefix}[]`));
8059
+ else if (def.type === "union" && def.options) for (const option of def.options) paths.push(...collectZodSecretPaths(option, prefix));
8060
+ else if (def.type === "intersection") {
8061
+ if (def.left) paths.push(...collectZodSecretPaths(def.left, prefix));
8062
+ if (def.right) paths.push(...collectZodSecretPaths(def.right, prefix));
8063
+ }
8064
+ }
8065
+ return [...new Set(paths)];
8066
+ }
8067
+ /**
8068
+ * Secret fields of a record, addressed the way a Zod schema declares them
8069
+ * (`collectZodSecretPaths`): dotted keys, `[]` for "each element of this array"
8070
+ * (`auth.accessToken`, `headers[].value`).
8071
+ *
8072
+ * Array elements are matched by a DECLARED id key (`secretArrayKeys`:
8073
+ * `{ headers: 'name' }`), never by index, so reordering a list keeps every
8074
+ * keychain ref (the same rule as `arrayItemFieldPath`). The concrete path of a
8075
+ * leaf names its element: `headers[X-Api].value`.
8076
+ *
8077
+ * Pure and browser-safe. Nothing here mutates: every transform returns a new value.
8078
+ */
8079
+ /** The array prefixes (declared form, e.g. `headers` or `a.headers`) of a path. */
8080
+ function parseSecretPath(path) {
8081
+ if (path.length === 0) throw new InvalidRecordError("an empty secret path");
8082
+ return path.split(".").map((raw) => {
8083
+ const each = raw.endsWith("[]");
8084
+ const key = each ? raw.slice(0, -2) : raw;
8085
+ if (key.length === 0) throw new InvalidRecordError(`secret path "${path}" has an empty segment`);
8086
+ return {
8087
+ key,
8088
+ each
8089
+ };
8090
+ });
8091
+ }
8092
+ /** The declared array prefixes of `path` that need an id key (`headers`, `a.rows`). */
8093
+ function secretArrayPrefixes(path) {
8094
+ const segments = parseSecretPath(path);
8095
+ const prefixes = [];
8096
+ const walked = [];
8097
+ for (const segment of segments) {
8098
+ walked.push(segment.key);
8099
+ if (segment.each) prefixes.push(walked.join("."));
8100
+ }
8101
+ return prefixes;
8102
+ }
8103
+ /**
8104
+ * Record kinds (D881): the declaration an addon makes of one kind of fact, the
8105
+ * Zod row schema that describes it, and the helper that turns the two into the
8106
+ * JSON the engine stores.
8107
+ *
8108
+ * A kind is declared ONCE, next to the code that owns it, and the engine's
8109
+ * reconciler creates its indexes - nothing creates DDL at runtime from a write.
8110
+ * Everything the generic machinery needs (secret fields, the entry descriptor)
8111
+ * is DERIVED from the Zod schema: `.meta({ secret: true })` marks a credential,
8112
+ * never a field name (D879).
8113
+ */
8114
+ /** A JSON field path: `trackId`, `auth.accessToken`. Charset-restricted: it is rendered into DDL. */
8115
+ var RecordFieldPathSchema = string().regex(/^[A-Za-z_][A-Za-z0-9_]{0,63}(\.[A-Za-z_][A-Za-z0-9_]{0,63}){0,3}$/);
8116
+ var RecordIndexSchema = object({
8117
+ name: string().regex(/^[a-z][a-z0-9_]{0,31}$/),
8118
+ fields: array(RecordFieldPathSchema).min(1).max(4),
8119
+ unique: boolean().optional()
8120
+ }).strict();
8121
+ var RecordRetentionSchema = union([
8122
+ object({
8123
+ ttlMs: number().int().positive(),
8124
+ from: _enum(["at", "write"])
8125
+ }).strict(),
8126
+ object({
8127
+ maxRows: number().int().positive().optional(),
8128
+ maxRowsPerDevice: number().int().positive().optional()
8129
+ }).strict().refine((r) => r.maxRows !== void 0 || r.maxRowsPerDevice !== void 0, { message: "name maxRows, maxRowsPerDevice or both" }),
8130
+ object({
8131
+ owner: string().min(1),
8132
+ reason: string().min(1)
8133
+ }).strict(),
8134
+ object({ none: string().min(1) }).strict()
8135
+ ]);
8136
+ /** The descriptor a generic entries UI reads (D881 "generic entries"). */
8137
+ var EntryDescriptorSchema = object({
8138
+ title: string().min(1),
8139
+ /** The record body field shown as the entry's name. */
8140
+ nameField: string().min(1),
8141
+ /** JSON Schema of the entry body; `secret: true` marks a password field. */
8142
+ fields: record(string(), unknown())
8143
+ }).strict();
8144
+ /** What crosses the wire and sits in the engine's catalog: JSON only, no Zod. */
8145
+ var RecordKindDeclarationSchema = object({
8146
+ database: _enum(RECORD_DATABASES).default("settings"),
8147
+ class: _enum(RECORD_CLASSES),
8148
+ writeTrigger: string().min(1),
8149
+ device: _enum([
8150
+ "required",
8151
+ "optional",
8152
+ "none"
8153
+ ]).default("none"),
8154
+ at: _enum(["required", "none"]).default("none"),
8155
+ indexes: array(RecordIndexSchema).max(8).default([]),
8156
+ retention: RecordRetentionSchema,
8157
+ deviceRemoval: _enum(["delete", "none"]).default("none"),
8158
+ maxDataBytes: number().int().positive().max(RECORD_MAX_DATA_BYTES).default(RECORD_DEFAULT_MAX_DATA_BYTES),
8159
+ /** Derived from the Zod schema; never written by hand. */
8160
+ secretPaths: array(string().min(1)).default([]),
8161
+ /** The id key of each array that carries a secret (`{ headers: 'name' }`). */
8162
+ secretArrayKeys: record(string(), string()).default({}),
8163
+ /** The legacy table this kind adopts from; the boot guard reads it (D853: no migration code). */
8164
+ adoptsFrom: string().min(1).optional(),
8165
+ /** Kinds that must agree through `transact` sit in one file under one family name. */
8166
+ transactFamily: string().min(1).optional(),
8167
+ entry: EntryDescriptorSchema.optional()
8168
+ }).strict();
8169
+ /** The kind names: lower-case, dash separated, short enough for an index name. */
8170
+ var RecordKindNameSchema = string().regex(/^[a-z][a-z0-9-]{0,47}$/);
8171
+ /** Cross-field rules a declaration must satisfy. Throws {@link DeclarationRefusedError}. */
8172
+ function assertValidDeclaration(name, decl) {
8173
+ const refuse = (why) => {
8174
+ throw new DeclarationRefusedError(`kind "${name}": ${why}`);
8175
+ };
8176
+ if (!RecordKindNameSchema.safeParse(name).success) refuse("the name must be lower-case-dashed");
8177
+ const seen = /* @__PURE__ */ new Set();
8178
+ for (const index of decl.indexes) {
8179
+ if (seen.has(index.name)) refuse(`index name "${index.name}" is declared twice`);
8180
+ seen.add(index.name);
8181
+ }
8182
+ const { retention } = decl;
8183
+ const hasSecrets = decl.secretPaths.length > 0;
8184
+ if ("ttlMs" in retention) {
8185
+ if (retention.from === "at" && decl.at !== "required") refuse("a ttl from \"at\" needs at: \"required\"");
8186
+ if (hasSecrets) refuse("a kind with secret fields cannot use engine TTL (its keychain values would be orphaned)");
8187
+ }
8188
+ if ("maxRows" in retention || "maxRowsPerDevice" in retention) {
8189
+ if (retention.maxRowsPerDevice !== void 0 && decl.device !== "required") refuse("maxRowsPerDevice needs device: \"required\"");
8190
+ if (decl.at !== "required") refuse("a row bound trims the oldest \"at\": it needs at: \"required\"");
8191
+ if (hasSecrets) refuse("a kind with secret fields cannot use an engine row bound");
8192
+ const bound = Math.max(retention.maxRows ?? 0, retention.maxRowsPerDevice ?? 0);
8193
+ if (decl.database === "settings" && bound > 5e4) refuse(`a row bound above ${RECORD_SETTINGS_MAX_ROWS} belongs in database: "events" (a big delete on the settings thread stalls every configuration read)`);
8194
+ }
8195
+ if (decl.deviceRemoval === "delete" && decl.device === "none") refuse("deviceRemoval: \"delete\" needs a device: \"required\" or \"optional\"");
8196
+ for (const path of decl.secretPaths) for (const prefix of secretArrayPrefixes(path)) if (decl.secretArrayKeys[prefix] === void 0) refuse(`secret path "${path}" crosses the array "${prefix}": declare its id key in secretArrayKeys`);
8197
+ }
8198
+ function bodyFieldsOf(schema) {
8199
+ return { ...toJSONSchema(schema, {
8200
+ unrepresentable: "any",
8201
+ io: "input"
8202
+ }) };
8203
+ }
8204
+ function isRecordLike(value) {
8205
+ return typeof value === "object" && value !== null && !Array.isArray(value);
8206
+ }
8207
+ /** Does every branch of the body schema carry `field`? (A discriminated union has several.) */
8208
+ function hasNameField(json, field) {
8209
+ const branches = json["oneOf"] ?? json["anyOf"];
8210
+ if (Array.isArray(branches)) return branches.length > 0 && branches.every((b) => isRecordLike(b) && hasNameField(b, field));
8211
+ const properties = json["properties"];
8212
+ return isRecordLike(properties) && Object.prototype.hasOwnProperty.call(properties, field);
8213
+ }
8214
+ /**
8215
+ * Declare the kinds of a package. The keys are the kind names. The result is
8216
+ * what `ctx.records.declare` sends to the engine and what `ctx.records.kind`
8217
+ * types its handle from.
8218
+ */
8219
+ function defineRecordKinds(specs) {
8220
+ const out = {};
8221
+ for (const [name, spec] of Object.entries(specs)) {
8222
+ const secretPaths = collectZodSecretPaths(spec.schema);
8223
+ const nameField = spec.entry?.nameField ?? "name";
8224
+ const fields = bodyFieldsOf(spec.schema);
8225
+ if (spec.entry !== void 0 && !hasNameField(fields, nameField)) throw new DeclarationRefusedError(`kind "${name}": an entry kind's schema needs a "${nameField}" field`);
8226
+ const parsed = RecordKindDeclarationSchema.parse({
8227
+ database: spec.database,
8228
+ class: spec.class,
8229
+ writeTrigger: spec.writeTrigger,
8230
+ device: spec.device,
8231
+ at: spec.at,
8232
+ indexes: spec.indexes === void 0 ? void 0 : [...spec.indexes],
8233
+ retention: spec.retention,
8234
+ deviceRemoval: spec.deviceRemoval,
8235
+ maxDataBytes: spec.maxDataBytes,
8236
+ secretPaths: [...secretPaths],
8237
+ secretArrayKeys: spec.secretArrayKeys === void 0 ? void 0 : { ...spec.secretArrayKeys },
8238
+ adoptsFrom: spec.adoptsFrom,
8239
+ transactFamily: spec.transactFamily,
8240
+ entry: spec.entry === void 0 ? void 0 : {
8241
+ title: spec.entry.title,
8242
+ nameField,
8243
+ fields
8244
+ }
8245
+ });
8246
+ assertValidDeclaration(name, parsed);
8247
+ out[name] = {
8248
+ name,
8249
+ schema: spec.schema,
8250
+ declaration: parsed
8251
+ };
8252
+ }
8253
+ return out;
8254
+ }
8255
+ /**
8256
+ * Entry kinds (D881): every list of user-created entries (notification
8257
+ * targets, brokers, LLM profiles) is ONE record kind with an id, a name and a
8258
+ * kind-specific body, and the admin UI lists/adds/edits/deletes all of them
8259
+ * through the `record-entries` capability with password fields derived from
8260
+ * the schema (`.meta({ secret: true })`).
8261
+ */
8262
+ /** The body of a plain entry: a name and the fields the kind adds. */
8263
+ function entryBody(shape) {
8264
+ return object({
8265
+ name: string().min(1),
8266
+ ...shape
8267
+ });
8268
+ }
8269
+ /**
8270
+ * Declare one entry kind. An entry is configuration: never trimmed by the
8271
+ * engine, never aged, belonging to no device.
8272
+ */
8273
+ function defineEntryKind(name, spec) {
8274
+ const defined = defineRecordKinds({ [name]: {
8275
+ schema: spec.schema,
8276
+ class: "config",
8277
+ writeTrigger: spec.writeTrigger ?? "an operator adds or edits an entry in the entries UI",
8278
+ retention: { none: "an entry goes only when the operator deletes it" },
8279
+ ...spec.database === void 0 ? {} : { database: spec.database },
8280
+ ...spec.indexes === void 0 ? {} : { indexes: spec.indexes },
8281
+ ...spec.secretArrayKeys === void 0 ? {} : { secretArrayKeys: spec.secretArrayKeys },
8282
+ ...spec.adoptsFrom === void 0 ? {} : { adoptsFrom: spec.adoptsFrom },
8283
+ entry: {
8284
+ title: spec.title,
8285
+ ...spec.nameField === void 0 ? {} : { nameField: spec.nameField }
8286
+ }
8287
+ } })[name];
8288
+ if (defined === void 0) throw new DeclarationRefusedError(`entry kind "${name}" was not built`);
8289
+ return defined;
8290
+ }
8291
+ /**
8292
+ * Legacy source for broker entry adoption (B2): brokers live in addon-settings
8293
+ * as one row `<addonId>.brokers` whose value is an array until records-adopt
8294
+ * copies them into the entry kind.
8295
+ */
8296
+ var SETTINGS_BROKERS_ADOPTS_PREFIX = "@settings-brokers/";
8297
+ /** The `adoptsFrom` value for an addon's broker entry kind. */
8298
+ function settingsBrokersAdoptsFrom(addonId) {
8299
+ return `${SETTINGS_BROKERS_ADOPTS_PREFIX}${addonId}`;
8300
+ }
7708
8301
  /** Shared Zod schemas used across streaming capabilities. */
7709
8302
  var CamProfileSchema = _enum([
7710
8303
  "high",
@@ -8169,75 +8762,12 @@ method(object({ deviceId: number() }), array(StreamSourceEntrySchema)), method(o
8169
8762
  kind: "mutation",
8170
8763
  auth: "admin"
8171
8764
  }), method(object({ deviceId: number() }), unknown().nullable()), method(object({ deviceId: number() }), RawStateResultSchema.nullable(), { auth: "protected" });
8172
- function defOf(schema) {
8173
- return schema._zod?.def ?? {};
8174
- }
8175
- function declaredHere(schema) {
8176
- return globalRegistry.get(schema)?.secret === true;
8177
- }
8178
- /** Wrapper kinds whose `innerType` is the field itself. */
8179
- var WRAPPERS = new Set([
8180
- "optional",
8181
- "nullable",
8182
- "default",
8183
- "prefault",
8184
- "catch",
8185
- "readonly",
8186
- "nonoptional"
8187
- ]);
8188
- /**
8189
- * The schema layers that make up ONE field: the schema itself and every
8190
- * wrapper below it (optional / default / nullable / readonly / catch), plus
8191
- * both sides of a pipe (`z.preprocess` puts the real schema on `out`,
8192
- * `.transform` on `in`).
8193
- */
8194
- function layersOf(schema) {
8195
- const out = [];
8196
- const queue = [schema];
8197
- while (queue.length > 0) {
8198
- const s = queue.shift();
8199
- if (!s || out.includes(s)) continue;
8200
- out.push(s);
8201
- const def = defOf(s);
8202
- if (def.type !== void 0 && WRAPPERS.has(def.type) && def.innerType) queue.push(def.innerType);
8203
- if (def.type === "pipe") {
8204
- if (def.in) queue.push(def.in);
8205
- if (def.out) queue.push(def.out);
8206
- }
8207
- }
8208
- return out;
8209
- }
8210
- /** True when any layer of this field declares `.meta({ secret: true })`. */
8211
- function isZodSecret(schema) {
8212
- return layersOf(schema).some(declaredHere);
8213
- }
8214
- /**
8215
- * Every declared secret path in a config schema: dotted keys, `[]` for "each
8216
- * element of this array" (`connection.password`, `rows[].token`). A declared
8217
- * object or array is reported as one path and not descended into — everything
8218
- * under it is secret.
8219
- */
8220
- function collectZodSecretPaths(schema, prefix = "") {
8221
- if (isZodSecret(schema)) return prefix.length > 0 ? [prefix] : [];
8222
- const paths = [];
8223
- for (const layer of layersOf(schema)) {
8224
- const def = defOf(layer);
8225
- if (def.type === "object" && def.shape) for (const [key, child] of Object.entries(def.shape)) paths.push(...collectZodSecretPaths(child, prefix ? `${prefix}.${key}` : key));
8226
- else if (def.type === "array" && def.element) paths.push(...collectZodSecretPaths(def.element, `${prefix}[]`));
8227
- else if (def.type === "union" && def.options) for (const option of def.options) paths.push(...collectZodSecretPaths(option, prefix));
8228
- else if (def.type === "intersection") {
8229
- if (def.left) paths.push(...collectZodSecretPaths(def.left, prefix));
8230
- if (def.right) paths.push(...collectZodSecretPaths(def.right, prefix));
8231
- }
8232
- }
8233
- return [...new Set(paths)];
8234
- }
8235
8765
  object({
8236
8766
  code: string().regex(/^[a-z][a-z0-9-]*(\.[a-z0-9-]+)+$/),
8237
8767
  params: record(string(), union([string(), number()])).optional()
8238
8768
  });
8239
8769
  //#endregion
8240
- //#region ../types/dist/err-msg-DLerKiVO.mjs
8770
+ //#region ../types/dist/err-msg-BXKzRBwg.mjs
8241
8771
  var DeviceType = /* @__PURE__ */ function(DeviceType) {
8242
8772
  DeviceType["Camera"] = "camera";
8243
8773
  DeviceType["Hub"] = "hub";
@@ -8329,6 +8859,10 @@ var DeviceType = /* @__PURE__ */ function(DeviceType) {
8329
8859
  * native PetKit (`nodepetkit` `FeederDevice`), reusable by other feeder
8330
8860
  * integrations sharing the same food/desiccant/hopper surface. */
8331
8861
  DeviceType["PetFeeder"] = "pet-feeder";
8862
+ /** Built-in dishwasher — program lifecycle, door / remote-start gates,
8863
+ * salt and rinse-aid levels. Installed with the `dishwasher` cap.
8864
+ * Sources: native Bosch Home Connect, reusable by similar integrations. */
8865
+ DeviceType["Dishwasher"] = "dishwasher";
8332
8866
  return DeviceType;
8333
8867
  }({});
8334
8868
  var DeviceFeature = /* @__PURE__ */ function(DeviceFeature) {
@@ -8506,6 +9040,9 @@ var DeviceRole = /* @__PURE__ */ function(DeviceRole) {
8506
9040
  /** Virtual HA toggle (input_boolean.*) — distinguishable from a
8507
9041
  * real Switch device for UI rendering / export adapters. */
8508
9042
  DeviceRole["BinaryHelper"] = "binary-helper";
9043
+ /** A smart plug: a `switch` whose source says it is an outlet (HA
9044
+ * `device_class: outlet`). The Alexa export shows it as a SMARTPLUG. */
9045
+ DeviceRole["Outlet"] = "outlet";
8509
9046
  /** Generic motion / occupancy / moving event source. Distinct from
8510
9047
  * the camera accessory PirSensor role: that one is a camera child;
8511
9048
  * this is a standalone HA / 3rd-party motion sensor. */
@@ -8583,7 +9120,7 @@ function errMsg(err) {
8583
9120
  return String(err);
8584
9121
  }
8585
9122
  //#endregion
8586
- //#region ../types/dist/composition-EQ9Ok0Ee.mjs
9123
+ //#region ../types/dist/composition-CB6PMT9p.mjs
8587
9124
  /**
8588
9125
  * The ffmpeg build every CamStack node downloads, per platform and arch.
8589
9126
  *
@@ -11787,11 +12324,10 @@ var ClipModelMetaSchema = object({
11787
12324
  /**
11788
12325
  * The `vector-store` index this model's vectors live in. ONE feature space
11789
12326
  * per index: two models share an index only when their vectors are ranked
11790
- * against each other, which for CLIP means never across families. MobileCLIP
11791
- * S1 and S2 share `object-clip` for history (separated by the row's
11792
- * `modelId`); any other model gets its own.
12327
+ * against each other, which for CLIP means never across families. Every
12328
+ * model gets its own.
11793
12329
  */
11794
- vectorIndex: string().regex(/^object-clip(-[a-z0-9][a-z0-9-]*)?$/),
12330
+ vectorIndex: string().regex(/^object-clip-[a-z0-9][a-z0-9-]*$/),
11795
12331
  /**
11796
12332
  * The text encoder's tokenizer, a declared SIBLING file of its onnx. The name
11797
12333
  * must be unique per tokenizer: every model's siblings land in ONE flat
@@ -12970,8 +13506,13 @@ var AlertSeveritySchema = _enum([
12970
13506
  "info",
12971
13507
  "success",
12972
13508
  "warning",
12973
- "error"
13509
+ "error",
13510
+ "critical"
12974
13511
  ]);
13512
+ var AlertActionSchema = object({
13513
+ label: string(),
13514
+ href: string().optional()
13515
+ });
12975
13516
  var AlertStatusSchema = _enum([
12976
13517
  "active",
12977
13518
  "in-progress",
@@ -12989,6 +13530,7 @@ var AlertSchema = object({
12989
13530
  severity: AlertSeveritySchema,
12990
13531
  title: string(),
12991
13532
  message: string(),
13533
+ action: AlertActionSchema.optional(),
12992
13534
  status: AlertStatusSchema,
12993
13535
  progress: number().optional(),
12994
13536
  read: boolean(),
@@ -15573,6 +16115,41 @@ var ComposableCapabilitiesSchema = object({ caps: array(object({
15573
16115
  keyField: string()
15574
16116
  }).optional()
15575
16117
  })) });
16118
+ /**
16119
+ * The report of a one-shot "move this owner's plaintext secrets into the
16120
+ * keychain" run (D878). COUNTS only - never a value, never a ref.
16121
+ *
16122
+ * The owner runs it on its own rows, through its own write path; an operator
16123
+ * script (`scripts/hub/migrate-raw-secrets.ts`) calls the owner's cap method.
16124
+ * Dry run (`apply: false`) reports what WOULD move and changes nothing.
16125
+ */
16126
+ var RawSecretMigrationInputSchema = object({
16127
+ /** `false` (the default of the script) = report only. */
16128
+ apply: boolean() });
16129
+ var RawSecretMigrationReportSchema = object({
16130
+ apply: boolean(),
16131
+ /** Rows that can carry a secret (a profile, an enrolment). */
16132
+ rows: number().int(),
16133
+ /** Rows whose secret was plaintext when the run started. */
16134
+ raw: number().int(),
16135
+ /** Rows that already held a keychain marker when the run started. */
16136
+ markers: number().int(),
16137
+ /** Plaintext rows moved by THIS run (always 0 on a dry run). */
16138
+ migrated: number().int(),
16139
+ /** Plaintext rows left in place because the move or its read-back failed. */
16140
+ failed: number().int(),
16141
+ /** After the run: rows still holding plaintext. */
16142
+ remainingRaw: number().int(),
16143
+ /** After the run: markers the keychain could not resolve right now. */
16144
+ unresolvedMarkers: number().int(),
16145
+ /**
16146
+ * A second, redundant copy of the secrets' rows that the run found (and, on
16147
+ * `apply`, deleted after verifying the first). Owners with a single copy omit it.
16148
+ */
16149
+ redundantCopies: number().int().optional(),
16150
+ /** True when nothing is raw and every marker resolves. */
16151
+ verified: boolean()
16152
+ });
15576
16153
  /** Where a block runs. The operator chooses — a block driving a device on an
15577
16154
  * agent is the reason placement is not fixed to the hub. */
15578
16155
  var CoreBlockPlacementSchema = union([literal("hub"), string().min(1)]);
@@ -15799,6 +16376,9 @@ method(object({}), object({ blocks: array(CoreBlockSchema) }), { auth: "admin" }
15799
16376
  }), SettingsUpdateResultSchema, {
15800
16377
  kind: "mutation",
15801
16378
  auth: "admin"
16379
+ }), method(RawSecretMigrationInputSchema, RawSecretMigrationReportSchema, {
16380
+ kind: "mutation",
16381
+ auth: "admin"
15802
16382
  }), method(object({}), object({ libs: array(object({
15803
16383
  filePath: string(),
15804
16384
  content: string()
@@ -16062,6 +16642,347 @@ id: union([string(), number()]) }), {
16062
16642
  auth: "admin"
16063
16643
  });
16064
16644
  /**
16645
+ * records - an addon's own facts and documents (D881): ledgers, audit rows,
16646
+ * config documents, mirrors. The third storage API next to `ctx.settings`
16647
+ * (operator intent, D870) and device-history (numbers over time, D850).
16648
+ *
16649
+ * Who the OWNER is: `callerAddonId`, stamped by the transport on a call that
16650
+ * crossed a process and stated by a hub in-process caller (`ctx.records` does
16651
+ * that with the addon id closed over). It is deliberately NOT in any input
16652
+ * schema, so a session can never supply it, and a call with no stamp is refused
16653
+ * `records/no-caller`. A kind is readable and writable only by its owner; other
16654
+ * addons go through the owner's capability.
16655
+ *
16656
+ * Every read is three-way: a row, `null`, or the call THROWS. A failed read is
16657
+ * never `[]`. Secret fields are never on the wire: a read shows the
16658
+ * redaction token, `secretRefs` hands the owner's `ctx.secrets` the refs it
16659
+ * resolves itself, and a write may carry only a keychain marker bound to the
16660
+ * row's own ref.
16661
+ *
16662
+ * Internal: addons reach it through `ctx.records`, never directly.
16663
+ */
16664
+ var RecordIdSchema = string().min(1).max(256);
16665
+ /** A JSON object body. Size is the engine's check (`maxDataBytes`), not a schema's. */
16666
+ var RecordBodySchema = record(string(), unknown());
16667
+ var RecordInputSchema = object({
16668
+ id: RecordIdSchema,
16669
+ /** The device this row belongs to (D865 removal, per-device reads). */
16670
+ deviceId: number().int().optional(),
16671
+ /** The domain clock, ms: observed / created / opened. */
16672
+ at: number().int().optional(),
16673
+ /** Producer-set expiry, ms. Refused on a kind whose retention is an engine TTL. */
16674
+ expiresAt: number().int().optional(),
16675
+ data: RecordBodySchema
16676
+ });
16677
+ var RecordViewSchema = object({
16678
+ id: string(),
16679
+ deviceId: number().int().nullable(),
16680
+ at: number().nullable(),
16681
+ expiresAt: number().nullable(),
16682
+ rev: number().int(),
16683
+ updatedAt: number(),
16684
+ data: RecordBodySchema
16685
+ });
16686
+ /** Declared index fields only. Anything else does not compile, by design. */
16687
+ var RecordWhereSchema = record(RecordFieldPathSchema, union([
16688
+ string(),
16689
+ number(),
16690
+ boolean(),
16691
+ object({ in: array(union([
16692
+ string(),
16693
+ number(),
16694
+ boolean()
16695
+ ])).min(1).max(RECORD_BATCH_MAX) }),
16696
+ object({
16697
+ gt: union([string(), number()]).optional(),
16698
+ gte: union([string(), number()]).optional(),
16699
+ lt: union([string(), number()]).optional(),
16700
+ lte: union([string(), number()]).optional()
16701
+ }).refine((r) => Object.keys(r).length > 0, { message: "name at least one bound" })
16702
+ ]));
16703
+ var KindShape = { kind: RecordKindNameSchema };
16704
+ var TimeWindowShape = {
16705
+ deviceId: number().int().optional(),
16706
+ atFrom: number().optional(),
16707
+ atTo: number().optional()
16708
+ };
16709
+ var RecordQueryInputSchema = object({
16710
+ ...KindShape,
16711
+ ...TimeWindowShape,
16712
+ where: RecordWhereSchema.optional(),
16713
+ /** Without `where`: `at` (default for a kind with a clock) or `id`. With `where` the order is the index's. */
16714
+ order: _enum(["at", "id"]).optional(),
16715
+ desc: boolean().optional(),
16716
+ limit: number().int().min(1).max(RECORD_QUERY_MAX).default(100),
16717
+ /** Opaque keyset cursor from a previous answer. There is no offset. */
16718
+ cursor: string().min(1).optional()
16719
+ });
16720
+ var RecordQueryResultSchema = object({
16721
+ records: array(RecordViewSchema),
16722
+ nextCursor: string().nullable()
16723
+ });
16724
+ var RecordKindStateSchema = _enum([
16725
+ "created",
16726
+ "unchanged",
16727
+ "updated"
16728
+ ]);
16729
+ var DeclareKindResultSchema = object({
16730
+ kindId: number().int(),
16731
+ state: RecordKindStateSchema,
16732
+ createdIndexes: array(string()),
16733
+ /** The boot guard: the kind is empty while its legacy table still holds rows. */
16734
+ adoptionPending: object({
16735
+ legacyTable: string(),
16736
+ legacyRows: number().int()
16737
+ }).nullable()
16738
+ });
16739
+ /** Keychain refs a write released (the old marker is gone from the row): the owner deletes the values. */
16740
+ var SecretRefsList = array(string());
16741
+ var RecordSecretRefsSchema = record(string(), record(string(), string()));
16742
+ method(object({ kinds: record(RecordKindNameSchema, RecordKindDeclarationSchema) }), object({ kinds: record(string(), DeclareKindResultSchema) }), {
16743
+ kind: "mutation",
16744
+ auth: "admin"
16745
+ }), method(object({
16746
+ ...KindShape,
16747
+ id: RecordIdSchema
16748
+ }), RecordViewSchema.nullable(), { auth: "admin" }), method(object({
16749
+ ...KindShape,
16750
+ ids: array(RecordIdSchema).min(1).max(RECORD_BATCH_MAX)
16751
+ }), array(RecordViewSchema), { auth: "admin" }), method(object({
16752
+ ...KindShape,
16753
+ ids: array(RecordIdSchema).min(1).max(RECORD_BATCH_MAX)
16754
+ }), RecordSecretRefsSchema, { auth: "admin" }), method(object({
16755
+ ...KindShape,
16756
+ record: RecordInputSchema,
16757
+ /** Compare-and-set. `0` means "the row must not exist". */
16758
+ ifRev: number().int().min(0).optional()
16759
+ }), object({
16760
+ rev: number().int(),
16761
+ releasedRefs: SecretRefsList
16762
+ }), {
16763
+ kind: "mutation",
16764
+ auth: "admin"
16765
+ }), method(object({
16766
+ ...KindShape,
16767
+ records: array(RecordInputSchema).min(1).max(RECORD_BATCH_MAX)
16768
+ }), object({
16769
+ count: number().int(),
16770
+ releasedRefs: SecretRefsList
16771
+ }), {
16772
+ kind: "mutation",
16773
+ auth: "admin"
16774
+ }), method(object({
16775
+ ...KindShape,
16776
+ id: RecordIdSchema,
16777
+ data: RecordBodySchema,
16778
+ at: number().int().nullable().optional(),
16779
+ expiresAt: number().int().nullable().optional(),
16780
+ ifRev: number().int().min(1).optional()
16781
+ }), object({
16782
+ rev: number().int(),
16783
+ releasedRefs: SecretRefsList
16784
+ }), {
16785
+ kind: "mutation",
16786
+ auth: "admin"
16787
+ }), method(object({
16788
+ ...KindShape,
16789
+ id: RecordIdSchema
16790
+ }), object({
16791
+ deleted: boolean(),
16792
+ secretRefs: SecretRefsList
16793
+ }), {
16794
+ kind: "mutation",
16795
+ auth: "admin"
16796
+ }), method(object({
16797
+ ...KindShape,
16798
+ ids: array(RecordIdSchema).min(1).max(RECORD_BATCH_MAX)
16799
+ }), object({
16800
+ deleted: number().int(),
16801
+ secretRefs: SecretRefsList
16802
+ }), {
16803
+ kind: "mutation",
16804
+ auth: "admin"
16805
+ }), method(RecordQueryInputSchema, RecordQueryResultSchema, { auth: "admin" }), method(object({
16806
+ ...KindShape,
16807
+ ...TimeWindowShape,
16808
+ where: RecordWhereSchema.optional()
16809
+ }), object({ count: number().int() }), { auth: "admin" }), method(object({
16810
+ ...KindShape,
16811
+ deviceId: number().int().optional(),
16812
+ from: number(),
16813
+ to: number(),
16814
+ bucketMs: number().int().positive()
16815
+ }), object({ buckets: array(object({
16816
+ bucketStart: number(),
16817
+ count: number().int()
16818
+ })) }), { auth: "admin" }), method(object({
16819
+ ...KindShape,
16820
+ op: _enum([
16821
+ "sum",
16822
+ "min",
16823
+ "max",
16824
+ "count"
16825
+ ]),
16826
+ field: RecordFieldPathSchema.optional(),
16827
+ groupBy: RecordFieldPathSchema.optional(),
16828
+ where: RecordWhereSchema.optional()
16829
+ }), object({ rows: array(object({
16830
+ group: union([
16831
+ string(),
16832
+ number(),
16833
+ _null()
16834
+ ]),
16835
+ value: number().nullable()
16836
+ })) }), { auth: "admin" }), method(object({
16837
+ ...KindShape,
16838
+ deviceId: number().int().optional(),
16839
+ atBefore: number().optional(),
16840
+ where: RecordWhereSchema.optional()
16841
+ }), object({
16842
+ deleted: number().int(),
16843
+ secretRefs: SecretRefsList
16844
+ }), {
16845
+ kind: "mutation",
16846
+ auth: "admin"
16847
+ }), method(object({
16848
+ deviceId: number().int(),
16849
+ kinds: array(RecordKindNameSchema).optional()
16850
+ }), object({
16851
+ deleted: record(string(), number().int()),
16852
+ secretRefs: SecretRefsList
16853
+ }), {
16854
+ kind: "mutation",
16855
+ auth: "admin"
16856
+ }), method(object(KindShape), object({ id: number().int() }), {
16857
+ kind: "mutation",
16858
+ auth: "admin"
16859
+ });
16860
+ /** One table of the settings database. */
16861
+ var StorageTableSchema = object({
16862
+ /** The table's full name, e.g. `recorder:addon-settings` or `addon-device-settings`. */
16863
+ name: string(),
16864
+ /** The owner prefix of a scoped name (`recorder` for `recorder:addon-settings`), else null. */
16865
+ owner: string().nullable(),
16866
+ rows: number().int().nonnegative(),
16867
+ /** Bytes the table's pages occupy (`dbstat`); null when the engine cannot measure. */
16868
+ bytes: number().int().nonnegative().nullable(),
16869
+ /** Declared by an addon since this engine process started (a running addon claims it). */
16870
+ declaredThisBoot: boolean()
16871
+ });
16872
+ /** One declared record kind (D881) as System -> Data shows it. */
16873
+ var StorageKindSchema = object({
16874
+ owner: string(),
16875
+ kind: string(),
16876
+ database: _enum(["settings", "events"]),
16877
+ class: string(),
16878
+ state: _enum([
16879
+ "declared",
16880
+ "orphaned",
16881
+ "dropped"
16882
+ ]),
16883
+ /** `null` when the caller asked for no counts (`counts: false`). */
16884
+ rows: number().int().nonnegative().nullable(),
16885
+ /** Rows x the average size of a sample; null for an empty kind. */
16886
+ bytesEstimate: number().int().nonnegative().nullable(),
16887
+ writeTrigger: string(),
16888
+ retention: RecordRetentionSchema,
16889
+ /** `true` when the kind is an entry kind (the generic entries UI lists it). */
16890
+ entry: boolean(),
16891
+ /** The whole declaration, secret paths and entry descriptor included (the entries service builds its handle from it). */
16892
+ declaration: RecordKindDeclarationSchema
16893
+ });
16894
+ method(object({ ownerPrefix: string().min(1).optional() }), object({ tables: array(StorageTableSchema) }), { auth: "admin" }), method(object({
16895
+ collection: string().min(1),
16896
+ expectRows: number().int().nonnegative()
16897
+ }), object({
16898
+ dropped: literal(true),
16899
+ rows: number().int().nonnegative()
16900
+ }), {
16901
+ kind: "mutation",
16902
+ auth: "admin"
16903
+ }), method(object({
16904
+ owner: string().min(1).optional(),
16905
+ /** `false` skips the per-kind row count (a catalog read only). Default true. */
16906
+ counts: boolean().optional()
16907
+ }), object({ kinds: array(StorageKindSchema) }), { auth: "admin" }), method(RecordQueryInputSchema.extend({
16908
+ owner: string().min(1),
16909
+ kind: RecordKindNameSchema
16910
+ }), RecordQueryResultSchema, { auth: "admin" }), method(object({
16911
+ owner: string().min(1),
16912
+ kind: RecordKindNameSchema,
16913
+ records: array(RecordInputSchema).max(RECORD_BATCH_MAX),
16914
+ /** The LAST batch: the copy is complete, the boot guard stops asking. */
16915
+ complete: boolean().optional()
16916
+ }).refine((input) => input.records.length > 0 || input.complete === true, { message: "records must be non-empty unless complete is true" }), object({ adopted: number().int() }), {
16917
+ kind: "mutation",
16918
+ auth: "admin"
16919
+ }), method(object({
16920
+ collection: string().min(1),
16921
+ cursor: string().optional(),
16922
+ limit: number().int().min(1).max(1e3).optional()
16923
+ }), object({
16924
+ rows: array(object({
16925
+ id: string(),
16926
+ data: record(string(), unknown())
16927
+ })),
16928
+ nextCursor: string().nullable()
16929
+ }), { auth: "admin" }), method(object({ collection: string().min(1) }), object({ adopted: boolean() }), { auth: "admin" });
16930
+ /**
16931
+ * record-entries - the ONE admin surface for every list of user-created entries
16932
+ * (D881): notification targets, brokers, LLM profiles, anything an addon
16933
+ * declares as an ENTRY kind (`entry: { title }` in `defineRecordKinds`).
16934
+ *
16935
+ * The UI is generic. `listEntryKinds` hands it, per kind, the JSON Schema of
16936
+ * the entry body with `secret: true` on every credential field, so a password
16937
+ * field is derived from the schema and never from a name. `putEntry` takes the
16938
+ * redaction token for an untouched secret (the stored value is kept), a string
16939
+ * for a new one, and the clear instruction to remove one. A read never carries
16940
+ * a secret value, and a locked keychain refuses the write with
16941
+ * `records/secret-unavailable` instead of storing plaintext.
16942
+ *
16943
+ * Hub-only, served in-process (it acts for each entry's owner on the keychain).
16944
+ */
16945
+ var EntryKindInfoSchema = object({
16946
+ owner: string(),
16947
+ kind: RecordKindNameSchema,
16948
+ title: string(),
16949
+ nameField: string(),
16950
+ /** JSON Schema of the body; `secret: true` marks a password field. */
16951
+ fields: record(string(), unknown()),
16952
+ secretPaths: array(string()),
16953
+ rows: number().int().nonnegative()
16954
+ });
16955
+ var EntryViewSchema = object({
16956
+ id: RecordIdSchema,
16957
+ name: string(),
16958
+ rev: number().int(),
16959
+ updatedAt: number(),
16960
+ /** Secret fields hold the redaction token. */
16961
+ data: RecordBodySchema
16962
+ });
16963
+ var EntryAddress = {
16964
+ owner: string().min(1),
16965
+ kind: RecordKindNameSchema
16966
+ };
16967
+ method(object({}), object({ kinds: array(EntryKindInfoSchema) }), { auth: "admin" }), method(object({ ...EntryAddress }), object({ entries: array(EntryViewSchema) }), { auth: "admin" }), method(object({
16968
+ ...EntryAddress,
16969
+ id: RecordIdSchema.optional(),
16970
+ data: RecordBodySchema,
16971
+ ifRev: number().int().min(1).optional()
16972
+ }), object({
16973
+ id: string(),
16974
+ rev: number().int()
16975
+ }), {
16976
+ kind: "mutation",
16977
+ auth: "admin"
16978
+ }), method(object({
16979
+ ...EntryAddress,
16980
+ id: RecordIdSchema
16981
+ }), object({ deleted: boolean() }), {
16982
+ kind: "mutation",
16983
+ auth: "admin"
16984
+ });
16985
+ /**
16065
16986
  * `keychain` — the hub's encrypted store of secret values (D787).
16066
16987
  *
16067
16988
  * Settings blobs never hold a secret: they hold a marker
@@ -16602,6 +17523,16 @@ method(object({}), KeychainStatusSchema, { auth: "admin" }), method(object({}),
16602
17523
  kind: "mutation",
16603
17524
  auth: "admin",
16604
17525
  caller: "required"
17526
+ }), method(object({
17527
+ ref: string().min(1),
17528
+ value: string().min(1)
17529
+ }), object({
17530
+ ref: string(),
17531
+ version: number().int()
17532
+ }), {
17533
+ kind: "mutation",
17534
+ auth: "admin",
17535
+ caller: "required"
16605
17536
  }), method(object({ refs: array(string().min(1)).max(1e3) }), object({
16606
17537
  deleted: array(string()).readonly(),
16607
17538
  kept: array(object({
@@ -39393,6 +40324,9 @@ method(LlmGenerateBaseInputSchema, LlmGenerateResultSchema, {
39393
40324
  }), _void(), { kind: "mutation" }), method(object({}), array(LlmProfileKindDescriptorSchema)), method(object({}), array(LlmProfileSchema)), method(object({ profile: LlmProfileSchema }), LlmProfileSchema, {
39394
40325
  kind: "mutation",
39395
40326
  auth: "admin"
40327
+ }), method(RawSecretMigrationInputSchema, RawSecretMigrationReportSchema, {
40328
+ kind: "mutation",
40329
+ auth: "admin"
39396
40330
  }), method(ProfileRefInputSchema, _void(), {
39397
40331
  kind: "mutation",
39398
40332
  auth: "admin"
@@ -49902,6 +50836,41 @@ var ServerRollbackInfoSchema = object({
49902
50836
  atMs: number(),
49903
50837
  reason: string()
49904
50838
  });
50839
+ /**
50840
+ * The runner boot check (D877): the runners this node PLANNED (hub: one per
50841
+ * `resolveRunnerId` over its forked addons; agent: the runners its process
50842
+ * service holds, because only the hub plans) against the states the process
50843
+ * service reports. Kept in memory, recomputed by the same one-shot check after
50844
+ * every boot, served on `getServerPackageStatus`.
50845
+ *
50846
+ * `failed` is the D6 breaker's terminal state, `refused` a deterministic Init
50847
+ * refusal (an addon that said "I will not start, and here is why"), `missing` a
50848
+ * planned runner the process service has no entry for.
50849
+ */
50850
+ var RunnerRefusalSchema = object({
50851
+ runnerId: string(),
50852
+ addonIds: array(string()),
50853
+ reason: string()
50854
+ });
50855
+ var RunnerBootCheckSchema = object({
50856
+ checkedAtMs: number(),
50857
+ /** Runners planned for this node. */
50858
+ expected: number(),
50859
+ /** Planned runners whose process is `running`. */
50860
+ running: number(),
50861
+ failed: array(string()),
50862
+ refused: array(RunnerRefusalSchema),
50863
+ missing: array(string()),
50864
+ /**
50865
+ * Runners still on their way: `starting`, or `crashed` waiting on a backoff
50866
+ * respawn. The check is FINAL only when this is empty; until then nothing is
50867
+ * pushed and the verdict is re-evaluated on the next runner state change.
50868
+ * Optional for version skew (absent = settled).
50869
+ */
50870
+ pending: array(string()).optional(),
50871
+ /** True when the plan is the hub's (`missing` is then meaningful); false on an agent. */
50872
+ planKnown: boolean()
50873
+ });
49905
50874
  var ServerPackageStatusSchema = object({
49906
50875
  /** Root package name (`@camstack/server` on the hub). */
49907
50876
  packageName: string(),
@@ -49964,7 +50933,14 @@ var ServerPackageStatusSchema = object({
49964
50933
  * for version skew: an older provider's payload simply omits it, and an
49965
50934
  * absent wrapper is unknown — never `native`.
49966
50935
  */
49967
- wrapper: WrapperIdentitySchema.optional()
50936
+ wrapper: WrapperIdentitySchema.optional(),
50937
+ /**
50938
+ * What this node PLANNED to run against what its process service reports
50939
+ * (D877). Absent until the one-shot boot check has run (~60 s after boot) and
50940
+ * on a provider that predates it. Absent is "not checked yet", never "all
50941
+ * well": a consumer that needs the answer treats it as pending.
50942
+ */
50943
+ runners: RunnerBootCheckSchema.optional()
49968
50944
  });
49969
50945
  var ServerUpdateCheckResultSchema = object({
49970
50946
  packageName: string(),
@@ -50015,6 +50991,13 @@ var ServerUpdateOutcomeSchema = _enum([
50015
50991
  "refused",
50016
50992
  "failed"
50017
50993
  ]);
50994
+ /** One addon the pre-flight found the target version would refuse (D877). */
50995
+ var UpdateBlockerSchema = object({
50996
+ addonId: string(),
50997
+ reason: string(),
50998
+ /** What the operator does about it. */
50999
+ remedy: string()
51000
+ });
50018
51001
  var ServerUpdateActionResultSchema = object({
50019
51002
  accepted: boolean(),
50020
51003
  targetVersion: string().nullable(),
@@ -50032,14 +51015,27 @@ var ServerUpdateActionResultSchema = object({
50032
51015
  * The failure itself, verbatim enough to act on (the npm output for a
50033
51016
  * staging install). Non-null only for `failed`.
50034
51017
  */
50035
- error: string().nullable().optional()
51018
+ error: string().nullable().optional(),
51019
+ /**
51020
+ * The addons the target version would refuse to start on this node's live
51021
+ * store (D877), present when the pre-flight refused the update
51022
+ * (`reason: 'addon-would-refuse'`). Optional for version skew.
51023
+ */
51024
+ blockers: array(UpdateBlockerSchema).optional()
50036
51025
  });
50037
51026
  method(_void(), ServerPackageStatusSchema, { auth: "admin" }), method(_void(), ServerUpdateCheckResultSchema, {
50038
51027
  kind: "mutation",
50039
51028
  auth: "admin"
50040
- }), method(object({
50041
- /** Explicit target version; omitted = latest from the registry. */
50042
- version: string().optional() }), ServerUpdateActionResultSchema, {
51029
+ }), method(object({
51030
+ /** Explicit target version; omitted = latest from the registry. */
51031
+ version: string().optional(),
51032
+ /**
51033
+ * Apply even though the pre-flight (D877) found addons the target would
51034
+ * refuse to start. Off by default: those addons stay down until the
51035
+ * remedy is run, which is the incident this gate exists to prevent.
51036
+ */
51037
+ acknowledgeRefusals: boolean().optional()
51038
+ }), ServerUpdateActionResultSchema, {
50043
51039
  kind: "mutation",
50044
51040
  auth: "admin",
50045
51041
  timeoutMs: 16 * 6e4
@@ -52485,7 +53481,9 @@ var ManifestShapeSchema = object({
52485
53481
  var AddonProcessSchema = object({
52486
53482
  pid: number().optional(),
52487
53483
  mode: string(),
52488
- state: string()
53484
+ state: string(),
53485
+ /** Why the runner is `refused` (an addon's own words), when it is (D877). */
53486
+ reason: string().optional()
52489
53487
  });
52490
53488
  /**
52491
53489
  * Per-addon health snapshot from the kernel's AddonHealthMonitor.
@@ -53253,7 +54251,8 @@ var batteryCapability = {
53253
54251
  DeviceType.Button,
53254
54252
  DeviceType.Switch,
53255
54253
  DeviceType.PetFeeder,
53256
- DeviceType.Container
54254
+ DeviceType.Container,
54255
+ DeviceType.Thermostat
53257
54256
  ],
53258
54257
  methods: {
53259
54258
  /**
@@ -53874,6 +54873,12 @@ var ClimateControlStatusSchema = object({
53874
54873
  /** Horizontal louver swing on/off. Null when the device has no
53875
54874
  * horizontal swing surface (gate with `DeviceFeature.ClimateSwingHorizontal`). */
53876
54875
  swingHorizontal: boolean().nullable(),
54876
+ /** Lowest setpoint the device accepts, Celsius. Absent / null = not reported. */
54877
+ minTemp: number().nullable().optional(),
54878
+ /** Highest setpoint the device accepts, Celsius. Absent / null = not reported. */
54879
+ maxTemp: number().nullable().optional(),
54880
+ /** Setpoint granularity, Celsius (0.5, 1). Absent / null = not reported. */
54881
+ tempStep: number().positive().nullable().optional(),
53877
54882
  /** Ms epoch when the slice was last updated (push or command). */
53878
54883
  lastFetchedAt: number()
53879
54884
  });
@@ -54720,6 +55725,125 @@ onStatusChanged: { data: object({
54720
55725
  * whether persisting is worth a SQLite commit. */
54721
55726
  volatileStateFields: ["lastChangedAt"]
54722
55727
  };
55728
+ /**
55729
+ * Smart-dishwasher cap — program lifecycle, door / remote-start gates,
55730
+ * consumable levels (salt, rinse aid) and common program options.
55731
+ *
55732
+ * Sources: native Bosch Home Connect (`dishwasher` device type). Reusable
55733
+ * by any integration that exposes the same program / option surface.
55734
+ *
55735
+ * `kind: 'poll'` — cloud REST APIs typically have no push channel; the
55736
+ * provider refreshes the slice on an interval and eagerly after commands.
55737
+ */
55738
+ var DishwasherStateSchema = _enum([
55739
+ "idle",
55740
+ "running",
55741
+ "paused",
55742
+ "finished",
55743
+ "error",
55744
+ "unavailable"
55745
+ ]);
55746
+ var DishwasherConsumableLevelSchema = _enum([
55747
+ "ok",
55748
+ "low",
55749
+ "empty"
55750
+ ]);
55751
+ var DishwasherStatusSchema = object({
55752
+ state: DishwasherStateSchema,
55753
+ /** Active program id/name, or null when none selected / unknown. */
55754
+ program: string().nullable(),
55755
+ /** Program tokens the hardware accepts — drives the UI selector. */
55756
+ availablePrograms: array(string()),
55757
+ /** Minutes remaining on the active cycle, or null when not running. */
55758
+ remainingMinutes: number().int().nonnegative().nullable(),
55759
+ /** Cycle completion 0..100, or null when not applicable. */
55760
+ progressPercent: number().min(0).max(100).nullable(),
55761
+ /** True when the door is reported open. */
55762
+ doorOpen: boolean(),
55763
+ /** True when remote start is allowed (door closed, power on, etc.). */
55764
+ remoteStartAllowed: boolean(),
55765
+ /** Main power / switched-on state. */
55766
+ powerOn: boolean(),
55767
+ saltLevel: DishwasherConsumableLevelSchema.nullable(),
55768
+ rinseAidLevel: DishwasherConsumableLevelSchema.nullable(),
55769
+ halfLoad: boolean(),
55770
+ hygienePlus: boolean(),
55771
+ errorCode: number().nullable(),
55772
+ errorLabel: string().nullable(),
55773
+ lastFetchedAt: number()
55774
+ });
55775
+ var dishwasherCapability = {
55776
+ name: "dishwasher",
55777
+ scope: "device",
55778
+ deviceNative: true,
55779
+ mode: "singleton",
55780
+ deviceTypes: [DeviceType.Dishwasher],
55781
+ methods: {
55782
+ start: method(object({ deviceId: number().int().nonnegative() }), _void(), {
55783
+ kind: "mutation",
55784
+ auth: "protected"
55785
+ }),
55786
+ pause: method(object({ deviceId: number().int().nonnegative() }), _void(), {
55787
+ kind: "mutation",
55788
+ auth: "protected"
55789
+ }),
55790
+ stop: method(object({ deviceId: number().int().nonnegative() }), _void(), {
55791
+ kind: "mutation",
55792
+ auth: "protected"
55793
+ }),
55794
+ setProgram: method(object({
55795
+ deviceId: number().int().nonnegative(),
55796
+ program: string().min(1)
55797
+ }), _void(), {
55798
+ kind: "mutation",
55799
+ auth: "protected"
55800
+ }),
55801
+ setPower: method(object({
55802
+ deviceId: number().int().nonnegative(),
55803
+ on: boolean()
55804
+ }), _void(), {
55805
+ kind: "mutation",
55806
+ auth: "protected"
55807
+ }),
55808
+ setHalfLoad: method(object({
55809
+ deviceId: number().int().nonnegative(),
55810
+ on: boolean()
55811
+ }), _void(), {
55812
+ kind: "mutation",
55813
+ auth: "protected"
55814
+ }),
55815
+ setHygienePlus: method(object({
55816
+ deviceId: number().int().nonnegative(),
55817
+ on: boolean()
55818
+ }), _void(), {
55819
+ kind: "mutation",
55820
+ auth: "protected"
55821
+ }),
55822
+ setOption: method(object({
55823
+ deviceId: number().int().nonnegative(),
55824
+ key: string().min(1),
55825
+ value: union([
55826
+ boolean(),
55827
+ string(),
55828
+ number()
55829
+ ])
55830
+ }), _void(), {
55831
+ kind: "mutation",
55832
+ auth: "protected"
55833
+ })
55834
+ },
55835
+ status: {
55836
+ schema: DishwasherStatusSchema,
55837
+ kind: "poll"
55838
+ },
55839
+ runtimeState: DishwasherStatusSchema,
55840
+ durability: "session",
55841
+ history: { fields: { progressPercent: {
55842
+ kind: "gauge",
55843
+ unit: "%",
55844
+ deadband: 2
55845
+ } } }
55846
+ };
54723
55847
  var DoorbellStatusSchema = object({
54724
55848
  /** Ms epoch of the last press. null = never observed since this provider started. */
54725
55849
  lastPressedAt: number().nullable(),
@@ -55522,6 +56646,32 @@ var gasCapability = {
55522
56646
  * whether persisting is worth a SQLite commit. */
55523
56647
  volatileStateFields: ["lastChangedAt"]
55524
56648
  };
56649
+ var HeatingValveStatusSchema = object({
56650
+ /** Radiator valve opening 0 (closed) .. 100 (open). Null = not yet known. */
56651
+ position: number().min(0).max(100).nullable(),
56652
+ /** Ms epoch when the slice was last updated (push or poll). */
56653
+ lastFetchedAt: number()
56654
+ });
56655
+ var heatingValveCapability = {
56656
+ name: "heating-valve",
56657
+ scope: "device",
56658
+ deviceNative: true,
56659
+ mode: "singleton",
56660
+ deviceTypes: [DeviceType.Thermostat],
56661
+ methods: {},
56662
+ status: {
56663
+ schema: HeatingValveStatusSchema,
56664
+ kind: "push"
56665
+ },
56666
+ runtimeState: HeatingValveStatusSchema,
56667
+ durability: "session",
56668
+ history: { fields: { position: {
56669
+ kind: "gauge",
56670
+ unit: "%",
56671
+ deadband: 1
56672
+ } } },
56673
+ volatileStateFields: ["lastFetchedAt"]
56674
+ };
55525
56675
  /**
55526
56676
  * Humidifier / dehumidifier cap. Models HA `humidifier.*` entities —
55527
56677
  * an on/off actuator with an optional target-humidity setpoint and an
@@ -56654,7 +57804,19 @@ var TlsStatusSchema = object({
56654
57804
  sans: array(string()),
56655
57805
  caCertPem: string().nullable(),
56656
57806
  reissueError: string().nullable(),
56657
- restartRequired: boolean()
57807
+ restartRequired: boolean(),
57808
+ /** An uploaded certificate is served but no CA is kept for it and it is not publicly signed (D873). */
57809
+ caMissing: boolean(),
57810
+ /** Does the hub's own generated CA carry a critical name constraint? `null` while it has none. */
57811
+ localCaConstrained: boolean().nullable(),
57812
+ /** ISO time the generated CA was replaced by a constrained one; devices must re-download it. */
57813
+ caReplacedAt: string().nullable(),
57814
+ /** The uploaded certificate kept on disk, selectable again after "Revert to generated". */
57815
+ storedUpload: object({
57816
+ leafFingerprintSha256: string(),
57817
+ validTo: string(),
57818
+ hasCa: boolean()
57819
+ }).nullable()
56658
57820
  });
56659
57821
  method(_void(), ListResultSchema), method(_void(), PreferredSchema), method(object({
56660
57822
  /**
@@ -56710,6 +57872,9 @@ method(_void(), ListResultSchema), method(_void(), PreferredSchema), method(obje
56710
57872
  }), method(_void(), object({ pem: string() })), method(_void(), TlsStatusSchema, {
56711
57873
  kind: "mutation",
56712
57874
  auth: "admin"
57875
+ }), method(_void(), TlsStatusSchema, {
57876
+ kind: "mutation",
57877
+ auth: "admin"
56713
57878
  });
56714
57879
  var LockControlStatusSchema = object({
56715
57880
  /** Lifecycle state of the lock. `jammed` means the motor reported
@@ -63203,7 +64368,11 @@ method(_void(), array(UserSummarySchema), { auth: "admin" }), method(CreateUserI
63203
64368
  kind: "mutation",
63204
64369
  auth: "admin",
63205
64370
  access: "delete"
63206
- }), method(object({ userId: string() }), TotpStatusSchema, { auth: "admin" }), method(object({
64371
+ }), method(object({ userId: string() }), TotpStatusSchema, { auth: "admin" }), method(RawSecretMigrationInputSchema, RawSecretMigrationReportSchema, {
64372
+ kind: "mutation",
64373
+ auth: "admin",
64374
+ access: "create"
64375
+ }), method(object({
63207
64376
  userId: string(),
63208
64377
  code: string()
63209
64378
  }), object({ valid: boolean() }), {
@@ -64923,6 +66092,7 @@ var DEVICE_LOCAL_STATE_CAPS = {
64923
66092
  dayNight: dayNightCapability,
64924
66093
  deviceDiscovery: deviceDiscoveryCapability,
64925
66094
  deviceStatus: deviceStatusCapability,
66095
+ dishwasher: dishwasherCapability,
64926
66096
  doorbell: doorbellCapability,
64927
66097
  enumSensor: enumSensorCapability,
64928
66098
  eventEmitter: eventEmitterCapability,
@@ -64930,6 +66100,7 @@ var DEVICE_LOCAL_STATE_CAPS = {
64930
66100
  featureProbe: featureProbeCapability,
64931
66101
  flood: floodCapability,
64932
66102
  gas: gasCapability,
66103
+ heatingValve: heatingValveCapability,
64933
66104
  humidifier: humidifierCapability,
64934
66105
  humiditySensor: humiditySensorCapability,
64935
66106
  image: imageCapability,
@@ -65015,13 +66186,14 @@ var BaseDevice = class {
65015
66186
  get state() {
65016
66187
  if (!this._stateProxyCache) {
65017
66188
  const cache = {};
65018
- const handler = { get: (_target, key) => {
66189
+ const handler = { get: (target, key) => {
65019
66190
  const k = key;
65020
- if (k in cache) return cache[k];
66191
+ const existing = Reflect.get(target, k);
66192
+ if (existing !== void 0) return existing;
65021
66193
  const cap = DEVICE_LOCAL_STATE_CAPS[k];
65022
66194
  if (!cap) return void 0;
65023
66195
  const proxy = this.sliceProxy(cap);
65024
- cache[k] = proxy;
66196
+ Reflect.set(target, k, proxy);
65025
66197
  return proxy;
65026
66198
  } };
65027
66199
  this._stateProxyCache = new Proxy(cache, handler);
@@ -65220,7 +66392,7 @@ var BaseDevice = class {
65220
66392
  async updateSourceInfo(patch) {
65221
66393
  const next = mergeSourceInfo(this.sourceInfo, patch);
65222
66394
  this._sourceInfoCache = Object.freeze({ ...next });
65223
- const action = this.ctx.api?.deviceManager?.setMetadata;
66395
+ const action = this.ctx.api.deviceManager?.setMetadata;
65224
66396
  if (action) try {
65225
66397
  await action.mutate({
65226
66398
  deviceId: this.id,
@@ -65255,7 +66427,7 @@ var BaseDevice = class {
65255
66427
  * device boot on a meta refresh.
65256
66428
  */
65257
66429
  async refreshFeatures() {
65258
- const action = this.ctx.api?.deviceManager?.registerDevice;
66430
+ const action = this.ctx.api.deviceManager?.registerDevice;
65259
66431
  if (!action) return;
65260
66432
  try {
65261
66433
  await action.mutate({
@@ -65654,6 +66826,12 @@ var BaseDeviceProvider = class extends BaseAddon {
65654
66826
  provider: this
65655
66827
  }];
65656
66828
  }
66829
+ /** Flatten `super.onInitialize()` whether it returned an array or an envelope. */
66830
+ providerRegistrationsFromSuper(result) {
66831
+ if (Array.isArray(result)) return result;
66832
+ if (result !== void 0 && result.providers !== void 0) return [...result.providers];
66833
+ return [];
66834
+ }
65657
66835
  async onShutdown() {
65658
66836
  this._restoreShuttingDown = true;
65659
66837
  this.cancelRestoreRetries();
@@ -66180,7 +67358,7 @@ var BaseDeviceProvider = class extends BaseAddon {
66180
67358
  return toDeviceSummary(device, this.addonId);
66181
67359
  }
66182
67360
  };
66183
- DeviceType.Cover, DeviceType.Valve, DeviceType.Humidifier, DeviceType.WaterHeater, DeviceType.Camera, DeviceType.Hub, DeviceType.Switch, DeviceType.Siren, DeviceType.Light, DeviceType.Fan, DeviceType.Sensor, DeviceType.Thermostat, DeviceType.Climate, DeviceType.Button, DeviceType.EventEmitter, DeviceType.Update, DeviceType.Generic, DeviceType.Notifier, DeviceType.Script, DeviceType.Automation, DeviceType.Lock, DeviceType.MediaPlayer, DeviceType.AlarmPanel, DeviceType.Control, DeviceType.Presence, DeviceType.Weather, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.Container, DeviceType.Image, DeviceType.PetFeeder;
67361
+ DeviceType.Cover, DeviceType.Valve, DeviceType.Humidifier, DeviceType.WaterHeater, DeviceType.Camera, DeviceType.Hub, DeviceType.Switch, DeviceType.Siren, DeviceType.Light, DeviceType.Fan, DeviceType.Sensor, DeviceType.Thermostat, DeviceType.Climate, DeviceType.Button, DeviceType.EventEmitter, DeviceType.Update, DeviceType.Generic, DeviceType.Notifier, DeviceType.Script, DeviceType.Automation, DeviceType.Lock, DeviceType.MediaPlayer, DeviceType.AlarmPanel, DeviceType.Control, DeviceType.Presence, DeviceType.Weather, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.Container, DeviceType.Image, DeviceType.PetFeeder, DeviceType.Dishwasher;
66184
67362
  new Set(Object.values(DeviceType));
66185
67363
  Object.freeze({
66186
67364
  "accessories.getStatus": {
@@ -67329,6 +68507,12 @@ Object.freeze({
67329
68507
  addonId: null,
67330
68508
  access: "view"
67331
68509
  },
68510
+ "coreBlocks.migrateRawSecrets": {
68511
+ capName: "core-blocks",
68512
+ capScope: "system",
68513
+ addonId: null,
68514
+ access: "create"
68515
+ },
67332
68516
  "coreBlocks.restart": {
67333
68517
  capName: "core-blocks",
67334
68518
  capScope: "system",
@@ -68595,6 +69779,60 @@ Object.freeze({
68595
69779
  addonId: null,
68596
69780
  access: "view"
68597
69781
  },
69782
+ "dishwasher.getStatus": {
69783
+ capName: "dishwasher",
69784
+ capScope: "device",
69785
+ addonId: null,
69786
+ access: "view"
69787
+ },
69788
+ "dishwasher.pause": {
69789
+ capName: "dishwasher",
69790
+ capScope: "device",
69791
+ addonId: null,
69792
+ access: "create"
69793
+ },
69794
+ "dishwasher.setHalfLoad": {
69795
+ capName: "dishwasher",
69796
+ capScope: "device",
69797
+ addonId: null,
69798
+ access: "create"
69799
+ },
69800
+ "dishwasher.setHygienePlus": {
69801
+ capName: "dishwasher",
69802
+ capScope: "device",
69803
+ addonId: null,
69804
+ access: "create"
69805
+ },
69806
+ "dishwasher.setOption": {
69807
+ capName: "dishwasher",
69808
+ capScope: "device",
69809
+ addonId: null,
69810
+ access: "create"
69811
+ },
69812
+ "dishwasher.setPower": {
69813
+ capName: "dishwasher",
69814
+ capScope: "device",
69815
+ addonId: null,
69816
+ access: "create"
69817
+ },
69818
+ "dishwasher.setProgram": {
69819
+ capName: "dishwasher",
69820
+ capScope: "device",
69821
+ addonId: null,
69822
+ access: "create"
69823
+ },
69824
+ "dishwasher.start": {
69825
+ capName: "dishwasher",
69826
+ capScope: "device",
69827
+ addonId: null,
69828
+ access: "create"
69829
+ },
69830
+ "dishwasher.stop": {
69831
+ capName: "dishwasher",
69832
+ capScope: "device",
69833
+ addonId: null,
69834
+ access: "create"
69835
+ },
68598
69836
  "doorbell.getStatus": {
68599
69837
  capName: "doorbell",
68600
69838
  capScope: "device",
@@ -68805,6 +70043,12 @@ Object.freeze({
68805
70043
  addonId: null,
68806
70044
  access: "view"
68807
70045
  },
70046
+ "heatingValve.getStatus": {
70047
+ capName: "heating-valve",
70048
+ capScope: "device",
70049
+ addonId: null,
70050
+ access: "view"
70051
+ },
68808
70052
  "humidifier.getStatus": {
68809
70053
  capName: "humidifier",
68810
70054
  capScope: "device",
@@ -69015,6 +70259,12 @@ Object.freeze({
69015
70259
  addonId: null,
69016
70260
  access: "create"
69017
70261
  },
70262
+ "keychainAdmin.importSecret": {
70263
+ capName: "keychain-admin",
70264
+ capScope: "system",
70265
+ addonId: null,
70266
+ access: "create"
70267
+ },
69018
70268
  "keychainAdmin.listAudit": {
69019
70269
  capName: "keychain-admin",
69020
70270
  capScope: "system",
@@ -69183,6 +70433,12 @@ Object.freeze({
69183
70433
  addonId: null,
69184
70434
  access: "view"
69185
70435
  },
70436
+ "llm.migrateRawSecrets": {
70437
+ capName: "llm",
70438
+ capScope: "system",
70439
+ addonId: null,
70440
+ access: "create"
70441
+ },
69186
70442
  "llm.resolveModelRef": {
69187
70443
  capName: "llm",
69188
70444
  capScope: "system",
@@ -69411,6 +70667,12 @@ Object.freeze({
69411
70667
  addonId: null,
69412
70668
  access: "create"
69413
70669
  },
70670
+ "localNetwork.useStoredUploadedCertificate": {
70671
+ capName: "local-network",
70672
+ capScope: "system",
70673
+ addonId: null,
70674
+ access: "create"
70675
+ },
69414
70676
  "lockControl.getStatus": {
69415
70677
  capName: "lock-control",
69416
70678
  capScope: "device",
@@ -72063,6 +73325,30 @@ Object.freeze({
72063
73325
  addonId: null,
72064
73326
  access: "create"
72065
73327
  },
73328
+ "recordEntries.deleteEntry": {
73329
+ capName: "record-entries",
73330
+ capScope: "system",
73331
+ addonId: null,
73332
+ access: "delete"
73333
+ },
73334
+ "recordEntries.listEntries": {
73335
+ capName: "record-entries",
73336
+ capScope: "system",
73337
+ addonId: null,
73338
+ access: "view"
73339
+ },
73340
+ "recordEntries.listEntryKinds": {
73341
+ capName: "record-entries",
73342
+ capScope: "system",
73343
+ addonId: null,
73344
+ access: "view"
73345
+ },
73346
+ "recordEntries.putEntry": {
73347
+ capName: "record-entries",
73348
+ capScope: "system",
73349
+ addonId: null,
73350
+ access: "create"
73351
+ },
72066
73352
  "recording.getAvailability": {
72067
73353
  capName: "recording",
72068
73354
  capScope: "device",
@@ -72363,6 +73649,102 @@ Object.freeze({
72363
73649
  addonId: null,
72364
73650
  access: "view"
72365
73651
  },
73652
+ "records.aggregate": {
73653
+ capName: "records",
73654
+ capScope: "system",
73655
+ addonId: null,
73656
+ access: "view"
73657
+ },
73658
+ "records.allocateId": {
73659
+ capName: "records",
73660
+ capScope: "system",
73661
+ addonId: null,
73662
+ access: "create"
73663
+ },
73664
+ "records.count": {
73665
+ capName: "records",
73666
+ capScope: "system",
73667
+ addonId: null,
73668
+ access: "view"
73669
+ },
73670
+ "records.declareKinds": {
73671
+ capName: "records",
73672
+ capScope: "system",
73673
+ addonId: null,
73674
+ access: "create"
73675
+ },
73676
+ "records.delete": {
73677
+ capName: "records",
73678
+ capScope: "system",
73679
+ addonId: null,
73680
+ access: "delete"
73681
+ },
73682
+ "records.deleteDevice": {
73683
+ capName: "records",
73684
+ capScope: "system",
73685
+ addonId: null,
73686
+ access: "delete"
73687
+ },
73688
+ "records.deleteMany": {
73689
+ capName: "records",
73690
+ capScope: "system",
73691
+ addonId: null,
73692
+ access: "delete"
73693
+ },
73694
+ "records.deleteWhere": {
73695
+ capName: "records",
73696
+ capScope: "system",
73697
+ addonId: null,
73698
+ access: "delete"
73699
+ },
73700
+ "records.get": {
73701
+ capName: "records",
73702
+ capScope: "system",
73703
+ addonId: null,
73704
+ access: "view"
73705
+ },
73706
+ "records.getMany": {
73707
+ capName: "records",
73708
+ capScope: "system",
73709
+ addonId: null,
73710
+ access: "view"
73711
+ },
73712
+ "records.histogram": {
73713
+ capName: "records",
73714
+ capScope: "system",
73715
+ addonId: null,
73716
+ access: "view"
73717
+ },
73718
+ "records.patch": {
73719
+ capName: "records",
73720
+ capScope: "system",
73721
+ addonId: null,
73722
+ access: "create"
73723
+ },
73724
+ "records.put": {
73725
+ capName: "records",
73726
+ capScope: "system",
73727
+ addonId: null,
73728
+ access: "create"
73729
+ },
73730
+ "records.putMany": {
73731
+ capName: "records",
73732
+ capScope: "system",
73733
+ addonId: null,
73734
+ access: "create"
73735
+ },
73736
+ "records.query": {
73737
+ capName: "records",
73738
+ capScope: "system",
73739
+ addonId: null,
73740
+ access: "view"
73741
+ },
73742
+ "records.secretRefs": {
73743
+ capName: "records",
73744
+ capScope: "system",
73745
+ addonId: null,
73746
+ access: "view"
73747
+ },
72366
73748
  "sceneMonitor.captureReference": {
72367
73749
  capName: "scene-monitor",
72368
73750
  capScope: "device",
@@ -72795,6 +74177,48 @@ Object.freeze({
72795
74177
  addonId: null,
72796
74178
  access: "create"
72797
74179
  },
74180
+ "storageAdmin.adoptRecords": {
74181
+ capName: "storage-admin",
74182
+ capScope: "system",
74183
+ addonId: null,
74184
+ access: "create"
74185
+ },
74186
+ "storageAdmin.dropCollection": {
74187
+ capName: "storage-admin",
74188
+ capScope: "system",
74189
+ addonId: null,
74190
+ access: "delete"
74191
+ },
74192
+ "storageAdmin.isAdoptedLegacyTable": {
74193
+ capName: "storage-admin",
74194
+ capScope: "system",
74195
+ addonId: null,
74196
+ access: "view"
74197
+ },
74198
+ "storageAdmin.listKinds": {
74199
+ capName: "storage-admin",
74200
+ capScope: "system",
74201
+ addonId: null,
74202
+ access: "view"
74203
+ },
74204
+ "storageAdmin.listTables": {
74205
+ capName: "storage-admin",
74206
+ capScope: "system",
74207
+ addonId: null,
74208
+ access: "view"
74209
+ },
74210
+ "storageAdmin.readLegacyCollection": {
74211
+ capName: "storage-admin",
74212
+ capScope: "system",
74213
+ addonId: null,
74214
+ access: "view"
74215
+ },
74216
+ "storageAdmin.readRecords": {
74217
+ capName: "storage-admin",
74218
+ capScope: "system",
74219
+ addonId: null,
74220
+ access: "view"
74221
+ },
72798
74222
  "storageEvictable.evict": {
72799
74223
  capName: "storage-evictable",
72800
74224
  capScope: "system",
@@ -73707,6 +75131,12 @@ Object.freeze({
73707
75131
  addonId: null,
73708
75132
  access: "view"
73709
75133
  },
75134
+ "userManagement.migrateRawSecrets": {
75135
+ capName: "user-management",
75136
+ capScope: "system",
75137
+ addonId: null,
75138
+ access: "create"
75139
+ },
73710
75140
  "userManagement.oauthExchangeCode": {
73711
75141
  capName: "user-management",
73712
75142
  capScope: "system",
@@ -74206,7 +75636,7 @@ Object.freeze({
74206
75636
  access: "create"
74207
75637
  }
74208
75638
  });
74209
- DeviceType.Camera, DeviceType.Hub, DeviceType.Light, DeviceType.Siren, DeviceType.Switch, DeviceType.Sensor, DeviceType.Thermostat, DeviceType.Climate, DeviceType.Button, DeviceType.EventEmitter, DeviceType.Update, DeviceType.Generic, DeviceType.Notifier, DeviceType.Script, DeviceType.Automation, DeviceType.Lock, DeviceType.Cover, DeviceType.Valve, DeviceType.Humidifier, DeviceType.WaterHeater, DeviceType.Fan, DeviceType.MediaPlayer, DeviceType.AlarmPanel, DeviceType.Control, DeviceType.Presence, DeviceType.Weather, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.Container, DeviceType.Image, DeviceType.PetFeeder;
75639
+ DeviceType.Camera, DeviceType.Hub, DeviceType.Light, DeviceType.Siren, DeviceType.Switch, DeviceType.Sensor, DeviceType.Thermostat, DeviceType.Climate, DeviceType.Button, DeviceType.EventEmitter, DeviceType.Update, DeviceType.Generic, DeviceType.Notifier, DeviceType.Script, DeviceType.Automation, DeviceType.Lock, DeviceType.Cover, DeviceType.Valve, DeviceType.Humidifier, DeviceType.WaterHeater, DeviceType.Fan, DeviceType.MediaPlayer, DeviceType.AlarmPanel, DeviceType.Control, DeviceType.Presence, DeviceType.Weather, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.Container, DeviceType.Image, DeviceType.PetFeeder, DeviceType.Dishwasher;
74210
75640
  DeviceFeature.BatteryOperated;
74211
75641
  Object.freeze({
74212
75642
  "accessories.getStatus": [{
@@ -75030,6 +76460,51 @@ Object.freeze({
75030
76460
  form: "single",
75031
76461
  optional: false
75032
76462
  }],
76463
+ "dishwasher.getStatus": [{
76464
+ name: "deviceId",
76465
+ form: "single",
76466
+ optional: false
76467
+ }],
76468
+ "dishwasher.pause": [{
76469
+ name: "deviceId",
76470
+ form: "single",
76471
+ optional: false
76472
+ }],
76473
+ "dishwasher.setHalfLoad": [{
76474
+ name: "deviceId",
76475
+ form: "single",
76476
+ optional: false
76477
+ }],
76478
+ "dishwasher.setHygienePlus": [{
76479
+ name: "deviceId",
76480
+ form: "single",
76481
+ optional: false
76482
+ }],
76483
+ "dishwasher.setOption": [{
76484
+ name: "deviceId",
76485
+ form: "single",
76486
+ optional: false
76487
+ }],
76488
+ "dishwasher.setPower": [{
76489
+ name: "deviceId",
76490
+ form: "single",
76491
+ optional: false
76492
+ }],
76493
+ "dishwasher.setProgram": [{
76494
+ name: "deviceId",
76495
+ form: "single",
76496
+ optional: false
76497
+ }],
76498
+ "dishwasher.start": [{
76499
+ name: "deviceId",
76500
+ form: "single",
76501
+ optional: false
76502
+ }],
76503
+ "dishwasher.stop": [{
76504
+ name: "deviceId",
76505
+ form: "single",
76506
+ optional: false
76507
+ }],
75033
76508
  "doorbell.getStatus": [{
75034
76509
  name: "deviceId",
75035
76510
  form: "single",
@@ -75099,6 +76574,11 @@ Object.freeze({
75099
76574
  form: "single",
75100
76575
  optional: false
75101
76576
  }],
76577
+ "heatingValve.getStatus": [{
76578
+ name: "deviceId",
76579
+ form: "single",
76580
+ optional: false
76581
+ }],
75102
76582
  "humidifier.getStatus": [{
75103
76583
  name: "deviceId",
75104
76584
  form: "single",
@@ -76383,6 +77863,37 @@ Object.freeze({
76383
77863
  form: "single",
76384
77864
  optional: false
76385
77865
  }],
77866
+ "records.count": [{
77867
+ name: "deviceId",
77868
+ form: "single",
77869
+ optional: true
77870
+ }],
77871
+ "records.deleteDevice": [{
77872
+ name: "deviceId",
77873
+ form: "single",
77874
+ optional: false
77875
+ }],
77876
+ "records.deleteWhere": [{
77877
+ name: "deviceId",
77878
+ form: "single",
77879
+ optional: true
77880
+ }],
77881
+ "records.histogram": [{
77882
+ name: "deviceId",
77883
+ form: "single",
77884
+ optional: true
77885
+ }],
77886
+ "records.putMany": [{
77887
+ name: "records",
77888
+ form: "object-array",
77889
+ optional: false,
77890
+ itemField: "deviceId"
77891
+ }],
77892
+ "records.query": [{
77893
+ name: "deviceId",
77894
+ form: "single",
77895
+ optional: true
77896
+ }],
76386
77897
  "sceneMonitor.captureReference": [{
76387
77898
  name: "deviceId",
76388
77899
  form: "single",
@@ -76499,6 +78010,17 @@ Object.freeze({
76499
78010
  form: "single",
76500
78011
  optional: false
76501
78012
  }],
78013
+ "storageAdmin.adoptRecords": [{
78014
+ name: "records",
78015
+ form: "object-array",
78016
+ optional: false,
78017
+ itemField: "deviceId"
78018
+ }],
78019
+ "storageAdmin.readRecords": [{
78020
+ name: "deviceId",
78021
+ form: "single",
78022
+ optional: true
78023
+ }],
76502
78024
  "streamBroker.acquireEgressTranscode": [{
76503
78025
  name: "deviceId",
76504
78026
  form: "single",
@@ -78083,12 +79605,12 @@ function toHomematicOptions(config) {
78083
79605
  };
78084
79606
  }
78085
79607
  /**
78086
- * Top-level addon config that replaces the old single-CCU
78087
- * `{connection: HomematicConfig|null}` shape. Holds an ordered list of
78088
- * broker entries; the list defaults to empty so a fresh install requires
78089
- * no explicit initialisation.
79608
+ * A single registered Homematic CCU hub ("broker"). One broker entry maps
79609
+ * 1-to-1 with an operator-added integration and holds the validated CCU
79610
+ * connection settings plus an optional back-reference to the spawning
79611
+ * integration (used for cascade-delete when the integration is removed).
78090
79612
  */
78091
- var homematicAddonConfigSchema = object({ brokers: array(object({
79613
+ var HmBrokerEntrySchema = object({
78092
79614
  /** Stable opaque identifier — e.g. 'hm_001', 'hm_002'. */
78093
79615
  id: string().min(1),
78094
79616
  /** Human-readable label shown in the admin UI. */
@@ -78097,7 +79619,14 @@ var homematicAddonConfigSchema = object({ brokers: array(object({
78097
79619
  connection: homematicConfigSchema,
78098
79620
  /** FK to the spawning integration — auto-cleanup on integration delete. */
78099
79621
  integrationId: string().optional()
78100
- })).default([]) });
79622
+ });
79623
+ /**
79624
+ * Top-level addon config that replaces the old single-CCU
79625
+ * `{connection: HomematicConfig|null}` shape. Holds an ordered list of
79626
+ * broker entries; the list defaults to empty so a fresh install requires
79627
+ * no explicit initialisation.
79628
+ */
79629
+ var homematicAddonConfigSchema = object({ brokers: array(HmBrokerEntrySchema).default([]) });
78101
79630
  /**
78102
79631
  * Coerce a loose settings blob (e.g. from the broker `add`/`setSettings`
78103
79632
  * cap) through the connection schema, applying all schema defaults. Throws
@@ -78256,6 +79785,70 @@ function buildConnectionFormSchema() {
78256
79785
  }
78257
79786
  ] };
78258
79787
  }
79788
+ var hmBrokersEntryKind = defineEntryKind("brokers", {
79789
+ title: "Homematic brokers",
79790
+ schema: entryBody({
79791
+ connection: HmBrokerEntrySchema.shape.connection,
79792
+ integrationId: string().optional()
79793
+ }),
79794
+ writeTrigger: "an operator adds, edits or removes a Homematic CCU broker connection",
79795
+ adoptsFrom: settingsBrokersAdoptsFrom("provider-homematic")
79796
+ });
79797
+ //#endregion
79798
+ //#region src/hm-broker-store.ts
79799
+ function rowToEntry(id, data) {
79800
+ const parsed = HmBrokerEntrySchema.safeParse({
79801
+ id,
79802
+ name: data.name,
79803
+ connection: data.connection,
79804
+ integrationId: data.integrationId
79805
+ });
79806
+ return parsed.success ? parsed.data : null;
79807
+ }
79808
+ var HmBrokerStore = class HmBrokerStore {
79809
+ kind;
79810
+ constructor(kind) {
79811
+ this.kind = kind;
79812
+ }
79813
+ static of(records) {
79814
+ return new HmBrokerStore(records.kind(hmBrokersEntryKind));
79815
+ }
79816
+ async listResolved() {
79817
+ const page = await this.kind.query({ limit: 1e3 });
79818
+ const out = [];
79819
+ for (const record of page.records) {
79820
+ let data = record.data;
79821
+ try {
79822
+ const resolved = await this.kind.getResolved(record.id);
79823
+ if (resolved !== null) data = resolved.data;
79824
+ } catch (err) {
79825
+ if (!(err instanceof RecordSecretUnavailableError)) throw err;
79826
+ }
79827
+ const entry = rowToEntry(record.id, data);
79828
+ if (entry !== null) out.push(entry);
79829
+ }
79830
+ return out;
79831
+ }
79832
+ async replaceAll(entries) {
79833
+ const page = await this.kind.query({ limit: 1e3 });
79834
+ const nextIds = new Set(entries.map((e) => e.id));
79835
+ for (const row of page.records) if (!nextIds.has(row.id)) await this.kind.delete(row.id);
79836
+ for (const entry of entries) {
79837
+ const { id, name, connection, integrationId } = entry;
79838
+ const body = {
79839
+ name,
79840
+ connection,
79841
+ ...integrationId === void 0 ? {} : { integrationId }
79842
+ };
79843
+ const parsed = hmBrokersEntryKind.schema.safeParse(body);
79844
+ if (!parsed.success) throw new Error(`invalid HM broker '${id}': ${parsed.error.message}`);
79845
+ await this.kind.put({
79846
+ id,
79847
+ data: parsed.data
79848
+ });
79849
+ }
79850
+ }
79851
+ };
78259
79852
  //#endregion
78260
79853
  //#region ../../node_modules/nodehomematic/node_modules/undici/lib/core/symbols.js
78261
79854
  var require_symbols$4 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
@@ -103991,13 +105584,20 @@ var HomematicProviderAddon = class extends BaseDeviceProvider {
103991
105584
  deviceClasses = { [DeviceType.Container]: HmContainerDevice };
103992
105585
  /** Live multi-broker registry, or null before init / after shutdown. */
103993
105586
  registry = null;
105587
+ brokerStore = null;
105588
+ activeBrokers = [];
103994
105589
  constructor() {
103995
105590
  super({ ...DEFAULTS });
103996
105591
  }
103997
105592
  async onInitialize() {
103998
- const regs = await super.onInitialize();
105593
+ const regs = this.providerRegistrationsFromSuper(await super.onInitialize());
103999
105594
  const migrated = migrateLegacyConfig(await this.resolveGlobalStore());
104000
105595
  if (this.brokersDiffer(migrated.brokers, this.config.brokers)) await this.updateGlobalSettings({ brokers: migrated.brokers });
105596
+ const records = this.ctx.records;
105597
+ if (records === void 0) throw new Error("provider-homematic: ctx.records is required (hub-only addon)");
105598
+ await records.declare({ brokers: hmBrokersEntryKind });
105599
+ this.brokerStore = HmBrokerStore.of(records);
105600
+ this.activeBrokers = await this.loadPersistedBrokers();
104001
105601
  this.registry = new HmBrokerRegistry(this.ctx.logger);
104002
105602
  this.registry.setOnBrokerConnected((brokerId) => {
104003
105603
  this.ctx.logger.info("Homematic: broker connected", { meta: { brokerId } });
@@ -104007,8 +105607,8 @@ var HomematicProviderAddon = class extends BaseDeviceProvider {
104007
105607
  this.registry.setOnBrokerDisconnected((brokerId) => {
104008
105608
  this.setBrokerDevicesOnline(brokerId, false);
104009
105609
  });
104010
- await this.registry.restore(this.config.brokers);
104011
- this.ctx.logger.info("Homematic: provider initialised", { meta: { brokerCount: this.config.brokers.length } });
105610
+ await this.registry.restore(this.activeBrokers);
105611
+ this.ctx.logger.info("Homematic: provider initialised", { meta: { brokerCount: this.activeBrokers.length } });
104012
105612
  await this.reconcileIntegrationsToBrokers();
104013
105613
  this.subscribeIntegrationLifecycle();
104014
105614
  return [
@@ -104030,10 +105630,28 @@ var HomematicProviderAddon = class extends BaseDeviceProvider {
104030
105630
  * (persisting the registry-allocated id back when it differs), and apply
104031
105631
  * connection updates to existing rows.
104032
105632
  */
105633
+ async loadPersistedBrokers() {
105634
+ const store = this.brokerStore;
105635
+ if (store !== null) {
105636
+ const fromRecords = await store.listResolved();
105637
+ if (fromRecords.length > 0) return fromRecords;
105638
+ }
105639
+ return this.config.brokers;
105640
+ }
105641
+ async persistBrokerEntries(entries) {
105642
+ this.activeBrokers = [...entries];
105643
+ const store = this.brokerStore;
105644
+ if (store !== null) {
105645
+ await store.replaceAll(entries);
105646
+ return;
105647
+ }
105648
+ await this.updateGlobalSettings({ brokers: [...entries] });
105649
+ }
104033
105650
  async onConfigChanged() {
104034
105651
  const reg = this.registry;
104035
105652
  if (!reg) return;
104036
- const persisted = this.config.brokers;
105653
+ this.activeBrokers = await this.loadPersistedBrokers();
105654
+ const persisted = this.activeBrokers;
104037
105655
  const liveIds = new Set(reg.list().map((b) => b.id));
104038
105656
  const persistedIds = new Set(persisted.map((e) => e.id));
104039
105657
  for (const liveId of liveIds) if (!persistedIds.has(liveId)) try {
@@ -104064,7 +105682,7 @@ var HomematicProviderAddon = class extends BaseDeviceProvider {
104064
105682
  ...b,
104065
105683
  id: created.id
104066
105684
  } : b);
104067
- await this.updateGlobalSettings({ brokers: next });
105685
+ await this.persistBrokerEntries(next);
104068
105686
  }
104069
105687
  } catch (err) {
104070
105688
  this.ctx.logger.warn("Homematic onConfigChanged: failed to start new broker", { meta: {
@@ -104129,8 +105747,8 @@ var HomematicProviderAddon = class extends BaseDeviceProvider {
104129
105747
  return buildHmBrokerProvider({
104130
105748
  ownerAddonId: this.ctx.id,
104131
105749
  registry: this.requireRegistry(),
104132
- getBrokers: () => this.config.brokers,
104133
- persistBrokers: (brokers) => this.updateGlobalSettings({ brokers: [...brokers] }),
105750
+ getBrokers: () => this.activeBrokers,
105751
+ persistBrokers: (brokers) => this.persistBrokerEntries([...brokers]),
104134
105752
  cascadeRemoveDevices: (brokerId) => this.cascadeRemoveDevicesForBroker(brokerId),
104135
105753
  logger: this.ctx.logger
104136
105754
  });
@@ -104187,7 +105805,7 @@ var HomematicProviderAddon = class extends BaseDeviceProvider {
104187
105805
  brokerId
104188
105806
  });
104189
105807
  if (brokerId === void 0) continue;
104190
- if (!this.config.brokers.some((b) => b.id === brokerId)) {
105808
+ if (!this.activeBrokers.some((b) => b.id === brokerId)) {
104191
105809
  this.ctx.logger.warn("Homematic integration→broker: linked broker not found", { meta: {
104192
105810
  integrationId: integration.id,
104193
105811
  brokerId
@@ -104196,9 +105814,9 @@ var HomematicProviderAddon = class extends BaseDeviceProvider {
104196
105814
  }
104197
105815
  this.requireRegistry().linkIntegration(integration.id, brokerId);
104198
105816
  }
104199
- const linked = linkBrokersToIntegrations(this.config.brokers, integrations);
104200
- if (linked.some((b, i) => b !== this.config.brokers[i])) await this.updateGlobalSettings({ brokers: linked });
104201
- const toRemove = computeBrokerCleanup(this.config.brokers, survivingIntegrationIds);
105817
+ const linked = linkBrokersToIntegrations(this.activeBrokers, integrations);
105818
+ if (linked.some((b, i) => b !== this.activeBrokers[i])) await this.persistBrokerEntries(linked);
105819
+ const toRemove = computeBrokerCleanup(this.activeBrokers, survivingIntegrationIds);
104202
105820
  if (toRemove.length === 0) return;
104203
105821
  for (const id of toRemove) try {
104204
105822
  await this.requireRegistry().removeEntry(id);
@@ -104209,8 +105827,8 @@ var HomematicProviderAddon = class extends BaseDeviceProvider {
104209
105827
  error: errMsg(err)
104210
105828
  } });
104211
105829
  }
104212
- const nextBrokers = this.config.brokers.filter((b) => !toRemove.includes(b.id));
104213
- await this.updateGlobalSettings({ brokers: nextBrokers });
105830
+ const nextBrokers = this.activeBrokers.filter((b) => !toRemove.includes(b.id));
105831
+ await this.persistBrokerEntries(nextBrokers);
104214
105832
  this.ctx.logger.info("Homematic integration→broker reconcile", { meta: {
104215
105833
  brokerCount: nextBrokers.length,
104216
105834
  integrationCount: mine.length,