@camstack/addon-provider-unraid 0.2.124 → 0.2.125

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
@@ -5376,7 +5376,7 @@ var ZodIssueCode = {
5376
5376
  var ZodFirstPartyTypeKind;
5377
5377
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
5378
5378
  //#endregion
5379
- //#region ../types/dist/sleep-Cr5YOk3m.mjs
5379
+ //#region ../types/dist/sleep-r3RWkGVx.mjs
5380
5380
  /**
5381
5381
  * The audio chunk plane's byte format, and the ONE expansion from a coded
5382
5382
  * window to float samples (D455).
@@ -5493,7 +5493,7 @@ function isKeychainStoredField(field) {
5493
5493
  var SECRET_CLEAR = { $secretClear: true };
5494
5494
  /** The `'***'` token D634 redaction writes for non-admins. */
5495
5495
  var LEGACY_DEVICE_REDACTION = "***";
5496
- function isRecord$1(value) {
5496
+ function isRecord$2(value) {
5497
5497
  return typeof value === "object" && value !== null && !Array.isArray(value);
5498
5498
  }
5499
5499
  function makeSecretMarker(ref) {
@@ -5504,12 +5504,12 @@ function makeSecretMarker(ref) {
5504
5504
  }
5505
5505
  /** A stored marker: an object whose `$secret` is a non-empty string. */
5506
5506
  function isSecretMarker(value) {
5507
- if (!isRecord$1(value)) return false;
5507
+ if (!isRecord$2(value)) return false;
5508
5508
  const ref = value["$secret"];
5509
5509
  return typeof ref === "string" && ref.length > 0;
5510
5510
  }
5511
5511
  function isSecretClear(value) {
5512
- return isRecord$1(value) && value["$secretClear"] === true;
5512
+ return isRecord$2(value) && value["$secretClear"] === true;
5513
5513
  }
5514
5514
  /**
5515
5515
  * The UI view of a stored secret field value: a marker becomes "set", inline
@@ -6025,6 +6025,13 @@ function globalSecretScope() {
6025
6025
  function encodeSegment(value) {
6026
6026
  return encodeURIComponent(value);
6027
6027
  }
6028
+ function decodeSegment(value) {
6029
+ try {
6030
+ return decodeURIComponent(value);
6031
+ } catch {
6032
+ return null;
6033
+ }
6034
+ }
6028
6035
  /**
6029
6036
  * The field path of a value inside an array item, addressed by the item's id:
6030
6037
  * `arrayItemFieldPath('providers', 'authentik', 'clientSecret')` →
@@ -6033,6 +6040,75 @@ function encodeSegment(value) {
6033
6040
  function arrayItemFieldPath(arrayKey, itemId, fieldKey) {
6034
6041
  return `${arrayKey}[${encodeSegment(itemId)}].${fieldKey}`;
6035
6042
  }
6043
+ function parseScope(segments) {
6044
+ switch (segments[0]) {
6045
+ case "global": return {
6046
+ scope: GLOBAL_SCOPE,
6047
+ used: 1
6048
+ };
6049
+ case "node": {
6050
+ const nodeId = segments[1] !== void 0 ? decodeSegment(segments[1]) : null;
6051
+ return nodeId === null || nodeId.length === 0 ? null : {
6052
+ scope: {
6053
+ kind: "node",
6054
+ nodeId
6055
+ },
6056
+ used: 2
6057
+ };
6058
+ }
6059
+ case "device": {
6060
+ const raw = segments[1];
6061
+ if (raw === void 0 || !/^\d+$/.test(raw)) return null;
6062
+ return {
6063
+ scope: {
6064
+ kind: "device",
6065
+ deviceId: Number(raw)
6066
+ },
6067
+ used: 2
6068
+ };
6069
+ }
6070
+ case "integration": {
6071
+ const id = segments[1] !== void 0 ? decodeSegment(segments[1]) : null;
6072
+ return id === null || id.length === 0 ? null : {
6073
+ scope: {
6074
+ kind: "integration",
6075
+ integrationId: id
6076
+ },
6077
+ used: 2
6078
+ };
6079
+ }
6080
+ case "row": {
6081
+ const collection = segments[1] !== void 0 ? decodeSegment(segments[1]) : null;
6082
+ const rowId = segments[2] !== void 0 ? decodeSegment(segments[2]) : null;
6083
+ if (collection === null || rowId === null || collection.length === 0 || rowId.length === 0) return null;
6084
+ return {
6085
+ scope: {
6086
+ kind: "row",
6087
+ collection,
6088
+ rowId
6089
+ },
6090
+ used: 3
6091
+ };
6092
+ }
6093
+ default: return null;
6094
+ }
6095
+ }
6096
+ /** Take a ref apart; `null` when it is not a well-formed ref. */
6097
+ function parseSecretRef(ref) {
6098
+ if (!ref.startsWith("secret://")) return null;
6099
+ const segments = ref.slice(9).split("/");
6100
+ const owner = segments[0] !== void 0 ? decodeSegment(segments[0]) : null;
6101
+ if (owner === null || owner.length === 0) return null;
6102
+ const parsed = parseScope(segments.slice(1));
6103
+ if (parsed === null) return null;
6104
+ const fieldPath = segments.slice(1 + parsed.used).join("/");
6105
+ if (fieldPath.length === 0) return null;
6106
+ return {
6107
+ owner,
6108
+ scope: parsed.scope,
6109
+ fieldPath
6110
+ };
6111
+ }
6036
6112
  /** A write to a secret path could not be stored in the keychain, so it was refused. */
6037
6113
  var KeychainWriteRefusedError = class extends Error {
6038
6114
  fieldPath;
@@ -6043,7 +6119,7 @@ var KeychainWriteRefusedError = class extends Error {
6043
6119
  }
6044
6120
  };
6045
6121
  var KEEP = { kind: "keep" };
6046
- function isRecord(value) {
6122
+ function isRecord$1(value) {
6047
6123
  return typeof value === "object" && value !== null && !Array.isArray(value);
6048
6124
  }
6049
6125
  function defaultMintId() {
@@ -6056,7 +6132,7 @@ function collectSecretMarkerRefs(value, out = []) {
6056
6132
  return out;
6057
6133
  }
6058
6134
  if (Array.isArray(value)) for (const item of value) collectSecretMarkerRefs(item, out);
6059
- else if (isRecord(value)) for (const child of Object.values(value)) collectSecretMarkerRefs(child, out);
6135
+ else if (isRecord$1(value)) for (const child of Object.values(value)) collectSecretMarkerRefs(child, out);
6060
6136
  return out;
6061
6137
  }
6062
6138
  async function storedValueEquals(secrets, marker, candidate) {
@@ -6111,7 +6187,7 @@ function rowId(row, idKey) {
6111
6187
  return null;
6112
6188
  }
6113
6189
  async function writeArray(ctx, node, incoming, stored, fieldPath) {
6114
- const storedRows = Array.isArray(stored) ? stored.filter(isRecord) : [];
6190
+ const storedRows = Array.isArray(stored) ? stored.filter(isRecord$1) : [];
6115
6191
  if (!Array.isArray(incoming)) {
6116
6192
  ctx.deletes.push(...collectSecretMarkerRefs(storedRows));
6117
6193
  return {
@@ -6127,7 +6203,7 @@ async function writeArray(ctx, node, incoming, stored, fieldPath) {
6127
6203
  const kept = /* @__PURE__ */ new Set();
6128
6204
  const rows = [];
6129
6205
  for (const row of incoming) {
6130
- if (!isRecord(row)) {
6206
+ if (!isRecord$1(row)) {
6131
6207
  rows.push(row);
6132
6208
  continue;
6133
6209
  }
@@ -6152,7 +6228,7 @@ async function writeNode(ctx, node, incoming, stored, fieldPath) {
6152
6228
  case "leaf": return writeLeaf(ctx, incoming, stored, fieldPath);
6153
6229
  case "array": return writeArray(ctx, node, incoming, stored, fieldPath);
6154
6230
  case "object": {
6155
- if (!isRecord(incoming)) {
6231
+ if (!isRecord$1(incoming)) {
6156
6232
  if (incoming === void 0) return KEEP;
6157
6233
  ctx.deletes.push(...collectSecretMarkerRefs(stored));
6158
6234
  return {
@@ -6160,7 +6236,7 @@ async function writeNode(ctx, node, incoming, stored, fieldPath) {
6160
6236
  value: incoming
6161
6237
  };
6162
6238
  }
6163
- const storedObj = isRecord(stored) ? stored : {};
6239
+ const storedObj = isRecord$1(stored) ? stored : {};
6164
6240
  return {
6165
6241
  kind: "value",
6166
6242
  value: await writeMembers(ctx, node.children, incoming, storedObj, (m) => `${fieldPath}.${m}`)
@@ -6219,12 +6295,19 @@ async function transformSecretWrite(input) {
6219
6295
  }
6220
6296
  };
6221
6297
  }
6298
+ /** Is `ref` one of `owner`'s refs? */
6299
+ function isSecretRefOwnedBy(ref, owner) {
6300
+ return parseSecretRef(ref)?.owner === owner;
6301
+ }
6222
6302
  /**
6223
6303
  * Replace every marker in `value` with its keychain value. Returns the SAME
6224
6304
  * reference when there is no marker (no allocation, no keychain call).
6225
6305
  */
6226
- async function resolveSecretMarkers(value, secrets) {
6227
- const refs = collectSecretMarkerRefs(value);
6306
+ async function resolveSecretMarkers(value, secrets, options = {}) {
6307
+ const keepMarker = options.unresolved === "keep-marker";
6308
+ const owner = options.ownedBy;
6309
+ const inScope = (ref) => owner === void 0 || isSecretRefOwnedBy(ref, owner);
6310
+ const refs = collectSecretMarkerRefs(value).filter(inScope);
6228
6311
  if (refs.length === 0) return {
6229
6312
  value,
6230
6313
  unresolved: []
@@ -6248,10 +6331,18 @@ async function resolveSecretMarkers(value, secrets) {
6248
6331
  }
6249
6332
  const substitute = (v) => {
6250
6333
  if (isSecretMarker(v)) {
6334
+ if (!inScope(v.$secret)) return {
6335
+ keep: true,
6336
+ value: v
6337
+ };
6251
6338
  const answer = answers[v.$secret];
6252
- return answer?.kind === "value" ? {
6339
+ if (answer?.kind === "value") return {
6253
6340
  keep: true,
6254
6341
  value: answer.value
6342
+ };
6343
+ return keepMarker ? {
6344
+ keep: true,
6345
+ value: v
6255
6346
  } : {
6256
6347
  keep: false,
6257
6348
  value: void 0
@@ -6268,7 +6359,7 @@ async function resolveSecretMarkers(value, secrets) {
6268
6359
  value: items
6269
6360
  };
6270
6361
  }
6271
- if (isRecord(v)) {
6362
+ if (isRecord$1(v)) {
6272
6363
  const out = {};
6273
6364
  for (const [k, child] of Object.entries(v)) {
6274
6365
  const s = substitute(child);
@@ -6289,14 +6380,152 @@ async function resolveSecretMarkers(value, secrets) {
6289
6380
  unresolved
6290
6381
  };
6291
6382
  }
6292
- function touchesTree(tree, patch) {
6293
- if (tree.size === 0) return false;
6294
- for (const key of Object.keys(patch)) {
6295
- const at = key.indexOf("@");
6296
- if (tree.has(at > 0 ? key.slice(0, at) : key)) return true;
6383
+ /** An addon tried to replace a stored secret it could not read. Nothing was written. */
6384
+ var SecretOverwriteRefusedError = class extends Error {
6385
+ ref;
6386
+ reason;
6387
+ constructor(ref, reason) {
6388
+ 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.`);
6389
+ this.ref = ref;
6390
+ this.reason = reason;
6391
+ this.name = "SecretOverwriteRefusedError";
6392
+ }
6393
+ };
6394
+ function isRecord(value) {
6395
+ return typeof value === "object" && value !== null && !Array.isArray(value);
6396
+ }
6397
+ function resolvedValue(pass, marker) {
6398
+ const answer = pass.answers[marker.$secret];
6399
+ return answer?.kind === "value" ? answer.value : null;
6400
+ }
6401
+ async function atMarker(pass, incoming, stored) {
6402
+ if (incoming === null) return stored;
6403
+ if (typeof incoming !== "string") return incoming;
6404
+ if (incoming === resolvedValue(pass, stored)) return stored;
6405
+ const intent = classifySecretWrite(incoming);
6406
+ if (intent.kind !== "set") return stored;
6407
+ const ref = stored.$secret;
6408
+ if (!isSecretRefOwnedBy(ref, pass.secrets.owner)) return incoming;
6409
+ const answer = pass.answers[ref];
6410
+ 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);
6411
+ try {
6412
+ await pass.secrets.put(ref, intent.value);
6413
+ } catch (err) {
6414
+ throw new KeychainWriteRefusedError(ref, err);
6415
+ }
6416
+ pass.changedRefs.push(ref);
6417
+ return stored;
6418
+ }
6419
+ function inArray(pass, incoming, stored) {
6420
+ return incoming.map((item, index) => {
6421
+ const twin = stored[index];
6422
+ if (isSecretMarker(twin)) return typeof item === "string" && item === resolvedValue(pass, twin) ? twin : item;
6423
+ if (isRecord(item) && isRecord(twin)) return inArrayRow(pass, item, twin);
6424
+ if (Array.isArray(item) && Array.isArray(twin)) return inArray(pass, item, twin);
6425
+ return item;
6426
+ });
6427
+ }
6428
+ function inArrayRow(pass, incoming, stored) {
6429
+ const out = { ...incoming };
6430
+ for (const [key, value] of Object.entries(incoming)) {
6431
+ const twin = stored[key];
6432
+ if (isSecretMarker(twin)) {
6433
+ if (typeof value === "string" && value === resolvedValue(pass, twin)) out[key] = twin;
6434
+ } else if (isRecord(value) && isRecord(twin)) out[key] = inArrayRow(pass, value, twin);
6435
+ else if (Array.isArray(value) && Array.isArray(twin)) out[key] = inArray(pass, value, twin);
6436
+ }
6437
+ return out;
6438
+ }
6439
+ async function walk(pass, incoming, stored) {
6440
+ if (isSecretMarker(stored)) return atMarker(pass, incoming, stored);
6441
+ if (Array.isArray(incoming) && Array.isArray(stored)) return inArray(pass, incoming, stored);
6442
+ if (!isRecord(incoming) || !isRecord(stored)) return incoming;
6443
+ const out = { ...incoming };
6444
+ for (const [key, value] of Object.entries(incoming)) out[key] = await walk(pass, value, stored[key]);
6445
+ return out;
6446
+ }
6447
+ /** Restore markers a write-back carries as values. See the file doc. */
6448
+ async function restoreUnchangedSecrets(input) {
6449
+ const refs = [];
6450
+ for (const key of Object.keys(input.patch)) collectSecretMarkerRefs(input.stored[key], refs);
6451
+ const owned = refs.filter((ref) => isSecretRefOwnedBy(ref, input.secrets.owner));
6452
+ if (owned.length === 0) return {
6453
+ patch: input.patch,
6454
+ changedRefs: []
6455
+ };
6456
+ const pass = {
6457
+ secrets: input.secrets,
6458
+ answers: await input.secrets.resolve([...new Set(owned)]),
6459
+ operatorWrite: input.operatorWrite,
6460
+ changedRefs: []
6461
+ };
6462
+ const out = {};
6463
+ for (const [key, value] of Object.entries(input.patch)) out[key] = await walk(pass, value, input.stored[key]);
6464
+ return {
6465
+ patch: out,
6466
+ changedRefs: pass.changedRefs
6467
+ };
6468
+ }
6469
+ /** Structural equality over JSON-shaped values (key order does not matter). */
6470
+ function isJsonEqual(a, b) {
6471
+ if (Object.is(a, b)) return true;
6472
+ if (Array.isArray(a)) return Array.isArray(b) && a.length === b.length && a.every((v, i) => isJsonEqual(v, b[i]));
6473
+ if (isRecord(a) && isRecord(b)) {
6474
+ const keys = Object.keys(a);
6475
+ if (keys.length !== Object.keys(b).length) return false;
6476
+ return keys.every((k) => Object.prototype.hasOwnProperty.call(b, k) && isJsonEqual(a[k], b[k]));
6297
6477
  }
6298
6478
  return false;
6299
6479
  }
6480
+ /** The patch without the keys whose value already equals the stored one. */
6481
+ function dropUnchangedKeys(patch, stored) {
6482
+ const out = {};
6483
+ for (const [key, value] of Object.entries(patch)) {
6484
+ if (Object.prototype.hasOwnProperty.call(stored, key) && isJsonEqual(value, stored[key])) continue;
6485
+ out[key] = value;
6486
+ }
6487
+ return out;
6488
+ }
6489
+ /** The top-level keys of a blob that hold at least one of `owner`'s markers. */
6490
+ function markerKeysOf(blob, owner) {
6491
+ const keys = /* @__PURE__ */ new Set();
6492
+ for (const [key, value] of Object.entries(blob)) if (collectSecretMarkerRefs(value).some((ref) => isSecretRefOwnedBy(ref, owner))) keys.add(key);
6493
+ return keys;
6494
+ }
6495
+ function nodeFromStored(value, owner) {
6496
+ if (isSecretMarker(value)) return isSecretRefOwnedBy(value.$secret, owner) ? { kind: "leaf" } : null;
6497
+ if (!isRecord(value)) return null;
6498
+ const children = /* @__PURE__ */ new Map();
6499
+ for (const [key, child] of Object.entries(value)) {
6500
+ const node = nodeFromStored(child, owner);
6501
+ if (node !== null) children.set(key, node);
6502
+ }
6503
+ return children.size > 0 ? {
6504
+ kind: "object",
6505
+ children
6506
+ } : null;
6507
+ }
6508
+ /**
6509
+ * The declared secret tree, widened by every place the STORED blob holds a
6510
+ * marker under one of `keys` — so a marker the schema no longer declares (or
6511
+ * never declared: Wyze before b4906cec6) still gets the save path's
6512
+ * KEEP / SET / CLEAR semantics instead of being overwritten by whatever the
6513
+ * addon writes. Markers inside arrays are not added: a row has no id field to
6514
+ * match by unless the schema declares one. Only `owner`'s markers count: a
6515
+ * builtin that keeps another addon's marker (device-manager) never takes it
6516
+ * over.
6517
+ */
6518
+ function widenTreeWithStoredMarkers(declared, stored, keys, owner) {
6519
+ const added = /* @__PURE__ */ new Map();
6520
+ for (const key of keys) {
6521
+ const at = key.indexOf("@");
6522
+ const base = at > 0 ? key.slice(0, at) : key;
6523
+ if (declared.has(base) || added.has(base)) continue;
6524
+ const node = nodeFromStored(stored[key], owner);
6525
+ if (node !== null) added.set(base, node);
6526
+ }
6527
+ return added.size === 0 ? declared : new Map([...declared, ...added]);
6528
+ }
6300
6529
  /** The blob as stored now; a failed read REFUSES the write instead of guessing. */
6301
6530
  async function readStoredAddonBlob(raw) {
6302
6531
  const threeWay = raw.readAddonStoreResult;
@@ -6305,7 +6534,41 @@ async function readStoredAddonBlob(raw) {
6305
6534
  if (result.kind === "failed") throw new Error(`settings write refused: the stored blob could not be read (${result.error})`);
6306
6535
  return result.kind === "missing" ? {} : result.value;
6307
6536
  }
6308
- function createSecretAwareSettings(raw, opts) {
6537
+ function touchesTree(tree, patch) {
6538
+ if (tree.size === 0) return false;
6539
+ for (const key of Object.keys(patch)) {
6540
+ const at = key.indexOf("@");
6541
+ if (tree.has(at > 0 ? key.slice(0, at) : key)) return true;
6542
+ }
6543
+ return false;
6544
+ }
6545
+ /**
6546
+ * Which top-level keys of each store held markers when last seen. `undefined`
6547
+ * for a store not seen yet: its first write reads it, to be safe.
6548
+ */
6549
+ var MarkerKeyIndex = class {
6550
+ owner;
6551
+ byStore = /* @__PURE__ */ new Map();
6552
+ constructor(owner) {
6553
+ this.owner = owner;
6554
+ }
6555
+ seen(store, blob) {
6556
+ this.byStore.set(store, markerKeysOf(blob, this.owner));
6557
+ }
6558
+ wrote(store, patch) {
6559
+ const keys = this.byStore.get(store);
6560
+ if (keys === void 0) return;
6561
+ const now = markerKeysOf(patch, this.owner);
6562
+ for (const key of Object.keys(patch)) if (now.has(key)) keys.add(key);
6563
+ else keys.delete(key);
6564
+ }
6565
+ mayHoldMarkers(store, patch) {
6566
+ const keys = this.byStore.get(store);
6567
+ if (keys === void 0) return true;
6568
+ return Object.keys(patch).some((key) => keys.has(key));
6569
+ }
6570
+ };
6571
+ function createHandle(raw, opts) {
6309
6572
  const chains = /* @__PURE__ */ new Map();
6310
6573
  const serialize = (key, fn) => {
6311
6574
  const next = (chains.get(key) ?? Promise.resolve()).then(fn, fn);
@@ -6316,46 +6579,130 @@ function createSecretAwareSettings(raw, opts) {
6316
6579
  });
6317
6580
  return next;
6318
6581
  };
6319
- const write = async (chainKey, tree, scope, patch, readStored, rawWrite) => {
6320
- if (!touchesTree(tree, patch)) return rawWrite(patch);
6321
- return serialize(chainKey, async () => {
6582
+ const index = new MarkerKeyIndex(opts.secrets.owner);
6583
+ const resolveRead = async (store, blob) => {
6584
+ index.seen(store, blob);
6585
+ const { value, unresolved } = await resolveSecretMarkers(blob, opts.secrets, {
6586
+ unresolved: "keep-marker",
6587
+ ownedBy: opts.secrets.owner
6588
+ });
6589
+ if (unresolved.length > 0) opts.onUnresolved?.(unresolved);
6590
+ return value;
6591
+ };
6592
+ const write = async (store, declared, scope, patch, readStored, rawWrite) => {
6593
+ if (!touchesTree(declared, patch) && !index.mayHoldMarkers(store, patch)) {
6594
+ await rawWrite(patch);
6595
+ index.wrote(store, patch);
6596
+ return { changed: true };
6597
+ }
6598
+ return serialize(store, async () => {
6322
6599
  const stored = await readStored();
6600
+ index.seen(store, stored);
6601
+ const operatorWrite = opts.isOperatorWrite?.() === true;
6602
+ const restored = await restoreUnchangedSecrets({
6603
+ patch,
6604
+ stored,
6605
+ secrets: opts.secrets,
6606
+ operatorWrite
6607
+ });
6323
6608
  const result = await transformSecretWrite({
6324
- tree,
6609
+ tree: widenTreeWithStoredMarkers(declared, stored, Object.keys(restored.patch), opts.secrets.owner),
6325
6610
  secrets: opts.secrets,
6326
- patch,
6611
+ patch: restored.patch,
6327
6612
  stored,
6328
6613
  ...scope !== void 0 ? { scope } : {},
6329
- operatorWrite: opts.isOperatorWrite?.() === true
6614
+ operatorWrite
6330
6615
  });
6331
- if (Object.keys(result.patch).length > 0) await rawWrite(result.patch);
6616
+ const effective = dropUnchangedKeys(result.patch, stored);
6617
+ const wroteBlob = Object.keys(effective).length > 0;
6618
+ if (wroteBlob) {
6619
+ await rawWrite(effective);
6620
+ index.wrote(store, effective);
6621
+ }
6332
6622
  const { orphaned } = await result.afterWrite();
6333
6623
  if (orphaned.length > 0) opts.onOrphaned(orphaned);
6624
+ return { changed: wroteBlob || restored.changedRefs.length > 0 };
6334
6625
  });
6335
6626
  };
6336
- const wrapped = {
6337
- writeAddonStore: (patch) => write("addon", opts.addonTree(), void 0, patch, () => readStoredAddonBlob(raw), (p) => raw.writeAddonStore(p)),
6338
- writeDeviceStore: (deviceId, patch) => write(`device:${deviceId}`, opts.deviceTree(), {
6339
- kind: "device",
6340
- deviceId
6341
- }, patch, () => raw.readDeviceStore(deviceId), (p) => raw.writeDeviceStore(deviceId, p))
6627
+ const writeAddon = (patch) => write("addon", opts.addonTree(), void 0, patch, () => readStoredAddonBlob(raw), (p) => raw.writeAddonStore(p));
6628
+ const readAddonStoreResult = raw.readAddonStoreResult;
6629
+ const readAddonStoreKeyResult = raw.readAddonStoreKeyResult;
6630
+ const readDeviceStoreBatch = raw.readDeviceStoreBatch;
6631
+ const overrides = {
6632
+ readAddonStore: async () => resolveRead("addon", await raw.readAddonStore()),
6633
+ ...readAddonStoreResult !== void 0 ? { readAddonStoreResult: async () => {
6634
+ const result = await readAddonStoreResult.call(raw);
6635
+ return result.kind === "value" ? {
6636
+ kind: "value",
6637
+ value: await resolveRead("addon", result.value)
6638
+ } : result;
6639
+ } } : {},
6640
+ ...readAddonStoreKeyResult !== void 0 ? { readAddonStoreKeyResult: async (key) => {
6641
+ const result = await readAddonStoreKeyResult.call(raw, key);
6642
+ if (result.kind !== "present") return result;
6643
+ const { value, unresolved } = await resolveSecretMarkers({ [key]: result.value }, opts.secrets, {
6644
+ unresolved: "keep-marker",
6645
+ ownedBy: opts.secrets.owner
6646
+ });
6647
+ if (unresolved.length > 0) opts.onUnresolved?.(unresolved);
6648
+ return {
6649
+ kind: "present",
6650
+ value: value[key]
6651
+ };
6652
+ } } : {},
6653
+ readDeviceStore: async (deviceId) => resolveRead(`device:${deviceId}`, await raw.readDeviceStore(deviceId)),
6654
+ ...readDeviceStoreBatch !== void 0 ? { readDeviceStoreBatch: async (deviceIds) => {
6655
+ const rows = await readDeviceStoreBatch.call(raw, deviceIds);
6656
+ const out = /* @__PURE__ */ new Map();
6657
+ for (const [deviceId, blob] of rows) out.set(deviceId, await resolveRead(`device:${deviceId}`, blob));
6658
+ return out;
6659
+ } } : {},
6660
+ writeAddonStore: async (patch) => {
6661
+ await writeAddon(patch);
6662
+ },
6663
+ writeDeviceStore: async (deviceId, patch) => {
6664
+ await write(`device:${deviceId}`, opts.deviceTree(), {
6665
+ kind: "device",
6666
+ deviceId
6667
+ }, patch, () => raw.readDeviceStore(deviceId), (p) => raw.writeDeviceStore(deviceId, p));
6668
+ }
6669
+ };
6670
+ return {
6671
+ settings: new Proxy(raw, { get(target, prop, receiver) {
6672
+ if (typeof prop === "string" && Object.prototype.hasOwnProperty.call(overrides, prop)) return Reflect.get(overrides, prop);
6673
+ const value = Reflect.get(target, prop, receiver);
6674
+ return typeof value === "function" ? value.bind(target) : value;
6675
+ } }),
6676
+ raw: {
6677
+ readAddonStore: async () => {
6678
+ const blob = await raw.readAddonStore();
6679
+ index.seen("addon", blob);
6680
+ return blob;
6681
+ },
6682
+ readDeviceStore: async (deviceId) => {
6683
+ const blob = await raw.readDeviceStore(deviceId);
6684
+ index.seen(`device:${deviceId}`, blob);
6685
+ return blob;
6686
+ }
6687
+ },
6688
+ writeAddonStore: writeAddon
6342
6689
  };
6343
- return new Proxy(raw, { get(target, prop, receiver) {
6344
- if (prop === "writeAddonStore") return wrapped.writeAddonStore;
6345
- if (prop === "writeDeviceStore") return wrapped.writeDeviceStore;
6346
- const value = Reflect.get(target, prop, receiver);
6347
- return typeof value === "function" ? value.bind(target) : value;
6348
- } });
6349
6690
  }
6350
- /** The context the addon sees: identical, except that its settings writes are secret-aware. */
6351
- function withSecretAwareSettings(context, opts) {
6691
+ /** The context the addon sees, plus the private raw view and write outcome. */
6692
+ function createSecretAwareContext(context, opts) {
6352
6693
  const raw = context.settings;
6353
- if (raw === void 0) return context;
6354
- const settings = createSecretAwareSettings(raw, opts);
6355
- return new Proxy(context, { get(target, prop, receiver) {
6356
- if (prop === "settings") return settings;
6357
- return Reflect.get(target, prop, receiver);
6358
- } });
6694
+ if (raw === void 0) return {
6695
+ context,
6696
+ handle: null
6697
+ };
6698
+ const handle = createHandle(raw, opts);
6699
+ return {
6700
+ context: new Proxy(context, { get(target, prop, receiver) {
6701
+ if (prop === "settings") return handle.settings;
6702
+ return Reflect.get(target, prop, receiver);
6703
+ } }),
6704
+ handle
6705
+ };
6359
6706
  }
6360
6707
  var LEAF = { kind: "leaf" };
6361
6708
  var DEFAULT_ITEM_ID_KEY = "id";
@@ -6530,6 +6877,14 @@ var BaseAddon = class {
6530
6877
  _secretChangeUnsub = null;
6531
6878
  /** >0 while an OPERATOR's settings write is being applied. */
6532
6879
  _operatorWriteDepth = 0;
6880
+ /**
6881
+ * The keychain-aware settings handle (D798). Its `raw` view is the ONLY way
6882
+ * to the marker-bearing blobs and stays private to this class: the form
6883
+ * hydrate and config resolution need markers, addon code never does.
6884
+ */
6885
+ _secretSettings = null;
6886
+ /** Refs an addon-facing read could not resolve — each is logged once per process. */
6887
+ _loggedUnresolvedReads = /* @__PURE__ */ new Set();
6533
6888
  constructor(defaults) {
6534
6889
  this.defaults = defaults;
6535
6890
  this._config = { ...defaults };
@@ -6566,13 +6921,21 @@ var BaseAddon = class {
6566
6921
  }
6567
6922
  async initialize(context) {
6568
6923
  const secrets = context.secrets;
6569
- this._ctx = secrets !== void 0 ? withSecretAwareSettings(context, {
6570
- secrets,
6571
- addonTree: () => this.addonSecretTree(),
6572
- deviceTree: () => this.deviceSecretTree(),
6573
- onOrphaned: (refs) => context.logger.warn("keychain refs dropped by a settings write could not be deleted", { meta: { refs: [...refs] } }),
6574
- isOperatorWrite: () => this._operatorWriteDepth > 0
6575
- }) : context;
6924
+ if (secrets !== void 0) {
6925
+ const { context: wrapped, handle } = createSecretAwareContext(context, {
6926
+ secrets,
6927
+ addonTree: () => this.addonSecretTree(),
6928
+ deviceTree: () => this.deviceSecretTree(),
6929
+ onOrphaned: (refs) => context.logger.warn("keychain refs dropped by a settings write could not be deleted", { meta: { refs: [...refs] } }),
6930
+ isOperatorWrite: () => this._operatorWriteDepth > 0,
6931
+ onUnresolved: (unresolved) => this.logUnresolvedRead(unresolved)
6932
+ });
6933
+ this._ctx = wrapped;
6934
+ this._secretSettings = handle;
6935
+ } else {
6936
+ this._ctx = context;
6937
+ this._secretSettings = null;
6938
+ }
6576
6939
  await this.resolveConfig();
6577
6940
  if (secrets !== void 0) this._secretChangeUnsub = secrets.onChange((ref) => {
6578
6941
  if (this._configSecretRefs.has(ref)) this.scheduleSecretReresolve(SECRET_CHANGE_DEBOUNCE_MS);
@@ -6689,11 +7052,8 @@ var BaseAddon = class {
6689
7052
  async getGlobalSettings(overlay, cap, nodeId) {
6690
7053
  const schema = this.globalSettingsSchema(cap);
6691
7054
  if (!schema) return { sections: [] };
6692
- const projected = await this.resolveGlobalStore(nodeId, cap);
6693
- return hydrateSchema(schema, overlay ? {
6694
- ...projected,
6695
- ...overlay
6696
- } : projected, { inlineSecretsAsViews: true });
7055
+ const projected = await this.readRawProjectedStore(nodeId, cap);
7056
+ return hydrateSchema(schema, overlay ? await this.overlayKeepingMarkers(projected, overlay) : projected, { inlineSecretsAsViews: true });
6697
7057
  }
6698
7058
  /**
6699
7059
  * The integration-level view of this addon's settings: exactly the sections
@@ -6738,7 +7098,7 @@ var BaseAddon = class {
6738
7098
  });
6739
7099
  }
6740
7100
  if (sections.length === 0) return null;
6741
- const projected = await this.resolveGlobalStore(nodeId);
7101
+ const projected = await this.readRawProjectedStore(nodeId);
6742
7102
  return hydrateSchema({
6743
7103
  ...schema,
6744
7104
  sections
@@ -6755,12 +7115,50 @@ var BaseAddon = class {
6755
7115
  * the store for custom option logic (option narrowing, value snapping) to
6756
7116
  * read it per-node — never `ctx.settings.readAddonStore()` directly.
6757
7117
  * `nodeId` omitted ⇒ the local node (node-blind injection from ctx).
7118
+ *
7119
+ * Keychain values come back RESOLVED (D798): a secret reads as its value,
7120
+ * never as a `{ $secret }` marker. One the keychain cannot serve right now
7121
+ * stays a marker — "stored, unavailable" (`isSecretMarker()` is true, and it
7122
+ * is listed in {@link unresolvedSecrets}) — never `''` and never absent, so
7123
+ * it cannot be mistaken for "nothing stored, mint a new one". Writing the
7124
+ * resolved blob back is a no-op for every unchanged secret.
6758
7125
  */
6759
7126
  async resolveGlobalStore(nodeId, cap) {
6760
7127
  const raw = await this._ctx?.settings?.readAddonStore() ?? {};
7128
+ return this.projectForNode(raw, nodeId, cap);
7129
+ }
7130
+ projectForNode(store, nodeId, cap) {
6761
7131
  const keys = this.perNodeKeys(cap);
6762
7132
  const node = normalizeNodeId(nodeId ?? this._ctx?.kernel?.localNodeId);
6763
- return keys.size > 0 ? projectStore(raw, keys, node) : raw;
7133
+ return keys.size > 0 ? projectStore(store, keys, node) : store;
7134
+ }
7135
+ /** The PROJECTED store with its markers — the form hydrate only (D798). */
7136
+ async readRawProjectedStore(nodeId, cap) {
7137
+ const raw = await this.rawSettings()?.readAddonStore() ?? {};
7138
+ return this.projectForNode(raw, nodeId, cap);
7139
+ }
7140
+ /**
7141
+ * `{ ...stored, ...overlay }`, except that an overlay member equal to the
7142
+ * RESOLVED stored one keeps the stored (marker-bearing) member — so a form
7143
+ * hydrated from a resolved overlay still shows a secret as "set", never as
7144
+ * its value.
7145
+ */
7146
+ async overlayKeepingMarkers(stored, overlay) {
7147
+ const secrets = this._ctx?.secrets;
7148
+ const merged = {
7149
+ ...stored,
7150
+ ...overlay
7151
+ };
7152
+ if (secrets === void 0 || collectSecretMarkerRefs(stored).length === 0) return merged;
7153
+ const { value: resolved } = await resolveSecretMarkers(stored, secrets, {
7154
+ unresolved: "keep-marker",
7155
+ ownedBy: secrets.owner
7156
+ });
7157
+ for (const key of Object.keys(overlay)) {
7158
+ if (collectSecretMarkerRefs(stored[key]).length === 0) continue;
7159
+ if (isJsonEqual(overlay[key], resolved[key])) merged[key] = stored[key];
7160
+ }
7161
+ return merged;
6764
7162
  }
6765
7163
  /**
6766
7164
  * Whether ONE global key of this addon's store was written, read three-way
@@ -6825,8 +7223,12 @@ var BaseAddon = class {
6825
7223
  async clearSecrets(keys, nodeId) {
6826
7224
  const tree = this.addonSecretTree();
6827
7225
  const keychain = this._ctx?.secrets !== void 0;
7226
+ const stored = keychain ? await this.readAddonStoreWithRetry() : {};
6828
7227
  const patch = {};
6829
- for (const key of keys) patch[key] = keychain && tree.has(key) ? SECRET_CLEAR : "";
7228
+ for (const key of keys) {
7229
+ const keychainStored = tree.has(key) || collectSecretMarkerRefs(stored[key]).length > 0;
7230
+ patch[key] = keychain && keychainStored ? SECRET_CLEAR : "";
7231
+ }
6830
7232
  await this.applyGlobalPatch(patch, nodeId);
6831
7233
  }
6832
7234
  async applyGlobalPatch(barePatch, nodeId) {
@@ -6834,7 +7236,11 @@ var BaseAddon = class {
6834
7236
  const localNode = normalizeNodeId(this._ctx?.kernel?.localNodeId);
6835
7237
  const target = normalizeNodeId(nodeId ?? this._ctx?.kernel?.localNodeId);
6836
7238
  const scoped = keys.size > 0 ? scopePatch(barePatch, keys, target) : barePatch;
6837
- await this._ctx?.settings?.writeAddonStore(scoped);
7239
+ const handle = this._secretSettings;
7240
+ if (handle !== null) {
7241
+ const { changed } = await handle.writeAddonStore(scoped);
7242
+ if (!changed) return;
7243
+ } else await this._ctx?.settings?.writeAddonStore(scoped);
6838
7244
  if (target !== localNode) return;
6839
7245
  await this.resolveConfig();
6840
7246
  await this.onConfigChanged();
@@ -6887,7 +7293,7 @@ var BaseAddon = class {
6887
7293
  async getDeviceSettings(deviceId) {
6888
7294
  const schema = this.deviceSettingsSchema();
6889
7295
  if (!schema) return { sections: [] };
6890
- return hydrateSchema(schema, await this._ctx?.settings?.readDeviceStore(deviceId) ?? {}, { inlineSecretsAsViews: true });
7296
+ return hydrateSchema(schema, await this.rawSettings()?.readDeviceStore(deviceId) ?? {}, { inlineSecretsAsViews: true });
6891
7297
  }
6892
7298
  async updateDeviceSettings(deviceId, patch) {
6893
7299
  await this._ctx?.settings?.writeDeviceStore(deviceId, patch);
@@ -7059,7 +7465,7 @@ var BaseAddon = class {
7059
7465
  key,
7060
7466
  schema,
7061
7467
  fallback,
7062
- read: async () => this.resolveStoredSecrets(await this._ctx?.settings?.readDeviceStore(deviceId) ?? {}, false),
7468
+ read: async () => this.resolveStoredSecrets(await this.rawSettings()?.readDeviceStore(deviceId) ?? {}, false),
7063
7469
  write: async (patch) => {
7064
7470
  await this._ctx?.settings?.writeDeviceStore(deviceId, patch);
7065
7471
  },
@@ -7121,6 +7527,23 @@ var BaseAddon = class {
7121
7527
  }
7122
7528
  return value;
7123
7529
  }
7530
+ /**
7531
+ * The marker-bearing settings reads (D798) — private on purpose. Without a
7532
+ * keychain the context's own view is already raw.
7533
+ */
7534
+ rawSettings() {
7535
+ return this._secretSettings?.raw ?? this._ctx?.settings;
7536
+ }
7537
+ /** An addon-facing read met markers it could not resolve: say so once per ref. */
7538
+ logUnresolvedRead(unresolved) {
7539
+ const fresh = unresolved.filter((u) => !this._loggedUnresolvedReads.has(u.ref));
7540
+ if (fresh.length === 0) return;
7541
+ for (const u of fresh) this._loggedUnresolvedReads.add(u.ref);
7542
+ 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) => ({
7543
+ ref: u.ref,
7544
+ reason: u.reason
7545
+ })) } });
7546
+ }
7124
7547
  /** Re-resolve the config (a keychain-only change, or a retry) and apply it. */
7125
7548
  scheduleSecretReresolve(delayMs) {
7126
7549
  const timerOf = delayMs === SECRET_CHANGE_DEBOUNCE_MS ? "_secretChangeTimer" : "_secretRetryTimer";
@@ -7147,7 +7570,7 @@ var BaseAddon = class {
7147
7570
  * `{}` (defaults) — the addon's first successful patch will rehydrate.
7148
7571
  */
7149
7572
  async readAddonStoreWithRetry() {
7150
- const settings = this._ctx?.settings;
7573
+ const settings = this.rawSettings();
7151
7574
  if (!settings) return {};
7152
7575
  const delaysMs = [
7153
7576
  150,
@@ -9450,6 +9873,278 @@ var CameraSwitchGroupSchema = object({
9450
9873
  fetchedAt: number()
9451
9874
  });
9452
9875
  /**
9876
+ * The trainer contract — what the hub hands the cloud trainer and what it
9877
+ * gets back (cloud training, D805+).
9878
+ *
9879
+ * The trainer (`hf/camstack-trainer`, published as the Hugging Face repo
9880
+ * `camstack/camstack-trainer`) is a separate AGPL program the hub never
9881
+ * imports: `job.json` goes in, files come out, and progress is `CAMSTACK_EVENT`
9882
+ * lines on stdout. These schemas are the hub's half of that boundary; the
9883
+ * trainer's pydantic models (and the JSON Schemas generated from them under
9884
+ * `hf/camstack-trainer/schemas/`) are the other half. A change here is a
9885
+ * change there, in the same piece of work.
9886
+ *
9887
+ * No `.default()` anywhere: defaults do not run on the addon cap path, so the
9888
+ * orchestrator fills every field of a job spec explicitly.
9889
+ */
9890
+ var TRAINING_JOB_SCHEMA = "camstack.training/v1";
9891
+ var TRAINING_RESULT_SCHEMA = "camstack.training-result/v1";
9892
+ /** What the trainer can export. Edge TPU is a later, separate image. */
9893
+ var TrainingExportSchema = _enum([
9894
+ "onnx",
9895
+ "openvino-fp16",
9896
+ "openvino-int8",
9897
+ "coreml-fp16"
9898
+ ]);
9899
+ var FloorsSchema = record(string(), number().min(0).max(1));
9900
+ object({
9901
+ schema: literal(TRAINING_JOB_SCHEMA),
9902
+ jobKey: string().uuid(),
9903
+ target: object({
9904
+ kind: literal("detector"),
9905
+ step: literal("object-detection")
9906
+ }),
9907
+ base: object({
9908
+ modelId: string().min(1),
9909
+ /** Ultralytics weights id, e.g. `yolov9m.pt`. */
9910
+ weights: string().min(1),
9911
+ imgsz: number().int().positive()
9912
+ }),
9913
+ baseline: object({
9914
+ modelId: string().min(1),
9915
+ /** The baseline ONNX the holdout comparison runs; public mirror URL. */
9916
+ onnxUrl: string().url(),
9917
+ imgsz: number().int().positive(),
9918
+ floors: FloorsSchema
9919
+ }),
9920
+ dataset: object({
9921
+ versionId: string().min(1),
9922
+ annotationHash: string(),
9923
+ /** sha256 of the uploaded archive; the trainer refuses a mismatch (exit 65). */
9924
+ sha256: string().regex(/^[0-9a-f]{64}$/)
9925
+ }),
9926
+ split: object({
9927
+ holdoutCameras: array(number().int()),
9928
+ /** When no camera is held out: the last N days of every camera. */
9929
+ holdoutLastDays: number().int().nonnegative(),
9930
+ valFraction: number().min(0).max(.5),
9931
+ seed: number().int()
9932
+ }),
9933
+ hyper: object({
9934
+ epochs: number().int().positive(),
9935
+ batch: number().int().positive(),
9936
+ lr0: number().positive(),
9937
+ /** Layers frozen from the start of the backbone; 0 = none. */
9938
+ freeze: number().int().nonnegative(),
9939
+ patience: number().int().nonnegative(),
9940
+ seed: number().int()
9941
+ }),
9942
+ replay: object({
9943
+ source: literal("coco2017"),
9944
+ count: number().int().nonnegative()
9945
+ }),
9946
+ exports: array(TrainingExportSchema).min(1),
9947
+ calibration: object({ maxFrames: number().int().positive() }),
9948
+ floors: object({
9949
+ minSupport: number().int().positive(),
9950
+ clamp: number().min(0).max(1)
9951
+ }),
9952
+ int8Gate: object({ maxMap50Drop: number().min(0).max(1) }),
9953
+ catalog: object({
9954
+ id: string().regex(/^[a-z0-9][a-z0-9-]{2,80}$/),
9955
+ name: string().min(1).max(160)
9956
+ })
9957
+ });
9958
+ /** One regular file of the bundle. An mlpackage contributes one row per member. */
9959
+ var TrainingResultFileSchema = object({
9960
+ path: string().min(1),
9961
+ bytes: number().int().nonnegative(),
9962
+ sha256: string().regex(/^[0-9a-f]{64}$/),
9963
+ format: _enum([
9964
+ "onnx",
9965
+ "openvino",
9966
+ "coreml",
9967
+ "pt"
9968
+ ]),
9969
+ variant: _enum(["base", "int8"])
9970
+ });
9971
+ var DraftFormatSchema = object({
9972
+ /** RELATIVE path inside the bundle; the hub rewrites it to `camstack-local://`. */
9973
+ url: string().min(1),
9974
+ sizeMB: number().nonnegative(),
9975
+ isDirectory: boolean().optional(),
9976
+ files: array(string()).optional(),
9977
+ runtimes: array(literal("python")).optional(),
9978
+ revision: string().min(1)
9979
+ });
9980
+ /** The trainer's half of a catalog entry; the hub completes it (labels, licence, group). */
9981
+ var TrainingCatalogDraftSchema = object({
9982
+ id: string().min(1),
9983
+ name: string().min(1),
9984
+ description: string(),
9985
+ labels: array(unknown()),
9986
+ inputSize: object({
9987
+ width: number().int().positive(),
9988
+ height: number().int().positive()
9989
+ }),
9990
+ preprocessMode: literal("letterbox"),
9991
+ defaultClassFloors: FloorsSchema,
9992
+ formats: object({
9993
+ onnx: DraftFormatSchema.optional(),
9994
+ openvino: DraftFormatSchema.optional(),
9995
+ coreml: DraftFormatSchema.optional()
9996
+ })
9997
+ });
9998
+ /** One class of one model's holdout report (the eval harness's summary). */
9999
+ var TrainingEvalClassSchema = object({
10000
+ positives: number().int(),
10001
+ floor: number().nullable(),
10002
+ tp: number().int(),
10003
+ fp: number().int(),
10004
+ fn: number().int(),
10005
+ precision: number().nullable(),
10006
+ recall: number().nullable(),
10007
+ ap50: number().nullable(),
10008
+ recallByCamera: record(string(), number().nullable()).optional(),
10009
+ recallByLight: record(string(), number().nullable()).optional(),
10010
+ fpByCamera: record(string(), number()).optional(),
10011
+ smallFound: number().int().optional(),
10012
+ smallTotal: number().int().optional()
10013
+ }).passthrough();
10014
+ var TrainingEvalReportSchema = object({
10015
+ frames: number().int(),
10016
+ classes: record(string(), TrainingEvalClassSchema)
10017
+ }).passthrough();
10018
+ /**
10019
+ * A succeeded result carries every block; a failed one carries the error and
10020
+ * whatever was known by then — the other blocks are ABSENT, not null. The
10021
+ * orchestrator checks the blocks it needs before it trusts a success.
10022
+ */
10023
+ var TrainingResultSchema = object({
10024
+ schema: literal(TRAINING_RESULT_SCHEMA),
10025
+ jobKey: string(),
10026
+ status: _enum(["succeeded", "failed"]),
10027
+ error: object({
10028
+ stage: string(),
10029
+ code: string(),
10030
+ message: string()
10031
+ }).nullable(),
10032
+ trainer: object({
10033
+ version: string(),
10034
+ revision: string()
10035
+ }),
10036
+ toolchain: record(string(), string().nullable()),
10037
+ dataset: object({
10038
+ versionId: string(),
10039
+ annotationHash: string(),
10040
+ sha256: string(),
10041
+ frames: object({
10042
+ train: number().int(),
10043
+ val: number().int(),
10044
+ holdout: number().int()
10045
+ }),
10046
+ holdoutCameras: array(number().int()),
10047
+ replayImages: number().int()
10048
+ }).optional(),
10049
+ training: object({
10050
+ epochsRun: number().int(),
10051
+ bestEpoch: number().int(),
10052
+ bestMap50: number(),
10053
+ bestMap50_95: number(),
10054
+ seconds: number()
10055
+ }).optional(),
10056
+ evaluation: object({
10057
+ holdoutFrames: number().int(),
10058
+ baseline: TrainingEvalReportSchema.nullable(),
10059
+ candidate: TrainingEvalReportSchema.nullable(),
10060
+ candidateInt8: TrainingEvalReportSchema.nullable(),
10061
+ recallDeltaByCamera: record(string(), record(string(), number())).nullable(),
10062
+ map50: record(string(), number().nullable())
10063
+ }).optional(),
10064
+ floors: object({
10065
+ baseline: FloorsSchema,
10066
+ candidate: FloorsSchema,
10067
+ candidateInt8: FloorsSchema.nullable(),
10068
+ notes: array(string())
10069
+ }).optional(),
10070
+ int8: object({
10071
+ kept: boolean(),
10072
+ map50Fp16: number().nullable(),
10073
+ map50Int8: number().nullable(),
10074
+ reason: string().nullable()
10075
+ }).optional(),
10076
+ exportsDropped: array(object({
10077
+ export: string(),
10078
+ reason: string()
10079
+ })).optional(),
10080
+ files: array(TrainingResultFileSchema).optional(),
10081
+ bundle: object({
10082
+ path: literal("bundle.tar"),
10083
+ bytes: number().int().nonnegative(),
10084
+ sha256: string().regex(/^[0-9a-f]{64}$/)
10085
+ }).nullable().optional(),
10086
+ catalogDraft: object({
10087
+ base: TrainingCatalogDraftSchema,
10088
+ int8: TrainingCatalogDraftSchema.nullable()
10089
+ }).nullable().optional(),
10090
+ licence: string()
10091
+ });
10092
+ var TrainingStageSchema = _enum([
10093
+ "prepare",
10094
+ "replay",
10095
+ "train",
10096
+ "eval",
10097
+ "export",
10098
+ "package"
10099
+ ]);
10100
+ var EventBase = {
10101
+ v: literal(1),
10102
+ ts: number()
10103
+ };
10104
+ discriminatedUnion("type", [
10105
+ object({
10106
+ ...EventBase,
10107
+ type: literal("stage"),
10108
+ stage: TrainingStageSchema
10109
+ }),
10110
+ object({
10111
+ ...EventBase,
10112
+ type: literal("epoch"),
10113
+ epoch: number().int(),
10114
+ epochs: number().int(),
10115
+ boxLoss: number().nullable().optional(),
10116
+ map50: number().nullable().optional(),
10117
+ map50_95: number().nullable().optional(),
10118
+ etaSec: number().nullable().optional()
10119
+ }),
10120
+ object({
10121
+ ...EventBase,
10122
+ type: literal("metric"),
10123
+ name: string(),
10124
+ value: number()
10125
+ }),
10126
+ object({
10127
+ ...EventBase,
10128
+ type: literal("artifact"),
10129
+ path: string(),
10130
+ bytes: number(),
10131
+ sha256: string()
10132
+ }),
10133
+ object({
10134
+ ...EventBase,
10135
+ type: literal("done"),
10136
+ status: _enum(["succeeded", "failed"]),
10137
+ resultSha256: string().nullable().optional()
10138
+ }),
10139
+ object({
10140
+ ...EventBase,
10141
+ type: literal("error"),
10142
+ stage: string(),
10143
+ code: string(),
10144
+ message: string()
10145
+ })
10146
+ ]);
10147
+ /**
9453
10148
  * What the gate decided about a birth, from the CALLER's point of view.
9454
10149
  *
9455
10150
  * Deliberately not `ConfirmationVerdict`: `undecided` is not a birth decision
@@ -11777,7 +12472,9 @@ var AddonHttpRouteSchema = object({
11777
12472
  "authenticated",
11778
12473
  "admin"
11779
12474
  ]).optional(),
11780
- description: string().optional()
12475
+ description: string().optional(),
12476
+ /** The hub limits this route per client address before the handler runs. */
12477
+ rateLimit: _enum(["auth"]).optional()
11781
12478
  });
11782
12479
  /**
11783
12480
  * Cross-process route invocation envelope. The hub captures the
@@ -12482,6 +13179,37 @@ var BackupDestinationInfoSchema = object({
12482
13179
  lastError: string().optional()
12483
13180
  });
12484
13181
  /**
13182
+ * How an archive is encrypted (operator decision 2026-10-09): to a backup
13183
+ * PUBLIC key the hub holds, so only the operator's secret key opens it.
13184
+ * Absent on a plain `.tar.gz` — every archive made before encryption, or
13185
+ * with it off — which restores without a key.
13186
+ */
13187
+ var BackupArchiveEncryptionSchema = object({
13188
+ /** `x25519-hkdf-aes256gcm-stream-v1`. */
13189
+ scheme: string(),
13190
+ /** 16 hex — the backup key whose secret restores this archive. */
13191
+ keyId: string()
13192
+ });
13193
+ /**
13194
+ * The backup encryption setting. The hub keeps PUBLIC keys only: the active
13195
+ * one new archives are encrypted to, and the retired ones older archives
13196
+ * still need. The secret key is shown once, at `setupEncryption`.
13197
+ */
13198
+ var BackupEncryptionStatusSchema = object({
13199
+ enabled: boolean(),
13200
+ active: object({
13201
+ keyId: string(),
13202
+ publicKey: string(),
13203
+ createdAt: number()
13204
+ }).nullable(),
13205
+ /** Every key ever set up, newest first. */
13206
+ keys: array(object({
13207
+ keyId: string(),
13208
+ createdAt: number(),
13209
+ retiredAt: number().nullable()
13210
+ })).readonly()
13211
+ });
13212
+ /**
12485
13213
  * Per-archive entry returned by `backup.listArchives({ destinationId })`.
12486
13214
  * Same shape the destination drill-in renders. Sourced from the per-
12487
13215
  * location `manifests.json` (no per-archive tarball read required).
@@ -12493,7 +13221,9 @@ var BackupArchiveEntrySchema = object({
12493
13221
  sizeBytes: number(),
12494
13222
  label: string().optional(),
12495
13223
  /** Top-level locations included in the archive (db, addons, tls, …). */
12496
- locations: array(string()).readonly()
13224
+ locations: array(string()).readonly(),
13225
+ /** Present when the archive is encrypted; restore then needs that key. */
13226
+ encryption: BackupArchiveEncryptionSchema.optional()
12497
13227
  });
12498
13228
  var BackupEntrySchema = object({
12499
13229
  id: string(),
@@ -12502,7 +13232,8 @@ var BackupEntrySchema = object({
12502
13232
  label: string().optional(),
12503
13233
  createdAt: number(),
12504
13234
  sizeBytes: number(),
12505
- locations: array(string()).optional()
13235
+ locations: array(string()).optional(),
13236
+ encryption: BackupArchiveEncryptionSchema.optional()
12506
13237
  });
12507
13238
  var ArchiveEntrySchema = object({
12508
13239
  path: string(),
@@ -12691,10 +13422,40 @@ method(_void(), array(BackupDestinationInfoSchema).readonly(), { auth: "admin" }
12691
13422
  * this list and skips entries whose path doesn't start with
12692
13423
  * any of them.
12693
13424
  */
12694
- locations: array(string()).optional()
13425
+ locations: array(string()).optional(),
13426
+ /**
13427
+ * The backup SECRET key, for an encrypted archive (ignored for a plain
13428
+ * one). The archive is decrypted into the hub's private staging
13429
+ * before the restart; the key is not stored. A wrong or missing key
13430
+ * is refused before the archive is downloaded.
13431
+ */
13432
+ backupSecretKey: string().optional()
12695
13433
  }), _void(), {
12696
13434
  kind: "mutation",
12697
13435
  auth: "admin"
13436
+ }), method(_void(), BackupEncryptionStatusSchema, { auth: "admin" }), method(object({}), object({
13437
+ keyId: string(),
13438
+ secretKey: string(),
13439
+ publicKey: string(),
13440
+ createdAt: number(),
13441
+ replacedKeyId: string().nullable()
13442
+ }), {
13443
+ kind: "mutation",
13444
+ auth: "admin"
13445
+ }), method(object({}), object({ disabledKeyId: string().nullable() }), {
13446
+ kind: "mutation",
13447
+ auth: "admin"
13448
+ }), method(object({ backupSecretKey: string() }), object({
13449
+ valid: boolean(),
13450
+ keyId: string().nullable(),
13451
+ /** The hub knows this key (active or retired). */
13452
+ known: boolean(),
13453
+ /** It is the key new archives are encrypted to. */
13454
+ active: boolean(),
13455
+ error: string().optional()
13456
+ }), {
13457
+ kind: "mutation",
13458
+ auth: "admin"
12698
13459
  }), method(object({
12699
13460
  destinationId: string(),
12700
13461
  backupId: string()
@@ -14420,7 +15181,60 @@ var CustomModelDescriptorSchema = object({
14420
15181
  stepId: string(),
14421
15182
  entry: ModelCatalogEntrySchema
14422
15183
  });
14423
- method(_void(), array(CustomModelDescriptorSchema).readonly(), { auth: "admin" });
15184
+ /** One regular file of an imported bundle, as the producer measured it. */
15185
+ var ModelBundleFileSchema = object({
15186
+ /** Relative path inside the bundle tar; an mlpackage member is `<x>.mlpackage/<member>`. */
15187
+ path: string().min(1),
15188
+ bytes: number().int().nonnegative(),
15189
+ sha256: string().regex(/^[0-9a-f]{64}$/)
15190
+ });
15191
+ var ImportModelBundleInputSchema = object({
15192
+ /** The registry provider that keeps the model (Model Studio). */
15193
+ addonId: string(),
15194
+ stepId: string().min(1),
15195
+ /**
15196
+ * The catalog rows to register, complete, every format URL already
15197
+ * `camstack-local://<modelId>/<file>` naming a file of the bundle. One
15198
+ * bundle may carry several rows (a base and its INT8 variant).
15199
+ */
15200
+ entries: array(ModelCatalogEntrySchema).min(1).max(4),
15201
+ /** The bundle tar, offered by the producer over `ctx.peerBytes` (same host). */
15202
+ bundle: object({
15203
+ ticket: PeerBytesTicketSchema,
15204
+ bytes: number().int().positive(),
15205
+ sha256: string().regex(/^[0-9a-f]{64}$/)
15206
+ }),
15207
+ /** Every file the tar must hold; anything missing, extra or different is refused. */
15208
+ files: array(ModelBundleFileSchema).min(1).max(64),
15209
+ /** Convert missing engine formats and push the model to every agent afterwards. */
15210
+ distribute: boolean()
15211
+ });
15212
+ var ImportModelBundleResultSchema = discriminatedUnion("kind", [object({
15213
+ kind: literal("imported"),
15214
+ modelIds: array(string()).readonly(),
15215
+ distributed: array(object({
15216
+ modelId: string(),
15217
+ nodeId: string(),
15218
+ format: _enum(MODEL_FORMATS),
15219
+ ok: boolean(),
15220
+ error: string().optional()
15221
+ })).readonly()
15222
+ }), object({
15223
+ kind: literal("refused"),
15224
+ reason: _enum([
15225
+ "transfer-failed",
15226
+ "checksum-mismatch",
15227
+ "bundle-mismatch",
15228
+ "invalid-entry",
15229
+ "id-taken"
15230
+ ]),
15231
+ detail: string()
15232
+ })]);
15233
+ method(_void(), array(CustomModelDescriptorSchema).readonly(), { auth: "admin" }), method(ImportModelBundleInputSchema, ImportModelBundleResultSchema, {
15234
+ kind: "mutation",
15235
+ auth: "admin",
15236
+ timeoutMs: 30 * 6e4
15237
+ });
14424
15238
  /**
14425
15239
  * Query filter for settings-store collections.
14426
15240
  */
@@ -14899,6 +15713,35 @@ var KeychainKeySourceSchema = object({
14899
15713
  */
14900
15714
  sharesBackupWithDatabase: boolean()
14901
15715
  });
15716
+ /**
15717
+ * One keychain reset, as the Secrets page reports it until the operator
15718
+ * acknowledges it. Never a value: refs, counts and table names only.
15719
+ */
15720
+ var KeychainResetRecordSchema = object({
15721
+ id: string(),
15722
+ at: number(),
15723
+ /** `user:<id>` or {@link KEYCHAIN_RESET_TRIGGER_ACTOR}. */
15724
+ actor: string(),
15725
+ /** Why the keychain was locked when it was reset; `null` when it was not locked. */
15726
+ lockedReason: string().nullable(),
15727
+ /** Values moved into the archive table (ciphertext under the lost key). */
15728
+ archived: number().int(),
15729
+ /** `keychain:secrets-orphaned-<ts>`, or `null` when nothing was stored. */
15730
+ archivedCollection: string().nullable(),
15731
+ /**
15732
+ * `keychain:keys-orphaned-<ts>`: the wrapped data keys of the archive, kept
15733
+ * so the archive can still be opened if the lost master key turns up.
15734
+ */
15735
+ archivedKeysCollection: string().nullable(),
15736
+ /**
15737
+ * `system-settings` keys whose marker the reset cleared — the cluster
15738
+ * secret's: a marker left pointing at an archived value would refuse every
15739
+ * agent forever (D797).
15740
+ */
15741
+ clearedSettingsKeys: array(string()).readonly(),
15742
+ /** When an operator dismissed the notice on the Secrets page; `null` until then. */
15743
+ acknowledgedAt: number().nullable()
15744
+ });
14902
15745
  var KeychainStatusSchema = object({
14903
15746
  keychain: KeychainStateSchema,
14904
15747
  /** The source of the master key in use; `null` while locked. */
@@ -14916,7 +15759,9 @@ var KeychainStatusSchema = object({
14916
15759
  /** Wrapped copies of the data key under a previous master key, kept until purged. */
14917
15760
  retiredWraps: number().int(),
14918
15761
  recoveryKeyDownloadedAt: number().nullable(),
14919
- secretCount: number().int()
15762
+ secretCount: number().int(),
15763
+ /** The most recent reset, acknowledged or not; `null` when the keychain was never reset. */
15764
+ lastReset: KeychainResetRecordSchema.nullable()
14920
15765
  });
14921
15766
  /**
14922
15767
  * Whether a stored value is still pointed at by its owner's settings.
@@ -14938,17 +15783,26 @@ var KeychainAuditActionSchema = _enum([
14938
15783
  "download-recovery-key",
14939
15784
  "delete-orphans",
14940
15785
  "reset",
15786
+ "acknowledge-reset",
14941
15787
  "initialize"
14942
15788
  ]);
14943
15789
  var KeychainAuditEntrySchema = object({
14944
15790
  id: string(),
14945
15791
  at: number(),
14946
15792
  action: KeychainAuditActionSchema,
14947
- /** `addon:<id>` | `user:<id>` | `system`. */
15793
+ /** `addon:<id>` | `user:<id>` | `system` | `trigger-file`. */
14948
15794
  actor: string(),
14949
15795
  ref: string().nullable(),
14950
15796
  detail: string().nullable()
14951
15797
  });
15798
+ var KEYCHAIN_RESET_CONFIRMATION = "RESET KEYCHAIN";
15799
+ /**
15800
+ * Secrets the HUB itself holds (owner `system`) that no settings form shows:
15801
+ * `jwt-signing-key` — the session signing key (D797). It is always "in use",
15802
+ * never an orphan; it is generated on a fresh hub and replaced only through
15803
+ * {@link keychainAdminCapability.methods.setSystemSecret}.
15804
+ */
15805
+ var SystemHeldSecretNameSchema = _enum(["jwt-signing-key"]);
14952
15806
  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({
14953
15807
  value: string(),
14954
15808
  version: number().int()
@@ -14956,6 +15810,16 @@ method(object({}), KeychainStatusSchema, { auth: "admin" }), method(object({}),
14956
15810
  kind: "mutation",
14957
15811
  auth: "admin",
14958
15812
  caller: "required"
15813
+ }), method(object({
15814
+ name: SystemHeldSecretNameSchema,
15815
+ value: string().min(16)
15816
+ }), object({
15817
+ ref: string(),
15818
+ version: number().int()
15819
+ }), {
15820
+ kind: "mutation",
15821
+ auth: "admin",
15822
+ caller: "required"
14959
15823
  }), method(object({ refs: array(string().min(1)).max(1e3) }), object({
14960
15824
  deleted: array(string()).readonly(),
14961
15825
  kept: array(object({
@@ -14985,13 +15849,20 @@ method(object({}), KeychainStatusSchema, { auth: "admin" }), method(object({}),
14985
15849
  kind: "mutation",
14986
15850
  auth: "admin",
14987
15851
  caller: "required"
14988
- }), method(object({ confirm: literal("RESET KEYCHAIN") }), object({
15852
+ }), method(object({ confirm: literal(KEYCHAIN_RESET_CONFIRMATION) }), object({
14989
15853
  archivedCollection: string().nullable(),
14990
15854
  archived: number().int()
14991
15855
  }), {
14992
15856
  kind: "mutation",
14993
15857
  auth: "admin",
14994
15858
  caller: "required"
15859
+ }), method(object({}), object({
15860
+ reset: KeychainResetRecordSchema.nullable(),
15861
+ pendingReentry: array(KeychainSecretMetaSchema).readonly()
15862
+ }), { auth: "admin" }), method(object({}), object({ acknowledged: boolean() }), {
15863
+ kind: "mutation",
15864
+ auth: "admin",
15865
+ caller: "required"
14995
15866
  });
14996
15867
  method(_void(), object({
14997
15868
  id: string(),
@@ -17938,7 +18809,7 @@ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
17938
18809
  * `login-method` — collection cap through which auth addons contribute
17939
18810
  * their pre-auth login surfaces to the login page. This is the SINGLE,
17940
18811
  * generic mechanism that supersedes the dead `auth.listProviders` reader:
17941
- * every auth addon (OIDC, magic-link, WebAuthn/passkey) registers a
18812
+ * every auth addon (OIDC, WebAuthn/passkey) registers a
17942
18813
  * `login-method` provider and the PUBLIC `auth.listLoginMethods`
17943
18814
  * procedure aggregates them for the unauthenticated login page.
17944
18815
  *
@@ -17946,8 +18817,7 @@ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
17946
18817
  *
17947
18818
  * - `redirect` — a declarative button. The login page renders a generic
17948
18819
  * button that navigates to `startUrl` (an addon-owned HTTP route).
17949
- * Covers OIDC (`/addon/auth-oidc/<id>/start`) and magic-link with
17950
- * ZERO shell-side JS. A future SSO addon plugs in the same way — the
18820
+ * Covers OIDC (`/addon/auth-oidc/<id>/start`) with ZERO shell-side JS. A future SSO addon plugs in the same way — the
17951
18821
  * login page needs NO change.
17952
18822
  *
17953
18823
  * - `widget` — a Module-Federation widget the login page mounts (via
@@ -17966,8 +18836,8 @@ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
17966
18836
  * decision.
17967
18837
  *
17968
18838
  * Every contribution carries a `stage`:
17969
- * - `primary` — shown on the first credentials screen (OIDC /
17970
- * magic-link buttons; a future usernameless passkey).
18839
+ * - `primary` — shown on the first credentials screen (OIDC
18840
+ * buttons; a usernameless passkey).
17971
18841
  * - `second-factor` — shown AFTER the password leg, gated on the
17972
18842
  * returned `factors` (passkey-as-2FA today).
17973
18843
  *
@@ -17994,7 +18864,7 @@ var LoginMethodContributionSchema = discriminatedUnion("kind", [
17994
18864
  * The provider names an external identity a signed-in user can link to
17995
18865
  * their own account (D782): `auth.listLinkableProviders` /
17996
18866
  * `beginExternalLink` offer exactly the redirect methods that set this,
17997
- * whatever their id. Absent / false — a login button only (magic-link).
18867
+ * whatever their id. Absent / false — a login button only.
17998
18868
  */
17999
18869
  linkable: boolean().optional()
18000
18870
  }),
@@ -21849,8 +22719,7 @@ method(object({}), object({ rules: array(NcRuleSchema) }), { auth: "admin" }), m
21849
22719
  * `super_admin` — collapsed onto the single boolean because every
21850
22720
  * non-admin caller is governed by the same scope-check rules; the
21851
22721
  * distinction was only ever used to route role-specific procedures
21852
- * which we no longer have. Agents are admin sessions issued via
21853
- * `createServiceToken`; CLI / webhook integrations are `cst_*` tokens
22722
+ * which we no longer have. CLI / webhook integrations are `cst_*` tokens
21854
22723
  * with `isAdmin: false` + an explicit scope list.
21855
22724
  */
21856
22725
  /** Per-method access flavour. Materialised on every cap method via codegen. */
@@ -23525,6 +24394,9 @@ var RetrainExportFilterSchema = object({
23525
24394
  frameIds: array(string()).max(2e4).optional(),
23526
24395
  /** Only frames in at least one of these named collections. */
23527
24396
  collectionIds: array(string()).max(200).optional(),
24397
+ /** Exactly the frames of this dataset version (and its completeOnly). An
24398
+ * unknown id selects nothing. */
24399
+ datasetVersionId: string().optional(),
23528
24400
  batchId: string().optional(),
23529
24401
  /** Only frames the operator marked complete (all subjects boxed). */
23530
24402
  completeOnly: boolean().optional()
@@ -23692,6 +24564,67 @@ var RetrainLlmAssistResultSchema = discriminatedUnion("kind", [object({
23692
24564
  ]),
23693
24565
  detail: string().optional()
23694
24566
  })]);
24567
+ /** What a dataset version is cut from. Every field narrows. */
24568
+ var RetrainDatasetSelectionSchema = object({
24569
+ deviceIds: array(number()).readonly().optional(),
24570
+ collectionIds: array(string()).max(200).readonly().optional(),
24571
+ frameIds: array(string()).max(2e4).readonly().optional()
24572
+ });
24573
+ /** The counts a dataset is judged by. */
24574
+ var RetrainDatasetStatsSchema = object({
24575
+ frames: number().int(),
24576
+ completeFrames: number().int(),
24577
+ /** `completeFrames / frames`, 0..1. */
24578
+ completeness: number(),
24579
+ /** Boxes to learn (model errors excluded). */
24580
+ subjects: number().int(),
24581
+ modelErrors: number().int(),
24582
+ /** Complete frames with no subject. */
24583
+ hardNegatives: number().int(),
24584
+ /** Subjects per class × camera × day/night. */
24585
+ cells: array(object({
24586
+ macroClass: string(),
24587
+ deviceId: number(),
24588
+ lighting: _enum([
24589
+ "day",
24590
+ "night",
24591
+ "unknown"
24592
+ ]),
24593
+ subjects: number().int(),
24594
+ frames: number().int()
24595
+ })).readonly(),
24596
+ cameras: array(object({
24597
+ deviceId: number(),
24598
+ frames: number().int(),
24599
+ completeFrames: number().int()
24600
+ })).readonly()
24601
+ });
24602
+ /** An immutable dataset version, without its frame list. */
24603
+ var RetrainDatasetVersionSchema = object({
24604
+ id: string(),
24605
+ name: string(),
24606
+ createdAt: number(),
24607
+ selection: RetrainDatasetSelectionSchema,
24608
+ layout: RetrainExportLayoutSchema,
24609
+ completeOnly: boolean(),
24610
+ frameCount: number().int(),
24611
+ /** sha256 of what the frames taught when the version was frozen. */
24612
+ annotationHash: string(),
24613
+ /** The export manifest schema the version was cut under. */
24614
+ manifestSchema: string(),
24615
+ stats: RetrainDatasetStatsSchema
24616
+ });
24617
+ var CreateRetrainDatasetVersionResultSchema = discriminatedUnion("kind", [object({
24618
+ kind: literal("created"),
24619
+ version: RetrainDatasetVersionSchema
24620
+ }), object({
24621
+ kind: literal("refused"),
24622
+ reason: _enum([
24623
+ "empty-name",
24624
+ "duplicate-name",
24625
+ "no-frames"
24626
+ ])
24627
+ })]);
23695
24628
  /** The outcome of a lifecycle move owned by the retrain page. */
23696
24629
  var RetrainTransitionResultSchema = object({
23697
24630
  trackId: string(),
@@ -24481,6 +25414,47 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
24481
25414
  kind: "mutation",
24482
25415
  auth: "admin",
24483
25416
  timeoutMs: 60 * 6e4
25417
+ }), method(object({
25418
+ filter: RetrainExportFilterSchema,
25419
+ layout: RetrainExportLayoutSchema
25420
+ }), object({
25421
+ ticket: PeerBytesTicketSchema,
25422
+ frames: number().int(),
25423
+ annotations: number().int()
25424
+ }), {
25425
+ kind: "mutation",
25426
+ auth: "admin",
25427
+ timeoutMs: 12e4
25428
+ }), method(object({
25429
+ selection: RetrainDatasetSelectionSchema,
25430
+ completeOnly: boolean().optional()
25431
+ }), RetrainDatasetStatsSchema, {
25432
+ kind: "query",
25433
+ auth: "admin"
25434
+ }), method(object({
25435
+ name: string().max(120),
25436
+ selection: RetrainDatasetSelectionSchema,
25437
+ layout: RetrainExportLayoutSchema,
25438
+ completeOnly: boolean()
25439
+ }), CreateRetrainDatasetVersionResultSchema, {
25440
+ kind: "mutation",
25441
+ auth: "admin",
25442
+ timeoutMs: 12e4
25443
+ }), method(object({}), array(RetrainDatasetVersionSchema).readonly(), {
25444
+ kind: "query",
25445
+ auth: "admin"
25446
+ }), method(object({ id: string() }), object({ deleted: boolean() }), {
25447
+ kind: "mutation",
25448
+ auth: "admin"
25449
+ }), method(object({ id: string() }), object({
25450
+ found: boolean(),
25451
+ annotationHash: string(),
25452
+ matches: boolean(),
25453
+ missingFrames: number().int()
25454
+ }), {
25455
+ kind: "query",
25456
+ auth: "admin",
25457
+ timeoutMs: 12e4
24484
25458
  }), method(object({}), array(RetrainAssistProfileSchema).readonly(), {
24485
25459
  kind: "query",
24486
25460
  auth: "admin"
@@ -28059,8 +29033,8 @@ version: string().optional() }), ServerUpdateActionResultSchema, {
28059
29033
  * `smtp-provider` — pluggable email delivery surface.
28060
29034
  *
28061
29035
  * Collection cap: a deployment may install multiple SMTP relays (e.g.
28062
- * one for transactional / one for notifications). Consumers (magic-link,
28063
- * notifier addons, …) walk the collection and pick the first
29036
+ * one for transactional / one for notifications). Consumers (notifier
29037
+ * addons, …) walk the collection and pick the first
28064
29038
  * ready provider OR target a specific addonId.
28065
29039
  *
28066
29040
  * The shape stays small on purpose — `sendEmail` is enough for the
@@ -28239,7 +29213,7 @@ targets: array(object({
28239
29213
  })));
28240
29214
  /**
28241
29215
  * `sso-bridge` — internal hub-only cap that lets SSO-style auth
28242
- * providers (OIDC, SAML, magic-link, …) mint an HMAC-signed token
29216
+ * providers (OIDC, SAML, …) mint an HMAC-signed token
28243
29217
  * carrying the post-callback claims before redirecting back to
28244
29218
  * `/api/auth/sso/finish`.
28245
29219
  *
@@ -28302,7 +29276,14 @@ var SsoBridgeClaimsSchema = object({
28302
29276
  * Verified `iss` of the id_token behind an OIDC login bridge (D782). A
28303
29277
  * subject is unique only per issuer, so a link is bound to it.
28304
29278
  */
28305
- issuer: string().optional()
29279
+ issuer: string().optional(),
29280
+ /**
29281
+ * SHA-256 (hex) of the `camstack_sso_state` cookie the IdP `/start` set in
29282
+ * the browser that began this sign-in. `/api/auth/sso/finish` requires the
29283
+ * request to present the matching cookie — a login bridge is useless in
29284
+ * any other browser.
29285
+ */
29286
+ browserBinding: string().optional()
28306
29287
  });
28307
29288
  method(object({
28308
29289
  claims: SsoBridgeClaimsSchema,
@@ -40578,16 +41559,6 @@ var ApiKeySummarySchema = object({
40578
41559
  createdAt: number(),
40579
41560
  lastUsedAt: number().optional()
40580
41561
  });
40581
- var CreateApiKeyInputSchema = object({
40582
- label: string(),
40583
- isAdmin: boolean().default(false),
40584
- allowedProviders: union([array(string()), literal("*")]).optional(),
40585
- allowedDevices: record(string(), union([array(string()), literal("*")])).optional()
40586
- });
40587
- var CreateApiKeyResultSchema = object({
40588
- token: string(),
40589
- record: ApiKeySummarySchema
40590
- });
40591
41562
  var ScopedTokenSummarySchema = object({
40592
41563
  id: string(),
40593
41564
  userId: string(),
@@ -40686,17 +41657,10 @@ method(_void(), array(UserSummarySchema), { auth: "admin" }), method(CreateUserI
40686
41657
  }), UserSummarySchema.extend({ passwordHash: string() }).nullable(), {
40687
41658
  kind: "mutation",
40688
41659
  access: "view"
40689
- }), method(_void(), array(ApiKeySummarySchema), { auth: "admin" }), method(CreateApiKeyInputSchema, CreateApiKeyResultSchema, {
40690
- kind: "mutation",
40691
- auth: "admin",
40692
- access: "create"
40693
- }), method(object({ id: string() }), object({ success: literal(true) }), {
41660
+ }), method(_void(), array(ApiKeySummarySchema), { auth: "admin" }), method(object({ id: string() }), object({ success: literal(true) }), {
40694
41661
  kind: "mutation",
40695
41662
  auth: "admin",
40696
41663
  access: "delete"
40697
- }), method(object({ token: string() }), ApiKeySummarySchema.nullable(), {
40698
- kind: "mutation",
40699
- access: "view"
40700
41664
  }), method(CreateScopedTokenInputSchema, CreateScopedTokenResultSchema, {
40701
41665
  kind: "mutation",
40702
41666
  auth: "admin",
@@ -40770,15 +41734,7 @@ method(_void(), array(UserSummarySchema), { auth: "admin" }), method(CreateUserI
40770
41734
  }).nullable(), { access: "view" }), method(object({ userId: string() }), array(ExternalIdentitySchema), { auth: "admin" }), method(ExternalIdentityKeySchema, object({
40771
41735
  userId: string(),
40772
41736
  issuer: string()
40773
- }).nullable(), { auth: "admin" }), method(ExternalIdentityKeySchema.extend({
40774
- userId: string(),
40775
- issuer: string().min(1),
40776
- label: string().optional()
40777
- }), object({ success: literal(true) }), {
40778
- kind: "mutation",
40779
- auth: "admin",
40780
- access: "create"
40781
- }), method(ExternalIdentityKeySchema.extend({ userId: string() }), object({ success: boolean() }), {
41737
+ }).nullable(), { auth: "admin" }), method(ExternalIdentityKeySchema.extend({ userId: string() }), object({ success: boolean() }), {
40782
41738
  kind: "mutation",
40783
41739
  auth: "admin",
40784
41740
  access: "delete"
@@ -41483,6 +42439,451 @@ var zoneRulesCapability = {
41483
42439
  */
41484
42440
  durability: "restored"
41485
42441
  };
42442
+ /**
42443
+ * `training-provider` — ONE cloud that can run the CamStack trainer.
42444
+ *
42445
+ * A thin, mockable translation layer: it knows how to run a container with a
42446
+ * GPU, move a dataset in, read the job's stdout and hand artefacts back. It
42447
+ * knows nothing about datasets, splits, floors, cost policy or Model Studio —
42448
+ * those are the `training` orchestrator's (D805). Every rule written there
42449
+ * once is what makes a second provider (RunPod, a local NVIDIA node) a new
42450
+ * manifest entry and nothing else.
42451
+ *
42452
+ * Collection, routed by the `addonId` in every single-row input (the `llm` /
42453
+ * `notification-output` posture); `describe` concat-fans across providers.
42454
+ * Every method is `admin`: these spend money.
42455
+ *
42456
+ * Every cloud object a provider creates is tagged with the orchestrator's
42457
+ * `jobKey`, so a retried submit finds the job it already started instead of
42458
+ * starting a second GPU, and `listJobs` can find orphans.
42459
+ *
42460
+ * Bytes never ride a cap field: the dataset arrives as a `ctx.peerBytes`
42461
+ * ticket the producer (pipeline-analytics) minted, and artefacts leave as a
42462
+ * ticket the provider mints (D613).
42463
+ */
42464
+ var TrainingGpuOptionSchema = object({
42465
+ id: string(),
42466
+ label: string(),
42467
+ /** List price, USD per GPU-hour, before any region multiplier. */
42468
+ usdPerHour: number().nonnegative(),
42469
+ vramGb: number().nonnegative()
42470
+ });
42471
+ var TrainingRegionOptionSchema = object({
42472
+ /** `''` = any region (the provider's choice). */
42473
+ id: string(),
42474
+ label: string(),
42475
+ priceMultiplier: number().positive()
42476
+ });
42477
+ /**
42478
+ * The provider's per-account settings, as the orchestrator reads them. They
42479
+ * live in the PROVIDER addon's settings (operator decision 2026-10-08: they
42480
+ * depend on the user's account), never hard-coded in the orchestrator.
42481
+ */
42482
+ var TrainingProviderDefaultsSchema = object({
42483
+ gpuType: string(),
42484
+ region: string(),
42485
+ costCapUsd: number().nonnegative(),
42486
+ maxRuntimeSec: number().int().positive(),
42487
+ /** Hours a FAILED job's cloud dataset is kept for debugging; 0 = delete at once. */
42488
+ failedDatasetGraceHours: number().nonnegative()
42489
+ });
42490
+ var TrainingProviderDescriptorSchema = object({
42491
+ addonId: string(),
42492
+ /** `modal`, `runpod`, `fake`, … */
42493
+ kind: string(),
42494
+ label: string(),
42495
+ gpuTypes: array(TrainingGpuOptionSchema).readonly(),
42496
+ regions: array(TrainingRegionOptionSchema).readonly(),
42497
+ maxDatasetBytes: number().int().positive(),
42498
+ maxRuntimeSec: number().int().positive(),
42499
+ freeTierNote: string().optional(),
42500
+ /** Where the data goes, in one sentence the confirm dialog repeats. */
42501
+ dataResidencyNote: string(),
42502
+ /** Credentials are present — never the values. */
42503
+ configured: boolean(),
42504
+ defaults: TrainingProviderDefaultsSchema
42505
+ });
42506
+ var TrainingCredentialCheckSchema = object({
42507
+ ok: boolean(),
42508
+ /** Workspace / account name, when the provider says. */
42509
+ account: string().optional(),
42510
+ reason: _enum([
42511
+ "missing",
42512
+ "invalid",
42513
+ "forbidden",
42514
+ "network",
42515
+ "quota"
42516
+ ]).optional(),
42517
+ detail: string().optional()
42518
+ });
42519
+ var ProviderJobStateSchema = _enum([
42520
+ "pending",
42521
+ "starting",
42522
+ "running",
42523
+ "succeeded",
42524
+ "failed",
42525
+ "cancelled",
42526
+ "lost"
42527
+ ]);
42528
+ var ProviderJobStatusSchema = object({
42529
+ jobKey: string(),
42530
+ providerJobId: string().optional(),
42531
+ state: ProviderJobStateSchema,
42532
+ startedAt: number().optional(),
42533
+ endedAt: number().optional(),
42534
+ exitCode: number().int().optional(),
42535
+ failureReason: string().optional(),
42536
+ gpuType: string(),
42537
+ region: string().optional(),
42538
+ billedSeconds: number().nonnegative(),
42539
+ costUsd: number().nonnegative(),
42540
+ /** True when `costUsd` is runtime × list price, not a billing answer. */
42541
+ costIsEstimate: boolean(),
42542
+ lastFetchedAt: number()
42543
+ });
42544
+ /**
42545
+ * The trainer the job runs, by SOURCE revision: the provider turns it into an
42546
+ * image its own way (Modal builds the published Dockerfile at that revision;
42547
+ * a registry-pull provider maps it to a tag). Recorded on the job and echoed
42548
+ * in `result.json`.
42549
+ */
42550
+ var TrainerSourceRefSchema = object({
42551
+ /** Hugging Face repo id, e.g. `camstack/camstack-trainer`. */
42552
+ repo: string().min(1),
42553
+ /** A commit sha (never a branch) — the job must be reproducible. */
42554
+ revision: string().regex(/^[0-9a-f]{7,64}$/)
42555
+ });
42556
+ var JobRef = {
42557
+ addonId: string(),
42558
+ jobKey: string().uuid()
42559
+ };
42560
+ var TrainingLogLineSchema = object({
42561
+ ts: number(),
42562
+ text: string()
42563
+ });
42564
+ method(object({}), array(TrainingProviderDescriptorSchema).readonly(), { auth: "admin" }), method(object({ addonId: string() }), TrainingCredentialCheckSchema, {
42565
+ kind: "mutation",
42566
+ auth: "admin",
42567
+ timeoutMs: 3e4
42568
+ }), method(object({
42569
+ addonId: string(),
42570
+ gpuType: string(),
42571
+ region: string(),
42572
+ datasetBytes: number().int().nonnegative(),
42573
+ gpuSecondsLow: number().nonnegative(),
42574
+ gpuSecondsHigh: number().nonnegative()
42575
+ }), object({
42576
+ usdLow: number().nonnegative(),
42577
+ usdHigh: number().nonnegative(),
42578
+ notes: array(string()).readonly()
42579
+ }), { auth: "admin" }), method(object({
42580
+ ...JobRef,
42581
+ ticket: PeerBytesTicketSchema
42582
+ }), object({
42583
+ bytes: number().int().nonnegative(),
42584
+ sha256: string()
42585
+ }), {
42586
+ kind: "mutation",
42587
+ auth: "admin",
42588
+ timeoutMs: 120 * 6e4
42589
+ }), method(object({
42590
+ ...JobRef,
42591
+ trainer: TrainerSourceRefSchema,
42592
+ jobSpecJson: string().min(2).max(64e3),
42593
+ gpuType: string(),
42594
+ region: string(),
42595
+ maxRuntimeSec: number().int().positive()
42596
+ }), ProviderJobStatusSchema, {
42597
+ kind: "mutation",
42598
+ auth: "admin",
42599
+ timeoutMs: 30 * 6e4
42600
+ }), method(object(JobRef), ProviderJobStatusSchema, {
42601
+ auth: "admin",
42602
+ timeoutMs: 6e4
42603
+ }), method(object({
42604
+ ...JobRef,
42605
+ cursor: string().optional(),
42606
+ max: number().int().min(1).max(500)
42607
+ }), object({
42608
+ lines: array(TrainingLogLineSchema).readonly(),
42609
+ cursor: string()
42610
+ }), {
42611
+ auth: "admin",
42612
+ timeoutMs: 6e4
42613
+ }), method(object(JobRef), object({ ok: literal(true) }), {
42614
+ kind: "mutation",
42615
+ auth: "admin",
42616
+ timeoutMs: 6e4
42617
+ }), method(object(JobRef), object({
42618
+ found: boolean(),
42619
+ text: string().optional()
42620
+ }), {
42621
+ kind: "mutation",
42622
+ auth: "admin",
42623
+ timeoutMs: 5 * 6e4
42624
+ }), method(object({
42625
+ ...JobRef,
42626
+ path: _enum(["bundle.tar"])
42627
+ }), object({ ticket: PeerBytesTicketSchema }), {
42628
+ kind: "mutation",
42629
+ auth: "admin",
42630
+ timeoutMs: 5 * 6e4
42631
+ }), method(object(JobRef), object({ deleted: array(string()).readonly() }), {
42632
+ kind: "mutation",
42633
+ auth: "admin",
42634
+ timeoutMs: 5 * 6e4
42635
+ }), method(object({ addonId: string() }), array(ProviderJobStatusSchema).readonly(), {
42636
+ auth: "admin",
42637
+ timeoutMs: 2 * 6e4
42638
+ });
42639
+ /**
42640
+ * `training` — the cloud-training orchestrator (D805). Hub-only singleton,
42641
+ * provided by `addon-training`.
42642
+ *
42643
+ * It owns what every provider must agree on, written once:
42644
+ *
42645
+ * - **Dataset versions.** Taken over from pipeline-analytics (D796): the rows
42646
+ * live here (D808); pipeline-analytics still CUTS a version (it owns the corpus and
42647
+ * the export plan) and reaches this store through the five row methods
42648
+ * below, so the Retrain page and the export did not change.
42649
+ * - **Jobs.** A persisted state machine, a reconcile loop against the
42650
+ * provider, a cost guard, a daily orphan sweep and the retention rules.
42651
+ * - **The return flow.** Verified artefacts → Model Studio
42652
+ * (`custom-model-registry.importModelBundle`) → canary on cameras →
42653
+ * rollback. Nothing is ever registered automatically.
42654
+ *
42655
+ * Every method is `admin`.
42656
+ */
42657
+ /** A version WITH its frame list — what the export and a job read. */
42658
+ var TrainingDatasetVersionRowSchema = RetrainDatasetVersionSchema.omit({ frameCount: true }).extend({ frameIds: array(string()).max(2e4).readonly() });
42659
+ /** A base model a detector job can fine-tune, and the baseline it is judged against. */
42660
+ var TrainingBaseModelSchema = object({
42661
+ modelId: string(),
42662
+ label: string(),
42663
+ weights: string(),
42664
+ imgsz: number().int(),
42665
+ baselineOnnxUrl: string(),
42666
+ baselineFloors: record(string(), number()),
42667
+ /** The base the fleet runs most — the UI's default. */
42668
+ recommended: boolean()
42669
+ });
42670
+ var TrainingPresetSchema = _enum([
42671
+ "quick",
42672
+ "standard",
42673
+ "thorough"
42674
+ ]);
42675
+ var TrainingJobRequestSchema = object({
42676
+ datasetVersionId: string().min(1),
42677
+ /** The `training-provider` addon that runs it. */
42678
+ addonId: string().min(1),
42679
+ gpuType: string().min(1),
42680
+ region: string(),
42681
+ baseModelId: string().min(1),
42682
+ preset: TrainingPresetSchema,
42683
+ /** Freeze the backbone's first N layers; `null` = the preset's choice. */
42684
+ freeze: number().int().nonnegative().nullable(),
42685
+ /** Cameras held out whole for evaluation; `null` = the orchestrator's default. */
42686
+ holdoutCameras: array(number().int()).nullable()
42687
+ });
42688
+ var TrainingSplitPlanSchema = object({
42689
+ holdoutCameras: array(number().int()).readonly(),
42690
+ /** Used when no camera is held out: the last N days of every camera. */
42691
+ holdoutLastDays: number().int().nonnegative(),
42692
+ /** Holdout subjects per class (camera holdout only; `null` = known only after the split). */
42693
+ holdoutSupport: record(string(), number().int()).nullable(),
42694
+ trainSubjects: number().int()
42695
+ });
42696
+ var TrainingRefusalReasonSchema = _enum([
42697
+ "unknown-dataset",
42698
+ "unknown-provider",
42699
+ "provider-not-configured",
42700
+ "unknown-base-model",
42701
+ "unknown-gpu",
42702
+ "dataset-too-large",
42703
+ "no-training-subjects",
42704
+ "job-already-running"
42705
+ ]);
42706
+ var TrainingJobPlanSchema = object({
42707
+ refusal: object({
42708
+ reason: TrainingRefusalReasonSchema,
42709
+ detail: string()
42710
+ }).nullable(),
42711
+ warnings: array(string()).readonly(),
42712
+ split: TrainingSplitPlanSchema.nullable(),
42713
+ estimate: object({
42714
+ datasetBytes: number().int(),
42715
+ uploadMinutesAt20Mbps: number(),
42716
+ gpuSecondsLow: number(),
42717
+ gpuSecondsHigh: number(),
42718
+ usdLow: number(),
42719
+ usdHigh: number(),
42720
+ notes: array(string()).readonly()
42721
+ }).nullable(),
42722
+ /** Pre-filled from the provider's settings; the operator may lower or raise them. */
42723
+ defaults: object({
42724
+ maxCostUsd: number(),
42725
+ maxRuntimeSec: number().int()
42726
+ }).nullable(),
42727
+ /** The sentence the confirm dialog repeats: where the frames go and when they are deleted. */
42728
+ dataNotice: string()
42729
+ });
42730
+ /**
42731
+ * Orchestrator-owned states, persisted. `uploading` covers exporting the
42732
+ * archive (it is streamed, never staged). Terminal: `failed`, `cancelled`,
42733
+ * `lost`, `expired`, `discarded`. `registered` and `canary` are where a
42734
+ * result lives after the operator acted on it.
42735
+ */
42736
+ var TrainingJobStateSchema = _enum([
42737
+ "uploading",
42738
+ "submitted",
42739
+ "starting",
42740
+ "running",
42741
+ "collecting",
42742
+ "ready",
42743
+ "registered",
42744
+ "canary",
42745
+ "failed",
42746
+ "cancelling",
42747
+ "cancelled",
42748
+ "lost",
42749
+ "expired",
42750
+ "discarded"
42751
+ ]);
42752
+ var TrainingFailureReasonSchema = _enum([
42753
+ "cost-cap",
42754
+ "runtime-cap",
42755
+ "upload-failed",
42756
+ "submit-failed",
42757
+ "trainer-failed",
42758
+ "result-invalid",
42759
+ "checksum-mismatch",
42760
+ "fetch-failed",
42761
+ "provider-error",
42762
+ "hub-restart-during-upload"
42763
+ ]);
42764
+ var TrainingProgressPointSchema = object({
42765
+ epoch: number().int(),
42766
+ map50: number().nullable(),
42767
+ map50_95: number().nullable()
42768
+ });
42769
+ var TrainingCanarySchema = object({
42770
+ deviceIds: array(number().int()).readonly(),
42771
+ since: number(),
42772
+ /** Every override the canary replaced, exactly, so rollback restores it. */
42773
+ previous: array(object({
42774
+ deviceId: number().int(),
42775
+ nodeId: string(),
42776
+ deviceKey: string(),
42777
+ patch: object({
42778
+ modelId: string().optional(),
42779
+ settings: record(string(), unknown()).readonly().optional()
42780
+ }).nullable()
42781
+ })).readonly()
42782
+ });
42783
+ var TrainingJobSchema = object({
42784
+ id: string(),
42785
+ idempotencyKey: string(),
42786
+ name: string(),
42787
+ createdAt: number(),
42788
+ updatedAt: number(),
42789
+ state: TrainingJobStateSchema,
42790
+ stage: TrainingStageSchema.nullable(),
42791
+ failure: object({
42792
+ reason: TrainingFailureReasonSchema,
42793
+ stage: string().nullable(),
42794
+ detail: string()
42795
+ }).nullable(),
42796
+ request: TrainingJobRequestSchema,
42797
+ maxCostUsd: number().nonnegative(),
42798
+ maxRuntimeSec: number().int().positive(),
42799
+ trainer: TrainerSourceRefSchema,
42800
+ datasetLayout: RetrainExportLayoutSchema,
42801
+ dataset: object({
42802
+ bytes: number().int(),
42803
+ sha256: string(),
42804
+ uploadedAt: number()
42805
+ }).nullable(),
42806
+ split: TrainingSplitPlanSchema,
42807
+ provider: object({
42808
+ state: ProviderJobStateSchema.nullable(),
42809
+ providerJobId: string().nullable(),
42810
+ startedAt: number().nullable(),
42811
+ endedAt: number().nullable(),
42812
+ billedSeconds: number(),
42813
+ costUsd: number(),
42814
+ costIsEstimate: boolean(),
42815
+ lastPolledAt: number().nullable()
42816
+ }),
42817
+ progress: object({
42818
+ epoch: number().int().nullable(),
42819
+ epochs: number().int().nullable(),
42820
+ etaSec: number().nullable(),
42821
+ series: array(TrainingProgressPointSchema).readonly()
42822
+ }),
42823
+ /** The last lines of the job's output (≤ 200), newest last. Never frame paths. */
42824
+ logTail: array(string()).readonly(),
42825
+ logCursor: string().nullable(),
42826
+ artifacts: object({
42827
+ bundleBytes: number().int(),
42828
+ bundleSha256: string(),
42829
+ fetchedAt: number(),
42830
+ /** When the staged artefacts are deleted from the hub. */
42831
+ expiresAt: number()
42832
+ }).nullable(),
42833
+ /** When the provider-side copy of the frames was deleted; null while it exists. */
42834
+ cloudDatasetDeletedAt: number().nullable(),
42835
+ /** A failed job's dataset is kept until then (the provider's grace), then deleted. */
42836
+ cloudCleanupDueAt: number().nullable(),
42837
+ /** Model ids registered from this job (base, and int8 when kept). */
42838
+ registeredModelIds: array(string()).readonly(),
42839
+ canary: TrainingCanarySchema.nullable()
42840
+ });
42841
+ var IdInput = object({ id: string().min(1) });
42842
+ method(TrainingDatasetVersionRowSchema, object({ stored: boolean() }), {
42843
+ kind: "mutation",
42844
+ auth: "admin"
42845
+ }), 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() }), {
42846
+ kind: "mutation",
42847
+ auth: "admin"
42848
+ }), method(object({}), array(TrainingBaseModelSchema).readonly(), { auth: "admin" }), method(TrainingJobRequestSchema, TrainingJobPlanSchema, {
42849
+ auth: "admin",
42850
+ timeoutMs: 6e4
42851
+ }), method(TrainingJobRequestSchema.extend({
42852
+ name: string().min(1).max(120),
42853
+ maxCostUsd: number().positive(),
42854
+ maxRuntimeSec: number().int().positive(),
42855
+ idempotencyKey: string().min(8).max(80)
42856
+ }), discriminatedUnion("kind", [object({
42857
+ kind: literal("started"),
42858
+ job: TrainingJobSchema
42859
+ }), object({
42860
+ kind: literal("refused"),
42861
+ reason: TrainingRefusalReasonSchema,
42862
+ detail: string()
42863
+ })]), {
42864
+ kind: "mutation",
42865
+ auth: "admin",
42866
+ timeoutMs: 12e4
42867
+ }), method(object({}), array(TrainingJobSchema).readonly(), { auth: "admin" }), method(IdInput, TrainingJobSchema.nullable(), { auth: "admin" }), method(IdInput, TrainingJobSchema, {
42868
+ kind: "mutation",
42869
+ auth: "admin",
42870
+ timeoutMs: 12e4
42871
+ }), method(IdInput, TrainingResultSchema.nullable(), { auth: "admin" }), method(IdInput.extend({ canaryDeviceIds: array(number().int()).readonly() }), TrainingJobSchema, {
42872
+ kind: "mutation",
42873
+ auth: "admin",
42874
+ timeoutMs: 30 * 6e4
42875
+ }), method(IdInput.extend({ deviceIds: array(number().int()).min(1).readonly() }), TrainingJobSchema, {
42876
+ kind: "mutation",
42877
+ auth: "admin",
42878
+ timeoutMs: 12e4
42879
+ }), method(IdInput, TrainingJobSchema, {
42880
+ kind: "mutation",
42881
+ auth: "admin",
42882
+ timeoutMs: 12e4
42883
+ }), method(IdInput, TrainingJobSchema, {
42884
+ kind: "mutation",
42885
+ auth: "admin"
42886
+ });
41486
42887
  SOURCE_CAPS.filter((cap) => cap !== "switch" && cap !== "motion");
41487
42888
  Object.freeze({
41488
42889
  person: .5,
@@ -43631,6 +45032,12 @@ Object.freeze({
43631
45032
  addonId: null,
43632
45033
  access: "create"
43633
45034
  },
45035
+ "backup.checkBackupKey": {
45036
+ capName: "backup",
45037
+ capScope: "system",
45038
+ addonId: null,
45039
+ access: "create"
45040
+ },
43634
45041
  "backup.delete": {
43635
45042
  capName: "backup",
43636
45043
  capScope: "system",
@@ -43643,6 +45050,18 @@ Object.freeze({
43643
45050
  addonId: null,
43644
45051
  access: "delete"
43645
45052
  },
45053
+ "backup.disableEncryption": {
45054
+ capName: "backup",
45055
+ capScope: "system",
45056
+ addonId: null,
45057
+ access: "create"
45058
+ },
45059
+ "backup.getEncryption": {
45060
+ capName: "backup",
45061
+ capScope: "system",
45062
+ addonId: null,
45063
+ access: "view"
45064
+ },
43646
45065
  "backup.getEntries": {
43647
45066
  capName: "backup",
43648
45067
  capScope: "system",
@@ -43697,6 +45116,12 @@ Object.freeze({
43697
45116
  addonId: null,
43698
45117
  access: "create"
43699
45118
  },
45119
+ "backup.setupEncryption": {
45120
+ capName: "backup",
45121
+ capScope: "system",
45122
+ addonId: null,
45123
+ access: "create"
45124
+ },
43700
45125
  "backup.trigger": {
43701
45126
  capName: "backup",
43702
45127
  capScope: "system",
@@ -44249,6 +45674,12 @@ Object.freeze({
44249
45674
  addonId: null,
44250
45675
  access: "create"
44251
45676
  },
45677
+ "customModelRegistry.importModelBundle": {
45678
+ capName: "custom-model-registry",
45679
+ capScope: "system",
45680
+ addonId: null,
45681
+ access: "create"
45682
+ },
44252
45683
  "customModelRegistry.listModels": {
44253
45684
  capName: "custom-model-registry",
44254
45685
  capScope: "system",
@@ -45689,6 +47120,12 @@ Object.freeze({
45689
47120
  addonId: null,
45690
47121
  access: "view"
45691
47122
  },
47123
+ "keychainAdmin.acknowledgeReset": {
47124
+ capName: "keychain-admin",
47125
+ capScope: "system",
47126
+ addonId: null,
47127
+ access: "create"
47128
+ },
45692
47129
  "keychainAdmin.deleteOrphans": {
45693
47130
  capName: "keychain-admin",
45694
47131
  capScope: "system",
@@ -45725,6 +47162,12 @@ Object.freeze({
45725
47162
  addonId: null,
45726
47163
  access: "delete"
45727
47164
  },
47165
+ "keychainAdmin.resetReport": {
47166
+ capName: "keychain-admin",
47167
+ capScope: "system",
47168
+ addonId: null,
47169
+ access: "delete"
47170
+ },
45728
47171
  "keychainAdmin.reveal": {
45729
47172
  capName: "keychain-admin",
45730
47173
  capScope: "system",
@@ -45737,6 +47180,12 @@ Object.freeze({
45737
47180
  addonId: null,
45738
47181
  access: "create"
45739
47182
  },
47183
+ "keychainAdmin.setSystemSecret": {
47184
+ capName: "keychain-admin",
47185
+ capScope: "system",
47186
+ addonId: null,
47187
+ access: "create"
47188
+ },
45740
47189
  "keychainAdmin.status": {
45741
47190
  capName: "keychain-admin",
45742
47191
  capScope: "system",
@@ -47183,6 +48632,12 @@ Object.freeze({
47183
48632
  addonId: null,
47184
48633
  access: "create"
47185
48634
  },
48635
+ "pipelineAnalytics.createRetrainDatasetVersion": {
48636
+ capName: "pipeline-analytics",
48637
+ capScope: "device",
48638
+ addonId: null,
48639
+ access: "create"
48640
+ },
47186
48641
  "pipelineAnalytics.deleteDeviceEvents": {
47187
48642
  capName: "pipeline-analytics",
47188
48643
  capScope: "device",
@@ -47195,6 +48650,12 @@ Object.freeze({
47195
48650
  addonId: null,
47196
48651
  access: "delete"
47197
48652
  },
48653
+ "pipelineAnalytics.deleteRetrainDatasetVersion": {
48654
+ capName: "pipeline-analytics",
48655
+ capScope: "device",
48656
+ addonId: null,
48657
+ access: "delete"
48658
+ },
47198
48659
  "pipelineAnalytics.deleteTracks": {
47199
48660
  capName: "pipeline-analytics",
47200
48661
  capScope: "device",
@@ -47417,6 +48878,12 @@ Object.freeze({
47417
48878
  addonId: null,
47418
48879
  access: "view"
47419
48880
  },
48881
+ "pipelineAnalytics.listRetrainDatasetVersions": {
48882
+ capName: "pipeline-analytics",
48883
+ capScope: "device",
48884
+ addonId: null,
48885
+ access: "view"
48886
+ },
47420
48887
  "pipelineAnalytics.listRetrainFrames": {
47421
48888
  capName: "pipeline-analytics",
47422
48889
  capScope: "device",
@@ -47447,6 +48914,12 @@ Object.freeze({
47447
48914
  addonId: null,
47448
48915
  access: "view"
47449
48916
  },
48917
+ "pipelineAnalytics.offerRetrainArchive": {
48918
+ capName: "pipeline-analytics",
48919
+ capScope: "device",
48920
+ addonId: null,
48921
+ access: "create"
48922
+ },
47450
48923
  "pipelineAnalytics.ownersWithMedia": {
47451
48924
  capName: "pipeline-analytics",
47452
48925
  capScope: "device",
@@ -47459,6 +48932,12 @@ Object.freeze({
47459
48932
  addonId: null,
47460
48933
  access: "create"
47461
48934
  },
48935
+ "pipelineAnalytics.previewRetrainDataset": {
48936
+ capName: "pipeline-analytics",
48937
+ capScope: "device",
48938
+ addonId: null,
48939
+ access: "view"
48940
+ },
47462
48941
  "pipelineAnalytics.proposeRetrainAnnotations": {
47463
48942
  capName: "pipeline-analytics",
47464
48943
  capScope: "device",
@@ -47597,6 +49076,12 @@ Object.freeze({
47597
49076
  addonId: null,
47598
49077
  access: "create"
47599
49078
  },
49079
+ "pipelineAnalytics.verifyRetrainDatasetVersion": {
49080
+ capName: "pipeline-analytics",
49081
+ capScope: "device",
49082
+ addonId: null,
49083
+ access: "view"
49084
+ },
47600
49085
  "pipelineAnalytics.wipeAllAnalytics": {
47601
49086
  capName: "pipeline-analytics",
47602
49087
  capScope: "device",
@@ -49973,6 +51458,174 @@ Object.freeze({
49973
51458
  addonId: null,
49974
51459
  access: "view"
49975
51460
  },
51461
+ "training.canaryResult": {
51462
+ capName: "training",
51463
+ capScope: "system",
51464
+ addonId: null,
51465
+ access: "create"
51466
+ },
51467
+ "training.cancelJob": {
51468
+ capName: "training",
51469
+ capScope: "system",
51470
+ addonId: null,
51471
+ access: "create"
51472
+ },
51473
+ "training.discardResult": {
51474
+ capName: "training",
51475
+ capScope: "system",
51476
+ addonId: null,
51477
+ access: "create"
51478
+ },
51479
+ "training.findDatasetVersionIdByName": {
51480
+ capName: "training",
51481
+ capScope: "system",
51482
+ addonId: null,
51483
+ access: "view"
51484
+ },
51485
+ "training.getDatasetVersion": {
51486
+ capName: "training",
51487
+ capScope: "system",
51488
+ addonId: null,
51489
+ access: "view"
51490
+ },
51491
+ "training.getJob": {
51492
+ capName: "training",
51493
+ capScope: "system",
51494
+ addonId: null,
51495
+ access: "view"
51496
+ },
51497
+ "training.getJobResult": {
51498
+ capName: "training",
51499
+ capScope: "system",
51500
+ addonId: null,
51501
+ access: "view"
51502
+ },
51503
+ "training.listBaseModels": {
51504
+ capName: "training",
51505
+ capScope: "system",
51506
+ addonId: null,
51507
+ access: "view"
51508
+ },
51509
+ "training.listDatasetVersions": {
51510
+ capName: "training",
51511
+ capScope: "system",
51512
+ addonId: null,
51513
+ access: "view"
51514
+ },
51515
+ "training.listJobs": {
51516
+ capName: "training",
51517
+ capScope: "system",
51518
+ addonId: null,
51519
+ access: "view"
51520
+ },
51521
+ "training.planJob": {
51522
+ capName: "training",
51523
+ capScope: "system",
51524
+ addonId: null,
51525
+ access: "view"
51526
+ },
51527
+ "training.putDatasetVersion": {
51528
+ capName: "training",
51529
+ capScope: "system",
51530
+ addonId: null,
51531
+ access: "create"
51532
+ },
51533
+ "training.registerResult": {
51534
+ capName: "training",
51535
+ capScope: "system",
51536
+ addonId: null,
51537
+ access: "create"
51538
+ },
51539
+ "training.removeDatasetVersion": {
51540
+ capName: "training",
51541
+ capScope: "system",
51542
+ addonId: null,
51543
+ access: "delete"
51544
+ },
51545
+ "training.rollbackCanary": {
51546
+ capName: "training",
51547
+ capScope: "system",
51548
+ addonId: null,
51549
+ access: "create"
51550
+ },
51551
+ "training.startJob": {
51552
+ capName: "training",
51553
+ capScope: "system",
51554
+ addonId: null,
51555
+ access: "create"
51556
+ },
51557
+ "trainingProvider.cancelJob": {
51558
+ capName: "training-provider",
51559
+ capScope: "system",
51560
+ addonId: null,
51561
+ access: "create"
51562
+ },
51563
+ "trainingProvider.cleanupJob": {
51564
+ capName: "training-provider",
51565
+ capScope: "system",
51566
+ addonId: null,
51567
+ access: "create"
51568
+ },
51569
+ "trainingProvider.describe": {
51570
+ capName: "training-provider",
51571
+ capScope: "system",
51572
+ addonId: null,
51573
+ access: "view"
51574
+ },
51575
+ "trainingProvider.estimateJob": {
51576
+ capName: "training-provider",
51577
+ capScope: "system",
51578
+ addonId: null,
51579
+ access: "view"
51580
+ },
51581
+ "trainingProvider.getJob": {
51582
+ capName: "training-provider",
51583
+ capScope: "system",
51584
+ addonId: null,
51585
+ access: "view"
51586
+ },
51587
+ "trainingProvider.listJobEvents": {
51588
+ capName: "training-provider",
51589
+ capScope: "system",
51590
+ addonId: null,
51591
+ access: "view"
51592
+ },
51593
+ "trainingProvider.listJobs": {
51594
+ capName: "training-provider",
51595
+ capScope: "system",
51596
+ addonId: null,
51597
+ access: "view"
51598
+ },
51599
+ "trainingProvider.offerArtifact": {
51600
+ capName: "training-provider",
51601
+ capScope: "system",
51602
+ addonId: null,
51603
+ access: "create"
51604
+ },
51605
+ "trainingProvider.readResult": {
51606
+ capName: "training-provider",
51607
+ capScope: "system",
51608
+ addonId: null,
51609
+ access: "create"
51610
+ },
51611
+ "trainingProvider.submitJob": {
51612
+ capName: "training-provider",
51613
+ capScope: "system",
51614
+ addonId: null,
51615
+ access: "create"
51616
+ },
51617
+ "trainingProvider.uploadDataset": {
51618
+ capName: "training-provider",
51619
+ capScope: "system",
51620
+ addonId: null,
51621
+ access: "create"
51622
+ },
51623
+ "trainingProvider.validateCredentials": {
51624
+ capName: "training-provider",
51625
+ capScope: "system",
51626
+ addonId: null,
51627
+ access: "create"
51628
+ },
49976
51629
  "turnProvider.getTurnServers": {
49977
51630
  capName: "turn-provider",
49978
51631
  capScope: "system",
@@ -49997,12 +51650,6 @@ Object.freeze({
49997
51650
  addonId: null,
49998
51651
  access: "create"
49999
51652
  },
50000
- "userManagement.createApiKey": {
50001
- capName: "user-management",
50002
- capScope: "system",
50003
- addonId: null,
50004
- access: "create"
50005
- },
50006
51653
  "userManagement.createScopedToken": {
50007
51654
  capName: "user-management",
50008
51655
  capScope: "system",
@@ -50039,12 +51686,6 @@ Object.freeze({
50039
51686
  addonId: null,
50040
51687
  access: "view"
50041
51688
  },
50042
- "userManagement.linkExternalIdentity": {
50043
- capName: "user-management",
50044
- capScope: "system",
50045
- addonId: null,
50046
- access: "create"
50047
- },
50048
51689
  "userManagement.listApiKeys": {
50049
51690
  capName: "user-management",
50050
51691
  capScope: "system",
@@ -50147,12 +51788,6 @@ Object.freeze({
50147
51788
  addonId: null,
50148
51789
  access: "create"
50149
51790
  },
50150
- "userManagement.validateApiKey": {
50151
- capName: "user-management",
50152
- capScope: "system",
50153
- addonId: null,
50154
- access: "view"
50155
- },
50156
51791
  "userManagement.validateCredentials": {
50157
51792
  capName: "user-management",
50158
51793
  capScope: "system",
@@ -54266,6 +55901,11 @@ Object.freeze({
54266
55901
  form: "single",
54267
55902
  optional: false
54268
55903
  }],
55904
+ "training.canaryResult": [{
55905
+ name: "deviceIds",
55906
+ form: "array",
55907
+ optional: false
55908
+ }],
54269
55909
  "update.getStatus": [{
54270
55910
  name: "deviceId",
54271
55911
  form: "single",