@camstack/addon-provider-amcrest 0.2.133 → 0.2.134

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.
Files changed (3) hide show
  1. package/dist/addon.js +1771 -131
  2. package/dist/addon.mjs +1771 -131
  3. package/package.json +1 -1
package/dist/addon.js CHANGED
@@ -5412,7 +5412,7 @@ var ZodIssueCode = {
5412
5412
  var ZodFirstPartyTypeKind;
5413
5413
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
5414
5414
  //#endregion
5415
- //#region ../types/dist/sleep-Cr5YOk3m.mjs
5415
+ //#region ../types/dist/sleep-r3RWkGVx.mjs
5416
5416
  /**
5417
5417
  * The audio chunk plane's byte format, and the ONE expansion from a coded
5418
5418
  * window to float samples (D455).
@@ -5529,7 +5529,7 @@ function isKeychainStoredField(field) {
5529
5529
  var SECRET_CLEAR = { $secretClear: true };
5530
5530
  /** The `'***'` token D634 redaction writes for non-admins. */
5531
5531
  var LEGACY_DEVICE_REDACTION = "***";
5532
- function isRecord$1$1(value) {
5532
+ function isRecord$2(value) {
5533
5533
  return typeof value === "object" && value !== null && !Array.isArray(value);
5534
5534
  }
5535
5535
  function makeSecretMarker(ref) {
@@ -5540,12 +5540,12 @@ function makeSecretMarker(ref) {
5540
5540
  }
5541
5541
  /** A stored marker: an object whose `$secret` is a non-empty string. */
5542
5542
  function isSecretMarker(value) {
5543
- if (!isRecord$1$1(value)) return false;
5543
+ if (!isRecord$2(value)) return false;
5544
5544
  const ref = value["$secret"];
5545
5545
  return typeof ref === "string" && ref.length > 0;
5546
5546
  }
5547
5547
  function isSecretClear(value) {
5548
- return isRecord$1$1(value) && value["$secretClear"] === true;
5548
+ return isRecord$2(value) && value["$secretClear"] === true;
5549
5549
  }
5550
5550
  /**
5551
5551
  * The UI view of a stored secret field value: a marker becomes "set", inline
@@ -6061,6 +6061,13 @@ function globalSecretScope() {
6061
6061
  function encodeSegment(value) {
6062
6062
  return encodeURIComponent(value);
6063
6063
  }
6064
+ function decodeSegment(value) {
6065
+ try {
6066
+ return decodeURIComponent(value);
6067
+ } catch {
6068
+ return null;
6069
+ }
6070
+ }
6064
6071
  /**
6065
6072
  * The field path of a value inside an array item, addressed by the item's id:
6066
6073
  * `arrayItemFieldPath('providers', 'authentik', 'clientSecret')` →
@@ -6069,6 +6076,75 @@ function encodeSegment(value) {
6069
6076
  function arrayItemFieldPath(arrayKey, itemId, fieldKey) {
6070
6077
  return `${arrayKey}[${encodeSegment(itemId)}].${fieldKey}`;
6071
6078
  }
6079
+ function parseScope(segments) {
6080
+ switch (segments[0]) {
6081
+ case "global": return {
6082
+ scope: GLOBAL_SCOPE,
6083
+ used: 1
6084
+ };
6085
+ case "node": {
6086
+ const nodeId = segments[1] !== void 0 ? decodeSegment(segments[1]) : null;
6087
+ return nodeId === null || nodeId.length === 0 ? null : {
6088
+ scope: {
6089
+ kind: "node",
6090
+ nodeId
6091
+ },
6092
+ used: 2
6093
+ };
6094
+ }
6095
+ case "device": {
6096
+ const raw = segments[1];
6097
+ if (raw === void 0 || !/^\d+$/.test(raw)) return null;
6098
+ return {
6099
+ scope: {
6100
+ kind: "device",
6101
+ deviceId: Number(raw)
6102
+ },
6103
+ used: 2
6104
+ };
6105
+ }
6106
+ case "integration": {
6107
+ const id = segments[1] !== void 0 ? decodeSegment(segments[1]) : null;
6108
+ return id === null || id.length === 0 ? null : {
6109
+ scope: {
6110
+ kind: "integration",
6111
+ integrationId: id
6112
+ },
6113
+ used: 2
6114
+ };
6115
+ }
6116
+ case "row": {
6117
+ const collection = segments[1] !== void 0 ? decodeSegment(segments[1]) : null;
6118
+ const rowId = segments[2] !== void 0 ? decodeSegment(segments[2]) : null;
6119
+ if (collection === null || rowId === null || collection.length === 0 || rowId.length === 0) return null;
6120
+ return {
6121
+ scope: {
6122
+ kind: "row",
6123
+ collection,
6124
+ rowId
6125
+ },
6126
+ used: 3
6127
+ };
6128
+ }
6129
+ default: return null;
6130
+ }
6131
+ }
6132
+ /** Take a ref apart; `null` when it is not a well-formed ref. */
6133
+ function parseSecretRef(ref) {
6134
+ if (!ref.startsWith("secret://")) return null;
6135
+ const segments = ref.slice(9).split("/");
6136
+ const owner = segments[0] !== void 0 ? decodeSegment(segments[0]) : null;
6137
+ if (owner === null || owner.length === 0) return null;
6138
+ const parsed = parseScope(segments.slice(1));
6139
+ if (parsed === null) return null;
6140
+ const fieldPath = segments.slice(1 + parsed.used).join("/");
6141
+ if (fieldPath.length === 0) return null;
6142
+ return {
6143
+ owner,
6144
+ scope: parsed.scope,
6145
+ fieldPath
6146
+ };
6147
+ }
6072
6148
  /** A write to a secret path could not be stored in the keychain, so it was refused. */
6073
6149
  var KeychainWriteRefusedError = class extends Error {
6074
6150
  fieldPath;
@@ -6079,7 +6155,7 @@ var KeychainWriteRefusedError = class extends Error {
6079
6155
  }
6080
6156
  };
6081
6157
  var KEEP = { kind: "keep" };
6082
- function isRecord$2(value) {
6158
+ function isRecord$1$1(value) {
6083
6159
  return typeof value === "object" && value !== null && !Array.isArray(value);
6084
6160
  }
6085
6161
  function defaultMintId() {
@@ -6092,7 +6168,7 @@ function collectSecretMarkerRefs(value, out = []) {
6092
6168
  return out;
6093
6169
  }
6094
6170
  if (Array.isArray(value)) for (const item of value) collectSecretMarkerRefs(item, out);
6095
- else if (isRecord$2(value)) for (const child of Object.values(value)) collectSecretMarkerRefs(child, out);
6171
+ else if (isRecord$1$1(value)) for (const child of Object.values(value)) collectSecretMarkerRefs(child, out);
6096
6172
  return out;
6097
6173
  }
6098
6174
  async function storedValueEquals(secrets, marker, candidate) {
@@ -6147,7 +6223,7 @@ function rowId(row, idKey) {
6147
6223
  return null;
6148
6224
  }
6149
6225
  async function writeArray(ctx, node, incoming, stored, fieldPath) {
6150
- const storedRows = Array.isArray(stored) ? stored.filter(isRecord$2) : [];
6226
+ const storedRows = Array.isArray(stored) ? stored.filter(isRecord$1$1) : [];
6151
6227
  if (!Array.isArray(incoming)) {
6152
6228
  ctx.deletes.push(...collectSecretMarkerRefs(storedRows));
6153
6229
  return {
@@ -6163,7 +6239,7 @@ async function writeArray(ctx, node, incoming, stored, fieldPath) {
6163
6239
  const kept = /* @__PURE__ */ new Set();
6164
6240
  const rows = [];
6165
6241
  for (const row of incoming) {
6166
- if (!isRecord$2(row)) {
6242
+ if (!isRecord$1$1(row)) {
6167
6243
  rows.push(row);
6168
6244
  continue;
6169
6245
  }
@@ -6188,7 +6264,7 @@ async function writeNode(ctx, node, incoming, stored, fieldPath) {
6188
6264
  case "leaf": return writeLeaf(ctx, incoming, stored, fieldPath);
6189
6265
  case "array": return writeArray(ctx, node, incoming, stored, fieldPath);
6190
6266
  case "object": {
6191
- if (!isRecord$2(incoming)) {
6267
+ if (!isRecord$1$1(incoming)) {
6192
6268
  if (incoming === void 0) return KEEP;
6193
6269
  ctx.deletes.push(...collectSecretMarkerRefs(stored));
6194
6270
  return {
@@ -6196,7 +6272,7 @@ async function writeNode(ctx, node, incoming, stored, fieldPath) {
6196
6272
  value: incoming
6197
6273
  };
6198
6274
  }
6199
- const storedObj = isRecord$2(stored) ? stored : {};
6275
+ const storedObj = isRecord$1$1(stored) ? stored : {};
6200
6276
  return {
6201
6277
  kind: "value",
6202
6278
  value: await writeMembers(ctx, node.children, incoming, storedObj, (m) => `${fieldPath}.${m}`)
@@ -6255,12 +6331,19 @@ async function transformSecretWrite(input) {
6255
6331
  }
6256
6332
  };
6257
6333
  }
6334
+ /** Is `ref` one of `owner`'s refs? */
6335
+ function isSecretRefOwnedBy(ref, owner) {
6336
+ return parseSecretRef(ref)?.owner === owner;
6337
+ }
6258
6338
  /**
6259
6339
  * Replace every marker in `value` with its keychain value. Returns the SAME
6260
6340
  * reference when there is no marker (no allocation, no keychain call).
6261
6341
  */
6262
- async function resolveSecretMarkers(value, secrets) {
6263
- const refs = collectSecretMarkerRefs(value);
6342
+ async function resolveSecretMarkers(value, secrets, options = {}) {
6343
+ const keepMarker = options.unresolved === "keep-marker";
6344
+ const owner = options.ownedBy;
6345
+ const inScope = (ref) => owner === void 0 || isSecretRefOwnedBy(ref, owner);
6346
+ const refs = collectSecretMarkerRefs(value).filter(inScope);
6264
6347
  if (refs.length === 0) return {
6265
6348
  value,
6266
6349
  unresolved: []
@@ -6284,10 +6367,18 @@ async function resolveSecretMarkers(value, secrets) {
6284
6367
  }
6285
6368
  const substitute = (v) => {
6286
6369
  if (isSecretMarker(v)) {
6370
+ if (!inScope(v.$secret)) return {
6371
+ keep: true,
6372
+ value: v
6373
+ };
6287
6374
  const answer = answers[v.$secret];
6288
- return answer?.kind === "value" ? {
6375
+ if (answer?.kind === "value") return {
6289
6376
  keep: true,
6290
6377
  value: answer.value
6378
+ };
6379
+ return keepMarker ? {
6380
+ keep: true,
6381
+ value: v
6291
6382
  } : {
6292
6383
  keep: false,
6293
6384
  value: void 0
@@ -6304,7 +6395,7 @@ async function resolveSecretMarkers(value, secrets) {
6304
6395
  value: items
6305
6396
  };
6306
6397
  }
6307
- if (isRecord$2(v)) {
6398
+ if (isRecord$1$1(v)) {
6308
6399
  const out = {};
6309
6400
  for (const [k, child] of Object.entries(v)) {
6310
6401
  const s = substitute(child);
@@ -6325,14 +6416,152 @@ async function resolveSecretMarkers(value, secrets) {
6325
6416
  unresolved
6326
6417
  };
6327
6418
  }
6328
- function touchesTree(tree, patch) {
6329
- if (tree.size === 0) return false;
6330
- for (const key of Object.keys(patch)) {
6331
- const at = key.indexOf("@");
6332
- if (tree.has(at > 0 ? key.slice(0, at) : key)) return true;
6419
+ /** An addon tried to replace a stored secret it could not read. Nothing was written. */
6420
+ var SecretOverwriteRefusedError = class extends Error {
6421
+ ref;
6422
+ reason;
6423
+ constructor(ref, reason) {
6424
+ super(`secret ${ref} was not replaced: its stored value cannot be read right now (${reason}), and an addon may not overwrite a secret it cannot see. Nothing was written.`);
6425
+ this.ref = ref;
6426
+ this.reason = reason;
6427
+ this.name = "SecretOverwriteRefusedError";
6428
+ }
6429
+ };
6430
+ function isRecord$3(value) {
6431
+ return typeof value === "object" && value !== null && !Array.isArray(value);
6432
+ }
6433
+ function resolvedValue(pass, marker) {
6434
+ const answer = pass.answers[marker.$secret];
6435
+ return answer?.kind === "value" ? answer.value : null;
6436
+ }
6437
+ async function atMarker(pass, incoming, stored) {
6438
+ if (incoming === null) return stored;
6439
+ if (typeof incoming !== "string") return incoming;
6440
+ if (incoming === resolvedValue(pass, stored)) return stored;
6441
+ const intent = classifySecretWrite(incoming);
6442
+ if (intent.kind !== "set") return stored;
6443
+ const ref = stored.$secret;
6444
+ if (!isSecretRefOwnedBy(ref, pass.secrets.owner)) return incoming;
6445
+ const answer = pass.answers[ref];
6446
+ if ((answer === void 0 || answer.kind === "unavailable" || answer.kind === "forbidden") && !pass.operatorWrite) throw new SecretOverwriteRefusedError(ref, answer === void 0 ? "not-initialized" : answer.kind === "unavailable" ? answer.reason : answer.kind);
6447
+ try {
6448
+ await pass.secrets.put(ref, intent.value);
6449
+ } catch (err) {
6450
+ throw new KeychainWriteRefusedError(ref, err);
6451
+ }
6452
+ pass.changedRefs.push(ref);
6453
+ return stored;
6454
+ }
6455
+ function inArray(pass, incoming, stored) {
6456
+ return incoming.map((item, index) => {
6457
+ const twin = stored[index];
6458
+ if (isSecretMarker(twin)) return typeof item === "string" && item === resolvedValue(pass, twin) ? twin : item;
6459
+ if (isRecord$3(item) && isRecord$3(twin)) return inArrayRow(pass, item, twin);
6460
+ if (Array.isArray(item) && Array.isArray(twin)) return inArray(pass, item, twin);
6461
+ return item;
6462
+ });
6463
+ }
6464
+ function inArrayRow(pass, incoming, stored) {
6465
+ const out = { ...incoming };
6466
+ for (const [key, value] of Object.entries(incoming)) {
6467
+ const twin = stored[key];
6468
+ if (isSecretMarker(twin)) {
6469
+ if (typeof value === "string" && value === resolvedValue(pass, twin)) out[key] = twin;
6470
+ } else if (isRecord$3(value) && isRecord$3(twin)) out[key] = inArrayRow(pass, value, twin);
6471
+ else if (Array.isArray(value) && Array.isArray(twin)) out[key] = inArray(pass, value, twin);
6472
+ }
6473
+ return out;
6474
+ }
6475
+ async function walk(pass, incoming, stored) {
6476
+ if (isSecretMarker(stored)) return atMarker(pass, incoming, stored);
6477
+ if (Array.isArray(incoming) && Array.isArray(stored)) return inArray(pass, incoming, stored);
6478
+ if (!isRecord$3(incoming) || !isRecord$3(stored)) return incoming;
6479
+ const out = { ...incoming };
6480
+ for (const [key, value] of Object.entries(incoming)) out[key] = await walk(pass, value, stored[key]);
6481
+ return out;
6482
+ }
6483
+ /** Restore markers a write-back carries as values. See the file doc. */
6484
+ async function restoreUnchangedSecrets(input) {
6485
+ const refs = [];
6486
+ for (const key of Object.keys(input.patch)) collectSecretMarkerRefs(input.stored[key], refs);
6487
+ const owned = refs.filter((ref) => isSecretRefOwnedBy(ref, input.secrets.owner));
6488
+ if (owned.length === 0) return {
6489
+ patch: input.patch,
6490
+ changedRefs: []
6491
+ };
6492
+ const pass = {
6493
+ secrets: input.secrets,
6494
+ answers: await input.secrets.resolve([...new Set(owned)]),
6495
+ operatorWrite: input.operatorWrite,
6496
+ changedRefs: []
6497
+ };
6498
+ const out = {};
6499
+ for (const [key, value] of Object.entries(input.patch)) out[key] = await walk(pass, value, input.stored[key]);
6500
+ return {
6501
+ patch: out,
6502
+ changedRefs: pass.changedRefs
6503
+ };
6504
+ }
6505
+ /** Structural equality over JSON-shaped values (key order does not matter). */
6506
+ function isJsonEqual(a, b) {
6507
+ if (Object.is(a, b)) return true;
6508
+ if (Array.isArray(a)) return Array.isArray(b) && a.length === b.length && a.every((v, i) => isJsonEqual(v, b[i]));
6509
+ if (isRecord$3(a) && isRecord$3(b)) {
6510
+ const keys = Object.keys(a);
6511
+ if (keys.length !== Object.keys(b).length) return false;
6512
+ return keys.every((k) => Object.prototype.hasOwnProperty.call(b, k) && isJsonEqual(a[k], b[k]));
6333
6513
  }
6334
6514
  return false;
6335
6515
  }
6516
+ /** The patch without the keys whose value already equals the stored one. */
6517
+ function dropUnchangedKeys(patch, stored) {
6518
+ const out = {};
6519
+ for (const [key, value] of Object.entries(patch)) {
6520
+ if (Object.prototype.hasOwnProperty.call(stored, key) && isJsonEqual(value, stored[key])) continue;
6521
+ out[key] = value;
6522
+ }
6523
+ return out;
6524
+ }
6525
+ /** The top-level keys of a blob that hold at least one of `owner`'s markers. */
6526
+ function markerKeysOf(blob, owner) {
6527
+ const keys = /* @__PURE__ */ new Set();
6528
+ for (const [key, value] of Object.entries(blob)) if (collectSecretMarkerRefs(value).some((ref) => isSecretRefOwnedBy(ref, owner))) keys.add(key);
6529
+ return keys;
6530
+ }
6531
+ function nodeFromStored(value, owner) {
6532
+ if (isSecretMarker(value)) return isSecretRefOwnedBy(value.$secret, owner) ? { kind: "leaf" } : null;
6533
+ if (!isRecord$3(value)) return null;
6534
+ const children = /* @__PURE__ */ new Map();
6535
+ for (const [key, child] of Object.entries(value)) {
6536
+ const node = nodeFromStored(child, owner);
6537
+ if (node !== null) children.set(key, node);
6538
+ }
6539
+ return children.size > 0 ? {
6540
+ kind: "object",
6541
+ children
6542
+ } : null;
6543
+ }
6544
+ /**
6545
+ * The declared secret tree, widened by every place the STORED blob holds a
6546
+ * marker under one of `keys` — so a marker the schema no longer declares (or
6547
+ * never declared: Wyze before b4906cec6) still gets the save path's
6548
+ * KEEP / SET / CLEAR semantics instead of being overwritten by whatever the
6549
+ * addon writes. Markers inside arrays are not added: a row has no id field to
6550
+ * match by unless the schema declares one. Only `owner`'s markers count: a
6551
+ * builtin that keeps another addon's marker (device-manager) never takes it
6552
+ * over.
6553
+ */
6554
+ function widenTreeWithStoredMarkers(declared, stored, keys, owner) {
6555
+ const added = /* @__PURE__ */ new Map();
6556
+ for (const key of keys) {
6557
+ const at = key.indexOf("@");
6558
+ const base = at > 0 ? key.slice(0, at) : key;
6559
+ if (declared.has(base) || added.has(base)) continue;
6560
+ const node = nodeFromStored(stored[key], owner);
6561
+ if (node !== null) added.set(base, node);
6562
+ }
6563
+ return added.size === 0 ? declared : new Map([...declared, ...added]);
6564
+ }
6336
6565
  /** The blob as stored now; a failed read REFUSES the write instead of guessing. */
6337
6566
  async function readStoredAddonBlob(raw) {
6338
6567
  const threeWay = raw.readAddonStoreResult;
@@ -6341,7 +6570,41 @@ async function readStoredAddonBlob(raw) {
6341
6570
  if (result.kind === "failed") throw new Error(`settings write refused: the stored blob could not be read (${result.error})`);
6342
6571
  return result.kind === "missing" ? {} : result.value;
6343
6572
  }
6344
- function createSecretAwareSettings(raw, opts) {
6573
+ function touchesTree(tree, patch) {
6574
+ if (tree.size === 0) return false;
6575
+ for (const key of Object.keys(patch)) {
6576
+ const at = key.indexOf("@");
6577
+ if (tree.has(at > 0 ? key.slice(0, at) : key)) return true;
6578
+ }
6579
+ return false;
6580
+ }
6581
+ /**
6582
+ * Which top-level keys of each store held markers when last seen. `undefined`
6583
+ * for a store not seen yet: its first write reads it, to be safe.
6584
+ */
6585
+ var MarkerKeyIndex = class {
6586
+ owner;
6587
+ byStore = /* @__PURE__ */ new Map();
6588
+ constructor(owner) {
6589
+ this.owner = owner;
6590
+ }
6591
+ seen(store, blob) {
6592
+ this.byStore.set(store, markerKeysOf(blob, this.owner));
6593
+ }
6594
+ wrote(store, patch) {
6595
+ const keys = this.byStore.get(store);
6596
+ if (keys === void 0) return;
6597
+ const now = markerKeysOf(patch, this.owner);
6598
+ for (const key of Object.keys(patch)) if (now.has(key)) keys.add(key);
6599
+ else keys.delete(key);
6600
+ }
6601
+ mayHoldMarkers(store, patch) {
6602
+ const keys = this.byStore.get(store);
6603
+ if (keys === void 0) return true;
6604
+ return Object.keys(patch).some((key) => keys.has(key));
6605
+ }
6606
+ };
6607
+ function createHandle(raw, opts) {
6345
6608
  const chains = /* @__PURE__ */ new Map();
6346
6609
  const serialize = (key, fn) => {
6347
6610
  const next = (chains.get(key) ?? Promise.resolve()).then(fn, fn);
@@ -6352,46 +6615,130 @@ function createSecretAwareSettings(raw, opts) {
6352
6615
  });
6353
6616
  return next;
6354
6617
  };
6355
- const write = async (chainKey, tree, scope, patch, readStored, rawWrite) => {
6356
- if (!touchesTree(tree, patch)) return rawWrite(patch);
6357
- return serialize(chainKey, async () => {
6618
+ const index = new MarkerKeyIndex(opts.secrets.owner);
6619
+ const resolveRead = async (store, blob) => {
6620
+ index.seen(store, blob);
6621
+ const { value, unresolved } = await resolveSecretMarkers(blob, opts.secrets, {
6622
+ unresolved: "keep-marker",
6623
+ ownedBy: opts.secrets.owner
6624
+ });
6625
+ if (unresolved.length > 0) opts.onUnresolved?.(unresolved);
6626
+ return value;
6627
+ };
6628
+ const write = async (store, declared, scope, patch, readStored, rawWrite) => {
6629
+ if (!touchesTree(declared, patch) && !index.mayHoldMarkers(store, patch)) {
6630
+ await rawWrite(patch);
6631
+ index.wrote(store, patch);
6632
+ return { changed: true };
6633
+ }
6634
+ return serialize(store, async () => {
6358
6635
  const stored = await readStored();
6636
+ index.seen(store, stored);
6637
+ const operatorWrite = opts.isOperatorWrite?.() === true;
6638
+ const restored = await restoreUnchangedSecrets({
6639
+ patch,
6640
+ stored,
6641
+ secrets: opts.secrets,
6642
+ operatorWrite
6643
+ });
6359
6644
  const result = await transformSecretWrite({
6360
- tree,
6645
+ tree: widenTreeWithStoredMarkers(declared, stored, Object.keys(restored.patch), opts.secrets.owner),
6361
6646
  secrets: opts.secrets,
6362
- patch,
6647
+ patch: restored.patch,
6363
6648
  stored,
6364
6649
  ...scope !== void 0 ? { scope } : {},
6365
- operatorWrite: opts.isOperatorWrite?.() === true
6650
+ operatorWrite
6366
6651
  });
6367
- if (Object.keys(result.patch).length > 0) await rawWrite(result.patch);
6652
+ const effective = dropUnchangedKeys(result.patch, stored);
6653
+ const wroteBlob = Object.keys(effective).length > 0;
6654
+ if (wroteBlob) {
6655
+ await rawWrite(effective);
6656
+ index.wrote(store, effective);
6657
+ }
6368
6658
  const { orphaned } = await result.afterWrite();
6369
6659
  if (orphaned.length > 0) opts.onOrphaned(orphaned);
6660
+ return { changed: wroteBlob || restored.changedRefs.length > 0 };
6370
6661
  });
6371
6662
  };
6372
- const wrapped = {
6373
- writeAddonStore: (patch) => write("addon", opts.addonTree(), void 0, patch, () => readStoredAddonBlob(raw), (p) => raw.writeAddonStore(p)),
6374
- writeDeviceStore: (deviceId, patch) => write(`device:${deviceId}`, opts.deviceTree(), {
6375
- kind: "device",
6376
- deviceId
6377
- }, patch, () => raw.readDeviceStore(deviceId), (p) => raw.writeDeviceStore(deviceId, p))
6663
+ const writeAddon = (patch) => write("addon", opts.addonTree(), void 0, patch, () => readStoredAddonBlob(raw), (p) => raw.writeAddonStore(p));
6664
+ const readAddonStoreResult = raw.readAddonStoreResult;
6665
+ const readAddonStoreKeyResult = raw.readAddonStoreKeyResult;
6666
+ const readDeviceStoreBatch = raw.readDeviceStoreBatch;
6667
+ const overrides = {
6668
+ readAddonStore: async () => resolveRead("addon", await raw.readAddonStore()),
6669
+ ...readAddonStoreResult !== void 0 ? { readAddonStoreResult: async () => {
6670
+ const result = await readAddonStoreResult.call(raw);
6671
+ return result.kind === "value" ? {
6672
+ kind: "value",
6673
+ value: await resolveRead("addon", result.value)
6674
+ } : result;
6675
+ } } : {},
6676
+ ...readAddonStoreKeyResult !== void 0 ? { readAddonStoreKeyResult: async (key) => {
6677
+ const result = await readAddonStoreKeyResult.call(raw, key);
6678
+ if (result.kind !== "present") return result;
6679
+ const { value, unresolved } = await resolveSecretMarkers({ [key]: result.value }, opts.secrets, {
6680
+ unresolved: "keep-marker",
6681
+ ownedBy: opts.secrets.owner
6682
+ });
6683
+ if (unresolved.length > 0) opts.onUnresolved?.(unresolved);
6684
+ return {
6685
+ kind: "present",
6686
+ value: value[key]
6687
+ };
6688
+ } } : {},
6689
+ readDeviceStore: async (deviceId) => resolveRead(`device:${deviceId}`, await raw.readDeviceStore(deviceId)),
6690
+ ...readDeviceStoreBatch !== void 0 ? { readDeviceStoreBatch: async (deviceIds) => {
6691
+ const rows = await readDeviceStoreBatch.call(raw, deviceIds);
6692
+ const out = /* @__PURE__ */ new Map();
6693
+ for (const [deviceId, blob] of rows) out.set(deviceId, await resolveRead(`device:${deviceId}`, blob));
6694
+ return out;
6695
+ } } : {},
6696
+ writeAddonStore: async (patch) => {
6697
+ await writeAddon(patch);
6698
+ },
6699
+ writeDeviceStore: async (deviceId, patch) => {
6700
+ await write(`device:${deviceId}`, opts.deviceTree(), {
6701
+ kind: "device",
6702
+ deviceId
6703
+ }, patch, () => raw.readDeviceStore(deviceId), (p) => raw.writeDeviceStore(deviceId, p));
6704
+ }
6705
+ };
6706
+ return {
6707
+ settings: new Proxy(raw, { get(target, prop, receiver) {
6708
+ if (typeof prop === "string" && Object.prototype.hasOwnProperty.call(overrides, prop)) return Reflect.get(overrides, prop);
6709
+ const value = Reflect.get(target, prop, receiver);
6710
+ return typeof value === "function" ? value.bind(target) : value;
6711
+ } }),
6712
+ raw: {
6713
+ readAddonStore: async () => {
6714
+ const blob = await raw.readAddonStore();
6715
+ index.seen("addon", blob);
6716
+ return blob;
6717
+ },
6718
+ readDeviceStore: async (deviceId) => {
6719
+ const blob = await raw.readDeviceStore(deviceId);
6720
+ index.seen(`device:${deviceId}`, blob);
6721
+ return blob;
6722
+ }
6723
+ },
6724
+ writeAddonStore: writeAddon
6378
6725
  };
6379
- return new Proxy(raw, { get(target, prop, receiver) {
6380
- if (prop === "writeAddonStore") return wrapped.writeAddonStore;
6381
- if (prop === "writeDeviceStore") return wrapped.writeDeviceStore;
6382
- const value = Reflect.get(target, prop, receiver);
6383
- return typeof value === "function" ? value.bind(target) : value;
6384
- } });
6385
6726
  }
6386
- /** The context the addon sees: identical, except that its settings writes are secret-aware. */
6387
- function withSecretAwareSettings(context, opts) {
6727
+ /** The context the addon sees, plus the private raw view and write outcome. */
6728
+ function createSecretAwareContext(context, opts) {
6388
6729
  const raw = context.settings;
6389
- if (raw === void 0) return context;
6390
- const settings = createSecretAwareSettings(raw, opts);
6391
- return new Proxy(context, { get(target, prop, receiver) {
6392
- if (prop === "settings") return settings;
6393
- return Reflect.get(target, prop, receiver);
6394
- } });
6730
+ if (raw === void 0) return {
6731
+ context,
6732
+ handle: null
6733
+ };
6734
+ const handle = createHandle(raw, opts);
6735
+ return {
6736
+ context: new Proxy(context, { get(target, prop, receiver) {
6737
+ if (prop === "settings") return handle.settings;
6738
+ return Reflect.get(target, prop, receiver);
6739
+ } }),
6740
+ handle
6741
+ };
6395
6742
  }
6396
6743
  var LEAF = { kind: "leaf" };
6397
6744
  var DEFAULT_ITEM_ID_KEY = "id";
@@ -6566,6 +6913,14 @@ var BaseAddon = class {
6566
6913
  _secretChangeUnsub = null;
6567
6914
  /** >0 while an OPERATOR's settings write is being applied. */
6568
6915
  _operatorWriteDepth = 0;
6916
+ /**
6917
+ * The keychain-aware settings handle (D798). Its `raw` view is the ONLY way
6918
+ * to the marker-bearing blobs and stays private to this class: the form
6919
+ * hydrate and config resolution need markers, addon code never does.
6920
+ */
6921
+ _secretSettings = null;
6922
+ /** Refs an addon-facing read could not resolve — each is logged once per process. */
6923
+ _loggedUnresolvedReads = /* @__PURE__ */ new Set();
6569
6924
  constructor(defaults) {
6570
6925
  this.defaults = defaults;
6571
6926
  this._config = { ...defaults };
@@ -6602,13 +6957,21 @@ var BaseAddon = class {
6602
6957
  }
6603
6958
  async initialize(context) {
6604
6959
  const secrets = context.secrets;
6605
- this._ctx = secrets !== void 0 ? withSecretAwareSettings(context, {
6606
- secrets,
6607
- addonTree: () => this.addonSecretTree(),
6608
- deviceTree: () => this.deviceSecretTree(),
6609
- onOrphaned: (refs) => context.logger.warn("keychain refs dropped by a settings write could not be deleted", { meta: { refs: [...refs] } }),
6610
- isOperatorWrite: () => this._operatorWriteDepth > 0
6611
- }) : context;
6960
+ if (secrets !== void 0) {
6961
+ const { context: wrapped, handle } = createSecretAwareContext(context, {
6962
+ secrets,
6963
+ addonTree: () => this.addonSecretTree(),
6964
+ deviceTree: () => this.deviceSecretTree(),
6965
+ onOrphaned: (refs) => context.logger.warn("keychain refs dropped by a settings write could not be deleted", { meta: { refs: [...refs] } }),
6966
+ isOperatorWrite: () => this._operatorWriteDepth > 0,
6967
+ onUnresolved: (unresolved) => this.logUnresolvedRead(unresolved)
6968
+ });
6969
+ this._ctx = wrapped;
6970
+ this._secretSettings = handle;
6971
+ } else {
6972
+ this._ctx = context;
6973
+ this._secretSettings = null;
6974
+ }
6612
6975
  await this.resolveConfig();
6613
6976
  if (secrets !== void 0) this._secretChangeUnsub = secrets.onChange((ref) => {
6614
6977
  if (this._configSecretRefs.has(ref)) this.scheduleSecretReresolve(SECRET_CHANGE_DEBOUNCE_MS);
@@ -6725,11 +7088,8 @@ var BaseAddon = class {
6725
7088
  async getGlobalSettings(overlay, cap, nodeId) {
6726
7089
  const schema = this.globalSettingsSchema(cap);
6727
7090
  if (!schema) return { sections: [] };
6728
- const projected = await this.resolveGlobalStore(nodeId, cap);
6729
- return hydrateSchema(schema, overlay ? {
6730
- ...projected,
6731
- ...overlay
6732
- } : projected, { inlineSecretsAsViews: true });
7091
+ const projected = await this.readRawProjectedStore(nodeId, cap);
7092
+ return hydrateSchema(schema, overlay ? await this.overlayKeepingMarkers(projected, overlay) : projected, { inlineSecretsAsViews: true });
6733
7093
  }
6734
7094
  /**
6735
7095
  * The integration-level view of this addon's settings: exactly the sections
@@ -6774,7 +7134,7 @@ var BaseAddon = class {
6774
7134
  });
6775
7135
  }
6776
7136
  if (sections.length === 0) return null;
6777
- const projected = await this.resolveGlobalStore(nodeId);
7137
+ const projected = await this.readRawProjectedStore(nodeId);
6778
7138
  return hydrateSchema({
6779
7139
  ...schema,
6780
7140
  sections
@@ -6791,12 +7151,50 @@ var BaseAddon = class {
6791
7151
  * the store for custom option logic (option narrowing, value snapping) to
6792
7152
  * read it per-node — never `ctx.settings.readAddonStore()` directly.
6793
7153
  * `nodeId` omitted ⇒ the local node (node-blind injection from ctx).
7154
+ *
7155
+ * Keychain values come back RESOLVED (D798): a secret reads as its value,
7156
+ * never as a `{ $secret }` marker. One the keychain cannot serve right now
7157
+ * stays a marker — "stored, unavailable" (`isSecretMarker()` is true, and it
7158
+ * is listed in {@link unresolvedSecrets}) — never `''` and never absent, so
7159
+ * it cannot be mistaken for "nothing stored, mint a new one". Writing the
7160
+ * resolved blob back is a no-op for every unchanged secret.
6794
7161
  */
6795
7162
  async resolveGlobalStore(nodeId, cap) {
6796
7163
  const raw = await this._ctx?.settings?.readAddonStore() ?? {};
7164
+ return this.projectForNode(raw, nodeId, cap);
7165
+ }
7166
+ projectForNode(store, nodeId, cap) {
6797
7167
  const keys = this.perNodeKeys(cap);
6798
7168
  const node = normalizeNodeId(nodeId ?? this._ctx?.kernel?.localNodeId);
6799
- return keys.size > 0 ? projectStore(raw, keys, node) : raw;
7169
+ return keys.size > 0 ? projectStore(store, keys, node) : store;
7170
+ }
7171
+ /** The PROJECTED store with its markers — the form hydrate only (D798). */
7172
+ async readRawProjectedStore(nodeId, cap) {
7173
+ const raw = await this.rawSettings()?.readAddonStore() ?? {};
7174
+ return this.projectForNode(raw, nodeId, cap);
7175
+ }
7176
+ /**
7177
+ * `{ ...stored, ...overlay }`, except that an overlay member equal to the
7178
+ * RESOLVED stored one keeps the stored (marker-bearing) member — so a form
7179
+ * hydrated from a resolved overlay still shows a secret as "set", never as
7180
+ * its value.
7181
+ */
7182
+ async overlayKeepingMarkers(stored, overlay) {
7183
+ const secrets = this._ctx?.secrets;
7184
+ const merged = {
7185
+ ...stored,
7186
+ ...overlay
7187
+ };
7188
+ if (secrets === void 0 || collectSecretMarkerRefs(stored).length === 0) return merged;
7189
+ const { value: resolved } = await resolveSecretMarkers(stored, secrets, {
7190
+ unresolved: "keep-marker",
7191
+ ownedBy: secrets.owner
7192
+ });
7193
+ for (const key of Object.keys(overlay)) {
7194
+ if (collectSecretMarkerRefs(stored[key]).length === 0) continue;
7195
+ if (isJsonEqual(overlay[key], resolved[key])) merged[key] = stored[key];
7196
+ }
7197
+ return merged;
6800
7198
  }
6801
7199
  /**
6802
7200
  * Whether ONE global key of this addon's store was written, read three-way
@@ -6861,8 +7259,12 @@ var BaseAddon = class {
6861
7259
  async clearSecrets(keys, nodeId) {
6862
7260
  const tree = this.addonSecretTree();
6863
7261
  const keychain = this._ctx?.secrets !== void 0;
7262
+ const stored = keychain ? await this.readAddonStoreWithRetry() : {};
6864
7263
  const patch = {};
6865
- for (const key of keys) patch[key] = keychain && tree.has(key) ? SECRET_CLEAR : "";
7264
+ for (const key of keys) {
7265
+ const keychainStored = tree.has(key) || collectSecretMarkerRefs(stored[key]).length > 0;
7266
+ patch[key] = keychain && keychainStored ? SECRET_CLEAR : "";
7267
+ }
6866
7268
  await this.applyGlobalPatch(patch, nodeId);
6867
7269
  }
6868
7270
  async applyGlobalPatch(barePatch, nodeId) {
@@ -6870,7 +7272,11 @@ var BaseAddon = class {
6870
7272
  const localNode = normalizeNodeId(this._ctx?.kernel?.localNodeId);
6871
7273
  const target = normalizeNodeId(nodeId ?? this._ctx?.kernel?.localNodeId);
6872
7274
  const scoped = keys.size > 0 ? scopePatch(barePatch, keys, target) : barePatch;
6873
- await this._ctx?.settings?.writeAddonStore(scoped);
7275
+ const handle = this._secretSettings;
7276
+ if (handle !== null) {
7277
+ const { changed } = await handle.writeAddonStore(scoped);
7278
+ if (!changed) return;
7279
+ } else await this._ctx?.settings?.writeAddonStore(scoped);
6874
7280
  if (target !== localNode) return;
6875
7281
  await this.resolveConfig();
6876
7282
  await this.onConfigChanged();
@@ -6923,7 +7329,7 @@ var BaseAddon = class {
6923
7329
  async getDeviceSettings(deviceId) {
6924
7330
  const schema = this.deviceSettingsSchema();
6925
7331
  if (!schema) return { sections: [] };
6926
- return hydrateSchema(schema, await this._ctx?.settings?.readDeviceStore(deviceId) ?? {}, { inlineSecretsAsViews: true });
7332
+ return hydrateSchema(schema, await this.rawSettings()?.readDeviceStore(deviceId) ?? {}, { inlineSecretsAsViews: true });
6927
7333
  }
6928
7334
  async updateDeviceSettings(deviceId, patch) {
6929
7335
  await this._ctx?.settings?.writeDeviceStore(deviceId, patch);
@@ -7095,7 +7501,7 @@ var BaseAddon = class {
7095
7501
  key,
7096
7502
  schema,
7097
7503
  fallback,
7098
- read: async () => this.resolveStoredSecrets(await this._ctx?.settings?.readDeviceStore(deviceId) ?? {}, false),
7504
+ read: async () => this.resolveStoredSecrets(await this.rawSettings()?.readDeviceStore(deviceId) ?? {}, false),
7099
7505
  write: async (patch) => {
7100
7506
  await this._ctx?.settings?.writeDeviceStore(deviceId, patch);
7101
7507
  },
@@ -7157,6 +7563,23 @@ var BaseAddon = class {
7157
7563
  }
7158
7564
  return value;
7159
7565
  }
7566
+ /**
7567
+ * The marker-bearing settings reads (D798) — private on purpose. Without a
7568
+ * keychain the context's own view is already raw.
7569
+ */
7570
+ rawSettings() {
7571
+ return this._secretSettings?.raw ?? this._ctx?.settings;
7572
+ }
7573
+ /** An addon-facing read met markers it could not resolve: say so once per ref. */
7574
+ logUnresolvedRead(unresolved) {
7575
+ const fresh = unresolved.filter((u) => !this._loggedUnresolvedReads.has(u.ref));
7576
+ if (fresh.length === 0) return;
7577
+ for (const u of fresh) this._loggedUnresolvedReads.add(u.ref);
7578
+ this._ctx?.logger?.warn?.("settings read: a stored secret is unavailable — it reads as its marker, not as a value", { meta: { secrets: fresh.map((u) => ({
7579
+ ref: u.ref,
7580
+ reason: u.reason
7581
+ })) } });
7582
+ }
7160
7583
  /** Re-resolve the config (a keychain-only change, or a retry) and apply it. */
7161
7584
  scheduleSecretReresolve(delayMs) {
7162
7585
  const timerOf = delayMs === SECRET_CHANGE_DEBOUNCE_MS ? "_secretChangeTimer" : "_secretRetryTimer";
@@ -7183,7 +7606,7 @@ var BaseAddon = class {
7183
7606
  * `{}` (defaults) — the addon's first successful patch will rehydrate.
7184
7607
  */
7185
7608
  async readAddonStoreWithRetry() {
7186
- const settings = this._ctx?.settings;
7609
+ const settings = this.rawSettings();
7187
7610
  if (!settings) return {};
7188
7611
  const delaysMs = [
7189
7612
  150,
@@ -9496,6 +9919,278 @@ var CameraSwitchGroupSchema = object({
9496
9919
  fetchedAt: number()
9497
9920
  });
9498
9921
  /**
9922
+ * The trainer contract — what the hub hands the cloud trainer and what it
9923
+ * gets back (cloud training, D805+).
9924
+ *
9925
+ * The trainer (`hf/camstack-trainer`, published as the Hugging Face repo
9926
+ * `camstack/camstack-trainer`) is a separate AGPL program the hub never
9927
+ * imports: `job.json` goes in, files come out, and progress is `CAMSTACK_EVENT`
9928
+ * lines on stdout. These schemas are the hub's half of that boundary; the
9929
+ * trainer's pydantic models (and the JSON Schemas generated from them under
9930
+ * `hf/camstack-trainer/schemas/`) are the other half. A change here is a
9931
+ * change there, in the same piece of work.
9932
+ *
9933
+ * No `.default()` anywhere: defaults do not run on the addon cap path, so the
9934
+ * orchestrator fills every field of a job spec explicitly.
9935
+ */
9936
+ var TRAINING_JOB_SCHEMA = "camstack.training/v1";
9937
+ var TRAINING_RESULT_SCHEMA = "camstack.training-result/v1";
9938
+ /** What the trainer can export. Edge TPU is a later, separate image. */
9939
+ var TrainingExportSchema = _enum([
9940
+ "onnx",
9941
+ "openvino-fp16",
9942
+ "openvino-int8",
9943
+ "coreml-fp16"
9944
+ ]);
9945
+ var FloorsSchema = record(string(), number().min(0).max(1));
9946
+ object({
9947
+ schema: literal(TRAINING_JOB_SCHEMA),
9948
+ jobKey: string().uuid(),
9949
+ target: object({
9950
+ kind: literal("detector"),
9951
+ step: literal("object-detection")
9952
+ }),
9953
+ base: object({
9954
+ modelId: string().min(1),
9955
+ /** Ultralytics weights id, e.g. `yolov9m.pt`. */
9956
+ weights: string().min(1),
9957
+ imgsz: number().int().positive()
9958
+ }),
9959
+ baseline: object({
9960
+ modelId: string().min(1),
9961
+ /** The baseline ONNX the holdout comparison runs; public mirror URL. */
9962
+ onnxUrl: string().url(),
9963
+ imgsz: number().int().positive(),
9964
+ floors: FloorsSchema
9965
+ }),
9966
+ dataset: object({
9967
+ versionId: string().min(1),
9968
+ annotationHash: string(),
9969
+ /** sha256 of the uploaded archive; the trainer refuses a mismatch (exit 65). */
9970
+ sha256: string().regex(/^[0-9a-f]{64}$/)
9971
+ }),
9972
+ split: object({
9973
+ holdoutCameras: array(number().int()),
9974
+ /** When no camera is held out: the last N days of every camera. */
9975
+ holdoutLastDays: number().int().nonnegative(),
9976
+ valFraction: number().min(0).max(.5),
9977
+ seed: number().int()
9978
+ }),
9979
+ hyper: object({
9980
+ epochs: number().int().positive(),
9981
+ batch: number().int().positive(),
9982
+ lr0: number().positive(),
9983
+ /** Layers frozen from the start of the backbone; 0 = none. */
9984
+ freeze: number().int().nonnegative(),
9985
+ patience: number().int().nonnegative(),
9986
+ seed: number().int()
9987
+ }),
9988
+ replay: object({
9989
+ source: literal("coco2017"),
9990
+ count: number().int().nonnegative()
9991
+ }),
9992
+ exports: array(TrainingExportSchema).min(1),
9993
+ calibration: object({ maxFrames: number().int().positive() }),
9994
+ floors: object({
9995
+ minSupport: number().int().positive(),
9996
+ clamp: number().min(0).max(1)
9997
+ }),
9998
+ int8Gate: object({ maxMap50Drop: number().min(0).max(1) }),
9999
+ catalog: object({
10000
+ id: string().regex(/^[a-z0-9][a-z0-9-]{2,80}$/),
10001
+ name: string().min(1).max(160)
10002
+ })
10003
+ });
10004
+ /** One regular file of the bundle. An mlpackage contributes one row per member. */
10005
+ var TrainingResultFileSchema = object({
10006
+ path: string().min(1),
10007
+ bytes: number().int().nonnegative(),
10008
+ sha256: string().regex(/^[0-9a-f]{64}$/),
10009
+ format: _enum([
10010
+ "onnx",
10011
+ "openvino",
10012
+ "coreml",
10013
+ "pt"
10014
+ ]),
10015
+ variant: _enum(["base", "int8"])
10016
+ });
10017
+ var DraftFormatSchema = object({
10018
+ /** RELATIVE path inside the bundle; the hub rewrites it to `camstack-local://`. */
10019
+ url: string().min(1),
10020
+ sizeMB: number().nonnegative(),
10021
+ isDirectory: boolean().optional(),
10022
+ files: array(string()).optional(),
10023
+ runtimes: array(literal("python")).optional(),
10024
+ revision: string().min(1)
10025
+ });
10026
+ /** The trainer's half of a catalog entry; the hub completes it (labels, licence, group). */
10027
+ var TrainingCatalogDraftSchema = object({
10028
+ id: string().min(1),
10029
+ name: string().min(1),
10030
+ description: string(),
10031
+ labels: array(unknown()),
10032
+ inputSize: object({
10033
+ width: number().int().positive(),
10034
+ height: number().int().positive()
10035
+ }),
10036
+ preprocessMode: literal("letterbox"),
10037
+ defaultClassFloors: FloorsSchema,
10038
+ formats: object({
10039
+ onnx: DraftFormatSchema.optional(),
10040
+ openvino: DraftFormatSchema.optional(),
10041
+ coreml: DraftFormatSchema.optional()
10042
+ })
10043
+ });
10044
+ /** One class of one model's holdout report (the eval harness's summary). */
10045
+ var TrainingEvalClassSchema = object({
10046
+ positives: number().int(),
10047
+ floor: number().nullable(),
10048
+ tp: number().int(),
10049
+ fp: number().int(),
10050
+ fn: number().int(),
10051
+ precision: number().nullable(),
10052
+ recall: number().nullable(),
10053
+ ap50: number().nullable(),
10054
+ recallByCamera: record(string(), number().nullable()).optional(),
10055
+ recallByLight: record(string(), number().nullable()).optional(),
10056
+ fpByCamera: record(string(), number()).optional(),
10057
+ smallFound: number().int().optional(),
10058
+ smallTotal: number().int().optional()
10059
+ }).passthrough();
10060
+ var TrainingEvalReportSchema = object({
10061
+ frames: number().int(),
10062
+ classes: record(string(), TrainingEvalClassSchema)
10063
+ }).passthrough();
10064
+ /**
10065
+ * A succeeded result carries every block; a failed one carries the error and
10066
+ * whatever was known by then — the other blocks are ABSENT, not null. The
10067
+ * orchestrator checks the blocks it needs before it trusts a success.
10068
+ */
10069
+ var TrainingResultSchema = object({
10070
+ schema: literal(TRAINING_RESULT_SCHEMA),
10071
+ jobKey: string(),
10072
+ status: _enum(["succeeded", "failed"]),
10073
+ error: object({
10074
+ stage: string(),
10075
+ code: string(),
10076
+ message: string()
10077
+ }).nullable(),
10078
+ trainer: object({
10079
+ version: string(),
10080
+ revision: string()
10081
+ }),
10082
+ toolchain: record(string(), string().nullable()),
10083
+ dataset: object({
10084
+ versionId: string(),
10085
+ annotationHash: string(),
10086
+ sha256: string(),
10087
+ frames: object({
10088
+ train: number().int(),
10089
+ val: number().int(),
10090
+ holdout: number().int()
10091
+ }),
10092
+ holdoutCameras: array(number().int()),
10093
+ replayImages: number().int()
10094
+ }).optional(),
10095
+ training: object({
10096
+ epochsRun: number().int(),
10097
+ bestEpoch: number().int(),
10098
+ bestMap50: number(),
10099
+ bestMap50_95: number(),
10100
+ seconds: number()
10101
+ }).optional(),
10102
+ evaluation: object({
10103
+ holdoutFrames: number().int(),
10104
+ baseline: TrainingEvalReportSchema.nullable(),
10105
+ candidate: TrainingEvalReportSchema.nullable(),
10106
+ candidateInt8: TrainingEvalReportSchema.nullable(),
10107
+ recallDeltaByCamera: record(string(), record(string(), number())).nullable(),
10108
+ map50: record(string(), number().nullable())
10109
+ }).optional(),
10110
+ floors: object({
10111
+ baseline: FloorsSchema,
10112
+ candidate: FloorsSchema,
10113
+ candidateInt8: FloorsSchema.nullable(),
10114
+ notes: array(string())
10115
+ }).optional(),
10116
+ int8: object({
10117
+ kept: boolean(),
10118
+ map50Fp16: number().nullable(),
10119
+ map50Int8: number().nullable(),
10120
+ reason: string().nullable()
10121
+ }).optional(),
10122
+ exportsDropped: array(object({
10123
+ export: string(),
10124
+ reason: string()
10125
+ })).optional(),
10126
+ files: array(TrainingResultFileSchema).optional(),
10127
+ bundle: object({
10128
+ path: literal("bundle.tar"),
10129
+ bytes: number().int().nonnegative(),
10130
+ sha256: string().regex(/^[0-9a-f]{64}$/)
10131
+ }).nullable().optional(),
10132
+ catalogDraft: object({
10133
+ base: TrainingCatalogDraftSchema,
10134
+ int8: TrainingCatalogDraftSchema.nullable()
10135
+ }).nullable().optional(),
10136
+ licence: string()
10137
+ });
10138
+ var TrainingStageSchema = _enum([
10139
+ "prepare",
10140
+ "replay",
10141
+ "train",
10142
+ "eval",
10143
+ "export",
10144
+ "package"
10145
+ ]);
10146
+ var EventBase = {
10147
+ v: literal(1),
10148
+ ts: number()
10149
+ };
10150
+ discriminatedUnion("type", [
10151
+ object({
10152
+ ...EventBase,
10153
+ type: literal("stage"),
10154
+ stage: TrainingStageSchema
10155
+ }),
10156
+ object({
10157
+ ...EventBase,
10158
+ type: literal("epoch"),
10159
+ epoch: number().int(),
10160
+ epochs: number().int(),
10161
+ boxLoss: number().nullable().optional(),
10162
+ map50: number().nullable().optional(),
10163
+ map50_95: number().nullable().optional(),
10164
+ etaSec: number().nullable().optional()
10165
+ }),
10166
+ object({
10167
+ ...EventBase,
10168
+ type: literal("metric"),
10169
+ name: string(),
10170
+ value: number()
10171
+ }),
10172
+ object({
10173
+ ...EventBase,
10174
+ type: literal("artifact"),
10175
+ path: string(),
10176
+ bytes: number(),
10177
+ sha256: string()
10178
+ }),
10179
+ object({
10180
+ ...EventBase,
10181
+ type: literal("done"),
10182
+ status: _enum(["succeeded", "failed"]),
10183
+ resultSha256: string().nullable().optional()
10184
+ }),
10185
+ object({
10186
+ ...EventBase,
10187
+ type: literal("error"),
10188
+ stage: string(),
10189
+ code: string(),
10190
+ message: string()
10191
+ })
10192
+ ]);
10193
+ /**
9499
10194
  * What the gate decided about a birth, from the CALLER's point of view.
9500
10195
  *
9501
10196
  * Deliberately not `ConfirmationVerdict`: `undecided` is not a birth decision
@@ -11823,7 +12518,9 @@ var AddonHttpRouteSchema = object({
11823
12518
  "authenticated",
11824
12519
  "admin"
11825
12520
  ]).optional(),
11826
- description: string().optional()
12521
+ description: string().optional(),
12522
+ /** The hub limits this route per client address before the handler runs. */
12523
+ rateLimit: _enum(["auth"]).optional()
11827
12524
  });
11828
12525
  /**
11829
12526
  * Cross-process route invocation envelope. The hub captures the
@@ -12528,6 +13225,37 @@ var BackupDestinationInfoSchema = object({
12528
13225
  lastError: string().optional()
12529
13226
  });
12530
13227
  /**
13228
+ * How an archive is encrypted (operator decision 2026-10-09): to a backup
13229
+ * PUBLIC key the hub holds, so only the operator's secret key opens it.
13230
+ * Absent on a plain `.tar.gz` — every archive made before encryption, or
13231
+ * with it off — which restores without a key.
13232
+ */
13233
+ var BackupArchiveEncryptionSchema = object({
13234
+ /** `x25519-hkdf-aes256gcm-stream-v1`. */
13235
+ scheme: string(),
13236
+ /** 16 hex — the backup key whose secret restores this archive. */
13237
+ keyId: string()
13238
+ });
13239
+ /**
13240
+ * The backup encryption setting. The hub keeps PUBLIC keys only: the active
13241
+ * one new archives are encrypted to, and the retired ones older archives
13242
+ * still need. The secret key is shown once, at `setupEncryption`.
13243
+ */
13244
+ var BackupEncryptionStatusSchema = object({
13245
+ enabled: boolean(),
13246
+ active: object({
13247
+ keyId: string(),
13248
+ publicKey: string(),
13249
+ createdAt: number()
13250
+ }).nullable(),
13251
+ /** Every key ever set up, newest first. */
13252
+ keys: array(object({
13253
+ keyId: string(),
13254
+ createdAt: number(),
13255
+ retiredAt: number().nullable()
13256
+ })).readonly()
13257
+ });
13258
+ /**
12531
13259
  * Per-archive entry returned by `backup.listArchives({ destinationId })`.
12532
13260
  * Same shape the destination drill-in renders. Sourced from the per-
12533
13261
  * location `manifests.json` (no per-archive tarball read required).
@@ -12539,7 +13267,9 @@ var BackupArchiveEntrySchema = object({
12539
13267
  sizeBytes: number(),
12540
13268
  label: string().optional(),
12541
13269
  /** Top-level locations included in the archive (db, addons, tls, …). */
12542
- locations: array(string()).readonly()
13270
+ locations: array(string()).readonly(),
13271
+ /** Present when the archive is encrypted; restore then needs that key. */
13272
+ encryption: BackupArchiveEncryptionSchema.optional()
12543
13273
  });
12544
13274
  var BackupEntrySchema = object({
12545
13275
  id: string(),
@@ -12548,7 +13278,8 @@ var BackupEntrySchema = object({
12548
13278
  label: string().optional(),
12549
13279
  createdAt: number(),
12550
13280
  sizeBytes: number(),
12551
- locations: array(string()).optional()
13281
+ locations: array(string()).optional(),
13282
+ encryption: BackupArchiveEncryptionSchema.optional()
12552
13283
  });
12553
13284
  var ArchiveEntrySchema = object({
12554
13285
  path: string(),
@@ -12737,10 +13468,40 @@ method(_void(), array(BackupDestinationInfoSchema).readonly(), { auth: "admin" }
12737
13468
  * this list and skips entries whose path doesn't start with
12738
13469
  * any of them.
12739
13470
  */
12740
- locations: array(string()).optional()
13471
+ locations: array(string()).optional(),
13472
+ /**
13473
+ * The backup SECRET key, for an encrypted archive (ignored for a plain
13474
+ * one). The archive is decrypted into the hub's private staging
13475
+ * before the restart; the key is not stored. A wrong or missing key
13476
+ * is refused before the archive is downloaded.
13477
+ */
13478
+ backupSecretKey: string().optional()
12741
13479
  }), _void(), {
12742
13480
  kind: "mutation",
12743
13481
  auth: "admin"
13482
+ }), method(_void(), BackupEncryptionStatusSchema, { auth: "admin" }), method(object({}), object({
13483
+ keyId: string(),
13484
+ secretKey: string(),
13485
+ publicKey: string(),
13486
+ createdAt: number(),
13487
+ replacedKeyId: string().nullable()
13488
+ }), {
13489
+ kind: "mutation",
13490
+ auth: "admin"
13491
+ }), method(object({}), object({ disabledKeyId: string().nullable() }), {
13492
+ kind: "mutation",
13493
+ auth: "admin"
13494
+ }), method(object({ backupSecretKey: string() }), object({
13495
+ valid: boolean(),
13496
+ keyId: string().nullable(),
13497
+ /** The hub knows this key (active or retired). */
13498
+ known: boolean(),
13499
+ /** It is the key new archives are encrypted to. */
13500
+ active: boolean(),
13501
+ error: string().optional()
13502
+ }), {
13503
+ kind: "mutation",
13504
+ auth: "admin"
12744
13505
  }), method(object({
12745
13506
  destinationId: string(),
12746
13507
  backupId: string()
@@ -14466,7 +15227,60 @@ var CustomModelDescriptorSchema = object({
14466
15227
  stepId: string(),
14467
15228
  entry: ModelCatalogEntrySchema
14468
15229
  });
14469
- method(_void(), array(CustomModelDescriptorSchema).readonly(), { auth: "admin" });
15230
+ /** One regular file of an imported bundle, as the producer measured it. */
15231
+ var ModelBundleFileSchema = object({
15232
+ /** Relative path inside the bundle tar; an mlpackage member is `<x>.mlpackage/<member>`. */
15233
+ path: string().min(1),
15234
+ bytes: number().int().nonnegative(),
15235
+ sha256: string().regex(/^[0-9a-f]{64}$/)
15236
+ });
15237
+ var ImportModelBundleInputSchema = object({
15238
+ /** The registry provider that keeps the model (Model Studio). */
15239
+ addonId: string(),
15240
+ stepId: string().min(1),
15241
+ /**
15242
+ * The catalog rows to register, complete, every format URL already
15243
+ * `camstack-local://<modelId>/<file>` naming a file of the bundle. One
15244
+ * bundle may carry several rows (a base and its INT8 variant).
15245
+ */
15246
+ entries: array(ModelCatalogEntrySchema).min(1).max(4),
15247
+ /** The bundle tar, offered by the producer over `ctx.peerBytes` (same host). */
15248
+ bundle: object({
15249
+ ticket: PeerBytesTicketSchema,
15250
+ bytes: number().int().positive(),
15251
+ sha256: string().regex(/^[0-9a-f]{64}$/)
15252
+ }),
15253
+ /** Every file the tar must hold; anything missing, extra or different is refused. */
15254
+ files: array(ModelBundleFileSchema).min(1).max(64),
15255
+ /** Convert missing engine formats and push the model to every agent afterwards. */
15256
+ distribute: boolean()
15257
+ });
15258
+ var ImportModelBundleResultSchema = discriminatedUnion("kind", [object({
15259
+ kind: literal("imported"),
15260
+ modelIds: array(string()).readonly(),
15261
+ distributed: array(object({
15262
+ modelId: string(),
15263
+ nodeId: string(),
15264
+ format: _enum(MODEL_FORMATS),
15265
+ ok: boolean(),
15266
+ error: string().optional()
15267
+ })).readonly()
15268
+ }), object({
15269
+ kind: literal("refused"),
15270
+ reason: _enum([
15271
+ "transfer-failed",
15272
+ "checksum-mismatch",
15273
+ "bundle-mismatch",
15274
+ "invalid-entry",
15275
+ "id-taken"
15276
+ ]),
15277
+ detail: string()
15278
+ })]);
15279
+ method(_void(), array(CustomModelDescriptorSchema).readonly(), { auth: "admin" }), method(ImportModelBundleInputSchema, ImportModelBundleResultSchema, {
15280
+ kind: "mutation",
15281
+ auth: "admin",
15282
+ timeoutMs: 30 * 6e4
15283
+ });
14470
15284
  /**
14471
15285
  * Query filter for settings-store collections.
14472
15286
  */
@@ -14945,6 +15759,35 @@ var KeychainKeySourceSchema = object({
14945
15759
  */
14946
15760
  sharesBackupWithDatabase: boolean()
14947
15761
  });
15762
+ /**
15763
+ * One keychain reset, as the Secrets page reports it until the operator
15764
+ * acknowledges it. Never a value: refs, counts and table names only.
15765
+ */
15766
+ var KeychainResetRecordSchema = object({
15767
+ id: string(),
15768
+ at: number(),
15769
+ /** `user:<id>` or {@link KEYCHAIN_RESET_TRIGGER_ACTOR}. */
15770
+ actor: string(),
15771
+ /** Why the keychain was locked when it was reset; `null` when it was not locked. */
15772
+ lockedReason: string().nullable(),
15773
+ /** Values moved into the archive table (ciphertext under the lost key). */
15774
+ archived: number().int(),
15775
+ /** `keychain:secrets-orphaned-<ts>`, or `null` when nothing was stored. */
15776
+ archivedCollection: string().nullable(),
15777
+ /**
15778
+ * `keychain:keys-orphaned-<ts>`: the wrapped data keys of the archive, kept
15779
+ * so the archive can still be opened if the lost master key turns up.
15780
+ */
15781
+ archivedKeysCollection: string().nullable(),
15782
+ /**
15783
+ * `system-settings` keys whose marker the reset cleared — the cluster
15784
+ * secret's: a marker left pointing at an archived value would refuse every
15785
+ * agent forever (D797).
15786
+ */
15787
+ clearedSettingsKeys: array(string()).readonly(),
15788
+ /** When an operator dismissed the notice on the Secrets page; `null` until then. */
15789
+ acknowledgedAt: number().nullable()
15790
+ });
14948
15791
  var KeychainStatusSchema = object({
14949
15792
  keychain: KeychainStateSchema,
14950
15793
  /** The source of the master key in use; `null` while locked. */
@@ -14962,7 +15805,9 @@ var KeychainStatusSchema = object({
14962
15805
  /** Wrapped copies of the data key under a previous master key, kept until purged. */
14963
15806
  retiredWraps: number().int(),
14964
15807
  recoveryKeyDownloadedAt: number().nullable(),
14965
- secretCount: number().int()
15808
+ secretCount: number().int(),
15809
+ /** The most recent reset, acknowledged or not; `null` when the keychain was never reset. */
15810
+ lastReset: KeychainResetRecordSchema.nullable()
14966
15811
  });
14967
15812
  /**
14968
15813
  * Whether a stored value is still pointed at by its owner's settings.
@@ -14984,17 +15829,26 @@ var KeychainAuditActionSchema = _enum([
14984
15829
  "download-recovery-key",
14985
15830
  "delete-orphans",
14986
15831
  "reset",
15832
+ "acknowledge-reset",
14987
15833
  "initialize"
14988
15834
  ]);
14989
15835
  var KeychainAuditEntrySchema = object({
14990
15836
  id: string(),
14991
15837
  at: number(),
14992
15838
  action: KeychainAuditActionSchema,
14993
- /** `addon:<id>` | `user:<id>` | `system`. */
15839
+ /** `addon:<id>` | `user:<id>` | `system` | `trigger-file`. */
14994
15840
  actor: string(),
14995
15841
  ref: string().nullable(),
14996
15842
  detail: string().nullable()
14997
15843
  });
15844
+ var KEYCHAIN_RESET_CONFIRMATION = "RESET KEYCHAIN";
15845
+ /**
15846
+ * Secrets the HUB itself holds (owner `system`) that no settings form shows:
15847
+ * `jwt-signing-key` — the session signing key (D797). It is always "in use",
15848
+ * never an orphan; it is generated on a fresh hub and replaced only through
15849
+ * {@link keychainAdminCapability.methods.setSystemSecret}.
15850
+ */
15851
+ var SystemHeldSecretNameSchema = _enum(["jwt-signing-key"]);
14998
15852
  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({
14999
15853
  value: string(),
15000
15854
  version: number().int()
@@ -15002,6 +15856,16 @@ method(object({}), KeychainStatusSchema, { auth: "admin" }), method(object({}),
15002
15856
  kind: "mutation",
15003
15857
  auth: "admin",
15004
15858
  caller: "required"
15859
+ }), method(object({
15860
+ name: SystemHeldSecretNameSchema,
15861
+ value: string().min(16)
15862
+ }), object({
15863
+ ref: string(),
15864
+ version: number().int()
15865
+ }), {
15866
+ kind: "mutation",
15867
+ auth: "admin",
15868
+ caller: "required"
15005
15869
  }), method(object({ refs: array(string().min(1)).max(1e3) }), object({
15006
15870
  deleted: array(string()).readonly(),
15007
15871
  kept: array(object({
@@ -15031,13 +15895,20 @@ method(object({}), KeychainStatusSchema, { auth: "admin" }), method(object({}),
15031
15895
  kind: "mutation",
15032
15896
  auth: "admin",
15033
15897
  caller: "required"
15034
- }), method(object({ confirm: literal("RESET KEYCHAIN") }), object({
15898
+ }), method(object({ confirm: literal(KEYCHAIN_RESET_CONFIRMATION) }), object({
15035
15899
  archivedCollection: string().nullable(),
15036
15900
  archived: number().int()
15037
15901
  }), {
15038
15902
  kind: "mutation",
15039
15903
  auth: "admin",
15040
15904
  caller: "required"
15905
+ }), method(object({}), object({
15906
+ reset: KeychainResetRecordSchema.nullable(),
15907
+ pendingReentry: array(KeychainSecretMetaSchema).readonly()
15908
+ }), { auth: "admin" }), method(object({}), object({ acknowledged: boolean() }), {
15909
+ kind: "mutation",
15910
+ auth: "admin",
15911
+ caller: "required"
15041
15912
  });
15042
15913
  method(_void(), object({
15043
15914
  id: string(),
@@ -17984,7 +18855,7 @@ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
17984
18855
  * `login-method` — collection cap through which auth addons contribute
17985
18856
  * their pre-auth login surfaces to the login page. This is the SINGLE,
17986
18857
  * generic mechanism that supersedes the dead `auth.listProviders` reader:
17987
- * every auth addon (OIDC, magic-link, WebAuthn/passkey) registers a
18858
+ * every auth addon (OIDC, WebAuthn/passkey) registers a
17988
18859
  * `login-method` provider and the PUBLIC `auth.listLoginMethods`
17989
18860
  * procedure aggregates them for the unauthenticated login page.
17990
18861
  *
@@ -17992,8 +18863,7 @@ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
17992
18863
  *
17993
18864
  * - `redirect` — a declarative button. The login page renders a generic
17994
18865
  * button that navigates to `startUrl` (an addon-owned HTTP route).
17995
- * Covers OIDC (`/addon/auth-oidc/<id>/start`) and magic-link with
17996
- * ZERO shell-side JS. A future SSO addon plugs in the same way — the
18866
+ * Covers OIDC (`/addon/auth-oidc/<id>/start`) with ZERO shell-side JS. A future SSO addon plugs in the same way — the
17997
18867
  * login page needs NO change.
17998
18868
  *
17999
18869
  * - `widget` — a Module-Federation widget the login page mounts (via
@@ -18012,8 +18882,8 @@ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
18012
18882
  * decision.
18013
18883
  *
18014
18884
  * Every contribution carries a `stage`:
18015
- * - `primary` — shown on the first credentials screen (OIDC /
18016
- * magic-link buttons; a future usernameless passkey).
18885
+ * - `primary` — shown on the first credentials screen (OIDC
18886
+ * buttons; a usernameless passkey).
18017
18887
  * - `second-factor` — shown AFTER the password leg, gated on the
18018
18888
  * returned `factors` (passkey-as-2FA today).
18019
18889
  *
@@ -18040,7 +18910,7 @@ var LoginMethodContributionSchema = discriminatedUnion("kind", [
18040
18910
  * The provider names an external identity a signed-in user can link to
18041
18911
  * their own account (D782): `auth.listLinkableProviders` /
18042
18912
  * `beginExternalLink` offer exactly the redirect methods that set this,
18043
- * whatever their id. Absent / false — a login button only (magic-link).
18913
+ * whatever their id. Absent / false — a login button only.
18044
18914
  */
18045
18915
  linkable: boolean().optional()
18046
18916
  }),
@@ -21895,8 +22765,7 @@ method(object({}), object({ rules: array(NcRuleSchema) }), { auth: "admin" }), m
21895
22765
  * `super_admin` — collapsed onto the single boolean because every
21896
22766
  * non-admin caller is governed by the same scope-check rules; the
21897
22767
  * distinction was only ever used to route role-specific procedures
21898
- * which we no longer have. Agents are admin sessions issued via
21899
- * `createServiceToken`; CLI / webhook integrations are `cst_*` tokens
22768
+ * which we no longer have. CLI / webhook integrations are `cst_*` tokens
21900
22769
  * with `isAdmin: false` + an explicit scope list.
21901
22770
  */
21902
22771
  /** Per-method access flavour. Materialised on every cap method via codegen. */
@@ -23571,6 +24440,9 @@ var RetrainExportFilterSchema = object({
23571
24440
  frameIds: array(string()).max(2e4).optional(),
23572
24441
  /** Only frames in at least one of these named collections. */
23573
24442
  collectionIds: array(string()).max(200).optional(),
24443
+ /** Exactly the frames of this dataset version (and its completeOnly). An
24444
+ * unknown id selects nothing. */
24445
+ datasetVersionId: string().optional(),
23574
24446
  batchId: string().optional(),
23575
24447
  /** Only frames the operator marked complete (all subjects boxed). */
23576
24448
  completeOnly: boolean().optional()
@@ -23738,6 +24610,67 @@ var RetrainLlmAssistResultSchema = discriminatedUnion("kind", [object({
23738
24610
  ]),
23739
24611
  detail: string().optional()
23740
24612
  })]);
24613
+ /** What a dataset version is cut from. Every field narrows. */
24614
+ var RetrainDatasetSelectionSchema = object({
24615
+ deviceIds: array(number()).readonly().optional(),
24616
+ collectionIds: array(string()).max(200).readonly().optional(),
24617
+ frameIds: array(string()).max(2e4).readonly().optional()
24618
+ });
24619
+ /** The counts a dataset is judged by. */
24620
+ var RetrainDatasetStatsSchema = object({
24621
+ frames: number().int(),
24622
+ completeFrames: number().int(),
24623
+ /** `completeFrames / frames`, 0..1. */
24624
+ completeness: number(),
24625
+ /** Boxes to learn (model errors excluded). */
24626
+ subjects: number().int(),
24627
+ modelErrors: number().int(),
24628
+ /** Complete frames with no subject. */
24629
+ hardNegatives: number().int(),
24630
+ /** Subjects per class × camera × day/night. */
24631
+ cells: array(object({
24632
+ macroClass: string(),
24633
+ deviceId: number(),
24634
+ lighting: _enum([
24635
+ "day",
24636
+ "night",
24637
+ "unknown"
24638
+ ]),
24639
+ subjects: number().int(),
24640
+ frames: number().int()
24641
+ })).readonly(),
24642
+ cameras: array(object({
24643
+ deviceId: number(),
24644
+ frames: number().int(),
24645
+ completeFrames: number().int()
24646
+ })).readonly()
24647
+ });
24648
+ /** An immutable dataset version, without its frame list. */
24649
+ var RetrainDatasetVersionSchema = object({
24650
+ id: string(),
24651
+ name: string(),
24652
+ createdAt: number(),
24653
+ selection: RetrainDatasetSelectionSchema,
24654
+ layout: RetrainExportLayoutSchema,
24655
+ completeOnly: boolean(),
24656
+ frameCount: number().int(),
24657
+ /** sha256 of what the frames taught when the version was frozen. */
24658
+ annotationHash: string(),
24659
+ /** The export manifest schema the version was cut under. */
24660
+ manifestSchema: string(),
24661
+ stats: RetrainDatasetStatsSchema
24662
+ });
24663
+ var CreateRetrainDatasetVersionResultSchema = discriminatedUnion("kind", [object({
24664
+ kind: literal("created"),
24665
+ version: RetrainDatasetVersionSchema
24666
+ }), object({
24667
+ kind: literal("refused"),
24668
+ reason: _enum([
24669
+ "empty-name",
24670
+ "duplicate-name",
24671
+ "no-frames"
24672
+ ])
24673
+ })]);
23741
24674
  /** The outcome of a lifecycle move owned by the retrain page. */
23742
24675
  var RetrainTransitionResultSchema = object({
23743
24676
  trackId: string(),
@@ -24527,6 +25460,47 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
24527
25460
  kind: "mutation",
24528
25461
  auth: "admin",
24529
25462
  timeoutMs: 60 * 6e4
25463
+ }), method(object({
25464
+ filter: RetrainExportFilterSchema,
25465
+ layout: RetrainExportLayoutSchema
25466
+ }), object({
25467
+ ticket: PeerBytesTicketSchema,
25468
+ frames: number().int(),
25469
+ annotations: number().int()
25470
+ }), {
25471
+ kind: "mutation",
25472
+ auth: "admin",
25473
+ timeoutMs: 12e4
25474
+ }), method(object({
25475
+ selection: RetrainDatasetSelectionSchema,
25476
+ completeOnly: boolean().optional()
25477
+ }), RetrainDatasetStatsSchema, {
25478
+ kind: "query",
25479
+ auth: "admin"
25480
+ }), method(object({
25481
+ name: string().max(120),
25482
+ selection: RetrainDatasetSelectionSchema,
25483
+ layout: RetrainExportLayoutSchema,
25484
+ completeOnly: boolean()
25485
+ }), CreateRetrainDatasetVersionResultSchema, {
25486
+ kind: "mutation",
25487
+ auth: "admin",
25488
+ timeoutMs: 12e4
25489
+ }), method(object({}), array(RetrainDatasetVersionSchema).readonly(), {
25490
+ kind: "query",
25491
+ auth: "admin"
25492
+ }), method(object({ id: string() }), object({ deleted: boolean() }), {
25493
+ kind: "mutation",
25494
+ auth: "admin"
25495
+ }), method(object({ id: string() }), object({
25496
+ found: boolean(),
25497
+ annotationHash: string(),
25498
+ matches: boolean(),
25499
+ missingFrames: number().int()
25500
+ }), {
25501
+ kind: "query",
25502
+ auth: "admin",
25503
+ timeoutMs: 12e4
24530
25504
  }), method(object({}), array(RetrainAssistProfileSchema).readonly(), {
24531
25505
  kind: "query",
24532
25506
  auth: "admin"
@@ -28105,8 +29079,8 @@ version: string().optional() }), ServerUpdateActionResultSchema, {
28105
29079
  * `smtp-provider` — pluggable email delivery surface.
28106
29080
  *
28107
29081
  * Collection cap: a deployment may install multiple SMTP relays (e.g.
28108
- * one for transactional / one for notifications). Consumers (magic-link,
28109
- * notifier addons, …) walk the collection and pick the first
29082
+ * one for transactional / one for notifications). Consumers (notifier
29083
+ * addons, …) walk the collection and pick the first
28110
29084
  * ready provider OR target a specific addonId.
28111
29085
  *
28112
29086
  * The shape stays small on purpose — `sendEmail` is enough for the
@@ -28389,7 +29363,7 @@ targets: array(object({
28389
29363
  };
28390
29364
  /**
28391
29365
  * `sso-bridge` — internal hub-only cap that lets SSO-style auth
28392
- * providers (OIDC, SAML, magic-link, …) mint an HMAC-signed token
29366
+ * providers (OIDC, SAML, …) mint an HMAC-signed token
28393
29367
  * carrying the post-callback claims before redirecting back to
28394
29368
  * `/api/auth/sso/finish`.
28395
29369
  *
@@ -28452,7 +29426,14 @@ var SsoBridgeClaimsSchema = object({
28452
29426
  * Verified `iss` of the id_token behind an OIDC login bridge (D782). A
28453
29427
  * subject is unique only per issuer, so a link is bound to it.
28454
29428
  */
28455
- issuer: string().optional()
29429
+ issuer: string().optional(),
29430
+ /**
29431
+ * SHA-256 (hex) of the `camstack_sso_state` cookie the IdP `/start` set in
29432
+ * the browser that began this sign-in. `/api/auth/sso/finish` requires the
29433
+ * request to present the matching cookie — a login bridge is useless in
29434
+ * any other browser.
29435
+ */
29436
+ browserBinding: string().optional()
28456
29437
  });
28457
29438
  method(object({
28458
29439
  claims: SsoBridgeClaimsSchema,
@@ -41582,16 +42563,6 @@ var ApiKeySummarySchema = object({
41582
42563
  createdAt: number(),
41583
42564
  lastUsedAt: number().optional()
41584
42565
  });
41585
- var CreateApiKeyInputSchema = object({
41586
- label: string(),
41587
- isAdmin: boolean().default(false),
41588
- allowedProviders: union([array(string()), literal("*")]).optional(),
41589
- allowedDevices: record(string(), union([array(string()), literal("*")])).optional()
41590
- });
41591
- var CreateApiKeyResultSchema = object({
41592
- token: string(),
41593
- record: ApiKeySummarySchema
41594
- });
41595
42566
  var ScopedTokenSummarySchema = object({
41596
42567
  id: string(),
41597
42568
  userId: string(),
@@ -41690,17 +42661,10 @@ method(_void(), array(UserSummarySchema), { auth: "admin" }), method(CreateUserI
41690
42661
  }), UserSummarySchema.extend({ passwordHash: string() }).nullable(), {
41691
42662
  kind: "mutation",
41692
42663
  access: "view"
41693
- }), method(_void(), array(ApiKeySummarySchema), { auth: "admin" }), method(CreateApiKeyInputSchema, CreateApiKeyResultSchema, {
41694
- kind: "mutation",
41695
- auth: "admin",
41696
- access: "create"
41697
- }), method(object({ id: string() }), object({ success: literal(true) }), {
42664
+ }), method(_void(), array(ApiKeySummarySchema), { auth: "admin" }), method(object({ id: string() }), object({ success: literal(true) }), {
41698
42665
  kind: "mutation",
41699
42666
  auth: "admin",
41700
42667
  access: "delete"
41701
- }), method(object({ token: string() }), ApiKeySummarySchema.nullable(), {
41702
- kind: "mutation",
41703
- access: "view"
41704
42668
  }), method(CreateScopedTokenInputSchema, CreateScopedTokenResultSchema, {
41705
42669
  kind: "mutation",
41706
42670
  auth: "admin",
@@ -41774,15 +42738,7 @@ method(_void(), array(UserSummarySchema), { auth: "admin" }), method(CreateUserI
41774
42738
  }).nullable(), { access: "view" }), method(object({ userId: string() }), array(ExternalIdentitySchema), { auth: "admin" }), method(ExternalIdentityKeySchema, object({
41775
42739
  userId: string(),
41776
42740
  issuer: string()
41777
- }).nullable(), { auth: "admin" }), method(ExternalIdentityKeySchema.extend({
41778
- userId: string(),
41779
- issuer: string().min(1),
41780
- label: string().optional()
41781
- }), object({ success: literal(true) }), {
41782
- kind: "mutation",
41783
- auth: "admin",
41784
- access: "create"
41785
- }), method(ExternalIdentityKeySchema.extend({ userId: string() }), object({ success: boolean() }), {
42741
+ }).nullable(), { auth: "admin" }), method(ExternalIdentityKeySchema.extend({ userId: string() }), object({ success: boolean() }), {
41786
42742
  kind: "mutation",
41787
42743
  auth: "admin",
41788
42744
  access: "delete"
@@ -42487,6 +43443,451 @@ var zoneRulesCapability = {
42487
43443
  */
42488
43444
  durability: "restored"
42489
43445
  };
43446
+ /**
43447
+ * `training-provider` — ONE cloud that can run the CamStack trainer.
43448
+ *
43449
+ * A thin, mockable translation layer: it knows how to run a container with a
43450
+ * GPU, move a dataset in, read the job's stdout and hand artefacts back. It
43451
+ * knows nothing about datasets, splits, floors, cost policy or Model Studio —
43452
+ * those are the `training` orchestrator's (D805). Every rule written there
43453
+ * once is what makes a second provider (RunPod, a local NVIDIA node) a new
43454
+ * manifest entry and nothing else.
43455
+ *
43456
+ * Collection, routed by the `addonId` in every single-row input (the `llm` /
43457
+ * `notification-output` posture); `describe` concat-fans across providers.
43458
+ * Every method is `admin`: these spend money.
43459
+ *
43460
+ * Every cloud object a provider creates is tagged with the orchestrator's
43461
+ * `jobKey`, so a retried submit finds the job it already started instead of
43462
+ * starting a second GPU, and `listJobs` can find orphans.
43463
+ *
43464
+ * Bytes never ride a cap field: the dataset arrives as a `ctx.peerBytes`
43465
+ * ticket the producer (pipeline-analytics) minted, and artefacts leave as a
43466
+ * ticket the provider mints (D613).
43467
+ */
43468
+ var TrainingGpuOptionSchema = object({
43469
+ id: string(),
43470
+ label: string(),
43471
+ /** List price, USD per GPU-hour, before any region multiplier. */
43472
+ usdPerHour: number().nonnegative(),
43473
+ vramGb: number().nonnegative()
43474
+ });
43475
+ var TrainingRegionOptionSchema = object({
43476
+ /** `''` = any region (the provider's choice). */
43477
+ id: string(),
43478
+ label: string(),
43479
+ priceMultiplier: number().positive()
43480
+ });
43481
+ /**
43482
+ * The provider's per-account settings, as the orchestrator reads them. They
43483
+ * live in the PROVIDER addon's settings (operator decision 2026-10-08: they
43484
+ * depend on the user's account), never hard-coded in the orchestrator.
43485
+ */
43486
+ var TrainingProviderDefaultsSchema = object({
43487
+ gpuType: string(),
43488
+ region: string(),
43489
+ costCapUsd: number().nonnegative(),
43490
+ maxRuntimeSec: number().int().positive(),
43491
+ /** Hours a FAILED job's cloud dataset is kept for debugging; 0 = delete at once. */
43492
+ failedDatasetGraceHours: number().nonnegative()
43493
+ });
43494
+ var TrainingProviderDescriptorSchema = object({
43495
+ addonId: string(),
43496
+ /** `modal`, `runpod`, `fake`, … */
43497
+ kind: string(),
43498
+ label: string(),
43499
+ gpuTypes: array(TrainingGpuOptionSchema).readonly(),
43500
+ regions: array(TrainingRegionOptionSchema).readonly(),
43501
+ maxDatasetBytes: number().int().positive(),
43502
+ maxRuntimeSec: number().int().positive(),
43503
+ freeTierNote: string().optional(),
43504
+ /** Where the data goes, in one sentence the confirm dialog repeats. */
43505
+ dataResidencyNote: string(),
43506
+ /** Credentials are present — never the values. */
43507
+ configured: boolean(),
43508
+ defaults: TrainingProviderDefaultsSchema
43509
+ });
43510
+ var TrainingCredentialCheckSchema = object({
43511
+ ok: boolean(),
43512
+ /** Workspace / account name, when the provider says. */
43513
+ account: string().optional(),
43514
+ reason: _enum([
43515
+ "missing",
43516
+ "invalid",
43517
+ "forbidden",
43518
+ "network",
43519
+ "quota"
43520
+ ]).optional(),
43521
+ detail: string().optional()
43522
+ });
43523
+ var ProviderJobStateSchema = _enum([
43524
+ "pending",
43525
+ "starting",
43526
+ "running",
43527
+ "succeeded",
43528
+ "failed",
43529
+ "cancelled",
43530
+ "lost"
43531
+ ]);
43532
+ var ProviderJobStatusSchema = object({
43533
+ jobKey: string(),
43534
+ providerJobId: string().optional(),
43535
+ state: ProviderJobStateSchema,
43536
+ startedAt: number().optional(),
43537
+ endedAt: number().optional(),
43538
+ exitCode: number().int().optional(),
43539
+ failureReason: string().optional(),
43540
+ gpuType: string(),
43541
+ region: string().optional(),
43542
+ billedSeconds: number().nonnegative(),
43543
+ costUsd: number().nonnegative(),
43544
+ /** True when `costUsd` is runtime × list price, not a billing answer. */
43545
+ costIsEstimate: boolean(),
43546
+ lastFetchedAt: number()
43547
+ });
43548
+ /**
43549
+ * The trainer the job runs, by SOURCE revision: the provider turns it into an
43550
+ * image its own way (Modal builds the published Dockerfile at that revision;
43551
+ * a registry-pull provider maps it to a tag). Recorded on the job and echoed
43552
+ * in `result.json`.
43553
+ */
43554
+ var TrainerSourceRefSchema = object({
43555
+ /** Hugging Face repo id, e.g. `camstack/camstack-trainer`. */
43556
+ repo: string().min(1),
43557
+ /** A commit sha (never a branch) — the job must be reproducible. */
43558
+ revision: string().regex(/^[0-9a-f]{7,64}$/)
43559
+ });
43560
+ var JobRef = {
43561
+ addonId: string(),
43562
+ jobKey: string().uuid()
43563
+ };
43564
+ var TrainingLogLineSchema = object({
43565
+ ts: number(),
43566
+ text: string()
43567
+ });
43568
+ method(object({}), array(TrainingProviderDescriptorSchema).readonly(), { auth: "admin" }), method(object({ addonId: string() }), TrainingCredentialCheckSchema, {
43569
+ kind: "mutation",
43570
+ auth: "admin",
43571
+ timeoutMs: 3e4
43572
+ }), method(object({
43573
+ addonId: string(),
43574
+ gpuType: string(),
43575
+ region: string(),
43576
+ datasetBytes: number().int().nonnegative(),
43577
+ gpuSecondsLow: number().nonnegative(),
43578
+ gpuSecondsHigh: number().nonnegative()
43579
+ }), object({
43580
+ usdLow: number().nonnegative(),
43581
+ usdHigh: number().nonnegative(),
43582
+ notes: array(string()).readonly()
43583
+ }), { auth: "admin" }), method(object({
43584
+ ...JobRef,
43585
+ ticket: PeerBytesTicketSchema
43586
+ }), object({
43587
+ bytes: number().int().nonnegative(),
43588
+ sha256: string()
43589
+ }), {
43590
+ kind: "mutation",
43591
+ auth: "admin",
43592
+ timeoutMs: 120 * 6e4
43593
+ }), method(object({
43594
+ ...JobRef,
43595
+ trainer: TrainerSourceRefSchema,
43596
+ jobSpecJson: string().min(2).max(64e3),
43597
+ gpuType: string(),
43598
+ region: string(),
43599
+ maxRuntimeSec: number().int().positive()
43600
+ }), ProviderJobStatusSchema, {
43601
+ kind: "mutation",
43602
+ auth: "admin",
43603
+ timeoutMs: 30 * 6e4
43604
+ }), method(object(JobRef), ProviderJobStatusSchema, {
43605
+ auth: "admin",
43606
+ timeoutMs: 6e4
43607
+ }), method(object({
43608
+ ...JobRef,
43609
+ cursor: string().optional(),
43610
+ max: number().int().min(1).max(500)
43611
+ }), object({
43612
+ lines: array(TrainingLogLineSchema).readonly(),
43613
+ cursor: string()
43614
+ }), {
43615
+ auth: "admin",
43616
+ timeoutMs: 6e4
43617
+ }), method(object(JobRef), object({ ok: literal(true) }), {
43618
+ kind: "mutation",
43619
+ auth: "admin",
43620
+ timeoutMs: 6e4
43621
+ }), method(object(JobRef), object({
43622
+ found: boolean(),
43623
+ text: string().optional()
43624
+ }), {
43625
+ kind: "mutation",
43626
+ auth: "admin",
43627
+ timeoutMs: 5 * 6e4
43628
+ }), method(object({
43629
+ ...JobRef,
43630
+ path: _enum(["bundle.tar"])
43631
+ }), object({ ticket: PeerBytesTicketSchema }), {
43632
+ kind: "mutation",
43633
+ auth: "admin",
43634
+ timeoutMs: 5 * 6e4
43635
+ }), method(object(JobRef), object({ deleted: array(string()).readonly() }), {
43636
+ kind: "mutation",
43637
+ auth: "admin",
43638
+ timeoutMs: 5 * 6e4
43639
+ }), method(object({ addonId: string() }), array(ProviderJobStatusSchema).readonly(), {
43640
+ auth: "admin",
43641
+ timeoutMs: 2 * 6e4
43642
+ });
43643
+ /**
43644
+ * `training` — the cloud-training orchestrator (D805). Hub-only singleton,
43645
+ * provided by `addon-training`.
43646
+ *
43647
+ * It owns what every provider must agree on, written once:
43648
+ *
43649
+ * - **Dataset versions.** Taken over from pipeline-analytics (D796): the rows
43650
+ * live here (D808); pipeline-analytics still CUTS a version (it owns the corpus and
43651
+ * the export plan) and reaches this store through the five row methods
43652
+ * below, so the Retrain page and the export did not change.
43653
+ * - **Jobs.** A persisted state machine, a reconcile loop against the
43654
+ * provider, a cost guard, a daily orphan sweep and the retention rules.
43655
+ * - **The return flow.** Verified artefacts → Model Studio
43656
+ * (`custom-model-registry.importModelBundle`) → canary on cameras →
43657
+ * rollback. Nothing is ever registered automatically.
43658
+ *
43659
+ * Every method is `admin`.
43660
+ */
43661
+ /** A version WITH its frame list — what the export and a job read. */
43662
+ var TrainingDatasetVersionRowSchema = RetrainDatasetVersionSchema.omit({ frameCount: true }).extend({ frameIds: array(string()).max(2e4).readonly() });
43663
+ /** A base model a detector job can fine-tune, and the baseline it is judged against. */
43664
+ var TrainingBaseModelSchema = object({
43665
+ modelId: string(),
43666
+ label: string(),
43667
+ weights: string(),
43668
+ imgsz: number().int(),
43669
+ baselineOnnxUrl: string(),
43670
+ baselineFloors: record(string(), number()),
43671
+ /** The base the fleet runs most — the UI's default. */
43672
+ recommended: boolean()
43673
+ });
43674
+ var TrainingPresetSchema = _enum([
43675
+ "quick",
43676
+ "standard",
43677
+ "thorough"
43678
+ ]);
43679
+ var TrainingJobRequestSchema = object({
43680
+ datasetVersionId: string().min(1),
43681
+ /** The `training-provider` addon that runs it. */
43682
+ addonId: string().min(1),
43683
+ gpuType: string().min(1),
43684
+ region: string(),
43685
+ baseModelId: string().min(1),
43686
+ preset: TrainingPresetSchema,
43687
+ /** Freeze the backbone's first N layers; `null` = the preset's choice. */
43688
+ freeze: number().int().nonnegative().nullable(),
43689
+ /** Cameras held out whole for evaluation; `null` = the orchestrator's default. */
43690
+ holdoutCameras: array(number().int()).nullable()
43691
+ });
43692
+ var TrainingSplitPlanSchema = object({
43693
+ holdoutCameras: array(number().int()).readonly(),
43694
+ /** Used when no camera is held out: the last N days of every camera. */
43695
+ holdoutLastDays: number().int().nonnegative(),
43696
+ /** Holdout subjects per class (camera holdout only; `null` = known only after the split). */
43697
+ holdoutSupport: record(string(), number().int()).nullable(),
43698
+ trainSubjects: number().int()
43699
+ });
43700
+ var TrainingRefusalReasonSchema = _enum([
43701
+ "unknown-dataset",
43702
+ "unknown-provider",
43703
+ "provider-not-configured",
43704
+ "unknown-base-model",
43705
+ "unknown-gpu",
43706
+ "dataset-too-large",
43707
+ "no-training-subjects",
43708
+ "job-already-running"
43709
+ ]);
43710
+ var TrainingJobPlanSchema = object({
43711
+ refusal: object({
43712
+ reason: TrainingRefusalReasonSchema,
43713
+ detail: string()
43714
+ }).nullable(),
43715
+ warnings: array(string()).readonly(),
43716
+ split: TrainingSplitPlanSchema.nullable(),
43717
+ estimate: object({
43718
+ datasetBytes: number().int(),
43719
+ uploadMinutesAt20Mbps: number(),
43720
+ gpuSecondsLow: number(),
43721
+ gpuSecondsHigh: number(),
43722
+ usdLow: number(),
43723
+ usdHigh: number(),
43724
+ notes: array(string()).readonly()
43725
+ }).nullable(),
43726
+ /** Pre-filled from the provider's settings; the operator may lower or raise them. */
43727
+ defaults: object({
43728
+ maxCostUsd: number(),
43729
+ maxRuntimeSec: number().int()
43730
+ }).nullable(),
43731
+ /** The sentence the confirm dialog repeats: where the frames go and when they are deleted. */
43732
+ dataNotice: string()
43733
+ });
43734
+ /**
43735
+ * Orchestrator-owned states, persisted. `uploading` covers exporting the
43736
+ * archive (it is streamed, never staged). Terminal: `failed`, `cancelled`,
43737
+ * `lost`, `expired`, `discarded`. `registered` and `canary` are where a
43738
+ * result lives after the operator acted on it.
43739
+ */
43740
+ var TrainingJobStateSchema = _enum([
43741
+ "uploading",
43742
+ "submitted",
43743
+ "starting",
43744
+ "running",
43745
+ "collecting",
43746
+ "ready",
43747
+ "registered",
43748
+ "canary",
43749
+ "failed",
43750
+ "cancelling",
43751
+ "cancelled",
43752
+ "lost",
43753
+ "expired",
43754
+ "discarded"
43755
+ ]);
43756
+ var TrainingFailureReasonSchema = _enum([
43757
+ "cost-cap",
43758
+ "runtime-cap",
43759
+ "upload-failed",
43760
+ "submit-failed",
43761
+ "trainer-failed",
43762
+ "result-invalid",
43763
+ "checksum-mismatch",
43764
+ "fetch-failed",
43765
+ "provider-error",
43766
+ "hub-restart-during-upload"
43767
+ ]);
43768
+ var TrainingProgressPointSchema = object({
43769
+ epoch: number().int(),
43770
+ map50: number().nullable(),
43771
+ map50_95: number().nullable()
43772
+ });
43773
+ var TrainingCanarySchema = object({
43774
+ deviceIds: array(number().int()).readonly(),
43775
+ since: number(),
43776
+ /** Every override the canary replaced, exactly, so rollback restores it. */
43777
+ previous: array(object({
43778
+ deviceId: number().int(),
43779
+ nodeId: string(),
43780
+ deviceKey: string(),
43781
+ patch: object({
43782
+ modelId: string().optional(),
43783
+ settings: record(string(), unknown()).readonly().optional()
43784
+ }).nullable()
43785
+ })).readonly()
43786
+ });
43787
+ var TrainingJobSchema = object({
43788
+ id: string(),
43789
+ idempotencyKey: string(),
43790
+ name: string(),
43791
+ createdAt: number(),
43792
+ updatedAt: number(),
43793
+ state: TrainingJobStateSchema,
43794
+ stage: TrainingStageSchema.nullable(),
43795
+ failure: object({
43796
+ reason: TrainingFailureReasonSchema,
43797
+ stage: string().nullable(),
43798
+ detail: string()
43799
+ }).nullable(),
43800
+ request: TrainingJobRequestSchema,
43801
+ maxCostUsd: number().nonnegative(),
43802
+ maxRuntimeSec: number().int().positive(),
43803
+ trainer: TrainerSourceRefSchema,
43804
+ datasetLayout: RetrainExportLayoutSchema,
43805
+ dataset: object({
43806
+ bytes: number().int(),
43807
+ sha256: string(),
43808
+ uploadedAt: number()
43809
+ }).nullable(),
43810
+ split: TrainingSplitPlanSchema,
43811
+ provider: object({
43812
+ state: ProviderJobStateSchema.nullable(),
43813
+ providerJobId: string().nullable(),
43814
+ startedAt: number().nullable(),
43815
+ endedAt: number().nullable(),
43816
+ billedSeconds: number(),
43817
+ costUsd: number(),
43818
+ costIsEstimate: boolean(),
43819
+ lastPolledAt: number().nullable()
43820
+ }),
43821
+ progress: object({
43822
+ epoch: number().int().nullable(),
43823
+ epochs: number().int().nullable(),
43824
+ etaSec: number().nullable(),
43825
+ series: array(TrainingProgressPointSchema).readonly()
43826
+ }),
43827
+ /** The last lines of the job's output (≤ 200), newest last. Never frame paths. */
43828
+ logTail: array(string()).readonly(),
43829
+ logCursor: string().nullable(),
43830
+ artifacts: object({
43831
+ bundleBytes: number().int(),
43832
+ bundleSha256: string(),
43833
+ fetchedAt: number(),
43834
+ /** When the staged artefacts are deleted from the hub. */
43835
+ expiresAt: number()
43836
+ }).nullable(),
43837
+ /** When the provider-side copy of the frames was deleted; null while it exists. */
43838
+ cloudDatasetDeletedAt: number().nullable(),
43839
+ /** A failed job's dataset is kept until then (the provider's grace), then deleted. */
43840
+ cloudCleanupDueAt: number().nullable(),
43841
+ /** Model ids registered from this job (base, and int8 when kept). */
43842
+ registeredModelIds: array(string()).readonly(),
43843
+ canary: TrainingCanarySchema.nullable()
43844
+ });
43845
+ var IdInput = object({ id: string().min(1) });
43846
+ method(TrainingDatasetVersionRowSchema, object({ stored: boolean() }), {
43847
+ kind: "mutation",
43848
+ auth: "admin"
43849
+ }), 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() }), {
43850
+ kind: "mutation",
43851
+ auth: "admin"
43852
+ }), method(object({}), array(TrainingBaseModelSchema).readonly(), { auth: "admin" }), method(TrainingJobRequestSchema, TrainingJobPlanSchema, {
43853
+ auth: "admin",
43854
+ timeoutMs: 6e4
43855
+ }), method(TrainingJobRequestSchema.extend({
43856
+ name: string().min(1).max(120),
43857
+ maxCostUsd: number().positive(),
43858
+ maxRuntimeSec: number().int().positive(),
43859
+ idempotencyKey: string().min(8).max(80)
43860
+ }), discriminatedUnion("kind", [object({
43861
+ kind: literal("started"),
43862
+ job: TrainingJobSchema
43863
+ }), object({
43864
+ kind: literal("refused"),
43865
+ reason: TrainingRefusalReasonSchema,
43866
+ detail: string()
43867
+ })]), {
43868
+ kind: "mutation",
43869
+ auth: "admin",
43870
+ timeoutMs: 12e4
43871
+ }), method(object({}), array(TrainingJobSchema).readonly(), { auth: "admin" }), method(IdInput, TrainingJobSchema.nullable(), { auth: "admin" }), method(IdInput, TrainingJobSchema, {
43872
+ kind: "mutation",
43873
+ auth: "admin",
43874
+ timeoutMs: 12e4
43875
+ }), method(IdInput, TrainingResultSchema.nullable(), { auth: "admin" }), method(IdInput.extend({ canaryDeviceIds: array(number().int()).readonly() }), TrainingJobSchema, {
43876
+ kind: "mutation",
43877
+ auth: "admin",
43878
+ timeoutMs: 30 * 6e4
43879
+ }), method(IdInput.extend({ deviceIds: array(number().int()).min(1).readonly() }), TrainingJobSchema, {
43880
+ kind: "mutation",
43881
+ auth: "admin",
43882
+ timeoutMs: 12e4
43883
+ }), method(IdInput, TrainingJobSchema, {
43884
+ kind: "mutation",
43885
+ auth: "admin",
43886
+ timeoutMs: 12e4
43887
+ }), method(IdInput, TrainingJobSchema, {
43888
+ kind: "mutation",
43889
+ auth: "admin"
43890
+ });
42490
43891
  SOURCE_CAPS.filter((cap) => cap !== "switch" && cap !== "motion");
42491
43892
  Object.freeze({
42492
43893
  person: .5,
@@ -44635,6 +46036,12 @@ Object.freeze({
44635
46036
  addonId: null,
44636
46037
  access: "create"
44637
46038
  },
46039
+ "backup.checkBackupKey": {
46040
+ capName: "backup",
46041
+ capScope: "system",
46042
+ addonId: null,
46043
+ access: "create"
46044
+ },
44638
46045
  "backup.delete": {
44639
46046
  capName: "backup",
44640
46047
  capScope: "system",
@@ -44647,6 +46054,18 @@ Object.freeze({
44647
46054
  addonId: null,
44648
46055
  access: "delete"
44649
46056
  },
46057
+ "backup.disableEncryption": {
46058
+ capName: "backup",
46059
+ capScope: "system",
46060
+ addonId: null,
46061
+ access: "create"
46062
+ },
46063
+ "backup.getEncryption": {
46064
+ capName: "backup",
46065
+ capScope: "system",
46066
+ addonId: null,
46067
+ access: "view"
46068
+ },
44650
46069
  "backup.getEntries": {
44651
46070
  capName: "backup",
44652
46071
  capScope: "system",
@@ -44701,6 +46120,12 @@ Object.freeze({
44701
46120
  addonId: null,
44702
46121
  access: "create"
44703
46122
  },
46123
+ "backup.setupEncryption": {
46124
+ capName: "backup",
46125
+ capScope: "system",
46126
+ addonId: null,
46127
+ access: "create"
46128
+ },
44704
46129
  "backup.trigger": {
44705
46130
  capName: "backup",
44706
46131
  capScope: "system",
@@ -45253,6 +46678,12 @@ Object.freeze({
45253
46678
  addonId: null,
45254
46679
  access: "create"
45255
46680
  },
46681
+ "customModelRegistry.importModelBundle": {
46682
+ capName: "custom-model-registry",
46683
+ capScope: "system",
46684
+ addonId: null,
46685
+ access: "create"
46686
+ },
45256
46687
  "customModelRegistry.listModels": {
45257
46688
  capName: "custom-model-registry",
45258
46689
  capScope: "system",
@@ -46693,6 +48124,12 @@ Object.freeze({
46693
48124
  addonId: null,
46694
48125
  access: "view"
46695
48126
  },
48127
+ "keychainAdmin.acknowledgeReset": {
48128
+ capName: "keychain-admin",
48129
+ capScope: "system",
48130
+ addonId: null,
48131
+ access: "create"
48132
+ },
46696
48133
  "keychainAdmin.deleteOrphans": {
46697
48134
  capName: "keychain-admin",
46698
48135
  capScope: "system",
@@ -46729,6 +48166,12 @@ Object.freeze({
46729
48166
  addonId: null,
46730
48167
  access: "delete"
46731
48168
  },
48169
+ "keychainAdmin.resetReport": {
48170
+ capName: "keychain-admin",
48171
+ capScope: "system",
48172
+ addonId: null,
48173
+ access: "delete"
48174
+ },
46732
48175
  "keychainAdmin.reveal": {
46733
48176
  capName: "keychain-admin",
46734
48177
  capScope: "system",
@@ -46741,6 +48184,12 @@ Object.freeze({
46741
48184
  addonId: null,
46742
48185
  access: "create"
46743
48186
  },
48187
+ "keychainAdmin.setSystemSecret": {
48188
+ capName: "keychain-admin",
48189
+ capScope: "system",
48190
+ addonId: null,
48191
+ access: "create"
48192
+ },
46744
48193
  "keychainAdmin.status": {
46745
48194
  capName: "keychain-admin",
46746
48195
  capScope: "system",
@@ -48187,6 +49636,12 @@ Object.freeze({
48187
49636
  addonId: null,
48188
49637
  access: "create"
48189
49638
  },
49639
+ "pipelineAnalytics.createRetrainDatasetVersion": {
49640
+ capName: "pipeline-analytics",
49641
+ capScope: "device",
49642
+ addonId: null,
49643
+ access: "create"
49644
+ },
48190
49645
  "pipelineAnalytics.deleteDeviceEvents": {
48191
49646
  capName: "pipeline-analytics",
48192
49647
  capScope: "device",
@@ -48199,6 +49654,12 @@ Object.freeze({
48199
49654
  addonId: null,
48200
49655
  access: "delete"
48201
49656
  },
49657
+ "pipelineAnalytics.deleteRetrainDatasetVersion": {
49658
+ capName: "pipeline-analytics",
49659
+ capScope: "device",
49660
+ addonId: null,
49661
+ access: "delete"
49662
+ },
48202
49663
  "pipelineAnalytics.deleteTracks": {
48203
49664
  capName: "pipeline-analytics",
48204
49665
  capScope: "device",
@@ -48421,6 +49882,12 @@ Object.freeze({
48421
49882
  addonId: null,
48422
49883
  access: "view"
48423
49884
  },
49885
+ "pipelineAnalytics.listRetrainDatasetVersions": {
49886
+ capName: "pipeline-analytics",
49887
+ capScope: "device",
49888
+ addonId: null,
49889
+ access: "view"
49890
+ },
48424
49891
  "pipelineAnalytics.listRetrainFrames": {
48425
49892
  capName: "pipeline-analytics",
48426
49893
  capScope: "device",
@@ -48451,6 +49918,12 @@ Object.freeze({
48451
49918
  addonId: null,
48452
49919
  access: "view"
48453
49920
  },
49921
+ "pipelineAnalytics.offerRetrainArchive": {
49922
+ capName: "pipeline-analytics",
49923
+ capScope: "device",
49924
+ addonId: null,
49925
+ access: "create"
49926
+ },
48454
49927
  "pipelineAnalytics.ownersWithMedia": {
48455
49928
  capName: "pipeline-analytics",
48456
49929
  capScope: "device",
@@ -48463,6 +49936,12 @@ Object.freeze({
48463
49936
  addonId: null,
48464
49937
  access: "create"
48465
49938
  },
49939
+ "pipelineAnalytics.previewRetrainDataset": {
49940
+ capName: "pipeline-analytics",
49941
+ capScope: "device",
49942
+ addonId: null,
49943
+ access: "view"
49944
+ },
48466
49945
  "pipelineAnalytics.proposeRetrainAnnotations": {
48467
49946
  capName: "pipeline-analytics",
48468
49947
  capScope: "device",
@@ -48601,6 +50080,12 @@ Object.freeze({
48601
50080
  addonId: null,
48602
50081
  access: "create"
48603
50082
  },
50083
+ "pipelineAnalytics.verifyRetrainDatasetVersion": {
50084
+ capName: "pipeline-analytics",
50085
+ capScope: "device",
50086
+ addonId: null,
50087
+ access: "view"
50088
+ },
48604
50089
  "pipelineAnalytics.wipeAllAnalytics": {
48605
50090
  capName: "pipeline-analytics",
48606
50091
  capScope: "device",
@@ -50977,6 +52462,174 @@ Object.freeze({
50977
52462
  addonId: null,
50978
52463
  access: "view"
50979
52464
  },
52465
+ "training.canaryResult": {
52466
+ capName: "training",
52467
+ capScope: "system",
52468
+ addonId: null,
52469
+ access: "create"
52470
+ },
52471
+ "training.cancelJob": {
52472
+ capName: "training",
52473
+ capScope: "system",
52474
+ addonId: null,
52475
+ access: "create"
52476
+ },
52477
+ "training.discardResult": {
52478
+ capName: "training",
52479
+ capScope: "system",
52480
+ addonId: null,
52481
+ access: "create"
52482
+ },
52483
+ "training.findDatasetVersionIdByName": {
52484
+ capName: "training",
52485
+ capScope: "system",
52486
+ addonId: null,
52487
+ access: "view"
52488
+ },
52489
+ "training.getDatasetVersion": {
52490
+ capName: "training",
52491
+ capScope: "system",
52492
+ addonId: null,
52493
+ access: "view"
52494
+ },
52495
+ "training.getJob": {
52496
+ capName: "training",
52497
+ capScope: "system",
52498
+ addonId: null,
52499
+ access: "view"
52500
+ },
52501
+ "training.getJobResult": {
52502
+ capName: "training",
52503
+ capScope: "system",
52504
+ addonId: null,
52505
+ access: "view"
52506
+ },
52507
+ "training.listBaseModels": {
52508
+ capName: "training",
52509
+ capScope: "system",
52510
+ addonId: null,
52511
+ access: "view"
52512
+ },
52513
+ "training.listDatasetVersions": {
52514
+ capName: "training",
52515
+ capScope: "system",
52516
+ addonId: null,
52517
+ access: "view"
52518
+ },
52519
+ "training.listJobs": {
52520
+ capName: "training",
52521
+ capScope: "system",
52522
+ addonId: null,
52523
+ access: "view"
52524
+ },
52525
+ "training.planJob": {
52526
+ capName: "training",
52527
+ capScope: "system",
52528
+ addonId: null,
52529
+ access: "view"
52530
+ },
52531
+ "training.putDatasetVersion": {
52532
+ capName: "training",
52533
+ capScope: "system",
52534
+ addonId: null,
52535
+ access: "create"
52536
+ },
52537
+ "training.registerResult": {
52538
+ capName: "training",
52539
+ capScope: "system",
52540
+ addonId: null,
52541
+ access: "create"
52542
+ },
52543
+ "training.removeDatasetVersion": {
52544
+ capName: "training",
52545
+ capScope: "system",
52546
+ addonId: null,
52547
+ access: "delete"
52548
+ },
52549
+ "training.rollbackCanary": {
52550
+ capName: "training",
52551
+ capScope: "system",
52552
+ addonId: null,
52553
+ access: "create"
52554
+ },
52555
+ "training.startJob": {
52556
+ capName: "training",
52557
+ capScope: "system",
52558
+ addonId: null,
52559
+ access: "create"
52560
+ },
52561
+ "trainingProvider.cancelJob": {
52562
+ capName: "training-provider",
52563
+ capScope: "system",
52564
+ addonId: null,
52565
+ access: "create"
52566
+ },
52567
+ "trainingProvider.cleanupJob": {
52568
+ capName: "training-provider",
52569
+ capScope: "system",
52570
+ addonId: null,
52571
+ access: "create"
52572
+ },
52573
+ "trainingProvider.describe": {
52574
+ capName: "training-provider",
52575
+ capScope: "system",
52576
+ addonId: null,
52577
+ access: "view"
52578
+ },
52579
+ "trainingProvider.estimateJob": {
52580
+ capName: "training-provider",
52581
+ capScope: "system",
52582
+ addonId: null,
52583
+ access: "view"
52584
+ },
52585
+ "trainingProvider.getJob": {
52586
+ capName: "training-provider",
52587
+ capScope: "system",
52588
+ addonId: null,
52589
+ access: "view"
52590
+ },
52591
+ "trainingProvider.listJobEvents": {
52592
+ capName: "training-provider",
52593
+ capScope: "system",
52594
+ addonId: null,
52595
+ access: "view"
52596
+ },
52597
+ "trainingProvider.listJobs": {
52598
+ capName: "training-provider",
52599
+ capScope: "system",
52600
+ addonId: null,
52601
+ access: "view"
52602
+ },
52603
+ "trainingProvider.offerArtifact": {
52604
+ capName: "training-provider",
52605
+ capScope: "system",
52606
+ addonId: null,
52607
+ access: "create"
52608
+ },
52609
+ "trainingProvider.readResult": {
52610
+ capName: "training-provider",
52611
+ capScope: "system",
52612
+ addonId: null,
52613
+ access: "create"
52614
+ },
52615
+ "trainingProvider.submitJob": {
52616
+ capName: "training-provider",
52617
+ capScope: "system",
52618
+ addonId: null,
52619
+ access: "create"
52620
+ },
52621
+ "trainingProvider.uploadDataset": {
52622
+ capName: "training-provider",
52623
+ capScope: "system",
52624
+ addonId: null,
52625
+ access: "create"
52626
+ },
52627
+ "trainingProvider.validateCredentials": {
52628
+ capName: "training-provider",
52629
+ capScope: "system",
52630
+ addonId: null,
52631
+ access: "create"
52632
+ },
50980
52633
  "turnProvider.getTurnServers": {
50981
52634
  capName: "turn-provider",
50982
52635
  capScope: "system",
@@ -51001,12 +52654,6 @@ Object.freeze({
51001
52654
  addonId: null,
51002
52655
  access: "create"
51003
52656
  },
51004
- "userManagement.createApiKey": {
51005
- capName: "user-management",
51006
- capScope: "system",
51007
- addonId: null,
51008
- access: "create"
51009
- },
51010
52657
  "userManagement.createScopedToken": {
51011
52658
  capName: "user-management",
51012
52659
  capScope: "system",
@@ -51043,12 +52690,6 @@ Object.freeze({
51043
52690
  addonId: null,
51044
52691
  access: "view"
51045
52692
  },
51046
- "userManagement.linkExternalIdentity": {
51047
- capName: "user-management",
51048
- capScope: "system",
51049
- addonId: null,
51050
- access: "create"
51051
- },
51052
52693
  "userManagement.listApiKeys": {
51053
52694
  capName: "user-management",
51054
52695
  capScope: "system",
@@ -51151,12 +52792,6 @@ Object.freeze({
51151
52792
  addonId: null,
51152
52793
  access: "create"
51153
52794
  },
51154
- "userManagement.validateApiKey": {
51155
- capName: "user-management",
51156
- capScope: "system",
51157
- addonId: null,
51158
- access: "view"
51159
- },
51160
52795
  "userManagement.validateCredentials": {
51161
52796
  capName: "user-management",
51162
52797
  capScope: "system",
@@ -55476,6 +57111,11 @@ Object.freeze({
55476
57111
  form: "single",
55477
57112
  optional: false
55478
57113
  }],
57114
+ "training.canaryResult": [{
57115
+ name: "deviceIds",
57116
+ form: "array",
57117
+ optional: false
57118
+ }],
55479
57119
  "update.getStatus": [{
55480
57120
  name: "deviceId",
55481
57121
  form: "single",