@camstack/addon-export-hap 1.2.195 → 1.2.197

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.
@@ -49,7 +49,7 @@ let node_fs_promises = require("node:fs/promises");
49
49
  node_fs_promises = __toESM(node_fs_promises, 1);
50
50
  let node_events = require("node:events");
51
51
  let node_dgram = require("node:dgram");
52
- //#region ../types/dist/event-category-BmPm98n0.mjs
52
+ //#region ../types/dist/event-category-78tcBemo.mjs
53
53
  var EventCategory = /* @__PURE__ */ function(EventCategory) {
54
54
  EventCategory["SystemBoot"] = "system.boot";
55
55
  EventCategory["SystemAddonsReady"] = "system.addons-ready";
@@ -170,6 +170,23 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
170
170
  */
171
171
  EventCategory["AddonLoadRecovered"] = "addon.load-recovered";
172
172
  /**
173
+ * An addon is RUNNING although its installed package is below what the
174
+ * running server requires (`camstack.requires.addons` of the server, or the
175
+ * addon's own `requires.server`). Raised once per streak by the unsupported-
176
+ * addon tracker, on the hub and on agents; AlertCenter turns it into one
177
+ * operator alert per node and package. The addon is never held back for it.
178
+ *
179
+ * Payload: `{ packageName, addonId, nodeId, installedVersion, requiredMinimum, serverVersion, unmet }`.
180
+ */
181
+ EventCategory["AddonUnsupportedVersion"] = "addon.unsupported-version";
182
+ /**
183
+ * The package of an {@link AddonUnsupportedVersion} alert reached a supported
184
+ * version, or is no longer installed on the node. AlertCenter dismisses the matching alert.
185
+ *
186
+ * Payload: `{ packageName, addonId, nodeId }`.
187
+ */
188
+ EventCategory["AddonUnsupportedResolved"] = "addon.unsupported-resolved";
189
+ /**
173
190
  * Monitor scheduled the next retry for a failed addon. Transient —
174
191
  * surfaced to the UI for live-updating the "next retry in Ns"
175
192
  * countdown on the Addons page row, NOT persisted as an alert.
@@ -280,7 +297,7 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
280
297
  EventCategory["ProcessRestarted"] = "process.restarted";
281
298
  /**
282
299
  * The SET of storage locations changed — one was created, edited, enabled,
283
- * disabled or deleted through `storage.upsertLocation` / `deleteLocation`.
300
+ * disabled or deleted through the location instances or the forced-delete action.
284
301
  *
285
302
  * Telemetry, not a transaction (D8/D11): every consumer that re-resolves on
286
303
  * it must also converge on its own periodic path, because a dropped event
@@ -6031,7 +6048,7 @@ var ZodIssueCode = {
6031
6048
  var ZodFirstPartyTypeKind;
6032
6049
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
6033
6050
  //#endregion
6034
- //#region ../types/dist/sleep-D7ZKm4nb.mjs
6051
+ //#region ../types/dist/sleep-CQP-REJp.mjs
6035
6052
  /**
6036
6053
  * The audio chunk plane's byte format, and the ONE expansion from a coded
6037
6054
  * window to float samples (D455).
@@ -6395,6 +6412,59 @@ Object.fromEntries([
6395
6412
  function isValuelessField(field) {
6396
6413
  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";
6397
6414
  }
6415
+ /**
6416
+ * Base collector: flatten a hydrated `ConfigUISchemaWithValues` into
6417
+ * `key → { value, default }`, recursing through `group` and `sub-tabs`
6418
+ * layout fields. Keeping `value` and `default` SEPARATE (rather than
6419
+ * pre-resolving) lets callers both read the effective value AND detect
6420
+ * overrides (`value` differs from `default`). Structural over `unknown`;
6421
+ * malformed input yields an empty map, never throws.
6422
+ */
6423
+ function collectHydratedFieldEntries(schema) {
6424
+ const out = /* @__PURE__ */ new Map();
6425
+ if (typeof schema !== "object" || schema === null) return out;
6426
+ const sections = schema.sections;
6427
+ if (!Array.isArray(sections)) return out;
6428
+ for (const section of sections) if (typeof section === "object" && section !== null) collectFieldEntriesInto(section.fields, out);
6429
+ return out;
6430
+ }
6431
+ /** Recursive field walker for {@link collectHydratedFieldEntries}. */
6432
+ function collectFieldEntriesInto(fields, into) {
6433
+ if (!Array.isArray(fields)) return;
6434
+ for (const field of fields) {
6435
+ if (typeof field !== "object" || field === null) continue;
6436
+ const type = field.type;
6437
+ if (type === "group") {
6438
+ collectFieldEntriesInto(field.fields, into);
6439
+ continue;
6440
+ }
6441
+ if (type === "sub-tabs") {
6442
+ const tabs = field.tabs;
6443
+ if (Array.isArray(tabs)) {
6444
+ for (const tab of tabs) if (typeof tab === "object" && tab !== null) collectFieldEntriesInto(tab.fields, into);
6445
+ }
6446
+ continue;
6447
+ }
6448
+ const key = field.key;
6449
+ if (typeof key !== "string" || key.length === 0) continue;
6450
+ if (!("value" in field)) continue;
6451
+ into.set(key, {
6452
+ value: field.value,
6453
+ default: field.default
6454
+ });
6455
+ }
6456
+ }
6457
+ /**
6458
+ * Flatten a hydrated settings payload into `key → EFFECTIVE value`
6459
+ * (`value ?? default`). The read-side inverse of `hydrateSchema` for the
6460
+ * common "just give me the resolved values" case. Built on
6461
+ * {@link collectHydratedFieldEntries}.
6462
+ */
6463
+ function collectHydratedFieldValues(schema) {
6464
+ const out = /* @__PURE__ */ new Map();
6465
+ for (const [key, entry] of collectHydratedFieldEntries(schema)) out.set(key, entry.value ?? entry.default);
6466
+ return out;
6467
+ }
6398
6468
  function hydrateSchema(schema, values, options = {}) {
6399
6469
  return {
6400
6470
  ...schema.tabs ? { tabs: [...schema.tabs] } : {},
@@ -7279,17 +7349,35 @@ var RecordIntegrationInstances = class {
7279
7349
  ...kind !== void 0 ? { kind } : {}
7280
7350
  });
7281
7351
  if (minted === void 0) throw new Error("createInstance needs an id: this provider does not mint one");
7352
+ const initial = this.hooks.initialBody(name, kind);
7353
+ const patch = this.patchOf(values ?? {});
7354
+ if (Object.keys(patch).length > 0) Object.assign(patch, await this.hooks.validateWrite?.({
7355
+ kind,
7356
+ body: {
7357
+ ...initial,
7358
+ ...patch
7359
+ }
7360
+ }));
7282
7361
  await this.handle.put({
7283
7362
  id: minted,
7284
- data: this.hooks.initialBody(name, kind)
7363
+ data: initial
7285
7364
  }, { ifRev: 0 });
7286
- const patch = this.patchOf(values ?? {});
7287
7365
  if (Object.keys(patch).length > 0) await this.handle.patch(minted, patch);
7288
7366
  await this.hooks.onChanged?.(minted, "created");
7289
7367
  return { id: minted };
7290
7368
  };
7291
7369
  updateInstance = async ({ id, name, values }) => {
7292
7370
  const patch = this.patchOf(values);
7371
+ if (this.hooks.validateWrite !== void 0 && Object.keys(patch).length > 0) {
7372
+ const stored = await this.handle.get(id);
7373
+ if (stored !== null) Object.assign(patch, await this.hooks.validateWrite({
7374
+ kind: void 0,
7375
+ body: {
7376
+ ...stored.data,
7377
+ ...patch
7378
+ }
7379
+ }));
7380
+ }
7293
7381
  if (name !== void 0) patch[this.nameField] = name;
7294
7382
  await this.handle.patch(id, patch);
7295
7383
  await this.hooks.onChanged?.(id, "updated");
@@ -7600,6 +7688,21 @@ var SCOPED_SETTINGS_SCOPES = [
7600
7688
  "device-defaults",
7601
7689
  "node"
7602
7690
  ];
7691
+ /** The one refusal of a key a scope did not declare. */
7692
+ function assertDeclaredKeys(keys, declared) {
7693
+ const undeclared = keys.filter((key) => !declared.has(key));
7694
+ if (undeclared.length > 0) throw new Error(`scoped settings: [${undeclared.join(", ")}] not declared for this scope (declared: [${[...declared].join(", ")}])`);
7695
+ }
7696
+ /** Build the handle over an addon's scoped read, write and unset. */
7697
+ function createScopedSettings(deps) {
7698
+ return {
7699
+ async get() {
7700
+ return deps.schema.parse(await deps.read());
7701
+ },
7702
+ patch: (patch) => deps.write(Object.fromEntries(Object.entries(patch))),
7703
+ unset: (keys) => deps.unset(keys)
7704
+ };
7705
+ }
7603
7706
  /** A write to a secret path could not be stored in the keychain, so it was refused. */
7604
7707
  var KeychainWriteRefusedError = class extends Error {
7605
7708
  fieldPath;
@@ -8175,7 +8278,16 @@ function createHandle(raw, opts) {
8175
8278
  return blob;
8176
8279
  }
8177
8280
  },
8178
- writeAddonStore: writeAddon
8281
+ writeAddonStore: writeAddon,
8282
+ removeClearedKeys: (keys) => serialize("addon", async () => {
8283
+ const stored = await readStoredAddonBlob(raw);
8284
+ index.seen("addon", stored);
8285
+ const removable = keys.filter((key) => collectSecretMarkerRefs(stored[key]).length === 0);
8286
+ if (removable.length === 0) return;
8287
+ const patch = Object.fromEntries(removable.map((key) => [key, void 0]));
8288
+ await raw.writeAddonStore(patch);
8289
+ index.wrote("addon", patch);
8290
+ })
8179
8291
  };
8180
8292
  }
8181
8293
  /** The context the addon sees, plus the private raw view and write outcome. */
@@ -8720,6 +8832,151 @@ var BaseAddon = class {
8720
8832
  }
8721
8833
  }
8722
8834
  /**
8835
+ * Hook: values layered over the stored ones when the FORM of one scope is served
8836
+ * ({@link getScopedSettings}) — a preview that derives dependent options without writing.
8837
+ * Never applied to {@link ScopedSettings.get} or to a write. `null` ⇒ no overlay.
8838
+ */
8839
+ async scopedSettingsOverlay(_scope, _cap, _nodeId) {
8840
+ return null;
8841
+ }
8842
+ /**
8843
+ * Hook: a write of one scope changed stored values (not called when the store reports no change,
8844
+ * e.g. the write-back of a stored secret). `keys` are the bare field keys of the write, node keys included.
8845
+ */
8846
+ async onScopedSettingsChanged(_scope, _cap, _keys) {}
8847
+ /** Typed handle over the CLUSTER settings `cap` declares (`clusterSettingsSchema`). */
8848
+ clusterSettings(cap, schema) {
8849
+ return this.scopedHandle("cluster", cap, schema);
8850
+ }
8851
+ /** Typed handle over the fleet defaults of the per-device settings `cap` declares. */
8852
+ deviceDefaults(cap, schema) {
8853
+ return this.scopedHandle("device-defaults", cap, schema);
8854
+ }
8855
+ /**
8856
+ * Typed handle over the settings `cap` owns PER NODE. `nodeId` omitted ⇒ the local node. A node
8857
+ * with no row yields the schema defaults — never a bare-key fallback.
8858
+ */
8859
+ nodeSettings(cap, schema, nodeId) {
8860
+ return this.scopedHandle("node", cap, schema, nodeId);
8861
+ }
8862
+ /**
8863
+ * {@link state} for a value that is kept per node: stored under `<key>@<nodeId>`, and the
8864
+ * settings store carries `nodeId` in the row data (D986 §1), so a forgotten node's rows go in one
8865
+ * central delete. `nodeId` omitted ⇒ the local node.
8866
+ */
8867
+ nodeState(key, schema, fallback, nodeId) {
8868
+ this._declaredStateKeys.add(key);
8869
+ return createDurableState({
8870
+ key: nodeScopedKey(key, nodeId ?? this._ctx?.kernel?.localNodeId ?? ""),
8871
+ schema,
8872
+ fallback,
8873
+ read: async () => this.resolveStoredSecrets(await this.readAddonStoreWithRetry()),
8874
+ write: async (patch) => {
8875
+ await this._ctx?.settings?.writeAddonStore(patch);
8876
+ },
8877
+ onParseError: (k, e) => this._ctx?.logger?.warn?.(`durable-state: stored "${k}" failed validation — using fallback`, { meta: {
8878
+ addonId: this._ctx?.id,
8879
+ key: k,
8880
+ error: String(e)
8881
+ } })
8882
+ });
8883
+ }
8884
+ /** The loaded schema `cap` declares for `scope`, or `null`. */
8885
+ async declaredScopedSchema(scope, cap) {
8886
+ await this.loadScopedSchemas(cap);
8887
+ return this.loadedScopedSchemas(cap).find((entry) => entry.scope === scope)?.schema ?? null;
8888
+ }
8889
+ async requireScopedSchema(scope, cap) {
8890
+ const schema = await this.declaredScopedSchema(scope, cap);
8891
+ if (schema === null) throw new Error(`${this.constructor.name}: cap "${cap}" declares no ${scope} settings`);
8892
+ return schema;
8893
+ }
8894
+ scopedKeys(schema) {
8895
+ return new Set(schema.sections.flatMap((section) => collectValueFieldKeys(section.fields)));
8896
+ }
8897
+ /** `store` narrowed to the keys `schema` declares. */
8898
+ narrowToScope(store, schema) {
8899
+ const keys = this.scopedKeys(schema);
8900
+ return Object.fromEntries(Object.entries(store).filter(([key]) => keys.has(key)));
8901
+ }
8902
+ scopedHandle(scope, cap, schema, nodeId) {
8903
+ return createScopedSettings({
8904
+ schema,
8905
+ read: async () => {
8906
+ const declared = await this.requireScopedSchema(scope, cap);
8907
+ const stored = this.narrowToScope(await this.resolveGlobalStore(nodeId, cap), declared);
8908
+ const effective = collectHydratedFieldValues(hydrateSchema(declared, stored));
8909
+ return {
8910
+ ...Object.fromEntries([...effective].filter(([, value]) => value !== void 0)),
8911
+ ...stored
8912
+ };
8913
+ },
8914
+ write: (patch) => this.writeScoped(scope, cap, patch, nodeId),
8915
+ unset: (keys) => this.unsetScoped(scope, cap, keys, nodeId)
8916
+ });
8917
+ }
8918
+ /** The one write path of the scoped API: declared keys only, then the global patch. */
8919
+ async writeScoped(scope, cap, patch, nodeId) {
8920
+ assertDeclaredKeys(Object.keys(patch), this.scopedKeys(await this.requireScopedSchema(scope, cap)));
8921
+ if (await this.applyGlobalPatch(patch, scope === "node" ? nodeId : void 0, cap)) await this.onScopedSettingsChanged(scope, cap, Object.keys(patch));
8922
+ }
8923
+ /**
8924
+ * Remove declared keys of one scope. A secret goes through {@link clearSecrets} — its keychain
8925
+ * value is released exactly as there — and the emptied row is then removed; every other key is
8926
+ * removed by an `undefined` patch (which a secret transform would read as "keep").
8927
+ */
8928
+ async unsetScoped(scope, cap, keys, nodeId) {
8929
+ assertDeclaredKeys(keys, this.scopedKeys(await this.requireScopedSchema(scope, cap)));
8930
+ const target = scope === "node" ? nodeId : void 0;
8931
+ const tree = this.addonSecretTree();
8932
+ const secretKeys = keys.filter((key) => tree.has(key));
8933
+ const plainKeys = keys.filter((key) => !tree.has(key));
8934
+ let changed = false;
8935
+ if (plainKeys.length > 0) {
8936
+ const patch = Object.fromEntries(plainKeys.map((key) => [key, void 0]));
8937
+ changed = await this.applyGlobalPatch(patch, target, cap) || changed;
8938
+ }
8939
+ if (secretKeys.length > 0) {
8940
+ await this.clearSecretKeys(secretKeys, target, cap);
8941
+ const node = normalizeNodeId(target ?? this._ctx?.kernel?.localNodeId);
8942
+ const rows = secretKeys.map((key) => scope === "node" ? nodeScopedKey(key, node) : key);
8943
+ if (this._secretSettings !== null) await this._secretSettings.removeClearedKeys(rows);
8944
+ else await this._ctx?.settings?.writeAddonStore(Object.fromEntries(rows.map((row) => [row, void 0])));
8945
+ changed = true;
8946
+ }
8947
+ if (changed) await this.onScopedSettingsChanged(scope, cap, [...keys]);
8948
+ }
8949
+ /**
8950
+ * The hydrated form of one scope of one capability's settings (any
8951
+ * {@link scopedSettingsOverlay} applied), or `null` when the capability declares nothing there.
8952
+ */
8953
+ async getScopedSettings(scope, cap, nodeId) {
8954
+ const schema = await this.declaredScopedSchema(scope, cap);
8955
+ if (schema === null) return null;
8956
+ const stored = this.narrowToScope(await this.readRawProjectedStore(nodeId, cap), schema);
8957
+ const overlay = await this.scopedSettingsOverlay(scope, cap, nodeId);
8958
+ return hydrateSchema(schema, overlay ? await this.overlayKeepingMarkers(stored, overlay) : stored, { inlineSecretsAsViews: true });
8959
+ }
8960
+ /** The OPERATOR's write of declared keys of one scope (D787 secret semantics). */
8961
+ async updateScopedSettings(scope, cap, patch, nodeId) {
8962
+ this._operatorWriteDepth++;
8963
+ try {
8964
+ await this.writeScoped(scope, cap, patch, nodeId);
8965
+ } finally {
8966
+ this._operatorWriteDepth--;
8967
+ }
8968
+ }
8969
+ /**
8970
+ * The effective values (`stored ?? default`) of one scope, a secret as its `set` view — never
8971
+ * its value. `null` when the capability declares nothing for the scope.
8972
+ */
8973
+ async readScopedValues(scope, cap, nodeId) {
8974
+ const schema = await this.declaredScopedSchema(scope, cap);
8975
+ if (schema === null) return null;
8976
+ const form = hydrateSchema(schema, this.narrowToScope(await this.readRawProjectedStore(nodeId, cap), schema), { inlineSecretsAsViews: true });
8977
+ return Object.fromEntries([...collectHydratedFieldValues(form)].filter(([, value]) => value !== void 0));
8978
+ }
8979
+ /**
8723
8980
  * What the create wizard and the integration edit page render for one instance: the addon's
8724
8981
  * per-instance schema when it declares one, else its global schema (what they always showed).
8725
8982
  */
@@ -8871,6 +9128,9 @@ var BaseAddon = class {
8871
9128
  * a keychain (an older kernel) it writes `''`, as such code always did.
8872
9129
  */
8873
9130
  async clearSecrets(keys, nodeId) {
9131
+ await this.clearSecretKeys(keys, nodeId);
9132
+ }
9133
+ async clearSecretKeys(keys, nodeId, cap) {
8874
9134
  const tree = this.addonSecretTree();
8875
9135
  const keychain = this._ctx?.secrets !== void 0;
8876
9136
  const stored = keychain ? await this.readAddonStoreWithRetry() : {};
@@ -8883,25 +9143,27 @@ var BaseAddon = class {
8883
9143
  const keychainStored = tree.has(key) || collectSecretMarkerRefs(stored[key]).length > 0;
8884
9144
  patch[key] = keychain && keychainStored ? SECRET_CLEAR : "";
8885
9145
  }
8886
- await this.applyGlobalPatch(patch, nodeId);
9146
+ await this.applyGlobalPatch(patch, nodeId, cap);
8887
9147
  }
8888
- async applyGlobalPatch(barePatch, nodeId) {
8889
- await this.loadScopedSchemas();
8890
- const keys = this.perNodeKeys();
9148
+ /** Resolves `true` when the write changed stored values. */
9149
+ async applyGlobalPatch(barePatch, nodeId, cap) {
9150
+ await this.loadScopedSchemas(cap);
9151
+ const keys = this.perNodeKeys(cap);
8891
9152
  const localNode = normalizeNodeId(this._ctx?.kernel?.localNodeId);
8892
9153
  const target = normalizeNodeId(nodeId ?? this._ctx?.kernel?.localNodeId);
8893
9154
  const scoped = keys.size > 0 ? scopePatch(barePatch, keys, target) : barePatch;
8894
9155
  const handle = this._secretSettings;
8895
9156
  if (handle !== null) {
8896
9157
  const { changed } = await handle.writeAddonStore(scoped);
8897
- if (!changed) return;
9158
+ if (!changed) return false;
8898
9159
  } else await this._ctx?.settings?.writeAddonStore(scoped);
8899
- if (target !== localNode) return;
9160
+ if (target !== localNode) return true;
8900
9161
  await this.resolveConfig();
8901
9162
  await this.onConfigChanged();
8902
9163
  this.emitLifecycle(EventCategory.AddonUpdated, { level: "global" });
8903
9164
  const legacy = this.globalSettingsSchema();
8904
9165
  this.maybeAutoRestart(Object.keys(barePatch), [...legacy === null ? [] : [legacy], ...this.loadedScopedSchemas().map((entry) => entry.schema)]);
9166
+ return true;
8905
9167
  }
8906
9168
  /**
8907
9169
  * The set of field keys the global settings schema declares `perNode: true`
@@ -10697,7 +10959,6 @@ var CAP_NAMES = Object.freeze([
10697
10959
  "notifier",
10698
10960
  "numeric-sensor",
10699
10961
  "oauth-integration",
10700
- "oidc-connections",
10701
10962
  "osd",
10702
10963
  "osd-manager",
10703
10964
  "pet-feeder",
@@ -12589,8 +12850,7 @@ Object.freeze({
12589
12850
  "device-provider": { "reloadDevice": 18e4 },
12590
12851
  "llm": {
12591
12852
  "generate": 6e5,
12592
- "generateVision": 6e5,
12593
- "testProfile": 6e5
12853
+ "generateVision": 6e5
12594
12854
  },
12595
12855
  "llm-runtime": {
12596
12856
  "complete": 6e5,
@@ -14589,17 +14849,18 @@ var IntegrationInstanceRefSchema = object({
14589
14849
  * message to what the kind supports — callers never special-case a service.
14590
14850
  *
14591
14851
  * DESIGN DECISIONS (locked):
14592
- * - Target CRUD lives on THIS cap (`upsertTarget` / `deleteTarget` /
14593
- * `setTargetEnabled`), each provider persisting via the `settings-store`
14594
- * cap. Rationale: the admin UI needs one uniform surface across the
14595
- * notifiers addon AND the HA addon; the addon-`globalSettingsSchema`-array
14596
- * alternative would fork the UI per addon and cannot host the
14597
- * discovery→adopt flow.
14598
- * - `listTargetKinds` / `listTargets` / `discoverTargets` return arrays →
14599
- * the generated cap-mount auto-`concatCollection`-fans them across every
14600
- * registered provider (notifiers addon + HA addon) so one catalog is
14601
- * routable. `send` / `testTarget` / CRUD route to ONE provider by the
14602
- * `addonId` the generated collection router extracts from the call input.
14852
+ * - A target is an INSTANCE of this function cap (epic #440, step 6): the
14853
+ * providers serve their targets as `integration-instances` records, one
14854
+ * record kind per target kind, and the admin lists, adds, edits, switches
14855
+ * and deletes them through that cap. This cap keeps what an instance cannot
14856
+ * say: the kind catalogue (`listTargetKinds`: capabilities, delivery
14857
+ * parameters, brand icon), dispatch (`send`, `testTarget`) and the form
14858
+ * helpers (`discoverTargets`, `probeTargetConfig`).
14859
+ * - `listTargetKinds` / `discoverTargets` return arrays → the generated
14860
+ * cap-mount auto-`concatCollection`-fans them across every registered
14861
+ * provider so one catalog is routable. `send` / `testTarget` /
14862
+ * `probeTargetConfig` route to ONE provider by the `addonId` the generated
14863
+ * collection router extracts from the call input.
14603
14864
  * - `Attachment.bytes` is `Uint8Array`. Transport-safe: superjson (the tRPC
14604
14865
  * transformer) + UDS MsgPack both round-trip typed arrays — already used by
14605
14866
  * `storage` / `storage-provider` / `recording` caps over the same path. No
@@ -14844,7 +15105,7 @@ var TargetKindCapsSchema = object({
14844
15105
  * the union is large and not meant for runtime validation here; the exported
14845
15106
  * `TargetKind` type re-tightens `configSchema` to `ConfigUISchema`.
14846
15107
  */
14847
- var ConfigSchemaPassthrough$4 = unknown();
15108
+ var ConfigSchemaPassthrough$3 = unknown();
14848
15109
  var TargetKindSchema = object({
14849
15110
  kind: string(),
14850
15111
  label: string(),
@@ -14881,7 +15142,7 @@ var TargetKindSchema = object({
14881
15142
  * its raster path, which is the safe default for an unknown image.
14882
15143
  */
14883
15144
  iconMediaType: string().optional(),
14884
- configSchema: ConfigSchemaPassthrough$4,
15145
+ configSchema: ConfigSchemaPassthrough$3,
14885
15146
  /**
14886
15147
  * The config keys that decide WHERE this kind's secrets are sent (server,
14887
15148
  * base URL, instance, chat, recipient). A save that changes any of them
@@ -14903,9 +15164,11 @@ var TargetKindSchema = object({
14903
15164
  caps: TargetKindCapsSchema
14904
15165
  });
14905
15166
  /**
14906
- * A persisted target. `config` holds secrets; providers REDACT secret fields
14907
- * (return a presence marker only) when serving `listTargets` — never
14908
- * round-trip a stored secret to the UI.
15167
+ * A target as a provider's own code sees it (the notification-center bridge, the
15168
+ * send path): the flat record body split into the name, the switch and the
15169
+ * kind's fields. `config` holds secrets; a reader that serves it to a client
15170
+ * REDACTS secret fields (a presence marker only) — never round-trip a stored
15171
+ * secret to the UI.
14909
15172
  */
14910
15173
  var TargetSchema = object({
14911
15174
  id: string(),
@@ -14948,13 +15211,13 @@ var ProbeTargetConfigResultSchema = object({
14948
15211
  stateInstance: string().optional(),
14949
15212
  error: string().optional()
14950
15213
  });
14951
- method(object({}), array(TargetKindSchema)), method(object({}), array(TargetSchema), { auth: "admin" }), method(object({ targetId: string() }), TargetSchema, { auth: "admin" }), method(object({
15214
+ method(object({}), array(TargetKindSchema)), method(object({
14952
15215
  kind: string(),
14953
15216
  config: record(string(), unknown()).optional(),
14954
15217
  /**
14955
15218
  * When editing / duplicating, the blank password field never round-trips
14956
15219
  * the stored token. Pass the source target id so the provider can restore
14957
- * secrets server-side before dialling (same merge as upsert).
15220
+ * secrets server-side before dialling.
14958
15221
  */
14959
15222
  targetId: string().optional()
14960
15223
  }), array(DiscoveredTargetSchema), { auth: "admin" }), method(object({
@@ -14977,27 +15240,6 @@ method(object({}), array(TargetKindSchema)), method(object({}), array(TargetSche
14977
15240
  }), TestResultSchema, {
14978
15241
  kind: "mutation",
14979
15242
  auth: "admin"
14980
- }), method(object({
14981
- target: TargetSchema,
14982
- /**
14983
- * Duplicate flow: create a NEW target id while copying secrets from an
14984
- * existing row. The UI never holds the stored token; blank / redacted
14985
- * password fields are restored from this source (D634 still applies if
14986
- * destinations diverge without a re-typed secret).
14987
- */
14988
- cloneSecretsFrom: string().optional()
14989
- }), TargetSchema, {
14990
- kind: "mutation",
14991
- auth: "admin"
14992
- }), method(object({ targetId: string() }), _void(), {
14993
- kind: "mutation",
14994
- auth: "admin"
14995
- }), method(object({
14996
- targetId: string(),
14997
- enabled: boolean()
14998
- }), _void(), {
14999
- kind: "mutation",
15000
- auth: "admin"
15001
15243
  });
15002
15244
  looseObject({
15003
15245
  name: string().min(1),
@@ -23489,7 +23731,6 @@ var SYSTEM_CAP_VOCABULARY = {
23489
23731
  "notification-output": system("notification delivery — reached through notifier devices and rules"),
23490
23732
  "notification-rules": system("notification rules — authored on their own page"),
23491
23733
  "oauth-integration": system(IDENTITY),
23492
- "oidc-connections": system(IDENTITY),
23493
23734
  "osd-manager": system(PIPELINE),
23494
23735
  "pipeline-executor": system(PIPELINE),
23495
23736
  "pipeline-orchestrator": system(PIPELINE),
@@ -45714,6 +45955,8 @@ var SettingsSchemaWithValuesSchema = object({
45714
45955
  });
45715
45956
  /** Patch object — keys are field names, values are the new field values. */
45716
45957
  var SettingsPatchSchema = record(string(), unknown());
45958
+ /** The scope of a scoped-settings call (D986): where the capability declared the values. */
45959
+ var ScopedSettingsScopeSchema = _enum(SCOPED_SETTINGS_SCOPES);
45717
45960
  /** Standard success response for update operations. */
45718
45961
  var SettingsUpdateResultSchema = object({ success: literal(true) });
45719
45962
  method(object({
@@ -45729,6 +45972,25 @@ method(object({
45729
45972
  kind: "mutation",
45730
45973
  auth: "admin"
45731
45974
  }), method(object({
45975
+ addonId: string(),
45976
+ cap: string(),
45977
+ scope: ScopedSettingsScopeSchema,
45978
+ nodeId: string().optional()
45979
+ }), SettingsSchemaWithValuesSchema.nullable()), method(object({
45980
+ addonId: string(),
45981
+ cap: string(),
45982
+ scope: ScopedSettingsScopeSchema,
45983
+ nodeId: string().optional(),
45984
+ patch: SettingsPatchSchema
45985
+ }), SettingsUpdateResultSchema, {
45986
+ kind: "mutation",
45987
+ auth: "admin"
45988
+ }), method(object({
45989
+ addonId: string(),
45990
+ cap: string(),
45991
+ scope: ScopedSettingsScopeSchema,
45992
+ nodeId: string().optional()
45993
+ }), record(string(), unknown()).nullable()), method(object({
45732
45994
  addonId: string(),
45733
45995
  nodeId: string().optional()
45734
45996
  }), SettingsSchemaWithValuesSchema.nullable()), method(object({
@@ -55391,7 +55653,7 @@ method(_void(), array(IntegrationWithStateSchema)), method(object({ id: string()
55391
55653
  * or the redaction token KEEPS the stored secret; `{ $secretClear: true }`
55392
55654
  * clears it.
55393
55655
  */
55394
- var ConfigSchemaPassthrough$3 = custom();
55656
+ var ConfigSchemaPassthrough$2 = custom();
55395
55657
  var IntegrationInstanceIdSchema = string().min(1);
55396
55658
  var IntegrationInstanceModeSchema = _enum(["single", "multiple"]);
55397
55659
  /**
@@ -55437,7 +55699,16 @@ var IntegrationInstanceKindSchema = object({
55437
55699
  /** Relative hub path to start an interactive account link of an instance of this kind. */
55438
55700
  connectPath: string().min(1).optional(),
55439
55701
  /** Relative hub path to disconnect that account. */
55440
- disconnectPath: string().min(1).optional()
55702
+ disconnectPath: string().min(1).optional(),
55703
+ /**
55704
+ * Parts of the edit dialog the flat form cannot draw (a node picker, a model source), named by a
55705
+ * GENERIC widget id the client maps to a component; a client that knows none of them shows none.
55706
+ * `connection` widgets write connection values, `model` widgets own the model choice.
55707
+ */
55708
+ widgets: array(object({
55709
+ id: string().min(1),
55710
+ placement: _enum(["connection", "model"])
55711
+ })).optional()
55441
55712
  });
55442
55713
  /**
55443
55714
  * How devices of an instance are found. `none`: the operator adds them by hand; `lan`: the addon
@@ -55542,7 +55813,7 @@ var integrationInstancesCapability = {
55542
55813
  id: IntegrationInstanceIdSchema.nullable(),
55543
55814
  /** The kind of the create form (`id: null`) of a provider with several. */
55544
55815
  kind: string().min(1).optional()
55545
- }), ConfigSchemaPassthrough$3, { auth: "admin" }),
55816
+ }), ConfigSchemaPassthrough$2, { auth: "admin" }),
55546
55817
  listInstances: method(_void(), array(IntegrationInstanceSchema).readonly(), { auth: "admin" }),
55547
55818
  getInstance: method(object({ id: IntegrationInstanceIdSchema }), IntegrationInstanceSchema.nullable(), { auth: "admin" }),
55548
55819
  /**
@@ -56493,12 +56764,12 @@ var LlmModelInfoSchema = object({
56493
56764
  });
56494
56765
  /**
56495
56766
  * The provider-specific part of a profile, validated by the provider that owns
56496
- * the kind (`upsertProfile` refuses what it does not accept). A field its
56767
+ * the kind (saving an instance refuses what it does not accept). A field its
56497
56768
  * `connectionSchema` declares `type: 'password'` is a secret: it is held in the
56498
56769
  * keychain, never in the row, and reads back as the redaction marker.
56499
56770
  */
56500
56771
  var LlmProviderConfigSchema = record(string(), unknown());
56501
- var LlmProfileSchema = object({
56772
+ object({
56502
56773
  id: string(),
56503
56774
  name: string(),
56504
56775
  /** The provider-declared kind (`LlmProfileKindDescriptor.kind`). */
@@ -56592,8 +56863,8 @@ var LlmProviderWidgetSchema = object({
56592
56863
  /** ConfigUISchema tree passed through untyped on the wire (the
56593
56864
  * notification-output `ConfigSchemaPassthrough` precedent at
56594
56865
  * notification-output.cap.ts:151); the exported TS type re-tightens it. */
56595
- var ConfigSchemaPassthrough$2 = unknown();
56596
- var LlmProfileKindDescriptorSchema = object({
56866
+ var ConfigSchemaPassthrough$1 = unknown();
56867
+ object({
56597
56868
  kind: LlmProfileKindSchema,
56598
56869
  label: string(),
56599
56870
  /** A generic icon name (`cloud`, `plug`, `cpu`) — never a glyph or a logo. */
@@ -56601,9 +56872,9 @@ var LlmProfileKindDescriptorSchema = object({
56601
56872
  /** Stamped by each provider so the concat-fanned catalog stays routable. */
56602
56873
  addonId: string(),
56603
56874
  /** The provider's own fields (`providerConfig`); `password` fields are keychain-held. */
56604
- connectionSchema: ConfigSchemaPassthrough$2,
56875
+ connectionSchema: ConfigSchemaPassthrough$1,
56605
56876
  /** Provider fields that belong under "Advanced" (extra headers, runtime tuning). */
56606
- advancedSchema: ConfigSchemaPassthrough$2.optional(),
56877
+ advancedSchema: ConfigSchemaPassthrough$1.optional(),
56607
56878
  /** The kind's defaults; a model from `listModels` may override any of them. */
56608
56879
  features: LlmModelFeaturesSchema,
56609
56880
  /** `false` = the provider stamps `supportsVision` itself (from what a node reports). */
@@ -56732,20 +57003,7 @@ method(LlmGenerateBaseInputSchema, LlmGenerateResultSchema, {
56732
57003
  }), method(object({
56733
57004
  addonId: string().optional(),
56734
57005
  requestId: string()
56735
- }), _void(), { kind: "mutation" }), method(object({}), array(LlmProfileKindDescriptorSchema)), method(object({}), array(LlmProfileSchema)), method(object({ profile: LlmProfileSchema }), LlmProfileSchema, {
56736
- kind: "mutation",
56737
- auth: "admin"
56738
- }), method(RawSecretMigrationInputSchema, RawSecretMigrationReportSchema, {
56739
- kind: "mutation",
56740
- auth: "admin"
56741
- }), method(ProfileRefInputSchema, _void(), {
56742
- kind: "mutation",
56743
- auth: "admin"
56744
- }), method(ProfileRefInputSchema, LlmGenerateResultSchema, {
56745
- kind: "mutation",
56746
- auth: "admin",
56747
- timeoutMs: AI_CAP_TRANSPORT_TIMEOUT_MS
56748
- }), method(LlmListModelsInputSchema, LlmListModelsResultSchema, {
57006
+ }), _void(), { kind: "mutation" }), method(LlmListModelsInputSchema, LlmListModelsResultSchema, {
56749
57007
  kind: "mutation",
56750
57008
  auth: "admin"
56751
57009
  }), method(object({}), array(LlmDefaultSchema)), method(object({
@@ -57740,20 +57998,7 @@ method(_void(), MeshStatusSchema), method(object({
57740
57998
  /** Optional hostname override the host should advertise once joined. */
57741
57999
  hostname: string().optional() }), object({
57742
58000
  /** Authentication URL the operator should open in a browser. */
57743
- loginUrl: string() }), { kind: "mutation" }), method(_void(), object({ left: literal(true) }), { kind: "mutation" }), method(_void(), object({ loggedOut: literal(true) }), { kind: "mutation" }), method(_void(), object({ peers: array(MeshPeerSchema).readonly() })), method(object({
57744
- /** Optional auth key — when provided, probes the key validity
57745
- * against the provider's API. Omit when already joined to
57746
- * just ping the daemon. */
57747
- authKey: string().optional() }), object({
57748
- ok: boolean(),
57749
- /** Provider-side identifier resolved by the probe (tailnet
57750
- * name for Tailscale, network id for ZeroTier, etc.). */
57751
- tenant: string().optional(),
57752
- /** Daemon binary version, when reachable. */
57753
- daemonVersion: string().optional(),
57754
- /** Human-readable error when `ok: false`. */
57755
- error: string().optional()
57756
- }), { kind: "mutation" });
58001
+ loginUrl: string() }), { kind: "mutation" }), method(_void(), object({ left: literal(true) }), { kind: "mutation" }), method(_void(), object({ loggedOut: literal(true) }), { kind: "mutation" }), method(_void(), object({ peers: array(MeshPeerSchema).readonly() }));
57757
58002
  object({
57758
58003
  value: number().nullable().meta(readingMeta("device", { label: "Total" })),
57759
58004
  lastFetchedAt: number()
@@ -67411,61 +67656,6 @@ var OauthIntegrationDescriptorSchema = object({
67411
67656
  });
67412
67657
  method(_void(), OauthIntegrationDescriptorSchema, { auth: "admin" });
67413
67658
  /**
67414
- * `oidc-connections` — CRUD for IdP rows under `auth-oidc` (D828 sibling).
67415
- *
67416
- * One hub-only singleton (`auth-oidc`). The Settings UI is a DataTable +
67417
- * ItemFormDialog; there is no `editable-array` in `globalSettingsSchema`.
67418
- * Operator-chosen `id` is the URL slug (`/addon/auth-oidc/<id>/…`) and is
67419
- * immutable after create.
67420
- */
67421
- var ConfigSchemaPassthrough$1 = unknown();
67422
- var OidcConnectionSchema = object({
67423
- id: string().min(1),
67424
- displayName: string(),
67425
- icon: string(),
67426
- issuerUrl: string(),
67427
- clientId: string(),
67428
- /** Client id + secret present — never the secret value. */
67429
- configured: boolean(),
67430
- /**
67431
- * Values for the connection form schema. `clientSecret` is a keychain
67432
- * {@link SecretFieldView} or `null` / `''`, never plaintext (D789).
67433
- */
67434
- formValues: record(string(), unknown()).optional()
67435
- });
67436
- /**
67437
- * Patch one connection. Omitted or empty `clientSecret` keeps the stored
67438
- * secret (D787). `{ $secretClear: true }` clears it. `id` is never renamed.
67439
- */
67440
- var OidcConnectionUpdateInputSchema = object({
67441
- id: string().min(1),
67442
- displayName: string().min(1),
67443
- icon: string().optional(),
67444
- issuerUrl: string().optional(),
67445
- clientId: string().optional(),
67446
- clientSecret: union([string(), object({ $secretClear: literal(true) })]).optional(),
67447
- redirectUri: string().optional(),
67448
- scopes: string().optional(),
67449
- usernameClaim: _enum([
67450
- "preferred_username",
67451
- "email",
67452
- "sub"
67453
- ]).optional()
67454
- });
67455
- method(object({}), ConfigSchemaPassthrough$1, { auth: "admin" }), method(object({}), array(OidcConnectionSchema).readonly(), { auth: "admin" }), method(object({
67456
- id: string().min(1).regex(/^[a-z0-9][a-z0-9-]{0,63}$/, "id must be a lowercase slug"),
67457
- displayName: string().min(1)
67458
- }), object({ id: string() }), {
67459
- kind: "mutation",
67460
- auth: "admin"
67461
- }), method(OidcConnectionUpdateInputSchema, object({ ok: literal(true) }), {
67462
- kind: "mutation",
67463
- auth: "admin"
67464
- }), method(object({ id: string().min(1) }), object({ ok: literal(true) }), {
67465
- kind: "mutation",
67466
- auth: "admin"
67467
- });
67468
- /**
67469
67659
  * Generic on-screen-display (video overlay) cap. Each camera exposes
67470
67660
  * a firmware-defined list of overlays (channel name, timestamp,
67471
67661
  * watermark, logo, …); the cap models them as a homogeneous array of
@@ -73840,21 +74030,6 @@ method(object({
73840
74030
  */
73841
74031
  ttlSec: union([number().int().positive(), literal("never")]).optional()
73842
74032
  }), object({ token: string() }), { auth: "admin" }), method(object({ token: string() }), SsoBridgeClaimsSchema.nullable(), { auth: "admin" });
73843
- var ProviderListEntrySchema = discriminatedUnion("shouldSaveDiskSpace", [object({
73844
- providerId: string().min(1),
73845
- displayName: string().min(1),
73846
- configSchema: unknown(),
73847
- nodeLocal: boolean(),
73848
- shouldSaveDiskSpace: literal(true),
73849
- minFreePercent: number().min(0).max(100)
73850
- }), object({
73851
- providerId: string().min(1),
73852
- displayName: string().min(1),
73853
- configSchema: unknown(),
73854
- nodeLocal: boolean(),
73855
- shouldSaveDiskSpace: literal(false),
73856
- minFreePercent: literal(null)
73857
- })]);
73858
74033
  method(object({
73859
74034
  location: StorageLocationRefSchema,
73860
74035
  relativePath: string()
@@ -73916,42 +74091,7 @@ method(object({
73916
74091
  }), _instanceof(Uint8Array), { auth: "admin" }), method(object({ downloadId: string() }), _void(), {
73917
74092
  kind: "mutation",
73918
74093
  auth: "admin"
73919
- }), method(object({ type: StorageLocationTypeSchema.optional() }), array(StorageLocationSchema).readonly()), method(_void(), array(StorageLocationDeclarationSchema).readonly()), method(StorageLocationSchema.omit({
73920
- createdAt: true,
73921
- updatedAt: true
73922
- }), StorageLocationSchema, {
73923
- kind: "mutation",
73924
- auth: "admin"
73925
- }), method(object({
73926
- id: string(),
73927
- force: boolean().optional()
73928
- }), _void(), {
73929
- kind: "mutation",
73930
- auth: "admin"
73931
- }), method(_void(), array(StorageDrainProgressSchema).readonly()), method(object({ id: string() }), object({
73932
- ok: boolean(),
73933
- error: string().optional()
73934
- }), { auth: "admin" }), method(_void(), array(ProviderListEntrySchema).readonly()), method(object({
73935
- providerId: string(),
73936
- /**
73937
- * The location this config is an UNSAVED edit of, when there is one.
73938
- *
73939
- * `listLocations` replaces every declared secret with the redaction
73940
- * sentinel, so the edit modal's form state holds the sentinel for any
73941
- * credential the operator did not retype — and posting that here
73942
- * without a way to resolve it makes the provider try to authenticate
73943
- * as `__camstack_redacted__` and report the operator's own working
73944
- * password as wrong. Given this id, the orchestrator restores each
73945
- * sentinel from the stored config (same rule as `upsertLocation`)
73946
- * before dispatching. Omitted by the "Add location" wizard, where
73947
- * every value was typed just now and nothing is stored yet.
73948
- */
73949
- locationId: string().optional(),
73950
- config: record(string(), unknown())
73951
- }), object({
73952
- ok: boolean(),
73953
- error: string().optional()
73954
- }), { auth: "admin" });
74094
+ }), method(object({ type: StorageLocationTypeSchema.optional() }), array(StorageLocationSchema).readonly()), method(_void(), array(StorageLocationDeclarationSchema).readonly()), method(_void(), array(StorageDrainProgressSchema).readonly());
73955
74095
  /** One table of the settings database. */
73956
74096
  var StorageTableSchema = object({
73957
74097
  /** The table's full name, e.g. `recorder:addon-settings` or `addon-device-settings`. */
@@ -78084,6 +78224,20 @@ Object.freeze({
78084
78224
  access: "view",
78085
78225
  role: "admin"
78086
78226
  },
78227
+ "addonSettings.getScopedSettings": {
78228
+ capName: "addon-settings",
78229
+ capScope: "system",
78230
+ addonId: null,
78231
+ access: "view",
78232
+ role: "admin"
78233
+ },
78234
+ "addonSettings.readScopedValues": {
78235
+ capName: "addon-settings",
78236
+ capScope: "system",
78237
+ addonId: null,
78238
+ access: "view",
78239
+ role: "admin"
78240
+ },
78087
78241
  "addonSettings.unsetStoredSettingsKeys": {
78088
78242
  capName: "addon-settings",
78089
78243
  capScope: "system",
@@ -78105,6 +78259,13 @@ Object.freeze({
78105
78259
  access: "create",
78106
78260
  role: "admin"
78107
78261
  },
78262
+ "addonSettings.updateScopedSettings": {
78263
+ capName: "addon-settings",
78264
+ capScope: "system",
78265
+ addonId: null,
78266
+ access: "create",
78267
+ role: "admin"
78268
+ },
78108
78269
  "addonWidgets.listWidgets": {
78109
78270
  capName: "addon-widgets",
78110
78271
  capScope: "system",
@@ -81556,13 +81717,6 @@ Object.freeze({
81556
81717
  access: "delete",
81557
81718
  role: "admin"
81558
81719
  },
81559
- "llm.deleteProfile": {
81560
- capName: "llm",
81561
- capScope: "system",
81562
- addonId: null,
81563
- access: "delete",
81564
- role: "admin"
81565
- },
81566
81720
  "llm.generate": {
81567
81721
  capName: "llm",
81568
81722
  capScope: "system",
@@ -81626,20 +81780,6 @@ Object.freeze({
81626
81780
  access: "view",
81627
81781
  role: "admin"
81628
81782
  },
81629
- "llm.listProfileKinds": {
81630
- capName: "llm",
81631
- capScope: "system",
81632
- addonId: null,
81633
- access: "view",
81634
- role: "admin"
81635
- },
81636
- "llm.listProfiles": {
81637
- capName: "llm",
81638
- capScope: "system",
81639
- addonId: null,
81640
- access: "view",
81641
- role: "admin"
81642
- },
81643
81783
  "llm.listRuntimeNodes": {
81644
81784
  capName: "llm",
81645
81785
  capScope: "system",
@@ -81647,13 +81787,6 @@ Object.freeze({
81647
81787
  access: "view",
81648
81788
  role: "admin"
81649
81789
  },
81650
- "llm.migrateRawSecrets": {
81651
- capName: "llm",
81652
- capScope: "system",
81653
- addonId: null,
81654
- access: "create",
81655
- role: "admin"
81656
- },
81657
81790
  "llm.resolveModelRef": {
81658
81791
  capName: "llm",
81659
81792
  capScope: "system",
@@ -81682,20 +81815,6 @@ Object.freeze({
81682
81815
  access: "create",
81683
81816
  role: "admin"
81684
81817
  },
81685
- "llm.testProfile": {
81686
- capName: "llm",
81687
- capScope: "system",
81688
- addonId: null,
81689
- access: "create",
81690
- role: "admin"
81691
- },
81692
- "llm.upsertProfile": {
81693
- capName: "llm",
81694
- capScope: "system",
81695
- addonId: null,
81696
- access: "create",
81697
- role: "admin"
81698
- },
81699
81818
  "llmRuntime.appleAvailability": {
81700
81819
  capName: "llm-runtime",
81701
81820
  capScope: "system",
@@ -82200,13 +82319,6 @@ Object.freeze({
82200
82319
  access: "create",
82201
82320
  role: "admin"
82202
82321
  },
82203
- "meshNetwork.testConnection": {
82204
- capName: "mesh-network",
82205
- capScope: "system",
82206
- addonId: null,
82207
- access: "create",
82208
- role: "admin"
82209
- },
82210
82322
  "meter.getStatus": {
82211
82323
  capName: "meter",
82212
82324
  capScope: "device",
@@ -82865,13 +82977,6 @@ Object.freeze({
82865
82977
  access: "create",
82866
82978
  role: "admin"
82867
82979
  },
82868
- "notificationOutput.deleteTarget": {
82869
- capName: "notification-output",
82870
- capScope: "system",
82871
- addonId: null,
82872
- access: "delete",
82873
- role: "admin"
82874
- },
82875
82980
  "notificationOutput.discoverTargets": {
82876
82981
  capName: "notification-output",
82877
82982
  capScope: "system",
@@ -82879,13 +82984,6 @@ Object.freeze({
82879
82984
  access: "view",
82880
82985
  role: "admin"
82881
82986
  },
82882
- "notificationOutput.getTarget": {
82883
- capName: "notification-output",
82884
- capScope: "system",
82885
- addonId: null,
82886
- access: "view",
82887
- role: "admin"
82888
- },
82889
82987
  "notificationOutput.listTargetKinds": {
82890
82988
  capName: "notification-output",
82891
82989
  capScope: "system",
@@ -82893,13 +82991,6 @@ Object.freeze({
82893
82991
  access: "view",
82894
82992
  role: "admin"
82895
82993
  },
82896
- "notificationOutput.listTargets": {
82897
- capName: "notification-output",
82898
- capScope: "system",
82899
- addonId: null,
82900
- access: "view",
82901
- role: "admin"
82902
- },
82903
82994
  "notificationOutput.probeTargetConfig": {
82904
82995
  capName: "notification-output",
82905
82996
  capScope: "system",
@@ -82914,13 +83005,6 @@ Object.freeze({
82914
83005
  access: "create",
82915
83006
  role: "admin"
82916
83007
  },
82917
- "notificationOutput.setTargetEnabled": {
82918
- capName: "notification-output",
82919
- capScope: "system",
82920
- addonId: null,
82921
- access: "create",
82922
- role: "admin"
82923
- },
82924
83008
  "notificationOutput.testTarget": {
82925
83009
  capName: "notification-output",
82926
83010
  capScope: "system",
@@ -82928,13 +83012,6 @@ Object.freeze({
82928
83012
  access: "create",
82929
83013
  role: "admin"
82930
83014
  },
82931
- "notificationOutput.upsertTarget": {
82932
- capName: "notification-output",
82933
- capScope: "system",
82934
- addonId: null,
82935
- access: "create",
82936
- role: "admin"
82937
- },
82938
83015
  "notificationRules.activateAlarmProfile": {
82939
83016
  capName: "notification-rules",
82940
83017
  capScope: "system",
@@ -83194,41 +83271,6 @@ Object.freeze({
83194
83271
  access: "view",
83195
83272
  role: "admin"
83196
83273
  },
83197
- "oidcConnections.connectionFormSchema": {
83198
- capName: "oidc-connections",
83199
- capScope: "system",
83200
- addonId: null,
83201
- access: "view",
83202
- role: "admin"
83203
- },
83204
- "oidcConnections.createConnection": {
83205
- capName: "oidc-connections",
83206
- capScope: "system",
83207
- addonId: null,
83208
- access: "create",
83209
- role: "admin"
83210
- },
83211
- "oidcConnections.deleteConnection": {
83212
- capName: "oidc-connections",
83213
- capScope: "system",
83214
- addonId: null,
83215
- access: "delete",
83216
- role: "admin"
83217
- },
83218
- "oidcConnections.listConnections": {
83219
- capName: "oidc-connections",
83220
- capScope: "system",
83221
- addonId: null,
83222
- access: "view",
83223
- role: "admin"
83224
- },
83225
- "oidcConnections.updateConnection": {
83226
- capName: "oidc-connections",
83227
- capScope: "system",
83228
- addonId: null,
83229
- access: "create",
83230
- role: "admin"
83231
- },
83232
83274
  "osd.getStatus": {
83233
83275
  capName: "osd",
83234
83276
  capScope: "device",
@@ -86260,13 +86302,6 @@ Object.freeze({
86260
86302
  access: "delete",
86261
86303
  role: "admin"
86262
86304
  },
86263
- "storage.deleteLocation": {
86264
- capName: "storage",
86265
- capScope: "system",
86266
- addonId: null,
86267
- access: "delete",
86268
- role: "admin"
86269
- },
86270
86305
  "storage.endDownload": {
86271
86306
  capName: "storage",
86272
86307
  capScope: "system",
@@ -86323,13 +86358,6 @@ Object.freeze({
86323
86358
  access: "view",
86324
86359
  role: "admin"
86325
86360
  },
86326
- "storage.listProviders": {
86327
- capName: "storage",
86328
- capScope: "system",
86329
- addonId: null,
86330
- access: "view",
86331
- role: "admin"
86332
- },
86333
86361
  "storage.read": {
86334
86362
  capName: "storage",
86335
86363
  capScope: "system",
@@ -86351,27 +86379,6 @@ Object.freeze({
86351
86379
  access: "view",
86352
86380
  role: "admin"
86353
86381
  },
86354
- "storage.testConfig": {
86355
- capName: "storage",
86356
- capScope: "system",
86357
- addonId: null,
86358
- access: "view",
86359
- role: "admin"
86360
- },
86361
- "storage.testLocation": {
86362
- capName: "storage",
86363
- capScope: "system",
86364
- addonId: null,
86365
- access: "view",
86366
- role: "admin"
86367
- },
86368
- "storage.upsertLocation": {
86369
- capName: "storage",
86370
- capScope: "system",
86371
- addonId: null,
86372
- access: "create",
86373
- role: "admin"
86374
- },
86375
86382
  "storage.write": {
86376
86383
  capName: "storage",
86377
86384
  capScope: "system",
@@ -159732,10 +159739,23 @@ var HAP_STREAM_PREFERENCE_OPTIONS = [
159732
159739
  label: "Low"
159733
159740
  }
159734
159741
  ];
159742
+ /** One device's advertised HAP state, persisted in the addon store. JSON-plain
159743
+ * mirror of `ExportTargetEntry` from `@camstack/types/node`. Keyed by
159744
+ * `String(deviceId)` in the `exportSyncState` store key. `externalIds` holds
159745
+ * the deterministic accessory UUID (diagnostic; rebuild uses the live mapper). */
159746
+ var ExportTargetEntrySchema = object({
159747
+ fingerprint: string(),
159748
+ externalIds: array(string())
159749
+ });
159750
+ /** Durable per-device export sync state — the Phase-C reconciler cache, kept under the
159751
+ * addon-store key `exportSyncState` (the key the addon always used).
159752
+ * Key = `String(deviceId)`, value = the device's export fingerprint at last
159753
+ * attach. Drives `diffExportTargets`: an unchanged restart hashes to the same
159754
+ * fingerprint → no rebuild. */
159755
+ var ExportSyncStateSchema = record(string(), ExportTargetEntrySchema);
159735
159756
  var DEFAULT_CONFIG = {
159736
159757
  interfaceName: "",
159737
- clipRetentionDays: 14,
159738
- exportSyncState: {}
159758
+ clipRetentionDays: 14
159739
159759
  };
159740
159760
  var BANNED_PINCODES = new Set([
159741
159761
  "000-00-000",
@@ -160054,7 +160074,7 @@ var ExportHapAddon = class extends BaseAddon {
160054
160074
  await this.stopInstance(id);
160055
160075
  for (const uuid of uuids) clearPairingFiles(uuid, this.ctx.logger);
160056
160076
  await this.exposureHandle().delete(id);
160057
- if (id === "export-hap") await this.updateGlobalSettings({ exportSyncState: {} });
160077
+ if (id === "export-hap") await this.exportSyncState.set({});
160058
160078
  this.ctx.logger.info("export-hap: bridge removed", { meta: { instanceId: id } });
160059
160079
  }
160060
160080
  /**
@@ -160426,9 +160446,11 @@ var ExportHapAddon = class extends BaseAddon {
160426
160446
  return inst.accessoryUuidOf(inst.findEntry(deviceId)?.mapperKind ?? "camera", deviceId);
160427
160447
  }
160428
160448
  /** The reconcile cache of a bridge: the default one is persisted, the others live in memory (boot re-attach seeds them). */
160429
- syncStateOf(inst) {
160430
- return inst.id === "export-hap" ? syncStateFromJson(this.config.exportSyncState) : inst.syncState;
160449
+ async syncStateOf(inst) {
160450
+ return inst.id === "export-hap" ? syncStateFromJson(await this.exportSyncState.get()) : inst.syncState;
160431
160451
  }
160452
+ /** The persisted reconcile cache of the default bridge (store key `exportSyncState`). */
160453
+ exportSyncState = this.state("exportSyncState", ExportSyncStateSchema, {});
160432
160454
  /**
160433
160455
  * Export fingerprint of a device from its PERSISTED features + type
160434
160456
  * (`canonicalDeviceFingerprint`). Returns `null` on a transient API error or
@@ -160454,7 +160476,7 @@ var ExportHapAddon = class extends BaseAddon {
160454
160476
  deviceType: device.type,
160455
160477
  features: device.features
160456
160478
  });
160457
- const persisted = this.syncStateOf(inst).get(deviceId)?.fingerprint;
160479
+ const persisted = (await this.syncStateOf(inst)).get(deviceId)?.fingerprint;
160458
160480
  const withToken = withRecordabilityToken({
160459
160481
  base: fresh,
160460
160482
  token: await this.readRecordabilityToken(inst, deviceId, device.type),
@@ -160489,22 +160511,35 @@ var ExportHapAddon = class extends BaseAddon {
160489
160511
  return null;
160490
160512
  }
160491
160513
  }
160514
+ /** Tail of the pending cache writes of each bridge: a read-modify-write of one bridge never overlaps another. */
160515
+ syncWrites = /* @__PURE__ */ new Map();
160516
+ /** Run one read-modify-write of a bridge's reconcile cache after the previous one finished. */
160517
+ serialisedSyncWrite(inst, write) {
160518
+ const next = (this.syncWrites.get(inst.id) ?? Promise.resolve()).then(write);
160519
+ this.syncWrites.set(inst.id, next.catch(() => void 0));
160520
+ return next;
160521
+ }
160492
160522
  /** Persist a device's current export fingerprint into `exportSyncState`
160493
- * (best-effort; called after a successful attach). */
160494
- async persistFingerprint(inst, deviceId, fingerprint) {
160495
- const state = this.syncStateOf(inst);
160496
- state.set(deviceId, {
160497
- fingerprint,
160498
- externalIds: [this.hapAccessoryUuid(inst, deviceId)]
160523
+ * (best-effort; called after a successful attach). Serialised per bridge, so two attaches
160524
+ * finishing together cannot each write back a cache that lacks the other's entry. */
160525
+ persistFingerprint(inst, deviceId, fingerprint) {
160526
+ return this.serialisedSyncWrite(inst, async () => {
160527
+ const state = await this.syncStateOf(inst);
160528
+ state.set(deviceId, {
160529
+ fingerprint,
160530
+ externalIds: [this.hapAccessoryUuid(inst, deviceId)]
160531
+ });
160532
+ if (inst.id === "export-hap") await this.exportSyncState.set(syncStateToJson(state));
160499
160533
  });
160500
- if (inst.id === "export-hap") await this.updateGlobalSettings({ exportSyncState: syncStateToJson(state) });
160501
160534
  }
160502
- /** Drop a device's `exportSyncState` entry (on unexpose). */
160503
- async forgetFingerprint(inst, deviceId) {
160504
- const state = this.syncStateOf(inst);
160505
- if (!state.has(deviceId)) return;
160506
- state.delete(deviceId);
160507
- if (inst.id === "export-hap") await this.updateGlobalSettings({ exportSyncState: syncStateToJson(state) });
160535
+ /** Drop a device's `exportSyncState` entry (on unexpose). Serialised with the writes above. */
160536
+ forgetFingerprint(inst, deviceId) {
160537
+ return this.serialisedSyncWrite(inst, async () => {
160538
+ const state = await this.syncStateOf(inst);
160539
+ if (!state.has(deviceId)) return;
160540
+ state.delete(deviceId);
160541
+ if (inst.id === "export-hap") await this.exportSyncState.set(syncStateToJson(state));
160542
+ });
160508
160543
  }
160509
160544
  /**
160510
160545
  * Subscribe to a device-lifecycle event category and reconcile the exposed
@@ -160592,7 +160627,7 @@ var ExportHapAddon = class extends BaseAddon {
160592
160627
  log.debug("export-hap: reconcile skipped — fingerprint unavailable (transient)");
160593
160628
  return;
160594
160629
  }
160595
- const last = this.syncStateOf(inst).get(numericId);
160630
+ const last = (await this.syncStateOf(inst)).get(numericId);
160596
160631
  if (last?.fingerprint === current) {
160597
160632
  if (!inst.exposed.has(deviceId)) try {
160598
160633
  await this.attachMapper(inst, entry);
@@ -161114,6 +161149,7 @@ exports.DEFAULT_DEVICE_SETTINGS = DEFAULT_DEVICE_SETTINGS;
161114
161149
  exports.EXPORT_HAP_ADDON_ID = EXPORT_HAP_ADDON_ID;
161115
161150
  exports.ExportHapAddon = ExportHapAddon;
161116
161151
  exports.default = ExportHapAddon;
161152
+ exports.ExportSyncStateSchema = ExportSyncStateSchema;
161117
161153
  exports.__toCommonJS = __toCommonJS;
161118
161154
  exports.deriveUsername = deriveUsername;
161119
161155
  exports.describeHksvCamera = describeHksvCamera;