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