@camstack/addon-provider-homematic 1.2.186 → 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-D7ZKm4nb.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] } : {},
@@ -7163,6 +7240,7 @@ var RecordIntegrationInstances = class {
7163
7240
  this.secretKeys = topLevelSecretKeys(kind.declaration.secretPaths);
7164
7241
  this.secretMaps = secretMapKeys(kind.declaration.secretPaths);
7165
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`);
7166
7244
  }
7167
7245
  /**
7168
7246
  * One instance read for the addon's own runtime; null when absent. When the keychain is
@@ -7204,10 +7282,21 @@ var RecordIntegrationInstances = class {
7204
7282
  }
7205
7283
  return out;
7206
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
+ }
7207
7296
  viewOf(record) {
7208
7297
  const shown = secretViewsOf(this.records.owner, this.kind.name, record.id, this.kind.declaration, record.data);
7209
7298
  const rawName = record.data[this.nameField];
7210
- const kind = this.hooks.kindOf?.(record.data);
7299
+ const kind = this.kindOfBody(record.data);
7211
7300
  const health = this.hooks.health?.(record.data, record.id);
7212
7301
  return {
7213
7302
  id: record.id,
@@ -7215,7 +7304,7 @@ var RecordIntegrationInstances = class {
7215
7304
  configured: this.hooks.configured(record.data),
7216
7305
  enabled: isInstanceEnabled(record.data),
7217
7306
  formValues: shown,
7218
- ...kind !== void 0 ? { kind } : {},
7307
+ kind,
7219
7308
  ...health?.status !== void 0 ? { status: health.status } : {},
7220
7309
  ...health?.lastCheckedAt !== void 0 ? { lastCheckedAt: health.lastCheckedAt } : {}
7221
7310
  };
@@ -7248,17 +7337,35 @@ var RecordIntegrationInstances = class {
7248
7337
  ...kind !== void 0 ? { kind } : {}
7249
7338
  });
7250
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
+ }));
7251
7349
  await this.handle.put({
7252
7350
  id: minted,
7253
- data: this.hooks.initialBody(name, kind)
7351
+ data: initial
7254
7352
  }, { ifRev: 0 });
7255
- const patch = this.patchOf(values ?? {});
7256
7353
  if (Object.keys(patch).length > 0) await this.handle.patch(minted, patch);
7257
7354
  await this.hooks.onChanged?.(minted, "created");
7258
7355
  return { id: minted };
7259
7356
  };
7260
7357
  updateInstance = async ({ id, name, values }) => {
7261
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
+ }
7262
7369
  if (name !== void 0) patch[this.nameField] = name;
7263
7370
  await this.handle.patch(id, patch);
7264
7371
  await this.hooks.onChanged?.(id, "updated");
@@ -7569,6 +7676,21 @@ var SCOPED_SETTINGS_SCOPES = [
7569
7676
  "device-defaults",
7570
7677
  "node"
7571
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
+ }
7572
7694
  /** A write to a secret path could not be stored in the keychain, so it was refused. */
7573
7695
  var KeychainWriteRefusedError = class extends Error {
7574
7696
  fieldPath;
@@ -8144,7 +8266,16 @@ function createHandle(raw, opts) {
8144
8266
  return blob;
8145
8267
  }
8146
8268
  },
8147
- 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
+ })
8148
8279
  };
8149
8280
  }
8150
8281
  /** The context the addon sees, plus the private raw view and write outcome. */
@@ -8274,7 +8405,7 @@ function boundOf(list) {
8274
8405
  * Base class for CamStack addons. Eliminates settings boilerplate:
8275
8406
  *
8276
8407
  * - Typed `config` property with automatic resolution from store + defaults
8277
- * - `getGlobalSettings()` / `updateGlobalSettings()` auto-implemented
8408
+ * - the scoped settings API (`clusterSettings` / `nodeSettings` / `deviceDefaults`) auto-implemented
8278
8409
  * - `getAddonSettings()` / `updateAddonSettings()` auto-implemented
8279
8410
  * - `getDeviceSettings()` / `updateDeviceSettings()` auto-implemented
8280
8411
  * - `ctx` accessor for the AddonContext (no manual `this.ctxRef` storage)
@@ -8284,7 +8415,7 @@ function boundOf(list) {
8284
8415
  * Subclasses override:
8285
8416
  * - `onInitialize()` — addon-specific init logic, return ProviderRegistration[]
8286
8417
  * - `onShutdown()` — cleanup
8287
- * - `globalSettingsSchema()` / `deviceSettingsSchema()` — UI schemas
8418
+ * - `clusterSettingsSchema()` / `nodeSettingsSchema()` / `deviceSettingsSchema()` — UI schemas
8288
8419
  *
8289
8420
  * @example
8290
8421
  * ```ts
@@ -8298,7 +8429,7 @@ function boundOf(list) {
8298
8429
  * super({ maxRetries: 3, endpoint: 'http://localhost' })
8299
8430
  * }
8300
8431
  *
8301
- * protected globalSettingsSchema() {
8432
+ * protected clusterSettingsSchema() {
8302
8433
  * return this.schema({
8303
8434
  * sections: [{
8304
8435
  * id: 'main', title: 'Settings',
@@ -8341,7 +8472,7 @@ var BaseAddon = class {
8341
8472
  defaults;
8342
8473
  /**
8343
8474
  * Hidden-state paths that hold secrets (D787) — values the addon writes
8344
- * itself (`updateGlobalSettings`, `state()`) that no form field declares.
8475
+ * itself (`state()`, the scoped writers) that no form field declares.
8345
8476
  * Stored in the keychain exactly like a `password` field. Syntax:
8346
8477
  * `'snapshotSigningKey'`, `'identity.pincode'`, `'tokens[userId].accessToken'`
8347
8478
  * (`key[<id field>]` addresses array items by id, never by index).
@@ -8351,7 +8482,7 @@ var BaseAddon = class {
8351
8482
  /**
8352
8483
  * D986 M4: the scoped schemas this addon declared, resolved once per capability
8353
8484
  * (`loadScopedSchemas`) so the sync readers (`perNodeKeys`, the secret tree, the restart check)
8354
- * see them. Empty until loaded: the readers then fall back to {@link globalSettingsSchema}.
8485
+ * see them. Empty until loaded.
8355
8486
  */
8356
8487
  _scopedByCap = /* @__PURE__ */ new Map();
8357
8488
  _nodeKeysByCap = /* @__PURE__ */ new Map();
@@ -8537,7 +8668,7 @@ var BaseAddon = class {
8537
8668
  /** Addon-specific cleanup. Override if needed. */
8538
8669
  async onShutdown() {}
8539
8670
  /**
8540
- * Called after config is resolved during updateGlobalSettings/updateAddonSettings.
8671
+ * Called after config is resolved during a settings write.
8541
8672
  * Override to react to config changes (e.g. restart a sampler, reconnect a service).
8542
8673
  * Not called during initialize() — use onInitialize() for initial setup.
8543
8674
  */
@@ -8566,82 +8697,12 @@ var BaseAddon = class {
8566
8697
  scopedSettingsCapabilities() {
8567
8698
  return [];
8568
8699
  }
8569
- /** Override to provide global-level settings UI schema. */
8570
- globalSettingsSchema(_cap) {
8571
- return null;
8572
- }
8573
8700
  /** Override to provide device-level settings UI schema. */
8574
8701
  deviceSettingsSchema() {
8575
8702
  return null;
8576
8703
  }
8577
8704
  /**
8578
- * INTEGRATION-LEVEL SETTINGS — declare which of this addon's global sections
8579
- * ARE the configuration of its integration.
8580
- *
8581
- * Return the `ConfigSection.id`s, from {@link globalSettingsSchema}, that an
8582
- * operator should find on the addon's integration page (System →
8583
- * Integrations → <name>) rather than only in the cluster-wide list of every
8584
- * addon. Empty (the default) means the addon has no integration-level
8585
- * settings and no such surface is offered — this is opt-in, because whether
8586
- * an addon's configuration IS its integration's configuration depends on the
8587
- * nature of the integration.
8588
- *
8589
- * WHAT THIS IS NOT. It is not a scope. The selected sections keep living in
8590
- * the ONE global schema, in the ONE addon store, written by the ONE
8591
- * `updateGlobalSettings` path. There is deliberately no
8592
- * `updateIntegrationSettings`: a second write path is how a surface acquires
8593
- * a second store key, and this repo has shipped that twice (`btmPath@hub`,
8594
- * D266). Selecting sections cannot introduce a key that selecting cannot.
8595
- *
8596
- * WHY IT IS A LIST OF SECTION IDS AND NOT A MARKER ON THE SECTION.
8597
- * `ConfigFieldBase` used to carry `scope?: 'device' | 'global'` and it was
8598
- * removed with the reason recorded at
8599
- * `packages/types/src/interfaces/config-ui.ts:249` — *"a field's scope is
8600
- * determined by WHICH schema it lives in, not by a field-level marker."* A
8601
- * marker sprinkled across sections also has to borrow a field that already
8602
- * means something else; borrowing `section.tab` put the literal word
8603
- * "integration" into an operator-facing tab bar, because `tab` means "how to
8604
- * GROUP this visually" and cannot also mean "where this lives" (D269
8605
- * supersedes D268). One declaration, in one place, next to the schema whose
8606
- * ids it names.
8607
- */
8608
- integrationSettingSections() {
8609
- return [];
8610
- }
8611
- async getGlobalSettings(overlay, cap, nodeId) {
8612
- await this.loadScopedSchemas(cap);
8613
- const schema = this.globalSettingsSchema(cap) ?? this.scopedFormSchema(cap);
8614
- if (!schema) return { sections: [] };
8615
- const projected = await this.readRawProjectedStore(nodeId, cap);
8616
- return hydrateSchema(schema, overlay ? await this.overlayKeepingMarkers(projected, overlay) : projected, { inlineSecretsAsViews: true });
8617
- }
8618
- /**
8619
- * The integration-level view of this addon's settings: exactly the sections
8620
- * named by {@link integrationSettingSections}, hydrated from the SAME store
8621
- * `getGlobalSettings` reads, and narrowed to cluster-scoped fields.
8622
- *
8623
- * Returns `null` when the addon declared nothing — an addon that opts out has
8624
- * no integration settings surface at all, rather than an empty one that reads
8625
- * as a failed load.
8626
- *
8627
- * Three properties hold BY CONSTRUCTION, which is why they are here in core
8628
- * and not in whichever UI happens to render this:
8629
- *
8630
- * 1. **One key.** The payload is a SUBSET of the global schema, so a field
8631
- * shown here is the same field, with the same bare key, that the addon's
8632
- * own page shows. There is no integration-specific writer — callers save
8633
- * through `updateGlobalSettings` — so a second store key is unreachable,
8634
- * not merely discouraged.
8635
- * 2. **No node scope.** `perNode: true` fields are DROPPED. Their store key
8636
- * is `<key>@<nodeId>` and an integration is not a node; whichever node
8637
- * such a field silently picked would be a wrong answer for the operator
8638
- * who opened the page (D266).
8639
- * 3. **No silent typo.** A declared id that names no section throws. The
8640
- * alternative — skip it — turns a rename into a surface that quietly
8641
- * empties, which looks exactly like an addon with nothing to configure.
8642
- */
8643
- /**
8644
- * 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.
8645
8706
  *
8646
8707
  * Override it only when an `instanceMode: multiple` addon's instances differ: an NVR integration
8647
8708
  * needs its connection fields, the default integration the addon's own sections. It is the
@@ -8689,37 +8750,178 @@ var BaseAddon = class {
8689
8750
  }
8690
8751
  }
8691
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
+ /**
8692
8911
  * What the create wizard and the integration edit page render for one instance: the addon's
8693
8912
  * per-instance schema when it declares one, else its global schema (what they always showed).
8694
8913
  */
8695
8914
  async getIntegrationFormSchema(instance, nodeId) {
8696
8915
  const scoped = await this.integrationFormSchema(instance);
8697
- if (scoped === null) return this.getGlobalSettings(void 0, void 0, nodeId);
8916
+ if (scoped === null) return this.scopedForm(nodeId);
8698
8917
  return hydrateSchema(scoped, {}, { inlineSecretsAsViews: true });
8699
8918
  }
8700
- async getIntegrationSettings(nodeId) {
8701
- const declared = this.integrationSettingSections();
8702
- if (declared.length === 0) return null;
8703
- const schema = this.globalSettingsSchema();
8704
- if (!schema) throw new Error(`${this.constructor.name}: integrationSettingSections() names [${declared.join(", ")}] but globalSettingsSchema() returns null.`);
8705
- const byId = new Map(schema.sections.map((section) => [section.id, section]));
8706
- const sections = [];
8707
- for (const id of declared) {
8708
- const section = byId.get(id);
8709
- if (!section) throw new Error(`${this.constructor.name}: integrationSettingSections() names unknown section "${id}". Known sections: [${[...byId.keys()].join(", ")}].`);
8710
- const fields = dropPerNodeFields(section.fields);
8711
- if (fields.length === 0) continue;
8712
- sections.push({
8713
- ...section,
8714
- fields
8715
- });
8716
- }
8717
- if (sections.length === 0) return null;
8718
- const projected = await this.readRawProjectedStore(nodeId);
8719
- return hydrateSchema({
8720
- ...schema,
8721
- sections
8722
- }, 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 });
8723
8925
  }
8724
8926
  /**
8725
8927
  * The raw addon store PROJECTED onto the target node's bare per-node keys:
@@ -8728,8 +8930,8 @@ var BaseAddon = class {
8728
8930
  * bare fallback), all `@`-scoped and stray bare per-node keys are dropped.
8729
8931
  * A no-op passthrough when the schema declares no `perNode` field.
8730
8932
  *
8731
- * This is the sanctioned way for a `getGlobalSettings` OVERRIDE that needs
8732
- * 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
8733
8935
  * read it per-node — never `ctx.settings.readAddonStore()` directly.
8734
8936
  * `nodeId` omitted ⇒ the local node (node-blind injection from ctx).
8735
8937
  *
@@ -8781,7 +8983,7 @@ var BaseAddon = class {
8781
8983
  }
8782
8984
  /**
8783
8985
  * Whether ONE global key of this addon's store was written, read three-way
8784
- * (D651). For a question a hydrated view cannot answer: `getGlobalSettings`
8986
+ * (D651). For a question a hydrated view cannot answer: a hydrated form
8785
8987
  * reports `value ?? default`, so "the operator chose the default" and "nobody
8786
8988
  * chose" look the same, and a failed read looks like both. A `perNode` key is
8787
8989
  * not supported here: its stored name is scoped.
@@ -8815,7 +9017,7 @@ var BaseAddon = class {
8815
9017
  }
8816
9018
  /**
8817
9019
  * The OPERATOR's write — a settings form or an admin API call, dispatched by
8818
- * 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
8819
9021
  * the operator sends is stored as sent even when it equals a pre-keychain
8820
9022
  * inline value: the operator re-entering a password is a change, an addon
8821
9023
  * writing back what it read is not (D787).
@@ -8828,9 +9030,6 @@ var BaseAddon = class {
8828
9030
  this._operatorWriteDepth--;
8829
9031
  }
8830
9032
  }
8831
- async updateGlobalSettings(patch, nodeId) {
8832
- await this.applyGlobalPatch(patch, nodeId);
8833
- }
8834
9033
  /**
8835
9034
  * REMOVE stored secrets — their keychain values and their markers (D787).
8836
9035
  *
@@ -8840,6 +9039,9 @@ var BaseAddon = class {
8840
9039
  * a keychain (an older kernel) it writes `''`, as such code always did.
8841
9040
  */
8842
9041
  async clearSecrets(keys, nodeId) {
9042
+ await this.clearSecretKeys(keys, nodeId);
9043
+ }
9044
+ async clearSecretKeys(keys, nodeId, cap) {
8843
9045
  const tree = this.addonSecretTree();
8844
9046
  const keychain = this._ctx?.secrets !== void 0;
8845
9047
  const stored = keychain ? await this.readAddonStoreWithRetry() : {};
@@ -8852,25 +9054,26 @@ var BaseAddon = class {
8852
9054
  const keychainStored = tree.has(key) || collectSecretMarkerRefs(stored[key]).length > 0;
8853
9055
  patch[key] = keychain && keychainStored ? SECRET_CLEAR : "";
8854
9056
  }
8855
- await this.applyGlobalPatch(patch, nodeId);
9057
+ await this.applyGlobalPatch(patch, nodeId, cap);
8856
9058
  }
8857
- async applyGlobalPatch(barePatch, nodeId) {
8858
- await this.loadScopedSchemas();
8859
- 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);
8860
9063
  const localNode = normalizeNodeId(this._ctx?.kernel?.localNodeId);
8861
9064
  const target = normalizeNodeId(nodeId ?? this._ctx?.kernel?.localNodeId);
8862
9065
  const scoped = keys.size > 0 ? scopePatch(barePatch, keys, target) : barePatch;
8863
9066
  const handle = this._secretSettings;
8864
9067
  if (handle !== null) {
8865
9068
  const { changed } = await handle.writeAddonStore(scoped);
8866
- if (!changed) return;
9069
+ if (!changed) return false;
8867
9070
  } else await this._ctx?.settings?.writeAddonStore(scoped);
8868
- if (target !== localNode) return;
9071
+ if (target !== localNode) return true;
8869
9072
  await this.resolveConfig();
8870
9073
  await this.onConfigChanged();
8871
9074
  this.emitLifecycle(EventCategory.AddonUpdated, { level: "global" });
8872
- const legacy = this.globalSettingsSchema();
8873
- 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;
8874
9077
  }
8875
9078
  /**
8876
9079
  * The set of field keys the global settings schema declares `perNode: true`
@@ -8907,10 +9110,7 @@ var BaseAddon = class {
8907
9110
  this._nodeKeysByCap = /* @__PURE__ */ new Map();
8908
9111
  this._addonSecretTree = null;
8909
9112
  }
8910
- /**
8911
- * The form the settings API serves while an addon declares no {@link globalSettingsSchema}: the
8912
- * sections of its scoped schemas, so dropping the old hook does not blank the form.
8913
- */
9113
+ /** The form of an addon's scoped schemas: their sections, each shown once. */
8914
9114
  scopedFormSchema(cap) {
8915
9115
  const byId = /* @__PURE__ */ new Map();
8916
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);
@@ -8922,8 +9122,7 @@ var BaseAddon = class {
8922
9122
  return [...this._scopedByCap.values()].flat();
8923
9123
  }
8924
9124
  /**
8925
- * The field keys that are stored per node: every field of a {@link nodeSettingsSchema}, plus
8926
- * 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
8927
9126
  * per `cap` argument and memoized (schemas are static declarations). Empty set ⇒ every
8928
9127
  * per-node code path is bypassed and the settings API behaves like the node-agnostic one.
8929
9128
  * Call {@link loadScopedSchemas} first (the async seams do).
@@ -8932,8 +9131,7 @@ var BaseAddon = class {
8932
9131
  const cacheKey = cap ?? "";
8933
9132
  const cached = this._nodeKeysByCap.get(cacheKey);
8934
9133
  if (cached) return cached;
8935
- const legacy = this.globalSettingsSchema(cap);
8936
- const keys = new Set(legacy ? legacy.sections.flatMap((section) => collectPerNodeFieldKeys(section.fields)) : []);
9134
+ const keys = /* @__PURE__ */ new Set();
8937
9135
  for (const { scope, schema } of this.loadedScopedSchemas(cap)) {
8938
9136
  if (scope !== "node") continue;
8939
9137
  for (const section of schema.sections) for (const key of collectValueFieldKeys(section.fields)) keys.add(key);
@@ -9151,8 +9349,6 @@ var BaseAddon = class {
9151
9349
  }
9152
9350
  declaredKeySet() {
9153
9351
  const keys = new Set(Object.keys(this.defaults));
9154
- const schema = this.globalSettingsSchema();
9155
- if (schema) for (const section of schema.sections) for (const key of collectFieldKeys(section.fields)) keys.add(key);
9156
9352
  for (const { schema: scoped } of this.loadedScopedSchemas()) for (const section of scoped.sections) for (const key of collectFieldKeys(section.fields)) keys.add(key);
9157
9353
  for (const key of this._declaredStateKeys) keys.add(key);
9158
9354
  for (const path of this.secretStatePaths) {
@@ -9250,7 +9446,7 @@ var BaseAddon = class {
9250
9446
  /** The addon store's secret tree: schema fields by TYPE, plus `secretStatePaths`. */
9251
9447
  addonSecretTree() {
9252
9448
  if (this._addonSecretTree === null) {
9253
- const tree = new Map(secretTreeFromSchema(this.globalSettingsSchema()));
9449
+ const tree = /* @__PURE__ */ new Map();
9254
9450
  for (const { schema } of this.loadedScopedSchemas()) for (const [key, node] of secretTreeFromSchema(schema)) tree.set(key, node);
9255
9451
  this._addonSecretTree = mergeSecretStatePaths(tree, this.secretStatePaths);
9256
9452
  }
@@ -9462,47 +9658,6 @@ function classifyStoreError(err) {
9462
9658
  if (TRANSPORT_PHRASES.some((f) => message.includes(f))) return "transport";
9463
9659
  return "permanent";
9464
9660
  }
9465
- /**
9466
- * Collect the keys of every field marked `perNode: true`, recursing into
9467
- * layout containers (`group` fields and `sub-tabs` tabs) the same way
9468
- * `hydrateSchema` does. Valueless structural fields (separator/info/…)
9469
- * don't declare `perNode` and are excluded by the `in` narrowing.
9470
- */
9471
- /**
9472
- * The same fields with every `perNode: true` one removed, recursing into layout
9473
- * containers exactly as {@link collectPerNodeFieldKeys} does. A container left
9474
- * with no child is dropped rather than rendered empty.
9475
- *
9476
- * Used by `getIntegrationSettings`: an integration is not a node, so a field
9477
- * whose store key is `<key>@<nodeId>` has no node to belong to there.
9478
- */
9479
- function dropPerNodeFields(fields) {
9480
- const kept = [];
9481
- for (const field of fields) {
9482
- if (field.type === "group") {
9483
- const inner = dropPerNodeFields(field.fields);
9484
- if (inner.length > 0) kept.push({
9485
- ...field,
9486
- fields: inner
9487
- });
9488
- continue;
9489
- }
9490
- if (field.type === "sub-tabs") {
9491
- const tabs = field.tabs.map((tab) => ({
9492
- ...tab,
9493
- fields: dropPerNodeFields(tab.fields)
9494
- })).filter((tab) => tab.fields.length > 0);
9495
- if (tabs.length > 0) kept.push({
9496
- ...field,
9497
- tabs
9498
- });
9499
- continue;
9500
- }
9501
- if ("perNode" in field && field.perNode === true) continue;
9502
- kept.push(field);
9503
- }
9504
- return kept;
9505
- }
9506
9661
  /** The keys of the value-holding fields, recursing into layout containers. */
9507
9662
  function collectValueFieldKeys(fields) {
9508
9663
  const collected = [];
@@ -9535,21 +9690,6 @@ function collectFieldKeys(fields) {
9535
9690
  }
9536
9691
  return collected;
9537
9692
  }
9538
- function collectPerNodeFieldKeys(fields) {
9539
- const collected = [];
9540
- for (const field of fields) {
9541
- if (field.type === "group") {
9542
- collected.push(...collectPerNodeFieldKeys(field.fields));
9543
- continue;
9544
- }
9545
- if (field.type === "sub-tabs") {
9546
- for (const tab of field.tabs) collected.push(...collectPerNodeFieldKeys(tab.fields));
9547
- continue;
9548
- }
9549
- if ("perNode" in field && field.perNode === true) collected.push(field.key);
9550
- }
9551
- return collected;
9552
- }
9553
9693
  /**
9554
9694
  * Normalize an `ICamstackAddon.initialize()` return value into the
9555
9695
  * `AddonInitResult` envelope. Arrays are wrapped into `{ providers }`;
@@ -10643,7 +10783,6 @@ var CAP_NAMES = Object.freeze([
10643
10783
  "notifier",
10644
10784
  "numeric-sensor",
10645
10785
  "oauth-integration",
10646
- "oidc-connections",
10647
10786
  "osd",
10648
10787
  "osd-manager",
10649
10788
  "pet-feeder",
@@ -12350,13 +12489,25 @@ Object.freeze({
12350
12489
  "path": "temperature",
12351
12490
  "valueType": "number"
12352
12491
  }],
12353
- "timed-run": [{
12354
- "path": "activeUntil",
12355
- "valueType": "number"
12356
- }, {
12357
- "path": "requestedBy",
12358
- "valueType": "string"
12359
- }],
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
+ ],
12360
12511
  "update": [
12361
12512
  {
12362
12513
  "path": "currentVersion",
@@ -12535,8 +12686,7 @@ Object.freeze({
12535
12686
  "device-provider": { "reloadDevice": 18e4 },
12536
12687
  "llm": {
12537
12688
  "generate": 6e5,
12538
- "generateVision": 6e5,
12539
- "testProfile": 6e5
12689
+ "generateVision": 6e5
12540
12690
  },
12541
12691
  "llm-runtime": {
12542
12692
  "complete": 6e5,
@@ -12581,7 +12731,7 @@ object({
12581
12731
  params: record(string(), union([string(), number()])).optional()
12582
12732
  });
12583
12733
  //#endregion
12584
- //#region ../types/dist/composition-BmBHuDTQ.mjs
12734
+ //#region ../types/dist/composition-Bx0JvKUU.mjs
12585
12735
  /**
12586
12736
  * The ffmpeg build every CamStack node downloads, per platform and arch.
12587
12737
  *
@@ -13743,458 +13893,844 @@ var NodeColorIdSchema = _enum([
13743
13893
  "node-h"
13744
13894
  ]);
13745
13895
  //#endregion
13746
- //#region ../types/dist/index.mjs
13747
- var SMTP_INBOUND_DEFAULT_PORT = 2525;
13748
- var SMTP_INBOUND_DEFAULT_DOMAIN = "camstack.local";
13749
- var SMTP_INBOUND_DEFAULT_MAX_MESSAGE_BYTES = 25 * 1024 * 1024;
13750
- /** The text excerpt a message carries on the bus. */
13751
- var SMTP_INBOUND_TEXT_MAX_CHARS = 4096;
13752
- var PortSchema = number().int().min(1).max(65535);
13753
- /** A recipient local-part: what stands before the `@`. */
13754
- var SmtpRecipientSchema = string().min(1).max(64).regex(/^[A-Za-z0-9._+-]+$/);
13755
- object({
13756
- port: PortSchema.default(SMTP_INBOUND_DEFAULT_PORT),
13757
- bindHost: string().min(1).default("0.0.0.0"),
13758
- domain: string().min(1).default(SMTP_INBOUND_DEFAULT_DOMAIN),
13759
- requireAuth: boolean().default(true),
13760
- username: string().default(""),
13761
- password: string().default("").meta({ secret: true }),
13762
- starttls: boolean().default(false),
13763
- maxMessageBytes: number().int().positive().default(SMTP_INBOUND_DEFAULT_MAX_MESSAGE_BYTES)
13764
- });
13765
- object({
13766
- host: string().min(1).nullable(),
13767
- hostReason: string().nullable(),
13768
- port: PortSchema,
13769
- domain: string().min(1),
13770
- requireAuth: boolean(),
13771
- username: string(),
13772
- password: string(),
13773
- starttls: boolean()
13774
- });
13775
- object({
13776
- recipients: array(SmtpRecipientSchema).min(1),
13777
- /**
13778
- * Who is subscribing. A second `subscribe` with the same id REPLACES that subscriber's
13779
- * recipients (the way a consumer that restarted, or lost a device, declares its set again);
13780
- * a recipient held by another subscriber is refused with `smtp-inbound/recipient-claimed`.
13781
- * Absent, the subscriber is anonymous and unique.
13782
- */
13783
- subscriberId: string().min(1).max(64).optional()
13784
- });
13785
- var SmtpInboundAttachmentSchema = object({
13786
- filename: string(),
13787
- contentType: string(),
13788
- bytes: number().int().nonnegative()
13789
- });
13790
- /** The payload of one `broker.message` (the key is the recipient local-part). */
13791
- var SmtpInboundMessageSchema = object({
13792
- /** Monotonic per mailbox; a gap tells a consumer it missed an event. */
13793
- seq: number().int().positive(),
13794
- messageId: string(),
13795
- receivedAt: number().int().nonnegative(),
13796
- from: string(),
13797
- to: string(),
13798
- subject: string(),
13799
- text: string().max(SMTP_INBOUND_TEXT_MAX_CHARS),
13800
- attachments: array(SmtpInboundAttachmentSchema)
13801
- });
13802
- object({
13803
- /** The newest seq issued so far (0 before any mail). */
13804
- lastSeq: number().int().nonnegative(),
13805
- /** The oldest seq still retained; messages below it are gone. */
13806
- oldestSeq: number().int().nonnegative(),
13807
- messages: array(object({
13808
- key: string(),
13809
- message: SmtpInboundMessageSchema
13810
- }))
13811
- });
13812
- new Set([
13813
- "track",
13814
- "face",
13815
- "identity",
13816
- "plate",
13817
- "vehicle",
13818
- "scene",
13819
- "motion",
13820
- "object",
13821
- "audio",
13822
- "mosaic"
13823
- ]);
13824
- /**
13825
- * The owner types that are event tables, in the order the event-media resolver
13826
- * should consider them. Exported so a consumer asking "is this key an event?"
13827
- * does not re-spell the list and drift from it.
13828
- */
13829
- var EVENT_OWNER_TYPES = [
13830
- "motion",
13831
- "object",
13832
- "audio"
13833
- ];
13834
- /**
13835
- * The same list as a Zod enum, for the cap inputs that must NAME the table
13836
- * (D482: `getEventMedia` / `listEventMedia` take an owner, and an owner is
13837
- * `(table, id)`).
13838
- *
13839
- * Built FROM {@link EVENT_OWNER_TYPES} rather than re-spelled: a fourth event
13840
- * table would otherwise be accepted by the codec and refused at the door, with
13841
- * nothing failing until a caller asked.
13842
- */
13843
- var EventOwnerTypeSchema = _enum(EVENT_OWNER_TYPES);
13844
- /** The same list as a Zod enum, for the cap input that carries it. */
13845
- var MediaPresenceOwnerKindSchema = _enum([...EVENT_OWNER_TYPES, "track"]);
13846
- new Set(EVENT_OWNER_TYPES);
13847
- /**
13848
- * What a published package needs from the rest of the install (D989).
13849
- *
13850
- * One published framework package (`@camstack/server`) carries the kernel, the
13851
- * builtins and the capability contracts, so "which addon runs on which
13852
- * framework" is a question of version, and the answer is DECLARED by the
13853
- * package that knows it:
13854
- *
13855
- * - an addon says the oldest server it runs on (`requires.server: ">=X"`);
13856
- * - the server says the oldest addon it works with
13857
- * (`requires.addons: { "@camstack/addon-x": ">=Y" }`) and the oldest shell
13858
- * around it (`requires.wrapper: { desktop, image }`);
13859
- * - a wrapper (the desktop app, the container starter) says which server
13860
- * range it can host, and reports its own kind and version.
13861
- *
13862
- * The publish workflow STAMPS these after the version bump
13863
- * (`scripts/ci/stamp-requires.mjs`); nobody types a number by hand.
13864
- *
13865
- * A requirement that cannot be checked is NOT met: a shell that reports no
13866
- * version counts as below the minimum, and an unreadable running version is
13867
- * named in the result (a failed read is never a pass).
13868
- */
13869
- /** `>=MAJOR.MINOR.PATCH[-prerelease]` — the only range shape a requirement uses. */
13870
- var MinVersionSchema = string().regex(/^>=\d+\.\d+\.\d+(-[0-9A-Za-z.-]+)?$/, "a minimum is written \">=X.Y.Z\"");
13871
- object({
13872
- /** The oldest `@camstack/server` this package runs on. */
13873
- server: MinVersionSchema.optional(),
13874
- /** The oldest installed version of each named addon package. */
13875
- addons: record(string(), MinVersionSchema).optional(),
13876
- /** The oldest shell around the server, per shell kind. */
13877
- wrapper: object({
13878
- desktop: MinVersionSchema.optional(),
13879
- image: MinVersionSchema.optional()
13880
- }).optional()
13881
- });
13882
- /** One unmet requirement; each names the versions on both sides. */
13883
- var UnmetRequirementSchema = discriminatedUnion("kind", [
13884
- object({
13885
- kind: literal("server-too-old"),
13886
- required: string(),
13887
- /** `null` — the running server version could not be read. */
13888
- running: string().nullable()
13889
- }),
13890
- object({
13891
- kind: literal("addon-too-old"),
13892
- packageName: string(),
13893
- required: string(),
13894
- /** `null` — the addon is not installed (or its version is unreadable). */
13895
- running: string().nullable()
13896
- }),
13897
- object({
13898
- kind: literal("wrapper-too-old"),
13899
- wrapper: _enum(["desktop", "image"]),
13900
- required: string(),
13901
- /** `null` — the wrapper reported no version. */
13902
- running: string().nullable()
13903
- })
13904
- ]);
13905
- var RequiredAddonUpdateSchema = object({
13906
- packageName: string(),
13907
- /** The minimum the target server declares. */
13908
- required: string(),
13909
- /** What this node has; `null` when the addon is not installed. */
13910
- installed: string().nullable()
13911
- });
13912
- /**
13913
- * Which integration instance a settings form is for. An addon that serves several instances
13914
- * (`instanceMode: multiple`) can show a different form per instance — an NVR integration
13915
- * needs its connection, the default integration needs the addon's own sections.
13916
- *
13917
- * - `integrationId` is `null` in the create wizard: nothing exists yet, the operator is
13918
- * setting up a NEW instance.
13919
- * - `mode` is the wizard mode of the integration type (`getAvailableTypes`).
13920
- * - `candidateStableId` is the discovery candidate a wizard was seeded from, if any.
13921
- */
13922
- var IntegrationInstanceRefSchema = object({
13923
- integrationId: string().nullable(),
13924
- mode: _enum([
13925
- "standalone",
13926
- "account",
13927
- "broker"
13928
- ]),
13929
- candidateStableId: string().optional()
13930
- });
13931
- /**
13932
- * notification-output — canonical, capability-gated notification delivery.
13933
- *
13934
- * Apprise-derived model (see
13935
- * `docs/superpowers/specs/2026-07-03-notification-output-notifier-matrix.md`):
13936
- * callers emit ONE canonical `Notification`; each provider declares a
13937
- * per-kind capability descriptor (`TargetKind`), and the pure degrade
13938
- * engine (`@camstack/types` `prepareNotification`) transcodes / degrades the
13939
- * message to what the kind supports — callers never special-case a service.
13940
- *
13941
- * DESIGN DECISIONS (locked):
13942
- * - Target CRUD lives on THIS cap (`upsertTarget` / `deleteTarget` /
13943
- * `setTargetEnabled`), each provider persisting via the `settings-store`
13944
- * cap. Rationale: the admin UI needs one uniform surface across the
13945
- * notifiers addon AND the HA addon; the addon-`globalSettingsSchema`-array
13946
- * alternative would fork the UI per addon and cannot host the
13947
- * discovery→adopt flow.
13948
- * - `listTargetKinds` / `listTargets` / `discoverTargets` return arrays →
13949
- * the generated cap-mount auto-`concatCollection`-fans them across every
13950
- * registered provider (notifiers addon + HA addon) so one catalog is
13951
- * routable. `send` / `testTarget` / CRUD route to ONE provider by the
13952
- * `addonId` the generated collection router extracts from the call input.
13953
- * - `Attachment.bytes` is `Uint8Array`. Transport-safe: superjson (the tRPC
13954
- * transformer) + UDS MsgPack both round-trip typed arrays — already used by
13955
- * `storage` / `storage-provider` / `recording` caps over the same path. No
13956
- * base64 fallback needed.
13957
- *
13958
- * TODO (deferred, closed-set change — separate decision): add
13959
- * `providerKind: 'notify'` so notification providers surface on the unified
13960
- * admin "Integrations" page.
13961
- */
13962
- /**
13963
- * Zentik-derived typed-media enum — the superset across every kind. Each
13964
- * adapter picks what it supports and the degrade engine filters the rest.
13965
- */
13966
- var AttachmentMediaTypeSchema = _enum([
13967
- "image",
13968
- "video",
13969
- "gif",
13970
- "audio",
13971
- "icon"
13972
- ]);
13973
- /**
13974
- * A single attachment. Exactly one of `url` (remote source, most adapters
13975
- * prefer this) or `bytes` (inline source; required for Pushover-style
13976
- * bytes-only kinds) MUST be present — the degrade engine expresses a
13977
- * url→bytes fetch as a `needsFetch` directive the adapter executes.
13978
- */
13979
- var AttachmentSchema = object({
13980
- mediaType: AttachmentMediaTypeSchema,
13981
- url: string().optional(),
13982
- bytes: _instanceof(Uint8Array).optional(),
13983
- mime: string().optional(),
13984
- name: string().optional()
13985
- }).refine((a) => a.url !== void 0 || a.bytes !== void 0, { message: "Attachment requires either `url` or `bytes`" });
13986
- var NotificationFormatSchema = _enum([
13987
- "text",
13988
- "markdown",
13989
- "html"
13990
- ]);
13896
+ //#region ../types/dist/convert-BAzH15HU.mjs
13991
13897
  /**
13992
- * The CLOSED icon vocabulary an action button may use.
13993
- *
13994
- * A closed set, not a free string, and that is the whole point: an arbitrary
13995
- * icon name is one that ntfy renders, zentik silently drops, and nobody
13996
- * notices — the same class of gap as a zone vocabulary nothing produced
13997
- * ([D35](../../../docs/decisions/adr-0035.md)). Every adapter maps this set or
13998
- * declares `actionIcons: false` and the degrade engine strips the field.
13999
- *
14000
- * Named by INTENT, never by glyph. "check" would tie the vocabulary to one
14001
- * renderer's icon set; "acknowledge" survives an adapter that draws it
14002
- * differently.
14003
- *
14004
- * ── A TOKEN IS NOT A WIRE VALUE ─────────────────────────────────────
14005
- *
14006
- * These names are for US. **No adapter may forward one verbatim.** Each maps
14007
- * the whole set onto its own renderer's vocabulary through a
14008
- * `Record<NotificationActionIcon, string>` — a Record, never a lookup with a
14009
- * fallback, so adding a member here fails every adapter's build until someone
14010
- * decides its glyph, which is the only place that decision can be made
14011
- * honestly.
14012
- *
14013
- * This paragraph is the bug. Zentik declared `actionIcons: true` and passed
14014
- * `disarm` straight through; iOS feeds that string to
14015
- * `UNNotificationActionIcon(systemImageName:)`, `disarm` is not an SF Symbol,
14016
- * and every snooze and alarm button arrived BLANK. A pass-through is not a
14017
- * mapping, and "the field is documented" is not "the value renders".
14018
- *
14019
- * Adding a member is TRAIN-BOUND. The enum lives in the published
14020
- * `@camstack/server` closure and the cap seam validates against the HUB's copy,
14021
- * so an addon that emits a token the running hub does not know does not lose an
14022
- * icon — its whole `send` fails Zod validation and the notification never
14023
- * 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`.
14024
13902
  */
14025
- var NotificationActionIconSchema = _enum([
14026
- "acknowledge",
14027
- "dismiss",
14028
- "silence",
14029
- "snooze",
14030
- "view",
14031
- "play",
14032
- "open",
14033
- "close",
14034
- "lock",
14035
- "unlock",
14036
- "arm",
14037
- "arm-home",
14038
- "arm-away",
14039
- "arm-night",
14040
- "disarm",
14041
- "light",
14042
- "alert",
14043
- "camera"
14044
- ]);
14045
- /** A single tap-through action button. */
14046
- var NotificationActionSchema = object({
14047
- id: string(),
14048
- label: string(),
14049
- url: string().optional(),
14050
- /** Dropped by the degrade engine for a kind with `caps.actionIcons: false`. */
14051
- icon: NotificationActionIconSchema.optional(),
14052
- /**
14053
- * Renders in a warning style where the notifier supports it.
14054
- *
14055
- * A HINT, never a gate. The callback's authority is its token and nothing
14056
- * else — see `notification-center/action-token.ts` for what that does and
14057
- * does not buy.
14058
- */
14059
- destructive: boolean().optional(),
14060
- /**
14061
- * How the tap should REACH the url.
14062
- *
14063
- * `navigate` (absent, and every button authored before this field) opens it:
14064
- * the phone leaves the notification and shows whatever the callback returns.
14065
- * That is right for a button whose answer the operator wants to read.
14066
- *
14067
- * `background` fires it as a POST and stays put. It exists for the buttons
14068
- * whose whole point is not to interrupt — "silence this for 30 minutes" is
14069
- * an answer to the notification, and being thrown into a browser tab to
14070
- * confirm it costs more attention than the notification did. A backend that
14071
- * cannot do a background call renders it as an ordinary link (the adapters
14072
- * fall back rather than dropping the button), so this is a preference, never
14073
- * a requirement.
14074
- */
14075
- mode: _enum(["navigate", "background"]).optional()
14076
- });
14077
- /** A delivery parameter value: what a notifier declared it takes. */
14078
- var DeliveryParamValueSchema = union([
14079
- string(),
14080
- number(),
14081
- boolean()
14082
- ]);
14083
- /**
14084
- * One extra delivery parameter a notifier KIND declares (D938). A rule that
14085
- * addresses a target of that kind may set it; a kind that declares nothing is
14086
- * never handed one. The admin UI derives its control from this descriptor —
14087
- * no editor knows a service by name.
14088
- *
14089
- * Optional fields are `.optional()`, never `.default()` (a Zod default does not
14090
- * run on the addon cap path).
14091
- */
14092
- var DeliveryParamSchema = object({
14093
- key: string().min(1),
14094
- label: string(),
14095
- /** i18n key of the label, resolved by the declaring addon's namespace. */
14096
- labelKey: string().optional(),
14097
- type: _enum([
14098
- "enum",
14099
- "number",
14100
- "boolean",
14101
- "string"
14102
- ]),
14103
- /** `enum` only: the closed set of accepted values. */
14104
- options: array(object({
14105
- value: string(),
14106
- label: string()
14107
- })).optional(),
14108
- /** `number` only. */
14109
- min: number().optional(),
14110
- max: number().optional(),
14111
- /** What the notifier does when the rule sets nothing; shown as the placeholder. */
14112
- default: DeliveryParamValueSchema.optional()
14113
- });
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
+ }
14114
14266
  /**
14115
- * The canonical notification. `body` is the only hard field (Apprise model).
14116
- * `priority` is a 5-level ORDINAL (1=lowest … 3=normal(default) … 5=urgent),
14117
- * NOT a fixed severity enum — each kind declares its own `caps.levels` and
14118
- * the adapter maps this ordinal onto its native level. `level?` is an
14119
- * optional kind-native level id (`emergency`, `silent`, …) that overrides
14120
- * `priority` for that one target.
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.
14121
14270
  */
14122
- var NotificationSchema = object({
14123
- body: string(),
14124
- title: string().optional(),
14125
- format: NotificationFormatSchema.default("text"),
14126
- priority: number().int().min(1).max(5).default(3),
14127
- level: string().optional(),
14128
- attachments: array(AttachmentSchema).optional(),
14129
- clickUrl: string().optional(),
14130
- actions: array(NotificationActionSchema).optional(),
14131
- sound: string().optional(),
14132
- ttl: number().optional(),
14133
- tag: string().optional(),
14134
- deviceId: number().optional(),
14135
- eventId: string().optional(),
14136
- metadata: record(string(), unknown()).optional(),
14137
- /**
14138
- * Values for the parameters the target's kind DECLARES in
14139
- * {@link TargetKindSchema} `deliveryParams`. Already validated against the
14140
- * declaration by the sender; a notifier reads only the keys it declared.
14141
- */
14142
- delivery: record(string(), 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)
14143
14299
  });
14144
- /** One declared native severity/priority level for a kind. */
14145
- var TargetKindLevelSchema = object({
14146
- id: string(),
14147
- label: string(),
14148
- /** Which canonical priority (1..5) this level maps to. `null` = qualitative-only. */
14149
- ordinal: number().int().min(1).max(5).nullable(),
14150
- flags: object({
14151
- critical: boolean().optional(),
14152
- silent: boolean().optional(),
14153
- noPush: boolean().optional()
14154
- }).optional(),
14155
- /** e.g. Pushover `emergency` requires `retry` / `expire`. */
14156
- requires: array(string()).optional(),
14157
- description: string().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()
14158
14309
  });
14159
- /** The full capability block consulted before dispatch. */
14160
- var TargetKindCapsSchema = object({
14161
- attachments: object({
14162
- mediaTypes: array(AttachmentMediaTypeSchema),
14163
- mode: _enum([
14164
- "url",
14165
- "bytes",
14166
- "both"
14167
- ]),
14168
- max: number().int().nonnegative(),
14169
- maxBytes: number().int().positive().optional()
14170
- }),
14171
- /** Max action buttons (0 = none). */
14172
- actions: number().int().nonnegative(),
14310
+ object({
14311
+ recipients: array(SmtpRecipientSchema).min(1),
14173
14312
  /**
14174
- * Whether this kind renders a per-action ICON.
14175
- *
14176
- * `.optional()`, deliberately NOT `.default(false)`: a Zod default does not
14177
- * run on the addon cap path — three production failures in one day taught
14178
- * this repo that once. Absent is read as false by the degrade engine, which
14179
- * is the safe direction: an icon that is not rendered costs nothing, an icon
14180
- * assumed and dropped costs the operator's trust in the field.
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.
14181
14317
  */
14182
- actionIcons: boolean().optional(),
14183
- levels: array(TargetKindLevelSchema),
14184
- format: array(NotificationFormatSchema),
14185
- clickUrl: boolean(),
14186
- sound: boolean(),
14187
- ttl: boolean(),
14188
- bodyMaxLen: number().int().positive()
14318
+ subscriberId: string().min(1).max(64).optional()
14189
14319
  });
14190
- /**
14191
- * `configSchema` is a `ConfigUISchema` tree passed through to the admin
14192
- * FormBuilder. Stored as `z.unknown()` at the cap seam (mirrors
14320
+ var SmtpInboundAttachmentSchema = object({
14321
+ filename: string(),
14322
+ contentType: string(),
14323
+ bytes: number().int().nonnegative()
14324
+ });
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
+ */
14718
+ actionIcons: boolean().optional(),
14719
+ levels: array(TargetKindLevelSchema),
14720
+ format: array(NotificationFormatSchema),
14721
+ clickUrl: boolean(),
14722
+ sound: boolean(),
14723
+ ttl: boolean(),
14724
+ bodyMaxLen: number().int().positive()
14725
+ });
14726
+ /**
14727
+ * `configSchema` is a `ConfigUISchema` tree passed through to the admin
14728
+ * FormBuilder. Stored as `z.unknown()` at the cap seam (mirrors
14193
14729
  * `device-provider.getChildCreationSchema` `CreationSchemaOutputSchema`) —
14194
14730
  * the union is large and not meant for runtime validation here; the exported
14195
14731
  * `TargetKind` type re-tightens `configSchema` to `ConfigUISchema`.
14196
14732
  */
14197
- var ConfigSchemaPassthrough$4 = unknown();
14733
+ var ConfigSchemaPassthrough$3 = unknown();
14198
14734
  var TargetKindSchema = object({
14199
14735
  kind: string(),
14200
14736
  label: string(),
@@ -14231,7 +14767,7 @@ var TargetKindSchema = object({
14231
14767
  * its raster path, which is the safe default for an unknown image.
14232
14768
  */
14233
14769
  iconMediaType: string().optional(),
14234
- configSchema: ConfigSchemaPassthrough$4,
14770
+ configSchema: ConfigSchemaPassthrough$3,
14235
14771
  /**
14236
14772
  * The config keys that decide WHERE this kind's secrets are sent (server,
14237
14773
  * base URL, instance, chat, recipient). A save that changes any of them
@@ -14253,9 +14789,11 @@ var TargetKindSchema = object({
14253
14789
  caps: TargetKindCapsSchema
14254
14790
  });
14255
14791
  /**
14256
- * A persisted target. `config` holds secrets; providers REDACT secret fields
14257
- * (return a presence marker only) when serving `listTargets` — never
14258
- * 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.
14259
14797
  */
14260
14798
  var TargetSchema = object({
14261
14799
  id: string(),
@@ -14298,13 +14836,13 @@ var ProbeTargetConfigResultSchema = object({
14298
14836
  stateInstance: string().optional(),
14299
14837
  error: string().optional()
14300
14838
  });
14301
- 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({
14302
14840
  kind: string(),
14303
14841
  config: record(string(), unknown()).optional(),
14304
14842
  /**
14305
14843
  * When editing / duplicating, the blank password field never round-trips
14306
14844
  * the stored token. Pass the source target id so the provider can restore
14307
- * secrets server-side before dialling (same merge as upsert).
14845
+ * secrets server-side before dialling.
14308
14846
  */
14309
14847
  targetId: string().optional()
14310
14848
  }), array(DiscoveredTargetSchema), { auth: "admin" }), method(object({
@@ -14327,27 +14865,6 @@ method(object({}), array(TargetKindSchema)), method(object({}), array(TargetSche
14327
14865
  }), TestResultSchema, {
14328
14866
  kind: "mutation",
14329
14867
  auth: "admin"
14330
- }), method(object({
14331
- target: TargetSchema,
14332
- /**
14333
- * Duplicate flow: create a NEW target id while copying secrets from an
14334
- * existing row. The UI never holds the stored token; blank / redacted
14335
- * password fields are restored from this source (D634 still applies if
14336
- * destinations diverge without a re-typed secret).
14337
- */
14338
- cloneSecretsFrom: string().optional()
14339
- }), TargetSchema, {
14340
- kind: "mutation",
14341
- auth: "admin"
14342
- }), method(object({ targetId: string() }), _void(), {
14343
- kind: "mutation",
14344
- auth: "admin"
14345
- }), method(object({
14346
- targetId: string(),
14347
- enabled: boolean()
14348
- }), _void(), {
14349
- kind: "mutation",
14350
- auth: "admin"
14351
14868
  });
14352
14869
  looseObject({
14353
14870
  name: string().min(1),
@@ -22758,7 +23275,6 @@ var SYSTEM_CAP_VOCABULARY = {
22758
23275
  "notification-output": system("notification delivery — reached through notifier devices and rules"),
22759
23276
  "notification-rules": system("notification rules — authored on their own page"),
22760
23277
  "oauth-integration": system(IDENTITY),
22761
- "oidc-connections": system(IDENTITY),
22762
23278
  "osd-manager": system(PIPELINE),
22763
23279
  "pipeline-executor": system(PIPELINE),
22764
23280
  "pipeline-orchestrator": system(PIPELINE),
@@ -42640,727 +43156,345 @@ var LEGACY_ICON_ALIASES = { gauge2: "gauge" };
42640
43156
  *
42641
43157
  * ## What is persisted
42642
43158
  *
42643
- * The canonical kebab-case lucide id ({@link IconKey}). Spellings that a lucide
42644
- * package still accepts (`home` for `house`) and this repo's own legacy ones
42645
- * (`gauge2`) RESOLVE ({@link canonicalIconKey}) so a stored value never goes
42646
- * stale, but they are never OFFERED by search.
42647
- *
42648
- * ## Search
42649
- *
42650
- * Over the key, the Italian/English overlay in `icon-synonyms.ts`, any words
42651
- * the caller adds, and lucide's English tags — in that order of weight.
42652
- */
42653
- var KEY_SET$2 = new Set(ICON_KEYS);
42654
- new Map([...Object.entries(ICON_ALIASES), ...Object.entries(LEGACY_ICON_ALIASES)]);
42655
- /** Is this a canonical key of the catalog? (An alias is not — see {@link canonicalIconKey}.) */
42656
- function isIconKey(value) {
42657
- return typeof value === "string" && KEY_SET$2.has(value);
42658
- }
42659
- /**
42660
- * Wire/storage schema for one icon key.
42661
- *
42662
- * Deliberately NOT a `z.enum` of the catalog: ~1,700 literals would be inlined
42663
- * into every cap router, type and API-reference row that carries an icon. The
42664
- * check is membership in the catalog and the type is {@link IconKey}.
42665
- */
42666
- var IconKeySchema = custom(isIconKey, "Not an icon of the catalog");
42667
- var ENTRIES = ICON_KEYS.map((key, index) => {
42668
- const [categoryIndexes, tags] = ICON_META[index] ?? [[], []];
42669
- const categories = categoryIndexes.flatMap((i) => {
42670
- const id = ICON_CATEGORY_IDS[i];
42671
- return id === void 0 ? [] : [id];
42672
- });
42673
- return {
42674
- key,
42675
- categories,
42676
- primaryCategory: categories[0] ?? ICON_CATEGORY_IDS[0],
42677
- tags,
42678
- synonyms: ICON_SYNONYMS[key] ?? []
42679
- };
42680
- });
42681
- new Map(ENTRIES.map((e) => [e.key, e]));
42682
- /** Categories a picker offers first: the ones this product's icons mostly live in. */
42683
- var LEADING_CATEGORIES = [
42684
- "devices",
42685
- "home",
42686
- "security",
42687
- "buildings",
42688
- "connectivity",
42689
- "multimedia",
42690
- "nature",
42691
- "weather",
42692
- "transportation",
42693
- "animals"
42694
- ];
42695
- var PRIMARY_CATEGORIES = new Set(ENTRIES.map((e) => e.primaryCategory));
42696
- [...LEADING_CATEGORIES, ...ICON_CATEGORY_IDS.filter((c) => !LEADING_CATEGORIES.includes(c))].filter((c) => PRIMARY_CATEGORIES.has(c));
42697
- /**
42698
- * One (location, icon) assignment as it travels.
42699
- *
42700
- * `locationKey` is ALWAYS {@link locationIconKey} of the label — never the
42701
- * operator's casing. The registry matches labels trimmed + case-insensitively
42702
- * everywhere (`addLocation`, `removeLocation`, `renameLocation`), and a
42703
- * case-only rename (`kitchen` → `Kitchen`) is a real edit this repo supports; a
42704
- * map keyed on the displayed casing would orphan its entry on exactly that
42705
- * edit. Consumers join by keying their own label through `locationIconKey`.
42706
- */
42707
- var LocationIconAssignmentSchema = object({
42708
- locationKey: string(),
42709
- icon: IconKeySchema
42710
- });
42711
- /**
42712
- * One (location, description) assignment as it travels.
42713
- *
42714
- * Same key discipline as {@link LocationIconAssignmentSchema}, and for the same
42715
- * reason: this lived for a while in the post-analysis addon's own settings,
42716
- * keyed by a HAND-TYPED label matched exactly and case-sensitively. A rename in
42717
- * the Locations page carried the icon and silently orphaned the description —
42718
- * two authorities for one thing, joined by two different rules. Now both hang
42719
- * off the location itself, on `locationIconKey`.
42720
- */
42721
- var LocationDescriptionAssignmentSchema = object({
42722
- locationKey: string(),
42723
- description: string()
42724
- });
42725
- /**
42726
- * WHO an action step acts on (D983) — one target shape for every place that
42727
- * performs an action (automation steps, Action entries, notification
42728
- * sequences, scheduler points):
42729
- *
42730
- * - `devices` — device ids the operator picked, frozen at save time;
42731
- * - `domain` — every device that offers the step's VOCABULARY action,
42732
- * optionally narrowed to one device type and one room, resolved WHEN THE
42733
- * STEP RUNS (a device added later is included). The action always comes
42734
- * from the vocabulary (`cover.open`), never from a raw cap name, so a
42735
- * `domain` target needs an `actionId` (enforced on the step schema);
42736
- * - `var` — a `$var` resolved from the run's scope.
42737
- *
42738
- * {@link ActionTargetResolver} turns a target into device ids. It is pure
42739
- * (a {@link DeviceDirectory} is handed in) so the hub's core-blocks service and
42740
- * a generated automation block share it.
42741
- *
42742
- * A room is the device's `location` label (`DeviceInfo.location`); two labels
42743
- * name the same room when `locationIconKey` agrees (trimmed, lower-cased).
42744
- */
42745
- var ActionTargetSchema = discriminatedUnion("kind", [
42746
- object({
42747
- kind: literal("devices"),
42748
- ids: array(number().int()).min(1)
42749
- }),
42750
- object({
42751
- kind: literal("domain"),
42752
- /** Narrow to one kind of device. */
42753
- deviceType: _enum(DeviceType).optional(),
42754
- /** Narrow to one room: the `location` label devices carry. */
42755
- roomId: string().min(1).optional()
42756
- }),
42757
- object({
42758
- kind: literal("var"),
42759
- name: string().min(1)
42760
- })
42761
- ]);
42762
- EventCategory.DeviceRegistered, EventCategory.DeviceUnregistered, EventCategory.DeviceUpdated, EventCategory.DeviceMetaChanged, EventCategory.DeviceBindingsChanged;
42763
- var ExpressionBindingSourceSchema = union([
42764
- object({
42765
- kind: literal("field").optional(),
42766
- sourceKey: string(),
42767
- cap: string(),
42768
- fieldPath: string()
42769
- }),
42770
- object({
42771
- kind: literal("literal"),
42772
- value: union([
42773
- string(),
42774
- number(),
42775
- boolean(),
42776
- _null()
42777
- ])
42778
- }),
42779
- object({
42780
- kind: literal("global"),
42781
- sourceStableId: string(),
42782
- cap: string(),
42783
- fieldPath: string()
42784
- })
42785
- ]);
42786
- object({
42787
- expr: string().min(1).max(MAX_EXPRESSION_SOURCE_LENGTH),
42788
- bindings: record(string().regex(EXPRESSION_IDENTIFIER_RE), ExpressionBindingSourceSchema)
42789
- }).superRefine((src, ctx) => {
42790
- const err = validateExpressionSource(src);
42791
- if (err !== null) ctx.addIssue({
42792
- code: "custom",
42793
- message: err,
42794
- path: ["expr"]
42795
- });
42796
- });
42797
- /**
42798
- * Identity envelope for a device's upstream-system metadata.
42799
- *
42800
- * Two jobs:
42801
- *
42802
- * 1. **Dispatch key.** `id` is the natural identifier the SOURCE system
42803
- * uses to address this device (HA `entity_id`, Reolink MAC, ONVIF
42804
- * WS-Discovery endpoint UUID, …). Provider code keeps a
42805
- * `Map<sourceInfo.id, IDevice>` to route inbound push events in O(1)
42806
- * without round-tripping through `stableId` / `id` mappings.
42807
- *
42808
- * 2. **Stability bridge.** `uniqueId` is the *immutable* upstream id when
42809
- * one exists (HA `entity.unique_id`, Reolink MAC again — same as `id`
42810
- * for vendors where MAC is the natural key). For systems where the
42811
- * live dispatch key can be renamed (HA `entity_id` can be edited),
42812
- * providers detect renames by matching `uniqueId` and patch `id`
42813
- * in-place so dispatch keeps working.
42814
- *
42815
- * **Display unit and precision are NOT stored here.** They are a read-time
42816
- * preference (D944). A polymorphic reading stores its `quantity` here once,
42817
- * at adopt, and a date/time value stores `dateTimeShape` the same way —
42818
- * neither is repeated on each sample. The `device_class` tag is an
42819
- * HA-specific input consumed at the discovery boundary (`ha-domain-mapping`)
42820
- * to derive the CamStack `DeviceRole`; it is never stored after that point.
42821
- *
42822
- * The `raw` escape hatch carries provider-specific attributes that don't
42823
- * fit the structured slots (HA `attributes` whitelist, Reolink `deviceCache`
42824
- * details, …). Providers control what lands here.
42825
- */
42826
- var SourceInfoSchema = object({
42827
- /** Live dispatch key — mutable when the source system allows rename. */
42828
- id: string(),
42829
- /** Source system tag — e.g. 'homeassistant' | 'reolink' | 'onvif'. */
42830
- system: string(),
42831
- /** Immutable upstream identifier when available (HA `unique_id`, … ).
42832
- * Used to detect rename when `id` changes. */
42833
- uniqueId: string().optional(),
42834
- /** Quantity of a polymorphic reading, written once at adopt (D944). */
42835
- quantity: ReadingQuantitySchema.optional(),
42836
- /** Date / time / datetime shape of a string reading, written once at adopt. */
42837
- dateTimeShape: _enum([
42838
- "date",
42839
- "time",
42840
- "datetime"
42841
- ]).optional(),
42842
- /** Provider-specific extras that don't fit the structured slots.
42843
- * Whitelist what goes here per provider — do NOT dump entire HA
42844
- * attribute blobs (would explode the meta JSON column). */
42845
- raw: record(string(), unknown()).optional()
42846
- });
42847
- /**
42848
- * Build the synthetic SourceInfo every existing provider falls back to
42849
- * when no upstream value has been persisted. Keeps non-migrated providers
42850
- * (Reolink / Hikvision / ONVIF / RTSP) functional without code
42851
- * changes — `id` reuses the CamStack stableId, `system` reuses the addon
42852
- * id. Real upstream identity replaces this once a provider migrates and
42853
- * calls `updateSourceInfo()` with concrete values.
42854
- */
42855
- function synthesizeSourceInfo(input) {
42856
- return {
42857
- id: input.stableId,
42858
- system: input.addonId
42859
- };
42860
- }
42861
- /**
42862
- * Shallow-merge a partial patch over a prior SourceInfo. `undefined`
42863
- * patch values are ignored (no field clobber); to clear a field
42864
- * explicitly, providers omit it from the patch and rebuild from scratch
42865
- * via `updateSourceInfo({})` cycles — uncommon enough that we don't
42866
- * bother with a `null`-means-delete sentinel.
42867
- *
42868
- * The `raw` field is also shallow-merged: passing `raw: { foo: 1 }`
42869
- * merges over existing `raw` keys instead of replacing the whole bag.
42870
- */
42871
- function mergeSourceInfo(prev, patch) {
42872
- const next = { ...prev };
42873
- for (const [k, v] of Object.entries(patch)) {
42874
- if (v === void 0) continue;
42875
- if (k === "raw" && typeof v === "object" && v !== null) {
42876
- next.raw = {
42877
- ...prev.raw,
42878
- ...v
42879
- };
42880
- continue;
42881
- }
42882
- next[k] = v;
42883
- }
42884
- return next;
42885
- }
42886
- /**
42887
- * Coerce common unit-of-measurement string variants to a canonical form
42888
- * so the UI's display templates can rely on stable strings. Pure
42889
- * passthrough for unknown units — kept conservative on purpose, the goal
42890
- * is to normalise the long tail of HA `unit_of_measurement` values that
42891
- * have multiple historical spellings (`'°C'` vs `'C'` vs `'celsius'`).
42892
- *
42893
- * Extend the map as we encounter real-world data. Returning the raw
42894
- * input for unknown values is intentional: providers should never
42895
- * lose information silently here.
42896
- */
42897
- function normalizeUnit(raw) {
42898
- if (raw == null) return void 0;
42899
- const trimmed = raw.trim();
42900
- if (trimmed === "") return void 0;
42901
- const lower = trimmed.toLowerCase();
42902
- if (lower === "°c" || lower === "c" || lower === "celsius") return "°C";
42903
- if (lower === "°f" || lower === "f" || lower === "fahrenheit") return "°F";
42904
- if (lower === "k" || lower === "kelvin") return "K";
42905
- if (lower === "%" || lower === "percent" || lower === "percentage") return "%";
42906
- if (lower === "lx" || lower === "lux") return "lx";
42907
- if (lower === "hpa" || lower === "hectopascal") return "hPa";
42908
- if (lower === "kpa") return "kPa";
42909
- if (lower === "pa") return "Pa";
42910
- if (lower === "mbar" || lower === "millibar") return "mbar";
42911
- if (lower === "w" || lower === "watt") return "W";
42912
- if (lower === "kw" || lower === "kilowatt") return "kW";
42913
- if (lower === "wh" || lower === "watt-hour") return "Wh";
42914
- if (lower === "kwh" || lower === "kilowatt-hour") return "kWh";
42915
- if (lower === "v" || lower === "volt") return "V";
42916
- if (lower === "a" || lower === "amp" || lower === "ampere") return "A";
42917
- if (lower === "ma" || lower === "milliampere") return "mA";
42918
- if (lower === "va") return "VA";
42919
- if (lower === "ppm") return "ppm";
42920
- if (lower === "ppb") return "ppb";
42921
- if (lower === "µg/m³" || lower === "ug/m3" || lower === "µg/m3") return "µg/m³";
42922
- if (lower === "km/h" || lower === "kph") return "km/h";
42923
- if (lower === "mph") return "mph";
42924
- if (lower === "m/s") return "m/s";
42925
- if (lower === "m") return "m";
42926
- if (lower === "m²" || lower === "m2") return "m²";
42927
- if (lower === "mm") return "mm";
42928
- if (lower === "cm") return "cm";
42929
- if (lower === "km") return "km";
42930
- if (lower === "in" || lower === "inch" || lower === "inches") return "in";
42931
- if (lower === "ft" || lower === "foot" || lower === "feet") return "ft";
42932
- if (lower === "kg") return "kg";
42933
- if (lower === "g") return "g";
42934
- if (lower === "l" || lower === "liter" || lower === "litre" || lower === "liters" || lower === "litres") return "L";
42935
- if (lower === "ml") return "mL";
42936
- if (lower === "gal" || lower === "gallon" || lower === "gallons") return "gal";
42937
- if (lower === "s" || lower === "sec" || lower === "second" || lower === "seconds") return "s";
42938
- if (lower === "ms") return "ms";
42939
- if (lower === "min" || lower === "minute" || lower === "minutes") return "min";
42940
- if (lower === "h" || lower === "hr" || lower === "hour" || lower === "hours") return "h";
42941
- if (lower === "d" || lower === "day" || lower === "days") return "d";
42942
- if (lower === "b" || lower === "byte" || lower === "bytes") return "B";
42943
- if (lower === "kib") return "KiB";
42944
- if (lower === "mib") return "MiB";
42945
- if (lower === "gib") return "GiB";
42946
- if (lower === "tib") return "TiB";
42947
- if (lower === "kb") return "kB";
42948
- if (lower === "mb") return "MB";
42949
- if (lower === "gb") return "GB";
42950
- if (lower === "dbm") return "dBm";
42951
- if (lower === "dbfs") return "dBFS";
42952
- if (lower === "inhg") return "inHg";
42953
- if (lower === "mm/h" || lower === "mm/hr") return "mm/h";
42954
- if (lower === "in/h" || lower === "in/hr") return "in/h";
42955
- if (lower === "w/m²" || lower === "w/m2") return "W/m²";
42956
- if (lower === "°" || lower === "deg" || lower === "degree" || lower === "degrees") return "°";
42957
- if (lower === "kbps") return "kbps";
42958
- if (lower === "fps") return "fps";
42959
- return trimmed;
42960
- }
42961
- /**
42962
- * Key under which `SourceInfo` lives inside `DeviceMeta.metadata`. The
42963
- * blob is a free-form `Record<string, unknown>` shared with hardware-
42964
- * identity fields (`manufacturer`, `model`, `firmware`, …); SourceInfo
42965
- * lives under a single nested key to keep it composable with those.
42966
- */
42967
- var SOURCE_INFO_METADATA_KEY = "sourceInfo";
42968
- /**
42969
- * Extract a SourceInfo from a `DeviceMeta.metadata` blob, validating
42970
- * with Zod. Returns `null` when the blob is missing or the nested
42971
- * `sourceInfo` key fails validation — callers fall back to the
42972
- * synthetic default in that case (see `synthesizeSourceInfo`).
42973
- */
42974
- function extractSourceInfoFromMetadata(metadata) {
42975
- if (!metadata) return null;
42976
- const raw = metadata[SOURCE_INFO_METADATA_KEY];
42977
- if (!raw) return null;
42978
- const parsed = SourceInfoSchema.safeParse(raw);
42979
- if (!parsed.success) return null;
42980
- return parsed.data;
42981
- }
42982
- /**
42983
- * Frozen unit → spec table. `•` in the doc marks each dimension's canonical
42984
- * unit (`factor: 1, offset: 0`). °F derives from `°C = (°F − 32) × 5/9` ⇒
42985
- * `factor = 5/9`, `offset = -160/9` (kept as exact expressions, not rounded
42986
- * decimals). K derives from `°C = K − 273.15`.
42987
- */
42988
- var UNIT_TABLE = {
42989
- "°C": {
42990
- dimension: "temperature",
42991
- factor: 1,
42992
- offset: 0
42993
- },
42994
- "°F": {
42995
- dimension: "temperature",
42996
- factor: 5 / 9,
42997
- offset: -160 / 9
42998
- },
42999
- K: {
43000
- dimension: "temperature",
43001
- factor: 1,
43002
- offset: -273.15
43003
- },
43004
- hPa: {
43005
- dimension: "pressure",
43006
- factor: 1,
43007
- offset: 0
43008
- },
43009
- kPa: {
43010
- dimension: "pressure",
43011
- factor: 10,
43012
- offset: 0
43013
- },
43014
- Pa: {
43015
- dimension: "pressure",
43016
- factor: .01,
43017
- offset: 0
43018
- },
43019
- mbar: {
43020
- dimension: "pressure",
43021
- factor: 1,
43022
- offset: 0
43023
- },
43024
- bar: {
43025
- dimension: "pressure",
43026
- factor: 1e3,
43027
- offset: 0
43028
- },
43029
- inHg: {
43030
- dimension: "pressure",
43031
- factor: 33.8639,
43032
- offset: 0
43033
- },
43034
- mmHg: {
43035
- dimension: "pressure",
43036
- factor: 1.33322,
43037
- offset: 0
43038
- },
43039
- psi: {
43040
- dimension: "pressure",
43041
- factor: 68.9476,
43042
- offset: 0
43043
- },
43044
- "m/s": {
43045
- dimension: "speed",
43046
- factor: 1,
43047
- offset: 0
43048
- },
43049
- "km/h": {
43050
- dimension: "speed",
43051
- factor: 1 / 3.6,
43052
- offset: 0
43053
- },
43054
- mph: {
43055
- dimension: "speed",
43056
- factor: .44704,
43057
- offset: 0
43058
- },
43059
- kn: {
43060
- dimension: "speed",
43061
- factor: .514444,
43062
- offset: 0
43063
- },
43064
- "mm/h": {
43065
- dimension: "precipitation-rate",
43066
- factor: 1,
43067
- offset: 0
43068
- },
43069
- "in/h": {
43070
- dimension: "precipitation-rate",
43071
- factor: 25.4,
43072
- offset: 0
43073
- },
43074
- m: {
43075
- dimension: "length",
43076
- factor: 1,
43077
- offset: 0
43078
- },
43079
- mm: {
43080
- dimension: "length",
43081
- factor: .001,
43082
- offset: 0
43083
- },
43084
- cm: {
43085
- dimension: "length",
43086
- factor: .01,
43087
- offset: 0
43088
- },
43089
- km: {
43090
- dimension: "length",
43091
- factor: 1e3,
43092
- offset: 0
43093
- },
43094
- in: {
43095
- dimension: "length",
43096
- factor: .0254,
43097
- offset: 0
43098
- },
43099
- ft: {
43100
- dimension: "length",
43101
- factor: .3048,
43102
- offset: 0
43103
- },
43104
- mi: {
43105
- dimension: "length",
43106
- factor: 1609.344,
43107
- offset: 0
43108
- },
43109
- "m²": {
43110
- dimension: "area",
43111
- factor: 1,
43112
- offset: 0
43113
- },
43114
- lx: {
43115
- dimension: "illuminance",
43116
- factor: 1,
43117
- offset: 0
43118
- },
43119
- "W/m²": {
43120
- dimension: "irradiance",
43121
- factor: 1,
43122
- offset: 0
43123
- },
43124
- W: {
43125
- dimension: "power",
43126
- factor: 1,
43127
- offset: 0
43128
- },
43129
- kW: {
43130
- dimension: "power",
43131
- factor: 1e3,
43132
- offset: 0
43133
- },
43134
- VA: {
43135
- dimension: "apparent-power",
43136
- factor: 1,
43137
- offset: 0
43138
- },
43139
- Wh: {
43140
- dimension: "energy",
43141
- factor: 1,
43142
- offset: 0
43143
- },
43144
- kWh: {
43145
- dimension: "energy",
43146
- factor: 1e3,
43147
- offset: 0
43148
- },
43149
- MWh: {
43150
- dimension: "energy",
43151
- factor: 1e6,
43152
- offset: 0
43153
- },
43154
- V: {
43155
- dimension: "voltage",
43156
- factor: 1,
43157
- offset: 0
43158
- },
43159
- mV: {
43160
- dimension: "voltage",
43161
- factor: .001,
43162
- offset: 0
43163
- },
43164
- A: {
43165
- dimension: "current",
43166
- factor: 1,
43167
- offset: 0
43168
- },
43169
- mA: {
43170
- dimension: "current",
43171
- factor: .001,
43172
- offset: 0
43173
- },
43174
- ppm: {
43175
- dimension: "concentration-volume",
43176
- factor: 1,
43177
- offset: 0
43178
- },
43179
- ppb: {
43180
- dimension: "concentration-volume",
43181
- factor: .001,
43182
- offset: 0
43183
- },
43184
- "µg/m³": {
43185
- dimension: "concentration-mass",
43186
- factor: 1,
43187
- offset: 0
43188
- },
43189
- "mg/m³": {
43190
- dimension: "concentration-mass",
43191
- factor: 1e3,
43192
- offset: 0
43193
- },
43194
- kg: {
43195
- dimension: "mass",
43196
- factor: 1,
43197
- offset: 0
43198
- },
43199
- g: {
43200
- dimension: "mass",
43201
- factor: .001,
43202
- offset: 0
43203
- },
43204
- lb: {
43205
- dimension: "mass",
43206
- factor: .453592,
43207
- offset: 0
43208
- },
43209
- oz: {
43210
- dimension: "mass",
43211
- factor: .0283495,
43212
- offset: 0
43213
- },
43214
- "%": {
43215
- dimension: "percentage",
43216
- factor: 1,
43217
- offset: 0
43218
- },
43219
- L: {
43220
- dimension: "volume",
43221
- factor: 1,
43222
- offset: 0
43223
- },
43224
- mL: {
43225
- dimension: "volume",
43226
- factor: .001,
43227
- offset: 0
43228
- },
43229
- gal: {
43230
- dimension: "volume",
43231
- factor: 3.785411784,
43232
- offset: 0
43233
- },
43234
- s: {
43235
- dimension: "duration",
43236
- factor: 1,
43237
- offset: 0
43238
- },
43239
- ms: {
43240
- dimension: "duration",
43241
- factor: .001,
43242
- offset: 0
43243
- },
43244
- min: {
43245
- dimension: "duration",
43246
- factor: 60,
43247
- offset: 0
43248
- },
43249
- h: {
43250
- dimension: "duration",
43251
- factor: 3600,
43252
- offset: 0
43253
- },
43254
- d: {
43255
- dimension: "duration",
43256
- factor: 86400,
43257
- offset: 0
43258
- },
43259
- B: {
43260
- dimension: "information",
43261
- factor: 1,
43262
- offset: 0
43263
- },
43264
- KiB: {
43265
- dimension: "information",
43266
- factor: 1024,
43267
- offset: 0
43268
- },
43269
- MiB: {
43270
- dimension: "information",
43271
- factor: 1024 ** 2,
43272
- offset: 0
43273
- },
43274
- GiB: {
43275
- dimension: "information",
43276
- factor: 1024 ** 3,
43277
- offset: 0
43278
- },
43279
- TiB: {
43280
- dimension: "information",
43281
- factor: 1024 ** 4,
43282
- offset: 0
43283
- },
43284
- kB: {
43285
- dimension: "information",
43286
- factor: 1e3,
43287
- offset: 0
43288
- },
43289
- MB: {
43290
- dimension: "information",
43291
- factor: 1e6,
43292
- offset: 0
43293
- },
43294
- GB: {
43295
- dimension: "information",
43296
- factor: 1e9,
43297
- offset: 0
43298
- },
43299
- "°": {
43300
- dimension: "angle",
43301
- factor: 1,
43302
- offset: 0
43303
- },
43304
- dBFS: {
43305
- dimension: "sound-level",
43306
- factor: 1,
43307
- offset: 0
43308
- },
43309
- dBm: {
43310
- dimension: "signal-level",
43311
- factor: 1,
43312
- offset: 0
43313
- },
43314
- mired: {
43315
- dimension: "colour-temperature",
43316
- factor: 1,
43317
- offset: 0
43318
- },
43319
- kbps: {
43320
- dimension: "bitrate",
43321
- factor: 1,
43322
- offset: 0
43323
- },
43324
- Mbps: {
43325
- dimension: "bitrate",
43326
- factor: 1e3,
43327
- offset: 0
43328
- },
43329
- fps: {
43330
- dimension: "rate",
43331
- factor: 1,
43332
- offset: 0
43333
- }
43334
- };
43335
- /** Resolve a unit's `UnitSpec`, or `undefined` when the spelling is unknown. */
43336
- function specFor(unit) {
43337
- 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);
43338
43174
  }
43339
- /** The dimension a unit belongs to, or `undefined` for an unknown unit. */
43340
- function unitDimension(unit) {
43341
- 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
+ };
43342
43377
  }
43343
- /** Value in `spec`'s unit → its dimension's canonical unit. */
43344
- function toCanonical(value, spec) {
43345
- 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;
43346
43402
  }
43347
- /** Canonical-unit value → the unit described by `spec`. */
43348
- function fromCanonical(canonical, spec) {
43349
- 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;
43350
43477
  }
43351
43478
  /**
43352
- * Graceful variant for the render path: returns the converted value, or
43353
- * `undefined` when the conversion is refused (unknown unit / cross-dimension).
43354
- * 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.
43355
43483
  */
43356
- function tryConvertUnit(value, from, to) {
43357
- if (from === to) return value;
43358
- const fromSpec = specFor(from);
43359
- if (!fromSpec) return void 0;
43360
- const toSpec = specFor(to);
43361
- if (!toSpec) return void 0;
43362
- if (fromSpec.dimension !== toSpec.dimension) return void 0;
43363
- 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;
43364
43498
  }
43365
43499
  /**
43366
43500
  * A number a person types for a physical quantity — the input side of the
@@ -45039,15 +45173,28 @@ var SettingsSchemaWithValuesSchema = object({
45039
45173
  });
45040
45174
  /** Patch object — keys are field names, values are the new field values. */
45041
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
+ });
45042
45184
  /** Standard success response for update operations. */
45043
45185
  var SettingsUpdateResultSchema = object({ success: literal(true) });
45044
45186
  method(object({
45045
45187
  addonId: string(),
45046
- nodeId: string().optional(),
45047
- overlay: record(string(), unknown()).optional(),
45048
- cap: string().optional()
45188
+ cap: string(),
45189
+ scope: ScopedSettingsScopeSchema,
45190
+ nodeId: string().optional()
45049
45191
  }), SettingsSchemaWithValuesSchema.nullable()), method(object({
45050
45192
  addonId: string(),
45193
+ nodeId: string().optional()
45194
+ }), array(ScopedSettingsDeclarationSchema).nullable()), method(object({
45195
+ addonId: string(),
45196
+ cap: string(),
45197
+ scope: ScopedSettingsScopeSchema,
45051
45198
  nodeId: string().optional(),
45052
45199
  patch: SettingsPatchSchema
45053
45200
  }), SettingsUpdateResultSchema, {
@@ -45055,8 +45202,10 @@ method(object({
45055
45202
  auth: "admin"
45056
45203
  }), method(object({
45057
45204
  addonId: string(),
45205
+ cap: string(),
45206
+ scope: ScopedSettingsScopeSchema,
45058
45207
  nodeId: string().optional()
45059
- }), SettingsSchemaWithValuesSchema.nullable()), method(object({
45208
+ }), record(string(), unknown()).nullable()), method(object({
45060
45209
  addonId: string(),
45061
45210
  nodeId: string().optional(),
45062
45211
  instance: IntegrationInstanceRefSchema
@@ -46619,7 +46768,7 @@ var BackupDestinationInfoSchema = object({
46619
46768
  id: string(),
46620
46769
  /**
46621
46770
  * Manifest id of the owning addon. The Settings button on the
46622
- * destination card opens that addon's `globalSettingsSchema` panel.
46771
+ * destination card opens that addon's scoped settings panel.
46623
46772
  */
46624
46773
  addonId: string(),
46625
46774
  /** Operator-toggled enable flag from the destination-policy table. */
@@ -50033,7 +50182,7 @@ var mediaPlayerCapability = {
50033
50182
  isMuted: { kind: "boolean" }
50034
50183
  } }
50035
50184
  };
50036
- 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;
50037
50186
  var NUMBER = {
50038
50187
  kind: "fixed",
50039
50188
  result: ["number"]
@@ -52072,6 +52221,7 @@ method(InstancePinSchema, DeviceExportStatusSchema), method(_void(), array(Expor
52072
52221
  kind: "mutation",
52073
52222
  auth: "admin"
52074
52223
  });
52224
+ var DeviceAliasSchema = string().max(64).regex(/^[a-z][a-z0-9_]*$/);
52075
52225
  /**
52076
52226
  * A SITE ZONE — a named part of the property that several locations belong to.
52077
52227
  *
@@ -52558,6 +52708,12 @@ var DeviceInfoSchema = object({
52558
52708
  addonId: string(),
52559
52709
  type: _enum(DeviceType),
52560
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(),
52561
52717
  /** Operator-organisational location label. `null` when unset. */
52562
52718
  location: string().nullable(),
52563
52719
  /** Soft-disabled flag. */
@@ -52877,6 +53033,25 @@ method(object({
52877
53033
  }), _void(), {
52878
53034
  kind: "mutation",
52879
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"
52880
53055
  }), method(object({
52881
53056
  deviceId: number(),
52882
53057
  location: string().nullable()
@@ -56586,7 +56761,7 @@ method(_void(), array(IntegrationWithStateSchema)), method(object({ id: string()
56586
56761
  * or the redaction token KEEPS the stored secret; `{ $secretClear: true }`
56587
56762
  * clears it.
56588
56763
  */
56589
- var ConfigSchemaPassthrough$3 = custom();
56764
+ var ConfigSchemaPassthrough$2 = custom();
56590
56765
  var IntegrationInstanceIdSchema = string().min(1);
56591
56766
  var IntegrationInstanceModeSchema = _enum(["single", "multiple"]);
56592
56767
  /**
@@ -56632,7 +56807,16 @@ var IntegrationInstanceKindSchema = object({
56632
56807
  /** Relative hub path to start an interactive account link of an instance of this kind. */
56633
56808
  connectPath: string().min(1).optional(),
56634
56809
  /** Relative hub path to disconnect that account. */
56635
- 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()
56636
56820
  });
56637
56821
  /**
56638
56822
  * How devices of an instance are found. `none`: the operator adds them by hand; `lan`: the addon
@@ -56673,10 +56857,11 @@ var IntegrationInstanceDescriptionSchema = object({
56673
56857
  /** True when `testInstance` really probes the remote. */
56674
56858
  canTest: boolean(),
56675
56859
  /**
56676
- * The kinds an instance can be of. Absent or one entry: nothing to choose; more than one: the
56677
- * 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.
56678
56863
  */
56679
- kinds: array(IntegrationInstanceKindSchema).optional(),
56864
+ kinds: array(IntegrationInstanceKindSchema).min(1),
56680
56865
  /**
56681
56866
  * The provider accepts `createInstance.id` for an id that once existed (an adopted id, because
56682
56867
  * devices carry it). The UI then offers "restore under its old id" on Add. Absent means no.
@@ -56712,8 +56897,8 @@ var IntegrationInstanceSchema = object({
56712
56897
  * the body is the one store, `setInstanceEnabled` the one writer (epic #440, step 3).
56713
56898
  */
56714
56899
  enabled: boolean().optional(),
56715
- /** The kind of this instance (one of `describe().kinds[].id`), when the provider has kinds. */
56716
- kind: string().optional(),
56900
+ /** The kind of this instance: exactly one of `describe().kinds[].id` (D1013 rule 2). */
56901
+ kind: string().min(1),
56717
56902
  /** Values for the instance form; a secret is a `SecretFieldView`, never text. */
56718
56903
  formValues: record(string(), unknown()),
56719
56904
  status: IntegrationInstanceStatusSchema.optional(),
@@ -56737,7 +56922,7 @@ var integrationInstancesCapability = {
56737
56922
  id: IntegrationInstanceIdSchema.nullable(),
56738
56923
  /** The kind of the create form (`id: null`) of a provider with several. */
56739
56924
  kind: string().min(1).optional()
56740
- }), ConfigSchemaPassthrough$3, { auth: "admin" }),
56925
+ }), ConfigSchemaPassthrough$2, { auth: "admin" }),
56741
56926
  listInstances: method(_void(), array(IntegrationInstanceSchema).readonly(), { auth: "admin" }),
56742
56927
  getInstance: method(object({ id: IntegrationInstanceIdSchema }), IntegrationInstanceSchema.nullable(), { auth: "admin" }),
56743
56928
  /**
@@ -57839,12 +58024,12 @@ var LlmModelInfoSchema = object({
57839
58024
  });
57840
58025
  /**
57841
58026
  * The provider-specific part of a profile, validated by the provider that owns
57842
- * 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
57843
58028
  * `connectionSchema` declares `type: 'password'` is a secret: it is held in the
57844
58029
  * keychain, never in the row, and reads back as the redaction marker.
57845
58030
  */
57846
58031
  var LlmProviderConfigSchema = record(string(), unknown());
57847
- var LlmProfileSchema = object({
58032
+ object({
57848
58033
  id: string(),
57849
58034
  name: string(),
57850
58035
  /** The provider-declared kind (`LlmProfileKindDescriptor.kind`). */
@@ -57938,8 +58123,8 @@ var LlmProviderWidgetSchema = object({
57938
58123
  /** ConfigUISchema tree passed through untyped on the wire (the
57939
58124
  * notification-output `ConfigSchemaPassthrough` precedent at
57940
58125
  * notification-output.cap.ts:151); the exported TS type re-tightens it. */
57941
- var ConfigSchemaPassthrough$2 = unknown();
57942
- var LlmProfileKindDescriptorSchema = object({
58126
+ var ConfigSchemaPassthrough$1 = unknown();
58127
+ object({
57943
58128
  kind: LlmProfileKindSchema,
57944
58129
  label: string(),
57945
58130
  /** A generic icon name (`cloud`, `plug`, `cpu`) — never a glyph or a logo. */
@@ -57947,9 +58132,9 @@ var LlmProfileKindDescriptorSchema = object({
57947
58132
  /** Stamped by each provider so the concat-fanned catalog stays routable. */
57948
58133
  addonId: string(),
57949
58134
  /** The provider's own fields (`providerConfig`); `password` fields are keychain-held. */
57950
- connectionSchema: ConfigSchemaPassthrough$2,
58135
+ connectionSchema: ConfigSchemaPassthrough$1,
57951
58136
  /** Provider fields that belong under "Advanced" (extra headers, runtime tuning). */
57952
- advancedSchema: ConfigSchemaPassthrough$2.optional(),
58137
+ advancedSchema: ConfigSchemaPassthrough$1.optional(),
57953
58138
  /** The kind's defaults; a model from `listModels` may override any of them. */
57954
58139
  features: LlmModelFeaturesSchema,
57955
58140
  /** `false` = the provider stamps `supportsVision` itself (from what a node reports). */
@@ -58078,20 +58263,7 @@ method(LlmGenerateBaseInputSchema, LlmGenerateResultSchema, {
58078
58263
  }), method(object({
58079
58264
  addonId: string().optional(),
58080
58265
  requestId: string()
58081
- }), _void(), { kind: "mutation" }), method(object({}), array(LlmProfileKindDescriptorSchema)), method(object({}), array(LlmProfileSchema)), method(object({ profile: LlmProfileSchema }), LlmProfileSchema, {
58082
- kind: "mutation",
58083
- auth: "admin"
58084
- }), method(RawSecretMigrationInputSchema, RawSecretMigrationReportSchema, {
58085
- kind: "mutation",
58086
- auth: "admin"
58087
- }), method(ProfileRefInputSchema, _void(), {
58088
- kind: "mutation",
58089
- auth: "admin"
58090
- }), method(ProfileRefInputSchema, LlmGenerateResultSchema, {
58091
- kind: "mutation",
58092
- auth: "admin",
58093
- timeoutMs: AI_CAP_TRANSPORT_TIMEOUT_MS
58094
- }), method(LlmListModelsInputSchema, LlmListModelsResultSchema, {
58266
+ }), _void(), { kind: "mutation" }), method(LlmListModelsInputSchema, LlmListModelsResultSchema, {
58095
58267
  kind: "mutation",
58096
58268
  auth: "admin"
58097
58269
  }), method(object({}), array(LlmDefaultSchema)), method(object({
@@ -59154,20 +59326,7 @@ method(_void(), MeshStatusSchema), method(object({
59154
59326
  /** Optional hostname override the host should advertise once joined. */
59155
59327
  hostname: string().optional() }), object({
59156
59328
  /** Authentication URL the operator should open in a browser. */
59157
- 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({
59158
- /** Optional auth key — when provided, probes the key validity
59159
- * against the provider's API. Omit when already joined to
59160
- * just ping the daemon. */
59161
- authKey: string().optional() }), object({
59162
- ok: boolean(),
59163
- /** Provider-side identifier resolved by the probe (tailnet
59164
- * name for Tailscale, network id for ZeroTier, etc.). */
59165
- tenant: string().optional(),
59166
- /** Daemon binary version, when reachable. */
59167
- daemonVersion: string().optional(),
59168
- /** Human-readable error when `ok: false`. */
59169
- error: string().optional()
59170
- }), { 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() }));
59171
59330
  /**
59172
59331
  * A monotonic total between resets (D944). Energy uses `power-meter.energy`
59173
59332
  * so dashboards keep one series; every other instantaneous reading lands here.
@@ -66994,6 +67153,11 @@ var NcScheduleSchema = object({
66994
67153
  * as a STATE SUMMARY at the end of each window of `schedule`.
66995
67154
  */
66996
67155
  var NcSystemEventDeliveryModeSchema = _enum(["instant", "summary"]);
67156
+ _enum([
67157
+ "activation",
67158
+ "deactivation",
67159
+ "schedule"
67160
+ ]);
66997
67161
  /**
66998
67162
  * How a summary window is SENT (D698): `rule` (absent) = ONE notification with
66999
67163
  * every section; `section` = one notification per section with something to
@@ -67010,11 +67174,26 @@ var NcStateSummarySplitSchema = _enum(["rule", "section"]);
67010
67174
  * midnight crossing); the send time is each window's END. Refused on the
67011
67175
  * `alarm` family, which stays instant (`systemEventDeliveryProblems`).
67012
67176
  */
67013
- var NcSystemEventDeliverySchema = discriminatedUnion("mode", [object({ mode: literal("instant") }), object({
67014
- mode: literal("summary"),
67015
- schedule: NcScheduleSchema,
67016
- split: NcStateSummarySplitSchema.optional()
67017
- })]);
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
+ ]);
67018
67197
  /** Fuzzy plate matcher — OCR noise makes exact match useless (spec row 12/13). */
67019
67198
  var NcPlateMatcherSchema = object({
67020
67199
  /**
@@ -69374,61 +69553,6 @@ var OauthIntegrationDescriptorSchema = object({
69374
69553
  });
69375
69554
  method(_void(), OauthIntegrationDescriptorSchema, { auth: "admin" });
69376
69555
  /**
69377
- * `oidc-connections` — CRUD for IdP rows under `auth-oidc` (D828 sibling).
69378
- *
69379
- * One hub-only singleton (`auth-oidc`). The Settings UI is a DataTable +
69380
- * ItemFormDialog; there is no `editable-array` in `globalSettingsSchema`.
69381
- * Operator-chosen `id` is the URL slug (`/addon/auth-oidc/<id>/…`) and is
69382
- * immutable after create.
69383
- */
69384
- var ConfigSchemaPassthrough$1 = unknown();
69385
- var OidcConnectionSchema = object({
69386
- id: string().min(1),
69387
- displayName: string(),
69388
- icon: string(),
69389
- issuerUrl: string(),
69390
- clientId: string(),
69391
- /** Client id + secret present — never the secret value. */
69392
- configured: boolean(),
69393
- /**
69394
- * Values for the connection form schema. `clientSecret` is a keychain
69395
- * {@link SecretFieldView} or `null` / `''`, never plaintext (D789).
69396
- */
69397
- formValues: record(string(), unknown()).optional()
69398
- });
69399
- /**
69400
- * Patch one connection. Omitted or empty `clientSecret` keeps the stored
69401
- * secret (D787). `{ $secretClear: true }` clears it. `id` is never renamed.
69402
- */
69403
- var OidcConnectionUpdateInputSchema = object({
69404
- id: string().min(1),
69405
- displayName: string().min(1),
69406
- icon: string().optional(),
69407
- issuerUrl: string().optional(),
69408
- clientId: string().optional(),
69409
- clientSecret: union([string(), object({ $secretClear: literal(true) })]).optional(),
69410
- redirectUri: string().optional(),
69411
- scopes: string().optional(),
69412
- usernameClaim: _enum([
69413
- "preferred_username",
69414
- "email",
69415
- "sub"
69416
- ]).optional()
69417
- });
69418
- method(object({}), ConfigSchemaPassthrough$1, { auth: "admin" }), method(object({}), array(OidcConnectionSchema).readonly(), { auth: "admin" }), method(object({
69419
- id: string().min(1).regex(/^[a-z0-9][a-z0-9-]{0,63}$/, "id must be a lowercase slug"),
69420
- displayName: string().min(1)
69421
- }), object({ id: string() }), {
69422
- kind: "mutation",
69423
- auth: "admin"
69424
- }), method(OidcConnectionUpdateInputSchema, object({ ok: literal(true) }), {
69425
- kind: "mutation",
69426
- auth: "admin"
69427
- }), method(object({ id: string().min(1) }), object({ ok: literal(true) }), {
69428
- kind: "mutation",
69429
- auth: "admin"
69430
- });
69431
- /**
69432
69556
  * Generic on-screen-display (video overlay) cap. Each camera exposes
69433
69557
  * a firmware-defined list of overlays (channel name, timestamp,
69434
69558
  * watermark, logo, …); the cap models them as a homogeneous array of
@@ -75143,6 +75267,16 @@ var RemoteLayoutComponentSchema = object({
75143
75267
  method(object({}), array(RemoteLayoutComponentSchema), { auth: "protected" });
75144
75268
  var RUNNING_POWER_START_DELAY_MS = 3e4;
75145
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
+ } };
75146
75280
  var RunningStateSourceSchema = _enum(["native", "assigned"]);
75147
75281
  var RunningStateStatusSchema = object({
75148
75282
  /** null = unknown — never coerced to false (D393). */
@@ -75160,93 +75294,27 @@ var RunningFlipEventDataSchema = object({
75160
75294
  phase: string().nullable()
75161
75295
  });
75162
75296
  var RUNNING_DEVICE_TYPES = Object.values(DeviceType);
75163
- /** Generic Customize target for the running boolean (D936). */
75164
- var runningCustomize = {
75165
- version: 1,
75166
- overridable: [{
75167
- path: "running",
75168
- by: "running"
75169
- }],
75170
- targets: [{
75171
- id: "running",
75172
- cardinality: "scalar",
75173
- vocabulary: {
75174
- cap: "running-state",
75175
- stateField: "running"
75176
- },
75177
- deviceTypes: [
75178
- DeviceType.Washer,
75179
- DeviceType.Dryer,
75180
- DeviceType.Dishwasher,
75181
- DeviceType.Vacuum,
75182
- DeviceType.LawnMower,
75183
- DeviceType.MediaPlayer,
75184
- DeviceType.WaterHeater,
75185
- DeviceType.Humidifier,
75186
- DeviceType.Fan,
75187
- DeviceType.Climate,
75188
- DeviceType.Thermostat,
75189
- DeviceType.PetFeeder,
75190
- DeviceType.Heater
75191
- ],
75192
- apply: "add",
75193
- path: "running",
75194
- sources: [
75195
- {
75196
- kind: "switch",
75197
- transforms: [{ kind: "identity" }]
75198
- },
75199
- {
75200
- kind: "binary",
75201
- transforms: [{ kind: "identity" }, { kind: "invert" }]
75202
- },
75203
- {
75204
- kind: "numeric",
75205
- requiredUnit: "W",
75206
- transforms: [{
75207
- kind: "threshold",
75208
- comparisons: ["gte", "lte"],
75209
- comparison: "gte",
75210
- defaultThreshold: 5,
75211
- defaultStartDwellMs: RUNNING_POWER_START_DELAY_MS,
75212
- defaultStopDwellMs: RUNNING_POWER_STOP_DELAY_MS,
75213
- thresholdUnit: "W"
75214
- }]
75215
- }
75216
- ],
75217
- companions: [
75218
- {
75219
- kind: "constant",
75220
- path: "source",
75221
- value: "assigned",
75222
- when: "always"
75223
- },
75224
- {
75225
- kind: "constant",
75226
- path: "phase",
75227
- value: null,
75228
- when: "add"
75229
- },
75230
- {
75231
- kind: "clock",
75232
- path: "lastFetchedAt",
75233
- when: "always"
75234
- },
75235
- {
75236
- kind: "transition-time",
75237
- path: "since",
75238
- sourceChangedAt: "prefer"
75239
- }
75240
- ],
75241
- sourceReport: {
75242
- status: "assignment-status",
75243
- runtimeField: "source",
75244
- nativeValue: "native",
75245
- assignedValue: "assigned"
75246
- },
75247
- advancedExpression: true
75248
- }]
75249
- };
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
+ ];
75250
75318
  var runningStateCapability = {
75251
75319
  name: "running-state",
75252
75320
  scope: "device",
@@ -75266,7 +75334,79 @@ var runningStateCapability = {
75266
75334
  durability: "restored",
75267
75335
  history: { fields: { running: { kind: "boolean" } } },
75268
75336
  volatileStateFields: ["lastFetchedAt"],
75269
- 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
+ }
75270
75410
  };
75271
75411
  /**
75272
75412
  * scene-monitor — device-scoped reference-region state cap. An operator marks
@@ -76510,21 +76650,6 @@ method(object({
76510
76650
  */
76511
76651
  ttlSec: union([number().int().positive(), literal("never")]).optional()
76512
76652
  }), object({ token: string() }), { auth: "admin" }), method(object({ token: string() }), SsoBridgeClaimsSchema.nullable(), { auth: "admin" });
76513
- var ProviderListEntrySchema = discriminatedUnion("shouldSaveDiskSpace", [object({
76514
- providerId: string().min(1),
76515
- displayName: string().min(1),
76516
- configSchema: unknown(),
76517
- nodeLocal: boolean(),
76518
- shouldSaveDiskSpace: literal(true),
76519
- minFreePercent: number().min(0).max(100)
76520
- }), object({
76521
- providerId: string().min(1),
76522
- displayName: string().min(1),
76523
- configSchema: unknown(),
76524
- nodeLocal: boolean(),
76525
- shouldSaveDiskSpace: literal(false),
76526
- minFreePercent: literal(null)
76527
- })]);
76528
76653
  method(object({
76529
76654
  location: StorageLocationRefSchema,
76530
76655
  relativePath: string()
@@ -76586,42 +76711,7 @@ method(object({
76586
76711
  }), _instanceof(Uint8Array), { auth: "admin" }), method(object({ downloadId: string() }), _void(), {
76587
76712
  kind: "mutation",
76588
76713
  auth: "admin"
76589
- }), method(object({ type: StorageLocationTypeSchema.optional() }), array(StorageLocationSchema).readonly()), method(_void(), array(StorageLocationDeclarationSchema).readonly()), method(StorageLocationSchema.omit({
76590
- createdAt: true,
76591
- updatedAt: true
76592
- }), StorageLocationSchema, {
76593
- kind: "mutation",
76594
- auth: "admin"
76595
- }), method(object({
76596
- id: string(),
76597
- force: boolean().optional()
76598
- }), _void(), {
76599
- kind: "mutation",
76600
- auth: "admin"
76601
- }), method(_void(), array(StorageDrainProgressSchema).readonly()), method(object({ id: string() }), object({
76602
- ok: boolean(),
76603
- error: string().optional()
76604
- }), { auth: "admin" }), method(_void(), array(ProviderListEntrySchema).readonly()), method(object({
76605
- providerId: string(),
76606
- /**
76607
- * The location this config is an UNSAVED edit of, when there is one.
76608
- *
76609
- * `listLocations` replaces every declared secret with the redaction
76610
- * sentinel, so the edit modal's form state holds the sentinel for any
76611
- * credential the operator did not retype — and posting that here
76612
- * without a way to resolve it makes the provider try to authenticate
76613
- * as `__camstack_redacted__` and report the operator's own working
76614
- * password as wrong. Given this id, the orchestrator restores each
76615
- * sentinel from the stored config (same rule as `upsertLocation`)
76616
- * before dispatching. Omitted by the "Add location" wizard, where
76617
- * every value was typed just now and nothing is stored yet.
76618
- */
76619
- locationId: string().optional(),
76620
- config: record(string(), unknown())
76621
- }), object({
76622
- ok: boolean(),
76623
- error: string().optional()
76624
- }), { auth: "admin" });
76714
+ }), method(object({ type: StorageLocationTypeSchema.optional() }), array(StorageLocationSchema).readonly()), method(_void(), array(StorageLocationDeclarationSchema).readonly()), method(_void(), array(StorageDrainProgressSchema).readonly());
76625
76715
  /** One table of the settings database. */
76626
76716
  var StorageTableSchema = object({
76627
76717
  /** The table's full name, e.g. `recorder:addon-settings` or `addon-device-settings`. */
@@ -78143,7 +78233,7 @@ var TerminalInstanceInfoSchema = object({
78143
78233
  /**
78144
78234
  * False while the node the instance is bound to is not in the cluster
78145
78235
  * topology (forgotten, renamed, re-paired). The instance is kept; the
78146
- * operator re-points it with `updateInstance({ targetNodeId })`.
78236
+ * operator re-points it on the Terminal page.
78147
78237
  */
78148
78238
  nodeInCluster: boolean(),
78149
78239
  profileId: string(),
@@ -78181,41 +78271,7 @@ var TerminalOutputBatchSchema = object({
78181
78271
  snapshot: string().optional(),
78182
78272
  events: array(TerminalOutputEventSchema).readonly()
78183
78273
  });
78184
- method(_void(), array(TerminalProfileInfoSchema).readonly(), { auth: "admin" }), method(_void(), array(TerminalInstanceInfoSchema).readonly(), { auth: "admin" }), method(object({
78185
- targetNodeId: string().min(1),
78186
- profileId: string().min(1),
78187
- name: string().trim().min(1).max(160).optional(),
78188
- executable: string().max(1024).optional(),
78189
- args: array(string().max(2048)).max(64).optional(),
78190
- cwd: string().max(1024).optional(),
78191
- environment: array(string().max(4096)).max(64).optional(),
78192
- profileSettings: ProfileSettingsBagSchema.optional()
78193
- }), TerminalInstanceInfoSchema, {
78194
- kind: "mutation",
78195
- auth: "admin"
78196
- }), method(object({
78197
- instanceId: string().min(1),
78198
- /** Re-point the instance to another node; the profile must exist there. */
78199
- targetNodeId: string().min(1).max(256).optional(),
78200
- name: string().trim().min(1).max(160).optional(),
78201
- executable: string().max(1024).optional(),
78202
- args: array(string().max(2048)).max(64).optional(),
78203
- cwd: string().max(1024).optional(),
78204
- environment: array(string().max(4096)).max(64).optional(),
78205
- profileSettings: ProfileSettingsBagSchema.optional()
78206
- }), TerminalInstanceInfoSchema, {
78207
- kind: "mutation",
78208
- auth: "admin"
78209
- }), method(object({ instanceId: string().min(1) }), _void(), {
78210
- kind: "mutation",
78211
- auth: "admin"
78212
- }), method(object({
78213
- instanceId: string().min(1),
78214
- enabled: boolean()
78215
- }), TerminalInstanceInfoSchema, {
78216
- kind: "mutation",
78217
- auth: "admin"
78218
- }), 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({
78219
78275
  stableId: string().min(1),
78220
78276
  name: string().trim().min(1).max(160).optional()
78221
78277
  }), TerminalInstanceInfoSchema, {
@@ -78284,6 +78340,11 @@ var TimedRunUnitSchema = _enum(["s", "min"]);
78284
78340
  _enum(["switch", "pet-fountain"]);
78285
78341
  DeviceType.Heater, DeviceType.PetFountain;
78286
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
+ });
78287
78348
  /** Why a request was not carried out. Typed, so a caller can say it in words. */
78288
78349
  var TimedRunRefusalSchema = _enum([
78289
78350
  "unsupported-device",
@@ -78304,8 +78365,23 @@ var TimedRunStatusSchema = object({
78304
78365
  activeUntil: number().nullable(),
78305
78366
  /** Who asked for the run (a user id or an addon id); `null` when nothing is armed or it did not say. */
78306
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(),
78307
78374
  lastFetchedAt: number()
78308
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() });
78309
78385
  var timedRunCapability = {
78310
78386
  name: "timed-run",
78311
78387
  scope: "device",
@@ -78313,7 +78389,24 @@ var timedRunCapability = {
78313
78389
  kind: "wrapper",
78314
78390
  defaultActive: true,
78315
78391
  deviceTypes: TIMED_RUN_DEVICE_TYPES,
78392
+ deviceConfig: { ui: {
78393
+ kind: "derived-form",
78394
+ builderId: "timed-run",
78395
+ tab: "general"
78396
+ } },
78316
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
+ }),
78317
78410
  /**
78318
78411
  * Turn the device on and arm its off. A run already armed is replaced (the
78319
78412
  * new deadline wins). Refuses with a typed reason above the type's maximum.
@@ -83106,21 +83199,28 @@ Object.freeze({
83106
83199
  access: "view",
83107
83200
  role: "admin"
83108
83201
  },
83109
- "addonSettings.getGlobalSettings": {
83202
+ "addonSettings.getIntegrationFormSchema": {
83110
83203
  capName: "addon-settings",
83111
83204
  capScope: "system",
83112
83205
  addonId: null,
83113
83206
  access: "view",
83114
83207
  role: "admin"
83115
83208
  },
83116
- "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": {
83117
83217
  capName: "addon-settings",
83118
83218
  capScope: "system",
83119
83219
  addonId: null,
83120
83220
  access: "view",
83121
83221
  role: "admin"
83122
83222
  },
83123
- "addonSettings.getIntegrationSettings": {
83223
+ "addonSettings.readScopedValues": {
83124
83224
  capName: "addon-settings",
83125
83225
  capScope: "system",
83126
83226
  addonId: null,
@@ -83141,7 +83241,7 @@ Object.freeze({
83141
83241
  access: "create",
83142
83242
  role: "admin"
83143
83243
  },
83144
- "addonSettings.updateGlobalSettings": {
83244
+ "addonSettings.updateScopedSettings": {
83145
83245
  capName: "addon-settings",
83146
83246
  capScope: "system",
83147
83247
  addonId: null,
@@ -85311,6 +85411,13 @@ Object.freeze({
85311
85411
  access: "create",
85312
85412
  role: "admin"
85313
85413
  },
85414
+ "deviceManager.setAlias": {
85415
+ capName: "device-manager",
85416
+ capScope: "system",
85417
+ addonId: null,
85418
+ access: "create",
85419
+ role: "admin"
85420
+ },
85314
85421
  "deviceManager.setChildLayout": {
85315
85422
  capName: "device-manager",
85316
85423
  capScope: "system",
@@ -86599,13 +86706,6 @@ Object.freeze({
86599
86706
  access: "delete",
86600
86707
  role: "admin"
86601
86708
  },
86602
- "llm.deleteProfile": {
86603
- capName: "llm",
86604
- capScope: "system",
86605
- addonId: null,
86606
- access: "delete",
86607
- role: "admin"
86608
- },
86609
86709
  "llm.generate": {
86610
86710
  capName: "llm",
86611
86711
  capScope: "system",
@@ -86669,20 +86769,6 @@ Object.freeze({
86669
86769
  access: "view",
86670
86770
  role: "admin"
86671
86771
  },
86672
- "llm.listProfileKinds": {
86673
- capName: "llm",
86674
- capScope: "system",
86675
- addonId: null,
86676
- access: "view",
86677
- role: "admin"
86678
- },
86679
- "llm.listProfiles": {
86680
- capName: "llm",
86681
- capScope: "system",
86682
- addonId: null,
86683
- access: "view",
86684
- role: "admin"
86685
- },
86686
86772
  "llm.listRuntimeNodes": {
86687
86773
  capName: "llm",
86688
86774
  capScope: "system",
@@ -86690,13 +86776,6 @@ Object.freeze({
86690
86776
  access: "view",
86691
86777
  role: "admin"
86692
86778
  },
86693
- "llm.migrateRawSecrets": {
86694
- capName: "llm",
86695
- capScope: "system",
86696
- addonId: null,
86697
- access: "create",
86698
- role: "admin"
86699
- },
86700
86779
  "llm.resolveModelRef": {
86701
86780
  capName: "llm",
86702
86781
  capScope: "system",
@@ -86725,20 +86804,6 @@ Object.freeze({
86725
86804
  access: "create",
86726
86805
  role: "admin"
86727
86806
  },
86728
- "llm.testProfile": {
86729
- capName: "llm",
86730
- capScope: "system",
86731
- addonId: null,
86732
- access: "create",
86733
- role: "admin"
86734
- },
86735
- "llm.upsertProfile": {
86736
- capName: "llm",
86737
- capScope: "system",
86738
- addonId: null,
86739
- access: "create",
86740
- role: "admin"
86741
- },
86742
86807
  "llmRuntime.appleAvailability": {
86743
86808
  capName: "llm-runtime",
86744
86809
  capScope: "system",
@@ -87243,13 +87308,6 @@ Object.freeze({
87243
87308
  access: "create",
87244
87309
  role: "admin"
87245
87310
  },
87246
- "meshNetwork.testConnection": {
87247
- capName: "mesh-network",
87248
- capScope: "system",
87249
- addonId: null,
87250
- access: "create",
87251
- role: "admin"
87252
- },
87253
87311
  "meter.getStatus": {
87254
87312
  capName: "meter",
87255
87313
  capScope: "device",
@@ -87908,13 +87966,6 @@ Object.freeze({
87908
87966
  access: "create",
87909
87967
  role: "admin"
87910
87968
  },
87911
- "notificationOutput.deleteTarget": {
87912
- capName: "notification-output",
87913
- capScope: "system",
87914
- addonId: null,
87915
- access: "delete",
87916
- role: "admin"
87917
- },
87918
87969
  "notificationOutput.discoverTargets": {
87919
87970
  capName: "notification-output",
87920
87971
  capScope: "system",
@@ -87922,13 +87973,6 @@ Object.freeze({
87922
87973
  access: "view",
87923
87974
  role: "admin"
87924
87975
  },
87925
- "notificationOutput.getTarget": {
87926
- capName: "notification-output",
87927
- capScope: "system",
87928
- addonId: null,
87929
- access: "view",
87930
- role: "admin"
87931
- },
87932
87976
  "notificationOutput.listTargetKinds": {
87933
87977
  capName: "notification-output",
87934
87978
  capScope: "system",
@@ -87936,13 +87980,6 @@ Object.freeze({
87936
87980
  access: "view",
87937
87981
  role: "admin"
87938
87982
  },
87939
- "notificationOutput.listTargets": {
87940
- capName: "notification-output",
87941
- capScope: "system",
87942
- addonId: null,
87943
- access: "view",
87944
- role: "admin"
87945
- },
87946
87983
  "notificationOutput.probeTargetConfig": {
87947
87984
  capName: "notification-output",
87948
87985
  capScope: "system",
@@ -87957,13 +87994,6 @@ Object.freeze({
87957
87994
  access: "create",
87958
87995
  role: "admin"
87959
87996
  },
87960
- "notificationOutput.setTargetEnabled": {
87961
- capName: "notification-output",
87962
- capScope: "system",
87963
- addonId: null,
87964
- access: "create",
87965
- role: "admin"
87966
- },
87967
87997
  "notificationOutput.testTarget": {
87968
87998
  capName: "notification-output",
87969
87999
  capScope: "system",
@@ -87971,13 +88001,6 @@ Object.freeze({
87971
88001
  access: "create",
87972
88002
  role: "admin"
87973
88003
  },
87974
- "notificationOutput.upsertTarget": {
87975
- capName: "notification-output",
87976
- capScope: "system",
87977
- addonId: null,
87978
- access: "create",
87979
- role: "admin"
87980
- },
87981
88004
  "notificationRules.activateAlarmProfile": {
87982
88005
  capName: "notification-rules",
87983
88006
  capScope: "system",
@@ -88237,41 +88260,6 @@ Object.freeze({
88237
88260
  access: "view",
88238
88261
  role: "admin"
88239
88262
  },
88240
- "oidcConnections.connectionFormSchema": {
88241
- capName: "oidc-connections",
88242
- capScope: "system",
88243
- addonId: null,
88244
- access: "view",
88245
- role: "admin"
88246
- },
88247
- "oidcConnections.createConnection": {
88248
- capName: "oidc-connections",
88249
- capScope: "system",
88250
- addonId: null,
88251
- access: "create",
88252
- role: "admin"
88253
- },
88254
- "oidcConnections.deleteConnection": {
88255
- capName: "oidc-connections",
88256
- capScope: "system",
88257
- addonId: null,
88258
- access: "delete",
88259
- role: "admin"
88260
- },
88261
- "oidcConnections.listConnections": {
88262
- capName: "oidc-connections",
88263
- capScope: "system",
88264
- addonId: null,
88265
- access: "view",
88266
- role: "admin"
88267
- },
88268
- "oidcConnections.updateConnection": {
88269
- capName: "oidc-connections",
88270
- capScope: "system",
88271
- addonId: null,
88272
- access: "create",
88273
- role: "admin"
88274
- },
88275
88263
  "osd.getStatus": {
88276
88264
  capName: "osd",
88277
88265
  capScope: "device",
@@ -91303,13 +91291,6 @@ Object.freeze({
91303
91291
  access: "delete",
91304
91292
  role: "admin"
91305
91293
  },
91306
- "storage.deleteLocation": {
91307
- capName: "storage",
91308
- capScope: "system",
91309
- addonId: null,
91310
- access: "delete",
91311
- role: "admin"
91312
- },
91313
91294
  "storage.endDownload": {
91314
91295
  capName: "storage",
91315
91296
  capScope: "system",
@@ -91366,13 +91347,6 @@ Object.freeze({
91366
91347
  access: "view",
91367
91348
  role: "admin"
91368
91349
  },
91369
- "storage.listProviders": {
91370
- capName: "storage",
91371
- capScope: "system",
91372
- addonId: null,
91373
- access: "view",
91374
- role: "admin"
91375
- },
91376
91350
  "storage.read": {
91377
91351
  capName: "storage",
91378
91352
  capScope: "system",
@@ -91394,27 +91368,6 @@ Object.freeze({
91394
91368
  access: "view",
91395
91369
  role: "admin"
91396
91370
  },
91397
- "storage.testConfig": {
91398
- capName: "storage",
91399
- capScope: "system",
91400
- addonId: null,
91401
- access: "view",
91402
- role: "admin"
91403
- },
91404
- "storage.testLocation": {
91405
- capName: "storage",
91406
- capScope: "system",
91407
- addonId: null,
91408
- access: "view",
91409
- role: "admin"
91410
- },
91411
- "storage.upsertLocation": {
91412
- capName: "storage",
91413
- capScope: "system",
91414
- addonId: null,
91415
- access: "create",
91416
- role: "admin"
91417
- },
91418
91371
  "storage.write": {
91419
91372
  capName: "storage",
91420
91373
  capScope: "system",
@@ -92192,27 +92145,6 @@ Object.freeze({
92192
92145
  access: "create",
92193
92146
  role: "admin"
92194
92147
  },
92195
- "terminalSession.createInstance": {
92196
- capName: "terminal-session",
92197
- capScope: "system",
92198
- addonId: null,
92199
- access: "create",
92200
- role: "admin"
92201
- },
92202
- "terminalSession.deleteInstance": {
92203
- capName: "terminal-session",
92204
- capScope: "system",
92205
- addonId: null,
92206
- access: "delete",
92207
- role: "admin"
92208
- },
92209
- "terminalSession.listInstances": {
92210
- capName: "terminal-session",
92211
- capScope: "system",
92212
- addonId: null,
92213
- access: "view",
92214
- role: "admin"
92215
- },
92216
92148
  "terminalSession.listLegacyCameras": {
92217
92149
  capName: "terminal-session",
92218
92150
  capScope: "system",
@@ -92255,20 +92187,6 @@ Object.freeze({
92255
92187
  access: "create",
92256
92188
  role: "admin"
92257
92189
  },
92258
- "terminalSession.setInstanceEnabled": {
92259
- capName: "terminal-session",
92260
- capScope: "system",
92261
- addonId: null,
92262
- access: "create",
92263
- role: "admin"
92264
- },
92265
- "terminalSession.updateInstance": {
92266
- capName: "terminal-session",
92267
- capScope: "system",
92268
- addonId: null,
92269
- access: "create",
92270
- role: "admin"
92271
- },
92272
92190
  "terminalSession.writeInput": {
92273
92191
  capName: "terminal-session",
92274
92192
  capScope: "system",
@@ -92283,6 +92201,13 @@ Object.freeze({
92283
92201
  access: "create",
92284
92202
  role: "viewer"
92285
92203
  },
92204
+ "timedRun.getOptions": {
92205
+ capName: "timed-run",
92206
+ capScope: "device",
92207
+ addonId: null,
92208
+ access: "view",
92209
+ role: "viewer"
92210
+ },
92286
92211
  "timedRun.getStatus": {
92287
92212
  capName: "timed-run",
92288
92213
  capScope: "device",
@@ -92297,6 +92222,13 @@ Object.freeze({
92297
92222
  access: "create",
92298
92223
  role: "viewer"
92299
92224
  },
92225
+ "timedRun.setSettings": {
92226
+ capName: "timed-run",
92227
+ capScope: "device",
92228
+ addonId: null,
92229
+ access: "create",
92230
+ role: "admin"
92231
+ },
92300
92232
  "toast.onToast": {
92301
92233
  capName: "toast",
92302
92234
  capScope: "system",
@@ -93227,6 +93159,7 @@ function offered(received) {
93227
93159
  };
93228
93160
  }
93229
93161
  offered(HA_AS), withheld(HOMEKIT_REASON), withheld(ALEXA_REASON), withheld(GOOGLE_REASON), withheld(MATTER_REASON);
93162
+ string().min(1).max(4096);
93230
93163
  Object.freeze({
93231
93164
  "accessories.getStatus": [{
93232
93165
  name: "deviceId",
@@ -93910,6 +93843,11 @@ Object.freeze({
93910
93843
  form: "single",
93911
93844
  optional: false
93912
93845
  }],
93846
+ "deviceManager.setAlias": [{
93847
+ name: "deviceId",
93848
+ form: "single",
93849
+ optional: false
93850
+ }],
93913
93851
  "deviceManager.setChildLayout": [{
93914
93852
  name: "deviceId",
93915
93853
  form: "single",
@@ -95974,6 +95912,11 @@ Object.freeze({
95974
95912
  form: "single",
95975
95913
  optional: false
95976
95914
  }],
95915
+ "timedRun.getOptions": [{
95916
+ name: "deviceId",
95917
+ form: "single",
95918
+ optional: false
95919
+ }],
95977
95920
  "timedRun.getStatus": [{
95978
95921
  name: "deviceId",
95979
95922
  form: "single",
@@ -95984,6 +95927,11 @@ Object.freeze({
95984
95927
  form: "single",
95985
95928
  optional: false
95986
95929
  }],
95930
+ "timedRun.setSettings": [{
95931
+ name: "deviceId",
95932
+ form: "single",
95933
+ optional: false
95934
+ }],
95987
95935
  "update.getStatus": [{
95988
95936
  name: "deviceId",
95989
95937
  form: "single",
@@ -96846,6 +96794,7 @@ var STATE_SUMMARY_VARS = [
96846
96794
  [...RULE_TEXT],
96847
96795
  [...RULE_TEXT],
96848
96796
  [...RULE_TEXT],
96797
+ [...RULE_TEXT],
96849
96798
  [...RULE_BODY_ONLY],
96850
96799
  [...RULE_TEXT],
96851
96800
  ([...RULE_TEXT], [...DEVICE_EVENTS]),
@@ -122137,7 +122086,13 @@ function buildHomematicInstances(records, deps) {
122137
122086
  },
122138
122087
  instanceMode: "multiple",
122139
122088
  kind: "connection",
122140
- canTest: true
122089
+ canTest: true,
122090
+ kinds: [{
122091
+ id: "connection",
122092
+ label: "Homematic",
122093
+ functionCap: "device-provider",
122094
+ role: "devices"
122095
+ }]
122141
122096
  },
122142
122097
  formSchema: () => buildConnectionFormSchema(),
122143
122098
  initialBody: (name) => ({ name }),