@camstack/addon-provider-homeassistant 1.2.164 → 1.2.166

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.
@@ -5377,7 +5377,7 @@ var ZodIssueCode = {
5377
5377
  var ZodFirstPartyTypeKind;
5378
5378
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
5379
5379
  //#endregion
5380
- //#region ../types/dist/sleep-Cr5YOk3m.mjs
5380
+ //#region ../types/dist/sleep-r3RWkGVx.mjs
5381
5381
  /**
5382
5382
  * The audio chunk plane's byte format, and the ONE expansion from a coded
5383
5383
  * window to float samples (D455).
@@ -5494,7 +5494,7 @@ function isKeychainStoredField(field) {
5494
5494
  var SECRET_CLEAR = { $secretClear: true };
5495
5495
  /** The `'***'` token D634 redaction writes for non-admins. */
5496
5496
  var LEGACY_DEVICE_REDACTION = "***";
5497
- function isRecord$1(value) {
5497
+ function isRecord$2(value) {
5498
5498
  return typeof value === "object" && value !== null && !Array.isArray(value);
5499
5499
  }
5500
5500
  function makeSecretMarker(ref) {
@@ -5505,12 +5505,12 @@ function makeSecretMarker(ref) {
5505
5505
  }
5506
5506
  /** A stored marker: an object whose `$secret` is a non-empty string. */
5507
5507
  function isSecretMarker(value) {
5508
- if (!isRecord$1(value)) return false;
5508
+ if (!isRecord$2(value)) return false;
5509
5509
  const ref = value["$secret"];
5510
5510
  return typeof ref === "string" && ref.length > 0;
5511
5511
  }
5512
5512
  function isSecretClear(value) {
5513
- return isRecord$1(value) && value["$secretClear"] === true;
5513
+ return isRecord$2(value) && value["$secretClear"] === true;
5514
5514
  }
5515
5515
  /**
5516
5516
  * The UI view of a stored secret field value: a marker becomes "set", inline
@@ -6026,6 +6026,13 @@ function globalSecretScope() {
6026
6026
  function encodeSegment(value) {
6027
6027
  return encodeURIComponent(value);
6028
6028
  }
6029
+ function decodeSegment(value) {
6030
+ try {
6031
+ return decodeURIComponent(value);
6032
+ } catch {
6033
+ return null;
6034
+ }
6035
+ }
6029
6036
  /**
6030
6037
  * The field path of a value inside an array item, addressed by the item's id:
6031
6038
  * `arrayItemFieldPath('providers', 'authentik', 'clientSecret')` →
@@ -6034,6 +6041,75 @@ function encodeSegment(value) {
6034
6041
  function arrayItemFieldPath(arrayKey, itemId, fieldKey) {
6035
6042
  return `${arrayKey}[${encodeSegment(itemId)}].${fieldKey}`;
6036
6043
  }
6044
+ function parseScope(segments) {
6045
+ switch (segments[0]) {
6046
+ case "global": return {
6047
+ scope: GLOBAL_SCOPE,
6048
+ used: 1
6049
+ };
6050
+ case "node": {
6051
+ const nodeId = segments[1] !== void 0 ? decodeSegment(segments[1]) : null;
6052
+ return nodeId === null || nodeId.length === 0 ? null : {
6053
+ scope: {
6054
+ kind: "node",
6055
+ nodeId
6056
+ },
6057
+ used: 2
6058
+ };
6059
+ }
6060
+ case "device": {
6061
+ const raw = segments[1];
6062
+ if (raw === void 0 || !/^\d+$/.test(raw)) return null;
6063
+ return {
6064
+ scope: {
6065
+ kind: "device",
6066
+ deviceId: Number(raw)
6067
+ },
6068
+ used: 2
6069
+ };
6070
+ }
6071
+ case "integration": {
6072
+ const id = segments[1] !== void 0 ? decodeSegment(segments[1]) : null;
6073
+ return id === null || id.length === 0 ? null : {
6074
+ scope: {
6075
+ kind: "integration",
6076
+ integrationId: id
6077
+ },
6078
+ used: 2
6079
+ };
6080
+ }
6081
+ case "row": {
6082
+ const collection = segments[1] !== void 0 ? decodeSegment(segments[1]) : null;
6083
+ const rowId = segments[2] !== void 0 ? decodeSegment(segments[2]) : null;
6084
+ if (collection === null || rowId === null || collection.length === 0 || rowId.length === 0) return null;
6085
+ return {
6086
+ scope: {
6087
+ kind: "row",
6088
+ collection,
6089
+ rowId
6090
+ },
6091
+ used: 3
6092
+ };
6093
+ }
6094
+ default: return null;
6095
+ }
6096
+ }
6097
+ /** Take a ref apart; `null` when it is not a well-formed ref. */
6098
+ function parseSecretRef(ref) {
6099
+ if (!ref.startsWith("secret://")) return null;
6100
+ const segments = ref.slice(9).split("/");
6101
+ const owner = segments[0] !== void 0 ? decodeSegment(segments[0]) : null;
6102
+ if (owner === null || owner.length === 0) return null;
6103
+ const parsed = parseScope(segments.slice(1));
6104
+ if (parsed === null) return null;
6105
+ const fieldPath = segments.slice(1 + parsed.used).join("/");
6106
+ if (fieldPath.length === 0) return null;
6107
+ return {
6108
+ owner,
6109
+ scope: parsed.scope,
6110
+ fieldPath
6111
+ };
6112
+ }
6037
6113
  /** A write to a secret path could not be stored in the keychain, so it was refused. */
6038
6114
  var KeychainWriteRefusedError = class extends Error {
6039
6115
  fieldPath;
@@ -6044,7 +6120,7 @@ var KeychainWriteRefusedError = class extends Error {
6044
6120
  }
6045
6121
  };
6046
6122
  var KEEP = { kind: "keep" };
6047
- function isRecord(value) {
6123
+ function isRecord$1(value) {
6048
6124
  return typeof value === "object" && value !== null && !Array.isArray(value);
6049
6125
  }
6050
6126
  function defaultMintId() {
@@ -6057,7 +6133,7 @@ function collectSecretMarkerRefs(value, out = []) {
6057
6133
  return out;
6058
6134
  }
6059
6135
  if (Array.isArray(value)) for (const item of value) collectSecretMarkerRefs(item, out);
6060
- else if (isRecord(value)) for (const child of Object.values(value)) collectSecretMarkerRefs(child, out);
6136
+ else if (isRecord$1(value)) for (const child of Object.values(value)) collectSecretMarkerRefs(child, out);
6061
6137
  return out;
6062
6138
  }
6063
6139
  async function storedValueEquals(secrets, marker, candidate) {
@@ -6112,7 +6188,7 @@ function rowId(row, idKey) {
6112
6188
  return null;
6113
6189
  }
6114
6190
  async function writeArray(ctx, node, incoming, stored, fieldPath) {
6115
- const storedRows = Array.isArray(stored) ? stored.filter(isRecord) : [];
6191
+ const storedRows = Array.isArray(stored) ? stored.filter(isRecord$1) : [];
6116
6192
  if (!Array.isArray(incoming)) {
6117
6193
  ctx.deletes.push(...collectSecretMarkerRefs(storedRows));
6118
6194
  return {
@@ -6128,7 +6204,7 @@ async function writeArray(ctx, node, incoming, stored, fieldPath) {
6128
6204
  const kept = /* @__PURE__ */ new Set();
6129
6205
  const rows = [];
6130
6206
  for (const row of incoming) {
6131
- if (!isRecord(row)) {
6207
+ if (!isRecord$1(row)) {
6132
6208
  rows.push(row);
6133
6209
  continue;
6134
6210
  }
@@ -6153,7 +6229,7 @@ async function writeNode(ctx, node, incoming, stored, fieldPath) {
6153
6229
  case "leaf": return writeLeaf(ctx, incoming, stored, fieldPath);
6154
6230
  case "array": return writeArray(ctx, node, incoming, stored, fieldPath);
6155
6231
  case "object": {
6156
- if (!isRecord(incoming)) {
6232
+ if (!isRecord$1(incoming)) {
6157
6233
  if (incoming === void 0) return KEEP;
6158
6234
  ctx.deletes.push(...collectSecretMarkerRefs(stored));
6159
6235
  return {
@@ -6161,7 +6237,7 @@ async function writeNode(ctx, node, incoming, stored, fieldPath) {
6161
6237
  value: incoming
6162
6238
  };
6163
6239
  }
6164
- const storedObj = isRecord(stored) ? stored : {};
6240
+ const storedObj = isRecord$1(stored) ? stored : {};
6165
6241
  return {
6166
6242
  kind: "value",
6167
6243
  value: await writeMembers(ctx, node.children, incoming, storedObj, (m) => `${fieldPath}.${m}`)
@@ -6220,12 +6296,19 @@ async function transformSecretWrite(input) {
6220
6296
  }
6221
6297
  };
6222
6298
  }
6299
+ /** Is `ref` one of `owner`'s refs? */
6300
+ function isSecretRefOwnedBy(ref, owner) {
6301
+ return parseSecretRef(ref)?.owner === owner;
6302
+ }
6223
6303
  /**
6224
6304
  * Replace every marker in `value` with its keychain value. Returns the SAME
6225
6305
  * reference when there is no marker (no allocation, no keychain call).
6226
6306
  */
6227
- async function resolveSecretMarkers(value, secrets) {
6228
- const refs = collectSecretMarkerRefs(value);
6307
+ async function resolveSecretMarkers(value, secrets, options = {}) {
6308
+ const keepMarker = options.unresolved === "keep-marker";
6309
+ const owner = options.ownedBy;
6310
+ const inScope = (ref) => owner === void 0 || isSecretRefOwnedBy(ref, owner);
6311
+ const refs = collectSecretMarkerRefs(value).filter(inScope);
6229
6312
  if (refs.length === 0) return {
6230
6313
  value,
6231
6314
  unresolved: []
@@ -6249,10 +6332,18 @@ async function resolveSecretMarkers(value, secrets) {
6249
6332
  }
6250
6333
  const substitute = (v) => {
6251
6334
  if (isSecretMarker(v)) {
6335
+ if (!inScope(v.$secret)) return {
6336
+ keep: true,
6337
+ value: v
6338
+ };
6252
6339
  const answer = answers[v.$secret];
6253
- return answer?.kind === "value" ? {
6340
+ if (answer?.kind === "value") return {
6254
6341
  keep: true,
6255
6342
  value: answer.value
6343
+ };
6344
+ return keepMarker ? {
6345
+ keep: true,
6346
+ value: v
6256
6347
  } : {
6257
6348
  keep: false,
6258
6349
  value: void 0
@@ -6269,7 +6360,7 @@ async function resolveSecretMarkers(value, secrets) {
6269
6360
  value: items
6270
6361
  };
6271
6362
  }
6272
- if (isRecord(v)) {
6363
+ if (isRecord$1(v)) {
6273
6364
  const out = {};
6274
6365
  for (const [k, child] of Object.entries(v)) {
6275
6366
  const s = substitute(child);
@@ -6290,14 +6381,152 @@ async function resolveSecretMarkers(value, secrets) {
6290
6381
  unresolved
6291
6382
  };
6292
6383
  }
6293
- function touchesTree(tree, patch) {
6294
- if (tree.size === 0) return false;
6295
- for (const key of Object.keys(patch)) {
6296
- const at = key.indexOf("@");
6297
- if (tree.has(at > 0 ? key.slice(0, at) : key)) return true;
6384
+ /** An addon tried to replace a stored secret it could not read. Nothing was written. */
6385
+ var SecretOverwriteRefusedError = class extends Error {
6386
+ ref;
6387
+ reason;
6388
+ constructor(ref, reason) {
6389
+ super(`secret ${ref} was not replaced: its stored value cannot be read right now (${reason}), and an addon may not overwrite a secret it cannot see. Nothing was written.`);
6390
+ this.ref = ref;
6391
+ this.reason = reason;
6392
+ this.name = "SecretOverwriteRefusedError";
6393
+ }
6394
+ };
6395
+ function isRecord(value) {
6396
+ return typeof value === "object" && value !== null && !Array.isArray(value);
6397
+ }
6398
+ function resolvedValue(pass, marker) {
6399
+ const answer = pass.answers[marker.$secret];
6400
+ return answer?.kind === "value" ? answer.value : null;
6401
+ }
6402
+ async function atMarker(pass, incoming, stored) {
6403
+ if (incoming === null) return stored;
6404
+ if (typeof incoming !== "string") return incoming;
6405
+ if (incoming === resolvedValue(pass, stored)) return stored;
6406
+ const intent = classifySecretWrite(incoming);
6407
+ if (intent.kind !== "set") return stored;
6408
+ const ref = stored.$secret;
6409
+ if (!isSecretRefOwnedBy(ref, pass.secrets.owner)) return incoming;
6410
+ const answer = pass.answers[ref];
6411
+ if ((answer === void 0 || answer.kind === "unavailable" || answer.kind === "forbidden") && !pass.operatorWrite) throw new SecretOverwriteRefusedError(ref, answer === void 0 ? "not-initialized" : answer.kind === "unavailable" ? answer.reason : answer.kind);
6412
+ try {
6413
+ await pass.secrets.put(ref, intent.value);
6414
+ } catch (err) {
6415
+ throw new KeychainWriteRefusedError(ref, err);
6416
+ }
6417
+ pass.changedRefs.push(ref);
6418
+ return stored;
6419
+ }
6420
+ function inArray(pass, incoming, stored) {
6421
+ return incoming.map((item, index) => {
6422
+ const twin = stored[index];
6423
+ if (isSecretMarker(twin)) return typeof item === "string" && item === resolvedValue(pass, twin) ? twin : item;
6424
+ if (isRecord(item) && isRecord(twin)) return inArrayRow(pass, item, twin);
6425
+ if (Array.isArray(item) && Array.isArray(twin)) return inArray(pass, item, twin);
6426
+ return item;
6427
+ });
6428
+ }
6429
+ function inArrayRow(pass, incoming, stored) {
6430
+ const out = { ...incoming };
6431
+ for (const [key, value] of Object.entries(incoming)) {
6432
+ const twin = stored[key];
6433
+ if (isSecretMarker(twin)) {
6434
+ if (typeof value === "string" && value === resolvedValue(pass, twin)) out[key] = twin;
6435
+ } else if (isRecord(value) && isRecord(twin)) out[key] = inArrayRow(pass, value, twin);
6436
+ else if (Array.isArray(value) && Array.isArray(twin)) out[key] = inArray(pass, value, twin);
6437
+ }
6438
+ return out;
6439
+ }
6440
+ async function walk(pass, incoming, stored) {
6441
+ if (isSecretMarker(stored)) return atMarker(pass, incoming, stored);
6442
+ if (Array.isArray(incoming) && Array.isArray(stored)) return inArray(pass, incoming, stored);
6443
+ if (!isRecord(incoming) || !isRecord(stored)) return incoming;
6444
+ const out = { ...incoming };
6445
+ for (const [key, value] of Object.entries(incoming)) out[key] = await walk(pass, value, stored[key]);
6446
+ return out;
6447
+ }
6448
+ /** Restore markers a write-back carries as values. See the file doc. */
6449
+ async function restoreUnchangedSecrets(input) {
6450
+ const refs = [];
6451
+ for (const key of Object.keys(input.patch)) collectSecretMarkerRefs(input.stored[key], refs);
6452
+ const owned = refs.filter((ref) => isSecretRefOwnedBy(ref, input.secrets.owner));
6453
+ if (owned.length === 0) return {
6454
+ patch: input.patch,
6455
+ changedRefs: []
6456
+ };
6457
+ const pass = {
6458
+ secrets: input.secrets,
6459
+ answers: await input.secrets.resolve([...new Set(owned)]),
6460
+ operatorWrite: input.operatorWrite,
6461
+ changedRefs: []
6462
+ };
6463
+ const out = {};
6464
+ for (const [key, value] of Object.entries(input.patch)) out[key] = await walk(pass, value, input.stored[key]);
6465
+ return {
6466
+ patch: out,
6467
+ changedRefs: pass.changedRefs
6468
+ };
6469
+ }
6470
+ /** Structural equality over JSON-shaped values (key order does not matter). */
6471
+ function isJsonEqual(a, b) {
6472
+ if (Object.is(a, b)) return true;
6473
+ if (Array.isArray(a)) return Array.isArray(b) && a.length === b.length && a.every((v, i) => isJsonEqual(v, b[i]));
6474
+ if (isRecord(a) && isRecord(b)) {
6475
+ const keys = Object.keys(a);
6476
+ if (keys.length !== Object.keys(b).length) return false;
6477
+ return keys.every((k) => Object.prototype.hasOwnProperty.call(b, k) && isJsonEqual(a[k], b[k]));
6298
6478
  }
6299
6479
  return false;
6300
6480
  }
6481
+ /** The patch without the keys whose value already equals the stored one. */
6482
+ function dropUnchangedKeys(patch, stored) {
6483
+ const out = {};
6484
+ for (const [key, value] of Object.entries(patch)) {
6485
+ if (Object.prototype.hasOwnProperty.call(stored, key) && isJsonEqual(value, stored[key])) continue;
6486
+ out[key] = value;
6487
+ }
6488
+ return out;
6489
+ }
6490
+ /** The top-level keys of a blob that hold at least one of `owner`'s markers. */
6491
+ function markerKeysOf(blob, owner) {
6492
+ const keys = /* @__PURE__ */ new Set();
6493
+ for (const [key, value] of Object.entries(blob)) if (collectSecretMarkerRefs(value).some((ref) => isSecretRefOwnedBy(ref, owner))) keys.add(key);
6494
+ return keys;
6495
+ }
6496
+ function nodeFromStored(value, owner) {
6497
+ if (isSecretMarker(value)) return isSecretRefOwnedBy(value.$secret, owner) ? { kind: "leaf" } : null;
6498
+ if (!isRecord(value)) return null;
6499
+ const children = /* @__PURE__ */ new Map();
6500
+ for (const [key, child] of Object.entries(value)) {
6501
+ const node = nodeFromStored(child, owner);
6502
+ if (node !== null) children.set(key, node);
6503
+ }
6504
+ return children.size > 0 ? {
6505
+ kind: "object",
6506
+ children
6507
+ } : null;
6508
+ }
6509
+ /**
6510
+ * The declared secret tree, widened by every place the STORED blob holds a
6511
+ * marker under one of `keys` — so a marker the schema no longer declares (or
6512
+ * never declared: Wyze before b4906cec6) still gets the save path's
6513
+ * KEEP / SET / CLEAR semantics instead of being overwritten by whatever the
6514
+ * addon writes. Markers inside arrays are not added: a row has no id field to
6515
+ * match by unless the schema declares one. Only `owner`'s markers count: a
6516
+ * builtin that keeps another addon's marker (device-manager) never takes it
6517
+ * over.
6518
+ */
6519
+ function widenTreeWithStoredMarkers(declared, stored, keys, owner) {
6520
+ const added = /* @__PURE__ */ new Map();
6521
+ for (const key of keys) {
6522
+ const at = key.indexOf("@");
6523
+ const base = at > 0 ? key.slice(0, at) : key;
6524
+ if (declared.has(base) || added.has(base)) continue;
6525
+ const node = nodeFromStored(stored[key], owner);
6526
+ if (node !== null) added.set(base, node);
6527
+ }
6528
+ return added.size === 0 ? declared : new Map([...declared, ...added]);
6529
+ }
6301
6530
  /** The blob as stored now; a failed read REFUSES the write instead of guessing. */
6302
6531
  async function readStoredAddonBlob(raw) {
6303
6532
  const threeWay = raw.readAddonStoreResult;
@@ -6306,7 +6535,41 @@ async function readStoredAddonBlob(raw) {
6306
6535
  if (result.kind === "failed") throw new Error(`settings write refused: the stored blob could not be read (${result.error})`);
6307
6536
  return result.kind === "missing" ? {} : result.value;
6308
6537
  }
6309
- function createSecretAwareSettings(raw, opts) {
6538
+ function touchesTree(tree, patch) {
6539
+ if (tree.size === 0) return false;
6540
+ for (const key of Object.keys(patch)) {
6541
+ const at = key.indexOf("@");
6542
+ if (tree.has(at > 0 ? key.slice(0, at) : key)) return true;
6543
+ }
6544
+ return false;
6545
+ }
6546
+ /**
6547
+ * Which top-level keys of each store held markers when last seen. `undefined`
6548
+ * for a store not seen yet: its first write reads it, to be safe.
6549
+ */
6550
+ var MarkerKeyIndex = class {
6551
+ owner;
6552
+ byStore = /* @__PURE__ */ new Map();
6553
+ constructor(owner) {
6554
+ this.owner = owner;
6555
+ }
6556
+ seen(store, blob) {
6557
+ this.byStore.set(store, markerKeysOf(blob, this.owner));
6558
+ }
6559
+ wrote(store, patch) {
6560
+ const keys = this.byStore.get(store);
6561
+ if (keys === void 0) return;
6562
+ const now = markerKeysOf(patch, this.owner);
6563
+ for (const key of Object.keys(patch)) if (now.has(key)) keys.add(key);
6564
+ else keys.delete(key);
6565
+ }
6566
+ mayHoldMarkers(store, patch) {
6567
+ const keys = this.byStore.get(store);
6568
+ if (keys === void 0) return true;
6569
+ return Object.keys(patch).some((key) => keys.has(key));
6570
+ }
6571
+ };
6572
+ function createHandle(raw, opts) {
6310
6573
  const chains = /* @__PURE__ */ new Map();
6311
6574
  const serialize = (key, fn) => {
6312
6575
  const next = (chains.get(key) ?? Promise.resolve()).then(fn, fn);
@@ -6317,46 +6580,130 @@ function createSecretAwareSettings(raw, opts) {
6317
6580
  });
6318
6581
  return next;
6319
6582
  };
6320
- const write = async (chainKey, tree, scope, patch, readStored, rawWrite) => {
6321
- if (!touchesTree(tree, patch)) return rawWrite(patch);
6322
- return serialize(chainKey, async () => {
6583
+ const index = new MarkerKeyIndex(opts.secrets.owner);
6584
+ const resolveRead = async (store, blob) => {
6585
+ index.seen(store, blob);
6586
+ const { value, unresolved } = await resolveSecretMarkers(blob, opts.secrets, {
6587
+ unresolved: "keep-marker",
6588
+ ownedBy: opts.secrets.owner
6589
+ });
6590
+ if (unresolved.length > 0) opts.onUnresolved?.(unresolved);
6591
+ return value;
6592
+ };
6593
+ const write = async (store, declared, scope, patch, readStored, rawWrite) => {
6594
+ if (!touchesTree(declared, patch) && !index.mayHoldMarkers(store, patch)) {
6595
+ await rawWrite(patch);
6596
+ index.wrote(store, patch);
6597
+ return { changed: true };
6598
+ }
6599
+ return serialize(store, async () => {
6323
6600
  const stored = await readStored();
6601
+ index.seen(store, stored);
6602
+ const operatorWrite = opts.isOperatorWrite?.() === true;
6603
+ const restored = await restoreUnchangedSecrets({
6604
+ patch,
6605
+ stored,
6606
+ secrets: opts.secrets,
6607
+ operatorWrite
6608
+ });
6324
6609
  const result = await transformSecretWrite({
6325
- tree,
6610
+ tree: widenTreeWithStoredMarkers(declared, stored, Object.keys(restored.patch), opts.secrets.owner),
6326
6611
  secrets: opts.secrets,
6327
- patch,
6612
+ patch: restored.patch,
6328
6613
  stored,
6329
6614
  ...scope !== void 0 ? { scope } : {},
6330
- operatorWrite: opts.isOperatorWrite?.() === true
6615
+ operatorWrite
6331
6616
  });
6332
- if (Object.keys(result.patch).length > 0) await rawWrite(result.patch);
6617
+ const effective = dropUnchangedKeys(result.patch, stored);
6618
+ const wroteBlob = Object.keys(effective).length > 0;
6619
+ if (wroteBlob) {
6620
+ await rawWrite(effective);
6621
+ index.wrote(store, effective);
6622
+ }
6333
6623
  const { orphaned } = await result.afterWrite();
6334
6624
  if (orphaned.length > 0) opts.onOrphaned(orphaned);
6625
+ return { changed: wroteBlob || restored.changedRefs.length > 0 };
6335
6626
  });
6336
6627
  };
6337
- const wrapped = {
6338
- writeAddonStore: (patch) => write("addon", opts.addonTree(), void 0, patch, () => readStoredAddonBlob(raw), (p) => raw.writeAddonStore(p)),
6339
- writeDeviceStore: (deviceId, patch) => write(`device:${deviceId}`, opts.deviceTree(), {
6340
- kind: "device",
6341
- deviceId
6342
- }, patch, () => raw.readDeviceStore(deviceId), (p) => raw.writeDeviceStore(deviceId, p))
6628
+ const writeAddon = (patch) => write("addon", opts.addonTree(), void 0, patch, () => readStoredAddonBlob(raw), (p) => raw.writeAddonStore(p));
6629
+ const readAddonStoreResult = raw.readAddonStoreResult;
6630
+ const readAddonStoreKeyResult = raw.readAddonStoreKeyResult;
6631
+ const readDeviceStoreBatch = raw.readDeviceStoreBatch;
6632
+ const overrides = {
6633
+ readAddonStore: async () => resolveRead("addon", await raw.readAddonStore()),
6634
+ ...readAddonStoreResult !== void 0 ? { readAddonStoreResult: async () => {
6635
+ const result = await readAddonStoreResult.call(raw);
6636
+ return result.kind === "value" ? {
6637
+ kind: "value",
6638
+ value: await resolveRead("addon", result.value)
6639
+ } : result;
6640
+ } } : {},
6641
+ ...readAddonStoreKeyResult !== void 0 ? { readAddonStoreKeyResult: async (key) => {
6642
+ const result = await readAddonStoreKeyResult.call(raw, key);
6643
+ if (result.kind !== "present") return result;
6644
+ const { value, unresolved } = await resolveSecretMarkers({ [key]: result.value }, opts.secrets, {
6645
+ unresolved: "keep-marker",
6646
+ ownedBy: opts.secrets.owner
6647
+ });
6648
+ if (unresolved.length > 0) opts.onUnresolved?.(unresolved);
6649
+ return {
6650
+ kind: "present",
6651
+ value: value[key]
6652
+ };
6653
+ } } : {},
6654
+ readDeviceStore: async (deviceId) => resolveRead(`device:${deviceId}`, await raw.readDeviceStore(deviceId)),
6655
+ ...readDeviceStoreBatch !== void 0 ? { readDeviceStoreBatch: async (deviceIds) => {
6656
+ const rows = await readDeviceStoreBatch.call(raw, deviceIds);
6657
+ const out = /* @__PURE__ */ new Map();
6658
+ for (const [deviceId, blob] of rows) out.set(deviceId, await resolveRead(`device:${deviceId}`, blob));
6659
+ return out;
6660
+ } } : {},
6661
+ writeAddonStore: async (patch) => {
6662
+ await writeAddon(patch);
6663
+ },
6664
+ writeDeviceStore: async (deviceId, patch) => {
6665
+ await write(`device:${deviceId}`, opts.deviceTree(), {
6666
+ kind: "device",
6667
+ deviceId
6668
+ }, patch, () => raw.readDeviceStore(deviceId), (p) => raw.writeDeviceStore(deviceId, p));
6669
+ }
6670
+ };
6671
+ return {
6672
+ settings: new Proxy(raw, { get(target, prop, receiver) {
6673
+ if (typeof prop === "string" && Object.prototype.hasOwnProperty.call(overrides, prop)) return Reflect.get(overrides, prop);
6674
+ const value = Reflect.get(target, prop, receiver);
6675
+ return typeof value === "function" ? value.bind(target) : value;
6676
+ } }),
6677
+ raw: {
6678
+ readAddonStore: async () => {
6679
+ const blob = await raw.readAddonStore();
6680
+ index.seen("addon", blob);
6681
+ return blob;
6682
+ },
6683
+ readDeviceStore: async (deviceId) => {
6684
+ const blob = await raw.readDeviceStore(deviceId);
6685
+ index.seen(`device:${deviceId}`, blob);
6686
+ return blob;
6687
+ }
6688
+ },
6689
+ writeAddonStore: writeAddon
6343
6690
  };
6344
- return new Proxy(raw, { get(target, prop, receiver) {
6345
- if (prop === "writeAddonStore") return wrapped.writeAddonStore;
6346
- if (prop === "writeDeviceStore") return wrapped.writeDeviceStore;
6347
- const value = Reflect.get(target, prop, receiver);
6348
- return typeof value === "function" ? value.bind(target) : value;
6349
- } });
6350
6691
  }
6351
- /** The context the addon sees: identical, except that its settings writes are secret-aware. */
6352
- function withSecretAwareSettings(context, opts) {
6692
+ /** The context the addon sees, plus the private raw view and write outcome. */
6693
+ function createSecretAwareContext(context, opts) {
6353
6694
  const raw = context.settings;
6354
- if (raw === void 0) return context;
6355
- const settings = createSecretAwareSettings(raw, opts);
6356
- return new Proxy(context, { get(target, prop, receiver) {
6357
- if (prop === "settings") return settings;
6358
- return Reflect.get(target, prop, receiver);
6359
- } });
6695
+ if (raw === void 0) return {
6696
+ context,
6697
+ handle: null
6698
+ };
6699
+ const handle = createHandle(raw, opts);
6700
+ return {
6701
+ context: new Proxy(context, { get(target, prop, receiver) {
6702
+ if (prop === "settings") return handle.settings;
6703
+ return Reflect.get(target, prop, receiver);
6704
+ } }),
6705
+ handle
6706
+ };
6360
6707
  }
6361
6708
  var LEAF = { kind: "leaf" };
6362
6709
  var DEFAULT_ITEM_ID_KEY = "id";
@@ -6531,6 +6878,14 @@ var BaseAddon = class {
6531
6878
  _secretChangeUnsub = null;
6532
6879
  /** >0 while an OPERATOR's settings write is being applied. */
6533
6880
  _operatorWriteDepth = 0;
6881
+ /**
6882
+ * The keychain-aware settings handle (D798). Its `raw` view is the ONLY way
6883
+ * to the marker-bearing blobs and stays private to this class: the form
6884
+ * hydrate and config resolution need markers, addon code never does.
6885
+ */
6886
+ _secretSettings = null;
6887
+ /** Refs an addon-facing read could not resolve — each is logged once per process. */
6888
+ _loggedUnresolvedReads = /* @__PURE__ */ new Set();
6534
6889
  constructor(defaults) {
6535
6890
  this.defaults = defaults;
6536
6891
  this._config = { ...defaults };
@@ -6567,13 +6922,21 @@ var BaseAddon = class {
6567
6922
  }
6568
6923
  async initialize(context) {
6569
6924
  const secrets = context.secrets;
6570
- this._ctx = secrets !== void 0 ? withSecretAwareSettings(context, {
6571
- secrets,
6572
- addonTree: () => this.addonSecretTree(),
6573
- deviceTree: () => this.deviceSecretTree(),
6574
- onOrphaned: (refs) => context.logger.warn("keychain refs dropped by a settings write could not be deleted", { meta: { refs: [...refs] } }),
6575
- isOperatorWrite: () => this._operatorWriteDepth > 0
6576
- }) : context;
6925
+ if (secrets !== void 0) {
6926
+ const { context: wrapped, handle } = createSecretAwareContext(context, {
6927
+ secrets,
6928
+ addonTree: () => this.addonSecretTree(),
6929
+ deviceTree: () => this.deviceSecretTree(),
6930
+ onOrphaned: (refs) => context.logger.warn("keychain refs dropped by a settings write could not be deleted", { meta: { refs: [...refs] } }),
6931
+ isOperatorWrite: () => this._operatorWriteDepth > 0,
6932
+ onUnresolved: (unresolved) => this.logUnresolvedRead(unresolved)
6933
+ });
6934
+ this._ctx = wrapped;
6935
+ this._secretSettings = handle;
6936
+ } else {
6937
+ this._ctx = context;
6938
+ this._secretSettings = null;
6939
+ }
6577
6940
  await this.resolveConfig();
6578
6941
  if (secrets !== void 0) this._secretChangeUnsub = secrets.onChange((ref) => {
6579
6942
  if (this._configSecretRefs.has(ref)) this.scheduleSecretReresolve(SECRET_CHANGE_DEBOUNCE_MS);
@@ -6690,11 +7053,8 @@ var BaseAddon = class {
6690
7053
  async getGlobalSettings(overlay, cap, nodeId) {
6691
7054
  const schema = this.globalSettingsSchema(cap);
6692
7055
  if (!schema) return { sections: [] };
6693
- const projected = await this.resolveGlobalStore(nodeId, cap);
6694
- return hydrateSchema(schema, overlay ? {
6695
- ...projected,
6696
- ...overlay
6697
- } : projected, { inlineSecretsAsViews: true });
7056
+ const projected = await this.readRawProjectedStore(nodeId, cap);
7057
+ return hydrateSchema(schema, overlay ? await this.overlayKeepingMarkers(projected, overlay) : projected, { inlineSecretsAsViews: true });
6698
7058
  }
6699
7059
  /**
6700
7060
  * The integration-level view of this addon's settings: exactly the sections
@@ -6739,7 +7099,7 @@ var BaseAddon = class {
6739
7099
  });
6740
7100
  }
6741
7101
  if (sections.length === 0) return null;
6742
- const projected = await this.resolveGlobalStore(nodeId);
7102
+ const projected = await this.readRawProjectedStore(nodeId);
6743
7103
  return hydrateSchema({
6744
7104
  ...schema,
6745
7105
  sections
@@ -6756,12 +7116,50 @@ var BaseAddon = class {
6756
7116
  * the store for custom option logic (option narrowing, value snapping) to
6757
7117
  * read it per-node — never `ctx.settings.readAddonStore()` directly.
6758
7118
  * `nodeId` omitted ⇒ the local node (node-blind injection from ctx).
7119
+ *
7120
+ * Keychain values come back RESOLVED (D798): a secret reads as its value,
7121
+ * never as a `{ $secret }` marker. One the keychain cannot serve right now
7122
+ * stays a marker — "stored, unavailable" (`isSecretMarker()` is true, and it
7123
+ * is listed in {@link unresolvedSecrets}) — never `''` and never absent, so
7124
+ * it cannot be mistaken for "nothing stored, mint a new one". Writing the
7125
+ * resolved blob back is a no-op for every unchanged secret.
6759
7126
  */
6760
7127
  async resolveGlobalStore(nodeId, cap) {
6761
7128
  const raw = await this._ctx?.settings?.readAddonStore() ?? {};
7129
+ return this.projectForNode(raw, nodeId, cap);
7130
+ }
7131
+ projectForNode(store, nodeId, cap) {
6762
7132
  const keys = this.perNodeKeys(cap);
6763
7133
  const node = normalizeNodeId(nodeId ?? this._ctx?.kernel?.localNodeId);
6764
- return keys.size > 0 ? projectStore(raw, keys, node) : raw;
7134
+ return keys.size > 0 ? projectStore(store, keys, node) : store;
7135
+ }
7136
+ /** The PROJECTED store with its markers — the form hydrate only (D798). */
7137
+ async readRawProjectedStore(nodeId, cap) {
7138
+ const raw = await this.rawSettings()?.readAddonStore() ?? {};
7139
+ return this.projectForNode(raw, nodeId, cap);
7140
+ }
7141
+ /**
7142
+ * `{ ...stored, ...overlay }`, except that an overlay member equal to the
7143
+ * RESOLVED stored one keeps the stored (marker-bearing) member — so a form
7144
+ * hydrated from a resolved overlay still shows a secret as "set", never as
7145
+ * its value.
7146
+ */
7147
+ async overlayKeepingMarkers(stored, overlay) {
7148
+ const secrets = this._ctx?.secrets;
7149
+ const merged = {
7150
+ ...stored,
7151
+ ...overlay
7152
+ };
7153
+ if (secrets === void 0 || collectSecretMarkerRefs(stored).length === 0) return merged;
7154
+ const { value: resolved } = await resolveSecretMarkers(stored, secrets, {
7155
+ unresolved: "keep-marker",
7156
+ ownedBy: secrets.owner
7157
+ });
7158
+ for (const key of Object.keys(overlay)) {
7159
+ if (collectSecretMarkerRefs(stored[key]).length === 0) continue;
7160
+ if (isJsonEqual(overlay[key], resolved[key])) merged[key] = stored[key];
7161
+ }
7162
+ return merged;
6765
7163
  }
6766
7164
  /**
6767
7165
  * Whether ONE global key of this addon's store was written, read three-way
@@ -6826,8 +7224,12 @@ var BaseAddon = class {
6826
7224
  async clearSecrets(keys, nodeId) {
6827
7225
  const tree = this.addonSecretTree();
6828
7226
  const keychain = this._ctx?.secrets !== void 0;
7227
+ const stored = keychain ? await this.readAddonStoreWithRetry() : {};
6829
7228
  const patch = {};
6830
- for (const key of keys) patch[key] = keychain && tree.has(key) ? SECRET_CLEAR : "";
7229
+ for (const key of keys) {
7230
+ const keychainStored = tree.has(key) || collectSecretMarkerRefs(stored[key]).length > 0;
7231
+ patch[key] = keychain && keychainStored ? SECRET_CLEAR : "";
7232
+ }
6831
7233
  await this.applyGlobalPatch(patch, nodeId);
6832
7234
  }
6833
7235
  async applyGlobalPatch(barePatch, nodeId) {
@@ -6835,7 +7237,11 @@ var BaseAddon = class {
6835
7237
  const localNode = normalizeNodeId(this._ctx?.kernel?.localNodeId);
6836
7238
  const target = normalizeNodeId(nodeId ?? this._ctx?.kernel?.localNodeId);
6837
7239
  const scoped = keys.size > 0 ? scopePatch(barePatch, keys, target) : barePatch;
6838
- await this._ctx?.settings?.writeAddonStore(scoped);
7240
+ const handle = this._secretSettings;
7241
+ if (handle !== null) {
7242
+ const { changed } = await handle.writeAddonStore(scoped);
7243
+ if (!changed) return;
7244
+ } else await this._ctx?.settings?.writeAddonStore(scoped);
6839
7245
  if (target !== localNode) return;
6840
7246
  await this.resolveConfig();
6841
7247
  await this.onConfigChanged();
@@ -6888,7 +7294,7 @@ var BaseAddon = class {
6888
7294
  async getDeviceSettings(deviceId) {
6889
7295
  const schema = this.deviceSettingsSchema();
6890
7296
  if (!schema) return { sections: [] };
6891
- return hydrateSchema(schema, await this._ctx?.settings?.readDeviceStore(deviceId) ?? {}, { inlineSecretsAsViews: true });
7297
+ return hydrateSchema(schema, await this.rawSettings()?.readDeviceStore(deviceId) ?? {}, { inlineSecretsAsViews: true });
6892
7298
  }
6893
7299
  async updateDeviceSettings(deviceId, patch) {
6894
7300
  await this._ctx?.settings?.writeDeviceStore(deviceId, patch);
@@ -7060,7 +7466,7 @@ var BaseAddon = class {
7060
7466
  key,
7061
7467
  schema,
7062
7468
  fallback,
7063
- read: async () => this.resolveStoredSecrets(await this._ctx?.settings?.readDeviceStore(deviceId) ?? {}, false),
7469
+ read: async () => this.resolveStoredSecrets(await this.rawSettings()?.readDeviceStore(deviceId) ?? {}, false),
7064
7470
  write: async (patch) => {
7065
7471
  await this._ctx?.settings?.writeDeviceStore(deviceId, patch);
7066
7472
  },
@@ -7122,6 +7528,23 @@ var BaseAddon = class {
7122
7528
  }
7123
7529
  return value;
7124
7530
  }
7531
+ /**
7532
+ * The marker-bearing settings reads (D798) — private on purpose. Without a
7533
+ * keychain the context's own view is already raw.
7534
+ */
7535
+ rawSettings() {
7536
+ return this._secretSettings?.raw ?? this._ctx?.settings;
7537
+ }
7538
+ /** An addon-facing read met markers it could not resolve: say so once per ref. */
7539
+ logUnresolvedRead(unresolved) {
7540
+ const fresh = unresolved.filter((u) => !this._loggedUnresolvedReads.has(u.ref));
7541
+ if (fresh.length === 0) return;
7542
+ for (const u of fresh) this._loggedUnresolvedReads.add(u.ref);
7543
+ this._ctx?.logger?.warn?.("settings read: a stored secret is unavailable — it reads as its marker, not as a value", { meta: { secrets: fresh.map((u) => ({
7544
+ ref: u.ref,
7545
+ reason: u.reason
7546
+ })) } });
7547
+ }
7125
7548
  /** Re-resolve the config (a keychain-only change, or a retry) and apply it. */
7126
7549
  scheduleSecretReresolve(delayMs) {
7127
7550
  const timerOf = delayMs === SECRET_CHANGE_DEBOUNCE_MS ? "_secretChangeTimer" : "_secretRetryTimer";
@@ -7148,7 +7571,7 @@ var BaseAddon = class {
7148
7571
  * `{}` (defaults) — the addon's first successful patch will rehydrate.
7149
7572
  */
7150
7573
  async readAddonStoreWithRetry() {
7151
- const settings = this._ctx?.settings;
7574
+ const settings = this.rawSettings();
7152
7575
  if (!settings) return {};
7153
7576
  const delaysMs = [
7154
7577
  150,
@@ -9654,6 +10077,278 @@ var CameraSwitchGroupSchema = object({
9654
10077
  fetchedAt: number()
9655
10078
  });
9656
10079
  /**
10080
+ * The trainer contract — what the hub hands the cloud trainer and what it
10081
+ * gets back (cloud training, D805+).
10082
+ *
10083
+ * The trainer (`hf/camstack-trainer`, published as the Hugging Face repo
10084
+ * `camstack/camstack-trainer`) is a separate AGPL program the hub never
10085
+ * imports: `job.json` goes in, files come out, and progress is `CAMSTACK_EVENT`
10086
+ * lines on stdout. These schemas are the hub's half of that boundary; the
10087
+ * trainer's pydantic models (and the JSON Schemas generated from them under
10088
+ * `hf/camstack-trainer/schemas/`) are the other half. A change here is a
10089
+ * change there, in the same piece of work.
10090
+ *
10091
+ * No `.default()` anywhere: defaults do not run on the addon cap path, so the
10092
+ * orchestrator fills every field of a job spec explicitly.
10093
+ */
10094
+ var TRAINING_JOB_SCHEMA = "camstack.training/v1";
10095
+ var TRAINING_RESULT_SCHEMA = "camstack.training-result/v1";
10096
+ /** What the trainer can export. Edge TPU is a later, separate image. */
10097
+ var TrainingExportSchema = _enum([
10098
+ "onnx",
10099
+ "openvino-fp16",
10100
+ "openvino-int8",
10101
+ "coreml-fp16"
10102
+ ]);
10103
+ var FloorsSchema = record(string(), number().min(0).max(1));
10104
+ object({
10105
+ schema: literal(TRAINING_JOB_SCHEMA),
10106
+ jobKey: string().uuid(),
10107
+ target: object({
10108
+ kind: literal("detector"),
10109
+ step: literal("object-detection")
10110
+ }),
10111
+ base: object({
10112
+ modelId: string().min(1),
10113
+ /** Ultralytics weights id, e.g. `yolov9m.pt`. */
10114
+ weights: string().min(1),
10115
+ imgsz: number().int().positive()
10116
+ }),
10117
+ baseline: object({
10118
+ modelId: string().min(1),
10119
+ /** The baseline ONNX the holdout comparison runs; public mirror URL. */
10120
+ onnxUrl: string().url(),
10121
+ imgsz: number().int().positive(),
10122
+ floors: FloorsSchema
10123
+ }),
10124
+ dataset: object({
10125
+ versionId: string().min(1),
10126
+ annotationHash: string(),
10127
+ /** sha256 of the uploaded archive; the trainer refuses a mismatch (exit 65). */
10128
+ sha256: string().regex(/^[0-9a-f]{64}$/)
10129
+ }),
10130
+ split: object({
10131
+ holdoutCameras: array(number().int()),
10132
+ /** When no camera is held out: the last N days of every camera. */
10133
+ holdoutLastDays: number().int().nonnegative(),
10134
+ valFraction: number().min(0).max(.5),
10135
+ seed: number().int()
10136
+ }),
10137
+ hyper: object({
10138
+ epochs: number().int().positive(),
10139
+ batch: number().int().positive(),
10140
+ lr0: number().positive(),
10141
+ /** Layers frozen from the start of the backbone; 0 = none. */
10142
+ freeze: number().int().nonnegative(),
10143
+ patience: number().int().nonnegative(),
10144
+ seed: number().int()
10145
+ }),
10146
+ replay: object({
10147
+ source: literal("coco2017"),
10148
+ count: number().int().nonnegative()
10149
+ }),
10150
+ exports: array(TrainingExportSchema).min(1),
10151
+ calibration: object({ maxFrames: number().int().positive() }),
10152
+ floors: object({
10153
+ minSupport: number().int().positive(),
10154
+ clamp: number().min(0).max(1)
10155
+ }),
10156
+ int8Gate: object({ maxMap50Drop: number().min(0).max(1) }),
10157
+ catalog: object({
10158
+ id: string().regex(/^[a-z0-9][a-z0-9-]{2,80}$/),
10159
+ name: string().min(1).max(160)
10160
+ })
10161
+ });
10162
+ /** One regular file of the bundle. An mlpackage contributes one row per member. */
10163
+ var TrainingResultFileSchema = object({
10164
+ path: string().min(1),
10165
+ bytes: number().int().nonnegative(),
10166
+ sha256: string().regex(/^[0-9a-f]{64}$/),
10167
+ format: _enum([
10168
+ "onnx",
10169
+ "openvino",
10170
+ "coreml",
10171
+ "pt"
10172
+ ]),
10173
+ variant: _enum(["base", "int8"])
10174
+ });
10175
+ var DraftFormatSchema = object({
10176
+ /** RELATIVE path inside the bundle; the hub rewrites it to `camstack-local://`. */
10177
+ url: string().min(1),
10178
+ sizeMB: number().nonnegative(),
10179
+ isDirectory: boolean().optional(),
10180
+ files: array(string()).optional(),
10181
+ runtimes: array(literal("python")).optional(),
10182
+ revision: string().min(1)
10183
+ });
10184
+ /** The trainer's half of a catalog entry; the hub completes it (labels, licence, group). */
10185
+ var TrainingCatalogDraftSchema = object({
10186
+ id: string().min(1),
10187
+ name: string().min(1),
10188
+ description: string(),
10189
+ labels: array(unknown()),
10190
+ inputSize: object({
10191
+ width: number().int().positive(),
10192
+ height: number().int().positive()
10193
+ }),
10194
+ preprocessMode: literal("letterbox"),
10195
+ defaultClassFloors: FloorsSchema,
10196
+ formats: object({
10197
+ onnx: DraftFormatSchema.optional(),
10198
+ openvino: DraftFormatSchema.optional(),
10199
+ coreml: DraftFormatSchema.optional()
10200
+ })
10201
+ });
10202
+ /** One class of one model's holdout report (the eval harness's summary). */
10203
+ var TrainingEvalClassSchema = object({
10204
+ positives: number().int(),
10205
+ floor: number().nullable(),
10206
+ tp: number().int(),
10207
+ fp: number().int(),
10208
+ fn: number().int(),
10209
+ precision: number().nullable(),
10210
+ recall: number().nullable(),
10211
+ ap50: number().nullable(),
10212
+ recallByCamera: record(string(), number().nullable()).optional(),
10213
+ recallByLight: record(string(), number().nullable()).optional(),
10214
+ fpByCamera: record(string(), number()).optional(),
10215
+ smallFound: number().int().optional(),
10216
+ smallTotal: number().int().optional()
10217
+ }).passthrough();
10218
+ var TrainingEvalReportSchema = object({
10219
+ frames: number().int(),
10220
+ classes: record(string(), TrainingEvalClassSchema)
10221
+ }).passthrough();
10222
+ /**
10223
+ * A succeeded result carries every block; a failed one carries the error and
10224
+ * whatever was known by then — the other blocks are ABSENT, not null. The
10225
+ * orchestrator checks the blocks it needs before it trusts a success.
10226
+ */
10227
+ var TrainingResultSchema = object({
10228
+ schema: literal(TRAINING_RESULT_SCHEMA),
10229
+ jobKey: string(),
10230
+ status: _enum(["succeeded", "failed"]),
10231
+ error: object({
10232
+ stage: string(),
10233
+ code: string(),
10234
+ message: string()
10235
+ }).nullable(),
10236
+ trainer: object({
10237
+ version: string(),
10238
+ revision: string()
10239
+ }),
10240
+ toolchain: record(string(), string().nullable()),
10241
+ dataset: object({
10242
+ versionId: string(),
10243
+ annotationHash: string(),
10244
+ sha256: string(),
10245
+ frames: object({
10246
+ train: number().int(),
10247
+ val: number().int(),
10248
+ holdout: number().int()
10249
+ }),
10250
+ holdoutCameras: array(number().int()),
10251
+ replayImages: number().int()
10252
+ }).optional(),
10253
+ training: object({
10254
+ epochsRun: number().int(),
10255
+ bestEpoch: number().int(),
10256
+ bestMap50: number(),
10257
+ bestMap50_95: number(),
10258
+ seconds: number()
10259
+ }).optional(),
10260
+ evaluation: object({
10261
+ holdoutFrames: number().int(),
10262
+ baseline: TrainingEvalReportSchema.nullable(),
10263
+ candidate: TrainingEvalReportSchema.nullable(),
10264
+ candidateInt8: TrainingEvalReportSchema.nullable(),
10265
+ recallDeltaByCamera: record(string(), record(string(), number())).nullable(),
10266
+ map50: record(string(), number().nullable())
10267
+ }).optional(),
10268
+ floors: object({
10269
+ baseline: FloorsSchema,
10270
+ candidate: FloorsSchema,
10271
+ candidateInt8: FloorsSchema.nullable(),
10272
+ notes: array(string())
10273
+ }).optional(),
10274
+ int8: object({
10275
+ kept: boolean(),
10276
+ map50Fp16: number().nullable(),
10277
+ map50Int8: number().nullable(),
10278
+ reason: string().nullable()
10279
+ }).optional(),
10280
+ exportsDropped: array(object({
10281
+ export: string(),
10282
+ reason: string()
10283
+ })).optional(),
10284
+ files: array(TrainingResultFileSchema).optional(),
10285
+ bundle: object({
10286
+ path: literal("bundle.tar"),
10287
+ bytes: number().int().nonnegative(),
10288
+ sha256: string().regex(/^[0-9a-f]{64}$/)
10289
+ }).nullable().optional(),
10290
+ catalogDraft: object({
10291
+ base: TrainingCatalogDraftSchema,
10292
+ int8: TrainingCatalogDraftSchema.nullable()
10293
+ }).nullable().optional(),
10294
+ licence: string()
10295
+ });
10296
+ var TrainingStageSchema = _enum([
10297
+ "prepare",
10298
+ "replay",
10299
+ "train",
10300
+ "eval",
10301
+ "export",
10302
+ "package"
10303
+ ]);
10304
+ var EventBase = {
10305
+ v: literal(1),
10306
+ ts: number()
10307
+ };
10308
+ discriminatedUnion("type", [
10309
+ object({
10310
+ ...EventBase,
10311
+ type: literal("stage"),
10312
+ stage: TrainingStageSchema
10313
+ }),
10314
+ object({
10315
+ ...EventBase,
10316
+ type: literal("epoch"),
10317
+ epoch: number().int(),
10318
+ epochs: number().int(),
10319
+ boxLoss: number().nullable().optional(),
10320
+ map50: number().nullable().optional(),
10321
+ map50_95: number().nullable().optional(),
10322
+ etaSec: number().nullable().optional()
10323
+ }),
10324
+ object({
10325
+ ...EventBase,
10326
+ type: literal("metric"),
10327
+ name: string(),
10328
+ value: number()
10329
+ }),
10330
+ object({
10331
+ ...EventBase,
10332
+ type: literal("artifact"),
10333
+ path: string(),
10334
+ bytes: number(),
10335
+ sha256: string()
10336
+ }),
10337
+ object({
10338
+ ...EventBase,
10339
+ type: literal("done"),
10340
+ status: _enum(["succeeded", "failed"]),
10341
+ resultSha256: string().nullable().optional()
10342
+ }),
10343
+ object({
10344
+ ...EventBase,
10345
+ type: literal("error"),
10346
+ stage: string(),
10347
+ code: string(),
10348
+ message: string()
10349
+ })
10350
+ ]);
10351
+ /**
9657
10352
  * What the gate decided about a birth, from the CALLER's point of view.
9658
10353
  *
9659
10354
  * Deliberately not `ConfirmationVerdict`: `undecided` is not a birth decision
@@ -11981,7 +12676,9 @@ var AddonHttpRouteSchema = object({
11981
12676
  "authenticated",
11982
12677
  "admin"
11983
12678
  ]).optional(),
11984
- description: string().optional()
12679
+ description: string().optional(),
12680
+ /** The hub limits this route per client address before the handler runs. */
12681
+ rateLimit: _enum(["auth"]).optional()
11985
12682
  });
11986
12683
  /**
11987
12684
  * Cross-process route invocation envelope. The hub captures the
@@ -12705,6 +13402,37 @@ var BackupDestinationInfoSchema = object({
12705
13402
  lastError: string().optional()
12706
13403
  });
12707
13404
  /**
13405
+ * How an archive is encrypted (operator decision 2026-10-09): to a backup
13406
+ * PUBLIC key the hub holds, so only the operator's secret key opens it.
13407
+ * Absent on a plain `.tar.gz` — every archive made before encryption, or
13408
+ * with it off — which restores without a key.
13409
+ */
13410
+ var BackupArchiveEncryptionSchema = object({
13411
+ /** `x25519-hkdf-aes256gcm-stream-v1`. */
13412
+ scheme: string(),
13413
+ /** 16 hex — the backup key whose secret restores this archive. */
13414
+ keyId: string()
13415
+ });
13416
+ /**
13417
+ * The backup encryption setting. The hub keeps PUBLIC keys only: the active
13418
+ * one new archives are encrypted to, and the retired ones older archives
13419
+ * still need. The secret key is shown once, at `setupEncryption`.
13420
+ */
13421
+ var BackupEncryptionStatusSchema = object({
13422
+ enabled: boolean(),
13423
+ active: object({
13424
+ keyId: string(),
13425
+ publicKey: string(),
13426
+ createdAt: number()
13427
+ }).nullable(),
13428
+ /** Every key ever set up, newest first. */
13429
+ keys: array(object({
13430
+ keyId: string(),
13431
+ createdAt: number(),
13432
+ retiredAt: number().nullable()
13433
+ })).readonly()
13434
+ });
13435
+ /**
12708
13436
  * Per-archive entry returned by `backup.listArchives({ destinationId })`.
12709
13437
  * Same shape the destination drill-in renders. Sourced from the per-
12710
13438
  * location `manifests.json` (no per-archive tarball read required).
@@ -12716,7 +13444,9 @@ var BackupArchiveEntrySchema = object({
12716
13444
  sizeBytes: number(),
12717
13445
  label: string().optional(),
12718
13446
  /** Top-level locations included in the archive (db, addons, tls, …). */
12719
- locations: array(string()).readonly()
13447
+ locations: array(string()).readonly(),
13448
+ /** Present when the archive is encrypted; restore then needs that key. */
13449
+ encryption: BackupArchiveEncryptionSchema.optional()
12720
13450
  });
12721
13451
  var BackupEntrySchema = object({
12722
13452
  id: string(),
@@ -12725,7 +13455,8 @@ var BackupEntrySchema = object({
12725
13455
  label: string().optional(),
12726
13456
  createdAt: number(),
12727
13457
  sizeBytes: number(),
12728
- locations: array(string()).optional()
13458
+ locations: array(string()).optional(),
13459
+ encryption: BackupArchiveEncryptionSchema.optional()
12729
13460
  });
12730
13461
  var ArchiveEntrySchema = object({
12731
13462
  path: string(),
@@ -12914,10 +13645,40 @@ method(_void(), array(BackupDestinationInfoSchema).readonly(), { auth: "admin" }
12914
13645
  * this list and skips entries whose path doesn't start with
12915
13646
  * any of them.
12916
13647
  */
12917
- locations: array(string()).optional()
13648
+ locations: array(string()).optional(),
13649
+ /**
13650
+ * The backup SECRET key, for an encrypted archive (ignored for a plain
13651
+ * one). The archive is decrypted into the hub's private staging
13652
+ * before the restart; the key is not stored. A wrong or missing key
13653
+ * is refused before the archive is downloaded.
13654
+ */
13655
+ backupSecretKey: string().optional()
12918
13656
  }), _void(), {
12919
13657
  kind: "mutation",
12920
13658
  auth: "admin"
13659
+ }), method(_void(), BackupEncryptionStatusSchema, { auth: "admin" }), method(object({}), object({
13660
+ keyId: string(),
13661
+ secretKey: string(),
13662
+ publicKey: string(),
13663
+ createdAt: number(),
13664
+ replacedKeyId: string().nullable()
13665
+ }), {
13666
+ kind: "mutation",
13667
+ auth: "admin"
13668
+ }), method(object({}), object({ disabledKeyId: string().nullable() }), {
13669
+ kind: "mutation",
13670
+ auth: "admin"
13671
+ }), method(object({ backupSecretKey: string() }), object({
13672
+ valid: boolean(),
13673
+ keyId: string().nullable(),
13674
+ /** The hub knows this key (active or retired). */
13675
+ known: boolean(),
13676
+ /** It is the key new archives are encrypted to. */
13677
+ active: boolean(),
13678
+ error: string().optional()
13679
+ }), {
13680
+ kind: "mutation",
13681
+ auth: "admin"
12921
13682
  }), method(object({
12922
13683
  destinationId: string(),
12923
13684
  backupId: string()
@@ -14692,7 +15453,60 @@ var CustomModelDescriptorSchema = object({
14692
15453
  stepId: string(),
14693
15454
  entry: ModelCatalogEntrySchema
14694
15455
  });
14695
- method(_void(), array(CustomModelDescriptorSchema).readonly(), { auth: "admin" });
15456
+ /** One regular file of an imported bundle, as the producer measured it. */
15457
+ var ModelBundleFileSchema = object({
15458
+ /** Relative path inside the bundle tar; an mlpackage member is `<x>.mlpackage/<member>`. */
15459
+ path: string().min(1),
15460
+ bytes: number().int().nonnegative(),
15461
+ sha256: string().regex(/^[0-9a-f]{64}$/)
15462
+ });
15463
+ var ImportModelBundleInputSchema = object({
15464
+ /** The registry provider that keeps the model (Model Studio). */
15465
+ addonId: string(),
15466
+ stepId: string().min(1),
15467
+ /**
15468
+ * The catalog rows to register, complete, every format URL already
15469
+ * `camstack-local://<modelId>/<file>` naming a file of the bundle. One
15470
+ * bundle may carry several rows (a base and its INT8 variant).
15471
+ */
15472
+ entries: array(ModelCatalogEntrySchema).min(1).max(4),
15473
+ /** The bundle tar, offered by the producer over `ctx.peerBytes` (same host). */
15474
+ bundle: object({
15475
+ ticket: PeerBytesTicketSchema,
15476
+ bytes: number().int().positive(),
15477
+ sha256: string().regex(/^[0-9a-f]{64}$/)
15478
+ }),
15479
+ /** Every file the tar must hold; anything missing, extra or different is refused. */
15480
+ files: array(ModelBundleFileSchema).min(1).max(64),
15481
+ /** Convert missing engine formats and push the model to every agent afterwards. */
15482
+ distribute: boolean()
15483
+ });
15484
+ var ImportModelBundleResultSchema = discriminatedUnion("kind", [object({
15485
+ kind: literal("imported"),
15486
+ modelIds: array(string()).readonly(),
15487
+ distributed: array(object({
15488
+ modelId: string(),
15489
+ nodeId: string(),
15490
+ format: _enum(MODEL_FORMATS),
15491
+ ok: boolean(),
15492
+ error: string().optional()
15493
+ })).readonly()
15494
+ }), object({
15495
+ kind: literal("refused"),
15496
+ reason: _enum([
15497
+ "transfer-failed",
15498
+ "checksum-mismatch",
15499
+ "bundle-mismatch",
15500
+ "invalid-entry",
15501
+ "id-taken"
15502
+ ]),
15503
+ detail: string()
15504
+ })]);
15505
+ method(_void(), array(CustomModelDescriptorSchema).readonly(), { auth: "admin" }), method(ImportModelBundleInputSchema, ImportModelBundleResultSchema, {
15506
+ kind: "mutation",
15507
+ auth: "admin",
15508
+ timeoutMs: 30 * 6e4
15509
+ });
14696
15510
  /**
14697
15511
  * Query filter for settings-store collections.
14698
15512
  */
@@ -15171,6 +15985,35 @@ var KeychainKeySourceSchema = object({
15171
15985
  */
15172
15986
  sharesBackupWithDatabase: boolean()
15173
15987
  });
15988
+ /**
15989
+ * One keychain reset, as the Secrets page reports it until the operator
15990
+ * acknowledges it. Never a value: refs, counts and table names only.
15991
+ */
15992
+ var KeychainResetRecordSchema = object({
15993
+ id: string(),
15994
+ at: number(),
15995
+ /** `user:<id>` or {@link KEYCHAIN_RESET_TRIGGER_ACTOR}. */
15996
+ actor: string(),
15997
+ /** Why the keychain was locked when it was reset; `null` when it was not locked. */
15998
+ lockedReason: string().nullable(),
15999
+ /** Values moved into the archive table (ciphertext under the lost key). */
16000
+ archived: number().int(),
16001
+ /** `keychain:secrets-orphaned-<ts>`, or `null` when nothing was stored. */
16002
+ archivedCollection: string().nullable(),
16003
+ /**
16004
+ * `keychain:keys-orphaned-<ts>`: the wrapped data keys of the archive, kept
16005
+ * so the archive can still be opened if the lost master key turns up.
16006
+ */
16007
+ archivedKeysCollection: string().nullable(),
16008
+ /**
16009
+ * `system-settings` keys whose marker the reset cleared — the cluster
16010
+ * secret's: a marker left pointing at an archived value would refuse every
16011
+ * agent forever (D797).
16012
+ */
16013
+ clearedSettingsKeys: array(string()).readonly(),
16014
+ /** When an operator dismissed the notice on the Secrets page; `null` until then. */
16015
+ acknowledgedAt: number().nullable()
16016
+ });
15174
16017
  var KeychainStatusSchema = object({
15175
16018
  keychain: KeychainStateSchema,
15176
16019
  /** The source of the master key in use; `null` while locked. */
@@ -15188,7 +16031,9 @@ var KeychainStatusSchema = object({
15188
16031
  /** Wrapped copies of the data key under a previous master key, kept until purged. */
15189
16032
  retiredWraps: number().int(),
15190
16033
  recoveryKeyDownloadedAt: number().nullable(),
15191
- secretCount: number().int()
16034
+ secretCount: number().int(),
16035
+ /** The most recent reset, acknowledged or not; `null` when the keychain was never reset. */
16036
+ lastReset: KeychainResetRecordSchema.nullable()
15192
16037
  });
15193
16038
  /**
15194
16039
  * Whether a stored value is still pointed at by its owner's settings.
@@ -15210,17 +16055,26 @@ var KeychainAuditActionSchema = _enum([
15210
16055
  "download-recovery-key",
15211
16056
  "delete-orphans",
15212
16057
  "reset",
16058
+ "acknowledge-reset",
15213
16059
  "initialize"
15214
16060
  ]);
15215
16061
  var KeychainAuditEntrySchema = object({
15216
16062
  id: string(),
15217
16063
  at: number(),
15218
16064
  action: KeychainAuditActionSchema,
15219
- /** `addon:<id>` | `user:<id>` | `system`. */
16065
+ /** `addon:<id>` | `user:<id>` | `system` | `trigger-file`. */
15220
16066
  actor: string(),
15221
16067
  ref: string().nullable(),
15222
16068
  detail: string().nullable()
15223
16069
  });
16070
+ var KEYCHAIN_RESET_CONFIRMATION = "RESET KEYCHAIN";
16071
+ /**
16072
+ * Secrets the HUB itself holds (owner `system`) that no settings form shows:
16073
+ * `jwt-signing-key` — the session signing key (D797). It is always "in use",
16074
+ * never an orphan; it is generated on a fresh hub and replaced only through
16075
+ * {@link keychainAdminCapability.methods.setSystemSecret}.
16076
+ */
16077
+ var SystemHeldSecretNameSchema = _enum(["jwt-signing-key"]);
15224
16078
  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({
15225
16079
  value: string(),
15226
16080
  version: number().int()
@@ -15228,6 +16082,16 @@ method(object({}), KeychainStatusSchema, { auth: "admin" }), method(object({}),
15228
16082
  kind: "mutation",
15229
16083
  auth: "admin",
15230
16084
  caller: "required"
16085
+ }), method(object({
16086
+ name: SystemHeldSecretNameSchema,
16087
+ value: string().min(16)
16088
+ }), object({
16089
+ ref: string(),
16090
+ version: number().int()
16091
+ }), {
16092
+ kind: "mutation",
16093
+ auth: "admin",
16094
+ caller: "required"
15231
16095
  }), method(object({ refs: array(string().min(1)).max(1e3) }), object({
15232
16096
  deleted: array(string()).readonly(),
15233
16097
  kept: array(object({
@@ -15257,13 +16121,20 @@ method(object({}), KeychainStatusSchema, { auth: "admin" }), method(object({}),
15257
16121
  kind: "mutation",
15258
16122
  auth: "admin",
15259
16123
  caller: "required"
15260
- }), method(object({ confirm: literal("RESET KEYCHAIN") }), object({
16124
+ }), method(object({ confirm: literal(KEYCHAIN_RESET_CONFIRMATION) }), object({
15261
16125
  archivedCollection: string().nullable(),
15262
16126
  archived: number().int()
15263
16127
  }), {
15264
16128
  kind: "mutation",
15265
16129
  auth: "admin",
15266
16130
  caller: "required"
16131
+ }), method(object({}), object({
16132
+ reset: KeychainResetRecordSchema.nullable(),
16133
+ pendingReentry: array(KeychainSecretMetaSchema).readonly()
16134
+ }), { auth: "admin" }), method(object({}), object({ acknowledged: boolean() }), {
16135
+ kind: "mutation",
16136
+ auth: "admin",
16137
+ caller: "required"
15267
16138
  });
15268
16139
  method(_void(), object({
15269
16140
  id: string(),
@@ -18331,7 +19202,7 @@ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
18331
19202
  * `login-method` — collection cap through which auth addons contribute
18332
19203
  * their pre-auth login surfaces to the login page. This is the SINGLE,
18333
19204
  * generic mechanism that supersedes the dead `auth.listProviders` reader:
18334
- * every auth addon (OIDC, magic-link, WebAuthn/passkey) registers a
19205
+ * every auth addon (OIDC, WebAuthn/passkey) registers a
18335
19206
  * `login-method` provider and the PUBLIC `auth.listLoginMethods`
18336
19207
  * procedure aggregates them for the unauthenticated login page.
18337
19208
  *
@@ -18339,8 +19210,7 @@ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
18339
19210
  *
18340
19211
  * - `redirect` — a declarative button. The login page renders a generic
18341
19212
  * button that navigates to `startUrl` (an addon-owned HTTP route).
18342
- * Covers OIDC (`/addon/auth-oidc/<id>/start`) and magic-link with
18343
- * ZERO shell-side JS. A future SSO addon plugs in the same way — the
19213
+ * Covers OIDC (`/addon/auth-oidc/<id>/start`) with ZERO shell-side JS. A future SSO addon plugs in the same way — the
18344
19214
  * login page needs NO change.
18345
19215
  *
18346
19216
  * - `widget` — a Module-Federation widget the login page mounts (via
@@ -18359,8 +19229,8 @@ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
18359
19229
  * decision.
18360
19230
  *
18361
19231
  * Every contribution carries a `stage`:
18362
- * - `primary` — shown on the first credentials screen (OIDC /
18363
- * magic-link buttons; a future usernameless passkey).
19232
+ * - `primary` — shown on the first credentials screen (OIDC
19233
+ * buttons; a usernameless passkey).
18364
19234
  * - `second-factor` — shown AFTER the password leg, gated on the
18365
19235
  * returned `factors` (passkey-as-2FA today).
18366
19236
  *
@@ -18387,7 +19257,7 @@ var LoginMethodContributionSchema = discriminatedUnion("kind", [
18387
19257
  * The provider names an external identity a signed-in user can link to
18388
19258
  * their own account (D782): `auth.listLinkableProviders` /
18389
19259
  * `beginExternalLink` offer exactly the redirect methods that set this,
18390
- * whatever their id. Absent / false — a login button only (magic-link).
19260
+ * whatever their id. Absent / false — a login button only.
18391
19261
  */
18392
19262
  linkable: boolean().optional()
18393
19263
  }),
@@ -22264,8 +23134,7 @@ method(object({}), object({ rules: array(NcRuleSchema) }), { auth: "admin" }), m
22264
23134
  * `super_admin` — collapsed onto the single boolean because every
22265
23135
  * non-admin caller is governed by the same scope-check rules; the
22266
23136
  * distinction was only ever used to route role-specific procedures
22267
- * which we no longer have. Agents are admin sessions issued via
22268
- * `createServiceToken`; CLI / webhook integrations are `cst_*` tokens
23137
+ * which we no longer have. CLI / webhook integrations are `cst_*` tokens
22269
23138
  * with `isAdmin: false` + an explicit scope list.
22270
23139
  */
22271
23140
  /** Per-method access flavour. Materialised on every cap method via codegen. */
@@ -23956,6 +24825,9 @@ var RetrainExportFilterSchema = object({
23956
24825
  frameIds: array(string()).max(2e4).optional(),
23957
24826
  /** Only frames in at least one of these named collections. */
23958
24827
  collectionIds: array(string()).max(200).optional(),
24828
+ /** Exactly the frames of this dataset version (and its completeOnly). An
24829
+ * unknown id selects nothing. */
24830
+ datasetVersionId: string().optional(),
23959
24831
  batchId: string().optional(),
23960
24832
  /** Only frames the operator marked complete (all subjects boxed). */
23961
24833
  completeOnly: boolean().optional()
@@ -24123,6 +24995,67 @@ var RetrainLlmAssistResultSchema = discriminatedUnion("kind", [object({
24123
24995
  ]),
24124
24996
  detail: string().optional()
24125
24997
  })]);
24998
+ /** What a dataset version is cut from. Every field narrows. */
24999
+ var RetrainDatasetSelectionSchema = object({
25000
+ deviceIds: array(number()).readonly().optional(),
25001
+ collectionIds: array(string()).max(200).readonly().optional(),
25002
+ frameIds: array(string()).max(2e4).readonly().optional()
25003
+ });
25004
+ /** The counts a dataset is judged by. */
25005
+ var RetrainDatasetStatsSchema = object({
25006
+ frames: number().int(),
25007
+ completeFrames: number().int(),
25008
+ /** `completeFrames / frames`, 0..1. */
25009
+ completeness: number(),
25010
+ /** Boxes to learn (model errors excluded). */
25011
+ subjects: number().int(),
25012
+ modelErrors: number().int(),
25013
+ /** Complete frames with no subject. */
25014
+ hardNegatives: number().int(),
25015
+ /** Subjects per class × camera × day/night. */
25016
+ cells: array(object({
25017
+ macroClass: string(),
25018
+ deviceId: number(),
25019
+ lighting: _enum([
25020
+ "day",
25021
+ "night",
25022
+ "unknown"
25023
+ ]),
25024
+ subjects: number().int(),
25025
+ frames: number().int()
25026
+ })).readonly(),
25027
+ cameras: array(object({
25028
+ deviceId: number(),
25029
+ frames: number().int(),
25030
+ completeFrames: number().int()
25031
+ })).readonly()
25032
+ });
25033
+ /** An immutable dataset version, without its frame list. */
25034
+ var RetrainDatasetVersionSchema = object({
25035
+ id: string(),
25036
+ name: string(),
25037
+ createdAt: number(),
25038
+ selection: RetrainDatasetSelectionSchema,
25039
+ layout: RetrainExportLayoutSchema,
25040
+ completeOnly: boolean(),
25041
+ frameCount: number().int(),
25042
+ /** sha256 of what the frames taught when the version was frozen. */
25043
+ annotationHash: string(),
25044
+ /** The export manifest schema the version was cut under. */
25045
+ manifestSchema: string(),
25046
+ stats: RetrainDatasetStatsSchema
25047
+ });
25048
+ var CreateRetrainDatasetVersionResultSchema = discriminatedUnion("kind", [object({
25049
+ kind: literal("created"),
25050
+ version: RetrainDatasetVersionSchema
25051
+ }), object({
25052
+ kind: literal("refused"),
25053
+ reason: _enum([
25054
+ "empty-name",
25055
+ "duplicate-name",
25056
+ "no-frames"
25057
+ ])
25058
+ })]);
24126
25059
  /** The outcome of a lifecycle move owned by the retrain page. */
24127
25060
  var RetrainTransitionResultSchema = object({
24128
25061
  trackId: string(),
@@ -24912,6 +25845,47 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
24912
25845
  kind: "mutation",
24913
25846
  auth: "admin",
24914
25847
  timeoutMs: 60 * 6e4
25848
+ }), method(object({
25849
+ filter: RetrainExportFilterSchema,
25850
+ layout: RetrainExportLayoutSchema
25851
+ }), object({
25852
+ ticket: PeerBytesTicketSchema,
25853
+ frames: number().int(),
25854
+ annotations: number().int()
25855
+ }), {
25856
+ kind: "mutation",
25857
+ auth: "admin",
25858
+ timeoutMs: 12e4
25859
+ }), method(object({
25860
+ selection: RetrainDatasetSelectionSchema,
25861
+ completeOnly: boolean().optional()
25862
+ }), RetrainDatasetStatsSchema, {
25863
+ kind: "query",
25864
+ auth: "admin"
25865
+ }), method(object({
25866
+ name: string().max(120),
25867
+ selection: RetrainDatasetSelectionSchema,
25868
+ layout: RetrainExportLayoutSchema,
25869
+ completeOnly: boolean()
25870
+ }), CreateRetrainDatasetVersionResultSchema, {
25871
+ kind: "mutation",
25872
+ auth: "admin",
25873
+ timeoutMs: 12e4
25874
+ }), method(object({}), array(RetrainDatasetVersionSchema).readonly(), {
25875
+ kind: "query",
25876
+ auth: "admin"
25877
+ }), method(object({ id: string() }), object({ deleted: boolean() }), {
25878
+ kind: "mutation",
25879
+ auth: "admin"
25880
+ }), method(object({ id: string() }), object({
25881
+ found: boolean(),
25882
+ annotationHash: string(),
25883
+ matches: boolean(),
25884
+ missingFrames: number().int()
25885
+ }), {
25886
+ kind: "query",
25887
+ auth: "admin",
25888
+ timeoutMs: 12e4
24915
25889
  }), method(object({}), array(RetrainAssistProfileSchema).readonly(), {
24916
25890
  kind: "query",
24917
25891
  auth: "admin"
@@ -28490,8 +29464,8 @@ version: string().optional() }), ServerUpdateActionResultSchema, {
28490
29464
  * `smtp-provider` — pluggable email delivery surface.
28491
29465
  *
28492
29466
  * Collection cap: a deployment may install multiple SMTP relays (e.g.
28493
- * one for transactional / one for notifications). Consumers (magic-link,
28494
- * notifier addons, …) walk the collection and pick the first
29467
+ * one for transactional / one for notifications). Consumers (notifier
29468
+ * addons, …) walk the collection and pick the first
28495
29469
  * ready provider OR target a specific addonId.
28496
29470
  *
28497
29471
  * The shape stays small on purpose — `sendEmail` is enough for the
@@ -28670,7 +29644,7 @@ targets: array(object({
28670
29644
  })));
28671
29645
  /**
28672
29646
  * `sso-bridge` — internal hub-only cap that lets SSO-style auth
28673
- * providers (OIDC, SAML, magic-link, …) mint an HMAC-signed token
29647
+ * providers (OIDC, SAML, …) mint an HMAC-signed token
28674
29648
  * carrying the post-callback claims before redirecting back to
28675
29649
  * `/api/auth/sso/finish`.
28676
29650
  *
@@ -28733,7 +29707,14 @@ var SsoBridgeClaimsSchema = object({
28733
29707
  * Verified `iss` of the id_token behind an OIDC login bridge (D782). A
28734
29708
  * subject is unique only per issuer, so a link is bound to it.
28735
29709
  */
28736
- issuer: string().optional()
29710
+ issuer: string().optional(),
29711
+ /**
29712
+ * SHA-256 (hex) of the `camstack_sso_state` cookie the IdP `/start` set in
29713
+ * the browser that began this sign-in. `/api/auth/sso/finish` requires the
29714
+ * request to present the matching cookie — a login bridge is useless in
29715
+ * any other browser.
29716
+ */
29717
+ browserBinding: string().optional()
28737
29718
  });
28738
29719
  method(object({
28739
29720
  claims: SsoBridgeClaimsSchema,
@@ -36267,7 +37248,13 @@ var TopologyNodeSchema = object({
36267
37248
  })).readonly(),
36268
37249
  processes: array(TopologyProcessSchema).readonly(),
36269
37250
  categories: array(TopologyCategorySchema).readonly(),
36270
- rootPackage: TopologyRootPackageSchema.nullable()
37251
+ rootPackage: TopologyRootPackageSchema.nullable(),
37252
+ /**
37253
+ * How an online AGENT reaches the hub (mesh mTLS Release A): `tls` once it has
37254
+ * completed a mutual-TLS handshake, `clear` otherwise. Absent for the hub,
37255
+ * for offline rows and when the hub cannot tell.
37256
+ */
37257
+ meshTransport: _enum(["tls", "clear"]).optional()
36271
37258
  });
36272
37259
  var CapUsageEdgeSchema = object({
36273
37260
  callerAddonId: string(),
@@ -41090,16 +42077,6 @@ var ApiKeySummarySchema = object({
41090
42077
  createdAt: number(),
41091
42078
  lastUsedAt: number().optional()
41092
42079
  });
41093
- var CreateApiKeyInputSchema = object({
41094
- label: string(),
41095
- isAdmin: boolean().default(false),
41096
- allowedProviders: union([array(string()), literal("*")]).optional(),
41097
- allowedDevices: record(string(), union([array(string()), literal("*")])).optional()
41098
- });
41099
- var CreateApiKeyResultSchema = object({
41100
- token: string(),
41101
- record: ApiKeySummarySchema
41102
- });
41103
42080
  var ScopedTokenSummarySchema = object({
41104
42081
  id: string(),
41105
42082
  userId: string(),
@@ -41198,17 +42175,10 @@ method(_void(), array(UserSummarySchema), { auth: "admin" }), method(CreateUserI
41198
42175
  }), UserSummarySchema.extend({ passwordHash: string() }).nullable(), {
41199
42176
  kind: "mutation",
41200
42177
  access: "view"
41201
- }), method(_void(), array(ApiKeySummarySchema), { auth: "admin" }), method(CreateApiKeyInputSchema, CreateApiKeyResultSchema, {
41202
- kind: "mutation",
41203
- auth: "admin",
41204
- access: "create"
41205
- }), method(object({ id: string() }), object({ success: literal(true) }), {
42178
+ }), method(_void(), array(ApiKeySummarySchema), { auth: "admin" }), method(object({ id: string() }), object({ success: literal(true) }), {
41206
42179
  kind: "mutation",
41207
42180
  auth: "admin",
41208
42181
  access: "delete"
41209
- }), method(object({ token: string() }), ApiKeySummarySchema.nullable(), {
41210
- kind: "mutation",
41211
- access: "view"
41212
42182
  }), method(CreateScopedTokenInputSchema, CreateScopedTokenResultSchema, {
41213
42183
  kind: "mutation",
41214
42184
  auth: "admin",
@@ -41282,15 +42252,7 @@ method(_void(), array(UserSummarySchema), { auth: "admin" }), method(CreateUserI
41282
42252
  }).nullable(), { access: "view" }), method(object({ userId: string() }), array(ExternalIdentitySchema), { auth: "admin" }), method(ExternalIdentityKeySchema, object({
41283
42253
  userId: string(),
41284
42254
  issuer: string()
41285
- }).nullable(), { auth: "admin" }), method(ExternalIdentityKeySchema.extend({
41286
- userId: string(),
41287
- issuer: string().min(1),
41288
- label: string().optional()
41289
- }), object({ success: literal(true) }), {
41290
- kind: "mutation",
41291
- auth: "admin",
41292
- access: "create"
41293
- }), method(ExternalIdentityKeySchema.extend({ userId: string() }), object({ success: boolean() }), {
42255
+ }).nullable(), { auth: "admin" }), method(ExternalIdentityKeySchema.extend({ userId: string() }), object({ success: boolean() }), {
41294
42256
  kind: "mutation",
41295
42257
  auth: "admin",
41296
42258
  access: "delete"
@@ -41995,6 +42957,451 @@ var zoneRulesCapability = {
41995
42957
  */
41996
42958
  durability: "restored"
41997
42959
  };
42960
+ /**
42961
+ * `training-provider` — ONE cloud that can run the CamStack trainer.
42962
+ *
42963
+ * A thin, mockable translation layer: it knows how to run a container with a
42964
+ * GPU, move a dataset in, read the job's stdout and hand artefacts back. It
42965
+ * knows nothing about datasets, splits, floors, cost policy or Model Studio —
42966
+ * those are the `training` orchestrator's (D805). Every rule written there
42967
+ * once is what makes a second provider (RunPod, a local NVIDIA node) a new
42968
+ * manifest entry and nothing else.
42969
+ *
42970
+ * Collection, routed by the `addonId` in every single-row input (the `llm` /
42971
+ * `notification-output` posture); `describe` concat-fans across providers.
42972
+ * Every method is `admin`: these spend money.
42973
+ *
42974
+ * Every cloud object a provider creates is tagged with the orchestrator's
42975
+ * `jobKey`, so a retried submit finds the job it already started instead of
42976
+ * starting a second GPU, and `listJobs` can find orphans.
42977
+ *
42978
+ * Bytes never ride a cap field: the dataset arrives as a `ctx.peerBytes`
42979
+ * ticket the producer (pipeline-analytics) minted, and artefacts leave as a
42980
+ * ticket the provider mints (D613).
42981
+ */
42982
+ var TrainingGpuOptionSchema = object({
42983
+ id: string(),
42984
+ label: string(),
42985
+ /** List price, USD per GPU-hour, before any region multiplier. */
42986
+ usdPerHour: number().nonnegative(),
42987
+ vramGb: number().nonnegative()
42988
+ });
42989
+ var TrainingRegionOptionSchema = object({
42990
+ /** `''` = any region (the provider's choice). */
42991
+ id: string(),
42992
+ label: string(),
42993
+ priceMultiplier: number().positive()
42994
+ });
42995
+ /**
42996
+ * The provider's per-account settings, as the orchestrator reads them. They
42997
+ * live in the PROVIDER addon's settings (operator decision 2026-10-08: they
42998
+ * depend on the user's account), never hard-coded in the orchestrator.
42999
+ */
43000
+ var TrainingProviderDefaultsSchema = object({
43001
+ gpuType: string(),
43002
+ region: string(),
43003
+ costCapUsd: number().nonnegative(),
43004
+ maxRuntimeSec: number().int().positive(),
43005
+ /** Hours a FAILED job's cloud dataset is kept for debugging; 0 = delete at once. */
43006
+ failedDatasetGraceHours: number().nonnegative()
43007
+ });
43008
+ var TrainingProviderDescriptorSchema = object({
43009
+ addonId: string(),
43010
+ /** `modal`, `runpod`, `fake`, … */
43011
+ kind: string(),
43012
+ label: string(),
43013
+ gpuTypes: array(TrainingGpuOptionSchema).readonly(),
43014
+ regions: array(TrainingRegionOptionSchema).readonly(),
43015
+ maxDatasetBytes: number().int().positive(),
43016
+ maxRuntimeSec: number().int().positive(),
43017
+ freeTierNote: string().optional(),
43018
+ /** Where the data goes, in one sentence the confirm dialog repeats. */
43019
+ dataResidencyNote: string(),
43020
+ /** Credentials are present — never the values. */
43021
+ configured: boolean(),
43022
+ defaults: TrainingProviderDefaultsSchema
43023
+ });
43024
+ var TrainingCredentialCheckSchema = object({
43025
+ ok: boolean(),
43026
+ /** Workspace / account name, when the provider says. */
43027
+ account: string().optional(),
43028
+ reason: _enum([
43029
+ "missing",
43030
+ "invalid",
43031
+ "forbidden",
43032
+ "network",
43033
+ "quota"
43034
+ ]).optional(),
43035
+ detail: string().optional()
43036
+ });
43037
+ var ProviderJobStateSchema = _enum([
43038
+ "pending",
43039
+ "starting",
43040
+ "running",
43041
+ "succeeded",
43042
+ "failed",
43043
+ "cancelled",
43044
+ "lost"
43045
+ ]);
43046
+ var ProviderJobStatusSchema = object({
43047
+ jobKey: string(),
43048
+ providerJobId: string().optional(),
43049
+ state: ProviderJobStateSchema,
43050
+ startedAt: number().optional(),
43051
+ endedAt: number().optional(),
43052
+ exitCode: number().int().optional(),
43053
+ failureReason: string().optional(),
43054
+ gpuType: string(),
43055
+ region: string().optional(),
43056
+ billedSeconds: number().nonnegative(),
43057
+ costUsd: number().nonnegative(),
43058
+ /** True when `costUsd` is runtime × list price, not a billing answer. */
43059
+ costIsEstimate: boolean(),
43060
+ lastFetchedAt: number()
43061
+ });
43062
+ /**
43063
+ * The trainer the job runs, by SOURCE revision: the provider turns it into an
43064
+ * image its own way (Modal builds the published Dockerfile at that revision;
43065
+ * a registry-pull provider maps it to a tag). Recorded on the job and echoed
43066
+ * in `result.json`.
43067
+ */
43068
+ var TrainerSourceRefSchema = object({
43069
+ /** Hugging Face repo id, e.g. `camstack/camstack-trainer`. */
43070
+ repo: string().min(1),
43071
+ /** A commit sha (never a branch) — the job must be reproducible. */
43072
+ revision: string().regex(/^[0-9a-f]{7,64}$/)
43073
+ });
43074
+ var JobRef = {
43075
+ addonId: string(),
43076
+ jobKey: string().uuid()
43077
+ };
43078
+ var TrainingLogLineSchema = object({
43079
+ ts: number(),
43080
+ text: string()
43081
+ });
43082
+ method(object({}), array(TrainingProviderDescriptorSchema).readonly(), { auth: "admin" }), method(object({ addonId: string() }), TrainingCredentialCheckSchema, {
43083
+ kind: "mutation",
43084
+ auth: "admin",
43085
+ timeoutMs: 3e4
43086
+ }), method(object({
43087
+ addonId: string(),
43088
+ gpuType: string(),
43089
+ region: string(),
43090
+ datasetBytes: number().int().nonnegative(),
43091
+ gpuSecondsLow: number().nonnegative(),
43092
+ gpuSecondsHigh: number().nonnegative()
43093
+ }), object({
43094
+ usdLow: number().nonnegative(),
43095
+ usdHigh: number().nonnegative(),
43096
+ notes: array(string()).readonly()
43097
+ }), { auth: "admin" }), method(object({
43098
+ ...JobRef,
43099
+ ticket: PeerBytesTicketSchema
43100
+ }), object({
43101
+ bytes: number().int().nonnegative(),
43102
+ sha256: string()
43103
+ }), {
43104
+ kind: "mutation",
43105
+ auth: "admin",
43106
+ timeoutMs: 120 * 6e4
43107
+ }), method(object({
43108
+ ...JobRef,
43109
+ trainer: TrainerSourceRefSchema,
43110
+ jobSpecJson: string().min(2).max(64e3),
43111
+ gpuType: string(),
43112
+ region: string(),
43113
+ maxRuntimeSec: number().int().positive()
43114
+ }), ProviderJobStatusSchema, {
43115
+ kind: "mutation",
43116
+ auth: "admin",
43117
+ timeoutMs: 30 * 6e4
43118
+ }), method(object(JobRef), ProviderJobStatusSchema, {
43119
+ auth: "admin",
43120
+ timeoutMs: 6e4
43121
+ }), method(object({
43122
+ ...JobRef,
43123
+ cursor: string().optional(),
43124
+ max: number().int().min(1).max(500)
43125
+ }), object({
43126
+ lines: array(TrainingLogLineSchema).readonly(),
43127
+ cursor: string()
43128
+ }), {
43129
+ auth: "admin",
43130
+ timeoutMs: 6e4
43131
+ }), method(object(JobRef), object({ ok: literal(true) }), {
43132
+ kind: "mutation",
43133
+ auth: "admin",
43134
+ timeoutMs: 6e4
43135
+ }), method(object(JobRef), object({
43136
+ found: boolean(),
43137
+ text: string().optional()
43138
+ }), {
43139
+ kind: "mutation",
43140
+ auth: "admin",
43141
+ timeoutMs: 5 * 6e4
43142
+ }), method(object({
43143
+ ...JobRef,
43144
+ path: _enum(["bundle.tar"])
43145
+ }), object({ ticket: PeerBytesTicketSchema }), {
43146
+ kind: "mutation",
43147
+ auth: "admin",
43148
+ timeoutMs: 5 * 6e4
43149
+ }), method(object(JobRef), object({ deleted: array(string()).readonly() }), {
43150
+ kind: "mutation",
43151
+ auth: "admin",
43152
+ timeoutMs: 5 * 6e4
43153
+ }), method(object({ addonId: string() }), array(ProviderJobStatusSchema).readonly(), {
43154
+ auth: "admin",
43155
+ timeoutMs: 2 * 6e4
43156
+ });
43157
+ /**
43158
+ * `training` — the cloud-training orchestrator (D805). Hub-only singleton,
43159
+ * provided by `addon-training`.
43160
+ *
43161
+ * It owns what every provider must agree on, written once:
43162
+ *
43163
+ * - **Dataset versions.** Taken over from pipeline-analytics (D796): the rows
43164
+ * live here (D808); pipeline-analytics still CUTS a version (it owns the corpus and
43165
+ * the export plan) and reaches this store through the five row methods
43166
+ * below, so the Retrain page and the export did not change.
43167
+ * - **Jobs.** A persisted state machine, a reconcile loop against the
43168
+ * provider, a cost guard, a daily orphan sweep and the retention rules.
43169
+ * - **The return flow.** Verified artefacts → Model Studio
43170
+ * (`custom-model-registry.importModelBundle`) → canary on cameras →
43171
+ * rollback. Nothing is ever registered automatically.
43172
+ *
43173
+ * Every method is `admin`.
43174
+ */
43175
+ /** A version WITH its frame list — what the export and a job read. */
43176
+ var TrainingDatasetVersionRowSchema = RetrainDatasetVersionSchema.omit({ frameCount: true }).extend({ frameIds: array(string()).max(2e4).readonly() });
43177
+ /** A base model a detector job can fine-tune, and the baseline it is judged against. */
43178
+ var TrainingBaseModelSchema = object({
43179
+ modelId: string(),
43180
+ label: string(),
43181
+ weights: string(),
43182
+ imgsz: number().int(),
43183
+ baselineOnnxUrl: string(),
43184
+ baselineFloors: record(string(), number()),
43185
+ /** The base the fleet runs most — the UI's default. */
43186
+ recommended: boolean()
43187
+ });
43188
+ var TrainingPresetSchema = _enum([
43189
+ "quick",
43190
+ "standard",
43191
+ "thorough"
43192
+ ]);
43193
+ var TrainingJobRequestSchema = object({
43194
+ datasetVersionId: string().min(1),
43195
+ /** The `training-provider` addon that runs it. */
43196
+ addonId: string().min(1),
43197
+ gpuType: string().min(1),
43198
+ region: string(),
43199
+ baseModelId: string().min(1),
43200
+ preset: TrainingPresetSchema,
43201
+ /** Freeze the backbone's first N layers; `null` = the preset's choice. */
43202
+ freeze: number().int().nonnegative().nullable(),
43203
+ /** Cameras held out whole for evaluation; `null` = the orchestrator's default. */
43204
+ holdoutCameras: array(number().int()).nullable()
43205
+ });
43206
+ var TrainingSplitPlanSchema = object({
43207
+ holdoutCameras: array(number().int()).readonly(),
43208
+ /** Used when no camera is held out: the last N days of every camera. */
43209
+ holdoutLastDays: number().int().nonnegative(),
43210
+ /** Holdout subjects per class (camera holdout only; `null` = known only after the split). */
43211
+ holdoutSupport: record(string(), number().int()).nullable(),
43212
+ trainSubjects: number().int()
43213
+ });
43214
+ var TrainingRefusalReasonSchema = _enum([
43215
+ "unknown-dataset",
43216
+ "unknown-provider",
43217
+ "provider-not-configured",
43218
+ "unknown-base-model",
43219
+ "unknown-gpu",
43220
+ "dataset-too-large",
43221
+ "no-training-subjects",
43222
+ "job-already-running"
43223
+ ]);
43224
+ var TrainingJobPlanSchema = object({
43225
+ refusal: object({
43226
+ reason: TrainingRefusalReasonSchema,
43227
+ detail: string()
43228
+ }).nullable(),
43229
+ warnings: array(string()).readonly(),
43230
+ split: TrainingSplitPlanSchema.nullable(),
43231
+ estimate: object({
43232
+ datasetBytes: number().int(),
43233
+ uploadMinutesAt20Mbps: number(),
43234
+ gpuSecondsLow: number(),
43235
+ gpuSecondsHigh: number(),
43236
+ usdLow: number(),
43237
+ usdHigh: number(),
43238
+ notes: array(string()).readonly()
43239
+ }).nullable(),
43240
+ /** Pre-filled from the provider's settings; the operator may lower or raise them. */
43241
+ defaults: object({
43242
+ maxCostUsd: number(),
43243
+ maxRuntimeSec: number().int()
43244
+ }).nullable(),
43245
+ /** The sentence the confirm dialog repeats: where the frames go and when they are deleted. */
43246
+ dataNotice: string()
43247
+ });
43248
+ /**
43249
+ * Orchestrator-owned states, persisted. `uploading` covers exporting the
43250
+ * archive (it is streamed, never staged). Terminal: `failed`, `cancelled`,
43251
+ * `lost`, `expired`, `discarded`. `registered` and `canary` are where a
43252
+ * result lives after the operator acted on it.
43253
+ */
43254
+ var TrainingJobStateSchema = _enum([
43255
+ "uploading",
43256
+ "submitted",
43257
+ "starting",
43258
+ "running",
43259
+ "collecting",
43260
+ "ready",
43261
+ "registered",
43262
+ "canary",
43263
+ "failed",
43264
+ "cancelling",
43265
+ "cancelled",
43266
+ "lost",
43267
+ "expired",
43268
+ "discarded"
43269
+ ]);
43270
+ var TrainingFailureReasonSchema = _enum([
43271
+ "cost-cap",
43272
+ "runtime-cap",
43273
+ "upload-failed",
43274
+ "submit-failed",
43275
+ "trainer-failed",
43276
+ "result-invalid",
43277
+ "checksum-mismatch",
43278
+ "fetch-failed",
43279
+ "provider-error",
43280
+ "hub-restart-during-upload"
43281
+ ]);
43282
+ var TrainingProgressPointSchema = object({
43283
+ epoch: number().int(),
43284
+ map50: number().nullable(),
43285
+ map50_95: number().nullable()
43286
+ });
43287
+ var TrainingCanarySchema = object({
43288
+ deviceIds: array(number().int()).readonly(),
43289
+ since: number(),
43290
+ /** Every override the canary replaced, exactly, so rollback restores it. */
43291
+ previous: array(object({
43292
+ deviceId: number().int(),
43293
+ nodeId: string(),
43294
+ deviceKey: string(),
43295
+ patch: object({
43296
+ modelId: string().optional(),
43297
+ settings: record(string(), unknown()).readonly().optional()
43298
+ }).nullable()
43299
+ })).readonly()
43300
+ });
43301
+ var TrainingJobSchema = object({
43302
+ id: string(),
43303
+ idempotencyKey: string(),
43304
+ name: string(),
43305
+ createdAt: number(),
43306
+ updatedAt: number(),
43307
+ state: TrainingJobStateSchema,
43308
+ stage: TrainingStageSchema.nullable(),
43309
+ failure: object({
43310
+ reason: TrainingFailureReasonSchema,
43311
+ stage: string().nullable(),
43312
+ detail: string()
43313
+ }).nullable(),
43314
+ request: TrainingJobRequestSchema,
43315
+ maxCostUsd: number().nonnegative(),
43316
+ maxRuntimeSec: number().int().positive(),
43317
+ trainer: TrainerSourceRefSchema,
43318
+ datasetLayout: RetrainExportLayoutSchema,
43319
+ dataset: object({
43320
+ bytes: number().int(),
43321
+ sha256: string(),
43322
+ uploadedAt: number()
43323
+ }).nullable(),
43324
+ split: TrainingSplitPlanSchema,
43325
+ provider: object({
43326
+ state: ProviderJobStateSchema.nullable(),
43327
+ providerJobId: string().nullable(),
43328
+ startedAt: number().nullable(),
43329
+ endedAt: number().nullable(),
43330
+ billedSeconds: number(),
43331
+ costUsd: number(),
43332
+ costIsEstimate: boolean(),
43333
+ lastPolledAt: number().nullable()
43334
+ }),
43335
+ progress: object({
43336
+ epoch: number().int().nullable(),
43337
+ epochs: number().int().nullable(),
43338
+ etaSec: number().nullable(),
43339
+ series: array(TrainingProgressPointSchema).readonly()
43340
+ }),
43341
+ /** The last lines of the job's output (≤ 200), newest last. Never frame paths. */
43342
+ logTail: array(string()).readonly(),
43343
+ logCursor: string().nullable(),
43344
+ artifacts: object({
43345
+ bundleBytes: number().int(),
43346
+ bundleSha256: string(),
43347
+ fetchedAt: number(),
43348
+ /** When the staged artefacts are deleted from the hub. */
43349
+ expiresAt: number()
43350
+ }).nullable(),
43351
+ /** When the provider-side copy of the frames was deleted; null while it exists. */
43352
+ cloudDatasetDeletedAt: number().nullable(),
43353
+ /** A failed job's dataset is kept until then (the provider's grace), then deleted. */
43354
+ cloudCleanupDueAt: number().nullable(),
43355
+ /** Model ids registered from this job (base, and int8 when kept). */
43356
+ registeredModelIds: array(string()).readonly(),
43357
+ canary: TrainingCanarySchema.nullable()
43358
+ });
43359
+ var IdInput = object({ id: string().min(1) });
43360
+ method(TrainingDatasetVersionRowSchema, object({ stored: boolean() }), {
43361
+ kind: "mutation",
43362
+ auth: "admin"
43363
+ }), 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() }), {
43364
+ kind: "mutation",
43365
+ auth: "admin"
43366
+ }), method(object({}), array(TrainingBaseModelSchema).readonly(), { auth: "admin" }), method(TrainingJobRequestSchema, TrainingJobPlanSchema, {
43367
+ auth: "admin",
43368
+ timeoutMs: 6e4
43369
+ }), method(TrainingJobRequestSchema.extend({
43370
+ name: string().min(1).max(120),
43371
+ maxCostUsd: number().positive(),
43372
+ maxRuntimeSec: number().int().positive(),
43373
+ idempotencyKey: string().min(8).max(80)
43374
+ }), discriminatedUnion("kind", [object({
43375
+ kind: literal("started"),
43376
+ job: TrainingJobSchema
43377
+ }), object({
43378
+ kind: literal("refused"),
43379
+ reason: TrainingRefusalReasonSchema,
43380
+ detail: string()
43381
+ })]), {
43382
+ kind: "mutation",
43383
+ auth: "admin",
43384
+ timeoutMs: 12e4
43385
+ }), method(object({}), array(TrainingJobSchema).readonly(), { auth: "admin" }), method(IdInput, TrainingJobSchema.nullable(), { auth: "admin" }), method(IdInput, TrainingJobSchema, {
43386
+ kind: "mutation",
43387
+ auth: "admin",
43388
+ timeoutMs: 12e4
43389
+ }), method(IdInput, TrainingResultSchema.nullable(), { auth: "admin" }), method(IdInput.extend({ canaryDeviceIds: array(number().int()).readonly() }), TrainingJobSchema, {
43390
+ kind: "mutation",
43391
+ auth: "admin",
43392
+ timeoutMs: 30 * 6e4
43393
+ }), method(IdInput.extend({ deviceIds: array(number().int()).min(1).readonly() }), TrainingJobSchema, {
43394
+ kind: "mutation",
43395
+ auth: "admin",
43396
+ timeoutMs: 12e4
43397
+ }), method(IdInput, TrainingJobSchema, {
43398
+ kind: "mutation",
43399
+ auth: "admin",
43400
+ timeoutMs: 12e4
43401
+ }), method(IdInput, TrainingJobSchema, {
43402
+ kind: "mutation",
43403
+ auth: "admin"
43404
+ });
41998
43405
  SOURCE_CAPS.filter((cap) => cap !== "switch" && cap !== "motion");
41999
43406
  Object.freeze({
42000
43407
  person: .5,
@@ -44143,6 +45550,12 @@ Object.freeze({
44143
45550
  addonId: null,
44144
45551
  access: "create"
44145
45552
  },
45553
+ "backup.checkBackupKey": {
45554
+ capName: "backup",
45555
+ capScope: "system",
45556
+ addonId: null,
45557
+ access: "create"
45558
+ },
44146
45559
  "backup.delete": {
44147
45560
  capName: "backup",
44148
45561
  capScope: "system",
@@ -44155,6 +45568,18 @@ Object.freeze({
44155
45568
  addonId: null,
44156
45569
  access: "delete"
44157
45570
  },
45571
+ "backup.disableEncryption": {
45572
+ capName: "backup",
45573
+ capScope: "system",
45574
+ addonId: null,
45575
+ access: "create"
45576
+ },
45577
+ "backup.getEncryption": {
45578
+ capName: "backup",
45579
+ capScope: "system",
45580
+ addonId: null,
45581
+ access: "view"
45582
+ },
44158
45583
  "backup.getEntries": {
44159
45584
  capName: "backup",
44160
45585
  capScope: "system",
@@ -44209,6 +45634,12 @@ Object.freeze({
44209
45634
  addonId: null,
44210
45635
  access: "create"
44211
45636
  },
45637
+ "backup.setupEncryption": {
45638
+ capName: "backup",
45639
+ capScope: "system",
45640
+ addonId: null,
45641
+ access: "create"
45642
+ },
44212
45643
  "backup.trigger": {
44213
45644
  capName: "backup",
44214
45645
  capScope: "system",
@@ -44761,6 +46192,12 @@ Object.freeze({
44761
46192
  addonId: null,
44762
46193
  access: "create"
44763
46194
  },
46195
+ "customModelRegistry.importModelBundle": {
46196
+ capName: "custom-model-registry",
46197
+ capScope: "system",
46198
+ addonId: null,
46199
+ access: "create"
46200
+ },
44764
46201
  "customModelRegistry.listModels": {
44765
46202
  capName: "custom-model-registry",
44766
46203
  capScope: "system",
@@ -46201,6 +47638,12 @@ Object.freeze({
46201
47638
  addonId: null,
46202
47639
  access: "view"
46203
47640
  },
47641
+ "keychainAdmin.acknowledgeReset": {
47642
+ capName: "keychain-admin",
47643
+ capScope: "system",
47644
+ addonId: null,
47645
+ access: "create"
47646
+ },
46204
47647
  "keychainAdmin.deleteOrphans": {
46205
47648
  capName: "keychain-admin",
46206
47649
  capScope: "system",
@@ -46237,6 +47680,12 @@ Object.freeze({
46237
47680
  addonId: null,
46238
47681
  access: "delete"
46239
47682
  },
47683
+ "keychainAdmin.resetReport": {
47684
+ capName: "keychain-admin",
47685
+ capScope: "system",
47686
+ addonId: null,
47687
+ access: "delete"
47688
+ },
46240
47689
  "keychainAdmin.reveal": {
46241
47690
  capName: "keychain-admin",
46242
47691
  capScope: "system",
@@ -46249,6 +47698,12 @@ Object.freeze({
46249
47698
  addonId: null,
46250
47699
  access: "create"
46251
47700
  },
47701
+ "keychainAdmin.setSystemSecret": {
47702
+ capName: "keychain-admin",
47703
+ capScope: "system",
47704
+ addonId: null,
47705
+ access: "create"
47706
+ },
46252
47707
  "keychainAdmin.status": {
46253
47708
  capName: "keychain-admin",
46254
47709
  capScope: "system",
@@ -47695,6 +49150,12 @@ Object.freeze({
47695
49150
  addonId: null,
47696
49151
  access: "create"
47697
49152
  },
49153
+ "pipelineAnalytics.createRetrainDatasetVersion": {
49154
+ capName: "pipeline-analytics",
49155
+ capScope: "device",
49156
+ addonId: null,
49157
+ access: "create"
49158
+ },
47698
49159
  "pipelineAnalytics.deleteDeviceEvents": {
47699
49160
  capName: "pipeline-analytics",
47700
49161
  capScope: "device",
@@ -47707,6 +49168,12 @@ Object.freeze({
47707
49168
  addonId: null,
47708
49169
  access: "delete"
47709
49170
  },
49171
+ "pipelineAnalytics.deleteRetrainDatasetVersion": {
49172
+ capName: "pipeline-analytics",
49173
+ capScope: "device",
49174
+ addonId: null,
49175
+ access: "delete"
49176
+ },
47710
49177
  "pipelineAnalytics.deleteTracks": {
47711
49178
  capName: "pipeline-analytics",
47712
49179
  capScope: "device",
@@ -47929,6 +49396,12 @@ Object.freeze({
47929
49396
  addonId: null,
47930
49397
  access: "view"
47931
49398
  },
49399
+ "pipelineAnalytics.listRetrainDatasetVersions": {
49400
+ capName: "pipeline-analytics",
49401
+ capScope: "device",
49402
+ addonId: null,
49403
+ access: "view"
49404
+ },
47932
49405
  "pipelineAnalytics.listRetrainFrames": {
47933
49406
  capName: "pipeline-analytics",
47934
49407
  capScope: "device",
@@ -47959,6 +49432,12 @@ Object.freeze({
47959
49432
  addonId: null,
47960
49433
  access: "view"
47961
49434
  },
49435
+ "pipelineAnalytics.offerRetrainArchive": {
49436
+ capName: "pipeline-analytics",
49437
+ capScope: "device",
49438
+ addonId: null,
49439
+ access: "create"
49440
+ },
47962
49441
  "pipelineAnalytics.ownersWithMedia": {
47963
49442
  capName: "pipeline-analytics",
47964
49443
  capScope: "device",
@@ -47971,6 +49450,12 @@ Object.freeze({
47971
49450
  addonId: null,
47972
49451
  access: "create"
47973
49452
  },
49453
+ "pipelineAnalytics.previewRetrainDataset": {
49454
+ capName: "pipeline-analytics",
49455
+ capScope: "device",
49456
+ addonId: null,
49457
+ access: "view"
49458
+ },
47974
49459
  "pipelineAnalytics.proposeRetrainAnnotations": {
47975
49460
  capName: "pipeline-analytics",
47976
49461
  capScope: "device",
@@ -48109,6 +49594,12 @@ Object.freeze({
48109
49594
  addonId: null,
48110
49595
  access: "create"
48111
49596
  },
49597
+ "pipelineAnalytics.verifyRetrainDatasetVersion": {
49598
+ capName: "pipeline-analytics",
49599
+ capScope: "device",
49600
+ addonId: null,
49601
+ access: "view"
49602
+ },
48112
49603
  "pipelineAnalytics.wipeAllAnalytics": {
48113
49604
  capName: "pipeline-analytics",
48114
49605
  capScope: "device",
@@ -50485,6 +51976,174 @@ Object.freeze({
50485
51976
  addonId: null,
50486
51977
  access: "view"
50487
51978
  },
51979
+ "training.canaryResult": {
51980
+ capName: "training",
51981
+ capScope: "system",
51982
+ addonId: null,
51983
+ access: "create"
51984
+ },
51985
+ "training.cancelJob": {
51986
+ capName: "training",
51987
+ capScope: "system",
51988
+ addonId: null,
51989
+ access: "create"
51990
+ },
51991
+ "training.discardResult": {
51992
+ capName: "training",
51993
+ capScope: "system",
51994
+ addonId: null,
51995
+ access: "create"
51996
+ },
51997
+ "training.findDatasetVersionIdByName": {
51998
+ capName: "training",
51999
+ capScope: "system",
52000
+ addonId: null,
52001
+ access: "view"
52002
+ },
52003
+ "training.getDatasetVersion": {
52004
+ capName: "training",
52005
+ capScope: "system",
52006
+ addonId: null,
52007
+ access: "view"
52008
+ },
52009
+ "training.getJob": {
52010
+ capName: "training",
52011
+ capScope: "system",
52012
+ addonId: null,
52013
+ access: "view"
52014
+ },
52015
+ "training.getJobResult": {
52016
+ capName: "training",
52017
+ capScope: "system",
52018
+ addonId: null,
52019
+ access: "view"
52020
+ },
52021
+ "training.listBaseModels": {
52022
+ capName: "training",
52023
+ capScope: "system",
52024
+ addonId: null,
52025
+ access: "view"
52026
+ },
52027
+ "training.listDatasetVersions": {
52028
+ capName: "training",
52029
+ capScope: "system",
52030
+ addonId: null,
52031
+ access: "view"
52032
+ },
52033
+ "training.listJobs": {
52034
+ capName: "training",
52035
+ capScope: "system",
52036
+ addonId: null,
52037
+ access: "view"
52038
+ },
52039
+ "training.planJob": {
52040
+ capName: "training",
52041
+ capScope: "system",
52042
+ addonId: null,
52043
+ access: "view"
52044
+ },
52045
+ "training.putDatasetVersion": {
52046
+ capName: "training",
52047
+ capScope: "system",
52048
+ addonId: null,
52049
+ access: "create"
52050
+ },
52051
+ "training.registerResult": {
52052
+ capName: "training",
52053
+ capScope: "system",
52054
+ addonId: null,
52055
+ access: "create"
52056
+ },
52057
+ "training.removeDatasetVersion": {
52058
+ capName: "training",
52059
+ capScope: "system",
52060
+ addonId: null,
52061
+ access: "delete"
52062
+ },
52063
+ "training.rollbackCanary": {
52064
+ capName: "training",
52065
+ capScope: "system",
52066
+ addonId: null,
52067
+ access: "create"
52068
+ },
52069
+ "training.startJob": {
52070
+ capName: "training",
52071
+ capScope: "system",
52072
+ addonId: null,
52073
+ access: "create"
52074
+ },
52075
+ "trainingProvider.cancelJob": {
52076
+ capName: "training-provider",
52077
+ capScope: "system",
52078
+ addonId: null,
52079
+ access: "create"
52080
+ },
52081
+ "trainingProvider.cleanupJob": {
52082
+ capName: "training-provider",
52083
+ capScope: "system",
52084
+ addonId: null,
52085
+ access: "create"
52086
+ },
52087
+ "trainingProvider.describe": {
52088
+ capName: "training-provider",
52089
+ capScope: "system",
52090
+ addonId: null,
52091
+ access: "view"
52092
+ },
52093
+ "trainingProvider.estimateJob": {
52094
+ capName: "training-provider",
52095
+ capScope: "system",
52096
+ addonId: null,
52097
+ access: "view"
52098
+ },
52099
+ "trainingProvider.getJob": {
52100
+ capName: "training-provider",
52101
+ capScope: "system",
52102
+ addonId: null,
52103
+ access: "view"
52104
+ },
52105
+ "trainingProvider.listJobEvents": {
52106
+ capName: "training-provider",
52107
+ capScope: "system",
52108
+ addonId: null,
52109
+ access: "view"
52110
+ },
52111
+ "trainingProvider.listJobs": {
52112
+ capName: "training-provider",
52113
+ capScope: "system",
52114
+ addonId: null,
52115
+ access: "view"
52116
+ },
52117
+ "trainingProvider.offerArtifact": {
52118
+ capName: "training-provider",
52119
+ capScope: "system",
52120
+ addonId: null,
52121
+ access: "create"
52122
+ },
52123
+ "trainingProvider.readResult": {
52124
+ capName: "training-provider",
52125
+ capScope: "system",
52126
+ addonId: null,
52127
+ access: "create"
52128
+ },
52129
+ "trainingProvider.submitJob": {
52130
+ capName: "training-provider",
52131
+ capScope: "system",
52132
+ addonId: null,
52133
+ access: "create"
52134
+ },
52135
+ "trainingProvider.uploadDataset": {
52136
+ capName: "training-provider",
52137
+ capScope: "system",
52138
+ addonId: null,
52139
+ access: "create"
52140
+ },
52141
+ "trainingProvider.validateCredentials": {
52142
+ capName: "training-provider",
52143
+ capScope: "system",
52144
+ addonId: null,
52145
+ access: "create"
52146
+ },
50488
52147
  "turnProvider.getTurnServers": {
50489
52148
  capName: "turn-provider",
50490
52149
  capScope: "system",
@@ -50509,12 +52168,6 @@ Object.freeze({
50509
52168
  addonId: null,
50510
52169
  access: "create"
50511
52170
  },
50512
- "userManagement.createApiKey": {
50513
- capName: "user-management",
50514
- capScope: "system",
50515
- addonId: null,
50516
- access: "create"
50517
- },
50518
52171
  "userManagement.createScopedToken": {
50519
52172
  capName: "user-management",
50520
52173
  capScope: "system",
@@ -50551,12 +52204,6 @@ Object.freeze({
50551
52204
  addonId: null,
50552
52205
  access: "view"
50553
52206
  },
50554
- "userManagement.linkExternalIdentity": {
50555
- capName: "user-management",
50556
- capScope: "system",
50557
- addonId: null,
50558
- access: "create"
50559
- },
50560
52207
  "userManagement.listApiKeys": {
50561
52208
  capName: "user-management",
50562
52209
  capScope: "system",
@@ -50659,12 +52306,6 @@ Object.freeze({
50659
52306
  addonId: null,
50660
52307
  access: "create"
50661
52308
  },
50662
- "userManagement.validateApiKey": {
50663
- capName: "user-management",
50664
- capScope: "system",
50665
- addonId: null,
50666
- access: "view"
50667
- },
50668
52309
  "userManagement.validateCredentials": {
50669
52310
  capName: "user-management",
50670
52311
  capScope: "system",
@@ -54778,6 +56419,11 @@ Object.freeze({
54778
56419
  form: "single",
54779
56420
  optional: false
54780
56421
  }],
56422
+ "training.canaryResult": [{
56423
+ name: "deviceIds",
56424
+ form: "array",
56425
+ optional: false
56426
+ }],
54781
56427
  "update.getStatus": [{
54782
56428
  name: "deviceId",
54783
56429
  form: "single",
@@ -55713,6 +57359,8 @@ var STATE_SUMMARY_VARS = [
55713
57359
  [...RULE_TEXT],
55714
57360
  [...RULE_TEXT],
55715
57361
  [...RULE_TEXT],
57362
+ [...RULE_TEXT],
57363
+ [...RULE_TEXT],
55716
57364
  ([...RULE_TEXT], [...UPDATES]),
55717
57365
  ([...RULE_TEXT], [...PACKAGE_UPDATES]),
55718
57366
  ([...RULE_TEXT], [...PACKAGE_UPDATES]),