@camstack/addon-provider-homematic 1.2.180 → 1.2.182

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/addon.mjs CHANGED
@@ -795,7 +795,7 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
795
795
  return EventCategory;
796
796
  }({});
797
797
  //#endregion
798
- //#region ../types/dist/device-type-BOWLtoOt.mjs
798
+ //#region ../types/dist/device-type-D1fH5kaC.mjs
799
799
  /**
800
800
  import { errMsg } from '@camstack/types'
801
801
  * Extract a human-readable message from an unknown error value.
@@ -984,6 +984,9 @@ var DeviceFeature = /* @__PURE__ */ function(DeviceFeature) {
984
984
  DeviceFeature["CoverPositionable"] = "cover-positionable";
985
985
  /** Cover exposes slat-tilt control. Gates the tilt slider UI. */
986
986
  DeviceFeature["CoverTilt"] = "cover-tilt";
987
+ /** Cover has a real stop: `stop` halts the travel in place. Gates the stop
988
+ * control in exporters; a provider whose `stop` is a no-op never declares it. */
989
+ DeviceFeature["CoverStoppable"] = "cover-stoppable";
987
990
  /** Valve exposes intermediate position control (0..100). Gates the
988
991
  * position slider / drag surface UI. */
989
992
  DeviceFeature["ValvePositionable"] = "valve-positionable";
@@ -1023,6 +1026,12 @@ var DeviceFeature = /* @__PURE__ */ function(DeviceFeature) {
1023
1026
  DeviceFeature["MediaPlayerPrevious"] = "media-player-previous";
1024
1027
  /** Media player exposes stop distinct from pause. */
1025
1028
  DeviceFeature["MediaPlayerStop"] = "media-player-stop";
1029
+ /** Media player exposes volume up / down in steps (an infrared TV has no level). */
1030
+ DeviceFeature["MediaPlayerVolumeStep"] = "media-player-volume-step";
1031
+ /** Media player exposes channel up / down in steps. */
1032
+ DeviceFeature["MediaPlayerChannelStep"] = "media-player-channel-step";
1033
+ /** Media player exposes power on / off. */
1034
+ DeviceFeature["MediaPlayerPower"] = "media-player-power";
1026
1035
  /** Alarm panel requires a PIN code on arm/disarm. */
1027
1036
  DeviceFeature["AlarmPinRequired"] = "alarm-pin-required";
1028
1037
  /** Presence device carries GPS coordinates (lat/lng/accuracy) in
@@ -4559,6 +4568,12 @@ var numberProcessor = (schema, ctx, _json, _params) => {
4559
4568
  var booleanProcessor = (_schema, _ctx, json, _params) => {
4560
4569
  json.type = "boolean";
4561
4570
  };
4571
+ var bigintProcessor = (_schema, ctx, _json, _params) => {
4572
+ if (ctx.unrepresentable === "throw") throw new Error("BigInt cannot be represented in JSON Schema");
4573
+ };
4574
+ var symbolProcessor = (_schema, ctx, _json, _params) => {
4575
+ if (ctx.unrepresentable === "throw") throw new Error("Symbols cannot be represented in JSON Schema");
4576
+ };
4562
4577
  var nullProcessor = (_schema, ctx, json, _params) => {
4563
4578
  if (ctx.target === "openapi-3.0") {
4564
4579
  json.type = "string";
@@ -4566,12 +4581,17 @@ var nullProcessor = (_schema, ctx, json, _params) => {
4566
4581
  json.enum = [null];
4567
4582
  } else json.type = "null";
4568
4583
  };
4584
+ var undefinedProcessor = (_schema, ctx, _json, _params) => {
4585
+ if (ctx.unrepresentable === "throw") throw new Error("Undefined cannot be represented in JSON Schema");
4586
+ };
4569
4587
  var voidProcessor = (_schema, ctx, _json, _params) => {
4570
4588
  if (ctx.unrepresentable === "throw") throw new Error("Void cannot be represented in JSON Schema");
4571
4589
  };
4572
4590
  var neverProcessor = (_schema, _ctx, json, _params) => {
4573
4591
  json.not = {};
4574
4592
  };
4593
+ var anyProcessor = (_schema, _ctx, _json, _params) => {};
4594
+ var unknownProcessor = (_schema, _ctx, _json, _params) => {};
4575
4595
  var dateProcessor = (_schema, ctx, _json, _params) => {
4576
4596
  if (ctx.unrepresentable === "throw") throw new Error("Date cannot be represented in JSON Schema");
4577
4597
  };
@@ -4603,12 +4623,53 @@ var literalProcessor = (schema, ctx, json, _params) => {
4603
4623
  json.enum = vals;
4604
4624
  }
4605
4625
  };
4626
+ var nanProcessor = (_schema, ctx, _json, _params) => {
4627
+ if (ctx.unrepresentable === "throw") throw new Error("NaN cannot be represented in JSON Schema");
4628
+ };
4629
+ var templateLiteralProcessor = (schema, _ctx, json, _params) => {
4630
+ const _json = json;
4631
+ const pattern = schema._zod.pattern;
4632
+ if (!pattern) throw new Error("Pattern not found in template literal");
4633
+ _json.type = "string";
4634
+ _json.pattern = pattern.source;
4635
+ };
4636
+ var fileProcessor = (schema, _ctx, json, _params) => {
4637
+ const _json = json;
4638
+ const file = {
4639
+ type: "string",
4640
+ format: "binary",
4641
+ contentEncoding: "binary"
4642
+ };
4643
+ const { minimum, maximum, mime } = schema._zod.bag;
4644
+ if (minimum !== void 0) file.minLength = minimum;
4645
+ if (maximum !== void 0) file.maxLength = maximum;
4646
+ if (mime) if (mime.length === 1) {
4647
+ file.contentMediaType = mime[0];
4648
+ Object.assign(_json, file);
4649
+ } else {
4650
+ Object.assign(_json, file);
4651
+ _json.anyOf = mime.map((m) => ({ contentMediaType: m }));
4652
+ }
4653
+ else Object.assign(_json, file);
4654
+ };
4655
+ var successProcessor = (_schema, _ctx, json, _params) => {
4656
+ json.type = "boolean";
4657
+ };
4606
4658
  var customProcessor = (_schema, ctx, _json, _params) => {
4607
4659
  if (ctx.unrepresentable === "throw") throw new Error("Custom types cannot be represented in JSON Schema");
4608
4660
  };
4661
+ var functionProcessor = (_schema, ctx, _json, _params) => {
4662
+ if (ctx.unrepresentable === "throw") throw new Error("Function types cannot be represented in JSON Schema");
4663
+ };
4609
4664
  var transformProcessor = (_schema, ctx, _json, _params) => {
4610
4665
  if (ctx.unrepresentable === "throw") throw new Error("Transforms cannot be represented in JSON Schema");
4611
4666
  };
4667
+ var mapProcessor = (_schema, ctx, _json, _params) => {
4668
+ if (ctx.unrepresentable === "throw") throw new Error("Map cannot be represented in JSON Schema");
4669
+ };
4670
+ var setProcessor = (_schema, ctx, _json, _params) => {
4671
+ if (ctx.unrepresentable === "throw") throw new Error("Set cannot be represented in JSON Schema");
4672
+ };
4612
4673
  var arrayProcessor = (schema, ctx, _json, params) => {
4613
4674
  const json = _json;
4614
4675
  const def = schema._zod.def;
@@ -4813,6 +4874,12 @@ var readonlyProcessor = (schema, ctx, json, params) => {
4813
4874
  seen.ref = def.innerType;
4814
4875
  json.readOnly = true;
4815
4876
  };
4877
+ var promiseProcessor = (schema, ctx, _json, params) => {
4878
+ const def = schema._zod.def;
4879
+ process$1(def.innerType, ctx, params);
4880
+ const seen = ctx.seen.get(schema);
4881
+ seen.ref = def.innerType;
4882
+ };
4816
4883
  var optionalProcessor = (schema, ctx, _json, params) => {
4817
4884
  const def = schema._zod.def;
4818
4885
  process$1(def.innerType, ctx, params);
@@ -4825,6 +4892,81 @@ var lazyProcessor = (schema, ctx, _json, params) => {
4825
4892
  const seen = ctx.seen.get(schema);
4826
4893
  seen.ref = innerType;
4827
4894
  };
4895
+ var allProcessors = {
4896
+ string: stringProcessor,
4897
+ number: numberProcessor,
4898
+ boolean: booleanProcessor,
4899
+ bigint: bigintProcessor,
4900
+ symbol: symbolProcessor,
4901
+ null: nullProcessor,
4902
+ undefined: undefinedProcessor,
4903
+ void: voidProcessor,
4904
+ never: neverProcessor,
4905
+ any: anyProcessor,
4906
+ unknown: unknownProcessor,
4907
+ date: dateProcessor,
4908
+ enum: enumProcessor,
4909
+ literal: literalProcessor,
4910
+ nan: nanProcessor,
4911
+ template_literal: templateLiteralProcessor,
4912
+ file: fileProcessor,
4913
+ success: successProcessor,
4914
+ custom: customProcessor,
4915
+ function: functionProcessor,
4916
+ transform: transformProcessor,
4917
+ map: mapProcessor,
4918
+ set: setProcessor,
4919
+ array: arrayProcessor,
4920
+ object: objectProcessor,
4921
+ union: unionProcessor,
4922
+ intersection: intersectionProcessor,
4923
+ tuple: tupleProcessor,
4924
+ record: recordProcessor,
4925
+ nullable: nullableProcessor,
4926
+ nonoptional: nonoptionalProcessor,
4927
+ default: defaultProcessor,
4928
+ prefault: prefaultProcessor,
4929
+ catch: catchProcessor,
4930
+ pipe: pipeProcessor,
4931
+ readonly: readonlyProcessor,
4932
+ promise: promiseProcessor,
4933
+ optional: optionalProcessor,
4934
+ lazy: lazyProcessor
4935
+ };
4936
+ function toJSONSchema(input, params) {
4937
+ if ("_idmap" in input) {
4938
+ const registry = input;
4939
+ const ctx = initializeContext({
4940
+ ...params,
4941
+ processors: allProcessors
4942
+ });
4943
+ const defs = {};
4944
+ for (const entry of registry._idmap.entries()) {
4945
+ const [_, schema] = entry;
4946
+ process$1(schema, ctx);
4947
+ }
4948
+ const schemas = {};
4949
+ ctx.external = {
4950
+ registry,
4951
+ uri: params?.uri,
4952
+ defs
4953
+ };
4954
+ for (const entry of registry._idmap.entries()) {
4955
+ const [key, schema] = entry;
4956
+ extractDefs(ctx, schema);
4957
+ schemas[key] = finalize(ctx, schema);
4958
+ }
4959
+ if (Object.keys(defs).length > 0) schemas.__shared = { [ctx.target === "draft-2020-12" ? "$defs" : "definitions"]: defs };
4960
+ return { schemas };
4961
+ }
4962
+ const ctx = initializeContext({
4963
+ ...params,
4964
+ processors: allProcessors
4965
+ });
4966
+ process$1(input, ctx);
4967
+ extractDefs(ctx, input);
4968
+ return finalize(ctx, input);
4969
+ }
4828
4970
  //#endregion
4829
4971
  //#region ../../node_modules/zod/v4/classic/iso.js
4830
4972
  var ZodISODateTime = /*@__PURE__*/ $constructor("ZodISODateTime", (inst, def) => {
@@ -5849,7 +5991,7 @@ var ZodIssueCode = {
5849
5991
  var ZodFirstPartyTypeKind;
5850
5992
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
5851
5993
  //#endregion
5852
- //#region ../types/dist/sleep-B-vp7x15.mjs
5994
+ //#region ../types/dist/sleep-D1jjWAr8.mjs
5853
5995
  /**
5854
5996
  * The audio chunk plane's byte format, and the ONE expansion from a coded
5855
5997
  * window to float samples (D455).
@@ -5928,6 +6070,22 @@ function buildAlawTable() {
5928
6070
  }
5929
6071
  buildUlawTable();
5930
6072
  buildAlawTable();
6073
+ /**
6074
+ * An addon whose own migrations did not apply refuses to initialise (D987). The error is typed
6075
+ * so a runner hosting several addons can tell "this addon is blocked" from a crash and keep its
6076
+ * co-located siblings running. Recognised by NAME and shape, never `instanceof`: a forked addon
6077
+ * bundles its own copy of this module, so the class the runner sees is not the one that threw.
6078
+ */
6079
+ var MIGRATIONS_BLOCKED_ERROR_NAME = "AddonMigrationsBlockedError";
6080
+ var AddonMigrationsBlockedError = class extends Error {
6081
+ /** The ledger ids that did not apply and block the owner. */
6082
+ migrationIds;
6083
+ constructor(migrationIds) {
6084
+ super(`migration(s) ${migrationIds.join(", ")} did not apply and block this addon — fix or retry them (migrations.retry), then restart it`);
6085
+ this.name = MIGRATIONS_BLOCKED_ERROR_NAME;
6086
+ this.migrationIds = migrationIds;
6087
+ }
6088
+ };
5931
6089
  /** Is this field's stored value a credential? */
5932
6090
  function isSecretConfigField(field) {
5933
6091
  if (field.type === "password") return true;
@@ -5966,7 +6124,7 @@ function isKeychainStoredField(field) {
5966
6124
  var SECRET_CLEAR = { $secretClear: true };
5967
6125
  /** The `'***'` token D634 redaction writes for non-admins. */
5968
6126
  var LEGACY_DEVICE_REDACTION = "***";
5969
- function isRecord$6(value) {
6127
+ function isRecord$7(value) {
5970
6128
  return typeof value === "object" && value !== null && !Array.isArray(value);
5971
6129
  }
5972
6130
  function makeSecretMarker(ref) {
@@ -5977,12 +6135,19 @@ function makeSecretMarker(ref) {
5977
6135
  }
5978
6136
  /** A stored marker: an object whose `$secret` is a non-empty string. */
5979
6137
  function isSecretMarker(value) {
5980
- if (!isRecord$6(value)) return false;
6138
+ if (!isRecord$7(value)) return false;
5981
6139
  const ref = value["$secret"];
5982
6140
  return typeof ref === "string" && ref.length > 0;
5983
6141
  }
6142
+ /** Anything carrying a `$secret` key — a stored marker or a UI view of one. */
6143
+ function isSecretMarkerLike(value) {
6144
+ return isRecord$7(value) && Object.prototype.hasOwnProperty.call(value, "$secret");
6145
+ }
5984
6146
  function isSecretClear(value) {
5985
- return isRecord$6(value) && value["$secretClear"] === true;
6147
+ return isRecord$7(value) && value["$secretClear"] === true;
6148
+ }
6149
+ function isSecretFieldView(value) {
6150
+ return isRecord$7(value) && value["set"] === true && isSecretMarkerLike(value);
5986
6151
  }
5987
6152
  /**
5988
6153
  * The UI view of a stored secret field value: a marker becomes "set", inline
@@ -6365,6 +6530,53 @@ function emitReadiness(bus, params) {
6365
6530
  ts
6366
6531
  }));
6367
6532
  }
6533
+ /** Why a catalogue entry is not a runnable body of its declared kind. */
6534
+ var AddonMigrationDefinitionError = class extends Error {
6535
+ id;
6536
+ constructor(id, message) {
6537
+ super(`${id}: ${message}`);
6538
+ this.id = id;
6539
+ this.name = "AddonMigrationDefinitionError";
6540
+ }
6541
+ };
6542
+ /**
6543
+ * Bind a catalogue to the addon's ports. Throws {@link AddonMigrationDefinitionError} when
6544
+ * an entry's `bodyKind` does not match the body it carries, or is `sql` (a hub-only
6545
+ * body). A throwing body never escapes `execute`: it is reported as a failed result.
6546
+ */
6547
+ function defineAddonMigrations(catalogue, ports) {
6548
+ return catalogue.map((entry) => {
6549
+ const { meta } = entry;
6550
+ if ("plan" in entry) {
6551
+ if (meta.bodyKind !== "plan") throw new AddonMigrationDefinitionError(meta.id, `carries a plan body but declares "${meta.bodyKind}"`);
6552
+ return {
6553
+ meta,
6554
+ execute: () => guarded(async () => ({
6555
+ kind: "plan",
6556
+ plan: await entry.plan(ports)
6557
+ }))
6558
+ };
6559
+ }
6560
+ if (meta.bodyKind !== "procedure") throw new AddonMigrationDefinitionError(meta.id, `carries a procedure body but declares "${meta.bodyKind}"`);
6561
+ return {
6562
+ meta,
6563
+ execute: () => guarded(async () => ({
6564
+ kind: "procedure",
6565
+ result: await entry.procedure(ports)
6566
+ }))
6567
+ };
6568
+ });
6569
+ }
6570
+ async function guarded(work) {
6571
+ try {
6572
+ return await work();
6573
+ } catch (err) {
6574
+ return {
6575
+ kind: "failed",
6576
+ error: errMsg(err)
6577
+ };
6578
+ }
6579
+ }
6368
6580
  var NOT_RUN = {
6369
6581
  declared: false,
6370
6582
  snapshot: null,
@@ -6379,7 +6591,7 @@ var NOT_RUN = {
6379
6591
  * throws: an unreachable or refusing engine is logged and reported `declared: false`,
6380
6592
  * because the hub (and this addon's boot) must not hang on a migration.
6381
6593
  */
6382
- async function runAddonMigrations(host, migrations, logger) {
6594
+ async function runAddonMigrations(host, migrations, logger, options = {}) {
6383
6595
  const first = migrations[0];
6384
6596
  if (first === void 0) return NOT_RUN;
6385
6597
  const owner = first.meta.owner;
@@ -6408,7 +6620,9 @@ async function runAddonMigrations(host, migrations, logger) {
6408
6620
  else if (status === "blocked") blocked.push(id);
6409
6621
  else skipped.push(id);
6410
6622
  };
6623
+ const selected = options.only === void 0 ? null : new Set(options.only);
6411
6624
  for (const step of declaration.steps) {
6625
+ if (selected !== null && !selected.has(step.id)) continue;
6412
6626
  const bound = byId.get(step.id);
6413
6627
  if (bound === void 0 || step.action === "skip") {
6414
6628
  skipped.push(step.id);
@@ -6586,11 +6800,36 @@ function projectStore(store, perNodeKeys, nodeId) {
6586
6800
  }
6587
6801
  return out;
6588
6802
  }
6803
+ /**
6804
+ * The address of one keychain value: `secret://<owner>/<scope>/<fieldPath>`.
6805
+ *
6806
+ * A ref is DETERMINISTIC from where the value lives — the owner addon, the
6807
+ * scope (global, one node, one device, one integration, one row of a business
6808
+ * collection) and the field path inside that scope — so saving the same field
6809
+ * twice updates the same ref, and the ref itself says which settings blob
6810
+ * points at it. It is also the AAD of the value's ciphertext: a ciphertext
6811
+ * copied onto another ref does not decrypt.
6812
+ *
6813
+ * Array items are addressed by ITEM ID, never by index
6814
+ * (`providers[authentik].clientSecret`), so reordering a list keeps every ref.
6815
+ *
6816
+ * Pure and browser-safe: no node builtins, no I/O.
6817
+ */
6818
+ /** The URI scheme of every keychain ref. */
6819
+ var SECRET_REF_SCHEME = "secret://";
6589
6820
  var GLOBAL_SCOPE = { kind: "global" };
6590
6821
  /** The scope every addon-wide (not per-node, not per-device) setting lives in. */
6591
6822
  function globalSecretScope() {
6592
6823
  return GLOBAL_SCOPE;
6593
6824
  }
6825
+ /**
6826
+ * An addon id as a ref owner. A hub in-process builtin's context id is
6827
+ * `addon:<id>`; the owner of its secrets is `<id>`, exactly as for the same
6828
+ * addon running forked.
6829
+ */
6830
+ function normalizeSecretOwner(addonId) {
6831
+ return addonId.startsWith("addon:") ? addonId.slice(6) : addonId;
6832
+ }
6594
6833
  function encodeSegment(value) {
6595
6834
  return encodeURIComponent(value);
6596
6835
  }
@@ -6601,6 +6840,16 @@ function decodeSegment(value) {
6601
6840
  return null;
6602
6841
  }
6603
6842
  }
6843
+ /** The scope as it appears inside a ref (`global`, `node/<id>`, …). */
6844
+ function formatSecretScope(scope) {
6845
+ switch (scope.kind) {
6846
+ case "global": return "global";
6847
+ case "node": return `node/${encodeSegment(scope.nodeId)}`;
6848
+ case "device": return `device/${scope.deviceId}`;
6849
+ case "integration": return `integration/${encodeSegment(scope.integrationId)}`;
6850
+ case "row": return `row/${encodeSegment(scope.collection)}/${encodeSegment(scope.rowId)}`;
6851
+ }
6852
+ }
6604
6853
  /**
6605
6854
  * The field path of a value inside an array item, addressed by the item's id:
6606
6855
  * `arrayItemFieldPath('providers', 'authentik', 'clientSecret')` →
@@ -6609,6 +6858,13 @@ function decodeSegment(value) {
6609
6858
  function arrayItemFieldPath(arrayKey, itemId, fieldKey) {
6610
6859
  return `${arrayKey}[${encodeSegment(itemId)}].${fieldKey}`;
6611
6860
  }
6861
+ /** Build a ref. Throws on an empty owner or field path — both are bugs. */
6862
+ function buildSecretRef(parts) {
6863
+ const owner = normalizeSecretOwner(parts.owner);
6864
+ if (owner.length === 0) throw new Error("buildSecretRef: owner is empty");
6865
+ if (parts.fieldPath.length === 0) throw new Error("buildSecretRef: fieldPath is empty");
6866
+ return `${SECRET_REF_SCHEME}${encodeSegment(owner)}/${formatSecretScope(parts.scope)}/${parts.fieldPath}`;
6867
+ }
6612
6868
  function parseScope(segments) {
6613
6869
  switch (segments[0]) {
6614
6870
  case "global": return {
@@ -6688,7 +6944,7 @@ var KeychainWriteRefusedError = class extends Error {
6688
6944
  }
6689
6945
  };
6690
6946
  var KEEP = { kind: "keep" };
6691
- function isRecord$5(value) {
6947
+ function isRecord$6(value) {
6692
6948
  return typeof value === "object" && value !== null && !Array.isArray(value);
6693
6949
  }
6694
6950
  function defaultMintId() {
@@ -6701,7 +6957,7 @@ function collectSecretMarkerRefs(value, out = []) {
6701
6957
  return out;
6702
6958
  }
6703
6959
  if (Array.isArray(value)) for (const item of value) collectSecretMarkerRefs(item, out);
6704
- else if (isRecord$5(value)) for (const child of Object.values(value)) collectSecretMarkerRefs(child, out);
6960
+ else if (isRecord$6(value)) for (const child of Object.values(value)) collectSecretMarkerRefs(child, out);
6705
6961
  return out;
6706
6962
  }
6707
6963
  async function storedValueEquals(secrets, marker, candidate) {
@@ -6756,7 +7012,7 @@ function rowId(row, idKey) {
6756
7012
  return null;
6757
7013
  }
6758
7014
  async function writeArray(ctx, node, incoming, stored, fieldPath) {
6759
- const storedRows = Array.isArray(stored) ? stored.filter(isRecord$5) : [];
7015
+ const storedRows = Array.isArray(stored) ? stored.filter(isRecord$6) : [];
6760
7016
  if (!Array.isArray(incoming)) {
6761
7017
  ctx.deletes.push(...collectSecretMarkerRefs(storedRows));
6762
7018
  return {
@@ -6772,7 +7028,7 @@ async function writeArray(ctx, node, incoming, stored, fieldPath) {
6772
7028
  const kept = /* @__PURE__ */ new Set();
6773
7029
  const rows = [];
6774
7030
  for (const row of incoming) {
6775
- if (!isRecord$5(row)) {
7031
+ if (!isRecord$6(row)) {
6776
7032
  rows.push(row);
6777
7033
  continue;
6778
7034
  }
@@ -6797,7 +7053,7 @@ async function writeNode(ctx, node, incoming, stored, fieldPath) {
6797
7053
  case "leaf": return writeLeaf(ctx, incoming, stored, fieldPath);
6798
7054
  case "array": return writeArray(ctx, node, incoming, stored, fieldPath);
6799
7055
  case "object": {
6800
- if (!isRecord$5(incoming)) {
7056
+ if (!isRecord$6(incoming)) {
6801
7057
  if (incoming === void 0) return KEEP;
6802
7058
  ctx.deletes.push(...collectSecretMarkerRefs(stored));
6803
7059
  return {
@@ -6805,7 +7061,7 @@ async function writeNode(ctx, node, incoming, stored, fieldPath) {
6805
7061
  value: incoming
6806
7062
  };
6807
7063
  }
6808
- const storedObj = isRecord$5(stored) ? stored : {};
7064
+ const storedObj = isRecord$6(stored) ? stored : {};
6809
7065
  return {
6810
7066
  kind: "value",
6811
7067
  value: await writeMembers(ctx, node.children, incoming, storedObj, (m) => `${fieldPath}.${m}`)
@@ -6928,7 +7184,7 @@ async function resolveSecretMarkers(value, secrets, options = {}) {
6928
7184
  value: items
6929
7185
  };
6930
7186
  }
6931
- if (isRecord$5(v)) {
7187
+ if (isRecord$6(v)) {
6932
7188
  const out = {};
6933
7189
  for (const [k, child] of Object.entries(v)) {
6934
7190
  const s = substitute(child);
@@ -6960,7 +7216,7 @@ var SecretOverwriteRefusedError = class extends Error {
6960
7216
  this.name = "SecretOverwriteRefusedError";
6961
7217
  }
6962
7218
  };
6963
- function isRecord$4(value) {
7219
+ function isRecord$5(value) {
6964
7220
  return typeof value === "object" && value !== null && !Array.isArray(value);
6965
7221
  }
6966
7222
  function resolvedValue(pass, marker) {
@@ -6989,7 +7245,7 @@ function inArray(pass, incoming, stored) {
6989
7245
  return incoming.map((item, index) => {
6990
7246
  const twin = stored[index];
6991
7247
  if (isSecretMarker(twin)) return typeof item === "string" && item === resolvedValue(pass, twin) ? twin : item;
6992
- if (isRecord$4(item) && isRecord$4(twin)) return inArrayRow(pass, item, twin);
7248
+ if (isRecord$5(item) && isRecord$5(twin)) return inArrayRow(pass, item, twin);
6993
7249
  if (Array.isArray(item) && Array.isArray(twin)) return inArray(pass, item, twin);
6994
7250
  return item;
6995
7251
  });
@@ -7000,7 +7256,7 @@ function inArrayRow(pass, incoming, stored) {
7000
7256
  const twin = stored[key];
7001
7257
  if (isSecretMarker(twin)) {
7002
7258
  if (typeof value === "string" && value === resolvedValue(pass, twin)) out[key] = twin;
7003
- } else if (isRecord$4(value) && isRecord$4(twin)) out[key] = inArrayRow(pass, value, twin);
7259
+ } else if (isRecord$5(value) && isRecord$5(twin)) out[key] = inArrayRow(pass, value, twin);
7004
7260
  else if (Array.isArray(value) && Array.isArray(twin)) out[key] = inArray(pass, value, twin);
7005
7261
  }
7006
7262
  return out;
@@ -7008,7 +7264,7 @@ function inArrayRow(pass, incoming, stored) {
7008
7264
  async function walk(pass, incoming, stored) {
7009
7265
  if (isSecretMarker(stored)) return atMarker(pass, incoming, stored);
7010
7266
  if (Array.isArray(incoming) && Array.isArray(stored)) return inArray(pass, incoming, stored);
7011
- if (!isRecord$4(incoming) || !isRecord$4(stored)) return incoming;
7267
+ if (!isRecord$5(incoming) || !isRecord$5(stored)) return incoming;
7012
7268
  const out = { ...incoming };
7013
7269
  for (const [key, value] of Object.entries(incoming)) out[key] = await walk(pass, value, stored[key]);
7014
7270
  return out;
@@ -7039,7 +7295,7 @@ async function restoreUnchangedSecrets(input) {
7039
7295
  function isJsonEqual(a, b) {
7040
7296
  if (Object.is(a, b)) return true;
7041
7297
  if (Array.isArray(a)) return Array.isArray(b) && a.length === b.length && a.every((v, i) => isJsonEqual(v, b[i]));
7042
- if (isRecord$4(a) && isRecord$4(b)) {
7298
+ if (isRecord$5(a) && isRecord$5(b)) {
7043
7299
  const keys = Object.keys(a);
7044
7300
  if (keys.length !== Object.keys(b).length) return false;
7045
7301
  return keys.every((k) => Object.prototype.hasOwnProperty.call(b, k) && isJsonEqual(a[k], b[k]));
@@ -7063,7 +7319,7 @@ function markerKeysOf(blob, owner) {
7063
7319
  }
7064
7320
  function nodeFromStored(value, owner) {
7065
7321
  if (isSecretMarker(value)) return isSecretRefOwnedBy(value.$secret, owner) ? { kind: "leaf" } : null;
7066
- if (!isRecord$4(value)) return null;
7322
+ if (!isRecord$5(value)) return null;
7067
7323
  const children = /* @__PURE__ */ new Map();
7068
7324
  for (const [key, child] of Object.entries(value)) {
7069
7325
  const node = nodeFromStored(child, owner);
@@ -7526,15 +7782,19 @@ var BaseAddon = class {
7526
7782
  * nothing; the boot continues. A migration that FAILED (or was blocked by one)
7527
7783
  * and declares `onFailure: 'block-owner'` makes this throw, so the addon does not
7528
7784
  * serve data whose shape it cannot trust; `tolerate` migrations never do.
7785
+ *
7786
+ * ALWAYS pass the whole catalogue; a phase that must run only some of it passes
7787
+ * `{ only: [ids] }` — never a filtered catalogue (the engine would judge the
7788
+ * omitted applied ids "newer").
7529
7789
  */
7530
- async runMigrations(migrations) {
7790
+ async runMigrations(migrations, options) {
7531
7791
  const api = this.ctx.api.migrations;
7532
7792
  const report = await runAddonMigrations({
7533
7793
  declareOwner: (input) => api.declareOwner.mutate(input),
7534
7794
  startMigration: (input) => api.startMigration.mutate(input),
7535
7795
  finishMigration: (input) => api.finishMigration.mutate(input)
7536
- }, migrations, this.ctx.logger);
7537
- if (report.blockOwner.length > 0) throw new Error(`migration(s) ${report.blockOwner.join(", ")} did not apply and block this addon — fix or retry them (migrations.retry), then restart it`);
7796
+ }, migrations, this.ctx.logger, options);
7797
+ if (report.blockOwner.length > 0) throw new AddonMigrationsBlockedError(report.blockOwner);
7538
7798
  return report;
7539
7799
  }
7540
7800
  /**
@@ -7682,6 +7942,44 @@ var BaseAddon = class {
7682
7942
  return null;
7683
7943
  }
7684
7944
  /**
7945
+ * D986 scoped settings: the form shape of the CLUSTER-wide settings one capability this addon
7946
+ * provides owns, or `null` when it has none. `cap` is a capability name the addon's manifest
7947
+ * declares. Stored as `addon-settings` rows `<addonId>.<field>`. The keys of this schema, of
7948
+ * {@link nodeSettingsSchema} and of {@link deviceDefaultsSchema} are disjoint, and a key never
7949
+ * contains `@` (guard `check-scoped-settings-declared`). SHAPE only: values are read by scope.
7950
+ */
7951
+ async clusterSettingsSchema(_cap) {
7952
+ return null;
7953
+ }
7954
+ /**
7955
+ * D986: the form shape of the settings one capability owns PER NODE, or `null`. Stored as
7956
+ * `addon-settings` rows `<addonId>.<field>@<nodeId>` carrying `nodeId` in the row data, so a
7957
+ * forgotten node's rows go in one central delete.
7958
+ */
7959
+ async nodeSettingsSchema(_cap) {
7960
+ return null;
7961
+ }
7962
+ /**
7963
+ * D986: the form shape of the FLEET DEFAULTS of the per-device settings one capability owns,
7964
+ * or `null`. Stored as `addon-settings` rows `<addonId>.<field>`; a device resolves its value
7965
+ * as device row, then this default, then the schema default (`resolveDeviceSettings`).
7966
+ */
7967
+ async deviceDefaultsSchema(_cap) {
7968
+ return null;
7969
+ }
7970
+ /**
7971
+ * The host's read of the scoped declarations: the schema one capability declares for `scope`,
7972
+ * or `null`. Beside {@link getIntegrationFormSchema}, the same shape: the hook is protected, the
7973
+ * host asks this method.
7974
+ */
7975
+ async getScopedSettingsSchema(scope, cap) {
7976
+ switch (scope) {
7977
+ case "cluster": return this.clusterSettingsSchema(cap);
7978
+ case "node": return this.nodeSettingsSchema(cap);
7979
+ case "device-defaults": return this.deviceDefaultsSchema(cap);
7980
+ }
7981
+ }
7982
+ /**
7685
7983
  * What the create wizard and the integration edit page render for one instance: the addon's
7686
7984
  * per-instance schema when it declares one, else its global schema (what they always showed).
7687
7985
  */
@@ -7836,6 +8134,10 @@ var BaseAddon = class {
7836
8134
  const stored = keychain ? await this.readAddonStoreWithRetry() : {};
7837
8135
  const patch = {};
7838
8136
  for (const key of keys) {
8137
+ if (tree.get(key)?.kind === "array") {
8138
+ patch[key] = [];
8139
+ continue;
8140
+ }
7839
8141
  const keychainStored = tree.has(key) || collectSecretMarkerRefs(stored[key]).length > 0;
7840
8142
  patch[key] = keychain && keychainStored ? SECRET_CLEAR : "";
7841
8143
  }
@@ -8475,6 +8777,237 @@ function normalizeAddonInitResult(result) {
8475
8777
  if (Array.isArray(result)) return { providers: result };
8476
8778
  return result;
8477
8779
  }
8780
+ var PREFIX = "records/";
8781
+ /** The base of every records failure. `detail` is the human part of the message. */
8782
+ var RecordsError = class extends Error {
8783
+ code;
8784
+ detail;
8785
+ constructor(code, detail) {
8786
+ super(`${PREFIX}${code}: ${detail}`);
8787
+ this.name = "RecordsError";
8788
+ this.code = code;
8789
+ this.detail = detail;
8790
+ }
8791
+ };
8792
+ /** A write guarded by `ifRev` found another revision (or an existing row for `ifRev: 0`). */
8793
+ var RevConflictError = class extends RecordsError {
8794
+ constructor(detail) {
8795
+ super("rev-conflict", detail);
8796
+ this.name = "RevConflictError";
8797
+ }
8798
+ };
8799
+ /** The keychain could not store or serve a value: explicit, never an empty string. */
8800
+ var RecordSecretUnavailableError = class extends RecordsError {
8801
+ constructor(detail) {
8802
+ super("secret-unavailable", detail);
8803
+ this.name = "RecordSecretUnavailableError";
8804
+ }
8805
+ };
8806
+ var InvalidRecordError = class extends RecordsError {
8807
+ constructor(detail) {
8808
+ super("invalid-record", detail);
8809
+ this.name = "InvalidRecordError";
8810
+ }
8811
+ };
8812
+ /** A kind declaration the engine refuses (non-additive change, bad shape, wrong file). */
8813
+ var DeclarationRefusedError = class extends RecordsError {
8814
+ constructor(detail) {
8815
+ super("declaration-refused", detail);
8816
+ this.name = "DeclarationRefusedError";
8817
+ }
8818
+ };
8819
+ /** Limits and names of `ctx.records` (D881). One authority; the engine and the facade read it. */
8820
+ /** The files a kind may live in. `history` is device-history's (D850), never records. */
8821
+ var RECORD_DATABASES = ["settings", "events"];
8822
+ /** The classes of a kind: the `@durable` vocabulary, one authority (replaces the annotation). */
8823
+ var RECORD_CLASSES = [
8824
+ "config",
8825
+ "ledger",
8826
+ "audit",
8827
+ "mirror",
8828
+ "ephemeral"
8829
+ ];
8830
+ var RECORD_DEFAULT_MAX_DATA_BYTES = 64 * 1024;
8831
+ var RECORD_MAX_DATA_BYTES = 1024 * 1024;
8832
+ var RECORD_BATCH_MAX = 1e3;
8833
+ var RECORD_QUERY_MAX = 1e3;
8834
+ /** A kind in the `settings` file may not bound itself above this (D447: high volume is `events`). */
8835
+ var RECORD_SETTINGS_MAX_ROWS = 5e4;
8836
+ /** The `Column`-free proof prefix: a ref collection for a kind's secret fields. */
8837
+ var RECORD_SECRET_COLLECTION_PREFIX = "records:";
8838
+ /**
8839
+ * Secret fields of a record, addressed the way a Zod schema declares them
8840
+ * (`collectZodSecretPaths`): dotted keys, `[]` for "each element of this array"
8841
+ * (`auth.accessToken`, `headers[].value`).
8842
+ *
8843
+ * `{}` after a key means "each value of this map" (`applianceSecrets{}`): the map's own key
8844
+ * names the value (`applianceSecrets{fridge}`), so no id key is declared and a body that drops a
8845
+ * key releases exactly that key's secret.
8846
+ *
8847
+ * Array elements are matched by a DECLARED id key (`secretArrayKeys`:
8848
+ * `{ headers: 'name' }`), never by index, so reordering a list keeps every
8849
+ * keychain ref (the same rule as `arrayItemFieldPath`). The concrete path of a
8850
+ * leaf names its element: `headers[X-Api].value`.
8851
+ *
8852
+ * Pure and browser-safe. Nothing here mutates: every transform returns a new value.
8853
+ */
8854
+ /** The array prefixes (declared form, e.g. `headers` or `a.headers`) of a path. */
8855
+ function parseSecretPath(path) {
8856
+ if (path.length === 0) throw new InvalidRecordError("an empty secret path");
8857
+ return path.split(".").map((raw) => {
8858
+ const each = raw.endsWith("[]");
8859
+ const map = raw.endsWith("{}");
8860
+ const key = each || map ? raw.slice(0, -2) : raw;
8861
+ if (key.length === 0) throw new InvalidRecordError(`secret path "${path}" has an empty segment`);
8862
+ return {
8863
+ key,
8864
+ each,
8865
+ map
8866
+ };
8867
+ });
8868
+ }
8869
+ /** The declared array prefixes of `path` that need an id key (`headers`, `a.rows`). */
8870
+ function secretArrayPrefixes(path) {
8871
+ const segments = parseSecretPath(path);
8872
+ const prefixes = [];
8873
+ const walked = [];
8874
+ for (const segment of segments) {
8875
+ walked.push(segment.key);
8876
+ if (segment.each) prefixes.push(walked.join("."));
8877
+ }
8878
+ return prefixes;
8879
+ }
8880
+ function isRecord$4(value) {
8881
+ return typeof value === "object" && value !== null && !Array.isArray(value);
8882
+ }
8883
+ function elementId(element, idKey, declared, prefix) {
8884
+ const id = isRecord$4(element) ? element[idKey] : void 0;
8885
+ if (typeof id !== "string" || id.length === 0) throw new InvalidRecordError(`"${declared}": every element of "${prefix}" needs a non-empty string "${idKey}" to carry a secret`);
8886
+ return id;
8887
+ }
8888
+ /**
8889
+ * Visit every secret leaf PRESENT in `data` (an absent branch has nothing to
8890
+ * visit). `replace` returns the new leaf value, or {@link REMOVE_LEAF}; the
8891
+ * result is a new body, `data` is untouched.
8892
+ */
8893
+ var REMOVE_LEAF = Symbol("remove-leaf");
8894
+ function mapAt(node, segments, index, walkedKeys, concretePrefix, declared, arrayKeys, visit) {
8895
+ if (!isRecord$4(node)) return node;
8896
+ const segment = segments[index];
8897
+ if (segment === void 0) return node;
8898
+ if (!Object.prototype.hasOwnProperty.call(node, segment.key)) return node;
8899
+ const child = node[segment.key];
8900
+ const keys = [...walkedKeys, segment.key];
8901
+ const last = index === segments.length - 1;
8902
+ if (segment.each) {
8903
+ if (!Array.isArray(child)) return node;
8904
+ const prefix = keys.join(".");
8905
+ const idKey = arrayKeys[prefix];
8906
+ if (idKey === void 0) throw new InvalidRecordError(`"${declared}": no id key declared for the array "${prefix}"`);
8907
+ const mapped = child.map((element) => {
8908
+ const id = elementId(element, idKey, declared, prefix);
8909
+ const concrete = `${concretePrefix}${concretePrefix.length > 0 ? "." : ""}${segment.key}[${encodeURIComponent(id)}]`;
8910
+ return last ? element : mapAt(element, segments, index + 1, keys, concrete, declared, arrayKeys, visit);
8911
+ });
8912
+ return {
8913
+ ...node,
8914
+ [segment.key]: mapped
8915
+ };
8916
+ }
8917
+ if (segment.map) {
8918
+ if (!isRecord$4(child)) return node;
8919
+ const kept = Object.entries(child).map(([mapKey, value]) => {
8920
+ const concrete = `${concretePrefix}${concretePrefix.length > 0 ? "." : ""}${segment.key}{${encodeURIComponent(mapKey)}}`;
8921
+ if (!last) return [mapKey, mapAt(value, segments, index + 1, keys, concrete, declared, arrayKeys, visit)];
8922
+ return [mapKey, visit({
8923
+ declared,
8924
+ concrete,
8925
+ value
8926
+ })];
8927
+ }).filter(([, value]) => value !== REMOVE_LEAF);
8928
+ return {
8929
+ ...node,
8930
+ [segment.key]: Object.fromEntries(kept)
8931
+ };
8932
+ }
8933
+ const concrete = `${concretePrefix}${concretePrefix.length > 0 ? "." : ""}${segment.key}`;
8934
+ if (last) {
8935
+ const replacement = visit({
8936
+ declared,
8937
+ concrete,
8938
+ value: child
8939
+ });
8940
+ if (replacement === REMOVE_LEAF) return Object.fromEntries(Object.entries(node).filter(([key]) => key !== segment.key));
8941
+ return {
8942
+ ...node,
8943
+ [segment.key]: replacement
8944
+ };
8945
+ }
8946
+ return {
8947
+ ...node,
8948
+ [segment.key]: mapAt(child, segments, index + 1, keys, concrete, declared, arrayKeys, visit)
8949
+ };
8950
+ }
8951
+ /** Replace/remove every present secret leaf; returns a NEW body. */
8952
+ function mapSecretLeaves(data, paths, arrayKeys, visit) {
8953
+ let current = data;
8954
+ for (const declared of paths) current = mapAt(current, parseSecretPath(declared), 0, [], "", declared, arrayKeys, visit);
8955
+ return current;
8956
+ }
8957
+ /** Every present secret leaf, read-only. */
8958
+ function collectSecretLeaves(data, paths, arrayKeys) {
8959
+ const found = [];
8960
+ mapSecretLeaves(data, paths, arrayKeys, (leaf) => {
8961
+ found.push(leaf);
8962
+ return leaf.value;
8963
+ });
8964
+ return found;
8965
+ }
8966
+ /**
8967
+ * The keychain collection name a kind's secrets live under. Prefixed so a
8968
+ * record's refs never collide with the refs a legacy collection of the same name
8969
+ * already holds during an adoption.
8970
+ */
8971
+ function recordSecretCollection(kind) {
8972
+ return `${RECORD_SECRET_COLLECTION_PREFIX}${kind}`;
8973
+ }
8974
+ /** The ONE ref a row's secret field may carry: the engine and the facade both build it here. */
8975
+ function recordSecretRef(owner, kind, rowId, concretePath) {
8976
+ return buildSecretRef({
8977
+ owner,
8978
+ scope: {
8979
+ kind: "row",
8980
+ collection: recordSecretCollection(kind),
8981
+ rowId
8982
+ },
8983
+ fieldPath: concretePath
8984
+ });
8985
+ }
8986
+ /**
8987
+ * A stored secret, as an admin read shows it: a VIEW naming the row's own
8988
+ * keychain ref (`set: true`), never the value and no longer the bare redaction
8989
+ * token. The form hands it to the secret field, which reveals the value by ref
8990
+ * through the audited `keychain-admin.reveal`; sent back untouched it keeps the
8991
+ * stored secret (the records door reads a view as KEEP).
8992
+ *
8993
+ * ONE implementation for the entries service and for every addon that serves
8994
+ * its own instances (`RecordIntegrationInstances`).
8995
+ */
8996
+ function isRecord$3(value) {
8997
+ return typeof value === "object" && value !== null && !Array.isArray(value);
8998
+ }
8999
+ function secretViewsOf(owner, kind, id, decl, data) {
9000
+ if (decl.secretPaths.length === 0) return data;
9001
+ const shown = mapSecretLeaves(data, decl.secretPaths, decl.secretArrayKeys, (leaf) => {
9002
+ if (leaf.value !== "__camstack_redacted__") return leaf.value;
9003
+ return {
9004
+ $secret: recordSecretRef(owner, kind, id, leaf.concrete),
9005
+ v: 1,
9006
+ set: true
9007
+ };
9008
+ });
9009
+ return isRecord$3(shown) ? shown : data;
9010
+ }
8478
9011
  /**
8479
9012
  * The share-view scope kinds a share-link token can carry. The hub mints
8480
9013
  * and validates them (`ShareViewGrantSchema` builds its
@@ -8499,21 +9032,6 @@ var PeerBytesTicketSchema = object({
8499
9032
  */
8500
9033
  declaredBytes: number().int().nonnegative().nullable()
8501
9034
  });
8502
- /** Limits and names of `ctx.records` (D881). One authority; the engine and the facade read it. */
8503
- /** The files a kind may live in. `history` is device-history's (D850), never records. */
8504
- var RECORD_DATABASES = ["settings", "events"];
8505
- /** The classes of a kind: the `@durable` vocabulary, one authority (replaces the annotation). */
8506
- var RECORD_CLASSES = [
8507
- "config",
8508
- "ledger",
8509
- "audit",
8510
- "mirror",
8511
- "ephemeral"
8512
- ];
8513
- var RECORD_DEFAULT_MAX_DATA_BYTES = 64 * 1024;
8514
- var RECORD_MAX_DATA_BYTES = 1024 * 1024;
8515
- var RECORD_BATCH_MAX = 1e3;
8516
- var RECORD_QUERY_MAX = 1e3;
8517
9035
  function defOf(schema) {
8518
9036
  const zodBag = Reflect.get(schema, "_zod");
8519
9037
  if (typeof zodBag !== "object" || zodBag === null) return {};
@@ -8562,7 +9080,8 @@ function isZodSecret(schema) {
8562
9080
  }
8563
9081
  /**
8564
9082
  * Every declared secret path in a config schema: dotted keys, `[]` for "each
8565
- * element of this array" (`connection.password`, `rows[].token`). A declared
9083
+ * element of this array" (`connection.password`, `rows[].token`), `{}` for "each value of this
9084
+ * map" (`applianceSecrets{}`). A declared
8566
9085
  * object or array is reported as one path and not descended into — everything
8567
9086
  * under it is secret.
8568
9087
  */
@@ -8573,6 +9092,7 @@ function collectZodSecretPaths(schema, prefix = "") {
8573
9092
  const def = defOf(layer);
8574
9093
  if (def.type === "object" && def.shape) for (const [key, child] of Object.entries(def.shape)) paths.push(...collectZodSecretPaths(child, prefix ? `${prefix}.${key}` : key));
8575
9094
  else if (def.type === "array" && def.element) paths.push(...collectZodSecretPaths(def.element, `${prefix}[]`));
9095
+ else if (def.type === "record" && def.valueType) paths.push(...collectZodSecretPaths(def.valueType, `${prefix}{}`));
8576
9096
  else if (def.type === "union" && def.options) for (const option of def.options) paths.push(...collectZodSecretPaths(option, prefix));
8577
9097
  else if (def.type === "intersection") {
8578
9098
  if (def.left) paths.push(...collectZodSecretPaths(def.left, prefix));
@@ -8647,6 +9167,126 @@ var RecordKindDeclarationSchema = object({
8647
9167
  }).strict();
8648
9168
  /** The kind names: lower-case, dash separated, short enough for an index name. */
8649
9169
  var RecordKindNameSchema = string().regex(/^[a-z][a-z0-9-]{0,47}$/);
9170
+ /** Cross-field rules a declaration must satisfy. Throws {@link DeclarationRefusedError}. */
9171
+ function assertValidDeclaration(name, decl) {
9172
+ const refuse = (why) => {
9173
+ throw new DeclarationRefusedError(`kind "${name}": ${why}`);
9174
+ };
9175
+ if (!RecordKindNameSchema.safeParse(name).success) refuse("the name must be lower-case-dashed");
9176
+ const seen = /* @__PURE__ */ new Set();
9177
+ for (const index of decl.indexes) {
9178
+ if (seen.has(index.name)) refuse(`index name "${index.name}" is declared twice`);
9179
+ seen.add(index.name);
9180
+ }
9181
+ const { retention } = decl;
9182
+ const hasSecrets = decl.secretPaths.length > 0;
9183
+ if ("ttlMs" in retention) {
9184
+ if (retention.from === "at" && decl.at !== "required") refuse("a ttl from \"at\" needs at: \"required\"");
9185
+ if (hasSecrets) refuse("a kind with secret fields cannot use engine TTL (its keychain values would be orphaned)");
9186
+ }
9187
+ if ("maxRows" in retention || "maxRowsPerDevice" in retention) {
9188
+ if (retention.maxRowsPerDevice !== void 0 && decl.device !== "required") refuse("maxRowsPerDevice needs device: \"required\"");
9189
+ if (decl.at !== "required") refuse("a row bound trims the oldest \"at\": it needs at: \"required\"");
9190
+ if (hasSecrets) refuse("a kind with secret fields cannot use an engine row bound");
9191
+ const bound = Math.max(retention.maxRows ?? 0, retention.maxRowsPerDevice ?? 0);
9192
+ 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)`);
9193
+ }
9194
+ if (decl.deviceRemoval === "delete" && decl.device === "none") refuse("deviceRemoval: \"delete\" needs a device: \"required\" or \"optional\"");
9195
+ 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`);
9196
+ }
9197
+ function bodyFieldsOf(schema) {
9198
+ return { ...toJSONSchema(schema, {
9199
+ unrepresentable: "any",
9200
+ io: "input"
9201
+ }) };
9202
+ }
9203
+ function isRecordLike(value) {
9204
+ return typeof value === "object" && value !== null && !Array.isArray(value);
9205
+ }
9206
+ /** Does every branch of the body schema carry `field`? (A discriminated union has several.) */
9207
+ function hasNameField(json, field) {
9208
+ const branches = json["oneOf"] ?? json["anyOf"];
9209
+ if (Array.isArray(branches)) return branches.length > 0 && branches.every((b) => isRecordLike(b) && hasNameField(b, field));
9210
+ const properties = json["properties"];
9211
+ return isRecordLike(properties) && Object.prototype.hasOwnProperty.call(properties, field);
9212
+ }
9213
+ /**
9214
+ * Declare the kinds of a package. The keys are the kind names. The result is
9215
+ * what `ctx.records.declare` sends to the engine and what `ctx.records.kind`
9216
+ * types its handle from.
9217
+ */
9218
+ function defineRecordKinds(specs) {
9219
+ const out = {};
9220
+ for (const [name, spec] of Object.entries(specs)) {
9221
+ const secretPaths = collectZodSecretPaths(spec.schema);
9222
+ const nameField = spec.entry?.nameField ?? "name";
9223
+ const fields = bodyFieldsOf(spec.schema);
9224
+ if (spec.entry !== void 0 && !hasNameField(fields, nameField)) throw new DeclarationRefusedError(`kind "${name}": an entry kind's schema needs a "${nameField}" field`);
9225
+ const parsed = RecordKindDeclarationSchema.parse({
9226
+ database: spec.database,
9227
+ class: spec.class,
9228
+ writeTrigger: spec.writeTrigger,
9229
+ device: spec.device,
9230
+ at: spec.at,
9231
+ indexes: spec.indexes === void 0 ? void 0 : [...spec.indexes],
9232
+ retention: spec.retention,
9233
+ deviceRemoval: spec.deviceRemoval,
9234
+ maxDataBytes: spec.maxDataBytes,
9235
+ secretPaths: [...new Set([...secretPaths, ...spec.retiredSecretPaths ?? []])],
9236
+ secretArrayKeys: spec.secretArrayKeys === void 0 ? void 0 : { ...spec.secretArrayKeys },
9237
+ transactFamily: spec.transactFamily,
9238
+ entry: spec.entry === void 0 ? void 0 : {
9239
+ title: spec.entry.title,
9240
+ nameField,
9241
+ fields
9242
+ }
9243
+ });
9244
+ assertValidDeclaration(name, parsed);
9245
+ out[name] = {
9246
+ name,
9247
+ schema: spec.schema,
9248
+ declaration: parsed
9249
+ };
9250
+ }
9251
+ return out;
9252
+ }
9253
+ /**
9254
+ * Entry kinds (D881): every list of user-created entries (notification
9255
+ * targets, brokers, LLM profiles) is ONE record kind with an id, a name and a
9256
+ * kind-specific body, and the admin UI lists/adds/edits/deletes all of them
9257
+ * through the `record-entries` capability with password fields derived from
9258
+ * the schema (`.meta({ secret: true })`).
9259
+ */
9260
+ /** The body of a plain entry: a name and the fields the kind adds. */
9261
+ function entryBody(shape) {
9262
+ return object({
9263
+ name: string().min(1),
9264
+ ...shape
9265
+ });
9266
+ }
9267
+ /**
9268
+ * Declare one entry kind. An entry is configuration: never trimmed by the
9269
+ * engine, never aged, belonging to no device.
9270
+ */
9271
+ function defineEntryKind(name, spec) {
9272
+ const defined = defineRecordKinds({ [name]: {
9273
+ schema: spec.schema,
9274
+ class: "config",
9275
+ writeTrigger: spec.writeTrigger ?? "an operator adds or edits an entry in the entries UI",
9276
+ retention: { none: "an entry goes only when the operator deletes it" },
9277
+ ...spec.maxDataBytes === void 0 ? {} : { maxDataBytes: spec.maxDataBytes },
9278
+ ...spec.database === void 0 ? {} : { database: spec.database },
9279
+ ...spec.indexes === void 0 ? {} : { indexes: spec.indexes },
9280
+ ...spec.secretArrayKeys === void 0 ? {} : { secretArrayKeys: spec.secretArrayKeys },
9281
+ ...spec.retiredSecretPaths === void 0 ? {} : { retiredSecretPaths: spec.retiredSecretPaths },
9282
+ entry: {
9283
+ title: spec.title,
9284
+ ...spec.nameField === void 0 ? {} : { nameField: spec.nameField }
9285
+ }
9286
+ } })[name];
9287
+ if (defined === void 0) throw new DeclarationRefusedError(`entry kind "${name}" was not built`);
9288
+ return defined;
9289
+ }
8650
9290
  object({
8651
9291
  field: string().min(1),
8652
9292
  on: literal("advance")
@@ -9342,6 +9982,7 @@ var CAP_NAMES = Object.freeze([
9342
9982
  "backup",
9343
9983
  "battery",
9344
9984
  "binary",
9985
+ "board-key-source",
9345
9986
  "brightness",
9346
9987
  "broker",
9347
9988
  "button",
@@ -9405,6 +10046,7 @@ var CAP_NAMES = Object.freeze([
9405
10046
  "humidity-sensor",
9406
10047
  "image",
9407
10048
  "image-settings",
10049
+ "integration-instances",
9408
10050
  "integrations",
9409
10051
  "intercom",
9410
10052
  "ir-transmitter",
@@ -9462,6 +10104,7 @@ var CAP_NAMES = Object.freeze([
9462
10104
  "privacy-mask",
9463
10105
  "ptz",
9464
10106
  "ptz-autotrack",
10107
+ "pump-cycle",
9465
10108
  "reboot",
9466
10109
  "record-entries",
9467
10110
  "recording",
@@ -10754,18 +11397,6 @@ Object.freeze({
10754
11397
  "path": "pumpRunning",
10755
11398
  "valueType": "boolean"
10756
11399
  },
10757
- {
10758
- "path": "pumpIntervalEnabled",
10759
- "valueType": "boolean"
10760
- },
10761
- {
10762
- "path": "pumpOnTime",
10763
- "valueType": "number"
10764
- },
10765
- {
10766
- "path": "pumpOffTime",
10767
- "valueType": "number"
10768
- },
10769
11400
  {
10770
11401
  "path": "lastDrink",
10771
11402
  "valueType": "number"
@@ -10889,6 +11520,20 @@ Object.freeze({
10889
11520
  "valueType": "number"
10890
11521
  }
10891
11522
  ],
11523
+ "pump-cycle": [
11524
+ {
11525
+ "path": "enabled",
11526
+ "valueType": "boolean"
11527
+ },
11528
+ {
11529
+ "path": "onTime",
11530
+ "valueType": "number"
11531
+ },
11532
+ {
11533
+ "path": "offTime",
11534
+ "valueType": "number"
11535
+ }
11536
+ ],
10892
11537
  "recording-archive": [
10893
11538
  {
10894
11539
  "path": "deviceId",
@@ -11338,7 +11983,7 @@ object({
11338
11983
  params: record(string(), union([string(), number()])).optional()
11339
11984
  });
11340
11985
  //#endregion
11341
- //#region ../types/dist/composition-kKKOdFIG.mjs
11986
+ //#region ../types/dist/composition-CRNwcFYY.mjs
11342
11987
  /**
11343
11988
  * The ffmpeg build every CamStack node downloads, per platform and arch.
11344
11989
  *
@@ -12101,38 +12746,6 @@ function validateExpressionSource(src) {
12101
12746
  return null;
12102
12747
  }
12103
12748
  /**
12104
- * One power reading becomes a washer, dryer or dishwasher (D944 helper).
12105
- *
12106
- * Standby of the control board is under 5 W; a motor or a heater is far
12107
- * above that, so 5 W is the line. A door lock or a short pump spike is not
12108
- * a cycle, so running starts only after 30 s above the line.
12109
- *
12110
- * A wash, dry or dishwasher pause (soak, heat-wait, heater off between
12111
- * bursts) lasts several minutes. Ending the cycle on the first dip would
12112
- * report "finished" in the middle of the program, so the stop dwell is
12113
- * 10 minutes on every type. The number is stored per type so one machine
12114
- * can move later without moving the others.
12115
- */
12116
- var APPLIANCE_TEMPLATE_ID = "appliance";
12117
- var APPLIANCE_KINDS = [
12118
- "washer",
12119
- "dryer",
12120
- "dishwasher"
12121
- ];
12122
- DeviceType.Washer, DeviceType.Dryer, DeviceType.Dishwasher;
12123
- /**
12124
- * A dumb plug-in stove or heater, built from a smart plug (a `Heater`).
12125
- *
12126
- * The plug is the actuator: `switch.setState` is a FORWARD to the plug's own
12127
- * (D967), so the heater switches exactly as the plug does. Running is the
12128
- * plug being on; when a power reading is also named, running is the draw
12129
- * staying above the line instead (a plug left on with the stove's own
12130
- * thermostat open is not heating). 50 W is far above any standby and below
12131
- * the smallest radiator.
12132
- */
12133
- var HEATER_TEMPLATE_ID = "heater";
12134
- DeviceType.Heater;
12135
- /**
12136
12749
  * Statistics and integrals over a history read (D944).
12137
12750
  *
12138
12751
  * Pure: the same points always give the same answer, so a restart recomputes
@@ -12276,34 +12889,6 @@ var HelperSpecSchema = discriminatedUnion("kind", [
12276
12889
  /** Actuator groups only. Readings leave this unset. */
12277
12890
  active: ActiveCriterionSchema.optional()
12278
12891
  }),
12279
- object({
12280
- kind: literal("appliance"),
12281
- templateId: literal(APPLIANCE_TEMPLATE_ID),
12282
- appliance: _enum(APPLIANCE_KINDS),
12283
- thresholdWatts: number().positive(),
12284
- startDwellMs: number().int().nonnegative(),
12285
- stopDwellMs: number().int().nonnegative(),
12286
- member: HelperMemberSchema,
12287
- /**
12288
- * The plug that powers the appliance (`switch.on`). Optional: when set, the
12289
- * composition carries a `power-source` feature, so the hub can cut and restore
12290
- * that plug (power-source link of a NEW-target composition).
12291
- */
12292
- powerSwitch: HelperMemberSchema.optional(),
12293
- /** How long a forced restart keeps the plug off; the cap's default when unset. */
12294
- offSeconds: number().optional()
12295
- }),
12296
- object({
12297
- kind: literal("heater"),
12298
- templateId: literal(HEATER_TEMPLATE_ID),
12299
- /** The plug, read and commanded at `switch.on`. */
12300
- plug: HelperMemberSchema,
12301
- /** The plug's power reading, when it has one: running is then the draw, not the switch. */
12302
- meter: HelperMemberSchema.optional(),
12303
- thresholdWatts: number().positive(),
12304
- startDwellMs: number().int().nonnegative(),
12305
- stopDwellMs: number().int().nonnegative()
12306
- }),
12307
12892
  object({
12308
12893
  kind: literal("statistic"),
12309
12894
  stat: _enum(STATISTIC_STATS),
@@ -12475,7 +13060,14 @@ var CompositionForwardCommandSchema = object({
12475
13060
  method: string().min(1),
12476
13061
  args: record(string().min(1), CompositionForwardArgSchema).optional()
12477
13062
  });
12478
- var CompositionCommandTargetSchema = discriminatedUnion("kind", [CompositionForwardCommandSchema, CompositionCodeSourceSchema]);
13063
+ var CompositionCommandTargetSchema = discriminatedUnion("kind", [
13064
+ CompositionForwardCommandSchema,
13065
+ CompositionCodeSourceSchema,
13066
+ object({
13067
+ kind: literal("extension"),
13068
+ target: literal("remote")
13069
+ })
13070
+ ]);
12479
13071
  /** An item key inside an item-array cap (`consumables.items[<key>]`). */
12480
13072
  var COMPOSITION_ITEM_KEY_RE = /^[a-z0-9][a-z0-9-]{0,47}$/;
12481
13073
  /**
@@ -12520,7 +13112,7 @@ var CompositionSchema = object({
12520
13112
  kind: literal("existing"),
12521
13113
  device: CompositionSourceRefSchema
12522
13114
  })]),
12523
- features: array(CompositionFeatureSchema).min(1).max(16),
13115
+ features: array(CompositionFeatureSchema).min(0).max(16),
12524
13116
  /**
12525
13117
  * Present when the block is a helper template. Absent on a free
12526
13118
  * composition (the room example, device 4603). The editor reads this,
@@ -12552,6 +13144,73 @@ var NodeColorIdSchema = _enum([
12552
13144
  "node-g",
12553
13145
  "node-h"
12554
13146
  ]);
13147
+ //#endregion
13148
+ //#region ../types/dist/index.mjs
13149
+ var SMTP_INBOUND_DEFAULT_PORT = 2525;
13150
+ var SMTP_INBOUND_DEFAULT_DOMAIN = "camstack.local";
13151
+ var SMTP_INBOUND_DEFAULT_MAX_MESSAGE_BYTES = 25 * 1024 * 1024;
13152
+ /** The text excerpt a message carries on the bus. */
13153
+ var SMTP_INBOUND_TEXT_MAX_CHARS = 4096;
13154
+ var PortSchema = number().int().min(1).max(65535);
13155
+ /** A recipient local-part: what stands before the `@`. */
13156
+ var SmtpRecipientSchema = string().min(1).max(64).regex(/^[A-Za-z0-9._+-]+$/);
13157
+ object({
13158
+ port: PortSchema.default(SMTP_INBOUND_DEFAULT_PORT),
13159
+ bindHost: string().min(1).default("0.0.0.0"),
13160
+ domain: string().min(1).default(SMTP_INBOUND_DEFAULT_DOMAIN),
13161
+ requireAuth: boolean().default(true),
13162
+ username: string().default(""),
13163
+ password: string().default("").meta({ secret: true }),
13164
+ starttls: boolean().default(false),
13165
+ maxMessageBytes: number().int().positive().default(SMTP_INBOUND_DEFAULT_MAX_MESSAGE_BYTES)
13166
+ });
13167
+ object({
13168
+ host: string().min(1).nullable(),
13169
+ hostReason: string().nullable(),
13170
+ port: PortSchema,
13171
+ domain: string().min(1),
13172
+ requireAuth: boolean(),
13173
+ username: string(),
13174
+ password: string(),
13175
+ starttls: boolean()
13176
+ });
13177
+ object({
13178
+ recipients: array(SmtpRecipientSchema).min(1),
13179
+ /**
13180
+ * Who is subscribing. A second `subscribe` with the same id REPLACES that subscriber's
13181
+ * recipients (the way a consumer that restarted, or lost a device, declares its set again);
13182
+ * a recipient held by another subscriber is refused with `smtp-inbound/recipient-claimed`.
13183
+ * Absent, the subscriber is anonymous and unique.
13184
+ */
13185
+ subscriberId: string().min(1).max(64).optional()
13186
+ });
13187
+ var SmtpInboundAttachmentSchema = object({
13188
+ filename: string(),
13189
+ contentType: string(),
13190
+ bytes: number().int().nonnegative()
13191
+ });
13192
+ /** The payload of one `broker.message` (the key is the recipient local-part). */
13193
+ var SmtpInboundMessageSchema = object({
13194
+ /** Monotonic per mailbox; a gap tells a consumer it missed an event. */
13195
+ seq: number().int().positive(),
13196
+ messageId: string(),
13197
+ receivedAt: number().int().nonnegative(),
13198
+ from: string(),
13199
+ to: string(),
13200
+ subject: string(),
13201
+ text: string().max(SMTP_INBOUND_TEXT_MAX_CHARS),
13202
+ attachments: array(SmtpInboundAttachmentSchema)
13203
+ });
13204
+ object({
13205
+ /** The newest seq issued so far (0 before any mail). */
13206
+ lastSeq: number().int().nonnegative(),
13207
+ /** The oldest seq still retained; messages below it are gone. */
13208
+ oldestSeq: number().int().nonnegative(),
13209
+ messages: array(object({
13210
+ key: string(),
13211
+ message: SmtpInboundMessageSchema
13212
+ }))
13213
+ });
12555
13214
  new Set([
12556
13215
  "track",
12557
13216
  "face",
@@ -12671,6 +13330,205 @@ var IntegrationInstanceRefSchema = object({
12671
13330
  ]),
12672
13331
  candidateStableId: string().optional()
12673
13332
  });
13333
+ /**
13334
+ * `RecordIntegrationInstances` - the `integration-instances` provider over ONE
13335
+ * entry kind, so an addon that holds a connection serves it in ~30 lines.
13336
+ *
13337
+ * Every instance is one record of the addon's own kind, keyed by the
13338
+ * `integrations` registry id. The records door does the secret work: a field the
13339
+ * kind marks `.meta({ secret: true })` is a keychain marker bound to the row, so
13340
+ * deleting the row deletes the secret, and one row's value is never another's.
13341
+ *
13342
+ * Patch rules for a secret (`updateInstance`): omitted, `''`, the redaction
13343
+ * token or the view the form was given KEEP the stored secret;
13344
+ * `{ $secretClear: true }` clears it; any other string replaces it.
13345
+ */
13346
+ /** The most instances one addon lists (an integrations page, not a table). */
13347
+ var INSTANCES_LIST_MAX = 1e3;
13348
+ /** The keys of the kind's secret fields that sit at the top level of the body. */
13349
+ function topLevelSecretKeys(paths) {
13350
+ return new Set(paths.filter((p) => !p.includes(".") && !p.includes("[") && !p.includes("{")));
13351
+ }
13352
+ /** The keys of the kind's top-level MAPS whose values are secrets (`applianceSecrets{}`). */
13353
+ function secretMapKeys(paths) {
13354
+ return new Set(paths.filter((p) => p.endsWith("{}") && !p.slice(0, -2).match(/[.[{]/)).map((p) => p.slice(0, -2)));
13355
+ }
13356
+ /**
13357
+ * A patch value for a map of secrets: an entry that is omitted, `''`, the redaction token or the
13358
+ * view the form was given KEEPS its stored secret (it is left out of the merge); `{ $secretClear }`
13359
+ * or `null` removes the entry; any other string replaces it. Null when nothing is left to merge.
13360
+ */
13361
+ function secretMapPatch(value) {
13362
+ if (typeof value !== "object" || value === null || Array.isArray(value)) return null;
13363
+ const out = {};
13364
+ for (const [key, entry] of Object.entries(value)) if (entry === null || isSecretClear(entry)) out[key] = null;
13365
+ else if (typeof entry === "string" && entry !== "" && entry !== "__camstack_redacted__" && !isSecretFieldView(entry)) out[key] = entry;
13366
+ return Object.keys(out).length > 0 ? out : null;
13367
+ }
13368
+ /** Does the kind's body schema carry an `enabled` field? */
13369
+ function declaresEnabled(kind) {
13370
+ const json = toJSONSchema(kind.schema, {
13371
+ unrepresentable: "any",
13372
+ io: "input"
13373
+ });
13374
+ const properties = Reflect.get(json, "properties");
13375
+ return typeof properties === "object" && properties !== null && "enabled" in properties;
13376
+ }
13377
+ var RecordIntegrationInstances = class {
13378
+ records;
13379
+ kind;
13380
+ hooks;
13381
+ handle;
13382
+ secretKeys;
13383
+ secretMaps;
13384
+ nameField;
13385
+ /** The `integrations` registry owns the on/off switch (`role: devices`); the body has none. */
13386
+ registryOwnsEnabled;
13387
+ constructor(records, kind, hooks) {
13388
+ this.records = records;
13389
+ this.kind = kind;
13390
+ this.hooks = hooks;
13391
+ this.handle = records.kind(kind);
13392
+ this.secretKeys = topLevelSecretKeys(kind.declaration.secretPaths);
13393
+ this.secretMaps = secretMapKeys(kind.declaration.secretPaths);
13394
+ this.nameField = kind.declaration.entry?.nameField ?? "name";
13395
+ this.registryOwnsEnabled = hooks.description.role === "devices";
13396
+ if (this.registryOwnsEnabled && declaresEnabled(kind)) throw new Error(`kind "${kind.name}": the integrations registry owns the on/off switch of a role "devices" addon, so the body must not declare "enabled"`);
13397
+ }
13398
+ /**
13399
+ * One instance read for the addon's own runtime; null when absent. When the keychain is
13400
+ * locked the row is served WITHOUT its secrets and says so (`secrets: 'unavailable'`), so the
13401
+ * caller can keep what it had instead of reconfiguring with an empty secret (D49).
13402
+ */
13403
+ async readResolved(id) {
13404
+ try {
13405
+ const record = await this.handle.getResolved(id);
13406
+ return record === null ? null : {
13407
+ id,
13408
+ body: record.data,
13409
+ enabled: record.data.enabled !== false,
13410
+ secrets: "resolved"
13411
+ };
13412
+ } catch (err) {
13413
+ if (!(err instanceof RecordSecretUnavailableError)) throw err;
13414
+ const stored = await this.handle.get(id);
13415
+ if (stored === null) return null;
13416
+ return {
13417
+ id,
13418
+ body: Object.fromEntries(Object.entries(stored.data).filter(([key]) => !this.secretKeys.has(key))),
13419
+ enabled: stored.data.enabled !== false,
13420
+ secrets: "unavailable"
13421
+ };
13422
+ }
13423
+ }
13424
+ /** The body of {@link readResolved} alone; a locked keychain yields the row without secrets. */
13425
+ async getResolved(id) {
13426
+ return (await this.readResolved(id))?.body ?? null;
13427
+ }
13428
+ /** Every instance, secrets resolved where the keychain allows; an absent one is skipped. */
13429
+ async listResolved() {
13430
+ const page = await this.handle.query({ limit: INSTANCES_LIST_MAX });
13431
+ const out = [];
13432
+ for (const record of page.records) {
13433
+ const read = await this.readResolved(record.id);
13434
+ if (read !== null) out.push(read);
13435
+ }
13436
+ return out;
13437
+ }
13438
+ viewOf(record) {
13439
+ const shown = secretViewsOf(this.records.owner, this.kind.name, record.id, this.kind.declaration, record.data);
13440
+ const rawName = record.data[this.nameField];
13441
+ const kind = this.hooks.kindOf?.(record.data);
13442
+ const health = this.hooks.health?.(record.data, record.id);
13443
+ return {
13444
+ id: record.id,
13445
+ name: typeof rawName === "string" ? rawName : record.id,
13446
+ configured: this.hooks.configured(record.data),
13447
+ ...this.registryOwnsEnabled ? {} : { enabled: record.data.enabled !== false },
13448
+ formValues: shown,
13449
+ ...kind !== void 0 ? { kind } : {},
13450
+ ...health?.status !== void 0 ? { status: health.status } : {},
13451
+ ...health?.lastCheckedAt !== void 0 ? { lastCheckedAt: health.lastCheckedAt } : {}
13452
+ };
13453
+ }
13454
+ describe = async () => this.hooks.mintId === void 0 ? this.hooks.description : {
13455
+ ...this.hooks.description,
13456
+ mintsId: true
13457
+ };
13458
+ instanceFormSchema = async ({ id }) => this.hooks.formSchema(id);
13459
+ listInstances = async () => {
13460
+ return (await this.handle.query({ limit: INSTANCES_LIST_MAX })).records.map((record) => this.viewOf(record));
13461
+ };
13462
+ getInstance = async ({ id }) => {
13463
+ const record = await this.handle.get(id);
13464
+ return record === null ? null : this.viewOf(record);
13465
+ };
13466
+ /** Insert ONE row (`ifRev: 0`: an existing id is refused, never overwritten). */
13467
+ createInstance = async ({ id, name, kind }) => {
13468
+ const minted = id ?? this.hooks.mintId?.({
13469
+ name,
13470
+ ...kind !== void 0 ? { kind } : {}
13471
+ });
13472
+ if (minted === void 0) throw new Error("createInstance needs an id: this provider does not mint one");
13473
+ await this.handle.put({
13474
+ id: minted,
13475
+ data: this.hooks.initialBody(name, kind)
13476
+ }, { ifRev: 0 });
13477
+ await this.hooks.onChanged?.(minted, "created");
13478
+ return { id: minted };
13479
+ };
13480
+ updateInstance = async ({ id, name, values }) => {
13481
+ const patch = {};
13482
+ for (const [key, value] of Object.entries(values)) {
13483
+ if (value === void 0) continue;
13484
+ if (this.secretMaps.has(key)) {
13485
+ const entries = secretMapPatch(value);
13486
+ if (entries !== null) patch[key] = entries;
13487
+ } else if (!this.secretKeys.has(key)) patch[key] = value;
13488
+ else if (isSecretClear(value)) patch[key] = null;
13489
+ else if (typeof value === "string" && value !== "" && value !== "__camstack_redacted__" && !isSecretFieldView(value)) patch[key] = value;
13490
+ }
13491
+ if (name !== void 0) patch[this.nameField] = name;
13492
+ await this.handle.patch(id, patch);
13493
+ await this.hooks.onChanged?.(id, "updated");
13494
+ return { ok: true };
13495
+ };
13496
+ /** The switch lives in the record body; the addon is told so it applies it (D996). */
13497
+ setInstanceEnabled = async ({ id, enabled }) => {
13498
+ if (this.registryOwnsEnabled) throw new Error(`instance "${id}": the integrations registry owns the on/off switch of this addon; set it with integrations.update`);
13499
+ await this.handle.patch(id, { enabled });
13500
+ await this.hooks.onChanged?.(id, "enabled");
13501
+ return { ok: true };
13502
+ };
13503
+ /** The row and its keychain refs go together (the records door). */
13504
+ deleteInstance = async ({ id }) => {
13505
+ await this.handle.delete(id);
13506
+ await this.hooks.onChanged?.(id, "deleted");
13507
+ return { ok: true };
13508
+ };
13509
+ testInstance = async (input) => {
13510
+ if (this.hooks.test === void 0) return {
13511
+ success: false,
13512
+ status: "unsupported",
13513
+ error: "This integration declares no connection test"
13514
+ };
13515
+ return this.hooks.test(input);
13516
+ };
13517
+ /** The flat provider object to hand to `registerProvider`. */
13518
+ toProvider() {
13519
+ return {
13520
+ describe: this.describe,
13521
+ instanceFormSchema: this.instanceFormSchema,
13522
+ listInstances: this.listInstances,
13523
+ getInstance: this.getInstance,
13524
+ createInstance: this.createInstance,
13525
+ updateInstance: this.updateInstance,
13526
+ setInstanceEnabled: this.setInstanceEnabled,
13527
+ deleteInstance: this.deleteInstance,
13528
+ testInstance: this.testInstance
13529
+ };
13530
+ }
13531
+ };
12674
13532
  var EncodeProfileSchema = object({
12675
13533
  video: object({
12676
13534
  codec: _enum([
@@ -13706,7 +14564,13 @@ var MigrationLedgerEntrySchema = object({
13706
14564
  * joined by the engine from the catalogues it knows this boot. Absent when no
13707
14565
  * catalogue lists the id (a newer database).
13708
14566
  */
13709
- meta: MigrationMetaSchema.optional()
14567
+ meta: MigrationMetaSchema.optional(),
14568
+ /**
14569
+ * Set when this is an applied row of an addon owner whose catalogue the answering
14570
+ * process has not loaded (the owner has not declared yet): the row is applied, the
14571
+ * process just cannot judge it. Never `skipped-newer` — that needs the owner loaded.
14572
+ */
14573
+ ownerNotLoaded: boolean().optional()
13710
14574
  });
13711
14575
  /** A catalogued migration that is not applied, with where it stands. */
13712
14576
  var MigrationPendingEntrySchema = object({
@@ -13740,6 +14604,149 @@ var MigrationOwnerStepSchema = object({
13740
14604
  state: union([literal("pending"), MigrationStatusSchema])
13741
14605
  });
13742
14606
  /**
14607
+ * Move an integration's legacy `integration_settings` rows into a typed record of the addon's own
14608
+ * kind (planning#416, the one store). The record is keyed by the `integrations` registry id, so
14609
+ * the integration id, the devices stamped with it and the automations that name it do not change.
14610
+ *
14611
+ * Order, so a crash or a locked keychain is safe at every point:
14612
+ *
14613
+ * 1. Phase A, read only: every row of every integration of the addon is read with its secrets
14614
+ * resolved. One that cannot be read (a locked keychain) throws, naming the integration, before
14615
+ * anything is written; `block-owner` then holds the addon.
14616
+ * 2. Phase B, per integration: the addon's `bodyFrom` builds the body; the record is put with
14617
+ * `ifRev: 0` (an existing record is never overwritten). A record this pass CREATED is read back
14618
+ * and every secret leaf must equal what the rows held, else the record is deleted and the pass
14619
+ * throws; an EXISTING record must hold every secret the rows carry, else the rows are kept and
14620
+ * a warning names the path. Only then are the rows (and their keychain values) cleared.
14621
+ *
14622
+ * Idempotent: an integration whose rows are gone and whose record exists is skipped, so a rerun is
14623
+ * a no-op. A default integration with no rows still gets its record (an empty body, D985).
14624
+ * Never logs or throws a secret value; messages name integration ids and secret PATHS only.
14625
+ */
14626
+ function secretLeavesOf(body, spec) {
14627
+ const out = /* @__PURE__ */ new Map();
14628
+ for (const leaf of collectSecretLeaves(body, spec.secretPaths, spec.secretArrayKeys ?? {})) if (typeof leaf.value === "string" && leaf.value.length > 0) out.set(leaf.concrete, leaf.value);
14629
+ return out;
14630
+ }
14631
+ function why(err) {
14632
+ return err instanceof Error ? err.message : String(err);
14633
+ }
14634
+ async function moveIntegrationRowsToRecords(ports, spec) {
14635
+ const integrations = await ports.listIntegrations(spec.addonId);
14636
+ if (integrations.length === 0) return {
14637
+ outcome: "already-done",
14638
+ summary: { integrations: 0 }
14639
+ };
14640
+ const rowsOf = /* @__PURE__ */ new Map();
14641
+ for (const integration of integrations) try {
14642
+ rowsOf.set(integration.id, await ports.readRows(integration.id));
14643
+ } catch (err) {
14644
+ throw new Error(`integration '${integration.id}': the legacy settings cannot be read with their secrets (${why(err)}) - nothing moved`, { cause: err });
14645
+ }
14646
+ let created = 0;
14647
+ let cleared = 0;
14648
+ let kept = 0;
14649
+ for (const integration of integrations) {
14650
+ const values = rowsOf.get(integration.id) ?? {};
14651
+ const hasRows = Object.keys(values).length > 0;
14652
+ const body = spec.bodyFrom(values, ports, integration);
14653
+ const put = await ports.putRecord(integration.id, body);
14654
+ if (put === "created") created += 1;
14655
+ if (!hasRows) continue;
14656
+ const wanted = secretLeavesOf(body, spec);
14657
+ const back = await ports.readRecord(integration.id);
14658
+ if (back === null) throw new Error(`integration '${integration.id}': the record is gone after it was put`);
14659
+ const held = secretLeavesOf(back, spec);
14660
+ if (put === "created") {
14661
+ const wrong = [...wanted].filter(([path, value]) => held.get(path) !== value).map(([p]) => p);
14662
+ if (wrong.length > 0) {
14663
+ await ports.deleteRecord(integration.id);
14664
+ throw new Error(`integration '${integration.id}': ${wrong.join(", ")} did not read back from the record - the record was removed and the legacy settings are kept`);
14665
+ }
14666
+ } else {
14667
+ const missing = [...wanted].filter(([path]) => !held.has(path)).map(([p]) => p);
14668
+ if (missing.length > 0) {
14669
+ ports.warn(`integration '${integration.id}': the existing record holds no ${missing.join(", ")}; the legacy settings are kept, not cleared`);
14670
+ kept += 1;
14671
+ continue;
14672
+ }
14673
+ }
14674
+ await ports.clearRows(integration.id);
14675
+ cleared += 1;
14676
+ }
14677
+ return created === 0 && cleared === 0 ? {
14678
+ outcome: "already-done",
14679
+ summary: {
14680
+ integrations: integrations.length,
14681
+ kept
14682
+ }
14683
+ } : {
14684
+ outcome: "done",
14685
+ summary: {
14686
+ integrations: integrations.length,
14687
+ created,
14688
+ cleared,
14689
+ kept
14690
+ }
14691
+ };
14692
+ }
14693
+ /**
14694
+ * The addon-side ports of `moveIntegrationRowsToRecords` (planning#416): an addon runs the move
14695
+ * from its own process, so the legacy rows are reached through the hub (`ctx.api.integrations`:
14696
+ * `list`, `getSettings` - which answers the OWNER its secrets resolved - and `clearSettings`) and
14697
+ * the new record through the addon's own records handle. The hub deletes the rows and their
14698
+ * keychain values; the addon never touches the registry.
14699
+ */
14700
+ function integrationRowsPortsOverApi(deps) {
14701
+ return {
14702
+ warn: (message) => deps.log.warn(message),
14703
+ listIntegrations: async (addonId) => (await deps.api.list()).filter((i) => i.addonId === addonId).map((i) => ({
14704
+ id: i.id,
14705
+ name: i.name
14706
+ })),
14707
+ readRows: (integrationId) => deps.api.getSettings({ id: integrationId }),
14708
+ putRecord: async (id, body) => {
14709
+ if (await deps.records.get(id) !== null) return "exists";
14710
+ try {
14711
+ await deps.records.put({
14712
+ id,
14713
+ data: body
14714
+ }, { ifRev: 0 });
14715
+ } catch (err) {
14716
+ if (err instanceof RevConflictError) return "exists";
14717
+ throw err;
14718
+ }
14719
+ return "created";
14720
+ },
14721
+ readRecord: async (id) => (await deps.records.getResolved(id))?.data ?? null,
14722
+ deleteRecord: async (id) => {
14723
+ await deps.records.delete(id);
14724
+ },
14725
+ clearRows: async (integrationId) => {
14726
+ await deps.api.clearSettings({ id: integrationId });
14727
+ }
14728
+ };
14729
+ }
14730
+ function defaultIntegrationApiOver(api) {
14731
+ return {
14732
+ list: () => api.integrations.list.query(),
14733
+ getSettings: (input) => api.integrations.getSettings.query(input),
14734
+ clearSettings: (input) => api.integrations.clearSettings.mutate(input),
14735
+ listDevices: (addonId) => api.deviceManager.listAll.query({
14736
+ addonId,
14737
+ projection: "slim"
14738
+ }),
14739
+ setDeviceIntegrationId: async (deviceId, integrationId) => {
14740
+ await api.deviceManager.setIntegrationId.mutate({
14741
+ deviceId,
14742
+ integrationId
14743
+ });
14744
+ },
14745
+ readDeviceHasConfig: async (deviceId) => Object.keys((await api.deviceManager.getDevice.query({ deviceId }))?.config ?? {}).length > 0,
14746
+ readDeviceIntegrationId: async (deviceId) => (await api.deviceManager.getDevice.query({ deviceId }))?.integrationId ?? null
14747
+ };
14748
+ }
14749
+ /**
13743
14750
  * The trainer contract — what the hub hands the cloud trainer and what it
13744
14751
  * gets back (cloud training, D805+).
13745
14752
  *
@@ -15594,8 +16601,18 @@ var LogChannelDescriptorSchema = object({
15594
16601
  * the operator narrows to one camera, sees nothing, and concludes the code
15595
16602
  * path was never taken.
15596
16603
  */
15597
- perDevice: boolean()
15598
- });
16604
+ perDevice: boolean(),
16605
+ /**
16606
+ * What the channel is FOR, so the UI can list the channels an addon offers.
16607
+ *
16608
+ * - `diagnostic` (the default): a per-component diagnostic armed from the
16609
+ * Levels page, emitted at its declared level.
16610
+ * - `debug`: a `debug.<channel>` dump watched live for a short window
16611
+ * (`ctx.debug`). Always per-device, and its lines are denied by the log
16612
+ * ring unless somebody is watching that device.
16613
+ */
16614
+ kind: _enum(["diagnostic", "debug"]).default("diagnostic")
16615
+ }).refine((d) => d.kind !== "debug" || d.name.startsWith("debug.") && d.perDevice, { message: "a debug channel is named debug.<channel> and is per-device" });
15599
16616
  /**
15600
16617
  * An armed window over one channel, as the document hands it to a mirror.
15601
16618
  *
@@ -18814,24 +19831,52 @@ var APPLIANCE_CAP_VOCABULARY = {
18814
19831
  args: { on: false }
18815
19832
  },
18816
19833
  {
18817
- id: "petFountain.intervalOn",
18818
- method: "setPumpInterval",
19834
+ id: "petFountain.resetDailyConsumption",
19835
+ method: "resetDailyConsumption",
19836
+ label: t("Clear daily consumption", "Azzera il consumo giornaliero"),
19837
+ phrase: t("Clear the daily water consumption of {device}", "Azzera il consumo giornaliero di acqua di {device}"),
19838
+ icon: "rotate-ccw"
19839
+ }
19840
+ ],
19841
+ state: [{
19842
+ kind: "boolean",
19843
+ field: "empty",
19844
+ label: t("Tank empty", "Serbatoio vuoto"),
19845
+ whenTrue: t("When the tank of {device} is empty", "Quando il serbatoio di {device} è vuoto"),
19846
+ whenFalse: t("When the tank of {device} is refilled", "Quando il serbatoio di {device} viene riempito"),
19847
+ icon: "droplet"
19848
+ }, {
19849
+ kind: "numeric",
19850
+ field: "waterLevel",
19851
+ quantity: t("the water level", "il livello dell’acqua"),
19852
+ label: t("Water level", "Livello dell’acqua"),
19853
+ unit: "%",
19854
+ icon: "droplets"
19855
+ }]
19856
+ },
19857
+ "pump-cycle": {
19858
+ scope: "device",
19859
+ noun: t("Pump cycle", "Ciclo della pompa"),
19860
+ actions: [
19861
+ {
19862
+ id: "pumpCycle.on",
19863
+ method: "setEnabled",
18819
19864
  label: t("Pump cycle on", "Ciclo pompa attivo"),
18820
19865
  phrase: t("Run the pump of {device} on its on/off cycle", "Fai lavorare la pompa di {device} a ciclo acceso/spento"),
18821
19866
  icon: "timer",
18822
19867
  args: { on: true }
18823
19868
  },
18824
19869
  {
18825
- id: "petFountain.intervalOff",
18826
- method: "setPumpInterval",
19870
+ id: "pumpCycle.off",
19871
+ method: "setEnabled",
18827
19872
  label: t("Pump cycle off", "Ciclo pompa spento"),
18828
19873
  phrase: t("Run the pump of {device} continuously", "Fai lavorare la pompa di {device} in continuo"),
18829
19874
  icon: "timer-off",
18830
19875
  args: { on: false }
18831
19876
  },
18832
19877
  {
18833
- id: "petFountain.pumpOnMinutes",
18834
- method: "setPumpOnMinutes",
19878
+ id: "pumpCycle.onMinutes",
19879
+ method: "setOnMinutes",
18835
19880
  label: t("Set pump run time", "Imposta il tempo di lavoro della pompa"),
18836
19881
  phrase: t("Set the pump of {device} to run {minutes} minutes per cycle", "Imposta la pompa di {device} a lavorare {minutes} minuti per ciclo"),
18837
19882
  icon: "timer",
@@ -18847,8 +19892,8 @@ var APPLIANCE_CAP_VOCABULARY = {
18847
19892
  }]
18848
19893
  },
18849
19894
  {
18850
- id: "petFountain.pumpOffMinutes",
18851
- method: "setPumpOffMinutes",
19895
+ id: "pumpCycle.offMinutes",
19896
+ method: "setOffMinutes",
18852
19897
  label: t("Set pump rest time", "Imposta il tempo di riposo della pompa"),
18853
19898
  phrase: t("Set the pump of {device} to rest {minutes} minutes per cycle", "Imposta la pompa di {device} a riposare {minutes} minuti per ciclo"),
18854
19899
  icon: "timer-off",
@@ -18862,35 +19907,63 @@ var APPLIANCE_CAP_VOCABULARY = {
18862
19907
  unit: "min"
18863
19908
  }
18864
19909
  }]
18865
- },
18866
- {
18867
- id: "petFountain.resetDailyConsumption",
18868
- method: "resetDailyConsumption",
18869
- label: t("Clear daily consumption", "Azzera il consumo giornaliero"),
18870
- phrase: t("Clear the daily water consumption of {device}", "Azzera il consumo giornaliero di acqua di {device}"),
18871
- icon: "rotate-ccw"
18872
19910
  }
18873
19911
  ],
18874
19912
  state: [{
18875
19913
  kind: "boolean",
18876
- field: "empty",
18877
- label: t("Tank empty", "Serbatoio vuoto"),
18878
- whenTrue: t("When the tank of {device} is empty", "Quando il serbatoio di {device} è vuoto"),
18879
- whenFalse: t("When the tank of {device} is refilled", "Quando il serbatoio di {device} viene riempito"),
18880
- icon: "droplet"
18881
- }, {
18882
- kind: "numeric",
18883
- field: "waterLevel",
18884
- quantity: t("the water level", "il livello dell’acqua"),
18885
- label: t("Water level", "Livello dell’acqua"),
18886
- unit: "%",
18887
- icon: "droplets"
19914
+ field: "enabled",
19915
+ label: t("Pump cycle", "Ciclo pompa"),
19916
+ whenTrue: t("When {device} starts running its pump on a cycle", "Quando {device} inizia a far lavorare la pompa a ciclo"),
19917
+ whenFalse: t("When {device} runs its pump continuously", "Quando {device} fa lavorare la pompa in continuo"),
19918
+ icon: "timer"
18888
19919
  }]
18889
19920
  },
18890
19921
  "media-player": {
18891
19922
  scope: "device",
18892
19923
  noun: t("Media player", "Lettore multimediale"),
18893
19924
  actions: [
19925
+ {
19926
+ id: "media.turnOn",
19927
+ method: "turnOn",
19928
+ label: t("Turn on", "Accendi"),
19929
+ phrase: t("Turn on {device}", "Accendi {device}"),
19930
+ icon: "power"
19931
+ },
19932
+ {
19933
+ id: "media.turnOff",
19934
+ method: "turnOff",
19935
+ label: t("Turn off", "Spegni"),
19936
+ phrase: t("Turn off {device}", "Spegni {device}"),
19937
+ icon: "power"
19938
+ },
19939
+ {
19940
+ id: "media.volumeUp",
19941
+ method: "volumeUp",
19942
+ label: t("Volume up", "Alza il volume"),
19943
+ phrase: t("Raise the volume of {device}", "Alza il volume di {device}"),
19944
+ icon: "volume-2"
19945
+ },
19946
+ {
19947
+ id: "media.volumeDown",
19948
+ method: "volumeDown",
19949
+ label: t("Volume down", "Abbassa il volume"),
19950
+ phrase: t("Lower the volume of {device}", "Abbassa il volume di {device}"),
19951
+ icon: "volume-2"
19952
+ },
19953
+ {
19954
+ id: "media.channelUp",
19955
+ method: "channelUp",
19956
+ label: t("Channel up", "Canale successivo"),
19957
+ phrase: t("Go to the next channel on {device}", "Passa al canale successivo su {device}"),
19958
+ icon: "skip-forward"
19959
+ },
19960
+ {
19961
+ id: "media.channelDown",
19962
+ method: "channelDown",
19963
+ label: t("Channel down", "Canale precedente"),
19964
+ phrase: t("Go to the previous channel on {device}", "Torna al canale precedente su {device}"),
19965
+ icon: "skip-back"
19966
+ },
18894
19967
  {
18895
19968
  id: "media.play",
18896
19969
  method: "play",
@@ -20777,6 +21850,7 @@ var SYSTEM_CAP_VOCABULARY = {
20777
21850
  "audio-analyzer": system(PIPELINE),
20778
21851
  "audio-codec": system(INTERNAL),
20779
21852
  "auth-provider": system(IDENTITY),
21853
+ "board-key-source": system(INTERNAL),
20780
21854
  backup: system("system backups — run and restored from the Backups page"),
20781
21855
  broker: system("message-broker connections — configured, not actuated"),
20782
21856
  "calendar-source": system(INTERNAL),
@@ -20811,6 +21885,7 @@ var SYSTEM_CAP_VOCABULARY = {
20811
21885
  "load-contribution": system(INTERNAL),
20812
21886
  "local-network": system(NETWORK),
20813
21887
  "log-channels": system(INTERNAL),
21888
+ "integration-instances": system(INTERNAL),
20814
21889
  "log-destination": system(INTERNAL),
20815
21890
  "login-method": system(IDENTITY),
20816
21891
  "mesh-network": system(NETWORK),
@@ -43096,7 +44171,7 @@ var TargetKindCapsSchema = object({
43096
44171
  * the union is large and not meant for runtime validation here; the exported
43097
44172
  * `TargetKind` type re-tightens `configSchema` to `ConfigUISchema`.
43098
44173
  */
43099
- var ConfigSchemaPassthrough$3 = unknown();
44174
+ var ConfigSchemaPassthrough$4 = unknown();
43100
44175
  var TargetKindSchema = object({
43101
44176
  kind: string(),
43102
44177
  label: string(),
@@ -43133,7 +44208,7 @@ var TargetKindSchema = object({
43133
44208
  * its raster path, which is the safe default for an unknown image.
43134
44209
  */
43135
44210
  iconMediaType: string().optional(),
43136
- configSchema: ConfigSchemaPassthrough$3,
44211
+ configSchema: ConfigSchemaPassthrough$4,
43137
44212
  /**
43138
44213
  * The config keys that decide WHERE this kind's secrets are sent (server,
43139
44214
  * base URL, instance, chat, recipient). A save that changes any of them
@@ -45764,6 +46839,49 @@ var binaryCapability = {
45764
46839
  volatileStateFields: ["lastChangedAt"]
45765
46840
  };
45766
46841
  /**
46842
+ * Why a board key could not be read. Typed so a caller reports the cause and
46843
+ * never treats "could not read" as "has no key" (D49).
46844
+ */
46845
+ var BoardKeyFailureReasonSchema = _enum([
46846
+ "unknown-source",
46847
+ "not-admin",
46848
+ "no-builder",
46849
+ "no-ingress-url",
46850
+ "unreachable",
46851
+ "unknown-board",
46852
+ "no-encryption-key",
46853
+ "unreadable-config"
46854
+ ]);
46855
+ var BoardKeySourceSchema = object({
46856
+ sourceId: string(),
46857
+ name: string()
46858
+ });
46859
+ var BoardKeyBoardSchema = object({
46860
+ /** The builder's file name, e.g. `kitchen.yaml`: the handle `getBoardKey` takes. */
46861
+ configuration: string(),
46862
+ /** The node name the builder gives the board. */
46863
+ name: string(),
46864
+ /** The address the builder knows the board by, when it has one. */
46865
+ address: string().nullable()
46866
+ });
46867
+ var BoardKeyFailureSchema = object({
46868
+ ok: literal(false),
46869
+ reason: BoardKeyFailureReasonSchema,
46870
+ detail: string().optional()
46871
+ });
46872
+ var ListBoardsResultSchema = discriminatedUnion("ok", [object({
46873
+ ok: literal(true),
46874
+ boards: array(BoardKeyBoardSchema).readonly()
46875
+ }), BoardKeyFailureSchema]);
46876
+ var GetBoardKeyResultSchema = discriminatedUnion("ok", [object({
46877
+ ok: literal(true),
46878
+ key: string()
46879
+ }), BoardKeyFailureSchema]);
46880
+ method(_void(), array(BoardKeySourceSchema).readonly(), { auth: "admin" }), method(object({ sourceId: string().min(1) }), ListBoardsResultSchema, { auth: "admin" }), method(object({
46881
+ sourceId: string().min(1),
46882
+ configuration: string().min(1)
46883
+ }), GetBoardKeyResultSchema, { auth: "admin" });
46884
+ /**
45767
46885
  * Dimmable-light brightness control. Co-exists with `switch` on the
45768
46886
  * same device — the switch toggles on/off, this cap sets the level
45769
46887
  * applied when the light is on. Drivers map their per-vendor dim
@@ -48453,6 +49571,244 @@ var controlCapability = {
48453
49571
  */
48454
49572
  history: "none"
48455
49573
  };
49574
+ /**
49575
+ * Media-player cap. Models HA `media_player.*` (Sonos, Chromecast,
49576
+ * Apple TV, Spotify, Roku, generic OTT receivers, …) on
49577
+ * `DeviceType.MediaPlayer`. Disjoint from the camera streaming
49578
+ * surface — those use `DeviceType.Camera` + the broker pipeline.
49579
+ *
49580
+ * The cap declares a wide method surface; not every backend supports
49581
+ * every method. Drivers signal sub-capability via the
49582
+ * `DeviceFeature.MediaPlayerXxx` flags (paired one-to-one with the
49583
+ * corresponding method) so the UI gates buttons without a slice
49584
+ * fetch — same pattern as `PanTiltZoom` for cameras.
49585
+ */
49586
+ var MediaPlayerStateSchema = _enum([
49587
+ "off",
49588
+ "on",
49589
+ "idle",
49590
+ "playing",
49591
+ "paused",
49592
+ "buffering",
49593
+ "standby"
49594
+ ]);
49595
+ var MediaPlayerRepeatSchema = _enum([
49596
+ "off",
49597
+ "all",
49598
+ "one"
49599
+ ]);
49600
+ var MediaInfoSchema = object({
49601
+ /** Free-form media kind (`music`, `tvshow`, `movie`, `app`, `channel`,
49602
+ * `podcast`, …). */
49603
+ type: string(),
49604
+ /** Human-readable title. */
49605
+ title: string(),
49606
+ /** Optional artist / channel / station label. */
49607
+ artist: string().optional(),
49608
+ /** Optional album / season / show name. */
49609
+ album: string().optional(),
49610
+ /** Optional cover-art / thumbnail URL. */
49611
+ imageUrl: string().optional()
49612
+ });
49613
+ /**
49614
+ * Where `state`, `volumeLevel`, `isMuted` and `source` come from. `reported`:
49615
+ * the device said so. `assumed`: the driver has no feedback (infrared) and
49616
+ * tracks what it last SENT; it moves only after a send was accepted, and a
49617
+ * human at the real remote makes it wrong. A UI shows an assumed value as a
49618
+ * guess, never as a reading.
49619
+ */
49620
+ var MediaPlayerStateSourceSchema = _enum(["reported", "assumed"]);
49621
+ /** The fields of a media-player status a driver can only guess. */
49622
+ var MediaPlayerAssumedFieldSchema = _enum([
49623
+ "state",
49624
+ "volumeLevel",
49625
+ "isMuted",
49626
+ "source"
49627
+ ]);
49628
+ var MediaPlayerStatusSchema = object({
49629
+ /** Playback lifecycle state. */
49630
+ state: MediaPlayerStateSchema,
49631
+ /**
49632
+ * Whether the state fields are readings or the driver's own bookkeeping.
49633
+ * A slice written before this field existed parses as `reported`.
49634
+ */
49635
+ stateSource: MediaPlayerStateSourceSchema.default("reported"),
49636
+ /**
49637
+ * Which fields are the driver's own guess. `stateSource` is `assumed` when
49638
+ * this is not empty; a field not listed here is a reading even then (power
49639
+ * from a running-state source, mute guessed from the last send).
49640
+ */
49641
+ assumedFields: array(MediaPlayerAssumedFieldSchema).default([]),
49642
+ /** Volume as 0..100 inclusive. Null when the device has no volume
49643
+ * surface. Pair with `DeviceFeature.MediaPlayerVolume`. */
49644
+ volumeLevel: number().min(0).max(100).nullable().meta(readingMeta("percentage")),
49645
+ /** Mute toggle distinct from volume=0. Null when no mute surface.
49646
+ * Pair with `DeviceFeature.MediaPlayerMute`. */
49647
+ isMuted: boolean().nullable(),
49648
+ /** Active source / input. Empty when no source surface. */
49649
+ source: string(),
49650
+ /** Selectable sources. Empty when no source surface.
49651
+ * Pair with `DeviceFeature.MediaPlayerSelectSource`. */
49652
+ availableSources: array(string()),
49653
+ /** Currently-playing media info. Null when nothing is playing. */
49654
+ currentMedia: MediaInfoSchema.nullable(),
49655
+ /** Current playback position in ms. Null when not seekable or
49656
+ * nothing is playing. Pair with `DeviceFeature.MediaPlayerSeek`. */
49657
+ position: number().int().nonnegative().nullable().meta(readingMeta("duration-ms")),
49658
+ /** Total duration of the current media in ms. Null when unknown
49659
+ * (live stream) or nothing is playing. */
49660
+ duration: number().int().nonnegative().nullable().meta(readingMeta("duration-ms")),
49661
+ /** Shuffle toggle. Null when no shuffle surface.
49662
+ * Pair with `DeviceFeature.MediaPlayerShuffle`. */
49663
+ shuffle: boolean().nullable(),
49664
+ /** Repeat mode. Null when no repeat surface.
49665
+ * Pair with `DeviceFeature.MediaPlayerRepeat`. */
49666
+ repeat: MediaPlayerRepeatSchema.nullable(),
49667
+ /** Ms epoch when the slice was last updated. */
49668
+ lastChangedAt: number()
49669
+ });
49670
+ var stepInput = object({
49671
+ deviceId: number().int().nonnegative(),
49672
+ /** How many presses: the caller's count (Alexa `volumeSteps`, `channelCount`). */
49673
+ steps: number().int().min(1).max(50).default(1)
49674
+ });
49675
+ var deviceOnly = object({ deviceId: number().int().nonnegative() });
49676
+ var mediaPlayerCapability = {
49677
+ name: "media-player",
49678
+ scope: "device",
49679
+ deviceNative: true,
49680
+ mode: "singleton",
49681
+ deviceTypes: [DeviceType.MediaPlayer],
49682
+ methods: {
49683
+ turnOn: method(deviceOnly, _void(), {
49684
+ kind: "mutation",
49685
+ auth: "protected"
49686
+ }),
49687
+ turnOff: method(deviceOnly, _void(), {
49688
+ kind: "mutation",
49689
+ auth: "protected"
49690
+ }),
49691
+ volumeUp: method(stepInput, _void(), {
49692
+ kind: "mutation",
49693
+ auth: "protected"
49694
+ }),
49695
+ volumeDown: method(stepInput, _void(), {
49696
+ kind: "mutation",
49697
+ auth: "protected"
49698
+ }),
49699
+ channelUp: method(stepInput, _void(), {
49700
+ kind: "mutation",
49701
+ auth: "protected"
49702
+ }),
49703
+ channelDown: method(stepInput, _void(), {
49704
+ kind: "mutation",
49705
+ auth: "protected"
49706
+ }),
49707
+ play: method(object({ deviceId: number().int().nonnegative() }), _void(), {
49708
+ kind: "mutation",
49709
+ auth: "protected"
49710
+ }),
49711
+ pause: method(object({ deviceId: number().int().nonnegative() }), _void(), {
49712
+ kind: "mutation",
49713
+ auth: "protected"
49714
+ }),
49715
+ stop: method(object({ deviceId: number().int().nonnegative() }), _void(), {
49716
+ kind: "mutation",
49717
+ auth: "protected"
49718
+ }),
49719
+ next: method(object({ deviceId: number().int().nonnegative() }), _void(), {
49720
+ kind: "mutation",
49721
+ auth: "protected"
49722
+ }),
49723
+ previous: method(object({ deviceId: number().int().nonnegative() }), _void(), {
49724
+ kind: "mutation",
49725
+ auth: "protected"
49726
+ }),
49727
+ seek: method(object({
49728
+ deviceId: number().int().nonnegative(),
49729
+ position: number().int().nonnegative()
49730
+ }), _void(), {
49731
+ kind: "mutation",
49732
+ auth: "protected"
49733
+ }),
49734
+ setVolume: method(object({
49735
+ deviceId: number().int().nonnegative(),
49736
+ volumeLevel: number().min(0).max(100)
49737
+ }), _void(), {
49738
+ kind: "mutation",
49739
+ auth: "protected"
49740
+ }),
49741
+ setMute: method(object({
49742
+ deviceId: number().int().nonnegative(),
49743
+ muted: boolean()
49744
+ }), _void(), {
49745
+ kind: "mutation",
49746
+ auth: "protected"
49747
+ }),
49748
+ setShuffle: method(object({
49749
+ deviceId: number().int().nonnegative(),
49750
+ shuffle: boolean()
49751
+ }), _void(), {
49752
+ kind: "mutation",
49753
+ auth: "protected"
49754
+ }),
49755
+ setRepeat: method(object({
49756
+ deviceId: number().int().nonnegative(),
49757
+ repeat: MediaPlayerRepeatSchema
49758
+ }), _void(), {
49759
+ kind: "mutation",
49760
+ auth: "protected"
49761
+ }),
49762
+ selectSource: method(object({
49763
+ deviceId: number().int().nonnegative(),
49764
+ source: string().min(1)
49765
+ }), _void(), {
49766
+ kind: "mutation",
49767
+ auth: "protected"
49768
+ }),
49769
+ playMedia: method(object({
49770
+ deviceId: number().int().nonnegative(),
49771
+ /** Media identifier / URL. */
49772
+ mediaId: string().min(1),
49773
+ /** Media kind (`music`, `tvshow`, `movie`, `app`, …) — provider
49774
+ * passes it through to the upstream service. */
49775
+ mediaType: string().min(1)
49776
+ }), _void(), {
49777
+ kind: "mutation",
49778
+ auth: "protected"
49779
+ })
49780
+ },
49781
+ status: {
49782
+ schema: MediaPlayerStatusSchema,
49783
+ kind: "push"
49784
+ },
49785
+ /**
49786
+ * Runtime-state slice — mirrored by the kernel. UI players read the
49787
+ * full slice for live now-playing, volume, and progress updates
49788
+ * without polling.
49789
+ */
49790
+ runtimeState: MediaPlayerStatusSchema,
49791
+ /**
49792
+ * Runtime-state durability: **session** — a restored transport position describes a playback that stopped when the hub did.
49793
+ *
49794
+ * See `RuntimeStateDurability`. Enforced by
49795
+ * `scripts/check-runtime-state-durability.ts`.
49796
+ */
49797
+ durability: "session",
49798
+ /**
49799
+ * History (D850): volume (a level an operator or an automation sets; the
49800
+ * default 10 s floor folds a slider drag into its end value) and mute.
49801
+ * `position` is not recorded: it moves continuously while playing.
49802
+ */
49803
+ history: { fields: {
49804
+ volumeLevel: {
49805
+ kind: "gauge",
49806
+ unit: "%",
49807
+ deadband: 1
49808
+ },
49809
+ isMuted: { kind: "boolean" }
49810
+ } }
49811
+ };
48456
49812
  DeviceType.Camera, DeviceType.Sensor, DeviceType.Button, DeviceType.Switch, DeviceType.PetFeeder, DeviceType.Container, DeviceType.Thermostat, DeviceType.EventEmitter, 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.PetFountain, DeviceType.Dishwasher, DeviceType.Washer, DeviceType.Heater, DeviceType.Dryer, DeviceType.Gateway, DeviceType.Camera, DeviceType.Fan, DeviceType.Lock, DeviceType.Camera, DeviceType.Switch, DeviceType.Light, DeviceType.Fan, DeviceType.Climate, DeviceType.Thermostat, DeviceType.Humidifier, DeviceType.WaterHeater, DeviceType.MediaPlayer, DeviceType.Washer, DeviceType.Dryer, DeviceType.Dishwasher, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.PetFeeder, DeviceType.Heater, DeviceType.Switch, DeviceType.Light, DeviceType.Fan, DeviceType.Climate, DeviceType.Thermostat, DeviceType.Humidifier, DeviceType.WaterHeater, DeviceType.MediaPlayer, DeviceType.Washer, DeviceType.Dryer, DeviceType.Dishwasher, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.PetFeeder, DeviceType.Heater, DeviceType.Switch, DeviceType.Light, DeviceType.Fan, DeviceType.Climate, DeviceType.Thermostat, DeviceType.Humidifier, DeviceType.WaterHeater, DeviceType.MediaPlayer, DeviceType.Washer, DeviceType.Dryer, DeviceType.Dishwasher, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.PetFeeder, DeviceType.Heater, DeviceType.Switch, DeviceType.Light, DeviceType.Fan, DeviceType.Climate, DeviceType.Thermostat, DeviceType.Humidifier, DeviceType.WaterHeater, DeviceType.MediaPlayer, DeviceType.Washer, DeviceType.Dryer, DeviceType.Dishwasher, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.PetFeeder, DeviceType.Heater, DeviceType.Gateway, DeviceType.Hub, DeviceType.Camera, DeviceType.Sensor, DeviceType.MediaPlayer, DeviceType.Vacuum, DeviceType.Generic, DeviceType.Washer, DeviceType.Dryer, DeviceType.Dishwasher, DeviceType.PetFountain, DeviceType.Fan, DeviceType.Humidifier, DeviceType.Climate, DeviceType.WaterHeater, DeviceType.MediaPlayer, DeviceType.Washer, DeviceType.Dryer, DeviceType.Dishwasher, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.MediaPlayer, DeviceType.WaterHeater, DeviceType.Humidifier, DeviceType.Fan, DeviceType.Climate, DeviceType.Thermostat, DeviceType.PetFeeder, DeviceType.Heater;
48457
49813
  var NUMBER = {
48458
49814
  kind: "fixed",
@@ -48900,117 +50256,6 @@ function actuator(input) {
48900
50256
  };
48901
50257
  }
48902
50258
  new Map(GROUP_TEMPLATES.map((template) => [template.id, template]));
48903
- var PowerSourceRefusalReasonSchema = _enum([
48904
- "no-power-source",
48905
- "switch-missing",
48906
- "switch-offline",
48907
- "switch-unknown",
48908
- "restart-in-progress",
48909
- "switch-call-failed"
48910
- ]);
48911
- var PowerSourceActionResultSchema = discriminatedUnion("accepted", [object({ accepted: literal(true) }), object({
48912
- accepted: literal(false),
48913
- reason: PowerSourceRefusalReasonSchema,
48914
- /** One line for the operator, naming the switch. */
48915
- message: string()
48916
- })]);
48917
- var PowerSourceInfoSchema = object({
48918
- /** False when the device has no power source linked; the rest is then empty. */
48919
- linked: boolean(),
48920
- switchDeviceId: number().nullable(),
48921
- switchName: string().nullable(),
48922
- /** The switch's on/off state, or null when it is unknown. Never false for unknown (D393). */
48923
- switchOn: boolean().nullable(),
48924
- switchOnline: boolean().nullable(),
48925
- restartInProgress: boolean(),
48926
- offSeconds: number().int()
48927
- });
48928
- /** The composed slice: the switch state the link mirrors, plus the stored off time. */
48929
- var PowerSourceStateSchema = object({
48930
- /** Null while the switch has not reported: unknown is never `false` (D393). */
48931
- switchOn: boolean().nullable(),
48932
- offSeconds: number().int(),
48933
- lastFetchedAt: number()
48934
- });
48935
- var POWER_SOURCE_DEVICE_TYPES = [
48936
- DeviceType.Gateway,
48937
- DeviceType.Hub,
48938
- DeviceType.Camera,
48939
- DeviceType.Sensor,
48940
- DeviceType.MediaPlayer,
48941
- DeviceType.Vacuum,
48942
- DeviceType.Generic,
48943
- DeviceType.Washer,
48944
- DeviceType.Dryer,
48945
- DeviceType.Dishwasher,
48946
- DeviceType.PetFountain,
48947
- DeviceType.Fan,
48948
- DeviceType.Humidifier,
48949
- DeviceType.Climate,
48950
- DeviceType.WaterHeater
48951
- ];
48952
- var powerSourceCustomize = {
48953
- version: 1,
48954
- targets: [{
48955
- id: "switch",
48956
- cardinality: "scalar",
48957
- vocabulary: {
48958
- cap: "power-source",
48959
- stateField: "switchOn"
48960
- },
48961
- deviceTypes: POWER_SOURCE_DEVICE_TYPES,
48962
- apply: "add",
48963
- path: "switchOn",
48964
- sources: [{
48965
- kind: "switch",
48966
- transforms: [{ kind: "identity" }]
48967
- }],
48968
- companions: [{
48969
- kind: "constant",
48970
- path: "offSeconds",
48971
- value: 10,
48972
- when: "add"
48973
- }, {
48974
- kind: "clock",
48975
- path: "lastFetchedAt",
48976
- when: "always"
48977
- }],
48978
- sourceReport: { status: "assignment-status" }
48979
- }]
48980
- };
48981
- var deviceInput$2 = object({ deviceId: number().int().nonnegative() });
48982
- var powerSourceCapability = {
48983
- name: "power-source",
48984
- scope: "device",
48985
- mode: "singleton",
48986
- deviceTypes: POWER_SOURCE_DEVICE_TYPES,
48987
- methods: {
48988
- getStatus: systemMethod(deviceInput$2, PowerSourceInfoSchema, { auth: "admin" }),
48989
- powerOn: systemMethod(deviceInput$2, PowerSourceActionResultSchema, {
48990
- kind: "mutation",
48991
- auth: "admin"
48992
- }),
48993
- powerOff: systemMethod(deviceInput$2, PowerSourceActionResultSchema, {
48994
- kind: "mutation",
48995
- auth: "admin"
48996
- }),
48997
- forceRestart: systemMethod(deviceInput$2, PowerSourceActionResultSchema, {
48998
- kind: "mutation",
48999
- auth: "admin"
49000
- })
49001
- },
49002
- runtimeState: PowerSourceStateSchema,
49003
- customize: powerSourceCustomize,
49004
- /**
49005
- * Runtime-state durability: **session** — mirrored from the linked switch on
49006
- * its next report; a restored value would outlive the reading it names.
49007
- *
49008
- * See `RuntimeStateDurability`. Enforced by
49009
- * `scripts/check-runtime-state-durability.ts`.
49010
- */
49011
- durability: "session",
49012
- history: "none"
49013
- };
49014
50259
  DeviceFeature.LightColorRgb, DeviceFeature.LightColorHsv, DeviceFeature.LightColorMired;
49015
50260
  DeviceType.Camera;
49016
50261
  `${COMPOSED_DEVICE_STABLE_ID_PREFIX}`;
@@ -49038,6 +50283,165 @@ var ComposableCapabilitiesSchema = object({ caps: array(object({
49038
50283
  }).optional()
49039
50284
  })) });
49040
50285
  /**
50286
+ * A saved Customize assignment (D936). The schema is the type: callers use
50287
+ * `z.infer`, they do not restate the shape.
50288
+ */
50289
+ var OverrideSourceSchema = object({
50290
+ addonId: string().min(1),
50291
+ stableId: string().min(1),
50292
+ cap: string().min(1),
50293
+ fieldPath: string().min(1)
50294
+ });
50295
+ var IdentityTransformDraftSchema = object({ kind: literal("identity") });
50296
+ var InvertTransformDraftSchema = object({ kind: literal("invert") });
50297
+ var ThresholdTransformDraftSchema = object({
50298
+ kind: literal("threshold"),
50299
+ comparison: _enum(["gte", "lte"]),
50300
+ threshold: number(),
50301
+ startDwellMs: number().nonnegative(),
50302
+ stopDwellMs: number().nonnegative()
50303
+ });
50304
+ var CustomizeTransformDraftSchema = discriminatedUnion("kind", [
50305
+ IdentityTransformDraftSchema,
50306
+ InvertTransformDraftSchema,
50307
+ ThresholdTransformDraftSchema,
50308
+ object({
50309
+ kind: literal("linear"),
50310
+ scale: number(),
50311
+ offset: number(),
50312
+ clampMin: number().optional(),
50313
+ clampMax: number().optional()
50314
+ }),
50315
+ object({
50316
+ kind: literal("enum-map"),
50317
+ mapping: record(string(), string().nullable())
50318
+ }),
50319
+ object({ kind: literal("number") })
50320
+ ]);
50321
+ var ScalarOverrideDraftSchema = object({
50322
+ kind: literal("scalar"),
50323
+ cap: string().min(1),
50324
+ targetId: string().min(1),
50325
+ source: OverrideSourceSchema,
50326
+ transform: CustomizeTransformDraftSchema
50327
+ });
50328
+ var KeyedArrayOverrideDraftSchema = object({
50329
+ kind: literal("keyedArray"),
50330
+ cap: string().min(1),
50331
+ targetId: string().min(1),
50332
+ key: string().min(1),
50333
+ label: string().min(1),
50334
+ fieldPath: string().min(1),
50335
+ source: OverrideSourceSchema,
50336
+ transform: CustomizeTransformDraftSchema
50337
+ });
50338
+ var PulseOverrideDraftSchema = object({
50339
+ kind: literal("pulse"),
50340
+ cap: string().min(1),
50341
+ targetId: string().min(1),
50342
+ enabled: boolean(),
50343
+ debounceMs: number().nonnegative(),
50344
+ edges: array(_enum([
50345
+ "rising",
50346
+ "button",
50347
+ "native-event"
50348
+ ])).min(1).optional(),
50349
+ sources: array(OverrideSourceSchema).min(1)
50350
+ });
50351
+ var SpanSourceDraftSchema = OverrideSourceSchema.extend({ mode: _enum([
50352
+ "in-addition",
50353
+ "confirm",
50354
+ "replace"
50355
+ ]).optional() });
50356
+ discriminatedUnion("kind", [
50357
+ ScalarOverrideDraftSchema,
50358
+ KeyedArrayOverrideDraftSchema,
50359
+ PulseOverrideDraftSchema,
50360
+ object({
50361
+ kind: literal("span"),
50362
+ cap: string().min(1),
50363
+ targetId: string().min(1),
50364
+ timeoutMs: number().nonnegative(),
50365
+ cooldownMs: number().nonnegative().optional(),
50366
+ sources: array(SpanSourceDraftSchema)
50367
+ })
50368
+ ]);
50369
+ object({
50370
+ targetId: string().min(1),
50371
+ configured: boolean(),
50372
+ source: _enum(["native", "assigned"]),
50373
+ state: _enum([
50374
+ "active",
50375
+ "stale",
50376
+ "released",
50377
+ "unavailable"
50378
+ ]),
50379
+ reason: string().nullable()
50380
+ });
50381
+ /**
50382
+ * What a running-threshold proposal says (planning#405). The schema is the
50383
+ * type: the algorithm, the capability method and the UI all read `z.infer`.
50384
+ *
50385
+ * A proposal is read-only advice: it carries the numbers it was derived from
50386
+ * (`evidence`) so the operator can judge it, and an `insufficient` answer names
50387
+ * WHY with a typed reason and the catalog defaults, never an invented number.
50388
+ */
50389
+ var RunningProposalTierSchema = _enum(["raw", "5m"]);
50390
+ var RunningProposalConfidenceSchema = _enum([
50391
+ "high",
50392
+ "medium",
50393
+ "low"
50394
+ ]);
50395
+ var RunningProposalInsufficientReasonSchema = _enum([
50396
+ "no-history",
50397
+ "span-too-short",
50398
+ "truncated",
50399
+ "no-idle-floor",
50400
+ "no-runs",
50401
+ "no-separation"
50402
+ ]);
50403
+ var RunningProposalReplaySchema = object({
50404
+ /** Intervals the real dwell expression held true over the window. */
50405
+ intervals: number().int().nonnegative(),
50406
+ /** Intervals outside every run, or a second interval inside one. */
50407
+ extra: number().int().nonnegative(),
50408
+ /** Runs without an interval of their own (none, or merged into a neighbour). */
50409
+ missed: number().int().nonnegative()
50410
+ });
50411
+ var RunningProposalEvidenceSchema = object({
50412
+ tier: RunningProposalTierSchema,
50413
+ spanMs: number().nonnegative(),
50414
+ from: number(),
50415
+ to: number(),
50416
+ points: number().int().nonnegative(),
50417
+ runsFound: number().int().nonnegative(),
50418
+ pausesFound: number().int().nonnegative(),
50419
+ longestPauseMs: number().nonnegative(),
50420
+ idleFloorW: number(),
50421
+ noiseCeilingW: number(),
50422
+ plateauW: number(),
50423
+ replay: RunningProposalReplaySchema
50424
+ });
50425
+ var RunningProposalInsufficientEvidenceSchema = object({
50426
+ spanMs: number().nonnegative(),
50427
+ points: number().int().nonnegative(),
50428
+ runsFound: number().int().nonnegative()
50429
+ });
50430
+ var RunningThresholdProposalSchema = discriminatedUnion("state", [object({
50431
+ state: literal("proposal"),
50432
+ transform: ThresholdTransformDraftSchema,
50433
+ evidence: RunningProposalEvidenceSchema,
50434
+ confidence: RunningProposalConfidenceSchema,
50435
+ /** Why the confidence is not higher; empty when nothing held it back. */
50436
+ notes: array(string())
50437
+ }), object({
50438
+ state: literal("insufficient"),
50439
+ reason: RunningProposalInsufficientReasonSchema,
50440
+ evidence: RunningProposalInsufficientEvidenceSchema,
50441
+ /** The catalog defaults, offered as what stands when nothing better is known. */
50442
+ fallback: ThresholdTransformDraftSchema
50443
+ })]);
50444
+ /**
49041
50445
  * The report of a one-shot "move this owner's plaintext secrets into the
49042
50446
  * keychain" run (D878). COUNTS only - never a value, never a ref.
49043
50447
  *
@@ -49327,6 +50731,14 @@ method(object({}), object({ blocks: array(CoreBlockSchema) }), { auth: "admin" }
49327
50731
  kind: "mutation",
49328
50732
  auth: "admin",
49329
50733
  access: "view"
50734
+ }), method(object({
50735
+ deviceId: number().int(),
50736
+ cap: string().min(1),
50737
+ fieldPath: string().min(1),
50738
+ deviceType: _enum(DeviceType).optional()
50739
+ }), RunningThresholdProposalSchema, {
50740
+ auth: "admin",
50741
+ access: "view"
49330
50742
  }), method(object({
49331
50743
  blockId: string().min(1),
49332
50744
  trace: AutomationRunTraceSchema.optional(),
@@ -50303,7 +51715,27 @@ method(object({
50303
51715
  * exposes only the COMMON surface: link state, supported device
50304
51716
  * kinds (so the UI can filter the device picker), and per-device
50305
51717
  * expose/unexpose.
50306
- */
51718
+ *
51719
+ * INSTANCES. One export addon can serve several independent targets (a
51720
+ * HomeKit bridge, a Home Assistant broker). `listInstances` names them.
51721
+ * `instanceId` on a READ is optional: absent = the whole addon (linked if any
51722
+ * enabled instance is, `exposedDeviceCount` = distinct devices, `setup` = the
51723
+ * default instance's); present = that instance; an id the provider does not
51724
+ * serve is refused with `ExportInstanceUnknownError` (`export-instance-unknown`),
51725
+ * never answered empty. `instanceId` on a WRITE is REQUIRED: a membership
51726
+ * change always names the target it changes. A single-instance provider
51727
+ * accepts an absent id on a read or its own id, and refuses any other.
51728
+ */
51729
+ /** Which instance of an export addon a call addresses. Absent on a read = the whole addon. */
51730
+ var InstanceIdSchema$1 = string().min(1);
51731
+ var InstancePinSchema = object({ instanceId: InstanceIdSchema$1.optional() });
51732
+ /** One independent export target of an addon. */
51733
+ var ExportInstanceSchema = object({
51734
+ instanceId: InstanceIdSchema$1,
51735
+ name: string(),
51736
+ enabled: boolean(),
51737
+ kind: string().optional()
51738
+ });
50307
51739
  var LinkStateSchema = _enum([
50308
51740
  "unlinked",
50309
51741
  "linked",
@@ -50354,10 +51786,14 @@ var ExposedDeviceSchema = object({
50354
51786
  capabilities: array(string()).optional()
50355
51787
  });
50356
51788
  var ExposeInputSchema = object({
51789
+ instanceId: InstanceIdSchema$1,
50357
51790
  deviceId: string(),
50358
51791
  capabilities: array(string()).optional()
50359
51792
  });
50360
- var UnexposeInputSchema = object({ deviceId: string() });
51793
+ var UnexposeInputSchema = object({
51794
+ instanceId: InstanceIdSchema$1,
51795
+ deviceId: string()
51796
+ });
50361
51797
  /**
50362
51798
  * What an exporter may expose besides devices (D968). An action and a
50363
51799
  * notification target are LIST ENTRIES, never devices (D954): they enter an
@@ -50386,15 +51822,21 @@ var ExposedEntitySchema = object({
50386
51822
  entity: ExportEntityRefSchema,
50387
51823
  exposedAs: string().optional()
50388
51824
  });
50389
- var ExposeEntityInputSchema = object({ entity: ExportEntityRefSchema });
50390
- var UnexposeEntityInputSchema = object({ entity: ExportEntityRefSchema });
50391
- method(_void(), DeviceExportStatusSchema), method(_void(), array(DeviceKindSchema)), method(_void(), array(ExposedDeviceSchema)), method(ExposeInputSchema, _void(), {
51825
+ var ExposeEntityInputSchema = object({
51826
+ instanceId: InstanceIdSchema$1,
51827
+ entity: ExportEntityRefSchema
51828
+ });
51829
+ var UnexposeEntityInputSchema = object({
51830
+ instanceId: InstanceIdSchema$1,
51831
+ entity: ExportEntityRefSchema
51832
+ });
51833
+ method(InstancePinSchema, DeviceExportStatusSchema), method(_void(), array(ExportInstanceSchema)), method(InstancePinSchema, array(DeviceKindSchema)), method(InstancePinSchema, array(ExposedDeviceSchema)), method(ExposeInputSchema, _void(), {
50392
51834
  kind: "mutation",
50393
51835
  auth: "admin"
50394
51836
  }), method(UnexposeInputSchema, _void(), {
50395
51837
  kind: "mutation",
50396
51838
  auth: "admin"
50397
- }), optionalMethod(_void(), array(ExportEntityKindSchema)), optionalMethod(_void(), array(ExposedEntitySchema)), optionalMethod(ExposeEntityInputSchema, _void(), {
51839
+ }), optionalMethod(_void(), array(ExportEntityKindSchema)), optionalMethod(InstancePinSchema, array(ExposedEntitySchema)), optionalMethod(ExposeEntityInputSchema, _void(), {
50398
51840
  kind: "mutation",
50399
51841
  auth: "admin"
50400
51842
  }), optionalMethod(UnexposeEntityInputSchema, _void(), {
@@ -50760,6 +52202,45 @@ var deviceProviderCapability = {
50760
52202
  }
50761
52203
  };
50762
52204
  /**
52205
+ * What the passive listener of `local-network` saw on the wire, before any
52206
+ * provider classified it. Device-manager turns an observation into the hits
52207
+ * of the providers whose declared discovery modes it matches.
52208
+ */
52209
+ var DiscoveryObservationSchema = discriminatedUnion("kind", [object({
52210
+ kind: literal("mdns"),
52211
+ /** Normalised DNS-SD service type, e.g. `_esphomelib._tcp`. */
52212
+ serviceType: string(),
52213
+ instance: string(),
52214
+ host: string(),
52215
+ /** The A record address when the announcement carried one. */
52216
+ address: string().nullable(),
52217
+ port: number().int(),
52218
+ txt: record(string(), string())
52219
+ }), object({
52220
+ kind: literal("ssdp"),
52221
+ /** Sender address of the datagram. */
52222
+ host: string(),
52223
+ port: number().int(),
52224
+ /** `NT` of a NOTIFY, `ST` of a search response. */
52225
+ target: string(),
52226
+ headers: record(string(), string())
52227
+ })]);
52228
+ object({
52229
+ addonId: string(),
52230
+ candidate: DiscoveryCandidateSchema,
52231
+ firstSeenAt: number(),
52232
+ lastSeenAt: number(),
52233
+ dismissed: boolean()
52234
+ });
52235
+ var DiscoveryProposalSchema = object({
52236
+ id: string(),
52237
+ addonId: string(),
52238
+ candidate: DiscoveryCandidateSchema,
52239
+ firstSeenAt: number(),
52240
+ lastSeenAt: number(),
52241
+ dismissed: boolean()
52242
+ });
52243
+ /**
50763
52244
  * Device Manager capability — hub-side singleton that unifies device persistence,
50764
52245
  * live registry access, and all management operations into a single tRPC surface.
50765
52246
  *
@@ -51488,6 +52969,19 @@ method(object({
51488
52969
  }), object({ candidates: array(DiscoveryCandidateSchema).readonly() }), {
51489
52970
  kind: "mutation",
51490
52971
  auth: "admin"
52972
+ }), method(object({}), object({ proposals: array(DiscoveryProposalSchema).readonly() }), { auth: "admin" }), method(object({ id: string() }), object({ dismissed: boolean() }), {
52973
+ kind: "mutation",
52974
+ auth: "admin"
52975
+ }), method(object({ observations: array(DiscoveryObservationSchema).max(512) }), object({ proposed: number().int() }), {
52976
+ kind: "mutation",
52977
+ auth: "admin"
52978
+ }), method(object({}), object({
52979
+ providers: number().int(),
52980
+ proposed: number().int()
52981
+ }), {
52982
+ kind: "mutation",
52983
+ auth: "admin",
52984
+ timeoutMs: 12e4
51491
52985
  }), method(object({ addonId: string() }), object({ deviceType: _enum(DeviceType).nullable() }), { auth: "admin" }), method(object({ addonId: string() }), unknown(), { auth: "admin" }), method(object({
51492
52986
  deviceId: number(),
51493
52987
  key: string(),
@@ -52344,7 +53838,7 @@ var DishwasherStatusSchema = object({
52344
53838
  /** Ms epoch of the last value received from the appliance; 0 = never. */
52345
53839
  lastFetchedAt: number()
52346
53840
  });
52347
- var DeviceIdSchema$1 = number().int().nonnegative();
53841
+ var DeviceIdSchema$2 = number().int().nonnegative();
52348
53842
  /** A value a program option or setting can take. */
52349
53843
  var DishwasherValueSchema = union([
52350
53844
  boolean(),
@@ -52419,77 +53913,77 @@ var dishwasherCapability = {
52419
53913
  * option feature keys; each is checked against the program's constraints.
52420
53914
  */
52421
53915
  start: method(object({
52422
- deviceId: DeviceIdSchema$1,
53916
+ deviceId: DeviceIdSchema$2,
52423
53917
  program: string().min(1).optional(),
52424
53918
  options: record(string(), DishwasherValueSchema).optional()
52425
53919
  }), _void(), {
52426
53920
  kind: "mutation",
52427
53921
  auth: "protected"
52428
53922
  }),
52429
- pause: method(object({ deviceId: DeviceIdSchema$1 }), _void(), {
53923
+ pause: method(object({ deviceId: DeviceIdSchema$2 }), _void(), {
52430
53924
  kind: "mutation",
52431
53925
  auth: "protected"
52432
53926
  }),
52433
- resume: method(object({ deviceId: DeviceIdSchema$1 }), _void(), {
53927
+ resume: method(object({ deviceId: DeviceIdSchema$2 }), _void(), {
52434
53928
  kind: "mutation",
52435
53929
  auth: "protected"
52436
53930
  }),
52437
- stop: method(object({ deviceId: DeviceIdSchema$1 }), _void(), {
53931
+ stop: method(object({ deviceId: DeviceIdSchema$2 }), _void(), {
52438
53932
  kind: "mutation",
52439
53933
  auth: "protected"
52440
53934
  }),
52441
53935
  /** Select (not start) a program; refused when the appliance does not offer it. */
52442
53936
  setProgram: method(object({
52443
- deviceId: DeviceIdSchema$1,
53937
+ deviceId: DeviceIdSchema$2,
52444
53938
  program: string().min(1)
52445
53939
  }), _void(), {
52446
53940
  kind: "mutation",
52447
53941
  auth: "protected"
52448
53942
  }),
52449
53943
  setPower: method(object({
52450
- deviceId: DeviceIdSchema$1,
53944
+ deviceId: DeviceIdSchema$2,
52451
53945
  on: boolean()
52452
53946
  }), _void(), {
52453
53947
  kind: "mutation",
52454
53948
  auth: "protected"
52455
53949
  }),
52456
53950
  setHalfLoad: method(object({
52457
- deviceId: DeviceIdSchema$1,
53951
+ deviceId: DeviceIdSchema$2,
52458
53952
  on: boolean()
52459
53953
  }), _void(), {
52460
53954
  kind: "mutation",
52461
53955
  auth: "protected"
52462
53956
  }),
52463
53957
  setHygienePlus: method(object({
52464
- deviceId: DeviceIdSchema$1,
53958
+ deviceId: DeviceIdSchema$2,
52465
53959
  on: boolean()
52466
53960
  }), _void(), {
52467
53961
  kind: "mutation",
52468
53962
  auth: "protected"
52469
53963
  }),
52470
53964
  setExtraDry: method(object({
52471
- deviceId: DeviceIdSchema$1,
53965
+ deviceId: DeviceIdSchema$2,
52472
53966
  on: boolean()
52473
53967
  }), _void(), {
52474
53968
  kind: "mutation",
52475
53969
  auth: "protected"
52476
53970
  }),
52477
53971
  setIntensiveZone: method(object({
52478
- deviceId: DeviceIdSchema$1,
53972
+ deviceId: DeviceIdSchema$2,
52479
53973
  on: boolean()
52480
53974
  }), _void(), {
52481
53975
  kind: "mutation",
52482
53976
  auth: "protected"
52483
53977
  }),
52484
53978
  setVarioSpeedPlus: method(object({
52485
- deviceId: DeviceIdSchema$1,
53979
+ deviceId: DeviceIdSchema$2,
52486
53980
  on: boolean()
52487
53981
  }), _void(), {
52488
53982
  kind: "mutation",
52489
53983
  auth: "protected"
52490
53984
  }),
52491
53985
  setChildLock: method(object({
52492
- deviceId: DeviceIdSchema$1,
53986
+ deviceId: DeviceIdSchema$2,
52493
53987
  on: boolean()
52494
53988
  }), _void(), {
52495
53989
  kind: "mutation",
@@ -52501,7 +53995,7 @@ var dishwasherCapability = {
52501
53995
  * its declared range / members.
52502
53996
  */
52503
53997
  setOption: method(object({
52504
- deviceId: DeviceIdSchema$1,
53998
+ deviceId: DeviceIdSchema$2,
52505
53999
  key: string().min(1),
52506
54000
  value: DishwasherValueSchema
52507
54001
  }), _void(), {
@@ -52509,7 +54003,7 @@ var dishwasherCapability = {
52509
54003
  auth: "protected"
52510
54004
  }),
52511
54005
  /** What this appliance can do, from its own description — the UI is derived from it. */
52512
- getOptions: method(object({ deviceId: DeviceIdSchema$1 }), DishwasherOptionsSchema, { auth: "protected" })
54006
+ getOptions: method(object({ deviceId: DeviceIdSchema$2 }), DishwasherOptionsSchema, { auth: "protected" })
52513
54007
  },
52514
54008
  status: {
52515
54009
  schema: DishwasherStatusSchema,
@@ -53933,15 +55427,15 @@ var FanPresetCaptureResultSchema = object({
53933
55427
  items: array(FanCaptureItemSchema),
53934
55428
  omitted: array(FanCaptureOmissionSchema)
53935
55429
  });
53936
- var deviceInput$1 = object({ deviceId: number().int().nonnegative() });
55430
+ var deviceInput$2 = object({ deviceId: number().int().nonnegative() });
53937
55431
  DeviceType.Fan;
53938
- method(deviceInput$1, array(FanPresetSchema), { auth: "protected" }), method(deviceInput$1.extend({ presets: array(FanPresetSchema).max(12) }), FanPresetsSetResultSchema, {
55432
+ method(deviceInput$2, array(FanPresetSchema), { auth: "protected" }), method(deviceInput$2.extend({ presets: array(FanPresetSchema).max(12) }), FanPresetsSetResultSchema, {
53939
55433
  kind: "mutation",
53940
55434
  auth: "admin"
53941
- }), method(deviceInput$1.extend({ presetId: string().min(1) }), FanPresetApplyResultSchema, {
55435
+ }), method(deviceInput$2.extend({ presetId: string().min(1) }), FanPresetApplyResultSchema, {
53942
55436
  kind: "mutation",
53943
55437
  auth: "protected"
53944
- }), method(deviceInput$1.extend({
55438
+ }), method(deviceInput$2.extend({
53945
55439
  fields: array(FanCaptureFieldSchema).optional(),
53946
55440
  steps: array(ActionStepSchema).max(20).default([])
53947
55441
  }), FanPresetCaptureResultSchema, { auth: "protected" });
@@ -54824,6 +56318,12 @@ method(_void(), array(IntegrationWithStateSchema)), method(object({ id: string()
54824
56318
  }), object({ success: boolean() }), {
54825
56319
  kind: "mutation",
54826
56320
  auth: "admin"
56321
+ }), method(object({ id: string() }), object({
56322
+ rows: number().int().nonnegative(),
56323
+ secrets: number().int().nonnegative()
56324
+ }), {
56325
+ kind: "mutation",
56326
+ auth: "admin"
54827
56327
  }), method(_void(), array(AvailableIntegrationTypeSchema), { auth: "admin" }), method(object({
54828
56328
  addonId: string(),
54829
56329
  settings: record(string(), unknown())
@@ -54832,6 +56332,174 @@ method(_void(), array(IntegrationWithStateSchema)), method(object({ id: string()
54832
56332
  auth: "admin"
54833
56333
  });
54834
56334
  /**
56335
+ * `integration-instances` - the connection of an addon that holds ONE or SEVERAL
56336
+ * (an account, a relay, a destination) as typed records (D985, D986). The addon's
56337
+ * own function page reads and writes them (Logging for Loki); the Integrations
56338
+ * page lists only the integrations that bring devices (D996).
56339
+ *
56340
+ * A collection of providers: each addon that holds connections registers one and a
56341
+ * caller reaches a provider with the pinned `addonId`.
56342
+ *
56343
+ * Identity: the instance id is immutable and opaque to the caller. A record the
56344
+ * Loki migration made keeps the `integrations` registry id it was created under
56345
+ * (`int_NNNN`); a single instance made by its function page takes the addon id.
56346
+ * `name` is the editable label.
56347
+ *
56348
+ * Secrets: every field the instance kind marks `.meta({ secret: true })` reaches
56349
+ * the form as a `SecretFieldView`, never text (D789). A patch value omitted, `''`
56350
+ * or the redaction token KEEPS the stored secret; `{ $secretClear: true }`
56351
+ * clears it.
56352
+ */
56353
+ var ConfigSchemaPassthrough$3 = custom();
56354
+ var IntegrationInstanceIdSchema = string().min(1);
56355
+ var IntegrationInstanceModeSchema = _enum(["single", "multiple"]);
56356
+ /**
56357
+ * One kind of instance a provider can create (an adapter, an account type). The sign-in and
56358
+ * connect fields follow the `broker` contract (`broker.cap.ts`): `signIn.basePath` is a
56359
+ * hub-relative route set speaking the sign-in contract, `connectPath` / `disconnectPath` open an
56360
+ * interactive account link (popup) and may carry `{{brokerId}}`, which the UI replaces with the
56361
+ * instance id.
56362
+ */
56363
+ var IntegrationInstanceKindSchema = object({
56364
+ /** Stable id of the kind, sent back as `createInstance.kind`. */
56365
+ id: string().min(1),
56366
+ label: string().min(1),
56367
+ /** The kind signs in through a server-held interactive session. */
56368
+ signIn: object({
56369
+ basePath: string().min(1),
56370
+ methods: array(_enum(["device-code", "proxy"])).optional()
56371
+ }).optional(),
56372
+ /** Relative hub path to start an interactive account link of an instance of this kind. */
56373
+ connectPath: string().min(1).optional(),
56374
+ /** Relative hub path to disconnect that account. */
56375
+ disconnectPath: string().min(1).optional()
56376
+ });
56377
+ var IntegrationInstanceDescriptionSchema = object({
56378
+ /** What the instances are for the Integrations page; see {@link IntegrationInstanceRoleSchema}. */
56379
+ role: _enum([
56380
+ "devices",
56381
+ "services",
56382
+ "both"
56383
+ ]),
56384
+ /** How the devices of an instance are found; absent means `{ mode: 'none' }`. */
56385
+ discovery: object({
56386
+ mode: _enum([
56387
+ "none",
56388
+ "lan",
56389
+ "account"
56390
+ ]),
56391
+ scopedToInstance: boolean()
56392
+ }).optional(),
56393
+ /** `single`: at most one instance can exist (Loki). `multiple`: an account each. */
56394
+ instanceMode: IntegrationInstanceModeSchema,
56395
+ /** What the instance is, for the UI (`destination`, `relay`, `account`). */
56396
+ kind: string(),
56397
+ /** True when `testInstance` really probes the remote. */
56398
+ canTest: boolean(),
56399
+ /**
56400
+ * The kinds an instance can be of. Absent or one entry: nothing to choose; more than one: the
56401
+ * Add flow asks which first and sends it as `createInstance.kind`.
56402
+ */
56403
+ kinds: array(IntegrationInstanceKindSchema).optional(),
56404
+ /**
56405
+ * The provider accepts `createInstance.id` for an id that once existed (an adopted id, because
56406
+ * devices carry it). The UI then offers "restore under its old id" on Add. Absent means no.
56407
+ */
56408
+ allowRestoreId: boolean().optional(),
56409
+ /**
56410
+ * `createInstance` without an `id` works: the provider mints it. Absent means the caller must
56411
+ * send an id (the UI then mints an opaque one).
56412
+ */
56413
+ mintsId: boolean().optional()
56414
+ });
56415
+ var IntegrationInstanceStatusSchema = object({
56416
+ state: _enum([
56417
+ "ok",
56418
+ "off",
56419
+ "error",
56420
+ "unknown"
56421
+ ]),
56422
+ detail: string().optional(),
56423
+ /** A short human word for the state ("Signed in", "Token expired"); shown instead of `state`. */
56424
+ label: string().optional()
56425
+ });
56426
+ var IntegrationInstanceSchema = object({
56427
+ id: IntegrationInstanceIdSchema,
56428
+ name: string(),
56429
+ /** The addon's own rule (an URL is present, a client id is present...). */
56430
+ configured: boolean(),
56431
+ /**
56432
+ * The instance's own on/off switch (D996), derived from the record body (`enabled !== false`,
56433
+ * so a row written before the field existed is on). Absent when the `integrations` registry
56434
+ * owns the switch (`describe().role` is `devices`): read it from the registry row.
56435
+ */
56436
+ enabled: boolean().optional(),
56437
+ /** The kind of this instance (one of `describe().kinds[].id`), when the provider has kinds. */
56438
+ kind: string().optional(),
56439
+ /** Values for the instance form; a secret is a `SecretFieldView`, never text. */
56440
+ formValues: record(string(), unknown()),
56441
+ status: IntegrationInstanceStatusSchema.optional(),
56442
+ /** Epoch ms of the last probe of the remote that produced `status`; absent when never checked. */
56443
+ lastCheckedAt: number().optional()
56444
+ });
56445
+ var IntegrationInstancePatchSchema = object({
56446
+ id: IntegrationInstanceIdSchema,
56447
+ name: string().min(1).optional(),
56448
+ /** Omitted / '' / redaction token keeps a secret; `{ $secretClear: true }` clears it. */
56449
+ values: record(string(), unknown())
56450
+ });
56451
+ var integrationInstancesCapability = {
56452
+ name: "integration-instances",
56453
+ scope: "system",
56454
+ mode: "collection",
56455
+ methods: {
56456
+ describe: method(_void(), IntegrationInstanceDescriptionSchema, { auth: "admin" }),
56457
+ /** The form; `id: null` is the create form. */
56458
+ instanceFormSchema: method(object({ id: IntegrationInstanceIdSchema.nullable() }), ConfigSchemaPassthrough$3, { auth: "admin" }),
56459
+ listInstances: method(_void(), array(IntegrationInstanceSchema).readonly(), { auth: "admin" }),
56460
+ getInstance: method(object({ id: IntegrationInstanceIdSchema }), IntegrationInstanceSchema.nullable(), { auth: "admin" }),
56461
+ /**
56462
+ * Insert the typed record. With `id` it is stored under that id (a duplicate id is refused);
56463
+ * without one the PROVIDER mints it and answers it. `kind` picks one of `describe().kinds`.
56464
+ */
56465
+ createInstance: method(object({
56466
+ id: IntegrationInstanceIdSchema.optional(),
56467
+ name: string().min(1),
56468
+ kind: string().min(1).optional()
56469
+ }), object({ id: string() }), {
56470
+ kind: "mutation",
56471
+ auth: "admin"
56472
+ }),
56473
+ updateInstance: method(IntegrationInstancePatchSchema, object({ ok: literal(true) }), {
56474
+ kind: "mutation",
56475
+ auth: "admin"
56476
+ }),
56477
+ /**
56478
+ * Switch ONE instance on or off. A row control, not a form field: `updateInstance.values` is the
56479
+ * form patch (D62, D996). An off instance keeps its record and secrets and does no work.
56480
+ */
56481
+ setInstanceEnabled: method(object({
56482
+ id: IntegrationInstanceIdSchema,
56483
+ enabled: boolean()
56484
+ }), object({ ok: literal(true) }), {
56485
+ kind: "mutation",
56486
+ auth: "admin"
56487
+ }),
56488
+ /** Delete the record and its keychain refs together. */
56489
+ deleteInstance: method(object({ id: IntegrationInstanceIdSchema }), object({ ok: literal(true) }), {
56490
+ kind: "mutation",
56491
+ auth: "admin"
56492
+ }),
56493
+ testInstance: optionalMethod(object({
56494
+ id: IntegrationInstanceIdSchema.nullable(),
56495
+ values: record(string(), unknown())
56496
+ }), TestConnectionResultSchema$1, {
56497
+ kind: "mutation",
56498
+ auth: "admin"
56499
+ })
56500
+ }
56501
+ };
56502
+ /**
54835
56503
  * Two-way audio / talk-back cap. Clients open a WebRTC audio-only
54836
56504
  * session (server-initiated offer pattern, identical to the main
54837
56505
  * video WebRTC flow) and the browser captures the mic; the server
@@ -56848,6 +58516,11 @@ var LogEntrySchema = object({
56848
58516
  * flight, and not asking for the next slice ends the scan.
56849
58517
  */
56850
58518
  var LogReadQuerySchema = object({
58519
+ /**
58520
+ * Which destination INSTANCE answers (a destination addon may hold several records). Absent ⇒
58521
+ * the provider's first readable one, so a caller written before instances existed is unchanged.
58522
+ */
58523
+ instanceId: string().min(1).max(200).optional(),
56851
58524
  /** Correlates `cancelRead`. Caller-chosen, unique per in-flight read. */
56852
58525
  requestId: string().min(1).max(64).optional(),
56853
58526
  /** The device the line is about (`tags.deviceId`, numeric). */
@@ -56910,6 +58583,8 @@ var LogReadResultSchema = object({
56910
58583
  /** True when `cancelRead` ended this slice early. */
56911
58584
  cancelled: boolean().optional()
56912
58585
  });
58586
+ /** Names one destination instance; absent ⇒ the provider's first readable one. */
58587
+ var LogInstanceSelectorSchema = object({ instanceId: string().min(1).max(200).optional() });
56913
58588
  var LogReadCapabilitiesSchema = object({
56914
58589
  /** False ⇒ this destination only ships lines (console, forwarder, an unconfigured Loki). */
56915
58590
  readable: boolean(),
@@ -56928,7 +58603,7 @@ var LogReadCapabilitiesSchema = object({
56928
58603
  /** How far back the store reaches, when the provider knows (days). */
56929
58604
  retentionDays: number().nullable()
56930
58605
  });
56931
- method(LogEntrySchema, _void(), { kind: "mutation" }), optionalMethod(_void(), LogReadCapabilitiesSchema, { auth: "admin" }), optionalMethod(LogReadQuerySchema, LogReadResultSchema, { auth: "admin" }), optionalMethod(object({ requestId: string().min(1).max(64) }), object({ cancelled: boolean() }), {
58606
+ method(LogEntrySchema, _void(), { kind: "mutation" }), optionalMethod(LogInstanceSelectorSchema, LogReadCapabilitiesSchema, { auth: "admin" }), optionalMethod(LogReadQuerySchema, LogReadResultSchema, { auth: "admin" }), optionalMethod(object({ requestId: string().min(1).max(64) }), object({ cancelled: boolean() }), {
56932
58607
  kind: "mutation",
56933
58608
  auth: "admin"
56934
58609
  });
@@ -57032,214 +58707,6 @@ var LoginMethodContributionSchema = discriminatedUnion("kind", [
57032
58707
  ]);
57033
58708
  method(_void(), array(LoginMethodContributionSchema).readonly());
57034
58709
  /**
57035
- * Media-player cap. Models HA `media_player.*` (Sonos, Chromecast,
57036
- * Apple TV, Spotify, Roku, generic OTT receivers, …) on
57037
- * `DeviceType.MediaPlayer`. Disjoint from the camera streaming
57038
- * surface — those use `DeviceType.Camera` + the broker pipeline.
57039
- *
57040
- * The cap declares a wide method surface; not every backend supports
57041
- * every method. Drivers signal sub-capability via the
57042
- * `DeviceFeature.MediaPlayerXxx` flags (paired one-to-one with the
57043
- * corresponding method) so the UI gates buttons without a slice
57044
- * fetch — same pattern as `PanTiltZoom` for cameras.
57045
- */
57046
- var MediaPlayerStateSchema = _enum([
57047
- "off",
57048
- "on",
57049
- "idle",
57050
- "playing",
57051
- "paused",
57052
- "buffering",
57053
- "standby"
57054
- ]);
57055
- var MediaPlayerRepeatSchema = _enum([
57056
- "off",
57057
- "all",
57058
- "one"
57059
- ]);
57060
- var MediaInfoSchema = object({
57061
- /** Free-form media kind (`music`, `tvshow`, `movie`, `app`, `channel`,
57062
- * `podcast`, …). */
57063
- type: string(),
57064
- /** Human-readable title. */
57065
- title: string(),
57066
- /** Optional artist / channel / station label. */
57067
- artist: string().optional(),
57068
- /** Optional album / season / show name. */
57069
- album: string().optional(),
57070
- /** Optional cover-art / thumbnail URL. */
57071
- imageUrl: string().optional()
57072
- });
57073
- /**
57074
- * Where `state`, `volumeLevel`, `isMuted` and `source` come from. `reported`:
57075
- * the device said so. `assumed`: the driver has no feedback (infrared) and
57076
- * tracks what it last SENT; it moves only after a send was accepted, and a
57077
- * human at the real remote makes it wrong. A UI shows an assumed value as a
57078
- * guess, never as a reading.
57079
- */
57080
- var MediaPlayerStateSourceSchema = _enum(["reported", "assumed"]);
57081
- /** The fields of a media-player status a driver can only guess. */
57082
- var MediaPlayerAssumedFieldSchema = _enum([
57083
- "state",
57084
- "volumeLevel",
57085
- "isMuted",
57086
- "source"
57087
- ]);
57088
- var MediaPlayerStatusSchema = object({
57089
- /** Playback lifecycle state. */
57090
- state: MediaPlayerStateSchema,
57091
- /**
57092
- * Whether the state fields are readings or the driver's own bookkeeping.
57093
- * A slice written before this field existed parses as `reported`.
57094
- */
57095
- stateSource: MediaPlayerStateSourceSchema.default("reported"),
57096
- /**
57097
- * Which fields are the driver's own guess. `stateSource` is `assumed` when
57098
- * this is not empty; a field not listed here is a reading even then (power
57099
- * from a running-state source, mute guessed from the last send).
57100
- */
57101
- assumedFields: array(MediaPlayerAssumedFieldSchema).default([]),
57102
- /** Volume as 0..100 inclusive. Null when the device has no volume
57103
- * surface. Pair with `DeviceFeature.MediaPlayerVolume`. */
57104
- volumeLevel: number().min(0).max(100).nullable().meta(readingMeta("percentage")),
57105
- /** Mute toggle distinct from volume=0. Null when no mute surface.
57106
- * Pair with `DeviceFeature.MediaPlayerMute`. */
57107
- isMuted: boolean().nullable(),
57108
- /** Active source / input. Empty when no source surface. */
57109
- source: string(),
57110
- /** Selectable sources. Empty when no source surface.
57111
- * Pair with `DeviceFeature.MediaPlayerSelectSource`. */
57112
- availableSources: array(string()),
57113
- /** Currently-playing media info. Null when nothing is playing. */
57114
- currentMedia: MediaInfoSchema.nullable(),
57115
- /** Current playback position in ms. Null when not seekable or
57116
- * nothing is playing. Pair with `DeviceFeature.MediaPlayerSeek`. */
57117
- position: number().int().nonnegative().nullable().meta(readingMeta("duration-ms")),
57118
- /** Total duration of the current media in ms. Null when unknown
57119
- * (live stream) or nothing is playing. */
57120
- duration: number().int().nonnegative().nullable().meta(readingMeta("duration-ms")),
57121
- /** Shuffle toggle. Null when no shuffle surface.
57122
- * Pair with `DeviceFeature.MediaPlayerShuffle`. */
57123
- shuffle: boolean().nullable(),
57124
- /** Repeat mode. Null when no repeat surface.
57125
- * Pair with `DeviceFeature.MediaPlayerRepeat`. */
57126
- repeat: MediaPlayerRepeatSchema.nullable(),
57127
- /** Ms epoch when the slice was last updated. */
57128
- lastChangedAt: number()
57129
- });
57130
- var mediaPlayerCapability = {
57131
- name: "media-player",
57132
- scope: "device",
57133
- deviceNative: true,
57134
- mode: "singleton",
57135
- deviceTypes: [DeviceType.MediaPlayer],
57136
- methods: {
57137
- play: method(object({ deviceId: number().int().nonnegative() }), _void(), {
57138
- kind: "mutation",
57139
- auth: "protected"
57140
- }),
57141
- pause: method(object({ deviceId: number().int().nonnegative() }), _void(), {
57142
- kind: "mutation",
57143
- auth: "protected"
57144
- }),
57145
- stop: method(object({ deviceId: number().int().nonnegative() }), _void(), {
57146
- kind: "mutation",
57147
- auth: "protected"
57148
- }),
57149
- next: method(object({ deviceId: number().int().nonnegative() }), _void(), {
57150
- kind: "mutation",
57151
- auth: "protected"
57152
- }),
57153
- previous: method(object({ deviceId: number().int().nonnegative() }), _void(), {
57154
- kind: "mutation",
57155
- auth: "protected"
57156
- }),
57157
- seek: method(object({
57158
- deviceId: number().int().nonnegative(),
57159
- position: number().int().nonnegative()
57160
- }), _void(), {
57161
- kind: "mutation",
57162
- auth: "protected"
57163
- }),
57164
- setVolume: method(object({
57165
- deviceId: number().int().nonnegative(),
57166
- volumeLevel: number().min(0).max(100)
57167
- }), _void(), {
57168
- kind: "mutation",
57169
- auth: "protected"
57170
- }),
57171
- setMute: method(object({
57172
- deviceId: number().int().nonnegative(),
57173
- muted: boolean()
57174
- }), _void(), {
57175
- kind: "mutation",
57176
- auth: "protected"
57177
- }),
57178
- setShuffle: method(object({
57179
- deviceId: number().int().nonnegative(),
57180
- shuffle: boolean()
57181
- }), _void(), {
57182
- kind: "mutation",
57183
- auth: "protected"
57184
- }),
57185
- setRepeat: method(object({
57186
- deviceId: number().int().nonnegative(),
57187
- repeat: MediaPlayerRepeatSchema
57188
- }), _void(), {
57189
- kind: "mutation",
57190
- auth: "protected"
57191
- }),
57192
- selectSource: method(object({
57193
- deviceId: number().int().nonnegative(),
57194
- source: string().min(1)
57195
- }), _void(), {
57196
- kind: "mutation",
57197
- auth: "protected"
57198
- }),
57199
- playMedia: method(object({
57200
- deviceId: number().int().nonnegative(),
57201
- /** Media identifier / URL. */
57202
- mediaId: string().min(1),
57203
- /** Media kind (`music`, `tvshow`, `movie`, `app`, …) — provider
57204
- * passes it through to the upstream service. */
57205
- mediaType: string().min(1)
57206
- }), _void(), {
57207
- kind: "mutation",
57208
- auth: "protected"
57209
- })
57210
- },
57211
- status: {
57212
- schema: MediaPlayerStatusSchema,
57213
- kind: "push"
57214
- },
57215
- /**
57216
- * Runtime-state slice — mirrored by the kernel. UI players read the
57217
- * full slice for live now-playing, volume, and progress updates
57218
- * without polling.
57219
- */
57220
- runtimeState: MediaPlayerStatusSchema,
57221
- /**
57222
- * Runtime-state durability: **session** — a restored transport position describes a playback that stopped when the hub did.
57223
- *
57224
- * See `RuntimeStateDurability`. Enforced by
57225
- * `scripts/check-runtime-state-durability.ts`.
57226
- */
57227
- durability: "session",
57228
- /**
57229
- * History (D850): volume (a level an operator or an automation sets; the
57230
- * default 10 s floor folds a slider drag into its end value) and mute.
57231
- * `position` is not recorded: it moves continuously while playing.
57232
- */
57233
- history: { fields: {
57234
- volumeLevel: {
57235
- kind: "gauge",
57236
- unit: "%",
57237
- deadband: 1
57238
- },
57239
- isMuted: { kind: "boolean" }
57240
- } }
57241
- };
57242
- /**
57243
58710
  * mesh-network — collection cap for mesh-VPN providers.
57244
58711
  *
57245
58712
  * Different shape from `network-access` (public tunnels):
@@ -65599,7 +67066,14 @@ var NcMediaPolicySchema = object({
65599
67066
  */
65600
67067
  profile: CamProfileSchema.optional(),
65601
67068
  /** See {@link NcLinkedCameraModeSchema}. */
65602
- linkedCameras: NcLinkedCameraModeSchema.optional()
67069
+ linkedCameras: NcLinkedCameraModeSchema.optional(),
67070
+ /**
67071
+ * Sensor rules only: may this rule wake a SLEEPING battery camera to take
67072
+ * the linked still it attaches (D998)? Absent means yes, an explicit `false`
67073
+ * opts out. Deliberately not a Zod default: a rule that never chose keeps
67074
+ * following the hub's. One bounded wake per event; nothing is attached later.
67075
+ */
67076
+ wakeSleepingCamera: boolean().optional()
65603
67077
  });
65604
67078
  /**
65605
67079
  * Cooldown GRANULARITY over the subject's class — how much a fired
@@ -65991,6 +67465,21 @@ var NcTemplateVarKindSchema = _enum([
65991
67465
  "sound",
65992
67466
  "system"
65993
67467
  ]);
67468
+ /**
67469
+ * The default title/body a rule of one SITUATION is delivered with when the
67470
+ * operator wrote no template — served so an editor can pre-fill it (and the
67471
+ * operator can rebuild it from placeholders) instead of starting from a blank
67472
+ * box that, once saved, silently replaces it. `id` names the situation inside
67473
+ * a rule `kind`: `appliance-cycle` is a `sensor` rule whose device is an
67474
+ * appliance finishing a cycle. Texts are raw templates (`{{var}}` intact), in
67475
+ * the hub's current language and with its overrides applied.
67476
+ */
67477
+ var NcTemplateDefaultSchema = object({
67478
+ id: _enum(["appliance-cycle"]),
67479
+ kind: NcRuleKindSchema,
67480
+ title: string(),
67481
+ body: string()
67482
+ });
65994
67483
  /** Which producer renders a template: an ordinary rule, a timelapse, a digest. */
65995
67484
  var NcTemplateFamilySchema = _enum([
65996
67485
  "rule",
@@ -66846,7 +68335,11 @@ method(object({}), object({ rules: array(NcRuleSchema) }), { auth: "admin" }), m
66846
68335
  }), method(object({}), object({
66847
68336
  catalog: array(NcConditionDescriptorSchema),
66848
68337
  taxonomy: NcTaxonomySchema.optional()
66849
- })), method(object({}), object({ vars: array(NcTemplateVarDescriptorSchema) })), method(NcTemplatePreviewInputSchema, NcTemplatePreviewSchema, {
68338
+ })), method(object({}), object({
68339
+ vars: array(NcTemplateVarDescriptorSchema),
68340
+ /** Per-situation default texts; absent on a hub that predates them. */
68341
+ defaults: array(NcTemplateDefaultSchema)
68342
+ })), method(NcTemplatePreviewInputSchema, NcTemplatePreviewSchema, {
66850
68343
  kind: "mutation",
66851
68344
  access: "view"
66852
68345
  }), method(object({ filter: NcHistoryFilterSchema.default({ limit: 100 }) }), object({ entries: array(NcHistoryEntrySchema) }), { auth: "admin" }), method(object({}), NcRuleLastRunsSchema, { auth: "admin" }), method(object({ artifactId: string().min(1) }), object({ url: string().nullable() }), { auth: "admin" }), method(object({}), object({ snoozes: array(NcSnoozeSchema) }), { caller: "required" }), method(object({ snooze: NcSnoozeInputSchema }), object({ snooze: NcSnoozeSchema }), {
@@ -67742,7 +69235,7 @@ var petFeederCapability = {
67742
69235
  /**
67743
69236
  * Pet water-fountain cap. Models the telemetry and the control surface of a
67744
69237
  * circulating drinking fountain: how much water is in the tank, how much the
67745
- * pet drank, whether the pump runs and on what duty cycle.
69238
+ * pet drank, whether the pump runs.
67746
69239
  *
67747
69240
  * It has no native vendor provider of its own: a fountain reaches CamStack as
67748
69241
  * a container of loose entities (a pump switch, two number boxes, a "filter
@@ -67758,8 +69251,10 @@ var petFeederCapability = {
67758
69251
  * never here. Every reading may be `null`: a source that is offline or does
67759
69252
  * not report is unknown, never zero.
67760
69253
  *
67761
- * The filter is not a field of this cap: it is an item of the `consumables`
67762
- * cap on the same device (kind `wear`), reset by the same forward mechanism.
69254
+ * The pump's on/off duty cycle is model-specific and lives in the optional
69255
+ * `pump-cycle` cap. The filter, the cleaning and the water change are not
69256
+ * fields of this cap: they are items of the `consumables` cap on the same
69257
+ * device (kind `wear`), reset by the same forward mechanism.
67763
69258
  */
67764
69259
  var PetFountainStatusSchema = object({
67765
69260
  /** Water in the tank, 0..100 (%). Null while the source has not reported. */
@@ -67770,27 +69265,20 @@ var PetFountainStatusSchema = object({
67770
69265
  empty: boolean().nullable(),
67771
69266
  /** True while the pump is running. Null while unknown. */
67772
69267
  pumpRunning: boolean().nullable(),
67773
- /** True when the pump works on an on/off duty cycle rather than continuously. */
67774
- pumpIntervalEnabled: boolean().nullable(),
67775
- /** How long the pump runs per cycle, in seconds. */
67776
- pumpOnTime: number().min(0).nullable().meta(readingMeta("duration")),
67777
- /** How long the pump rests per cycle, in seconds. */
67778
- pumpOffTime: number().min(0).nullable().meta(readingMeta("duration")),
67779
69268
  /** Water drunk in the last drink, in litres. */
67780
69269
  lastDrink: number().min(0).nullable().meta(readingMeta("volume")),
67781
69270
  /** Water drunk in the current hour, in litres. */
67782
69271
  currentHourDrink: number().min(0).nullable().meta(readingMeta("volume")),
67783
69272
  /** Water drunk over the last 24 hours (rolling), in litres. */
67784
69273
  last24hDrink: number().min(0).nullable().meta(readingMeta("volume")),
67785
- /** Water drunk since local midnight, in litres. */
69274
+ /** Water drunk since local midnight, in litres. Null when the fountain has no such sensor. */
67786
69275
  todayDrink: number().min(0).nullable().meta(readingMeta("volume")),
67787
69276
  /** Decoded fault message. Null means healthy; a non-null string is an active fault. */
67788
69277
  error: string().nullable(),
67789
69278
  /** Ms epoch when the slice was last refreshed. */
67790
69279
  lastFetchedAt: number()
67791
69280
  });
67792
- var DeviceIdSchema = number().int().nonnegative();
67793
- var MinutesSchema = number().int().min(0);
69281
+ var DeviceIdSchema$1 = number().int().nonnegative();
67794
69282
  var petFountainCapability = {
67795
69283
  name: "pet-fountain",
67796
69284
  scope: "device",
@@ -67800,38 +69288,14 @@ var petFountainCapability = {
67800
69288
  methods: {
67801
69289
  /** Start or stop the pump. */
67802
69290
  setPump: method(object({
67803
- deviceId: DeviceIdSchema,
67804
- on: boolean()
67805
- }), _void(), {
67806
- kind: "mutation",
67807
- auth: "protected"
67808
- }),
67809
- /** Switch the on/off duty cycle on or off (off = the pump runs continuously). */
67810
- setPumpInterval: method(object({
67811
- deviceId: DeviceIdSchema,
69291
+ deviceId: DeviceIdSchema$1,
67812
69292
  on: boolean()
67813
69293
  }), _void(), {
67814
69294
  kind: "mutation",
67815
69295
  auth: "protected"
67816
69296
  }),
67817
- /** Set how many minutes the pump runs per cycle. */
67818
- setPumpOnMinutes: method(object({
67819
- deviceId: DeviceIdSchema,
67820
- minutes: MinutesSchema
67821
- }), _void(), {
67822
- kind: "mutation",
67823
- auth: "protected"
67824
- }),
67825
- /** Set how many minutes the pump rests per cycle. */
67826
- setPumpOffMinutes: method(object({
67827
- deviceId: DeviceIdSchema,
67828
- minutes: MinutesSchema
67829
- }), _void(), {
67830
- kind: "mutation",
67831
- auth: "protected"
67832
- }),
67833
69297
  /** Clear the rolling daily consumption counters on the device. */
67834
- resetDailyConsumption: method(object({ deviceId: DeviceIdSchema }), _void(), {
69298
+ resetDailyConsumption: method(object({ deviceId: DeviceIdSchema$1 }), _void(), {
67835
69299
  kind: "mutation",
67836
69300
  auth: "protected"
67837
69301
  })
@@ -69466,6 +70930,14 @@ var powerMeterCapability = {
69466
70930
  deviceNative: true,
69467
70931
  mode: "singleton",
69468
70932
  deviceTypes: POWER_METER_DEVICE_TYPES,
70933
+ deviceConfig: { ui: {
70934
+ kind: "widget",
70935
+ widgetId: "host/power-meter-line",
70936
+ tab: "power",
70937
+ placement: "hero",
70938
+ label: "Power",
70939
+ order: 4
70940
+ } },
69469
70941
  methods: {},
69470
70942
  status: {
69471
70943
  schema: PowerMeterStatusSchema,
@@ -69525,6 +70997,117 @@ var powerMeterCapability = {
69525
70997
  volatileStateFields: ["lastFetchedAt"],
69526
70998
  customize: powerMeterCustomize
69527
70999
  };
71000
+ var PowerSourceRefusalReasonSchema = _enum([
71001
+ "no-power-source",
71002
+ "switch-missing",
71003
+ "switch-offline",
71004
+ "switch-unknown",
71005
+ "restart-in-progress",
71006
+ "switch-call-failed"
71007
+ ]);
71008
+ var PowerSourceActionResultSchema = discriminatedUnion("accepted", [object({ accepted: literal(true) }), object({
71009
+ accepted: literal(false),
71010
+ reason: PowerSourceRefusalReasonSchema,
71011
+ /** One line for the operator, naming the switch. */
71012
+ message: string()
71013
+ })]);
71014
+ var PowerSourceInfoSchema = object({
71015
+ /** False when the device has no power source linked; the rest is then empty. */
71016
+ linked: boolean(),
71017
+ switchDeviceId: number().nullable(),
71018
+ switchName: string().nullable(),
71019
+ /** The switch's on/off state, or null when it is unknown. Never false for unknown (D393). */
71020
+ switchOn: boolean().nullable(),
71021
+ switchOnline: boolean().nullable(),
71022
+ restartInProgress: boolean(),
71023
+ offSeconds: number().int()
71024
+ });
71025
+ /** The composed slice: the switch state the link mirrors, plus the stored off time. */
71026
+ var PowerSourceStateSchema = object({
71027
+ /** Null while the switch has not reported: unknown is never `false` (D393). */
71028
+ switchOn: boolean().nullable(),
71029
+ offSeconds: number().int(),
71030
+ lastFetchedAt: number()
71031
+ });
71032
+ var POWER_SOURCE_DEVICE_TYPES = [
71033
+ DeviceType.Gateway,
71034
+ DeviceType.Hub,
71035
+ DeviceType.Camera,
71036
+ DeviceType.Sensor,
71037
+ DeviceType.MediaPlayer,
71038
+ DeviceType.Vacuum,
71039
+ DeviceType.Generic,
71040
+ DeviceType.Washer,
71041
+ DeviceType.Dryer,
71042
+ DeviceType.Dishwasher,
71043
+ DeviceType.PetFountain,
71044
+ DeviceType.Fan,
71045
+ DeviceType.Humidifier,
71046
+ DeviceType.Climate,
71047
+ DeviceType.WaterHeater
71048
+ ];
71049
+ var powerSourceCustomize = {
71050
+ version: 1,
71051
+ targets: [{
71052
+ id: "switch",
71053
+ cardinality: "scalar",
71054
+ vocabulary: {
71055
+ cap: "power-source",
71056
+ stateField: "switchOn"
71057
+ },
71058
+ deviceTypes: POWER_SOURCE_DEVICE_TYPES,
71059
+ apply: "add",
71060
+ path: "switchOn",
71061
+ sources: [{
71062
+ kind: "switch",
71063
+ transforms: [{ kind: "identity" }]
71064
+ }],
71065
+ companions: [{
71066
+ kind: "constant",
71067
+ path: "offSeconds",
71068
+ value: 10,
71069
+ when: "add"
71070
+ }, {
71071
+ kind: "clock",
71072
+ path: "lastFetchedAt",
71073
+ when: "always"
71074
+ }],
71075
+ sourceReport: { status: "assignment-status" }
71076
+ }]
71077
+ };
71078
+ var deviceInput$1 = object({ deviceId: number().int().nonnegative() });
71079
+ var powerSourceCapability = {
71080
+ name: "power-source",
71081
+ scope: "device",
71082
+ mode: "singleton",
71083
+ deviceTypes: POWER_SOURCE_DEVICE_TYPES,
71084
+ methods: {
71085
+ getStatus: systemMethod(deviceInput$1, PowerSourceInfoSchema, { auth: "admin" }),
71086
+ powerOn: systemMethod(deviceInput$1, PowerSourceActionResultSchema, {
71087
+ kind: "mutation",
71088
+ auth: "admin"
71089
+ }),
71090
+ powerOff: systemMethod(deviceInput$1, PowerSourceActionResultSchema, {
71091
+ kind: "mutation",
71092
+ auth: "admin"
71093
+ }),
71094
+ forceRestart: systemMethod(deviceInput$1, PowerSourceActionResultSchema, {
71095
+ kind: "mutation",
71096
+ auth: "admin"
71097
+ })
71098
+ },
71099
+ runtimeState: PowerSourceStateSchema,
71100
+ customize: powerSourceCustomize,
71101
+ /**
71102
+ * Runtime-state durability: **session** — mirrored from the linked switch on
71103
+ * its next report; a restored value would outlive the reading it names.
71104
+ *
71105
+ * See `RuntimeStateDurability`. Enforced by
71106
+ * `scripts/check-runtime-state-durability.ts`.
71107
+ */
71108
+ durability: "session",
71109
+ history: "none"
71110
+ };
69528
71111
  /**
69529
71112
  * Presence cap. Models HA `person.*` and `device_tracker.*` entities
69530
71113
  * on `DeviceType.Presence`. Read-only — no setters: presence is
@@ -70164,6 +71747,79 @@ var ptzAutotrackCapability = {
70164
71747
  */
70165
71748
  history: "none"
70166
71749
  };
71750
+ /**
71751
+ * The on/off duty cycle of a pet fountain's pump. Some models run the pump
71752
+ * continuously and have nothing to configure; others can alternate a run time
71753
+ * and a rest time. That is model-specific, so it is its own optional cap on the
71754
+ * fountain device: a fountain without cycle entities simply never composes it
71755
+ * (planning#366), and the `pet-fountain` cap stays the model-independent core.
71756
+ *
71757
+ * Like `pet-fountain` it has no native vendor provider: an operator BUILDS the
71758
+ * cycle from loose entities (a cycle switch and two number boxes) and every
71759
+ * method is a forward to one source entity (D659, D967). Durations are stored
71760
+ * in SECONDS (D944); a number box that cannot be read back leaves them `null`
71761
+ * — unknown, never zero (D393).
71762
+ */
71763
+ var PumpCycleStatusSchema = object({
71764
+ /** True when the pump works on the on/off cycle, false when it runs continuously. Null while unknown. */
71765
+ enabled: boolean().nullable(),
71766
+ /** How long the pump runs per cycle, in seconds. Null while unknown. */
71767
+ onTime: number().min(0).nullable().meta(readingMeta("duration")),
71768
+ /** How long the pump rests per cycle, in seconds. Null while unknown. */
71769
+ offTime: number().min(0).nullable().meta(readingMeta("duration")),
71770
+ /** Ms epoch when the slice was last refreshed. */
71771
+ lastFetchedAt: number()
71772
+ });
71773
+ var DeviceIdSchema = number().int().nonnegative();
71774
+ var MinutesSchema = number().int().min(0);
71775
+ var pumpCycleCapability = {
71776
+ name: "pump-cycle",
71777
+ scope: "device",
71778
+ deviceNative: true,
71779
+ mode: "singleton",
71780
+ deviceTypes: [DeviceType.PetFountain],
71781
+ methods: {
71782
+ /** Switch the on/off duty cycle on or off (off = the pump runs continuously). */
71783
+ setEnabled: method(object({
71784
+ deviceId: DeviceIdSchema,
71785
+ on: boolean()
71786
+ }), _void(), {
71787
+ kind: "mutation",
71788
+ auth: "protected"
71789
+ }),
71790
+ /** Set how many minutes the pump runs per cycle. */
71791
+ setOnMinutes: method(object({
71792
+ deviceId: DeviceIdSchema,
71793
+ minutes: MinutesSchema
71794
+ }), _void(), {
71795
+ kind: "mutation",
71796
+ auth: "protected"
71797
+ }),
71798
+ /** Set how many minutes the pump rests per cycle. */
71799
+ setOffMinutes: method(object({
71800
+ deviceId: DeviceIdSchema,
71801
+ minutes: MinutesSchema
71802
+ }), _void(), {
71803
+ kind: "mutation",
71804
+ auth: "protected"
71805
+ })
71806
+ },
71807
+ status: {
71808
+ schema: PumpCycleStatusSchema,
71809
+ kind: "push"
71810
+ },
71811
+ /** Runtime-state slice — mirrored by the kernel; the hero card reads it whole. */
71812
+ runtimeState: PumpCycleStatusSchema,
71813
+ /**
71814
+ * Runtime-state durability: **session** — live appliance state re-published on connect.
71815
+ *
71816
+ * See `RuntimeStateDurability`. Enforced by
71817
+ * `scripts/check-runtime-state-durability.ts`.
71818
+ */
71819
+ durability: "session",
71820
+ /** History (D850): a duty-cycle setting is not a series worth recording. */
71821
+ history: "none"
71822
+ };
70167
71823
  DeviceType.Camera, DeviceType.Sensor, DeviceType.Switch, DeviceType.Gateway, method(object({ deviceId: number().int().nonnegative() }), object({ success: literal(true) }), {
70168
71824
  kind: "mutation",
70169
71825
  auth: "admin"
@@ -72954,7 +74610,13 @@ var RemoteMediaCommandSchema = _enum([
72954
74610
  "next",
72955
74611
  "previous",
72956
74612
  "setMute",
72957
- "selectSource"
74613
+ "selectSource",
74614
+ "turnOn",
74615
+ "turnOff",
74616
+ "volumeUp",
74617
+ "volumeDown",
74618
+ "channelUp",
74619
+ "channelDown"
72958
74620
  ]);
72959
74621
  /** A send result, or `not-routed`: the role is not bound, so the native cap answers. */
72960
74622
  var RemoteMediaCommandResultSchema = discriminatedUnion("status", [...RemoteSendResultSchema.options, object({ status: literal("not-routed") })]);
@@ -72975,7 +74637,7 @@ method(deviceInput, RemoteConfigSchema, { auth: "admin" }), method(deviceInput.e
72975
74637
  }), RemoteSendResultSchema, {
72976
74638
  kind: "mutation",
72977
74639
  auth: "protected"
72978
- }), method(deviceInput.extend({
74640
+ }), method(deviceInput, MediaPlayerStatusSchema.nullable(), { auth: "protected" }), method(deviceInput.extend({
72979
74641
  command: RemoteMediaCommandSchema,
72980
74642
  muted: boolean().optional(),
72981
74643
  source: string().optional(),
@@ -74156,7 +75818,16 @@ var smokeCapability = {
74156
75818
  * future fields without breaking the existing call sites.
74157
75819
  */
74158
75820
  var EmailAddressSchema = email();
75821
+ /**
75822
+ * Which relay of a multi-relay provider answers (D996). Absent = the provider's first / default
75823
+ * relay, so a caller written before relays existed keeps working unchanged. A provider with one
75824
+ * fixed relay ignores it. This is the integration instance id (`int_NNNN`), NOT the addon id: the
75825
+ * collection pin `addonId` still picks the provider, `instanceId` picks the relay inside it.
75826
+ */
75827
+ var InstanceIdSchema = string().min(1).optional();
75828
+ var RelayPinSchema = object({ instanceId: InstanceIdSchema });
74159
75829
  var SendEmailInputSchema = object({
75830
+ instanceId: InstanceIdSchema,
74160
75831
  to: union([EmailAddressSchema, array(EmailAddressSchema).min(1)]),
74161
75832
  cc: array(EmailAddressSchema).optional(),
74162
75833
  bcc: array(EmailAddressSchema).optional(),
@@ -74192,11 +75863,11 @@ method(SendEmailInputSchema, SendEmailResultSchema, {
74192
75863
  kind: "mutation",
74193
75864
  auth: "admin",
74194
75865
  access: "create"
74195
- }), method(_void(), SmtpStatusSchema, {
75866
+ }), method(RelayPinSchema, SmtpStatusSchema, {
74196
75867
  kind: "mutation",
74197
75868
  auth: "admin",
74198
75869
  access: "view"
74199
- }), method(_void(), SmtpStatusSchema, { auth: "admin" });
75870
+ }), method(RelayPinSchema, SmtpStatusSchema, { auth: "admin" });
74200
75871
  /**
74201
75872
  * A single device snapshot returned as base64 JPEG/PNG.
74202
75873
  *
@@ -74228,10 +75899,12 @@ DeviceType.Camera, method(object({
74228
75899
  * even when the cache is well within the device's
74229
75900
  * `snapshotMaxAgeS` window.
74230
75901
  *
74231
- * **`force` is an OPERATOR signal, not a freshness preference.** On a
75902
+ * **`force` is a demand with a named principal, not a freshness
75903
+ * preference** — an operator button, the scheduled refresh (D847), or a
75904
+ * notification rule that left the camera's wake allowed (D998). On a
74232
75905
  * battery camera it is the one thing that walks past the wrapper's
74233
- * sleep gate and wakes the camera, so a background caller — a poller,
74234
- * an event handler, a thumbnail — must NEVER set it. Every such caller
75906
+ * sleep gate and wakes the camera, so a poller, a thumbnail or a
75907
+ * prestream must NEVER set it. Every such caller
74235
75908
  * gets the cached frame, which on a sleeping battery camera is the
74236
75909
  * correct answer: stale but honest beats woken.
74237
75910
  */
@@ -75210,7 +76883,11 @@ listSignals: method(_void(), array(StreamSignalSchema).readonly()) }
75210
76883
  * `getSettingsUISchema()` surface.
75211
76884
  */
75212
76885
  var SwitchStatusSchema = object({
75213
- on: boolean().meta({ label: "On" }),
76886
+ /**
76887
+ * `null` = the device has never reported its state (a measurement that
76888
+ * has not happened is unknown, never `false`).
76889
+ */
76890
+ on: boolean().nullable().meta({ label: "On" }),
75214
76891
  /** Ms epoch of the last state change. Useful for UI "X minutes ago". */
75215
76892
  lastChangedAt: number()
75216
76893
  });
@@ -75235,7 +76912,7 @@ var switchCapability = {
75235
76912
  }) },
75236
76913
  events: { onStateChanged: { data: object({
75237
76914
  deviceId: number(),
75238
- on: boolean(),
76915
+ on: boolean().nullable(),
75239
76916
  lastChangedAt: number()
75240
76917
  }) } },
75241
76918
  status: {
@@ -75801,6 +77478,40 @@ var LoggingSettingsStateSchema = object({
75801
77478
  opsLogRetentionDays: number().int().min(0),
75802
77479
  persisted: boolean()
75803
77480
  });
77481
+ /**
77482
+ * Debug WATCH — a short, per-device window over `debug.<channel>` lines.
77483
+ *
77484
+ * `start` opens (or re-arms) a 10 minute window; `rearm` extends a LIVE one
77485
+ * and never revives a lapsed one; `stop` closes it; `list` only reads. No
77486
+ * chain of re-arms outlives 60 minutes from the first start. The hub holds the
77487
+ * watches in memory and pushes the interest to every node, so a watch lapses
77488
+ * by itself and survives nothing — a restart is a stop.
77489
+ */
77490
+ var DebugWatchInputSchema = object({
77491
+ action: _enum([
77492
+ "list",
77493
+ "start",
77494
+ "rearm",
77495
+ "stop"
77496
+ ]),
77497
+ /** Full channel names, `debug.<channel>`, each declared with `kind: 'debug'`. */
77498
+ channels: array(string().min(1)).readonly().default([]),
77499
+ /** Numeric device ids. Required (non-empty) for `start`. */
77500
+ deviceIds: array(number().int()).readonly().default([])
77501
+ });
77502
+ var DebugWatchStateSchema = object({
77503
+ channel: string(),
77504
+ deviceIds: array(number().int()).readonly(),
77505
+ startedAtMs: number(),
77506
+ untilMs: number(),
77507
+ capAtMs: number()
77508
+ });
77509
+ var DebugWatchResultSchema = object({
77510
+ nowMs: number(),
77511
+ watches: array(DebugWatchStateSchema).readonly(),
77512
+ /** Channels a `rearm` found already lapsed: nothing was revived. */
77513
+ lapsed: array(string()).readonly()
77514
+ });
75804
77515
  method(_void(), SystemInfoSchema), method(_void(), HealthStatusSchema), method(_void(), FeatureManifestSchema), method(_void(), array(NetworkAddressSchema).readonly()), method(_void(), unknown().nullable(), { auth: "admin" }), method(record(string(), unknown()), _null(), {
75805
77516
  kind: "mutation",
75806
77517
  auth: "admin"
@@ -75816,6 +77527,9 @@ method(_void(), SystemInfoSchema), method(_void(), HealthStatusSchema), method(_
75816
77527
  }), method(_void(), RequestCensusStatusSchema, { auth: "admin" }), method(_void(), array(ReportedLoadContributionSchema).readonly(), { auth: "admin" }), method(_void(), array(ReportedFailureContributionSchema).readonly(), { auth: "admin" }), method(GetLoggingSettingsInputSchema, LoggingSettingsStateSchema, { auth: "admin" }), method(SetLoggingSettingsInputSchema, LoggingSettingsStateSchema, {
75817
77528
  kind: "mutation",
75818
77529
  auth: "admin"
77530
+ }), method(DebugWatchInputSchema, DebugWatchResultSchema, {
77531
+ kind: "mutation",
77532
+ auth: "admin"
75819
77533
  });
75820
77534
  /**
75821
77535
  * Tamper / case-open detection sensor. Drives Home Assistant
@@ -78847,6 +80561,26 @@ function buildDescriptor(capName, kind) {
78847
80561
  * contributes one entry per bound cap present in this map.
78848
80562
  */
78849
80563
  var EVENT_KIND_BY_CAP = Object.freeze(Object.fromEntries(Object.entries(CAP_TO_KIND).map(([capName, kind]) => [capName, buildDescriptor(capName, kind)])));
80564
+ /**
80565
+ * What a remote key is CALLED and what it LOOKS like, for every role (D963),
80566
+ * shared by the admin UI and the viewer. A role is data on the wire; each
80567
+ * client resolves its name from `label` (English and Italian side by side) and
80568
+ * its glyph from `icon`, a lucide id from the shared icon catalogue — the
80569
+ * server sends an id, a client maps it to its own icon set.
80570
+ *
80571
+ * `legend` is text printed on the key INSTEAD of a glyph (a digit has no
80572
+ * pictogram): a client that can draw text shows it, one that cannot falls back
80573
+ * to `icon`.
80574
+ */
80575
+ function digit(n) {
80576
+ return {
80577
+ label: t(n, n),
80578
+ icon: "hash",
80579
+ legend: n
80580
+ };
80581
+ }
80582
+ digit("0"), digit("1"), digit("2"), digit("3"), digit("4"), digit("5"), digit("6"), digit("7"), digit("8"), digit("9");
80583
+ DeviceFeature.MediaPlayerPower, DeviceFeature.MediaPlayerVolumeStep, DeviceFeature.MediaPlayerChannelStep, DeviceFeature.MediaPlayerMute, DeviceFeature.MediaPlayerStop, DeviceFeature.MediaPlayerNext, DeviceFeature.MediaPlayerPrevious;
78850
80584
  var btn = (idSuffix, row, col, init) => ({
78851
80585
  idSuffix,
78852
80586
  row,
@@ -78973,7 +80707,35 @@ discriminatedUnion("kind", [object({
78973
80707
  kind: literal("pronto"),
78974
80708
  code: string()
78975
80709
  })]);
78976
- DeviceFeature.FanSpeed, DeviceFeature.FanPreset, DeviceFeature.FanDirection, DeviceFeature.FanOscillating, DeviceFeature.CoverPositionable, DeviceFeature.CoverTilt, DeviceFeature.ValvePositionable, DeviceFeature.MediaPlayerVolume, DeviceFeature.ClimateFanMode;
80710
+ /**
80711
+ * Propose a running threshold from a device's own power history (planning#405).
80712
+ *
80713
+ * Pure and deterministic: the same series gives the same answer. The series is
80714
+ * a HELD-VALUE step series — a point's value stands until the next point — which
80715
+ * is how device-history stores a gauge, so "time at a level" is exact, not a
80716
+ * count of samples.
80717
+ *
80718
+ * 1. idle floor F = time-weighted median; noise ceiling N = highest value seen
80719
+ * near F. A device that is not near one level most of the time has no floor.
80720
+ * 2. coarse activity = above max(2N, N + 5 W); consecutive stretches are episodes.
80721
+ * 3. gaps between episodes split in two by the largest log-scale jump (>= 3x):
80722
+ * the short ones are pauses INSIDE a run (a soak), the long ones separate runs.
80723
+ * 4. T = geometric mean of N and the plateau's 10th percentile, snapped to a
80724
+ * grid a person would type; stop dwell covers the longest pause; start dwell
80725
+ * covers the longest standby blip above T.
80726
+ * 5. the numbers are proved by REPLAY through the real `dwell` evaluation: each
80727
+ * run must hold exactly one true interval and nothing may flap outside.
80728
+ */
80729
+ var SECOND_MS = 1e3;
80730
+ var MINUTE_MS$1 = 60 * SECOND_MS;
80731
+ 24 * (60 * MINUTE_MS$1);
80732
+ 10 * MINUTE_MS$1;
80733
+ 30 * SECOND_MS;
80734
+ 60 * SECOND_MS;
80735
+ 20 * MINUTE_MS$1;
80736
+ 10 * SECOND_MS;
80737
+ 10 * SECOND_MS;
80738
+ DeviceFeature.FanSpeed, DeviceFeature.FanPreset, DeviceFeature.FanDirection, DeviceFeature.FanOscillating, DeviceFeature.CoverStoppable, DeviceFeature.CoverPositionable, DeviceFeature.CoverTilt, DeviceFeature.ValvePositionable, DeviceFeature.MediaPlayerVolume, DeviceFeature.ClimateFanMode;
78977
80739
  SOURCE_CAPS.filter((cap) => cap !== "switch" && cap !== "motion");
78978
80740
  String.raw`rose\(active(\d+), changed(\d+), (\d+(?:\.\d+)?)\)`;
78979
80741
  DeviceRole.BinarySensor, DeviceRole.MotionSensor;
@@ -79333,6 +81095,7 @@ var DEVICE_LOCAL_STATE_CAPS = {
79333
81095
  pressureSensor: pressureSensorCapability,
79334
81096
  privacyMask: privacyMaskCapability,
79335
81097
  ptzAutotrack: ptzAutotrackCapability,
81098
+ pumpCycle: pumpCycleCapability,
79336
81099
  recordingOnboard: recordingOnboardCapability,
79337
81100
  recordingSignal: recordingSignalCapability,
79338
81101
  runningState: runningStateCapability,
@@ -81517,6 +83280,27 @@ Object.freeze({
81517
83280
  access: "view",
81518
83281
  role: "viewer"
81519
83282
  },
83283
+ "boardKeySource.getBoardKey": {
83284
+ capName: "board-key-source",
83285
+ capScope: "system",
83286
+ addonId: null,
83287
+ access: "view",
83288
+ role: "admin"
83289
+ },
83290
+ "boardKeySource.listBoards": {
83291
+ capName: "board-key-source",
83292
+ capScope: "system",
83293
+ addonId: null,
83294
+ access: "view",
83295
+ role: "admin"
83296
+ },
83297
+ "boardKeySource.listSources": {
83298
+ capName: "board-key-source",
83299
+ capScope: "system",
83300
+ addonId: null,
83301
+ access: "view",
83302
+ role: "admin"
83303
+ },
81520
83304
  "brightness.getStatus": {
81521
83305
  capName: "brightness",
81522
83306
  capScope: "device",
@@ -82056,6 +83840,13 @@ Object.freeze({
82056
83840
  access: "create",
82057
83841
  role: "admin"
82058
83842
  },
83843
+ "coreBlocks.proposeRunningThreshold": {
83844
+ capName: "core-blocks",
83845
+ capScope: "system",
83846
+ addonId: null,
83847
+ access: "view",
83848
+ role: "admin"
83849
+ },
82059
83850
  "coreBlocks.reportAutomationRun": {
82060
83851
  capName: "core-blocks",
82061
83852
  capScope: "system",
@@ -82567,6 +84358,13 @@ Object.freeze({
82567
84358
  access: "view",
82568
84359
  role: "admin"
82569
84360
  },
84361
+ "deviceExport.listInstances": {
84362
+ capName: "device-export",
84363
+ capScope: "system",
84364
+ addonId: null,
84365
+ access: "view",
84366
+ role: "admin"
84367
+ },
82570
84368
  "deviceExport.listSupportedDeviceKinds": {
82571
84369
  capName: "device-export",
82572
84370
  capScope: "system",
@@ -82854,6 +84652,13 @@ Object.freeze({
82854
84652
  access: "view",
82855
84653
  role: "admin"
82856
84654
  },
84655
+ "deviceManager.dismissDiscoveryProposal": {
84656
+ capName: "device-manager",
84657
+ capScope: "system",
84658
+ addonId: null,
84659
+ access: "create",
84660
+ role: "admin"
84661
+ },
82857
84662
  "deviceManager.enable": {
82858
84663
  capName: "device-manager",
82859
84664
  capScope: "system",
@@ -83036,6 +84841,13 @@ Object.freeze({
83036
84841
  access: "view",
83037
84842
  role: "viewer"
83038
84843
  },
84844
+ "deviceManager.listDiscoveryProposals": {
84845
+ capName: "device-manager",
84846
+ capScope: "system",
84847
+ addonId: null,
84848
+ access: "view",
84849
+ role: "admin"
84850
+ },
83039
84851
  "deviceManager.listLocationDescriptions": {
83040
84852
  capName: "device-manager",
83041
84853
  capScope: "system",
@@ -83190,6 +85002,13 @@ Object.freeze({
83190
85002
  access: "create",
83191
85003
  role: "admin"
83192
85004
  },
85005
+ "deviceManager.reportDiscoveryObservations": {
85006
+ capName: "device-manager",
85007
+ capScope: "system",
85008
+ addonId: null,
85009
+ access: "create",
85010
+ role: "admin"
85011
+ },
83193
85012
  "deviceManager.runDeviceAction": {
83194
85013
  capName: "device-manager",
83195
85014
  capScope: "system",
@@ -83197,6 +85016,13 @@ Object.freeze({
83197
85016
  access: "create",
83198
85017
  role: "admin"
83199
85018
  },
85019
+ "deviceManager.runDiscoverySweep": {
85020
+ capName: "device-manager",
85021
+ capScope: "system",
85022
+ addonId: null,
85023
+ access: "create",
85024
+ role: "admin"
85025
+ },
83200
85026
  "deviceManager.setChildLayout": {
83201
85027
  capName: "device-manager",
83202
85028
  capScope: "system",
@@ -84128,6 +85954,76 @@ Object.freeze({
84128
85954
  access: "create",
84129
85955
  role: "admin"
84130
85956
  },
85957
+ "integrationInstances.createInstance": {
85958
+ capName: "integration-instances",
85959
+ capScope: "system",
85960
+ addonId: null,
85961
+ access: "create",
85962
+ role: "admin"
85963
+ },
85964
+ "integrationInstances.deleteInstance": {
85965
+ capName: "integration-instances",
85966
+ capScope: "system",
85967
+ addonId: null,
85968
+ access: "delete",
85969
+ role: "admin"
85970
+ },
85971
+ "integrationInstances.describe": {
85972
+ capName: "integration-instances",
85973
+ capScope: "system",
85974
+ addonId: null,
85975
+ access: "view",
85976
+ role: "admin"
85977
+ },
85978
+ "integrationInstances.getInstance": {
85979
+ capName: "integration-instances",
85980
+ capScope: "system",
85981
+ addonId: null,
85982
+ access: "view",
85983
+ role: "admin"
85984
+ },
85985
+ "integrationInstances.instanceFormSchema": {
85986
+ capName: "integration-instances",
85987
+ capScope: "system",
85988
+ addonId: null,
85989
+ access: "view",
85990
+ role: "admin"
85991
+ },
85992
+ "integrationInstances.listInstances": {
85993
+ capName: "integration-instances",
85994
+ capScope: "system",
85995
+ addonId: null,
85996
+ access: "view",
85997
+ role: "admin"
85998
+ },
85999
+ "integrationInstances.setInstanceEnabled": {
86000
+ capName: "integration-instances",
86001
+ capScope: "system",
86002
+ addonId: null,
86003
+ access: "create",
86004
+ role: "admin"
86005
+ },
86006
+ "integrationInstances.testInstance": {
86007
+ capName: "integration-instances",
86008
+ capScope: "system",
86009
+ addonId: null,
86010
+ access: "create",
86011
+ role: "admin"
86012
+ },
86013
+ "integrationInstances.updateInstance": {
86014
+ capName: "integration-instances",
86015
+ capScope: "system",
86016
+ addonId: null,
86017
+ access: "create",
86018
+ role: "admin"
86019
+ },
86020
+ "integrations.clearSettings": {
86021
+ capName: "integrations",
86022
+ capScope: "system",
86023
+ addonId: null,
86024
+ access: "delete",
86025
+ role: "admin"
86026
+ },
84131
86027
  "integrations.create": {
84132
86028
  capName: "integrations",
84133
86029
  capScope: "system",
@@ -84912,6 +86808,20 @@ Object.freeze({
84912
86808
  access: "view",
84913
86809
  role: "admin"
84914
86810
  },
86811
+ "mediaPlayer.channelDown": {
86812
+ capName: "media-player",
86813
+ capScope: "device",
86814
+ addonId: null,
86815
+ access: "create",
86816
+ role: "viewer"
86817
+ },
86818
+ "mediaPlayer.channelUp": {
86819
+ capName: "media-player",
86820
+ capScope: "device",
86821
+ addonId: null,
86822
+ access: "create",
86823
+ role: "viewer"
86824
+ },
84915
86825
  "mediaPlayer.getStatus": {
84916
86826
  capName: "media-player",
84917
86827
  capScope: "device",
@@ -85003,6 +86913,34 @@ Object.freeze({
85003
86913
  access: "create",
85004
86914
  role: "viewer"
85005
86915
  },
86916
+ "mediaPlayer.turnOff": {
86917
+ capName: "media-player",
86918
+ capScope: "device",
86919
+ addonId: null,
86920
+ access: "create",
86921
+ role: "viewer"
86922
+ },
86923
+ "mediaPlayer.turnOn": {
86924
+ capName: "media-player",
86925
+ capScope: "device",
86926
+ addonId: null,
86927
+ access: "create",
86928
+ role: "viewer"
86929
+ },
86930
+ "mediaPlayer.volumeDown": {
86931
+ capName: "media-player",
86932
+ capScope: "device",
86933
+ addonId: null,
86934
+ access: "create",
86935
+ role: "viewer"
86936
+ },
86937
+ "mediaPlayer.volumeUp": {
86938
+ capName: "media-player",
86939
+ capScope: "device",
86940
+ addonId: null,
86941
+ access: "create",
86942
+ role: "viewer"
86943
+ },
85006
86944
  "meshNetwork.getStatus": {
85007
86945
  capName: "mesh-network",
85008
86946
  capScope: "system",
@@ -86249,27 +88187,6 @@ Object.freeze({
86249
88187
  access: "create",
86250
88188
  role: "viewer"
86251
88189
  },
86252
- "petFountain.setPumpInterval": {
86253
- capName: "pet-fountain",
86254
- capScope: "device",
86255
- addonId: null,
86256
- access: "create",
86257
- role: "viewer"
86258
- },
86259
- "petFountain.setPumpOffMinutes": {
86260
- capName: "pet-fountain",
86261
- capScope: "device",
86262
- addonId: null,
86263
- access: "create",
86264
- role: "viewer"
86265
- },
86266
- "petFountain.setPumpOnMinutes": {
86267
- capName: "pet-fountain",
86268
- capScope: "device",
86269
- addonId: null,
86270
- access: "create",
86271
- role: "viewer"
86272
- },
86273
88190
  "pipelineAnalytics.addRetrainFrameFromRecording": {
86274
88191
  capName: "pipeline-analytics",
86275
88192
  capScope: "device",
@@ -88048,6 +89965,34 @@ Object.freeze({
88048
89965
  access: "create",
88049
89966
  role: "admin"
88050
89967
  },
89968
+ "pumpCycle.getStatus": {
89969
+ capName: "pump-cycle",
89970
+ capScope: "device",
89971
+ addonId: null,
89972
+ access: "view",
89973
+ role: "viewer"
89974
+ },
89975
+ "pumpCycle.setEnabled": {
89976
+ capName: "pump-cycle",
89977
+ capScope: "device",
89978
+ addonId: null,
89979
+ access: "create",
89980
+ role: "viewer"
89981
+ },
89982
+ "pumpCycle.setOffMinutes": {
89983
+ capName: "pump-cycle",
89984
+ capScope: "device",
89985
+ addonId: null,
89986
+ access: "create",
89987
+ role: "viewer"
89988
+ },
89989
+ "pumpCycle.setOnMinutes": {
89990
+ capName: "pump-cycle",
89991
+ capScope: "device",
89992
+ addonId: null,
89993
+ access: "create",
89994
+ role: "viewer"
89995
+ },
88051
89996
  "reboot.reboot": {
88052
89997
  capName: "reboot",
88053
89998
  capScope: "device",
@@ -88552,6 +90497,13 @@ Object.freeze({
88552
90497
  access: "create",
88553
90498
  role: "admin"
88554
90499
  },
90500
+ "remote.getAssumedStatus": {
90501
+ capName: "remote",
90502
+ capScope: "system",
90503
+ addonId: null,
90504
+ access: "view",
90505
+ role: "admin"
90506
+ },
88555
90507
  "remote.getConfig": {
88556
90508
  capName: "remote",
88557
90509
  capScope: "system",
@@ -89784,6 +91736,13 @@ Object.freeze({
89784
91736
  access: "create",
89785
91737
  role: "viewer"
89786
91738
  },
91739
+ "system.debugWatch": {
91740
+ capName: "system",
91741
+ capScope: "system",
91742
+ addonId: null,
91743
+ access: "create",
91744
+ role: "admin"
91745
+ },
89787
91746
  "system.detectSiteLocation": {
89788
91747
  capName: "system",
89789
91748
  capScope: "system",
@@ -91360,6 +93319,11 @@ Object.freeze({
91360
93319
  form: "single",
91361
93320
  optional: false
91362
93321
  }],
93322
+ "coreBlocks.proposeRunningThreshold": [{
93323
+ name: "deviceId",
93324
+ form: "single",
93325
+ optional: false
93326
+ }],
91363
93327
  "cover.close": [{
91364
93328
  name: "deviceId",
91365
93329
  form: "single",
@@ -92211,6 +94175,16 @@ Object.freeze({
92211
94175
  form: "single",
92212
94176
  optional: true
92213
94177
  }],
94178
+ "mediaPlayer.channelDown": [{
94179
+ name: "deviceId",
94180
+ form: "single",
94181
+ optional: false
94182
+ }],
94183
+ "mediaPlayer.channelUp": [{
94184
+ name: "deviceId",
94185
+ form: "single",
94186
+ optional: false
94187
+ }],
92214
94188
  "mediaPlayer.getStatus": [{
92215
94189
  name: "deviceId",
92216
94190
  form: "single",
@@ -92276,6 +94250,26 @@ Object.freeze({
92276
94250
  form: "single",
92277
94251
  optional: false
92278
94252
  }],
94253
+ "mediaPlayer.turnOff": [{
94254
+ name: "deviceId",
94255
+ form: "single",
94256
+ optional: false
94257
+ }],
94258
+ "mediaPlayer.turnOn": [{
94259
+ name: "deviceId",
94260
+ form: "single",
94261
+ optional: false
94262
+ }],
94263
+ "mediaPlayer.volumeDown": [{
94264
+ name: "deviceId",
94265
+ form: "single",
94266
+ optional: false
94267
+ }],
94268
+ "mediaPlayer.volumeUp": [{
94269
+ name: "deviceId",
94270
+ form: "single",
94271
+ optional: false
94272
+ }],
92279
94273
  "meter.getStatus": [{
92280
94274
  name: "deviceId",
92281
94275
  form: "single",
@@ -92585,21 +94579,6 @@ Object.freeze({
92585
94579
  form: "single",
92586
94580
  optional: false
92587
94581
  }],
92588
- "petFountain.setPumpInterval": [{
92589
- name: "deviceId",
92590
- form: "single",
92591
- optional: false
92592
- }],
92593
- "petFountain.setPumpOffMinutes": [{
92594
- name: "deviceId",
92595
- form: "single",
92596
- optional: false
92597
- }],
92598
- "petFountain.setPumpOnMinutes": [{
92599
- name: "deviceId",
92600
- form: "single",
92601
- optional: false
92602
- }],
92603
94582
  "pipelineAnalytics.addRetrainFrameFromRecording": [{
92604
94583
  name: "deviceId",
92605
94584
  form: "single",
@@ -93235,6 +95214,26 @@ Object.freeze({
93235
95214
  form: "single",
93236
95215
  optional: false
93237
95216
  }],
95217
+ "pumpCycle.getStatus": [{
95218
+ name: "deviceId",
95219
+ form: "single",
95220
+ optional: false
95221
+ }],
95222
+ "pumpCycle.setEnabled": [{
95223
+ name: "deviceId",
95224
+ form: "single",
95225
+ optional: false
95226
+ }],
95227
+ "pumpCycle.setOffMinutes": [{
95228
+ name: "deviceId",
95229
+ form: "single",
95230
+ optional: false
95231
+ }],
95232
+ "pumpCycle.setOnMinutes": [{
95233
+ name: "deviceId",
95234
+ form: "single",
95235
+ optional: false
95236
+ }],
93238
95237
  "reboot.reboot": [{
93239
95238
  name: "deviceId",
93240
95239
  form: "single",
@@ -93436,6 +95435,11 @@ Object.freeze({
93436
95435
  form: "single",
93437
95436
  optional: true
93438
95437
  }],
95438
+ "remote.getAssumedStatus": [{
95439
+ name: "deviceId",
95440
+ form: "single",
95441
+ optional: false
95442
+ }],
93439
95443
  "remote.getConfig": [{
93440
95444
  name: "deviceId",
93441
95445
  form: "single",
@@ -93702,6 +95706,11 @@ Object.freeze({
93702
95706
  form: "single",
93703
95707
  optional: false
93704
95708
  }],
95709
+ "system.debugWatch": [{
95710
+ name: "deviceIds",
95711
+ form: "array",
95712
+ optional: true
95713
+ }],
93705
95714
  "tamper.getStatus": [{
93706
95715
  name: "deviceId",
93707
95716
  form: "single",
@@ -93978,99 +95987,6 @@ Object.freeze({
93978
95987
  "network-access": "ingress",
93979
95988
  "smtp-provider": "email"
93980
95989
  });
93981
- /**
93982
- * A saved Customize assignment (D936). The schema is the type: callers use
93983
- * `z.infer`, they do not restate the shape.
93984
- */
93985
- var OverrideSourceSchema = object({
93986
- addonId: string().min(1),
93987
- stableId: string().min(1),
93988
- cap: string().min(1),
93989
- fieldPath: string().min(1)
93990
- });
93991
- var CustomizeTransformDraftSchema = discriminatedUnion("kind", [
93992
- object({ kind: literal("identity") }),
93993
- object({ kind: literal("invert") }),
93994
- object({
93995
- kind: literal("threshold"),
93996
- comparison: _enum(["gte", "lte"]),
93997
- threshold: number(),
93998
- startDwellMs: number().nonnegative(),
93999
- stopDwellMs: number().nonnegative()
94000
- }),
94001
- object({
94002
- kind: literal("linear"),
94003
- scale: number(),
94004
- offset: number(),
94005
- clampMin: number().optional(),
94006
- clampMax: number().optional()
94007
- }),
94008
- object({
94009
- kind: literal("enum-map"),
94010
- mapping: record(string(), string().nullable())
94011
- }),
94012
- object({ kind: literal("number") })
94013
- ]);
94014
- var ScalarOverrideDraftSchema = object({
94015
- kind: literal("scalar"),
94016
- cap: string().min(1),
94017
- targetId: string().min(1),
94018
- source: OverrideSourceSchema,
94019
- transform: CustomizeTransformDraftSchema
94020
- });
94021
- var KeyedArrayOverrideDraftSchema = object({
94022
- kind: literal("keyedArray"),
94023
- cap: string().min(1),
94024
- targetId: string().min(1),
94025
- key: string().min(1),
94026
- label: string().min(1),
94027
- fieldPath: string().min(1),
94028
- source: OverrideSourceSchema,
94029
- transform: CustomizeTransformDraftSchema
94030
- });
94031
- var PulseOverrideDraftSchema = object({
94032
- kind: literal("pulse"),
94033
- cap: string().min(1),
94034
- targetId: string().min(1),
94035
- enabled: boolean(),
94036
- debounceMs: number().nonnegative(),
94037
- edges: array(_enum([
94038
- "rising",
94039
- "button",
94040
- "native-event"
94041
- ])).min(1).optional(),
94042
- sources: array(OverrideSourceSchema).min(1)
94043
- });
94044
- var SpanSourceDraftSchema = OverrideSourceSchema.extend({ mode: _enum([
94045
- "in-addition",
94046
- "confirm",
94047
- "replace"
94048
- ]).optional() });
94049
- discriminatedUnion("kind", [
94050
- ScalarOverrideDraftSchema,
94051
- KeyedArrayOverrideDraftSchema,
94052
- PulseOverrideDraftSchema,
94053
- object({
94054
- kind: literal("span"),
94055
- cap: string().min(1),
94056
- targetId: string().min(1),
94057
- timeoutMs: number().nonnegative(),
94058
- cooldownMs: number().nonnegative().optional(),
94059
- sources: array(SpanSourceDraftSchema)
94060
- })
94061
- ]);
94062
- object({
94063
- targetId: string().min(1),
94064
- configured: boolean(),
94065
- source: _enum(["native", "assigned"]),
94066
- state: _enum([
94067
- "active",
94068
- "stale",
94069
- "released",
94070
- "unavailable"
94071
- ]),
94072
- reason: string().nullable()
94073
- });
94074
95990
  var G711_SCALE_CORRECTION_DB = {
94075
95991
  PCMU: 20 * Math.log10(4),
94076
95992
  PCMA: 20 * Math.log10(8)
@@ -94686,6 +96602,7 @@ var STATE_SUMMARY_VARS = [
94686
96602
  [...RULE_TEXT],
94687
96603
  ([...RULE_TEXT], [...DEVICE_EVENTS]),
94688
96604
  ([...RULE_TEXT], [...COMBINED_ALARM]),
96605
+ ([...RULE_TEXT], [...COMBINED_ALARM]),
94689
96606
  ([...RULE_TEXT], [...DEVICE_EVENTS]),
94690
96607
  ([...RULE_TEXT], [...BATTERY, ...CONSUMABLE]),
94691
96608
  ([...RULE_TEXT], [...CONSUMABLE]),
@@ -119582,6 +121499,83 @@ function buildCcuOverviewHandlers(deps) {
119582
121499
  };
119583
121500
  }
119584
121501
  //#endregion
121502
+ //#region src/custom-actions.ts
121503
+ /**
121504
+ * Custom actions of the Homematic addon: the LAN scan behind the integration
121505
+ * form's CCU picker, and the CCU management page (`provider-homematic` admin
121506
+ * page). Reads are `query`; every CCU write is a `mutation` whose input carries
121507
+ * the operator's `confirmed` flag.
121508
+ */
121509
+ var homematicActions = defineCustomActions({
121510
+ discoverCcu: customAction(object({}), object({
121511
+ hosts: array(object({
121512
+ host: string(),
121513
+ name: string(),
121514
+ id: string()
121515
+ })),
121516
+ summary: string()
121517
+ }), {
121518
+ kind: "mutation",
121519
+ auth: "admin"
121520
+ }),
121521
+ listCcus: customAction(object({}), array(CcuListItemSchema), {
121522
+ kind: "query",
121523
+ auth: "admin"
121524
+ }),
121525
+ ccuOverview: customAction(IntegrationRefSchema, CcuOverviewSchema, {
121526
+ kind: "query",
121527
+ auth: "admin"
121528
+ }),
121529
+ listServiceMessages: customAction(IntegrationRefSchema, ServiceMessagesResultSchema, {
121530
+ kind: "query",
121531
+ auth: "admin"
121532
+ }),
121533
+ listCcuDevices: customAction(IntegrationRefSchema, CcuDevicesResultSchema, {
121534
+ kind: "query",
121535
+ auth: "admin"
121536
+ }),
121537
+ listHeatingGroups: customAction(IntegrationRefSchema, HeatingOverviewSchema, {
121538
+ kind: "query",
121539
+ auth: "admin"
121540
+ }),
121541
+ createHeatingGroup: customAction(CreateGroupInputSchema, HeatingGroupSchema, {
121542
+ kind: "mutation",
121543
+ auth: "admin"
121544
+ }),
121545
+ updateHeatingGroup: customAction(UpdateGroupInputSchema, HeatingGroupSchema, {
121546
+ kind: "mutation",
121547
+ auth: "admin"
121548
+ }),
121549
+ deleteHeatingGroup: customAction(DeleteGroupInputSchema, OkResultSchema, {
121550
+ kind: "mutation",
121551
+ auth: "admin"
121552
+ }),
121553
+ ccuPairingStatus: customAction(IntegrationRefSchema, PairingStatusSchema, {
121554
+ kind: "query",
121555
+ auth: "admin"
121556
+ }),
121557
+ setCcuInstallMode: customAction(SetInstallModeInputSchema, OkResultSchema, {
121558
+ kind: "mutation",
121559
+ auth: "admin"
121560
+ }),
121561
+ deleteCcuDevice: customAction(DeleteCcuDeviceInputSchema, OkResultSchema, {
121562
+ kind: "mutation",
121563
+ auth: "admin"
121564
+ }),
121565
+ getCcuDeviceConfig: customAction(DeviceRefSchema, DeviceConfigSchema, {
121566
+ kind: "query",
121567
+ auth: "admin"
121568
+ }),
121569
+ setCcuChannelConfig: customAction(SetChannelConfigInputSchema, OkResultSchema, {
121570
+ kind: "mutation",
121571
+ auth: "admin"
121572
+ }),
121573
+ acknowledgeServiceMessage: customAction(AcknowledgeInputSchema, OkResultSchema, {
121574
+ kind: "mutation",
121575
+ auth: "admin"
121576
+ })
121577
+ });
121578
+ //#endregion
119585
121579
  //#region src/callback-host.ts
119586
121580
  /**
119587
121581
  * Pick the hub LAN IPv4 a CCU at `ccuHost` can call back to. Prefers an
@@ -119848,83 +121842,170 @@ function buildConnectionFormSchema() {
119848
121842
  }
119849
121843
  ] };
119850
121844
  }
121845
+ var homematicConnectionsEntryKind = defineEntryKind("connections", {
121846
+ title: "Homematic CCUs",
121847
+ schema: entryBody({
121848
+ host: string().nullish(),
121849
+ enableHmipRf: boolean().nullish(),
121850
+ enableBidcosRf: boolean().nullish(),
121851
+ enableGroups: boolean().nullish(),
121852
+ enableBidcosWired: boolean().nullish(),
121853
+ username: string().nullish(),
121854
+ password: string().optional().meta({ secret: true }),
121855
+ callbackHost: string().nullish(),
121856
+ callbackPort: number().int().min(1).max(65535).nullish(),
121857
+ tls: boolean().nullish()
121858
+ }),
121859
+ writeTrigger: "an operator adds, edits or removes a Homematic CCU"
121860
+ });
121861
+ /** Every kind this addon declares, keyed by its name. */
121862
+ var homematicRecordKinds = { connections: homematicConnectionsEntryKind };
121863
+ /** The record body as the flat settings the connection schema parses: no name, no unset keys. */
121864
+ function connectionSettingsOf(body) {
121865
+ const out = {};
121866
+ for (const [key, value] of Object.entries(body)) {
121867
+ if (key === "name" || value === null || value === void 0) continue;
121868
+ out[key] = value;
121869
+ }
121870
+ return out;
121871
+ }
121872
+ function settingsReadOf(resolved) {
121873
+ return resolved === null ? {
121874
+ values: {},
121875
+ secretsLocked: false
121876
+ } : {
121877
+ values: connectionSettingsOf(resolved.body),
121878
+ secretsLocked: resolved.secrets === "unavailable"
121879
+ };
121880
+ }
121881
+ function buildHomematicInstances(records, deps) {
121882
+ return new RecordIntegrationInstances(records, homematicConnectionsEntryKind, {
121883
+ description: {
121884
+ role: "devices",
121885
+ discovery: {
121886
+ mode: "lan",
121887
+ scopedToInstance: false
121888
+ },
121889
+ instanceMode: "multiple",
121890
+ kind: "connection",
121891
+ canTest: false
121892
+ },
121893
+ formSchema: () => buildConnectionFormSchema(),
121894
+ initialBody: (name) => ({ name }),
121895
+ configured: (body) => (body.host ?? "").trim().length > 0,
121896
+ onChanged: () => deps.onChanged()
121897
+ });
121898
+ }
121899
+ /** The ONE reader of a CCU's connection: the integration's record, never the legacy rows. */
121900
+ async function readCcuConnection(instances, integrationId) {
121901
+ const read = settingsReadOf(await instances.readResolved(integrationId));
121902
+ return {
121903
+ connection: connectionFromSettings(read.values),
121904
+ secretsLocked: read.secretsLocked
121905
+ };
121906
+ }
121907
+ /** The hosts of the CCUs already set up, for discovery to leave out; an unreadable one is skipped. */
121908
+ async function knownCcuHostsOf(deps) {
121909
+ const hosts = [];
121910
+ for (const id of deps.integrationIds) try {
121911
+ const { connection } = await readCcuConnection(deps.instances, id);
121912
+ if (connection !== null) hosts.push(connection.host);
121913
+ } catch (err) {
121914
+ deps.onUnreadable(id, err);
121915
+ }
121916
+ return hosts;
121917
+ }
119851
121918
  //#endregion
119852
- //#region src/custom-actions.ts
121919
+ //#region src/migrations/integration-rows-to-record.ts
119853
121920
  /**
119854
- * Custom actions of the Homematic addon: the LAN scan behind the integration
119855
- * form's CCU picker, and the CCU management page (`provider-homematic` admin
119856
- * page). Reads are `query`; every CCU write is a `mutation` whose input carries
119857
- * the operator's `confirmed` flag.
121921
+ * Every Homematic integration moves from legacy `integration_settings` rows into its own
121922
+ * `connections` record under the registry id (planning#416, D1007): the CCU connection the live
121923
+ * session dials, the WebUI password a keychain secret declared by the kind. Each integration's
121924
+ * record is built from ITS OWN rows, never from another's. Only the integration configuration
121925
+ * moves: adopted devices, their stable ids and their history are not touched.
121926
+ *
121927
+ * Keys nothing reads any more are named in a warning, by key, and dropped with the rows once the
121928
+ * record has been read back; a value of the wrong type is left out and named by key as well.
119858
121929
  */
119859
- var homematicActions = defineCustomActions({
119860
- discoverCcu: customAction(object({}), object({
119861
- hosts: array(object({
119862
- host: string(),
119863
- name: string(),
119864
- id: string()
119865
- })),
119866
- summary: string()
119867
- }), {
119868
- kind: "mutation",
119869
- auth: "admin"
119870
- }),
119871
- listCcus: customAction(object({}), array(CcuListItemSchema), {
119872
- kind: "query",
119873
- auth: "admin"
119874
- }),
119875
- ccuOverview: customAction(IntegrationRefSchema, CcuOverviewSchema, {
119876
- kind: "query",
119877
- auth: "admin"
119878
- }),
119879
- listServiceMessages: customAction(IntegrationRefSchema, ServiceMessagesResultSchema, {
119880
- kind: "query",
119881
- auth: "admin"
119882
- }),
119883
- listCcuDevices: customAction(IntegrationRefSchema, CcuDevicesResultSchema, {
119884
- kind: "query",
119885
- auth: "admin"
119886
- }),
119887
- listHeatingGroups: customAction(IntegrationRefSchema, HeatingOverviewSchema, {
119888
- kind: "query",
119889
- auth: "admin"
119890
- }),
119891
- createHeatingGroup: customAction(CreateGroupInputSchema, HeatingGroupSchema, {
119892
- kind: "mutation",
119893
- auth: "admin"
119894
- }),
119895
- updateHeatingGroup: customAction(UpdateGroupInputSchema, HeatingGroupSchema, {
119896
- kind: "mutation",
119897
- auth: "admin"
119898
- }),
119899
- deleteHeatingGroup: customAction(DeleteGroupInputSchema, OkResultSchema, {
119900
- kind: "mutation",
119901
- auth: "admin"
119902
- }),
119903
- ccuPairingStatus: customAction(IntegrationRefSchema, PairingStatusSchema, {
119904
- kind: "query",
119905
- auth: "admin"
119906
- }),
119907
- setCcuInstallMode: customAction(SetInstallModeInputSchema, OkResultSchema, {
119908
- kind: "mutation",
119909
- auth: "admin"
119910
- }),
119911
- deleteCcuDevice: customAction(DeleteCcuDeviceInputSchema, OkResultSchema, {
119912
- kind: "mutation",
119913
- auth: "admin"
119914
- }),
119915
- getCcuDeviceConfig: customAction(DeviceRefSchema, DeviceConfigSchema, {
119916
- kind: "query",
119917
- auth: "admin"
119918
- }),
119919
- setCcuChannelConfig: customAction(SetChannelConfigInputSchema, OkResultSchema, {
119920
- kind: "mutation",
119921
- auth: "admin"
119922
- }),
119923
- acknowledgeServiceMessage: customAction(AcknowledgeInputSchema, OkResultSchema, {
119924
- kind: "mutation",
119925
- auth: "admin"
121930
+ var HOMEMATIC_ROWS_TO_RECORD_ID = "provider-homematic/2026-11-05-integration-rows-to-record";
121931
+ var TEXT_KEYS = [
121932
+ "host",
121933
+ "username",
121934
+ "callbackHost"
121935
+ ];
121936
+ var FLAG_KEYS = [
121937
+ "enableHmipRf",
121938
+ "enableBidcosRf",
121939
+ "enableGroups",
121940
+ "enableBidcosWired",
121941
+ "tls"
121942
+ ];
121943
+ function portOf(value) {
121944
+ const n = typeof value === "string" && value.trim() !== "" ? Number(value) : value;
121945
+ return typeof n === "number" && Number.isInteger(n) && n >= 1 && n <= 65535 ? n : null;
121946
+ }
121947
+ /** The record body of one integration, from its resolved legacy rows. Never logs a value. */
121948
+ function homematicBodyFromRows(values, log, integration) {
121949
+ const body = { name: integration.name };
121950
+ const unusable = [];
121951
+ const known = new Set([
121952
+ "password",
121953
+ "callbackPort",
121954
+ ...TEXT_KEYS,
121955
+ ...FLAG_KEYS
121956
+ ]);
121957
+ for (const key of TEXT_KEYS) {
121958
+ if (!(key in values)) continue;
121959
+ const raw = values[key];
121960
+ if (typeof raw === "string") {
121961
+ if (raw.trim() !== "") body[key] = raw.trim();
121962
+ } else unusable.push(key);
121963
+ }
121964
+ for (const key of FLAG_KEYS) {
121965
+ if (!(key in values)) continue;
121966
+ const raw = values[key];
121967
+ if (typeof raw === "boolean") body[key] = raw;
121968
+ else unusable.push(key);
121969
+ }
121970
+ if ("callbackPort" in values) {
121971
+ const raw = values["callbackPort"];
121972
+ if (raw !== "" && raw !== null) {
121973
+ const port = portOf(raw);
121974
+ if (port === null) unusable.push("callbackPort");
121975
+ else body["callbackPort"] = port;
121976
+ }
121977
+ }
121978
+ if ("password" in values) {
121979
+ const password = values["password"];
121980
+ if (typeof password === "string") {
121981
+ if (password.length > 0) body["password"] = password;
121982
+ } else unusable.push("password");
121983
+ }
121984
+ const unknown = Object.keys(values).filter((key) => !known.has(key));
121985
+ if (unknown.length > 0) log.warn(`integration '${integration.id}': legacy settings nothing reads any more are dropped: ${unknown.join(", ")}`);
121986
+ if (unusable.length > 0) log.warn(`integration '${integration.id}': legacy settings with an unusable value are left out: ${unusable.join(", ")}`);
121987
+ return homematicConnectionsEntryKind.schema.parse(body);
121988
+ }
121989
+ var HOMEMATIC_ROWS_TO_RECORD_MIGRATION = {
121990
+ meta: {
121991
+ id: HOMEMATIC_ROWS_TO_RECORD_ID,
121992
+ owner: "provider-homematic",
121993
+ level: "addon-state",
121994
+ seq: 1,
121995
+ dependsOn: [],
121996
+ store: "settings",
121997
+ scope: "cluster",
121998
+ onFailure: "block-owner",
121999
+ bodyKind: "procedure",
122000
+ description: "Move every Homematic CCU integration into its own connection record keyed by its registry id, the WebUI password as a keychain secret, then clear its legacy integration settings rows; adopted devices are not touched",
122001
+ fixtureMark: "a legacy setting key the migration does not know"
122002
+ },
122003
+ procedure: (ports) => moveIntegrationRowsToRecords(ports, {
122004
+ addonId: "provider-homematic",
122005
+ secretPaths: homematicConnectionsEntryKind.declaration.secretPaths,
122006
+ bodyFrom: homematicBodyFromRows
119926
122007
  })
119927
- });
122008
+ };
119928
122009
  //#endregion
119929
122010
  //#region src/homematic-facade-resolver.ts
119930
122011
  /**
@@ -121059,6 +123140,8 @@ var hmActuatorSchema = hmChildSchema.extend({
121059
123140
  * existing pure decoders (`decodeCover` / `decodeLock` / `decodeClimate`).
121060
123141
  */
121061
123142
  var HmActuatorDevice = class extends HmChildDevice {
123143
+ /** A cover's `stop` drives the channel's real STOP (`coverStop`). */
123144
+ features = this.config.values.kind === "cover" ? [DeviceFeature.CoverStoppable] : [];
121062
123145
  kind;
121063
123146
  /** The actuator cap name actually registered (drives decode routing). */
121064
123147
  registeredCap = null;
@@ -123453,11 +125536,26 @@ var HomematicProviderAddon = class extends BaseDeviceProvider {
123453
125536
  /** Live per-integration CCU sessions, or null before init / after shutdown. */
123454
125537
  integrationReconciler = null;
123455
125538
  clients = null;
125539
+ instances = null;
123456
125540
  constructor() {
123457
125541
  super({});
123458
125542
  }
123459
125543
  async onInitialize() {
123460
125544
  const regs = this.providerRegistrationsFromSuper(await super.onInitialize());
125545
+ const records = this.ctx.records;
125546
+ if (records === void 0) throw new Error("provider-homematic: ctx.records is required (hub-only addon)");
125547
+ await records.declare(homematicRecordKinds);
125548
+ const instances = buildHomematicInstances(records, { onChanged: () => this.reconcileIntegrations() });
125549
+ this.instances = instances;
125550
+ await this.runMigrations(defineAddonMigrations([HOMEMATIC_ROWS_TO_RECORD_MIGRATION], integrationRowsPortsOverApi({
125551
+ api: defaultIntegrationApiOver(this.ctx.api),
125552
+ records: records.kind({
125553
+ name: homematicConnectionsEntryKind.name,
125554
+ declaration: homematicConnectionsEntryKind.declaration,
125555
+ schema: record(string(), unknown())
125556
+ }),
125557
+ log: { warn: (message) => this.ctx.logger.warn(message) }
125558
+ })));
123461
125559
  this.clients = new HmClientRegistry(this.ctx.logger);
123462
125560
  this.clients.setOnConnected((integrationId) => {
123463
125561
  this.ctx.logger.info("Homematic: CCU connected", { meta: { integrationId } });
@@ -123473,6 +125571,10 @@ var HomematicProviderAddon = class extends BaseDeviceProvider {
123473
125571
  return {
123474
125572
  providers: [
123475
125573
  ...regs,
125574
+ {
125575
+ capability: integrationInstancesCapability,
125576
+ provider: instances.toProvider()
125577
+ },
123476
125578
  {
123477
125579
  capability: deviceAdoptionCapability,
123478
125580
  provider: this.buildAdoptionProvider()
@@ -123546,8 +125648,9 @@ var HomematicProviderAddon = class extends BaseDeviceProvider {
123546
125648
  homematicFacades.clear();
123547
125649
  await super.onShutdown();
123548
125650
  }
123549
- globalSettingsSchema() {
123550
- return buildConnectionFormSchema();
125651
+ requireInstances() {
125652
+ if (!this.instances) throw new Error("Homematic provider not initialised");
125653
+ return this.instances;
123551
125654
  }
123552
125655
  /**
123553
125656
  * Stable id, integration-scoped so two CCUs exposing the same device address
@@ -123594,20 +125697,14 @@ var HomematicProviderAddon = class extends BaseDeviceProvider {
123594
125697
  async knownCcuHosts() {
123595
125698
  try {
123596
125699
  const all = await this.ctx.api.integrations.list.query();
123597
- const hosts = [];
123598
- for (const integration of all) {
123599
- if (integration.addonId !== this.ctx.id) continue;
123600
- try {
123601
- const connection = connectionFromSettings(await this.ctx.api.integrations.getSettings.query({ id: integration.id }));
123602
- if (connection) hosts.push(connection.host);
123603
- } catch (err) {
123604
- this.ctx.logger.warn("Homematic discovery: settings read failed", {
123605
- tags: { integrationId: integration.id },
123606
- meta: { error: errMsg(err) }
123607
- });
123608
- }
123609
- }
123610
- return hosts;
125700
+ return await knownCcuHostsOf({
125701
+ instances: this.requireInstances(),
125702
+ integrationIds: all.filter((i) => i.addonId === this.ctx.id).map((i) => i.id),
125703
+ onUnreadable: (integrationId, err) => this.ctx.logger.warn("Homematic discovery: settings read failed", {
125704
+ tags: { integrationId },
125705
+ meta: { error: errMsg(err) }
125706
+ })
125707
+ });
123611
125708
  } catch (err) {
123612
125709
  this.ctx.logger.warn("Homematic discovery: integration list failed", { meta: { error: errMsg(err) } });
123613
125710
  return [];
@@ -123662,8 +125759,8 @@ var HomematicProviderAddon = class extends BaseDeviceProvider {
123662
125759
  },
123663
125760
  listIntegrations: () => this.ctx.api.integrations.list.query(),
123664
125761
  applySettings: async (integration) => {
123665
- const connection = connectionFromSettings(await this.ctx.api.integrations.getSettings.query({ id: integration.id }));
123666
- if (!connection) return false;
125762
+ const { connection, secretsLocked } = await readCcuConnection(this.requireInstances(), integration.id);
125763
+ if (secretsLocked || !connection) return false;
123667
125764
  await this.requireClients().upsert(integration.id, integration.name, connection);
123668
125765
  return true;
123669
125766
  },