@camstack/addon-provider-rademacher 0.2.123 → 0.2.125

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 +3555 -126
  2. package/dist/addon.mjs +3555 -126
  3. package/package.json +1 -1
package/dist/addon.mjs CHANGED
@@ -983,7 +983,7 @@ var Rademacher = class {
983
983
  }
984
984
  };
985
985
  //#endregion
986
- //#region ../types/dist/event-category-B_0XEcLF.mjs
986
+ //#region ../types/dist/event-category-DaIZi00R.mjs
987
987
  var EventCategory = /* @__PURE__ */ function(EventCategory) {
988
988
  EventCategory["SystemBoot"] = "system.boot";
989
989
  EventCategory["SystemAddonsReady"] = "system.addons-ready";
@@ -1062,6 +1062,13 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
1062
1062
  */
1063
1063
  EventCategory["AddonLoadFailed"] = "addon.load-failed";
1064
1064
  /**
1065
+ * A keychain value was stored or removed (D787). Carries the ref, its
1066
+ * owner and the new version — NEVER the value. A process holding the ref
1067
+ * drops its cached copy and the owning `BaseAddon` re-resolves its config.
1068
+ * Telemetry (D8): a process that misses it still revalidates by version.
1069
+ */
1070
+ EventCategory["KeychainChanged"] = "keychain.changed";
1071
+ /**
1065
1072
  * Addon recovered from a previous failure. Emitted when an addon
1066
1073
  * transitions from `failed` back to `healthy` (typically via the
1067
1074
  * monitor's auto-retry loop, or after manual `addons.retryLoad`).
@@ -6354,7 +6361,7 @@ var ZodIssueCode = {
6354
6361
  var ZodFirstPartyTypeKind;
6355
6362
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
6356
6363
  //#endregion
6357
- //#region ../types/dist/sleep-B0JG7-_F.mjs
6364
+ //#region ../types/dist/sleep-r3RWkGVx.mjs
6358
6365
  /**
6359
6366
  * The audio chunk plane's byte format, and the ONE expansion from a coded
6360
6367
  * window to float samples (D455).
@@ -6433,6 +6440,97 @@ function buildAlawTable() {
6433
6440
  }
6434
6441
  buildUlawTable();
6435
6442
  buildAlawTable();
6443
+ /** Is this field's stored value a credential? */
6444
+ function isSecretConfigField(field) {
6445
+ if (field.type === "password") return true;
6446
+ return "secret" in field && field.secret === true;
6447
+ }
6448
+ /**
6449
+ * Is this field's value stored in the KEYCHAIN (D787)? Every secret field is,
6450
+ * by its TYPE, unless it opts out with `storage: 'inline'` — never by its name.
6451
+ */
6452
+ function isKeychainStoredField(field) {
6453
+ if (!isSecretConfigField(field)) return false;
6454
+ if (field.type === "textarea" && field.isJson === true) return false;
6455
+ return !("storage" in field && field.storage === "inline");
6456
+ }
6457
+ /**
6458
+ * What a settings blob holds where a secret used to be.
6459
+ *
6460
+ * A keychain-stored field never holds its value. It holds a self-describing
6461
+ * MARKER, `{"$secret":"secret://…","v":1}` — an object, never a string, so no
6462
+ * code can mistake it for a credential and no form can send it to a camera as
6463
+ * a password. The empty state is `null` / absent, never `''`.
6464
+ *
6465
+ * The same shapes travel to and from the admin UI:
6466
+ *
6467
+ * - read: `hydrateSchema` hands a secret field a {@link SecretFieldView}
6468
+ * (`{ $secret, v, set: true }`) or `null` — the browser learns whether a
6469
+ * value is set, never the value.
6470
+ * - write: an untouched field submits the view back unchanged (KEEP); a typed
6471
+ * value is a plain non-empty string (CHANGE); the Clear button submits
6472
+ * {@link SECRET_CLEAR} (CLEAR). `''`, `null` and the legacy redaction tokens
6473
+ * are KEEP — an empty string is what a defaults-fallback pushes back, and
6474
+ * treating it as "clear" is how a save destroyed a stored credential before.
6475
+ *
6476
+ * Pure and browser-safe.
6477
+ */
6478
+ var SECRET_CLEAR = { $secretClear: true };
6479
+ /** The `'***'` token D634 redaction writes for non-admins. */
6480
+ var LEGACY_DEVICE_REDACTION = "***";
6481
+ function isRecord$2(value) {
6482
+ return typeof value === "object" && value !== null && !Array.isArray(value);
6483
+ }
6484
+ function makeSecretMarker(ref) {
6485
+ return {
6486
+ $secret: ref,
6487
+ v: 1
6488
+ };
6489
+ }
6490
+ /** A stored marker: an object whose `$secret` is a non-empty string. */
6491
+ function isSecretMarker(value) {
6492
+ if (!isRecord$2(value)) return false;
6493
+ const ref = value["$secret"];
6494
+ return typeof ref === "string" && ref.length > 0;
6495
+ }
6496
+ function isSecretClear(value) {
6497
+ return isRecord$2(value) && value["$secretClear"] === true;
6498
+ }
6499
+ /**
6500
+ * The UI view of a stored secret field value: a marker becomes "set", inline
6501
+ * plaintext becomes "set (inline)", nothing becomes `null`. A value never
6502
+ * survives this function.
6503
+ */
6504
+ function toSecretFieldView(stored) {
6505
+ if (isSecretMarker(stored)) return {
6506
+ $secret: stored.$secret,
6507
+ v: 1,
6508
+ set: true
6509
+ };
6510
+ if (typeof stored === "string" && stored.length > 0) return {
6511
+ $secret: null,
6512
+ v: 1,
6513
+ set: true,
6514
+ inline: true
6515
+ };
6516
+ return null;
6517
+ }
6518
+ /**
6519
+ * Classify an incoming value for a secret path. Only a non-empty string that is
6520
+ * not a redaction token sets a value; only {@link SECRET_CLEAR} clears.
6521
+ * Everything else — a marker (ours or anyone's), a UI view, `''`, `null`,
6522
+ * `undefined`, a redaction token, a non-string — keeps what is stored.
6523
+ */
6524
+ function classifySecretWrite(incoming) {
6525
+ if (isSecretClear(incoming)) return { kind: "clear" };
6526
+ if (typeof incoming !== "string") return { kind: "keep" };
6527
+ if (incoming.length === 0) return { kind: "keep" };
6528
+ if (incoming === "__camstack_redacted__" || incoming === LEGACY_DEVICE_REDACTION) return { kind: "keep" };
6529
+ return {
6530
+ kind: "set",
6531
+ value: incoming
6532
+ };
6533
+ }
6436
6534
  Object.fromEntries([
6437
6535
  {
6438
6536
  id: "overview",
@@ -6604,33 +6702,19 @@ Object.fromEntries([
6604
6702
  function isValuelessField(field) {
6605
6703
  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";
6606
6704
  }
6607
- /**
6608
- * Merge a `ConfigUISchema` with a raw `values` record into a
6609
- * `ConfigUISchemaWithValues`. Used by every `get*Settings` backend endpoint
6610
- * before returning to the admin UI. Groups are walked recursively.
6611
- *
6612
- * For each leaf field:
6613
- * - structural fields (`separator`, `info`, `button`) pass through unchanged
6614
- * - other fields get `value = values[key] ?? field.default ?? null`
6615
- *
6616
- * Unknown keys in `values` (keys not declared in the schema) are silently
6617
- * ignored — they don't contribute to the output. Missing keys fall back to
6618
- * the schema default or `null`. This mirrors the old backend behaviour where
6619
- * `FormBuilder` rendered `values[key] ?? field.default`.
6620
- */
6621
- function hydrateSchema(schema, values) {
6705
+ function hydrateSchema(schema, values, options = {}) {
6622
6706
  return {
6623
6707
  ...schema.tabs ? { tabs: [...schema.tabs] } : {},
6624
6708
  sections: schema.sections.map((section) => ({
6625
6709
  ...section,
6626
- fields: section.fields.map((field) => hydrateField(field, values))
6710
+ fields: section.fields.map((field) => hydrateField(field, values, options))
6627
6711
  }))
6628
6712
  };
6629
6713
  }
6630
- function hydrateField(field, values) {
6714
+ function hydrateField(field, values, options) {
6631
6715
  if (isValuelessField(field)) return field;
6632
6716
  if (field.type === "group") {
6633
- const hydratedChildren = field.fields.map((child) => hydrateField(child, values));
6717
+ const hydratedChildren = field.fields.map((child) => hydrateField(child, values, options));
6634
6718
  return {
6635
6719
  ...field,
6636
6720
  fields: hydratedChildren
@@ -6639,7 +6723,7 @@ function hydrateField(field, values) {
6639
6723
  if (field.type === "sub-tabs") {
6640
6724
  const hydratedTabs = field.tabs.map((tab) => ({
6641
6725
  ...tab,
6642
- fields: tab.fields.map((child) => hydrateField(child, values))
6726
+ fields: tab.fields.map((child) => hydrateField(child, values, options))
6643
6727
  }));
6644
6728
  return {
6645
6729
  ...field,
@@ -6649,6 +6733,33 @@ function hydrateField(field, values) {
6649
6733
  const key = field.key;
6650
6734
  const storedValue = Object.prototype.hasOwnProperty.call(values, key) ? values[key] : void 0;
6651
6735
  const defaultValue = field.default;
6736
+ const asView = (v) => isSecretMarker(v) || options.inlineSecretsAsViews === true && v !== void 0;
6737
+ if (isKeychainStoredField(field) && asView(storedValue)) return {
6738
+ ...field,
6739
+ value: toSecretFieldView(storedValue)
6740
+ };
6741
+ if (isKeychainStoredField(field) && options.inlineSecretsAsViews === true) return {
6742
+ ...field,
6743
+ value: null
6744
+ };
6745
+ if (field.type === "editable-array" && Array.isArray(storedValue)) {
6746
+ const secretItemKeys = field.itemFields.filter((item) => "key" in item && isKeychainStoredField(item)).map((item) => "key" in item ? item.key : "");
6747
+ if (secretItemKeys.length > 0) {
6748
+ const rows = storedValue.map((row) => {
6749
+ if (row === null || typeof row !== "object" || Array.isArray(row)) return row;
6750
+ const out = { ...row };
6751
+ for (const k of secretItemKeys) {
6752
+ const v = Reflect.get(row, k);
6753
+ if (asView(v)) out[k] = toSecretFieldView(v);
6754
+ }
6755
+ return out;
6756
+ });
6757
+ return {
6758
+ ...field,
6759
+ value: rows
6760
+ };
6761
+ }
6762
+ }
6652
6763
  if (field.multiple) {
6653
6764
  const stored = Array.isArray(storedValue) ? storedValue : storedValue !== void 0 && storedValue !== null ? [storedValue] : [];
6654
6765
  const itemFallback = field.multiple.itemDefault !== void 0 ? field.multiple.itemDefault : defaultValue !== void 0 ? defaultValue : typeOf(field) === "string" ? "" : null;
@@ -6891,6 +7002,778 @@ function projectStore(store, perNodeKeys, nodeId) {
6891
7002
  }
6892
7003
  return out;
6893
7004
  }
7005
+ var GLOBAL_SCOPE = { kind: "global" };
7006
+ /** The scope every addon-wide (not per-node, not per-device) setting lives in. */
7007
+ function globalSecretScope() {
7008
+ return GLOBAL_SCOPE;
7009
+ }
7010
+ function encodeSegment(value) {
7011
+ return encodeURIComponent(value);
7012
+ }
7013
+ function decodeSegment(value) {
7014
+ try {
7015
+ return decodeURIComponent(value);
7016
+ } catch {
7017
+ return null;
7018
+ }
7019
+ }
7020
+ /**
7021
+ * The field path of a value inside an array item, addressed by the item's id:
7022
+ * `arrayItemFieldPath('providers', 'authentik', 'clientSecret')` →
7023
+ * `providers[authentik].clientSecret`.
7024
+ */
7025
+ function arrayItemFieldPath(arrayKey, itemId, fieldKey) {
7026
+ return `${arrayKey}[${encodeSegment(itemId)}].${fieldKey}`;
7027
+ }
7028
+ function parseScope(segments) {
7029
+ switch (segments[0]) {
7030
+ case "global": return {
7031
+ scope: GLOBAL_SCOPE,
7032
+ used: 1
7033
+ };
7034
+ case "node": {
7035
+ const nodeId = segments[1] !== void 0 ? decodeSegment(segments[1]) : null;
7036
+ return nodeId === null || nodeId.length === 0 ? null : {
7037
+ scope: {
7038
+ kind: "node",
7039
+ nodeId
7040
+ },
7041
+ used: 2
7042
+ };
7043
+ }
7044
+ case "device": {
7045
+ const raw = segments[1];
7046
+ if (raw === void 0 || !/^\d+$/.test(raw)) return null;
7047
+ return {
7048
+ scope: {
7049
+ kind: "device",
7050
+ deviceId: Number(raw)
7051
+ },
7052
+ used: 2
7053
+ };
7054
+ }
7055
+ case "integration": {
7056
+ const id = segments[1] !== void 0 ? decodeSegment(segments[1]) : null;
7057
+ return id === null || id.length === 0 ? null : {
7058
+ scope: {
7059
+ kind: "integration",
7060
+ integrationId: id
7061
+ },
7062
+ used: 2
7063
+ };
7064
+ }
7065
+ case "row": {
7066
+ const collection = segments[1] !== void 0 ? decodeSegment(segments[1]) : null;
7067
+ const rowId = segments[2] !== void 0 ? decodeSegment(segments[2]) : null;
7068
+ if (collection === null || rowId === null || collection.length === 0 || rowId.length === 0) return null;
7069
+ return {
7070
+ scope: {
7071
+ kind: "row",
7072
+ collection,
7073
+ rowId
7074
+ },
7075
+ used: 3
7076
+ };
7077
+ }
7078
+ default: return null;
7079
+ }
7080
+ }
7081
+ /** Take a ref apart; `null` when it is not a well-formed ref. */
7082
+ function parseSecretRef(ref) {
7083
+ if (!ref.startsWith("secret://")) return null;
7084
+ const segments = ref.slice(9).split("/");
7085
+ const owner = segments[0] !== void 0 ? decodeSegment(segments[0]) : null;
7086
+ if (owner === null || owner.length === 0) return null;
7087
+ const parsed = parseScope(segments.slice(1));
7088
+ if (parsed === null) return null;
7089
+ const fieldPath = segments.slice(1 + parsed.used).join("/");
7090
+ if (fieldPath.length === 0) return null;
7091
+ return {
7092
+ owner,
7093
+ scope: parsed.scope,
7094
+ fieldPath
7095
+ };
7096
+ }
7097
+ /** A write to a secret path could not be stored in the keychain, so it was refused. */
7098
+ var KeychainWriteRefusedError = class extends Error {
7099
+ fieldPath;
7100
+ constructor(fieldPath, cause) {
7101
+ super(`secret "${fieldPath}" was not saved: the keychain could not store it (${cause instanceof Error ? cause.message : String(cause)}). Nothing was written.`);
7102
+ this.fieldPath = fieldPath;
7103
+ this.name = "KeychainWriteRefusedError";
7104
+ }
7105
+ };
7106
+ var KEEP = { kind: "keep" };
7107
+ function isRecord$1(value) {
7108
+ return typeof value === "object" && value !== null && !Array.isArray(value);
7109
+ }
7110
+ function defaultMintId() {
7111
+ return globalThis.crypto.randomUUID();
7112
+ }
7113
+ /** Every marker ref anywhere under `value`. */
7114
+ function collectSecretMarkerRefs(value, out = []) {
7115
+ if (isSecretMarker(value)) {
7116
+ out.push(value.$secret);
7117
+ return out;
7118
+ }
7119
+ if (Array.isArray(value)) for (const item of value) collectSecretMarkerRefs(item, out);
7120
+ else if (isRecord$1(value)) for (const child of Object.values(value)) collectSecretMarkerRefs(child, out);
7121
+ return out;
7122
+ }
7123
+ async function storedValueEquals(secrets, marker, candidate) {
7124
+ const resolved = (await secrets.resolve([marker.$secret]))[marker.$secret];
7125
+ return resolved?.kind === "value" && resolved.value === candidate;
7126
+ }
7127
+ async function writeLeaf(ctx, incoming, stored, fieldPath) {
7128
+ const intent = classifySecretWrite(incoming);
7129
+ const ref = ctx.secrets.ref(ctx.scope, fieldPath);
7130
+ const storedIsOurs = isSecretMarker(stored) && stored.$secret === ref;
7131
+ if (intent.kind === "keep") return KEEP;
7132
+ if (intent.kind === "set" && !ctx.operatorWrite && typeof stored === "string" && stored === intent.value) return KEEP;
7133
+ if (intent.kind === "clear") {
7134
+ if (storedIsOurs) ctx.deletes.push(ref);
7135
+ return {
7136
+ kind: "value",
7137
+ value: null
7138
+ };
7139
+ }
7140
+ if (storedIsOurs && await storedValueEquals(ctx.secrets, stored, intent.value)) return {
7141
+ kind: "value",
7142
+ value: stored
7143
+ };
7144
+ try {
7145
+ await ctx.secrets.put(ref, intent.value);
7146
+ } catch (err) {
7147
+ throw new KeychainWriteRefusedError(fieldPath, err);
7148
+ }
7149
+ return {
7150
+ kind: "value",
7151
+ value: makeSecretMarker(ref)
7152
+ };
7153
+ }
7154
+ /** Apply a member result onto `out`: KEEP restores the stored member, or removes it. */
7155
+ function applyMember(out, key, result, storedParent) {
7156
+ if (result.kind === "value") {
7157
+ out[key] = result.value;
7158
+ return;
7159
+ }
7160
+ if (Object.prototype.hasOwnProperty.call(storedParent, key)) out[key] = storedParent[key];
7161
+ else delete out[key];
7162
+ }
7163
+ async function writeMembers(ctx, children, incoming, stored, pathOf) {
7164
+ const out = { ...incoming };
7165
+ for (const [member, node] of children) applyMember(out, member, await writeNode(ctx, node, incoming[member], stored[member], pathOf(member)), stored);
7166
+ return out;
7167
+ }
7168
+ function rowId(row, idKey) {
7169
+ const raw = row[idKey];
7170
+ if (typeof raw === "string" && raw.length > 0) return raw;
7171
+ if (typeof raw === "number" && Number.isFinite(raw)) return String(raw);
7172
+ return null;
7173
+ }
7174
+ async function writeArray(ctx, node, incoming, stored, fieldPath) {
7175
+ const storedRows = Array.isArray(stored) ? stored.filter(isRecord$1) : [];
7176
+ if (!Array.isArray(incoming)) {
7177
+ ctx.deletes.push(...collectSecretMarkerRefs(storedRows));
7178
+ return {
7179
+ kind: "value",
7180
+ value: incoming
7181
+ };
7182
+ }
7183
+ const storedById = /* @__PURE__ */ new Map();
7184
+ for (const row of storedRows) {
7185
+ const id = rowId(row, node.idKey);
7186
+ if (id !== null) storedById.set(id, row);
7187
+ }
7188
+ const kept = /* @__PURE__ */ new Set();
7189
+ const rows = [];
7190
+ for (const row of incoming) {
7191
+ if (!isRecord$1(row)) {
7192
+ rows.push(row);
7193
+ continue;
7194
+ }
7195
+ const id = rowId(row, node.idKey) ?? ctx.mintId();
7196
+ kept.add(id);
7197
+ const withId = {
7198
+ ...row,
7199
+ [node.idKey]: row[node.idKey] ?? id
7200
+ };
7201
+ if (rowId(withId, node.idKey) === null) withId[node.idKey] = id;
7202
+ const storedRow = storedById.get(id) ?? {};
7203
+ rows.push(await writeMembers(ctx, node.item, withId, storedRow, (member) => arrayItemFieldPath(fieldPath, id, member)));
7204
+ }
7205
+ for (const [id, row] of storedById) if (!kept.has(id)) ctx.deletes.push(...collectSecretMarkerRefs(row));
7206
+ return {
7207
+ kind: "value",
7208
+ value: rows
7209
+ };
7210
+ }
7211
+ async function writeNode(ctx, node, incoming, stored, fieldPath) {
7212
+ switch (node.kind) {
7213
+ case "leaf": return writeLeaf(ctx, incoming, stored, fieldPath);
7214
+ case "array": return writeArray(ctx, node, incoming, stored, fieldPath);
7215
+ case "object": {
7216
+ if (!isRecord$1(incoming)) {
7217
+ if (incoming === void 0) return KEEP;
7218
+ ctx.deletes.push(...collectSecretMarkerRefs(stored));
7219
+ return {
7220
+ kind: "value",
7221
+ value: incoming
7222
+ };
7223
+ }
7224
+ const storedObj = isRecord$1(stored) ? stored : {};
7225
+ return {
7226
+ kind: "value",
7227
+ value: await writeMembers(ctx, node.children, incoming, storedObj, (m) => `${fieldPath}.${m}`)
7228
+ };
7229
+ }
7230
+ }
7231
+ }
7232
+ /** Split a perNode-scoped key (`key@nodeId`). */
7233
+ function splitNodeKey(key) {
7234
+ const at = key.indexOf("@");
7235
+ return at <= 0 ? {
7236
+ base: key,
7237
+ nodeId: null
7238
+ } : {
7239
+ base: key.slice(0, at),
7240
+ nodeId: key.slice(at + 1)
7241
+ };
7242
+ }
7243
+ /** Rewrite a settings patch so no secret value reaches the blob. See the file doc. */
7244
+ async function transformSecretWrite(input) {
7245
+ const deletes = [];
7246
+ const base = {
7247
+ secrets: input.secrets,
7248
+ mintId: input.mintId ?? defaultMintId,
7249
+ deletes,
7250
+ operatorWrite: input.operatorWrite === true
7251
+ };
7252
+ const out = {};
7253
+ for (const [key, incoming] of Object.entries(input.patch)) {
7254
+ const { base: baseKey, nodeId } = splitNodeKey(key);
7255
+ const node = input.tree.get(baseKey);
7256
+ if (node === void 0) {
7257
+ out[key] = incoming;
7258
+ continue;
7259
+ }
7260
+ const scope = nodeId !== null && nodeId.length > 0 ? {
7261
+ kind: "node",
7262
+ nodeId
7263
+ } : input.scope ?? globalSecretScope();
7264
+ const result = await writeNode({
7265
+ ...base,
7266
+ scope
7267
+ }, node, incoming, input.stored[key], baseKey);
7268
+ if (result.kind === "value") out[key] = result.value;
7269
+ }
7270
+ return {
7271
+ patch: out,
7272
+ afterWrite: async () => {
7273
+ if (deletes.length === 0) return { orphaned: [] };
7274
+ try {
7275
+ await input.secrets.delete([...new Set(deletes)]);
7276
+ return { orphaned: [] };
7277
+ } catch {
7278
+ return { orphaned: [...new Set(deletes)] };
7279
+ }
7280
+ }
7281
+ };
7282
+ }
7283
+ /** Is `ref` one of `owner`'s refs? */
7284
+ function isSecretRefOwnedBy(ref, owner) {
7285
+ return parseSecretRef(ref)?.owner === owner;
7286
+ }
7287
+ /**
7288
+ * Replace every marker in `value` with its keychain value. Returns the SAME
7289
+ * reference when there is no marker (no allocation, no keychain call).
7290
+ */
7291
+ async function resolveSecretMarkers(value, secrets, options = {}) {
7292
+ const keepMarker = options.unresolved === "keep-marker";
7293
+ const owner = options.ownedBy;
7294
+ const inScope = (ref) => owner === void 0 || isSecretRefOwnedBy(ref, owner);
7295
+ const refs = collectSecretMarkerRefs(value).filter(inScope);
7296
+ if (refs.length === 0) return {
7297
+ value,
7298
+ unresolved: []
7299
+ };
7300
+ const answers = await secrets.resolve(refs);
7301
+ const unresolved = [];
7302
+ for (const ref of new Set(refs)) {
7303
+ const answer = answers[ref];
7304
+ if (answer === void 0) unresolved.push({
7305
+ ref,
7306
+ reason: "not-initialized"
7307
+ });
7308
+ else if (answer.kind === "unavailable") unresolved.push({
7309
+ ref,
7310
+ reason: answer.reason
7311
+ });
7312
+ else if (answer.kind === "missing" || answer.kind === "forbidden") unresolved.push({
7313
+ ref,
7314
+ reason: answer.kind
7315
+ });
7316
+ }
7317
+ const substitute = (v) => {
7318
+ if (isSecretMarker(v)) {
7319
+ if (!inScope(v.$secret)) return {
7320
+ keep: true,
7321
+ value: v
7322
+ };
7323
+ const answer = answers[v.$secret];
7324
+ if (answer?.kind === "value") return {
7325
+ keep: true,
7326
+ value: answer.value
7327
+ };
7328
+ return keepMarker ? {
7329
+ keep: true,
7330
+ value: v
7331
+ } : {
7332
+ keep: false,
7333
+ value: void 0
7334
+ };
7335
+ }
7336
+ if (Array.isArray(v)) {
7337
+ const items = [];
7338
+ for (const item of v) {
7339
+ const s = substitute(item);
7340
+ if (s.keep) items.push(s.value);
7341
+ }
7342
+ return {
7343
+ keep: true,
7344
+ value: items
7345
+ };
7346
+ }
7347
+ if (isRecord$1(v)) {
7348
+ const out = {};
7349
+ for (const [k, child] of Object.entries(v)) {
7350
+ const s = substitute(child);
7351
+ if (s.keep) out[k] = s.value;
7352
+ }
7353
+ return {
7354
+ keep: true,
7355
+ value: out
7356
+ };
7357
+ }
7358
+ return {
7359
+ keep: true,
7360
+ value: v
7361
+ };
7362
+ };
7363
+ return {
7364
+ value: substitute(value).value,
7365
+ unresolved
7366
+ };
7367
+ }
7368
+ /** An addon tried to replace a stored secret it could not read. Nothing was written. */
7369
+ var SecretOverwriteRefusedError = class extends Error {
7370
+ ref;
7371
+ reason;
7372
+ constructor(ref, reason) {
7373
+ super(`secret ${ref} was not replaced: its stored value cannot be read right now (${reason}), and an addon may not overwrite a secret it cannot see. Nothing was written.`);
7374
+ this.ref = ref;
7375
+ this.reason = reason;
7376
+ this.name = "SecretOverwriteRefusedError";
7377
+ }
7378
+ };
7379
+ function isRecord(value) {
7380
+ return typeof value === "object" && value !== null && !Array.isArray(value);
7381
+ }
7382
+ function resolvedValue(pass, marker) {
7383
+ const answer = pass.answers[marker.$secret];
7384
+ return answer?.kind === "value" ? answer.value : null;
7385
+ }
7386
+ async function atMarker(pass, incoming, stored) {
7387
+ if (incoming === null) return stored;
7388
+ if (typeof incoming !== "string") return incoming;
7389
+ if (incoming === resolvedValue(pass, stored)) return stored;
7390
+ const intent = classifySecretWrite(incoming);
7391
+ if (intent.kind !== "set") return stored;
7392
+ const ref = stored.$secret;
7393
+ if (!isSecretRefOwnedBy(ref, pass.secrets.owner)) return incoming;
7394
+ const answer = pass.answers[ref];
7395
+ if ((answer === void 0 || answer.kind === "unavailable" || answer.kind === "forbidden") && !pass.operatorWrite) throw new SecretOverwriteRefusedError(ref, answer === void 0 ? "not-initialized" : answer.kind === "unavailable" ? answer.reason : answer.kind);
7396
+ try {
7397
+ await pass.secrets.put(ref, intent.value);
7398
+ } catch (err) {
7399
+ throw new KeychainWriteRefusedError(ref, err);
7400
+ }
7401
+ pass.changedRefs.push(ref);
7402
+ return stored;
7403
+ }
7404
+ function inArray(pass, incoming, stored) {
7405
+ return incoming.map((item, index) => {
7406
+ const twin = stored[index];
7407
+ if (isSecretMarker(twin)) return typeof item === "string" && item === resolvedValue(pass, twin) ? twin : item;
7408
+ if (isRecord(item) && isRecord(twin)) return inArrayRow(pass, item, twin);
7409
+ if (Array.isArray(item) && Array.isArray(twin)) return inArray(pass, item, twin);
7410
+ return item;
7411
+ });
7412
+ }
7413
+ function inArrayRow(pass, incoming, stored) {
7414
+ const out = { ...incoming };
7415
+ for (const [key, value] of Object.entries(incoming)) {
7416
+ const twin = stored[key];
7417
+ if (isSecretMarker(twin)) {
7418
+ if (typeof value === "string" && value === resolvedValue(pass, twin)) out[key] = twin;
7419
+ } else if (isRecord(value) && isRecord(twin)) out[key] = inArrayRow(pass, value, twin);
7420
+ else if (Array.isArray(value) && Array.isArray(twin)) out[key] = inArray(pass, value, twin);
7421
+ }
7422
+ return out;
7423
+ }
7424
+ async function walk(pass, incoming, stored) {
7425
+ if (isSecretMarker(stored)) return atMarker(pass, incoming, stored);
7426
+ if (Array.isArray(incoming) && Array.isArray(stored)) return inArray(pass, incoming, stored);
7427
+ if (!isRecord(incoming) || !isRecord(stored)) return incoming;
7428
+ const out = { ...incoming };
7429
+ for (const [key, value] of Object.entries(incoming)) out[key] = await walk(pass, value, stored[key]);
7430
+ return out;
7431
+ }
7432
+ /** Restore markers a write-back carries as values. See the file doc. */
7433
+ async function restoreUnchangedSecrets(input) {
7434
+ const refs = [];
7435
+ for (const key of Object.keys(input.patch)) collectSecretMarkerRefs(input.stored[key], refs);
7436
+ const owned = refs.filter((ref) => isSecretRefOwnedBy(ref, input.secrets.owner));
7437
+ if (owned.length === 0) return {
7438
+ patch: input.patch,
7439
+ changedRefs: []
7440
+ };
7441
+ const pass = {
7442
+ secrets: input.secrets,
7443
+ answers: await input.secrets.resolve([...new Set(owned)]),
7444
+ operatorWrite: input.operatorWrite,
7445
+ changedRefs: []
7446
+ };
7447
+ const out = {};
7448
+ for (const [key, value] of Object.entries(input.patch)) out[key] = await walk(pass, value, input.stored[key]);
7449
+ return {
7450
+ patch: out,
7451
+ changedRefs: pass.changedRefs
7452
+ };
7453
+ }
7454
+ /** Structural equality over JSON-shaped values (key order does not matter). */
7455
+ function isJsonEqual(a, b) {
7456
+ if (Object.is(a, b)) return true;
7457
+ if (Array.isArray(a)) return Array.isArray(b) && a.length === b.length && a.every((v, i) => isJsonEqual(v, b[i]));
7458
+ if (isRecord(a) && isRecord(b)) {
7459
+ const keys = Object.keys(a);
7460
+ if (keys.length !== Object.keys(b).length) return false;
7461
+ return keys.every((k) => Object.prototype.hasOwnProperty.call(b, k) && isJsonEqual(a[k], b[k]));
7462
+ }
7463
+ return false;
7464
+ }
7465
+ /** The patch without the keys whose value already equals the stored one. */
7466
+ function dropUnchangedKeys(patch, stored) {
7467
+ const out = {};
7468
+ for (const [key, value] of Object.entries(patch)) {
7469
+ if (Object.prototype.hasOwnProperty.call(stored, key) && isJsonEqual(value, stored[key])) continue;
7470
+ out[key] = value;
7471
+ }
7472
+ return out;
7473
+ }
7474
+ /** The top-level keys of a blob that hold at least one of `owner`'s markers. */
7475
+ function markerKeysOf(blob, owner) {
7476
+ const keys = /* @__PURE__ */ new Set();
7477
+ for (const [key, value] of Object.entries(blob)) if (collectSecretMarkerRefs(value).some((ref) => isSecretRefOwnedBy(ref, owner))) keys.add(key);
7478
+ return keys;
7479
+ }
7480
+ function nodeFromStored(value, owner) {
7481
+ if (isSecretMarker(value)) return isSecretRefOwnedBy(value.$secret, owner) ? { kind: "leaf" } : null;
7482
+ if (!isRecord(value)) return null;
7483
+ const children = /* @__PURE__ */ new Map();
7484
+ for (const [key, child] of Object.entries(value)) {
7485
+ const node = nodeFromStored(child, owner);
7486
+ if (node !== null) children.set(key, node);
7487
+ }
7488
+ return children.size > 0 ? {
7489
+ kind: "object",
7490
+ children
7491
+ } : null;
7492
+ }
7493
+ /**
7494
+ * The declared secret tree, widened by every place the STORED blob holds a
7495
+ * marker under one of `keys` — so a marker the schema no longer declares (or
7496
+ * never declared: Wyze before b4906cec6) still gets the save path's
7497
+ * KEEP / SET / CLEAR semantics instead of being overwritten by whatever the
7498
+ * addon writes. Markers inside arrays are not added: a row has no id field to
7499
+ * match by unless the schema declares one. Only `owner`'s markers count: a
7500
+ * builtin that keeps another addon's marker (device-manager) never takes it
7501
+ * over.
7502
+ */
7503
+ function widenTreeWithStoredMarkers(declared, stored, keys, owner) {
7504
+ const added = /* @__PURE__ */ new Map();
7505
+ for (const key of keys) {
7506
+ const at = key.indexOf("@");
7507
+ const base = at > 0 ? key.slice(0, at) : key;
7508
+ if (declared.has(base) || added.has(base)) continue;
7509
+ const node = nodeFromStored(stored[key], owner);
7510
+ if (node !== null) added.set(base, node);
7511
+ }
7512
+ return added.size === 0 ? declared : new Map([...declared, ...added]);
7513
+ }
7514
+ /** The blob as stored now; a failed read REFUSES the write instead of guessing. */
7515
+ async function readStoredAddonBlob(raw) {
7516
+ const threeWay = raw.readAddonStoreResult;
7517
+ if (threeWay === void 0) return raw.readAddonStore();
7518
+ const result = await threeWay.call(raw);
7519
+ if (result.kind === "failed") throw new Error(`settings write refused: the stored blob could not be read (${result.error})`);
7520
+ return result.kind === "missing" ? {} : result.value;
7521
+ }
7522
+ function touchesTree(tree, patch) {
7523
+ if (tree.size === 0) return false;
7524
+ for (const key of Object.keys(patch)) {
7525
+ const at = key.indexOf("@");
7526
+ if (tree.has(at > 0 ? key.slice(0, at) : key)) return true;
7527
+ }
7528
+ return false;
7529
+ }
7530
+ /**
7531
+ * Which top-level keys of each store held markers when last seen. `undefined`
7532
+ * for a store not seen yet: its first write reads it, to be safe.
7533
+ */
7534
+ var MarkerKeyIndex = class {
7535
+ owner;
7536
+ byStore = /* @__PURE__ */ new Map();
7537
+ constructor(owner) {
7538
+ this.owner = owner;
7539
+ }
7540
+ seen(store, blob) {
7541
+ this.byStore.set(store, markerKeysOf(blob, this.owner));
7542
+ }
7543
+ wrote(store, patch) {
7544
+ const keys = this.byStore.get(store);
7545
+ if (keys === void 0) return;
7546
+ const now = markerKeysOf(patch, this.owner);
7547
+ for (const key of Object.keys(patch)) if (now.has(key)) keys.add(key);
7548
+ else keys.delete(key);
7549
+ }
7550
+ mayHoldMarkers(store, patch) {
7551
+ const keys = this.byStore.get(store);
7552
+ if (keys === void 0) return true;
7553
+ return Object.keys(patch).some((key) => keys.has(key));
7554
+ }
7555
+ };
7556
+ function createHandle(raw, opts) {
7557
+ const chains = /* @__PURE__ */ new Map();
7558
+ const serialize = (key, fn) => {
7559
+ const next = (chains.get(key) ?? Promise.resolve()).then(fn, fn);
7560
+ const tail = next.catch(() => void 0);
7561
+ chains.set(key, tail);
7562
+ tail.then(() => {
7563
+ if (chains.get(key) === tail) chains.delete(key);
7564
+ });
7565
+ return next;
7566
+ };
7567
+ const index = new MarkerKeyIndex(opts.secrets.owner);
7568
+ const resolveRead = async (store, blob) => {
7569
+ index.seen(store, blob);
7570
+ const { value, unresolved } = await resolveSecretMarkers(blob, opts.secrets, {
7571
+ unresolved: "keep-marker",
7572
+ ownedBy: opts.secrets.owner
7573
+ });
7574
+ if (unresolved.length > 0) opts.onUnresolved?.(unresolved);
7575
+ return value;
7576
+ };
7577
+ const write = async (store, declared, scope, patch, readStored, rawWrite) => {
7578
+ if (!touchesTree(declared, patch) && !index.mayHoldMarkers(store, patch)) {
7579
+ await rawWrite(patch);
7580
+ index.wrote(store, patch);
7581
+ return { changed: true };
7582
+ }
7583
+ return serialize(store, async () => {
7584
+ const stored = await readStored();
7585
+ index.seen(store, stored);
7586
+ const operatorWrite = opts.isOperatorWrite?.() === true;
7587
+ const restored = await restoreUnchangedSecrets({
7588
+ patch,
7589
+ stored,
7590
+ secrets: opts.secrets,
7591
+ operatorWrite
7592
+ });
7593
+ const result = await transformSecretWrite({
7594
+ tree: widenTreeWithStoredMarkers(declared, stored, Object.keys(restored.patch), opts.secrets.owner),
7595
+ secrets: opts.secrets,
7596
+ patch: restored.patch,
7597
+ stored,
7598
+ ...scope !== void 0 ? { scope } : {},
7599
+ operatorWrite
7600
+ });
7601
+ const effective = dropUnchangedKeys(result.patch, stored);
7602
+ const wroteBlob = Object.keys(effective).length > 0;
7603
+ if (wroteBlob) {
7604
+ await rawWrite(effective);
7605
+ index.wrote(store, effective);
7606
+ }
7607
+ const { orphaned } = await result.afterWrite();
7608
+ if (orphaned.length > 0) opts.onOrphaned(orphaned);
7609
+ return { changed: wroteBlob || restored.changedRefs.length > 0 };
7610
+ });
7611
+ };
7612
+ const writeAddon = (patch) => write("addon", opts.addonTree(), void 0, patch, () => readStoredAddonBlob(raw), (p) => raw.writeAddonStore(p));
7613
+ const readAddonStoreResult = raw.readAddonStoreResult;
7614
+ const readAddonStoreKeyResult = raw.readAddonStoreKeyResult;
7615
+ const readDeviceStoreBatch = raw.readDeviceStoreBatch;
7616
+ const overrides = {
7617
+ readAddonStore: async () => resolveRead("addon", await raw.readAddonStore()),
7618
+ ...readAddonStoreResult !== void 0 ? { readAddonStoreResult: async () => {
7619
+ const result = await readAddonStoreResult.call(raw);
7620
+ return result.kind === "value" ? {
7621
+ kind: "value",
7622
+ value: await resolveRead("addon", result.value)
7623
+ } : result;
7624
+ } } : {},
7625
+ ...readAddonStoreKeyResult !== void 0 ? { readAddonStoreKeyResult: async (key) => {
7626
+ const result = await readAddonStoreKeyResult.call(raw, key);
7627
+ if (result.kind !== "present") return result;
7628
+ const { value, unresolved } = await resolveSecretMarkers({ [key]: result.value }, opts.secrets, {
7629
+ unresolved: "keep-marker",
7630
+ ownedBy: opts.secrets.owner
7631
+ });
7632
+ if (unresolved.length > 0) opts.onUnresolved?.(unresolved);
7633
+ return {
7634
+ kind: "present",
7635
+ value: value[key]
7636
+ };
7637
+ } } : {},
7638
+ readDeviceStore: async (deviceId) => resolveRead(`device:${deviceId}`, await raw.readDeviceStore(deviceId)),
7639
+ ...readDeviceStoreBatch !== void 0 ? { readDeviceStoreBatch: async (deviceIds) => {
7640
+ const rows = await readDeviceStoreBatch.call(raw, deviceIds);
7641
+ const out = /* @__PURE__ */ new Map();
7642
+ for (const [deviceId, blob] of rows) out.set(deviceId, await resolveRead(`device:${deviceId}`, blob));
7643
+ return out;
7644
+ } } : {},
7645
+ writeAddonStore: async (patch) => {
7646
+ await writeAddon(patch);
7647
+ },
7648
+ writeDeviceStore: async (deviceId, patch) => {
7649
+ await write(`device:${deviceId}`, opts.deviceTree(), {
7650
+ kind: "device",
7651
+ deviceId
7652
+ }, patch, () => raw.readDeviceStore(deviceId), (p) => raw.writeDeviceStore(deviceId, p));
7653
+ }
7654
+ };
7655
+ return {
7656
+ settings: new Proxy(raw, { get(target, prop, receiver) {
7657
+ if (typeof prop === "string" && Object.prototype.hasOwnProperty.call(overrides, prop)) return Reflect.get(overrides, prop);
7658
+ const value = Reflect.get(target, prop, receiver);
7659
+ return typeof value === "function" ? value.bind(target) : value;
7660
+ } }),
7661
+ raw: {
7662
+ readAddonStore: async () => {
7663
+ const blob = await raw.readAddonStore();
7664
+ index.seen("addon", blob);
7665
+ return blob;
7666
+ },
7667
+ readDeviceStore: async (deviceId) => {
7668
+ const blob = await raw.readDeviceStore(deviceId);
7669
+ index.seen(`device:${deviceId}`, blob);
7670
+ return blob;
7671
+ }
7672
+ },
7673
+ writeAddonStore: writeAddon
7674
+ };
7675
+ }
7676
+ /** The context the addon sees, plus the private raw view and write outcome. */
7677
+ function createSecretAwareContext(context, opts) {
7678
+ const raw = context.settings;
7679
+ if (raw === void 0) return {
7680
+ context,
7681
+ handle: null
7682
+ };
7683
+ const handle = createHandle(raw, opts);
7684
+ return {
7685
+ context: new Proxy(context, { get(target, prop, receiver) {
7686
+ if (prop === "settings") return handle.settings;
7687
+ return Reflect.get(target, prop, receiver);
7688
+ } }),
7689
+ handle
7690
+ };
7691
+ }
7692
+ var LEAF = { kind: "leaf" };
7693
+ var DEFAULT_ITEM_ID_KEY = "id";
7694
+ function collectFields(fields, out) {
7695
+ for (const field of fields) {
7696
+ if (field.type === "group") {
7697
+ collectFields(field.fields, out);
7698
+ continue;
7699
+ }
7700
+ if (field.type === "sub-tabs") {
7701
+ for (const tab of field.tabs) collectFields(tab.fields, out);
7702
+ continue;
7703
+ }
7704
+ if (field.type === "editable-array") {
7705
+ const item = /* @__PURE__ */ new Map();
7706
+ for (const itemField of field.itemFields) if ("key" in itemField && isKeychainStoredField(itemField)) item.set(itemField.key, LEAF);
7707
+ if (item.size > 0) out.set(field.key, {
7708
+ kind: "array",
7709
+ idKey: field.itemIdKey ?? DEFAULT_ITEM_ID_KEY,
7710
+ item
7711
+ });
7712
+ continue;
7713
+ }
7714
+ if (!("key" in field) || typeof field.key !== "string") continue;
7715
+ if (isKeychainStoredField(field)) out.set(field.key, LEAF);
7716
+ }
7717
+ }
7718
+ /** The secret tree a settings schema declares. */
7719
+ function secretTreeFromSchema(schema) {
7720
+ const out = /* @__PURE__ */ new Map();
7721
+ if (schema === null) return out;
7722
+ for (const section of schema.sections) collectFields(section.fields, out);
7723
+ return out;
7724
+ }
7725
+ /** Parse `a.b[id].c` into segments; throws on a malformed path (a declaration bug). */
7726
+ function parseSecretStatePath(path) {
7727
+ const segments = [];
7728
+ for (const raw of path.split(".")) {
7729
+ const m = /^([^[\]]+)(?:\[([^[\]]+)\])?$/.exec(raw);
7730
+ if (m === null || m[1] === void 0) throw new Error(`secretStatePaths: malformed path "${path}"`);
7731
+ segments.push(m[2] !== void 0 ? {
7732
+ key: m[1],
7733
+ idKey: m[2]
7734
+ } : { key: m[1] });
7735
+ }
7736
+ if (segments.length === 0) throw new Error(`secretStatePaths: empty path`);
7737
+ if (segments[segments.length - 1]?.idKey !== void 0) throw new Error(`secretStatePaths: "${path}" ends on an array — name the member that is secret`);
7738
+ return segments;
7739
+ }
7740
+ function insert(into, segments) {
7741
+ const [head, ...rest] = segments;
7742
+ if (head === void 0) return;
7743
+ if (rest.length === 0) {
7744
+ into.set(head.key, LEAF);
7745
+ return;
7746
+ }
7747
+ const existing = into.get(head.key);
7748
+ if (head.idKey !== void 0) {
7749
+ const item = new Map(existing?.kind === "array" ? existing.item : []);
7750
+ insert(item, rest);
7751
+ into.set(head.key, {
7752
+ kind: "array",
7753
+ idKey: head.idKey,
7754
+ item
7755
+ });
7756
+ return;
7757
+ }
7758
+ const children = new Map(existing?.kind === "object" ? existing.children : []);
7759
+ insert(children, rest);
7760
+ into.set(head.key, {
7761
+ kind: "object",
7762
+ children
7763
+ });
7764
+ }
7765
+ /** Add hidden-state paths (`secretStatePaths`) to a schema-derived tree. */
7766
+ function mergeSecretStatePaths(tree, paths) {
7767
+ if (paths.length === 0) return tree;
7768
+ const out = new Map(tree);
7769
+ for (const path of paths) insert(out, parseSecretStatePath(path));
7770
+ return out;
7771
+ }
7772
+ /** First retry of a secret the keychain could not serve; doubles to {@link SECRET_RETRY_MAX_MS}. */
7773
+ var SECRET_RETRY_FIRST_MS = 5e3;
7774
+ var SECRET_RETRY_MAX_MS = 5 * 6e4;
7775
+ /** Coalesces a burst of `keychain.changed` events into one re-resolve. */
7776
+ var SECRET_CHANGE_DEBOUNCE_MS = 250;
6894
7777
  /**
6895
7778
  * Base class for CamStack addons. Eliminates settings boilerplate:
6896
7779
  *
@@ -6960,6 +7843,33 @@ var BaseAddon = class {
6960
7843
  settingsStoreReady = false;
6961
7844
  /** Default config values. Provided via constructor. */
6962
7845
  defaults;
7846
+ /**
7847
+ * Hidden-state paths that hold secrets (D787) — values the addon writes
7848
+ * itself (`updateGlobalSettings`, `state()`) that no form field declares.
7849
+ * Stored in the keychain exactly like a `password` field. Syntax:
7850
+ * `'snapshotSigningKey'`, `'identity.pincode'`, `'tokens[userId].accessToken'`
7851
+ * (`key[<id field>]` addresses array items by id, never by index).
7852
+ */
7853
+ secretStatePaths = [];
7854
+ _addonSecretTree = null;
7855
+ _deviceSecretTree = null;
7856
+ /** Refs the last resolved config pointed at — a change to one re-resolves. */
7857
+ _configSecretRefs = /* @__PURE__ */ new Set();
7858
+ _unresolvedSecrets = [];
7859
+ _secretRetryTimer = null;
7860
+ _secretRetryDelayMs = SECRET_RETRY_FIRST_MS;
7861
+ _secretChangeTimer = null;
7862
+ _secretChangeUnsub = null;
7863
+ /** >0 while an OPERATOR's settings write is being applied. */
7864
+ _operatorWriteDepth = 0;
7865
+ /**
7866
+ * The keychain-aware settings handle (D798). Its `raw` view is the ONLY way
7867
+ * to the marker-bearing blobs and stays private to this class: the form
7868
+ * hydrate and config resolution need markers, addon code never does.
7869
+ */
7870
+ _secretSettings = null;
7871
+ /** Refs an addon-facing read could not resolve — each is logged once per process. */
7872
+ _loggedUnresolvedReads = /* @__PURE__ */ new Set();
6963
7873
  constructor(defaults) {
6964
7874
  this.defaults = defaults;
6965
7875
  this._config = { ...defaults };
@@ -6995,8 +7905,26 @@ var BaseAddon = class {
6995
7905
  return this._config;
6996
7906
  }
6997
7907
  async initialize(context) {
6998
- this._ctx = context;
7908
+ const secrets = context.secrets;
7909
+ if (secrets !== void 0) {
7910
+ const { context: wrapped, handle } = createSecretAwareContext(context, {
7911
+ secrets,
7912
+ addonTree: () => this.addonSecretTree(),
7913
+ deviceTree: () => this.deviceSecretTree(),
7914
+ onOrphaned: (refs) => context.logger.warn("keychain refs dropped by a settings write could not be deleted", { meta: { refs: [...refs] } }),
7915
+ isOperatorWrite: () => this._operatorWriteDepth > 0,
7916
+ onUnresolved: (unresolved) => this.logUnresolvedRead(unresolved)
7917
+ });
7918
+ this._ctx = wrapped;
7919
+ this._secretSettings = handle;
7920
+ } else {
7921
+ this._ctx = context;
7922
+ this._secretSettings = null;
7923
+ }
6999
7924
  await this.resolveConfig();
7925
+ if (secrets !== void 0) this._secretChangeUnsub = secrets.onChange((ref) => {
7926
+ if (this._configSecretRefs.has(ref)) this.scheduleSecretReresolve(SECRET_CHANGE_DEBOUNCE_MS);
7927
+ });
7000
7928
  const result = await this.onInitialize();
7001
7929
  this.emitLifecycle(EventCategory.AddonStarted);
7002
7930
  const normalized = normalizeAddonInitResult(result);
@@ -7029,6 +7957,12 @@ var BaseAddon = class {
7029
7957
  */
7030
7958
  async onHubReachable() {}
7031
7959
  async shutdown() {
7960
+ this._secretChangeUnsub?.();
7961
+ this._secretChangeUnsub = null;
7962
+ if (this._secretRetryTimer !== null) clearTimeout(this._secretRetryTimer);
7963
+ if (this._secretChangeTimer !== null) clearTimeout(this._secretChangeTimer);
7964
+ this._secretRetryTimer = null;
7965
+ this._secretChangeTimer = null;
7032
7966
  this.emitLifecycle(EventCategory.AddonStopped);
7033
7967
  if (this.autoEmitReadiness) this.emitReadinessForProviders("down");
7034
7968
  await this.onShutdown();
@@ -7103,11 +8037,8 @@ var BaseAddon = class {
7103
8037
  async getGlobalSettings(overlay, cap, nodeId) {
7104
8038
  const schema = this.globalSettingsSchema(cap);
7105
8039
  if (!schema) return { sections: [] };
7106
- const projected = await this.resolveGlobalStore(nodeId, cap);
7107
- return hydrateSchema(schema, overlay ? {
7108
- ...projected,
7109
- ...overlay
7110
- } : projected);
8040
+ const projected = await this.readRawProjectedStore(nodeId, cap);
8041
+ return hydrateSchema(schema, overlay ? await this.overlayKeepingMarkers(projected, overlay) : projected, { inlineSecretsAsViews: true });
7111
8042
  }
7112
8043
  /**
7113
8044
  * The integration-level view of this addon's settings: exactly the sections
@@ -7152,11 +8083,11 @@ var BaseAddon = class {
7152
8083
  });
7153
8084
  }
7154
8085
  if (sections.length === 0) return null;
7155
- const projected = await this.resolveGlobalStore(nodeId);
8086
+ const projected = await this.readRawProjectedStore(nodeId);
7156
8087
  return hydrateSchema({
7157
8088
  ...schema,
7158
8089
  sections
7159
- }, projected);
8090
+ }, projected, { inlineSecretsAsViews: true });
7160
8091
  }
7161
8092
  /**
7162
8093
  * The raw addon store PROJECTED onto the target node's bare per-node keys:
@@ -7169,12 +8100,50 @@ var BaseAddon = class {
7169
8100
  * the store for custom option logic (option narrowing, value snapping) to
7170
8101
  * read it per-node — never `ctx.settings.readAddonStore()` directly.
7171
8102
  * `nodeId` omitted ⇒ the local node (node-blind injection from ctx).
8103
+ *
8104
+ * Keychain values come back RESOLVED (D798): a secret reads as its value,
8105
+ * never as a `{ $secret }` marker. One the keychain cannot serve right now
8106
+ * stays a marker — "stored, unavailable" (`isSecretMarker()` is true, and it
8107
+ * is listed in {@link unresolvedSecrets}) — never `''` and never absent, so
8108
+ * it cannot be mistaken for "nothing stored, mint a new one". Writing the
8109
+ * resolved blob back is a no-op for every unchanged secret.
7172
8110
  */
7173
8111
  async resolveGlobalStore(nodeId, cap) {
7174
8112
  const raw = await this._ctx?.settings?.readAddonStore() ?? {};
8113
+ return this.projectForNode(raw, nodeId, cap);
8114
+ }
8115
+ projectForNode(store, nodeId, cap) {
7175
8116
  const keys = this.perNodeKeys(cap);
7176
8117
  const node = normalizeNodeId(nodeId ?? this._ctx?.kernel?.localNodeId);
7177
- return keys.size > 0 ? projectStore(raw, keys, node) : raw;
8118
+ return keys.size > 0 ? projectStore(store, keys, node) : store;
8119
+ }
8120
+ /** The PROJECTED store with its markers — the form hydrate only (D798). */
8121
+ async readRawProjectedStore(nodeId, cap) {
8122
+ const raw = await this.rawSettings()?.readAddonStore() ?? {};
8123
+ return this.projectForNode(raw, nodeId, cap);
8124
+ }
8125
+ /**
8126
+ * `{ ...stored, ...overlay }`, except that an overlay member equal to the
8127
+ * RESOLVED stored one keeps the stored (marker-bearing) member — so a form
8128
+ * hydrated from a resolved overlay still shows a secret as "set", never as
8129
+ * its value.
8130
+ */
8131
+ async overlayKeepingMarkers(stored, overlay) {
8132
+ const secrets = this._ctx?.secrets;
8133
+ const merged = {
8134
+ ...stored,
8135
+ ...overlay
8136
+ };
8137
+ if (secrets === void 0 || collectSecretMarkerRefs(stored).length === 0) return merged;
8138
+ const { value: resolved } = await resolveSecretMarkers(stored, secrets, {
8139
+ unresolved: "keep-marker",
8140
+ ownedBy: secrets.owner
8141
+ });
8142
+ for (const key of Object.keys(overlay)) {
8143
+ if (collectSecretMarkerRefs(stored[key]).length === 0) continue;
8144
+ if (isJsonEqual(overlay[key], resolved[key])) merged[key] = stored[key];
8145
+ }
8146
+ return merged;
7178
8147
  }
7179
8148
  /**
7180
8149
  * Whether ONE global key of this addon's store was written, read three-way
@@ -7210,18 +8179,58 @@ var BaseAddon = class {
7210
8179
  value: result.value[key]
7211
8180
  };
7212
8181
  }
8182
+ /**
8183
+ * The OPERATOR's write — a settings form or an admin API call, dispatched by
8184
+ * the kernel. Identical to {@link updateGlobalSettings}, except that a secret
8185
+ * the operator sends is stored as sent even when it equals a pre-keychain
8186
+ * inline value: the operator re-entering a password is a change, an addon
8187
+ * writing back what it read is not (D787).
8188
+ */
8189
+ async updateGlobalSettingsAsOperator(patch, nodeId) {
8190
+ this._operatorWriteDepth++;
8191
+ try {
8192
+ await this.applyGlobalPatch(patch, nodeId);
8193
+ } finally {
8194
+ this._operatorWriteDepth--;
8195
+ }
8196
+ }
7213
8197
  async updateGlobalSettings(patch, nodeId) {
8198
+ await this.applyGlobalPatch(patch, nodeId);
8199
+ }
8200
+ /**
8201
+ * REMOVE stored secrets — their keychain values and their markers (D787).
8202
+ *
8203
+ * Writing `''` to a secret field KEEPS what is stored (an empty string is
8204
+ * what a defaults fallback writes back, and it must never destroy a
8205
+ * credential), so code that means "forget this token" says so here. Without
8206
+ * a keychain (an older kernel) it writes `''`, as such code always did.
8207
+ */
8208
+ async clearSecrets(keys, nodeId) {
8209
+ const tree = this.addonSecretTree();
8210
+ const keychain = this._ctx?.secrets !== void 0;
8211
+ const stored = keychain ? await this.readAddonStoreWithRetry() : {};
8212
+ const patch = {};
8213
+ for (const key of keys) {
8214
+ const keychainStored = tree.has(key) || collectSecretMarkerRefs(stored[key]).length > 0;
8215
+ patch[key] = keychain && keychainStored ? SECRET_CLEAR : "";
8216
+ }
8217
+ await this.applyGlobalPatch(patch, nodeId);
8218
+ }
8219
+ async applyGlobalPatch(barePatch, nodeId) {
7214
8220
  const keys = this.perNodeKeys();
7215
8221
  const localNode = normalizeNodeId(this._ctx?.kernel?.localNodeId);
7216
8222
  const target = normalizeNodeId(nodeId ?? this._ctx?.kernel?.localNodeId);
7217
- const barePatch = patch;
7218
8223
  const scoped = keys.size > 0 ? scopePatch(barePatch, keys, target) : barePatch;
7219
- await this._ctx?.settings?.writeAddonStore(scoped);
8224
+ const handle = this._secretSettings;
8225
+ if (handle !== null) {
8226
+ const { changed } = await handle.writeAddonStore(scoped);
8227
+ if (!changed) return;
8228
+ } else await this._ctx?.settings?.writeAddonStore(scoped);
7220
8229
  if (target !== localNode) return;
7221
8230
  await this.resolveConfig();
7222
8231
  await this.onConfigChanged();
7223
8232
  this.emitLifecycle(EventCategory.AddonUpdated, { level: "global" });
7224
- this.maybeAutoRestart(patch, this.globalSettingsSchema());
8233
+ this.maybeAutoRestart(Object.keys(barePatch), this.globalSettingsSchema());
7225
8234
  }
7226
8235
  /**
7227
8236
  * The set of field keys the global settings schema declares `perNode: true`
@@ -7246,7 +8255,7 @@ var BaseAddon = class {
7246
8255
  * time to return its response before the addon is torn down and
7247
8256
  * re-initialised by `AddonRegistryService.restartAddon`.
7248
8257
  */
7249
- maybeAutoRestart(patch, schema) {
8258
+ maybeAutoRestart(patchKeys, schema) {
7250
8259
  if (!schema) return;
7251
8260
  const restartKeys = /* @__PURE__ */ new Set();
7252
8261
  for (const section of schema.sections) for (const field of section.fields) {
@@ -7254,13 +8263,13 @@ var BaseAddon = class {
7254
8263
  if (field.requiresRestart) restartKeys.add(field.key);
7255
8264
  }
7256
8265
  if (restartKeys.size === 0) return;
7257
- if (!Object.keys(patch).some((k) => restartKeys.has(k))) return;
8266
+ if (!patchKeys.some((k) => restartKeys.has(k))) return;
7258
8267
  const ctx = this._ctx;
7259
8268
  if (!ctx) return;
7260
8269
  const addonId = ctx.id;
7261
8270
  setImmediate(() => {
7262
8271
  ctx.api.addons?.restartAddon?.mutate({ addonId }).then(() => {
7263
- ctx.logger.info("addon auto-restart triggered by restart-required setting change", { meta: { changedFields: Object.keys(patch).filter((k) => restartKeys.has(k)) } });
8272
+ ctx.logger.info("addon auto-restart triggered by restart-required setting change", { meta: { changedFields: patchKeys.filter((k) => restartKeys.has(k)) } });
7264
8273
  }).catch((err) => {
7265
8274
  ctx.logger.error("addon auto-restart failed", { meta: { error: err instanceof Error ? err.message : String(err) } });
7266
8275
  });
@@ -7269,7 +8278,7 @@ var BaseAddon = class {
7269
8278
  async getDeviceSettings(deviceId) {
7270
8279
  const schema = this.deviceSettingsSchema();
7271
8280
  if (!schema) return { sections: [] };
7272
- return hydrateSchema(schema, await this._ctx?.settings?.readDeviceStore(deviceId) ?? {});
8281
+ return hydrateSchema(schema, await this.rawSettings()?.readDeviceStore(deviceId) ?? {}, { inlineSecretsAsViews: true });
7273
8282
  }
7274
8283
  async updateDeviceSettings(deviceId, patch) {
7275
8284
  await this._ctx?.settings?.writeDeviceStore(deviceId, patch);
@@ -7399,7 +8408,7 @@ var BaseAddon = class {
7399
8408
  * selection at boot (absent scoped key ⇒ the constructor default wins).
7400
8409
  */
7401
8410
  async resolveConfig() {
7402
- const stored = await this.readAddonStoreWithRetry();
8411
+ const stored = await this.resolveStoredSecrets(await this.readAddonStoreWithRetry());
7403
8412
  const perNode = this.perNodeKeys();
7404
8413
  const localNode = normalizeNodeId(this._ctx?.kernel?.localNodeId);
7405
8414
  const resolved = { ...this.defaults };
@@ -7424,7 +8433,7 @@ var BaseAddon = class {
7424
8433
  key,
7425
8434
  schema,
7426
8435
  fallback,
7427
- read: () => this.readAddonStoreWithRetry(),
8436
+ read: async () => this.resolveStoredSecrets(await this.readAddonStoreWithRetry()),
7428
8437
  write: async (patch) => {
7429
8438
  await this._ctx?.settings?.writeAddonStore(patch);
7430
8439
  },
@@ -7441,7 +8450,7 @@ var BaseAddon = class {
7441
8450
  key,
7442
8451
  schema,
7443
8452
  fallback,
7444
- read: async () => await this._ctx?.settings?.readDeviceStore(deviceId) ?? {},
8453
+ read: async () => this.resolveStoredSecrets(await this.rawSettings()?.readDeviceStore(deviceId) ?? {}, false),
7445
8454
  write: async (patch) => {
7446
8455
  await this._ctx?.settings?.writeDeviceStore(deviceId, patch);
7447
8456
  },
@@ -7453,6 +8462,87 @@ var BaseAddon = class {
7453
8462
  } })
7454
8463
  });
7455
8464
  }
8465
+ /** The addon store's secret tree: schema fields by TYPE, plus `secretStatePaths`. */
8466
+ addonSecretTree() {
8467
+ this._addonSecretTree ??= mergeSecretStatePaths(secretTreeFromSchema(this.globalSettingsSchema()), this.secretStatePaths);
8468
+ return this._addonSecretTree;
8469
+ }
8470
+ deviceSecretTree() {
8471
+ this._deviceSecretTree ??= secretTreeFromSchema(this.deviceSettingsSchema());
8472
+ return this._deviceSecretTree;
8473
+ }
8474
+ /**
8475
+ * Secrets of this addon's stored config that could not be resolved on the
8476
+ * last read, with why. Non-empty means the addon is running WITHOUT them —
8477
+ * an addon whose function needs one should report itself degraded rather
8478
+ * than start on an empty credential.
8479
+ */
8480
+ get unresolvedSecrets() {
8481
+ return this._unresolvedSecrets;
8482
+ }
8483
+ /**
8484
+ * Substitute every keychain marker in a stored blob with its value. With no
8485
+ * keychain (no `ctx.secrets`) or no marker, the blob comes back unchanged.
8486
+ * An unresolvable value is LEFT OUT (never `''`), logged by ref — never by
8487
+ * value — and, when the cause can pass, retried with backoff. Nothing is
8488
+ * ever written back from here.
8489
+ */
8490
+ async resolveStoredSecrets(blob, trackForConfig = true) {
8491
+ const secrets = this._ctx?.secrets;
8492
+ if (secrets === void 0) return blob;
8493
+ const refs = collectSecretMarkerRefs(blob);
8494
+ if (trackForConfig) this._configSecretRefs = new Set(refs);
8495
+ if (refs.length === 0) {
8496
+ if (trackForConfig) this._unresolvedSecrets = [];
8497
+ return blob;
8498
+ }
8499
+ const { value, unresolved } = await resolveSecretMarkers(blob, secrets);
8500
+ if (trackForConfig) {
8501
+ this._unresolvedSecrets = unresolved;
8502
+ if (unresolved.length > 0) {
8503
+ this._ctx?.logger?.error?.("secret unavailable — running without it, will retry", { meta: { secrets: unresolved.map((u) => ({
8504
+ ref: u.ref,
8505
+ reason: u.reason
8506
+ })) } });
8507
+ if (unresolved.some((u) => u.reason !== "missing" && u.reason !== "forbidden")) {
8508
+ this.scheduleSecretReresolve(this._secretRetryDelayMs);
8509
+ this._secretRetryDelayMs = Math.min(this._secretRetryDelayMs * 2, SECRET_RETRY_MAX_MS);
8510
+ }
8511
+ } else this._secretRetryDelayMs = SECRET_RETRY_FIRST_MS;
8512
+ }
8513
+ return value;
8514
+ }
8515
+ /**
8516
+ * The marker-bearing settings reads (D798) — private on purpose. Without a
8517
+ * keychain the context's own view is already raw.
8518
+ */
8519
+ rawSettings() {
8520
+ return this._secretSettings?.raw ?? this._ctx?.settings;
8521
+ }
8522
+ /** An addon-facing read met markers it could not resolve: say so once per ref. */
8523
+ logUnresolvedRead(unresolved) {
8524
+ const fresh = unresolved.filter((u) => !this._loggedUnresolvedReads.has(u.ref));
8525
+ if (fresh.length === 0) return;
8526
+ for (const u of fresh) this._loggedUnresolvedReads.add(u.ref);
8527
+ this._ctx?.logger?.warn?.("settings read: a stored secret is unavailable — it reads as its marker, not as a value", { meta: { secrets: fresh.map((u) => ({
8528
+ ref: u.ref,
8529
+ reason: u.reason
8530
+ })) } });
8531
+ }
8532
+ /** Re-resolve the config (a keychain-only change, or a retry) and apply it. */
8533
+ scheduleSecretReresolve(delayMs) {
8534
+ const timerOf = delayMs === SECRET_CHANGE_DEBOUNCE_MS ? "_secretChangeTimer" : "_secretRetryTimer";
8535
+ if (this[timerOf] !== null) return;
8536
+ const timer = setTimeout(() => {
8537
+ this[timerOf] = null;
8538
+ if (this._ctx === null) return;
8539
+ this.resolveConfig().then(() => this.onConfigChanged()).catch((err) => {
8540
+ this._ctx?.logger?.error?.("re-resolving secrets failed", { meta: { error: err instanceof Error ? err.message : String(err) } });
8541
+ });
8542
+ }, delayMs);
8543
+ timer.unref?.();
8544
+ this[timerOf] = timer;
8545
+ }
7456
8546
  /**
7457
8547
  * Wrap `ctx.settings.readAddonStore()` with a short retry budget so a
7458
8548
  * transient settings-store outage (mid-restart of sqlite-settings, tsx-watch
@@ -7465,7 +8555,7 @@ var BaseAddon = class {
7465
8555
  * `{}` (defaults) — the addon's first successful patch will rehydrate.
7466
8556
  */
7467
8557
  async readAddonStoreWithRetry() {
7468
- const settings = this._ctx?.settings;
8558
+ const settings = this.rawSettings();
7469
8559
  if (!settings) return {};
7470
8560
  const delaysMs = [
7471
8561
  150,
@@ -8028,6 +9118,69 @@ method(object({ deviceId: number() }), array(StreamSourceEntrySchema)), method(o
8028
9118
  kind: "mutation",
8029
9119
  auth: "admin"
8030
9120
  }), method(object({ deviceId: number() }), unknown().nullable()), method(object({ deviceId: number() }), RawStateResultSchema.nullable(), { auth: "protected" });
9121
+ function defOf(schema) {
9122
+ return schema._zod?.def ?? {};
9123
+ }
9124
+ function declaredHere(schema) {
9125
+ return globalRegistry.get(schema)?.secret === true;
9126
+ }
9127
+ /** Wrapper kinds whose `innerType` is the field itself. */
9128
+ var WRAPPERS = new Set([
9129
+ "optional",
9130
+ "nullable",
9131
+ "default",
9132
+ "prefault",
9133
+ "catch",
9134
+ "readonly",
9135
+ "nonoptional"
9136
+ ]);
9137
+ /**
9138
+ * The schema layers that make up ONE field: the schema itself and every
9139
+ * wrapper below it (optional / default / nullable / readonly / catch), plus
9140
+ * both sides of a pipe (`z.preprocess` puts the real schema on `out`,
9141
+ * `.transform` on `in`).
9142
+ */
9143
+ function layersOf(schema) {
9144
+ const out = [];
9145
+ const queue = [schema];
9146
+ while (queue.length > 0) {
9147
+ const s = queue.shift();
9148
+ if (!s || out.includes(s)) continue;
9149
+ out.push(s);
9150
+ const def = defOf(s);
9151
+ if (def.type !== void 0 && WRAPPERS.has(def.type) && def.innerType) queue.push(def.innerType);
9152
+ if (def.type === "pipe") {
9153
+ if (def.in) queue.push(def.in);
9154
+ if (def.out) queue.push(def.out);
9155
+ }
9156
+ }
9157
+ return out;
9158
+ }
9159
+ /** True when any layer of this field declares `.meta({ secret: true })`. */
9160
+ function isZodSecret(schema) {
9161
+ return layersOf(schema).some(declaredHere);
9162
+ }
9163
+ /**
9164
+ * Every declared secret path in a config schema: dotted keys, `[]` for "each
9165
+ * element of this array" (`connection.password`, `rows[].token`). A declared
9166
+ * object or array is reported as one path and not descended into — everything
9167
+ * under it is secret.
9168
+ */
9169
+ function collectZodSecretPaths(schema, prefix = "") {
9170
+ if (isZodSecret(schema)) return prefix.length > 0 ? [prefix] : [];
9171
+ const paths = [];
9172
+ for (const layer of layersOf(schema)) {
9173
+ const def = defOf(layer);
9174
+ if (def.type === "object" && def.shape) for (const [key, child] of Object.entries(def.shape)) paths.push(...collectZodSecretPaths(child, prefix ? `${prefix}.${key}` : key));
9175
+ else if (def.type === "array" && def.element) paths.push(...collectZodSecretPaths(def.element, `${prefix}[]`));
9176
+ else if (def.type === "union" && def.options) for (const option of def.options) paths.push(...collectZodSecretPaths(option, prefix));
9177
+ else if (def.type === "intersection") {
9178
+ if (def.left) paths.push(...collectZodSecretPaths(def.left, prefix));
9179
+ if (def.right) paths.push(...collectZodSecretPaths(def.right, prefix));
9180
+ }
9181
+ }
9182
+ return [...new Set(paths)];
9183
+ }
8031
9184
  //#endregion
8032
9185
  //#region ../types/dist/err-msg-DX6i_MY4.mjs
8033
9186
  var DeviceType = /* @__PURE__ */ function(DeviceType) {
@@ -9705,6 +10858,278 @@ var CameraSwitchGroupSchema = object({
9705
10858
  fetchedAt: number()
9706
10859
  });
9707
10860
  /**
10861
+ * The trainer contract — what the hub hands the cloud trainer and what it
10862
+ * gets back (cloud training, D805+).
10863
+ *
10864
+ * The trainer (`hf/camstack-trainer`, published as the Hugging Face repo
10865
+ * `camstack/camstack-trainer`) is a separate AGPL program the hub never
10866
+ * imports: `job.json` goes in, files come out, and progress is `CAMSTACK_EVENT`
10867
+ * lines on stdout. These schemas are the hub's half of that boundary; the
10868
+ * trainer's pydantic models (and the JSON Schemas generated from them under
10869
+ * `hf/camstack-trainer/schemas/`) are the other half. A change here is a
10870
+ * change there, in the same piece of work.
10871
+ *
10872
+ * No `.default()` anywhere: defaults do not run on the addon cap path, so the
10873
+ * orchestrator fills every field of a job spec explicitly.
10874
+ */
10875
+ var TRAINING_JOB_SCHEMA = "camstack.training/v1";
10876
+ var TRAINING_RESULT_SCHEMA = "camstack.training-result/v1";
10877
+ /** What the trainer can export. Edge TPU is a later, separate image. */
10878
+ var TrainingExportSchema = _enum([
10879
+ "onnx",
10880
+ "openvino-fp16",
10881
+ "openvino-int8",
10882
+ "coreml-fp16"
10883
+ ]);
10884
+ var FloorsSchema = record(string(), number().min(0).max(1));
10885
+ object({
10886
+ schema: literal(TRAINING_JOB_SCHEMA),
10887
+ jobKey: string().uuid(),
10888
+ target: object({
10889
+ kind: literal("detector"),
10890
+ step: literal("object-detection")
10891
+ }),
10892
+ base: object({
10893
+ modelId: string().min(1),
10894
+ /** Ultralytics weights id, e.g. `yolov9m.pt`. */
10895
+ weights: string().min(1),
10896
+ imgsz: number().int().positive()
10897
+ }),
10898
+ baseline: object({
10899
+ modelId: string().min(1),
10900
+ /** The baseline ONNX the holdout comparison runs; public mirror URL. */
10901
+ onnxUrl: string().url(),
10902
+ imgsz: number().int().positive(),
10903
+ floors: FloorsSchema
10904
+ }),
10905
+ dataset: object({
10906
+ versionId: string().min(1),
10907
+ annotationHash: string(),
10908
+ /** sha256 of the uploaded archive; the trainer refuses a mismatch (exit 65). */
10909
+ sha256: string().regex(/^[0-9a-f]{64}$/)
10910
+ }),
10911
+ split: object({
10912
+ holdoutCameras: array(number().int()),
10913
+ /** When no camera is held out: the last N days of every camera. */
10914
+ holdoutLastDays: number().int().nonnegative(),
10915
+ valFraction: number().min(0).max(.5),
10916
+ seed: number().int()
10917
+ }),
10918
+ hyper: object({
10919
+ epochs: number().int().positive(),
10920
+ batch: number().int().positive(),
10921
+ lr0: number().positive(),
10922
+ /** Layers frozen from the start of the backbone; 0 = none. */
10923
+ freeze: number().int().nonnegative(),
10924
+ patience: number().int().nonnegative(),
10925
+ seed: number().int()
10926
+ }),
10927
+ replay: object({
10928
+ source: literal("coco2017"),
10929
+ count: number().int().nonnegative()
10930
+ }),
10931
+ exports: array(TrainingExportSchema).min(1),
10932
+ calibration: object({ maxFrames: number().int().positive() }),
10933
+ floors: object({
10934
+ minSupport: number().int().positive(),
10935
+ clamp: number().min(0).max(1)
10936
+ }),
10937
+ int8Gate: object({ maxMap50Drop: number().min(0).max(1) }),
10938
+ catalog: object({
10939
+ id: string().regex(/^[a-z0-9][a-z0-9-]{2,80}$/),
10940
+ name: string().min(1).max(160)
10941
+ })
10942
+ });
10943
+ /** One regular file of the bundle. An mlpackage contributes one row per member. */
10944
+ var TrainingResultFileSchema = object({
10945
+ path: string().min(1),
10946
+ bytes: number().int().nonnegative(),
10947
+ sha256: string().regex(/^[0-9a-f]{64}$/),
10948
+ format: _enum([
10949
+ "onnx",
10950
+ "openvino",
10951
+ "coreml",
10952
+ "pt"
10953
+ ]),
10954
+ variant: _enum(["base", "int8"])
10955
+ });
10956
+ var DraftFormatSchema = object({
10957
+ /** RELATIVE path inside the bundle; the hub rewrites it to `camstack-local://`. */
10958
+ url: string().min(1),
10959
+ sizeMB: number().nonnegative(),
10960
+ isDirectory: boolean().optional(),
10961
+ files: array(string()).optional(),
10962
+ runtimes: array(literal("python")).optional(),
10963
+ revision: string().min(1)
10964
+ });
10965
+ /** The trainer's half of a catalog entry; the hub completes it (labels, licence, group). */
10966
+ var TrainingCatalogDraftSchema = object({
10967
+ id: string().min(1),
10968
+ name: string().min(1),
10969
+ description: string(),
10970
+ labels: array(unknown()),
10971
+ inputSize: object({
10972
+ width: number().int().positive(),
10973
+ height: number().int().positive()
10974
+ }),
10975
+ preprocessMode: literal("letterbox"),
10976
+ defaultClassFloors: FloorsSchema,
10977
+ formats: object({
10978
+ onnx: DraftFormatSchema.optional(),
10979
+ openvino: DraftFormatSchema.optional(),
10980
+ coreml: DraftFormatSchema.optional()
10981
+ })
10982
+ });
10983
+ /** One class of one model's holdout report (the eval harness's summary). */
10984
+ var TrainingEvalClassSchema = object({
10985
+ positives: number().int(),
10986
+ floor: number().nullable(),
10987
+ tp: number().int(),
10988
+ fp: number().int(),
10989
+ fn: number().int(),
10990
+ precision: number().nullable(),
10991
+ recall: number().nullable(),
10992
+ ap50: number().nullable(),
10993
+ recallByCamera: record(string(), number().nullable()).optional(),
10994
+ recallByLight: record(string(), number().nullable()).optional(),
10995
+ fpByCamera: record(string(), number()).optional(),
10996
+ smallFound: number().int().optional(),
10997
+ smallTotal: number().int().optional()
10998
+ }).passthrough();
10999
+ var TrainingEvalReportSchema = object({
11000
+ frames: number().int(),
11001
+ classes: record(string(), TrainingEvalClassSchema)
11002
+ }).passthrough();
11003
+ /**
11004
+ * A succeeded result carries every block; a failed one carries the error and
11005
+ * whatever was known by then — the other blocks are ABSENT, not null. The
11006
+ * orchestrator checks the blocks it needs before it trusts a success.
11007
+ */
11008
+ var TrainingResultSchema = object({
11009
+ schema: literal(TRAINING_RESULT_SCHEMA),
11010
+ jobKey: string(),
11011
+ status: _enum(["succeeded", "failed"]),
11012
+ error: object({
11013
+ stage: string(),
11014
+ code: string(),
11015
+ message: string()
11016
+ }).nullable(),
11017
+ trainer: object({
11018
+ version: string(),
11019
+ revision: string()
11020
+ }),
11021
+ toolchain: record(string(), string().nullable()),
11022
+ dataset: object({
11023
+ versionId: string(),
11024
+ annotationHash: string(),
11025
+ sha256: string(),
11026
+ frames: object({
11027
+ train: number().int(),
11028
+ val: number().int(),
11029
+ holdout: number().int()
11030
+ }),
11031
+ holdoutCameras: array(number().int()),
11032
+ replayImages: number().int()
11033
+ }).optional(),
11034
+ training: object({
11035
+ epochsRun: number().int(),
11036
+ bestEpoch: number().int(),
11037
+ bestMap50: number(),
11038
+ bestMap50_95: number(),
11039
+ seconds: number()
11040
+ }).optional(),
11041
+ evaluation: object({
11042
+ holdoutFrames: number().int(),
11043
+ baseline: TrainingEvalReportSchema.nullable(),
11044
+ candidate: TrainingEvalReportSchema.nullable(),
11045
+ candidateInt8: TrainingEvalReportSchema.nullable(),
11046
+ recallDeltaByCamera: record(string(), record(string(), number())).nullable(),
11047
+ map50: record(string(), number().nullable())
11048
+ }).optional(),
11049
+ floors: object({
11050
+ baseline: FloorsSchema,
11051
+ candidate: FloorsSchema,
11052
+ candidateInt8: FloorsSchema.nullable(),
11053
+ notes: array(string())
11054
+ }).optional(),
11055
+ int8: object({
11056
+ kept: boolean(),
11057
+ map50Fp16: number().nullable(),
11058
+ map50Int8: number().nullable(),
11059
+ reason: string().nullable()
11060
+ }).optional(),
11061
+ exportsDropped: array(object({
11062
+ export: string(),
11063
+ reason: string()
11064
+ })).optional(),
11065
+ files: array(TrainingResultFileSchema).optional(),
11066
+ bundle: object({
11067
+ path: literal("bundle.tar"),
11068
+ bytes: number().int().nonnegative(),
11069
+ sha256: string().regex(/^[0-9a-f]{64}$/)
11070
+ }).nullable().optional(),
11071
+ catalogDraft: object({
11072
+ base: TrainingCatalogDraftSchema,
11073
+ int8: TrainingCatalogDraftSchema.nullable()
11074
+ }).nullable().optional(),
11075
+ licence: string()
11076
+ });
11077
+ var TrainingStageSchema = _enum([
11078
+ "prepare",
11079
+ "replay",
11080
+ "train",
11081
+ "eval",
11082
+ "export",
11083
+ "package"
11084
+ ]);
11085
+ var EventBase = {
11086
+ v: literal(1),
11087
+ ts: number()
11088
+ };
11089
+ discriminatedUnion("type", [
11090
+ object({
11091
+ ...EventBase,
11092
+ type: literal("stage"),
11093
+ stage: TrainingStageSchema
11094
+ }),
11095
+ object({
11096
+ ...EventBase,
11097
+ type: literal("epoch"),
11098
+ epoch: number().int(),
11099
+ epochs: number().int(),
11100
+ boxLoss: number().nullable().optional(),
11101
+ map50: number().nullable().optional(),
11102
+ map50_95: number().nullable().optional(),
11103
+ etaSec: number().nullable().optional()
11104
+ }),
11105
+ object({
11106
+ ...EventBase,
11107
+ type: literal("metric"),
11108
+ name: string(),
11109
+ value: number()
11110
+ }),
11111
+ object({
11112
+ ...EventBase,
11113
+ type: literal("artifact"),
11114
+ path: string(),
11115
+ bytes: number(),
11116
+ sha256: string()
11117
+ }),
11118
+ object({
11119
+ ...EventBase,
11120
+ type: literal("done"),
11121
+ status: _enum(["succeeded", "failed"]),
11122
+ resultSha256: string().nullable().optional()
11123
+ }),
11124
+ object({
11125
+ ...EventBase,
11126
+ type: literal("error"),
11127
+ stage: string(),
11128
+ code: string(),
11129
+ message: string()
11130
+ })
11131
+ ]);
11132
+ /**
9708
11133
  * What the gate decided about a birth, from the CALLER's point of view.
9709
11134
  *
9710
11135
  * Deliberately not `ConfirmationVerdict`: `undecided` is not a birth decision
@@ -12032,7 +13457,9 @@ var AddonHttpRouteSchema = object({
12032
13457
  "authenticated",
12033
13458
  "admin"
12034
13459
  ]).optional(),
12035
- description: string().optional()
13460
+ description: string().optional(),
13461
+ /** The hub limits this route per client address before the handler runs. */
13462
+ rateLimit: _enum(["auth"]).optional()
12036
13463
  });
12037
13464
  /**
12038
13465
  * Cross-process route invocation envelope. The hub captures the
@@ -12737,6 +14164,37 @@ var BackupDestinationInfoSchema = object({
12737
14164
  lastError: string().optional()
12738
14165
  });
12739
14166
  /**
14167
+ * How an archive is encrypted (operator decision 2026-10-09): to a backup
14168
+ * PUBLIC key the hub holds, so only the operator's secret key opens it.
14169
+ * Absent on a plain `.tar.gz` — every archive made before encryption, or
14170
+ * with it off — which restores without a key.
14171
+ */
14172
+ var BackupArchiveEncryptionSchema = object({
14173
+ /** `x25519-hkdf-aes256gcm-stream-v1`. */
14174
+ scheme: string(),
14175
+ /** 16 hex — the backup key whose secret restores this archive. */
14176
+ keyId: string()
14177
+ });
14178
+ /**
14179
+ * The backup encryption setting. The hub keeps PUBLIC keys only: the active
14180
+ * one new archives are encrypted to, and the retired ones older archives
14181
+ * still need. The secret key is shown once, at `setupEncryption`.
14182
+ */
14183
+ var BackupEncryptionStatusSchema = object({
14184
+ enabled: boolean(),
14185
+ active: object({
14186
+ keyId: string(),
14187
+ publicKey: string(),
14188
+ createdAt: number()
14189
+ }).nullable(),
14190
+ /** Every key ever set up, newest first. */
14191
+ keys: array(object({
14192
+ keyId: string(),
14193
+ createdAt: number(),
14194
+ retiredAt: number().nullable()
14195
+ })).readonly()
14196
+ });
14197
+ /**
12740
14198
  * Per-archive entry returned by `backup.listArchives({ destinationId })`.
12741
14199
  * Same shape the destination drill-in renders. Sourced from the per-
12742
14200
  * location `manifests.json` (no per-archive tarball read required).
@@ -12748,7 +14206,9 @@ var BackupArchiveEntrySchema = object({
12748
14206
  sizeBytes: number(),
12749
14207
  label: string().optional(),
12750
14208
  /** Top-level locations included in the archive (db, addons, tls, …). */
12751
- locations: array(string()).readonly()
14209
+ locations: array(string()).readonly(),
14210
+ /** Present when the archive is encrypted; restore then needs that key. */
14211
+ encryption: BackupArchiveEncryptionSchema.optional()
12752
14212
  });
12753
14213
  var BackupEntrySchema = object({
12754
14214
  id: string(),
@@ -12757,7 +14217,8 @@ var BackupEntrySchema = object({
12757
14217
  label: string().optional(),
12758
14218
  createdAt: number(),
12759
14219
  sizeBytes: number(),
12760
- locations: array(string()).optional()
14220
+ locations: array(string()).optional(),
14221
+ encryption: BackupArchiveEncryptionSchema.optional()
12761
14222
  });
12762
14223
  var ArchiveEntrySchema = object({
12763
14224
  path: string(),
@@ -12946,10 +14407,40 @@ method(_void(), array(BackupDestinationInfoSchema).readonly(), { auth: "admin" }
12946
14407
  * this list and skips entries whose path doesn't start with
12947
14408
  * any of them.
12948
14409
  */
12949
- locations: array(string()).optional()
14410
+ locations: array(string()).optional(),
14411
+ /**
14412
+ * The backup SECRET key, for an encrypted archive (ignored for a plain
14413
+ * one). The archive is decrypted into the hub's private staging
14414
+ * before the restart; the key is not stored. A wrong or missing key
14415
+ * is refused before the archive is downloaded.
14416
+ */
14417
+ backupSecretKey: string().optional()
12950
14418
  }), _void(), {
12951
14419
  kind: "mutation",
12952
14420
  auth: "admin"
14421
+ }), method(_void(), BackupEncryptionStatusSchema, { auth: "admin" }), method(object({}), object({
14422
+ keyId: string(),
14423
+ secretKey: string(),
14424
+ publicKey: string(),
14425
+ createdAt: number(),
14426
+ replacedKeyId: string().nullable()
14427
+ }), {
14428
+ kind: "mutation",
14429
+ auth: "admin"
14430
+ }), method(object({}), object({ disabledKeyId: string().nullable() }), {
14431
+ kind: "mutation",
14432
+ auth: "admin"
14433
+ }), method(object({ backupSecretKey: string() }), object({
14434
+ valid: boolean(),
14435
+ keyId: string().nullable(),
14436
+ /** The hub knows this key (active or retired). */
14437
+ known: boolean(),
14438
+ /** It is the key new archives are encrypted to. */
14439
+ active: boolean(),
14440
+ error: string().optional()
14441
+ }), {
14442
+ kind: "mutation",
14443
+ auth: "admin"
12953
14444
  }), method(object({
12954
14445
  destinationId: string(),
12955
14446
  backupId: string()
@@ -14675,7 +16166,60 @@ var CustomModelDescriptorSchema = object({
14675
16166
  stepId: string(),
14676
16167
  entry: ModelCatalogEntrySchema
14677
16168
  });
14678
- method(_void(), array(CustomModelDescriptorSchema).readonly(), { auth: "admin" });
16169
+ /** One regular file of an imported bundle, as the producer measured it. */
16170
+ var ModelBundleFileSchema = object({
16171
+ /** Relative path inside the bundle tar; an mlpackage member is `<x>.mlpackage/<member>`. */
16172
+ path: string().min(1),
16173
+ bytes: number().int().nonnegative(),
16174
+ sha256: string().regex(/^[0-9a-f]{64}$/)
16175
+ });
16176
+ var ImportModelBundleInputSchema = object({
16177
+ /** The registry provider that keeps the model (Model Studio). */
16178
+ addonId: string(),
16179
+ stepId: string().min(1),
16180
+ /**
16181
+ * The catalog rows to register, complete, every format URL already
16182
+ * `camstack-local://<modelId>/<file>` naming a file of the bundle. One
16183
+ * bundle may carry several rows (a base and its INT8 variant).
16184
+ */
16185
+ entries: array(ModelCatalogEntrySchema).min(1).max(4),
16186
+ /** The bundle tar, offered by the producer over `ctx.peerBytes` (same host). */
16187
+ bundle: object({
16188
+ ticket: PeerBytesTicketSchema,
16189
+ bytes: number().int().positive(),
16190
+ sha256: string().regex(/^[0-9a-f]{64}$/)
16191
+ }),
16192
+ /** Every file the tar must hold; anything missing, extra or different is refused. */
16193
+ files: array(ModelBundleFileSchema).min(1).max(64),
16194
+ /** Convert missing engine formats and push the model to every agent afterwards. */
16195
+ distribute: boolean()
16196
+ });
16197
+ var ImportModelBundleResultSchema = discriminatedUnion("kind", [object({
16198
+ kind: literal("imported"),
16199
+ modelIds: array(string()).readonly(),
16200
+ distributed: array(object({
16201
+ modelId: string(),
16202
+ nodeId: string(),
16203
+ format: _enum(MODEL_FORMATS),
16204
+ ok: boolean(),
16205
+ error: string().optional()
16206
+ })).readonly()
16207
+ }), object({
16208
+ kind: literal("refused"),
16209
+ reason: _enum([
16210
+ "transfer-failed",
16211
+ "checksum-mismatch",
16212
+ "bundle-mismatch",
16213
+ "invalid-entry",
16214
+ "id-taken"
16215
+ ]),
16216
+ detail: string()
16217
+ })]);
16218
+ method(_void(), array(CustomModelDescriptorSchema).readonly(), { auth: "admin" }), method(ImportModelBundleInputSchema, ImportModelBundleResultSchema, {
16219
+ kind: "mutation",
16220
+ auth: "admin",
16221
+ timeoutMs: 30 * 6e4
16222
+ });
14679
16223
  /**
14680
16224
  * Query filter for settings-store collections.
14681
16225
  */
@@ -15058,6 +16602,253 @@ id: union([string(), number()]) }), {
15058
16602
  kind: "mutation",
15059
16603
  auth: "admin"
15060
16604
  });
16605
+ /**
16606
+ * `keychain` — the hub's encrypted store of secret values (D787).
16607
+ *
16608
+ * Settings blobs never hold a secret: they hold a marker
16609
+ * `{"$secret":"secret://<owner>/<scope>/<fieldPath>","v":1}` and the value
16610
+ * lives here, AES-256-GCM under a data key that a master key wraps. This cap
16611
+ * is the OWNER's door to its own values: every method is owner-checked
16612
+ * against the CALLER, never against anything the caller claims.
16613
+ *
16614
+ * Who the caller is: the transport stamps `callerAddonId` into the args of a
16615
+ * call that crossed a process (the parent `LocalChildRegistry` from the UDS
16616
+ * connection, the agent from its child's connection carried in
16617
+ * `$hub-cap-fwd`'s envelope). A stamp always overwrites; a wire call with no
16618
+ * stamp has its claim stripped. Only a hub in-process caller may state its own
16619
+ * identity — `ctx.secrets` does that with the addon id closed over. This is
16620
+ * identity against BUGS and misrouting, not against a malicious addon (every
16621
+ * runner is the same OS user): see the threat model in
16622
+ * `docs/design/2026-10-08-secrets-keychain.md`.
16623
+ *
16624
+ * `callerAddonId` is deliberately NOT in any input schema: the tRPC router
16625
+ * parses the input, so a session can never supply it, and the internal mount
16626
+ * floors every method to admin anyway (D240).
16627
+ *
16628
+ * Internal: addons reach it through `ctx.secrets`, never directly.
16629
+ */
16630
+ /** Why a value cannot be served right now. Never folded into "missing". */
16631
+ var KeychainUnavailableReasonSchema = _enum([
16632
+ "key-missing",
16633
+ "wrong-key",
16634
+ "key-file-unreadable",
16635
+ "store-unavailable",
16636
+ "not-initialized",
16637
+ "decrypt-failed"
16638
+ ]);
16639
+ var KeychainStateSchema = discriminatedUnion("state", [object({ state: literal("ready") }), object({
16640
+ state: literal("locked"),
16641
+ reason: KeychainUnavailableReasonSchema
16642
+ })]);
16643
+ var KeychainResolveEntrySchema = discriminatedUnion("kind", [
16644
+ object({
16645
+ kind: literal("value"),
16646
+ value: string(),
16647
+ version: number().int()
16648
+ }),
16649
+ object({ kind: literal("missing") }),
16650
+ object({
16651
+ kind: literal("unavailable"),
16652
+ reason: KeychainUnavailableReasonSchema
16653
+ }),
16654
+ object({ kind: literal("forbidden") })
16655
+ ]);
16656
+ var KeychainResolveResultSchema = record(string(), KeychainResolveEntrySchema);
16657
+ /** Metadata of one stored value — never the value. */
16658
+ var KeychainSecretMetaSchema = object({
16659
+ ref: string(),
16660
+ owner: string(),
16661
+ /** Formatted scope (`global`, `node/<id>`, `device/<id>`, …). */
16662
+ scope: string(),
16663
+ fieldPath: string(),
16664
+ version: number().int(),
16665
+ createdAt: number(),
16666
+ updatedAt: number(),
16667
+ /** `addon:<id>` | `user:<id>` | `system`. */
16668
+ updatedBy: string(),
16669
+ /** Coarse — written at most once an hour per ref. `null` = never read. */
16670
+ lastReadAt: number().nullable()
16671
+ });
16672
+ var RefListSchema = array(string().min(1)).max(512);
16673
+ method(object({
16674
+ ref: string().min(1),
16675
+ value: string().min(1)
16676
+ }), object({
16677
+ ref: string(),
16678
+ version: number().int()
16679
+ }), {
16680
+ kind: "mutation",
16681
+ auth: "admin"
16682
+ }), method(object({ refs: RefListSchema }), KeychainResolveResultSchema, { auth: "admin" }), method(object({ refs: RefListSchema }), object({ deleted: number().int() }), {
16683
+ kind: "mutation",
16684
+ auth: "admin"
16685
+ }), method(object({}), array(KeychainSecretMetaSchema).readonly(), { auth: "admin" }), method(object({}), KeychainStateSchema, { auth: "admin" });
16686
+ var KeychainKeySourceSchema = object({
16687
+ kind: _enum([
16688
+ "config-file",
16689
+ "previous-config-file",
16690
+ "platform",
16691
+ "default-file"
16692
+ ]),
16693
+ /** File sources only — a path is not a secret. */
16694
+ path: string().optional(),
16695
+ /**
16696
+ * True when a whole-volume backup of the data directory carries this key
16697
+ * next to the database it protects (the default file). The page warns.
16698
+ */
16699
+ sharesBackupWithDatabase: boolean()
16700
+ });
16701
+ /**
16702
+ * One keychain reset, as the Secrets page reports it until the operator
16703
+ * acknowledges it. Never a value: refs, counts and table names only.
16704
+ */
16705
+ var KeychainResetRecordSchema = object({
16706
+ id: string(),
16707
+ at: number(),
16708
+ /** `user:<id>` or {@link KEYCHAIN_RESET_TRIGGER_ACTOR}. */
16709
+ actor: string(),
16710
+ /** Why the keychain was locked when it was reset; `null` when it was not locked. */
16711
+ lockedReason: string().nullable(),
16712
+ /** Values moved into the archive table (ciphertext under the lost key). */
16713
+ archived: number().int(),
16714
+ /** `keychain:secrets-orphaned-<ts>`, or `null` when nothing was stored. */
16715
+ archivedCollection: string().nullable(),
16716
+ /**
16717
+ * `keychain:keys-orphaned-<ts>`: the wrapped data keys of the archive, kept
16718
+ * so the archive can still be opened if the lost master key turns up.
16719
+ */
16720
+ archivedKeysCollection: string().nullable(),
16721
+ /**
16722
+ * `system-settings` keys whose marker the reset cleared — the cluster
16723
+ * secret's: a marker left pointing at an archived value would refuse every
16724
+ * agent forever (D797).
16725
+ */
16726
+ clearedSettingsKeys: array(string()).readonly(),
16727
+ /** When an operator dismissed the notice on the Secrets page; `null` until then. */
16728
+ acknowledgedAt: number().nullable()
16729
+ });
16730
+ var KeychainStatusSchema = object({
16731
+ keychain: KeychainStateSchema,
16732
+ /** The source of the master key in use; `null` while locked. */
16733
+ keySource: KeychainKeySourceSchema.nullable(),
16734
+ /** The source configured to be primary — differs from `keySource` while a rotation is pending. */
16735
+ configuredSource: KeychainKeySourceSchema,
16736
+ /** Short fingerprint of the master key in use (`HMAC(KEK, label)`, 16 hex). */
16737
+ fingerprint: string().nullable(),
16738
+ activeKeyId: string().nullable(),
16739
+ /**
16740
+ * The keychain unlocked with a NON-primary source: the configured primary
16741
+ * key is not the one that wraps the data key yet. `rotateMasterKey` moves it.
16742
+ */
16743
+ rotationPending: boolean(),
16744
+ /** Wrapped copies of the data key under a previous master key, kept until purged. */
16745
+ retiredWraps: number().int(),
16746
+ recoveryKeyDownloadedAt: number().nullable(),
16747
+ secretCount: number().int(),
16748
+ /** The most recent reset, acknowledged or not; `null` when the keychain was never reset. */
16749
+ lastReset: KeychainResetRecordSchema.nullable()
16750
+ });
16751
+ /**
16752
+ * Whether a stored value is still pointed at by its owner's settings.
16753
+ * `unknown` is a first-class answer: a scope whose blob could not be read is
16754
+ * never reported as an orphan (and never deleted as one).
16755
+ */
16756
+ var KeychainSecretUsageSchema = _enum([
16757
+ "in-use",
16758
+ "orphan",
16759
+ "unknown"
16760
+ ]);
16761
+ var KeychainAdminSecretSchema = KeychainSecretMetaSchema.extend({ usage: KeychainSecretUsageSchema });
16762
+ var KeychainAuditActionSchema = _enum([
16763
+ "put",
16764
+ "delete",
16765
+ "reveal",
16766
+ "rotate-master-key",
16767
+ "purge-retired-keys",
16768
+ "download-recovery-key",
16769
+ "delete-orphans",
16770
+ "reset",
16771
+ "acknowledge-reset",
16772
+ "initialize"
16773
+ ]);
16774
+ var KeychainAuditEntrySchema = object({
16775
+ id: string(),
16776
+ at: number(),
16777
+ action: KeychainAuditActionSchema,
16778
+ /** `addon:<id>` | `user:<id>` | `system` | `trigger-file`. */
16779
+ actor: string(),
16780
+ ref: string().nullable(),
16781
+ detail: string().nullable()
16782
+ });
16783
+ var KEYCHAIN_RESET_CONFIRMATION = "RESET KEYCHAIN";
16784
+ /**
16785
+ * Secrets the HUB itself holds (owner `system`) that no settings form shows:
16786
+ * `jwt-signing-key` — the session signing key (D797). It is always "in use",
16787
+ * never an orphan; it is generated on a fresh hub and replaced only through
16788
+ * {@link keychainAdminCapability.methods.setSystemSecret}.
16789
+ */
16790
+ var SystemHeldSecretNameSchema = _enum(["jwt-signing-key"]);
16791
+ 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({
16792
+ value: string(),
16793
+ version: number().int()
16794
+ }), {
16795
+ kind: "mutation",
16796
+ auth: "admin",
16797
+ caller: "required"
16798
+ }), method(object({
16799
+ name: SystemHeldSecretNameSchema,
16800
+ value: string().min(16)
16801
+ }), object({
16802
+ ref: string(),
16803
+ version: number().int()
16804
+ }), {
16805
+ kind: "mutation",
16806
+ auth: "admin",
16807
+ caller: "required"
16808
+ }), method(object({ refs: array(string().min(1)).max(1e3) }), object({
16809
+ deleted: array(string()).readonly(),
16810
+ kept: array(object({
16811
+ ref: string(),
16812
+ usage: KeychainSecretUsageSchema
16813
+ })).readonly()
16814
+ }), {
16815
+ kind: "mutation",
16816
+ auth: "admin",
16817
+ caller: "required"
16818
+ }), method(object({}), object({
16819
+ fingerprint: string(),
16820
+ keySource: KeychainKeySourceSchema
16821
+ }), {
16822
+ kind: "mutation",
16823
+ auth: "admin",
16824
+ caller: "required"
16825
+ }), method(object({}), object({ purged: number().int() }), {
16826
+ kind: "mutation",
16827
+ auth: "admin",
16828
+ caller: "required"
16829
+ }), method(object({}), object({
16830
+ key: string(),
16831
+ fingerprint: string(),
16832
+ keySource: KeychainKeySourceSchema
16833
+ }), {
16834
+ kind: "mutation",
16835
+ auth: "admin",
16836
+ caller: "required"
16837
+ }), method(object({ confirm: literal(KEYCHAIN_RESET_CONFIRMATION) }), object({
16838
+ archivedCollection: string().nullable(),
16839
+ archived: number().int()
16840
+ }), {
16841
+ kind: "mutation",
16842
+ auth: "admin",
16843
+ caller: "required"
16844
+ }), method(object({}), object({
16845
+ reset: KeychainResetRecordSchema.nullable(),
16846
+ pendingReentry: array(KeychainSecretMetaSchema).readonly()
16847
+ }), { auth: "admin" }), method(object({}), object({ acknowledged: boolean() }), {
16848
+ kind: "mutation",
16849
+ auth: "admin",
16850
+ caller: "required"
16851
+ });
15061
16852
  method(_void(), object({
15062
16853
  id: string(),
15063
16854
  name: string(),
@@ -16396,7 +18187,11 @@ var DeviceRegisterPayloadSchema = object({
16396
18187
  var DeviceRemovePayloadSchema = object({ deviceId: number() });
16397
18188
  var DevicePersistConfigPayloadSchema = object({
16398
18189
  deviceId: number(),
16399
- data: record(string(), unknown())
18190
+ data: record(string(), unknown()),
18191
+ /** The paths the device's schema declares secret (D783), when the caller
18192
+ * knows them — those values are kept in the keychain, not the blob (D787).
18193
+ * Absent: the paths the device last reported at `registerDevice` apply. */
18194
+ secretConfigPaths: array(string()).optional()
16400
18195
  });
16401
18196
  /** What a migration actually did, per switch. `unreachable` is a first-class
16402
18197
  * answer: a camera that could not be asked is not a camera that was silenced. */
@@ -17999,7 +19794,7 @@ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
17999
19794
  * `login-method` — collection cap through which auth addons contribute
18000
19795
  * their pre-auth login surfaces to the login page. This is the SINGLE,
18001
19796
  * generic mechanism that supersedes the dead `auth.listProviders` reader:
18002
- * every auth addon (OIDC, magic-link, WebAuthn/passkey) registers a
19797
+ * every auth addon (OIDC, WebAuthn/passkey) registers a
18003
19798
  * `login-method` provider and the PUBLIC `auth.listLoginMethods`
18004
19799
  * procedure aggregates them for the unauthenticated login page.
18005
19800
  *
@@ -18007,8 +19802,7 @@ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
18007
19802
  *
18008
19803
  * - `redirect` — a declarative button. The login page renders a generic
18009
19804
  * button that navigates to `startUrl` (an addon-owned HTTP route).
18010
- * Covers OIDC (`/addon/auth-oidc/<id>/start`) and magic-link with
18011
- * ZERO shell-side JS. A future SSO addon plugs in the same way — the
19805
+ * Covers OIDC (`/addon/auth-oidc/<id>/start`) with ZERO shell-side JS. A future SSO addon plugs in the same way — the
18012
19806
  * login page needs NO change.
18013
19807
  *
18014
19808
  * - `widget` — a Module-Federation widget the login page mounts (via
@@ -18027,8 +19821,8 @@ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
18027
19821
  * decision.
18028
19822
  *
18029
19823
  * Every contribution carries a `stage`:
18030
- * - `primary` — shown on the first credentials screen (OIDC /
18031
- * magic-link buttons; a future usernameless passkey).
19824
+ * - `primary` — shown on the first credentials screen (OIDC
19825
+ * buttons; a usernameless passkey).
18032
19826
  * - `second-factor` — shown AFTER the password leg, gated on the
18033
19827
  * returned `factors` (passkey-as-2FA today).
18034
19828
  *
@@ -18055,7 +19849,7 @@ var LoginMethodContributionSchema = discriminatedUnion("kind", [
18055
19849
  * The provider names an external identity a signed-in user can link to
18056
19850
  * their own account (D782): `auth.listLinkableProviders` /
18057
19851
  * `beginExternalLink` offer exactly the redirect methods that set this,
18058
- * whatever their id. Absent / false — a login button only (magic-link).
19852
+ * whatever their id. Absent / false — a login button only.
18059
19853
  */
18060
19854
  linkable: boolean().optional()
18061
19855
  }),
@@ -21910,8 +23704,7 @@ method(object({}), object({ rules: array(NcRuleSchema) }), { auth: "admin" }), m
21910
23704
  * `super_admin` — collapsed onto the single boolean because every
21911
23705
  * non-admin caller is governed by the same scope-check rules; the
21912
23706
  * distinction was only ever used to route role-specific procedures
21913
- * which we no longer have. Agents are admin sessions issued via
21914
- * `createServiceToken`; CLI / webhook integrations are `cst_*` tokens
23707
+ * which we no longer have. CLI / webhook integrations are `cst_*` tokens
21915
23708
  * with `isAdmin: false` + an explicit scope list.
21916
23709
  */
21917
23710
  /** Per-method access flavour. Materialised on every cap method via codegen. */
@@ -23413,8 +25206,23 @@ var RetrainMacroClassSchema = _enum([
23413
25206
  ]);
23414
25207
  /** A subject to learn, or a phantom to unlearn (taught by OMISSION). */
23415
25208
  var RetrainAnnotationKindSchema = _enum(["subject", "model_error"]);
23416
- /** Did a human draw this box, or did the assist propose it? */
23417
- var RetrainAnnotationSourceSchema = _enum(["operator", "assist"]);
25209
+ /**
25210
+ * Where a box came from. A machine-sourced box is a DRAFT on the page until
25211
+ * the operator confirms it; once saved it keeps its source as provenance.
25212
+ *
25213
+ * - `operator` — drawn by hand.
25214
+ * - `assist` — proposed by a detector run on the copy (the camera's own
25215
+ * model, or a larger teacher model).
25216
+ * - `pipeline` — the box the live pipeline actually drew on that frame, read
25217
+ * back from the track store (never a re-run).
25218
+ * - `llm` — proposed by a vision-capable LLM profile.
25219
+ */
25220
+ var RetrainAnnotationSourceSchema = _enum([
25221
+ "operator",
25222
+ "assist",
25223
+ "pipeline",
25224
+ "llm"
25225
+ ]);
23418
25226
  /** Normalised `[0,1]` rectangle against the FULL frame — the canonical form. */
23419
25227
  var RetrainBboxSchema = object({
23420
25228
  x: number(),
@@ -23432,7 +25240,8 @@ var RetrainBboxSchema = object({
23432
25240
  */
23433
25241
  var RetrainAnnotationSchema = object({
23434
25242
  id: string(),
23435
- trackId: string(),
25243
+ /** The frame's track. Absent on a recording still, which has none. */
25244
+ trackId: string().optional(),
23436
25245
  deviceId: number(),
23437
25246
  /** The COPY in retrain storage — never the source track's media key. */
23438
25247
  mediaKey: string(),
@@ -23481,13 +25290,47 @@ var RetrainFrameCandidateSchema = object({
23481
25290
  * fail, whatever became of the original. */
23482
25291
  copied: boolean()
23483
25292
  });
25293
+ /**
25294
+ * One box the live pipeline drew on a copied frame — what a correction starts
25295
+ * from. Derived when the frame is listed, from the track store: the subject
25296
+ * box recorded on the source media row when there is one, else the track
25297
+ * position nearest the frame's capture time. Never stored as an annotation
25298
+ * until the operator confirms it.
25299
+ */
25300
+ var RetrainPipelineBoxSchema = object({
25301
+ /** Normalised `[0,1]` against the full frame. */
25302
+ bbox: RetrainBboxSchema,
25303
+ macroClass: RetrainMacroClassSchema,
25304
+ label: string().optional(),
25305
+ subLabel: string().optional(),
25306
+ /** The detection score of the position used, when it was recorded. */
25307
+ score: number().optional(),
25308
+ /** The root model that produced the track, when it was recorded. */
25309
+ modelId: string().optional(),
25310
+ trackId: string(),
25311
+ /** `subject-box`: recorded on this very frame. `position`: the track's
25312
+ * position nearest the capture time, `deltaMs` away. */
25313
+ basis: _enum(["subject-box", "position"]),
25314
+ deltaMs: number()
25315
+ });
25316
+ /**
25317
+ * Where a retrain frame came from: a TRACK's stored media (copy-on-select),
25318
+ * or the RECORDING at an instant — the frame a model saw nothing in has no
25319
+ * track at all.
25320
+ */
25321
+ var RetrainFrameOriginSchema = _enum(["track", "recording"]);
23484
25322
  /** A frame the dataset OWNS: bytes copied at selection time. */
23485
25323
  var RetrainFrameSchema = object({
23486
25324
  frameId: string(),
23487
25325
  deviceId: number(),
23488
- trackId: string(),
23489
- /** Provenance only. It may already point at nothing — that is expected. */
23490
- sourceMediaId: number().int(),
25326
+ origin: RetrainFrameOriginSchema,
25327
+ /** The track it was copied from. Absent on a recording still. */
25328
+ trackId: string().optional(),
25329
+ /** Provenance only. It may already point at nothing — that is expected.
25330
+ * Absent on a recording still. */
25331
+ sourceMediaId: number().int().optional(),
25332
+ /** A recording still: the playhead instant it was taken at. */
25333
+ epochMs: number().optional(),
23491
25334
  sourceKind: MediaFileKindEnum,
23492
25335
  sizeBytes: number().int(),
23493
25336
  width: number().int(),
@@ -23498,7 +25341,12 @@ var RetrainFrameSchema = object({
23498
25341
  /** The operator's "every subject in this frame is boxed". Detector
23499
25342
  * evaluation keeps only complete frames: an unboxed subject would count as
23500
25343
  * a false positive. */
23501
- complete: boolean()
25344
+ complete: boolean(),
25345
+ /** The boxes the pipeline drew on this frame. Present on list answers;
25346
+ * empty when nothing the track store holds can be placed on it. */
25347
+ pipelineBoxes: array(RetrainPipelineBoxSchema).readonly().optional(),
25348
+ /** The named collections this frame belongs to. Present on list answers. */
25349
+ collectionIds: array(string()).readonly().optional()
23502
25350
  });
23503
25351
  /** Why a copy-on-select could not be honoured — named, never a silent skip. */
23504
25352
  var RetrainCopyRefusalSchema = _enum([
@@ -23529,6 +25377,11 @@ var RetrainFrameListSchema = object({
23529
25377
  var RetrainExportFilterSchema = object({
23530
25378
  deviceIds: array(number()).optional(),
23531
25379
  frameIds: array(string()).max(2e4).optional(),
25380
+ /** Only frames in at least one of these named collections. */
25381
+ collectionIds: array(string()).max(200).optional(),
25382
+ /** Exactly the frames of this dataset version (and its completeOnly). An
25383
+ * unknown id selects nothing. */
25384
+ datasetVersionId: string().optional(),
23532
25385
  batchId: string().optional(),
23533
25386
  /** Only frames the operator marked complete (all subjects boxed). */
23534
25387
  completeOnly: boolean().optional()
@@ -23593,6 +25446,170 @@ var RetrainAssistResultSchema = discriminatedUnion("kind", [object({
23593
25446
  reason: string(),
23594
25447
  detail: string().optional()
23595
25448
  })]);
25449
+ /** A named set over the retrain corpus — membership only, it owns no pixels. */
25450
+ var RetrainCollectionSchema = object({
25451
+ id: string(),
25452
+ name: string(),
25453
+ createdAt: number(),
25454
+ frameCount: number().int()
25455
+ });
25456
+ var RetrainCollectionCreateResultSchema = discriminatedUnion("kind", [object({
25457
+ kind: literal("created"),
25458
+ collection: RetrainCollectionSchema
25459
+ }), object({
25460
+ kind: literal("refused"),
25461
+ reason: _enum(["empty-name", "duplicate-name"])
25462
+ })]);
25463
+ var RetrainCollectionRenameResultSchema = discriminatedUnion("kind", [object({
25464
+ kind: literal("renamed"),
25465
+ collection: RetrainCollectionSchema
25466
+ }), object({
25467
+ kind: literal("refused"),
25468
+ reason: _enum([
25469
+ "empty-name",
25470
+ "duplicate-name",
25471
+ "unknown-collection"
25472
+ ])
25473
+ })]);
25474
+ /**
25475
+ * The outcome of adding the frame at a recording instant. Every refusal is
25476
+ * named: `still-unavailable` (not recording, a gap, or an undecodable frame —
25477
+ * `detail` says which), `still-busy` (the recorder is at its decode bound; try
25478
+ * again), `unreadable-image`, `write-failed`, `unknown-collection`.
25479
+ */
25480
+ var AddRetrainFrameFromRecordingResultSchema = discriminatedUnion("kind", [object({
25481
+ kind: literal("added"),
25482
+ collectionId: string(),
25483
+ frame: RetrainFrameSchema,
25484
+ /** The moment was already in the dataset; nothing was decoded. */
25485
+ reused: boolean()
25486
+ }), object({
25487
+ kind: literal("refused"),
25488
+ reason: _enum([
25489
+ "unknown-collection",
25490
+ "still-unavailable",
25491
+ "still-busy",
25492
+ "unreadable-image",
25493
+ "write-failed"
25494
+ ]),
25495
+ detail: string().optional()
25496
+ })]);
25497
+ /** A vision LLM profile the AI assist may use, and where it sends the frame. */
25498
+ var RetrainAssistProfileSchema = object({
25499
+ id: string(),
25500
+ name: string(),
25501
+ model: string(),
25502
+ kind: string(),
25503
+ /** `true` when the frame would leave the house (a cloud vendor, or an
25504
+ * endpoint that is not on the local network). The page confirms each such
25505
+ * run, and the provider refuses one without `allowCloud`. */
25506
+ leavesHouse: boolean()
25507
+ });
25508
+ /** A box the AI assist proposed: a draft, plus the model's own reason. */
25509
+ var RetrainLlmProposalSchema = RetrainAnnotationDraftSchema.extend({ reason: string() });
25510
+ /** What the AI assist said about a box that was already on the canvas. */
25511
+ var RetrainLlmReviewSchema = object({
25512
+ /** The `ref` the page sent the box under. */
25513
+ ref: string(),
25514
+ verdict: _enum([
25515
+ "confirmed",
25516
+ "wrong-class",
25517
+ "not-an-object",
25518
+ "uncertain"
25519
+ ]),
25520
+ suggestedClass: RetrainMacroClassSchema.optional(),
25521
+ reason: string()
25522
+ });
25523
+ /**
25524
+ * The AI assist's answer. `proposed` carries drafts (`source: 'llm'`, the
25525
+ * model and its confidence) and reviews; items the model got wrong (a box off
25526
+ * the frame, an unasked class, an unknown ref) are dropped and counted in
25527
+ * `rejected`. A whole answer that is not the schema is `malformed-answer`.
25528
+ */
25529
+ var RetrainLlmAssistResultSchema = discriminatedUnion("kind", [object({
25530
+ kind: literal("proposed"),
25531
+ profileId: string(),
25532
+ model: string(),
25533
+ /** The frame was sent outside the house for this answer. */
25534
+ leftHouse: boolean(),
25535
+ proposals: array(RetrainLlmProposalSchema).readonly(),
25536
+ reviews: array(RetrainLlmReviewSchema).readonly(),
25537
+ rejected: number().int()
25538
+ }), object({
25539
+ kind: literal("refused"),
25540
+ reason: _enum([
25541
+ "unknown-frame",
25542
+ "unreadable-frame",
25543
+ "unknown-profile",
25544
+ "profile-disabled",
25545
+ "no-vision",
25546
+ "cloud-not-confirmed",
25547
+ "llm-error",
25548
+ "malformed-answer"
25549
+ ]),
25550
+ detail: string().optional()
25551
+ })]);
25552
+ /** What a dataset version is cut from. Every field narrows. */
25553
+ var RetrainDatasetSelectionSchema = object({
25554
+ deviceIds: array(number()).readonly().optional(),
25555
+ collectionIds: array(string()).max(200).readonly().optional(),
25556
+ frameIds: array(string()).max(2e4).readonly().optional()
25557
+ });
25558
+ /** The counts a dataset is judged by. */
25559
+ var RetrainDatasetStatsSchema = object({
25560
+ frames: number().int(),
25561
+ completeFrames: number().int(),
25562
+ /** `completeFrames / frames`, 0..1. */
25563
+ completeness: number(),
25564
+ /** Boxes to learn (model errors excluded). */
25565
+ subjects: number().int(),
25566
+ modelErrors: number().int(),
25567
+ /** Complete frames with no subject. */
25568
+ hardNegatives: number().int(),
25569
+ /** Subjects per class × camera × day/night. */
25570
+ cells: array(object({
25571
+ macroClass: string(),
25572
+ deviceId: number(),
25573
+ lighting: _enum([
25574
+ "day",
25575
+ "night",
25576
+ "unknown"
25577
+ ]),
25578
+ subjects: number().int(),
25579
+ frames: number().int()
25580
+ })).readonly(),
25581
+ cameras: array(object({
25582
+ deviceId: number(),
25583
+ frames: number().int(),
25584
+ completeFrames: number().int()
25585
+ })).readonly()
25586
+ });
25587
+ /** An immutable dataset version, without its frame list. */
25588
+ var RetrainDatasetVersionSchema = object({
25589
+ id: string(),
25590
+ name: string(),
25591
+ createdAt: number(),
25592
+ selection: RetrainDatasetSelectionSchema,
25593
+ layout: RetrainExportLayoutSchema,
25594
+ completeOnly: boolean(),
25595
+ frameCount: number().int(),
25596
+ /** sha256 of what the frames taught when the version was frozen. */
25597
+ annotationHash: string(),
25598
+ /** The export manifest schema the version was cut under. */
25599
+ manifestSchema: string(),
25600
+ stats: RetrainDatasetStatsSchema
25601
+ });
25602
+ var CreateRetrainDatasetVersionResultSchema = discriminatedUnion("kind", [object({
25603
+ kind: literal("created"),
25604
+ version: RetrainDatasetVersionSchema
25605
+ }), object({
25606
+ kind: literal("refused"),
25607
+ reason: _enum([
25608
+ "empty-name",
25609
+ "duplicate-name",
25610
+ "no-frames"
25611
+ ])
25612
+ })]);
23596
25613
  /** The outcome of a lifecycle move owned by the retrain page. */
23597
25614
  var RetrainTransitionResultSchema = object({
23598
25615
  trackId: string(),
@@ -24310,7 +26327,7 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
24310
26327
  auth: "admin"
24311
26328
  }), method(object({
24312
26329
  deviceId: number(),
24313
- trackId: string(),
26330
+ trackId: string().optional(),
24314
26331
  frameId: string()
24315
26332
  }), object({
24316
26333
  removed: boolean(),
@@ -24327,7 +26344,8 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
24327
26344
  auth: "admin"
24328
26345
  }), method(object({
24329
26346
  deviceId: number(),
24330
- trackId: string(),
26347
+ /** The frame's track, when it has one — checked against the frame. */
26348
+ trackId: string().optional(),
24331
26349
  frameId: string(),
24332
26350
  subject: RetrainAssistSubjectSchema,
24333
26351
  /** Which node runs it. Absent ⇒ wherever an unowned call lands. */
@@ -24335,12 +26353,16 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
24335
26353
  }), RetrainAssistResultSchema, {
24336
26354
  kind: "mutation",
24337
26355
  auth: "admin"
24338
- }), method(object({ trackId: string() }), array(RetrainAnnotationSchema).readonly(), {
26356
+ }), method(object({
26357
+ trackId: string().optional(),
26358
+ frameIds: array(string()).max(2e3).optional()
26359
+ }), array(RetrainAnnotationSchema).readonly(), {
24339
26360
  kind: "query",
24340
26361
  auth: "admin"
24341
26362
  }), method(object({
24342
26363
  deviceId: number(),
24343
- trackId: string(),
26364
+ /** The frame's track, when it has one — checked against the frame. */
26365
+ trackId: string().optional(),
24344
26366
  frameId: string(),
24345
26367
  annotations: array(RetrainAnnotationDraftSchema)
24346
26368
  }), array(RetrainAnnotationSchema).readonly(), {
@@ -24363,7 +26385,7 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
24363
26385
  auth: "admin"
24364
26386
  }), method(object({
24365
26387
  deviceId: number(),
24366
- trackId: string(),
26388
+ trackId: string().optional(),
24367
26389
  frameId: string(),
24368
26390
  complete: boolean()
24369
26391
  }), RetrainFrameSchema, {
@@ -24377,6 +26399,115 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
24377
26399
  kind: "mutation",
24378
26400
  auth: "admin",
24379
26401
  timeoutMs: 60 * 6e4
26402
+ }), method(object({
26403
+ filter: RetrainExportFilterSchema,
26404
+ layout: RetrainExportLayoutSchema
26405
+ }), object({
26406
+ ticket: PeerBytesTicketSchema,
26407
+ frames: number().int(),
26408
+ annotations: number().int()
26409
+ }), {
26410
+ kind: "mutation",
26411
+ auth: "admin",
26412
+ timeoutMs: 12e4
26413
+ }), method(object({
26414
+ selection: RetrainDatasetSelectionSchema,
26415
+ completeOnly: boolean().optional()
26416
+ }), RetrainDatasetStatsSchema, {
26417
+ kind: "query",
26418
+ auth: "admin"
26419
+ }), method(object({
26420
+ name: string().max(120),
26421
+ selection: RetrainDatasetSelectionSchema,
26422
+ layout: RetrainExportLayoutSchema,
26423
+ completeOnly: boolean()
26424
+ }), CreateRetrainDatasetVersionResultSchema, {
26425
+ kind: "mutation",
26426
+ auth: "admin",
26427
+ timeoutMs: 12e4
26428
+ }), method(object({}), array(RetrainDatasetVersionSchema).readonly(), {
26429
+ kind: "query",
26430
+ auth: "admin"
26431
+ }), method(object({ id: string() }), object({ deleted: boolean() }), {
26432
+ kind: "mutation",
26433
+ auth: "admin"
26434
+ }), method(object({ id: string() }), object({
26435
+ found: boolean(),
26436
+ annotationHash: string(),
26437
+ matches: boolean(),
26438
+ missingFrames: number().int()
26439
+ }), {
26440
+ kind: "query",
26441
+ auth: "admin",
26442
+ timeoutMs: 12e4
26443
+ }), method(object({}), array(RetrainAssistProfileSchema).readonly(), {
26444
+ kind: "query",
26445
+ auth: "admin"
26446
+ }), method(object({
26447
+ deviceId: number(),
26448
+ trackId: string().optional(),
26449
+ frameId: string(),
26450
+ profileId: string(),
26451
+ classes: array(RetrainMacroClassSchema).min(1),
26452
+ boxes: array(object({
26453
+ ref: string(),
26454
+ bbox: RetrainBboxSchema,
26455
+ macroClass: RetrainMacroClassSchema,
26456
+ label: string().optional()
26457
+ })).max(50),
26458
+ allowCloud: boolean()
26459
+ }), RetrainLlmAssistResultSchema, {
26460
+ kind: "mutation",
26461
+ auth: "admin",
26462
+ timeoutMs: 18e4
26463
+ }), method(object({ name: string().max(120) }), RetrainCollectionCreateResultSchema, {
26464
+ kind: "mutation",
26465
+ auth: "admin"
26466
+ }), method(object({}), array(RetrainCollectionSchema).readonly(), {
26467
+ kind: "query",
26468
+ auth: "admin"
26469
+ }), method(object({
26470
+ id: string(),
26471
+ name: string().max(120)
26472
+ }), RetrainCollectionRenameResultSchema, {
26473
+ kind: "mutation",
26474
+ auth: "admin"
26475
+ }), method(object({ id: string() }), object({
26476
+ deleted: boolean(),
26477
+ removedFrames: number().int()
26478
+ }), {
26479
+ kind: "mutation",
26480
+ auth: "admin"
26481
+ }), method(object({
26482
+ collectionId: string(),
26483
+ deviceId: number(),
26484
+ epochMs: number()
26485
+ }), AddRetrainFrameFromRecordingResultSchema, {
26486
+ kind: "mutation",
26487
+ auth: "admin",
26488
+ timeoutMs: 6e4
26489
+ }), method(object({
26490
+ collectionId: string(),
26491
+ frameIds: array(string()).min(1).max(500)
26492
+ }), object({
26493
+ added: number().int(),
26494
+ alreadyMember: number().int(),
26495
+ unknownFrameIds: array(string()).readonly()
26496
+ }), {
26497
+ kind: "mutation",
26498
+ auth: "admin"
26499
+ }), method(object({
26500
+ collectionId: string(),
26501
+ frameId: string()
26502
+ }), object({
26503
+ removed: boolean(),
26504
+ deletedFrame: boolean()
26505
+ }), {
26506
+ kind: "mutation",
26507
+ auth: "admin"
26508
+ }), method(object({ collectionId: string() }), array(RetrainFrameSchema).readonly(), {
26509
+ kind: "query",
26510
+ auth: "admin"
24380
26511
  }), method(object({
24381
26512
  /** Which of the three event tables owns the row. */
24382
26513
  ownerType: EventOwnerTypeSchema,
@@ -25000,13 +27131,31 @@ var RecommendationReasonSchema = discriminatedUnion("kind", [
25000
27131
  object({
25001
27132
  kind: literal("no-family-build"),
25002
27133
  format: ModelFormatSchema$1
27134
+ }),
27135
+ object({
27136
+ kind: literal("kept-custom-pin"),
27137
+ modelId: string(),
27138
+ deviceKey: string()
25003
27139
  })
25004
27140
  ]);
27141
+ /** Why a device is left exactly as it is, whatever the plan would pick (D786). */
27142
+ var KeptReasonSchema = _enum(["custom-pin"]);
27143
+ /**
27144
+ * Where a choice's latency came from (D791): this node's own benchmark
27145
+ * result, or the hardware-class table. Measured on the node beats the table.
27146
+ */
27147
+ var LatencySourceSchema = discriminatedUnion("kind", [object({ kind: literal("table") }), object({
27148
+ kind: literal("node-benchmark"),
27149
+ resultId: string(),
27150
+ measuredAtMs: number()
27151
+ })]);
25005
27152
  var DeviceModelChoiceSchema = object({
25006
27153
  modelId: string(),
25007
27154
  p50Ms: number(),
25008
27155
  fps: number(),
25009
27156
  measured: boolean(),
27157
+ /** Absent on a plan from before D791 — read as the table. */
27158
+ source: LatencySourceSchema.optional(),
25010
27159
  /** Parallel sessions at the camera rate with the headroom kept free: ⌊fps × (1 − headroom) / camera fps⌋. */
25011
27160
  capacitySessions: number(),
25012
27161
  personRecall: number()
@@ -25017,6 +27166,8 @@ var DeviceRecommendationSchema = object({
25017
27166
  enabled: boolean(),
25018
27167
  available: boolean(),
25019
27168
  chosen: DeviceModelChoiceSchema.nullable(),
27169
+ /** Present when the device is kept as is: Apply writes nothing on it. */
27170
+ kept: KeptReasonSchema.optional(),
25020
27171
  reasons: array(RecommendationReasonSchema).readonly()
25021
27172
  });
25022
27173
  var NodeRecommendationSchema = object({
@@ -25070,6 +27221,17 @@ var AutoTuneWarningSchema = discriminatedUnion("kind", [
25070
27221
  kind: literal("coral-enabled"),
25071
27222
  nodeId: string(),
25072
27223
  deviceKey: string()
27224
+ }),
27225
+ object({
27226
+ kind: literal("custom-pin-kept"),
27227
+ nodeId: string(),
27228
+ deviceKey: string().nullable(),
27229
+ deviceId: number().nullable(),
27230
+ modelId: string()
27231
+ }),
27232
+ object({
27233
+ kind: literal("custom-registry-unreadable"),
27234
+ error: string()
25073
27235
  })
25074
27236
  ]);
25075
27237
  var AutoTuneOptionsSchema = object({
@@ -25248,13 +27410,14 @@ var SuggestSharesResultSchema = object({
25248
27410
  nodes: array(SuggestedNodeShareSchema).readonly()
25249
27411
  });
25250
27412
  /**
25251
- * Where the node and device shares come from (D750, D755).
25252
- * - `hardware` (default) — computed by the system from each node's static
25253
- * capacity (its accelerators at their Auto tune models, from the measured
25254
- * latency table), recomputed whenever a node or device joins, leaves, is
25255
- * switched on or off, or changes model. No load input.
25256
- * - `benchmark` — the same, from each node's measured capacity (node
25257
- * benchmark results); a node without results falls back to `hardware`.
27413
+ * Where the node and device shares come from (D750, D755, D791).
27414
+ * - `benchmark` (default since D791) — each node's capacity as its own node
27415
+ * benchmark measured it; a node without fresh results is sized from
27416
+ * `hardware` and says so. Measured on the node beats the table.
27417
+ * - `hardware` — computed from each node's static capacity only (its
27418
+ * accelerators at their Auto tune models, from the latency table).
27419
+ * Both are recomputed whenever a node or device joins, leaves, is switched
27420
+ * on or off, changes model, or a benchmark result is written. No load input.
25258
27421
  * - `manual` — the operator's stored sliders.
25259
27422
  * Either way a node or device that cannot take sessions gives its share to
25260
27423
  * the others in proportion; the stored values are never rewritten for that.
@@ -25303,6 +27466,362 @@ var EffectiveSharesSchema = object({
25303
27466
  nodeWeights: record(string(), number()),
25304
27467
  deviceWeights: record(string(), record(string(), number()))
25305
27468
  });
27469
+ /**
27470
+ * Wire shapes of the node benchmark (D791): the operator's plan, the
27471
+ * preflight the confirmation shows, the run the orchestrator owns, what the
27472
+ * measuring runner reports, and the result rows Auto tune and the automatic
27473
+ * shares read.
27474
+ *
27475
+ * ONE node at a time, owned by the pipeline orchestrator. While a run is
27476
+ * active the cluster is in BENCHMARK MODE for that node: it is not a
27477
+ * detection candidate, camera pins naming it are ignored so its sessions move
27478
+ * elsewhere, and both come back when the mode ends — after a crash or a hub
27479
+ * restart too (a persisted manifest, reconciled against the registry).
27480
+ *
27481
+ * Two measurements, both on the node, driven by its own runner (frames never
27482
+ * cross a process at frame rate, D9):
27483
+ * - `device` — one accelerator × one candidate detector, root only, open
27484
+ * loop: how many streams at the camera rate it carries inside the frame
27485
+ * interval;
27486
+ * - `pipeline` — the chosen detector plus the operator's detail steps
27487
+ * (faces, plates, classifiers, CLIP…), on varied frames from the bench
27488
+ * clip: how many parallel sessions the node carries before latency, drops,
27489
+ * CPU, RAM or the event loop give out.
27490
+ */
27491
+ /** Defaults and bounds, one place. */
27492
+ var NODE_BENCHMARK_DEFAULTS = {
27493
+ fpsPerStream: 10,
27494
+ budgetMinutes: 45,
27495
+ minBudgetMinutes: 10,
27496
+ maxBudgetMinutes: 120,
27497
+ /** A result older than this no longer beats the table. */
27498
+ staleAfterDays: 30,
27499
+ /** Warm-in per ramp step (not accounted). */
27500
+ settleSec: 5,
27501
+ /** Accounted window per ramp step. */
27502
+ measureSec: 20,
27503
+ /** Longest the drain may take before the run is refused. */
27504
+ drainTimeoutSec: 120,
27505
+ /** Candidate models per device in one run. */
27506
+ maxModelsPerDevice: 6
27507
+ };
27508
+ /** The two measurements a run can make. */
27509
+ var NodeBenchmarkPhaseSchema = _enum(["device", "pipeline"]);
27510
+ var NodeBenchmarkDevicePlanSchema = object({
27511
+ /** `<backend>:<device>` — `openvino:npu`, `coreml:all`, `cpu`. */
27512
+ deviceKey: string().min(1),
27513
+ /**
27514
+ * Root detector candidates for the `device` measurement, in the order
27515
+ * measured. The FIRST is the one the `pipeline` measurement runs.
27516
+ */
27517
+ modelIds: array(string().min(1)).min(1).max(NODE_BENCHMARK_DEFAULTS.maxModelsPerDevice)
27518
+ });
27519
+ /** What the operator confirmed. */
27520
+ var NodeBenchmarkPlanSchema = object({
27521
+ nodeId: string().min(1),
27522
+ devices: array(NodeBenchmarkDevicePlanSchema).min(1),
27523
+ /** Which measurements run. At least one. */
27524
+ phases: array(NodeBenchmarkPhaseSchema).min(1).default(["device", "pipeline"]),
27525
+ /**
27526
+ * Detail steps (catalog step ids under the root: faces, plates,
27527
+ * classifiers, CLIP…) the `pipeline` measurement enables. The root
27528
+ * detector always runs.
27529
+ */
27530
+ steps: array(string().min(1)).default([]),
27531
+ /** Offered rate of one stream / session. */
27532
+ fpsPerStream: number().int().min(1).max(30).default(NODE_BENCHMARK_DEFAULTS.fpsPerStream),
27533
+ /** Hard deadline: the mode ends and the cluster is restored when it passes. */
27534
+ budgetMinutes: number().int().min(NODE_BENCHMARK_DEFAULTS.minBudgetMinutes).max(NODE_BENCHMARK_DEFAULTS.maxBudgetMinutes).default(NODE_BENCHMARK_DEFAULTS.budgetMinutes),
27535
+ /** Keep the models the run downloaded (default: delete what was not installed before). */
27536
+ keepDownloadedModels: boolean().default(false),
27537
+ /** Start although the other nodes' capacity does not cover the sessions running now. */
27538
+ acceptInsufficientHeadroom: boolean().default(false)
27539
+ });
27540
+ var NodeBenchmarkRefusalSchema = object({
27541
+ kind: _enum([
27542
+ "benchmark-active",
27543
+ "node-offline",
27544
+ "unknown-device",
27545
+ "no-phase",
27546
+ "insufficient-headroom"
27547
+ ]),
27548
+ detail: string(),
27549
+ overridable: boolean()
27550
+ });
27551
+ /** A camera whose detection leaves the node for the run. */
27552
+ var NodeBenchmarkMovingCameraSchema = object({
27553
+ deviceId: number(),
27554
+ /** Placed on the node now (a standing attach or a running session). */
27555
+ placedOnNode: boolean(),
27556
+ /** A node pin naming this node, ignored for the run. */
27557
+ pinnedToNode: boolean()
27558
+ });
27559
+ /** A camera that cannot leave: no other node can obtain its frames. */
27560
+ var NodeBenchmarkStayingCameraSchema = object({
27561
+ deviceId: number(),
27562
+ reason: literal("only-frame-source")
27563
+ });
27564
+ var NodeBenchmarkPreflightSchema = object({
27565
+ nodeId: string(),
27566
+ online: boolean(),
27567
+ moving: array(NodeBenchmarkMovingCameraSchema).readonly(),
27568
+ /** Keep running on the node during the run; the result is flagged contaminated. */
27569
+ staying: array(NodeBenchmarkStayingCameraSchema).readonly(),
27570
+ estimatedDurationMs: number(),
27571
+ /** The run ends and the cluster is restored at the latest after this long. */
27572
+ budgetMs: number(),
27573
+ phases: array(NodeBenchmarkPhaseSchema).readonly(),
27574
+ steps: array(string()).readonly(),
27575
+ devices: array(NodeBenchmarkDevicePlanSchema).readonly(),
27576
+ /** Parallel sessions the cluster runs now, and what the other nodes can carry. */
27577
+ headroom: object({
27578
+ sessionsNow: number(),
27579
+ otherNodesCapacitySessions: number().nullable()
27580
+ }),
27581
+ refusals: array(NodeBenchmarkRefusalSchema).readonly(),
27582
+ canStart: boolean()
27583
+ });
27584
+ /** Where the measuring runner is. */
27585
+ var NodeBenchProgressSchema = object({
27586
+ phase: _enum([
27587
+ "preparing",
27588
+ "device",
27589
+ "pipeline",
27590
+ "cleanup"
27591
+ ]),
27592
+ deviceKey: string().nullable(),
27593
+ modelId: string().nullable(),
27594
+ /** Streams (device) or sessions (pipeline) of the step running now. */
27595
+ load: number().nullable(),
27596
+ cellsDone: number(),
27597
+ cellsTotal: number(),
27598
+ message: string()
27599
+ });
27600
+ /** What limited a ramp. `none` = the ramp ran out of steps still passing. */
27601
+ var NodeBenchLimitSchema = _enum([
27602
+ "p95",
27603
+ "drops",
27604
+ "errors",
27605
+ "stall",
27606
+ "cpu",
27607
+ "ram",
27608
+ "none"
27609
+ ]);
27610
+ var NodeBenchRampStepSchema = object({
27611
+ load: number(),
27612
+ pass: boolean(),
27613
+ p95Ms: number(),
27614
+ dropRatio: number(),
27615
+ /** Completed frames per second over the accounted window. */
27616
+ fps: number(),
27617
+ cpuPct: number().nullable(),
27618
+ ramFreePct: number().nullable(),
27619
+ failReasons: array(string()).readonly()
27620
+ });
27621
+ var NodeBenchCellSchema = discriminatedUnion("phase", [object({
27622
+ phase: literal("device"),
27623
+ deviceKey: string(),
27624
+ modelId: string(),
27625
+ /** Single-stream latency (the K = 1 step). */
27626
+ p50Ms: number(),
27627
+ p95Ms: number(),
27628
+ p99Ms: number(),
27629
+ /** Frames per second sustained at the last passing step. */
27630
+ fps: number(),
27631
+ /** Streams at the camera rate the device carried inside the frame interval; 0 = not even one. */
27632
+ kMax: number(),
27633
+ limitedBy: NodeBenchLimitSchema,
27634
+ /** First call (model load + warm-up). */
27635
+ warmupMs: number(),
27636
+ ramp: array(NodeBenchRampStepSchema).readonly()
27637
+ }), object({
27638
+ phase: literal("pipeline"),
27639
+ deviceKey: string(),
27640
+ modelId: string(),
27641
+ steps: array(string()).readonly(),
27642
+ /** Parallel sessions at the camera rate the node carried; 0 = not even one. */
27643
+ maxSessions: number(),
27644
+ limitedBy: NodeBenchLimitSchema,
27645
+ /** Detail steps that produced at least one result on the clip — a step that never fired measured nothing. */
27646
+ stepsFired: array(string()).readonly(),
27647
+ warmupMs: number(),
27648
+ ramp: array(NodeBenchRampStepSchema).readonly()
27649
+ })]);
27650
+ /**
27651
+ * What a result was measured ON. A result whose fingerprint no longer matches
27652
+ * the node no longer beats the table.
27653
+ */
27654
+ var NodeBenchFingerprintSchema = object({
27655
+ pipelineVersion: string().nullable(),
27656
+ cpuModel: string().nullable(),
27657
+ ramGb: number().nullable(),
27658
+ os: string().nullable(),
27659
+ /** Per device: the pool the cells ran on (runtime + tuning). */
27660
+ pools: record(string(), object({
27661
+ runtime: string(),
27662
+ numWorkers: number(),
27663
+ concurrency: number(),
27664
+ batchMode: string()
27665
+ })).default({})
27666
+ });
27667
+ /** The frames the run used. */
27668
+ var NodeBenchClipSchema = object({
27669
+ /** `camstack-bench-v1` or `reference-images` (the fallback when the clip is not reachable). */
27670
+ id: string(),
27671
+ revision: string().nullable(),
27672
+ frames: number(),
27673
+ width: number(),
27674
+ height: number()
27675
+ });
27676
+ var NodeBenchRunnerInputSchema = object({
27677
+ runId: string().min(1),
27678
+ devices: array(NodeBenchmarkDevicePlanSchema).min(1),
27679
+ phases: array(NodeBenchmarkPhaseSchema).min(1),
27680
+ /** The full detail step tree root for the `pipeline` measurement is built on the node from these ids. */
27681
+ steps: array(string()).default([]),
27682
+ fpsPerStream: number().int().min(1).max(30),
27683
+ /** The runner stops on its own past this instant, whatever the hub does. */
27684
+ deadlineAtMs: number(),
27685
+ settleSec: number().min(0).max(60).default(NODE_BENCHMARK_DEFAULTS.settleSec),
27686
+ measureSec: number().min(2).max(300).default(NODE_BENCHMARK_DEFAULTS.measureSec),
27687
+ keepDownloadedModels: boolean().default(false)
27688
+ });
27689
+ var NodeBenchRunnerStateSchema = _enum([
27690
+ "running",
27691
+ "done",
27692
+ "failed",
27693
+ "aborted"
27694
+ ]);
27695
+ var NodeBenchRunnerStatusSchema = object({
27696
+ runId: string(),
27697
+ nodeId: string(),
27698
+ state: NodeBenchRunnerStateSchema,
27699
+ progress: NodeBenchProgressSchema.nullable(),
27700
+ /** Every finished cell so far — a run stopped half way keeps what it measured. */
27701
+ cells: array(NodeBenchCellSchema).readonly(),
27702
+ fingerprint: NodeBenchFingerprintSchema.nullable(),
27703
+ clip: NodeBenchClipSchema.nullable(),
27704
+ /** Cameras seen running on the node during the run (they share its pools). */
27705
+ activeCameraIds: array(number()).readonly(),
27706
+ /** Models the run downloaded and then deleted (not installed before). */
27707
+ deletedModels: array(string()).readonly(),
27708
+ error: string().nullable(),
27709
+ startedAtMs: number(),
27710
+ finishedAtMs: number().nullable()
27711
+ });
27712
+ var NodeBenchmarkStateSchema = _enum([
27713
+ "draining",
27714
+ "measuring",
27715
+ "restoring",
27716
+ "done",
27717
+ "failed",
27718
+ "aborted"
27719
+ ]);
27720
+ /** Why a run ended. */
27721
+ var NodeBenchmarkEndReasonSchema = _enum([
27722
+ "completed",
27723
+ "operator-abort",
27724
+ "deadline",
27725
+ "node-lost",
27726
+ "runner-lost",
27727
+ "hub-restart",
27728
+ "drain-timeout",
27729
+ "failed"
27730
+ ]);
27731
+ var NodeBenchmarkRunSchema = object({
27732
+ runId: string(),
27733
+ nodeId: string(),
27734
+ state: NodeBenchmarkStateSchema,
27735
+ plan: NodeBenchmarkPlanSchema,
27736
+ startedAtMs: number(),
27737
+ deadlineAtMs: number(),
27738
+ finishedAtMs: number().nullable(),
27739
+ endReason: NodeBenchmarkEndReasonSchema.nullable(),
27740
+ error: string().nullable(),
27741
+ /** Cameras moved off the node for the run. */
27742
+ moved: array(number()).readonly(),
27743
+ /** Cameras that stayed (their only frame source is the node). */
27744
+ staying: array(number()).readonly(),
27745
+ /** Something else ran on the node's pools during the run. */
27746
+ contaminated: boolean(),
27747
+ progress: NodeBenchProgressSchema.nullable(),
27748
+ resultIds: array(string()).readonly()
27749
+ });
27750
+ /** `getNodeBenchmarkStatus`: the active run (or the last one), and whether benchmark mode is on. */
27751
+ var NodeBenchmarkStatusSchema = object({
27752
+ /** The node the cluster is in benchmark mode for; null = none. */
27753
+ modeNodeId: string().nullable(),
27754
+ run: NodeBenchmarkRunSchema.nullable()
27755
+ });
27756
+ /**
27757
+ * One stored measurement — the only authority Auto tune and the automatic
27758
+ * shares read measured capacity from. Written by the orchestrator when a run
27759
+ * ends, never by anyone else.
27760
+ */
27761
+ var NodeBenchmarkResultSchema = object({
27762
+ id: string(),
27763
+ runId: string(),
27764
+ nodeId: string(),
27765
+ cell: NodeBenchCellSchema,
27766
+ fpsPerStream: number(),
27767
+ fingerprint: NodeBenchFingerprintSchema.nullable(),
27768
+ clip: NodeBenchClipSchema.nullable(),
27769
+ /** Other work shared the node's pools (a camera that could not move, or the hub's own duties). */
27770
+ contaminated: boolean(),
27771
+ stayingCameras: array(number()).readonly(),
27772
+ /** The run ended early; the cell itself completed. */
27773
+ partialRun: boolean(),
27774
+ measuredAtMs: number()
27775
+ });
27776
+ var ListNodeBenchmarkResultsInputSchema = object({
27777
+ nodeId: string().optional(),
27778
+ deviceKey: string().optional()
27779
+ });
27780
+ /** A result with its standing today: does it still beat the table? */
27781
+ var NodeBenchmarkResultViewSchema = NodeBenchmarkResultSchema.extend({
27782
+ /** `fresh` beats the table; `stale` falls back to it; `superseded` = a newer row covers the same cell. */
27783
+ standing: _enum([
27784
+ "fresh",
27785
+ "stale",
27786
+ "superseded"
27787
+ ]),
27788
+ staleWhy: _enum([
27789
+ "age",
27790
+ "runtime",
27791
+ "pool-tuning"
27792
+ ]).nullable()
27793
+ });
27794
+ object({
27795
+ runId: string(),
27796
+ nodeId: string(),
27797
+ startedAtMs: number(),
27798
+ deadlineAtMs: number(),
27799
+ plan: NodeBenchmarkPlanSchema,
27800
+ moved: array(number()).readonly(),
27801
+ staying: array(number()).readonly()
27802
+ });
27803
+ /** Candidate detectors per device, for the plan editor. */
27804
+ var NodeBenchmarkCandidatesSchema = object({
27805
+ nodeId: string(),
27806
+ reachable: boolean(),
27807
+ devices: array(object({
27808
+ deviceKey: string(),
27809
+ enabled: boolean(),
27810
+ available: boolean(),
27811
+ /** Ordered: what Auto tune would pick first, then the rest of the family by accuracy. */
27812
+ suggested: array(string()).readonly(),
27813
+ /** Every root detector the device has a build for. */
27814
+ all: array(string()).readonly(),
27815
+ /** The model the device runs now, when pinned. */
27816
+ currentModelId: string().nullable()
27817
+ })).readonly(),
27818
+ /** Detail steps the node's catalog offers under the root (for the `pipeline` measurement). */
27819
+ steps: array(object({
27820
+ id: string(),
27821
+ name: string(),
27822
+ slot: string()
27823
+ })).readonly()
27824
+ });
25306
27825
  object({
25307
27826
  activeCameras: number(),
25308
27827
  throttledCameras: number(),
@@ -26431,7 +28950,16 @@ method(RunnerCameraConfigSchema, object({ success: literal(true) }), { kind: "mu
26431
28950
  }), ParkedTrackFrameSchema.nullable()), method(object({
26432
28951
  deviceId: number(),
26433
28952
  trackId: string()
26434
- }), object({ released: number().int().nonnegative() }), { kind: "mutation" });
28953
+ }), object({ released: number().int().nonnegative() }), { kind: "mutation" }), method(NodeBenchRunnerInputSchema, object({
28954
+ accepted: literal(true),
28955
+ runId: string()
28956
+ }), {
28957
+ kind: "mutation",
28958
+ auth: "admin"
28959
+ }), method(object({ runId: string() }), NodeBenchRunnerStatusSchema.nullable(), { auth: "admin" }), method(object({ runId: string() }), object({ aborted: boolean() }), {
28960
+ kind: "mutation",
28961
+ auth: "admin"
28962
+ });
26435
28963
  var CameraPipelineConfigSchema = object({
26436
28964
  engine: PipelineEngineChoiceSchema.optional(),
26437
28965
  steps: array(PipelineStepInputSchema).readonly(),
@@ -27070,6 +29598,21 @@ method(object({
27070
29598
  }), method(PlacementStatsInputSchema, PlacementStatsSchema, { auth: "admin" }), method(SuggestSharesInputSchema, SuggestSharesResultSchema, { auth: "admin" }), method(_void(), EffectiveSharesSchema, { auth: "admin" }), method(SetShareSourceInputSchema, object({ success: literal(true) }), {
27071
29599
  kind: "mutation",
27072
29600
  auth: "admin"
29601
+ }), method(NodeBenchmarkPlanSchema, NodeBenchmarkPreflightSchema, { auth: "admin" }), method(NodeBenchmarkPlanSchema, discriminatedUnion("kind", [object({
29602
+ kind: literal("started"),
29603
+ runId: string()
29604
+ }), object({
29605
+ kind: literal("refused"),
29606
+ preflight: NodeBenchmarkPreflightSchema
29607
+ })]), {
29608
+ kind: "mutation",
29609
+ auth: "admin"
29610
+ }), method(_void(), NodeBenchmarkStatusSchema, { auth: "admin" }), method(object({ runId: string() }), object({ aborted: boolean() }), {
29611
+ kind: "mutation",
29612
+ auth: "admin"
29613
+ }), method(object({ nodeId: string() }), NodeBenchmarkCandidatesSchema, { auth: "admin" }), method(ListNodeBenchmarkResultsInputSchema, array(NodeBenchmarkResultViewSchema).readonly(), { auth: "admin" }), method(object({ id: string() }), object({ deleted: boolean() }), {
29614
+ kind: "mutation",
29615
+ auth: "admin"
27073
29616
  }), method(object({ deviceId: number() }), CameraPipelineSettingsSchema.nullable()), method(object({
27074
29617
  deviceId: number(),
27075
29618
  addonId: string(),
@@ -27475,8 +30018,8 @@ version: string().optional() }), ServerUpdateActionResultSchema, {
27475
30018
  * `smtp-provider` — pluggable email delivery surface.
27476
30019
  *
27477
30020
  * Collection cap: a deployment may install multiple SMTP relays (e.g.
27478
- * one for transactional / one for notifications). Consumers (magic-link,
27479
- * notifier addons, …) walk the collection and pick the first
30021
+ * one for transactional / one for notifications). Consumers (notifier
30022
+ * addons, …) walk the collection and pick the first
27480
30023
  * ready provider OR target a specific addonId.
27481
30024
  *
27482
30025
  * The shape stays small on purpose — `sendEmail` is enough for the
@@ -27655,7 +30198,7 @@ targets: array(object({
27655
30198
  })));
27656
30199
  /**
27657
30200
  * `sso-bridge` — internal hub-only cap that lets SSO-style auth
27658
- * providers (OIDC, SAML, magic-link, …) mint an HMAC-signed token
30201
+ * providers (OIDC, SAML, …) mint an HMAC-signed token
27659
30202
  * carrying the post-callback claims before redirecting back to
27660
30203
  * `/api/auth/sso/finish`.
27661
30204
  *
@@ -27718,7 +30261,14 @@ var SsoBridgeClaimsSchema = object({
27718
30261
  * Verified `iss` of the id_token behind an OIDC login bridge (D782). A
27719
30262
  * subject is unique only per issuer, so a link is bound to it.
27720
30263
  */
27721
- issuer: string().optional()
30264
+ issuer: string().optional(),
30265
+ /**
30266
+ * SHA-256 (hex) of the `camstack_sso_state` cookie the IdP `/start` set in
30267
+ * the browser that began this sign-in. `/api/auth/sso/finish` requires the
30268
+ * request to present the matching cookie — a login bridge is useless in
30269
+ * any other browser.
30270
+ */
30271
+ browserBinding: string().optional()
27722
30272
  });
27723
30273
  method(object({
27724
30274
  claims: SsoBridgeClaimsSchema,
@@ -33177,6 +35727,9 @@ var CreateIntegrationInputSchema = object({
33177
35727
  enabled: boolean().optional(),
33178
35728
  info: record(string(), unknown()).optional(),
33179
35729
  settings: record(string(), unknown()).optional(),
35730
+ /** Keys of `settings` the form's schema declares secret (by type) — kept in
35731
+ * the keychain, not the table (D787). */
35732
+ secretKeys: array(string()).optional(),
33180
35733
  skipRestart: boolean().optional()
33181
35734
  });
33182
35735
  var UpdateIntegrationInputSchema = object({
@@ -33200,7 +35753,9 @@ method(_void(), array(IntegrationWithStateSchema)), method(object({ id: string()
33200
35753
  auth: "admin"
33201
35754
  }), method(object({ id: string() }), record(string(), unknown()), { auth: "admin" }), method(object({
33202
35755
  id: string(),
33203
- settings: record(string(), unknown())
35756
+ settings: record(string(), unknown()),
35757
+ /** Keys the form's schema declares secret (by type) — keychain-stored (D787). */
35758
+ secretKeys: array(string()).optional()
33204
35759
  }), object({ success: boolean() }), {
33205
35760
  kind: "mutation",
33206
35761
  auth: "admin"
@@ -39972,16 +42527,6 @@ var ApiKeySummarySchema = object({
39972
42527
  createdAt: number(),
39973
42528
  lastUsedAt: number().optional()
39974
42529
  });
39975
- var CreateApiKeyInputSchema = object({
39976
- label: string(),
39977
- isAdmin: boolean().default(false),
39978
- allowedProviders: union([array(string()), literal("*")]).optional(),
39979
- allowedDevices: record(string(), union([array(string()), literal("*")])).optional()
39980
- });
39981
- var CreateApiKeyResultSchema = object({
39982
- token: string(),
39983
- record: ApiKeySummarySchema
39984
- });
39985
42530
  var ScopedTokenSummarySchema = object({
39986
42531
  id: string(),
39987
42532
  userId: string(),
@@ -40080,17 +42625,10 @@ method(_void(), array(UserSummarySchema), { auth: "admin" }), method(CreateUserI
40080
42625
  }), UserSummarySchema.extend({ passwordHash: string() }).nullable(), {
40081
42626
  kind: "mutation",
40082
42627
  access: "view"
40083
- }), method(_void(), array(ApiKeySummarySchema), { auth: "admin" }), method(CreateApiKeyInputSchema, CreateApiKeyResultSchema, {
40084
- kind: "mutation",
40085
- auth: "admin",
40086
- access: "create"
40087
- }), method(object({ id: string() }), object({ success: literal(true) }), {
42628
+ }), method(_void(), array(ApiKeySummarySchema), { auth: "admin" }), method(object({ id: string() }), object({ success: literal(true) }), {
40088
42629
  kind: "mutation",
40089
42630
  auth: "admin",
40090
42631
  access: "delete"
40091
- }), method(object({ token: string() }), ApiKeySummarySchema.nullable(), {
40092
- kind: "mutation",
40093
- access: "view"
40094
42632
  }), method(CreateScopedTokenInputSchema, CreateScopedTokenResultSchema, {
40095
42633
  kind: "mutation",
40096
42634
  auth: "admin",
@@ -40164,15 +42702,7 @@ method(_void(), array(UserSummarySchema), { auth: "admin" }), method(CreateUserI
40164
42702
  }).nullable(), { access: "view" }), method(object({ userId: string() }), array(ExternalIdentitySchema), { auth: "admin" }), method(ExternalIdentityKeySchema, object({
40165
42703
  userId: string(),
40166
42704
  issuer: string()
40167
- }).nullable(), { auth: "admin" }), method(ExternalIdentityKeySchema.extend({
40168
- userId: string(),
40169
- issuer: string().min(1),
40170
- label: string().optional()
40171
- }), object({ success: literal(true) }), {
40172
- kind: "mutation",
40173
- auth: "admin",
40174
- access: "create"
40175
- }), method(ExternalIdentityKeySchema.extend({ userId: string() }), object({ success: boolean() }), {
42705
+ }).nullable(), { auth: "admin" }), method(ExternalIdentityKeySchema.extend({ userId: string() }), object({ success: boolean() }), {
40176
42706
  kind: "mutation",
40177
42707
  auth: "admin",
40178
42708
  access: "delete"
@@ -40877,6 +43407,451 @@ var zoneRulesCapability = {
40877
43407
  */
40878
43408
  durability: "restored"
40879
43409
  };
43410
+ /**
43411
+ * `training-provider` — ONE cloud that can run the CamStack trainer.
43412
+ *
43413
+ * A thin, mockable translation layer: it knows how to run a container with a
43414
+ * GPU, move a dataset in, read the job's stdout and hand artefacts back. It
43415
+ * knows nothing about datasets, splits, floors, cost policy or Model Studio —
43416
+ * those are the `training` orchestrator's (D805). Every rule written there
43417
+ * once is what makes a second provider (RunPod, a local NVIDIA node) a new
43418
+ * manifest entry and nothing else.
43419
+ *
43420
+ * Collection, routed by the `addonId` in every single-row input (the `llm` /
43421
+ * `notification-output` posture); `describe` concat-fans across providers.
43422
+ * Every method is `admin`: these spend money.
43423
+ *
43424
+ * Every cloud object a provider creates is tagged with the orchestrator's
43425
+ * `jobKey`, so a retried submit finds the job it already started instead of
43426
+ * starting a second GPU, and `listJobs` can find orphans.
43427
+ *
43428
+ * Bytes never ride a cap field: the dataset arrives as a `ctx.peerBytes`
43429
+ * ticket the producer (pipeline-analytics) minted, and artefacts leave as a
43430
+ * ticket the provider mints (D613).
43431
+ */
43432
+ var TrainingGpuOptionSchema = object({
43433
+ id: string(),
43434
+ label: string(),
43435
+ /** List price, USD per GPU-hour, before any region multiplier. */
43436
+ usdPerHour: number().nonnegative(),
43437
+ vramGb: number().nonnegative()
43438
+ });
43439
+ var TrainingRegionOptionSchema = object({
43440
+ /** `''` = any region (the provider's choice). */
43441
+ id: string(),
43442
+ label: string(),
43443
+ priceMultiplier: number().positive()
43444
+ });
43445
+ /**
43446
+ * The provider's per-account settings, as the orchestrator reads them. They
43447
+ * live in the PROVIDER addon's settings (operator decision 2026-10-08: they
43448
+ * depend on the user's account), never hard-coded in the orchestrator.
43449
+ */
43450
+ var TrainingProviderDefaultsSchema = object({
43451
+ gpuType: string(),
43452
+ region: string(),
43453
+ costCapUsd: number().nonnegative(),
43454
+ maxRuntimeSec: number().int().positive(),
43455
+ /** Hours a FAILED job's cloud dataset is kept for debugging; 0 = delete at once. */
43456
+ failedDatasetGraceHours: number().nonnegative()
43457
+ });
43458
+ var TrainingProviderDescriptorSchema = object({
43459
+ addonId: string(),
43460
+ /** `modal`, `runpod`, `fake`, … */
43461
+ kind: string(),
43462
+ label: string(),
43463
+ gpuTypes: array(TrainingGpuOptionSchema).readonly(),
43464
+ regions: array(TrainingRegionOptionSchema).readonly(),
43465
+ maxDatasetBytes: number().int().positive(),
43466
+ maxRuntimeSec: number().int().positive(),
43467
+ freeTierNote: string().optional(),
43468
+ /** Where the data goes, in one sentence the confirm dialog repeats. */
43469
+ dataResidencyNote: string(),
43470
+ /** Credentials are present — never the values. */
43471
+ configured: boolean(),
43472
+ defaults: TrainingProviderDefaultsSchema
43473
+ });
43474
+ var TrainingCredentialCheckSchema = object({
43475
+ ok: boolean(),
43476
+ /** Workspace / account name, when the provider says. */
43477
+ account: string().optional(),
43478
+ reason: _enum([
43479
+ "missing",
43480
+ "invalid",
43481
+ "forbidden",
43482
+ "network",
43483
+ "quota"
43484
+ ]).optional(),
43485
+ detail: string().optional()
43486
+ });
43487
+ var ProviderJobStateSchema = _enum([
43488
+ "pending",
43489
+ "starting",
43490
+ "running",
43491
+ "succeeded",
43492
+ "failed",
43493
+ "cancelled",
43494
+ "lost"
43495
+ ]);
43496
+ var ProviderJobStatusSchema = object({
43497
+ jobKey: string(),
43498
+ providerJobId: string().optional(),
43499
+ state: ProviderJobStateSchema,
43500
+ startedAt: number().optional(),
43501
+ endedAt: number().optional(),
43502
+ exitCode: number().int().optional(),
43503
+ failureReason: string().optional(),
43504
+ gpuType: string(),
43505
+ region: string().optional(),
43506
+ billedSeconds: number().nonnegative(),
43507
+ costUsd: number().nonnegative(),
43508
+ /** True when `costUsd` is runtime × list price, not a billing answer. */
43509
+ costIsEstimate: boolean(),
43510
+ lastFetchedAt: number()
43511
+ });
43512
+ /**
43513
+ * The trainer the job runs, by SOURCE revision: the provider turns it into an
43514
+ * image its own way (Modal builds the published Dockerfile at that revision;
43515
+ * a registry-pull provider maps it to a tag). Recorded on the job and echoed
43516
+ * in `result.json`.
43517
+ */
43518
+ var TrainerSourceRefSchema = object({
43519
+ /** Hugging Face repo id, e.g. `camstack/camstack-trainer`. */
43520
+ repo: string().min(1),
43521
+ /** A commit sha (never a branch) — the job must be reproducible. */
43522
+ revision: string().regex(/^[0-9a-f]{7,64}$/)
43523
+ });
43524
+ var JobRef = {
43525
+ addonId: string(),
43526
+ jobKey: string().uuid()
43527
+ };
43528
+ var TrainingLogLineSchema = object({
43529
+ ts: number(),
43530
+ text: string()
43531
+ });
43532
+ method(object({}), array(TrainingProviderDescriptorSchema).readonly(), { auth: "admin" }), method(object({ addonId: string() }), TrainingCredentialCheckSchema, {
43533
+ kind: "mutation",
43534
+ auth: "admin",
43535
+ timeoutMs: 3e4
43536
+ }), method(object({
43537
+ addonId: string(),
43538
+ gpuType: string(),
43539
+ region: string(),
43540
+ datasetBytes: number().int().nonnegative(),
43541
+ gpuSecondsLow: number().nonnegative(),
43542
+ gpuSecondsHigh: number().nonnegative()
43543
+ }), object({
43544
+ usdLow: number().nonnegative(),
43545
+ usdHigh: number().nonnegative(),
43546
+ notes: array(string()).readonly()
43547
+ }), { auth: "admin" }), method(object({
43548
+ ...JobRef,
43549
+ ticket: PeerBytesTicketSchema
43550
+ }), object({
43551
+ bytes: number().int().nonnegative(),
43552
+ sha256: string()
43553
+ }), {
43554
+ kind: "mutation",
43555
+ auth: "admin",
43556
+ timeoutMs: 120 * 6e4
43557
+ }), method(object({
43558
+ ...JobRef,
43559
+ trainer: TrainerSourceRefSchema,
43560
+ jobSpecJson: string().min(2).max(64e3),
43561
+ gpuType: string(),
43562
+ region: string(),
43563
+ maxRuntimeSec: number().int().positive()
43564
+ }), ProviderJobStatusSchema, {
43565
+ kind: "mutation",
43566
+ auth: "admin",
43567
+ timeoutMs: 30 * 6e4
43568
+ }), method(object(JobRef), ProviderJobStatusSchema, {
43569
+ auth: "admin",
43570
+ timeoutMs: 6e4
43571
+ }), method(object({
43572
+ ...JobRef,
43573
+ cursor: string().optional(),
43574
+ max: number().int().min(1).max(500)
43575
+ }), object({
43576
+ lines: array(TrainingLogLineSchema).readonly(),
43577
+ cursor: string()
43578
+ }), {
43579
+ auth: "admin",
43580
+ timeoutMs: 6e4
43581
+ }), method(object(JobRef), object({ ok: literal(true) }), {
43582
+ kind: "mutation",
43583
+ auth: "admin",
43584
+ timeoutMs: 6e4
43585
+ }), method(object(JobRef), object({
43586
+ found: boolean(),
43587
+ text: string().optional()
43588
+ }), {
43589
+ kind: "mutation",
43590
+ auth: "admin",
43591
+ timeoutMs: 5 * 6e4
43592
+ }), method(object({
43593
+ ...JobRef,
43594
+ path: _enum(["bundle.tar"])
43595
+ }), object({ ticket: PeerBytesTicketSchema }), {
43596
+ kind: "mutation",
43597
+ auth: "admin",
43598
+ timeoutMs: 5 * 6e4
43599
+ }), method(object(JobRef), object({ deleted: array(string()).readonly() }), {
43600
+ kind: "mutation",
43601
+ auth: "admin",
43602
+ timeoutMs: 5 * 6e4
43603
+ }), method(object({ addonId: string() }), array(ProviderJobStatusSchema).readonly(), {
43604
+ auth: "admin",
43605
+ timeoutMs: 2 * 6e4
43606
+ });
43607
+ /**
43608
+ * `training` — the cloud-training orchestrator (D805). Hub-only singleton,
43609
+ * provided by `addon-training`.
43610
+ *
43611
+ * It owns what every provider must agree on, written once:
43612
+ *
43613
+ * - **Dataset versions.** Taken over from pipeline-analytics (D796): the rows
43614
+ * live here (D808); pipeline-analytics still CUTS a version (it owns the corpus and
43615
+ * the export plan) and reaches this store through the five row methods
43616
+ * below, so the Retrain page and the export did not change.
43617
+ * - **Jobs.** A persisted state machine, a reconcile loop against the
43618
+ * provider, a cost guard, a daily orphan sweep and the retention rules.
43619
+ * - **The return flow.** Verified artefacts → Model Studio
43620
+ * (`custom-model-registry.importModelBundle`) → canary on cameras →
43621
+ * rollback. Nothing is ever registered automatically.
43622
+ *
43623
+ * Every method is `admin`.
43624
+ */
43625
+ /** A version WITH its frame list — what the export and a job read. */
43626
+ var TrainingDatasetVersionRowSchema = RetrainDatasetVersionSchema.omit({ frameCount: true }).extend({ frameIds: array(string()).max(2e4).readonly() });
43627
+ /** A base model a detector job can fine-tune, and the baseline it is judged against. */
43628
+ var TrainingBaseModelSchema = object({
43629
+ modelId: string(),
43630
+ label: string(),
43631
+ weights: string(),
43632
+ imgsz: number().int(),
43633
+ baselineOnnxUrl: string(),
43634
+ baselineFloors: record(string(), number()),
43635
+ /** The base the fleet runs most — the UI's default. */
43636
+ recommended: boolean()
43637
+ });
43638
+ var TrainingPresetSchema = _enum([
43639
+ "quick",
43640
+ "standard",
43641
+ "thorough"
43642
+ ]);
43643
+ var TrainingJobRequestSchema = object({
43644
+ datasetVersionId: string().min(1),
43645
+ /** The `training-provider` addon that runs it. */
43646
+ addonId: string().min(1),
43647
+ gpuType: string().min(1),
43648
+ region: string(),
43649
+ baseModelId: string().min(1),
43650
+ preset: TrainingPresetSchema,
43651
+ /** Freeze the backbone's first N layers; `null` = the preset's choice. */
43652
+ freeze: number().int().nonnegative().nullable(),
43653
+ /** Cameras held out whole for evaluation; `null` = the orchestrator's default. */
43654
+ holdoutCameras: array(number().int()).nullable()
43655
+ });
43656
+ var TrainingSplitPlanSchema = object({
43657
+ holdoutCameras: array(number().int()).readonly(),
43658
+ /** Used when no camera is held out: the last N days of every camera. */
43659
+ holdoutLastDays: number().int().nonnegative(),
43660
+ /** Holdout subjects per class (camera holdout only; `null` = known only after the split). */
43661
+ holdoutSupport: record(string(), number().int()).nullable(),
43662
+ trainSubjects: number().int()
43663
+ });
43664
+ var TrainingRefusalReasonSchema = _enum([
43665
+ "unknown-dataset",
43666
+ "unknown-provider",
43667
+ "provider-not-configured",
43668
+ "unknown-base-model",
43669
+ "unknown-gpu",
43670
+ "dataset-too-large",
43671
+ "no-training-subjects",
43672
+ "job-already-running"
43673
+ ]);
43674
+ var TrainingJobPlanSchema = object({
43675
+ refusal: object({
43676
+ reason: TrainingRefusalReasonSchema,
43677
+ detail: string()
43678
+ }).nullable(),
43679
+ warnings: array(string()).readonly(),
43680
+ split: TrainingSplitPlanSchema.nullable(),
43681
+ estimate: object({
43682
+ datasetBytes: number().int(),
43683
+ uploadMinutesAt20Mbps: number(),
43684
+ gpuSecondsLow: number(),
43685
+ gpuSecondsHigh: number(),
43686
+ usdLow: number(),
43687
+ usdHigh: number(),
43688
+ notes: array(string()).readonly()
43689
+ }).nullable(),
43690
+ /** Pre-filled from the provider's settings; the operator may lower or raise them. */
43691
+ defaults: object({
43692
+ maxCostUsd: number(),
43693
+ maxRuntimeSec: number().int()
43694
+ }).nullable(),
43695
+ /** The sentence the confirm dialog repeats: where the frames go and when they are deleted. */
43696
+ dataNotice: string()
43697
+ });
43698
+ /**
43699
+ * Orchestrator-owned states, persisted. `uploading` covers exporting the
43700
+ * archive (it is streamed, never staged). Terminal: `failed`, `cancelled`,
43701
+ * `lost`, `expired`, `discarded`. `registered` and `canary` are where a
43702
+ * result lives after the operator acted on it.
43703
+ */
43704
+ var TrainingJobStateSchema = _enum([
43705
+ "uploading",
43706
+ "submitted",
43707
+ "starting",
43708
+ "running",
43709
+ "collecting",
43710
+ "ready",
43711
+ "registered",
43712
+ "canary",
43713
+ "failed",
43714
+ "cancelling",
43715
+ "cancelled",
43716
+ "lost",
43717
+ "expired",
43718
+ "discarded"
43719
+ ]);
43720
+ var TrainingFailureReasonSchema = _enum([
43721
+ "cost-cap",
43722
+ "runtime-cap",
43723
+ "upload-failed",
43724
+ "submit-failed",
43725
+ "trainer-failed",
43726
+ "result-invalid",
43727
+ "checksum-mismatch",
43728
+ "fetch-failed",
43729
+ "provider-error",
43730
+ "hub-restart-during-upload"
43731
+ ]);
43732
+ var TrainingProgressPointSchema = object({
43733
+ epoch: number().int(),
43734
+ map50: number().nullable(),
43735
+ map50_95: number().nullable()
43736
+ });
43737
+ var TrainingCanarySchema = object({
43738
+ deviceIds: array(number().int()).readonly(),
43739
+ since: number(),
43740
+ /** Every override the canary replaced, exactly, so rollback restores it. */
43741
+ previous: array(object({
43742
+ deviceId: number().int(),
43743
+ nodeId: string(),
43744
+ deviceKey: string(),
43745
+ patch: object({
43746
+ modelId: string().optional(),
43747
+ settings: record(string(), unknown()).readonly().optional()
43748
+ }).nullable()
43749
+ })).readonly()
43750
+ });
43751
+ var TrainingJobSchema = object({
43752
+ id: string(),
43753
+ idempotencyKey: string(),
43754
+ name: string(),
43755
+ createdAt: number(),
43756
+ updatedAt: number(),
43757
+ state: TrainingJobStateSchema,
43758
+ stage: TrainingStageSchema.nullable(),
43759
+ failure: object({
43760
+ reason: TrainingFailureReasonSchema,
43761
+ stage: string().nullable(),
43762
+ detail: string()
43763
+ }).nullable(),
43764
+ request: TrainingJobRequestSchema,
43765
+ maxCostUsd: number().nonnegative(),
43766
+ maxRuntimeSec: number().int().positive(),
43767
+ trainer: TrainerSourceRefSchema,
43768
+ datasetLayout: RetrainExportLayoutSchema,
43769
+ dataset: object({
43770
+ bytes: number().int(),
43771
+ sha256: string(),
43772
+ uploadedAt: number()
43773
+ }).nullable(),
43774
+ split: TrainingSplitPlanSchema,
43775
+ provider: object({
43776
+ state: ProviderJobStateSchema.nullable(),
43777
+ providerJobId: string().nullable(),
43778
+ startedAt: number().nullable(),
43779
+ endedAt: number().nullable(),
43780
+ billedSeconds: number(),
43781
+ costUsd: number(),
43782
+ costIsEstimate: boolean(),
43783
+ lastPolledAt: number().nullable()
43784
+ }),
43785
+ progress: object({
43786
+ epoch: number().int().nullable(),
43787
+ epochs: number().int().nullable(),
43788
+ etaSec: number().nullable(),
43789
+ series: array(TrainingProgressPointSchema).readonly()
43790
+ }),
43791
+ /** The last lines of the job's output (≤ 200), newest last. Never frame paths. */
43792
+ logTail: array(string()).readonly(),
43793
+ logCursor: string().nullable(),
43794
+ artifacts: object({
43795
+ bundleBytes: number().int(),
43796
+ bundleSha256: string(),
43797
+ fetchedAt: number(),
43798
+ /** When the staged artefacts are deleted from the hub. */
43799
+ expiresAt: number()
43800
+ }).nullable(),
43801
+ /** When the provider-side copy of the frames was deleted; null while it exists. */
43802
+ cloudDatasetDeletedAt: number().nullable(),
43803
+ /** A failed job's dataset is kept until then (the provider's grace), then deleted. */
43804
+ cloudCleanupDueAt: number().nullable(),
43805
+ /** Model ids registered from this job (base, and int8 when kept). */
43806
+ registeredModelIds: array(string()).readonly(),
43807
+ canary: TrainingCanarySchema.nullable()
43808
+ });
43809
+ var IdInput = object({ id: string().min(1) });
43810
+ method(TrainingDatasetVersionRowSchema, object({ stored: boolean() }), {
43811
+ kind: "mutation",
43812
+ auth: "admin"
43813
+ }), method(IdInput, TrainingDatasetVersionRowSchema.nullable(), { auth: "admin" }), method(object({}), array(RetrainDatasetVersionSchema).readonly(), { auth: "admin" }), method(object({ name: string() }), object({ id: string().nullable() }), { auth: "admin" }), method(IdInput, object({ removed: boolean() }), {
43814
+ kind: "mutation",
43815
+ auth: "admin"
43816
+ }), method(object({}), array(TrainingBaseModelSchema).readonly(), { auth: "admin" }), method(TrainingJobRequestSchema, TrainingJobPlanSchema, {
43817
+ auth: "admin",
43818
+ timeoutMs: 6e4
43819
+ }), method(TrainingJobRequestSchema.extend({
43820
+ name: string().min(1).max(120),
43821
+ maxCostUsd: number().positive(),
43822
+ maxRuntimeSec: number().int().positive(),
43823
+ idempotencyKey: string().min(8).max(80)
43824
+ }), discriminatedUnion("kind", [object({
43825
+ kind: literal("started"),
43826
+ job: TrainingJobSchema
43827
+ }), object({
43828
+ kind: literal("refused"),
43829
+ reason: TrainingRefusalReasonSchema,
43830
+ detail: string()
43831
+ })]), {
43832
+ kind: "mutation",
43833
+ auth: "admin",
43834
+ timeoutMs: 12e4
43835
+ }), method(object({}), array(TrainingJobSchema).readonly(), { auth: "admin" }), method(IdInput, TrainingJobSchema.nullable(), { auth: "admin" }), method(IdInput, TrainingJobSchema, {
43836
+ kind: "mutation",
43837
+ auth: "admin",
43838
+ timeoutMs: 12e4
43839
+ }), method(IdInput, TrainingResultSchema.nullable(), { auth: "admin" }), method(IdInput.extend({ canaryDeviceIds: array(number().int()).readonly() }), TrainingJobSchema, {
43840
+ kind: "mutation",
43841
+ auth: "admin",
43842
+ timeoutMs: 30 * 6e4
43843
+ }), method(IdInput.extend({ deviceIds: array(number().int()).min(1).readonly() }), TrainingJobSchema, {
43844
+ kind: "mutation",
43845
+ auth: "admin",
43846
+ timeoutMs: 12e4
43847
+ }), method(IdInput, TrainingJobSchema, {
43848
+ kind: "mutation",
43849
+ auth: "admin",
43850
+ timeoutMs: 12e4
43851
+ }), method(IdInput, TrainingJobSchema, {
43852
+ kind: "mutation",
43853
+ auth: "admin"
43854
+ });
40880
43855
  SOURCE_CAPS.filter((cap) => cap !== "switch" && cap !== "motion");
40881
43856
  Object.freeze({
40882
43857
  person: .5,
@@ -41363,7 +44338,8 @@ var BaseDevice = class {
41363
44338
  this.role = options.role;
41364
44339
  this.parentDeviceId = ctx.parentDeviceId;
41365
44340
  const seedData = ctx.persistedConfig ?? {};
41366
- this.config = DeviceConfig.fromSchema(schema, (data) => ctx.persistConfig(data), seedData, ({ droppedKeys, issues }) => {
44341
+ const declaredSecretPaths = collectZodSecretPaths(schema);
44342
+ this.config = DeviceConfig.fromSchema(schema, (data) => ctx.persistConfig(data, { secretConfigPaths: declaredSecretPaths }), seedData, ({ droppedKeys, issues }) => {
41367
44343
  ctx.logger.warn("Device config recovery: dropping invalid persisted fields", {
41368
44344
  tags: {
41369
44345
  deviceId: ctx.id,
@@ -43024,6 +46000,12 @@ Object.freeze({
43024
46000
  addonId: null,
43025
46001
  access: "create"
43026
46002
  },
46003
+ "backup.checkBackupKey": {
46004
+ capName: "backup",
46005
+ capScope: "system",
46006
+ addonId: null,
46007
+ access: "create"
46008
+ },
43027
46009
  "backup.delete": {
43028
46010
  capName: "backup",
43029
46011
  capScope: "system",
@@ -43036,6 +46018,18 @@ Object.freeze({
43036
46018
  addonId: null,
43037
46019
  access: "delete"
43038
46020
  },
46021
+ "backup.disableEncryption": {
46022
+ capName: "backup",
46023
+ capScope: "system",
46024
+ addonId: null,
46025
+ access: "create"
46026
+ },
46027
+ "backup.getEncryption": {
46028
+ capName: "backup",
46029
+ capScope: "system",
46030
+ addonId: null,
46031
+ access: "view"
46032
+ },
43039
46033
  "backup.getEntries": {
43040
46034
  capName: "backup",
43041
46035
  capScope: "system",
@@ -43090,6 +46084,12 @@ Object.freeze({
43090
46084
  addonId: null,
43091
46085
  access: "create"
43092
46086
  },
46087
+ "backup.setupEncryption": {
46088
+ capName: "backup",
46089
+ capScope: "system",
46090
+ addonId: null,
46091
+ access: "create"
46092
+ },
43093
46093
  "backup.trigger": {
43094
46094
  capName: "backup",
43095
46095
  capScope: "system",
@@ -43642,6 +46642,12 @@ Object.freeze({
43642
46642
  addonId: null,
43643
46643
  access: "create"
43644
46644
  },
46645
+ "customModelRegistry.importModelBundle": {
46646
+ capName: "custom-model-registry",
46647
+ capScope: "system",
46648
+ addonId: null,
46649
+ access: "create"
46650
+ },
43645
46651
  "customModelRegistry.listModels": {
43646
46652
  capName: "custom-model-registry",
43647
46653
  capScope: "system",
@@ -45052,6 +48058,108 @@ Object.freeze({
45052
48058
  addonId: null,
45053
48059
  access: "create"
45054
48060
  },
48061
+ "keychain.delete": {
48062
+ capName: "keychain",
48063
+ capScope: "system",
48064
+ addonId: null,
48065
+ access: "delete"
48066
+ },
48067
+ "keychain.getState": {
48068
+ capName: "keychain",
48069
+ capScope: "system",
48070
+ addonId: null,
48071
+ access: "view"
48072
+ },
48073
+ "keychain.listMeta": {
48074
+ capName: "keychain",
48075
+ capScope: "system",
48076
+ addonId: null,
48077
+ access: "view"
48078
+ },
48079
+ "keychain.put": {
48080
+ capName: "keychain",
48081
+ capScope: "system",
48082
+ addonId: null,
48083
+ access: "create"
48084
+ },
48085
+ "keychain.resolve": {
48086
+ capName: "keychain",
48087
+ capScope: "system",
48088
+ addonId: null,
48089
+ access: "view"
48090
+ },
48091
+ "keychainAdmin.acknowledgeReset": {
48092
+ capName: "keychain-admin",
48093
+ capScope: "system",
48094
+ addonId: null,
48095
+ access: "create"
48096
+ },
48097
+ "keychainAdmin.deleteOrphans": {
48098
+ capName: "keychain-admin",
48099
+ capScope: "system",
48100
+ addonId: null,
48101
+ access: "delete"
48102
+ },
48103
+ "keychainAdmin.downloadRecoveryKey": {
48104
+ capName: "keychain-admin",
48105
+ capScope: "system",
48106
+ addonId: null,
48107
+ access: "create"
48108
+ },
48109
+ "keychainAdmin.listAudit": {
48110
+ capName: "keychain-admin",
48111
+ capScope: "system",
48112
+ addonId: null,
48113
+ access: "view"
48114
+ },
48115
+ "keychainAdmin.listSecrets": {
48116
+ capName: "keychain-admin",
48117
+ capScope: "system",
48118
+ addonId: null,
48119
+ access: "view"
48120
+ },
48121
+ "keychainAdmin.purgeRetiredKeys": {
48122
+ capName: "keychain-admin",
48123
+ capScope: "system",
48124
+ addonId: null,
48125
+ access: "delete"
48126
+ },
48127
+ "keychainAdmin.resetKeychain": {
48128
+ capName: "keychain-admin",
48129
+ capScope: "system",
48130
+ addonId: null,
48131
+ access: "delete"
48132
+ },
48133
+ "keychainAdmin.resetReport": {
48134
+ capName: "keychain-admin",
48135
+ capScope: "system",
48136
+ addonId: null,
48137
+ access: "delete"
48138
+ },
48139
+ "keychainAdmin.reveal": {
48140
+ capName: "keychain-admin",
48141
+ capScope: "system",
48142
+ addonId: null,
48143
+ access: "create"
48144
+ },
48145
+ "keychainAdmin.rotateMasterKey": {
48146
+ capName: "keychain-admin",
48147
+ capScope: "system",
48148
+ addonId: null,
48149
+ access: "create"
48150
+ },
48151
+ "keychainAdmin.setSystemSecret": {
48152
+ capName: "keychain-admin",
48153
+ capScope: "system",
48154
+ addonId: null,
48155
+ access: "create"
48156
+ },
48157
+ "keychainAdmin.status": {
48158
+ capName: "keychain-admin",
48159
+ capScope: "system",
48160
+ addonId: null,
48161
+ access: "view"
48162
+ },
45055
48163
  "lawnMowerControl.dock": {
45056
48164
  capName: "lawn-mower-control",
45057
48165
  capScope: "device",
@@ -46426,6 +49534,18 @@ Object.freeze({
46426
49534
  addonId: null,
46427
49535
  access: "create"
46428
49536
  },
49537
+ "pipelineAnalytics.addRetrainFrameFromRecording": {
49538
+ capName: "pipeline-analytics",
49539
+ capScope: "device",
49540
+ addonId: null,
49541
+ access: "create"
49542
+ },
49543
+ "pipelineAnalytics.addRetrainFramesToCollection": {
49544
+ capName: "pipeline-analytics",
49545
+ capScope: "device",
49546
+ addonId: null,
49547
+ access: "create"
49548
+ },
46429
49549
  "pipelineAnalytics.applyDeviceSettingsPatch": {
46430
49550
  capName: "pipeline-analytics",
46431
49551
  capScope: "device",
@@ -46474,12 +49594,36 @@ Object.freeze({
46474
49594
  addonId: null,
46475
49595
  access: "view"
46476
49596
  },
49597
+ "pipelineAnalytics.createRetrainCollection": {
49598
+ capName: "pipeline-analytics",
49599
+ capScope: "device",
49600
+ addonId: null,
49601
+ access: "create"
49602
+ },
49603
+ "pipelineAnalytics.createRetrainDatasetVersion": {
49604
+ capName: "pipeline-analytics",
49605
+ capScope: "device",
49606
+ addonId: null,
49607
+ access: "create"
49608
+ },
46477
49609
  "pipelineAnalytics.deleteDeviceEvents": {
46478
49610
  capName: "pipeline-analytics",
46479
49611
  capScope: "device",
46480
49612
  addonId: null,
46481
49613
  access: "delete"
46482
49614
  },
49615
+ "pipelineAnalytics.deleteRetrainCollection": {
49616
+ capName: "pipeline-analytics",
49617
+ capScope: "device",
49618
+ addonId: null,
49619
+ access: "delete"
49620
+ },
49621
+ "pipelineAnalytics.deleteRetrainDatasetVersion": {
49622
+ capName: "pipeline-analytics",
49623
+ capScope: "device",
49624
+ addonId: null,
49625
+ access: "delete"
49626
+ },
46483
49627
  "pipelineAnalytics.deleteTracks": {
46484
49628
  capName: "pipeline-analytics",
46485
49629
  capScope: "device",
@@ -46684,6 +49828,30 @@ Object.freeze({
46684
49828
  addonId: null,
46685
49829
  access: "view"
46686
49830
  },
49831
+ "pipelineAnalytics.listRetrainAssistProfiles": {
49832
+ capName: "pipeline-analytics",
49833
+ capScope: "device",
49834
+ addonId: null,
49835
+ access: "view"
49836
+ },
49837
+ "pipelineAnalytics.listRetrainCollectionFrames": {
49838
+ capName: "pipeline-analytics",
49839
+ capScope: "device",
49840
+ addonId: null,
49841
+ access: "view"
49842
+ },
49843
+ "pipelineAnalytics.listRetrainCollections": {
49844
+ capName: "pipeline-analytics",
49845
+ capScope: "device",
49846
+ addonId: null,
49847
+ access: "view"
49848
+ },
49849
+ "pipelineAnalytics.listRetrainDatasetVersions": {
49850
+ capName: "pipeline-analytics",
49851
+ capScope: "device",
49852
+ addonId: null,
49853
+ access: "view"
49854
+ },
46687
49855
  "pipelineAnalytics.listRetrainFrames": {
46688
49856
  capName: "pipeline-analytics",
46689
49857
  capScope: "device",
@@ -46714,6 +49882,12 @@ Object.freeze({
46714
49882
  addonId: null,
46715
49883
  access: "view"
46716
49884
  },
49885
+ "pipelineAnalytics.offerRetrainArchive": {
49886
+ capName: "pipeline-analytics",
49887
+ capScope: "device",
49888
+ addonId: null,
49889
+ access: "create"
49890
+ },
46717
49891
  "pipelineAnalytics.ownersWithMedia": {
46718
49892
  capName: "pipeline-analytics",
46719
49893
  capScope: "device",
@@ -46726,12 +49900,24 @@ Object.freeze({
46726
49900
  addonId: null,
46727
49901
  access: "create"
46728
49902
  },
49903
+ "pipelineAnalytics.previewRetrainDataset": {
49904
+ capName: "pipeline-analytics",
49905
+ capScope: "device",
49906
+ addonId: null,
49907
+ access: "view"
49908
+ },
46729
49909
  "pipelineAnalytics.proposeRetrainAnnotations": {
46730
49910
  capName: "pipeline-analytics",
46731
49911
  capScope: "device",
46732
49912
  addonId: null,
46733
49913
  access: "create"
46734
49914
  },
49915
+ "pipelineAnalytics.proposeRetrainAnnotationsWithLlm": {
49916
+ capName: "pipeline-analytics",
49917
+ capScope: "device",
49918
+ addonId: null,
49919
+ access: "create"
49920
+ },
46735
49921
  "pipelineAnalytics.pruneEvents": {
46736
49922
  capName: "pipeline-analytics",
46737
49923
  capScope: "device",
@@ -46786,6 +49972,18 @@ Object.freeze({
46786
49972
  addonId: null,
46787
49973
  access: "create"
46788
49974
  },
49975
+ "pipelineAnalytics.removeRetrainFrameFromCollection": {
49976
+ capName: "pipeline-analytics",
49977
+ capScope: "device",
49978
+ addonId: null,
49979
+ access: "delete"
49980
+ },
49981
+ "pipelineAnalytics.renameRetrainCollection": {
49982
+ capName: "pipeline-analytics",
49983
+ capScope: "device",
49984
+ addonId: null,
49985
+ access: "create"
49986
+ },
46789
49987
  "pipelineAnalytics.restageRetrainTrack": {
46790
49988
  capName: "pipeline-analytics",
46791
49989
  capScope: "device",
@@ -46846,6 +50044,12 @@ Object.freeze({
46846
50044
  addonId: null,
46847
50045
  access: "create"
46848
50046
  },
50047
+ "pipelineAnalytics.verifyRetrainDatasetVersion": {
50048
+ capName: "pipeline-analytics",
50049
+ capScope: "device",
50050
+ addonId: null,
50051
+ access: "view"
50052
+ },
46849
50053
  "pipelineAnalytics.wipeAllAnalytics": {
46850
50054
  capName: "pipeline-analytics",
46851
50055
  capScope: "device",
@@ -47074,6 +50278,12 @@ Object.freeze({
47074
50278
  addonId: null,
47075
50279
  access: "view"
47076
50280
  },
50281
+ "pipelineOrchestrator.abortNodeBenchmark": {
50282
+ capName: "pipeline-orchestrator",
50283
+ capScope: "system",
50284
+ addonId: null,
50285
+ access: "create"
50286
+ },
47077
50287
  "pipelineOrchestrator.applyAutoTune": {
47078
50288
  capName: "pipeline-orchestrator",
47079
50289
  capScope: "system",
@@ -47098,6 +50308,12 @@ Object.freeze({
47098
50308
  addonId: null,
47099
50309
  access: "create"
47100
50310
  },
50311
+ "pipelineOrchestrator.deleteNodeBenchmarkResult": {
50312
+ capName: "pipeline-orchestrator",
50313
+ capScope: "system",
50314
+ addonId: null,
50315
+ access: "delete"
50316
+ },
47101
50317
  "pipelineOrchestrator.getAgentLoad": {
47102
50318
  capName: "pipeline-orchestrator",
47103
50319
  capScope: "system",
@@ -47206,6 +50422,24 @@ Object.freeze({
47206
50422
  addonId: null,
47207
50423
  access: "view"
47208
50424
  },
50425
+ "pipelineOrchestrator.getNodeBenchmarkCandidates": {
50426
+ capName: "pipeline-orchestrator",
50427
+ capScope: "system",
50428
+ addonId: null,
50429
+ access: "view"
50430
+ },
50431
+ "pipelineOrchestrator.getNodeBenchmarkPreflight": {
50432
+ capName: "pipeline-orchestrator",
50433
+ capScope: "system",
50434
+ addonId: null,
50435
+ access: "view"
50436
+ },
50437
+ "pipelineOrchestrator.getNodeBenchmarkStatus": {
50438
+ capName: "pipeline-orchestrator",
50439
+ capScope: "system",
50440
+ addonId: null,
50441
+ access: "view"
50442
+ },
47209
50443
  "pipelineOrchestrator.getNodeInferenceDevices": {
47210
50444
  capName: "pipeline-orchestrator",
47211
50445
  capScope: "system",
@@ -47248,6 +50482,12 @@ Object.freeze({
47248
50482
  addonId: null,
47249
50483
  access: "view"
47250
50484
  },
50485
+ "pipelineOrchestrator.listNodeBenchmarkResults": {
50486
+ capName: "pipeline-orchestrator",
50487
+ capScope: "system",
50488
+ addonId: null,
50489
+ access: "view"
50490
+ },
47251
50491
  "pipelineOrchestrator.pauseForStorageMigration": {
47252
50492
  capName: "pipeline-orchestrator",
47253
50493
  capScope: "system",
@@ -47392,6 +50632,12 @@ Object.freeze({
47392
50632
  addonId: null,
47393
50633
  access: "create"
47394
50634
  },
50635
+ "pipelineOrchestrator.startNodeBenchmark": {
50636
+ capName: "pipeline-orchestrator",
50637
+ capScope: "system",
50638
+ addonId: null,
50639
+ access: "create"
50640
+ },
47395
50641
  "pipelineOrchestrator.suggestShares": {
47396
50642
  capName: "pipeline-orchestrator",
47397
50643
  capScope: "system",
@@ -47410,6 +50656,12 @@ Object.freeze({
47410
50656
  addonId: null,
47411
50657
  access: "create"
47412
50658
  },
50659
+ "pipelineRunner.abortNodeBench": {
50660
+ capName: "pipeline-runner",
50661
+ capScope: "system",
50662
+ addonId: null,
50663
+ access: "create"
50664
+ },
47413
50665
  "pipelineRunner.attachCamera": {
47414
50666
  capName: "pipeline-runner",
47415
50667
  capScope: "system",
@@ -47458,6 +50710,12 @@ Object.freeze({
47458
50710
  addonId: null,
47459
50711
  access: "view"
47460
50712
  },
50713
+ "pipelineRunner.getNodeBenchStatus": {
50714
+ capName: "pipeline-runner",
50715
+ capScope: "system",
50716
+ addonId: null,
50717
+ access: "view"
50718
+ },
47461
50719
  "pipelineRunner.getParkedTrackFrame": {
47462
50720
  capName: "pipeline-runner",
47463
50721
  capScope: "system",
@@ -47500,6 +50758,12 @@ Object.freeze({
47500
50758
  addonId: null,
47501
50759
  access: "create"
47502
50760
  },
50761
+ "pipelineRunner.startNodeBench": {
50762
+ capName: "pipeline-runner",
50763
+ capScope: "system",
50764
+ addonId: null,
50765
+ access: "create"
50766
+ },
47503
50767
  "plateGallery.assignPlate": {
47504
50768
  capName: "plate-gallery",
47505
50769
  capScope: "system",
@@ -49162,6 +52426,174 @@ Object.freeze({
49162
52426
  addonId: null,
49163
52427
  access: "view"
49164
52428
  },
52429
+ "training.canaryResult": {
52430
+ capName: "training",
52431
+ capScope: "system",
52432
+ addonId: null,
52433
+ access: "create"
52434
+ },
52435
+ "training.cancelJob": {
52436
+ capName: "training",
52437
+ capScope: "system",
52438
+ addonId: null,
52439
+ access: "create"
52440
+ },
52441
+ "training.discardResult": {
52442
+ capName: "training",
52443
+ capScope: "system",
52444
+ addonId: null,
52445
+ access: "create"
52446
+ },
52447
+ "training.findDatasetVersionIdByName": {
52448
+ capName: "training",
52449
+ capScope: "system",
52450
+ addonId: null,
52451
+ access: "view"
52452
+ },
52453
+ "training.getDatasetVersion": {
52454
+ capName: "training",
52455
+ capScope: "system",
52456
+ addonId: null,
52457
+ access: "view"
52458
+ },
52459
+ "training.getJob": {
52460
+ capName: "training",
52461
+ capScope: "system",
52462
+ addonId: null,
52463
+ access: "view"
52464
+ },
52465
+ "training.getJobResult": {
52466
+ capName: "training",
52467
+ capScope: "system",
52468
+ addonId: null,
52469
+ access: "view"
52470
+ },
52471
+ "training.listBaseModels": {
52472
+ capName: "training",
52473
+ capScope: "system",
52474
+ addonId: null,
52475
+ access: "view"
52476
+ },
52477
+ "training.listDatasetVersions": {
52478
+ capName: "training",
52479
+ capScope: "system",
52480
+ addonId: null,
52481
+ access: "view"
52482
+ },
52483
+ "training.listJobs": {
52484
+ capName: "training",
52485
+ capScope: "system",
52486
+ addonId: null,
52487
+ access: "view"
52488
+ },
52489
+ "training.planJob": {
52490
+ capName: "training",
52491
+ capScope: "system",
52492
+ addonId: null,
52493
+ access: "view"
52494
+ },
52495
+ "training.putDatasetVersion": {
52496
+ capName: "training",
52497
+ capScope: "system",
52498
+ addonId: null,
52499
+ access: "create"
52500
+ },
52501
+ "training.registerResult": {
52502
+ capName: "training",
52503
+ capScope: "system",
52504
+ addonId: null,
52505
+ access: "create"
52506
+ },
52507
+ "training.removeDatasetVersion": {
52508
+ capName: "training",
52509
+ capScope: "system",
52510
+ addonId: null,
52511
+ access: "delete"
52512
+ },
52513
+ "training.rollbackCanary": {
52514
+ capName: "training",
52515
+ capScope: "system",
52516
+ addonId: null,
52517
+ access: "create"
52518
+ },
52519
+ "training.startJob": {
52520
+ capName: "training",
52521
+ capScope: "system",
52522
+ addonId: null,
52523
+ access: "create"
52524
+ },
52525
+ "trainingProvider.cancelJob": {
52526
+ capName: "training-provider",
52527
+ capScope: "system",
52528
+ addonId: null,
52529
+ access: "create"
52530
+ },
52531
+ "trainingProvider.cleanupJob": {
52532
+ capName: "training-provider",
52533
+ capScope: "system",
52534
+ addonId: null,
52535
+ access: "create"
52536
+ },
52537
+ "trainingProvider.describe": {
52538
+ capName: "training-provider",
52539
+ capScope: "system",
52540
+ addonId: null,
52541
+ access: "view"
52542
+ },
52543
+ "trainingProvider.estimateJob": {
52544
+ capName: "training-provider",
52545
+ capScope: "system",
52546
+ addonId: null,
52547
+ access: "view"
52548
+ },
52549
+ "trainingProvider.getJob": {
52550
+ capName: "training-provider",
52551
+ capScope: "system",
52552
+ addonId: null,
52553
+ access: "view"
52554
+ },
52555
+ "trainingProvider.listJobEvents": {
52556
+ capName: "training-provider",
52557
+ capScope: "system",
52558
+ addonId: null,
52559
+ access: "view"
52560
+ },
52561
+ "trainingProvider.listJobs": {
52562
+ capName: "training-provider",
52563
+ capScope: "system",
52564
+ addonId: null,
52565
+ access: "view"
52566
+ },
52567
+ "trainingProvider.offerArtifact": {
52568
+ capName: "training-provider",
52569
+ capScope: "system",
52570
+ addonId: null,
52571
+ access: "create"
52572
+ },
52573
+ "trainingProvider.readResult": {
52574
+ capName: "training-provider",
52575
+ capScope: "system",
52576
+ addonId: null,
52577
+ access: "create"
52578
+ },
52579
+ "trainingProvider.submitJob": {
52580
+ capName: "training-provider",
52581
+ capScope: "system",
52582
+ addonId: null,
52583
+ access: "create"
52584
+ },
52585
+ "trainingProvider.uploadDataset": {
52586
+ capName: "training-provider",
52587
+ capScope: "system",
52588
+ addonId: null,
52589
+ access: "create"
52590
+ },
52591
+ "trainingProvider.validateCredentials": {
52592
+ capName: "training-provider",
52593
+ capScope: "system",
52594
+ addonId: null,
52595
+ access: "create"
52596
+ },
49165
52597
  "turnProvider.getTurnServers": {
49166
52598
  capName: "turn-provider",
49167
52599
  capScope: "system",
@@ -49186,12 +52618,6 @@ Object.freeze({
49186
52618
  addonId: null,
49187
52619
  access: "create"
49188
52620
  },
49189
- "userManagement.createApiKey": {
49190
- capName: "user-management",
49191
- capScope: "system",
49192
- addonId: null,
49193
- access: "create"
49194
- },
49195
52621
  "userManagement.createScopedToken": {
49196
52622
  capName: "user-management",
49197
52623
  capScope: "system",
@@ -49228,12 +52654,6 @@ Object.freeze({
49228
52654
  addonId: null,
49229
52655
  access: "view"
49230
52656
  },
49231
- "userManagement.linkExternalIdentity": {
49232
- capName: "user-management",
49233
- capScope: "system",
49234
- addonId: null,
49235
- access: "create"
49236
- },
49237
52657
  "userManagement.listApiKeys": {
49238
52658
  capName: "user-management",
49239
52659
  capScope: "system",
@@ -49336,12 +52756,6 @@ Object.freeze({
49336
52756
  addonId: null,
49337
52757
  access: "create"
49338
52758
  },
49339
- "userManagement.validateApiKey": {
49340
- capName: "user-management",
49341
- capScope: "system",
49342
- addonId: null,
49343
- access: "view"
49344
- },
49345
52759
  "userManagement.validateCredentials": {
49346
52760
  capName: "user-management",
49347
52761
  capScope: "system",
@@ -52429,6 +55843,11 @@ Object.freeze({
52429
55843
  form: "single",
52430
55844
  optional: false
52431
55845
  }],
55846
+ "pipelineAnalytics.addRetrainFrameFromRecording": [{
55847
+ name: "deviceId",
55848
+ form: "single",
55849
+ optional: false
55850
+ }],
52432
55851
  "pipelineAnalytics.applyDeviceSettingsPatch": [{
52433
55852
  name: "deviceId",
52434
55853
  form: "single",
@@ -52619,6 +56038,11 @@ Object.freeze({
52619
56038
  form: "single",
52620
56039
  optional: false
52621
56040
  }],
56041
+ "pipelineAnalytics.proposeRetrainAnnotationsWithLlm": [{
56042
+ name: "deviceId",
56043
+ form: "single",
56044
+ optional: false
56045
+ }],
52622
56046
  "pipelineAnalytics.pruneEventsBefore": [{
52623
56047
  name: "deviceId",
52624
56048
  form: "single",
@@ -53445,6 +56869,11 @@ Object.freeze({
53445
56869
  form: "single",
53446
56870
  optional: false
53447
56871
  }],
56872
+ "training.canaryResult": [{
56873
+ name: "deviceIds",
56874
+ form: "array",
56875
+ optional: false
56876
+ }],
53448
56877
  "update.getStatus": [{
53449
56878
  name: "deviceId",
53450
56879
  form: "single",