@camstack/addon-mqtt-broker 1.2.121 → 1.2.122

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.
@@ -5417,7 +5417,7 @@ var ZodIssueCode = {
5417
5417
  var ZodFirstPartyTypeKind;
5418
5418
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
5419
5419
  //#endregion
5420
- //#region ../types/dist/sleep-DujUvOcb.mjs
5420
+ //#region ../types/dist/sleep-r3RWkGVx.mjs
5421
5421
  /**
5422
5422
  * The audio chunk plane's byte format, and the ONE expansion from a coded
5423
5423
  * window to float samples (D455).
@@ -5534,7 +5534,7 @@ function isKeychainStoredField(field) {
5534
5534
  var SECRET_CLEAR = { $secretClear: true };
5535
5535
  /** The `'***'` token D634 redaction writes for non-admins. */
5536
5536
  var LEGACY_DEVICE_REDACTION = "***";
5537
- function isRecord$1(value) {
5537
+ function isRecord$2(value) {
5538
5538
  return typeof value === "object" && value !== null && !Array.isArray(value);
5539
5539
  }
5540
5540
  function makeSecretMarker(ref) {
@@ -5545,12 +5545,12 @@ function makeSecretMarker(ref) {
5545
5545
  }
5546
5546
  /** A stored marker: an object whose `$secret` is a non-empty string. */
5547
5547
  function isSecretMarker(value) {
5548
- if (!isRecord$1(value)) return false;
5548
+ if (!isRecord$2(value)) return false;
5549
5549
  const ref = value["$secret"];
5550
5550
  return typeof ref === "string" && ref.length > 0;
5551
5551
  }
5552
5552
  function isSecretClear(value) {
5553
- return isRecord$1(value) && value["$secretClear"] === true;
5553
+ return isRecord$2(value) && value["$secretClear"] === true;
5554
5554
  }
5555
5555
  /**
5556
5556
  * The UI view of a stored secret field value: a marker becomes "set", inline
@@ -6066,6 +6066,13 @@ function globalSecretScope() {
6066
6066
  function encodeSegment(value) {
6067
6067
  return encodeURIComponent(value);
6068
6068
  }
6069
+ function decodeSegment(value) {
6070
+ try {
6071
+ return decodeURIComponent(value);
6072
+ } catch {
6073
+ return null;
6074
+ }
6075
+ }
6069
6076
  /**
6070
6077
  * The field path of a value inside an array item, addressed by the item's id:
6071
6078
  * `arrayItemFieldPath('providers', 'authentik', 'clientSecret')` →
@@ -6074,6 +6081,75 @@ function encodeSegment(value) {
6074
6081
  function arrayItemFieldPath(arrayKey, itemId, fieldKey) {
6075
6082
  return `${arrayKey}[${encodeSegment(itemId)}].${fieldKey}`;
6076
6083
  }
6084
+ function parseScope(segments) {
6085
+ switch (segments[0]) {
6086
+ case "global": return {
6087
+ scope: GLOBAL_SCOPE,
6088
+ used: 1
6089
+ };
6090
+ case "node": {
6091
+ const nodeId = segments[1] !== void 0 ? decodeSegment(segments[1]) : null;
6092
+ return nodeId === null || nodeId.length === 0 ? null : {
6093
+ scope: {
6094
+ kind: "node",
6095
+ nodeId
6096
+ },
6097
+ used: 2
6098
+ };
6099
+ }
6100
+ case "device": {
6101
+ const raw = segments[1];
6102
+ if (raw === void 0 || !/^\d+$/.test(raw)) return null;
6103
+ return {
6104
+ scope: {
6105
+ kind: "device",
6106
+ deviceId: Number(raw)
6107
+ },
6108
+ used: 2
6109
+ };
6110
+ }
6111
+ case "integration": {
6112
+ const id = segments[1] !== void 0 ? decodeSegment(segments[1]) : null;
6113
+ return id === null || id.length === 0 ? null : {
6114
+ scope: {
6115
+ kind: "integration",
6116
+ integrationId: id
6117
+ },
6118
+ used: 2
6119
+ };
6120
+ }
6121
+ case "row": {
6122
+ const collection = segments[1] !== void 0 ? decodeSegment(segments[1]) : null;
6123
+ const rowId = segments[2] !== void 0 ? decodeSegment(segments[2]) : null;
6124
+ if (collection === null || rowId === null || collection.length === 0 || rowId.length === 0) return null;
6125
+ return {
6126
+ scope: {
6127
+ kind: "row",
6128
+ collection,
6129
+ rowId
6130
+ },
6131
+ used: 3
6132
+ };
6133
+ }
6134
+ default: return null;
6135
+ }
6136
+ }
6137
+ /** Take a ref apart; `null` when it is not a well-formed ref. */
6138
+ function parseSecretRef(ref) {
6139
+ if (!ref.startsWith("secret://")) return null;
6140
+ const segments = ref.slice(9).split("/");
6141
+ const owner = segments[0] !== void 0 ? decodeSegment(segments[0]) : null;
6142
+ if (owner === null || owner.length === 0) return null;
6143
+ const parsed = parseScope(segments.slice(1));
6144
+ if (parsed === null) return null;
6145
+ const fieldPath = segments.slice(1 + parsed.used).join("/");
6146
+ if (fieldPath.length === 0) return null;
6147
+ return {
6148
+ owner,
6149
+ scope: parsed.scope,
6150
+ fieldPath
6151
+ };
6152
+ }
6077
6153
  /** A write to a secret path could not be stored in the keychain, so it was refused. */
6078
6154
  var KeychainWriteRefusedError = class extends Error {
6079
6155
  fieldPath;
@@ -6084,7 +6160,7 @@ var KeychainWriteRefusedError = class extends Error {
6084
6160
  }
6085
6161
  };
6086
6162
  var KEEP = { kind: "keep" };
6087
- function isRecord(value) {
6163
+ function isRecord$1(value) {
6088
6164
  return typeof value === "object" && value !== null && !Array.isArray(value);
6089
6165
  }
6090
6166
  function defaultMintId() {
@@ -6097,7 +6173,7 @@ function collectSecretMarkerRefs(value, out = []) {
6097
6173
  return out;
6098
6174
  }
6099
6175
  if (Array.isArray(value)) for (const item of value) collectSecretMarkerRefs(item, out);
6100
- else if (isRecord(value)) for (const child of Object.values(value)) collectSecretMarkerRefs(child, out);
6176
+ else if (isRecord$1(value)) for (const child of Object.values(value)) collectSecretMarkerRefs(child, out);
6101
6177
  return out;
6102
6178
  }
6103
6179
  async function storedValueEquals(secrets, marker, candidate) {
@@ -6152,7 +6228,7 @@ function rowId(row, idKey) {
6152
6228
  return null;
6153
6229
  }
6154
6230
  async function writeArray(ctx, node, incoming, stored, fieldPath) {
6155
- const storedRows = Array.isArray(stored) ? stored.filter(isRecord) : [];
6231
+ const storedRows = Array.isArray(stored) ? stored.filter(isRecord$1) : [];
6156
6232
  if (!Array.isArray(incoming)) {
6157
6233
  ctx.deletes.push(...collectSecretMarkerRefs(storedRows));
6158
6234
  return {
@@ -6168,7 +6244,7 @@ async function writeArray(ctx, node, incoming, stored, fieldPath) {
6168
6244
  const kept = /* @__PURE__ */ new Set();
6169
6245
  const rows = [];
6170
6246
  for (const row of incoming) {
6171
- if (!isRecord(row)) {
6247
+ if (!isRecord$1(row)) {
6172
6248
  rows.push(row);
6173
6249
  continue;
6174
6250
  }
@@ -6193,7 +6269,7 @@ async function writeNode(ctx, node, incoming, stored, fieldPath) {
6193
6269
  case "leaf": return writeLeaf(ctx, incoming, stored, fieldPath);
6194
6270
  case "array": return writeArray(ctx, node, incoming, stored, fieldPath);
6195
6271
  case "object": {
6196
- if (!isRecord(incoming)) {
6272
+ if (!isRecord$1(incoming)) {
6197
6273
  if (incoming === void 0) return KEEP;
6198
6274
  ctx.deletes.push(...collectSecretMarkerRefs(stored));
6199
6275
  return {
@@ -6201,7 +6277,7 @@ async function writeNode(ctx, node, incoming, stored, fieldPath) {
6201
6277
  value: incoming
6202
6278
  };
6203
6279
  }
6204
- const storedObj = isRecord(stored) ? stored : {};
6280
+ const storedObj = isRecord$1(stored) ? stored : {};
6205
6281
  return {
6206
6282
  kind: "value",
6207
6283
  value: await writeMembers(ctx, node.children, incoming, storedObj, (m) => `${fieldPath}.${m}`)
@@ -6260,12 +6336,19 @@ async function transformSecretWrite(input) {
6260
6336
  }
6261
6337
  };
6262
6338
  }
6339
+ /** Is `ref` one of `owner`'s refs? */
6340
+ function isSecretRefOwnedBy(ref, owner) {
6341
+ return parseSecretRef(ref)?.owner === owner;
6342
+ }
6263
6343
  /**
6264
6344
  * Replace every marker in `value` with its keychain value. Returns the SAME
6265
6345
  * reference when there is no marker (no allocation, no keychain call).
6266
6346
  */
6267
- async function resolveSecretMarkers(value, secrets) {
6268
- const refs = collectSecretMarkerRefs(value);
6347
+ async function resolveSecretMarkers(value, secrets, options = {}) {
6348
+ const keepMarker = options.unresolved === "keep-marker";
6349
+ const owner = options.ownedBy;
6350
+ const inScope = (ref) => owner === void 0 || isSecretRefOwnedBy(ref, owner);
6351
+ const refs = collectSecretMarkerRefs(value).filter(inScope);
6269
6352
  if (refs.length === 0) return {
6270
6353
  value,
6271
6354
  unresolved: []
@@ -6289,10 +6372,18 @@ async function resolveSecretMarkers(value, secrets) {
6289
6372
  }
6290
6373
  const substitute = (v) => {
6291
6374
  if (isSecretMarker(v)) {
6375
+ if (!inScope(v.$secret)) return {
6376
+ keep: true,
6377
+ value: v
6378
+ };
6292
6379
  const answer = answers[v.$secret];
6293
- return answer?.kind === "value" ? {
6380
+ if (answer?.kind === "value") return {
6294
6381
  keep: true,
6295
6382
  value: answer.value
6383
+ };
6384
+ return keepMarker ? {
6385
+ keep: true,
6386
+ value: v
6296
6387
  } : {
6297
6388
  keep: false,
6298
6389
  value: void 0
@@ -6309,7 +6400,7 @@ async function resolveSecretMarkers(value, secrets) {
6309
6400
  value: items
6310
6401
  };
6311
6402
  }
6312
- if (isRecord(v)) {
6403
+ if (isRecord$1(v)) {
6313
6404
  const out = {};
6314
6405
  for (const [k, child] of Object.entries(v)) {
6315
6406
  const s = substitute(child);
@@ -6330,14 +6421,152 @@ async function resolveSecretMarkers(value, secrets) {
6330
6421
  unresolved
6331
6422
  };
6332
6423
  }
6333
- function touchesTree(tree, patch) {
6334
- if (tree.size === 0) return false;
6335
- for (const key of Object.keys(patch)) {
6336
- const at = key.indexOf("@");
6337
- if (tree.has(at > 0 ? key.slice(0, at) : key)) return true;
6424
+ /** An addon tried to replace a stored secret it could not read. Nothing was written. */
6425
+ var SecretOverwriteRefusedError = class extends Error {
6426
+ ref;
6427
+ reason;
6428
+ constructor(ref, reason) {
6429
+ 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.`);
6430
+ this.ref = ref;
6431
+ this.reason = reason;
6432
+ this.name = "SecretOverwriteRefusedError";
6433
+ }
6434
+ };
6435
+ function isRecord(value) {
6436
+ return typeof value === "object" && value !== null && !Array.isArray(value);
6437
+ }
6438
+ function resolvedValue(pass, marker) {
6439
+ const answer = pass.answers[marker.$secret];
6440
+ return answer?.kind === "value" ? answer.value : null;
6441
+ }
6442
+ async function atMarker(pass, incoming, stored) {
6443
+ if (incoming === null) return stored;
6444
+ if (typeof incoming !== "string") return incoming;
6445
+ if (incoming === resolvedValue(pass, stored)) return stored;
6446
+ const intent = classifySecretWrite(incoming);
6447
+ if (intent.kind !== "set") return stored;
6448
+ const ref = stored.$secret;
6449
+ if (!isSecretRefOwnedBy(ref, pass.secrets.owner)) return incoming;
6450
+ const answer = pass.answers[ref];
6451
+ 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);
6452
+ try {
6453
+ await pass.secrets.put(ref, intent.value);
6454
+ } catch (err) {
6455
+ throw new KeychainWriteRefusedError(ref, err);
6456
+ }
6457
+ pass.changedRefs.push(ref);
6458
+ return stored;
6459
+ }
6460
+ function inArray(pass, incoming, stored) {
6461
+ return incoming.map((item, index) => {
6462
+ const twin = stored[index];
6463
+ if (isSecretMarker(twin)) return typeof item === "string" && item === resolvedValue(pass, twin) ? twin : item;
6464
+ if (isRecord(item) && isRecord(twin)) return inArrayRow(pass, item, twin);
6465
+ if (Array.isArray(item) && Array.isArray(twin)) return inArray(pass, item, twin);
6466
+ return item;
6467
+ });
6468
+ }
6469
+ function inArrayRow(pass, incoming, stored) {
6470
+ const out = { ...incoming };
6471
+ for (const [key, value] of Object.entries(incoming)) {
6472
+ const twin = stored[key];
6473
+ if (isSecretMarker(twin)) {
6474
+ if (typeof value === "string" && value === resolvedValue(pass, twin)) out[key] = twin;
6475
+ } else if (isRecord(value) && isRecord(twin)) out[key] = inArrayRow(pass, value, twin);
6476
+ else if (Array.isArray(value) && Array.isArray(twin)) out[key] = inArray(pass, value, twin);
6477
+ }
6478
+ return out;
6479
+ }
6480
+ async function walk(pass, incoming, stored) {
6481
+ if (isSecretMarker(stored)) return atMarker(pass, incoming, stored);
6482
+ if (Array.isArray(incoming) && Array.isArray(stored)) return inArray(pass, incoming, stored);
6483
+ if (!isRecord(incoming) || !isRecord(stored)) return incoming;
6484
+ const out = { ...incoming };
6485
+ for (const [key, value] of Object.entries(incoming)) out[key] = await walk(pass, value, stored[key]);
6486
+ return out;
6487
+ }
6488
+ /** Restore markers a write-back carries as values. See the file doc. */
6489
+ async function restoreUnchangedSecrets(input) {
6490
+ const refs = [];
6491
+ for (const key of Object.keys(input.patch)) collectSecretMarkerRefs(input.stored[key], refs);
6492
+ const owned = refs.filter((ref) => isSecretRefOwnedBy(ref, input.secrets.owner));
6493
+ if (owned.length === 0) return {
6494
+ patch: input.patch,
6495
+ changedRefs: []
6496
+ };
6497
+ const pass = {
6498
+ secrets: input.secrets,
6499
+ answers: await input.secrets.resolve([...new Set(owned)]),
6500
+ operatorWrite: input.operatorWrite,
6501
+ changedRefs: []
6502
+ };
6503
+ const out = {};
6504
+ for (const [key, value] of Object.entries(input.patch)) out[key] = await walk(pass, value, input.stored[key]);
6505
+ return {
6506
+ patch: out,
6507
+ changedRefs: pass.changedRefs
6508
+ };
6509
+ }
6510
+ /** Structural equality over JSON-shaped values (key order does not matter). */
6511
+ function isJsonEqual(a, b) {
6512
+ if (Object.is(a, b)) return true;
6513
+ if (Array.isArray(a)) return Array.isArray(b) && a.length === b.length && a.every((v, i) => isJsonEqual(v, b[i]));
6514
+ if (isRecord(a) && isRecord(b)) {
6515
+ const keys = Object.keys(a);
6516
+ if (keys.length !== Object.keys(b).length) return false;
6517
+ return keys.every((k) => Object.prototype.hasOwnProperty.call(b, k) && isJsonEqual(a[k], b[k]));
6338
6518
  }
6339
6519
  return false;
6340
6520
  }
6521
+ /** The patch without the keys whose value already equals the stored one. */
6522
+ function dropUnchangedKeys(patch, stored) {
6523
+ const out = {};
6524
+ for (const [key, value] of Object.entries(patch)) {
6525
+ if (Object.prototype.hasOwnProperty.call(stored, key) && isJsonEqual(value, stored[key])) continue;
6526
+ out[key] = value;
6527
+ }
6528
+ return out;
6529
+ }
6530
+ /** The top-level keys of a blob that hold at least one of `owner`'s markers. */
6531
+ function markerKeysOf(blob, owner) {
6532
+ const keys = /* @__PURE__ */ new Set();
6533
+ for (const [key, value] of Object.entries(blob)) if (collectSecretMarkerRefs(value).some((ref) => isSecretRefOwnedBy(ref, owner))) keys.add(key);
6534
+ return keys;
6535
+ }
6536
+ function nodeFromStored(value, owner) {
6537
+ if (isSecretMarker(value)) return isSecretRefOwnedBy(value.$secret, owner) ? { kind: "leaf" } : null;
6538
+ if (!isRecord(value)) return null;
6539
+ const children = /* @__PURE__ */ new Map();
6540
+ for (const [key, child] of Object.entries(value)) {
6541
+ const node = nodeFromStored(child, owner);
6542
+ if (node !== null) children.set(key, node);
6543
+ }
6544
+ return children.size > 0 ? {
6545
+ kind: "object",
6546
+ children
6547
+ } : null;
6548
+ }
6549
+ /**
6550
+ * The declared secret tree, widened by every place the STORED blob holds a
6551
+ * marker under one of `keys` — so a marker the schema no longer declares (or
6552
+ * never declared: Wyze before b4906cec6) still gets the save path's
6553
+ * KEEP / SET / CLEAR semantics instead of being overwritten by whatever the
6554
+ * addon writes. Markers inside arrays are not added: a row has no id field to
6555
+ * match by unless the schema declares one. Only `owner`'s markers count: a
6556
+ * builtin that keeps another addon's marker (device-manager) never takes it
6557
+ * over.
6558
+ */
6559
+ function widenTreeWithStoredMarkers(declared, stored, keys, owner) {
6560
+ const added = /* @__PURE__ */ new Map();
6561
+ for (const key of keys) {
6562
+ const at = key.indexOf("@");
6563
+ const base = at > 0 ? key.slice(0, at) : key;
6564
+ if (declared.has(base) || added.has(base)) continue;
6565
+ const node = nodeFromStored(stored[key], owner);
6566
+ if (node !== null) added.set(base, node);
6567
+ }
6568
+ return added.size === 0 ? declared : new Map([...declared, ...added]);
6569
+ }
6341
6570
  /** The blob as stored now; a failed read REFUSES the write instead of guessing. */
6342
6571
  async function readStoredAddonBlob(raw) {
6343
6572
  const threeWay = raw.readAddonStoreResult;
@@ -6346,7 +6575,41 @@ async function readStoredAddonBlob(raw) {
6346
6575
  if (result.kind === "failed") throw new Error(`settings write refused: the stored blob could not be read (${result.error})`);
6347
6576
  return result.kind === "missing" ? {} : result.value;
6348
6577
  }
6349
- function createSecretAwareSettings(raw, opts) {
6578
+ function touchesTree(tree, patch) {
6579
+ if (tree.size === 0) return false;
6580
+ for (const key of Object.keys(patch)) {
6581
+ const at = key.indexOf("@");
6582
+ if (tree.has(at > 0 ? key.slice(0, at) : key)) return true;
6583
+ }
6584
+ return false;
6585
+ }
6586
+ /**
6587
+ * Which top-level keys of each store held markers when last seen. `undefined`
6588
+ * for a store not seen yet: its first write reads it, to be safe.
6589
+ */
6590
+ var MarkerKeyIndex = class {
6591
+ owner;
6592
+ byStore = /* @__PURE__ */ new Map();
6593
+ constructor(owner) {
6594
+ this.owner = owner;
6595
+ }
6596
+ seen(store, blob) {
6597
+ this.byStore.set(store, markerKeysOf(blob, this.owner));
6598
+ }
6599
+ wrote(store, patch) {
6600
+ const keys = this.byStore.get(store);
6601
+ if (keys === void 0) return;
6602
+ const now = markerKeysOf(patch, this.owner);
6603
+ for (const key of Object.keys(patch)) if (now.has(key)) keys.add(key);
6604
+ else keys.delete(key);
6605
+ }
6606
+ mayHoldMarkers(store, patch) {
6607
+ const keys = this.byStore.get(store);
6608
+ if (keys === void 0) return true;
6609
+ return Object.keys(patch).some((key) => keys.has(key));
6610
+ }
6611
+ };
6612
+ function createHandle(raw, opts) {
6350
6613
  const chains = /* @__PURE__ */ new Map();
6351
6614
  const serialize = (key, fn) => {
6352
6615
  const next = (chains.get(key) ?? Promise.resolve()).then(fn, fn);
@@ -6357,46 +6620,130 @@ function createSecretAwareSettings(raw, opts) {
6357
6620
  });
6358
6621
  return next;
6359
6622
  };
6360
- const write = async (chainKey, tree, scope, patch, readStored, rawWrite) => {
6361
- if (!touchesTree(tree, patch)) return rawWrite(patch);
6362
- return serialize(chainKey, async () => {
6623
+ const index = new MarkerKeyIndex(opts.secrets.owner);
6624
+ const resolveRead = async (store, blob) => {
6625
+ index.seen(store, blob);
6626
+ const { value, unresolved } = await resolveSecretMarkers(blob, opts.secrets, {
6627
+ unresolved: "keep-marker",
6628
+ ownedBy: opts.secrets.owner
6629
+ });
6630
+ if (unresolved.length > 0) opts.onUnresolved?.(unresolved);
6631
+ return value;
6632
+ };
6633
+ const write = async (store, declared, scope, patch, readStored, rawWrite) => {
6634
+ if (!touchesTree(declared, patch) && !index.mayHoldMarkers(store, patch)) {
6635
+ await rawWrite(patch);
6636
+ index.wrote(store, patch);
6637
+ return { changed: true };
6638
+ }
6639
+ return serialize(store, async () => {
6363
6640
  const stored = await readStored();
6641
+ index.seen(store, stored);
6642
+ const operatorWrite = opts.isOperatorWrite?.() === true;
6643
+ const restored = await restoreUnchangedSecrets({
6644
+ patch,
6645
+ stored,
6646
+ secrets: opts.secrets,
6647
+ operatorWrite
6648
+ });
6364
6649
  const result = await transformSecretWrite({
6365
- tree,
6650
+ tree: widenTreeWithStoredMarkers(declared, stored, Object.keys(restored.patch), opts.secrets.owner),
6366
6651
  secrets: opts.secrets,
6367
- patch,
6652
+ patch: restored.patch,
6368
6653
  stored,
6369
6654
  ...scope !== void 0 ? { scope } : {},
6370
- operatorWrite: opts.isOperatorWrite?.() === true
6655
+ operatorWrite
6371
6656
  });
6372
- if (Object.keys(result.patch).length > 0) await rawWrite(result.patch);
6657
+ const effective = dropUnchangedKeys(result.patch, stored);
6658
+ const wroteBlob = Object.keys(effective).length > 0;
6659
+ if (wroteBlob) {
6660
+ await rawWrite(effective);
6661
+ index.wrote(store, effective);
6662
+ }
6373
6663
  const { orphaned } = await result.afterWrite();
6374
6664
  if (orphaned.length > 0) opts.onOrphaned(orphaned);
6665
+ return { changed: wroteBlob || restored.changedRefs.length > 0 };
6375
6666
  });
6376
6667
  };
6377
- const wrapped = {
6378
- writeAddonStore: (patch) => write("addon", opts.addonTree(), void 0, patch, () => readStoredAddonBlob(raw), (p) => raw.writeAddonStore(p)),
6379
- writeDeviceStore: (deviceId, patch) => write(`device:${deviceId}`, opts.deviceTree(), {
6380
- kind: "device",
6381
- deviceId
6382
- }, patch, () => raw.readDeviceStore(deviceId), (p) => raw.writeDeviceStore(deviceId, p))
6383
- };
6384
- return new Proxy(raw, { get(target, prop, receiver) {
6385
- if (prop === "writeAddonStore") return wrapped.writeAddonStore;
6386
- if (prop === "writeDeviceStore") return wrapped.writeDeviceStore;
6387
- const value = Reflect.get(target, prop, receiver);
6388
- return typeof value === "function" ? value.bind(target) : value;
6389
- } });
6668
+ const writeAddon = (patch) => write("addon", opts.addonTree(), void 0, patch, () => readStoredAddonBlob(raw), (p) => raw.writeAddonStore(p));
6669
+ const readAddonStoreResult = raw.readAddonStoreResult;
6670
+ const readAddonStoreKeyResult = raw.readAddonStoreKeyResult;
6671
+ const readDeviceStoreBatch = raw.readDeviceStoreBatch;
6672
+ const overrides = {
6673
+ readAddonStore: async () => resolveRead("addon", await raw.readAddonStore()),
6674
+ ...readAddonStoreResult !== void 0 ? { readAddonStoreResult: async () => {
6675
+ const result = await readAddonStoreResult.call(raw);
6676
+ return result.kind === "value" ? {
6677
+ kind: "value",
6678
+ value: await resolveRead("addon", result.value)
6679
+ } : result;
6680
+ } } : {},
6681
+ ...readAddonStoreKeyResult !== void 0 ? { readAddonStoreKeyResult: async (key) => {
6682
+ const result = await readAddonStoreKeyResult.call(raw, key);
6683
+ if (result.kind !== "present") return result;
6684
+ const { value, unresolved } = await resolveSecretMarkers({ [key]: result.value }, opts.secrets, {
6685
+ unresolved: "keep-marker",
6686
+ ownedBy: opts.secrets.owner
6687
+ });
6688
+ if (unresolved.length > 0) opts.onUnresolved?.(unresolved);
6689
+ return {
6690
+ kind: "present",
6691
+ value: value[key]
6692
+ };
6693
+ } } : {},
6694
+ readDeviceStore: async (deviceId) => resolveRead(`device:${deviceId}`, await raw.readDeviceStore(deviceId)),
6695
+ ...readDeviceStoreBatch !== void 0 ? { readDeviceStoreBatch: async (deviceIds) => {
6696
+ const rows = await readDeviceStoreBatch.call(raw, deviceIds);
6697
+ const out = /* @__PURE__ */ new Map();
6698
+ for (const [deviceId, blob] of rows) out.set(deviceId, await resolveRead(`device:${deviceId}`, blob));
6699
+ return out;
6700
+ } } : {},
6701
+ writeAddonStore: async (patch) => {
6702
+ await writeAddon(patch);
6703
+ },
6704
+ writeDeviceStore: async (deviceId, patch) => {
6705
+ await write(`device:${deviceId}`, opts.deviceTree(), {
6706
+ kind: "device",
6707
+ deviceId
6708
+ }, patch, () => raw.readDeviceStore(deviceId), (p) => raw.writeDeviceStore(deviceId, p));
6709
+ }
6710
+ };
6711
+ return {
6712
+ settings: new Proxy(raw, { get(target, prop, receiver) {
6713
+ if (typeof prop === "string" && Object.prototype.hasOwnProperty.call(overrides, prop)) return Reflect.get(overrides, prop);
6714
+ const value = Reflect.get(target, prop, receiver);
6715
+ return typeof value === "function" ? value.bind(target) : value;
6716
+ } }),
6717
+ raw: {
6718
+ readAddonStore: async () => {
6719
+ const blob = await raw.readAddonStore();
6720
+ index.seen("addon", blob);
6721
+ return blob;
6722
+ },
6723
+ readDeviceStore: async (deviceId) => {
6724
+ const blob = await raw.readDeviceStore(deviceId);
6725
+ index.seen(`device:${deviceId}`, blob);
6726
+ return blob;
6727
+ }
6728
+ },
6729
+ writeAddonStore: writeAddon
6730
+ };
6390
6731
  }
6391
- /** The context the addon sees: identical, except that its settings writes are secret-aware. */
6392
- function withSecretAwareSettings(context, opts) {
6732
+ /** The context the addon sees, plus the private raw view and write outcome. */
6733
+ function createSecretAwareContext(context, opts) {
6393
6734
  const raw = context.settings;
6394
- if (raw === void 0) return context;
6395
- const settings = createSecretAwareSettings(raw, opts);
6396
- return new Proxy(context, { get(target, prop, receiver) {
6397
- if (prop === "settings") return settings;
6398
- return Reflect.get(target, prop, receiver);
6399
- } });
6735
+ if (raw === void 0) return {
6736
+ context,
6737
+ handle: null
6738
+ };
6739
+ const handle = createHandle(raw, opts);
6740
+ return {
6741
+ context: new Proxy(context, { get(target, prop, receiver) {
6742
+ if (prop === "settings") return handle.settings;
6743
+ return Reflect.get(target, prop, receiver);
6744
+ } }),
6745
+ handle
6746
+ };
6400
6747
  }
6401
6748
  var LEAF = { kind: "leaf" };
6402
6749
  var DEFAULT_ITEM_ID_KEY = "id";
@@ -6571,6 +6918,14 @@ var BaseAddon = class {
6571
6918
  _secretChangeUnsub = null;
6572
6919
  /** >0 while an OPERATOR's settings write is being applied. */
6573
6920
  _operatorWriteDepth = 0;
6921
+ /**
6922
+ * The keychain-aware settings handle (D798). Its `raw` view is the ONLY way
6923
+ * to the marker-bearing blobs and stays private to this class: the form
6924
+ * hydrate and config resolution need markers, addon code never does.
6925
+ */
6926
+ _secretSettings = null;
6927
+ /** Refs an addon-facing read could not resolve — each is logged once per process. */
6928
+ _loggedUnresolvedReads = /* @__PURE__ */ new Set();
6574
6929
  constructor(defaults) {
6575
6930
  this.defaults = defaults;
6576
6931
  this._config = { ...defaults };
@@ -6607,13 +6962,21 @@ var BaseAddon = class {
6607
6962
  }
6608
6963
  async initialize(context) {
6609
6964
  const secrets = context.secrets;
6610
- this._ctx = secrets !== void 0 ? withSecretAwareSettings(context, {
6611
- secrets,
6612
- addonTree: () => this.addonSecretTree(),
6613
- deviceTree: () => this.deviceSecretTree(),
6614
- onOrphaned: (refs) => context.logger.warn("keychain refs dropped by a settings write could not be deleted", { meta: { refs: [...refs] } }),
6615
- isOperatorWrite: () => this._operatorWriteDepth > 0
6616
- }) : context;
6965
+ if (secrets !== void 0) {
6966
+ const { context: wrapped, handle } = createSecretAwareContext(context, {
6967
+ secrets,
6968
+ addonTree: () => this.addonSecretTree(),
6969
+ deviceTree: () => this.deviceSecretTree(),
6970
+ onOrphaned: (refs) => context.logger.warn("keychain refs dropped by a settings write could not be deleted", { meta: { refs: [...refs] } }),
6971
+ isOperatorWrite: () => this._operatorWriteDepth > 0,
6972
+ onUnresolved: (unresolved) => this.logUnresolvedRead(unresolved)
6973
+ });
6974
+ this._ctx = wrapped;
6975
+ this._secretSettings = handle;
6976
+ } else {
6977
+ this._ctx = context;
6978
+ this._secretSettings = null;
6979
+ }
6617
6980
  await this.resolveConfig();
6618
6981
  if (secrets !== void 0) this._secretChangeUnsub = secrets.onChange((ref) => {
6619
6982
  if (this._configSecretRefs.has(ref)) this.scheduleSecretReresolve(SECRET_CHANGE_DEBOUNCE_MS);
@@ -6730,11 +7093,8 @@ var BaseAddon = class {
6730
7093
  async getGlobalSettings(overlay, cap, nodeId) {
6731
7094
  const schema = this.globalSettingsSchema(cap);
6732
7095
  if (!schema) return { sections: [] };
6733
- const projected = await this.resolveGlobalStore(nodeId, cap);
6734
- return hydrateSchema(schema, overlay ? {
6735
- ...projected,
6736
- ...overlay
6737
- } : projected, { inlineSecretsAsViews: true });
7096
+ const projected = await this.readRawProjectedStore(nodeId, cap);
7097
+ return hydrateSchema(schema, overlay ? await this.overlayKeepingMarkers(projected, overlay) : projected, { inlineSecretsAsViews: true });
6738
7098
  }
6739
7099
  /**
6740
7100
  * The integration-level view of this addon's settings: exactly the sections
@@ -6779,7 +7139,7 @@ var BaseAddon = class {
6779
7139
  });
6780
7140
  }
6781
7141
  if (sections.length === 0) return null;
6782
- const projected = await this.resolveGlobalStore(nodeId);
7142
+ const projected = await this.readRawProjectedStore(nodeId);
6783
7143
  return hydrateSchema({
6784
7144
  ...schema,
6785
7145
  sections
@@ -6796,12 +7156,50 @@ var BaseAddon = class {
6796
7156
  * the store for custom option logic (option narrowing, value snapping) to
6797
7157
  * read it per-node — never `ctx.settings.readAddonStore()` directly.
6798
7158
  * `nodeId` omitted ⇒ the local node (node-blind injection from ctx).
7159
+ *
7160
+ * Keychain values come back RESOLVED (D798): a secret reads as its value,
7161
+ * never as a `{ $secret }` marker. One the keychain cannot serve right now
7162
+ * stays a marker — "stored, unavailable" (`isSecretMarker()` is true, and it
7163
+ * is listed in {@link unresolvedSecrets}) — never `''` and never absent, so
7164
+ * it cannot be mistaken for "nothing stored, mint a new one". Writing the
7165
+ * resolved blob back is a no-op for every unchanged secret.
6799
7166
  */
6800
7167
  async resolveGlobalStore(nodeId, cap) {
6801
7168
  const raw = await this._ctx?.settings?.readAddonStore() ?? {};
7169
+ return this.projectForNode(raw, nodeId, cap);
7170
+ }
7171
+ projectForNode(store, nodeId, cap) {
6802
7172
  const keys = this.perNodeKeys(cap);
6803
7173
  const node = normalizeNodeId(nodeId ?? this._ctx?.kernel?.localNodeId);
6804
- return keys.size > 0 ? projectStore(raw, keys, node) : raw;
7174
+ return keys.size > 0 ? projectStore(store, keys, node) : store;
7175
+ }
7176
+ /** The PROJECTED store with its markers — the form hydrate only (D798). */
7177
+ async readRawProjectedStore(nodeId, cap) {
7178
+ const raw = await this.rawSettings()?.readAddonStore() ?? {};
7179
+ return this.projectForNode(raw, nodeId, cap);
7180
+ }
7181
+ /**
7182
+ * `{ ...stored, ...overlay }`, except that an overlay member equal to the
7183
+ * RESOLVED stored one keeps the stored (marker-bearing) member — so a form
7184
+ * hydrated from a resolved overlay still shows a secret as "set", never as
7185
+ * its value.
7186
+ */
7187
+ async overlayKeepingMarkers(stored, overlay) {
7188
+ const secrets = this._ctx?.secrets;
7189
+ const merged = {
7190
+ ...stored,
7191
+ ...overlay
7192
+ };
7193
+ if (secrets === void 0 || collectSecretMarkerRefs(stored).length === 0) return merged;
7194
+ const { value: resolved } = await resolveSecretMarkers(stored, secrets, {
7195
+ unresolved: "keep-marker",
7196
+ ownedBy: secrets.owner
7197
+ });
7198
+ for (const key of Object.keys(overlay)) {
7199
+ if (collectSecretMarkerRefs(stored[key]).length === 0) continue;
7200
+ if (isJsonEqual(overlay[key], resolved[key])) merged[key] = stored[key];
7201
+ }
7202
+ return merged;
6805
7203
  }
6806
7204
  /**
6807
7205
  * Whether ONE global key of this addon's store was written, read three-way
@@ -6866,8 +7264,12 @@ var BaseAddon = class {
6866
7264
  async clearSecrets(keys, nodeId) {
6867
7265
  const tree = this.addonSecretTree();
6868
7266
  const keychain = this._ctx?.secrets !== void 0;
7267
+ const stored = keychain ? await this.readAddonStoreWithRetry() : {};
6869
7268
  const patch = {};
6870
- for (const key of keys) patch[key] = keychain && tree.has(key) ? SECRET_CLEAR : "";
7269
+ for (const key of keys) {
7270
+ const keychainStored = tree.has(key) || collectSecretMarkerRefs(stored[key]).length > 0;
7271
+ patch[key] = keychain && keychainStored ? SECRET_CLEAR : "";
7272
+ }
6871
7273
  await this.applyGlobalPatch(patch, nodeId);
6872
7274
  }
6873
7275
  async applyGlobalPatch(barePatch, nodeId) {
@@ -6875,7 +7277,11 @@ var BaseAddon = class {
6875
7277
  const localNode = normalizeNodeId(this._ctx?.kernel?.localNodeId);
6876
7278
  const target = normalizeNodeId(nodeId ?? this._ctx?.kernel?.localNodeId);
6877
7279
  const scoped = keys.size > 0 ? scopePatch(barePatch, keys, target) : barePatch;
6878
- await this._ctx?.settings?.writeAddonStore(scoped);
7280
+ const handle = this._secretSettings;
7281
+ if (handle !== null) {
7282
+ const { changed } = await handle.writeAddonStore(scoped);
7283
+ if (!changed) return;
7284
+ } else await this._ctx?.settings?.writeAddonStore(scoped);
6879
7285
  if (target !== localNode) return;
6880
7286
  await this.resolveConfig();
6881
7287
  await this.onConfigChanged();
@@ -6928,7 +7334,7 @@ var BaseAddon = class {
6928
7334
  async getDeviceSettings(deviceId) {
6929
7335
  const schema = this.deviceSettingsSchema();
6930
7336
  if (!schema) return { sections: [] };
6931
- return hydrateSchema(schema, await this._ctx?.settings?.readDeviceStore(deviceId) ?? {}, { inlineSecretsAsViews: true });
7337
+ return hydrateSchema(schema, await this.rawSettings()?.readDeviceStore(deviceId) ?? {}, { inlineSecretsAsViews: true });
6932
7338
  }
6933
7339
  async updateDeviceSettings(deviceId, patch) {
6934
7340
  await this._ctx?.settings?.writeDeviceStore(deviceId, patch);
@@ -7100,7 +7506,7 @@ var BaseAddon = class {
7100
7506
  key,
7101
7507
  schema,
7102
7508
  fallback,
7103
- read: async () => this.resolveStoredSecrets(await this._ctx?.settings?.readDeviceStore(deviceId) ?? {}, false),
7509
+ read: async () => this.resolveStoredSecrets(await this.rawSettings()?.readDeviceStore(deviceId) ?? {}, false),
7104
7510
  write: async (patch) => {
7105
7511
  await this._ctx?.settings?.writeDeviceStore(deviceId, patch);
7106
7512
  },
@@ -7162,6 +7568,23 @@ var BaseAddon = class {
7162
7568
  }
7163
7569
  return value;
7164
7570
  }
7571
+ /**
7572
+ * The marker-bearing settings reads (D798) — private on purpose. Without a
7573
+ * keychain the context's own view is already raw.
7574
+ */
7575
+ rawSettings() {
7576
+ return this._secretSettings?.raw ?? this._ctx?.settings;
7577
+ }
7578
+ /** An addon-facing read met markers it could not resolve: say so once per ref. */
7579
+ logUnresolvedRead(unresolved) {
7580
+ const fresh = unresolved.filter((u) => !this._loggedUnresolvedReads.has(u.ref));
7581
+ if (fresh.length === 0) return;
7582
+ for (const u of fresh) this._loggedUnresolvedReads.add(u.ref);
7583
+ 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) => ({
7584
+ ref: u.ref,
7585
+ reason: u.reason
7586
+ })) } });
7587
+ }
7165
7588
  /** Re-resolve the config (a keychain-only change, or a retry) and apply it. */
7166
7589
  scheduleSecretReresolve(delayMs) {
7167
7590
  const timerOf = delayMs === SECRET_CHANGE_DEBOUNCE_MS ? "_secretChangeTimer" : "_secretRetryTimer";
@@ -7188,7 +7611,7 @@ var BaseAddon = class {
7188
7611
  * `{}` (defaults) — the addon's first successful patch will rehydrate.
7189
7612
  */
7190
7613
  async readAddonStoreWithRetry() {
7191
- const settings = this._ctx?.settings;
7614
+ const settings = this.rawSettings();
7192
7615
  if (!settings) return {};
7193
7616
  const delaysMs = [
7194
7617
  150,
@@ -9414,6 +9837,278 @@ var CameraSwitchGroupSchema = object({
9414
9837
  fetchedAt: number()
9415
9838
  });
9416
9839
  /**
9840
+ * The trainer contract — what the hub hands the cloud trainer and what it
9841
+ * gets back (cloud training, D805+).
9842
+ *
9843
+ * The trainer (`hf/camstack-trainer`, published as the Hugging Face repo
9844
+ * `camstack/camstack-trainer`) is a separate AGPL program the hub never
9845
+ * imports: `job.json` goes in, files come out, and progress is `CAMSTACK_EVENT`
9846
+ * lines on stdout. These schemas are the hub's half of that boundary; the
9847
+ * trainer's pydantic models (and the JSON Schemas generated from them under
9848
+ * `hf/camstack-trainer/schemas/`) are the other half. A change here is a
9849
+ * change there, in the same piece of work.
9850
+ *
9851
+ * No `.default()` anywhere: defaults do not run on the addon cap path, so the
9852
+ * orchestrator fills every field of a job spec explicitly.
9853
+ */
9854
+ var TRAINING_JOB_SCHEMA = "camstack.training/v1";
9855
+ var TRAINING_RESULT_SCHEMA = "camstack.training-result/v1";
9856
+ /** What the trainer can export. Edge TPU is a later, separate image. */
9857
+ var TrainingExportSchema = _enum([
9858
+ "onnx",
9859
+ "openvino-fp16",
9860
+ "openvino-int8",
9861
+ "coreml-fp16"
9862
+ ]);
9863
+ var FloorsSchema = record(string(), number().min(0).max(1));
9864
+ object({
9865
+ schema: literal(TRAINING_JOB_SCHEMA),
9866
+ jobKey: string().uuid(),
9867
+ target: object({
9868
+ kind: literal("detector"),
9869
+ step: literal("object-detection")
9870
+ }),
9871
+ base: object({
9872
+ modelId: string().min(1),
9873
+ /** Ultralytics weights id, e.g. `yolov9m.pt`. */
9874
+ weights: string().min(1),
9875
+ imgsz: number().int().positive()
9876
+ }),
9877
+ baseline: object({
9878
+ modelId: string().min(1),
9879
+ /** The baseline ONNX the holdout comparison runs; public mirror URL. */
9880
+ onnxUrl: string().url(),
9881
+ imgsz: number().int().positive(),
9882
+ floors: FloorsSchema
9883
+ }),
9884
+ dataset: object({
9885
+ versionId: string().min(1),
9886
+ annotationHash: string(),
9887
+ /** sha256 of the uploaded archive; the trainer refuses a mismatch (exit 65). */
9888
+ sha256: string().regex(/^[0-9a-f]{64}$/)
9889
+ }),
9890
+ split: object({
9891
+ holdoutCameras: array(number().int()),
9892
+ /** When no camera is held out: the last N days of every camera. */
9893
+ holdoutLastDays: number().int().nonnegative(),
9894
+ valFraction: number().min(0).max(.5),
9895
+ seed: number().int()
9896
+ }),
9897
+ hyper: object({
9898
+ epochs: number().int().positive(),
9899
+ batch: number().int().positive(),
9900
+ lr0: number().positive(),
9901
+ /** Layers frozen from the start of the backbone; 0 = none. */
9902
+ freeze: number().int().nonnegative(),
9903
+ patience: number().int().nonnegative(),
9904
+ seed: number().int()
9905
+ }),
9906
+ replay: object({
9907
+ source: literal("coco2017"),
9908
+ count: number().int().nonnegative()
9909
+ }),
9910
+ exports: array(TrainingExportSchema).min(1),
9911
+ calibration: object({ maxFrames: number().int().positive() }),
9912
+ floors: object({
9913
+ minSupport: number().int().positive(),
9914
+ clamp: number().min(0).max(1)
9915
+ }),
9916
+ int8Gate: object({ maxMap50Drop: number().min(0).max(1) }),
9917
+ catalog: object({
9918
+ id: string().regex(/^[a-z0-9][a-z0-9-]{2,80}$/),
9919
+ name: string().min(1).max(160)
9920
+ })
9921
+ });
9922
+ /** One regular file of the bundle. An mlpackage contributes one row per member. */
9923
+ var TrainingResultFileSchema = object({
9924
+ path: string().min(1),
9925
+ bytes: number().int().nonnegative(),
9926
+ sha256: string().regex(/^[0-9a-f]{64}$/),
9927
+ format: _enum([
9928
+ "onnx",
9929
+ "openvino",
9930
+ "coreml",
9931
+ "pt"
9932
+ ]),
9933
+ variant: _enum(["base", "int8"])
9934
+ });
9935
+ var DraftFormatSchema = object({
9936
+ /** RELATIVE path inside the bundle; the hub rewrites it to `camstack-local://`. */
9937
+ url: string().min(1),
9938
+ sizeMB: number().nonnegative(),
9939
+ isDirectory: boolean().optional(),
9940
+ files: array(string()).optional(),
9941
+ runtimes: array(literal("python")).optional(),
9942
+ revision: string().min(1)
9943
+ });
9944
+ /** The trainer's half of a catalog entry; the hub completes it (labels, licence, group). */
9945
+ var TrainingCatalogDraftSchema = object({
9946
+ id: string().min(1),
9947
+ name: string().min(1),
9948
+ description: string(),
9949
+ labels: array(unknown()),
9950
+ inputSize: object({
9951
+ width: number().int().positive(),
9952
+ height: number().int().positive()
9953
+ }),
9954
+ preprocessMode: literal("letterbox"),
9955
+ defaultClassFloors: FloorsSchema,
9956
+ formats: object({
9957
+ onnx: DraftFormatSchema.optional(),
9958
+ openvino: DraftFormatSchema.optional(),
9959
+ coreml: DraftFormatSchema.optional()
9960
+ })
9961
+ });
9962
+ /** One class of one model's holdout report (the eval harness's summary). */
9963
+ var TrainingEvalClassSchema = object({
9964
+ positives: number().int(),
9965
+ floor: number().nullable(),
9966
+ tp: number().int(),
9967
+ fp: number().int(),
9968
+ fn: number().int(),
9969
+ precision: number().nullable(),
9970
+ recall: number().nullable(),
9971
+ ap50: number().nullable(),
9972
+ recallByCamera: record(string(), number().nullable()).optional(),
9973
+ recallByLight: record(string(), number().nullable()).optional(),
9974
+ fpByCamera: record(string(), number()).optional(),
9975
+ smallFound: number().int().optional(),
9976
+ smallTotal: number().int().optional()
9977
+ }).passthrough();
9978
+ var TrainingEvalReportSchema = object({
9979
+ frames: number().int(),
9980
+ classes: record(string(), TrainingEvalClassSchema)
9981
+ }).passthrough();
9982
+ /**
9983
+ * A succeeded result carries every block; a failed one carries the error and
9984
+ * whatever was known by then — the other blocks are ABSENT, not null. The
9985
+ * orchestrator checks the blocks it needs before it trusts a success.
9986
+ */
9987
+ var TrainingResultSchema = object({
9988
+ schema: literal(TRAINING_RESULT_SCHEMA),
9989
+ jobKey: string(),
9990
+ status: _enum(["succeeded", "failed"]),
9991
+ error: object({
9992
+ stage: string(),
9993
+ code: string(),
9994
+ message: string()
9995
+ }).nullable(),
9996
+ trainer: object({
9997
+ version: string(),
9998
+ revision: string()
9999
+ }),
10000
+ toolchain: record(string(), string().nullable()),
10001
+ dataset: object({
10002
+ versionId: string(),
10003
+ annotationHash: string(),
10004
+ sha256: string(),
10005
+ frames: object({
10006
+ train: number().int(),
10007
+ val: number().int(),
10008
+ holdout: number().int()
10009
+ }),
10010
+ holdoutCameras: array(number().int()),
10011
+ replayImages: number().int()
10012
+ }).optional(),
10013
+ training: object({
10014
+ epochsRun: number().int(),
10015
+ bestEpoch: number().int(),
10016
+ bestMap50: number(),
10017
+ bestMap50_95: number(),
10018
+ seconds: number()
10019
+ }).optional(),
10020
+ evaluation: object({
10021
+ holdoutFrames: number().int(),
10022
+ baseline: TrainingEvalReportSchema.nullable(),
10023
+ candidate: TrainingEvalReportSchema.nullable(),
10024
+ candidateInt8: TrainingEvalReportSchema.nullable(),
10025
+ recallDeltaByCamera: record(string(), record(string(), number())).nullable(),
10026
+ map50: record(string(), number().nullable())
10027
+ }).optional(),
10028
+ floors: object({
10029
+ baseline: FloorsSchema,
10030
+ candidate: FloorsSchema,
10031
+ candidateInt8: FloorsSchema.nullable(),
10032
+ notes: array(string())
10033
+ }).optional(),
10034
+ int8: object({
10035
+ kept: boolean(),
10036
+ map50Fp16: number().nullable(),
10037
+ map50Int8: number().nullable(),
10038
+ reason: string().nullable()
10039
+ }).optional(),
10040
+ exportsDropped: array(object({
10041
+ export: string(),
10042
+ reason: string()
10043
+ })).optional(),
10044
+ files: array(TrainingResultFileSchema).optional(),
10045
+ bundle: object({
10046
+ path: literal("bundle.tar"),
10047
+ bytes: number().int().nonnegative(),
10048
+ sha256: string().regex(/^[0-9a-f]{64}$/)
10049
+ }).nullable().optional(),
10050
+ catalogDraft: object({
10051
+ base: TrainingCatalogDraftSchema,
10052
+ int8: TrainingCatalogDraftSchema.nullable()
10053
+ }).nullable().optional(),
10054
+ licence: string()
10055
+ });
10056
+ var TrainingStageSchema = _enum([
10057
+ "prepare",
10058
+ "replay",
10059
+ "train",
10060
+ "eval",
10061
+ "export",
10062
+ "package"
10063
+ ]);
10064
+ var EventBase = {
10065
+ v: literal(1),
10066
+ ts: number()
10067
+ };
10068
+ discriminatedUnion("type", [
10069
+ object({
10070
+ ...EventBase,
10071
+ type: literal("stage"),
10072
+ stage: TrainingStageSchema
10073
+ }),
10074
+ object({
10075
+ ...EventBase,
10076
+ type: literal("epoch"),
10077
+ epoch: number().int(),
10078
+ epochs: number().int(),
10079
+ boxLoss: number().nullable().optional(),
10080
+ map50: number().nullable().optional(),
10081
+ map50_95: number().nullable().optional(),
10082
+ etaSec: number().nullable().optional()
10083
+ }),
10084
+ object({
10085
+ ...EventBase,
10086
+ type: literal("metric"),
10087
+ name: string(),
10088
+ value: number()
10089
+ }),
10090
+ object({
10091
+ ...EventBase,
10092
+ type: literal("artifact"),
10093
+ path: string(),
10094
+ bytes: number(),
10095
+ sha256: string()
10096
+ }),
10097
+ object({
10098
+ ...EventBase,
10099
+ type: literal("done"),
10100
+ status: _enum(["succeeded", "failed"]),
10101
+ resultSha256: string().nullable().optional()
10102
+ }),
10103
+ object({
10104
+ ...EventBase,
10105
+ type: literal("error"),
10106
+ stage: string(),
10107
+ code: string(),
10108
+ message: string()
10109
+ })
10110
+ ]);
10111
+ /**
9417
10112
  * What the gate decided about a birth, from the CALLER's point of view.
9418
10113
  *
9419
10114
  * Deliberately not `ConfirmationVerdict`: `undecided` is not a birth decision
@@ -11741,7 +12436,9 @@ var AddonHttpRouteSchema = object({
11741
12436
  "authenticated",
11742
12437
  "admin"
11743
12438
  ]).optional(),
11744
- description: string().optional()
12439
+ description: string().optional(),
12440
+ /** The hub limits this route per client address before the handler runs. */
12441
+ rateLimit: _enum(["auth"]).optional()
11745
12442
  });
11746
12443
  /**
11747
12444
  * Cross-process route invocation envelope. The hub captures the
@@ -12446,6 +13143,37 @@ var BackupDestinationInfoSchema = object({
12446
13143
  lastError: string().optional()
12447
13144
  });
12448
13145
  /**
13146
+ * How an archive is encrypted (operator decision 2026-10-09): to a backup
13147
+ * PUBLIC key the hub holds, so only the operator's secret key opens it.
13148
+ * Absent on a plain `.tar.gz` — every archive made before encryption, or
13149
+ * with it off — which restores without a key.
13150
+ */
13151
+ var BackupArchiveEncryptionSchema = object({
13152
+ /** `x25519-hkdf-aes256gcm-stream-v1`. */
13153
+ scheme: string(),
13154
+ /** 16 hex — the backup key whose secret restores this archive. */
13155
+ keyId: string()
13156
+ });
13157
+ /**
13158
+ * The backup encryption setting. The hub keeps PUBLIC keys only: the active
13159
+ * one new archives are encrypted to, and the retired ones older archives
13160
+ * still need. The secret key is shown once, at `setupEncryption`.
13161
+ */
13162
+ var BackupEncryptionStatusSchema = object({
13163
+ enabled: boolean(),
13164
+ active: object({
13165
+ keyId: string(),
13166
+ publicKey: string(),
13167
+ createdAt: number()
13168
+ }).nullable(),
13169
+ /** Every key ever set up, newest first. */
13170
+ keys: array(object({
13171
+ keyId: string(),
13172
+ createdAt: number(),
13173
+ retiredAt: number().nullable()
13174
+ })).readonly()
13175
+ });
13176
+ /**
12449
13177
  * Per-archive entry returned by `backup.listArchives({ destinationId })`.
12450
13178
  * Same shape the destination drill-in renders. Sourced from the per-
12451
13179
  * location `manifests.json` (no per-archive tarball read required).
@@ -12457,7 +13185,9 @@ var BackupArchiveEntrySchema = object({
12457
13185
  sizeBytes: number(),
12458
13186
  label: string().optional(),
12459
13187
  /** Top-level locations included in the archive (db, addons, tls, …). */
12460
- locations: array(string()).readonly()
13188
+ locations: array(string()).readonly(),
13189
+ /** Present when the archive is encrypted; restore then needs that key. */
13190
+ encryption: BackupArchiveEncryptionSchema.optional()
12461
13191
  });
12462
13192
  var BackupEntrySchema = object({
12463
13193
  id: string(),
@@ -12466,7 +13196,8 @@ var BackupEntrySchema = object({
12466
13196
  label: string().optional(),
12467
13197
  createdAt: number(),
12468
13198
  sizeBytes: number(),
12469
- locations: array(string()).optional()
13199
+ locations: array(string()).optional(),
13200
+ encryption: BackupArchiveEncryptionSchema.optional()
12470
13201
  });
12471
13202
  var ArchiveEntrySchema = object({
12472
13203
  path: string(),
@@ -12655,10 +13386,40 @@ method(_void(), array(BackupDestinationInfoSchema).readonly(), { auth: "admin" }
12655
13386
  * this list and skips entries whose path doesn't start with
12656
13387
  * any of them.
12657
13388
  */
12658
- locations: array(string()).optional()
13389
+ locations: array(string()).optional(),
13390
+ /**
13391
+ * The backup SECRET key, for an encrypted archive (ignored for a plain
13392
+ * one). The archive is decrypted into the hub's private staging
13393
+ * before the restart; the key is not stored. A wrong or missing key
13394
+ * is refused before the archive is downloaded.
13395
+ */
13396
+ backupSecretKey: string().optional()
12659
13397
  }), _void(), {
12660
13398
  kind: "mutation",
12661
13399
  auth: "admin"
13400
+ }), method(_void(), BackupEncryptionStatusSchema, { auth: "admin" }), method(object({}), object({
13401
+ keyId: string(),
13402
+ secretKey: string(),
13403
+ publicKey: string(),
13404
+ createdAt: number(),
13405
+ replacedKeyId: string().nullable()
13406
+ }), {
13407
+ kind: "mutation",
13408
+ auth: "admin"
13409
+ }), method(object({}), object({ disabledKeyId: string().nullable() }), {
13410
+ kind: "mutation",
13411
+ auth: "admin"
13412
+ }), method(object({ backupSecretKey: string() }), object({
13413
+ valid: boolean(),
13414
+ keyId: string().nullable(),
13415
+ /** The hub knows this key (active or retired). */
13416
+ known: boolean(),
13417
+ /** It is the key new archives are encrypted to. */
13418
+ active: boolean(),
13419
+ error: string().optional()
13420
+ }), {
13421
+ kind: "mutation",
13422
+ auth: "admin"
12662
13423
  }), method(object({
12663
13424
  destinationId: string(),
12664
13425
  backupId: string()
@@ -14331,7 +15092,60 @@ var CustomModelDescriptorSchema = object({
14331
15092
  stepId: string(),
14332
15093
  entry: ModelCatalogEntrySchema
14333
15094
  });
14334
- method(_void(), array(CustomModelDescriptorSchema).readonly(), { auth: "admin" });
15095
+ /** One regular file of an imported bundle, as the producer measured it. */
15096
+ var ModelBundleFileSchema = object({
15097
+ /** Relative path inside the bundle tar; an mlpackage member is `<x>.mlpackage/<member>`. */
15098
+ path: string().min(1),
15099
+ bytes: number().int().nonnegative(),
15100
+ sha256: string().regex(/^[0-9a-f]{64}$/)
15101
+ });
15102
+ var ImportModelBundleInputSchema = object({
15103
+ /** The registry provider that keeps the model (Model Studio). */
15104
+ addonId: string(),
15105
+ stepId: string().min(1),
15106
+ /**
15107
+ * The catalog rows to register, complete, every format URL already
15108
+ * `camstack-local://<modelId>/<file>` naming a file of the bundle. One
15109
+ * bundle may carry several rows (a base and its INT8 variant).
15110
+ */
15111
+ entries: array(ModelCatalogEntrySchema).min(1).max(4),
15112
+ /** The bundle tar, offered by the producer over `ctx.peerBytes` (same host). */
15113
+ bundle: object({
15114
+ ticket: PeerBytesTicketSchema,
15115
+ bytes: number().int().positive(),
15116
+ sha256: string().regex(/^[0-9a-f]{64}$/)
15117
+ }),
15118
+ /** Every file the tar must hold; anything missing, extra or different is refused. */
15119
+ files: array(ModelBundleFileSchema).min(1).max(64),
15120
+ /** Convert missing engine formats and push the model to every agent afterwards. */
15121
+ distribute: boolean()
15122
+ });
15123
+ var ImportModelBundleResultSchema = discriminatedUnion("kind", [object({
15124
+ kind: literal("imported"),
15125
+ modelIds: array(string()).readonly(),
15126
+ distributed: array(object({
15127
+ modelId: string(),
15128
+ nodeId: string(),
15129
+ format: _enum(MODEL_FORMATS),
15130
+ ok: boolean(),
15131
+ error: string().optional()
15132
+ })).readonly()
15133
+ }), object({
15134
+ kind: literal("refused"),
15135
+ reason: _enum([
15136
+ "transfer-failed",
15137
+ "checksum-mismatch",
15138
+ "bundle-mismatch",
15139
+ "invalid-entry",
15140
+ "id-taken"
15141
+ ]),
15142
+ detail: string()
15143
+ })]);
15144
+ method(_void(), array(CustomModelDescriptorSchema).readonly(), { auth: "admin" }), method(ImportModelBundleInputSchema, ImportModelBundleResultSchema, {
15145
+ kind: "mutation",
15146
+ auth: "admin",
15147
+ timeoutMs: 30 * 6e4
15148
+ });
14335
15149
  /**
14336
15150
  * Query filter for settings-store collections.
14337
15151
  */
@@ -14810,6 +15624,35 @@ var KeychainKeySourceSchema = object({
14810
15624
  */
14811
15625
  sharesBackupWithDatabase: boolean()
14812
15626
  });
15627
+ /**
15628
+ * One keychain reset, as the Secrets page reports it until the operator
15629
+ * acknowledges it. Never a value: refs, counts and table names only.
15630
+ */
15631
+ var KeychainResetRecordSchema = object({
15632
+ id: string(),
15633
+ at: number(),
15634
+ /** `user:<id>` or {@link KEYCHAIN_RESET_TRIGGER_ACTOR}. */
15635
+ actor: string(),
15636
+ /** Why the keychain was locked when it was reset; `null` when it was not locked. */
15637
+ lockedReason: string().nullable(),
15638
+ /** Values moved into the archive table (ciphertext under the lost key). */
15639
+ archived: number().int(),
15640
+ /** `keychain:secrets-orphaned-<ts>`, or `null` when nothing was stored. */
15641
+ archivedCollection: string().nullable(),
15642
+ /**
15643
+ * `keychain:keys-orphaned-<ts>`: the wrapped data keys of the archive, kept
15644
+ * so the archive can still be opened if the lost master key turns up.
15645
+ */
15646
+ archivedKeysCollection: string().nullable(),
15647
+ /**
15648
+ * `system-settings` keys whose marker the reset cleared — the cluster
15649
+ * secret's: a marker left pointing at an archived value would refuse every
15650
+ * agent forever (D797).
15651
+ */
15652
+ clearedSettingsKeys: array(string()).readonly(),
15653
+ /** When an operator dismissed the notice on the Secrets page; `null` until then. */
15654
+ acknowledgedAt: number().nullable()
15655
+ });
14813
15656
  var KeychainStatusSchema = object({
14814
15657
  keychain: KeychainStateSchema,
14815
15658
  /** The source of the master key in use; `null` while locked. */
@@ -14827,7 +15670,9 @@ var KeychainStatusSchema = object({
14827
15670
  /** Wrapped copies of the data key under a previous master key, kept until purged. */
14828
15671
  retiredWraps: number().int(),
14829
15672
  recoveryKeyDownloadedAt: number().nullable(),
14830
- secretCount: number().int()
15673
+ secretCount: number().int(),
15674
+ /** The most recent reset, acknowledged or not; `null` when the keychain was never reset. */
15675
+ lastReset: KeychainResetRecordSchema.nullable()
14831
15676
  });
14832
15677
  /**
14833
15678
  * Whether a stored value is still pointed at by its owner's settings.
@@ -14849,13 +15694,14 @@ var KeychainAuditActionSchema = _enum([
14849
15694
  "download-recovery-key",
14850
15695
  "delete-orphans",
14851
15696
  "reset",
15697
+ "acknowledge-reset",
14852
15698
  "initialize"
14853
15699
  ]);
14854
15700
  var KeychainAuditEntrySchema = object({
14855
15701
  id: string(),
14856
15702
  at: number(),
14857
15703
  action: KeychainAuditActionSchema,
14858
- /** `addon:<id>` | `user:<id>` | `system`. */
15704
+ /** `addon:<id>` | `user:<id>` | `system` | `trigger-file`. */
14859
15705
  actor: string(),
14860
15706
  ref: string().nullable(),
14861
15707
  detail: string().nullable()
@@ -14921,6 +15767,13 @@ method(object({}), KeychainStatusSchema, { auth: "admin" }), method(object({}),
14921
15767
  kind: "mutation",
14922
15768
  auth: "admin",
14923
15769
  caller: "required"
15770
+ }), method(object({}), object({
15771
+ reset: KeychainResetRecordSchema.nullable(),
15772
+ pendingReentry: array(KeychainSecretMetaSchema).readonly()
15773
+ }), { auth: "admin" }), method(object({}), object({ acknowledged: boolean() }), {
15774
+ kind: "mutation",
15775
+ auth: "admin",
15776
+ caller: "required"
14924
15777
  });
14925
15778
  method(_void(), object({
14926
15779
  id: string(),
@@ -17566,7 +18419,7 @@ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
17566
18419
  * `login-method` — collection cap through which auth addons contribute
17567
18420
  * their pre-auth login surfaces to the login page. This is the SINGLE,
17568
18421
  * generic mechanism that supersedes the dead `auth.listProviders` reader:
17569
- * every auth addon (OIDC, magic-link, WebAuthn/passkey) registers a
18422
+ * every auth addon (OIDC, WebAuthn/passkey) registers a
17570
18423
  * `login-method` provider and the PUBLIC `auth.listLoginMethods`
17571
18424
  * procedure aggregates them for the unauthenticated login page.
17572
18425
  *
@@ -17574,8 +18427,7 @@ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
17574
18427
  *
17575
18428
  * - `redirect` — a declarative button. The login page renders a generic
17576
18429
  * button that navigates to `startUrl` (an addon-owned HTTP route).
17577
- * Covers OIDC (`/addon/auth-oidc/<id>/start`) and magic-link with
17578
- * ZERO shell-side JS. A future SSO addon plugs in the same way — the
18430
+ * Covers OIDC (`/addon/auth-oidc/<id>/start`) with ZERO shell-side JS. A future SSO addon plugs in the same way — the
17579
18431
  * login page needs NO change.
17580
18432
  *
17581
18433
  * - `widget` — a Module-Federation widget the login page mounts (via
@@ -17594,8 +18446,8 @@ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
17594
18446
  * decision.
17595
18447
  *
17596
18448
  * Every contribution carries a `stage`:
17597
- * - `primary` — shown on the first credentials screen (OIDC /
17598
- * magic-link buttons; a future usernameless passkey).
18449
+ * - `primary` — shown on the first credentials screen (OIDC
18450
+ * buttons; a usernameless passkey).
17599
18451
  * - `second-factor` — shown AFTER the password leg, gated on the
17600
18452
  * returned `factors` (passkey-as-2FA today).
17601
18453
  *
@@ -17622,7 +18474,7 @@ var LoginMethodContributionSchema = discriminatedUnion("kind", [
17622
18474
  * The provider names an external identity a signed-in user can link to
17623
18475
  * their own account (D782): `auth.listLinkableProviders` /
17624
18476
  * `beginExternalLink` offer exactly the redirect methods that set this,
17625
- * whatever their id. Absent / false — a login button only (magic-link).
18477
+ * whatever their id. Absent / false — a login button only.
17626
18478
  */
17627
18479
  linkable: boolean().optional()
17628
18480
  }),
@@ -21458,8 +22310,7 @@ method(object({}), object({ rules: array(NcRuleSchema) }), { auth: "admin" }), m
21458
22310
  * `super_admin` — collapsed onto the single boolean because every
21459
22311
  * non-admin caller is governed by the same scope-check rules; the
21460
22312
  * distinction was only ever used to route role-specific procedures
21461
- * which we no longer have. Agents are admin sessions issued via
21462
- * `createServiceToken`; CLI / webhook integrations are `cst_*` tokens
22313
+ * which we no longer have. CLI / webhook integrations are `cst_*` tokens
21463
22314
  * with `isAdmin: false` + an explicit scope list.
21464
22315
  */
21465
22316
  /** Per-method access flavour. Materialised on every cap method via codegen. */
@@ -24154,6 +25005,17 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
24154
25005
  kind: "mutation",
24155
25006
  auth: "admin",
24156
25007
  timeoutMs: 60 * 6e4
25008
+ }), method(object({
25009
+ filter: RetrainExportFilterSchema,
25010
+ layout: RetrainExportLayoutSchema
25011
+ }), object({
25012
+ ticket: PeerBytesTicketSchema,
25013
+ frames: number().int(),
25014
+ annotations: number().int()
25015
+ }), {
25016
+ kind: "mutation",
25017
+ auth: "admin",
25018
+ timeoutMs: 12e4
24157
25019
  }), method(object({
24158
25020
  selection: RetrainDatasetSelectionSchema,
24159
25021
  completeOnly: boolean().optional()
@@ -27722,8 +28584,8 @@ version: string().optional() }), ServerUpdateActionResultSchema, {
27722
28584
  * `smtp-provider` — pluggable email delivery surface.
27723
28585
  *
27724
28586
  * Collection cap: a deployment may install multiple SMTP relays (e.g.
27725
- * one for transactional / one for notifications). Consumers (magic-link,
27726
- * notifier addons, …) walk the collection and pick the first
28587
+ * one for transactional / one for notifications). Consumers (notifier
28588
+ * addons, …) walk the collection and pick the first
27727
28589
  * ready provider OR target a specific addonId.
27728
28590
  *
27729
28591
  * The shape stays small on purpose — `sendEmail` is enough for the
@@ -27902,7 +28764,7 @@ targets: array(object({
27902
28764
  })));
27903
28765
  /**
27904
28766
  * `sso-bridge` — internal hub-only cap that lets SSO-style auth
27905
- * providers (OIDC, SAML, magic-link, …) mint an HMAC-signed token
28767
+ * providers (OIDC, SAML, …) mint an HMAC-signed token
27906
28768
  * carrying the post-callback claims before redirecting back to
27907
28769
  * `/api/auth/sso/finish`.
27908
28770
  *
@@ -27965,7 +28827,14 @@ var SsoBridgeClaimsSchema = object({
27965
28827
  * Verified `iss` of the id_token behind an OIDC login bridge (D782). A
27966
28828
  * subject is unique only per issuer, so a link is bound to it.
27967
28829
  */
27968
- issuer: string().optional()
28830
+ issuer: string().optional(),
28831
+ /**
28832
+ * SHA-256 (hex) of the `camstack_sso_state` cookie the IdP `/start` set in
28833
+ * the browser that began this sign-in. `/api/auth/sso/finish` requires the
28834
+ * request to present the matching cookie — a login bridge is useless in
28835
+ * any other browser.
28836
+ */
28837
+ browserBinding: string().optional()
27969
28838
  });
27970
28839
  method(object({
27971
28840
  claims: SsoBridgeClaimsSchema,
@@ -37885,16 +38754,6 @@ var ApiKeySummarySchema = object({
37885
38754
  createdAt: number(),
37886
38755
  lastUsedAt: number().optional()
37887
38756
  });
37888
- var CreateApiKeyInputSchema = object({
37889
- label: string(),
37890
- isAdmin: boolean().default(false),
37891
- allowedProviders: union([array(string()), literal("*")]).optional(),
37892
- allowedDevices: record(string(), union([array(string()), literal("*")])).optional()
37893
- });
37894
- var CreateApiKeyResultSchema = object({
37895
- token: string(),
37896
- record: ApiKeySummarySchema
37897
- });
37898
38757
  var ScopedTokenSummarySchema = object({
37899
38758
  id: string(),
37900
38759
  userId: string(),
@@ -37993,17 +38852,10 @@ method(_void(), array(UserSummarySchema), { auth: "admin" }), method(CreateUserI
37993
38852
  }), UserSummarySchema.extend({ passwordHash: string() }).nullable(), {
37994
38853
  kind: "mutation",
37995
38854
  access: "view"
37996
- }), method(_void(), array(ApiKeySummarySchema), { auth: "admin" }), method(CreateApiKeyInputSchema, CreateApiKeyResultSchema, {
37997
- kind: "mutation",
37998
- auth: "admin",
37999
- access: "create"
38000
- }), method(object({ id: string() }), object({ success: literal(true) }), {
38855
+ }), method(_void(), array(ApiKeySummarySchema), { auth: "admin" }), method(object({ id: string() }), object({ success: literal(true) }), {
38001
38856
  kind: "mutation",
38002
38857
  auth: "admin",
38003
38858
  access: "delete"
38004
- }), method(object({ token: string() }), ApiKeySummarySchema.nullable(), {
38005
- kind: "mutation",
38006
- access: "view"
38007
38859
  }), method(CreateScopedTokenInputSchema, CreateScopedTokenResultSchema, {
38008
38860
  kind: "mutation",
38009
38861
  auth: "admin",
@@ -38077,15 +38929,7 @@ method(_void(), array(UserSummarySchema), { auth: "admin" }), method(CreateUserI
38077
38929
  }).nullable(), { access: "view" }), method(object({ userId: string() }), array(ExternalIdentitySchema), { auth: "admin" }), method(ExternalIdentityKeySchema, object({
38078
38930
  userId: string(),
38079
38931
  issuer: string()
38080
- }).nullable(), { auth: "admin" }), method(ExternalIdentityKeySchema.extend({
38081
- userId: string(),
38082
- issuer: string().min(1),
38083
- label: string().optional()
38084
- }), object({ success: literal(true) }), {
38085
- kind: "mutation",
38086
- auth: "admin",
38087
- access: "create"
38088
- }), method(ExternalIdentityKeySchema.extend({ userId: string() }), object({ success: boolean() }), {
38932
+ }).nullable(), { auth: "admin" }), method(ExternalIdentityKeySchema.extend({ userId: string() }), object({ success: boolean() }), {
38089
38933
  kind: "mutation",
38090
38934
  auth: "admin",
38091
38935
  access: "delete"
@@ -38480,6 +39324,451 @@ DeviceType.Camera, method(object({
38480
39324
  detection: array(ZoneRuleSchema).readonly(),
38481
39325
  package: array(ZoneRuleSchema).readonly()
38482
39326
  });
39327
+ /**
39328
+ * `training-provider` — ONE cloud that can run the CamStack trainer.
39329
+ *
39330
+ * A thin, mockable translation layer: it knows how to run a container with a
39331
+ * GPU, move a dataset in, read the job's stdout and hand artefacts back. It
39332
+ * knows nothing about datasets, splits, floors, cost policy or Model Studio —
39333
+ * those are the `training` orchestrator's (D805). Every rule written there
39334
+ * once is what makes a second provider (RunPod, a local NVIDIA node) a new
39335
+ * manifest entry and nothing else.
39336
+ *
39337
+ * Collection, routed by the `addonId` in every single-row input (the `llm` /
39338
+ * `notification-output` posture); `describe` concat-fans across providers.
39339
+ * Every method is `admin`: these spend money.
39340
+ *
39341
+ * Every cloud object a provider creates is tagged with the orchestrator's
39342
+ * `jobKey`, so a retried submit finds the job it already started instead of
39343
+ * starting a second GPU, and `listJobs` can find orphans.
39344
+ *
39345
+ * Bytes never ride a cap field: the dataset arrives as a `ctx.peerBytes`
39346
+ * ticket the producer (pipeline-analytics) minted, and artefacts leave as a
39347
+ * ticket the provider mints (D613).
39348
+ */
39349
+ var TrainingGpuOptionSchema = object({
39350
+ id: string(),
39351
+ label: string(),
39352
+ /** List price, USD per GPU-hour, before any region multiplier. */
39353
+ usdPerHour: number().nonnegative(),
39354
+ vramGb: number().nonnegative()
39355
+ });
39356
+ var TrainingRegionOptionSchema = object({
39357
+ /** `''` = any region (the provider's choice). */
39358
+ id: string(),
39359
+ label: string(),
39360
+ priceMultiplier: number().positive()
39361
+ });
39362
+ /**
39363
+ * The provider's per-account settings, as the orchestrator reads them. They
39364
+ * live in the PROVIDER addon's settings (operator decision 2026-10-08: they
39365
+ * depend on the user's account), never hard-coded in the orchestrator.
39366
+ */
39367
+ var TrainingProviderDefaultsSchema = object({
39368
+ gpuType: string(),
39369
+ region: string(),
39370
+ costCapUsd: number().nonnegative(),
39371
+ maxRuntimeSec: number().int().positive(),
39372
+ /** Hours a FAILED job's cloud dataset is kept for debugging; 0 = delete at once. */
39373
+ failedDatasetGraceHours: number().nonnegative()
39374
+ });
39375
+ var TrainingProviderDescriptorSchema = object({
39376
+ addonId: string(),
39377
+ /** `modal`, `runpod`, `fake`, … */
39378
+ kind: string(),
39379
+ label: string(),
39380
+ gpuTypes: array(TrainingGpuOptionSchema).readonly(),
39381
+ regions: array(TrainingRegionOptionSchema).readonly(),
39382
+ maxDatasetBytes: number().int().positive(),
39383
+ maxRuntimeSec: number().int().positive(),
39384
+ freeTierNote: string().optional(),
39385
+ /** Where the data goes, in one sentence the confirm dialog repeats. */
39386
+ dataResidencyNote: string(),
39387
+ /** Credentials are present — never the values. */
39388
+ configured: boolean(),
39389
+ defaults: TrainingProviderDefaultsSchema
39390
+ });
39391
+ var TrainingCredentialCheckSchema = object({
39392
+ ok: boolean(),
39393
+ /** Workspace / account name, when the provider says. */
39394
+ account: string().optional(),
39395
+ reason: _enum([
39396
+ "missing",
39397
+ "invalid",
39398
+ "forbidden",
39399
+ "network",
39400
+ "quota"
39401
+ ]).optional(),
39402
+ detail: string().optional()
39403
+ });
39404
+ var ProviderJobStateSchema = _enum([
39405
+ "pending",
39406
+ "starting",
39407
+ "running",
39408
+ "succeeded",
39409
+ "failed",
39410
+ "cancelled",
39411
+ "lost"
39412
+ ]);
39413
+ var ProviderJobStatusSchema = object({
39414
+ jobKey: string(),
39415
+ providerJobId: string().optional(),
39416
+ state: ProviderJobStateSchema,
39417
+ startedAt: number().optional(),
39418
+ endedAt: number().optional(),
39419
+ exitCode: number().int().optional(),
39420
+ failureReason: string().optional(),
39421
+ gpuType: string(),
39422
+ region: string().optional(),
39423
+ billedSeconds: number().nonnegative(),
39424
+ costUsd: number().nonnegative(),
39425
+ /** True when `costUsd` is runtime × list price, not a billing answer. */
39426
+ costIsEstimate: boolean(),
39427
+ lastFetchedAt: number()
39428
+ });
39429
+ /**
39430
+ * The trainer the job runs, by SOURCE revision: the provider turns it into an
39431
+ * image its own way (Modal builds the published Dockerfile at that revision;
39432
+ * a registry-pull provider maps it to a tag). Recorded on the job and echoed
39433
+ * in `result.json`.
39434
+ */
39435
+ var TrainerSourceRefSchema = object({
39436
+ /** Hugging Face repo id, e.g. `camstack/camstack-trainer`. */
39437
+ repo: string().min(1),
39438
+ /** A commit sha (never a branch) — the job must be reproducible. */
39439
+ revision: string().regex(/^[0-9a-f]{7,64}$/)
39440
+ });
39441
+ var JobRef = {
39442
+ addonId: string(),
39443
+ jobKey: string().uuid()
39444
+ };
39445
+ var TrainingLogLineSchema = object({
39446
+ ts: number(),
39447
+ text: string()
39448
+ });
39449
+ method(object({}), array(TrainingProviderDescriptorSchema).readonly(), { auth: "admin" }), method(object({ addonId: string() }), TrainingCredentialCheckSchema, {
39450
+ kind: "mutation",
39451
+ auth: "admin",
39452
+ timeoutMs: 3e4
39453
+ }), method(object({
39454
+ addonId: string(),
39455
+ gpuType: string(),
39456
+ region: string(),
39457
+ datasetBytes: number().int().nonnegative(),
39458
+ gpuSecondsLow: number().nonnegative(),
39459
+ gpuSecondsHigh: number().nonnegative()
39460
+ }), object({
39461
+ usdLow: number().nonnegative(),
39462
+ usdHigh: number().nonnegative(),
39463
+ notes: array(string()).readonly()
39464
+ }), { auth: "admin" }), method(object({
39465
+ ...JobRef,
39466
+ ticket: PeerBytesTicketSchema
39467
+ }), object({
39468
+ bytes: number().int().nonnegative(),
39469
+ sha256: string()
39470
+ }), {
39471
+ kind: "mutation",
39472
+ auth: "admin",
39473
+ timeoutMs: 120 * 6e4
39474
+ }), method(object({
39475
+ ...JobRef,
39476
+ trainer: TrainerSourceRefSchema,
39477
+ jobSpecJson: string().min(2).max(64e3),
39478
+ gpuType: string(),
39479
+ region: string(),
39480
+ maxRuntimeSec: number().int().positive()
39481
+ }), ProviderJobStatusSchema, {
39482
+ kind: "mutation",
39483
+ auth: "admin",
39484
+ timeoutMs: 30 * 6e4
39485
+ }), method(object(JobRef), ProviderJobStatusSchema, {
39486
+ auth: "admin",
39487
+ timeoutMs: 6e4
39488
+ }), method(object({
39489
+ ...JobRef,
39490
+ cursor: string().optional(),
39491
+ max: number().int().min(1).max(500)
39492
+ }), object({
39493
+ lines: array(TrainingLogLineSchema).readonly(),
39494
+ cursor: string()
39495
+ }), {
39496
+ auth: "admin",
39497
+ timeoutMs: 6e4
39498
+ }), method(object(JobRef), object({ ok: literal(true) }), {
39499
+ kind: "mutation",
39500
+ auth: "admin",
39501
+ timeoutMs: 6e4
39502
+ }), method(object(JobRef), object({
39503
+ found: boolean(),
39504
+ text: string().optional()
39505
+ }), {
39506
+ kind: "mutation",
39507
+ auth: "admin",
39508
+ timeoutMs: 5 * 6e4
39509
+ }), method(object({
39510
+ ...JobRef,
39511
+ path: _enum(["bundle.tar"])
39512
+ }), object({ ticket: PeerBytesTicketSchema }), {
39513
+ kind: "mutation",
39514
+ auth: "admin",
39515
+ timeoutMs: 5 * 6e4
39516
+ }), method(object(JobRef), object({ deleted: array(string()).readonly() }), {
39517
+ kind: "mutation",
39518
+ auth: "admin",
39519
+ timeoutMs: 5 * 6e4
39520
+ }), method(object({ addonId: string() }), array(ProviderJobStatusSchema).readonly(), {
39521
+ auth: "admin",
39522
+ timeoutMs: 2 * 6e4
39523
+ });
39524
+ /**
39525
+ * `training` — the cloud-training orchestrator (D805). Hub-only singleton,
39526
+ * provided by `addon-training`.
39527
+ *
39528
+ * It owns what every provider must agree on, written once:
39529
+ *
39530
+ * - **Dataset versions.** Taken over from pipeline-analytics (D796): the rows
39531
+ * live here (D808); pipeline-analytics still CUTS a version (it owns the corpus and
39532
+ * the export plan) and reaches this store through the five row methods
39533
+ * below, so the Retrain page and the export did not change.
39534
+ * - **Jobs.** A persisted state machine, a reconcile loop against the
39535
+ * provider, a cost guard, a daily orphan sweep and the retention rules.
39536
+ * - **The return flow.** Verified artefacts → Model Studio
39537
+ * (`custom-model-registry.importModelBundle`) → canary on cameras →
39538
+ * rollback. Nothing is ever registered automatically.
39539
+ *
39540
+ * Every method is `admin`.
39541
+ */
39542
+ /** A version WITH its frame list — what the export and a job read. */
39543
+ var TrainingDatasetVersionRowSchema = RetrainDatasetVersionSchema.omit({ frameCount: true }).extend({ frameIds: array(string()).max(2e4).readonly() });
39544
+ /** A base model a detector job can fine-tune, and the baseline it is judged against. */
39545
+ var TrainingBaseModelSchema = object({
39546
+ modelId: string(),
39547
+ label: string(),
39548
+ weights: string(),
39549
+ imgsz: number().int(),
39550
+ baselineOnnxUrl: string(),
39551
+ baselineFloors: record(string(), number()),
39552
+ /** The base the fleet runs most — the UI's default. */
39553
+ recommended: boolean()
39554
+ });
39555
+ var TrainingPresetSchema = _enum([
39556
+ "quick",
39557
+ "standard",
39558
+ "thorough"
39559
+ ]);
39560
+ var TrainingJobRequestSchema = object({
39561
+ datasetVersionId: string().min(1),
39562
+ /** The `training-provider` addon that runs it. */
39563
+ addonId: string().min(1),
39564
+ gpuType: string().min(1),
39565
+ region: string(),
39566
+ baseModelId: string().min(1),
39567
+ preset: TrainingPresetSchema,
39568
+ /** Freeze the backbone's first N layers; `null` = the preset's choice. */
39569
+ freeze: number().int().nonnegative().nullable(),
39570
+ /** Cameras held out whole for evaluation; `null` = the orchestrator's default. */
39571
+ holdoutCameras: array(number().int()).nullable()
39572
+ });
39573
+ var TrainingSplitPlanSchema = object({
39574
+ holdoutCameras: array(number().int()).readonly(),
39575
+ /** Used when no camera is held out: the last N days of every camera. */
39576
+ holdoutLastDays: number().int().nonnegative(),
39577
+ /** Holdout subjects per class (camera holdout only; `null` = known only after the split). */
39578
+ holdoutSupport: record(string(), number().int()).nullable(),
39579
+ trainSubjects: number().int()
39580
+ });
39581
+ var TrainingRefusalReasonSchema = _enum([
39582
+ "unknown-dataset",
39583
+ "unknown-provider",
39584
+ "provider-not-configured",
39585
+ "unknown-base-model",
39586
+ "unknown-gpu",
39587
+ "dataset-too-large",
39588
+ "no-training-subjects",
39589
+ "job-already-running"
39590
+ ]);
39591
+ var TrainingJobPlanSchema = object({
39592
+ refusal: object({
39593
+ reason: TrainingRefusalReasonSchema,
39594
+ detail: string()
39595
+ }).nullable(),
39596
+ warnings: array(string()).readonly(),
39597
+ split: TrainingSplitPlanSchema.nullable(),
39598
+ estimate: object({
39599
+ datasetBytes: number().int(),
39600
+ uploadMinutesAt20Mbps: number(),
39601
+ gpuSecondsLow: number(),
39602
+ gpuSecondsHigh: number(),
39603
+ usdLow: number(),
39604
+ usdHigh: number(),
39605
+ notes: array(string()).readonly()
39606
+ }).nullable(),
39607
+ /** Pre-filled from the provider's settings; the operator may lower or raise them. */
39608
+ defaults: object({
39609
+ maxCostUsd: number(),
39610
+ maxRuntimeSec: number().int()
39611
+ }).nullable(),
39612
+ /** The sentence the confirm dialog repeats: where the frames go and when they are deleted. */
39613
+ dataNotice: string()
39614
+ });
39615
+ /**
39616
+ * Orchestrator-owned states, persisted. `uploading` covers exporting the
39617
+ * archive (it is streamed, never staged). Terminal: `failed`, `cancelled`,
39618
+ * `lost`, `expired`, `discarded`. `registered` and `canary` are where a
39619
+ * result lives after the operator acted on it.
39620
+ */
39621
+ var TrainingJobStateSchema = _enum([
39622
+ "uploading",
39623
+ "submitted",
39624
+ "starting",
39625
+ "running",
39626
+ "collecting",
39627
+ "ready",
39628
+ "registered",
39629
+ "canary",
39630
+ "failed",
39631
+ "cancelling",
39632
+ "cancelled",
39633
+ "lost",
39634
+ "expired",
39635
+ "discarded"
39636
+ ]);
39637
+ var TrainingFailureReasonSchema = _enum([
39638
+ "cost-cap",
39639
+ "runtime-cap",
39640
+ "upload-failed",
39641
+ "submit-failed",
39642
+ "trainer-failed",
39643
+ "result-invalid",
39644
+ "checksum-mismatch",
39645
+ "fetch-failed",
39646
+ "provider-error",
39647
+ "hub-restart-during-upload"
39648
+ ]);
39649
+ var TrainingProgressPointSchema = object({
39650
+ epoch: number().int(),
39651
+ map50: number().nullable(),
39652
+ map50_95: number().nullable()
39653
+ });
39654
+ var TrainingCanarySchema = object({
39655
+ deviceIds: array(number().int()).readonly(),
39656
+ since: number(),
39657
+ /** Every override the canary replaced, exactly, so rollback restores it. */
39658
+ previous: array(object({
39659
+ deviceId: number().int(),
39660
+ nodeId: string(),
39661
+ deviceKey: string(),
39662
+ patch: object({
39663
+ modelId: string().optional(),
39664
+ settings: record(string(), unknown()).readonly().optional()
39665
+ }).nullable()
39666
+ })).readonly()
39667
+ });
39668
+ var TrainingJobSchema = object({
39669
+ id: string(),
39670
+ idempotencyKey: string(),
39671
+ name: string(),
39672
+ createdAt: number(),
39673
+ updatedAt: number(),
39674
+ state: TrainingJobStateSchema,
39675
+ stage: TrainingStageSchema.nullable(),
39676
+ failure: object({
39677
+ reason: TrainingFailureReasonSchema,
39678
+ stage: string().nullable(),
39679
+ detail: string()
39680
+ }).nullable(),
39681
+ request: TrainingJobRequestSchema,
39682
+ maxCostUsd: number().nonnegative(),
39683
+ maxRuntimeSec: number().int().positive(),
39684
+ trainer: TrainerSourceRefSchema,
39685
+ datasetLayout: RetrainExportLayoutSchema,
39686
+ dataset: object({
39687
+ bytes: number().int(),
39688
+ sha256: string(),
39689
+ uploadedAt: number()
39690
+ }).nullable(),
39691
+ split: TrainingSplitPlanSchema,
39692
+ provider: object({
39693
+ state: ProviderJobStateSchema.nullable(),
39694
+ providerJobId: string().nullable(),
39695
+ startedAt: number().nullable(),
39696
+ endedAt: number().nullable(),
39697
+ billedSeconds: number(),
39698
+ costUsd: number(),
39699
+ costIsEstimate: boolean(),
39700
+ lastPolledAt: number().nullable()
39701
+ }),
39702
+ progress: object({
39703
+ epoch: number().int().nullable(),
39704
+ epochs: number().int().nullable(),
39705
+ etaSec: number().nullable(),
39706
+ series: array(TrainingProgressPointSchema).readonly()
39707
+ }),
39708
+ /** The last lines of the job's output (≤ 200), newest last. Never frame paths. */
39709
+ logTail: array(string()).readonly(),
39710
+ logCursor: string().nullable(),
39711
+ artifacts: object({
39712
+ bundleBytes: number().int(),
39713
+ bundleSha256: string(),
39714
+ fetchedAt: number(),
39715
+ /** When the staged artefacts are deleted from the hub. */
39716
+ expiresAt: number()
39717
+ }).nullable(),
39718
+ /** When the provider-side copy of the frames was deleted; null while it exists. */
39719
+ cloudDatasetDeletedAt: number().nullable(),
39720
+ /** A failed job's dataset is kept until then (the provider's grace), then deleted. */
39721
+ cloudCleanupDueAt: number().nullable(),
39722
+ /** Model ids registered from this job (base, and int8 when kept). */
39723
+ registeredModelIds: array(string()).readonly(),
39724
+ canary: TrainingCanarySchema.nullable()
39725
+ });
39726
+ var IdInput = object({ id: string().min(1) });
39727
+ method(TrainingDatasetVersionRowSchema, object({ stored: boolean() }), {
39728
+ kind: "mutation",
39729
+ auth: "admin"
39730
+ }), 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() }), {
39731
+ kind: "mutation",
39732
+ auth: "admin"
39733
+ }), method(object({}), array(TrainingBaseModelSchema).readonly(), { auth: "admin" }), method(TrainingJobRequestSchema, TrainingJobPlanSchema, {
39734
+ auth: "admin",
39735
+ timeoutMs: 6e4
39736
+ }), method(TrainingJobRequestSchema.extend({
39737
+ name: string().min(1).max(120),
39738
+ maxCostUsd: number().positive(),
39739
+ maxRuntimeSec: number().int().positive(),
39740
+ idempotencyKey: string().min(8).max(80)
39741
+ }), discriminatedUnion("kind", [object({
39742
+ kind: literal("started"),
39743
+ job: TrainingJobSchema
39744
+ }), object({
39745
+ kind: literal("refused"),
39746
+ reason: TrainingRefusalReasonSchema,
39747
+ detail: string()
39748
+ })]), {
39749
+ kind: "mutation",
39750
+ auth: "admin",
39751
+ timeoutMs: 12e4
39752
+ }), method(object({}), array(TrainingJobSchema).readonly(), { auth: "admin" }), method(IdInput, TrainingJobSchema.nullable(), { auth: "admin" }), method(IdInput, TrainingJobSchema, {
39753
+ kind: "mutation",
39754
+ auth: "admin",
39755
+ timeoutMs: 12e4
39756
+ }), method(IdInput, TrainingResultSchema.nullable(), { auth: "admin" }), method(IdInput.extend({ canaryDeviceIds: array(number().int()).readonly() }), TrainingJobSchema, {
39757
+ kind: "mutation",
39758
+ auth: "admin",
39759
+ timeoutMs: 30 * 6e4
39760
+ }), method(IdInput.extend({ deviceIds: array(number().int()).min(1).readonly() }), TrainingJobSchema, {
39761
+ kind: "mutation",
39762
+ auth: "admin",
39763
+ timeoutMs: 12e4
39764
+ }), method(IdInput, TrainingJobSchema, {
39765
+ kind: "mutation",
39766
+ auth: "admin",
39767
+ timeoutMs: 12e4
39768
+ }), method(IdInput, TrainingJobSchema, {
39769
+ kind: "mutation",
39770
+ auth: "admin"
39771
+ });
38483
39772
  SOURCE_CAPS.filter((cap) => cap !== "switch" && cap !== "motion");
38484
39773
  Object.freeze({
38485
39774
  person: .5,
@@ -39103,6 +40392,12 @@ Object.freeze({
39103
40392
  addonId: null,
39104
40393
  access: "create"
39105
40394
  },
40395
+ "backup.checkBackupKey": {
40396
+ capName: "backup",
40397
+ capScope: "system",
40398
+ addonId: null,
40399
+ access: "create"
40400
+ },
39106
40401
  "backup.delete": {
39107
40402
  capName: "backup",
39108
40403
  capScope: "system",
@@ -39115,6 +40410,18 @@ Object.freeze({
39115
40410
  addonId: null,
39116
40411
  access: "delete"
39117
40412
  },
40413
+ "backup.disableEncryption": {
40414
+ capName: "backup",
40415
+ capScope: "system",
40416
+ addonId: null,
40417
+ access: "create"
40418
+ },
40419
+ "backup.getEncryption": {
40420
+ capName: "backup",
40421
+ capScope: "system",
40422
+ addonId: null,
40423
+ access: "view"
40424
+ },
39118
40425
  "backup.getEntries": {
39119
40426
  capName: "backup",
39120
40427
  capScope: "system",
@@ -39169,6 +40476,12 @@ Object.freeze({
39169
40476
  addonId: null,
39170
40477
  access: "create"
39171
40478
  },
40479
+ "backup.setupEncryption": {
40480
+ capName: "backup",
40481
+ capScope: "system",
40482
+ addonId: null,
40483
+ access: "create"
40484
+ },
39172
40485
  "backup.trigger": {
39173
40486
  capName: "backup",
39174
40487
  capScope: "system",
@@ -39721,6 +41034,12 @@ Object.freeze({
39721
41034
  addonId: null,
39722
41035
  access: "create"
39723
41036
  },
41037
+ "customModelRegistry.importModelBundle": {
41038
+ capName: "custom-model-registry",
41039
+ capScope: "system",
41040
+ addonId: null,
41041
+ access: "create"
41042
+ },
39724
41043
  "customModelRegistry.listModels": {
39725
41044
  capName: "custom-model-registry",
39726
41045
  capScope: "system",
@@ -41161,6 +42480,12 @@ Object.freeze({
41161
42480
  addonId: null,
41162
42481
  access: "view"
41163
42482
  },
42483
+ "keychainAdmin.acknowledgeReset": {
42484
+ capName: "keychain-admin",
42485
+ capScope: "system",
42486
+ addonId: null,
42487
+ access: "create"
42488
+ },
41164
42489
  "keychainAdmin.deleteOrphans": {
41165
42490
  capName: "keychain-admin",
41166
42491
  capScope: "system",
@@ -41197,6 +42522,12 @@ Object.freeze({
41197
42522
  addonId: null,
41198
42523
  access: "delete"
41199
42524
  },
42525
+ "keychainAdmin.resetReport": {
42526
+ capName: "keychain-admin",
42527
+ capScope: "system",
42528
+ addonId: null,
42529
+ access: "delete"
42530
+ },
41200
42531
  "keychainAdmin.reveal": {
41201
42532
  capName: "keychain-admin",
41202
42533
  capScope: "system",
@@ -42943,6 +44274,12 @@ Object.freeze({
42943
44274
  addonId: null,
42944
44275
  access: "view"
42945
44276
  },
44277
+ "pipelineAnalytics.offerRetrainArchive": {
44278
+ capName: "pipeline-analytics",
44279
+ capScope: "device",
44280
+ addonId: null,
44281
+ access: "create"
44282
+ },
42946
44283
  "pipelineAnalytics.ownersWithMedia": {
42947
44284
  capName: "pipeline-analytics",
42948
44285
  capScope: "device",
@@ -45481,6 +46818,174 @@ Object.freeze({
45481
46818
  addonId: null,
45482
46819
  access: "view"
45483
46820
  },
46821
+ "training.canaryResult": {
46822
+ capName: "training",
46823
+ capScope: "system",
46824
+ addonId: null,
46825
+ access: "create"
46826
+ },
46827
+ "training.cancelJob": {
46828
+ capName: "training",
46829
+ capScope: "system",
46830
+ addonId: null,
46831
+ access: "create"
46832
+ },
46833
+ "training.discardResult": {
46834
+ capName: "training",
46835
+ capScope: "system",
46836
+ addonId: null,
46837
+ access: "create"
46838
+ },
46839
+ "training.findDatasetVersionIdByName": {
46840
+ capName: "training",
46841
+ capScope: "system",
46842
+ addonId: null,
46843
+ access: "view"
46844
+ },
46845
+ "training.getDatasetVersion": {
46846
+ capName: "training",
46847
+ capScope: "system",
46848
+ addonId: null,
46849
+ access: "view"
46850
+ },
46851
+ "training.getJob": {
46852
+ capName: "training",
46853
+ capScope: "system",
46854
+ addonId: null,
46855
+ access: "view"
46856
+ },
46857
+ "training.getJobResult": {
46858
+ capName: "training",
46859
+ capScope: "system",
46860
+ addonId: null,
46861
+ access: "view"
46862
+ },
46863
+ "training.listBaseModels": {
46864
+ capName: "training",
46865
+ capScope: "system",
46866
+ addonId: null,
46867
+ access: "view"
46868
+ },
46869
+ "training.listDatasetVersions": {
46870
+ capName: "training",
46871
+ capScope: "system",
46872
+ addonId: null,
46873
+ access: "view"
46874
+ },
46875
+ "training.listJobs": {
46876
+ capName: "training",
46877
+ capScope: "system",
46878
+ addonId: null,
46879
+ access: "view"
46880
+ },
46881
+ "training.planJob": {
46882
+ capName: "training",
46883
+ capScope: "system",
46884
+ addonId: null,
46885
+ access: "view"
46886
+ },
46887
+ "training.putDatasetVersion": {
46888
+ capName: "training",
46889
+ capScope: "system",
46890
+ addonId: null,
46891
+ access: "create"
46892
+ },
46893
+ "training.registerResult": {
46894
+ capName: "training",
46895
+ capScope: "system",
46896
+ addonId: null,
46897
+ access: "create"
46898
+ },
46899
+ "training.removeDatasetVersion": {
46900
+ capName: "training",
46901
+ capScope: "system",
46902
+ addonId: null,
46903
+ access: "delete"
46904
+ },
46905
+ "training.rollbackCanary": {
46906
+ capName: "training",
46907
+ capScope: "system",
46908
+ addonId: null,
46909
+ access: "create"
46910
+ },
46911
+ "training.startJob": {
46912
+ capName: "training",
46913
+ capScope: "system",
46914
+ addonId: null,
46915
+ access: "create"
46916
+ },
46917
+ "trainingProvider.cancelJob": {
46918
+ capName: "training-provider",
46919
+ capScope: "system",
46920
+ addonId: null,
46921
+ access: "create"
46922
+ },
46923
+ "trainingProvider.cleanupJob": {
46924
+ capName: "training-provider",
46925
+ capScope: "system",
46926
+ addonId: null,
46927
+ access: "create"
46928
+ },
46929
+ "trainingProvider.describe": {
46930
+ capName: "training-provider",
46931
+ capScope: "system",
46932
+ addonId: null,
46933
+ access: "view"
46934
+ },
46935
+ "trainingProvider.estimateJob": {
46936
+ capName: "training-provider",
46937
+ capScope: "system",
46938
+ addonId: null,
46939
+ access: "view"
46940
+ },
46941
+ "trainingProvider.getJob": {
46942
+ capName: "training-provider",
46943
+ capScope: "system",
46944
+ addonId: null,
46945
+ access: "view"
46946
+ },
46947
+ "trainingProvider.listJobEvents": {
46948
+ capName: "training-provider",
46949
+ capScope: "system",
46950
+ addonId: null,
46951
+ access: "view"
46952
+ },
46953
+ "trainingProvider.listJobs": {
46954
+ capName: "training-provider",
46955
+ capScope: "system",
46956
+ addonId: null,
46957
+ access: "view"
46958
+ },
46959
+ "trainingProvider.offerArtifact": {
46960
+ capName: "training-provider",
46961
+ capScope: "system",
46962
+ addonId: null,
46963
+ access: "create"
46964
+ },
46965
+ "trainingProvider.readResult": {
46966
+ capName: "training-provider",
46967
+ capScope: "system",
46968
+ addonId: null,
46969
+ access: "create"
46970
+ },
46971
+ "trainingProvider.submitJob": {
46972
+ capName: "training-provider",
46973
+ capScope: "system",
46974
+ addonId: null,
46975
+ access: "create"
46976
+ },
46977
+ "trainingProvider.uploadDataset": {
46978
+ capName: "training-provider",
46979
+ capScope: "system",
46980
+ addonId: null,
46981
+ access: "create"
46982
+ },
46983
+ "trainingProvider.validateCredentials": {
46984
+ capName: "training-provider",
46985
+ capScope: "system",
46986
+ addonId: null,
46987
+ access: "create"
46988
+ },
45484
46989
  "turnProvider.getTurnServers": {
45485
46990
  capName: "turn-provider",
45486
46991
  capScope: "system",
@@ -45505,12 +47010,6 @@ Object.freeze({
45505
47010
  addonId: null,
45506
47011
  access: "create"
45507
47012
  },
45508
- "userManagement.createApiKey": {
45509
- capName: "user-management",
45510
- capScope: "system",
45511
- addonId: null,
45512
- access: "create"
45513
- },
45514
47013
  "userManagement.createScopedToken": {
45515
47014
  capName: "user-management",
45516
47015
  capScope: "system",
@@ -45547,12 +47046,6 @@ Object.freeze({
45547
47046
  addonId: null,
45548
47047
  access: "view"
45549
47048
  },
45550
- "userManagement.linkExternalIdentity": {
45551
- capName: "user-management",
45552
- capScope: "system",
45553
- addonId: null,
45554
- access: "create"
45555
- },
45556
47049
  "userManagement.listApiKeys": {
45557
47050
  capName: "user-management",
45558
47051
  capScope: "system",
@@ -45655,12 +47148,6 @@ Object.freeze({
45655
47148
  addonId: null,
45656
47149
  access: "create"
45657
47150
  },
45658
- "userManagement.validateApiKey": {
45659
- capName: "user-management",
45660
- capScope: "system",
45661
- addonId: null,
45662
- access: "view"
45663
- },
45664
47151
  "userManagement.validateCredentials": {
45665
47152
  capName: "user-management",
45666
47153
  capScope: "system",
@@ -49774,6 +51261,11 @@ Object.freeze({
49774
51261
  form: "single",
49775
51262
  optional: false
49776
51263
  }],
51264
+ "training.canaryResult": [{
51265
+ name: "deviceIds",
51266
+ form: "array",
51267
+ optional: false
51268
+ }],
49777
51269
  "update.getStatus": [{
49778
51270
  name: "deviceId",
49779
51271
  form: "single",