@camstack/addon-provider-petkit 0.2.121 → 0.2.123

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/dist/addon.js +2044 -62
  2. package/dist/addon.mjs +2044 -62
  3. package/package.json +1 -1
package/dist/addon.mjs CHANGED
@@ -1100,7 +1100,7 @@ var Nodepetkit = class {
1100
1100
  }
1101
1101
  };
1102
1102
  //#endregion
1103
- //#region ../types/dist/event-category-B_0XEcLF.mjs
1103
+ //#region ../types/dist/event-category-DaIZi00R.mjs
1104
1104
  var EventCategory = /* @__PURE__ */ function(EventCategory) {
1105
1105
  EventCategory["SystemBoot"] = "system.boot";
1106
1106
  EventCategory["SystemAddonsReady"] = "system.addons-ready";
@@ -1179,6 +1179,13 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
1179
1179
  */
1180
1180
  EventCategory["AddonLoadFailed"] = "addon.load-failed";
1181
1181
  /**
1182
+ * A keychain value was stored or removed (D787). Carries the ref, its
1183
+ * owner and the new version — NEVER the value. A process holding the ref
1184
+ * drops its cached copy and the owning `BaseAddon` re-resolves its config.
1185
+ * Telemetry (D8): a process that misses it still revalidates by version.
1186
+ */
1187
+ EventCategory["KeychainChanged"] = "keychain.changed";
1188
+ /**
1182
1189
  * Addon recovered from a previous failure. Emitted when an addon
1183
1190
  * transitions from `failed` back to `healthy` (typically via the
1184
1191
  * monitor's auto-retry loop, or after manual `addons.retryLoad`).
@@ -6471,7 +6478,7 @@ var ZodIssueCode = {
6471
6478
  var ZodFirstPartyTypeKind;
6472
6479
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
6473
6480
  //#endregion
6474
- //#region ../types/dist/sleep-BNeXenvr.mjs
6481
+ //#region ../types/dist/sleep-Cr5YOk3m.mjs
6475
6482
  /**
6476
6483
  * The audio chunk plane's byte format, and the ONE expansion from a coded
6477
6484
  * window to float samples (D455).
@@ -6550,6 +6557,97 @@ function buildAlawTable() {
6550
6557
  }
6551
6558
  buildUlawTable();
6552
6559
  buildAlawTable();
6560
+ /** Is this field's stored value a credential? */
6561
+ function isSecretConfigField(field) {
6562
+ if (field.type === "password") return true;
6563
+ return "secret" in field && field.secret === true;
6564
+ }
6565
+ /**
6566
+ * Is this field's value stored in the KEYCHAIN (D787)? Every secret field is,
6567
+ * by its TYPE, unless it opts out with `storage: 'inline'` — never by its name.
6568
+ */
6569
+ function isKeychainStoredField(field) {
6570
+ if (!isSecretConfigField(field)) return false;
6571
+ if (field.type === "textarea" && field.isJson === true) return false;
6572
+ return !("storage" in field && field.storage === "inline");
6573
+ }
6574
+ /**
6575
+ * What a settings blob holds where a secret used to be.
6576
+ *
6577
+ * A keychain-stored field never holds its value. It holds a self-describing
6578
+ * MARKER, `{"$secret":"secret://…","v":1}` — an object, never a string, so no
6579
+ * code can mistake it for a credential and no form can send it to a camera as
6580
+ * a password. The empty state is `null` / absent, never `''`.
6581
+ *
6582
+ * The same shapes travel to and from the admin UI:
6583
+ *
6584
+ * - read: `hydrateSchema` hands a secret field a {@link SecretFieldView}
6585
+ * (`{ $secret, v, set: true }`) or `null` — the browser learns whether a
6586
+ * value is set, never the value.
6587
+ * - write: an untouched field submits the view back unchanged (KEEP); a typed
6588
+ * value is a plain non-empty string (CHANGE); the Clear button submits
6589
+ * {@link SECRET_CLEAR} (CLEAR). `''`, `null` and the legacy redaction tokens
6590
+ * are KEEP — an empty string is what a defaults-fallback pushes back, and
6591
+ * treating it as "clear" is how a save destroyed a stored credential before.
6592
+ *
6593
+ * Pure and browser-safe.
6594
+ */
6595
+ var SECRET_CLEAR = { $secretClear: true };
6596
+ /** The `'***'` token D634 redaction writes for non-admins. */
6597
+ var LEGACY_DEVICE_REDACTION = "***";
6598
+ function isRecord$1(value) {
6599
+ return typeof value === "object" && value !== null && !Array.isArray(value);
6600
+ }
6601
+ function makeSecretMarker(ref) {
6602
+ return {
6603
+ $secret: ref,
6604
+ v: 1
6605
+ };
6606
+ }
6607
+ /** A stored marker: an object whose `$secret` is a non-empty string. */
6608
+ function isSecretMarker(value) {
6609
+ if (!isRecord$1(value)) return false;
6610
+ const ref = value["$secret"];
6611
+ return typeof ref === "string" && ref.length > 0;
6612
+ }
6613
+ function isSecretClear(value) {
6614
+ return isRecord$1(value) && value["$secretClear"] === true;
6615
+ }
6616
+ /**
6617
+ * The UI view of a stored secret field value: a marker becomes "set", inline
6618
+ * plaintext becomes "set (inline)", nothing becomes `null`. A value never
6619
+ * survives this function.
6620
+ */
6621
+ function toSecretFieldView(stored) {
6622
+ if (isSecretMarker(stored)) return {
6623
+ $secret: stored.$secret,
6624
+ v: 1,
6625
+ set: true
6626
+ };
6627
+ if (typeof stored === "string" && stored.length > 0) return {
6628
+ $secret: null,
6629
+ v: 1,
6630
+ set: true,
6631
+ inline: true
6632
+ };
6633
+ return null;
6634
+ }
6635
+ /**
6636
+ * Classify an incoming value for a secret path. Only a non-empty string that is
6637
+ * not a redaction token sets a value; only {@link SECRET_CLEAR} clears.
6638
+ * Everything else — a marker (ours or anyone's), a UI view, `''`, `null`,
6639
+ * `undefined`, a redaction token, a non-string — keeps what is stored.
6640
+ */
6641
+ function classifySecretWrite(incoming) {
6642
+ if (isSecretClear(incoming)) return { kind: "clear" };
6643
+ if (typeof incoming !== "string") return { kind: "keep" };
6644
+ if (incoming.length === 0) return { kind: "keep" };
6645
+ if (incoming === "__camstack_redacted__" || incoming === LEGACY_DEVICE_REDACTION) return { kind: "keep" };
6646
+ return {
6647
+ kind: "set",
6648
+ value: incoming
6649
+ };
6650
+ }
6553
6651
  Object.fromEntries([
6554
6652
  {
6555
6653
  id: "overview",
@@ -6721,33 +6819,19 @@ Object.fromEntries([
6721
6819
  function isValuelessField(field) {
6722
6820
  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";
6723
6821
  }
6724
- /**
6725
- * Merge a `ConfigUISchema` with a raw `values` record into a
6726
- * `ConfigUISchemaWithValues`. Used by every `get*Settings` backend endpoint
6727
- * before returning to the admin UI. Groups are walked recursively.
6728
- *
6729
- * For each leaf field:
6730
- * - structural fields (`separator`, `info`, `button`) pass through unchanged
6731
- * - other fields get `value = values[key] ?? field.default ?? null`
6732
- *
6733
- * Unknown keys in `values` (keys not declared in the schema) are silently
6734
- * ignored — they don't contribute to the output. Missing keys fall back to
6735
- * the schema default or `null`. This mirrors the old backend behaviour where
6736
- * `FormBuilder` rendered `values[key] ?? field.default`.
6737
- */
6738
- function hydrateSchema(schema, values) {
6822
+ function hydrateSchema(schema, values, options = {}) {
6739
6823
  return {
6740
6824
  ...schema.tabs ? { tabs: [...schema.tabs] } : {},
6741
6825
  sections: schema.sections.map((section) => ({
6742
6826
  ...section,
6743
- fields: section.fields.map((field) => hydrateField(field, values))
6827
+ fields: section.fields.map((field) => hydrateField(field, values, options))
6744
6828
  }))
6745
6829
  };
6746
6830
  }
6747
- function hydrateField(field, values) {
6831
+ function hydrateField(field, values, options) {
6748
6832
  if (isValuelessField(field)) return field;
6749
6833
  if (field.type === "group") {
6750
- const hydratedChildren = field.fields.map((child) => hydrateField(child, values));
6834
+ const hydratedChildren = field.fields.map((child) => hydrateField(child, values, options));
6751
6835
  return {
6752
6836
  ...field,
6753
6837
  fields: hydratedChildren
@@ -6756,7 +6840,7 @@ function hydrateField(field, values) {
6756
6840
  if (field.type === "sub-tabs") {
6757
6841
  const hydratedTabs = field.tabs.map((tab) => ({
6758
6842
  ...tab,
6759
- fields: tab.fields.map((child) => hydrateField(child, values))
6843
+ fields: tab.fields.map((child) => hydrateField(child, values, options))
6760
6844
  }));
6761
6845
  return {
6762
6846
  ...field,
@@ -6766,6 +6850,33 @@ function hydrateField(field, values) {
6766
6850
  const key = field.key;
6767
6851
  const storedValue = Object.prototype.hasOwnProperty.call(values, key) ? values[key] : void 0;
6768
6852
  const defaultValue = field.default;
6853
+ const asView = (v) => isSecretMarker(v) || options.inlineSecretsAsViews === true && v !== void 0;
6854
+ if (isKeychainStoredField(field) && asView(storedValue)) return {
6855
+ ...field,
6856
+ value: toSecretFieldView(storedValue)
6857
+ };
6858
+ if (isKeychainStoredField(field) && options.inlineSecretsAsViews === true) return {
6859
+ ...field,
6860
+ value: null
6861
+ };
6862
+ if (field.type === "editable-array" && Array.isArray(storedValue)) {
6863
+ const secretItemKeys = field.itemFields.filter((item) => "key" in item && isKeychainStoredField(item)).map((item) => "key" in item ? item.key : "");
6864
+ if (secretItemKeys.length > 0) {
6865
+ const rows = storedValue.map((row) => {
6866
+ if (row === null || typeof row !== "object" || Array.isArray(row)) return row;
6867
+ const out = { ...row };
6868
+ for (const k of secretItemKeys) {
6869
+ const v = Reflect.get(row, k);
6870
+ if (asView(v)) out[k] = toSecretFieldView(v);
6871
+ }
6872
+ return out;
6873
+ });
6874
+ return {
6875
+ ...field,
6876
+ value: rows
6877
+ };
6878
+ }
6879
+ }
6769
6880
  if (field.multiple) {
6770
6881
  const stored = Array.isArray(storedValue) ? storedValue : storedValue !== void 0 && storedValue !== null ? [storedValue] : [];
6771
6882
  const itemFallback = field.multiple.itemDefault !== void 0 ? field.multiple.itemDefault : defaultValue !== void 0 ? defaultValue : typeOf(field) === "string" ? "" : null;
@@ -7008,6 +7119,431 @@ function projectStore(store, perNodeKeys, nodeId) {
7008
7119
  }
7009
7120
  return out;
7010
7121
  }
7122
+ var GLOBAL_SCOPE = { kind: "global" };
7123
+ /** The scope every addon-wide (not per-node, not per-device) setting lives in. */
7124
+ function globalSecretScope() {
7125
+ return GLOBAL_SCOPE;
7126
+ }
7127
+ function encodeSegment(value) {
7128
+ return encodeURIComponent(value);
7129
+ }
7130
+ /**
7131
+ * The field path of a value inside an array item, addressed by the item's id:
7132
+ * `arrayItemFieldPath('providers', 'authentik', 'clientSecret')` →
7133
+ * `providers[authentik].clientSecret`.
7134
+ */
7135
+ function arrayItemFieldPath(arrayKey, itemId, fieldKey) {
7136
+ return `${arrayKey}[${encodeSegment(itemId)}].${fieldKey}`;
7137
+ }
7138
+ /** A write to a secret path could not be stored in the keychain, so it was refused. */
7139
+ var KeychainWriteRefusedError = class extends Error {
7140
+ fieldPath;
7141
+ constructor(fieldPath, cause) {
7142
+ super(`secret "${fieldPath}" was not saved: the keychain could not store it (${cause instanceof Error ? cause.message : String(cause)}). Nothing was written.`);
7143
+ this.fieldPath = fieldPath;
7144
+ this.name = "KeychainWriteRefusedError";
7145
+ }
7146
+ };
7147
+ var KEEP = { kind: "keep" };
7148
+ function isRecord(value) {
7149
+ return typeof value === "object" && value !== null && !Array.isArray(value);
7150
+ }
7151
+ function defaultMintId() {
7152
+ return globalThis.crypto.randomUUID();
7153
+ }
7154
+ /** Every marker ref anywhere under `value`. */
7155
+ function collectSecretMarkerRefs(value, out = []) {
7156
+ if (isSecretMarker(value)) {
7157
+ out.push(value.$secret);
7158
+ return out;
7159
+ }
7160
+ if (Array.isArray(value)) for (const item of value) collectSecretMarkerRefs(item, out);
7161
+ else if (isRecord(value)) for (const child of Object.values(value)) collectSecretMarkerRefs(child, out);
7162
+ return out;
7163
+ }
7164
+ async function storedValueEquals(secrets, marker, candidate) {
7165
+ const resolved = (await secrets.resolve([marker.$secret]))[marker.$secret];
7166
+ return resolved?.kind === "value" && resolved.value === candidate;
7167
+ }
7168
+ async function writeLeaf(ctx, incoming, stored, fieldPath) {
7169
+ const intent = classifySecretWrite(incoming);
7170
+ const ref = ctx.secrets.ref(ctx.scope, fieldPath);
7171
+ const storedIsOurs = isSecretMarker(stored) && stored.$secret === ref;
7172
+ if (intent.kind === "keep") return KEEP;
7173
+ if (intent.kind === "set" && !ctx.operatorWrite && typeof stored === "string" && stored === intent.value) return KEEP;
7174
+ if (intent.kind === "clear") {
7175
+ if (storedIsOurs) ctx.deletes.push(ref);
7176
+ return {
7177
+ kind: "value",
7178
+ value: null
7179
+ };
7180
+ }
7181
+ if (storedIsOurs && await storedValueEquals(ctx.secrets, stored, intent.value)) return {
7182
+ kind: "value",
7183
+ value: stored
7184
+ };
7185
+ try {
7186
+ await ctx.secrets.put(ref, intent.value);
7187
+ } catch (err) {
7188
+ throw new KeychainWriteRefusedError(fieldPath, err);
7189
+ }
7190
+ return {
7191
+ kind: "value",
7192
+ value: makeSecretMarker(ref)
7193
+ };
7194
+ }
7195
+ /** Apply a member result onto `out`: KEEP restores the stored member, or removes it. */
7196
+ function applyMember(out, key, result, storedParent) {
7197
+ if (result.kind === "value") {
7198
+ out[key] = result.value;
7199
+ return;
7200
+ }
7201
+ if (Object.prototype.hasOwnProperty.call(storedParent, key)) out[key] = storedParent[key];
7202
+ else delete out[key];
7203
+ }
7204
+ async function writeMembers(ctx, children, incoming, stored, pathOf) {
7205
+ const out = { ...incoming };
7206
+ for (const [member, node] of children) applyMember(out, member, await writeNode(ctx, node, incoming[member], stored[member], pathOf(member)), stored);
7207
+ return out;
7208
+ }
7209
+ function rowId(row, idKey) {
7210
+ const raw = row[idKey];
7211
+ if (typeof raw === "string" && raw.length > 0) return raw;
7212
+ if (typeof raw === "number" && Number.isFinite(raw)) return String(raw);
7213
+ return null;
7214
+ }
7215
+ async function writeArray(ctx, node, incoming, stored, fieldPath) {
7216
+ const storedRows = Array.isArray(stored) ? stored.filter(isRecord) : [];
7217
+ if (!Array.isArray(incoming)) {
7218
+ ctx.deletes.push(...collectSecretMarkerRefs(storedRows));
7219
+ return {
7220
+ kind: "value",
7221
+ value: incoming
7222
+ };
7223
+ }
7224
+ const storedById = /* @__PURE__ */ new Map();
7225
+ for (const row of storedRows) {
7226
+ const id = rowId(row, node.idKey);
7227
+ if (id !== null) storedById.set(id, row);
7228
+ }
7229
+ const kept = /* @__PURE__ */ new Set();
7230
+ const rows = [];
7231
+ for (const row of incoming) {
7232
+ if (!isRecord(row)) {
7233
+ rows.push(row);
7234
+ continue;
7235
+ }
7236
+ const id = rowId(row, node.idKey) ?? ctx.mintId();
7237
+ kept.add(id);
7238
+ const withId = {
7239
+ ...row,
7240
+ [node.idKey]: row[node.idKey] ?? id
7241
+ };
7242
+ if (rowId(withId, node.idKey) === null) withId[node.idKey] = id;
7243
+ const storedRow = storedById.get(id) ?? {};
7244
+ rows.push(await writeMembers(ctx, node.item, withId, storedRow, (member) => arrayItemFieldPath(fieldPath, id, member)));
7245
+ }
7246
+ for (const [id, row] of storedById) if (!kept.has(id)) ctx.deletes.push(...collectSecretMarkerRefs(row));
7247
+ return {
7248
+ kind: "value",
7249
+ value: rows
7250
+ };
7251
+ }
7252
+ async function writeNode(ctx, node, incoming, stored, fieldPath) {
7253
+ switch (node.kind) {
7254
+ case "leaf": return writeLeaf(ctx, incoming, stored, fieldPath);
7255
+ case "array": return writeArray(ctx, node, incoming, stored, fieldPath);
7256
+ case "object": {
7257
+ if (!isRecord(incoming)) {
7258
+ if (incoming === void 0) return KEEP;
7259
+ ctx.deletes.push(...collectSecretMarkerRefs(stored));
7260
+ return {
7261
+ kind: "value",
7262
+ value: incoming
7263
+ };
7264
+ }
7265
+ const storedObj = isRecord(stored) ? stored : {};
7266
+ return {
7267
+ kind: "value",
7268
+ value: await writeMembers(ctx, node.children, incoming, storedObj, (m) => `${fieldPath}.${m}`)
7269
+ };
7270
+ }
7271
+ }
7272
+ }
7273
+ /** Split a perNode-scoped key (`key@nodeId`). */
7274
+ function splitNodeKey(key) {
7275
+ const at = key.indexOf("@");
7276
+ return at <= 0 ? {
7277
+ base: key,
7278
+ nodeId: null
7279
+ } : {
7280
+ base: key.slice(0, at),
7281
+ nodeId: key.slice(at + 1)
7282
+ };
7283
+ }
7284
+ /** Rewrite a settings patch so no secret value reaches the blob. See the file doc. */
7285
+ async function transformSecretWrite(input) {
7286
+ const deletes = [];
7287
+ const base = {
7288
+ secrets: input.secrets,
7289
+ mintId: input.mintId ?? defaultMintId,
7290
+ deletes,
7291
+ operatorWrite: input.operatorWrite === true
7292
+ };
7293
+ const out = {};
7294
+ for (const [key, incoming] of Object.entries(input.patch)) {
7295
+ const { base: baseKey, nodeId } = splitNodeKey(key);
7296
+ const node = input.tree.get(baseKey);
7297
+ if (node === void 0) {
7298
+ out[key] = incoming;
7299
+ continue;
7300
+ }
7301
+ const scope = nodeId !== null && nodeId.length > 0 ? {
7302
+ kind: "node",
7303
+ nodeId
7304
+ } : input.scope ?? globalSecretScope();
7305
+ const result = await writeNode({
7306
+ ...base,
7307
+ scope
7308
+ }, node, incoming, input.stored[key], baseKey);
7309
+ if (result.kind === "value") out[key] = result.value;
7310
+ }
7311
+ return {
7312
+ patch: out,
7313
+ afterWrite: async () => {
7314
+ if (deletes.length === 0) return { orphaned: [] };
7315
+ try {
7316
+ await input.secrets.delete([...new Set(deletes)]);
7317
+ return { orphaned: [] };
7318
+ } catch {
7319
+ return { orphaned: [...new Set(deletes)] };
7320
+ }
7321
+ }
7322
+ };
7323
+ }
7324
+ /**
7325
+ * Replace every marker in `value` with its keychain value. Returns the SAME
7326
+ * reference when there is no marker (no allocation, no keychain call).
7327
+ */
7328
+ async function resolveSecretMarkers(value, secrets) {
7329
+ const refs = collectSecretMarkerRefs(value);
7330
+ if (refs.length === 0) return {
7331
+ value,
7332
+ unresolved: []
7333
+ };
7334
+ const answers = await secrets.resolve(refs);
7335
+ const unresolved = [];
7336
+ for (const ref of new Set(refs)) {
7337
+ const answer = answers[ref];
7338
+ if (answer === void 0) unresolved.push({
7339
+ ref,
7340
+ reason: "not-initialized"
7341
+ });
7342
+ else if (answer.kind === "unavailable") unresolved.push({
7343
+ ref,
7344
+ reason: answer.reason
7345
+ });
7346
+ else if (answer.kind === "missing" || answer.kind === "forbidden") unresolved.push({
7347
+ ref,
7348
+ reason: answer.kind
7349
+ });
7350
+ }
7351
+ const substitute = (v) => {
7352
+ if (isSecretMarker(v)) {
7353
+ const answer = answers[v.$secret];
7354
+ return answer?.kind === "value" ? {
7355
+ keep: true,
7356
+ value: answer.value
7357
+ } : {
7358
+ keep: false,
7359
+ value: void 0
7360
+ };
7361
+ }
7362
+ if (Array.isArray(v)) {
7363
+ const items = [];
7364
+ for (const item of v) {
7365
+ const s = substitute(item);
7366
+ if (s.keep) items.push(s.value);
7367
+ }
7368
+ return {
7369
+ keep: true,
7370
+ value: items
7371
+ };
7372
+ }
7373
+ if (isRecord(v)) {
7374
+ const out = {};
7375
+ for (const [k, child] of Object.entries(v)) {
7376
+ const s = substitute(child);
7377
+ if (s.keep) out[k] = s.value;
7378
+ }
7379
+ return {
7380
+ keep: true,
7381
+ value: out
7382
+ };
7383
+ }
7384
+ return {
7385
+ keep: true,
7386
+ value: v
7387
+ };
7388
+ };
7389
+ return {
7390
+ value: substitute(value).value,
7391
+ unresolved
7392
+ };
7393
+ }
7394
+ function touchesTree(tree, patch) {
7395
+ if (tree.size === 0) return false;
7396
+ for (const key of Object.keys(patch)) {
7397
+ const at = key.indexOf("@");
7398
+ if (tree.has(at > 0 ? key.slice(0, at) : key)) return true;
7399
+ }
7400
+ return false;
7401
+ }
7402
+ /** The blob as stored now; a failed read REFUSES the write instead of guessing. */
7403
+ async function readStoredAddonBlob(raw) {
7404
+ const threeWay = raw.readAddonStoreResult;
7405
+ if (threeWay === void 0) return raw.readAddonStore();
7406
+ const result = await threeWay.call(raw);
7407
+ if (result.kind === "failed") throw new Error(`settings write refused: the stored blob could not be read (${result.error})`);
7408
+ return result.kind === "missing" ? {} : result.value;
7409
+ }
7410
+ function createSecretAwareSettings(raw, opts) {
7411
+ const chains = /* @__PURE__ */ new Map();
7412
+ const serialize = (key, fn) => {
7413
+ const next = (chains.get(key) ?? Promise.resolve()).then(fn, fn);
7414
+ const tail = next.catch(() => void 0);
7415
+ chains.set(key, tail);
7416
+ tail.then(() => {
7417
+ if (chains.get(key) === tail) chains.delete(key);
7418
+ });
7419
+ return next;
7420
+ };
7421
+ const write = async (chainKey, tree, scope, patch, readStored, rawWrite) => {
7422
+ if (!touchesTree(tree, patch)) return rawWrite(patch);
7423
+ return serialize(chainKey, async () => {
7424
+ const stored = await readStored();
7425
+ const result = await transformSecretWrite({
7426
+ tree,
7427
+ secrets: opts.secrets,
7428
+ patch,
7429
+ stored,
7430
+ ...scope !== void 0 ? { scope } : {},
7431
+ operatorWrite: opts.isOperatorWrite?.() === true
7432
+ });
7433
+ if (Object.keys(result.patch).length > 0) await rawWrite(result.patch);
7434
+ const { orphaned } = await result.afterWrite();
7435
+ if (orphaned.length > 0) opts.onOrphaned(orphaned);
7436
+ });
7437
+ };
7438
+ const wrapped = {
7439
+ writeAddonStore: (patch) => write("addon", opts.addonTree(), void 0, patch, () => readStoredAddonBlob(raw), (p) => raw.writeAddonStore(p)),
7440
+ writeDeviceStore: (deviceId, patch) => write(`device:${deviceId}`, opts.deviceTree(), {
7441
+ kind: "device",
7442
+ deviceId
7443
+ }, patch, () => raw.readDeviceStore(deviceId), (p) => raw.writeDeviceStore(deviceId, p))
7444
+ };
7445
+ return new Proxy(raw, { get(target, prop, receiver) {
7446
+ if (prop === "writeAddonStore") return wrapped.writeAddonStore;
7447
+ if (prop === "writeDeviceStore") return wrapped.writeDeviceStore;
7448
+ const value = Reflect.get(target, prop, receiver);
7449
+ return typeof value === "function" ? value.bind(target) : value;
7450
+ } });
7451
+ }
7452
+ /** The context the addon sees: identical, except that its settings writes are secret-aware. */
7453
+ function withSecretAwareSettings(context, opts) {
7454
+ const raw = context.settings;
7455
+ if (raw === void 0) return context;
7456
+ const settings = createSecretAwareSettings(raw, opts);
7457
+ return new Proxy(context, { get(target, prop, receiver) {
7458
+ if (prop === "settings") return settings;
7459
+ return Reflect.get(target, prop, receiver);
7460
+ } });
7461
+ }
7462
+ var LEAF = { kind: "leaf" };
7463
+ var DEFAULT_ITEM_ID_KEY = "id";
7464
+ function collectFields(fields, out) {
7465
+ for (const field of fields) {
7466
+ if (field.type === "group") {
7467
+ collectFields(field.fields, out);
7468
+ continue;
7469
+ }
7470
+ if (field.type === "sub-tabs") {
7471
+ for (const tab of field.tabs) collectFields(tab.fields, out);
7472
+ continue;
7473
+ }
7474
+ if (field.type === "editable-array") {
7475
+ const item = /* @__PURE__ */ new Map();
7476
+ for (const itemField of field.itemFields) if ("key" in itemField && isKeychainStoredField(itemField)) item.set(itemField.key, LEAF);
7477
+ if (item.size > 0) out.set(field.key, {
7478
+ kind: "array",
7479
+ idKey: field.itemIdKey ?? DEFAULT_ITEM_ID_KEY,
7480
+ item
7481
+ });
7482
+ continue;
7483
+ }
7484
+ if (!("key" in field) || typeof field.key !== "string") continue;
7485
+ if (isKeychainStoredField(field)) out.set(field.key, LEAF);
7486
+ }
7487
+ }
7488
+ /** The secret tree a settings schema declares. */
7489
+ function secretTreeFromSchema(schema) {
7490
+ const out = /* @__PURE__ */ new Map();
7491
+ if (schema === null) return out;
7492
+ for (const section of schema.sections) collectFields(section.fields, out);
7493
+ return out;
7494
+ }
7495
+ /** Parse `a.b[id].c` into segments; throws on a malformed path (a declaration bug). */
7496
+ function parseSecretStatePath(path) {
7497
+ const segments = [];
7498
+ for (const raw of path.split(".")) {
7499
+ const m = /^([^[\]]+)(?:\[([^[\]]+)\])?$/.exec(raw);
7500
+ if (m === null || m[1] === void 0) throw new Error(`secretStatePaths: malformed path "${path}"`);
7501
+ segments.push(m[2] !== void 0 ? {
7502
+ key: m[1],
7503
+ idKey: m[2]
7504
+ } : { key: m[1] });
7505
+ }
7506
+ if (segments.length === 0) throw new Error(`secretStatePaths: empty path`);
7507
+ if (segments[segments.length - 1]?.idKey !== void 0) throw new Error(`secretStatePaths: "${path}" ends on an array — name the member that is secret`);
7508
+ return segments;
7509
+ }
7510
+ function insert(into, segments) {
7511
+ const [head, ...rest] = segments;
7512
+ if (head === void 0) return;
7513
+ if (rest.length === 0) {
7514
+ into.set(head.key, LEAF);
7515
+ return;
7516
+ }
7517
+ const existing = into.get(head.key);
7518
+ if (head.idKey !== void 0) {
7519
+ const item = new Map(existing?.kind === "array" ? existing.item : []);
7520
+ insert(item, rest);
7521
+ into.set(head.key, {
7522
+ kind: "array",
7523
+ idKey: head.idKey,
7524
+ item
7525
+ });
7526
+ return;
7527
+ }
7528
+ const children = new Map(existing?.kind === "object" ? existing.children : []);
7529
+ insert(children, rest);
7530
+ into.set(head.key, {
7531
+ kind: "object",
7532
+ children
7533
+ });
7534
+ }
7535
+ /** Add hidden-state paths (`secretStatePaths`) to a schema-derived tree. */
7536
+ function mergeSecretStatePaths(tree, paths) {
7537
+ if (paths.length === 0) return tree;
7538
+ const out = new Map(tree);
7539
+ for (const path of paths) insert(out, parseSecretStatePath(path));
7540
+ return out;
7541
+ }
7542
+ /** First retry of a secret the keychain could not serve; doubles to {@link SECRET_RETRY_MAX_MS}. */
7543
+ var SECRET_RETRY_FIRST_MS = 5e3;
7544
+ var SECRET_RETRY_MAX_MS = 5 * 6e4;
7545
+ /** Coalesces a burst of `keychain.changed` events into one re-resolve. */
7546
+ var SECRET_CHANGE_DEBOUNCE_MS = 250;
7011
7547
  /**
7012
7548
  * Base class for CamStack addons. Eliminates settings boilerplate:
7013
7549
  *
@@ -7077,6 +7613,25 @@ var BaseAddon = class {
7077
7613
  settingsStoreReady = false;
7078
7614
  /** Default config values. Provided via constructor. */
7079
7615
  defaults;
7616
+ /**
7617
+ * Hidden-state paths that hold secrets (D787) — values the addon writes
7618
+ * itself (`updateGlobalSettings`, `state()`) that no form field declares.
7619
+ * Stored in the keychain exactly like a `password` field. Syntax:
7620
+ * `'snapshotSigningKey'`, `'identity.pincode'`, `'tokens[userId].accessToken'`
7621
+ * (`key[<id field>]` addresses array items by id, never by index).
7622
+ */
7623
+ secretStatePaths = [];
7624
+ _addonSecretTree = null;
7625
+ _deviceSecretTree = null;
7626
+ /** Refs the last resolved config pointed at — a change to one re-resolves. */
7627
+ _configSecretRefs = /* @__PURE__ */ new Set();
7628
+ _unresolvedSecrets = [];
7629
+ _secretRetryTimer = null;
7630
+ _secretRetryDelayMs = SECRET_RETRY_FIRST_MS;
7631
+ _secretChangeTimer = null;
7632
+ _secretChangeUnsub = null;
7633
+ /** >0 while an OPERATOR's settings write is being applied. */
7634
+ _operatorWriteDepth = 0;
7080
7635
  constructor(defaults) {
7081
7636
  this.defaults = defaults;
7082
7637
  this._config = { ...defaults };
@@ -7112,8 +7667,18 @@ var BaseAddon = class {
7112
7667
  return this._config;
7113
7668
  }
7114
7669
  async initialize(context) {
7115
- this._ctx = context;
7670
+ const secrets = context.secrets;
7671
+ this._ctx = secrets !== void 0 ? withSecretAwareSettings(context, {
7672
+ secrets,
7673
+ addonTree: () => this.addonSecretTree(),
7674
+ deviceTree: () => this.deviceSecretTree(),
7675
+ onOrphaned: (refs) => context.logger.warn("keychain refs dropped by a settings write could not be deleted", { meta: { refs: [...refs] } }),
7676
+ isOperatorWrite: () => this._operatorWriteDepth > 0
7677
+ }) : context;
7116
7678
  await this.resolveConfig();
7679
+ if (secrets !== void 0) this._secretChangeUnsub = secrets.onChange((ref) => {
7680
+ if (this._configSecretRefs.has(ref)) this.scheduleSecretReresolve(SECRET_CHANGE_DEBOUNCE_MS);
7681
+ });
7117
7682
  const result = await this.onInitialize();
7118
7683
  this.emitLifecycle(EventCategory.AddonStarted);
7119
7684
  const normalized = normalizeAddonInitResult(result);
@@ -7146,6 +7711,12 @@ var BaseAddon = class {
7146
7711
  */
7147
7712
  async onHubReachable() {}
7148
7713
  async shutdown() {
7714
+ this._secretChangeUnsub?.();
7715
+ this._secretChangeUnsub = null;
7716
+ if (this._secretRetryTimer !== null) clearTimeout(this._secretRetryTimer);
7717
+ if (this._secretChangeTimer !== null) clearTimeout(this._secretChangeTimer);
7718
+ this._secretRetryTimer = null;
7719
+ this._secretChangeTimer = null;
7149
7720
  this.emitLifecycle(EventCategory.AddonStopped);
7150
7721
  if (this.autoEmitReadiness) this.emitReadinessForProviders("down");
7151
7722
  await this.onShutdown();
@@ -7224,7 +7795,7 @@ var BaseAddon = class {
7224
7795
  return hydrateSchema(schema, overlay ? {
7225
7796
  ...projected,
7226
7797
  ...overlay
7227
- } : projected);
7798
+ } : projected, { inlineSecretsAsViews: true });
7228
7799
  }
7229
7800
  /**
7230
7801
  * The integration-level view of this addon's settings: exactly the sections
@@ -7273,7 +7844,7 @@ var BaseAddon = class {
7273
7844
  return hydrateSchema({
7274
7845
  ...schema,
7275
7846
  sections
7276
- }, projected);
7847
+ }, projected, { inlineSecretsAsViews: true });
7277
7848
  }
7278
7849
  /**
7279
7850
  * The raw addon store PROJECTED onto the target node's bare per-node keys:
@@ -7327,18 +7898,50 @@ var BaseAddon = class {
7327
7898
  value: result.value[key]
7328
7899
  };
7329
7900
  }
7901
+ /**
7902
+ * The OPERATOR's write — a settings form or an admin API call, dispatched by
7903
+ * the kernel. Identical to {@link updateGlobalSettings}, except that a secret
7904
+ * the operator sends is stored as sent even when it equals a pre-keychain
7905
+ * inline value: the operator re-entering a password is a change, an addon
7906
+ * writing back what it read is not (D787).
7907
+ */
7908
+ async updateGlobalSettingsAsOperator(patch, nodeId) {
7909
+ this._operatorWriteDepth++;
7910
+ try {
7911
+ await this.applyGlobalPatch(patch, nodeId);
7912
+ } finally {
7913
+ this._operatorWriteDepth--;
7914
+ }
7915
+ }
7330
7916
  async updateGlobalSettings(patch, nodeId) {
7917
+ await this.applyGlobalPatch(patch, nodeId);
7918
+ }
7919
+ /**
7920
+ * REMOVE stored secrets — their keychain values and their markers (D787).
7921
+ *
7922
+ * Writing `''` to a secret field KEEPS what is stored (an empty string is
7923
+ * what a defaults fallback writes back, and it must never destroy a
7924
+ * credential), so code that means "forget this token" says so here. Without
7925
+ * a keychain (an older kernel) it writes `''`, as such code always did.
7926
+ */
7927
+ async clearSecrets(keys, nodeId) {
7928
+ const tree = this.addonSecretTree();
7929
+ const keychain = this._ctx?.secrets !== void 0;
7930
+ const patch = {};
7931
+ for (const key of keys) patch[key] = keychain && tree.has(key) ? SECRET_CLEAR : "";
7932
+ await this.applyGlobalPatch(patch, nodeId);
7933
+ }
7934
+ async applyGlobalPatch(barePatch, nodeId) {
7331
7935
  const keys = this.perNodeKeys();
7332
7936
  const localNode = normalizeNodeId(this._ctx?.kernel?.localNodeId);
7333
7937
  const target = normalizeNodeId(nodeId ?? this._ctx?.kernel?.localNodeId);
7334
- const barePatch = patch;
7335
7938
  const scoped = keys.size > 0 ? scopePatch(barePatch, keys, target) : barePatch;
7336
7939
  await this._ctx?.settings?.writeAddonStore(scoped);
7337
7940
  if (target !== localNode) return;
7338
7941
  await this.resolveConfig();
7339
7942
  await this.onConfigChanged();
7340
7943
  this.emitLifecycle(EventCategory.AddonUpdated, { level: "global" });
7341
- this.maybeAutoRestart(patch, this.globalSettingsSchema());
7944
+ this.maybeAutoRestart(Object.keys(barePatch), this.globalSettingsSchema());
7342
7945
  }
7343
7946
  /**
7344
7947
  * The set of field keys the global settings schema declares `perNode: true`
@@ -7363,7 +7966,7 @@ var BaseAddon = class {
7363
7966
  * time to return its response before the addon is torn down and
7364
7967
  * re-initialised by `AddonRegistryService.restartAddon`.
7365
7968
  */
7366
- maybeAutoRestart(patch, schema) {
7969
+ maybeAutoRestart(patchKeys, schema) {
7367
7970
  if (!schema) return;
7368
7971
  const restartKeys = /* @__PURE__ */ new Set();
7369
7972
  for (const section of schema.sections) for (const field of section.fields) {
@@ -7371,13 +7974,13 @@ var BaseAddon = class {
7371
7974
  if (field.requiresRestart) restartKeys.add(field.key);
7372
7975
  }
7373
7976
  if (restartKeys.size === 0) return;
7374
- if (!Object.keys(patch).some((k) => restartKeys.has(k))) return;
7977
+ if (!patchKeys.some((k) => restartKeys.has(k))) return;
7375
7978
  const ctx = this._ctx;
7376
7979
  if (!ctx) return;
7377
7980
  const addonId = ctx.id;
7378
7981
  setImmediate(() => {
7379
7982
  ctx.api.addons?.restartAddon?.mutate({ addonId }).then(() => {
7380
- ctx.logger.info("addon auto-restart triggered by restart-required setting change", { meta: { changedFields: Object.keys(patch).filter((k) => restartKeys.has(k)) } });
7983
+ ctx.logger.info("addon auto-restart triggered by restart-required setting change", { meta: { changedFields: patchKeys.filter((k) => restartKeys.has(k)) } });
7381
7984
  }).catch((err) => {
7382
7985
  ctx.logger.error("addon auto-restart failed", { meta: { error: err instanceof Error ? err.message : String(err) } });
7383
7986
  });
@@ -7386,7 +7989,7 @@ var BaseAddon = class {
7386
7989
  async getDeviceSettings(deviceId) {
7387
7990
  const schema = this.deviceSettingsSchema();
7388
7991
  if (!schema) return { sections: [] };
7389
- return hydrateSchema(schema, await this._ctx?.settings?.readDeviceStore(deviceId) ?? {});
7992
+ return hydrateSchema(schema, await this._ctx?.settings?.readDeviceStore(deviceId) ?? {}, { inlineSecretsAsViews: true });
7390
7993
  }
7391
7994
  async updateDeviceSettings(deviceId, patch) {
7392
7995
  await this._ctx?.settings?.writeDeviceStore(deviceId, patch);
@@ -7516,7 +8119,7 @@ var BaseAddon = class {
7516
8119
  * selection at boot (absent scoped key ⇒ the constructor default wins).
7517
8120
  */
7518
8121
  async resolveConfig() {
7519
- const stored = await this.readAddonStoreWithRetry();
8122
+ const stored = await this.resolveStoredSecrets(await this.readAddonStoreWithRetry());
7520
8123
  const perNode = this.perNodeKeys();
7521
8124
  const localNode = normalizeNodeId(this._ctx?.kernel?.localNodeId);
7522
8125
  const resolved = { ...this.defaults };
@@ -7541,7 +8144,7 @@ var BaseAddon = class {
7541
8144
  key,
7542
8145
  schema,
7543
8146
  fallback,
7544
- read: () => this.readAddonStoreWithRetry(),
8147
+ read: async () => this.resolveStoredSecrets(await this.readAddonStoreWithRetry()),
7545
8148
  write: async (patch) => {
7546
8149
  await this._ctx?.settings?.writeAddonStore(patch);
7547
8150
  },
@@ -7558,7 +8161,7 @@ var BaseAddon = class {
7558
8161
  key,
7559
8162
  schema,
7560
8163
  fallback,
7561
- read: async () => await this._ctx?.settings?.readDeviceStore(deviceId) ?? {},
8164
+ read: async () => this.resolveStoredSecrets(await this._ctx?.settings?.readDeviceStore(deviceId) ?? {}, false),
7562
8165
  write: async (patch) => {
7563
8166
  await this._ctx?.settings?.writeDeviceStore(deviceId, patch);
7564
8167
  },
@@ -7570,6 +8173,70 @@ var BaseAddon = class {
7570
8173
  } })
7571
8174
  });
7572
8175
  }
8176
+ /** The addon store's secret tree: schema fields by TYPE, plus `secretStatePaths`. */
8177
+ addonSecretTree() {
8178
+ this._addonSecretTree ??= mergeSecretStatePaths(secretTreeFromSchema(this.globalSettingsSchema()), this.secretStatePaths);
8179
+ return this._addonSecretTree;
8180
+ }
8181
+ deviceSecretTree() {
8182
+ this._deviceSecretTree ??= secretTreeFromSchema(this.deviceSettingsSchema());
8183
+ return this._deviceSecretTree;
8184
+ }
8185
+ /**
8186
+ * Secrets of this addon's stored config that could not be resolved on the
8187
+ * last read, with why. Non-empty means the addon is running WITHOUT them —
8188
+ * an addon whose function needs one should report itself degraded rather
8189
+ * than start on an empty credential.
8190
+ */
8191
+ get unresolvedSecrets() {
8192
+ return this._unresolvedSecrets;
8193
+ }
8194
+ /**
8195
+ * Substitute every keychain marker in a stored blob with its value. With no
8196
+ * keychain (no `ctx.secrets`) or no marker, the blob comes back unchanged.
8197
+ * An unresolvable value is LEFT OUT (never `''`), logged by ref — never by
8198
+ * value — and, when the cause can pass, retried with backoff. Nothing is
8199
+ * ever written back from here.
8200
+ */
8201
+ async resolveStoredSecrets(blob, trackForConfig = true) {
8202
+ const secrets = this._ctx?.secrets;
8203
+ if (secrets === void 0) return blob;
8204
+ const refs = collectSecretMarkerRefs(blob);
8205
+ if (trackForConfig) this._configSecretRefs = new Set(refs);
8206
+ if (refs.length === 0) {
8207
+ if (trackForConfig) this._unresolvedSecrets = [];
8208
+ return blob;
8209
+ }
8210
+ const { value, unresolved } = await resolveSecretMarkers(blob, secrets);
8211
+ if (trackForConfig) {
8212
+ this._unresolvedSecrets = unresolved;
8213
+ if (unresolved.length > 0) {
8214
+ this._ctx?.logger?.error?.("secret unavailable — running without it, will retry", { meta: { secrets: unresolved.map((u) => ({
8215
+ ref: u.ref,
8216
+ reason: u.reason
8217
+ })) } });
8218
+ if (unresolved.some((u) => u.reason !== "missing" && u.reason !== "forbidden")) {
8219
+ this.scheduleSecretReresolve(this._secretRetryDelayMs);
8220
+ this._secretRetryDelayMs = Math.min(this._secretRetryDelayMs * 2, SECRET_RETRY_MAX_MS);
8221
+ }
8222
+ } else this._secretRetryDelayMs = SECRET_RETRY_FIRST_MS;
8223
+ }
8224
+ return value;
8225
+ }
8226
+ /** Re-resolve the config (a keychain-only change, or a retry) and apply it. */
8227
+ scheduleSecretReresolve(delayMs) {
8228
+ const timerOf = delayMs === SECRET_CHANGE_DEBOUNCE_MS ? "_secretChangeTimer" : "_secretRetryTimer";
8229
+ if (this[timerOf] !== null) return;
8230
+ const timer = setTimeout(() => {
8231
+ this[timerOf] = null;
8232
+ if (this._ctx === null) return;
8233
+ this.resolveConfig().then(() => this.onConfigChanged()).catch((err) => {
8234
+ this._ctx?.logger?.error?.("re-resolving secrets failed", { meta: { error: err instanceof Error ? err.message : String(err) } });
8235
+ });
8236
+ }, delayMs);
8237
+ timer.unref?.();
8238
+ this[timerOf] = timer;
8239
+ }
7573
8240
  /**
7574
8241
  * Wrap `ctx.settings.readAddonStore()` with a short retry budget so a
7575
8242
  * transient settings-store outage (mid-restart of sqlite-settings, tsx-watch
@@ -8145,6 +8812,69 @@ method(object({ deviceId: number() }), array(StreamSourceEntrySchema)), method(o
8145
8812
  kind: "mutation",
8146
8813
  auth: "admin"
8147
8814
  }), method(object({ deviceId: number() }), unknown().nullable()), method(object({ deviceId: number() }), RawStateResultSchema.nullable(), { auth: "protected" });
8815
+ function defOf(schema) {
8816
+ return schema._zod?.def ?? {};
8817
+ }
8818
+ function declaredHere(schema) {
8819
+ return globalRegistry.get(schema)?.secret === true;
8820
+ }
8821
+ /** Wrapper kinds whose `innerType` is the field itself. */
8822
+ var WRAPPERS = new Set([
8823
+ "optional",
8824
+ "nullable",
8825
+ "default",
8826
+ "prefault",
8827
+ "catch",
8828
+ "readonly",
8829
+ "nonoptional"
8830
+ ]);
8831
+ /**
8832
+ * The schema layers that make up ONE field: the schema itself and every
8833
+ * wrapper below it (optional / default / nullable / readonly / catch), plus
8834
+ * both sides of a pipe (`z.preprocess` puts the real schema on `out`,
8835
+ * `.transform` on `in`).
8836
+ */
8837
+ function layersOf(schema) {
8838
+ const out = [];
8839
+ const queue = [schema];
8840
+ while (queue.length > 0) {
8841
+ const s = queue.shift();
8842
+ if (!s || out.includes(s)) continue;
8843
+ out.push(s);
8844
+ const def = defOf(s);
8845
+ if (def.type !== void 0 && WRAPPERS.has(def.type) && def.innerType) queue.push(def.innerType);
8846
+ if (def.type === "pipe") {
8847
+ if (def.in) queue.push(def.in);
8848
+ if (def.out) queue.push(def.out);
8849
+ }
8850
+ }
8851
+ return out;
8852
+ }
8853
+ /** True when any layer of this field declares `.meta({ secret: true })`. */
8854
+ function isZodSecret(schema) {
8855
+ return layersOf(schema).some(declaredHere);
8856
+ }
8857
+ /**
8858
+ * Every declared secret path in a config schema: dotted keys, `[]` for "each
8859
+ * element of this array" (`connection.password`, `rows[].token`). A declared
8860
+ * object or array is reported as one path and not descended into — everything
8861
+ * under it is secret.
8862
+ */
8863
+ function collectZodSecretPaths(schema, prefix = "") {
8864
+ if (isZodSecret(schema)) return prefix.length > 0 ? [prefix] : [];
8865
+ const paths = [];
8866
+ for (const layer of layersOf(schema)) {
8867
+ const def = defOf(layer);
8868
+ if (def.type === "object" && def.shape) for (const [key, child] of Object.entries(def.shape)) paths.push(...collectZodSecretPaths(child, prefix ? `${prefix}.${key}` : key));
8869
+ else if (def.type === "array" && def.element) paths.push(...collectZodSecretPaths(def.element, `${prefix}[]`));
8870
+ else if (def.type === "union" && def.options) for (const option of def.options) paths.push(...collectZodSecretPaths(option, prefix));
8871
+ else if (def.type === "intersection") {
8872
+ if (def.left) paths.push(...collectZodSecretPaths(def.left, prefix));
8873
+ if (def.right) paths.push(...collectZodSecretPaths(def.right, prefix));
8874
+ }
8875
+ }
8876
+ return [...new Set(paths)];
8877
+ }
8148
8878
  //#endregion
8149
8879
  //#region ../types/dist/err-msg-DX6i_MY4.mjs
8150
8880
  var DeviceType = /* @__PURE__ */ function(DeviceType) {
@@ -15175,6 +15905,196 @@ id: union([string(), number()]) }), {
15175
15905
  kind: "mutation",
15176
15906
  auth: "admin"
15177
15907
  });
15908
+ /**
15909
+ * `keychain` — the hub's encrypted store of secret values (D787).
15910
+ *
15911
+ * Settings blobs never hold a secret: they hold a marker
15912
+ * `{"$secret":"secret://<owner>/<scope>/<fieldPath>","v":1}` and the value
15913
+ * lives here, AES-256-GCM under a data key that a master key wraps. This cap
15914
+ * is the OWNER's door to its own values: every method is owner-checked
15915
+ * against the CALLER, never against anything the caller claims.
15916
+ *
15917
+ * Who the caller is: the transport stamps `callerAddonId` into the args of a
15918
+ * call that crossed a process (the parent `LocalChildRegistry` from the UDS
15919
+ * connection, the agent from its child's connection carried in
15920
+ * `$hub-cap-fwd`'s envelope). A stamp always overwrites; a wire call with no
15921
+ * stamp has its claim stripped. Only a hub in-process caller may state its own
15922
+ * identity — `ctx.secrets` does that with the addon id closed over. This is
15923
+ * identity against BUGS and misrouting, not against a malicious addon (every
15924
+ * runner is the same OS user): see the threat model in
15925
+ * `docs/design/2026-10-08-secrets-keychain.md`.
15926
+ *
15927
+ * `callerAddonId` is deliberately NOT in any input schema: the tRPC router
15928
+ * parses the input, so a session can never supply it, and the internal mount
15929
+ * floors every method to admin anyway (D240).
15930
+ *
15931
+ * Internal: addons reach it through `ctx.secrets`, never directly.
15932
+ */
15933
+ /** Why a value cannot be served right now. Never folded into "missing". */
15934
+ var KeychainUnavailableReasonSchema = _enum([
15935
+ "key-missing",
15936
+ "wrong-key",
15937
+ "key-file-unreadable",
15938
+ "store-unavailable",
15939
+ "not-initialized",
15940
+ "decrypt-failed"
15941
+ ]);
15942
+ var KeychainStateSchema = discriminatedUnion("state", [object({ state: literal("ready") }), object({
15943
+ state: literal("locked"),
15944
+ reason: KeychainUnavailableReasonSchema
15945
+ })]);
15946
+ var KeychainResolveEntrySchema = discriminatedUnion("kind", [
15947
+ object({
15948
+ kind: literal("value"),
15949
+ value: string(),
15950
+ version: number().int()
15951
+ }),
15952
+ object({ kind: literal("missing") }),
15953
+ object({
15954
+ kind: literal("unavailable"),
15955
+ reason: KeychainUnavailableReasonSchema
15956
+ }),
15957
+ object({ kind: literal("forbidden") })
15958
+ ]);
15959
+ var KeychainResolveResultSchema = record(string(), KeychainResolveEntrySchema);
15960
+ /** Metadata of one stored value — never the value. */
15961
+ var KeychainSecretMetaSchema = object({
15962
+ ref: string(),
15963
+ owner: string(),
15964
+ /** Formatted scope (`global`, `node/<id>`, `device/<id>`, …). */
15965
+ scope: string(),
15966
+ fieldPath: string(),
15967
+ version: number().int(),
15968
+ createdAt: number(),
15969
+ updatedAt: number(),
15970
+ /** `addon:<id>` | `user:<id>` | `system`. */
15971
+ updatedBy: string(),
15972
+ /** Coarse — written at most once an hour per ref. `null` = never read. */
15973
+ lastReadAt: number().nullable()
15974
+ });
15975
+ var RefListSchema = array(string().min(1)).max(512);
15976
+ method(object({
15977
+ ref: string().min(1),
15978
+ value: string().min(1)
15979
+ }), object({
15980
+ ref: string(),
15981
+ version: number().int()
15982
+ }), {
15983
+ kind: "mutation",
15984
+ auth: "admin"
15985
+ }), method(object({ refs: RefListSchema }), KeychainResolveResultSchema, { auth: "admin" }), method(object({ refs: RefListSchema }), object({ deleted: number().int() }), {
15986
+ kind: "mutation",
15987
+ auth: "admin"
15988
+ }), method(object({}), array(KeychainSecretMetaSchema).readonly(), { auth: "admin" }), method(object({}), KeychainStateSchema, { auth: "admin" });
15989
+ var KeychainKeySourceSchema = object({
15990
+ kind: _enum([
15991
+ "config-file",
15992
+ "previous-config-file",
15993
+ "platform",
15994
+ "default-file"
15995
+ ]),
15996
+ /** File sources only — a path is not a secret. */
15997
+ path: string().optional(),
15998
+ /**
15999
+ * True when a whole-volume backup of the data directory carries this key
16000
+ * next to the database it protects (the default file). The page warns.
16001
+ */
16002
+ sharesBackupWithDatabase: boolean()
16003
+ });
16004
+ var KeychainStatusSchema = object({
16005
+ keychain: KeychainStateSchema,
16006
+ /** The source of the master key in use; `null` while locked. */
16007
+ keySource: KeychainKeySourceSchema.nullable(),
16008
+ /** The source configured to be primary — differs from `keySource` while a rotation is pending. */
16009
+ configuredSource: KeychainKeySourceSchema,
16010
+ /** Short fingerprint of the master key in use (`HMAC(KEK, label)`, 16 hex). */
16011
+ fingerprint: string().nullable(),
16012
+ activeKeyId: string().nullable(),
16013
+ /**
16014
+ * The keychain unlocked with a NON-primary source: the configured primary
16015
+ * key is not the one that wraps the data key yet. `rotateMasterKey` moves it.
16016
+ */
16017
+ rotationPending: boolean(),
16018
+ /** Wrapped copies of the data key under a previous master key, kept until purged. */
16019
+ retiredWraps: number().int(),
16020
+ recoveryKeyDownloadedAt: number().nullable(),
16021
+ secretCount: number().int()
16022
+ });
16023
+ /**
16024
+ * Whether a stored value is still pointed at by its owner's settings.
16025
+ * `unknown` is a first-class answer: a scope whose blob could not be read is
16026
+ * never reported as an orphan (and never deleted as one).
16027
+ */
16028
+ var KeychainSecretUsageSchema = _enum([
16029
+ "in-use",
16030
+ "orphan",
16031
+ "unknown"
16032
+ ]);
16033
+ var KeychainAdminSecretSchema = KeychainSecretMetaSchema.extend({ usage: KeychainSecretUsageSchema });
16034
+ var KeychainAuditActionSchema = _enum([
16035
+ "put",
16036
+ "delete",
16037
+ "reveal",
16038
+ "rotate-master-key",
16039
+ "purge-retired-keys",
16040
+ "download-recovery-key",
16041
+ "delete-orphans",
16042
+ "reset",
16043
+ "initialize"
16044
+ ]);
16045
+ var KeychainAuditEntrySchema = object({
16046
+ id: string(),
16047
+ at: number(),
16048
+ action: KeychainAuditActionSchema,
16049
+ /** `addon:<id>` | `user:<id>` | `system`. */
16050
+ actor: string(),
16051
+ ref: string().nullable(),
16052
+ detail: string().nullable()
16053
+ });
16054
+ 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({
16055
+ value: string(),
16056
+ version: number().int()
16057
+ }), {
16058
+ kind: "mutation",
16059
+ auth: "admin",
16060
+ caller: "required"
16061
+ }), method(object({ refs: array(string().min(1)).max(1e3) }), object({
16062
+ deleted: array(string()).readonly(),
16063
+ kept: array(object({
16064
+ ref: string(),
16065
+ usage: KeychainSecretUsageSchema
16066
+ })).readonly()
16067
+ }), {
16068
+ kind: "mutation",
16069
+ auth: "admin",
16070
+ caller: "required"
16071
+ }), method(object({}), object({
16072
+ fingerprint: string(),
16073
+ keySource: KeychainKeySourceSchema
16074
+ }), {
16075
+ kind: "mutation",
16076
+ auth: "admin",
16077
+ caller: "required"
16078
+ }), method(object({}), object({ purged: number().int() }), {
16079
+ kind: "mutation",
16080
+ auth: "admin",
16081
+ caller: "required"
16082
+ }), method(object({}), object({
16083
+ key: string(),
16084
+ fingerprint: string(),
16085
+ keySource: KeychainKeySourceSchema
16086
+ }), {
16087
+ kind: "mutation",
16088
+ auth: "admin",
16089
+ caller: "required"
16090
+ }), method(object({ confirm: literal("RESET KEYCHAIN") }), object({
16091
+ archivedCollection: string().nullable(),
16092
+ archived: number().int()
16093
+ }), {
16094
+ kind: "mutation",
16095
+ auth: "admin",
16096
+ caller: "required"
16097
+ });
15178
16098
  method(_void(), object({
15179
16099
  id: string(),
15180
16100
  name: string(),
@@ -16197,6 +17117,10 @@ var DeviceInfoSchema = object({
16197
17117
  isCamera: boolean(),
16198
17118
  /** Current config values — serializable snapshot */
16199
17119
  config: record(string(), unknown()),
17120
+ /** Paths inside `config` the device's schema declares secret (D783) —
17121
+ * what the non-admin redaction withholds. Paths, never values. Absent
17122
+ * when the owning runner has not reported them. */
17123
+ secretConfigPaths: array(string()).optional(),
16200
17124
  /** Hardware + identity blob (manufacturer / model / firmware / sn /
16201
17125
  * uid / mac / …). Populated by drivers; editable via setMetadata. */
16202
17126
  metadata: record(string(), unknown()).nullable().optional(),
@@ -16402,12 +17326,22 @@ var DeviceRegisterPayloadSchema = object({
16402
17326
  * call (workers re-register on init), so probe-driven updates
16403
17327
  * (e.g. PTZ flag flipping after the abilities probe) propagate. */
16404
17328
  features: array(string()).optional(),
16405
- config: record(string(), unknown())
17329
+ config: record(string(), unknown()),
17330
+ /** Config paths the device's own schema DECLARES secret
17331
+ * (`.meta({ secret: true })` — dotted, `[]` for array items, e.g.
17332
+ * `connection.password`). Re-published on every register; the non-admin
17333
+ * redaction withholds them at any depth (D783). Optional: an older runner
17334
+ * omits it and the keyword backstop applies. */
17335
+ secretConfigPaths: array(string()).optional()
16406
17336
  });
16407
17337
  var DeviceRemovePayloadSchema = object({ deviceId: number() });
16408
17338
  var DevicePersistConfigPayloadSchema = object({
16409
17339
  deviceId: number(),
16410
- data: record(string(), unknown())
17340
+ data: record(string(), unknown()),
17341
+ /** The paths the device's schema declares secret (D783), when the caller
17342
+ * knows them — those values are kept in the keychain, not the blob (D787).
17343
+ * Absent: the paths the device last reported at `registerDevice` apply. */
17344
+ secretConfigPaths: array(string()).optional()
16411
17345
  });
16412
17346
  /** What a migration actually did, per switch. `unreachable` is a first-class
16413
17347
  * answer: a camera that could not be asked is not a camera that was silenced. */
@@ -18061,7 +18995,14 @@ var LoginMethodContributionSchema = discriminatedUnion("kind", [
18061
18995
  icon: string().optional(),
18062
18996
  /** Addon-owned HTTP route the button navigates to (GET). */
18063
18997
  startUrl: string(),
18064
- stage: LoginStageEnum
18998
+ stage: LoginStageEnum,
18999
+ /**
19000
+ * The provider names an external identity a signed-in user can link to
19001
+ * their own account (D782): `auth.listLinkableProviders` /
19002
+ * `beginExternalLink` offer exactly the redirect methods that set this,
19003
+ * whatever their id. Absent / false — a login button only (magic-link).
19004
+ */
19005
+ linkable: boolean().optional()
18065
19006
  }),
18066
19007
  object({
18067
19008
  kind: literal("widget"),
@@ -23417,8 +24358,23 @@ var RetrainMacroClassSchema = _enum([
23417
24358
  ]);
23418
24359
  /** A subject to learn, or a phantom to unlearn (taught by OMISSION). */
23419
24360
  var RetrainAnnotationKindSchema = _enum(["subject", "model_error"]);
23420
- /** Did a human draw this box, or did the assist propose it? */
23421
- var RetrainAnnotationSourceSchema = _enum(["operator", "assist"]);
24361
+ /**
24362
+ * Where a box came from. A machine-sourced box is a DRAFT on the page until
24363
+ * the operator confirms it; once saved it keeps its source as provenance.
24364
+ *
24365
+ * - `operator` — drawn by hand.
24366
+ * - `assist` — proposed by a detector run on the copy (the camera's own
24367
+ * model, or a larger teacher model).
24368
+ * - `pipeline` — the box the live pipeline actually drew on that frame, read
24369
+ * back from the track store (never a re-run).
24370
+ * - `llm` — proposed by a vision-capable LLM profile.
24371
+ */
24372
+ var RetrainAnnotationSourceSchema = _enum([
24373
+ "operator",
24374
+ "assist",
24375
+ "pipeline",
24376
+ "llm"
24377
+ ]);
23422
24378
  /** Normalised `[0,1]` rectangle against the FULL frame — the canonical form. */
23423
24379
  var RetrainBboxSchema = object({
23424
24380
  x: number(),
@@ -23436,7 +24392,8 @@ var RetrainBboxSchema = object({
23436
24392
  */
23437
24393
  var RetrainAnnotationSchema = object({
23438
24394
  id: string(),
23439
- trackId: string(),
24395
+ /** The frame's track. Absent on a recording still, which has none. */
24396
+ trackId: string().optional(),
23440
24397
  deviceId: number(),
23441
24398
  /** The COPY in retrain storage — never the source track's media key. */
23442
24399
  mediaKey: string(),
@@ -23485,18 +24442,63 @@ var RetrainFrameCandidateSchema = object({
23485
24442
  * fail, whatever became of the original. */
23486
24443
  copied: boolean()
23487
24444
  });
24445
+ /**
24446
+ * One box the live pipeline drew on a copied frame — what a correction starts
24447
+ * from. Derived when the frame is listed, from the track store: the subject
24448
+ * box recorded on the source media row when there is one, else the track
24449
+ * position nearest the frame's capture time. Never stored as an annotation
24450
+ * until the operator confirms it.
24451
+ */
24452
+ var RetrainPipelineBoxSchema = object({
24453
+ /** Normalised `[0,1]` against the full frame. */
24454
+ bbox: RetrainBboxSchema,
24455
+ macroClass: RetrainMacroClassSchema,
24456
+ label: string().optional(),
24457
+ subLabel: string().optional(),
24458
+ /** The detection score of the position used, when it was recorded. */
24459
+ score: number().optional(),
24460
+ /** The root model that produced the track, when it was recorded. */
24461
+ modelId: string().optional(),
24462
+ trackId: string(),
24463
+ /** `subject-box`: recorded on this very frame. `position`: the track's
24464
+ * position nearest the capture time, `deltaMs` away. */
24465
+ basis: _enum(["subject-box", "position"]),
24466
+ deltaMs: number()
24467
+ });
24468
+ /**
24469
+ * Where a retrain frame came from: a TRACK's stored media (copy-on-select),
24470
+ * or the RECORDING at an instant — the frame a model saw nothing in has no
24471
+ * track at all.
24472
+ */
24473
+ var RetrainFrameOriginSchema = _enum(["track", "recording"]);
23488
24474
  /** A frame the dataset OWNS: bytes copied at selection time. */
23489
24475
  var RetrainFrameSchema = object({
23490
24476
  frameId: string(),
23491
24477
  deviceId: number(),
23492
- trackId: string(),
23493
- /** Provenance only. It may already point at nothing — that is expected. */
23494
- sourceMediaId: number().int(),
24478
+ origin: RetrainFrameOriginSchema,
24479
+ /** The track it was copied from. Absent on a recording still. */
24480
+ trackId: string().optional(),
24481
+ /** Provenance only. It may already point at nothing — that is expected.
24482
+ * Absent on a recording still. */
24483
+ sourceMediaId: number().int().optional(),
24484
+ /** A recording still: the playhead instant it was taken at. */
24485
+ epochMs: number().optional(),
23495
24486
  sourceKind: MediaFileKindEnum,
23496
24487
  sizeBytes: number().int(),
23497
24488
  width: number().int(),
23498
24489
  height: number().int(),
23499
- copiedAt: number()
24490
+ copiedAt: number(),
24491
+ /** When the CAMERA captured the frame. Absent on a copy taken before D785. */
24492
+ capturedAt: number().optional(),
24493
+ /** The operator's "every subject in this frame is boxed". Detector
24494
+ * evaluation keeps only complete frames: an unboxed subject would count as
24495
+ * a false positive. */
24496
+ complete: boolean(),
24497
+ /** The boxes the pipeline drew on this frame. Present on list answers;
24498
+ * empty when nothing the track store holds can be placed on it. */
24499
+ pipelineBoxes: array(RetrainPipelineBoxSchema).readonly().optional(),
24500
+ /** The named collections this frame belongs to. Present on list answers. */
24501
+ collectionIds: array(string()).readonly().optional()
23500
24502
  });
23501
24503
  /** Why a copy-on-select could not be honoured — named, never a silent skip. */
23502
24504
  var RetrainCopyRefusalSchema = _enum([
@@ -23517,6 +24519,53 @@ var RetrainFrameListSchema = object({
23517
24519
  /** What the page pre-selects — the native key frame when one survives. */
23518
24520
  autoPickMediaId: number().int().optional()
23519
24521
  });
24522
+ /**
24523
+ * Which frames an annotated export carries. Every field narrows; an empty
24524
+ * filter is every annotated copy. A dataset VERSION is a frozen `frameIds`
24525
+ * list owned by whoever trains (the training orchestrator), so `frameIds` is
24526
+ * the primitive a version export uses; `batchId` re-selects what an earlier
24527
+ * export carried (`exportedInBatch`).
24528
+ */
24529
+ var RetrainExportFilterSchema = object({
24530
+ deviceIds: array(number()).optional(),
24531
+ frameIds: array(string()).max(2e4).optional(),
24532
+ /** Only frames in at least one of these named collections. */
24533
+ collectionIds: array(string()).max(200).optional(),
24534
+ batchId: string().optional(),
24535
+ /** Only frames the operator marked complete (all subjects boxed). */
24536
+ completeOnly: boolean().optional()
24537
+ });
24538
+ /**
24539
+ * `frames`: the full frame copies, boxes in `annotations.json`.
24540
+ * `crops`: additionally one JPEG per subject, cut with the runtime detail-crop
24541
+ * convention — the classifier layout.
24542
+ */
24543
+ var RetrainExportLayoutSchema = _enum(["frames", "crops"]);
24544
+ /**
24545
+ * Where `writeRetrainArchive` streams the tar: one HTTP request whose body is
24546
+ * the archive, sent chunk by chunk. Covers a presigned PUT and a provider
24547
+ * addon's data-plane upload route alike. Headers are sent verbatim and never
24548
+ * logged.
24549
+ */
24550
+ var RetrainArchiveTargetSchema = object({
24551
+ kind: literal("http"),
24552
+ method: _enum(["PUT", "POST"]),
24553
+ url: string().url(),
24554
+ headers: record(string(), string()).optional()
24555
+ });
24556
+ var RetrainArchiveResultSchema = object({
24557
+ batchId: string(),
24558
+ frames: number().int(),
24559
+ crops: number().int(),
24560
+ annotations: number().int(),
24561
+ /** Frames planned but not shipped (unreadable copy, path too long). */
24562
+ missing: number().int(),
24563
+ bytes: number().int(),
24564
+ /** sha256 of the exact bytes sent. */
24565
+ sha256: string(),
24566
+ /** The target's HTTP status. */
24567
+ status: number().int()
24568
+ });
23520
24569
  /** What the operator asked the assist to look for. */
23521
24570
  var RetrainAssistSubjectSchema = discriminatedUnion("kind", [object({
23522
24571
  kind: literal("package"),
@@ -23546,6 +24595,109 @@ var RetrainAssistResultSchema = discriminatedUnion("kind", [object({
23546
24595
  reason: string(),
23547
24596
  detail: string().optional()
23548
24597
  })]);
24598
+ /** A named set over the retrain corpus — membership only, it owns no pixels. */
24599
+ var RetrainCollectionSchema = object({
24600
+ id: string(),
24601
+ name: string(),
24602
+ createdAt: number(),
24603
+ frameCount: number().int()
24604
+ });
24605
+ var RetrainCollectionCreateResultSchema = discriminatedUnion("kind", [object({
24606
+ kind: literal("created"),
24607
+ collection: RetrainCollectionSchema
24608
+ }), object({
24609
+ kind: literal("refused"),
24610
+ reason: _enum(["empty-name", "duplicate-name"])
24611
+ })]);
24612
+ var RetrainCollectionRenameResultSchema = discriminatedUnion("kind", [object({
24613
+ kind: literal("renamed"),
24614
+ collection: RetrainCollectionSchema
24615
+ }), object({
24616
+ kind: literal("refused"),
24617
+ reason: _enum([
24618
+ "empty-name",
24619
+ "duplicate-name",
24620
+ "unknown-collection"
24621
+ ])
24622
+ })]);
24623
+ /**
24624
+ * The outcome of adding the frame at a recording instant. Every refusal is
24625
+ * named: `still-unavailable` (not recording, a gap, or an undecodable frame —
24626
+ * `detail` says which), `still-busy` (the recorder is at its decode bound; try
24627
+ * again), `unreadable-image`, `write-failed`, `unknown-collection`.
24628
+ */
24629
+ var AddRetrainFrameFromRecordingResultSchema = discriminatedUnion("kind", [object({
24630
+ kind: literal("added"),
24631
+ collectionId: string(),
24632
+ frame: RetrainFrameSchema,
24633
+ /** The moment was already in the dataset; nothing was decoded. */
24634
+ reused: boolean()
24635
+ }), object({
24636
+ kind: literal("refused"),
24637
+ reason: _enum([
24638
+ "unknown-collection",
24639
+ "still-unavailable",
24640
+ "still-busy",
24641
+ "unreadable-image",
24642
+ "write-failed"
24643
+ ]),
24644
+ detail: string().optional()
24645
+ })]);
24646
+ /** A vision LLM profile the AI assist may use, and where it sends the frame. */
24647
+ var RetrainAssistProfileSchema = object({
24648
+ id: string(),
24649
+ name: string(),
24650
+ model: string(),
24651
+ kind: string(),
24652
+ /** `true` when the frame would leave the house (a cloud vendor, or an
24653
+ * endpoint that is not on the local network). The page confirms each such
24654
+ * run, and the provider refuses one without `allowCloud`. */
24655
+ leavesHouse: boolean()
24656
+ });
24657
+ /** A box the AI assist proposed: a draft, plus the model's own reason. */
24658
+ var RetrainLlmProposalSchema = RetrainAnnotationDraftSchema.extend({ reason: string() });
24659
+ /** What the AI assist said about a box that was already on the canvas. */
24660
+ var RetrainLlmReviewSchema = object({
24661
+ /** The `ref` the page sent the box under. */
24662
+ ref: string(),
24663
+ verdict: _enum([
24664
+ "confirmed",
24665
+ "wrong-class",
24666
+ "not-an-object",
24667
+ "uncertain"
24668
+ ]),
24669
+ suggestedClass: RetrainMacroClassSchema.optional(),
24670
+ reason: string()
24671
+ });
24672
+ /**
24673
+ * The AI assist's answer. `proposed` carries drafts (`source: 'llm'`, the
24674
+ * model and its confidence) and reviews; items the model got wrong (a box off
24675
+ * the frame, an unasked class, an unknown ref) are dropped and counted in
24676
+ * `rejected`. A whole answer that is not the schema is `malformed-answer`.
24677
+ */
24678
+ var RetrainLlmAssistResultSchema = discriminatedUnion("kind", [object({
24679
+ kind: literal("proposed"),
24680
+ profileId: string(),
24681
+ model: string(),
24682
+ /** The frame was sent outside the house for this answer. */
24683
+ leftHouse: boolean(),
24684
+ proposals: array(RetrainLlmProposalSchema).readonly(),
24685
+ reviews: array(RetrainLlmReviewSchema).readonly(),
24686
+ rejected: number().int()
24687
+ }), object({
24688
+ kind: literal("refused"),
24689
+ reason: _enum([
24690
+ "unknown-frame",
24691
+ "unreadable-frame",
24692
+ "unknown-profile",
24693
+ "profile-disabled",
24694
+ "no-vision",
24695
+ "cloud-not-confirmed",
24696
+ "llm-error",
24697
+ "malformed-answer"
24698
+ ]),
24699
+ detail: string().optional()
24700
+ })]);
23549
24701
  /** The outcome of a lifecycle move owned by the retrain page. */
23550
24702
  var RetrainTransitionResultSchema = object({
23551
24703
  trackId: string(),
@@ -24263,7 +25415,7 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
24263
25415
  auth: "admin"
24264
25416
  }), method(object({
24265
25417
  deviceId: number(),
24266
- trackId: string(),
25418
+ trackId: string().optional(),
24267
25419
  frameId: string()
24268
25420
  }), object({
24269
25421
  removed: boolean(),
@@ -24280,7 +25432,8 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
24280
25432
  auth: "admin"
24281
25433
  }), method(object({
24282
25434
  deviceId: number(),
24283
- trackId: string(),
25435
+ /** The frame's track, when it has one — checked against the frame. */
25436
+ trackId: string().optional(),
24284
25437
  frameId: string(),
24285
25438
  subject: RetrainAssistSubjectSchema,
24286
25439
  /** Which node runs it. Absent ⇒ wherever an unowned call lands. */
@@ -24288,12 +25441,16 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
24288
25441
  }), RetrainAssistResultSchema, {
24289
25442
  kind: "mutation",
24290
25443
  auth: "admin"
24291
- }), method(object({ trackId: string() }), array(RetrainAnnotationSchema).readonly(), {
25444
+ }), method(object({
25445
+ trackId: string().optional(),
25446
+ frameIds: array(string()).max(2e3).optional()
25447
+ }), array(RetrainAnnotationSchema).readonly(), {
24292
25448
  kind: "query",
24293
25449
  auth: "admin"
24294
25450
  }), method(object({
24295
25451
  deviceId: number(),
24296
- trackId: string(),
25452
+ /** The frame's track, when it has one — checked against the frame. */
25453
+ trackId: string().optional(),
24297
25454
  frameId: string(),
24298
25455
  annotations: array(RetrainAnnotationDraftSchema)
24299
25456
  }), array(RetrainAnnotationSchema).readonly(), {
@@ -24311,7 +25468,91 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
24311
25468
  }), RetrainTransitionResultSchema, {
24312
25469
  kind: "mutation",
24313
25470
  auth: "admin"
24314
- }), method(object({ deviceIds: array(number()).optional() }), object({ url: string() }), {
25471
+ }), method(RetrainExportFilterSchema.extend({ layout: RetrainExportLayoutSchema.optional() }), object({ url: string() }), {
25472
+ kind: "query",
25473
+ auth: "admin"
25474
+ }), method(object({
25475
+ deviceId: number(),
25476
+ trackId: string().optional(),
25477
+ frameId: string(),
25478
+ complete: boolean()
25479
+ }), RetrainFrameSchema, {
25480
+ kind: "mutation",
25481
+ auth: "admin"
25482
+ }), method(object({
25483
+ filter: RetrainExportFilterSchema,
25484
+ layout: RetrainExportLayoutSchema,
25485
+ target: RetrainArchiveTargetSchema
25486
+ }), RetrainArchiveResultSchema, {
25487
+ kind: "mutation",
25488
+ auth: "admin",
25489
+ timeoutMs: 60 * 6e4
25490
+ }), method(object({}), array(RetrainAssistProfileSchema).readonly(), {
25491
+ kind: "query",
25492
+ auth: "admin"
25493
+ }), method(object({
25494
+ deviceId: number(),
25495
+ trackId: string().optional(),
25496
+ frameId: string(),
25497
+ profileId: string(),
25498
+ classes: array(RetrainMacroClassSchema).min(1),
25499
+ boxes: array(object({
25500
+ ref: string(),
25501
+ bbox: RetrainBboxSchema,
25502
+ macroClass: RetrainMacroClassSchema,
25503
+ label: string().optional()
25504
+ })).max(50),
25505
+ allowCloud: boolean()
25506
+ }), RetrainLlmAssistResultSchema, {
25507
+ kind: "mutation",
25508
+ auth: "admin",
25509
+ timeoutMs: 18e4
25510
+ }), method(object({ name: string().max(120) }), RetrainCollectionCreateResultSchema, {
25511
+ kind: "mutation",
25512
+ auth: "admin"
25513
+ }), method(object({}), array(RetrainCollectionSchema).readonly(), {
25514
+ kind: "query",
25515
+ auth: "admin"
25516
+ }), method(object({
25517
+ id: string(),
25518
+ name: string().max(120)
25519
+ }), RetrainCollectionRenameResultSchema, {
25520
+ kind: "mutation",
25521
+ auth: "admin"
25522
+ }), method(object({ id: string() }), object({
25523
+ deleted: boolean(),
25524
+ removedFrames: number().int()
25525
+ }), {
25526
+ kind: "mutation",
25527
+ auth: "admin"
25528
+ }), method(object({
25529
+ collectionId: string(),
25530
+ deviceId: number(),
25531
+ epochMs: number()
25532
+ }), AddRetrainFrameFromRecordingResultSchema, {
25533
+ kind: "mutation",
25534
+ auth: "admin",
25535
+ timeoutMs: 6e4
25536
+ }), method(object({
25537
+ collectionId: string(),
25538
+ frameIds: array(string()).min(1).max(500)
25539
+ }), object({
25540
+ added: number().int(),
25541
+ alreadyMember: number().int(),
25542
+ unknownFrameIds: array(string()).readonly()
25543
+ }), {
25544
+ kind: "mutation",
25545
+ auth: "admin"
25546
+ }), method(object({
25547
+ collectionId: string(),
25548
+ frameId: string()
25549
+ }), object({
25550
+ removed: boolean(),
25551
+ deletedFrame: boolean()
25552
+ }), {
25553
+ kind: "mutation",
25554
+ auth: "admin"
25555
+ }), method(object({ collectionId: string() }), array(RetrainFrameSchema).readonly(), {
24315
25556
  kind: "query",
24316
25557
  auth: "admin"
24317
25558
  }), method(object({
@@ -24937,13 +26178,31 @@ var RecommendationReasonSchema = discriminatedUnion("kind", [
24937
26178
  object({
24938
26179
  kind: literal("no-family-build"),
24939
26180
  format: ModelFormatSchema$1
26181
+ }),
26182
+ object({
26183
+ kind: literal("kept-custom-pin"),
26184
+ modelId: string(),
26185
+ deviceKey: string()
24940
26186
  })
24941
26187
  ]);
26188
+ /** Why a device is left exactly as it is, whatever the plan would pick (D786). */
26189
+ var KeptReasonSchema = _enum(["custom-pin"]);
26190
+ /**
26191
+ * Where a choice's latency came from (D791): this node's own benchmark
26192
+ * result, or the hardware-class table. Measured on the node beats the table.
26193
+ */
26194
+ var LatencySourceSchema = discriminatedUnion("kind", [object({ kind: literal("table") }), object({
26195
+ kind: literal("node-benchmark"),
26196
+ resultId: string(),
26197
+ measuredAtMs: number()
26198
+ })]);
24942
26199
  var DeviceModelChoiceSchema = object({
24943
26200
  modelId: string(),
24944
26201
  p50Ms: number(),
24945
26202
  fps: number(),
24946
26203
  measured: boolean(),
26204
+ /** Absent on a plan from before D791 — read as the table. */
26205
+ source: LatencySourceSchema.optional(),
24947
26206
  /** Parallel sessions at the camera rate with the headroom kept free: ⌊fps × (1 − headroom) / camera fps⌋. */
24948
26207
  capacitySessions: number(),
24949
26208
  personRecall: number()
@@ -24954,6 +26213,8 @@ var DeviceRecommendationSchema = object({
24954
26213
  enabled: boolean(),
24955
26214
  available: boolean(),
24956
26215
  chosen: DeviceModelChoiceSchema.nullable(),
26216
+ /** Present when the device is kept as is: Apply writes nothing on it. */
26217
+ kept: KeptReasonSchema.optional(),
24957
26218
  reasons: array(RecommendationReasonSchema).readonly()
24958
26219
  });
24959
26220
  var NodeRecommendationSchema = object({
@@ -25007,6 +26268,17 @@ var AutoTuneWarningSchema = discriminatedUnion("kind", [
25007
26268
  kind: literal("coral-enabled"),
25008
26269
  nodeId: string(),
25009
26270
  deviceKey: string()
26271
+ }),
26272
+ object({
26273
+ kind: literal("custom-pin-kept"),
26274
+ nodeId: string(),
26275
+ deviceKey: string().nullable(),
26276
+ deviceId: number().nullable(),
26277
+ modelId: string()
26278
+ }),
26279
+ object({
26280
+ kind: literal("custom-registry-unreadable"),
26281
+ error: string()
25010
26282
  })
25011
26283
  ]);
25012
26284
  var AutoTuneOptionsSchema = object({
@@ -25185,13 +26457,14 @@ var SuggestSharesResultSchema = object({
25185
26457
  nodes: array(SuggestedNodeShareSchema).readonly()
25186
26458
  });
25187
26459
  /**
25188
- * Where the node and device shares come from (D750, D755).
25189
- * - `hardware` (default) — computed by the system from each node's static
25190
- * capacity (its accelerators at their Auto tune models, from the measured
25191
- * latency table), recomputed whenever a node or device joins, leaves, is
25192
- * switched on or off, or changes model. No load input.
25193
- * - `benchmark` — the same, from each node's measured capacity (node
25194
- * benchmark results); a node without results falls back to `hardware`.
26460
+ * Where the node and device shares come from (D750, D755, D791).
26461
+ * - `benchmark` (default since D791) — each node's capacity as its own node
26462
+ * benchmark measured it; a node without fresh results is sized from
26463
+ * `hardware` and says so. Measured on the node beats the table.
26464
+ * - `hardware` — computed from each node's static capacity only (its
26465
+ * accelerators at their Auto tune models, from the latency table).
26466
+ * Both are recomputed whenever a node or device joins, leaves, is switched
26467
+ * on or off, changes model, or a benchmark result is written. No load input.
25195
26468
  * - `manual` — the operator's stored sliders.
25196
26469
  * Either way a node or device that cannot take sessions gives its share to
25197
26470
  * the others in proportion; the stored values are never rewritten for that.
@@ -25240,6 +26513,362 @@ var EffectiveSharesSchema = object({
25240
26513
  nodeWeights: record(string(), number()),
25241
26514
  deviceWeights: record(string(), record(string(), number()))
25242
26515
  });
26516
+ /**
26517
+ * Wire shapes of the node benchmark (D791): the operator's plan, the
26518
+ * preflight the confirmation shows, the run the orchestrator owns, what the
26519
+ * measuring runner reports, and the result rows Auto tune and the automatic
26520
+ * shares read.
26521
+ *
26522
+ * ONE node at a time, owned by the pipeline orchestrator. While a run is
26523
+ * active the cluster is in BENCHMARK MODE for that node: it is not a
26524
+ * detection candidate, camera pins naming it are ignored so its sessions move
26525
+ * elsewhere, and both come back when the mode ends — after a crash or a hub
26526
+ * restart too (a persisted manifest, reconciled against the registry).
26527
+ *
26528
+ * Two measurements, both on the node, driven by its own runner (frames never
26529
+ * cross a process at frame rate, D9):
26530
+ * - `device` — one accelerator × one candidate detector, root only, open
26531
+ * loop: how many streams at the camera rate it carries inside the frame
26532
+ * interval;
26533
+ * - `pipeline` — the chosen detector plus the operator's detail steps
26534
+ * (faces, plates, classifiers, CLIP…), on varied frames from the bench
26535
+ * clip: how many parallel sessions the node carries before latency, drops,
26536
+ * CPU, RAM or the event loop give out.
26537
+ */
26538
+ /** Defaults and bounds, one place. */
26539
+ var NODE_BENCHMARK_DEFAULTS = {
26540
+ fpsPerStream: 10,
26541
+ budgetMinutes: 45,
26542
+ minBudgetMinutes: 10,
26543
+ maxBudgetMinutes: 120,
26544
+ /** A result older than this no longer beats the table. */
26545
+ staleAfterDays: 30,
26546
+ /** Warm-in per ramp step (not accounted). */
26547
+ settleSec: 5,
26548
+ /** Accounted window per ramp step. */
26549
+ measureSec: 20,
26550
+ /** Longest the drain may take before the run is refused. */
26551
+ drainTimeoutSec: 120,
26552
+ /** Candidate models per device in one run. */
26553
+ maxModelsPerDevice: 6
26554
+ };
26555
+ /** The two measurements a run can make. */
26556
+ var NodeBenchmarkPhaseSchema = _enum(["device", "pipeline"]);
26557
+ var NodeBenchmarkDevicePlanSchema = object({
26558
+ /** `<backend>:<device>` — `openvino:npu`, `coreml:all`, `cpu`. */
26559
+ deviceKey: string().min(1),
26560
+ /**
26561
+ * Root detector candidates for the `device` measurement, in the order
26562
+ * measured. The FIRST is the one the `pipeline` measurement runs.
26563
+ */
26564
+ modelIds: array(string().min(1)).min(1).max(NODE_BENCHMARK_DEFAULTS.maxModelsPerDevice)
26565
+ });
26566
+ /** What the operator confirmed. */
26567
+ var NodeBenchmarkPlanSchema = object({
26568
+ nodeId: string().min(1),
26569
+ devices: array(NodeBenchmarkDevicePlanSchema).min(1),
26570
+ /** Which measurements run. At least one. */
26571
+ phases: array(NodeBenchmarkPhaseSchema).min(1).default(["device", "pipeline"]),
26572
+ /**
26573
+ * Detail steps (catalog step ids under the root: faces, plates,
26574
+ * classifiers, CLIP…) the `pipeline` measurement enables. The root
26575
+ * detector always runs.
26576
+ */
26577
+ steps: array(string().min(1)).default([]),
26578
+ /** Offered rate of one stream / session. */
26579
+ fpsPerStream: number().int().min(1).max(30).default(NODE_BENCHMARK_DEFAULTS.fpsPerStream),
26580
+ /** Hard deadline: the mode ends and the cluster is restored when it passes. */
26581
+ budgetMinutes: number().int().min(NODE_BENCHMARK_DEFAULTS.minBudgetMinutes).max(NODE_BENCHMARK_DEFAULTS.maxBudgetMinutes).default(NODE_BENCHMARK_DEFAULTS.budgetMinutes),
26582
+ /** Keep the models the run downloaded (default: delete what was not installed before). */
26583
+ keepDownloadedModels: boolean().default(false),
26584
+ /** Start although the other nodes' capacity does not cover the sessions running now. */
26585
+ acceptInsufficientHeadroom: boolean().default(false)
26586
+ });
26587
+ var NodeBenchmarkRefusalSchema = object({
26588
+ kind: _enum([
26589
+ "benchmark-active",
26590
+ "node-offline",
26591
+ "unknown-device",
26592
+ "no-phase",
26593
+ "insufficient-headroom"
26594
+ ]),
26595
+ detail: string(),
26596
+ overridable: boolean()
26597
+ });
26598
+ /** A camera whose detection leaves the node for the run. */
26599
+ var NodeBenchmarkMovingCameraSchema = object({
26600
+ deviceId: number(),
26601
+ /** Placed on the node now (a standing attach or a running session). */
26602
+ placedOnNode: boolean(),
26603
+ /** A node pin naming this node, ignored for the run. */
26604
+ pinnedToNode: boolean()
26605
+ });
26606
+ /** A camera that cannot leave: no other node can obtain its frames. */
26607
+ var NodeBenchmarkStayingCameraSchema = object({
26608
+ deviceId: number(),
26609
+ reason: literal("only-frame-source")
26610
+ });
26611
+ var NodeBenchmarkPreflightSchema = object({
26612
+ nodeId: string(),
26613
+ online: boolean(),
26614
+ moving: array(NodeBenchmarkMovingCameraSchema).readonly(),
26615
+ /** Keep running on the node during the run; the result is flagged contaminated. */
26616
+ staying: array(NodeBenchmarkStayingCameraSchema).readonly(),
26617
+ estimatedDurationMs: number(),
26618
+ /** The run ends and the cluster is restored at the latest after this long. */
26619
+ budgetMs: number(),
26620
+ phases: array(NodeBenchmarkPhaseSchema).readonly(),
26621
+ steps: array(string()).readonly(),
26622
+ devices: array(NodeBenchmarkDevicePlanSchema).readonly(),
26623
+ /** Parallel sessions the cluster runs now, and what the other nodes can carry. */
26624
+ headroom: object({
26625
+ sessionsNow: number(),
26626
+ otherNodesCapacitySessions: number().nullable()
26627
+ }),
26628
+ refusals: array(NodeBenchmarkRefusalSchema).readonly(),
26629
+ canStart: boolean()
26630
+ });
26631
+ /** Where the measuring runner is. */
26632
+ var NodeBenchProgressSchema = object({
26633
+ phase: _enum([
26634
+ "preparing",
26635
+ "device",
26636
+ "pipeline",
26637
+ "cleanup"
26638
+ ]),
26639
+ deviceKey: string().nullable(),
26640
+ modelId: string().nullable(),
26641
+ /** Streams (device) or sessions (pipeline) of the step running now. */
26642
+ load: number().nullable(),
26643
+ cellsDone: number(),
26644
+ cellsTotal: number(),
26645
+ message: string()
26646
+ });
26647
+ /** What limited a ramp. `none` = the ramp ran out of steps still passing. */
26648
+ var NodeBenchLimitSchema = _enum([
26649
+ "p95",
26650
+ "drops",
26651
+ "errors",
26652
+ "stall",
26653
+ "cpu",
26654
+ "ram",
26655
+ "none"
26656
+ ]);
26657
+ var NodeBenchRampStepSchema = object({
26658
+ load: number(),
26659
+ pass: boolean(),
26660
+ p95Ms: number(),
26661
+ dropRatio: number(),
26662
+ /** Completed frames per second over the accounted window. */
26663
+ fps: number(),
26664
+ cpuPct: number().nullable(),
26665
+ ramFreePct: number().nullable(),
26666
+ failReasons: array(string()).readonly()
26667
+ });
26668
+ var NodeBenchCellSchema = discriminatedUnion("phase", [object({
26669
+ phase: literal("device"),
26670
+ deviceKey: string(),
26671
+ modelId: string(),
26672
+ /** Single-stream latency (the K = 1 step). */
26673
+ p50Ms: number(),
26674
+ p95Ms: number(),
26675
+ p99Ms: number(),
26676
+ /** Frames per second sustained at the last passing step. */
26677
+ fps: number(),
26678
+ /** Streams at the camera rate the device carried inside the frame interval; 0 = not even one. */
26679
+ kMax: number(),
26680
+ limitedBy: NodeBenchLimitSchema,
26681
+ /** First call (model load + warm-up). */
26682
+ warmupMs: number(),
26683
+ ramp: array(NodeBenchRampStepSchema).readonly()
26684
+ }), object({
26685
+ phase: literal("pipeline"),
26686
+ deviceKey: string(),
26687
+ modelId: string(),
26688
+ steps: array(string()).readonly(),
26689
+ /** Parallel sessions at the camera rate the node carried; 0 = not even one. */
26690
+ maxSessions: number(),
26691
+ limitedBy: NodeBenchLimitSchema,
26692
+ /** Detail steps that produced at least one result on the clip — a step that never fired measured nothing. */
26693
+ stepsFired: array(string()).readonly(),
26694
+ warmupMs: number(),
26695
+ ramp: array(NodeBenchRampStepSchema).readonly()
26696
+ })]);
26697
+ /**
26698
+ * What a result was measured ON. A result whose fingerprint no longer matches
26699
+ * the node no longer beats the table.
26700
+ */
26701
+ var NodeBenchFingerprintSchema = object({
26702
+ pipelineVersion: string().nullable(),
26703
+ cpuModel: string().nullable(),
26704
+ ramGb: number().nullable(),
26705
+ os: string().nullable(),
26706
+ /** Per device: the pool the cells ran on (runtime + tuning). */
26707
+ pools: record(string(), object({
26708
+ runtime: string(),
26709
+ numWorkers: number(),
26710
+ concurrency: number(),
26711
+ batchMode: string()
26712
+ })).default({})
26713
+ });
26714
+ /** The frames the run used. */
26715
+ var NodeBenchClipSchema = object({
26716
+ /** `camstack-bench-v1` or `reference-images` (the fallback when the clip is not reachable). */
26717
+ id: string(),
26718
+ revision: string().nullable(),
26719
+ frames: number(),
26720
+ width: number(),
26721
+ height: number()
26722
+ });
26723
+ var NodeBenchRunnerInputSchema = object({
26724
+ runId: string().min(1),
26725
+ devices: array(NodeBenchmarkDevicePlanSchema).min(1),
26726
+ phases: array(NodeBenchmarkPhaseSchema).min(1),
26727
+ /** The full detail step tree root for the `pipeline` measurement is built on the node from these ids. */
26728
+ steps: array(string()).default([]),
26729
+ fpsPerStream: number().int().min(1).max(30),
26730
+ /** The runner stops on its own past this instant, whatever the hub does. */
26731
+ deadlineAtMs: number(),
26732
+ settleSec: number().min(0).max(60).default(NODE_BENCHMARK_DEFAULTS.settleSec),
26733
+ measureSec: number().min(2).max(300).default(NODE_BENCHMARK_DEFAULTS.measureSec),
26734
+ keepDownloadedModels: boolean().default(false)
26735
+ });
26736
+ var NodeBenchRunnerStateSchema = _enum([
26737
+ "running",
26738
+ "done",
26739
+ "failed",
26740
+ "aborted"
26741
+ ]);
26742
+ var NodeBenchRunnerStatusSchema = object({
26743
+ runId: string(),
26744
+ nodeId: string(),
26745
+ state: NodeBenchRunnerStateSchema,
26746
+ progress: NodeBenchProgressSchema.nullable(),
26747
+ /** Every finished cell so far — a run stopped half way keeps what it measured. */
26748
+ cells: array(NodeBenchCellSchema).readonly(),
26749
+ fingerprint: NodeBenchFingerprintSchema.nullable(),
26750
+ clip: NodeBenchClipSchema.nullable(),
26751
+ /** Cameras seen running on the node during the run (they share its pools). */
26752
+ activeCameraIds: array(number()).readonly(),
26753
+ /** Models the run downloaded and then deleted (not installed before). */
26754
+ deletedModels: array(string()).readonly(),
26755
+ error: string().nullable(),
26756
+ startedAtMs: number(),
26757
+ finishedAtMs: number().nullable()
26758
+ });
26759
+ var NodeBenchmarkStateSchema = _enum([
26760
+ "draining",
26761
+ "measuring",
26762
+ "restoring",
26763
+ "done",
26764
+ "failed",
26765
+ "aborted"
26766
+ ]);
26767
+ /** Why a run ended. */
26768
+ var NodeBenchmarkEndReasonSchema = _enum([
26769
+ "completed",
26770
+ "operator-abort",
26771
+ "deadline",
26772
+ "node-lost",
26773
+ "runner-lost",
26774
+ "hub-restart",
26775
+ "drain-timeout",
26776
+ "failed"
26777
+ ]);
26778
+ var NodeBenchmarkRunSchema = object({
26779
+ runId: string(),
26780
+ nodeId: string(),
26781
+ state: NodeBenchmarkStateSchema,
26782
+ plan: NodeBenchmarkPlanSchema,
26783
+ startedAtMs: number(),
26784
+ deadlineAtMs: number(),
26785
+ finishedAtMs: number().nullable(),
26786
+ endReason: NodeBenchmarkEndReasonSchema.nullable(),
26787
+ error: string().nullable(),
26788
+ /** Cameras moved off the node for the run. */
26789
+ moved: array(number()).readonly(),
26790
+ /** Cameras that stayed (their only frame source is the node). */
26791
+ staying: array(number()).readonly(),
26792
+ /** Something else ran on the node's pools during the run. */
26793
+ contaminated: boolean(),
26794
+ progress: NodeBenchProgressSchema.nullable(),
26795
+ resultIds: array(string()).readonly()
26796
+ });
26797
+ /** `getNodeBenchmarkStatus`: the active run (or the last one), and whether benchmark mode is on. */
26798
+ var NodeBenchmarkStatusSchema = object({
26799
+ /** The node the cluster is in benchmark mode for; null = none. */
26800
+ modeNodeId: string().nullable(),
26801
+ run: NodeBenchmarkRunSchema.nullable()
26802
+ });
26803
+ /**
26804
+ * One stored measurement — the only authority Auto tune and the automatic
26805
+ * shares read measured capacity from. Written by the orchestrator when a run
26806
+ * ends, never by anyone else.
26807
+ */
26808
+ var NodeBenchmarkResultSchema = object({
26809
+ id: string(),
26810
+ runId: string(),
26811
+ nodeId: string(),
26812
+ cell: NodeBenchCellSchema,
26813
+ fpsPerStream: number(),
26814
+ fingerprint: NodeBenchFingerprintSchema.nullable(),
26815
+ clip: NodeBenchClipSchema.nullable(),
26816
+ /** Other work shared the node's pools (a camera that could not move, or the hub's own duties). */
26817
+ contaminated: boolean(),
26818
+ stayingCameras: array(number()).readonly(),
26819
+ /** The run ended early; the cell itself completed. */
26820
+ partialRun: boolean(),
26821
+ measuredAtMs: number()
26822
+ });
26823
+ var ListNodeBenchmarkResultsInputSchema = object({
26824
+ nodeId: string().optional(),
26825
+ deviceKey: string().optional()
26826
+ });
26827
+ /** A result with its standing today: does it still beat the table? */
26828
+ var NodeBenchmarkResultViewSchema = NodeBenchmarkResultSchema.extend({
26829
+ /** `fresh` beats the table; `stale` falls back to it; `superseded` = a newer row covers the same cell. */
26830
+ standing: _enum([
26831
+ "fresh",
26832
+ "stale",
26833
+ "superseded"
26834
+ ]),
26835
+ staleWhy: _enum([
26836
+ "age",
26837
+ "runtime",
26838
+ "pool-tuning"
26839
+ ]).nullable()
26840
+ });
26841
+ object({
26842
+ runId: string(),
26843
+ nodeId: string(),
26844
+ startedAtMs: number(),
26845
+ deadlineAtMs: number(),
26846
+ plan: NodeBenchmarkPlanSchema,
26847
+ moved: array(number()).readonly(),
26848
+ staying: array(number()).readonly()
26849
+ });
26850
+ /** Candidate detectors per device, for the plan editor. */
26851
+ var NodeBenchmarkCandidatesSchema = object({
26852
+ nodeId: string(),
26853
+ reachable: boolean(),
26854
+ devices: array(object({
26855
+ deviceKey: string(),
26856
+ enabled: boolean(),
26857
+ available: boolean(),
26858
+ /** Ordered: what Auto tune would pick first, then the rest of the family by accuracy. */
26859
+ suggested: array(string()).readonly(),
26860
+ /** Every root detector the device has a build for. */
26861
+ all: array(string()).readonly(),
26862
+ /** The model the device runs now, when pinned. */
26863
+ currentModelId: string().nullable()
26864
+ })).readonly(),
26865
+ /** Detail steps the node's catalog offers under the root (for the `pipeline` measurement). */
26866
+ steps: array(object({
26867
+ id: string(),
26868
+ name: string(),
26869
+ slot: string()
26870
+ })).readonly()
26871
+ });
25243
26872
  object({
25244
26873
  activeCameras: number(),
25245
26874
  throttledCameras: number(),
@@ -26368,7 +27997,16 @@ method(RunnerCameraConfigSchema, object({ success: literal(true) }), { kind: "mu
26368
27997
  }), ParkedTrackFrameSchema.nullable()), method(object({
26369
27998
  deviceId: number(),
26370
27999
  trackId: string()
26371
- }), object({ released: number().int().nonnegative() }), { kind: "mutation" });
28000
+ }), object({ released: number().int().nonnegative() }), { kind: "mutation" }), method(NodeBenchRunnerInputSchema, object({
28001
+ accepted: literal(true),
28002
+ runId: string()
28003
+ }), {
28004
+ kind: "mutation",
28005
+ auth: "admin"
28006
+ }), method(object({ runId: string() }), NodeBenchRunnerStatusSchema.nullable(), { auth: "admin" }), method(object({ runId: string() }), object({ aborted: boolean() }), {
28007
+ kind: "mutation",
28008
+ auth: "admin"
28009
+ });
26372
28010
  var CameraPipelineConfigSchema = object({
26373
28011
  engine: PipelineEngineChoiceSchema.optional(),
26374
28012
  steps: array(PipelineStepInputSchema).readonly(),
@@ -27007,6 +28645,21 @@ method(object({
27007
28645
  }), method(PlacementStatsInputSchema, PlacementStatsSchema, { auth: "admin" }), method(SuggestSharesInputSchema, SuggestSharesResultSchema, { auth: "admin" }), method(_void(), EffectiveSharesSchema, { auth: "admin" }), method(SetShareSourceInputSchema, object({ success: literal(true) }), {
27008
28646
  kind: "mutation",
27009
28647
  auth: "admin"
28648
+ }), method(NodeBenchmarkPlanSchema, NodeBenchmarkPreflightSchema, { auth: "admin" }), method(NodeBenchmarkPlanSchema, discriminatedUnion("kind", [object({
28649
+ kind: literal("started"),
28650
+ runId: string()
28651
+ }), object({
28652
+ kind: literal("refused"),
28653
+ preflight: NodeBenchmarkPreflightSchema
28654
+ })]), {
28655
+ kind: "mutation",
28656
+ auth: "admin"
28657
+ }), method(_void(), NodeBenchmarkStatusSchema, { auth: "admin" }), method(object({ runId: string() }), object({ aborted: boolean() }), {
28658
+ kind: "mutation",
28659
+ auth: "admin"
28660
+ }), method(object({ nodeId: string() }), NodeBenchmarkCandidatesSchema, { auth: "admin" }), method(ListNodeBenchmarkResultsInputSchema, array(NodeBenchmarkResultViewSchema).readonly(), { auth: "admin" }), method(object({ id: string() }), object({ deleted: boolean() }), {
28661
+ kind: "mutation",
28662
+ auth: "admin"
27010
28663
  }), method(object({ deviceId: number() }), CameraPipelineSettingsSchema.nullable()), method(object({
27011
28664
  deviceId: number(),
27012
28665
  addonId: string(),
@@ -27643,7 +29296,19 @@ var SsoBridgeClaimsSchema = object({
27643
29296
  * editing a descriptor must not retroactively extend or shorten a link the
27644
29297
  * operator already consented to.
27645
29298
  */
27646
- refreshTtl: union([number().int().positive(), literal("never")]).optional()
29299
+ refreshTtl: union([number().int().positive(), literal("never")]).optional(),
29300
+ /**
29301
+ * Opaque handle of a hub-side LINK intent (D782). Set by an OIDC callback
29302
+ * that was started from a signed-in user's "Link" button: the finish then
29303
+ * links this identity to the intent's user instead of signing anyone in.
29304
+ * The handle carries no user id — the hub resolves it, single-use.
29305
+ */
29306
+ linkIntent: string().optional(),
29307
+ /**
29308
+ * Verified `iss` of the id_token behind an OIDC login bridge (D782). A
29309
+ * subject is unique only per issuer, so a link is bound to it.
29310
+ */
29311
+ issuer: string().optional()
27647
29312
  });
27648
29313
  method(object({
27649
29314
  claims: SsoBridgeClaimsSchema,
@@ -29578,7 +31243,22 @@ DeviceType.Camera, method(object({ deviceId: number().int().nonnegative() }), ar
29578
31243
  * field their hints were silently stripped by the schema and the
29579
31244
  * adaptive ladder started blind on the client's display size.
29580
31245
  */
29581
- hints: webrtcClientHintsSchema.optional()
31246
+ hints: webrtcClientHintsSchema.optional(),
31247
+ /**
31248
+ * Talk-back (D771): relay the PEER's audio to the device's speaker
31249
+ * through the `intercom` cap's push-talk triple. When `true` and the
31250
+ * offer lets the peer send audio, the answer's audio is `sendrecv`
31251
+ * and every inbound frame goes to `intercom.pushTalkAudio` for this
31252
+ * `deviceId`; absent/false answers `sendonly`, as for every viewer.
31253
+ *
31254
+ * TRUSTED-CALLER ONLY. Set by the Alexa export for an Echo on a camera
31255
+ * with `intercom`, when the linked user may control that camera. The
31256
+ * hub STRIPS it from every request-bound call (a browser), exactly as
31257
+ * it overwrites `relayOnly` — a viewer's talk permission is the
31258
+ * intercom cap's own surface (share tokens gate it there), and this
31259
+ * flag must not become a second door to the camera's speaker.
31260
+ */
31261
+ talkback: boolean().optional()
29582
31262
  }), object({
29583
31263
  sessionId: string(),
29584
31264
  sdpAnswer: string()
@@ -33095,6 +34775,9 @@ var CreateIntegrationInputSchema = object({
33095
34775
  enabled: boolean().optional(),
33096
34776
  info: record(string(), unknown()).optional(),
33097
34777
  settings: record(string(), unknown()).optional(),
34778
+ /** Keys of `settings` the form's schema declares secret (by type) — kept in
34779
+ * the keychain, not the table (D787). */
34780
+ secretKeys: array(string()).optional(),
33098
34781
  skipRestart: boolean().optional()
33099
34782
  });
33100
34783
  var UpdateIntegrationInputSchema = object({
@@ -33118,7 +34801,9 @@ method(_void(), array(IntegrationWithStateSchema)), method(object({ id: string()
33118
34801
  auth: "admin"
33119
34802
  }), method(object({ id: string() }), record(string(), unknown()), { auth: "admin" }), method(object({
33120
34803
  id: string(),
33121
- settings: record(string(), unknown())
34804
+ settings: record(string(), unknown()),
34805
+ /** Keys the form's schema declares secret (by type) — keychain-stored (D787). */
34806
+ secretKeys: array(string()).optional()
33122
34807
  }), object({ success: boolean() }), {
33123
34808
  kind: "mutation",
33124
34809
  auth: "admin"
@@ -39940,6 +41625,32 @@ var TotpStatusSchema = object({
39940
41625
  /** Null when no row exists OR the row is still pending confirmation. */
39941
41626
  confirmedAt: number().nullable()
39942
41627
  });
41628
+ /**
41629
+ * user-management — singleton capability for user accounts, API keys,
41630
+ * and scoped tokens.
41631
+ *
41632
+ * v2 model: every method gated by `auth: 'admin'`. Admin-only delegation
41633
+ * — the subset check on `setUserScopes` / `createScopedToken` is moot
41634
+ * because non-admins never reach these. If/when we open non-admin
41635
+ * delegation, structural caller-scope subset check goes inside the
41636
+ * provider.
41637
+ */
41638
+ var ExternalIdentitySchema = object({
41639
+ /** Login-method id of the provider instance, e.g. `auth-oidc/authentik`. */
41640
+ provider: string(),
41641
+ /** The IdP's stable subject (`sub`) for this account. */
41642
+ subject: string(),
41643
+ /** The verified `iss` of the IdP the identity was linked under — `sub` is unique only per issuer. */
41644
+ issuer: string(),
41645
+ userId: string(),
41646
+ /** What the IdP called the account at link time (username / email) — display only. */
41647
+ label: string().optional(),
41648
+ linkedAt: number()
41649
+ });
41650
+ var ExternalIdentityKeySchema = object({
41651
+ provider: string().min(1),
41652
+ subject: string().min(1)
41653
+ });
39943
41654
  method(_void(), array(UserSummarySchema), { auth: "admin" }), method(CreateUserInputSchema, UserSummarySchema, {
39944
41655
  kind: "mutation",
39945
41656
  auth: "admin",
@@ -40053,7 +41764,22 @@ method(_void(), array(UserSummarySchema), { auth: "admin" }), method(CreateUserI
40053
41764
  userId: string(),
40054
41765
  username: string(),
40055
41766
  scopes: array(TokenScopeSchema)
40056
- }).nullable(), { access: "view" }), method(_void(), array(OauthSessionSummarySchema), { auth: "admin" }), method(object({ id: string() }), object({ success: boolean() }), {
41767
+ }).nullable(), { access: "view" }), method(object({ userId: string() }), array(ExternalIdentitySchema), { auth: "admin" }), method(ExternalIdentityKeySchema, object({
41768
+ userId: string(),
41769
+ issuer: string()
41770
+ }).nullable(), { auth: "admin" }), method(ExternalIdentityKeySchema.extend({
41771
+ userId: string(),
41772
+ issuer: string().min(1),
41773
+ label: string().optional()
41774
+ }), object({ success: literal(true) }), {
41775
+ kind: "mutation",
41776
+ auth: "admin",
41777
+ access: "create"
41778
+ }), method(ExternalIdentityKeySchema.extend({ userId: string() }), object({ success: boolean() }), {
41779
+ kind: "mutation",
41780
+ auth: "admin",
41781
+ access: "delete"
41782
+ }), method(_void(), array(OauthSessionSummarySchema), { auth: "admin" }), method(object({ id: string() }), object({ success: boolean() }), {
40057
41783
  kind: "mutation",
40058
41784
  auth: "admin",
40059
41785
  access: "delete"
@@ -41240,7 +42966,8 @@ var BaseDevice = class {
41240
42966
  this.role = options.role;
41241
42967
  this.parentDeviceId = ctx.parentDeviceId;
41242
42968
  const seedData = ctx.persistedConfig ?? {};
41243
- this.config = DeviceConfig.fromSchema(schema, (data) => ctx.persistConfig(data), seedData, ({ droppedKeys, issues }) => {
42969
+ const declaredSecretPaths = collectZodSecretPaths(schema);
42970
+ this.config = DeviceConfig.fromSchema(schema, (data) => ctx.persistConfig(data, { secretConfigPaths: declaredSecretPaths }), seedData, ({ droppedKeys, issues }) => {
41244
42971
  ctx.logger.warn("Device config recovery: dropping invalid persisted fields", {
41245
42972
  tags: {
41246
42973
  deviceId: ctx.id,
@@ -44929,6 +46656,90 @@ Object.freeze({
44929
46656
  addonId: null,
44930
46657
  access: "create"
44931
46658
  },
46659
+ "keychain.delete": {
46660
+ capName: "keychain",
46661
+ capScope: "system",
46662
+ addonId: null,
46663
+ access: "delete"
46664
+ },
46665
+ "keychain.getState": {
46666
+ capName: "keychain",
46667
+ capScope: "system",
46668
+ addonId: null,
46669
+ access: "view"
46670
+ },
46671
+ "keychain.listMeta": {
46672
+ capName: "keychain",
46673
+ capScope: "system",
46674
+ addonId: null,
46675
+ access: "view"
46676
+ },
46677
+ "keychain.put": {
46678
+ capName: "keychain",
46679
+ capScope: "system",
46680
+ addonId: null,
46681
+ access: "create"
46682
+ },
46683
+ "keychain.resolve": {
46684
+ capName: "keychain",
46685
+ capScope: "system",
46686
+ addonId: null,
46687
+ access: "view"
46688
+ },
46689
+ "keychainAdmin.deleteOrphans": {
46690
+ capName: "keychain-admin",
46691
+ capScope: "system",
46692
+ addonId: null,
46693
+ access: "delete"
46694
+ },
46695
+ "keychainAdmin.downloadRecoveryKey": {
46696
+ capName: "keychain-admin",
46697
+ capScope: "system",
46698
+ addonId: null,
46699
+ access: "create"
46700
+ },
46701
+ "keychainAdmin.listAudit": {
46702
+ capName: "keychain-admin",
46703
+ capScope: "system",
46704
+ addonId: null,
46705
+ access: "view"
46706
+ },
46707
+ "keychainAdmin.listSecrets": {
46708
+ capName: "keychain-admin",
46709
+ capScope: "system",
46710
+ addonId: null,
46711
+ access: "view"
46712
+ },
46713
+ "keychainAdmin.purgeRetiredKeys": {
46714
+ capName: "keychain-admin",
46715
+ capScope: "system",
46716
+ addonId: null,
46717
+ access: "delete"
46718
+ },
46719
+ "keychainAdmin.resetKeychain": {
46720
+ capName: "keychain-admin",
46721
+ capScope: "system",
46722
+ addonId: null,
46723
+ access: "delete"
46724
+ },
46725
+ "keychainAdmin.reveal": {
46726
+ capName: "keychain-admin",
46727
+ capScope: "system",
46728
+ addonId: null,
46729
+ access: "create"
46730
+ },
46731
+ "keychainAdmin.rotateMasterKey": {
46732
+ capName: "keychain-admin",
46733
+ capScope: "system",
46734
+ addonId: null,
46735
+ access: "create"
46736
+ },
46737
+ "keychainAdmin.status": {
46738
+ capName: "keychain-admin",
46739
+ capScope: "system",
46740
+ addonId: null,
46741
+ access: "view"
46742
+ },
44932
46743
  "lawnMowerControl.dock": {
44933
46744
  capName: "lawn-mower-control",
44934
46745
  capScope: "device",
@@ -46303,6 +48114,18 @@ Object.freeze({
46303
48114
  addonId: null,
46304
48115
  access: "create"
46305
48116
  },
48117
+ "pipelineAnalytics.addRetrainFrameFromRecording": {
48118
+ capName: "pipeline-analytics",
48119
+ capScope: "device",
48120
+ addonId: null,
48121
+ access: "create"
48122
+ },
48123
+ "pipelineAnalytics.addRetrainFramesToCollection": {
48124
+ capName: "pipeline-analytics",
48125
+ capScope: "device",
48126
+ addonId: null,
48127
+ access: "create"
48128
+ },
46306
48129
  "pipelineAnalytics.applyDeviceSettingsPatch": {
46307
48130
  capName: "pipeline-analytics",
46308
48131
  capScope: "device",
@@ -46351,12 +48174,24 @@ Object.freeze({
46351
48174
  addonId: null,
46352
48175
  access: "view"
46353
48176
  },
48177
+ "pipelineAnalytics.createRetrainCollection": {
48178
+ capName: "pipeline-analytics",
48179
+ capScope: "device",
48180
+ addonId: null,
48181
+ access: "create"
48182
+ },
46354
48183
  "pipelineAnalytics.deleteDeviceEvents": {
46355
48184
  capName: "pipeline-analytics",
46356
48185
  capScope: "device",
46357
48186
  addonId: null,
46358
48187
  access: "delete"
46359
48188
  },
48189
+ "pipelineAnalytics.deleteRetrainCollection": {
48190
+ capName: "pipeline-analytics",
48191
+ capScope: "device",
48192
+ addonId: null,
48193
+ access: "delete"
48194
+ },
46360
48195
  "pipelineAnalytics.deleteTracks": {
46361
48196
  capName: "pipeline-analytics",
46362
48197
  capScope: "device",
@@ -46561,6 +48396,24 @@ Object.freeze({
46561
48396
  addonId: null,
46562
48397
  access: "view"
46563
48398
  },
48399
+ "pipelineAnalytics.listRetrainAssistProfiles": {
48400
+ capName: "pipeline-analytics",
48401
+ capScope: "device",
48402
+ addonId: null,
48403
+ access: "view"
48404
+ },
48405
+ "pipelineAnalytics.listRetrainCollectionFrames": {
48406
+ capName: "pipeline-analytics",
48407
+ capScope: "device",
48408
+ addonId: null,
48409
+ access: "view"
48410
+ },
48411
+ "pipelineAnalytics.listRetrainCollections": {
48412
+ capName: "pipeline-analytics",
48413
+ capScope: "device",
48414
+ addonId: null,
48415
+ access: "view"
48416
+ },
46564
48417
  "pipelineAnalytics.listRetrainFrames": {
46565
48418
  capName: "pipeline-analytics",
46566
48419
  capScope: "device",
@@ -46609,6 +48462,12 @@ Object.freeze({
46609
48462
  addonId: null,
46610
48463
  access: "create"
46611
48464
  },
48465
+ "pipelineAnalytics.proposeRetrainAnnotationsWithLlm": {
48466
+ capName: "pipeline-analytics",
48467
+ capScope: "device",
48468
+ addonId: null,
48469
+ access: "create"
48470
+ },
46612
48471
  "pipelineAnalytics.pruneEvents": {
46613
48472
  capName: "pipeline-analytics",
46614
48473
  capScope: "device",
@@ -46663,6 +48522,18 @@ Object.freeze({
46663
48522
  addonId: null,
46664
48523
  access: "create"
46665
48524
  },
48525
+ "pipelineAnalytics.removeRetrainFrameFromCollection": {
48526
+ capName: "pipeline-analytics",
48527
+ capScope: "device",
48528
+ addonId: null,
48529
+ access: "delete"
48530
+ },
48531
+ "pipelineAnalytics.renameRetrainCollection": {
48532
+ capName: "pipeline-analytics",
48533
+ capScope: "device",
48534
+ addonId: null,
48535
+ access: "create"
48536
+ },
46666
48537
  "pipelineAnalytics.restageRetrainTrack": {
46667
48538
  capName: "pipeline-analytics",
46668
48539
  capScope: "device",
@@ -46693,6 +48564,12 @@ Object.freeze({
46693
48564
  addonId: null,
46694
48565
  access: "create"
46695
48566
  },
48567
+ "pipelineAnalytics.setRetrainFrameComplete": {
48568
+ capName: "pipeline-analytics",
48569
+ capScope: "device",
48570
+ addonId: null,
48571
+ access: "create"
48572
+ },
46696
48573
  "pipelineAnalytics.setTrackFlags": {
46697
48574
  capName: "pipeline-analytics",
46698
48575
  capScope: "device",
@@ -46729,6 +48606,12 @@ Object.freeze({
46729
48606
  addonId: null,
46730
48607
  access: "delete"
46731
48608
  },
48609
+ "pipelineAnalytics.writeRetrainArchive": {
48610
+ capName: "pipeline-analytics",
48611
+ capScope: "device",
48612
+ addonId: null,
48613
+ access: "create"
48614
+ },
46732
48615
  "pipelineExecutor.cacheFrameInPool": {
46733
48616
  capName: "pipeline-executor",
46734
48617
  capScope: "system",
@@ -46939,6 +48822,12 @@ Object.freeze({
46939
48822
  addonId: null,
46940
48823
  access: "view"
46941
48824
  },
48825
+ "pipelineOrchestrator.abortNodeBenchmark": {
48826
+ capName: "pipeline-orchestrator",
48827
+ capScope: "system",
48828
+ addonId: null,
48829
+ access: "create"
48830
+ },
46942
48831
  "pipelineOrchestrator.applyAutoTune": {
46943
48832
  capName: "pipeline-orchestrator",
46944
48833
  capScope: "system",
@@ -46963,6 +48852,12 @@ Object.freeze({
46963
48852
  addonId: null,
46964
48853
  access: "create"
46965
48854
  },
48855
+ "pipelineOrchestrator.deleteNodeBenchmarkResult": {
48856
+ capName: "pipeline-orchestrator",
48857
+ capScope: "system",
48858
+ addonId: null,
48859
+ access: "delete"
48860
+ },
46966
48861
  "pipelineOrchestrator.getAgentLoad": {
46967
48862
  capName: "pipeline-orchestrator",
46968
48863
  capScope: "system",
@@ -47071,6 +48966,24 @@ Object.freeze({
47071
48966
  addonId: null,
47072
48967
  access: "view"
47073
48968
  },
48969
+ "pipelineOrchestrator.getNodeBenchmarkCandidates": {
48970
+ capName: "pipeline-orchestrator",
48971
+ capScope: "system",
48972
+ addonId: null,
48973
+ access: "view"
48974
+ },
48975
+ "pipelineOrchestrator.getNodeBenchmarkPreflight": {
48976
+ capName: "pipeline-orchestrator",
48977
+ capScope: "system",
48978
+ addonId: null,
48979
+ access: "view"
48980
+ },
48981
+ "pipelineOrchestrator.getNodeBenchmarkStatus": {
48982
+ capName: "pipeline-orchestrator",
48983
+ capScope: "system",
48984
+ addonId: null,
48985
+ access: "view"
48986
+ },
47074
48987
  "pipelineOrchestrator.getNodeInferenceDevices": {
47075
48988
  capName: "pipeline-orchestrator",
47076
48989
  capScope: "system",
@@ -47113,6 +49026,12 @@ Object.freeze({
47113
49026
  addonId: null,
47114
49027
  access: "view"
47115
49028
  },
49029
+ "pipelineOrchestrator.listNodeBenchmarkResults": {
49030
+ capName: "pipeline-orchestrator",
49031
+ capScope: "system",
49032
+ addonId: null,
49033
+ access: "view"
49034
+ },
47116
49035
  "pipelineOrchestrator.pauseForStorageMigration": {
47117
49036
  capName: "pipeline-orchestrator",
47118
49037
  capScope: "system",
@@ -47257,6 +49176,12 @@ Object.freeze({
47257
49176
  addonId: null,
47258
49177
  access: "create"
47259
49178
  },
49179
+ "pipelineOrchestrator.startNodeBenchmark": {
49180
+ capName: "pipeline-orchestrator",
49181
+ capScope: "system",
49182
+ addonId: null,
49183
+ access: "create"
49184
+ },
47260
49185
  "pipelineOrchestrator.suggestShares": {
47261
49186
  capName: "pipeline-orchestrator",
47262
49187
  capScope: "system",
@@ -47275,6 +49200,12 @@ Object.freeze({
47275
49200
  addonId: null,
47276
49201
  access: "create"
47277
49202
  },
49203
+ "pipelineRunner.abortNodeBench": {
49204
+ capName: "pipeline-runner",
49205
+ capScope: "system",
49206
+ addonId: null,
49207
+ access: "create"
49208
+ },
47278
49209
  "pipelineRunner.attachCamera": {
47279
49210
  capName: "pipeline-runner",
47280
49211
  capScope: "system",
@@ -47323,6 +49254,12 @@ Object.freeze({
47323
49254
  addonId: null,
47324
49255
  access: "view"
47325
49256
  },
49257
+ "pipelineRunner.getNodeBenchStatus": {
49258
+ capName: "pipeline-runner",
49259
+ capScope: "system",
49260
+ addonId: null,
49261
+ access: "view"
49262
+ },
47326
49263
  "pipelineRunner.getParkedTrackFrame": {
47327
49264
  capName: "pipeline-runner",
47328
49265
  capScope: "system",
@@ -47365,6 +49302,12 @@ Object.freeze({
47365
49302
  addonId: null,
47366
49303
  access: "create"
47367
49304
  },
49305
+ "pipelineRunner.startNodeBench": {
49306
+ capName: "pipeline-runner",
49307
+ capScope: "system",
49308
+ addonId: null,
49309
+ access: "create"
49310
+ },
47368
49311
  "plateGallery.assignPlate": {
47369
49312
  capName: "plate-gallery",
47370
49313
  capScope: "system",
@@ -49081,18 +51024,36 @@ Object.freeze({
49081
51024
  addonId: null,
49082
51025
  access: "delete"
49083
51026
  },
51027
+ "userManagement.findUserByExternalIdentity": {
51028
+ capName: "user-management",
51029
+ capScope: "system",
51030
+ addonId: null,
51031
+ access: "view"
51032
+ },
49084
51033
  "userManagement.getTotpStatus": {
49085
51034
  capName: "user-management",
49086
51035
  capScope: "system",
49087
51036
  addonId: null,
49088
51037
  access: "view"
49089
51038
  },
51039
+ "userManagement.linkExternalIdentity": {
51040
+ capName: "user-management",
51041
+ capScope: "system",
51042
+ addonId: null,
51043
+ access: "create"
51044
+ },
49090
51045
  "userManagement.listApiKeys": {
49091
51046
  capName: "user-management",
49092
51047
  capScope: "system",
49093
51048
  addonId: null,
49094
51049
  access: "view"
49095
51050
  },
51051
+ "userManagement.listExternalIdentities": {
51052
+ capName: "user-management",
51053
+ capScope: "system",
51054
+ addonId: null,
51055
+ access: "view"
51056
+ },
49096
51057
  "userManagement.listOauthSessions": {
49097
51058
  capName: "user-management",
49098
51059
  capScope: "system",
@@ -49171,6 +51132,12 @@ Object.freeze({
49171
51132
  addonId: null,
49172
51133
  access: "create"
49173
51134
  },
51135
+ "userManagement.unlinkExternalIdentity": {
51136
+ capName: "user-management",
51137
+ capScope: "system",
51138
+ addonId: null,
51139
+ access: "delete"
51140
+ },
49174
51141
  "userManagement.updateUser": {
49175
51142
  capName: "user-management",
49176
51143
  capScope: "system",
@@ -52270,6 +54237,11 @@ Object.freeze({
52270
54237
  form: "single",
52271
54238
  optional: false
52272
54239
  }],
54240
+ "pipelineAnalytics.addRetrainFrameFromRecording": [{
54241
+ name: "deviceId",
54242
+ form: "single",
54243
+ optional: false
54244
+ }],
52273
54245
  "pipelineAnalytics.applyDeviceSettingsPatch": [{
52274
54246
  name: "deviceId",
52275
54247
  form: "single",
@@ -52460,6 +54432,11 @@ Object.freeze({
52460
54432
  form: "single",
52461
54433
  optional: false
52462
54434
  }],
54435
+ "pipelineAnalytics.proposeRetrainAnnotationsWithLlm": [{
54436
+ name: "deviceId",
54437
+ form: "single",
54438
+ optional: false
54439
+ }],
52463
54440
  "pipelineAnalytics.pruneEventsBefore": [{
52464
54441
  name: "deviceId",
52465
54442
  form: "single",
@@ -52510,6 +54487,11 @@ Object.freeze({
52510
54487
  form: "single",
52511
54488
  optional: false
52512
54489
  }],
54490
+ "pipelineAnalytics.setRetrainFrameComplete": [{
54491
+ name: "deviceId",
54492
+ form: "single",
54493
+ optional: false
54494
+ }],
52513
54495
  "pipelineAnalytics.setTrackFlags": [{
52514
54496
  name: "deviceId",
52515
54497
  form: "single",
@@ -54597,7 +56579,7 @@ var PetkitRegionSchema = _enum(PETKIT_REGIONS);
54597
56579
  */
54598
56580
  var petkitConfigSchema = object({
54599
56581
  email: string().min(1).describe("PetKit account email"),
54600
- password: string().min(1).describe("PetKit account password"),
56582
+ password: string().min(1).describe("PetKit account password").meta({ secret: true }),
54601
56583
  region: PetkitRegionSchema.default("de").describe("PetKit cloud region"),
54602
56584
  timezone: string().default("Europe/Berlin").describe("IANA timezone used for cloud request headers"),
54603
56585
  pollIntervalMs: preprocess((v) => v === "" || v === null ? void 0 : v, number().int().min(0).max(36e5).default(3e4)).describe("Per-feeder poll cadence (ms) — 0 leaves only eager/stale refresh")