@camstack/addon-provider-wyze 0.2.133 → 0.2.135

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 +1622 -130
  2. package/dist/addon.mjs +1622 -130
  3. package/package.json +1 -1
package/dist/addon.js CHANGED
@@ -5409,7 +5409,7 @@ var ZodIssueCode = {
5409
5409
  var ZodFirstPartyTypeKind;
5410
5410
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
5411
5411
  //#endregion
5412
- //#region ../types/dist/sleep-DujUvOcb.mjs
5412
+ //#region ../types/dist/sleep-r3RWkGVx.mjs
5413
5413
  /**
5414
5414
  * The audio chunk plane's byte format, and the ONE expansion from a coded
5415
5415
  * window to float samples (D455).
@@ -5526,7 +5526,7 @@ function isKeychainStoredField(field) {
5526
5526
  var SECRET_CLEAR = { $secretClear: true };
5527
5527
  /** The `'***'` token D634 redaction writes for non-admins. */
5528
5528
  var LEGACY_DEVICE_REDACTION = "***";
5529
- function isRecord$1(value) {
5529
+ function isRecord$2(value) {
5530
5530
  return typeof value === "object" && value !== null && !Array.isArray(value);
5531
5531
  }
5532
5532
  function makeSecretMarker(ref) {
@@ -5537,12 +5537,12 @@ function makeSecretMarker(ref) {
5537
5537
  }
5538
5538
  /** A stored marker: an object whose `$secret` is a non-empty string. */
5539
5539
  function isSecretMarker(value) {
5540
- if (!isRecord$1(value)) return false;
5540
+ if (!isRecord$2(value)) return false;
5541
5541
  const ref = value["$secret"];
5542
5542
  return typeof ref === "string" && ref.length > 0;
5543
5543
  }
5544
5544
  function isSecretClear(value) {
5545
- return isRecord$1(value) && value["$secretClear"] === true;
5545
+ return isRecord$2(value) && value["$secretClear"] === true;
5546
5546
  }
5547
5547
  /**
5548
5548
  * The UI view of a stored secret field value: a marker becomes "set", inline
@@ -6058,6 +6058,13 @@ function globalSecretScope() {
6058
6058
  function encodeSegment(value) {
6059
6059
  return encodeURIComponent(value);
6060
6060
  }
6061
+ function decodeSegment(value) {
6062
+ try {
6063
+ return decodeURIComponent(value);
6064
+ } catch {
6065
+ return null;
6066
+ }
6067
+ }
6061
6068
  /**
6062
6069
  * The field path of a value inside an array item, addressed by the item's id:
6063
6070
  * `arrayItemFieldPath('providers', 'authentik', 'clientSecret')` →
@@ -6066,6 +6073,75 @@ function encodeSegment(value) {
6066
6073
  function arrayItemFieldPath(arrayKey, itemId, fieldKey) {
6067
6074
  return `${arrayKey}[${encodeSegment(itemId)}].${fieldKey}`;
6068
6075
  }
6076
+ function parseScope(segments) {
6077
+ switch (segments[0]) {
6078
+ case "global": return {
6079
+ scope: GLOBAL_SCOPE,
6080
+ used: 1
6081
+ };
6082
+ case "node": {
6083
+ const nodeId = segments[1] !== void 0 ? decodeSegment(segments[1]) : null;
6084
+ return nodeId === null || nodeId.length === 0 ? null : {
6085
+ scope: {
6086
+ kind: "node",
6087
+ nodeId
6088
+ },
6089
+ used: 2
6090
+ };
6091
+ }
6092
+ case "device": {
6093
+ const raw = segments[1];
6094
+ if (raw === void 0 || !/^\d+$/.test(raw)) return null;
6095
+ return {
6096
+ scope: {
6097
+ kind: "device",
6098
+ deviceId: Number(raw)
6099
+ },
6100
+ used: 2
6101
+ };
6102
+ }
6103
+ case "integration": {
6104
+ const id = segments[1] !== void 0 ? decodeSegment(segments[1]) : null;
6105
+ return id === null || id.length === 0 ? null : {
6106
+ scope: {
6107
+ kind: "integration",
6108
+ integrationId: id
6109
+ },
6110
+ used: 2
6111
+ };
6112
+ }
6113
+ case "row": {
6114
+ const collection = segments[1] !== void 0 ? decodeSegment(segments[1]) : null;
6115
+ const rowId = segments[2] !== void 0 ? decodeSegment(segments[2]) : null;
6116
+ if (collection === null || rowId === null || collection.length === 0 || rowId.length === 0) return null;
6117
+ return {
6118
+ scope: {
6119
+ kind: "row",
6120
+ collection,
6121
+ rowId
6122
+ },
6123
+ used: 3
6124
+ };
6125
+ }
6126
+ default: return null;
6127
+ }
6128
+ }
6129
+ /** Take a ref apart; `null` when it is not a well-formed ref. */
6130
+ function parseSecretRef(ref) {
6131
+ if (!ref.startsWith("secret://")) return null;
6132
+ const segments = ref.slice(9).split("/");
6133
+ const owner = segments[0] !== void 0 ? decodeSegment(segments[0]) : null;
6134
+ if (owner === null || owner.length === 0) return null;
6135
+ const parsed = parseScope(segments.slice(1));
6136
+ if (parsed === null) return null;
6137
+ const fieldPath = segments.slice(1 + parsed.used).join("/");
6138
+ if (fieldPath.length === 0) return null;
6139
+ return {
6140
+ owner,
6141
+ scope: parsed.scope,
6142
+ fieldPath
6143
+ };
6144
+ }
6069
6145
  /** A write to a secret path could not be stored in the keychain, so it was refused. */
6070
6146
  var KeychainWriteRefusedError = class extends Error {
6071
6147
  fieldPath;
@@ -6076,7 +6152,7 @@ var KeychainWriteRefusedError = class extends Error {
6076
6152
  }
6077
6153
  };
6078
6154
  var KEEP = { kind: "keep" };
6079
- function isRecord(value) {
6155
+ function isRecord$1(value) {
6080
6156
  return typeof value === "object" && value !== null && !Array.isArray(value);
6081
6157
  }
6082
6158
  function defaultMintId() {
@@ -6089,7 +6165,7 @@ function collectSecretMarkerRefs(value, out = []) {
6089
6165
  return out;
6090
6166
  }
6091
6167
  if (Array.isArray(value)) for (const item of value) collectSecretMarkerRefs(item, out);
6092
- else if (isRecord(value)) for (const child of Object.values(value)) collectSecretMarkerRefs(child, out);
6168
+ else if (isRecord$1(value)) for (const child of Object.values(value)) collectSecretMarkerRefs(child, out);
6093
6169
  return out;
6094
6170
  }
6095
6171
  async function storedValueEquals(secrets, marker, candidate) {
@@ -6144,7 +6220,7 @@ function rowId(row, idKey) {
6144
6220
  return null;
6145
6221
  }
6146
6222
  async function writeArray(ctx, node, incoming, stored, fieldPath) {
6147
- const storedRows = Array.isArray(stored) ? stored.filter(isRecord) : [];
6223
+ const storedRows = Array.isArray(stored) ? stored.filter(isRecord$1) : [];
6148
6224
  if (!Array.isArray(incoming)) {
6149
6225
  ctx.deletes.push(...collectSecretMarkerRefs(storedRows));
6150
6226
  return {
@@ -6160,7 +6236,7 @@ async function writeArray(ctx, node, incoming, stored, fieldPath) {
6160
6236
  const kept = /* @__PURE__ */ new Set();
6161
6237
  const rows = [];
6162
6238
  for (const row of incoming) {
6163
- if (!isRecord(row)) {
6239
+ if (!isRecord$1(row)) {
6164
6240
  rows.push(row);
6165
6241
  continue;
6166
6242
  }
@@ -6185,7 +6261,7 @@ async function writeNode(ctx, node, incoming, stored, fieldPath) {
6185
6261
  case "leaf": return writeLeaf(ctx, incoming, stored, fieldPath);
6186
6262
  case "array": return writeArray(ctx, node, incoming, stored, fieldPath);
6187
6263
  case "object": {
6188
- if (!isRecord(incoming)) {
6264
+ if (!isRecord$1(incoming)) {
6189
6265
  if (incoming === void 0) return KEEP;
6190
6266
  ctx.deletes.push(...collectSecretMarkerRefs(stored));
6191
6267
  return {
@@ -6193,7 +6269,7 @@ async function writeNode(ctx, node, incoming, stored, fieldPath) {
6193
6269
  value: incoming
6194
6270
  };
6195
6271
  }
6196
- const storedObj = isRecord(stored) ? stored : {};
6272
+ const storedObj = isRecord$1(stored) ? stored : {};
6197
6273
  return {
6198
6274
  kind: "value",
6199
6275
  value: await writeMembers(ctx, node.children, incoming, storedObj, (m) => `${fieldPath}.${m}`)
@@ -6252,12 +6328,19 @@ async function transformSecretWrite(input) {
6252
6328
  }
6253
6329
  };
6254
6330
  }
6331
+ /** Is `ref` one of `owner`'s refs? */
6332
+ function isSecretRefOwnedBy(ref, owner) {
6333
+ return parseSecretRef(ref)?.owner === owner;
6334
+ }
6255
6335
  /**
6256
6336
  * Replace every marker in `value` with its keychain value. Returns the SAME
6257
6337
  * reference when there is no marker (no allocation, no keychain call).
6258
6338
  */
6259
- async function resolveSecretMarkers(value, secrets) {
6260
- const refs = collectSecretMarkerRefs(value);
6339
+ async function resolveSecretMarkers(value, secrets, options = {}) {
6340
+ const keepMarker = options.unresolved === "keep-marker";
6341
+ const owner = options.ownedBy;
6342
+ const inScope = (ref) => owner === void 0 || isSecretRefOwnedBy(ref, owner);
6343
+ const refs = collectSecretMarkerRefs(value).filter(inScope);
6261
6344
  if (refs.length === 0) return {
6262
6345
  value,
6263
6346
  unresolved: []
@@ -6281,10 +6364,18 @@ async function resolveSecretMarkers(value, secrets) {
6281
6364
  }
6282
6365
  const substitute = (v) => {
6283
6366
  if (isSecretMarker(v)) {
6367
+ if (!inScope(v.$secret)) return {
6368
+ keep: true,
6369
+ value: v
6370
+ };
6284
6371
  const answer = answers[v.$secret];
6285
- return answer?.kind === "value" ? {
6372
+ if (answer?.kind === "value") return {
6286
6373
  keep: true,
6287
6374
  value: answer.value
6375
+ };
6376
+ return keepMarker ? {
6377
+ keep: true,
6378
+ value: v
6288
6379
  } : {
6289
6380
  keep: false,
6290
6381
  value: void 0
@@ -6301,7 +6392,7 @@ async function resolveSecretMarkers(value, secrets) {
6301
6392
  value: items
6302
6393
  };
6303
6394
  }
6304
- if (isRecord(v)) {
6395
+ if (isRecord$1(v)) {
6305
6396
  const out = {};
6306
6397
  for (const [k, child] of Object.entries(v)) {
6307
6398
  const s = substitute(child);
@@ -6322,14 +6413,152 @@ async function resolveSecretMarkers(value, secrets) {
6322
6413
  unresolved
6323
6414
  };
6324
6415
  }
6325
- function touchesTree(tree, patch) {
6326
- if (tree.size === 0) return false;
6327
- for (const key of Object.keys(patch)) {
6328
- const at = key.indexOf("@");
6329
- if (tree.has(at > 0 ? key.slice(0, at) : key)) return true;
6416
+ /** An addon tried to replace a stored secret it could not read. Nothing was written. */
6417
+ var SecretOverwriteRefusedError = class extends Error {
6418
+ ref;
6419
+ reason;
6420
+ constructor(ref, reason) {
6421
+ 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.`);
6422
+ this.ref = ref;
6423
+ this.reason = reason;
6424
+ this.name = "SecretOverwriteRefusedError";
6425
+ }
6426
+ };
6427
+ function isRecord(value) {
6428
+ return typeof value === "object" && value !== null && !Array.isArray(value);
6429
+ }
6430
+ function resolvedValue(pass, marker) {
6431
+ const answer = pass.answers[marker.$secret];
6432
+ return answer?.kind === "value" ? answer.value : null;
6433
+ }
6434
+ async function atMarker(pass, incoming, stored) {
6435
+ if (incoming === null) return stored;
6436
+ if (typeof incoming !== "string") return incoming;
6437
+ if (incoming === resolvedValue(pass, stored)) return stored;
6438
+ const intent = classifySecretWrite(incoming);
6439
+ if (intent.kind !== "set") return stored;
6440
+ const ref = stored.$secret;
6441
+ if (!isSecretRefOwnedBy(ref, pass.secrets.owner)) return incoming;
6442
+ const answer = pass.answers[ref];
6443
+ 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);
6444
+ try {
6445
+ await pass.secrets.put(ref, intent.value);
6446
+ } catch (err) {
6447
+ throw new KeychainWriteRefusedError(ref, err);
6448
+ }
6449
+ pass.changedRefs.push(ref);
6450
+ return stored;
6451
+ }
6452
+ function inArray(pass, incoming, stored) {
6453
+ return incoming.map((item, index) => {
6454
+ const twin = stored[index];
6455
+ if (isSecretMarker(twin)) return typeof item === "string" && item === resolvedValue(pass, twin) ? twin : item;
6456
+ if (isRecord(item) && isRecord(twin)) return inArrayRow(pass, item, twin);
6457
+ if (Array.isArray(item) && Array.isArray(twin)) return inArray(pass, item, twin);
6458
+ return item;
6459
+ });
6460
+ }
6461
+ function inArrayRow(pass, incoming, stored) {
6462
+ const out = { ...incoming };
6463
+ for (const [key, value] of Object.entries(incoming)) {
6464
+ const twin = stored[key];
6465
+ if (isSecretMarker(twin)) {
6466
+ if (typeof value === "string" && value === resolvedValue(pass, twin)) out[key] = twin;
6467
+ } else if (isRecord(value) && isRecord(twin)) out[key] = inArrayRow(pass, value, twin);
6468
+ else if (Array.isArray(value) && Array.isArray(twin)) out[key] = inArray(pass, value, twin);
6469
+ }
6470
+ return out;
6471
+ }
6472
+ async function walk(pass, incoming, stored) {
6473
+ if (isSecretMarker(stored)) return atMarker(pass, incoming, stored);
6474
+ if (Array.isArray(incoming) && Array.isArray(stored)) return inArray(pass, incoming, stored);
6475
+ if (!isRecord(incoming) || !isRecord(stored)) return incoming;
6476
+ const out = { ...incoming };
6477
+ for (const [key, value] of Object.entries(incoming)) out[key] = await walk(pass, value, stored[key]);
6478
+ return out;
6479
+ }
6480
+ /** Restore markers a write-back carries as values. See the file doc. */
6481
+ async function restoreUnchangedSecrets(input) {
6482
+ const refs = [];
6483
+ for (const key of Object.keys(input.patch)) collectSecretMarkerRefs(input.stored[key], refs);
6484
+ const owned = refs.filter((ref) => isSecretRefOwnedBy(ref, input.secrets.owner));
6485
+ if (owned.length === 0) return {
6486
+ patch: input.patch,
6487
+ changedRefs: []
6488
+ };
6489
+ const pass = {
6490
+ secrets: input.secrets,
6491
+ answers: await input.secrets.resolve([...new Set(owned)]),
6492
+ operatorWrite: input.operatorWrite,
6493
+ changedRefs: []
6494
+ };
6495
+ const out = {};
6496
+ for (const [key, value] of Object.entries(input.patch)) out[key] = await walk(pass, value, input.stored[key]);
6497
+ return {
6498
+ patch: out,
6499
+ changedRefs: pass.changedRefs
6500
+ };
6501
+ }
6502
+ /** Structural equality over JSON-shaped values (key order does not matter). */
6503
+ function isJsonEqual(a, b) {
6504
+ if (Object.is(a, b)) return true;
6505
+ if (Array.isArray(a)) return Array.isArray(b) && a.length === b.length && a.every((v, i) => isJsonEqual(v, b[i]));
6506
+ if (isRecord(a) && isRecord(b)) {
6507
+ const keys = Object.keys(a);
6508
+ if (keys.length !== Object.keys(b).length) return false;
6509
+ return keys.every((k) => Object.prototype.hasOwnProperty.call(b, k) && isJsonEqual(a[k], b[k]));
6330
6510
  }
6331
6511
  return false;
6332
6512
  }
6513
+ /** The patch without the keys whose value already equals the stored one. */
6514
+ function dropUnchangedKeys(patch, stored) {
6515
+ const out = {};
6516
+ for (const [key, value] of Object.entries(patch)) {
6517
+ if (Object.prototype.hasOwnProperty.call(stored, key) && isJsonEqual(value, stored[key])) continue;
6518
+ out[key] = value;
6519
+ }
6520
+ return out;
6521
+ }
6522
+ /** The top-level keys of a blob that hold at least one of `owner`'s markers. */
6523
+ function markerKeysOf(blob, owner) {
6524
+ const keys = /* @__PURE__ */ new Set();
6525
+ for (const [key, value] of Object.entries(blob)) if (collectSecretMarkerRefs(value).some((ref) => isSecretRefOwnedBy(ref, owner))) keys.add(key);
6526
+ return keys;
6527
+ }
6528
+ function nodeFromStored(value, owner) {
6529
+ if (isSecretMarker(value)) return isSecretRefOwnedBy(value.$secret, owner) ? { kind: "leaf" } : null;
6530
+ if (!isRecord(value)) return null;
6531
+ const children = /* @__PURE__ */ new Map();
6532
+ for (const [key, child] of Object.entries(value)) {
6533
+ const node = nodeFromStored(child, owner);
6534
+ if (node !== null) children.set(key, node);
6535
+ }
6536
+ return children.size > 0 ? {
6537
+ kind: "object",
6538
+ children
6539
+ } : null;
6540
+ }
6541
+ /**
6542
+ * The declared secret tree, widened by every place the STORED blob holds a
6543
+ * marker under one of `keys` — so a marker the schema no longer declares (or
6544
+ * never declared: Wyze before b4906cec6) still gets the save path's
6545
+ * KEEP / SET / CLEAR semantics instead of being overwritten by whatever the
6546
+ * addon writes. Markers inside arrays are not added: a row has no id field to
6547
+ * match by unless the schema declares one. Only `owner`'s markers count: a
6548
+ * builtin that keeps another addon's marker (device-manager) never takes it
6549
+ * over.
6550
+ */
6551
+ function widenTreeWithStoredMarkers(declared, stored, keys, owner) {
6552
+ const added = /* @__PURE__ */ new Map();
6553
+ for (const key of keys) {
6554
+ const at = key.indexOf("@");
6555
+ const base = at > 0 ? key.slice(0, at) : key;
6556
+ if (declared.has(base) || added.has(base)) continue;
6557
+ const node = nodeFromStored(stored[key], owner);
6558
+ if (node !== null) added.set(base, node);
6559
+ }
6560
+ return added.size === 0 ? declared : new Map([...declared, ...added]);
6561
+ }
6333
6562
  /** The blob as stored now; a failed read REFUSES the write instead of guessing. */
6334
6563
  async function readStoredAddonBlob(raw) {
6335
6564
  const threeWay = raw.readAddonStoreResult;
@@ -6338,7 +6567,41 @@ async function readStoredAddonBlob(raw) {
6338
6567
  if (result.kind === "failed") throw new Error(`settings write refused: the stored blob could not be read (${result.error})`);
6339
6568
  return result.kind === "missing" ? {} : result.value;
6340
6569
  }
6341
- function createSecretAwareSettings(raw, opts) {
6570
+ function touchesTree(tree, patch) {
6571
+ if (tree.size === 0) return false;
6572
+ for (const key of Object.keys(patch)) {
6573
+ const at = key.indexOf("@");
6574
+ if (tree.has(at > 0 ? key.slice(0, at) : key)) return true;
6575
+ }
6576
+ return false;
6577
+ }
6578
+ /**
6579
+ * Which top-level keys of each store held markers when last seen. `undefined`
6580
+ * for a store not seen yet: its first write reads it, to be safe.
6581
+ */
6582
+ var MarkerKeyIndex = class {
6583
+ owner;
6584
+ byStore = /* @__PURE__ */ new Map();
6585
+ constructor(owner) {
6586
+ this.owner = owner;
6587
+ }
6588
+ seen(store, blob) {
6589
+ this.byStore.set(store, markerKeysOf(blob, this.owner));
6590
+ }
6591
+ wrote(store, patch) {
6592
+ const keys = this.byStore.get(store);
6593
+ if (keys === void 0) return;
6594
+ const now = markerKeysOf(patch, this.owner);
6595
+ for (const key of Object.keys(patch)) if (now.has(key)) keys.add(key);
6596
+ else keys.delete(key);
6597
+ }
6598
+ mayHoldMarkers(store, patch) {
6599
+ const keys = this.byStore.get(store);
6600
+ if (keys === void 0) return true;
6601
+ return Object.keys(patch).some((key) => keys.has(key));
6602
+ }
6603
+ };
6604
+ function createHandle(raw, opts) {
6342
6605
  const chains = /* @__PURE__ */ new Map();
6343
6606
  const serialize = (key, fn) => {
6344
6607
  const next = (chains.get(key) ?? Promise.resolve()).then(fn, fn);
@@ -6349,46 +6612,130 @@ function createSecretAwareSettings(raw, opts) {
6349
6612
  });
6350
6613
  return next;
6351
6614
  };
6352
- const write = async (chainKey, tree, scope, patch, readStored, rawWrite) => {
6353
- if (!touchesTree(tree, patch)) return rawWrite(patch);
6354
- return serialize(chainKey, async () => {
6615
+ const index = new MarkerKeyIndex(opts.secrets.owner);
6616
+ const resolveRead = async (store, blob) => {
6617
+ index.seen(store, blob);
6618
+ const { value, unresolved } = await resolveSecretMarkers(blob, opts.secrets, {
6619
+ unresolved: "keep-marker",
6620
+ ownedBy: opts.secrets.owner
6621
+ });
6622
+ if (unresolved.length > 0) opts.onUnresolved?.(unresolved);
6623
+ return value;
6624
+ };
6625
+ const write = async (store, declared, scope, patch, readStored, rawWrite) => {
6626
+ if (!touchesTree(declared, patch) && !index.mayHoldMarkers(store, patch)) {
6627
+ await rawWrite(patch);
6628
+ index.wrote(store, patch);
6629
+ return { changed: true };
6630
+ }
6631
+ return serialize(store, async () => {
6355
6632
  const stored = await readStored();
6633
+ index.seen(store, stored);
6634
+ const operatorWrite = opts.isOperatorWrite?.() === true;
6635
+ const restored = await restoreUnchangedSecrets({
6636
+ patch,
6637
+ stored,
6638
+ secrets: opts.secrets,
6639
+ operatorWrite
6640
+ });
6356
6641
  const result = await transformSecretWrite({
6357
- tree,
6642
+ tree: widenTreeWithStoredMarkers(declared, stored, Object.keys(restored.patch), opts.secrets.owner),
6358
6643
  secrets: opts.secrets,
6359
- patch,
6644
+ patch: restored.patch,
6360
6645
  stored,
6361
6646
  ...scope !== void 0 ? { scope } : {},
6362
- operatorWrite: opts.isOperatorWrite?.() === true
6647
+ operatorWrite
6363
6648
  });
6364
- if (Object.keys(result.patch).length > 0) await rawWrite(result.patch);
6649
+ const effective = dropUnchangedKeys(result.patch, stored);
6650
+ const wroteBlob = Object.keys(effective).length > 0;
6651
+ if (wroteBlob) {
6652
+ await rawWrite(effective);
6653
+ index.wrote(store, effective);
6654
+ }
6365
6655
  const { orphaned } = await result.afterWrite();
6366
6656
  if (orphaned.length > 0) opts.onOrphaned(orphaned);
6657
+ return { changed: wroteBlob || restored.changedRefs.length > 0 };
6367
6658
  });
6368
6659
  };
6369
- const wrapped = {
6370
- writeAddonStore: (patch) => write("addon", opts.addonTree(), void 0, patch, () => readStoredAddonBlob(raw), (p) => raw.writeAddonStore(p)),
6371
- writeDeviceStore: (deviceId, patch) => write(`device:${deviceId}`, opts.deviceTree(), {
6372
- kind: "device",
6373
- deviceId
6374
- }, patch, () => raw.readDeviceStore(deviceId), (p) => raw.writeDeviceStore(deviceId, p))
6660
+ const writeAddon = (patch) => write("addon", opts.addonTree(), void 0, patch, () => readStoredAddonBlob(raw), (p) => raw.writeAddonStore(p));
6661
+ const readAddonStoreResult = raw.readAddonStoreResult;
6662
+ const readAddonStoreKeyResult = raw.readAddonStoreKeyResult;
6663
+ const readDeviceStoreBatch = raw.readDeviceStoreBatch;
6664
+ const overrides = {
6665
+ readAddonStore: async () => resolveRead("addon", await raw.readAddonStore()),
6666
+ ...readAddonStoreResult !== void 0 ? { readAddonStoreResult: async () => {
6667
+ const result = await readAddonStoreResult.call(raw);
6668
+ return result.kind === "value" ? {
6669
+ kind: "value",
6670
+ value: await resolveRead("addon", result.value)
6671
+ } : result;
6672
+ } } : {},
6673
+ ...readAddonStoreKeyResult !== void 0 ? { readAddonStoreKeyResult: async (key) => {
6674
+ const result = await readAddonStoreKeyResult.call(raw, key);
6675
+ if (result.kind !== "present") return result;
6676
+ const { value, unresolved } = await resolveSecretMarkers({ [key]: result.value }, opts.secrets, {
6677
+ unresolved: "keep-marker",
6678
+ ownedBy: opts.secrets.owner
6679
+ });
6680
+ if (unresolved.length > 0) opts.onUnresolved?.(unresolved);
6681
+ return {
6682
+ kind: "present",
6683
+ value: value[key]
6684
+ };
6685
+ } } : {},
6686
+ readDeviceStore: async (deviceId) => resolveRead(`device:${deviceId}`, await raw.readDeviceStore(deviceId)),
6687
+ ...readDeviceStoreBatch !== void 0 ? { readDeviceStoreBatch: async (deviceIds) => {
6688
+ const rows = await readDeviceStoreBatch.call(raw, deviceIds);
6689
+ const out = /* @__PURE__ */ new Map();
6690
+ for (const [deviceId, blob] of rows) out.set(deviceId, await resolveRead(`device:${deviceId}`, blob));
6691
+ return out;
6692
+ } } : {},
6693
+ writeAddonStore: async (patch) => {
6694
+ await writeAddon(patch);
6695
+ },
6696
+ writeDeviceStore: async (deviceId, patch) => {
6697
+ await write(`device:${deviceId}`, opts.deviceTree(), {
6698
+ kind: "device",
6699
+ deviceId
6700
+ }, patch, () => raw.readDeviceStore(deviceId), (p) => raw.writeDeviceStore(deviceId, p));
6701
+ }
6702
+ };
6703
+ return {
6704
+ settings: new Proxy(raw, { get(target, prop, receiver) {
6705
+ if (typeof prop === "string" && Object.prototype.hasOwnProperty.call(overrides, prop)) return Reflect.get(overrides, prop);
6706
+ const value = Reflect.get(target, prop, receiver);
6707
+ return typeof value === "function" ? value.bind(target) : value;
6708
+ } }),
6709
+ raw: {
6710
+ readAddonStore: async () => {
6711
+ const blob = await raw.readAddonStore();
6712
+ index.seen("addon", blob);
6713
+ return blob;
6714
+ },
6715
+ readDeviceStore: async (deviceId) => {
6716
+ const blob = await raw.readDeviceStore(deviceId);
6717
+ index.seen(`device:${deviceId}`, blob);
6718
+ return blob;
6719
+ }
6720
+ },
6721
+ writeAddonStore: writeAddon
6375
6722
  };
6376
- return new Proxy(raw, { get(target, prop, receiver) {
6377
- if (prop === "writeAddonStore") return wrapped.writeAddonStore;
6378
- if (prop === "writeDeviceStore") return wrapped.writeDeviceStore;
6379
- const value = Reflect.get(target, prop, receiver);
6380
- return typeof value === "function" ? value.bind(target) : value;
6381
- } });
6382
6723
  }
6383
- /** The context the addon sees: identical, except that its settings writes are secret-aware. */
6384
- function withSecretAwareSettings(context, opts) {
6724
+ /** The context the addon sees, plus the private raw view and write outcome. */
6725
+ function createSecretAwareContext(context, opts) {
6385
6726
  const raw = context.settings;
6386
- if (raw === void 0) return context;
6387
- const settings = createSecretAwareSettings(raw, opts);
6388
- return new Proxy(context, { get(target, prop, receiver) {
6389
- if (prop === "settings") return settings;
6390
- return Reflect.get(target, prop, receiver);
6391
- } });
6727
+ if (raw === void 0) return {
6728
+ context,
6729
+ handle: null
6730
+ };
6731
+ const handle = createHandle(raw, opts);
6732
+ return {
6733
+ context: new Proxy(context, { get(target, prop, receiver) {
6734
+ if (prop === "settings") return handle.settings;
6735
+ return Reflect.get(target, prop, receiver);
6736
+ } }),
6737
+ handle
6738
+ };
6392
6739
  }
6393
6740
  var LEAF = { kind: "leaf" };
6394
6741
  var DEFAULT_ITEM_ID_KEY = "id";
@@ -6563,6 +6910,14 @@ var BaseAddon = class {
6563
6910
  _secretChangeUnsub = null;
6564
6911
  /** >0 while an OPERATOR's settings write is being applied. */
6565
6912
  _operatorWriteDepth = 0;
6913
+ /**
6914
+ * The keychain-aware settings handle (D798). Its `raw` view is the ONLY way
6915
+ * to the marker-bearing blobs and stays private to this class: the form
6916
+ * hydrate and config resolution need markers, addon code never does.
6917
+ */
6918
+ _secretSettings = null;
6919
+ /** Refs an addon-facing read could not resolve — each is logged once per process. */
6920
+ _loggedUnresolvedReads = /* @__PURE__ */ new Set();
6566
6921
  constructor(defaults) {
6567
6922
  this.defaults = defaults;
6568
6923
  this._config = { ...defaults };
@@ -6599,13 +6954,21 @@ var BaseAddon = class {
6599
6954
  }
6600
6955
  async initialize(context) {
6601
6956
  const secrets = context.secrets;
6602
- this._ctx = secrets !== void 0 ? withSecretAwareSettings(context, {
6603
- secrets,
6604
- addonTree: () => this.addonSecretTree(),
6605
- deviceTree: () => this.deviceSecretTree(),
6606
- onOrphaned: (refs) => context.logger.warn("keychain refs dropped by a settings write could not be deleted", { meta: { refs: [...refs] } }),
6607
- isOperatorWrite: () => this._operatorWriteDepth > 0
6608
- }) : context;
6957
+ if (secrets !== void 0) {
6958
+ const { context: wrapped, handle } = createSecretAwareContext(context, {
6959
+ secrets,
6960
+ addonTree: () => this.addonSecretTree(),
6961
+ deviceTree: () => this.deviceSecretTree(),
6962
+ onOrphaned: (refs) => context.logger.warn("keychain refs dropped by a settings write could not be deleted", { meta: { refs: [...refs] } }),
6963
+ isOperatorWrite: () => this._operatorWriteDepth > 0,
6964
+ onUnresolved: (unresolved) => this.logUnresolvedRead(unresolved)
6965
+ });
6966
+ this._ctx = wrapped;
6967
+ this._secretSettings = handle;
6968
+ } else {
6969
+ this._ctx = context;
6970
+ this._secretSettings = null;
6971
+ }
6609
6972
  await this.resolveConfig();
6610
6973
  if (secrets !== void 0) this._secretChangeUnsub = secrets.onChange((ref) => {
6611
6974
  if (this._configSecretRefs.has(ref)) this.scheduleSecretReresolve(SECRET_CHANGE_DEBOUNCE_MS);
@@ -6722,11 +7085,8 @@ var BaseAddon = class {
6722
7085
  async getGlobalSettings(overlay, cap, nodeId) {
6723
7086
  const schema = this.globalSettingsSchema(cap);
6724
7087
  if (!schema) return { sections: [] };
6725
- const projected = await this.resolveGlobalStore(nodeId, cap);
6726
- return hydrateSchema(schema, overlay ? {
6727
- ...projected,
6728
- ...overlay
6729
- } : projected, { inlineSecretsAsViews: true });
7088
+ const projected = await this.readRawProjectedStore(nodeId, cap);
7089
+ return hydrateSchema(schema, overlay ? await this.overlayKeepingMarkers(projected, overlay) : projected, { inlineSecretsAsViews: true });
6730
7090
  }
6731
7091
  /**
6732
7092
  * The integration-level view of this addon's settings: exactly the sections
@@ -6771,7 +7131,7 @@ var BaseAddon = class {
6771
7131
  });
6772
7132
  }
6773
7133
  if (sections.length === 0) return null;
6774
- const projected = await this.resolveGlobalStore(nodeId);
7134
+ const projected = await this.readRawProjectedStore(nodeId);
6775
7135
  return hydrateSchema({
6776
7136
  ...schema,
6777
7137
  sections
@@ -6788,12 +7148,50 @@ var BaseAddon = class {
6788
7148
  * the store for custom option logic (option narrowing, value snapping) to
6789
7149
  * read it per-node — never `ctx.settings.readAddonStore()` directly.
6790
7150
  * `nodeId` omitted ⇒ the local node (node-blind injection from ctx).
7151
+ *
7152
+ * Keychain values come back RESOLVED (D798): a secret reads as its value,
7153
+ * never as a `{ $secret }` marker. One the keychain cannot serve right now
7154
+ * stays a marker — "stored, unavailable" (`isSecretMarker()` is true, and it
7155
+ * is listed in {@link unresolvedSecrets}) — never `''` and never absent, so
7156
+ * it cannot be mistaken for "nothing stored, mint a new one". Writing the
7157
+ * resolved blob back is a no-op for every unchanged secret.
6791
7158
  */
6792
7159
  async resolveGlobalStore(nodeId, cap) {
6793
7160
  const raw = await this._ctx?.settings?.readAddonStore() ?? {};
7161
+ return this.projectForNode(raw, nodeId, cap);
7162
+ }
7163
+ projectForNode(store, nodeId, cap) {
6794
7164
  const keys = this.perNodeKeys(cap);
6795
7165
  const node = normalizeNodeId(nodeId ?? this._ctx?.kernel?.localNodeId);
6796
- return keys.size > 0 ? projectStore(raw, keys, node) : raw;
7166
+ return keys.size > 0 ? projectStore(store, keys, node) : store;
7167
+ }
7168
+ /** The PROJECTED store with its markers — the form hydrate only (D798). */
7169
+ async readRawProjectedStore(nodeId, cap) {
7170
+ const raw = await this.rawSettings()?.readAddonStore() ?? {};
7171
+ return this.projectForNode(raw, nodeId, cap);
7172
+ }
7173
+ /**
7174
+ * `{ ...stored, ...overlay }`, except that an overlay member equal to the
7175
+ * RESOLVED stored one keeps the stored (marker-bearing) member — so a form
7176
+ * hydrated from a resolved overlay still shows a secret as "set", never as
7177
+ * its value.
7178
+ */
7179
+ async overlayKeepingMarkers(stored, overlay) {
7180
+ const secrets = this._ctx?.secrets;
7181
+ const merged = {
7182
+ ...stored,
7183
+ ...overlay
7184
+ };
7185
+ if (secrets === void 0 || collectSecretMarkerRefs(stored).length === 0) return merged;
7186
+ const { value: resolved } = await resolveSecretMarkers(stored, secrets, {
7187
+ unresolved: "keep-marker",
7188
+ ownedBy: secrets.owner
7189
+ });
7190
+ for (const key of Object.keys(overlay)) {
7191
+ if (collectSecretMarkerRefs(stored[key]).length === 0) continue;
7192
+ if (isJsonEqual(overlay[key], resolved[key])) merged[key] = stored[key];
7193
+ }
7194
+ return merged;
6797
7195
  }
6798
7196
  /**
6799
7197
  * Whether ONE global key of this addon's store was written, read three-way
@@ -6858,8 +7256,12 @@ var BaseAddon = class {
6858
7256
  async clearSecrets(keys, nodeId) {
6859
7257
  const tree = this.addonSecretTree();
6860
7258
  const keychain = this._ctx?.secrets !== void 0;
7259
+ const stored = keychain ? await this.readAddonStoreWithRetry() : {};
6861
7260
  const patch = {};
6862
- for (const key of keys) patch[key] = keychain && tree.has(key) ? SECRET_CLEAR : "";
7261
+ for (const key of keys) {
7262
+ const keychainStored = tree.has(key) || collectSecretMarkerRefs(stored[key]).length > 0;
7263
+ patch[key] = keychain && keychainStored ? SECRET_CLEAR : "";
7264
+ }
6863
7265
  await this.applyGlobalPatch(patch, nodeId);
6864
7266
  }
6865
7267
  async applyGlobalPatch(barePatch, nodeId) {
@@ -6867,7 +7269,11 @@ var BaseAddon = class {
6867
7269
  const localNode = normalizeNodeId(this._ctx?.kernel?.localNodeId);
6868
7270
  const target = normalizeNodeId(nodeId ?? this._ctx?.kernel?.localNodeId);
6869
7271
  const scoped = keys.size > 0 ? scopePatch(barePatch, keys, target) : barePatch;
6870
- await this._ctx?.settings?.writeAddonStore(scoped);
7272
+ const handle = this._secretSettings;
7273
+ if (handle !== null) {
7274
+ const { changed } = await handle.writeAddonStore(scoped);
7275
+ if (!changed) return;
7276
+ } else await this._ctx?.settings?.writeAddonStore(scoped);
6871
7277
  if (target !== localNode) return;
6872
7278
  await this.resolveConfig();
6873
7279
  await this.onConfigChanged();
@@ -6920,7 +7326,7 @@ var BaseAddon = class {
6920
7326
  async getDeviceSettings(deviceId) {
6921
7327
  const schema = this.deviceSettingsSchema();
6922
7328
  if (!schema) return { sections: [] };
6923
- return hydrateSchema(schema, await this._ctx?.settings?.readDeviceStore(deviceId) ?? {}, { inlineSecretsAsViews: true });
7329
+ return hydrateSchema(schema, await this.rawSettings()?.readDeviceStore(deviceId) ?? {}, { inlineSecretsAsViews: true });
6924
7330
  }
6925
7331
  async updateDeviceSettings(deviceId, patch) {
6926
7332
  await this._ctx?.settings?.writeDeviceStore(deviceId, patch);
@@ -7092,7 +7498,7 @@ var BaseAddon = class {
7092
7498
  key,
7093
7499
  schema,
7094
7500
  fallback,
7095
- read: async () => this.resolveStoredSecrets(await this._ctx?.settings?.readDeviceStore(deviceId) ?? {}, false),
7501
+ read: async () => this.resolveStoredSecrets(await this.rawSettings()?.readDeviceStore(deviceId) ?? {}, false),
7096
7502
  write: async (patch) => {
7097
7503
  await this._ctx?.settings?.writeDeviceStore(deviceId, patch);
7098
7504
  },
@@ -7154,6 +7560,23 @@ var BaseAddon = class {
7154
7560
  }
7155
7561
  return value;
7156
7562
  }
7563
+ /**
7564
+ * The marker-bearing settings reads (D798) — private on purpose. Without a
7565
+ * keychain the context's own view is already raw.
7566
+ */
7567
+ rawSettings() {
7568
+ return this._secretSettings?.raw ?? this._ctx?.settings;
7569
+ }
7570
+ /** An addon-facing read met markers it could not resolve: say so once per ref. */
7571
+ logUnresolvedRead(unresolved) {
7572
+ const fresh = unresolved.filter((u) => !this._loggedUnresolvedReads.has(u.ref));
7573
+ if (fresh.length === 0) return;
7574
+ for (const u of fresh) this._loggedUnresolvedReads.add(u.ref);
7575
+ 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) => ({
7576
+ ref: u.ref,
7577
+ reason: u.reason
7578
+ })) } });
7579
+ }
7157
7580
  /** Re-resolve the config (a keychain-only change, or a retry) and apply it. */
7158
7581
  scheduleSecretReresolve(delayMs) {
7159
7582
  const timerOf = delayMs === SECRET_CHANGE_DEBOUNCE_MS ? "_secretChangeTimer" : "_secretRetryTimer";
@@ -7180,7 +7603,7 @@ var BaseAddon = class {
7180
7603
  * `{}` (defaults) — the addon's first successful patch will rehydrate.
7181
7604
  */
7182
7605
  async readAddonStoreWithRetry() {
7183
- const settings = this._ctx?.settings;
7606
+ const settings = this.rawSettings();
7184
7607
  if (!settings) return {};
7185
7608
  const delaysMs = [
7186
7609
  150,
@@ -9503,6 +9926,278 @@ var CameraSwitchGroupSchema = object({
9503
9926
  fetchedAt: number()
9504
9927
  });
9505
9928
  /**
9929
+ * The trainer contract — what the hub hands the cloud trainer and what it
9930
+ * gets back (cloud training, D805+).
9931
+ *
9932
+ * The trainer (`hf/camstack-trainer`, published as the Hugging Face repo
9933
+ * `camstack/camstack-trainer`) is a separate AGPL program the hub never
9934
+ * imports: `job.json` goes in, files come out, and progress is `CAMSTACK_EVENT`
9935
+ * lines on stdout. These schemas are the hub's half of that boundary; the
9936
+ * trainer's pydantic models (and the JSON Schemas generated from them under
9937
+ * `hf/camstack-trainer/schemas/`) are the other half. A change here is a
9938
+ * change there, in the same piece of work.
9939
+ *
9940
+ * No `.default()` anywhere: defaults do not run on the addon cap path, so the
9941
+ * orchestrator fills every field of a job spec explicitly.
9942
+ */
9943
+ var TRAINING_JOB_SCHEMA = "camstack.training/v1";
9944
+ var TRAINING_RESULT_SCHEMA = "camstack.training-result/v1";
9945
+ /** What the trainer can export. Edge TPU is a later, separate image. */
9946
+ var TrainingExportSchema = _enum([
9947
+ "onnx",
9948
+ "openvino-fp16",
9949
+ "openvino-int8",
9950
+ "coreml-fp16"
9951
+ ]);
9952
+ var FloorsSchema = record(string(), number().min(0).max(1));
9953
+ object({
9954
+ schema: literal(TRAINING_JOB_SCHEMA),
9955
+ jobKey: string().uuid(),
9956
+ target: object({
9957
+ kind: literal("detector"),
9958
+ step: literal("object-detection")
9959
+ }),
9960
+ base: object({
9961
+ modelId: string().min(1),
9962
+ /** Ultralytics weights id, e.g. `yolov9m.pt`. */
9963
+ weights: string().min(1),
9964
+ imgsz: number().int().positive()
9965
+ }),
9966
+ baseline: object({
9967
+ modelId: string().min(1),
9968
+ /** The baseline ONNX the holdout comparison runs; public mirror URL. */
9969
+ onnxUrl: string().url(),
9970
+ imgsz: number().int().positive(),
9971
+ floors: FloorsSchema
9972
+ }),
9973
+ dataset: object({
9974
+ versionId: string().min(1),
9975
+ annotationHash: string(),
9976
+ /** sha256 of the uploaded archive; the trainer refuses a mismatch (exit 65). */
9977
+ sha256: string().regex(/^[0-9a-f]{64}$/)
9978
+ }),
9979
+ split: object({
9980
+ holdoutCameras: array(number().int()),
9981
+ /** When no camera is held out: the last N days of every camera. */
9982
+ holdoutLastDays: number().int().nonnegative(),
9983
+ valFraction: number().min(0).max(.5),
9984
+ seed: number().int()
9985
+ }),
9986
+ hyper: object({
9987
+ epochs: number().int().positive(),
9988
+ batch: number().int().positive(),
9989
+ lr0: number().positive(),
9990
+ /** Layers frozen from the start of the backbone; 0 = none. */
9991
+ freeze: number().int().nonnegative(),
9992
+ patience: number().int().nonnegative(),
9993
+ seed: number().int()
9994
+ }),
9995
+ replay: object({
9996
+ source: literal("coco2017"),
9997
+ count: number().int().nonnegative()
9998
+ }),
9999
+ exports: array(TrainingExportSchema).min(1),
10000
+ calibration: object({ maxFrames: number().int().positive() }),
10001
+ floors: object({
10002
+ minSupport: number().int().positive(),
10003
+ clamp: number().min(0).max(1)
10004
+ }),
10005
+ int8Gate: object({ maxMap50Drop: number().min(0).max(1) }),
10006
+ catalog: object({
10007
+ id: string().regex(/^[a-z0-9][a-z0-9-]{2,80}$/),
10008
+ name: string().min(1).max(160)
10009
+ })
10010
+ });
10011
+ /** One regular file of the bundle. An mlpackage contributes one row per member. */
10012
+ var TrainingResultFileSchema = object({
10013
+ path: string().min(1),
10014
+ bytes: number().int().nonnegative(),
10015
+ sha256: string().regex(/^[0-9a-f]{64}$/),
10016
+ format: _enum([
10017
+ "onnx",
10018
+ "openvino",
10019
+ "coreml",
10020
+ "pt"
10021
+ ]),
10022
+ variant: _enum(["base", "int8"])
10023
+ });
10024
+ var DraftFormatSchema = object({
10025
+ /** RELATIVE path inside the bundle; the hub rewrites it to `camstack-local://`. */
10026
+ url: string().min(1),
10027
+ sizeMB: number().nonnegative(),
10028
+ isDirectory: boolean().optional(),
10029
+ files: array(string()).optional(),
10030
+ runtimes: array(literal("python")).optional(),
10031
+ revision: string().min(1)
10032
+ });
10033
+ /** The trainer's half of a catalog entry; the hub completes it (labels, licence, group). */
10034
+ var TrainingCatalogDraftSchema = object({
10035
+ id: string().min(1),
10036
+ name: string().min(1),
10037
+ description: string(),
10038
+ labels: array(unknown()),
10039
+ inputSize: object({
10040
+ width: number().int().positive(),
10041
+ height: number().int().positive()
10042
+ }),
10043
+ preprocessMode: literal("letterbox"),
10044
+ defaultClassFloors: FloorsSchema,
10045
+ formats: object({
10046
+ onnx: DraftFormatSchema.optional(),
10047
+ openvino: DraftFormatSchema.optional(),
10048
+ coreml: DraftFormatSchema.optional()
10049
+ })
10050
+ });
10051
+ /** One class of one model's holdout report (the eval harness's summary). */
10052
+ var TrainingEvalClassSchema = object({
10053
+ positives: number().int(),
10054
+ floor: number().nullable(),
10055
+ tp: number().int(),
10056
+ fp: number().int(),
10057
+ fn: number().int(),
10058
+ precision: number().nullable(),
10059
+ recall: number().nullable(),
10060
+ ap50: number().nullable(),
10061
+ recallByCamera: record(string(), number().nullable()).optional(),
10062
+ recallByLight: record(string(), number().nullable()).optional(),
10063
+ fpByCamera: record(string(), number()).optional(),
10064
+ smallFound: number().int().optional(),
10065
+ smallTotal: number().int().optional()
10066
+ }).passthrough();
10067
+ var TrainingEvalReportSchema = object({
10068
+ frames: number().int(),
10069
+ classes: record(string(), TrainingEvalClassSchema)
10070
+ }).passthrough();
10071
+ /**
10072
+ * A succeeded result carries every block; a failed one carries the error and
10073
+ * whatever was known by then — the other blocks are ABSENT, not null. The
10074
+ * orchestrator checks the blocks it needs before it trusts a success.
10075
+ */
10076
+ var TrainingResultSchema = object({
10077
+ schema: literal(TRAINING_RESULT_SCHEMA),
10078
+ jobKey: string(),
10079
+ status: _enum(["succeeded", "failed"]),
10080
+ error: object({
10081
+ stage: string(),
10082
+ code: string(),
10083
+ message: string()
10084
+ }).nullable(),
10085
+ trainer: object({
10086
+ version: string(),
10087
+ revision: string()
10088
+ }),
10089
+ toolchain: record(string(), string().nullable()),
10090
+ dataset: object({
10091
+ versionId: string(),
10092
+ annotationHash: string(),
10093
+ sha256: string(),
10094
+ frames: object({
10095
+ train: number().int(),
10096
+ val: number().int(),
10097
+ holdout: number().int()
10098
+ }),
10099
+ holdoutCameras: array(number().int()),
10100
+ replayImages: number().int()
10101
+ }).optional(),
10102
+ training: object({
10103
+ epochsRun: number().int(),
10104
+ bestEpoch: number().int(),
10105
+ bestMap50: number(),
10106
+ bestMap50_95: number(),
10107
+ seconds: number()
10108
+ }).optional(),
10109
+ evaluation: object({
10110
+ holdoutFrames: number().int(),
10111
+ baseline: TrainingEvalReportSchema.nullable(),
10112
+ candidate: TrainingEvalReportSchema.nullable(),
10113
+ candidateInt8: TrainingEvalReportSchema.nullable(),
10114
+ recallDeltaByCamera: record(string(), record(string(), number())).nullable(),
10115
+ map50: record(string(), number().nullable())
10116
+ }).optional(),
10117
+ floors: object({
10118
+ baseline: FloorsSchema,
10119
+ candidate: FloorsSchema,
10120
+ candidateInt8: FloorsSchema.nullable(),
10121
+ notes: array(string())
10122
+ }).optional(),
10123
+ int8: object({
10124
+ kept: boolean(),
10125
+ map50Fp16: number().nullable(),
10126
+ map50Int8: number().nullable(),
10127
+ reason: string().nullable()
10128
+ }).optional(),
10129
+ exportsDropped: array(object({
10130
+ export: string(),
10131
+ reason: string()
10132
+ })).optional(),
10133
+ files: array(TrainingResultFileSchema).optional(),
10134
+ bundle: object({
10135
+ path: literal("bundle.tar"),
10136
+ bytes: number().int().nonnegative(),
10137
+ sha256: string().regex(/^[0-9a-f]{64}$/)
10138
+ }).nullable().optional(),
10139
+ catalogDraft: object({
10140
+ base: TrainingCatalogDraftSchema,
10141
+ int8: TrainingCatalogDraftSchema.nullable()
10142
+ }).nullable().optional(),
10143
+ licence: string()
10144
+ });
10145
+ var TrainingStageSchema = _enum([
10146
+ "prepare",
10147
+ "replay",
10148
+ "train",
10149
+ "eval",
10150
+ "export",
10151
+ "package"
10152
+ ]);
10153
+ var EventBase = {
10154
+ v: literal(1),
10155
+ ts: number()
10156
+ };
10157
+ discriminatedUnion("type", [
10158
+ object({
10159
+ ...EventBase,
10160
+ type: literal("stage"),
10161
+ stage: TrainingStageSchema
10162
+ }),
10163
+ object({
10164
+ ...EventBase,
10165
+ type: literal("epoch"),
10166
+ epoch: number().int(),
10167
+ epochs: number().int(),
10168
+ boxLoss: number().nullable().optional(),
10169
+ map50: number().nullable().optional(),
10170
+ map50_95: number().nullable().optional(),
10171
+ etaSec: number().nullable().optional()
10172
+ }),
10173
+ object({
10174
+ ...EventBase,
10175
+ type: literal("metric"),
10176
+ name: string(),
10177
+ value: number()
10178
+ }),
10179
+ object({
10180
+ ...EventBase,
10181
+ type: literal("artifact"),
10182
+ path: string(),
10183
+ bytes: number(),
10184
+ sha256: string()
10185
+ }),
10186
+ object({
10187
+ ...EventBase,
10188
+ type: literal("done"),
10189
+ status: _enum(["succeeded", "failed"]),
10190
+ resultSha256: string().nullable().optional()
10191
+ }),
10192
+ object({
10193
+ ...EventBase,
10194
+ type: literal("error"),
10195
+ stage: string(),
10196
+ code: string(),
10197
+ message: string()
10198
+ })
10199
+ ]);
10200
+ /**
9506
10201
  * What the gate decided about a birth, from the CALLER's point of view.
9507
10202
  *
9508
10203
  * Deliberately not `ConfirmationVerdict`: `undecided` is not a birth decision
@@ -11830,7 +12525,9 @@ var AddonHttpRouteSchema = object({
11830
12525
  "authenticated",
11831
12526
  "admin"
11832
12527
  ]).optional(),
11833
- description: string().optional()
12528
+ description: string().optional(),
12529
+ /** The hub limits this route per client address before the handler runs. */
12530
+ rateLimit: _enum(["auth"]).optional()
11834
12531
  });
11835
12532
  /**
11836
12533
  * Cross-process route invocation envelope. The hub captures the
@@ -12535,6 +13232,37 @@ var BackupDestinationInfoSchema = object({
12535
13232
  lastError: string().optional()
12536
13233
  });
12537
13234
  /**
13235
+ * How an archive is encrypted (operator decision 2026-10-09): to a backup
13236
+ * PUBLIC key the hub holds, so only the operator's secret key opens it.
13237
+ * Absent on a plain `.tar.gz` — every archive made before encryption, or
13238
+ * with it off — which restores without a key.
13239
+ */
13240
+ var BackupArchiveEncryptionSchema = object({
13241
+ /** `x25519-hkdf-aes256gcm-stream-v1`. */
13242
+ scheme: string(),
13243
+ /** 16 hex — the backup key whose secret restores this archive. */
13244
+ keyId: string()
13245
+ });
13246
+ /**
13247
+ * The backup encryption setting. The hub keeps PUBLIC keys only: the active
13248
+ * one new archives are encrypted to, and the retired ones older archives
13249
+ * still need. The secret key is shown once, at `setupEncryption`.
13250
+ */
13251
+ var BackupEncryptionStatusSchema = object({
13252
+ enabled: boolean(),
13253
+ active: object({
13254
+ keyId: string(),
13255
+ publicKey: string(),
13256
+ createdAt: number()
13257
+ }).nullable(),
13258
+ /** Every key ever set up, newest first. */
13259
+ keys: array(object({
13260
+ keyId: string(),
13261
+ createdAt: number(),
13262
+ retiredAt: number().nullable()
13263
+ })).readonly()
13264
+ });
13265
+ /**
12538
13266
  * Per-archive entry returned by `backup.listArchives({ destinationId })`.
12539
13267
  * Same shape the destination drill-in renders. Sourced from the per-
12540
13268
  * location `manifests.json` (no per-archive tarball read required).
@@ -12546,7 +13274,9 @@ var BackupArchiveEntrySchema = object({
12546
13274
  sizeBytes: number(),
12547
13275
  label: string().optional(),
12548
13276
  /** Top-level locations included in the archive (db, addons, tls, …). */
12549
- locations: array(string()).readonly()
13277
+ locations: array(string()).readonly(),
13278
+ /** Present when the archive is encrypted; restore then needs that key. */
13279
+ encryption: BackupArchiveEncryptionSchema.optional()
12550
13280
  });
12551
13281
  var BackupEntrySchema = object({
12552
13282
  id: string(),
@@ -12555,7 +13285,8 @@ var BackupEntrySchema = object({
12555
13285
  label: string().optional(),
12556
13286
  createdAt: number(),
12557
13287
  sizeBytes: number(),
12558
- locations: array(string()).optional()
13288
+ locations: array(string()).optional(),
13289
+ encryption: BackupArchiveEncryptionSchema.optional()
12559
13290
  });
12560
13291
  var ArchiveEntrySchema = object({
12561
13292
  path: string(),
@@ -12744,10 +13475,40 @@ method(_void(), array(BackupDestinationInfoSchema).readonly(), { auth: "admin" }
12744
13475
  * this list and skips entries whose path doesn't start with
12745
13476
  * any of them.
12746
13477
  */
12747
- locations: array(string()).optional()
13478
+ locations: array(string()).optional(),
13479
+ /**
13480
+ * The backup SECRET key, for an encrypted archive (ignored for a plain
13481
+ * one). The archive is decrypted into the hub's private staging
13482
+ * before the restart; the key is not stored. A wrong or missing key
13483
+ * is refused before the archive is downloaded.
13484
+ */
13485
+ backupSecretKey: string().optional()
12748
13486
  }), _void(), {
12749
13487
  kind: "mutation",
12750
13488
  auth: "admin"
13489
+ }), method(_void(), BackupEncryptionStatusSchema, { auth: "admin" }), method(object({}), object({
13490
+ keyId: string(),
13491
+ secretKey: string(),
13492
+ publicKey: string(),
13493
+ createdAt: number(),
13494
+ replacedKeyId: string().nullable()
13495
+ }), {
13496
+ kind: "mutation",
13497
+ auth: "admin"
13498
+ }), method(object({}), object({ disabledKeyId: string().nullable() }), {
13499
+ kind: "mutation",
13500
+ auth: "admin"
13501
+ }), method(object({ backupSecretKey: string() }), object({
13502
+ valid: boolean(),
13503
+ keyId: string().nullable(),
13504
+ /** The hub knows this key (active or retired). */
13505
+ known: boolean(),
13506
+ /** It is the key new archives are encrypted to. */
13507
+ active: boolean(),
13508
+ error: string().optional()
13509
+ }), {
13510
+ kind: "mutation",
13511
+ auth: "admin"
12751
13512
  }), method(object({
12752
13513
  destinationId: string(),
12753
13514
  backupId: string()
@@ -14473,7 +15234,60 @@ var CustomModelDescriptorSchema = object({
14473
15234
  stepId: string(),
14474
15235
  entry: ModelCatalogEntrySchema
14475
15236
  });
14476
- method(_void(), array(CustomModelDescriptorSchema).readonly(), { auth: "admin" });
15237
+ /** One regular file of an imported bundle, as the producer measured it. */
15238
+ var ModelBundleFileSchema = object({
15239
+ /** Relative path inside the bundle tar; an mlpackage member is `<x>.mlpackage/<member>`. */
15240
+ path: string().min(1),
15241
+ bytes: number().int().nonnegative(),
15242
+ sha256: string().regex(/^[0-9a-f]{64}$/)
15243
+ });
15244
+ var ImportModelBundleInputSchema = object({
15245
+ /** The registry provider that keeps the model (Model Studio). */
15246
+ addonId: string(),
15247
+ stepId: string().min(1),
15248
+ /**
15249
+ * The catalog rows to register, complete, every format URL already
15250
+ * `camstack-local://<modelId>/<file>` naming a file of the bundle. One
15251
+ * bundle may carry several rows (a base and its INT8 variant).
15252
+ */
15253
+ entries: array(ModelCatalogEntrySchema).min(1).max(4),
15254
+ /** The bundle tar, offered by the producer over `ctx.peerBytes` (same host). */
15255
+ bundle: object({
15256
+ ticket: PeerBytesTicketSchema,
15257
+ bytes: number().int().positive(),
15258
+ sha256: string().regex(/^[0-9a-f]{64}$/)
15259
+ }),
15260
+ /** Every file the tar must hold; anything missing, extra or different is refused. */
15261
+ files: array(ModelBundleFileSchema).min(1).max(64),
15262
+ /** Convert missing engine formats and push the model to every agent afterwards. */
15263
+ distribute: boolean()
15264
+ });
15265
+ var ImportModelBundleResultSchema = discriminatedUnion("kind", [object({
15266
+ kind: literal("imported"),
15267
+ modelIds: array(string()).readonly(),
15268
+ distributed: array(object({
15269
+ modelId: string(),
15270
+ nodeId: string(),
15271
+ format: _enum(MODEL_FORMATS),
15272
+ ok: boolean(),
15273
+ error: string().optional()
15274
+ })).readonly()
15275
+ }), object({
15276
+ kind: literal("refused"),
15277
+ reason: _enum([
15278
+ "transfer-failed",
15279
+ "checksum-mismatch",
15280
+ "bundle-mismatch",
15281
+ "invalid-entry",
15282
+ "id-taken"
15283
+ ]),
15284
+ detail: string()
15285
+ })]);
15286
+ method(_void(), array(CustomModelDescriptorSchema).readonly(), { auth: "admin" }), method(ImportModelBundleInputSchema, ImportModelBundleResultSchema, {
15287
+ kind: "mutation",
15288
+ auth: "admin",
15289
+ timeoutMs: 30 * 6e4
15290
+ });
14477
15291
  /**
14478
15292
  * Query filter for settings-store collections.
14479
15293
  */
@@ -14952,6 +15766,35 @@ var KeychainKeySourceSchema = object({
14952
15766
  */
14953
15767
  sharesBackupWithDatabase: boolean()
14954
15768
  });
15769
+ /**
15770
+ * One keychain reset, as the Secrets page reports it until the operator
15771
+ * acknowledges it. Never a value: refs, counts and table names only.
15772
+ */
15773
+ var KeychainResetRecordSchema = object({
15774
+ id: string(),
15775
+ at: number(),
15776
+ /** `user:<id>` or {@link KEYCHAIN_RESET_TRIGGER_ACTOR}. */
15777
+ actor: string(),
15778
+ /** Why the keychain was locked when it was reset; `null` when it was not locked. */
15779
+ lockedReason: string().nullable(),
15780
+ /** Values moved into the archive table (ciphertext under the lost key). */
15781
+ archived: number().int(),
15782
+ /** `keychain:secrets-orphaned-<ts>`, or `null` when nothing was stored. */
15783
+ archivedCollection: string().nullable(),
15784
+ /**
15785
+ * `keychain:keys-orphaned-<ts>`: the wrapped data keys of the archive, kept
15786
+ * so the archive can still be opened if the lost master key turns up.
15787
+ */
15788
+ archivedKeysCollection: string().nullable(),
15789
+ /**
15790
+ * `system-settings` keys whose marker the reset cleared — the cluster
15791
+ * secret's: a marker left pointing at an archived value would refuse every
15792
+ * agent forever (D797).
15793
+ */
15794
+ clearedSettingsKeys: array(string()).readonly(),
15795
+ /** When an operator dismissed the notice on the Secrets page; `null` until then. */
15796
+ acknowledgedAt: number().nullable()
15797
+ });
14955
15798
  var KeychainStatusSchema = object({
14956
15799
  keychain: KeychainStateSchema,
14957
15800
  /** The source of the master key in use; `null` while locked. */
@@ -14969,7 +15812,9 @@ var KeychainStatusSchema = object({
14969
15812
  /** Wrapped copies of the data key under a previous master key, kept until purged. */
14970
15813
  retiredWraps: number().int(),
14971
15814
  recoveryKeyDownloadedAt: number().nullable(),
14972
- secretCount: number().int()
15815
+ secretCount: number().int(),
15816
+ /** The most recent reset, acknowledged or not; `null` when the keychain was never reset. */
15817
+ lastReset: KeychainResetRecordSchema.nullable()
14973
15818
  });
14974
15819
  /**
14975
15820
  * Whether a stored value is still pointed at by its owner's settings.
@@ -14991,13 +15836,14 @@ var KeychainAuditActionSchema = _enum([
14991
15836
  "download-recovery-key",
14992
15837
  "delete-orphans",
14993
15838
  "reset",
15839
+ "acknowledge-reset",
14994
15840
  "initialize"
14995
15841
  ]);
14996
15842
  var KeychainAuditEntrySchema = object({
14997
15843
  id: string(),
14998
15844
  at: number(),
14999
15845
  action: KeychainAuditActionSchema,
15000
- /** `addon:<id>` | `user:<id>` | `system`. */
15846
+ /** `addon:<id>` | `user:<id>` | `system` | `trigger-file`. */
15001
15847
  actor: string(),
15002
15848
  ref: string().nullable(),
15003
15849
  detail: string().nullable()
@@ -15063,6 +15909,13 @@ method(object({}), KeychainStatusSchema, { auth: "admin" }), method(object({}),
15063
15909
  kind: "mutation",
15064
15910
  auth: "admin",
15065
15911
  caller: "required"
15912
+ }), method(object({}), object({
15913
+ reset: KeychainResetRecordSchema.nullable(),
15914
+ pendingReentry: array(KeychainSecretMetaSchema).readonly()
15915
+ }), { auth: "admin" }), method(object({}), object({ acknowledged: boolean() }), {
15916
+ kind: "mutation",
15917
+ auth: "admin",
15918
+ caller: "required"
15066
15919
  });
15067
15920
  method(_void(), object({
15068
15921
  id: string(),
@@ -17913,7 +18766,7 @@ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
17913
18766
  * `login-method` — collection cap through which auth addons contribute
17914
18767
  * their pre-auth login surfaces to the login page. This is the SINGLE,
17915
18768
  * generic mechanism that supersedes the dead `auth.listProviders` reader:
17916
- * every auth addon (OIDC, magic-link, WebAuthn/passkey) registers a
18769
+ * every auth addon (OIDC, WebAuthn/passkey) registers a
17917
18770
  * `login-method` provider and the PUBLIC `auth.listLoginMethods`
17918
18771
  * procedure aggregates them for the unauthenticated login page.
17919
18772
  *
@@ -17921,8 +18774,7 @@ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
17921
18774
  *
17922
18775
  * - `redirect` — a declarative button. The login page renders a generic
17923
18776
  * button that navigates to `startUrl` (an addon-owned HTTP route).
17924
- * Covers OIDC (`/addon/auth-oidc/<id>/start`) and magic-link with
17925
- * ZERO shell-side JS. A future SSO addon plugs in the same way — the
18777
+ * Covers OIDC (`/addon/auth-oidc/<id>/start`) with ZERO shell-side JS. A future SSO addon plugs in the same way — the
17926
18778
  * login page needs NO change.
17927
18779
  *
17928
18780
  * - `widget` — a Module-Federation widget the login page mounts (via
@@ -17941,8 +18793,8 @@ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
17941
18793
  * decision.
17942
18794
  *
17943
18795
  * Every contribution carries a `stage`:
17944
- * - `primary` — shown on the first credentials screen (OIDC /
17945
- * magic-link buttons; a future usernameless passkey).
18796
+ * - `primary` — shown on the first credentials screen (OIDC
18797
+ * buttons; a usernameless passkey).
17946
18798
  * - `second-factor` — shown AFTER the password leg, gated on the
17947
18799
  * returned `factors` (passkey-as-2FA today).
17948
18800
  *
@@ -17969,7 +18821,7 @@ var LoginMethodContributionSchema = discriminatedUnion("kind", [
17969
18821
  * The provider names an external identity a signed-in user can link to
17970
18822
  * their own account (D782): `auth.listLinkableProviders` /
17971
18823
  * `beginExternalLink` offer exactly the redirect methods that set this,
17972
- * whatever their id. Absent / false — a login button only (magic-link).
18824
+ * whatever their id. Absent / false — a login button only.
17973
18825
  */
17974
18826
  linkable: boolean().optional()
17975
18827
  }),
@@ -21824,8 +22676,7 @@ method(object({}), object({ rules: array(NcRuleSchema) }), { auth: "admin" }), m
21824
22676
  * `super_admin` — collapsed onto the single boolean because every
21825
22677
  * non-admin caller is governed by the same scope-check rules; the
21826
22678
  * distinction was only ever used to route role-specific procedures
21827
- * which we no longer have. Agents are admin sessions issued via
21828
- * `createServiceToken`; CLI / webhook integrations are `cst_*` tokens
22679
+ * which we no longer have. CLI / webhook integrations are `cst_*` tokens
21829
22680
  * with `isAdmin: false` + an explicit scope list.
21830
22681
  */
21831
22682
  /** Per-method access flavour. Materialised on every cap method via codegen. */
@@ -24520,6 +25371,17 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
24520
25371
  kind: "mutation",
24521
25372
  auth: "admin",
24522
25373
  timeoutMs: 60 * 6e4
25374
+ }), method(object({
25375
+ filter: RetrainExportFilterSchema,
25376
+ layout: RetrainExportLayoutSchema
25377
+ }), object({
25378
+ ticket: PeerBytesTicketSchema,
25379
+ frames: number().int(),
25380
+ annotations: number().int()
25381
+ }), {
25382
+ kind: "mutation",
25383
+ auth: "admin",
25384
+ timeoutMs: 12e4
24523
25385
  }), method(object({
24524
25386
  selection: RetrainDatasetSelectionSchema,
24525
25387
  completeOnly: boolean().optional()
@@ -28128,8 +28990,8 @@ version: string().optional() }), ServerUpdateActionResultSchema, {
28128
28990
  * `smtp-provider` — pluggable email delivery surface.
28129
28991
  *
28130
28992
  * Collection cap: a deployment may install multiple SMTP relays (e.g.
28131
- * one for transactional / one for notifications). Consumers (magic-link,
28132
- * notifier addons, …) walk the collection and pick the first
28993
+ * one for transactional / one for notifications). Consumers (notifier
28994
+ * addons, …) walk the collection and pick the first
28133
28995
  * ready provider OR target a specific addonId.
28134
28996
  *
28135
28997
  * The shape stays small on purpose — `sendEmail` is enough for the
@@ -28412,7 +29274,7 @@ targets: array(object({
28412
29274
  };
28413
29275
  /**
28414
29276
  * `sso-bridge` — internal hub-only cap that lets SSO-style auth
28415
- * providers (OIDC, SAML, magic-link, …) mint an HMAC-signed token
29277
+ * providers (OIDC, SAML, …) mint an HMAC-signed token
28416
29278
  * carrying the post-callback claims before redirecting back to
28417
29279
  * `/api/auth/sso/finish`.
28418
29280
  *
@@ -28475,7 +29337,14 @@ var SsoBridgeClaimsSchema = object({
28475
29337
  * Verified `iss` of the id_token behind an OIDC login bridge (D782). A
28476
29338
  * subject is unique only per issuer, so a link is bound to it.
28477
29339
  */
28478
- issuer: string().optional()
29340
+ issuer: string().optional(),
29341
+ /**
29342
+ * SHA-256 (hex) of the `camstack_sso_state` cookie the IdP `/start` set in
29343
+ * the browser that began this sign-in. `/api/auth/sso/finish` requires the
29344
+ * request to present the matching cookie — a login bridge is useless in
29345
+ * any other browser.
29346
+ */
29347
+ browserBinding: string().optional()
28479
29348
  });
28480
29349
  method(object({
28481
29350
  claims: SsoBridgeClaimsSchema,
@@ -40742,16 +41611,6 @@ var ApiKeySummarySchema = object({
40742
41611
  createdAt: number(),
40743
41612
  lastUsedAt: number().optional()
40744
41613
  });
40745
- var CreateApiKeyInputSchema = object({
40746
- label: string(),
40747
- isAdmin: boolean().default(false),
40748
- allowedProviders: union([array(string()), literal("*")]).optional(),
40749
- allowedDevices: record(string(), union([array(string()), literal("*")])).optional()
40750
- });
40751
- var CreateApiKeyResultSchema = object({
40752
- token: string(),
40753
- record: ApiKeySummarySchema
40754
- });
40755
41614
  var ScopedTokenSummarySchema = object({
40756
41615
  id: string(),
40757
41616
  userId: string(),
@@ -40850,17 +41709,10 @@ method(_void(), array(UserSummarySchema), { auth: "admin" }), method(CreateUserI
40850
41709
  }), UserSummarySchema.extend({ passwordHash: string() }).nullable(), {
40851
41710
  kind: "mutation",
40852
41711
  access: "view"
40853
- }), method(_void(), array(ApiKeySummarySchema), { auth: "admin" }), method(CreateApiKeyInputSchema, CreateApiKeyResultSchema, {
40854
- kind: "mutation",
40855
- auth: "admin",
40856
- access: "create"
40857
- }), method(object({ id: string() }), object({ success: literal(true) }), {
41712
+ }), method(_void(), array(ApiKeySummarySchema), { auth: "admin" }), method(object({ id: string() }), object({ success: literal(true) }), {
40858
41713
  kind: "mutation",
40859
41714
  auth: "admin",
40860
41715
  access: "delete"
40861
- }), method(object({ token: string() }), ApiKeySummarySchema.nullable(), {
40862
- kind: "mutation",
40863
- access: "view"
40864
41716
  }), method(CreateScopedTokenInputSchema, CreateScopedTokenResultSchema, {
40865
41717
  kind: "mutation",
40866
41718
  auth: "admin",
@@ -40934,15 +41786,7 @@ method(_void(), array(UserSummarySchema), { auth: "admin" }), method(CreateUserI
40934
41786
  }).nullable(), { access: "view" }), method(object({ userId: string() }), array(ExternalIdentitySchema), { auth: "admin" }), method(ExternalIdentityKeySchema, object({
40935
41787
  userId: string(),
40936
41788
  issuer: string()
40937
- }).nullable(), { auth: "admin" }), method(ExternalIdentityKeySchema.extend({
40938
- userId: string(),
40939
- issuer: string().min(1),
40940
- label: string().optional()
40941
- }), object({ success: literal(true) }), {
40942
- kind: "mutation",
40943
- auth: "admin",
40944
- access: "create"
40945
- }), method(ExternalIdentityKeySchema.extend({ userId: string() }), object({ success: boolean() }), {
41789
+ }).nullable(), { auth: "admin" }), method(ExternalIdentityKeySchema.extend({ userId: string() }), object({ success: boolean() }), {
40946
41790
  kind: "mutation",
40947
41791
  auth: "admin",
40948
41792
  access: "delete"
@@ -41647,6 +42491,451 @@ var zoneRulesCapability = {
41647
42491
  */
41648
42492
  durability: "restored"
41649
42493
  };
42494
+ /**
42495
+ * `training-provider` — ONE cloud that can run the CamStack trainer.
42496
+ *
42497
+ * A thin, mockable translation layer: it knows how to run a container with a
42498
+ * GPU, move a dataset in, read the job's stdout and hand artefacts back. It
42499
+ * knows nothing about datasets, splits, floors, cost policy or Model Studio —
42500
+ * those are the `training` orchestrator's (D805). Every rule written there
42501
+ * once is what makes a second provider (RunPod, a local NVIDIA node) a new
42502
+ * manifest entry and nothing else.
42503
+ *
42504
+ * Collection, routed by the `addonId` in every single-row input (the `llm` /
42505
+ * `notification-output` posture); `describe` concat-fans across providers.
42506
+ * Every method is `admin`: these spend money.
42507
+ *
42508
+ * Every cloud object a provider creates is tagged with the orchestrator's
42509
+ * `jobKey`, so a retried submit finds the job it already started instead of
42510
+ * starting a second GPU, and `listJobs` can find orphans.
42511
+ *
42512
+ * Bytes never ride a cap field: the dataset arrives as a `ctx.peerBytes`
42513
+ * ticket the producer (pipeline-analytics) minted, and artefacts leave as a
42514
+ * ticket the provider mints (D613).
42515
+ */
42516
+ var TrainingGpuOptionSchema = object({
42517
+ id: string(),
42518
+ label: string(),
42519
+ /** List price, USD per GPU-hour, before any region multiplier. */
42520
+ usdPerHour: number().nonnegative(),
42521
+ vramGb: number().nonnegative()
42522
+ });
42523
+ var TrainingRegionOptionSchema = object({
42524
+ /** `''` = any region (the provider's choice). */
42525
+ id: string(),
42526
+ label: string(),
42527
+ priceMultiplier: number().positive()
42528
+ });
42529
+ /**
42530
+ * The provider's per-account settings, as the orchestrator reads them. They
42531
+ * live in the PROVIDER addon's settings (operator decision 2026-10-08: they
42532
+ * depend on the user's account), never hard-coded in the orchestrator.
42533
+ */
42534
+ var TrainingProviderDefaultsSchema = object({
42535
+ gpuType: string(),
42536
+ region: string(),
42537
+ costCapUsd: number().nonnegative(),
42538
+ maxRuntimeSec: number().int().positive(),
42539
+ /** Hours a FAILED job's cloud dataset is kept for debugging; 0 = delete at once. */
42540
+ failedDatasetGraceHours: number().nonnegative()
42541
+ });
42542
+ var TrainingProviderDescriptorSchema = object({
42543
+ addonId: string(),
42544
+ /** `modal`, `runpod`, `fake`, … */
42545
+ kind: string(),
42546
+ label: string(),
42547
+ gpuTypes: array(TrainingGpuOptionSchema).readonly(),
42548
+ regions: array(TrainingRegionOptionSchema).readonly(),
42549
+ maxDatasetBytes: number().int().positive(),
42550
+ maxRuntimeSec: number().int().positive(),
42551
+ freeTierNote: string().optional(),
42552
+ /** Where the data goes, in one sentence the confirm dialog repeats. */
42553
+ dataResidencyNote: string(),
42554
+ /** Credentials are present — never the values. */
42555
+ configured: boolean(),
42556
+ defaults: TrainingProviderDefaultsSchema
42557
+ });
42558
+ var TrainingCredentialCheckSchema = object({
42559
+ ok: boolean(),
42560
+ /** Workspace / account name, when the provider says. */
42561
+ account: string().optional(),
42562
+ reason: _enum([
42563
+ "missing",
42564
+ "invalid",
42565
+ "forbidden",
42566
+ "network",
42567
+ "quota"
42568
+ ]).optional(),
42569
+ detail: string().optional()
42570
+ });
42571
+ var ProviderJobStateSchema = _enum([
42572
+ "pending",
42573
+ "starting",
42574
+ "running",
42575
+ "succeeded",
42576
+ "failed",
42577
+ "cancelled",
42578
+ "lost"
42579
+ ]);
42580
+ var ProviderJobStatusSchema = object({
42581
+ jobKey: string(),
42582
+ providerJobId: string().optional(),
42583
+ state: ProviderJobStateSchema,
42584
+ startedAt: number().optional(),
42585
+ endedAt: number().optional(),
42586
+ exitCode: number().int().optional(),
42587
+ failureReason: string().optional(),
42588
+ gpuType: string(),
42589
+ region: string().optional(),
42590
+ billedSeconds: number().nonnegative(),
42591
+ costUsd: number().nonnegative(),
42592
+ /** True when `costUsd` is runtime × list price, not a billing answer. */
42593
+ costIsEstimate: boolean(),
42594
+ lastFetchedAt: number()
42595
+ });
42596
+ /**
42597
+ * The trainer the job runs, by SOURCE revision: the provider turns it into an
42598
+ * image its own way (Modal builds the published Dockerfile at that revision;
42599
+ * a registry-pull provider maps it to a tag). Recorded on the job and echoed
42600
+ * in `result.json`.
42601
+ */
42602
+ var TrainerSourceRefSchema = object({
42603
+ /** Hugging Face repo id, e.g. `camstack/camstack-trainer`. */
42604
+ repo: string().min(1),
42605
+ /** A commit sha (never a branch) — the job must be reproducible. */
42606
+ revision: string().regex(/^[0-9a-f]{7,64}$/)
42607
+ });
42608
+ var JobRef = {
42609
+ addonId: string(),
42610
+ jobKey: string().uuid()
42611
+ };
42612
+ var TrainingLogLineSchema = object({
42613
+ ts: number(),
42614
+ text: string()
42615
+ });
42616
+ method(object({}), array(TrainingProviderDescriptorSchema).readonly(), { auth: "admin" }), method(object({ addonId: string() }), TrainingCredentialCheckSchema, {
42617
+ kind: "mutation",
42618
+ auth: "admin",
42619
+ timeoutMs: 3e4
42620
+ }), method(object({
42621
+ addonId: string(),
42622
+ gpuType: string(),
42623
+ region: string(),
42624
+ datasetBytes: number().int().nonnegative(),
42625
+ gpuSecondsLow: number().nonnegative(),
42626
+ gpuSecondsHigh: number().nonnegative()
42627
+ }), object({
42628
+ usdLow: number().nonnegative(),
42629
+ usdHigh: number().nonnegative(),
42630
+ notes: array(string()).readonly()
42631
+ }), { auth: "admin" }), method(object({
42632
+ ...JobRef,
42633
+ ticket: PeerBytesTicketSchema
42634
+ }), object({
42635
+ bytes: number().int().nonnegative(),
42636
+ sha256: string()
42637
+ }), {
42638
+ kind: "mutation",
42639
+ auth: "admin",
42640
+ timeoutMs: 120 * 6e4
42641
+ }), method(object({
42642
+ ...JobRef,
42643
+ trainer: TrainerSourceRefSchema,
42644
+ jobSpecJson: string().min(2).max(64e3),
42645
+ gpuType: string(),
42646
+ region: string(),
42647
+ maxRuntimeSec: number().int().positive()
42648
+ }), ProviderJobStatusSchema, {
42649
+ kind: "mutation",
42650
+ auth: "admin",
42651
+ timeoutMs: 30 * 6e4
42652
+ }), method(object(JobRef), ProviderJobStatusSchema, {
42653
+ auth: "admin",
42654
+ timeoutMs: 6e4
42655
+ }), method(object({
42656
+ ...JobRef,
42657
+ cursor: string().optional(),
42658
+ max: number().int().min(1).max(500)
42659
+ }), object({
42660
+ lines: array(TrainingLogLineSchema).readonly(),
42661
+ cursor: string()
42662
+ }), {
42663
+ auth: "admin",
42664
+ timeoutMs: 6e4
42665
+ }), method(object(JobRef), object({ ok: literal(true) }), {
42666
+ kind: "mutation",
42667
+ auth: "admin",
42668
+ timeoutMs: 6e4
42669
+ }), method(object(JobRef), object({
42670
+ found: boolean(),
42671
+ text: string().optional()
42672
+ }), {
42673
+ kind: "mutation",
42674
+ auth: "admin",
42675
+ timeoutMs: 5 * 6e4
42676
+ }), method(object({
42677
+ ...JobRef,
42678
+ path: _enum(["bundle.tar"])
42679
+ }), object({ ticket: PeerBytesTicketSchema }), {
42680
+ kind: "mutation",
42681
+ auth: "admin",
42682
+ timeoutMs: 5 * 6e4
42683
+ }), method(object(JobRef), object({ deleted: array(string()).readonly() }), {
42684
+ kind: "mutation",
42685
+ auth: "admin",
42686
+ timeoutMs: 5 * 6e4
42687
+ }), method(object({ addonId: string() }), array(ProviderJobStatusSchema).readonly(), {
42688
+ auth: "admin",
42689
+ timeoutMs: 2 * 6e4
42690
+ });
42691
+ /**
42692
+ * `training` — the cloud-training orchestrator (D805). Hub-only singleton,
42693
+ * provided by `addon-training`.
42694
+ *
42695
+ * It owns what every provider must agree on, written once:
42696
+ *
42697
+ * - **Dataset versions.** Taken over from pipeline-analytics (D796): the rows
42698
+ * live here (D808); pipeline-analytics still CUTS a version (it owns the corpus and
42699
+ * the export plan) and reaches this store through the five row methods
42700
+ * below, so the Retrain page and the export did not change.
42701
+ * - **Jobs.** A persisted state machine, a reconcile loop against the
42702
+ * provider, a cost guard, a daily orphan sweep and the retention rules.
42703
+ * - **The return flow.** Verified artefacts → Model Studio
42704
+ * (`custom-model-registry.importModelBundle`) → canary on cameras →
42705
+ * rollback. Nothing is ever registered automatically.
42706
+ *
42707
+ * Every method is `admin`.
42708
+ */
42709
+ /** A version WITH its frame list — what the export and a job read. */
42710
+ var TrainingDatasetVersionRowSchema = RetrainDatasetVersionSchema.omit({ frameCount: true }).extend({ frameIds: array(string()).max(2e4).readonly() });
42711
+ /** A base model a detector job can fine-tune, and the baseline it is judged against. */
42712
+ var TrainingBaseModelSchema = object({
42713
+ modelId: string(),
42714
+ label: string(),
42715
+ weights: string(),
42716
+ imgsz: number().int(),
42717
+ baselineOnnxUrl: string(),
42718
+ baselineFloors: record(string(), number()),
42719
+ /** The base the fleet runs most — the UI's default. */
42720
+ recommended: boolean()
42721
+ });
42722
+ var TrainingPresetSchema = _enum([
42723
+ "quick",
42724
+ "standard",
42725
+ "thorough"
42726
+ ]);
42727
+ var TrainingJobRequestSchema = object({
42728
+ datasetVersionId: string().min(1),
42729
+ /** The `training-provider` addon that runs it. */
42730
+ addonId: string().min(1),
42731
+ gpuType: string().min(1),
42732
+ region: string(),
42733
+ baseModelId: string().min(1),
42734
+ preset: TrainingPresetSchema,
42735
+ /** Freeze the backbone's first N layers; `null` = the preset's choice. */
42736
+ freeze: number().int().nonnegative().nullable(),
42737
+ /** Cameras held out whole for evaluation; `null` = the orchestrator's default. */
42738
+ holdoutCameras: array(number().int()).nullable()
42739
+ });
42740
+ var TrainingSplitPlanSchema = object({
42741
+ holdoutCameras: array(number().int()).readonly(),
42742
+ /** Used when no camera is held out: the last N days of every camera. */
42743
+ holdoutLastDays: number().int().nonnegative(),
42744
+ /** Holdout subjects per class (camera holdout only; `null` = known only after the split). */
42745
+ holdoutSupport: record(string(), number().int()).nullable(),
42746
+ trainSubjects: number().int()
42747
+ });
42748
+ var TrainingRefusalReasonSchema = _enum([
42749
+ "unknown-dataset",
42750
+ "unknown-provider",
42751
+ "provider-not-configured",
42752
+ "unknown-base-model",
42753
+ "unknown-gpu",
42754
+ "dataset-too-large",
42755
+ "no-training-subjects",
42756
+ "job-already-running"
42757
+ ]);
42758
+ var TrainingJobPlanSchema = object({
42759
+ refusal: object({
42760
+ reason: TrainingRefusalReasonSchema,
42761
+ detail: string()
42762
+ }).nullable(),
42763
+ warnings: array(string()).readonly(),
42764
+ split: TrainingSplitPlanSchema.nullable(),
42765
+ estimate: object({
42766
+ datasetBytes: number().int(),
42767
+ uploadMinutesAt20Mbps: number(),
42768
+ gpuSecondsLow: number(),
42769
+ gpuSecondsHigh: number(),
42770
+ usdLow: number(),
42771
+ usdHigh: number(),
42772
+ notes: array(string()).readonly()
42773
+ }).nullable(),
42774
+ /** Pre-filled from the provider's settings; the operator may lower or raise them. */
42775
+ defaults: object({
42776
+ maxCostUsd: number(),
42777
+ maxRuntimeSec: number().int()
42778
+ }).nullable(),
42779
+ /** The sentence the confirm dialog repeats: where the frames go and when they are deleted. */
42780
+ dataNotice: string()
42781
+ });
42782
+ /**
42783
+ * Orchestrator-owned states, persisted. `uploading` covers exporting the
42784
+ * archive (it is streamed, never staged). Terminal: `failed`, `cancelled`,
42785
+ * `lost`, `expired`, `discarded`. `registered` and `canary` are where a
42786
+ * result lives after the operator acted on it.
42787
+ */
42788
+ var TrainingJobStateSchema = _enum([
42789
+ "uploading",
42790
+ "submitted",
42791
+ "starting",
42792
+ "running",
42793
+ "collecting",
42794
+ "ready",
42795
+ "registered",
42796
+ "canary",
42797
+ "failed",
42798
+ "cancelling",
42799
+ "cancelled",
42800
+ "lost",
42801
+ "expired",
42802
+ "discarded"
42803
+ ]);
42804
+ var TrainingFailureReasonSchema = _enum([
42805
+ "cost-cap",
42806
+ "runtime-cap",
42807
+ "upload-failed",
42808
+ "submit-failed",
42809
+ "trainer-failed",
42810
+ "result-invalid",
42811
+ "checksum-mismatch",
42812
+ "fetch-failed",
42813
+ "provider-error",
42814
+ "hub-restart-during-upload"
42815
+ ]);
42816
+ var TrainingProgressPointSchema = object({
42817
+ epoch: number().int(),
42818
+ map50: number().nullable(),
42819
+ map50_95: number().nullable()
42820
+ });
42821
+ var TrainingCanarySchema = object({
42822
+ deviceIds: array(number().int()).readonly(),
42823
+ since: number(),
42824
+ /** Every override the canary replaced, exactly, so rollback restores it. */
42825
+ previous: array(object({
42826
+ deviceId: number().int(),
42827
+ nodeId: string(),
42828
+ deviceKey: string(),
42829
+ patch: object({
42830
+ modelId: string().optional(),
42831
+ settings: record(string(), unknown()).readonly().optional()
42832
+ }).nullable()
42833
+ })).readonly()
42834
+ });
42835
+ var TrainingJobSchema = object({
42836
+ id: string(),
42837
+ idempotencyKey: string(),
42838
+ name: string(),
42839
+ createdAt: number(),
42840
+ updatedAt: number(),
42841
+ state: TrainingJobStateSchema,
42842
+ stage: TrainingStageSchema.nullable(),
42843
+ failure: object({
42844
+ reason: TrainingFailureReasonSchema,
42845
+ stage: string().nullable(),
42846
+ detail: string()
42847
+ }).nullable(),
42848
+ request: TrainingJobRequestSchema,
42849
+ maxCostUsd: number().nonnegative(),
42850
+ maxRuntimeSec: number().int().positive(),
42851
+ trainer: TrainerSourceRefSchema,
42852
+ datasetLayout: RetrainExportLayoutSchema,
42853
+ dataset: object({
42854
+ bytes: number().int(),
42855
+ sha256: string(),
42856
+ uploadedAt: number()
42857
+ }).nullable(),
42858
+ split: TrainingSplitPlanSchema,
42859
+ provider: object({
42860
+ state: ProviderJobStateSchema.nullable(),
42861
+ providerJobId: string().nullable(),
42862
+ startedAt: number().nullable(),
42863
+ endedAt: number().nullable(),
42864
+ billedSeconds: number(),
42865
+ costUsd: number(),
42866
+ costIsEstimate: boolean(),
42867
+ lastPolledAt: number().nullable()
42868
+ }),
42869
+ progress: object({
42870
+ epoch: number().int().nullable(),
42871
+ epochs: number().int().nullable(),
42872
+ etaSec: number().nullable(),
42873
+ series: array(TrainingProgressPointSchema).readonly()
42874
+ }),
42875
+ /** The last lines of the job's output (≤ 200), newest last. Never frame paths. */
42876
+ logTail: array(string()).readonly(),
42877
+ logCursor: string().nullable(),
42878
+ artifacts: object({
42879
+ bundleBytes: number().int(),
42880
+ bundleSha256: string(),
42881
+ fetchedAt: number(),
42882
+ /** When the staged artefacts are deleted from the hub. */
42883
+ expiresAt: number()
42884
+ }).nullable(),
42885
+ /** When the provider-side copy of the frames was deleted; null while it exists. */
42886
+ cloudDatasetDeletedAt: number().nullable(),
42887
+ /** A failed job's dataset is kept until then (the provider's grace), then deleted. */
42888
+ cloudCleanupDueAt: number().nullable(),
42889
+ /** Model ids registered from this job (base, and int8 when kept). */
42890
+ registeredModelIds: array(string()).readonly(),
42891
+ canary: TrainingCanarySchema.nullable()
42892
+ });
42893
+ var IdInput = object({ id: string().min(1) });
42894
+ method(TrainingDatasetVersionRowSchema, object({ stored: boolean() }), {
42895
+ kind: "mutation",
42896
+ auth: "admin"
42897
+ }), 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() }), {
42898
+ kind: "mutation",
42899
+ auth: "admin"
42900
+ }), method(object({}), array(TrainingBaseModelSchema).readonly(), { auth: "admin" }), method(TrainingJobRequestSchema, TrainingJobPlanSchema, {
42901
+ auth: "admin",
42902
+ timeoutMs: 6e4
42903
+ }), method(TrainingJobRequestSchema.extend({
42904
+ name: string().min(1).max(120),
42905
+ maxCostUsd: number().positive(),
42906
+ maxRuntimeSec: number().int().positive(),
42907
+ idempotencyKey: string().min(8).max(80)
42908
+ }), discriminatedUnion("kind", [object({
42909
+ kind: literal("started"),
42910
+ job: TrainingJobSchema
42911
+ }), object({
42912
+ kind: literal("refused"),
42913
+ reason: TrainingRefusalReasonSchema,
42914
+ detail: string()
42915
+ })]), {
42916
+ kind: "mutation",
42917
+ auth: "admin",
42918
+ timeoutMs: 12e4
42919
+ }), method(object({}), array(TrainingJobSchema).readonly(), { auth: "admin" }), method(IdInput, TrainingJobSchema.nullable(), { auth: "admin" }), method(IdInput, TrainingJobSchema, {
42920
+ kind: "mutation",
42921
+ auth: "admin",
42922
+ timeoutMs: 12e4
42923
+ }), method(IdInput, TrainingResultSchema.nullable(), { auth: "admin" }), method(IdInput.extend({ canaryDeviceIds: array(number().int()).readonly() }), TrainingJobSchema, {
42924
+ kind: "mutation",
42925
+ auth: "admin",
42926
+ timeoutMs: 30 * 6e4
42927
+ }), method(IdInput.extend({ deviceIds: array(number().int()).min(1).readonly() }), TrainingJobSchema, {
42928
+ kind: "mutation",
42929
+ auth: "admin",
42930
+ timeoutMs: 12e4
42931
+ }), method(IdInput, TrainingJobSchema, {
42932
+ kind: "mutation",
42933
+ auth: "admin",
42934
+ timeoutMs: 12e4
42935
+ }), method(IdInput, TrainingJobSchema, {
42936
+ kind: "mutation",
42937
+ auth: "admin"
42938
+ });
41650
42939
  SOURCE_CAPS.filter((cap) => cap !== "switch" && cap !== "motion");
41651
42940
  Object.freeze({
41652
42941
  person: .5,
@@ -43795,6 +45084,12 @@ Object.freeze({
43795
45084
  addonId: null,
43796
45085
  access: "create"
43797
45086
  },
45087
+ "backup.checkBackupKey": {
45088
+ capName: "backup",
45089
+ capScope: "system",
45090
+ addonId: null,
45091
+ access: "create"
45092
+ },
43798
45093
  "backup.delete": {
43799
45094
  capName: "backup",
43800
45095
  capScope: "system",
@@ -43807,6 +45102,18 @@ Object.freeze({
43807
45102
  addonId: null,
43808
45103
  access: "delete"
43809
45104
  },
45105
+ "backup.disableEncryption": {
45106
+ capName: "backup",
45107
+ capScope: "system",
45108
+ addonId: null,
45109
+ access: "create"
45110
+ },
45111
+ "backup.getEncryption": {
45112
+ capName: "backup",
45113
+ capScope: "system",
45114
+ addonId: null,
45115
+ access: "view"
45116
+ },
43810
45117
  "backup.getEntries": {
43811
45118
  capName: "backup",
43812
45119
  capScope: "system",
@@ -43861,6 +45168,12 @@ Object.freeze({
43861
45168
  addonId: null,
43862
45169
  access: "create"
43863
45170
  },
45171
+ "backup.setupEncryption": {
45172
+ capName: "backup",
45173
+ capScope: "system",
45174
+ addonId: null,
45175
+ access: "create"
45176
+ },
43864
45177
  "backup.trigger": {
43865
45178
  capName: "backup",
43866
45179
  capScope: "system",
@@ -44413,6 +45726,12 @@ Object.freeze({
44413
45726
  addonId: null,
44414
45727
  access: "create"
44415
45728
  },
45729
+ "customModelRegistry.importModelBundle": {
45730
+ capName: "custom-model-registry",
45731
+ capScope: "system",
45732
+ addonId: null,
45733
+ access: "create"
45734
+ },
44416
45735
  "customModelRegistry.listModels": {
44417
45736
  capName: "custom-model-registry",
44418
45737
  capScope: "system",
@@ -45853,6 +47172,12 @@ Object.freeze({
45853
47172
  addonId: null,
45854
47173
  access: "view"
45855
47174
  },
47175
+ "keychainAdmin.acknowledgeReset": {
47176
+ capName: "keychain-admin",
47177
+ capScope: "system",
47178
+ addonId: null,
47179
+ access: "create"
47180
+ },
45856
47181
  "keychainAdmin.deleteOrphans": {
45857
47182
  capName: "keychain-admin",
45858
47183
  capScope: "system",
@@ -45889,6 +47214,12 @@ Object.freeze({
45889
47214
  addonId: null,
45890
47215
  access: "delete"
45891
47216
  },
47217
+ "keychainAdmin.resetReport": {
47218
+ capName: "keychain-admin",
47219
+ capScope: "system",
47220
+ addonId: null,
47221
+ access: "delete"
47222
+ },
45892
47223
  "keychainAdmin.reveal": {
45893
47224
  capName: "keychain-admin",
45894
47225
  capScope: "system",
@@ -47635,6 +48966,12 @@ Object.freeze({
47635
48966
  addonId: null,
47636
48967
  access: "view"
47637
48968
  },
48969
+ "pipelineAnalytics.offerRetrainArchive": {
48970
+ capName: "pipeline-analytics",
48971
+ capScope: "device",
48972
+ addonId: null,
48973
+ access: "create"
48974
+ },
47638
48975
  "pipelineAnalytics.ownersWithMedia": {
47639
48976
  capName: "pipeline-analytics",
47640
48977
  capScope: "device",
@@ -50173,6 +51510,174 @@ Object.freeze({
50173
51510
  addonId: null,
50174
51511
  access: "view"
50175
51512
  },
51513
+ "training.canaryResult": {
51514
+ capName: "training",
51515
+ capScope: "system",
51516
+ addonId: null,
51517
+ access: "create"
51518
+ },
51519
+ "training.cancelJob": {
51520
+ capName: "training",
51521
+ capScope: "system",
51522
+ addonId: null,
51523
+ access: "create"
51524
+ },
51525
+ "training.discardResult": {
51526
+ capName: "training",
51527
+ capScope: "system",
51528
+ addonId: null,
51529
+ access: "create"
51530
+ },
51531
+ "training.findDatasetVersionIdByName": {
51532
+ capName: "training",
51533
+ capScope: "system",
51534
+ addonId: null,
51535
+ access: "view"
51536
+ },
51537
+ "training.getDatasetVersion": {
51538
+ capName: "training",
51539
+ capScope: "system",
51540
+ addonId: null,
51541
+ access: "view"
51542
+ },
51543
+ "training.getJob": {
51544
+ capName: "training",
51545
+ capScope: "system",
51546
+ addonId: null,
51547
+ access: "view"
51548
+ },
51549
+ "training.getJobResult": {
51550
+ capName: "training",
51551
+ capScope: "system",
51552
+ addonId: null,
51553
+ access: "view"
51554
+ },
51555
+ "training.listBaseModels": {
51556
+ capName: "training",
51557
+ capScope: "system",
51558
+ addonId: null,
51559
+ access: "view"
51560
+ },
51561
+ "training.listDatasetVersions": {
51562
+ capName: "training",
51563
+ capScope: "system",
51564
+ addonId: null,
51565
+ access: "view"
51566
+ },
51567
+ "training.listJobs": {
51568
+ capName: "training",
51569
+ capScope: "system",
51570
+ addonId: null,
51571
+ access: "view"
51572
+ },
51573
+ "training.planJob": {
51574
+ capName: "training",
51575
+ capScope: "system",
51576
+ addonId: null,
51577
+ access: "view"
51578
+ },
51579
+ "training.putDatasetVersion": {
51580
+ capName: "training",
51581
+ capScope: "system",
51582
+ addonId: null,
51583
+ access: "create"
51584
+ },
51585
+ "training.registerResult": {
51586
+ capName: "training",
51587
+ capScope: "system",
51588
+ addonId: null,
51589
+ access: "create"
51590
+ },
51591
+ "training.removeDatasetVersion": {
51592
+ capName: "training",
51593
+ capScope: "system",
51594
+ addonId: null,
51595
+ access: "delete"
51596
+ },
51597
+ "training.rollbackCanary": {
51598
+ capName: "training",
51599
+ capScope: "system",
51600
+ addonId: null,
51601
+ access: "create"
51602
+ },
51603
+ "training.startJob": {
51604
+ capName: "training",
51605
+ capScope: "system",
51606
+ addonId: null,
51607
+ access: "create"
51608
+ },
51609
+ "trainingProvider.cancelJob": {
51610
+ capName: "training-provider",
51611
+ capScope: "system",
51612
+ addonId: null,
51613
+ access: "create"
51614
+ },
51615
+ "trainingProvider.cleanupJob": {
51616
+ capName: "training-provider",
51617
+ capScope: "system",
51618
+ addonId: null,
51619
+ access: "create"
51620
+ },
51621
+ "trainingProvider.describe": {
51622
+ capName: "training-provider",
51623
+ capScope: "system",
51624
+ addonId: null,
51625
+ access: "view"
51626
+ },
51627
+ "trainingProvider.estimateJob": {
51628
+ capName: "training-provider",
51629
+ capScope: "system",
51630
+ addonId: null,
51631
+ access: "view"
51632
+ },
51633
+ "trainingProvider.getJob": {
51634
+ capName: "training-provider",
51635
+ capScope: "system",
51636
+ addonId: null,
51637
+ access: "view"
51638
+ },
51639
+ "trainingProvider.listJobEvents": {
51640
+ capName: "training-provider",
51641
+ capScope: "system",
51642
+ addonId: null,
51643
+ access: "view"
51644
+ },
51645
+ "trainingProvider.listJobs": {
51646
+ capName: "training-provider",
51647
+ capScope: "system",
51648
+ addonId: null,
51649
+ access: "view"
51650
+ },
51651
+ "trainingProvider.offerArtifact": {
51652
+ capName: "training-provider",
51653
+ capScope: "system",
51654
+ addonId: null,
51655
+ access: "create"
51656
+ },
51657
+ "trainingProvider.readResult": {
51658
+ capName: "training-provider",
51659
+ capScope: "system",
51660
+ addonId: null,
51661
+ access: "create"
51662
+ },
51663
+ "trainingProvider.submitJob": {
51664
+ capName: "training-provider",
51665
+ capScope: "system",
51666
+ addonId: null,
51667
+ access: "create"
51668
+ },
51669
+ "trainingProvider.uploadDataset": {
51670
+ capName: "training-provider",
51671
+ capScope: "system",
51672
+ addonId: null,
51673
+ access: "create"
51674
+ },
51675
+ "trainingProvider.validateCredentials": {
51676
+ capName: "training-provider",
51677
+ capScope: "system",
51678
+ addonId: null,
51679
+ access: "create"
51680
+ },
50176
51681
  "turnProvider.getTurnServers": {
50177
51682
  capName: "turn-provider",
50178
51683
  capScope: "system",
@@ -50197,12 +51702,6 @@ Object.freeze({
50197
51702
  addonId: null,
50198
51703
  access: "create"
50199
51704
  },
50200
- "userManagement.createApiKey": {
50201
- capName: "user-management",
50202
- capScope: "system",
50203
- addonId: null,
50204
- access: "create"
50205
- },
50206
51705
  "userManagement.createScopedToken": {
50207
51706
  capName: "user-management",
50208
51707
  capScope: "system",
@@ -50239,12 +51738,6 @@ Object.freeze({
50239
51738
  addonId: null,
50240
51739
  access: "view"
50241
51740
  },
50242
- "userManagement.linkExternalIdentity": {
50243
- capName: "user-management",
50244
- capScope: "system",
50245
- addonId: null,
50246
- access: "create"
50247
- },
50248
51741
  "userManagement.listApiKeys": {
50249
51742
  capName: "user-management",
50250
51743
  capScope: "system",
@@ -50347,12 +51840,6 @@ Object.freeze({
50347
51840
  addonId: null,
50348
51841
  access: "create"
50349
51842
  },
50350
- "userManagement.validateApiKey": {
50351
- capName: "user-management",
50352
- capScope: "system",
50353
- addonId: null,
50354
- access: "view"
50355
- },
50356
51843
  "userManagement.validateCredentials": {
50357
51844
  capName: "user-management",
50358
51845
  capScope: "system",
@@ -54466,6 +55953,11 @@ Object.freeze({
54466
55953
  form: "single",
54467
55954
  optional: false
54468
55955
  }],
55956
+ "training.canaryResult": [{
55957
+ name: "deviceIds",
55958
+ form: "array",
55959
+ optional: false
55960
+ }],
54469
55961
  "update.getStatus": [{
54470
55962
  name: "deviceId",
54471
55963
  form: "single",