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