@camstack/addon-export-hap 1.2.155 → 1.2.157

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.
@@ -5426,7 +5426,7 @@ var ZodIssueCode = {
5426
5426
  var ZodFirstPartyTypeKind;
5427
5427
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
5428
5428
  //#endregion
5429
- //#region ../types/dist/sleep-Cr5YOk3m.mjs
5429
+ //#region ../types/dist/sleep-r3RWkGVx.mjs
5430
5430
  /**
5431
5431
  * The audio chunk plane's byte format, and the ONE expansion from a coded
5432
5432
  * window to float samples (D455).
@@ -5543,7 +5543,7 @@ function isKeychainStoredField(field) {
5543
5543
  var SECRET_CLEAR = { $secretClear: true };
5544
5544
  /** The `'***'` token D634 redaction writes for non-admins. */
5545
5545
  var LEGACY_DEVICE_REDACTION = "***";
5546
- function isRecord$1$1(value) {
5546
+ function isRecord$2(value) {
5547
5547
  return typeof value === "object" && value !== null && !Array.isArray(value);
5548
5548
  }
5549
5549
  function makeSecretMarker(ref) {
@@ -5554,12 +5554,12 @@ function makeSecretMarker(ref) {
5554
5554
  }
5555
5555
  /** A stored marker: an object whose `$secret` is a non-empty string. */
5556
5556
  function isSecretMarker(value) {
5557
- if (!isRecord$1$1(value)) return false;
5557
+ if (!isRecord$2(value)) return false;
5558
5558
  const ref = value["$secret"];
5559
5559
  return typeof ref === "string" && ref.length > 0;
5560
5560
  }
5561
5561
  function isSecretClear(value) {
5562
- return isRecord$1$1(value) && value["$secretClear"] === true;
5562
+ return isRecord$2(value) && value["$secretClear"] === true;
5563
5563
  }
5564
5564
  /**
5565
5565
  * The UI view of a stored secret field value: a marker becomes "set", inline
@@ -6075,6 +6075,13 @@ function globalSecretScope() {
6075
6075
  function encodeSegment(value) {
6076
6076
  return encodeURIComponent(value);
6077
6077
  }
6078
+ function decodeSegment(value) {
6079
+ try {
6080
+ return decodeURIComponent(value);
6081
+ } catch {
6082
+ return null;
6083
+ }
6084
+ }
6078
6085
  /**
6079
6086
  * The field path of a value inside an array item, addressed by the item's id:
6080
6087
  * `arrayItemFieldPath('providers', 'authentik', 'clientSecret')` →
@@ -6083,6 +6090,75 @@ function encodeSegment(value) {
6083
6090
  function arrayItemFieldPath(arrayKey, itemId, fieldKey) {
6084
6091
  return `${arrayKey}[${encodeSegment(itemId)}].${fieldKey}`;
6085
6092
  }
6093
+ function parseScope(segments) {
6094
+ switch (segments[0]) {
6095
+ case "global": return {
6096
+ scope: GLOBAL_SCOPE,
6097
+ used: 1
6098
+ };
6099
+ case "node": {
6100
+ const nodeId = segments[1] !== void 0 ? decodeSegment(segments[1]) : null;
6101
+ return nodeId === null || nodeId.length === 0 ? null : {
6102
+ scope: {
6103
+ kind: "node",
6104
+ nodeId
6105
+ },
6106
+ used: 2
6107
+ };
6108
+ }
6109
+ case "device": {
6110
+ const raw = segments[1];
6111
+ if (raw === void 0 || !/^\d+$/.test(raw)) return null;
6112
+ return {
6113
+ scope: {
6114
+ kind: "device",
6115
+ deviceId: Number(raw)
6116
+ },
6117
+ used: 2
6118
+ };
6119
+ }
6120
+ case "integration": {
6121
+ const id = segments[1] !== void 0 ? decodeSegment(segments[1]) : null;
6122
+ return id === null || id.length === 0 ? null : {
6123
+ scope: {
6124
+ kind: "integration",
6125
+ integrationId: id
6126
+ },
6127
+ used: 2
6128
+ };
6129
+ }
6130
+ case "row": {
6131
+ const collection = segments[1] !== void 0 ? decodeSegment(segments[1]) : null;
6132
+ const rowId = segments[2] !== void 0 ? decodeSegment(segments[2]) : null;
6133
+ if (collection === null || rowId === null || collection.length === 0 || rowId.length === 0) return null;
6134
+ return {
6135
+ scope: {
6136
+ kind: "row",
6137
+ collection,
6138
+ rowId
6139
+ },
6140
+ used: 3
6141
+ };
6142
+ }
6143
+ default: return null;
6144
+ }
6145
+ }
6146
+ /** Take a ref apart; `null` when it is not a well-formed ref. */
6147
+ function parseSecretRef(ref) {
6148
+ if (!ref.startsWith("secret://")) return null;
6149
+ const segments = ref.slice(9).split("/");
6150
+ const owner = segments[0] !== void 0 ? decodeSegment(segments[0]) : null;
6151
+ if (owner === null || owner.length === 0) return null;
6152
+ const parsed = parseScope(segments.slice(1));
6153
+ if (parsed === null) return null;
6154
+ const fieldPath = segments.slice(1 + parsed.used).join("/");
6155
+ if (fieldPath.length === 0) return null;
6156
+ return {
6157
+ owner,
6158
+ scope: parsed.scope,
6159
+ fieldPath
6160
+ };
6161
+ }
6086
6162
  /** A write to a secret path could not be stored in the keychain, so it was refused. */
6087
6163
  var KeychainWriteRefusedError = class extends Error {
6088
6164
  fieldPath;
@@ -6093,7 +6169,7 @@ var KeychainWriteRefusedError = class extends Error {
6093
6169
  }
6094
6170
  };
6095
6171
  var KEEP = { kind: "keep" };
6096
- function isRecord$2(value) {
6172
+ function isRecord$1$1(value) {
6097
6173
  return typeof value === "object" && value !== null && !Array.isArray(value);
6098
6174
  }
6099
6175
  function defaultMintId() {
@@ -6106,7 +6182,7 @@ function collectSecretMarkerRefs(value, out = []) {
6106
6182
  return out;
6107
6183
  }
6108
6184
  if (Array.isArray(value)) for (const item of value) collectSecretMarkerRefs(item, out);
6109
- else if (isRecord$2(value)) for (const child of Object.values(value)) collectSecretMarkerRefs(child, out);
6185
+ else if (isRecord$1$1(value)) for (const child of Object.values(value)) collectSecretMarkerRefs(child, out);
6110
6186
  return out;
6111
6187
  }
6112
6188
  async function storedValueEquals(secrets, marker, candidate) {
@@ -6161,7 +6237,7 @@ function rowId(row, idKey) {
6161
6237
  return null;
6162
6238
  }
6163
6239
  async function writeArray(ctx, node, incoming, stored, fieldPath) {
6164
- const storedRows = Array.isArray(stored) ? stored.filter(isRecord$2) : [];
6240
+ const storedRows = Array.isArray(stored) ? stored.filter(isRecord$1$1) : [];
6165
6241
  if (!Array.isArray(incoming)) {
6166
6242
  ctx.deletes.push(...collectSecretMarkerRefs(storedRows));
6167
6243
  return {
@@ -6177,7 +6253,7 @@ async function writeArray(ctx, node, incoming, stored, fieldPath) {
6177
6253
  const kept = /* @__PURE__ */ new Set();
6178
6254
  const rows = [];
6179
6255
  for (const row of incoming) {
6180
- if (!isRecord$2(row)) {
6256
+ if (!isRecord$1$1(row)) {
6181
6257
  rows.push(row);
6182
6258
  continue;
6183
6259
  }
@@ -6202,7 +6278,7 @@ async function writeNode(ctx, node, incoming, stored, fieldPath) {
6202
6278
  case "leaf": return writeLeaf(ctx, incoming, stored, fieldPath);
6203
6279
  case "array": return writeArray(ctx, node, incoming, stored, fieldPath);
6204
6280
  case "object": {
6205
- if (!isRecord$2(incoming)) {
6281
+ if (!isRecord$1$1(incoming)) {
6206
6282
  if (incoming === void 0) return KEEP;
6207
6283
  ctx.deletes.push(...collectSecretMarkerRefs(stored));
6208
6284
  return {
@@ -6210,7 +6286,7 @@ async function writeNode(ctx, node, incoming, stored, fieldPath) {
6210
6286
  value: incoming
6211
6287
  };
6212
6288
  }
6213
- const storedObj = isRecord$2(stored) ? stored : {};
6289
+ const storedObj = isRecord$1$1(stored) ? stored : {};
6214
6290
  return {
6215
6291
  kind: "value",
6216
6292
  value: await writeMembers(ctx, node.children, incoming, storedObj, (m) => `${fieldPath}.${m}`)
@@ -6269,12 +6345,19 @@ async function transformSecretWrite(input) {
6269
6345
  }
6270
6346
  };
6271
6347
  }
6348
+ /** Is `ref` one of `owner`'s refs? */
6349
+ function isSecretRefOwnedBy(ref, owner) {
6350
+ return parseSecretRef(ref)?.owner === owner;
6351
+ }
6272
6352
  /**
6273
6353
  * Replace every marker in `value` with its keychain value. Returns the SAME
6274
6354
  * reference when there is no marker (no allocation, no keychain call).
6275
6355
  */
6276
- async function resolveSecretMarkers(value, secrets) {
6277
- const refs = collectSecretMarkerRefs(value);
6356
+ async function resolveSecretMarkers(value, secrets, options = {}) {
6357
+ const keepMarker = options.unresolved === "keep-marker";
6358
+ const owner = options.ownedBy;
6359
+ const inScope = (ref) => owner === void 0 || isSecretRefOwnedBy(ref, owner);
6360
+ const refs = collectSecretMarkerRefs(value).filter(inScope);
6278
6361
  if (refs.length === 0) return {
6279
6362
  value,
6280
6363
  unresolved: []
@@ -6298,10 +6381,18 @@ async function resolveSecretMarkers(value, secrets) {
6298
6381
  }
6299
6382
  const substitute = (v) => {
6300
6383
  if (isSecretMarker(v)) {
6384
+ if (!inScope(v.$secret)) return {
6385
+ keep: true,
6386
+ value: v
6387
+ };
6301
6388
  const answer = answers[v.$secret];
6302
- return answer?.kind === "value" ? {
6389
+ if (answer?.kind === "value") return {
6303
6390
  keep: true,
6304
6391
  value: answer.value
6392
+ };
6393
+ return keepMarker ? {
6394
+ keep: true,
6395
+ value: v
6305
6396
  } : {
6306
6397
  keep: false,
6307
6398
  value: void 0
@@ -6318,7 +6409,7 @@ async function resolveSecretMarkers(value, secrets) {
6318
6409
  value: items
6319
6410
  };
6320
6411
  }
6321
- if (isRecord$2(v)) {
6412
+ if (isRecord$1$1(v)) {
6322
6413
  const out = {};
6323
6414
  for (const [k, child] of Object.entries(v)) {
6324
6415
  const s = substitute(child);
@@ -6339,14 +6430,152 @@ async function resolveSecretMarkers(value, secrets) {
6339
6430
  unresolved
6340
6431
  };
6341
6432
  }
6342
- function touchesTree(tree, patch) {
6343
- if (tree.size === 0) return false;
6344
- for (const key of Object.keys(patch)) {
6345
- const at = key.indexOf("@");
6346
- if (tree.has(at > 0 ? key.slice(0, at) : key)) return true;
6433
+ /** An addon tried to replace a stored secret it could not read. Nothing was written. */
6434
+ var SecretOverwriteRefusedError = class extends Error {
6435
+ ref;
6436
+ reason;
6437
+ constructor(ref, reason) {
6438
+ 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.`);
6439
+ this.ref = ref;
6440
+ this.reason = reason;
6441
+ this.name = "SecretOverwriteRefusedError";
6442
+ }
6443
+ };
6444
+ function isRecord$3(value) {
6445
+ return typeof value === "object" && value !== null && !Array.isArray(value);
6446
+ }
6447
+ function resolvedValue(pass, marker) {
6448
+ const answer = pass.answers[marker.$secret];
6449
+ return answer?.kind === "value" ? answer.value : null;
6450
+ }
6451
+ async function atMarker(pass, incoming, stored) {
6452
+ if (incoming === null) return stored;
6453
+ if (typeof incoming !== "string") return incoming;
6454
+ if (incoming === resolvedValue(pass, stored)) return stored;
6455
+ const intent = classifySecretWrite(incoming);
6456
+ if (intent.kind !== "set") return stored;
6457
+ const ref = stored.$secret;
6458
+ if (!isSecretRefOwnedBy(ref, pass.secrets.owner)) return incoming;
6459
+ const answer = pass.answers[ref];
6460
+ 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);
6461
+ try {
6462
+ await pass.secrets.put(ref, intent.value);
6463
+ } catch (err) {
6464
+ throw new KeychainWriteRefusedError(ref, err);
6465
+ }
6466
+ pass.changedRefs.push(ref);
6467
+ return stored;
6468
+ }
6469
+ function inArray(pass, incoming, stored) {
6470
+ return incoming.map((item, index) => {
6471
+ const twin = stored[index];
6472
+ if (isSecretMarker(twin)) return typeof item === "string" && item === resolvedValue(pass, twin) ? twin : item;
6473
+ if (isRecord$3(item) && isRecord$3(twin)) return inArrayRow(pass, item, twin);
6474
+ if (Array.isArray(item) && Array.isArray(twin)) return inArray(pass, item, twin);
6475
+ return item;
6476
+ });
6477
+ }
6478
+ function inArrayRow(pass, incoming, stored) {
6479
+ const out = { ...incoming };
6480
+ for (const [key, value] of Object.entries(incoming)) {
6481
+ const twin = stored[key];
6482
+ if (isSecretMarker(twin)) {
6483
+ if (typeof value === "string" && value === resolvedValue(pass, twin)) out[key] = twin;
6484
+ } else if (isRecord$3(value) && isRecord$3(twin)) out[key] = inArrayRow(pass, value, twin);
6485
+ else if (Array.isArray(value) && Array.isArray(twin)) out[key] = inArray(pass, value, twin);
6486
+ }
6487
+ return out;
6488
+ }
6489
+ async function walk(pass, incoming, stored) {
6490
+ if (isSecretMarker(stored)) return atMarker(pass, incoming, stored);
6491
+ if (Array.isArray(incoming) && Array.isArray(stored)) return inArray(pass, incoming, stored);
6492
+ if (!isRecord$3(incoming) || !isRecord$3(stored)) return incoming;
6493
+ const out = { ...incoming };
6494
+ for (const [key, value] of Object.entries(incoming)) out[key] = await walk(pass, value, stored[key]);
6495
+ return out;
6496
+ }
6497
+ /** Restore markers a write-back carries as values. See the file doc. */
6498
+ async function restoreUnchangedSecrets(input) {
6499
+ const refs = [];
6500
+ for (const key of Object.keys(input.patch)) collectSecretMarkerRefs(input.stored[key], refs);
6501
+ const owned = refs.filter((ref) => isSecretRefOwnedBy(ref, input.secrets.owner));
6502
+ if (owned.length === 0) return {
6503
+ patch: input.patch,
6504
+ changedRefs: []
6505
+ };
6506
+ const pass = {
6507
+ secrets: input.secrets,
6508
+ answers: await input.secrets.resolve([...new Set(owned)]),
6509
+ operatorWrite: input.operatorWrite,
6510
+ changedRefs: []
6511
+ };
6512
+ const out = {};
6513
+ for (const [key, value] of Object.entries(input.patch)) out[key] = await walk(pass, value, input.stored[key]);
6514
+ return {
6515
+ patch: out,
6516
+ changedRefs: pass.changedRefs
6517
+ };
6518
+ }
6519
+ /** Structural equality over JSON-shaped values (key order does not matter). */
6520
+ function isJsonEqual(a, b) {
6521
+ if (Object.is(a, b)) return true;
6522
+ if (Array.isArray(a)) return Array.isArray(b) && a.length === b.length && a.every((v, i) => isJsonEqual(v, b[i]));
6523
+ if (isRecord$3(a) && isRecord$3(b)) {
6524
+ const keys = Object.keys(a);
6525
+ if (keys.length !== Object.keys(b).length) return false;
6526
+ return keys.every((k) => Object.prototype.hasOwnProperty.call(b, k) && isJsonEqual(a[k], b[k]));
6347
6527
  }
6348
6528
  return false;
6349
6529
  }
6530
+ /** The patch without the keys whose value already equals the stored one. */
6531
+ function dropUnchangedKeys(patch, stored) {
6532
+ const out = {};
6533
+ for (const [key, value] of Object.entries(patch)) {
6534
+ if (Object.prototype.hasOwnProperty.call(stored, key) && isJsonEqual(value, stored[key])) continue;
6535
+ out[key] = value;
6536
+ }
6537
+ return out;
6538
+ }
6539
+ /** The top-level keys of a blob that hold at least one of `owner`'s markers. */
6540
+ function markerKeysOf(blob, owner) {
6541
+ const keys = /* @__PURE__ */ new Set();
6542
+ for (const [key, value] of Object.entries(blob)) if (collectSecretMarkerRefs(value).some((ref) => isSecretRefOwnedBy(ref, owner))) keys.add(key);
6543
+ return keys;
6544
+ }
6545
+ function nodeFromStored(value, owner) {
6546
+ if (isSecretMarker(value)) return isSecretRefOwnedBy(value.$secret, owner) ? { kind: "leaf" } : null;
6547
+ if (!isRecord$3(value)) return null;
6548
+ const children = /* @__PURE__ */ new Map();
6549
+ for (const [key, child] of Object.entries(value)) {
6550
+ const node = nodeFromStored(child, owner);
6551
+ if (node !== null) children.set(key, node);
6552
+ }
6553
+ return children.size > 0 ? {
6554
+ kind: "object",
6555
+ children
6556
+ } : null;
6557
+ }
6558
+ /**
6559
+ * The declared secret tree, widened by every place the STORED blob holds a
6560
+ * marker under one of `keys` — so a marker the schema no longer declares (or
6561
+ * never declared: Wyze before b4906cec6) still gets the save path's
6562
+ * KEEP / SET / CLEAR semantics instead of being overwritten by whatever the
6563
+ * addon writes. Markers inside arrays are not added: a row has no id field to
6564
+ * match by unless the schema declares one. Only `owner`'s markers count: a
6565
+ * builtin that keeps another addon's marker (device-manager) never takes it
6566
+ * over.
6567
+ */
6568
+ function widenTreeWithStoredMarkers(declared, stored, keys, owner) {
6569
+ const added = /* @__PURE__ */ new Map();
6570
+ for (const key of keys) {
6571
+ const at = key.indexOf("@");
6572
+ const base = at > 0 ? key.slice(0, at) : key;
6573
+ if (declared.has(base) || added.has(base)) continue;
6574
+ const node = nodeFromStored(stored[key], owner);
6575
+ if (node !== null) added.set(base, node);
6576
+ }
6577
+ return added.size === 0 ? declared : new Map([...declared, ...added]);
6578
+ }
6350
6579
  /** The blob as stored now; a failed read REFUSES the write instead of guessing. */
6351
6580
  async function readStoredAddonBlob(raw) {
6352
6581
  const threeWay = raw.readAddonStoreResult;
@@ -6355,7 +6584,41 @@ async function readStoredAddonBlob(raw) {
6355
6584
  if (result.kind === "failed") throw new Error(`settings write refused: the stored blob could not be read (${result.error})`);
6356
6585
  return result.kind === "missing" ? {} : result.value;
6357
6586
  }
6358
- function createSecretAwareSettings(raw, opts) {
6587
+ function touchesTree(tree, patch) {
6588
+ if (tree.size === 0) return false;
6589
+ for (const key of Object.keys(patch)) {
6590
+ const at = key.indexOf("@");
6591
+ if (tree.has(at > 0 ? key.slice(0, at) : key)) return true;
6592
+ }
6593
+ return false;
6594
+ }
6595
+ /**
6596
+ * Which top-level keys of each store held markers when last seen. `undefined`
6597
+ * for a store not seen yet: its first write reads it, to be safe.
6598
+ */
6599
+ var MarkerKeyIndex = class {
6600
+ owner;
6601
+ byStore = /* @__PURE__ */ new Map();
6602
+ constructor(owner) {
6603
+ this.owner = owner;
6604
+ }
6605
+ seen(store, blob) {
6606
+ this.byStore.set(store, markerKeysOf(blob, this.owner));
6607
+ }
6608
+ wrote(store, patch) {
6609
+ const keys = this.byStore.get(store);
6610
+ if (keys === void 0) return;
6611
+ const now = markerKeysOf(patch, this.owner);
6612
+ for (const key of Object.keys(patch)) if (now.has(key)) keys.add(key);
6613
+ else keys.delete(key);
6614
+ }
6615
+ mayHoldMarkers(store, patch) {
6616
+ const keys = this.byStore.get(store);
6617
+ if (keys === void 0) return true;
6618
+ return Object.keys(patch).some((key) => keys.has(key));
6619
+ }
6620
+ };
6621
+ function createHandle(raw, opts) {
6359
6622
  const chains = /* @__PURE__ */ new Map();
6360
6623
  const serialize = (key, fn) => {
6361
6624
  const next = (chains.get(key) ?? Promise.resolve()).then(fn, fn);
@@ -6366,46 +6629,130 @@ function createSecretAwareSettings(raw, opts) {
6366
6629
  });
6367
6630
  return next;
6368
6631
  };
6369
- const write = async (chainKey, tree, scope, patch, readStored, rawWrite) => {
6370
- if (!touchesTree(tree, patch)) return rawWrite(patch);
6371
- return serialize(chainKey, async () => {
6632
+ const index = new MarkerKeyIndex(opts.secrets.owner);
6633
+ const resolveRead = async (store, blob) => {
6634
+ index.seen(store, blob);
6635
+ const { value, unresolved } = await resolveSecretMarkers(blob, opts.secrets, {
6636
+ unresolved: "keep-marker",
6637
+ ownedBy: opts.secrets.owner
6638
+ });
6639
+ if (unresolved.length > 0) opts.onUnresolved?.(unresolved);
6640
+ return value;
6641
+ };
6642
+ const write = async (store, declared, scope, patch, readStored, rawWrite) => {
6643
+ if (!touchesTree(declared, patch) && !index.mayHoldMarkers(store, patch)) {
6644
+ await rawWrite(patch);
6645
+ index.wrote(store, patch);
6646
+ return { changed: true };
6647
+ }
6648
+ return serialize(store, async () => {
6372
6649
  const stored = await readStored();
6650
+ index.seen(store, stored);
6651
+ const operatorWrite = opts.isOperatorWrite?.() === true;
6652
+ const restored = await restoreUnchangedSecrets({
6653
+ patch,
6654
+ stored,
6655
+ secrets: opts.secrets,
6656
+ operatorWrite
6657
+ });
6373
6658
  const result = await transformSecretWrite({
6374
- tree,
6659
+ tree: widenTreeWithStoredMarkers(declared, stored, Object.keys(restored.patch), opts.secrets.owner),
6375
6660
  secrets: opts.secrets,
6376
- patch,
6661
+ patch: restored.patch,
6377
6662
  stored,
6378
6663
  ...scope !== void 0 ? { scope } : {},
6379
- operatorWrite: opts.isOperatorWrite?.() === true
6664
+ operatorWrite
6380
6665
  });
6381
- if (Object.keys(result.patch).length > 0) await rawWrite(result.patch);
6666
+ const effective = dropUnchangedKeys(result.patch, stored);
6667
+ const wroteBlob = Object.keys(effective).length > 0;
6668
+ if (wroteBlob) {
6669
+ await rawWrite(effective);
6670
+ index.wrote(store, effective);
6671
+ }
6382
6672
  const { orphaned } = await result.afterWrite();
6383
6673
  if (orphaned.length > 0) opts.onOrphaned(orphaned);
6674
+ return { changed: wroteBlob || restored.changedRefs.length > 0 };
6384
6675
  });
6385
6676
  };
6386
- const wrapped = {
6387
- writeAddonStore: (patch) => write("addon", opts.addonTree(), void 0, patch, () => readStoredAddonBlob(raw), (p) => raw.writeAddonStore(p)),
6388
- writeDeviceStore: (deviceId, patch) => write(`device:${deviceId}`, opts.deviceTree(), {
6389
- kind: "device",
6390
- deviceId
6391
- }, patch, () => raw.readDeviceStore(deviceId), (p) => raw.writeDeviceStore(deviceId, p))
6392
- };
6393
- return new Proxy(raw, { get(target, prop, receiver) {
6394
- if (prop === "writeAddonStore") return wrapped.writeAddonStore;
6395
- if (prop === "writeDeviceStore") return wrapped.writeDeviceStore;
6396
- const value = Reflect.get(target, prop, receiver);
6397
- return typeof value === "function" ? value.bind(target) : value;
6398
- } });
6677
+ const writeAddon = (patch) => write("addon", opts.addonTree(), void 0, patch, () => readStoredAddonBlob(raw), (p) => raw.writeAddonStore(p));
6678
+ const readAddonStoreResult = raw.readAddonStoreResult;
6679
+ const readAddonStoreKeyResult = raw.readAddonStoreKeyResult;
6680
+ const readDeviceStoreBatch = raw.readDeviceStoreBatch;
6681
+ const overrides = {
6682
+ readAddonStore: async () => resolveRead("addon", await raw.readAddonStore()),
6683
+ ...readAddonStoreResult !== void 0 ? { readAddonStoreResult: async () => {
6684
+ const result = await readAddonStoreResult.call(raw);
6685
+ return result.kind === "value" ? {
6686
+ kind: "value",
6687
+ value: await resolveRead("addon", result.value)
6688
+ } : result;
6689
+ } } : {},
6690
+ ...readAddonStoreKeyResult !== void 0 ? { readAddonStoreKeyResult: async (key) => {
6691
+ const result = await readAddonStoreKeyResult.call(raw, key);
6692
+ if (result.kind !== "present") return result;
6693
+ const { value, unresolved } = await resolveSecretMarkers({ [key]: result.value }, opts.secrets, {
6694
+ unresolved: "keep-marker",
6695
+ ownedBy: opts.secrets.owner
6696
+ });
6697
+ if (unresolved.length > 0) opts.onUnresolved?.(unresolved);
6698
+ return {
6699
+ kind: "present",
6700
+ value: value[key]
6701
+ };
6702
+ } } : {},
6703
+ readDeviceStore: async (deviceId) => resolveRead(`device:${deviceId}`, await raw.readDeviceStore(deviceId)),
6704
+ ...readDeviceStoreBatch !== void 0 ? { readDeviceStoreBatch: async (deviceIds) => {
6705
+ const rows = await readDeviceStoreBatch.call(raw, deviceIds);
6706
+ const out = /* @__PURE__ */ new Map();
6707
+ for (const [deviceId, blob] of rows) out.set(deviceId, await resolveRead(`device:${deviceId}`, blob));
6708
+ return out;
6709
+ } } : {},
6710
+ writeAddonStore: async (patch) => {
6711
+ await writeAddon(patch);
6712
+ },
6713
+ writeDeviceStore: async (deviceId, patch) => {
6714
+ await write(`device:${deviceId}`, opts.deviceTree(), {
6715
+ kind: "device",
6716
+ deviceId
6717
+ }, patch, () => raw.readDeviceStore(deviceId), (p) => raw.writeDeviceStore(deviceId, p));
6718
+ }
6719
+ };
6720
+ return {
6721
+ settings: new Proxy(raw, { get(target, prop, receiver) {
6722
+ if (typeof prop === "string" && Object.prototype.hasOwnProperty.call(overrides, prop)) return Reflect.get(overrides, prop);
6723
+ const value = Reflect.get(target, prop, receiver);
6724
+ return typeof value === "function" ? value.bind(target) : value;
6725
+ } }),
6726
+ raw: {
6727
+ readAddonStore: async () => {
6728
+ const blob = await raw.readAddonStore();
6729
+ index.seen("addon", blob);
6730
+ return blob;
6731
+ },
6732
+ readDeviceStore: async (deviceId) => {
6733
+ const blob = await raw.readDeviceStore(deviceId);
6734
+ index.seen(`device:${deviceId}`, blob);
6735
+ return blob;
6736
+ }
6737
+ },
6738
+ writeAddonStore: writeAddon
6739
+ };
6399
6740
  }
6400
- /** The context the addon sees: identical, except that its settings writes are secret-aware. */
6401
- function withSecretAwareSettings(context, opts) {
6741
+ /** The context the addon sees, plus the private raw view and write outcome. */
6742
+ function createSecretAwareContext(context, opts) {
6402
6743
  const raw = context.settings;
6403
- if (raw === void 0) return context;
6404
- const settings = createSecretAwareSettings(raw, opts);
6405
- return new Proxy(context, { get(target, prop, receiver) {
6406
- if (prop === "settings") return settings;
6407
- return Reflect.get(target, prop, receiver);
6408
- } });
6744
+ if (raw === void 0) return {
6745
+ context,
6746
+ handle: null
6747
+ };
6748
+ const handle = createHandle(raw, opts);
6749
+ return {
6750
+ context: new Proxy(context, { get(target, prop, receiver) {
6751
+ if (prop === "settings") return handle.settings;
6752
+ return Reflect.get(target, prop, receiver);
6753
+ } }),
6754
+ handle
6755
+ };
6409
6756
  }
6410
6757
  var LEAF = { kind: "leaf" };
6411
6758
  var DEFAULT_ITEM_ID_KEY = "id";
@@ -6580,6 +6927,14 @@ var BaseAddon = class {
6580
6927
  _secretChangeUnsub = null;
6581
6928
  /** >0 while an OPERATOR's settings write is being applied. */
6582
6929
  _operatorWriteDepth = 0;
6930
+ /**
6931
+ * The keychain-aware settings handle (D798). Its `raw` view is the ONLY way
6932
+ * to the marker-bearing blobs and stays private to this class: the form
6933
+ * hydrate and config resolution need markers, addon code never does.
6934
+ */
6935
+ _secretSettings = null;
6936
+ /** Refs an addon-facing read could not resolve — each is logged once per process. */
6937
+ _loggedUnresolvedReads = /* @__PURE__ */ new Set();
6583
6938
  constructor(defaults) {
6584
6939
  this.defaults = defaults;
6585
6940
  this._config = { ...defaults };
@@ -6616,13 +6971,21 @@ var BaseAddon = class {
6616
6971
  }
6617
6972
  async initialize(context) {
6618
6973
  const secrets = context.secrets;
6619
- this._ctx = secrets !== void 0 ? withSecretAwareSettings(context, {
6620
- secrets,
6621
- addonTree: () => this.addonSecretTree(),
6622
- deviceTree: () => this.deviceSecretTree(),
6623
- onOrphaned: (refs) => context.logger.warn("keychain refs dropped by a settings write could not be deleted", { meta: { refs: [...refs] } }),
6624
- isOperatorWrite: () => this._operatorWriteDepth > 0
6625
- }) : context;
6974
+ if (secrets !== void 0) {
6975
+ const { context: wrapped, handle } = createSecretAwareContext(context, {
6976
+ secrets,
6977
+ addonTree: () => this.addonSecretTree(),
6978
+ deviceTree: () => this.deviceSecretTree(),
6979
+ onOrphaned: (refs) => context.logger.warn("keychain refs dropped by a settings write could not be deleted", { meta: { refs: [...refs] } }),
6980
+ isOperatorWrite: () => this._operatorWriteDepth > 0,
6981
+ onUnresolved: (unresolved) => this.logUnresolvedRead(unresolved)
6982
+ });
6983
+ this._ctx = wrapped;
6984
+ this._secretSettings = handle;
6985
+ } else {
6986
+ this._ctx = context;
6987
+ this._secretSettings = null;
6988
+ }
6626
6989
  await this.resolveConfig();
6627
6990
  if (secrets !== void 0) this._secretChangeUnsub = secrets.onChange((ref) => {
6628
6991
  if (this._configSecretRefs.has(ref)) this.scheduleSecretReresolve(SECRET_CHANGE_DEBOUNCE_MS);
@@ -6739,11 +7102,8 @@ var BaseAddon = class {
6739
7102
  async getGlobalSettings(overlay, cap, nodeId) {
6740
7103
  const schema = this.globalSettingsSchema(cap);
6741
7104
  if (!schema) return { sections: [] };
6742
- const projected = await this.resolveGlobalStore(nodeId, cap);
6743
- return hydrateSchema(schema, overlay ? {
6744
- ...projected,
6745
- ...overlay
6746
- } : projected, { inlineSecretsAsViews: true });
7105
+ const projected = await this.readRawProjectedStore(nodeId, cap);
7106
+ return hydrateSchema(schema, overlay ? await this.overlayKeepingMarkers(projected, overlay) : projected, { inlineSecretsAsViews: true });
6747
7107
  }
6748
7108
  /**
6749
7109
  * The integration-level view of this addon's settings: exactly the sections
@@ -6788,7 +7148,7 @@ var BaseAddon = class {
6788
7148
  });
6789
7149
  }
6790
7150
  if (sections.length === 0) return null;
6791
- const projected = await this.resolveGlobalStore(nodeId);
7151
+ const projected = await this.readRawProjectedStore(nodeId);
6792
7152
  return hydrateSchema({
6793
7153
  ...schema,
6794
7154
  sections
@@ -6805,12 +7165,50 @@ var BaseAddon = class {
6805
7165
  * the store for custom option logic (option narrowing, value snapping) to
6806
7166
  * read it per-node — never `ctx.settings.readAddonStore()` directly.
6807
7167
  * `nodeId` omitted ⇒ the local node (node-blind injection from ctx).
7168
+ *
7169
+ * Keychain values come back RESOLVED (D798): a secret reads as its value,
7170
+ * never as a `{ $secret }` marker. One the keychain cannot serve right now
7171
+ * stays a marker — "stored, unavailable" (`isSecretMarker()` is true, and it
7172
+ * is listed in {@link unresolvedSecrets}) — never `''` and never absent, so
7173
+ * it cannot be mistaken for "nothing stored, mint a new one". Writing the
7174
+ * resolved blob back is a no-op for every unchanged secret.
6808
7175
  */
6809
7176
  async resolveGlobalStore(nodeId, cap) {
6810
7177
  const raw = await this._ctx?.settings?.readAddonStore() ?? {};
7178
+ return this.projectForNode(raw, nodeId, cap);
7179
+ }
7180
+ projectForNode(store, nodeId, cap) {
6811
7181
  const keys = this.perNodeKeys(cap);
6812
7182
  const node = normalizeNodeId(nodeId ?? this._ctx?.kernel?.localNodeId);
6813
- return keys.size > 0 ? projectStore(raw, keys, node) : raw;
7183
+ return keys.size > 0 ? projectStore(store, keys, node) : store;
7184
+ }
7185
+ /** The PROJECTED store with its markers — the form hydrate only (D798). */
7186
+ async readRawProjectedStore(nodeId, cap) {
7187
+ const raw = await this.rawSettings()?.readAddonStore() ?? {};
7188
+ return this.projectForNode(raw, nodeId, cap);
7189
+ }
7190
+ /**
7191
+ * `{ ...stored, ...overlay }`, except that an overlay member equal to the
7192
+ * RESOLVED stored one keeps the stored (marker-bearing) member — so a form
7193
+ * hydrated from a resolved overlay still shows a secret as "set", never as
7194
+ * its value.
7195
+ */
7196
+ async overlayKeepingMarkers(stored, overlay) {
7197
+ const secrets = this._ctx?.secrets;
7198
+ const merged = {
7199
+ ...stored,
7200
+ ...overlay
7201
+ };
7202
+ if (secrets === void 0 || collectSecretMarkerRefs(stored).length === 0) return merged;
7203
+ const { value: resolved } = await resolveSecretMarkers(stored, secrets, {
7204
+ unresolved: "keep-marker",
7205
+ ownedBy: secrets.owner
7206
+ });
7207
+ for (const key of Object.keys(overlay)) {
7208
+ if (collectSecretMarkerRefs(stored[key]).length === 0) continue;
7209
+ if (isJsonEqual(overlay[key], resolved[key])) merged[key] = stored[key];
7210
+ }
7211
+ return merged;
6814
7212
  }
6815
7213
  /**
6816
7214
  * Whether ONE global key of this addon's store was written, read three-way
@@ -6875,8 +7273,12 @@ var BaseAddon = class {
6875
7273
  async clearSecrets(keys, nodeId) {
6876
7274
  const tree = this.addonSecretTree();
6877
7275
  const keychain = this._ctx?.secrets !== void 0;
7276
+ const stored = keychain ? await this.readAddonStoreWithRetry() : {};
6878
7277
  const patch = {};
6879
- for (const key of keys) patch[key] = keychain && tree.has(key) ? SECRET_CLEAR : "";
7278
+ for (const key of keys) {
7279
+ const keychainStored = tree.has(key) || collectSecretMarkerRefs(stored[key]).length > 0;
7280
+ patch[key] = keychain && keychainStored ? SECRET_CLEAR : "";
7281
+ }
6880
7282
  await this.applyGlobalPatch(patch, nodeId);
6881
7283
  }
6882
7284
  async applyGlobalPatch(barePatch, nodeId) {
@@ -6884,7 +7286,11 @@ var BaseAddon = class {
6884
7286
  const localNode = normalizeNodeId(this._ctx?.kernel?.localNodeId);
6885
7287
  const target = normalizeNodeId(nodeId ?? this._ctx?.kernel?.localNodeId);
6886
7288
  const scoped = keys.size > 0 ? scopePatch(barePatch, keys, target) : barePatch;
6887
- await this._ctx?.settings?.writeAddonStore(scoped);
7289
+ const handle = this._secretSettings;
7290
+ if (handle !== null) {
7291
+ const { changed } = await handle.writeAddonStore(scoped);
7292
+ if (!changed) return;
7293
+ } else await this._ctx?.settings?.writeAddonStore(scoped);
6888
7294
  if (target !== localNode) return;
6889
7295
  await this.resolveConfig();
6890
7296
  await this.onConfigChanged();
@@ -6937,7 +7343,7 @@ var BaseAddon = class {
6937
7343
  async getDeviceSettings(deviceId) {
6938
7344
  const schema = this.deviceSettingsSchema();
6939
7345
  if (!schema) return { sections: [] };
6940
- return hydrateSchema(schema, await this._ctx?.settings?.readDeviceStore(deviceId) ?? {}, { inlineSecretsAsViews: true });
7346
+ return hydrateSchema(schema, await this.rawSettings()?.readDeviceStore(deviceId) ?? {}, { inlineSecretsAsViews: true });
6941
7347
  }
6942
7348
  async updateDeviceSettings(deviceId, patch) {
6943
7349
  await this._ctx?.settings?.writeDeviceStore(deviceId, patch);
@@ -7109,7 +7515,7 @@ var BaseAddon = class {
7109
7515
  key,
7110
7516
  schema,
7111
7517
  fallback,
7112
- read: async () => this.resolveStoredSecrets(await this._ctx?.settings?.readDeviceStore(deviceId) ?? {}, false),
7518
+ read: async () => this.resolveStoredSecrets(await this.rawSettings()?.readDeviceStore(deviceId) ?? {}, false),
7113
7519
  write: async (patch) => {
7114
7520
  await this._ctx?.settings?.writeDeviceStore(deviceId, patch);
7115
7521
  },
@@ -7171,6 +7577,23 @@ var BaseAddon = class {
7171
7577
  }
7172
7578
  return value;
7173
7579
  }
7580
+ /**
7581
+ * The marker-bearing settings reads (D798) — private on purpose. Without a
7582
+ * keychain the context's own view is already raw.
7583
+ */
7584
+ rawSettings() {
7585
+ return this._secretSettings?.raw ?? this._ctx?.settings;
7586
+ }
7587
+ /** An addon-facing read met markers it could not resolve: say so once per ref. */
7588
+ logUnresolvedRead(unresolved) {
7589
+ const fresh = unresolved.filter((u) => !this._loggedUnresolvedReads.has(u.ref));
7590
+ if (fresh.length === 0) return;
7591
+ for (const u of fresh) this._loggedUnresolvedReads.add(u.ref);
7592
+ 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) => ({
7593
+ ref: u.ref,
7594
+ reason: u.reason
7595
+ })) } });
7596
+ }
7174
7597
  /** Re-resolve the config (a keychain-only change, or a retry) and apply it. */
7175
7598
  scheduleSecretReresolve(delayMs) {
7176
7599
  const timerOf = delayMs === SECRET_CHANGE_DEBOUNCE_MS ? "_secretChangeTimer" : "_secretRetryTimer";
@@ -7197,7 +7620,7 @@ var BaseAddon = class {
7197
7620
  * `{}` (defaults) — the addon's first successful patch will rehydrate.
7198
7621
  */
7199
7622
  async readAddonStoreWithRetry() {
7200
- const settings = this._ctx?.settings;
7623
+ const settings = this.rawSettings();
7201
7624
  if (!settings) return {};
7202
7625
  const delaysMs = [
7203
7626
  150,
@@ -10157,6 +10580,278 @@ var CameraSwitchGroupSchema = object({
10157
10580
  fetchedAt: number()
10158
10581
  });
10159
10582
  /**
10583
+ * The trainer contract — what the hub hands the cloud trainer and what it
10584
+ * gets back (cloud training, D805+).
10585
+ *
10586
+ * The trainer (`hf/camstack-trainer`, published as the Hugging Face repo
10587
+ * `camstack/camstack-trainer`) is a separate AGPL program the hub never
10588
+ * imports: `job.json` goes in, files come out, and progress is `CAMSTACK_EVENT`
10589
+ * lines on stdout. These schemas are the hub's half of that boundary; the
10590
+ * trainer's pydantic models (and the JSON Schemas generated from them under
10591
+ * `hf/camstack-trainer/schemas/`) are the other half. A change here is a
10592
+ * change there, in the same piece of work.
10593
+ *
10594
+ * No `.default()` anywhere: defaults do not run on the addon cap path, so the
10595
+ * orchestrator fills every field of a job spec explicitly.
10596
+ */
10597
+ var TRAINING_JOB_SCHEMA = "camstack.training/v1";
10598
+ var TRAINING_RESULT_SCHEMA = "camstack.training-result/v1";
10599
+ /** What the trainer can export. Edge TPU is a later, separate image. */
10600
+ var TrainingExportSchema = _enum([
10601
+ "onnx",
10602
+ "openvino-fp16",
10603
+ "openvino-int8",
10604
+ "coreml-fp16"
10605
+ ]);
10606
+ var FloorsSchema = record(string(), number().min(0).max(1));
10607
+ object({
10608
+ schema: literal(TRAINING_JOB_SCHEMA),
10609
+ jobKey: string().uuid(),
10610
+ target: object({
10611
+ kind: literal("detector"),
10612
+ step: literal("object-detection")
10613
+ }),
10614
+ base: object({
10615
+ modelId: string().min(1),
10616
+ /** Ultralytics weights id, e.g. `yolov9m.pt`. */
10617
+ weights: string().min(1),
10618
+ imgsz: number().int().positive()
10619
+ }),
10620
+ baseline: object({
10621
+ modelId: string().min(1),
10622
+ /** The baseline ONNX the holdout comparison runs; public mirror URL. */
10623
+ onnxUrl: string().url(),
10624
+ imgsz: number().int().positive(),
10625
+ floors: FloorsSchema
10626
+ }),
10627
+ dataset: object({
10628
+ versionId: string().min(1),
10629
+ annotationHash: string(),
10630
+ /** sha256 of the uploaded archive; the trainer refuses a mismatch (exit 65). */
10631
+ sha256: string().regex(/^[0-9a-f]{64}$/)
10632
+ }),
10633
+ split: object({
10634
+ holdoutCameras: array(number().int()),
10635
+ /** When no camera is held out: the last N days of every camera. */
10636
+ holdoutLastDays: number().int().nonnegative(),
10637
+ valFraction: number().min(0).max(.5),
10638
+ seed: number().int()
10639
+ }),
10640
+ hyper: object({
10641
+ epochs: number().int().positive(),
10642
+ batch: number().int().positive(),
10643
+ lr0: number().positive(),
10644
+ /** Layers frozen from the start of the backbone; 0 = none. */
10645
+ freeze: number().int().nonnegative(),
10646
+ patience: number().int().nonnegative(),
10647
+ seed: number().int()
10648
+ }),
10649
+ replay: object({
10650
+ source: literal("coco2017"),
10651
+ count: number().int().nonnegative()
10652
+ }),
10653
+ exports: array(TrainingExportSchema).min(1),
10654
+ calibration: object({ maxFrames: number().int().positive() }),
10655
+ floors: object({
10656
+ minSupport: number().int().positive(),
10657
+ clamp: number().min(0).max(1)
10658
+ }),
10659
+ int8Gate: object({ maxMap50Drop: number().min(0).max(1) }),
10660
+ catalog: object({
10661
+ id: string().regex(/^[a-z0-9][a-z0-9-]{2,80}$/),
10662
+ name: string().min(1).max(160)
10663
+ })
10664
+ });
10665
+ /** One regular file of the bundle. An mlpackage contributes one row per member. */
10666
+ var TrainingResultFileSchema = object({
10667
+ path: string().min(1),
10668
+ bytes: number().int().nonnegative(),
10669
+ sha256: string().regex(/^[0-9a-f]{64}$/),
10670
+ format: _enum([
10671
+ "onnx",
10672
+ "openvino",
10673
+ "coreml",
10674
+ "pt"
10675
+ ]),
10676
+ variant: _enum(["base", "int8"])
10677
+ });
10678
+ var DraftFormatSchema = object({
10679
+ /** RELATIVE path inside the bundle; the hub rewrites it to `camstack-local://`. */
10680
+ url: string().min(1),
10681
+ sizeMB: number().nonnegative(),
10682
+ isDirectory: boolean().optional(),
10683
+ files: array(string()).optional(),
10684
+ runtimes: array(literal("python")).optional(),
10685
+ revision: string().min(1)
10686
+ });
10687
+ /** The trainer's half of a catalog entry; the hub completes it (labels, licence, group). */
10688
+ var TrainingCatalogDraftSchema = object({
10689
+ id: string().min(1),
10690
+ name: string().min(1),
10691
+ description: string(),
10692
+ labels: array(unknown()),
10693
+ inputSize: object({
10694
+ width: number().int().positive(),
10695
+ height: number().int().positive()
10696
+ }),
10697
+ preprocessMode: literal("letterbox"),
10698
+ defaultClassFloors: FloorsSchema,
10699
+ formats: object({
10700
+ onnx: DraftFormatSchema.optional(),
10701
+ openvino: DraftFormatSchema.optional(),
10702
+ coreml: DraftFormatSchema.optional()
10703
+ })
10704
+ });
10705
+ /** One class of one model's holdout report (the eval harness's summary). */
10706
+ var TrainingEvalClassSchema = object({
10707
+ positives: number().int(),
10708
+ floor: number().nullable(),
10709
+ tp: number().int(),
10710
+ fp: number().int(),
10711
+ fn: number().int(),
10712
+ precision: number().nullable(),
10713
+ recall: number().nullable(),
10714
+ ap50: number().nullable(),
10715
+ recallByCamera: record(string(), number().nullable()).optional(),
10716
+ recallByLight: record(string(), number().nullable()).optional(),
10717
+ fpByCamera: record(string(), number()).optional(),
10718
+ smallFound: number().int().optional(),
10719
+ smallTotal: number().int().optional()
10720
+ }).passthrough();
10721
+ var TrainingEvalReportSchema = object({
10722
+ frames: number().int(),
10723
+ classes: record(string(), TrainingEvalClassSchema)
10724
+ }).passthrough();
10725
+ /**
10726
+ * A succeeded result carries every block; a failed one carries the error and
10727
+ * whatever was known by then — the other blocks are ABSENT, not null. The
10728
+ * orchestrator checks the blocks it needs before it trusts a success.
10729
+ */
10730
+ var TrainingResultSchema = object({
10731
+ schema: literal(TRAINING_RESULT_SCHEMA),
10732
+ jobKey: string(),
10733
+ status: _enum(["succeeded", "failed"]),
10734
+ error: object({
10735
+ stage: string(),
10736
+ code: string(),
10737
+ message: string()
10738
+ }).nullable(),
10739
+ trainer: object({
10740
+ version: string(),
10741
+ revision: string()
10742
+ }),
10743
+ toolchain: record(string(), string().nullable()),
10744
+ dataset: object({
10745
+ versionId: string(),
10746
+ annotationHash: string(),
10747
+ sha256: string(),
10748
+ frames: object({
10749
+ train: number().int(),
10750
+ val: number().int(),
10751
+ holdout: number().int()
10752
+ }),
10753
+ holdoutCameras: array(number().int()),
10754
+ replayImages: number().int()
10755
+ }).optional(),
10756
+ training: object({
10757
+ epochsRun: number().int(),
10758
+ bestEpoch: number().int(),
10759
+ bestMap50: number(),
10760
+ bestMap50_95: number(),
10761
+ seconds: number()
10762
+ }).optional(),
10763
+ evaluation: object({
10764
+ holdoutFrames: number().int(),
10765
+ baseline: TrainingEvalReportSchema.nullable(),
10766
+ candidate: TrainingEvalReportSchema.nullable(),
10767
+ candidateInt8: TrainingEvalReportSchema.nullable(),
10768
+ recallDeltaByCamera: record(string(), record(string(), number())).nullable(),
10769
+ map50: record(string(), number().nullable())
10770
+ }).optional(),
10771
+ floors: object({
10772
+ baseline: FloorsSchema,
10773
+ candidate: FloorsSchema,
10774
+ candidateInt8: FloorsSchema.nullable(),
10775
+ notes: array(string())
10776
+ }).optional(),
10777
+ int8: object({
10778
+ kept: boolean(),
10779
+ map50Fp16: number().nullable(),
10780
+ map50Int8: number().nullable(),
10781
+ reason: string().nullable()
10782
+ }).optional(),
10783
+ exportsDropped: array(object({
10784
+ export: string(),
10785
+ reason: string()
10786
+ })).optional(),
10787
+ files: array(TrainingResultFileSchema).optional(),
10788
+ bundle: object({
10789
+ path: literal("bundle.tar"),
10790
+ bytes: number().int().nonnegative(),
10791
+ sha256: string().regex(/^[0-9a-f]{64}$/)
10792
+ }).nullable().optional(),
10793
+ catalogDraft: object({
10794
+ base: TrainingCatalogDraftSchema,
10795
+ int8: TrainingCatalogDraftSchema.nullable()
10796
+ }).nullable().optional(),
10797
+ licence: string()
10798
+ });
10799
+ var TrainingStageSchema = _enum([
10800
+ "prepare",
10801
+ "replay",
10802
+ "train",
10803
+ "eval",
10804
+ "export",
10805
+ "package"
10806
+ ]);
10807
+ var EventBase = {
10808
+ v: literal(1),
10809
+ ts: number()
10810
+ };
10811
+ discriminatedUnion("type", [
10812
+ object({
10813
+ ...EventBase,
10814
+ type: literal("stage"),
10815
+ stage: TrainingStageSchema
10816
+ }),
10817
+ object({
10818
+ ...EventBase,
10819
+ type: literal("epoch"),
10820
+ epoch: number().int(),
10821
+ epochs: number().int(),
10822
+ boxLoss: number().nullable().optional(),
10823
+ map50: number().nullable().optional(),
10824
+ map50_95: number().nullable().optional(),
10825
+ etaSec: number().nullable().optional()
10826
+ }),
10827
+ object({
10828
+ ...EventBase,
10829
+ type: literal("metric"),
10830
+ name: string(),
10831
+ value: number()
10832
+ }),
10833
+ object({
10834
+ ...EventBase,
10835
+ type: literal("artifact"),
10836
+ path: string(),
10837
+ bytes: number(),
10838
+ sha256: string()
10839
+ }),
10840
+ object({
10841
+ ...EventBase,
10842
+ type: literal("done"),
10843
+ status: _enum(["succeeded", "failed"]),
10844
+ resultSha256: string().nullable().optional()
10845
+ }),
10846
+ object({
10847
+ ...EventBase,
10848
+ type: literal("error"),
10849
+ stage: string(),
10850
+ code: string(),
10851
+ message: string()
10852
+ })
10853
+ ]);
10854
+ /**
10160
10855
  * What the gate decided about a birth, from the CALLER's point of view.
10161
10856
  *
10162
10857
  * Deliberately not `ConfirmationVerdict`: `undecided` is not a birth decision
@@ -12638,7 +13333,9 @@ var AddonHttpRouteSchema = object({
12638
13333
  "authenticated",
12639
13334
  "admin"
12640
13335
  ]).optional(),
12641
- description: string().optional()
13336
+ description: string().optional(),
13337
+ /** The hub limits this route per client address before the handler runs. */
13338
+ rateLimit: _enum(["auth"]).optional()
12642
13339
  });
12643
13340
  /**
12644
13341
  * Cross-process route invocation envelope. The hub captures the
@@ -13343,6 +14040,37 @@ var BackupDestinationInfoSchema = object({
13343
14040
  lastError: string().optional()
13344
14041
  });
13345
14042
  /**
14043
+ * How an archive is encrypted (operator decision 2026-10-09): to a backup
14044
+ * PUBLIC key the hub holds, so only the operator's secret key opens it.
14045
+ * Absent on a plain `.tar.gz` — every archive made before encryption, or
14046
+ * with it off — which restores without a key.
14047
+ */
14048
+ var BackupArchiveEncryptionSchema = object({
14049
+ /** `x25519-hkdf-aes256gcm-stream-v1`. */
14050
+ scheme: string(),
14051
+ /** 16 hex — the backup key whose secret restores this archive. */
14052
+ keyId: string()
14053
+ });
14054
+ /**
14055
+ * The backup encryption setting. The hub keeps PUBLIC keys only: the active
14056
+ * one new archives are encrypted to, and the retired ones older archives
14057
+ * still need. The secret key is shown once, at `setupEncryption`.
14058
+ */
14059
+ var BackupEncryptionStatusSchema = object({
14060
+ enabled: boolean(),
14061
+ active: object({
14062
+ keyId: string(),
14063
+ publicKey: string(),
14064
+ createdAt: number()
14065
+ }).nullable(),
14066
+ /** Every key ever set up, newest first. */
14067
+ keys: array(object({
14068
+ keyId: string(),
14069
+ createdAt: number(),
14070
+ retiredAt: number().nullable()
14071
+ })).readonly()
14072
+ });
14073
+ /**
13346
14074
  * Per-archive entry returned by `backup.listArchives({ destinationId })`.
13347
14075
  * Same shape the destination drill-in renders. Sourced from the per-
13348
14076
  * location `manifests.json` (no per-archive tarball read required).
@@ -13354,7 +14082,9 @@ var BackupArchiveEntrySchema = object({
13354
14082
  sizeBytes: number(),
13355
14083
  label: string().optional(),
13356
14084
  /** Top-level locations included in the archive (db, addons, tls, …). */
13357
- locations: array(string()).readonly()
14085
+ locations: array(string()).readonly(),
14086
+ /** Present when the archive is encrypted; restore then needs that key. */
14087
+ encryption: BackupArchiveEncryptionSchema.optional()
13358
14088
  });
13359
14089
  var BackupEntrySchema = object({
13360
14090
  id: string(),
@@ -13363,7 +14093,8 @@ var BackupEntrySchema = object({
13363
14093
  label: string().optional(),
13364
14094
  createdAt: number(),
13365
14095
  sizeBytes: number(),
13366
- locations: array(string()).optional()
14096
+ locations: array(string()).optional(),
14097
+ encryption: BackupArchiveEncryptionSchema.optional()
13367
14098
  });
13368
14099
  var ArchiveEntrySchema = object({
13369
14100
  path: string(),
@@ -13552,10 +14283,40 @@ method(_void(), array(BackupDestinationInfoSchema).readonly(), { auth: "admin" }
13552
14283
  * this list and skips entries whose path doesn't start with
13553
14284
  * any of them.
13554
14285
  */
13555
- locations: array(string()).optional()
14286
+ locations: array(string()).optional(),
14287
+ /**
14288
+ * The backup SECRET key, for an encrypted archive (ignored for a plain
14289
+ * one). The archive is decrypted into the hub's private staging
14290
+ * before the restart; the key is not stored. A wrong or missing key
14291
+ * is refused before the archive is downloaded.
14292
+ */
14293
+ backupSecretKey: string().optional()
13556
14294
  }), _void(), {
13557
14295
  kind: "mutation",
13558
14296
  auth: "admin"
14297
+ }), method(_void(), BackupEncryptionStatusSchema, { auth: "admin" }), method(object({}), object({
14298
+ keyId: string(),
14299
+ secretKey: string(),
14300
+ publicKey: string(),
14301
+ createdAt: number(),
14302
+ replacedKeyId: string().nullable()
14303
+ }), {
14304
+ kind: "mutation",
14305
+ auth: "admin"
14306
+ }), method(object({}), object({ disabledKeyId: string().nullable() }), {
14307
+ kind: "mutation",
14308
+ auth: "admin"
14309
+ }), method(object({ backupSecretKey: string() }), object({
14310
+ valid: boolean(),
14311
+ keyId: string().nullable(),
14312
+ /** The hub knows this key (active or retired). */
14313
+ known: boolean(),
14314
+ /** It is the key new archives are encrypted to. */
14315
+ active: boolean(),
14316
+ error: string().optional()
14317
+ }), {
14318
+ kind: "mutation",
14319
+ auth: "admin"
13559
14320
  }), method(object({
13560
14321
  destinationId: string(),
13561
14322
  backupId: string()
@@ -15179,7 +15940,60 @@ var CustomModelDescriptorSchema = object({
15179
15940
  stepId: string(),
15180
15941
  entry: ModelCatalogEntrySchema
15181
15942
  });
15182
- method(_void(), array(CustomModelDescriptorSchema).readonly(), { auth: "admin" });
15943
+ /** One regular file of an imported bundle, as the producer measured it. */
15944
+ var ModelBundleFileSchema = object({
15945
+ /** Relative path inside the bundle tar; an mlpackage member is `<x>.mlpackage/<member>`. */
15946
+ path: string().min(1),
15947
+ bytes: number().int().nonnegative(),
15948
+ sha256: string().regex(/^[0-9a-f]{64}$/)
15949
+ });
15950
+ var ImportModelBundleInputSchema = object({
15951
+ /** The registry provider that keeps the model (Model Studio). */
15952
+ addonId: string(),
15953
+ stepId: string().min(1),
15954
+ /**
15955
+ * The catalog rows to register, complete, every format URL already
15956
+ * `camstack-local://<modelId>/<file>` naming a file of the bundle. One
15957
+ * bundle may carry several rows (a base and its INT8 variant).
15958
+ */
15959
+ entries: array(ModelCatalogEntrySchema).min(1).max(4),
15960
+ /** The bundle tar, offered by the producer over `ctx.peerBytes` (same host). */
15961
+ bundle: object({
15962
+ ticket: PeerBytesTicketSchema,
15963
+ bytes: number().int().positive(),
15964
+ sha256: string().regex(/^[0-9a-f]{64}$/)
15965
+ }),
15966
+ /** Every file the tar must hold; anything missing, extra or different is refused. */
15967
+ files: array(ModelBundleFileSchema).min(1).max(64),
15968
+ /** Convert missing engine formats and push the model to every agent afterwards. */
15969
+ distribute: boolean()
15970
+ });
15971
+ var ImportModelBundleResultSchema = discriminatedUnion("kind", [object({
15972
+ kind: literal("imported"),
15973
+ modelIds: array(string()).readonly(),
15974
+ distributed: array(object({
15975
+ modelId: string(),
15976
+ nodeId: string(),
15977
+ format: _enum(MODEL_FORMATS),
15978
+ ok: boolean(),
15979
+ error: string().optional()
15980
+ })).readonly()
15981
+ }), object({
15982
+ kind: literal("refused"),
15983
+ reason: _enum([
15984
+ "transfer-failed",
15985
+ "checksum-mismatch",
15986
+ "bundle-mismatch",
15987
+ "invalid-entry",
15988
+ "id-taken"
15989
+ ]),
15990
+ detail: string()
15991
+ })]);
15992
+ method(_void(), array(CustomModelDescriptorSchema).readonly(), { auth: "admin" }), method(ImportModelBundleInputSchema, ImportModelBundleResultSchema, {
15993
+ kind: "mutation",
15994
+ auth: "admin",
15995
+ timeoutMs: 30 * 6e4
15996
+ });
15183
15997
  /**
15184
15998
  * Query filter for settings-store collections.
15185
15999
  */
@@ -15658,6 +16472,35 @@ var KeychainKeySourceSchema = object({
15658
16472
  */
15659
16473
  sharesBackupWithDatabase: boolean()
15660
16474
  });
16475
+ /**
16476
+ * One keychain reset, as the Secrets page reports it until the operator
16477
+ * acknowledges it. Never a value: refs, counts and table names only.
16478
+ */
16479
+ var KeychainResetRecordSchema = object({
16480
+ id: string(),
16481
+ at: number(),
16482
+ /** `user:<id>` or {@link KEYCHAIN_RESET_TRIGGER_ACTOR}. */
16483
+ actor: string(),
16484
+ /** Why the keychain was locked when it was reset; `null` when it was not locked. */
16485
+ lockedReason: string().nullable(),
16486
+ /** Values moved into the archive table (ciphertext under the lost key). */
16487
+ archived: number().int(),
16488
+ /** `keychain:secrets-orphaned-<ts>`, or `null` when nothing was stored. */
16489
+ archivedCollection: string().nullable(),
16490
+ /**
16491
+ * `keychain:keys-orphaned-<ts>`: the wrapped data keys of the archive, kept
16492
+ * so the archive can still be opened if the lost master key turns up.
16493
+ */
16494
+ archivedKeysCollection: string().nullable(),
16495
+ /**
16496
+ * `system-settings` keys whose marker the reset cleared — the cluster
16497
+ * secret's: a marker left pointing at an archived value would refuse every
16498
+ * agent forever (D797).
16499
+ */
16500
+ clearedSettingsKeys: array(string()).readonly(),
16501
+ /** When an operator dismissed the notice on the Secrets page; `null` until then. */
16502
+ acknowledgedAt: number().nullable()
16503
+ });
15661
16504
  var KeychainStatusSchema = object({
15662
16505
  keychain: KeychainStateSchema,
15663
16506
  /** The source of the master key in use; `null` while locked. */
@@ -15675,7 +16518,9 @@ var KeychainStatusSchema = object({
15675
16518
  /** Wrapped copies of the data key under a previous master key, kept until purged. */
15676
16519
  retiredWraps: number().int(),
15677
16520
  recoveryKeyDownloadedAt: number().nullable(),
15678
- secretCount: number().int()
16521
+ secretCount: number().int(),
16522
+ /** The most recent reset, acknowledged or not; `null` when the keychain was never reset. */
16523
+ lastReset: KeychainResetRecordSchema.nullable()
15679
16524
  });
15680
16525
  /**
15681
16526
  * Whether a stored value is still pointed at by its owner's settings.
@@ -15697,17 +16542,26 @@ var KeychainAuditActionSchema = _enum([
15697
16542
  "download-recovery-key",
15698
16543
  "delete-orphans",
15699
16544
  "reset",
16545
+ "acknowledge-reset",
15700
16546
  "initialize"
15701
16547
  ]);
15702
16548
  var KeychainAuditEntrySchema = object({
15703
16549
  id: string(),
15704
16550
  at: number(),
15705
16551
  action: KeychainAuditActionSchema,
15706
- /** `addon:<id>` | `user:<id>` | `system`. */
16552
+ /** `addon:<id>` | `user:<id>` | `system` | `trigger-file`. */
15707
16553
  actor: string(),
15708
16554
  ref: string().nullable(),
15709
16555
  detail: string().nullable()
15710
16556
  });
16557
+ var KEYCHAIN_RESET_CONFIRMATION = "RESET KEYCHAIN";
16558
+ /**
16559
+ * Secrets the HUB itself holds (owner `system`) that no settings form shows:
16560
+ * `jwt-signing-key` — the session signing key (D797). It is always "in use",
16561
+ * never an orphan; it is generated on a fresh hub and replaced only through
16562
+ * {@link keychainAdminCapability.methods.setSystemSecret}.
16563
+ */
16564
+ var SystemHeldSecretNameSchema = _enum(["jwt-signing-key"]);
15711
16565
  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({
15712
16566
  value: string(),
15713
16567
  version: number().int()
@@ -15715,6 +16569,16 @@ method(object({}), KeychainStatusSchema, { auth: "admin" }), method(object({}),
15715
16569
  kind: "mutation",
15716
16570
  auth: "admin",
15717
16571
  caller: "required"
16572
+ }), method(object({
16573
+ name: SystemHeldSecretNameSchema,
16574
+ value: string().min(16)
16575
+ }), object({
16576
+ ref: string(),
16577
+ version: number().int()
16578
+ }), {
16579
+ kind: "mutation",
16580
+ auth: "admin",
16581
+ caller: "required"
15718
16582
  }), method(object({ refs: array(string().min(1)).max(1e3) }), object({
15719
16583
  deleted: array(string()).readonly(),
15720
16584
  kept: array(object({
@@ -15744,13 +16608,20 @@ method(object({}), KeychainStatusSchema, { auth: "admin" }), method(object({}),
15744
16608
  kind: "mutation",
15745
16609
  auth: "admin",
15746
16610
  caller: "required"
15747
- }), method(object({ confirm: literal("RESET KEYCHAIN") }), object({
16611
+ }), method(object({ confirm: literal(KEYCHAIN_RESET_CONFIRMATION) }), object({
15748
16612
  archivedCollection: string().nullable(),
15749
16613
  archived: number().int()
15750
16614
  }), {
15751
16615
  kind: "mutation",
15752
16616
  auth: "admin",
15753
16617
  caller: "required"
16618
+ }), method(object({}), object({
16619
+ reset: KeychainResetRecordSchema.nullable(),
16620
+ pendingReentry: array(KeychainSecretMetaSchema).readonly()
16621
+ }), { auth: "admin" }), method(object({}), object({ acknowledged: boolean() }), {
16622
+ kind: "mutation",
16623
+ auth: "admin",
16624
+ caller: "required"
15754
16625
  });
15755
16626
  /**
15756
16627
  * Stable UI option list for the `hwaccel` setting. Decoder addons
@@ -18477,7 +19348,7 @@ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
18477
19348
  * `login-method` — collection cap through which auth addons contribute
18478
19349
  * their pre-auth login surfaces to the login page. This is the SINGLE,
18479
19350
  * generic mechanism that supersedes the dead `auth.listProviders` reader:
18480
- * every auth addon (OIDC, magic-link, WebAuthn/passkey) registers a
19351
+ * every auth addon (OIDC, WebAuthn/passkey) registers a
18481
19352
  * `login-method` provider and the PUBLIC `auth.listLoginMethods`
18482
19353
  * procedure aggregates them for the unauthenticated login page.
18483
19354
  *
@@ -18485,8 +19356,7 @@ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
18485
19356
  *
18486
19357
  * - `redirect` — a declarative button. The login page renders a generic
18487
19358
  * button that navigates to `startUrl` (an addon-owned HTTP route).
18488
- * Covers OIDC (`/addon/auth-oidc/<id>/start`) and magic-link with
18489
- * ZERO shell-side JS. A future SSO addon plugs in the same way — the
19359
+ * Covers OIDC (`/addon/auth-oidc/<id>/start`) with ZERO shell-side JS. A future SSO addon plugs in the same way — the
18490
19360
  * login page needs NO change.
18491
19361
  *
18492
19362
  * - `widget` — a Module-Federation widget the login page mounts (via
@@ -18505,8 +19375,8 @@ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
18505
19375
  * decision.
18506
19376
  *
18507
19377
  * Every contribution carries a `stage`:
18508
- * - `primary` — shown on the first credentials screen (OIDC /
18509
- * magic-link buttons; a future usernameless passkey).
19378
+ * - `primary` — shown on the first credentials screen (OIDC
19379
+ * buttons; a usernameless passkey).
18510
19380
  * - `second-factor` — shown AFTER the password leg, gated on the
18511
19381
  * returned `factors` (passkey-as-2FA today).
18512
19382
  *
@@ -18533,7 +19403,7 @@ var LoginMethodContributionSchema = discriminatedUnion("kind", [
18533
19403
  * The provider names an external identity a signed-in user can link to
18534
19404
  * their own account (D782): `auth.listLinkableProviders` /
18535
19405
  * `beginExternalLink` offer exactly the redirect methods that set this,
18536
- * whatever their id. Absent / false — a login button only (magic-link).
19406
+ * whatever their id. Absent / false — a login button only.
18537
19407
  */
18538
19408
  linkable: boolean().optional()
18539
19409
  }),
@@ -22350,8 +23220,7 @@ method(object({}), object({ rules: array(NcRuleSchema) }), { auth: "admin" }), m
22350
23220
  * `super_admin` — collapsed onto the single boolean because every
22351
23221
  * non-admin caller is governed by the same scope-check rules; the
22352
23222
  * distinction was only ever used to route role-specific procedures
22353
- * which we no longer have. Agents are admin sessions issued via
22354
- * `createServiceToken`; CLI / webhook integrations are `cst_*` tokens
23223
+ * which we no longer have. CLI / webhook integrations are `cst_*` tokens
22355
23224
  * with `isAdmin: false` + an explicit scope list.
22356
23225
  */
22357
23226
  /** Per-method access flavour. Materialised on every cap method via codegen. */
@@ -24026,6 +24895,9 @@ var RetrainExportFilterSchema = object({
24026
24895
  frameIds: array(string()).max(2e4).optional(),
24027
24896
  /** Only frames in at least one of these named collections. */
24028
24897
  collectionIds: array(string()).max(200).optional(),
24898
+ /** Exactly the frames of this dataset version (and its completeOnly). An
24899
+ * unknown id selects nothing. */
24900
+ datasetVersionId: string().optional(),
24029
24901
  batchId: string().optional(),
24030
24902
  /** Only frames the operator marked complete (all subjects boxed). */
24031
24903
  completeOnly: boolean().optional()
@@ -24193,6 +25065,67 @@ var RetrainLlmAssistResultSchema = discriminatedUnion("kind", [object({
24193
25065
  ]),
24194
25066
  detail: string().optional()
24195
25067
  })]);
25068
+ /** What a dataset version is cut from. Every field narrows. */
25069
+ var RetrainDatasetSelectionSchema = object({
25070
+ deviceIds: array(number()).readonly().optional(),
25071
+ collectionIds: array(string()).max(200).readonly().optional(),
25072
+ frameIds: array(string()).max(2e4).readonly().optional()
25073
+ });
25074
+ /** The counts a dataset is judged by. */
25075
+ var RetrainDatasetStatsSchema = object({
25076
+ frames: number().int(),
25077
+ completeFrames: number().int(),
25078
+ /** `completeFrames / frames`, 0..1. */
25079
+ completeness: number(),
25080
+ /** Boxes to learn (model errors excluded). */
25081
+ subjects: number().int(),
25082
+ modelErrors: number().int(),
25083
+ /** Complete frames with no subject. */
25084
+ hardNegatives: number().int(),
25085
+ /** Subjects per class × camera × day/night. */
25086
+ cells: array(object({
25087
+ macroClass: string(),
25088
+ deviceId: number(),
25089
+ lighting: _enum([
25090
+ "day",
25091
+ "night",
25092
+ "unknown"
25093
+ ]),
25094
+ subjects: number().int(),
25095
+ frames: number().int()
25096
+ })).readonly(),
25097
+ cameras: array(object({
25098
+ deviceId: number(),
25099
+ frames: number().int(),
25100
+ completeFrames: number().int()
25101
+ })).readonly()
25102
+ });
25103
+ /** An immutable dataset version, without its frame list. */
25104
+ var RetrainDatasetVersionSchema = object({
25105
+ id: string(),
25106
+ name: string(),
25107
+ createdAt: number(),
25108
+ selection: RetrainDatasetSelectionSchema,
25109
+ layout: RetrainExportLayoutSchema,
25110
+ completeOnly: boolean(),
25111
+ frameCount: number().int(),
25112
+ /** sha256 of what the frames taught when the version was frozen. */
25113
+ annotationHash: string(),
25114
+ /** The export manifest schema the version was cut under. */
25115
+ manifestSchema: string(),
25116
+ stats: RetrainDatasetStatsSchema
25117
+ });
25118
+ var CreateRetrainDatasetVersionResultSchema = discriminatedUnion("kind", [object({
25119
+ kind: literal("created"),
25120
+ version: RetrainDatasetVersionSchema
25121
+ }), object({
25122
+ kind: literal("refused"),
25123
+ reason: _enum([
25124
+ "empty-name",
25125
+ "duplicate-name",
25126
+ "no-frames"
25127
+ ])
25128
+ })]);
24196
25129
  /** The outcome of a lifecycle move owned by the retrain page. */
24197
25130
  var RetrainTransitionResultSchema = object({
24198
25131
  trackId: string(),
@@ -24982,6 +25915,47 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
24982
25915
  kind: "mutation",
24983
25916
  auth: "admin",
24984
25917
  timeoutMs: 60 * 6e4
25918
+ }), method(object({
25919
+ filter: RetrainExportFilterSchema,
25920
+ layout: RetrainExportLayoutSchema
25921
+ }), object({
25922
+ ticket: PeerBytesTicketSchema,
25923
+ frames: number().int(),
25924
+ annotations: number().int()
25925
+ }), {
25926
+ kind: "mutation",
25927
+ auth: "admin",
25928
+ timeoutMs: 12e4
25929
+ }), method(object({
25930
+ selection: RetrainDatasetSelectionSchema,
25931
+ completeOnly: boolean().optional()
25932
+ }), RetrainDatasetStatsSchema, {
25933
+ kind: "query",
25934
+ auth: "admin"
25935
+ }), method(object({
25936
+ name: string().max(120),
25937
+ selection: RetrainDatasetSelectionSchema,
25938
+ layout: RetrainExportLayoutSchema,
25939
+ completeOnly: boolean()
25940
+ }), CreateRetrainDatasetVersionResultSchema, {
25941
+ kind: "mutation",
25942
+ auth: "admin",
25943
+ timeoutMs: 12e4
25944
+ }), method(object({}), array(RetrainDatasetVersionSchema).readonly(), {
25945
+ kind: "query",
25946
+ auth: "admin"
25947
+ }), method(object({ id: string() }), object({ deleted: boolean() }), {
25948
+ kind: "mutation",
25949
+ auth: "admin"
25950
+ }), method(object({ id: string() }), object({
25951
+ found: boolean(),
25952
+ annotationHash: string(),
25953
+ matches: boolean(),
25954
+ missingFrames: number().int()
25955
+ }), {
25956
+ kind: "query",
25957
+ auth: "admin",
25958
+ timeoutMs: 12e4
24985
25959
  }), method(object({}), array(RetrainAssistProfileSchema).readonly(), {
24986
25960
  kind: "query",
24987
25961
  auth: "admin"
@@ -28520,8 +29494,8 @@ version: string().optional() }), ServerUpdateActionResultSchema, {
28520
29494
  * `smtp-provider` — pluggable email delivery surface.
28521
29495
  *
28522
29496
  * Collection cap: a deployment may install multiple SMTP relays (e.g.
28523
- * one for transactional / one for notifications). Consumers (magic-link,
28524
- * notifier addons, …) walk the collection and pick the first
29497
+ * one for transactional / one for notifications). Consumers (notifier
29498
+ * addons, …) walk the collection and pick the first
28525
29499
  * ready provider OR target a specific addonId.
28526
29500
  *
28527
29501
  * The shape stays small on purpose — `sendEmail` is enough for the
@@ -28700,7 +29674,7 @@ targets: array(object({
28700
29674
  })));
28701
29675
  /**
28702
29676
  * `sso-bridge` — internal hub-only cap that lets SSO-style auth
28703
- * providers (OIDC, SAML, magic-link, …) mint an HMAC-signed token
29677
+ * providers (OIDC, SAML, …) mint an HMAC-signed token
28704
29678
  * carrying the post-callback claims before redirecting back to
28705
29679
  * `/api/auth/sso/finish`.
28706
29680
  *
@@ -28763,7 +29737,14 @@ var SsoBridgeClaimsSchema = object({
28763
29737
  * Verified `iss` of the id_token behind an OIDC login bridge (D782). A
28764
29738
  * subject is unique only per issuer, so a link is bound to it.
28765
29739
  */
28766
- issuer: string().optional()
29740
+ issuer: string().optional(),
29741
+ /**
29742
+ * SHA-256 (hex) of the `camstack_sso_state` cookie the IdP `/start` set in
29743
+ * the browser that began this sign-in. `/api/auth/sso/finish` requires the
29744
+ * request to present the matching cookie — a login bridge is useless in
29745
+ * any other browser.
29746
+ */
29747
+ browserBinding: string().optional()
28767
29748
  });
28768
29749
  method(object({
28769
29750
  claims: SsoBridgeClaimsSchema,
@@ -34884,7 +35865,13 @@ var TopologyNodeSchema = object({
34884
35865
  })).readonly(),
34885
35866
  processes: array(TopologyProcessSchema).readonly(),
34886
35867
  categories: array(TopologyCategorySchema).readonly(),
34887
- rootPackage: TopologyRootPackageSchema.nullable()
35868
+ rootPackage: TopologyRootPackageSchema.nullable(),
35869
+ /**
35870
+ * How an online AGENT reaches the hub (mesh mTLS Release A): `tls` once it has
35871
+ * completed a mutual-TLS handshake, `clear` otherwise. Absent for the hub,
35872
+ * for offline rows and when the hub cannot tell.
35873
+ */
35874
+ meshTransport: _enum(["tls", "clear"]).optional()
34888
35875
  });
34889
35876
  var CapUsageEdgeSchema = object({
34890
35877
  callerAddonId: string(),
@@ -38937,16 +39924,6 @@ var ApiKeySummarySchema = object({
38937
39924
  createdAt: number(),
38938
39925
  lastUsedAt: number().optional()
38939
39926
  });
38940
- var CreateApiKeyInputSchema = object({
38941
- label: string(),
38942
- isAdmin: boolean().default(false),
38943
- allowedProviders: union([array(string()), literal("*")]).optional(),
38944
- allowedDevices: record(string(), union([array(string()), literal("*")])).optional()
38945
- });
38946
- var CreateApiKeyResultSchema = object({
38947
- token: string(),
38948
- record: ApiKeySummarySchema
38949
- });
38950
39927
  var ScopedTokenSummarySchema = object({
38951
39928
  id: string(),
38952
39929
  userId: string(),
@@ -39045,17 +40022,10 @@ method(_void(), array(UserSummarySchema), { auth: "admin" }), method(CreateUserI
39045
40022
  }), UserSummarySchema.extend({ passwordHash: string() }).nullable(), {
39046
40023
  kind: "mutation",
39047
40024
  access: "view"
39048
- }), method(_void(), array(ApiKeySummarySchema), { auth: "admin" }), method(CreateApiKeyInputSchema, CreateApiKeyResultSchema, {
39049
- kind: "mutation",
39050
- auth: "admin",
39051
- access: "create"
39052
- }), method(object({ id: string() }), object({ success: literal(true) }), {
40025
+ }), method(_void(), array(ApiKeySummarySchema), { auth: "admin" }), method(object({ id: string() }), object({ success: literal(true) }), {
39053
40026
  kind: "mutation",
39054
40027
  auth: "admin",
39055
40028
  access: "delete"
39056
- }), method(object({ token: string() }), ApiKeySummarySchema.nullable(), {
39057
- kind: "mutation",
39058
- access: "view"
39059
40029
  }), method(CreateScopedTokenInputSchema, CreateScopedTokenResultSchema, {
39060
40030
  kind: "mutation",
39061
40031
  auth: "admin",
@@ -39129,15 +40099,7 @@ method(_void(), array(UserSummarySchema), { auth: "admin" }), method(CreateUserI
39129
40099
  }).nullable(), { access: "view" }), method(object({ userId: string() }), array(ExternalIdentitySchema), { auth: "admin" }), method(ExternalIdentityKeySchema, object({
39130
40100
  userId: string(),
39131
40101
  issuer: string()
39132
- }).nullable(), { auth: "admin" }), method(ExternalIdentityKeySchema.extend({
39133
- userId: string(),
39134
- issuer: string().min(1),
39135
- label: string().optional()
39136
- }), object({ success: literal(true) }), {
39137
- kind: "mutation",
39138
- auth: "admin",
39139
- access: "create"
39140
- }), method(ExternalIdentityKeySchema.extend({ userId: string() }), object({ success: boolean() }), {
40102
+ }).nullable(), { auth: "admin" }), method(ExternalIdentityKeySchema.extend({ userId: string() }), object({ success: boolean() }), {
39141
40103
  kind: "mutation",
39142
40104
  auth: "admin",
39143
40105
  access: "delete"
@@ -39532,6 +40494,451 @@ DeviceType.Camera, method(object({
39532
40494
  detection: array(ZoneRuleSchema).readonly(),
39533
40495
  package: array(ZoneRuleSchema).readonly()
39534
40496
  });
40497
+ /**
40498
+ * `training-provider` — ONE cloud that can run the CamStack trainer.
40499
+ *
40500
+ * A thin, mockable translation layer: it knows how to run a container with a
40501
+ * GPU, move a dataset in, read the job's stdout and hand artefacts back. It
40502
+ * knows nothing about datasets, splits, floors, cost policy or Model Studio —
40503
+ * those are the `training` orchestrator's (D805). Every rule written there
40504
+ * once is what makes a second provider (RunPod, a local NVIDIA node) a new
40505
+ * manifest entry and nothing else.
40506
+ *
40507
+ * Collection, routed by the `addonId` in every single-row input (the `llm` /
40508
+ * `notification-output` posture); `describe` concat-fans across providers.
40509
+ * Every method is `admin`: these spend money.
40510
+ *
40511
+ * Every cloud object a provider creates is tagged with the orchestrator's
40512
+ * `jobKey`, so a retried submit finds the job it already started instead of
40513
+ * starting a second GPU, and `listJobs` can find orphans.
40514
+ *
40515
+ * Bytes never ride a cap field: the dataset arrives as a `ctx.peerBytes`
40516
+ * ticket the producer (pipeline-analytics) minted, and artefacts leave as a
40517
+ * ticket the provider mints (D613).
40518
+ */
40519
+ var TrainingGpuOptionSchema = object({
40520
+ id: string(),
40521
+ label: string(),
40522
+ /** List price, USD per GPU-hour, before any region multiplier. */
40523
+ usdPerHour: number().nonnegative(),
40524
+ vramGb: number().nonnegative()
40525
+ });
40526
+ var TrainingRegionOptionSchema = object({
40527
+ /** `''` = any region (the provider's choice). */
40528
+ id: string(),
40529
+ label: string(),
40530
+ priceMultiplier: number().positive()
40531
+ });
40532
+ /**
40533
+ * The provider's per-account settings, as the orchestrator reads them. They
40534
+ * live in the PROVIDER addon's settings (operator decision 2026-10-08: they
40535
+ * depend on the user's account), never hard-coded in the orchestrator.
40536
+ */
40537
+ var TrainingProviderDefaultsSchema = object({
40538
+ gpuType: string(),
40539
+ region: string(),
40540
+ costCapUsd: number().nonnegative(),
40541
+ maxRuntimeSec: number().int().positive(),
40542
+ /** Hours a FAILED job's cloud dataset is kept for debugging; 0 = delete at once. */
40543
+ failedDatasetGraceHours: number().nonnegative()
40544
+ });
40545
+ var TrainingProviderDescriptorSchema = object({
40546
+ addonId: string(),
40547
+ /** `modal`, `runpod`, `fake`, … */
40548
+ kind: string(),
40549
+ label: string(),
40550
+ gpuTypes: array(TrainingGpuOptionSchema).readonly(),
40551
+ regions: array(TrainingRegionOptionSchema).readonly(),
40552
+ maxDatasetBytes: number().int().positive(),
40553
+ maxRuntimeSec: number().int().positive(),
40554
+ freeTierNote: string().optional(),
40555
+ /** Where the data goes, in one sentence the confirm dialog repeats. */
40556
+ dataResidencyNote: string(),
40557
+ /** Credentials are present — never the values. */
40558
+ configured: boolean(),
40559
+ defaults: TrainingProviderDefaultsSchema
40560
+ });
40561
+ var TrainingCredentialCheckSchema = object({
40562
+ ok: boolean(),
40563
+ /** Workspace / account name, when the provider says. */
40564
+ account: string().optional(),
40565
+ reason: _enum([
40566
+ "missing",
40567
+ "invalid",
40568
+ "forbidden",
40569
+ "network",
40570
+ "quota"
40571
+ ]).optional(),
40572
+ detail: string().optional()
40573
+ });
40574
+ var ProviderJobStateSchema = _enum([
40575
+ "pending",
40576
+ "starting",
40577
+ "running",
40578
+ "succeeded",
40579
+ "failed",
40580
+ "cancelled",
40581
+ "lost"
40582
+ ]);
40583
+ var ProviderJobStatusSchema = object({
40584
+ jobKey: string(),
40585
+ providerJobId: string().optional(),
40586
+ state: ProviderJobStateSchema,
40587
+ startedAt: number().optional(),
40588
+ endedAt: number().optional(),
40589
+ exitCode: number().int().optional(),
40590
+ failureReason: string().optional(),
40591
+ gpuType: string(),
40592
+ region: string().optional(),
40593
+ billedSeconds: number().nonnegative(),
40594
+ costUsd: number().nonnegative(),
40595
+ /** True when `costUsd` is runtime × list price, not a billing answer. */
40596
+ costIsEstimate: boolean(),
40597
+ lastFetchedAt: number()
40598
+ });
40599
+ /**
40600
+ * The trainer the job runs, by SOURCE revision: the provider turns it into an
40601
+ * image its own way (Modal builds the published Dockerfile at that revision;
40602
+ * a registry-pull provider maps it to a tag). Recorded on the job and echoed
40603
+ * in `result.json`.
40604
+ */
40605
+ var TrainerSourceRefSchema = object({
40606
+ /** Hugging Face repo id, e.g. `camstack/camstack-trainer`. */
40607
+ repo: string().min(1),
40608
+ /** A commit sha (never a branch) — the job must be reproducible. */
40609
+ revision: string().regex(/^[0-9a-f]{7,64}$/)
40610
+ });
40611
+ var JobRef = {
40612
+ addonId: string(),
40613
+ jobKey: string().uuid()
40614
+ };
40615
+ var TrainingLogLineSchema = object({
40616
+ ts: number(),
40617
+ text: string()
40618
+ });
40619
+ method(object({}), array(TrainingProviderDescriptorSchema).readonly(), { auth: "admin" }), method(object({ addonId: string() }), TrainingCredentialCheckSchema, {
40620
+ kind: "mutation",
40621
+ auth: "admin",
40622
+ timeoutMs: 3e4
40623
+ }), method(object({
40624
+ addonId: string(),
40625
+ gpuType: string(),
40626
+ region: string(),
40627
+ datasetBytes: number().int().nonnegative(),
40628
+ gpuSecondsLow: number().nonnegative(),
40629
+ gpuSecondsHigh: number().nonnegative()
40630
+ }), object({
40631
+ usdLow: number().nonnegative(),
40632
+ usdHigh: number().nonnegative(),
40633
+ notes: array(string()).readonly()
40634
+ }), { auth: "admin" }), method(object({
40635
+ ...JobRef,
40636
+ ticket: PeerBytesTicketSchema
40637
+ }), object({
40638
+ bytes: number().int().nonnegative(),
40639
+ sha256: string()
40640
+ }), {
40641
+ kind: "mutation",
40642
+ auth: "admin",
40643
+ timeoutMs: 120 * 6e4
40644
+ }), method(object({
40645
+ ...JobRef,
40646
+ trainer: TrainerSourceRefSchema,
40647
+ jobSpecJson: string().min(2).max(64e3),
40648
+ gpuType: string(),
40649
+ region: string(),
40650
+ maxRuntimeSec: number().int().positive()
40651
+ }), ProviderJobStatusSchema, {
40652
+ kind: "mutation",
40653
+ auth: "admin",
40654
+ timeoutMs: 30 * 6e4
40655
+ }), method(object(JobRef), ProviderJobStatusSchema, {
40656
+ auth: "admin",
40657
+ timeoutMs: 6e4
40658
+ }), method(object({
40659
+ ...JobRef,
40660
+ cursor: string().optional(),
40661
+ max: number().int().min(1).max(500)
40662
+ }), object({
40663
+ lines: array(TrainingLogLineSchema).readonly(),
40664
+ cursor: string()
40665
+ }), {
40666
+ auth: "admin",
40667
+ timeoutMs: 6e4
40668
+ }), method(object(JobRef), object({ ok: literal(true) }), {
40669
+ kind: "mutation",
40670
+ auth: "admin",
40671
+ timeoutMs: 6e4
40672
+ }), method(object(JobRef), object({
40673
+ found: boolean(),
40674
+ text: string().optional()
40675
+ }), {
40676
+ kind: "mutation",
40677
+ auth: "admin",
40678
+ timeoutMs: 5 * 6e4
40679
+ }), method(object({
40680
+ ...JobRef,
40681
+ path: _enum(["bundle.tar"])
40682
+ }), object({ ticket: PeerBytesTicketSchema }), {
40683
+ kind: "mutation",
40684
+ auth: "admin",
40685
+ timeoutMs: 5 * 6e4
40686
+ }), method(object(JobRef), object({ deleted: array(string()).readonly() }), {
40687
+ kind: "mutation",
40688
+ auth: "admin",
40689
+ timeoutMs: 5 * 6e4
40690
+ }), method(object({ addonId: string() }), array(ProviderJobStatusSchema).readonly(), {
40691
+ auth: "admin",
40692
+ timeoutMs: 2 * 6e4
40693
+ });
40694
+ /**
40695
+ * `training` — the cloud-training orchestrator (D805). Hub-only singleton,
40696
+ * provided by `addon-training`.
40697
+ *
40698
+ * It owns what every provider must agree on, written once:
40699
+ *
40700
+ * - **Dataset versions.** Taken over from pipeline-analytics (D796): the rows
40701
+ * live here (D808); pipeline-analytics still CUTS a version (it owns the corpus and
40702
+ * the export plan) and reaches this store through the five row methods
40703
+ * below, so the Retrain page and the export did not change.
40704
+ * - **Jobs.** A persisted state machine, a reconcile loop against the
40705
+ * provider, a cost guard, a daily orphan sweep and the retention rules.
40706
+ * - **The return flow.** Verified artefacts → Model Studio
40707
+ * (`custom-model-registry.importModelBundle`) → canary on cameras →
40708
+ * rollback. Nothing is ever registered automatically.
40709
+ *
40710
+ * Every method is `admin`.
40711
+ */
40712
+ /** A version WITH its frame list — what the export and a job read. */
40713
+ var TrainingDatasetVersionRowSchema = RetrainDatasetVersionSchema.omit({ frameCount: true }).extend({ frameIds: array(string()).max(2e4).readonly() });
40714
+ /** A base model a detector job can fine-tune, and the baseline it is judged against. */
40715
+ var TrainingBaseModelSchema = object({
40716
+ modelId: string(),
40717
+ label: string(),
40718
+ weights: string(),
40719
+ imgsz: number().int(),
40720
+ baselineOnnxUrl: string(),
40721
+ baselineFloors: record(string(), number()),
40722
+ /** The base the fleet runs most — the UI's default. */
40723
+ recommended: boolean()
40724
+ });
40725
+ var TrainingPresetSchema = _enum([
40726
+ "quick",
40727
+ "standard",
40728
+ "thorough"
40729
+ ]);
40730
+ var TrainingJobRequestSchema = object({
40731
+ datasetVersionId: string().min(1),
40732
+ /** The `training-provider` addon that runs it. */
40733
+ addonId: string().min(1),
40734
+ gpuType: string().min(1),
40735
+ region: string(),
40736
+ baseModelId: string().min(1),
40737
+ preset: TrainingPresetSchema,
40738
+ /** Freeze the backbone's first N layers; `null` = the preset's choice. */
40739
+ freeze: number().int().nonnegative().nullable(),
40740
+ /** Cameras held out whole for evaluation; `null` = the orchestrator's default. */
40741
+ holdoutCameras: array(number().int()).nullable()
40742
+ });
40743
+ var TrainingSplitPlanSchema = object({
40744
+ holdoutCameras: array(number().int()).readonly(),
40745
+ /** Used when no camera is held out: the last N days of every camera. */
40746
+ holdoutLastDays: number().int().nonnegative(),
40747
+ /** Holdout subjects per class (camera holdout only; `null` = known only after the split). */
40748
+ holdoutSupport: record(string(), number().int()).nullable(),
40749
+ trainSubjects: number().int()
40750
+ });
40751
+ var TrainingRefusalReasonSchema = _enum([
40752
+ "unknown-dataset",
40753
+ "unknown-provider",
40754
+ "provider-not-configured",
40755
+ "unknown-base-model",
40756
+ "unknown-gpu",
40757
+ "dataset-too-large",
40758
+ "no-training-subjects",
40759
+ "job-already-running"
40760
+ ]);
40761
+ var TrainingJobPlanSchema = object({
40762
+ refusal: object({
40763
+ reason: TrainingRefusalReasonSchema,
40764
+ detail: string()
40765
+ }).nullable(),
40766
+ warnings: array(string()).readonly(),
40767
+ split: TrainingSplitPlanSchema.nullable(),
40768
+ estimate: object({
40769
+ datasetBytes: number().int(),
40770
+ uploadMinutesAt20Mbps: number(),
40771
+ gpuSecondsLow: number(),
40772
+ gpuSecondsHigh: number(),
40773
+ usdLow: number(),
40774
+ usdHigh: number(),
40775
+ notes: array(string()).readonly()
40776
+ }).nullable(),
40777
+ /** Pre-filled from the provider's settings; the operator may lower or raise them. */
40778
+ defaults: object({
40779
+ maxCostUsd: number(),
40780
+ maxRuntimeSec: number().int()
40781
+ }).nullable(),
40782
+ /** The sentence the confirm dialog repeats: where the frames go and when they are deleted. */
40783
+ dataNotice: string()
40784
+ });
40785
+ /**
40786
+ * Orchestrator-owned states, persisted. `uploading` covers exporting the
40787
+ * archive (it is streamed, never staged). Terminal: `failed`, `cancelled`,
40788
+ * `lost`, `expired`, `discarded`. `registered` and `canary` are where a
40789
+ * result lives after the operator acted on it.
40790
+ */
40791
+ var TrainingJobStateSchema = _enum([
40792
+ "uploading",
40793
+ "submitted",
40794
+ "starting",
40795
+ "running",
40796
+ "collecting",
40797
+ "ready",
40798
+ "registered",
40799
+ "canary",
40800
+ "failed",
40801
+ "cancelling",
40802
+ "cancelled",
40803
+ "lost",
40804
+ "expired",
40805
+ "discarded"
40806
+ ]);
40807
+ var TrainingFailureReasonSchema = _enum([
40808
+ "cost-cap",
40809
+ "runtime-cap",
40810
+ "upload-failed",
40811
+ "submit-failed",
40812
+ "trainer-failed",
40813
+ "result-invalid",
40814
+ "checksum-mismatch",
40815
+ "fetch-failed",
40816
+ "provider-error",
40817
+ "hub-restart-during-upload"
40818
+ ]);
40819
+ var TrainingProgressPointSchema = object({
40820
+ epoch: number().int(),
40821
+ map50: number().nullable(),
40822
+ map50_95: number().nullable()
40823
+ });
40824
+ var TrainingCanarySchema = object({
40825
+ deviceIds: array(number().int()).readonly(),
40826
+ since: number(),
40827
+ /** Every override the canary replaced, exactly, so rollback restores it. */
40828
+ previous: array(object({
40829
+ deviceId: number().int(),
40830
+ nodeId: string(),
40831
+ deviceKey: string(),
40832
+ patch: object({
40833
+ modelId: string().optional(),
40834
+ settings: record(string(), unknown()).readonly().optional()
40835
+ }).nullable()
40836
+ })).readonly()
40837
+ });
40838
+ var TrainingJobSchema = object({
40839
+ id: string(),
40840
+ idempotencyKey: string(),
40841
+ name: string(),
40842
+ createdAt: number(),
40843
+ updatedAt: number(),
40844
+ state: TrainingJobStateSchema,
40845
+ stage: TrainingStageSchema.nullable(),
40846
+ failure: object({
40847
+ reason: TrainingFailureReasonSchema,
40848
+ stage: string().nullable(),
40849
+ detail: string()
40850
+ }).nullable(),
40851
+ request: TrainingJobRequestSchema,
40852
+ maxCostUsd: number().nonnegative(),
40853
+ maxRuntimeSec: number().int().positive(),
40854
+ trainer: TrainerSourceRefSchema,
40855
+ datasetLayout: RetrainExportLayoutSchema,
40856
+ dataset: object({
40857
+ bytes: number().int(),
40858
+ sha256: string(),
40859
+ uploadedAt: number()
40860
+ }).nullable(),
40861
+ split: TrainingSplitPlanSchema,
40862
+ provider: object({
40863
+ state: ProviderJobStateSchema.nullable(),
40864
+ providerJobId: string().nullable(),
40865
+ startedAt: number().nullable(),
40866
+ endedAt: number().nullable(),
40867
+ billedSeconds: number(),
40868
+ costUsd: number(),
40869
+ costIsEstimate: boolean(),
40870
+ lastPolledAt: number().nullable()
40871
+ }),
40872
+ progress: object({
40873
+ epoch: number().int().nullable(),
40874
+ epochs: number().int().nullable(),
40875
+ etaSec: number().nullable(),
40876
+ series: array(TrainingProgressPointSchema).readonly()
40877
+ }),
40878
+ /** The last lines of the job's output (≤ 200), newest last. Never frame paths. */
40879
+ logTail: array(string()).readonly(),
40880
+ logCursor: string().nullable(),
40881
+ artifacts: object({
40882
+ bundleBytes: number().int(),
40883
+ bundleSha256: string(),
40884
+ fetchedAt: number(),
40885
+ /** When the staged artefacts are deleted from the hub. */
40886
+ expiresAt: number()
40887
+ }).nullable(),
40888
+ /** When the provider-side copy of the frames was deleted; null while it exists. */
40889
+ cloudDatasetDeletedAt: number().nullable(),
40890
+ /** A failed job's dataset is kept until then (the provider's grace), then deleted. */
40891
+ cloudCleanupDueAt: number().nullable(),
40892
+ /** Model ids registered from this job (base, and int8 when kept). */
40893
+ registeredModelIds: array(string()).readonly(),
40894
+ canary: TrainingCanarySchema.nullable()
40895
+ });
40896
+ var IdInput = object({ id: string().min(1) });
40897
+ method(TrainingDatasetVersionRowSchema, object({ stored: boolean() }), {
40898
+ kind: "mutation",
40899
+ auth: "admin"
40900
+ }), 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() }), {
40901
+ kind: "mutation",
40902
+ auth: "admin"
40903
+ }), method(object({}), array(TrainingBaseModelSchema).readonly(), { auth: "admin" }), method(TrainingJobRequestSchema, TrainingJobPlanSchema, {
40904
+ auth: "admin",
40905
+ timeoutMs: 6e4
40906
+ }), method(TrainingJobRequestSchema.extend({
40907
+ name: string().min(1).max(120),
40908
+ maxCostUsd: number().positive(),
40909
+ maxRuntimeSec: number().int().positive(),
40910
+ idempotencyKey: string().min(8).max(80)
40911
+ }), discriminatedUnion("kind", [object({
40912
+ kind: literal("started"),
40913
+ job: TrainingJobSchema
40914
+ }), object({
40915
+ kind: literal("refused"),
40916
+ reason: TrainingRefusalReasonSchema,
40917
+ detail: string()
40918
+ })]), {
40919
+ kind: "mutation",
40920
+ auth: "admin",
40921
+ timeoutMs: 12e4
40922
+ }), method(object({}), array(TrainingJobSchema).readonly(), { auth: "admin" }), method(IdInput, TrainingJobSchema.nullable(), { auth: "admin" }), method(IdInput, TrainingJobSchema, {
40923
+ kind: "mutation",
40924
+ auth: "admin",
40925
+ timeoutMs: 12e4
40926
+ }), method(IdInput, TrainingResultSchema.nullable(), { auth: "admin" }), method(IdInput.extend({ canaryDeviceIds: array(number().int()).readonly() }), TrainingJobSchema, {
40927
+ kind: "mutation",
40928
+ auth: "admin",
40929
+ timeoutMs: 30 * 6e4
40930
+ }), method(IdInput.extend({ deviceIds: array(number().int()).min(1).readonly() }), TrainingJobSchema, {
40931
+ kind: "mutation",
40932
+ auth: "admin",
40933
+ timeoutMs: 12e4
40934
+ }), method(IdInput, TrainingJobSchema, {
40935
+ kind: "mutation",
40936
+ auth: "admin",
40937
+ timeoutMs: 12e4
40938
+ }), method(IdInput, TrainingJobSchema, {
40939
+ kind: "mutation",
40940
+ auth: "admin"
40941
+ });
39535
40942
  SOURCE_CAPS.filter((cap) => cap !== "switch" && cap !== "motion");
39536
40943
  Object.freeze({
39537
40944
  person: .5,
@@ -40155,6 +41562,12 @@ Object.freeze({
40155
41562
  addonId: null,
40156
41563
  access: "create"
40157
41564
  },
41565
+ "backup.checkBackupKey": {
41566
+ capName: "backup",
41567
+ capScope: "system",
41568
+ addonId: null,
41569
+ access: "create"
41570
+ },
40158
41571
  "backup.delete": {
40159
41572
  capName: "backup",
40160
41573
  capScope: "system",
@@ -40167,6 +41580,18 @@ Object.freeze({
40167
41580
  addonId: null,
40168
41581
  access: "delete"
40169
41582
  },
41583
+ "backup.disableEncryption": {
41584
+ capName: "backup",
41585
+ capScope: "system",
41586
+ addonId: null,
41587
+ access: "create"
41588
+ },
41589
+ "backup.getEncryption": {
41590
+ capName: "backup",
41591
+ capScope: "system",
41592
+ addonId: null,
41593
+ access: "view"
41594
+ },
40170
41595
  "backup.getEntries": {
40171
41596
  capName: "backup",
40172
41597
  capScope: "system",
@@ -40221,6 +41646,12 @@ Object.freeze({
40221
41646
  addonId: null,
40222
41647
  access: "create"
40223
41648
  },
41649
+ "backup.setupEncryption": {
41650
+ capName: "backup",
41651
+ capScope: "system",
41652
+ addonId: null,
41653
+ access: "create"
41654
+ },
40224
41655
  "backup.trigger": {
40225
41656
  capName: "backup",
40226
41657
  capScope: "system",
@@ -40773,6 +42204,12 @@ Object.freeze({
40773
42204
  addonId: null,
40774
42205
  access: "create"
40775
42206
  },
42207
+ "customModelRegistry.importModelBundle": {
42208
+ capName: "custom-model-registry",
42209
+ capScope: "system",
42210
+ addonId: null,
42211
+ access: "create"
42212
+ },
40776
42213
  "customModelRegistry.listModels": {
40777
42214
  capName: "custom-model-registry",
40778
42215
  capScope: "system",
@@ -42213,6 +43650,12 @@ Object.freeze({
42213
43650
  addonId: null,
42214
43651
  access: "view"
42215
43652
  },
43653
+ "keychainAdmin.acknowledgeReset": {
43654
+ capName: "keychain-admin",
43655
+ capScope: "system",
43656
+ addonId: null,
43657
+ access: "create"
43658
+ },
42216
43659
  "keychainAdmin.deleteOrphans": {
42217
43660
  capName: "keychain-admin",
42218
43661
  capScope: "system",
@@ -42249,6 +43692,12 @@ Object.freeze({
42249
43692
  addonId: null,
42250
43693
  access: "delete"
42251
43694
  },
43695
+ "keychainAdmin.resetReport": {
43696
+ capName: "keychain-admin",
43697
+ capScope: "system",
43698
+ addonId: null,
43699
+ access: "delete"
43700
+ },
42252
43701
  "keychainAdmin.reveal": {
42253
43702
  capName: "keychain-admin",
42254
43703
  capScope: "system",
@@ -42261,6 +43710,12 @@ Object.freeze({
42261
43710
  addonId: null,
42262
43711
  access: "create"
42263
43712
  },
43713
+ "keychainAdmin.setSystemSecret": {
43714
+ capName: "keychain-admin",
43715
+ capScope: "system",
43716
+ addonId: null,
43717
+ access: "create"
43718
+ },
42264
43719
  "keychainAdmin.status": {
42265
43720
  capName: "keychain-admin",
42266
43721
  capScope: "system",
@@ -43707,6 +45162,12 @@ Object.freeze({
43707
45162
  addonId: null,
43708
45163
  access: "create"
43709
45164
  },
45165
+ "pipelineAnalytics.createRetrainDatasetVersion": {
45166
+ capName: "pipeline-analytics",
45167
+ capScope: "device",
45168
+ addonId: null,
45169
+ access: "create"
45170
+ },
43710
45171
  "pipelineAnalytics.deleteDeviceEvents": {
43711
45172
  capName: "pipeline-analytics",
43712
45173
  capScope: "device",
@@ -43719,6 +45180,12 @@ Object.freeze({
43719
45180
  addonId: null,
43720
45181
  access: "delete"
43721
45182
  },
45183
+ "pipelineAnalytics.deleteRetrainDatasetVersion": {
45184
+ capName: "pipeline-analytics",
45185
+ capScope: "device",
45186
+ addonId: null,
45187
+ access: "delete"
45188
+ },
43722
45189
  "pipelineAnalytics.deleteTracks": {
43723
45190
  capName: "pipeline-analytics",
43724
45191
  capScope: "device",
@@ -43941,6 +45408,12 @@ Object.freeze({
43941
45408
  addonId: null,
43942
45409
  access: "view"
43943
45410
  },
45411
+ "pipelineAnalytics.listRetrainDatasetVersions": {
45412
+ capName: "pipeline-analytics",
45413
+ capScope: "device",
45414
+ addonId: null,
45415
+ access: "view"
45416
+ },
43944
45417
  "pipelineAnalytics.listRetrainFrames": {
43945
45418
  capName: "pipeline-analytics",
43946
45419
  capScope: "device",
@@ -43971,6 +45444,12 @@ Object.freeze({
43971
45444
  addonId: null,
43972
45445
  access: "view"
43973
45446
  },
45447
+ "pipelineAnalytics.offerRetrainArchive": {
45448
+ capName: "pipeline-analytics",
45449
+ capScope: "device",
45450
+ addonId: null,
45451
+ access: "create"
45452
+ },
43974
45453
  "pipelineAnalytics.ownersWithMedia": {
43975
45454
  capName: "pipeline-analytics",
43976
45455
  capScope: "device",
@@ -43983,6 +45462,12 @@ Object.freeze({
43983
45462
  addonId: null,
43984
45463
  access: "create"
43985
45464
  },
45465
+ "pipelineAnalytics.previewRetrainDataset": {
45466
+ capName: "pipeline-analytics",
45467
+ capScope: "device",
45468
+ addonId: null,
45469
+ access: "view"
45470
+ },
43986
45471
  "pipelineAnalytics.proposeRetrainAnnotations": {
43987
45472
  capName: "pipeline-analytics",
43988
45473
  capScope: "device",
@@ -44121,6 +45606,12 @@ Object.freeze({
44121
45606
  addonId: null,
44122
45607
  access: "create"
44123
45608
  },
45609
+ "pipelineAnalytics.verifyRetrainDatasetVersion": {
45610
+ capName: "pipeline-analytics",
45611
+ capScope: "device",
45612
+ addonId: null,
45613
+ access: "view"
45614
+ },
44124
45615
  "pipelineAnalytics.wipeAllAnalytics": {
44125
45616
  capName: "pipeline-analytics",
44126
45617
  capScope: "device",
@@ -46497,6 +47988,174 @@ Object.freeze({
46497
47988
  addonId: null,
46498
47989
  access: "view"
46499
47990
  },
47991
+ "training.canaryResult": {
47992
+ capName: "training",
47993
+ capScope: "system",
47994
+ addonId: null,
47995
+ access: "create"
47996
+ },
47997
+ "training.cancelJob": {
47998
+ capName: "training",
47999
+ capScope: "system",
48000
+ addonId: null,
48001
+ access: "create"
48002
+ },
48003
+ "training.discardResult": {
48004
+ capName: "training",
48005
+ capScope: "system",
48006
+ addonId: null,
48007
+ access: "create"
48008
+ },
48009
+ "training.findDatasetVersionIdByName": {
48010
+ capName: "training",
48011
+ capScope: "system",
48012
+ addonId: null,
48013
+ access: "view"
48014
+ },
48015
+ "training.getDatasetVersion": {
48016
+ capName: "training",
48017
+ capScope: "system",
48018
+ addonId: null,
48019
+ access: "view"
48020
+ },
48021
+ "training.getJob": {
48022
+ capName: "training",
48023
+ capScope: "system",
48024
+ addonId: null,
48025
+ access: "view"
48026
+ },
48027
+ "training.getJobResult": {
48028
+ capName: "training",
48029
+ capScope: "system",
48030
+ addonId: null,
48031
+ access: "view"
48032
+ },
48033
+ "training.listBaseModels": {
48034
+ capName: "training",
48035
+ capScope: "system",
48036
+ addonId: null,
48037
+ access: "view"
48038
+ },
48039
+ "training.listDatasetVersions": {
48040
+ capName: "training",
48041
+ capScope: "system",
48042
+ addonId: null,
48043
+ access: "view"
48044
+ },
48045
+ "training.listJobs": {
48046
+ capName: "training",
48047
+ capScope: "system",
48048
+ addonId: null,
48049
+ access: "view"
48050
+ },
48051
+ "training.planJob": {
48052
+ capName: "training",
48053
+ capScope: "system",
48054
+ addonId: null,
48055
+ access: "view"
48056
+ },
48057
+ "training.putDatasetVersion": {
48058
+ capName: "training",
48059
+ capScope: "system",
48060
+ addonId: null,
48061
+ access: "create"
48062
+ },
48063
+ "training.registerResult": {
48064
+ capName: "training",
48065
+ capScope: "system",
48066
+ addonId: null,
48067
+ access: "create"
48068
+ },
48069
+ "training.removeDatasetVersion": {
48070
+ capName: "training",
48071
+ capScope: "system",
48072
+ addonId: null,
48073
+ access: "delete"
48074
+ },
48075
+ "training.rollbackCanary": {
48076
+ capName: "training",
48077
+ capScope: "system",
48078
+ addonId: null,
48079
+ access: "create"
48080
+ },
48081
+ "training.startJob": {
48082
+ capName: "training",
48083
+ capScope: "system",
48084
+ addonId: null,
48085
+ access: "create"
48086
+ },
48087
+ "trainingProvider.cancelJob": {
48088
+ capName: "training-provider",
48089
+ capScope: "system",
48090
+ addonId: null,
48091
+ access: "create"
48092
+ },
48093
+ "trainingProvider.cleanupJob": {
48094
+ capName: "training-provider",
48095
+ capScope: "system",
48096
+ addonId: null,
48097
+ access: "create"
48098
+ },
48099
+ "trainingProvider.describe": {
48100
+ capName: "training-provider",
48101
+ capScope: "system",
48102
+ addonId: null,
48103
+ access: "view"
48104
+ },
48105
+ "trainingProvider.estimateJob": {
48106
+ capName: "training-provider",
48107
+ capScope: "system",
48108
+ addonId: null,
48109
+ access: "view"
48110
+ },
48111
+ "trainingProvider.getJob": {
48112
+ capName: "training-provider",
48113
+ capScope: "system",
48114
+ addonId: null,
48115
+ access: "view"
48116
+ },
48117
+ "trainingProvider.listJobEvents": {
48118
+ capName: "training-provider",
48119
+ capScope: "system",
48120
+ addonId: null,
48121
+ access: "view"
48122
+ },
48123
+ "trainingProvider.listJobs": {
48124
+ capName: "training-provider",
48125
+ capScope: "system",
48126
+ addonId: null,
48127
+ access: "view"
48128
+ },
48129
+ "trainingProvider.offerArtifact": {
48130
+ capName: "training-provider",
48131
+ capScope: "system",
48132
+ addonId: null,
48133
+ access: "create"
48134
+ },
48135
+ "trainingProvider.readResult": {
48136
+ capName: "training-provider",
48137
+ capScope: "system",
48138
+ addonId: null,
48139
+ access: "create"
48140
+ },
48141
+ "trainingProvider.submitJob": {
48142
+ capName: "training-provider",
48143
+ capScope: "system",
48144
+ addonId: null,
48145
+ access: "create"
48146
+ },
48147
+ "trainingProvider.uploadDataset": {
48148
+ capName: "training-provider",
48149
+ capScope: "system",
48150
+ addonId: null,
48151
+ access: "create"
48152
+ },
48153
+ "trainingProvider.validateCredentials": {
48154
+ capName: "training-provider",
48155
+ capScope: "system",
48156
+ addonId: null,
48157
+ access: "create"
48158
+ },
46500
48159
  "turnProvider.getTurnServers": {
46501
48160
  capName: "turn-provider",
46502
48161
  capScope: "system",
@@ -46521,12 +48180,6 @@ Object.freeze({
46521
48180
  addonId: null,
46522
48181
  access: "create"
46523
48182
  },
46524
- "userManagement.createApiKey": {
46525
- capName: "user-management",
46526
- capScope: "system",
46527
- addonId: null,
46528
- access: "create"
46529
- },
46530
48183
  "userManagement.createScopedToken": {
46531
48184
  capName: "user-management",
46532
48185
  capScope: "system",
@@ -46563,12 +48216,6 @@ Object.freeze({
46563
48216
  addonId: null,
46564
48217
  access: "view"
46565
48218
  },
46566
- "userManagement.linkExternalIdentity": {
46567
- capName: "user-management",
46568
- capScope: "system",
46569
- addonId: null,
46570
- access: "create"
46571
- },
46572
48219
  "userManagement.listApiKeys": {
46573
48220
  capName: "user-management",
46574
48221
  capScope: "system",
@@ -46671,12 +48318,6 @@ Object.freeze({
46671
48318
  addonId: null,
46672
48319
  access: "create"
46673
48320
  },
46674
- "userManagement.validateApiKey": {
46675
- capName: "user-management",
46676
- capScope: "system",
46677
- addonId: null,
46678
- access: "view"
46679
- },
46680
48321
  "userManagement.validateCredentials": {
46681
48322
  capName: "user-management",
46682
48323
  capScope: "system",
@@ -50790,6 +52431,11 @@ Object.freeze({
50790
52431
  form: "single",
50791
52432
  optional: false
50792
52433
  }],
52434
+ "training.canaryResult": [{
52435
+ name: "deviceIds",
52436
+ form: "array",
52437
+ optional: false
52438
+ }],
50793
52439
  "update.getStatus": [{
50794
52440
  name: "deviceId",
50795
52441
  form: "single",
@@ -51518,6 +53164,8 @@ var STATE_SUMMARY_VARS = [
51518
53164
  [...RULE_TEXT],
51519
53165
  [...RULE_TEXT],
51520
53166
  [...RULE_TEXT],
53167
+ [...RULE_TEXT],
53168
+ [...RULE_TEXT],
51521
53169
  ([...RULE_TEXT], [...UPDATES]),
51522
53170
  ([...RULE_TEXT], [...PACKAGE_UPDATES]),
51523
53171
  ([...RULE_TEXT], [...PACKAGE_UPDATES]),