@camstack/addon-provider-amcrest 0.2.133 → 0.2.134

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
@@ -5391,7 +5391,7 @@ var ZodIssueCode = {
5391
5391
  var ZodFirstPartyTypeKind;
5392
5392
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
5393
5393
  //#endregion
5394
- //#region ../types/dist/sleep-Cr5YOk3m.mjs
5394
+ //#region ../types/dist/sleep-r3RWkGVx.mjs
5395
5395
  /**
5396
5396
  * The audio chunk plane's byte format, and the ONE expansion from a coded
5397
5397
  * window to float samples (D455).
@@ -5508,7 +5508,7 @@ function isKeychainStoredField(field) {
5508
5508
  var SECRET_CLEAR = { $secretClear: true };
5509
5509
  /** The `'***'` token D634 redaction writes for non-admins. */
5510
5510
  var LEGACY_DEVICE_REDACTION = "***";
5511
- function isRecord$1$1(value) {
5511
+ function isRecord$2(value) {
5512
5512
  return typeof value === "object" && value !== null && !Array.isArray(value);
5513
5513
  }
5514
5514
  function makeSecretMarker(ref) {
@@ -5519,12 +5519,12 @@ function makeSecretMarker(ref) {
5519
5519
  }
5520
5520
  /** A stored marker: an object whose `$secret` is a non-empty string. */
5521
5521
  function isSecretMarker(value) {
5522
- if (!isRecord$1$1(value)) return false;
5522
+ if (!isRecord$2(value)) return false;
5523
5523
  const ref = value["$secret"];
5524
5524
  return typeof ref === "string" && ref.length > 0;
5525
5525
  }
5526
5526
  function isSecretClear(value) {
5527
- return isRecord$1$1(value) && value["$secretClear"] === true;
5527
+ return isRecord$2(value) && value["$secretClear"] === true;
5528
5528
  }
5529
5529
  /**
5530
5530
  * The UI view of a stored secret field value: a marker becomes "set", inline
@@ -6040,6 +6040,13 @@ function globalSecretScope() {
6040
6040
  function encodeSegment(value) {
6041
6041
  return encodeURIComponent(value);
6042
6042
  }
6043
+ function decodeSegment(value) {
6044
+ try {
6045
+ return decodeURIComponent(value);
6046
+ } catch {
6047
+ return null;
6048
+ }
6049
+ }
6043
6050
  /**
6044
6051
  * The field path of a value inside an array item, addressed by the item's id:
6045
6052
  * `arrayItemFieldPath('providers', 'authentik', 'clientSecret')` →
@@ -6048,6 +6055,75 @@ function encodeSegment(value) {
6048
6055
  function arrayItemFieldPath(arrayKey, itemId, fieldKey) {
6049
6056
  return `${arrayKey}[${encodeSegment(itemId)}].${fieldKey}`;
6050
6057
  }
6058
+ function parseScope(segments) {
6059
+ switch (segments[0]) {
6060
+ case "global": return {
6061
+ scope: GLOBAL_SCOPE,
6062
+ used: 1
6063
+ };
6064
+ case "node": {
6065
+ const nodeId = segments[1] !== void 0 ? decodeSegment(segments[1]) : null;
6066
+ return nodeId === null || nodeId.length === 0 ? null : {
6067
+ scope: {
6068
+ kind: "node",
6069
+ nodeId
6070
+ },
6071
+ used: 2
6072
+ };
6073
+ }
6074
+ case "device": {
6075
+ const raw = segments[1];
6076
+ if (raw === void 0 || !/^\d+$/.test(raw)) return null;
6077
+ return {
6078
+ scope: {
6079
+ kind: "device",
6080
+ deviceId: Number(raw)
6081
+ },
6082
+ used: 2
6083
+ };
6084
+ }
6085
+ case "integration": {
6086
+ const id = segments[1] !== void 0 ? decodeSegment(segments[1]) : null;
6087
+ return id === null || id.length === 0 ? null : {
6088
+ scope: {
6089
+ kind: "integration",
6090
+ integrationId: id
6091
+ },
6092
+ used: 2
6093
+ };
6094
+ }
6095
+ case "row": {
6096
+ const collection = segments[1] !== void 0 ? decodeSegment(segments[1]) : null;
6097
+ const rowId = segments[2] !== void 0 ? decodeSegment(segments[2]) : null;
6098
+ if (collection === null || rowId === null || collection.length === 0 || rowId.length === 0) return null;
6099
+ return {
6100
+ scope: {
6101
+ kind: "row",
6102
+ collection,
6103
+ rowId
6104
+ },
6105
+ used: 3
6106
+ };
6107
+ }
6108
+ default: return null;
6109
+ }
6110
+ }
6111
+ /** Take a ref apart; `null` when it is not a well-formed ref. */
6112
+ function parseSecretRef(ref) {
6113
+ if (!ref.startsWith("secret://")) return null;
6114
+ const segments = ref.slice(9).split("/");
6115
+ const owner = segments[0] !== void 0 ? decodeSegment(segments[0]) : null;
6116
+ if (owner === null || owner.length === 0) return null;
6117
+ const parsed = parseScope(segments.slice(1));
6118
+ if (parsed === null) return null;
6119
+ const fieldPath = segments.slice(1 + parsed.used).join("/");
6120
+ if (fieldPath.length === 0) return null;
6121
+ return {
6122
+ owner,
6123
+ scope: parsed.scope,
6124
+ fieldPath
6125
+ };
6126
+ }
6051
6127
  /** A write to a secret path could not be stored in the keychain, so it was refused. */
6052
6128
  var KeychainWriteRefusedError = class extends Error {
6053
6129
  fieldPath;
@@ -6058,7 +6134,7 @@ var KeychainWriteRefusedError = class extends Error {
6058
6134
  }
6059
6135
  };
6060
6136
  var KEEP = { kind: "keep" };
6061
- function isRecord$2(value) {
6137
+ function isRecord$1$1(value) {
6062
6138
  return typeof value === "object" && value !== null && !Array.isArray(value);
6063
6139
  }
6064
6140
  function defaultMintId() {
@@ -6071,7 +6147,7 @@ function collectSecretMarkerRefs(value, out = []) {
6071
6147
  return out;
6072
6148
  }
6073
6149
  if (Array.isArray(value)) for (const item of value) collectSecretMarkerRefs(item, out);
6074
- else if (isRecord$2(value)) for (const child of Object.values(value)) collectSecretMarkerRefs(child, out);
6150
+ else if (isRecord$1$1(value)) for (const child of Object.values(value)) collectSecretMarkerRefs(child, out);
6075
6151
  return out;
6076
6152
  }
6077
6153
  async function storedValueEquals(secrets, marker, candidate) {
@@ -6126,7 +6202,7 @@ function rowId(row, idKey) {
6126
6202
  return null;
6127
6203
  }
6128
6204
  async function writeArray(ctx, node, incoming, stored, fieldPath) {
6129
- const storedRows = Array.isArray(stored) ? stored.filter(isRecord$2) : [];
6205
+ const storedRows = Array.isArray(stored) ? stored.filter(isRecord$1$1) : [];
6130
6206
  if (!Array.isArray(incoming)) {
6131
6207
  ctx.deletes.push(...collectSecretMarkerRefs(storedRows));
6132
6208
  return {
@@ -6142,7 +6218,7 @@ async function writeArray(ctx, node, incoming, stored, fieldPath) {
6142
6218
  const kept = /* @__PURE__ */ new Set();
6143
6219
  const rows = [];
6144
6220
  for (const row of incoming) {
6145
- if (!isRecord$2(row)) {
6221
+ if (!isRecord$1$1(row)) {
6146
6222
  rows.push(row);
6147
6223
  continue;
6148
6224
  }
@@ -6167,7 +6243,7 @@ async function writeNode(ctx, node, incoming, stored, fieldPath) {
6167
6243
  case "leaf": return writeLeaf(ctx, incoming, stored, fieldPath);
6168
6244
  case "array": return writeArray(ctx, node, incoming, stored, fieldPath);
6169
6245
  case "object": {
6170
- if (!isRecord$2(incoming)) {
6246
+ if (!isRecord$1$1(incoming)) {
6171
6247
  if (incoming === void 0) return KEEP;
6172
6248
  ctx.deletes.push(...collectSecretMarkerRefs(stored));
6173
6249
  return {
@@ -6175,7 +6251,7 @@ async function writeNode(ctx, node, incoming, stored, fieldPath) {
6175
6251
  value: incoming
6176
6252
  };
6177
6253
  }
6178
- const storedObj = isRecord$2(stored) ? stored : {};
6254
+ const storedObj = isRecord$1$1(stored) ? stored : {};
6179
6255
  return {
6180
6256
  kind: "value",
6181
6257
  value: await writeMembers(ctx, node.children, incoming, storedObj, (m) => `${fieldPath}.${m}`)
@@ -6234,12 +6310,19 @@ async function transformSecretWrite(input) {
6234
6310
  }
6235
6311
  };
6236
6312
  }
6313
+ /** Is `ref` one of `owner`'s refs? */
6314
+ function isSecretRefOwnedBy(ref, owner) {
6315
+ return parseSecretRef(ref)?.owner === owner;
6316
+ }
6237
6317
  /**
6238
6318
  * Replace every marker in `value` with its keychain value. Returns the SAME
6239
6319
  * reference when there is no marker (no allocation, no keychain call).
6240
6320
  */
6241
- async function resolveSecretMarkers(value, secrets) {
6242
- const refs = collectSecretMarkerRefs(value);
6321
+ async function resolveSecretMarkers(value, secrets, options = {}) {
6322
+ const keepMarker = options.unresolved === "keep-marker";
6323
+ const owner = options.ownedBy;
6324
+ const inScope = (ref) => owner === void 0 || isSecretRefOwnedBy(ref, owner);
6325
+ const refs = collectSecretMarkerRefs(value).filter(inScope);
6243
6326
  if (refs.length === 0) return {
6244
6327
  value,
6245
6328
  unresolved: []
@@ -6263,10 +6346,18 @@ async function resolveSecretMarkers(value, secrets) {
6263
6346
  }
6264
6347
  const substitute = (v) => {
6265
6348
  if (isSecretMarker(v)) {
6349
+ if (!inScope(v.$secret)) return {
6350
+ keep: true,
6351
+ value: v
6352
+ };
6266
6353
  const answer = answers[v.$secret];
6267
- return answer?.kind === "value" ? {
6354
+ if (answer?.kind === "value") return {
6268
6355
  keep: true,
6269
6356
  value: answer.value
6357
+ };
6358
+ return keepMarker ? {
6359
+ keep: true,
6360
+ value: v
6270
6361
  } : {
6271
6362
  keep: false,
6272
6363
  value: void 0
@@ -6283,7 +6374,7 @@ async function resolveSecretMarkers(value, secrets) {
6283
6374
  value: items
6284
6375
  };
6285
6376
  }
6286
- if (isRecord$2(v)) {
6377
+ if (isRecord$1$1(v)) {
6287
6378
  const out = {};
6288
6379
  for (const [k, child] of Object.entries(v)) {
6289
6380
  const s = substitute(child);
@@ -6304,14 +6395,152 @@ async function resolveSecretMarkers(value, secrets) {
6304
6395
  unresolved
6305
6396
  };
6306
6397
  }
6307
- function touchesTree(tree, patch) {
6308
- if (tree.size === 0) return false;
6309
- for (const key of Object.keys(patch)) {
6310
- const at = key.indexOf("@");
6311
- if (tree.has(at > 0 ? key.slice(0, at) : key)) return true;
6398
+ /** An addon tried to replace a stored secret it could not read. Nothing was written. */
6399
+ var SecretOverwriteRefusedError = class extends Error {
6400
+ ref;
6401
+ reason;
6402
+ constructor(ref, reason) {
6403
+ 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.`);
6404
+ this.ref = ref;
6405
+ this.reason = reason;
6406
+ this.name = "SecretOverwriteRefusedError";
6407
+ }
6408
+ };
6409
+ function isRecord$3(value) {
6410
+ return typeof value === "object" && value !== null && !Array.isArray(value);
6411
+ }
6412
+ function resolvedValue(pass, marker) {
6413
+ const answer = pass.answers[marker.$secret];
6414
+ return answer?.kind === "value" ? answer.value : null;
6415
+ }
6416
+ async function atMarker(pass, incoming, stored) {
6417
+ if (incoming === null) return stored;
6418
+ if (typeof incoming !== "string") return incoming;
6419
+ if (incoming === resolvedValue(pass, stored)) return stored;
6420
+ const intent = classifySecretWrite(incoming);
6421
+ if (intent.kind !== "set") return stored;
6422
+ const ref = stored.$secret;
6423
+ if (!isSecretRefOwnedBy(ref, pass.secrets.owner)) return incoming;
6424
+ const answer = pass.answers[ref];
6425
+ 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);
6426
+ try {
6427
+ await pass.secrets.put(ref, intent.value);
6428
+ } catch (err) {
6429
+ throw new KeychainWriteRefusedError(ref, err);
6430
+ }
6431
+ pass.changedRefs.push(ref);
6432
+ return stored;
6433
+ }
6434
+ function inArray(pass, incoming, stored) {
6435
+ return incoming.map((item, index) => {
6436
+ const twin = stored[index];
6437
+ if (isSecretMarker(twin)) return typeof item === "string" && item === resolvedValue(pass, twin) ? twin : item;
6438
+ if (isRecord$3(item) && isRecord$3(twin)) return inArrayRow(pass, item, twin);
6439
+ if (Array.isArray(item) && Array.isArray(twin)) return inArray(pass, item, twin);
6440
+ return item;
6441
+ });
6442
+ }
6443
+ function inArrayRow(pass, incoming, stored) {
6444
+ const out = { ...incoming };
6445
+ for (const [key, value] of Object.entries(incoming)) {
6446
+ const twin = stored[key];
6447
+ if (isSecretMarker(twin)) {
6448
+ if (typeof value === "string" && value === resolvedValue(pass, twin)) out[key] = twin;
6449
+ } else if (isRecord$3(value) && isRecord$3(twin)) out[key] = inArrayRow(pass, value, twin);
6450
+ else if (Array.isArray(value) && Array.isArray(twin)) out[key] = inArray(pass, value, twin);
6451
+ }
6452
+ return out;
6453
+ }
6454
+ async function walk(pass, incoming, stored) {
6455
+ if (isSecretMarker(stored)) return atMarker(pass, incoming, stored);
6456
+ if (Array.isArray(incoming) && Array.isArray(stored)) return inArray(pass, incoming, stored);
6457
+ if (!isRecord$3(incoming) || !isRecord$3(stored)) return incoming;
6458
+ const out = { ...incoming };
6459
+ for (const [key, value] of Object.entries(incoming)) out[key] = await walk(pass, value, stored[key]);
6460
+ return out;
6461
+ }
6462
+ /** Restore markers a write-back carries as values. See the file doc. */
6463
+ async function restoreUnchangedSecrets(input) {
6464
+ const refs = [];
6465
+ for (const key of Object.keys(input.patch)) collectSecretMarkerRefs(input.stored[key], refs);
6466
+ const owned = refs.filter((ref) => isSecretRefOwnedBy(ref, input.secrets.owner));
6467
+ if (owned.length === 0) return {
6468
+ patch: input.patch,
6469
+ changedRefs: []
6470
+ };
6471
+ const pass = {
6472
+ secrets: input.secrets,
6473
+ answers: await input.secrets.resolve([...new Set(owned)]),
6474
+ operatorWrite: input.operatorWrite,
6475
+ changedRefs: []
6476
+ };
6477
+ const out = {};
6478
+ for (const [key, value] of Object.entries(input.patch)) out[key] = await walk(pass, value, input.stored[key]);
6479
+ return {
6480
+ patch: out,
6481
+ changedRefs: pass.changedRefs
6482
+ };
6483
+ }
6484
+ /** Structural equality over JSON-shaped values (key order does not matter). */
6485
+ function isJsonEqual(a, b) {
6486
+ if (Object.is(a, b)) return true;
6487
+ if (Array.isArray(a)) return Array.isArray(b) && a.length === b.length && a.every((v, i) => isJsonEqual(v, b[i]));
6488
+ if (isRecord$3(a) && isRecord$3(b)) {
6489
+ const keys = Object.keys(a);
6490
+ if (keys.length !== Object.keys(b).length) return false;
6491
+ return keys.every((k) => Object.prototype.hasOwnProperty.call(b, k) && isJsonEqual(a[k], b[k]));
6312
6492
  }
6313
6493
  return false;
6314
6494
  }
6495
+ /** The patch without the keys whose value already equals the stored one. */
6496
+ function dropUnchangedKeys(patch, stored) {
6497
+ const out = {};
6498
+ for (const [key, value] of Object.entries(patch)) {
6499
+ if (Object.prototype.hasOwnProperty.call(stored, key) && isJsonEqual(value, stored[key])) continue;
6500
+ out[key] = value;
6501
+ }
6502
+ return out;
6503
+ }
6504
+ /** The top-level keys of a blob that hold at least one of `owner`'s markers. */
6505
+ function markerKeysOf(blob, owner) {
6506
+ const keys = /* @__PURE__ */ new Set();
6507
+ for (const [key, value] of Object.entries(blob)) if (collectSecretMarkerRefs(value).some((ref) => isSecretRefOwnedBy(ref, owner))) keys.add(key);
6508
+ return keys;
6509
+ }
6510
+ function nodeFromStored(value, owner) {
6511
+ if (isSecretMarker(value)) return isSecretRefOwnedBy(value.$secret, owner) ? { kind: "leaf" } : null;
6512
+ if (!isRecord$3(value)) return null;
6513
+ const children = /* @__PURE__ */ new Map();
6514
+ for (const [key, child] of Object.entries(value)) {
6515
+ const node = nodeFromStored(child, owner);
6516
+ if (node !== null) children.set(key, node);
6517
+ }
6518
+ return children.size > 0 ? {
6519
+ kind: "object",
6520
+ children
6521
+ } : null;
6522
+ }
6523
+ /**
6524
+ * The declared secret tree, widened by every place the STORED blob holds a
6525
+ * marker under one of `keys` — so a marker the schema no longer declares (or
6526
+ * never declared: Wyze before b4906cec6) still gets the save path's
6527
+ * KEEP / SET / CLEAR semantics instead of being overwritten by whatever the
6528
+ * addon writes. Markers inside arrays are not added: a row has no id field to
6529
+ * match by unless the schema declares one. Only `owner`'s markers count: a
6530
+ * builtin that keeps another addon's marker (device-manager) never takes it
6531
+ * over.
6532
+ */
6533
+ function widenTreeWithStoredMarkers(declared, stored, keys, owner) {
6534
+ const added = /* @__PURE__ */ new Map();
6535
+ for (const key of keys) {
6536
+ const at = key.indexOf("@");
6537
+ const base = at > 0 ? key.slice(0, at) : key;
6538
+ if (declared.has(base) || added.has(base)) continue;
6539
+ const node = nodeFromStored(stored[key], owner);
6540
+ if (node !== null) added.set(base, node);
6541
+ }
6542
+ return added.size === 0 ? declared : new Map([...declared, ...added]);
6543
+ }
6315
6544
  /** The blob as stored now; a failed read REFUSES the write instead of guessing. */
6316
6545
  async function readStoredAddonBlob(raw) {
6317
6546
  const threeWay = raw.readAddonStoreResult;
@@ -6320,7 +6549,41 @@ async function readStoredAddonBlob(raw) {
6320
6549
  if (result.kind === "failed") throw new Error(`settings write refused: the stored blob could not be read (${result.error})`);
6321
6550
  return result.kind === "missing" ? {} : result.value;
6322
6551
  }
6323
- function createSecretAwareSettings(raw, opts) {
6552
+ function touchesTree(tree, patch) {
6553
+ if (tree.size === 0) return false;
6554
+ for (const key of Object.keys(patch)) {
6555
+ const at = key.indexOf("@");
6556
+ if (tree.has(at > 0 ? key.slice(0, at) : key)) return true;
6557
+ }
6558
+ return false;
6559
+ }
6560
+ /**
6561
+ * Which top-level keys of each store held markers when last seen. `undefined`
6562
+ * for a store not seen yet: its first write reads it, to be safe.
6563
+ */
6564
+ var MarkerKeyIndex = class {
6565
+ owner;
6566
+ byStore = /* @__PURE__ */ new Map();
6567
+ constructor(owner) {
6568
+ this.owner = owner;
6569
+ }
6570
+ seen(store, blob) {
6571
+ this.byStore.set(store, markerKeysOf(blob, this.owner));
6572
+ }
6573
+ wrote(store, patch) {
6574
+ const keys = this.byStore.get(store);
6575
+ if (keys === void 0) return;
6576
+ const now = markerKeysOf(patch, this.owner);
6577
+ for (const key of Object.keys(patch)) if (now.has(key)) keys.add(key);
6578
+ else keys.delete(key);
6579
+ }
6580
+ mayHoldMarkers(store, patch) {
6581
+ const keys = this.byStore.get(store);
6582
+ if (keys === void 0) return true;
6583
+ return Object.keys(patch).some((key) => keys.has(key));
6584
+ }
6585
+ };
6586
+ function createHandle(raw, opts) {
6324
6587
  const chains = /* @__PURE__ */ new Map();
6325
6588
  const serialize = (key, fn) => {
6326
6589
  const next = (chains.get(key) ?? Promise.resolve()).then(fn, fn);
@@ -6331,46 +6594,130 @@ function createSecretAwareSettings(raw, opts) {
6331
6594
  });
6332
6595
  return next;
6333
6596
  };
6334
- const write = async (chainKey, tree, scope, patch, readStored, rawWrite) => {
6335
- if (!touchesTree(tree, patch)) return rawWrite(patch);
6336
- return serialize(chainKey, async () => {
6597
+ const index = new MarkerKeyIndex(opts.secrets.owner);
6598
+ const resolveRead = async (store, blob) => {
6599
+ index.seen(store, blob);
6600
+ const { value, unresolved } = await resolveSecretMarkers(blob, opts.secrets, {
6601
+ unresolved: "keep-marker",
6602
+ ownedBy: opts.secrets.owner
6603
+ });
6604
+ if (unresolved.length > 0) opts.onUnresolved?.(unresolved);
6605
+ return value;
6606
+ };
6607
+ const write = async (store, declared, scope, patch, readStored, rawWrite) => {
6608
+ if (!touchesTree(declared, patch) && !index.mayHoldMarkers(store, patch)) {
6609
+ await rawWrite(patch);
6610
+ index.wrote(store, patch);
6611
+ return { changed: true };
6612
+ }
6613
+ return serialize(store, async () => {
6337
6614
  const stored = await readStored();
6615
+ index.seen(store, stored);
6616
+ const operatorWrite = opts.isOperatorWrite?.() === true;
6617
+ const restored = await restoreUnchangedSecrets({
6618
+ patch,
6619
+ stored,
6620
+ secrets: opts.secrets,
6621
+ operatorWrite
6622
+ });
6338
6623
  const result = await transformSecretWrite({
6339
- tree,
6624
+ tree: widenTreeWithStoredMarkers(declared, stored, Object.keys(restored.patch), opts.secrets.owner),
6340
6625
  secrets: opts.secrets,
6341
- patch,
6626
+ patch: restored.patch,
6342
6627
  stored,
6343
6628
  ...scope !== void 0 ? { scope } : {},
6344
- operatorWrite: opts.isOperatorWrite?.() === true
6629
+ operatorWrite
6345
6630
  });
6346
- if (Object.keys(result.patch).length > 0) await rawWrite(result.patch);
6631
+ const effective = dropUnchangedKeys(result.patch, stored);
6632
+ const wroteBlob = Object.keys(effective).length > 0;
6633
+ if (wroteBlob) {
6634
+ await rawWrite(effective);
6635
+ index.wrote(store, effective);
6636
+ }
6347
6637
  const { orphaned } = await result.afterWrite();
6348
6638
  if (orphaned.length > 0) opts.onOrphaned(orphaned);
6639
+ return { changed: wroteBlob || restored.changedRefs.length > 0 };
6349
6640
  });
6350
6641
  };
6351
- const wrapped = {
6352
- writeAddonStore: (patch) => write("addon", opts.addonTree(), void 0, patch, () => readStoredAddonBlob(raw), (p) => raw.writeAddonStore(p)),
6353
- writeDeviceStore: (deviceId, patch) => write(`device:${deviceId}`, opts.deviceTree(), {
6354
- kind: "device",
6355
- deviceId
6356
- }, patch, () => raw.readDeviceStore(deviceId), (p) => raw.writeDeviceStore(deviceId, p))
6642
+ const writeAddon = (patch) => write("addon", opts.addonTree(), void 0, patch, () => readStoredAddonBlob(raw), (p) => raw.writeAddonStore(p));
6643
+ const readAddonStoreResult = raw.readAddonStoreResult;
6644
+ const readAddonStoreKeyResult = raw.readAddonStoreKeyResult;
6645
+ const readDeviceStoreBatch = raw.readDeviceStoreBatch;
6646
+ const overrides = {
6647
+ readAddonStore: async () => resolveRead("addon", await raw.readAddonStore()),
6648
+ ...readAddonStoreResult !== void 0 ? { readAddonStoreResult: async () => {
6649
+ const result = await readAddonStoreResult.call(raw);
6650
+ return result.kind === "value" ? {
6651
+ kind: "value",
6652
+ value: await resolveRead("addon", result.value)
6653
+ } : result;
6654
+ } } : {},
6655
+ ...readAddonStoreKeyResult !== void 0 ? { readAddonStoreKeyResult: async (key) => {
6656
+ const result = await readAddonStoreKeyResult.call(raw, key);
6657
+ if (result.kind !== "present") return result;
6658
+ const { value, unresolved } = await resolveSecretMarkers({ [key]: result.value }, opts.secrets, {
6659
+ unresolved: "keep-marker",
6660
+ ownedBy: opts.secrets.owner
6661
+ });
6662
+ if (unresolved.length > 0) opts.onUnresolved?.(unresolved);
6663
+ return {
6664
+ kind: "present",
6665
+ value: value[key]
6666
+ };
6667
+ } } : {},
6668
+ readDeviceStore: async (deviceId) => resolveRead(`device:${deviceId}`, await raw.readDeviceStore(deviceId)),
6669
+ ...readDeviceStoreBatch !== void 0 ? { readDeviceStoreBatch: async (deviceIds) => {
6670
+ const rows = await readDeviceStoreBatch.call(raw, deviceIds);
6671
+ const out = /* @__PURE__ */ new Map();
6672
+ for (const [deviceId, blob] of rows) out.set(deviceId, await resolveRead(`device:${deviceId}`, blob));
6673
+ return out;
6674
+ } } : {},
6675
+ writeAddonStore: async (patch) => {
6676
+ await writeAddon(patch);
6677
+ },
6678
+ writeDeviceStore: async (deviceId, patch) => {
6679
+ await write(`device:${deviceId}`, opts.deviceTree(), {
6680
+ kind: "device",
6681
+ deviceId
6682
+ }, patch, () => raw.readDeviceStore(deviceId), (p) => raw.writeDeviceStore(deviceId, p));
6683
+ }
6684
+ };
6685
+ return {
6686
+ settings: new Proxy(raw, { get(target, prop, receiver) {
6687
+ if (typeof prop === "string" && Object.prototype.hasOwnProperty.call(overrides, prop)) return Reflect.get(overrides, prop);
6688
+ const value = Reflect.get(target, prop, receiver);
6689
+ return typeof value === "function" ? value.bind(target) : value;
6690
+ } }),
6691
+ raw: {
6692
+ readAddonStore: async () => {
6693
+ const blob = await raw.readAddonStore();
6694
+ index.seen("addon", blob);
6695
+ return blob;
6696
+ },
6697
+ readDeviceStore: async (deviceId) => {
6698
+ const blob = await raw.readDeviceStore(deviceId);
6699
+ index.seen(`device:${deviceId}`, blob);
6700
+ return blob;
6701
+ }
6702
+ },
6703
+ writeAddonStore: writeAddon
6357
6704
  };
6358
- return new Proxy(raw, { get(target, prop, receiver) {
6359
- if (prop === "writeAddonStore") return wrapped.writeAddonStore;
6360
- if (prop === "writeDeviceStore") return wrapped.writeDeviceStore;
6361
- const value = Reflect.get(target, prop, receiver);
6362
- return typeof value === "function" ? value.bind(target) : value;
6363
- } });
6364
6705
  }
6365
- /** The context the addon sees: identical, except that its settings writes are secret-aware. */
6366
- function withSecretAwareSettings(context, opts) {
6706
+ /** The context the addon sees, plus the private raw view and write outcome. */
6707
+ function createSecretAwareContext(context, opts) {
6367
6708
  const raw = context.settings;
6368
- if (raw === void 0) return context;
6369
- const settings = createSecretAwareSettings(raw, opts);
6370
- return new Proxy(context, { get(target, prop, receiver) {
6371
- if (prop === "settings") return settings;
6372
- return Reflect.get(target, prop, receiver);
6373
- } });
6709
+ if (raw === void 0) return {
6710
+ context,
6711
+ handle: null
6712
+ };
6713
+ const handle = createHandle(raw, opts);
6714
+ return {
6715
+ context: new Proxy(context, { get(target, prop, receiver) {
6716
+ if (prop === "settings") return handle.settings;
6717
+ return Reflect.get(target, prop, receiver);
6718
+ } }),
6719
+ handle
6720
+ };
6374
6721
  }
6375
6722
  var LEAF = { kind: "leaf" };
6376
6723
  var DEFAULT_ITEM_ID_KEY = "id";
@@ -6545,6 +6892,14 @@ var BaseAddon = class {
6545
6892
  _secretChangeUnsub = null;
6546
6893
  /** >0 while an OPERATOR's settings write is being applied. */
6547
6894
  _operatorWriteDepth = 0;
6895
+ /**
6896
+ * The keychain-aware settings handle (D798). Its `raw` view is the ONLY way
6897
+ * to the marker-bearing blobs and stays private to this class: the form
6898
+ * hydrate and config resolution need markers, addon code never does.
6899
+ */
6900
+ _secretSettings = null;
6901
+ /** Refs an addon-facing read could not resolve — each is logged once per process. */
6902
+ _loggedUnresolvedReads = /* @__PURE__ */ new Set();
6548
6903
  constructor(defaults) {
6549
6904
  this.defaults = defaults;
6550
6905
  this._config = { ...defaults };
@@ -6581,13 +6936,21 @@ var BaseAddon = class {
6581
6936
  }
6582
6937
  async initialize(context) {
6583
6938
  const secrets = context.secrets;
6584
- this._ctx = secrets !== void 0 ? withSecretAwareSettings(context, {
6585
- secrets,
6586
- addonTree: () => this.addonSecretTree(),
6587
- deviceTree: () => this.deviceSecretTree(),
6588
- onOrphaned: (refs) => context.logger.warn("keychain refs dropped by a settings write could not be deleted", { meta: { refs: [...refs] } }),
6589
- isOperatorWrite: () => this._operatorWriteDepth > 0
6590
- }) : context;
6939
+ if (secrets !== void 0) {
6940
+ const { context: wrapped, handle } = createSecretAwareContext(context, {
6941
+ secrets,
6942
+ addonTree: () => this.addonSecretTree(),
6943
+ deviceTree: () => this.deviceSecretTree(),
6944
+ onOrphaned: (refs) => context.logger.warn("keychain refs dropped by a settings write could not be deleted", { meta: { refs: [...refs] } }),
6945
+ isOperatorWrite: () => this._operatorWriteDepth > 0,
6946
+ onUnresolved: (unresolved) => this.logUnresolvedRead(unresolved)
6947
+ });
6948
+ this._ctx = wrapped;
6949
+ this._secretSettings = handle;
6950
+ } else {
6951
+ this._ctx = context;
6952
+ this._secretSettings = null;
6953
+ }
6591
6954
  await this.resolveConfig();
6592
6955
  if (secrets !== void 0) this._secretChangeUnsub = secrets.onChange((ref) => {
6593
6956
  if (this._configSecretRefs.has(ref)) this.scheduleSecretReresolve(SECRET_CHANGE_DEBOUNCE_MS);
@@ -6704,11 +7067,8 @@ var BaseAddon = class {
6704
7067
  async getGlobalSettings(overlay, cap, nodeId) {
6705
7068
  const schema = this.globalSettingsSchema(cap);
6706
7069
  if (!schema) return { sections: [] };
6707
- const projected = await this.resolveGlobalStore(nodeId, cap);
6708
- return hydrateSchema(schema, overlay ? {
6709
- ...projected,
6710
- ...overlay
6711
- } : projected, { inlineSecretsAsViews: true });
7070
+ const projected = await this.readRawProjectedStore(nodeId, cap);
7071
+ return hydrateSchema(schema, overlay ? await this.overlayKeepingMarkers(projected, overlay) : projected, { inlineSecretsAsViews: true });
6712
7072
  }
6713
7073
  /**
6714
7074
  * The integration-level view of this addon's settings: exactly the sections
@@ -6753,7 +7113,7 @@ var BaseAddon = class {
6753
7113
  });
6754
7114
  }
6755
7115
  if (sections.length === 0) return null;
6756
- const projected = await this.resolveGlobalStore(nodeId);
7116
+ const projected = await this.readRawProjectedStore(nodeId);
6757
7117
  return hydrateSchema({
6758
7118
  ...schema,
6759
7119
  sections
@@ -6770,12 +7130,50 @@ var BaseAddon = class {
6770
7130
  * the store for custom option logic (option narrowing, value snapping) to
6771
7131
  * read it per-node — never `ctx.settings.readAddonStore()` directly.
6772
7132
  * `nodeId` omitted ⇒ the local node (node-blind injection from ctx).
7133
+ *
7134
+ * Keychain values come back RESOLVED (D798): a secret reads as its value,
7135
+ * never as a `{ $secret }` marker. One the keychain cannot serve right now
7136
+ * stays a marker — "stored, unavailable" (`isSecretMarker()` is true, and it
7137
+ * is listed in {@link unresolvedSecrets}) — never `''` and never absent, so
7138
+ * it cannot be mistaken for "nothing stored, mint a new one". Writing the
7139
+ * resolved blob back is a no-op for every unchanged secret.
6773
7140
  */
6774
7141
  async resolveGlobalStore(nodeId, cap) {
6775
7142
  const raw = await this._ctx?.settings?.readAddonStore() ?? {};
7143
+ return this.projectForNode(raw, nodeId, cap);
7144
+ }
7145
+ projectForNode(store, nodeId, cap) {
6776
7146
  const keys = this.perNodeKeys(cap);
6777
7147
  const node = normalizeNodeId(nodeId ?? this._ctx?.kernel?.localNodeId);
6778
- return keys.size > 0 ? projectStore(raw, keys, node) : raw;
7148
+ return keys.size > 0 ? projectStore(store, keys, node) : store;
7149
+ }
7150
+ /** The PROJECTED store with its markers — the form hydrate only (D798). */
7151
+ async readRawProjectedStore(nodeId, cap) {
7152
+ const raw = await this.rawSettings()?.readAddonStore() ?? {};
7153
+ return this.projectForNode(raw, nodeId, cap);
7154
+ }
7155
+ /**
7156
+ * `{ ...stored, ...overlay }`, except that an overlay member equal to the
7157
+ * RESOLVED stored one keeps the stored (marker-bearing) member — so a form
7158
+ * hydrated from a resolved overlay still shows a secret as "set", never as
7159
+ * its value.
7160
+ */
7161
+ async overlayKeepingMarkers(stored, overlay) {
7162
+ const secrets = this._ctx?.secrets;
7163
+ const merged = {
7164
+ ...stored,
7165
+ ...overlay
7166
+ };
7167
+ if (secrets === void 0 || collectSecretMarkerRefs(stored).length === 0) return merged;
7168
+ const { value: resolved } = await resolveSecretMarkers(stored, secrets, {
7169
+ unresolved: "keep-marker",
7170
+ ownedBy: secrets.owner
7171
+ });
7172
+ for (const key of Object.keys(overlay)) {
7173
+ if (collectSecretMarkerRefs(stored[key]).length === 0) continue;
7174
+ if (isJsonEqual(overlay[key], resolved[key])) merged[key] = stored[key];
7175
+ }
7176
+ return merged;
6779
7177
  }
6780
7178
  /**
6781
7179
  * Whether ONE global key of this addon's store was written, read three-way
@@ -6840,8 +7238,12 @@ var BaseAddon = class {
6840
7238
  async clearSecrets(keys, nodeId) {
6841
7239
  const tree = this.addonSecretTree();
6842
7240
  const keychain = this._ctx?.secrets !== void 0;
7241
+ const stored = keychain ? await this.readAddonStoreWithRetry() : {};
6843
7242
  const patch = {};
6844
- for (const key of keys) patch[key] = keychain && tree.has(key) ? SECRET_CLEAR : "";
7243
+ for (const key of keys) {
7244
+ const keychainStored = tree.has(key) || collectSecretMarkerRefs(stored[key]).length > 0;
7245
+ patch[key] = keychain && keychainStored ? SECRET_CLEAR : "";
7246
+ }
6845
7247
  await this.applyGlobalPatch(patch, nodeId);
6846
7248
  }
6847
7249
  async applyGlobalPatch(barePatch, nodeId) {
@@ -6849,7 +7251,11 @@ var BaseAddon = class {
6849
7251
  const localNode = normalizeNodeId(this._ctx?.kernel?.localNodeId);
6850
7252
  const target = normalizeNodeId(nodeId ?? this._ctx?.kernel?.localNodeId);
6851
7253
  const scoped = keys.size > 0 ? scopePatch(barePatch, keys, target) : barePatch;
6852
- await this._ctx?.settings?.writeAddonStore(scoped);
7254
+ const handle = this._secretSettings;
7255
+ if (handle !== null) {
7256
+ const { changed } = await handle.writeAddonStore(scoped);
7257
+ if (!changed) return;
7258
+ } else await this._ctx?.settings?.writeAddonStore(scoped);
6853
7259
  if (target !== localNode) return;
6854
7260
  await this.resolveConfig();
6855
7261
  await this.onConfigChanged();
@@ -6902,7 +7308,7 @@ var BaseAddon = class {
6902
7308
  async getDeviceSettings(deviceId) {
6903
7309
  const schema = this.deviceSettingsSchema();
6904
7310
  if (!schema) return { sections: [] };
6905
- return hydrateSchema(schema, await this._ctx?.settings?.readDeviceStore(deviceId) ?? {}, { inlineSecretsAsViews: true });
7311
+ return hydrateSchema(schema, await this.rawSettings()?.readDeviceStore(deviceId) ?? {}, { inlineSecretsAsViews: true });
6906
7312
  }
6907
7313
  async updateDeviceSettings(deviceId, patch) {
6908
7314
  await this._ctx?.settings?.writeDeviceStore(deviceId, patch);
@@ -7074,7 +7480,7 @@ var BaseAddon = class {
7074
7480
  key,
7075
7481
  schema,
7076
7482
  fallback,
7077
- read: async () => this.resolveStoredSecrets(await this._ctx?.settings?.readDeviceStore(deviceId) ?? {}, false),
7483
+ read: async () => this.resolveStoredSecrets(await this.rawSettings()?.readDeviceStore(deviceId) ?? {}, false),
7078
7484
  write: async (patch) => {
7079
7485
  await this._ctx?.settings?.writeDeviceStore(deviceId, patch);
7080
7486
  },
@@ -7136,6 +7542,23 @@ var BaseAddon = class {
7136
7542
  }
7137
7543
  return value;
7138
7544
  }
7545
+ /**
7546
+ * The marker-bearing settings reads (D798) — private on purpose. Without a
7547
+ * keychain the context's own view is already raw.
7548
+ */
7549
+ rawSettings() {
7550
+ return this._secretSettings?.raw ?? this._ctx?.settings;
7551
+ }
7552
+ /** An addon-facing read met markers it could not resolve: say so once per ref. */
7553
+ logUnresolvedRead(unresolved) {
7554
+ const fresh = unresolved.filter((u) => !this._loggedUnresolvedReads.has(u.ref));
7555
+ if (fresh.length === 0) return;
7556
+ for (const u of fresh) this._loggedUnresolvedReads.add(u.ref);
7557
+ 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) => ({
7558
+ ref: u.ref,
7559
+ reason: u.reason
7560
+ })) } });
7561
+ }
7139
7562
  /** Re-resolve the config (a keychain-only change, or a retry) and apply it. */
7140
7563
  scheduleSecretReresolve(delayMs) {
7141
7564
  const timerOf = delayMs === SECRET_CHANGE_DEBOUNCE_MS ? "_secretChangeTimer" : "_secretRetryTimer";
@@ -7162,7 +7585,7 @@ var BaseAddon = class {
7162
7585
  * `{}` (defaults) — the addon's first successful patch will rehydrate.
7163
7586
  */
7164
7587
  async readAddonStoreWithRetry() {
7165
- const settings = this._ctx?.settings;
7588
+ const settings = this.rawSettings();
7166
7589
  if (!settings) return {};
7167
7590
  const delaysMs = [
7168
7591
  150,
@@ -9475,6 +9898,278 @@ var CameraSwitchGroupSchema = object({
9475
9898
  fetchedAt: number()
9476
9899
  });
9477
9900
  /**
9901
+ * The trainer contract — what the hub hands the cloud trainer and what it
9902
+ * gets back (cloud training, D805+).
9903
+ *
9904
+ * The trainer (`hf/camstack-trainer`, published as the Hugging Face repo
9905
+ * `camstack/camstack-trainer`) is a separate AGPL program the hub never
9906
+ * imports: `job.json` goes in, files come out, and progress is `CAMSTACK_EVENT`
9907
+ * lines on stdout. These schemas are the hub's half of that boundary; the
9908
+ * trainer's pydantic models (and the JSON Schemas generated from them under
9909
+ * `hf/camstack-trainer/schemas/`) are the other half. A change here is a
9910
+ * change there, in the same piece of work.
9911
+ *
9912
+ * No `.default()` anywhere: defaults do not run on the addon cap path, so the
9913
+ * orchestrator fills every field of a job spec explicitly.
9914
+ */
9915
+ var TRAINING_JOB_SCHEMA = "camstack.training/v1";
9916
+ var TRAINING_RESULT_SCHEMA = "camstack.training-result/v1";
9917
+ /** What the trainer can export. Edge TPU is a later, separate image. */
9918
+ var TrainingExportSchema = _enum([
9919
+ "onnx",
9920
+ "openvino-fp16",
9921
+ "openvino-int8",
9922
+ "coreml-fp16"
9923
+ ]);
9924
+ var FloorsSchema = record(string(), number().min(0).max(1));
9925
+ object({
9926
+ schema: literal(TRAINING_JOB_SCHEMA),
9927
+ jobKey: string().uuid(),
9928
+ target: object({
9929
+ kind: literal("detector"),
9930
+ step: literal("object-detection")
9931
+ }),
9932
+ base: object({
9933
+ modelId: string().min(1),
9934
+ /** Ultralytics weights id, e.g. `yolov9m.pt`. */
9935
+ weights: string().min(1),
9936
+ imgsz: number().int().positive()
9937
+ }),
9938
+ baseline: object({
9939
+ modelId: string().min(1),
9940
+ /** The baseline ONNX the holdout comparison runs; public mirror URL. */
9941
+ onnxUrl: string().url(),
9942
+ imgsz: number().int().positive(),
9943
+ floors: FloorsSchema
9944
+ }),
9945
+ dataset: object({
9946
+ versionId: string().min(1),
9947
+ annotationHash: string(),
9948
+ /** sha256 of the uploaded archive; the trainer refuses a mismatch (exit 65). */
9949
+ sha256: string().regex(/^[0-9a-f]{64}$/)
9950
+ }),
9951
+ split: object({
9952
+ holdoutCameras: array(number().int()),
9953
+ /** When no camera is held out: the last N days of every camera. */
9954
+ holdoutLastDays: number().int().nonnegative(),
9955
+ valFraction: number().min(0).max(.5),
9956
+ seed: number().int()
9957
+ }),
9958
+ hyper: object({
9959
+ epochs: number().int().positive(),
9960
+ batch: number().int().positive(),
9961
+ lr0: number().positive(),
9962
+ /** Layers frozen from the start of the backbone; 0 = none. */
9963
+ freeze: number().int().nonnegative(),
9964
+ patience: number().int().nonnegative(),
9965
+ seed: number().int()
9966
+ }),
9967
+ replay: object({
9968
+ source: literal("coco2017"),
9969
+ count: number().int().nonnegative()
9970
+ }),
9971
+ exports: array(TrainingExportSchema).min(1),
9972
+ calibration: object({ maxFrames: number().int().positive() }),
9973
+ floors: object({
9974
+ minSupport: number().int().positive(),
9975
+ clamp: number().min(0).max(1)
9976
+ }),
9977
+ int8Gate: object({ maxMap50Drop: number().min(0).max(1) }),
9978
+ catalog: object({
9979
+ id: string().regex(/^[a-z0-9][a-z0-9-]{2,80}$/),
9980
+ name: string().min(1).max(160)
9981
+ })
9982
+ });
9983
+ /** One regular file of the bundle. An mlpackage contributes one row per member. */
9984
+ var TrainingResultFileSchema = object({
9985
+ path: string().min(1),
9986
+ bytes: number().int().nonnegative(),
9987
+ sha256: string().regex(/^[0-9a-f]{64}$/),
9988
+ format: _enum([
9989
+ "onnx",
9990
+ "openvino",
9991
+ "coreml",
9992
+ "pt"
9993
+ ]),
9994
+ variant: _enum(["base", "int8"])
9995
+ });
9996
+ var DraftFormatSchema = object({
9997
+ /** RELATIVE path inside the bundle; the hub rewrites it to `camstack-local://`. */
9998
+ url: string().min(1),
9999
+ sizeMB: number().nonnegative(),
10000
+ isDirectory: boolean().optional(),
10001
+ files: array(string()).optional(),
10002
+ runtimes: array(literal("python")).optional(),
10003
+ revision: string().min(1)
10004
+ });
10005
+ /** The trainer's half of a catalog entry; the hub completes it (labels, licence, group). */
10006
+ var TrainingCatalogDraftSchema = object({
10007
+ id: string().min(1),
10008
+ name: string().min(1),
10009
+ description: string(),
10010
+ labels: array(unknown()),
10011
+ inputSize: object({
10012
+ width: number().int().positive(),
10013
+ height: number().int().positive()
10014
+ }),
10015
+ preprocessMode: literal("letterbox"),
10016
+ defaultClassFloors: FloorsSchema,
10017
+ formats: object({
10018
+ onnx: DraftFormatSchema.optional(),
10019
+ openvino: DraftFormatSchema.optional(),
10020
+ coreml: DraftFormatSchema.optional()
10021
+ })
10022
+ });
10023
+ /** One class of one model's holdout report (the eval harness's summary). */
10024
+ var TrainingEvalClassSchema = object({
10025
+ positives: number().int(),
10026
+ floor: number().nullable(),
10027
+ tp: number().int(),
10028
+ fp: number().int(),
10029
+ fn: number().int(),
10030
+ precision: number().nullable(),
10031
+ recall: number().nullable(),
10032
+ ap50: number().nullable(),
10033
+ recallByCamera: record(string(), number().nullable()).optional(),
10034
+ recallByLight: record(string(), number().nullable()).optional(),
10035
+ fpByCamera: record(string(), number()).optional(),
10036
+ smallFound: number().int().optional(),
10037
+ smallTotal: number().int().optional()
10038
+ }).passthrough();
10039
+ var TrainingEvalReportSchema = object({
10040
+ frames: number().int(),
10041
+ classes: record(string(), TrainingEvalClassSchema)
10042
+ }).passthrough();
10043
+ /**
10044
+ * A succeeded result carries every block; a failed one carries the error and
10045
+ * whatever was known by then — the other blocks are ABSENT, not null. The
10046
+ * orchestrator checks the blocks it needs before it trusts a success.
10047
+ */
10048
+ var TrainingResultSchema = object({
10049
+ schema: literal(TRAINING_RESULT_SCHEMA),
10050
+ jobKey: string(),
10051
+ status: _enum(["succeeded", "failed"]),
10052
+ error: object({
10053
+ stage: string(),
10054
+ code: string(),
10055
+ message: string()
10056
+ }).nullable(),
10057
+ trainer: object({
10058
+ version: string(),
10059
+ revision: string()
10060
+ }),
10061
+ toolchain: record(string(), string().nullable()),
10062
+ dataset: object({
10063
+ versionId: string(),
10064
+ annotationHash: string(),
10065
+ sha256: string(),
10066
+ frames: object({
10067
+ train: number().int(),
10068
+ val: number().int(),
10069
+ holdout: number().int()
10070
+ }),
10071
+ holdoutCameras: array(number().int()),
10072
+ replayImages: number().int()
10073
+ }).optional(),
10074
+ training: object({
10075
+ epochsRun: number().int(),
10076
+ bestEpoch: number().int(),
10077
+ bestMap50: number(),
10078
+ bestMap50_95: number(),
10079
+ seconds: number()
10080
+ }).optional(),
10081
+ evaluation: object({
10082
+ holdoutFrames: number().int(),
10083
+ baseline: TrainingEvalReportSchema.nullable(),
10084
+ candidate: TrainingEvalReportSchema.nullable(),
10085
+ candidateInt8: TrainingEvalReportSchema.nullable(),
10086
+ recallDeltaByCamera: record(string(), record(string(), number())).nullable(),
10087
+ map50: record(string(), number().nullable())
10088
+ }).optional(),
10089
+ floors: object({
10090
+ baseline: FloorsSchema,
10091
+ candidate: FloorsSchema,
10092
+ candidateInt8: FloorsSchema.nullable(),
10093
+ notes: array(string())
10094
+ }).optional(),
10095
+ int8: object({
10096
+ kept: boolean(),
10097
+ map50Fp16: number().nullable(),
10098
+ map50Int8: number().nullable(),
10099
+ reason: string().nullable()
10100
+ }).optional(),
10101
+ exportsDropped: array(object({
10102
+ export: string(),
10103
+ reason: string()
10104
+ })).optional(),
10105
+ files: array(TrainingResultFileSchema).optional(),
10106
+ bundle: object({
10107
+ path: literal("bundle.tar"),
10108
+ bytes: number().int().nonnegative(),
10109
+ sha256: string().regex(/^[0-9a-f]{64}$/)
10110
+ }).nullable().optional(),
10111
+ catalogDraft: object({
10112
+ base: TrainingCatalogDraftSchema,
10113
+ int8: TrainingCatalogDraftSchema.nullable()
10114
+ }).nullable().optional(),
10115
+ licence: string()
10116
+ });
10117
+ var TrainingStageSchema = _enum([
10118
+ "prepare",
10119
+ "replay",
10120
+ "train",
10121
+ "eval",
10122
+ "export",
10123
+ "package"
10124
+ ]);
10125
+ var EventBase = {
10126
+ v: literal(1),
10127
+ ts: number()
10128
+ };
10129
+ discriminatedUnion("type", [
10130
+ object({
10131
+ ...EventBase,
10132
+ type: literal("stage"),
10133
+ stage: TrainingStageSchema
10134
+ }),
10135
+ object({
10136
+ ...EventBase,
10137
+ type: literal("epoch"),
10138
+ epoch: number().int(),
10139
+ epochs: number().int(),
10140
+ boxLoss: number().nullable().optional(),
10141
+ map50: number().nullable().optional(),
10142
+ map50_95: number().nullable().optional(),
10143
+ etaSec: number().nullable().optional()
10144
+ }),
10145
+ object({
10146
+ ...EventBase,
10147
+ type: literal("metric"),
10148
+ name: string(),
10149
+ value: number()
10150
+ }),
10151
+ object({
10152
+ ...EventBase,
10153
+ type: literal("artifact"),
10154
+ path: string(),
10155
+ bytes: number(),
10156
+ sha256: string()
10157
+ }),
10158
+ object({
10159
+ ...EventBase,
10160
+ type: literal("done"),
10161
+ status: _enum(["succeeded", "failed"]),
10162
+ resultSha256: string().nullable().optional()
10163
+ }),
10164
+ object({
10165
+ ...EventBase,
10166
+ type: literal("error"),
10167
+ stage: string(),
10168
+ code: string(),
10169
+ message: string()
10170
+ })
10171
+ ]);
10172
+ /**
9478
10173
  * What the gate decided about a birth, from the CALLER's point of view.
9479
10174
  *
9480
10175
  * Deliberately not `ConfirmationVerdict`: `undecided` is not a birth decision
@@ -11802,7 +12497,9 @@ var AddonHttpRouteSchema = object({
11802
12497
  "authenticated",
11803
12498
  "admin"
11804
12499
  ]).optional(),
11805
- description: string().optional()
12500
+ description: string().optional(),
12501
+ /** The hub limits this route per client address before the handler runs. */
12502
+ rateLimit: _enum(["auth"]).optional()
11806
12503
  });
11807
12504
  /**
11808
12505
  * Cross-process route invocation envelope. The hub captures the
@@ -12507,6 +13204,37 @@ var BackupDestinationInfoSchema = object({
12507
13204
  lastError: string().optional()
12508
13205
  });
12509
13206
  /**
13207
+ * How an archive is encrypted (operator decision 2026-10-09): to a backup
13208
+ * PUBLIC key the hub holds, so only the operator's secret key opens it.
13209
+ * Absent on a plain `.tar.gz` — every archive made before encryption, or
13210
+ * with it off — which restores without a key.
13211
+ */
13212
+ var BackupArchiveEncryptionSchema = object({
13213
+ /** `x25519-hkdf-aes256gcm-stream-v1`. */
13214
+ scheme: string(),
13215
+ /** 16 hex — the backup key whose secret restores this archive. */
13216
+ keyId: string()
13217
+ });
13218
+ /**
13219
+ * The backup encryption setting. The hub keeps PUBLIC keys only: the active
13220
+ * one new archives are encrypted to, and the retired ones older archives
13221
+ * still need. The secret key is shown once, at `setupEncryption`.
13222
+ */
13223
+ var BackupEncryptionStatusSchema = object({
13224
+ enabled: boolean(),
13225
+ active: object({
13226
+ keyId: string(),
13227
+ publicKey: string(),
13228
+ createdAt: number()
13229
+ }).nullable(),
13230
+ /** Every key ever set up, newest first. */
13231
+ keys: array(object({
13232
+ keyId: string(),
13233
+ createdAt: number(),
13234
+ retiredAt: number().nullable()
13235
+ })).readonly()
13236
+ });
13237
+ /**
12510
13238
  * Per-archive entry returned by `backup.listArchives({ destinationId })`.
12511
13239
  * Same shape the destination drill-in renders. Sourced from the per-
12512
13240
  * location `manifests.json` (no per-archive tarball read required).
@@ -12518,7 +13246,9 @@ var BackupArchiveEntrySchema = object({
12518
13246
  sizeBytes: number(),
12519
13247
  label: string().optional(),
12520
13248
  /** Top-level locations included in the archive (db, addons, tls, …). */
12521
- locations: array(string()).readonly()
13249
+ locations: array(string()).readonly(),
13250
+ /** Present when the archive is encrypted; restore then needs that key. */
13251
+ encryption: BackupArchiveEncryptionSchema.optional()
12522
13252
  });
12523
13253
  var BackupEntrySchema = object({
12524
13254
  id: string(),
@@ -12527,7 +13257,8 @@ var BackupEntrySchema = object({
12527
13257
  label: string().optional(),
12528
13258
  createdAt: number(),
12529
13259
  sizeBytes: number(),
12530
- locations: array(string()).optional()
13260
+ locations: array(string()).optional(),
13261
+ encryption: BackupArchiveEncryptionSchema.optional()
12531
13262
  });
12532
13263
  var ArchiveEntrySchema = object({
12533
13264
  path: string(),
@@ -12716,10 +13447,40 @@ method(_void(), array(BackupDestinationInfoSchema).readonly(), { auth: "admin" }
12716
13447
  * this list and skips entries whose path doesn't start with
12717
13448
  * any of them.
12718
13449
  */
12719
- locations: array(string()).optional()
13450
+ locations: array(string()).optional(),
13451
+ /**
13452
+ * The backup SECRET key, for an encrypted archive (ignored for a plain
13453
+ * one). The archive is decrypted into the hub's private staging
13454
+ * before the restart; the key is not stored. A wrong or missing key
13455
+ * is refused before the archive is downloaded.
13456
+ */
13457
+ backupSecretKey: string().optional()
12720
13458
  }), _void(), {
12721
13459
  kind: "mutation",
12722
13460
  auth: "admin"
13461
+ }), method(_void(), BackupEncryptionStatusSchema, { auth: "admin" }), method(object({}), object({
13462
+ keyId: string(),
13463
+ secretKey: string(),
13464
+ publicKey: string(),
13465
+ createdAt: number(),
13466
+ replacedKeyId: string().nullable()
13467
+ }), {
13468
+ kind: "mutation",
13469
+ auth: "admin"
13470
+ }), method(object({}), object({ disabledKeyId: string().nullable() }), {
13471
+ kind: "mutation",
13472
+ auth: "admin"
13473
+ }), method(object({ backupSecretKey: string() }), object({
13474
+ valid: boolean(),
13475
+ keyId: string().nullable(),
13476
+ /** The hub knows this key (active or retired). */
13477
+ known: boolean(),
13478
+ /** It is the key new archives are encrypted to. */
13479
+ active: boolean(),
13480
+ error: string().optional()
13481
+ }), {
13482
+ kind: "mutation",
13483
+ auth: "admin"
12723
13484
  }), method(object({
12724
13485
  destinationId: string(),
12725
13486
  backupId: string()
@@ -14445,7 +15206,60 @@ var CustomModelDescriptorSchema = object({
14445
15206
  stepId: string(),
14446
15207
  entry: ModelCatalogEntrySchema
14447
15208
  });
14448
- method(_void(), array(CustomModelDescriptorSchema).readonly(), { auth: "admin" });
15209
+ /** One regular file of an imported bundle, as the producer measured it. */
15210
+ var ModelBundleFileSchema = object({
15211
+ /** Relative path inside the bundle tar; an mlpackage member is `<x>.mlpackage/<member>`. */
15212
+ path: string().min(1),
15213
+ bytes: number().int().nonnegative(),
15214
+ sha256: string().regex(/^[0-9a-f]{64}$/)
15215
+ });
15216
+ var ImportModelBundleInputSchema = object({
15217
+ /** The registry provider that keeps the model (Model Studio). */
15218
+ addonId: string(),
15219
+ stepId: string().min(1),
15220
+ /**
15221
+ * The catalog rows to register, complete, every format URL already
15222
+ * `camstack-local://<modelId>/<file>` naming a file of the bundle. One
15223
+ * bundle may carry several rows (a base and its INT8 variant).
15224
+ */
15225
+ entries: array(ModelCatalogEntrySchema).min(1).max(4),
15226
+ /** The bundle tar, offered by the producer over `ctx.peerBytes` (same host). */
15227
+ bundle: object({
15228
+ ticket: PeerBytesTicketSchema,
15229
+ bytes: number().int().positive(),
15230
+ sha256: string().regex(/^[0-9a-f]{64}$/)
15231
+ }),
15232
+ /** Every file the tar must hold; anything missing, extra or different is refused. */
15233
+ files: array(ModelBundleFileSchema).min(1).max(64),
15234
+ /** Convert missing engine formats and push the model to every agent afterwards. */
15235
+ distribute: boolean()
15236
+ });
15237
+ var ImportModelBundleResultSchema = discriminatedUnion("kind", [object({
15238
+ kind: literal("imported"),
15239
+ modelIds: array(string()).readonly(),
15240
+ distributed: array(object({
15241
+ modelId: string(),
15242
+ nodeId: string(),
15243
+ format: _enum(MODEL_FORMATS),
15244
+ ok: boolean(),
15245
+ error: string().optional()
15246
+ })).readonly()
15247
+ }), object({
15248
+ kind: literal("refused"),
15249
+ reason: _enum([
15250
+ "transfer-failed",
15251
+ "checksum-mismatch",
15252
+ "bundle-mismatch",
15253
+ "invalid-entry",
15254
+ "id-taken"
15255
+ ]),
15256
+ detail: string()
15257
+ })]);
15258
+ method(_void(), array(CustomModelDescriptorSchema).readonly(), { auth: "admin" }), method(ImportModelBundleInputSchema, ImportModelBundleResultSchema, {
15259
+ kind: "mutation",
15260
+ auth: "admin",
15261
+ timeoutMs: 30 * 6e4
15262
+ });
14449
15263
  /**
14450
15264
  * Query filter for settings-store collections.
14451
15265
  */
@@ -14924,6 +15738,35 @@ var KeychainKeySourceSchema = object({
14924
15738
  */
14925
15739
  sharesBackupWithDatabase: boolean()
14926
15740
  });
15741
+ /**
15742
+ * One keychain reset, as the Secrets page reports it until the operator
15743
+ * acknowledges it. Never a value: refs, counts and table names only.
15744
+ */
15745
+ var KeychainResetRecordSchema = object({
15746
+ id: string(),
15747
+ at: number(),
15748
+ /** `user:<id>` or {@link KEYCHAIN_RESET_TRIGGER_ACTOR}. */
15749
+ actor: string(),
15750
+ /** Why the keychain was locked when it was reset; `null` when it was not locked. */
15751
+ lockedReason: string().nullable(),
15752
+ /** Values moved into the archive table (ciphertext under the lost key). */
15753
+ archived: number().int(),
15754
+ /** `keychain:secrets-orphaned-<ts>`, or `null` when nothing was stored. */
15755
+ archivedCollection: string().nullable(),
15756
+ /**
15757
+ * `keychain:keys-orphaned-<ts>`: the wrapped data keys of the archive, kept
15758
+ * so the archive can still be opened if the lost master key turns up.
15759
+ */
15760
+ archivedKeysCollection: string().nullable(),
15761
+ /**
15762
+ * `system-settings` keys whose marker the reset cleared — the cluster
15763
+ * secret's: a marker left pointing at an archived value would refuse every
15764
+ * agent forever (D797).
15765
+ */
15766
+ clearedSettingsKeys: array(string()).readonly(),
15767
+ /** When an operator dismissed the notice on the Secrets page; `null` until then. */
15768
+ acknowledgedAt: number().nullable()
15769
+ });
14927
15770
  var KeychainStatusSchema = object({
14928
15771
  keychain: KeychainStateSchema,
14929
15772
  /** The source of the master key in use; `null` while locked. */
@@ -14941,7 +15784,9 @@ var KeychainStatusSchema = object({
14941
15784
  /** Wrapped copies of the data key under a previous master key, kept until purged. */
14942
15785
  retiredWraps: number().int(),
14943
15786
  recoveryKeyDownloadedAt: number().nullable(),
14944
- secretCount: number().int()
15787
+ secretCount: number().int(),
15788
+ /** The most recent reset, acknowledged or not; `null` when the keychain was never reset. */
15789
+ lastReset: KeychainResetRecordSchema.nullable()
14945
15790
  });
14946
15791
  /**
14947
15792
  * Whether a stored value is still pointed at by its owner's settings.
@@ -14963,17 +15808,26 @@ var KeychainAuditActionSchema = _enum([
14963
15808
  "download-recovery-key",
14964
15809
  "delete-orphans",
14965
15810
  "reset",
15811
+ "acknowledge-reset",
14966
15812
  "initialize"
14967
15813
  ]);
14968
15814
  var KeychainAuditEntrySchema = object({
14969
15815
  id: string(),
14970
15816
  at: number(),
14971
15817
  action: KeychainAuditActionSchema,
14972
- /** `addon:<id>` | `user:<id>` | `system`. */
15818
+ /** `addon:<id>` | `user:<id>` | `system` | `trigger-file`. */
14973
15819
  actor: string(),
14974
15820
  ref: string().nullable(),
14975
15821
  detail: string().nullable()
14976
15822
  });
15823
+ var KEYCHAIN_RESET_CONFIRMATION = "RESET KEYCHAIN";
15824
+ /**
15825
+ * Secrets the HUB itself holds (owner `system`) that no settings form shows:
15826
+ * `jwt-signing-key` — the session signing key (D797). It is always "in use",
15827
+ * never an orphan; it is generated on a fresh hub and replaced only through
15828
+ * {@link keychainAdminCapability.methods.setSystemSecret}.
15829
+ */
15830
+ var SystemHeldSecretNameSchema = _enum(["jwt-signing-key"]);
14977
15831
  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({
14978
15832
  value: string(),
14979
15833
  version: number().int()
@@ -14981,6 +15835,16 @@ method(object({}), KeychainStatusSchema, { auth: "admin" }), method(object({}),
14981
15835
  kind: "mutation",
14982
15836
  auth: "admin",
14983
15837
  caller: "required"
15838
+ }), method(object({
15839
+ name: SystemHeldSecretNameSchema,
15840
+ value: string().min(16)
15841
+ }), object({
15842
+ ref: string(),
15843
+ version: number().int()
15844
+ }), {
15845
+ kind: "mutation",
15846
+ auth: "admin",
15847
+ caller: "required"
14984
15848
  }), method(object({ refs: array(string().min(1)).max(1e3) }), object({
14985
15849
  deleted: array(string()).readonly(),
14986
15850
  kept: array(object({
@@ -15010,13 +15874,20 @@ method(object({}), KeychainStatusSchema, { auth: "admin" }), method(object({}),
15010
15874
  kind: "mutation",
15011
15875
  auth: "admin",
15012
15876
  caller: "required"
15013
- }), method(object({ confirm: literal("RESET KEYCHAIN") }), object({
15877
+ }), method(object({ confirm: literal(KEYCHAIN_RESET_CONFIRMATION) }), object({
15014
15878
  archivedCollection: string().nullable(),
15015
15879
  archived: number().int()
15016
15880
  }), {
15017
15881
  kind: "mutation",
15018
15882
  auth: "admin",
15019
15883
  caller: "required"
15884
+ }), method(object({}), object({
15885
+ reset: KeychainResetRecordSchema.nullable(),
15886
+ pendingReentry: array(KeychainSecretMetaSchema).readonly()
15887
+ }), { auth: "admin" }), method(object({}), object({ acknowledged: boolean() }), {
15888
+ kind: "mutation",
15889
+ auth: "admin",
15890
+ caller: "required"
15020
15891
  });
15021
15892
  method(_void(), object({
15022
15893
  id: string(),
@@ -17963,7 +18834,7 @@ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
17963
18834
  * `login-method` — collection cap through which auth addons contribute
17964
18835
  * their pre-auth login surfaces to the login page. This is the SINGLE,
17965
18836
  * generic mechanism that supersedes the dead `auth.listProviders` reader:
17966
- * every auth addon (OIDC, magic-link, WebAuthn/passkey) registers a
18837
+ * every auth addon (OIDC, WebAuthn/passkey) registers a
17967
18838
  * `login-method` provider and the PUBLIC `auth.listLoginMethods`
17968
18839
  * procedure aggregates them for the unauthenticated login page.
17969
18840
  *
@@ -17971,8 +18842,7 @@ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
17971
18842
  *
17972
18843
  * - `redirect` — a declarative button. The login page renders a generic
17973
18844
  * button that navigates to `startUrl` (an addon-owned HTTP route).
17974
- * Covers OIDC (`/addon/auth-oidc/<id>/start`) and magic-link with
17975
- * ZERO shell-side JS. A future SSO addon plugs in the same way — the
18845
+ * Covers OIDC (`/addon/auth-oidc/<id>/start`) with ZERO shell-side JS. A future SSO addon plugs in the same way — the
17976
18846
  * login page needs NO change.
17977
18847
  *
17978
18848
  * - `widget` — a Module-Federation widget the login page mounts (via
@@ -17991,8 +18861,8 @@ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
17991
18861
  * decision.
17992
18862
  *
17993
18863
  * Every contribution carries a `stage`:
17994
- * - `primary` — shown on the first credentials screen (OIDC /
17995
- * magic-link buttons; a future usernameless passkey).
18864
+ * - `primary` — shown on the first credentials screen (OIDC
18865
+ * buttons; a usernameless passkey).
17996
18866
  * - `second-factor` — shown AFTER the password leg, gated on the
17997
18867
  * returned `factors` (passkey-as-2FA today).
17998
18868
  *
@@ -18019,7 +18889,7 @@ var LoginMethodContributionSchema = discriminatedUnion("kind", [
18019
18889
  * The provider names an external identity a signed-in user can link to
18020
18890
  * their own account (D782): `auth.listLinkableProviders` /
18021
18891
  * `beginExternalLink` offer exactly the redirect methods that set this,
18022
- * whatever their id. Absent / false — a login button only (magic-link).
18892
+ * whatever their id. Absent / false — a login button only.
18023
18893
  */
18024
18894
  linkable: boolean().optional()
18025
18895
  }),
@@ -21874,8 +22744,7 @@ method(object({}), object({ rules: array(NcRuleSchema) }), { auth: "admin" }), m
21874
22744
  * `super_admin` — collapsed onto the single boolean because every
21875
22745
  * non-admin caller is governed by the same scope-check rules; the
21876
22746
  * distinction was only ever used to route role-specific procedures
21877
- * which we no longer have. Agents are admin sessions issued via
21878
- * `createServiceToken`; CLI / webhook integrations are `cst_*` tokens
22747
+ * which we no longer have. CLI / webhook integrations are `cst_*` tokens
21879
22748
  * with `isAdmin: false` + an explicit scope list.
21880
22749
  */
21881
22750
  /** Per-method access flavour. Materialised on every cap method via codegen. */
@@ -23550,6 +24419,9 @@ var RetrainExportFilterSchema = object({
23550
24419
  frameIds: array(string()).max(2e4).optional(),
23551
24420
  /** Only frames in at least one of these named collections. */
23552
24421
  collectionIds: array(string()).max(200).optional(),
24422
+ /** Exactly the frames of this dataset version (and its completeOnly). An
24423
+ * unknown id selects nothing. */
24424
+ datasetVersionId: string().optional(),
23553
24425
  batchId: string().optional(),
23554
24426
  /** Only frames the operator marked complete (all subjects boxed). */
23555
24427
  completeOnly: boolean().optional()
@@ -23717,6 +24589,67 @@ var RetrainLlmAssistResultSchema = discriminatedUnion("kind", [object({
23717
24589
  ]),
23718
24590
  detail: string().optional()
23719
24591
  })]);
24592
+ /** What a dataset version is cut from. Every field narrows. */
24593
+ var RetrainDatasetSelectionSchema = object({
24594
+ deviceIds: array(number()).readonly().optional(),
24595
+ collectionIds: array(string()).max(200).readonly().optional(),
24596
+ frameIds: array(string()).max(2e4).readonly().optional()
24597
+ });
24598
+ /** The counts a dataset is judged by. */
24599
+ var RetrainDatasetStatsSchema = object({
24600
+ frames: number().int(),
24601
+ completeFrames: number().int(),
24602
+ /** `completeFrames / frames`, 0..1. */
24603
+ completeness: number(),
24604
+ /** Boxes to learn (model errors excluded). */
24605
+ subjects: number().int(),
24606
+ modelErrors: number().int(),
24607
+ /** Complete frames with no subject. */
24608
+ hardNegatives: number().int(),
24609
+ /** Subjects per class × camera × day/night. */
24610
+ cells: array(object({
24611
+ macroClass: string(),
24612
+ deviceId: number(),
24613
+ lighting: _enum([
24614
+ "day",
24615
+ "night",
24616
+ "unknown"
24617
+ ]),
24618
+ subjects: number().int(),
24619
+ frames: number().int()
24620
+ })).readonly(),
24621
+ cameras: array(object({
24622
+ deviceId: number(),
24623
+ frames: number().int(),
24624
+ completeFrames: number().int()
24625
+ })).readonly()
24626
+ });
24627
+ /** An immutable dataset version, without its frame list. */
24628
+ var RetrainDatasetVersionSchema = object({
24629
+ id: string(),
24630
+ name: string(),
24631
+ createdAt: number(),
24632
+ selection: RetrainDatasetSelectionSchema,
24633
+ layout: RetrainExportLayoutSchema,
24634
+ completeOnly: boolean(),
24635
+ frameCount: number().int(),
24636
+ /** sha256 of what the frames taught when the version was frozen. */
24637
+ annotationHash: string(),
24638
+ /** The export manifest schema the version was cut under. */
24639
+ manifestSchema: string(),
24640
+ stats: RetrainDatasetStatsSchema
24641
+ });
24642
+ var CreateRetrainDatasetVersionResultSchema = discriminatedUnion("kind", [object({
24643
+ kind: literal("created"),
24644
+ version: RetrainDatasetVersionSchema
24645
+ }), object({
24646
+ kind: literal("refused"),
24647
+ reason: _enum([
24648
+ "empty-name",
24649
+ "duplicate-name",
24650
+ "no-frames"
24651
+ ])
24652
+ })]);
23720
24653
  /** The outcome of a lifecycle move owned by the retrain page. */
23721
24654
  var RetrainTransitionResultSchema = object({
23722
24655
  trackId: string(),
@@ -24506,6 +25439,47 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
24506
25439
  kind: "mutation",
24507
25440
  auth: "admin",
24508
25441
  timeoutMs: 60 * 6e4
25442
+ }), method(object({
25443
+ filter: RetrainExportFilterSchema,
25444
+ layout: RetrainExportLayoutSchema
25445
+ }), object({
25446
+ ticket: PeerBytesTicketSchema,
25447
+ frames: number().int(),
25448
+ annotations: number().int()
25449
+ }), {
25450
+ kind: "mutation",
25451
+ auth: "admin",
25452
+ timeoutMs: 12e4
25453
+ }), method(object({
25454
+ selection: RetrainDatasetSelectionSchema,
25455
+ completeOnly: boolean().optional()
25456
+ }), RetrainDatasetStatsSchema, {
25457
+ kind: "query",
25458
+ auth: "admin"
25459
+ }), method(object({
25460
+ name: string().max(120),
25461
+ selection: RetrainDatasetSelectionSchema,
25462
+ layout: RetrainExportLayoutSchema,
25463
+ completeOnly: boolean()
25464
+ }), CreateRetrainDatasetVersionResultSchema, {
25465
+ kind: "mutation",
25466
+ auth: "admin",
25467
+ timeoutMs: 12e4
25468
+ }), method(object({}), array(RetrainDatasetVersionSchema).readonly(), {
25469
+ kind: "query",
25470
+ auth: "admin"
25471
+ }), method(object({ id: string() }), object({ deleted: boolean() }), {
25472
+ kind: "mutation",
25473
+ auth: "admin"
25474
+ }), method(object({ id: string() }), object({
25475
+ found: boolean(),
25476
+ annotationHash: string(),
25477
+ matches: boolean(),
25478
+ missingFrames: number().int()
25479
+ }), {
25480
+ kind: "query",
25481
+ auth: "admin",
25482
+ timeoutMs: 12e4
24509
25483
  }), method(object({}), array(RetrainAssistProfileSchema).readonly(), {
24510
25484
  kind: "query",
24511
25485
  auth: "admin"
@@ -28084,8 +29058,8 @@ version: string().optional() }), ServerUpdateActionResultSchema, {
28084
29058
  * `smtp-provider` — pluggable email delivery surface.
28085
29059
  *
28086
29060
  * Collection cap: a deployment may install multiple SMTP relays (e.g.
28087
- * one for transactional / one for notifications). Consumers (magic-link,
28088
- * notifier addons, …) walk the collection and pick the first
29061
+ * one for transactional / one for notifications). Consumers (notifier
29062
+ * addons, …) walk the collection and pick the first
28089
29063
  * ready provider OR target a specific addonId.
28090
29064
  *
28091
29065
  * The shape stays small on purpose — `sendEmail` is enough for the
@@ -28368,7 +29342,7 @@ targets: array(object({
28368
29342
  };
28369
29343
  /**
28370
29344
  * `sso-bridge` — internal hub-only cap that lets SSO-style auth
28371
- * providers (OIDC, SAML, magic-link, …) mint an HMAC-signed token
29345
+ * providers (OIDC, SAML, …) mint an HMAC-signed token
28372
29346
  * carrying the post-callback claims before redirecting back to
28373
29347
  * `/api/auth/sso/finish`.
28374
29348
  *
@@ -28431,7 +29405,14 @@ var SsoBridgeClaimsSchema = object({
28431
29405
  * Verified `iss` of the id_token behind an OIDC login bridge (D782). A
28432
29406
  * subject is unique only per issuer, so a link is bound to it.
28433
29407
  */
28434
- issuer: string().optional()
29408
+ issuer: string().optional(),
29409
+ /**
29410
+ * SHA-256 (hex) of the `camstack_sso_state` cookie the IdP `/start` set in
29411
+ * the browser that began this sign-in. `/api/auth/sso/finish` requires the
29412
+ * request to present the matching cookie — a login bridge is useless in
29413
+ * any other browser.
29414
+ */
29415
+ browserBinding: string().optional()
28435
29416
  });
28436
29417
  method(object({
28437
29418
  claims: SsoBridgeClaimsSchema,
@@ -41561,16 +42542,6 @@ var ApiKeySummarySchema = object({
41561
42542
  createdAt: number(),
41562
42543
  lastUsedAt: number().optional()
41563
42544
  });
41564
- var CreateApiKeyInputSchema = object({
41565
- label: string(),
41566
- isAdmin: boolean().default(false),
41567
- allowedProviders: union([array(string()), literal("*")]).optional(),
41568
- allowedDevices: record(string(), union([array(string()), literal("*")])).optional()
41569
- });
41570
- var CreateApiKeyResultSchema = object({
41571
- token: string(),
41572
- record: ApiKeySummarySchema
41573
- });
41574
42545
  var ScopedTokenSummarySchema = object({
41575
42546
  id: string(),
41576
42547
  userId: string(),
@@ -41669,17 +42640,10 @@ method(_void(), array(UserSummarySchema), { auth: "admin" }), method(CreateUserI
41669
42640
  }), UserSummarySchema.extend({ passwordHash: string() }).nullable(), {
41670
42641
  kind: "mutation",
41671
42642
  access: "view"
41672
- }), method(_void(), array(ApiKeySummarySchema), { auth: "admin" }), method(CreateApiKeyInputSchema, CreateApiKeyResultSchema, {
41673
- kind: "mutation",
41674
- auth: "admin",
41675
- access: "create"
41676
- }), method(object({ id: string() }), object({ success: literal(true) }), {
42643
+ }), method(_void(), array(ApiKeySummarySchema), { auth: "admin" }), method(object({ id: string() }), object({ success: literal(true) }), {
41677
42644
  kind: "mutation",
41678
42645
  auth: "admin",
41679
42646
  access: "delete"
41680
- }), method(object({ token: string() }), ApiKeySummarySchema.nullable(), {
41681
- kind: "mutation",
41682
- access: "view"
41683
42647
  }), method(CreateScopedTokenInputSchema, CreateScopedTokenResultSchema, {
41684
42648
  kind: "mutation",
41685
42649
  auth: "admin",
@@ -41753,15 +42717,7 @@ method(_void(), array(UserSummarySchema), { auth: "admin" }), method(CreateUserI
41753
42717
  }).nullable(), { access: "view" }), method(object({ userId: string() }), array(ExternalIdentitySchema), { auth: "admin" }), method(ExternalIdentityKeySchema, object({
41754
42718
  userId: string(),
41755
42719
  issuer: string()
41756
- }).nullable(), { auth: "admin" }), method(ExternalIdentityKeySchema.extend({
41757
- userId: string(),
41758
- issuer: string().min(1),
41759
- label: string().optional()
41760
- }), object({ success: literal(true) }), {
41761
- kind: "mutation",
41762
- auth: "admin",
41763
- access: "create"
41764
- }), method(ExternalIdentityKeySchema.extend({ userId: string() }), object({ success: boolean() }), {
42720
+ }).nullable(), { auth: "admin" }), method(ExternalIdentityKeySchema.extend({ userId: string() }), object({ success: boolean() }), {
41765
42721
  kind: "mutation",
41766
42722
  auth: "admin",
41767
42723
  access: "delete"
@@ -42466,6 +43422,451 @@ var zoneRulesCapability = {
42466
43422
  */
42467
43423
  durability: "restored"
42468
43424
  };
43425
+ /**
43426
+ * `training-provider` — ONE cloud that can run the CamStack trainer.
43427
+ *
43428
+ * A thin, mockable translation layer: it knows how to run a container with a
43429
+ * GPU, move a dataset in, read the job's stdout and hand artefacts back. It
43430
+ * knows nothing about datasets, splits, floors, cost policy or Model Studio —
43431
+ * those are the `training` orchestrator's (D805). Every rule written there
43432
+ * once is what makes a second provider (RunPod, a local NVIDIA node) a new
43433
+ * manifest entry and nothing else.
43434
+ *
43435
+ * Collection, routed by the `addonId` in every single-row input (the `llm` /
43436
+ * `notification-output` posture); `describe` concat-fans across providers.
43437
+ * Every method is `admin`: these spend money.
43438
+ *
43439
+ * Every cloud object a provider creates is tagged with the orchestrator's
43440
+ * `jobKey`, so a retried submit finds the job it already started instead of
43441
+ * starting a second GPU, and `listJobs` can find orphans.
43442
+ *
43443
+ * Bytes never ride a cap field: the dataset arrives as a `ctx.peerBytes`
43444
+ * ticket the producer (pipeline-analytics) minted, and artefacts leave as a
43445
+ * ticket the provider mints (D613).
43446
+ */
43447
+ var TrainingGpuOptionSchema = object({
43448
+ id: string(),
43449
+ label: string(),
43450
+ /** List price, USD per GPU-hour, before any region multiplier. */
43451
+ usdPerHour: number().nonnegative(),
43452
+ vramGb: number().nonnegative()
43453
+ });
43454
+ var TrainingRegionOptionSchema = object({
43455
+ /** `''` = any region (the provider's choice). */
43456
+ id: string(),
43457
+ label: string(),
43458
+ priceMultiplier: number().positive()
43459
+ });
43460
+ /**
43461
+ * The provider's per-account settings, as the orchestrator reads them. They
43462
+ * live in the PROVIDER addon's settings (operator decision 2026-10-08: they
43463
+ * depend on the user's account), never hard-coded in the orchestrator.
43464
+ */
43465
+ var TrainingProviderDefaultsSchema = object({
43466
+ gpuType: string(),
43467
+ region: string(),
43468
+ costCapUsd: number().nonnegative(),
43469
+ maxRuntimeSec: number().int().positive(),
43470
+ /** Hours a FAILED job's cloud dataset is kept for debugging; 0 = delete at once. */
43471
+ failedDatasetGraceHours: number().nonnegative()
43472
+ });
43473
+ var TrainingProviderDescriptorSchema = object({
43474
+ addonId: string(),
43475
+ /** `modal`, `runpod`, `fake`, … */
43476
+ kind: string(),
43477
+ label: string(),
43478
+ gpuTypes: array(TrainingGpuOptionSchema).readonly(),
43479
+ regions: array(TrainingRegionOptionSchema).readonly(),
43480
+ maxDatasetBytes: number().int().positive(),
43481
+ maxRuntimeSec: number().int().positive(),
43482
+ freeTierNote: string().optional(),
43483
+ /** Where the data goes, in one sentence the confirm dialog repeats. */
43484
+ dataResidencyNote: string(),
43485
+ /** Credentials are present — never the values. */
43486
+ configured: boolean(),
43487
+ defaults: TrainingProviderDefaultsSchema
43488
+ });
43489
+ var TrainingCredentialCheckSchema = object({
43490
+ ok: boolean(),
43491
+ /** Workspace / account name, when the provider says. */
43492
+ account: string().optional(),
43493
+ reason: _enum([
43494
+ "missing",
43495
+ "invalid",
43496
+ "forbidden",
43497
+ "network",
43498
+ "quota"
43499
+ ]).optional(),
43500
+ detail: string().optional()
43501
+ });
43502
+ var ProviderJobStateSchema = _enum([
43503
+ "pending",
43504
+ "starting",
43505
+ "running",
43506
+ "succeeded",
43507
+ "failed",
43508
+ "cancelled",
43509
+ "lost"
43510
+ ]);
43511
+ var ProviderJobStatusSchema = object({
43512
+ jobKey: string(),
43513
+ providerJobId: string().optional(),
43514
+ state: ProviderJobStateSchema,
43515
+ startedAt: number().optional(),
43516
+ endedAt: number().optional(),
43517
+ exitCode: number().int().optional(),
43518
+ failureReason: string().optional(),
43519
+ gpuType: string(),
43520
+ region: string().optional(),
43521
+ billedSeconds: number().nonnegative(),
43522
+ costUsd: number().nonnegative(),
43523
+ /** True when `costUsd` is runtime × list price, not a billing answer. */
43524
+ costIsEstimate: boolean(),
43525
+ lastFetchedAt: number()
43526
+ });
43527
+ /**
43528
+ * The trainer the job runs, by SOURCE revision: the provider turns it into an
43529
+ * image its own way (Modal builds the published Dockerfile at that revision;
43530
+ * a registry-pull provider maps it to a tag). Recorded on the job and echoed
43531
+ * in `result.json`.
43532
+ */
43533
+ var TrainerSourceRefSchema = object({
43534
+ /** Hugging Face repo id, e.g. `camstack/camstack-trainer`. */
43535
+ repo: string().min(1),
43536
+ /** A commit sha (never a branch) — the job must be reproducible. */
43537
+ revision: string().regex(/^[0-9a-f]{7,64}$/)
43538
+ });
43539
+ var JobRef = {
43540
+ addonId: string(),
43541
+ jobKey: string().uuid()
43542
+ };
43543
+ var TrainingLogLineSchema = object({
43544
+ ts: number(),
43545
+ text: string()
43546
+ });
43547
+ method(object({}), array(TrainingProviderDescriptorSchema).readonly(), { auth: "admin" }), method(object({ addonId: string() }), TrainingCredentialCheckSchema, {
43548
+ kind: "mutation",
43549
+ auth: "admin",
43550
+ timeoutMs: 3e4
43551
+ }), method(object({
43552
+ addonId: string(),
43553
+ gpuType: string(),
43554
+ region: string(),
43555
+ datasetBytes: number().int().nonnegative(),
43556
+ gpuSecondsLow: number().nonnegative(),
43557
+ gpuSecondsHigh: number().nonnegative()
43558
+ }), object({
43559
+ usdLow: number().nonnegative(),
43560
+ usdHigh: number().nonnegative(),
43561
+ notes: array(string()).readonly()
43562
+ }), { auth: "admin" }), method(object({
43563
+ ...JobRef,
43564
+ ticket: PeerBytesTicketSchema
43565
+ }), object({
43566
+ bytes: number().int().nonnegative(),
43567
+ sha256: string()
43568
+ }), {
43569
+ kind: "mutation",
43570
+ auth: "admin",
43571
+ timeoutMs: 120 * 6e4
43572
+ }), method(object({
43573
+ ...JobRef,
43574
+ trainer: TrainerSourceRefSchema,
43575
+ jobSpecJson: string().min(2).max(64e3),
43576
+ gpuType: string(),
43577
+ region: string(),
43578
+ maxRuntimeSec: number().int().positive()
43579
+ }), ProviderJobStatusSchema, {
43580
+ kind: "mutation",
43581
+ auth: "admin",
43582
+ timeoutMs: 30 * 6e4
43583
+ }), method(object(JobRef), ProviderJobStatusSchema, {
43584
+ auth: "admin",
43585
+ timeoutMs: 6e4
43586
+ }), method(object({
43587
+ ...JobRef,
43588
+ cursor: string().optional(),
43589
+ max: number().int().min(1).max(500)
43590
+ }), object({
43591
+ lines: array(TrainingLogLineSchema).readonly(),
43592
+ cursor: string()
43593
+ }), {
43594
+ auth: "admin",
43595
+ timeoutMs: 6e4
43596
+ }), method(object(JobRef), object({ ok: literal(true) }), {
43597
+ kind: "mutation",
43598
+ auth: "admin",
43599
+ timeoutMs: 6e4
43600
+ }), method(object(JobRef), object({
43601
+ found: boolean(),
43602
+ text: string().optional()
43603
+ }), {
43604
+ kind: "mutation",
43605
+ auth: "admin",
43606
+ timeoutMs: 5 * 6e4
43607
+ }), method(object({
43608
+ ...JobRef,
43609
+ path: _enum(["bundle.tar"])
43610
+ }), object({ ticket: PeerBytesTicketSchema }), {
43611
+ kind: "mutation",
43612
+ auth: "admin",
43613
+ timeoutMs: 5 * 6e4
43614
+ }), method(object(JobRef), object({ deleted: array(string()).readonly() }), {
43615
+ kind: "mutation",
43616
+ auth: "admin",
43617
+ timeoutMs: 5 * 6e4
43618
+ }), method(object({ addonId: string() }), array(ProviderJobStatusSchema).readonly(), {
43619
+ auth: "admin",
43620
+ timeoutMs: 2 * 6e4
43621
+ });
43622
+ /**
43623
+ * `training` — the cloud-training orchestrator (D805). Hub-only singleton,
43624
+ * provided by `addon-training`.
43625
+ *
43626
+ * It owns what every provider must agree on, written once:
43627
+ *
43628
+ * - **Dataset versions.** Taken over from pipeline-analytics (D796): the rows
43629
+ * live here (D808); pipeline-analytics still CUTS a version (it owns the corpus and
43630
+ * the export plan) and reaches this store through the five row methods
43631
+ * below, so the Retrain page and the export did not change.
43632
+ * - **Jobs.** A persisted state machine, a reconcile loop against the
43633
+ * provider, a cost guard, a daily orphan sweep and the retention rules.
43634
+ * - **The return flow.** Verified artefacts → Model Studio
43635
+ * (`custom-model-registry.importModelBundle`) → canary on cameras →
43636
+ * rollback. Nothing is ever registered automatically.
43637
+ *
43638
+ * Every method is `admin`.
43639
+ */
43640
+ /** A version WITH its frame list — what the export and a job read. */
43641
+ var TrainingDatasetVersionRowSchema = RetrainDatasetVersionSchema.omit({ frameCount: true }).extend({ frameIds: array(string()).max(2e4).readonly() });
43642
+ /** A base model a detector job can fine-tune, and the baseline it is judged against. */
43643
+ var TrainingBaseModelSchema = object({
43644
+ modelId: string(),
43645
+ label: string(),
43646
+ weights: string(),
43647
+ imgsz: number().int(),
43648
+ baselineOnnxUrl: string(),
43649
+ baselineFloors: record(string(), number()),
43650
+ /** The base the fleet runs most — the UI's default. */
43651
+ recommended: boolean()
43652
+ });
43653
+ var TrainingPresetSchema = _enum([
43654
+ "quick",
43655
+ "standard",
43656
+ "thorough"
43657
+ ]);
43658
+ var TrainingJobRequestSchema = object({
43659
+ datasetVersionId: string().min(1),
43660
+ /** The `training-provider` addon that runs it. */
43661
+ addonId: string().min(1),
43662
+ gpuType: string().min(1),
43663
+ region: string(),
43664
+ baseModelId: string().min(1),
43665
+ preset: TrainingPresetSchema,
43666
+ /** Freeze the backbone's first N layers; `null` = the preset's choice. */
43667
+ freeze: number().int().nonnegative().nullable(),
43668
+ /** Cameras held out whole for evaluation; `null` = the orchestrator's default. */
43669
+ holdoutCameras: array(number().int()).nullable()
43670
+ });
43671
+ var TrainingSplitPlanSchema = object({
43672
+ holdoutCameras: array(number().int()).readonly(),
43673
+ /** Used when no camera is held out: the last N days of every camera. */
43674
+ holdoutLastDays: number().int().nonnegative(),
43675
+ /** Holdout subjects per class (camera holdout only; `null` = known only after the split). */
43676
+ holdoutSupport: record(string(), number().int()).nullable(),
43677
+ trainSubjects: number().int()
43678
+ });
43679
+ var TrainingRefusalReasonSchema = _enum([
43680
+ "unknown-dataset",
43681
+ "unknown-provider",
43682
+ "provider-not-configured",
43683
+ "unknown-base-model",
43684
+ "unknown-gpu",
43685
+ "dataset-too-large",
43686
+ "no-training-subjects",
43687
+ "job-already-running"
43688
+ ]);
43689
+ var TrainingJobPlanSchema = object({
43690
+ refusal: object({
43691
+ reason: TrainingRefusalReasonSchema,
43692
+ detail: string()
43693
+ }).nullable(),
43694
+ warnings: array(string()).readonly(),
43695
+ split: TrainingSplitPlanSchema.nullable(),
43696
+ estimate: object({
43697
+ datasetBytes: number().int(),
43698
+ uploadMinutesAt20Mbps: number(),
43699
+ gpuSecondsLow: number(),
43700
+ gpuSecondsHigh: number(),
43701
+ usdLow: number(),
43702
+ usdHigh: number(),
43703
+ notes: array(string()).readonly()
43704
+ }).nullable(),
43705
+ /** Pre-filled from the provider's settings; the operator may lower or raise them. */
43706
+ defaults: object({
43707
+ maxCostUsd: number(),
43708
+ maxRuntimeSec: number().int()
43709
+ }).nullable(),
43710
+ /** The sentence the confirm dialog repeats: where the frames go and when they are deleted. */
43711
+ dataNotice: string()
43712
+ });
43713
+ /**
43714
+ * Orchestrator-owned states, persisted. `uploading` covers exporting the
43715
+ * archive (it is streamed, never staged). Terminal: `failed`, `cancelled`,
43716
+ * `lost`, `expired`, `discarded`. `registered` and `canary` are where a
43717
+ * result lives after the operator acted on it.
43718
+ */
43719
+ var TrainingJobStateSchema = _enum([
43720
+ "uploading",
43721
+ "submitted",
43722
+ "starting",
43723
+ "running",
43724
+ "collecting",
43725
+ "ready",
43726
+ "registered",
43727
+ "canary",
43728
+ "failed",
43729
+ "cancelling",
43730
+ "cancelled",
43731
+ "lost",
43732
+ "expired",
43733
+ "discarded"
43734
+ ]);
43735
+ var TrainingFailureReasonSchema = _enum([
43736
+ "cost-cap",
43737
+ "runtime-cap",
43738
+ "upload-failed",
43739
+ "submit-failed",
43740
+ "trainer-failed",
43741
+ "result-invalid",
43742
+ "checksum-mismatch",
43743
+ "fetch-failed",
43744
+ "provider-error",
43745
+ "hub-restart-during-upload"
43746
+ ]);
43747
+ var TrainingProgressPointSchema = object({
43748
+ epoch: number().int(),
43749
+ map50: number().nullable(),
43750
+ map50_95: number().nullable()
43751
+ });
43752
+ var TrainingCanarySchema = object({
43753
+ deviceIds: array(number().int()).readonly(),
43754
+ since: number(),
43755
+ /** Every override the canary replaced, exactly, so rollback restores it. */
43756
+ previous: array(object({
43757
+ deviceId: number().int(),
43758
+ nodeId: string(),
43759
+ deviceKey: string(),
43760
+ patch: object({
43761
+ modelId: string().optional(),
43762
+ settings: record(string(), unknown()).readonly().optional()
43763
+ }).nullable()
43764
+ })).readonly()
43765
+ });
43766
+ var TrainingJobSchema = object({
43767
+ id: string(),
43768
+ idempotencyKey: string(),
43769
+ name: string(),
43770
+ createdAt: number(),
43771
+ updatedAt: number(),
43772
+ state: TrainingJobStateSchema,
43773
+ stage: TrainingStageSchema.nullable(),
43774
+ failure: object({
43775
+ reason: TrainingFailureReasonSchema,
43776
+ stage: string().nullable(),
43777
+ detail: string()
43778
+ }).nullable(),
43779
+ request: TrainingJobRequestSchema,
43780
+ maxCostUsd: number().nonnegative(),
43781
+ maxRuntimeSec: number().int().positive(),
43782
+ trainer: TrainerSourceRefSchema,
43783
+ datasetLayout: RetrainExportLayoutSchema,
43784
+ dataset: object({
43785
+ bytes: number().int(),
43786
+ sha256: string(),
43787
+ uploadedAt: number()
43788
+ }).nullable(),
43789
+ split: TrainingSplitPlanSchema,
43790
+ provider: object({
43791
+ state: ProviderJobStateSchema.nullable(),
43792
+ providerJobId: string().nullable(),
43793
+ startedAt: number().nullable(),
43794
+ endedAt: number().nullable(),
43795
+ billedSeconds: number(),
43796
+ costUsd: number(),
43797
+ costIsEstimate: boolean(),
43798
+ lastPolledAt: number().nullable()
43799
+ }),
43800
+ progress: object({
43801
+ epoch: number().int().nullable(),
43802
+ epochs: number().int().nullable(),
43803
+ etaSec: number().nullable(),
43804
+ series: array(TrainingProgressPointSchema).readonly()
43805
+ }),
43806
+ /** The last lines of the job's output (≤ 200), newest last. Never frame paths. */
43807
+ logTail: array(string()).readonly(),
43808
+ logCursor: string().nullable(),
43809
+ artifacts: object({
43810
+ bundleBytes: number().int(),
43811
+ bundleSha256: string(),
43812
+ fetchedAt: number(),
43813
+ /** When the staged artefacts are deleted from the hub. */
43814
+ expiresAt: number()
43815
+ }).nullable(),
43816
+ /** When the provider-side copy of the frames was deleted; null while it exists. */
43817
+ cloudDatasetDeletedAt: number().nullable(),
43818
+ /** A failed job's dataset is kept until then (the provider's grace), then deleted. */
43819
+ cloudCleanupDueAt: number().nullable(),
43820
+ /** Model ids registered from this job (base, and int8 when kept). */
43821
+ registeredModelIds: array(string()).readonly(),
43822
+ canary: TrainingCanarySchema.nullable()
43823
+ });
43824
+ var IdInput = object({ id: string().min(1) });
43825
+ method(TrainingDatasetVersionRowSchema, object({ stored: boolean() }), {
43826
+ kind: "mutation",
43827
+ auth: "admin"
43828
+ }), 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() }), {
43829
+ kind: "mutation",
43830
+ auth: "admin"
43831
+ }), method(object({}), array(TrainingBaseModelSchema).readonly(), { auth: "admin" }), method(TrainingJobRequestSchema, TrainingJobPlanSchema, {
43832
+ auth: "admin",
43833
+ timeoutMs: 6e4
43834
+ }), method(TrainingJobRequestSchema.extend({
43835
+ name: string().min(1).max(120),
43836
+ maxCostUsd: number().positive(),
43837
+ maxRuntimeSec: number().int().positive(),
43838
+ idempotencyKey: string().min(8).max(80)
43839
+ }), discriminatedUnion("kind", [object({
43840
+ kind: literal("started"),
43841
+ job: TrainingJobSchema
43842
+ }), object({
43843
+ kind: literal("refused"),
43844
+ reason: TrainingRefusalReasonSchema,
43845
+ detail: string()
43846
+ })]), {
43847
+ kind: "mutation",
43848
+ auth: "admin",
43849
+ timeoutMs: 12e4
43850
+ }), method(object({}), array(TrainingJobSchema).readonly(), { auth: "admin" }), method(IdInput, TrainingJobSchema.nullable(), { auth: "admin" }), method(IdInput, TrainingJobSchema, {
43851
+ kind: "mutation",
43852
+ auth: "admin",
43853
+ timeoutMs: 12e4
43854
+ }), method(IdInput, TrainingResultSchema.nullable(), { auth: "admin" }), method(IdInput.extend({ canaryDeviceIds: array(number().int()).readonly() }), TrainingJobSchema, {
43855
+ kind: "mutation",
43856
+ auth: "admin",
43857
+ timeoutMs: 30 * 6e4
43858
+ }), method(IdInput.extend({ deviceIds: array(number().int()).min(1).readonly() }), TrainingJobSchema, {
43859
+ kind: "mutation",
43860
+ auth: "admin",
43861
+ timeoutMs: 12e4
43862
+ }), method(IdInput, TrainingJobSchema, {
43863
+ kind: "mutation",
43864
+ auth: "admin",
43865
+ timeoutMs: 12e4
43866
+ }), method(IdInput, TrainingJobSchema, {
43867
+ kind: "mutation",
43868
+ auth: "admin"
43869
+ });
42469
43870
  SOURCE_CAPS.filter((cap) => cap !== "switch" && cap !== "motion");
42470
43871
  Object.freeze({
42471
43872
  person: .5,
@@ -44614,6 +46015,12 @@ Object.freeze({
44614
46015
  addonId: null,
44615
46016
  access: "create"
44616
46017
  },
46018
+ "backup.checkBackupKey": {
46019
+ capName: "backup",
46020
+ capScope: "system",
46021
+ addonId: null,
46022
+ access: "create"
46023
+ },
44617
46024
  "backup.delete": {
44618
46025
  capName: "backup",
44619
46026
  capScope: "system",
@@ -44626,6 +46033,18 @@ Object.freeze({
44626
46033
  addonId: null,
44627
46034
  access: "delete"
44628
46035
  },
46036
+ "backup.disableEncryption": {
46037
+ capName: "backup",
46038
+ capScope: "system",
46039
+ addonId: null,
46040
+ access: "create"
46041
+ },
46042
+ "backup.getEncryption": {
46043
+ capName: "backup",
46044
+ capScope: "system",
46045
+ addonId: null,
46046
+ access: "view"
46047
+ },
44629
46048
  "backup.getEntries": {
44630
46049
  capName: "backup",
44631
46050
  capScope: "system",
@@ -44680,6 +46099,12 @@ Object.freeze({
44680
46099
  addonId: null,
44681
46100
  access: "create"
44682
46101
  },
46102
+ "backup.setupEncryption": {
46103
+ capName: "backup",
46104
+ capScope: "system",
46105
+ addonId: null,
46106
+ access: "create"
46107
+ },
44683
46108
  "backup.trigger": {
44684
46109
  capName: "backup",
44685
46110
  capScope: "system",
@@ -45232,6 +46657,12 @@ Object.freeze({
45232
46657
  addonId: null,
45233
46658
  access: "create"
45234
46659
  },
46660
+ "customModelRegistry.importModelBundle": {
46661
+ capName: "custom-model-registry",
46662
+ capScope: "system",
46663
+ addonId: null,
46664
+ access: "create"
46665
+ },
45235
46666
  "customModelRegistry.listModels": {
45236
46667
  capName: "custom-model-registry",
45237
46668
  capScope: "system",
@@ -46672,6 +48103,12 @@ Object.freeze({
46672
48103
  addonId: null,
46673
48104
  access: "view"
46674
48105
  },
48106
+ "keychainAdmin.acknowledgeReset": {
48107
+ capName: "keychain-admin",
48108
+ capScope: "system",
48109
+ addonId: null,
48110
+ access: "create"
48111
+ },
46675
48112
  "keychainAdmin.deleteOrphans": {
46676
48113
  capName: "keychain-admin",
46677
48114
  capScope: "system",
@@ -46708,6 +48145,12 @@ Object.freeze({
46708
48145
  addonId: null,
46709
48146
  access: "delete"
46710
48147
  },
48148
+ "keychainAdmin.resetReport": {
48149
+ capName: "keychain-admin",
48150
+ capScope: "system",
48151
+ addonId: null,
48152
+ access: "delete"
48153
+ },
46711
48154
  "keychainAdmin.reveal": {
46712
48155
  capName: "keychain-admin",
46713
48156
  capScope: "system",
@@ -46720,6 +48163,12 @@ Object.freeze({
46720
48163
  addonId: null,
46721
48164
  access: "create"
46722
48165
  },
48166
+ "keychainAdmin.setSystemSecret": {
48167
+ capName: "keychain-admin",
48168
+ capScope: "system",
48169
+ addonId: null,
48170
+ access: "create"
48171
+ },
46723
48172
  "keychainAdmin.status": {
46724
48173
  capName: "keychain-admin",
46725
48174
  capScope: "system",
@@ -48166,6 +49615,12 @@ Object.freeze({
48166
49615
  addonId: null,
48167
49616
  access: "create"
48168
49617
  },
49618
+ "pipelineAnalytics.createRetrainDatasetVersion": {
49619
+ capName: "pipeline-analytics",
49620
+ capScope: "device",
49621
+ addonId: null,
49622
+ access: "create"
49623
+ },
48169
49624
  "pipelineAnalytics.deleteDeviceEvents": {
48170
49625
  capName: "pipeline-analytics",
48171
49626
  capScope: "device",
@@ -48178,6 +49633,12 @@ Object.freeze({
48178
49633
  addonId: null,
48179
49634
  access: "delete"
48180
49635
  },
49636
+ "pipelineAnalytics.deleteRetrainDatasetVersion": {
49637
+ capName: "pipeline-analytics",
49638
+ capScope: "device",
49639
+ addonId: null,
49640
+ access: "delete"
49641
+ },
48181
49642
  "pipelineAnalytics.deleteTracks": {
48182
49643
  capName: "pipeline-analytics",
48183
49644
  capScope: "device",
@@ -48400,6 +49861,12 @@ Object.freeze({
48400
49861
  addonId: null,
48401
49862
  access: "view"
48402
49863
  },
49864
+ "pipelineAnalytics.listRetrainDatasetVersions": {
49865
+ capName: "pipeline-analytics",
49866
+ capScope: "device",
49867
+ addonId: null,
49868
+ access: "view"
49869
+ },
48403
49870
  "pipelineAnalytics.listRetrainFrames": {
48404
49871
  capName: "pipeline-analytics",
48405
49872
  capScope: "device",
@@ -48430,6 +49897,12 @@ Object.freeze({
48430
49897
  addonId: null,
48431
49898
  access: "view"
48432
49899
  },
49900
+ "pipelineAnalytics.offerRetrainArchive": {
49901
+ capName: "pipeline-analytics",
49902
+ capScope: "device",
49903
+ addonId: null,
49904
+ access: "create"
49905
+ },
48433
49906
  "pipelineAnalytics.ownersWithMedia": {
48434
49907
  capName: "pipeline-analytics",
48435
49908
  capScope: "device",
@@ -48442,6 +49915,12 @@ Object.freeze({
48442
49915
  addonId: null,
48443
49916
  access: "create"
48444
49917
  },
49918
+ "pipelineAnalytics.previewRetrainDataset": {
49919
+ capName: "pipeline-analytics",
49920
+ capScope: "device",
49921
+ addonId: null,
49922
+ access: "view"
49923
+ },
48445
49924
  "pipelineAnalytics.proposeRetrainAnnotations": {
48446
49925
  capName: "pipeline-analytics",
48447
49926
  capScope: "device",
@@ -48580,6 +50059,12 @@ Object.freeze({
48580
50059
  addonId: null,
48581
50060
  access: "create"
48582
50061
  },
50062
+ "pipelineAnalytics.verifyRetrainDatasetVersion": {
50063
+ capName: "pipeline-analytics",
50064
+ capScope: "device",
50065
+ addonId: null,
50066
+ access: "view"
50067
+ },
48583
50068
  "pipelineAnalytics.wipeAllAnalytics": {
48584
50069
  capName: "pipeline-analytics",
48585
50070
  capScope: "device",
@@ -50956,6 +52441,174 @@ Object.freeze({
50956
52441
  addonId: null,
50957
52442
  access: "view"
50958
52443
  },
52444
+ "training.canaryResult": {
52445
+ capName: "training",
52446
+ capScope: "system",
52447
+ addonId: null,
52448
+ access: "create"
52449
+ },
52450
+ "training.cancelJob": {
52451
+ capName: "training",
52452
+ capScope: "system",
52453
+ addonId: null,
52454
+ access: "create"
52455
+ },
52456
+ "training.discardResult": {
52457
+ capName: "training",
52458
+ capScope: "system",
52459
+ addonId: null,
52460
+ access: "create"
52461
+ },
52462
+ "training.findDatasetVersionIdByName": {
52463
+ capName: "training",
52464
+ capScope: "system",
52465
+ addonId: null,
52466
+ access: "view"
52467
+ },
52468
+ "training.getDatasetVersion": {
52469
+ capName: "training",
52470
+ capScope: "system",
52471
+ addonId: null,
52472
+ access: "view"
52473
+ },
52474
+ "training.getJob": {
52475
+ capName: "training",
52476
+ capScope: "system",
52477
+ addonId: null,
52478
+ access: "view"
52479
+ },
52480
+ "training.getJobResult": {
52481
+ capName: "training",
52482
+ capScope: "system",
52483
+ addonId: null,
52484
+ access: "view"
52485
+ },
52486
+ "training.listBaseModels": {
52487
+ capName: "training",
52488
+ capScope: "system",
52489
+ addonId: null,
52490
+ access: "view"
52491
+ },
52492
+ "training.listDatasetVersions": {
52493
+ capName: "training",
52494
+ capScope: "system",
52495
+ addonId: null,
52496
+ access: "view"
52497
+ },
52498
+ "training.listJobs": {
52499
+ capName: "training",
52500
+ capScope: "system",
52501
+ addonId: null,
52502
+ access: "view"
52503
+ },
52504
+ "training.planJob": {
52505
+ capName: "training",
52506
+ capScope: "system",
52507
+ addonId: null,
52508
+ access: "view"
52509
+ },
52510
+ "training.putDatasetVersion": {
52511
+ capName: "training",
52512
+ capScope: "system",
52513
+ addonId: null,
52514
+ access: "create"
52515
+ },
52516
+ "training.registerResult": {
52517
+ capName: "training",
52518
+ capScope: "system",
52519
+ addonId: null,
52520
+ access: "create"
52521
+ },
52522
+ "training.removeDatasetVersion": {
52523
+ capName: "training",
52524
+ capScope: "system",
52525
+ addonId: null,
52526
+ access: "delete"
52527
+ },
52528
+ "training.rollbackCanary": {
52529
+ capName: "training",
52530
+ capScope: "system",
52531
+ addonId: null,
52532
+ access: "create"
52533
+ },
52534
+ "training.startJob": {
52535
+ capName: "training",
52536
+ capScope: "system",
52537
+ addonId: null,
52538
+ access: "create"
52539
+ },
52540
+ "trainingProvider.cancelJob": {
52541
+ capName: "training-provider",
52542
+ capScope: "system",
52543
+ addonId: null,
52544
+ access: "create"
52545
+ },
52546
+ "trainingProvider.cleanupJob": {
52547
+ capName: "training-provider",
52548
+ capScope: "system",
52549
+ addonId: null,
52550
+ access: "create"
52551
+ },
52552
+ "trainingProvider.describe": {
52553
+ capName: "training-provider",
52554
+ capScope: "system",
52555
+ addonId: null,
52556
+ access: "view"
52557
+ },
52558
+ "trainingProvider.estimateJob": {
52559
+ capName: "training-provider",
52560
+ capScope: "system",
52561
+ addonId: null,
52562
+ access: "view"
52563
+ },
52564
+ "trainingProvider.getJob": {
52565
+ capName: "training-provider",
52566
+ capScope: "system",
52567
+ addonId: null,
52568
+ access: "view"
52569
+ },
52570
+ "trainingProvider.listJobEvents": {
52571
+ capName: "training-provider",
52572
+ capScope: "system",
52573
+ addonId: null,
52574
+ access: "view"
52575
+ },
52576
+ "trainingProvider.listJobs": {
52577
+ capName: "training-provider",
52578
+ capScope: "system",
52579
+ addonId: null,
52580
+ access: "view"
52581
+ },
52582
+ "trainingProvider.offerArtifact": {
52583
+ capName: "training-provider",
52584
+ capScope: "system",
52585
+ addonId: null,
52586
+ access: "create"
52587
+ },
52588
+ "trainingProvider.readResult": {
52589
+ capName: "training-provider",
52590
+ capScope: "system",
52591
+ addonId: null,
52592
+ access: "create"
52593
+ },
52594
+ "trainingProvider.submitJob": {
52595
+ capName: "training-provider",
52596
+ capScope: "system",
52597
+ addonId: null,
52598
+ access: "create"
52599
+ },
52600
+ "trainingProvider.uploadDataset": {
52601
+ capName: "training-provider",
52602
+ capScope: "system",
52603
+ addonId: null,
52604
+ access: "create"
52605
+ },
52606
+ "trainingProvider.validateCredentials": {
52607
+ capName: "training-provider",
52608
+ capScope: "system",
52609
+ addonId: null,
52610
+ access: "create"
52611
+ },
50959
52612
  "turnProvider.getTurnServers": {
50960
52613
  capName: "turn-provider",
50961
52614
  capScope: "system",
@@ -50980,12 +52633,6 @@ Object.freeze({
50980
52633
  addonId: null,
50981
52634
  access: "create"
50982
52635
  },
50983
- "userManagement.createApiKey": {
50984
- capName: "user-management",
50985
- capScope: "system",
50986
- addonId: null,
50987
- access: "create"
50988
- },
50989
52636
  "userManagement.createScopedToken": {
50990
52637
  capName: "user-management",
50991
52638
  capScope: "system",
@@ -51022,12 +52669,6 @@ Object.freeze({
51022
52669
  addonId: null,
51023
52670
  access: "view"
51024
52671
  },
51025
- "userManagement.linkExternalIdentity": {
51026
- capName: "user-management",
51027
- capScope: "system",
51028
- addonId: null,
51029
- access: "create"
51030
- },
51031
52672
  "userManagement.listApiKeys": {
51032
52673
  capName: "user-management",
51033
52674
  capScope: "system",
@@ -51130,12 +52771,6 @@ Object.freeze({
51130
52771
  addonId: null,
51131
52772
  access: "create"
51132
52773
  },
51133
- "userManagement.validateApiKey": {
51134
- capName: "user-management",
51135
- capScope: "system",
51136
- addonId: null,
51137
- access: "view"
51138
- },
51139
52774
  "userManagement.validateCredentials": {
51140
52775
  capName: "user-management",
51141
52776
  capScope: "system",
@@ -55455,6 +57090,11 @@ Object.freeze({
55455
57090
  form: "single",
55456
57091
  optional: false
55457
57092
  }],
57093
+ "training.canaryResult": [{
57094
+ name: "deviceIds",
57095
+ form: "array",
57096
+ optional: false
57097
+ }],
55458
57098
  "update.getStatus": [{
55459
57099
  name: "deviceId",
55460
57100
  form: "single",