@camstack/addon-provider-reolink 1.2.178 → 1.2.179

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.
Files changed (3) hide show
  1. package/dist/addon.js +1927 -66
  2. package/dist/addon.mjs +1927 -66
  3. package/package.json +1 -1
package/dist/addon.mjs CHANGED
@@ -27,7 +27,7 @@ import { URL as URL$1 } from "url";
27
27
  import { spawn as spawn$1 } from "node:child_process";
28
28
  import os, { tmpdir } from "node:os";
29
29
  import { createReadStream } from "node:fs";
30
- //#region ../types/dist/event-category-B_0XEcLF.mjs
30
+ //#region ../types/dist/event-category-DaIZi00R.mjs
31
31
  var EventCategory = /* @__PURE__ */ function(EventCategory) {
32
32
  EventCategory["SystemBoot"] = "system.boot";
33
33
  EventCategory["SystemAddonsReady"] = "system.addons-ready";
@@ -106,6 +106,13 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
106
106
  */
107
107
  EventCategory["AddonLoadFailed"] = "addon.load-failed";
108
108
  /**
109
+ * A keychain value was stored or removed (D787). Carries the ref, its
110
+ * owner and the new version — NEVER the value. A process holding the ref
111
+ * drops its cached copy and the owning `BaseAddon` re-resolves its config.
112
+ * Telemetry (D8): a process that misses it still revalidates by version.
113
+ */
114
+ EventCategory["KeychainChanged"] = "keychain.changed";
115
+ /**
109
116
  * Addon recovered from a previous failure. Emitted when an addon
110
117
  * transitions from `failed` back to `healthy` (typically via the
111
118
  * monitor's auto-retry loop, or after manual `addons.retryLoad`).
@@ -5398,7 +5405,7 @@ var ZodIssueCode = {
5398
5405
  var ZodFirstPartyTypeKind;
5399
5406
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
5400
5407
  //#endregion
5401
- //#region ../types/dist/sleep-B0JG7-_F.mjs
5408
+ //#region ../types/dist/sleep-Cr5YOk3m.mjs
5402
5409
  /**
5403
5410
  * The audio chunk plane's byte format, and the ONE expansion from a coded
5404
5411
  * window to float samples (D455).
@@ -5477,6 +5484,97 @@ function buildAlawTable() {
5477
5484
  }
5478
5485
  buildUlawTable();
5479
5486
  buildAlawTable();
5487
+ /** Is this field's stored value a credential? */
5488
+ function isSecretConfigField(field) {
5489
+ if (field.type === "password") return true;
5490
+ return "secret" in field && field.secret === true;
5491
+ }
5492
+ /**
5493
+ * Is this field's value stored in the KEYCHAIN (D787)? Every secret field is,
5494
+ * by its TYPE, unless it opts out with `storage: 'inline'` — never by its name.
5495
+ */
5496
+ function isKeychainStoredField(field) {
5497
+ if (!isSecretConfigField(field)) return false;
5498
+ if (field.type === "textarea" && field.isJson === true) return false;
5499
+ return !("storage" in field && field.storage === "inline");
5500
+ }
5501
+ /**
5502
+ * What a settings blob holds where a secret used to be.
5503
+ *
5504
+ * A keychain-stored field never holds its value. It holds a self-describing
5505
+ * MARKER, `{"$secret":"secret://…","v":1}` — an object, never a string, so no
5506
+ * code can mistake it for a credential and no form can send it to a camera as
5507
+ * a password. The empty state is `null` / absent, never `''`.
5508
+ *
5509
+ * The same shapes travel to and from the admin UI:
5510
+ *
5511
+ * - read: `hydrateSchema` hands a secret field a {@link SecretFieldView}
5512
+ * (`{ $secret, v, set: true }`) or `null` — the browser learns whether a
5513
+ * value is set, never the value.
5514
+ * - write: an untouched field submits the view back unchanged (KEEP); a typed
5515
+ * value is a plain non-empty string (CHANGE); the Clear button submits
5516
+ * {@link SECRET_CLEAR} (CLEAR). `''`, `null` and the legacy redaction tokens
5517
+ * are KEEP — an empty string is what a defaults-fallback pushes back, and
5518
+ * treating it as "clear" is how a save destroyed a stored credential before.
5519
+ *
5520
+ * Pure and browser-safe.
5521
+ */
5522
+ var SECRET_CLEAR = { $secretClear: true };
5523
+ /** The `'***'` token D634 redaction writes for non-admins. */
5524
+ var LEGACY_DEVICE_REDACTION = "***";
5525
+ function isRecord$1(value) {
5526
+ return typeof value === "object" && value !== null && !Array.isArray(value);
5527
+ }
5528
+ function makeSecretMarker(ref) {
5529
+ return {
5530
+ $secret: ref,
5531
+ v: 1
5532
+ };
5533
+ }
5534
+ /** A stored marker: an object whose `$secret` is a non-empty string. */
5535
+ function isSecretMarker(value) {
5536
+ if (!isRecord$1(value)) return false;
5537
+ const ref = value["$secret"];
5538
+ return typeof ref === "string" && ref.length > 0;
5539
+ }
5540
+ function isSecretClear(value) {
5541
+ return isRecord$1(value) && value["$secretClear"] === true;
5542
+ }
5543
+ /**
5544
+ * The UI view of a stored secret field value: a marker becomes "set", inline
5545
+ * plaintext becomes "set (inline)", nothing becomes `null`. A value never
5546
+ * survives this function.
5547
+ */
5548
+ function toSecretFieldView(stored) {
5549
+ if (isSecretMarker(stored)) return {
5550
+ $secret: stored.$secret,
5551
+ v: 1,
5552
+ set: true
5553
+ };
5554
+ if (typeof stored === "string" && stored.length > 0) return {
5555
+ $secret: null,
5556
+ v: 1,
5557
+ set: true,
5558
+ inline: true
5559
+ };
5560
+ return null;
5561
+ }
5562
+ /**
5563
+ * Classify an incoming value for a secret path. Only a non-empty string that is
5564
+ * not a redaction token sets a value; only {@link SECRET_CLEAR} clears.
5565
+ * Everything else — a marker (ours or anyone's), a UI view, `''`, `null`,
5566
+ * `undefined`, a redaction token, a non-string — keeps what is stored.
5567
+ */
5568
+ function classifySecretWrite(incoming) {
5569
+ if (isSecretClear(incoming)) return { kind: "clear" };
5570
+ if (typeof incoming !== "string") return { kind: "keep" };
5571
+ if (incoming.length === 0) return { kind: "keep" };
5572
+ if (incoming === "__camstack_redacted__" || incoming === LEGACY_DEVICE_REDACTION) return { kind: "keep" };
5573
+ return {
5574
+ kind: "set",
5575
+ value: incoming
5576
+ };
5577
+ }
5480
5578
  Object.fromEntries([
5481
5579
  {
5482
5580
  id: "overview",
@@ -5648,33 +5746,19 @@ Object.fromEntries([
5648
5746
  function isValuelessField(field) {
5649
5747
  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";
5650
5748
  }
5651
- /**
5652
- * Merge a `ConfigUISchema` with a raw `values` record into a
5653
- * `ConfigUISchemaWithValues`. Used by every `get*Settings` backend endpoint
5654
- * before returning to the admin UI. Groups are walked recursively.
5655
- *
5656
- * For each leaf field:
5657
- * - structural fields (`separator`, `info`, `button`) pass through unchanged
5658
- * - other fields get `value = values[key] ?? field.default ?? null`
5659
- *
5660
- * Unknown keys in `values` (keys not declared in the schema) are silently
5661
- * ignored — they don't contribute to the output. Missing keys fall back to
5662
- * the schema default or `null`. This mirrors the old backend behaviour where
5663
- * `FormBuilder` rendered `values[key] ?? field.default`.
5664
- */
5665
- function hydrateSchema(schema, values) {
5749
+ function hydrateSchema(schema, values, options = {}) {
5666
5750
  return {
5667
5751
  ...schema.tabs ? { tabs: [...schema.tabs] } : {},
5668
5752
  sections: schema.sections.map((section) => ({
5669
5753
  ...section,
5670
- fields: section.fields.map((field) => hydrateField(field, values))
5754
+ fields: section.fields.map((field) => hydrateField(field, values, options))
5671
5755
  }))
5672
5756
  };
5673
5757
  }
5674
- function hydrateField(field, values) {
5758
+ function hydrateField(field, values, options) {
5675
5759
  if (isValuelessField(field)) return field;
5676
5760
  if (field.type === "group") {
5677
- const hydratedChildren = field.fields.map((child) => hydrateField(child, values));
5761
+ const hydratedChildren = field.fields.map((child) => hydrateField(child, values, options));
5678
5762
  return {
5679
5763
  ...field,
5680
5764
  fields: hydratedChildren
@@ -5683,7 +5767,7 @@ function hydrateField(field, values) {
5683
5767
  if (field.type === "sub-tabs") {
5684
5768
  const hydratedTabs = field.tabs.map((tab) => ({
5685
5769
  ...tab,
5686
- fields: tab.fields.map((child) => hydrateField(child, values))
5770
+ fields: tab.fields.map((child) => hydrateField(child, values, options))
5687
5771
  }));
5688
5772
  return {
5689
5773
  ...field,
@@ -5693,6 +5777,33 @@ function hydrateField(field, values) {
5693
5777
  const key = field.key;
5694
5778
  const storedValue = Object.prototype.hasOwnProperty.call(values, key) ? values[key] : void 0;
5695
5779
  const defaultValue = field.default;
5780
+ const asView = (v) => isSecretMarker(v) || options.inlineSecretsAsViews === true && v !== void 0;
5781
+ if (isKeychainStoredField(field) && asView(storedValue)) return {
5782
+ ...field,
5783
+ value: toSecretFieldView(storedValue)
5784
+ };
5785
+ if (isKeychainStoredField(field) && options.inlineSecretsAsViews === true) return {
5786
+ ...field,
5787
+ value: null
5788
+ };
5789
+ if (field.type === "editable-array" && Array.isArray(storedValue)) {
5790
+ const secretItemKeys = field.itemFields.filter((item) => "key" in item && isKeychainStoredField(item)).map((item) => "key" in item ? item.key : "");
5791
+ if (secretItemKeys.length > 0) {
5792
+ const rows = storedValue.map((row) => {
5793
+ if (row === null || typeof row !== "object" || Array.isArray(row)) return row;
5794
+ const out = { ...row };
5795
+ for (const k of secretItemKeys) {
5796
+ const v = Reflect.get(row, k);
5797
+ if (asView(v)) out[k] = toSecretFieldView(v);
5798
+ }
5799
+ return out;
5800
+ });
5801
+ return {
5802
+ ...field,
5803
+ value: rows
5804
+ };
5805
+ }
5806
+ }
5696
5807
  if (field.multiple) {
5697
5808
  const stored = Array.isArray(storedValue) ? storedValue : storedValue !== void 0 && storedValue !== null ? [storedValue] : [];
5698
5809
  const itemFallback = field.multiple.itemDefault !== void 0 ? field.multiple.itemDefault : defaultValue !== void 0 ? defaultValue : typeOf(field) === "string" ? "" : null;
@@ -5935,6 +6046,431 @@ function projectStore(store, perNodeKeys, nodeId) {
5935
6046
  }
5936
6047
  return out;
5937
6048
  }
6049
+ var GLOBAL_SCOPE = { kind: "global" };
6050
+ /** The scope every addon-wide (not per-node, not per-device) setting lives in. */
6051
+ function globalSecretScope() {
6052
+ return GLOBAL_SCOPE;
6053
+ }
6054
+ function encodeSegment(value) {
6055
+ return encodeURIComponent(value);
6056
+ }
6057
+ /**
6058
+ * The field path of a value inside an array item, addressed by the item's id:
6059
+ * `arrayItemFieldPath('providers', 'authentik', 'clientSecret')` →
6060
+ * `providers[authentik].clientSecret`.
6061
+ */
6062
+ function arrayItemFieldPath(arrayKey, itemId, fieldKey) {
6063
+ return `${arrayKey}[${encodeSegment(itemId)}].${fieldKey}`;
6064
+ }
6065
+ /** A write to a secret path could not be stored in the keychain, so it was refused. */
6066
+ var KeychainWriteRefusedError = class extends Error {
6067
+ fieldPath;
6068
+ constructor(fieldPath, cause) {
6069
+ super(`secret "${fieldPath}" was not saved: the keychain could not store it (${cause instanceof Error ? cause.message : String(cause)}). Nothing was written.`);
6070
+ this.fieldPath = fieldPath;
6071
+ this.name = "KeychainWriteRefusedError";
6072
+ }
6073
+ };
6074
+ var KEEP = { kind: "keep" };
6075
+ function isRecord$2(value) {
6076
+ return typeof value === "object" && value !== null && !Array.isArray(value);
6077
+ }
6078
+ function defaultMintId() {
6079
+ return globalThis.crypto.randomUUID();
6080
+ }
6081
+ /** Every marker ref anywhere under `value`. */
6082
+ function collectSecretMarkerRefs(value, out = []) {
6083
+ if (isSecretMarker(value)) {
6084
+ out.push(value.$secret);
6085
+ return out;
6086
+ }
6087
+ if (Array.isArray(value)) for (const item of value) collectSecretMarkerRefs(item, out);
6088
+ else if (isRecord$2(value)) for (const child of Object.values(value)) collectSecretMarkerRefs(child, out);
6089
+ return out;
6090
+ }
6091
+ async function storedValueEquals(secrets, marker, candidate) {
6092
+ const resolved = (await secrets.resolve([marker.$secret]))[marker.$secret];
6093
+ return resolved?.kind === "value" && resolved.value === candidate;
6094
+ }
6095
+ async function writeLeaf(ctx, incoming, stored, fieldPath) {
6096
+ const intent = classifySecretWrite(incoming);
6097
+ const ref = ctx.secrets.ref(ctx.scope, fieldPath);
6098
+ const storedIsOurs = isSecretMarker(stored) && stored.$secret === ref;
6099
+ if (intent.kind === "keep") return KEEP;
6100
+ if (intent.kind === "set" && !ctx.operatorWrite && typeof stored === "string" && stored === intent.value) return KEEP;
6101
+ if (intent.kind === "clear") {
6102
+ if (storedIsOurs) ctx.deletes.push(ref);
6103
+ return {
6104
+ kind: "value",
6105
+ value: null
6106
+ };
6107
+ }
6108
+ if (storedIsOurs && await storedValueEquals(ctx.secrets, stored, intent.value)) return {
6109
+ kind: "value",
6110
+ value: stored
6111
+ };
6112
+ try {
6113
+ await ctx.secrets.put(ref, intent.value);
6114
+ } catch (err) {
6115
+ throw new KeychainWriteRefusedError(fieldPath, err);
6116
+ }
6117
+ return {
6118
+ kind: "value",
6119
+ value: makeSecretMarker(ref)
6120
+ };
6121
+ }
6122
+ /** Apply a member result onto `out`: KEEP restores the stored member, or removes it. */
6123
+ function applyMember(out, key, result, storedParent) {
6124
+ if (result.kind === "value") {
6125
+ out[key] = result.value;
6126
+ return;
6127
+ }
6128
+ if (Object.prototype.hasOwnProperty.call(storedParent, key)) out[key] = storedParent[key];
6129
+ else delete out[key];
6130
+ }
6131
+ async function writeMembers(ctx, children, incoming, stored, pathOf) {
6132
+ const out = { ...incoming };
6133
+ for (const [member, node] of children) applyMember(out, member, await writeNode(ctx, node, incoming[member], stored[member], pathOf(member)), stored);
6134
+ return out;
6135
+ }
6136
+ function rowId(row, idKey) {
6137
+ const raw = row[idKey];
6138
+ if (typeof raw === "string" && raw.length > 0) return raw;
6139
+ if (typeof raw === "number" && Number.isFinite(raw)) return String(raw);
6140
+ return null;
6141
+ }
6142
+ async function writeArray(ctx, node, incoming, stored, fieldPath) {
6143
+ const storedRows = Array.isArray(stored) ? stored.filter(isRecord$2) : [];
6144
+ if (!Array.isArray(incoming)) {
6145
+ ctx.deletes.push(...collectSecretMarkerRefs(storedRows));
6146
+ return {
6147
+ kind: "value",
6148
+ value: incoming
6149
+ };
6150
+ }
6151
+ const storedById = /* @__PURE__ */ new Map();
6152
+ for (const row of storedRows) {
6153
+ const id = rowId(row, node.idKey);
6154
+ if (id !== null) storedById.set(id, row);
6155
+ }
6156
+ const kept = /* @__PURE__ */ new Set();
6157
+ const rows = [];
6158
+ for (const row of incoming) {
6159
+ if (!isRecord$2(row)) {
6160
+ rows.push(row);
6161
+ continue;
6162
+ }
6163
+ const id = rowId(row, node.idKey) ?? ctx.mintId();
6164
+ kept.add(id);
6165
+ const withId = {
6166
+ ...row,
6167
+ [node.idKey]: row[node.idKey] ?? id
6168
+ };
6169
+ if (rowId(withId, node.idKey) === null) withId[node.idKey] = id;
6170
+ const storedRow = storedById.get(id) ?? {};
6171
+ rows.push(await writeMembers(ctx, node.item, withId, storedRow, (member) => arrayItemFieldPath(fieldPath, id, member)));
6172
+ }
6173
+ for (const [id, row] of storedById) if (!kept.has(id)) ctx.deletes.push(...collectSecretMarkerRefs(row));
6174
+ return {
6175
+ kind: "value",
6176
+ value: rows
6177
+ };
6178
+ }
6179
+ async function writeNode(ctx, node, incoming, stored, fieldPath) {
6180
+ switch (node.kind) {
6181
+ case "leaf": return writeLeaf(ctx, incoming, stored, fieldPath);
6182
+ case "array": return writeArray(ctx, node, incoming, stored, fieldPath);
6183
+ case "object": {
6184
+ if (!isRecord$2(incoming)) {
6185
+ if (incoming === void 0) return KEEP;
6186
+ ctx.deletes.push(...collectSecretMarkerRefs(stored));
6187
+ return {
6188
+ kind: "value",
6189
+ value: incoming
6190
+ };
6191
+ }
6192
+ const storedObj = isRecord$2(stored) ? stored : {};
6193
+ return {
6194
+ kind: "value",
6195
+ value: await writeMembers(ctx, node.children, incoming, storedObj, (m) => `${fieldPath}.${m}`)
6196
+ };
6197
+ }
6198
+ }
6199
+ }
6200
+ /** Split a perNode-scoped key (`key@nodeId`). */
6201
+ function splitNodeKey(key) {
6202
+ const at = key.indexOf("@");
6203
+ return at <= 0 ? {
6204
+ base: key,
6205
+ nodeId: null
6206
+ } : {
6207
+ base: key.slice(0, at),
6208
+ nodeId: key.slice(at + 1)
6209
+ };
6210
+ }
6211
+ /** Rewrite a settings patch so no secret value reaches the blob. See the file doc. */
6212
+ async function transformSecretWrite(input) {
6213
+ const deletes = [];
6214
+ const base = {
6215
+ secrets: input.secrets,
6216
+ mintId: input.mintId ?? defaultMintId,
6217
+ deletes,
6218
+ operatorWrite: input.operatorWrite === true
6219
+ };
6220
+ const out = {};
6221
+ for (const [key, incoming] of Object.entries(input.patch)) {
6222
+ const { base: baseKey, nodeId } = splitNodeKey(key);
6223
+ const node = input.tree.get(baseKey);
6224
+ if (node === void 0) {
6225
+ out[key] = incoming;
6226
+ continue;
6227
+ }
6228
+ const scope = nodeId !== null && nodeId.length > 0 ? {
6229
+ kind: "node",
6230
+ nodeId
6231
+ } : input.scope ?? globalSecretScope();
6232
+ const result = await writeNode({
6233
+ ...base,
6234
+ scope
6235
+ }, node, incoming, input.stored[key], baseKey);
6236
+ if (result.kind === "value") out[key] = result.value;
6237
+ }
6238
+ return {
6239
+ patch: out,
6240
+ afterWrite: async () => {
6241
+ if (deletes.length === 0) return { orphaned: [] };
6242
+ try {
6243
+ await input.secrets.delete([...new Set(deletes)]);
6244
+ return { orphaned: [] };
6245
+ } catch {
6246
+ return { orphaned: [...new Set(deletes)] };
6247
+ }
6248
+ }
6249
+ };
6250
+ }
6251
+ /**
6252
+ * Replace every marker in `value` with its keychain value. Returns the SAME
6253
+ * reference when there is no marker (no allocation, no keychain call).
6254
+ */
6255
+ async function resolveSecretMarkers(value, secrets) {
6256
+ const refs = collectSecretMarkerRefs(value);
6257
+ if (refs.length === 0) return {
6258
+ value,
6259
+ unresolved: []
6260
+ };
6261
+ const answers = await secrets.resolve(refs);
6262
+ const unresolved = [];
6263
+ for (const ref of new Set(refs)) {
6264
+ const answer = answers[ref];
6265
+ if (answer === void 0) unresolved.push({
6266
+ ref,
6267
+ reason: "not-initialized"
6268
+ });
6269
+ else if (answer.kind === "unavailable") unresolved.push({
6270
+ ref,
6271
+ reason: answer.reason
6272
+ });
6273
+ else if (answer.kind === "missing" || answer.kind === "forbidden") unresolved.push({
6274
+ ref,
6275
+ reason: answer.kind
6276
+ });
6277
+ }
6278
+ const substitute = (v) => {
6279
+ if (isSecretMarker(v)) {
6280
+ const answer = answers[v.$secret];
6281
+ return answer?.kind === "value" ? {
6282
+ keep: true,
6283
+ value: answer.value
6284
+ } : {
6285
+ keep: false,
6286
+ value: void 0
6287
+ };
6288
+ }
6289
+ if (Array.isArray(v)) {
6290
+ const items = [];
6291
+ for (const item of v) {
6292
+ const s = substitute(item);
6293
+ if (s.keep) items.push(s.value);
6294
+ }
6295
+ return {
6296
+ keep: true,
6297
+ value: items
6298
+ };
6299
+ }
6300
+ if (isRecord$2(v)) {
6301
+ const out = {};
6302
+ for (const [k, child] of Object.entries(v)) {
6303
+ const s = substitute(child);
6304
+ if (s.keep) out[k] = s.value;
6305
+ }
6306
+ return {
6307
+ keep: true,
6308
+ value: out
6309
+ };
6310
+ }
6311
+ return {
6312
+ keep: true,
6313
+ value: v
6314
+ };
6315
+ };
6316
+ return {
6317
+ value: substitute(value).value,
6318
+ unresolved
6319
+ };
6320
+ }
6321
+ function touchesTree(tree, patch) {
6322
+ if (tree.size === 0) return false;
6323
+ for (const key of Object.keys(patch)) {
6324
+ const at = key.indexOf("@");
6325
+ if (tree.has(at > 0 ? key.slice(0, at) : key)) return true;
6326
+ }
6327
+ return false;
6328
+ }
6329
+ /** The blob as stored now; a failed read REFUSES the write instead of guessing. */
6330
+ async function readStoredAddonBlob(raw) {
6331
+ const threeWay = raw.readAddonStoreResult;
6332
+ if (threeWay === void 0) return raw.readAddonStore();
6333
+ const result = await threeWay.call(raw);
6334
+ if (result.kind === "failed") throw new Error(`settings write refused: the stored blob could not be read (${result.error})`);
6335
+ return result.kind === "missing" ? {} : result.value;
6336
+ }
6337
+ function createSecretAwareSettings(raw, opts) {
6338
+ const chains = /* @__PURE__ */ new Map();
6339
+ const serialize = (key, fn) => {
6340
+ const next = (chains.get(key) ?? Promise.resolve()).then(fn, fn);
6341
+ const tail = next.catch(() => void 0);
6342
+ chains.set(key, tail);
6343
+ tail.then(() => {
6344
+ if (chains.get(key) === tail) chains.delete(key);
6345
+ });
6346
+ return next;
6347
+ };
6348
+ const write = async (chainKey, tree, scope, patch, readStored, rawWrite) => {
6349
+ if (!touchesTree(tree, patch)) return rawWrite(patch);
6350
+ return serialize(chainKey, async () => {
6351
+ const stored = await readStored();
6352
+ const result = await transformSecretWrite({
6353
+ tree,
6354
+ secrets: opts.secrets,
6355
+ patch,
6356
+ stored,
6357
+ ...scope !== void 0 ? { scope } : {},
6358
+ operatorWrite: opts.isOperatorWrite?.() === true
6359
+ });
6360
+ if (Object.keys(result.patch).length > 0) await rawWrite(result.patch);
6361
+ const { orphaned } = await result.afterWrite();
6362
+ if (orphaned.length > 0) opts.onOrphaned(orphaned);
6363
+ });
6364
+ };
6365
+ const wrapped = {
6366
+ writeAddonStore: (patch) => write("addon", opts.addonTree(), void 0, patch, () => readStoredAddonBlob(raw), (p) => raw.writeAddonStore(p)),
6367
+ writeDeviceStore: (deviceId, patch) => write(`device:${deviceId}`, opts.deviceTree(), {
6368
+ kind: "device",
6369
+ deviceId
6370
+ }, patch, () => raw.readDeviceStore(deviceId), (p) => raw.writeDeviceStore(deviceId, p))
6371
+ };
6372
+ return new Proxy(raw, { get(target, prop, receiver) {
6373
+ if (prop === "writeAddonStore") return wrapped.writeAddonStore;
6374
+ if (prop === "writeDeviceStore") return wrapped.writeDeviceStore;
6375
+ const value = Reflect.get(target, prop, receiver);
6376
+ return typeof value === "function" ? value.bind(target) : value;
6377
+ } });
6378
+ }
6379
+ /** The context the addon sees: identical, except that its settings writes are secret-aware. */
6380
+ function withSecretAwareSettings(context, opts) {
6381
+ const raw = context.settings;
6382
+ if (raw === void 0) return context;
6383
+ const settings = createSecretAwareSettings(raw, opts);
6384
+ return new Proxy(context, { get(target, prop, receiver) {
6385
+ if (prop === "settings") return settings;
6386
+ return Reflect.get(target, prop, receiver);
6387
+ } });
6388
+ }
6389
+ var LEAF = { kind: "leaf" };
6390
+ var DEFAULT_ITEM_ID_KEY = "id";
6391
+ function collectFields(fields, out) {
6392
+ for (const field of fields) {
6393
+ if (field.type === "group") {
6394
+ collectFields(field.fields, out);
6395
+ continue;
6396
+ }
6397
+ if (field.type === "sub-tabs") {
6398
+ for (const tab of field.tabs) collectFields(tab.fields, out);
6399
+ continue;
6400
+ }
6401
+ if (field.type === "editable-array") {
6402
+ const item = /* @__PURE__ */ new Map();
6403
+ for (const itemField of field.itemFields) if ("key" in itemField && isKeychainStoredField(itemField)) item.set(itemField.key, LEAF);
6404
+ if (item.size > 0) out.set(field.key, {
6405
+ kind: "array",
6406
+ idKey: field.itemIdKey ?? DEFAULT_ITEM_ID_KEY,
6407
+ item
6408
+ });
6409
+ continue;
6410
+ }
6411
+ if (!("key" in field) || typeof field.key !== "string") continue;
6412
+ if (isKeychainStoredField(field)) out.set(field.key, LEAF);
6413
+ }
6414
+ }
6415
+ /** The secret tree a settings schema declares. */
6416
+ function secretTreeFromSchema(schema) {
6417
+ const out = /* @__PURE__ */ new Map();
6418
+ if (schema === null) return out;
6419
+ for (const section of schema.sections) collectFields(section.fields, out);
6420
+ return out;
6421
+ }
6422
+ /** Parse `a.b[id].c` into segments; throws on a malformed path (a declaration bug). */
6423
+ function parseSecretStatePath(path) {
6424
+ const segments = [];
6425
+ for (const raw of path.split(".")) {
6426
+ const m = /^([^[\]]+)(?:\[([^[\]]+)\])?$/.exec(raw);
6427
+ if (m === null || m[1] === void 0) throw new Error(`secretStatePaths: malformed path "${path}"`);
6428
+ segments.push(m[2] !== void 0 ? {
6429
+ key: m[1],
6430
+ idKey: m[2]
6431
+ } : { key: m[1] });
6432
+ }
6433
+ if (segments.length === 0) throw new Error(`secretStatePaths: empty path`);
6434
+ if (segments[segments.length - 1]?.idKey !== void 0) throw new Error(`secretStatePaths: "${path}" ends on an array — name the member that is secret`);
6435
+ return segments;
6436
+ }
6437
+ function insert(into, segments) {
6438
+ const [head, ...rest] = segments;
6439
+ if (head === void 0) return;
6440
+ if (rest.length === 0) {
6441
+ into.set(head.key, LEAF);
6442
+ return;
6443
+ }
6444
+ const existing = into.get(head.key);
6445
+ if (head.idKey !== void 0) {
6446
+ const item = new Map(existing?.kind === "array" ? existing.item : []);
6447
+ insert(item, rest);
6448
+ into.set(head.key, {
6449
+ kind: "array",
6450
+ idKey: head.idKey,
6451
+ item
6452
+ });
6453
+ return;
6454
+ }
6455
+ const children = new Map(existing?.kind === "object" ? existing.children : []);
6456
+ insert(children, rest);
6457
+ into.set(head.key, {
6458
+ kind: "object",
6459
+ children
6460
+ });
6461
+ }
6462
+ /** Add hidden-state paths (`secretStatePaths`) to a schema-derived tree. */
6463
+ function mergeSecretStatePaths(tree, paths) {
6464
+ if (paths.length === 0) return tree;
6465
+ const out = new Map(tree);
6466
+ for (const path of paths) insert(out, parseSecretStatePath(path));
6467
+ return out;
6468
+ }
6469
+ /** First retry of a secret the keychain could not serve; doubles to {@link SECRET_RETRY_MAX_MS}. */
6470
+ var SECRET_RETRY_FIRST_MS = 5e3;
6471
+ var SECRET_RETRY_MAX_MS = 5 * 6e4;
6472
+ /** Coalesces a burst of `keychain.changed` events into one re-resolve. */
6473
+ var SECRET_CHANGE_DEBOUNCE_MS = 250;
5938
6474
  /**
5939
6475
  * Base class for CamStack addons. Eliminates settings boilerplate:
5940
6476
  *
@@ -6004,6 +6540,25 @@ var BaseAddon = class {
6004
6540
  settingsStoreReady = false;
6005
6541
  /** Default config values. Provided via constructor. */
6006
6542
  defaults;
6543
+ /**
6544
+ * Hidden-state paths that hold secrets (D787) — values the addon writes
6545
+ * itself (`updateGlobalSettings`, `state()`) that no form field declares.
6546
+ * Stored in the keychain exactly like a `password` field. Syntax:
6547
+ * `'snapshotSigningKey'`, `'identity.pincode'`, `'tokens[userId].accessToken'`
6548
+ * (`key[<id field>]` addresses array items by id, never by index).
6549
+ */
6550
+ secretStatePaths = [];
6551
+ _addonSecretTree = null;
6552
+ _deviceSecretTree = null;
6553
+ /** Refs the last resolved config pointed at — a change to one re-resolves. */
6554
+ _configSecretRefs = /* @__PURE__ */ new Set();
6555
+ _unresolvedSecrets = [];
6556
+ _secretRetryTimer = null;
6557
+ _secretRetryDelayMs = SECRET_RETRY_FIRST_MS;
6558
+ _secretChangeTimer = null;
6559
+ _secretChangeUnsub = null;
6560
+ /** >0 while an OPERATOR's settings write is being applied. */
6561
+ _operatorWriteDepth = 0;
6007
6562
  constructor(defaults) {
6008
6563
  this.defaults = defaults;
6009
6564
  this._config = { ...defaults };
@@ -6039,8 +6594,18 @@ var BaseAddon = class {
6039
6594
  return this._config;
6040
6595
  }
6041
6596
  async initialize(context) {
6042
- this._ctx = context;
6597
+ const secrets = context.secrets;
6598
+ this._ctx = secrets !== void 0 ? withSecretAwareSettings(context, {
6599
+ secrets,
6600
+ addonTree: () => this.addonSecretTree(),
6601
+ deviceTree: () => this.deviceSecretTree(),
6602
+ onOrphaned: (refs) => context.logger.warn("keychain refs dropped by a settings write could not be deleted", { meta: { refs: [...refs] } }),
6603
+ isOperatorWrite: () => this._operatorWriteDepth > 0
6604
+ }) : context;
6043
6605
  await this.resolveConfig();
6606
+ if (secrets !== void 0) this._secretChangeUnsub = secrets.onChange((ref) => {
6607
+ if (this._configSecretRefs.has(ref)) this.scheduleSecretReresolve(SECRET_CHANGE_DEBOUNCE_MS);
6608
+ });
6044
6609
  const result = await this.onInitialize();
6045
6610
  this.emitLifecycle(EventCategory.AddonStarted);
6046
6611
  const normalized = normalizeAddonInitResult(result);
@@ -6073,6 +6638,12 @@ var BaseAddon = class {
6073
6638
  */
6074
6639
  async onHubReachable() {}
6075
6640
  async shutdown() {
6641
+ this._secretChangeUnsub?.();
6642
+ this._secretChangeUnsub = null;
6643
+ if (this._secretRetryTimer !== null) clearTimeout(this._secretRetryTimer);
6644
+ if (this._secretChangeTimer !== null) clearTimeout(this._secretChangeTimer);
6645
+ this._secretRetryTimer = null;
6646
+ this._secretChangeTimer = null;
6076
6647
  this.emitLifecycle(EventCategory.AddonStopped);
6077
6648
  if (this.autoEmitReadiness) this.emitReadinessForProviders("down");
6078
6649
  await this.onShutdown();
@@ -6151,7 +6722,7 @@ var BaseAddon = class {
6151
6722
  return hydrateSchema(schema, overlay ? {
6152
6723
  ...projected,
6153
6724
  ...overlay
6154
- } : projected);
6725
+ } : projected, { inlineSecretsAsViews: true });
6155
6726
  }
6156
6727
  /**
6157
6728
  * The integration-level view of this addon's settings: exactly the sections
@@ -6200,7 +6771,7 @@ var BaseAddon = class {
6200
6771
  return hydrateSchema({
6201
6772
  ...schema,
6202
6773
  sections
6203
- }, projected);
6774
+ }, projected, { inlineSecretsAsViews: true });
6204
6775
  }
6205
6776
  /**
6206
6777
  * The raw addon store PROJECTED onto the target node's bare per-node keys:
@@ -6254,18 +6825,50 @@ var BaseAddon = class {
6254
6825
  value: result.value[key]
6255
6826
  };
6256
6827
  }
6828
+ /**
6829
+ * The OPERATOR's write — a settings form or an admin API call, dispatched by
6830
+ * the kernel. Identical to {@link updateGlobalSettings}, except that a secret
6831
+ * the operator sends is stored as sent even when it equals a pre-keychain
6832
+ * inline value: the operator re-entering a password is a change, an addon
6833
+ * writing back what it read is not (D787).
6834
+ */
6835
+ async updateGlobalSettingsAsOperator(patch, nodeId) {
6836
+ this._operatorWriteDepth++;
6837
+ try {
6838
+ await this.applyGlobalPatch(patch, nodeId);
6839
+ } finally {
6840
+ this._operatorWriteDepth--;
6841
+ }
6842
+ }
6257
6843
  async updateGlobalSettings(patch, nodeId) {
6844
+ await this.applyGlobalPatch(patch, nodeId);
6845
+ }
6846
+ /**
6847
+ * REMOVE stored secrets — their keychain values and their markers (D787).
6848
+ *
6849
+ * Writing `''` to a secret field KEEPS what is stored (an empty string is
6850
+ * what a defaults fallback writes back, and it must never destroy a
6851
+ * credential), so code that means "forget this token" says so here. Without
6852
+ * a keychain (an older kernel) it writes `''`, as such code always did.
6853
+ */
6854
+ async clearSecrets(keys, nodeId) {
6855
+ const tree = this.addonSecretTree();
6856
+ const keychain = this._ctx?.secrets !== void 0;
6857
+ const patch = {};
6858
+ for (const key of keys) patch[key] = keychain && tree.has(key) ? SECRET_CLEAR : "";
6859
+ await this.applyGlobalPatch(patch, nodeId);
6860
+ }
6861
+ async applyGlobalPatch(barePatch, nodeId) {
6258
6862
  const keys = this.perNodeKeys();
6259
6863
  const localNode = normalizeNodeId(this._ctx?.kernel?.localNodeId);
6260
6864
  const target = normalizeNodeId(nodeId ?? this._ctx?.kernel?.localNodeId);
6261
- const barePatch = patch;
6262
6865
  const scoped = keys.size > 0 ? scopePatch(barePatch, keys, target) : barePatch;
6263
6866
  await this._ctx?.settings?.writeAddonStore(scoped);
6264
6867
  if (target !== localNode) return;
6265
6868
  await this.resolveConfig();
6266
6869
  await this.onConfigChanged();
6267
6870
  this.emitLifecycle(EventCategory.AddonUpdated, { level: "global" });
6268
- this.maybeAutoRestart(patch, this.globalSettingsSchema());
6871
+ this.maybeAutoRestart(Object.keys(barePatch), this.globalSettingsSchema());
6269
6872
  }
6270
6873
  /**
6271
6874
  * The set of field keys the global settings schema declares `perNode: true`
@@ -6290,7 +6893,7 @@ var BaseAddon = class {
6290
6893
  * time to return its response before the addon is torn down and
6291
6894
  * re-initialised by `AddonRegistryService.restartAddon`.
6292
6895
  */
6293
- maybeAutoRestart(patch, schema) {
6896
+ maybeAutoRestart(patchKeys, schema) {
6294
6897
  if (!schema) return;
6295
6898
  const restartKeys = /* @__PURE__ */ new Set();
6296
6899
  for (const section of schema.sections) for (const field of section.fields) {
@@ -6298,13 +6901,13 @@ var BaseAddon = class {
6298
6901
  if (field.requiresRestart) restartKeys.add(field.key);
6299
6902
  }
6300
6903
  if (restartKeys.size === 0) return;
6301
- if (!Object.keys(patch).some((k) => restartKeys.has(k))) return;
6904
+ if (!patchKeys.some((k) => restartKeys.has(k))) return;
6302
6905
  const ctx = this._ctx;
6303
6906
  if (!ctx) return;
6304
6907
  const addonId = ctx.id;
6305
6908
  setImmediate(() => {
6306
6909
  ctx.api.addons?.restartAddon?.mutate({ addonId }).then(() => {
6307
- ctx.logger.info("addon auto-restart triggered by restart-required setting change", { meta: { changedFields: Object.keys(patch).filter((k) => restartKeys.has(k)) } });
6910
+ ctx.logger.info("addon auto-restart triggered by restart-required setting change", { meta: { changedFields: patchKeys.filter((k) => restartKeys.has(k)) } });
6308
6911
  }).catch((err) => {
6309
6912
  ctx.logger.error("addon auto-restart failed", { meta: { error: err instanceof Error ? err.message : String(err) } });
6310
6913
  });
@@ -6313,7 +6916,7 @@ var BaseAddon = class {
6313
6916
  async getDeviceSettings(deviceId) {
6314
6917
  const schema = this.deviceSettingsSchema();
6315
6918
  if (!schema) return { sections: [] };
6316
- return hydrateSchema(schema, await this._ctx?.settings?.readDeviceStore(deviceId) ?? {});
6919
+ return hydrateSchema(schema, await this._ctx?.settings?.readDeviceStore(deviceId) ?? {}, { inlineSecretsAsViews: true });
6317
6920
  }
6318
6921
  async updateDeviceSettings(deviceId, patch) {
6319
6922
  await this._ctx?.settings?.writeDeviceStore(deviceId, patch);
@@ -6443,7 +7046,7 @@ var BaseAddon = class {
6443
7046
  * selection at boot (absent scoped key ⇒ the constructor default wins).
6444
7047
  */
6445
7048
  async resolveConfig() {
6446
- const stored = await this.readAddonStoreWithRetry();
7049
+ const stored = await this.resolveStoredSecrets(await this.readAddonStoreWithRetry());
6447
7050
  const perNode = this.perNodeKeys();
6448
7051
  const localNode = normalizeNodeId(this._ctx?.kernel?.localNodeId);
6449
7052
  const resolved = { ...this.defaults };
@@ -6468,7 +7071,7 @@ var BaseAddon = class {
6468
7071
  key,
6469
7072
  schema,
6470
7073
  fallback,
6471
- read: () => this.readAddonStoreWithRetry(),
7074
+ read: async () => this.resolveStoredSecrets(await this.readAddonStoreWithRetry()),
6472
7075
  write: async (patch) => {
6473
7076
  await this._ctx?.settings?.writeAddonStore(patch);
6474
7077
  },
@@ -6485,7 +7088,7 @@ var BaseAddon = class {
6485
7088
  key,
6486
7089
  schema,
6487
7090
  fallback,
6488
- read: async () => await this._ctx?.settings?.readDeviceStore(deviceId) ?? {},
7091
+ read: async () => this.resolveStoredSecrets(await this._ctx?.settings?.readDeviceStore(deviceId) ?? {}, false),
6489
7092
  write: async (patch) => {
6490
7093
  await this._ctx?.settings?.writeDeviceStore(deviceId, patch);
6491
7094
  },
@@ -6497,6 +7100,70 @@ var BaseAddon = class {
6497
7100
  } })
6498
7101
  });
6499
7102
  }
7103
+ /** The addon store's secret tree: schema fields by TYPE, plus `secretStatePaths`. */
7104
+ addonSecretTree() {
7105
+ this._addonSecretTree ??= mergeSecretStatePaths(secretTreeFromSchema(this.globalSettingsSchema()), this.secretStatePaths);
7106
+ return this._addonSecretTree;
7107
+ }
7108
+ deviceSecretTree() {
7109
+ this._deviceSecretTree ??= secretTreeFromSchema(this.deviceSettingsSchema());
7110
+ return this._deviceSecretTree;
7111
+ }
7112
+ /**
7113
+ * Secrets of this addon's stored config that could not be resolved on the
7114
+ * last read, with why. Non-empty means the addon is running WITHOUT them —
7115
+ * an addon whose function needs one should report itself degraded rather
7116
+ * than start on an empty credential.
7117
+ */
7118
+ get unresolvedSecrets() {
7119
+ return this._unresolvedSecrets;
7120
+ }
7121
+ /**
7122
+ * Substitute every keychain marker in a stored blob with its value. With no
7123
+ * keychain (no `ctx.secrets`) or no marker, the blob comes back unchanged.
7124
+ * An unresolvable value is LEFT OUT (never `''`), logged by ref — never by
7125
+ * value — and, when the cause can pass, retried with backoff. Nothing is
7126
+ * ever written back from here.
7127
+ */
7128
+ async resolveStoredSecrets(blob, trackForConfig = true) {
7129
+ const secrets = this._ctx?.secrets;
7130
+ if (secrets === void 0) return blob;
7131
+ const refs = collectSecretMarkerRefs(blob);
7132
+ if (trackForConfig) this._configSecretRefs = new Set(refs);
7133
+ if (refs.length === 0) {
7134
+ if (trackForConfig) this._unresolvedSecrets = [];
7135
+ return blob;
7136
+ }
7137
+ const { value, unresolved } = await resolveSecretMarkers(blob, secrets);
7138
+ if (trackForConfig) {
7139
+ this._unresolvedSecrets = unresolved;
7140
+ if (unresolved.length > 0) {
7141
+ this._ctx?.logger?.error?.("secret unavailable — running without it, will retry", { meta: { secrets: unresolved.map((u) => ({
7142
+ ref: u.ref,
7143
+ reason: u.reason
7144
+ })) } });
7145
+ if (unresolved.some((u) => u.reason !== "missing" && u.reason !== "forbidden")) {
7146
+ this.scheduleSecretReresolve(this._secretRetryDelayMs);
7147
+ this._secretRetryDelayMs = Math.min(this._secretRetryDelayMs * 2, SECRET_RETRY_MAX_MS);
7148
+ }
7149
+ } else this._secretRetryDelayMs = SECRET_RETRY_FIRST_MS;
7150
+ }
7151
+ return value;
7152
+ }
7153
+ /** Re-resolve the config (a keychain-only change, or a retry) and apply it. */
7154
+ scheduleSecretReresolve(delayMs) {
7155
+ const timerOf = delayMs === SECRET_CHANGE_DEBOUNCE_MS ? "_secretChangeTimer" : "_secretRetryTimer";
7156
+ if (this[timerOf] !== null) return;
7157
+ const timer = setTimeout(() => {
7158
+ this[timerOf] = null;
7159
+ if (this._ctx === null) return;
7160
+ this.resolveConfig().then(() => this.onConfigChanged()).catch((err) => {
7161
+ this._ctx?.logger?.error?.("re-resolving secrets failed", { meta: { error: err instanceof Error ? err.message : String(err) } });
7162
+ });
7163
+ }, delayMs);
7164
+ timer.unref?.();
7165
+ this[timerOf] = timer;
7166
+ }
6500
7167
  /**
6501
7168
  * Wrap `ctx.settings.readAddonStore()` with a short retry budget so a
6502
7169
  * transient settings-store outage (mid-restart of sqlite-settings, tsx-watch
@@ -7106,6 +7773,69 @@ method(object({ deviceId: number() }), array(StreamSourceEntrySchema)), method(o
7106
7773
  kind: "mutation",
7107
7774
  auth: "admin"
7108
7775
  }), method(object({ deviceId: number() }), unknown().nullable()), method(object({ deviceId: number() }), RawStateResultSchema.nullable(), { auth: "protected" });
7776
+ function defOf(schema) {
7777
+ return schema._zod?.def ?? {};
7778
+ }
7779
+ function declaredHere(schema) {
7780
+ return globalRegistry.get(schema)?.secret === true;
7781
+ }
7782
+ /** Wrapper kinds whose `innerType` is the field itself. */
7783
+ var WRAPPERS = new Set([
7784
+ "optional",
7785
+ "nullable",
7786
+ "default",
7787
+ "prefault",
7788
+ "catch",
7789
+ "readonly",
7790
+ "nonoptional"
7791
+ ]);
7792
+ /**
7793
+ * The schema layers that make up ONE field: the schema itself and every
7794
+ * wrapper below it (optional / default / nullable / readonly / catch), plus
7795
+ * both sides of a pipe (`z.preprocess` puts the real schema on `out`,
7796
+ * `.transform` on `in`).
7797
+ */
7798
+ function layersOf(schema) {
7799
+ const out = [];
7800
+ const queue = [schema];
7801
+ while (queue.length > 0) {
7802
+ const s = queue.shift();
7803
+ if (!s || out.includes(s)) continue;
7804
+ out.push(s);
7805
+ const def = defOf(s);
7806
+ if (def.type !== void 0 && WRAPPERS.has(def.type) && def.innerType) queue.push(def.innerType);
7807
+ if (def.type === "pipe") {
7808
+ if (def.in) queue.push(def.in);
7809
+ if (def.out) queue.push(def.out);
7810
+ }
7811
+ }
7812
+ return out;
7813
+ }
7814
+ /** True when any layer of this field declares `.meta({ secret: true })`. */
7815
+ function isZodSecret(schema) {
7816
+ return layersOf(schema).some(declaredHere);
7817
+ }
7818
+ /**
7819
+ * Every declared secret path in a config schema: dotted keys, `[]` for "each
7820
+ * element of this array" (`connection.password`, `rows[].token`). A declared
7821
+ * object or array is reported as one path and not descended into — everything
7822
+ * under it is secret.
7823
+ */
7824
+ function collectZodSecretPaths(schema, prefix = "") {
7825
+ if (isZodSecret(schema)) return prefix.length > 0 ? [prefix] : [];
7826
+ const paths = [];
7827
+ for (const layer of layersOf(schema)) {
7828
+ const def = defOf(layer);
7829
+ if (def.type === "object" && def.shape) for (const [key, child] of Object.entries(def.shape)) paths.push(...collectZodSecretPaths(child, prefix ? `${prefix}.${key}` : key));
7830
+ else if (def.type === "array" && def.element) paths.push(...collectZodSecretPaths(def.element, `${prefix}[]`));
7831
+ else if (def.type === "union" && def.options) for (const option of def.options) paths.push(...collectZodSecretPaths(option, prefix));
7832
+ else if (def.type === "intersection") {
7833
+ if (def.left) paths.push(...collectZodSecretPaths(def.left, prefix));
7834
+ if (def.right) paths.push(...collectZodSecretPaths(def.right, prefix));
7835
+ }
7836
+ }
7837
+ return [...new Set(paths)];
7838
+ }
7109
7839
  /**
7110
7840
  * Promise-based timer helpers — used everywhere the codebase needs to
7111
7841
  * wait, back off, or schedule a retry. Before these helpers landed, each
@@ -14702,6 +15432,196 @@ id: union([string(), number()]) }), {
14702
15432
  kind: "mutation",
14703
15433
  auth: "admin"
14704
15434
  });
15435
+ /**
15436
+ * `keychain` — the hub's encrypted store of secret values (D787).
15437
+ *
15438
+ * Settings blobs never hold a secret: they hold a marker
15439
+ * `{"$secret":"secret://<owner>/<scope>/<fieldPath>","v":1}` and the value
15440
+ * lives here, AES-256-GCM under a data key that a master key wraps. This cap
15441
+ * is the OWNER's door to its own values: every method is owner-checked
15442
+ * against the CALLER, never against anything the caller claims.
15443
+ *
15444
+ * Who the caller is: the transport stamps `callerAddonId` into the args of a
15445
+ * call that crossed a process (the parent `LocalChildRegistry` from the UDS
15446
+ * connection, the agent from its child's connection carried in
15447
+ * `$hub-cap-fwd`'s envelope). A stamp always overwrites; a wire call with no
15448
+ * stamp has its claim stripped. Only a hub in-process caller may state its own
15449
+ * identity — `ctx.secrets` does that with the addon id closed over. This is
15450
+ * identity against BUGS and misrouting, not against a malicious addon (every
15451
+ * runner is the same OS user): see the threat model in
15452
+ * `docs/design/2026-10-08-secrets-keychain.md`.
15453
+ *
15454
+ * `callerAddonId` is deliberately NOT in any input schema: the tRPC router
15455
+ * parses the input, so a session can never supply it, and the internal mount
15456
+ * floors every method to admin anyway (D240).
15457
+ *
15458
+ * Internal: addons reach it through `ctx.secrets`, never directly.
15459
+ */
15460
+ /** Why a value cannot be served right now. Never folded into "missing". */
15461
+ var KeychainUnavailableReasonSchema = _enum([
15462
+ "key-missing",
15463
+ "wrong-key",
15464
+ "key-file-unreadable",
15465
+ "store-unavailable",
15466
+ "not-initialized",
15467
+ "decrypt-failed"
15468
+ ]);
15469
+ var KeychainStateSchema = discriminatedUnion("state", [object({ state: literal("ready") }), object({
15470
+ state: literal("locked"),
15471
+ reason: KeychainUnavailableReasonSchema
15472
+ })]);
15473
+ var KeychainResolveEntrySchema = discriminatedUnion("kind", [
15474
+ object({
15475
+ kind: literal("value"),
15476
+ value: string(),
15477
+ version: number().int()
15478
+ }),
15479
+ object({ kind: literal("missing") }),
15480
+ object({
15481
+ kind: literal("unavailable"),
15482
+ reason: KeychainUnavailableReasonSchema
15483
+ }),
15484
+ object({ kind: literal("forbidden") })
15485
+ ]);
15486
+ var KeychainResolveResultSchema = record(string(), KeychainResolveEntrySchema);
15487
+ /** Metadata of one stored value — never the value. */
15488
+ var KeychainSecretMetaSchema = object({
15489
+ ref: string(),
15490
+ owner: string(),
15491
+ /** Formatted scope (`global`, `node/<id>`, `device/<id>`, …). */
15492
+ scope: string(),
15493
+ fieldPath: string(),
15494
+ version: number().int(),
15495
+ createdAt: number(),
15496
+ updatedAt: number(),
15497
+ /** `addon:<id>` | `user:<id>` | `system`. */
15498
+ updatedBy: string(),
15499
+ /** Coarse — written at most once an hour per ref. `null` = never read. */
15500
+ lastReadAt: number().nullable()
15501
+ });
15502
+ var RefListSchema = array(string().min(1)).max(512);
15503
+ method(object({
15504
+ ref: string().min(1),
15505
+ value: string().min(1)
15506
+ }), object({
15507
+ ref: string(),
15508
+ version: number().int()
15509
+ }), {
15510
+ kind: "mutation",
15511
+ auth: "admin"
15512
+ }), method(object({ refs: RefListSchema }), KeychainResolveResultSchema, { auth: "admin" }), method(object({ refs: RefListSchema }), object({ deleted: number().int() }), {
15513
+ kind: "mutation",
15514
+ auth: "admin"
15515
+ }), method(object({}), array(KeychainSecretMetaSchema).readonly(), { auth: "admin" }), method(object({}), KeychainStateSchema, { auth: "admin" });
15516
+ var KeychainKeySourceSchema = object({
15517
+ kind: _enum([
15518
+ "config-file",
15519
+ "previous-config-file",
15520
+ "platform",
15521
+ "default-file"
15522
+ ]),
15523
+ /** File sources only — a path is not a secret. */
15524
+ path: string().optional(),
15525
+ /**
15526
+ * True when a whole-volume backup of the data directory carries this key
15527
+ * next to the database it protects (the default file). The page warns.
15528
+ */
15529
+ sharesBackupWithDatabase: boolean()
15530
+ });
15531
+ var KeychainStatusSchema = object({
15532
+ keychain: KeychainStateSchema,
15533
+ /** The source of the master key in use; `null` while locked. */
15534
+ keySource: KeychainKeySourceSchema.nullable(),
15535
+ /** The source configured to be primary — differs from `keySource` while a rotation is pending. */
15536
+ configuredSource: KeychainKeySourceSchema,
15537
+ /** Short fingerprint of the master key in use (`HMAC(KEK, label)`, 16 hex). */
15538
+ fingerprint: string().nullable(),
15539
+ activeKeyId: string().nullable(),
15540
+ /**
15541
+ * The keychain unlocked with a NON-primary source: the configured primary
15542
+ * key is not the one that wraps the data key yet. `rotateMasterKey` moves it.
15543
+ */
15544
+ rotationPending: boolean(),
15545
+ /** Wrapped copies of the data key under a previous master key, kept until purged. */
15546
+ retiredWraps: number().int(),
15547
+ recoveryKeyDownloadedAt: number().nullable(),
15548
+ secretCount: number().int()
15549
+ });
15550
+ /**
15551
+ * Whether a stored value is still pointed at by its owner's settings.
15552
+ * `unknown` is a first-class answer: a scope whose blob could not be read is
15553
+ * never reported as an orphan (and never deleted as one).
15554
+ */
15555
+ var KeychainSecretUsageSchema = _enum([
15556
+ "in-use",
15557
+ "orphan",
15558
+ "unknown"
15559
+ ]);
15560
+ var KeychainAdminSecretSchema = KeychainSecretMetaSchema.extend({ usage: KeychainSecretUsageSchema });
15561
+ var KeychainAuditActionSchema = _enum([
15562
+ "put",
15563
+ "delete",
15564
+ "reveal",
15565
+ "rotate-master-key",
15566
+ "purge-retired-keys",
15567
+ "download-recovery-key",
15568
+ "delete-orphans",
15569
+ "reset",
15570
+ "initialize"
15571
+ ]);
15572
+ var KeychainAuditEntrySchema = object({
15573
+ id: string(),
15574
+ at: number(),
15575
+ action: KeychainAuditActionSchema,
15576
+ /** `addon:<id>` | `user:<id>` | `system`. */
15577
+ actor: string(),
15578
+ ref: string().nullable(),
15579
+ detail: string().nullable()
15580
+ });
15581
+ method(object({}), KeychainStatusSchema, { auth: "admin" }), method(object({}), array(KeychainAdminSecretSchema).readonly(), { auth: "admin" }), method(object({ limit: number().int().min(1).max(500).optional() }), array(KeychainAuditEntrySchema).readonly(), { auth: "admin" }), method(object({ ref: string().min(1) }), object({
15582
+ value: string(),
15583
+ version: number().int()
15584
+ }), {
15585
+ kind: "mutation",
15586
+ auth: "admin",
15587
+ caller: "required"
15588
+ }), method(object({ refs: array(string().min(1)).max(1e3) }), object({
15589
+ deleted: array(string()).readonly(),
15590
+ kept: array(object({
15591
+ ref: string(),
15592
+ usage: KeychainSecretUsageSchema
15593
+ })).readonly()
15594
+ }), {
15595
+ kind: "mutation",
15596
+ auth: "admin",
15597
+ caller: "required"
15598
+ }), method(object({}), object({
15599
+ fingerprint: string(),
15600
+ keySource: KeychainKeySourceSchema
15601
+ }), {
15602
+ kind: "mutation",
15603
+ auth: "admin",
15604
+ caller: "required"
15605
+ }), method(object({}), object({ purged: number().int() }), {
15606
+ kind: "mutation",
15607
+ auth: "admin",
15608
+ caller: "required"
15609
+ }), method(object({}), object({
15610
+ key: string(),
15611
+ fingerprint: string(),
15612
+ keySource: KeychainKeySourceSchema
15613
+ }), {
15614
+ kind: "mutation",
15615
+ auth: "admin",
15616
+ caller: "required"
15617
+ }), method(object({ confirm: literal("RESET KEYCHAIN") }), object({
15618
+ archivedCollection: string().nullable(),
15619
+ archived: number().int()
15620
+ }), {
15621
+ kind: "mutation",
15622
+ auth: "admin",
15623
+ caller: "required"
15624
+ });
14705
15625
  method(_void(), object({
14706
15626
  id: string(),
14707
15627
  name: string(),
@@ -16040,7 +16960,11 @@ var DeviceRegisterPayloadSchema = object({
16040
16960
  var DeviceRemovePayloadSchema = object({ deviceId: number() });
16041
16961
  var DevicePersistConfigPayloadSchema = object({
16042
16962
  deviceId: number(),
16043
- data: record(string(), unknown())
16963
+ data: record(string(), unknown()),
16964
+ /** The paths the device's schema declares secret (D783), when the caller
16965
+ * knows them — those values are kept in the keychain, not the blob (D787).
16966
+ * Absent: the paths the device last reported at `registerDevice` apply. */
16967
+ secretConfigPaths: array(string()).optional()
16044
16968
  });
16045
16969
  /** What a migration actually did, per switch. `unreachable` is a first-class
16046
16970
  * answer: a camera that could not be asked is not a camera that was silenced. */
@@ -23097,8 +24021,23 @@ var RetrainMacroClassSchema = _enum([
23097
24021
  ]);
23098
24022
  /** A subject to learn, or a phantom to unlearn (taught by OMISSION). */
23099
24023
  var RetrainAnnotationKindSchema = _enum(["subject", "model_error"]);
23100
- /** Did a human draw this box, or did the assist propose it? */
23101
- var RetrainAnnotationSourceSchema = _enum(["operator", "assist"]);
24024
+ /**
24025
+ * Where a box came from. A machine-sourced box is a DRAFT on the page until
24026
+ * the operator confirms it; once saved it keeps its source as provenance.
24027
+ *
24028
+ * - `operator` — drawn by hand.
24029
+ * - `assist` — proposed by a detector run on the copy (the camera's own
24030
+ * model, or a larger teacher model).
24031
+ * - `pipeline` — the box the live pipeline actually drew on that frame, read
24032
+ * back from the track store (never a re-run).
24033
+ * - `llm` — proposed by a vision-capable LLM profile.
24034
+ */
24035
+ var RetrainAnnotationSourceSchema = _enum([
24036
+ "operator",
24037
+ "assist",
24038
+ "pipeline",
24039
+ "llm"
24040
+ ]);
23102
24041
  /** Normalised `[0,1]` rectangle against the FULL frame — the canonical form. */
23103
24042
  var RetrainBboxSchema = object({
23104
24043
  x: number(),
@@ -23116,7 +24055,8 @@ var RetrainBboxSchema = object({
23116
24055
  */
23117
24056
  var RetrainAnnotationSchema = object({
23118
24057
  id: string(),
23119
- trackId: string(),
24058
+ /** The frame's track. Absent on a recording still, which has none. */
24059
+ trackId: string().optional(),
23120
24060
  deviceId: number(),
23121
24061
  /** The COPY in retrain storage — never the source track's media key. */
23122
24062
  mediaKey: string(),
@@ -23165,13 +24105,47 @@ var RetrainFrameCandidateSchema = object({
23165
24105
  * fail, whatever became of the original. */
23166
24106
  copied: boolean()
23167
24107
  });
24108
+ /**
24109
+ * One box the live pipeline drew on a copied frame — what a correction starts
24110
+ * from. Derived when the frame is listed, from the track store: the subject
24111
+ * box recorded on the source media row when there is one, else the track
24112
+ * position nearest the frame's capture time. Never stored as an annotation
24113
+ * until the operator confirms it.
24114
+ */
24115
+ var RetrainPipelineBoxSchema = object({
24116
+ /** Normalised `[0,1]` against the full frame. */
24117
+ bbox: RetrainBboxSchema,
24118
+ macroClass: RetrainMacroClassSchema,
24119
+ label: string().optional(),
24120
+ subLabel: string().optional(),
24121
+ /** The detection score of the position used, when it was recorded. */
24122
+ score: number().optional(),
24123
+ /** The root model that produced the track, when it was recorded. */
24124
+ modelId: string().optional(),
24125
+ trackId: string(),
24126
+ /** `subject-box`: recorded on this very frame. `position`: the track's
24127
+ * position nearest the capture time, `deltaMs` away. */
24128
+ basis: _enum(["subject-box", "position"]),
24129
+ deltaMs: number()
24130
+ });
24131
+ /**
24132
+ * Where a retrain frame came from: a TRACK's stored media (copy-on-select),
24133
+ * or the RECORDING at an instant — the frame a model saw nothing in has no
24134
+ * track at all.
24135
+ */
24136
+ var RetrainFrameOriginSchema = _enum(["track", "recording"]);
23168
24137
  /** A frame the dataset OWNS: bytes copied at selection time. */
23169
24138
  var RetrainFrameSchema = object({
23170
24139
  frameId: string(),
23171
24140
  deviceId: number(),
23172
- trackId: string(),
23173
- /** Provenance only. It may already point at nothing — that is expected. */
23174
- sourceMediaId: number().int(),
24141
+ origin: RetrainFrameOriginSchema,
24142
+ /** The track it was copied from. Absent on a recording still. */
24143
+ trackId: string().optional(),
24144
+ /** Provenance only. It may already point at nothing — that is expected.
24145
+ * Absent on a recording still. */
24146
+ sourceMediaId: number().int().optional(),
24147
+ /** A recording still: the playhead instant it was taken at. */
24148
+ epochMs: number().optional(),
23175
24149
  sourceKind: MediaFileKindEnum,
23176
24150
  sizeBytes: number().int(),
23177
24151
  width: number().int(),
@@ -23182,7 +24156,12 @@ var RetrainFrameSchema = object({
23182
24156
  /** The operator's "every subject in this frame is boxed". Detector
23183
24157
  * evaluation keeps only complete frames: an unboxed subject would count as
23184
24158
  * a false positive. */
23185
- complete: boolean()
24159
+ complete: boolean(),
24160
+ /** The boxes the pipeline drew on this frame. Present on list answers;
24161
+ * empty when nothing the track store holds can be placed on it. */
24162
+ pipelineBoxes: array(RetrainPipelineBoxSchema).readonly().optional(),
24163
+ /** The named collections this frame belongs to. Present on list answers. */
24164
+ collectionIds: array(string()).readonly().optional()
23186
24165
  });
23187
24166
  /** Why a copy-on-select could not be honoured — named, never a silent skip. */
23188
24167
  var RetrainCopyRefusalSchema = _enum([
@@ -23213,6 +24192,8 @@ var RetrainFrameListSchema = object({
23213
24192
  var RetrainExportFilterSchema = object({
23214
24193
  deviceIds: array(number()).optional(),
23215
24194
  frameIds: array(string()).max(2e4).optional(),
24195
+ /** Only frames in at least one of these named collections. */
24196
+ collectionIds: array(string()).max(200).optional(),
23216
24197
  batchId: string().optional(),
23217
24198
  /** Only frames the operator marked complete (all subjects boxed). */
23218
24199
  completeOnly: boolean().optional()
@@ -23277,6 +24258,109 @@ var RetrainAssistResultSchema = discriminatedUnion("kind", [object({
23277
24258
  reason: string(),
23278
24259
  detail: string().optional()
23279
24260
  })]);
24261
+ /** A named set over the retrain corpus — membership only, it owns no pixels. */
24262
+ var RetrainCollectionSchema = object({
24263
+ id: string(),
24264
+ name: string(),
24265
+ createdAt: number(),
24266
+ frameCount: number().int()
24267
+ });
24268
+ var RetrainCollectionCreateResultSchema = discriminatedUnion("kind", [object({
24269
+ kind: literal("created"),
24270
+ collection: RetrainCollectionSchema
24271
+ }), object({
24272
+ kind: literal("refused"),
24273
+ reason: _enum(["empty-name", "duplicate-name"])
24274
+ })]);
24275
+ var RetrainCollectionRenameResultSchema = discriminatedUnion("kind", [object({
24276
+ kind: literal("renamed"),
24277
+ collection: RetrainCollectionSchema
24278
+ }), object({
24279
+ kind: literal("refused"),
24280
+ reason: _enum([
24281
+ "empty-name",
24282
+ "duplicate-name",
24283
+ "unknown-collection"
24284
+ ])
24285
+ })]);
24286
+ /**
24287
+ * The outcome of adding the frame at a recording instant. Every refusal is
24288
+ * named: `still-unavailable` (not recording, a gap, or an undecodable frame —
24289
+ * `detail` says which), `still-busy` (the recorder is at its decode bound; try
24290
+ * again), `unreadable-image`, `write-failed`, `unknown-collection`.
24291
+ */
24292
+ var AddRetrainFrameFromRecordingResultSchema = discriminatedUnion("kind", [object({
24293
+ kind: literal("added"),
24294
+ collectionId: string(),
24295
+ frame: RetrainFrameSchema,
24296
+ /** The moment was already in the dataset; nothing was decoded. */
24297
+ reused: boolean()
24298
+ }), object({
24299
+ kind: literal("refused"),
24300
+ reason: _enum([
24301
+ "unknown-collection",
24302
+ "still-unavailable",
24303
+ "still-busy",
24304
+ "unreadable-image",
24305
+ "write-failed"
24306
+ ]),
24307
+ detail: string().optional()
24308
+ })]);
24309
+ /** A vision LLM profile the AI assist may use, and where it sends the frame. */
24310
+ var RetrainAssistProfileSchema = object({
24311
+ id: string(),
24312
+ name: string(),
24313
+ model: string(),
24314
+ kind: string(),
24315
+ /** `true` when the frame would leave the house (a cloud vendor, or an
24316
+ * endpoint that is not on the local network). The page confirms each such
24317
+ * run, and the provider refuses one without `allowCloud`. */
24318
+ leavesHouse: boolean()
24319
+ });
24320
+ /** A box the AI assist proposed: a draft, plus the model's own reason. */
24321
+ var RetrainLlmProposalSchema = RetrainAnnotationDraftSchema.extend({ reason: string() });
24322
+ /** What the AI assist said about a box that was already on the canvas. */
24323
+ var RetrainLlmReviewSchema = object({
24324
+ /** The `ref` the page sent the box under. */
24325
+ ref: string(),
24326
+ verdict: _enum([
24327
+ "confirmed",
24328
+ "wrong-class",
24329
+ "not-an-object",
24330
+ "uncertain"
24331
+ ]),
24332
+ suggestedClass: RetrainMacroClassSchema.optional(),
24333
+ reason: string()
24334
+ });
24335
+ /**
24336
+ * The AI assist's answer. `proposed` carries drafts (`source: 'llm'`, the
24337
+ * model and its confidence) and reviews; items the model got wrong (a box off
24338
+ * the frame, an unasked class, an unknown ref) are dropped and counted in
24339
+ * `rejected`. A whole answer that is not the schema is `malformed-answer`.
24340
+ */
24341
+ var RetrainLlmAssistResultSchema = discriminatedUnion("kind", [object({
24342
+ kind: literal("proposed"),
24343
+ profileId: string(),
24344
+ model: string(),
24345
+ /** The frame was sent outside the house for this answer. */
24346
+ leftHouse: boolean(),
24347
+ proposals: array(RetrainLlmProposalSchema).readonly(),
24348
+ reviews: array(RetrainLlmReviewSchema).readonly(),
24349
+ rejected: number().int()
24350
+ }), object({
24351
+ kind: literal("refused"),
24352
+ reason: _enum([
24353
+ "unknown-frame",
24354
+ "unreadable-frame",
24355
+ "unknown-profile",
24356
+ "profile-disabled",
24357
+ "no-vision",
24358
+ "cloud-not-confirmed",
24359
+ "llm-error",
24360
+ "malformed-answer"
24361
+ ]),
24362
+ detail: string().optional()
24363
+ })]);
23280
24364
  /** The outcome of a lifecycle move owned by the retrain page. */
23281
24365
  var RetrainTransitionResultSchema = object({
23282
24366
  trackId: string(),
@@ -23994,7 +25078,7 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
23994
25078
  auth: "admin"
23995
25079
  }), method(object({
23996
25080
  deviceId: number(),
23997
- trackId: string(),
25081
+ trackId: string().optional(),
23998
25082
  frameId: string()
23999
25083
  }), object({
24000
25084
  removed: boolean(),
@@ -24011,7 +25095,8 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
24011
25095
  auth: "admin"
24012
25096
  }), method(object({
24013
25097
  deviceId: number(),
24014
- trackId: string(),
25098
+ /** The frame's track, when it has one — checked against the frame. */
25099
+ trackId: string().optional(),
24015
25100
  frameId: string(),
24016
25101
  subject: RetrainAssistSubjectSchema,
24017
25102
  /** Which node runs it. Absent ⇒ wherever an unowned call lands. */
@@ -24019,12 +25104,16 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
24019
25104
  }), RetrainAssistResultSchema, {
24020
25105
  kind: "mutation",
24021
25106
  auth: "admin"
24022
- }), method(object({ trackId: string() }), array(RetrainAnnotationSchema).readonly(), {
25107
+ }), method(object({
25108
+ trackId: string().optional(),
25109
+ frameIds: array(string()).max(2e3).optional()
25110
+ }), array(RetrainAnnotationSchema).readonly(), {
24023
25111
  kind: "query",
24024
25112
  auth: "admin"
24025
25113
  }), method(object({
24026
25114
  deviceId: number(),
24027
- trackId: string(),
25115
+ /** The frame's track, when it has one — checked against the frame. */
25116
+ trackId: string().optional(),
24028
25117
  frameId: string(),
24029
25118
  annotations: array(RetrainAnnotationDraftSchema)
24030
25119
  }), array(RetrainAnnotationSchema).readonly(), {
@@ -24047,7 +25136,7 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
24047
25136
  auth: "admin"
24048
25137
  }), method(object({
24049
25138
  deviceId: number(),
24050
- trackId: string(),
25139
+ trackId: string().optional(),
24051
25140
  frameId: string(),
24052
25141
  complete: boolean()
24053
25142
  }), RetrainFrameSchema, {
@@ -24061,6 +25150,74 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
24061
25150
  kind: "mutation",
24062
25151
  auth: "admin",
24063
25152
  timeoutMs: 60 * 6e4
25153
+ }), method(object({}), array(RetrainAssistProfileSchema).readonly(), {
25154
+ kind: "query",
25155
+ auth: "admin"
25156
+ }), method(object({
25157
+ deviceId: number(),
25158
+ trackId: string().optional(),
25159
+ frameId: string(),
25160
+ profileId: string(),
25161
+ classes: array(RetrainMacroClassSchema).min(1),
25162
+ boxes: array(object({
25163
+ ref: string(),
25164
+ bbox: RetrainBboxSchema,
25165
+ macroClass: RetrainMacroClassSchema,
25166
+ label: string().optional()
25167
+ })).max(50),
25168
+ allowCloud: boolean()
25169
+ }), RetrainLlmAssistResultSchema, {
25170
+ kind: "mutation",
25171
+ auth: "admin",
25172
+ timeoutMs: 18e4
25173
+ }), method(object({ name: string().max(120) }), RetrainCollectionCreateResultSchema, {
25174
+ kind: "mutation",
25175
+ auth: "admin"
25176
+ }), method(object({}), array(RetrainCollectionSchema).readonly(), {
25177
+ kind: "query",
25178
+ auth: "admin"
25179
+ }), method(object({
25180
+ id: string(),
25181
+ name: string().max(120)
25182
+ }), RetrainCollectionRenameResultSchema, {
25183
+ kind: "mutation",
25184
+ auth: "admin"
25185
+ }), method(object({ id: string() }), object({
25186
+ deleted: boolean(),
25187
+ removedFrames: number().int()
25188
+ }), {
25189
+ kind: "mutation",
25190
+ auth: "admin"
25191
+ }), method(object({
25192
+ collectionId: string(),
25193
+ deviceId: number(),
25194
+ epochMs: number()
25195
+ }), AddRetrainFrameFromRecordingResultSchema, {
25196
+ kind: "mutation",
25197
+ auth: "admin",
25198
+ timeoutMs: 6e4
25199
+ }), method(object({
25200
+ collectionId: string(),
25201
+ frameIds: array(string()).min(1).max(500)
25202
+ }), object({
25203
+ added: number().int(),
25204
+ alreadyMember: number().int(),
25205
+ unknownFrameIds: array(string()).readonly()
25206
+ }), {
25207
+ kind: "mutation",
25208
+ auth: "admin"
25209
+ }), method(object({
25210
+ collectionId: string(),
25211
+ frameId: string()
25212
+ }), object({
25213
+ removed: boolean(),
25214
+ deletedFrame: boolean()
25215
+ }), {
25216
+ kind: "mutation",
25217
+ auth: "admin"
25218
+ }), method(object({ collectionId: string() }), array(RetrainFrameSchema).readonly(), {
25219
+ kind: "query",
25220
+ auth: "admin"
24064
25221
  }), method(object({
24065
25222
  /** Which of the three event tables owns the row. */
24066
25223
  ownerType: EventOwnerTypeSchema,
@@ -24684,13 +25841,31 @@ var RecommendationReasonSchema = discriminatedUnion("kind", [
24684
25841
  object({
24685
25842
  kind: literal("no-family-build"),
24686
25843
  format: ModelFormatSchema$1
25844
+ }),
25845
+ object({
25846
+ kind: literal("kept-custom-pin"),
25847
+ modelId: string(),
25848
+ deviceKey: string()
24687
25849
  })
24688
25850
  ]);
25851
+ /** Why a device is left exactly as it is, whatever the plan would pick (D786). */
25852
+ var KeptReasonSchema = _enum(["custom-pin"]);
25853
+ /**
25854
+ * Where a choice's latency came from (D791): this node's own benchmark
25855
+ * result, or the hardware-class table. Measured on the node beats the table.
25856
+ */
25857
+ var LatencySourceSchema = discriminatedUnion("kind", [object({ kind: literal("table") }), object({
25858
+ kind: literal("node-benchmark"),
25859
+ resultId: string(),
25860
+ measuredAtMs: number()
25861
+ })]);
24689
25862
  var DeviceModelChoiceSchema = object({
24690
25863
  modelId: string(),
24691
25864
  p50Ms: number(),
24692
25865
  fps: number(),
24693
25866
  measured: boolean(),
25867
+ /** Absent on a plan from before D791 — read as the table. */
25868
+ source: LatencySourceSchema.optional(),
24694
25869
  /** Parallel sessions at the camera rate with the headroom kept free: ⌊fps × (1 − headroom) / camera fps⌋. */
24695
25870
  capacitySessions: number(),
24696
25871
  personRecall: number()
@@ -24701,6 +25876,8 @@ var DeviceRecommendationSchema = object({
24701
25876
  enabled: boolean(),
24702
25877
  available: boolean(),
24703
25878
  chosen: DeviceModelChoiceSchema.nullable(),
25879
+ /** Present when the device is kept as is: Apply writes nothing on it. */
25880
+ kept: KeptReasonSchema.optional(),
24704
25881
  reasons: array(RecommendationReasonSchema).readonly()
24705
25882
  });
24706
25883
  var NodeRecommendationSchema = object({
@@ -24754,6 +25931,17 @@ var AutoTuneWarningSchema = discriminatedUnion("kind", [
24754
25931
  kind: literal("coral-enabled"),
24755
25932
  nodeId: string(),
24756
25933
  deviceKey: string()
25934
+ }),
25935
+ object({
25936
+ kind: literal("custom-pin-kept"),
25937
+ nodeId: string(),
25938
+ deviceKey: string().nullable(),
25939
+ deviceId: number().nullable(),
25940
+ modelId: string()
25941
+ }),
25942
+ object({
25943
+ kind: literal("custom-registry-unreadable"),
25944
+ error: string()
24757
25945
  })
24758
25946
  ]);
24759
25947
  var AutoTuneOptionsSchema = object({
@@ -24932,13 +26120,14 @@ var SuggestSharesResultSchema = object({
24932
26120
  nodes: array(SuggestedNodeShareSchema).readonly()
24933
26121
  });
24934
26122
  /**
24935
- * Where the node and device shares come from (D750, D755).
24936
- * - `hardware` (default) — computed by the system from each node's static
24937
- * capacity (its accelerators at their Auto tune models, from the measured
24938
- * latency table), recomputed whenever a node or device joins, leaves, is
24939
- * switched on or off, or changes model. No load input.
24940
- * - `benchmark` — the same, from each node's measured capacity (node
24941
- * benchmark results); a node without results falls back to `hardware`.
26123
+ * Where the node and device shares come from (D750, D755, D791).
26124
+ * - `benchmark` (default since D791) — each node's capacity as its own node
26125
+ * benchmark measured it; a node without fresh results is sized from
26126
+ * `hardware` and says so. Measured on the node beats the table.
26127
+ * - `hardware` — computed from each node's static capacity only (its
26128
+ * accelerators at their Auto tune models, from the latency table).
26129
+ * Both are recomputed whenever a node or device joins, leaves, is switched
26130
+ * on or off, changes model, or a benchmark result is written. No load input.
24942
26131
  * - `manual` — the operator's stored sliders.
24943
26132
  * Either way a node or device that cannot take sessions gives its share to
24944
26133
  * the others in proportion; the stored values are never rewritten for that.
@@ -24987,6 +26176,362 @@ var EffectiveSharesSchema = object({
24987
26176
  nodeWeights: record(string(), number()),
24988
26177
  deviceWeights: record(string(), record(string(), number()))
24989
26178
  });
26179
+ /**
26180
+ * Wire shapes of the node benchmark (D791): the operator's plan, the
26181
+ * preflight the confirmation shows, the run the orchestrator owns, what the
26182
+ * measuring runner reports, and the result rows Auto tune and the automatic
26183
+ * shares read.
26184
+ *
26185
+ * ONE node at a time, owned by the pipeline orchestrator. While a run is
26186
+ * active the cluster is in BENCHMARK MODE for that node: it is not a
26187
+ * detection candidate, camera pins naming it are ignored so its sessions move
26188
+ * elsewhere, and both come back when the mode ends — after a crash or a hub
26189
+ * restart too (a persisted manifest, reconciled against the registry).
26190
+ *
26191
+ * Two measurements, both on the node, driven by its own runner (frames never
26192
+ * cross a process at frame rate, D9):
26193
+ * - `device` — one accelerator × one candidate detector, root only, open
26194
+ * loop: how many streams at the camera rate it carries inside the frame
26195
+ * interval;
26196
+ * - `pipeline` — the chosen detector plus the operator's detail steps
26197
+ * (faces, plates, classifiers, CLIP…), on varied frames from the bench
26198
+ * clip: how many parallel sessions the node carries before latency, drops,
26199
+ * CPU, RAM or the event loop give out.
26200
+ */
26201
+ /** Defaults and bounds, one place. */
26202
+ var NODE_BENCHMARK_DEFAULTS = {
26203
+ fpsPerStream: 10,
26204
+ budgetMinutes: 45,
26205
+ minBudgetMinutes: 10,
26206
+ maxBudgetMinutes: 120,
26207
+ /** A result older than this no longer beats the table. */
26208
+ staleAfterDays: 30,
26209
+ /** Warm-in per ramp step (not accounted). */
26210
+ settleSec: 5,
26211
+ /** Accounted window per ramp step. */
26212
+ measureSec: 20,
26213
+ /** Longest the drain may take before the run is refused. */
26214
+ drainTimeoutSec: 120,
26215
+ /** Candidate models per device in one run. */
26216
+ maxModelsPerDevice: 6
26217
+ };
26218
+ /** The two measurements a run can make. */
26219
+ var NodeBenchmarkPhaseSchema = _enum(["device", "pipeline"]);
26220
+ var NodeBenchmarkDevicePlanSchema = object({
26221
+ /** `<backend>:<device>` — `openvino:npu`, `coreml:all`, `cpu`. */
26222
+ deviceKey: string().min(1),
26223
+ /**
26224
+ * Root detector candidates for the `device` measurement, in the order
26225
+ * measured. The FIRST is the one the `pipeline` measurement runs.
26226
+ */
26227
+ modelIds: array(string().min(1)).min(1).max(NODE_BENCHMARK_DEFAULTS.maxModelsPerDevice)
26228
+ });
26229
+ /** What the operator confirmed. */
26230
+ var NodeBenchmarkPlanSchema = object({
26231
+ nodeId: string().min(1),
26232
+ devices: array(NodeBenchmarkDevicePlanSchema).min(1),
26233
+ /** Which measurements run. At least one. */
26234
+ phases: array(NodeBenchmarkPhaseSchema).min(1).default(["device", "pipeline"]),
26235
+ /**
26236
+ * Detail steps (catalog step ids under the root: faces, plates,
26237
+ * classifiers, CLIP…) the `pipeline` measurement enables. The root
26238
+ * detector always runs.
26239
+ */
26240
+ steps: array(string().min(1)).default([]),
26241
+ /** Offered rate of one stream / session. */
26242
+ fpsPerStream: number().int().min(1).max(30).default(NODE_BENCHMARK_DEFAULTS.fpsPerStream),
26243
+ /** Hard deadline: the mode ends and the cluster is restored when it passes. */
26244
+ budgetMinutes: number().int().min(NODE_BENCHMARK_DEFAULTS.minBudgetMinutes).max(NODE_BENCHMARK_DEFAULTS.maxBudgetMinutes).default(NODE_BENCHMARK_DEFAULTS.budgetMinutes),
26245
+ /** Keep the models the run downloaded (default: delete what was not installed before). */
26246
+ keepDownloadedModels: boolean().default(false),
26247
+ /** Start although the other nodes' capacity does not cover the sessions running now. */
26248
+ acceptInsufficientHeadroom: boolean().default(false)
26249
+ });
26250
+ var NodeBenchmarkRefusalSchema = object({
26251
+ kind: _enum([
26252
+ "benchmark-active",
26253
+ "node-offline",
26254
+ "unknown-device",
26255
+ "no-phase",
26256
+ "insufficient-headroom"
26257
+ ]),
26258
+ detail: string(),
26259
+ overridable: boolean()
26260
+ });
26261
+ /** A camera whose detection leaves the node for the run. */
26262
+ var NodeBenchmarkMovingCameraSchema = object({
26263
+ deviceId: number(),
26264
+ /** Placed on the node now (a standing attach or a running session). */
26265
+ placedOnNode: boolean(),
26266
+ /** A node pin naming this node, ignored for the run. */
26267
+ pinnedToNode: boolean()
26268
+ });
26269
+ /** A camera that cannot leave: no other node can obtain its frames. */
26270
+ var NodeBenchmarkStayingCameraSchema = object({
26271
+ deviceId: number(),
26272
+ reason: literal("only-frame-source")
26273
+ });
26274
+ var NodeBenchmarkPreflightSchema = object({
26275
+ nodeId: string(),
26276
+ online: boolean(),
26277
+ moving: array(NodeBenchmarkMovingCameraSchema).readonly(),
26278
+ /** Keep running on the node during the run; the result is flagged contaminated. */
26279
+ staying: array(NodeBenchmarkStayingCameraSchema).readonly(),
26280
+ estimatedDurationMs: number(),
26281
+ /** The run ends and the cluster is restored at the latest after this long. */
26282
+ budgetMs: number(),
26283
+ phases: array(NodeBenchmarkPhaseSchema).readonly(),
26284
+ steps: array(string()).readonly(),
26285
+ devices: array(NodeBenchmarkDevicePlanSchema).readonly(),
26286
+ /** Parallel sessions the cluster runs now, and what the other nodes can carry. */
26287
+ headroom: object({
26288
+ sessionsNow: number(),
26289
+ otherNodesCapacitySessions: number().nullable()
26290
+ }),
26291
+ refusals: array(NodeBenchmarkRefusalSchema).readonly(),
26292
+ canStart: boolean()
26293
+ });
26294
+ /** Where the measuring runner is. */
26295
+ var NodeBenchProgressSchema = object({
26296
+ phase: _enum([
26297
+ "preparing",
26298
+ "device",
26299
+ "pipeline",
26300
+ "cleanup"
26301
+ ]),
26302
+ deviceKey: string().nullable(),
26303
+ modelId: string().nullable(),
26304
+ /** Streams (device) or sessions (pipeline) of the step running now. */
26305
+ load: number().nullable(),
26306
+ cellsDone: number(),
26307
+ cellsTotal: number(),
26308
+ message: string()
26309
+ });
26310
+ /** What limited a ramp. `none` = the ramp ran out of steps still passing. */
26311
+ var NodeBenchLimitSchema = _enum([
26312
+ "p95",
26313
+ "drops",
26314
+ "errors",
26315
+ "stall",
26316
+ "cpu",
26317
+ "ram",
26318
+ "none"
26319
+ ]);
26320
+ var NodeBenchRampStepSchema = object({
26321
+ load: number(),
26322
+ pass: boolean(),
26323
+ p95Ms: number(),
26324
+ dropRatio: number(),
26325
+ /** Completed frames per second over the accounted window. */
26326
+ fps: number(),
26327
+ cpuPct: number().nullable(),
26328
+ ramFreePct: number().nullable(),
26329
+ failReasons: array(string()).readonly()
26330
+ });
26331
+ var NodeBenchCellSchema = discriminatedUnion("phase", [object({
26332
+ phase: literal("device"),
26333
+ deviceKey: string(),
26334
+ modelId: string(),
26335
+ /** Single-stream latency (the K = 1 step). */
26336
+ p50Ms: number(),
26337
+ p95Ms: number(),
26338
+ p99Ms: number(),
26339
+ /** Frames per second sustained at the last passing step. */
26340
+ fps: number(),
26341
+ /** Streams at the camera rate the device carried inside the frame interval; 0 = not even one. */
26342
+ kMax: number(),
26343
+ limitedBy: NodeBenchLimitSchema,
26344
+ /** First call (model load + warm-up). */
26345
+ warmupMs: number(),
26346
+ ramp: array(NodeBenchRampStepSchema).readonly()
26347
+ }), object({
26348
+ phase: literal("pipeline"),
26349
+ deviceKey: string(),
26350
+ modelId: string(),
26351
+ steps: array(string()).readonly(),
26352
+ /** Parallel sessions at the camera rate the node carried; 0 = not even one. */
26353
+ maxSessions: number(),
26354
+ limitedBy: NodeBenchLimitSchema,
26355
+ /** Detail steps that produced at least one result on the clip — a step that never fired measured nothing. */
26356
+ stepsFired: array(string()).readonly(),
26357
+ warmupMs: number(),
26358
+ ramp: array(NodeBenchRampStepSchema).readonly()
26359
+ })]);
26360
+ /**
26361
+ * What a result was measured ON. A result whose fingerprint no longer matches
26362
+ * the node no longer beats the table.
26363
+ */
26364
+ var NodeBenchFingerprintSchema = object({
26365
+ pipelineVersion: string().nullable(),
26366
+ cpuModel: string().nullable(),
26367
+ ramGb: number().nullable(),
26368
+ os: string().nullable(),
26369
+ /** Per device: the pool the cells ran on (runtime + tuning). */
26370
+ pools: record(string(), object({
26371
+ runtime: string(),
26372
+ numWorkers: number(),
26373
+ concurrency: number(),
26374
+ batchMode: string()
26375
+ })).default({})
26376
+ });
26377
+ /** The frames the run used. */
26378
+ var NodeBenchClipSchema = object({
26379
+ /** `camstack-bench-v1` or `reference-images` (the fallback when the clip is not reachable). */
26380
+ id: string(),
26381
+ revision: string().nullable(),
26382
+ frames: number(),
26383
+ width: number(),
26384
+ height: number()
26385
+ });
26386
+ var NodeBenchRunnerInputSchema = object({
26387
+ runId: string().min(1),
26388
+ devices: array(NodeBenchmarkDevicePlanSchema).min(1),
26389
+ phases: array(NodeBenchmarkPhaseSchema).min(1),
26390
+ /** The full detail step tree root for the `pipeline` measurement is built on the node from these ids. */
26391
+ steps: array(string()).default([]),
26392
+ fpsPerStream: number().int().min(1).max(30),
26393
+ /** The runner stops on its own past this instant, whatever the hub does. */
26394
+ deadlineAtMs: number(),
26395
+ settleSec: number().min(0).max(60).default(NODE_BENCHMARK_DEFAULTS.settleSec),
26396
+ measureSec: number().min(2).max(300).default(NODE_BENCHMARK_DEFAULTS.measureSec),
26397
+ keepDownloadedModels: boolean().default(false)
26398
+ });
26399
+ var NodeBenchRunnerStateSchema = _enum([
26400
+ "running",
26401
+ "done",
26402
+ "failed",
26403
+ "aborted"
26404
+ ]);
26405
+ var NodeBenchRunnerStatusSchema = object({
26406
+ runId: string(),
26407
+ nodeId: string(),
26408
+ state: NodeBenchRunnerStateSchema,
26409
+ progress: NodeBenchProgressSchema.nullable(),
26410
+ /** Every finished cell so far — a run stopped half way keeps what it measured. */
26411
+ cells: array(NodeBenchCellSchema).readonly(),
26412
+ fingerprint: NodeBenchFingerprintSchema.nullable(),
26413
+ clip: NodeBenchClipSchema.nullable(),
26414
+ /** Cameras seen running on the node during the run (they share its pools). */
26415
+ activeCameraIds: array(number()).readonly(),
26416
+ /** Models the run downloaded and then deleted (not installed before). */
26417
+ deletedModels: array(string()).readonly(),
26418
+ error: string().nullable(),
26419
+ startedAtMs: number(),
26420
+ finishedAtMs: number().nullable()
26421
+ });
26422
+ var NodeBenchmarkStateSchema = _enum([
26423
+ "draining",
26424
+ "measuring",
26425
+ "restoring",
26426
+ "done",
26427
+ "failed",
26428
+ "aborted"
26429
+ ]);
26430
+ /** Why a run ended. */
26431
+ var NodeBenchmarkEndReasonSchema = _enum([
26432
+ "completed",
26433
+ "operator-abort",
26434
+ "deadline",
26435
+ "node-lost",
26436
+ "runner-lost",
26437
+ "hub-restart",
26438
+ "drain-timeout",
26439
+ "failed"
26440
+ ]);
26441
+ var NodeBenchmarkRunSchema = object({
26442
+ runId: string(),
26443
+ nodeId: string(),
26444
+ state: NodeBenchmarkStateSchema,
26445
+ plan: NodeBenchmarkPlanSchema,
26446
+ startedAtMs: number(),
26447
+ deadlineAtMs: number(),
26448
+ finishedAtMs: number().nullable(),
26449
+ endReason: NodeBenchmarkEndReasonSchema.nullable(),
26450
+ error: string().nullable(),
26451
+ /** Cameras moved off the node for the run. */
26452
+ moved: array(number()).readonly(),
26453
+ /** Cameras that stayed (their only frame source is the node). */
26454
+ staying: array(number()).readonly(),
26455
+ /** Something else ran on the node's pools during the run. */
26456
+ contaminated: boolean(),
26457
+ progress: NodeBenchProgressSchema.nullable(),
26458
+ resultIds: array(string()).readonly()
26459
+ });
26460
+ /** `getNodeBenchmarkStatus`: the active run (or the last one), and whether benchmark mode is on. */
26461
+ var NodeBenchmarkStatusSchema = object({
26462
+ /** The node the cluster is in benchmark mode for; null = none. */
26463
+ modeNodeId: string().nullable(),
26464
+ run: NodeBenchmarkRunSchema.nullable()
26465
+ });
26466
+ /**
26467
+ * One stored measurement — the only authority Auto tune and the automatic
26468
+ * shares read measured capacity from. Written by the orchestrator when a run
26469
+ * ends, never by anyone else.
26470
+ */
26471
+ var NodeBenchmarkResultSchema = object({
26472
+ id: string(),
26473
+ runId: string(),
26474
+ nodeId: string(),
26475
+ cell: NodeBenchCellSchema,
26476
+ fpsPerStream: number(),
26477
+ fingerprint: NodeBenchFingerprintSchema.nullable(),
26478
+ clip: NodeBenchClipSchema.nullable(),
26479
+ /** Other work shared the node's pools (a camera that could not move, or the hub's own duties). */
26480
+ contaminated: boolean(),
26481
+ stayingCameras: array(number()).readonly(),
26482
+ /** The run ended early; the cell itself completed. */
26483
+ partialRun: boolean(),
26484
+ measuredAtMs: number()
26485
+ });
26486
+ var ListNodeBenchmarkResultsInputSchema = object({
26487
+ nodeId: string().optional(),
26488
+ deviceKey: string().optional()
26489
+ });
26490
+ /** A result with its standing today: does it still beat the table? */
26491
+ var NodeBenchmarkResultViewSchema = NodeBenchmarkResultSchema.extend({
26492
+ /** `fresh` beats the table; `stale` falls back to it; `superseded` = a newer row covers the same cell. */
26493
+ standing: _enum([
26494
+ "fresh",
26495
+ "stale",
26496
+ "superseded"
26497
+ ]),
26498
+ staleWhy: _enum([
26499
+ "age",
26500
+ "runtime",
26501
+ "pool-tuning"
26502
+ ]).nullable()
26503
+ });
26504
+ object({
26505
+ runId: string(),
26506
+ nodeId: string(),
26507
+ startedAtMs: number(),
26508
+ deadlineAtMs: number(),
26509
+ plan: NodeBenchmarkPlanSchema,
26510
+ moved: array(number()).readonly(),
26511
+ staying: array(number()).readonly()
26512
+ });
26513
+ /** Candidate detectors per device, for the plan editor. */
26514
+ var NodeBenchmarkCandidatesSchema = object({
26515
+ nodeId: string(),
26516
+ reachable: boolean(),
26517
+ devices: array(object({
26518
+ deviceKey: string(),
26519
+ enabled: boolean(),
26520
+ available: boolean(),
26521
+ /** Ordered: what Auto tune would pick first, then the rest of the family by accuracy. */
26522
+ suggested: array(string()).readonly(),
26523
+ /** Every root detector the device has a build for. */
26524
+ all: array(string()).readonly(),
26525
+ /** The model the device runs now, when pinned. */
26526
+ currentModelId: string().nullable()
26527
+ })).readonly(),
26528
+ /** Detail steps the node's catalog offers under the root (for the `pipeline` measurement). */
26529
+ steps: array(object({
26530
+ id: string(),
26531
+ name: string(),
26532
+ slot: string()
26533
+ })).readonly()
26534
+ });
24990
26535
  object({
24991
26536
  activeCameras: number(),
24992
26537
  throttledCameras: number(),
@@ -26115,7 +27660,16 @@ method(RunnerCameraConfigSchema, object({ success: literal(true) }), { kind: "mu
26115
27660
  }), ParkedTrackFrameSchema.nullable()), method(object({
26116
27661
  deviceId: number(),
26117
27662
  trackId: string()
26118
- }), object({ released: number().int().nonnegative() }), { kind: "mutation" });
27663
+ }), object({ released: number().int().nonnegative() }), { kind: "mutation" }), method(NodeBenchRunnerInputSchema, object({
27664
+ accepted: literal(true),
27665
+ runId: string()
27666
+ }), {
27667
+ kind: "mutation",
27668
+ auth: "admin"
27669
+ }), method(object({ runId: string() }), NodeBenchRunnerStatusSchema.nullable(), { auth: "admin" }), method(object({ runId: string() }), object({ aborted: boolean() }), {
27670
+ kind: "mutation",
27671
+ auth: "admin"
27672
+ });
26119
27673
  var CameraPipelineConfigSchema = object({
26120
27674
  engine: PipelineEngineChoiceSchema.optional(),
26121
27675
  steps: array(PipelineStepInputSchema).readonly(),
@@ -26754,6 +28308,21 @@ method(object({
26754
28308
  }), method(PlacementStatsInputSchema, PlacementStatsSchema, { auth: "admin" }), method(SuggestSharesInputSchema, SuggestSharesResultSchema, { auth: "admin" }), method(_void(), EffectiveSharesSchema, { auth: "admin" }), method(SetShareSourceInputSchema, object({ success: literal(true) }), {
26755
28309
  kind: "mutation",
26756
28310
  auth: "admin"
28311
+ }), method(NodeBenchmarkPlanSchema, NodeBenchmarkPreflightSchema, { auth: "admin" }), method(NodeBenchmarkPlanSchema, discriminatedUnion("kind", [object({
28312
+ kind: literal("started"),
28313
+ runId: string()
28314
+ }), object({
28315
+ kind: literal("refused"),
28316
+ preflight: NodeBenchmarkPreflightSchema
28317
+ })]), {
28318
+ kind: "mutation",
28319
+ auth: "admin"
28320
+ }), method(_void(), NodeBenchmarkStatusSchema, { auth: "admin" }), method(object({ runId: string() }), object({ aborted: boolean() }), {
28321
+ kind: "mutation",
28322
+ auth: "admin"
28323
+ }), method(object({ nodeId: string() }), NodeBenchmarkCandidatesSchema, { auth: "admin" }), method(ListNodeBenchmarkResultsInputSchema, array(NodeBenchmarkResultViewSchema).readonly(), { auth: "admin" }), method(object({ id: string() }), object({ deleted: boolean() }), {
28324
+ kind: "mutation",
28325
+ auth: "admin"
26757
28326
  }), method(object({ deviceId: number() }), CameraPipelineSettingsSchema.nullable()), method(object({
26758
28327
  deviceId: number(),
26759
28328
  addonId: string(),
@@ -33383,6 +34952,9 @@ var CreateIntegrationInputSchema = object({
33383
34952
  enabled: boolean().optional(),
33384
34953
  info: record(string(), unknown()).optional(),
33385
34954
  settings: record(string(), unknown()).optional(),
34955
+ /** Keys of `settings` the form's schema declares secret (by type) — kept in
34956
+ * the keychain, not the table (D787). */
34957
+ secretKeys: array(string()).optional(),
33386
34958
  skipRestart: boolean().optional()
33387
34959
  });
33388
34960
  var UpdateIntegrationInputSchema = object({
@@ -33406,7 +34978,9 @@ method(_void(), array(IntegrationWithStateSchema)), method(object({ id: string()
33406
34978
  auth: "admin"
33407
34979
  }), method(object({ id: string() }), record(string(), unknown()), { auth: "admin" }), method(object({
33408
34980
  id: string(),
33409
- settings: record(string(), unknown())
34981
+ settings: record(string(), unknown()),
34982
+ /** Keys the form's schema declares secret (by type) — keychain-stored (D787). */
34983
+ secretKeys: array(string()).optional()
33410
34984
  }), object({ success: boolean() }), {
33411
34985
  kind: "mutation",
33412
34986
  auth: "admin"
@@ -42154,7 +43728,8 @@ var BaseDevice = class {
42154
43728
  this.role = options.role;
42155
43729
  this.parentDeviceId = ctx.parentDeviceId;
42156
43730
  const seedData = ctx.persistedConfig ?? {};
42157
- this.config = DeviceConfig.fromSchema(schema, (data) => ctx.persistConfig(data), seedData, ({ droppedKeys, issues }) => {
43731
+ const declaredSecretPaths = collectZodSecretPaths(schema);
43732
+ this.config = DeviceConfig.fromSchema(schema, (data) => ctx.persistConfig(data, { secretConfigPaths: declaredSecretPaths }), seedData, ({ droppedKeys, issues }) => {
42158
43733
  ctx.logger.warn("Device config recovery: dropping invalid persisted fields", {
42159
43734
  tags: {
42160
43735
  deviceId: ctx.id,
@@ -45854,6 +47429,90 @@ Object.freeze({
45854
47429
  addonId: null,
45855
47430
  access: "create"
45856
47431
  },
47432
+ "keychain.delete": {
47433
+ capName: "keychain",
47434
+ capScope: "system",
47435
+ addonId: null,
47436
+ access: "delete"
47437
+ },
47438
+ "keychain.getState": {
47439
+ capName: "keychain",
47440
+ capScope: "system",
47441
+ addonId: null,
47442
+ access: "view"
47443
+ },
47444
+ "keychain.listMeta": {
47445
+ capName: "keychain",
47446
+ capScope: "system",
47447
+ addonId: null,
47448
+ access: "view"
47449
+ },
47450
+ "keychain.put": {
47451
+ capName: "keychain",
47452
+ capScope: "system",
47453
+ addonId: null,
47454
+ access: "create"
47455
+ },
47456
+ "keychain.resolve": {
47457
+ capName: "keychain",
47458
+ capScope: "system",
47459
+ addonId: null,
47460
+ access: "view"
47461
+ },
47462
+ "keychainAdmin.deleteOrphans": {
47463
+ capName: "keychain-admin",
47464
+ capScope: "system",
47465
+ addonId: null,
47466
+ access: "delete"
47467
+ },
47468
+ "keychainAdmin.downloadRecoveryKey": {
47469
+ capName: "keychain-admin",
47470
+ capScope: "system",
47471
+ addonId: null,
47472
+ access: "create"
47473
+ },
47474
+ "keychainAdmin.listAudit": {
47475
+ capName: "keychain-admin",
47476
+ capScope: "system",
47477
+ addonId: null,
47478
+ access: "view"
47479
+ },
47480
+ "keychainAdmin.listSecrets": {
47481
+ capName: "keychain-admin",
47482
+ capScope: "system",
47483
+ addonId: null,
47484
+ access: "view"
47485
+ },
47486
+ "keychainAdmin.purgeRetiredKeys": {
47487
+ capName: "keychain-admin",
47488
+ capScope: "system",
47489
+ addonId: null,
47490
+ access: "delete"
47491
+ },
47492
+ "keychainAdmin.resetKeychain": {
47493
+ capName: "keychain-admin",
47494
+ capScope: "system",
47495
+ addonId: null,
47496
+ access: "delete"
47497
+ },
47498
+ "keychainAdmin.reveal": {
47499
+ capName: "keychain-admin",
47500
+ capScope: "system",
47501
+ addonId: null,
47502
+ access: "create"
47503
+ },
47504
+ "keychainAdmin.rotateMasterKey": {
47505
+ capName: "keychain-admin",
47506
+ capScope: "system",
47507
+ addonId: null,
47508
+ access: "create"
47509
+ },
47510
+ "keychainAdmin.status": {
47511
+ capName: "keychain-admin",
47512
+ capScope: "system",
47513
+ addonId: null,
47514
+ access: "view"
47515
+ },
45857
47516
  "lawnMowerControl.dock": {
45858
47517
  capName: "lawn-mower-control",
45859
47518
  capScope: "device",
@@ -47228,6 +48887,18 @@ Object.freeze({
47228
48887
  addonId: null,
47229
48888
  access: "create"
47230
48889
  },
48890
+ "pipelineAnalytics.addRetrainFrameFromRecording": {
48891
+ capName: "pipeline-analytics",
48892
+ capScope: "device",
48893
+ addonId: null,
48894
+ access: "create"
48895
+ },
48896
+ "pipelineAnalytics.addRetrainFramesToCollection": {
48897
+ capName: "pipeline-analytics",
48898
+ capScope: "device",
48899
+ addonId: null,
48900
+ access: "create"
48901
+ },
47231
48902
  "pipelineAnalytics.applyDeviceSettingsPatch": {
47232
48903
  capName: "pipeline-analytics",
47233
48904
  capScope: "device",
@@ -47276,12 +48947,24 @@ Object.freeze({
47276
48947
  addonId: null,
47277
48948
  access: "view"
47278
48949
  },
48950
+ "pipelineAnalytics.createRetrainCollection": {
48951
+ capName: "pipeline-analytics",
48952
+ capScope: "device",
48953
+ addonId: null,
48954
+ access: "create"
48955
+ },
47279
48956
  "pipelineAnalytics.deleteDeviceEvents": {
47280
48957
  capName: "pipeline-analytics",
47281
48958
  capScope: "device",
47282
48959
  addonId: null,
47283
48960
  access: "delete"
47284
48961
  },
48962
+ "pipelineAnalytics.deleteRetrainCollection": {
48963
+ capName: "pipeline-analytics",
48964
+ capScope: "device",
48965
+ addonId: null,
48966
+ access: "delete"
48967
+ },
47285
48968
  "pipelineAnalytics.deleteTracks": {
47286
48969
  capName: "pipeline-analytics",
47287
48970
  capScope: "device",
@@ -47486,6 +49169,24 @@ Object.freeze({
47486
49169
  addonId: null,
47487
49170
  access: "view"
47488
49171
  },
49172
+ "pipelineAnalytics.listRetrainAssistProfiles": {
49173
+ capName: "pipeline-analytics",
49174
+ capScope: "device",
49175
+ addonId: null,
49176
+ access: "view"
49177
+ },
49178
+ "pipelineAnalytics.listRetrainCollectionFrames": {
49179
+ capName: "pipeline-analytics",
49180
+ capScope: "device",
49181
+ addonId: null,
49182
+ access: "view"
49183
+ },
49184
+ "pipelineAnalytics.listRetrainCollections": {
49185
+ capName: "pipeline-analytics",
49186
+ capScope: "device",
49187
+ addonId: null,
49188
+ access: "view"
49189
+ },
47489
49190
  "pipelineAnalytics.listRetrainFrames": {
47490
49191
  capName: "pipeline-analytics",
47491
49192
  capScope: "device",
@@ -47534,6 +49235,12 @@ Object.freeze({
47534
49235
  addonId: null,
47535
49236
  access: "create"
47536
49237
  },
49238
+ "pipelineAnalytics.proposeRetrainAnnotationsWithLlm": {
49239
+ capName: "pipeline-analytics",
49240
+ capScope: "device",
49241
+ addonId: null,
49242
+ access: "create"
49243
+ },
47537
49244
  "pipelineAnalytics.pruneEvents": {
47538
49245
  capName: "pipeline-analytics",
47539
49246
  capScope: "device",
@@ -47588,6 +49295,18 @@ Object.freeze({
47588
49295
  addonId: null,
47589
49296
  access: "create"
47590
49297
  },
49298
+ "pipelineAnalytics.removeRetrainFrameFromCollection": {
49299
+ capName: "pipeline-analytics",
49300
+ capScope: "device",
49301
+ addonId: null,
49302
+ access: "delete"
49303
+ },
49304
+ "pipelineAnalytics.renameRetrainCollection": {
49305
+ capName: "pipeline-analytics",
49306
+ capScope: "device",
49307
+ addonId: null,
49308
+ access: "create"
49309
+ },
47591
49310
  "pipelineAnalytics.restageRetrainTrack": {
47592
49311
  capName: "pipeline-analytics",
47593
49312
  capScope: "device",
@@ -47876,6 +49595,12 @@ Object.freeze({
47876
49595
  addonId: null,
47877
49596
  access: "view"
47878
49597
  },
49598
+ "pipelineOrchestrator.abortNodeBenchmark": {
49599
+ capName: "pipeline-orchestrator",
49600
+ capScope: "system",
49601
+ addonId: null,
49602
+ access: "create"
49603
+ },
47879
49604
  "pipelineOrchestrator.applyAutoTune": {
47880
49605
  capName: "pipeline-orchestrator",
47881
49606
  capScope: "system",
@@ -47900,6 +49625,12 @@ Object.freeze({
47900
49625
  addonId: null,
47901
49626
  access: "create"
47902
49627
  },
49628
+ "pipelineOrchestrator.deleteNodeBenchmarkResult": {
49629
+ capName: "pipeline-orchestrator",
49630
+ capScope: "system",
49631
+ addonId: null,
49632
+ access: "delete"
49633
+ },
47903
49634
  "pipelineOrchestrator.getAgentLoad": {
47904
49635
  capName: "pipeline-orchestrator",
47905
49636
  capScope: "system",
@@ -48008,6 +49739,24 @@ Object.freeze({
48008
49739
  addonId: null,
48009
49740
  access: "view"
48010
49741
  },
49742
+ "pipelineOrchestrator.getNodeBenchmarkCandidates": {
49743
+ capName: "pipeline-orchestrator",
49744
+ capScope: "system",
49745
+ addonId: null,
49746
+ access: "view"
49747
+ },
49748
+ "pipelineOrchestrator.getNodeBenchmarkPreflight": {
49749
+ capName: "pipeline-orchestrator",
49750
+ capScope: "system",
49751
+ addonId: null,
49752
+ access: "view"
49753
+ },
49754
+ "pipelineOrchestrator.getNodeBenchmarkStatus": {
49755
+ capName: "pipeline-orchestrator",
49756
+ capScope: "system",
49757
+ addonId: null,
49758
+ access: "view"
49759
+ },
48011
49760
  "pipelineOrchestrator.getNodeInferenceDevices": {
48012
49761
  capName: "pipeline-orchestrator",
48013
49762
  capScope: "system",
@@ -48050,6 +49799,12 @@ Object.freeze({
48050
49799
  addonId: null,
48051
49800
  access: "view"
48052
49801
  },
49802
+ "pipelineOrchestrator.listNodeBenchmarkResults": {
49803
+ capName: "pipeline-orchestrator",
49804
+ capScope: "system",
49805
+ addonId: null,
49806
+ access: "view"
49807
+ },
48053
49808
  "pipelineOrchestrator.pauseForStorageMigration": {
48054
49809
  capName: "pipeline-orchestrator",
48055
49810
  capScope: "system",
@@ -48194,6 +49949,12 @@ Object.freeze({
48194
49949
  addonId: null,
48195
49950
  access: "create"
48196
49951
  },
49952
+ "pipelineOrchestrator.startNodeBenchmark": {
49953
+ capName: "pipeline-orchestrator",
49954
+ capScope: "system",
49955
+ addonId: null,
49956
+ access: "create"
49957
+ },
48197
49958
  "pipelineOrchestrator.suggestShares": {
48198
49959
  capName: "pipeline-orchestrator",
48199
49960
  capScope: "system",
@@ -48212,6 +49973,12 @@ Object.freeze({
48212
49973
  addonId: null,
48213
49974
  access: "create"
48214
49975
  },
49976
+ "pipelineRunner.abortNodeBench": {
49977
+ capName: "pipeline-runner",
49978
+ capScope: "system",
49979
+ addonId: null,
49980
+ access: "create"
49981
+ },
48215
49982
  "pipelineRunner.attachCamera": {
48216
49983
  capName: "pipeline-runner",
48217
49984
  capScope: "system",
@@ -48260,6 +50027,12 @@ Object.freeze({
48260
50027
  addonId: null,
48261
50028
  access: "view"
48262
50029
  },
50030
+ "pipelineRunner.getNodeBenchStatus": {
50031
+ capName: "pipeline-runner",
50032
+ capScope: "system",
50033
+ addonId: null,
50034
+ access: "view"
50035
+ },
48263
50036
  "pipelineRunner.getParkedTrackFrame": {
48264
50037
  capName: "pipeline-runner",
48265
50038
  capScope: "system",
@@ -48302,6 +50075,12 @@ Object.freeze({
48302
50075
  addonId: null,
48303
50076
  access: "create"
48304
50077
  },
50078
+ "pipelineRunner.startNodeBench": {
50079
+ capName: "pipeline-runner",
50080
+ capScope: "system",
50081
+ addonId: null,
50082
+ access: "create"
50083
+ },
48305
50084
  "plateGallery.assignPlate": {
48306
50085
  capName: "plate-gallery",
48307
50086
  capScope: "system",
@@ -53383,6 +55162,11 @@ Object.freeze({
53383
55162
  form: "single",
53384
55163
  optional: false
53385
55164
  }],
55165
+ "pipelineAnalytics.addRetrainFrameFromRecording": [{
55166
+ name: "deviceId",
55167
+ form: "single",
55168
+ optional: false
55169
+ }],
53386
55170
  "pipelineAnalytics.applyDeviceSettingsPatch": [{
53387
55171
  name: "deviceId",
53388
55172
  form: "single",
@@ -53573,6 +55357,11 @@ Object.freeze({
53573
55357
  form: "single",
53574
55358
  optional: false
53575
55359
  }],
55360
+ "pipelineAnalytics.proposeRetrainAnnotationsWithLlm": [{
55361
+ name: "deviceId",
55362
+ form: "single",
55363
+ optional: false
55364
+ }],
53576
55365
  "pipelineAnalytics.pruneEventsBefore": [{
53577
55366
  name: "deviceId",
53578
55367
  form: "single",
@@ -165333,6 +167122,31 @@ function createAccessoryDevice(kind, ctx, parent) {
165333
167122
  }
165334
167123
  //#endregion
165335
167124
  //#region src/accessory-probe-flags.ts
167125
+ /**
167126
+ * Pure helpers that decide which probe flags drive accessory-child
167127
+ * derivation, and whether a Reolink camera has *ever* been probed.
167128
+ *
167129
+ * Why this exists as its own module: the `feature-probe` runtime-state
167130
+ * slice is the live, in-session source of the camera's ability flags
167131
+ * (`hasSiren` / `hasFloodlight` / `hasPirSensor` / …). It is rehydrated
167132
+ * on restart, BUT a camera whose Baichuan `getDeviceCapabilities`
167133
+ * round-trip is slow or flaky (observed: a doorbell that times out the
167134
+ * kernel's 30s `onProbe` window on every boot) restores with an empty
167135
+ * slice (`lastProbedAt === 0`). The `deviceCache` config blob — written
167136
+ * alongside the slice on the LAST successful probe and preserved across
167137
+ * restarts by the camera schema's `.loose()` passthrough — still carries
167138
+ * that probe's flags plus a `probedAt` stamp.
167139
+ *
167140
+ * Deriving accessory specs from the `deviceCache` fallback lets the
167141
+ * kernel re-spawn the persisted accessory children (and therefore
167142
+ * re-mount their kernel-managed `device-ops` provider) even when this
167143
+ * session's live probe never completes. Without it, every accessory of
167144
+ * a slow-probing camera is left as a DB row with no live provider
167145
+ * ("device-ops not registered for device N").
167146
+ *
167147
+ * Kept pure (no `this`, no I/O) so the slice-vs-cache precedence is
167148
+ * unit-testable without standing up a full camera device.
167149
+ */
165336
167150
  var FLAG_KEYS = [
165337
167151
  "hasBattery",
165338
167152
  "hasPtz",
@@ -165370,6 +167184,43 @@ function resolveAccessoryProbeFlags(sliceProbed, sliceFlags, deviceCache) {
165370
167184
  }
165371
167185
  return out;
165372
167186
  }
167187
+ /**
167188
+ * The `deviceCache` blob a successful feature probe leaves behind: the
167189
+ * previous blob, plus the `probedAt` stamp and every boolean ability flag
167190
+ * the probe resolved. This is what lets {@link resolveAccessoryProbeFlags}
167191
+ * fall back on the next boot — a battery camera asleep at boot skips its
167192
+ * probe, and the `feature-probe` slice alone does not carry the flags
167193
+ * across a provider restart. Returns a new object; `previous` is untouched.
167194
+ */
167195
+ function withPersistedProbe(previous, flags, probedAt) {
167196
+ const persisted = {};
167197
+ for (const key of FLAG_KEYS) {
167198
+ const value = flags[key];
167199
+ if (typeof value === "boolean") persisted[key] = value;
167200
+ }
167201
+ return {
167202
+ ...previous,
167203
+ ...persisted,
167204
+ probedAt
167205
+ };
167206
+ }
167207
+ /** The accessory children a probe flag set spawns, in spawn order. */
167208
+ var ACCESSORY_FLAGS = [
167209
+ ["hasSiren", AccessoryKind.Siren],
167210
+ ["hasFloodlight", AccessoryKind.Floodlight],
167211
+ ["hasPirSensor", AccessoryKind.PirSensor]
167212
+ ];
167213
+ /**
167214
+ * Accessory kinds a camera should spawn: none until it has EVER probed
167215
+ * (live slice this session, or a persisted `probedAt`), then one per
167216
+ * ability flag that is exactly `true` — live slice first, persisted
167217
+ * `deviceCache` flags as the fallback.
167218
+ */
167219
+ function accessoryKindsFor(sliceProbed, sliceFlags, deviceCache) {
167220
+ if (!hasEverProbed(sliceProbed, deviceCache)) return [];
167221
+ const flags = resolveAccessoryProbeFlags(sliceProbed, sliceFlags, deviceCache);
167222
+ return ACCESSORY_FLAGS.filter(([flag]) => flags[flag] === true).map(([, kind]) => kind);
167223
+ }
165373
167224
  //#endregion
165374
167225
  //#region src/metadata-populator.ts
165375
167226
  var EXTENDED_INFO_TAGS = [
@@ -168185,9 +170036,7 @@ var ReolinkCamera = class ReolinkCamera extends BaseDevice {
168185
170036
  * parent register.
168186
170037
  */
168187
170038
  getAccessoryChildren() {
168188
- const deviceCache = this.config.get("deviceCache");
168189
- if (!hasEverProbed(this.hasProbed(), deviceCache)) return [];
168190
- const probe = resolveAccessoryProbeFlags(this.hasProbed(), this.getProbeFlags(), deviceCache);
170039
+ const kinds = accessoryKindsFor(this.hasProbed(), this.getProbeFlags(), this.config.get("deviceCache"));
168191
170040
  const out = [];
168192
170041
  const push = (kind, type, label) => {
168193
170042
  out.push({
@@ -168203,9 +170052,9 @@ var ReolinkCamera = class ReolinkCamera extends BaseDevice {
168203
170052
  factory: (ctx) => createAccessoryDevice(kind, ctx, this)
168204
170053
  });
168205
170054
  };
168206
- if (probe.hasSiren === true) push(AccessoryKind.Siren, DeviceType.Siren, ACCESSORY_LABEL[AccessoryKind.Siren]);
168207
- if (probe.hasFloodlight === true) push(AccessoryKind.Floodlight, DeviceType.Light, ACCESSORY_LABEL[AccessoryKind.Floodlight]);
168208
- if (probe.hasPirSensor === true) push(AccessoryKind.PirSensor, DeviceType.Switch, ACCESSORY_LABEL[AccessoryKind.PirSensor]);
170055
+ if (kinds.includes(AccessoryKind.Siren)) push(AccessoryKind.Siren, DeviceType.Siren, ACCESSORY_LABEL[AccessoryKind.Siren]);
170056
+ if (kinds.includes(AccessoryKind.Floodlight)) push(AccessoryKind.Floodlight, DeviceType.Light, ACCESSORY_LABEL[AccessoryKind.Floodlight]);
170057
+ if (kinds.includes(AccessoryKind.PirSensor)) push(AccessoryKind.PirSensor, DeviceType.Switch, ACCESSORY_LABEL[AccessoryKind.PirSensor]);
168209
170058
  return out;
168210
170059
  }
168211
170060
  /**
@@ -172656,6 +174505,14 @@ var ReolinkCamera = class ReolinkCamera extends BaseDevice {
172656
174505
  meta: { error: err instanceof Error ? err.message : String(err) }
172657
174506
  });
172658
174507
  }
174508
+ if (!this.hasProbed()) try {
174509
+ await this.reprobe();
174510
+ } catch (err) {
174511
+ this.ctx.logger.debug("onWakeTransition: feature probe failed — next wake retries", {
174512
+ tags: { deviceId: this.id },
174513
+ meta: { error: err instanceof Error ? err.message : String(err) }
174514
+ });
174515
+ }
172659
174516
  await this.warmCapSlicesOnWake();
172660
174517
  await this.warmSnapshotOnWake();
172661
174518
  await this.alignAuxDevicesState("wake");
@@ -174724,6 +176581,7 @@ var ReolinkCamera = class ReolinkCamera extends BaseDevice {
174724
176581
  let hasBattery;
174725
176582
  let hasPirSensor;
174726
176583
  let hasAutotrack;
176584
+ let capabilitiesRead = false;
174727
176585
  try {
174728
176586
  channelCount = await api.getChannelCount();
174729
176587
  } catch {}
@@ -174737,6 +176595,7 @@ var ReolinkCamera = class ReolinkCamera extends BaseDevice {
174737
176595
  hasBattery = capabilities.hasBattery;
174738
176596
  hasPirSensor = capabilities.hasPir;
174739
176597
  hasAutotrack = capabilities.hasAutotracking;
176598
+ capabilitiesRead = true;
174740
176599
  } catch (err) {
174741
176600
  this.ctx.logger.debug("getDeviceCapabilities failed — leaving flags unset", {
174742
176601
  tags: { deviceId: this.id },
@@ -174773,12 +176632,12 @@ var ReolinkCamera = class ReolinkCamera extends BaseDevice {
174773
176632
  };
174774
176633
  this.runtimeState.setCapState("feature-probe", next);
174775
176634
  try {
174776
- const previous = this.config.get("deviceCache") ?? {};
174777
- await this.config.setAll({ deviceCache: {
174778
- ...previous,
176635
+ const identity = {
176636
+ ...this.config.get("deviceCache") ?? {},
174779
176637
  ...inferredDeviceType ? { deviceType: inferredDeviceType } : {},
174780
176638
  ...channelCount !== void 0 ? { channelCount } : {}
174781
- } });
176639
+ };
176640
+ await this.config.setAll({ deviceCache: capabilitiesRead ? withPersistedProbe(identity, flags, now) : identity });
174782
176641
  } catch (err) {
174783
176642
  this.ctx.logger.debug("deviceCache identity persist failed (non-fatal)", {
174784
176643
  tags: { deviceId: this.id },
@@ -177229,6 +179088,8 @@ async function enrichHostIdentifiersFromLiveApi(detection, logger) {
177229
179088
  }
177230
179089
  }
177231
179090
  var ReolinkProviderAddon = class extends BaseDeviceProvider {
179091
+ /** The email-push SMTP password is hidden state — kept in the keychain (D787). */
179092
+ secretStatePaths = ["emailPushAuthPassword"];
177232
179093
  addonId = REOLINK_ADDON_ID;
177233
179094
  providerName = "Reolink";
177234
179095
  deviceClasses = {