@camstack/addon-smtp-nodemailer 1.2.119 → 1.2.120

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.
@@ -5412,7 +5412,7 @@ var ZodIssueCode = {
5412
5412
  var ZodFirstPartyTypeKind;
5413
5413
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
5414
5414
  //#endregion
5415
- //#region ../types/dist/sleep-Cr5YOk3m.mjs
5415
+ //#region ../types/dist/sleep-r3RWkGVx.mjs
5416
5416
  /**
5417
5417
  * The audio chunk plane's byte format, and the ONE expansion from a coded
5418
5418
  * window to float samples (D455).
@@ -5529,7 +5529,7 @@ function isKeychainStoredField(field) {
5529
5529
  var SECRET_CLEAR = { $secretClear: true };
5530
5530
  /** The `'***'` token D634 redaction writes for non-admins. */
5531
5531
  var LEGACY_DEVICE_REDACTION = "***";
5532
- function isRecord$1(value) {
5532
+ function isRecord$2(value) {
5533
5533
  return typeof value === "object" && value !== null && !Array.isArray(value);
5534
5534
  }
5535
5535
  function makeSecretMarker(ref) {
@@ -5540,12 +5540,12 @@ function makeSecretMarker(ref) {
5540
5540
  }
5541
5541
  /** A stored marker: an object whose `$secret` is a non-empty string. */
5542
5542
  function isSecretMarker(value) {
5543
- if (!isRecord$1(value)) return false;
5543
+ if (!isRecord$2(value)) return false;
5544
5544
  const ref = value["$secret"];
5545
5545
  return typeof ref === "string" && ref.length > 0;
5546
5546
  }
5547
5547
  function isSecretClear(value) {
5548
- return isRecord$1(value) && value["$secretClear"] === true;
5548
+ return isRecord$2(value) && value["$secretClear"] === true;
5549
5549
  }
5550
5550
  /**
5551
5551
  * The UI view of a stored secret field value: a marker becomes "set", inline
@@ -6061,6 +6061,13 @@ function globalSecretScope() {
6061
6061
  function encodeSegment(value) {
6062
6062
  return encodeURIComponent(value);
6063
6063
  }
6064
+ function decodeSegment(value) {
6065
+ try {
6066
+ return decodeURIComponent(value);
6067
+ } catch {
6068
+ return null;
6069
+ }
6070
+ }
6064
6071
  /**
6065
6072
  * The field path of a value inside an array item, addressed by the item's id:
6066
6073
  * `arrayItemFieldPath('providers', 'authentik', 'clientSecret')` →
@@ -6069,6 +6076,75 @@ function encodeSegment(value) {
6069
6076
  function arrayItemFieldPath(arrayKey, itemId, fieldKey) {
6070
6077
  return `${arrayKey}[${encodeSegment(itemId)}].${fieldKey}`;
6071
6078
  }
6079
+ function parseScope(segments) {
6080
+ switch (segments[0]) {
6081
+ case "global": return {
6082
+ scope: GLOBAL_SCOPE,
6083
+ used: 1
6084
+ };
6085
+ case "node": {
6086
+ const nodeId = segments[1] !== void 0 ? decodeSegment(segments[1]) : null;
6087
+ return nodeId === null || nodeId.length === 0 ? null : {
6088
+ scope: {
6089
+ kind: "node",
6090
+ nodeId
6091
+ },
6092
+ used: 2
6093
+ };
6094
+ }
6095
+ case "device": {
6096
+ const raw = segments[1];
6097
+ if (raw === void 0 || !/^\d+$/.test(raw)) return null;
6098
+ return {
6099
+ scope: {
6100
+ kind: "device",
6101
+ deviceId: Number(raw)
6102
+ },
6103
+ used: 2
6104
+ };
6105
+ }
6106
+ case "integration": {
6107
+ const id = segments[1] !== void 0 ? decodeSegment(segments[1]) : null;
6108
+ return id === null || id.length === 0 ? null : {
6109
+ scope: {
6110
+ kind: "integration",
6111
+ integrationId: id
6112
+ },
6113
+ used: 2
6114
+ };
6115
+ }
6116
+ case "row": {
6117
+ const collection = segments[1] !== void 0 ? decodeSegment(segments[1]) : null;
6118
+ const rowId = segments[2] !== void 0 ? decodeSegment(segments[2]) : null;
6119
+ if (collection === null || rowId === null || collection.length === 0 || rowId.length === 0) return null;
6120
+ return {
6121
+ scope: {
6122
+ kind: "row",
6123
+ collection,
6124
+ rowId
6125
+ },
6126
+ used: 3
6127
+ };
6128
+ }
6129
+ default: return null;
6130
+ }
6131
+ }
6132
+ /** Take a ref apart; `null` when it is not a well-formed ref. */
6133
+ function parseSecretRef(ref) {
6134
+ if (!ref.startsWith("secret://")) return null;
6135
+ const segments = ref.slice(9).split("/");
6136
+ const owner = segments[0] !== void 0 ? decodeSegment(segments[0]) : null;
6137
+ if (owner === null || owner.length === 0) return null;
6138
+ const parsed = parseScope(segments.slice(1));
6139
+ if (parsed === null) return null;
6140
+ const fieldPath = segments.slice(1 + parsed.used).join("/");
6141
+ if (fieldPath.length === 0) return null;
6142
+ return {
6143
+ owner,
6144
+ scope: parsed.scope,
6145
+ fieldPath
6146
+ };
6147
+ }
6072
6148
  /** A write to a secret path could not be stored in the keychain, so it was refused. */
6073
6149
  var KeychainWriteRefusedError = class extends Error {
6074
6150
  fieldPath;
@@ -6079,7 +6155,7 @@ var KeychainWriteRefusedError = class extends Error {
6079
6155
  }
6080
6156
  };
6081
6157
  var KEEP = { kind: "keep" };
6082
- function isRecord(value) {
6158
+ function isRecord$1(value) {
6083
6159
  return typeof value === "object" && value !== null && !Array.isArray(value);
6084
6160
  }
6085
6161
  function defaultMintId() {
@@ -6092,7 +6168,7 @@ function collectSecretMarkerRefs(value, out = []) {
6092
6168
  return out;
6093
6169
  }
6094
6170
  if (Array.isArray(value)) for (const item of value) collectSecretMarkerRefs(item, out);
6095
- else if (isRecord(value)) for (const child of Object.values(value)) collectSecretMarkerRefs(child, out);
6171
+ else if (isRecord$1(value)) for (const child of Object.values(value)) collectSecretMarkerRefs(child, out);
6096
6172
  return out;
6097
6173
  }
6098
6174
  async function storedValueEquals(secrets, marker, candidate) {
@@ -6147,7 +6223,7 @@ function rowId(row, idKey) {
6147
6223
  return null;
6148
6224
  }
6149
6225
  async function writeArray(ctx, node, incoming, stored, fieldPath) {
6150
- const storedRows = Array.isArray(stored) ? stored.filter(isRecord) : [];
6226
+ const storedRows = Array.isArray(stored) ? stored.filter(isRecord$1) : [];
6151
6227
  if (!Array.isArray(incoming)) {
6152
6228
  ctx.deletes.push(...collectSecretMarkerRefs(storedRows));
6153
6229
  return {
@@ -6163,7 +6239,7 @@ async function writeArray(ctx, node, incoming, stored, fieldPath) {
6163
6239
  const kept = /* @__PURE__ */ new Set();
6164
6240
  const rows = [];
6165
6241
  for (const row of incoming) {
6166
- if (!isRecord(row)) {
6242
+ if (!isRecord$1(row)) {
6167
6243
  rows.push(row);
6168
6244
  continue;
6169
6245
  }
@@ -6188,7 +6264,7 @@ async function writeNode(ctx, node, incoming, stored, fieldPath) {
6188
6264
  case "leaf": return writeLeaf(ctx, incoming, stored, fieldPath);
6189
6265
  case "array": return writeArray(ctx, node, incoming, stored, fieldPath);
6190
6266
  case "object": {
6191
- if (!isRecord(incoming)) {
6267
+ if (!isRecord$1(incoming)) {
6192
6268
  if (incoming === void 0) return KEEP;
6193
6269
  ctx.deletes.push(...collectSecretMarkerRefs(stored));
6194
6270
  return {
@@ -6196,7 +6272,7 @@ async function writeNode(ctx, node, incoming, stored, fieldPath) {
6196
6272
  value: incoming
6197
6273
  };
6198
6274
  }
6199
- const storedObj = isRecord(stored) ? stored : {};
6275
+ const storedObj = isRecord$1(stored) ? stored : {};
6200
6276
  return {
6201
6277
  kind: "value",
6202
6278
  value: await writeMembers(ctx, node.children, incoming, storedObj, (m) => `${fieldPath}.${m}`)
@@ -6255,12 +6331,19 @@ async function transformSecretWrite(input) {
6255
6331
  }
6256
6332
  };
6257
6333
  }
6334
+ /** Is `ref` one of `owner`'s refs? */
6335
+ function isSecretRefOwnedBy(ref, owner) {
6336
+ return parseSecretRef(ref)?.owner === owner;
6337
+ }
6258
6338
  /**
6259
6339
  * Replace every marker in `value` with its keychain value. Returns the SAME
6260
6340
  * reference when there is no marker (no allocation, no keychain call).
6261
6341
  */
6262
- async function resolveSecretMarkers(value, secrets) {
6263
- const refs = collectSecretMarkerRefs(value);
6342
+ async function resolveSecretMarkers(value, secrets, options = {}) {
6343
+ const keepMarker = options.unresolved === "keep-marker";
6344
+ const owner = options.ownedBy;
6345
+ const inScope = (ref) => owner === void 0 || isSecretRefOwnedBy(ref, owner);
6346
+ const refs = collectSecretMarkerRefs(value).filter(inScope);
6264
6347
  if (refs.length === 0) return {
6265
6348
  value,
6266
6349
  unresolved: []
@@ -6284,10 +6367,18 @@ async function resolveSecretMarkers(value, secrets) {
6284
6367
  }
6285
6368
  const substitute = (v) => {
6286
6369
  if (isSecretMarker(v)) {
6370
+ if (!inScope(v.$secret)) return {
6371
+ keep: true,
6372
+ value: v
6373
+ };
6287
6374
  const answer = answers[v.$secret];
6288
- return answer?.kind === "value" ? {
6375
+ if (answer?.kind === "value") return {
6289
6376
  keep: true,
6290
6377
  value: answer.value
6378
+ };
6379
+ return keepMarker ? {
6380
+ keep: true,
6381
+ value: v
6291
6382
  } : {
6292
6383
  keep: false,
6293
6384
  value: void 0
@@ -6304,7 +6395,7 @@ async function resolveSecretMarkers(value, secrets) {
6304
6395
  value: items
6305
6396
  };
6306
6397
  }
6307
- if (isRecord(v)) {
6398
+ if (isRecord$1(v)) {
6308
6399
  const out = {};
6309
6400
  for (const [k, child] of Object.entries(v)) {
6310
6401
  const s = substitute(child);
@@ -6325,14 +6416,152 @@ async function resolveSecretMarkers(value, secrets) {
6325
6416
  unresolved
6326
6417
  };
6327
6418
  }
6328
- function touchesTree(tree, patch) {
6329
- if (tree.size === 0) return false;
6330
- for (const key of Object.keys(patch)) {
6331
- const at = key.indexOf("@");
6332
- if (tree.has(at > 0 ? key.slice(0, at) : key)) return true;
6419
+ /** An addon tried to replace a stored secret it could not read. Nothing was written. */
6420
+ var SecretOverwriteRefusedError = class extends Error {
6421
+ ref;
6422
+ reason;
6423
+ constructor(ref, reason) {
6424
+ 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.`);
6425
+ this.ref = ref;
6426
+ this.reason = reason;
6427
+ this.name = "SecretOverwriteRefusedError";
6428
+ }
6429
+ };
6430
+ function isRecord(value) {
6431
+ return typeof value === "object" && value !== null && !Array.isArray(value);
6432
+ }
6433
+ function resolvedValue(pass, marker) {
6434
+ const answer = pass.answers[marker.$secret];
6435
+ return answer?.kind === "value" ? answer.value : null;
6436
+ }
6437
+ async function atMarker(pass, incoming, stored) {
6438
+ if (incoming === null) return stored;
6439
+ if (typeof incoming !== "string") return incoming;
6440
+ if (incoming === resolvedValue(pass, stored)) return stored;
6441
+ const intent = classifySecretWrite(incoming);
6442
+ if (intent.kind !== "set") return stored;
6443
+ const ref = stored.$secret;
6444
+ if (!isSecretRefOwnedBy(ref, pass.secrets.owner)) return incoming;
6445
+ const answer = pass.answers[ref];
6446
+ 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);
6447
+ try {
6448
+ await pass.secrets.put(ref, intent.value);
6449
+ } catch (err) {
6450
+ throw new KeychainWriteRefusedError(ref, err);
6451
+ }
6452
+ pass.changedRefs.push(ref);
6453
+ return stored;
6454
+ }
6455
+ function inArray(pass, incoming, stored) {
6456
+ return incoming.map((item, index) => {
6457
+ const twin = stored[index];
6458
+ if (isSecretMarker(twin)) return typeof item === "string" && item === resolvedValue(pass, twin) ? twin : item;
6459
+ if (isRecord(item) && isRecord(twin)) return inArrayRow(pass, item, twin);
6460
+ if (Array.isArray(item) && Array.isArray(twin)) return inArray(pass, item, twin);
6461
+ return item;
6462
+ });
6463
+ }
6464
+ function inArrayRow(pass, incoming, stored) {
6465
+ const out = { ...incoming };
6466
+ for (const [key, value] of Object.entries(incoming)) {
6467
+ const twin = stored[key];
6468
+ if (isSecretMarker(twin)) {
6469
+ if (typeof value === "string" && value === resolvedValue(pass, twin)) out[key] = twin;
6470
+ } else if (isRecord(value) && isRecord(twin)) out[key] = inArrayRow(pass, value, twin);
6471
+ else if (Array.isArray(value) && Array.isArray(twin)) out[key] = inArray(pass, value, twin);
6472
+ }
6473
+ return out;
6474
+ }
6475
+ async function walk(pass, incoming, stored) {
6476
+ if (isSecretMarker(stored)) return atMarker(pass, incoming, stored);
6477
+ if (Array.isArray(incoming) && Array.isArray(stored)) return inArray(pass, incoming, stored);
6478
+ if (!isRecord(incoming) || !isRecord(stored)) return incoming;
6479
+ const out = { ...incoming };
6480
+ for (const [key, value] of Object.entries(incoming)) out[key] = await walk(pass, value, stored[key]);
6481
+ return out;
6482
+ }
6483
+ /** Restore markers a write-back carries as values. See the file doc. */
6484
+ async function restoreUnchangedSecrets(input) {
6485
+ const refs = [];
6486
+ for (const key of Object.keys(input.patch)) collectSecretMarkerRefs(input.stored[key], refs);
6487
+ const owned = refs.filter((ref) => isSecretRefOwnedBy(ref, input.secrets.owner));
6488
+ if (owned.length === 0) return {
6489
+ patch: input.patch,
6490
+ changedRefs: []
6491
+ };
6492
+ const pass = {
6493
+ secrets: input.secrets,
6494
+ answers: await input.secrets.resolve([...new Set(owned)]),
6495
+ operatorWrite: input.operatorWrite,
6496
+ changedRefs: []
6497
+ };
6498
+ const out = {};
6499
+ for (const [key, value] of Object.entries(input.patch)) out[key] = await walk(pass, value, input.stored[key]);
6500
+ return {
6501
+ patch: out,
6502
+ changedRefs: pass.changedRefs
6503
+ };
6504
+ }
6505
+ /** Structural equality over JSON-shaped values (key order does not matter). */
6506
+ function isJsonEqual(a, b) {
6507
+ if (Object.is(a, b)) return true;
6508
+ if (Array.isArray(a)) return Array.isArray(b) && a.length === b.length && a.every((v, i) => isJsonEqual(v, b[i]));
6509
+ if (isRecord(a) && isRecord(b)) {
6510
+ const keys = Object.keys(a);
6511
+ if (keys.length !== Object.keys(b).length) return false;
6512
+ return keys.every((k) => Object.prototype.hasOwnProperty.call(b, k) && isJsonEqual(a[k], b[k]));
6333
6513
  }
6334
6514
  return false;
6335
6515
  }
6516
+ /** The patch without the keys whose value already equals the stored one. */
6517
+ function dropUnchangedKeys(patch, stored) {
6518
+ const out = {};
6519
+ for (const [key, value] of Object.entries(patch)) {
6520
+ if (Object.prototype.hasOwnProperty.call(stored, key) && isJsonEqual(value, stored[key])) continue;
6521
+ out[key] = value;
6522
+ }
6523
+ return out;
6524
+ }
6525
+ /** The top-level keys of a blob that hold at least one of `owner`'s markers. */
6526
+ function markerKeysOf(blob, owner) {
6527
+ const keys = /* @__PURE__ */ new Set();
6528
+ for (const [key, value] of Object.entries(blob)) if (collectSecretMarkerRefs(value).some((ref) => isSecretRefOwnedBy(ref, owner))) keys.add(key);
6529
+ return keys;
6530
+ }
6531
+ function nodeFromStored(value, owner) {
6532
+ if (isSecretMarker(value)) return isSecretRefOwnedBy(value.$secret, owner) ? { kind: "leaf" } : null;
6533
+ if (!isRecord(value)) return null;
6534
+ const children = /* @__PURE__ */ new Map();
6535
+ for (const [key, child] of Object.entries(value)) {
6536
+ const node = nodeFromStored(child, owner);
6537
+ if (node !== null) children.set(key, node);
6538
+ }
6539
+ return children.size > 0 ? {
6540
+ kind: "object",
6541
+ children
6542
+ } : null;
6543
+ }
6544
+ /**
6545
+ * The declared secret tree, widened by every place the STORED blob holds a
6546
+ * marker under one of `keys` — so a marker the schema no longer declares (or
6547
+ * never declared: Wyze before b4906cec6) still gets the save path's
6548
+ * KEEP / SET / CLEAR semantics instead of being overwritten by whatever the
6549
+ * addon writes. Markers inside arrays are not added: a row has no id field to
6550
+ * match by unless the schema declares one. Only `owner`'s markers count: a
6551
+ * builtin that keeps another addon's marker (device-manager) never takes it
6552
+ * over.
6553
+ */
6554
+ function widenTreeWithStoredMarkers(declared, stored, keys, owner) {
6555
+ const added = /* @__PURE__ */ new Map();
6556
+ for (const key of keys) {
6557
+ const at = key.indexOf("@");
6558
+ const base = at > 0 ? key.slice(0, at) : key;
6559
+ if (declared.has(base) || added.has(base)) continue;
6560
+ const node = nodeFromStored(stored[key], owner);
6561
+ if (node !== null) added.set(base, node);
6562
+ }
6563
+ return added.size === 0 ? declared : new Map([...declared, ...added]);
6564
+ }
6336
6565
  /** The blob as stored now; a failed read REFUSES the write instead of guessing. */
6337
6566
  async function readStoredAddonBlob(raw) {
6338
6567
  const threeWay = raw.readAddonStoreResult;
@@ -6341,7 +6570,41 @@ async function readStoredAddonBlob(raw) {
6341
6570
  if (result.kind === "failed") throw new Error(`settings write refused: the stored blob could not be read (${result.error})`);
6342
6571
  return result.kind === "missing" ? {} : result.value;
6343
6572
  }
6344
- function createSecretAwareSettings(raw, opts) {
6573
+ function touchesTree(tree, patch) {
6574
+ if (tree.size === 0) return false;
6575
+ for (const key of Object.keys(patch)) {
6576
+ const at = key.indexOf("@");
6577
+ if (tree.has(at > 0 ? key.slice(0, at) : key)) return true;
6578
+ }
6579
+ return false;
6580
+ }
6581
+ /**
6582
+ * Which top-level keys of each store held markers when last seen. `undefined`
6583
+ * for a store not seen yet: its first write reads it, to be safe.
6584
+ */
6585
+ var MarkerKeyIndex = class {
6586
+ owner;
6587
+ byStore = /* @__PURE__ */ new Map();
6588
+ constructor(owner) {
6589
+ this.owner = owner;
6590
+ }
6591
+ seen(store, blob) {
6592
+ this.byStore.set(store, markerKeysOf(blob, this.owner));
6593
+ }
6594
+ wrote(store, patch) {
6595
+ const keys = this.byStore.get(store);
6596
+ if (keys === void 0) return;
6597
+ const now = markerKeysOf(patch, this.owner);
6598
+ for (const key of Object.keys(patch)) if (now.has(key)) keys.add(key);
6599
+ else keys.delete(key);
6600
+ }
6601
+ mayHoldMarkers(store, patch) {
6602
+ const keys = this.byStore.get(store);
6603
+ if (keys === void 0) return true;
6604
+ return Object.keys(patch).some((key) => keys.has(key));
6605
+ }
6606
+ };
6607
+ function createHandle(raw, opts) {
6345
6608
  const chains = /* @__PURE__ */ new Map();
6346
6609
  const serialize = (key, fn) => {
6347
6610
  const next = (chains.get(key) ?? Promise.resolve()).then(fn, fn);
@@ -6352,46 +6615,130 @@ function createSecretAwareSettings(raw, opts) {
6352
6615
  });
6353
6616
  return next;
6354
6617
  };
6355
- const write = async (chainKey, tree, scope, patch, readStored, rawWrite) => {
6356
- if (!touchesTree(tree, patch)) return rawWrite(patch);
6357
- return serialize(chainKey, async () => {
6618
+ const index = new MarkerKeyIndex(opts.secrets.owner);
6619
+ const resolveRead = async (store, blob) => {
6620
+ index.seen(store, blob);
6621
+ const { value, unresolved } = await resolveSecretMarkers(blob, opts.secrets, {
6622
+ unresolved: "keep-marker",
6623
+ ownedBy: opts.secrets.owner
6624
+ });
6625
+ if (unresolved.length > 0) opts.onUnresolved?.(unresolved);
6626
+ return value;
6627
+ };
6628
+ const write = async (store, declared, scope, patch, readStored, rawWrite) => {
6629
+ if (!touchesTree(declared, patch) && !index.mayHoldMarkers(store, patch)) {
6630
+ await rawWrite(patch);
6631
+ index.wrote(store, patch);
6632
+ return { changed: true };
6633
+ }
6634
+ return serialize(store, async () => {
6358
6635
  const stored = await readStored();
6636
+ index.seen(store, stored);
6637
+ const operatorWrite = opts.isOperatorWrite?.() === true;
6638
+ const restored = await restoreUnchangedSecrets({
6639
+ patch,
6640
+ stored,
6641
+ secrets: opts.secrets,
6642
+ operatorWrite
6643
+ });
6359
6644
  const result = await transformSecretWrite({
6360
- tree,
6645
+ tree: widenTreeWithStoredMarkers(declared, stored, Object.keys(restored.patch), opts.secrets.owner),
6361
6646
  secrets: opts.secrets,
6362
- patch,
6647
+ patch: restored.patch,
6363
6648
  stored,
6364
6649
  ...scope !== void 0 ? { scope } : {},
6365
- operatorWrite: opts.isOperatorWrite?.() === true
6650
+ operatorWrite
6366
6651
  });
6367
- if (Object.keys(result.patch).length > 0) await rawWrite(result.patch);
6652
+ const effective = dropUnchangedKeys(result.patch, stored);
6653
+ const wroteBlob = Object.keys(effective).length > 0;
6654
+ if (wroteBlob) {
6655
+ await rawWrite(effective);
6656
+ index.wrote(store, effective);
6657
+ }
6368
6658
  const { orphaned } = await result.afterWrite();
6369
6659
  if (orphaned.length > 0) opts.onOrphaned(orphaned);
6660
+ return { changed: wroteBlob || restored.changedRefs.length > 0 };
6370
6661
  });
6371
6662
  };
6372
- const wrapped = {
6373
- writeAddonStore: (patch) => write("addon", opts.addonTree(), void 0, patch, () => readStoredAddonBlob(raw), (p) => raw.writeAddonStore(p)),
6374
- writeDeviceStore: (deviceId, patch) => write(`device:${deviceId}`, opts.deviceTree(), {
6375
- kind: "device",
6376
- deviceId
6377
- }, patch, () => raw.readDeviceStore(deviceId), (p) => raw.writeDeviceStore(deviceId, p))
6663
+ const writeAddon = (patch) => write("addon", opts.addonTree(), void 0, patch, () => readStoredAddonBlob(raw), (p) => raw.writeAddonStore(p));
6664
+ const readAddonStoreResult = raw.readAddonStoreResult;
6665
+ const readAddonStoreKeyResult = raw.readAddonStoreKeyResult;
6666
+ const readDeviceStoreBatch = raw.readDeviceStoreBatch;
6667
+ const overrides = {
6668
+ readAddonStore: async () => resolveRead("addon", await raw.readAddonStore()),
6669
+ ...readAddonStoreResult !== void 0 ? { readAddonStoreResult: async () => {
6670
+ const result = await readAddonStoreResult.call(raw);
6671
+ return result.kind === "value" ? {
6672
+ kind: "value",
6673
+ value: await resolveRead("addon", result.value)
6674
+ } : result;
6675
+ } } : {},
6676
+ ...readAddonStoreKeyResult !== void 0 ? { readAddonStoreKeyResult: async (key) => {
6677
+ const result = await readAddonStoreKeyResult.call(raw, key);
6678
+ if (result.kind !== "present") return result;
6679
+ const { value, unresolved } = await resolveSecretMarkers({ [key]: result.value }, opts.secrets, {
6680
+ unresolved: "keep-marker",
6681
+ ownedBy: opts.secrets.owner
6682
+ });
6683
+ if (unresolved.length > 0) opts.onUnresolved?.(unresolved);
6684
+ return {
6685
+ kind: "present",
6686
+ value: value[key]
6687
+ };
6688
+ } } : {},
6689
+ readDeviceStore: async (deviceId) => resolveRead(`device:${deviceId}`, await raw.readDeviceStore(deviceId)),
6690
+ ...readDeviceStoreBatch !== void 0 ? { readDeviceStoreBatch: async (deviceIds) => {
6691
+ const rows = await readDeviceStoreBatch.call(raw, deviceIds);
6692
+ const out = /* @__PURE__ */ new Map();
6693
+ for (const [deviceId, blob] of rows) out.set(deviceId, await resolveRead(`device:${deviceId}`, blob));
6694
+ return out;
6695
+ } } : {},
6696
+ writeAddonStore: async (patch) => {
6697
+ await writeAddon(patch);
6698
+ },
6699
+ writeDeviceStore: async (deviceId, patch) => {
6700
+ await write(`device:${deviceId}`, opts.deviceTree(), {
6701
+ kind: "device",
6702
+ deviceId
6703
+ }, patch, () => raw.readDeviceStore(deviceId), (p) => raw.writeDeviceStore(deviceId, p));
6704
+ }
6705
+ };
6706
+ return {
6707
+ settings: new Proxy(raw, { get(target, prop, receiver) {
6708
+ if (typeof prop === "string" && Object.prototype.hasOwnProperty.call(overrides, prop)) return Reflect.get(overrides, prop);
6709
+ const value = Reflect.get(target, prop, receiver);
6710
+ return typeof value === "function" ? value.bind(target) : value;
6711
+ } }),
6712
+ raw: {
6713
+ readAddonStore: async () => {
6714
+ const blob = await raw.readAddonStore();
6715
+ index.seen("addon", blob);
6716
+ return blob;
6717
+ },
6718
+ readDeviceStore: async (deviceId) => {
6719
+ const blob = await raw.readDeviceStore(deviceId);
6720
+ index.seen(`device:${deviceId}`, blob);
6721
+ return blob;
6722
+ }
6723
+ },
6724
+ writeAddonStore: writeAddon
6378
6725
  };
6379
- return new Proxy(raw, { get(target, prop, receiver) {
6380
- if (prop === "writeAddonStore") return wrapped.writeAddonStore;
6381
- if (prop === "writeDeviceStore") return wrapped.writeDeviceStore;
6382
- const value = Reflect.get(target, prop, receiver);
6383
- return typeof value === "function" ? value.bind(target) : value;
6384
- } });
6385
6726
  }
6386
- /** The context the addon sees: identical, except that its settings writes are secret-aware. */
6387
- function withSecretAwareSettings(context, opts) {
6727
+ /** The context the addon sees, plus the private raw view and write outcome. */
6728
+ function createSecretAwareContext(context, opts) {
6388
6729
  const raw = context.settings;
6389
- if (raw === void 0) return context;
6390
- const settings = createSecretAwareSettings(raw, opts);
6391
- return new Proxy(context, { get(target, prop, receiver) {
6392
- if (prop === "settings") return settings;
6393
- return Reflect.get(target, prop, receiver);
6394
- } });
6730
+ if (raw === void 0) return {
6731
+ context,
6732
+ handle: null
6733
+ };
6734
+ const handle = createHandle(raw, opts);
6735
+ return {
6736
+ context: new Proxy(context, { get(target, prop, receiver) {
6737
+ if (prop === "settings") return handle.settings;
6738
+ return Reflect.get(target, prop, receiver);
6739
+ } }),
6740
+ handle
6741
+ };
6395
6742
  }
6396
6743
  var LEAF = { kind: "leaf" };
6397
6744
  var DEFAULT_ITEM_ID_KEY = "id";
@@ -6566,6 +6913,14 @@ var BaseAddon = class {
6566
6913
  _secretChangeUnsub = null;
6567
6914
  /** >0 while an OPERATOR's settings write is being applied. */
6568
6915
  _operatorWriteDepth = 0;
6916
+ /**
6917
+ * The keychain-aware settings handle (D798). Its `raw` view is the ONLY way
6918
+ * to the marker-bearing blobs and stays private to this class: the form
6919
+ * hydrate and config resolution need markers, addon code never does.
6920
+ */
6921
+ _secretSettings = null;
6922
+ /** Refs an addon-facing read could not resolve — each is logged once per process. */
6923
+ _loggedUnresolvedReads = /* @__PURE__ */ new Set();
6569
6924
  constructor(defaults) {
6570
6925
  this.defaults = defaults;
6571
6926
  this._config = { ...defaults };
@@ -6602,13 +6957,21 @@ var BaseAddon = class {
6602
6957
  }
6603
6958
  async initialize(context) {
6604
6959
  const secrets = context.secrets;
6605
- this._ctx = secrets !== void 0 ? withSecretAwareSettings(context, {
6606
- secrets,
6607
- addonTree: () => this.addonSecretTree(),
6608
- deviceTree: () => this.deviceSecretTree(),
6609
- onOrphaned: (refs) => context.logger.warn("keychain refs dropped by a settings write could not be deleted", { meta: { refs: [...refs] } }),
6610
- isOperatorWrite: () => this._operatorWriteDepth > 0
6611
- }) : context;
6960
+ if (secrets !== void 0) {
6961
+ const { context: wrapped, handle } = createSecretAwareContext(context, {
6962
+ secrets,
6963
+ addonTree: () => this.addonSecretTree(),
6964
+ deviceTree: () => this.deviceSecretTree(),
6965
+ onOrphaned: (refs) => context.logger.warn("keychain refs dropped by a settings write could not be deleted", { meta: { refs: [...refs] } }),
6966
+ isOperatorWrite: () => this._operatorWriteDepth > 0,
6967
+ onUnresolved: (unresolved) => this.logUnresolvedRead(unresolved)
6968
+ });
6969
+ this._ctx = wrapped;
6970
+ this._secretSettings = handle;
6971
+ } else {
6972
+ this._ctx = context;
6973
+ this._secretSettings = null;
6974
+ }
6612
6975
  await this.resolveConfig();
6613
6976
  if (secrets !== void 0) this._secretChangeUnsub = secrets.onChange((ref) => {
6614
6977
  if (this._configSecretRefs.has(ref)) this.scheduleSecretReresolve(SECRET_CHANGE_DEBOUNCE_MS);
@@ -6725,11 +7088,8 @@ var BaseAddon = class {
6725
7088
  async getGlobalSettings(overlay, cap, nodeId) {
6726
7089
  const schema = this.globalSettingsSchema(cap);
6727
7090
  if (!schema) return { sections: [] };
6728
- const projected = await this.resolveGlobalStore(nodeId, cap);
6729
- return hydrateSchema(schema, overlay ? {
6730
- ...projected,
6731
- ...overlay
6732
- } : projected, { inlineSecretsAsViews: true });
7091
+ const projected = await this.readRawProjectedStore(nodeId, cap);
7092
+ return hydrateSchema(schema, overlay ? await this.overlayKeepingMarkers(projected, overlay) : projected, { inlineSecretsAsViews: true });
6733
7093
  }
6734
7094
  /**
6735
7095
  * The integration-level view of this addon's settings: exactly the sections
@@ -6774,7 +7134,7 @@ var BaseAddon = class {
6774
7134
  });
6775
7135
  }
6776
7136
  if (sections.length === 0) return null;
6777
- const projected = await this.resolveGlobalStore(nodeId);
7137
+ const projected = await this.readRawProjectedStore(nodeId);
6778
7138
  return hydrateSchema({
6779
7139
  ...schema,
6780
7140
  sections
@@ -6791,12 +7151,50 @@ var BaseAddon = class {
6791
7151
  * the store for custom option logic (option narrowing, value snapping) to
6792
7152
  * read it per-node — never `ctx.settings.readAddonStore()` directly.
6793
7153
  * `nodeId` omitted ⇒ the local node (node-blind injection from ctx).
7154
+ *
7155
+ * Keychain values come back RESOLVED (D798): a secret reads as its value,
7156
+ * never as a `{ $secret }` marker. One the keychain cannot serve right now
7157
+ * stays a marker — "stored, unavailable" (`isSecretMarker()` is true, and it
7158
+ * is listed in {@link unresolvedSecrets}) — never `''` and never absent, so
7159
+ * it cannot be mistaken for "nothing stored, mint a new one". Writing the
7160
+ * resolved blob back is a no-op for every unchanged secret.
6794
7161
  */
6795
7162
  async resolveGlobalStore(nodeId, cap) {
6796
7163
  const raw = await this._ctx?.settings?.readAddonStore() ?? {};
7164
+ return this.projectForNode(raw, nodeId, cap);
7165
+ }
7166
+ projectForNode(store, nodeId, cap) {
6797
7167
  const keys = this.perNodeKeys(cap);
6798
7168
  const node = normalizeNodeId(nodeId ?? this._ctx?.kernel?.localNodeId);
6799
- return keys.size > 0 ? projectStore(raw, keys, node) : raw;
7169
+ return keys.size > 0 ? projectStore(store, keys, node) : store;
7170
+ }
7171
+ /** The PROJECTED store with its markers — the form hydrate only (D798). */
7172
+ async readRawProjectedStore(nodeId, cap) {
7173
+ const raw = await this.rawSettings()?.readAddonStore() ?? {};
7174
+ return this.projectForNode(raw, nodeId, cap);
7175
+ }
7176
+ /**
7177
+ * `{ ...stored, ...overlay }`, except that an overlay member equal to the
7178
+ * RESOLVED stored one keeps the stored (marker-bearing) member — so a form
7179
+ * hydrated from a resolved overlay still shows a secret as "set", never as
7180
+ * its value.
7181
+ */
7182
+ async overlayKeepingMarkers(stored, overlay) {
7183
+ const secrets = this._ctx?.secrets;
7184
+ const merged = {
7185
+ ...stored,
7186
+ ...overlay
7187
+ };
7188
+ if (secrets === void 0 || collectSecretMarkerRefs(stored).length === 0) return merged;
7189
+ const { value: resolved } = await resolveSecretMarkers(stored, secrets, {
7190
+ unresolved: "keep-marker",
7191
+ ownedBy: secrets.owner
7192
+ });
7193
+ for (const key of Object.keys(overlay)) {
7194
+ if (collectSecretMarkerRefs(stored[key]).length === 0) continue;
7195
+ if (isJsonEqual(overlay[key], resolved[key])) merged[key] = stored[key];
7196
+ }
7197
+ return merged;
6800
7198
  }
6801
7199
  /**
6802
7200
  * Whether ONE global key of this addon's store was written, read three-way
@@ -6861,8 +7259,12 @@ var BaseAddon = class {
6861
7259
  async clearSecrets(keys, nodeId) {
6862
7260
  const tree = this.addonSecretTree();
6863
7261
  const keychain = this._ctx?.secrets !== void 0;
7262
+ const stored = keychain ? await this.readAddonStoreWithRetry() : {};
6864
7263
  const patch = {};
6865
- for (const key of keys) patch[key] = keychain && tree.has(key) ? SECRET_CLEAR : "";
7264
+ for (const key of keys) {
7265
+ const keychainStored = tree.has(key) || collectSecretMarkerRefs(stored[key]).length > 0;
7266
+ patch[key] = keychain && keychainStored ? SECRET_CLEAR : "";
7267
+ }
6866
7268
  await this.applyGlobalPatch(patch, nodeId);
6867
7269
  }
6868
7270
  async applyGlobalPatch(barePatch, nodeId) {
@@ -6870,7 +7272,11 @@ var BaseAddon = class {
6870
7272
  const localNode = normalizeNodeId(this._ctx?.kernel?.localNodeId);
6871
7273
  const target = normalizeNodeId(nodeId ?? this._ctx?.kernel?.localNodeId);
6872
7274
  const scoped = keys.size > 0 ? scopePatch(barePatch, keys, target) : barePatch;
6873
- await this._ctx?.settings?.writeAddonStore(scoped);
7275
+ const handle = this._secretSettings;
7276
+ if (handle !== null) {
7277
+ const { changed } = await handle.writeAddonStore(scoped);
7278
+ if (!changed) return;
7279
+ } else await this._ctx?.settings?.writeAddonStore(scoped);
6874
7280
  if (target !== localNode) return;
6875
7281
  await this.resolveConfig();
6876
7282
  await this.onConfigChanged();
@@ -6923,7 +7329,7 @@ var BaseAddon = class {
6923
7329
  async getDeviceSettings(deviceId) {
6924
7330
  const schema = this.deviceSettingsSchema();
6925
7331
  if (!schema) return { sections: [] };
6926
- return hydrateSchema(schema, await this._ctx?.settings?.readDeviceStore(deviceId) ?? {}, { inlineSecretsAsViews: true });
7332
+ return hydrateSchema(schema, await this.rawSettings()?.readDeviceStore(deviceId) ?? {}, { inlineSecretsAsViews: true });
6927
7333
  }
6928
7334
  async updateDeviceSettings(deviceId, patch) {
6929
7335
  await this._ctx?.settings?.writeDeviceStore(deviceId, patch);
@@ -7095,7 +7501,7 @@ var BaseAddon = class {
7095
7501
  key,
7096
7502
  schema,
7097
7503
  fallback,
7098
- read: async () => this.resolveStoredSecrets(await this._ctx?.settings?.readDeviceStore(deviceId) ?? {}, false),
7504
+ read: async () => this.resolveStoredSecrets(await this.rawSettings()?.readDeviceStore(deviceId) ?? {}, false),
7099
7505
  write: async (patch) => {
7100
7506
  await this._ctx?.settings?.writeDeviceStore(deviceId, patch);
7101
7507
  },
@@ -7157,6 +7563,23 @@ var BaseAddon = class {
7157
7563
  }
7158
7564
  return value;
7159
7565
  }
7566
+ /**
7567
+ * The marker-bearing settings reads (D798) — private on purpose. Without a
7568
+ * keychain the context's own view is already raw.
7569
+ */
7570
+ rawSettings() {
7571
+ return this._secretSettings?.raw ?? this._ctx?.settings;
7572
+ }
7573
+ /** An addon-facing read met markers it could not resolve: say so once per ref. */
7574
+ logUnresolvedRead(unresolved) {
7575
+ const fresh = unresolved.filter((u) => !this._loggedUnresolvedReads.has(u.ref));
7576
+ if (fresh.length === 0) return;
7577
+ for (const u of fresh) this._loggedUnresolvedReads.add(u.ref);
7578
+ 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) => ({
7579
+ ref: u.ref,
7580
+ reason: u.reason
7581
+ })) } });
7582
+ }
7160
7583
  /** Re-resolve the config (a keychain-only change, or a retry) and apply it. */
7161
7584
  scheduleSecretReresolve(delayMs) {
7162
7585
  const timerOf = delayMs === SECRET_CHANGE_DEBOUNCE_MS ? "_secretChangeTimer" : "_secretRetryTimer";
@@ -7183,7 +7606,7 @@ var BaseAddon = class {
7183
7606
  * `{}` (defaults) — the addon's first successful patch will rehydrate.
7184
7607
  */
7185
7608
  async readAddonStoreWithRetry() {
7186
- const settings = this._ctx?.settings;
7609
+ const settings = this.rawSettings();
7187
7610
  if (!settings) return {};
7188
7611
  const delaysMs = [
7189
7612
  150,
@@ -9409,6 +9832,278 @@ var CameraSwitchGroupSchema = object({
9409
9832
  fetchedAt: number()
9410
9833
  });
9411
9834
  /**
9835
+ * The trainer contract — what the hub hands the cloud trainer and what it
9836
+ * gets back (cloud training, D805+).
9837
+ *
9838
+ * The trainer (`hf/camstack-trainer`, published as the Hugging Face repo
9839
+ * `camstack/camstack-trainer`) is a separate AGPL program the hub never
9840
+ * imports: `job.json` goes in, files come out, and progress is `CAMSTACK_EVENT`
9841
+ * lines on stdout. These schemas are the hub's half of that boundary; the
9842
+ * trainer's pydantic models (and the JSON Schemas generated from them under
9843
+ * `hf/camstack-trainer/schemas/`) are the other half. A change here is a
9844
+ * change there, in the same piece of work.
9845
+ *
9846
+ * No `.default()` anywhere: defaults do not run on the addon cap path, so the
9847
+ * orchestrator fills every field of a job spec explicitly.
9848
+ */
9849
+ var TRAINING_JOB_SCHEMA = "camstack.training/v1";
9850
+ var TRAINING_RESULT_SCHEMA = "camstack.training-result/v1";
9851
+ /** What the trainer can export. Edge TPU is a later, separate image. */
9852
+ var TrainingExportSchema = _enum([
9853
+ "onnx",
9854
+ "openvino-fp16",
9855
+ "openvino-int8",
9856
+ "coreml-fp16"
9857
+ ]);
9858
+ var FloorsSchema = record(string(), number().min(0).max(1));
9859
+ object({
9860
+ schema: literal(TRAINING_JOB_SCHEMA),
9861
+ jobKey: string().uuid(),
9862
+ target: object({
9863
+ kind: literal("detector"),
9864
+ step: literal("object-detection")
9865
+ }),
9866
+ base: object({
9867
+ modelId: string().min(1),
9868
+ /** Ultralytics weights id, e.g. `yolov9m.pt`. */
9869
+ weights: string().min(1),
9870
+ imgsz: number().int().positive()
9871
+ }),
9872
+ baseline: object({
9873
+ modelId: string().min(1),
9874
+ /** The baseline ONNX the holdout comparison runs; public mirror URL. */
9875
+ onnxUrl: string().url(),
9876
+ imgsz: number().int().positive(),
9877
+ floors: FloorsSchema
9878
+ }),
9879
+ dataset: object({
9880
+ versionId: string().min(1),
9881
+ annotationHash: string(),
9882
+ /** sha256 of the uploaded archive; the trainer refuses a mismatch (exit 65). */
9883
+ sha256: string().regex(/^[0-9a-f]{64}$/)
9884
+ }),
9885
+ split: object({
9886
+ holdoutCameras: array(number().int()),
9887
+ /** When no camera is held out: the last N days of every camera. */
9888
+ holdoutLastDays: number().int().nonnegative(),
9889
+ valFraction: number().min(0).max(.5),
9890
+ seed: number().int()
9891
+ }),
9892
+ hyper: object({
9893
+ epochs: number().int().positive(),
9894
+ batch: number().int().positive(),
9895
+ lr0: number().positive(),
9896
+ /** Layers frozen from the start of the backbone; 0 = none. */
9897
+ freeze: number().int().nonnegative(),
9898
+ patience: number().int().nonnegative(),
9899
+ seed: number().int()
9900
+ }),
9901
+ replay: object({
9902
+ source: literal("coco2017"),
9903
+ count: number().int().nonnegative()
9904
+ }),
9905
+ exports: array(TrainingExportSchema).min(1),
9906
+ calibration: object({ maxFrames: number().int().positive() }),
9907
+ floors: object({
9908
+ minSupport: number().int().positive(),
9909
+ clamp: number().min(0).max(1)
9910
+ }),
9911
+ int8Gate: object({ maxMap50Drop: number().min(0).max(1) }),
9912
+ catalog: object({
9913
+ id: string().regex(/^[a-z0-9][a-z0-9-]{2,80}$/),
9914
+ name: string().min(1).max(160)
9915
+ })
9916
+ });
9917
+ /** One regular file of the bundle. An mlpackage contributes one row per member. */
9918
+ var TrainingResultFileSchema = object({
9919
+ path: string().min(1),
9920
+ bytes: number().int().nonnegative(),
9921
+ sha256: string().regex(/^[0-9a-f]{64}$/),
9922
+ format: _enum([
9923
+ "onnx",
9924
+ "openvino",
9925
+ "coreml",
9926
+ "pt"
9927
+ ]),
9928
+ variant: _enum(["base", "int8"])
9929
+ });
9930
+ var DraftFormatSchema = object({
9931
+ /** RELATIVE path inside the bundle; the hub rewrites it to `camstack-local://`. */
9932
+ url: string().min(1),
9933
+ sizeMB: number().nonnegative(),
9934
+ isDirectory: boolean().optional(),
9935
+ files: array(string()).optional(),
9936
+ runtimes: array(literal("python")).optional(),
9937
+ revision: string().min(1)
9938
+ });
9939
+ /** The trainer's half of a catalog entry; the hub completes it (labels, licence, group). */
9940
+ var TrainingCatalogDraftSchema = object({
9941
+ id: string().min(1),
9942
+ name: string().min(1),
9943
+ description: string(),
9944
+ labels: array(unknown()),
9945
+ inputSize: object({
9946
+ width: number().int().positive(),
9947
+ height: number().int().positive()
9948
+ }),
9949
+ preprocessMode: literal("letterbox"),
9950
+ defaultClassFloors: FloorsSchema,
9951
+ formats: object({
9952
+ onnx: DraftFormatSchema.optional(),
9953
+ openvino: DraftFormatSchema.optional(),
9954
+ coreml: DraftFormatSchema.optional()
9955
+ })
9956
+ });
9957
+ /** One class of one model's holdout report (the eval harness's summary). */
9958
+ var TrainingEvalClassSchema = object({
9959
+ positives: number().int(),
9960
+ floor: number().nullable(),
9961
+ tp: number().int(),
9962
+ fp: number().int(),
9963
+ fn: number().int(),
9964
+ precision: number().nullable(),
9965
+ recall: number().nullable(),
9966
+ ap50: number().nullable(),
9967
+ recallByCamera: record(string(), number().nullable()).optional(),
9968
+ recallByLight: record(string(), number().nullable()).optional(),
9969
+ fpByCamera: record(string(), number()).optional(),
9970
+ smallFound: number().int().optional(),
9971
+ smallTotal: number().int().optional()
9972
+ }).passthrough();
9973
+ var TrainingEvalReportSchema = object({
9974
+ frames: number().int(),
9975
+ classes: record(string(), TrainingEvalClassSchema)
9976
+ }).passthrough();
9977
+ /**
9978
+ * A succeeded result carries every block; a failed one carries the error and
9979
+ * whatever was known by then — the other blocks are ABSENT, not null. The
9980
+ * orchestrator checks the blocks it needs before it trusts a success.
9981
+ */
9982
+ var TrainingResultSchema = object({
9983
+ schema: literal(TRAINING_RESULT_SCHEMA),
9984
+ jobKey: string(),
9985
+ status: _enum(["succeeded", "failed"]),
9986
+ error: object({
9987
+ stage: string(),
9988
+ code: string(),
9989
+ message: string()
9990
+ }).nullable(),
9991
+ trainer: object({
9992
+ version: string(),
9993
+ revision: string()
9994
+ }),
9995
+ toolchain: record(string(), string().nullable()),
9996
+ dataset: object({
9997
+ versionId: string(),
9998
+ annotationHash: string(),
9999
+ sha256: string(),
10000
+ frames: object({
10001
+ train: number().int(),
10002
+ val: number().int(),
10003
+ holdout: number().int()
10004
+ }),
10005
+ holdoutCameras: array(number().int()),
10006
+ replayImages: number().int()
10007
+ }).optional(),
10008
+ training: object({
10009
+ epochsRun: number().int(),
10010
+ bestEpoch: number().int(),
10011
+ bestMap50: number(),
10012
+ bestMap50_95: number(),
10013
+ seconds: number()
10014
+ }).optional(),
10015
+ evaluation: object({
10016
+ holdoutFrames: number().int(),
10017
+ baseline: TrainingEvalReportSchema.nullable(),
10018
+ candidate: TrainingEvalReportSchema.nullable(),
10019
+ candidateInt8: TrainingEvalReportSchema.nullable(),
10020
+ recallDeltaByCamera: record(string(), record(string(), number())).nullable(),
10021
+ map50: record(string(), number().nullable())
10022
+ }).optional(),
10023
+ floors: object({
10024
+ baseline: FloorsSchema,
10025
+ candidate: FloorsSchema,
10026
+ candidateInt8: FloorsSchema.nullable(),
10027
+ notes: array(string())
10028
+ }).optional(),
10029
+ int8: object({
10030
+ kept: boolean(),
10031
+ map50Fp16: number().nullable(),
10032
+ map50Int8: number().nullable(),
10033
+ reason: string().nullable()
10034
+ }).optional(),
10035
+ exportsDropped: array(object({
10036
+ export: string(),
10037
+ reason: string()
10038
+ })).optional(),
10039
+ files: array(TrainingResultFileSchema).optional(),
10040
+ bundle: object({
10041
+ path: literal("bundle.tar"),
10042
+ bytes: number().int().nonnegative(),
10043
+ sha256: string().regex(/^[0-9a-f]{64}$/)
10044
+ }).nullable().optional(),
10045
+ catalogDraft: object({
10046
+ base: TrainingCatalogDraftSchema,
10047
+ int8: TrainingCatalogDraftSchema.nullable()
10048
+ }).nullable().optional(),
10049
+ licence: string()
10050
+ });
10051
+ var TrainingStageSchema = _enum([
10052
+ "prepare",
10053
+ "replay",
10054
+ "train",
10055
+ "eval",
10056
+ "export",
10057
+ "package"
10058
+ ]);
10059
+ var EventBase = {
10060
+ v: literal(1),
10061
+ ts: number()
10062
+ };
10063
+ discriminatedUnion("type", [
10064
+ object({
10065
+ ...EventBase,
10066
+ type: literal("stage"),
10067
+ stage: TrainingStageSchema
10068
+ }),
10069
+ object({
10070
+ ...EventBase,
10071
+ type: literal("epoch"),
10072
+ epoch: number().int(),
10073
+ epochs: number().int(),
10074
+ boxLoss: number().nullable().optional(),
10075
+ map50: number().nullable().optional(),
10076
+ map50_95: number().nullable().optional(),
10077
+ etaSec: number().nullable().optional()
10078
+ }),
10079
+ object({
10080
+ ...EventBase,
10081
+ type: literal("metric"),
10082
+ name: string(),
10083
+ value: number()
10084
+ }),
10085
+ object({
10086
+ ...EventBase,
10087
+ type: literal("artifact"),
10088
+ path: string(),
10089
+ bytes: number(),
10090
+ sha256: string()
10091
+ }),
10092
+ object({
10093
+ ...EventBase,
10094
+ type: literal("done"),
10095
+ status: _enum(["succeeded", "failed"]),
10096
+ resultSha256: string().nullable().optional()
10097
+ }),
10098
+ object({
10099
+ ...EventBase,
10100
+ type: literal("error"),
10101
+ stage: string(),
10102
+ code: string(),
10103
+ message: string()
10104
+ })
10105
+ ]);
10106
+ /**
9412
10107
  * What the gate decided about a birth, from the CALLER's point of view.
9413
10108
  *
9414
10109
  * Deliberately not `ConfirmationVerdict`: `undecided` is not a birth decision
@@ -11736,7 +12431,9 @@ var AddonHttpRouteSchema = object({
11736
12431
  "authenticated",
11737
12432
  "admin"
11738
12433
  ]).optional(),
11739
- description: string().optional()
12434
+ description: string().optional(),
12435
+ /** The hub limits this route per client address before the handler runs. */
12436
+ rateLimit: _enum(["auth"]).optional()
11740
12437
  });
11741
12438
  /**
11742
12439
  * Cross-process route invocation envelope. The hub captures the
@@ -12441,6 +13138,37 @@ var BackupDestinationInfoSchema = object({
12441
13138
  lastError: string().optional()
12442
13139
  });
12443
13140
  /**
13141
+ * How an archive is encrypted (operator decision 2026-10-09): to a backup
13142
+ * PUBLIC key the hub holds, so only the operator's secret key opens it.
13143
+ * Absent on a plain `.tar.gz` — every archive made before encryption, or
13144
+ * with it off — which restores without a key.
13145
+ */
13146
+ var BackupArchiveEncryptionSchema = object({
13147
+ /** `x25519-hkdf-aes256gcm-stream-v1`. */
13148
+ scheme: string(),
13149
+ /** 16 hex — the backup key whose secret restores this archive. */
13150
+ keyId: string()
13151
+ });
13152
+ /**
13153
+ * The backup encryption setting. The hub keeps PUBLIC keys only: the active
13154
+ * one new archives are encrypted to, and the retired ones older archives
13155
+ * still need. The secret key is shown once, at `setupEncryption`.
13156
+ */
13157
+ var BackupEncryptionStatusSchema = object({
13158
+ enabled: boolean(),
13159
+ active: object({
13160
+ keyId: string(),
13161
+ publicKey: string(),
13162
+ createdAt: number()
13163
+ }).nullable(),
13164
+ /** Every key ever set up, newest first. */
13165
+ keys: array(object({
13166
+ keyId: string(),
13167
+ createdAt: number(),
13168
+ retiredAt: number().nullable()
13169
+ })).readonly()
13170
+ });
13171
+ /**
12444
13172
  * Per-archive entry returned by `backup.listArchives({ destinationId })`.
12445
13173
  * Same shape the destination drill-in renders. Sourced from the per-
12446
13174
  * location `manifests.json` (no per-archive tarball read required).
@@ -12452,7 +13180,9 @@ var BackupArchiveEntrySchema = object({
12452
13180
  sizeBytes: number(),
12453
13181
  label: string().optional(),
12454
13182
  /** Top-level locations included in the archive (db, addons, tls, …). */
12455
- locations: array(string()).readonly()
13183
+ locations: array(string()).readonly(),
13184
+ /** Present when the archive is encrypted; restore then needs that key. */
13185
+ encryption: BackupArchiveEncryptionSchema.optional()
12456
13186
  });
12457
13187
  var BackupEntrySchema = object({
12458
13188
  id: string(),
@@ -12461,7 +13191,8 @@ var BackupEntrySchema = object({
12461
13191
  label: string().optional(),
12462
13192
  createdAt: number(),
12463
13193
  sizeBytes: number(),
12464
- locations: array(string()).optional()
13194
+ locations: array(string()).optional(),
13195
+ encryption: BackupArchiveEncryptionSchema.optional()
12465
13196
  });
12466
13197
  var ArchiveEntrySchema = object({
12467
13198
  path: string(),
@@ -12650,10 +13381,40 @@ method(_void(), array(BackupDestinationInfoSchema).readonly(), { auth: "admin" }
12650
13381
  * this list and skips entries whose path doesn't start with
12651
13382
  * any of them.
12652
13383
  */
12653
- locations: array(string()).optional()
13384
+ locations: array(string()).optional(),
13385
+ /**
13386
+ * The backup SECRET key, for an encrypted archive (ignored for a plain
13387
+ * one). The archive is decrypted into the hub's private staging
13388
+ * before the restart; the key is not stored. A wrong or missing key
13389
+ * is refused before the archive is downloaded.
13390
+ */
13391
+ backupSecretKey: string().optional()
12654
13392
  }), _void(), {
12655
13393
  kind: "mutation",
12656
13394
  auth: "admin"
13395
+ }), method(_void(), BackupEncryptionStatusSchema, { auth: "admin" }), method(object({}), object({
13396
+ keyId: string(),
13397
+ secretKey: string(),
13398
+ publicKey: string(),
13399
+ createdAt: number(),
13400
+ replacedKeyId: string().nullable()
13401
+ }), {
13402
+ kind: "mutation",
13403
+ auth: "admin"
13404
+ }), method(object({}), object({ disabledKeyId: string().nullable() }), {
13405
+ kind: "mutation",
13406
+ auth: "admin"
13407
+ }), method(object({ backupSecretKey: string() }), object({
13408
+ valid: boolean(),
13409
+ keyId: string().nullable(),
13410
+ /** The hub knows this key (active or retired). */
13411
+ known: boolean(),
13412
+ /** It is the key new archives are encrypted to. */
13413
+ active: boolean(),
13414
+ error: string().optional()
13415
+ }), {
13416
+ kind: "mutation",
13417
+ auth: "admin"
12657
13418
  }), method(object({
12658
13419
  destinationId: string(),
12659
13420
  backupId: string()
@@ -14277,7 +15038,60 @@ var CustomModelDescriptorSchema = object({
14277
15038
  stepId: string(),
14278
15039
  entry: ModelCatalogEntrySchema
14279
15040
  });
14280
- method(_void(), array(CustomModelDescriptorSchema).readonly(), { auth: "admin" });
15041
+ /** One regular file of an imported bundle, as the producer measured it. */
15042
+ var ModelBundleFileSchema = object({
15043
+ /** Relative path inside the bundle tar; an mlpackage member is `<x>.mlpackage/<member>`. */
15044
+ path: string().min(1),
15045
+ bytes: number().int().nonnegative(),
15046
+ sha256: string().regex(/^[0-9a-f]{64}$/)
15047
+ });
15048
+ var ImportModelBundleInputSchema = object({
15049
+ /** The registry provider that keeps the model (Model Studio). */
15050
+ addonId: string(),
15051
+ stepId: string().min(1),
15052
+ /**
15053
+ * The catalog rows to register, complete, every format URL already
15054
+ * `camstack-local://<modelId>/<file>` naming a file of the bundle. One
15055
+ * bundle may carry several rows (a base and its INT8 variant).
15056
+ */
15057
+ entries: array(ModelCatalogEntrySchema).min(1).max(4),
15058
+ /** The bundle tar, offered by the producer over `ctx.peerBytes` (same host). */
15059
+ bundle: object({
15060
+ ticket: PeerBytesTicketSchema,
15061
+ bytes: number().int().positive(),
15062
+ sha256: string().regex(/^[0-9a-f]{64}$/)
15063
+ }),
15064
+ /** Every file the tar must hold; anything missing, extra or different is refused. */
15065
+ files: array(ModelBundleFileSchema).min(1).max(64),
15066
+ /** Convert missing engine formats and push the model to every agent afterwards. */
15067
+ distribute: boolean()
15068
+ });
15069
+ var ImportModelBundleResultSchema = discriminatedUnion("kind", [object({
15070
+ kind: literal("imported"),
15071
+ modelIds: array(string()).readonly(),
15072
+ distributed: array(object({
15073
+ modelId: string(),
15074
+ nodeId: string(),
15075
+ format: _enum(MODEL_FORMATS),
15076
+ ok: boolean(),
15077
+ error: string().optional()
15078
+ })).readonly()
15079
+ }), object({
15080
+ kind: literal("refused"),
15081
+ reason: _enum([
15082
+ "transfer-failed",
15083
+ "checksum-mismatch",
15084
+ "bundle-mismatch",
15085
+ "invalid-entry",
15086
+ "id-taken"
15087
+ ]),
15088
+ detail: string()
15089
+ })]);
15090
+ method(_void(), array(CustomModelDescriptorSchema).readonly(), { auth: "admin" }), method(ImportModelBundleInputSchema, ImportModelBundleResultSchema, {
15091
+ kind: "mutation",
15092
+ auth: "admin",
15093
+ timeoutMs: 30 * 6e4
15094
+ });
14281
15095
  /**
14282
15096
  * Query filter for settings-store collections.
14283
15097
  */
@@ -14756,6 +15570,35 @@ var KeychainKeySourceSchema = object({
14756
15570
  */
14757
15571
  sharesBackupWithDatabase: boolean()
14758
15572
  });
15573
+ /**
15574
+ * One keychain reset, as the Secrets page reports it until the operator
15575
+ * acknowledges it. Never a value: refs, counts and table names only.
15576
+ */
15577
+ var KeychainResetRecordSchema = object({
15578
+ id: string(),
15579
+ at: number(),
15580
+ /** `user:<id>` or {@link KEYCHAIN_RESET_TRIGGER_ACTOR}. */
15581
+ actor: string(),
15582
+ /** Why the keychain was locked when it was reset; `null` when it was not locked. */
15583
+ lockedReason: string().nullable(),
15584
+ /** Values moved into the archive table (ciphertext under the lost key). */
15585
+ archived: number().int(),
15586
+ /** `keychain:secrets-orphaned-<ts>`, or `null` when nothing was stored. */
15587
+ archivedCollection: string().nullable(),
15588
+ /**
15589
+ * `keychain:keys-orphaned-<ts>`: the wrapped data keys of the archive, kept
15590
+ * so the archive can still be opened if the lost master key turns up.
15591
+ */
15592
+ archivedKeysCollection: string().nullable(),
15593
+ /**
15594
+ * `system-settings` keys whose marker the reset cleared — the cluster
15595
+ * secret's: a marker left pointing at an archived value would refuse every
15596
+ * agent forever (D797).
15597
+ */
15598
+ clearedSettingsKeys: array(string()).readonly(),
15599
+ /** When an operator dismissed the notice on the Secrets page; `null` until then. */
15600
+ acknowledgedAt: number().nullable()
15601
+ });
14759
15602
  var KeychainStatusSchema = object({
14760
15603
  keychain: KeychainStateSchema,
14761
15604
  /** The source of the master key in use; `null` while locked. */
@@ -14773,7 +15616,9 @@ var KeychainStatusSchema = object({
14773
15616
  /** Wrapped copies of the data key under a previous master key, kept until purged. */
14774
15617
  retiredWraps: number().int(),
14775
15618
  recoveryKeyDownloadedAt: number().nullable(),
14776
- secretCount: number().int()
15619
+ secretCount: number().int(),
15620
+ /** The most recent reset, acknowledged or not; `null` when the keychain was never reset. */
15621
+ lastReset: KeychainResetRecordSchema.nullable()
14777
15622
  });
14778
15623
  /**
14779
15624
  * Whether a stored value is still pointed at by its owner's settings.
@@ -14795,17 +15640,26 @@ var KeychainAuditActionSchema = _enum([
14795
15640
  "download-recovery-key",
14796
15641
  "delete-orphans",
14797
15642
  "reset",
15643
+ "acknowledge-reset",
14798
15644
  "initialize"
14799
15645
  ]);
14800
15646
  var KeychainAuditEntrySchema = object({
14801
15647
  id: string(),
14802
15648
  at: number(),
14803
15649
  action: KeychainAuditActionSchema,
14804
- /** `addon:<id>` | `user:<id>` | `system`. */
15650
+ /** `addon:<id>` | `user:<id>` | `system` | `trigger-file`. */
14805
15651
  actor: string(),
14806
15652
  ref: string().nullable(),
14807
15653
  detail: string().nullable()
14808
15654
  });
15655
+ var KEYCHAIN_RESET_CONFIRMATION = "RESET KEYCHAIN";
15656
+ /**
15657
+ * Secrets the HUB itself holds (owner `system`) that no settings form shows:
15658
+ * `jwt-signing-key` — the session signing key (D797). It is always "in use",
15659
+ * never an orphan; it is generated on a fresh hub and replaced only through
15660
+ * {@link keychainAdminCapability.methods.setSystemSecret}.
15661
+ */
15662
+ var SystemHeldSecretNameSchema = _enum(["jwt-signing-key"]);
14809
15663
  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({
14810
15664
  value: string(),
14811
15665
  version: number().int()
@@ -14813,6 +15667,16 @@ method(object({}), KeychainStatusSchema, { auth: "admin" }), method(object({}),
14813
15667
  kind: "mutation",
14814
15668
  auth: "admin",
14815
15669
  caller: "required"
15670
+ }), method(object({
15671
+ name: SystemHeldSecretNameSchema,
15672
+ value: string().min(16)
15673
+ }), object({
15674
+ ref: string(),
15675
+ version: number().int()
15676
+ }), {
15677
+ kind: "mutation",
15678
+ auth: "admin",
15679
+ caller: "required"
14816
15680
  }), method(object({ refs: array(string().min(1)).max(1e3) }), object({
14817
15681
  deleted: array(string()).readonly(),
14818
15682
  kept: array(object({
@@ -14842,13 +15706,20 @@ method(object({}), KeychainStatusSchema, { auth: "admin" }), method(object({}),
14842
15706
  kind: "mutation",
14843
15707
  auth: "admin",
14844
15708
  caller: "required"
14845
- }), method(object({ confirm: literal("RESET KEYCHAIN") }), object({
15709
+ }), method(object({ confirm: literal(KEYCHAIN_RESET_CONFIRMATION) }), object({
14846
15710
  archivedCollection: string().nullable(),
14847
15711
  archived: number().int()
14848
15712
  }), {
14849
15713
  kind: "mutation",
14850
15714
  auth: "admin",
14851
15715
  caller: "required"
15716
+ }), method(object({}), object({
15717
+ reset: KeychainResetRecordSchema.nullable(),
15718
+ pendingReentry: array(KeychainSecretMetaSchema).readonly()
15719
+ }), { auth: "admin" }), method(object({}), object({ acknowledged: boolean() }), {
15720
+ kind: "mutation",
15721
+ auth: "admin",
15722
+ caller: "required"
14852
15723
  });
14853
15724
  method(_void(), object({
14854
15725
  id: string(),
@@ -17494,7 +18365,7 @@ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
17494
18365
  * `login-method` — collection cap through which auth addons contribute
17495
18366
  * their pre-auth login surfaces to the login page. This is the SINGLE,
17496
18367
  * generic mechanism that supersedes the dead `auth.listProviders` reader:
17497
- * every auth addon (OIDC, magic-link, WebAuthn/passkey) registers a
18368
+ * every auth addon (OIDC, WebAuthn/passkey) registers a
17498
18369
  * `login-method` provider and the PUBLIC `auth.listLoginMethods`
17499
18370
  * procedure aggregates them for the unauthenticated login page.
17500
18371
  *
@@ -17502,8 +18373,7 @@ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
17502
18373
  *
17503
18374
  * - `redirect` — a declarative button. The login page renders a generic
17504
18375
  * button that navigates to `startUrl` (an addon-owned HTTP route).
17505
- * Covers OIDC (`/addon/auth-oidc/<id>/start`) and magic-link with
17506
- * ZERO shell-side JS. A future SSO addon plugs in the same way — the
18376
+ * Covers OIDC (`/addon/auth-oidc/<id>/start`) with ZERO shell-side JS. A future SSO addon plugs in the same way — the
17507
18377
  * login page needs NO change.
17508
18378
  *
17509
18379
  * - `widget` — a Module-Federation widget the login page mounts (via
@@ -17522,8 +18392,8 @@ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
17522
18392
  * decision.
17523
18393
  *
17524
18394
  * Every contribution carries a `stage`:
17525
- * - `primary` — shown on the first credentials screen (OIDC /
17526
- * magic-link buttons; a future usernameless passkey).
18395
+ * - `primary` — shown on the first credentials screen (OIDC
18396
+ * buttons; a usernameless passkey).
17527
18397
  * - `second-factor` — shown AFTER the password leg, gated on the
17528
18398
  * returned `factors` (passkey-as-2FA today).
17529
18399
  *
@@ -17550,7 +18420,7 @@ var LoginMethodContributionSchema = discriminatedUnion("kind", [
17550
18420
  * The provider names an external identity a signed-in user can link to
17551
18421
  * their own account (D782): `auth.listLinkableProviders` /
17552
18422
  * `beginExternalLink` offer exactly the redirect methods that set this,
17553
- * whatever their id. Absent / false — a login button only (magic-link).
18423
+ * whatever their id. Absent / false — a login button only.
17554
18424
  */
17555
18425
  linkable: boolean().optional()
17556
18426
  }),
@@ -21367,8 +22237,7 @@ method(object({}), object({ rules: array(NcRuleSchema) }), { auth: "admin" }), m
21367
22237
  * `super_admin` — collapsed onto the single boolean because every
21368
22238
  * non-admin caller is governed by the same scope-check rules; the
21369
22239
  * distinction was only ever used to route role-specific procedures
21370
- * which we no longer have. Agents are admin sessions issued via
21371
- * `createServiceToken`; CLI / webhook integrations are `cst_*` tokens
22240
+ * which we no longer have. CLI / webhook integrations are `cst_*` tokens
21372
22241
  * with `isAdmin: false` + an explicit scope list.
21373
22242
  */
21374
22243
  /** Per-method access flavour. Materialised on every cap method via codegen. */
@@ -23043,6 +23912,9 @@ var RetrainExportFilterSchema = object({
23043
23912
  frameIds: array(string()).max(2e4).optional(),
23044
23913
  /** Only frames in at least one of these named collections. */
23045
23914
  collectionIds: array(string()).max(200).optional(),
23915
+ /** Exactly the frames of this dataset version (and its completeOnly). An
23916
+ * unknown id selects nothing. */
23917
+ datasetVersionId: string().optional(),
23046
23918
  batchId: string().optional(),
23047
23919
  /** Only frames the operator marked complete (all subjects boxed). */
23048
23920
  completeOnly: boolean().optional()
@@ -23210,6 +24082,67 @@ var RetrainLlmAssistResultSchema = discriminatedUnion("kind", [object({
23210
24082
  ]),
23211
24083
  detail: string().optional()
23212
24084
  })]);
24085
+ /** What a dataset version is cut from. Every field narrows. */
24086
+ var RetrainDatasetSelectionSchema = object({
24087
+ deviceIds: array(number()).readonly().optional(),
24088
+ collectionIds: array(string()).max(200).readonly().optional(),
24089
+ frameIds: array(string()).max(2e4).readonly().optional()
24090
+ });
24091
+ /** The counts a dataset is judged by. */
24092
+ var RetrainDatasetStatsSchema = object({
24093
+ frames: number().int(),
24094
+ completeFrames: number().int(),
24095
+ /** `completeFrames / frames`, 0..1. */
24096
+ completeness: number(),
24097
+ /** Boxes to learn (model errors excluded). */
24098
+ subjects: number().int(),
24099
+ modelErrors: number().int(),
24100
+ /** Complete frames with no subject. */
24101
+ hardNegatives: number().int(),
24102
+ /** Subjects per class × camera × day/night. */
24103
+ cells: array(object({
24104
+ macroClass: string(),
24105
+ deviceId: number(),
24106
+ lighting: _enum([
24107
+ "day",
24108
+ "night",
24109
+ "unknown"
24110
+ ]),
24111
+ subjects: number().int(),
24112
+ frames: number().int()
24113
+ })).readonly(),
24114
+ cameras: array(object({
24115
+ deviceId: number(),
24116
+ frames: number().int(),
24117
+ completeFrames: number().int()
24118
+ })).readonly()
24119
+ });
24120
+ /** An immutable dataset version, without its frame list. */
24121
+ var RetrainDatasetVersionSchema = object({
24122
+ id: string(),
24123
+ name: string(),
24124
+ createdAt: number(),
24125
+ selection: RetrainDatasetSelectionSchema,
24126
+ layout: RetrainExportLayoutSchema,
24127
+ completeOnly: boolean(),
24128
+ frameCount: number().int(),
24129
+ /** sha256 of what the frames taught when the version was frozen. */
24130
+ annotationHash: string(),
24131
+ /** The export manifest schema the version was cut under. */
24132
+ manifestSchema: string(),
24133
+ stats: RetrainDatasetStatsSchema
24134
+ });
24135
+ var CreateRetrainDatasetVersionResultSchema = discriminatedUnion("kind", [object({
24136
+ kind: literal("created"),
24137
+ version: RetrainDatasetVersionSchema
24138
+ }), object({
24139
+ kind: literal("refused"),
24140
+ reason: _enum([
24141
+ "empty-name",
24142
+ "duplicate-name",
24143
+ "no-frames"
24144
+ ])
24145
+ })]);
23213
24146
  /** The outcome of a lifecycle move owned by the retrain page. */
23214
24147
  var RetrainTransitionResultSchema = object({
23215
24148
  trackId: string(),
@@ -23999,6 +24932,47 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
23999
24932
  kind: "mutation",
24000
24933
  auth: "admin",
24001
24934
  timeoutMs: 60 * 6e4
24935
+ }), method(object({
24936
+ filter: RetrainExportFilterSchema,
24937
+ layout: RetrainExportLayoutSchema
24938
+ }), object({
24939
+ ticket: PeerBytesTicketSchema,
24940
+ frames: number().int(),
24941
+ annotations: number().int()
24942
+ }), {
24943
+ kind: "mutation",
24944
+ auth: "admin",
24945
+ timeoutMs: 12e4
24946
+ }), method(object({
24947
+ selection: RetrainDatasetSelectionSchema,
24948
+ completeOnly: boolean().optional()
24949
+ }), RetrainDatasetStatsSchema, {
24950
+ kind: "query",
24951
+ auth: "admin"
24952
+ }), method(object({
24953
+ name: string().max(120),
24954
+ selection: RetrainDatasetSelectionSchema,
24955
+ layout: RetrainExportLayoutSchema,
24956
+ completeOnly: boolean()
24957
+ }), CreateRetrainDatasetVersionResultSchema, {
24958
+ kind: "mutation",
24959
+ auth: "admin",
24960
+ timeoutMs: 12e4
24961
+ }), method(object({}), array(RetrainDatasetVersionSchema).readonly(), {
24962
+ kind: "query",
24963
+ auth: "admin"
24964
+ }), method(object({ id: string() }), object({ deleted: boolean() }), {
24965
+ kind: "mutation",
24966
+ auth: "admin"
24967
+ }), method(object({ id: string() }), object({
24968
+ found: boolean(),
24969
+ annotationHash: string(),
24970
+ matches: boolean(),
24971
+ missingFrames: number().int()
24972
+ }), {
24973
+ kind: "query",
24974
+ auth: "admin",
24975
+ timeoutMs: 12e4
24002
24976
  }), method(object({}), array(RetrainAssistProfileSchema).readonly(), {
24003
24977
  kind: "query",
24004
24978
  auth: "admin"
@@ -27537,8 +28511,8 @@ version: string().optional() }), ServerUpdateActionResultSchema, {
27537
28511
  * `smtp-provider` — pluggable email delivery surface.
27538
28512
  *
27539
28513
  * Collection cap: a deployment may install multiple SMTP relays (e.g.
27540
- * one for transactional / one for notifications). Consumers (magic-link,
27541
- * notifier addons, …) walk the collection and pick the first
28514
+ * one for transactional / one for notifications). Consumers (notifier
28515
+ * addons, …) walk the collection and pick the first
27542
28516
  * ready provider OR target a specific addonId.
27543
28517
  *
27544
28518
  * The shape stays small on purpose — `sendEmail` is enough for the
@@ -27730,7 +28704,7 @@ targets: array(object({
27730
28704
  })));
27731
28705
  /**
27732
28706
  * `sso-bridge` — internal hub-only cap that lets SSO-style auth
27733
- * providers (OIDC, SAML, magic-link, …) mint an HMAC-signed token
28707
+ * providers (OIDC, SAML, …) mint an HMAC-signed token
27734
28708
  * carrying the post-callback claims before redirecting back to
27735
28709
  * `/api/auth/sso/finish`.
27736
28710
  *
@@ -27793,7 +28767,14 @@ var SsoBridgeClaimsSchema = object({
27793
28767
  * Verified `iss` of the id_token behind an OIDC login bridge (D782). A
27794
28768
  * subject is unique only per issuer, so a link is bound to it.
27795
28769
  */
27796
- issuer: string().optional()
28770
+ issuer: string().optional(),
28771
+ /**
28772
+ * SHA-256 (hex) of the `camstack_sso_state` cookie the IdP `/start` set in
28773
+ * the browser that began this sign-in. `/api/auth/sso/finish` requires the
28774
+ * request to present the matching cookie — a login bridge is useless in
28775
+ * any other browser.
28776
+ */
28777
+ browserBinding: string().optional()
27797
28778
  });
27798
28779
  method(object({
27799
28780
  claims: SsoBridgeClaimsSchema,
@@ -37713,16 +38694,6 @@ var ApiKeySummarySchema = object({
37713
38694
  createdAt: number(),
37714
38695
  lastUsedAt: number().optional()
37715
38696
  });
37716
- var CreateApiKeyInputSchema = object({
37717
- label: string(),
37718
- isAdmin: boolean().default(false),
37719
- allowedProviders: union([array(string()), literal("*")]).optional(),
37720
- allowedDevices: record(string(), union([array(string()), literal("*")])).optional()
37721
- });
37722
- var CreateApiKeyResultSchema = object({
37723
- token: string(),
37724
- record: ApiKeySummarySchema
37725
- });
37726
38697
  var ScopedTokenSummarySchema = object({
37727
38698
  id: string(),
37728
38699
  userId: string(),
@@ -37821,17 +38792,10 @@ method(_void(), array(UserSummarySchema), { auth: "admin" }), method(CreateUserI
37821
38792
  }), UserSummarySchema.extend({ passwordHash: string() }).nullable(), {
37822
38793
  kind: "mutation",
37823
38794
  access: "view"
37824
- }), method(_void(), array(ApiKeySummarySchema), { auth: "admin" }), method(CreateApiKeyInputSchema, CreateApiKeyResultSchema, {
37825
- kind: "mutation",
37826
- auth: "admin",
37827
- access: "create"
37828
- }), method(object({ id: string() }), object({ success: literal(true) }), {
38795
+ }), method(_void(), array(ApiKeySummarySchema), { auth: "admin" }), method(object({ id: string() }), object({ success: literal(true) }), {
37829
38796
  kind: "mutation",
37830
38797
  auth: "admin",
37831
38798
  access: "delete"
37832
- }), method(object({ token: string() }), ApiKeySummarySchema.nullable(), {
37833
- kind: "mutation",
37834
- access: "view"
37835
38799
  }), method(CreateScopedTokenInputSchema, CreateScopedTokenResultSchema, {
37836
38800
  kind: "mutation",
37837
38801
  auth: "admin",
@@ -37905,15 +38869,7 @@ method(_void(), array(UserSummarySchema), { auth: "admin" }), method(CreateUserI
37905
38869
  }).nullable(), { access: "view" }), method(object({ userId: string() }), array(ExternalIdentitySchema), { auth: "admin" }), method(ExternalIdentityKeySchema, object({
37906
38870
  userId: string(),
37907
38871
  issuer: string()
37908
- }).nullable(), { auth: "admin" }), method(ExternalIdentityKeySchema.extend({
37909
- userId: string(),
37910
- issuer: string().min(1),
37911
- label: string().optional()
37912
- }), object({ success: literal(true) }), {
37913
- kind: "mutation",
37914
- auth: "admin",
37915
- access: "create"
37916
- }), method(ExternalIdentityKeySchema.extend({ userId: string() }), object({ success: boolean() }), {
38872
+ }).nullable(), { auth: "admin" }), method(ExternalIdentityKeySchema.extend({ userId: string() }), object({ success: boolean() }), {
37917
38873
  kind: "mutation",
37918
38874
  auth: "admin",
37919
38875
  access: "delete"
@@ -38308,6 +39264,451 @@ DeviceType.Camera, method(object({
38308
39264
  detection: array(ZoneRuleSchema).readonly(),
38309
39265
  package: array(ZoneRuleSchema).readonly()
38310
39266
  });
39267
+ /**
39268
+ * `training-provider` — ONE cloud that can run the CamStack trainer.
39269
+ *
39270
+ * A thin, mockable translation layer: it knows how to run a container with a
39271
+ * GPU, move a dataset in, read the job's stdout and hand artefacts back. It
39272
+ * knows nothing about datasets, splits, floors, cost policy or Model Studio —
39273
+ * those are the `training` orchestrator's (D805). Every rule written there
39274
+ * once is what makes a second provider (RunPod, a local NVIDIA node) a new
39275
+ * manifest entry and nothing else.
39276
+ *
39277
+ * Collection, routed by the `addonId` in every single-row input (the `llm` /
39278
+ * `notification-output` posture); `describe` concat-fans across providers.
39279
+ * Every method is `admin`: these spend money.
39280
+ *
39281
+ * Every cloud object a provider creates is tagged with the orchestrator's
39282
+ * `jobKey`, so a retried submit finds the job it already started instead of
39283
+ * starting a second GPU, and `listJobs` can find orphans.
39284
+ *
39285
+ * Bytes never ride a cap field: the dataset arrives as a `ctx.peerBytes`
39286
+ * ticket the producer (pipeline-analytics) minted, and artefacts leave as a
39287
+ * ticket the provider mints (D613).
39288
+ */
39289
+ var TrainingGpuOptionSchema = object({
39290
+ id: string(),
39291
+ label: string(),
39292
+ /** List price, USD per GPU-hour, before any region multiplier. */
39293
+ usdPerHour: number().nonnegative(),
39294
+ vramGb: number().nonnegative()
39295
+ });
39296
+ var TrainingRegionOptionSchema = object({
39297
+ /** `''` = any region (the provider's choice). */
39298
+ id: string(),
39299
+ label: string(),
39300
+ priceMultiplier: number().positive()
39301
+ });
39302
+ /**
39303
+ * The provider's per-account settings, as the orchestrator reads them. They
39304
+ * live in the PROVIDER addon's settings (operator decision 2026-10-08: they
39305
+ * depend on the user's account), never hard-coded in the orchestrator.
39306
+ */
39307
+ var TrainingProviderDefaultsSchema = object({
39308
+ gpuType: string(),
39309
+ region: string(),
39310
+ costCapUsd: number().nonnegative(),
39311
+ maxRuntimeSec: number().int().positive(),
39312
+ /** Hours a FAILED job's cloud dataset is kept for debugging; 0 = delete at once. */
39313
+ failedDatasetGraceHours: number().nonnegative()
39314
+ });
39315
+ var TrainingProviderDescriptorSchema = object({
39316
+ addonId: string(),
39317
+ /** `modal`, `runpod`, `fake`, … */
39318
+ kind: string(),
39319
+ label: string(),
39320
+ gpuTypes: array(TrainingGpuOptionSchema).readonly(),
39321
+ regions: array(TrainingRegionOptionSchema).readonly(),
39322
+ maxDatasetBytes: number().int().positive(),
39323
+ maxRuntimeSec: number().int().positive(),
39324
+ freeTierNote: string().optional(),
39325
+ /** Where the data goes, in one sentence the confirm dialog repeats. */
39326
+ dataResidencyNote: string(),
39327
+ /** Credentials are present — never the values. */
39328
+ configured: boolean(),
39329
+ defaults: TrainingProviderDefaultsSchema
39330
+ });
39331
+ var TrainingCredentialCheckSchema = object({
39332
+ ok: boolean(),
39333
+ /** Workspace / account name, when the provider says. */
39334
+ account: string().optional(),
39335
+ reason: _enum([
39336
+ "missing",
39337
+ "invalid",
39338
+ "forbidden",
39339
+ "network",
39340
+ "quota"
39341
+ ]).optional(),
39342
+ detail: string().optional()
39343
+ });
39344
+ var ProviderJobStateSchema = _enum([
39345
+ "pending",
39346
+ "starting",
39347
+ "running",
39348
+ "succeeded",
39349
+ "failed",
39350
+ "cancelled",
39351
+ "lost"
39352
+ ]);
39353
+ var ProviderJobStatusSchema = object({
39354
+ jobKey: string(),
39355
+ providerJobId: string().optional(),
39356
+ state: ProviderJobStateSchema,
39357
+ startedAt: number().optional(),
39358
+ endedAt: number().optional(),
39359
+ exitCode: number().int().optional(),
39360
+ failureReason: string().optional(),
39361
+ gpuType: string(),
39362
+ region: string().optional(),
39363
+ billedSeconds: number().nonnegative(),
39364
+ costUsd: number().nonnegative(),
39365
+ /** True when `costUsd` is runtime × list price, not a billing answer. */
39366
+ costIsEstimate: boolean(),
39367
+ lastFetchedAt: number()
39368
+ });
39369
+ /**
39370
+ * The trainer the job runs, by SOURCE revision: the provider turns it into an
39371
+ * image its own way (Modal builds the published Dockerfile at that revision;
39372
+ * a registry-pull provider maps it to a tag). Recorded on the job and echoed
39373
+ * in `result.json`.
39374
+ */
39375
+ var TrainerSourceRefSchema = object({
39376
+ /** Hugging Face repo id, e.g. `camstack/camstack-trainer`. */
39377
+ repo: string().min(1),
39378
+ /** A commit sha (never a branch) — the job must be reproducible. */
39379
+ revision: string().regex(/^[0-9a-f]{7,64}$/)
39380
+ });
39381
+ var JobRef = {
39382
+ addonId: string(),
39383
+ jobKey: string().uuid()
39384
+ };
39385
+ var TrainingLogLineSchema = object({
39386
+ ts: number(),
39387
+ text: string()
39388
+ });
39389
+ method(object({}), array(TrainingProviderDescriptorSchema).readonly(), { auth: "admin" }), method(object({ addonId: string() }), TrainingCredentialCheckSchema, {
39390
+ kind: "mutation",
39391
+ auth: "admin",
39392
+ timeoutMs: 3e4
39393
+ }), method(object({
39394
+ addonId: string(),
39395
+ gpuType: string(),
39396
+ region: string(),
39397
+ datasetBytes: number().int().nonnegative(),
39398
+ gpuSecondsLow: number().nonnegative(),
39399
+ gpuSecondsHigh: number().nonnegative()
39400
+ }), object({
39401
+ usdLow: number().nonnegative(),
39402
+ usdHigh: number().nonnegative(),
39403
+ notes: array(string()).readonly()
39404
+ }), { auth: "admin" }), method(object({
39405
+ ...JobRef,
39406
+ ticket: PeerBytesTicketSchema
39407
+ }), object({
39408
+ bytes: number().int().nonnegative(),
39409
+ sha256: string()
39410
+ }), {
39411
+ kind: "mutation",
39412
+ auth: "admin",
39413
+ timeoutMs: 120 * 6e4
39414
+ }), method(object({
39415
+ ...JobRef,
39416
+ trainer: TrainerSourceRefSchema,
39417
+ jobSpecJson: string().min(2).max(64e3),
39418
+ gpuType: string(),
39419
+ region: string(),
39420
+ maxRuntimeSec: number().int().positive()
39421
+ }), ProviderJobStatusSchema, {
39422
+ kind: "mutation",
39423
+ auth: "admin",
39424
+ timeoutMs: 30 * 6e4
39425
+ }), method(object(JobRef), ProviderJobStatusSchema, {
39426
+ auth: "admin",
39427
+ timeoutMs: 6e4
39428
+ }), method(object({
39429
+ ...JobRef,
39430
+ cursor: string().optional(),
39431
+ max: number().int().min(1).max(500)
39432
+ }), object({
39433
+ lines: array(TrainingLogLineSchema).readonly(),
39434
+ cursor: string()
39435
+ }), {
39436
+ auth: "admin",
39437
+ timeoutMs: 6e4
39438
+ }), method(object(JobRef), object({ ok: literal(true) }), {
39439
+ kind: "mutation",
39440
+ auth: "admin",
39441
+ timeoutMs: 6e4
39442
+ }), method(object(JobRef), object({
39443
+ found: boolean(),
39444
+ text: string().optional()
39445
+ }), {
39446
+ kind: "mutation",
39447
+ auth: "admin",
39448
+ timeoutMs: 5 * 6e4
39449
+ }), method(object({
39450
+ ...JobRef,
39451
+ path: _enum(["bundle.tar"])
39452
+ }), object({ ticket: PeerBytesTicketSchema }), {
39453
+ kind: "mutation",
39454
+ auth: "admin",
39455
+ timeoutMs: 5 * 6e4
39456
+ }), method(object(JobRef), object({ deleted: array(string()).readonly() }), {
39457
+ kind: "mutation",
39458
+ auth: "admin",
39459
+ timeoutMs: 5 * 6e4
39460
+ }), method(object({ addonId: string() }), array(ProviderJobStatusSchema).readonly(), {
39461
+ auth: "admin",
39462
+ timeoutMs: 2 * 6e4
39463
+ });
39464
+ /**
39465
+ * `training` — the cloud-training orchestrator (D805). Hub-only singleton,
39466
+ * provided by `addon-training`.
39467
+ *
39468
+ * It owns what every provider must agree on, written once:
39469
+ *
39470
+ * - **Dataset versions.** Taken over from pipeline-analytics (D796): the rows
39471
+ * live here (D808); pipeline-analytics still CUTS a version (it owns the corpus and
39472
+ * the export plan) and reaches this store through the five row methods
39473
+ * below, so the Retrain page and the export did not change.
39474
+ * - **Jobs.** A persisted state machine, a reconcile loop against the
39475
+ * provider, a cost guard, a daily orphan sweep and the retention rules.
39476
+ * - **The return flow.** Verified artefacts → Model Studio
39477
+ * (`custom-model-registry.importModelBundle`) → canary on cameras →
39478
+ * rollback. Nothing is ever registered automatically.
39479
+ *
39480
+ * Every method is `admin`.
39481
+ */
39482
+ /** A version WITH its frame list — what the export and a job read. */
39483
+ var TrainingDatasetVersionRowSchema = RetrainDatasetVersionSchema.omit({ frameCount: true }).extend({ frameIds: array(string()).max(2e4).readonly() });
39484
+ /** A base model a detector job can fine-tune, and the baseline it is judged against. */
39485
+ var TrainingBaseModelSchema = object({
39486
+ modelId: string(),
39487
+ label: string(),
39488
+ weights: string(),
39489
+ imgsz: number().int(),
39490
+ baselineOnnxUrl: string(),
39491
+ baselineFloors: record(string(), number()),
39492
+ /** The base the fleet runs most — the UI's default. */
39493
+ recommended: boolean()
39494
+ });
39495
+ var TrainingPresetSchema = _enum([
39496
+ "quick",
39497
+ "standard",
39498
+ "thorough"
39499
+ ]);
39500
+ var TrainingJobRequestSchema = object({
39501
+ datasetVersionId: string().min(1),
39502
+ /** The `training-provider` addon that runs it. */
39503
+ addonId: string().min(1),
39504
+ gpuType: string().min(1),
39505
+ region: string(),
39506
+ baseModelId: string().min(1),
39507
+ preset: TrainingPresetSchema,
39508
+ /** Freeze the backbone's first N layers; `null` = the preset's choice. */
39509
+ freeze: number().int().nonnegative().nullable(),
39510
+ /** Cameras held out whole for evaluation; `null` = the orchestrator's default. */
39511
+ holdoutCameras: array(number().int()).nullable()
39512
+ });
39513
+ var TrainingSplitPlanSchema = object({
39514
+ holdoutCameras: array(number().int()).readonly(),
39515
+ /** Used when no camera is held out: the last N days of every camera. */
39516
+ holdoutLastDays: number().int().nonnegative(),
39517
+ /** Holdout subjects per class (camera holdout only; `null` = known only after the split). */
39518
+ holdoutSupport: record(string(), number().int()).nullable(),
39519
+ trainSubjects: number().int()
39520
+ });
39521
+ var TrainingRefusalReasonSchema = _enum([
39522
+ "unknown-dataset",
39523
+ "unknown-provider",
39524
+ "provider-not-configured",
39525
+ "unknown-base-model",
39526
+ "unknown-gpu",
39527
+ "dataset-too-large",
39528
+ "no-training-subjects",
39529
+ "job-already-running"
39530
+ ]);
39531
+ var TrainingJobPlanSchema = object({
39532
+ refusal: object({
39533
+ reason: TrainingRefusalReasonSchema,
39534
+ detail: string()
39535
+ }).nullable(),
39536
+ warnings: array(string()).readonly(),
39537
+ split: TrainingSplitPlanSchema.nullable(),
39538
+ estimate: object({
39539
+ datasetBytes: number().int(),
39540
+ uploadMinutesAt20Mbps: number(),
39541
+ gpuSecondsLow: number(),
39542
+ gpuSecondsHigh: number(),
39543
+ usdLow: number(),
39544
+ usdHigh: number(),
39545
+ notes: array(string()).readonly()
39546
+ }).nullable(),
39547
+ /** Pre-filled from the provider's settings; the operator may lower or raise them. */
39548
+ defaults: object({
39549
+ maxCostUsd: number(),
39550
+ maxRuntimeSec: number().int()
39551
+ }).nullable(),
39552
+ /** The sentence the confirm dialog repeats: where the frames go and when they are deleted. */
39553
+ dataNotice: string()
39554
+ });
39555
+ /**
39556
+ * Orchestrator-owned states, persisted. `uploading` covers exporting the
39557
+ * archive (it is streamed, never staged). Terminal: `failed`, `cancelled`,
39558
+ * `lost`, `expired`, `discarded`. `registered` and `canary` are where a
39559
+ * result lives after the operator acted on it.
39560
+ */
39561
+ var TrainingJobStateSchema = _enum([
39562
+ "uploading",
39563
+ "submitted",
39564
+ "starting",
39565
+ "running",
39566
+ "collecting",
39567
+ "ready",
39568
+ "registered",
39569
+ "canary",
39570
+ "failed",
39571
+ "cancelling",
39572
+ "cancelled",
39573
+ "lost",
39574
+ "expired",
39575
+ "discarded"
39576
+ ]);
39577
+ var TrainingFailureReasonSchema = _enum([
39578
+ "cost-cap",
39579
+ "runtime-cap",
39580
+ "upload-failed",
39581
+ "submit-failed",
39582
+ "trainer-failed",
39583
+ "result-invalid",
39584
+ "checksum-mismatch",
39585
+ "fetch-failed",
39586
+ "provider-error",
39587
+ "hub-restart-during-upload"
39588
+ ]);
39589
+ var TrainingProgressPointSchema = object({
39590
+ epoch: number().int(),
39591
+ map50: number().nullable(),
39592
+ map50_95: number().nullable()
39593
+ });
39594
+ var TrainingCanarySchema = object({
39595
+ deviceIds: array(number().int()).readonly(),
39596
+ since: number(),
39597
+ /** Every override the canary replaced, exactly, so rollback restores it. */
39598
+ previous: array(object({
39599
+ deviceId: number().int(),
39600
+ nodeId: string(),
39601
+ deviceKey: string(),
39602
+ patch: object({
39603
+ modelId: string().optional(),
39604
+ settings: record(string(), unknown()).readonly().optional()
39605
+ }).nullable()
39606
+ })).readonly()
39607
+ });
39608
+ var TrainingJobSchema = object({
39609
+ id: string(),
39610
+ idempotencyKey: string(),
39611
+ name: string(),
39612
+ createdAt: number(),
39613
+ updatedAt: number(),
39614
+ state: TrainingJobStateSchema,
39615
+ stage: TrainingStageSchema.nullable(),
39616
+ failure: object({
39617
+ reason: TrainingFailureReasonSchema,
39618
+ stage: string().nullable(),
39619
+ detail: string()
39620
+ }).nullable(),
39621
+ request: TrainingJobRequestSchema,
39622
+ maxCostUsd: number().nonnegative(),
39623
+ maxRuntimeSec: number().int().positive(),
39624
+ trainer: TrainerSourceRefSchema,
39625
+ datasetLayout: RetrainExportLayoutSchema,
39626
+ dataset: object({
39627
+ bytes: number().int(),
39628
+ sha256: string(),
39629
+ uploadedAt: number()
39630
+ }).nullable(),
39631
+ split: TrainingSplitPlanSchema,
39632
+ provider: object({
39633
+ state: ProviderJobStateSchema.nullable(),
39634
+ providerJobId: string().nullable(),
39635
+ startedAt: number().nullable(),
39636
+ endedAt: number().nullable(),
39637
+ billedSeconds: number(),
39638
+ costUsd: number(),
39639
+ costIsEstimate: boolean(),
39640
+ lastPolledAt: number().nullable()
39641
+ }),
39642
+ progress: object({
39643
+ epoch: number().int().nullable(),
39644
+ epochs: number().int().nullable(),
39645
+ etaSec: number().nullable(),
39646
+ series: array(TrainingProgressPointSchema).readonly()
39647
+ }),
39648
+ /** The last lines of the job's output (≤ 200), newest last. Never frame paths. */
39649
+ logTail: array(string()).readonly(),
39650
+ logCursor: string().nullable(),
39651
+ artifacts: object({
39652
+ bundleBytes: number().int(),
39653
+ bundleSha256: string(),
39654
+ fetchedAt: number(),
39655
+ /** When the staged artefacts are deleted from the hub. */
39656
+ expiresAt: number()
39657
+ }).nullable(),
39658
+ /** When the provider-side copy of the frames was deleted; null while it exists. */
39659
+ cloudDatasetDeletedAt: number().nullable(),
39660
+ /** A failed job's dataset is kept until then (the provider's grace), then deleted. */
39661
+ cloudCleanupDueAt: number().nullable(),
39662
+ /** Model ids registered from this job (base, and int8 when kept). */
39663
+ registeredModelIds: array(string()).readonly(),
39664
+ canary: TrainingCanarySchema.nullable()
39665
+ });
39666
+ var IdInput = object({ id: string().min(1) });
39667
+ method(TrainingDatasetVersionRowSchema, object({ stored: boolean() }), {
39668
+ kind: "mutation",
39669
+ auth: "admin"
39670
+ }), 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() }), {
39671
+ kind: "mutation",
39672
+ auth: "admin"
39673
+ }), method(object({}), array(TrainingBaseModelSchema).readonly(), { auth: "admin" }), method(TrainingJobRequestSchema, TrainingJobPlanSchema, {
39674
+ auth: "admin",
39675
+ timeoutMs: 6e4
39676
+ }), method(TrainingJobRequestSchema.extend({
39677
+ name: string().min(1).max(120),
39678
+ maxCostUsd: number().positive(),
39679
+ maxRuntimeSec: number().int().positive(),
39680
+ idempotencyKey: string().min(8).max(80)
39681
+ }), discriminatedUnion("kind", [object({
39682
+ kind: literal("started"),
39683
+ job: TrainingJobSchema
39684
+ }), object({
39685
+ kind: literal("refused"),
39686
+ reason: TrainingRefusalReasonSchema,
39687
+ detail: string()
39688
+ })]), {
39689
+ kind: "mutation",
39690
+ auth: "admin",
39691
+ timeoutMs: 12e4
39692
+ }), method(object({}), array(TrainingJobSchema).readonly(), { auth: "admin" }), method(IdInput, TrainingJobSchema.nullable(), { auth: "admin" }), method(IdInput, TrainingJobSchema, {
39693
+ kind: "mutation",
39694
+ auth: "admin",
39695
+ timeoutMs: 12e4
39696
+ }), method(IdInput, TrainingResultSchema.nullable(), { auth: "admin" }), method(IdInput.extend({ canaryDeviceIds: array(number().int()).readonly() }), TrainingJobSchema, {
39697
+ kind: "mutation",
39698
+ auth: "admin",
39699
+ timeoutMs: 30 * 6e4
39700
+ }), method(IdInput.extend({ deviceIds: array(number().int()).min(1).readonly() }), TrainingJobSchema, {
39701
+ kind: "mutation",
39702
+ auth: "admin",
39703
+ timeoutMs: 12e4
39704
+ }), method(IdInput, TrainingJobSchema, {
39705
+ kind: "mutation",
39706
+ auth: "admin",
39707
+ timeoutMs: 12e4
39708
+ }), method(IdInput, TrainingJobSchema, {
39709
+ kind: "mutation",
39710
+ auth: "admin"
39711
+ });
38311
39712
  SOURCE_CAPS.filter((cap) => cap !== "switch" && cap !== "motion");
38312
39713
  Object.freeze({
38313
39714
  person: .5,
@@ -38931,6 +40332,12 @@ Object.freeze({
38931
40332
  addonId: null,
38932
40333
  access: "create"
38933
40334
  },
40335
+ "backup.checkBackupKey": {
40336
+ capName: "backup",
40337
+ capScope: "system",
40338
+ addonId: null,
40339
+ access: "create"
40340
+ },
38934
40341
  "backup.delete": {
38935
40342
  capName: "backup",
38936
40343
  capScope: "system",
@@ -38943,6 +40350,18 @@ Object.freeze({
38943
40350
  addonId: null,
38944
40351
  access: "delete"
38945
40352
  },
40353
+ "backup.disableEncryption": {
40354
+ capName: "backup",
40355
+ capScope: "system",
40356
+ addonId: null,
40357
+ access: "create"
40358
+ },
40359
+ "backup.getEncryption": {
40360
+ capName: "backup",
40361
+ capScope: "system",
40362
+ addonId: null,
40363
+ access: "view"
40364
+ },
38946
40365
  "backup.getEntries": {
38947
40366
  capName: "backup",
38948
40367
  capScope: "system",
@@ -38997,6 +40416,12 @@ Object.freeze({
38997
40416
  addonId: null,
38998
40417
  access: "create"
38999
40418
  },
40419
+ "backup.setupEncryption": {
40420
+ capName: "backup",
40421
+ capScope: "system",
40422
+ addonId: null,
40423
+ access: "create"
40424
+ },
39000
40425
  "backup.trigger": {
39001
40426
  capName: "backup",
39002
40427
  capScope: "system",
@@ -39549,6 +40974,12 @@ Object.freeze({
39549
40974
  addonId: null,
39550
40975
  access: "create"
39551
40976
  },
40977
+ "customModelRegistry.importModelBundle": {
40978
+ capName: "custom-model-registry",
40979
+ capScope: "system",
40980
+ addonId: null,
40981
+ access: "create"
40982
+ },
39552
40983
  "customModelRegistry.listModels": {
39553
40984
  capName: "custom-model-registry",
39554
40985
  capScope: "system",
@@ -40989,6 +42420,12 @@ Object.freeze({
40989
42420
  addonId: null,
40990
42421
  access: "view"
40991
42422
  },
42423
+ "keychainAdmin.acknowledgeReset": {
42424
+ capName: "keychain-admin",
42425
+ capScope: "system",
42426
+ addonId: null,
42427
+ access: "create"
42428
+ },
40992
42429
  "keychainAdmin.deleteOrphans": {
40993
42430
  capName: "keychain-admin",
40994
42431
  capScope: "system",
@@ -41025,6 +42462,12 @@ Object.freeze({
41025
42462
  addonId: null,
41026
42463
  access: "delete"
41027
42464
  },
42465
+ "keychainAdmin.resetReport": {
42466
+ capName: "keychain-admin",
42467
+ capScope: "system",
42468
+ addonId: null,
42469
+ access: "delete"
42470
+ },
41028
42471
  "keychainAdmin.reveal": {
41029
42472
  capName: "keychain-admin",
41030
42473
  capScope: "system",
@@ -41037,6 +42480,12 @@ Object.freeze({
41037
42480
  addonId: null,
41038
42481
  access: "create"
41039
42482
  },
42483
+ "keychainAdmin.setSystemSecret": {
42484
+ capName: "keychain-admin",
42485
+ capScope: "system",
42486
+ addonId: null,
42487
+ access: "create"
42488
+ },
41040
42489
  "keychainAdmin.status": {
41041
42490
  capName: "keychain-admin",
41042
42491
  capScope: "system",
@@ -42483,6 +43932,12 @@ Object.freeze({
42483
43932
  addonId: null,
42484
43933
  access: "create"
42485
43934
  },
43935
+ "pipelineAnalytics.createRetrainDatasetVersion": {
43936
+ capName: "pipeline-analytics",
43937
+ capScope: "device",
43938
+ addonId: null,
43939
+ access: "create"
43940
+ },
42486
43941
  "pipelineAnalytics.deleteDeviceEvents": {
42487
43942
  capName: "pipeline-analytics",
42488
43943
  capScope: "device",
@@ -42495,6 +43950,12 @@ Object.freeze({
42495
43950
  addonId: null,
42496
43951
  access: "delete"
42497
43952
  },
43953
+ "pipelineAnalytics.deleteRetrainDatasetVersion": {
43954
+ capName: "pipeline-analytics",
43955
+ capScope: "device",
43956
+ addonId: null,
43957
+ access: "delete"
43958
+ },
42498
43959
  "pipelineAnalytics.deleteTracks": {
42499
43960
  capName: "pipeline-analytics",
42500
43961
  capScope: "device",
@@ -42717,6 +44178,12 @@ Object.freeze({
42717
44178
  addonId: null,
42718
44179
  access: "view"
42719
44180
  },
44181
+ "pipelineAnalytics.listRetrainDatasetVersions": {
44182
+ capName: "pipeline-analytics",
44183
+ capScope: "device",
44184
+ addonId: null,
44185
+ access: "view"
44186
+ },
42720
44187
  "pipelineAnalytics.listRetrainFrames": {
42721
44188
  capName: "pipeline-analytics",
42722
44189
  capScope: "device",
@@ -42747,6 +44214,12 @@ Object.freeze({
42747
44214
  addonId: null,
42748
44215
  access: "view"
42749
44216
  },
44217
+ "pipelineAnalytics.offerRetrainArchive": {
44218
+ capName: "pipeline-analytics",
44219
+ capScope: "device",
44220
+ addonId: null,
44221
+ access: "create"
44222
+ },
42750
44223
  "pipelineAnalytics.ownersWithMedia": {
42751
44224
  capName: "pipeline-analytics",
42752
44225
  capScope: "device",
@@ -42759,6 +44232,12 @@ Object.freeze({
42759
44232
  addonId: null,
42760
44233
  access: "create"
42761
44234
  },
44235
+ "pipelineAnalytics.previewRetrainDataset": {
44236
+ capName: "pipeline-analytics",
44237
+ capScope: "device",
44238
+ addonId: null,
44239
+ access: "view"
44240
+ },
42762
44241
  "pipelineAnalytics.proposeRetrainAnnotations": {
42763
44242
  capName: "pipeline-analytics",
42764
44243
  capScope: "device",
@@ -42897,6 +44376,12 @@ Object.freeze({
42897
44376
  addonId: null,
42898
44377
  access: "create"
42899
44378
  },
44379
+ "pipelineAnalytics.verifyRetrainDatasetVersion": {
44380
+ capName: "pipeline-analytics",
44381
+ capScope: "device",
44382
+ addonId: null,
44383
+ access: "view"
44384
+ },
42900
44385
  "pipelineAnalytics.wipeAllAnalytics": {
42901
44386
  capName: "pipeline-analytics",
42902
44387
  capScope: "device",
@@ -45273,6 +46758,174 @@ Object.freeze({
45273
46758
  addonId: null,
45274
46759
  access: "view"
45275
46760
  },
46761
+ "training.canaryResult": {
46762
+ capName: "training",
46763
+ capScope: "system",
46764
+ addonId: null,
46765
+ access: "create"
46766
+ },
46767
+ "training.cancelJob": {
46768
+ capName: "training",
46769
+ capScope: "system",
46770
+ addonId: null,
46771
+ access: "create"
46772
+ },
46773
+ "training.discardResult": {
46774
+ capName: "training",
46775
+ capScope: "system",
46776
+ addonId: null,
46777
+ access: "create"
46778
+ },
46779
+ "training.findDatasetVersionIdByName": {
46780
+ capName: "training",
46781
+ capScope: "system",
46782
+ addonId: null,
46783
+ access: "view"
46784
+ },
46785
+ "training.getDatasetVersion": {
46786
+ capName: "training",
46787
+ capScope: "system",
46788
+ addonId: null,
46789
+ access: "view"
46790
+ },
46791
+ "training.getJob": {
46792
+ capName: "training",
46793
+ capScope: "system",
46794
+ addonId: null,
46795
+ access: "view"
46796
+ },
46797
+ "training.getJobResult": {
46798
+ capName: "training",
46799
+ capScope: "system",
46800
+ addonId: null,
46801
+ access: "view"
46802
+ },
46803
+ "training.listBaseModels": {
46804
+ capName: "training",
46805
+ capScope: "system",
46806
+ addonId: null,
46807
+ access: "view"
46808
+ },
46809
+ "training.listDatasetVersions": {
46810
+ capName: "training",
46811
+ capScope: "system",
46812
+ addonId: null,
46813
+ access: "view"
46814
+ },
46815
+ "training.listJobs": {
46816
+ capName: "training",
46817
+ capScope: "system",
46818
+ addonId: null,
46819
+ access: "view"
46820
+ },
46821
+ "training.planJob": {
46822
+ capName: "training",
46823
+ capScope: "system",
46824
+ addonId: null,
46825
+ access: "view"
46826
+ },
46827
+ "training.putDatasetVersion": {
46828
+ capName: "training",
46829
+ capScope: "system",
46830
+ addonId: null,
46831
+ access: "create"
46832
+ },
46833
+ "training.registerResult": {
46834
+ capName: "training",
46835
+ capScope: "system",
46836
+ addonId: null,
46837
+ access: "create"
46838
+ },
46839
+ "training.removeDatasetVersion": {
46840
+ capName: "training",
46841
+ capScope: "system",
46842
+ addonId: null,
46843
+ access: "delete"
46844
+ },
46845
+ "training.rollbackCanary": {
46846
+ capName: "training",
46847
+ capScope: "system",
46848
+ addonId: null,
46849
+ access: "create"
46850
+ },
46851
+ "training.startJob": {
46852
+ capName: "training",
46853
+ capScope: "system",
46854
+ addonId: null,
46855
+ access: "create"
46856
+ },
46857
+ "trainingProvider.cancelJob": {
46858
+ capName: "training-provider",
46859
+ capScope: "system",
46860
+ addonId: null,
46861
+ access: "create"
46862
+ },
46863
+ "trainingProvider.cleanupJob": {
46864
+ capName: "training-provider",
46865
+ capScope: "system",
46866
+ addonId: null,
46867
+ access: "create"
46868
+ },
46869
+ "trainingProvider.describe": {
46870
+ capName: "training-provider",
46871
+ capScope: "system",
46872
+ addonId: null,
46873
+ access: "view"
46874
+ },
46875
+ "trainingProvider.estimateJob": {
46876
+ capName: "training-provider",
46877
+ capScope: "system",
46878
+ addonId: null,
46879
+ access: "view"
46880
+ },
46881
+ "trainingProvider.getJob": {
46882
+ capName: "training-provider",
46883
+ capScope: "system",
46884
+ addonId: null,
46885
+ access: "view"
46886
+ },
46887
+ "trainingProvider.listJobEvents": {
46888
+ capName: "training-provider",
46889
+ capScope: "system",
46890
+ addonId: null,
46891
+ access: "view"
46892
+ },
46893
+ "trainingProvider.listJobs": {
46894
+ capName: "training-provider",
46895
+ capScope: "system",
46896
+ addonId: null,
46897
+ access: "view"
46898
+ },
46899
+ "trainingProvider.offerArtifact": {
46900
+ capName: "training-provider",
46901
+ capScope: "system",
46902
+ addonId: null,
46903
+ access: "create"
46904
+ },
46905
+ "trainingProvider.readResult": {
46906
+ capName: "training-provider",
46907
+ capScope: "system",
46908
+ addonId: null,
46909
+ access: "create"
46910
+ },
46911
+ "trainingProvider.submitJob": {
46912
+ capName: "training-provider",
46913
+ capScope: "system",
46914
+ addonId: null,
46915
+ access: "create"
46916
+ },
46917
+ "trainingProvider.uploadDataset": {
46918
+ capName: "training-provider",
46919
+ capScope: "system",
46920
+ addonId: null,
46921
+ access: "create"
46922
+ },
46923
+ "trainingProvider.validateCredentials": {
46924
+ capName: "training-provider",
46925
+ capScope: "system",
46926
+ addonId: null,
46927
+ access: "create"
46928
+ },
45276
46929
  "turnProvider.getTurnServers": {
45277
46930
  capName: "turn-provider",
45278
46931
  capScope: "system",
@@ -45297,12 +46950,6 @@ Object.freeze({
45297
46950
  addonId: null,
45298
46951
  access: "create"
45299
46952
  },
45300
- "userManagement.createApiKey": {
45301
- capName: "user-management",
45302
- capScope: "system",
45303
- addonId: null,
45304
- access: "create"
45305
- },
45306
46953
  "userManagement.createScopedToken": {
45307
46954
  capName: "user-management",
45308
46955
  capScope: "system",
@@ -45339,12 +46986,6 @@ Object.freeze({
45339
46986
  addonId: null,
45340
46987
  access: "view"
45341
46988
  },
45342
- "userManagement.linkExternalIdentity": {
45343
- capName: "user-management",
45344
- capScope: "system",
45345
- addonId: null,
45346
- access: "create"
45347
- },
45348
46989
  "userManagement.listApiKeys": {
45349
46990
  capName: "user-management",
45350
46991
  capScope: "system",
@@ -45447,12 +47088,6 @@ Object.freeze({
45447
47088
  addonId: null,
45448
47089
  access: "create"
45449
47090
  },
45450
- "userManagement.validateApiKey": {
45451
- capName: "user-management",
45452
- capScope: "system",
45453
- addonId: null,
45454
- access: "view"
45455
- },
45456
47091
  "userManagement.validateCredentials": {
45457
47092
  capName: "user-management",
45458
47093
  capScope: "system",
@@ -49566,6 +51201,11 @@ Object.freeze({
49566
51201
  form: "single",
49567
51202
  optional: false
49568
51203
  }],
51204
+ "training.canaryResult": [{
51205
+ name: "deviceIds",
51206
+ form: "array",
51207
+ optional: false
51208
+ }],
49569
51209
  "update.getStatus": [{
49570
51210
  name: "deviceId",
49571
51211
  form: "single",
@@ -62041,7 +63681,7 @@ var SmtpNodemailerAddon = class extends BaseAddon {
62041
63681
  return this.schema({ sections: [{
62042
63682
  id: "smtp-relay",
62043
63683
  title: "SMTP Relay",
62044
- description: "Outbound SMTP relay used by magic-link logins, notifications, and alerts. Tested with the per-cap `verify()` button — see the Integrations status badge for the last result.",
63684
+ description: "Outbound SMTP relay used by notifications and alerts. Tested with the per-cap `verify()` button — see the Integrations status badge for the last result.",
62045
63685
  columns: 2,
62046
63686
  fields: [
62047
63687
  {