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