@camstack/addon-provider-hikvision 1.2.147 → 1.2.148

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/dist/addon.js +1771 -131
  2. package/dist/addon.mjs +1771 -131
  3. package/package.json +1 -1
package/dist/addon.mjs CHANGED
@@ -5390,7 +5390,7 @@ var ZodIssueCode = {
5390
5390
  var ZodFirstPartyTypeKind;
5391
5391
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
5392
5392
  //#endregion
5393
- //#region ../types/dist/sleep-Cr5YOk3m.mjs
5393
+ //#region ../types/dist/sleep-r3RWkGVx.mjs
5394
5394
  /**
5395
5395
  * The audio chunk plane's byte format, and the ONE expansion from a coded
5396
5396
  * window to float samples (D455).
@@ -5507,7 +5507,7 @@ function isKeychainStoredField(field) {
5507
5507
  var SECRET_CLEAR = { $secretClear: true };
5508
5508
  /** The `'***'` token D634 redaction writes for non-admins. */
5509
5509
  var LEGACY_DEVICE_REDACTION = "***";
5510
- function isRecord$1(value) {
5510
+ function isRecord$2(value) {
5511
5511
  return typeof value === "object" && value !== null && !Array.isArray(value);
5512
5512
  }
5513
5513
  function makeSecretMarker(ref) {
@@ -5518,12 +5518,12 @@ function makeSecretMarker(ref) {
5518
5518
  }
5519
5519
  /** A stored marker: an object whose `$secret` is a non-empty string. */
5520
5520
  function isSecretMarker(value) {
5521
- if (!isRecord$1(value)) return false;
5521
+ if (!isRecord$2(value)) return false;
5522
5522
  const ref = value["$secret"];
5523
5523
  return typeof ref === "string" && ref.length > 0;
5524
5524
  }
5525
5525
  function isSecretClear(value) {
5526
- return isRecord$1(value) && value["$secretClear"] === true;
5526
+ return isRecord$2(value) && value["$secretClear"] === true;
5527
5527
  }
5528
5528
  /**
5529
5529
  * The UI view of a stored secret field value: a marker becomes "set", inline
@@ -6039,6 +6039,13 @@ function globalSecretScope() {
6039
6039
  function encodeSegment(value) {
6040
6040
  return encodeURIComponent(value);
6041
6041
  }
6042
+ function decodeSegment(value) {
6043
+ try {
6044
+ return decodeURIComponent(value);
6045
+ } catch {
6046
+ return null;
6047
+ }
6048
+ }
6042
6049
  /**
6043
6050
  * The field path of a value inside an array item, addressed by the item's id:
6044
6051
  * `arrayItemFieldPath('providers', 'authentik', 'clientSecret')` →
@@ -6047,6 +6054,75 @@ function encodeSegment(value) {
6047
6054
  function arrayItemFieldPath(arrayKey, itemId, fieldKey) {
6048
6055
  return `${arrayKey}[${encodeSegment(itemId)}].${fieldKey}`;
6049
6056
  }
6057
+ function parseScope(segments) {
6058
+ switch (segments[0]) {
6059
+ case "global": return {
6060
+ scope: GLOBAL_SCOPE,
6061
+ used: 1
6062
+ };
6063
+ case "node": {
6064
+ const nodeId = segments[1] !== void 0 ? decodeSegment(segments[1]) : null;
6065
+ return nodeId === null || nodeId.length === 0 ? null : {
6066
+ scope: {
6067
+ kind: "node",
6068
+ nodeId
6069
+ },
6070
+ used: 2
6071
+ };
6072
+ }
6073
+ case "device": {
6074
+ const raw = segments[1];
6075
+ if (raw === void 0 || !/^\d+$/.test(raw)) return null;
6076
+ return {
6077
+ scope: {
6078
+ kind: "device",
6079
+ deviceId: Number(raw)
6080
+ },
6081
+ used: 2
6082
+ };
6083
+ }
6084
+ case "integration": {
6085
+ const id = segments[1] !== void 0 ? decodeSegment(segments[1]) : null;
6086
+ return id === null || id.length === 0 ? null : {
6087
+ scope: {
6088
+ kind: "integration",
6089
+ integrationId: id
6090
+ },
6091
+ used: 2
6092
+ };
6093
+ }
6094
+ case "row": {
6095
+ const collection = segments[1] !== void 0 ? decodeSegment(segments[1]) : null;
6096
+ const rowId = segments[2] !== void 0 ? decodeSegment(segments[2]) : null;
6097
+ if (collection === null || rowId === null || collection.length === 0 || rowId.length === 0) return null;
6098
+ return {
6099
+ scope: {
6100
+ kind: "row",
6101
+ collection,
6102
+ rowId
6103
+ },
6104
+ used: 3
6105
+ };
6106
+ }
6107
+ default: return null;
6108
+ }
6109
+ }
6110
+ /** Take a ref apart; `null` when it is not a well-formed ref. */
6111
+ function parseSecretRef(ref) {
6112
+ if (!ref.startsWith("secret://")) return null;
6113
+ const segments = ref.slice(9).split("/");
6114
+ const owner = segments[0] !== void 0 ? decodeSegment(segments[0]) : null;
6115
+ if (owner === null || owner.length === 0) return null;
6116
+ const parsed = parseScope(segments.slice(1));
6117
+ if (parsed === null) return null;
6118
+ const fieldPath = segments.slice(1 + parsed.used).join("/");
6119
+ if (fieldPath.length === 0) return null;
6120
+ return {
6121
+ owner,
6122
+ scope: parsed.scope,
6123
+ fieldPath
6124
+ };
6125
+ }
6050
6126
  /** A write to a secret path could not be stored in the keychain, so it was refused. */
6051
6127
  var KeychainWriteRefusedError = class extends Error {
6052
6128
  fieldPath;
@@ -6057,7 +6133,7 @@ var KeychainWriteRefusedError = class extends Error {
6057
6133
  }
6058
6134
  };
6059
6135
  var KEEP = { kind: "keep" };
6060
- function isRecord(value) {
6136
+ function isRecord$1(value) {
6061
6137
  return typeof value === "object" && value !== null && !Array.isArray(value);
6062
6138
  }
6063
6139
  function defaultMintId() {
@@ -6070,7 +6146,7 @@ function collectSecretMarkerRefs(value, out = []) {
6070
6146
  return out;
6071
6147
  }
6072
6148
  if (Array.isArray(value)) for (const item of value) collectSecretMarkerRefs(item, out);
6073
- else if (isRecord(value)) for (const child of Object.values(value)) collectSecretMarkerRefs(child, out);
6149
+ else if (isRecord$1(value)) for (const child of Object.values(value)) collectSecretMarkerRefs(child, out);
6074
6150
  return out;
6075
6151
  }
6076
6152
  async function storedValueEquals(secrets, marker, candidate) {
@@ -6125,7 +6201,7 @@ function rowId(row, idKey) {
6125
6201
  return null;
6126
6202
  }
6127
6203
  async function writeArray(ctx, node, incoming, stored, fieldPath) {
6128
- const storedRows = Array.isArray(stored) ? stored.filter(isRecord) : [];
6204
+ const storedRows = Array.isArray(stored) ? stored.filter(isRecord$1) : [];
6129
6205
  if (!Array.isArray(incoming)) {
6130
6206
  ctx.deletes.push(...collectSecretMarkerRefs(storedRows));
6131
6207
  return {
@@ -6141,7 +6217,7 @@ async function writeArray(ctx, node, incoming, stored, fieldPath) {
6141
6217
  const kept = /* @__PURE__ */ new Set();
6142
6218
  const rows = [];
6143
6219
  for (const row of incoming) {
6144
- if (!isRecord(row)) {
6220
+ if (!isRecord$1(row)) {
6145
6221
  rows.push(row);
6146
6222
  continue;
6147
6223
  }
@@ -6166,7 +6242,7 @@ async function writeNode(ctx, node, incoming, stored, fieldPath) {
6166
6242
  case "leaf": return writeLeaf(ctx, incoming, stored, fieldPath);
6167
6243
  case "array": return writeArray(ctx, node, incoming, stored, fieldPath);
6168
6244
  case "object": {
6169
- if (!isRecord(incoming)) {
6245
+ if (!isRecord$1(incoming)) {
6170
6246
  if (incoming === void 0) return KEEP;
6171
6247
  ctx.deletes.push(...collectSecretMarkerRefs(stored));
6172
6248
  return {
@@ -6174,7 +6250,7 @@ async function writeNode(ctx, node, incoming, stored, fieldPath) {
6174
6250
  value: incoming
6175
6251
  };
6176
6252
  }
6177
- const storedObj = isRecord(stored) ? stored : {};
6253
+ const storedObj = isRecord$1(stored) ? stored : {};
6178
6254
  return {
6179
6255
  kind: "value",
6180
6256
  value: await writeMembers(ctx, node.children, incoming, storedObj, (m) => `${fieldPath}.${m}`)
@@ -6233,12 +6309,19 @@ async function transformSecretWrite(input) {
6233
6309
  }
6234
6310
  };
6235
6311
  }
6312
+ /** Is `ref` one of `owner`'s refs? */
6313
+ function isSecretRefOwnedBy(ref, owner) {
6314
+ return parseSecretRef(ref)?.owner === owner;
6315
+ }
6236
6316
  /**
6237
6317
  * Replace every marker in `value` with its keychain value. Returns the SAME
6238
6318
  * reference when there is no marker (no allocation, no keychain call).
6239
6319
  */
6240
- async function resolveSecretMarkers(value, secrets) {
6241
- const refs = collectSecretMarkerRefs(value);
6320
+ async function resolveSecretMarkers(value, secrets, options = {}) {
6321
+ const keepMarker = options.unresolved === "keep-marker";
6322
+ const owner = options.ownedBy;
6323
+ const inScope = (ref) => owner === void 0 || isSecretRefOwnedBy(ref, owner);
6324
+ const refs = collectSecretMarkerRefs(value).filter(inScope);
6242
6325
  if (refs.length === 0) return {
6243
6326
  value,
6244
6327
  unresolved: []
@@ -6262,10 +6345,18 @@ async function resolveSecretMarkers(value, secrets) {
6262
6345
  }
6263
6346
  const substitute = (v) => {
6264
6347
  if (isSecretMarker(v)) {
6348
+ if (!inScope(v.$secret)) return {
6349
+ keep: true,
6350
+ value: v
6351
+ };
6265
6352
  const answer = answers[v.$secret];
6266
- return answer?.kind === "value" ? {
6353
+ if (answer?.kind === "value") return {
6267
6354
  keep: true,
6268
6355
  value: answer.value
6356
+ };
6357
+ return keepMarker ? {
6358
+ keep: true,
6359
+ value: v
6269
6360
  } : {
6270
6361
  keep: false,
6271
6362
  value: void 0
@@ -6282,7 +6373,7 @@ async function resolveSecretMarkers(value, secrets) {
6282
6373
  value: items
6283
6374
  };
6284
6375
  }
6285
- if (isRecord(v)) {
6376
+ if (isRecord$1(v)) {
6286
6377
  const out = {};
6287
6378
  for (const [k, child] of Object.entries(v)) {
6288
6379
  const s = substitute(child);
@@ -6303,14 +6394,152 @@ async function resolveSecretMarkers(value, secrets) {
6303
6394
  unresolved
6304
6395
  };
6305
6396
  }
6306
- function touchesTree(tree, patch) {
6307
- if (tree.size === 0) return false;
6308
- for (const key of Object.keys(patch)) {
6309
- const at = key.indexOf("@");
6310
- if (tree.has(at > 0 ? key.slice(0, at) : key)) return true;
6397
+ /** An addon tried to replace a stored secret it could not read. Nothing was written. */
6398
+ var SecretOverwriteRefusedError = class extends Error {
6399
+ ref;
6400
+ reason;
6401
+ constructor(ref, reason) {
6402
+ 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.`);
6403
+ this.ref = ref;
6404
+ this.reason = reason;
6405
+ this.name = "SecretOverwriteRefusedError";
6406
+ }
6407
+ };
6408
+ function isRecord(value) {
6409
+ return typeof value === "object" && value !== null && !Array.isArray(value);
6410
+ }
6411
+ function resolvedValue(pass, marker) {
6412
+ const answer = pass.answers[marker.$secret];
6413
+ return answer?.kind === "value" ? answer.value : null;
6414
+ }
6415
+ async function atMarker(pass, incoming, stored) {
6416
+ if (incoming === null) return stored;
6417
+ if (typeof incoming !== "string") return incoming;
6418
+ if (incoming === resolvedValue(pass, stored)) return stored;
6419
+ const intent = classifySecretWrite(incoming);
6420
+ if (intent.kind !== "set") return stored;
6421
+ const ref = stored.$secret;
6422
+ if (!isSecretRefOwnedBy(ref, pass.secrets.owner)) return incoming;
6423
+ const answer = pass.answers[ref];
6424
+ 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);
6425
+ try {
6426
+ await pass.secrets.put(ref, intent.value);
6427
+ } catch (err) {
6428
+ throw new KeychainWriteRefusedError(ref, err);
6429
+ }
6430
+ pass.changedRefs.push(ref);
6431
+ return stored;
6432
+ }
6433
+ function inArray(pass, incoming, stored) {
6434
+ return incoming.map((item, index) => {
6435
+ const twin = stored[index];
6436
+ if (isSecretMarker(twin)) return typeof item === "string" && item === resolvedValue(pass, twin) ? twin : item;
6437
+ if (isRecord(item) && isRecord(twin)) return inArrayRow(pass, item, twin);
6438
+ if (Array.isArray(item) && Array.isArray(twin)) return inArray(pass, item, twin);
6439
+ return item;
6440
+ });
6441
+ }
6442
+ function inArrayRow(pass, incoming, stored) {
6443
+ const out = { ...incoming };
6444
+ for (const [key, value] of Object.entries(incoming)) {
6445
+ const twin = stored[key];
6446
+ if (isSecretMarker(twin)) {
6447
+ if (typeof value === "string" && value === resolvedValue(pass, twin)) out[key] = twin;
6448
+ } else if (isRecord(value) && isRecord(twin)) out[key] = inArrayRow(pass, value, twin);
6449
+ else if (Array.isArray(value) && Array.isArray(twin)) out[key] = inArray(pass, value, twin);
6450
+ }
6451
+ return out;
6452
+ }
6453
+ async function walk(pass, incoming, stored) {
6454
+ if (isSecretMarker(stored)) return atMarker(pass, incoming, stored);
6455
+ if (Array.isArray(incoming) && Array.isArray(stored)) return inArray(pass, incoming, stored);
6456
+ if (!isRecord(incoming) || !isRecord(stored)) return incoming;
6457
+ const out = { ...incoming };
6458
+ for (const [key, value] of Object.entries(incoming)) out[key] = await walk(pass, value, stored[key]);
6459
+ return out;
6460
+ }
6461
+ /** Restore markers a write-back carries as values. See the file doc. */
6462
+ async function restoreUnchangedSecrets(input) {
6463
+ const refs = [];
6464
+ for (const key of Object.keys(input.patch)) collectSecretMarkerRefs(input.stored[key], refs);
6465
+ const owned = refs.filter((ref) => isSecretRefOwnedBy(ref, input.secrets.owner));
6466
+ if (owned.length === 0) return {
6467
+ patch: input.patch,
6468
+ changedRefs: []
6469
+ };
6470
+ const pass = {
6471
+ secrets: input.secrets,
6472
+ answers: await input.secrets.resolve([...new Set(owned)]),
6473
+ operatorWrite: input.operatorWrite,
6474
+ changedRefs: []
6475
+ };
6476
+ const out = {};
6477
+ for (const [key, value] of Object.entries(input.patch)) out[key] = await walk(pass, value, input.stored[key]);
6478
+ return {
6479
+ patch: out,
6480
+ changedRefs: pass.changedRefs
6481
+ };
6482
+ }
6483
+ /** Structural equality over JSON-shaped values (key order does not matter). */
6484
+ function isJsonEqual(a, b) {
6485
+ if (Object.is(a, b)) return true;
6486
+ if (Array.isArray(a)) return Array.isArray(b) && a.length === b.length && a.every((v, i) => isJsonEqual(v, b[i]));
6487
+ if (isRecord(a) && isRecord(b)) {
6488
+ const keys = Object.keys(a);
6489
+ if (keys.length !== Object.keys(b).length) return false;
6490
+ return keys.every((k) => Object.prototype.hasOwnProperty.call(b, k) && isJsonEqual(a[k], b[k]));
6311
6491
  }
6312
6492
  return false;
6313
6493
  }
6494
+ /** The patch without the keys whose value already equals the stored one. */
6495
+ function dropUnchangedKeys(patch, stored) {
6496
+ const out = {};
6497
+ for (const [key, value] of Object.entries(patch)) {
6498
+ if (Object.prototype.hasOwnProperty.call(stored, key) && isJsonEqual(value, stored[key])) continue;
6499
+ out[key] = value;
6500
+ }
6501
+ return out;
6502
+ }
6503
+ /** The top-level keys of a blob that hold at least one of `owner`'s markers. */
6504
+ function markerKeysOf(blob, owner) {
6505
+ const keys = /* @__PURE__ */ new Set();
6506
+ for (const [key, value] of Object.entries(blob)) if (collectSecretMarkerRefs(value).some((ref) => isSecretRefOwnedBy(ref, owner))) keys.add(key);
6507
+ return keys;
6508
+ }
6509
+ function nodeFromStored(value, owner) {
6510
+ if (isSecretMarker(value)) return isSecretRefOwnedBy(value.$secret, owner) ? { kind: "leaf" } : null;
6511
+ if (!isRecord(value)) return null;
6512
+ const children = /* @__PURE__ */ new Map();
6513
+ for (const [key, child] of Object.entries(value)) {
6514
+ const node = nodeFromStored(child, owner);
6515
+ if (node !== null) children.set(key, node);
6516
+ }
6517
+ return children.size > 0 ? {
6518
+ kind: "object",
6519
+ children
6520
+ } : null;
6521
+ }
6522
+ /**
6523
+ * The declared secret tree, widened by every place the STORED blob holds a
6524
+ * marker under one of `keys` — so a marker the schema no longer declares (or
6525
+ * never declared: Wyze before b4906cec6) still gets the save path's
6526
+ * KEEP / SET / CLEAR semantics instead of being overwritten by whatever the
6527
+ * addon writes. Markers inside arrays are not added: a row has no id field to
6528
+ * match by unless the schema declares one. Only `owner`'s markers count: a
6529
+ * builtin that keeps another addon's marker (device-manager) never takes it
6530
+ * over.
6531
+ */
6532
+ function widenTreeWithStoredMarkers(declared, stored, keys, owner) {
6533
+ const added = /* @__PURE__ */ new Map();
6534
+ for (const key of keys) {
6535
+ const at = key.indexOf("@");
6536
+ const base = at > 0 ? key.slice(0, at) : key;
6537
+ if (declared.has(base) || added.has(base)) continue;
6538
+ const node = nodeFromStored(stored[key], owner);
6539
+ if (node !== null) added.set(base, node);
6540
+ }
6541
+ return added.size === 0 ? declared : new Map([...declared, ...added]);
6542
+ }
6314
6543
  /** The blob as stored now; a failed read REFUSES the write instead of guessing. */
6315
6544
  async function readStoredAddonBlob(raw) {
6316
6545
  const threeWay = raw.readAddonStoreResult;
@@ -6319,7 +6548,41 @@ async function readStoredAddonBlob(raw) {
6319
6548
  if (result.kind === "failed") throw new Error(`settings write refused: the stored blob could not be read (${result.error})`);
6320
6549
  return result.kind === "missing" ? {} : result.value;
6321
6550
  }
6322
- function createSecretAwareSettings(raw, opts) {
6551
+ function touchesTree(tree, patch) {
6552
+ if (tree.size === 0) return false;
6553
+ for (const key of Object.keys(patch)) {
6554
+ const at = key.indexOf("@");
6555
+ if (tree.has(at > 0 ? key.slice(0, at) : key)) return true;
6556
+ }
6557
+ return false;
6558
+ }
6559
+ /**
6560
+ * Which top-level keys of each store held markers when last seen. `undefined`
6561
+ * for a store not seen yet: its first write reads it, to be safe.
6562
+ */
6563
+ var MarkerKeyIndex = class {
6564
+ owner;
6565
+ byStore = /* @__PURE__ */ new Map();
6566
+ constructor(owner) {
6567
+ this.owner = owner;
6568
+ }
6569
+ seen(store, blob) {
6570
+ this.byStore.set(store, markerKeysOf(blob, this.owner));
6571
+ }
6572
+ wrote(store, patch) {
6573
+ const keys = this.byStore.get(store);
6574
+ if (keys === void 0) return;
6575
+ const now = markerKeysOf(patch, this.owner);
6576
+ for (const key of Object.keys(patch)) if (now.has(key)) keys.add(key);
6577
+ else keys.delete(key);
6578
+ }
6579
+ mayHoldMarkers(store, patch) {
6580
+ const keys = this.byStore.get(store);
6581
+ if (keys === void 0) return true;
6582
+ return Object.keys(patch).some((key) => keys.has(key));
6583
+ }
6584
+ };
6585
+ function createHandle(raw, opts) {
6323
6586
  const chains = /* @__PURE__ */ new Map();
6324
6587
  const serialize = (key, fn) => {
6325
6588
  const next = (chains.get(key) ?? Promise.resolve()).then(fn, fn);
@@ -6330,46 +6593,130 @@ function createSecretAwareSettings(raw, opts) {
6330
6593
  });
6331
6594
  return next;
6332
6595
  };
6333
- const write = async (chainKey, tree, scope, patch, readStored, rawWrite) => {
6334
- if (!touchesTree(tree, patch)) return rawWrite(patch);
6335
- return serialize(chainKey, async () => {
6596
+ const index = new MarkerKeyIndex(opts.secrets.owner);
6597
+ const resolveRead = async (store, blob) => {
6598
+ index.seen(store, blob);
6599
+ const { value, unresolved } = await resolveSecretMarkers(blob, opts.secrets, {
6600
+ unresolved: "keep-marker",
6601
+ ownedBy: opts.secrets.owner
6602
+ });
6603
+ if (unresolved.length > 0) opts.onUnresolved?.(unresolved);
6604
+ return value;
6605
+ };
6606
+ const write = async (store, declared, scope, patch, readStored, rawWrite) => {
6607
+ if (!touchesTree(declared, patch) && !index.mayHoldMarkers(store, patch)) {
6608
+ await rawWrite(patch);
6609
+ index.wrote(store, patch);
6610
+ return { changed: true };
6611
+ }
6612
+ return serialize(store, async () => {
6336
6613
  const stored = await readStored();
6614
+ index.seen(store, stored);
6615
+ const operatorWrite = opts.isOperatorWrite?.() === true;
6616
+ const restored = await restoreUnchangedSecrets({
6617
+ patch,
6618
+ stored,
6619
+ secrets: opts.secrets,
6620
+ operatorWrite
6621
+ });
6337
6622
  const result = await transformSecretWrite({
6338
- tree,
6623
+ tree: widenTreeWithStoredMarkers(declared, stored, Object.keys(restored.patch), opts.secrets.owner),
6339
6624
  secrets: opts.secrets,
6340
- patch,
6625
+ patch: restored.patch,
6341
6626
  stored,
6342
6627
  ...scope !== void 0 ? { scope } : {},
6343
- operatorWrite: opts.isOperatorWrite?.() === true
6628
+ operatorWrite
6344
6629
  });
6345
- if (Object.keys(result.patch).length > 0) await rawWrite(result.patch);
6630
+ const effective = dropUnchangedKeys(result.patch, stored);
6631
+ const wroteBlob = Object.keys(effective).length > 0;
6632
+ if (wroteBlob) {
6633
+ await rawWrite(effective);
6634
+ index.wrote(store, effective);
6635
+ }
6346
6636
  const { orphaned } = await result.afterWrite();
6347
6637
  if (orphaned.length > 0) opts.onOrphaned(orphaned);
6638
+ return { changed: wroteBlob || restored.changedRefs.length > 0 };
6348
6639
  });
6349
6640
  };
6350
- const wrapped = {
6351
- writeAddonStore: (patch) => write("addon", opts.addonTree(), void 0, patch, () => readStoredAddonBlob(raw), (p) => raw.writeAddonStore(p)),
6352
- writeDeviceStore: (deviceId, patch) => write(`device:${deviceId}`, opts.deviceTree(), {
6353
- kind: "device",
6354
- deviceId
6355
- }, patch, () => raw.readDeviceStore(deviceId), (p) => raw.writeDeviceStore(deviceId, p))
6641
+ const writeAddon = (patch) => write("addon", opts.addonTree(), void 0, patch, () => readStoredAddonBlob(raw), (p) => raw.writeAddonStore(p));
6642
+ const readAddonStoreResult = raw.readAddonStoreResult;
6643
+ const readAddonStoreKeyResult = raw.readAddonStoreKeyResult;
6644
+ const readDeviceStoreBatch = raw.readDeviceStoreBatch;
6645
+ const overrides = {
6646
+ readAddonStore: async () => resolveRead("addon", await raw.readAddonStore()),
6647
+ ...readAddonStoreResult !== void 0 ? { readAddonStoreResult: async () => {
6648
+ const result = await readAddonStoreResult.call(raw);
6649
+ return result.kind === "value" ? {
6650
+ kind: "value",
6651
+ value: await resolveRead("addon", result.value)
6652
+ } : result;
6653
+ } } : {},
6654
+ ...readAddonStoreKeyResult !== void 0 ? { readAddonStoreKeyResult: async (key) => {
6655
+ const result = await readAddonStoreKeyResult.call(raw, key);
6656
+ if (result.kind !== "present") return result;
6657
+ const { value, unresolved } = await resolveSecretMarkers({ [key]: result.value }, opts.secrets, {
6658
+ unresolved: "keep-marker",
6659
+ ownedBy: opts.secrets.owner
6660
+ });
6661
+ if (unresolved.length > 0) opts.onUnresolved?.(unresolved);
6662
+ return {
6663
+ kind: "present",
6664
+ value: value[key]
6665
+ };
6666
+ } } : {},
6667
+ readDeviceStore: async (deviceId) => resolveRead(`device:${deviceId}`, await raw.readDeviceStore(deviceId)),
6668
+ ...readDeviceStoreBatch !== void 0 ? { readDeviceStoreBatch: async (deviceIds) => {
6669
+ const rows = await readDeviceStoreBatch.call(raw, deviceIds);
6670
+ const out = /* @__PURE__ */ new Map();
6671
+ for (const [deviceId, blob] of rows) out.set(deviceId, await resolveRead(`device:${deviceId}`, blob));
6672
+ return out;
6673
+ } } : {},
6674
+ writeAddonStore: async (patch) => {
6675
+ await writeAddon(patch);
6676
+ },
6677
+ writeDeviceStore: async (deviceId, patch) => {
6678
+ await write(`device:${deviceId}`, opts.deviceTree(), {
6679
+ kind: "device",
6680
+ deviceId
6681
+ }, patch, () => raw.readDeviceStore(deviceId), (p) => raw.writeDeviceStore(deviceId, p));
6682
+ }
6683
+ };
6684
+ return {
6685
+ settings: new Proxy(raw, { get(target, prop, receiver) {
6686
+ if (typeof prop === "string" && Object.prototype.hasOwnProperty.call(overrides, prop)) return Reflect.get(overrides, prop);
6687
+ const value = Reflect.get(target, prop, receiver);
6688
+ return typeof value === "function" ? value.bind(target) : value;
6689
+ } }),
6690
+ raw: {
6691
+ readAddonStore: async () => {
6692
+ const blob = await raw.readAddonStore();
6693
+ index.seen("addon", blob);
6694
+ return blob;
6695
+ },
6696
+ readDeviceStore: async (deviceId) => {
6697
+ const blob = await raw.readDeviceStore(deviceId);
6698
+ index.seen(`device:${deviceId}`, blob);
6699
+ return blob;
6700
+ }
6701
+ },
6702
+ writeAddonStore: writeAddon
6356
6703
  };
6357
- return new Proxy(raw, { get(target, prop, receiver) {
6358
- if (prop === "writeAddonStore") return wrapped.writeAddonStore;
6359
- if (prop === "writeDeviceStore") return wrapped.writeDeviceStore;
6360
- const value = Reflect.get(target, prop, receiver);
6361
- return typeof value === "function" ? value.bind(target) : value;
6362
- } });
6363
6704
  }
6364
- /** The context the addon sees: identical, except that its settings writes are secret-aware. */
6365
- function withSecretAwareSettings(context, opts) {
6705
+ /** The context the addon sees, plus the private raw view and write outcome. */
6706
+ function createSecretAwareContext(context, opts) {
6366
6707
  const raw = context.settings;
6367
- if (raw === void 0) return context;
6368
- const settings = createSecretAwareSettings(raw, opts);
6369
- return new Proxy(context, { get(target, prop, receiver) {
6370
- if (prop === "settings") return settings;
6371
- return Reflect.get(target, prop, receiver);
6372
- } });
6708
+ if (raw === void 0) return {
6709
+ context,
6710
+ handle: null
6711
+ };
6712
+ const handle = createHandle(raw, opts);
6713
+ return {
6714
+ context: new Proxy(context, { get(target, prop, receiver) {
6715
+ if (prop === "settings") return handle.settings;
6716
+ return Reflect.get(target, prop, receiver);
6717
+ } }),
6718
+ handle
6719
+ };
6373
6720
  }
6374
6721
  var LEAF = { kind: "leaf" };
6375
6722
  var DEFAULT_ITEM_ID_KEY = "id";
@@ -6544,6 +6891,14 @@ var BaseAddon = class {
6544
6891
  _secretChangeUnsub = null;
6545
6892
  /** >0 while an OPERATOR's settings write is being applied. */
6546
6893
  _operatorWriteDepth = 0;
6894
+ /**
6895
+ * The keychain-aware settings handle (D798). Its `raw` view is the ONLY way
6896
+ * to the marker-bearing blobs and stays private to this class: the form
6897
+ * hydrate and config resolution need markers, addon code never does.
6898
+ */
6899
+ _secretSettings = null;
6900
+ /** Refs an addon-facing read could not resolve — each is logged once per process. */
6901
+ _loggedUnresolvedReads = /* @__PURE__ */ new Set();
6547
6902
  constructor(defaults) {
6548
6903
  this.defaults = defaults;
6549
6904
  this._config = { ...defaults };
@@ -6580,13 +6935,21 @@ var BaseAddon = class {
6580
6935
  }
6581
6936
  async initialize(context) {
6582
6937
  const secrets = context.secrets;
6583
- this._ctx = secrets !== void 0 ? withSecretAwareSettings(context, {
6584
- secrets,
6585
- addonTree: () => this.addonSecretTree(),
6586
- deviceTree: () => this.deviceSecretTree(),
6587
- onOrphaned: (refs) => context.logger.warn("keychain refs dropped by a settings write could not be deleted", { meta: { refs: [...refs] } }),
6588
- isOperatorWrite: () => this._operatorWriteDepth > 0
6589
- }) : context;
6938
+ if (secrets !== void 0) {
6939
+ const { context: wrapped, handle } = createSecretAwareContext(context, {
6940
+ secrets,
6941
+ addonTree: () => this.addonSecretTree(),
6942
+ deviceTree: () => this.deviceSecretTree(),
6943
+ onOrphaned: (refs) => context.logger.warn("keychain refs dropped by a settings write could not be deleted", { meta: { refs: [...refs] } }),
6944
+ isOperatorWrite: () => this._operatorWriteDepth > 0,
6945
+ onUnresolved: (unresolved) => this.logUnresolvedRead(unresolved)
6946
+ });
6947
+ this._ctx = wrapped;
6948
+ this._secretSettings = handle;
6949
+ } else {
6950
+ this._ctx = context;
6951
+ this._secretSettings = null;
6952
+ }
6590
6953
  await this.resolveConfig();
6591
6954
  if (secrets !== void 0) this._secretChangeUnsub = secrets.onChange((ref) => {
6592
6955
  if (this._configSecretRefs.has(ref)) this.scheduleSecretReresolve(SECRET_CHANGE_DEBOUNCE_MS);
@@ -6703,11 +7066,8 @@ var BaseAddon = class {
6703
7066
  async getGlobalSettings(overlay, cap, nodeId) {
6704
7067
  const schema = this.globalSettingsSchema(cap);
6705
7068
  if (!schema) return { sections: [] };
6706
- const projected = await this.resolveGlobalStore(nodeId, cap);
6707
- return hydrateSchema(schema, overlay ? {
6708
- ...projected,
6709
- ...overlay
6710
- } : projected, { inlineSecretsAsViews: true });
7069
+ const projected = await this.readRawProjectedStore(nodeId, cap);
7070
+ return hydrateSchema(schema, overlay ? await this.overlayKeepingMarkers(projected, overlay) : projected, { inlineSecretsAsViews: true });
6711
7071
  }
6712
7072
  /**
6713
7073
  * The integration-level view of this addon's settings: exactly the sections
@@ -6752,7 +7112,7 @@ var BaseAddon = class {
6752
7112
  });
6753
7113
  }
6754
7114
  if (sections.length === 0) return null;
6755
- const projected = await this.resolveGlobalStore(nodeId);
7115
+ const projected = await this.readRawProjectedStore(nodeId);
6756
7116
  return hydrateSchema({
6757
7117
  ...schema,
6758
7118
  sections
@@ -6769,12 +7129,50 @@ var BaseAddon = class {
6769
7129
  * the store for custom option logic (option narrowing, value snapping) to
6770
7130
  * read it per-node — never `ctx.settings.readAddonStore()` directly.
6771
7131
  * `nodeId` omitted ⇒ the local node (node-blind injection from ctx).
7132
+ *
7133
+ * Keychain values come back RESOLVED (D798): a secret reads as its value,
7134
+ * never as a `{ $secret }` marker. One the keychain cannot serve right now
7135
+ * stays a marker — "stored, unavailable" (`isSecretMarker()` is true, and it
7136
+ * is listed in {@link unresolvedSecrets}) — never `''` and never absent, so
7137
+ * it cannot be mistaken for "nothing stored, mint a new one". Writing the
7138
+ * resolved blob back is a no-op for every unchanged secret.
6772
7139
  */
6773
7140
  async resolveGlobalStore(nodeId, cap) {
6774
7141
  const raw = await this._ctx?.settings?.readAddonStore() ?? {};
7142
+ return this.projectForNode(raw, nodeId, cap);
7143
+ }
7144
+ projectForNode(store, nodeId, cap) {
6775
7145
  const keys = this.perNodeKeys(cap);
6776
7146
  const node = normalizeNodeId(nodeId ?? this._ctx?.kernel?.localNodeId);
6777
- return keys.size > 0 ? projectStore(raw, keys, node) : raw;
7147
+ return keys.size > 0 ? projectStore(store, keys, node) : store;
7148
+ }
7149
+ /** The PROJECTED store with its markers — the form hydrate only (D798). */
7150
+ async readRawProjectedStore(nodeId, cap) {
7151
+ const raw = await this.rawSettings()?.readAddonStore() ?? {};
7152
+ return this.projectForNode(raw, nodeId, cap);
7153
+ }
7154
+ /**
7155
+ * `{ ...stored, ...overlay }`, except that an overlay member equal to the
7156
+ * RESOLVED stored one keeps the stored (marker-bearing) member — so a form
7157
+ * hydrated from a resolved overlay still shows a secret as "set", never as
7158
+ * its value.
7159
+ */
7160
+ async overlayKeepingMarkers(stored, overlay) {
7161
+ const secrets = this._ctx?.secrets;
7162
+ const merged = {
7163
+ ...stored,
7164
+ ...overlay
7165
+ };
7166
+ if (secrets === void 0 || collectSecretMarkerRefs(stored).length === 0) return merged;
7167
+ const { value: resolved } = await resolveSecretMarkers(stored, secrets, {
7168
+ unresolved: "keep-marker",
7169
+ ownedBy: secrets.owner
7170
+ });
7171
+ for (const key of Object.keys(overlay)) {
7172
+ if (collectSecretMarkerRefs(stored[key]).length === 0) continue;
7173
+ if (isJsonEqual(overlay[key], resolved[key])) merged[key] = stored[key];
7174
+ }
7175
+ return merged;
6778
7176
  }
6779
7177
  /**
6780
7178
  * Whether ONE global key of this addon's store was written, read three-way
@@ -6839,8 +7237,12 @@ var BaseAddon = class {
6839
7237
  async clearSecrets(keys, nodeId) {
6840
7238
  const tree = this.addonSecretTree();
6841
7239
  const keychain = this._ctx?.secrets !== void 0;
7240
+ const stored = keychain ? await this.readAddonStoreWithRetry() : {};
6842
7241
  const patch = {};
6843
- for (const key of keys) patch[key] = keychain && tree.has(key) ? SECRET_CLEAR : "";
7242
+ for (const key of keys) {
7243
+ const keychainStored = tree.has(key) || collectSecretMarkerRefs(stored[key]).length > 0;
7244
+ patch[key] = keychain && keychainStored ? SECRET_CLEAR : "";
7245
+ }
6844
7246
  await this.applyGlobalPatch(patch, nodeId);
6845
7247
  }
6846
7248
  async applyGlobalPatch(barePatch, nodeId) {
@@ -6848,7 +7250,11 @@ var BaseAddon = class {
6848
7250
  const localNode = normalizeNodeId(this._ctx?.kernel?.localNodeId);
6849
7251
  const target = normalizeNodeId(nodeId ?? this._ctx?.kernel?.localNodeId);
6850
7252
  const scoped = keys.size > 0 ? scopePatch(barePatch, keys, target) : barePatch;
6851
- await this._ctx?.settings?.writeAddonStore(scoped);
7253
+ const handle = this._secretSettings;
7254
+ if (handle !== null) {
7255
+ const { changed } = await handle.writeAddonStore(scoped);
7256
+ if (!changed) return;
7257
+ } else await this._ctx?.settings?.writeAddonStore(scoped);
6852
7258
  if (target !== localNode) return;
6853
7259
  await this.resolveConfig();
6854
7260
  await this.onConfigChanged();
@@ -6901,7 +7307,7 @@ var BaseAddon = class {
6901
7307
  async getDeviceSettings(deviceId) {
6902
7308
  const schema = this.deviceSettingsSchema();
6903
7309
  if (!schema) return { sections: [] };
6904
- return hydrateSchema(schema, await this._ctx?.settings?.readDeviceStore(deviceId) ?? {}, { inlineSecretsAsViews: true });
7310
+ return hydrateSchema(schema, await this.rawSettings()?.readDeviceStore(deviceId) ?? {}, { inlineSecretsAsViews: true });
6905
7311
  }
6906
7312
  async updateDeviceSettings(deviceId, patch) {
6907
7313
  await this._ctx?.settings?.writeDeviceStore(deviceId, patch);
@@ -7073,7 +7479,7 @@ var BaseAddon = class {
7073
7479
  key,
7074
7480
  schema,
7075
7481
  fallback,
7076
- read: async () => this.resolveStoredSecrets(await this._ctx?.settings?.readDeviceStore(deviceId) ?? {}, false),
7482
+ read: async () => this.resolveStoredSecrets(await this.rawSettings()?.readDeviceStore(deviceId) ?? {}, false),
7077
7483
  write: async (patch) => {
7078
7484
  await this._ctx?.settings?.writeDeviceStore(deviceId, patch);
7079
7485
  },
@@ -7135,6 +7541,23 @@ var BaseAddon = class {
7135
7541
  }
7136
7542
  return value;
7137
7543
  }
7544
+ /**
7545
+ * The marker-bearing settings reads (D798) — private on purpose. Without a
7546
+ * keychain the context's own view is already raw.
7547
+ */
7548
+ rawSettings() {
7549
+ return this._secretSettings?.raw ?? this._ctx?.settings;
7550
+ }
7551
+ /** An addon-facing read met markers it could not resolve: say so once per ref. */
7552
+ logUnresolvedRead(unresolved) {
7553
+ const fresh = unresolved.filter((u) => !this._loggedUnresolvedReads.has(u.ref));
7554
+ if (fresh.length === 0) return;
7555
+ for (const u of fresh) this._loggedUnresolvedReads.add(u.ref);
7556
+ 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) => ({
7557
+ ref: u.ref,
7558
+ reason: u.reason
7559
+ })) } });
7560
+ }
7138
7561
  /** Re-resolve the config (a keychain-only change, or a retry) and apply it. */
7139
7562
  scheduleSecretReresolve(delayMs) {
7140
7563
  const timerOf = delayMs === SECRET_CHANGE_DEBOUNCE_MS ? "_secretChangeTimer" : "_secretRetryTimer";
@@ -7161,7 +7584,7 @@ var BaseAddon = class {
7161
7584
  * `{}` (defaults) — the addon's first successful patch will rehydrate.
7162
7585
  */
7163
7586
  async readAddonStoreWithRetry() {
7164
- const settings = this._ctx?.settings;
7587
+ const settings = this.rawSettings();
7165
7588
  if (!settings) return {};
7166
7589
  const delaysMs = [
7167
7590
  150,
@@ -9486,6 +9909,278 @@ var CameraSwitchGroupSchema = object({
9486
9909
  fetchedAt: number()
9487
9910
  });
9488
9911
  /**
9912
+ * The trainer contract — what the hub hands the cloud trainer and what it
9913
+ * gets back (cloud training, D805+).
9914
+ *
9915
+ * The trainer (`hf/camstack-trainer`, published as the Hugging Face repo
9916
+ * `camstack/camstack-trainer`) is a separate AGPL program the hub never
9917
+ * imports: `job.json` goes in, files come out, and progress is `CAMSTACK_EVENT`
9918
+ * lines on stdout. These schemas are the hub's half of that boundary; the
9919
+ * trainer's pydantic models (and the JSON Schemas generated from them under
9920
+ * `hf/camstack-trainer/schemas/`) are the other half. A change here is a
9921
+ * change there, in the same piece of work.
9922
+ *
9923
+ * No `.default()` anywhere: defaults do not run on the addon cap path, so the
9924
+ * orchestrator fills every field of a job spec explicitly.
9925
+ */
9926
+ var TRAINING_JOB_SCHEMA = "camstack.training/v1";
9927
+ var TRAINING_RESULT_SCHEMA = "camstack.training-result/v1";
9928
+ /** What the trainer can export. Edge TPU is a later, separate image. */
9929
+ var TrainingExportSchema = _enum([
9930
+ "onnx",
9931
+ "openvino-fp16",
9932
+ "openvino-int8",
9933
+ "coreml-fp16"
9934
+ ]);
9935
+ var FloorsSchema = record(string(), number().min(0).max(1));
9936
+ object({
9937
+ schema: literal(TRAINING_JOB_SCHEMA),
9938
+ jobKey: string().uuid(),
9939
+ target: object({
9940
+ kind: literal("detector"),
9941
+ step: literal("object-detection")
9942
+ }),
9943
+ base: object({
9944
+ modelId: string().min(1),
9945
+ /** Ultralytics weights id, e.g. `yolov9m.pt`. */
9946
+ weights: string().min(1),
9947
+ imgsz: number().int().positive()
9948
+ }),
9949
+ baseline: object({
9950
+ modelId: string().min(1),
9951
+ /** The baseline ONNX the holdout comparison runs; public mirror URL. */
9952
+ onnxUrl: string().url(),
9953
+ imgsz: number().int().positive(),
9954
+ floors: FloorsSchema
9955
+ }),
9956
+ dataset: object({
9957
+ versionId: string().min(1),
9958
+ annotationHash: string(),
9959
+ /** sha256 of the uploaded archive; the trainer refuses a mismatch (exit 65). */
9960
+ sha256: string().regex(/^[0-9a-f]{64}$/)
9961
+ }),
9962
+ split: object({
9963
+ holdoutCameras: array(number().int()),
9964
+ /** When no camera is held out: the last N days of every camera. */
9965
+ holdoutLastDays: number().int().nonnegative(),
9966
+ valFraction: number().min(0).max(.5),
9967
+ seed: number().int()
9968
+ }),
9969
+ hyper: object({
9970
+ epochs: number().int().positive(),
9971
+ batch: number().int().positive(),
9972
+ lr0: number().positive(),
9973
+ /** Layers frozen from the start of the backbone; 0 = none. */
9974
+ freeze: number().int().nonnegative(),
9975
+ patience: number().int().nonnegative(),
9976
+ seed: number().int()
9977
+ }),
9978
+ replay: object({
9979
+ source: literal("coco2017"),
9980
+ count: number().int().nonnegative()
9981
+ }),
9982
+ exports: array(TrainingExportSchema).min(1),
9983
+ calibration: object({ maxFrames: number().int().positive() }),
9984
+ floors: object({
9985
+ minSupport: number().int().positive(),
9986
+ clamp: number().min(0).max(1)
9987
+ }),
9988
+ int8Gate: object({ maxMap50Drop: number().min(0).max(1) }),
9989
+ catalog: object({
9990
+ id: string().regex(/^[a-z0-9][a-z0-9-]{2,80}$/),
9991
+ name: string().min(1).max(160)
9992
+ })
9993
+ });
9994
+ /** One regular file of the bundle. An mlpackage contributes one row per member. */
9995
+ var TrainingResultFileSchema = object({
9996
+ path: string().min(1),
9997
+ bytes: number().int().nonnegative(),
9998
+ sha256: string().regex(/^[0-9a-f]{64}$/),
9999
+ format: _enum([
10000
+ "onnx",
10001
+ "openvino",
10002
+ "coreml",
10003
+ "pt"
10004
+ ]),
10005
+ variant: _enum(["base", "int8"])
10006
+ });
10007
+ var DraftFormatSchema = object({
10008
+ /** RELATIVE path inside the bundle; the hub rewrites it to `camstack-local://`. */
10009
+ url: string().min(1),
10010
+ sizeMB: number().nonnegative(),
10011
+ isDirectory: boolean().optional(),
10012
+ files: array(string()).optional(),
10013
+ runtimes: array(literal("python")).optional(),
10014
+ revision: string().min(1)
10015
+ });
10016
+ /** The trainer's half of a catalog entry; the hub completes it (labels, licence, group). */
10017
+ var TrainingCatalogDraftSchema = object({
10018
+ id: string().min(1),
10019
+ name: string().min(1),
10020
+ description: string(),
10021
+ labels: array(unknown()),
10022
+ inputSize: object({
10023
+ width: number().int().positive(),
10024
+ height: number().int().positive()
10025
+ }),
10026
+ preprocessMode: literal("letterbox"),
10027
+ defaultClassFloors: FloorsSchema,
10028
+ formats: object({
10029
+ onnx: DraftFormatSchema.optional(),
10030
+ openvino: DraftFormatSchema.optional(),
10031
+ coreml: DraftFormatSchema.optional()
10032
+ })
10033
+ });
10034
+ /** One class of one model's holdout report (the eval harness's summary). */
10035
+ var TrainingEvalClassSchema = object({
10036
+ positives: number().int(),
10037
+ floor: number().nullable(),
10038
+ tp: number().int(),
10039
+ fp: number().int(),
10040
+ fn: number().int(),
10041
+ precision: number().nullable(),
10042
+ recall: number().nullable(),
10043
+ ap50: number().nullable(),
10044
+ recallByCamera: record(string(), number().nullable()).optional(),
10045
+ recallByLight: record(string(), number().nullable()).optional(),
10046
+ fpByCamera: record(string(), number()).optional(),
10047
+ smallFound: number().int().optional(),
10048
+ smallTotal: number().int().optional()
10049
+ }).passthrough();
10050
+ var TrainingEvalReportSchema = object({
10051
+ frames: number().int(),
10052
+ classes: record(string(), TrainingEvalClassSchema)
10053
+ }).passthrough();
10054
+ /**
10055
+ * A succeeded result carries every block; a failed one carries the error and
10056
+ * whatever was known by then — the other blocks are ABSENT, not null. The
10057
+ * orchestrator checks the blocks it needs before it trusts a success.
10058
+ */
10059
+ var TrainingResultSchema = object({
10060
+ schema: literal(TRAINING_RESULT_SCHEMA),
10061
+ jobKey: string(),
10062
+ status: _enum(["succeeded", "failed"]),
10063
+ error: object({
10064
+ stage: string(),
10065
+ code: string(),
10066
+ message: string()
10067
+ }).nullable(),
10068
+ trainer: object({
10069
+ version: string(),
10070
+ revision: string()
10071
+ }),
10072
+ toolchain: record(string(), string().nullable()),
10073
+ dataset: object({
10074
+ versionId: string(),
10075
+ annotationHash: string(),
10076
+ sha256: string(),
10077
+ frames: object({
10078
+ train: number().int(),
10079
+ val: number().int(),
10080
+ holdout: number().int()
10081
+ }),
10082
+ holdoutCameras: array(number().int()),
10083
+ replayImages: number().int()
10084
+ }).optional(),
10085
+ training: object({
10086
+ epochsRun: number().int(),
10087
+ bestEpoch: number().int(),
10088
+ bestMap50: number(),
10089
+ bestMap50_95: number(),
10090
+ seconds: number()
10091
+ }).optional(),
10092
+ evaluation: object({
10093
+ holdoutFrames: number().int(),
10094
+ baseline: TrainingEvalReportSchema.nullable(),
10095
+ candidate: TrainingEvalReportSchema.nullable(),
10096
+ candidateInt8: TrainingEvalReportSchema.nullable(),
10097
+ recallDeltaByCamera: record(string(), record(string(), number())).nullable(),
10098
+ map50: record(string(), number().nullable())
10099
+ }).optional(),
10100
+ floors: object({
10101
+ baseline: FloorsSchema,
10102
+ candidate: FloorsSchema,
10103
+ candidateInt8: FloorsSchema.nullable(),
10104
+ notes: array(string())
10105
+ }).optional(),
10106
+ int8: object({
10107
+ kept: boolean(),
10108
+ map50Fp16: number().nullable(),
10109
+ map50Int8: number().nullable(),
10110
+ reason: string().nullable()
10111
+ }).optional(),
10112
+ exportsDropped: array(object({
10113
+ export: string(),
10114
+ reason: string()
10115
+ })).optional(),
10116
+ files: array(TrainingResultFileSchema).optional(),
10117
+ bundle: object({
10118
+ path: literal("bundle.tar"),
10119
+ bytes: number().int().nonnegative(),
10120
+ sha256: string().regex(/^[0-9a-f]{64}$/)
10121
+ }).nullable().optional(),
10122
+ catalogDraft: object({
10123
+ base: TrainingCatalogDraftSchema,
10124
+ int8: TrainingCatalogDraftSchema.nullable()
10125
+ }).nullable().optional(),
10126
+ licence: string()
10127
+ });
10128
+ var TrainingStageSchema = _enum([
10129
+ "prepare",
10130
+ "replay",
10131
+ "train",
10132
+ "eval",
10133
+ "export",
10134
+ "package"
10135
+ ]);
10136
+ var EventBase = {
10137
+ v: literal(1),
10138
+ ts: number()
10139
+ };
10140
+ discriminatedUnion("type", [
10141
+ object({
10142
+ ...EventBase,
10143
+ type: literal("stage"),
10144
+ stage: TrainingStageSchema
10145
+ }),
10146
+ object({
10147
+ ...EventBase,
10148
+ type: literal("epoch"),
10149
+ epoch: number().int(),
10150
+ epochs: number().int(),
10151
+ boxLoss: number().nullable().optional(),
10152
+ map50: number().nullable().optional(),
10153
+ map50_95: number().nullable().optional(),
10154
+ etaSec: number().nullable().optional()
10155
+ }),
10156
+ object({
10157
+ ...EventBase,
10158
+ type: literal("metric"),
10159
+ name: string(),
10160
+ value: number()
10161
+ }),
10162
+ object({
10163
+ ...EventBase,
10164
+ type: literal("artifact"),
10165
+ path: string(),
10166
+ bytes: number(),
10167
+ sha256: string()
10168
+ }),
10169
+ object({
10170
+ ...EventBase,
10171
+ type: literal("done"),
10172
+ status: _enum(["succeeded", "failed"]),
10173
+ resultSha256: string().nullable().optional()
10174
+ }),
10175
+ object({
10176
+ ...EventBase,
10177
+ type: literal("error"),
10178
+ stage: string(),
10179
+ code: string(),
10180
+ message: string()
10181
+ })
10182
+ ]);
10183
+ /**
9489
10184
  * What the gate decided about a birth, from the CALLER's point of view.
9490
10185
  *
9491
10186
  * Deliberately not `ConfirmationVerdict`: `undecided` is not a birth decision
@@ -12094,7 +12789,9 @@ var AddonHttpRouteSchema = object({
12094
12789
  "authenticated",
12095
12790
  "admin"
12096
12791
  ]).optional(),
12097
- description: string().optional()
12792
+ description: string().optional(),
12793
+ /** The hub limits this route per client address before the handler runs. */
12794
+ rateLimit: _enum(["auth"]).optional()
12098
12795
  });
12099
12796
  /**
12100
12797
  * Cross-process route invocation envelope. The hub captures the
@@ -12799,6 +13496,37 @@ var BackupDestinationInfoSchema = object({
12799
13496
  lastError: string().optional()
12800
13497
  });
12801
13498
  /**
13499
+ * How an archive is encrypted (operator decision 2026-10-09): to a backup
13500
+ * PUBLIC key the hub holds, so only the operator's secret key opens it.
13501
+ * Absent on a plain `.tar.gz` — every archive made before encryption, or
13502
+ * with it off — which restores without a key.
13503
+ */
13504
+ var BackupArchiveEncryptionSchema = object({
13505
+ /** `x25519-hkdf-aes256gcm-stream-v1`. */
13506
+ scheme: string(),
13507
+ /** 16 hex — the backup key whose secret restores this archive. */
13508
+ keyId: string()
13509
+ });
13510
+ /**
13511
+ * The backup encryption setting. The hub keeps PUBLIC keys only: the active
13512
+ * one new archives are encrypted to, and the retired ones older archives
13513
+ * still need. The secret key is shown once, at `setupEncryption`.
13514
+ */
13515
+ var BackupEncryptionStatusSchema = object({
13516
+ enabled: boolean(),
13517
+ active: object({
13518
+ keyId: string(),
13519
+ publicKey: string(),
13520
+ createdAt: number()
13521
+ }).nullable(),
13522
+ /** Every key ever set up, newest first. */
13523
+ keys: array(object({
13524
+ keyId: string(),
13525
+ createdAt: number(),
13526
+ retiredAt: number().nullable()
13527
+ })).readonly()
13528
+ });
13529
+ /**
12802
13530
  * Per-archive entry returned by `backup.listArchives({ destinationId })`.
12803
13531
  * Same shape the destination drill-in renders. Sourced from the per-
12804
13532
  * location `manifests.json` (no per-archive tarball read required).
@@ -12810,7 +13538,9 @@ var BackupArchiveEntrySchema = object({
12810
13538
  sizeBytes: number(),
12811
13539
  label: string().optional(),
12812
13540
  /** Top-level locations included in the archive (db, addons, tls, …). */
12813
- locations: array(string()).readonly()
13541
+ locations: array(string()).readonly(),
13542
+ /** Present when the archive is encrypted; restore then needs that key. */
13543
+ encryption: BackupArchiveEncryptionSchema.optional()
12814
13544
  });
12815
13545
  var BackupEntrySchema = object({
12816
13546
  id: string(),
@@ -12819,7 +13549,8 @@ var BackupEntrySchema = object({
12819
13549
  label: string().optional(),
12820
13550
  createdAt: number(),
12821
13551
  sizeBytes: number(),
12822
- locations: array(string()).optional()
13552
+ locations: array(string()).optional(),
13553
+ encryption: BackupArchiveEncryptionSchema.optional()
12823
13554
  });
12824
13555
  var ArchiveEntrySchema = object({
12825
13556
  path: string(),
@@ -13008,10 +13739,40 @@ method(_void(), array(BackupDestinationInfoSchema).readonly(), { auth: "admin" }
13008
13739
  * this list and skips entries whose path doesn't start with
13009
13740
  * any of them.
13010
13741
  */
13011
- locations: array(string()).optional()
13742
+ locations: array(string()).optional(),
13743
+ /**
13744
+ * The backup SECRET key, for an encrypted archive (ignored for a plain
13745
+ * one). The archive is decrypted into the hub's private staging
13746
+ * before the restart; the key is not stored. A wrong or missing key
13747
+ * is refused before the archive is downloaded.
13748
+ */
13749
+ backupSecretKey: string().optional()
13012
13750
  }), _void(), {
13013
13751
  kind: "mutation",
13014
13752
  auth: "admin"
13753
+ }), method(_void(), BackupEncryptionStatusSchema, { auth: "admin" }), method(object({}), object({
13754
+ keyId: string(),
13755
+ secretKey: string(),
13756
+ publicKey: string(),
13757
+ createdAt: number(),
13758
+ replacedKeyId: string().nullable()
13759
+ }), {
13760
+ kind: "mutation",
13761
+ auth: "admin"
13762
+ }), method(object({}), object({ disabledKeyId: string().nullable() }), {
13763
+ kind: "mutation",
13764
+ auth: "admin"
13765
+ }), method(object({ backupSecretKey: string() }), object({
13766
+ valid: boolean(),
13767
+ keyId: string().nullable(),
13768
+ /** The hub knows this key (active or retired). */
13769
+ known: boolean(),
13770
+ /** It is the key new archives are encrypted to. */
13771
+ active: boolean(),
13772
+ error: string().optional()
13773
+ }), {
13774
+ kind: "mutation",
13775
+ auth: "admin"
13015
13776
  }), method(object({
13016
13777
  destinationId: string(),
13017
13778
  backupId: string()
@@ -14737,7 +15498,60 @@ var CustomModelDescriptorSchema = object({
14737
15498
  stepId: string(),
14738
15499
  entry: ModelCatalogEntrySchema
14739
15500
  });
14740
- method(_void(), array(CustomModelDescriptorSchema).readonly(), { auth: "admin" });
15501
+ /** One regular file of an imported bundle, as the producer measured it. */
15502
+ var ModelBundleFileSchema = object({
15503
+ /** Relative path inside the bundle tar; an mlpackage member is `<x>.mlpackage/<member>`. */
15504
+ path: string().min(1),
15505
+ bytes: number().int().nonnegative(),
15506
+ sha256: string().regex(/^[0-9a-f]{64}$/)
15507
+ });
15508
+ var ImportModelBundleInputSchema = object({
15509
+ /** The registry provider that keeps the model (Model Studio). */
15510
+ addonId: string(),
15511
+ stepId: string().min(1),
15512
+ /**
15513
+ * The catalog rows to register, complete, every format URL already
15514
+ * `camstack-local://<modelId>/<file>` naming a file of the bundle. One
15515
+ * bundle may carry several rows (a base and its INT8 variant).
15516
+ */
15517
+ entries: array(ModelCatalogEntrySchema).min(1).max(4),
15518
+ /** The bundle tar, offered by the producer over `ctx.peerBytes` (same host). */
15519
+ bundle: object({
15520
+ ticket: PeerBytesTicketSchema,
15521
+ bytes: number().int().positive(),
15522
+ sha256: string().regex(/^[0-9a-f]{64}$/)
15523
+ }),
15524
+ /** Every file the tar must hold; anything missing, extra or different is refused. */
15525
+ files: array(ModelBundleFileSchema).min(1).max(64),
15526
+ /** Convert missing engine formats and push the model to every agent afterwards. */
15527
+ distribute: boolean()
15528
+ });
15529
+ var ImportModelBundleResultSchema = discriminatedUnion("kind", [object({
15530
+ kind: literal("imported"),
15531
+ modelIds: array(string()).readonly(),
15532
+ distributed: array(object({
15533
+ modelId: string(),
15534
+ nodeId: string(),
15535
+ format: _enum(MODEL_FORMATS),
15536
+ ok: boolean(),
15537
+ error: string().optional()
15538
+ })).readonly()
15539
+ }), object({
15540
+ kind: literal("refused"),
15541
+ reason: _enum([
15542
+ "transfer-failed",
15543
+ "checksum-mismatch",
15544
+ "bundle-mismatch",
15545
+ "invalid-entry",
15546
+ "id-taken"
15547
+ ]),
15548
+ detail: string()
15549
+ })]);
15550
+ method(_void(), array(CustomModelDescriptorSchema).readonly(), { auth: "admin" }), method(ImportModelBundleInputSchema, ImportModelBundleResultSchema, {
15551
+ kind: "mutation",
15552
+ auth: "admin",
15553
+ timeoutMs: 30 * 6e4
15554
+ });
14741
15555
  /**
14742
15556
  * Query filter for settings-store collections.
14743
15557
  */
@@ -15216,6 +16030,35 @@ var KeychainKeySourceSchema = object({
15216
16030
  */
15217
16031
  sharesBackupWithDatabase: boolean()
15218
16032
  });
16033
+ /**
16034
+ * One keychain reset, as the Secrets page reports it until the operator
16035
+ * acknowledges it. Never a value: refs, counts and table names only.
16036
+ */
16037
+ var KeychainResetRecordSchema = object({
16038
+ id: string(),
16039
+ at: number(),
16040
+ /** `user:<id>` or {@link KEYCHAIN_RESET_TRIGGER_ACTOR}. */
16041
+ actor: string(),
16042
+ /** Why the keychain was locked when it was reset; `null` when it was not locked. */
16043
+ lockedReason: string().nullable(),
16044
+ /** Values moved into the archive table (ciphertext under the lost key). */
16045
+ archived: number().int(),
16046
+ /** `keychain:secrets-orphaned-<ts>`, or `null` when nothing was stored. */
16047
+ archivedCollection: string().nullable(),
16048
+ /**
16049
+ * `keychain:keys-orphaned-<ts>`: the wrapped data keys of the archive, kept
16050
+ * so the archive can still be opened if the lost master key turns up.
16051
+ */
16052
+ archivedKeysCollection: string().nullable(),
16053
+ /**
16054
+ * `system-settings` keys whose marker the reset cleared — the cluster
16055
+ * secret's: a marker left pointing at an archived value would refuse every
16056
+ * agent forever (D797).
16057
+ */
16058
+ clearedSettingsKeys: array(string()).readonly(),
16059
+ /** When an operator dismissed the notice on the Secrets page; `null` until then. */
16060
+ acknowledgedAt: number().nullable()
16061
+ });
15219
16062
  var KeychainStatusSchema = object({
15220
16063
  keychain: KeychainStateSchema,
15221
16064
  /** The source of the master key in use; `null` while locked. */
@@ -15233,7 +16076,9 @@ var KeychainStatusSchema = object({
15233
16076
  /** Wrapped copies of the data key under a previous master key, kept until purged. */
15234
16077
  retiredWraps: number().int(),
15235
16078
  recoveryKeyDownloadedAt: number().nullable(),
15236
- secretCount: number().int()
16079
+ secretCount: number().int(),
16080
+ /** The most recent reset, acknowledged or not; `null` when the keychain was never reset. */
16081
+ lastReset: KeychainResetRecordSchema.nullable()
15237
16082
  });
15238
16083
  /**
15239
16084
  * Whether a stored value is still pointed at by its owner's settings.
@@ -15255,17 +16100,26 @@ var KeychainAuditActionSchema = _enum([
15255
16100
  "download-recovery-key",
15256
16101
  "delete-orphans",
15257
16102
  "reset",
16103
+ "acknowledge-reset",
15258
16104
  "initialize"
15259
16105
  ]);
15260
16106
  var KeychainAuditEntrySchema = object({
15261
16107
  id: string(),
15262
16108
  at: number(),
15263
16109
  action: KeychainAuditActionSchema,
15264
- /** `addon:<id>` | `user:<id>` | `system`. */
16110
+ /** `addon:<id>` | `user:<id>` | `system` | `trigger-file`. */
15265
16111
  actor: string(),
15266
16112
  ref: string().nullable(),
15267
16113
  detail: string().nullable()
15268
16114
  });
16115
+ var KEYCHAIN_RESET_CONFIRMATION = "RESET KEYCHAIN";
16116
+ /**
16117
+ * Secrets the HUB itself holds (owner `system`) that no settings form shows:
16118
+ * `jwt-signing-key` — the session signing key (D797). It is always "in use",
16119
+ * never an orphan; it is generated on a fresh hub and replaced only through
16120
+ * {@link keychainAdminCapability.methods.setSystemSecret}.
16121
+ */
16122
+ var SystemHeldSecretNameSchema = _enum(["jwt-signing-key"]);
15269
16123
  method(object({}), KeychainStatusSchema, { auth: "admin" }), method(object({}), array(KeychainAdminSecretSchema).readonly(), { auth: "admin" }), method(object({ limit: number().int().min(1).max(500).optional() }), array(KeychainAuditEntrySchema).readonly(), { auth: "admin" }), method(object({ ref: string().min(1) }), object({
15270
16124
  value: string(),
15271
16125
  version: number().int()
@@ -15273,6 +16127,16 @@ method(object({}), KeychainStatusSchema, { auth: "admin" }), method(object({}),
15273
16127
  kind: "mutation",
15274
16128
  auth: "admin",
15275
16129
  caller: "required"
16130
+ }), method(object({
16131
+ name: SystemHeldSecretNameSchema,
16132
+ value: string().min(16)
16133
+ }), object({
16134
+ ref: string(),
16135
+ version: number().int()
16136
+ }), {
16137
+ kind: "mutation",
16138
+ auth: "admin",
16139
+ caller: "required"
15276
16140
  }), method(object({ refs: array(string().min(1)).max(1e3) }), object({
15277
16141
  deleted: array(string()).readonly(),
15278
16142
  kept: array(object({
@@ -15302,13 +16166,20 @@ method(object({}), KeychainStatusSchema, { auth: "admin" }), method(object({}),
15302
16166
  kind: "mutation",
15303
16167
  auth: "admin",
15304
16168
  caller: "required"
15305
- }), method(object({ confirm: literal("RESET KEYCHAIN") }), object({
16169
+ }), method(object({ confirm: literal(KEYCHAIN_RESET_CONFIRMATION) }), object({
15306
16170
  archivedCollection: string().nullable(),
15307
16171
  archived: number().int()
15308
16172
  }), {
15309
16173
  kind: "mutation",
15310
16174
  auth: "admin",
15311
16175
  caller: "required"
16176
+ }), method(object({}), object({
16177
+ reset: KeychainResetRecordSchema.nullable(),
16178
+ pendingReentry: array(KeychainSecretMetaSchema).readonly()
16179
+ }), { auth: "admin" }), method(object({}), object({ acknowledged: boolean() }), {
16180
+ kind: "mutation",
16181
+ auth: "admin",
16182
+ caller: "required"
15312
16183
  });
15313
16184
  method(_void(), object({
15314
16185
  id: string(),
@@ -18274,7 +19145,7 @@ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
18274
19145
  * `login-method` — collection cap through which auth addons contribute
18275
19146
  * their pre-auth login surfaces to the login page. This is the SINGLE,
18276
19147
  * generic mechanism that supersedes the dead `auth.listProviders` reader:
18277
- * every auth addon (OIDC, magic-link, WebAuthn/passkey) registers a
19148
+ * every auth addon (OIDC, WebAuthn/passkey) registers a
18278
19149
  * `login-method` provider and the PUBLIC `auth.listLoginMethods`
18279
19150
  * procedure aggregates them for the unauthenticated login page.
18280
19151
  *
@@ -18282,8 +19153,7 @@ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
18282
19153
  *
18283
19154
  * - `redirect` — a declarative button. The login page renders a generic
18284
19155
  * button that navigates to `startUrl` (an addon-owned HTTP route).
18285
- * Covers OIDC (`/addon/auth-oidc/<id>/start`) and magic-link with
18286
- * ZERO shell-side JS. A future SSO addon plugs in the same way — the
19156
+ * Covers OIDC (`/addon/auth-oidc/<id>/start`) with ZERO shell-side JS. A future SSO addon plugs in the same way — the
18287
19157
  * login page needs NO change.
18288
19158
  *
18289
19159
  * - `widget` — a Module-Federation widget the login page mounts (via
@@ -18302,8 +19172,8 @@ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
18302
19172
  * decision.
18303
19173
  *
18304
19174
  * Every contribution carries a `stage`:
18305
- * - `primary` — shown on the first credentials screen (OIDC /
18306
- * magic-link buttons; a future usernameless passkey).
19175
+ * - `primary` — shown on the first credentials screen (OIDC
19176
+ * buttons; a usernameless passkey).
18307
19177
  * - `second-factor` — shown AFTER the password leg, gated on the
18308
19178
  * returned `factors` (passkey-as-2FA today).
18309
19179
  *
@@ -18330,7 +19200,7 @@ var LoginMethodContributionSchema = discriminatedUnion("kind", [
18330
19200
  * The provider names an external identity a signed-in user can link to
18331
19201
  * their own account (D782): `auth.listLinkableProviders` /
18332
19202
  * `beginExternalLink` offer exactly the redirect methods that set this,
18333
- * whatever their id. Absent / false — a login button only (magic-link).
19203
+ * whatever their id. Absent / false — a login button only.
18334
19204
  */
18335
19205
  linkable: boolean().optional()
18336
19206
  }),
@@ -22185,8 +23055,7 @@ method(object({}), object({ rules: array(NcRuleSchema) }), { auth: "admin" }), m
22185
23055
  * `super_admin` — collapsed onto the single boolean because every
22186
23056
  * non-admin caller is governed by the same scope-check rules; the
22187
23057
  * distinction was only ever used to route role-specific procedures
22188
- * which we no longer have. Agents are admin sessions issued via
22189
- * `createServiceToken`; CLI / webhook integrations are `cst_*` tokens
23058
+ * which we no longer have. CLI / webhook integrations are `cst_*` tokens
22190
23059
  * with `isAdmin: false` + an explicit scope list.
22191
23060
  */
22192
23061
  /** Per-method access flavour. Materialised on every cap method via codegen. */
@@ -23861,6 +24730,9 @@ var RetrainExportFilterSchema = object({
23861
24730
  frameIds: array(string()).max(2e4).optional(),
23862
24731
  /** Only frames in at least one of these named collections. */
23863
24732
  collectionIds: array(string()).max(200).optional(),
24733
+ /** Exactly the frames of this dataset version (and its completeOnly). An
24734
+ * unknown id selects nothing. */
24735
+ datasetVersionId: string().optional(),
23864
24736
  batchId: string().optional(),
23865
24737
  /** Only frames the operator marked complete (all subjects boxed). */
23866
24738
  completeOnly: boolean().optional()
@@ -24028,6 +24900,67 @@ var RetrainLlmAssistResultSchema = discriminatedUnion("kind", [object({
24028
24900
  ]),
24029
24901
  detail: string().optional()
24030
24902
  })]);
24903
+ /** What a dataset version is cut from. Every field narrows. */
24904
+ var RetrainDatasetSelectionSchema = object({
24905
+ deviceIds: array(number()).readonly().optional(),
24906
+ collectionIds: array(string()).max(200).readonly().optional(),
24907
+ frameIds: array(string()).max(2e4).readonly().optional()
24908
+ });
24909
+ /** The counts a dataset is judged by. */
24910
+ var RetrainDatasetStatsSchema = object({
24911
+ frames: number().int(),
24912
+ completeFrames: number().int(),
24913
+ /** `completeFrames / frames`, 0..1. */
24914
+ completeness: number(),
24915
+ /** Boxes to learn (model errors excluded). */
24916
+ subjects: number().int(),
24917
+ modelErrors: number().int(),
24918
+ /** Complete frames with no subject. */
24919
+ hardNegatives: number().int(),
24920
+ /** Subjects per class × camera × day/night. */
24921
+ cells: array(object({
24922
+ macroClass: string(),
24923
+ deviceId: number(),
24924
+ lighting: _enum([
24925
+ "day",
24926
+ "night",
24927
+ "unknown"
24928
+ ]),
24929
+ subjects: number().int(),
24930
+ frames: number().int()
24931
+ })).readonly(),
24932
+ cameras: array(object({
24933
+ deviceId: number(),
24934
+ frames: number().int(),
24935
+ completeFrames: number().int()
24936
+ })).readonly()
24937
+ });
24938
+ /** An immutable dataset version, without its frame list. */
24939
+ var RetrainDatasetVersionSchema = object({
24940
+ id: string(),
24941
+ name: string(),
24942
+ createdAt: number(),
24943
+ selection: RetrainDatasetSelectionSchema,
24944
+ layout: RetrainExportLayoutSchema,
24945
+ completeOnly: boolean(),
24946
+ frameCount: number().int(),
24947
+ /** sha256 of what the frames taught when the version was frozen. */
24948
+ annotationHash: string(),
24949
+ /** The export manifest schema the version was cut under. */
24950
+ manifestSchema: string(),
24951
+ stats: RetrainDatasetStatsSchema
24952
+ });
24953
+ var CreateRetrainDatasetVersionResultSchema = discriminatedUnion("kind", [object({
24954
+ kind: literal("created"),
24955
+ version: RetrainDatasetVersionSchema
24956
+ }), object({
24957
+ kind: literal("refused"),
24958
+ reason: _enum([
24959
+ "empty-name",
24960
+ "duplicate-name",
24961
+ "no-frames"
24962
+ ])
24963
+ })]);
24031
24964
  /** The outcome of a lifecycle move owned by the retrain page. */
24032
24965
  var RetrainTransitionResultSchema = object({
24033
24966
  trackId: string(),
@@ -24817,6 +25750,47 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
24817
25750
  kind: "mutation",
24818
25751
  auth: "admin",
24819
25752
  timeoutMs: 60 * 6e4
25753
+ }), method(object({
25754
+ filter: RetrainExportFilterSchema,
25755
+ layout: RetrainExportLayoutSchema
25756
+ }), object({
25757
+ ticket: PeerBytesTicketSchema,
25758
+ frames: number().int(),
25759
+ annotations: number().int()
25760
+ }), {
25761
+ kind: "mutation",
25762
+ auth: "admin",
25763
+ timeoutMs: 12e4
25764
+ }), method(object({
25765
+ selection: RetrainDatasetSelectionSchema,
25766
+ completeOnly: boolean().optional()
25767
+ }), RetrainDatasetStatsSchema, {
25768
+ kind: "query",
25769
+ auth: "admin"
25770
+ }), method(object({
25771
+ name: string().max(120),
25772
+ selection: RetrainDatasetSelectionSchema,
25773
+ layout: RetrainExportLayoutSchema,
25774
+ completeOnly: boolean()
25775
+ }), CreateRetrainDatasetVersionResultSchema, {
25776
+ kind: "mutation",
25777
+ auth: "admin",
25778
+ timeoutMs: 12e4
25779
+ }), method(object({}), array(RetrainDatasetVersionSchema).readonly(), {
25780
+ kind: "query",
25781
+ auth: "admin"
25782
+ }), method(object({ id: string() }), object({ deleted: boolean() }), {
25783
+ kind: "mutation",
25784
+ auth: "admin"
25785
+ }), method(object({ id: string() }), object({
25786
+ found: boolean(),
25787
+ annotationHash: string(),
25788
+ matches: boolean(),
25789
+ missingFrames: number().int()
25790
+ }), {
25791
+ kind: "query",
25792
+ auth: "admin",
25793
+ timeoutMs: 12e4
24820
25794
  }), method(object({}), array(RetrainAssistProfileSchema).readonly(), {
24821
25795
  kind: "query",
24822
25796
  auth: "admin"
@@ -28395,8 +29369,8 @@ version: string().optional() }), ServerUpdateActionResultSchema, {
28395
29369
  * `smtp-provider` — pluggable email delivery surface.
28396
29370
  *
28397
29371
  * Collection cap: a deployment may install multiple SMTP relays (e.g.
28398
- * one for transactional / one for notifications). Consumers (magic-link,
28399
- * notifier addons, …) walk the collection and pick the first
29372
+ * one for transactional / one for notifications). Consumers (notifier
29373
+ * addons, …) walk the collection and pick the first
28400
29374
  * ready provider OR target a specific addonId.
28401
29375
  *
28402
29376
  * The shape stays small on purpose — `sendEmail` is enough for the
@@ -28679,7 +29653,7 @@ targets: array(object({
28679
29653
  };
28680
29654
  /**
28681
29655
  * `sso-bridge` — internal hub-only cap that lets SSO-style auth
28682
- * providers (OIDC, SAML, magic-link, …) mint an HMAC-signed token
29656
+ * providers (OIDC, SAML, …) mint an HMAC-signed token
28683
29657
  * carrying the post-callback claims before redirecting back to
28684
29658
  * `/api/auth/sso/finish`.
28685
29659
  *
@@ -28742,7 +29716,14 @@ var SsoBridgeClaimsSchema = object({
28742
29716
  * Verified `iss` of the id_token behind an OIDC login bridge (D782). A
28743
29717
  * subject is unique only per issuer, so a link is bound to it.
28744
29718
  */
28745
- issuer: string().optional()
29719
+ issuer: string().optional(),
29720
+ /**
29721
+ * SHA-256 (hex) of the `camstack_sso_state` cookie the IdP `/start` set in
29722
+ * the browser that began this sign-in. `/api/auth/sso/finish` requires the
29723
+ * request to present the matching cookie — a login bridge is useless in
29724
+ * any other browser.
29725
+ */
29726
+ browserBinding: string().optional()
28746
29727
  });
28747
29728
  method(object({
28748
29729
  claims: SsoBridgeClaimsSchema,
@@ -41980,16 +42961,6 @@ var ApiKeySummarySchema = object({
41980
42961
  createdAt: number(),
41981
42962
  lastUsedAt: number().optional()
41982
42963
  });
41983
- var CreateApiKeyInputSchema = object({
41984
- label: string(),
41985
- isAdmin: boolean().default(false),
41986
- allowedProviders: union([array(string()), literal("*")]).optional(),
41987
- allowedDevices: record(string(), union([array(string()), literal("*")])).optional()
41988
- });
41989
- var CreateApiKeyResultSchema = object({
41990
- token: string(),
41991
- record: ApiKeySummarySchema
41992
- });
41993
42964
  var ScopedTokenSummarySchema = object({
41994
42965
  id: string(),
41995
42966
  userId: string(),
@@ -42088,17 +43059,10 @@ method(_void(), array(UserSummarySchema), { auth: "admin" }), method(CreateUserI
42088
43059
  }), UserSummarySchema.extend({ passwordHash: string() }).nullable(), {
42089
43060
  kind: "mutation",
42090
43061
  access: "view"
42091
- }), method(_void(), array(ApiKeySummarySchema), { auth: "admin" }), method(CreateApiKeyInputSchema, CreateApiKeyResultSchema, {
42092
- kind: "mutation",
42093
- auth: "admin",
42094
- access: "create"
42095
- }), method(object({ id: string() }), object({ success: literal(true) }), {
43062
+ }), method(_void(), array(ApiKeySummarySchema), { auth: "admin" }), method(object({ id: string() }), object({ success: literal(true) }), {
42096
43063
  kind: "mutation",
42097
43064
  auth: "admin",
42098
43065
  access: "delete"
42099
- }), method(object({ token: string() }), ApiKeySummarySchema.nullable(), {
42100
- kind: "mutation",
42101
- access: "view"
42102
43066
  }), method(CreateScopedTokenInputSchema, CreateScopedTokenResultSchema, {
42103
43067
  kind: "mutation",
42104
43068
  auth: "admin",
@@ -42172,15 +43136,7 @@ method(_void(), array(UserSummarySchema), { auth: "admin" }), method(CreateUserI
42172
43136
  }).nullable(), { access: "view" }), method(object({ userId: string() }), array(ExternalIdentitySchema), { auth: "admin" }), method(ExternalIdentityKeySchema, object({
42173
43137
  userId: string(),
42174
43138
  issuer: string()
42175
- }).nullable(), { auth: "admin" }), method(ExternalIdentityKeySchema.extend({
42176
- userId: string(),
42177
- issuer: string().min(1),
42178
- label: string().optional()
42179
- }), object({ success: literal(true) }), {
42180
- kind: "mutation",
42181
- auth: "admin",
42182
- access: "create"
42183
- }), method(ExternalIdentityKeySchema.extend({ userId: string() }), object({ success: boolean() }), {
43139
+ }).nullable(), { auth: "admin" }), method(ExternalIdentityKeySchema.extend({ userId: string() }), object({ success: boolean() }), {
42184
43140
  kind: "mutation",
42185
43141
  auth: "admin",
42186
43142
  access: "delete"
@@ -42885,6 +43841,451 @@ var zoneRulesCapability = {
42885
43841
  */
42886
43842
  durability: "restored"
42887
43843
  };
43844
+ /**
43845
+ * `training-provider` — ONE cloud that can run the CamStack trainer.
43846
+ *
43847
+ * A thin, mockable translation layer: it knows how to run a container with a
43848
+ * GPU, move a dataset in, read the job's stdout and hand artefacts back. It
43849
+ * knows nothing about datasets, splits, floors, cost policy or Model Studio —
43850
+ * those are the `training` orchestrator's (D805). Every rule written there
43851
+ * once is what makes a second provider (RunPod, a local NVIDIA node) a new
43852
+ * manifest entry and nothing else.
43853
+ *
43854
+ * Collection, routed by the `addonId` in every single-row input (the `llm` /
43855
+ * `notification-output` posture); `describe` concat-fans across providers.
43856
+ * Every method is `admin`: these spend money.
43857
+ *
43858
+ * Every cloud object a provider creates is tagged with the orchestrator's
43859
+ * `jobKey`, so a retried submit finds the job it already started instead of
43860
+ * starting a second GPU, and `listJobs` can find orphans.
43861
+ *
43862
+ * Bytes never ride a cap field: the dataset arrives as a `ctx.peerBytes`
43863
+ * ticket the producer (pipeline-analytics) minted, and artefacts leave as a
43864
+ * ticket the provider mints (D613).
43865
+ */
43866
+ var TrainingGpuOptionSchema = object({
43867
+ id: string(),
43868
+ label: string(),
43869
+ /** List price, USD per GPU-hour, before any region multiplier. */
43870
+ usdPerHour: number().nonnegative(),
43871
+ vramGb: number().nonnegative()
43872
+ });
43873
+ var TrainingRegionOptionSchema = object({
43874
+ /** `''` = any region (the provider's choice). */
43875
+ id: string(),
43876
+ label: string(),
43877
+ priceMultiplier: number().positive()
43878
+ });
43879
+ /**
43880
+ * The provider's per-account settings, as the orchestrator reads them. They
43881
+ * live in the PROVIDER addon's settings (operator decision 2026-10-08: they
43882
+ * depend on the user's account), never hard-coded in the orchestrator.
43883
+ */
43884
+ var TrainingProviderDefaultsSchema = object({
43885
+ gpuType: string(),
43886
+ region: string(),
43887
+ costCapUsd: number().nonnegative(),
43888
+ maxRuntimeSec: number().int().positive(),
43889
+ /** Hours a FAILED job's cloud dataset is kept for debugging; 0 = delete at once. */
43890
+ failedDatasetGraceHours: number().nonnegative()
43891
+ });
43892
+ var TrainingProviderDescriptorSchema = object({
43893
+ addonId: string(),
43894
+ /** `modal`, `runpod`, `fake`, … */
43895
+ kind: string(),
43896
+ label: string(),
43897
+ gpuTypes: array(TrainingGpuOptionSchema).readonly(),
43898
+ regions: array(TrainingRegionOptionSchema).readonly(),
43899
+ maxDatasetBytes: number().int().positive(),
43900
+ maxRuntimeSec: number().int().positive(),
43901
+ freeTierNote: string().optional(),
43902
+ /** Where the data goes, in one sentence the confirm dialog repeats. */
43903
+ dataResidencyNote: string(),
43904
+ /** Credentials are present — never the values. */
43905
+ configured: boolean(),
43906
+ defaults: TrainingProviderDefaultsSchema
43907
+ });
43908
+ var TrainingCredentialCheckSchema = object({
43909
+ ok: boolean(),
43910
+ /** Workspace / account name, when the provider says. */
43911
+ account: string().optional(),
43912
+ reason: _enum([
43913
+ "missing",
43914
+ "invalid",
43915
+ "forbidden",
43916
+ "network",
43917
+ "quota"
43918
+ ]).optional(),
43919
+ detail: string().optional()
43920
+ });
43921
+ var ProviderJobStateSchema = _enum([
43922
+ "pending",
43923
+ "starting",
43924
+ "running",
43925
+ "succeeded",
43926
+ "failed",
43927
+ "cancelled",
43928
+ "lost"
43929
+ ]);
43930
+ var ProviderJobStatusSchema = object({
43931
+ jobKey: string(),
43932
+ providerJobId: string().optional(),
43933
+ state: ProviderJobStateSchema,
43934
+ startedAt: number().optional(),
43935
+ endedAt: number().optional(),
43936
+ exitCode: number().int().optional(),
43937
+ failureReason: string().optional(),
43938
+ gpuType: string(),
43939
+ region: string().optional(),
43940
+ billedSeconds: number().nonnegative(),
43941
+ costUsd: number().nonnegative(),
43942
+ /** True when `costUsd` is runtime × list price, not a billing answer. */
43943
+ costIsEstimate: boolean(),
43944
+ lastFetchedAt: number()
43945
+ });
43946
+ /**
43947
+ * The trainer the job runs, by SOURCE revision: the provider turns it into an
43948
+ * image its own way (Modal builds the published Dockerfile at that revision;
43949
+ * a registry-pull provider maps it to a tag). Recorded on the job and echoed
43950
+ * in `result.json`.
43951
+ */
43952
+ var TrainerSourceRefSchema = object({
43953
+ /** Hugging Face repo id, e.g. `camstack/camstack-trainer`. */
43954
+ repo: string().min(1),
43955
+ /** A commit sha (never a branch) — the job must be reproducible. */
43956
+ revision: string().regex(/^[0-9a-f]{7,64}$/)
43957
+ });
43958
+ var JobRef = {
43959
+ addonId: string(),
43960
+ jobKey: string().uuid()
43961
+ };
43962
+ var TrainingLogLineSchema = object({
43963
+ ts: number(),
43964
+ text: string()
43965
+ });
43966
+ method(object({}), array(TrainingProviderDescriptorSchema).readonly(), { auth: "admin" }), method(object({ addonId: string() }), TrainingCredentialCheckSchema, {
43967
+ kind: "mutation",
43968
+ auth: "admin",
43969
+ timeoutMs: 3e4
43970
+ }), method(object({
43971
+ addonId: string(),
43972
+ gpuType: string(),
43973
+ region: string(),
43974
+ datasetBytes: number().int().nonnegative(),
43975
+ gpuSecondsLow: number().nonnegative(),
43976
+ gpuSecondsHigh: number().nonnegative()
43977
+ }), object({
43978
+ usdLow: number().nonnegative(),
43979
+ usdHigh: number().nonnegative(),
43980
+ notes: array(string()).readonly()
43981
+ }), { auth: "admin" }), method(object({
43982
+ ...JobRef,
43983
+ ticket: PeerBytesTicketSchema
43984
+ }), object({
43985
+ bytes: number().int().nonnegative(),
43986
+ sha256: string()
43987
+ }), {
43988
+ kind: "mutation",
43989
+ auth: "admin",
43990
+ timeoutMs: 120 * 6e4
43991
+ }), method(object({
43992
+ ...JobRef,
43993
+ trainer: TrainerSourceRefSchema,
43994
+ jobSpecJson: string().min(2).max(64e3),
43995
+ gpuType: string(),
43996
+ region: string(),
43997
+ maxRuntimeSec: number().int().positive()
43998
+ }), ProviderJobStatusSchema, {
43999
+ kind: "mutation",
44000
+ auth: "admin",
44001
+ timeoutMs: 30 * 6e4
44002
+ }), method(object(JobRef), ProviderJobStatusSchema, {
44003
+ auth: "admin",
44004
+ timeoutMs: 6e4
44005
+ }), method(object({
44006
+ ...JobRef,
44007
+ cursor: string().optional(),
44008
+ max: number().int().min(1).max(500)
44009
+ }), object({
44010
+ lines: array(TrainingLogLineSchema).readonly(),
44011
+ cursor: string()
44012
+ }), {
44013
+ auth: "admin",
44014
+ timeoutMs: 6e4
44015
+ }), method(object(JobRef), object({ ok: literal(true) }), {
44016
+ kind: "mutation",
44017
+ auth: "admin",
44018
+ timeoutMs: 6e4
44019
+ }), method(object(JobRef), object({
44020
+ found: boolean(),
44021
+ text: string().optional()
44022
+ }), {
44023
+ kind: "mutation",
44024
+ auth: "admin",
44025
+ timeoutMs: 5 * 6e4
44026
+ }), method(object({
44027
+ ...JobRef,
44028
+ path: _enum(["bundle.tar"])
44029
+ }), object({ ticket: PeerBytesTicketSchema }), {
44030
+ kind: "mutation",
44031
+ auth: "admin",
44032
+ timeoutMs: 5 * 6e4
44033
+ }), method(object(JobRef), object({ deleted: array(string()).readonly() }), {
44034
+ kind: "mutation",
44035
+ auth: "admin",
44036
+ timeoutMs: 5 * 6e4
44037
+ }), method(object({ addonId: string() }), array(ProviderJobStatusSchema).readonly(), {
44038
+ auth: "admin",
44039
+ timeoutMs: 2 * 6e4
44040
+ });
44041
+ /**
44042
+ * `training` — the cloud-training orchestrator (D805). Hub-only singleton,
44043
+ * provided by `addon-training`.
44044
+ *
44045
+ * It owns what every provider must agree on, written once:
44046
+ *
44047
+ * - **Dataset versions.** Taken over from pipeline-analytics (D796): the rows
44048
+ * live here (D808); pipeline-analytics still CUTS a version (it owns the corpus and
44049
+ * the export plan) and reaches this store through the five row methods
44050
+ * below, so the Retrain page and the export did not change.
44051
+ * - **Jobs.** A persisted state machine, a reconcile loop against the
44052
+ * provider, a cost guard, a daily orphan sweep and the retention rules.
44053
+ * - **The return flow.** Verified artefacts → Model Studio
44054
+ * (`custom-model-registry.importModelBundle`) → canary on cameras →
44055
+ * rollback. Nothing is ever registered automatically.
44056
+ *
44057
+ * Every method is `admin`.
44058
+ */
44059
+ /** A version WITH its frame list — what the export and a job read. */
44060
+ var TrainingDatasetVersionRowSchema = RetrainDatasetVersionSchema.omit({ frameCount: true }).extend({ frameIds: array(string()).max(2e4).readonly() });
44061
+ /** A base model a detector job can fine-tune, and the baseline it is judged against. */
44062
+ var TrainingBaseModelSchema = object({
44063
+ modelId: string(),
44064
+ label: string(),
44065
+ weights: string(),
44066
+ imgsz: number().int(),
44067
+ baselineOnnxUrl: string(),
44068
+ baselineFloors: record(string(), number()),
44069
+ /** The base the fleet runs most — the UI's default. */
44070
+ recommended: boolean()
44071
+ });
44072
+ var TrainingPresetSchema = _enum([
44073
+ "quick",
44074
+ "standard",
44075
+ "thorough"
44076
+ ]);
44077
+ var TrainingJobRequestSchema = object({
44078
+ datasetVersionId: string().min(1),
44079
+ /** The `training-provider` addon that runs it. */
44080
+ addonId: string().min(1),
44081
+ gpuType: string().min(1),
44082
+ region: string(),
44083
+ baseModelId: string().min(1),
44084
+ preset: TrainingPresetSchema,
44085
+ /** Freeze the backbone's first N layers; `null` = the preset's choice. */
44086
+ freeze: number().int().nonnegative().nullable(),
44087
+ /** Cameras held out whole for evaluation; `null` = the orchestrator's default. */
44088
+ holdoutCameras: array(number().int()).nullable()
44089
+ });
44090
+ var TrainingSplitPlanSchema = object({
44091
+ holdoutCameras: array(number().int()).readonly(),
44092
+ /** Used when no camera is held out: the last N days of every camera. */
44093
+ holdoutLastDays: number().int().nonnegative(),
44094
+ /** Holdout subjects per class (camera holdout only; `null` = known only after the split). */
44095
+ holdoutSupport: record(string(), number().int()).nullable(),
44096
+ trainSubjects: number().int()
44097
+ });
44098
+ var TrainingRefusalReasonSchema = _enum([
44099
+ "unknown-dataset",
44100
+ "unknown-provider",
44101
+ "provider-not-configured",
44102
+ "unknown-base-model",
44103
+ "unknown-gpu",
44104
+ "dataset-too-large",
44105
+ "no-training-subjects",
44106
+ "job-already-running"
44107
+ ]);
44108
+ var TrainingJobPlanSchema = object({
44109
+ refusal: object({
44110
+ reason: TrainingRefusalReasonSchema,
44111
+ detail: string()
44112
+ }).nullable(),
44113
+ warnings: array(string()).readonly(),
44114
+ split: TrainingSplitPlanSchema.nullable(),
44115
+ estimate: object({
44116
+ datasetBytes: number().int(),
44117
+ uploadMinutesAt20Mbps: number(),
44118
+ gpuSecondsLow: number(),
44119
+ gpuSecondsHigh: number(),
44120
+ usdLow: number(),
44121
+ usdHigh: number(),
44122
+ notes: array(string()).readonly()
44123
+ }).nullable(),
44124
+ /** Pre-filled from the provider's settings; the operator may lower or raise them. */
44125
+ defaults: object({
44126
+ maxCostUsd: number(),
44127
+ maxRuntimeSec: number().int()
44128
+ }).nullable(),
44129
+ /** The sentence the confirm dialog repeats: where the frames go and when they are deleted. */
44130
+ dataNotice: string()
44131
+ });
44132
+ /**
44133
+ * Orchestrator-owned states, persisted. `uploading` covers exporting the
44134
+ * archive (it is streamed, never staged). Terminal: `failed`, `cancelled`,
44135
+ * `lost`, `expired`, `discarded`. `registered` and `canary` are where a
44136
+ * result lives after the operator acted on it.
44137
+ */
44138
+ var TrainingJobStateSchema = _enum([
44139
+ "uploading",
44140
+ "submitted",
44141
+ "starting",
44142
+ "running",
44143
+ "collecting",
44144
+ "ready",
44145
+ "registered",
44146
+ "canary",
44147
+ "failed",
44148
+ "cancelling",
44149
+ "cancelled",
44150
+ "lost",
44151
+ "expired",
44152
+ "discarded"
44153
+ ]);
44154
+ var TrainingFailureReasonSchema = _enum([
44155
+ "cost-cap",
44156
+ "runtime-cap",
44157
+ "upload-failed",
44158
+ "submit-failed",
44159
+ "trainer-failed",
44160
+ "result-invalid",
44161
+ "checksum-mismatch",
44162
+ "fetch-failed",
44163
+ "provider-error",
44164
+ "hub-restart-during-upload"
44165
+ ]);
44166
+ var TrainingProgressPointSchema = object({
44167
+ epoch: number().int(),
44168
+ map50: number().nullable(),
44169
+ map50_95: number().nullable()
44170
+ });
44171
+ var TrainingCanarySchema = object({
44172
+ deviceIds: array(number().int()).readonly(),
44173
+ since: number(),
44174
+ /** Every override the canary replaced, exactly, so rollback restores it. */
44175
+ previous: array(object({
44176
+ deviceId: number().int(),
44177
+ nodeId: string(),
44178
+ deviceKey: string(),
44179
+ patch: object({
44180
+ modelId: string().optional(),
44181
+ settings: record(string(), unknown()).readonly().optional()
44182
+ }).nullable()
44183
+ })).readonly()
44184
+ });
44185
+ var TrainingJobSchema = object({
44186
+ id: string(),
44187
+ idempotencyKey: string(),
44188
+ name: string(),
44189
+ createdAt: number(),
44190
+ updatedAt: number(),
44191
+ state: TrainingJobStateSchema,
44192
+ stage: TrainingStageSchema.nullable(),
44193
+ failure: object({
44194
+ reason: TrainingFailureReasonSchema,
44195
+ stage: string().nullable(),
44196
+ detail: string()
44197
+ }).nullable(),
44198
+ request: TrainingJobRequestSchema,
44199
+ maxCostUsd: number().nonnegative(),
44200
+ maxRuntimeSec: number().int().positive(),
44201
+ trainer: TrainerSourceRefSchema,
44202
+ datasetLayout: RetrainExportLayoutSchema,
44203
+ dataset: object({
44204
+ bytes: number().int(),
44205
+ sha256: string(),
44206
+ uploadedAt: number()
44207
+ }).nullable(),
44208
+ split: TrainingSplitPlanSchema,
44209
+ provider: object({
44210
+ state: ProviderJobStateSchema.nullable(),
44211
+ providerJobId: string().nullable(),
44212
+ startedAt: number().nullable(),
44213
+ endedAt: number().nullable(),
44214
+ billedSeconds: number(),
44215
+ costUsd: number(),
44216
+ costIsEstimate: boolean(),
44217
+ lastPolledAt: number().nullable()
44218
+ }),
44219
+ progress: object({
44220
+ epoch: number().int().nullable(),
44221
+ epochs: number().int().nullable(),
44222
+ etaSec: number().nullable(),
44223
+ series: array(TrainingProgressPointSchema).readonly()
44224
+ }),
44225
+ /** The last lines of the job's output (≤ 200), newest last. Never frame paths. */
44226
+ logTail: array(string()).readonly(),
44227
+ logCursor: string().nullable(),
44228
+ artifacts: object({
44229
+ bundleBytes: number().int(),
44230
+ bundleSha256: string(),
44231
+ fetchedAt: number(),
44232
+ /** When the staged artefacts are deleted from the hub. */
44233
+ expiresAt: number()
44234
+ }).nullable(),
44235
+ /** When the provider-side copy of the frames was deleted; null while it exists. */
44236
+ cloudDatasetDeletedAt: number().nullable(),
44237
+ /** A failed job's dataset is kept until then (the provider's grace), then deleted. */
44238
+ cloudCleanupDueAt: number().nullable(),
44239
+ /** Model ids registered from this job (base, and int8 when kept). */
44240
+ registeredModelIds: array(string()).readonly(),
44241
+ canary: TrainingCanarySchema.nullable()
44242
+ });
44243
+ var IdInput = object({ id: string().min(1) });
44244
+ method(TrainingDatasetVersionRowSchema, object({ stored: boolean() }), {
44245
+ kind: "mutation",
44246
+ auth: "admin"
44247
+ }), method(IdInput, TrainingDatasetVersionRowSchema.nullable(), { auth: "admin" }), method(object({}), array(RetrainDatasetVersionSchema).readonly(), { auth: "admin" }), method(object({ name: string() }), object({ id: string().nullable() }), { auth: "admin" }), method(IdInput, object({ removed: boolean() }), {
44248
+ kind: "mutation",
44249
+ auth: "admin"
44250
+ }), method(object({}), array(TrainingBaseModelSchema).readonly(), { auth: "admin" }), method(TrainingJobRequestSchema, TrainingJobPlanSchema, {
44251
+ auth: "admin",
44252
+ timeoutMs: 6e4
44253
+ }), method(TrainingJobRequestSchema.extend({
44254
+ name: string().min(1).max(120),
44255
+ maxCostUsd: number().positive(),
44256
+ maxRuntimeSec: number().int().positive(),
44257
+ idempotencyKey: string().min(8).max(80)
44258
+ }), discriminatedUnion("kind", [object({
44259
+ kind: literal("started"),
44260
+ job: TrainingJobSchema
44261
+ }), object({
44262
+ kind: literal("refused"),
44263
+ reason: TrainingRefusalReasonSchema,
44264
+ detail: string()
44265
+ })]), {
44266
+ kind: "mutation",
44267
+ auth: "admin",
44268
+ timeoutMs: 12e4
44269
+ }), method(object({}), array(TrainingJobSchema).readonly(), { auth: "admin" }), method(IdInput, TrainingJobSchema.nullable(), { auth: "admin" }), method(IdInput, TrainingJobSchema, {
44270
+ kind: "mutation",
44271
+ auth: "admin",
44272
+ timeoutMs: 12e4
44273
+ }), method(IdInput, TrainingResultSchema.nullable(), { auth: "admin" }), method(IdInput.extend({ canaryDeviceIds: array(number().int()).readonly() }), TrainingJobSchema, {
44274
+ kind: "mutation",
44275
+ auth: "admin",
44276
+ timeoutMs: 30 * 6e4
44277
+ }), method(IdInput.extend({ deviceIds: array(number().int()).min(1).readonly() }), TrainingJobSchema, {
44278
+ kind: "mutation",
44279
+ auth: "admin",
44280
+ timeoutMs: 12e4
44281
+ }), method(IdInput, TrainingJobSchema, {
44282
+ kind: "mutation",
44283
+ auth: "admin",
44284
+ timeoutMs: 12e4
44285
+ }), method(IdInput, TrainingJobSchema, {
44286
+ kind: "mutation",
44287
+ auth: "admin"
44288
+ });
42888
44289
  SOURCE_CAPS.filter((cap) => cap !== "switch" && cap !== "motion");
42889
44290
  Object.freeze({
42890
44291
  person: .5,
@@ -45048,6 +46449,12 @@ Object.freeze({
45048
46449
  addonId: null,
45049
46450
  access: "create"
45050
46451
  },
46452
+ "backup.checkBackupKey": {
46453
+ capName: "backup",
46454
+ capScope: "system",
46455
+ addonId: null,
46456
+ access: "create"
46457
+ },
45051
46458
  "backup.delete": {
45052
46459
  capName: "backup",
45053
46460
  capScope: "system",
@@ -45060,6 +46467,18 @@ Object.freeze({
45060
46467
  addonId: null,
45061
46468
  access: "delete"
45062
46469
  },
46470
+ "backup.disableEncryption": {
46471
+ capName: "backup",
46472
+ capScope: "system",
46473
+ addonId: null,
46474
+ access: "create"
46475
+ },
46476
+ "backup.getEncryption": {
46477
+ capName: "backup",
46478
+ capScope: "system",
46479
+ addonId: null,
46480
+ access: "view"
46481
+ },
45063
46482
  "backup.getEntries": {
45064
46483
  capName: "backup",
45065
46484
  capScope: "system",
@@ -45114,6 +46533,12 @@ Object.freeze({
45114
46533
  addonId: null,
45115
46534
  access: "create"
45116
46535
  },
46536
+ "backup.setupEncryption": {
46537
+ capName: "backup",
46538
+ capScope: "system",
46539
+ addonId: null,
46540
+ access: "create"
46541
+ },
45117
46542
  "backup.trigger": {
45118
46543
  capName: "backup",
45119
46544
  capScope: "system",
@@ -45666,6 +47091,12 @@ Object.freeze({
45666
47091
  addonId: null,
45667
47092
  access: "create"
45668
47093
  },
47094
+ "customModelRegistry.importModelBundle": {
47095
+ capName: "custom-model-registry",
47096
+ capScope: "system",
47097
+ addonId: null,
47098
+ access: "create"
47099
+ },
45669
47100
  "customModelRegistry.listModels": {
45670
47101
  capName: "custom-model-registry",
45671
47102
  capScope: "system",
@@ -47106,6 +48537,12 @@ Object.freeze({
47106
48537
  addonId: null,
47107
48538
  access: "view"
47108
48539
  },
48540
+ "keychainAdmin.acknowledgeReset": {
48541
+ capName: "keychain-admin",
48542
+ capScope: "system",
48543
+ addonId: null,
48544
+ access: "create"
48545
+ },
47109
48546
  "keychainAdmin.deleteOrphans": {
47110
48547
  capName: "keychain-admin",
47111
48548
  capScope: "system",
@@ -47142,6 +48579,12 @@ Object.freeze({
47142
48579
  addonId: null,
47143
48580
  access: "delete"
47144
48581
  },
48582
+ "keychainAdmin.resetReport": {
48583
+ capName: "keychain-admin",
48584
+ capScope: "system",
48585
+ addonId: null,
48586
+ access: "delete"
48587
+ },
47145
48588
  "keychainAdmin.reveal": {
47146
48589
  capName: "keychain-admin",
47147
48590
  capScope: "system",
@@ -47154,6 +48597,12 @@ Object.freeze({
47154
48597
  addonId: null,
47155
48598
  access: "create"
47156
48599
  },
48600
+ "keychainAdmin.setSystemSecret": {
48601
+ capName: "keychain-admin",
48602
+ capScope: "system",
48603
+ addonId: null,
48604
+ access: "create"
48605
+ },
47157
48606
  "keychainAdmin.status": {
47158
48607
  capName: "keychain-admin",
47159
48608
  capScope: "system",
@@ -48600,6 +50049,12 @@ Object.freeze({
48600
50049
  addonId: null,
48601
50050
  access: "create"
48602
50051
  },
50052
+ "pipelineAnalytics.createRetrainDatasetVersion": {
50053
+ capName: "pipeline-analytics",
50054
+ capScope: "device",
50055
+ addonId: null,
50056
+ access: "create"
50057
+ },
48603
50058
  "pipelineAnalytics.deleteDeviceEvents": {
48604
50059
  capName: "pipeline-analytics",
48605
50060
  capScope: "device",
@@ -48612,6 +50067,12 @@ Object.freeze({
48612
50067
  addonId: null,
48613
50068
  access: "delete"
48614
50069
  },
50070
+ "pipelineAnalytics.deleteRetrainDatasetVersion": {
50071
+ capName: "pipeline-analytics",
50072
+ capScope: "device",
50073
+ addonId: null,
50074
+ access: "delete"
50075
+ },
48615
50076
  "pipelineAnalytics.deleteTracks": {
48616
50077
  capName: "pipeline-analytics",
48617
50078
  capScope: "device",
@@ -48834,6 +50295,12 @@ Object.freeze({
48834
50295
  addonId: null,
48835
50296
  access: "view"
48836
50297
  },
50298
+ "pipelineAnalytics.listRetrainDatasetVersions": {
50299
+ capName: "pipeline-analytics",
50300
+ capScope: "device",
50301
+ addonId: null,
50302
+ access: "view"
50303
+ },
48837
50304
  "pipelineAnalytics.listRetrainFrames": {
48838
50305
  capName: "pipeline-analytics",
48839
50306
  capScope: "device",
@@ -48864,6 +50331,12 @@ Object.freeze({
48864
50331
  addonId: null,
48865
50332
  access: "view"
48866
50333
  },
50334
+ "pipelineAnalytics.offerRetrainArchive": {
50335
+ capName: "pipeline-analytics",
50336
+ capScope: "device",
50337
+ addonId: null,
50338
+ access: "create"
50339
+ },
48867
50340
  "pipelineAnalytics.ownersWithMedia": {
48868
50341
  capName: "pipeline-analytics",
48869
50342
  capScope: "device",
@@ -48876,6 +50349,12 @@ Object.freeze({
48876
50349
  addonId: null,
48877
50350
  access: "create"
48878
50351
  },
50352
+ "pipelineAnalytics.previewRetrainDataset": {
50353
+ capName: "pipeline-analytics",
50354
+ capScope: "device",
50355
+ addonId: null,
50356
+ access: "view"
50357
+ },
48879
50358
  "pipelineAnalytics.proposeRetrainAnnotations": {
48880
50359
  capName: "pipeline-analytics",
48881
50360
  capScope: "device",
@@ -49014,6 +50493,12 @@ Object.freeze({
49014
50493
  addonId: null,
49015
50494
  access: "create"
49016
50495
  },
50496
+ "pipelineAnalytics.verifyRetrainDatasetVersion": {
50497
+ capName: "pipeline-analytics",
50498
+ capScope: "device",
50499
+ addonId: null,
50500
+ access: "view"
50501
+ },
49017
50502
  "pipelineAnalytics.wipeAllAnalytics": {
49018
50503
  capName: "pipeline-analytics",
49019
50504
  capScope: "device",
@@ -51390,6 +52875,174 @@ Object.freeze({
51390
52875
  addonId: null,
51391
52876
  access: "view"
51392
52877
  },
52878
+ "training.canaryResult": {
52879
+ capName: "training",
52880
+ capScope: "system",
52881
+ addonId: null,
52882
+ access: "create"
52883
+ },
52884
+ "training.cancelJob": {
52885
+ capName: "training",
52886
+ capScope: "system",
52887
+ addonId: null,
52888
+ access: "create"
52889
+ },
52890
+ "training.discardResult": {
52891
+ capName: "training",
52892
+ capScope: "system",
52893
+ addonId: null,
52894
+ access: "create"
52895
+ },
52896
+ "training.findDatasetVersionIdByName": {
52897
+ capName: "training",
52898
+ capScope: "system",
52899
+ addonId: null,
52900
+ access: "view"
52901
+ },
52902
+ "training.getDatasetVersion": {
52903
+ capName: "training",
52904
+ capScope: "system",
52905
+ addonId: null,
52906
+ access: "view"
52907
+ },
52908
+ "training.getJob": {
52909
+ capName: "training",
52910
+ capScope: "system",
52911
+ addonId: null,
52912
+ access: "view"
52913
+ },
52914
+ "training.getJobResult": {
52915
+ capName: "training",
52916
+ capScope: "system",
52917
+ addonId: null,
52918
+ access: "view"
52919
+ },
52920
+ "training.listBaseModels": {
52921
+ capName: "training",
52922
+ capScope: "system",
52923
+ addonId: null,
52924
+ access: "view"
52925
+ },
52926
+ "training.listDatasetVersions": {
52927
+ capName: "training",
52928
+ capScope: "system",
52929
+ addonId: null,
52930
+ access: "view"
52931
+ },
52932
+ "training.listJobs": {
52933
+ capName: "training",
52934
+ capScope: "system",
52935
+ addonId: null,
52936
+ access: "view"
52937
+ },
52938
+ "training.planJob": {
52939
+ capName: "training",
52940
+ capScope: "system",
52941
+ addonId: null,
52942
+ access: "view"
52943
+ },
52944
+ "training.putDatasetVersion": {
52945
+ capName: "training",
52946
+ capScope: "system",
52947
+ addonId: null,
52948
+ access: "create"
52949
+ },
52950
+ "training.registerResult": {
52951
+ capName: "training",
52952
+ capScope: "system",
52953
+ addonId: null,
52954
+ access: "create"
52955
+ },
52956
+ "training.removeDatasetVersion": {
52957
+ capName: "training",
52958
+ capScope: "system",
52959
+ addonId: null,
52960
+ access: "delete"
52961
+ },
52962
+ "training.rollbackCanary": {
52963
+ capName: "training",
52964
+ capScope: "system",
52965
+ addonId: null,
52966
+ access: "create"
52967
+ },
52968
+ "training.startJob": {
52969
+ capName: "training",
52970
+ capScope: "system",
52971
+ addonId: null,
52972
+ access: "create"
52973
+ },
52974
+ "trainingProvider.cancelJob": {
52975
+ capName: "training-provider",
52976
+ capScope: "system",
52977
+ addonId: null,
52978
+ access: "create"
52979
+ },
52980
+ "trainingProvider.cleanupJob": {
52981
+ capName: "training-provider",
52982
+ capScope: "system",
52983
+ addonId: null,
52984
+ access: "create"
52985
+ },
52986
+ "trainingProvider.describe": {
52987
+ capName: "training-provider",
52988
+ capScope: "system",
52989
+ addonId: null,
52990
+ access: "view"
52991
+ },
52992
+ "trainingProvider.estimateJob": {
52993
+ capName: "training-provider",
52994
+ capScope: "system",
52995
+ addonId: null,
52996
+ access: "view"
52997
+ },
52998
+ "trainingProvider.getJob": {
52999
+ capName: "training-provider",
53000
+ capScope: "system",
53001
+ addonId: null,
53002
+ access: "view"
53003
+ },
53004
+ "trainingProvider.listJobEvents": {
53005
+ capName: "training-provider",
53006
+ capScope: "system",
53007
+ addonId: null,
53008
+ access: "view"
53009
+ },
53010
+ "trainingProvider.listJobs": {
53011
+ capName: "training-provider",
53012
+ capScope: "system",
53013
+ addonId: null,
53014
+ access: "view"
53015
+ },
53016
+ "trainingProvider.offerArtifact": {
53017
+ capName: "training-provider",
53018
+ capScope: "system",
53019
+ addonId: null,
53020
+ access: "create"
53021
+ },
53022
+ "trainingProvider.readResult": {
53023
+ capName: "training-provider",
53024
+ capScope: "system",
53025
+ addonId: null,
53026
+ access: "create"
53027
+ },
53028
+ "trainingProvider.submitJob": {
53029
+ capName: "training-provider",
53030
+ capScope: "system",
53031
+ addonId: null,
53032
+ access: "create"
53033
+ },
53034
+ "trainingProvider.uploadDataset": {
53035
+ capName: "training-provider",
53036
+ capScope: "system",
53037
+ addonId: null,
53038
+ access: "create"
53039
+ },
53040
+ "trainingProvider.validateCredentials": {
53041
+ capName: "training-provider",
53042
+ capScope: "system",
53043
+ addonId: null,
53044
+ access: "create"
53045
+ },
51393
53046
  "turnProvider.getTurnServers": {
51394
53047
  capName: "turn-provider",
51395
53048
  capScope: "system",
@@ -51414,12 +53067,6 @@ Object.freeze({
51414
53067
  addonId: null,
51415
53068
  access: "create"
51416
53069
  },
51417
- "userManagement.createApiKey": {
51418
- capName: "user-management",
51419
- capScope: "system",
51420
- addonId: null,
51421
- access: "create"
51422
- },
51423
53070
  "userManagement.createScopedToken": {
51424
53071
  capName: "user-management",
51425
53072
  capScope: "system",
@@ -51456,12 +53103,6 @@ Object.freeze({
51456
53103
  addonId: null,
51457
53104
  access: "view"
51458
53105
  },
51459
- "userManagement.linkExternalIdentity": {
51460
- capName: "user-management",
51461
- capScope: "system",
51462
- addonId: null,
51463
- access: "create"
51464
- },
51465
53106
  "userManagement.listApiKeys": {
51466
53107
  capName: "user-management",
51467
53108
  capScope: "system",
@@ -51564,12 +53205,6 @@ Object.freeze({
51564
53205
  addonId: null,
51565
53206
  access: "create"
51566
53207
  },
51567
- "userManagement.validateApiKey": {
51568
- capName: "user-management",
51569
- capScope: "system",
51570
- addonId: null,
51571
- access: "view"
51572
- },
51573
53208
  "userManagement.validateCredentials": {
51574
53209
  capName: "user-management",
51575
53210
  capScope: "system",
@@ -55901,6 +57536,11 @@ Object.freeze({
55901
57536
  form: "single",
55902
57537
  optional: false
55903
57538
  }],
57539
+ "training.canaryResult": [{
57540
+ name: "deviceIds",
57541
+ form: "array",
57542
+ optional: false
57543
+ }],
55904
57544
  "update.getStatus": [{
55905
57545
  name: "deviceId",
55906
57546
  form: "single",