@camstack/addon-provider-homematic 1.2.185 → 1.2.187

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
@@ -9,7 +9,7 @@ import { networkInterfaces } from "node:os";
9
9
  var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
10
10
  var __require = /* @__PURE__ */ createRequire(import.meta.url);
11
11
  //#endregion
12
- //#region ../types/dist/event-category-BmPm98n0.mjs
12
+ //#region ../types/dist/event-category-78tcBemo.mjs
13
13
  var EventCategory = /* @__PURE__ */ function(EventCategory) {
14
14
  EventCategory["SystemBoot"] = "system.boot";
15
15
  EventCategory["SystemAddonsReady"] = "system.addons-ready";
@@ -130,6 +130,23 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
130
130
  */
131
131
  EventCategory["AddonLoadRecovered"] = "addon.load-recovered";
132
132
  /**
133
+ * An addon is RUNNING although its installed package is below what the
134
+ * running server requires (`camstack.requires.addons` of the server, or the
135
+ * addon's own `requires.server`). Raised once per streak by the unsupported-
136
+ * addon tracker, on the hub and on agents; AlertCenter turns it into one
137
+ * operator alert per node and package. The addon is never held back for it.
138
+ *
139
+ * Payload: `{ packageName, addonId, nodeId, installedVersion, requiredMinimum, serverVersion, unmet }`.
140
+ */
141
+ EventCategory["AddonUnsupportedVersion"] = "addon.unsupported-version";
142
+ /**
143
+ * The package of an {@link AddonUnsupportedVersion} alert reached a supported
144
+ * version, or is no longer installed on the node. AlertCenter dismisses the matching alert.
145
+ *
146
+ * Payload: `{ packageName, addonId, nodeId }`.
147
+ */
148
+ EventCategory["AddonUnsupportedResolved"] = "addon.unsupported-resolved";
149
+ /**
133
150
  * Monitor scheduled the next retry for a failed addon. Transient —
134
151
  * surfaced to the UI for live-updating the "next retry in Ns"
135
152
  * countdown on the Addons page row, NOT persisted as an alert.
@@ -240,7 +257,7 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
240
257
  EventCategory["ProcessRestarted"] = "process.restarted";
241
258
  /**
242
259
  * The SET of storage locations changed — one was created, edited, enabled,
243
- * disabled or deleted through `storage.upsertLocation` / `deleteLocation`.
260
+ * disabled or deleted through the location instances or the forced-delete action.
244
261
  *
245
262
  * Telemetry, not a transaction (D8/D11): every consumer that re-resolves on
246
263
  * it must also converge on its own periodic path, because a dropped event
@@ -795,7 +812,7 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
795
812
  return EventCategory;
796
813
  }({});
797
814
  //#endregion
798
- //#region ../types/dist/device-type-D1fH5kaC.mjs
815
+ //#region ../types/dist/device-type-DxCT0krO.mjs
799
816
  /**
800
817
  import { errMsg } from '@camstack/types'
801
818
  * Extract a human-readable message from an unknown error value.
@@ -957,6 +974,13 @@ var DeviceFeature = /* @__PURE__ */ function(DeviceFeature) {
957
974
  * filters that want "all devices with on-motion behaviour".
958
975
  */
959
976
  DeviceFeature["MotionTrigger"] = "motion-trigger";
977
+ /**
978
+ * Device can be run for a chosen time and then stopped. Mirrors the
979
+ * `timed-run` wrapper cap — the cap is bound by the core-blocks addon, not by
980
+ * a driver, so the flag is derived from the device's bindings
981
+ * (`featuresOfBoundCaps`). Gates the quick-run control in the viewer.
982
+ */
983
+ DeviceFeature["TimedRun"] = "timed-run";
960
984
  /** Light supports rgb-triplet color via `color` cap. */
961
985
  DeviceFeature["LightColorRgb"] = "light-color-rgb";
962
986
  /** Light supports HSV color via `color` cap. */
@@ -5991,7 +6015,7 @@ var ZodIssueCode = {
5991
6015
  var ZodFirstPartyTypeKind;
5992
6016
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
5993
6017
  //#endregion
5994
- //#region ../types/dist/sleep-CdKka2ri.mjs
6018
+ //#region ../types/dist/sleep-CGPZyzB5.mjs
5995
6019
  /**
5996
6020
  * The audio chunk plane's byte format, and the ONE expansion from a coded
5997
6021
  * window to float samples (D455).
@@ -6355,6 +6379,59 @@ Object.fromEntries([
6355
6379
  function isValuelessField(field) {
6356
6380
  return field.type === "separator" || field.type === "info" || field.type === "qr-code" || field.type === "button" || field.type === "object-array" || field.type === "widget" || field.type === "addon-action-button" || field.type === "device-action-button" || field.type === "account-sign-in" || field.type === "secret-presence";
6357
6381
  }
6382
+ /**
6383
+ * Base collector: flatten a hydrated `ConfigUISchemaWithValues` into
6384
+ * `key → { value, default }`, recursing through `group` and `sub-tabs`
6385
+ * layout fields. Keeping `value` and `default` SEPARATE (rather than
6386
+ * pre-resolving) lets callers both read the effective value AND detect
6387
+ * overrides (`value` differs from `default`). Structural over `unknown`;
6388
+ * malformed input yields an empty map, never throws.
6389
+ */
6390
+ function collectHydratedFieldEntries(schema) {
6391
+ const out = /* @__PURE__ */ new Map();
6392
+ if (typeof schema !== "object" || schema === null) return out;
6393
+ const sections = schema.sections;
6394
+ if (!Array.isArray(sections)) return out;
6395
+ for (const section of sections) if (typeof section === "object" && section !== null) collectFieldEntriesInto(section.fields, out);
6396
+ return out;
6397
+ }
6398
+ /** Recursive field walker for {@link collectHydratedFieldEntries}. */
6399
+ function collectFieldEntriesInto(fields, into) {
6400
+ if (!Array.isArray(fields)) return;
6401
+ for (const field of fields) {
6402
+ if (typeof field !== "object" || field === null) continue;
6403
+ const type = field.type;
6404
+ if (type === "group") {
6405
+ collectFieldEntriesInto(field.fields, into);
6406
+ continue;
6407
+ }
6408
+ if (type === "sub-tabs") {
6409
+ const tabs = field.tabs;
6410
+ if (Array.isArray(tabs)) {
6411
+ for (const tab of tabs) if (typeof tab === "object" && tab !== null) collectFieldEntriesInto(tab.fields, into);
6412
+ }
6413
+ continue;
6414
+ }
6415
+ const key = field.key;
6416
+ if (typeof key !== "string" || key.length === 0) continue;
6417
+ if (!("value" in field)) continue;
6418
+ into.set(key, {
6419
+ value: field.value,
6420
+ default: field.default
6421
+ });
6422
+ }
6423
+ }
6424
+ /**
6425
+ * Flatten a hydrated settings payload into `key → EFFECTIVE value`
6426
+ * (`value ?? default`). The read-side inverse of `hydrateSchema` for the
6427
+ * common "just give me the resolved values" case. Built on
6428
+ * {@link collectHydratedFieldEntries}.
6429
+ */
6430
+ function collectHydratedFieldValues(schema) {
6431
+ const out = /* @__PURE__ */ new Map();
6432
+ for (const [key, entry] of collectHydratedFieldEntries(schema)) out.set(key, entry.value ?? entry.default);
6433
+ return out;
6434
+ }
6358
6435
  function hydrateSchema(schema, values, options = {}) {
6359
6436
  return {
6360
6437
  ...schema.tabs ? { tabs: [...schema.tabs] } : {},
@@ -6700,10 +6777,33 @@ function integrationRowsApiOver(api) {
6700
6777
  };
6701
6778
  }
6702
6779
  var PREFIX = "records/";
6780
+ /**
6781
+ * Cross-realm brand. An addon bundles its own copy of this module (D15) while
6782
+ * `ctx.records` is the HOST's door, so an error thrown by the host is an
6783
+ * instance of the host's classes, not of the addon's. The brand plus the code
6784
+ * make `instanceof` answer by identity of the failure, not of the copy.
6785
+ */
6786
+ var RECORDS_ERROR_BRAND = Symbol.for("camstack.records-error");
6787
+ function carriesBrand(value) {
6788
+ return typeof value === "object" && value !== null && Reflect.get(value, RECORDS_ERROR_BRAND) === true;
6789
+ }
6703
6790
  /** The base of every records failure. `detail` is the human part of the message. */
6704
6791
  var RecordsError = class extends Error {
6792
+ /** The code a subclass stands for; the base stands for every code. */
6793
+ static code = void 0;
6794
+ /**
6795
+ * `instanceof` across copies of this module: any branded error is a
6796
+ * `RecordsError`, and is an instance of a subclass only when its code is the
6797
+ * subclass's code. Same-copy answers are unchanged.
6798
+ */
6799
+ static [Symbol.hasInstance](value) {
6800
+ if (Function.prototype[Symbol.hasInstance].call(this, value)) return true;
6801
+ if (!carriesBrand(value)) return false;
6802
+ return this.code === void 0 || value.code === this.code;
6803
+ }
6705
6804
  code;
6706
6805
  detail;
6806
+ [RECORDS_ERROR_BRAND] = true;
6707
6807
  constructor(code, detail) {
6708
6808
  super(`${PREFIX}${code}: ${detail}`);
6709
6809
  this.name = "RecordsError";
@@ -6712,29 +6812,33 @@ var RecordsError = class extends Error {
6712
6812
  }
6713
6813
  };
6714
6814
  /** A write guarded by `ifRev` found another revision (or an existing row for `ifRev: 0`). */
6715
- var RevConflictError = class extends RecordsError {
6815
+ var RevConflictError = class RevConflictError extends RecordsError {
6816
+ static code = "rev-conflict";
6716
6817
  constructor(detail) {
6717
- super("rev-conflict", detail);
6818
+ super(RevConflictError.code, detail);
6718
6819
  this.name = "RevConflictError";
6719
6820
  }
6720
6821
  };
6721
6822
  /** The keychain could not store or serve a value: explicit, never an empty string. */
6722
- var RecordSecretUnavailableError = class extends RecordsError {
6823
+ var RecordSecretUnavailableError = class RecordSecretUnavailableError extends RecordsError {
6824
+ static code = "secret-unavailable";
6723
6825
  constructor(detail) {
6724
- super("secret-unavailable", detail);
6826
+ super(RecordSecretUnavailableError.code, detail);
6725
6827
  this.name = "RecordSecretUnavailableError";
6726
6828
  }
6727
6829
  };
6728
- var InvalidRecordError = class extends RecordsError {
6830
+ var InvalidRecordError = class InvalidRecordError extends RecordsError {
6831
+ static code = "invalid-record";
6729
6832
  constructor(detail) {
6730
- super("invalid-record", detail);
6833
+ super(InvalidRecordError.code, detail);
6731
6834
  this.name = "InvalidRecordError";
6732
6835
  }
6733
6836
  };
6734
6837
  /** A kind declaration the engine refuses (non-additive change, bad shape, wrong file). */
6735
- var DeclarationRefusedError = class extends RecordsError {
6838
+ var DeclarationRefusedError = class DeclarationRefusedError extends RecordsError {
6839
+ static code = "declaration-refused";
6736
6840
  constructor(detail) {
6737
- super("declaration-refused", detail);
6841
+ super(DeclarationRefusedError.code, detail);
6738
6842
  this.name = "DeclarationRefusedError";
6739
6843
  }
6740
6844
  };
@@ -7136,6 +7240,7 @@ var RecordIntegrationInstances = class {
7136
7240
  this.secretKeys = topLevelSecretKeys(kind.declaration.secretPaths);
7137
7241
  this.secretMaps = secretMapKeys(kind.declaration.secretPaths);
7138
7242
  this.nameField = kind.declaration.entry?.nameField ?? "name";
7243
+ if (hooks.kindOf === void 0 && hooks.description.kinds.length !== 1) throw new Error(`record kind '${kind.name}': describe().kinds has ${hooks.description.kinds.length} entries, so kindOf is required to say which one an instance is`);
7139
7244
  }
7140
7245
  /**
7141
7246
  * One instance read for the addon's own runtime; null when absent. When the keychain is
@@ -7177,10 +7282,21 @@ var RecordIntegrationInstances = class {
7177
7282
  }
7178
7283
  return out;
7179
7284
  }
7285
+ /** The kind an instance body is of: the provider's `kindOf`, else its one declared kind. */
7286
+ kindOfBody(body) {
7287
+ if (this.hooks.kindOf !== void 0) {
7288
+ const id = this.hooks.kindOf(body);
7289
+ if (!this.hooks.description.kinds.some((declared) => declared.id === id)) throw new Error(`record kind '${this.kind.name}': kindOf returned '${id}', which describe().kinds does not declare (D1013)`);
7290
+ return id;
7291
+ }
7292
+ const only = this.hooks.description.kinds[0];
7293
+ if (only === void 0) throw new Error(`record kind '${this.kind.name}' declares no kinds`);
7294
+ return only.id;
7295
+ }
7180
7296
  viewOf(record) {
7181
7297
  const shown = secretViewsOf(this.records.owner, this.kind.name, record.id, this.kind.declaration, record.data);
7182
7298
  const rawName = record.data[this.nameField];
7183
- const kind = this.hooks.kindOf?.(record.data);
7299
+ const kind = this.kindOfBody(record.data);
7184
7300
  const health = this.hooks.health?.(record.data, record.id);
7185
7301
  return {
7186
7302
  id: record.id,
@@ -7188,7 +7304,7 @@ var RecordIntegrationInstances = class {
7188
7304
  configured: this.hooks.configured(record.data),
7189
7305
  enabled: isInstanceEnabled(record.data),
7190
7306
  formValues: shown,
7191
- ...kind !== void 0 ? { kind } : {},
7307
+ kind,
7192
7308
  ...health?.status !== void 0 ? { status: health.status } : {},
7193
7309
  ...health?.lastCheckedAt !== void 0 ? { lastCheckedAt: health.lastCheckedAt } : {}
7194
7310
  };
@@ -7221,17 +7337,35 @@ var RecordIntegrationInstances = class {
7221
7337
  ...kind !== void 0 ? { kind } : {}
7222
7338
  });
7223
7339
  if (minted === void 0) throw new Error("createInstance needs an id: this provider does not mint one");
7340
+ const initial = this.hooks.initialBody(name, kind);
7341
+ const patch = this.patchOf(values ?? {});
7342
+ if (Object.keys(patch).length > 0) Object.assign(patch, await this.hooks.validateWrite?.({
7343
+ kind,
7344
+ body: {
7345
+ ...initial,
7346
+ ...patch
7347
+ }
7348
+ }));
7224
7349
  await this.handle.put({
7225
7350
  id: minted,
7226
- data: this.hooks.initialBody(name, kind)
7351
+ data: initial
7227
7352
  }, { ifRev: 0 });
7228
- const patch = this.patchOf(values ?? {});
7229
7353
  if (Object.keys(patch).length > 0) await this.handle.patch(minted, patch);
7230
7354
  await this.hooks.onChanged?.(minted, "created");
7231
7355
  return { id: minted };
7232
7356
  };
7233
7357
  updateInstance = async ({ id, name, values }) => {
7234
7358
  const patch = this.patchOf(values);
7359
+ if (this.hooks.validateWrite !== void 0 && Object.keys(patch).length > 0) {
7360
+ const stored = await this.handle.get(id);
7361
+ if (stored !== null) Object.assign(patch, await this.hooks.validateWrite({
7362
+ kind: void 0,
7363
+ body: {
7364
+ ...stored.data,
7365
+ ...patch
7366
+ }
7367
+ }));
7368
+ }
7235
7369
  if (name !== void 0) patch[this.nameField] = name;
7236
7370
  await this.handle.patch(id, patch);
7237
7371
  await this.hooks.onChanged?.(id, "updated");
@@ -7542,6 +7676,21 @@ var SCOPED_SETTINGS_SCOPES = [
7542
7676
  "device-defaults",
7543
7677
  "node"
7544
7678
  ];
7679
+ /** The one refusal of a key a scope did not declare. */
7680
+ function assertDeclaredKeys(keys, declared) {
7681
+ const undeclared = keys.filter((key) => !declared.has(key));
7682
+ if (undeclared.length > 0) throw new Error(`scoped settings: [${undeclared.join(", ")}] not declared for this scope (declared: [${[...declared].join(", ")}])`);
7683
+ }
7684
+ /** Build the handle over an addon's scoped read, write and unset. */
7685
+ function createScopedSettings(deps) {
7686
+ return {
7687
+ async get() {
7688
+ return deps.schema.parse(await deps.read());
7689
+ },
7690
+ patch: (patch) => deps.write(Object.fromEntries(Object.entries(patch))),
7691
+ unset: (keys) => deps.unset(keys)
7692
+ };
7693
+ }
7545
7694
  /** A write to a secret path could not be stored in the keychain, so it was refused. */
7546
7695
  var KeychainWriteRefusedError = class extends Error {
7547
7696
  fieldPath;
@@ -8117,7 +8266,16 @@ function createHandle(raw, opts) {
8117
8266
  return blob;
8118
8267
  }
8119
8268
  },
8120
- writeAddonStore: writeAddon
8269
+ writeAddonStore: writeAddon,
8270
+ removeClearedKeys: (keys) => serialize("addon", async () => {
8271
+ const stored = await readStoredAddonBlob(raw);
8272
+ index.seen("addon", stored);
8273
+ const removable = keys.filter((key) => collectSecretMarkerRefs(stored[key]).length === 0);
8274
+ if (removable.length === 0) return;
8275
+ const patch = Object.fromEntries(removable.map((key) => [key, void 0]));
8276
+ await raw.writeAddonStore(patch);
8277
+ index.wrote("addon", patch);
8278
+ })
8121
8279
  };
8122
8280
  }
8123
8281
  /** The context the addon sees, plus the private raw view and write outcome. */
@@ -8247,7 +8405,7 @@ function boundOf(list) {
8247
8405
  * Base class for CamStack addons. Eliminates settings boilerplate:
8248
8406
  *
8249
8407
  * - Typed `config` property with automatic resolution from store + defaults
8250
- * - `getGlobalSettings()` / `updateGlobalSettings()` auto-implemented
8408
+ * - the scoped settings API (`clusterSettings` / `nodeSettings` / `deviceDefaults`) auto-implemented
8251
8409
  * - `getAddonSettings()` / `updateAddonSettings()` auto-implemented
8252
8410
  * - `getDeviceSettings()` / `updateDeviceSettings()` auto-implemented
8253
8411
  * - `ctx` accessor for the AddonContext (no manual `this.ctxRef` storage)
@@ -8257,7 +8415,7 @@ function boundOf(list) {
8257
8415
  * Subclasses override:
8258
8416
  * - `onInitialize()` — addon-specific init logic, return ProviderRegistration[]
8259
8417
  * - `onShutdown()` — cleanup
8260
- * - `globalSettingsSchema()` / `deviceSettingsSchema()` — UI schemas
8418
+ * - `clusterSettingsSchema()` / `nodeSettingsSchema()` / `deviceSettingsSchema()` — UI schemas
8261
8419
  *
8262
8420
  * @example
8263
8421
  * ```ts
@@ -8271,7 +8429,7 @@ function boundOf(list) {
8271
8429
  * super({ maxRetries: 3, endpoint: 'http://localhost' })
8272
8430
  * }
8273
8431
  *
8274
- * protected globalSettingsSchema() {
8432
+ * protected clusterSettingsSchema() {
8275
8433
  * return this.schema({
8276
8434
  * sections: [{
8277
8435
  * id: 'main', title: 'Settings',
@@ -8314,7 +8472,7 @@ var BaseAddon = class {
8314
8472
  defaults;
8315
8473
  /**
8316
8474
  * Hidden-state paths that hold secrets (D787) — values the addon writes
8317
- * itself (`updateGlobalSettings`, `state()`) that no form field declares.
8475
+ * itself (`state()`, the scoped writers) that no form field declares.
8318
8476
  * Stored in the keychain exactly like a `password` field. Syntax:
8319
8477
  * `'snapshotSigningKey'`, `'identity.pincode'`, `'tokens[userId].accessToken'`
8320
8478
  * (`key[<id field>]` addresses array items by id, never by index).
@@ -8324,7 +8482,7 @@ var BaseAddon = class {
8324
8482
  /**
8325
8483
  * D986 M4: the scoped schemas this addon declared, resolved once per capability
8326
8484
  * (`loadScopedSchemas`) so the sync readers (`perNodeKeys`, the secret tree, the restart check)
8327
- * see them. Empty until loaded: the readers then fall back to {@link globalSettingsSchema}.
8485
+ * see them. Empty until loaded.
8328
8486
  */
8329
8487
  _scopedByCap = /* @__PURE__ */ new Map();
8330
8488
  _nodeKeysByCap = /* @__PURE__ */ new Map();
@@ -8510,7 +8668,7 @@ var BaseAddon = class {
8510
8668
  /** Addon-specific cleanup. Override if needed. */
8511
8669
  async onShutdown() {}
8512
8670
  /**
8513
- * Called after config is resolved during updateGlobalSettings/updateAddonSettings.
8671
+ * Called after config is resolved during a settings write.
8514
8672
  * Override to react to config changes (e.g. restart a sampler, reconnect a service).
8515
8673
  * Not called during initialize() — use onInitialize() for initial setup.
8516
8674
  */
@@ -8539,82 +8697,12 @@ var BaseAddon = class {
8539
8697
  scopedSettingsCapabilities() {
8540
8698
  return [];
8541
8699
  }
8542
- /** Override to provide global-level settings UI schema. */
8543
- globalSettingsSchema(_cap) {
8544
- return null;
8545
- }
8546
8700
  /** Override to provide device-level settings UI schema. */
8547
8701
  deviceSettingsSchema() {
8548
8702
  return null;
8549
8703
  }
8550
8704
  /**
8551
- * INTEGRATION-LEVEL SETTINGS — declare which of this addon's global sections
8552
- * ARE the configuration of its integration.
8553
- *
8554
- * Return the `ConfigSection.id`s, from {@link globalSettingsSchema}, that an
8555
- * operator should find on the addon's integration page (System →
8556
- * Integrations → <name>) rather than only in the cluster-wide list of every
8557
- * addon. Empty (the default) means the addon has no integration-level
8558
- * settings and no such surface is offered — this is opt-in, because whether
8559
- * an addon's configuration IS its integration's configuration depends on the
8560
- * nature of the integration.
8561
- *
8562
- * WHAT THIS IS NOT. It is not a scope. The selected sections keep living in
8563
- * the ONE global schema, in the ONE addon store, written by the ONE
8564
- * `updateGlobalSettings` path. There is deliberately no
8565
- * `updateIntegrationSettings`: a second write path is how a surface acquires
8566
- * a second store key, and this repo has shipped that twice (`btmPath@hub`,
8567
- * D266). Selecting sections cannot introduce a key that selecting cannot.
8568
- *
8569
- * WHY IT IS A LIST OF SECTION IDS AND NOT A MARKER ON THE SECTION.
8570
- * `ConfigFieldBase` used to carry `scope?: 'device' | 'global'` and it was
8571
- * removed with the reason recorded at
8572
- * `packages/types/src/interfaces/config-ui.ts:249` — *"a field's scope is
8573
- * determined by WHICH schema it lives in, not by a field-level marker."* A
8574
- * marker sprinkled across sections also has to borrow a field that already
8575
- * means something else; borrowing `section.tab` put the literal word
8576
- * "integration" into an operator-facing tab bar, because `tab` means "how to
8577
- * GROUP this visually" and cannot also mean "where this lives" (D269
8578
- * supersedes D268). One declaration, in one place, next to the schema whose
8579
- * ids it names.
8580
- */
8581
- integrationSettingSections() {
8582
- return [];
8583
- }
8584
- async getGlobalSettings(overlay, cap, nodeId) {
8585
- await this.loadScopedSchemas(cap);
8586
- const schema = this.globalSettingsSchema(cap) ?? this.scopedFormSchema(cap);
8587
- if (!schema) return { sections: [] };
8588
- const projected = await this.readRawProjectedStore(nodeId, cap);
8589
- return hydrateSchema(schema, overlay ? await this.overlayKeepingMarkers(projected, overlay) : projected, { inlineSecretsAsViews: true });
8590
- }
8591
- /**
8592
- * The integration-level view of this addon's settings: exactly the sections
8593
- * named by {@link integrationSettingSections}, hydrated from the SAME store
8594
- * `getGlobalSettings` reads, and narrowed to cluster-scoped fields.
8595
- *
8596
- * Returns `null` when the addon declared nothing — an addon that opts out has
8597
- * no integration settings surface at all, rather than an empty one that reads
8598
- * as a failed load.
8599
- *
8600
- * Three properties hold BY CONSTRUCTION, which is why they are here in core
8601
- * and not in whichever UI happens to render this:
8602
- *
8603
- * 1. **One key.** The payload is a SUBSET of the global schema, so a field
8604
- * shown here is the same field, with the same bare key, that the addon's
8605
- * own page shows. There is no integration-specific writer — callers save
8606
- * through `updateGlobalSettings` — so a second store key is unreachable,
8607
- * not merely discouraged.
8608
- * 2. **No node scope.** `perNode: true` fields are DROPPED. Their store key
8609
- * is `<key>@<nodeId>` and an integration is not a node; whichever node
8610
- * such a field silently picked would be a wrong answer for the operator
8611
- * who opened the page (D266).
8612
- * 3. **No silent typo.** A declared id that names no section throws. The
8613
- * alternative — skip it — turns a rename into a surface that quietly
8614
- * empties, which looks exactly like an addon with nothing to configure.
8615
- */
8616
- /**
8617
- * The form schema of ONE integration instance, or `null` to use {@link globalSettingsSchema}.
8705
+ * The form schema of ONE integration instance, or `null` to use the scoped form.
8618
8706
  *
8619
8707
  * Override it only when an `instanceMode: multiple` addon's instances differ: an NVR integration
8620
8708
  * needs its connection fields, the default integration the addon's own sections. It is the
@@ -8662,37 +8750,178 @@ var BaseAddon = class {
8662
8750
  }
8663
8751
  }
8664
8752
  /**
8753
+ * Hook: values layered over the stored ones when the FORM of one scope is served
8754
+ * ({@link getScopedSettings}) — a preview that derives dependent options without writing.
8755
+ * Never applied to {@link ScopedSettings.get} or to a write. `null` ⇒ no overlay.
8756
+ */
8757
+ async scopedSettingsOverlay(_scope, _cap, _nodeId) {
8758
+ return null;
8759
+ }
8760
+ /**
8761
+ * Hook: a write of one scope changed stored values (not called when the store reports no change,
8762
+ * e.g. the write-back of a stored secret). `keys` are the bare field keys of the write, node keys included.
8763
+ */
8764
+ async onScopedSettingsChanged(_scope, _cap, _keys) {}
8765
+ /** Typed handle over the CLUSTER settings `cap` declares (`clusterSettingsSchema`). */
8766
+ clusterSettings(cap, schema) {
8767
+ return this.scopedHandle("cluster", cap, schema);
8768
+ }
8769
+ /** Typed handle over the fleet defaults of the per-device settings `cap` declares. */
8770
+ deviceDefaults(cap, schema) {
8771
+ return this.scopedHandle("device-defaults", cap, schema);
8772
+ }
8773
+ /**
8774
+ * Typed handle over the settings `cap` owns PER NODE. `nodeId` omitted ⇒ the local node. A node
8775
+ * with no row yields the schema defaults — never a bare-key fallback.
8776
+ */
8777
+ nodeSettings(cap, schema, nodeId) {
8778
+ return this.scopedHandle("node", cap, schema, nodeId);
8779
+ }
8780
+ /**
8781
+ * {@link state} for a value that is kept per node: stored under `<key>@<nodeId>`, and the
8782
+ * settings store carries `nodeId` in the row data (D986 §1), so a forgotten node's rows go in one
8783
+ * central delete. `nodeId` omitted ⇒ the local node.
8784
+ */
8785
+ nodeState(key, schema, fallback, nodeId) {
8786
+ this._declaredStateKeys.add(key);
8787
+ return createDurableState({
8788
+ key: nodeScopedKey(key, nodeId ?? this._ctx?.kernel?.localNodeId ?? ""),
8789
+ schema,
8790
+ fallback,
8791
+ read: async () => this.resolveStoredSecrets(await this.readAddonStoreWithRetry()),
8792
+ write: async (patch) => {
8793
+ await this._ctx?.settings?.writeAddonStore(patch);
8794
+ },
8795
+ onParseError: (k, e) => this._ctx?.logger?.warn?.(`durable-state: stored "${k}" failed validation — using fallback`, { meta: {
8796
+ addonId: this._ctx?.id,
8797
+ key: k,
8798
+ error: String(e)
8799
+ } })
8800
+ });
8801
+ }
8802
+ /** The loaded schema `cap` declares for `scope`, or `null`. */
8803
+ async declaredScopedSchema(scope, cap) {
8804
+ await this.loadScopedSchemas(cap);
8805
+ return this.loadedScopedSchemas(cap).find((entry) => entry.scope === scope)?.schema ?? null;
8806
+ }
8807
+ async requireScopedSchema(scope, cap) {
8808
+ const schema = await this.declaredScopedSchema(scope, cap);
8809
+ if (schema === null) throw new Error(`${this.constructor.name}: cap "${cap}" declares no ${scope} settings`);
8810
+ return schema;
8811
+ }
8812
+ scopedKeys(schema) {
8813
+ return new Set(schema.sections.flatMap((section) => collectValueFieldKeys(section.fields)));
8814
+ }
8815
+ /** `store` narrowed to the keys `schema` declares. */
8816
+ narrowToScope(store, schema) {
8817
+ const keys = this.scopedKeys(schema);
8818
+ return Object.fromEntries(Object.entries(store).filter(([key]) => keys.has(key)));
8819
+ }
8820
+ scopedHandle(scope, cap, schema, nodeId) {
8821
+ return createScopedSettings({
8822
+ schema,
8823
+ read: async () => {
8824
+ const declared = await this.requireScopedSchema(scope, cap);
8825
+ const stored = this.narrowToScope(await this.resolveGlobalStore(nodeId, cap), declared);
8826
+ const effective = collectHydratedFieldValues(hydrateSchema(declared, stored));
8827
+ return {
8828
+ ...Object.fromEntries([...effective].filter(([, value]) => value !== void 0)),
8829
+ ...stored
8830
+ };
8831
+ },
8832
+ write: (patch) => this.writeScoped(scope, cap, patch, nodeId),
8833
+ unset: (keys) => this.unsetScoped(scope, cap, keys, nodeId)
8834
+ });
8835
+ }
8836
+ /** The one write path of the scoped API: declared keys only, then the global patch. */
8837
+ async writeScoped(scope, cap, patch, nodeId) {
8838
+ assertDeclaredKeys(Object.keys(patch), this.scopedKeys(await this.requireScopedSchema(scope, cap)));
8839
+ if (await this.applyGlobalPatch(patch, scope === "node" ? nodeId : void 0, cap)) await this.onScopedSettingsChanged(scope, cap, Object.keys(patch));
8840
+ }
8841
+ /**
8842
+ * Remove declared keys of one scope. A secret goes through {@link clearSecrets} — its keychain
8843
+ * value is released exactly as there — and the emptied row is then removed; every other key is
8844
+ * removed by an `undefined` patch (which a secret transform would read as "keep").
8845
+ */
8846
+ async unsetScoped(scope, cap, keys, nodeId) {
8847
+ assertDeclaredKeys(keys, this.scopedKeys(await this.requireScopedSchema(scope, cap)));
8848
+ const target = scope === "node" ? nodeId : void 0;
8849
+ const tree = this.addonSecretTree();
8850
+ const secretKeys = keys.filter((key) => tree.has(key));
8851
+ const plainKeys = keys.filter((key) => !tree.has(key));
8852
+ let changed = false;
8853
+ if (plainKeys.length > 0) {
8854
+ const patch = Object.fromEntries(plainKeys.map((key) => [key, void 0]));
8855
+ changed = await this.applyGlobalPatch(patch, target, cap) || changed;
8856
+ }
8857
+ if (secretKeys.length > 0) {
8858
+ await this.clearSecretKeys(secretKeys, target, cap);
8859
+ const node = normalizeNodeId(target ?? this._ctx?.kernel?.localNodeId);
8860
+ const rows = secretKeys.map((key) => scope === "node" ? nodeScopedKey(key, node) : key);
8861
+ if (this._secretSettings !== null) await this._secretSettings.removeClearedKeys(rows);
8862
+ else await this._ctx?.settings?.writeAddonStore(Object.fromEntries(rows.map((row) => [row, void 0])));
8863
+ changed = true;
8864
+ }
8865
+ if (changed) await this.onScopedSettingsChanged(scope, cap, [...keys]);
8866
+ }
8867
+ /**
8868
+ * The hydrated form of one scope of one capability's settings (any
8869
+ * {@link scopedSettingsOverlay} applied), or `null` when the capability declares nothing there.
8870
+ */
8871
+ async getScopedSettings(scope, cap, nodeId) {
8872
+ const schema = await this.declaredScopedSchema(scope, cap);
8873
+ if (schema === null) return null;
8874
+ const stored = this.narrowToScope(await this.readRawProjectedStore(nodeId, cap), schema);
8875
+ const overlay = await this.scopedSettingsOverlay(scope, cap, nodeId);
8876
+ return hydrateSchema(schema, overlay ? await this.overlayKeepingMarkers(stored, overlay) : stored, { inlineSecretsAsViews: true });
8877
+ }
8878
+ /**
8879
+ * The scoped schemas this addon serves: one entry per loaded (capability, scope), capabilities
8880
+ * in declaration order, scopes in {@link SCOPED_SETTINGS_SCOPES} order. `[]` when it declares
8881
+ * nothing.
8882
+ */
8883
+ async listScopedSettings() {
8884
+ await this.loadScopedSchemas();
8885
+ return [...this._scopedByCap].flatMap(([cap, entries]) => entries.map((entry) => ({
8886
+ cap,
8887
+ scope: entry.scope,
8888
+ sectionIds: entry.schema.sections.map((section) => section.id)
8889
+ })));
8890
+ }
8891
+ /** The OPERATOR's write of declared keys of one scope (D787 secret semantics). */
8892
+ async updateScopedSettings(scope, cap, patch, nodeId) {
8893
+ this._operatorWriteDepth++;
8894
+ try {
8895
+ await this.writeScoped(scope, cap, patch, nodeId);
8896
+ } finally {
8897
+ this._operatorWriteDepth--;
8898
+ }
8899
+ }
8900
+ /**
8901
+ * The effective values (`stored ?? default`) of one scope, a secret as its `set` view — never
8902
+ * its value. `null` when the capability declares nothing for the scope.
8903
+ */
8904
+ async readScopedValues(scope, cap, nodeId) {
8905
+ const schema = await this.declaredScopedSchema(scope, cap);
8906
+ if (schema === null) return null;
8907
+ const form = hydrateSchema(schema, this.narrowToScope(await this.readRawProjectedStore(nodeId, cap), schema), { inlineSecretsAsViews: true });
8908
+ return Object.fromEntries([...collectHydratedFieldValues(form)].filter(([, value]) => value !== void 0));
8909
+ }
8910
+ /**
8665
8911
  * What the create wizard and the integration edit page render for one instance: the addon's
8666
8912
  * per-instance schema when it declares one, else its global schema (what they always showed).
8667
8913
  */
8668
8914
  async getIntegrationFormSchema(instance, nodeId) {
8669
8915
  const scoped = await this.integrationFormSchema(instance);
8670
- if (scoped === null) return this.getGlobalSettings(void 0, void 0, nodeId);
8916
+ if (scoped === null) return this.scopedForm(nodeId);
8671
8917
  return hydrateSchema(scoped, {}, { inlineSecretsAsViews: true });
8672
8918
  }
8673
- async getIntegrationSettings(nodeId) {
8674
- const declared = this.integrationSettingSections();
8675
- if (declared.length === 0) return null;
8676
- const schema = this.globalSettingsSchema();
8677
- if (!schema) throw new Error(`${this.constructor.name}: integrationSettingSections() names [${declared.join(", ")}] but globalSettingsSchema() returns null.`);
8678
- const byId = new Map(schema.sections.map((section) => [section.id, section]));
8679
- const sections = [];
8680
- for (const id of declared) {
8681
- const section = byId.get(id);
8682
- if (!section) throw new Error(`${this.constructor.name}: integrationSettingSections() names unknown section "${id}". Known sections: [${[...byId.keys()].join(", ")}].`);
8683
- const fields = dropPerNodeFields(section.fields);
8684
- if (fields.length === 0) continue;
8685
- sections.push({
8686
- ...section,
8687
- fields
8688
- });
8689
- }
8690
- if (sections.length === 0) return null;
8691
- const projected = await this.readRawProjectedStore(nodeId);
8692
- return hydrateSchema({
8693
- ...schema,
8694
- sections
8695
- }, projected, { inlineSecretsAsViews: true });
8919
+ /** The form of the scoped schemas this addon declared, hydrated from its store. */
8920
+ async scopedForm(nodeId) {
8921
+ await this.loadScopedSchemas();
8922
+ const schema = this.scopedFormSchema();
8923
+ if (!schema) return { sections: [] };
8924
+ return hydrateSchema(schema, await this.readRawProjectedStore(nodeId), { inlineSecretsAsViews: true });
8696
8925
  }
8697
8926
  /**
8698
8927
  * The raw addon store PROJECTED onto the target node's bare per-node keys:
@@ -8701,8 +8930,8 @@ var BaseAddon = class {
8701
8930
  * bare fallback), all `@`-scoped and stray bare per-node keys are dropped.
8702
8931
  * A no-op passthrough when the schema declares no `perNode` field.
8703
8932
  *
8704
- * This is the sanctioned way for a `getGlobalSettings` OVERRIDE that needs
8705
- * the store for custom option logic (option narrowing, value snapping) to
8933
+ * This is the sanctioned way for an addon that needs
8934
+ * the store for custom logic (option narrowing, value snapping) to
8706
8935
  * read it per-node — never `ctx.settings.readAddonStore()` directly.
8707
8936
  * `nodeId` omitted ⇒ the local node (node-blind injection from ctx).
8708
8937
  *
@@ -8754,7 +8983,7 @@ var BaseAddon = class {
8754
8983
  }
8755
8984
  /**
8756
8985
  * Whether ONE global key of this addon's store was written, read three-way
8757
- * (D651). For a question a hydrated view cannot answer: `getGlobalSettings`
8986
+ * (D651). For a question a hydrated view cannot answer: a hydrated form
8758
8987
  * reports `value ?? default`, so "the operator chose the default" and "nobody
8759
8988
  * chose" look the same, and a failed read looks like both. A `perNode` key is
8760
8989
  * not supported here: its stored name is scoped.
@@ -8788,7 +9017,7 @@ var BaseAddon = class {
8788
9017
  }
8789
9018
  /**
8790
9019
  * The OPERATOR's write — a settings form or an admin API call, dispatched by
8791
- * the kernel. Identical to {@link updateGlobalSettings}, except that a secret
9020
+ * the kernel. The one in-process write of the addon blob that is not a scoped write; a secret
8792
9021
  * the operator sends is stored as sent even when it equals a pre-keychain
8793
9022
  * inline value: the operator re-entering a password is a change, an addon
8794
9023
  * writing back what it read is not (D787).
@@ -8801,9 +9030,6 @@ var BaseAddon = class {
8801
9030
  this._operatorWriteDepth--;
8802
9031
  }
8803
9032
  }
8804
- async updateGlobalSettings(patch, nodeId) {
8805
- await this.applyGlobalPatch(patch, nodeId);
8806
- }
8807
9033
  /**
8808
9034
  * REMOVE stored secrets — their keychain values and their markers (D787).
8809
9035
  *
@@ -8813,6 +9039,9 @@ var BaseAddon = class {
8813
9039
  * a keychain (an older kernel) it writes `''`, as such code always did.
8814
9040
  */
8815
9041
  async clearSecrets(keys, nodeId) {
9042
+ await this.clearSecretKeys(keys, nodeId);
9043
+ }
9044
+ async clearSecretKeys(keys, nodeId, cap) {
8816
9045
  const tree = this.addonSecretTree();
8817
9046
  const keychain = this._ctx?.secrets !== void 0;
8818
9047
  const stored = keychain ? await this.readAddonStoreWithRetry() : {};
@@ -8825,25 +9054,26 @@ var BaseAddon = class {
8825
9054
  const keychainStored = tree.has(key) || collectSecretMarkerRefs(stored[key]).length > 0;
8826
9055
  patch[key] = keychain && keychainStored ? SECRET_CLEAR : "";
8827
9056
  }
8828
- await this.applyGlobalPatch(patch, nodeId);
9057
+ await this.applyGlobalPatch(patch, nodeId, cap);
8829
9058
  }
8830
- async applyGlobalPatch(barePatch, nodeId) {
8831
- await this.loadScopedSchemas();
8832
- const keys = this.perNodeKeys();
9059
+ /** Resolves `true` when the write changed stored values. */
9060
+ async applyGlobalPatch(barePatch, nodeId, cap) {
9061
+ await this.loadScopedSchemas(cap);
9062
+ const keys = this.perNodeKeys(cap);
8833
9063
  const localNode = normalizeNodeId(this._ctx?.kernel?.localNodeId);
8834
9064
  const target = normalizeNodeId(nodeId ?? this._ctx?.kernel?.localNodeId);
8835
9065
  const scoped = keys.size > 0 ? scopePatch(barePatch, keys, target) : barePatch;
8836
9066
  const handle = this._secretSettings;
8837
9067
  if (handle !== null) {
8838
9068
  const { changed } = await handle.writeAddonStore(scoped);
8839
- if (!changed) return;
9069
+ if (!changed) return false;
8840
9070
  } else await this._ctx?.settings?.writeAddonStore(scoped);
8841
- if (target !== localNode) return;
9071
+ if (target !== localNode) return true;
8842
9072
  await this.resolveConfig();
8843
9073
  await this.onConfigChanged();
8844
9074
  this.emitLifecycle(EventCategory.AddonUpdated, { level: "global" });
8845
- const legacy = this.globalSettingsSchema();
8846
- this.maybeAutoRestart(Object.keys(barePatch), [...legacy === null ? [] : [legacy], ...this.loadedScopedSchemas().map((entry) => entry.schema)]);
9075
+ this.maybeAutoRestart(Object.keys(barePatch), this.loadedScopedSchemas().map((entry) => entry.schema));
9076
+ return true;
8847
9077
  }
8848
9078
  /**
8849
9079
  * The set of field keys the global settings schema declares `perNode: true`
@@ -8880,10 +9110,7 @@ var BaseAddon = class {
8880
9110
  this._nodeKeysByCap = /* @__PURE__ */ new Map();
8881
9111
  this._addonSecretTree = null;
8882
9112
  }
8883
- /**
8884
- * The form the settings API serves while an addon declares no {@link globalSettingsSchema}: the
8885
- * sections of its scoped schemas, so dropping the old hook does not blank the form.
8886
- */
9113
+ /** The form of an addon's scoped schemas: their sections, each shown once. */
8887
9114
  scopedFormSchema(cap) {
8888
9115
  const byId = /* @__PURE__ */ new Map();
8889
9116
  for (const entry of this.loadedScopedSchemas(cap)) for (const section of entry.schema.sections) if (!byId.has(section.id)) byId.set(section.id, section);
@@ -8895,8 +9122,7 @@ var BaseAddon = class {
8895
9122
  return [...this._scopedByCap.values()].flat();
8896
9123
  }
8897
9124
  /**
8898
- * The field keys that are stored per node: every field of a {@link nodeSettingsSchema}, plus
8899
- * the fields the legacy {@link globalSettingsSchema} still marks `perNode: true`. Derived once
9125
+ * The field keys that are stored per node: every field of a {@link nodeSettingsSchema}. Derived once
8900
9126
  * per `cap` argument and memoized (schemas are static declarations). Empty set ⇒ every
8901
9127
  * per-node code path is bypassed and the settings API behaves like the node-agnostic one.
8902
9128
  * Call {@link loadScopedSchemas} first (the async seams do).
@@ -8905,8 +9131,7 @@ var BaseAddon = class {
8905
9131
  const cacheKey = cap ?? "";
8906
9132
  const cached = this._nodeKeysByCap.get(cacheKey);
8907
9133
  if (cached) return cached;
8908
- const legacy = this.globalSettingsSchema(cap);
8909
- const keys = new Set(legacy ? legacy.sections.flatMap((section) => collectPerNodeFieldKeys(section.fields)) : []);
9134
+ const keys = /* @__PURE__ */ new Set();
8910
9135
  for (const { scope, schema } of this.loadedScopedSchemas(cap)) {
8911
9136
  if (scope !== "node") continue;
8912
9137
  for (const section of schema.sections) for (const key of collectValueFieldKeys(section.fields)) keys.add(key);
@@ -9124,8 +9349,6 @@ var BaseAddon = class {
9124
9349
  }
9125
9350
  declaredKeySet() {
9126
9351
  const keys = new Set(Object.keys(this.defaults));
9127
- const schema = this.globalSettingsSchema();
9128
- if (schema) for (const section of schema.sections) for (const key of collectFieldKeys(section.fields)) keys.add(key);
9129
9352
  for (const { schema: scoped } of this.loadedScopedSchemas()) for (const section of scoped.sections) for (const key of collectFieldKeys(section.fields)) keys.add(key);
9130
9353
  for (const key of this._declaredStateKeys) keys.add(key);
9131
9354
  for (const path of this.secretStatePaths) {
@@ -9223,7 +9446,7 @@ var BaseAddon = class {
9223
9446
  /** The addon store's secret tree: schema fields by TYPE, plus `secretStatePaths`. */
9224
9447
  addonSecretTree() {
9225
9448
  if (this._addonSecretTree === null) {
9226
- const tree = new Map(secretTreeFromSchema(this.globalSettingsSchema()));
9449
+ const tree = /* @__PURE__ */ new Map();
9227
9450
  for (const { schema } of this.loadedScopedSchemas()) for (const [key, node] of secretTreeFromSchema(schema)) tree.set(key, node);
9228
9451
  this._addonSecretTree = mergeSecretStatePaths(tree, this.secretStatePaths);
9229
9452
  }
@@ -9435,47 +9658,6 @@ function classifyStoreError(err) {
9435
9658
  if (TRANSPORT_PHRASES.some((f) => message.includes(f))) return "transport";
9436
9659
  return "permanent";
9437
9660
  }
9438
- /**
9439
- * Collect the keys of every field marked `perNode: true`, recursing into
9440
- * layout containers (`group` fields and `sub-tabs` tabs) the same way
9441
- * `hydrateSchema` does. Valueless structural fields (separator/info/…)
9442
- * don't declare `perNode` and are excluded by the `in` narrowing.
9443
- */
9444
- /**
9445
- * The same fields with every `perNode: true` one removed, recursing into layout
9446
- * containers exactly as {@link collectPerNodeFieldKeys} does. A container left
9447
- * with no child is dropped rather than rendered empty.
9448
- *
9449
- * Used by `getIntegrationSettings`: an integration is not a node, so a field
9450
- * whose store key is `<key>@<nodeId>` has no node to belong to there.
9451
- */
9452
- function dropPerNodeFields(fields) {
9453
- const kept = [];
9454
- for (const field of fields) {
9455
- if (field.type === "group") {
9456
- const inner = dropPerNodeFields(field.fields);
9457
- if (inner.length > 0) kept.push({
9458
- ...field,
9459
- fields: inner
9460
- });
9461
- continue;
9462
- }
9463
- if (field.type === "sub-tabs") {
9464
- const tabs = field.tabs.map((tab) => ({
9465
- ...tab,
9466
- fields: dropPerNodeFields(tab.fields)
9467
- })).filter((tab) => tab.fields.length > 0);
9468
- if (tabs.length > 0) kept.push({
9469
- ...field,
9470
- tabs
9471
- });
9472
- continue;
9473
- }
9474
- if ("perNode" in field && field.perNode === true) continue;
9475
- kept.push(field);
9476
- }
9477
- return kept;
9478
- }
9479
9661
  /** The keys of the value-holding fields, recursing into layout containers. */
9480
9662
  function collectValueFieldKeys(fields) {
9481
9663
  const collected = [];
@@ -9508,21 +9690,6 @@ function collectFieldKeys(fields) {
9508
9690
  }
9509
9691
  return collected;
9510
9692
  }
9511
- function collectPerNodeFieldKeys(fields) {
9512
- const collected = [];
9513
- for (const field of fields) {
9514
- if (field.type === "group") {
9515
- collected.push(...collectPerNodeFieldKeys(field.fields));
9516
- continue;
9517
- }
9518
- if (field.type === "sub-tabs") {
9519
- for (const tab of field.tabs) collected.push(...collectPerNodeFieldKeys(tab.fields));
9520
- continue;
9521
- }
9522
- if ("perNode" in field && field.perNode === true) collected.push(field.key);
9523
- }
9524
- return collected;
9525
- }
9526
9693
  /**
9527
9694
  * Normalize an `ICamstackAddon.initialize()` return value into the
9528
9695
  * `AddonInitResult` envelope. Arrays are wrapped into `{ providers }`;
@@ -10616,7 +10783,6 @@ var CAP_NAMES = Object.freeze([
10616
10783
  "notifier",
10617
10784
  "numeric-sensor",
10618
10785
  "oauth-integration",
10619
- "oidc-connections",
10620
10786
  "osd",
10621
10787
  "osd-manager",
10622
10788
  "pet-feeder",
@@ -12323,13 +12489,25 @@ Object.freeze({
12323
12489
  "path": "temperature",
12324
12490
  "valueType": "number"
12325
12491
  }],
12326
- "timed-run": [{
12327
- "path": "activeUntil",
12328
- "valueType": "number"
12329
- }, {
12330
- "path": "requestedBy",
12331
- "valueType": "string"
12332
- }],
12492
+ "timed-run": [
12493
+ {
12494
+ "path": "activeUntil",
12495
+ "valueType": "number"
12496
+ },
12497
+ {
12498
+ "path": "requestedBy",
12499
+ "valueType": "string"
12500
+ },
12501
+ {
12502
+ "path": "quickRun.duration",
12503
+ "valueType": "number"
12504
+ },
12505
+ {
12506
+ "path": "quickRun.unit",
12507
+ "valueType": "enum",
12508
+ "enumValues": ["s", "min"]
12509
+ }
12510
+ ],
12333
12511
  "update": [
12334
12512
  {
12335
12513
  "path": "currentVersion",
@@ -12508,8 +12686,7 @@ Object.freeze({
12508
12686
  "device-provider": { "reloadDevice": 18e4 },
12509
12687
  "llm": {
12510
12688
  "generate": 6e5,
12511
- "generateVision": 6e5,
12512
- "testProfile": 6e5
12689
+ "generateVision": 6e5
12513
12690
  },
12514
12691
  "llm-runtime": {
12515
12692
  "complete": 6e5,
@@ -12554,7 +12731,7 @@ object({
12554
12731
  params: record(string(), union([string(), number()])).optional()
12555
12732
  });
12556
12733
  //#endregion
12557
- //#region ../types/dist/composition-BmBHuDTQ.mjs
12734
+ //#region ../types/dist/composition-Bx0JvKUU.mjs
12558
12735
  /**
12559
12736
  * The ffmpeg build every CamStack node downloads, per platform and arch.
12560
12737
  *
@@ -13716,442 +13893,828 @@ var NodeColorIdSchema = _enum([
13716
13893
  "node-h"
13717
13894
  ]);
13718
13895
  //#endregion
13719
- //#region ../types/dist/index.mjs
13720
- var SMTP_INBOUND_DEFAULT_PORT = 2525;
13721
- var SMTP_INBOUND_DEFAULT_DOMAIN = "camstack.local";
13722
- var SMTP_INBOUND_DEFAULT_MAX_MESSAGE_BYTES = 25 * 1024 * 1024;
13723
- /** The text excerpt a message carries on the bus. */
13724
- var SMTP_INBOUND_TEXT_MAX_CHARS = 4096;
13725
- var PortSchema = number().int().min(1).max(65535);
13726
- /** A recipient local-part: what stands before the `@`. */
13727
- var SmtpRecipientSchema = string().min(1).max(64).regex(/^[A-Za-z0-9._+-]+$/);
13728
- object({
13729
- port: PortSchema.default(SMTP_INBOUND_DEFAULT_PORT),
13730
- bindHost: string().min(1).default("0.0.0.0"),
13731
- domain: string().min(1).default(SMTP_INBOUND_DEFAULT_DOMAIN),
13732
- requireAuth: boolean().default(true),
13733
- username: string().default(""),
13734
- password: string().default("").meta({ secret: true }),
13735
- starttls: boolean().default(false),
13736
- maxMessageBytes: number().int().positive().default(SMTP_INBOUND_DEFAULT_MAX_MESSAGE_BYTES)
13737
- });
13738
- object({
13739
- host: string().min(1).nullable(),
13740
- hostReason: string().nullable(),
13741
- port: PortSchema,
13742
- domain: string().min(1),
13743
- requireAuth: boolean(),
13744
- username: string(),
13745
- password: string(),
13746
- starttls: boolean()
13747
- });
13748
- object({
13749
- recipients: array(SmtpRecipientSchema).min(1),
13750
- /**
13751
- * Who is subscribing. A second `subscribe` with the same id REPLACES that subscriber's
13752
- * recipients (the way a consumer that restarted, or lost a device, declares its set again);
13753
- * a recipient held by another subscriber is refused with `smtp-inbound/recipient-claimed`.
13754
- * Absent, the subscriber is anonymous and unique.
13755
- */
13756
- subscriberId: string().min(1).max(64).optional()
13757
- });
13758
- var SmtpInboundAttachmentSchema = object({
13759
- filename: string(),
13760
- contentType: string(),
13761
- bytes: number().int().nonnegative()
13762
- });
13763
- /** The payload of one `broker.message` (the key is the recipient local-part). */
13764
- var SmtpInboundMessageSchema = object({
13765
- /** Monotonic per mailbox; a gap tells a consumer it missed an event. */
13766
- seq: number().int().positive(),
13767
- messageId: string(),
13768
- receivedAt: number().int().nonnegative(),
13769
- from: string(),
13770
- to: string(),
13771
- subject: string(),
13772
- text: string().max(SMTP_INBOUND_TEXT_MAX_CHARS),
13773
- attachments: array(SmtpInboundAttachmentSchema)
13774
- });
13775
- object({
13776
- /** The newest seq issued so far (0 before any mail). */
13777
- lastSeq: number().int().nonnegative(),
13778
- /** The oldest seq still retained; messages below it are gone. */
13779
- oldestSeq: number().int().nonnegative(),
13780
- messages: array(object({
13781
- key: string(),
13782
- message: SmtpInboundMessageSchema
13783
- }))
13784
- });
13785
- new Set([
13786
- "track",
13787
- "face",
13788
- "identity",
13789
- "plate",
13790
- "vehicle",
13791
- "scene",
13792
- "motion",
13793
- "object",
13794
- "audio",
13795
- "mosaic"
13796
- ]);
13797
- /**
13798
- * The owner types that are event tables, in the order the event-media resolver
13799
- * should consider them. Exported so a consumer asking "is this key an event?"
13800
- * does not re-spell the list and drift from it.
13801
- */
13802
- var EVENT_OWNER_TYPES = [
13803
- "motion",
13804
- "object",
13805
- "audio"
13806
- ];
13807
- /**
13808
- * The same list as a Zod enum, for the cap inputs that must NAME the table
13809
- * (D482: `getEventMedia` / `listEventMedia` take an owner, and an owner is
13810
- * `(table, id)`).
13811
- *
13812
- * Built FROM {@link EVENT_OWNER_TYPES} rather than re-spelled: a fourth event
13813
- * table would otherwise be accepted by the codec and refused at the door, with
13814
- * nothing failing until a caller asked.
13815
- */
13816
- var EventOwnerTypeSchema = _enum(EVENT_OWNER_TYPES);
13817
- /** The same list as a Zod enum, for the cap input that carries it. */
13818
- var MediaPresenceOwnerKindSchema = _enum([...EVENT_OWNER_TYPES, "track"]);
13819
- new Set(EVENT_OWNER_TYPES);
13820
- /**
13821
- * What a published package needs from the rest of the install (D989).
13822
- *
13823
- * One published framework package (`@camstack/server`) carries the kernel, the
13824
- * builtins and the capability contracts, so "which addon runs on which
13825
- * framework" is a question of version, and the answer is DECLARED by the
13826
- * package that knows it:
13827
- *
13828
- * - an addon says the oldest server it runs on (`requires.server: ">=X"`);
13829
- * - the server says the oldest addon it works with
13830
- * (`requires.addons: { "@camstack/addon-x": ">=Y" }`) and the oldest shell
13831
- * around it (`requires.wrapper: { desktop, image }`);
13832
- * - a wrapper (the desktop app, the container starter) says which server
13833
- * range it can host, and reports its own kind and version.
13834
- *
13835
- * The publish workflow STAMPS these after the version bump
13836
- * (`scripts/ci/stamp-requires.mjs`); nobody types a number by hand.
13837
- *
13838
- * A requirement that cannot be checked is NOT met: a shell that reports no
13839
- * version counts as below the minimum, and an unreadable running version is
13840
- * named in the result (a failed read is never a pass).
13841
- */
13842
- /** `>=MAJOR.MINOR.PATCH[-prerelease]` — the only range shape a requirement uses. */
13843
- var MinVersionSchema = string().regex(/^>=\d+\.\d+\.\d+(-[0-9A-Za-z.-]+)?$/, "a minimum is written \">=X.Y.Z\"");
13844
- object({
13845
- /** The oldest `@camstack/server` this package runs on. */
13846
- server: MinVersionSchema.optional(),
13847
- /** The oldest installed version of each named addon package. */
13848
- addons: record(string(), MinVersionSchema).optional(),
13849
- /** The oldest shell around the server, per shell kind. */
13850
- wrapper: object({
13851
- desktop: MinVersionSchema.optional(),
13852
- image: MinVersionSchema.optional()
13853
- }).optional()
13854
- });
13855
- /** One unmet requirement; each names the versions on both sides. */
13856
- var UnmetRequirementSchema = discriminatedUnion("kind", [
13857
- object({
13858
- kind: literal("server-too-old"),
13859
- required: string(),
13860
- /** `null` — the running server version could not be read. */
13861
- running: string().nullable()
13862
- }),
13863
- object({
13864
- kind: literal("addon-too-old"),
13865
- packageName: string(),
13866
- required: string(),
13867
- /** `null` — the addon is not installed (or its version is unreadable). */
13868
- running: string().nullable()
13869
- }),
13870
- object({
13871
- kind: literal("wrapper-too-old"),
13872
- wrapper: _enum(["desktop", "image"]),
13873
- required: string(),
13874
- /** `null` — the wrapper reported no version. */
13875
- running: string().nullable()
13876
- })
13877
- ]);
13878
- var RequiredAddonUpdateSchema = object({
13879
- packageName: string(),
13880
- /** The minimum the target server declares. */
13881
- required: string(),
13882
- /** What this node has; `null` when the addon is not installed. */
13883
- installed: string().nullable()
13884
- });
13885
- /**
13886
- * Which integration instance a settings form is for. An addon that serves several instances
13887
- * (`instanceMode: multiple`) can show a different form per instance — an NVR integration
13888
- * needs its connection, the default integration needs the addon's own sections.
13889
- *
13890
- * - `integrationId` is `null` in the create wizard: nothing exists yet, the operator is
13891
- * setting up a NEW instance.
13892
- * - `mode` is the wizard mode of the integration type (`getAvailableTypes`).
13893
- * - `candidateStableId` is the discovery candidate a wizard was seeded from, if any.
13894
- */
13895
- var IntegrationInstanceRefSchema = object({
13896
- integrationId: string().nullable(),
13897
- mode: _enum([
13898
- "standalone",
13899
- "account",
13900
- "broker"
13901
- ]),
13902
- candidateStableId: string().optional()
13903
- });
13904
- /**
13905
- * notification-output — canonical, capability-gated notification delivery.
13906
- *
13907
- * Apprise-derived model (see
13908
- * `docs/superpowers/specs/2026-07-03-notification-output-notifier-matrix.md`):
13909
- * callers emit ONE canonical `Notification`; each provider declares a
13910
- * per-kind capability descriptor (`TargetKind`), and the pure degrade
13911
- * engine (`@camstack/types` `prepareNotification`) transcodes / degrades the
13912
- * message to what the kind supports — callers never special-case a service.
13913
- *
13914
- * DESIGN DECISIONS (locked):
13915
- * - Target CRUD lives on THIS cap (`upsertTarget` / `deleteTarget` /
13916
- * `setTargetEnabled`), each provider persisting via the `settings-store`
13917
- * cap. Rationale: the admin UI needs one uniform surface across the
13918
- * notifiers addon AND the HA addon; the addon-`globalSettingsSchema`-array
13919
- * alternative would fork the UI per addon and cannot host the
13920
- * discovery→adopt flow.
13921
- * - `listTargetKinds` / `listTargets` / `discoverTargets` return arrays →
13922
- * the generated cap-mount auto-`concatCollection`-fans them across every
13923
- * registered provider (notifiers addon + HA addon) so one catalog is
13924
- * routable. `send` / `testTarget` / CRUD route to ONE provider by the
13925
- * `addonId` the generated collection router extracts from the call input.
13926
- * - `Attachment.bytes` is `Uint8Array`. Transport-safe: superjson (the tRPC
13927
- * transformer) + UDS MsgPack both round-trip typed arrays — already used by
13928
- * `storage` / `storage-provider` / `recording` caps over the same path. No
13929
- * base64 fallback needed.
13930
- *
13931
- * TODO (deferred, closed-set change — separate decision): add
13932
- * `providerKind: 'notify'` so notification providers surface on the unified
13933
- * admin "Integrations" page.
13934
- */
13935
- /**
13936
- * Zentik-derived typed-media enum — the superset across every kind. Each
13937
- * adapter picks what it supports and the degrade engine filters the rest.
13938
- */
13939
- var AttachmentMediaTypeSchema = _enum([
13940
- "image",
13941
- "video",
13942
- "gif",
13943
- "audio",
13944
- "icon"
13945
- ]);
13946
- /**
13947
- * A single attachment. Exactly one of `url` (remote source, most adapters
13948
- * prefer this) or `bytes` (inline source; required for Pushover-style
13949
- * bytes-only kinds) MUST be present — the degrade engine expresses a
13950
- * url→bytes fetch as a `needsFetch` directive the adapter executes.
13951
- */
13952
- var AttachmentSchema = object({
13953
- mediaType: AttachmentMediaTypeSchema,
13954
- url: string().optional(),
13955
- bytes: _instanceof(Uint8Array).optional(),
13956
- mime: string().optional(),
13957
- name: string().optional()
13958
- }).refine((a) => a.url !== void 0 || a.bytes !== void 0, { message: "Attachment requires either `url` or `bytes`" });
13959
- var NotificationFormatSchema = _enum([
13960
- "text",
13961
- "markdown",
13962
- "html"
13963
- ]);
13896
+ //#region ../types/dist/convert-BAzH15HU.mjs
13964
13897
  /**
13965
- * The CLOSED icon vocabulary an action button may use.
13966
- *
13967
- * A closed set, not a free string, and that is the whole point: an arbitrary
13968
- * icon name is one that ntfy renders, zentik silently drops, and nobody
13969
- * notices — the same class of gap as a zone vocabulary nothing produced
13970
- * ([D35](../../../docs/decisions/adr-0035.md)). Every adapter maps this set or
13971
- * declares `actionIcons: false` and the degrade engine strips the field.
13972
- *
13973
- * Named by INTENT, never by glyph. "check" would tie the vocabulary to one
13974
- * renderer's icon set; "acknowledge" survives an adapter that draws it
13975
- * differently.
13976
- *
13977
- * ── A TOKEN IS NOT A WIRE VALUE ─────────────────────────────────────
13978
- *
13979
- * These names are for US. **No adapter may forward one verbatim.** Each maps
13980
- * the whole set onto its own renderer's vocabulary through a
13981
- * `Record<NotificationActionIcon, string>` — a Record, never a lookup with a
13982
- * fallback, so adding a member here fails every adapter's build until someone
13983
- * decides its glyph, which is the only place that decision can be made
13984
- * honestly.
13985
- *
13986
- * This paragraph is the bug. Zentik declared `actionIcons: true` and passed
13987
- * `disarm` straight through; iOS feeds that string to
13988
- * `UNNotificationActionIcon(systemImageName:)`, `disarm` is not an SF Symbol,
13989
- * and every snooze and alarm button arrived BLANK. A pass-through is not a
13990
- * mapping, and "the field is documented" is not "the value renders".
13991
- *
13992
- * Adding a member is TRAIN-BOUND. The enum lives in the published
13993
- * `@camstack/server` closure and the cap seam validates against the HUB's copy,
13994
- * so an addon that emits a token the running hub does not know does not lose an
13995
- * icon — its whole `send` fails Zod validation and the notification never
13996
- * arrives. Never emit a new token from an addon before the train carrying it.
13898
+ * Frozen unit → spec table. `•` in the doc marks each dimension's canonical
13899
+ * unit (`factor: 1, offset: 0`). °F derives from `°C = (°F − 32) × 5/9` ⇒
13900
+ * `factor = 5/9`, `offset = -160/9` (kept as exact expressions, not rounded
13901
+ * decimals). K derives from `°C = K − 273.15`.
13997
13902
  */
13998
- var NotificationActionIconSchema = _enum([
13999
- "acknowledge",
14000
- "dismiss",
14001
- "silence",
14002
- "snooze",
14003
- "view",
14004
- "play",
14005
- "open",
14006
- "close",
14007
- "lock",
14008
- "unlock",
14009
- "arm",
14010
- "arm-home",
14011
- "arm-away",
14012
- "arm-night",
14013
- "disarm",
14014
- "light",
14015
- "alert",
14016
- "camera"
14017
- ]);
14018
- /** A single tap-through action button. */
14019
- var NotificationActionSchema = object({
14020
- id: string(),
14021
- label: string(),
14022
- url: string().optional(),
14023
- /** Dropped by the degrade engine for a kind with `caps.actionIcons: false`. */
14024
- icon: NotificationActionIconSchema.optional(),
14025
- /**
14026
- * Renders in a warning style where the notifier supports it.
14027
- *
14028
- * A HINT, never a gate. The callback's authority is its token and nothing
14029
- * else — see `notification-center/action-token.ts` for what that does and
14030
- * does not buy.
14031
- */
14032
- destructive: boolean().optional(),
14033
- /**
14034
- * How the tap should REACH the url.
14035
- *
14036
- * `navigate` (absent, and every button authored before this field) opens it:
14037
- * the phone leaves the notification and shows whatever the callback returns.
14038
- * That is right for a button whose answer the operator wants to read.
14039
- *
14040
- * `background` fires it as a POST and stays put. It exists for the buttons
14041
- * whose whole point is not to interrupt — "silence this for 30 minutes" is
14042
- * an answer to the notification, and being thrown into a browser tab to
14043
- * confirm it costs more attention than the notification did. A backend that
14044
- * cannot do a background call renders it as an ordinary link (the adapters
14045
- * fall back rather than dropping the button), so this is a preference, never
14046
- * a requirement.
14047
- */
14048
- mode: _enum(["navigate", "background"]).optional()
14049
- });
14050
- /** A delivery parameter value: what a notifier declared it takes. */
14051
- var DeliveryParamValueSchema = union([
14052
- string(),
14053
- number(),
14054
- boolean()
14055
- ]);
13903
+ var UNIT_TABLE = {
13904
+ "°C": {
13905
+ dimension: "temperature",
13906
+ factor: 1,
13907
+ offset: 0
13908
+ },
13909
+ "°F": {
13910
+ dimension: "temperature",
13911
+ factor: 5 / 9,
13912
+ offset: -160 / 9
13913
+ },
13914
+ K: {
13915
+ dimension: "temperature",
13916
+ factor: 1,
13917
+ offset: -273.15
13918
+ },
13919
+ hPa: {
13920
+ dimension: "pressure",
13921
+ factor: 1,
13922
+ offset: 0
13923
+ },
13924
+ kPa: {
13925
+ dimension: "pressure",
13926
+ factor: 10,
13927
+ offset: 0
13928
+ },
13929
+ Pa: {
13930
+ dimension: "pressure",
13931
+ factor: .01,
13932
+ offset: 0
13933
+ },
13934
+ mbar: {
13935
+ dimension: "pressure",
13936
+ factor: 1,
13937
+ offset: 0
13938
+ },
13939
+ bar: {
13940
+ dimension: "pressure",
13941
+ factor: 1e3,
13942
+ offset: 0
13943
+ },
13944
+ inHg: {
13945
+ dimension: "pressure",
13946
+ factor: 33.8639,
13947
+ offset: 0
13948
+ },
13949
+ mmHg: {
13950
+ dimension: "pressure",
13951
+ factor: 1.33322,
13952
+ offset: 0
13953
+ },
13954
+ psi: {
13955
+ dimension: "pressure",
13956
+ factor: 68.9476,
13957
+ offset: 0
13958
+ },
13959
+ "m/s": {
13960
+ dimension: "speed",
13961
+ factor: 1,
13962
+ offset: 0
13963
+ },
13964
+ "km/h": {
13965
+ dimension: "speed",
13966
+ factor: 1 / 3.6,
13967
+ offset: 0
13968
+ },
13969
+ mph: {
13970
+ dimension: "speed",
13971
+ factor: .44704,
13972
+ offset: 0
13973
+ },
13974
+ kn: {
13975
+ dimension: "speed",
13976
+ factor: .514444,
13977
+ offset: 0
13978
+ },
13979
+ "mm/h": {
13980
+ dimension: "precipitation-rate",
13981
+ factor: 1,
13982
+ offset: 0
13983
+ },
13984
+ "in/h": {
13985
+ dimension: "precipitation-rate",
13986
+ factor: 25.4,
13987
+ offset: 0
13988
+ },
13989
+ m: {
13990
+ dimension: "length",
13991
+ factor: 1,
13992
+ offset: 0
13993
+ },
13994
+ mm: {
13995
+ dimension: "length",
13996
+ factor: .001,
13997
+ offset: 0
13998
+ },
13999
+ cm: {
14000
+ dimension: "length",
14001
+ factor: .01,
14002
+ offset: 0
14003
+ },
14004
+ km: {
14005
+ dimension: "length",
14006
+ factor: 1e3,
14007
+ offset: 0
14008
+ },
14009
+ in: {
14010
+ dimension: "length",
14011
+ factor: .0254,
14012
+ offset: 0
14013
+ },
14014
+ ft: {
14015
+ dimension: "length",
14016
+ factor: .3048,
14017
+ offset: 0
14018
+ },
14019
+ mi: {
14020
+ dimension: "length",
14021
+ factor: 1609.344,
14022
+ offset: 0
14023
+ },
14024
+ "m²": {
14025
+ dimension: "area",
14026
+ factor: 1,
14027
+ offset: 0
14028
+ },
14029
+ lx: {
14030
+ dimension: "illuminance",
14031
+ factor: 1,
14032
+ offset: 0
14033
+ },
14034
+ "W/m²": {
14035
+ dimension: "irradiance",
14036
+ factor: 1,
14037
+ offset: 0
14038
+ },
14039
+ W: {
14040
+ dimension: "power",
14041
+ factor: 1,
14042
+ offset: 0
14043
+ },
14044
+ kW: {
14045
+ dimension: "power",
14046
+ factor: 1e3,
14047
+ offset: 0
14048
+ },
14049
+ VA: {
14050
+ dimension: "apparent-power",
14051
+ factor: 1,
14052
+ offset: 0
14053
+ },
14054
+ Wh: {
14055
+ dimension: "energy",
14056
+ factor: 1,
14057
+ offset: 0
14058
+ },
14059
+ kWh: {
14060
+ dimension: "energy",
14061
+ factor: 1e3,
14062
+ offset: 0
14063
+ },
14064
+ MWh: {
14065
+ dimension: "energy",
14066
+ factor: 1e6,
14067
+ offset: 0
14068
+ },
14069
+ V: {
14070
+ dimension: "voltage",
14071
+ factor: 1,
14072
+ offset: 0
14073
+ },
14074
+ mV: {
14075
+ dimension: "voltage",
14076
+ factor: .001,
14077
+ offset: 0
14078
+ },
14079
+ A: {
14080
+ dimension: "current",
14081
+ factor: 1,
14082
+ offset: 0
14083
+ },
14084
+ mA: {
14085
+ dimension: "current",
14086
+ factor: .001,
14087
+ offset: 0
14088
+ },
14089
+ ppm: {
14090
+ dimension: "concentration-volume",
14091
+ factor: 1,
14092
+ offset: 0
14093
+ },
14094
+ ppb: {
14095
+ dimension: "concentration-volume",
14096
+ factor: .001,
14097
+ offset: 0
14098
+ },
14099
+ "µg/m³": {
14100
+ dimension: "concentration-mass",
14101
+ factor: 1,
14102
+ offset: 0
14103
+ },
14104
+ "mg/m³": {
14105
+ dimension: "concentration-mass",
14106
+ factor: 1e3,
14107
+ offset: 0
14108
+ },
14109
+ kg: {
14110
+ dimension: "mass",
14111
+ factor: 1,
14112
+ offset: 0
14113
+ },
14114
+ g: {
14115
+ dimension: "mass",
14116
+ factor: .001,
14117
+ offset: 0
14118
+ },
14119
+ lb: {
14120
+ dimension: "mass",
14121
+ factor: .453592,
14122
+ offset: 0
14123
+ },
14124
+ oz: {
14125
+ dimension: "mass",
14126
+ factor: .0283495,
14127
+ offset: 0
14128
+ },
14129
+ "%": {
14130
+ dimension: "percentage",
14131
+ factor: 1,
14132
+ offset: 0
14133
+ },
14134
+ L: {
14135
+ dimension: "volume",
14136
+ factor: 1,
14137
+ offset: 0
14138
+ },
14139
+ mL: {
14140
+ dimension: "volume",
14141
+ factor: .001,
14142
+ offset: 0
14143
+ },
14144
+ gal: {
14145
+ dimension: "volume",
14146
+ factor: 3.785411784,
14147
+ offset: 0
14148
+ },
14149
+ s: {
14150
+ dimension: "duration",
14151
+ factor: 1,
14152
+ offset: 0
14153
+ },
14154
+ ms: {
14155
+ dimension: "duration",
14156
+ factor: .001,
14157
+ offset: 0
14158
+ },
14159
+ min: {
14160
+ dimension: "duration",
14161
+ factor: 60,
14162
+ offset: 0
14163
+ },
14164
+ h: {
14165
+ dimension: "duration",
14166
+ factor: 3600,
14167
+ offset: 0
14168
+ },
14169
+ d: {
14170
+ dimension: "duration",
14171
+ factor: 86400,
14172
+ offset: 0
14173
+ },
14174
+ B: {
14175
+ dimension: "information",
14176
+ factor: 1,
14177
+ offset: 0
14178
+ },
14179
+ KiB: {
14180
+ dimension: "information",
14181
+ factor: 1024,
14182
+ offset: 0
14183
+ },
14184
+ MiB: {
14185
+ dimension: "information",
14186
+ factor: 1024 ** 2,
14187
+ offset: 0
14188
+ },
14189
+ GiB: {
14190
+ dimension: "information",
14191
+ factor: 1024 ** 3,
14192
+ offset: 0
14193
+ },
14194
+ TiB: {
14195
+ dimension: "information",
14196
+ factor: 1024 ** 4,
14197
+ offset: 0
14198
+ },
14199
+ kB: {
14200
+ dimension: "information",
14201
+ factor: 1e3,
14202
+ offset: 0
14203
+ },
14204
+ MB: {
14205
+ dimension: "information",
14206
+ factor: 1e6,
14207
+ offset: 0
14208
+ },
14209
+ GB: {
14210
+ dimension: "information",
14211
+ factor: 1e9,
14212
+ offset: 0
14213
+ },
14214
+ "°": {
14215
+ dimension: "angle",
14216
+ factor: 1,
14217
+ offset: 0
14218
+ },
14219
+ dBFS: {
14220
+ dimension: "sound-level",
14221
+ factor: 1,
14222
+ offset: 0
14223
+ },
14224
+ dBm: {
14225
+ dimension: "signal-level",
14226
+ factor: 1,
14227
+ offset: 0
14228
+ },
14229
+ mired: {
14230
+ dimension: "colour-temperature",
14231
+ factor: 1,
14232
+ offset: 0
14233
+ },
14234
+ kbps: {
14235
+ dimension: "bitrate",
14236
+ factor: 1,
14237
+ offset: 0
14238
+ },
14239
+ Mbps: {
14240
+ dimension: "bitrate",
14241
+ factor: 1e3,
14242
+ offset: 0
14243
+ },
14244
+ fps: {
14245
+ dimension: "rate",
14246
+ factor: 1,
14247
+ offset: 0
14248
+ }
14249
+ };
14250
+ /** Resolve a unit's `UnitSpec`, or `undefined` when the spelling is unknown. */
14251
+ function specFor(unit) {
14252
+ return Object.hasOwn(UNIT_TABLE, unit) ? UNIT_TABLE[unit] : void 0;
14253
+ }
14254
+ /** The dimension a unit belongs to, or `undefined` for an unknown unit. */
14255
+ function unitDimension(unit) {
14256
+ return specFor(unit)?.dimension;
14257
+ }
14258
+ /** Value in `spec`'s unit → its dimension's canonical unit. */
14259
+ function toCanonical(value, spec) {
14260
+ return value * spec.factor + spec.offset;
14261
+ }
14262
+ /** Canonical-unit value → the unit described by `spec`. */
14263
+ function fromCanonical(canonical, spec) {
14264
+ return (canonical - spec.offset) / spec.factor;
14265
+ }
14056
14266
  /**
14057
- * One extra delivery parameter a notifier KIND declares (D938). A rule that
14058
- * addresses a target of that kind may set it; a kind that declares nothing is
14059
- * never handed one. The admin UI derives its control from this descriptor —
14060
- * no editor knows a service by name.
14061
- *
14062
- * Optional fields are `.optional()`, never `.default()` (a Zod default does not
14063
- * run on the addon cap path).
14267
+ * Graceful variant for the render path: returns the converted value, or
14268
+ * `undefined` when the conversion is refused (unknown unit / cross-dimension).
14269
+ * Never throws — a render caller falls back to the raw value + source unit.
14064
14270
  */
14065
- var DeliveryParamSchema = object({
14066
- key: string().min(1),
14067
- label: string(),
14068
- /** i18n key of the label, resolved by the declaring addon's namespace. */
14069
- labelKey: string().optional(),
14070
- type: _enum([
14071
- "enum",
14072
- "number",
14073
- "boolean",
14074
- "string"
14075
- ]),
14076
- /** `enum` only: the closed set of accepted values. */
14077
- options: array(object({
14078
- value: string(),
14079
- label: string()
14080
- })).optional(),
14081
- /** `number` only. */
14082
- min: number().optional(),
14083
- max: number().optional(),
14084
- /** What the notifier does when the rule sets nothing; shown as the placeholder. */
14085
- default: DeliveryParamValueSchema.optional()
14271
+ function tryConvertUnit(value, from, to) {
14272
+ if (from === to) return value;
14273
+ const fromSpec = specFor(from);
14274
+ if (!fromSpec) return void 0;
14275
+ const toSpec = specFor(to);
14276
+ if (!toSpec) return void 0;
14277
+ if (fromSpec.dimension !== toSpec.dimension) return void 0;
14278
+ return fromCanonical(toCanonical(value, fromSpec), toSpec);
14279
+ }
14280
+ //#endregion
14281
+ //#region ../types/dist/index.mjs
14282
+ var SMTP_INBOUND_DEFAULT_PORT = 2525;
14283
+ var SMTP_INBOUND_DEFAULT_DOMAIN = "camstack.local";
14284
+ var SMTP_INBOUND_DEFAULT_MAX_MESSAGE_BYTES = 25 * 1024 * 1024;
14285
+ /** The text excerpt a message carries on the bus. */
14286
+ var SMTP_INBOUND_TEXT_MAX_CHARS = 4096;
14287
+ var PortSchema = number().int().min(1).max(65535);
14288
+ /** A recipient local-part: what stands before the `@`. */
14289
+ var SmtpRecipientSchema = string().min(1).max(64).regex(/^[A-Za-z0-9._+-]+$/);
14290
+ object({
14291
+ port: PortSchema.default(SMTP_INBOUND_DEFAULT_PORT),
14292
+ bindHost: string().min(1).default("0.0.0.0"),
14293
+ domain: string().min(1).default(SMTP_INBOUND_DEFAULT_DOMAIN),
14294
+ requireAuth: boolean().default(true),
14295
+ username: string().default(""),
14296
+ password: string().default("").meta({ secret: true }),
14297
+ starttls: boolean().default(false),
14298
+ maxMessageBytes: number().int().positive().default(SMTP_INBOUND_DEFAULT_MAX_MESSAGE_BYTES)
14086
14299
  });
14087
- /**
14088
- * The canonical notification. `body` is the only hard field (Apprise model).
14089
- * `priority` is a 5-level ORDINAL (1=lowest … 3=normal(default) … 5=urgent),
14090
- * NOT a fixed severity enum — each kind declares its own `caps.levels` and
14091
- * the adapter maps this ordinal onto its native level. `level?` is an
14092
- * optional kind-native level id (`emergency`, `silent`, …) that overrides
14093
- * `priority` for that one target.
14094
- */
14095
- var NotificationSchema = object({
14096
- body: string(),
14097
- title: string().optional(),
14098
- format: NotificationFormatSchema.default("text"),
14099
- priority: number().int().min(1).max(5).default(3),
14100
- level: string().optional(),
14101
- attachments: array(AttachmentSchema).optional(),
14102
- clickUrl: string().optional(),
14103
- actions: array(NotificationActionSchema).optional(),
14104
- sound: string().optional(),
14105
- ttl: number().optional(),
14106
- tag: string().optional(),
14107
- deviceId: number().optional(),
14108
- eventId: string().optional(),
14109
- metadata: record(string(), unknown()).optional(),
14300
+ object({
14301
+ host: string().min(1).nullable(),
14302
+ hostReason: string().nullable(),
14303
+ port: PortSchema,
14304
+ domain: string().min(1),
14305
+ requireAuth: boolean(),
14306
+ username: string(),
14307
+ password: string(),
14308
+ starttls: boolean()
14309
+ });
14310
+ object({
14311
+ recipients: array(SmtpRecipientSchema).min(1),
14110
14312
  /**
14111
- * Values for the parameters the target's kind DECLARES in
14112
- * {@link TargetKindSchema} `deliveryParams`. Already validated against the
14113
- * declaration by the sender; a notifier reads only the keys it declared.
14313
+ * Who is subscribing. A second `subscribe` with the same id REPLACES that subscriber's
14314
+ * recipients (the way a consumer that restarted, or lost a device, declares its set again);
14315
+ * a recipient held by another subscriber is refused with `smtp-inbound/recipient-claimed`.
14316
+ * Absent, the subscriber is anonymous and unique.
14114
14317
  */
14115
- delivery: record(string(), DeliveryParamValueSchema).optional()
14318
+ subscriberId: string().min(1).max(64).optional()
14116
14319
  });
14117
- /** One declared native severity/priority level for a kind. */
14118
- var TargetKindLevelSchema = object({
14119
- id: string(),
14120
- label: string(),
14121
- /** Which canonical priority (1..5) this level maps to. `null` = qualitative-only. */
14122
- ordinal: number().int().min(1).max(5).nullable(),
14123
- flags: object({
14124
- critical: boolean().optional(),
14125
- silent: boolean().optional(),
14126
- noPush: boolean().optional()
14127
- }).optional(),
14128
- /** e.g. Pushover `emergency` requires `retry` / `expire`. */
14129
- requires: array(string()).optional(),
14130
- description: string().optional()
14320
+ var SmtpInboundAttachmentSchema = object({
14321
+ filename: string(),
14322
+ contentType: string(),
14323
+ bytes: number().int().nonnegative()
14131
14324
  });
14132
- /** The full capability block consulted before dispatch. */
14133
- var TargetKindCapsSchema = object({
14134
- attachments: object({
14135
- mediaTypes: array(AttachmentMediaTypeSchema),
14136
- mode: _enum([
14137
- "url",
14138
- "bytes",
14139
- "both"
14140
- ]),
14141
- max: number().int().nonnegative(),
14142
- maxBytes: number().int().positive().optional()
14143
- }),
14144
- /** Max action buttons (0 = none). */
14145
- actions: number().int().nonnegative(),
14146
- /**
14147
- * Whether this kind renders a per-action ICON.
14148
- *
14149
- * `.optional()`, deliberately NOT `.default(false)`: a Zod default does not
14150
- * run on the addon cap path — three production failures in one day taught
14151
- * this repo that once. Absent is read as false by the degrade engine, which
14152
- * is the safe direction: an icon that is not rendered costs nothing, an icon
14153
- * assumed and dropped costs the operator's trust in the field.
14154
- */
14325
+ /** The payload of one `broker.message` (the key is the recipient local-part). */
14326
+ var SmtpInboundMessageSchema = object({
14327
+ /** Monotonic per mailbox; a gap tells a consumer it missed an event. */
14328
+ seq: number().int().positive(),
14329
+ messageId: string(),
14330
+ receivedAt: number().int().nonnegative(),
14331
+ from: string(),
14332
+ to: string(),
14333
+ subject: string(),
14334
+ text: string().max(SMTP_INBOUND_TEXT_MAX_CHARS),
14335
+ attachments: array(SmtpInboundAttachmentSchema)
14336
+ });
14337
+ object({
14338
+ /** The newest seq issued so far (0 before any mail). */
14339
+ lastSeq: number().int().nonnegative(),
14340
+ /** The oldest seq still retained; messages below it are gone. */
14341
+ oldestSeq: number().int().nonnegative(),
14342
+ messages: array(object({
14343
+ key: string(),
14344
+ message: SmtpInboundMessageSchema
14345
+ }))
14346
+ });
14347
+ new Set([
14348
+ "track",
14349
+ "face",
14350
+ "identity",
14351
+ "plate",
14352
+ "vehicle",
14353
+ "scene",
14354
+ "motion",
14355
+ "object",
14356
+ "audio",
14357
+ "mosaic"
14358
+ ]);
14359
+ /**
14360
+ * The owner types that are event tables, in the order the event-media resolver
14361
+ * should consider them. Exported so a consumer asking "is this key an event?"
14362
+ * does not re-spell the list and drift from it.
14363
+ */
14364
+ var EVENT_OWNER_TYPES = [
14365
+ "motion",
14366
+ "object",
14367
+ "audio"
14368
+ ];
14369
+ /**
14370
+ * The same list as a Zod enum, for the cap inputs that must NAME the table
14371
+ * (D482: `getEventMedia` / `listEventMedia` take an owner, and an owner is
14372
+ * `(table, id)`).
14373
+ *
14374
+ * Built FROM {@link EVENT_OWNER_TYPES} rather than re-spelled: a fourth event
14375
+ * table would otherwise be accepted by the codec and refused at the door, with
14376
+ * nothing failing until a caller asked.
14377
+ */
14378
+ var EventOwnerTypeSchema = _enum(EVENT_OWNER_TYPES);
14379
+ /** The same list as a Zod enum, for the cap input that carries it. */
14380
+ var MediaPresenceOwnerKindSchema = _enum([...EVENT_OWNER_TYPES, "track"]);
14381
+ new Set(EVENT_OWNER_TYPES);
14382
+ /**
14383
+ * What a published package needs from the rest of the install (D989).
14384
+ *
14385
+ * One published framework package (`@camstack/server`) carries the kernel, the
14386
+ * builtins and the capability contracts, so "which addon runs on which
14387
+ * framework" is a question of version, and the answer is DECLARED by the
14388
+ * package that knows it:
14389
+ *
14390
+ * - an addon says the oldest server it runs on (`requires.server: ">=X"`);
14391
+ * - the server says the oldest addon it works with
14392
+ * (`requires.addons: { "@camstack/addon-x": ">=Y" }`) and the oldest shell
14393
+ * around it (`requires.wrapper: { desktop, image }`);
14394
+ * - a wrapper (the desktop app, the container starter) says which server
14395
+ * range it can host, and reports its own kind and version.
14396
+ *
14397
+ * The publish workflow STAMPS these after the version bump
14398
+ * (`scripts/ci/stamp-requires.mjs`); nobody types a number by hand.
14399
+ *
14400
+ * A requirement that cannot be checked is NOT met: a shell that reports no
14401
+ * version counts as below the minimum, and an unreadable running version is
14402
+ * named in the result (a failed read is never a pass).
14403
+ */
14404
+ /** `>=MAJOR.MINOR.PATCH[-prerelease]` — the only range shape a requirement uses. */
14405
+ var MinVersionSchema = string().regex(/^>=\d+\.\d+\.\d+(-[0-9A-Za-z.-]+)?$/, "a minimum is written \">=X.Y.Z\"");
14406
+ object({
14407
+ /** The oldest `@camstack/server` this package runs on. */
14408
+ server: MinVersionSchema.optional(),
14409
+ /** The oldest installed version of each named addon package. */
14410
+ addons: record(string(), MinVersionSchema).optional(),
14411
+ /** The oldest shell around the server, per shell kind. */
14412
+ wrapper: object({
14413
+ desktop: MinVersionSchema.optional(),
14414
+ image: MinVersionSchema.optional()
14415
+ }).optional()
14416
+ });
14417
+ /** One unmet requirement; each names the versions on both sides. */
14418
+ var UnmetRequirementSchema = discriminatedUnion("kind", [
14419
+ object({
14420
+ kind: literal("server-too-old"),
14421
+ required: string(),
14422
+ /** `null` — the running server version could not be read. */
14423
+ running: string().nullable()
14424
+ }),
14425
+ object({
14426
+ kind: literal("addon-too-old"),
14427
+ packageName: string(),
14428
+ required: string(),
14429
+ /** `null` — the addon is not installed (or its version is unreadable). */
14430
+ running: string().nullable()
14431
+ }),
14432
+ object({
14433
+ kind: literal("wrapper-too-old"),
14434
+ wrapper: _enum(["desktop", "image"]),
14435
+ required: string(),
14436
+ /** `null` — the wrapper reported no version. */
14437
+ running: string().nullable()
14438
+ })
14439
+ ]);
14440
+ var RequiredAddonUpdateSchema = object({
14441
+ packageName: string(),
14442
+ /** The minimum the target server declares. */
14443
+ required: string(),
14444
+ /** What this node has; `null` when the addon is not installed. */
14445
+ installed: string().nullable()
14446
+ });
14447
+ /**
14448
+ * Which integration instance a settings form is for. An addon that serves several instances
14449
+ * (`instanceMode: multiple`) can show a different form per instance — an NVR integration
14450
+ * needs its connection, the default integration needs the addon's own sections.
14451
+ *
14452
+ * - `integrationId` is `null` in the create wizard: nothing exists yet, the operator is
14453
+ * setting up a NEW instance.
14454
+ * - `mode` is the wizard mode of the integration type (`getAvailableTypes`).
14455
+ * - `candidateStableId` is the discovery candidate a wizard was seeded from, if any.
14456
+ */
14457
+ var IntegrationInstanceRefSchema = object({
14458
+ integrationId: string().nullable(),
14459
+ mode: _enum([
14460
+ "standalone",
14461
+ "account",
14462
+ "broker"
14463
+ ]),
14464
+ candidateStableId: string().optional()
14465
+ });
14466
+ /**
14467
+ * notification-output — canonical, capability-gated notification delivery.
14468
+ *
14469
+ * Apprise-derived model (see
14470
+ * `docs/superpowers/specs/2026-07-03-notification-output-notifier-matrix.md`):
14471
+ * callers emit ONE canonical `Notification`; each provider declares a
14472
+ * per-kind capability descriptor (`TargetKind`), and the pure degrade
14473
+ * engine (`@camstack/types` `prepareNotification`) transcodes / degrades the
14474
+ * message to what the kind supports — callers never special-case a service.
14475
+ *
14476
+ * DESIGN DECISIONS (locked):
14477
+ * - A target is an INSTANCE of this function cap (epic #440, step 6): the
14478
+ * providers serve their targets as `integration-instances` records, one
14479
+ * record kind per target kind, and the admin lists, adds, edits, switches
14480
+ * and deletes them through that cap. This cap keeps what an instance cannot
14481
+ * say: the kind catalogue (`listTargetKinds`: capabilities, delivery
14482
+ * parameters, brand icon), dispatch (`send`, `testTarget`) and the form
14483
+ * helpers (`discoverTargets`, `probeTargetConfig`).
14484
+ * - `listTargetKinds` / `discoverTargets` return arrays → the generated
14485
+ * cap-mount auto-`concatCollection`-fans them across every registered
14486
+ * provider so one catalog is routable. `send` / `testTarget` /
14487
+ * `probeTargetConfig` route to ONE provider by the `addonId` the generated
14488
+ * collection router extracts from the call input.
14489
+ * - `Attachment.bytes` is `Uint8Array`. Transport-safe: superjson (the tRPC
14490
+ * transformer) + UDS MsgPack both round-trip typed arrays — already used by
14491
+ * `storage` / `storage-provider` / `recording` caps over the same path. No
14492
+ * base64 fallback needed.
14493
+ *
14494
+ * TODO (deferred, closed-set change — separate decision): add
14495
+ * `providerKind: 'notify'` so notification providers surface on the unified
14496
+ * admin "Integrations" page.
14497
+ */
14498
+ /**
14499
+ * Zentik-derived typed-media enum — the superset across every kind. Each
14500
+ * adapter picks what it supports and the degrade engine filters the rest.
14501
+ */
14502
+ var AttachmentMediaTypeSchema = _enum([
14503
+ "image",
14504
+ "video",
14505
+ "gif",
14506
+ "audio",
14507
+ "icon"
14508
+ ]);
14509
+ /**
14510
+ * A single attachment. Exactly one of `url` (remote source, most adapters
14511
+ * prefer this) or `bytes` (inline source; required for Pushover-style
14512
+ * bytes-only kinds) MUST be present — the degrade engine expresses a
14513
+ * url→bytes fetch as a `needsFetch` directive the adapter executes.
14514
+ */
14515
+ var AttachmentSchema = object({
14516
+ mediaType: AttachmentMediaTypeSchema,
14517
+ url: string().optional(),
14518
+ bytes: _instanceof(Uint8Array).optional(),
14519
+ mime: string().optional(),
14520
+ name: string().optional()
14521
+ }).refine((a) => a.url !== void 0 || a.bytes !== void 0, { message: "Attachment requires either `url` or `bytes`" });
14522
+ var NotificationFormatSchema = _enum([
14523
+ "text",
14524
+ "markdown",
14525
+ "html"
14526
+ ]);
14527
+ /**
14528
+ * The CLOSED icon vocabulary an action button may use.
14529
+ *
14530
+ * A closed set, not a free string, and that is the whole point: an arbitrary
14531
+ * icon name is one that ntfy renders, zentik silently drops, and nobody
14532
+ * notices — the same class of gap as a zone vocabulary nothing produced
14533
+ * ([D35](../../../docs/decisions/adr-0035.md)). Every adapter maps this set or
14534
+ * declares `actionIcons: false` and the degrade engine strips the field.
14535
+ *
14536
+ * Named by INTENT, never by glyph. "check" would tie the vocabulary to one
14537
+ * renderer's icon set; "acknowledge" survives an adapter that draws it
14538
+ * differently.
14539
+ *
14540
+ * ── A TOKEN IS NOT A WIRE VALUE ─────────────────────────────────────
14541
+ *
14542
+ * These names are for US. **No adapter may forward one verbatim.** Each maps
14543
+ * the whole set onto its own renderer's vocabulary through a
14544
+ * `Record<NotificationActionIcon, string>` — a Record, never a lookup with a
14545
+ * fallback, so adding a member here fails every adapter's build until someone
14546
+ * decides its glyph, which is the only place that decision can be made
14547
+ * honestly.
14548
+ *
14549
+ * This paragraph is the bug. Zentik declared `actionIcons: true` and passed
14550
+ * `disarm` straight through; iOS feeds that string to
14551
+ * `UNNotificationActionIcon(systemImageName:)`, `disarm` is not an SF Symbol,
14552
+ * and every snooze and alarm button arrived BLANK. A pass-through is not a
14553
+ * mapping, and "the field is documented" is not "the value renders".
14554
+ *
14555
+ * Adding a member is TRAIN-BOUND. The enum lives in the published
14556
+ * `@camstack/server` closure and the cap seam validates against the HUB's copy,
14557
+ * so an addon that emits a token the running hub does not know does not lose an
14558
+ * icon — its whole `send` fails Zod validation and the notification never
14559
+ * arrives. Never emit a new token from an addon before the train carrying it.
14560
+ */
14561
+ var NotificationActionIconSchema = _enum([
14562
+ "acknowledge",
14563
+ "dismiss",
14564
+ "silence",
14565
+ "snooze",
14566
+ "view",
14567
+ "play",
14568
+ "open",
14569
+ "close",
14570
+ "lock",
14571
+ "unlock",
14572
+ "arm",
14573
+ "arm-home",
14574
+ "arm-away",
14575
+ "arm-night",
14576
+ "disarm",
14577
+ "light",
14578
+ "alert",
14579
+ "camera"
14580
+ ]);
14581
+ /** A single tap-through action button. */
14582
+ var NotificationActionSchema = object({
14583
+ id: string(),
14584
+ label: string(),
14585
+ url: string().optional(),
14586
+ /** Dropped by the degrade engine for a kind with `caps.actionIcons: false`. */
14587
+ icon: NotificationActionIconSchema.optional(),
14588
+ /**
14589
+ * Renders in a warning style where the notifier supports it.
14590
+ *
14591
+ * A HINT, never a gate. The callback's authority is its token and nothing
14592
+ * else — see `notification-center/action-token.ts` for what that does and
14593
+ * does not buy.
14594
+ */
14595
+ destructive: boolean().optional(),
14596
+ /**
14597
+ * How the tap should REACH the url.
14598
+ *
14599
+ * `navigate` (absent, and every button authored before this field) opens it:
14600
+ * the phone leaves the notification and shows whatever the callback returns.
14601
+ * That is right for a button whose answer the operator wants to read.
14602
+ *
14603
+ * `background` fires it as a POST and stays put. It exists for the buttons
14604
+ * whose whole point is not to interrupt — "silence this for 30 minutes" is
14605
+ * an answer to the notification, and being thrown into a browser tab to
14606
+ * confirm it costs more attention than the notification did. A backend that
14607
+ * cannot do a background call renders it as an ordinary link (the adapters
14608
+ * fall back rather than dropping the button), so this is a preference, never
14609
+ * a requirement.
14610
+ */
14611
+ mode: _enum(["navigate", "background"]).optional()
14612
+ });
14613
+ /** A delivery parameter value: what a notifier declared it takes. */
14614
+ var DeliveryParamValueSchema = union([
14615
+ string(),
14616
+ number(),
14617
+ boolean()
14618
+ ]);
14619
+ /**
14620
+ * One extra delivery parameter a notifier KIND declares (D938). A rule that
14621
+ * addresses a target of that kind may set it; a kind that declares nothing is
14622
+ * never handed one. The admin UI derives its control from this descriptor —
14623
+ * no editor knows a service by name.
14624
+ *
14625
+ * Optional fields are `.optional()`, never `.default()` (a Zod default does not
14626
+ * run on the addon cap path).
14627
+ */
14628
+ var DeliveryParamSchema = object({
14629
+ key: string().min(1),
14630
+ label: string(),
14631
+ /** i18n key of the label, resolved by the declaring addon's namespace. */
14632
+ labelKey: string().optional(),
14633
+ type: _enum([
14634
+ "enum",
14635
+ "number",
14636
+ "boolean",
14637
+ "string"
14638
+ ]),
14639
+ /** `enum` only: the closed set of accepted values. */
14640
+ options: array(object({
14641
+ value: string(),
14642
+ label: string()
14643
+ })).optional(),
14644
+ /** `number` only. */
14645
+ min: number().optional(),
14646
+ max: number().optional(),
14647
+ /** What the notifier does when the rule sets nothing; shown as the placeholder. */
14648
+ default: DeliveryParamValueSchema.optional()
14649
+ });
14650
+ /**
14651
+ * The canonical notification. `body` is the only hard field (Apprise model).
14652
+ * `priority` is a 5-level ORDINAL (1=lowest … 3=normal(default) … 5=urgent),
14653
+ * NOT a fixed severity enum — each kind declares its own `caps.levels` and
14654
+ * the adapter maps this ordinal onto its native level. `level?` is an
14655
+ * optional kind-native level id (`emergency`, `silent`, …) that overrides
14656
+ * `priority` for that one target.
14657
+ */
14658
+ var NotificationSchema = object({
14659
+ body: string(),
14660
+ title: string().optional(),
14661
+ format: NotificationFormatSchema.default("text"),
14662
+ priority: number().int().min(1).max(5).default(3),
14663
+ level: string().optional(),
14664
+ attachments: array(AttachmentSchema).optional(),
14665
+ clickUrl: string().optional(),
14666
+ actions: array(NotificationActionSchema).optional(),
14667
+ sound: string().optional(),
14668
+ ttl: number().optional(),
14669
+ tag: string().optional(),
14670
+ deviceId: number().optional(),
14671
+ eventId: string().optional(),
14672
+ metadata: record(string(), unknown()).optional(),
14673
+ /**
14674
+ * Values for the parameters the target's kind DECLARES in
14675
+ * {@link TargetKindSchema} `deliveryParams`. Already validated against the
14676
+ * declaration by the sender; a notifier reads only the keys it declared.
14677
+ */
14678
+ delivery: record(string(), DeliveryParamValueSchema).optional()
14679
+ });
14680
+ /** One declared native severity/priority level for a kind. */
14681
+ var TargetKindLevelSchema = object({
14682
+ id: string(),
14683
+ label: string(),
14684
+ /** Which canonical priority (1..5) this level maps to. `null` = qualitative-only. */
14685
+ ordinal: number().int().min(1).max(5).nullable(),
14686
+ flags: object({
14687
+ critical: boolean().optional(),
14688
+ silent: boolean().optional(),
14689
+ noPush: boolean().optional()
14690
+ }).optional(),
14691
+ /** e.g. Pushover `emergency` requires `retry` / `expire`. */
14692
+ requires: array(string()).optional(),
14693
+ description: string().optional()
14694
+ });
14695
+ /** The full capability block consulted before dispatch. */
14696
+ var TargetKindCapsSchema = object({
14697
+ attachments: object({
14698
+ mediaTypes: array(AttachmentMediaTypeSchema),
14699
+ mode: _enum([
14700
+ "url",
14701
+ "bytes",
14702
+ "both"
14703
+ ]),
14704
+ max: number().int().nonnegative(),
14705
+ maxBytes: number().int().positive().optional()
14706
+ }),
14707
+ /** Max action buttons (0 = none). */
14708
+ actions: number().int().nonnegative(),
14709
+ /**
14710
+ * Whether this kind renders a per-action ICON.
14711
+ *
14712
+ * `.optional()`, deliberately NOT `.default(false)`: a Zod default does not
14713
+ * run on the addon cap path — three production failures in one day taught
14714
+ * this repo that once. Absent is read as false by the degrade engine, which
14715
+ * is the safe direction: an icon that is not rendered costs nothing, an icon
14716
+ * assumed and dropped costs the operator's trust in the field.
14717
+ */
14155
14718
  actionIcons: boolean().optional(),
14156
14719
  levels: array(TargetKindLevelSchema),
14157
14720
  format: array(NotificationFormatSchema),
@@ -14167,7 +14730,7 @@ var TargetKindCapsSchema = object({
14167
14730
  * the union is large and not meant for runtime validation here; the exported
14168
14731
  * `TargetKind` type re-tightens `configSchema` to `ConfigUISchema`.
14169
14732
  */
14170
- var ConfigSchemaPassthrough$4 = unknown();
14733
+ var ConfigSchemaPassthrough$3 = unknown();
14171
14734
  var TargetKindSchema = object({
14172
14735
  kind: string(),
14173
14736
  label: string(),
@@ -14204,7 +14767,7 @@ var TargetKindSchema = object({
14204
14767
  * its raster path, which is the safe default for an unknown image.
14205
14768
  */
14206
14769
  iconMediaType: string().optional(),
14207
- configSchema: ConfigSchemaPassthrough$4,
14770
+ configSchema: ConfigSchemaPassthrough$3,
14208
14771
  /**
14209
14772
  * The config keys that decide WHERE this kind's secrets are sent (server,
14210
14773
  * base URL, instance, chat, recipient). A save that changes any of them
@@ -14226,9 +14789,11 @@ var TargetKindSchema = object({
14226
14789
  caps: TargetKindCapsSchema
14227
14790
  });
14228
14791
  /**
14229
- * A persisted target. `config` holds secrets; providers REDACT secret fields
14230
- * (return a presence marker only) when serving `listTargets` — never
14231
- * round-trip a stored secret to the UI.
14792
+ * A target as a provider's own code sees it (the notification-center bridge, the
14793
+ * send path): the flat record body split into the name, the switch and the
14794
+ * kind's fields. `config` holds secrets; a reader that serves it to a client
14795
+ * REDACTS secret fields (a presence marker only) — never round-trip a stored
14796
+ * secret to the UI.
14232
14797
  */
14233
14798
  var TargetSchema = object({
14234
14799
  id: string(),
@@ -14271,13 +14836,13 @@ var ProbeTargetConfigResultSchema = object({
14271
14836
  stateInstance: string().optional(),
14272
14837
  error: string().optional()
14273
14838
  });
14274
- method(object({}), array(TargetKindSchema)), method(object({}), array(TargetSchema), { auth: "admin" }), method(object({ targetId: string() }), TargetSchema, { auth: "admin" }), method(object({
14839
+ method(object({}), array(TargetKindSchema)), method(object({
14275
14840
  kind: string(),
14276
14841
  config: record(string(), unknown()).optional(),
14277
14842
  /**
14278
14843
  * When editing / duplicating, the blank password field never round-trips
14279
14844
  * the stored token. Pass the source target id so the provider can restore
14280
- * secrets server-side before dialling (same merge as upsert).
14845
+ * secrets server-side before dialling.
14281
14846
  */
14282
14847
  targetId: string().optional()
14283
14848
  }), array(DiscoveredTargetSchema), { auth: "admin" }), method(object({
@@ -14300,27 +14865,6 @@ method(object({}), array(TargetKindSchema)), method(object({}), array(TargetSche
14300
14865
  }), TestResultSchema, {
14301
14866
  kind: "mutation",
14302
14867
  auth: "admin"
14303
- }), method(object({
14304
- target: TargetSchema,
14305
- /**
14306
- * Duplicate flow: create a NEW target id while copying secrets from an
14307
- * existing row. The UI never holds the stored token; blank / redacted
14308
- * password fields are restored from this source (D634 still applies if
14309
- * destinations diverge without a re-typed secret).
14310
- */
14311
- cloneSecretsFrom: string().optional()
14312
- }), TargetSchema, {
14313
- kind: "mutation",
14314
- auth: "admin"
14315
- }), method(object({ targetId: string() }), _void(), {
14316
- kind: "mutation",
14317
- auth: "admin"
14318
- }), method(object({
14319
- targetId: string(),
14320
- enabled: boolean()
14321
- }), _void(), {
14322
- kind: "mutation",
14323
- auth: "admin"
14324
14868
  });
14325
14869
  looseObject({
14326
14870
  name: string().min(1),
@@ -22731,7 +23275,6 @@ var SYSTEM_CAP_VOCABULARY = {
22731
23275
  "notification-output": system("notification delivery — reached through notifier devices and rules"),
22732
23276
  "notification-rules": system("notification rules — authored on their own page"),
22733
23277
  "oauth-integration": system(IDENTITY),
22734
- "oidc-connections": system(IDENTITY),
22735
23278
  "osd-manager": system(PIPELINE),
22736
23279
  "pipeline-executor": system(PIPELINE),
22737
23280
  "pipeline-orchestrator": system(PIPELINE),
@@ -42613,727 +43156,345 @@ var LEGACY_ICON_ALIASES = { gauge2: "gauge" };
42613
43156
  *
42614
43157
  * ## What is persisted
42615
43158
  *
42616
- * The canonical kebab-case lucide id ({@link IconKey}). Spellings that a lucide
42617
- * package still accepts (`home` for `house`) and this repo's own legacy ones
42618
- * (`gauge2`) RESOLVE ({@link canonicalIconKey}) so a stored value never goes
42619
- * stale, but they are never OFFERED by search.
42620
- *
42621
- * ## Search
42622
- *
42623
- * Over the key, the Italian/English overlay in `icon-synonyms.ts`, any words
42624
- * the caller adds, and lucide's English tags — in that order of weight.
42625
- */
42626
- var KEY_SET$2 = new Set(ICON_KEYS);
42627
- new Map([...Object.entries(ICON_ALIASES), ...Object.entries(LEGACY_ICON_ALIASES)]);
42628
- /** Is this a canonical key of the catalog? (An alias is not — see {@link canonicalIconKey}.) */
42629
- function isIconKey(value) {
42630
- return typeof value === "string" && KEY_SET$2.has(value);
42631
- }
42632
- /**
42633
- * Wire/storage schema for one icon key.
42634
- *
42635
- * Deliberately NOT a `z.enum` of the catalog: ~1,700 literals would be inlined
42636
- * into every cap router, type and API-reference row that carries an icon. The
42637
- * check is membership in the catalog and the type is {@link IconKey}.
42638
- */
42639
- var IconKeySchema = custom(isIconKey, "Not an icon of the catalog");
42640
- var ENTRIES = ICON_KEYS.map((key, index) => {
42641
- const [categoryIndexes, tags] = ICON_META[index] ?? [[], []];
42642
- const categories = categoryIndexes.flatMap((i) => {
42643
- const id = ICON_CATEGORY_IDS[i];
42644
- return id === void 0 ? [] : [id];
42645
- });
42646
- return {
42647
- key,
42648
- categories,
42649
- primaryCategory: categories[0] ?? ICON_CATEGORY_IDS[0],
42650
- tags,
42651
- synonyms: ICON_SYNONYMS[key] ?? []
42652
- };
42653
- });
42654
- new Map(ENTRIES.map((e) => [e.key, e]));
42655
- /** Categories a picker offers first: the ones this product's icons mostly live in. */
42656
- var LEADING_CATEGORIES = [
42657
- "devices",
42658
- "home",
42659
- "security",
42660
- "buildings",
42661
- "connectivity",
42662
- "multimedia",
42663
- "nature",
42664
- "weather",
42665
- "transportation",
42666
- "animals"
42667
- ];
42668
- var PRIMARY_CATEGORIES = new Set(ENTRIES.map((e) => e.primaryCategory));
42669
- [...LEADING_CATEGORIES, ...ICON_CATEGORY_IDS.filter((c) => !LEADING_CATEGORIES.includes(c))].filter((c) => PRIMARY_CATEGORIES.has(c));
42670
- /**
42671
- * One (location, icon) assignment as it travels.
42672
- *
42673
- * `locationKey` is ALWAYS {@link locationIconKey} of the label — never the
42674
- * operator's casing. The registry matches labels trimmed + case-insensitively
42675
- * everywhere (`addLocation`, `removeLocation`, `renameLocation`), and a
42676
- * case-only rename (`kitchen` → `Kitchen`) is a real edit this repo supports; a
42677
- * map keyed on the displayed casing would orphan its entry on exactly that
42678
- * edit. Consumers join by keying their own label through `locationIconKey`.
42679
- */
42680
- var LocationIconAssignmentSchema = object({
42681
- locationKey: string(),
42682
- icon: IconKeySchema
42683
- });
42684
- /**
42685
- * One (location, description) assignment as it travels.
42686
- *
42687
- * Same key discipline as {@link LocationIconAssignmentSchema}, and for the same
42688
- * reason: this lived for a while in the post-analysis addon's own settings,
42689
- * keyed by a HAND-TYPED label matched exactly and case-sensitively. A rename in
42690
- * the Locations page carried the icon and silently orphaned the description —
42691
- * two authorities for one thing, joined by two different rules. Now both hang
42692
- * off the location itself, on `locationIconKey`.
42693
- */
42694
- var LocationDescriptionAssignmentSchema = object({
42695
- locationKey: string(),
42696
- description: string()
42697
- });
42698
- /**
42699
- * WHO an action step acts on (D983) — one target shape for every place that
42700
- * performs an action (automation steps, Action entries, notification
42701
- * sequences, scheduler points):
42702
- *
42703
- * - `devices` — device ids the operator picked, frozen at save time;
42704
- * - `domain` — every device that offers the step's VOCABULARY action,
42705
- * optionally narrowed to one device type and one room, resolved WHEN THE
42706
- * STEP RUNS (a device added later is included). The action always comes
42707
- * from the vocabulary (`cover.open`), never from a raw cap name, so a
42708
- * `domain` target needs an `actionId` (enforced on the step schema);
42709
- * - `var` — a `$var` resolved from the run's scope.
42710
- *
42711
- * {@link ActionTargetResolver} turns a target into device ids. It is pure
42712
- * (a {@link DeviceDirectory} is handed in) so the hub's core-blocks service and
42713
- * a generated automation block share it.
42714
- *
42715
- * A room is the device's `location` label (`DeviceInfo.location`); two labels
42716
- * name the same room when `locationIconKey` agrees (trimmed, lower-cased).
42717
- */
42718
- var ActionTargetSchema = discriminatedUnion("kind", [
42719
- object({
42720
- kind: literal("devices"),
42721
- ids: array(number().int()).min(1)
42722
- }),
42723
- object({
42724
- kind: literal("domain"),
42725
- /** Narrow to one kind of device. */
42726
- deviceType: _enum(DeviceType).optional(),
42727
- /** Narrow to one room: the `location` label devices carry. */
42728
- roomId: string().min(1).optional()
42729
- }),
42730
- object({
42731
- kind: literal("var"),
42732
- name: string().min(1)
42733
- })
42734
- ]);
42735
- EventCategory.DeviceRegistered, EventCategory.DeviceUnregistered, EventCategory.DeviceUpdated, EventCategory.DeviceMetaChanged, EventCategory.DeviceBindingsChanged;
42736
- var ExpressionBindingSourceSchema = union([
42737
- object({
42738
- kind: literal("field").optional(),
42739
- sourceKey: string(),
42740
- cap: string(),
42741
- fieldPath: string()
42742
- }),
42743
- object({
42744
- kind: literal("literal"),
42745
- value: union([
42746
- string(),
42747
- number(),
42748
- boolean(),
42749
- _null()
42750
- ])
42751
- }),
42752
- object({
42753
- kind: literal("global"),
42754
- sourceStableId: string(),
42755
- cap: string(),
42756
- fieldPath: string()
42757
- })
42758
- ]);
42759
- object({
42760
- expr: string().min(1).max(MAX_EXPRESSION_SOURCE_LENGTH),
42761
- bindings: record(string().regex(EXPRESSION_IDENTIFIER_RE), ExpressionBindingSourceSchema)
42762
- }).superRefine((src, ctx) => {
42763
- const err = validateExpressionSource(src);
42764
- if (err !== null) ctx.addIssue({
42765
- code: "custom",
42766
- message: err,
42767
- path: ["expr"]
42768
- });
42769
- });
42770
- /**
42771
- * Identity envelope for a device's upstream-system metadata.
42772
- *
42773
- * Two jobs:
42774
- *
42775
- * 1. **Dispatch key.** `id` is the natural identifier the SOURCE system
42776
- * uses to address this device (HA `entity_id`, Reolink MAC, ONVIF
42777
- * WS-Discovery endpoint UUID, …). Provider code keeps a
42778
- * `Map<sourceInfo.id, IDevice>` to route inbound push events in O(1)
42779
- * without round-tripping through `stableId` / `id` mappings.
42780
- *
42781
- * 2. **Stability bridge.** `uniqueId` is the *immutable* upstream id when
42782
- * one exists (HA `entity.unique_id`, Reolink MAC again — same as `id`
42783
- * for vendors where MAC is the natural key). For systems where the
42784
- * live dispatch key can be renamed (HA `entity_id` can be edited),
42785
- * providers detect renames by matching `uniqueId` and patch `id`
42786
- * in-place so dispatch keeps working.
42787
- *
42788
- * **Display unit and precision are NOT stored here.** They are a read-time
42789
- * preference (D944). A polymorphic reading stores its `quantity` here once,
42790
- * at adopt, and a date/time value stores `dateTimeShape` the same way —
42791
- * neither is repeated on each sample. The `device_class` tag is an
42792
- * HA-specific input consumed at the discovery boundary (`ha-domain-mapping`)
42793
- * to derive the CamStack `DeviceRole`; it is never stored after that point.
42794
- *
42795
- * The `raw` escape hatch carries provider-specific attributes that don't
42796
- * fit the structured slots (HA `attributes` whitelist, Reolink `deviceCache`
42797
- * details, …). Providers control what lands here.
42798
- */
42799
- var SourceInfoSchema = object({
42800
- /** Live dispatch key — mutable when the source system allows rename. */
42801
- id: string(),
42802
- /** Source system tag — e.g. 'homeassistant' | 'reolink' | 'onvif'. */
42803
- system: string(),
42804
- /** Immutable upstream identifier when available (HA `unique_id`, … ).
42805
- * Used to detect rename when `id` changes. */
42806
- uniqueId: string().optional(),
42807
- /** Quantity of a polymorphic reading, written once at adopt (D944). */
42808
- quantity: ReadingQuantitySchema.optional(),
42809
- /** Date / time / datetime shape of a string reading, written once at adopt. */
42810
- dateTimeShape: _enum([
42811
- "date",
42812
- "time",
42813
- "datetime"
42814
- ]).optional(),
42815
- /** Provider-specific extras that don't fit the structured slots.
42816
- * Whitelist what goes here per provider — do NOT dump entire HA
42817
- * attribute blobs (would explode the meta JSON column). */
42818
- raw: record(string(), unknown()).optional()
42819
- });
42820
- /**
42821
- * Build the synthetic SourceInfo every existing provider falls back to
42822
- * when no upstream value has been persisted. Keeps non-migrated providers
42823
- * (Reolink / Hikvision / ONVIF / RTSP) functional without code
42824
- * changes — `id` reuses the CamStack stableId, `system` reuses the addon
42825
- * id. Real upstream identity replaces this once a provider migrates and
42826
- * calls `updateSourceInfo()` with concrete values.
42827
- */
42828
- function synthesizeSourceInfo(input) {
42829
- return {
42830
- id: input.stableId,
42831
- system: input.addonId
42832
- };
42833
- }
42834
- /**
42835
- * Shallow-merge a partial patch over a prior SourceInfo. `undefined`
42836
- * patch values are ignored (no field clobber); to clear a field
42837
- * explicitly, providers omit it from the patch and rebuild from scratch
42838
- * via `updateSourceInfo({})` cycles — uncommon enough that we don't
42839
- * bother with a `null`-means-delete sentinel.
42840
- *
42841
- * The `raw` field is also shallow-merged: passing `raw: { foo: 1 }`
42842
- * merges over existing `raw` keys instead of replacing the whole bag.
42843
- */
42844
- function mergeSourceInfo(prev, patch) {
42845
- const next = { ...prev };
42846
- for (const [k, v] of Object.entries(patch)) {
42847
- if (v === void 0) continue;
42848
- if (k === "raw" && typeof v === "object" && v !== null) {
42849
- next.raw = {
42850
- ...prev.raw,
42851
- ...v
42852
- };
42853
- continue;
42854
- }
42855
- next[k] = v;
42856
- }
42857
- return next;
42858
- }
42859
- /**
42860
- * Coerce common unit-of-measurement string variants to a canonical form
42861
- * so the UI's display templates can rely on stable strings. Pure
42862
- * passthrough for unknown units — kept conservative on purpose, the goal
42863
- * is to normalise the long tail of HA `unit_of_measurement` values that
42864
- * have multiple historical spellings (`'°C'` vs `'C'` vs `'celsius'`).
42865
- *
42866
- * Extend the map as we encounter real-world data. Returning the raw
42867
- * input for unknown values is intentional: providers should never
42868
- * lose information silently here.
42869
- */
42870
- function normalizeUnit(raw) {
42871
- if (raw == null) return void 0;
42872
- const trimmed = raw.trim();
42873
- if (trimmed === "") return void 0;
42874
- const lower = trimmed.toLowerCase();
42875
- if (lower === "°c" || lower === "c" || lower === "celsius") return "°C";
42876
- if (lower === "°f" || lower === "f" || lower === "fahrenheit") return "°F";
42877
- if (lower === "k" || lower === "kelvin") return "K";
42878
- if (lower === "%" || lower === "percent" || lower === "percentage") return "%";
42879
- if (lower === "lx" || lower === "lux") return "lx";
42880
- if (lower === "hpa" || lower === "hectopascal") return "hPa";
42881
- if (lower === "kpa") return "kPa";
42882
- if (lower === "pa") return "Pa";
42883
- if (lower === "mbar" || lower === "millibar") return "mbar";
42884
- if (lower === "w" || lower === "watt") return "W";
42885
- if (lower === "kw" || lower === "kilowatt") return "kW";
42886
- if (lower === "wh" || lower === "watt-hour") return "Wh";
42887
- if (lower === "kwh" || lower === "kilowatt-hour") return "kWh";
42888
- if (lower === "v" || lower === "volt") return "V";
42889
- if (lower === "a" || lower === "amp" || lower === "ampere") return "A";
42890
- if (lower === "ma" || lower === "milliampere") return "mA";
42891
- if (lower === "va") return "VA";
42892
- if (lower === "ppm") return "ppm";
42893
- if (lower === "ppb") return "ppb";
42894
- if (lower === "µg/m³" || lower === "ug/m3" || lower === "µg/m3") return "µg/m³";
42895
- if (lower === "km/h" || lower === "kph") return "km/h";
42896
- if (lower === "mph") return "mph";
42897
- if (lower === "m/s") return "m/s";
42898
- if (lower === "m") return "m";
42899
- if (lower === "m²" || lower === "m2") return "m²";
42900
- if (lower === "mm") return "mm";
42901
- if (lower === "cm") return "cm";
42902
- if (lower === "km") return "km";
42903
- if (lower === "in" || lower === "inch" || lower === "inches") return "in";
42904
- if (lower === "ft" || lower === "foot" || lower === "feet") return "ft";
42905
- if (lower === "kg") return "kg";
42906
- if (lower === "g") return "g";
42907
- if (lower === "l" || lower === "liter" || lower === "litre" || lower === "liters" || lower === "litres") return "L";
42908
- if (lower === "ml") return "mL";
42909
- if (lower === "gal" || lower === "gallon" || lower === "gallons") return "gal";
42910
- if (lower === "s" || lower === "sec" || lower === "second" || lower === "seconds") return "s";
42911
- if (lower === "ms") return "ms";
42912
- if (lower === "min" || lower === "minute" || lower === "minutes") return "min";
42913
- if (lower === "h" || lower === "hr" || lower === "hour" || lower === "hours") return "h";
42914
- if (lower === "d" || lower === "day" || lower === "days") return "d";
42915
- if (lower === "b" || lower === "byte" || lower === "bytes") return "B";
42916
- if (lower === "kib") return "KiB";
42917
- if (lower === "mib") return "MiB";
42918
- if (lower === "gib") return "GiB";
42919
- if (lower === "tib") return "TiB";
42920
- if (lower === "kb") return "kB";
42921
- if (lower === "mb") return "MB";
42922
- if (lower === "gb") return "GB";
42923
- if (lower === "dbm") return "dBm";
42924
- if (lower === "dbfs") return "dBFS";
42925
- if (lower === "inhg") return "inHg";
42926
- if (lower === "mm/h" || lower === "mm/hr") return "mm/h";
42927
- if (lower === "in/h" || lower === "in/hr") return "in/h";
42928
- if (lower === "w/m²" || lower === "w/m2") return "W/m²";
42929
- if (lower === "°" || lower === "deg" || lower === "degree" || lower === "degrees") return "°";
42930
- if (lower === "kbps") return "kbps";
42931
- if (lower === "fps") return "fps";
42932
- return trimmed;
42933
- }
42934
- /**
42935
- * Key under which `SourceInfo` lives inside `DeviceMeta.metadata`. The
42936
- * blob is a free-form `Record<string, unknown>` shared with hardware-
42937
- * identity fields (`manufacturer`, `model`, `firmware`, …); SourceInfo
42938
- * lives under a single nested key to keep it composable with those.
42939
- */
42940
- var SOURCE_INFO_METADATA_KEY = "sourceInfo";
42941
- /**
42942
- * Extract a SourceInfo from a `DeviceMeta.metadata` blob, validating
42943
- * with Zod. Returns `null` when the blob is missing or the nested
42944
- * `sourceInfo` key fails validation — callers fall back to the
42945
- * synthetic default in that case (see `synthesizeSourceInfo`).
42946
- */
42947
- function extractSourceInfoFromMetadata(metadata) {
42948
- if (!metadata) return null;
42949
- const raw = metadata[SOURCE_INFO_METADATA_KEY];
42950
- if (!raw) return null;
42951
- const parsed = SourceInfoSchema.safeParse(raw);
42952
- if (!parsed.success) return null;
42953
- return parsed.data;
42954
- }
42955
- /**
42956
- * Frozen unit → spec table. `•` in the doc marks each dimension's canonical
42957
- * unit (`factor: 1, offset: 0`). °F derives from `°C = (°F − 32) × 5/9` ⇒
42958
- * `factor = 5/9`, `offset = -160/9` (kept as exact expressions, not rounded
42959
- * decimals). K derives from `°C = K − 273.15`.
42960
- */
42961
- var UNIT_TABLE = {
42962
- "°C": {
42963
- dimension: "temperature",
42964
- factor: 1,
42965
- offset: 0
42966
- },
42967
- "°F": {
42968
- dimension: "temperature",
42969
- factor: 5 / 9,
42970
- offset: -160 / 9
42971
- },
42972
- K: {
42973
- dimension: "temperature",
42974
- factor: 1,
42975
- offset: -273.15
42976
- },
42977
- hPa: {
42978
- dimension: "pressure",
42979
- factor: 1,
42980
- offset: 0
42981
- },
42982
- kPa: {
42983
- dimension: "pressure",
42984
- factor: 10,
42985
- offset: 0
42986
- },
42987
- Pa: {
42988
- dimension: "pressure",
42989
- factor: .01,
42990
- offset: 0
42991
- },
42992
- mbar: {
42993
- dimension: "pressure",
42994
- factor: 1,
42995
- offset: 0
42996
- },
42997
- bar: {
42998
- dimension: "pressure",
42999
- factor: 1e3,
43000
- offset: 0
43001
- },
43002
- inHg: {
43003
- dimension: "pressure",
43004
- factor: 33.8639,
43005
- offset: 0
43006
- },
43007
- mmHg: {
43008
- dimension: "pressure",
43009
- factor: 1.33322,
43010
- offset: 0
43011
- },
43012
- psi: {
43013
- dimension: "pressure",
43014
- factor: 68.9476,
43015
- offset: 0
43016
- },
43017
- "m/s": {
43018
- dimension: "speed",
43019
- factor: 1,
43020
- offset: 0
43021
- },
43022
- "km/h": {
43023
- dimension: "speed",
43024
- factor: 1 / 3.6,
43025
- offset: 0
43026
- },
43027
- mph: {
43028
- dimension: "speed",
43029
- factor: .44704,
43030
- offset: 0
43031
- },
43032
- kn: {
43033
- dimension: "speed",
43034
- factor: .514444,
43035
- offset: 0
43036
- },
43037
- "mm/h": {
43038
- dimension: "precipitation-rate",
43039
- factor: 1,
43040
- offset: 0
43041
- },
43042
- "in/h": {
43043
- dimension: "precipitation-rate",
43044
- factor: 25.4,
43045
- offset: 0
43046
- },
43047
- m: {
43048
- dimension: "length",
43049
- factor: 1,
43050
- offset: 0
43051
- },
43052
- mm: {
43053
- dimension: "length",
43054
- factor: .001,
43055
- offset: 0
43056
- },
43057
- cm: {
43058
- dimension: "length",
43059
- factor: .01,
43060
- offset: 0
43061
- },
43062
- km: {
43063
- dimension: "length",
43064
- factor: 1e3,
43065
- offset: 0
43066
- },
43067
- in: {
43068
- dimension: "length",
43069
- factor: .0254,
43070
- offset: 0
43071
- },
43072
- ft: {
43073
- dimension: "length",
43074
- factor: .3048,
43075
- offset: 0
43076
- },
43077
- mi: {
43078
- dimension: "length",
43079
- factor: 1609.344,
43080
- offset: 0
43081
- },
43082
- "m²": {
43083
- dimension: "area",
43084
- factor: 1,
43085
- offset: 0
43086
- },
43087
- lx: {
43088
- dimension: "illuminance",
43089
- factor: 1,
43090
- offset: 0
43091
- },
43092
- "W/m²": {
43093
- dimension: "irradiance",
43094
- factor: 1,
43095
- offset: 0
43096
- },
43097
- W: {
43098
- dimension: "power",
43099
- factor: 1,
43100
- offset: 0
43101
- },
43102
- kW: {
43103
- dimension: "power",
43104
- factor: 1e3,
43105
- offset: 0
43106
- },
43107
- VA: {
43108
- dimension: "apparent-power",
43109
- factor: 1,
43110
- offset: 0
43111
- },
43112
- Wh: {
43113
- dimension: "energy",
43114
- factor: 1,
43115
- offset: 0
43116
- },
43117
- kWh: {
43118
- dimension: "energy",
43119
- factor: 1e3,
43120
- offset: 0
43121
- },
43122
- MWh: {
43123
- dimension: "energy",
43124
- factor: 1e6,
43125
- offset: 0
43126
- },
43127
- V: {
43128
- dimension: "voltage",
43129
- factor: 1,
43130
- offset: 0
43131
- },
43132
- mV: {
43133
- dimension: "voltage",
43134
- factor: .001,
43135
- offset: 0
43136
- },
43137
- A: {
43138
- dimension: "current",
43139
- factor: 1,
43140
- offset: 0
43141
- },
43142
- mA: {
43143
- dimension: "current",
43144
- factor: .001,
43145
- offset: 0
43146
- },
43147
- ppm: {
43148
- dimension: "concentration-volume",
43149
- factor: 1,
43150
- offset: 0
43151
- },
43152
- ppb: {
43153
- dimension: "concentration-volume",
43154
- factor: .001,
43155
- offset: 0
43156
- },
43157
- "µg/m³": {
43158
- dimension: "concentration-mass",
43159
- factor: 1,
43160
- offset: 0
43161
- },
43162
- "mg/m³": {
43163
- dimension: "concentration-mass",
43164
- factor: 1e3,
43165
- offset: 0
43166
- },
43167
- kg: {
43168
- dimension: "mass",
43169
- factor: 1,
43170
- offset: 0
43171
- },
43172
- g: {
43173
- dimension: "mass",
43174
- factor: .001,
43175
- offset: 0
43176
- },
43177
- lb: {
43178
- dimension: "mass",
43179
- factor: .453592,
43180
- offset: 0
43181
- },
43182
- oz: {
43183
- dimension: "mass",
43184
- factor: .0283495,
43185
- offset: 0
43186
- },
43187
- "%": {
43188
- dimension: "percentage",
43189
- factor: 1,
43190
- offset: 0
43191
- },
43192
- L: {
43193
- dimension: "volume",
43194
- factor: 1,
43195
- offset: 0
43196
- },
43197
- mL: {
43198
- dimension: "volume",
43199
- factor: .001,
43200
- offset: 0
43201
- },
43202
- gal: {
43203
- dimension: "volume",
43204
- factor: 3.785411784,
43205
- offset: 0
43206
- },
43207
- s: {
43208
- dimension: "duration",
43209
- factor: 1,
43210
- offset: 0
43211
- },
43212
- ms: {
43213
- dimension: "duration",
43214
- factor: .001,
43215
- offset: 0
43216
- },
43217
- min: {
43218
- dimension: "duration",
43219
- factor: 60,
43220
- offset: 0
43221
- },
43222
- h: {
43223
- dimension: "duration",
43224
- factor: 3600,
43225
- offset: 0
43226
- },
43227
- d: {
43228
- dimension: "duration",
43229
- factor: 86400,
43230
- offset: 0
43231
- },
43232
- B: {
43233
- dimension: "information",
43234
- factor: 1,
43235
- offset: 0
43236
- },
43237
- KiB: {
43238
- dimension: "information",
43239
- factor: 1024,
43240
- offset: 0
43241
- },
43242
- MiB: {
43243
- dimension: "information",
43244
- factor: 1024 ** 2,
43245
- offset: 0
43246
- },
43247
- GiB: {
43248
- dimension: "information",
43249
- factor: 1024 ** 3,
43250
- offset: 0
43251
- },
43252
- TiB: {
43253
- dimension: "information",
43254
- factor: 1024 ** 4,
43255
- offset: 0
43256
- },
43257
- kB: {
43258
- dimension: "information",
43259
- factor: 1e3,
43260
- offset: 0
43261
- },
43262
- MB: {
43263
- dimension: "information",
43264
- factor: 1e6,
43265
- offset: 0
43266
- },
43267
- GB: {
43268
- dimension: "information",
43269
- factor: 1e9,
43270
- offset: 0
43271
- },
43272
- "°": {
43273
- dimension: "angle",
43274
- factor: 1,
43275
- offset: 0
43276
- },
43277
- dBFS: {
43278
- dimension: "sound-level",
43279
- factor: 1,
43280
- offset: 0
43281
- },
43282
- dBm: {
43283
- dimension: "signal-level",
43284
- factor: 1,
43285
- offset: 0
43286
- },
43287
- mired: {
43288
- dimension: "colour-temperature",
43289
- factor: 1,
43290
- offset: 0
43291
- },
43292
- kbps: {
43293
- dimension: "bitrate",
43294
- factor: 1,
43295
- offset: 0
43296
- },
43297
- Mbps: {
43298
- dimension: "bitrate",
43299
- factor: 1e3,
43300
- offset: 0
43301
- },
43302
- fps: {
43303
- dimension: "rate",
43304
- factor: 1,
43305
- offset: 0
43306
- }
43307
- };
43308
- /** Resolve a unit's `UnitSpec`, or `undefined` when the spelling is unknown. */
43309
- function specFor(unit) {
43310
- return Object.hasOwn(UNIT_TABLE, unit) ? UNIT_TABLE[unit] : void 0;
43159
+ * The canonical kebab-case lucide id ({@link IconKey}). Spellings that a lucide
43160
+ * package still accepts (`home` for `house`) and this repo's own legacy ones
43161
+ * (`gauge2`) RESOLVE ({@link canonicalIconKey}) so a stored value never goes
43162
+ * stale, but they are never OFFERED by search.
43163
+ *
43164
+ * ## Search
43165
+ *
43166
+ * Over the key, the Italian/English overlay in `icon-synonyms.ts`, any words
43167
+ * the caller adds, and lucide's English tags — in that order of weight.
43168
+ */
43169
+ var KEY_SET$2 = new Set(ICON_KEYS);
43170
+ new Map([...Object.entries(ICON_ALIASES), ...Object.entries(LEGACY_ICON_ALIASES)]);
43171
+ /** Is this a canonical key of the catalog? (An alias is not — see {@link canonicalIconKey}.) */
43172
+ function isIconKey(value) {
43173
+ return typeof value === "string" && KEY_SET$2.has(value);
43311
43174
  }
43312
- /** The dimension a unit belongs to, or `undefined` for an unknown unit. */
43313
- function unitDimension(unit) {
43314
- return specFor(unit)?.dimension;
43175
+ /**
43176
+ * Wire/storage schema for one icon key.
43177
+ *
43178
+ * Deliberately NOT a `z.enum` of the catalog: ~1,700 literals would be inlined
43179
+ * into every cap router, type and API-reference row that carries an icon. The
43180
+ * check is membership in the catalog and the type is {@link IconKey}.
43181
+ */
43182
+ var IconKeySchema = custom(isIconKey, "Not an icon of the catalog");
43183
+ var ENTRIES = ICON_KEYS.map((key, index) => {
43184
+ const [categoryIndexes, tags] = ICON_META[index] ?? [[], []];
43185
+ const categories = categoryIndexes.flatMap((i) => {
43186
+ const id = ICON_CATEGORY_IDS[i];
43187
+ return id === void 0 ? [] : [id];
43188
+ });
43189
+ return {
43190
+ key,
43191
+ categories,
43192
+ primaryCategory: categories[0] ?? ICON_CATEGORY_IDS[0],
43193
+ tags,
43194
+ synonyms: ICON_SYNONYMS[key] ?? []
43195
+ };
43196
+ });
43197
+ new Map(ENTRIES.map((e) => [e.key, e]));
43198
+ /** Categories a picker offers first: the ones this product's icons mostly live in. */
43199
+ var LEADING_CATEGORIES = [
43200
+ "devices",
43201
+ "home",
43202
+ "security",
43203
+ "buildings",
43204
+ "connectivity",
43205
+ "multimedia",
43206
+ "nature",
43207
+ "weather",
43208
+ "transportation",
43209
+ "animals"
43210
+ ];
43211
+ var PRIMARY_CATEGORIES = new Set(ENTRIES.map((e) => e.primaryCategory));
43212
+ [...LEADING_CATEGORIES, ...ICON_CATEGORY_IDS.filter((c) => !LEADING_CATEGORIES.includes(c))].filter((c) => PRIMARY_CATEGORIES.has(c));
43213
+ /**
43214
+ * One (location, icon) assignment as it travels.
43215
+ *
43216
+ * `locationKey` is ALWAYS {@link locationIconKey} of the label — never the
43217
+ * operator's casing. The registry matches labels trimmed + case-insensitively
43218
+ * everywhere (`addLocation`, `removeLocation`, `renameLocation`), and a
43219
+ * case-only rename (`kitchen` → `Kitchen`) is a real edit this repo supports; a
43220
+ * map keyed on the displayed casing would orphan its entry on exactly that
43221
+ * edit. Consumers join by keying their own label through `locationIconKey`.
43222
+ */
43223
+ var LocationIconAssignmentSchema = object({
43224
+ locationKey: string(),
43225
+ icon: IconKeySchema
43226
+ });
43227
+ /**
43228
+ * One (location, description) assignment as it travels.
43229
+ *
43230
+ * Same key discipline as {@link LocationIconAssignmentSchema}, and for the same
43231
+ * reason: this lived for a while in the post-analysis addon's own settings,
43232
+ * keyed by a HAND-TYPED label matched exactly and case-sensitively. A rename in
43233
+ * the Locations page carried the icon and silently orphaned the description —
43234
+ * two authorities for one thing, joined by two different rules. Now both hang
43235
+ * off the location itself, on `locationIconKey`.
43236
+ */
43237
+ var LocationDescriptionAssignmentSchema = object({
43238
+ locationKey: string(),
43239
+ description: string()
43240
+ });
43241
+ /**
43242
+ * WHO an action step acts on (D983) — one target shape for every place that
43243
+ * performs an action (automation steps, Action entries, notification
43244
+ * sequences, scheduler points):
43245
+ *
43246
+ * - `devices` — device ids the operator picked, frozen at save time;
43247
+ * - `domain` — every device that offers the step's VOCABULARY action,
43248
+ * optionally narrowed to one device type and one room, resolved WHEN THE
43249
+ * STEP RUNS (a device added later is included). The action always comes
43250
+ * from the vocabulary (`cover.open`), never from a raw cap name, so a
43251
+ * `domain` target needs an `actionId` (enforced on the step schema);
43252
+ * - `var` — a `$var` resolved from the run's scope.
43253
+ *
43254
+ * {@link ActionTargetResolver} turns a target into device ids. It is pure
43255
+ * (a {@link DeviceDirectory} is handed in) so the hub's core-blocks service and
43256
+ * a generated automation block share it.
43257
+ *
43258
+ * A room is the device's `location` label (`DeviceInfo.location`); two labels
43259
+ * name the same room when `locationIconKey` agrees (trimmed, lower-cased).
43260
+ */
43261
+ var ActionTargetSchema = discriminatedUnion("kind", [
43262
+ object({
43263
+ kind: literal("devices"),
43264
+ ids: array(number().int()).min(1)
43265
+ }),
43266
+ object({
43267
+ kind: literal("domain"),
43268
+ /** Narrow to one kind of device. */
43269
+ deviceType: _enum(DeviceType).optional(),
43270
+ /** Narrow to one room: the `location` label devices carry. */
43271
+ roomId: string().min(1).optional()
43272
+ }),
43273
+ object({
43274
+ kind: literal("var"),
43275
+ name: string().min(1)
43276
+ })
43277
+ ]);
43278
+ EventCategory.DeviceRegistered, EventCategory.DeviceUnregistered, EventCategory.DeviceUpdated, EventCategory.DeviceMetaChanged, EventCategory.DeviceBindingsChanged;
43279
+ var ExpressionBindingSourceSchema = union([
43280
+ object({
43281
+ kind: literal("field").optional(),
43282
+ sourceKey: string(),
43283
+ cap: string(),
43284
+ fieldPath: string()
43285
+ }),
43286
+ object({
43287
+ kind: literal("literal"),
43288
+ value: union([
43289
+ string(),
43290
+ number(),
43291
+ boolean(),
43292
+ _null()
43293
+ ])
43294
+ }),
43295
+ object({
43296
+ kind: literal("global"),
43297
+ sourceStableId: string(),
43298
+ addonId: string().optional(),
43299
+ cap: string(),
43300
+ fieldPath: string()
43301
+ })
43302
+ ]);
43303
+ object({
43304
+ expr: string().min(1).max(MAX_EXPRESSION_SOURCE_LENGTH),
43305
+ bindings: record(string().regex(EXPRESSION_IDENTIFIER_RE), ExpressionBindingSourceSchema)
43306
+ }).superRefine((src, ctx) => {
43307
+ const err = validateExpressionSource(src);
43308
+ if (err !== null) ctx.addIssue({
43309
+ code: "custom",
43310
+ message: err,
43311
+ path: ["expr"]
43312
+ });
43313
+ });
43314
+ /**
43315
+ * Identity envelope for a device's upstream-system metadata.
43316
+ *
43317
+ * Two jobs:
43318
+ *
43319
+ * 1. **Dispatch key.** `id` is the natural identifier the SOURCE system
43320
+ * uses to address this device (HA `entity_id`, Reolink MAC, ONVIF
43321
+ * WS-Discovery endpoint UUID, …). Provider code keeps a
43322
+ * `Map<sourceInfo.id, IDevice>` to route inbound push events in O(1)
43323
+ * without round-tripping through `stableId` / `id` mappings.
43324
+ *
43325
+ * 2. **Stability bridge.** `uniqueId` is the *immutable* upstream id when
43326
+ * one exists (HA `entity.unique_id`, Reolink MAC again — same as `id`
43327
+ * for vendors where MAC is the natural key). For systems where the
43328
+ * live dispatch key can be renamed (HA `entity_id` can be edited),
43329
+ * providers detect renames by matching `uniqueId` and patch `id`
43330
+ * in-place so dispatch keeps working.
43331
+ *
43332
+ * **Display unit and precision are NOT stored here.** They are a read-time
43333
+ * preference (D944). A polymorphic reading stores its `quantity` here once,
43334
+ * at adopt, and a date/time value stores `dateTimeShape` the same way —
43335
+ * neither is repeated on each sample. The `device_class` tag is an
43336
+ * HA-specific input consumed at the discovery boundary (`ha-domain-mapping`)
43337
+ * to derive the CamStack `DeviceRole`; it is never stored after that point.
43338
+ *
43339
+ * The `raw` escape hatch carries provider-specific attributes that don't
43340
+ * fit the structured slots (HA `attributes` whitelist, Reolink `deviceCache`
43341
+ * details, …). Providers control what lands here.
43342
+ */
43343
+ var SourceInfoSchema = object({
43344
+ /** Live dispatch key — mutable when the source system allows rename. */
43345
+ id: string(),
43346
+ /** Source system tag — e.g. 'homeassistant' | 'reolink' | 'onvif'. */
43347
+ system: string(),
43348
+ /** Immutable upstream identifier when available (HA `unique_id`, … ).
43349
+ * Used to detect rename when `id` changes. */
43350
+ uniqueId: string().optional(),
43351
+ /** Quantity of a polymorphic reading, written once at adopt (D944). */
43352
+ quantity: ReadingQuantitySchema.optional(),
43353
+ /** Date / time / datetime shape of a string reading, written once at adopt. */
43354
+ dateTimeShape: _enum([
43355
+ "date",
43356
+ "time",
43357
+ "datetime"
43358
+ ]).optional(),
43359
+ /** Provider-specific extras that don't fit the structured slots.
43360
+ * Whitelist what goes here per provider — do NOT dump entire HA
43361
+ * attribute blobs (would explode the meta JSON column). */
43362
+ raw: record(string(), unknown()).optional()
43363
+ });
43364
+ /**
43365
+ * Build the synthetic SourceInfo every existing provider falls back to
43366
+ * when no upstream value has been persisted. Keeps non-migrated providers
43367
+ * (Reolink / Hikvision / ONVIF / RTSP) functional without code
43368
+ * changes — `id` reuses the CamStack stableId, `system` reuses the addon
43369
+ * id. Real upstream identity replaces this once a provider migrates and
43370
+ * calls `updateSourceInfo()` with concrete values.
43371
+ */
43372
+ function synthesizeSourceInfo(input) {
43373
+ return {
43374
+ id: input.stableId,
43375
+ system: input.addonId
43376
+ };
43315
43377
  }
43316
- /** Value in `spec`'s unit → its dimension's canonical unit. */
43317
- function toCanonical(value, spec) {
43318
- return value * spec.factor + spec.offset;
43378
+ /**
43379
+ * Shallow-merge a partial patch over a prior SourceInfo. `undefined`
43380
+ * patch values are ignored (no field clobber); to clear a field
43381
+ * explicitly, providers omit it from the patch and rebuild from scratch
43382
+ * via `updateSourceInfo({})` cycles — uncommon enough that we don't
43383
+ * bother with a `null`-means-delete sentinel.
43384
+ *
43385
+ * The `raw` field is also shallow-merged: passing `raw: { foo: 1 }`
43386
+ * merges over existing `raw` keys instead of replacing the whole bag.
43387
+ */
43388
+ function mergeSourceInfo(prev, patch) {
43389
+ const next = { ...prev };
43390
+ for (const [k, v] of Object.entries(patch)) {
43391
+ if (v === void 0) continue;
43392
+ if (k === "raw" && typeof v === "object" && v !== null) {
43393
+ next.raw = {
43394
+ ...prev.raw,
43395
+ ...v
43396
+ };
43397
+ continue;
43398
+ }
43399
+ next[k] = v;
43400
+ }
43401
+ return next;
43319
43402
  }
43320
- /** Canonical-unit value → the unit described by `spec`. */
43321
- function fromCanonical(canonical, spec) {
43322
- return (canonical - spec.offset) / spec.factor;
43403
+ /**
43404
+ * Coerce common unit-of-measurement string variants to a canonical form
43405
+ * so the UI's display templates can rely on stable strings. Pure
43406
+ * passthrough for unknown units — kept conservative on purpose, the goal
43407
+ * is to normalise the long tail of HA `unit_of_measurement` values that
43408
+ * have multiple historical spellings (`'°C'` vs `'C'` vs `'celsius'`).
43409
+ *
43410
+ * Extend the map as we encounter real-world data. Returning the raw
43411
+ * input for unknown values is intentional: providers should never
43412
+ * lose information silently here.
43413
+ */
43414
+ function normalizeUnit(raw) {
43415
+ if (raw == null) return void 0;
43416
+ const trimmed = raw.trim();
43417
+ if (trimmed === "") return void 0;
43418
+ const lower = trimmed.toLowerCase();
43419
+ if (lower === "°c" || lower === "c" || lower === "celsius") return "°C";
43420
+ if (lower === "°f" || lower === "f" || lower === "fahrenheit") return "°F";
43421
+ if (lower === "k" || lower === "kelvin") return "K";
43422
+ if (lower === "%" || lower === "percent" || lower === "percentage") return "%";
43423
+ if (lower === "lx" || lower === "lux") return "lx";
43424
+ if (lower === "hpa" || lower === "hectopascal") return "hPa";
43425
+ if (lower === "kpa") return "kPa";
43426
+ if (lower === "pa") return "Pa";
43427
+ if (lower === "mbar" || lower === "millibar") return "mbar";
43428
+ if (lower === "w" || lower === "watt") return "W";
43429
+ if (lower === "kw" || lower === "kilowatt") return "kW";
43430
+ if (lower === "wh" || lower === "watt-hour") return "Wh";
43431
+ if (lower === "kwh" || lower === "kilowatt-hour") return "kWh";
43432
+ if (lower === "v" || lower === "volt") return "V";
43433
+ if (lower === "a" || lower === "amp" || lower === "ampere") return "A";
43434
+ if (lower === "ma" || lower === "milliampere") return "mA";
43435
+ if (lower === "va") return "VA";
43436
+ if (lower === "ppm") return "ppm";
43437
+ if (lower === "ppb") return "ppb";
43438
+ if (lower === "µg/m³" || lower === "ug/m3" || lower === "µg/m3") return "µg/m³";
43439
+ if (lower === "km/h" || lower === "kph") return "km/h";
43440
+ if (lower === "mph") return "mph";
43441
+ if (lower === "m/s") return "m/s";
43442
+ if (lower === "m") return "m";
43443
+ if (lower === "m²" || lower === "m2") return "m²";
43444
+ if (lower === "mm") return "mm";
43445
+ if (lower === "cm") return "cm";
43446
+ if (lower === "km") return "km";
43447
+ if (lower === "in" || lower === "inch" || lower === "inches") return "in";
43448
+ if (lower === "ft" || lower === "foot" || lower === "feet") return "ft";
43449
+ if (lower === "kg") return "kg";
43450
+ if (lower === "g") return "g";
43451
+ if (lower === "l" || lower === "liter" || lower === "litre" || lower === "liters" || lower === "litres") return "L";
43452
+ if (lower === "ml") return "mL";
43453
+ if (lower === "gal" || lower === "gallon" || lower === "gallons") return "gal";
43454
+ if (lower === "s" || lower === "sec" || lower === "second" || lower === "seconds") return "s";
43455
+ if (lower === "ms") return "ms";
43456
+ if (lower === "min" || lower === "minute" || lower === "minutes") return "min";
43457
+ if (lower === "h" || lower === "hr" || lower === "hour" || lower === "hours") return "h";
43458
+ if (lower === "d" || lower === "day" || lower === "days") return "d";
43459
+ if (lower === "b" || lower === "byte" || lower === "bytes") return "B";
43460
+ if (lower === "kib") return "KiB";
43461
+ if (lower === "mib") return "MiB";
43462
+ if (lower === "gib") return "GiB";
43463
+ if (lower === "tib") return "TiB";
43464
+ if (lower === "kb") return "kB";
43465
+ if (lower === "mb") return "MB";
43466
+ if (lower === "gb") return "GB";
43467
+ if (lower === "dbm") return "dBm";
43468
+ if (lower === "dbfs") return "dBFS";
43469
+ if (lower === "inhg") return "inHg";
43470
+ if (lower === "mm/h" || lower === "mm/hr") return "mm/h";
43471
+ if (lower === "in/h" || lower === "in/hr") return "in/h";
43472
+ if (lower === "w/m²" || lower === "w/m2") return "W/m²";
43473
+ if (lower === "°" || lower === "deg" || lower === "degree" || lower === "degrees") return "°";
43474
+ if (lower === "kbps") return "kbps";
43475
+ if (lower === "fps") return "fps";
43476
+ return trimmed;
43323
43477
  }
43324
43478
  /**
43325
- * Graceful variant for the render path: returns the converted value, or
43326
- * `undefined` when the conversion is refused (unknown unit / cross-dimension).
43327
- * Never throws — a render caller falls back to the raw value + source unit.
43479
+ * Key under which `SourceInfo` lives inside `DeviceMeta.metadata`. The
43480
+ * blob is a free-form `Record<string, unknown>` shared with hardware-
43481
+ * identity fields (`manufacturer`, `model`, `firmware`, …); SourceInfo
43482
+ * lives under a single nested key to keep it composable with those.
43328
43483
  */
43329
- function tryConvertUnit(value, from, to) {
43330
- if (from === to) return value;
43331
- const fromSpec = specFor(from);
43332
- if (!fromSpec) return void 0;
43333
- const toSpec = specFor(to);
43334
- if (!toSpec) return void 0;
43335
- if (fromSpec.dimension !== toSpec.dimension) return void 0;
43336
- return fromCanonical(toCanonical(value, fromSpec), toSpec);
43484
+ var SOURCE_INFO_METADATA_KEY = "sourceInfo";
43485
+ /**
43486
+ * Extract a SourceInfo from a `DeviceMeta.metadata` blob, validating
43487
+ * with Zod. Returns `null` when the blob is missing or the nested
43488
+ * `sourceInfo` key fails validation — callers fall back to the
43489
+ * synthetic default in that case (see `synthesizeSourceInfo`).
43490
+ */
43491
+ function extractSourceInfoFromMetadata(metadata) {
43492
+ if (!metadata) return null;
43493
+ const raw = metadata[SOURCE_INFO_METADATA_KEY];
43494
+ if (!raw) return null;
43495
+ const parsed = SourceInfoSchema.safeParse(raw);
43496
+ if (!parsed.success) return null;
43497
+ return parsed.data;
43337
43498
  }
43338
43499
  /**
43339
43500
  * A number a person types for a physical quantity — the input side of the
@@ -45012,15 +45173,28 @@ var SettingsSchemaWithValuesSchema = object({
45012
45173
  });
45013
45174
  /** Patch object — keys are field names, values are the new field values. */
45014
45175
  var SettingsPatchSchema = record(string(), unknown());
45176
+ /** The scope of a scoped-settings call (D986): where the capability declared the values. */
45177
+ var ScopedSettingsScopeSchema = _enum(SCOPED_SETTINGS_SCOPES);
45178
+ /** One scoped schema an addon serves: its capability, scope and section ids. */
45179
+ var ScopedSettingsDeclarationSchema = object({
45180
+ cap: string(),
45181
+ scope: ScopedSettingsScopeSchema,
45182
+ sectionIds: array(string())
45183
+ });
45015
45184
  /** Standard success response for update operations. */
45016
45185
  var SettingsUpdateResultSchema = object({ success: literal(true) });
45017
45186
  method(object({
45018
45187
  addonId: string(),
45019
- nodeId: string().optional(),
45020
- overlay: record(string(), unknown()).optional(),
45021
- cap: string().optional()
45188
+ cap: string(),
45189
+ scope: ScopedSettingsScopeSchema,
45190
+ nodeId: string().optional()
45022
45191
  }), SettingsSchemaWithValuesSchema.nullable()), method(object({
45023
45192
  addonId: string(),
45193
+ nodeId: string().optional()
45194
+ }), array(ScopedSettingsDeclarationSchema).nullable()), method(object({
45195
+ addonId: string(),
45196
+ cap: string(),
45197
+ scope: ScopedSettingsScopeSchema,
45024
45198
  nodeId: string().optional(),
45025
45199
  patch: SettingsPatchSchema
45026
45200
  }), SettingsUpdateResultSchema, {
@@ -45028,8 +45202,10 @@ method(object({
45028
45202
  auth: "admin"
45029
45203
  }), method(object({
45030
45204
  addonId: string(),
45205
+ cap: string(),
45206
+ scope: ScopedSettingsScopeSchema,
45031
45207
  nodeId: string().optional()
45032
- }), SettingsSchemaWithValuesSchema.nullable()), method(object({
45208
+ }), record(string(), unknown()).nullable()), method(object({
45033
45209
  addonId: string(),
45034
45210
  nodeId: string().optional(),
45035
45211
  instance: IntegrationInstanceRefSchema
@@ -46592,7 +46768,7 @@ var BackupDestinationInfoSchema = object({
46592
46768
  id: string(),
46593
46769
  /**
46594
46770
  * Manifest id of the owning addon. The Settings button on the
46595
- * destination card opens that addon's `globalSettingsSchema` panel.
46771
+ * destination card opens that addon's scoped settings panel.
46596
46772
  */
46597
46773
  addonId: string(),
46598
46774
  /** Operator-toggled enable flag from the destination-policy table. */
@@ -50006,7 +50182,7 @@ var mediaPlayerCapability = {
50006
50182
  isMuted: { kind: "boolean" }
50007
50183
  } }
50008
50184
  };
50009
- 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;
50185
+ 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, DeviceType.MediaPlayer;
50010
50186
  var NUMBER = {
50011
50187
  kind: "fixed",
50012
50188
  result: ["number"]
@@ -52045,6 +52221,7 @@ method(InstancePinSchema, DeviceExportStatusSchema), method(_void(), array(Expor
52045
52221
  kind: "mutation",
52046
52222
  auth: "admin"
52047
52223
  });
52224
+ var DeviceAliasSchema = string().max(64).regex(/^[a-z][a-z0-9_]*$/);
52048
52225
  /**
52049
52226
  * A SITE ZONE — a named part of the property that several locations belong to.
52050
52227
  *
@@ -52531,6 +52708,12 @@ var DeviceInfoSchema = object({
52531
52708
  addonId: string(),
52532
52709
  type: _enum(DeviceType),
52533
52710
  name: string(),
52711
+ /** The name a value template uses for this device (`{{ stufa_veranda.temperature }}`),
52712
+ * entity_id style. Generated once from the name at first registration, unique
52713
+ * cluster-wide, editable through `setAlias`, NOT changed by a rename (D1021).
52714
+ * Optional: a record produced by an older build omits it until the boot
52715
+ * backfill has run. */
52716
+ alias: DeviceAliasSchema.optional(),
52534
52717
  /** Operator-organisational location label. `null` when unset. */
52535
52718
  location: string().nullable(),
52536
52719
  /** Soft-disabled flag. */
@@ -52850,6 +53033,25 @@ method(object({
52850
53033
  }), _void(), {
52851
53034
  kind: "mutation",
52852
53035
  auth: "admin"
53036
+ }), method(object({
53037
+ deviceId: number(),
53038
+ alias: string()
53039
+ }), discriminatedUnion("ok", [object({
53040
+ ok: literal(true),
53041
+ alias: DeviceAliasSchema
53042
+ }), object({
53043
+ ok: literal(false),
53044
+ reason: _enum([
53045
+ "empty",
53046
+ "too-long",
53047
+ "grammar",
53048
+ "reserved",
53049
+ "taken"
53050
+ ]),
53051
+ takenBy: number().optional()
53052
+ })]), {
53053
+ kind: "mutation",
53054
+ auth: "admin"
52853
53055
  }), method(object({
52854
53056
  deviceId: number(),
52855
53057
  location: string().nullable()
@@ -56559,7 +56761,7 @@ method(_void(), array(IntegrationWithStateSchema)), method(object({ id: string()
56559
56761
  * or the redaction token KEEPS the stored secret; `{ $secretClear: true }`
56560
56762
  * clears it.
56561
56763
  */
56562
- var ConfigSchemaPassthrough$3 = custom();
56764
+ var ConfigSchemaPassthrough$2 = custom();
56563
56765
  var IntegrationInstanceIdSchema = string().min(1);
56564
56766
  var IntegrationInstanceModeSchema = _enum(["single", "multiple"]);
56565
56767
  /**
@@ -56605,7 +56807,16 @@ var IntegrationInstanceKindSchema = object({
56605
56807
  /** Relative hub path to start an interactive account link of an instance of this kind. */
56606
56808
  connectPath: string().min(1).optional(),
56607
56809
  /** Relative hub path to disconnect that account. */
56608
- disconnectPath: string().min(1).optional()
56810
+ disconnectPath: string().min(1).optional(),
56811
+ /**
56812
+ * Parts of the edit dialog the flat form cannot draw (a node picker, a model source), named by a
56813
+ * GENERIC widget id the client maps to a component; a client that knows none of them shows none.
56814
+ * `connection` widgets write connection values, `model` widgets own the model choice.
56815
+ */
56816
+ widgets: array(object({
56817
+ id: string().min(1),
56818
+ placement: _enum(["connection", "model"])
56819
+ })).optional()
56609
56820
  });
56610
56821
  /**
56611
56822
  * How devices of an instance are found. `none`: the operator adds them by hand; `lan`: the addon
@@ -56646,10 +56857,11 @@ var IntegrationInstanceDescriptionSchema = object({
56646
56857
  /** True when `testInstance` really probes the remote. */
56647
56858
  canTest: boolean(),
56648
56859
  /**
56649
- * The kinds an instance can be of. Absent or one entry: nothing to choose; more than one: the
56650
- * Add flow asks which first and sends it as `createInstance.kind`.
56860
+ * The kinds an instance can be of (D1013 rule 1), each naming its `functionCap`. One entry:
56861
+ * nothing to choose; more than one: the Add flow asks which first and sends it as
56862
+ * `createInstance.kind`. Never empty: every instance belongs to exactly one kind.
56651
56863
  */
56652
- kinds: array(IntegrationInstanceKindSchema).optional(),
56864
+ kinds: array(IntegrationInstanceKindSchema).min(1),
56653
56865
  /**
56654
56866
  * The provider accepts `createInstance.id` for an id that once existed (an adopted id, because
56655
56867
  * devices carry it). The UI then offers "restore under its old id" on Add. Absent means no.
@@ -56685,8 +56897,8 @@ var IntegrationInstanceSchema = object({
56685
56897
  * the body is the one store, `setInstanceEnabled` the one writer (epic #440, step 3).
56686
56898
  */
56687
56899
  enabled: boolean().optional(),
56688
- /** The kind of this instance (one of `describe().kinds[].id`), when the provider has kinds. */
56689
- kind: string().optional(),
56900
+ /** The kind of this instance: exactly one of `describe().kinds[].id` (D1013 rule 2). */
56901
+ kind: string().min(1),
56690
56902
  /** Values for the instance form; a secret is a `SecretFieldView`, never text. */
56691
56903
  formValues: record(string(), unknown()),
56692
56904
  status: IntegrationInstanceStatusSchema.optional(),
@@ -56710,7 +56922,7 @@ var integrationInstancesCapability = {
56710
56922
  id: IntegrationInstanceIdSchema.nullable(),
56711
56923
  /** The kind of the create form (`id: null`) of a provider with several. */
56712
56924
  kind: string().min(1).optional()
56713
- }), ConfigSchemaPassthrough$3, { auth: "admin" }),
56925
+ }), ConfigSchemaPassthrough$2, { auth: "admin" }),
56714
56926
  listInstances: method(_void(), array(IntegrationInstanceSchema).readonly(), { auth: "admin" }),
56715
56927
  getInstance: method(object({ id: IntegrationInstanceIdSchema }), IntegrationInstanceSchema.nullable(), { auth: "admin" }),
56716
56928
  /**
@@ -57812,12 +58024,12 @@ var LlmModelInfoSchema = object({
57812
58024
  });
57813
58025
  /**
57814
58026
  * The provider-specific part of a profile, validated by the provider that owns
57815
- * the kind (`upsertProfile` refuses what it does not accept). A field its
58027
+ * the kind (saving an instance refuses what it does not accept). A field its
57816
58028
  * `connectionSchema` declares `type: 'password'` is a secret: it is held in the
57817
58029
  * keychain, never in the row, and reads back as the redaction marker.
57818
58030
  */
57819
58031
  var LlmProviderConfigSchema = record(string(), unknown());
57820
- var LlmProfileSchema = object({
58032
+ object({
57821
58033
  id: string(),
57822
58034
  name: string(),
57823
58035
  /** The provider-declared kind (`LlmProfileKindDescriptor.kind`). */
@@ -57911,8 +58123,8 @@ var LlmProviderWidgetSchema = object({
57911
58123
  /** ConfigUISchema tree passed through untyped on the wire (the
57912
58124
  * notification-output `ConfigSchemaPassthrough` precedent at
57913
58125
  * notification-output.cap.ts:151); the exported TS type re-tightens it. */
57914
- var ConfigSchemaPassthrough$2 = unknown();
57915
- var LlmProfileKindDescriptorSchema = object({
58126
+ var ConfigSchemaPassthrough$1 = unknown();
58127
+ object({
57916
58128
  kind: LlmProfileKindSchema,
57917
58129
  label: string(),
57918
58130
  /** A generic icon name (`cloud`, `plug`, `cpu`) — never a glyph or a logo. */
@@ -57920,9 +58132,9 @@ var LlmProfileKindDescriptorSchema = object({
57920
58132
  /** Stamped by each provider so the concat-fanned catalog stays routable. */
57921
58133
  addonId: string(),
57922
58134
  /** The provider's own fields (`providerConfig`); `password` fields are keychain-held. */
57923
- connectionSchema: ConfigSchemaPassthrough$2,
58135
+ connectionSchema: ConfigSchemaPassthrough$1,
57924
58136
  /** Provider fields that belong under "Advanced" (extra headers, runtime tuning). */
57925
- advancedSchema: ConfigSchemaPassthrough$2.optional(),
58137
+ advancedSchema: ConfigSchemaPassthrough$1.optional(),
57926
58138
  /** The kind's defaults; a model from `listModels` may override any of them. */
57927
58139
  features: LlmModelFeaturesSchema,
57928
58140
  /** `false` = the provider stamps `supportsVision` itself (from what a node reports). */
@@ -58051,20 +58263,7 @@ method(LlmGenerateBaseInputSchema, LlmGenerateResultSchema, {
58051
58263
  }), method(object({
58052
58264
  addonId: string().optional(),
58053
58265
  requestId: string()
58054
- }), _void(), { kind: "mutation" }), method(object({}), array(LlmProfileKindDescriptorSchema)), method(object({}), array(LlmProfileSchema)), method(object({ profile: LlmProfileSchema }), LlmProfileSchema, {
58055
- kind: "mutation",
58056
- auth: "admin"
58057
- }), method(RawSecretMigrationInputSchema, RawSecretMigrationReportSchema, {
58058
- kind: "mutation",
58059
- auth: "admin"
58060
- }), method(ProfileRefInputSchema, _void(), {
58061
- kind: "mutation",
58062
- auth: "admin"
58063
- }), method(ProfileRefInputSchema, LlmGenerateResultSchema, {
58064
- kind: "mutation",
58065
- auth: "admin",
58066
- timeoutMs: AI_CAP_TRANSPORT_TIMEOUT_MS
58067
- }), method(LlmListModelsInputSchema, LlmListModelsResultSchema, {
58266
+ }), _void(), { kind: "mutation" }), method(LlmListModelsInputSchema, LlmListModelsResultSchema, {
58068
58267
  kind: "mutation",
58069
58268
  auth: "admin"
58070
58269
  }), method(object({}), array(LlmDefaultSchema)), method(object({
@@ -59127,20 +59326,7 @@ method(_void(), MeshStatusSchema), method(object({
59127
59326
  /** Optional hostname override the host should advertise once joined. */
59128
59327
  hostname: string().optional() }), object({
59129
59328
  /** Authentication URL the operator should open in a browser. */
59130
- loginUrl: string() }), { kind: "mutation" }), method(_void(), object({ left: literal(true) }), { kind: "mutation" }), method(_void(), object({ loggedOut: literal(true) }), { kind: "mutation" }), method(_void(), object({ peers: array(MeshPeerSchema).readonly() })), method(object({
59131
- /** Optional auth key — when provided, probes the key validity
59132
- * against the provider's API. Omit when already joined to
59133
- * just ping the daemon. */
59134
- authKey: string().optional() }), object({
59135
- ok: boolean(),
59136
- /** Provider-side identifier resolved by the probe (tailnet
59137
- * name for Tailscale, network id for ZeroTier, etc.). */
59138
- tenant: string().optional(),
59139
- /** Daemon binary version, when reachable. */
59140
- daemonVersion: string().optional(),
59141
- /** Human-readable error when `ok: false`. */
59142
- error: string().optional()
59143
- }), { kind: "mutation" });
59329
+ loginUrl: string() }), { kind: "mutation" }), method(_void(), object({ left: literal(true) }), { kind: "mutation" }), method(_void(), object({ loggedOut: literal(true) }), { kind: "mutation" }), method(_void(), object({ peers: array(MeshPeerSchema).readonly() }));
59144
59330
  /**
59145
59331
  * A monotonic total between resets (D944). Energy uses `power-meter.energy`
59146
59332
  * so dashboards keep one series; every other instantaneous reading lands here.
@@ -66967,6 +67153,11 @@ var NcScheduleSchema = object({
66967
67153
  * as a STATE SUMMARY at the end of each window of `schedule`.
66968
67154
  */
66969
67155
  var NcSystemEventDeliveryModeSchema = _enum(["instant", "summary"]);
67156
+ _enum([
67157
+ "activation",
67158
+ "deactivation",
67159
+ "schedule"
67160
+ ]);
66970
67161
  /**
66971
67162
  * How a summary window is SENT (D698): `rule` (absent) = ONE notification with
66972
67163
  * every section; `section` = one notification per section with something to
@@ -66983,11 +67174,26 @@ var NcStateSummarySplitSchema = _enum(["rule", "section"]);
66983
67174
  * midnight crossing); the send time is each window's END. Refused on the
66984
67175
  * `alarm` family, which stays instant (`systemEventDeliveryProblems`).
66985
67176
  */
66986
- var NcSystemEventDeliverySchema = discriminatedUnion("mode", [object({ mode: literal("instant") }), object({
66987
- mode: literal("summary"),
66988
- schedule: NcScheduleSchema,
66989
- split: NcStateSummarySplitSchema.optional()
66990
- })]);
67177
+ var NcSystemEventDeliverySchema = discriminatedUnion("mode", [
67178
+ object({ mode: literal("instant") }),
67179
+ object({
67180
+ mode: literal("summary"),
67181
+ schedule: NcScheduleSchema,
67182
+ split: NcStateSummarySplitSchema.optional()
67183
+ }),
67184
+ object({
67185
+ mode: literal("modes"),
67186
+ /** The bad edge, and every kind that has a single edge. */
67187
+ onActivation: boolean(),
67188
+ /** The recovery edges of the classes of the selected kinds (derived, never stored per kind). */
67189
+ onDeactivation: boolean(),
67190
+ /** A state summary at the end of each window; absent = no summary. */
67191
+ onSchedule: object({
67192
+ schedule: NcScheduleSchema,
67193
+ grouping: NcStateSummarySplitSchema
67194
+ }).optional()
67195
+ })
67196
+ ]);
66991
67197
  /** Fuzzy plate matcher — OCR noise makes exact match useless (spec row 12/13). */
66992
67198
  var NcPlateMatcherSchema = object({
66993
67199
  /**
@@ -69347,61 +69553,6 @@ var OauthIntegrationDescriptorSchema = object({
69347
69553
  });
69348
69554
  method(_void(), OauthIntegrationDescriptorSchema, { auth: "admin" });
69349
69555
  /**
69350
- * `oidc-connections` — CRUD for IdP rows under `auth-oidc` (D828 sibling).
69351
- *
69352
- * One hub-only singleton (`auth-oidc`). The Settings UI is a DataTable +
69353
- * ItemFormDialog; there is no `editable-array` in `globalSettingsSchema`.
69354
- * Operator-chosen `id` is the URL slug (`/addon/auth-oidc/<id>/…`) and is
69355
- * immutable after create.
69356
- */
69357
- var ConfigSchemaPassthrough$1 = unknown();
69358
- var OidcConnectionSchema = object({
69359
- id: string().min(1),
69360
- displayName: string(),
69361
- icon: string(),
69362
- issuerUrl: string(),
69363
- clientId: string(),
69364
- /** Client id + secret present — never the secret value. */
69365
- configured: boolean(),
69366
- /**
69367
- * Values for the connection form schema. `clientSecret` is a keychain
69368
- * {@link SecretFieldView} or `null` / `''`, never plaintext (D789).
69369
- */
69370
- formValues: record(string(), unknown()).optional()
69371
- });
69372
- /**
69373
- * Patch one connection. Omitted or empty `clientSecret` keeps the stored
69374
- * secret (D787). `{ $secretClear: true }` clears it. `id` is never renamed.
69375
- */
69376
- var OidcConnectionUpdateInputSchema = object({
69377
- id: string().min(1),
69378
- displayName: string().min(1),
69379
- icon: string().optional(),
69380
- issuerUrl: string().optional(),
69381
- clientId: string().optional(),
69382
- clientSecret: union([string(), object({ $secretClear: literal(true) })]).optional(),
69383
- redirectUri: string().optional(),
69384
- scopes: string().optional(),
69385
- usernameClaim: _enum([
69386
- "preferred_username",
69387
- "email",
69388
- "sub"
69389
- ]).optional()
69390
- });
69391
- method(object({}), ConfigSchemaPassthrough$1, { auth: "admin" }), method(object({}), array(OidcConnectionSchema).readonly(), { auth: "admin" }), method(object({
69392
- id: string().min(1).regex(/^[a-z0-9][a-z0-9-]{0,63}$/, "id must be a lowercase slug"),
69393
- displayName: string().min(1)
69394
- }), object({ id: string() }), {
69395
- kind: "mutation",
69396
- auth: "admin"
69397
- }), method(OidcConnectionUpdateInputSchema, object({ ok: literal(true) }), {
69398
- kind: "mutation",
69399
- auth: "admin"
69400
- }), method(object({ id: string().min(1) }), object({ ok: literal(true) }), {
69401
- kind: "mutation",
69402
- auth: "admin"
69403
- });
69404
- /**
69405
69556
  * Generic on-screen-display (video overlay) cap. Each camera exposes
69406
69557
  * a firmware-defined list of overlays (channel name, timestamp,
69407
69558
  * watermark, logo, …); the cap models them as a homogeneous array of
@@ -75116,6 +75267,16 @@ var RemoteLayoutComponentSchema = object({
75116
75267
  method(object({}), array(RemoteLayoutComponentSchema), { auth: "protected" });
75117
75268
  var RUNNING_POWER_START_DELAY_MS = 3e4;
75118
75269
  var RUNNING_POWER_STOP_DELAY_MS = 18e4;
75270
+ /**
75271
+ * Per-type overrides of the dwell defaults. A media player draws power the
75272
+ * moment it is on and stops drawing the moment it is off, so it needs neither
75273
+ * a long dwell nor a second sample. A type absent here keeps the global values.
75274
+ */
75275
+ var RUNNING_POWER_DEFAULTS_BY_TYPE = { [DeviceType.MediaPlayer]: {
75276
+ startDwellMs: 1e4,
75277
+ stopDwellMs: 1e4,
75278
+ minSamples: 1
75279
+ } };
75119
75280
  var RunningStateSourceSchema = _enum(["native", "assigned"]);
75120
75281
  var RunningStateStatusSchema = object({
75121
75282
  /** null = unknown — never coerced to false (D393). */
@@ -75133,93 +75294,27 @@ var RunningFlipEventDataSchema = object({
75133
75294
  phase: string().nullable()
75134
75295
  });
75135
75296
  var RUNNING_DEVICE_TYPES = Object.values(DeviceType);
75136
- /** Generic Customize target for the running boolean (D936). */
75137
- var runningCustomize = {
75138
- version: 1,
75139
- overridable: [{
75140
- path: "running",
75141
- by: "running"
75142
- }],
75143
- targets: [{
75144
- id: "running",
75145
- cardinality: "scalar",
75146
- vocabulary: {
75147
- cap: "running-state",
75148
- stateField: "running"
75149
- },
75150
- deviceTypes: [
75151
- DeviceType.Washer,
75152
- DeviceType.Dryer,
75153
- DeviceType.Dishwasher,
75154
- DeviceType.Vacuum,
75155
- DeviceType.LawnMower,
75156
- DeviceType.MediaPlayer,
75157
- DeviceType.WaterHeater,
75158
- DeviceType.Humidifier,
75159
- DeviceType.Fan,
75160
- DeviceType.Climate,
75161
- DeviceType.Thermostat,
75162
- DeviceType.PetFeeder,
75163
- DeviceType.Heater
75164
- ],
75165
- apply: "add",
75166
- path: "running",
75167
- sources: [
75168
- {
75169
- kind: "switch",
75170
- transforms: [{ kind: "identity" }]
75171
- },
75172
- {
75173
- kind: "binary",
75174
- transforms: [{ kind: "identity" }, { kind: "invert" }]
75175
- },
75176
- {
75177
- kind: "numeric",
75178
- requiredUnit: "W",
75179
- transforms: [{
75180
- kind: "threshold",
75181
- comparisons: ["gte", "lte"],
75182
- comparison: "gte",
75183
- defaultThreshold: 5,
75184
- defaultStartDwellMs: RUNNING_POWER_START_DELAY_MS,
75185
- defaultStopDwellMs: RUNNING_POWER_STOP_DELAY_MS,
75186
- thresholdUnit: "W"
75187
- }]
75188
- }
75189
- ],
75190
- companions: [
75191
- {
75192
- kind: "constant",
75193
- path: "source",
75194
- value: "assigned",
75195
- when: "always"
75196
- },
75197
- {
75198
- kind: "constant",
75199
- path: "phase",
75200
- value: null,
75201
- when: "add"
75202
- },
75203
- {
75204
- kind: "clock",
75205
- path: "lastFetchedAt",
75206
- when: "always"
75207
- },
75208
- {
75209
- kind: "transition-time",
75210
- path: "since",
75211
- sourceChangedAt: "prefer"
75212
- }
75213
- ],
75214
- sourceReport: {
75215
- status: "assignment-status",
75216
- runtimeField: "source",
75217
- nativeValue: "native",
75218
- assignedValue: "assigned"
75219
- },
75220
- advancedExpression: true
75221
- }]
75222
- };
75297
+ /**
75298
+ * Customize offers "running" only where a job makes sense (D933): a cycle,
75299
+ * a clean, a mow, playback, or another appliance that is on and working.
75300
+ * The cap itself stays on every type — a camera can still report running
75301
+ * natively; it just has no card.
75302
+ */
75303
+ var RUNNING_CUSTOMIZE_DEVICE_TYPES = [
75304
+ DeviceType.Washer,
75305
+ DeviceType.Dryer,
75306
+ DeviceType.Dishwasher,
75307
+ DeviceType.Vacuum,
75308
+ DeviceType.LawnMower,
75309
+ DeviceType.MediaPlayer,
75310
+ DeviceType.WaterHeater,
75311
+ DeviceType.Humidifier,
75312
+ DeviceType.Fan,
75313
+ DeviceType.Climate,
75314
+ DeviceType.Thermostat,
75315
+ DeviceType.PetFeeder,
75316
+ DeviceType.Heater
75317
+ ];
75223
75318
  var runningStateCapability = {
75224
75319
  name: "running-state",
75225
75320
  scope: "device",
@@ -75239,7 +75334,79 @@ var runningStateCapability = {
75239
75334
  durability: "restored",
75240
75335
  history: { fields: { running: { kind: "boolean" } } },
75241
75336
  volatileStateFields: ["lastFetchedAt"],
75242
- customize: runningCustomize
75337
+ customize: {
75338
+ version: 1,
75339
+ overridable: [{
75340
+ path: "running",
75341
+ by: "running"
75342
+ }],
75343
+ targets: [{
75344
+ id: "running",
75345
+ cardinality: "scalar",
75346
+ vocabulary: {
75347
+ cap: "running-state",
75348
+ stateField: "running"
75349
+ },
75350
+ deviceTypes: RUNNING_CUSTOMIZE_DEVICE_TYPES,
75351
+ apply: "add",
75352
+ path: "running",
75353
+ sources: [
75354
+ {
75355
+ kind: "switch",
75356
+ transforms: [{ kind: "identity" }]
75357
+ },
75358
+ {
75359
+ kind: "binary",
75360
+ transforms: [{ kind: "identity" }, { kind: "invert" }]
75361
+ },
75362
+ {
75363
+ kind: "numeric",
75364
+ requiredUnit: "W",
75365
+ transforms: [{
75366
+ kind: "threshold",
75367
+ comparisons: ["gte", "lte"],
75368
+ comparison: "gte",
75369
+ defaultThreshold: 5,
75370
+ defaultStartDwellMs: RUNNING_POWER_START_DELAY_MS,
75371
+ defaultStopDwellMs: RUNNING_POWER_STOP_DELAY_MS,
75372
+ deviceTypeDefaults: RUNNING_POWER_DEFAULTS_BY_TYPE,
75373
+ thresholdUnit: "W"
75374
+ }]
75375
+ }
75376
+ ],
75377
+ companions: [
75378
+ {
75379
+ kind: "constant",
75380
+ path: "source",
75381
+ value: "assigned",
75382
+ when: "always"
75383
+ },
75384
+ {
75385
+ kind: "constant",
75386
+ path: "phase",
75387
+ value: null,
75388
+ when: "add"
75389
+ },
75390
+ {
75391
+ kind: "clock",
75392
+ path: "lastFetchedAt",
75393
+ when: "always"
75394
+ },
75395
+ {
75396
+ kind: "transition-time",
75397
+ path: "since",
75398
+ sourceChangedAt: "prefer"
75399
+ }
75400
+ ],
75401
+ sourceReport: {
75402
+ status: "assignment-status",
75403
+ runtimeField: "source",
75404
+ nativeValue: "native",
75405
+ assignedValue: "assigned"
75406
+ },
75407
+ advancedExpression: true
75408
+ }]
75409
+ }
75243
75410
  };
75244
75411
  /**
75245
75412
  * scene-monitor — device-scoped reference-region state cap. An operator marks
@@ -76483,21 +76650,6 @@ method(object({
76483
76650
  */
76484
76651
  ttlSec: union([number().int().positive(), literal("never")]).optional()
76485
76652
  }), object({ token: string() }), { auth: "admin" }), method(object({ token: string() }), SsoBridgeClaimsSchema.nullable(), { auth: "admin" });
76486
- var ProviderListEntrySchema = discriminatedUnion("shouldSaveDiskSpace", [object({
76487
- providerId: string().min(1),
76488
- displayName: string().min(1),
76489
- configSchema: unknown(),
76490
- nodeLocal: boolean(),
76491
- shouldSaveDiskSpace: literal(true),
76492
- minFreePercent: number().min(0).max(100)
76493
- }), object({
76494
- providerId: string().min(1),
76495
- displayName: string().min(1),
76496
- configSchema: unknown(),
76497
- nodeLocal: boolean(),
76498
- shouldSaveDiskSpace: literal(false),
76499
- minFreePercent: literal(null)
76500
- })]);
76501
76653
  method(object({
76502
76654
  location: StorageLocationRefSchema,
76503
76655
  relativePath: string()
@@ -76559,42 +76711,7 @@ method(object({
76559
76711
  }), _instanceof(Uint8Array), { auth: "admin" }), method(object({ downloadId: string() }), _void(), {
76560
76712
  kind: "mutation",
76561
76713
  auth: "admin"
76562
- }), method(object({ type: StorageLocationTypeSchema.optional() }), array(StorageLocationSchema).readonly()), method(_void(), array(StorageLocationDeclarationSchema).readonly()), method(StorageLocationSchema.omit({
76563
- createdAt: true,
76564
- updatedAt: true
76565
- }), StorageLocationSchema, {
76566
- kind: "mutation",
76567
- auth: "admin"
76568
- }), method(object({
76569
- id: string(),
76570
- force: boolean().optional()
76571
- }), _void(), {
76572
- kind: "mutation",
76573
- auth: "admin"
76574
- }), method(_void(), array(StorageDrainProgressSchema).readonly()), method(object({ id: string() }), object({
76575
- ok: boolean(),
76576
- error: string().optional()
76577
- }), { auth: "admin" }), method(_void(), array(ProviderListEntrySchema).readonly()), method(object({
76578
- providerId: string(),
76579
- /**
76580
- * The location this config is an UNSAVED edit of, when there is one.
76581
- *
76582
- * `listLocations` replaces every declared secret with the redaction
76583
- * sentinel, so the edit modal's form state holds the sentinel for any
76584
- * credential the operator did not retype — and posting that here
76585
- * without a way to resolve it makes the provider try to authenticate
76586
- * as `__camstack_redacted__` and report the operator's own working
76587
- * password as wrong. Given this id, the orchestrator restores each
76588
- * sentinel from the stored config (same rule as `upsertLocation`)
76589
- * before dispatching. Omitted by the "Add location" wizard, where
76590
- * every value was typed just now and nothing is stored yet.
76591
- */
76592
- locationId: string().optional(),
76593
- config: record(string(), unknown())
76594
- }), object({
76595
- ok: boolean(),
76596
- error: string().optional()
76597
- }), { auth: "admin" });
76714
+ }), method(object({ type: StorageLocationTypeSchema.optional() }), array(StorageLocationSchema).readonly()), method(_void(), array(StorageLocationDeclarationSchema).readonly()), method(_void(), array(StorageDrainProgressSchema).readonly());
76598
76715
  /** One table of the settings database. */
76599
76716
  var StorageTableSchema = object({
76600
76717
  /** The table's full name, e.g. `recorder:addon-settings` or `addon-device-settings`. */
@@ -78116,7 +78233,7 @@ var TerminalInstanceInfoSchema = object({
78116
78233
  /**
78117
78234
  * False while the node the instance is bound to is not in the cluster
78118
78235
  * topology (forgotten, renamed, re-paired). The instance is kept; the
78119
- * operator re-points it with `updateInstance({ targetNodeId })`.
78236
+ * operator re-points it on the Terminal page.
78120
78237
  */
78121
78238
  nodeInCluster: boolean(),
78122
78239
  profileId: string(),
@@ -78154,41 +78271,7 @@ var TerminalOutputBatchSchema = object({
78154
78271
  snapshot: string().optional(),
78155
78272
  events: array(TerminalOutputEventSchema).readonly()
78156
78273
  });
78157
- method(_void(), array(TerminalProfileInfoSchema).readonly(), { auth: "admin" }), method(_void(), array(TerminalInstanceInfoSchema).readonly(), { auth: "admin" }), method(object({
78158
- targetNodeId: string().min(1),
78159
- profileId: string().min(1),
78160
- name: string().trim().min(1).max(160).optional(),
78161
- executable: string().max(1024).optional(),
78162
- args: array(string().max(2048)).max(64).optional(),
78163
- cwd: string().max(1024).optional(),
78164
- environment: array(string().max(4096)).max(64).optional(),
78165
- profileSettings: ProfileSettingsBagSchema.optional()
78166
- }), TerminalInstanceInfoSchema, {
78167
- kind: "mutation",
78168
- auth: "admin"
78169
- }), method(object({
78170
- instanceId: string().min(1),
78171
- /** Re-point the instance to another node; the profile must exist there. */
78172
- targetNodeId: string().min(1).max(256).optional(),
78173
- name: string().trim().min(1).max(160).optional(),
78174
- executable: string().max(1024).optional(),
78175
- args: array(string().max(2048)).max(64).optional(),
78176
- cwd: string().max(1024).optional(),
78177
- environment: array(string().max(4096)).max(64).optional(),
78178
- profileSettings: ProfileSettingsBagSchema.optional()
78179
- }), TerminalInstanceInfoSchema, {
78180
- kind: "mutation",
78181
- auth: "admin"
78182
- }), method(object({ instanceId: string().min(1) }), _void(), {
78183
- kind: "mutation",
78184
- auth: "admin"
78185
- }), method(object({
78186
- instanceId: string().min(1),
78187
- enabled: boolean()
78188
- }), TerminalInstanceInfoSchema, {
78189
- kind: "mutation",
78190
- auth: "admin"
78191
- }), method(_void(), array(TerminalLegacyCameraSchema).readonly(), { auth: "admin" }), method(object({
78274
+ method(_void(), array(TerminalProfileInfoSchema).readonly(), { auth: "admin" }), method(_void(), array(TerminalLegacyCameraSchema).readonly(), { auth: "admin" }), method(object({
78192
78275
  stableId: string().min(1),
78193
78276
  name: string().trim().min(1).max(160).optional()
78194
78277
  }), TerminalInstanceInfoSchema, {
@@ -78257,6 +78340,11 @@ var TimedRunUnitSchema = _enum(["s", "min"]);
78257
78340
  _enum(["switch", "pet-fountain"]);
78258
78341
  DeviceType.Heater, DeviceType.PetFountain;
78259
78342
  var TIMED_RUN_DEVICE_TYPES = [DeviceType.Heater, DeviceType.PetFountain];
78343
+ /** One duration, as the one-tap run asks for it. */
78344
+ var TimedRunQuickRunSchema = object({
78345
+ duration: number().positive().finite(),
78346
+ unit: TimedRunUnitSchema
78347
+ });
78260
78348
  /** Why a request was not carried out. Typed, so a caller can say it in words. */
78261
78349
  var TimedRunRefusalSchema = _enum([
78262
78350
  "unsupported-device",
@@ -78277,8 +78365,23 @@ var TimedRunStatusSchema = object({
78277
78365
  activeUntil: number().nullable(),
78278
78366
  /** Who asked for the run (a user id or an addon id); `null` when nothing is armed or it did not say. */
78279
78367
  requestedBy: string().nullable(),
78368
+ /**
78369
+ * The one-tap run of THIS device: what a "Run" button on any surface starts. `null` when
78370
+ * the device is gone or its type has no timed run; a status from before this field
78371
+ * existed has none, and a surface falls back to the type's default.
78372
+ */
78373
+ quickRun: TimedRunQuickRunSchema.nullable(),
78280
78374
  lastFetchedAt: number()
78281
78375
  });
78376
+ /** What the settings form needs: the unit, the bounds and the type's default. */
78377
+ var TimedRunOptionsSchema = object({
78378
+ unit: TimedRunUnitSchema,
78379
+ /** The longest run, in `unit`. */
78380
+ maxDuration: number(),
78381
+ defaultDuration: number()
78382
+ });
78383
+ /** The one-tap run duration, in the type's unit; `null` returns to the type's default. */
78384
+ var TimedRunSettingsPatchSchema = object({ quickRunDuration: number().positive().finite().nullable().optional() });
78282
78385
  var timedRunCapability = {
78283
78386
  name: "timed-run",
78284
78387
  scope: "device",
@@ -78286,7 +78389,24 @@ var timedRunCapability = {
78286
78389
  kind: "wrapper",
78287
78390
  defaultActive: true,
78288
78391
  deviceTypes: TIMED_RUN_DEVICE_TYPES,
78392
+ deviceConfig: { ui: {
78393
+ kind: "derived-form",
78394
+ builderId: "timed-run",
78395
+ tab: "general"
78396
+ } },
78289
78397
  methods: {
78398
+ getOptions: method(object({ deviceId: number().int() }), TimedRunOptionsSchema),
78399
+ /**
78400
+ * The one-tap run of this device. A duration above the type's maximum is
78401
+ * REFUSED (thrown), like `runFor`: the maximum is a safety bound.
78402
+ */
78403
+ setSettings: method(object({
78404
+ deviceId: number().int(),
78405
+ settings: TimedRunSettingsPatchSchema
78406
+ }), _void(), {
78407
+ kind: "mutation",
78408
+ auth: "admin"
78409
+ }),
78290
78410
  /**
78291
78411
  * Turn the device on and arm its off. A run already armed is replaced (the
78292
78412
  * new deadline wins). Refuses with a typed reason above the type's maximum.
@@ -83079,21 +83199,28 @@ Object.freeze({
83079
83199
  access: "view",
83080
83200
  role: "admin"
83081
83201
  },
83082
- "addonSettings.getGlobalSettings": {
83202
+ "addonSettings.getIntegrationFormSchema": {
83083
83203
  capName: "addon-settings",
83084
83204
  capScope: "system",
83085
83205
  addonId: null,
83086
83206
  access: "view",
83087
83207
  role: "admin"
83088
83208
  },
83089
- "addonSettings.getIntegrationFormSchema": {
83209
+ "addonSettings.getScopedSettings": {
83210
+ capName: "addon-settings",
83211
+ capScope: "system",
83212
+ addonId: null,
83213
+ access: "view",
83214
+ role: "admin"
83215
+ },
83216
+ "addonSettings.listScopedSettings": {
83090
83217
  capName: "addon-settings",
83091
83218
  capScope: "system",
83092
83219
  addonId: null,
83093
83220
  access: "view",
83094
83221
  role: "admin"
83095
83222
  },
83096
- "addonSettings.getIntegrationSettings": {
83223
+ "addonSettings.readScopedValues": {
83097
83224
  capName: "addon-settings",
83098
83225
  capScope: "system",
83099
83226
  addonId: null,
@@ -83114,7 +83241,7 @@ Object.freeze({
83114
83241
  access: "create",
83115
83242
  role: "admin"
83116
83243
  },
83117
- "addonSettings.updateGlobalSettings": {
83244
+ "addonSettings.updateScopedSettings": {
83118
83245
  capName: "addon-settings",
83119
83246
  capScope: "system",
83120
83247
  addonId: null,
@@ -85284,6 +85411,13 @@ Object.freeze({
85284
85411
  access: "create",
85285
85412
  role: "admin"
85286
85413
  },
85414
+ "deviceManager.setAlias": {
85415
+ capName: "device-manager",
85416
+ capScope: "system",
85417
+ addonId: null,
85418
+ access: "create",
85419
+ role: "admin"
85420
+ },
85287
85421
  "deviceManager.setChildLayout": {
85288
85422
  capName: "device-manager",
85289
85423
  capScope: "system",
@@ -86572,13 +86706,6 @@ Object.freeze({
86572
86706
  access: "delete",
86573
86707
  role: "admin"
86574
86708
  },
86575
- "llm.deleteProfile": {
86576
- capName: "llm",
86577
- capScope: "system",
86578
- addonId: null,
86579
- access: "delete",
86580
- role: "admin"
86581
- },
86582
86709
  "llm.generate": {
86583
86710
  capName: "llm",
86584
86711
  capScope: "system",
@@ -86642,20 +86769,6 @@ Object.freeze({
86642
86769
  access: "view",
86643
86770
  role: "admin"
86644
86771
  },
86645
- "llm.listProfileKinds": {
86646
- capName: "llm",
86647
- capScope: "system",
86648
- addonId: null,
86649
- access: "view",
86650
- role: "admin"
86651
- },
86652
- "llm.listProfiles": {
86653
- capName: "llm",
86654
- capScope: "system",
86655
- addonId: null,
86656
- access: "view",
86657
- role: "admin"
86658
- },
86659
86772
  "llm.listRuntimeNodes": {
86660
86773
  capName: "llm",
86661
86774
  capScope: "system",
@@ -86663,13 +86776,6 @@ Object.freeze({
86663
86776
  access: "view",
86664
86777
  role: "admin"
86665
86778
  },
86666
- "llm.migrateRawSecrets": {
86667
- capName: "llm",
86668
- capScope: "system",
86669
- addonId: null,
86670
- access: "create",
86671
- role: "admin"
86672
- },
86673
86779
  "llm.resolveModelRef": {
86674
86780
  capName: "llm",
86675
86781
  capScope: "system",
@@ -86698,20 +86804,6 @@ Object.freeze({
86698
86804
  access: "create",
86699
86805
  role: "admin"
86700
86806
  },
86701
- "llm.testProfile": {
86702
- capName: "llm",
86703
- capScope: "system",
86704
- addonId: null,
86705
- access: "create",
86706
- role: "admin"
86707
- },
86708
- "llm.upsertProfile": {
86709
- capName: "llm",
86710
- capScope: "system",
86711
- addonId: null,
86712
- access: "create",
86713
- role: "admin"
86714
- },
86715
86807
  "llmRuntime.appleAvailability": {
86716
86808
  capName: "llm-runtime",
86717
86809
  capScope: "system",
@@ -87216,13 +87308,6 @@ Object.freeze({
87216
87308
  access: "create",
87217
87309
  role: "admin"
87218
87310
  },
87219
- "meshNetwork.testConnection": {
87220
- capName: "mesh-network",
87221
- capScope: "system",
87222
- addonId: null,
87223
- access: "create",
87224
- role: "admin"
87225
- },
87226
87311
  "meter.getStatus": {
87227
87312
  capName: "meter",
87228
87313
  capScope: "device",
@@ -87881,13 +87966,6 @@ Object.freeze({
87881
87966
  access: "create",
87882
87967
  role: "admin"
87883
87968
  },
87884
- "notificationOutput.deleteTarget": {
87885
- capName: "notification-output",
87886
- capScope: "system",
87887
- addonId: null,
87888
- access: "delete",
87889
- role: "admin"
87890
- },
87891
87969
  "notificationOutput.discoverTargets": {
87892
87970
  capName: "notification-output",
87893
87971
  capScope: "system",
@@ -87895,13 +87973,6 @@ Object.freeze({
87895
87973
  access: "view",
87896
87974
  role: "admin"
87897
87975
  },
87898
- "notificationOutput.getTarget": {
87899
- capName: "notification-output",
87900
- capScope: "system",
87901
- addonId: null,
87902
- access: "view",
87903
- role: "admin"
87904
- },
87905
87976
  "notificationOutput.listTargetKinds": {
87906
87977
  capName: "notification-output",
87907
87978
  capScope: "system",
@@ -87909,13 +87980,6 @@ Object.freeze({
87909
87980
  access: "view",
87910
87981
  role: "admin"
87911
87982
  },
87912
- "notificationOutput.listTargets": {
87913
- capName: "notification-output",
87914
- capScope: "system",
87915
- addonId: null,
87916
- access: "view",
87917
- role: "admin"
87918
- },
87919
87983
  "notificationOutput.probeTargetConfig": {
87920
87984
  capName: "notification-output",
87921
87985
  capScope: "system",
@@ -87930,13 +87994,6 @@ Object.freeze({
87930
87994
  access: "create",
87931
87995
  role: "admin"
87932
87996
  },
87933
- "notificationOutput.setTargetEnabled": {
87934
- capName: "notification-output",
87935
- capScope: "system",
87936
- addonId: null,
87937
- access: "create",
87938
- role: "admin"
87939
- },
87940
87997
  "notificationOutput.testTarget": {
87941
87998
  capName: "notification-output",
87942
87999
  capScope: "system",
@@ -87944,13 +88001,6 @@ Object.freeze({
87944
88001
  access: "create",
87945
88002
  role: "admin"
87946
88003
  },
87947
- "notificationOutput.upsertTarget": {
87948
- capName: "notification-output",
87949
- capScope: "system",
87950
- addonId: null,
87951
- access: "create",
87952
- role: "admin"
87953
- },
87954
88004
  "notificationRules.activateAlarmProfile": {
87955
88005
  capName: "notification-rules",
87956
88006
  capScope: "system",
@@ -88210,41 +88260,6 @@ Object.freeze({
88210
88260
  access: "view",
88211
88261
  role: "admin"
88212
88262
  },
88213
- "oidcConnections.connectionFormSchema": {
88214
- capName: "oidc-connections",
88215
- capScope: "system",
88216
- addonId: null,
88217
- access: "view",
88218
- role: "admin"
88219
- },
88220
- "oidcConnections.createConnection": {
88221
- capName: "oidc-connections",
88222
- capScope: "system",
88223
- addonId: null,
88224
- access: "create",
88225
- role: "admin"
88226
- },
88227
- "oidcConnections.deleteConnection": {
88228
- capName: "oidc-connections",
88229
- capScope: "system",
88230
- addonId: null,
88231
- access: "delete",
88232
- role: "admin"
88233
- },
88234
- "oidcConnections.listConnections": {
88235
- capName: "oidc-connections",
88236
- capScope: "system",
88237
- addonId: null,
88238
- access: "view",
88239
- role: "admin"
88240
- },
88241
- "oidcConnections.updateConnection": {
88242
- capName: "oidc-connections",
88243
- capScope: "system",
88244
- addonId: null,
88245
- access: "create",
88246
- role: "admin"
88247
- },
88248
88263
  "osd.getStatus": {
88249
88264
  capName: "osd",
88250
88265
  capScope: "device",
@@ -91276,13 +91291,6 @@ Object.freeze({
91276
91291
  access: "delete",
91277
91292
  role: "admin"
91278
91293
  },
91279
- "storage.deleteLocation": {
91280
- capName: "storage",
91281
- capScope: "system",
91282
- addonId: null,
91283
- access: "delete",
91284
- role: "admin"
91285
- },
91286
91294
  "storage.endDownload": {
91287
91295
  capName: "storage",
91288
91296
  capScope: "system",
@@ -91339,13 +91347,6 @@ Object.freeze({
91339
91347
  access: "view",
91340
91348
  role: "admin"
91341
91349
  },
91342
- "storage.listProviders": {
91343
- capName: "storage",
91344
- capScope: "system",
91345
- addonId: null,
91346
- access: "view",
91347
- role: "admin"
91348
- },
91349
91350
  "storage.read": {
91350
91351
  capName: "storage",
91351
91352
  capScope: "system",
@@ -91367,27 +91368,6 @@ Object.freeze({
91367
91368
  access: "view",
91368
91369
  role: "admin"
91369
91370
  },
91370
- "storage.testConfig": {
91371
- capName: "storage",
91372
- capScope: "system",
91373
- addonId: null,
91374
- access: "view",
91375
- role: "admin"
91376
- },
91377
- "storage.testLocation": {
91378
- capName: "storage",
91379
- capScope: "system",
91380
- addonId: null,
91381
- access: "view",
91382
- role: "admin"
91383
- },
91384
- "storage.upsertLocation": {
91385
- capName: "storage",
91386
- capScope: "system",
91387
- addonId: null,
91388
- access: "create",
91389
- role: "admin"
91390
- },
91391
91371
  "storage.write": {
91392
91372
  capName: "storage",
91393
91373
  capScope: "system",
@@ -92165,27 +92145,6 @@ Object.freeze({
92165
92145
  access: "create",
92166
92146
  role: "admin"
92167
92147
  },
92168
- "terminalSession.createInstance": {
92169
- capName: "terminal-session",
92170
- capScope: "system",
92171
- addonId: null,
92172
- access: "create",
92173
- role: "admin"
92174
- },
92175
- "terminalSession.deleteInstance": {
92176
- capName: "terminal-session",
92177
- capScope: "system",
92178
- addonId: null,
92179
- access: "delete",
92180
- role: "admin"
92181
- },
92182
- "terminalSession.listInstances": {
92183
- capName: "terminal-session",
92184
- capScope: "system",
92185
- addonId: null,
92186
- access: "view",
92187
- role: "admin"
92188
- },
92189
92148
  "terminalSession.listLegacyCameras": {
92190
92149
  capName: "terminal-session",
92191
92150
  capScope: "system",
@@ -92228,20 +92187,6 @@ Object.freeze({
92228
92187
  access: "create",
92229
92188
  role: "admin"
92230
92189
  },
92231
- "terminalSession.setInstanceEnabled": {
92232
- capName: "terminal-session",
92233
- capScope: "system",
92234
- addonId: null,
92235
- access: "create",
92236
- role: "admin"
92237
- },
92238
- "terminalSession.updateInstance": {
92239
- capName: "terminal-session",
92240
- capScope: "system",
92241
- addonId: null,
92242
- access: "create",
92243
- role: "admin"
92244
- },
92245
92190
  "terminalSession.writeInput": {
92246
92191
  capName: "terminal-session",
92247
92192
  capScope: "system",
@@ -92256,6 +92201,13 @@ Object.freeze({
92256
92201
  access: "create",
92257
92202
  role: "viewer"
92258
92203
  },
92204
+ "timedRun.getOptions": {
92205
+ capName: "timed-run",
92206
+ capScope: "device",
92207
+ addonId: null,
92208
+ access: "view",
92209
+ role: "viewer"
92210
+ },
92259
92211
  "timedRun.getStatus": {
92260
92212
  capName: "timed-run",
92261
92213
  capScope: "device",
@@ -92270,6 +92222,13 @@ Object.freeze({
92270
92222
  access: "create",
92271
92223
  role: "viewer"
92272
92224
  },
92225
+ "timedRun.setSettings": {
92226
+ capName: "timed-run",
92227
+ capScope: "device",
92228
+ addonId: null,
92229
+ access: "create",
92230
+ role: "admin"
92231
+ },
92273
92232
  "toast.onToast": {
92274
92233
  capName: "toast",
92275
92234
  capScope: "system",
@@ -93200,6 +93159,7 @@ function offered(received) {
93200
93159
  };
93201
93160
  }
93202
93161
  offered(HA_AS), withheld(HOMEKIT_REASON), withheld(ALEXA_REASON), withheld(GOOGLE_REASON), withheld(MATTER_REASON);
93162
+ string().min(1).max(4096);
93203
93163
  Object.freeze({
93204
93164
  "accessories.getStatus": [{
93205
93165
  name: "deviceId",
@@ -93883,6 +93843,11 @@ Object.freeze({
93883
93843
  form: "single",
93884
93844
  optional: false
93885
93845
  }],
93846
+ "deviceManager.setAlias": [{
93847
+ name: "deviceId",
93848
+ form: "single",
93849
+ optional: false
93850
+ }],
93886
93851
  "deviceManager.setChildLayout": [{
93887
93852
  name: "deviceId",
93888
93853
  form: "single",
@@ -95947,6 +95912,11 @@ Object.freeze({
95947
95912
  form: "single",
95948
95913
  optional: false
95949
95914
  }],
95915
+ "timedRun.getOptions": [{
95916
+ name: "deviceId",
95917
+ form: "single",
95918
+ optional: false
95919
+ }],
95950
95920
  "timedRun.getStatus": [{
95951
95921
  name: "deviceId",
95952
95922
  form: "single",
@@ -95957,6 +95927,11 @@ Object.freeze({
95957
95927
  form: "single",
95958
95928
  optional: false
95959
95929
  }],
95930
+ "timedRun.setSettings": [{
95931
+ name: "deviceId",
95932
+ form: "single",
95933
+ optional: false
95934
+ }],
95960
95935
  "update.getStatus": [{
95961
95936
  name: "deviceId",
95962
95937
  form: "single",
@@ -96819,6 +96794,7 @@ var STATE_SUMMARY_VARS = [
96819
96794
  [...RULE_TEXT],
96820
96795
  [...RULE_TEXT],
96821
96796
  [...RULE_TEXT],
96797
+ [...RULE_TEXT],
96822
96798
  [...RULE_BODY_ONLY],
96823
96799
  [...RULE_TEXT],
96824
96800
  ([...RULE_TEXT], [...DEVICE_EVENTS]),
@@ -122110,7 +122086,13 @@ function buildHomematicInstances(records, deps) {
122110
122086
  },
122111
122087
  instanceMode: "multiple",
122112
122088
  kind: "connection",
122113
- canTest: true
122089
+ canTest: true,
122090
+ kinds: [{
122091
+ id: "connection",
122092
+ label: "Homematic",
122093
+ functionCap: "device-provider",
122094
+ role: "devices"
122095
+ }]
122114
122096
  },
122115
122097
  formSchema: () => buildConnectionFormSchema(),
122116
122098
  initialBody: (name) => ({ name }),