@camstack/addon-export-alexa 1.2.138 → 1.2.139

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.
@@ -28,7 +28,7 @@ let node_crypto = require("node:crypto");
28
28
  node_crypto = __toESM(node_crypto, 1);
29
29
  let sharp = require("sharp");
30
30
  sharp = __toESM(sharp);
31
- //#region ../types/dist/event-category-B_0XEcLF.mjs
31
+ //#region ../types/dist/event-category-DaIZi00R.mjs
32
32
  var EventCategory = /* @__PURE__ */ function(EventCategory) {
33
33
  EventCategory["SystemBoot"] = "system.boot";
34
34
  EventCategory["SystemAddonsReady"] = "system.addons-ready";
@@ -107,6 +107,13 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
107
107
  */
108
108
  EventCategory["AddonLoadFailed"] = "addon.load-failed";
109
109
  /**
110
+ * A keychain value was stored or removed (D787). Carries the ref, its
111
+ * owner and the new version — NEVER the value. A process holding the ref
112
+ * drops its cached copy and the owning `BaseAddon` re-resolves its config.
113
+ * Telemetry (D8): a process that misses it still revalidates by version.
114
+ */
115
+ EventCategory["KeychainChanged"] = "keychain.changed";
116
+ /**
110
117
  * Addon recovered from a previous failure. Emitted when an addon
111
118
  * transitions from `failed` back to `healthy` (typically via the
112
119
  * monitor's auto-retry loop, or after manual `addons.retryLoad`).
@@ -5399,7 +5406,7 @@ var ZodIssueCode = {
5399
5406
  var ZodFirstPartyTypeKind;
5400
5407
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
5401
5408
  //#endregion
5402
- //#region ../types/dist/sleep-B0JG7-_F.mjs
5409
+ //#region ../types/dist/sleep-Cr5YOk3m.mjs
5403
5410
  /**
5404
5411
  * The audio chunk plane's byte format, and the ONE expansion from a coded
5405
5412
  * window to float samples (D455).
@@ -5478,6 +5485,97 @@ function buildAlawTable() {
5478
5485
  }
5479
5486
  buildUlawTable();
5480
5487
  buildAlawTable();
5488
+ /** Is this field's stored value a credential? */
5489
+ function isSecretConfigField(field) {
5490
+ if (field.type === "password") return true;
5491
+ return "secret" in field && field.secret === true;
5492
+ }
5493
+ /**
5494
+ * Is this field's value stored in the KEYCHAIN (D787)? Every secret field is,
5495
+ * by its TYPE, unless it opts out with `storage: 'inline'` — never by its name.
5496
+ */
5497
+ function isKeychainStoredField(field) {
5498
+ if (!isSecretConfigField(field)) return false;
5499
+ if (field.type === "textarea" && field.isJson === true) return false;
5500
+ return !("storage" in field && field.storage === "inline");
5501
+ }
5502
+ /**
5503
+ * What a settings blob holds where a secret used to be.
5504
+ *
5505
+ * A keychain-stored field never holds its value. It holds a self-describing
5506
+ * MARKER, `{"$secret":"secret://…","v":1}` — an object, never a string, so no
5507
+ * code can mistake it for a credential and no form can send it to a camera as
5508
+ * a password. The empty state is `null` / absent, never `''`.
5509
+ *
5510
+ * The same shapes travel to and from the admin UI:
5511
+ *
5512
+ * - read: `hydrateSchema` hands a secret field a {@link SecretFieldView}
5513
+ * (`{ $secret, v, set: true }`) or `null` — the browser learns whether a
5514
+ * value is set, never the value.
5515
+ * - write: an untouched field submits the view back unchanged (KEEP); a typed
5516
+ * value is a plain non-empty string (CHANGE); the Clear button submits
5517
+ * {@link SECRET_CLEAR} (CLEAR). `''`, `null` and the legacy redaction tokens
5518
+ * are KEEP — an empty string is what a defaults-fallback pushes back, and
5519
+ * treating it as "clear" is how a save destroyed a stored credential before.
5520
+ *
5521
+ * Pure and browser-safe.
5522
+ */
5523
+ var SECRET_CLEAR = { $secretClear: true };
5524
+ /** The `'***'` token D634 redaction writes for non-admins. */
5525
+ var LEGACY_DEVICE_REDACTION = "***";
5526
+ function isRecord$1(value) {
5527
+ return typeof value === "object" && value !== null && !Array.isArray(value);
5528
+ }
5529
+ function makeSecretMarker(ref) {
5530
+ return {
5531
+ $secret: ref,
5532
+ v: 1
5533
+ };
5534
+ }
5535
+ /** A stored marker: an object whose `$secret` is a non-empty string. */
5536
+ function isSecretMarker(value) {
5537
+ if (!isRecord$1(value)) return false;
5538
+ const ref = value["$secret"];
5539
+ return typeof ref === "string" && ref.length > 0;
5540
+ }
5541
+ function isSecretClear(value) {
5542
+ return isRecord$1(value) && value["$secretClear"] === true;
5543
+ }
5544
+ /**
5545
+ * The UI view of a stored secret field value: a marker becomes "set", inline
5546
+ * plaintext becomes "set (inline)", nothing becomes `null`. A value never
5547
+ * survives this function.
5548
+ */
5549
+ function toSecretFieldView(stored) {
5550
+ if (isSecretMarker(stored)) return {
5551
+ $secret: stored.$secret,
5552
+ v: 1,
5553
+ set: true
5554
+ };
5555
+ if (typeof stored === "string" && stored.length > 0) return {
5556
+ $secret: null,
5557
+ v: 1,
5558
+ set: true,
5559
+ inline: true
5560
+ };
5561
+ return null;
5562
+ }
5563
+ /**
5564
+ * Classify an incoming value for a secret path. Only a non-empty string that is
5565
+ * not a redaction token sets a value; only {@link SECRET_CLEAR} clears.
5566
+ * Everything else — a marker (ours or anyone's), a UI view, `''`, `null`,
5567
+ * `undefined`, a redaction token, a non-string — keeps what is stored.
5568
+ */
5569
+ function classifySecretWrite(incoming) {
5570
+ if (isSecretClear(incoming)) return { kind: "clear" };
5571
+ if (typeof incoming !== "string") return { kind: "keep" };
5572
+ if (incoming.length === 0) return { kind: "keep" };
5573
+ if (incoming === "__camstack_redacted__" || incoming === LEGACY_DEVICE_REDACTION) return { kind: "keep" };
5574
+ return {
5575
+ kind: "set",
5576
+ value: incoming
5577
+ };
5578
+ }
5481
5579
  Object.fromEntries([
5482
5580
  {
5483
5581
  id: "overview",
@@ -5649,33 +5747,19 @@ Object.fromEntries([
5649
5747
  function isValuelessField(field) {
5650
5748
  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";
5651
5749
  }
5652
- /**
5653
- * Merge a `ConfigUISchema` with a raw `values` record into a
5654
- * `ConfigUISchemaWithValues`. Used by every `get*Settings` backend endpoint
5655
- * before returning to the admin UI. Groups are walked recursively.
5656
- *
5657
- * For each leaf field:
5658
- * - structural fields (`separator`, `info`, `button`) pass through unchanged
5659
- * - other fields get `value = values[key] ?? field.default ?? null`
5660
- *
5661
- * Unknown keys in `values` (keys not declared in the schema) are silently
5662
- * ignored — they don't contribute to the output. Missing keys fall back to
5663
- * the schema default or `null`. This mirrors the old backend behaviour where
5664
- * `FormBuilder` rendered `values[key] ?? field.default`.
5665
- */
5666
- function hydrateSchema(schema, values) {
5750
+ function hydrateSchema(schema, values, options = {}) {
5667
5751
  return {
5668
5752
  ...schema.tabs ? { tabs: [...schema.tabs] } : {},
5669
5753
  sections: schema.sections.map((section) => ({
5670
5754
  ...section,
5671
- fields: section.fields.map((field) => hydrateField(field, values))
5755
+ fields: section.fields.map((field) => hydrateField(field, values, options))
5672
5756
  }))
5673
5757
  };
5674
5758
  }
5675
- function hydrateField(field, values) {
5759
+ function hydrateField(field, values, options) {
5676
5760
  if (isValuelessField(field)) return field;
5677
5761
  if (field.type === "group") {
5678
- const hydratedChildren = field.fields.map((child) => hydrateField(child, values));
5762
+ const hydratedChildren = field.fields.map((child) => hydrateField(child, values, options));
5679
5763
  return {
5680
5764
  ...field,
5681
5765
  fields: hydratedChildren
@@ -5684,7 +5768,7 @@ function hydrateField(field, values) {
5684
5768
  if (field.type === "sub-tabs") {
5685
5769
  const hydratedTabs = field.tabs.map((tab) => ({
5686
5770
  ...tab,
5687
- fields: tab.fields.map((child) => hydrateField(child, values))
5771
+ fields: tab.fields.map((child) => hydrateField(child, values, options))
5688
5772
  }));
5689
5773
  return {
5690
5774
  ...field,
@@ -5694,6 +5778,33 @@ function hydrateField(field, values) {
5694
5778
  const key = field.key;
5695
5779
  const storedValue = Object.prototype.hasOwnProperty.call(values, key) ? values[key] : void 0;
5696
5780
  const defaultValue = field.default;
5781
+ const asView = (v) => isSecretMarker(v) || options.inlineSecretsAsViews === true && v !== void 0;
5782
+ if (isKeychainStoredField(field) && asView(storedValue)) return {
5783
+ ...field,
5784
+ value: toSecretFieldView(storedValue)
5785
+ };
5786
+ if (isKeychainStoredField(field) && options.inlineSecretsAsViews === true) return {
5787
+ ...field,
5788
+ value: null
5789
+ };
5790
+ if (field.type === "editable-array" && Array.isArray(storedValue)) {
5791
+ const secretItemKeys = field.itemFields.filter((item) => "key" in item && isKeychainStoredField(item)).map((item) => "key" in item ? item.key : "");
5792
+ if (secretItemKeys.length > 0) {
5793
+ const rows = storedValue.map((row) => {
5794
+ if (row === null || typeof row !== "object" || Array.isArray(row)) return row;
5795
+ const out = { ...row };
5796
+ for (const k of secretItemKeys) {
5797
+ const v = Reflect.get(row, k);
5798
+ if (asView(v)) out[k] = toSecretFieldView(v);
5799
+ }
5800
+ return out;
5801
+ });
5802
+ return {
5803
+ ...field,
5804
+ value: rows
5805
+ };
5806
+ }
5807
+ }
5697
5808
  if (field.multiple) {
5698
5809
  const stored = Array.isArray(storedValue) ? storedValue : storedValue !== void 0 && storedValue !== null ? [storedValue] : [];
5699
5810
  const itemFallback = field.multiple.itemDefault !== void 0 ? field.multiple.itemDefault : defaultValue !== void 0 ? defaultValue : typeOf(field) === "string" ? "" : null;
@@ -5936,6 +6047,431 @@ function projectStore(store, perNodeKeys, nodeId) {
5936
6047
  }
5937
6048
  return out;
5938
6049
  }
6050
+ var GLOBAL_SCOPE = { kind: "global" };
6051
+ /** The scope every addon-wide (not per-node, not per-device) setting lives in. */
6052
+ function globalSecretScope() {
6053
+ return GLOBAL_SCOPE;
6054
+ }
6055
+ function encodeSegment(value) {
6056
+ return encodeURIComponent(value);
6057
+ }
6058
+ /**
6059
+ * The field path of a value inside an array item, addressed by the item's id:
6060
+ * `arrayItemFieldPath('providers', 'authentik', 'clientSecret')` →
6061
+ * `providers[authentik].clientSecret`.
6062
+ */
6063
+ function arrayItemFieldPath(arrayKey, itemId, fieldKey) {
6064
+ return `${arrayKey}[${encodeSegment(itemId)}].${fieldKey}`;
6065
+ }
6066
+ /** A write to a secret path could not be stored in the keychain, so it was refused. */
6067
+ var KeychainWriteRefusedError = class extends Error {
6068
+ fieldPath;
6069
+ constructor(fieldPath, cause) {
6070
+ super(`secret "${fieldPath}" was not saved: the keychain could not store it (${cause instanceof Error ? cause.message : String(cause)}). Nothing was written.`);
6071
+ this.fieldPath = fieldPath;
6072
+ this.name = "KeychainWriteRefusedError";
6073
+ }
6074
+ };
6075
+ var KEEP = { kind: "keep" };
6076
+ function isRecord(value) {
6077
+ return typeof value === "object" && value !== null && !Array.isArray(value);
6078
+ }
6079
+ function defaultMintId() {
6080
+ return globalThis.crypto.randomUUID();
6081
+ }
6082
+ /** Every marker ref anywhere under `value`. */
6083
+ function collectSecretMarkerRefs(value, out = []) {
6084
+ if (isSecretMarker(value)) {
6085
+ out.push(value.$secret);
6086
+ return out;
6087
+ }
6088
+ if (Array.isArray(value)) for (const item of value) collectSecretMarkerRefs(item, out);
6089
+ else if (isRecord(value)) for (const child of Object.values(value)) collectSecretMarkerRefs(child, out);
6090
+ return out;
6091
+ }
6092
+ async function storedValueEquals(secrets, marker, candidate) {
6093
+ const resolved = (await secrets.resolve([marker.$secret]))[marker.$secret];
6094
+ return resolved?.kind === "value" && resolved.value === candidate;
6095
+ }
6096
+ async function writeLeaf(ctx, incoming, stored, fieldPath) {
6097
+ const intent = classifySecretWrite(incoming);
6098
+ const ref = ctx.secrets.ref(ctx.scope, fieldPath);
6099
+ const storedIsOurs = isSecretMarker(stored) && stored.$secret === ref;
6100
+ if (intent.kind === "keep") return KEEP;
6101
+ if (intent.kind === "set" && !ctx.operatorWrite && typeof stored === "string" && stored === intent.value) return KEEP;
6102
+ if (intent.kind === "clear") {
6103
+ if (storedIsOurs) ctx.deletes.push(ref);
6104
+ return {
6105
+ kind: "value",
6106
+ value: null
6107
+ };
6108
+ }
6109
+ if (storedIsOurs && await storedValueEquals(ctx.secrets, stored, intent.value)) return {
6110
+ kind: "value",
6111
+ value: stored
6112
+ };
6113
+ try {
6114
+ await ctx.secrets.put(ref, intent.value);
6115
+ } catch (err) {
6116
+ throw new KeychainWriteRefusedError(fieldPath, err);
6117
+ }
6118
+ return {
6119
+ kind: "value",
6120
+ value: makeSecretMarker(ref)
6121
+ };
6122
+ }
6123
+ /** Apply a member result onto `out`: KEEP restores the stored member, or removes it. */
6124
+ function applyMember(out, key, result, storedParent) {
6125
+ if (result.kind === "value") {
6126
+ out[key] = result.value;
6127
+ return;
6128
+ }
6129
+ if (Object.prototype.hasOwnProperty.call(storedParent, key)) out[key] = storedParent[key];
6130
+ else delete out[key];
6131
+ }
6132
+ async function writeMembers(ctx, children, incoming, stored, pathOf) {
6133
+ const out = { ...incoming };
6134
+ for (const [member, node] of children) applyMember(out, member, await writeNode(ctx, node, incoming[member], stored[member], pathOf(member)), stored);
6135
+ return out;
6136
+ }
6137
+ function rowId(row, idKey) {
6138
+ const raw = row[idKey];
6139
+ if (typeof raw === "string" && raw.length > 0) return raw;
6140
+ if (typeof raw === "number" && Number.isFinite(raw)) return String(raw);
6141
+ return null;
6142
+ }
6143
+ async function writeArray(ctx, node, incoming, stored, fieldPath) {
6144
+ const storedRows = Array.isArray(stored) ? stored.filter(isRecord) : [];
6145
+ if (!Array.isArray(incoming)) {
6146
+ ctx.deletes.push(...collectSecretMarkerRefs(storedRows));
6147
+ return {
6148
+ kind: "value",
6149
+ value: incoming
6150
+ };
6151
+ }
6152
+ const storedById = /* @__PURE__ */ new Map();
6153
+ for (const row of storedRows) {
6154
+ const id = rowId(row, node.idKey);
6155
+ if (id !== null) storedById.set(id, row);
6156
+ }
6157
+ const kept = /* @__PURE__ */ new Set();
6158
+ const rows = [];
6159
+ for (const row of incoming) {
6160
+ if (!isRecord(row)) {
6161
+ rows.push(row);
6162
+ continue;
6163
+ }
6164
+ const id = rowId(row, node.idKey) ?? ctx.mintId();
6165
+ kept.add(id);
6166
+ const withId = {
6167
+ ...row,
6168
+ [node.idKey]: row[node.idKey] ?? id
6169
+ };
6170
+ if (rowId(withId, node.idKey) === null) withId[node.idKey] = id;
6171
+ const storedRow = storedById.get(id) ?? {};
6172
+ rows.push(await writeMembers(ctx, node.item, withId, storedRow, (member) => arrayItemFieldPath(fieldPath, id, member)));
6173
+ }
6174
+ for (const [id, row] of storedById) if (!kept.has(id)) ctx.deletes.push(...collectSecretMarkerRefs(row));
6175
+ return {
6176
+ kind: "value",
6177
+ value: rows
6178
+ };
6179
+ }
6180
+ async function writeNode(ctx, node, incoming, stored, fieldPath) {
6181
+ switch (node.kind) {
6182
+ case "leaf": return writeLeaf(ctx, incoming, stored, fieldPath);
6183
+ case "array": return writeArray(ctx, node, incoming, stored, fieldPath);
6184
+ case "object": {
6185
+ if (!isRecord(incoming)) {
6186
+ if (incoming === void 0) return KEEP;
6187
+ ctx.deletes.push(...collectSecretMarkerRefs(stored));
6188
+ return {
6189
+ kind: "value",
6190
+ value: incoming
6191
+ };
6192
+ }
6193
+ const storedObj = isRecord(stored) ? stored : {};
6194
+ return {
6195
+ kind: "value",
6196
+ value: await writeMembers(ctx, node.children, incoming, storedObj, (m) => `${fieldPath}.${m}`)
6197
+ };
6198
+ }
6199
+ }
6200
+ }
6201
+ /** Split a perNode-scoped key (`key@nodeId`). */
6202
+ function splitNodeKey(key) {
6203
+ const at = key.indexOf("@");
6204
+ return at <= 0 ? {
6205
+ base: key,
6206
+ nodeId: null
6207
+ } : {
6208
+ base: key.slice(0, at),
6209
+ nodeId: key.slice(at + 1)
6210
+ };
6211
+ }
6212
+ /** Rewrite a settings patch so no secret value reaches the blob. See the file doc. */
6213
+ async function transformSecretWrite(input) {
6214
+ const deletes = [];
6215
+ const base = {
6216
+ secrets: input.secrets,
6217
+ mintId: input.mintId ?? defaultMintId,
6218
+ deletes,
6219
+ operatorWrite: input.operatorWrite === true
6220
+ };
6221
+ const out = {};
6222
+ for (const [key, incoming] of Object.entries(input.patch)) {
6223
+ const { base: baseKey, nodeId } = splitNodeKey(key);
6224
+ const node = input.tree.get(baseKey);
6225
+ if (node === void 0) {
6226
+ out[key] = incoming;
6227
+ continue;
6228
+ }
6229
+ const scope = nodeId !== null && nodeId.length > 0 ? {
6230
+ kind: "node",
6231
+ nodeId
6232
+ } : input.scope ?? globalSecretScope();
6233
+ const result = await writeNode({
6234
+ ...base,
6235
+ scope
6236
+ }, node, incoming, input.stored[key], baseKey);
6237
+ if (result.kind === "value") out[key] = result.value;
6238
+ }
6239
+ return {
6240
+ patch: out,
6241
+ afterWrite: async () => {
6242
+ if (deletes.length === 0) return { orphaned: [] };
6243
+ try {
6244
+ await input.secrets.delete([...new Set(deletes)]);
6245
+ return { orphaned: [] };
6246
+ } catch {
6247
+ return { orphaned: [...new Set(deletes)] };
6248
+ }
6249
+ }
6250
+ };
6251
+ }
6252
+ /**
6253
+ * Replace every marker in `value` with its keychain value. Returns the SAME
6254
+ * reference when there is no marker (no allocation, no keychain call).
6255
+ */
6256
+ async function resolveSecretMarkers(value, secrets) {
6257
+ const refs = collectSecretMarkerRefs(value);
6258
+ if (refs.length === 0) return {
6259
+ value,
6260
+ unresolved: []
6261
+ };
6262
+ const answers = await secrets.resolve(refs);
6263
+ const unresolved = [];
6264
+ for (const ref of new Set(refs)) {
6265
+ const answer = answers[ref];
6266
+ if (answer === void 0) unresolved.push({
6267
+ ref,
6268
+ reason: "not-initialized"
6269
+ });
6270
+ else if (answer.kind === "unavailable") unresolved.push({
6271
+ ref,
6272
+ reason: answer.reason
6273
+ });
6274
+ else if (answer.kind === "missing" || answer.kind === "forbidden") unresolved.push({
6275
+ ref,
6276
+ reason: answer.kind
6277
+ });
6278
+ }
6279
+ const substitute = (v) => {
6280
+ if (isSecretMarker(v)) {
6281
+ const answer = answers[v.$secret];
6282
+ return answer?.kind === "value" ? {
6283
+ keep: true,
6284
+ value: answer.value
6285
+ } : {
6286
+ keep: false,
6287
+ value: void 0
6288
+ };
6289
+ }
6290
+ if (Array.isArray(v)) {
6291
+ const items = [];
6292
+ for (const item of v) {
6293
+ const s = substitute(item);
6294
+ if (s.keep) items.push(s.value);
6295
+ }
6296
+ return {
6297
+ keep: true,
6298
+ value: items
6299
+ };
6300
+ }
6301
+ if (isRecord(v)) {
6302
+ const out = {};
6303
+ for (const [k, child] of Object.entries(v)) {
6304
+ const s = substitute(child);
6305
+ if (s.keep) out[k] = s.value;
6306
+ }
6307
+ return {
6308
+ keep: true,
6309
+ value: out
6310
+ };
6311
+ }
6312
+ return {
6313
+ keep: true,
6314
+ value: v
6315
+ };
6316
+ };
6317
+ return {
6318
+ value: substitute(value).value,
6319
+ unresolved
6320
+ };
6321
+ }
6322
+ function touchesTree(tree, patch) {
6323
+ if (tree.size === 0) return false;
6324
+ for (const key of Object.keys(patch)) {
6325
+ const at = key.indexOf("@");
6326
+ if (tree.has(at > 0 ? key.slice(0, at) : key)) return true;
6327
+ }
6328
+ return false;
6329
+ }
6330
+ /** The blob as stored now; a failed read REFUSES the write instead of guessing. */
6331
+ async function readStoredAddonBlob(raw) {
6332
+ const threeWay = raw.readAddonStoreResult;
6333
+ if (threeWay === void 0) return raw.readAddonStore();
6334
+ const result = await threeWay.call(raw);
6335
+ if (result.kind === "failed") throw new Error(`settings write refused: the stored blob could not be read (${result.error})`);
6336
+ return result.kind === "missing" ? {} : result.value;
6337
+ }
6338
+ function createSecretAwareSettings(raw, opts) {
6339
+ const chains = /* @__PURE__ */ new Map();
6340
+ const serialize = (key, fn) => {
6341
+ const next = (chains.get(key) ?? Promise.resolve()).then(fn, fn);
6342
+ const tail = next.catch(() => void 0);
6343
+ chains.set(key, tail);
6344
+ tail.then(() => {
6345
+ if (chains.get(key) === tail) chains.delete(key);
6346
+ });
6347
+ return next;
6348
+ };
6349
+ const write = async (chainKey, tree, scope, patch, readStored, rawWrite) => {
6350
+ if (!touchesTree(tree, patch)) return rawWrite(patch);
6351
+ return serialize(chainKey, async () => {
6352
+ const stored = await readStored();
6353
+ const result = await transformSecretWrite({
6354
+ tree,
6355
+ secrets: opts.secrets,
6356
+ patch,
6357
+ stored,
6358
+ ...scope !== void 0 ? { scope } : {},
6359
+ operatorWrite: opts.isOperatorWrite?.() === true
6360
+ });
6361
+ if (Object.keys(result.patch).length > 0) await rawWrite(result.patch);
6362
+ const { orphaned } = await result.afterWrite();
6363
+ if (orphaned.length > 0) opts.onOrphaned(orphaned);
6364
+ });
6365
+ };
6366
+ const wrapped = {
6367
+ writeAddonStore: (patch) => write("addon", opts.addonTree(), void 0, patch, () => readStoredAddonBlob(raw), (p) => raw.writeAddonStore(p)),
6368
+ writeDeviceStore: (deviceId, patch) => write(`device:${deviceId}`, opts.deviceTree(), {
6369
+ kind: "device",
6370
+ deviceId
6371
+ }, patch, () => raw.readDeviceStore(deviceId), (p) => raw.writeDeviceStore(deviceId, p))
6372
+ };
6373
+ return new Proxy(raw, { get(target, prop, receiver) {
6374
+ if (prop === "writeAddonStore") return wrapped.writeAddonStore;
6375
+ if (prop === "writeDeviceStore") return wrapped.writeDeviceStore;
6376
+ const value = Reflect.get(target, prop, receiver);
6377
+ return typeof value === "function" ? value.bind(target) : value;
6378
+ } });
6379
+ }
6380
+ /** The context the addon sees: identical, except that its settings writes are secret-aware. */
6381
+ function withSecretAwareSettings(context, opts) {
6382
+ const raw = context.settings;
6383
+ if (raw === void 0) return context;
6384
+ const settings = createSecretAwareSettings(raw, opts);
6385
+ return new Proxy(context, { get(target, prop, receiver) {
6386
+ if (prop === "settings") return settings;
6387
+ return Reflect.get(target, prop, receiver);
6388
+ } });
6389
+ }
6390
+ var LEAF = { kind: "leaf" };
6391
+ var DEFAULT_ITEM_ID_KEY = "id";
6392
+ function collectFields(fields, out) {
6393
+ for (const field of fields) {
6394
+ if (field.type === "group") {
6395
+ collectFields(field.fields, out);
6396
+ continue;
6397
+ }
6398
+ if (field.type === "sub-tabs") {
6399
+ for (const tab of field.tabs) collectFields(tab.fields, out);
6400
+ continue;
6401
+ }
6402
+ if (field.type === "editable-array") {
6403
+ const item = /* @__PURE__ */ new Map();
6404
+ for (const itemField of field.itemFields) if ("key" in itemField && isKeychainStoredField(itemField)) item.set(itemField.key, LEAF);
6405
+ if (item.size > 0) out.set(field.key, {
6406
+ kind: "array",
6407
+ idKey: field.itemIdKey ?? DEFAULT_ITEM_ID_KEY,
6408
+ item
6409
+ });
6410
+ continue;
6411
+ }
6412
+ if (!("key" in field) || typeof field.key !== "string") continue;
6413
+ if (isKeychainStoredField(field)) out.set(field.key, LEAF);
6414
+ }
6415
+ }
6416
+ /** The secret tree a settings schema declares. */
6417
+ function secretTreeFromSchema(schema) {
6418
+ const out = /* @__PURE__ */ new Map();
6419
+ if (schema === null) return out;
6420
+ for (const section of schema.sections) collectFields(section.fields, out);
6421
+ return out;
6422
+ }
6423
+ /** Parse `a.b[id].c` into segments; throws on a malformed path (a declaration bug). */
6424
+ function parseSecretStatePath(path) {
6425
+ const segments = [];
6426
+ for (const raw of path.split(".")) {
6427
+ const m = /^([^[\]]+)(?:\[([^[\]]+)\])?$/.exec(raw);
6428
+ if (m === null || m[1] === void 0) throw new Error(`secretStatePaths: malformed path "${path}"`);
6429
+ segments.push(m[2] !== void 0 ? {
6430
+ key: m[1],
6431
+ idKey: m[2]
6432
+ } : { key: m[1] });
6433
+ }
6434
+ if (segments.length === 0) throw new Error(`secretStatePaths: empty path`);
6435
+ if (segments[segments.length - 1]?.idKey !== void 0) throw new Error(`secretStatePaths: "${path}" ends on an array — name the member that is secret`);
6436
+ return segments;
6437
+ }
6438
+ function insert(into, segments) {
6439
+ const [head, ...rest] = segments;
6440
+ if (head === void 0) return;
6441
+ if (rest.length === 0) {
6442
+ into.set(head.key, LEAF);
6443
+ return;
6444
+ }
6445
+ const existing = into.get(head.key);
6446
+ if (head.idKey !== void 0) {
6447
+ const item = new Map(existing?.kind === "array" ? existing.item : []);
6448
+ insert(item, rest);
6449
+ into.set(head.key, {
6450
+ kind: "array",
6451
+ idKey: head.idKey,
6452
+ item
6453
+ });
6454
+ return;
6455
+ }
6456
+ const children = new Map(existing?.kind === "object" ? existing.children : []);
6457
+ insert(children, rest);
6458
+ into.set(head.key, {
6459
+ kind: "object",
6460
+ children
6461
+ });
6462
+ }
6463
+ /** Add hidden-state paths (`secretStatePaths`) to a schema-derived tree. */
6464
+ function mergeSecretStatePaths(tree, paths) {
6465
+ if (paths.length === 0) return tree;
6466
+ const out = new Map(tree);
6467
+ for (const path of paths) insert(out, parseSecretStatePath(path));
6468
+ return out;
6469
+ }
6470
+ /** First retry of a secret the keychain could not serve; doubles to {@link SECRET_RETRY_MAX_MS}. */
6471
+ var SECRET_RETRY_FIRST_MS = 5e3;
6472
+ var SECRET_RETRY_MAX_MS = 5 * 6e4;
6473
+ /** Coalesces a burst of `keychain.changed` events into one re-resolve. */
6474
+ var SECRET_CHANGE_DEBOUNCE_MS = 250;
5939
6475
  /**
5940
6476
  * Base class for CamStack addons. Eliminates settings boilerplate:
5941
6477
  *
@@ -6005,6 +6541,25 @@ var BaseAddon = class {
6005
6541
  settingsStoreReady = false;
6006
6542
  /** Default config values. Provided via constructor. */
6007
6543
  defaults;
6544
+ /**
6545
+ * Hidden-state paths that hold secrets (D787) — values the addon writes
6546
+ * itself (`updateGlobalSettings`, `state()`) that no form field declares.
6547
+ * Stored in the keychain exactly like a `password` field. Syntax:
6548
+ * `'snapshotSigningKey'`, `'identity.pincode'`, `'tokens[userId].accessToken'`
6549
+ * (`key[<id field>]` addresses array items by id, never by index).
6550
+ */
6551
+ secretStatePaths = [];
6552
+ _addonSecretTree = null;
6553
+ _deviceSecretTree = null;
6554
+ /** Refs the last resolved config pointed at — a change to one re-resolves. */
6555
+ _configSecretRefs = /* @__PURE__ */ new Set();
6556
+ _unresolvedSecrets = [];
6557
+ _secretRetryTimer = null;
6558
+ _secretRetryDelayMs = SECRET_RETRY_FIRST_MS;
6559
+ _secretChangeTimer = null;
6560
+ _secretChangeUnsub = null;
6561
+ /** >0 while an OPERATOR's settings write is being applied. */
6562
+ _operatorWriteDepth = 0;
6008
6563
  constructor(defaults) {
6009
6564
  this.defaults = defaults;
6010
6565
  this._config = { ...defaults };
@@ -6040,8 +6595,18 @@ var BaseAddon = class {
6040
6595
  return this._config;
6041
6596
  }
6042
6597
  async initialize(context) {
6043
- this._ctx = context;
6598
+ const secrets = context.secrets;
6599
+ this._ctx = secrets !== void 0 ? withSecretAwareSettings(context, {
6600
+ secrets,
6601
+ addonTree: () => this.addonSecretTree(),
6602
+ deviceTree: () => this.deviceSecretTree(),
6603
+ onOrphaned: (refs) => context.logger.warn("keychain refs dropped by a settings write could not be deleted", { meta: { refs: [...refs] } }),
6604
+ isOperatorWrite: () => this._operatorWriteDepth > 0
6605
+ }) : context;
6044
6606
  await this.resolveConfig();
6607
+ if (secrets !== void 0) this._secretChangeUnsub = secrets.onChange((ref) => {
6608
+ if (this._configSecretRefs.has(ref)) this.scheduleSecretReresolve(SECRET_CHANGE_DEBOUNCE_MS);
6609
+ });
6045
6610
  const result = await this.onInitialize();
6046
6611
  this.emitLifecycle(EventCategory.AddonStarted);
6047
6612
  const normalized = normalizeAddonInitResult(result);
@@ -6074,6 +6639,12 @@ var BaseAddon = class {
6074
6639
  */
6075
6640
  async onHubReachable() {}
6076
6641
  async shutdown() {
6642
+ this._secretChangeUnsub?.();
6643
+ this._secretChangeUnsub = null;
6644
+ if (this._secretRetryTimer !== null) clearTimeout(this._secretRetryTimer);
6645
+ if (this._secretChangeTimer !== null) clearTimeout(this._secretChangeTimer);
6646
+ this._secretRetryTimer = null;
6647
+ this._secretChangeTimer = null;
6077
6648
  this.emitLifecycle(EventCategory.AddonStopped);
6078
6649
  if (this.autoEmitReadiness) this.emitReadinessForProviders("down");
6079
6650
  await this.onShutdown();
@@ -6152,7 +6723,7 @@ var BaseAddon = class {
6152
6723
  return hydrateSchema(schema, overlay ? {
6153
6724
  ...projected,
6154
6725
  ...overlay
6155
- } : projected);
6726
+ } : projected, { inlineSecretsAsViews: true });
6156
6727
  }
6157
6728
  /**
6158
6729
  * The integration-level view of this addon's settings: exactly the sections
@@ -6201,7 +6772,7 @@ var BaseAddon = class {
6201
6772
  return hydrateSchema({
6202
6773
  ...schema,
6203
6774
  sections
6204
- }, projected);
6775
+ }, projected, { inlineSecretsAsViews: true });
6205
6776
  }
6206
6777
  /**
6207
6778
  * The raw addon store PROJECTED onto the target node's bare per-node keys:
@@ -6255,18 +6826,50 @@ var BaseAddon = class {
6255
6826
  value: result.value[key]
6256
6827
  };
6257
6828
  }
6829
+ /**
6830
+ * The OPERATOR's write — a settings form or an admin API call, dispatched by
6831
+ * the kernel. Identical to {@link updateGlobalSettings}, except that a secret
6832
+ * the operator sends is stored as sent even when it equals a pre-keychain
6833
+ * inline value: the operator re-entering a password is a change, an addon
6834
+ * writing back what it read is not (D787).
6835
+ */
6836
+ async updateGlobalSettingsAsOperator(patch, nodeId) {
6837
+ this._operatorWriteDepth++;
6838
+ try {
6839
+ await this.applyGlobalPatch(patch, nodeId);
6840
+ } finally {
6841
+ this._operatorWriteDepth--;
6842
+ }
6843
+ }
6258
6844
  async updateGlobalSettings(patch, nodeId) {
6845
+ await this.applyGlobalPatch(patch, nodeId);
6846
+ }
6847
+ /**
6848
+ * REMOVE stored secrets — their keychain values and their markers (D787).
6849
+ *
6850
+ * Writing `''` to a secret field KEEPS what is stored (an empty string is
6851
+ * what a defaults fallback writes back, and it must never destroy a
6852
+ * credential), so code that means "forget this token" says so here. Without
6853
+ * a keychain (an older kernel) it writes `''`, as such code always did.
6854
+ */
6855
+ async clearSecrets(keys, nodeId) {
6856
+ const tree = this.addonSecretTree();
6857
+ const keychain = this._ctx?.secrets !== void 0;
6858
+ const patch = {};
6859
+ for (const key of keys) patch[key] = keychain && tree.has(key) ? SECRET_CLEAR : "";
6860
+ await this.applyGlobalPatch(patch, nodeId);
6861
+ }
6862
+ async applyGlobalPatch(barePatch, nodeId) {
6259
6863
  const keys = this.perNodeKeys();
6260
6864
  const localNode = normalizeNodeId(this._ctx?.kernel?.localNodeId);
6261
6865
  const target = normalizeNodeId(nodeId ?? this._ctx?.kernel?.localNodeId);
6262
- const barePatch = patch;
6263
6866
  const scoped = keys.size > 0 ? scopePatch(barePatch, keys, target) : barePatch;
6264
6867
  await this._ctx?.settings?.writeAddonStore(scoped);
6265
6868
  if (target !== localNode) return;
6266
6869
  await this.resolveConfig();
6267
6870
  await this.onConfigChanged();
6268
6871
  this.emitLifecycle(EventCategory.AddonUpdated, { level: "global" });
6269
- this.maybeAutoRestart(patch, this.globalSettingsSchema());
6872
+ this.maybeAutoRestart(Object.keys(barePatch), this.globalSettingsSchema());
6270
6873
  }
6271
6874
  /**
6272
6875
  * The set of field keys the global settings schema declares `perNode: true`
@@ -6291,7 +6894,7 @@ var BaseAddon = class {
6291
6894
  * time to return its response before the addon is torn down and
6292
6895
  * re-initialised by `AddonRegistryService.restartAddon`.
6293
6896
  */
6294
- maybeAutoRestart(patch, schema) {
6897
+ maybeAutoRestart(patchKeys, schema) {
6295
6898
  if (!schema) return;
6296
6899
  const restartKeys = /* @__PURE__ */ new Set();
6297
6900
  for (const section of schema.sections) for (const field of section.fields) {
@@ -6299,13 +6902,13 @@ var BaseAddon = class {
6299
6902
  if (field.requiresRestart) restartKeys.add(field.key);
6300
6903
  }
6301
6904
  if (restartKeys.size === 0) return;
6302
- if (!Object.keys(patch).some((k) => restartKeys.has(k))) return;
6905
+ if (!patchKeys.some((k) => restartKeys.has(k))) return;
6303
6906
  const ctx = this._ctx;
6304
6907
  if (!ctx) return;
6305
6908
  const addonId = ctx.id;
6306
6909
  setImmediate(() => {
6307
6910
  ctx.api.addons?.restartAddon?.mutate({ addonId }).then(() => {
6308
- ctx.logger.info("addon auto-restart triggered by restart-required setting change", { meta: { changedFields: Object.keys(patch).filter((k) => restartKeys.has(k)) } });
6911
+ ctx.logger.info("addon auto-restart triggered by restart-required setting change", { meta: { changedFields: patchKeys.filter((k) => restartKeys.has(k)) } });
6309
6912
  }).catch((err) => {
6310
6913
  ctx.logger.error("addon auto-restart failed", { meta: { error: err instanceof Error ? err.message : String(err) } });
6311
6914
  });
@@ -6314,7 +6917,7 @@ var BaseAddon = class {
6314
6917
  async getDeviceSettings(deviceId) {
6315
6918
  const schema = this.deviceSettingsSchema();
6316
6919
  if (!schema) return { sections: [] };
6317
- return hydrateSchema(schema, await this._ctx?.settings?.readDeviceStore(deviceId) ?? {});
6920
+ return hydrateSchema(schema, await this._ctx?.settings?.readDeviceStore(deviceId) ?? {}, { inlineSecretsAsViews: true });
6318
6921
  }
6319
6922
  async updateDeviceSettings(deviceId, patch) {
6320
6923
  await this._ctx?.settings?.writeDeviceStore(deviceId, patch);
@@ -6444,7 +7047,7 @@ var BaseAddon = class {
6444
7047
  * selection at boot (absent scoped key ⇒ the constructor default wins).
6445
7048
  */
6446
7049
  async resolveConfig() {
6447
- const stored = await this.readAddonStoreWithRetry();
7050
+ const stored = await this.resolveStoredSecrets(await this.readAddonStoreWithRetry());
6448
7051
  const perNode = this.perNodeKeys();
6449
7052
  const localNode = normalizeNodeId(this._ctx?.kernel?.localNodeId);
6450
7053
  const resolved = { ...this.defaults };
@@ -6469,7 +7072,7 @@ var BaseAddon = class {
6469
7072
  key,
6470
7073
  schema,
6471
7074
  fallback,
6472
- read: () => this.readAddonStoreWithRetry(),
7075
+ read: async () => this.resolveStoredSecrets(await this.readAddonStoreWithRetry()),
6473
7076
  write: async (patch) => {
6474
7077
  await this._ctx?.settings?.writeAddonStore(patch);
6475
7078
  },
@@ -6486,7 +7089,7 @@ var BaseAddon = class {
6486
7089
  key,
6487
7090
  schema,
6488
7091
  fallback,
6489
- read: async () => await this._ctx?.settings?.readDeviceStore(deviceId) ?? {},
7092
+ read: async () => this.resolveStoredSecrets(await this._ctx?.settings?.readDeviceStore(deviceId) ?? {}, false),
6490
7093
  write: async (patch) => {
6491
7094
  await this._ctx?.settings?.writeDeviceStore(deviceId, patch);
6492
7095
  },
@@ -6498,6 +7101,70 @@ var BaseAddon = class {
6498
7101
  } })
6499
7102
  });
6500
7103
  }
7104
+ /** The addon store's secret tree: schema fields by TYPE, plus `secretStatePaths`. */
7105
+ addonSecretTree() {
7106
+ this._addonSecretTree ??= mergeSecretStatePaths(secretTreeFromSchema(this.globalSettingsSchema()), this.secretStatePaths);
7107
+ return this._addonSecretTree;
7108
+ }
7109
+ deviceSecretTree() {
7110
+ this._deviceSecretTree ??= secretTreeFromSchema(this.deviceSettingsSchema());
7111
+ return this._deviceSecretTree;
7112
+ }
7113
+ /**
7114
+ * Secrets of this addon's stored config that could not be resolved on the
7115
+ * last read, with why. Non-empty means the addon is running WITHOUT them —
7116
+ * an addon whose function needs one should report itself degraded rather
7117
+ * than start on an empty credential.
7118
+ */
7119
+ get unresolvedSecrets() {
7120
+ return this._unresolvedSecrets;
7121
+ }
7122
+ /**
7123
+ * Substitute every keychain marker in a stored blob with its value. With no
7124
+ * keychain (no `ctx.secrets`) or no marker, the blob comes back unchanged.
7125
+ * An unresolvable value is LEFT OUT (never `''`), logged by ref — never by
7126
+ * value — and, when the cause can pass, retried with backoff. Nothing is
7127
+ * ever written back from here.
7128
+ */
7129
+ async resolveStoredSecrets(blob, trackForConfig = true) {
7130
+ const secrets = this._ctx?.secrets;
7131
+ if (secrets === void 0) return blob;
7132
+ const refs = collectSecretMarkerRefs(blob);
7133
+ if (trackForConfig) this._configSecretRefs = new Set(refs);
7134
+ if (refs.length === 0) {
7135
+ if (trackForConfig) this._unresolvedSecrets = [];
7136
+ return blob;
7137
+ }
7138
+ const { value, unresolved } = await resolveSecretMarkers(blob, secrets);
7139
+ if (trackForConfig) {
7140
+ this._unresolvedSecrets = unresolved;
7141
+ if (unresolved.length > 0) {
7142
+ this._ctx?.logger?.error?.("secret unavailable — running without it, will retry", { meta: { secrets: unresolved.map((u) => ({
7143
+ ref: u.ref,
7144
+ reason: u.reason
7145
+ })) } });
7146
+ if (unresolved.some((u) => u.reason !== "missing" && u.reason !== "forbidden")) {
7147
+ this.scheduleSecretReresolve(this._secretRetryDelayMs);
7148
+ this._secretRetryDelayMs = Math.min(this._secretRetryDelayMs * 2, SECRET_RETRY_MAX_MS);
7149
+ }
7150
+ } else this._secretRetryDelayMs = SECRET_RETRY_FIRST_MS;
7151
+ }
7152
+ return value;
7153
+ }
7154
+ /** Re-resolve the config (a keychain-only change, or a retry) and apply it. */
7155
+ scheduleSecretReresolve(delayMs) {
7156
+ const timerOf = delayMs === SECRET_CHANGE_DEBOUNCE_MS ? "_secretChangeTimer" : "_secretRetryTimer";
7157
+ if (this[timerOf] !== null) return;
7158
+ const timer = setTimeout(() => {
7159
+ this[timerOf] = null;
7160
+ if (this._ctx === null) return;
7161
+ this.resolveConfig().then(() => this.onConfigChanged()).catch((err) => {
7162
+ this._ctx?.logger?.error?.("re-resolving secrets failed", { meta: { error: err instanceof Error ? err.message : String(err) } });
7163
+ });
7164
+ }, delayMs);
7165
+ timer.unref?.();
7166
+ this[timerOf] = timer;
7167
+ }
6501
7168
  /**
6502
7169
  * Wrap `ctx.settings.readAddonStore()` with a short retry budget so a
6503
7170
  * transient settings-store outage (mid-restart of sqlite-settings, tsx-watch
@@ -14302,6 +14969,196 @@ id: union([string(), number()]) }), {
14302
14969
  kind: "mutation",
14303
14970
  auth: "admin"
14304
14971
  });
14972
+ /**
14973
+ * `keychain` — the hub's encrypted store of secret values (D787).
14974
+ *
14975
+ * Settings blobs never hold a secret: they hold a marker
14976
+ * `{"$secret":"secret://<owner>/<scope>/<fieldPath>","v":1}` and the value
14977
+ * lives here, AES-256-GCM under a data key that a master key wraps. This cap
14978
+ * is the OWNER's door to its own values: every method is owner-checked
14979
+ * against the CALLER, never against anything the caller claims.
14980
+ *
14981
+ * Who the caller is: the transport stamps `callerAddonId` into the args of a
14982
+ * call that crossed a process (the parent `LocalChildRegistry` from the UDS
14983
+ * connection, the agent from its child's connection carried in
14984
+ * `$hub-cap-fwd`'s envelope). A stamp always overwrites; a wire call with no
14985
+ * stamp has its claim stripped. Only a hub in-process caller may state its own
14986
+ * identity — `ctx.secrets` does that with the addon id closed over. This is
14987
+ * identity against BUGS and misrouting, not against a malicious addon (every
14988
+ * runner is the same OS user): see the threat model in
14989
+ * `docs/design/2026-10-08-secrets-keychain.md`.
14990
+ *
14991
+ * `callerAddonId` is deliberately NOT in any input schema: the tRPC router
14992
+ * parses the input, so a session can never supply it, and the internal mount
14993
+ * floors every method to admin anyway (D240).
14994
+ *
14995
+ * Internal: addons reach it through `ctx.secrets`, never directly.
14996
+ */
14997
+ /** Why a value cannot be served right now. Never folded into "missing". */
14998
+ var KeychainUnavailableReasonSchema = _enum([
14999
+ "key-missing",
15000
+ "wrong-key",
15001
+ "key-file-unreadable",
15002
+ "store-unavailable",
15003
+ "not-initialized",
15004
+ "decrypt-failed"
15005
+ ]);
15006
+ var KeychainStateSchema = discriminatedUnion("state", [object({ state: literal("ready") }), object({
15007
+ state: literal("locked"),
15008
+ reason: KeychainUnavailableReasonSchema
15009
+ })]);
15010
+ var KeychainResolveEntrySchema = discriminatedUnion("kind", [
15011
+ object({
15012
+ kind: literal("value"),
15013
+ value: string(),
15014
+ version: number().int()
15015
+ }),
15016
+ object({ kind: literal("missing") }),
15017
+ object({
15018
+ kind: literal("unavailable"),
15019
+ reason: KeychainUnavailableReasonSchema
15020
+ }),
15021
+ object({ kind: literal("forbidden") })
15022
+ ]);
15023
+ var KeychainResolveResultSchema = record(string(), KeychainResolveEntrySchema);
15024
+ /** Metadata of one stored value — never the value. */
15025
+ var KeychainSecretMetaSchema = object({
15026
+ ref: string(),
15027
+ owner: string(),
15028
+ /** Formatted scope (`global`, `node/<id>`, `device/<id>`, …). */
15029
+ scope: string(),
15030
+ fieldPath: string(),
15031
+ version: number().int(),
15032
+ createdAt: number(),
15033
+ updatedAt: number(),
15034
+ /** `addon:<id>` | `user:<id>` | `system`. */
15035
+ updatedBy: string(),
15036
+ /** Coarse — written at most once an hour per ref. `null` = never read. */
15037
+ lastReadAt: number().nullable()
15038
+ });
15039
+ var RefListSchema = array(string().min(1)).max(512);
15040
+ method(object({
15041
+ ref: string().min(1),
15042
+ value: string().min(1)
15043
+ }), object({
15044
+ ref: string(),
15045
+ version: number().int()
15046
+ }), {
15047
+ kind: "mutation",
15048
+ auth: "admin"
15049
+ }), method(object({ refs: RefListSchema }), KeychainResolveResultSchema, { auth: "admin" }), method(object({ refs: RefListSchema }), object({ deleted: number().int() }), {
15050
+ kind: "mutation",
15051
+ auth: "admin"
15052
+ }), method(object({}), array(KeychainSecretMetaSchema).readonly(), { auth: "admin" }), method(object({}), KeychainStateSchema, { auth: "admin" });
15053
+ var KeychainKeySourceSchema = object({
15054
+ kind: _enum([
15055
+ "config-file",
15056
+ "previous-config-file",
15057
+ "platform",
15058
+ "default-file"
15059
+ ]),
15060
+ /** File sources only — a path is not a secret. */
15061
+ path: string().optional(),
15062
+ /**
15063
+ * True when a whole-volume backup of the data directory carries this key
15064
+ * next to the database it protects (the default file). The page warns.
15065
+ */
15066
+ sharesBackupWithDatabase: boolean()
15067
+ });
15068
+ var KeychainStatusSchema = object({
15069
+ keychain: KeychainStateSchema,
15070
+ /** The source of the master key in use; `null` while locked. */
15071
+ keySource: KeychainKeySourceSchema.nullable(),
15072
+ /** The source configured to be primary — differs from `keySource` while a rotation is pending. */
15073
+ configuredSource: KeychainKeySourceSchema,
15074
+ /** Short fingerprint of the master key in use (`HMAC(KEK, label)`, 16 hex). */
15075
+ fingerprint: string().nullable(),
15076
+ activeKeyId: string().nullable(),
15077
+ /**
15078
+ * The keychain unlocked with a NON-primary source: the configured primary
15079
+ * key is not the one that wraps the data key yet. `rotateMasterKey` moves it.
15080
+ */
15081
+ rotationPending: boolean(),
15082
+ /** Wrapped copies of the data key under a previous master key, kept until purged. */
15083
+ retiredWraps: number().int(),
15084
+ recoveryKeyDownloadedAt: number().nullable(),
15085
+ secretCount: number().int()
15086
+ });
15087
+ /**
15088
+ * Whether a stored value is still pointed at by its owner's settings.
15089
+ * `unknown` is a first-class answer: a scope whose blob could not be read is
15090
+ * never reported as an orphan (and never deleted as one).
15091
+ */
15092
+ var KeychainSecretUsageSchema = _enum([
15093
+ "in-use",
15094
+ "orphan",
15095
+ "unknown"
15096
+ ]);
15097
+ var KeychainAdminSecretSchema = KeychainSecretMetaSchema.extend({ usage: KeychainSecretUsageSchema });
15098
+ var KeychainAuditActionSchema = _enum([
15099
+ "put",
15100
+ "delete",
15101
+ "reveal",
15102
+ "rotate-master-key",
15103
+ "purge-retired-keys",
15104
+ "download-recovery-key",
15105
+ "delete-orphans",
15106
+ "reset",
15107
+ "initialize"
15108
+ ]);
15109
+ var KeychainAuditEntrySchema = object({
15110
+ id: string(),
15111
+ at: number(),
15112
+ action: KeychainAuditActionSchema,
15113
+ /** `addon:<id>` | `user:<id>` | `system`. */
15114
+ actor: string(),
15115
+ ref: string().nullable(),
15116
+ detail: string().nullable()
15117
+ });
15118
+ 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({
15119
+ value: string(),
15120
+ version: number().int()
15121
+ }), {
15122
+ kind: "mutation",
15123
+ auth: "admin",
15124
+ caller: "required"
15125
+ }), method(object({ refs: array(string().min(1)).max(1e3) }), object({
15126
+ deleted: array(string()).readonly(),
15127
+ kept: array(object({
15128
+ ref: string(),
15129
+ usage: KeychainSecretUsageSchema
15130
+ })).readonly()
15131
+ }), {
15132
+ kind: "mutation",
15133
+ auth: "admin",
15134
+ caller: "required"
15135
+ }), method(object({}), object({
15136
+ fingerprint: string(),
15137
+ keySource: KeychainKeySourceSchema
15138
+ }), {
15139
+ kind: "mutation",
15140
+ auth: "admin",
15141
+ caller: "required"
15142
+ }), method(object({}), object({ purged: number().int() }), {
15143
+ kind: "mutation",
15144
+ auth: "admin",
15145
+ caller: "required"
15146
+ }), method(object({}), object({
15147
+ key: string(),
15148
+ fingerprint: string(),
15149
+ keySource: KeychainKeySourceSchema
15150
+ }), {
15151
+ kind: "mutation",
15152
+ auth: "admin",
15153
+ caller: "required"
15154
+ }), method(object({ confirm: literal("RESET KEYCHAIN") }), object({
15155
+ archivedCollection: string().nullable(),
15156
+ archived: number().int()
15157
+ }), {
15158
+ kind: "mutation",
15159
+ auth: "admin",
15160
+ caller: "required"
15161
+ });
14305
15162
  method(_void(), object({
14306
15163
  id: string(),
14307
15164
  name: string(),
@@ -15364,7 +16221,11 @@ var DeviceRegisterPayloadSchema = object({
15364
16221
  var DeviceRemovePayloadSchema = object({ deviceId: number() });
15365
16222
  var DevicePersistConfigPayloadSchema = object({
15366
16223
  deviceId: number(),
15367
- data: record(string(), unknown())
16224
+ data: record(string(), unknown()),
16225
+ /** The paths the device's schema declares secret (D783), when the caller
16226
+ * knows them — those values are kept in the keychain, not the blob (D787).
16227
+ * Absent: the paths the device last reported at `registerDevice` apply. */
16228
+ secretConfigPaths: array(string()).optional()
15368
16229
  });
15369
16230
  /** What a migration actually did, per switch. `unreachable` is a first-class
15370
16231
  * answer: a camera that could not be asked is not a camera that was silenced. */
@@ -22359,8 +23220,23 @@ var RetrainMacroClassSchema = _enum([
22359
23220
  ]);
22360
23221
  /** A subject to learn, or a phantom to unlearn (taught by OMISSION). */
22361
23222
  var RetrainAnnotationKindSchema = _enum(["subject", "model_error"]);
22362
- /** Did a human draw this box, or did the assist propose it? */
22363
- var RetrainAnnotationSourceSchema = _enum(["operator", "assist"]);
23223
+ /**
23224
+ * Where a box came from. A machine-sourced box is a DRAFT on the page until
23225
+ * the operator confirms it; once saved it keeps its source as provenance.
23226
+ *
23227
+ * - `operator` — drawn by hand.
23228
+ * - `assist` — proposed by a detector run on the copy (the camera's own
23229
+ * model, or a larger teacher model).
23230
+ * - `pipeline` — the box the live pipeline actually drew on that frame, read
23231
+ * back from the track store (never a re-run).
23232
+ * - `llm` — proposed by a vision-capable LLM profile.
23233
+ */
23234
+ var RetrainAnnotationSourceSchema = _enum([
23235
+ "operator",
23236
+ "assist",
23237
+ "pipeline",
23238
+ "llm"
23239
+ ]);
22364
23240
  /** Normalised `[0,1]` rectangle against the FULL frame — the canonical form. */
22365
23241
  var RetrainBboxSchema = object({
22366
23242
  x: number(),
@@ -22378,7 +23254,8 @@ var RetrainBboxSchema = object({
22378
23254
  */
22379
23255
  var RetrainAnnotationSchema = object({
22380
23256
  id: string(),
22381
- trackId: string(),
23257
+ /** The frame's track. Absent on a recording still, which has none. */
23258
+ trackId: string().optional(),
22382
23259
  deviceId: number(),
22383
23260
  /** The COPY in retrain storage — never the source track's media key. */
22384
23261
  mediaKey: string(),
@@ -22427,13 +23304,47 @@ var RetrainFrameCandidateSchema = object({
22427
23304
  * fail, whatever became of the original. */
22428
23305
  copied: boolean()
22429
23306
  });
23307
+ /**
23308
+ * One box the live pipeline drew on a copied frame — what a correction starts
23309
+ * from. Derived when the frame is listed, from the track store: the subject
23310
+ * box recorded on the source media row when there is one, else the track
23311
+ * position nearest the frame's capture time. Never stored as an annotation
23312
+ * until the operator confirms it.
23313
+ */
23314
+ var RetrainPipelineBoxSchema = object({
23315
+ /** Normalised `[0,1]` against the full frame. */
23316
+ bbox: RetrainBboxSchema,
23317
+ macroClass: RetrainMacroClassSchema,
23318
+ label: string().optional(),
23319
+ subLabel: string().optional(),
23320
+ /** The detection score of the position used, when it was recorded. */
23321
+ score: number().optional(),
23322
+ /** The root model that produced the track, when it was recorded. */
23323
+ modelId: string().optional(),
23324
+ trackId: string(),
23325
+ /** `subject-box`: recorded on this very frame. `position`: the track's
23326
+ * position nearest the capture time, `deltaMs` away. */
23327
+ basis: _enum(["subject-box", "position"]),
23328
+ deltaMs: number()
23329
+ });
23330
+ /**
23331
+ * Where a retrain frame came from: a TRACK's stored media (copy-on-select),
23332
+ * or the RECORDING at an instant — the frame a model saw nothing in has no
23333
+ * track at all.
23334
+ */
23335
+ var RetrainFrameOriginSchema = _enum(["track", "recording"]);
22430
23336
  /** A frame the dataset OWNS: bytes copied at selection time. */
22431
23337
  var RetrainFrameSchema = object({
22432
23338
  frameId: string(),
22433
23339
  deviceId: number(),
22434
- trackId: string(),
22435
- /** Provenance only. It may already point at nothing — that is expected. */
22436
- sourceMediaId: number().int(),
23340
+ origin: RetrainFrameOriginSchema,
23341
+ /** The track it was copied from. Absent on a recording still. */
23342
+ trackId: string().optional(),
23343
+ /** Provenance only. It may already point at nothing — that is expected.
23344
+ * Absent on a recording still. */
23345
+ sourceMediaId: number().int().optional(),
23346
+ /** A recording still: the playhead instant it was taken at. */
23347
+ epochMs: number().optional(),
22437
23348
  sourceKind: MediaFileKindEnum,
22438
23349
  sizeBytes: number().int(),
22439
23350
  width: number().int(),
@@ -22444,7 +23355,12 @@ var RetrainFrameSchema = object({
22444
23355
  /** The operator's "every subject in this frame is boxed". Detector
22445
23356
  * evaluation keeps only complete frames: an unboxed subject would count as
22446
23357
  * a false positive. */
22447
- complete: boolean()
23358
+ complete: boolean(),
23359
+ /** The boxes the pipeline drew on this frame. Present on list answers;
23360
+ * empty when nothing the track store holds can be placed on it. */
23361
+ pipelineBoxes: array(RetrainPipelineBoxSchema).readonly().optional(),
23362
+ /** The named collections this frame belongs to. Present on list answers. */
23363
+ collectionIds: array(string()).readonly().optional()
22448
23364
  });
22449
23365
  /** Why a copy-on-select could not be honoured — named, never a silent skip. */
22450
23366
  var RetrainCopyRefusalSchema = _enum([
@@ -22475,6 +23391,8 @@ var RetrainFrameListSchema = object({
22475
23391
  var RetrainExportFilterSchema = object({
22476
23392
  deviceIds: array(number()).optional(),
22477
23393
  frameIds: array(string()).max(2e4).optional(),
23394
+ /** Only frames in at least one of these named collections. */
23395
+ collectionIds: array(string()).max(200).optional(),
22478
23396
  batchId: string().optional(),
22479
23397
  /** Only frames the operator marked complete (all subjects boxed). */
22480
23398
  completeOnly: boolean().optional()
@@ -22539,6 +23457,109 @@ var RetrainAssistResultSchema = discriminatedUnion("kind", [object({
22539
23457
  reason: string(),
22540
23458
  detail: string().optional()
22541
23459
  })]);
23460
+ /** A named set over the retrain corpus — membership only, it owns no pixels. */
23461
+ var RetrainCollectionSchema = object({
23462
+ id: string(),
23463
+ name: string(),
23464
+ createdAt: number(),
23465
+ frameCount: number().int()
23466
+ });
23467
+ var RetrainCollectionCreateResultSchema = discriminatedUnion("kind", [object({
23468
+ kind: literal("created"),
23469
+ collection: RetrainCollectionSchema
23470
+ }), object({
23471
+ kind: literal("refused"),
23472
+ reason: _enum(["empty-name", "duplicate-name"])
23473
+ })]);
23474
+ var RetrainCollectionRenameResultSchema = discriminatedUnion("kind", [object({
23475
+ kind: literal("renamed"),
23476
+ collection: RetrainCollectionSchema
23477
+ }), object({
23478
+ kind: literal("refused"),
23479
+ reason: _enum([
23480
+ "empty-name",
23481
+ "duplicate-name",
23482
+ "unknown-collection"
23483
+ ])
23484
+ })]);
23485
+ /**
23486
+ * The outcome of adding the frame at a recording instant. Every refusal is
23487
+ * named: `still-unavailable` (not recording, a gap, or an undecodable frame —
23488
+ * `detail` says which), `still-busy` (the recorder is at its decode bound; try
23489
+ * again), `unreadable-image`, `write-failed`, `unknown-collection`.
23490
+ */
23491
+ var AddRetrainFrameFromRecordingResultSchema = discriminatedUnion("kind", [object({
23492
+ kind: literal("added"),
23493
+ collectionId: string(),
23494
+ frame: RetrainFrameSchema,
23495
+ /** The moment was already in the dataset; nothing was decoded. */
23496
+ reused: boolean()
23497
+ }), object({
23498
+ kind: literal("refused"),
23499
+ reason: _enum([
23500
+ "unknown-collection",
23501
+ "still-unavailable",
23502
+ "still-busy",
23503
+ "unreadable-image",
23504
+ "write-failed"
23505
+ ]),
23506
+ detail: string().optional()
23507
+ })]);
23508
+ /** A vision LLM profile the AI assist may use, and where it sends the frame. */
23509
+ var RetrainAssistProfileSchema = object({
23510
+ id: string(),
23511
+ name: string(),
23512
+ model: string(),
23513
+ kind: string(),
23514
+ /** `true` when the frame would leave the house (a cloud vendor, or an
23515
+ * endpoint that is not on the local network). The page confirms each such
23516
+ * run, and the provider refuses one without `allowCloud`. */
23517
+ leavesHouse: boolean()
23518
+ });
23519
+ /** A box the AI assist proposed: a draft, plus the model's own reason. */
23520
+ var RetrainLlmProposalSchema = RetrainAnnotationDraftSchema.extend({ reason: string() });
23521
+ /** What the AI assist said about a box that was already on the canvas. */
23522
+ var RetrainLlmReviewSchema = object({
23523
+ /** The `ref` the page sent the box under. */
23524
+ ref: string(),
23525
+ verdict: _enum([
23526
+ "confirmed",
23527
+ "wrong-class",
23528
+ "not-an-object",
23529
+ "uncertain"
23530
+ ]),
23531
+ suggestedClass: RetrainMacroClassSchema.optional(),
23532
+ reason: string()
23533
+ });
23534
+ /**
23535
+ * The AI assist's answer. `proposed` carries drafts (`source: 'llm'`, the
23536
+ * model and its confidence) and reviews; items the model got wrong (a box off
23537
+ * the frame, an unasked class, an unknown ref) are dropped and counted in
23538
+ * `rejected`. A whole answer that is not the schema is `malformed-answer`.
23539
+ */
23540
+ var RetrainLlmAssistResultSchema = discriminatedUnion("kind", [object({
23541
+ kind: literal("proposed"),
23542
+ profileId: string(),
23543
+ model: string(),
23544
+ /** The frame was sent outside the house for this answer. */
23545
+ leftHouse: boolean(),
23546
+ proposals: array(RetrainLlmProposalSchema).readonly(),
23547
+ reviews: array(RetrainLlmReviewSchema).readonly(),
23548
+ rejected: number().int()
23549
+ }), object({
23550
+ kind: literal("refused"),
23551
+ reason: _enum([
23552
+ "unknown-frame",
23553
+ "unreadable-frame",
23554
+ "unknown-profile",
23555
+ "profile-disabled",
23556
+ "no-vision",
23557
+ "cloud-not-confirmed",
23558
+ "llm-error",
23559
+ "malformed-answer"
23560
+ ]),
23561
+ detail: string().optional()
23562
+ })]);
22542
23563
  /** The outcome of a lifecycle move owned by the retrain page. */
22543
23564
  var RetrainTransitionResultSchema = object({
22544
23565
  trackId: string(),
@@ -23256,7 +24277,7 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema$1).r
23256
24277
  auth: "admin"
23257
24278
  }), method(object({
23258
24279
  deviceId: number(),
23259
- trackId: string(),
24280
+ trackId: string().optional(),
23260
24281
  frameId: string()
23261
24282
  }), object({
23262
24283
  removed: boolean(),
@@ -23273,7 +24294,8 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema$1).r
23273
24294
  auth: "admin"
23274
24295
  }), method(object({
23275
24296
  deviceId: number(),
23276
- trackId: string(),
24297
+ /** The frame's track, when it has one — checked against the frame. */
24298
+ trackId: string().optional(),
23277
24299
  frameId: string(),
23278
24300
  subject: RetrainAssistSubjectSchema,
23279
24301
  /** Which node runs it. Absent ⇒ wherever an unowned call lands. */
@@ -23281,12 +24303,16 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema$1).r
23281
24303
  }), RetrainAssistResultSchema, {
23282
24304
  kind: "mutation",
23283
24305
  auth: "admin"
23284
- }), method(object({ trackId: string() }), array(RetrainAnnotationSchema).readonly(), {
24306
+ }), method(object({
24307
+ trackId: string().optional(),
24308
+ frameIds: array(string()).max(2e3).optional()
24309
+ }), array(RetrainAnnotationSchema).readonly(), {
23285
24310
  kind: "query",
23286
24311
  auth: "admin"
23287
24312
  }), method(object({
23288
24313
  deviceId: number(),
23289
- trackId: string(),
24314
+ /** The frame's track, when it has one — checked against the frame. */
24315
+ trackId: string().optional(),
23290
24316
  frameId: string(),
23291
24317
  annotations: array(RetrainAnnotationDraftSchema)
23292
24318
  }), array(RetrainAnnotationSchema).readonly(), {
@@ -23309,7 +24335,7 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema$1).r
23309
24335
  auth: "admin"
23310
24336
  }), method(object({
23311
24337
  deviceId: number(),
23312
- trackId: string(),
24338
+ trackId: string().optional(),
23313
24339
  frameId: string(),
23314
24340
  complete: boolean()
23315
24341
  }), RetrainFrameSchema, {
@@ -23323,6 +24349,74 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema$1).r
23323
24349
  kind: "mutation",
23324
24350
  auth: "admin",
23325
24351
  timeoutMs: 60 * 6e4
24352
+ }), method(object({}), array(RetrainAssistProfileSchema).readonly(), {
24353
+ kind: "query",
24354
+ auth: "admin"
24355
+ }), method(object({
24356
+ deviceId: number(),
24357
+ trackId: string().optional(),
24358
+ frameId: string(),
24359
+ profileId: string(),
24360
+ classes: array(RetrainMacroClassSchema).min(1),
24361
+ boxes: array(object({
24362
+ ref: string(),
24363
+ bbox: RetrainBboxSchema,
24364
+ macroClass: RetrainMacroClassSchema,
24365
+ label: string().optional()
24366
+ })).max(50),
24367
+ allowCloud: boolean()
24368
+ }), RetrainLlmAssistResultSchema, {
24369
+ kind: "mutation",
24370
+ auth: "admin",
24371
+ timeoutMs: 18e4
24372
+ }), method(object({ name: string().max(120) }), RetrainCollectionCreateResultSchema, {
24373
+ kind: "mutation",
24374
+ auth: "admin"
24375
+ }), method(object({}), array(RetrainCollectionSchema).readonly(), {
24376
+ kind: "query",
24377
+ auth: "admin"
24378
+ }), method(object({
24379
+ id: string(),
24380
+ name: string().max(120)
24381
+ }), RetrainCollectionRenameResultSchema, {
24382
+ kind: "mutation",
24383
+ auth: "admin"
24384
+ }), method(object({ id: string() }), object({
24385
+ deleted: boolean(),
24386
+ removedFrames: number().int()
24387
+ }), {
24388
+ kind: "mutation",
24389
+ auth: "admin"
24390
+ }), method(object({
24391
+ collectionId: string(),
24392
+ deviceId: number(),
24393
+ epochMs: number()
24394
+ }), AddRetrainFrameFromRecordingResultSchema, {
24395
+ kind: "mutation",
24396
+ auth: "admin",
24397
+ timeoutMs: 6e4
24398
+ }), method(object({
24399
+ collectionId: string(),
24400
+ frameIds: array(string()).min(1).max(500)
24401
+ }), object({
24402
+ added: number().int(),
24403
+ alreadyMember: number().int(),
24404
+ unknownFrameIds: array(string()).readonly()
24405
+ }), {
24406
+ kind: "mutation",
24407
+ auth: "admin"
24408
+ }), method(object({
24409
+ collectionId: string(),
24410
+ frameId: string()
24411
+ }), object({
24412
+ removed: boolean(),
24413
+ deletedFrame: boolean()
24414
+ }), {
24415
+ kind: "mutation",
24416
+ auth: "admin"
24417
+ }), method(object({ collectionId: string() }), array(RetrainFrameSchema).readonly(), {
24418
+ kind: "query",
24419
+ auth: "admin"
23326
24420
  }), method(object({
23327
24421
  /** Which of the three event tables owns the row. */
23328
24422
  ownerType: EventOwnerTypeSchema,
@@ -23946,13 +25040,31 @@ var RecommendationReasonSchema = discriminatedUnion("kind", [
23946
25040
  object({
23947
25041
  kind: literal("no-family-build"),
23948
25042
  format: ModelFormatSchema$1
25043
+ }),
25044
+ object({
25045
+ kind: literal("kept-custom-pin"),
25046
+ modelId: string(),
25047
+ deviceKey: string()
23949
25048
  })
23950
25049
  ]);
25050
+ /** Why a device is left exactly as it is, whatever the plan would pick (D786). */
25051
+ var KeptReasonSchema = _enum(["custom-pin"]);
25052
+ /**
25053
+ * Where a choice's latency came from (D791): this node's own benchmark
25054
+ * result, or the hardware-class table. Measured on the node beats the table.
25055
+ */
25056
+ var LatencySourceSchema = discriminatedUnion("kind", [object({ kind: literal("table") }), object({
25057
+ kind: literal("node-benchmark"),
25058
+ resultId: string(),
25059
+ measuredAtMs: number()
25060
+ })]);
23951
25061
  var DeviceModelChoiceSchema = object({
23952
25062
  modelId: string(),
23953
25063
  p50Ms: number(),
23954
25064
  fps: number(),
23955
25065
  measured: boolean(),
25066
+ /** Absent on a plan from before D791 — read as the table. */
25067
+ source: LatencySourceSchema.optional(),
23956
25068
  /** Parallel sessions at the camera rate with the headroom kept free: ⌊fps × (1 − headroom) / camera fps⌋. */
23957
25069
  capacitySessions: number(),
23958
25070
  personRecall: number()
@@ -23963,6 +25075,8 @@ var DeviceRecommendationSchema = object({
23963
25075
  enabled: boolean(),
23964
25076
  available: boolean(),
23965
25077
  chosen: DeviceModelChoiceSchema.nullable(),
25078
+ /** Present when the device is kept as is: Apply writes nothing on it. */
25079
+ kept: KeptReasonSchema.optional(),
23966
25080
  reasons: array(RecommendationReasonSchema).readonly()
23967
25081
  });
23968
25082
  var NodeRecommendationSchema = object({
@@ -24016,6 +25130,17 @@ var AutoTuneWarningSchema = discriminatedUnion("kind", [
24016
25130
  kind: literal("coral-enabled"),
24017
25131
  nodeId: string(),
24018
25132
  deviceKey: string()
25133
+ }),
25134
+ object({
25135
+ kind: literal("custom-pin-kept"),
25136
+ nodeId: string(),
25137
+ deviceKey: string().nullable(),
25138
+ deviceId: number().nullable(),
25139
+ modelId: string()
25140
+ }),
25141
+ object({
25142
+ kind: literal("custom-registry-unreadable"),
25143
+ error: string()
24019
25144
  })
24020
25145
  ]);
24021
25146
  var AutoTuneOptionsSchema = object({
@@ -24194,13 +25319,14 @@ var SuggestSharesResultSchema = object({
24194
25319
  nodes: array(SuggestedNodeShareSchema).readonly()
24195
25320
  });
24196
25321
  /**
24197
- * Where the node and device shares come from (D750, D755).
24198
- * - `hardware` (default) — computed by the system from each node's static
24199
- * capacity (its accelerators at their Auto tune models, from the measured
24200
- * latency table), recomputed whenever a node or device joins, leaves, is
24201
- * switched on or off, or changes model. No load input.
24202
- * - `benchmark` — the same, from each node's measured capacity (node
24203
- * benchmark results); a node without results falls back to `hardware`.
25322
+ * Where the node and device shares come from (D750, D755, D791).
25323
+ * - `benchmark` (default since D791) — each node's capacity as its own node
25324
+ * benchmark measured it; a node without fresh results is sized from
25325
+ * `hardware` and says so. Measured on the node beats the table.
25326
+ * - `hardware` — computed from each node's static capacity only (its
25327
+ * accelerators at their Auto tune models, from the latency table).
25328
+ * Both are recomputed whenever a node or device joins, leaves, is switched
25329
+ * on or off, changes model, or a benchmark result is written. No load input.
24204
25330
  * - `manual` — the operator's stored sliders.
24205
25331
  * Either way a node or device that cannot take sessions gives its share to
24206
25332
  * the others in proportion; the stored values are never rewritten for that.
@@ -24249,6 +25375,362 @@ var EffectiveSharesSchema = object({
24249
25375
  nodeWeights: record(string(), number()),
24250
25376
  deviceWeights: record(string(), record(string(), number()))
24251
25377
  });
25378
+ /**
25379
+ * Wire shapes of the node benchmark (D791): the operator's plan, the
25380
+ * preflight the confirmation shows, the run the orchestrator owns, what the
25381
+ * measuring runner reports, and the result rows Auto tune and the automatic
25382
+ * shares read.
25383
+ *
25384
+ * ONE node at a time, owned by the pipeline orchestrator. While a run is
25385
+ * active the cluster is in BENCHMARK MODE for that node: it is not a
25386
+ * detection candidate, camera pins naming it are ignored so its sessions move
25387
+ * elsewhere, and both come back when the mode ends — after a crash or a hub
25388
+ * restart too (a persisted manifest, reconciled against the registry).
25389
+ *
25390
+ * Two measurements, both on the node, driven by its own runner (frames never
25391
+ * cross a process at frame rate, D9):
25392
+ * - `device` — one accelerator × one candidate detector, root only, open
25393
+ * loop: how many streams at the camera rate it carries inside the frame
25394
+ * interval;
25395
+ * - `pipeline` — the chosen detector plus the operator's detail steps
25396
+ * (faces, plates, classifiers, CLIP…), on varied frames from the bench
25397
+ * clip: how many parallel sessions the node carries before latency, drops,
25398
+ * CPU, RAM or the event loop give out.
25399
+ */
25400
+ /** Defaults and bounds, one place. */
25401
+ var NODE_BENCHMARK_DEFAULTS = {
25402
+ fpsPerStream: 10,
25403
+ budgetMinutes: 45,
25404
+ minBudgetMinutes: 10,
25405
+ maxBudgetMinutes: 120,
25406
+ /** A result older than this no longer beats the table. */
25407
+ staleAfterDays: 30,
25408
+ /** Warm-in per ramp step (not accounted). */
25409
+ settleSec: 5,
25410
+ /** Accounted window per ramp step. */
25411
+ measureSec: 20,
25412
+ /** Longest the drain may take before the run is refused. */
25413
+ drainTimeoutSec: 120,
25414
+ /** Candidate models per device in one run. */
25415
+ maxModelsPerDevice: 6
25416
+ };
25417
+ /** The two measurements a run can make. */
25418
+ var NodeBenchmarkPhaseSchema = _enum(["device", "pipeline"]);
25419
+ var NodeBenchmarkDevicePlanSchema = object({
25420
+ /** `<backend>:<device>` — `openvino:npu`, `coreml:all`, `cpu`. */
25421
+ deviceKey: string().min(1),
25422
+ /**
25423
+ * Root detector candidates for the `device` measurement, in the order
25424
+ * measured. The FIRST is the one the `pipeline` measurement runs.
25425
+ */
25426
+ modelIds: array(string().min(1)).min(1).max(NODE_BENCHMARK_DEFAULTS.maxModelsPerDevice)
25427
+ });
25428
+ /** What the operator confirmed. */
25429
+ var NodeBenchmarkPlanSchema = object({
25430
+ nodeId: string().min(1),
25431
+ devices: array(NodeBenchmarkDevicePlanSchema).min(1),
25432
+ /** Which measurements run. At least one. */
25433
+ phases: array(NodeBenchmarkPhaseSchema).min(1).default(["device", "pipeline"]),
25434
+ /**
25435
+ * Detail steps (catalog step ids under the root: faces, plates,
25436
+ * classifiers, CLIP…) the `pipeline` measurement enables. The root
25437
+ * detector always runs.
25438
+ */
25439
+ steps: array(string().min(1)).default([]),
25440
+ /** Offered rate of one stream / session. */
25441
+ fpsPerStream: number().int().min(1).max(30).default(NODE_BENCHMARK_DEFAULTS.fpsPerStream),
25442
+ /** Hard deadline: the mode ends and the cluster is restored when it passes. */
25443
+ budgetMinutes: number().int().min(NODE_BENCHMARK_DEFAULTS.minBudgetMinutes).max(NODE_BENCHMARK_DEFAULTS.maxBudgetMinutes).default(NODE_BENCHMARK_DEFAULTS.budgetMinutes),
25444
+ /** Keep the models the run downloaded (default: delete what was not installed before). */
25445
+ keepDownloadedModels: boolean().default(false),
25446
+ /** Start although the other nodes' capacity does not cover the sessions running now. */
25447
+ acceptInsufficientHeadroom: boolean().default(false)
25448
+ });
25449
+ var NodeBenchmarkRefusalSchema = object({
25450
+ kind: _enum([
25451
+ "benchmark-active",
25452
+ "node-offline",
25453
+ "unknown-device",
25454
+ "no-phase",
25455
+ "insufficient-headroom"
25456
+ ]),
25457
+ detail: string(),
25458
+ overridable: boolean()
25459
+ });
25460
+ /** A camera whose detection leaves the node for the run. */
25461
+ var NodeBenchmarkMovingCameraSchema = object({
25462
+ deviceId: number(),
25463
+ /** Placed on the node now (a standing attach or a running session). */
25464
+ placedOnNode: boolean(),
25465
+ /** A node pin naming this node, ignored for the run. */
25466
+ pinnedToNode: boolean()
25467
+ });
25468
+ /** A camera that cannot leave: no other node can obtain its frames. */
25469
+ var NodeBenchmarkStayingCameraSchema = object({
25470
+ deviceId: number(),
25471
+ reason: literal("only-frame-source")
25472
+ });
25473
+ var NodeBenchmarkPreflightSchema = object({
25474
+ nodeId: string(),
25475
+ online: boolean(),
25476
+ moving: array(NodeBenchmarkMovingCameraSchema).readonly(),
25477
+ /** Keep running on the node during the run; the result is flagged contaminated. */
25478
+ staying: array(NodeBenchmarkStayingCameraSchema).readonly(),
25479
+ estimatedDurationMs: number(),
25480
+ /** The run ends and the cluster is restored at the latest after this long. */
25481
+ budgetMs: number(),
25482
+ phases: array(NodeBenchmarkPhaseSchema).readonly(),
25483
+ steps: array(string()).readonly(),
25484
+ devices: array(NodeBenchmarkDevicePlanSchema).readonly(),
25485
+ /** Parallel sessions the cluster runs now, and what the other nodes can carry. */
25486
+ headroom: object({
25487
+ sessionsNow: number(),
25488
+ otherNodesCapacitySessions: number().nullable()
25489
+ }),
25490
+ refusals: array(NodeBenchmarkRefusalSchema).readonly(),
25491
+ canStart: boolean()
25492
+ });
25493
+ /** Where the measuring runner is. */
25494
+ var NodeBenchProgressSchema = object({
25495
+ phase: _enum([
25496
+ "preparing",
25497
+ "device",
25498
+ "pipeline",
25499
+ "cleanup"
25500
+ ]),
25501
+ deviceKey: string().nullable(),
25502
+ modelId: string().nullable(),
25503
+ /** Streams (device) or sessions (pipeline) of the step running now. */
25504
+ load: number().nullable(),
25505
+ cellsDone: number(),
25506
+ cellsTotal: number(),
25507
+ message: string()
25508
+ });
25509
+ /** What limited a ramp. `none` = the ramp ran out of steps still passing. */
25510
+ var NodeBenchLimitSchema = _enum([
25511
+ "p95",
25512
+ "drops",
25513
+ "errors",
25514
+ "stall",
25515
+ "cpu",
25516
+ "ram",
25517
+ "none"
25518
+ ]);
25519
+ var NodeBenchRampStepSchema = object({
25520
+ load: number(),
25521
+ pass: boolean(),
25522
+ p95Ms: number(),
25523
+ dropRatio: number(),
25524
+ /** Completed frames per second over the accounted window. */
25525
+ fps: number(),
25526
+ cpuPct: number().nullable(),
25527
+ ramFreePct: number().nullable(),
25528
+ failReasons: array(string()).readonly()
25529
+ });
25530
+ var NodeBenchCellSchema = discriminatedUnion("phase", [object({
25531
+ phase: literal("device"),
25532
+ deviceKey: string(),
25533
+ modelId: string(),
25534
+ /** Single-stream latency (the K = 1 step). */
25535
+ p50Ms: number(),
25536
+ p95Ms: number(),
25537
+ p99Ms: number(),
25538
+ /** Frames per second sustained at the last passing step. */
25539
+ fps: number(),
25540
+ /** Streams at the camera rate the device carried inside the frame interval; 0 = not even one. */
25541
+ kMax: number(),
25542
+ limitedBy: NodeBenchLimitSchema,
25543
+ /** First call (model load + warm-up). */
25544
+ warmupMs: number(),
25545
+ ramp: array(NodeBenchRampStepSchema).readonly()
25546
+ }), object({
25547
+ phase: literal("pipeline"),
25548
+ deviceKey: string(),
25549
+ modelId: string(),
25550
+ steps: array(string()).readonly(),
25551
+ /** Parallel sessions at the camera rate the node carried; 0 = not even one. */
25552
+ maxSessions: number(),
25553
+ limitedBy: NodeBenchLimitSchema,
25554
+ /** Detail steps that produced at least one result on the clip — a step that never fired measured nothing. */
25555
+ stepsFired: array(string()).readonly(),
25556
+ warmupMs: number(),
25557
+ ramp: array(NodeBenchRampStepSchema).readonly()
25558
+ })]);
25559
+ /**
25560
+ * What a result was measured ON. A result whose fingerprint no longer matches
25561
+ * the node no longer beats the table.
25562
+ */
25563
+ var NodeBenchFingerprintSchema = object({
25564
+ pipelineVersion: string().nullable(),
25565
+ cpuModel: string().nullable(),
25566
+ ramGb: number().nullable(),
25567
+ os: string().nullable(),
25568
+ /** Per device: the pool the cells ran on (runtime + tuning). */
25569
+ pools: record(string(), object({
25570
+ runtime: string(),
25571
+ numWorkers: number(),
25572
+ concurrency: number(),
25573
+ batchMode: string()
25574
+ })).default({})
25575
+ });
25576
+ /** The frames the run used. */
25577
+ var NodeBenchClipSchema = object({
25578
+ /** `camstack-bench-v1` or `reference-images` (the fallback when the clip is not reachable). */
25579
+ id: string(),
25580
+ revision: string().nullable(),
25581
+ frames: number(),
25582
+ width: number(),
25583
+ height: number()
25584
+ });
25585
+ var NodeBenchRunnerInputSchema = object({
25586
+ runId: string().min(1),
25587
+ devices: array(NodeBenchmarkDevicePlanSchema).min(1),
25588
+ phases: array(NodeBenchmarkPhaseSchema).min(1),
25589
+ /** The full detail step tree root for the `pipeline` measurement is built on the node from these ids. */
25590
+ steps: array(string()).default([]),
25591
+ fpsPerStream: number().int().min(1).max(30),
25592
+ /** The runner stops on its own past this instant, whatever the hub does. */
25593
+ deadlineAtMs: number(),
25594
+ settleSec: number().min(0).max(60).default(NODE_BENCHMARK_DEFAULTS.settleSec),
25595
+ measureSec: number().min(2).max(300).default(NODE_BENCHMARK_DEFAULTS.measureSec),
25596
+ keepDownloadedModels: boolean().default(false)
25597
+ });
25598
+ var NodeBenchRunnerStateSchema = _enum([
25599
+ "running",
25600
+ "done",
25601
+ "failed",
25602
+ "aborted"
25603
+ ]);
25604
+ var NodeBenchRunnerStatusSchema = object({
25605
+ runId: string(),
25606
+ nodeId: string(),
25607
+ state: NodeBenchRunnerStateSchema,
25608
+ progress: NodeBenchProgressSchema.nullable(),
25609
+ /** Every finished cell so far — a run stopped half way keeps what it measured. */
25610
+ cells: array(NodeBenchCellSchema).readonly(),
25611
+ fingerprint: NodeBenchFingerprintSchema.nullable(),
25612
+ clip: NodeBenchClipSchema.nullable(),
25613
+ /** Cameras seen running on the node during the run (they share its pools). */
25614
+ activeCameraIds: array(number()).readonly(),
25615
+ /** Models the run downloaded and then deleted (not installed before). */
25616
+ deletedModels: array(string()).readonly(),
25617
+ error: string().nullable(),
25618
+ startedAtMs: number(),
25619
+ finishedAtMs: number().nullable()
25620
+ });
25621
+ var NodeBenchmarkStateSchema = _enum([
25622
+ "draining",
25623
+ "measuring",
25624
+ "restoring",
25625
+ "done",
25626
+ "failed",
25627
+ "aborted"
25628
+ ]);
25629
+ /** Why a run ended. */
25630
+ var NodeBenchmarkEndReasonSchema = _enum([
25631
+ "completed",
25632
+ "operator-abort",
25633
+ "deadline",
25634
+ "node-lost",
25635
+ "runner-lost",
25636
+ "hub-restart",
25637
+ "drain-timeout",
25638
+ "failed"
25639
+ ]);
25640
+ var NodeBenchmarkRunSchema = object({
25641
+ runId: string(),
25642
+ nodeId: string(),
25643
+ state: NodeBenchmarkStateSchema,
25644
+ plan: NodeBenchmarkPlanSchema,
25645
+ startedAtMs: number(),
25646
+ deadlineAtMs: number(),
25647
+ finishedAtMs: number().nullable(),
25648
+ endReason: NodeBenchmarkEndReasonSchema.nullable(),
25649
+ error: string().nullable(),
25650
+ /** Cameras moved off the node for the run. */
25651
+ moved: array(number()).readonly(),
25652
+ /** Cameras that stayed (their only frame source is the node). */
25653
+ staying: array(number()).readonly(),
25654
+ /** Something else ran on the node's pools during the run. */
25655
+ contaminated: boolean(),
25656
+ progress: NodeBenchProgressSchema.nullable(),
25657
+ resultIds: array(string()).readonly()
25658
+ });
25659
+ /** `getNodeBenchmarkStatus`: the active run (or the last one), and whether benchmark mode is on. */
25660
+ var NodeBenchmarkStatusSchema = object({
25661
+ /** The node the cluster is in benchmark mode for; null = none. */
25662
+ modeNodeId: string().nullable(),
25663
+ run: NodeBenchmarkRunSchema.nullable()
25664
+ });
25665
+ /**
25666
+ * One stored measurement — the only authority Auto tune and the automatic
25667
+ * shares read measured capacity from. Written by the orchestrator when a run
25668
+ * ends, never by anyone else.
25669
+ */
25670
+ var NodeBenchmarkResultSchema = object({
25671
+ id: string(),
25672
+ runId: string(),
25673
+ nodeId: string(),
25674
+ cell: NodeBenchCellSchema,
25675
+ fpsPerStream: number(),
25676
+ fingerprint: NodeBenchFingerprintSchema.nullable(),
25677
+ clip: NodeBenchClipSchema.nullable(),
25678
+ /** Other work shared the node's pools (a camera that could not move, or the hub's own duties). */
25679
+ contaminated: boolean(),
25680
+ stayingCameras: array(number()).readonly(),
25681
+ /** The run ended early; the cell itself completed. */
25682
+ partialRun: boolean(),
25683
+ measuredAtMs: number()
25684
+ });
25685
+ var ListNodeBenchmarkResultsInputSchema = object({
25686
+ nodeId: string().optional(),
25687
+ deviceKey: string().optional()
25688
+ });
25689
+ /** A result with its standing today: does it still beat the table? */
25690
+ var NodeBenchmarkResultViewSchema = NodeBenchmarkResultSchema.extend({
25691
+ /** `fresh` beats the table; `stale` falls back to it; `superseded` = a newer row covers the same cell. */
25692
+ standing: _enum([
25693
+ "fresh",
25694
+ "stale",
25695
+ "superseded"
25696
+ ]),
25697
+ staleWhy: _enum([
25698
+ "age",
25699
+ "runtime",
25700
+ "pool-tuning"
25701
+ ]).nullable()
25702
+ });
25703
+ object({
25704
+ runId: string(),
25705
+ nodeId: string(),
25706
+ startedAtMs: number(),
25707
+ deadlineAtMs: number(),
25708
+ plan: NodeBenchmarkPlanSchema,
25709
+ moved: array(number()).readonly(),
25710
+ staying: array(number()).readonly()
25711
+ });
25712
+ /** Candidate detectors per device, for the plan editor. */
25713
+ var NodeBenchmarkCandidatesSchema = object({
25714
+ nodeId: string(),
25715
+ reachable: boolean(),
25716
+ devices: array(object({
25717
+ deviceKey: string(),
25718
+ enabled: boolean(),
25719
+ available: boolean(),
25720
+ /** Ordered: what Auto tune would pick first, then the rest of the family by accuracy. */
25721
+ suggested: array(string()).readonly(),
25722
+ /** Every root detector the device has a build for. */
25723
+ all: array(string()).readonly(),
25724
+ /** The model the device runs now, when pinned. */
25725
+ currentModelId: string().nullable()
25726
+ })).readonly(),
25727
+ /** Detail steps the node's catalog offers under the root (for the `pipeline` measurement). */
25728
+ steps: array(object({
25729
+ id: string(),
25730
+ name: string(),
25731
+ slot: string()
25732
+ })).readonly()
25733
+ });
24252
25734
  object({
24253
25735
  activeCameras: number(),
24254
25736
  throttledCameras: number(),
@@ -25337,7 +26819,16 @@ method(RunnerCameraConfigSchema, object({ success: literal(true) }), { kind: "mu
25337
26819
  }), ParkedTrackFrameSchema.nullable()), method(object({
25338
26820
  deviceId: number(),
25339
26821
  trackId: string()
25340
- }), object({ released: number().int().nonnegative() }), { kind: "mutation" });
26822
+ }), object({ released: number().int().nonnegative() }), { kind: "mutation" }), method(NodeBenchRunnerInputSchema, object({
26823
+ accepted: literal(true),
26824
+ runId: string()
26825
+ }), {
26826
+ kind: "mutation",
26827
+ auth: "admin"
26828
+ }), method(object({ runId: string() }), NodeBenchRunnerStatusSchema.nullable(), { auth: "admin" }), method(object({ runId: string() }), object({ aborted: boolean() }), {
26829
+ kind: "mutation",
26830
+ auth: "admin"
26831
+ });
25341
26832
  var CameraPipelineConfigSchema = object({
25342
26833
  engine: PipelineEngineChoiceSchema.optional(),
25343
26834
  steps: array(PipelineStepInputSchema).readonly(),
@@ -25976,6 +27467,21 @@ method(object({
25976
27467
  }), method(PlacementStatsInputSchema, PlacementStatsSchema, { auth: "admin" }), method(SuggestSharesInputSchema, SuggestSharesResultSchema, { auth: "admin" }), method(_void(), EffectiveSharesSchema, { auth: "admin" }), method(SetShareSourceInputSchema, object({ success: literal(true) }), {
25977
27468
  kind: "mutation",
25978
27469
  auth: "admin"
27470
+ }), method(NodeBenchmarkPlanSchema, NodeBenchmarkPreflightSchema, { auth: "admin" }), method(NodeBenchmarkPlanSchema, discriminatedUnion("kind", [object({
27471
+ kind: literal("started"),
27472
+ runId: string()
27473
+ }), object({
27474
+ kind: literal("refused"),
27475
+ preflight: NodeBenchmarkPreflightSchema
27476
+ })]), {
27477
+ kind: "mutation",
27478
+ auth: "admin"
27479
+ }), method(_void(), NodeBenchmarkStatusSchema, { auth: "admin" }), method(object({ runId: string() }), object({ aborted: boolean() }), {
27480
+ kind: "mutation",
27481
+ auth: "admin"
27482
+ }), method(object({ nodeId: string() }), NodeBenchmarkCandidatesSchema, { auth: "admin" }), method(ListNodeBenchmarkResultsInputSchema, array(NodeBenchmarkResultViewSchema).readonly(), { auth: "admin" }), method(object({ id: string() }), object({ deleted: boolean() }), {
27483
+ kind: "mutation",
27484
+ auth: "admin"
25979
27485
  }), method(object({ deviceId: number() }), CameraPipelineSettingsSchema.nullable()), method(object({
25980
27486
  deviceId: number(),
25981
27487
  addonId: string(),
@@ -31089,6 +32595,9 @@ var CreateIntegrationInputSchema = object({
31089
32595
  enabled: boolean().optional(),
31090
32596
  info: record(string(), unknown()).optional(),
31091
32597
  settings: record(string(), unknown()).optional(),
32598
+ /** Keys of `settings` the form's schema declares secret (by type) — kept in
32599
+ * the keychain, not the table (D787). */
32600
+ secretKeys: array(string()).optional(),
31092
32601
  skipRestart: boolean().optional()
31093
32602
  });
31094
32603
  var UpdateIntegrationInputSchema = object({
@@ -31112,7 +32621,9 @@ method(_void(), array(IntegrationWithStateSchema)), method(object({ id: string()
31112
32621
  auth: "admin"
31113
32622
  }), method(object({ id: string() }), record(string(), unknown()), { auth: "admin" }), method(object({
31114
32623
  id: string(),
31115
- settings: record(string(), unknown())
32624
+ settings: record(string(), unknown()),
32625
+ /** Keys the form's schema declares secret (by type) — keychain-stored (D787). */
32626
+ secretKeys: array(string()).optional()
31116
32627
  }), object({ success: boolean() }), {
31117
32628
  kind: "mutation",
31118
32629
  auth: "admin"
@@ -39840,6 +41351,90 @@ Object.freeze({
39840
41351
  addonId: null,
39841
41352
  access: "create"
39842
41353
  },
41354
+ "keychain.delete": {
41355
+ capName: "keychain",
41356
+ capScope: "system",
41357
+ addonId: null,
41358
+ access: "delete"
41359
+ },
41360
+ "keychain.getState": {
41361
+ capName: "keychain",
41362
+ capScope: "system",
41363
+ addonId: null,
41364
+ access: "view"
41365
+ },
41366
+ "keychain.listMeta": {
41367
+ capName: "keychain",
41368
+ capScope: "system",
41369
+ addonId: null,
41370
+ access: "view"
41371
+ },
41372
+ "keychain.put": {
41373
+ capName: "keychain",
41374
+ capScope: "system",
41375
+ addonId: null,
41376
+ access: "create"
41377
+ },
41378
+ "keychain.resolve": {
41379
+ capName: "keychain",
41380
+ capScope: "system",
41381
+ addonId: null,
41382
+ access: "view"
41383
+ },
41384
+ "keychainAdmin.deleteOrphans": {
41385
+ capName: "keychain-admin",
41386
+ capScope: "system",
41387
+ addonId: null,
41388
+ access: "delete"
41389
+ },
41390
+ "keychainAdmin.downloadRecoveryKey": {
41391
+ capName: "keychain-admin",
41392
+ capScope: "system",
41393
+ addonId: null,
41394
+ access: "create"
41395
+ },
41396
+ "keychainAdmin.listAudit": {
41397
+ capName: "keychain-admin",
41398
+ capScope: "system",
41399
+ addonId: null,
41400
+ access: "view"
41401
+ },
41402
+ "keychainAdmin.listSecrets": {
41403
+ capName: "keychain-admin",
41404
+ capScope: "system",
41405
+ addonId: null,
41406
+ access: "view"
41407
+ },
41408
+ "keychainAdmin.purgeRetiredKeys": {
41409
+ capName: "keychain-admin",
41410
+ capScope: "system",
41411
+ addonId: null,
41412
+ access: "delete"
41413
+ },
41414
+ "keychainAdmin.resetKeychain": {
41415
+ capName: "keychain-admin",
41416
+ capScope: "system",
41417
+ addonId: null,
41418
+ access: "delete"
41419
+ },
41420
+ "keychainAdmin.reveal": {
41421
+ capName: "keychain-admin",
41422
+ capScope: "system",
41423
+ addonId: null,
41424
+ access: "create"
41425
+ },
41426
+ "keychainAdmin.rotateMasterKey": {
41427
+ capName: "keychain-admin",
41428
+ capScope: "system",
41429
+ addonId: null,
41430
+ access: "create"
41431
+ },
41432
+ "keychainAdmin.status": {
41433
+ capName: "keychain-admin",
41434
+ capScope: "system",
41435
+ addonId: null,
41436
+ access: "view"
41437
+ },
39843
41438
  "lawnMowerControl.dock": {
39844
41439
  capName: "lawn-mower-control",
39845
41440
  capScope: "device",
@@ -41214,6 +42809,18 @@ Object.freeze({
41214
42809
  addonId: null,
41215
42810
  access: "create"
41216
42811
  },
42812
+ "pipelineAnalytics.addRetrainFrameFromRecording": {
42813
+ capName: "pipeline-analytics",
42814
+ capScope: "device",
42815
+ addonId: null,
42816
+ access: "create"
42817
+ },
42818
+ "pipelineAnalytics.addRetrainFramesToCollection": {
42819
+ capName: "pipeline-analytics",
42820
+ capScope: "device",
42821
+ addonId: null,
42822
+ access: "create"
42823
+ },
41217
42824
  "pipelineAnalytics.applyDeviceSettingsPatch": {
41218
42825
  capName: "pipeline-analytics",
41219
42826
  capScope: "device",
@@ -41262,12 +42869,24 @@ Object.freeze({
41262
42869
  addonId: null,
41263
42870
  access: "view"
41264
42871
  },
42872
+ "pipelineAnalytics.createRetrainCollection": {
42873
+ capName: "pipeline-analytics",
42874
+ capScope: "device",
42875
+ addonId: null,
42876
+ access: "create"
42877
+ },
41265
42878
  "pipelineAnalytics.deleteDeviceEvents": {
41266
42879
  capName: "pipeline-analytics",
41267
42880
  capScope: "device",
41268
42881
  addonId: null,
41269
42882
  access: "delete"
41270
42883
  },
42884
+ "pipelineAnalytics.deleteRetrainCollection": {
42885
+ capName: "pipeline-analytics",
42886
+ capScope: "device",
42887
+ addonId: null,
42888
+ access: "delete"
42889
+ },
41271
42890
  "pipelineAnalytics.deleteTracks": {
41272
42891
  capName: "pipeline-analytics",
41273
42892
  capScope: "device",
@@ -41472,6 +43091,24 @@ Object.freeze({
41472
43091
  addonId: null,
41473
43092
  access: "view"
41474
43093
  },
43094
+ "pipelineAnalytics.listRetrainAssistProfiles": {
43095
+ capName: "pipeline-analytics",
43096
+ capScope: "device",
43097
+ addonId: null,
43098
+ access: "view"
43099
+ },
43100
+ "pipelineAnalytics.listRetrainCollectionFrames": {
43101
+ capName: "pipeline-analytics",
43102
+ capScope: "device",
43103
+ addonId: null,
43104
+ access: "view"
43105
+ },
43106
+ "pipelineAnalytics.listRetrainCollections": {
43107
+ capName: "pipeline-analytics",
43108
+ capScope: "device",
43109
+ addonId: null,
43110
+ access: "view"
43111
+ },
41475
43112
  "pipelineAnalytics.listRetrainFrames": {
41476
43113
  capName: "pipeline-analytics",
41477
43114
  capScope: "device",
@@ -41520,6 +43157,12 @@ Object.freeze({
41520
43157
  addonId: null,
41521
43158
  access: "create"
41522
43159
  },
43160
+ "pipelineAnalytics.proposeRetrainAnnotationsWithLlm": {
43161
+ capName: "pipeline-analytics",
43162
+ capScope: "device",
43163
+ addonId: null,
43164
+ access: "create"
43165
+ },
41523
43166
  "pipelineAnalytics.pruneEvents": {
41524
43167
  capName: "pipeline-analytics",
41525
43168
  capScope: "device",
@@ -41574,6 +43217,18 @@ Object.freeze({
41574
43217
  addonId: null,
41575
43218
  access: "create"
41576
43219
  },
43220
+ "pipelineAnalytics.removeRetrainFrameFromCollection": {
43221
+ capName: "pipeline-analytics",
43222
+ capScope: "device",
43223
+ addonId: null,
43224
+ access: "delete"
43225
+ },
43226
+ "pipelineAnalytics.renameRetrainCollection": {
43227
+ capName: "pipeline-analytics",
43228
+ capScope: "device",
43229
+ addonId: null,
43230
+ access: "create"
43231
+ },
41577
43232
  "pipelineAnalytics.restageRetrainTrack": {
41578
43233
  capName: "pipeline-analytics",
41579
43234
  capScope: "device",
@@ -41862,6 +43517,12 @@ Object.freeze({
41862
43517
  addonId: null,
41863
43518
  access: "view"
41864
43519
  },
43520
+ "pipelineOrchestrator.abortNodeBenchmark": {
43521
+ capName: "pipeline-orchestrator",
43522
+ capScope: "system",
43523
+ addonId: null,
43524
+ access: "create"
43525
+ },
41865
43526
  "pipelineOrchestrator.applyAutoTune": {
41866
43527
  capName: "pipeline-orchestrator",
41867
43528
  capScope: "system",
@@ -41886,6 +43547,12 @@ Object.freeze({
41886
43547
  addonId: null,
41887
43548
  access: "create"
41888
43549
  },
43550
+ "pipelineOrchestrator.deleteNodeBenchmarkResult": {
43551
+ capName: "pipeline-orchestrator",
43552
+ capScope: "system",
43553
+ addonId: null,
43554
+ access: "delete"
43555
+ },
41889
43556
  "pipelineOrchestrator.getAgentLoad": {
41890
43557
  capName: "pipeline-orchestrator",
41891
43558
  capScope: "system",
@@ -41994,6 +43661,24 @@ Object.freeze({
41994
43661
  addonId: null,
41995
43662
  access: "view"
41996
43663
  },
43664
+ "pipelineOrchestrator.getNodeBenchmarkCandidates": {
43665
+ capName: "pipeline-orchestrator",
43666
+ capScope: "system",
43667
+ addonId: null,
43668
+ access: "view"
43669
+ },
43670
+ "pipelineOrchestrator.getNodeBenchmarkPreflight": {
43671
+ capName: "pipeline-orchestrator",
43672
+ capScope: "system",
43673
+ addonId: null,
43674
+ access: "view"
43675
+ },
43676
+ "pipelineOrchestrator.getNodeBenchmarkStatus": {
43677
+ capName: "pipeline-orchestrator",
43678
+ capScope: "system",
43679
+ addonId: null,
43680
+ access: "view"
43681
+ },
41997
43682
  "pipelineOrchestrator.getNodeInferenceDevices": {
41998
43683
  capName: "pipeline-orchestrator",
41999
43684
  capScope: "system",
@@ -42036,6 +43721,12 @@ Object.freeze({
42036
43721
  addonId: null,
42037
43722
  access: "view"
42038
43723
  },
43724
+ "pipelineOrchestrator.listNodeBenchmarkResults": {
43725
+ capName: "pipeline-orchestrator",
43726
+ capScope: "system",
43727
+ addonId: null,
43728
+ access: "view"
43729
+ },
42039
43730
  "pipelineOrchestrator.pauseForStorageMigration": {
42040
43731
  capName: "pipeline-orchestrator",
42041
43732
  capScope: "system",
@@ -42180,6 +43871,12 @@ Object.freeze({
42180
43871
  addonId: null,
42181
43872
  access: "create"
42182
43873
  },
43874
+ "pipelineOrchestrator.startNodeBenchmark": {
43875
+ capName: "pipeline-orchestrator",
43876
+ capScope: "system",
43877
+ addonId: null,
43878
+ access: "create"
43879
+ },
42183
43880
  "pipelineOrchestrator.suggestShares": {
42184
43881
  capName: "pipeline-orchestrator",
42185
43882
  capScope: "system",
@@ -42198,6 +43895,12 @@ Object.freeze({
42198
43895
  addonId: null,
42199
43896
  access: "create"
42200
43897
  },
43898
+ "pipelineRunner.abortNodeBench": {
43899
+ capName: "pipeline-runner",
43900
+ capScope: "system",
43901
+ addonId: null,
43902
+ access: "create"
43903
+ },
42201
43904
  "pipelineRunner.attachCamera": {
42202
43905
  capName: "pipeline-runner",
42203
43906
  capScope: "system",
@@ -42246,6 +43949,12 @@ Object.freeze({
42246
43949
  addonId: null,
42247
43950
  access: "view"
42248
43951
  },
43952
+ "pipelineRunner.getNodeBenchStatus": {
43953
+ capName: "pipeline-runner",
43954
+ capScope: "system",
43955
+ addonId: null,
43956
+ access: "view"
43957
+ },
42249
43958
  "pipelineRunner.getParkedTrackFrame": {
42250
43959
  capName: "pipeline-runner",
42251
43960
  capScope: "system",
@@ -42288,6 +43997,12 @@ Object.freeze({
42288
43997
  addonId: null,
42289
43998
  access: "create"
42290
43999
  },
44000
+ "pipelineRunner.startNodeBench": {
44001
+ capName: "pipeline-runner",
44002
+ capScope: "system",
44003
+ addonId: null,
44004
+ access: "create"
44005
+ },
42291
44006
  "plateGallery.assignPlate": {
42292
44007
  capName: "plate-gallery",
42293
44008
  capScope: "system",
@@ -47217,6 +48932,11 @@ Object.freeze({
47217
48932
  form: "single",
47218
48933
  optional: false
47219
48934
  }],
48935
+ "pipelineAnalytics.addRetrainFrameFromRecording": [{
48936
+ name: "deviceId",
48937
+ form: "single",
48938
+ optional: false
48939
+ }],
47220
48940
  "pipelineAnalytics.applyDeviceSettingsPatch": [{
47221
48941
  name: "deviceId",
47222
48942
  form: "single",
@@ -47407,6 +49127,11 @@ Object.freeze({
47407
49127
  form: "single",
47408
49128
  optional: false
47409
49129
  }],
49130
+ "pipelineAnalytics.proposeRetrainAnnotationsWithLlm": [{
49131
+ name: "deviceId",
49132
+ form: "single",
49133
+ optional: false
49134
+ }],
47410
49135
  "pipelineAnalytics.pruneEventsBefore": [{
47411
49136
  name: "deviceId",
47412
49137
  form: "single",
@@ -50818,10 +52543,12 @@ var BRIGHTNESS_CONTROLLER = {
50818
52543
  };
50819
52544
  /**
50820
52545
  * PTZ directional toggle — one `Alexa.ToggleController` instance per
50821
- * pan/tilt direction. Each is MOMENTARY: turning the toggle ON pulses
50822
- * a `continuousMove({direction})` for `ptzPulseMs` then `stop`, and
50823
- * the toggle auto-resets to OFF (handler returns the OFF state in
50824
- * `context.properties`). Alexa renders one row per instance in the
52546
+ * pan/tilt direction. Each is MOMENTARY: turning the toggle ON moves the
52547
+ * head ~1 s through the driver's own self-terminating `ptz.move` pulses
52548
+ * (`round(TARGET_TRAVEL_MS / getOptions().moveImpulseMs)` of them, one
52549
+ * when the impulse is unknown — see `handlers/ptz-travel.ts`; never
52550
+ * `continuousMove` / `stop`), and the toggle auto-resets to OFF (handler
52551
+ * returns the OFF state in `context.properties`). Alexa renders one row per instance in the
50825
52552
  * device detail; users can also say "Alexa, turn on Salone Pan Left".
50826
52553
  *
50827
52554
  * Instance ids match the directive routing in `ptz-direction.ts`.
@@ -52190,8 +53917,10 @@ var DetectionTracker = class {
52190
53917
  * (R4, D779).
52191
53918
  *
52192
53919
  * - `objectIdentifier`: "a UUID identifying a specific physical object" — one
52193
- * per pipeline track. A UUIDv5 of `<deviceId>:<trackId>` under this hub's
52194
- * namespace, so it is stable for the track's life and across restarts.
53920
+ * per pipeline track. Amazon types it "Version 4 UUID String", so it is
53921
+ * v4-shaped like the event id: a hash of `object|<deviceId>:<trackId>` under
53922
+ * this hub's namespace, stable for the track's life and across restarts.
53923
+ * (The first build sent a UUIDv5 here — D779 amendment.)
52195
53924
  * - `eventIdentifier`: Amazon requires a version-4 UUID per event in the
52196
53925
  * history. This skill posts ONE event per track, so the event id is derived
52197
53926
  * from the track too — a v4-shaped UUID whose 122 "random" bits are a
@@ -52218,10 +53947,6 @@ function stamp$1(bytes, version) {
52218
53947
  out[8] = (out[8] ?? 0) & 63 | 128;
52219
53948
  return out;
52220
53949
  }
52221
- /** RFC 4122 UUIDv5 (SHA-1, name-based). */
52222
- function uuidV5(namespace, name) {
52223
- return formatUuid(stamp$1((0, node_crypto.createHash)("sha1").update(uuidBytes(namespace)).update(Buffer.from(name, "utf8")).digest(), 5));
52224
- }
52225
53950
  /** A version-4-formatted UUID whose bits are a hash — see the file header. */
52226
53951
  function hashedUuidV4(namespace, name) {
52227
53952
  return formatUuid(stamp$1((0, node_crypto.createHash)("sha256").update(uuidBytes(namespace)).update(name, "utf8").digest(), 4));
@@ -52230,7 +53955,7 @@ function trackName(deviceId, trackId) {
52230
53955
  return `${deviceId}:${trackId}`;
52231
53956
  }
52232
53957
  function objectIdentifierFor(namespace, deviceId, trackId) {
52233
- return uuidV5(namespace, trackName(deviceId, trackId));
53958
+ return hashedUuidV4(namespace, `object|${trackName(deviceId, trackId)}`);
52234
53959
  }
52235
53960
  /** One event per track AND class: a track re-classified person → package is a
52236
53961
  * second event about the same object. */
@@ -52729,18 +54454,80 @@ async function handlePower(header, endpointRaw, deps, _callerIdentity) {
52729
54454
  };
52730
54455
  }
52731
54456
  //#endregion
52732
- //#region src/handlers/ptz-direction.ts
54457
+ //#region src/handlers/ptz-travel.ts
54458
+ /**
54459
+ * One Alexa PTZ voice command = ~1 s of head travel, built ONLY from the PTZ
54460
+ * cap's `ptz.move`.
54461
+ *
54462
+ * `move` is a self-terminating burst: the driver runs it for the pulse it
54463
+ * calibrated and stops the head itself, and reports that pulse as
54464
+ * `getOptions().moveImpulseMs` (ptz.cap.ts) — 200 reolink, 350 amcrest,
54465
+ * 500 hikvision, 1000 onvif. One pulse is too short a nudge for a voice
54466
+ * command, so the travel issues `round(TARGET_TRAVEL_MS / moveImpulseMs)` of
54467
+ * them back to back. There is no `continuousMove` / timer / `stop` here:
54468
+ * ONVIF does not implement `continuousMove`, and `move` needs no stop.
54469
+ *
54470
+ * Drivers differ in WHEN `move` resolves: hikvision awaits its own pulse,
54471
+ * reolink / amcrest / onvif return as soon as the burst has started. Each pulse
54472
+ * is awaited, then the remainder of its impulse is waited out, so both kinds
54473
+ * yield consecutive pulses rather than overlapping ones (which a driver would
54474
+ * collapse into one). An unknown impulse is a single `move`.
54475
+ */
54476
+ /** How far a voice command moves the head, in driver-pulse milliseconds. */
54477
+ var TARGET_TRAVEL_MS = 1e3;
54478
+ var realClock = {
54479
+ now: () => Date.now(),
54480
+ sleep: (ms) => new Promise((resolve) => setTimeout(resolve, ms))
54481
+ };
54482
+ /** `max(1, round(TARGET_TRAVEL_MS / moveImpulseMs))`; unknown impulse → 1. */
54483
+ function ptzTravelPulses(moveImpulseMs) {
54484
+ if (moveImpulseMs === null || !(moveImpulseMs > 0)) return 1;
54485
+ return Math.max(1, Math.round(TARGET_TRAVEL_MS / moveImpulseMs));
54486
+ }
54487
+ /** `getOptions().moveImpulseMs`, or `null` when unreported or unreadable. */
54488
+ async function readImpulse(ptz, deviceId) {
54489
+ try {
54490
+ const ms = (await ptz.getOptions.query({ deviceId })).moveImpulseMs;
54491
+ return typeof ms === "number" && ms > 0 ? ms : null;
54492
+ } catch {
54493
+ return null;
54494
+ }
54495
+ }
52733
54496
  /**
52734
- * `Alexa.ToggleController/{TurnOn,TurnOff}` handler — restricted to PTZ
52735
- * directional instances (`ptz.panLeft` / `ptz.panRight` / `ptz.tiltUp`
52736
- * / `ptz.tiltDown`). Mirrors the HAP momentary-switch pattern: every
52737
- * `TurnOn` pulses a `continuousMove({pan|tilt: ±1})` and schedules a
52738
- * `stop` after `ptzPulseMs`. The handler returns immediately with
52739
- * `toggleState=OFF` so Alexa reflects the momentary nature in its UI.
52740
- *
52741
- * `TurnOff` is a no-op (success response) — Alexa never delivers it in
52742
- * normal momentary usage, but accept it for resilience.
54497
+ * Runs the travel. REJECTS when the first `move` fails (nothing moved, the
54498
+ * caller answers with an error); a later failure stops the travel and is
54499
+ * returned in `error`, since the head has already moved.
52743
54500
  */
54501
+ async function runPtzTravel(ptz, deviceId, direction, clock = realClock) {
54502
+ const impulse = await readImpulse(ptz, deviceId);
54503
+ const pulses = ptzTravelPulses(impulse);
54504
+ for (let i = 0; i < pulses; i++) {
54505
+ const startedAt = clock.now();
54506
+ try {
54507
+ await ptz.move.mutate({
54508
+ deviceId,
54509
+ ...direction
54510
+ });
54511
+ } catch (err) {
54512
+ if (i === 0) throw err;
54513
+ return {
54514
+ pulses,
54515
+ issued: i,
54516
+ error: err instanceof Error ? err : new Error(String(err))
54517
+ };
54518
+ }
54519
+ if (!(i === pulses - 1) && impulse !== null) {
54520
+ const remaining = impulse - (clock.now() - startedAt);
54521
+ if (remaining > 0) await clock.sleep(remaining);
54522
+ }
54523
+ }
54524
+ return {
54525
+ pulses,
54526
+ issued: pulses
54527
+ };
54528
+ }
54529
+ //#endregion
54530
+ //#region src/handlers/ptz-direction.ts
52744
54531
  var ToggleDirectiveSchema = object({
52745
54532
  header: object({
52746
54533
  namespace: literal("Alexa.ToggleController"),
@@ -52774,27 +54561,24 @@ async function handlePtzDirection(header, endpointRaw, deps, _callerIdentity) {
52774
54561
  const move = INSTANCE_TO_MOVE[instance];
52775
54562
  if (!move) return errorEnvelope(header, "INVALID_DIRECTIVE", `ToggleController instance not supported: ${instance}`);
52776
54563
  const api = deps.ctx.api;
54564
+ const deviceId = parsedId.deviceId;
52777
54565
  try {
52778
- await api.ptz.continuousMove.mutate({
52779
- deviceId: parsedId.deviceId,
52780
- ...move
52781
- });
52782
- setTimeout(() => {
52783
- api.ptz.stop.mutate({ deviceId: parsedId.deviceId }).catch((err) => {
52784
- deps.logger.debug("alexa ptz-direction: stop after pulse failed (non-fatal)", { meta: {
52785
- deviceId: parsedId.deviceId,
52786
- instance,
52787
- error: err instanceof Error ? err.message : String(err)
52788
- } });
52789
- });
52790
- }, deps.ptzPulseMs);
54566
+ const travel = await runPtzTravel(api.ptz, deviceId, move);
54567
+ if (travel.error) deps.logger.warn("alexa ptz-direction: ptz.move failed mid-travel", { meta: {
54568
+ deviceId,
54569
+ instance,
54570
+ issued: travel.issued,
54571
+ pulses: travel.pulses,
54572
+ error: travel.error.message
54573
+ } });
52791
54574
  } catch (err) {
52792
- deps.logger.warn("alexa ptz-direction: continuousMove failed", { meta: {
52793
- deviceId: parsedId.deviceId,
54575
+ const message = err instanceof Error ? err.message : String(err);
54576
+ deps.logger.warn("alexa ptz-direction: ptz.move failed", { meta: {
54577
+ deviceId,
52794
54578
  instance,
52795
- error: err instanceof Error ? err.message : String(err)
54579
+ error: message
52796
54580
  } });
52797
- return errorEnvelope(header, "INTERNAL_ERROR", `ptz.continuousMove failed: ${err instanceof Error ? err.message : String(err)}`);
54581
+ return errorEnvelope(header, "INTERNAL_ERROR", `ptz.move failed: ${message}`);
52798
54582
  }
52799
54583
  return successResponse(header, endpointId, "OFF", instance);
52800
54584
  }
@@ -52823,18 +54607,6 @@ function successResponse(header, endpointId, toggleState, instance) {
52823
54607
  }
52824
54608
  //#endregion
52825
54609
  //#region src/handlers/ptz-preset.ts
52826
- /**
52827
- * `Alexa.ModeController/SetMode` handler — dispatches three PTZ instances:
52828
- *
52829
- * `ptz.preset` — preset-recall. Decodes the preset name from the mode
52830
- * value and calls `ptz.goToPreset({deviceId, presetId})`.
52831
- *
52832
- * `ptz.pan` — momentary pan. `ptz.pan.left|right|center` issues a
52833
- * continuousMove pulse stopped on a timer; the dropdown reverts to
52834
- * `center` server-side so subsequent picks re-trigger the move.
52835
- *
52836
- * `ptz.tilt` — momentary tilt. Mirrors ptz.pan with up|down|center.
52837
- */
52838
54610
  var SetModeDirectiveSchema = object({
52839
54611
  header: object({
52840
54612
  namespace: literal("Alexa.ModeController"),
@@ -52845,7 +54617,6 @@ var SetModeDirectiveSchema = object({
52845
54617
  payload: SetModePayloadSchema
52846
54618
  });
52847
54619
  var PTZ_PRESET_MODE_PREFIX = "ptz.preset.";
52848
- var PTZ_DIRECTION_PULSE_MS = 1e3;
52849
54620
  var PTZ_PAN_MOVES = {
52850
54621
  "ptz.pan.left": { pan: -1 },
52851
54622
  "ptz.pan.right": { pan: 1 },
@@ -52877,29 +54648,28 @@ async function handleSetMode(header, endpointRaw, payloadRaw, deps, _callerIdent
52877
54648
  if (instance === "ptz.pan" || instance === "ptz.tilt") {
52878
54649
  const move = (instance === "ptz.pan" ? PTZ_PAN_MOVES : PTZ_TILT_MOVES)[mode];
52879
54650
  if (!move) return errorEnvelope(header, "INVALID_DIRECTIVE", `mode '${mode}' is not a valid ${instance} mode`);
52880
- if (Object.keys(move).length === 0) await api.ptz.stop.mutate({ deviceId: parsedId.deviceId }).catch((err) => {
52881
- deps.logger.debug("alexa ptz-mode: stop (center) failed (non-fatal)", { meta: {
52882
- deviceId: parsedId.deviceId,
52883
- instance,
52884
- error: err instanceof Error ? err.message : String(err)
52885
- } });
52886
- });
52887
- else try {
52888
- await api.ptz.continuousMove.mutate({
52889
- deviceId: parsedId.deviceId,
52890
- ...move
52891
- });
52892
- setTimeout(() => {
52893
- api.ptz.stop.mutate({ deviceId: parsedId.deviceId }).catch((err) => {
52894
- deps.logger.debug("alexa ptz-mode: stop after pulse failed (non-fatal)", { meta: {
52895
- deviceId: parsedId.deviceId,
52896
- instance,
52897
- error: err instanceof Error ? err.message : String(err)
52898
- } });
52899
- });
52900
- }, PTZ_DIRECTION_PULSE_MS);
52901
- } catch (err) {
52902
- return errorEnvelope(header, "INTERNAL_ERROR", `ptz.continuousMove failed: ${err instanceof Error ? err.message : String(err)}`);
54651
+ if (Object.keys(move).length > 0) {
54652
+ const deviceId = parsedId.deviceId;
54653
+ try {
54654
+ const travel = await runPtzTravel(api.ptz, deviceId, move);
54655
+ if (travel.error) deps.logger.warn("alexa ptz-mode: ptz.move failed mid-travel", { meta: {
54656
+ deviceId,
54657
+ instance,
54658
+ mode,
54659
+ issued: travel.issued,
54660
+ pulses: travel.pulses,
54661
+ error: travel.error.message
54662
+ } });
54663
+ } catch (err) {
54664
+ const message = err instanceof Error ? err.message : String(err);
54665
+ deps.logger.warn("alexa ptz-mode: ptz.move failed", { meta: {
54666
+ deviceId,
54667
+ instance,
54668
+ mode,
54669
+ error: message
54670
+ } });
54671
+ return errorEnvelope(header, "INTERNAL_ERROR", `ptz.move failed: ${message}`);
54672
+ }
52903
54673
  }
52904
54674
  return modeSuccessResponse(header, endpointId, instance, instance === "ptz.pan" ? "ptz.pan.center" : "ptz.tilt.center");
52905
54675
  }
@@ -53201,6 +54971,7 @@ async function handleReportState(header, endpointRaw, deps, _callerIdentity) {
53201
54971
  });
53202
54972
  }
53203
54973
  } catch (err) {
54974
+ if (err instanceof ChildUnreachableError) return errorEnvelope(header, "ENDPOINT_UNREACHABLE", err.message);
53204
54975
  deps.logger.warn("alexa report-state: collection failed", { meta: {
53205
54976
  endpointId,
53206
54977
  error: err instanceof Error ? err.message : String(err)
@@ -53348,16 +55119,35 @@ async function collectAutotrackProperties(api, parentDeviceId, properties, timeO
53348
55119
  uncertaintyInMilliseconds: 0
53349
55120
  });
53350
55121
  }
55122
+ /** The child's `switch` cannot be read: answered `ENDPOINT_UNREACHABLE`. */
55123
+ var ChildUnreachableError = class extends Error {};
55124
+ /** One warning per child per window (a sleeping battery camera's accessories
55125
+ * are polled by Alexa for as long as it sleeps). */
55126
+ var CHILD_WARN_EVERY_MS = 10 * 6e4;
55127
+ var childWarnedAt = /* @__PURE__ */ new Map();
55128
+ function warnChildUnreadable(logger, childDeviceId, error) {
55129
+ const now = Date.now();
55130
+ const last = childWarnedAt.get(childDeviceId);
55131
+ if (last !== void 0 && now - last < CHILD_WARN_EVERY_MS) return;
55132
+ childWarnedAt.set(childDeviceId, now);
55133
+ logger.warn("alexa report-state: child accessory switch unreadable — answered ENDPOINT_UNREACHABLE", { meta: {
55134
+ childDeviceId,
55135
+ error,
55136
+ repeatsSuppressedForMs: CHILD_WARN_EVERY_MS
55137
+ } });
55138
+ }
53351
55139
  async function collectChildProperties(api, childDeviceId, properties, timeOfSample, logger) {
55140
+ let failure = null;
53352
55141
  const switchState = await api.switch.getStatus.query({ deviceId: childDeviceId }).catch((err) => {
53353
- logger.warn("alexa report-state: switch.getStatus FAILED — Alexa will show endpoint as \"unavailable\"", { meta: {
53354
- childDeviceId,
53355
- error: err instanceof Error ? err.message : String(err)
53356
- } });
55142
+ failure = err instanceof Error ? err.message : String(err);
53357
55143
  return null;
53358
55144
  });
53359
- if (switchState === null || switchState === void 0) logger.warn("alexa report-state: switch.getStatus returned no payload — surfacing as unavailable", { meta: { childDeviceId } });
53360
- else logger.info("alexa report-state: switch.getStatus payload", { meta: {
55145
+ if (switchState === null || switchState === void 0) {
55146
+ warnChildUnreadable(logger, childDeviceId, failure ?? "no payload");
55147
+ throw new ChildUnreachableError(`accessory ${childDeviceId} cannot be read right now`);
55148
+ }
55149
+ childWarnedAt.delete(childDeviceId);
55150
+ logger.debug("alexa report-state: switch.getStatus payload", { meta: {
53361
55151
  childDeviceId,
53362
55152
  payload: switchState
53363
55153
  } });
@@ -54178,44 +55968,84 @@ function refuse(reply, status, error) {
54178
55968
  reply.code(status).type("application/json").header("cache-control", "no-store").header("content-encoding", "identity");
54179
55969
  reply.send({ error });
54180
55970
  }
55971
+ function headerOf(headers, name) {
55972
+ for (const [key, value] of Object.entries(headers)) if (key.toLowerCase() === name) return value;
55973
+ }
55974
+ /**
55975
+ * Exactly one line per fetch, whatever the answer (D779 amendment): "did Amazon ever
55976
+ * fetch the image, and what did it get?" is otherwise unanswerable — a served
55977
+ * image used to log nothing. Never the signature, never the token.
55978
+ */
55979
+ function logFetch(deps, req, started, outcome) {
55980
+ const level = outcome.status === 401 || outcome.status === 403 ? "warn" : "info";
55981
+ deps.logger[level]("alexa snapshot: fetch answered", {
55982
+ ...outcome.deviceId !== void 0 ? { tags: { deviceId: outcome.deviceId } } : {},
55983
+ meta: {
55984
+ status: outcome.status,
55985
+ ...outcome.imageId !== void 0 ? { imageId: outcome.imageId } : {},
55986
+ ...outcome.reason !== void 0 ? { reason: outcome.reason } : {},
55987
+ ...outcome.lazy !== void 0 ? { lazy: outcome.lazy } : {},
55988
+ ...outcome.bytes !== void 0 ? { bytes: outcome.bytes } : {},
55989
+ tookMs: Date.now() - started,
55990
+ userAgent: headerOf(req.headers, "user-agent") ?? null,
55991
+ ...outcome.extra
55992
+ }
55993
+ });
55994
+ }
54181
55995
  async function handleSnapshotFetch(req, reply, deps) {
55996
+ const started = Date.now();
54182
55997
  if (!deps.enabled()) {
55998
+ logFetch(deps, req, started, {
55999
+ status: 410,
56000
+ reason: "switched-off"
56001
+ });
54183
56002
  refuse(reply, 410, "snapshots are switched off");
54184
56003
  return;
54185
56004
  }
54186
56005
  const imageId = IMAGE_FILE.exec(req.params["file"] ?? "")?.[1];
54187
56006
  if (imageId === void 0) {
56007
+ logFetch(deps, req, started, {
56008
+ status: 410,
56009
+ reason: "not-a-snapshot-address"
56010
+ });
54188
56011
  refuse(reply, 410, "not a snapshot address");
54189
56012
  return;
54190
56013
  }
54191
56014
  const found = deps.store.lookup(imageId, req.query["exp"], req.query["sig"]);
54192
56015
  if (found.kind === "gone") {
54193
- deps.logger.debug("alexa snapshot: fetch of a gone image", { meta: {
56016
+ logFetch(deps, req, started, {
56017
+ status: 410,
54194
56018
  imageId,
54195
56019
  reason: found.reason
54196
- } });
56020
+ });
54197
56021
  refuse(reply, 410, found.reason);
54198
56022
  return;
54199
56023
  }
54200
56024
  const image = found.image;
56025
+ const lazy = image.load !== void 0 || image.bytes.byteLength === 0;
56026
+ const base = {
56027
+ imageId,
56028
+ deviceId: image.deviceId,
56029
+ lazy
56030
+ };
54201
56031
  const token = bearerOf(req.headers);
54202
56032
  const verified = token === null ? null : await deps.verifyToken(token).catch(() => null);
54203
56033
  if (verified === null) {
54204
- deps.logger.warn("alexa snapshot: refused a fetch without a valid account-link token", {
54205
- tags: { deviceId: image.deviceId },
54206
- meta: {
54207
- imageId,
54208
- hadToken: token !== null
54209
- }
56034
+ logFetch(deps, req, started, {
56035
+ ...base,
56036
+ status: 401,
56037
+ reason: "no valid account-link token",
56038
+ extra: { hadToken: token !== null }
54210
56039
  });
54211
56040
  refuse(reply, 401, "a valid Alexa account-link token is required");
54212
56041
  return;
54213
56042
  }
54214
56043
  if (verified.userId !== image.userId || !await deps.mayView(verified.userId, image.deviceId)) {
54215
- deps.logger.warn("alexa snapshot: refused — the token does not belong to the user this image was made for, or that user lost the camera", {
54216
- tags: { deviceId: image.deviceId },
54217
- meta: {
54218
- imageId,
56044
+ logFetch(deps, req, started, {
56045
+ ...base,
56046
+ status: 403,
56047
+ reason: "token of another user, or the user lost the camera",
56048
+ extra: {
54219
56049
  tokenUser: verified.userId,
54220
56050
  imageUser: image.userId
54221
56051
  }
@@ -54225,13 +56055,19 @@ async function handleSnapshotFetch(req, reply, deps) {
54225
56055
  }
54226
56056
  const bytes = await deps.store.bytesOf(image);
54227
56057
  if (bytes === null || bytes.byteLength === 0) {
54228
- deps.logger.debug("alexa snapshot: no image to serve for this event", {
54229
- tags: { deviceId: image.deviceId },
54230
- meta: { imageId }
56058
+ logFetch(deps, req, started, {
56059
+ ...base,
56060
+ status: 410,
56061
+ reason: "no image for this event"
54231
56062
  });
54232
56063
  refuse(reply, 410, "no image is available for this event");
54233
56064
  return;
54234
56065
  }
56066
+ logFetch(deps, req, started, {
56067
+ ...base,
56068
+ status: 200,
56069
+ bytes: bytes.byteLength
56070
+ });
54235
56071
  reply.code(200).type(image.contentType).header("cache-control", "private, no-store").header("content-encoding", "identity").header("content-length", String(bytes.byteLength));
54236
56072
  reply.send(bytes);
54237
56073
  }
@@ -54714,6 +56550,8 @@ var LwaEventGateway = class {
54714
56550
  /** Per-endpoint count of `ObjectDetection` events dropped because the
54715
56551
  * endpoint does not declare {@link SMART_VISION_INTERFACE}. */
54716
56552
  smartVisionDropped = /* @__PURE__ */ new Map();
56553
+ /** Endpoints whose redacted ObjectDetection body was logged (D779 amendment). */
56554
+ smartVisionSampled = /* @__PURE__ */ new Set();
54717
56555
  /** Latches the "no grant at all" warning so it's logged ONCE, not on every
54718
56556
  * doorbell/motion event while no account has a push grant. */
54719
56557
  warnedNoGrant = false;
@@ -54766,6 +56604,7 @@ var LwaEventGateway = class {
54766
56604
  this.lastSentAt.clear();
54767
56605
  this.motionHold.clear();
54768
56606
  this.smartVisionDropped.clear();
56607
+ this.smartVisionSampled.clear();
54769
56608
  this.warnedNoToken.clear();
54770
56609
  this.warnedLegacyWaiting.clear();
54771
56610
  this.migrationRetryAt.clear();
@@ -54970,6 +56809,24 @@ var LwaEventGateway = class {
54970
56809
  for (const account of linked) {
54971
56810
  if (!this.mayPush(account.userId, opts.deviceId, "object detection")) continue;
54972
56811
  const images = opts.imagesFor?.(account.userId) ?? {};
56812
+ if (!this.smartVisionSampled.has(endpointId)) {
56813
+ this.smartVisionSampled.add(endpointId);
56814
+ this.deps.logger.info("alexa lwa-gateway: ObjectDetection body sample (redacted)", {
56815
+ tags: { deviceId: opts.deviceId },
56816
+ meta: { body: redactedObjectDetectionSample({
56817
+ userId: account.userId,
56818
+ endpointId,
56819
+ detections: [{
56820
+ eventIdentifier: d.eventIdentifier,
56821
+ imageNetClass: d.imageNetClass,
56822
+ objectIdentifier: d.objectIdentifier,
56823
+ ...images
56824
+ }],
56825
+ timestamp: d.timestamp,
56826
+ accessToken: ""
56827
+ }) }
56828
+ });
56829
+ }
54973
56830
  await this.postEventBody(account.userId, endpointId, (accessToken) => buildSmartVisionObjectDetectionEvent({
54974
56831
  userId: account.userId,
54975
56832
  endpointId,
@@ -55520,6 +57377,29 @@ function buildSmartVisionObjectDetectionEvent(opts) {
55520
57377
  })) }
55521
57378
  } };
55522
57379
  }
57380
+ /** Every `sig=` query value in a URI, for a log line. */
57381
+ function redactSignature(uri) {
57382
+ return uri?.replace(/([?&]sig=)[^&]*/g, "$1<redacted>");
57383
+ }
57384
+ /**
57385
+ * The ObjectDetection body exactly as built for the wire, minus its secrets
57386
+ * (D779 amendment): the scope token and every image URI's signature. Logged once per
57387
+ * endpoint per process so the shape can be compared with Amazon's example.
57388
+ */
57389
+ function redactedObjectDetectionSample(opts) {
57390
+ const body = buildSmartVisionObjectDetectionEvent({
57391
+ ...opts,
57392
+ accessToken: "<redacted>"
57393
+ });
57394
+ return { event: {
57395
+ ...body.event,
57396
+ payload: { events: body.event.payload.events.map((e) => ({
57397
+ ...e,
57398
+ ...e.frameImageUri !== void 0 ? { frameImageUri: redactSignature(e.frameImageUri) } : {},
57399
+ ...e.croppedImageUri !== void 0 ? { croppedImageUri: redactSignature(e.croppedImageUri) } : {}
57400
+ })) }
57401
+ } };
57402
+ }
55523
57403
  function buildAddOrUpdateReportPayload(_userId, endpoints, accessToken) {
55524
57404
  return { event: {
55525
57405
  header: {
@@ -55592,6 +57472,11 @@ async function removeEndpointsFromAlexa(deps) {
55592
57472
  //#endregion
55593
57473
  //#region src/settings-schema.ts
55594
57474
  var ADDON_ID = "export-alexa";
57475
+ /** The rows that exist only for a custom skill. */
57476
+ var CUSTOM_SKILL_ONLY = {
57477
+ field: "skillMode",
57478
+ equals: "custom"
57479
+ };
55595
57480
  var CONNECTION_DESCRIPTION = [
55596
57481
  "Public skill (default): enable the \"CamStack\" skill in the Alexa app and link your account. No Amazon developer setup is needed.",
55597
57482
  "Custom skill: enter your skill id and deploy the skill Lambda from this addon's lambda-template in your own AWS account.",
@@ -55641,13 +57526,14 @@ function connectionSection(input) {
55641
57526
  ],
55642
57527
  default: defaults.region
55643
57528
  },
55644
- ...input.skillMode === "custom" ? [{
57529
+ {
55645
57530
  type: "text",
55646
57531
  key: "expectedAudience",
55647
57532
  label: "Alexa skill id",
55648
57533
  description: "Your skill's id, format amzn1.ask.skill.xxxx, from the Alexa developer console. Directives for any other skill are refused.",
55649
- default: defaults.expectedAudience
55650
- }] : [],
57534
+ default: defaults.expectedAudience,
57535
+ showWhen: CUSTOM_SKILL_ONLY
57536
+ },
55651
57537
  {
55652
57538
  type: "addon-action-select",
55653
57539
  key: "publicHubUrl",
@@ -55790,6 +57676,7 @@ function customSkillSecuritySection(input) {
55790
57676
  key: "__ingress-token-info",
55791
57677
  label: "Ingress token",
55792
57678
  variant: "info",
57679
+ showWhen: CUSTOM_SKILL_ONLY,
55793
57680
  content: "An optional shared secret your skill Lambda sends on every call to this hub. Show it, put it in the Lambda's HUB_INGRESS_TOKEN environment variable, then turn on \"Require ingress token\". After a rotation, update the Lambda."
55794
57681
  },
55795
57682
  {
@@ -55801,7 +57688,8 @@ function customSkillSecuritySection(input) {
55801
57688
  buttonLabel: "Show ingress token",
55802
57689
  action: "revealIngressToken",
55803
57690
  variant: "default",
55804
- successMessage: "Ingress token: {ingressToken}"
57691
+ successMessage: "Ingress token: {ingressToken}",
57692
+ showWhen: CUSTOM_SKILL_ONLY
55805
57693
  },
55806
57694
  {
55807
57695
  type: "addon-action-button",
@@ -55813,14 +57701,16 @@ function customSkillSecuritySection(input) {
55813
57701
  action: "regenerateIngressToken",
55814
57702
  variant: "default",
55815
57703
  successMessage: "New ingress token: {ingressToken} — put it in HUB_INGRESS_TOKEN now.",
55816
- confirmMessage: "Rotate the ingress token? With \"Require ingress token\" on, the Lambda is refused until you update HUB_INGRESS_TOKEN."
57704
+ confirmMessage: "Rotate the ingress token? With \"Require ingress token\" on, the Lambda is refused until you update HUB_INGRESS_TOKEN.",
57705
+ showWhen: CUSTOM_SKILL_ONLY
55817
57706
  },
55818
57707
  {
55819
57708
  type: "boolean",
55820
57709
  key: "enforceIngressToken",
55821
57710
  label: "Require ingress token",
55822
57711
  description: "When on, this hub refuses skill calls without the matching token. Turn it on only after HUB_INGRESS_TOKEN is set in your Lambda.",
55823
- default: input.defaults.enforceIngressToken
57712
+ default: input.defaults.enforceIngressToken,
57713
+ showWhen: CUSTOM_SKILL_ONLY
55824
57714
  }
55825
57715
  ]
55826
57716
  };
@@ -55831,7 +57721,7 @@ function buildAlexaSettingsSections(input) {
55831
57721
  featuresSection(input),
55832
57722
  accountLinkSection(input),
55833
57723
  troubleshootingSection(),
55834
- ...input.skillMode === "custom" ? [customSkillSecuritySection(input)] : []
57724
+ customSkillSecuritySection(input)
55835
57725
  ];
55836
57726
  }
55837
57727
  //#endregion
@@ -56211,6 +58101,8 @@ function sensorSelectionField(input) {
56211
58101
  immediate: true
56212
58102
  };
56213
58103
  }
58104
+ /** Minimum spacing of two events of one class on one camera (D779 amendment). */
58105
+ var CAMERA_EVENT_MIN_INTERVAL_MS = 3e4;
56214
58106
  /** Bound on the per-track bookkeeping should `end` events be lost (D8). */
56215
58107
  var MAX_TRACKED = 5e3;
56216
58108
  var TrackLifecycleSchema = object({
@@ -56233,6 +58125,9 @@ var ObjectDetectionFeed = class {
56233
58125
  handled = /* @__PURE__ */ new Map();
56234
58126
  /** objectIdentifier → last event time. */
56235
58127
  lastPosted = /* @__PURE__ */ new Map();
58128
+ /** `${deviceId}|${class}` → last event time, and tracks held back since. */
58129
+ lastCameraPost = /* @__PURE__ */ new Map();
58130
+ heldBack = /* @__PURE__ */ new Map();
56236
58131
  off = null;
56237
58132
  constructor(deps) {
56238
58133
  this.deps = deps;
@@ -56257,6 +58152,8 @@ var ObjectDetectionFeed = class {
56257
58152
  this.off = null;
56258
58153
  this.handled.clear();
56259
58154
  this.lastPosted.clear();
58155
+ this.lastCameraPost.clear();
58156
+ this.heldBack.clear();
56260
58157
  }
56261
58158
  /** Per-track entries currently held (tests, diagnostics). */
56262
58159
  trackedCount() {
@@ -56277,6 +58174,12 @@ var ObjectDetectionFeed = class {
56277
58174
  const objectIdentifier = objectIdentifierFor(namespace, event.deviceId, event.trackId);
56278
58175
  const last = this.lastPosted.get(objectIdentifier);
56279
58176
  if (last !== void 0 && now - last < 3e4) return;
58177
+ const cameraKey = `${event.deviceId}|${cls}`;
58178
+ const lastOnCamera = this.lastCameraPost.get(cameraKey);
58179
+ if (lastOnCamera !== void 0 && now - lastOnCamera < 3e4) {
58180
+ if (event.phase === "start") this.heldBack.set(cameraKey, (this.heldBack.get(cameraKey) ?? 0) + 1);
58181
+ return;
58182
+ }
56280
58183
  this.mark(key, now);
56281
58184
  if (!(await this.deps.reportableClasses(event.deviceId)).includes(cls)) return;
56282
58185
  const detection = {
@@ -56287,7 +58190,20 @@ var ObjectDetectionFeed = class {
56287
58190
  timestamp: now
56288
58191
  };
56289
58192
  this.lastPosted.set(objectIdentifier, now);
58193
+ this.lastCameraPost.set(cameraKey, now);
56290
58194
  this.pruneLastPosted(now);
58195
+ const held = this.heldBack.get(cameraKey) ?? 0;
58196
+ if (held > 0) {
58197
+ this.heldBack.delete(cameraKey);
58198
+ this.deps.logger.info("alexa object detection: tracks held back by the per-camera window", {
58199
+ tags: { deviceId: event.deviceId },
58200
+ meta: {
58201
+ imageNetClass: cls,
58202
+ heldBack: held,
58203
+ windowMs: CAMERA_EVENT_MIN_INTERVAL_MS
58204
+ }
58205
+ });
58206
+ }
56291
58207
  await this.deps.remember(event.deviceId, {
56292
58208
  e: detection.eventIdentifier,
56293
58209
  t: event.trackId,
@@ -56706,7 +58622,15 @@ function verifyExpiringUrl(input) {
56706
58622
  */
56707
58623
  /** How long a minted image URL is valid — Amazon recommends ten minutes. */
56708
58624
  var SNAPSHOT_URL_TTL_MS = 10 * 6e4;
58625
+ /** Bound on entries holding pixels (GetSnapshot images, loaded lazy ones). */
56709
58626
  var MAX_IMAGES = 128;
58627
+ /**
58628
+ * Bound on lazy entries not yet fetched (D779 amendment). They hold no pixels — a closure
58629
+ * over (device, track) — so the bound only guards against a runaway. It must
58630
+ * cover ten minutes of events: at the measured ~15 events/min, two URIs each,
58631
+ * the shared 128 bound evicted a URI ~4 min after Alexa was handed it.
58632
+ */
58633
+ var MAX_LAZY_IMAGES = 4096;
56710
58634
  var MAX_TOTAL_BYTES = 24 * 1024 * 1024;
56711
58635
  var SnapshotStore = class {
56712
58636
  secret;
@@ -56836,9 +58760,18 @@ var SnapshotStore = class {
56836
58760
  for (const [id, image] of this.images) if (image.expiresAt <= now) this.drop(id, image);
56837
58761
  }
56838
58762
  evictOverBounds() {
58763
+ let lazy = 0;
58764
+ for (const image of this.images.values()) if (image.load !== void 0) lazy += 1;
58765
+ let loaded = this.images.size - lazy;
56839
58766
  for (const [id, image] of this.images) {
56840
- if (this.images.size <= MAX_IMAGES && this.totalBytes <= MAX_TOTAL_BYTES) return;
58767
+ const overLoaded = loaded > MAX_IMAGES || this.totalBytes > MAX_TOTAL_BYTES;
58768
+ const overLazy = lazy > MAX_LAZY_IMAGES;
58769
+ if (!overLoaded && !overLazy) return;
58770
+ const isLazy = image.load !== void 0;
58771
+ if (isLazy ? !overLazy : !overLoaded) continue;
56841
58772
  this.drop(id, image);
58773
+ if (isLazy) lazy -= 1;
58774
+ else loaded -= 1;
56842
58775
  }
56843
58776
  }
56844
58777
  drop(id, image) {
@@ -57568,6 +59501,14 @@ var SUPPORTED_KINDS = [
57568
59501
  DeviceType.Generic
57569
59502
  ];
57570
59503
  var ExportAlexaAddon = class extends BaseAddon {
59504
+ /** Hidden state that is a credential — kept in the keychain, never the blob (D787). */
59505
+ secretStatePaths = [
59506
+ "ingressToken",
59507
+ "snapshotSigningKey",
59508
+ "tokens[userId].accessToken",
59509
+ "tokens[userId].refreshToken",
59510
+ "tokens[userId].brokerCredential"
59511
+ ];
57571
59512
  lwaGateway = null;
57572
59513
  syncEngine = null;
57573
59514
  /** S1 (D767): the linking user's live grants. Built in `onInitialize`, the
@@ -57595,7 +59536,7 @@ var ExportAlexaAddon = class extends BaseAddon {
57595
59536
  if (!this.config.snapshotSigningKey) await this.updateGlobalSettings({ snapshotSigningKey: generateIngressToken() });
57596
59537
  if (!this.config.visionNamespace) await this.updateGlobalSettings({ visionNamespace: (0, node_crypto.randomUUID)() });
57597
59538
  if (this.config.lwaClientSecret) {
57598
- await this.updateGlobalSettings({ lwaClientSecret: "" });
59539
+ await this.clearSecrets(["lwaClientSecret"]);
57599
59540
  this.ctx.logger.warn("export-alexa: removed a stored LWA client secret — the hub no longer uses one; your skill Lambda holds it (D753)");
57600
59541
  }
57601
59542
  await this.backfillLinkedAccounts();
@@ -57670,8 +59611,7 @@ var ExportAlexaAddon = class extends BaseAddon {
57670
59611
  },
57671
59612
  ptzDirection: {
57672
59613
  ctx: this.ctx,
57673
- logger: this.ctx.logger,
57674
- ptzPulseMs: 1e3
59614
+ logger: this.ctx.logger
57675
59615
  },
57676
59616
  powerController: {
57677
59617
  ctx: this.ctx,
@@ -58423,7 +60363,6 @@ var ExportAlexaAddon = class extends BaseAddon {
58423
60363
  * linking rows live in the `device-export` setup block instead. */
58424
60364
  globalSettingsSchema() {
58425
60365
  return { sections: buildAlexaSettingsSections({
58426
- skillMode: this.config.skillMode,
58427
60366
  linkedAccounts: this.config.linkedAccounts,
58428
60367
  tokens: this.config.tokens,
58429
60368
  now: Date.now(),