@camstack/addon-export-google 0.1.130 → 0.1.132

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.
@@ -877,7 +877,7 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
877
877
  return EventCategory;
878
878
  }({});
879
879
  //#endregion
880
- //#region ../types/dist/device-type-D1fH5kaC.mjs
880
+ //#region ../types/dist/device-type-DxCT0krO.mjs
881
881
  /**
882
882
  import { errMsg } from '@camstack/types'
883
883
  * Extract a human-readable message from an unknown error value.
@@ -1039,6 +1039,13 @@ var DeviceFeature = /* @__PURE__ */ function(DeviceFeature) {
1039
1039
  * filters that want "all devices with on-motion behaviour".
1040
1040
  */
1041
1041
  DeviceFeature["MotionTrigger"] = "motion-trigger";
1042
+ /**
1043
+ * Device can be run for a chosen time and then stopped. Mirrors the
1044
+ * `timed-run` wrapper cap — the cap is bound by the core-blocks addon, not by
1045
+ * a driver, so the flag is derived from the device's bindings
1046
+ * (`featuresOfBoundCaps`). Gates the quick-run control in the viewer.
1047
+ */
1048
+ DeviceFeature["TimedRun"] = "timed-run";
1042
1049
  /** Light supports rgb-triplet color via `color` cap. */
1043
1050
  DeviceFeature["LightColorRgb"] = "light-color-rgb";
1044
1051
  /** Light supports HSV color via `color` cap. */
@@ -6073,7 +6080,7 @@ var ZodIssueCode = {
6073
6080
  var ZodFirstPartyTypeKind;
6074
6081
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
6075
6082
  //#endregion
6076
- //#region ../types/dist/sleep-AEnTN3b4.mjs
6083
+ //#region ../types/dist/sleep-CGPZyzB5.mjs
6077
6084
  /**
6078
6085
  * The audio chunk plane's byte format, and the ONE expansion from a coded
6079
6086
  * window to float samples (D455).
@@ -6437,6 +6444,59 @@ Object.fromEntries([
6437
6444
  function isValuelessField(field) {
6438
6445
  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";
6439
6446
  }
6447
+ /**
6448
+ * Base collector: flatten a hydrated `ConfigUISchemaWithValues` into
6449
+ * `key → { value, default }`, recursing through `group` and `sub-tabs`
6450
+ * layout fields. Keeping `value` and `default` SEPARATE (rather than
6451
+ * pre-resolving) lets callers both read the effective value AND detect
6452
+ * overrides (`value` differs from `default`). Structural over `unknown`;
6453
+ * malformed input yields an empty map, never throws.
6454
+ */
6455
+ function collectHydratedFieldEntries(schema) {
6456
+ const out = /* @__PURE__ */ new Map();
6457
+ if (typeof schema !== "object" || schema === null) return out;
6458
+ const sections = schema.sections;
6459
+ if (!Array.isArray(sections)) return out;
6460
+ for (const section of sections) if (typeof section === "object" && section !== null) collectFieldEntriesInto(section.fields, out);
6461
+ return out;
6462
+ }
6463
+ /** Recursive field walker for {@link collectHydratedFieldEntries}. */
6464
+ function collectFieldEntriesInto(fields, into) {
6465
+ if (!Array.isArray(fields)) return;
6466
+ for (const field of fields) {
6467
+ if (typeof field !== "object" || field === null) continue;
6468
+ const type = field.type;
6469
+ if (type === "group") {
6470
+ collectFieldEntriesInto(field.fields, into);
6471
+ continue;
6472
+ }
6473
+ if (type === "sub-tabs") {
6474
+ const tabs = field.tabs;
6475
+ if (Array.isArray(tabs)) {
6476
+ for (const tab of tabs) if (typeof tab === "object" && tab !== null) collectFieldEntriesInto(tab.fields, into);
6477
+ }
6478
+ continue;
6479
+ }
6480
+ const key = field.key;
6481
+ if (typeof key !== "string" || key.length === 0) continue;
6482
+ if (!("value" in field)) continue;
6483
+ into.set(key, {
6484
+ value: field.value,
6485
+ default: field.default
6486
+ });
6487
+ }
6488
+ }
6489
+ /**
6490
+ * Flatten a hydrated settings payload into `key → EFFECTIVE value`
6491
+ * (`value ?? default`). The read-side inverse of `hydrateSchema` for the
6492
+ * common "just give me the resolved values" case. Built on
6493
+ * {@link collectHydratedFieldEntries}.
6494
+ */
6495
+ function collectHydratedFieldValues(schema) {
6496
+ const out = /* @__PURE__ */ new Map();
6497
+ for (const [key, entry] of collectHydratedFieldEntries(schema)) out.set(key, entry.value ?? entry.default);
6498
+ return out;
6499
+ }
6440
6500
  function hydrateSchema(schema, values, options = {}) {
6441
6501
  return {
6442
6502
  ...schema.tabs ? { tabs: [...schema.tabs] } : {},
@@ -7236,6 +7296,7 @@ var RecordIntegrationInstances = class {
7236
7296
  this.secretKeys = topLevelSecretKeys(kind.declaration.secretPaths);
7237
7297
  this.secretMaps = secretMapKeys(kind.declaration.secretPaths);
7238
7298
  this.nameField = kind.declaration.entry?.nameField ?? "name";
7299
+ 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`);
7239
7300
  }
7240
7301
  /**
7241
7302
  * One instance read for the addon's own runtime; null when absent. When the keychain is
@@ -7277,10 +7338,21 @@ var RecordIntegrationInstances = class {
7277
7338
  }
7278
7339
  return out;
7279
7340
  }
7341
+ /** The kind an instance body is of: the provider's `kindOf`, else its one declared kind. */
7342
+ kindOfBody(body) {
7343
+ if (this.hooks.kindOf !== void 0) {
7344
+ const id = this.hooks.kindOf(body);
7345
+ 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)`);
7346
+ return id;
7347
+ }
7348
+ const only = this.hooks.description.kinds[0];
7349
+ if (only === void 0) throw new Error(`record kind '${this.kind.name}' declares no kinds`);
7350
+ return only.id;
7351
+ }
7280
7352
  viewOf(record) {
7281
7353
  const shown = secretViewsOf(this.records.owner, this.kind.name, record.id, this.kind.declaration, record.data);
7282
7354
  const rawName = record.data[this.nameField];
7283
- const kind = this.hooks.kindOf?.(record.data);
7355
+ const kind = this.kindOfBody(record.data);
7284
7356
  const health = this.hooks.health?.(record.data, record.id);
7285
7357
  return {
7286
7358
  id: record.id,
@@ -7288,7 +7360,7 @@ var RecordIntegrationInstances = class {
7288
7360
  configured: this.hooks.configured(record.data),
7289
7361
  enabled: isInstanceEnabled(record.data),
7290
7362
  formValues: shown,
7291
- ...kind !== void 0 ? { kind } : {},
7363
+ kind,
7292
7364
  ...health?.status !== void 0 ? { status: health.status } : {},
7293
7365
  ...health?.lastCheckedAt !== void 0 ? { lastCheckedAt: health.lastCheckedAt } : {}
7294
7366
  };
@@ -7660,6 +7732,21 @@ var SCOPED_SETTINGS_SCOPES = [
7660
7732
  "device-defaults",
7661
7733
  "node"
7662
7734
  ];
7735
+ /** The one refusal of a key a scope did not declare. */
7736
+ function assertDeclaredKeys(keys, declared) {
7737
+ const undeclared = keys.filter((key) => !declared.has(key));
7738
+ if (undeclared.length > 0) throw new Error(`scoped settings: [${undeclared.join(", ")}] not declared for this scope (declared: [${[...declared].join(", ")}])`);
7739
+ }
7740
+ /** Build the handle over an addon's scoped read, write and unset. */
7741
+ function createScopedSettings(deps) {
7742
+ return {
7743
+ async get() {
7744
+ return deps.schema.parse(await deps.read());
7745
+ },
7746
+ patch: (patch) => deps.write(Object.fromEntries(Object.entries(patch))),
7747
+ unset: (keys) => deps.unset(keys)
7748
+ };
7749
+ }
7663
7750
  /** A write to a secret path could not be stored in the keychain, so it was refused. */
7664
7751
  var KeychainWriteRefusedError = class extends Error {
7665
7752
  fieldPath;
@@ -8235,7 +8322,16 @@ function createHandle(raw, opts) {
8235
8322
  return blob;
8236
8323
  }
8237
8324
  },
8238
- writeAddonStore: writeAddon
8325
+ writeAddonStore: writeAddon,
8326
+ removeClearedKeys: (keys) => serialize("addon", async () => {
8327
+ const stored = await readStoredAddonBlob(raw);
8328
+ index.seen("addon", stored);
8329
+ const removable = keys.filter((key) => collectSecretMarkerRefs(stored[key]).length === 0);
8330
+ if (removable.length === 0) return;
8331
+ const patch = Object.fromEntries(removable.map((key) => [key, void 0]));
8332
+ await raw.writeAddonStore(patch);
8333
+ index.wrote("addon", patch);
8334
+ })
8239
8335
  };
8240
8336
  }
8241
8337
  /** The context the addon sees, plus the private raw view and write outcome. */
@@ -8365,7 +8461,7 @@ function boundOf(list) {
8365
8461
  * Base class for CamStack addons. Eliminates settings boilerplate:
8366
8462
  *
8367
8463
  * - Typed `config` property with automatic resolution from store + defaults
8368
- * - `getGlobalSettings()` / `updateGlobalSettings()` auto-implemented
8464
+ * - the scoped settings API (`clusterSettings` / `nodeSettings` / `deviceDefaults`) auto-implemented
8369
8465
  * - `getAddonSettings()` / `updateAddonSettings()` auto-implemented
8370
8466
  * - `getDeviceSettings()` / `updateDeviceSettings()` auto-implemented
8371
8467
  * - `ctx` accessor for the AddonContext (no manual `this.ctxRef` storage)
@@ -8375,7 +8471,7 @@ function boundOf(list) {
8375
8471
  * Subclasses override:
8376
8472
  * - `onInitialize()` — addon-specific init logic, return ProviderRegistration[]
8377
8473
  * - `onShutdown()` — cleanup
8378
- * - `globalSettingsSchema()` / `deviceSettingsSchema()` — UI schemas
8474
+ * - `clusterSettingsSchema()` / `nodeSettingsSchema()` / `deviceSettingsSchema()` — UI schemas
8379
8475
  *
8380
8476
  * @example
8381
8477
  * ```ts
@@ -8389,7 +8485,7 @@ function boundOf(list) {
8389
8485
  * super({ maxRetries: 3, endpoint: 'http://localhost' })
8390
8486
  * }
8391
8487
  *
8392
- * protected globalSettingsSchema() {
8488
+ * protected clusterSettingsSchema() {
8393
8489
  * return this.schema({
8394
8490
  * sections: [{
8395
8491
  * id: 'main', title: 'Settings',
@@ -8432,7 +8528,7 @@ var BaseAddon = class {
8432
8528
  defaults;
8433
8529
  /**
8434
8530
  * Hidden-state paths that hold secrets (D787) — values the addon writes
8435
- * itself (`updateGlobalSettings`, `state()`) that no form field declares.
8531
+ * itself (`state()`, the scoped writers) that no form field declares.
8436
8532
  * Stored in the keychain exactly like a `password` field. Syntax:
8437
8533
  * `'snapshotSigningKey'`, `'identity.pincode'`, `'tokens[userId].accessToken'`
8438
8534
  * (`key[<id field>]` addresses array items by id, never by index).
@@ -8442,7 +8538,7 @@ var BaseAddon = class {
8442
8538
  /**
8443
8539
  * D986 M4: the scoped schemas this addon declared, resolved once per capability
8444
8540
  * (`loadScopedSchemas`) so the sync readers (`perNodeKeys`, the secret tree, the restart check)
8445
- * see them. Empty until loaded: the readers then fall back to {@link globalSettingsSchema}.
8541
+ * see them. Empty until loaded.
8446
8542
  */
8447
8543
  _scopedByCap = /* @__PURE__ */ new Map();
8448
8544
  _nodeKeysByCap = /* @__PURE__ */ new Map();
@@ -8628,7 +8724,7 @@ var BaseAddon = class {
8628
8724
  /** Addon-specific cleanup. Override if needed. */
8629
8725
  async onShutdown() {}
8630
8726
  /**
8631
- * Called after config is resolved during updateGlobalSettings/updateAddonSettings.
8727
+ * Called after config is resolved during a settings write.
8632
8728
  * Override to react to config changes (e.g. restart a sampler, reconnect a service).
8633
8729
  * Not called during initialize() — use onInitialize() for initial setup.
8634
8730
  */
@@ -8657,82 +8753,12 @@ var BaseAddon = class {
8657
8753
  scopedSettingsCapabilities() {
8658
8754
  return [];
8659
8755
  }
8660
- /** Override to provide global-level settings UI schema. */
8661
- globalSettingsSchema(_cap) {
8662
- return null;
8663
- }
8664
8756
  /** Override to provide device-level settings UI schema. */
8665
8757
  deviceSettingsSchema() {
8666
8758
  return null;
8667
8759
  }
8668
8760
  /**
8669
- * INTEGRATION-LEVEL SETTINGS — declare which of this addon's global sections
8670
- * ARE the configuration of its integration.
8671
- *
8672
- * Return the `ConfigSection.id`s, from {@link globalSettingsSchema}, that an
8673
- * operator should find on the addon's integration page (System →
8674
- * Integrations → <name>) rather than only in the cluster-wide list of every
8675
- * addon. Empty (the default) means the addon has no integration-level
8676
- * settings and no such surface is offered — this is opt-in, because whether
8677
- * an addon's configuration IS its integration's configuration depends on the
8678
- * nature of the integration.
8679
- *
8680
- * WHAT THIS IS NOT. It is not a scope. The selected sections keep living in
8681
- * the ONE global schema, in the ONE addon store, written by the ONE
8682
- * `updateGlobalSettings` path. There is deliberately no
8683
- * `updateIntegrationSettings`: a second write path is how a surface acquires
8684
- * a second store key, and this repo has shipped that twice (`btmPath@hub`,
8685
- * D266). Selecting sections cannot introduce a key that selecting cannot.
8686
- *
8687
- * WHY IT IS A LIST OF SECTION IDS AND NOT A MARKER ON THE SECTION.
8688
- * `ConfigFieldBase` used to carry `scope?: 'device' | 'global'` and it was
8689
- * removed with the reason recorded at
8690
- * `packages/types/src/interfaces/config-ui.ts:249` — *"a field's scope is
8691
- * determined by WHICH schema it lives in, not by a field-level marker."* A
8692
- * marker sprinkled across sections also has to borrow a field that already
8693
- * means something else; borrowing `section.tab` put the literal word
8694
- * "integration" into an operator-facing tab bar, because `tab` means "how to
8695
- * GROUP this visually" and cannot also mean "where this lives" (D269
8696
- * supersedes D268). One declaration, in one place, next to the schema whose
8697
- * ids it names.
8698
- */
8699
- integrationSettingSections() {
8700
- return [];
8701
- }
8702
- async getGlobalSettings(overlay, cap, nodeId) {
8703
- await this.loadScopedSchemas(cap);
8704
- const schema = this.globalSettingsSchema(cap) ?? this.scopedFormSchema(cap);
8705
- if (!schema) return { sections: [] };
8706
- const projected = await this.readRawProjectedStore(nodeId, cap);
8707
- return hydrateSchema(schema, overlay ? await this.overlayKeepingMarkers(projected, overlay) : projected, { inlineSecretsAsViews: true });
8708
- }
8709
- /**
8710
- * The integration-level view of this addon's settings: exactly the sections
8711
- * named by {@link integrationSettingSections}, hydrated from the SAME store
8712
- * `getGlobalSettings` reads, and narrowed to cluster-scoped fields.
8713
- *
8714
- * Returns `null` when the addon declared nothing — an addon that opts out has
8715
- * no integration settings surface at all, rather than an empty one that reads
8716
- * as a failed load.
8717
- *
8718
- * Three properties hold BY CONSTRUCTION, which is why they are here in core
8719
- * and not in whichever UI happens to render this:
8720
- *
8721
- * 1. **One key.** The payload is a SUBSET of the global schema, so a field
8722
- * shown here is the same field, with the same bare key, that the addon's
8723
- * own page shows. There is no integration-specific writer — callers save
8724
- * through `updateGlobalSettings` — so a second store key is unreachable,
8725
- * not merely discouraged.
8726
- * 2. **No node scope.** `perNode: true` fields are DROPPED. Their store key
8727
- * is `<key>@<nodeId>` and an integration is not a node; whichever node
8728
- * such a field silently picked would be a wrong answer for the operator
8729
- * who opened the page (D266).
8730
- * 3. **No silent typo.** A declared id that names no section throws. The
8731
- * alternative — skip it — turns a rename into a surface that quietly
8732
- * empties, which looks exactly like an addon with nothing to configure.
8733
- */
8734
- /**
8735
- * The form schema of ONE integration instance, or `null` to use {@link globalSettingsSchema}.
8761
+ * The form schema of ONE integration instance, or `null` to use the scoped form.
8736
8762
  *
8737
8763
  * Override it only when an `instanceMode: multiple` addon's instances differ: an NVR integration
8738
8764
  * needs its connection fields, the default integration the addon's own sections. It is the
@@ -8780,37 +8806,178 @@ var BaseAddon = class {
8780
8806
  }
8781
8807
  }
8782
8808
  /**
8809
+ * Hook: values layered over the stored ones when the FORM of one scope is served
8810
+ * ({@link getScopedSettings}) — a preview that derives dependent options without writing.
8811
+ * Never applied to {@link ScopedSettings.get} or to a write. `null` ⇒ no overlay.
8812
+ */
8813
+ async scopedSettingsOverlay(_scope, _cap, _nodeId) {
8814
+ return null;
8815
+ }
8816
+ /**
8817
+ * Hook: a write of one scope changed stored values (not called when the store reports no change,
8818
+ * e.g. the write-back of a stored secret). `keys` are the bare field keys of the write, node keys included.
8819
+ */
8820
+ async onScopedSettingsChanged(_scope, _cap, _keys) {}
8821
+ /** Typed handle over the CLUSTER settings `cap` declares (`clusterSettingsSchema`). */
8822
+ clusterSettings(cap, schema) {
8823
+ return this.scopedHandle("cluster", cap, schema);
8824
+ }
8825
+ /** Typed handle over the fleet defaults of the per-device settings `cap` declares. */
8826
+ deviceDefaults(cap, schema) {
8827
+ return this.scopedHandle("device-defaults", cap, schema);
8828
+ }
8829
+ /**
8830
+ * Typed handle over the settings `cap` owns PER NODE. `nodeId` omitted ⇒ the local node. A node
8831
+ * with no row yields the schema defaults — never a bare-key fallback.
8832
+ */
8833
+ nodeSettings(cap, schema, nodeId) {
8834
+ return this.scopedHandle("node", cap, schema, nodeId);
8835
+ }
8836
+ /**
8837
+ * {@link state} for a value that is kept per node: stored under `<key>@<nodeId>`, and the
8838
+ * settings store carries `nodeId` in the row data (D986 §1), so a forgotten node's rows go in one
8839
+ * central delete. `nodeId` omitted ⇒ the local node.
8840
+ */
8841
+ nodeState(key, schema, fallback, nodeId) {
8842
+ this._declaredStateKeys.add(key);
8843
+ return createDurableState({
8844
+ key: nodeScopedKey(key, nodeId ?? this._ctx?.kernel?.localNodeId ?? ""),
8845
+ schema,
8846
+ fallback,
8847
+ read: async () => this.resolveStoredSecrets(await this.readAddonStoreWithRetry()),
8848
+ write: async (patch) => {
8849
+ await this._ctx?.settings?.writeAddonStore(patch);
8850
+ },
8851
+ onParseError: (k, e) => this._ctx?.logger?.warn?.(`durable-state: stored "${k}" failed validation — using fallback`, { meta: {
8852
+ addonId: this._ctx?.id,
8853
+ key: k,
8854
+ error: String(e)
8855
+ } })
8856
+ });
8857
+ }
8858
+ /** The loaded schema `cap` declares for `scope`, or `null`. */
8859
+ async declaredScopedSchema(scope, cap) {
8860
+ await this.loadScopedSchemas(cap);
8861
+ return this.loadedScopedSchemas(cap).find((entry) => entry.scope === scope)?.schema ?? null;
8862
+ }
8863
+ async requireScopedSchema(scope, cap) {
8864
+ const schema = await this.declaredScopedSchema(scope, cap);
8865
+ if (schema === null) throw new Error(`${this.constructor.name}: cap "${cap}" declares no ${scope} settings`);
8866
+ return schema;
8867
+ }
8868
+ scopedKeys(schema) {
8869
+ return new Set(schema.sections.flatMap((section) => collectValueFieldKeys(section.fields)));
8870
+ }
8871
+ /** `store` narrowed to the keys `schema` declares. */
8872
+ narrowToScope(store, schema) {
8873
+ const keys = this.scopedKeys(schema);
8874
+ return Object.fromEntries(Object.entries(store).filter(([key]) => keys.has(key)));
8875
+ }
8876
+ scopedHandle(scope, cap, schema, nodeId) {
8877
+ return createScopedSettings({
8878
+ schema,
8879
+ read: async () => {
8880
+ const declared = await this.requireScopedSchema(scope, cap);
8881
+ const stored = this.narrowToScope(await this.resolveGlobalStore(nodeId, cap), declared);
8882
+ const effective = collectHydratedFieldValues(hydrateSchema(declared, stored));
8883
+ return {
8884
+ ...Object.fromEntries([...effective].filter(([, value]) => value !== void 0)),
8885
+ ...stored
8886
+ };
8887
+ },
8888
+ write: (patch) => this.writeScoped(scope, cap, patch, nodeId),
8889
+ unset: (keys) => this.unsetScoped(scope, cap, keys, nodeId)
8890
+ });
8891
+ }
8892
+ /** The one write path of the scoped API: declared keys only, then the global patch. */
8893
+ async writeScoped(scope, cap, patch, nodeId) {
8894
+ assertDeclaredKeys(Object.keys(patch), this.scopedKeys(await this.requireScopedSchema(scope, cap)));
8895
+ if (await this.applyGlobalPatch(patch, scope === "node" ? nodeId : void 0, cap)) await this.onScopedSettingsChanged(scope, cap, Object.keys(patch));
8896
+ }
8897
+ /**
8898
+ * Remove declared keys of one scope. A secret goes through {@link clearSecrets} — its keychain
8899
+ * value is released exactly as there — and the emptied row is then removed; every other key is
8900
+ * removed by an `undefined` patch (which a secret transform would read as "keep").
8901
+ */
8902
+ async unsetScoped(scope, cap, keys, nodeId) {
8903
+ assertDeclaredKeys(keys, this.scopedKeys(await this.requireScopedSchema(scope, cap)));
8904
+ const target = scope === "node" ? nodeId : void 0;
8905
+ const tree = this.addonSecretTree();
8906
+ const secretKeys = keys.filter((key) => tree.has(key));
8907
+ const plainKeys = keys.filter((key) => !tree.has(key));
8908
+ let changed = false;
8909
+ if (plainKeys.length > 0) {
8910
+ const patch = Object.fromEntries(plainKeys.map((key) => [key, void 0]));
8911
+ changed = await this.applyGlobalPatch(patch, target, cap) || changed;
8912
+ }
8913
+ if (secretKeys.length > 0) {
8914
+ await this.clearSecretKeys(secretKeys, target, cap);
8915
+ const node = normalizeNodeId(target ?? this._ctx?.kernel?.localNodeId);
8916
+ const rows = secretKeys.map((key) => scope === "node" ? nodeScopedKey(key, node) : key);
8917
+ if (this._secretSettings !== null) await this._secretSettings.removeClearedKeys(rows);
8918
+ else await this._ctx?.settings?.writeAddonStore(Object.fromEntries(rows.map((row) => [row, void 0])));
8919
+ changed = true;
8920
+ }
8921
+ if (changed) await this.onScopedSettingsChanged(scope, cap, [...keys]);
8922
+ }
8923
+ /**
8924
+ * The hydrated form of one scope of one capability's settings (any
8925
+ * {@link scopedSettingsOverlay} applied), or `null` when the capability declares nothing there.
8926
+ */
8927
+ async getScopedSettings(scope, cap, nodeId) {
8928
+ const schema = await this.declaredScopedSchema(scope, cap);
8929
+ if (schema === null) return null;
8930
+ const stored = this.narrowToScope(await this.readRawProjectedStore(nodeId, cap), schema);
8931
+ const overlay = await this.scopedSettingsOverlay(scope, cap, nodeId);
8932
+ return hydrateSchema(schema, overlay ? await this.overlayKeepingMarkers(stored, overlay) : stored, { inlineSecretsAsViews: true });
8933
+ }
8934
+ /**
8935
+ * The scoped schemas this addon serves: one entry per loaded (capability, scope), capabilities
8936
+ * in declaration order, scopes in {@link SCOPED_SETTINGS_SCOPES} order. `[]` when it declares
8937
+ * nothing.
8938
+ */
8939
+ async listScopedSettings() {
8940
+ await this.loadScopedSchemas();
8941
+ return [...this._scopedByCap].flatMap(([cap, entries]) => entries.map((entry) => ({
8942
+ cap,
8943
+ scope: entry.scope,
8944
+ sectionIds: entry.schema.sections.map((section) => section.id)
8945
+ })));
8946
+ }
8947
+ /** The OPERATOR's write of declared keys of one scope (D787 secret semantics). */
8948
+ async updateScopedSettings(scope, cap, patch, nodeId) {
8949
+ this._operatorWriteDepth++;
8950
+ try {
8951
+ await this.writeScoped(scope, cap, patch, nodeId);
8952
+ } finally {
8953
+ this._operatorWriteDepth--;
8954
+ }
8955
+ }
8956
+ /**
8957
+ * The effective values (`stored ?? default`) of one scope, a secret as its `set` view — never
8958
+ * its value. `null` when the capability declares nothing for the scope.
8959
+ */
8960
+ async readScopedValues(scope, cap, nodeId) {
8961
+ const schema = await this.declaredScopedSchema(scope, cap);
8962
+ if (schema === null) return null;
8963
+ const form = hydrateSchema(schema, this.narrowToScope(await this.readRawProjectedStore(nodeId, cap), schema), { inlineSecretsAsViews: true });
8964
+ return Object.fromEntries([...collectHydratedFieldValues(form)].filter(([, value]) => value !== void 0));
8965
+ }
8966
+ /**
8783
8967
  * What the create wizard and the integration edit page render for one instance: the addon's
8784
8968
  * per-instance schema when it declares one, else its global schema (what they always showed).
8785
8969
  */
8786
8970
  async getIntegrationFormSchema(instance, nodeId) {
8787
8971
  const scoped = await this.integrationFormSchema(instance);
8788
- if (scoped === null) return this.getGlobalSettings(void 0, void 0, nodeId);
8972
+ if (scoped === null) return this.scopedForm(nodeId);
8789
8973
  return hydrateSchema(scoped, {}, { inlineSecretsAsViews: true });
8790
8974
  }
8791
- async getIntegrationSettings(nodeId) {
8792
- const declared = this.integrationSettingSections();
8793
- if (declared.length === 0) return null;
8794
- const schema = this.globalSettingsSchema();
8795
- if (!schema) throw new Error(`${this.constructor.name}: integrationSettingSections() names [${declared.join(", ")}] but globalSettingsSchema() returns null.`);
8796
- const byId = new Map(schema.sections.map((section) => [section.id, section]));
8797
- const sections = [];
8798
- for (const id of declared) {
8799
- const section = byId.get(id);
8800
- if (!section) throw new Error(`${this.constructor.name}: integrationSettingSections() names unknown section "${id}". Known sections: [${[...byId.keys()].join(", ")}].`);
8801
- const fields = dropPerNodeFields(section.fields);
8802
- if (fields.length === 0) continue;
8803
- sections.push({
8804
- ...section,
8805
- fields
8806
- });
8807
- }
8808
- if (sections.length === 0) return null;
8809
- const projected = await this.readRawProjectedStore(nodeId);
8810
- return hydrateSchema({
8811
- ...schema,
8812
- sections
8813
- }, projected, { inlineSecretsAsViews: true });
8975
+ /** The form of the scoped schemas this addon declared, hydrated from its store. */
8976
+ async scopedForm(nodeId) {
8977
+ await this.loadScopedSchemas();
8978
+ const schema = this.scopedFormSchema();
8979
+ if (!schema) return { sections: [] };
8980
+ return hydrateSchema(schema, await this.readRawProjectedStore(nodeId), { inlineSecretsAsViews: true });
8814
8981
  }
8815
8982
  /**
8816
8983
  * The raw addon store PROJECTED onto the target node's bare per-node keys:
@@ -8819,8 +8986,8 @@ var BaseAddon = class {
8819
8986
  * bare fallback), all `@`-scoped and stray bare per-node keys are dropped.
8820
8987
  * A no-op passthrough when the schema declares no `perNode` field.
8821
8988
  *
8822
- * This is the sanctioned way for a `getGlobalSettings` OVERRIDE that needs
8823
- * the store for custom option logic (option narrowing, value snapping) to
8989
+ * This is the sanctioned way for an addon that needs
8990
+ * the store for custom logic (option narrowing, value snapping) to
8824
8991
  * read it per-node — never `ctx.settings.readAddonStore()` directly.
8825
8992
  * `nodeId` omitted ⇒ the local node (node-blind injection from ctx).
8826
8993
  *
@@ -8872,7 +9039,7 @@ var BaseAddon = class {
8872
9039
  }
8873
9040
  /**
8874
9041
  * Whether ONE global key of this addon's store was written, read three-way
8875
- * (D651). For a question a hydrated view cannot answer: `getGlobalSettings`
9042
+ * (D651). For a question a hydrated view cannot answer: a hydrated form
8876
9043
  * reports `value ?? default`, so "the operator chose the default" and "nobody
8877
9044
  * chose" look the same, and a failed read looks like both. A `perNode` key is
8878
9045
  * not supported here: its stored name is scoped.
@@ -8906,7 +9073,7 @@ var BaseAddon = class {
8906
9073
  }
8907
9074
  /**
8908
9075
  * The OPERATOR's write — a settings form or an admin API call, dispatched by
8909
- * the kernel. Identical to {@link updateGlobalSettings}, except that a secret
9076
+ * the kernel. The one in-process write of the addon blob that is not a scoped write; a secret
8910
9077
  * the operator sends is stored as sent even when it equals a pre-keychain
8911
9078
  * inline value: the operator re-entering a password is a change, an addon
8912
9079
  * writing back what it read is not (D787).
@@ -8919,9 +9086,6 @@ var BaseAddon = class {
8919
9086
  this._operatorWriteDepth--;
8920
9087
  }
8921
9088
  }
8922
- async updateGlobalSettings(patch, nodeId) {
8923
- await this.applyGlobalPatch(patch, nodeId);
8924
- }
8925
9089
  /**
8926
9090
  * REMOVE stored secrets — their keychain values and their markers (D787).
8927
9091
  *
@@ -8931,6 +9095,9 @@ var BaseAddon = class {
8931
9095
  * a keychain (an older kernel) it writes `''`, as such code always did.
8932
9096
  */
8933
9097
  async clearSecrets(keys, nodeId) {
9098
+ await this.clearSecretKeys(keys, nodeId);
9099
+ }
9100
+ async clearSecretKeys(keys, nodeId, cap) {
8934
9101
  const tree = this.addonSecretTree();
8935
9102
  const keychain = this._ctx?.secrets !== void 0;
8936
9103
  const stored = keychain ? await this.readAddonStoreWithRetry() : {};
@@ -8943,25 +9110,26 @@ var BaseAddon = class {
8943
9110
  const keychainStored = tree.has(key) || collectSecretMarkerRefs(stored[key]).length > 0;
8944
9111
  patch[key] = keychain && keychainStored ? SECRET_CLEAR : "";
8945
9112
  }
8946
- await this.applyGlobalPatch(patch, nodeId);
9113
+ await this.applyGlobalPatch(patch, nodeId, cap);
8947
9114
  }
8948
- async applyGlobalPatch(barePatch, nodeId) {
8949
- await this.loadScopedSchemas();
8950
- const keys = this.perNodeKeys();
9115
+ /** Resolves `true` when the write changed stored values. */
9116
+ async applyGlobalPatch(barePatch, nodeId, cap) {
9117
+ await this.loadScopedSchemas(cap);
9118
+ const keys = this.perNodeKeys(cap);
8951
9119
  const localNode = normalizeNodeId(this._ctx?.kernel?.localNodeId);
8952
9120
  const target = normalizeNodeId(nodeId ?? this._ctx?.kernel?.localNodeId);
8953
9121
  const scoped = keys.size > 0 ? scopePatch(barePatch, keys, target) : barePatch;
8954
9122
  const handle = this._secretSettings;
8955
9123
  if (handle !== null) {
8956
9124
  const { changed } = await handle.writeAddonStore(scoped);
8957
- if (!changed) return;
9125
+ if (!changed) return false;
8958
9126
  } else await this._ctx?.settings?.writeAddonStore(scoped);
8959
- if (target !== localNode) return;
9127
+ if (target !== localNode) return true;
8960
9128
  await this.resolveConfig();
8961
9129
  await this.onConfigChanged();
8962
9130
  this.emitLifecycle(EventCategory.AddonUpdated, { level: "global" });
8963
- const legacy = this.globalSettingsSchema();
8964
- this.maybeAutoRestart(Object.keys(barePatch), [...legacy === null ? [] : [legacy], ...this.loadedScopedSchemas().map((entry) => entry.schema)]);
9131
+ this.maybeAutoRestart(Object.keys(barePatch), this.loadedScopedSchemas().map((entry) => entry.schema));
9132
+ return true;
8965
9133
  }
8966
9134
  /**
8967
9135
  * The set of field keys the global settings schema declares `perNode: true`
@@ -8998,10 +9166,7 @@ var BaseAddon = class {
8998
9166
  this._nodeKeysByCap = /* @__PURE__ */ new Map();
8999
9167
  this._addonSecretTree = null;
9000
9168
  }
9001
- /**
9002
- * The form the settings API serves while an addon declares no {@link globalSettingsSchema}: the
9003
- * sections of its scoped schemas, so dropping the old hook does not blank the form.
9004
- */
9169
+ /** The form of an addon's scoped schemas: their sections, each shown once. */
9005
9170
  scopedFormSchema(cap) {
9006
9171
  const byId = /* @__PURE__ */ new Map();
9007
9172
  for (const entry of this.loadedScopedSchemas(cap)) for (const section of entry.schema.sections) if (!byId.has(section.id)) byId.set(section.id, section);
@@ -9013,8 +9178,7 @@ var BaseAddon = class {
9013
9178
  return [...this._scopedByCap.values()].flat();
9014
9179
  }
9015
9180
  /**
9016
- * The field keys that are stored per node: every field of a {@link nodeSettingsSchema}, plus
9017
- * the fields the legacy {@link globalSettingsSchema} still marks `perNode: true`. Derived once
9181
+ * The field keys that are stored per node: every field of a {@link nodeSettingsSchema}. Derived once
9018
9182
  * per `cap` argument and memoized (schemas are static declarations). Empty set ⇒ every
9019
9183
  * per-node code path is bypassed and the settings API behaves like the node-agnostic one.
9020
9184
  * Call {@link loadScopedSchemas} first (the async seams do).
@@ -9023,8 +9187,7 @@ var BaseAddon = class {
9023
9187
  const cacheKey = cap ?? "";
9024
9188
  const cached = this._nodeKeysByCap.get(cacheKey);
9025
9189
  if (cached) return cached;
9026
- const legacy = this.globalSettingsSchema(cap);
9027
- const keys = new Set(legacy ? legacy.sections.flatMap((section) => collectPerNodeFieldKeys(section.fields)) : []);
9190
+ const keys = /* @__PURE__ */ new Set();
9028
9191
  for (const { scope, schema } of this.loadedScopedSchemas(cap)) {
9029
9192
  if (scope !== "node") continue;
9030
9193
  for (const section of schema.sections) for (const key of collectValueFieldKeys(section.fields)) keys.add(key);
@@ -9242,8 +9405,6 @@ var BaseAddon = class {
9242
9405
  }
9243
9406
  declaredKeySet() {
9244
9407
  const keys = new Set(Object.keys(this.defaults));
9245
- const schema = this.globalSettingsSchema();
9246
- if (schema) for (const section of schema.sections) for (const key of collectFieldKeys(section.fields)) keys.add(key);
9247
9408
  for (const { schema: scoped } of this.loadedScopedSchemas()) for (const section of scoped.sections) for (const key of collectFieldKeys(section.fields)) keys.add(key);
9248
9409
  for (const key of this._declaredStateKeys) keys.add(key);
9249
9410
  for (const path of this.secretStatePaths) {
@@ -9341,7 +9502,7 @@ var BaseAddon = class {
9341
9502
  /** The addon store's secret tree: schema fields by TYPE, plus `secretStatePaths`. */
9342
9503
  addonSecretTree() {
9343
9504
  if (this._addonSecretTree === null) {
9344
- const tree = new Map(secretTreeFromSchema(this.globalSettingsSchema()));
9505
+ const tree = /* @__PURE__ */ new Map();
9345
9506
  for (const { schema } of this.loadedScopedSchemas()) for (const [key, node] of secretTreeFromSchema(schema)) tree.set(key, node);
9346
9507
  this._addonSecretTree = mergeSecretStatePaths(tree, this.secretStatePaths);
9347
9508
  }
@@ -9553,47 +9714,6 @@ function classifyStoreError(err) {
9553
9714
  if (TRANSPORT_PHRASES.some((f) => message.includes(f))) return "transport";
9554
9715
  return "permanent";
9555
9716
  }
9556
- /**
9557
- * Collect the keys of every field marked `perNode: true`, recursing into
9558
- * layout containers (`group` fields and `sub-tabs` tabs) the same way
9559
- * `hydrateSchema` does. Valueless structural fields (separator/info/…)
9560
- * don't declare `perNode` and are excluded by the `in` narrowing.
9561
- */
9562
- /**
9563
- * The same fields with every `perNode: true` one removed, recursing into layout
9564
- * containers exactly as {@link collectPerNodeFieldKeys} does. A container left
9565
- * with no child is dropped rather than rendered empty.
9566
- *
9567
- * Used by `getIntegrationSettings`: an integration is not a node, so a field
9568
- * whose store key is `<key>@<nodeId>` has no node to belong to there.
9569
- */
9570
- function dropPerNodeFields(fields) {
9571
- const kept = [];
9572
- for (const field of fields) {
9573
- if (field.type === "group") {
9574
- const inner = dropPerNodeFields(field.fields);
9575
- if (inner.length > 0) kept.push({
9576
- ...field,
9577
- fields: inner
9578
- });
9579
- continue;
9580
- }
9581
- if (field.type === "sub-tabs") {
9582
- const tabs = field.tabs.map((tab) => ({
9583
- ...tab,
9584
- fields: dropPerNodeFields(tab.fields)
9585
- })).filter((tab) => tab.fields.length > 0);
9586
- if (tabs.length > 0) kept.push({
9587
- ...field,
9588
- tabs
9589
- });
9590
- continue;
9591
- }
9592
- if ("perNode" in field && field.perNode === true) continue;
9593
- kept.push(field);
9594
- }
9595
- return kept;
9596
- }
9597
9717
  /** The keys of the value-holding fields, recursing into layout containers. */
9598
9718
  function collectValueFieldKeys(fields) {
9599
9719
  const collected = [];
@@ -9626,21 +9746,6 @@ function collectFieldKeys(fields) {
9626
9746
  }
9627
9747
  return collected;
9628
9748
  }
9629
- function collectPerNodeFieldKeys(fields) {
9630
- const collected = [];
9631
- for (const field of fields) {
9632
- if (field.type === "group") {
9633
- collected.push(...collectPerNodeFieldKeys(field.fields));
9634
- continue;
9635
- }
9636
- if (field.type === "sub-tabs") {
9637
- for (const tab of field.tabs) collected.push(...collectPerNodeFieldKeys(tab.fields));
9638
- continue;
9639
- }
9640
- if ("perNode" in field && field.perNode === true) collected.push(field.key);
9641
- }
9642
- return collected;
9643
- }
9644
9749
  /**
9645
9750
  * Normalize an `ICamstackAddon.initialize()` return value into the
9646
9751
  * `AddonInitResult` envelope. Arrays are wrapped into `{ providers }`;
@@ -12382,13 +12487,25 @@ Object.freeze({
12382
12487
  "path": "temperature",
12383
12488
  "valueType": "number"
12384
12489
  }],
12385
- "timed-run": [{
12386
- "path": "activeUntil",
12387
- "valueType": "number"
12388
- }, {
12389
- "path": "requestedBy",
12390
- "valueType": "string"
12391
- }],
12490
+ "timed-run": [
12491
+ {
12492
+ "path": "activeUntil",
12493
+ "valueType": "number"
12494
+ },
12495
+ {
12496
+ "path": "requestedBy",
12497
+ "valueType": "string"
12498
+ },
12499
+ {
12500
+ "path": "quickRun.duration",
12501
+ "valueType": "number"
12502
+ },
12503
+ {
12504
+ "path": "quickRun.unit",
12505
+ "valueType": "enum",
12506
+ "enumValues": ["s", "min"]
12507
+ }
12508
+ ],
12392
12509
  "update": [
12393
12510
  {
12394
12511
  "path": "currentVersion",
@@ -12612,7 +12729,7 @@ object({
12612
12729
  params: record(string(), union([string(), number()])).optional()
12613
12730
  });
12614
12731
  //#endregion
12615
- //#region ../types/dist/composition-BmBHuDTQ.mjs
12732
+ //#region ../types/dist/composition-Bx0JvKUU.mjs
12616
12733
  /**
12617
12734
  * The ffmpeg build every CamStack node downloads, per platform and arch.
12618
12735
  *
@@ -13774,385 +13891,766 @@ var NodeColorIdSchema = _enum([
13774
13891
  "node-h"
13775
13892
  ]);
13776
13893
  //#endregion
13777
- //#region ../types/dist/index.mjs
13778
- var SMTP_INBOUND_DEFAULT_PORT = 2525;
13779
- var SMTP_INBOUND_DEFAULT_DOMAIN = "camstack.local";
13780
- var SMTP_INBOUND_DEFAULT_MAX_MESSAGE_BYTES = 25 * 1024 * 1024;
13781
- /** The text excerpt a message carries on the bus. */
13782
- var SMTP_INBOUND_TEXT_MAX_CHARS = 4096;
13783
- var PortSchema = number().int().min(1).max(65535);
13784
- /** A recipient local-part: what stands before the `@`. */
13785
- var SmtpRecipientSchema = string().min(1).max(64).regex(/^[A-Za-z0-9._+-]+$/);
13786
- object({
13787
- port: PortSchema.default(SMTP_INBOUND_DEFAULT_PORT),
13788
- bindHost: string().min(1).default("0.0.0.0"),
13789
- domain: string().min(1).default(SMTP_INBOUND_DEFAULT_DOMAIN),
13790
- requireAuth: boolean().default(true),
13791
- username: string().default(""),
13792
- password: string().default("").meta({ secret: true }),
13793
- starttls: boolean().default(false),
13794
- maxMessageBytes: number().int().positive().default(SMTP_INBOUND_DEFAULT_MAX_MESSAGE_BYTES)
13795
- });
13796
- object({
13797
- host: string().min(1).nullable(),
13798
- hostReason: string().nullable(),
13799
- port: PortSchema,
13800
- domain: string().min(1),
13801
- requireAuth: boolean(),
13802
- username: string(),
13803
- password: string(),
13804
- starttls: boolean()
13805
- });
13806
- object({
13807
- recipients: array(SmtpRecipientSchema).min(1),
13808
- /**
13809
- * Who is subscribing. A second `subscribe` with the same id REPLACES that subscriber's
13810
- * recipients (the way a consumer that restarted, or lost a device, declares its set again);
13811
- * a recipient held by another subscriber is refused with `smtp-inbound/recipient-claimed`.
13812
- * Absent, the subscriber is anonymous and unique.
13813
- */
13814
- subscriberId: string().min(1).max(64).optional()
13815
- });
13816
- var SmtpInboundAttachmentSchema = object({
13817
- filename: string(),
13818
- contentType: string(),
13819
- bytes: number().int().nonnegative()
13820
- });
13821
- /** The payload of one `broker.message` (the key is the recipient local-part). */
13822
- var SmtpInboundMessageSchema = object({
13823
- /** Monotonic per mailbox; a gap tells a consumer it missed an event. */
13824
- seq: number().int().positive(),
13825
- messageId: string(),
13826
- receivedAt: number().int().nonnegative(),
13827
- from: string(),
13828
- to: string(),
13829
- subject: string(),
13830
- text: string().max(SMTP_INBOUND_TEXT_MAX_CHARS),
13831
- attachments: array(SmtpInboundAttachmentSchema)
13832
- });
13833
- object({
13834
- /** The newest seq issued so far (0 before any mail). */
13835
- lastSeq: number().int().nonnegative(),
13836
- /** The oldest seq still retained; messages below it are gone. */
13837
- oldestSeq: number().int().nonnegative(),
13838
- messages: array(object({
13839
- key: string(),
13840
- message: SmtpInboundMessageSchema
13841
- }))
13842
- });
13843
- new Set([
13844
- "track",
13845
- "face",
13846
- "identity",
13847
- "plate",
13848
- "vehicle",
13849
- "scene",
13850
- "motion",
13851
- "object",
13852
- "audio",
13853
- "mosaic"
13854
- ]);
13855
- /**
13856
- * The owner types that are event tables, in the order the event-media resolver
13857
- * should consider them. Exported so a consumer asking "is this key an event?"
13858
- * does not re-spell the list and drift from it.
13859
- */
13860
- var EVENT_OWNER_TYPES = [
13861
- "motion",
13862
- "object",
13863
- "audio"
13864
- ];
13865
- /**
13866
- * The same list as a Zod enum, for the cap inputs that must NAME the table
13867
- * (D482: `getEventMedia` / `listEventMedia` take an owner, and an owner is
13868
- * `(table, id)`).
13869
- *
13870
- * Built FROM {@link EVENT_OWNER_TYPES} rather than re-spelled: a fourth event
13871
- * table would otherwise be accepted by the codec and refused at the door, with
13872
- * nothing failing until a caller asked.
13873
- */
13874
- var EventOwnerTypeSchema = _enum(EVENT_OWNER_TYPES);
13875
- /** The same list as a Zod enum, for the cap input that carries it. */
13876
- var MediaPresenceOwnerKindSchema = _enum([...EVENT_OWNER_TYPES, "track"]);
13877
- new Set(EVENT_OWNER_TYPES);
13878
- /**
13879
- * What a published package needs from the rest of the install (D989).
13880
- *
13881
- * One published framework package (`@camstack/server`) carries the kernel, the
13882
- * builtins and the capability contracts, so "which addon runs on which
13883
- * framework" is a question of version, and the answer is DECLARED by the
13884
- * package that knows it:
13885
- *
13886
- * - an addon says the oldest server it runs on (`requires.server: ">=X"`);
13887
- * - the server says the oldest addon it works with
13888
- * (`requires.addons: { "@camstack/addon-x": ">=Y" }`) and the oldest shell
13889
- * around it (`requires.wrapper: { desktop, image }`);
13890
- * - a wrapper (the desktop app, the container starter) says which server
13891
- * range it can host, and reports its own kind and version.
13892
- *
13893
- * The publish workflow STAMPS these after the version bump
13894
- * (`scripts/ci/stamp-requires.mjs`); nobody types a number by hand.
13895
- *
13896
- * A requirement that cannot be checked is NOT met: a shell that reports no
13897
- * version counts as below the minimum, and an unreadable running version is
13898
- * named in the result (a failed read is never a pass).
13899
- */
13900
- /** `>=MAJOR.MINOR.PATCH[-prerelease]` — the only range shape a requirement uses. */
13901
- var MinVersionSchema = string().regex(/^>=\d+\.\d+\.\d+(-[0-9A-Za-z.-]+)?$/, "a minimum is written \">=X.Y.Z\"");
13902
- object({
13903
- /** The oldest `@camstack/server` this package runs on. */
13904
- server: MinVersionSchema.optional(),
13905
- /** The oldest installed version of each named addon package. */
13906
- addons: record(string(), MinVersionSchema).optional(),
13907
- /** The oldest shell around the server, per shell kind. */
13908
- wrapper: object({
13909
- desktop: MinVersionSchema.optional(),
13910
- image: MinVersionSchema.optional()
13911
- }).optional()
13912
- });
13913
- /** One unmet requirement; each names the versions on both sides. */
13914
- var UnmetRequirementSchema = discriminatedUnion("kind", [
13915
- object({
13916
- kind: literal("server-too-old"),
13917
- required: string(),
13918
- /** `null` — the running server version could not be read. */
13919
- running: string().nullable()
13920
- }),
13921
- object({
13922
- kind: literal("addon-too-old"),
13923
- packageName: string(),
13924
- required: string(),
13925
- /** `null` — the addon is not installed (or its version is unreadable). */
13926
- running: string().nullable()
13927
- }),
13928
- object({
13929
- kind: literal("wrapper-too-old"),
13930
- wrapper: _enum(["desktop", "image"]),
13931
- required: string(),
13932
- /** `null` — the wrapper reported no version. */
13933
- running: string().nullable()
13934
- })
13935
- ]);
13936
- var RequiredAddonUpdateSchema = object({
13937
- packageName: string(),
13938
- /** The minimum the target server declares. */
13939
- required: string(),
13940
- /** What this node has; `null` when the addon is not installed. */
13941
- installed: string().nullable()
13942
- });
13943
- /**
13944
- * Which integration instance a settings form is for. An addon that serves several instances
13945
- * (`instanceMode: multiple`) can show a different form per instance — an NVR integration
13946
- * needs its connection, the default integration needs the addon's own sections.
13947
- *
13948
- * - `integrationId` is `null` in the create wizard: nothing exists yet, the operator is
13949
- * setting up a NEW instance.
13950
- * - `mode` is the wizard mode of the integration type (`getAvailableTypes`).
13951
- * - `candidateStableId` is the discovery candidate a wizard was seeded from, if any.
13952
- */
13953
- var IntegrationInstanceRefSchema = object({
13954
- integrationId: string().nullable(),
13955
- mode: _enum([
13956
- "standalone",
13957
- "account",
13958
- "broker"
13959
- ]),
13960
- candidateStableId: string().optional()
13961
- });
13962
- /**
13963
- * Build an `IAddonRouteProvider` from a list of routes. Implements
13964
- * both the operator-facing `getRoutes` (returning route descriptors
13965
- * minus the handlers, which can't cross JSON) and the framework-
13966
- * private `invoke` method that the hub calls when this provider lives
13967
- * in a forked worker.
13968
- *
13969
- * Co-located addons use the returned `getRoutes` directly because
13970
- * their handlers don't need to cross any wire. The `invoke` method
13971
- * is present anyway so the bridge code on the hub is uniform — it
13972
- * doesn't need to switch on "local vs remote provider" at the call
13973
- * site.
13974
- *
13975
- * Example:
13976
- * const routes: IAddonHttpRoute[] = [
13977
- * { method: 'GET', path: '/start', access: 'public', handler: this.handleStart },
13978
- * ]
13979
- * return [
13980
- * {
13981
- * capability: addonRoutesCapability,
13982
- * provider: buildAddonRouteProvider('auth-oidc', routes),
13983
- * },
13984
- * ]
13985
- */
13986
- function buildAddonRouteProvider(id, routes) {
13987
- return {
13988
- id,
13989
- getRoutes: () => routes,
13990
- invoke: async (input) => {
13991
- const match = matchRoute(routes, input.method, input.path);
13992
- if (!match) return {
13993
- status: 404,
13994
- headers: {},
13995
- redirectUrl: null,
13996
- body: { error: `No route matches ${input.method} ${input.path}` }
13997
- };
13998
- const envelope = {
13999
- status: 200,
14000
- headers: {},
14001
- redirectUrl: null
14002
- };
14003
- const reply = buildCapturingReply(envelope);
14004
- const request = {
14005
- params: {
14006
- ...match.params,
14007
- ...input.params
14008
- },
14009
- query: input.query,
14010
- body: input.body,
14011
- headers: input.headers,
14012
- ...input.user ? { user: input.user } : {},
14013
- ...input.scopedToken !== void 0 ? { scopedToken: input.scopedToken } : {}
14014
- };
14015
- await match.route.handler(request, reply);
14016
- return envelope;
14017
- }
14018
- };
14019
- }
14020
- /**
14021
- * Pattern matcher: same semantics as `AddonRouteRegistry.matchRoute`
14022
- * but operating on a flat list and bypassing the `/addon/<id>/` prefix
14023
- * — the bridge sends the post-prefix path directly so we don't need
14024
- * to round-trip it through normalization.
14025
- */
14026
- function matchRoute(routes, method, path) {
14027
- const normalizedMethod = method.toUpperCase();
14028
- for (const route of routes) {
14029
- if (route.method !== normalizedMethod) continue;
14030
- const params = matchPath(route.path, path);
14031
- if (params !== null) return {
14032
- route,
14033
- params
14034
- };
14035
- }
14036
- return null;
14037
- }
14038
- function matchPath(pattern, p) {
14039
- const patternParts = pattern.split("/").filter(Boolean);
14040
- const pathParts = p.split("/").filter(Boolean);
14041
- if (patternParts.length !== pathParts.length) return null;
14042
- const params = {};
14043
- for (let i = 0; i < patternParts.length; i++) {
14044
- const a = patternParts[i];
14045
- const b = pathParts[i];
14046
- if (a.startsWith(":")) params[a.slice(1)] = b;
14047
- else if (a !== b) return null;
14048
- }
14049
- return params;
14050
- }
14051
- function buildCapturingReply(envelope) {
14052
- const wrapper = {
14053
- status(code) {
14054
- envelope.status = code;
14055
- return wrapper;
14056
- },
14057
- code(code) {
14058
- envelope.status = code;
14059
- return wrapper;
14060
- },
14061
- send(data) {
14062
- envelope.body = data;
14063
- },
14064
- redirect(url) {
14065
- envelope.redirectUrl = url;
14066
- if (envelope.status === 200) envelope.status = 302;
14067
- },
14068
- header(name, value) {
14069
- envelope.headers[name.toLowerCase()] = value;
14070
- return wrapper;
14071
- },
14072
- type(mime) {
14073
- envelope.contentType = mime;
14074
- return wrapper;
14075
- }
14076
- };
14077
- return wrapper;
14078
- }
13894
+ //#region ../types/dist/convert-BAzH15HU.mjs
14079
13895
  /**
14080
- * notification-output — canonical, capability-gated notification delivery.
14081
- *
14082
- * Apprise-derived model (see
14083
- * `docs/superpowers/specs/2026-07-03-notification-output-notifier-matrix.md`):
14084
- * callers emit ONE canonical `Notification`; each provider declares a
14085
- * per-kind capability descriptor (`TargetKind`), and the pure degrade
14086
- * engine (`@camstack/types` `prepareNotification`) transcodes / degrades the
14087
- * message to what the kind supports — callers never special-case a service.
14088
- *
14089
- * DESIGN DECISIONS (locked):
14090
- * - A target is an INSTANCE of this function cap (epic #440, step 6): the
14091
- * providers serve their targets as `integration-instances` records, one
14092
- * record kind per target kind, and the admin lists, adds, edits, switches
14093
- * and deletes them through that cap. This cap keeps what an instance cannot
14094
- * say: the kind catalogue (`listTargetKinds`: capabilities, delivery
14095
- * parameters, brand icon), dispatch (`send`, `testTarget`) and the form
14096
- * helpers (`discoverTargets`, `probeTargetConfig`).
14097
- * - `listTargetKinds` / `discoverTargets` return arrays → the generated
14098
- * cap-mount auto-`concatCollection`-fans them across every registered
14099
- * provider so one catalog is routable. `send` / `testTarget` /
14100
- * `probeTargetConfig` route to ONE provider by the `addonId` the generated
14101
- * collection router extracts from the call input.
14102
- * - `Attachment.bytes` is `Uint8Array`. Transport-safe: superjson (the tRPC
14103
- * transformer) + UDS MsgPack both round-trip typed arrays — already used by
14104
- * `storage` / `storage-provider` / `recording` caps over the same path. No
14105
- * base64 fallback needed.
14106
- *
14107
- * TODO (deferred, closed-set change — separate decision): add
14108
- * `providerKind: 'notify'` so notification providers surface on the unified
14109
- * admin "Integrations" page.
13896
+ * Frozen unit → spec table. `•` in the doc marks each dimension's canonical
13897
+ * unit (`factor: 1, offset: 0`). °F derives from `°C = (°F − 32) × 5/9` ⇒
13898
+ * `factor = 5/9`, `offset = -160/9` (kept as exact expressions, not rounded
13899
+ * decimals). K derives from `°C = K − 273.15`.
14110
13900
  */
14111
- /**
14112
- * Zentik-derived typed-media enum — the superset across every kind. Each
14113
- * adapter picks what it supports and the degrade engine filters the rest.
13901
+ var UNIT_TABLE = {
13902
+ "°C": {
13903
+ dimension: "temperature",
13904
+ factor: 1,
13905
+ offset: 0
13906
+ },
13907
+ "°F": {
13908
+ dimension: "temperature",
13909
+ factor: 5 / 9,
13910
+ offset: -160 / 9
13911
+ },
13912
+ K: {
13913
+ dimension: "temperature",
13914
+ factor: 1,
13915
+ offset: -273.15
13916
+ },
13917
+ hPa: {
13918
+ dimension: "pressure",
13919
+ factor: 1,
13920
+ offset: 0
13921
+ },
13922
+ kPa: {
13923
+ dimension: "pressure",
13924
+ factor: 10,
13925
+ offset: 0
13926
+ },
13927
+ Pa: {
13928
+ dimension: "pressure",
13929
+ factor: .01,
13930
+ offset: 0
13931
+ },
13932
+ mbar: {
13933
+ dimension: "pressure",
13934
+ factor: 1,
13935
+ offset: 0
13936
+ },
13937
+ bar: {
13938
+ dimension: "pressure",
13939
+ factor: 1e3,
13940
+ offset: 0
13941
+ },
13942
+ inHg: {
13943
+ dimension: "pressure",
13944
+ factor: 33.8639,
13945
+ offset: 0
13946
+ },
13947
+ mmHg: {
13948
+ dimension: "pressure",
13949
+ factor: 1.33322,
13950
+ offset: 0
13951
+ },
13952
+ psi: {
13953
+ dimension: "pressure",
13954
+ factor: 68.9476,
13955
+ offset: 0
13956
+ },
13957
+ "m/s": {
13958
+ dimension: "speed",
13959
+ factor: 1,
13960
+ offset: 0
13961
+ },
13962
+ "km/h": {
13963
+ dimension: "speed",
13964
+ factor: 1 / 3.6,
13965
+ offset: 0
13966
+ },
13967
+ mph: {
13968
+ dimension: "speed",
13969
+ factor: .44704,
13970
+ offset: 0
13971
+ },
13972
+ kn: {
13973
+ dimension: "speed",
13974
+ factor: .514444,
13975
+ offset: 0
13976
+ },
13977
+ "mm/h": {
13978
+ dimension: "precipitation-rate",
13979
+ factor: 1,
13980
+ offset: 0
13981
+ },
13982
+ "in/h": {
13983
+ dimension: "precipitation-rate",
13984
+ factor: 25.4,
13985
+ offset: 0
13986
+ },
13987
+ m: {
13988
+ dimension: "length",
13989
+ factor: 1,
13990
+ offset: 0
13991
+ },
13992
+ mm: {
13993
+ dimension: "length",
13994
+ factor: .001,
13995
+ offset: 0
13996
+ },
13997
+ cm: {
13998
+ dimension: "length",
13999
+ factor: .01,
14000
+ offset: 0
14001
+ },
14002
+ km: {
14003
+ dimension: "length",
14004
+ factor: 1e3,
14005
+ offset: 0
14006
+ },
14007
+ in: {
14008
+ dimension: "length",
14009
+ factor: .0254,
14010
+ offset: 0
14011
+ },
14012
+ ft: {
14013
+ dimension: "length",
14014
+ factor: .3048,
14015
+ offset: 0
14016
+ },
14017
+ mi: {
14018
+ dimension: "length",
14019
+ factor: 1609.344,
14020
+ offset: 0
14021
+ },
14022
+ "m²": {
14023
+ dimension: "area",
14024
+ factor: 1,
14025
+ offset: 0
14026
+ },
14027
+ lx: {
14028
+ dimension: "illuminance",
14029
+ factor: 1,
14030
+ offset: 0
14031
+ },
14032
+ "W/m²": {
14033
+ dimension: "irradiance",
14034
+ factor: 1,
14035
+ offset: 0
14036
+ },
14037
+ W: {
14038
+ dimension: "power",
14039
+ factor: 1,
14040
+ offset: 0
14041
+ },
14042
+ kW: {
14043
+ dimension: "power",
14044
+ factor: 1e3,
14045
+ offset: 0
14046
+ },
14047
+ VA: {
14048
+ dimension: "apparent-power",
14049
+ factor: 1,
14050
+ offset: 0
14051
+ },
14052
+ Wh: {
14053
+ dimension: "energy",
14054
+ factor: 1,
14055
+ offset: 0
14056
+ },
14057
+ kWh: {
14058
+ dimension: "energy",
14059
+ factor: 1e3,
14060
+ offset: 0
14061
+ },
14062
+ MWh: {
14063
+ dimension: "energy",
14064
+ factor: 1e6,
14065
+ offset: 0
14066
+ },
14067
+ V: {
14068
+ dimension: "voltage",
14069
+ factor: 1,
14070
+ offset: 0
14071
+ },
14072
+ mV: {
14073
+ dimension: "voltage",
14074
+ factor: .001,
14075
+ offset: 0
14076
+ },
14077
+ A: {
14078
+ dimension: "current",
14079
+ factor: 1,
14080
+ offset: 0
14081
+ },
14082
+ mA: {
14083
+ dimension: "current",
14084
+ factor: .001,
14085
+ offset: 0
14086
+ },
14087
+ ppm: {
14088
+ dimension: "concentration-volume",
14089
+ factor: 1,
14090
+ offset: 0
14091
+ },
14092
+ ppb: {
14093
+ dimension: "concentration-volume",
14094
+ factor: .001,
14095
+ offset: 0
14096
+ },
14097
+ "µg/m³": {
14098
+ dimension: "concentration-mass",
14099
+ factor: 1,
14100
+ offset: 0
14101
+ },
14102
+ "mg/m³": {
14103
+ dimension: "concentration-mass",
14104
+ factor: 1e3,
14105
+ offset: 0
14106
+ },
14107
+ kg: {
14108
+ dimension: "mass",
14109
+ factor: 1,
14110
+ offset: 0
14111
+ },
14112
+ g: {
14113
+ dimension: "mass",
14114
+ factor: .001,
14115
+ offset: 0
14116
+ },
14117
+ lb: {
14118
+ dimension: "mass",
14119
+ factor: .453592,
14120
+ offset: 0
14121
+ },
14122
+ oz: {
14123
+ dimension: "mass",
14124
+ factor: .0283495,
14125
+ offset: 0
14126
+ },
14127
+ "%": {
14128
+ dimension: "percentage",
14129
+ factor: 1,
14130
+ offset: 0
14131
+ },
14132
+ L: {
14133
+ dimension: "volume",
14134
+ factor: 1,
14135
+ offset: 0
14136
+ },
14137
+ mL: {
14138
+ dimension: "volume",
14139
+ factor: .001,
14140
+ offset: 0
14141
+ },
14142
+ gal: {
14143
+ dimension: "volume",
14144
+ factor: 3.785411784,
14145
+ offset: 0
14146
+ },
14147
+ s: {
14148
+ dimension: "duration",
14149
+ factor: 1,
14150
+ offset: 0
14151
+ },
14152
+ ms: {
14153
+ dimension: "duration",
14154
+ factor: .001,
14155
+ offset: 0
14156
+ },
14157
+ min: {
14158
+ dimension: "duration",
14159
+ factor: 60,
14160
+ offset: 0
14161
+ },
14162
+ h: {
14163
+ dimension: "duration",
14164
+ factor: 3600,
14165
+ offset: 0
14166
+ },
14167
+ d: {
14168
+ dimension: "duration",
14169
+ factor: 86400,
14170
+ offset: 0
14171
+ },
14172
+ B: {
14173
+ dimension: "information",
14174
+ factor: 1,
14175
+ offset: 0
14176
+ },
14177
+ KiB: {
14178
+ dimension: "information",
14179
+ factor: 1024,
14180
+ offset: 0
14181
+ },
14182
+ MiB: {
14183
+ dimension: "information",
14184
+ factor: 1024 ** 2,
14185
+ offset: 0
14186
+ },
14187
+ GiB: {
14188
+ dimension: "information",
14189
+ factor: 1024 ** 3,
14190
+ offset: 0
14191
+ },
14192
+ TiB: {
14193
+ dimension: "information",
14194
+ factor: 1024 ** 4,
14195
+ offset: 0
14196
+ },
14197
+ kB: {
14198
+ dimension: "information",
14199
+ factor: 1e3,
14200
+ offset: 0
14201
+ },
14202
+ MB: {
14203
+ dimension: "information",
14204
+ factor: 1e6,
14205
+ offset: 0
14206
+ },
14207
+ GB: {
14208
+ dimension: "information",
14209
+ factor: 1e9,
14210
+ offset: 0
14211
+ },
14212
+ "°": {
14213
+ dimension: "angle",
14214
+ factor: 1,
14215
+ offset: 0
14216
+ },
14217
+ dBFS: {
14218
+ dimension: "sound-level",
14219
+ factor: 1,
14220
+ offset: 0
14221
+ },
14222
+ dBm: {
14223
+ dimension: "signal-level",
14224
+ factor: 1,
14225
+ offset: 0
14226
+ },
14227
+ mired: {
14228
+ dimension: "colour-temperature",
14229
+ factor: 1,
14230
+ offset: 0
14231
+ },
14232
+ kbps: {
14233
+ dimension: "bitrate",
14234
+ factor: 1,
14235
+ offset: 0
14236
+ },
14237
+ Mbps: {
14238
+ dimension: "bitrate",
14239
+ factor: 1e3,
14240
+ offset: 0
14241
+ },
14242
+ fps: {
14243
+ dimension: "rate",
14244
+ factor: 1,
14245
+ offset: 0
14246
+ }
14247
+ };
14248
+ /** Resolve a unit's `UnitSpec`, or `undefined` when the spelling is unknown. */
14249
+ function specFor(unit) {
14250
+ return Object.hasOwn(UNIT_TABLE, unit) ? UNIT_TABLE[unit] : void 0;
14251
+ }
14252
+ /** Value in `spec`'s unit → its dimension's canonical unit. */
14253
+ function toCanonical(value, spec) {
14254
+ return value * spec.factor + spec.offset;
14255
+ }
14256
+ /** Canonical-unit value → the unit described by `spec`. */
14257
+ function fromCanonical(canonical, spec) {
14258
+ return (canonical - spec.offset) / spec.factor;
14259
+ }
14260
+ /**
14261
+ * Graceful variant for the render path: returns the converted value, or
14262
+ * `undefined` when the conversion is refused (unknown unit / cross-dimension).
14263
+ * Never throws — a render caller falls back to the raw value + source unit.
14114
14264
  */
14115
- var AttachmentMediaTypeSchema = _enum([
14116
- "image",
14117
- "video",
14118
- "gif",
14265
+ function tryConvertUnit(value, from, to) {
14266
+ if (from === to) return value;
14267
+ const fromSpec = specFor(from);
14268
+ if (!fromSpec) return void 0;
14269
+ const toSpec = specFor(to);
14270
+ if (!toSpec) return void 0;
14271
+ if (fromSpec.dimension !== toSpec.dimension) return void 0;
14272
+ return fromCanonical(toCanonical(value, fromSpec), toSpec);
14273
+ }
14274
+ //#endregion
14275
+ //#region ../types/dist/index.mjs
14276
+ var SMTP_INBOUND_DEFAULT_PORT = 2525;
14277
+ var SMTP_INBOUND_DEFAULT_DOMAIN = "camstack.local";
14278
+ var SMTP_INBOUND_DEFAULT_MAX_MESSAGE_BYTES = 25 * 1024 * 1024;
14279
+ /** The text excerpt a message carries on the bus. */
14280
+ var SMTP_INBOUND_TEXT_MAX_CHARS = 4096;
14281
+ var PortSchema = number().int().min(1).max(65535);
14282
+ /** A recipient local-part: what stands before the `@`. */
14283
+ var SmtpRecipientSchema = string().min(1).max(64).regex(/^[A-Za-z0-9._+-]+$/);
14284
+ object({
14285
+ port: PortSchema.default(SMTP_INBOUND_DEFAULT_PORT),
14286
+ bindHost: string().min(1).default("0.0.0.0"),
14287
+ domain: string().min(1).default(SMTP_INBOUND_DEFAULT_DOMAIN),
14288
+ requireAuth: boolean().default(true),
14289
+ username: string().default(""),
14290
+ password: string().default("").meta({ secret: true }),
14291
+ starttls: boolean().default(false),
14292
+ maxMessageBytes: number().int().positive().default(SMTP_INBOUND_DEFAULT_MAX_MESSAGE_BYTES)
14293
+ });
14294
+ object({
14295
+ host: string().min(1).nullable(),
14296
+ hostReason: string().nullable(),
14297
+ port: PortSchema,
14298
+ domain: string().min(1),
14299
+ requireAuth: boolean(),
14300
+ username: string(),
14301
+ password: string(),
14302
+ starttls: boolean()
14303
+ });
14304
+ object({
14305
+ recipients: array(SmtpRecipientSchema).min(1),
14306
+ /**
14307
+ * Who is subscribing. A second `subscribe` with the same id REPLACES that subscriber's
14308
+ * recipients (the way a consumer that restarted, or lost a device, declares its set again);
14309
+ * a recipient held by another subscriber is refused with `smtp-inbound/recipient-claimed`.
14310
+ * Absent, the subscriber is anonymous and unique.
14311
+ */
14312
+ subscriberId: string().min(1).max(64).optional()
14313
+ });
14314
+ var SmtpInboundAttachmentSchema = object({
14315
+ filename: string(),
14316
+ contentType: string(),
14317
+ bytes: number().int().nonnegative()
14318
+ });
14319
+ /** The payload of one `broker.message` (the key is the recipient local-part). */
14320
+ var SmtpInboundMessageSchema = object({
14321
+ /** Monotonic per mailbox; a gap tells a consumer it missed an event. */
14322
+ seq: number().int().positive(),
14323
+ messageId: string(),
14324
+ receivedAt: number().int().nonnegative(),
14325
+ from: string(),
14326
+ to: string(),
14327
+ subject: string(),
14328
+ text: string().max(SMTP_INBOUND_TEXT_MAX_CHARS),
14329
+ attachments: array(SmtpInboundAttachmentSchema)
14330
+ });
14331
+ object({
14332
+ /** The newest seq issued so far (0 before any mail). */
14333
+ lastSeq: number().int().nonnegative(),
14334
+ /** The oldest seq still retained; messages below it are gone. */
14335
+ oldestSeq: number().int().nonnegative(),
14336
+ messages: array(object({
14337
+ key: string(),
14338
+ message: SmtpInboundMessageSchema
14339
+ }))
14340
+ });
14341
+ new Set([
14342
+ "track",
14343
+ "face",
14344
+ "identity",
14345
+ "plate",
14346
+ "vehicle",
14347
+ "scene",
14348
+ "motion",
14349
+ "object",
14119
14350
  "audio",
14120
- "icon"
14351
+ "mosaic"
14121
14352
  ]);
14122
14353
  /**
14123
- * A single attachment. Exactly one of `url` (remote source, most adapters
14124
- * prefer this) or `bytes` (inline source; required for Pushover-style
14125
- * bytes-only kinds) MUST be present — the degrade engine expresses a
14126
- * url→bytes fetch as a `needsFetch` directive the adapter executes.
14354
+ * The owner types that are event tables, in the order the event-media resolver
14355
+ * should consider them. Exported so a consumer asking "is this key an event?"
14356
+ * does not re-spell the list and drift from it.
14127
14357
  */
14128
- var AttachmentSchema = object({
14129
- mediaType: AttachmentMediaTypeSchema,
14130
- url: string().optional(),
14131
- bytes: _instanceof(Uint8Array).optional(),
14132
- mime: string().optional(),
14133
- name: string().optional()
14134
- }).refine((a) => a.url !== void 0 || a.bytes !== void 0, { message: "Attachment requires either `url` or `bytes`" });
14135
- var NotificationFormatSchema = _enum([
14136
- "text",
14137
- "markdown",
14138
- "html"
14139
- ]);
14358
+ var EVENT_OWNER_TYPES = [
14359
+ "motion",
14360
+ "object",
14361
+ "audio"
14362
+ ];
14140
14363
  /**
14141
- * The CLOSED icon vocabulary an action button may use.
14364
+ * The same list as a Zod enum, for the cap inputs that must NAME the table
14365
+ * (D482: `getEventMedia` / `listEventMedia` take an owner, and an owner is
14366
+ * `(table, id)`).
14142
14367
  *
14143
- * A closed set, not a free string, and that is the whole point: an arbitrary
14144
- * icon name is one that ntfy renders, zentik silently drops, and nobody
14145
- * notices — the same class of gap as a zone vocabulary nothing produced
14146
- * ([D35](../../../docs/decisions/adr-0035.md)). Every adapter maps this set or
14147
- * declares `actionIcons: false` and the degrade engine strips the field.
14368
+ * Built FROM {@link EVENT_OWNER_TYPES} rather than re-spelled: a fourth event
14369
+ * table would otherwise be accepted by the codec and refused at the door, with
14370
+ * nothing failing until a caller asked.
14371
+ */
14372
+ var EventOwnerTypeSchema = _enum(EVENT_OWNER_TYPES);
14373
+ /** The same list as a Zod enum, for the cap input that carries it. */
14374
+ var MediaPresenceOwnerKindSchema = _enum([...EVENT_OWNER_TYPES, "track"]);
14375
+ new Set(EVENT_OWNER_TYPES);
14376
+ /**
14377
+ * What a published package needs from the rest of the install (D989).
14148
14378
  *
14149
- * Named by INTENT, never by glyph. "check" would tie the vocabulary to one
14150
- * renderer's icon set; "acknowledge" survives an adapter that draws it
14151
- * differently.
14379
+ * One published framework package (`@camstack/server`) carries the kernel, the
14380
+ * builtins and the capability contracts, so "which addon runs on which
14381
+ * framework" is a question of version, and the answer is DECLARED by the
14382
+ * package that knows it:
14152
14383
  *
14153
- * ── A TOKEN IS NOT A WIRE VALUE ─────────────────────────────────────
14384
+ * - an addon says the oldest server it runs on (`requires.server: ">=X"`);
14385
+ * - the server says the oldest addon it works with
14386
+ * (`requires.addons: { "@camstack/addon-x": ">=Y" }`) and the oldest shell
14387
+ * around it (`requires.wrapper: { desktop, image }`);
14388
+ * - a wrapper (the desktop app, the container starter) says which server
14389
+ * range it can host, and reports its own kind and version.
14154
14390
  *
14155
- * These names are for US. **No adapter may forward one verbatim.** Each maps
14391
+ * The publish workflow STAMPS these after the version bump
14392
+ * (`scripts/ci/stamp-requires.mjs`); nobody types a number by hand.
14393
+ *
14394
+ * A requirement that cannot be checked is NOT met: a shell that reports no
14395
+ * version counts as below the minimum, and an unreadable running version is
14396
+ * named in the result (a failed read is never a pass).
14397
+ */
14398
+ /** `>=MAJOR.MINOR.PATCH[-prerelease]` — the only range shape a requirement uses. */
14399
+ var MinVersionSchema = string().regex(/^>=\d+\.\d+\.\d+(-[0-9A-Za-z.-]+)?$/, "a minimum is written \">=X.Y.Z\"");
14400
+ object({
14401
+ /** The oldest `@camstack/server` this package runs on. */
14402
+ server: MinVersionSchema.optional(),
14403
+ /** The oldest installed version of each named addon package. */
14404
+ addons: record(string(), MinVersionSchema).optional(),
14405
+ /** The oldest shell around the server, per shell kind. */
14406
+ wrapper: object({
14407
+ desktop: MinVersionSchema.optional(),
14408
+ image: MinVersionSchema.optional()
14409
+ }).optional()
14410
+ });
14411
+ /** One unmet requirement; each names the versions on both sides. */
14412
+ var UnmetRequirementSchema = discriminatedUnion("kind", [
14413
+ object({
14414
+ kind: literal("server-too-old"),
14415
+ required: string(),
14416
+ /** `null` — the running server version could not be read. */
14417
+ running: string().nullable()
14418
+ }),
14419
+ object({
14420
+ kind: literal("addon-too-old"),
14421
+ packageName: string(),
14422
+ required: string(),
14423
+ /** `null` — the addon is not installed (or its version is unreadable). */
14424
+ running: string().nullable()
14425
+ }),
14426
+ object({
14427
+ kind: literal("wrapper-too-old"),
14428
+ wrapper: _enum(["desktop", "image"]),
14429
+ required: string(),
14430
+ /** `null` — the wrapper reported no version. */
14431
+ running: string().nullable()
14432
+ })
14433
+ ]);
14434
+ var RequiredAddonUpdateSchema = object({
14435
+ packageName: string(),
14436
+ /** The minimum the target server declares. */
14437
+ required: string(),
14438
+ /** What this node has; `null` when the addon is not installed. */
14439
+ installed: string().nullable()
14440
+ });
14441
+ /**
14442
+ * Which integration instance a settings form is for. An addon that serves several instances
14443
+ * (`instanceMode: multiple`) can show a different form per instance — an NVR integration
14444
+ * needs its connection, the default integration needs the addon's own sections.
14445
+ *
14446
+ * - `integrationId` is `null` in the create wizard: nothing exists yet, the operator is
14447
+ * setting up a NEW instance.
14448
+ * - `mode` is the wizard mode of the integration type (`getAvailableTypes`).
14449
+ * - `candidateStableId` is the discovery candidate a wizard was seeded from, if any.
14450
+ */
14451
+ var IntegrationInstanceRefSchema = object({
14452
+ integrationId: string().nullable(),
14453
+ mode: _enum([
14454
+ "standalone",
14455
+ "account",
14456
+ "broker"
14457
+ ]),
14458
+ candidateStableId: string().optional()
14459
+ });
14460
+ /**
14461
+ * Build an `IAddonRouteProvider` from a list of routes. Implements
14462
+ * both the operator-facing `getRoutes` (returning route descriptors
14463
+ * minus the handlers, which can't cross JSON) and the framework-
14464
+ * private `invoke` method that the hub calls when this provider lives
14465
+ * in a forked worker.
14466
+ *
14467
+ * Co-located addons use the returned `getRoutes` directly because
14468
+ * their handlers don't need to cross any wire. The `invoke` method
14469
+ * is present anyway so the bridge code on the hub is uniform — it
14470
+ * doesn't need to switch on "local vs remote provider" at the call
14471
+ * site.
14472
+ *
14473
+ * Example:
14474
+ * const routes: IAddonHttpRoute[] = [
14475
+ * { method: 'GET', path: '/start', access: 'public', handler: this.handleStart },
14476
+ * ]
14477
+ * return [
14478
+ * {
14479
+ * capability: addonRoutesCapability,
14480
+ * provider: buildAddonRouteProvider('auth-oidc', routes),
14481
+ * },
14482
+ * ]
14483
+ */
14484
+ function buildAddonRouteProvider(id, routes) {
14485
+ return {
14486
+ id,
14487
+ getRoutes: () => routes,
14488
+ invoke: async (input) => {
14489
+ const match = matchRoute(routes, input.method, input.path);
14490
+ if (!match) return {
14491
+ status: 404,
14492
+ headers: {},
14493
+ redirectUrl: null,
14494
+ body: { error: `No route matches ${input.method} ${input.path}` }
14495
+ };
14496
+ const envelope = {
14497
+ status: 200,
14498
+ headers: {},
14499
+ redirectUrl: null
14500
+ };
14501
+ const reply = buildCapturingReply(envelope);
14502
+ const request = {
14503
+ params: {
14504
+ ...match.params,
14505
+ ...input.params
14506
+ },
14507
+ query: input.query,
14508
+ body: input.body,
14509
+ headers: input.headers,
14510
+ ...input.user ? { user: input.user } : {},
14511
+ ...input.scopedToken !== void 0 ? { scopedToken: input.scopedToken } : {}
14512
+ };
14513
+ await match.route.handler(request, reply);
14514
+ return envelope;
14515
+ }
14516
+ };
14517
+ }
14518
+ /**
14519
+ * Pattern matcher: same semantics as `AddonRouteRegistry.matchRoute`
14520
+ * but operating on a flat list and bypassing the `/addon/<id>/` prefix
14521
+ * — the bridge sends the post-prefix path directly so we don't need
14522
+ * to round-trip it through normalization.
14523
+ */
14524
+ function matchRoute(routes, method, path) {
14525
+ const normalizedMethod = method.toUpperCase();
14526
+ for (const route of routes) {
14527
+ if (route.method !== normalizedMethod) continue;
14528
+ const params = matchPath(route.path, path);
14529
+ if (params !== null) return {
14530
+ route,
14531
+ params
14532
+ };
14533
+ }
14534
+ return null;
14535
+ }
14536
+ function matchPath(pattern, p) {
14537
+ const patternParts = pattern.split("/").filter(Boolean);
14538
+ const pathParts = p.split("/").filter(Boolean);
14539
+ if (patternParts.length !== pathParts.length) return null;
14540
+ const params = {};
14541
+ for (let i = 0; i < patternParts.length; i++) {
14542
+ const a = patternParts[i];
14543
+ const b = pathParts[i];
14544
+ if (a.startsWith(":")) params[a.slice(1)] = b;
14545
+ else if (a !== b) return null;
14546
+ }
14547
+ return params;
14548
+ }
14549
+ function buildCapturingReply(envelope) {
14550
+ const wrapper = {
14551
+ status(code) {
14552
+ envelope.status = code;
14553
+ return wrapper;
14554
+ },
14555
+ code(code) {
14556
+ envelope.status = code;
14557
+ return wrapper;
14558
+ },
14559
+ send(data) {
14560
+ envelope.body = data;
14561
+ },
14562
+ redirect(url) {
14563
+ envelope.redirectUrl = url;
14564
+ if (envelope.status === 200) envelope.status = 302;
14565
+ },
14566
+ header(name, value) {
14567
+ envelope.headers[name.toLowerCase()] = value;
14568
+ return wrapper;
14569
+ },
14570
+ type(mime) {
14571
+ envelope.contentType = mime;
14572
+ return wrapper;
14573
+ }
14574
+ };
14575
+ return wrapper;
14576
+ }
14577
+ /**
14578
+ * notification-output — canonical, capability-gated notification delivery.
14579
+ *
14580
+ * Apprise-derived model (see
14581
+ * `docs/superpowers/specs/2026-07-03-notification-output-notifier-matrix.md`):
14582
+ * callers emit ONE canonical `Notification`; each provider declares a
14583
+ * per-kind capability descriptor (`TargetKind`), and the pure degrade
14584
+ * engine (`@camstack/types` `prepareNotification`) transcodes / degrades the
14585
+ * message to what the kind supports — callers never special-case a service.
14586
+ *
14587
+ * DESIGN DECISIONS (locked):
14588
+ * - A target is an INSTANCE of this function cap (epic #440, step 6): the
14589
+ * providers serve their targets as `integration-instances` records, one
14590
+ * record kind per target kind, and the admin lists, adds, edits, switches
14591
+ * and deletes them through that cap. This cap keeps what an instance cannot
14592
+ * say: the kind catalogue (`listTargetKinds`: capabilities, delivery
14593
+ * parameters, brand icon), dispatch (`send`, `testTarget`) and the form
14594
+ * helpers (`discoverTargets`, `probeTargetConfig`).
14595
+ * - `listTargetKinds` / `discoverTargets` return arrays → the generated
14596
+ * cap-mount auto-`concatCollection`-fans them across every registered
14597
+ * provider so one catalog is routable. `send` / `testTarget` /
14598
+ * `probeTargetConfig` route to ONE provider by the `addonId` the generated
14599
+ * collection router extracts from the call input.
14600
+ * - `Attachment.bytes` is `Uint8Array`. Transport-safe: superjson (the tRPC
14601
+ * transformer) + UDS MsgPack both round-trip typed arrays — already used by
14602
+ * `storage` / `storage-provider` / `recording` caps over the same path. No
14603
+ * base64 fallback needed.
14604
+ *
14605
+ * TODO (deferred, closed-set change — separate decision): add
14606
+ * `providerKind: 'notify'` so notification providers surface on the unified
14607
+ * admin "Integrations" page.
14608
+ */
14609
+ /**
14610
+ * Zentik-derived typed-media enum — the superset across every kind. Each
14611
+ * adapter picks what it supports and the degrade engine filters the rest.
14612
+ */
14613
+ var AttachmentMediaTypeSchema = _enum([
14614
+ "image",
14615
+ "video",
14616
+ "gif",
14617
+ "audio",
14618
+ "icon"
14619
+ ]);
14620
+ /**
14621
+ * A single attachment. Exactly one of `url` (remote source, most adapters
14622
+ * prefer this) or `bytes` (inline source; required for Pushover-style
14623
+ * bytes-only kinds) MUST be present — the degrade engine expresses a
14624
+ * url→bytes fetch as a `needsFetch` directive the adapter executes.
14625
+ */
14626
+ var AttachmentSchema = object({
14627
+ mediaType: AttachmentMediaTypeSchema,
14628
+ url: string().optional(),
14629
+ bytes: _instanceof(Uint8Array).optional(),
14630
+ mime: string().optional(),
14631
+ name: string().optional()
14632
+ }).refine((a) => a.url !== void 0 || a.bytes !== void 0, { message: "Attachment requires either `url` or `bytes`" });
14633
+ var NotificationFormatSchema = _enum([
14634
+ "text",
14635
+ "markdown",
14636
+ "html"
14637
+ ]);
14638
+ /**
14639
+ * The CLOSED icon vocabulary an action button may use.
14640
+ *
14641
+ * A closed set, not a free string, and that is the whole point: an arbitrary
14642
+ * icon name is one that ntfy renders, zentik silently drops, and nobody
14643
+ * notices — the same class of gap as a zone vocabulary nothing produced
14644
+ * ([D35](../../../docs/decisions/adr-0035.md)). Every adapter maps this set or
14645
+ * declares `actionIcons: false` and the degrade engine strips the field.
14646
+ *
14647
+ * Named by INTENT, never by glyph. "check" would tie the vocabulary to one
14648
+ * renderer's icon set; "acknowledge" survives an adapter that draws it
14649
+ * differently.
14650
+ *
14651
+ * ── A TOKEN IS NOT A WIRE VALUE ─────────────────────────────────────
14652
+ *
14653
+ * These names are for US. **No adapter may forward one verbatim.** Each maps
14156
14654
  * the whole set onto its own renderer's vocabulary through a
14157
14655
  * `Record<NotificationActionIcon, string>` — a Record, never a lookup with a
14158
14656
  * fallback, so adding a member here fails every adapter's build until someone
@@ -42480,743 +42978,365 @@ var ICON_SYNONYMS = {
42480
42978
  timer: ["conto", "rovescia"],
42481
42979
  "toggle-left": [
42482
42980
  "interruttore",
42483
- "switch",
42484
- "toggle"
42485
- ],
42486
- "toggle-right": [
42487
- "interruttore",
42488
- "switch",
42489
- "toggle",
42490
- "acceso"
42491
- ],
42492
- tractor: [
42493
- "trattore",
42494
- "tosaerba",
42495
- "giardino"
42496
- ],
42497
- "train-front": ["treno"],
42498
- "tree-pine": [
42499
- "albero",
42500
- "pino",
42501
- "giardino"
42502
- ],
42503
- trees: [
42504
- "giardino",
42505
- "alberi",
42506
- "esterno",
42507
- "parco",
42508
- "garden"
42509
- ],
42510
- truck: [
42511
- "camion",
42512
- "furgone",
42513
- "consegna"
42514
- ],
42515
- tv: ["televisore"],
42516
- umbrella: [
42517
- "tenda",
42518
- "markise",
42519
- "ombrellone",
42520
- "pergola",
42521
- "veranda",
42522
- "terrace"
42523
- ],
42524
- user: ["persona", "utente"],
42525
- users: [
42526
- "persone",
42527
- "gruppo",
42528
- "famiglia"
42529
- ],
42530
- utensils: [
42531
- "cucina",
42532
- "posate",
42533
- "sala",
42534
- "pranzo",
42535
- "kitchen"
42536
- ],
42537
- vibrate: [
42538
- "vibrazione",
42539
- "urto",
42540
- "tamper"
42541
- ],
42542
- video: [],
42543
- "video-off": ["video", "spento"],
42544
- "volume-2": [
42545
- "volume",
42546
- "audio",
42547
- "altoparlante",
42548
- "suono"
42549
- ],
42550
- "volume-x": [
42551
- "muto",
42552
- "silenziato",
42553
- "volume",
42554
- "spento"
42555
- ],
42556
- warehouse: [
42557
- "magazzino",
42558
- "capanno",
42559
- "deposito",
42560
- "cantina",
42561
- "warehouse"
42562
- ],
42563
- "washing-machine": [
42564
- "lavatrice",
42565
- "lavastoviglie",
42566
- "asciugatrice"
42567
- ],
42568
- waves: [
42569
- "onde",
42570
- "acqua",
42571
- "vibrazione"
42572
- ],
42573
- "waves-ladder": [
42574
- "piscina",
42575
- "vasca",
42576
- "pool"
42577
- ],
42578
- wifi: ["rete", "segnale"],
42579
- "wifi-off": [
42580
- "wifi",
42581
- "assente",
42582
- "offline",
42583
- "disconnesso"
42584
- ],
42585
- wind: [
42586
- "vento",
42587
- "aria",
42588
- "gas",
42589
- "monossido",
42590
- "co"
42591
- ],
42592
- workflow: [
42593
- "automazione",
42594
- "flusso",
42595
- "scenario"
42596
- ],
42597
- wrench: [
42598
- "officina",
42599
- "manutenzione",
42600
- "attrezzi",
42601
- "utenze"
42602
- ],
42603
- zap: [
42604
- "energia",
42605
- "corrente",
42606
- "consumo",
42607
- "watt",
42608
- "elettricita"
42609
- ]
42610
- };
42611
- /**
42612
- * Spellings an operator may already have PERSISTED that no lucide package
42613
- * accepts any more, and the catalog key they draw. They resolve
42614
- * (`canonicalIconKey`) but are never offered. `gauge2` was this repo's own
42615
- * pre-catalog spelling of `gauge`.
42616
- */
42617
- var LEGACY_ICON_ALIASES = { gauge2: "gauge" };
42618
- /**
42619
- * icon-catalog — THE icon vocabulary (D854).
42620
- *
42621
- * Every place that picks or stores an icon — a device's display override, a
42622
- * location, a site zone, a viewer accessory, an `icon` settings field — names
42623
- * it by a key of this catalog and nothing else. There is no curated subset and
42624
- * no second list: the catalog is every lucide icon that both surfaces can draw
42625
- * (the admin UI's `lucide-react` and the viewer's `lucide-react-native`), the
42626
- * intersection computed by `scripts/generate-icon-catalog.ts` into the
42627
- * committed `icon-catalog.generated.ts`.
42628
- *
42629
- * Like the vocabularies it replaces, this module holds STRINGS only — no React,
42630
- * no lucide import, no glyph. Each surface owns its glyph table (the web one
42631
- * lives in `ui-library`, loaded lazily), and a test on each side pins that it
42632
- * covers {@link ICON_KEYS}.
42633
- *
42634
- * ## What is persisted
42635
- *
42636
- * The canonical kebab-case lucide id ({@link IconKey}). Spellings that a lucide
42637
- * package still accepts (`home` for `house`) and this repo's own legacy ones
42638
- * (`gauge2`) RESOLVE ({@link canonicalIconKey}) so a stored value never goes
42639
- * stale, but they are never OFFERED by search.
42640
- *
42641
- * ## Search
42642
- *
42643
- * Over the key, the Italian/English overlay in `icon-synonyms.ts`, any words
42644
- * the caller adds, and lucide's English tags — in that order of weight.
42645
- */
42646
- var KEY_SET$2 = new Set(ICON_KEYS);
42647
- new Map([...Object.entries(ICON_ALIASES), ...Object.entries(LEGACY_ICON_ALIASES)]);
42648
- /** Is this a canonical key of the catalog? (An alias is not — see {@link canonicalIconKey}.) */
42649
- function isIconKey(value) {
42650
- return typeof value === "string" && KEY_SET$2.has(value);
42651
- }
42652
- /**
42653
- * Wire/storage schema for one icon key.
42654
- *
42655
- * Deliberately NOT a `z.enum` of the catalog: ~1,700 literals would be inlined
42656
- * into every cap router, type and API-reference row that carries an icon. The
42657
- * check is membership in the catalog and the type is {@link IconKey}.
42658
- */
42659
- var IconKeySchema = custom(isIconKey, "Not an icon of the catalog");
42660
- var ENTRIES = ICON_KEYS.map((key, index) => {
42661
- const [categoryIndexes, tags] = ICON_META[index] ?? [[], []];
42662
- const categories = categoryIndexes.flatMap((i) => {
42663
- const id = ICON_CATEGORY_IDS[i];
42664
- return id === void 0 ? [] : [id];
42665
- });
42666
- return {
42667
- key,
42668
- categories,
42669
- primaryCategory: categories[0] ?? ICON_CATEGORY_IDS[0],
42670
- tags,
42671
- synonyms: ICON_SYNONYMS[key] ?? []
42672
- };
42673
- });
42674
- new Map(ENTRIES.map((e) => [e.key, e]));
42675
- /** Categories a picker offers first: the ones this product's icons mostly live in. */
42676
- var LEADING_CATEGORIES = [
42677
- "devices",
42678
- "home",
42679
- "security",
42680
- "buildings",
42681
- "connectivity",
42682
- "multimedia",
42683
- "nature",
42684
- "weather",
42685
- "transportation",
42686
- "animals"
42687
- ];
42688
- var PRIMARY_CATEGORIES = new Set(ENTRIES.map((e) => e.primaryCategory));
42689
- [...LEADING_CATEGORIES, ...ICON_CATEGORY_IDS.filter((c) => !LEADING_CATEGORIES.includes(c))].filter((c) => PRIMARY_CATEGORIES.has(c));
42690
- /**
42691
- * One (location, icon) assignment as it travels.
42692
- *
42693
- * `locationKey` is ALWAYS {@link locationIconKey} of the label — never the
42694
- * operator's casing. The registry matches labels trimmed + case-insensitively
42695
- * everywhere (`addLocation`, `removeLocation`, `renameLocation`), and a
42696
- * case-only rename (`kitchen` → `Kitchen`) is a real edit this repo supports; a
42697
- * map keyed on the displayed casing would orphan its entry on exactly that
42698
- * edit. Consumers join by keying their own label through `locationIconKey`.
42699
- */
42700
- var LocationIconAssignmentSchema = object({
42701
- locationKey: string(),
42702
- icon: IconKeySchema
42703
- });
42704
- /**
42705
- * One (location, description) assignment as it travels.
42706
- *
42707
- * Same key discipline as {@link LocationIconAssignmentSchema}, and for the same
42708
- * reason: this lived for a while in the post-analysis addon's own settings,
42709
- * keyed by a HAND-TYPED label matched exactly and case-sensitively. A rename in
42710
- * the Locations page carried the icon and silently orphaned the description —
42711
- * two authorities for one thing, joined by two different rules. Now both hang
42712
- * off the location itself, on `locationIconKey`.
42713
- */
42714
- var LocationDescriptionAssignmentSchema = object({
42715
- locationKey: string(),
42716
- description: string()
42717
- });
42718
- /**
42719
- * WHO an action step acts on (D983) — one target shape for every place that
42720
- * performs an action (automation steps, Action entries, notification
42721
- * sequences, scheduler points):
42722
- *
42723
- * - `devices` — device ids the operator picked, frozen at save time;
42724
- * - `domain` — every device that offers the step's VOCABULARY action,
42725
- * optionally narrowed to one device type and one room, resolved WHEN THE
42726
- * STEP RUNS (a device added later is included). The action always comes
42727
- * from the vocabulary (`cover.open`), never from a raw cap name, so a
42728
- * `domain` target needs an `actionId` (enforced on the step schema);
42729
- * - `var` — a `$var` resolved from the run's scope.
42730
- *
42731
- * {@link ActionTargetResolver} turns a target into device ids. It is pure
42732
- * (a {@link DeviceDirectory} is handed in) so the hub's core-blocks service and
42733
- * a generated automation block share it.
42734
- *
42735
- * A room is the device's `location` label (`DeviceInfo.location`); two labels
42736
- * name the same room when `locationIconKey` agrees (trimmed, lower-cased).
42737
- */
42738
- var ActionTargetSchema = discriminatedUnion("kind", [
42739
- object({
42740
- kind: literal("devices"),
42741
- ids: array(number().int()).min(1)
42742
- }),
42743
- object({
42744
- kind: literal("domain"),
42745
- /** Narrow to one kind of device. */
42746
- deviceType: _enum(DeviceType).optional(),
42747
- /** Narrow to one room: the `location` label devices carry. */
42748
- roomId: string().min(1).optional()
42749
- }),
42750
- object({
42751
- kind: literal("var"),
42752
- name: string().min(1)
42753
- })
42754
- ]);
42755
- EventCategory.DeviceRegistered, EventCategory.DeviceUnregistered, EventCategory.DeviceUpdated, EventCategory.DeviceMetaChanged, EventCategory.DeviceBindingsChanged;
42756
- var ExpressionBindingSourceSchema = union([
42757
- object({
42758
- kind: literal("field").optional(),
42759
- sourceKey: string(),
42760
- cap: string(),
42761
- fieldPath: string()
42762
- }),
42763
- object({
42764
- kind: literal("literal"),
42765
- value: union([
42766
- string(),
42767
- number(),
42768
- boolean(),
42769
- _null()
42770
- ])
42771
- }),
42772
- object({
42773
- kind: literal("global"),
42774
- sourceStableId: string(),
42775
- cap: string(),
42776
- fieldPath: string()
42777
- })
42778
- ]);
42779
- object({
42780
- expr: string().min(1).max(MAX_EXPRESSION_SOURCE_LENGTH),
42781
- bindings: record(string().regex(EXPRESSION_IDENTIFIER_RE), ExpressionBindingSourceSchema)
42782
- }).superRefine((src, ctx) => {
42783
- const err = validateExpressionSource(src);
42784
- if (err !== null) ctx.addIssue({
42785
- code: "custom",
42786
- message: err,
42787
- path: ["expr"]
42788
- });
42789
- });
42790
- /**
42791
- * Identity envelope for a device's upstream-system metadata.
42792
- *
42793
- * Two jobs:
42794
- *
42795
- * 1. **Dispatch key.** `id` is the natural identifier the SOURCE system
42796
- * uses to address this device (HA `entity_id`, Reolink MAC, ONVIF
42797
- * WS-Discovery endpoint UUID, …). Provider code keeps a
42798
- * `Map<sourceInfo.id, IDevice>` to route inbound push events in O(1)
42799
- * without round-tripping through `stableId` / `id` mappings.
42800
- *
42801
- * 2. **Stability bridge.** `uniqueId` is the *immutable* upstream id when
42802
- * one exists (HA `entity.unique_id`, Reolink MAC again — same as `id`
42803
- * for vendors where MAC is the natural key). For systems where the
42804
- * live dispatch key can be renamed (HA `entity_id` can be edited),
42805
- * providers detect renames by matching `uniqueId` and patch `id`
42806
- * in-place so dispatch keeps working.
42807
- *
42808
- * **Display unit and precision are NOT stored here.** They are a read-time
42809
- * preference (D944). A polymorphic reading stores its `quantity` here once,
42810
- * at adopt, and a date/time value stores `dateTimeShape` the same way —
42811
- * neither is repeated on each sample. The `device_class` tag is an
42812
- * HA-specific input consumed at the discovery boundary (`ha-domain-mapping`)
42813
- * to derive the CamStack `DeviceRole`; it is never stored after that point.
42814
- *
42815
- * The `raw` escape hatch carries provider-specific attributes that don't
42816
- * fit the structured slots (HA `attributes` whitelist, Reolink `deviceCache`
42817
- * details, …). Providers control what lands here.
42818
- */
42819
- var SourceInfoSchema = object({
42820
- /** Live dispatch key — mutable when the source system allows rename. */
42821
- id: string(),
42822
- /** Source system tag — e.g. 'homeassistant' | 'reolink' | 'onvif'. */
42823
- system: string(),
42824
- /** Immutable upstream identifier when available (HA `unique_id`, … ).
42825
- * Used to detect rename when `id` changes. */
42826
- uniqueId: string().optional(),
42827
- /** Quantity of a polymorphic reading, written once at adopt (D944). */
42828
- quantity: ReadingQuantitySchema.optional(),
42829
- /** Date / time / datetime shape of a string reading, written once at adopt. */
42830
- dateTimeShape: _enum([
42831
- "date",
42832
- "time",
42833
- "datetime"
42834
- ]).optional(),
42835
- /** Provider-specific extras that don't fit the structured slots.
42836
- * Whitelist what goes here per provider — do NOT dump entire HA
42837
- * attribute blobs (would explode the meta JSON column). */
42838
- raw: record(string(), unknown()).optional()
42839
- });
42840
- /**
42841
- * Frozen unit → spec table. `•` in the doc marks each dimension's canonical
42842
- * unit (`factor: 1, offset: 0`). °F derives from `°C = (°F − 32) × 5/9` ⇒
42843
- * `factor = 5/9`, `offset = -160/9` (kept as exact expressions, not rounded
42844
- * decimals). K derives from `°C = K − 273.15`.
42845
- */
42846
- var UNIT_TABLE = {
42847
- "°C": {
42848
- dimension: "temperature",
42849
- factor: 1,
42850
- offset: 0
42851
- },
42852
- "°F": {
42853
- dimension: "temperature",
42854
- factor: 5 / 9,
42855
- offset: -160 / 9
42856
- },
42857
- K: {
42858
- dimension: "temperature",
42859
- factor: 1,
42860
- offset: -273.15
42861
- },
42862
- hPa: {
42863
- dimension: "pressure",
42864
- factor: 1,
42865
- offset: 0
42866
- },
42867
- kPa: {
42868
- dimension: "pressure",
42869
- factor: 10,
42870
- offset: 0
42871
- },
42872
- Pa: {
42873
- dimension: "pressure",
42874
- factor: .01,
42875
- offset: 0
42876
- },
42877
- mbar: {
42878
- dimension: "pressure",
42879
- factor: 1,
42880
- offset: 0
42881
- },
42882
- bar: {
42883
- dimension: "pressure",
42884
- factor: 1e3,
42885
- offset: 0
42886
- },
42887
- inHg: {
42888
- dimension: "pressure",
42889
- factor: 33.8639,
42890
- offset: 0
42891
- },
42892
- mmHg: {
42893
- dimension: "pressure",
42894
- factor: 1.33322,
42895
- offset: 0
42896
- },
42897
- psi: {
42898
- dimension: "pressure",
42899
- factor: 68.9476,
42900
- offset: 0
42901
- },
42902
- "m/s": {
42903
- dimension: "speed",
42904
- factor: 1,
42905
- offset: 0
42906
- },
42907
- "km/h": {
42908
- dimension: "speed",
42909
- factor: 1 / 3.6,
42910
- offset: 0
42911
- },
42912
- mph: {
42913
- dimension: "speed",
42914
- factor: .44704,
42915
- offset: 0
42916
- },
42917
- kn: {
42918
- dimension: "speed",
42919
- factor: .514444,
42920
- offset: 0
42921
- },
42922
- "mm/h": {
42923
- dimension: "precipitation-rate",
42924
- factor: 1,
42925
- offset: 0
42926
- },
42927
- "in/h": {
42928
- dimension: "precipitation-rate",
42929
- factor: 25.4,
42930
- offset: 0
42931
- },
42932
- m: {
42933
- dimension: "length",
42934
- factor: 1,
42935
- offset: 0
42936
- },
42937
- mm: {
42938
- dimension: "length",
42939
- factor: .001,
42940
- offset: 0
42941
- },
42942
- cm: {
42943
- dimension: "length",
42944
- factor: .01,
42945
- offset: 0
42946
- },
42947
- km: {
42948
- dimension: "length",
42949
- factor: 1e3,
42950
- offset: 0
42951
- },
42952
- in: {
42953
- dimension: "length",
42954
- factor: .0254,
42955
- offset: 0
42956
- },
42957
- ft: {
42958
- dimension: "length",
42959
- factor: .3048,
42960
- offset: 0
42961
- },
42962
- mi: {
42963
- dimension: "length",
42964
- factor: 1609.344,
42965
- offset: 0
42966
- },
42967
- "m²": {
42968
- dimension: "area",
42969
- factor: 1,
42970
- offset: 0
42971
- },
42972
- lx: {
42973
- dimension: "illuminance",
42974
- factor: 1,
42975
- offset: 0
42976
- },
42977
- "W/m²": {
42978
- dimension: "irradiance",
42979
- factor: 1,
42980
- offset: 0
42981
- },
42982
- W: {
42983
- dimension: "power",
42984
- factor: 1,
42985
- offset: 0
42986
- },
42987
- kW: {
42988
- dimension: "power",
42989
- factor: 1e3,
42990
- offset: 0
42991
- },
42992
- VA: {
42993
- dimension: "apparent-power",
42994
- factor: 1,
42995
- offset: 0
42996
- },
42997
- Wh: {
42998
- dimension: "energy",
42999
- factor: 1,
43000
- offset: 0
43001
- },
43002
- kWh: {
43003
- dimension: "energy",
43004
- factor: 1e3,
43005
- offset: 0
43006
- },
43007
- MWh: {
43008
- dimension: "energy",
43009
- factor: 1e6,
43010
- offset: 0
43011
- },
43012
- V: {
43013
- dimension: "voltage",
43014
- factor: 1,
43015
- offset: 0
43016
- },
43017
- mV: {
43018
- dimension: "voltage",
43019
- factor: .001,
43020
- offset: 0
43021
- },
43022
- A: {
43023
- dimension: "current",
43024
- factor: 1,
43025
- offset: 0
43026
- },
43027
- mA: {
43028
- dimension: "current",
43029
- factor: .001,
43030
- offset: 0
43031
- },
43032
- ppm: {
43033
- dimension: "concentration-volume",
43034
- factor: 1,
43035
- offset: 0
43036
- },
43037
- ppb: {
43038
- dimension: "concentration-volume",
43039
- factor: .001,
43040
- offset: 0
43041
- },
43042
- "µg/m³": {
43043
- dimension: "concentration-mass",
43044
- factor: 1,
43045
- offset: 0
43046
- },
43047
- "mg/m³": {
43048
- dimension: "concentration-mass",
43049
- factor: 1e3,
43050
- offset: 0
43051
- },
43052
- kg: {
43053
- dimension: "mass",
43054
- factor: 1,
43055
- offset: 0
43056
- },
43057
- g: {
43058
- dimension: "mass",
43059
- factor: .001,
43060
- offset: 0
43061
- },
43062
- lb: {
43063
- dimension: "mass",
43064
- factor: .453592,
43065
- offset: 0
43066
- },
43067
- oz: {
43068
- dimension: "mass",
43069
- factor: .0283495,
43070
- offset: 0
43071
- },
43072
- "%": {
43073
- dimension: "percentage",
43074
- factor: 1,
43075
- offset: 0
43076
- },
43077
- L: {
43078
- dimension: "volume",
43079
- factor: 1,
43080
- offset: 0
43081
- },
43082
- mL: {
43083
- dimension: "volume",
43084
- factor: .001,
43085
- offset: 0
43086
- },
43087
- gal: {
43088
- dimension: "volume",
43089
- factor: 3.785411784,
43090
- offset: 0
43091
- },
43092
- s: {
43093
- dimension: "duration",
43094
- factor: 1,
43095
- offset: 0
43096
- },
43097
- ms: {
43098
- dimension: "duration",
43099
- factor: .001,
43100
- offset: 0
43101
- },
43102
- min: {
43103
- dimension: "duration",
43104
- factor: 60,
43105
- offset: 0
43106
- },
43107
- h: {
43108
- dimension: "duration",
43109
- factor: 3600,
43110
- offset: 0
43111
- },
43112
- d: {
43113
- dimension: "duration",
43114
- factor: 86400,
43115
- offset: 0
43116
- },
43117
- B: {
43118
- dimension: "information",
43119
- factor: 1,
43120
- offset: 0
43121
- },
43122
- KiB: {
43123
- dimension: "information",
43124
- factor: 1024,
43125
- offset: 0
43126
- },
43127
- MiB: {
43128
- dimension: "information",
43129
- factor: 1024 ** 2,
43130
- offset: 0
43131
- },
43132
- GiB: {
43133
- dimension: "information",
43134
- factor: 1024 ** 3,
43135
- offset: 0
43136
- },
43137
- TiB: {
43138
- dimension: "information",
43139
- factor: 1024 ** 4,
43140
- offset: 0
43141
- },
43142
- kB: {
43143
- dimension: "information",
43144
- factor: 1e3,
43145
- offset: 0
43146
- },
43147
- MB: {
43148
- dimension: "information",
43149
- factor: 1e6,
43150
- offset: 0
43151
- },
43152
- GB: {
43153
- dimension: "information",
43154
- factor: 1e9,
43155
- offset: 0
43156
- },
43157
- "°": {
43158
- dimension: "angle",
43159
- factor: 1,
43160
- offset: 0
43161
- },
43162
- dBFS: {
43163
- dimension: "sound-level",
43164
- factor: 1,
43165
- offset: 0
43166
- },
43167
- dBm: {
43168
- dimension: "signal-level",
43169
- factor: 1,
43170
- offset: 0
43171
- },
43172
- mired: {
43173
- dimension: "colour-temperature",
43174
- factor: 1,
43175
- offset: 0
43176
- },
43177
- kbps: {
43178
- dimension: "bitrate",
43179
- factor: 1,
43180
- offset: 0
43181
- },
43182
- Mbps: {
43183
- dimension: "bitrate",
43184
- factor: 1e3,
43185
- offset: 0
43186
- },
43187
- fps: {
43188
- dimension: "rate",
43189
- factor: 1,
43190
- offset: 0
43191
- }
42981
+ "switch",
42982
+ "toggle"
42983
+ ],
42984
+ "toggle-right": [
42985
+ "interruttore",
42986
+ "switch",
42987
+ "toggle",
42988
+ "acceso"
42989
+ ],
42990
+ tractor: [
42991
+ "trattore",
42992
+ "tosaerba",
42993
+ "giardino"
42994
+ ],
42995
+ "train-front": ["treno"],
42996
+ "tree-pine": [
42997
+ "albero",
42998
+ "pino",
42999
+ "giardino"
43000
+ ],
43001
+ trees: [
43002
+ "giardino",
43003
+ "alberi",
43004
+ "esterno",
43005
+ "parco",
43006
+ "garden"
43007
+ ],
43008
+ truck: [
43009
+ "camion",
43010
+ "furgone",
43011
+ "consegna"
43012
+ ],
43013
+ tv: ["televisore"],
43014
+ umbrella: [
43015
+ "tenda",
43016
+ "markise",
43017
+ "ombrellone",
43018
+ "pergola",
43019
+ "veranda",
43020
+ "terrace"
43021
+ ],
43022
+ user: ["persona", "utente"],
43023
+ users: [
43024
+ "persone",
43025
+ "gruppo",
43026
+ "famiglia"
43027
+ ],
43028
+ utensils: [
43029
+ "cucina",
43030
+ "posate",
43031
+ "sala",
43032
+ "pranzo",
43033
+ "kitchen"
43034
+ ],
43035
+ vibrate: [
43036
+ "vibrazione",
43037
+ "urto",
43038
+ "tamper"
43039
+ ],
43040
+ video: [],
43041
+ "video-off": ["video", "spento"],
43042
+ "volume-2": [
43043
+ "volume",
43044
+ "audio",
43045
+ "altoparlante",
43046
+ "suono"
43047
+ ],
43048
+ "volume-x": [
43049
+ "muto",
43050
+ "silenziato",
43051
+ "volume",
43052
+ "spento"
43053
+ ],
43054
+ warehouse: [
43055
+ "magazzino",
43056
+ "capanno",
43057
+ "deposito",
43058
+ "cantina",
43059
+ "warehouse"
43060
+ ],
43061
+ "washing-machine": [
43062
+ "lavatrice",
43063
+ "lavastoviglie",
43064
+ "asciugatrice"
43065
+ ],
43066
+ waves: [
43067
+ "onde",
43068
+ "acqua",
43069
+ "vibrazione"
43070
+ ],
43071
+ "waves-ladder": [
43072
+ "piscina",
43073
+ "vasca",
43074
+ "pool"
43075
+ ],
43076
+ wifi: ["rete", "segnale"],
43077
+ "wifi-off": [
43078
+ "wifi",
43079
+ "assente",
43080
+ "offline",
43081
+ "disconnesso"
43082
+ ],
43083
+ wind: [
43084
+ "vento",
43085
+ "aria",
43086
+ "gas",
43087
+ "monossido",
43088
+ "co"
43089
+ ],
43090
+ workflow: [
43091
+ "automazione",
43092
+ "flusso",
43093
+ "scenario"
43094
+ ],
43095
+ wrench: [
43096
+ "officina",
43097
+ "manutenzione",
43098
+ "attrezzi",
43099
+ "utenze"
43100
+ ],
43101
+ zap: [
43102
+ "energia",
43103
+ "corrente",
43104
+ "consumo",
43105
+ "watt",
43106
+ "elettricita"
43107
+ ]
43192
43108
  };
43193
- /** Resolve a unit's `UnitSpec`, or `undefined` when the spelling is unknown. */
43194
- function specFor(unit) {
43195
- return Object.hasOwn(UNIT_TABLE, unit) ? UNIT_TABLE[unit] : void 0;
43196
- }
43197
- /** Value in `spec`'s unit → its dimension's canonical unit. */
43198
- function toCanonical(value, spec) {
43199
- return value * spec.factor + spec.offset;
43200
- }
43201
- /** Canonical-unit value → the unit described by `spec`. */
43202
- function fromCanonical(canonical, spec) {
43203
- return (canonical - spec.offset) / spec.factor;
43204
- }
43205
43109
  /**
43206
- * Graceful variant for the render path: returns the converted value, or
43207
- * `undefined` when the conversion is refused (unknown unit / cross-dimension).
43208
- * Never throws — a render caller falls back to the raw value + source unit.
43110
+ * Spellings an operator may already have PERSISTED that no lucide package
43111
+ * accepts any more, and the catalog key they draw. They resolve
43112
+ * (`canonicalIconKey`) but are never offered. `gauge2` was this repo's own
43113
+ * pre-catalog spelling of `gauge`.
43209
43114
  */
43210
- function tryConvertUnit(value, from, to) {
43211
- if (from === to) return value;
43212
- const fromSpec = specFor(from);
43213
- if (!fromSpec) return void 0;
43214
- const toSpec = specFor(to);
43215
- if (!toSpec) return void 0;
43216
- if (fromSpec.dimension !== toSpec.dimension) return void 0;
43217
- return fromCanonical(toCanonical(value, fromSpec), toSpec);
43115
+ var LEGACY_ICON_ALIASES = { gauge2: "gauge" };
43116
+ /**
43117
+ * icon-catalog — THE icon vocabulary (D854).
43118
+ *
43119
+ * Every place that picks or stores an icon — a device's display override, a
43120
+ * location, a site zone, a viewer accessory, an `icon` settings field — names
43121
+ * it by a key of this catalog and nothing else. There is no curated subset and
43122
+ * no second list: the catalog is every lucide icon that both surfaces can draw
43123
+ * (the admin UI's `lucide-react` and the viewer's `lucide-react-native`), the
43124
+ * intersection computed by `scripts/generate-icon-catalog.ts` into the
43125
+ * committed `icon-catalog.generated.ts`.
43126
+ *
43127
+ * Like the vocabularies it replaces, this module holds STRINGS only — no React,
43128
+ * no lucide import, no glyph. Each surface owns its glyph table (the web one
43129
+ * lives in `ui-library`, loaded lazily), and a test on each side pins that it
43130
+ * covers {@link ICON_KEYS}.
43131
+ *
43132
+ * ## What is persisted
43133
+ *
43134
+ * The canonical kebab-case lucide id ({@link IconKey}). Spellings that a lucide
43135
+ * package still accepts (`home` for `house`) and this repo's own legacy ones
43136
+ * (`gauge2`) RESOLVE ({@link canonicalIconKey}) so a stored value never goes
43137
+ * stale, but they are never OFFERED by search.
43138
+ *
43139
+ * ## Search
43140
+ *
43141
+ * Over the key, the Italian/English overlay in `icon-synonyms.ts`, any words
43142
+ * the caller adds, and lucide's English tags — in that order of weight.
43143
+ */
43144
+ var KEY_SET$2 = new Set(ICON_KEYS);
43145
+ new Map([...Object.entries(ICON_ALIASES), ...Object.entries(LEGACY_ICON_ALIASES)]);
43146
+ /** Is this a canonical key of the catalog? (An alias is not — see {@link canonicalIconKey}.) */
43147
+ function isIconKey(value) {
43148
+ return typeof value === "string" && KEY_SET$2.has(value);
43218
43149
  }
43219
43150
  /**
43151
+ * Wire/storage schema for one icon key.
43152
+ *
43153
+ * Deliberately NOT a `z.enum` of the catalog: ~1,700 literals would be inlined
43154
+ * into every cap router, type and API-reference row that carries an icon. The
43155
+ * check is membership in the catalog and the type is {@link IconKey}.
43156
+ */
43157
+ var IconKeySchema = custom(isIconKey, "Not an icon of the catalog");
43158
+ var ENTRIES = ICON_KEYS.map((key, index) => {
43159
+ const [categoryIndexes, tags] = ICON_META[index] ?? [[], []];
43160
+ const categories = categoryIndexes.flatMap((i) => {
43161
+ const id = ICON_CATEGORY_IDS[i];
43162
+ return id === void 0 ? [] : [id];
43163
+ });
43164
+ return {
43165
+ key,
43166
+ categories,
43167
+ primaryCategory: categories[0] ?? ICON_CATEGORY_IDS[0],
43168
+ tags,
43169
+ synonyms: ICON_SYNONYMS[key] ?? []
43170
+ };
43171
+ });
43172
+ new Map(ENTRIES.map((e) => [e.key, e]));
43173
+ /** Categories a picker offers first: the ones this product's icons mostly live in. */
43174
+ var LEADING_CATEGORIES = [
43175
+ "devices",
43176
+ "home",
43177
+ "security",
43178
+ "buildings",
43179
+ "connectivity",
43180
+ "multimedia",
43181
+ "nature",
43182
+ "weather",
43183
+ "transportation",
43184
+ "animals"
43185
+ ];
43186
+ var PRIMARY_CATEGORIES = new Set(ENTRIES.map((e) => e.primaryCategory));
43187
+ [...LEADING_CATEGORIES, ...ICON_CATEGORY_IDS.filter((c) => !LEADING_CATEGORIES.includes(c))].filter((c) => PRIMARY_CATEGORIES.has(c));
43188
+ /**
43189
+ * One (location, icon) assignment as it travels.
43190
+ *
43191
+ * `locationKey` is ALWAYS {@link locationIconKey} of the label — never the
43192
+ * operator's casing. The registry matches labels trimmed + case-insensitively
43193
+ * everywhere (`addLocation`, `removeLocation`, `renameLocation`), and a
43194
+ * case-only rename (`kitchen` → `Kitchen`) is a real edit this repo supports; a
43195
+ * map keyed on the displayed casing would orphan its entry on exactly that
43196
+ * edit. Consumers join by keying their own label through `locationIconKey`.
43197
+ */
43198
+ var LocationIconAssignmentSchema = object({
43199
+ locationKey: string(),
43200
+ icon: IconKeySchema
43201
+ });
43202
+ /**
43203
+ * One (location, description) assignment as it travels.
43204
+ *
43205
+ * Same key discipline as {@link LocationIconAssignmentSchema}, and for the same
43206
+ * reason: this lived for a while in the post-analysis addon's own settings,
43207
+ * keyed by a HAND-TYPED label matched exactly and case-sensitively. A rename in
43208
+ * the Locations page carried the icon and silently orphaned the description —
43209
+ * two authorities for one thing, joined by two different rules. Now both hang
43210
+ * off the location itself, on `locationIconKey`.
43211
+ */
43212
+ var LocationDescriptionAssignmentSchema = object({
43213
+ locationKey: string(),
43214
+ description: string()
43215
+ });
43216
+ /**
43217
+ * WHO an action step acts on (D983) — one target shape for every place that
43218
+ * performs an action (automation steps, Action entries, notification
43219
+ * sequences, scheduler points):
43220
+ *
43221
+ * - `devices` — device ids the operator picked, frozen at save time;
43222
+ * - `domain` — every device that offers the step's VOCABULARY action,
43223
+ * optionally narrowed to one device type and one room, resolved WHEN THE
43224
+ * STEP RUNS (a device added later is included). The action always comes
43225
+ * from the vocabulary (`cover.open`), never from a raw cap name, so a
43226
+ * `domain` target needs an `actionId` (enforced on the step schema);
43227
+ * - `var` — a `$var` resolved from the run's scope.
43228
+ *
43229
+ * {@link ActionTargetResolver} turns a target into device ids. It is pure
43230
+ * (a {@link DeviceDirectory} is handed in) so the hub's core-blocks service and
43231
+ * a generated automation block share it.
43232
+ *
43233
+ * A room is the device's `location` label (`DeviceInfo.location`); two labels
43234
+ * name the same room when `locationIconKey` agrees (trimmed, lower-cased).
43235
+ */
43236
+ var ActionTargetSchema = discriminatedUnion("kind", [
43237
+ object({
43238
+ kind: literal("devices"),
43239
+ ids: array(number().int()).min(1)
43240
+ }),
43241
+ object({
43242
+ kind: literal("domain"),
43243
+ /** Narrow to one kind of device. */
43244
+ deviceType: _enum(DeviceType).optional(),
43245
+ /** Narrow to one room: the `location` label devices carry. */
43246
+ roomId: string().min(1).optional()
43247
+ }),
43248
+ object({
43249
+ kind: literal("var"),
43250
+ name: string().min(1)
43251
+ })
43252
+ ]);
43253
+ EventCategory.DeviceRegistered, EventCategory.DeviceUnregistered, EventCategory.DeviceUpdated, EventCategory.DeviceMetaChanged, EventCategory.DeviceBindingsChanged;
43254
+ var ExpressionBindingSourceSchema = union([
43255
+ object({
43256
+ kind: literal("field").optional(),
43257
+ sourceKey: string(),
43258
+ cap: string(),
43259
+ fieldPath: string()
43260
+ }),
43261
+ object({
43262
+ kind: literal("literal"),
43263
+ value: union([
43264
+ string(),
43265
+ number(),
43266
+ boolean(),
43267
+ _null()
43268
+ ])
43269
+ }),
43270
+ object({
43271
+ kind: literal("global"),
43272
+ sourceStableId: string(),
43273
+ addonId: string().optional(),
43274
+ cap: string(),
43275
+ fieldPath: string()
43276
+ })
43277
+ ]);
43278
+ object({
43279
+ expr: string().min(1).max(MAX_EXPRESSION_SOURCE_LENGTH),
43280
+ bindings: record(string().regex(EXPRESSION_IDENTIFIER_RE), ExpressionBindingSourceSchema)
43281
+ }).superRefine((src, ctx) => {
43282
+ const err = validateExpressionSource(src);
43283
+ if (err !== null) ctx.addIssue({
43284
+ code: "custom",
43285
+ message: err,
43286
+ path: ["expr"]
43287
+ });
43288
+ });
43289
+ /**
43290
+ * Identity envelope for a device's upstream-system metadata.
43291
+ *
43292
+ * Two jobs:
43293
+ *
43294
+ * 1. **Dispatch key.** `id` is the natural identifier the SOURCE system
43295
+ * uses to address this device (HA `entity_id`, Reolink MAC, ONVIF
43296
+ * WS-Discovery endpoint UUID, …). Provider code keeps a
43297
+ * `Map<sourceInfo.id, IDevice>` to route inbound push events in O(1)
43298
+ * without round-tripping through `stableId` / `id` mappings.
43299
+ *
43300
+ * 2. **Stability bridge.** `uniqueId` is the *immutable* upstream id when
43301
+ * one exists (HA `entity.unique_id`, Reolink MAC again — same as `id`
43302
+ * for vendors where MAC is the natural key). For systems where the
43303
+ * live dispatch key can be renamed (HA `entity_id` can be edited),
43304
+ * providers detect renames by matching `uniqueId` and patch `id`
43305
+ * in-place so dispatch keeps working.
43306
+ *
43307
+ * **Display unit and precision are NOT stored here.** They are a read-time
43308
+ * preference (D944). A polymorphic reading stores its `quantity` here once,
43309
+ * at adopt, and a date/time value stores `dateTimeShape` the same way —
43310
+ * neither is repeated on each sample. The `device_class` tag is an
43311
+ * HA-specific input consumed at the discovery boundary (`ha-domain-mapping`)
43312
+ * to derive the CamStack `DeviceRole`; it is never stored after that point.
43313
+ *
43314
+ * The `raw` escape hatch carries provider-specific attributes that don't
43315
+ * fit the structured slots (HA `attributes` whitelist, Reolink `deviceCache`
43316
+ * details, …). Providers control what lands here.
43317
+ */
43318
+ var SourceInfoSchema = object({
43319
+ /** Live dispatch key — mutable when the source system allows rename. */
43320
+ id: string(),
43321
+ /** Source system tag — e.g. 'homeassistant' | 'reolink' | 'onvif'. */
43322
+ system: string(),
43323
+ /** Immutable upstream identifier when available (HA `unique_id`, … ).
43324
+ * Used to detect rename when `id` changes. */
43325
+ uniqueId: string().optional(),
43326
+ /** Quantity of a polymorphic reading, written once at adopt (D944). */
43327
+ quantity: ReadingQuantitySchema.optional(),
43328
+ /** Date / time / datetime shape of a string reading, written once at adopt. */
43329
+ dateTimeShape: _enum([
43330
+ "date",
43331
+ "time",
43332
+ "datetime"
43333
+ ]).optional(),
43334
+ /** Provider-specific extras that don't fit the structured slots.
43335
+ * Whitelist what goes here per provider — do NOT dump entire HA
43336
+ * attribute blobs (would explode the meta JSON column). */
43337
+ raw: record(string(), unknown()).optional()
43338
+ });
43339
+ /**
43220
43340
  * A number a person types for a physical quantity — the input side of the
43221
43341
  * value + unit contract (D972).
43222
43342
  *
@@ -44995,15 +45115,28 @@ var SettingsSchemaWithValuesSchema = object({
44995
45115
  });
44996
45116
  /** Patch object — keys are field names, values are the new field values. */
44997
45117
  var SettingsPatchSchema = record(string(), unknown());
45118
+ /** The scope of a scoped-settings call (D986): where the capability declared the values. */
45119
+ var ScopedSettingsScopeSchema = _enum(SCOPED_SETTINGS_SCOPES);
45120
+ /** One scoped schema an addon serves: its capability, scope and section ids. */
45121
+ var ScopedSettingsDeclarationSchema = object({
45122
+ cap: string(),
45123
+ scope: ScopedSettingsScopeSchema,
45124
+ sectionIds: array(string())
45125
+ });
44998
45126
  /** Standard success response for update operations. */
44999
45127
  var SettingsUpdateResultSchema = object({ success: literal(true) });
45000
45128
  method(object({
45001
45129
  addonId: string(),
45002
- nodeId: string().optional(),
45003
- overlay: record(string(), unknown()).optional(),
45004
- cap: string().optional()
45130
+ cap: string(),
45131
+ scope: ScopedSettingsScopeSchema,
45132
+ nodeId: string().optional()
45005
45133
  }), SettingsSchemaWithValuesSchema.nullable()), method(object({
45006
45134
  addonId: string(),
45135
+ nodeId: string().optional()
45136
+ }), array(ScopedSettingsDeclarationSchema).nullable()), method(object({
45137
+ addonId: string(),
45138
+ cap: string(),
45139
+ scope: ScopedSettingsScopeSchema,
45007
45140
  nodeId: string().optional(),
45008
45141
  patch: SettingsPatchSchema
45009
45142
  }), SettingsUpdateResultSchema, {
@@ -45011,8 +45144,10 @@ method(object({
45011
45144
  auth: "admin"
45012
45145
  }), method(object({
45013
45146
  addonId: string(),
45147
+ cap: string(),
45148
+ scope: ScopedSettingsScopeSchema,
45014
45149
  nodeId: string().optional()
45015
- }), SettingsSchemaWithValuesSchema.nullable()), method(object({
45150
+ }), record(string(), unknown()).nullable()), method(object({
45016
45151
  addonId: string(),
45017
45152
  nodeId: string().optional(),
45018
45153
  instance: IntegrationInstanceRefSchema
@@ -46352,7 +46487,7 @@ var BackupDestinationInfoSchema = object({
46352
46487
  id: string(),
46353
46488
  /**
46354
46489
  * Manifest id of the owning addon. The Settings button on the
46355
- * destination card opens that addon's `globalSettingsSchema` panel.
46490
+ * destination card opens that addon's scoped settings panel.
46356
46491
  */
46357
46492
  addonId: string(),
46358
46493
  /** Operator-toggled enable flag from the destination-policy table. */
@@ -48935,7 +49070,7 @@ DeviceType.MediaPlayer, method(deviceOnly, _void(), {
48935
49070
  kind: "mutation",
48936
49071
  auth: "protected"
48937
49072
  });
48938
- 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;
49073
+ 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;
48939
49074
  var NUMBER = {
48940
49075
  kind: "fixed",
48941
49076
  result: ["number"]
@@ -50855,6 +50990,7 @@ var deviceExportCapability = {
50855
50990
  })
50856
50991
  }
50857
50992
  };
50993
+ var DeviceAliasSchema = string().max(64).regex(/^[a-z][a-z0-9_]*$/);
50858
50994
  /**
50859
50995
  * A SITE ZONE — a named part of the property that several locations belong to.
50860
50996
  *
@@ -51248,6 +51384,12 @@ var DeviceInfoSchema = object({
51248
51384
  addonId: string(),
51249
51385
  type: _enum(DeviceType),
51250
51386
  name: string(),
51387
+ /** The name a value template uses for this device (`{{ stufa_veranda.temperature }}`),
51388
+ * entity_id style. Generated once from the name at first registration, unique
51389
+ * cluster-wide, editable through `setAlias`, NOT changed by a rename (D1021).
51390
+ * Optional: a record produced by an older build omits it until the boot
51391
+ * backfill has run. */
51392
+ alias: DeviceAliasSchema.optional(),
51251
51393
  /** Operator-organisational location label. `null` when unset. */
51252
51394
  location: string().nullable(),
51253
51395
  /** Soft-disabled flag. */
@@ -51567,6 +51709,25 @@ method(object({
51567
51709
  }), _void(), {
51568
51710
  kind: "mutation",
51569
51711
  auth: "admin"
51712
+ }), method(object({
51713
+ deviceId: number(),
51714
+ alias: string()
51715
+ }), discriminatedUnion("ok", [object({
51716
+ ok: literal(true),
51717
+ alias: DeviceAliasSchema
51718
+ }), object({
51719
+ ok: literal(false),
51720
+ reason: _enum([
51721
+ "empty",
51722
+ "too-long",
51723
+ "grammar",
51724
+ "reserved",
51725
+ "taken"
51726
+ ]),
51727
+ takenBy: number().optional()
51728
+ })]), {
51729
+ kind: "mutation",
51730
+ auth: "admin"
51570
51731
  }), method(object({
51571
51732
  deviceId: number(),
51572
51733
  location: string().nullable()
@@ -54688,10 +54849,11 @@ var IntegrationInstanceDescriptionSchema = object({
54688
54849
  /** True when `testInstance` really probes the remote. */
54689
54850
  canTest: boolean(),
54690
54851
  /**
54691
- * The kinds an instance can be of. Absent or one entry: nothing to choose; more than one: the
54692
- * Add flow asks which first and sends it as `createInstance.kind`.
54852
+ * The kinds an instance can be of (D1013 rule 1), each naming its `functionCap`. One entry:
54853
+ * nothing to choose; more than one: the Add flow asks which first and sends it as
54854
+ * `createInstance.kind`. Never empty: every instance belongs to exactly one kind.
54693
54855
  */
54694
- kinds: array(IntegrationInstanceKindSchema).optional(),
54856
+ kinds: array(IntegrationInstanceKindSchema).min(1),
54695
54857
  /**
54696
54858
  * The provider accepts `createInstance.id` for an id that once existed (an adopted id, because
54697
54859
  * devices carry it). The UI then offers "restore under its old id" on Add. Absent means no.
@@ -54727,8 +54889,8 @@ var IntegrationInstanceSchema = object({
54727
54889
  * the body is the one store, `setInstanceEnabled` the one writer (epic #440, step 3).
54728
54890
  */
54729
54891
  enabled: boolean().optional(),
54730
- /** The kind of this instance (one of `describe().kinds[].id`), when the provider has kinds. */
54731
- kind: string().optional(),
54892
+ /** The kind of this instance: exactly one of `describe().kinds[].id` (D1013 rule 2). */
54893
+ kind: string().min(1),
54732
54894
  /** Values for the instance form; a secret is a `SecretFieldView`, never text. */
54733
54895
  formValues: record(string(), unknown()),
54734
54896
  status: IntegrationInstanceStatusSchema.optional(),
@@ -64298,6 +64460,11 @@ var NcScheduleSchema = object({
64298
64460
  * as a STATE SUMMARY at the end of each window of `schedule`.
64299
64461
  */
64300
64462
  var NcSystemEventDeliveryModeSchema = _enum(["instant", "summary"]);
64463
+ _enum([
64464
+ "activation",
64465
+ "deactivation",
64466
+ "schedule"
64467
+ ]);
64301
64468
  /**
64302
64469
  * How a summary window is SENT (D698): `rule` (absent) = ONE notification with
64303
64470
  * every section; `section` = one notification per section with something to
@@ -64314,11 +64481,26 @@ var NcStateSummarySplitSchema = _enum(["rule", "section"]);
64314
64481
  * midnight crossing); the send time is each window's END. Refused on the
64315
64482
  * `alarm` family, which stays instant (`systemEventDeliveryProblems`).
64316
64483
  */
64317
- var NcSystemEventDeliverySchema = discriminatedUnion("mode", [object({ mode: literal("instant") }), object({
64318
- mode: literal("summary"),
64319
- schedule: NcScheduleSchema,
64320
- split: NcStateSummarySplitSchema.optional()
64321
- })]);
64484
+ var NcSystemEventDeliverySchema = discriminatedUnion("mode", [
64485
+ object({ mode: literal("instant") }),
64486
+ object({
64487
+ mode: literal("summary"),
64488
+ schedule: NcScheduleSchema,
64489
+ split: NcStateSummarySplitSchema.optional()
64490
+ }),
64491
+ object({
64492
+ mode: literal("modes"),
64493
+ /** The bad edge, and every kind that has a single edge. */
64494
+ onActivation: boolean(),
64495
+ /** The recovery edges of the classes of the selected kinds (derived, never stored per kind). */
64496
+ onDeactivation: boolean(),
64497
+ /** A state summary at the end of each window; absent = no summary. */
64498
+ onSchedule: object({
64499
+ schedule: NcScheduleSchema,
64500
+ grouping: NcStateSummarySplitSchema
64501
+ }).optional()
64502
+ })
64503
+ ]);
64322
64504
  /** Fuzzy plate matcher — OCR noise makes exact match useless (spec row 12/13). */
64323
64505
  var NcPlateMatcherSchema = object({
64324
64506
  /**
@@ -71661,6 +71843,7 @@ var RemoteLayoutComponentSchema = object({
71661
71843
  });
71662
71844
  });
71663
71845
  method(object({}), array(RemoteLayoutComponentSchema), { auth: "protected" });
71846
+ DeviceType.MediaPlayer;
71664
71847
  var RunningStateSourceSchema = _enum(["native", "assigned"]);
71665
71848
  object({
71666
71849
  /** null = unknown — never coerced to false (D393). */
@@ -74082,7 +74265,7 @@ var TerminalInstanceInfoSchema = object({
74082
74265
  /**
74083
74266
  * False while the node the instance is bound to is not in the cluster
74084
74267
  * topology (forgotten, renamed, re-paired). The instance is kept; the
74085
- * operator re-points it with `updateInstance({ targetNodeId })`.
74268
+ * operator re-points it on the Terminal page.
74086
74269
  */
74087
74270
  nodeInCluster: boolean(),
74088
74271
  profileId: string(),
@@ -74120,41 +74303,7 @@ var TerminalOutputBatchSchema = object({
74120
74303
  snapshot: string().optional(),
74121
74304
  events: array(TerminalOutputEventSchema).readonly()
74122
74305
  });
74123
- method(_void(), array(TerminalProfileInfoSchema).readonly(), { auth: "admin" }), method(_void(), array(TerminalInstanceInfoSchema).readonly(), { auth: "admin" }), method(object({
74124
- targetNodeId: string().min(1),
74125
- profileId: string().min(1),
74126
- name: string().trim().min(1).max(160).optional(),
74127
- executable: string().max(1024).optional(),
74128
- args: array(string().max(2048)).max(64).optional(),
74129
- cwd: string().max(1024).optional(),
74130
- environment: array(string().max(4096)).max(64).optional(),
74131
- profileSettings: ProfileSettingsBagSchema.optional()
74132
- }), TerminalInstanceInfoSchema, {
74133
- kind: "mutation",
74134
- auth: "admin"
74135
- }), method(object({
74136
- instanceId: string().min(1),
74137
- /** Re-point the instance to another node; the profile must exist there. */
74138
- targetNodeId: string().min(1).max(256).optional(),
74139
- name: string().trim().min(1).max(160).optional(),
74140
- executable: string().max(1024).optional(),
74141
- args: array(string().max(2048)).max(64).optional(),
74142
- cwd: string().max(1024).optional(),
74143
- environment: array(string().max(4096)).max(64).optional(),
74144
- profileSettings: ProfileSettingsBagSchema.optional()
74145
- }), TerminalInstanceInfoSchema, {
74146
- kind: "mutation",
74147
- auth: "admin"
74148
- }), method(object({ instanceId: string().min(1) }), _void(), {
74149
- kind: "mutation",
74150
- auth: "admin"
74151
- }), method(object({
74152
- instanceId: string().min(1),
74153
- enabled: boolean()
74154
- }), TerminalInstanceInfoSchema, {
74155
- kind: "mutation",
74156
- auth: "admin"
74157
- }), method(_void(), array(TerminalLegacyCameraSchema).readonly(), { auth: "admin" }), method(object({
74306
+ method(_void(), array(TerminalProfileInfoSchema).readonly(), { auth: "admin" }), method(_void(), array(TerminalLegacyCameraSchema).readonly(), { auth: "admin" }), method(object({
74158
74307
  stableId: string().min(1),
74159
74308
  name: string().trim().min(1).max(160).optional()
74160
74309
  }), TerminalInstanceInfoSchema, {
@@ -74223,6 +74372,11 @@ var TimedRunUnitSchema = _enum(["s", "min"]);
74223
74372
  _enum(["switch", "pet-fountain"]);
74224
74373
  DeviceType.Heater, DeviceType.PetFountain;
74225
74374
  DeviceType.Heater, DeviceType.PetFountain;
74375
+ /** One duration, as the one-tap run asks for it. */
74376
+ var TimedRunQuickRunSchema = object({
74377
+ duration: number().positive().finite(),
74378
+ unit: TimedRunUnitSchema
74379
+ });
74226
74380
  /** Why a request was not carried out. Typed, so a caller can say it in words. */
74227
74381
  var TimedRunRefusalSchema = _enum([
74228
74382
  "unsupported-device",
@@ -74243,9 +74397,30 @@ object({
74243
74397
  activeUntil: number().nullable(),
74244
74398
  /** Who asked for the run (a user id or an addon id); `null` when nothing is armed or it did not say. */
74245
74399
  requestedBy: string().nullable(),
74400
+ /**
74401
+ * The one-tap run of THIS device: what a "Run" button on any surface starts. `null` when
74402
+ * the device is gone or its type has no timed run; a status from before this field
74403
+ * existed has none, and a surface falls back to the type's default.
74404
+ */
74405
+ quickRun: TimedRunQuickRunSchema.nullable(),
74246
74406
  lastFetchedAt: number()
74247
74407
  });
74248
- method(object({
74408
+ /** What the settings form needs: the unit, the bounds and the type's default. */
74409
+ var TimedRunOptionsSchema = object({
74410
+ unit: TimedRunUnitSchema,
74411
+ /** The longest run, in `unit`. */
74412
+ maxDuration: number(),
74413
+ defaultDuration: number()
74414
+ });
74415
+ /** The one-tap run duration, in the type's unit; `null` returns to the type's default. */
74416
+ var TimedRunSettingsPatchSchema = object({ quickRunDuration: number().positive().finite().nullable().optional() });
74417
+ method(object({ deviceId: number().int() }), TimedRunOptionsSchema), method(object({
74418
+ deviceId: number().int(),
74419
+ settings: TimedRunSettingsPatchSchema
74420
+ }), _void(), {
74421
+ kind: "mutation",
74422
+ auth: "admin"
74423
+ }), method(object({
74249
74424
  deviceId: number().int(),
74250
74425
  duration: number().positive().finite(),
74251
74426
  unit: TimedRunUnitSchema
@@ -76951,21 +77126,28 @@ Object.freeze({
76951
77126
  access: "view",
76952
77127
  role: "admin"
76953
77128
  },
76954
- "addonSettings.getGlobalSettings": {
77129
+ "addonSettings.getIntegrationFormSchema": {
76955
77130
  capName: "addon-settings",
76956
77131
  capScope: "system",
76957
77132
  addonId: null,
76958
77133
  access: "view",
76959
77134
  role: "admin"
76960
77135
  },
76961
- "addonSettings.getIntegrationFormSchema": {
77136
+ "addonSettings.getScopedSettings": {
77137
+ capName: "addon-settings",
77138
+ capScope: "system",
77139
+ addonId: null,
77140
+ access: "view",
77141
+ role: "admin"
77142
+ },
77143
+ "addonSettings.listScopedSettings": {
76962
77144
  capName: "addon-settings",
76963
77145
  capScope: "system",
76964
77146
  addonId: null,
76965
77147
  access: "view",
76966
77148
  role: "admin"
76967
77149
  },
76968
- "addonSettings.getIntegrationSettings": {
77150
+ "addonSettings.readScopedValues": {
76969
77151
  capName: "addon-settings",
76970
77152
  capScope: "system",
76971
77153
  addonId: null,
@@ -76986,7 +77168,7 @@ Object.freeze({
76986
77168
  access: "create",
76987
77169
  role: "admin"
76988
77170
  },
76989
- "addonSettings.updateGlobalSettings": {
77171
+ "addonSettings.updateScopedSettings": {
76990
77172
  capName: "addon-settings",
76991
77173
  capScope: "system",
76992
77174
  addonId: null,
@@ -79156,6 +79338,13 @@ Object.freeze({
79156
79338
  access: "create",
79157
79339
  role: "admin"
79158
79340
  },
79341
+ "deviceManager.setAlias": {
79342
+ capName: "device-manager",
79343
+ capScope: "system",
79344
+ addonId: null,
79345
+ access: "create",
79346
+ role: "admin"
79347
+ },
79159
79348
  "deviceManager.setChildLayout": {
79160
79349
  capName: "device-manager",
79161
79350
  capScope: "system",
@@ -85883,27 +86072,6 @@ Object.freeze({
85883
86072
  access: "create",
85884
86073
  role: "admin"
85885
86074
  },
85886
- "terminalSession.createInstance": {
85887
- capName: "terminal-session",
85888
- capScope: "system",
85889
- addonId: null,
85890
- access: "create",
85891
- role: "admin"
85892
- },
85893
- "terminalSession.deleteInstance": {
85894
- capName: "terminal-session",
85895
- capScope: "system",
85896
- addonId: null,
85897
- access: "delete",
85898
- role: "admin"
85899
- },
85900
- "terminalSession.listInstances": {
85901
- capName: "terminal-session",
85902
- capScope: "system",
85903
- addonId: null,
85904
- access: "view",
85905
- role: "admin"
85906
- },
85907
86075
  "terminalSession.listLegacyCameras": {
85908
86076
  capName: "terminal-session",
85909
86077
  capScope: "system",
@@ -85946,20 +86114,6 @@ Object.freeze({
85946
86114
  access: "create",
85947
86115
  role: "admin"
85948
86116
  },
85949
- "terminalSession.setInstanceEnabled": {
85950
- capName: "terminal-session",
85951
- capScope: "system",
85952
- addonId: null,
85953
- access: "create",
85954
- role: "admin"
85955
- },
85956
- "terminalSession.updateInstance": {
85957
- capName: "terminal-session",
85958
- capScope: "system",
85959
- addonId: null,
85960
- access: "create",
85961
- role: "admin"
85962
- },
85963
86117
  "terminalSession.writeInput": {
85964
86118
  capName: "terminal-session",
85965
86119
  capScope: "system",
@@ -85974,6 +86128,13 @@ Object.freeze({
85974
86128
  access: "create",
85975
86129
  role: "viewer"
85976
86130
  },
86131
+ "timedRun.getOptions": {
86132
+ capName: "timed-run",
86133
+ capScope: "device",
86134
+ addonId: null,
86135
+ access: "view",
86136
+ role: "viewer"
86137
+ },
85977
86138
  "timedRun.getStatus": {
85978
86139
  capName: "timed-run",
85979
86140
  capScope: "device",
@@ -85988,6 +86149,13 @@ Object.freeze({
85988
86149
  access: "create",
85989
86150
  role: "viewer"
85990
86151
  },
86152
+ "timedRun.setSettings": {
86153
+ capName: "timed-run",
86154
+ capScope: "device",
86155
+ addonId: null,
86156
+ access: "create",
86157
+ role: "admin"
86158
+ },
85991
86159
  "toast.onToast": {
85992
86160
  capName: "toast",
85993
86161
  capScope: "system",
@@ -86943,6 +87111,7 @@ function applianceExport(ecosystem, deviceType) {
86943
87111
  if (!isPlugApplianceType(deviceType)) return null;
86944
87112
  return APPLIANCE_EXPORT[ecosystem][deviceType];
86945
87113
  }
87114
+ string().min(1).max(4096);
86946
87115
  Object.freeze({
86947
87116
  "accessories.getStatus": [{
86948
87117
  name: "deviceId",
@@ -87626,6 +87795,11 @@ Object.freeze({
87626
87795
  form: "single",
87627
87796
  optional: false
87628
87797
  }],
87798
+ "deviceManager.setAlias": [{
87799
+ name: "deviceId",
87800
+ form: "single",
87801
+ optional: false
87802
+ }],
87629
87803
  "deviceManager.setChildLayout": [{
87630
87804
  name: "deviceId",
87631
87805
  form: "single",
@@ -89690,6 +89864,11 @@ Object.freeze({
89690
89864
  form: "single",
89691
89865
  optional: false
89692
89866
  }],
89867
+ "timedRun.getOptions": [{
89868
+ name: "deviceId",
89869
+ form: "single",
89870
+ optional: false
89871
+ }],
89693
89872
  "timedRun.getStatus": [{
89694
89873
  name: "deviceId",
89695
89874
  form: "single",
@@ -89700,6 +89879,11 @@ Object.freeze({
89700
89879
  form: "single",
89701
89880
  optional: false
89702
89881
  }],
89882
+ "timedRun.setSettings": [{
89883
+ name: "deviceId",
89884
+ form: "single",
89885
+ optional: false
89886
+ }],
89703
89887
  "update.getStatus": [{
89704
89888
  name: "deviceId",
89705
89889
  form: "single",
@@ -90562,6 +90746,7 @@ var STATE_SUMMARY_VARS = [
90562
90746
  [...RULE_TEXT],
90563
90747
  [...RULE_TEXT],
90564
90748
  [...RULE_TEXT],
90749
+ [...RULE_TEXT],
90565
90750
  [...RULE_BODY_ONLY],
90566
90751
  [...RULE_TEXT],
90567
90752
  ([...RULE_TEXT], [...DEVICE_EVENTS]),
@@ -92980,7 +93165,13 @@ var ExportGoogleAddon = class extends BaseAddon {
92980
93165
  role: "services",
92981
93166
  instanceMode: "multiple",
92982
93167
  kind: "homes",
92983
- canTest: false
93168
+ canTest: false,
93169
+ kinds: [{
93170
+ id: "homes",
93171
+ label: "Google Home",
93172
+ functionCap: "device-export",
93173
+ role: "services"
93174
+ }]
92984
93175
  },
92985
93176
  formSchema: (id) => this.homeForm(id),
92986
93177
  initialBody: (name) => ({ name }),