@camstack/addon-osd-manager 0.1.192 → 0.1.194

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (20) hide show
  1. package/dist/{MotionZonesSettings-DA6kMhDo.mjs → MotionZonesSettings-DUltQQw1.mjs} +2 -2
  2. package/dist/{PrivacyMaskSettings-yu64qorr.mjs → PrivacyMaskSettings-xC6YrNM-.mjs} +4 -4
  3. package/dist/{SceneMonitorEditor-BDPE-kLF.mjs → SceneMonitorEditor-DKN2cL7k.mjs} +3 -3
  4. package/dist/_stub.js +2818 -2767
  5. package/dist/{_virtual_mf-localSharedImportMap___mfe_internal__addon_osd_manager_page-CgrkoJdk.mjs → _virtual_mf-localSharedImportMap___mfe_internal__addon_osd_manager_page-CQQfH2Z7.mjs} +4 -4
  6. package/dist/{_virtual_mf___mfe_internal__addon_osd_manager_page__loadShare___mf_0_camstack_mf_1_sdk__loadShare__.js-B_4MkXHU.mjs → _virtual_mf___mfe_internal__addon_osd_manager_page__loadShare___mf_0_camstack_mf_1_sdk__loadShare__.js-BdjiJb9r.mjs} +1 -1
  7. package/dist/_virtual_mf___mfe_internal__addon_osd_manager_page__loadShare___mf_0_camstack_mf_1_types__loadShare__.js-CGoq0DWk.mjs +26 -0
  8. package/dist/addon-osd-manager.css +1 -1
  9. package/dist/{hostInit-CMzgRhXV.mjs → hostInit-B-V1SPAc.mjs} +3 -3
  10. package/dist/index.js +1759 -147
  11. package/dist/index.mjs +1759 -147
  12. package/dist/{player-overlays-yo3byY33.mjs → player-overlays-TxRsHixk.mjs} +1 -1
  13. package/dist/remoteEntry.js +1 -1
  14. package/dist/{responsive-DManlL_B.mjs → responsive-t3UayeQT.mjs} +1 -1
  15. package/dist/{scene-monitor-copy-D3DDVyfO.mjs → scene-monitor-copy-gMmaT-FC.mjs} +1 -1
  16. package/dist/{square-Cez2ojTo.mjs → square-B_CvlH_T.mjs} +1 -1
  17. package/dist/{trash-2-Dfdmc9go.mjs → trash-2-BfeGf6tH.mjs} +1 -1
  18. package/dist/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__addon_osd_manager_page__remoteEntry_js-BEFG8H1P.mjs → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__addon_osd_manager_page__remoteEntry_js-DledZN7I.mjs} +1 -1
  19. package/package.json +1 -1
  20. package/dist/_virtual_mf___mfe_internal__addon_osd_manager_page__loadShare___mf_0_camstack_mf_1_types__loadShare__.js-Bn-J0B4D.mjs +0 -26
package/dist/index.js CHANGED
@@ -5380,7 +5380,7 @@ var ZodIssueCode = {
5380
5380
  var ZodFirstPartyTypeKind;
5381
5381
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
5382
5382
  //#endregion
5383
- //#region ../types/dist/sleep-DujUvOcb.mjs
5383
+ //#region ../types/dist/sleep-r3RWkGVx.mjs
5384
5384
  /**
5385
5385
  * The audio chunk plane's byte format, and the ONE expansion from a coded
5386
5386
  * window to float samples (D455).
@@ -5497,7 +5497,7 @@ function isKeychainStoredField(field) {
5497
5497
  var SECRET_CLEAR = { $secretClear: true };
5498
5498
  /** The `'***'` token D634 redaction writes for non-admins. */
5499
5499
  var LEGACY_DEVICE_REDACTION = "***";
5500
- function isRecord$1(value) {
5500
+ function isRecord$2(value) {
5501
5501
  return typeof value === "object" && value !== null && !Array.isArray(value);
5502
5502
  }
5503
5503
  function makeSecretMarker(ref) {
@@ -5508,12 +5508,12 @@ function makeSecretMarker(ref) {
5508
5508
  }
5509
5509
  /** A stored marker: an object whose `$secret` is a non-empty string. */
5510
5510
  function isSecretMarker(value) {
5511
- if (!isRecord$1(value)) return false;
5511
+ if (!isRecord$2(value)) return false;
5512
5512
  const ref = value["$secret"];
5513
5513
  return typeof ref === "string" && ref.length > 0;
5514
5514
  }
5515
5515
  function isSecretClear(value) {
5516
- return isRecord$1(value) && value["$secretClear"] === true;
5516
+ return isRecord$2(value) && value["$secretClear"] === true;
5517
5517
  }
5518
5518
  /**
5519
5519
  * The UI view of a stored secret field value: a marker becomes "set", inline
@@ -6029,6 +6029,13 @@ function globalSecretScope() {
6029
6029
  function encodeSegment(value) {
6030
6030
  return encodeURIComponent(value);
6031
6031
  }
6032
+ function decodeSegment(value) {
6033
+ try {
6034
+ return decodeURIComponent(value);
6035
+ } catch {
6036
+ return null;
6037
+ }
6038
+ }
6032
6039
  /**
6033
6040
  * The field path of a value inside an array item, addressed by the item's id:
6034
6041
  * `arrayItemFieldPath('providers', 'authentik', 'clientSecret')` →
@@ -6037,6 +6044,75 @@ function encodeSegment(value) {
6037
6044
  function arrayItemFieldPath(arrayKey, itemId, fieldKey) {
6038
6045
  return `${arrayKey}[${encodeSegment(itemId)}].${fieldKey}`;
6039
6046
  }
6047
+ function parseScope(segments) {
6048
+ switch (segments[0]) {
6049
+ case "global": return {
6050
+ scope: GLOBAL_SCOPE,
6051
+ used: 1
6052
+ };
6053
+ case "node": {
6054
+ const nodeId = segments[1] !== void 0 ? decodeSegment(segments[1]) : null;
6055
+ return nodeId === null || nodeId.length === 0 ? null : {
6056
+ scope: {
6057
+ kind: "node",
6058
+ nodeId
6059
+ },
6060
+ used: 2
6061
+ };
6062
+ }
6063
+ case "device": {
6064
+ const raw = segments[1];
6065
+ if (raw === void 0 || !/^\d+$/.test(raw)) return null;
6066
+ return {
6067
+ scope: {
6068
+ kind: "device",
6069
+ deviceId: Number(raw)
6070
+ },
6071
+ used: 2
6072
+ };
6073
+ }
6074
+ case "integration": {
6075
+ const id = segments[1] !== void 0 ? decodeSegment(segments[1]) : null;
6076
+ return id === null || id.length === 0 ? null : {
6077
+ scope: {
6078
+ kind: "integration",
6079
+ integrationId: id
6080
+ },
6081
+ used: 2
6082
+ };
6083
+ }
6084
+ case "row": {
6085
+ const collection = segments[1] !== void 0 ? decodeSegment(segments[1]) : null;
6086
+ const rowId = segments[2] !== void 0 ? decodeSegment(segments[2]) : null;
6087
+ if (collection === null || rowId === null || collection.length === 0 || rowId.length === 0) return null;
6088
+ return {
6089
+ scope: {
6090
+ kind: "row",
6091
+ collection,
6092
+ rowId
6093
+ },
6094
+ used: 3
6095
+ };
6096
+ }
6097
+ default: return null;
6098
+ }
6099
+ }
6100
+ /** Take a ref apart; `null` when it is not a well-formed ref. */
6101
+ function parseSecretRef(ref) {
6102
+ if (!ref.startsWith("secret://")) return null;
6103
+ const segments = ref.slice(9).split("/");
6104
+ const owner = segments[0] !== void 0 ? decodeSegment(segments[0]) : null;
6105
+ if (owner === null || owner.length === 0) return null;
6106
+ const parsed = parseScope(segments.slice(1));
6107
+ if (parsed === null) return null;
6108
+ const fieldPath = segments.slice(1 + parsed.used).join("/");
6109
+ if (fieldPath.length === 0) return null;
6110
+ return {
6111
+ owner,
6112
+ scope: parsed.scope,
6113
+ fieldPath
6114
+ };
6115
+ }
6040
6116
  /** A write to a secret path could not be stored in the keychain, so it was refused. */
6041
6117
  var KeychainWriteRefusedError = class extends Error {
6042
6118
  fieldPath;
@@ -6047,7 +6123,7 @@ var KeychainWriteRefusedError = class extends Error {
6047
6123
  }
6048
6124
  };
6049
6125
  var KEEP = { kind: "keep" };
6050
- function isRecord(value) {
6126
+ function isRecord$1(value) {
6051
6127
  return typeof value === "object" && value !== null && !Array.isArray(value);
6052
6128
  }
6053
6129
  function defaultMintId() {
@@ -6060,7 +6136,7 @@ function collectSecretMarkerRefs(value, out = []) {
6060
6136
  return out;
6061
6137
  }
6062
6138
  if (Array.isArray(value)) for (const item of value) collectSecretMarkerRefs(item, out);
6063
- else if (isRecord(value)) for (const child of Object.values(value)) collectSecretMarkerRefs(child, out);
6139
+ else if (isRecord$1(value)) for (const child of Object.values(value)) collectSecretMarkerRefs(child, out);
6064
6140
  return out;
6065
6141
  }
6066
6142
  async function storedValueEquals(secrets, marker, candidate) {
@@ -6115,7 +6191,7 @@ function rowId(row, idKey) {
6115
6191
  return null;
6116
6192
  }
6117
6193
  async function writeArray(ctx, node, incoming, stored, fieldPath) {
6118
- const storedRows = Array.isArray(stored) ? stored.filter(isRecord) : [];
6194
+ const storedRows = Array.isArray(stored) ? stored.filter(isRecord$1) : [];
6119
6195
  if (!Array.isArray(incoming)) {
6120
6196
  ctx.deletes.push(...collectSecretMarkerRefs(storedRows));
6121
6197
  return {
@@ -6131,7 +6207,7 @@ async function writeArray(ctx, node, incoming, stored, fieldPath) {
6131
6207
  const kept = /* @__PURE__ */ new Set();
6132
6208
  const rows = [];
6133
6209
  for (const row of incoming) {
6134
- if (!isRecord(row)) {
6210
+ if (!isRecord$1(row)) {
6135
6211
  rows.push(row);
6136
6212
  continue;
6137
6213
  }
@@ -6156,7 +6232,7 @@ async function writeNode(ctx, node, incoming, stored, fieldPath) {
6156
6232
  case "leaf": return writeLeaf(ctx, incoming, stored, fieldPath);
6157
6233
  case "array": return writeArray(ctx, node, incoming, stored, fieldPath);
6158
6234
  case "object": {
6159
- if (!isRecord(incoming)) {
6235
+ if (!isRecord$1(incoming)) {
6160
6236
  if (incoming === void 0) return KEEP;
6161
6237
  ctx.deletes.push(...collectSecretMarkerRefs(stored));
6162
6238
  return {
@@ -6164,7 +6240,7 @@ async function writeNode(ctx, node, incoming, stored, fieldPath) {
6164
6240
  value: incoming
6165
6241
  };
6166
6242
  }
6167
- const storedObj = isRecord(stored) ? stored : {};
6243
+ const storedObj = isRecord$1(stored) ? stored : {};
6168
6244
  return {
6169
6245
  kind: "value",
6170
6246
  value: await writeMembers(ctx, node.children, incoming, storedObj, (m) => `${fieldPath}.${m}`)
@@ -6223,12 +6299,19 @@ async function transformSecretWrite(input) {
6223
6299
  }
6224
6300
  };
6225
6301
  }
6302
+ /** Is `ref` one of `owner`'s refs? */
6303
+ function isSecretRefOwnedBy(ref, owner) {
6304
+ return parseSecretRef(ref)?.owner === owner;
6305
+ }
6226
6306
  /**
6227
6307
  * Replace every marker in `value` with its keychain value. Returns the SAME
6228
6308
  * reference when there is no marker (no allocation, no keychain call).
6229
6309
  */
6230
- async function resolveSecretMarkers(value, secrets) {
6231
- const refs = collectSecretMarkerRefs(value);
6310
+ async function resolveSecretMarkers(value, secrets, options = {}) {
6311
+ const keepMarker = options.unresolved === "keep-marker";
6312
+ const owner = options.ownedBy;
6313
+ const inScope = (ref) => owner === void 0 || isSecretRefOwnedBy(ref, owner);
6314
+ const refs = collectSecretMarkerRefs(value).filter(inScope);
6232
6315
  if (refs.length === 0) return {
6233
6316
  value,
6234
6317
  unresolved: []
@@ -6252,10 +6335,18 @@ async function resolveSecretMarkers(value, secrets) {
6252
6335
  }
6253
6336
  const substitute = (v) => {
6254
6337
  if (isSecretMarker(v)) {
6338
+ if (!inScope(v.$secret)) return {
6339
+ keep: true,
6340
+ value: v
6341
+ };
6255
6342
  const answer = answers[v.$secret];
6256
- return answer?.kind === "value" ? {
6343
+ if (answer?.kind === "value") return {
6257
6344
  keep: true,
6258
6345
  value: answer.value
6346
+ };
6347
+ return keepMarker ? {
6348
+ keep: true,
6349
+ value: v
6259
6350
  } : {
6260
6351
  keep: false,
6261
6352
  value: void 0
@@ -6272,7 +6363,7 @@ async function resolveSecretMarkers(value, secrets) {
6272
6363
  value: items
6273
6364
  };
6274
6365
  }
6275
- if (isRecord(v)) {
6366
+ if (isRecord$1(v)) {
6276
6367
  const out = {};
6277
6368
  for (const [k, child] of Object.entries(v)) {
6278
6369
  const s = substitute(child);
@@ -6293,14 +6384,152 @@ async function resolveSecretMarkers(value, secrets) {
6293
6384
  unresolved
6294
6385
  };
6295
6386
  }
6296
- function touchesTree(tree, patch) {
6297
- if (tree.size === 0) return false;
6298
- for (const key of Object.keys(patch)) {
6299
- const at = key.indexOf("@");
6300
- if (tree.has(at > 0 ? key.slice(0, at) : key)) return true;
6387
+ /** An addon tried to replace a stored secret it could not read. Nothing was written. */
6388
+ var SecretOverwriteRefusedError = class extends Error {
6389
+ ref;
6390
+ reason;
6391
+ constructor(ref, reason) {
6392
+ 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.`);
6393
+ this.ref = ref;
6394
+ this.reason = reason;
6395
+ this.name = "SecretOverwriteRefusedError";
6396
+ }
6397
+ };
6398
+ function isRecord(value) {
6399
+ return typeof value === "object" && value !== null && !Array.isArray(value);
6400
+ }
6401
+ function resolvedValue(pass, marker) {
6402
+ const answer = pass.answers[marker.$secret];
6403
+ return answer?.kind === "value" ? answer.value : null;
6404
+ }
6405
+ async function atMarker(pass, incoming, stored) {
6406
+ if (incoming === null) return stored;
6407
+ if (typeof incoming !== "string") return incoming;
6408
+ if (incoming === resolvedValue(pass, stored)) return stored;
6409
+ const intent = classifySecretWrite(incoming);
6410
+ if (intent.kind !== "set") return stored;
6411
+ const ref = stored.$secret;
6412
+ if (!isSecretRefOwnedBy(ref, pass.secrets.owner)) return incoming;
6413
+ const answer = pass.answers[ref];
6414
+ 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);
6415
+ try {
6416
+ await pass.secrets.put(ref, intent.value);
6417
+ } catch (err) {
6418
+ throw new KeychainWriteRefusedError(ref, err);
6419
+ }
6420
+ pass.changedRefs.push(ref);
6421
+ return stored;
6422
+ }
6423
+ function inArray(pass, incoming, stored) {
6424
+ return incoming.map((item, index) => {
6425
+ const twin = stored[index];
6426
+ if (isSecretMarker(twin)) return typeof item === "string" && item === resolvedValue(pass, twin) ? twin : item;
6427
+ if (isRecord(item) && isRecord(twin)) return inArrayRow(pass, item, twin);
6428
+ if (Array.isArray(item) && Array.isArray(twin)) return inArray(pass, item, twin);
6429
+ return item;
6430
+ });
6431
+ }
6432
+ function inArrayRow(pass, incoming, stored) {
6433
+ const out = { ...incoming };
6434
+ for (const [key, value] of Object.entries(incoming)) {
6435
+ const twin = stored[key];
6436
+ if (isSecretMarker(twin)) {
6437
+ if (typeof value === "string" && value === resolvedValue(pass, twin)) out[key] = twin;
6438
+ } else if (isRecord(value) && isRecord(twin)) out[key] = inArrayRow(pass, value, twin);
6439
+ else if (Array.isArray(value) && Array.isArray(twin)) out[key] = inArray(pass, value, twin);
6440
+ }
6441
+ return out;
6442
+ }
6443
+ async function walk$1(pass, incoming, stored) {
6444
+ if (isSecretMarker(stored)) return atMarker(pass, incoming, stored);
6445
+ if (Array.isArray(incoming) && Array.isArray(stored)) return inArray(pass, incoming, stored);
6446
+ if (!isRecord(incoming) || !isRecord(stored)) return incoming;
6447
+ const out = { ...incoming };
6448
+ for (const [key, value] of Object.entries(incoming)) out[key] = await walk$1(pass, value, stored[key]);
6449
+ return out;
6450
+ }
6451
+ /** Restore markers a write-back carries as values. See the file doc. */
6452
+ async function restoreUnchangedSecrets(input) {
6453
+ const refs = [];
6454
+ for (const key of Object.keys(input.patch)) collectSecretMarkerRefs(input.stored[key], refs);
6455
+ const owned = refs.filter((ref) => isSecretRefOwnedBy(ref, input.secrets.owner));
6456
+ if (owned.length === 0) return {
6457
+ patch: input.patch,
6458
+ changedRefs: []
6459
+ };
6460
+ const pass = {
6461
+ secrets: input.secrets,
6462
+ answers: await input.secrets.resolve([...new Set(owned)]),
6463
+ operatorWrite: input.operatorWrite,
6464
+ changedRefs: []
6465
+ };
6466
+ const out = {};
6467
+ for (const [key, value] of Object.entries(input.patch)) out[key] = await walk$1(pass, value, input.stored[key]);
6468
+ return {
6469
+ patch: out,
6470
+ changedRefs: pass.changedRefs
6471
+ };
6472
+ }
6473
+ /** Structural equality over JSON-shaped values (key order does not matter). */
6474
+ function isJsonEqual(a, b) {
6475
+ if (Object.is(a, b)) return true;
6476
+ if (Array.isArray(a)) return Array.isArray(b) && a.length === b.length && a.every((v, i) => isJsonEqual(v, b[i]));
6477
+ if (isRecord(a) && isRecord(b)) {
6478
+ const keys = Object.keys(a);
6479
+ if (keys.length !== Object.keys(b).length) return false;
6480
+ return keys.every((k) => Object.prototype.hasOwnProperty.call(b, k) && isJsonEqual(a[k], b[k]));
6301
6481
  }
6302
6482
  return false;
6303
6483
  }
6484
+ /** The patch without the keys whose value already equals the stored one. */
6485
+ function dropUnchangedKeys(patch, stored) {
6486
+ const out = {};
6487
+ for (const [key, value] of Object.entries(patch)) {
6488
+ if (Object.prototype.hasOwnProperty.call(stored, key) && isJsonEqual(value, stored[key])) continue;
6489
+ out[key] = value;
6490
+ }
6491
+ return out;
6492
+ }
6493
+ /** The top-level keys of a blob that hold at least one of `owner`'s markers. */
6494
+ function markerKeysOf(blob, owner) {
6495
+ const keys = /* @__PURE__ */ new Set();
6496
+ for (const [key, value] of Object.entries(blob)) if (collectSecretMarkerRefs(value).some((ref) => isSecretRefOwnedBy(ref, owner))) keys.add(key);
6497
+ return keys;
6498
+ }
6499
+ function nodeFromStored(value, owner) {
6500
+ if (isSecretMarker(value)) return isSecretRefOwnedBy(value.$secret, owner) ? { kind: "leaf" } : null;
6501
+ if (!isRecord(value)) return null;
6502
+ const children = /* @__PURE__ */ new Map();
6503
+ for (const [key, child] of Object.entries(value)) {
6504
+ const node = nodeFromStored(child, owner);
6505
+ if (node !== null) children.set(key, node);
6506
+ }
6507
+ return children.size > 0 ? {
6508
+ kind: "object",
6509
+ children
6510
+ } : null;
6511
+ }
6512
+ /**
6513
+ * The declared secret tree, widened by every place the STORED blob holds a
6514
+ * marker under one of `keys` — so a marker the schema no longer declares (or
6515
+ * never declared: Wyze before b4906cec6) still gets the save path's
6516
+ * KEEP / SET / CLEAR semantics instead of being overwritten by whatever the
6517
+ * addon writes. Markers inside arrays are not added: a row has no id field to
6518
+ * match by unless the schema declares one. Only `owner`'s markers count: a
6519
+ * builtin that keeps another addon's marker (device-manager) never takes it
6520
+ * over.
6521
+ */
6522
+ function widenTreeWithStoredMarkers(declared, stored, keys, owner) {
6523
+ const added = /* @__PURE__ */ new Map();
6524
+ for (const key of keys) {
6525
+ const at = key.indexOf("@");
6526
+ const base = at > 0 ? key.slice(0, at) : key;
6527
+ if (declared.has(base) || added.has(base)) continue;
6528
+ const node = nodeFromStored(stored[key], owner);
6529
+ if (node !== null) added.set(base, node);
6530
+ }
6531
+ return added.size === 0 ? declared : new Map([...declared, ...added]);
6532
+ }
6304
6533
  /** The blob as stored now; a failed read REFUSES the write instead of guessing. */
6305
6534
  async function readStoredAddonBlob(raw) {
6306
6535
  const threeWay = raw.readAddonStoreResult;
@@ -6309,7 +6538,41 @@ async function readStoredAddonBlob(raw) {
6309
6538
  if (result.kind === "failed") throw new Error(`settings write refused: the stored blob could not be read (${result.error})`);
6310
6539
  return result.kind === "missing" ? {} : result.value;
6311
6540
  }
6312
- function createSecretAwareSettings(raw, opts) {
6541
+ function touchesTree(tree, patch) {
6542
+ if (tree.size === 0) return false;
6543
+ for (const key of Object.keys(patch)) {
6544
+ const at = key.indexOf("@");
6545
+ if (tree.has(at > 0 ? key.slice(0, at) : key)) return true;
6546
+ }
6547
+ return false;
6548
+ }
6549
+ /**
6550
+ * Which top-level keys of each store held markers when last seen. `undefined`
6551
+ * for a store not seen yet: its first write reads it, to be safe.
6552
+ */
6553
+ var MarkerKeyIndex = class {
6554
+ owner;
6555
+ byStore = /* @__PURE__ */ new Map();
6556
+ constructor(owner) {
6557
+ this.owner = owner;
6558
+ }
6559
+ seen(store, blob) {
6560
+ this.byStore.set(store, markerKeysOf(blob, this.owner));
6561
+ }
6562
+ wrote(store, patch) {
6563
+ const keys = this.byStore.get(store);
6564
+ if (keys === void 0) return;
6565
+ const now = markerKeysOf(patch, this.owner);
6566
+ for (const key of Object.keys(patch)) if (now.has(key)) keys.add(key);
6567
+ else keys.delete(key);
6568
+ }
6569
+ mayHoldMarkers(store, patch) {
6570
+ const keys = this.byStore.get(store);
6571
+ if (keys === void 0) return true;
6572
+ return Object.keys(patch).some((key) => keys.has(key));
6573
+ }
6574
+ };
6575
+ function createHandle(raw, opts) {
6313
6576
  const chains = /* @__PURE__ */ new Map();
6314
6577
  const serialize = (key, fn) => {
6315
6578
  const next = (chains.get(key) ?? Promise.resolve()).then(fn, fn);
@@ -6320,46 +6583,130 @@ function createSecretAwareSettings(raw, opts) {
6320
6583
  });
6321
6584
  return next;
6322
6585
  };
6323
- const write = async (chainKey, tree, scope, patch, readStored, rawWrite) => {
6324
- if (!touchesTree(tree, patch)) return rawWrite(patch);
6325
- return serialize(chainKey, async () => {
6586
+ const index = new MarkerKeyIndex(opts.secrets.owner);
6587
+ const resolveRead = async (store, blob) => {
6588
+ index.seen(store, blob);
6589
+ const { value, unresolved } = await resolveSecretMarkers(blob, opts.secrets, {
6590
+ unresolved: "keep-marker",
6591
+ ownedBy: opts.secrets.owner
6592
+ });
6593
+ if (unresolved.length > 0) opts.onUnresolved?.(unresolved);
6594
+ return value;
6595
+ };
6596
+ const write = async (store, declared, scope, patch, readStored, rawWrite) => {
6597
+ if (!touchesTree(declared, patch) && !index.mayHoldMarkers(store, patch)) {
6598
+ await rawWrite(patch);
6599
+ index.wrote(store, patch);
6600
+ return { changed: true };
6601
+ }
6602
+ return serialize(store, async () => {
6326
6603
  const stored = await readStored();
6604
+ index.seen(store, stored);
6605
+ const operatorWrite = opts.isOperatorWrite?.() === true;
6606
+ const restored = await restoreUnchangedSecrets({
6607
+ patch,
6608
+ stored,
6609
+ secrets: opts.secrets,
6610
+ operatorWrite
6611
+ });
6327
6612
  const result = await transformSecretWrite({
6328
- tree,
6613
+ tree: widenTreeWithStoredMarkers(declared, stored, Object.keys(restored.patch), opts.secrets.owner),
6329
6614
  secrets: opts.secrets,
6330
- patch,
6615
+ patch: restored.patch,
6331
6616
  stored,
6332
6617
  ...scope !== void 0 ? { scope } : {},
6333
- operatorWrite: opts.isOperatorWrite?.() === true
6618
+ operatorWrite
6334
6619
  });
6335
- if (Object.keys(result.patch).length > 0) await rawWrite(result.patch);
6620
+ const effective = dropUnchangedKeys(result.patch, stored);
6621
+ const wroteBlob = Object.keys(effective).length > 0;
6622
+ if (wroteBlob) {
6623
+ await rawWrite(effective);
6624
+ index.wrote(store, effective);
6625
+ }
6336
6626
  const { orphaned } = await result.afterWrite();
6337
6627
  if (orphaned.length > 0) opts.onOrphaned(orphaned);
6628
+ return { changed: wroteBlob || restored.changedRefs.length > 0 };
6338
6629
  });
6339
6630
  };
6340
- const wrapped = {
6341
- writeAddonStore: (patch) => write("addon", opts.addonTree(), void 0, patch, () => readStoredAddonBlob(raw), (p) => raw.writeAddonStore(p)),
6342
- writeDeviceStore: (deviceId, patch) => write(`device:${deviceId}`, opts.deviceTree(), {
6343
- kind: "device",
6344
- deviceId
6345
- }, patch, () => raw.readDeviceStore(deviceId), (p) => raw.writeDeviceStore(deviceId, p))
6631
+ const writeAddon = (patch) => write("addon", opts.addonTree(), void 0, patch, () => readStoredAddonBlob(raw), (p) => raw.writeAddonStore(p));
6632
+ const readAddonStoreResult = raw.readAddonStoreResult;
6633
+ const readAddonStoreKeyResult = raw.readAddonStoreKeyResult;
6634
+ const readDeviceStoreBatch = raw.readDeviceStoreBatch;
6635
+ const overrides = {
6636
+ readAddonStore: async () => resolveRead("addon", await raw.readAddonStore()),
6637
+ ...readAddonStoreResult !== void 0 ? { readAddonStoreResult: async () => {
6638
+ const result = await readAddonStoreResult.call(raw);
6639
+ return result.kind === "value" ? {
6640
+ kind: "value",
6641
+ value: await resolveRead("addon", result.value)
6642
+ } : result;
6643
+ } } : {},
6644
+ ...readAddonStoreKeyResult !== void 0 ? { readAddonStoreKeyResult: async (key) => {
6645
+ const result = await readAddonStoreKeyResult.call(raw, key);
6646
+ if (result.kind !== "present") return result;
6647
+ const { value, unresolved } = await resolveSecretMarkers({ [key]: result.value }, opts.secrets, {
6648
+ unresolved: "keep-marker",
6649
+ ownedBy: opts.secrets.owner
6650
+ });
6651
+ if (unresolved.length > 0) opts.onUnresolved?.(unresolved);
6652
+ return {
6653
+ kind: "present",
6654
+ value: value[key]
6655
+ };
6656
+ } } : {},
6657
+ readDeviceStore: async (deviceId) => resolveRead(`device:${deviceId}`, await raw.readDeviceStore(deviceId)),
6658
+ ...readDeviceStoreBatch !== void 0 ? { readDeviceStoreBatch: async (deviceIds) => {
6659
+ const rows = await readDeviceStoreBatch.call(raw, deviceIds);
6660
+ const out = /* @__PURE__ */ new Map();
6661
+ for (const [deviceId, blob] of rows) out.set(deviceId, await resolveRead(`device:${deviceId}`, blob));
6662
+ return out;
6663
+ } } : {},
6664
+ writeAddonStore: async (patch) => {
6665
+ await writeAddon(patch);
6666
+ },
6667
+ writeDeviceStore: async (deviceId, patch) => {
6668
+ await write(`device:${deviceId}`, opts.deviceTree(), {
6669
+ kind: "device",
6670
+ deviceId
6671
+ }, patch, () => raw.readDeviceStore(deviceId), (p) => raw.writeDeviceStore(deviceId, p));
6672
+ }
6673
+ };
6674
+ return {
6675
+ settings: new Proxy(raw, { get(target, prop, receiver) {
6676
+ if (typeof prop === "string" && Object.prototype.hasOwnProperty.call(overrides, prop)) return Reflect.get(overrides, prop);
6677
+ const value = Reflect.get(target, prop, receiver);
6678
+ return typeof value === "function" ? value.bind(target) : value;
6679
+ } }),
6680
+ raw: {
6681
+ readAddonStore: async () => {
6682
+ const blob = await raw.readAddonStore();
6683
+ index.seen("addon", blob);
6684
+ return blob;
6685
+ },
6686
+ readDeviceStore: async (deviceId) => {
6687
+ const blob = await raw.readDeviceStore(deviceId);
6688
+ index.seen(`device:${deviceId}`, blob);
6689
+ return blob;
6690
+ }
6691
+ },
6692
+ writeAddonStore: writeAddon
6346
6693
  };
6347
- return new Proxy(raw, { get(target, prop, receiver) {
6348
- if (prop === "writeAddonStore") return wrapped.writeAddonStore;
6349
- if (prop === "writeDeviceStore") return wrapped.writeDeviceStore;
6350
- const value = Reflect.get(target, prop, receiver);
6351
- return typeof value === "function" ? value.bind(target) : value;
6352
- } });
6353
6694
  }
6354
- /** The context the addon sees: identical, except that its settings writes are secret-aware. */
6355
- function withSecretAwareSettings(context, opts) {
6695
+ /** The context the addon sees, plus the private raw view and write outcome. */
6696
+ function createSecretAwareContext(context, opts) {
6356
6697
  const raw = context.settings;
6357
- if (raw === void 0) return context;
6358
- const settings = createSecretAwareSettings(raw, opts);
6359
- return new Proxy(context, { get(target, prop, receiver) {
6360
- if (prop === "settings") return settings;
6361
- return Reflect.get(target, prop, receiver);
6362
- } });
6698
+ if (raw === void 0) return {
6699
+ context,
6700
+ handle: null
6701
+ };
6702
+ const handle = createHandle(raw, opts);
6703
+ return {
6704
+ context: new Proxy(context, { get(target, prop, receiver) {
6705
+ if (prop === "settings") return handle.settings;
6706
+ return Reflect.get(target, prop, receiver);
6707
+ } }),
6708
+ handle
6709
+ };
6363
6710
  }
6364
6711
  var LEAF = { kind: "leaf" };
6365
6712
  var DEFAULT_ITEM_ID_KEY = "id";
@@ -6534,6 +6881,14 @@ var BaseAddon = class {
6534
6881
  _secretChangeUnsub = null;
6535
6882
  /** >0 while an OPERATOR's settings write is being applied. */
6536
6883
  _operatorWriteDepth = 0;
6884
+ /**
6885
+ * The keychain-aware settings handle (D798). Its `raw` view is the ONLY way
6886
+ * to the marker-bearing blobs and stays private to this class: the form
6887
+ * hydrate and config resolution need markers, addon code never does.
6888
+ */
6889
+ _secretSettings = null;
6890
+ /** Refs an addon-facing read could not resolve — each is logged once per process. */
6891
+ _loggedUnresolvedReads = /* @__PURE__ */ new Set();
6537
6892
  constructor(defaults) {
6538
6893
  this.defaults = defaults;
6539
6894
  this._config = { ...defaults };
@@ -6570,13 +6925,21 @@ var BaseAddon = class {
6570
6925
  }
6571
6926
  async initialize(context) {
6572
6927
  const secrets = context.secrets;
6573
- this._ctx = secrets !== void 0 ? withSecretAwareSettings(context, {
6574
- secrets,
6575
- addonTree: () => this.addonSecretTree(),
6576
- deviceTree: () => this.deviceSecretTree(),
6577
- onOrphaned: (refs) => context.logger.warn("keychain refs dropped by a settings write could not be deleted", { meta: { refs: [...refs] } }),
6578
- isOperatorWrite: () => this._operatorWriteDepth > 0
6579
- }) : context;
6928
+ if (secrets !== void 0) {
6929
+ const { context: wrapped, handle } = createSecretAwareContext(context, {
6930
+ secrets,
6931
+ addonTree: () => this.addonSecretTree(),
6932
+ deviceTree: () => this.deviceSecretTree(),
6933
+ onOrphaned: (refs) => context.logger.warn("keychain refs dropped by a settings write could not be deleted", { meta: { refs: [...refs] } }),
6934
+ isOperatorWrite: () => this._operatorWriteDepth > 0,
6935
+ onUnresolved: (unresolved) => this.logUnresolvedRead(unresolved)
6936
+ });
6937
+ this._ctx = wrapped;
6938
+ this._secretSettings = handle;
6939
+ } else {
6940
+ this._ctx = context;
6941
+ this._secretSettings = null;
6942
+ }
6580
6943
  await this.resolveConfig();
6581
6944
  if (secrets !== void 0) this._secretChangeUnsub = secrets.onChange((ref) => {
6582
6945
  if (this._configSecretRefs.has(ref)) this.scheduleSecretReresolve(SECRET_CHANGE_DEBOUNCE_MS);
@@ -6693,11 +7056,8 @@ var BaseAddon = class {
6693
7056
  async getGlobalSettings(overlay, cap, nodeId) {
6694
7057
  const schema = this.globalSettingsSchema(cap);
6695
7058
  if (!schema) return { sections: [] };
6696
- const projected = await this.resolveGlobalStore(nodeId, cap);
6697
- return hydrateSchema(schema, overlay ? {
6698
- ...projected,
6699
- ...overlay
6700
- } : projected, { inlineSecretsAsViews: true });
7059
+ const projected = await this.readRawProjectedStore(nodeId, cap);
7060
+ return hydrateSchema(schema, overlay ? await this.overlayKeepingMarkers(projected, overlay) : projected, { inlineSecretsAsViews: true });
6701
7061
  }
6702
7062
  /**
6703
7063
  * The integration-level view of this addon's settings: exactly the sections
@@ -6742,7 +7102,7 @@ var BaseAddon = class {
6742
7102
  });
6743
7103
  }
6744
7104
  if (sections.length === 0) return null;
6745
- const projected = await this.resolveGlobalStore(nodeId);
7105
+ const projected = await this.readRawProjectedStore(nodeId);
6746
7106
  return hydrateSchema({
6747
7107
  ...schema,
6748
7108
  sections
@@ -6759,12 +7119,50 @@ var BaseAddon = class {
6759
7119
  * the store for custom option logic (option narrowing, value snapping) to
6760
7120
  * read it per-node — never `ctx.settings.readAddonStore()` directly.
6761
7121
  * `nodeId` omitted ⇒ the local node (node-blind injection from ctx).
7122
+ *
7123
+ * Keychain values come back RESOLVED (D798): a secret reads as its value,
7124
+ * never as a `{ $secret }` marker. One the keychain cannot serve right now
7125
+ * stays a marker — "stored, unavailable" (`isSecretMarker()` is true, and it
7126
+ * is listed in {@link unresolvedSecrets}) — never `''` and never absent, so
7127
+ * it cannot be mistaken for "nothing stored, mint a new one". Writing the
7128
+ * resolved blob back is a no-op for every unchanged secret.
6762
7129
  */
6763
7130
  async resolveGlobalStore(nodeId, cap) {
6764
7131
  const raw = await this._ctx?.settings?.readAddonStore() ?? {};
7132
+ return this.projectForNode(raw, nodeId, cap);
7133
+ }
7134
+ projectForNode(store, nodeId, cap) {
6765
7135
  const keys = this.perNodeKeys(cap);
6766
7136
  const node = normalizeNodeId(nodeId ?? this._ctx?.kernel?.localNodeId);
6767
- return keys.size > 0 ? projectStore(raw, keys, node) : raw;
7137
+ return keys.size > 0 ? projectStore(store, keys, node) : store;
7138
+ }
7139
+ /** The PROJECTED store with its markers — the form hydrate only (D798). */
7140
+ async readRawProjectedStore(nodeId, cap) {
7141
+ const raw = await this.rawSettings()?.readAddonStore() ?? {};
7142
+ return this.projectForNode(raw, nodeId, cap);
7143
+ }
7144
+ /**
7145
+ * `{ ...stored, ...overlay }`, except that an overlay member equal to the
7146
+ * RESOLVED stored one keeps the stored (marker-bearing) member — so a form
7147
+ * hydrated from a resolved overlay still shows a secret as "set", never as
7148
+ * its value.
7149
+ */
7150
+ async overlayKeepingMarkers(stored, overlay) {
7151
+ const secrets = this._ctx?.secrets;
7152
+ const merged = {
7153
+ ...stored,
7154
+ ...overlay
7155
+ };
7156
+ if (secrets === void 0 || collectSecretMarkerRefs(stored).length === 0) return merged;
7157
+ const { value: resolved } = await resolveSecretMarkers(stored, secrets, {
7158
+ unresolved: "keep-marker",
7159
+ ownedBy: secrets.owner
7160
+ });
7161
+ for (const key of Object.keys(overlay)) {
7162
+ if (collectSecretMarkerRefs(stored[key]).length === 0) continue;
7163
+ if (isJsonEqual(overlay[key], resolved[key])) merged[key] = stored[key];
7164
+ }
7165
+ return merged;
6768
7166
  }
6769
7167
  /**
6770
7168
  * Whether ONE global key of this addon's store was written, read three-way
@@ -6829,8 +7227,12 @@ var BaseAddon = class {
6829
7227
  async clearSecrets(keys, nodeId) {
6830
7228
  const tree = this.addonSecretTree();
6831
7229
  const keychain = this._ctx?.secrets !== void 0;
7230
+ const stored = keychain ? await this.readAddonStoreWithRetry() : {};
6832
7231
  const patch = {};
6833
- for (const key of keys) patch[key] = keychain && tree.has(key) ? SECRET_CLEAR : "";
7232
+ for (const key of keys) {
7233
+ const keychainStored = tree.has(key) || collectSecretMarkerRefs(stored[key]).length > 0;
7234
+ patch[key] = keychain && keychainStored ? SECRET_CLEAR : "";
7235
+ }
6834
7236
  await this.applyGlobalPatch(patch, nodeId);
6835
7237
  }
6836
7238
  async applyGlobalPatch(barePatch, nodeId) {
@@ -6838,7 +7240,11 @@ var BaseAddon = class {
6838
7240
  const localNode = normalizeNodeId(this._ctx?.kernel?.localNodeId);
6839
7241
  const target = normalizeNodeId(nodeId ?? this._ctx?.kernel?.localNodeId);
6840
7242
  const scoped = keys.size > 0 ? scopePatch(barePatch, keys, target) : barePatch;
6841
- await this._ctx?.settings?.writeAddonStore(scoped);
7243
+ const handle = this._secretSettings;
7244
+ if (handle !== null) {
7245
+ const { changed } = await handle.writeAddonStore(scoped);
7246
+ if (!changed) return;
7247
+ } else await this._ctx?.settings?.writeAddonStore(scoped);
6842
7248
  if (target !== localNode) return;
6843
7249
  await this.resolveConfig();
6844
7250
  await this.onConfigChanged();
@@ -6891,7 +7297,7 @@ var BaseAddon = class {
6891
7297
  async getDeviceSettings(deviceId) {
6892
7298
  const schema = this.deviceSettingsSchema();
6893
7299
  if (!schema) return { sections: [] };
6894
- return hydrateSchema(schema, await this._ctx?.settings?.readDeviceStore(deviceId) ?? {}, { inlineSecretsAsViews: true });
7300
+ return hydrateSchema(schema, await this.rawSettings()?.readDeviceStore(deviceId) ?? {}, { inlineSecretsAsViews: true });
6895
7301
  }
6896
7302
  async updateDeviceSettings(deviceId, patch) {
6897
7303
  await this._ctx?.settings?.writeDeviceStore(deviceId, patch);
@@ -7063,7 +7469,7 @@ var BaseAddon = class {
7063
7469
  key,
7064
7470
  schema,
7065
7471
  fallback,
7066
- read: async () => this.resolveStoredSecrets(await this._ctx?.settings?.readDeviceStore(deviceId) ?? {}, false),
7472
+ read: async () => this.resolveStoredSecrets(await this.rawSettings()?.readDeviceStore(deviceId) ?? {}, false),
7067
7473
  write: async (patch) => {
7068
7474
  await this._ctx?.settings?.writeDeviceStore(deviceId, patch);
7069
7475
  },
@@ -7125,6 +7531,23 @@ var BaseAddon = class {
7125
7531
  }
7126
7532
  return value;
7127
7533
  }
7534
+ /**
7535
+ * The marker-bearing settings reads (D798) — private on purpose. Without a
7536
+ * keychain the context's own view is already raw.
7537
+ */
7538
+ rawSettings() {
7539
+ return this._secretSettings?.raw ?? this._ctx?.settings;
7540
+ }
7541
+ /** An addon-facing read met markers it could not resolve: say so once per ref. */
7542
+ logUnresolvedRead(unresolved) {
7543
+ const fresh = unresolved.filter((u) => !this._loggedUnresolvedReads.has(u.ref));
7544
+ if (fresh.length === 0) return;
7545
+ for (const u of fresh) this._loggedUnresolvedReads.add(u.ref);
7546
+ 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) => ({
7547
+ ref: u.ref,
7548
+ reason: u.reason
7549
+ })) } });
7550
+ }
7128
7551
  /** Re-resolve the config (a keychain-only change, or a retry) and apply it. */
7129
7552
  scheduleSecretReresolve(delayMs) {
7130
7553
  const timerOf = delayMs === SECRET_CHANGE_DEBOUNCE_MS ? "_secretChangeTimer" : "_secretRetryTimer";
@@ -7151,7 +7574,7 @@ var BaseAddon = class {
7151
7574
  * `{}` (defaults) — the addon's first successful patch will rehydrate.
7152
7575
  */
7153
7576
  async readAddonStoreWithRetry() {
7154
- const settings = this._ctx?.settings;
7577
+ const settings = this.rawSettings();
7155
7578
  if (!settings) return {};
7156
7579
  const delaysMs = [
7157
7580
  150,
@@ -9489,6 +9912,278 @@ var CameraSwitchGroupSchema = object({
9489
9912
  fetchedAt: number()
9490
9913
  });
9491
9914
  /**
9915
+ * The trainer contract — what the hub hands the cloud trainer and what it
9916
+ * gets back (cloud training, D805+).
9917
+ *
9918
+ * The trainer (`hf/camstack-trainer`, published as the Hugging Face repo
9919
+ * `camstack/camstack-trainer`) is a separate AGPL program the hub never
9920
+ * imports: `job.json` goes in, files come out, and progress is `CAMSTACK_EVENT`
9921
+ * lines on stdout. These schemas are the hub's half of that boundary; the
9922
+ * trainer's pydantic models (and the JSON Schemas generated from them under
9923
+ * `hf/camstack-trainer/schemas/`) are the other half. A change here is a
9924
+ * change there, in the same piece of work.
9925
+ *
9926
+ * No `.default()` anywhere: defaults do not run on the addon cap path, so the
9927
+ * orchestrator fills every field of a job spec explicitly.
9928
+ */
9929
+ var TRAINING_JOB_SCHEMA = "camstack.training/v1";
9930
+ var TRAINING_RESULT_SCHEMA = "camstack.training-result/v1";
9931
+ /** What the trainer can export. Edge TPU is a later, separate image. */
9932
+ var TrainingExportSchema = _enum([
9933
+ "onnx",
9934
+ "openvino-fp16",
9935
+ "openvino-int8",
9936
+ "coreml-fp16"
9937
+ ]);
9938
+ var FloorsSchema = record(string(), number().min(0).max(1));
9939
+ object({
9940
+ schema: literal(TRAINING_JOB_SCHEMA),
9941
+ jobKey: string().uuid(),
9942
+ target: object({
9943
+ kind: literal("detector"),
9944
+ step: literal("object-detection")
9945
+ }),
9946
+ base: object({
9947
+ modelId: string().min(1),
9948
+ /** Ultralytics weights id, e.g. `yolov9m.pt`. */
9949
+ weights: string().min(1),
9950
+ imgsz: number().int().positive()
9951
+ }),
9952
+ baseline: object({
9953
+ modelId: string().min(1),
9954
+ /** The baseline ONNX the holdout comparison runs; public mirror URL. */
9955
+ onnxUrl: string().url(),
9956
+ imgsz: number().int().positive(),
9957
+ floors: FloorsSchema
9958
+ }),
9959
+ dataset: object({
9960
+ versionId: string().min(1),
9961
+ annotationHash: string(),
9962
+ /** sha256 of the uploaded archive; the trainer refuses a mismatch (exit 65). */
9963
+ sha256: string().regex(/^[0-9a-f]{64}$/)
9964
+ }),
9965
+ split: object({
9966
+ holdoutCameras: array(number().int()),
9967
+ /** When no camera is held out: the last N days of every camera. */
9968
+ holdoutLastDays: number().int().nonnegative(),
9969
+ valFraction: number().min(0).max(.5),
9970
+ seed: number().int()
9971
+ }),
9972
+ hyper: object({
9973
+ epochs: number().int().positive(),
9974
+ batch: number().int().positive(),
9975
+ lr0: number().positive(),
9976
+ /** Layers frozen from the start of the backbone; 0 = none. */
9977
+ freeze: number().int().nonnegative(),
9978
+ patience: number().int().nonnegative(),
9979
+ seed: number().int()
9980
+ }),
9981
+ replay: object({
9982
+ source: literal("coco2017"),
9983
+ count: number().int().nonnegative()
9984
+ }),
9985
+ exports: array(TrainingExportSchema).min(1),
9986
+ calibration: object({ maxFrames: number().int().positive() }),
9987
+ floors: object({
9988
+ minSupport: number().int().positive(),
9989
+ clamp: number().min(0).max(1)
9990
+ }),
9991
+ int8Gate: object({ maxMap50Drop: number().min(0).max(1) }),
9992
+ catalog: object({
9993
+ id: string().regex(/^[a-z0-9][a-z0-9-]{2,80}$/),
9994
+ name: string().min(1).max(160)
9995
+ })
9996
+ });
9997
+ /** One regular file of the bundle. An mlpackage contributes one row per member. */
9998
+ var TrainingResultFileSchema = object({
9999
+ path: string().min(1),
10000
+ bytes: number().int().nonnegative(),
10001
+ sha256: string().regex(/^[0-9a-f]{64}$/),
10002
+ format: _enum([
10003
+ "onnx",
10004
+ "openvino",
10005
+ "coreml",
10006
+ "pt"
10007
+ ]),
10008
+ variant: _enum(["base", "int8"])
10009
+ });
10010
+ var DraftFormatSchema = object({
10011
+ /** RELATIVE path inside the bundle; the hub rewrites it to `camstack-local://`. */
10012
+ url: string().min(1),
10013
+ sizeMB: number().nonnegative(),
10014
+ isDirectory: boolean().optional(),
10015
+ files: array(string()).optional(),
10016
+ runtimes: array(literal("python")).optional(),
10017
+ revision: string().min(1)
10018
+ });
10019
+ /** The trainer's half of a catalog entry; the hub completes it (labels, licence, group). */
10020
+ var TrainingCatalogDraftSchema = object({
10021
+ id: string().min(1),
10022
+ name: string().min(1),
10023
+ description: string(),
10024
+ labels: array(unknown()),
10025
+ inputSize: object({
10026
+ width: number().int().positive(),
10027
+ height: number().int().positive()
10028
+ }),
10029
+ preprocessMode: literal("letterbox"),
10030
+ defaultClassFloors: FloorsSchema,
10031
+ formats: object({
10032
+ onnx: DraftFormatSchema.optional(),
10033
+ openvino: DraftFormatSchema.optional(),
10034
+ coreml: DraftFormatSchema.optional()
10035
+ })
10036
+ });
10037
+ /** One class of one model's holdout report (the eval harness's summary). */
10038
+ var TrainingEvalClassSchema = object({
10039
+ positives: number().int(),
10040
+ floor: number().nullable(),
10041
+ tp: number().int(),
10042
+ fp: number().int(),
10043
+ fn: number().int(),
10044
+ precision: number().nullable(),
10045
+ recall: number().nullable(),
10046
+ ap50: number().nullable(),
10047
+ recallByCamera: record(string(), number().nullable()).optional(),
10048
+ recallByLight: record(string(), number().nullable()).optional(),
10049
+ fpByCamera: record(string(), number()).optional(),
10050
+ smallFound: number().int().optional(),
10051
+ smallTotal: number().int().optional()
10052
+ }).passthrough();
10053
+ var TrainingEvalReportSchema = object({
10054
+ frames: number().int(),
10055
+ classes: record(string(), TrainingEvalClassSchema)
10056
+ }).passthrough();
10057
+ /**
10058
+ * A succeeded result carries every block; a failed one carries the error and
10059
+ * whatever was known by then — the other blocks are ABSENT, not null. The
10060
+ * orchestrator checks the blocks it needs before it trusts a success.
10061
+ */
10062
+ var TrainingResultSchema = object({
10063
+ schema: literal(TRAINING_RESULT_SCHEMA),
10064
+ jobKey: string(),
10065
+ status: _enum(["succeeded", "failed"]),
10066
+ error: object({
10067
+ stage: string(),
10068
+ code: string(),
10069
+ message: string()
10070
+ }).nullable(),
10071
+ trainer: object({
10072
+ version: string(),
10073
+ revision: string()
10074
+ }),
10075
+ toolchain: record(string(), string().nullable()),
10076
+ dataset: object({
10077
+ versionId: string(),
10078
+ annotationHash: string(),
10079
+ sha256: string(),
10080
+ frames: object({
10081
+ train: number().int(),
10082
+ val: number().int(),
10083
+ holdout: number().int()
10084
+ }),
10085
+ holdoutCameras: array(number().int()),
10086
+ replayImages: number().int()
10087
+ }).optional(),
10088
+ training: object({
10089
+ epochsRun: number().int(),
10090
+ bestEpoch: number().int(),
10091
+ bestMap50: number(),
10092
+ bestMap50_95: number(),
10093
+ seconds: number()
10094
+ }).optional(),
10095
+ evaluation: object({
10096
+ holdoutFrames: number().int(),
10097
+ baseline: TrainingEvalReportSchema.nullable(),
10098
+ candidate: TrainingEvalReportSchema.nullable(),
10099
+ candidateInt8: TrainingEvalReportSchema.nullable(),
10100
+ recallDeltaByCamera: record(string(), record(string(), number())).nullable(),
10101
+ map50: record(string(), number().nullable())
10102
+ }).optional(),
10103
+ floors: object({
10104
+ baseline: FloorsSchema,
10105
+ candidate: FloorsSchema,
10106
+ candidateInt8: FloorsSchema.nullable(),
10107
+ notes: array(string())
10108
+ }).optional(),
10109
+ int8: object({
10110
+ kept: boolean(),
10111
+ map50Fp16: number().nullable(),
10112
+ map50Int8: number().nullable(),
10113
+ reason: string().nullable()
10114
+ }).optional(),
10115
+ exportsDropped: array(object({
10116
+ export: string(),
10117
+ reason: string()
10118
+ })).optional(),
10119
+ files: array(TrainingResultFileSchema).optional(),
10120
+ bundle: object({
10121
+ path: literal("bundle.tar"),
10122
+ bytes: number().int().nonnegative(),
10123
+ sha256: string().regex(/^[0-9a-f]{64}$/)
10124
+ }).nullable().optional(),
10125
+ catalogDraft: object({
10126
+ base: TrainingCatalogDraftSchema,
10127
+ int8: TrainingCatalogDraftSchema.nullable()
10128
+ }).nullable().optional(),
10129
+ licence: string()
10130
+ });
10131
+ var TrainingStageSchema = _enum([
10132
+ "prepare",
10133
+ "replay",
10134
+ "train",
10135
+ "eval",
10136
+ "export",
10137
+ "package"
10138
+ ]);
10139
+ var EventBase = {
10140
+ v: literal(1),
10141
+ ts: number()
10142
+ };
10143
+ discriminatedUnion("type", [
10144
+ object({
10145
+ ...EventBase,
10146
+ type: literal("stage"),
10147
+ stage: TrainingStageSchema
10148
+ }),
10149
+ object({
10150
+ ...EventBase,
10151
+ type: literal("epoch"),
10152
+ epoch: number().int(),
10153
+ epochs: number().int(),
10154
+ boxLoss: number().nullable().optional(),
10155
+ map50: number().nullable().optional(),
10156
+ map50_95: number().nullable().optional(),
10157
+ etaSec: number().nullable().optional()
10158
+ }),
10159
+ object({
10160
+ ...EventBase,
10161
+ type: literal("metric"),
10162
+ name: string(),
10163
+ value: number()
10164
+ }),
10165
+ object({
10166
+ ...EventBase,
10167
+ type: literal("artifact"),
10168
+ path: string(),
10169
+ bytes: number(),
10170
+ sha256: string()
10171
+ }),
10172
+ object({
10173
+ ...EventBase,
10174
+ type: literal("done"),
10175
+ status: _enum(["succeeded", "failed"]),
10176
+ resultSha256: string().nullable().optional()
10177
+ }),
10178
+ object({
10179
+ ...EventBase,
10180
+ type: literal("error"),
10181
+ stage: string(),
10182
+ code: string(),
10183
+ message: string()
10184
+ })
10185
+ ]);
10186
+ /**
9492
10187
  * What the gate decided about a birth, from the CALLER's point of view.
9493
10188
  *
9494
10189
  * Deliberately not `ConfirmationVerdict`: `undecided` is not a birth decision
@@ -11838,7 +12533,9 @@ var AddonHttpRouteSchema = object({
11838
12533
  "authenticated",
11839
12534
  "admin"
11840
12535
  ]).optional(),
11841
- description: string().optional()
12536
+ description: string().optional(),
12537
+ /** The hub limits this route per client address before the handler runs. */
12538
+ rateLimit: _enum(["auth"]).optional()
11842
12539
  });
11843
12540
  /**
11844
12541
  * Cross-process route invocation envelope. The hub captures the
@@ -12788,6 +13485,37 @@ var BackupDestinationInfoSchema = object({
12788
13485
  lastError: string().optional()
12789
13486
  });
12790
13487
  /**
13488
+ * How an archive is encrypted (operator decision 2026-10-09): to a backup
13489
+ * PUBLIC key the hub holds, so only the operator's secret key opens it.
13490
+ * Absent on a plain `.tar.gz` — every archive made before encryption, or
13491
+ * with it off — which restores without a key.
13492
+ */
13493
+ var BackupArchiveEncryptionSchema = object({
13494
+ /** `x25519-hkdf-aes256gcm-stream-v1`. */
13495
+ scheme: string(),
13496
+ /** 16 hex — the backup key whose secret restores this archive. */
13497
+ keyId: string()
13498
+ });
13499
+ /**
13500
+ * The backup encryption setting. The hub keeps PUBLIC keys only: the active
13501
+ * one new archives are encrypted to, and the retired ones older archives
13502
+ * still need. The secret key is shown once, at `setupEncryption`.
13503
+ */
13504
+ var BackupEncryptionStatusSchema = object({
13505
+ enabled: boolean(),
13506
+ active: object({
13507
+ keyId: string(),
13508
+ publicKey: string(),
13509
+ createdAt: number()
13510
+ }).nullable(),
13511
+ /** Every key ever set up, newest first. */
13512
+ keys: array(object({
13513
+ keyId: string(),
13514
+ createdAt: number(),
13515
+ retiredAt: number().nullable()
13516
+ })).readonly()
13517
+ });
13518
+ /**
12791
13519
  * Per-archive entry returned by `backup.listArchives({ destinationId })`.
12792
13520
  * Same shape the destination drill-in renders. Sourced from the per-
12793
13521
  * location `manifests.json` (no per-archive tarball read required).
@@ -12799,7 +13527,9 @@ var BackupArchiveEntrySchema = object({
12799
13527
  sizeBytes: number(),
12800
13528
  label: string().optional(),
12801
13529
  /** Top-level locations included in the archive (db, addons, tls, …). */
12802
- locations: array(string()).readonly()
13530
+ locations: array(string()).readonly(),
13531
+ /** Present when the archive is encrypted; restore then needs that key. */
13532
+ encryption: BackupArchiveEncryptionSchema.optional()
12803
13533
  });
12804
13534
  var BackupEntrySchema = object({
12805
13535
  id: string(),
@@ -12808,7 +13538,8 @@ var BackupEntrySchema = object({
12808
13538
  label: string().optional(),
12809
13539
  createdAt: number(),
12810
13540
  sizeBytes: number(),
12811
- locations: array(string()).optional()
13541
+ locations: array(string()).optional(),
13542
+ encryption: BackupArchiveEncryptionSchema.optional()
12812
13543
  });
12813
13544
  var ArchiveEntrySchema = object({
12814
13545
  path: string(),
@@ -13063,11 +13794,58 @@ var backupCapability = {
13063
13794
  * this list and skips entries whose path doesn't start with
13064
13795
  * any of them.
13065
13796
  */
13066
- locations: array(string()).optional()
13797
+ locations: array(string()).optional(),
13798
+ /**
13799
+ * The backup SECRET key, for an encrypted archive (ignored for a plain
13800
+ * one). The archive is decrypted into the hub's private staging
13801
+ * before the restart; the key is not stored. A wrong or missing key
13802
+ * is refused before the archive is downloaded.
13803
+ */
13804
+ backupSecretKey: string().optional()
13067
13805
  }), _void(), {
13068
13806
  kind: "mutation",
13069
13807
  auth: "admin"
13070
13808
  }),
13809
+ /** The encryption setting — public keys only. */
13810
+ getEncryption: method(_void(), BackupEncryptionStatusSchema, { auth: "admin" }),
13811
+ /**
13812
+ * Turn encryption on, or replace the key: generates a new key pair, keeps
13813
+ * the PUBLIC key, and returns the SECRET key — once. It is never stored
13814
+ * on the hub and cannot be shown again; archives made from now on need
13815
+ * it to be restored. A previous key is retired: archives made with it
13816
+ * still need IT.
13817
+ */
13818
+ setupEncryption: method(object({}), object({
13819
+ keyId: string(),
13820
+ secretKey: string(),
13821
+ publicKey: string(),
13822
+ createdAt: number(),
13823
+ replacedKeyId: string().nullable()
13824
+ }), {
13825
+ kind: "mutation",
13826
+ auth: "admin"
13827
+ }),
13828
+ /** New archives are plain again. Existing encrypted archives keep needing their key. */
13829
+ disableEncryption: method(object({}), object({ disabledKeyId: string().nullable() }), {
13830
+ kind: "mutation",
13831
+ auth: "admin"
13832
+ }),
13833
+ /**
13834
+ * Does this secret key parse, and which backup key is it? A mutation so
13835
+ * the key never travels in a URL. Nothing is stored.
13836
+ */
13837
+ checkBackupKey: method(object({ backupSecretKey: string() }), object({
13838
+ valid: boolean(),
13839
+ keyId: string().nullable(),
13840
+ /** The hub knows this key (active or retired). */
13841
+ known: boolean(),
13842
+ /** It is the key new archives are encrypted to. */
13843
+ active: boolean(),
13844
+ error: string().optional()
13845
+ }), {
13846
+ kind: "mutation",
13847
+ auth: "admin"
13848
+ }),
13071
13849
  delete: method(object({
13072
13850
  destinationId: string(),
13073
13851
  backupId: string()
@@ -15252,22 +16030,87 @@ var CustomModelDescriptorSchema = object({
15252
16030
  stepId: string(),
15253
16031
  entry: ModelCatalogEntrySchema
15254
16032
  });
16033
+ /** One regular file of an imported bundle, as the producer measured it. */
16034
+ var ModelBundleFileSchema = object({
16035
+ /** Relative path inside the bundle tar; an mlpackage member is `<x>.mlpackage/<member>`. */
16036
+ path: string().min(1),
16037
+ bytes: number().int().nonnegative(),
16038
+ sha256: string().regex(/^[0-9a-f]{64}$/)
16039
+ });
16040
+ var ImportModelBundleInputSchema = object({
16041
+ /** The registry provider that keeps the model (Model Studio). */
16042
+ addonId: string(),
16043
+ stepId: string().min(1),
16044
+ /**
16045
+ * The catalog rows to register, complete, every format URL already
16046
+ * `camstack-local://<modelId>/<file>` naming a file of the bundle. One
16047
+ * bundle may carry several rows (a base and its INT8 variant).
16048
+ */
16049
+ entries: array(ModelCatalogEntrySchema).min(1).max(4),
16050
+ /** The bundle tar, offered by the producer over `ctx.peerBytes` (same host). */
16051
+ bundle: object({
16052
+ ticket: PeerBytesTicketSchema,
16053
+ bytes: number().int().positive(),
16054
+ sha256: string().regex(/^[0-9a-f]{64}$/)
16055
+ }),
16056
+ /** Every file the tar must hold; anything missing, extra or different is refused. */
16057
+ files: array(ModelBundleFileSchema).min(1).max(64),
16058
+ /** Convert missing engine formats and push the model to every agent afterwards. */
16059
+ distribute: boolean()
16060
+ });
16061
+ var ImportModelBundleResultSchema = discriminatedUnion("kind", [object({
16062
+ kind: literal("imported"),
16063
+ modelIds: array(string()).readonly(),
16064
+ distributed: array(object({
16065
+ modelId: string(),
16066
+ nodeId: string(),
16067
+ format: _enum(MODEL_FORMATS),
16068
+ ok: boolean(),
16069
+ error: string().optional()
16070
+ })).readonly()
16071
+ }), object({
16072
+ kind: literal("refused"),
16073
+ reason: _enum([
16074
+ "transfer-failed",
16075
+ "checksum-mismatch",
16076
+ "bundle-mismatch",
16077
+ "invalid-entry",
16078
+ "id-taken"
16079
+ ]),
16080
+ detail: string()
16081
+ })]);
15255
16082
  var customModelRegistryCapability = {
15256
16083
  name: "custom-model-registry",
15257
16084
  scope: "system",
15258
16085
  mode: "collection",
15259
16086
  internal: true,
15260
- methods: {
15261
- /**
15262
- * `internal: true` did not gate the mount (see the 2026-08-26 note on
15263
- * `data-store-provider`) — this was reachable on the AppRouter by ANY
15264
- * authenticated session at the default `auth: 'protected'`. The only
15265
- * consumer, the detection-pipeline's model resolution
15266
- * (`addon-pipeline/src/detection-pipeline/provider.ts`), calls
15267
- * `ctx.api.customModelRegistry.listModels.query()` — UDS/Moleculer,
15268
- * never tRPC — so `auth: 'admin'` costs it nothing.
15269
- */
15270
- listModels: method(_void(), array(CustomModelDescriptorSchema).readonly(), { auth: "admin" }) }
16087
+ methods: {
16088
+ /**
16089
+ * `internal: true` did not gate the mount (see the 2026-08-26 note on
16090
+ * `data-store-provider`) — this was reachable on the AppRouter by ANY
16091
+ * authenticated session at the default `auth: 'protected'`. The only
16092
+ * consumer, the detection-pipeline's model resolution
16093
+ * (`addon-pipeline/src/detection-pipeline/provider.ts`), calls
16094
+ * `ctx.api.customModelRegistry.listModels.query()` — UDS/Moleculer,
16095
+ * never tRPC — so `auth: 'admin'` costs it nothing.
16096
+ */
16097
+ listModels: method(_void(), array(CustomModelDescriptorSchema).readonly(), { auth: "admin" }),
16098
+ /**
16099
+ * Register a model whose files arrive as ONE bundle tar (D806): the tar
16100
+ * is taken over `ctx.peerBytes`, checked against `bundle.sha256` and
16101
+ * every row of `files`, unpacked into the hub's flat modelsDir (directory
16102
+ * formats included), each format's `.revision` record written, the rows
16103
+ * upserted under the operator's name, the hub marked available and —
16104
+ * when asked — engine formats converted and the model distributed. A
16105
+ * model id already registered by another source is refused, never
16106
+ * overwritten.
16107
+ */
16108
+ importModelBundle: method(ImportModelBundleInputSchema, ImportModelBundleResultSchema, {
16109
+ kind: "mutation",
16110
+ auth: "admin",
16111
+ timeoutMs: 30 * 6e4
16112
+ })
16113
+ }
15271
16114
  };
15272
16115
  /**
15273
16116
  * Query filter for settings-store collections.
@@ -16058,6 +16901,35 @@ var KeychainKeySourceSchema = object({
16058
16901
  */
16059
16902
  sharesBackupWithDatabase: boolean()
16060
16903
  });
16904
+ /**
16905
+ * One keychain reset, as the Secrets page reports it until the operator
16906
+ * acknowledges it. Never a value: refs, counts and table names only.
16907
+ */
16908
+ var KeychainResetRecordSchema = object({
16909
+ id: string(),
16910
+ at: number(),
16911
+ /** `user:<id>` or {@link KEYCHAIN_RESET_TRIGGER_ACTOR}. */
16912
+ actor: string(),
16913
+ /** Why the keychain was locked when it was reset; `null` when it was not locked. */
16914
+ lockedReason: string().nullable(),
16915
+ /** Values moved into the archive table (ciphertext under the lost key). */
16916
+ archived: number().int(),
16917
+ /** `keychain:secrets-orphaned-<ts>`, or `null` when nothing was stored. */
16918
+ archivedCollection: string().nullable(),
16919
+ /**
16920
+ * `keychain:keys-orphaned-<ts>`: the wrapped data keys of the archive, kept
16921
+ * so the archive can still be opened if the lost master key turns up.
16922
+ */
16923
+ archivedKeysCollection: string().nullable(),
16924
+ /**
16925
+ * `system-settings` keys whose marker the reset cleared — the cluster
16926
+ * secret's: a marker left pointing at an archived value would refuse every
16927
+ * agent forever (D797).
16928
+ */
16929
+ clearedSettingsKeys: array(string()).readonly(),
16930
+ /** When an operator dismissed the notice on the Secrets page; `null` until then. */
16931
+ acknowledgedAt: number().nullable()
16932
+ });
16061
16933
  var KeychainStatusSchema = object({
16062
16934
  keychain: KeychainStateSchema,
16063
16935
  /** The source of the master key in use; `null` while locked. */
@@ -16075,7 +16947,9 @@ var KeychainStatusSchema = object({
16075
16947
  /** Wrapped copies of the data key under a previous master key, kept until purged. */
16076
16948
  retiredWraps: number().int(),
16077
16949
  recoveryKeyDownloadedAt: number().nullable(),
16078
- secretCount: number().int()
16950
+ secretCount: number().int(),
16951
+ /** The most recent reset, acknowledged or not; `null` when the keychain was never reset. */
16952
+ lastReset: KeychainResetRecordSchema.nullable()
16079
16953
  });
16080
16954
  /**
16081
16955
  * Whether a stored value is still pointed at by its owner's settings.
@@ -16097,13 +16971,14 @@ var KeychainAuditActionSchema = _enum([
16097
16971
  "download-recovery-key",
16098
16972
  "delete-orphans",
16099
16973
  "reset",
16974
+ "acknowledge-reset",
16100
16975
  "initialize"
16101
16976
  ]);
16102
16977
  var KeychainAuditEntrySchema = object({
16103
16978
  id: string(),
16104
16979
  at: number(),
16105
16980
  action: KeychainAuditActionSchema,
16106
- /** `addon:<id>` | `user:<id>` | `system`. */
16981
+ /** `addon:<id>` | `user:<id>` | `system` | `trigger-file`. */
16107
16982
  actor: string(),
16108
16983
  ref: string().nullable(),
16109
16984
  detail: string().nullable()
@@ -16213,6 +17088,21 @@ var keychainAdminCapability = {
16213
17088
  kind: "mutation",
16214
17089
  auth: "admin",
16215
17090
  caller: "required"
17091
+ }),
17092
+ /**
17093
+ * What the last reset left to re-enter: the archived refs (owner, scope,
17094
+ * field — never a value) that hold no value again yet. Process-held refs
17095
+ * the hub regenerates itself (the session signing key) are not listed.
17096
+ */
17097
+ resetReport: method(object({}), object({
17098
+ reset: KeychainResetRecordSchema.nullable(),
17099
+ pendingReentry: array(KeychainSecretMetaSchema).readonly()
17100
+ }), { auth: "admin" }),
17101
+ /** Dismiss the "keychain was reset" notice. Audited. */
17102
+ acknowledgeReset: method(object({}), object({ acknowledged: boolean() }), {
17103
+ kind: "mutation",
17104
+ auth: "admin",
17105
+ caller: "required"
16216
17106
  })
16217
17107
  }
16218
17108
  };
@@ -20128,7 +21018,7 @@ var logDestinationCapability = {
20128
21018
  * `login-method` — collection cap through which auth addons contribute
20129
21019
  * their pre-auth login surfaces to the login page. This is the SINGLE,
20130
21020
  * generic mechanism that supersedes the dead `auth.listProviders` reader:
20131
- * every auth addon (OIDC, magic-link, WebAuthn/passkey) registers a
21021
+ * every auth addon (OIDC, WebAuthn/passkey) registers a
20132
21022
  * `login-method` provider and the PUBLIC `auth.listLoginMethods`
20133
21023
  * procedure aggregates them for the unauthenticated login page.
20134
21024
  *
@@ -20136,8 +21026,7 @@ var logDestinationCapability = {
20136
21026
  *
20137
21027
  * - `redirect` — a declarative button. The login page renders a generic
20138
21028
  * button that navigates to `startUrl` (an addon-owned HTTP route).
20139
- * Covers OIDC (`/addon/auth-oidc/<id>/start`) and magic-link with
20140
- * ZERO shell-side JS. A future SSO addon plugs in the same way — the
21029
+ * Covers OIDC (`/addon/auth-oidc/<id>/start`) with ZERO shell-side JS. A future SSO addon plugs in the same way — the
20141
21030
  * login page needs NO change.
20142
21031
  *
20143
21032
  * - `widget` — a Module-Federation widget the login page mounts (via
@@ -20156,8 +21045,8 @@ var logDestinationCapability = {
20156
21045
  * decision.
20157
21046
  *
20158
21047
  * Every contribution carries a `stage`:
20159
- * - `primary` — shown on the first credentials screen (OIDC /
20160
- * magic-link buttons; a future usernameless passkey).
21048
+ * - `primary` — shown on the first credentials screen (OIDC
21049
+ * buttons; a usernameless passkey).
20161
21050
  * - `second-factor` — shown AFTER the password leg, gated on the
20162
21051
  * returned `factors` (passkey-as-2FA today).
20163
21052
  *
@@ -20184,7 +21073,7 @@ var LoginMethodContributionSchema = discriminatedUnion("kind", [
20184
21073
  * The provider names an external identity a signed-in user can link to
20185
21074
  * their own account (D782): `auth.listLinkableProviders` /
20186
21075
  * `beginExternalLink` offer exactly the redirect methods that set this,
20187
- * whatever their id. Absent / false — a login button only (magic-link).
21076
+ * whatever their id. Absent / false — a login button only.
20188
21077
  */
20189
21078
  linkable: boolean().optional()
20190
21079
  }),
@@ -24945,8 +25834,7 @@ var notificationRulesCapability = {
24945
25834
  * `super_admin` — collapsed onto the single boolean because every
24946
25835
  * non-admin caller is governed by the same scope-check rules; the
24947
25836
  * distinction was only ever used to route role-specific procedures
24948
- * which we no longer have. Agents are admin sessions issued via
24949
- * `createServiceToken`; CLI / webhook integrations are `cst_*` tokens
25837
+ * which we no longer have. CLI / webhook integrations are `cst_*` tokens
24950
25838
  * with `isAdmin: false` + an explicit scope list.
24951
25839
  */
24952
25840
  /** Per-method access flavour. Materialised on every cap method via codegen. */
@@ -28218,6 +29106,26 @@ var pipelineAnalyticsCapability = {
28218
29106
  auth: "admin",
28219
29107
  timeoutMs: 60 * 6e4
28220
29108
  }),
29109
+ /**
29110
+ * OFFER the annotated archive instead of pushing it (D805): the same tar
29111
+ * `writeRetrainArchive` streams, behind a one-shot `ctx.peerBytes` ticket
29112
+ * the caller dials at once (same host). For a consumer that cannot expose
29113
+ * an upload URL — a training provider streaming straight into its cloud.
29114
+ * The answer is the plan; the bytes and their sha256 are the consumer's
29115
+ * to measure as they arrive.
29116
+ */
29117
+ offerRetrainArchive: method(object({
29118
+ filter: RetrainExportFilterSchema,
29119
+ layout: RetrainExportLayoutSchema
29120
+ }), object({
29121
+ ticket: PeerBytesTicketSchema,
29122
+ frames: number().int(),
29123
+ annotations: number().int()
29124
+ }), {
29125
+ kind: "mutation",
29126
+ auth: "admin",
29127
+ timeoutMs: 12e4
29128
+ }),
28221
29129
  /** The counts a selection would freeze — class × camera × day/night,
28222
29130
  * completeness — without freezing anything. Index reads only. */
28223
29131
  previewRetrainDataset: method(object({
@@ -32859,8 +33767,8 @@ version: string().optional() }), ServerUpdateActionResultSchema, {
32859
33767
  * `smtp-provider` — pluggable email delivery surface.
32860
33768
  *
32861
33769
  * Collection cap: a deployment may install multiple SMTP relays (e.g.
32862
- * one for transactional / one for notifications). Consumers (magic-link,
32863
- * notifier addons, …) walk the collection and pick the first
33770
+ * one for transactional / one for notifications). Consumers (notifier
33771
+ * addons, …) walk the collection and pick the first
32864
33772
  * ready provider OR target a specific addonId.
32865
33773
  *
32866
33774
  * The shape stays small on purpose — `sendEmail` is enough for the
@@ -33156,7 +34064,7 @@ targets: array(object({
33156
34064
  };
33157
34065
  /**
33158
34066
  * `sso-bridge` — internal hub-only cap that lets SSO-style auth
33159
- * providers (OIDC, SAML, magic-link, …) mint an HMAC-signed token
34067
+ * providers (OIDC, SAML, …) mint an HMAC-signed token
33160
34068
  * carrying the post-callback claims before redirecting back to
33161
34069
  * `/api/auth/sso/finish`.
33162
34070
  *
@@ -33219,7 +34127,14 @@ var SsoBridgeClaimsSchema = object({
33219
34127
  * Verified `iss` of the id_token behind an OIDC login bridge (D782). A
33220
34128
  * subject is unique only per issuer, so a link is bound to it.
33221
34129
  */
33222
- issuer: string().optional()
34130
+ issuer: string().optional(),
34131
+ /**
34132
+ * SHA-256 (hex) of the `camstack_sso_state` cookie the IdP `/start` set in
34133
+ * the browser that began this sign-in. `/api/auth/sso/finish` requires the
34134
+ * request to present the matching cookie — a login bridge is useless in
34135
+ * any other browser.
34136
+ */
34137
+ browserBinding: string().optional()
33223
34138
  });
33224
34139
  var ssoBridgeCapability = {
33225
34140
  name: "sso-bridge",
@@ -33237,7 +34152,7 @@ var ssoBridgeCapability = {
33237
34152
  * `/api/auth/sso/finish` to become admin — a full privilege escalation
33238
34153
  * through the exact surface this cap exists to close (see the module
33239
34154
  * docblock). Every real caller (`oauth-grants.ts`, `main.ts`
33240
- * registration, the OIDC/magic-link addons) reaches this through
34155
+ * registration, the OIDC addon) reaches this through
33241
34156
  * `ctx.api` / the in-process registry — never through tRPC — so
33242
34157
  * `auth: 'admin'` costs those callers nothing.
33243
34158
  */
@@ -47514,16 +48429,6 @@ var ApiKeySummarySchema = object({
47514
48429
  createdAt: number(),
47515
48430
  lastUsedAt: number().optional()
47516
48431
  });
47517
- var CreateApiKeyInputSchema = object({
47518
- label: string(),
47519
- isAdmin: boolean().default(false),
47520
- allowedProviders: union([array(string()), literal("*")]).optional(),
47521
- allowedDevices: record(string(), union([array(string()), literal("*")])).optional()
47522
- });
47523
- var CreateApiKeyResultSchema = object({
47524
- token: string(),
47525
- record: ApiKeySummarySchema
47526
- });
47527
48432
  var ScopedTokenSummarySchema = object({
47528
48433
  id: string(),
47529
48434
  userId: string(),
@@ -47635,20 +48540,11 @@ var userManagementCapability = {
47635
48540
  access: "view"
47636
48541
  }),
47637
48542
  listApiKeys: method(_void(), array(ApiKeySummarySchema), { auth: "admin" }),
47638
- createApiKey: method(CreateApiKeyInputSchema, CreateApiKeyResultSchema, {
47639
- kind: "mutation",
47640
- auth: "admin",
47641
- access: "create"
47642
- }),
47643
48543
  revokeApiKey: method(object({ id: string() }), object({ success: literal(true) }), {
47644
48544
  kind: "mutation",
47645
48545
  auth: "admin",
47646
48546
  access: "delete"
47647
48547
  }),
47648
- validateApiKey: method(object({ token: string() }), ApiKeySummarySchema.nullable(), {
47649
- kind: "mutation",
47650
- access: "view"
47651
- }),
47652
48548
  createScopedToken: method(CreateScopedTokenInputSchema, CreateScopedTokenResultSchema, {
47653
48549
  kind: "mutation",
47654
48550
  auth: "admin",
@@ -47738,20 +48634,6 @@ var userManagementCapability = {
47738
48634
  userId: string(),
47739
48635
  issuer: string()
47740
48636
  }).nullable(), { auth: "admin" }),
47741
- /**
47742
- * Link `(provider, subject)` to `userId`. Idempotent for the same user;
47743
- * REFUSES (throws) an identity already linked to another user, and a
47744
- * user that does not exist.
47745
- */
47746
- linkExternalIdentity: method(ExternalIdentityKeySchema.extend({
47747
- userId: string(),
47748
- issuer: string().min(1),
47749
- label: string().optional()
47750
- }), object({ success: literal(true) }), {
47751
- kind: "mutation",
47752
- auth: "admin",
47753
- access: "create"
47754
- }),
47755
48637
  /** Remove one link of `userId`. `success: false` when it was not linked to that user. */
47756
48638
  unlinkExternalIdentity: method(ExternalIdentityKeySchema.extend({ userId: string() }), object({ success: boolean() }), {
47757
48639
  kind: "mutation",
@@ -48463,6 +49345,531 @@ var zoneRulesCapability = {
48463
49345
  durability: "restored"
48464
49346
  };
48465
49347
  /**
49348
+ * `training-provider` — ONE cloud that can run the CamStack trainer.
49349
+ *
49350
+ * A thin, mockable translation layer: it knows how to run a container with a
49351
+ * GPU, move a dataset in, read the job's stdout and hand artefacts back. It
49352
+ * knows nothing about datasets, splits, floors, cost policy or Model Studio —
49353
+ * those are the `training` orchestrator's (D805). Every rule written there
49354
+ * once is what makes a second provider (RunPod, a local NVIDIA node) a new
49355
+ * manifest entry and nothing else.
49356
+ *
49357
+ * Collection, routed by the `addonId` in every single-row input (the `llm` /
49358
+ * `notification-output` posture); `describe` concat-fans across providers.
49359
+ * Every method is `admin`: these spend money.
49360
+ *
49361
+ * Every cloud object a provider creates is tagged with the orchestrator's
49362
+ * `jobKey`, so a retried submit finds the job it already started instead of
49363
+ * starting a second GPU, and `listJobs` can find orphans.
49364
+ *
49365
+ * Bytes never ride a cap field: the dataset arrives as a `ctx.peerBytes`
49366
+ * ticket the producer (pipeline-analytics) minted, and artefacts leave as a
49367
+ * ticket the provider mints (D613).
49368
+ */
49369
+ var TrainingGpuOptionSchema = object({
49370
+ id: string(),
49371
+ label: string(),
49372
+ /** List price, USD per GPU-hour, before any region multiplier. */
49373
+ usdPerHour: number().nonnegative(),
49374
+ vramGb: number().nonnegative()
49375
+ });
49376
+ var TrainingRegionOptionSchema = object({
49377
+ /** `''` = any region (the provider's choice). */
49378
+ id: string(),
49379
+ label: string(),
49380
+ priceMultiplier: number().positive()
49381
+ });
49382
+ /**
49383
+ * The provider's per-account settings, as the orchestrator reads them. They
49384
+ * live in the PROVIDER addon's settings (operator decision 2026-10-08: they
49385
+ * depend on the user's account), never hard-coded in the orchestrator.
49386
+ */
49387
+ var TrainingProviderDefaultsSchema = object({
49388
+ gpuType: string(),
49389
+ region: string(),
49390
+ costCapUsd: number().nonnegative(),
49391
+ maxRuntimeSec: number().int().positive(),
49392
+ /** Hours a FAILED job's cloud dataset is kept for debugging; 0 = delete at once. */
49393
+ failedDatasetGraceHours: number().nonnegative()
49394
+ });
49395
+ var TrainingProviderDescriptorSchema = object({
49396
+ addonId: string(),
49397
+ /** `modal`, `runpod`, `fake`, … */
49398
+ kind: string(),
49399
+ label: string(),
49400
+ gpuTypes: array(TrainingGpuOptionSchema).readonly(),
49401
+ regions: array(TrainingRegionOptionSchema).readonly(),
49402
+ maxDatasetBytes: number().int().positive(),
49403
+ maxRuntimeSec: number().int().positive(),
49404
+ freeTierNote: string().optional(),
49405
+ /** Where the data goes, in one sentence the confirm dialog repeats. */
49406
+ dataResidencyNote: string(),
49407
+ /** Credentials are present — never the values. */
49408
+ configured: boolean(),
49409
+ defaults: TrainingProviderDefaultsSchema
49410
+ });
49411
+ var TrainingCredentialCheckSchema = object({
49412
+ ok: boolean(),
49413
+ /** Workspace / account name, when the provider says. */
49414
+ account: string().optional(),
49415
+ reason: _enum([
49416
+ "missing",
49417
+ "invalid",
49418
+ "forbidden",
49419
+ "network",
49420
+ "quota"
49421
+ ]).optional(),
49422
+ detail: string().optional()
49423
+ });
49424
+ var ProviderJobStateSchema = _enum([
49425
+ "pending",
49426
+ "starting",
49427
+ "running",
49428
+ "succeeded",
49429
+ "failed",
49430
+ "cancelled",
49431
+ "lost"
49432
+ ]);
49433
+ var ProviderJobStatusSchema = object({
49434
+ jobKey: string(),
49435
+ providerJobId: string().optional(),
49436
+ state: ProviderJobStateSchema,
49437
+ startedAt: number().optional(),
49438
+ endedAt: number().optional(),
49439
+ exitCode: number().int().optional(),
49440
+ failureReason: string().optional(),
49441
+ gpuType: string(),
49442
+ region: string().optional(),
49443
+ billedSeconds: number().nonnegative(),
49444
+ costUsd: number().nonnegative(),
49445
+ /** True when `costUsd` is runtime × list price, not a billing answer. */
49446
+ costIsEstimate: boolean(),
49447
+ lastFetchedAt: number()
49448
+ });
49449
+ /**
49450
+ * The trainer the job runs, by SOURCE revision: the provider turns it into an
49451
+ * image its own way (Modal builds the published Dockerfile at that revision;
49452
+ * a registry-pull provider maps it to a tag). Recorded on the job and echoed
49453
+ * in `result.json`.
49454
+ */
49455
+ var TrainerSourceRefSchema = object({
49456
+ /** Hugging Face repo id, e.g. `camstack/camstack-trainer`. */
49457
+ repo: string().min(1),
49458
+ /** A commit sha (never a branch) — the job must be reproducible. */
49459
+ revision: string().regex(/^[0-9a-f]{7,64}$/)
49460
+ });
49461
+ var JobRef = {
49462
+ addonId: string(),
49463
+ jobKey: string().uuid()
49464
+ };
49465
+ var TrainingLogLineSchema = object({
49466
+ ts: number(),
49467
+ text: string()
49468
+ });
49469
+ var trainingProviderCapability = {
49470
+ name: "training-provider",
49471
+ scope: "system",
49472
+ mode: "collection",
49473
+ internal: true,
49474
+ methods: {
49475
+ /** Every provider's offer and settings. Concat-fans across providers. */
49476
+ describe: method(object({}), array(TrainingProviderDescriptorSchema).readonly(), { auth: "admin" }),
49477
+ /** Call the provider with the stored credentials. Never returns them. */
49478
+ validateCredentials: method(object({ addonId: string() }), TrainingCredentialCheckSchema, {
49479
+ kind: "mutation",
49480
+ auth: "admin",
49481
+ timeoutMs: 3e4
49482
+ }),
49483
+ /** USD range for a run of `gpuSeconds` on `gpuType` in `region`. */
49484
+ estimateJob: method(object({
49485
+ addonId: string(),
49486
+ gpuType: string(),
49487
+ region: string(),
49488
+ datasetBytes: number().int().nonnegative(),
49489
+ gpuSecondsLow: number().nonnegative(),
49490
+ gpuSecondsHigh: number().nonnegative()
49491
+ }), object({
49492
+ usdLow: number().nonnegative(),
49493
+ usdHigh: number().nonnegative(),
49494
+ notes: array(string()).readonly()
49495
+ }), { auth: "admin" }),
49496
+ /**
49497
+ * Take the dataset archive behind `ticket` (minted by pipeline-analytics,
49498
+ * same host) and land it as the job's dataset in the cloud, streamed —
49499
+ * nothing is staged on the hub's disk. Idempotent per `jobKey`: a second
49500
+ * call replaces a partial upload. Answers what actually landed.
49501
+ */
49502
+ uploadDataset: method(object({
49503
+ ...JobRef,
49504
+ ticket: PeerBytesTicketSchema
49505
+ }), object({
49506
+ bytes: number().int().nonnegative(),
49507
+ sha256: string()
49508
+ }), {
49509
+ kind: "mutation",
49510
+ auth: "admin",
49511
+ timeoutMs: 120 * 6e4
49512
+ }),
49513
+ /**
49514
+ * Start the trainer on a GPU. Looks the job up by `jobKey` first, so a
49515
+ * retried submit never starts a second GPU. `jobSpecJson` is written next
49516
+ * to the dataset as `job.json`; `maxRuntimeSec` is enforced by the
49517
+ * provider (a hard timeout), not by the hub.
49518
+ */
49519
+ submitJob: method(object({
49520
+ ...JobRef,
49521
+ trainer: TrainerSourceRefSchema,
49522
+ jobSpecJson: string().min(2).max(64e3),
49523
+ gpuType: string(),
49524
+ region: string(),
49525
+ maxRuntimeSec: number().int().positive()
49526
+ }), ProviderJobStatusSchema, {
49527
+ kind: "mutation",
49528
+ auth: "admin",
49529
+ timeoutMs: 30 * 6e4
49530
+ }),
49531
+ getJob: method(object(JobRef), ProviderJobStatusSchema, {
49532
+ auth: "admin",
49533
+ timeoutMs: 6e4
49534
+ }),
49535
+ /** Stdout/stderr since `cursor` (opaque), oldest first, at most `max` lines. */
49536
+ listJobEvents: method(object({
49537
+ ...JobRef,
49538
+ cursor: string().optional(),
49539
+ max: number().int().min(1).max(500)
49540
+ }), object({
49541
+ lines: array(TrainingLogLineSchema).readonly(),
49542
+ cursor: string()
49543
+ }), {
49544
+ auth: "admin",
49545
+ timeoutMs: 6e4
49546
+ }),
49547
+ /** Stop the job. Idempotent: an unknown or finished job is a no-op. */
49548
+ cancelJob: method(object(JobRef), object({ ok: literal(true) }), {
49549
+ kind: "mutation",
49550
+ auth: "admin",
49551
+ timeoutMs: 6e4
49552
+ }),
49553
+ /** The job's `result.json`, as text (small, JSON). `found: false` before it exists. */
49554
+ readResult: method(object(JobRef), object({
49555
+ found: boolean(),
49556
+ text: string().optional()
49557
+ }), {
49558
+ kind: "mutation",
49559
+ auth: "admin",
49560
+ timeoutMs: 5 * 6e4
49561
+ }),
49562
+ /**
49563
+ * Offer one output file of the job (`bundle.tar`) to the caller as a
49564
+ * one-shot `ctx.peerBytes` ticket, streamed from the cloud — the provider
49565
+ * stages nothing on disk. The caller dials it at once.
49566
+ */
49567
+ offerArtifact: method(object({
49568
+ ...JobRef,
49569
+ path: _enum(["bundle.tar"])
49570
+ }), object({ ticket: PeerBytesTicketSchema }), {
49571
+ kind: "mutation",
49572
+ auth: "admin",
49573
+ timeoutMs: 5 * 6e4
49574
+ }),
49575
+ /** Delete every cloud object tagged with `jobKey` (the dataset first). Idempotent. */
49576
+ cleanupJob: method(object(JobRef), object({ deleted: array(string()).readonly() }), {
49577
+ kind: "mutation",
49578
+ auth: "admin",
49579
+ timeoutMs: 5 * 6e4
49580
+ }),
49581
+ /** Every job the provider can still see — the orphan sweep diffs it against our records. */
49582
+ listJobs: method(object({ addonId: string() }), array(ProviderJobStatusSchema).readonly(), {
49583
+ auth: "admin",
49584
+ timeoutMs: 2 * 6e4
49585
+ })
49586
+ }
49587
+ };
49588
+ /**
49589
+ * `training` — the cloud-training orchestrator (D805). Hub-only singleton,
49590
+ * provided by `addon-training`.
49591
+ *
49592
+ * It owns what every provider must agree on, written once:
49593
+ *
49594
+ * - **Dataset versions.** Taken over from pipeline-analytics (D796): the rows
49595
+ * live here (D808); pipeline-analytics still CUTS a version (it owns the corpus and
49596
+ * the export plan) and reaches this store through the five row methods
49597
+ * below, so the Retrain page and the export did not change.
49598
+ * - **Jobs.** A persisted state machine, a reconcile loop against the
49599
+ * provider, a cost guard, a daily orphan sweep and the retention rules.
49600
+ * - **The return flow.** Verified artefacts → Model Studio
49601
+ * (`custom-model-registry.importModelBundle`) → canary on cameras →
49602
+ * rollback. Nothing is ever registered automatically.
49603
+ *
49604
+ * Every method is `admin`.
49605
+ */
49606
+ /** A version WITH its frame list — what the export and a job read. */
49607
+ var TrainingDatasetVersionRowSchema = RetrainDatasetVersionSchema.omit({ frameCount: true }).extend({ frameIds: array(string()).max(2e4).readonly() });
49608
+ /** A base model a detector job can fine-tune, and the baseline it is judged against. */
49609
+ var TrainingBaseModelSchema = object({
49610
+ modelId: string(),
49611
+ label: string(),
49612
+ weights: string(),
49613
+ imgsz: number().int(),
49614
+ baselineOnnxUrl: string(),
49615
+ baselineFloors: record(string(), number()),
49616
+ /** The base the fleet runs most — the UI's default. */
49617
+ recommended: boolean()
49618
+ });
49619
+ var TrainingPresetSchema = _enum([
49620
+ "quick",
49621
+ "standard",
49622
+ "thorough"
49623
+ ]);
49624
+ var TrainingJobRequestSchema = object({
49625
+ datasetVersionId: string().min(1),
49626
+ /** The `training-provider` addon that runs it. */
49627
+ addonId: string().min(1),
49628
+ gpuType: string().min(1),
49629
+ region: string(),
49630
+ baseModelId: string().min(1),
49631
+ preset: TrainingPresetSchema,
49632
+ /** Freeze the backbone's first N layers; `null` = the preset's choice. */
49633
+ freeze: number().int().nonnegative().nullable(),
49634
+ /** Cameras held out whole for evaluation; `null` = the orchestrator's default. */
49635
+ holdoutCameras: array(number().int()).nullable()
49636
+ });
49637
+ var TrainingSplitPlanSchema = object({
49638
+ holdoutCameras: array(number().int()).readonly(),
49639
+ /** Used when no camera is held out: the last N days of every camera. */
49640
+ holdoutLastDays: number().int().nonnegative(),
49641
+ /** Holdout subjects per class (camera holdout only; `null` = known only after the split). */
49642
+ holdoutSupport: record(string(), number().int()).nullable(),
49643
+ trainSubjects: number().int()
49644
+ });
49645
+ var TrainingRefusalReasonSchema = _enum([
49646
+ "unknown-dataset",
49647
+ "unknown-provider",
49648
+ "provider-not-configured",
49649
+ "unknown-base-model",
49650
+ "unknown-gpu",
49651
+ "dataset-too-large",
49652
+ "no-training-subjects",
49653
+ "job-already-running"
49654
+ ]);
49655
+ var TrainingJobPlanSchema = object({
49656
+ refusal: object({
49657
+ reason: TrainingRefusalReasonSchema,
49658
+ detail: string()
49659
+ }).nullable(),
49660
+ warnings: array(string()).readonly(),
49661
+ split: TrainingSplitPlanSchema.nullable(),
49662
+ estimate: object({
49663
+ datasetBytes: number().int(),
49664
+ uploadMinutesAt20Mbps: number(),
49665
+ gpuSecondsLow: number(),
49666
+ gpuSecondsHigh: number(),
49667
+ usdLow: number(),
49668
+ usdHigh: number(),
49669
+ notes: array(string()).readonly()
49670
+ }).nullable(),
49671
+ /** Pre-filled from the provider's settings; the operator may lower or raise them. */
49672
+ defaults: object({
49673
+ maxCostUsd: number(),
49674
+ maxRuntimeSec: number().int()
49675
+ }).nullable(),
49676
+ /** The sentence the confirm dialog repeats: where the frames go and when they are deleted. */
49677
+ dataNotice: string()
49678
+ });
49679
+ /**
49680
+ * Orchestrator-owned states, persisted. `uploading` covers exporting the
49681
+ * archive (it is streamed, never staged). Terminal: `failed`, `cancelled`,
49682
+ * `lost`, `expired`, `discarded`. `registered` and `canary` are where a
49683
+ * result lives after the operator acted on it.
49684
+ */
49685
+ var TrainingJobStateSchema = _enum([
49686
+ "uploading",
49687
+ "submitted",
49688
+ "starting",
49689
+ "running",
49690
+ "collecting",
49691
+ "ready",
49692
+ "registered",
49693
+ "canary",
49694
+ "failed",
49695
+ "cancelling",
49696
+ "cancelled",
49697
+ "lost",
49698
+ "expired",
49699
+ "discarded"
49700
+ ]);
49701
+ var TrainingFailureReasonSchema = _enum([
49702
+ "cost-cap",
49703
+ "runtime-cap",
49704
+ "upload-failed",
49705
+ "submit-failed",
49706
+ "trainer-failed",
49707
+ "result-invalid",
49708
+ "checksum-mismatch",
49709
+ "fetch-failed",
49710
+ "provider-error",
49711
+ "hub-restart-during-upload"
49712
+ ]);
49713
+ var TrainingProgressPointSchema = object({
49714
+ epoch: number().int(),
49715
+ map50: number().nullable(),
49716
+ map50_95: number().nullable()
49717
+ });
49718
+ var TrainingCanarySchema = object({
49719
+ deviceIds: array(number().int()).readonly(),
49720
+ since: number(),
49721
+ /** Every override the canary replaced, exactly, so rollback restores it. */
49722
+ previous: array(object({
49723
+ deviceId: number().int(),
49724
+ nodeId: string(),
49725
+ deviceKey: string(),
49726
+ patch: object({
49727
+ modelId: string().optional(),
49728
+ settings: record(string(), unknown()).readonly().optional()
49729
+ }).nullable()
49730
+ })).readonly()
49731
+ });
49732
+ var TrainingJobSchema = object({
49733
+ id: string(),
49734
+ idempotencyKey: string(),
49735
+ name: string(),
49736
+ createdAt: number(),
49737
+ updatedAt: number(),
49738
+ state: TrainingJobStateSchema,
49739
+ stage: TrainingStageSchema.nullable(),
49740
+ failure: object({
49741
+ reason: TrainingFailureReasonSchema,
49742
+ stage: string().nullable(),
49743
+ detail: string()
49744
+ }).nullable(),
49745
+ request: TrainingJobRequestSchema,
49746
+ maxCostUsd: number().nonnegative(),
49747
+ maxRuntimeSec: number().int().positive(),
49748
+ trainer: TrainerSourceRefSchema,
49749
+ datasetLayout: RetrainExportLayoutSchema,
49750
+ dataset: object({
49751
+ bytes: number().int(),
49752
+ sha256: string(),
49753
+ uploadedAt: number()
49754
+ }).nullable(),
49755
+ split: TrainingSplitPlanSchema,
49756
+ provider: object({
49757
+ state: ProviderJobStateSchema.nullable(),
49758
+ providerJobId: string().nullable(),
49759
+ startedAt: number().nullable(),
49760
+ endedAt: number().nullable(),
49761
+ billedSeconds: number(),
49762
+ costUsd: number(),
49763
+ costIsEstimate: boolean(),
49764
+ lastPolledAt: number().nullable()
49765
+ }),
49766
+ progress: object({
49767
+ epoch: number().int().nullable(),
49768
+ epochs: number().int().nullable(),
49769
+ etaSec: number().nullable(),
49770
+ series: array(TrainingProgressPointSchema).readonly()
49771
+ }),
49772
+ /** The last lines of the job's output (≤ 200), newest last. Never frame paths. */
49773
+ logTail: array(string()).readonly(),
49774
+ logCursor: string().nullable(),
49775
+ artifacts: object({
49776
+ bundleBytes: number().int(),
49777
+ bundleSha256: string(),
49778
+ fetchedAt: number(),
49779
+ /** When the staged artefacts are deleted from the hub. */
49780
+ expiresAt: number()
49781
+ }).nullable(),
49782
+ /** When the provider-side copy of the frames was deleted; null while it exists. */
49783
+ cloudDatasetDeletedAt: number().nullable(),
49784
+ /** A failed job's dataset is kept until then (the provider's grace), then deleted. */
49785
+ cloudCleanupDueAt: number().nullable(),
49786
+ /** Model ids registered from this job (base, and int8 when kept). */
49787
+ registeredModelIds: array(string()).readonly(),
49788
+ canary: TrainingCanarySchema.nullable()
49789
+ });
49790
+ var IdInput = object({ id: string().min(1) });
49791
+ var trainingCapability = {
49792
+ name: "training",
49793
+ scope: "system",
49794
+ mode: "singleton",
49795
+ mount: { kind: "hub-only" },
49796
+ methods: {
49797
+ /** Store a version once. `stored: false` = that id already exists (immutable). */
49798
+ putDatasetVersion: method(TrainingDatasetVersionRowSchema, object({ stored: boolean() }), {
49799
+ kind: "mutation",
49800
+ auth: "admin"
49801
+ }),
49802
+ getDatasetVersion: method(IdInput, TrainingDatasetVersionRowSchema.nullable(), { auth: "admin" }),
49803
+ /** Every version without its frame list, newest first. */
49804
+ listDatasetVersions: method(object({}), array(RetrainDatasetVersionSchema).readonly(), { auth: "admin" }),
49805
+ findDatasetVersionIdByName: method(object({ name: string() }), object({ id: string().nullable() }), { auth: "admin" }),
49806
+ removeDatasetVersion: method(IdInput, object({ removed: boolean() }), {
49807
+ kind: "mutation",
49808
+ auth: "admin"
49809
+ }),
49810
+ listBaseModels: method(object({}), array(TrainingBaseModelSchema).readonly(), { auth: "admin" }),
49811
+ /** Split, estimate, defaults and any named refusal — nothing is started. */
49812
+ planJob: method(TrainingJobRequestSchema, TrainingJobPlanSchema, {
49813
+ auth: "admin",
49814
+ timeoutMs: 6e4
49815
+ }),
49816
+ /**
49817
+ * Start a job. The same `idempotencyKey` returns the job it already
49818
+ * started. Answers at once (`uploading`); the upload and the submit run in
49819
+ * the background and the job record says how far they got.
49820
+ */
49821
+ startJob: method(TrainingJobRequestSchema.extend({
49822
+ name: string().min(1).max(120),
49823
+ maxCostUsd: number().positive(),
49824
+ maxRuntimeSec: number().int().positive(),
49825
+ idempotencyKey: string().min(8).max(80)
49826
+ }), discriminatedUnion("kind", [object({
49827
+ kind: literal("started"),
49828
+ job: TrainingJobSchema
49829
+ }), object({
49830
+ kind: literal("refused"),
49831
+ reason: TrainingRefusalReasonSchema,
49832
+ detail: string()
49833
+ })]), {
49834
+ kind: "mutation",
49835
+ auth: "admin",
49836
+ timeoutMs: 12e4
49837
+ }),
49838
+ listJobs: method(object({}), array(TrainingJobSchema).readonly(), { auth: "admin" }),
49839
+ getJob: method(IdInput, TrainingJobSchema.nullable(), { auth: "admin" }),
49840
+ cancelJob: method(IdInput, TrainingJobSchema, {
49841
+ kind: "mutation",
49842
+ auth: "admin",
49843
+ timeoutMs: 12e4
49844
+ }),
49845
+ /** The verified `result.json` of a job in `ready` or later; null before. */
49846
+ getJobResult: method(IdInput, TrainingResultSchema.nullable(), { auth: "admin" }),
49847
+ /** Hand the verified bundle to Model Studio; optionally canary right after. */
49848
+ registerResult: method(IdInput.extend({ canaryDeviceIds: array(number().int()).readonly() }), TrainingJobSchema, {
49849
+ kind: "mutation",
49850
+ auth: "admin",
49851
+ timeoutMs: 30 * 6e4
49852
+ }),
49853
+ /** Pin the registered model on these cameras, remembering what it replaced. */
49854
+ canaryResult: method(IdInput.extend({ deviceIds: array(number().int()).min(1).readonly() }), TrainingJobSchema, {
49855
+ kind: "mutation",
49856
+ auth: "admin",
49857
+ timeoutMs: 12e4
49858
+ }),
49859
+ /** Put every canary camera back exactly as it was. */
49860
+ rollbackCanary: method(IdInput, TrainingJobSchema, {
49861
+ kind: "mutation",
49862
+ auth: "admin",
49863
+ timeoutMs: 12e4
49864
+ }),
49865
+ /** Delete the staged artefacts of an unregistered result. */
49866
+ discardResult: method(IdInput, TrainingJobSchema, {
49867
+ kind: "mutation",
49868
+ auth: "admin"
49869
+ })
49870
+ }
49871
+ };
49872
+ /**
48466
49873
  * Frozen unit → spec table. `•` in the doc marks each dimension's canonical
48467
49874
  * unit (`factor: 1, offset: 0`). °F derives from `°C = (°F − 32) × 5/9` ⇒
48468
49875
  * `factor = 5/9`, `offset = -160/9` (kept as exact expressions, not rounded
@@ -49401,6 +50808,12 @@ Object.freeze({
49401
50808
  addonId: null,
49402
50809
  access: "create"
49403
50810
  },
50811
+ "backup.checkBackupKey": {
50812
+ capName: "backup",
50813
+ capScope: "system",
50814
+ addonId: null,
50815
+ access: "create"
50816
+ },
49404
50817
  "backup.delete": {
49405
50818
  capName: "backup",
49406
50819
  capScope: "system",
@@ -49413,6 +50826,18 @@ Object.freeze({
49413
50826
  addonId: null,
49414
50827
  access: "delete"
49415
50828
  },
50829
+ "backup.disableEncryption": {
50830
+ capName: "backup",
50831
+ capScope: "system",
50832
+ addonId: null,
50833
+ access: "create"
50834
+ },
50835
+ "backup.getEncryption": {
50836
+ capName: "backup",
50837
+ capScope: "system",
50838
+ addonId: null,
50839
+ access: "view"
50840
+ },
49416
50841
  "backup.getEntries": {
49417
50842
  capName: "backup",
49418
50843
  capScope: "system",
@@ -49467,6 +50892,12 @@ Object.freeze({
49467
50892
  addonId: null,
49468
50893
  access: "create"
49469
50894
  },
50895
+ "backup.setupEncryption": {
50896
+ capName: "backup",
50897
+ capScope: "system",
50898
+ addonId: null,
50899
+ access: "create"
50900
+ },
49470
50901
  "backup.trigger": {
49471
50902
  capName: "backup",
49472
50903
  capScope: "system",
@@ -50019,6 +51450,12 @@ Object.freeze({
50019
51450
  addonId: null,
50020
51451
  access: "create"
50021
51452
  },
51453
+ "customModelRegistry.importModelBundle": {
51454
+ capName: "custom-model-registry",
51455
+ capScope: "system",
51456
+ addonId: null,
51457
+ access: "create"
51458
+ },
50022
51459
  "customModelRegistry.listModels": {
50023
51460
  capName: "custom-model-registry",
50024
51461
  capScope: "system",
@@ -51459,6 +52896,12 @@ Object.freeze({
51459
52896
  addonId: null,
51460
52897
  access: "view"
51461
52898
  },
52899
+ "keychainAdmin.acknowledgeReset": {
52900
+ capName: "keychain-admin",
52901
+ capScope: "system",
52902
+ addonId: null,
52903
+ access: "create"
52904
+ },
51462
52905
  "keychainAdmin.deleteOrphans": {
51463
52906
  capName: "keychain-admin",
51464
52907
  capScope: "system",
@@ -51495,6 +52938,12 @@ Object.freeze({
51495
52938
  addonId: null,
51496
52939
  access: "delete"
51497
52940
  },
52941
+ "keychainAdmin.resetReport": {
52942
+ capName: "keychain-admin",
52943
+ capScope: "system",
52944
+ addonId: null,
52945
+ access: "delete"
52946
+ },
51498
52947
  "keychainAdmin.reveal": {
51499
52948
  capName: "keychain-admin",
51500
52949
  capScope: "system",
@@ -53241,6 +54690,12 @@ Object.freeze({
53241
54690
  addonId: null,
53242
54691
  access: "view"
53243
54692
  },
54693
+ "pipelineAnalytics.offerRetrainArchive": {
54694
+ capName: "pipeline-analytics",
54695
+ capScope: "device",
54696
+ addonId: null,
54697
+ access: "create"
54698
+ },
53244
54699
  "pipelineAnalytics.ownersWithMedia": {
53245
54700
  capName: "pipeline-analytics",
53246
54701
  capScope: "device",
@@ -55779,6 +57234,174 @@ Object.freeze({
55779
57234
  addonId: null,
55780
57235
  access: "view"
55781
57236
  },
57237
+ "training.canaryResult": {
57238
+ capName: "training",
57239
+ capScope: "system",
57240
+ addonId: null,
57241
+ access: "create"
57242
+ },
57243
+ "training.cancelJob": {
57244
+ capName: "training",
57245
+ capScope: "system",
57246
+ addonId: null,
57247
+ access: "create"
57248
+ },
57249
+ "training.discardResult": {
57250
+ capName: "training",
57251
+ capScope: "system",
57252
+ addonId: null,
57253
+ access: "create"
57254
+ },
57255
+ "training.findDatasetVersionIdByName": {
57256
+ capName: "training",
57257
+ capScope: "system",
57258
+ addonId: null,
57259
+ access: "view"
57260
+ },
57261
+ "training.getDatasetVersion": {
57262
+ capName: "training",
57263
+ capScope: "system",
57264
+ addonId: null,
57265
+ access: "view"
57266
+ },
57267
+ "training.getJob": {
57268
+ capName: "training",
57269
+ capScope: "system",
57270
+ addonId: null,
57271
+ access: "view"
57272
+ },
57273
+ "training.getJobResult": {
57274
+ capName: "training",
57275
+ capScope: "system",
57276
+ addonId: null,
57277
+ access: "view"
57278
+ },
57279
+ "training.listBaseModels": {
57280
+ capName: "training",
57281
+ capScope: "system",
57282
+ addonId: null,
57283
+ access: "view"
57284
+ },
57285
+ "training.listDatasetVersions": {
57286
+ capName: "training",
57287
+ capScope: "system",
57288
+ addonId: null,
57289
+ access: "view"
57290
+ },
57291
+ "training.listJobs": {
57292
+ capName: "training",
57293
+ capScope: "system",
57294
+ addonId: null,
57295
+ access: "view"
57296
+ },
57297
+ "training.planJob": {
57298
+ capName: "training",
57299
+ capScope: "system",
57300
+ addonId: null,
57301
+ access: "view"
57302
+ },
57303
+ "training.putDatasetVersion": {
57304
+ capName: "training",
57305
+ capScope: "system",
57306
+ addonId: null,
57307
+ access: "create"
57308
+ },
57309
+ "training.registerResult": {
57310
+ capName: "training",
57311
+ capScope: "system",
57312
+ addonId: null,
57313
+ access: "create"
57314
+ },
57315
+ "training.removeDatasetVersion": {
57316
+ capName: "training",
57317
+ capScope: "system",
57318
+ addonId: null,
57319
+ access: "delete"
57320
+ },
57321
+ "training.rollbackCanary": {
57322
+ capName: "training",
57323
+ capScope: "system",
57324
+ addonId: null,
57325
+ access: "create"
57326
+ },
57327
+ "training.startJob": {
57328
+ capName: "training",
57329
+ capScope: "system",
57330
+ addonId: null,
57331
+ access: "create"
57332
+ },
57333
+ "trainingProvider.cancelJob": {
57334
+ capName: "training-provider",
57335
+ capScope: "system",
57336
+ addonId: null,
57337
+ access: "create"
57338
+ },
57339
+ "trainingProvider.cleanupJob": {
57340
+ capName: "training-provider",
57341
+ capScope: "system",
57342
+ addonId: null,
57343
+ access: "create"
57344
+ },
57345
+ "trainingProvider.describe": {
57346
+ capName: "training-provider",
57347
+ capScope: "system",
57348
+ addonId: null,
57349
+ access: "view"
57350
+ },
57351
+ "trainingProvider.estimateJob": {
57352
+ capName: "training-provider",
57353
+ capScope: "system",
57354
+ addonId: null,
57355
+ access: "view"
57356
+ },
57357
+ "trainingProvider.getJob": {
57358
+ capName: "training-provider",
57359
+ capScope: "system",
57360
+ addonId: null,
57361
+ access: "view"
57362
+ },
57363
+ "trainingProvider.listJobEvents": {
57364
+ capName: "training-provider",
57365
+ capScope: "system",
57366
+ addonId: null,
57367
+ access: "view"
57368
+ },
57369
+ "trainingProvider.listJobs": {
57370
+ capName: "training-provider",
57371
+ capScope: "system",
57372
+ addonId: null,
57373
+ access: "view"
57374
+ },
57375
+ "trainingProvider.offerArtifact": {
57376
+ capName: "training-provider",
57377
+ capScope: "system",
57378
+ addonId: null,
57379
+ access: "create"
57380
+ },
57381
+ "trainingProvider.readResult": {
57382
+ capName: "training-provider",
57383
+ capScope: "system",
57384
+ addonId: null,
57385
+ access: "create"
57386
+ },
57387
+ "trainingProvider.submitJob": {
57388
+ capName: "training-provider",
57389
+ capScope: "system",
57390
+ addonId: null,
57391
+ access: "create"
57392
+ },
57393
+ "trainingProvider.uploadDataset": {
57394
+ capName: "training-provider",
57395
+ capScope: "system",
57396
+ addonId: null,
57397
+ access: "create"
57398
+ },
57399
+ "trainingProvider.validateCredentials": {
57400
+ capName: "training-provider",
57401
+ capScope: "system",
57402
+ addonId: null,
57403
+ access: "create"
57404
+ },
55782
57405
  "turnProvider.getTurnServers": {
55783
57406
  capName: "turn-provider",
55784
57407
  capScope: "system",
@@ -55803,12 +57426,6 @@ Object.freeze({
55803
57426
  addonId: null,
55804
57427
  access: "create"
55805
57428
  },
55806
- "userManagement.createApiKey": {
55807
- capName: "user-management",
55808
- capScope: "system",
55809
- addonId: null,
55810
- access: "create"
55811
- },
55812
57429
  "userManagement.createScopedToken": {
55813
57430
  capName: "user-management",
55814
57431
  capScope: "system",
@@ -55845,12 +57462,6 @@ Object.freeze({
55845
57462
  addonId: null,
55846
57463
  access: "view"
55847
57464
  },
55848
- "userManagement.linkExternalIdentity": {
55849
- capName: "user-management",
55850
- capScope: "system",
55851
- addonId: null,
55852
- access: "create"
55853
- },
55854
57465
  "userManagement.listApiKeys": {
55855
57466
  capName: "user-management",
55856
57467
  capScope: "system",
@@ -55953,12 +57564,6 @@ Object.freeze({
55953
57564
  addonId: null,
55954
57565
  access: "create"
55955
57566
  },
55956
- "userManagement.validateApiKey": {
55957
- capName: "user-management",
55958
- capScope: "system",
55959
- addonId: null,
55960
- access: "view"
55961
- },
55962
57567
  "userManagement.validateCredentials": {
55963
57568
  capName: "user-management",
55964
57569
  capScope: "system",
@@ -57872,6 +59477,8 @@ var ALL_CAPABILITY_DEFINITIONS = [
57872
59477
  temperatureSensorCapability,
57873
59478
  terminalSessionCapability,
57874
59479
  toastCapability,
59480
+ trainingCapability,
59481
+ trainingProviderCapability,
57875
59482
  turnProviderCapability,
57876
59483
  updateCapability,
57877
59484
  userManagementCapability,
@@ -60250,6 +61857,11 @@ Object.freeze({
60250
61857
  form: "single",
60251
61858
  optional: false
60252
61859
  }],
61860
+ "training.canaryResult": [{
61861
+ name: "deviceIds",
61862
+ form: "array",
61863
+ optional: false
61864
+ }],
60253
61865
  "update.getStatus": [{
60254
61866
  name: "deviceId",
60255
61867
  form: "single",