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