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