@camstack/addon-pipeline-orchestrator 1.2.298 → 1.2.299

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.
package/dist/index.mjs CHANGED
@@ -5380,7 +5380,7 @@ var ZodIssueCode = {
5380
5380
  var ZodFirstPartyTypeKind;
5381
5381
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
5382
5382
  //#endregion
5383
- //#region ../types/dist/sleep-Cr5YOk3m.mjs
5383
+ //#region ../types/dist/sleep-r3RWkGVx.mjs
5384
5384
  /**
5385
5385
  * The audio chunk plane's byte format, and the ONE expansion from a coded
5386
5386
  * window to float samples (D455).
@@ -5497,7 +5497,7 @@ function isKeychainStoredField(field) {
5497
5497
  var SECRET_CLEAR = { $secretClear: true };
5498
5498
  /** The `'***'` token D634 redaction writes for non-admins. */
5499
5499
  var LEGACY_DEVICE_REDACTION = "***";
5500
- function isRecord$1(value) {
5500
+ function isRecord$2(value) {
5501
5501
  return typeof value === "object" && value !== null && !Array.isArray(value);
5502
5502
  }
5503
5503
  function makeSecretMarker(ref) {
@@ -5508,12 +5508,12 @@ function makeSecretMarker(ref) {
5508
5508
  }
5509
5509
  /** A stored marker: an object whose `$secret` is a non-empty string. */
5510
5510
  function isSecretMarker(value) {
5511
- if (!isRecord$1(value)) return false;
5511
+ if (!isRecord$2(value)) return false;
5512
5512
  const ref = value["$secret"];
5513
5513
  return typeof ref === "string" && ref.length > 0;
5514
5514
  }
5515
5515
  function isSecretClear(value) {
5516
- return isRecord$1(value) && value["$secretClear"] === true;
5516
+ return isRecord$2(value) && value["$secretClear"] === true;
5517
5517
  }
5518
5518
  /**
5519
5519
  * The UI view of a stored secret field value: a marker becomes "set", inline
@@ -6045,6 +6045,13 @@ function globalSecretScope() {
6045
6045
  function encodeSegment(value) {
6046
6046
  return encodeURIComponent(value);
6047
6047
  }
6048
+ function decodeSegment(value) {
6049
+ try {
6050
+ return decodeURIComponent(value);
6051
+ } catch {
6052
+ return null;
6053
+ }
6054
+ }
6048
6055
  /**
6049
6056
  * The field path of a value inside an array item, addressed by the item's id:
6050
6057
  * `arrayItemFieldPath('providers', 'authentik', 'clientSecret')` →
@@ -6053,6 +6060,75 @@ function encodeSegment(value) {
6053
6060
  function arrayItemFieldPath(arrayKey, itemId, fieldKey) {
6054
6061
  return `${arrayKey}[${encodeSegment(itemId)}].${fieldKey}`;
6055
6062
  }
6063
+ function parseScope(segments) {
6064
+ switch (segments[0]) {
6065
+ case "global": return {
6066
+ scope: GLOBAL_SCOPE,
6067
+ used: 1
6068
+ };
6069
+ case "node": {
6070
+ const nodeId = segments[1] !== void 0 ? decodeSegment(segments[1]) : null;
6071
+ return nodeId === null || nodeId.length === 0 ? null : {
6072
+ scope: {
6073
+ kind: "node",
6074
+ nodeId
6075
+ },
6076
+ used: 2
6077
+ };
6078
+ }
6079
+ case "device": {
6080
+ const raw = segments[1];
6081
+ if (raw === void 0 || !/^\d+$/.test(raw)) return null;
6082
+ return {
6083
+ scope: {
6084
+ kind: "device",
6085
+ deviceId: Number(raw)
6086
+ },
6087
+ used: 2
6088
+ };
6089
+ }
6090
+ case "integration": {
6091
+ const id = segments[1] !== void 0 ? decodeSegment(segments[1]) : null;
6092
+ return id === null || id.length === 0 ? null : {
6093
+ scope: {
6094
+ kind: "integration",
6095
+ integrationId: id
6096
+ },
6097
+ used: 2
6098
+ };
6099
+ }
6100
+ case "row": {
6101
+ const collection = segments[1] !== void 0 ? decodeSegment(segments[1]) : null;
6102
+ const rowId = segments[2] !== void 0 ? decodeSegment(segments[2]) : null;
6103
+ if (collection === null || rowId === null || collection.length === 0 || rowId.length === 0) return null;
6104
+ return {
6105
+ scope: {
6106
+ kind: "row",
6107
+ collection,
6108
+ rowId
6109
+ },
6110
+ used: 3
6111
+ };
6112
+ }
6113
+ default: return null;
6114
+ }
6115
+ }
6116
+ /** Take a ref apart; `null` when it is not a well-formed ref. */
6117
+ function parseSecretRef(ref) {
6118
+ if (!ref.startsWith("secret://")) return null;
6119
+ const segments = ref.slice(9).split("/");
6120
+ const owner = segments[0] !== void 0 ? decodeSegment(segments[0]) : null;
6121
+ if (owner === null || owner.length === 0) return null;
6122
+ const parsed = parseScope(segments.slice(1));
6123
+ if (parsed === null) return null;
6124
+ const fieldPath = segments.slice(1 + parsed.used).join("/");
6125
+ if (fieldPath.length === 0) return null;
6126
+ return {
6127
+ owner,
6128
+ scope: parsed.scope,
6129
+ fieldPath
6130
+ };
6131
+ }
6056
6132
  /** A write to a secret path could not be stored in the keychain, so it was refused. */
6057
6133
  var KeychainWriteRefusedError = class extends Error {
6058
6134
  fieldPath;
@@ -6063,7 +6139,7 @@ var KeychainWriteRefusedError = class extends Error {
6063
6139
  }
6064
6140
  };
6065
6141
  var KEEP = { kind: "keep" };
6066
- function isRecord(value) {
6142
+ function isRecord$1(value) {
6067
6143
  return typeof value === "object" && value !== null && !Array.isArray(value);
6068
6144
  }
6069
6145
  function defaultMintId() {
@@ -6076,7 +6152,7 @@ function collectSecretMarkerRefs(value, out = []) {
6076
6152
  return out;
6077
6153
  }
6078
6154
  if (Array.isArray(value)) for (const item of value) collectSecretMarkerRefs(item, out);
6079
- else if (isRecord(value)) for (const child of Object.values(value)) collectSecretMarkerRefs(child, out);
6155
+ else if (isRecord$1(value)) for (const child of Object.values(value)) collectSecretMarkerRefs(child, out);
6080
6156
  return out;
6081
6157
  }
6082
6158
  async function storedValueEquals(secrets, marker, candidate) {
@@ -6131,7 +6207,7 @@ function rowId$1(row, idKey) {
6131
6207
  return null;
6132
6208
  }
6133
6209
  async function writeArray(ctx, node, incoming, stored, fieldPath) {
6134
- const storedRows = Array.isArray(stored) ? stored.filter(isRecord) : [];
6210
+ const storedRows = Array.isArray(stored) ? stored.filter(isRecord$1) : [];
6135
6211
  if (!Array.isArray(incoming)) {
6136
6212
  ctx.deletes.push(...collectSecretMarkerRefs(storedRows));
6137
6213
  return {
@@ -6147,7 +6223,7 @@ async function writeArray(ctx, node, incoming, stored, fieldPath) {
6147
6223
  const kept = /* @__PURE__ */ new Set();
6148
6224
  const rows = [];
6149
6225
  for (const row of incoming) {
6150
- if (!isRecord(row)) {
6226
+ if (!isRecord$1(row)) {
6151
6227
  rows.push(row);
6152
6228
  continue;
6153
6229
  }
@@ -6172,7 +6248,7 @@ async function writeNode(ctx, node, incoming, stored, fieldPath) {
6172
6248
  case "leaf": return writeLeaf(ctx, incoming, stored, fieldPath);
6173
6249
  case "array": return writeArray(ctx, node, incoming, stored, fieldPath);
6174
6250
  case "object": {
6175
- if (!isRecord(incoming)) {
6251
+ if (!isRecord$1(incoming)) {
6176
6252
  if (incoming === void 0) return KEEP;
6177
6253
  ctx.deletes.push(...collectSecretMarkerRefs(stored));
6178
6254
  return {
@@ -6180,7 +6256,7 @@ async function writeNode(ctx, node, incoming, stored, fieldPath) {
6180
6256
  value: incoming
6181
6257
  };
6182
6258
  }
6183
- const storedObj = isRecord(stored) ? stored : {};
6259
+ const storedObj = isRecord$1(stored) ? stored : {};
6184
6260
  return {
6185
6261
  kind: "value",
6186
6262
  value: await writeMembers(ctx, node.children, incoming, storedObj, (m) => `${fieldPath}.${m}`)
@@ -6239,12 +6315,19 @@ async function transformSecretWrite(input) {
6239
6315
  }
6240
6316
  };
6241
6317
  }
6318
+ /** Is `ref` one of `owner`'s refs? */
6319
+ function isSecretRefOwnedBy(ref, owner) {
6320
+ return parseSecretRef(ref)?.owner === owner;
6321
+ }
6242
6322
  /**
6243
6323
  * Replace every marker in `value` with its keychain value. Returns the SAME
6244
6324
  * reference when there is no marker (no allocation, no keychain call).
6245
6325
  */
6246
- async function resolveSecretMarkers(value, secrets) {
6247
- const refs = collectSecretMarkerRefs(value);
6326
+ async function resolveSecretMarkers(value, secrets, options = {}) {
6327
+ const keepMarker = options.unresolved === "keep-marker";
6328
+ const owner = options.ownedBy;
6329
+ const inScope = (ref) => owner === void 0 || isSecretRefOwnedBy(ref, owner);
6330
+ const refs = collectSecretMarkerRefs(value).filter(inScope);
6248
6331
  if (refs.length === 0) return {
6249
6332
  value,
6250
6333
  unresolved: []
@@ -6268,10 +6351,18 @@ async function resolveSecretMarkers(value, secrets) {
6268
6351
  }
6269
6352
  const substitute = (v) => {
6270
6353
  if (isSecretMarker(v)) {
6354
+ if (!inScope(v.$secret)) return {
6355
+ keep: true,
6356
+ value: v
6357
+ };
6271
6358
  const answer = answers[v.$secret];
6272
- return answer?.kind === "value" ? {
6359
+ if (answer?.kind === "value") return {
6273
6360
  keep: true,
6274
6361
  value: answer.value
6362
+ };
6363
+ return keepMarker ? {
6364
+ keep: true,
6365
+ value: v
6275
6366
  } : {
6276
6367
  keep: false,
6277
6368
  value: void 0
@@ -6288,7 +6379,7 @@ async function resolveSecretMarkers(value, secrets) {
6288
6379
  value: items
6289
6380
  };
6290
6381
  }
6291
- if (isRecord(v)) {
6382
+ if (isRecord$1(v)) {
6292
6383
  const out = {};
6293
6384
  for (const [k, child] of Object.entries(v)) {
6294
6385
  const s = substitute(child);
@@ -6309,14 +6400,152 @@ async function resolveSecretMarkers(value, secrets) {
6309
6400
  unresolved
6310
6401
  };
6311
6402
  }
6312
- function touchesTree(tree, patch) {
6313
- if (tree.size === 0) return false;
6314
- for (const key of Object.keys(patch)) {
6315
- const at = key.indexOf("@");
6316
- if (tree.has(at > 0 ? key.slice(0, at) : key)) return true;
6403
+ /** An addon tried to replace a stored secret it could not read. Nothing was written. */
6404
+ var SecretOverwriteRefusedError = class extends Error {
6405
+ ref;
6406
+ reason;
6407
+ constructor(ref, reason) {
6408
+ 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.`);
6409
+ this.ref = ref;
6410
+ this.reason = reason;
6411
+ this.name = "SecretOverwriteRefusedError";
6412
+ }
6413
+ };
6414
+ function isRecord(value) {
6415
+ return typeof value === "object" && value !== null && !Array.isArray(value);
6416
+ }
6417
+ function resolvedValue(pass, marker) {
6418
+ const answer = pass.answers[marker.$secret];
6419
+ return answer?.kind === "value" ? answer.value : null;
6420
+ }
6421
+ async function atMarker(pass, incoming, stored) {
6422
+ if (incoming === null) return stored;
6423
+ if (typeof incoming !== "string") return incoming;
6424
+ if (incoming === resolvedValue(pass, stored)) return stored;
6425
+ const intent = classifySecretWrite(incoming);
6426
+ if (intent.kind !== "set") return stored;
6427
+ const ref = stored.$secret;
6428
+ if (!isSecretRefOwnedBy(ref, pass.secrets.owner)) return incoming;
6429
+ const answer = pass.answers[ref];
6430
+ 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);
6431
+ try {
6432
+ await pass.secrets.put(ref, intent.value);
6433
+ } catch (err) {
6434
+ throw new KeychainWriteRefusedError(ref, err);
6435
+ }
6436
+ pass.changedRefs.push(ref);
6437
+ return stored;
6438
+ }
6439
+ function inArray(pass, incoming, stored) {
6440
+ return incoming.map((item, index) => {
6441
+ const twin = stored[index];
6442
+ if (isSecretMarker(twin)) return typeof item === "string" && item === resolvedValue(pass, twin) ? twin : item;
6443
+ if (isRecord(item) && isRecord(twin)) return inArrayRow(pass, item, twin);
6444
+ if (Array.isArray(item) && Array.isArray(twin)) return inArray(pass, item, twin);
6445
+ return item;
6446
+ });
6447
+ }
6448
+ function inArrayRow(pass, incoming, stored) {
6449
+ const out = { ...incoming };
6450
+ for (const [key, value] of Object.entries(incoming)) {
6451
+ const twin = stored[key];
6452
+ if (isSecretMarker(twin)) {
6453
+ if (typeof value === "string" && value === resolvedValue(pass, twin)) out[key] = twin;
6454
+ } else if (isRecord(value) && isRecord(twin)) out[key] = inArrayRow(pass, value, twin);
6455
+ else if (Array.isArray(value) && Array.isArray(twin)) out[key] = inArray(pass, value, twin);
6456
+ }
6457
+ return out;
6458
+ }
6459
+ async function walk(pass, incoming, stored) {
6460
+ if (isSecretMarker(stored)) return atMarker(pass, incoming, stored);
6461
+ if (Array.isArray(incoming) && Array.isArray(stored)) return inArray(pass, incoming, stored);
6462
+ if (!isRecord(incoming) || !isRecord(stored)) return incoming;
6463
+ const out = { ...incoming };
6464
+ for (const [key, value] of Object.entries(incoming)) out[key] = await walk(pass, value, stored[key]);
6465
+ return out;
6466
+ }
6467
+ /** Restore markers a write-back carries as values. See the file doc. */
6468
+ async function restoreUnchangedSecrets(input) {
6469
+ const refs = [];
6470
+ for (const key of Object.keys(input.patch)) collectSecretMarkerRefs(input.stored[key], refs);
6471
+ const owned = refs.filter((ref) => isSecretRefOwnedBy(ref, input.secrets.owner));
6472
+ if (owned.length === 0) return {
6473
+ patch: input.patch,
6474
+ changedRefs: []
6475
+ };
6476
+ const pass = {
6477
+ secrets: input.secrets,
6478
+ answers: await input.secrets.resolve([...new Set(owned)]),
6479
+ operatorWrite: input.operatorWrite,
6480
+ changedRefs: []
6481
+ };
6482
+ const out = {};
6483
+ for (const [key, value] of Object.entries(input.patch)) out[key] = await walk(pass, value, input.stored[key]);
6484
+ return {
6485
+ patch: out,
6486
+ changedRefs: pass.changedRefs
6487
+ };
6488
+ }
6489
+ /** Structural equality over JSON-shaped values (key order does not matter). */
6490
+ function isJsonEqual(a, b) {
6491
+ if (Object.is(a, b)) return true;
6492
+ if (Array.isArray(a)) return Array.isArray(b) && a.length === b.length && a.every((v, i) => isJsonEqual(v, b[i]));
6493
+ if (isRecord(a) && isRecord(b)) {
6494
+ const keys = Object.keys(a);
6495
+ if (keys.length !== Object.keys(b).length) return false;
6496
+ return keys.every((k) => Object.prototype.hasOwnProperty.call(b, k) && isJsonEqual(a[k], b[k]));
6317
6497
  }
6318
6498
  return false;
6319
6499
  }
6500
+ /** The patch without the keys whose value already equals the stored one. */
6501
+ function dropUnchangedKeys(patch, stored) {
6502
+ const out = {};
6503
+ for (const [key, value] of Object.entries(patch)) {
6504
+ if (Object.prototype.hasOwnProperty.call(stored, key) && isJsonEqual(value, stored[key])) continue;
6505
+ out[key] = value;
6506
+ }
6507
+ return out;
6508
+ }
6509
+ /** The top-level keys of a blob that hold at least one of `owner`'s markers. */
6510
+ function markerKeysOf(blob, owner) {
6511
+ const keys = /* @__PURE__ */ new Set();
6512
+ for (const [key, value] of Object.entries(blob)) if (collectSecretMarkerRefs(value).some((ref) => isSecretRefOwnedBy(ref, owner))) keys.add(key);
6513
+ return keys;
6514
+ }
6515
+ function nodeFromStored(value, owner) {
6516
+ if (isSecretMarker(value)) return isSecretRefOwnedBy(value.$secret, owner) ? { kind: "leaf" } : null;
6517
+ if (!isRecord(value)) return null;
6518
+ const children = /* @__PURE__ */ new Map();
6519
+ for (const [key, child] of Object.entries(value)) {
6520
+ const node = nodeFromStored(child, owner);
6521
+ if (node !== null) children.set(key, node);
6522
+ }
6523
+ return children.size > 0 ? {
6524
+ kind: "object",
6525
+ children
6526
+ } : null;
6527
+ }
6528
+ /**
6529
+ * The declared secret tree, widened by every place the STORED blob holds a
6530
+ * marker under one of `keys` — so a marker the schema no longer declares (or
6531
+ * never declared: Wyze before b4906cec6) still gets the save path's
6532
+ * KEEP / SET / CLEAR semantics instead of being overwritten by whatever the
6533
+ * addon writes. Markers inside arrays are not added: a row has no id field to
6534
+ * match by unless the schema declares one. Only `owner`'s markers count: a
6535
+ * builtin that keeps another addon's marker (device-manager) never takes it
6536
+ * over.
6537
+ */
6538
+ function widenTreeWithStoredMarkers(declared, stored, keys, owner) {
6539
+ const added = /* @__PURE__ */ new Map();
6540
+ for (const key of keys) {
6541
+ const at = key.indexOf("@");
6542
+ const base = at > 0 ? key.slice(0, at) : key;
6543
+ if (declared.has(base) || added.has(base)) continue;
6544
+ const node = nodeFromStored(stored[key], owner);
6545
+ if (node !== null) added.set(base, node);
6546
+ }
6547
+ return added.size === 0 ? declared : new Map([...declared, ...added]);
6548
+ }
6320
6549
  /** The blob as stored now; a failed read REFUSES the write instead of guessing. */
6321
6550
  async function readStoredAddonBlob(raw) {
6322
6551
  const threeWay = raw.readAddonStoreResult;
@@ -6325,7 +6554,41 @@ async function readStoredAddonBlob(raw) {
6325
6554
  if (result.kind === "failed") throw new Error(`settings write refused: the stored blob could not be read (${result.error})`);
6326
6555
  return result.kind === "missing" ? {} : result.value;
6327
6556
  }
6328
- function createSecretAwareSettings(raw, opts) {
6557
+ function touchesTree(tree, patch) {
6558
+ if (tree.size === 0) return false;
6559
+ for (const key of Object.keys(patch)) {
6560
+ const at = key.indexOf("@");
6561
+ if (tree.has(at > 0 ? key.slice(0, at) : key)) return true;
6562
+ }
6563
+ return false;
6564
+ }
6565
+ /**
6566
+ * Which top-level keys of each store held markers when last seen. `undefined`
6567
+ * for a store not seen yet: its first write reads it, to be safe.
6568
+ */
6569
+ var MarkerKeyIndex = class {
6570
+ owner;
6571
+ byStore = /* @__PURE__ */ new Map();
6572
+ constructor(owner) {
6573
+ this.owner = owner;
6574
+ }
6575
+ seen(store, blob) {
6576
+ this.byStore.set(store, markerKeysOf(blob, this.owner));
6577
+ }
6578
+ wrote(store, patch) {
6579
+ const keys = this.byStore.get(store);
6580
+ if (keys === void 0) return;
6581
+ const now = markerKeysOf(patch, this.owner);
6582
+ for (const key of Object.keys(patch)) if (now.has(key)) keys.add(key);
6583
+ else keys.delete(key);
6584
+ }
6585
+ mayHoldMarkers(store, patch) {
6586
+ const keys = this.byStore.get(store);
6587
+ if (keys === void 0) return true;
6588
+ return Object.keys(patch).some((key) => keys.has(key));
6589
+ }
6590
+ };
6591
+ function createHandle(raw, opts) {
6329
6592
  const chains = /* @__PURE__ */ new Map();
6330
6593
  const serialize = (key, fn) => {
6331
6594
  const next = (chains.get(key) ?? Promise.resolve()).then(fn, fn);
@@ -6336,46 +6599,130 @@ function createSecretAwareSettings(raw, opts) {
6336
6599
  });
6337
6600
  return next;
6338
6601
  };
6339
- const write = async (chainKey, tree, scope, patch, readStored, rawWrite) => {
6340
- if (!touchesTree(tree, patch)) return rawWrite(patch);
6341
- return serialize(chainKey, async () => {
6602
+ const index = new MarkerKeyIndex(opts.secrets.owner);
6603
+ const resolveRead = async (store, blob) => {
6604
+ index.seen(store, blob);
6605
+ const { value, unresolved } = await resolveSecretMarkers(blob, opts.secrets, {
6606
+ unresolved: "keep-marker",
6607
+ ownedBy: opts.secrets.owner
6608
+ });
6609
+ if (unresolved.length > 0) opts.onUnresolved?.(unresolved);
6610
+ return value;
6611
+ };
6612
+ const write = async (store, declared, scope, patch, readStored, rawWrite) => {
6613
+ if (!touchesTree(declared, patch) && !index.mayHoldMarkers(store, patch)) {
6614
+ await rawWrite(patch);
6615
+ index.wrote(store, patch);
6616
+ return { changed: true };
6617
+ }
6618
+ return serialize(store, async () => {
6342
6619
  const stored = await readStored();
6620
+ index.seen(store, stored);
6621
+ const operatorWrite = opts.isOperatorWrite?.() === true;
6622
+ const restored = await restoreUnchangedSecrets({
6623
+ patch,
6624
+ stored,
6625
+ secrets: opts.secrets,
6626
+ operatorWrite
6627
+ });
6343
6628
  const result = await transformSecretWrite({
6344
- tree,
6629
+ tree: widenTreeWithStoredMarkers(declared, stored, Object.keys(restored.patch), opts.secrets.owner),
6345
6630
  secrets: opts.secrets,
6346
- patch,
6631
+ patch: restored.patch,
6347
6632
  stored,
6348
6633
  ...scope !== void 0 ? { scope } : {},
6349
- operatorWrite: opts.isOperatorWrite?.() === true
6634
+ operatorWrite
6350
6635
  });
6351
- if (Object.keys(result.patch).length > 0) await rawWrite(result.patch);
6636
+ const effective = dropUnchangedKeys(result.patch, stored);
6637
+ const wroteBlob = Object.keys(effective).length > 0;
6638
+ if (wroteBlob) {
6639
+ await rawWrite(effective);
6640
+ index.wrote(store, effective);
6641
+ }
6352
6642
  const { orphaned } = await result.afterWrite();
6353
6643
  if (orphaned.length > 0) opts.onOrphaned(orphaned);
6644
+ return { changed: wroteBlob || restored.changedRefs.length > 0 };
6354
6645
  });
6355
6646
  };
6356
- const wrapped = {
6357
- writeAddonStore: (patch) => write("addon", opts.addonTree(), void 0, patch, () => readStoredAddonBlob(raw), (p) => raw.writeAddonStore(p)),
6358
- writeDeviceStore: (deviceId, patch) => write(`device:${deviceId}`, opts.deviceTree(), {
6359
- kind: "device",
6360
- deviceId
6361
- }, patch, () => raw.readDeviceStore(deviceId), (p) => raw.writeDeviceStore(deviceId, p))
6647
+ const writeAddon = (patch) => write("addon", opts.addonTree(), void 0, patch, () => readStoredAddonBlob(raw), (p) => raw.writeAddonStore(p));
6648
+ const readAddonStoreResult = raw.readAddonStoreResult;
6649
+ const readAddonStoreKeyResult = raw.readAddonStoreKeyResult;
6650
+ const readDeviceStoreBatch = raw.readDeviceStoreBatch;
6651
+ const overrides = {
6652
+ readAddonStore: async () => resolveRead("addon", await raw.readAddonStore()),
6653
+ ...readAddonStoreResult !== void 0 ? { readAddonStoreResult: async () => {
6654
+ const result = await readAddonStoreResult.call(raw);
6655
+ return result.kind === "value" ? {
6656
+ kind: "value",
6657
+ value: await resolveRead("addon", result.value)
6658
+ } : result;
6659
+ } } : {},
6660
+ ...readAddonStoreKeyResult !== void 0 ? { readAddonStoreKeyResult: async (key) => {
6661
+ const result = await readAddonStoreKeyResult.call(raw, key);
6662
+ if (result.kind !== "present") return result;
6663
+ const { value, unresolved } = await resolveSecretMarkers({ [key]: result.value }, opts.secrets, {
6664
+ unresolved: "keep-marker",
6665
+ ownedBy: opts.secrets.owner
6666
+ });
6667
+ if (unresolved.length > 0) opts.onUnresolved?.(unresolved);
6668
+ return {
6669
+ kind: "present",
6670
+ value: value[key]
6671
+ };
6672
+ } } : {},
6673
+ readDeviceStore: async (deviceId) => resolveRead(`device:${deviceId}`, await raw.readDeviceStore(deviceId)),
6674
+ ...readDeviceStoreBatch !== void 0 ? { readDeviceStoreBatch: async (deviceIds) => {
6675
+ const rows = await readDeviceStoreBatch.call(raw, deviceIds);
6676
+ const out = /* @__PURE__ */ new Map();
6677
+ for (const [deviceId, blob] of rows) out.set(deviceId, await resolveRead(`device:${deviceId}`, blob));
6678
+ return out;
6679
+ } } : {},
6680
+ writeAddonStore: async (patch) => {
6681
+ await writeAddon(patch);
6682
+ },
6683
+ writeDeviceStore: async (deviceId, patch) => {
6684
+ await write(`device:${deviceId}`, opts.deviceTree(), {
6685
+ kind: "device",
6686
+ deviceId
6687
+ }, patch, () => raw.readDeviceStore(deviceId), (p) => raw.writeDeviceStore(deviceId, p));
6688
+ }
6689
+ };
6690
+ return {
6691
+ settings: new Proxy(raw, { get(target, prop, receiver) {
6692
+ if (typeof prop === "string" && Object.prototype.hasOwnProperty.call(overrides, prop)) return Reflect.get(overrides, prop);
6693
+ const value = Reflect.get(target, prop, receiver);
6694
+ return typeof value === "function" ? value.bind(target) : value;
6695
+ } }),
6696
+ raw: {
6697
+ readAddonStore: async () => {
6698
+ const blob = await raw.readAddonStore();
6699
+ index.seen("addon", blob);
6700
+ return blob;
6701
+ },
6702
+ readDeviceStore: async (deviceId) => {
6703
+ const blob = await raw.readDeviceStore(deviceId);
6704
+ index.seen(`device:${deviceId}`, blob);
6705
+ return blob;
6706
+ }
6707
+ },
6708
+ writeAddonStore: writeAddon
6362
6709
  };
6363
- return new Proxy(raw, { get(target, prop, receiver) {
6364
- if (prop === "writeAddonStore") return wrapped.writeAddonStore;
6365
- if (prop === "writeDeviceStore") return wrapped.writeDeviceStore;
6366
- const value = Reflect.get(target, prop, receiver);
6367
- return typeof value === "function" ? value.bind(target) : value;
6368
- } });
6369
6710
  }
6370
- /** The context the addon sees: identical, except that its settings writes are secret-aware. */
6371
- function withSecretAwareSettings(context, opts) {
6711
+ /** The context the addon sees, plus the private raw view and write outcome. */
6712
+ function createSecretAwareContext(context, opts) {
6372
6713
  const raw = context.settings;
6373
- if (raw === void 0) return context;
6374
- const settings = createSecretAwareSettings(raw, opts);
6375
- return new Proxy(context, { get(target, prop, receiver) {
6376
- if (prop === "settings") return settings;
6377
- return Reflect.get(target, prop, receiver);
6378
- } });
6714
+ if (raw === void 0) return {
6715
+ context,
6716
+ handle: null
6717
+ };
6718
+ const handle = createHandle(raw, opts);
6719
+ return {
6720
+ context: new Proxy(context, { get(target, prop, receiver) {
6721
+ if (prop === "settings") return handle.settings;
6722
+ return Reflect.get(target, prop, receiver);
6723
+ } }),
6724
+ handle
6725
+ };
6379
6726
  }
6380
6727
  var LEAF = { kind: "leaf" };
6381
6728
  var DEFAULT_ITEM_ID_KEY = "id";
@@ -6550,6 +6897,14 @@ var BaseAddon = class {
6550
6897
  _secretChangeUnsub = null;
6551
6898
  /** >0 while an OPERATOR's settings write is being applied. */
6552
6899
  _operatorWriteDepth = 0;
6900
+ /**
6901
+ * The keychain-aware settings handle (D798). Its `raw` view is the ONLY way
6902
+ * to the marker-bearing blobs and stays private to this class: the form
6903
+ * hydrate and config resolution need markers, addon code never does.
6904
+ */
6905
+ _secretSettings = null;
6906
+ /** Refs an addon-facing read could not resolve — each is logged once per process. */
6907
+ _loggedUnresolvedReads = /* @__PURE__ */ new Set();
6553
6908
  constructor(defaults) {
6554
6909
  this.defaults = defaults;
6555
6910
  this._config = { ...defaults };
@@ -6586,13 +6941,21 @@ var BaseAddon = class {
6586
6941
  }
6587
6942
  async initialize(context) {
6588
6943
  const secrets = context.secrets;
6589
- this._ctx = secrets !== void 0 ? withSecretAwareSettings(context, {
6590
- secrets,
6591
- addonTree: () => this.addonSecretTree(),
6592
- deviceTree: () => this.deviceSecretTree(),
6593
- onOrphaned: (refs) => context.logger.warn("keychain refs dropped by a settings write could not be deleted", { meta: { refs: [...refs] } }),
6594
- isOperatorWrite: () => this._operatorWriteDepth > 0
6595
- }) : context;
6944
+ if (secrets !== void 0) {
6945
+ const { context: wrapped, handle } = createSecretAwareContext(context, {
6946
+ secrets,
6947
+ addonTree: () => this.addonSecretTree(),
6948
+ deviceTree: () => this.deviceSecretTree(),
6949
+ onOrphaned: (refs) => context.logger.warn("keychain refs dropped by a settings write could not be deleted", { meta: { refs: [...refs] } }),
6950
+ isOperatorWrite: () => this._operatorWriteDepth > 0,
6951
+ onUnresolved: (unresolved) => this.logUnresolvedRead(unresolved)
6952
+ });
6953
+ this._ctx = wrapped;
6954
+ this._secretSettings = handle;
6955
+ } else {
6956
+ this._ctx = context;
6957
+ this._secretSettings = null;
6958
+ }
6596
6959
  await this.resolveConfig();
6597
6960
  if (secrets !== void 0) this._secretChangeUnsub = secrets.onChange((ref) => {
6598
6961
  if (this._configSecretRefs.has(ref)) this.scheduleSecretReresolve(SECRET_CHANGE_DEBOUNCE_MS);
@@ -6709,11 +7072,8 @@ var BaseAddon = class {
6709
7072
  async getGlobalSettings(overlay, cap, nodeId) {
6710
7073
  const schema = this.globalSettingsSchema(cap);
6711
7074
  if (!schema) return { sections: [] };
6712
- const projected = await this.resolveGlobalStore(nodeId, cap);
6713
- return hydrateSchema(schema, overlay ? {
6714
- ...projected,
6715
- ...overlay
6716
- } : projected, { inlineSecretsAsViews: true });
7075
+ const projected = await this.readRawProjectedStore(nodeId, cap);
7076
+ return hydrateSchema(schema, overlay ? await this.overlayKeepingMarkers(projected, overlay) : projected, { inlineSecretsAsViews: true });
6717
7077
  }
6718
7078
  /**
6719
7079
  * The integration-level view of this addon's settings: exactly the sections
@@ -6758,7 +7118,7 @@ var BaseAddon = class {
6758
7118
  });
6759
7119
  }
6760
7120
  if (sections.length === 0) return null;
6761
- const projected = await this.resolveGlobalStore(nodeId);
7121
+ const projected = await this.readRawProjectedStore(nodeId);
6762
7122
  return hydrateSchema({
6763
7123
  ...schema,
6764
7124
  sections
@@ -6775,12 +7135,50 @@ var BaseAddon = class {
6775
7135
  * the store for custom option logic (option narrowing, value snapping) to
6776
7136
  * read it per-node — never `ctx.settings.readAddonStore()` directly.
6777
7137
  * `nodeId` omitted ⇒ the local node (node-blind injection from ctx).
7138
+ *
7139
+ * Keychain values come back RESOLVED (D798): a secret reads as its value,
7140
+ * never as a `{ $secret }` marker. One the keychain cannot serve right now
7141
+ * stays a marker — "stored, unavailable" (`isSecretMarker()` is true, and it
7142
+ * is listed in {@link unresolvedSecrets}) — never `''` and never absent, so
7143
+ * it cannot be mistaken for "nothing stored, mint a new one". Writing the
7144
+ * resolved blob back is a no-op for every unchanged secret.
6778
7145
  */
6779
7146
  async resolveGlobalStore(nodeId, cap) {
6780
7147
  const raw = await this._ctx?.settings?.readAddonStore() ?? {};
7148
+ return this.projectForNode(raw, nodeId, cap);
7149
+ }
7150
+ projectForNode(store, nodeId, cap) {
6781
7151
  const keys = this.perNodeKeys(cap);
6782
7152
  const node = normalizeNodeId(nodeId ?? this._ctx?.kernel?.localNodeId);
6783
- return keys.size > 0 ? projectStore(raw, keys, node) : raw;
7153
+ return keys.size > 0 ? projectStore(store, keys, node) : store;
7154
+ }
7155
+ /** The PROJECTED store with its markers — the form hydrate only (D798). */
7156
+ async readRawProjectedStore(nodeId, cap) {
7157
+ const raw = await this.rawSettings()?.readAddonStore() ?? {};
7158
+ return this.projectForNode(raw, nodeId, cap);
7159
+ }
7160
+ /**
7161
+ * `{ ...stored, ...overlay }`, except that an overlay member equal to the
7162
+ * RESOLVED stored one keeps the stored (marker-bearing) member — so a form
7163
+ * hydrated from a resolved overlay still shows a secret as "set", never as
7164
+ * its value.
7165
+ */
7166
+ async overlayKeepingMarkers(stored, overlay) {
7167
+ const secrets = this._ctx?.secrets;
7168
+ const merged = {
7169
+ ...stored,
7170
+ ...overlay
7171
+ };
7172
+ if (secrets === void 0 || collectSecretMarkerRefs(stored).length === 0) return merged;
7173
+ const { value: resolved } = await resolveSecretMarkers(stored, secrets, {
7174
+ unresolved: "keep-marker",
7175
+ ownedBy: secrets.owner
7176
+ });
7177
+ for (const key of Object.keys(overlay)) {
7178
+ if (collectSecretMarkerRefs(stored[key]).length === 0) continue;
7179
+ if (isJsonEqual(overlay[key], resolved[key])) merged[key] = stored[key];
7180
+ }
7181
+ return merged;
6784
7182
  }
6785
7183
  /**
6786
7184
  * Whether ONE global key of this addon's store was written, read three-way
@@ -6845,8 +7243,12 @@ var BaseAddon = class {
6845
7243
  async clearSecrets(keys, nodeId) {
6846
7244
  const tree = this.addonSecretTree();
6847
7245
  const keychain = this._ctx?.secrets !== void 0;
7246
+ const stored = keychain ? await this.readAddonStoreWithRetry() : {};
6848
7247
  const patch = {};
6849
- for (const key of keys) patch[key] = keychain && tree.has(key) ? SECRET_CLEAR : "";
7248
+ for (const key of keys) {
7249
+ const keychainStored = tree.has(key) || collectSecretMarkerRefs(stored[key]).length > 0;
7250
+ patch[key] = keychain && keychainStored ? SECRET_CLEAR : "";
7251
+ }
6850
7252
  await this.applyGlobalPatch(patch, nodeId);
6851
7253
  }
6852
7254
  async applyGlobalPatch(barePatch, nodeId) {
@@ -6854,7 +7256,11 @@ var BaseAddon = class {
6854
7256
  const localNode = normalizeNodeId(this._ctx?.kernel?.localNodeId);
6855
7257
  const target = normalizeNodeId(nodeId ?? this._ctx?.kernel?.localNodeId);
6856
7258
  const scoped = keys.size > 0 ? scopePatch(barePatch, keys, target) : barePatch;
6857
- await this._ctx?.settings?.writeAddonStore(scoped);
7259
+ const handle = this._secretSettings;
7260
+ if (handle !== null) {
7261
+ const { changed } = await handle.writeAddonStore(scoped);
7262
+ if (!changed) return;
7263
+ } else await this._ctx?.settings?.writeAddonStore(scoped);
6858
7264
  if (target !== localNode) return;
6859
7265
  await this.resolveConfig();
6860
7266
  await this.onConfigChanged();
@@ -6907,7 +7313,7 @@ var BaseAddon = class {
6907
7313
  async getDeviceSettings(deviceId) {
6908
7314
  const schema = this.deviceSettingsSchema();
6909
7315
  if (!schema) return { sections: [] };
6910
- return hydrateSchema(schema, await this._ctx?.settings?.readDeviceStore(deviceId) ?? {}, { inlineSecretsAsViews: true });
7316
+ return hydrateSchema(schema, await this.rawSettings()?.readDeviceStore(deviceId) ?? {}, { inlineSecretsAsViews: true });
6911
7317
  }
6912
7318
  async updateDeviceSettings(deviceId, patch) {
6913
7319
  await this._ctx?.settings?.writeDeviceStore(deviceId, patch);
@@ -7079,7 +7485,7 @@ var BaseAddon = class {
7079
7485
  key,
7080
7486
  schema,
7081
7487
  fallback,
7082
- read: async () => this.resolveStoredSecrets(await this._ctx?.settings?.readDeviceStore(deviceId) ?? {}, false),
7488
+ read: async () => this.resolveStoredSecrets(await this.rawSettings()?.readDeviceStore(deviceId) ?? {}, false),
7083
7489
  write: async (patch) => {
7084
7490
  await this._ctx?.settings?.writeDeviceStore(deviceId, patch);
7085
7491
  },
@@ -7141,6 +7547,23 @@ var BaseAddon = class {
7141
7547
  }
7142
7548
  return value;
7143
7549
  }
7550
+ /**
7551
+ * The marker-bearing settings reads (D798) — private on purpose. Without a
7552
+ * keychain the context's own view is already raw.
7553
+ */
7554
+ rawSettings() {
7555
+ return this._secretSettings?.raw ?? this._ctx?.settings;
7556
+ }
7557
+ /** An addon-facing read met markers it could not resolve: say so once per ref. */
7558
+ logUnresolvedRead(unresolved) {
7559
+ const fresh = unresolved.filter((u) => !this._loggedUnresolvedReads.has(u.ref));
7560
+ if (fresh.length === 0) return;
7561
+ for (const u of fresh) this._loggedUnresolvedReads.add(u.ref);
7562
+ 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) => ({
7563
+ ref: u.ref,
7564
+ reason: u.reason
7565
+ })) } });
7566
+ }
7144
7567
  /** Re-resolve the config (a keychain-only change, or a retry) and apply it. */
7145
7568
  scheduleSecretReresolve(delayMs) {
7146
7569
  const timerOf = delayMs === SECRET_CHANGE_DEBOUNCE_MS ? "_secretChangeTimer" : "_secretRetryTimer";
@@ -7167,7 +7590,7 @@ var BaseAddon = class {
7167
7590
  * `{}` (defaults) — the addon's first successful patch will rehydrate.
7168
7591
  */
7169
7592
  async readAddonStoreWithRetry() {
7170
- const settings = this._ctx?.settings;
7593
+ const settings = this.rawSettings();
7171
7594
  if (!settings) return {};
7172
7595
  const delaysMs = [
7173
7596
  150,
@@ -10426,6 +10849,278 @@ function composeSwitchedOff(input) {
10426
10849
  };
10427
10850
  }
10428
10851
  /**
10852
+ * The trainer contract — what the hub hands the cloud trainer and what it
10853
+ * gets back (cloud training, D805+).
10854
+ *
10855
+ * The trainer (`hf/camstack-trainer`, published as the Hugging Face repo
10856
+ * `camstack/camstack-trainer`) is a separate AGPL program the hub never
10857
+ * imports: `job.json` goes in, files come out, and progress is `CAMSTACK_EVENT`
10858
+ * lines on stdout. These schemas are the hub's half of that boundary; the
10859
+ * trainer's pydantic models (and the JSON Schemas generated from them under
10860
+ * `hf/camstack-trainer/schemas/`) are the other half. A change here is a
10861
+ * change there, in the same piece of work.
10862
+ *
10863
+ * No `.default()` anywhere: defaults do not run on the addon cap path, so the
10864
+ * orchestrator fills every field of a job spec explicitly.
10865
+ */
10866
+ var TRAINING_JOB_SCHEMA = "camstack.training/v1";
10867
+ var TRAINING_RESULT_SCHEMA = "camstack.training-result/v1";
10868
+ /** What the trainer can export. Edge TPU is a later, separate image. */
10869
+ var TrainingExportSchema = _enum([
10870
+ "onnx",
10871
+ "openvino-fp16",
10872
+ "openvino-int8",
10873
+ "coreml-fp16"
10874
+ ]);
10875
+ var FloorsSchema = record(string(), number().min(0).max(1));
10876
+ object({
10877
+ schema: literal(TRAINING_JOB_SCHEMA),
10878
+ jobKey: string().uuid(),
10879
+ target: object({
10880
+ kind: literal("detector"),
10881
+ step: literal("object-detection")
10882
+ }),
10883
+ base: object({
10884
+ modelId: string().min(1),
10885
+ /** Ultralytics weights id, e.g. `yolov9m.pt`. */
10886
+ weights: string().min(1),
10887
+ imgsz: number().int().positive()
10888
+ }),
10889
+ baseline: object({
10890
+ modelId: string().min(1),
10891
+ /** The baseline ONNX the holdout comparison runs; public mirror URL. */
10892
+ onnxUrl: string().url(),
10893
+ imgsz: number().int().positive(),
10894
+ floors: FloorsSchema
10895
+ }),
10896
+ dataset: object({
10897
+ versionId: string().min(1),
10898
+ annotationHash: string(),
10899
+ /** sha256 of the uploaded archive; the trainer refuses a mismatch (exit 65). */
10900
+ sha256: string().regex(/^[0-9a-f]{64}$/)
10901
+ }),
10902
+ split: object({
10903
+ holdoutCameras: array(number().int()),
10904
+ /** When no camera is held out: the last N days of every camera. */
10905
+ holdoutLastDays: number().int().nonnegative(),
10906
+ valFraction: number().min(0).max(.5),
10907
+ seed: number().int()
10908
+ }),
10909
+ hyper: object({
10910
+ epochs: number().int().positive(),
10911
+ batch: number().int().positive(),
10912
+ lr0: number().positive(),
10913
+ /** Layers frozen from the start of the backbone; 0 = none. */
10914
+ freeze: number().int().nonnegative(),
10915
+ patience: number().int().nonnegative(),
10916
+ seed: number().int()
10917
+ }),
10918
+ replay: object({
10919
+ source: literal("coco2017"),
10920
+ count: number().int().nonnegative()
10921
+ }),
10922
+ exports: array(TrainingExportSchema).min(1),
10923
+ calibration: object({ maxFrames: number().int().positive() }),
10924
+ floors: object({
10925
+ minSupport: number().int().positive(),
10926
+ clamp: number().min(0).max(1)
10927
+ }),
10928
+ int8Gate: object({ maxMap50Drop: number().min(0).max(1) }),
10929
+ catalog: object({
10930
+ id: string().regex(/^[a-z0-9][a-z0-9-]{2,80}$/),
10931
+ name: string().min(1).max(160)
10932
+ })
10933
+ });
10934
+ /** One regular file of the bundle. An mlpackage contributes one row per member. */
10935
+ var TrainingResultFileSchema = object({
10936
+ path: string().min(1),
10937
+ bytes: number().int().nonnegative(),
10938
+ sha256: string().regex(/^[0-9a-f]{64}$/),
10939
+ format: _enum([
10940
+ "onnx",
10941
+ "openvino",
10942
+ "coreml",
10943
+ "pt"
10944
+ ]),
10945
+ variant: _enum(["base", "int8"])
10946
+ });
10947
+ var DraftFormatSchema = object({
10948
+ /** RELATIVE path inside the bundle; the hub rewrites it to `camstack-local://`. */
10949
+ url: string().min(1),
10950
+ sizeMB: number().nonnegative(),
10951
+ isDirectory: boolean().optional(),
10952
+ files: array(string()).optional(),
10953
+ runtimes: array(literal("python")).optional(),
10954
+ revision: string().min(1)
10955
+ });
10956
+ /** The trainer's half of a catalog entry; the hub completes it (labels, licence, group). */
10957
+ var TrainingCatalogDraftSchema = object({
10958
+ id: string().min(1),
10959
+ name: string().min(1),
10960
+ description: string(),
10961
+ labels: array(unknown()),
10962
+ inputSize: object({
10963
+ width: number().int().positive(),
10964
+ height: number().int().positive()
10965
+ }),
10966
+ preprocessMode: literal("letterbox"),
10967
+ defaultClassFloors: FloorsSchema,
10968
+ formats: object({
10969
+ onnx: DraftFormatSchema.optional(),
10970
+ openvino: DraftFormatSchema.optional(),
10971
+ coreml: DraftFormatSchema.optional()
10972
+ })
10973
+ });
10974
+ /** One class of one model's holdout report (the eval harness's summary). */
10975
+ var TrainingEvalClassSchema = object({
10976
+ positives: number().int(),
10977
+ floor: number().nullable(),
10978
+ tp: number().int(),
10979
+ fp: number().int(),
10980
+ fn: number().int(),
10981
+ precision: number().nullable(),
10982
+ recall: number().nullable(),
10983
+ ap50: number().nullable(),
10984
+ recallByCamera: record(string(), number().nullable()).optional(),
10985
+ recallByLight: record(string(), number().nullable()).optional(),
10986
+ fpByCamera: record(string(), number()).optional(),
10987
+ smallFound: number().int().optional(),
10988
+ smallTotal: number().int().optional()
10989
+ }).passthrough();
10990
+ var TrainingEvalReportSchema = object({
10991
+ frames: number().int(),
10992
+ classes: record(string(), TrainingEvalClassSchema)
10993
+ }).passthrough();
10994
+ /**
10995
+ * A succeeded result carries every block; a failed one carries the error and
10996
+ * whatever was known by then — the other blocks are ABSENT, not null. The
10997
+ * orchestrator checks the blocks it needs before it trusts a success.
10998
+ */
10999
+ var TrainingResultSchema = object({
11000
+ schema: literal(TRAINING_RESULT_SCHEMA),
11001
+ jobKey: string(),
11002
+ status: _enum(["succeeded", "failed"]),
11003
+ error: object({
11004
+ stage: string(),
11005
+ code: string(),
11006
+ message: string()
11007
+ }).nullable(),
11008
+ trainer: object({
11009
+ version: string(),
11010
+ revision: string()
11011
+ }),
11012
+ toolchain: record(string(), string().nullable()),
11013
+ dataset: object({
11014
+ versionId: string(),
11015
+ annotationHash: string(),
11016
+ sha256: string(),
11017
+ frames: object({
11018
+ train: number().int(),
11019
+ val: number().int(),
11020
+ holdout: number().int()
11021
+ }),
11022
+ holdoutCameras: array(number().int()),
11023
+ replayImages: number().int()
11024
+ }).optional(),
11025
+ training: object({
11026
+ epochsRun: number().int(),
11027
+ bestEpoch: number().int(),
11028
+ bestMap50: number(),
11029
+ bestMap50_95: number(),
11030
+ seconds: number()
11031
+ }).optional(),
11032
+ evaluation: object({
11033
+ holdoutFrames: number().int(),
11034
+ baseline: TrainingEvalReportSchema.nullable(),
11035
+ candidate: TrainingEvalReportSchema.nullable(),
11036
+ candidateInt8: TrainingEvalReportSchema.nullable(),
11037
+ recallDeltaByCamera: record(string(), record(string(), number())).nullable(),
11038
+ map50: record(string(), number().nullable())
11039
+ }).optional(),
11040
+ floors: object({
11041
+ baseline: FloorsSchema,
11042
+ candidate: FloorsSchema,
11043
+ candidateInt8: FloorsSchema.nullable(),
11044
+ notes: array(string())
11045
+ }).optional(),
11046
+ int8: object({
11047
+ kept: boolean(),
11048
+ map50Fp16: number().nullable(),
11049
+ map50Int8: number().nullable(),
11050
+ reason: string().nullable()
11051
+ }).optional(),
11052
+ exportsDropped: array(object({
11053
+ export: string(),
11054
+ reason: string()
11055
+ })).optional(),
11056
+ files: array(TrainingResultFileSchema).optional(),
11057
+ bundle: object({
11058
+ path: literal("bundle.tar"),
11059
+ bytes: number().int().nonnegative(),
11060
+ sha256: string().regex(/^[0-9a-f]{64}$/)
11061
+ }).nullable().optional(),
11062
+ catalogDraft: object({
11063
+ base: TrainingCatalogDraftSchema,
11064
+ int8: TrainingCatalogDraftSchema.nullable()
11065
+ }).nullable().optional(),
11066
+ licence: string()
11067
+ });
11068
+ var TrainingStageSchema = _enum([
11069
+ "prepare",
11070
+ "replay",
11071
+ "train",
11072
+ "eval",
11073
+ "export",
11074
+ "package"
11075
+ ]);
11076
+ var EventBase = {
11077
+ v: literal(1),
11078
+ ts: number()
11079
+ };
11080
+ discriminatedUnion("type", [
11081
+ object({
11082
+ ...EventBase,
11083
+ type: literal("stage"),
11084
+ stage: TrainingStageSchema
11085
+ }),
11086
+ object({
11087
+ ...EventBase,
11088
+ type: literal("epoch"),
11089
+ epoch: number().int(),
11090
+ epochs: number().int(),
11091
+ boxLoss: number().nullable().optional(),
11092
+ map50: number().nullable().optional(),
11093
+ map50_95: number().nullable().optional(),
11094
+ etaSec: number().nullable().optional()
11095
+ }),
11096
+ object({
11097
+ ...EventBase,
11098
+ type: literal("metric"),
11099
+ name: string(),
11100
+ value: number()
11101
+ }),
11102
+ object({
11103
+ ...EventBase,
11104
+ type: literal("artifact"),
11105
+ path: string(),
11106
+ bytes: number(),
11107
+ sha256: string()
11108
+ }),
11109
+ object({
11110
+ ...EventBase,
11111
+ type: literal("done"),
11112
+ status: _enum(["succeeded", "failed"]),
11113
+ resultSha256: string().nullable().optional()
11114
+ }),
11115
+ object({
11116
+ ...EventBase,
11117
+ type: literal("error"),
11118
+ stage: string(),
11119
+ code: string(),
11120
+ message: string()
11121
+ })
11122
+ ]);
11123
+ /**
10429
11124
  * What the gate decided about a birth, from the CALLER's point of view.
10430
11125
  *
10431
11126
  * Deliberately not `ConfirmationVerdict`: `undecided` is not a birth decision
@@ -12753,7 +13448,9 @@ var AddonHttpRouteSchema = object({
12753
13448
  "authenticated",
12754
13449
  "admin"
12755
13450
  ]).optional(),
12756
- description: string().optional()
13451
+ description: string().optional(),
13452
+ /** The hub limits this route per client address before the handler runs. */
13453
+ rateLimit: _enum(["auth"]).optional()
12757
13454
  });
12758
13455
  /**
12759
13456
  * Cross-process route invocation envelope. The hub captures the
@@ -13477,6 +14174,37 @@ var BackupDestinationInfoSchema = object({
13477
14174
  lastError: string().optional()
13478
14175
  });
13479
14176
  /**
14177
+ * How an archive is encrypted (operator decision 2026-10-09): to a backup
14178
+ * PUBLIC key the hub holds, so only the operator's secret key opens it.
14179
+ * Absent on a plain `.tar.gz` — every archive made before encryption, or
14180
+ * with it off — which restores without a key.
14181
+ */
14182
+ var BackupArchiveEncryptionSchema = object({
14183
+ /** `x25519-hkdf-aes256gcm-stream-v1`. */
14184
+ scheme: string(),
14185
+ /** 16 hex — the backup key whose secret restores this archive. */
14186
+ keyId: string()
14187
+ });
14188
+ /**
14189
+ * The backup encryption setting. The hub keeps PUBLIC keys only: the active
14190
+ * one new archives are encrypted to, and the retired ones older archives
14191
+ * still need. The secret key is shown once, at `setupEncryption`.
14192
+ */
14193
+ var BackupEncryptionStatusSchema = object({
14194
+ enabled: boolean(),
14195
+ active: object({
14196
+ keyId: string(),
14197
+ publicKey: string(),
14198
+ createdAt: number()
14199
+ }).nullable(),
14200
+ /** Every key ever set up, newest first. */
14201
+ keys: array(object({
14202
+ keyId: string(),
14203
+ createdAt: number(),
14204
+ retiredAt: number().nullable()
14205
+ })).readonly()
14206
+ });
14207
+ /**
13480
14208
  * Per-archive entry returned by `backup.listArchives({ destinationId })`.
13481
14209
  * Same shape the destination drill-in renders. Sourced from the per-
13482
14210
  * location `manifests.json` (no per-archive tarball read required).
@@ -13488,7 +14216,9 @@ var BackupArchiveEntrySchema = object({
13488
14216
  sizeBytes: number(),
13489
14217
  label: string().optional(),
13490
14218
  /** Top-level locations included in the archive (db, addons, tls, …). */
13491
- locations: array(string()).readonly()
14219
+ locations: array(string()).readonly(),
14220
+ /** Present when the archive is encrypted; restore then needs that key. */
14221
+ encryption: BackupArchiveEncryptionSchema.optional()
13492
14222
  });
13493
14223
  var BackupEntrySchema = object({
13494
14224
  id: string(),
@@ -13497,7 +14227,8 @@ var BackupEntrySchema = object({
13497
14227
  label: string().optional(),
13498
14228
  createdAt: number(),
13499
14229
  sizeBytes: number(),
13500
- locations: array(string()).optional()
14230
+ locations: array(string()).optional(),
14231
+ encryption: BackupArchiveEncryptionSchema.optional()
13501
14232
  });
13502
14233
  var ArchiveEntrySchema = object({
13503
14234
  path: string(),
@@ -13686,10 +14417,40 @@ method(_void(), array(BackupDestinationInfoSchema).readonly(), { auth: "admin" }
13686
14417
  * this list and skips entries whose path doesn't start with
13687
14418
  * any of them.
13688
14419
  */
13689
- locations: array(string()).optional()
14420
+ locations: array(string()).optional(),
14421
+ /**
14422
+ * The backup SECRET key, for an encrypted archive (ignored for a plain
14423
+ * one). The archive is decrypted into the hub's private staging
14424
+ * before the restart; the key is not stored. A wrong or missing key
14425
+ * is refused before the archive is downloaded.
14426
+ */
14427
+ backupSecretKey: string().optional()
13690
14428
  }), _void(), {
13691
14429
  kind: "mutation",
13692
14430
  auth: "admin"
14431
+ }), method(_void(), BackupEncryptionStatusSchema, { auth: "admin" }), method(object({}), object({
14432
+ keyId: string(),
14433
+ secretKey: string(),
14434
+ publicKey: string(),
14435
+ createdAt: number(),
14436
+ replacedKeyId: string().nullable()
14437
+ }), {
14438
+ kind: "mutation",
14439
+ auth: "admin"
14440
+ }), method(object({}), object({ disabledKeyId: string().nullable() }), {
14441
+ kind: "mutation",
14442
+ auth: "admin"
14443
+ }), method(object({ backupSecretKey: string() }), object({
14444
+ valid: boolean(),
14445
+ keyId: string().nullable(),
14446
+ /** The hub knows this key (active or retired). */
14447
+ known: boolean(),
14448
+ /** It is the key new archives are encrypted to. */
14449
+ active: boolean(),
14450
+ error: string().optional()
14451
+ }), {
14452
+ kind: "mutation",
14453
+ auth: "admin"
13693
14454
  }), method(object({
13694
14455
  destinationId: string(),
13695
14456
  backupId: string()
@@ -15351,7 +16112,60 @@ var CustomModelDescriptorSchema = object({
15351
16112
  stepId: string(),
15352
16113
  entry: ModelCatalogEntrySchema
15353
16114
  });
15354
- method(_void(), array(CustomModelDescriptorSchema).readonly(), { auth: "admin" });
16115
+ /** One regular file of an imported bundle, as the producer measured it. */
16116
+ var ModelBundleFileSchema = object({
16117
+ /** Relative path inside the bundle tar; an mlpackage member is `<x>.mlpackage/<member>`. */
16118
+ path: string().min(1),
16119
+ bytes: number().int().nonnegative(),
16120
+ sha256: string().regex(/^[0-9a-f]{64}$/)
16121
+ });
16122
+ var ImportModelBundleInputSchema = object({
16123
+ /** The registry provider that keeps the model (Model Studio). */
16124
+ addonId: string(),
16125
+ stepId: string().min(1),
16126
+ /**
16127
+ * The catalog rows to register, complete, every format URL already
16128
+ * `camstack-local://<modelId>/<file>` naming a file of the bundle. One
16129
+ * bundle may carry several rows (a base and its INT8 variant).
16130
+ */
16131
+ entries: array(ModelCatalogEntrySchema).min(1).max(4),
16132
+ /** The bundle tar, offered by the producer over `ctx.peerBytes` (same host). */
16133
+ bundle: object({
16134
+ ticket: PeerBytesTicketSchema,
16135
+ bytes: number().int().positive(),
16136
+ sha256: string().regex(/^[0-9a-f]{64}$/)
16137
+ }),
16138
+ /** Every file the tar must hold; anything missing, extra or different is refused. */
16139
+ files: array(ModelBundleFileSchema).min(1).max(64),
16140
+ /** Convert missing engine formats and push the model to every agent afterwards. */
16141
+ distribute: boolean()
16142
+ });
16143
+ var ImportModelBundleResultSchema = discriminatedUnion("kind", [object({
16144
+ kind: literal("imported"),
16145
+ modelIds: array(string()).readonly(),
16146
+ distributed: array(object({
16147
+ modelId: string(),
16148
+ nodeId: string(),
16149
+ format: _enum(MODEL_FORMATS),
16150
+ ok: boolean(),
16151
+ error: string().optional()
16152
+ })).readonly()
16153
+ }), object({
16154
+ kind: literal("refused"),
16155
+ reason: _enum([
16156
+ "transfer-failed",
16157
+ "checksum-mismatch",
16158
+ "bundle-mismatch",
16159
+ "invalid-entry",
16160
+ "id-taken"
16161
+ ]),
16162
+ detail: string()
16163
+ })]);
16164
+ method(_void(), array(CustomModelDescriptorSchema).readonly(), { auth: "admin" }), method(ImportModelBundleInputSchema, ImportModelBundleResultSchema, {
16165
+ kind: "mutation",
16166
+ auth: "admin",
16167
+ timeoutMs: 30 * 6e4
16168
+ });
15355
16169
  /**
15356
16170
  * Query filter for settings-store collections.
15357
16171
  */
@@ -15830,6 +16644,35 @@ var KeychainKeySourceSchema = object({
15830
16644
  */
15831
16645
  sharesBackupWithDatabase: boolean()
15832
16646
  });
16647
+ /**
16648
+ * One keychain reset, as the Secrets page reports it until the operator
16649
+ * acknowledges it. Never a value: refs, counts and table names only.
16650
+ */
16651
+ var KeychainResetRecordSchema = object({
16652
+ id: string(),
16653
+ at: number(),
16654
+ /** `user:<id>` or {@link KEYCHAIN_RESET_TRIGGER_ACTOR}. */
16655
+ actor: string(),
16656
+ /** Why the keychain was locked when it was reset; `null` when it was not locked. */
16657
+ lockedReason: string().nullable(),
16658
+ /** Values moved into the archive table (ciphertext under the lost key). */
16659
+ archived: number().int(),
16660
+ /** `keychain:secrets-orphaned-<ts>`, or `null` when nothing was stored. */
16661
+ archivedCollection: string().nullable(),
16662
+ /**
16663
+ * `keychain:keys-orphaned-<ts>`: the wrapped data keys of the archive, kept
16664
+ * so the archive can still be opened if the lost master key turns up.
16665
+ */
16666
+ archivedKeysCollection: string().nullable(),
16667
+ /**
16668
+ * `system-settings` keys whose marker the reset cleared — the cluster
16669
+ * secret's: a marker left pointing at an archived value would refuse every
16670
+ * agent forever (D797).
16671
+ */
16672
+ clearedSettingsKeys: array(string()).readonly(),
16673
+ /** When an operator dismissed the notice on the Secrets page; `null` until then. */
16674
+ acknowledgedAt: number().nullable()
16675
+ });
15833
16676
  var KeychainStatusSchema = object({
15834
16677
  keychain: KeychainStateSchema,
15835
16678
  /** The source of the master key in use; `null` while locked. */
@@ -15847,7 +16690,9 @@ var KeychainStatusSchema = object({
15847
16690
  /** Wrapped copies of the data key under a previous master key, kept until purged. */
15848
16691
  retiredWraps: number().int(),
15849
16692
  recoveryKeyDownloadedAt: number().nullable(),
15850
- secretCount: number().int()
16693
+ secretCount: number().int(),
16694
+ /** The most recent reset, acknowledged or not; `null` when the keychain was never reset. */
16695
+ lastReset: KeychainResetRecordSchema.nullable()
15851
16696
  });
15852
16697
  /**
15853
16698
  * Whether a stored value is still pointed at by its owner's settings.
@@ -15869,17 +16714,26 @@ var KeychainAuditActionSchema = _enum([
15869
16714
  "download-recovery-key",
15870
16715
  "delete-orphans",
15871
16716
  "reset",
16717
+ "acknowledge-reset",
15872
16718
  "initialize"
15873
16719
  ]);
15874
16720
  var KeychainAuditEntrySchema = object({
15875
16721
  id: string(),
15876
16722
  at: number(),
15877
16723
  action: KeychainAuditActionSchema,
15878
- /** `addon:<id>` | `user:<id>` | `system`. */
16724
+ /** `addon:<id>` | `user:<id>` | `system` | `trigger-file`. */
15879
16725
  actor: string(),
15880
16726
  ref: string().nullable(),
15881
16727
  detail: string().nullable()
15882
16728
  });
16729
+ var KEYCHAIN_RESET_CONFIRMATION = "RESET KEYCHAIN";
16730
+ /**
16731
+ * Secrets the HUB itself holds (owner `system`) that no settings form shows:
16732
+ * `jwt-signing-key` — the session signing key (D797). It is always "in use",
16733
+ * never an orphan; it is generated on a fresh hub and replaced only through
16734
+ * {@link keychainAdminCapability.methods.setSystemSecret}.
16735
+ */
16736
+ var SystemHeldSecretNameSchema = _enum(["jwt-signing-key"]);
15883
16737
  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({
15884
16738
  value: string(),
15885
16739
  version: number().int()
@@ -15887,6 +16741,16 @@ method(object({}), KeychainStatusSchema, { auth: "admin" }), method(object({}),
15887
16741
  kind: "mutation",
15888
16742
  auth: "admin",
15889
16743
  caller: "required"
16744
+ }), method(object({
16745
+ name: SystemHeldSecretNameSchema,
16746
+ value: string().min(16)
16747
+ }), object({
16748
+ ref: string(),
16749
+ version: number().int()
16750
+ }), {
16751
+ kind: "mutation",
16752
+ auth: "admin",
16753
+ caller: "required"
15890
16754
  }), method(object({ refs: array(string().min(1)).max(1e3) }), object({
15891
16755
  deleted: array(string()).readonly(),
15892
16756
  kept: array(object({
@@ -15916,13 +16780,20 @@ method(object({}), KeychainStatusSchema, { auth: "admin" }), method(object({}),
15916
16780
  kind: "mutation",
15917
16781
  auth: "admin",
15918
16782
  caller: "required"
15919
- }), method(object({ confirm: literal("RESET KEYCHAIN") }), object({
16783
+ }), method(object({ confirm: literal(KEYCHAIN_RESET_CONFIRMATION) }), object({
15920
16784
  archivedCollection: string().nullable(),
15921
16785
  archived: number().int()
15922
16786
  }), {
15923
16787
  kind: "mutation",
15924
16788
  auth: "admin",
15925
16789
  caller: "required"
16790
+ }), method(object({}), object({
16791
+ reset: KeychainResetRecordSchema.nullable(),
16792
+ pendingReentry: array(KeychainSecretMetaSchema).readonly()
16793
+ }), { auth: "admin" }), method(object({}), object({ acknowledged: boolean() }), {
16794
+ kind: "mutation",
16795
+ auth: "admin",
16796
+ caller: "required"
15926
16797
  });
15927
16798
  method(_void(), object({
15928
16799
  id: string(),
@@ -18568,7 +19439,7 @@ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
18568
19439
  * `login-method` — collection cap through which auth addons contribute
18569
19440
  * their pre-auth login surfaces to the login page. This is the SINGLE,
18570
19441
  * generic mechanism that supersedes the dead `auth.listProviders` reader:
18571
- * every auth addon (OIDC, magic-link, WebAuthn/passkey) registers a
19442
+ * every auth addon (OIDC, WebAuthn/passkey) registers a
18572
19443
  * `login-method` provider and the PUBLIC `auth.listLoginMethods`
18573
19444
  * procedure aggregates them for the unauthenticated login page.
18574
19445
  *
@@ -18576,8 +19447,7 @@ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
18576
19447
  *
18577
19448
  * - `redirect` — a declarative button. The login page renders a generic
18578
19449
  * button that navigates to `startUrl` (an addon-owned HTTP route).
18579
- * Covers OIDC (`/addon/auth-oidc/<id>/start`) and magic-link with
18580
- * ZERO shell-side JS. A future SSO addon plugs in the same way — the
19450
+ * Covers OIDC (`/addon/auth-oidc/<id>/start`) with ZERO shell-side JS. A future SSO addon plugs in the same way — the
18581
19451
  * login page needs NO change.
18582
19452
  *
18583
19453
  * - `widget` — a Module-Federation widget the login page mounts (via
@@ -18596,8 +19466,8 @@ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
18596
19466
  * decision.
18597
19467
  *
18598
19468
  * Every contribution carries a `stage`:
18599
- * - `primary` — shown on the first credentials screen (OIDC /
18600
- * magic-link buttons; a future usernameless passkey).
19469
+ * - `primary` — shown on the first credentials screen (OIDC
19470
+ * buttons; a usernameless passkey).
18601
19471
  * - `second-factor` — shown AFTER the password leg, gated on the
18602
19472
  * returned `factors` (passkey-as-2FA today).
18603
19473
  *
@@ -18624,7 +19494,7 @@ var LoginMethodContributionSchema = discriminatedUnion("kind", [
18624
19494
  * The provider names an external identity a signed-in user can link to
18625
19495
  * their own account (D782): `auth.listLinkableProviders` /
18626
19496
  * `beginExternalLink` offer exactly the redirect methods that set this,
18627
- * whatever their id. Absent / false — a login button only (magic-link).
19497
+ * whatever their id. Absent / false — a login button only.
18628
19498
  */
18629
19499
  linkable: boolean().optional()
18630
19500
  }),
@@ -22441,8 +23311,7 @@ method(object({}), object({ rules: array(NcRuleSchema) }), { auth: "admin" }), m
22441
23311
  * `super_admin` — collapsed onto the single boolean because every
22442
23312
  * non-admin caller is governed by the same scope-check rules; the
22443
23313
  * distinction was only ever used to route role-specific procedures
22444
- * which we no longer have. Agents are admin sessions issued via
22445
- * `createServiceToken`; CLI / webhook integrations are `cst_*` tokens
23314
+ * which we no longer have. CLI / webhook integrations are `cst_*` tokens
22446
23315
  * with `isAdmin: false` + an explicit scope list.
22447
23316
  */
22448
23317
  /** Per-method access flavour. Materialised on every cap method via codegen. */
@@ -24167,6 +25036,9 @@ var RetrainExportFilterSchema = object({
24167
25036
  frameIds: array(string()).max(2e4).optional(),
24168
25037
  /** Only frames in at least one of these named collections. */
24169
25038
  collectionIds: array(string()).max(200).optional(),
25039
+ /** Exactly the frames of this dataset version (and its completeOnly). An
25040
+ * unknown id selects nothing. */
25041
+ datasetVersionId: string().optional(),
24170
25042
  batchId: string().optional(),
24171
25043
  /** Only frames the operator marked complete (all subjects boxed). */
24172
25044
  completeOnly: boolean().optional()
@@ -24334,6 +25206,67 @@ var RetrainLlmAssistResultSchema = discriminatedUnion("kind", [object({
24334
25206
  ]),
24335
25207
  detail: string().optional()
24336
25208
  })]);
25209
+ /** What a dataset version is cut from. Every field narrows. */
25210
+ var RetrainDatasetSelectionSchema = object({
25211
+ deviceIds: array(number()).readonly().optional(),
25212
+ collectionIds: array(string()).max(200).readonly().optional(),
25213
+ frameIds: array(string()).max(2e4).readonly().optional()
25214
+ });
25215
+ /** The counts a dataset is judged by. */
25216
+ var RetrainDatasetStatsSchema = object({
25217
+ frames: number().int(),
25218
+ completeFrames: number().int(),
25219
+ /** `completeFrames / frames`, 0..1. */
25220
+ completeness: number(),
25221
+ /** Boxes to learn (model errors excluded). */
25222
+ subjects: number().int(),
25223
+ modelErrors: number().int(),
25224
+ /** Complete frames with no subject. */
25225
+ hardNegatives: number().int(),
25226
+ /** Subjects per class × camera × day/night. */
25227
+ cells: array(object({
25228
+ macroClass: string(),
25229
+ deviceId: number(),
25230
+ lighting: _enum([
25231
+ "day",
25232
+ "night",
25233
+ "unknown"
25234
+ ]),
25235
+ subjects: number().int(),
25236
+ frames: number().int()
25237
+ })).readonly(),
25238
+ cameras: array(object({
25239
+ deviceId: number(),
25240
+ frames: number().int(),
25241
+ completeFrames: number().int()
25242
+ })).readonly()
25243
+ });
25244
+ /** An immutable dataset version, without its frame list. */
25245
+ var RetrainDatasetVersionSchema = object({
25246
+ id: string(),
25247
+ name: string(),
25248
+ createdAt: number(),
25249
+ selection: RetrainDatasetSelectionSchema,
25250
+ layout: RetrainExportLayoutSchema,
25251
+ completeOnly: boolean(),
25252
+ frameCount: number().int(),
25253
+ /** sha256 of what the frames taught when the version was frozen. */
25254
+ annotationHash: string(),
25255
+ /** The export manifest schema the version was cut under. */
25256
+ manifestSchema: string(),
25257
+ stats: RetrainDatasetStatsSchema
25258
+ });
25259
+ var CreateRetrainDatasetVersionResultSchema = discriminatedUnion("kind", [object({
25260
+ kind: literal("created"),
25261
+ version: RetrainDatasetVersionSchema
25262
+ }), object({
25263
+ kind: literal("refused"),
25264
+ reason: _enum([
25265
+ "empty-name",
25266
+ "duplicate-name",
25267
+ "no-frames"
25268
+ ])
25269
+ })]);
24337
25270
  /** The outcome of a lifecycle move owned by the retrain page. */
24338
25271
  var RetrainTransitionResultSchema = object({
24339
25272
  trackId: string(),
@@ -25123,6 +26056,47 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
25123
26056
  kind: "mutation",
25124
26057
  auth: "admin",
25125
26058
  timeoutMs: 60 * 6e4
26059
+ }), method(object({
26060
+ filter: RetrainExportFilterSchema,
26061
+ layout: RetrainExportLayoutSchema
26062
+ }), object({
26063
+ ticket: PeerBytesTicketSchema,
26064
+ frames: number().int(),
26065
+ annotations: number().int()
26066
+ }), {
26067
+ kind: "mutation",
26068
+ auth: "admin",
26069
+ timeoutMs: 12e4
26070
+ }), method(object({
26071
+ selection: RetrainDatasetSelectionSchema,
26072
+ completeOnly: boolean().optional()
26073
+ }), RetrainDatasetStatsSchema, {
26074
+ kind: "query",
26075
+ auth: "admin"
26076
+ }), method(object({
26077
+ name: string().max(120),
26078
+ selection: RetrainDatasetSelectionSchema,
26079
+ layout: RetrainExportLayoutSchema,
26080
+ completeOnly: boolean()
26081
+ }), CreateRetrainDatasetVersionResultSchema, {
26082
+ kind: "mutation",
26083
+ auth: "admin",
26084
+ timeoutMs: 12e4
26085
+ }), method(object({}), array(RetrainDatasetVersionSchema).readonly(), {
26086
+ kind: "query",
26087
+ auth: "admin"
26088
+ }), method(object({ id: string() }), object({ deleted: boolean() }), {
26089
+ kind: "mutation",
26090
+ auth: "admin"
26091
+ }), method(object({ id: string() }), object({
26092
+ found: boolean(),
26093
+ annotationHash: string(),
26094
+ matches: boolean(),
26095
+ missingFrames: number().int()
26096
+ }), {
26097
+ kind: "query",
26098
+ auth: "admin",
26099
+ timeoutMs: 12e4
25126
26100
  }), method(object({}), array(RetrainAssistProfileSchema).readonly(), {
25127
26101
  kind: "query",
25128
26102
  auth: "admin"
@@ -29555,8 +30529,8 @@ version: string().optional() }), ServerUpdateActionResultSchema, {
29555
30529
  * `smtp-provider` — pluggable email delivery surface.
29556
30530
  *
29557
30531
  * Collection cap: a deployment may install multiple SMTP relays (e.g.
29558
- * one for transactional / one for notifications). Consumers (magic-link,
29559
- * notifier addons, …) walk the collection and pick the first
30532
+ * one for transactional / one for notifications). Consumers (notifier
30533
+ * addons, …) walk the collection and pick the first
29560
30534
  * ready provider OR target a specific addonId.
29561
30535
  *
29562
30536
  * The shape stays small on purpose — `sendEmail` is enough for the
@@ -29735,7 +30709,7 @@ targets: array(object({
29735
30709
  })));
29736
30710
  /**
29737
30711
  * `sso-bridge` — internal hub-only cap that lets SSO-style auth
29738
- * providers (OIDC, SAML, magic-link, …) mint an HMAC-signed token
30712
+ * providers (OIDC, SAML, …) mint an HMAC-signed token
29739
30713
  * carrying the post-callback claims before redirecting back to
29740
30714
  * `/api/auth/sso/finish`.
29741
30715
  *
@@ -29798,7 +30772,14 @@ var SsoBridgeClaimsSchema = object({
29798
30772
  * Verified `iss` of the id_token behind an OIDC login bridge (D782). A
29799
30773
  * subject is unique only per issuer, so a link is bound to it.
29800
30774
  */
29801
- issuer: string().optional()
30775
+ issuer: string().optional(),
30776
+ /**
30777
+ * SHA-256 (hex) of the `camstack_sso_state` cookie the IdP `/start` set in
30778
+ * the browser that began this sign-in. `/api/auth/sso/finish` requires the
30779
+ * request to present the matching cookie — a login bridge is useless in
30780
+ * any other browser.
30781
+ */
30782
+ browserBinding: string().optional()
29802
30783
  });
29803
30784
  method(object({
29804
30785
  claims: SsoBridgeClaimsSchema,
@@ -39773,16 +40754,6 @@ var ApiKeySummarySchema = object({
39773
40754
  createdAt: number(),
39774
40755
  lastUsedAt: number().optional()
39775
40756
  });
39776
- var CreateApiKeyInputSchema = object({
39777
- label: string(),
39778
- isAdmin: boolean().default(false),
39779
- allowedProviders: union([array(string()), literal("*")]).optional(),
39780
- allowedDevices: record(string(), union([array(string()), literal("*")])).optional()
39781
- });
39782
- var CreateApiKeyResultSchema = object({
39783
- token: string(),
39784
- record: ApiKeySummarySchema
39785
- });
39786
40757
  var ScopedTokenSummarySchema = object({
39787
40758
  id: string(),
39788
40759
  userId: string(),
@@ -39881,17 +40852,10 @@ method(_void(), array(UserSummarySchema), { auth: "admin" }), method(CreateUserI
39881
40852
  }), UserSummarySchema.extend({ passwordHash: string() }).nullable(), {
39882
40853
  kind: "mutation",
39883
40854
  access: "view"
39884
- }), method(_void(), array(ApiKeySummarySchema), { auth: "admin" }), method(CreateApiKeyInputSchema, CreateApiKeyResultSchema, {
39885
- kind: "mutation",
39886
- auth: "admin",
39887
- access: "create"
39888
- }), method(object({ id: string() }), object({ success: literal(true) }), {
40855
+ }), method(_void(), array(ApiKeySummarySchema), { auth: "admin" }), method(object({ id: string() }), object({ success: literal(true) }), {
39889
40856
  kind: "mutation",
39890
40857
  auth: "admin",
39891
40858
  access: "delete"
39892
- }), method(object({ token: string() }), ApiKeySummarySchema.nullable(), {
39893
- kind: "mutation",
39894
- access: "view"
39895
40859
  }), method(CreateScopedTokenInputSchema, CreateScopedTokenResultSchema, {
39896
40860
  kind: "mutation",
39897
40861
  auth: "admin",
@@ -39965,15 +40929,7 @@ method(_void(), array(UserSummarySchema), { auth: "admin" }), method(CreateUserI
39965
40929
  }).nullable(), { access: "view" }), method(object({ userId: string() }), array(ExternalIdentitySchema), { auth: "admin" }), method(ExternalIdentityKeySchema, object({
39966
40930
  userId: string(),
39967
40931
  issuer: string()
39968
- }).nullable(), { auth: "admin" }), method(ExternalIdentityKeySchema.extend({
39969
- userId: string(),
39970
- issuer: string().min(1),
39971
- label: string().optional()
39972
- }), object({ success: literal(true) }), {
39973
- kind: "mutation",
39974
- auth: "admin",
39975
- access: "create"
39976
- }), method(ExternalIdentityKeySchema.extend({ userId: string() }), object({ success: boolean() }), {
40932
+ }).nullable(), { auth: "admin" }), method(ExternalIdentityKeySchema.extend({ userId: string() }), object({ success: boolean() }), {
39977
40933
  kind: "mutation",
39978
40934
  auth: "admin",
39979
40935
  access: "delete"
@@ -40424,6 +41380,451 @@ var zoneRulesCapability = {
40424
41380
  */
40425
41381
  durability: "restored"
40426
41382
  };
41383
+ /**
41384
+ * `training-provider` — ONE cloud that can run the CamStack trainer.
41385
+ *
41386
+ * A thin, mockable translation layer: it knows how to run a container with a
41387
+ * GPU, move a dataset in, read the job's stdout and hand artefacts back. It
41388
+ * knows nothing about datasets, splits, floors, cost policy or Model Studio —
41389
+ * those are the `training` orchestrator's (D805). Every rule written there
41390
+ * once is what makes a second provider (RunPod, a local NVIDIA node) a new
41391
+ * manifest entry and nothing else.
41392
+ *
41393
+ * Collection, routed by the `addonId` in every single-row input (the `llm` /
41394
+ * `notification-output` posture); `describe` concat-fans across providers.
41395
+ * Every method is `admin`: these spend money.
41396
+ *
41397
+ * Every cloud object a provider creates is tagged with the orchestrator's
41398
+ * `jobKey`, so a retried submit finds the job it already started instead of
41399
+ * starting a second GPU, and `listJobs` can find orphans.
41400
+ *
41401
+ * Bytes never ride a cap field: the dataset arrives as a `ctx.peerBytes`
41402
+ * ticket the producer (pipeline-analytics) minted, and artefacts leave as a
41403
+ * ticket the provider mints (D613).
41404
+ */
41405
+ var TrainingGpuOptionSchema = object({
41406
+ id: string(),
41407
+ label: string(),
41408
+ /** List price, USD per GPU-hour, before any region multiplier. */
41409
+ usdPerHour: number().nonnegative(),
41410
+ vramGb: number().nonnegative()
41411
+ });
41412
+ var TrainingRegionOptionSchema = object({
41413
+ /** `''` = any region (the provider's choice). */
41414
+ id: string(),
41415
+ label: string(),
41416
+ priceMultiplier: number().positive()
41417
+ });
41418
+ /**
41419
+ * The provider's per-account settings, as the orchestrator reads them. They
41420
+ * live in the PROVIDER addon's settings (operator decision 2026-10-08: they
41421
+ * depend on the user's account), never hard-coded in the orchestrator.
41422
+ */
41423
+ var TrainingProviderDefaultsSchema = object({
41424
+ gpuType: string(),
41425
+ region: string(),
41426
+ costCapUsd: number().nonnegative(),
41427
+ maxRuntimeSec: number().int().positive(),
41428
+ /** Hours a FAILED job's cloud dataset is kept for debugging; 0 = delete at once. */
41429
+ failedDatasetGraceHours: number().nonnegative()
41430
+ });
41431
+ var TrainingProviderDescriptorSchema = object({
41432
+ addonId: string(),
41433
+ /** `modal`, `runpod`, `fake`, … */
41434
+ kind: string(),
41435
+ label: string(),
41436
+ gpuTypes: array(TrainingGpuOptionSchema).readonly(),
41437
+ regions: array(TrainingRegionOptionSchema).readonly(),
41438
+ maxDatasetBytes: number().int().positive(),
41439
+ maxRuntimeSec: number().int().positive(),
41440
+ freeTierNote: string().optional(),
41441
+ /** Where the data goes, in one sentence the confirm dialog repeats. */
41442
+ dataResidencyNote: string(),
41443
+ /** Credentials are present — never the values. */
41444
+ configured: boolean(),
41445
+ defaults: TrainingProviderDefaultsSchema
41446
+ });
41447
+ var TrainingCredentialCheckSchema = object({
41448
+ ok: boolean(),
41449
+ /** Workspace / account name, when the provider says. */
41450
+ account: string().optional(),
41451
+ reason: _enum([
41452
+ "missing",
41453
+ "invalid",
41454
+ "forbidden",
41455
+ "network",
41456
+ "quota"
41457
+ ]).optional(),
41458
+ detail: string().optional()
41459
+ });
41460
+ var ProviderJobStateSchema = _enum([
41461
+ "pending",
41462
+ "starting",
41463
+ "running",
41464
+ "succeeded",
41465
+ "failed",
41466
+ "cancelled",
41467
+ "lost"
41468
+ ]);
41469
+ var ProviderJobStatusSchema = object({
41470
+ jobKey: string(),
41471
+ providerJobId: string().optional(),
41472
+ state: ProviderJobStateSchema,
41473
+ startedAt: number().optional(),
41474
+ endedAt: number().optional(),
41475
+ exitCode: number().int().optional(),
41476
+ failureReason: string().optional(),
41477
+ gpuType: string(),
41478
+ region: string().optional(),
41479
+ billedSeconds: number().nonnegative(),
41480
+ costUsd: number().nonnegative(),
41481
+ /** True when `costUsd` is runtime × list price, not a billing answer. */
41482
+ costIsEstimate: boolean(),
41483
+ lastFetchedAt: number()
41484
+ });
41485
+ /**
41486
+ * The trainer the job runs, by SOURCE revision: the provider turns it into an
41487
+ * image its own way (Modal builds the published Dockerfile at that revision;
41488
+ * a registry-pull provider maps it to a tag). Recorded on the job and echoed
41489
+ * in `result.json`.
41490
+ */
41491
+ var TrainerSourceRefSchema = object({
41492
+ /** Hugging Face repo id, e.g. `camstack/camstack-trainer`. */
41493
+ repo: string().min(1),
41494
+ /** A commit sha (never a branch) — the job must be reproducible. */
41495
+ revision: string().regex(/^[0-9a-f]{7,64}$/)
41496
+ });
41497
+ var JobRef = {
41498
+ addonId: string(),
41499
+ jobKey: string().uuid()
41500
+ };
41501
+ var TrainingLogLineSchema = object({
41502
+ ts: number(),
41503
+ text: string()
41504
+ });
41505
+ method(object({}), array(TrainingProviderDescriptorSchema).readonly(), { auth: "admin" }), method(object({ addonId: string() }), TrainingCredentialCheckSchema, {
41506
+ kind: "mutation",
41507
+ auth: "admin",
41508
+ timeoutMs: 3e4
41509
+ }), method(object({
41510
+ addonId: string(),
41511
+ gpuType: string(),
41512
+ region: string(),
41513
+ datasetBytes: number().int().nonnegative(),
41514
+ gpuSecondsLow: number().nonnegative(),
41515
+ gpuSecondsHigh: number().nonnegative()
41516
+ }), object({
41517
+ usdLow: number().nonnegative(),
41518
+ usdHigh: number().nonnegative(),
41519
+ notes: array(string()).readonly()
41520
+ }), { auth: "admin" }), method(object({
41521
+ ...JobRef,
41522
+ ticket: PeerBytesTicketSchema
41523
+ }), object({
41524
+ bytes: number().int().nonnegative(),
41525
+ sha256: string()
41526
+ }), {
41527
+ kind: "mutation",
41528
+ auth: "admin",
41529
+ timeoutMs: 120 * 6e4
41530
+ }), method(object({
41531
+ ...JobRef,
41532
+ trainer: TrainerSourceRefSchema,
41533
+ jobSpecJson: string().min(2).max(64e3),
41534
+ gpuType: string(),
41535
+ region: string(),
41536
+ maxRuntimeSec: number().int().positive()
41537
+ }), ProviderJobStatusSchema, {
41538
+ kind: "mutation",
41539
+ auth: "admin",
41540
+ timeoutMs: 30 * 6e4
41541
+ }), method(object(JobRef), ProviderJobStatusSchema, {
41542
+ auth: "admin",
41543
+ timeoutMs: 6e4
41544
+ }), method(object({
41545
+ ...JobRef,
41546
+ cursor: string().optional(),
41547
+ max: number().int().min(1).max(500)
41548
+ }), object({
41549
+ lines: array(TrainingLogLineSchema).readonly(),
41550
+ cursor: string()
41551
+ }), {
41552
+ auth: "admin",
41553
+ timeoutMs: 6e4
41554
+ }), method(object(JobRef), object({ ok: literal(true) }), {
41555
+ kind: "mutation",
41556
+ auth: "admin",
41557
+ timeoutMs: 6e4
41558
+ }), method(object(JobRef), object({
41559
+ found: boolean(),
41560
+ text: string().optional()
41561
+ }), {
41562
+ kind: "mutation",
41563
+ auth: "admin",
41564
+ timeoutMs: 5 * 6e4
41565
+ }), method(object({
41566
+ ...JobRef,
41567
+ path: _enum(["bundle.tar"])
41568
+ }), object({ ticket: PeerBytesTicketSchema }), {
41569
+ kind: "mutation",
41570
+ auth: "admin",
41571
+ timeoutMs: 5 * 6e4
41572
+ }), method(object(JobRef), object({ deleted: array(string()).readonly() }), {
41573
+ kind: "mutation",
41574
+ auth: "admin",
41575
+ timeoutMs: 5 * 6e4
41576
+ }), method(object({ addonId: string() }), array(ProviderJobStatusSchema).readonly(), {
41577
+ auth: "admin",
41578
+ timeoutMs: 2 * 6e4
41579
+ });
41580
+ /**
41581
+ * `training` — the cloud-training orchestrator (D805). Hub-only singleton,
41582
+ * provided by `addon-training`.
41583
+ *
41584
+ * It owns what every provider must agree on, written once:
41585
+ *
41586
+ * - **Dataset versions.** Taken over from pipeline-analytics (D796): the rows
41587
+ * live here (D808); pipeline-analytics still CUTS a version (it owns the corpus and
41588
+ * the export plan) and reaches this store through the five row methods
41589
+ * below, so the Retrain page and the export did not change.
41590
+ * - **Jobs.** A persisted state machine, a reconcile loop against the
41591
+ * provider, a cost guard, a daily orphan sweep and the retention rules.
41592
+ * - **The return flow.** Verified artefacts → Model Studio
41593
+ * (`custom-model-registry.importModelBundle`) → canary on cameras →
41594
+ * rollback. Nothing is ever registered automatically.
41595
+ *
41596
+ * Every method is `admin`.
41597
+ */
41598
+ /** A version WITH its frame list — what the export and a job read. */
41599
+ var TrainingDatasetVersionRowSchema = RetrainDatasetVersionSchema.omit({ frameCount: true }).extend({ frameIds: array(string()).max(2e4).readonly() });
41600
+ /** A base model a detector job can fine-tune, and the baseline it is judged against. */
41601
+ var TrainingBaseModelSchema = object({
41602
+ modelId: string(),
41603
+ label: string(),
41604
+ weights: string(),
41605
+ imgsz: number().int(),
41606
+ baselineOnnxUrl: string(),
41607
+ baselineFloors: record(string(), number()),
41608
+ /** The base the fleet runs most — the UI's default. */
41609
+ recommended: boolean()
41610
+ });
41611
+ var TrainingPresetSchema = _enum([
41612
+ "quick",
41613
+ "standard",
41614
+ "thorough"
41615
+ ]);
41616
+ var TrainingJobRequestSchema = object({
41617
+ datasetVersionId: string().min(1),
41618
+ /** The `training-provider` addon that runs it. */
41619
+ addonId: string().min(1),
41620
+ gpuType: string().min(1),
41621
+ region: string(),
41622
+ baseModelId: string().min(1),
41623
+ preset: TrainingPresetSchema,
41624
+ /** Freeze the backbone's first N layers; `null` = the preset's choice. */
41625
+ freeze: number().int().nonnegative().nullable(),
41626
+ /** Cameras held out whole for evaluation; `null` = the orchestrator's default. */
41627
+ holdoutCameras: array(number().int()).nullable()
41628
+ });
41629
+ var TrainingSplitPlanSchema = object({
41630
+ holdoutCameras: array(number().int()).readonly(),
41631
+ /** Used when no camera is held out: the last N days of every camera. */
41632
+ holdoutLastDays: number().int().nonnegative(),
41633
+ /** Holdout subjects per class (camera holdout only; `null` = known only after the split). */
41634
+ holdoutSupport: record(string(), number().int()).nullable(),
41635
+ trainSubjects: number().int()
41636
+ });
41637
+ var TrainingRefusalReasonSchema = _enum([
41638
+ "unknown-dataset",
41639
+ "unknown-provider",
41640
+ "provider-not-configured",
41641
+ "unknown-base-model",
41642
+ "unknown-gpu",
41643
+ "dataset-too-large",
41644
+ "no-training-subjects",
41645
+ "job-already-running"
41646
+ ]);
41647
+ var TrainingJobPlanSchema = object({
41648
+ refusal: object({
41649
+ reason: TrainingRefusalReasonSchema,
41650
+ detail: string()
41651
+ }).nullable(),
41652
+ warnings: array(string()).readonly(),
41653
+ split: TrainingSplitPlanSchema.nullable(),
41654
+ estimate: object({
41655
+ datasetBytes: number().int(),
41656
+ uploadMinutesAt20Mbps: number(),
41657
+ gpuSecondsLow: number(),
41658
+ gpuSecondsHigh: number(),
41659
+ usdLow: number(),
41660
+ usdHigh: number(),
41661
+ notes: array(string()).readonly()
41662
+ }).nullable(),
41663
+ /** Pre-filled from the provider's settings; the operator may lower or raise them. */
41664
+ defaults: object({
41665
+ maxCostUsd: number(),
41666
+ maxRuntimeSec: number().int()
41667
+ }).nullable(),
41668
+ /** The sentence the confirm dialog repeats: where the frames go and when they are deleted. */
41669
+ dataNotice: string()
41670
+ });
41671
+ /**
41672
+ * Orchestrator-owned states, persisted. `uploading` covers exporting the
41673
+ * archive (it is streamed, never staged). Terminal: `failed`, `cancelled`,
41674
+ * `lost`, `expired`, `discarded`. `registered` and `canary` are where a
41675
+ * result lives after the operator acted on it.
41676
+ */
41677
+ var TrainingJobStateSchema = _enum([
41678
+ "uploading",
41679
+ "submitted",
41680
+ "starting",
41681
+ "running",
41682
+ "collecting",
41683
+ "ready",
41684
+ "registered",
41685
+ "canary",
41686
+ "failed",
41687
+ "cancelling",
41688
+ "cancelled",
41689
+ "lost",
41690
+ "expired",
41691
+ "discarded"
41692
+ ]);
41693
+ var TrainingFailureReasonSchema = _enum([
41694
+ "cost-cap",
41695
+ "runtime-cap",
41696
+ "upload-failed",
41697
+ "submit-failed",
41698
+ "trainer-failed",
41699
+ "result-invalid",
41700
+ "checksum-mismatch",
41701
+ "fetch-failed",
41702
+ "provider-error",
41703
+ "hub-restart-during-upload"
41704
+ ]);
41705
+ var TrainingProgressPointSchema = object({
41706
+ epoch: number().int(),
41707
+ map50: number().nullable(),
41708
+ map50_95: number().nullable()
41709
+ });
41710
+ var TrainingCanarySchema = object({
41711
+ deviceIds: array(number().int()).readonly(),
41712
+ since: number(),
41713
+ /** Every override the canary replaced, exactly, so rollback restores it. */
41714
+ previous: array(object({
41715
+ deviceId: number().int(),
41716
+ nodeId: string(),
41717
+ deviceKey: string(),
41718
+ patch: object({
41719
+ modelId: string().optional(),
41720
+ settings: record(string(), unknown()).readonly().optional()
41721
+ }).nullable()
41722
+ })).readonly()
41723
+ });
41724
+ var TrainingJobSchema = object({
41725
+ id: string(),
41726
+ idempotencyKey: string(),
41727
+ name: string(),
41728
+ createdAt: number(),
41729
+ updatedAt: number(),
41730
+ state: TrainingJobStateSchema,
41731
+ stage: TrainingStageSchema.nullable(),
41732
+ failure: object({
41733
+ reason: TrainingFailureReasonSchema,
41734
+ stage: string().nullable(),
41735
+ detail: string()
41736
+ }).nullable(),
41737
+ request: TrainingJobRequestSchema,
41738
+ maxCostUsd: number().nonnegative(),
41739
+ maxRuntimeSec: number().int().positive(),
41740
+ trainer: TrainerSourceRefSchema,
41741
+ datasetLayout: RetrainExportLayoutSchema,
41742
+ dataset: object({
41743
+ bytes: number().int(),
41744
+ sha256: string(),
41745
+ uploadedAt: number()
41746
+ }).nullable(),
41747
+ split: TrainingSplitPlanSchema,
41748
+ provider: object({
41749
+ state: ProviderJobStateSchema.nullable(),
41750
+ providerJobId: string().nullable(),
41751
+ startedAt: number().nullable(),
41752
+ endedAt: number().nullable(),
41753
+ billedSeconds: number(),
41754
+ costUsd: number(),
41755
+ costIsEstimate: boolean(),
41756
+ lastPolledAt: number().nullable()
41757
+ }),
41758
+ progress: object({
41759
+ epoch: number().int().nullable(),
41760
+ epochs: number().int().nullable(),
41761
+ etaSec: number().nullable(),
41762
+ series: array(TrainingProgressPointSchema).readonly()
41763
+ }),
41764
+ /** The last lines of the job's output (≤ 200), newest last. Never frame paths. */
41765
+ logTail: array(string()).readonly(),
41766
+ logCursor: string().nullable(),
41767
+ artifacts: object({
41768
+ bundleBytes: number().int(),
41769
+ bundleSha256: string(),
41770
+ fetchedAt: number(),
41771
+ /** When the staged artefacts are deleted from the hub. */
41772
+ expiresAt: number()
41773
+ }).nullable(),
41774
+ /** When the provider-side copy of the frames was deleted; null while it exists. */
41775
+ cloudDatasetDeletedAt: number().nullable(),
41776
+ /** A failed job's dataset is kept until then (the provider's grace), then deleted. */
41777
+ cloudCleanupDueAt: number().nullable(),
41778
+ /** Model ids registered from this job (base, and int8 when kept). */
41779
+ registeredModelIds: array(string()).readonly(),
41780
+ canary: TrainingCanarySchema.nullable()
41781
+ });
41782
+ var IdInput = object({ id: string().min(1) });
41783
+ method(TrainingDatasetVersionRowSchema, object({ stored: boolean() }), {
41784
+ kind: "mutation",
41785
+ auth: "admin"
41786
+ }), 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() }), {
41787
+ kind: "mutation",
41788
+ auth: "admin"
41789
+ }), method(object({}), array(TrainingBaseModelSchema).readonly(), { auth: "admin" }), method(TrainingJobRequestSchema, TrainingJobPlanSchema, {
41790
+ auth: "admin",
41791
+ timeoutMs: 6e4
41792
+ }), method(TrainingJobRequestSchema.extend({
41793
+ name: string().min(1).max(120),
41794
+ maxCostUsd: number().positive(),
41795
+ maxRuntimeSec: number().int().positive(),
41796
+ idempotencyKey: string().min(8).max(80)
41797
+ }), discriminatedUnion("kind", [object({
41798
+ kind: literal("started"),
41799
+ job: TrainingJobSchema
41800
+ }), object({
41801
+ kind: literal("refused"),
41802
+ reason: TrainingRefusalReasonSchema,
41803
+ detail: string()
41804
+ })]), {
41805
+ kind: "mutation",
41806
+ auth: "admin",
41807
+ timeoutMs: 12e4
41808
+ }), method(object({}), array(TrainingJobSchema).readonly(), { auth: "admin" }), method(IdInput, TrainingJobSchema.nullable(), { auth: "admin" }), method(IdInput, TrainingJobSchema, {
41809
+ kind: "mutation",
41810
+ auth: "admin",
41811
+ timeoutMs: 12e4
41812
+ }), method(IdInput, TrainingResultSchema.nullable(), { auth: "admin" }), method(IdInput.extend({ canaryDeviceIds: array(number().int()).readonly() }), TrainingJobSchema, {
41813
+ kind: "mutation",
41814
+ auth: "admin",
41815
+ timeoutMs: 30 * 6e4
41816
+ }), method(IdInput.extend({ deviceIds: array(number().int()).min(1).readonly() }), TrainingJobSchema, {
41817
+ kind: "mutation",
41818
+ auth: "admin",
41819
+ timeoutMs: 12e4
41820
+ }), method(IdInput, TrainingJobSchema, {
41821
+ kind: "mutation",
41822
+ auth: "admin",
41823
+ timeoutMs: 12e4
41824
+ }), method(IdInput, TrainingJobSchema, {
41825
+ kind: "mutation",
41826
+ auth: "admin"
41827
+ });
40427
41828
  SOURCE_CAPS.filter((cap) => cap !== "switch" && cap !== "motion");
40428
41829
  Object.freeze({
40429
41830
  person: .5,
@@ -41047,6 +42448,12 @@ Object.freeze({
41047
42448
  addonId: null,
41048
42449
  access: "create"
41049
42450
  },
42451
+ "backup.checkBackupKey": {
42452
+ capName: "backup",
42453
+ capScope: "system",
42454
+ addonId: null,
42455
+ access: "create"
42456
+ },
41050
42457
  "backup.delete": {
41051
42458
  capName: "backup",
41052
42459
  capScope: "system",
@@ -41059,6 +42466,18 @@ Object.freeze({
41059
42466
  addonId: null,
41060
42467
  access: "delete"
41061
42468
  },
42469
+ "backup.disableEncryption": {
42470
+ capName: "backup",
42471
+ capScope: "system",
42472
+ addonId: null,
42473
+ access: "create"
42474
+ },
42475
+ "backup.getEncryption": {
42476
+ capName: "backup",
42477
+ capScope: "system",
42478
+ addonId: null,
42479
+ access: "view"
42480
+ },
41062
42481
  "backup.getEntries": {
41063
42482
  capName: "backup",
41064
42483
  capScope: "system",
@@ -41113,6 +42532,12 @@ Object.freeze({
41113
42532
  addonId: null,
41114
42533
  access: "create"
41115
42534
  },
42535
+ "backup.setupEncryption": {
42536
+ capName: "backup",
42537
+ capScope: "system",
42538
+ addonId: null,
42539
+ access: "create"
42540
+ },
41116
42541
  "backup.trigger": {
41117
42542
  capName: "backup",
41118
42543
  capScope: "system",
@@ -41665,6 +43090,12 @@ Object.freeze({
41665
43090
  addonId: null,
41666
43091
  access: "create"
41667
43092
  },
43093
+ "customModelRegistry.importModelBundle": {
43094
+ capName: "custom-model-registry",
43095
+ capScope: "system",
43096
+ addonId: null,
43097
+ access: "create"
43098
+ },
41668
43099
  "customModelRegistry.listModels": {
41669
43100
  capName: "custom-model-registry",
41670
43101
  capScope: "system",
@@ -43105,6 +44536,12 @@ Object.freeze({
43105
44536
  addonId: null,
43106
44537
  access: "view"
43107
44538
  },
44539
+ "keychainAdmin.acknowledgeReset": {
44540
+ capName: "keychain-admin",
44541
+ capScope: "system",
44542
+ addonId: null,
44543
+ access: "create"
44544
+ },
43108
44545
  "keychainAdmin.deleteOrphans": {
43109
44546
  capName: "keychain-admin",
43110
44547
  capScope: "system",
@@ -43141,6 +44578,12 @@ Object.freeze({
43141
44578
  addonId: null,
43142
44579
  access: "delete"
43143
44580
  },
44581
+ "keychainAdmin.resetReport": {
44582
+ capName: "keychain-admin",
44583
+ capScope: "system",
44584
+ addonId: null,
44585
+ access: "delete"
44586
+ },
43144
44587
  "keychainAdmin.reveal": {
43145
44588
  capName: "keychain-admin",
43146
44589
  capScope: "system",
@@ -43153,6 +44596,12 @@ Object.freeze({
43153
44596
  addonId: null,
43154
44597
  access: "create"
43155
44598
  },
44599
+ "keychainAdmin.setSystemSecret": {
44600
+ capName: "keychain-admin",
44601
+ capScope: "system",
44602
+ addonId: null,
44603
+ access: "create"
44604
+ },
43156
44605
  "keychainAdmin.status": {
43157
44606
  capName: "keychain-admin",
43158
44607
  capScope: "system",
@@ -44599,6 +46048,12 @@ Object.freeze({
44599
46048
  addonId: null,
44600
46049
  access: "create"
44601
46050
  },
46051
+ "pipelineAnalytics.createRetrainDatasetVersion": {
46052
+ capName: "pipeline-analytics",
46053
+ capScope: "device",
46054
+ addonId: null,
46055
+ access: "create"
46056
+ },
44602
46057
  "pipelineAnalytics.deleteDeviceEvents": {
44603
46058
  capName: "pipeline-analytics",
44604
46059
  capScope: "device",
@@ -44611,6 +46066,12 @@ Object.freeze({
44611
46066
  addonId: null,
44612
46067
  access: "delete"
44613
46068
  },
46069
+ "pipelineAnalytics.deleteRetrainDatasetVersion": {
46070
+ capName: "pipeline-analytics",
46071
+ capScope: "device",
46072
+ addonId: null,
46073
+ access: "delete"
46074
+ },
44614
46075
  "pipelineAnalytics.deleteTracks": {
44615
46076
  capName: "pipeline-analytics",
44616
46077
  capScope: "device",
@@ -44833,6 +46294,12 @@ Object.freeze({
44833
46294
  addonId: null,
44834
46295
  access: "view"
44835
46296
  },
46297
+ "pipelineAnalytics.listRetrainDatasetVersions": {
46298
+ capName: "pipeline-analytics",
46299
+ capScope: "device",
46300
+ addonId: null,
46301
+ access: "view"
46302
+ },
44836
46303
  "pipelineAnalytics.listRetrainFrames": {
44837
46304
  capName: "pipeline-analytics",
44838
46305
  capScope: "device",
@@ -44863,6 +46330,12 @@ Object.freeze({
44863
46330
  addonId: null,
44864
46331
  access: "view"
44865
46332
  },
46333
+ "pipelineAnalytics.offerRetrainArchive": {
46334
+ capName: "pipeline-analytics",
46335
+ capScope: "device",
46336
+ addonId: null,
46337
+ access: "create"
46338
+ },
44866
46339
  "pipelineAnalytics.ownersWithMedia": {
44867
46340
  capName: "pipeline-analytics",
44868
46341
  capScope: "device",
@@ -44875,6 +46348,12 @@ Object.freeze({
44875
46348
  addonId: null,
44876
46349
  access: "create"
44877
46350
  },
46351
+ "pipelineAnalytics.previewRetrainDataset": {
46352
+ capName: "pipeline-analytics",
46353
+ capScope: "device",
46354
+ addonId: null,
46355
+ access: "view"
46356
+ },
44878
46357
  "pipelineAnalytics.proposeRetrainAnnotations": {
44879
46358
  capName: "pipeline-analytics",
44880
46359
  capScope: "device",
@@ -45013,6 +46492,12 @@ Object.freeze({
45013
46492
  addonId: null,
45014
46493
  access: "create"
45015
46494
  },
46495
+ "pipelineAnalytics.verifyRetrainDatasetVersion": {
46496
+ capName: "pipeline-analytics",
46497
+ capScope: "device",
46498
+ addonId: null,
46499
+ access: "view"
46500
+ },
45016
46501
  "pipelineAnalytics.wipeAllAnalytics": {
45017
46502
  capName: "pipeline-analytics",
45018
46503
  capScope: "device",
@@ -47389,6 +48874,174 @@ Object.freeze({
47389
48874
  addonId: null,
47390
48875
  access: "view"
47391
48876
  },
48877
+ "training.canaryResult": {
48878
+ capName: "training",
48879
+ capScope: "system",
48880
+ addonId: null,
48881
+ access: "create"
48882
+ },
48883
+ "training.cancelJob": {
48884
+ capName: "training",
48885
+ capScope: "system",
48886
+ addonId: null,
48887
+ access: "create"
48888
+ },
48889
+ "training.discardResult": {
48890
+ capName: "training",
48891
+ capScope: "system",
48892
+ addonId: null,
48893
+ access: "create"
48894
+ },
48895
+ "training.findDatasetVersionIdByName": {
48896
+ capName: "training",
48897
+ capScope: "system",
48898
+ addonId: null,
48899
+ access: "view"
48900
+ },
48901
+ "training.getDatasetVersion": {
48902
+ capName: "training",
48903
+ capScope: "system",
48904
+ addonId: null,
48905
+ access: "view"
48906
+ },
48907
+ "training.getJob": {
48908
+ capName: "training",
48909
+ capScope: "system",
48910
+ addonId: null,
48911
+ access: "view"
48912
+ },
48913
+ "training.getJobResult": {
48914
+ capName: "training",
48915
+ capScope: "system",
48916
+ addonId: null,
48917
+ access: "view"
48918
+ },
48919
+ "training.listBaseModels": {
48920
+ capName: "training",
48921
+ capScope: "system",
48922
+ addonId: null,
48923
+ access: "view"
48924
+ },
48925
+ "training.listDatasetVersions": {
48926
+ capName: "training",
48927
+ capScope: "system",
48928
+ addonId: null,
48929
+ access: "view"
48930
+ },
48931
+ "training.listJobs": {
48932
+ capName: "training",
48933
+ capScope: "system",
48934
+ addonId: null,
48935
+ access: "view"
48936
+ },
48937
+ "training.planJob": {
48938
+ capName: "training",
48939
+ capScope: "system",
48940
+ addonId: null,
48941
+ access: "view"
48942
+ },
48943
+ "training.putDatasetVersion": {
48944
+ capName: "training",
48945
+ capScope: "system",
48946
+ addonId: null,
48947
+ access: "create"
48948
+ },
48949
+ "training.registerResult": {
48950
+ capName: "training",
48951
+ capScope: "system",
48952
+ addonId: null,
48953
+ access: "create"
48954
+ },
48955
+ "training.removeDatasetVersion": {
48956
+ capName: "training",
48957
+ capScope: "system",
48958
+ addonId: null,
48959
+ access: "delete"
48960
+ },
48961
+ "training.rollbackCanary": {
48962
+ capName: "training",
48963
+ capScope: "system",
48964
+ addonId: null,
48965
+ access: "create"
48966
+ },
48967
+ "training.startJob": {
48968
+ capName: "training",
48969
+ capScope: "system",
48970
+ addonId: null,
48971
+ access: "create"
48972
+ },
48973
+ "trainingProvider.cancelJob": {
48974
+ capName: "training-provider",
48975
+ capScope: "system",
48976
+ addonId: null,
48977
+ access: "create"
48978
+ },
48979
+ "trainingProvider.cleanupJob": {
48980
+ capName: "training-provider",
48981
+ capScope: "system",
48982
+ addonId: null,
48983
+ access: "create"
48984
+ },
48985
+ "trainingProvider.describe": {
48986
+ capName: "training-provider",
48987
+ capScope: "system",
48988
+ addonId: null,
48989
+ access: "view"
48990
+ },
48991
+ "trainingProvider.estimateJob": {
48992
+ capName: "training-provider",
48993
+ capScope: "system",
48994
+ addonId: null,
48995
+ access: "view"
48996
+ },
48997
+ "trainingProvider.getJob": {
48998
+ capName: "training-provider",
48999
+ capScope: "system",
49000
+ addonId: null,
49001
+ access: "view"
49002
+ },
49003
+ "trainingProvider.listJobEvents": {
49004
+ capName: "training-provider",
49005
+ capScope: "system",
49006
+ addonId: null,
49007
+ access: "view"
49008
+ },
49009
+ "trainingProvider.listJobs": {
49010
+ capName: "training-provider",
49011
+ capScope: "system",
49012
+ addonId: null,
49013
+ access: "view"
49014
+ },
49015
+ "trainingProvider.offerArtifact": {
49016
+ capName: "training-provider",
49017
+ capScope: "system",
49018
+ addonId: null,
49019
+ access: "create"
49020
+ },
49021
+ "trainingProvider.readResult": {
49022
+ capName: "training-provider",
49023
+ capScope: "system",
49024
+ addonId: null,
49025
+ access: "create"
49026
+ },
49027
+ "trainingProvider.submitJob": {
49028
+ capName: "training-provider",
49029
+ capScope: "system",
49030
+ addonId: null,
49031
+ access: "create"
49032
+ },
49033
+ "trainingProvider.uploadDataset": {
49034
+ capName: "training-provider",
49035
+ capScope: "system",
49036
+ addonId: null,
49037
+ access: "create"
49038
+ },
49039
+ "trainingProvider.validateCredentials": {
49040
+ capName: "training-provider",
49041
+ capScope: "system",
49042
+ addonId: null,
49043
+ access: "create"
49044
+ },
47392
49045
  "turnProvider.getTurnServers": {
47393
49046
  capName: "turn-provider",
47394
49047
  capScope: "system",
@@ -47413,12 +49066,6 @@ Object.freeze({
47413
49066
  addonId: null,
47414
49067
  access: "create"
47415
49068
  },
47416
- "userManagement.createApiKey": {
47417
- capName: "user-management",
47418
- capScope: "system",
47419
- addonId: null,
47420
- access: "create"
47421
- },
47422
49069
  "userManagement.createScopedToken": {
47423
49070
  capName: "user-management",
47424
49071
  capScope: "system",
@@ -47455,12 +49102,6 @@ Object.freeze({
47455
49102
  addonId: null,
47456
49103
  access: "view"
47457
49104
  },
47458
- "userManagement.linkExternalIdentity": {
47459
- capName: "user-management",
47460
- capScope: "system",
47461
- addonId: null,
47462
- access: "create"
47463
- },
47464
49105
  "userManagement.listApiKeys": {
47465
49106
  capName: "user-management",
47466
49107
  capScope: "system",
@@ -47563,12 +49204,6 @@ Object.freeze({
47563
49204
  addonId: null,
47564
49205
  access: "create"
47565
49206
  },
47566
- "userManagement.validateApiKey": {
47567
- capName: "user-management",
47568
- capScope: "system",
47569
- addonId: null,
47570
- access: "view"
47571
- },
47572
49207
  "userManagement.validateCredentials": {
47573
49208
  capName: "user-management",
47574
49209
  capScope: "system",
@@ -51710,6 +53345,11 @@ Object.freeze({
51710
53345
  form: "single",
51711
53346
  optional: false
51712
53347
  }],
53348
+ "training.canaryResult": [{
53349
+ name: "deviceIds",
53350
+ form: "array",
53351
+ optional: false
53352
+ }],
51713
53353
  "update.getStatus": [{
51714
53354
  name: "deviceId",
51715
53355
  form: "single",