@camstack/addon-export-alexa 1.2.139 → 1.2.141

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.
@@ -5379,7 +5379,7 @@ var ZodIssueCode = {
5379
5379
  var ZodFirstPartyTypeKind;
5380
5380
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
5381
5381
  //#endregion
5382
- //#region ../types/dist/sleep-Cr5YOk3m.mjs
5382
+ //#region ../types/dist/sleep-r3RWkGVx.mjs
5383
5383
  /**
5384
5384
  * The audio chunk plane's byte format, and the ONE expansion from a coded
5385
5385
  * window to float samples (D455).
@@ -5496,7 +5496,7 @@ function isKeychainStoredField(field) {
5496
5496
  var SECRET_CLEAR = { $secretClear: true };
5497
5497
  /** The `'***'` token D634 redaction writes for non-admins. */
5498
5498
  var LEGACY_DEVICE_REDACTION = "***";
5499
- function isRecord$1(value) {
5499
+ function isRecord$2(value) {
5500
5500
  return typeof value === "object" && value !== null && !Array.isArray(value);
5501
5501
  }
5502
5502
  function makeSecretMarker(ref) {
@@ -5507,12 +5507,12 @@ function makeSecretMarker(ref) {
5507
5507
  }
5508
5508
  /** A stored marker: an object whose `$secret` is a non-empty string. */
5509
5509
  function isSecretMarker(value) {
5510
- if (!isRecord$1(value)) return false;
5510
+ if (!isRecord$2(value)) return false;
5511
5511
  const ref = value["$secret"];
5512
5512
  return typeof ref === "string" && ref.length > 0;
5513
5513
  }
5514
5514
  function isSecretClear(value) {
5515
- return isRecord$1(value) && value["$secretClear"] === true;
5515
+ return isRecord$2(value) && value["$secretClear"] === true;
5516
5516
  }
5517
5517
  /**
5518
5518
  * The UI view of a stored secret field value: a marker becomes "set", inline
@@ -6028,6 +6028,13 @@ function globalSecretScope() {
6028
6028
  function encodeSegment(value) {
6029
6029
  return encodeURIComponent(value);
6030
6030
  }
6031
+ function decodeSegment(value) {
6032
+ try {
6033
+ return decodeURIComponent(value);
6034
+ } catch {
6035
+ return null;
6036
+ }
6037
+ }
6031
6038
  /**
6032
6039
  * The field path of a value inside an array item, addressed by the item's id:
6033
6040
  * `arrayItemFieldPath('providers', 'authentik', 'clientSecret')` →
@@ -6036,6 +6043,75 @@ function encodeSegment(value) {
6036
6043
  function arrayItemFieldPath(arrayKey, itemId, fieldKey) {
6037
6044
  return `${arrayKey}[${encodeSegment(itemId)}].${fieldKey}`;
6038
6045
  }
6046
+ function parseScope(segments) {
6047
+ switch (segments[0]) {
6048
+ case "global": return {
6049
+ scope: GLOBAL_SCOPE,
6050
+ used: 1
6051
+ };
6052
+ case "node": {
6053
+ const nodeId = segments[1] !== void 0 ? decodeSegment(segments[1]) : null;
6054
+ return nodeId === null || nodeId.length === 0 ? null : {
6055
+ scope: {
6056
+ kind: "node",
6057
+ nodeId
6058
+ },
6059
+ used: 2
6060
+ };
6061
+ }
6062
+ case "device": {
6063
+ const raw = segments[1];
6064
+ if (raw === void 0 || !/^\d+$/.test(raw)) return null;
6065
+ return {
6066
+ scope: {
6067
+ kind: "device",
6068
+ deviceId: Number(raw)
6069
+ },
6070
+ used: 2
6071
+ };
6072
+ }
6073
+ case "integration": {
6074
+ const id = segments[1] !== void 0 ? decodeSegment(segments[1]) : null;
6075
+ return id === null || id.length === 0 ? null : {
6076
+ scope: {
6077
+ kind: "integration",
6078
+ integrationId: id
6079
+ },
6080
+ used: 2
6081
+ };
6082
+ }
6083
+ case "row": {
6084
+ const collection = segments[1] !== void 0 ? decodeSegment(segments[1]) : null;
6085
+ const rowId = segments[2] !== void 0 ? decodeSegment(segments[2]) : null;
6086
+ if (collection === null || rowId === null || collection.length === 0 || rowId.length === 0) return null;
6087
+ return {
6088
+ scope: {
6089
+ kind: "row",
6090
+ collection,
6091
+ rowId
6092
+ },
6093
+ used: 3
6094
+ };
6095
+ }
6096
+ default: return null;
6097
+ }
6098
+ }
6099
+ /** Take a ref apart; `null` when it is not a well-formed ref. */
6100
+ function parseSecretRef(ref) {
6101
+ if (!ref.startsWith("secret://")) return null;
6102
+ const segments = ref.slice(9).split("/");
6103
+ const owner = segments[0] !== void 0 ? decodeSegment(segments[0]) : null;
6104
+ if (owner === null || owner.length === 0) return null;
6105
+ const parsed = parseScope(segments.slice(1));
6106
+ if (parsed === null) return null;
6107
+ const fieldPath = segments.slice(1 + parsed.used).join("/");
6108
+ if (fieldPath.length === 0) return null;
6109
+ return {
6110
+ owner,
6111
+ scope: parsed.scope,
6112
+ fieldPath
6113
+ };
6114
+ }
6039
6115
  /** A write to a secret path could not be stored in the keychain, so it was refused. */
6040
6116
  var KeychainWriteRefusedError = class extends Error {
6041
6117
  fieldPath;
@@ -6046,7 +6122,7 @@ var KeychainWriteRefusedError = class extends Error {
6046
6122
  }
6047
6123
  };
6048
6124
  var KEEP = { kind: "keep" };
6049
- function isRecord(value) {
6125
+ function isRecord$1(value) {
6050
6126
  return typeof value === "object" && value !== null && !Array.isArray(value);
6051
6127
  }
6052
6128
  function defaultMintId() {
@@ -6059,7 +6135,7 @@ function collectSecretMarkerRefs(value, out = []) {
6059
6135
  return out;
6060
6136
  }
6061
6137
  if (Array.isArray(value)) for (const item of value) collectSecretMarkerRefs(item, out);
6062
- else if (isRecord(value)) for (const child of Object.values(value)) collectSecretMarkerRefs(child, out);
6138
+ else if (isRecord$1(value)) for (const child of Object.values(value)) collectSecretMarkerRefs(child, out);
6063
6139
  return out;
6064
6140
  }
6065
6141
  async function storedValueEquals(secrets, marker, candidate) {
@@ -6114,7 +6190,7 @@ function rowId(row, idKey) {
6114
6190
  return null;
6115
6191
  }
6116
6192
  async function writeArray(ctx, node, incoming, stored, fieldPath) {
6117
- const storedRows = Array.isArray(stored) ? stored.filter(isRecord) : [];
6193
+ const storedRows = Array.isArray(stored) ? stored.filter(isRecord$1) : [];
6118
6194
  if (!Array.isArray(incoming)) {
6119
6195
  ctx.deletes.push(...collectSecretMarkerRefs(storedRows));
6120
6196
  return {
@@ -6130,7 +6206,7 @@ async function writeArray(ctx, node, incoming, stored, fieldPath) {
6130
6206
  const kept = /* @__PURE__ */ new Set();
6131
6207
  const rows = [];
6132
6208
  for (const row of incoming) {
6133
- if (!isRecord(row)) {
6209
+ if (!isRecord$1(row)) {
6134
6210
  rows.push(row);
6135
6211
  continue;
6136
6212
  }
@@ -6155,7 +6231,7 @@ async function writeNode(ctx, node, incoming, stored, fieldPath) {
6155
6231
  case "leaf": return writeLeaf(ctx, incoming, stored, fieldPath);
6156
6232
  case "array": return writeArray(ctx, node, incoming, stored, fieldPath);
6157
6233
  case "object": {
6158
- if (!isRecord(incoming)) {
6234
+ if (!isRecord$1(incoming)) {
6159
6235
  if (incoming === void 0) return KEEP;
6160
6236
  ctx.deletes.push(...collectSecretMarkerRefs(stored));
6161
6237
  return {
@@ -6163,7 +6239,7 @@ async function writeNode(ctx, node, incoming, stored, fieldPath) {
6163
6239
  value: incoming
6164
6240
  };
6165
6241
  }
6166
- const storedObj = isRecord(stored) ? stored : {};
6242
+ const storedObj = isRecord$1(stored) ? stored : {};
6167
6243
  return {
6168
6244
  kind: "value",
6169
6245
  value: await writeMembers(ctx, node.children, incoming, storedObj, (m) => `${fieldPath}.${m}`)
@@ -6222,12 +6298,19 @@ async function transformSecretWrite(input) {
6222
6298
  }
6223
6299
  };
6224
6300
  }
6301
+ /** Is `ref` one of `owner`'s refs? */
6302
+ function isSecretRefOwnedBy(ref, owner) {
6303
+ return parseSecretRef(ref)?.owner === owner;
6304
+ }
6225
6305
  /**
6226
6306
  * Replace every marker in `value` with its keychain value. Returns the SAME
6227
6307
  * reference when there is no marker (no allocation, no keychain call).
6228
6308
  */
6229
- async function resolveSecretMarkers(value, secrets) {
6230
- const refs = collectSecretMarkerRefs(value);
6309
+ async function resolveSecretMarkers(value, secrets, options = {}) {
6310
+ const keepMarker = options.unresolved === "keep-marker";
6311
+ const owner = options.ownedBy;
6312
+ const inScope = (ref) => owner === void 0 || isSecretRefOwnedBy(ref, owner);
6313
+ const refs = collectSecretMarkerRefs(value).filter(inScope);
6231
6314
  if (refs.length === 0) return {
6232
6315
  value,
6233
6316
  unresolved: []
@@ -6251,10 +6334,18 @@ async function resolveSecretMarkers(value, secrets) {
6251
6334
  }
6252
6335
  const substitute = (v) => {
6253
6336
  if (isSecretMarker(v)) {
6337
+ if (!inScope(v.$secret)) return {
6338
+ keep: true,
6339
+ value: v
6340
+ };
6254
6341
  const answer = answers[v.$secret];
6255
- return answer?.kind === "value" ? {
6342
+ if (answer?.kind === "value") return {
6256
6343
  keep: true,
6257
6344
  value: answer.value
6345
+ };
6346
+ return keepMarker ? {
6347
+ keep: true,
6348
+ value: v
6258
6349
  } : {
6259
6350
  keep: false,
6260
6351
  value: void 0
@@ -6271,7 +6362,7 @@ async function resolveSecretMarkers(value, secrets) {
6271
6362
  value: items
6272
6363
  };
6273
6364
  }
6274
- if (isRecord(v)) {
6365
+ if (isRecord$1(v)) {
6275
6366
  const out = {};
6276
6367
  for (const [k, child] of Object.entries(v)) {
6277
6368
  const s = substitute(child);
@@ -6292,14 +6383,152 @@ async function resolveSecretMarkers(value, secrets) {
6292
6383
  unresolved
6293
6384
  };
6294
6385
  }
6295
- function touchesTree(tree, patch) {
6296
- if (tree.size === 0) return false;
6297
- for (const key of Object.keys(patch)) {
6298
- const at = key.indexOf("@");
6299
- if (tree.has(at > 0 ? key.slice(0, at) : key)) return true;
6386
+ /** An addon tried to replace a stored secret it could not read. Nothing was written. */
6387
+ var SecretOverwriteRefusedError = class extends Error {
6388
+ ref;
6389
+ reason;
6390
+ constructor(ref, reason) {
6391
+ 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.`);
6392
+ this.ref = ref;
6393
+ this.reason = reason;
6394
+ this.name = "SecretOverwriteRefusedError";
6395
+ }
6396
+ };
6397
+ function isRecord(value) {
6398
+ return typeof value === "object" && value !== null && !Array.isArray(value);
6399
+ }
6400
+ function resolvedValue(pass, marker) {
6401
+ const answer = pass.answers[marker.$secret];
6402
+ return answer?.kind === "value" ? answer.value : null;
6403
+ }
6404
+ async function atMarker(pass, incoming, stored) {
6405
+ if (incoming === null) return stored;
6406
+ if (typeof incoming !== "string") return incoming;
6407
+ if (incoming === resolvedValue(pass, stored)) return stored;
6408
+ const intent = classifySecretWrite(incoming);
6409
+ if (intent.kind !== "set") return stored;
6410
+ const ref = stored.$secret;
6411
+ if (!isSecretRefOwnedBy(ref, pass.secrets.owner)) return incoming;
6412
+ const answer = pass.answers[ref];
6413
+ 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);
6414
+ try {
6415
+ await pass.secrets.put(ref, intent.value);
6416
+ } catch (err) {
6417
+ throw new KeychainWriteRefusedError(ref, err);
6418
+ }
6419
+ pass.changedRefs.push(ref);
6420
+ return stored;
6421
+ }
6422
+ function inArray(pass, incoming, stored) {
6423
+ return incoming.map((item, index) => {
6424
+ const twin = stored[index];
6425
+ if (isSecretMarker(twin)) return typeof item === "string" && item === resolvedValue(pass, twin) ? twin : item;
6426
+ if (isRecord(item) && isRecord(twin)) return inArrayRow(pass, item, twin);
6427
+ if (Array.isArray(item) && Array.isArray(twin)) return inArray(pass, item, twin);
6428
+ return item;
6429
+ });
6430
+ }
6431
+ function inArrayRow(pass, incoming, stored) {
6432
+ const out = { ...incoming };
6433
+ for (const [key, value] of Object.entries(incoming)) {
6434
+ const twin = stored[key];
6435
+ if (isSecretMarker(twin)) {
6436
+ if (typeof value === "string" && value === resolvedValue(pass, twin)) out[key] = twin;
6437
+ } else if (isRecord(value) && isRecord(twin)) out[key] = inArrayRow(pass, value, twin);
6438
+ else if (Array.isArray(value) && Array.isArray(twin)) out[key] = inArray(pass, value, twin);
6439
+ }
6440
+ return out;
6441
+ }
6442
+ async function walk(pass, incoming, stored) {
6443
+ if (isSecretMarker(stored)) return atMarker(pass, incoming, stored);
6444
+ if (Array.isArray(incoming) && Array.isArray(stored)) return inArray(pass, incoming, stored);
6445
+ if (!isRecord(incoming) || !isRecord(stored)) return incoming;
6446
+ const out = { ...incoming };
6447
+ for (const [key, value] of Object.entries(incoming)) out[key] = await walk(pass, value, stored[key]);
6448
+ return out;
6449
+ }
6450
+ /** Restore markers a write-back carries as values. See the file doc. */
6451
+ async function restoreUnchangedSecrets(input) {
6452
+ const refs = [];
6453
+ for (const key of Object.keys(input.patch)) collectSecretMarkerRefs(input.stored[key], refs);
6454
+ const owned = refs.filter((ref) => isSecretRefOwnedBy(ref, input.secrets.owner));
6455
+ if (owned.length === 0) return {
6456
+ patch: input.patch,
6457
+ changedRefs: []
6458
+ };
6459
+ const pass = {
6460
+ secrets: input.secrets,
6461
+ answers: await input.secrets.resolve([...new Set(owned)]),
6462
+ operatorWrite: input.operatorWrite,
6463
+ changedRefs: []
6464
+ };
6465
+ const out = {};
6466
+ for (const [key, value] of Object.entries(input.patch)) out[key] = await walk(pass, value, input.stored[key]);
6467
+ return {
6468
+ patch: out,
6469
+ changedRefs: pass.changedRefs
6470
+ };
6471
+ }
6472
+ /** Structural equality over JSON-shaped values (key order does not matter). */
6473
+ function isJsonEqual(a, b) {
6474
+ if (Object.is(a, b)) return true;
6475
+ if (Array.isArray(a)) return Array.isArray(b) && a.length === b.length && a.every((v, i) => isJsonEqual(v, b[i]));
6476
+ if (isRecord(a) && isRecord(b)) {
6477
+ const keys = Object.keys(a);
6478
+ if (keys.length !== Object.keys(b).length) return false;
6479
+ return keys.every((k) => Object.prototype.hasOwnProperty.call(b, k) && isJsonEqual(a[k], b[k]));
6300
6480
  }
6301
6481
  return false;
6302
6482
  }
6483
+ /** The patch without the keys whose value already equals the stored one. */
6484
+ function dropUnchangedKeys(patch, stored) {
6485
+ const out = {};
6486
+ for (const [key, value] of Object.entries(patch)) {
6487
+ if (Object.prototype.hasOwnProperty.call(stored, key) && isJsonEqual(value, stored[key])) continue;
6488
+ out[key] = value;
6489
+ }
6490
+ return out;
6491
+ }
6492
+ /** The top-level keys of a blob that hold at least one of `owner`'s markers. */
6493
+ function markerKeysOf(blob, owner) {
6494
+ const keys = /* @__PURE__ */ new Set();
6495
+ for (const [key, value] of Object.entries(blob)) if (collectSecretMarkerRefs(value).some((ref) => isSecretRefOwnedBy(ref, owner))) keys.add(key);
6496
+ return keys;
6497
+ }
6498
+ function nodeFromStored(value, owner) {
6499
+ if (isSecretMarker(value)) return isSecretRefOwnedBy(value.$secret, owner) ? { kind: "leaf" } : null;
6500
+ if (!isRecord(value)) return null;
6501
+ const children = /* @__PURE__ */ new Map();
6502
+ for (const [key, child] of Object.entries(value)) {
6503
+ const node = nodeFromStored(child, owner);
6504
+ if (node !== null) children.set(key, node);
6505
+ }
6506
+ return children.size > 0 ? {
6507
+ kind: "object",
6508
+ children
6509
+ } : null;
6510
+ }
6511
+ /**
6512
+ * The declared secret tree, widened by every place the STORED blob holds a
6513
+ * marker under one of `keys` — so a marker the schema no longer declares (or
6514
+ * never declared: Wyze before b4906cec6) still gets the save path's
6515
+ * KEEP / SET / CLEAR semantics instead of being overwritten by whatever the
6516
+ * addon writes. Markers inside arrays are not added: a row has no id field to
6517
+ * match by unless the schema declares one. Only `owner`'s markers count: a
6518
+ * builtin that keeps another addon's marker (device-manager) never takes it
6519
+ * over.
6520
+ */
6521
+ function widenTreeWithStoredMarkers(declared, stored, keys, owner) {
6522
+ const added = /* @__PURE__ */ new Map();
6523
+ for (const key of keys) {
6524
+ const at = key.indexOf("@");
6525
+ const base = at > 0 ? key.slice(0, at) : key;
6526
+ if (declared.has(base) || added.has(base)) continue;
6527
+ const node = nodeFromStored(stored[key], owner);
6528
+ if (node !== null) added.set(base, node);
6529
+ }
6530
+ return added.size === 0 ? declared : new Map([...declared, ...added]);
6531
+ }
6303
6532
  /** The blob as stored now; a failed read REFUSES the write instead of guessing. */
6304
6533
  async function readStoredAddonBlob(raw) {
6305
6534
  const threeWay = raw.readAddonStoreResult;
@@ -6308,7 +6537,41 @@ async function readStoredAddonBlob(raw) {
6308
6537
  if (result.kind === "failed") throw new Error(`settings write refused: the stored blob could not be read (${result.error})`);
6309
6538
  return result.kind === "missing" ? {} : result.value;
6310
6539
  }
6311
- function createSecretAwareSettings(raw, opts) {
6540
+ function touchesTree(tree, patch) {
6541
+ if (tree.size === 0) return false;
6542
+ for (const key of Object.keys(patch)) {
6543
+ const at = key.indexOf("@");
6544
+ if (tree.has(at > 0 ? key.slice(0, at) : key)) return true;
6545
+ }
6546
+ return false;
6547
+ }
6548
+ /**
6549
+ * Which top-level keys of each store held markers when last seen. `undefined`
6550
+ * for a store not seen yet: its first write reads it, to be safe.
6551
+ */
6552
+ var MarkerKeyIndex = class {
6553
+ owner;
6554
+ byStore = /* @__PURE__ */ new Map();
6555
+ constructor(owner) {
6556
+ this.owner = owner;
6557
+ }
6558
+ seen(store, blob) {
6559
+ this.byStore.set(store, markerKeysOf(blob, this.owner));
6560
+ }
6561
+ wrote(store, patch) {
6562
+ const keys = this.byStore.get(store);
6563
+ if (keys === void 0) return;
6564
+ const now = markerKeysOf(patch, this.owner);
6565
+ for (const key of Object.keys(patch)) if (now.has(key)) keys.add(key);
6566
+ else keys.delete(key);
6567
+ }
6568
+ mayHoldMarkers(store, patch) {
6569
+ const keys = this.byStore.get(store);
6570
+ if (keys === void 0) return true;
6571
+ return Object.keys(patch).some((key) => keys.has(key));
6572
+ }
6573
+ };
6574
+ function createHandle(raw, opts) {
6312
6575
  const chains = /* @__PURE__ */ new Map();
6313
6576
  const serialize = (key, fn) => {
6314
6577
  const next = (chains.get(key) ?? Promise.resolve()).then(fn, fn);
@@ -6319,46 +6582,130 @@ function createSecretAwareSettings(raw, opts) {
6319
6582
  });
6320
6583
  return next;
6321
6584
  };
6322
- const write = async (chainKey, tree, scope, patch, readStored, rawWrite) => {
6323
- if (!touchesTree(tree, patch)) return rawWrite(patch);
6324
- return serialize(chainKey, async () => {
6585
+ const index = new MarkerKeyIndex(opts.secrets.owner);
6586
+ const resolveRead = async (store, blob) => {
6587
+ index.seen(store, blob);
6588
+ const { value, unresolved } = await resolveSecretMarkers(blob, opts.secrets, {
6589
+ unresolved: "keep-marker",
6590
+ ownedBy: opts.secrets.owner
6591
+ });
6592
+ if (unresolved.length > 0) opts.onUnresolved?.(unresolved);
6593
+ return value;
6594
+ };
6595
+ const write = async (store, declared, scope, patch, readStored, rawWrite) => {
6596
+ if (!touchesTree(declared, patch) && !index.mayHoldMarkers(store, patch)) {
6597
+ await rawWrite(patch);
6598
+ index.wrote(store, patch);
6599
+ return { changed: true };
6600
+ }
6601
+ return serialize(store, async () => {
6325
6602
  const stored = await readStored();
6603
+ index.seen(store, stored);
6604
+ const operatorWrite = opts.isOperatorWrite?.() === true;
6605
+ const restored = await restoreUnchangedSecrets({
6606
+ patch,
6607
+ stored,
6608
+ secrets: opts.secrets,
6609
+ operatorWrite
6610
+ });
6326
6611
  const result = await transformSecretWrite({
6327
- tree,
6612
+ tree: widenTreeWithStoredMarkers(declared, stored, Object.keys(restored.patch), opts.secrets.owner),
6328
6613
  secrets: opts.secrets,
6329
- patch,
6614
+ patch: restored.patch,
6330
6615
  stored,
6331
6616
  ...scope !== void 0 ? { scope } : {},
6332
- operatorWrite: opts.isOperatorWrite?.() === true
6617
+ operatorWrite
6333
6618
  });
6334
- if (Object.keys(result.patch).length > 0) await rawWrite(result.patch);
6619
+ const effective = dropUnchangedKeys(result.patch, stored);
6620
+ const wroteBlob = Object.keys(effective).length > 0;
6621
+ if (wroteBlob) {
6622
+ await rawWrite(effective);
6623
+ index.wrote(store, effective);
6624
+ }
6335
6625
  const { orphaned } = await result.afterWrite();
6336
6626
  if (orphaned.length > 0) opts.onOrphaned(orphaned);
6627
+ return { changed: wroteBlob || restored.changedRefs.length > 0 };
6337
6628
  });
6338
6629
  };
6339
- const wrapped = {
6340
- writeAddonStore: (patch) => write("addon", opts.addonTree(), void 0, patch, () => readStoredAddonBlob(raw), (p) => raw.writeAddonStore(p)),
6341
- writeDeviceStore: (deviceId, patch) => write(`device:${deviceId}`, opts.deviceTree(), {
6342
- kind: "device",
6343
- deviceId
6344
- }, patch, () => raw.readDeviceStore(deviceId), (p) => raw.writeDeviceStore(deviceId, p))
6630
+ const writeAddon = (patch) => write("addon", opts.addonTree(), void 0, patch, () => readStoredAddonBlob(raw), (p) => raw.writeAddonStore(p));
6631
+ const readAddonStoreResult = raw.readAddonStoreResult;
6632
+ const readAddonStoreKeyResult = raw.readAddonStoreKeyResult;
6633
+ const readDeviceStoreBatch = raw.readDeviceStoreBatch;
6634
+ const overrides = {
6635
+ readAddonStore: async () => resolveRead("addon", await raw.readAddonStore()),
6636
+ ...readAddonStoreResult !== void 0 ? { readAddonStoreResult: async () => {
6637
+ const result = await readAddonStoreResult.call(raw);
6638
+ return result.kind === "value" ? {
6639
+ kind: "value",
6640
+ value: await resolveRead("addon", result.value)
6641
+ } : result;
6642
+ } } : {},
6643
+ ...readAddonStoreKeyResult !== void 0 ? { readAddonStoreKeyResult: async (key) => {
6644
+ const result = await readAddonStoreKeyResult.call(raw, key);
6645
+ if (result.kind !== "present") return result;
6646
+ const { value, unresolved } = await resolveSecretMarkers({ [key]: result.value }, opts.secrets, {
6647
+ unresolved: "keep-marker",
6648
+ ownedBy: opts.secrets.owner
6649
+ });
6650
+ if (unresolved.length > 0) opts.onUnresolved?.(unresolved);
6651
+ return {
6652
+ kind: "present",
6653
+ value: value[key]
6654
+ };
6655
+ } } : {},
6656
+ readDeviceStore: async (deviceId) => resolveRead(`device:${deviceId}`, await raw.readDeviceStore(deviceId)),
6657
+ ...readDeviceStoreBatch !== void 0 ? { readDeviceStoreBatch: async (deviceIds) => {
6658
+ const rows = await readDeviceStoreBatch.call(raw, deviceIds);
6659
+ const out = /* @__PURE__ */ new Map();
6660
+ for (const [deviceId, blob] of rows) out.set(deviceId, await resolveRead(`device:${deviceId}`, blob));
6661
+ return out;
6662
+ } } : {},
6663
+ writeAddonStore: async (patch) => {
6664
+ await writeAddon(patch);
6665
+ },
6666
+ writeDeviceStore: async (deviceId, patch) => {
6667
+ await write(`device:${deviceId}`, opts.deviceTree(), {
6668
+ kind: "device",
6669
+ deviceId
6670
+ }, patch, () => raw.readDeviceStore(deviceId), (p) => raw.writeDeviceStore(deviceId, p));
6671
+ }
6672
+ };
6673
+ return {
6674
+ settings: new Proxy(raw, { get(target, prop, receiver) {
6675
+ if (typeof prop === "string" && Object.prototype.hasOwnProperty.call(overrides, prop)) return Reflect.get(overrides, prop);
6676
+ const value = Reflect.get(target, prop, receiver);
6677
+ return typeof value === "function" ? value.bind(target) : value;
6678
+ } }),
6679
+ raw: {
6680
+ readAddonStore: async () => {
6681
+ const blob = await raw.readAddonStore();
6682
+ index.seen("addon", blob);
6683
+ return blob;
6684
+ },
6685
+ readDeviceStore: async (deviceId) => {
6686
+ const blob = await raw.readDeviceStore(deviceId);
6687
+ index.seen(`device:${deviceId}`, blob);
6688
+ return blob;
6689
+ }
6690
+ },
6691
+ writeAddonStore: writeAddon
6345
6692
  };
6346
- return new Proxy(raw, { get(target, prop, receiver) {
6347
- if (prop === "writeAddonStore") return wrapped.writeAddonStore;
6348
- if (prop === "writeDeviceStore") return wrapped.writeDeviceStore;
6349
- const value = Reflect.get(target, prop, receiver);
6350
- return typeof value === "function" ? value.bind(target) : value;
6351
- } });
6352
6693
  }
6353
- /** The context the addon sees: identical, except that its settings writes are secret-aware. */
6354
- function withSecretAwareSettings(context, opts) {
6694
+ /** The context the addon sees, plus the private raw view and write outcome. */
6695
+ function createSecretAwareContext(context, opts) {
6355
6696
  const raw = context.settings;
6356
- if (raw === void 0) return context;
6357
- const settings = createSecretAwareSettings(raw, opts);
6358
- return new Proxy(context, { get(target, prop, receiver) {
6359
- if (prop === "settings") return settings;
6360
- return Reflect.get(target, prop, receiver);
6361
- } });
6697
+ if (raw === void 0) return {
6698
+ context,
6699
+ handle: null
6700
+ };
6701
+ const handle = createHandle(raw, opts);
6702
+ return {
6703
+ context: new Proxy(context, { get(target, prop, receiver) {
6704
+ if (prop === "settings") return handle.settings;
6705
+ return Reflect.get(target, prop, receiver);
6706
+ } }),
6707
+ handle
6708
+ };
6362
6709
  }
6363
6710
  var LEAF = { kind: "leaf" };
6364
6711
  var DEFAULT_ITEM_ID_KEY = "id";
@@ -6533,6 +6880,14 @@ var BaseAddon = class {
6533
6880
  _secretChangeUnsub = null;
6534
6881
  /** >0 while an OPERATOR's settings write is being applied. */
6535
6882
  _operatorWriteDepth = 0;
6883
+ /**
6884
+ * The keychain-aware settings handle (D798). Its `raw` view is the ONLY way
6885
+ * to the marker-bearing blobs and stays private to this class: the form
6886
+ * hydrate and config resolution need markers, addon code never does.
6887
+ */
6888
+ _secretSettings = null;
6889
+ /** Refs an addon-facing read could not resolve — each is logged once per process. */
6890
+ _loggedUnresolvedReads = /* @__PURE__ */ new Set();
6536
6891
  constructor(defaults) {
6537
6892
  this.defaults = defaults;
6538
6893
  this._config = { ...defaults };
@@ -6569,13 +6924,21 @@ var BaseAddon = class {
6569
6924
  }
6570
6925
  async initialize(context) {
6571
6926
  const secrets = context.secrets;
6572
- this._ctx = secrets !== void 0 ? withSecretAwareSettings(context, {
6573
- secrets,
6574
- addonTree: () => this.addonSecretTree(),
6575
- deviceTree: () => this.deviceSecretTree(),
6576
- onOrphaned: (refs) => context.logger.warn("keychain refs dropped by a settings write could not be deleted", { meta: { refs: [...refs] } }),
6577
- isOperatorWrite: () => this._operatorWriteDepth > 0
6578
- }) : context;
6927
+ if (secrets !== void 0) {
6928
+ const { context: wrapped, handle } = createSecretAwareContext(context, {
6929
+ secrets,
6930
+ addonTree: () => this.addonSecretTree(),
6931
+ deviceTree: () => this.deviceSecretTree(),
6932
+ onOrphaned: (refs) => context.logger.warn("keychain refs dropped by a settings write could not be deleted", { meta: { refs: [...refs] } }),
6933
+ isOperatorWrite: () => this._operatorWriteDepth > 0,
6934
+ onUnresolved: (unresolved) => this.logUnresolvedRead(unresolved)
6935
+ });
6936
+ this._ctx = wrapped;
6937
+ this._secretSettings = handle;
6938
+ } else {
6939
+ this._ctx = context;
6940
+ this._secretSettings = null;
6941
+ }
6579
6942
  await this.resolveConfig();
6580
6943
  if (secrets !== void 0) this._secretChangeUnsub = secrets.onChange((ref) => {
6581
6944
  if (this._configSecretRefs.has(ref)) this.scheduleSecretReresolve(SECRET_CHANGE_DEBOUNCE_MS);
@@ -6692,11 +7055,8 @@ var BaseAddon = class {
6692
7055
  async getGlobalSettings(overlay, cap, nodeId) {
6693
7056
  const schema = this.globalSettingsSchema(cap);
6694
7057
  if (!schema) return { sections: [] };
6695
- const projected = await this.resolveGlobalStore(nodeId, cap);
6696
- return hydrateSchema(schema, overlay ? {
6697
- ...projected,
6698
- ...overlay
6699
- } : projected, { inlineSecretsAsViews: true });
7058
+ const projected = await this.readRawProjectedStore(nodeId, cap);
7059
+ return hydrateSchema(schema, overlay ? await this.overlayKeepingMarkers(projected, overlay) : projected, { inlineSecretsAsViews: true });
6700
7060
  }
6701
7061
  /**
6702
7062
  * The integration-level view of this addon's settings: exactly the sections
@@ -6741,7 +7101,7 @@ var BaseAddon = class {
6741
7101
  });
6742
7102
  }
6743
7103
  if (sections.length === 0) return null;
6744
- const projected = await this.resolveGlobalStore(nodeId);
7104
+ const projected = await this.readRawProjectedStore(nodeId);
6745
7105
  return hydrateSchema({
6746
7106
  ...schema,
6747
7107
  sections
@@ -6758,12 +7118,50 @@ var BaseAddon = class {
6758
7118
  * the store for custom option logic (option narrowing, value snapping) to
6759
7119
  * read it per-node — never `ctx.settings.readAddonStore()` directly.
6760
7120
  * `nodeId` omitted ⇒ the local node (node-blind injection from ctx).
7121
+ *
7122
+ * Keychain values come back RESOLVED (D798): a secret reads as its value,
7123
+ * never as a `{ $secret }` marker. One the keychain cannot serve right now
7124
+ * stays a marker — "stored, unavailable" (`isSecretMarker()` is true, and it
7125
+ * is listed in {@link unresolvedSecrets}) — never `''` and never absent, so
7126
+ * it cannot be mistaken for "nothing stored, mint a new one". Writing the
7127
+ * resolved blob back is a no-op for every unchanged secret.
6761
7128
  */
6762
7129
  async resolveGlobalStore(nodeId, cap) {
6763
7130
  const raw = await this._ctx?.settings?.readAddonStore() ?? {};
7131
+ return this.projectForNode(raw, nodeId, cap);
7132
+ }
7133
+ projectForNode(store, nodeId, cap) {
6764
7134
  const keys = this.perNodeKeys(cap);
6765
7135
  const node = normalizeNodeId(nodeId ?? this._ctx?.kernel?.localNodeId);
6766
- return keys.size > 0 ? projectStore(raw, keys, node) : raw;
7136
+ return keys.size > 0 ? projectStore(store, keys, node) : store;
7137
+ }
7138
+ /** The PROJECTED store with its markers — the form hydrate only (D798). */
7139
+ async readRawProjectedStore(nodeId, cap) {
7140
+ const raw = await this.rawSettings()?.readAddonStore() ?? {};
7141
+ return this.projectForNode(raw, nodeId, cap);
7142
+ }
7143
+ /**
7144
+ * `{ ...stored, ...overlay }`, except that an overlay member equal to the
7145
+ * RESOLVED stored one keeps the stored (marker-bearing) member — so a form
7146
+ * hydrated from a resolved overlay still shows a secret as "set", never as
7147
+ * its value.
7148
+ */
7149
+ async overlayKeepingMarkers(stored, overlay) {
7150
+ const secrets = this._ctx?.secrets;
7151
+ const merged = {
7152
+ ...stored,
7153
+ ...overlay
7154
+ };
7155
+ if (secrets === void 0 || collectSecretMarkerRefs(stored).length === 0) return merged;
7156
+ const { value: resolved } = await resolveSecretMarkers(stored, secrets, {
7157
+ unresolved: "keep-marker",
7158
+ ownedBy: secrets.owner
7159
+ });
7160
+ for (const key of Object.keys(overlay)) {
7161
+ if (collectSecretMarkerRefs(stored[key]).length === 0) continue;
7162
+ if (isJsonEqual(overlay[key], resolved[key])) merged[key] = stored[key];
7163
+ }
7164
+ return merged;
6767
7165
  }
6768
7166
  /**
6769
7167
  * Whether ONE global key of this addon's store was written, read three-way
@@ -6828,8 +7226,12 @@ var BaseAddon = class {
6828
7226
  async clearSecrets(keys, nodeId) {
6829
7227
  const tree = this.addonSecretTree();
6830
7228
  const keychain = this._ctx?.secrets !== void 0;
7229
+ const stored = keychain ? await this.readAddonStoreWithRetry() : {};
6831
7230
  const patch = {};
6832
- for (const key of keys) patch[key] = keychain && tree.has(key) ? SECRET_CLEAR : "";
7231
+ for (const key of keys) {
7232
+ const keychainStored = tree.has(key) || collectSecretMarkerRefs(stored[key]).length > 0;
7233
+ patch[key] = keychain && keychainStored ? SECRET_CLEAR : "";
7234
+ }
6833
7235
  await this.applyGlobalPatch(patch, nodeId);
6834
7236
  }
6835
7237
  async applyGlobalPatch(barePatch, nodeId) {
@@ -6837,7 +7239,11 @@ var BaseAddon = class {
6837
7239
  const localNode = normalizeNodeId(this._ctx?.kernel?.localNodeId);
6838
7240
  const target = normalizeNodeId(nodeId ?? this._ctx?.kernel?.localNodeId);
6839
7241
  const scoped = keys.size > 0 ? scopePatch(barePatch, keys, target) : barePatch;
6840
- await this._ctx?.settings?.writeAddonStore(scoped);
7242
+ const handle = this._secretSettings;
7243
+ if (handle !== null) {
7244
+ const { changed } = await handle.writeAddonStore(scoped);
7245
+ if (!changed) return;
7246
+ } else await this._ctx?.settings?.writeAddonStore(scoped);
6841
7247
  if (target !== localNode) return;
6842
7248
  await this.resolveConfig();
6843
7249
  await this.onConfigChanged();
@@ -6890,7 +7296,7 @@ var BaseAddon = class {
6890
7296
  async getDeviceSettings(deviceId) {
6891
7297
  const schema = this.deviceSettingsSchema();
6892
7298
  if (!schema) return { sections: [] };
6893
- return hydrateSchema(schema, await this._ctx?.settings?.readDeviceStore(deviceId) ?? {}, { inlineSecretsAsViews: true });
7299
+ return hydrateSchema(schema, await this.rawSettings()?.readDeviceStore(deviceId) ?? {}, { inlineSecretsAsViews: true });
6894
7300
  }
6895
7301
  async updateDeviceSettings(deviceId, patch) {
6896
7302
  await this._ctx?.settings?.writeDeviceStore(deviceId, patch);
@@ -7062,7 +7468,7 @@ var BaseAddon = class {
7062
7468
  key,
7063
7469
  schema,
7064
7470
  fallback,
7065
- read: async () => this.resolveStoredSecrets(await this._ctx?.settings?.readDeviceStore(deviceId) ?? {}, false),
7471
+ read: async () => this.resolveStoredSecrets(await this.rawSettings()?.readDeviceStore(deviceId) ?? {}, false),
7066
7472
  write: async (patch) => {
7067
7473
  await this._ctx?.settings?.writeDeviceStore(deviceId, patch);
7068
7474
  },
@@ -7124,6 +7530,23 @@ var BaseAddon = class {
7124
7530
  }
7125
7531
  return value;
7126
7532
  }
7533
+ /**
7534
+ * The marker-bearing settings reads (D798) — private on purpose. Without a
7535
+ * keychain the context's own view is already raw.
7536
+ */
7537
+ rawSettings() {
7538
+ return this._secretSettings?.raw ?? this._ctx?.settings;
7539
+ }
7540
+ /** An addon-facing read met markers it could not resolve: say so once per ref. */
7541
+ logUnresolvedRead(unresolved) {
7542
+ const fresh = unresolved.filter((u) => !this._loggedUnresolvedReads.has(u.ref));
7543
+ if (fresh.length === 0) return;
7544
+ for (const u of fresh) this._loggedUnresolvedReads.add(u.ref);
7545
+ 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) => ({
7546
+ ref: u.ref,
7547
+ reason: u.reason
7548
+ })) } });
7549
+ }
7127
7550
  /** Re-resolve the config (a keychain-only change, or a retry) and apply it. */
7128
7551
  scheduleSecretReresolve(delayMs) {
7129
7552
  const timerOf = delayMs === SECRET_CHANGE_DEBOUNCE_MS ? "_secretChangeTimer" : "_secretRetryTimer";
@@ -7150,7 +7573,7 @@ var BaseAddon = class {
7150
7573
  * `{}` (defaults) — the addon's first successful patch will rehydrate.
7151
7574
  */
7152
7575
  async readAddonStoreWithRetry() {
7153
- const settings = this._ctx?.settings;
7576
+ const settings = this.rawSettings();
7154
7577
  if (!settings) return {};
7155
7578
  const delaysMs = [
7156
7579
  150,
@@ -9577,6 +10000,278 @@ var CameraSwitchGroupSchema = object({
9577
10000
  fetchedAt: number()
9578
10001
  });
9579
10002
  /**
10003
+ * The trainer contract — what the hub hands the cloud trainer and what it
10004
+ * gets back (cloud training, D805+).
10005
+ *
10006
+ * The trainer (`hf/camstack-trainer`, published as the Hugging Face repo
10007
+ * `camstack/camstack-trainer`) is a separate AGPL program the hub never
10008
+ * imports: `job.json` goes in, files come out, and progress is `CAMSTACK_EVENT`
10009
+ * lines on stdout. These schemas are the hub's half of that boundary; the
10010
+ * trainer's pydantic models (and the JSON Schemas generated from them under
10011
+ * `hf/camstack-trainer/schemas/`) are the other half. A change here is a
10012
+ * change there, in the same piece of work.
10013
+ *
10014
+ * No `.default()` anywhere: defaults do not run on the addon cap path, so the
10015
+ * orchestrator fills every field of a job spec explicitly.
10016
+ */
10017
+ var TRAINING_JOB_SCHEMA = "camstack.training/v1";
10018
+ var TRAINING_RESULT_SCHEMA = "camstack.training-result/v1";
10019
+ /** What the trainer can export. Edge TPU is a later, separate image. */
10020
+ var TrainingExportSchema = _enum([
10021
+ "onnx",
10022
+ "openvino-fp16",
10023
+ "openvino-int8",
10024
+ "coreml-fp16"
10025
+ ]);
10026
+ var FloorsSchema = record(string(), number().min(0).max(1));
10027
+ object({
10028
+ schema: literal(TRAINING_JOB_SCHEMA),
10029
+ jobKey: string().uuid(),
10030
+ target: object({
10031
+ kind: literal("detector"),
10032
+ step: literal("object-detection")
10033
+ }),
10034
+ base: object({
10035
+ modelId: string().min(1),
10036
+ /** Ultralytics weights id, e.g. `yolov9m.pt`. */
10037
+ weights: string().min(1),
10038
+ imgsz: number().int().positive()
10039
+ }),
10040
+ baseline: object({
10041
+ modelId: string().min(1),
10042
+ /** The baseline ONNX the holdout comparison runs; public mirror URL. */
10043
+ onnxUrl: string().url(),
10044
+ imgsz: number().int().positive(),
10045
+ floors: FloorsSchema
10046
+ }),
10047
+ dataset: object({
10048
+ versionId: string().min(1),
10049
+ annotationHash: string(),
10050
+ /** sha256 of the uploaded archive; the trainer refuses a mismatch (exit 65). */
10051
+ sha256: string().regex(/^[0-9a-f]{64}$/)
10052
+ }),
10053
+ split: object({
10054
+ holdoutCameras: array(number().int()),
10055
+ /** When no camera is held out: the last N days of every camera. */
10056
+ holdoutLastDays: number().int().nonnegative(),
10057
+ valFraction: number().min(0).max(.5),
10058
+ seed: number().int()
10059
+ }),
10060
+ hyper: object({
10061
+ epochs: number().int().positive(),
10062
+ batch: number().int().positive(),
10063
+ lr0: number().positive(),
10064
+ /** Layers frozen from the start of the backbone; 0 = none. */
10065
+ freeze: number().int().nonnegative(),
10066
+ patience: number().int().nonnegative(),
10067
+ seed: number().int()
10068
+ }),
10069
+ replay: object({
10070
+ source: literal("coco2017"),
10071
+ count: number().int().nonnegative()
10072
+ }),
10073
+ exports: array(TrainingExportSchema).min(1),
10074
+ calibration: object({ maxFrames: number().int().positive() }),
10075
+ floors: object({
10076
+ minSupport: number().int().positive(),
10077
+ clamp: number().min(0).max(1)
10078
+ }),
10079
+ int8Gate: object({ maxMap50Drop: number().min(0).max(1) }),
10080
+ catalog: object({
10081
+ id: string().regex(/^[a-z0-9][a-z0-9-]{2,80}$/),
10082
+ name: string().min(1).max(160)
10083
+ })
10084
+ });
10085
+ /** One regular file of the bundle. An mlpackage contributes one row per member. */
10086
+ var TrainingResultFileSchema = object({
10087
+ path: string().min(1),
10088
+ bytes: number().int().nonnegative(),
10089
+ sha256: string().regex(/^[0-9a-f]{64}$/),
10090
+ format: _enum([
10091
+ "onnx",
10092
+ "openvino",
10093
+ "coreml",
10094
+ "pt"
10095
+ ]),
10096
+ variant: _enum(["base", "int8"])
10097
+ });
10098
+ var DraftFormatSchema = object({
10099
+ /** RELATIVE path inside the bundle; the hub rewrites it to `camstack-local://`. */
10100
+ url: string().min(1),
10101
+ sizeMB: number().nonnegative(),
10102
+ isDirectory: boolean().optional(),
10103
+ files: array(string()).optional(),
10104
+ runtimes: array(literal("python")).optional(),
10105
+ revision: string().min(1)
10106
+ });
10107
+ /** The trainer's half of a catalog entry; the hub completes it (labels, licence, group). */
10108
+ var TrainingCatalogDraftSchema = object({
10109
+ id: string().min(1),
10110
+ name: string().min(1),
10111
+ description: string(),
10112
+ labels: array(unknown()),
10113
+ inputSize: object({
10114
+ width: number().int().positive(),
10115
+ height: number().int().positive()
10116
+ }),
10117
+ preprocessMode: literal("letterbox"),
10118
+ defaultClassFloors: FloorsSchema,
10119
+ formats: object({
10120
+ onnx: DraftFormatSchema.optional(),
10121
+ openvino: DraftFormatSchema.optional(),
10122
+ coreml: DraftFormatSchema.optional()
10123
+ })
10124
+ });
10125
+ /** One class of one model's holdout report (the eval harness's summary). */
10126
+ var TrainingEvalClassSchema = object({
10127
+ positives: number().int(),
10128
+ floor: number().nullable(),
10129
+ tp: number().int(),
10130
+ fp: number().int(),
10131
+ fn: number().int(),
10132
+ precision: number().nullable(),
10133
+ recall: number().nullable(),
10134
+ ap50: number().nullable(),
10135
+ recallByCamera: record(string(), number().nullable()).optional(),
10136
+ recallByLight: record(string(), number().nullable()).optional(),
10137
+ fpByCamera: record(string(), number()).optional(),
10138
+ smallFound: number().int().optional(),
10139
+ smallTotal: number().int().optional()
10140
+ }).passthrough();
10141
+ var TrainingEvalReportSchema = object({
10142
+ frames: number().int(),
10143
+ classes: record(string(), TrainingEvalClassSchema)
10144
+ }).passthrough();
10145
+ /**
10146
+ * A succeeded result carries every block; a failed one carries the error and
10147
+ * whatever was known by then — the other blocks are ABSENT, not null. The
10148
+ * orchestrator checks the blocks it needs before it trusts a success.
10149
+ */
10150
+ var TrainingResultSchema = object({
10151
+ schema: literal(TRAINING_RESULT_SCHEMA),
10152
+ jobKey: string(),
10153
+ status: _enum(["succeeded", "failed"]),
10154
+ error: object({
10155
+ stage: string(),
10156
+ code: string(),
10157
+ message: string()
10158
+ }).nullable(),
10159
+ trainer: object({
10160
+ version: string(),
10161
+ revision: string()
10162
+ }),
10163
+ toolchain: record(string(), string().nullable()),
10164
+ dataset: object({
10165
+ versionId: string(),
10166
+ annotationHash: string(),
10167
+ sha256: string(),
10168
+ frames: object({
10169
+ train: number().int(),
10170
+ val: number().int(),
10171
+ holdout: number().int()
10172
+ }),
10173
+ holdoutCameras: array(number().int()),
10174
+ replayImages: number().int()
10175
+ }).optional(),
10176
+ training: object({
10177
+ epochsRun: number().int(),
10178
+ bestEpoch: number().int(),
10179
+ bestMap50: number(),
10180
+ bestMap50_95: number(),
10181
+ seconds: number()
10182
+ }).optional(),
10183
+ evaluation: object({
10184
+ holdoutFrames: number().int(),
10185
+ baseline: TrainingEvalReportSchema.nullable(),
10186
+ candidate: TrainingEvalReportSchema.nullable(),
10187
+ candidateInt8: TrainingEvalReportSchema.nullable(),
10188
+ recallDeltaByCamera: record(string(), record(string(), number())).nullable(),
10189
+ map50: record(string(), number().nullable())
10190
+ }).optional(),
10191
+ floors: object({
10192
+ baseline: FloorsSchema,
10193
+ candidate: FloorsSchema,
10194
+ candidateInt8: FloorsSchema.nullable(),
10195
+ notes: array(string())
10196
+ }).optional(),
10197
+ int8: object({
10198
+ kept: boolean(),
10199
+ map50Fp16: number().nullable(),
10200
+ map50Int8: number().nullable(),
10201
+ reason: string().nullable()
10202
+ }).optional(),
10203
+ exportsDropped: array(object({
10204
+ export: string(),
10205
+ reason: string()
10206
+ })).optional(),
10207
+ files: array(TrainingResultFileSchema).optional(),
10208
+ bundle: object({
10209
+ path: literal("bundle.tar"),
10210
+ bytes: number().int().nonnegative(),
10211
+ sha256: string().regex(/^[0-9a-f]{64}$/)
10212
+ }).nullable().optional(),
10213
+ catalogDraft: object({
10214
+ base: TrainingCatalogDraftSchema,
10215
+ int8: TrainingCatalogDraftSchema.nullable()
10216
+ }).nullable().optional(),
10217
+ licence: string()
10218
+ });
10219
+ var TrainingStageSchema = _enum([
10220
+ "prepare",
10221
+ "replay",
10222
+ "train",
10223
+ "eval",
10224
+ "export",
10225
+ "package"
10226
+ ]);
10227
+ var EventBase = {
10228
+ v: literal(1),
10229
+ ts: number()
10230
+ };
10231
+ discriminatedUnion("type", [
10232
+ object({
10233
+ ...EventBase,
10234
+ type: literal("stage"),
10235
+ stage: TrainingStageSchema
10236
+ }),
10237
+ object({
10238
+ ...EventBase,
10239
+ type: literal("epoch"),
10240
+ epoch: number().int(),
10241
+ epochs: number().int(),
10242
+ boxLoss: number().nullable().optional(),
10243
+ map50: number().nullable().optional(),
10244
+ map50_95: number().nullable().optional(),
10245
+ etaSec: number().nullable().optional()
10246
+ }),
10247
+ object({
10248
+ ...EventBase,
10249
+ type: literal("metric"),
10250
+ name: string(),
10251
+ value: number()
10252
+ }),
10253
+ object({
10254
+ ...EventBase,
10255
+ type: literal("artifact"),
10256
+ path: string(),
10257
+ bytes: number(),
10258
+ sha256: string()
10259
+ }),
10260
+ object({
10261
+ ...EventBase,
10262
+ type: literal("done"),
10263
+ status: _enum(["succeeded", "failed"]),
10264
+ resultSha256: string().nullable().optional()
10265
+ }),
10266
+ object({
10267
+ ...EventBase,
10268
+ type: literal("error"),
10269
+ stage: string(),
10270
+ code: string(),
10271
+ message: string()
10272
+ })
10273
+ ]);
10274
+ /**
9580
10275
  * What the gate decided about a birth, from the CALLER's point of view.
9581
10276
  *
9582
10277
  * Deliberately not `ConfirmationVerdict`: `undecided` is not a birth decision
@@ -11999,7 +12694,9 @@ var AddonHttpRouteSchema = object({
11999
12694
  "authenticated",
12000
12695
  "admin"
12001
12696
  ]).optional(),
12002
- description: string().optional()
12697
+ description: string().optional(),
12698
+ /** The hub limits this route per client address before the handler runs. */
12699
+ rateLimit: _enum(["auth"]).optional()
12003
12700
  });
12004
12701
  /**
12005
12702
  * Cross-process route invocation envelope. The hub captures the
@@ -12723,6 +13420,37 @@ var BackupDestinationInfoSchema = object({
12723
13420
  lastError: string().optional()
12724
13421
  });
12725
13422
  /**
13423
+ * How an archive is encrypted (operator decision 2026-10-09): to a backup
13424
+ * PUBLIC key the hub holds, so only the operator's secret key opens it.
13425
+ * Absent on a plain `.tar.gz` — every archive made before encryption, or
13426
+ * with it off — which restores without a key.
13427
+ */
13428
+ var BackupArchiveEncryptionSchema = object({
13429
+ /** `x25519-hkdf-aes256gcm-stream-v1`. */
13430
+ scheme: string(),
13431
+ /** 16 hex — the backup key whose secret restores this archive. */
13432
+ keyId: string()
13433
+ });
13434
+ /**
13435
+ * The backup encryption setting. The hub keeps PUBLIC keys only: the active
13436
+ * one new archives are encrypted to, and the retired ones older archives
13437
+ * still need. The secret key is shown once, at `setupEncryption`.
13438
+ */
13439
+ var BackupEncryptionStatusSchema = object({
13440
+ enabled: boolean(),
13441
+ active: object({
13442
+ keyId: string(),
13443
+ publicKey: string(),
13444
+ createdAt: number()
13445
+ }).nullable(),
13446
+ /** Every key ever set up, newest first. */
13447
+ keys: array(object({
13448
+ keyId: string(),
13449
+ createdAt: number(),
13450
+ retiredAt: number().nullable()
13451
+ })).readonly()
13452
+ });
13453
+ /**
12726
13454
  * Per-archive entry returned by `backup.listArchives({ destinationId })`.
12727
13455
  * Same shape the destination drill-in renders. Sourced from the per-
12728
13456
  * location `manifests.json` (no per-archive tarball read required).
@@ -12734,7 +13462,9 @@ var BackupArchiveEntrySchema = object({
12734
13462
  sizeBytes: number(),
12735
13463
  label: string().optional(),
12736
13464
  /** Top-level locations included in the archive (db, addons, tls, …). */
12737
- locations: array(string()).readonly()
13465
+ locations: array(string()).readonly(),
13466
+ /** Present when the archive is encrypted; restore then needs that key. */
13467
+ encryption: BackupArchiveEncryptionSchema.optional()
12738
13468
  });
12739
13469
  var BackupEntrySchema = object({
12740
13470
  id: string(),
@@ -12743,7 +13473,8 @@ var BackupEntrySchema = object({
12743
13473
  label: string().optional(),
12744
13474
  createdAt: number(),
12745
13475
  sizeBytes: number(),
12746
- locations: array(string()).optional()
13476
+ locations: array(string()).optional(),
13477
+ encryption: BackupArchiveEncryptionSchema.optional()
12747
13478
  });
12748
13479
  var ArchiveEntrySchema = object({
12749
13480
  path: string(),
@@ -12932,10 +13663,40 @@ method(_void(), array(BackupDestinationInfoSchema).readonly(), { auth: "admin" }
12932
13663
  * this list and skips entries whose path doesn't start with
12933
13664
  * any of them.
12934
13665
  */
12935
- locations: array(string()).optional()
13666
+ locations: array(string()).optional(),
13667
+ /**
13668
+ * The backup SECRET key, for an encrypted archive (ignored for a plain
13669
+ * one). The archive is decrypted into the hub's private staging
13670
+ * before the restart; the key is not stored. A wrong or missing key
13671
+ * is refused before the archive is downloaded.
13672
+ */
13673
+ backupSecretKey: string().optional()
12936
13674
  }), _void(), {
12937
13675
  kind: "mutation",
12938
13676
  auth: "admin"
13677
+ }), method(_void(), BackupEncryptionStatusSchema, { auth: "admin" }), method(object({}), object({
13678
+ keyId: string(),
13679
+ secretKey: string(),
13680
+ publicKey: string(),
13681
+ createdAt: number(),
13682
+ replacedKeyId: string().nullable()
13683
+ }), {
13684
+ kind: "mutation",
13685
+ auth: "admin"
13686
+ }), method(object({}), object({ disabledKeyId: string().nullable() }), {
13687
+ kind: "mutation",
13688
+ auth: "admin"
13689
+ }), method(object({ backupSecretKey: string() }), object({
13690
+ valid: boolean(),
13691
+ keyId: string().nullable(),
13692
+ /** The hub knows this key (active or retired). */
13693
+ known: boolean(),
13694
+ /** It is the key new archives are encrypted to. */
13695
+ active: boolean(),
13696
+ error: string().optional()
13697
+ }), {
13698
+ kind: "mutation",
13699
+ auth: "admin"
12939
13700
  }), method(object({
12940
13701
  destinationId: string(),
12941
13702
  backupId: string()
@@ -14559,7 +15320,60 @@ var CustomModelDescriptorSchema = object({
14559
15320
  stepId: string(),
14560
15321
  entry: ModelCatalogEntrySchema
14561
15322
  });
14562
- method(_void(), array(CustomModelDescriptorSchema).readonly(), { auth: "admin" });
15323
+ /** One regular file of an imported bundle, as the producer measured it. */
15324
+ var ModelBundleFileSchema = object({
15325
+ /** Relative path inside the bundle tar; an mlpackage member is `<x>.mlpackage/<member>`. */
15326
+ path: string().min(1),
15327
+ bytes: number().int().nonnegative(),
15328
+ sha256: string().regex(/^[0-9a-f]{64}$/)
15329
+ });
15330
+ var ImportModelBundleInputSchema = object({
15331
+ /** The registry provider that keeps the model (Model Studio). */
15332
+ addonId: string(),
15333
+ stepId: string().min(1),
15334
+ /**
15335
+ * The catalog rows to register, complete, every format URL already
15336
+ * `camstack-local://<modelId>/<file>` naming a file of the bundle. One
15337
+ * bundle may carry several rows (a base and its INT8 variant).
15338
+ */
15339
+ entries: array(ModelCatalogEntrySchema).min(1).max(4),
15340
+ /** The bundle tar, offered by the producer over `ctx.peerBytes` (same host). */
15341
+ bundle: object({
15342
+ ticket: PeerBytesTicketSchema,
15343
+ bytes: number().int().positive(),
15344
+ sha256: string().regex(/^[0-9a-f]{64}$/)
15345
+ }),
15346
+ /** Every file the tar must hold; anything missing, extra or different is refused. */
15347
+ files: array(ModelBundleFileSchema).min(1).max(64),
15348
+ /** Convert missing engine formats and push the model to every agent afterwards. */
15349
+ distribute: boolean()
15350
+ });
15351
+ var ImportModelBundleResultSchema = discriminatedUnion("kind", [object({
15352
+ kind: literal("imported"),
15353
+ modelIds: array(string()).readonly(),
15354
+ distributed: array(object({
15355
+ modelId: string(),
15356
+ nodeId: string(),
15357
+ format: _enum(MODEL_FORMATS),
15358
+ ok: boolean(),
15359
+ error: string().optional()
15360
+ })).readonly()
15361
+ }), object({
15362
+ kind: literal("refused"),
15363
+ reason: _enum([
15364
+ "transfer-failed",
15365
+ "checksum-mismatch",
15366
+ "bundle-mismatch",
15367
+ "invalid-entry",
15368
+ "id-taken"
15369
+ ]),
15370
+ detail: string()
15371
+ })]);
15372
+ method(_void(), array(CustomModelDescriptorSchema).readonly(), { auth: "admin" }), method(ImportModelBundleInputSchema, ImportModelBundleResultSchema, {
15373
+ kind: "mutation",
15374
+ auth: "admin",
15375
+ timeoutMs: 30 * 6e4
15376
+ });
14563
15377
  /**
14564
15378
  * Query filter for settings-store collections.
14565
15379
  */
@@ -15038,6 +15852,35 @@ var KeychainKeySourceSchema = object({
15038
15852
  */
15039
15853
  sharesBackupWithDatabase: boolean()
15040
15854
  });
15855
+ /**
15856
+ * One keychain reset, as the Secrets page reports it until the operator
15857
+ * acknowledges it. Never a value: refs, counts and table names only.
15858
+ */
15859
+ var KeychainResetRecordSchema = object({
15860
+ id: string(),
15861
+ at: number(),
15862
+ /** `user:<id>` or {@link KEYCHAIN_RESET_TRIGGER_ACTOR}. */
15863
+ actor: string(),
15864
+ /** Why the keychain was locked when it was reset; `null` when it was not locked. */
15865
+ lockedReason: string().nullable(),
15866
+ /** Values moved into the archive table (ciphertext under the lost key). */
15867
+ archived: number().int(),
15868
+ /** `keychain:secrets-orphaned-<ts>`, or `null` when nothing was stored. */
15869
+ archivedCollection: string().nullable(),
15870
+ /**
15871
+ * `keychain:keys-orphaned-<ts>`: the wrapped data keys of the archive, kept
15872
+ * so the archive can still be opened if the lost master key turns up.
15873
+ */
15874
+ archivedKeysCollection: string().nullable(),
15875
+ /**
15876
+ * `system-settings` keys whose marker the reset cleared — the cluster
15877
+ * secret's: a marker left pointing at an archived value would refuse every
15878
+ * agent forever (D797).
15879
+ */
15880
+ clearedSettingsKeys: array(string()).readonly(),
15881
+ /** When an operator dismissed the notice on the Secrets page; `null` until then. */
15882
+ acknowledgedAt: number().nullable()
15883
+ });
15041
15884
  var KeychainStatusSchema = object({
15042
15885
  keychain: KeychainStateSchema,
15043
15886
  /** The source of the master key in use; `null` while locked. */
@@ -15055,7 +15898,9 @@ var KeychainStatusSchema = object({
15055
15898
  /** Wrapped copies of the data key under a previous master key, kept until purged. */
15056
15899
  retiredWraps: number().int(),
15057
15900
  recoveryKeyDownloadedAt: number().nullable(),
15058
- secretCount: number().int()
15901
+ secretCount: number().int(),
15902
+ /** The most recent reset, acknowledged or not; `null` when the keychain was never reset. */
15903
+ lastReset: KeychainResetRecordSchema.nullable()
15059
15904
  });
15060
15905
  /**
15061
15906
  * Whether a stored value is still pointed at by its owner's settings.
@@ -15077,17 +15922,26 @@ var KeychainAuditActionSchema = _enum([
15077
15922
  "download-recovery-key",
15078
15923
  "delete-orphans",
15079
15924
  "reset",
15925
+ "acknowledge-reset",
15080
15926
  "initialize"
15081
15927
  ]);
15082
15928
  var KeychainAuditEntrySchema = object({
15083
15929
  id: string(),
15084
15930
  at: number(),
15085
15931
  action: KeychainAuditActionSchema,
15086
- /** `addon:<id>` | `user:<id>` | `system`. */
15932
+ /** `addon:<id>` | `user:<id>` | `system` | `trigger-file`. */
15087
15933
  actor: string(),
15088
15934
  ref: string().nullable(),
15089
15935
  detail: string().nullable()
15090
15936
  });
15937
+ var KEYCHAIN_RESET_CONFIRMATION = "RESET KEYCHAIN";
15938
+ /**
15939
+ * Secrets the HUB itself holds (owner `system`) that no settings form shows:
15940
+ * `jwt-signing-key` — the session signing key (D797). It is always "in use",
15941
+ * never an orphan; it is generated on a fresh hub and replaced only through
15942
+ * {@link keychainAdminCapability.methods.setSystemSecret}.
15943
+ */
15944
+ var SystemHeldSecretNameSchema = _enum(["jwt-signing-key"]);
15091
15945
  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({
15092
15946
  value: string(),
15093
15947
  version: number().int()
@@ -15095,6 +15949,16 @@ method(object({}), KeychainStatusSchema, { auth: "admin" }), method(object({}),
15095
15949
  kind: "mutation",
15096
15950
  auth: "admin",
15097
15951
  caller: "required"
15952
+ }), method(object({
15953
+ name: SystemHeldSecretNameSchema,
15954
+ value: string().min(16)
15955
+ }), object({
15956
+ ref: string(),
15957
+ version: number().int()
15958
+ }), {
15959
+ kind: "mutation",
15960
+ auth: "admin",
15961
+ caller: "required"
15098
15962
  }), method(object({ refs: array(string().min(1)).max(1e3) }), object({
15099
15963
  deleted: array(string()).readonly(),
15100
15964
  kept: array(object({
@@ -15124,13 +15988,20 @@ method(object({}), KeychainStatusSchema, { auth: "admin" }), method(object({}),
15124
15988
  kind: "mutation",
15125
15989
  auth: "admin",
15126
15990
  caller: "required"
15127
- }), method(object({ confirm: literal("RESET KEYCHAIN") }), object({
15991
+ }), method(object({ confirm: literal(KEYCHAIN_RESET_CONFIRMATION) }), object({
15128
15992
  archivedCollection: string().nullable(),
15129
15993
  archived: number().int()
15130
15994
  }), {
15131
15995
  kind: "mutation",
15132
15996
  auth: "admin",
15133
15997
  caller: "required"
15998
+ }), method(object({}), object({
15999
+ reset: KeychainResetRecordSchema.nullable(),
16000
+ pendingReentry: array(KeychainSecretMetaSchema).readonly()
16001
+ }), { auth: "admin" }), method(object({}), object({ acknowledged: boolean() }), {
16002
+ kind: "mutation",
16003
+ auth: "admin",
16004
+ caller: "required"
15134
16005
  });
15135
16006
  method(_void(), object({
15136
16007
  id: string(),
@@ -17801,7 +18672,7 @@ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
17801
18672
  * `login-method` — collection cap through which auth addons contribute
17802
18673
  * their pre-auth login surfaces to the login page. This is the SINGLE,
17803
18674
  * generic mechanism that supersedes the dead `auth.listProviders` reader:
17804
- * every auth addon (OIDC, magic-link, WebAuthn/passkey) registers a
18675
+ * every auth addon (OIDC, WebAuthn/passkey) registers a
17805
18676
  * `login-method` provider and the PUBLIC `auth.listLoginMethods`
17806
18677
  * procedure aggregates them for the unauthenticated login page.
17807
18678
  *
@@ -17809,8 +18680,7 @@ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
17809
18680
  *
17810
18681
  * - `redirect` — a declarative button. The login page renders a generic
17811
18682
  * button that navigates to `startUrl` (an addon-owned HTTP route).
17812
- * Covers OIDC (`/addon/auth-oidc/<id>/start`) and magic-link with
17813
- * ZERO shell-side JS. A future SSO addon plugs in the same way — the
18683
+ * Covers OIDC (`/addon/auth-oidc/<id>/start`) with ZERO shell-side JS. A future SSO addon plugs in the same way — the
17814
18684
  * login page needs NO change.
17815
18685
  *
17816
18686
  * - `widget` — a Module-Federation widget the login page mounts (via
@@ -17829,8 +18699,8 @@ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
17829
18699
  * decision.
17830
18700
  *
17831
18701
  * Every contribution carries a `stage`:
17832
- * - `primary` — shown on the first credentials screen (OIDC /
17833
- * magic-link buttons; a future usernameless passkey).
18702
+ * - `primary` — shown on the first credentials screen (OIDC
18703
+ * buttons; a usernameless passkey).
17834
18704
  * - `second-factor` — shown AFTER the password leg, gated on the
17835
18705
  * returned `factors` (passkey-as-2FA today).
17836
18706
  *
@@ -17857,7 +18727,7 @@ var LoginMethodContributionSchema = discriminatedUnion("kind", [
17857
18727
  * The provider names an external identity a signed-in user can link to
17858
18728
  * their own account (D782): `auth.listLinkableProviders` /
17859
18729
  * `beginExternalLink` offer exactly the redirect methods that set this,
17860
- * whatever their id. Absent / false — a login button only (magic-link).
18730
+ * whatever their id. Absent / false — a login button only.
17861
18731
  */
17862
18732
  linkable: boolean().optional()
17863
18733
  }),
@@ -21674,8 +22544,7 @@ method(object({}), object({ rules: array(NcRuleSchema) }), { auth: "admin" }), m
21674
22544
  * `super_admin` — collapsed onto the single boolean because every
21675
22545
  * non-admin caller is governed by the same scope-check rules; the
21676
22546
  * distinction was only ever used to route role-specific procedures
21677
- * which we no longer have. Agents are admin sessions issued via
21678
- * `createServiceToken`; CLI / webhook integrations are `cst_*` tokens
22547
+ * which we no longer have. CLI / webhook integrations are `cst_*` tokens
21679
22548
  * with `isAdmin: false` + an explicit scope list.
21680
22549
  */
21681
22550
  /** Per-method access flavour. Materialised on every cap method via codegen. */
@@ -23366,6 +24235,9 @@ var RetrainExportFilterSchema = object({
23366
24235
  frameIds: array(string()).max(2e4).optional(),
23367
24236
  /** Only frames in at least one of these named collections. */
23368
24237
  collectionIds: array(string()).max(200).optional(),
24238
+ /** Exactly the frames of this dataset version (and its completeOnly). An
24239
+ * unknown id selects nothing. */
24240
+ datasetVersionId: string().optional(),
23369
24241
  batchId: string().optional(),
23370
24242
  /** Only frames the operator marked complete (all subjects boxed). */
23371
24243
  completeOnly: boolean().optional()
@@ -23533,6 +24405,67 @@ var RetrainLlmAssistResultSchema = discriminatedUnion("kind", [object({
23533
24405
  ]),
23534
24406
  detail: string().optional()
23535
24407
  })]);
24408
+ /** What a dataset version is cut from. Every field narrows. */
24409
+ var RetrainDatasetSelectionSchema = object({
24410
+ deviceIds: array(number()).readonly().optional(),
24411
+ collectionIds: array(string()).max(200).readonly().optional(),
24412
+ frameIds: array(string()).max(2e4).readonly().optional()
24413
+ });
24414
+ /** The counts a dataset is judged by. */
24415
+ var RetrainDatasetStatsSchema = object({
24416
+ frames: number().int(),
24417
+ completeFrames: number().int(),
24418
+ /** `completeFrames / frames`, 0..1. */
24419
+ completeness: number(),
24420
+ /** Boxes to learn (model errors excluded). */
24421
+ subjects: number().int(),
24422
+ modelErrors: number().int(),
24423
+ /** Complete frames with no subject. */
24424
+ hardNegatives: number().int(),
24425
+ /** Subjects per class × camera × day/night. */
24426
+ cells: array(object({
24427
+ macroClass: string(),
24428
+ deviceId: number(),
24429
+ lighting: _enum([
24430
+ "day",
24431
+ "night",
24432
+ "unknown"
24433
+ ]),
24434
+ subjects: number().int(),
24435
+ frames: number().int()
24436
+ })).readonly(),
24437
+ cameras: array(object({
24438
+ deviceId: number(),
24439
+ frames: number().int(),
24440
+ completeFrames: number().int()
24441
+ })).readonly()
24442
+ });
24443
+ /** An immutable dataset version, without its frame list. */
24444
+ var RetrainDatasetVersionSchema = object({
24445
+ id: string(),
24446
+ name: string(),
24447
+ createdAt: number(),
24448
+ selection: RetrainDatasetSelectionSchema,
24449
+ layout: RetrainExportLayoutSchema,
24450
+ completeOnly: boolean(),
24451
+ frameCount: number().int(),
24452
+ /** sha256 of what the frames taught when the version was frozen. */
24453
+ annotationHash: string(),
24454
+ /** The export manifest schema the version was cut under. */
24455
+ manifestSchema: string(),
24456
+ stats: RetrainDatasetStatsSchema
24457
+ });
24458
+ var CreateRetrainDatasetVersionResultSchema = discriminatedUnion("kind", [object({
24459
+ kind: literal("created"),
24460
+ version: RetrainDatasetVersionSchema
24461
+ }), object({
24462
+ kind: literal("refused"),
24463
+ reason: _enum([
24464
+ "empty-name",
24465
+ "duplicate-name",
24466
+ "no-frames"
24467
+ ])
24468
+ })]);
23536
24469
  /** The outcome of a lifecycle move owned by the retrain page. */
23537
24470
  var RetrainTransitionResultSchema = object({
23538
24471
  trackId: string(),
@@ -24322,6 +25255,47 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema$1).r
24322
25255
  kind: "mutation",
24323
25256
  auth: "admin",
24324
25257
  timeoutMs: 60 * 6e4
25258
+ }), method(object({
25259
+ filter: RetrainExportFilterSchema,
25260
+ layout: RetrainExportLayoutSchema
25261
+ }), object({
25262
+ ticket: PeerBytesTicketSchema,
25263
+ frames: number().int(),
25264
+ annotations: number().int()
25265
+ }), {
25266
+ kind: "mutation",
25267
+ auth: "admin",
25268
+ timeoutMs: 12e4
25269
+ }), method(object({
25270
+ selection: RetrainDatasetSelectionSchema,
25271
+ completeOnly: boolean().optional()
25272
+ }), RetrainDatasetStatsSchema, {
25273
+ kind: "query",
25274
+ auth: "admin"
25275
+ }), method(object({
25276
+ name: string().max(120),
25277
+ selection: RetrainDatasetSelectionSchema,
25278
+ layout: RetrainExportLayoutSchema,
25279
+ completeOnly: boolean()
25280
+ }), CreateRetrainDatasetVersionResultSchema, {
25281
+ kind: "mutation",
25282
+ auth: "admin",
25283
+ timeoutMs: 12e4
25284
+ }), method(object({}), array(RetrainDatasetVersionSchema).readonly(), {
25285
+ kind: "query",
25286
+ auth: "admin"
25287
+ }), method(object({ id: string() }), object({ deleted: boolean() }), {
25288
+ kind: "mutation",
25289
+ auth: "admin"
25290
+ }), method(object({ id: string() }), object({
25291
+ found: boolean(),
25292
+ annotationHash: string(),
25293
+ matches: boolean(),
25294
+ missingFrames: number().int()
25295
+ }), {
25296
+ kind: "query",
25297
+ auth: "admin",
25298
+ timeoutMs: 12e4
24325
25299
  }), method(object({}), array(RetrainAssistProfileSchema).readonly(), {
24326
25300
  kind: "query",
24327
25301
  auth: "admin"
@@ -27860,8 +28834,8 @@ version: string().optional() }), ServerUpdateActionResultSchema, {
27860
28834
  * `smtp-provider` — pluggable email delivery surface.
27861
28835
  *
27862
28836
  * Collection cap: a deployment may install multiple SMTP relays (e.g.
27863
- * one for transactional / one for notifications). Consumers (magic-link,
27864
- * notifier addons, …) walk the collection and pick the first
28837
+ * one for transactional / one for notifications). Consumers (notifier
28838
+ * addons, …) walk the collection and pick the first
27865
28839
  * ready provider OR target a specific addonId.
27866
28840
  *
27867
28841
  * The shape stays small on purpose — `sendEmail` is enough for the
@@ -28040,7 +29014,7 @@ targets: array(object({
28040
29014
  })));
28041
29015
  /**
28042
29016
  * `sso-bridge` — internal hub-only cap that lets SSO-style auth
28043
- * providers (OIDC, SAML, magic-link, …) mint an HMAC-signed token
29017
+ * providers (OIDC, SAML, …) mint an HMAC-signed token
28044
29018
  * carrying the post-callback claims before redirecting back to
28045
29019
  * `/api/auth/sso/finish`.
28046
29020
  *
@@ -28103,7 +29077,14 @@ var SsoBridgeClaimsSchema = object({
28103
29077
  * Verified `iss` of the id_token behind an OIDC login bridge (D782). A
28104
29078
  * subject is unique only per issuer, so a link is bound to it.
28105
29079
  */
28106
- issuer: string().optional()
29080
+ issuer: string().optional(),
29081
+ /**
29082
+ * SHA-256 (hex) of the `camstack_sso_state` cookie the IdP `/start` set in
29083
+ * the browser that began this sign-in. `/api/auth/sso/finish` requires the
29084
+ * request to present the matching cookie — a login bridge is useless in
29085
+ * any other browser.
29086
+ */
29087
+ browserBinding: string().optional()
28107
29088
  });
28108
29089
  method(object({
28109
29090
  claims: SsoBridgeClaimsSchema,
@@ -34027,7 +35008,13 @@ var TopologyNodeSchema = object({
34027
35008
  })).readonly(),
34028
35009
  processes: array(TopologyProcessSchema).readonly(),
34029
35010
  categories: array(TopologyCategorySchema).readonly(),
34030
- rootPackage: TopologyRootPackageSchema.nullable()
35011
+ rootPackage: TopologyRootPackageSchema.nullable(),
35012
+ /**
35013
+ * How an online AGENT reaches the hub (mesh mTLS Release A): `tls` once it has
35014
+ * completed a mutual-TLS handshake, `clear` otherwise. Absent for the hub,
35015
+ * for offline rows and when the hub cannot tell.
35016
+ */
35017
+ meshTransport: _enum(["tls", "clear"]).optional()
34031
35018
  });
34032
35019
  var CapUsageEdgeSchema = object({
34033
35020
  callerAddonId: string(),
@@ -38078,16 +39065,6 @@ var ApiKeySummarySchema = object({
38078
39065
  createdAt: number(),
38079
39066
  lastUsedAt: number().optional()
38080
39067
  });
38081
- var CreateApiKeyInputSchema = object({
38082
- label: string(),
38083
- isAdmin: boolean().default(false),
38084
- allowedProviders: union([array(string()), literal("*")]).optional(),
38085
- allowedDevices: record(string(), union([array(string()), literal("*")])).optional()
38086
- });
38087
- var CreateApiKeyResultSchema = object({
38088
- token: string(),
38089
- record: ApiKeySummarySchema
38090
- });
38091
39068
  var ScopedTokenSummarySchema = object({
38092
39069
  id: string(),
38093
39070
  userId: string(),
@@ -38186,17 +39163,10 @@ method(_void(), array(UserSummarySchema), { auth: "admin" }), method(CreateUserI
38186
39163
  }), UserSummarySchema.extend({ passwordHash: string() }).nullable(), {
38187
39164
  kind: "mutation",
38188
39165
  access: "view"
38189
- }), method(_void(), array(ApiKeySummarySchema), { auth: "admin" }), method(CreateApiKeyInputSchema, CreateApiKeyResultSchema, {
38190
- kind: "mutation",
38191
- auth: "admin",
38192
- access: "create"
38193
- }), method(object({ id: string() }), object({ success: literal(true) }), {
39166
+ }), method(_void(), array(ApiKeySummarySchema), { auth: "admin" }), method(object({ id: string() }), object({ success: literal(true) }), {
38194
39167
  kind: "mutation",
38195
39168
  auth: "admin",
38196
39169
  access: "delete"
38197
- }), method(object({ token: string() }), ApiKeySummarySchema.nullable(), {
38198
- kind: "mutation",
38199
- access: "view"
38200
39170
  }), method(CreateScopedTokenInputSchema, CreateScopedTokenResultSchema, {
38201
39171
  kind: "mutation",
38202
39172
  auth: "admin",
@@ -38270,15 +39240,7 @@ method(_void(), array(UserSummarySchema), { auth: "admin" }), method(CreateUserI
38270
39240
  }).nullable(), { access: "view" }), method(object({ userId: string() }), array(ExternalIdentitySchema), { auth: "admin" }), method(ExternalIdentityKeySchema, object({
38271
39241
  userId: string(),
38272
39242
  issuer: string()
38273
- }).nullable(), { auth: "admin" }), method(ExternalIdentityKeySchema.extend({
38274
- userId: string(),
38275
- issuer: string().min(1),
38276
- label: string().optional()
38277
- }), object({ success: literal(true) }), {
38278
- kind: "mutation",
38279
- auth: "admin",
38280
- access: "create"
38281
- }), method(ExternalIdentityKeySchema.extend({ userId: string() }), object({ success: boolean() }), {
39243
+ }).nullable(), { auth: "admin" }), method(ExternalIdentityKeySchema.extend({ userId: string() }), object({ success: boolean() }), {
38282
39244
  kind: "mutation",
38283
39245
  auth: "admin",
38284
39246
  access: "delete"
@@ -38673,6 +39635,451 @@ DeviceType.Camera, method(object({
38673
39635
  detection: array(ZoneRuleSchema).readonly(),
38674
39636
  package: array(ZoneRuleSchema).readonly()
38675
39637
  });
39638
+ /**
39639
+ * `training-provider` — ONE cloud that can run the CamStack trainer.
39640
+ *
39641
+ * A thin, mockable translation layer: it knows how to run a container with a
39642
+ * GPU, move a dataset in, read the job's stdout and hand artefacts back. It
39643
+ * knows nothing about datasets, splits, floors, cost policy or Model Studio —
39644
+ * those are the `training` orchestrator's (D805). Every rule written there
39645
+ * once is what makes a second provider (RunPod, a local NVIDIA node) a new
39646
+ * manifest entry and nothing else.
39647
+ *
39648
+ * Collection, routed by the `addonId` in every single-row input (the `llm` /
39649
+ * `notification-output` posture); `describe` concat-fans across providers.
39650
+ * Every method is `admin`: these spend money.
39651
+ *
39652
+ * Every cloud object a provider creates is tagged with the orchestrator's
39653
+ * `jobKey`, so a retried submit finds the job it already started instead of
39654
+ * starting a second GPU, and `listJobs` can find orphans.
39655
+ *
39656
+ * Bytes never ride a cap field: the dataset arrives as a `ctx.peerBytes`
39657
+ * ticket the producer (pipeline-analytics) minted, and artefacts leave as a
39658
+ * ticket the provider mints (D613).
39659
+ */
39660
+ var TrainingGpuOptionSchema = object({
39661
+ id: string(),
39662
+ label: string(),
39663
+ /** List price, USD per GPU-hour, before any region multiplier. */
39664
+ usdPerHour: number().nonnegative(),
39665
+ vramGb: number().nonnegative()
39666
+ });
39667
+ var TrainingRegionOptionSchema = object({
39668
+ /** `''` = any region (the provider's choice). */
39669
+ id: string(),
39670
+ label: string(),
39671
+ priceMultiplier: number().positive()
39672
+ });
39673
+ /**
39674
+ * The provider's per-account settings, as the orchestrator reads them. They
39675
+ * live in the PROVIDER addon's settings (operator decision 2026-10-08: they
39676
+ * depend on the user's account), never hard-coded in the orchestrator.
39677
+ */
39678
+ var TrainingProviderDefaultsSchema = object({
39679
+ gpuType: string(),
39680
+ region: string(),
39681
+ costCapUsd: number().nonnegative(),
39682
+ maxRuntimeSec: number().int().positive(),
39683
+ /** Hours a FAILED job's cloud dataset is kept for debugging; 0 = delete at once. */
39684
+ failedDatasetGraceHours: number().nonnegative()
39685
+ });
39686
+ var TrainingProviderDescriptorSchema = object({
39687
+ addonId: string(),
39688
+ /** `modal`, `runpod`, `fake`, … */
39689
+ kind: string(),
39690
+ label: string(),
39691
+ gpuTypes: array(TrainingGpuOptionSchema).readonly(),
39692
+ regions: array(TrainingRegionOptionSchema).readonly(),
39693
+ maxDatasetBytes: number().int().positive(),
39694
+ maxRuntimeSec: number().int().positive(),
39695
+ freeTierNote: string().optional(),
39696
+ /** Where the data goes, in one sentence the confirm dialog repeats. */
39697
+ dataResidencyNote: string(),
39698
+ /** Credentials are present — never the values. */
39699
+ configured: boolean(),
39700
+ defaults: TrainingProviderDefaultsSchema
39701
+ });
39702
+ var TrainingCredentialCheckSchema = object({
39703
+ ok: boolean(),
39704
+ /** Workspace / account name, when the provider says. */
39705
+ account: string().optional(),
39706
+ reason: _enum([
39707
+ "missing",
39708
+ "invalid",
39709
+ "forbidden",
39710
+ "network",
39711
+ "quota"
39712
+ ]).optional(),
39713
+ detail: string().optional()
39714
+ });
39715
+ var ProviderJobStateSchema = _enum([
39716
+ "pending",
39717
+ "starting",
39718
+ "running",
39719
+ "succeeded",
39720
+ "failed",
39721
+ "cancelled",
39722
+ "lost"
39723
+ ]);
39724
+ var ProviderJobStatusSchema = object({
39725
+ jobKey: string(),
39726
+ providerJobId: string().optional(),
39727
+ state: ProviderJobStateSchema,
39728
+ startedAt: number().optional(),
39729
+ endedAt: number().optional(),
39730
+ exitCode: number().int().optional(),
39731
+ failureReason: string().optional(),
39732
+ gpuType: string(),
39733
+ region: string().optional(),
39734
+ billedSeconds: number().nonnegative(),
39735
+ costUsd: number().nonnegative(),
39736
+ /** True when `costUsd` is runtime × list price, not a billing answer. */
39737
+ costIsEstimate: boolean(),
39738
+ lastFetchedAt: number()
39739
+ });
39740
+ /**
39741
+ * The trainer the job runs, by SOURCE revision: the provider turns it into an
39742
+ * image its own way (Modal builds the published Dockerfile at that revision;
39743
+ * a registry-pull provider maps it to a tag). Recorded on the job and echoed
39744
+ * in `result.json`.
39745
+ */
39746
+ var TrainerSourceRefSchema = object({
39747
+ /** Hugging Face repo id, e.g. `camstack/camstack-trainer`. */
39748
+ repo: string().min(1),
39749
+ /** A commit sha (never a branch) — the job must be reproducible. */
39750
+ revision: string().regex(/^[0-9a-f]{7,64}$/)
39751
+ });
39752
+ var JobRef = {
39753
+ addonId: string(),
39754
+ jobKey: string().uuid()
39755
+ };
39756
+ var TrainingLogLineSchema = object({
39757
+ ts: number(),
39758
+ text: string()
39759
+ });
39760
+ method(object({}), array(TrainingProviderDescriptorSchema).readonly(), { auth: "admin" }), method(object({ addonId: string() }), TrainingCredentialCheckSchema, {
39761
+ kind: "mutation",
39762
+ auth: "admin",
39763
+ timeoutMs: 3e4
39764
+ }), method(object({
39765
+ addonId: string(),
39766
+ gpuType: string(),
39767
+ region: string(),
39768
+ datasetBytes: number().int().nonnegative(),
39769
+ gpuSecondsLow: number().nonnegative(),
39770
+ gpuSecondsHigh: number().nonnegative()
39771
+ }), object({
39772
+ usdLow: number().nonnegative(),
39773
+ usdHigh: number().nonnegative(),
39774
+ notes: array(string()).readonly()
39775
+ }), { auth: "admin" }), method(object({
39776
+ ...JobRef,
39777
+ ticket: PeerBytesTicketSchema
39778
+ }), object({
39779
+ bytes: number().int().nonnegative(),
39780
+ sha256: string()
39781
+ }), {
39782
+ kind: "mutation",
39783
+ auth: "admin",
39784
+ timeoutMs: 120 * 6e4
39785
+ }), method(object({
39786
+ ...JobRef,
39787
+ trainer: TrainerSourceRefSchema,
39788
+ jobSpecJson: string().min(2).max(64e3),
39789
+ gpuType: string(),
39790
+ region: string(),
39791
+ maxRuntimeSec: number().int().positive()
39792
+ }), ProviderJobStatusSchema, {
39793
+ kind: "mutation",
39794
+ auth: "admin",
39795
+ timeoutMs: 30 * 6e4
39796
+ }), method(object(JobRef), ProviderJobStatusSchema, {
39797
+ auth: "admin",
39798
+ timeoutMs: 6e4
39799
+ }), method(object({
39800
+ ...JobRef,
39801
+ cursor: string().optional(),
39802
+ max: number().int().min(1).max(500)
39803
+ }), object({
39804
+ lines: array(TrainingLogLineSchema).readonly(),
39805
+ cursor: string()
39806
+ }), {
39807
+ auth: "admin",
39808
+ timeoutMs: 6e4
39809
+ }), method(object(JobRef), object({ ok: literal(true) }), {
39810
+ kind: "mutation",
39811
+ auth: "admin",
39812
+ timeoutMs: 6e4
39813
+ }), method(object(JobRef), object({
39814
+ found: boolean(),
39815
+ text: string().optional()
39816
+ }), {
39817
+ kind: "mutation",
39818
+ auth: "admin",
39819
+ timeoutMs: 5 * 6e4
39820
+ }), method(object({
39821
+ ...JobRef,
39822
+ path: _enum(["bundle.tar"])
39823
+ }), object({ ticket: PeerBytesTicketSchema }), {
39824
+ kind: "mutation",
39825
+ auth: "admin",
39826
+ timeoutMs: 5 * 6e4
39827
+ }), method(object(JobRef), object({ deleted: array(string()).readonly() }), {
39828
+ kind: "mutation",
39829
+ auth: "admin",
39830
+ timeoutMs: 5 * 6e4
39831
+ }), method(object({ addonId: string() }), array(ProviderJobStatusSchema).readonly(), {
39832
+ auth: "admin",
39833
+ timeoutMs: 2 * 6e4
39834
+ });
39835
+ /**
39836
+ * `training` — the cloud-training orchestrator (D805). Hub-only singleton,
39837
+ * provided by `addon-training`.
39838
+ *
39839
+ * It owns what every provider must agree on, written once:
39840
+ *
39841
+ * - **Dataset versions.** Taken over from pipeline-analytics (D796): the rows
39842
+ * live here (D808); pipeline-analytics still CUTS a version (it owns the corpus and
39843
+ * the export plan) and reaches this store through the five row methods
39844
+ * below, so the Retrain page and the export did not change.
39845
+ * - **Jobs.** A persisted state machine, a reconcile loop against the
39846
+ * provider, a cost guard, a daily orphan sweep and the retention rules.
39847
+ * - **The return flow.** Verified artefacts → Model Studio
39848
+ * (`custom-model-registry.importModelBundle`) → canary on cameras →
39849
+ * rollback. Nothing is ever registered automatically.
39850
+ *
39851
+ * Every method is `admin`.
39852
+ */
39853
+ /** A version WITH its frame list — what the export and a job read. */
39854
+ var TrainingDatasetVersionRowSchema = RetrainDatasetVersionSchema.omit({ frameCount: true }).extend({ frameIds: array(string()).max(2e4).readonly() });
39855
+ /** A base model a detector job can fine-tune, and the baseline it is judged against. */
39856
+ var TrainingBaseModelSchema = object({
39857
+ modelId: string(),
39858
+ label: string(),
39859
+ weights: string(),
39860
+ imgsz: number().int(),
39861
+ baselineOnnxUrl: string(),
39862
+ baselineFloors: record(string(), number()),
39863
+ /** The base the fleet runs most — the UI's default. */
39864
+ recommended: boolean()
39865
+ });
39866
+ var TrainingPresetSchema = _enum([
39867
+ "quick",
39868
+ "standard",
39869
+ "thorough"
39870
+ ]);
39871
+ var TrainingJobRequestSchema = object({
39872
+ datasetVersionId: string().min(1),
39873
+ /** The `training-provider` addon that runs it. */
39874
+ addonId: string().min(1),
39875
+ gpuType: string().min(1),
39876
+ region: string(),
39877
+ baseModelId: string().min(1),
39878
+ preset: TrainingPresetSchema,
39879
+ /** Freeze the backbone's first N layers; `null` = the preset's choice. */
39880
+ freeze: number().int().nonnegative().nullable(),
39881
+ /** Cameras held out whole for evaluation; `null` = the orchestrator's default. */
39882
+ holdoutCameras: array(number().int()).nullable()
39883
+ });
39884
+ var TrainingSplitPlanSchema = object({
39885
+ holdoutCameras: array(number().int()).readonly(),
39886
+ /** Used when no camera is held out: the last N days of every camera. */
39887
+ holdoutLastDays: number().int().nonnegative(),
39888
+ /** Holdout subjects per class (camera holdout only; `null` = known only after the split). */
39889
+ holdoutSupport: record(string(), number().int()).nullable(),
39890
+ trainSubjects: number().int()
39891
+ });
39892
+ var TrainingRefusalReasonSchema = _enum([
39893
+ "unknown-dataset",
39894
+ "unknown-provider",
39895
+ "provider-not-configured",
39896
+ "unknown-base-model",
39897
+ "unknown-gpu",
39898
+ "dataset-too-large",
39899
+ "no-training-subjects",
39900
+ "job-already-running"
39901
+ ]);
39902
+ var TrainingJobPlanSchema = object({
39903
+ refusal: object({
39904
+ reason: TrainingRefusalReasonSchema,
39905
+ detail: string()
39906
+ }).nullable(),
39907
+ warnings: array(string()).readonly(),
39908
+ split: TrainingSplitPlanSchema.nullable(),
39909
+ estimate: object({
39910
+ datasetBytes: number().int(),
39911
+ uploadMinutesAt20Mbps: number(),
39912
+ gpuSecondsLow: number(),
39913
+ gpuSecondsHigh: number(),
39914
+ usdLow: number(),
39915
+ usdHigh: number(),
39916
+ notes: array(string()).readonly()
39917
+ }).nullable(),
39918
+ /** Pre-filled from the provider's settings; the operator may lower or raise them. */
39919
+ defaults: object({
39920
+ maxCostUsd: number(),
39921
+ maxRuntimeSec: number().int()
39922
+ }).nullable(),
39923
+ /** The sentence the confirm dialog repeats: where the frames go and when they are deleted. */
39924
+ dataNotice: string()
39925
+ });
39926
+ /**
39927
+ * Orchestrator-owned states, persisted. `uploading` covers exporting the
39928
+ * archive (it is streamed, never staged). Terminal: `failed`, `cancelled`,
39929
+ * `lost`, `expired`, `discarded`. `registered` and `canary` are where a
39930
+ * result lives after the operator acted on it.
39931
+ */
39932
+ var TrainingJobStateSchema = _enum([
39933
+ "uploading",
39934
+ "submitted",
39935
+ "starting",
39936
+ "running",
39937
+ "collecting",
39938
+ "ready",
39939
+ "registered",
39940
+ "canary",
39941
+ "failed",
39942
+ "cancelling",
39943
+ "cancelled",
39944
+ "lost",
39945
+ "expired",
39946
+ "discarded"
39947
+ ]);
39948
+ var TrainingFailureReasonSchema = _enum([
39949
+ "cost-cap",
39950
+ "runtime-cap",
39951
+ "upload-failed",
39952
+ "submit-failed",
39953
+ "trainer-failed",
39954
+ "result-invalid",
39955
+ "checksum-mismatch",
39956
+ "fetch-failed",
39957
+ "provider-error",
39958
+ "hub-restart-during-upload"
39959
+ ]);
39960
+ var TrainingProgressPointSchema = object({
39961
+ epoch: number().int(),
39962
+ map50: number().nullable(),
39963
+ map50_95: number().nullable()
39964
+ });
39965
+ var TrainingCanarySchema = object({
39966
+ deviceIds: array(number().int()).readonly(),
39967
+ since: number(),
39968
+ /** Every override the canary replaced, exactly, so rollback restores it. */
39969
+ previous: array(object({
39970
+ deviceId: number().int(),
39971
+ nodeId: string(),
39972
+ deviceKey: string(),
39973
+ patch: object({
39974
+ modelId: string().optional(),
39975
+ settings: record(string(), unknown()).readonly().optional()
39976
+ }).nullable()
39977
+ })).readonly()
39978
+ });
39979
+ var TrainingJobSchema = object({
39980
+ id: string(),
39981
+ idempotencyKey: string(),
39982
+ name: string(),
39983
+ createdAt: number(),
39984
+ updatedAt: number(),
39985
+ state: TrainingJobStateSchema,
39986
+ stage: TrainingStageSchema.nullable(),
39987
+ failure: object({
39988
+ reason: TrainingFailureReasonSchema,
39989
+ stage: string().nullable(),
39990
+ detail: string()
39991
+ }).nullable(),
39992
+ request: TrainingJobRequestSchema,
39993
+ maxCostUsd: number().nonnegative(),
39994
+ maxRuntimeSec: number().int().positive(),
39995
+ trainer: TrainerSourceRefSchema,
39996
+ datasetLayout: RetrainExportLayoutSchema,
39997
+ dataset: object({
39998
+ bytes: number().int(),
39999
+ sha256: string(),
40000
+ uploadedAt: number()
40001
+ }).nullable(),
40002
+ split: TrainingSplitPlanSchema,
40003
+ provider: object({
40004
+ state: ProviderJobStateSchema.nullable(),
40005
+ providerJobId: string().nullable(),
40006
+ startedAt: number().nullable(),
40007
+ endedAt: number().nullable(),
40008
+ billedSeconds: number(),
40009
+ costUsd: number(),
40010
+ costIsEstimate: boolean(),
40011
+ lastPolledAt: number().nullable()
40012
+ }),
40013
+ progress: object({
40014
+ epoch: number().int().nullable(),
40015
+ epochs: number().int().nullable(),
40016
+ etaSec: number().nullable(),
40017
+ series: array(TrainingProgressPointSchema).readonly()
40018
+ }),
40019
+ /** The last lines of the job's output (≤ 200), newest last. Never frame paths. */
40020
+ logTail: array(string()).readonly(),
40021
+ logCursor: string().nullable(),
40022
+ artifacts: object({
40023
+ bundleBytes: number().int(),
40024
+ bundleSha256: string(),
40025
+ fetchedAt: number(),
40026
+ /** When the staged artefacts are deleted from the hub. */
40027
+ expiresAt: number()
40028
+ }).nullable(),
40029
+ /** When the provider-side copy of the frames was deleted; null while it exists. */
40030
+ cloudDatasetDeletedAt: number().nullable(),
40031
+ /** A failed job's dataset is kept until then (the provider's grace), then deleted. */
40032
+ cloudCleanupDueAt: number().nullable(),
40033
+ /** Model ids registered from this job (base, and int8 when kept). */
40034
+ registeredModelIds: array(string()).readonly(),
40035
+ canary: TrainingCanarySchema.nullable()
40036
+ });
40037
+ var IdInput = object({ id: string().min(1) });
40038
+ method(TrainingDatasetVersionRowSchema, object({ stored: boolean() }), {
40039
+ kind: "mutation",
40040
+ auth: "admin"
40041
+ }), 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() }), {
40042
+ kind: "mutation",
40043
+ auth: "admin"
40044
+ }), method(object({}), array(TrainingBaseModelSchema).readonly(), { auth: "admin" }), method(TrainingJobRequestSchema, TrainingJobPlanSchema, {
40045
+ auth: "admin",
40046
+ timeoutMs: 6e4
40047
+ }), method(TrainingJobRequestSchema.extend({
40048
+ name: string().min(1).max(120),
40049
+ maxCostUsd: number().positive(),
40050
+ maxRuntimeSec: number().int().positive(),
40051
+ idempotencyKey: string().min(8).max(80)
40052
+ }), discriminatedUnion("kind", [object({
40053
+ kind: literal("started"),
40054
+ job: TrainingJobSchema
40055
+ }), object({
40056
+ kind: literal("refused"),
40057
+ reason: TrainingRefusalReasonSchema,
40058
+ detail: string()
40059
+ })]), {
40060
+ kind: "mutation",
40061
+ auth: "admin",
40062
+ timeoutMs: 12e4
40063
+ }), method(object({}), array(TrainingJobSchema).readonly(), { auth: "admin" }), method(IdInput, TrainingJobSchema.nullable(), { auth: "admin" }), method(IdInput, TrainingJobSchema, {
40064
+ kind: "mutation",
40065
+ auth: "admin",
40066
+ timeoutMs: 12e4
40067
+ }), method(IdInput, TrainingResultSchema.nullable(), { auth: "admin" }), method(IdInput.extend({ canaryDeviceIds: array(number().int()).readonly() }), TrainingJobSchema, {
40068
+ kind: "mutation",
40069
+ auth: "admin",
40070
+ timeoutMs: 30 * 6e4
40071
+ }), method(IdInput.extend({ deviceIds: array(number().int()).min(1).readonly() }), TrainingJobSchema, {
40072
+ kind: "mutation",
40073
+ auth: "admin",
40074
+ timeoutMs: 12e4
40075
+ }), method(IdInput, TrainingJobSchema, {
40076
+ kind: "mutation",
40077
+ auth: "admin",
40078
+ timeoutMs: 12e4
40079
+ }), method(IdInput, TrainingJobSchema, {
40080
+ kind: "mutation",
40081
+ auth: "admin"
40082
+ });
38676
40083
  SOURCE_CAPS.filter((cap) => cap !== "switch" && cap !== "motion");
38677
40084
  Object.freeze({
38678
40085
  person: .5,
@@ -39296,6 +40703,12 @@ Object.freeze({
39296
40703
  addonId: null,
39297
40704
  access: "create"
39298
40705
  },
40706
+ "backup.checkBackupKey": {
40707
+ capName: "backup",
40708
+ capScope: "system",
40709
+ addonId: null,
40710
+ access: "create"
40711
+ },
39299
40712
  "backup.delete": {
39300
40713
  capName: "backup",
39301
40714
  capScope: "system",
@@ -39308,6 +40721,18 @@ Object.freeze({
39308
40721
  addonId: null,
39309
40722
  access: "delete"
39310
40723
  },
40724
+ "backup.disableEncryption": {
40725
+ capName: "backup",
40726
+ capScope: "system",
40727
+ addonId: null,
40728
+ access: "create"
40729
+ },
40730
+ "backup.getEncryption": {
40731
+ capName: "backup",
40732
+ capScope: "system",
40733
+ addonId: null,
40734
+ access: "view"
40735
+ },
39311
40736
  "backup.getEntries": {
39312
40737
  capName: "backup",
39313
40738
  capScope: "system",
@@ -39362,6 +40787,12 @@ Object.freeze({
39362
40787
  addonId: null,
39363
40788
  access: "create"
39364
40789
  },
40790
+ "backup.setupEncryption": {
40791
+ capName: "backup",
40792
+ capScope: "system",
40793
+ addonId: null,
40794
+ access: "create"
40795
+ },
39365
40796
  "backup.trigger": {
39366
40797
  capName: "backup",
39367
40798
  capScope: "system",
@@ -39914,6 +41345,12 @@ Object.freeze({
39914
41345
  addonId: null,
39915
41346
  access: "create"
39916
41347
  },
41348
+ "customModelRegistry.importModelBundle": {
41349
+ capName: "custom-model-registry",
41350
+ capScope: "system",
41351
+ addonId: null,
41352
+ access: "create"
41353
+ },
39917
41354
  "customModelRegistry.listModels": {
39918
41355
  capName: "custom-model-registry",
39919
41356
  capScope: "system",
@@ -41354,6 +42791,12 @@ Object.freeze({
41354
42791
  addonId: null,
41355
42792
  access: "view"
41356
42793
  },
42794
+ "keychainAdmin.acknowledgeReset": {
42795
+ capName: "keychain-admin",
42796
+ capScope: "system",
42797
+ addonId: null,
42798
+ access: "create"
42799
+ },
41357
42800
  "keychainAdmin.deleteOrphans": {
41358
42801
  capName: "keychain-admin",
41359
42802
  capScope: "system",
@@ -41390,6 +42833,12 @@ Object.freeze({
41390
42833
  addonId: null,
41391
42834
  access: "delete"
41392
42835
  },
42836
+ "keychainAdmin.resetReport": {
42837
+ capName: "keychain-admin",
42838
+ capScope: "system",
42839
+ addonId: null,
42840
+ access: "delete"
42841
+ },
41393
42842
  "keychainAdmin.reveal": {
41394
42843
  capName: "keychain-admin",
41395
42844
  capScope: "system",
@@ -41402,6 +42851,12 @@ Object.freeze({
41402
42851
  addonId: null,
41403
42852
  access: "create"
41404
42853
  },
42854
+ "keychainAdmin.setSystemSecret": {
42855
+ capName: "keychain-admin",
42856
+ capScope: "system",
42857
+ addonId: null,
42858
+ access: "create"
42859
+ },
41405
42860
  "keychainAdmin.status": {
41406
42861
  capName: "keychain-admin",
41407
42862
  capScope: "system",
@@ -42848,6 +44303,12 @@ Object.freeze({
42848
44303
  addonId: null,
42849
44304
  access: "create"
42850
44305
  },
44306
+ "pipelineAnalytics.createRetrainDatasetVersion": {
44307
+ capName: "pipeline-analytics",
44308
+ capScope: "device",
44309
+ addonId: null,
44310
+ access: "create"
44311
+ },
42851
44312
  "pipelineAnalytics.deleteDeviceEvents": {
42852
44313
  capName: "pipeline-analytics",
42853
44314
  capScope: "device",
@@ -42860,6 +44321,12 @@ Object.freeze({
42860
44321
  addonId: null,
42861
44322
  access: "delete"
42862
44323
  },
44324
+ "pipelineAnalytics.deleteRetrainDatasetVersion": {
44325
+ capName: "pipeline-analytics",
44326
+ capScope: "device",
44327
+ addonId: null,
44328
+ access: "delete"
44329
+ },
42863
44330
  "pipelineAnalytics.deleteTracks": {
42864
44331
  capName: "pipeline-analytics",
42865
44332
  capScope: "device",
@@ -43082,6 +44549,12 @@ Object.freeze({
43082
44549
  addonId: null,
43083
44550
  access: "view"
43084
44551
  },
44552
+ "pipelineAnalytics.listRetrainDatasetVersions": {
44553
+ capName: "pipeline-analytics",
44554
+ capScope: "device",
44555
+ addonId: null,
44556
+ access: "view"
44557
+ },
43085
44558
  "pipelineAnalytics.listRetrainFrames": {
43086
44559
  capName: "pipeline-analytics",
43087
44560
  capScope: "device",
@@ -43112,6 +44585,12 @@ Object.freeze({
43112
44585
  addonId: null,
43113
44586
  access: "view"
43114
44587
  },
44588
+ "pipelineAnalytics.offerRetrainArchive": {
44589
+ capName: "pipeline-analytics",
44590
+ capScope: "device",
44591
+ addonId: null,
44592
+ access: "create"
44593
+ },
43115
44594
  "pipelineAnalytics.ownersWithMedia": {
43116
44595
  capName: "pipeline-analytics",
43117
44596
  capScope: "device",
@@ -43124,6 +44603,12 @@ Object.freeze({
43124
44603
  addonId: null,
43125
44604
  access: "create"
43126
44605
  },
44606
+ "pipelineAnalytics.previewRetrainDataset": {
44607
+ capName: "pipeline-analytics",
44608
+ capScope: "device",
44609
+ addonId: null,
44610
+ access: "view"
44611
+ },
43127
44612
  "pipelineAnalytics.proposeRetrainAnnotations": {
43128
44613
  capName: "pipeline-analytics",
43129
44614
  capScope: "device",
@@ -43262,6 +44747,12 @@ Object.freeze({
43262
44747
  addonId: null,
43263
44748
  access: "create"
43264
44749
  },
44750
+ "pipelineAnalytics.verifyRetrainDatasetVersion": {
44751
+ capName: "pipeline-analytics",
44752
+ capScope: "device",
44753
+ addonId: null,
44754
+ access: "view"
44755
+ },
43265
44756
  "pipelineAnalytics.wipeAllAnalytics": {
43266
44757
  capName: "pipeline-analytics",
43267
44758
  capScope: "device",
@@ -45638,6 +47129,174 @@ Object.freeze({
45638
47129
  addonId: null,
45639
47130
  access: "view"
45640
47131
  },
47132
+ "training.canaryResult": {
47133
+ capName: "training",
47134
+ capScope: "system",
47135
+ addonId: null,
47136
+ access: "create"
47137
+ },
47138
+ "training.cancelJob": {
47139
+ capName: "training",
47140
+ capScope: "system",
47141
+ addonId: null,
47142
+ access: "create"
47143
+ },
47144
+ "training.discardResult": {
47145
+ capName: "training",
47146
+ capScope: "system",
47147
+ addonId: null,
47148
+ access: "create"
47149
+ },
47150
+ "training.findDatasetVersionIdByName": {
47151
+ capName: "training",
47152
+ capScope: "system",
47153
+ addonId: null,
47154
+ access: "view"
47155
+ },
47156
+ "training.getDatasetVersion": {
47157
+ capName: "training",
47158
+ capScope: "system",
47159
+ addonId: null,
47160
+ access: "view"
47161
+ },
47162
+ "training.getJob": {
47163
+ capName: "training",
47164
+ capScope: "system",
47165
+ addonId: null,
47166
+ access: "view"
47167
+ },
47168
+ "training.getJobResult": {
47169
+ capName: "training",
47170
+ capScope: "system",
47171
+ addonId: null,
47172
+ access: "view"
47173
+ },
47174
+ "training.listBaseModels": {
47175
+ capName: "training",
47176
+ capScope: "system",
47177
+ addonId: null,
47178
+ access: "view"
47179
+ },
47180
+ "training.listDatasetVersions": {
47181
+ capName: "training",
47182
+ capScope: "system",
47183
+ addonId: null,
47184
+ access: "view"
47185
+ },
47186
+ "training.listJobs": {
47187
+ capName: "training",
47188
+ capScope: "system",
47189
+ addonId: null,
47190
+ access: "view"
47191
+ },
47192
+ "training.planJob": {
47193
+ capName: "training",
47194
+ capScope: "system",
47195
+ addonId: null,
47196
+ access: "view"
47197
+ },
47198
+ "training.putDatasetVersion": {
47199
+ capName: "training",
47200
+ capScope: "system",
47201
+ addonId: null,
47202
+ access: "create"
47203
+ },
47204
+ "training.registerResult": {
47205
+ capName: "training",
47206
+ capScope: "system",
47207
+ addonId: null,
47208
+ access: "create"
47209
+ },
47210
+ "training.removeDatasetVersion": {
47211
+ capName: "training",
47212
+ capScope: "system",
47213
+ addonId: null,
47214
+ access: "delete"
47215
+ },
47216
+ "training.rollbackCanary": {
47217
+ capName: "training",
47218
+ capScope: "system",
47219
+ addonId: null,
47220
+ access: "create"
47221
+ },
47222
+ "training.startJob": {
47223
+ capName: "training",
47224
+ capScope: "system",
47225
+ addonId: null,
47226
+ access: "create"
47227
+ },
47228
+ "trainingProvider.cancelJob": {
47229
+ capName: "training-provider",
47230
+ capScope: "system",
47231
+ addonId: null,
47232
+ access: "create"
47233
+ },
47234
+ "trainingProvider.cleanupJob": {
47235
+ capName: "training-provider",
47236
+ capScope: "system",
47237
+ addonId: null,
47238
+ access: "create"
47239
+ },
47240
+ "trainingProvider.describe": {
47241
+ capName: "training-provider",
47242
+ capScope: "system",
47243
+ addonId: null,
47244
+ access: "view"
47245
+ },
47246
+ "trainingProvider.estimateJob": {
47247
+ capName: "training-provider",
47248
+ capScope: "system",
47249
+ addonId: null,
47250
+ access: "view"
47251
+ },
47252
+ "trainingProvider.getJob": {
47253
+ capName: "training-provider",
47254
+ capScope: "system",
47255
+ addonId: null,
47256
+ access: "view"
47257
+ },
47258
+ "trainingProvider.listJobEvents": {
47259
+ capName: "training-provider",
47260
+ capScope: "system",
47261
+ addonId: null,
47262
+ access: "view"
47263
+ },
47264
+ "trainingProvider.listJobs": {
47265
+ capName: "training-provider",
47266
+ capScope: "system",
47267
+ addonId: null,
47268
+ access: "view"
47269
+ },
47270
+ "trainingProvider.offerArtifact": {
47271
+ capName: "training-provider",
47272
+ capScope: "system",
47273
+ addonId: null,
47274
+ access: "create"
47275
+ },
47276
+ "trainingProvider.readResult": {
47277
+ capName: "training-provider",
47278
+ capScope: "system",
47279
+ addonId: null,
47280
+ access: "create"
47281
+ },
47282
+ "trainingProvider.submitJob": {
47283
+ capName: "training-provider",
47284
+ capScope: "system",
47285
+ addonId: null,
47286
+ access: "create"
47287
+ },
47288
+ "trainingProvider.uploadDataset": {
47289
+ capName: "training-provider",
47290
+ capScope: "system",
47291
+ addonId: null,
47292
+ access: "create"
47293
+ },
47294
+ "trainingProvider.validateCredentials": {
47295
+ capName: "training-provider",
47296
+ capScope: "system",
47297
+ addonId: null,
47298
+ access: "create"
47299
+ },
45641
47300
  "turnProvider.getTurnServers": {
45642
47301
  capName: "turn-provider",
45643
47302
  capScope: "system",
@@ -45662,12 +47321,6 @@ Object.freeze({
45662
47321
  addonId: null,
45663
47322
  access: "create"
45664
47323
  },
45665
- "userManagement.createApiKey": {
45666
- capName: "user-management",
45667
- capScope: "system",
45668
- addonId: null,
45669
- access: "create"
45670
- },
45671
47324
  "userManagement.createScopedToken": {
45672
47325
  capName: "user-management",
45673
47326
  capScope: "system",
@@ -45704,12 +47357,6 @@ Object.freeze({
45704
47357
  addonId: null,
45705
47358
  access: "view"
45706
47359
  },
45707
- "userManagement.linkExternalIdentity": {
45708
- capName: "user-management",
45709
- capScope: "system",
45710
- addonId: null,
45711
- access: "create"
45712
- },
45713
47360
  "userManagement.listApiKeys": {
45714
47361
  capName: "user-management",
45715
47362
  capScope: "system",
@@ -45812,12 +47459,6 @@ Object.freeze({
45812
47459
  addonId: null,
45813
47460
  access: "create"
45814
47461
  },
45815
- "userManagement.validateApiKey": {
45816
- capName: "user-management",
45817
- capScope: "system",
45818
- addonId: null,
45819
- access: "view"
45820
- },
45821
47462
  "userManagement.validateCredentials": {
45822
47463
  capName: "user-management",
45823
47464
  capScope: "system",
@@ -49931,6 +51572,11 @@ Object.freeze({
49931
51572
  form: "single",
49932
51573
  optional: false
49933
51574
  }],
51575
+ "training.canaryResult": [{
51576
+ name: "deviceIds",
51577
+ form: "array",
51578
+ optional: false
51579
+ }],
49934
51580
  "update.getStatus": [{
49935
51581
  name: "deviceId",
49936
51582
  form: "single",
@@ -50659,6 +52305,8 @@ var STATE_SUMMARY_VARS = [
50659
52305
  [...RULE_TEXT],
50660
52306
  [...RULE_TEXT],
50661
52307
  [...RULE_TEXT],
52308
+ [...RULE_TEXT],
52309
+ [...RULE_TEXT],
50662
52310
  ([...RULE_TEXT], [...UPDATES]),
50663
52311
  ([...RULE_TEXT], [...PACKAGE_UPDATES]),
50664
52312
  ([...RULE_TEXT], [...PACKAGE_UPDATES]),