@camstack/addon-provider-rtsp 1.2.123 → 1.2.124

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/dist/addon.js +1781 -132
  2. package/dist/addon.mjs +1781 -132
  3. package/package.json +1 -1
package/dist/addon.mjs CHANGED
@@ -5377,7 +5377,7 @@ var ZodIssueCode = {
5377
5377
  var ZodFirstPartyTypeKind;
5378
5378
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
5379
5379
  //#endregion
5380
- //#region ../types/dist/sleep-Cr5YOk3m.mjs
5380
+ //#region ../types/dist/sleep-r3RWkGVx.mjs
5381
5381
  /**
5382
5382
  * The audio chunk plane's byte format, and the ONE expansion from a coded
5383
5383
  * window to float samples (D455).
@@ -5494,7 +5494,7 @@ function isKeychainStoredField(field) {
5494
5494
  var SECRET_CLEAR = { $secretClear: true };
5495
5495
  /** The `'***'` token D634 redaction writes for non-admins. */
5496
5496
  var LEGACY_DEVICE_REDACTION = "***";
5497
- function isRecord$1(value) {
5497
+ function isRecord$2(value) {
5498
5498
  return typeof value === "object" && value !== null && !Array.isArray(value);
5499
5499
  }
5500
5500
  function makeSecretMarker(ref) {
@@ -5505,12 +5505,12 @@ function makeSecretMarker(ref) {
5505
5505
  }
5506
5506
  /** A stored marker: an object whose `$secret` is a non-empty string. */
5507
5507
  function isSecretMarker(value) {
5508
- if (!isRecord$1(value)) return false;
5508
+ if (!isRecord$2(value)) return false;
5509
5509
  const ref = value["$secret"];
5510
5510
  return typeof ref === "string" && ref.length > 0;
5511
5511
  }
5512
5512
  function isSecretClear(value) {
5513
- return isRecord$1(value) && value["$secretClear"] === true;
5513
+ return isRecord$2(value) && value["$secretClear"] === true;
5514
5514
  }
5515
5515
  /**
5516
5516
  * The UI view of a stored secret field value: a marker becomes "set", inline
@@ -6026,6 +6026,13 @@ function globalSecretScope() {
6026
6026
  function encodeSegment(value) {
6027
6027
  return encodeURIComponent(value);
6028
6028
  }
6029
+ function decodeSegment(value) {
6030
+ try {
6031
+ return decodeURIComponent(value);
6032
+ } catch {
6033
+ return null;
6034
+ }
6035
+ }
6029
6036
  /**
6030
6037
  * The field path of a value inside an array item, addressed by the item's id:
6031
6038
  * `arrayItemFieldPath('providers', 'authentik', 'clientSecret')` →
@@ -6034,6 +6041,75 @@ function encodeSegment(value) {
6034
6041
  function arrayItemFieldPath(arrayKey, itemId, fieldKey) {
6035
6042
  return `${arrayKey}[${encodeSegment(itemId)}].${fieldKey}`;
6036
6043
  }
6044
+ function parseScope(segments) {
6045
+ switch (segments[0]) {
6046
+ case "global": return {
6047
+ scope: GLOBAL_SCOPE,
6048
+ used: 1
6049
+ };
6050
+ case "node": {
6051
+ const nodeId = segments[1] !== void 0 ? decodeSegment(segments[1]) : null;
6052
+ return nodeId === null || nodeId.length === 0 ? null : {
6053
+ scope: {
6054
+ kind: "node",
6055
+ nodeId
6056
+ },
6057
+ used: 2
6058
+ };
6059
+ }
6060
+ case "device": {
6061
+ const raw = segments[1];
6062
+ if (raw === void 0 || !/^\d+$/.test(raw)) return null;
6063
+ return {
6064
+ scope: {
6065
+ kind: "device",
6066
+ deviceId: Number(raw)
6067
+ },
6068
+ used: 2
6069
+ };
6070
+ }
6071
+ case "integration": {
6072
+ const id = segments[1] !== void 0 ? decodeSegment(segments[1]) : null;
6073
+ return id === null || id.length === 0 ? null : {
6074
+ scope: {
6075
+ kind: "integration",
6076
+ integrationId: id
6077
+ },
6078
+ used: 2
6079
+ };
6080
+ }
6081
+ case "row": {
6082
+ const collection = segments[1] !== void 0 ? decodeSegment(segments[1]) : null;
6083
+ const rowId = segments[2] !== void 0 ? decodeSegment(segments[2]) : null;
6084
+ if (collection === null || rowId === null || collection.length === 0 || rowId.length === 0) return null;
6085
+ return {
6086
+ scope: {
6087
+ kind: "row",
6088
+ collection,
6089
+ rowId
6090
+ },
6091
+ used: 3
6092
+ };
6093
+ }
6094
+ default: return null;
6095
+ }
6096
+ }
6097
+ /** Take a ref apart; `null` when it is not a well-formed ref. */
6098
+ function parseSecretRef(ref) {
6099
+ if (!ref.startsWith("secret://")) return null;
6100
+ const segments = ref.slice(9).split("/");
6101
+ const owner = segments[0] !== void 0 ? decodeSegment(segments[0]) : null;
6102
+ if (owner === null || owner.length === 0) return null;
6103
+ const parsed = parseScope(segments.slice(1));
6104
+ if (parsed === null) return null;
6105
+ const fieldPath = segments.slice(1 + parsed.used).join("/");
6106
+ if (fieldPath.length === 0) return null;
6107
+ return {
6108
+ owner,
6109
+ scope: parsed.scope,
6110
+ fieldPath
6111
+ };
6112
+ }
6037
6113
  /** A write to a secret path could not be stored in the keychain, so it was refused. */
6038
6114
  var KeychainWriteRefusedError = class extends Error {
6039
6115
  fieldPath;
@@ -6044,7 +6120,7 @@ var KeychainWriteRefusedError = class extends Error {
6044
6120
  }
6045
6121
  };
6046
6122
  var KEEP = { kind: "keep" };
6047
- function isRecord(value) {
6123
+ function isRecord$1(value) {
6048
6124
  return typeof value === "object" && value !== null && !Array.isArray(value);
6049
6125
  }
6050
6126
  function defaultMintId() {
@@ -6057,7 +6133,7 @@ function collectSecretMarkerRefs(value, out = []) {
6057
6133
  return out;
6058
6134
  }
6059
6135
  if (Array.isArray(value)) for (const item of value) collectSecretMarkerRefs(item, out);
6060
- else if (isRecord(value)) for (const child of Object.values(value)) collectSecretMarkerRefs(child, out);
6136
+ else if (isRecord$1(value)) for (const child of Object.values(value)) collectSecretMarkerRefs(child, out);
6061
6137
  return out;
6062
6138
  }
6063
6139
  async function storedValueEquals(secrets, marker, candidate) {
@@ -6112,7 +6188,7 @@ function rowId(row, idKey) {
6112
6188
  return null;
6113
6189
  }
6114
6190
  async function writeArray(ctx, node, incoming, stored, fieldPath) {
6115
- const storedRows = Array.isArray(stored) ? stored.filter(isRecord) : [];
6191
+ const storedRows = Array.isArray(stored) ? stored.filter(isRecord$1) : [];
6116
6192
  if (!Array.isArray(incoming)) {
6117
6193
  ctx.deletes.push(...collectSecretMarkerRefs(storedRows));
6118
6194
  return {
@@ -6128,7 +6204,7 @@ async function writeArray(ctx, node, incoming, stored, fieldPath) {
6128
6204
  const kept = /* @__PURE__ */ new Set();
6129
6205
  const rows = [];
6130
6206
  for (const row of incoming) {
6131
- if (!isRecord(row)) {
6207
+ if (!isRecord$1(row)) {
6132
6208
  rows.push(row);
6133
6209
  continue;
6134
6210
  }
@@ -6153,7 +6229,7 @@ async function writeNode(ctx, node, incoming, stored, fieldPath) {
6153
6229
  case "leaf": return writeLeaf(ctx, incoming, stored, fieldPath);
6154
6230
  case "array": return writeArray(ctx, node, incoming, stored, fieldPath);
6155
6231
  case "object": {
6156
- if (!isRecord(incoming)) {
6232
+ if (!isRecord$1(incoming)) {
6157
6233
  if (incoming === void 0) return KEEP;
6158
6234
  ctx.deletes.push(...collectSecretMarkerRefs(stored));
6159
6235
  return {
@@ -6161,7 +6237,7 @@ async function writeNode(ctx, node, incoming, stored, fieldPath) {
6161
6237
  value: incoming
6162
6238
  };
6163
6239
  }
6164
- const storedObj = isRecord(stored) ? stored : {};
6240
+ const storedObj = isRecord$1(stored) ? stored : {};
6165
6241
  return {
6166
6242
  kind: "value",
6167
6243
  value: await writeMembers(ctx, node.children, incoming, storedObj, (m) => `${fieldPath}.${m}`)
@@ -6220,12 +6296,19 @@ async function transformSecretWrite(input) {
6220
6296
  }
6221
6297
  };
6222
6298
  }
6299
+ /** Is `ref` one of `owner`'s refs? */
6300
+ function isSecretRefOwnedBy(ref, owner) {
6301
+ return parseSecretRef(ref)?.owner === owner;
6302
+ }
6223
6303
  /**
6224
6304
  * Replace every marker in `value` with its keychain value. Returns the SAME
6225
6305
  * reference when there is no marker (no allocation, no keychain call).
6226
6306
  */
6227
- async function resolveSecretMarkers(value, secrets) {
6228
- const refs = collectSecretMarkerRefs(value);
6307
+ async function resolveSecretMarkers(value, secrets, options = {}) {
6308
+ const keepMarker = options.unresolved === "keep-marker";
6309
+ const owner = options.ownedBy;
6310
+ const inScope = (ref) => owner === void 0 || isSecretRefOwnedBy(ref, owner);
6311
+ const refs = collectSecretMarkerRefs(value).filter(inScope);
6229
6312
  if (refs.length === 0) return {
6230
6313
  value,
6231
6314
  unresolved: []
@@ -6249,10 +6332,18 @@ async function resolveSecretMarkers(value, secrets) {
6249
6332
  }
6250
6333
  const substitute = (v) => {
6251
6334
  if (isSecretMarker(v)) {
6335
+ if (!inScope(v.$secret)) return {
6336
+ keep: true,
6337
+ value: v
6338
+ };
6252
6339
  const answer = answers[v.$secret];
6253
- return answer?.kind === "value" ? {
6340
+ if (answer?.kind === "value") return {
6254
6341
  keep: true,
6255
6342
  value: answer.value
6343
+ };
6344
+ return keepMarker ? {
6345
+ keep: true,
6346
+ value: v
6256
6347
  } : {
6257
6348
  keep: false,
6258
6349
  value: void 0
@@ -6269,7 +6360,7 @@ async function resolveSecretMarkers(value, secrets) {
6269
6360
  value: items
6270
6361
  };
6271
6362
  }
6272
- if (isRecord(v)) {
6363
+ if (isRecord$1(v)) {
6273
6364
  const out = {};
6274
6365
  for (const [k, child] of Object.entries(v)) {
6275
6366
  const s = substitute(child);
@@ -6290,14 +6381,152 @@ async function resolveSecretMarkers(value, secrets) {
6290
6381
  unresolved
6291
6382
  };
6292
6383
  }
6293
- function touchesTree(tree, patch) {
6294
- if (tree.size === 0) return false;
6295
- for (const key of Object.keys(patch)) {
6296
- const at = key.indexOf("@");
6297
- if (tree.has(at > 0 ? key.slice(0, at) : key)) return true;
6384
+ /** An addon tried to replace a stored secret it could not read. Nothing was written. */
6385
+ var SecretOverwriteRefusedError = class extends Error {
6386
+ ref;
6387
+ reason;
6388
+ constructor(ref, reason) {
6389
+ 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.`);
6390
+ this.ref = ref;
6391
+ this.reason = reason;
6392
+ this.name = "SecretOverwriteRefusedError";
6393
+ }
6394
+ };
6395
+ function isRecord(value) {
6396
+ return typeof value === "object" && value !== null && !Array.isArray(value);
6397
+ }
6398
+ function resolvedValue(pass, marker) {
6399
+ const answer = pass.answers[marker.$secret];
6400
+ return answer?.kind === "value" ? answer.value : null;
6401
+ }
6402
+ async function atMarker(pass, incoming, stored) {
6403
+ if (incoming === null) return stored;
6404
+ if (typeof incoming !== "string") return incoming;
6405
+ if (incoming === resolvedValue(pass, stored)) return stored;
6406
+ const intent = classifySecretWrite(incoming);
6407
+ if (intent.kind !== "set") return stored;
6408
+ const ref = stored.$secret;
6409
+ if (!isSecretRefOwnedBy(ref, pass.secrets.owner)) return incoming;
6410
+ const answer = pass.answers[ref];
6411
+ 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);
6412
+ try {
6413
+ await pass.secrets.put(ref, intent.value);
6414
+ } catch (err) {
6415
+ throw new KeychainWriteRefusedError(ref, err);
6416
+ }
6417
+ pass.changedRefs.push(ref);
6418
+ return stored;
6419
+ }
6420
+ function inArray(pass, incoming, stored) {
6421
+ return incoming.map((item, index) => {
6422
+ const twin = stored[index];
6423
+ if (isSecretMarker(twin)) return typeof item === "string" && item === resolvedValue(pass, twin) ? twin : item;
6424
+ if (isRecord(item) && isRecord(twin)) return inArrayRow(pass, item, twin);
6425
+ if (Array.isArray(item) && Array.isArray(twin)) return inArray(pass, item, twin);
6426
+ return item;
6427
+ });
6428
+ }
6429
+ function inArrayRow(pass, incoming, stored) {
6430
+ const out = { ...incoming };
6431
+ for (const [key, value] of Object.entries(incoming)) {
6432
+ const twin = stored[key];
6433
+ if (isSecretMarker(twin)) {
6434
+ if (typeof value === "string" && value === resolvedValue(pass, twin)) out[key] = twin;
6435
+ } else if (isRecord(value) && isRecord(twin)) out[key] = inArrayRow(pass, value, twin);
6436
+ else if (Array.isArray(value) && Array.isArray(twin)) out[key] = inArray(pass, value, twin);
6437
+ }
6438
+ return out;
6439
+ }
6440
+ async function walk(pass, incoming, stored) {
6441
+ if (isSecretMarker(stored)) return atMarker(pass, incoming, stored);
6442
+ if (Array.isArray(incoming) && Array.isArray(stored)) return inArray(pass, incoming, stored);
6443
+ if (!isRecord(incoming) || !isRecord(stored)) return incoming;
6444
+ const out = { ...incoming };
6445
+ for (const [key, value] of Object.entries(incoming)) out[key] = await walk(pass, value, stored[key]);
6446
+ return out;
6447
+ }
6448
+ /** Restore markers a write-back carries as values. See the file doc. */
6449
+ async function restoreUnchangedSecrets(input) {
6450
+ const refs = [];
6451
+ for (const key of Object.keys(input.patch)) collectSecretMarkerRefs(input.stored[key], refs);
6452
+ const owned = refs.filter((ref) => isSecretRefOwnedBy(ref, input.secrets.owner));
6453
+ if (owned.length === 0) return {
6454
+ patch: input.patch,
6455
+ changedRefs: []
6456
+ };
6457
+ const pass = {
6458
+ secrets: input.secrets,
6459
+ answers: await input.secrets.resolve([...new Set(owned)]),
6460
+ operatorWrite: input.operatorWrite,
6461
+ changedRefs: []
6462
+ };
6463
+ const out = {};
6464
+ for (const [key, value] of Object.entries(input.patch)) out[key] = await walk(pass, value, input.stored[key]);
6465
+ return {
6466
+ patch: out,
6467
+ changedRefs: pass.changedRefs
6468
+ };
6469
+ }
6470
+ /** Structural equality over JSON-shaped values (key order does not matter). */
6471
+ function isJsonEqual(a, b) {
6472
+ if (Object.is(a, b)) return true;
6473
+ if (Array.isArray(a)) return Array.isArray(b) && a.length === b.length && a.every((v, i) => isJsonEqual(v, b[i]));
6474
+ if (isRecord(a) && isRecord(b)) {
6475
+ const keys = Object.keys(a);
6476
+ if (keys.length !== Object.keys(b).length) return false;
6477
+ return keys.every((k) => Object.prototype.hasOwnProperty.call(b, k) && isJsonEqual(a[k], b[k]));
6298
6478
  }
6299
6479
  return false;
6300
6480
  }
6481
+ /** The patch without the keys whose value already equals the stored one. */
6482
+ function dropUnchangedKeys(patch, stored) {
6483
+ const out = {};
6484
+ for (const [key, value] of Object.entries(patch)) {
6485
+ if (Object.prototype.hasOwnProperty.call(stored, key) && isJsonEqual(value, stored[key])) continue;
6486
+ out[key] = value;
6487
+ }
6488
+ return out;
6489
+ }
6490
+ /** The top-level keys of a blob that hold at least one of `owner`'s markers. */
6491
+ function markerKeysOf(blob, owner) {
6492
+ const keys = /* @__PURE__ */ new Set();
6493
+ for (const [key, value] of Object.entries(blob)) if (collectSecretMarkerRefs(value).some((ref) => isSecretRefOwnedBy(ref, owner))) keys.add(key);
6494
+ return keys;
6495
+ }
6496
+ function nodeFromStored(value, owner) {
6497
+ if (isSecretMarker(value)) return isSecretRefOwnedBy(value.$secret, owner) ? { kind: "leaf" } : null;
6498
+ if (!isRecord(value)) return null;
6499
+ const children = /* @__PURE__ */ new Map();
6500
+ for (const [key, child] of Object.entries(value)) {
6501
+ const node = nodeFromStored(child, owner);
6502
+ if (node !== null) children.set(key, node);
6503
+ }
6504
+ return children.size > 0 ? {
6505
+ kind: "object",
6506
+ children
6507
+ } : null;
6508
+ }
6509
+ /**
6510
+ * The declared secret tree, widened by every place the STORED blob holds a
6511
+ * marker under one of `keys` — so a marker the schema no longer declares (or
6512
+ * never declared: Wyze before b4906cec6) still gets the save path's
6513
+ * KEEP / SET / CLEAR semantics instead of being overwritten by whatever the
6514
+ * addon writes. Markers inside arrays are not added: a row has no id field to
6515
+ * match by unless the schema declares one. Only `owner`'s markers count: a
6516
+ * builtin that keeps another addon's marker (device-manager) never takes it
6517
+ * over.
6518
+ */
6519
+ function widenTreeWithStoredMarkers(declared, stored, keys, owner) {
6520
+ const added = /* @__PURE__ */ new Map();
6521
+ for (const key of keys) {
6522
+ const at = key.indexOf("@");
6523
+ const base = at > 0 ? key.slice(0, at) : key;
6524
+ if (declared.has(base) || added.has(base)) continue;
6525
+ const node = nodeFromStored(stored[key], owner);
6526
+ if (node !== null) added.set(base, node);
6527
+ }
6528
+ return added.size === 0 ? declared : new Map([...declared, ...added]);
6529
+ }
6301
6530
  /** The blob as stored now; a failed read REFUSES the write instead of guessing. */
6302
6531
  async function readStoredAddonBlob(raw) {
6303
6532
  const threeWay = raw.readAddonStoreResult;
@@ -6306,7 +6535,41 @@ async function readStoredAddonBlob(raw) {
6306
6535
  if (result.kind === "failed") throw new Error(`settings write refused: the stored blob could not be read (${result.error})`);
6307
6536
  return result.kind === "missing" ? {} : result.value;
6308
6537
  }
6309
- function createSecretAwareSettings(raw, opts) {
6538
+ function touchesTree(tree, patch) {
6539
+ if (tree.size === 0) return false;
6540
+ for (const key of Object.keys(patch)) {
6541
+ const at = key.indexOf("@");
6542
+ if (tree.has(at > 0 ? key.slice(0, at) : key)) return true;
6543
+ }
6544
+ return false;
6545
+ }
6546
+ /**
6547
+ * Which top-level keys of each store held markers when last seen. `undefined`
6548
+ * for a store not seen yet: its first write reads it, to be safe.
6549
+ */
6550
+ var MarkerKeyIndex = class {
6551
+ owner;
6552
+ byStore = /* @__PURE__ */ new Map();
6553
+ constructor(owner) {
6554
+ this.owner = owner;
6555
+ }
6556
+ seen(store, blob) {
6557
+ this.byStore.set(store, markerKeysOf(blob, this.owner));
6558
+ }
6559
+ wrote(store, patch) {
6560
+ const keys = this.byStore.get(store);
6561
+ if (keys === void 0) return;
6562
+ const now = markerKeysOf(patch, this.owner);
6563
+ for (const key of Object.keys(patch)) if (now.has(key)) keys.add(key);
6564
+ else keys.delete(key);
6565
+ }
6566
+ mayHoldMarkers(store, patch) {
6567
+ const keys = this.byStore.get(store);
6568
+ if (keys === void 0) return true;
6569
+ return Object.keys(patch).some((key) => keys.has(key));
6570
+ }
6571
+ };
6572
+ function createHandle(raw, opts) {
6310
6573
  const chains = /* @__PURE__ */ new Map();
6311
6574
  const serialize = (key, fn) => {
6312
6575
  const next = (chains.get(key) ?? Promise.resolve()).then(fn, fn);
@@ -6317,46 +6580,130 @@ function createSecretAwareSettings(raw, opts) {
6317
6580
  });
6318
6581
  return next;
6319
6582
  };
6320
- const write = async (chainKey, tree, scope, patch, readStored, rawWrite) => {
6321
- if (!touchesTree(tree, patch)) return rawWrite(patch);
6322
- return serialize(chainKey, async () => {
6583
+ const index = new MarkerKeyIndex(opts.secrets.owner);
6584
+ const resolveRead = async (store, blob) => {
6585
+ index.seen(store, blob);
6586
+ const { value, unresolved } = await resolveSecretMarkers(blob, opts.secrets, {
6587
+ unresolved: "keep-marker",
6588
+ ownedBy: opts.secrets.owner
6589
+ });
6590
+ if (unresolved.length > 0) opts.onUnresolved?.(unresolved);
6591
+ return value;
6592
+ };
6593
+ const write = async (store, declared, scope, patch, readStored, rawWrite) => {
6594
+ if (!touchesTree(declared, patch) && !index.mayHoldMarkers(store, patch)) {
6595
+ await rawWrite(patch);
6596
+ index.wrote(store, patch);
6597
+ return { changed: true };
6598
+ }
6599
+ return serialize(store, async () => {
6323
6600
  const stored = await readStored();
6601
+ index.seen(store, stored);
6602
+ const operatorWrite = opts.isOperatorWrite?.() === true;
6603
+ const restored = await restoreUnchangedSecrets({
6604
+ patch,
6605
+ stored,
6606
+ secrets: opts.secrets,
6607
+ operatorWrite
6608
+ });
6324
6609
  const result = await transformSecretWrite({
6325
- tree,
6610
+ tree: widenTreeWithStoredMarkers(declared, stored, Object.keys(restored.patch), opts.secrets.owner),
6326
6611
  secrets: opts.secrets,
6327
- patch,
6612
+ patch: restored.patch,
6328
6613
  stored,
6329
6614
  ...scope !== void 0 ? { scope } : {},
6330
- operatorWrite: opts.isOperatorWrite?.() === true
6615
+ operatorWrite
6331
6616
  });
6332
- if (Object.keys(result.patch).length > 0) await rawWrite(result.patch);
6617
+ const effective = dropUnchangedKeys(result.patch, stored);
6618
+ const wroteBlob = Object.keys(effective).length > 0;
6619
+ if (wroteBlob) {
6620
+ await rawWrite(effective);
6621
+ index.wrote(store, effective);
6622
+ }
6333
6623
  const { orphaned } = await result.afterWrite();
6334
6624
  if (orphaned.length > 0) opts.onOrphaned(orphaned);
6625
+ return { changed: wroteBlob || restored.changedRefs.length > 0 };
6335
6626
  });
6336
6627
  };
6337
- const wrapped = {
6338
- writeAddonStore: (patch) => write("addon", opts.addonTree(), void 0, patch, () => readStoredAddonBlob(raw), (p) => raw.writeAddonStore(p)),
6339
- writeDeviceStore: (deviceId, patch) => write(`device:${deviceId}`, opts.deviceTree(), {
6340
- kind: "device",
6341
- deviceId
6342
- }, patch, () => raw.readDeviceStore(deviceId), (p) => raw.writeDeviceStore(deviceId, p))
6628
+ const writeAddon = (patch) => write("addon", opts.addonTree(), void 0, patch, () => readStoredAddonBlob(raw), (p) => raw.writeAddonStore(p));
6629
+ const readAddonStoreResult = raw.readAddonStoreResult;
6630
+ const readAddonStoreKeyResult = raw.readAddonStoreKeyResult;
6631
+ const readDeviceStoreBatch = raw.readDeviceStoreBatch;
6632
+ const overrides = {
6633
+ readAddonStore: async () => resolveRead("addon", await raw.readAddonStore()),
6634
+ ...readAddonStoreResult !== void 0 ? { readAddonStoreResult: async () => {
6635
+ const result = await readAddonStoreResult.call(raw);
6636
+ return result.kind === "value" ? {
6637
+ kind: "value",
6638
+ value: await resolveRead("addon", result.value)
6639
+ } : result;
6640
+ } } : {},
6641
+ ...readAddonStoreKeyResult !== void 0 ? { readAddonStoreKeyResult: async (key) => {
6642
+ const result = await readAddonStoreKeyResult.call(raw, key);
6643
+ if (result.kind !== "present") return result;
6644
+ const { value, unresolved } = await resolveSecretMarkers({ [key]: result.value }, opts.secrets, {
6645
+ unresolved: "keep-marker",
6646
+ ownedBy: opts.secrets.owner
6647
+ });
6648
+ if (unresolved.length > 0) opts.onUnresolved?.(unresolved);
6649
+ return {
6650
+ kind: "present",
6651
+ value: value[key]
6652
+ };
6653
+ } } : {},
6654
+ readDeviceStore: async (deviceId) => resolveRead(`device:${deviceId}`, await raw.readDeviceStore(deviceId)),
6655
+ ...readDeviceStoreBatch !== void 0 ? { readDeviceStoreBatch: async (deviceIds) => {
6656
+ const rows = await readDeviceStoreBatch.call(raw, deviceIds);
6657
+ const out = /* @__PURE__ */ new Map();
6658
+ for (const [deviceId, blob] of rows) out.set(deviceId, await resolveRead(`device:${deviceId}`, blob));
6659
+ return out;
6660
+ } } : {},
6661
+ writeAddonStore: async (patch) => {
6662
+ await writeAddon(patch);
6663
+ },
6664
+ writeDeviceStore: async (deviceId, patch) => {
6665
+ await write(`device:${deviceId}`, opts.deviceTree(), {
6666
+ kind: "device",
6667
+ deviceId
6668
+ }, patch, () => raw.readDeviceStore(deviceId), (p) => raw.writeDeviceStore(deviceId, p));
6669
+ }
6670
+ };
6671
+ return {
6672
+ settings: new Proxy(raw, { get(target, prop, receiver) {
6673
+ if (typeof prop === "string" && Object.prototype.hasOwnProperty.call(overrides, prop)) return Reflect.get(overrides, prop);
6674
+ const value = Reflect.get(target, prop, receiver);
6675
+ return typeof value === "function" ? value.bind(target) : value;
6676
+ } }),
6677
+ raw: {
6678
+ readAddonStore: async () => {
6679
+ const blob = await raw.readAddonStore();
6680
+ index.seen("addon", blob);
6681
+ return blob;
6682
+ },
6683
+ readDeviceStore: async (deviceId) => {
6684
+ const blob = await raw.readDeviceStore(deviceId);
6685
+ index.seen(`device:${deviceId}`, blob);
6686
+ return blob;
6687
+ }
6688
+ },
6689
+ writeAddonStore: writeAddon
6343
6690
  };
6344
- return new Proxy(raw, { get(target, prop, receiver) {
6345
- if (prop === "writeAddonStore") return wrapped.writeAddonStore;
6346
- if (prop === "writeDeviceStore") return wrapped.writeDeviceStore;
6347
- const value = Reflect.get(target, prop, receiver);
6348
- return typeof value === "function" ? value.bind(target) : value;
6349
- } });
6350
6691
  }
6351
- /** The context the addon sees: identical, except that its settings writes are secret-aware. */
6352
- function withSecretAwareSettings(context, opts) {
6692
+ /** The context the addon sees, plus the private raw view and write outcome. */
6693
+ function createSecretAwareContext(context, opts) {
6353
6694
  const raw = context.settings;
6354
- if (raw === void 0) return context;
6355
- const settings = createSecretAwareSettings(raw, opts);
6356
- return new Proxy(context, { get(target, prop, receiver) {
6357
- if (prop === "settings") return settings;
6358
- return Reflect.get(target, prop, receiver);
6359
- } });
6695
+ if (raw === void 0) return {
6696
+ context,
6697
+ handle: null
6698
+ };
6699
+ const handle = createHandle(raw, opts);
6700
+ return {
6701
+ context: new Proxy(context, { get(target, prop, receiver) {
6702
+ if (prop === "settings") return handle.settings;
6703
+ return Reflect.get(target, prop, receiver);
6704
+ } }),
6705
+ handle
6706
+ };
6360
6707
  }
6361
6708
  var LEAF = { kind: "leaf" };
6362
6709
  var DEFAULT_ITEM_ID_KEY = "id";
@@ -6531,6 +6878,14 @@ var BaseAddon = class {
6531
6878
  _secretChangeUnsub = null;
6532
6879
  /** >0 while an OPERATOR's settings write is being applied. */
6533
6880
  _operatorWriteDepth = 0;
6881
+ /**
6882
+ * The keychain-aware settings handle (D798). Its `raw` view is the ONLY way
6883
+ * to the marker-bearing blobs and stays private to this class: the form
6884
+ * hydrate and config resolution need markers, addon code never does.
6885
+ */
6886
+ _secretSettings = null;
6887
+ /** Refs an addon-facing read could not resolve — each is logged once per process. */
6888
+ _loggedUnresolvedReads = /* @__PURE__ */ new Set();
6534
6889
  constructor(defaults) {
6535
6890
  this.defaults = defaults;
6536
6891
  this._config = { ...defaults };
@@ -6567,13 +6922,21 @@ var BaseAddon = class {
6567
6922
  }
6568
6923
  async initialize(context) {
6569
6924
  const secrets = context.secrets;
6570
- this._ctx = secrets !== void 0 ? withSecretAwareSettings(context, {
6571
- secrets,
6572
- addonTree: () => this.addonSecretTree(),
6573
- deviceTree: () => this.deviceSecretTree(),
6574
- onOrphaned: (refs) => context.logger.warn("keychain refs dropped by a settings write could not be deleted", { meta: { refs: [...refs] } }),
6575
- isOperatorWrite: () => this._operatorWriteDepth > 0
6576
- }) : context;
6925
+ if (secrets !== void 0) {
6926
+ const { context: wrapped, handle } = createSecretAwareContext(context, {
6927
+ secrets,
6928
+ addonTree: () => this.addonSecretTree(),
6929
+ deviceTree: () => this.deviceSecretTree(),
6930
+ onOrphaned: (refs) => context.logger.warn("keychain refs dropped by a settings write could not be deleted", { meta: { refs: [...refs] } }),
6931
+ isOperatorWrite: () => this._operatorWriteDepth > 0,
6932
+ onUnresolved: (unresolved) => this.logUnresolvedRead(unresolved)
6933
+ });
6934
+ this._ctx = wrapped;
6935
+ this._secretSettings = handle;
6936
+ } else {
6937
+ this._ctx = context;
6938
+ this._secretSettings = null;
6939
+ }
6577
6940
  await this.resolveConfig();
6578
6941
  if (secrets !== void 0) this._secretChangeUnsub = secrets.onChange((ref) => {
6579
6942
  if (this._configSecretRefs.has(ref)) this.scheduleSecretReresolve(SECRET_CHANGE_DEBOUNCE_MS);
@@ -6690,11 +7053,8 @@ var BaseAddon = class {
6690
7053
  async getGlobalSettings(overlay, cap, nodeId) {
6691
7054
  const schema = this.globalSettingsSchema(cap);
6692
7055
  if (!schema) return { sections: [] };
6693
- const projected = await this.resolveGlobalStore(nodeId, cap);
6694
- return hydrateSchema(schema, overlay ? {
6695
- ...projected,
6696
- ...overlay
6697
- } : projected, { inlineSecretsAsViews: true });
7056
+ const projected = await this.readRawProjectedStore(nodeId, cap);
7057
+ return hydrateSchema(schema, overlay ? await this.overlayKeepingMarkers(projected, overlay) : projected, { inlineSecretsAsViews: true });
6698
7058
  }
6699
7059
  /**
6700
7060
  * The integration-level view of this addon's settings: exactly the sections
@@ -6739,7 +7099,7 @@ var BaseAddon = class {
6739
7099
  });
6740
7100
  }
6741
7101
  if (sections.length === 0) return null;
6742
- const projected = await this.resolveGlobalStore(nodeId);
7102
+ const projected = await this.readRawProjectedStore(nodeId);
6743
7103
  return hydrateSchema({
6744
7104
  ...schema,
6745
7105
  sections
@@ -6756,12 +7116,50 @@ var BaseAddon = class {
6756
7116
  * the store for custom option logic (option narrowing, value snapping) to
6757
7117
  * read it per-node — never `ctx.settings.readAddonStore()` directly.
6758
7118
  * `nodeId` omitted ⇒ the local node (node-blind injection from ctx).
7119
+ *
7120
+ * Keychain values come back RESOLVED (D798): a secret reads as its value,
7121
+ * never as a `{ $secret }` marker. One the keychain cannot serve right now
7122
+ * stays a marker — "stored, unavailable" (`isSecretMarker()` is true, and it
7123
+ * is listed in {@link unresolvedSecrets}) — never `''` and never absent, so
7124
+ * it cannot be mistaken for "nothing stored, mint a new one". Writing the
7125
+ * resolved blob back is a no-op for every unchanged secret.
6759
7126
  */
6760
7127
  async resolveGlobalStore(nodeId, cap) {
6761
7128
  const raw = await this._ctx?.settings?.readAddonStore() ?? {};
7129
+ return this.projectForNode(raw, nodeId, cap);
7130
+ }
7131
+ projectForNode(store, nodeId, cap) {
6762
7132
  const keys = this.perNodeKeys(cap);
6763
7133
  const node = normalizeNodeId(nodeId ?? this._ctx?.kernel?.localNodeId);
6764
- return keys.size > 0 ? projectStore(raw, keys, node) : raw;
7134
+ return keys.size > 0 ? projectStore(store, keys, node) : store;
7135
+ }
7136
+ /** The PROJECTED store with its markers — the form hydrate only (D798). */
7137
+ async readRawProjectedStore(nodeId, cap) {
7138
+ const raw = await this.rawSettings()?.readAddonStore() ?? {};
7139
+ return this.projectForNode(raw, nodeId, cap);
7140
+ }
7141
+ /**
7142
+ * `{ ...stored, ...overlay }`, except that an overlay member equal to the
7143
+ * RESOLVED stored one keeps the stored (marker-bearing) member — so a form
7144
+ * hydrated from a resolved overlay still shows a secret as "set", never as
7145
+ * its value.
7146
+ */
7147
+ async overlayKeepingMarkers(stored, overlay) {
7148
+ const secrets = this._ctx?.secrets;
7149
+ const merged = {
7150
+ ...stored,
7151
+ ...overlay
7152
+ };
7153
+ if (secrets === void 0 || collectSecretMarkerRefs(stored).length === 0) return merged;
7154
+ const { value: resolved } = await resolveSecretMarkers(stored, secrets, {
7155
+ unresolved: "keep-marker",
7156
+ ownedBy: secrets.owner
7157
+ });
7158
+ for (const key of Object.keys(overlay)) {
7159
+ if (collectSecretMarkerRefs(stored[key]).length === 0) continue;
7160
+ if (isJsonEqual(overlay[key], resolved[key])) merged[key] = stored[key];
7161
+ }
7162
+ return merged;
6765
7163
  }
6766
7164
  /**
6767
7165
  * Whether ONE global key of this addon's store was written, read three-way
@@ -6826,8 +7224,12 @@ var BaseAddon = class {
6826
7224
  async clearSecrets(keys, nodeId) {
6827
7225
  const tree = this.addonSecretTree();
6828
7226
  const keychain = this._ctx?.secrets !== void 0;
7227
+ const stored = keychain ? await this.readAddonStoreWithRetry() : {};
6829
7228
  const patch = {};
6830
- for (const key of keys) patch[key] = keychain && tree.has(key) ? SECRET_CLEAR : "";
7229
+ for (const key of keys) {
7230
+ const keychainStored = tree.has(key) || collectSecretMarkerRefs(stored[key]).length > 0;
7231
+ patch[key] = keychain && keychainStored ? SECRET_CLEAR : "";
7232
+ }
6831
7233
  await this.applyGlobalPatch(patch, nodeId);
6832
7234
  }
6833
7235
  async applyGlobalPatch(barePatch, nodeId) {
@@ -6835,7 +7237,11 @@ var BaseAddon = class {
6835
7237
  const localNode = normalizeNodeId(this._ctx?.kernel?.localNodeId);
6836
7238
  const target = normalizeNodeId(nodeId ?? this._ctx?.kernel?.localNodeId);
6837
7239
  const scoped = keys.size > 0 ? scopePatch(barePatch, keys, target) : barePatch;
6838
- await this._ctx?.settings?.writeAddonStore(scoped);
7240
+ const handle = this._secretSettings;
7241
+ if (handle !== null) {
7242
+ const { changed } = await handle.writeAddonStore(scoped);
7243
+ if (!changed) return;
7244
+ } else await this._ctx?.settings?.writeAddonStore(scoped);
6839
7245
  if (target !== localNode) return;
6840
7246
  await this.resolveConfig();
6841
7247
  await this.onConfigChanged();
@@ -6888,7 +7294,7 @@ var BaseAddon = class {
6888
7294
  async getDeviceSettings(deviceId) {
6889
7295
  const schema = this.deviceSettingsSchema();
6890
7296
  if (!schema) return { sections: [] };
6891
- return hydrateSchema(schema, await this._ctx?.settings?.readDeviceStore(deviceId) ?? {}, { inlineSecretsAsViews: true });
7297
+ return hydrateSchema(schema, await this.rawSettings()?.readDeviceStore(deviceId) ?? {}, { inlineSecretsAsViews: true });
6892
7298
  }
6893
7299
  async updateDeviceSettings(deviceId, patch) {
6894
7300
  await this._ctx?.settings?.writeDeviceStore(deviceId, patch);
@@ -7060,7 +7466,7 @@ var BaseAddon = class {
7060
7466
  key,
7061
7467
  schema,
7062
7468
  fallback,
7063
- read: async () => this.resolveStoredSecrets(await this._ctx?.settings?.readDeviceStore(deviceId) ?? {}, false),
7469
+ read: async () => this.resolveStoredSecrets(await this.rawSettings()?.readDeviceStore(deviceId) ?? {}, false),
7064
7470
  write: async (patch) => {
7065
7471
  await this._ctx?.settings?.writeDeviceStore(deviceId, patch);
7066
7472
  },
@@ -7122,6 +7528,23 @@ var BaseAddon = class {
7122
7528
  }
7123
7529
  return value;
7124
7530
  }
7531
+ /**
7532
+ * The marker-bearing settings reads (D798) — private on purpose. Without a
7533
+ * keychain the context's own view is already raw.
7534
+ */
7535
+ rawSettings() {
7536
+ return this._secretSettings?.raw ?? this._ctx?.settings;
7537
+ }
7538
+ /** An addon-facing read met markers it could not resolve: say so once per ref. */
7539
+ logUnresolvedRead(unresolved) {
7540
+ const fresh = unresolved.filter((u) => !this._loggedUnresolvedReads.has(u.ref));
7541
+ if (fresh.length === 0) return;
7542
+ for (const u of fresh) this._loggedUnresolvedReads.add(u.ref);
7543
+ 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) => ({
7544
+ ref: u.ref,
7545
+ reason: u.reason
7546
+ })) } });
7547
+ }
7125
7548
  /** Re-resolve the config (a keychain-only change, or a retry) and apply it. */
7126
7549
  scheduleSecretReresolve(delayMs) {
7127
7550
  const timerOf = delayMs === SECRET_CHANGE_DEBOUNCE_MS ? "_secretChangeTimer" : "_secretRetryTimer";
@@ -7148,7 +7571,7 @@ var BaseAddon = class {
7148
7571
  * `{}` (defaults) — the addon's first successful patch will rehydrate.
7149
7572
  */
7150
7573
  async readAddonStoreWithRetry() {
7151
- const settings = this._ctx?.settings;
7574
+ const settings = this.rawSettings();
7152
7575
  if (!settings) return {};
7153
7576
  const delaysMs = [
7154
7577
  150,
@@ -9451,6 +9874,278 @@ var CameraSwitchGroupSchema = object({
9451
9874
  fetchedAt: number()
9452
9875
  });
9453
9876
  /**
9877
+ * The trainer contract — what the hub hands the cloud trainer and what it
9878
+ * gets back (cloud training, D805+).
9879
+ *
9880
+ * The trainer (`hf/camstack-trainer`, published as the Hugging Face repo
9881
+ * `camstack/camstack-trainer`) is a separate AGPL program the hub never
9882
+ * imports: `job.json` goes in, files come out, and progress is `CAMSTACK_EVENT`
9883
+ * lines on stdout. These schemas are the hub's half of that boundary; the
9884
+ * trainer's pydantic models (and the JSON Schemas generated from them under
9885
+ * `hf/camstack-trainer/schemas/`) are the other half. A change here is a
9886
+ * change there, in the same piece of work.
9887
+ *
9888
+ * No `.default()` anywhere: defaults do not run on the addon cap path, so the
9889
+ * orchestrator fills every field of a job spec explicitly.
9890
+ */
9891
+ var TRAINING_JOB_SCHEMA = "camstack.training/v1";
9892
+ var TRAINING_RESULT_SCHEMA = "camstack.training-result/v1";
9893
+ /** What the trainer can export. Edge TPU is a later, separate image. */
9894
+ var TrainingExportSchema = _enum([
9895
+ "onnx",
9896
+ "openvino-fp16",
9897
+ "openvino-int8",
9898
+ "coreml-fp16"
9899
+ ]);
9900
+ var FloorsSchema = record(string(), number().min(0).max(1));
9901
+ object({
9902
+ schema: literal(TRAINING_JOB_SCHEMA),
9903
+ jobKey: string().uuid(),
9904
+ target: object({
9905
+ kind: literal("detector"),
9906
+ step: literal("object-detection")
9907
+ }),
9908
+ base: object({
9909
+ modelId: string().min(1),
9910
+ /** Ultralytics weights id, e.g. `yolov9m.pt`. */
9911
+ weights: string().min(1),
9912
+ imgsz: number().int().positive()
9913
+ }),
9914
+ baseline: object({
9915
+ modelId: string().min(1),
9916
+ /** The baseline ONNX the holdout comparison runs; public mirror URL. */
9917
+ onnxUrl: string().url(),
9918
+ imgsz: number().int().positive(),
9919
+ floors: FloorsSchema
9920
+ }),
9921
+ dataset: object({
9922
+ versionId: string().min(1),
9923
+ annotationHash: string(),
9924
+ /** sha256 of the uploaded archive; the trainer refuses a mismatch (exit 65). */
9925
+ sha256: string().regex(/^[0-9a-f]{64}$/)
9926
+ }),
9927
+ split: object({
9928
+ holdoutCameras: array(number().int()),
9929
+ /** When no camera is held out: the last N days of every camera. */
9930
+ holdoutLastDays: number().int().nonnegative(),
9931
+ valFraction: number().min(0).max(.5),
9932
+ seed: number().int()
9933
+ }),
9934
+ hyper: object({
9935
+ epochs: number().int().positive(),
9936
+ batch: number().int().positive(),
9937
+ lr0: number().positive(),
9938
+ /** Layers frozen from the start of the backbone; 0 = none. */
9939
+ freeze: number().int().nonnegative(),
9940
+ patience: number().int().nonnegative(),
9941
+ seed: number().int()
9942
+ }),
9943
+ replay: object({
9944
+ source: literal("coco2017"),
9945
+ count: number().int().nonnegative()
9946
+ }),
9947
+ exports: array(TrainingExportSchema).min(1),
9948
+ calibration: object({ maxFrames: number().int().positive() }),
9949
+ floors: object({
9950
+ minSupport: number().int().positive(),
9951
+ clamp: number().min(0).max(1)
9952
+ }),
9953
+ int8Gate: object({ maxMap50Drop: number().min(0).max(1) }),
9954
+ catalog: object({
9955
+ id: string().regex(/^[a-z0-9][a-z0-9-]{2,80}$/),
9956
+ name: string().min(1).max(160)
9957
+ })
9958
+ });
9959
+ /** One regular file of the bundle. An mlpackage contributes one row per member. */
9960
+ var TrainingResultFileSchema = object({
9961
+ path: string().min(1),
9962
+ bytes: number().int().nonnegative(),
9963
+ sha256: string().regex(/^[0-9a-f]{64}$/),
9964
+ format: _enum([
9965
+ "onnx",
9966
+ "openvino",
9967
+ "coreml",
9968
+ "pt"
9969
+ ]),
9970
+ variant: _enum(["base", "int8"])
9971
+ });
9972
+ var DraftFormatSchema = object({
9973
+ /** RELATIVE path inside the bundle; the hub rewrites it to `camstack-local://`. */
9974
+ url: string().min(1),
9975
+ sizeMB: number().nonnegative(),
9976
+ isDirectory: boolean().optional(),
9977
+ files: array(string()).optional(),
9978
+ runtimes: array(literal("python")).optional(),
9979
+ revision: string().min(1)
9980
+ });
9981
+ /** The trainer's half of a catalog entry; the hub completes it (labels, licence, group). */
9982
+ var TrainingCatalogDraftSchema = object({
9983
+ id: string().min(1),
9984
+ name: string().min(1),
9985
+ description: string(),
9986
+ labels: array(unknown()),
9987
+ inputSize: object({
9988
+ width: number().int().positive(),
9989
+ height: number().int().positive()
9990
+ }),
9991
+ preprocessMode: literal("letterbox"),
9992
+ defaultClassFloors: FloorsSchema,
9993
+ formats: object({
9994
+ onnx: DraftFormatSchema.optional(),
9995
+ openvino: DraftFormatSchema.optional(),
9996
+ coreml: DraftFormatSchema.optional()
9997
+ })
9998
+ });
9999
+ /** One class of one model's holdout report (the eval harness's summary). */
10000
+ var TrainingEvalClassSchema = object({
10001
+ positives: number().int(),
10002
+ floor: number().nullable(),
10003
+ tp: number().int(),
10004
+ fp: number().int(),
10005
+ fn: number().int(),
10006
+ precision: number().nullable(),
10007
+ recall: number().nullable(),
10008
+ ap50: number().nullable(),
10009
+ recallByCamera: record(string(), number().nullable()).optional(),
10010
+ recallByLight: record(string(), number().nullable()).optional(),
10011
+ fpByCamera: record(string(), number()).optional(),
10012
+ smallFound: number().int().optional(),
10013
+ smallTotal: number().int().optional()
10014
+ }).passthrough();
10015
+ var TrainingEvalReportSchema = object({
10016
+ frames: number().int(),
10017
+ classes: record(string(), TrainingEvalClassSchema)
10018
+ }).passthrough();
10019
+ /**
10020
+ * A succeeded result carries every block; a failed one carries the error and
10021
+ * whatever was known by then — the other blocks are ABSENT, not null. The
10022
+ * orchestrator checks the blocks it needs before it trusts a success.
10023
+ */
10024
+ var TrainingResultSchema = object({
10025
+ schema: literal(TRAINING_RESULT_SCHEMA),
10026
+ jobKey: string(),
10027
+ status: _enum(["succeeded", "failed"]),
10028
+ error: object({
10029
+ stage: string(),
10030
+ code: string(),
10031
+ message: string()
10032
+ }).nullable(),
10033
+ trainer: object({
10034
+ version: string(),
10035
+ revision: string()
10036
+ }),
10037
+ toolchain: record(string(), string().nullable()),
10038
+ dataset: object({
10039
+ versionId: string(),
10040
+ annotationHash: string(),
10041
+ sha256: string(),
10042
+ frames: object({
10043
+ train: number().int(),
10044
+ val: number().int(),
10045
+ holdout: number().int()
10046
+ }),
10047
+ holdoutCameras: array(number().int()),
10048
+ replayImages: number().int()
10049
+ }).optional(),
10050
+ training: object({
10051
+ epochsRun: number().int(),
10052
+ bestEpoch: number().int(),
10053
+ bestMap50: number(),
10054
+ bestMap50_95: number(),
10055
+ seconds: number()
10056
+ }).optional(),
10057
+ evaluation: object({
10058
+ holdoutFrames: number().int(),
10059
+ baseline: TrainingEvalReportSchema.nullable(),
10060
+ candidate: TrainingEvalReportSchema.nullable(),
10061
+ candidateInt8: TrainingEvalReportSchema.nullable(),
10062
+ recallDeltaByCamera: record(string(), record(string(), number())).nullable(),
10063
+ map50: record(string(), number().nullable())
10064
+ }).optional(),
10065
+ floors: object({
10066
+ baseline: FloorsSchema,
10067
+ candidate: FloorsSchema,
10068
+ candidateInt8: FloorsSchema.nullable(),
10069
+ notes: array(string())
10070
+ }).optional(),
10071
+ int8: object({
10072
+ kept: boolean(),
10073
+ map50Fp16: number().nullable(),
10074
+ map50Int8: number().nullable(),
10075
+ reason: string().nullable()
10076
+ }).optional(),
10077
+ exportsDropped: array(object({
10078
+ export: string(),
10079
+ reason: string()
10080
+ })).optional(),
10081
+ files: array(TrainingResultFileSchema).optional(),
10082
+ bundle: object({
10083
+ path: literal("bundle.tar"),
10084
+ bytes: number().int().nonnegative(),
10085
+ sha256: string().regex(/^[0-9a-f]{64}$/)
10086
+ }).nullable().optional(),
10087
+ catalogDraft: object({
10088
+ base: TrainingCatalogDraftSchema,
10089
+ int8: TrainingCatalogDraftSchema.nullable()
10090
+ }).nullable().optional(),
10091
+ licence: string()
10092
+ });
10093
+ var TrainingStageSchema = _enum([
10094
+ "prepare",
10095
+ "replay",
10096
+ "train",
10097
+ "eval",
10098
+ "export",
10099
+ "package"
10100
+ ]);
10101
+ var EventBase = {
10102
+ v: literal(1),
10103
+ ts: number()
10104
+ };
10105
+ discriminatedUnion("type", [
10106
+ object({
10107
+ ...EventBase,
10108
+ type: literal("stage"),
10109
+ stage: TrainingStageSchema
10110
+ }),
10111
+ object({
10112
+ ...EventBase,
10113
+ type: literal("epoch"),
10114
+ epoch: number().int(),
10115
+ epochs: number().int(),
10116
+ boxLoss: number().nullable().optional(),
10117
+ map50: number().nullable().optional(),
10118
+ map50_95: number().nullable().optional(),
10119
+ etaSec: number().nullable().optional()
10120
+ }),
10121
+ object({
10122
+ ...EventBase,
10123
+ type: literal("metric"),
10124
+ name: string(),
10125
+ value: number()
10126
+ }),
10127
+ object({
10128
+ ...EventBase,
10129
+ type: literal("artifact"),
10130
+ path: string(),
10131
+ bytes: number(),
10132
+ sha256: string()
10133
+ }),
10134
+ object({
10135
+ ...EventBase,
10136
+ type: literal("done"),
10137
+ status: _enum(["succeeded", "failed"]),
10138
+ resultSha256: string().nullable().optional()
10139
+ }),
10140
+ object({
10141
+ ...EventBase,
10142
+ type: literal("error"),
10143
+ stage: string(),
10144
+ code: string(),
10145
+ message: string()
10146
+ })
10147
+ ]);
10148
+ /**
9454
10149
  * What the gate decided about a birth, from the CALLER's point of view.
9455
10150
  *
9456
10151
  * Deliberately not `ConfirmationVerdict`: `undecided` is not a birth decision
@@ -11810,7 +12505,9 @@ var AddonHttpRouteSchema = object({
11810
12505
  "authenticated",
11811
12506
  "admin"
11812
12507
  ]).optional(),
11813
- description: string().optional()
12508
+ description: string().optional(),
12509
+ /** The hub limits this route per client address before the handler runs. */
12510
+ rateLimit: _enum(["auth"]).optional()
11814
12511
  });
11815
12512
  /**
11816
12513
  * Cross-process route invocation envelope. The hub captures the
@@ -12515,6 +13212,37 @@ var BackupDestinationInfoSchema = object({
12515
13212
  lastError: string().optional()
12516
13213
  });
12517
13214
  /**
13215
+ * How an archive is encrypted (operator decision 2026-10-09): to a backup
13216
+ * PUBLIC key the hub holds, so only the operator's secret key opens it.
13217
+ * Absent on a plain `.tar.gz` — every archive made before encryption, or
13218
+ * with it off — which restores without a key.
13219
+ */
13220
+ var BackupArchiveEncryptionSchema = object({
13221
+ /** `x25519-hkdf-aes256gcm-stream-v1`. */
13222
+ scheme: string(),
13223
+ /** 16 hex — the backup key whose secret restores this archive. */
13224
+ keyId: string()
13225
+ });
13226
+ /**
13227
+ * The backup encryption setting. The hub keeps PUBLIC keys only: the active
13228
+ * one new archives are encrypted to, and the retired ones older archives
13229
+ * still need. The secret key is shown once, at `setupEncryption`.
13230
+ */
13231
+ var BackupEncryptionStatusSchema = object({
13232
+ enabled: boolean(),
13233
+ active: object({
13234
+ keyId: string(),
13235
+ publicKey: string(),
13236
+ createdAt: number()
13237
+ }).nullable(),
13238
+ /** Every key ever set up, newest first. */
13239
+ keys: array(object({
13240
+ keyId: string(),
13241
+ createdAt: number(),
13242
+ retiredAt: number().nullable()
13243
+ })).readonly()
13244
+ });
13245
+ /**
12518
13246
  * Per-archive entry returned by `backup.listArchives({ destinationId })`.
12519
13247
  * Same shape the destination drill-in renders. Sourced from the per-
12520
13248
  * location `manifests.json` (no per-archive tarball read required).
@@ -12526,7 +13254,9 @@ var BackupArchiveEntrySchema = object({
12526
13254
  sizeBytes: number(),
12527
13255
  label: string().optional(),
12528
13256
  /** Top-level locations included in the archive (db, addons, tls, …). */
12529
- locations: array(string()).readonly()
13257
+ locations: array(string()).readonly(),
13258
+ /** Present when the archive is encrypted; restore then needs that key. */
13259
+ encryption: BackupArchiveEncryptionSchema.optional()
12530
13260
  });
12531
13261
  var BackupEntrySchema = object({
12532
13262
  id: string(),
@@ -12535,7 +13265,8 @@ var BackupEntrySchema = object({
12535
13265
  label: string().optional(),
12536
13266
  createdAt: number(),
12537
13267
  sizeBytes: number(),
12538
- locations: array(string()).optional()
13268
+ locations: array(string()).optional(),
13269
+ encryption: BackupArchiveEncryptionSchema.optional()
12539
13270
  });
12540
13271
  var ArchiveEntrySchema = object({
12541
13272
  path: string(),
@@ -12724,10 +13455,40 @@ method(_void(), array(BackupDestinationInfoSchema).readonly(), { auth: "admin" }
12724
13455
  * this list and skips entries whose path doesn't start with
12725
13456
  * any of them.
12726
13457
  */
12727
- locations: array(string()).optional()
13458
+ locations: array(string()).optional(),
13459
+ /**
13460
+ * The backup SECRET key, for an encrypted archive (ignored for a plain
13461
+ * one). The archive is decrypted into the hub's private staging
13462
+ * before the restart; the key is not stored. A wrong or missing key
13463
+ * is refused before the archive is downloaded.
13464
+ */
13465
+ backupSecretKey: string().optional()
12728
13466
  }), _void(), {
12729
13467
  kind: "mutation",
12730
13468
  auth: "admin"
13469
+ }), method(_void(), BackupEncryptionStatusSchema, { auth: "admin" }), method(object({}), object({
13470
+ keyId: string(),
13471
+ secretKey: string(),
13472
+ publicKey: string(),
13473
+ createdAt: number(),
13474
+ replacedKeyId: string().nullable()
13475
+ }), {
13476
+ kind: "mutation",
13477
+ auth: "admin"
13478
+ }), method(object({}), object({ disabledKeyId: string().nullable() }), {
13479
+ kind: "mutation",
13480
+ auth: "admin"
13481
+ }), method(object({ backupSecretKey: string() }), object({
13482
+ valid: boolean(),
13483
+ keyId: string().nullable(),
13484
+ /** The hub knows this key (active or retired). */
13485
+ known: boolean(),
13486
+ /** It is the key new archives are encrypted to. */
13487
+ active: boolean(),
13488
+ error: string().optional()
13489
+ }), {
13490
+ kind: "mutation",
13491
+ auth: "admin"
12731
13492
  }), method(object({
12732
13493
  destinationId: string(),
12733
13494
  backupId: string()
@@ -14453,7 +15214,60 @@ var CustomModelDescriptorSchema = object({
14453
15214
  stepId: string(),
14454
15215
  entry: ModelCatalogEntrySchema
14455
15216
  });
14456
- method(_void(), array(CustomModelDescriptorSchema).readonly(), { auth: "admin" });
15217
+ /** One regular file of an imported bundle, as the producer measured it. */
15218
+ var ModelBundleFileSchema = object({
15219
+ /** Relative path inside the bundle tar; an mlpackage member is `<x>.mlpackage/<member>`. */
15220
+ path: string().min(1),
15221
+ bytes: number().int().nonnegative(),
15222
+ sha256: string().regex(/^[0-9a-f]{64}$/)
15223
+ });
15224
+ var ImportModelBundleInputSchema = object({
15225
+ /** The registry provider that keeps the model (Model Studio). */
15226
+ addonId: string(),
15227
+ stepId: string().min(1),
15228
+ /**
15229
+ * The catalog rows to register, complete, every format URL already
15230
+ * `camstack-local://<modelId>/<file>` naming a file of the bundle. One
15231
+ * bundle may carry several rows (a base and its INT8 variant).
15232
+ */
15233
+ entries: array(ModelCatalogEntrySchema).min(1).max(4),
15234
+ /** The bundle tar, offered by the producer over `ctx.peerBytes` (same host). */
15235
+ bundle: object({
15236
+ ticket: PeerBytesTicketSchema,
15237
+ bytes: number().int().positive(),
15238
+ sha256: string().regex(/^[0-9a-f]{64}$/)
15239
+ }),
15240
+ /** Every file the tar must hold; anything missing, extra or different is refused. */
15241
+ files: array(ModelBundleFileSchema).min(1).max(64),
15242
+ /** Convert missing engine formats and push the model to every agent afterwards. */
15243
+ distribute: boolean()
15244
+ });
15245
+ var ImportModelBundleResultSchema = discriminatedUnion("kind", [object({
15246
+ kind: literal("imported"),
15247
+ modelIds: array(string()).readonly(),
15248
+ distributed: array(object({
15249
+ modelId: string(),
15250
+ nodeId: string(),
15251
+ format: _enum(MODEL_FORMATS),
15252
+ ok: boolean(),
15253
+ error: string().optional()
15254
+ })).readonly()
15255
+ }), object({
15256
+ kind: literal("refused"),
15257
+ reason: _enum([
15258
+ "transfer-failed",
15259
+ "checksum-mismatch",
15260
+ "bundle-mismatch",
15261
+ "invalid-entry",
15262
+ "id-taken"
15263
+ ]),
15264
+ detail: string()
15265
+ })]);
15266
+ method(_void(), array(CustomModelDescriptorSchema).readonly(), { auth: "admin" }), method(ImportModelBundleInputSchema, ImportModelBundleResultSchema, {
15267
+ kind: "mutation",
15268
+ auth: "admin",
15269
+ timeoutMs: 30 * 6e4
15270
+ });
14457
15271
  /**
14458
15272
  * Query filter for settings-store collections.
14459
15273
  */
@@ -14932,6 +15746,35 @@ var KeychainKeySourceSchema = object({
14932
15746
  */
14933
15747
  sharesBackupWithDatabase: boolean()
14934
15748
  });
15749
+ /**
15750
+ * One keychain reset, as the Secrets page reports it until the operator
15751
+ * acknowledges it. Never a value: refs, counts and table names only.
15752
+ */
15753
+ var KeychainResetRecordSchema = object({
15754
+ id: string(),
15755
+ at: number(),
15756
+ /** `user:<id>` or {@link KEYCHAIN_RESET_TRIGGER_ACTOR}. */
15757
+ actor: string(),
15758
+ /** Why the keychain was locked when it was reset; `null` when it was not locked. */
15759
+ lockedReason: string().nullable(),
15760
+ /** Values moved into the archive table (ciphertext under the lost key). */
15761
+ archived: number().int(),
15762
+ /** `keychain:secrets-orphaned-<ts>`, or `null` when nothing was stored. */
15763
+ archivedCollection: string().nullable(),
15764
+ /**
15765
+ * `keychain:keys-orphaned-<ts>`: the wrapped data keys of the archive, kept
15766
+ * so the archive can still be opened if the lost master key turns up.
15767
+ */
15768
+ archivedKeysCollection: string().nullable(),
15769
+ /**
15770
+ * `system-settings` keys whose marker the reset cleared — the cluster
15771
+ * secret's: a marker left pointing at an archived value would refuse every
15772
+ * agent forever (D797).
15773
+ */
15774
+ clearedSettingsKeys: array(string()).readonly(),
15775
+ /** When an operator dismissed the notice on the Secrets page; `null` until then. */
15776
+ acknowledgedAt: number().nullable()
15777
+ });
14935
15778
  var KeychainStatusSchema = object({
14936
15779
  keychain: KeychainStateSchema,
14937
15780
  /** The source of the master key in use; `null` while locked. */
@@ -14949,7 +15792,9 @@ var KeychainStatusSchema = object({
14949
15792
  /** Wrapped copies of the data key under a previous master key, kept until purged. */
14950
15793
  retiredWraps: number().int(),
14951
15794
  recoveryKeyDownloadedAt: number().nullable(),
14952
- secretCount: number().int()
15795
+ secretCount: number().int(),
15796
+ /** The most recent reset, acknowledged or not; `null` when the keychain was never reset. */
15797
+ lastReset: KeychainResetRecordSchema.nullable()
14953
15798
  });
14954
15799
  /**
14955
15800
  * Whether a stored value is still pointed at by its owner's settings.
@@ -14971,17 +15816,26 @@ var KeychainAuditActionSchema = _enum([
14971
15816
  "download-recovery-key",
14972
15817
  "delete-orphans",
14973
15818
  "reset",
15819
+ "acknowledge-reset",
14974
15820
  "initialize"
14975
15821
  ]);
14976
15822
  var KeychainAuditEntrySchema = object({
14977
15823
  id: string(),
14978
15824
  at: number(),
14979
15825
  action: KeychainAuditActionSchema,
14980
- /** `addon:<id>` | `user:<id>` | `system`. */
15826
+ /** `addon:<id>` | `user:<id>` | `system` | `trigger-file`. */
14981
15827
  actor: string(),
14982
15828
  ref: string().nullable(),
14983
15829
  detail: string().nullable()
14984
15830
  });
15831
+ var KEYCHAIN_RESET_CONFIRMATION = "RESET KEYCHAIN";
15832
+ /**
15833
+ * Secrets the HUB itself holds (owner `system`) that no settings form shows:
15834
+ * `jwt-signing-key` — the session signing key (D797). It is always "in use",
15835
+ * never an orphan; it is generated on a fresh hub and replaced only through
15836
+ * {@link keychainAdminCapability.methods.setSystemSecret}.
15837
+ */
15838
+ var SystemHeldSecretNameSchema = _enum(["jwt-signing-key"]);
14985
15839
  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({
14986
15840
  value: string(),
14987
15841
  version: number().int()
@@ -14989,6 +15843,16 @@ method(object({}), KeychainStatusSchema, { auth: "admin" }), method(object({}),
14989
15843
  kind: "mutation",
14990
15844
  auth: "admin",
14991
15845
  caller: "required"
15846
+ }), method(object({
15847
+ name: SystemHeldSecretNameSchema,
15848
+ value: string().min(16)
15849
+ }), object({
15850
+ ref: string(),
15851
+ version: number().int()
15852
+ }), {
15853
+ kind: "mutation",
15854
+ auth: "admin",
15855
+ caller: "required"
14992
15856
  }), method(object({ refs: array(string().min(1)).max(1e3) }), object({
14993
15857
  deleted: array(string()).readonly(),
14994
15858
  kept: array(object({
@@ -15018,13 +15882,20 @@ method(object({}), KeychainStatusSchema, { auth: "admin" }), method(object({}),
15018
15882
  kind: "mutation",
15019
15883
  auth: "admin",
15020
15884
  caller: "required"
15021
- }), method(object({ confirm: literal("RESET KEYCHAIN") }), object({
15885
+ }), method(object({ confirm: literal(KEYCHAIN_RESET_CONFIRMATION) }), object({
15022
15886
  archivedCollection: string().nullable(),
15023
15887
  archived: number().int()
15024
15888
  }), {
15025
15889
  kind: "mutation",
15026
15890
  auth: "admin",
15027
15891
  caller: "required"
15892
+ }), method(object({}), object({
15893
+ reset: KeychainResetRecordSchema.nullable(),
15894
+ pendingReentry: array(KeychainSecretMetaSchema).readonly()
15895
+ }), { auth: "admin" }), method(object({}), object({ acknowledged: boolean() }), {
15896
+ kind: "mutation",
15897
+ auth: "admin",
15898
+ caller: "required"
15028
15899
  });
15029
15900
  method(_void(), object({
15030
15901
  id: string(),
@@ -17858,7 +18729,7 @@ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
17858
18729
  * `login-method` — collection cap through which auth addons contribute
17859
18730
  * their pre-auth login surfaces to the login page. This is the SINGLE,
17860
18731
  * generic mechanism that supersedes the dead `auth.listProviders` reader:
17861
- * every auth addon (OIDC, magic-link, WebAuthn/passkey) registers a
18732
+ * every auth addon (OIDC, WebAuthn/passkey) registers a
17862
18733
  * `login-method` provider and the PUBLIC `auth.listLoginMethods`
17863
18734
  * procedure aggregates them for the unauthenticated login page.
17864
18735
  *
@@ -17866,8 +18737,7 @@ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
17866
18737
  *
17867
18738
  * - `redirect` — a declarative button. The login page renders a generic
17868
18739
  * button that navigates to `startUrl` (an addon-owned HTTP route).
17869
- * Covers OIDC (`/addon/auth-oidc/<id>/start`) and magic-link with
17870
- * ZERO shell-side JS. A future SSO addon plugs in the same way — the
18740
+ * Covers OIDC (`/addon/auth-oidc/<id>/start`) with ZERO shell-side JS. A future SSO addon plugs in the same way — the
17871
18741
  * login page needs NO change.
17872
18742
  *
17873
18743
  * - `widget` — a Module-Federation widget the login page mounts (via
@@ -17886,8 +18756,8 @@ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
17886
18756
  * decision.
17887
18757
  *
17888
18758
  * Every contribution carries a `stage`:
17889
- * - `primary` — shown on the first credentials screen (OIDC /
17890
- * magic-link buttons; a future usernameless passkey).
18759
+ * - `primary` — shown on the first credentials screen (OIDC
18760
+ * buttons; a usernameless passkey).
17891
18761
  * - `second-factor` — shown AFTER the password leg, gated on the
17892
18762
  * returned `factors` (passkey-as-2FA today).
17893
18763
  *
@@ -17914,7 +18784,7 @@ var LoginMethodContributionSchema = discriminatedUnion("kind", [
17914
18784
  * The provider names an external identity a signed-in user can link to
17915
18785
  * their own account (D782): `auth.listLinkableProviders` /
17916
18786
  * `beginExternalLink` offer exactly the redirect methods that set this,
17917
- * whatever their id. Absent / false — a login button only (magic-link).
18787
+ * whatever their id. Absent / false — a login button only.
17918
18788
  */
17919
18789
  linkable: boolean().optional()
17920
18790
  }),
@@ -21769,8 +22639,7 @@ method(object({}), object({ rules: array(NcRuleSchema) }), { auth: "admin" }), m
21769
22639
  * `super_admin` — collapsed onto the single boolean because every
21770
22640
  * non-admin caller is governed by the same scope-check rules; the
21771
22641
  * distinction was only ever used to route role-specific procedures
21772
- * which we no longer have. Agents are admin sessions issued via
21773
- * `createServiceToken`; CLI / webhook integrations are `cst_*` tokens
22642
+ * which we no longer have. CLI / webhook integrations are `cst_*` tokens
21774
22643
  * with `isAdmin: false` + an explicit scope list.
21775
22644
  */
21776
22645
  /** Per-method access flavour. Materialised on every cap method via codegen. */
@@ -23445,6 +24314,9 @@ var RetrainExportFilterSchema = object({
23445
24314
  frameIds: array(string()).max(2e4).optional(),
23446
24315
  /** Only frames in at least one of these named collections. */
23447
24316
  collectionIds: array(string()).max(200).optional(),
24317
+ /** Exactly the frames of this dataset version (and its completeOnly). An
24318
+ * unknown id selects nothing. */
24319
+ datasetVersionId: string().optional(),
23448
24320
  batchId: string().optional(),
23449
24321
  /** Only frames the operator marked complete (all subjects boxed). */
23450
24322
  completeOnly: boolean().optional()
@@ -23612,6 +24484,67 @@ var RetrainLlmAssistResultSchema = discriminatedUnion("kind", [object({
23612
24484
  ]),
23613
24485
  detail: string().optional()
23614
24486
  })]);
24487
+ /** What a dataset version is cut from. Every field narrows. */
24488
+ var RetrainDatasetSelectionSchema = object({
24489
+ deviceIds: array(number()).readonly().optional(),
24490
+ collectionIds: array(string()).max(200).readonly().optional(),
24491
+ frameIds: array(string()).max(2e4).readonly().optional()
24492
+ });
24493
+ /** The counts a dataset is judged by. */
24494
+ var RetrainDatasetStatsSchema = object({
24495
+ frames: number().int(),
24496
+ completeFrames: number().int(),
24497
+ /** `completeFrames / frames`, 0..1. */
24498
+ completeness: number(),
24499
+ /** Boxes to learn (model errors excluded). */
24500
+ subjects: number().int(),
24501
+ modelErrors: number().int(),
24502
+ /** Complete frames with no subject. */
24503
+ hardNegatives: number().int(),
24504
+ /** Subjects per class × camera × day/night. */
24505
+ cells: array(object({
24506
+ macroClass: string(),
24507
+ deviceId: number(),
24508
+ lighting: _enum([
24509
+ "day",
24510
+ "night",
24511
+ "unknown"
24512
+ ]),
24513
+ subjects: number().int(),
24514
+ frames: number().int()
24515
+ })).readonly(),
24516
+ cameras: array(object({
24517
+ deviceId: number(),
24518
+ frames: number().int(),
24519
+ completeFrames: number().int()
24520
+ })).readonly()
24521
+ });
24522
+ /** An immutable dataset version, without its frame list. */
24523
+ var RetrainDatasetVersionSchema = object({
24524
+ id: string(),
24525
+ name: string(),
24526
+ createdAt: number(),
24527
+ selection: RetrainDatasetSelectionSchema,
24528
+ layout: RetrainExportLayoutSchema,
24529
+ completeOnly: boolean(),
24530
+ frameCount: number().int(),
24531
+ /** sha256 of what the frames taught when the version was frozen. */
24532
+ annotationHash: string(),
24533
+ /** The export manifest schema the version was cut under. */
24534
+ manifestSchema: string(),
24535
+ stats: RetrainDatasetStatsSchema
24536
+ });
24537
+ var CreateRetrainDatasetVersionResultSchema = discriminatedUnion("kind", [object({
24538
+ kind: literal("created"),
24539
+ version: RetrainDatasetVersionSchema
24540
+ }), object({
24541
+ kind: literal("refused"),
24542
+ reason: _enum([
24543
+ "empty-name",
24544
+ "duplicate-name",
24545
+ "no-frames"
24546
+ ])
24547
+ })]);
23615
24548
  /** The outcome of a lifecycle move owned by the retrain page. */
23616
24549
  var RetrainTransitionResultSchema = object({
23617
24550
  trackId: string(),
@@ -24401,6 +25334,47 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
24401
25334
  kind: "mutation",
24402
25335
  auth: "admin",
24403
25336
  timeoutMs: 60 * 6e4
25337
+ }), method(object({
25338
+ filter: RetrainExportFilterSchema,
25339
+ layout: RetrainExportLayoutSchema
25340
+ }), object({
25341
+ ticket: PeerBytesTicketSchema,
25342
+ frames: number().int(),
25343
+ annotations: number().int()
25344
+ }), {
25345
+ kind: "mutation",
25346
+ auth: "admin",
25347
+ timeoutMs: 12e4
25348
+ }), method(object({
25349
+ selection: RetrainDatasetSelectionSchema,
25350
+ completeOnly: boolean().optional()
25351
+ }), RetrainDatasetStatsSchema, {
25352
+ kind: "query",
25353
+ auth: "admin"
25354
+ }), method(object({
25355
+ name: string().max(120),
25356
+ selection: RetrainDatasetSelectionSchema,
25357
+ layout: RetrainExportLayoutSchema,
25358
+ completeOnly: boolean()
25359
+ }), CreateRetrainDatasetVersionResultSchema, {
25360
+ kind: "mutation",
25361
+ auth: "admin",
25362
+ timeoutMs: 12e4
25363
+ }), method(object({}), array(RetrainDatasetVersionSchema).readonly(), {
25364
+ kind: "query",
25365
+ auth: "admin"
25366
+ }), method(object({ id: string() }), object({ deleted: boolean() }), {
25367
+ kind: "mutation",
25368
+ auth: "admin"
25369
+ }), method(object({ id: string() }), object({
25370
+ found: boolean(),
25371
+ annotationHash: string(),
25372
+ matches: boolean(),
25373
+ missingFrames: number().int()
25374
+ }), {
25375
+ kind: "query",
25376
+ auth: "admin",
25377
+ timeoutMs: 12e4
24404
25378
  }), method(object({}), array(RetrainAssistProfileSchema).readonly(), {
24405
25379
  kind: "query",
24406
25380
  auth: "admin"
@@ -27979,8 +28953,8 @@ version: string().optional() }), ServerUpdateActionResultSchema, {
27979
28953
  * `smtp-provider` — pluggable email delivery surface.
27980
28954
  *
27981
28955
  * Collection cap: a deployment may install multiple SMTP relays (e.g.
27982
- * one for transactional / one for notifications). Consumers (magic-link,
27983
- * notifier addons, …) walk the collection and pick the first
28956
+ * one for transactional / one for notifications). Consumers (notifier
28957
+ * addons, …) walk the collection and pick the first
27984
28958
  * ready provider OR target a specific addonId.
27985
28959
  *
27986
28960
  * The shape stays small on purpose — `sendEmail` is enough for the
@@ -28263,7 +29237,7 @@ targets: array(object({
28263
29237
  };
28264
29238
  /**
28265
29239
  * `sso-bridge` — internal hub-only cap that lets SSO-style auth
28266
- * providers (OIDC, SAML, magic-link, …) mint an HMAC-signed token
29240
+ * providers (OIDC, SAML, …) mint an HMAC-signed token
28267
29241
  * carrying the post-callback claims before redirecting back to
28268
29242
  * `/api/auth/sso/finish`.
28269
29243
  *
@@ -28326,7 +29300,14 @@ var SsoBridgeClaimsSchema = object({
28326
29300
  * Verified `iss` of the id_token behind an OIDC login bridge (D782). A
28327
29301
  * subject is unique only per issuer, so a link is bound to it.
28328
29302
  */
28329
- issuer: string().optional()
29303
+ issuer: string().optional(),
29304
+ /**
29305
+ * SHA-256 (hex) of the `camstack_sso_state` cookie the IdP `/start` set in
29306
+ * the browser that began this sign-in. `/api/auth/sso/finish` requires the
29307
+ * request to present the matching cookie — a login bridge is useless in
29308
+ * any other browser.
29309
+ */
29310
+ browserBinding: string().optional()
28330
29311
  });
28331
29312
  method(object({
28332
29313
  claims: SsoBridgeClaimsSchema,
@@ -40593,16 +41574,6 @@ var ApiKeySummarySchema = object({
40593
41574
  createdAt: number(),
40594
41575
  lastUsedAt: number().optional()
40595
41576
  });
40596
- var CreateApiKeyInputSchema = object({
40597
- label: string(),
40598
- isAdmin: boolean().default(false),
40599
- allowedProviders: union([array(string()), literal("*")]).optional(),
40600
- allowedDevices: record(string(), union([array(string()), literal("*")])).optional()
40601
- });
40602
- var CreateApiKeyResultSchema = object({
40603
- token: string(),
40604
- record: ApiKeySummarySchema
40605
- });
40606
41577
  var ScopedTokenSummarySchema = object({
40607
41578
  id: string(),
40608
41579
  userId: string(),
@@ -40701,17 +41672,10 @@ method(_void(), array(UserSummarySchema), { auth: "admin" }), method(CreateUserI
40701
41672
  }), UserSummarySchema.extend({ passwordHash: string() }).nullable(), {
40702
41673
  kind: "mutation",
40703
41674
  access: "view"
40704
- }), method(_void(), array(ApiKeySummarySchema), { auth: "admin" }), method(CreateApiKeyInputSchema, CreateApiKeyResultSchema, {
40705
- kind: "mutation",
40706
- auth: "admin",
40707
- access: "create"
40708
- }), method(object({ id: string() }), object({ success: literal(true) }), {
41675
+ }), method(_void(), array(ApiKeySummarySchema), { auth: "admin" }), method(object({ id: string() }), object({ success: literal(true) }), {
40709
41676
  kind: "mutation",
40710
41677
  auth: "admin",
40711
41678
  access: "delete"
40712
- }), method(object({ token: string() }), ApiKeySummarySchema.nullable(), {
40713
- kind: "mutation",
40714
- access: "view"
40715
41679
  }), method(CreateScopedTokenInputSchema, CreateScopedTokenResultSchema, {
40716
41680
  kind: "mutation",
40717
41681
  auth: "admin",
@@ -40785,15 +41749,7 @@ method(_void(), array(UserSummarySchema), { auth: "admin" }), method(CreateUserI
40785
41749
  }).nullable(), { access: "view" }), method(object({ userId: string() }), array(ExternalIdentitySchema), { auth: "admin" }), method(ExternalIdentityKeySchema, object({
40786
41750
  userId: string(),
40787
41751
  issuer: string()
40788
- }).nullable(), { auth: "admin" }), method(ExternalIdentityKeySchema.extend({
40789
- userId: string(),
40790
- issuer: string().min(1),
40791
- label: string().optional()
40792
- }), object({ success: literal(true) }), {
40793
- kind: "mutation",
40794
- auth: "admin",
40795
- access: "create"
40796
- }), method(ExternalIdentityKeySchema.extend({ userId: string() }), object({ success: boolean() }), {
41752
+ }).nullable(), { auth: "admin" }), method(ExternalIdentityKeySchema.extend({ userId: string() }), object({ success: boolean() }), {
40797
41753
  kind: "mutation",
40798
41754
  auth: "admin",
40799
41755
  access: "delete"
@@ -41498,6 +42454,451 @@ var zoneRulesCapability = {
41498
42454
  */
41499
42455
  durability: "restored"
41500
42456
  };
42457
+ /**
42458
+ * `training-provider` — ONE cloud that can run the CamStack trainer.
42459
+ *
42460
+ * A thin, mockable translation layer: it knows how to run a container with a
42461
+ * GPU, move a dataset in, read the job's stdout and hand artefacts back. It
42462
+ * knows nothing about datasets, splits, floors, cost policy or Model Studio —
42463
+ * those are the `training` orchestrator's (D805). Every rule written there
42464
+ * once is what makes a second provider (RunPod, a local NVIDIA node) a new
42465
+ * manifest entry and nothing else.
42466
+ *
42467
+ * Collection, routed by the `addonId` in every single-row input (the `llm` /
42468
+ * `notification-output` posture); `describe` concat-fans across providers.
42469
+ * Every method is `admin`: these spend money.
42470
+ *
42471
+ * Every cloud object a provider creates is tagged with the orchestrator's
42472
+ * `jobKey`, so a retried submit finds the job it already started instead of
42473
+ * starting a second GPU, and `listJobs` can find orphans.
42474
+ *
42475
+ * Bytes never ride a cap field: the dataset arrives as a `ctx.peerBytes`
42476
+ * ticket the producer (pipeline-analytics) minted, and artefacts leave as a
42477
+ * ticket the provider mints (D613).
42478
+ */
42479
+ var TrainingGpuOptionSchema = object({
42480
+ id: string(),
42481
+ label: string(),
42482
+ /** List price, USD per GPU-hour, before any region multiplier. */
42483
+ usdPerHour: number().nonnegative(),
42484
+ vramGb: number().nonnegative()
42485
+ });
42486
+ var TrainingRegionOptionSchema = object({
42487
+ /** `''` = any region (the provider's choice). */
42488
+ id: string(),
42489
+ label: string(),
42490
+ priceMultiplier: number().positive()
42491
+ });
42492
+ /**
42493
+ * The provider's per-account settings, as the orchestrator reads them. They
42494
+ * live in the PROVIDER addon's settings (operator decision 2026-10-08: they
42495
+ * depend on the user's account), never hard-coded in the orchestrator.
42496
+ */
42497
+ var TrainingProviderDefaultsSchema = object({
42498
+ gpuType: string(),
42499
+ region: string(),
42500
+ costCapUsd: number().nonnegative(),
42501
+ maxRuntimeSec: number().int().positive(),
42502
+ /** Hours a FAILED job's cloud dataset is kept for debugging; 0 = delete at once. */
42503
+ failedDatasetGraceHours: number().nonnegative()
42504
+ });
42505
+ var TrainingProviderDescriptorSchema = object({
42506
+ addonId: string(),
42507
+ /** `modal`, `runpod`, `fake`, … */
42508
+ kind: string(),
42509
+ label: string(),
42510
+ gpuTypes: array(TrainingGpuOptionSchema).readonly(),
42511
+ regions: array(TrainingRegionOptionSchema).readonly(),
42512
+ maxDatasetBytes: number().int().positive(),
42513
+ maxRuntimeSec: number().int().positive(),
42514
+ freeTierNote: string().optional(),
42515
+ /** Where the data goes, in one sentence the confirm dialog repeats. */
42516
+ dataResidencyNote: string(),
42517
+ /** Credentials are present — never the values. */
42518
+ configured: boolean(),
42519
+ defaults: TrainingProviderDefaultsSchema
42520
+ });
42521
+ var TrainingCredentialCheckSchema = object({
42522
+ ok: boolean(),
42523
+ /** Workspace / account name, when the provider says. */
42524
+ account: string().optional(),
42525
+ reason: _enum([
42526
+ "missing",
42527
+ "invalid",
42528
+ "forbidden",
42529
+ "network",
42530
+ "quota"
42531
+ ]).optional(),
42532
+ detail: string().optional()
42533
+ });
42534
+ var ProviderJobStateSchema = _enum([
42535
+ "pending",
42536
+ "starting",
42537
+ "running",
42538
+ "succeeded",
42539
+ "failed",
42540
+ "cancelled",
42541
+ "lost"
42542
+ ]);
42543
+ var ProviderJobStatusSchema = object({
42544
+ jobKey: string(),
42545
+ providerJobId: string().optional(),
42546
+ state: ProviderJobStateSchema,
42547
+ startedAt: number().optional(),
42548
+ endedAt: number().optional(),
42549
+ exitCode: number().int().optional(),
42550
+ failureReason: string().optional(),
42551
+ gpuType: string(),
42552
+ region: string().optional(),
42553
+ billedSeconds: number().nonnegative(),
42554
+ costUsd: number().nonnegative(),
42555
+ /** True when `costUsd` is runtime × list price, not a billing answer. */
42556
+ costIsEstimate: boolean(),
42557
+ lastFetchedAt: number()
42558
+ });
42559
+ /**
42560
+ * The trainer the job runs, by SOURCE revision: the provider turns it into an
42561
+ * image its own way (Modal builds the published Dockerfile at that revision;
42562
+ * a registry-pull provider maps it to a tag). Recorded on the job and echoed
42563
+ * in `result.json`.
42564
+ */
42565
+ var TrainerSourceRefSchema = object({
42566
+ /** Hugging Face repo id, e.g. `camstack/camstack-trainer`. */
42567
+ repo: string().min(1),
42568
+ /** A commit sha (never a branch) — the job must be reproducible. */
42569
+ revision: string().regex(/^[0-9a-f]{7,64}$/)
42570
+ });
42571
+ var JobRef = {
42572
+ addonId: string(),
42573
+ jobKey: string().uuid()
42574
+ };
42575
+ var TrainingLogLineSchema = object({
42576
+ ts: number(),
42577
+ text: string()
42578
+ });
42579
+ method(object({}), array(TrainingProviderDescriptorSchema).readonly(), { auth: "admin" }), method(object({ addonId: string() }), TrainingCredentialCheckSchema, {
42580
+ kind: "mutation",
42581
+ auth: "admin",
42582
+ timeoutMs: 3e4
42583
+ }), method(object({
42584
+ addonId: string(),
42585
+ gpuType: string(),
42586
+ region: string(),
42587
+ datasetBytes: number().int().nonnegative(),
42588
+ gpuSecondsLow: number().nonnegative(),
42589
+ gpuSecondsHigh: number().nonnegative()
42590
+ }), object({
42591
+ usdLow: number().nonnegative(),
42592
+ usdHigh: number().nonnegative(),
42593
+ notes: array(string()).readonly()
42594
+ }), { auth: "admin" }), method(object({
42595
+ ...JobRef,
42596
+ ticket: PeerBytesTicketSchema
42597
+ }), object({
42598
+ bytes: number().int().nonnegative(),
42599
+ sha256: string()
42600
+ }), {
42601
+ kind: "mutation",
42602
+ auth: "admin",
42603
+ timeoutMs: 120 * 6e4
42604
+ }), method(object({
42605
+ ...JobRef,
42606
+ trainer: TrainerSourceRefSchema,
42607
+ jobSpecJson: string().min(2).max(64e3),
42608
+ gpuType: string(),
42609
+ region: string(),
42610
+ maxRuntimeSec: number().int().positive()
42611
+ }), ProviderJobStatusSchema, {
42612
+ kind: "mutation",
42613
+ auth: "admin",
42614
+ timeoutMs: 30 * 6e4
42615
+ }), method(object(JobRef), ProviderJobStatusSchema, {
42616
+ auth: "admin",
42617
+ timeoutMs: 6e4
42618
+ }), method(object({
42619
+ ...JobRef,
42620
+ cursor: string().optional(),
42621
+ max: number().int().min(1).max(500)
42622
+ }), object({
42623
+ lines: array(TrainingLogLineSchema).readonly(),
42624
+ cursor: string()
42625
+ }), {
42626
+ auth: "admin",
42627
+ timeoutMs: 6e4
42628
+ }), method(object(JobRef), object({ ok: literal(true) }), {
42629
+ kind: "mutation",
42630
+ auth: "admin",
42631
+ timeoutMs: 6e4
42632
+ }), method(object(JobRef), object({
42633
+ found: boolean(),
42634
+ text: string().optional()
42635
+ }), {
42636
+ kind: "mutation",
42637
+ auth: "admin",
42638
+ timeoutMs: 5 * 6e4
42639
+ }), method(object({
42640
+ ...JobRef,
42641
+ path: _enum(["bundle.tar"])
42642
+ }), object({ ticket: PeerBytesTicketSchema }), {
42643
+ kind: "mutation",
42644
+ auth: "admin",
42645
+ timeoutMs: 5 * 6e4
42646
+ }), method(object(JobRef), object({ deleted: array(string()).readonly() }), {
42647
+ kind: "mutation",
42648
+ auth: "admin",
42649
+ timeoutMs: 5 * 6e4
42650
+ }), method(object({ addonId: string() }), array(ProviderJobStatusSchema).readonly(), {
42651
+ auth: "admin",
42652
+ timeoutMs: 2 * 6e4
42653
+ });
42654
+ /**
42655
+ * `training` — the cloud-training orchestrator (D805). Hub-only singleton,
42656
+ * provided by `addon-training`.
42657
+ *
42658
+ * It owns what every provider must agree on, written once:
42659
+ *
42660
+ * - **Dataset versions.** Taken over from pipeline-analytics (D796): the rows
42661
+ * live here (D808); pipeline-analytics still CUTS a version (it owns the corpus and
42662
+ * the export plan) and reaches this store through the five row methods
42663
+ * below, so the Retrain page and the export did not change.
42664
+ * - **Jobs.** A persisted state machine, a reconcile loop against the
42665
+ * provider, a cost guard, a daily orphan sweep and the retention rules.
42666
+ * - **The return flow.** Verified artefacts → Model Studio
42667
+ * (`custom-model-registry.importModelBundle`) → canary on cameras →
42668
+ * rollback. Nothing is ever registered automatically.
42669
+ *
42670
+ * Every method is `admin`.
42671
+ */
42672
+ /** A version WITH its frame list — what the export and a job read. */
42673
+ var TrainingDatasetVersionRowSchema = RetrainDatasetVersionSchema.omit({ frameCount: true }).extend({ frameIds: array(string()).max(2e4).readonly() });
42674
+ /** A base model a detector job can fine-tune, and the baseline it is judged against. */
42675
+ var TrainingBaseModelSchema = object({
42676
+ modelId: string(),
42677
+ label: string(),
42678
+ weights: string(),
42679
+ imgsz: number().int(),
42680
+ baselineOnnxUrl: string(),
42681
+ baselineFloors: record(string(), number()),
42682
+ /** The base the fleet runs most — the UI's default. */
42683
+ recommended: boolean()
42684
+ });
42685
+ var TrainingPresetSchema = _enum([
42686
+ "quick",
42687
+ "standard",
42688
+ "thorough"
42689
+ ]);
42690
+ var TrainingJobRequestSchema = object({
42691
+ datasetVersionId: string().min(1),
42692
+ /** The `training-provider` addon that runs it. */
42693
+ addonId: string().min(1),
42694
+ gpuType: string().min(1),
42695
+ region: string(),
42696
+ baseModelId: string().min(1),
42697
+ preset: TrainingPresetSchema,
42698
+ /** Freeze the backbone's first N layers; `null` = the preset's choice. */
42699
+ freeze: number().int().nonnegative().nullable(),
42700
+ /** Cameras held out whole for evaluation; `null` = the orchestrator's default. */
42701
+ holdoutCameras: array(number().int()).nullable()
42702
+ });
42703
+ var TrainingSplitPlanSchema = object({
42704
+ holdoutCameras: array(number().int()).readonly(),
42705
+ /** Used when no camera is held out: the last N days of every camera. */
42706
+ holdoutLastDays: number().int().nonnegative(),
42707
+ /** Holdout subjects per class (camera holdout only; `null` = known only after the split). */
42708
+ holdoutSupport: record(string(), number().int()).nullable(),
42709
+ trainSubjects: number().int()
42710
+ });
42711
+ var TrainingRefusalReasonSchema = _enum([
42712
+ "unknown-dataset",
42713
+ "unknown-provider",
42714
+ "provider-not-configured",
42715
+ "unknown-base-model",
42716
+ "unknown-gpu",
42717
+ "dataset-too-large",
42718
+ "no-training-subjects",
42719
+ "job-already-running"
42720
+ ]);
42721
+ var TrainingJobPlanSchema = object({
42722
+ refusal: object({
42723
+ reason: TrainingRefusalReasonSchema,
42724
+ detail: string()
42725
+ }).nullable(),
42726
+ warnings: array(string()).readonly(),
42727
+ split: TrainingSplitPlanSchema.nullable(),
42728
+ estimate: object({
42729
+ datasetBytes: number().int(),
42730
+ uploadMinutesAt20Mbps: number(),
42731
+ gpuSecondsLow: number(),
42732
+ gpuSecondsHigh: number(),
42733
+ usdLow: number(),
42734
+ usdHigh: number(),
42735
+ notes: array(string()).readonly()
42736
+ }).nullable(),
42737
+ /** Pre-filled from the provider's settings; the operator may lower or raise them. */
42738
+ defaults: object({
42739
+ maxCostUsd: number(),
42740
+ maxRuntimeSec: number().int()
42741
+ }).nullable(),
42742
+ /** The sentence the confirm dialog repeats: where the frames go and when they are deleted. */
42743
+ dataNotice: string()
42744
+ });
42745
+ /**
42746
+ * Orchestrator-owned states, persisted. `uploading` covers exporting the
42747
+ * archive (it is streamed, never staged). Terminal: `failed`, `cancelled`,
42748
+ * `lost`, `expired`, `discarded`. `registered` and `canary` are where a
42749
+ * result lives after the operator acted on it.
42750
+ */
42751
+ var TrainingJobStateSchema = _enum([
42752
+ "uploading",
42753
+ "submitted",
42754
+ "starting",
42755
+ "running",
42756
+ "collecting",
42757
+ "ready",
42758
+ "registered",
42759
+ "canary",
42760
+ "failed",
42761
+ "cancelling",
42762
+ "cancelled",
42763
+ "lost",
42764
+ "expired",
42765
+ "discarded"
42766
+ ]);
42767
+ var TrainingFailureReasonSchema = _enum([
42768
+ "cost-cap",
42769
+ "runtime-cap",
42770
+ "upload-failed",
42771
+ "submit-failed",
42772
+ "trainer-failed",
42773
+ "result-invalid",
42774
+ "checksum-mismatch",
42775
+ "fetch-failed",
42776
+ "provider-error",
42777
+ "hub-restart-during-upload"
42778
+ ]);
42779
+ var TrainingProgressPointSchema = object({
42780
+ epoch: number().int(),
42781
+ map50: number().nullable(),
42782
+ map50_95: number().nullable()
42783
+ });
42784
+ var TrainingCanarySchema = object({
42785
+ deviceIds: array(number().int()).readonly(),
42786
+ since: number(),
42787
+ /** Every override the canary replaced, exactly, so rollback restores it. */
42788
+ previous: array(object({
42789
+ deviceId: number().int(),
42790
+ nodeId: string(),
42791
+ deviceKey: string(),
42792
+ patch: object({
42793
+ modelId: string().optional(),
42794
+ settings: record(string(), unknown()).readonly().optional()
42795
+ }).nullable()
42796
+ })).readonly()
42797
+ });
42798
+ var TrainingJobSchema = object({
42799
+ id: string(),
42800
+ idempotencyKey: string(),
42801
+ name: string(),
42802
+ createdAt: number(),
42803
+ updatedAt: number(),
42804
+ state: TrainingJobStateSchema,
42805
+ stage: TrainingStageSchema.nullable(),
42806
+ failure: object({
42807
+ reason: TrainingFailureReasonSchema,
42808
+ stage: string().nullable(),
42809
+ detail: string()
42810
+ }).nullable(),
42811
+ request: TrainingJobRequestSchema,
42812
+ maxCostUsd: number().nonnegative(),
42813
+ maxRuntimeSec: number().int().positive(),
42814
+ trainer: TrainerSourceRefSchema,
42815
+ datasetLayout: RetrainExportLayoutSchema,
42816
+ dataset: object({
42817
+ bytes: number().int(),
42818
+ sha256: string(),
42819
+ uploadedAt: number()
42820
+ }).nullable(),
42821
+ split: TrainingSplitPlanSchema,
42822
+ provider: object({
42823
+ state: ProviderJobStateSchema.nullable(),
42824
+ providerJobId: string().nullable(),
42825
+ startedAt: number().nullable(),
42826
+ endedAt: number().nullable(),
42827
+ billedSeconds: number(),
42828
+ costUsd: number(),
42829
+ costIsEstimate: boolean(),
42830
+ lastPolledAt: number().nullable()
42831
+ }),
42832
+ progress: object({
42833
+ epoch: number().int().nullable(),
42834
+ epochs: number().int().nullable(),
42835
+ etaSec: number().nullable(),
42836
+ series: array(TrainingProgressPointSchema).readonly()
42837
+ }),
42838
+ /** The last lines of the job's output (≤ 200), newest last. Never frame paths. */
42839
+ logTail: array(string()).readonly(),
42840
+ logCursor: string().nullable(),
42841
+ artifacts: object({
42842
+ bundleBytes: number().int(),
42843
+ bundleSha256: string(),
42844
+ fetchedAt: number(),
42845
+ /** When the staged artefacts are deleted from the hub. */
42846
+ expiresAt: number()
42847
+ }).nullable(),
42848
+ /** When the provider-side copy of the frames was deleted; null while it exists. */
42849
+ cloudDatasetDeletedAt: number().nullable(),
42850
+ /** A failed job's dataset is kept until then (the provider's grace), then deleted. */
42851
+ cloudCleanupDueAt: number().nullable(),
42852
+ /** Model ids registered from this job (base, and int8 when kept). */
42853
+ registeredModelIds: array(string()).readonly(),
42854
+ canary: TrainingCanarySchema.nullable()
42855
+ });
42856
+ var IdInput = object({ id: string().min(1) });
42857
+ method(TrainingDatasetVersionRowSchema, object({ stored: boolean() }), {
42858
+ kind: "mutation",
42859
+ auth: "admin"
42860
+ }), 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() }), {
42861
+ kind: "mutation",
42862
+ auth: "admin"
42863
+ }), method(object({}), array(TrainingBaseModelSchema).readonly(), { auth: "admin" }), method(TrainingJobRequestSchema, TrainingJobPlanSchema, {
42864
+ auth: "admin",
42865
+ timeoutMs: 6e4
42866
+ }), method(TrainingJobRequestSchema.extend({
42867
+ name: string().min(1).max(120),
42868
+ maxCostUsd: number().positive(),
42869
+ maxRuntimeSec: number().int().positive(),
42870
+ idempotencyKey: string().min(8).max(80)
42871
+ }), discriminatedUnion("kind", [object({
42872
+ kind: literal("started"),
42873
+ job: TrainingJobSchema
42874
+ }), object({
42875
+ kind: literal("refused"),
42876
+ reason: TrainingRefusalReasonSchema,
42877
+ detail: string()
42878
+ })]), {
42879
+ kind: "mutation",
42880
+ auth: "admin",
42881
+ timeoutMs: 12e4
42882
+ }), method(object({}), array(TrainingJobSchema).readonly(), { auth: "admin" }), method(IdInput, TrainingJobSchema.nullable(), { auth: "admin" }), method(IdInput, TrainingJobSchema, {
42883
+ kind: "mutation",
42884
+ auth: "admin",
42885
+ timeoutMs: 12e4
42886
+ }), method(IdInput, TrainingResultSchema.nullable(), { auth: "admin" }), method(IdInput.extend({ canaryDeviceIds: array(number().int()).readonly() }), TrainingJobSchema, {
42887
+ kind: "mutation",
42888
+ auth: "admin",
42889
+ timeoutMs: 30 * 6e4
42890
+ }), method(IdInput.extend({ deviceIds: array(number().int()).min(1).readonly() }), TrainingJobSchema, {
42891
+ kind: "mutation",
42892
+ auth: "admin",
42893
+ timeoutMs: 12e4
42894
+ }), method(IdInput, TrainingJobSchema, {
42895
+ kind: "mutation",
42896
+ auth: "admin",
42897
+ timeoutMs: 12e4
42898
+ }), method(IdInput, TrainingJobSchema, {
42899
+ kind: "mutation",
42900
+ auth: "admin"
42901
+ });
41501
42902
  SOURCE_CAPS.filter((cap) => cap !== "switch" && cap !== "motion");
41502
42903
  Object.freeze({
41503
42904
  person: .5,
@@ -43646,6 +45047,12 @@ Object.freeze({
43646
45047
  addonId: null,
43647
45048
  access: "create"
43648
45049
  },
45050
+ "backup.checkBackupKey": {
45051
+ capName: "backup",
45052
+ capScope: "system",
45053
+ addonId: null,
45054
+ access: "create"
45055
+ },
43649
45056
  "backup.delete": {
43650
45057
  capName: "backup",
43651
45058
  capScope: "system",
@@ -43658,6 +45065,18 @@ Object.freeze({
43658
45065
  addonId: null,
43659
45066
  access: "delete"
43660
45067
  },
45068
+ "backup.disableEncryption": {
45069
+ capName: "backup",
45070
+ capScope: "system",
45071
+ addonId: null,
45072
+ access: "create"
45073
+ },
45074
+ "backup.getEncryption": {
45075
+ capName: "backup",
45076
+ capScope: "system",
45077
+ addonId: null,
45078
+ access: "view"
45079
+ },
43661
45080
  "backup.getEntries": {
43662
45081
  capName: "backup",
43663
45082
  capScope: "system",
@@ -43712,6 +45131,12 @@ Object.freeze({
43712
45131
  addonId: null,
43713
45132
  access: "create"
43714
45133
  },
45134
+ "backup.setupEncryption": {
45135
+ capName: "backup",
45136
+ capScope: "system",
45137
+ addonId: null,
45138
+ access: "create"
45139
+ },
43715
45140
  "backup.trigger": {
43716
45141
  capName: "backup",
43717
45142
  capScope: "system",
@@ -44264,6 +45689,12 @@ Object.freeze({
44264
45689
  addonId: null,
44265
45690
  access: "create"
44266
45691
  },
45692
+ "customModelRegistry.importModelBundle": {
45693
+ capName: "custom-model-registry",
45694
+ capScope: "system",
45695
+ addonId: null,
45696
+ access: "create"
45697
+ },
44267
45698
  "customModelRegistry.listModels": {
44268
45699
  capName: "custom-model-registry",
44269
45700
  capScope: "system",
@@ -45704,6 +47135,12 @@ Object.freeze({
45704
47135
  addonId: null,
45705
47136
  access: "view"
45706
47137
  },
47138
+ "keychainAdmin.acknowledgeReset": {
47139
+ capName: "keychain-admin",
47140
+ capScope: "system",
47141
+ addonId: null,
47142
+ access: "create"
47143
+ },
45707
47144
  "keychainAdmin.deleteOrphans": {
45708
47145
  capName: "keychain-admin",
45709
47146
  capScope: "system",
@@ -45740,6 +47177,12 @@ Object.freeze({
45740
47177
  addonId: null,
45741
47178
  access: "delete"
45742
47179
  },
47180
+ "keychainAdmin.resetReport": {
47181
+ capName: "keychain-admin",
47182
+ capScope: "system",
47183
+ addonId: null,
47184
+ access: "delete"
47185
+ },
45743
47186
  "keychainAdmin.reveal": {
45744
47187
  capName: "keychain-admin",
45745
47188
  capScope: "system",
@@ -45752,6 +47195,12 @@ Object.freeze({
45752
47195
  addonId: null,
45753
47196
  access: "create"
45754
47197
  },
47198
+ "keychainAdmin.setSystemSecret": {
47199
+ capName: "keychain-admin",
47200
+ capScope: "system",
47201
+ addonId: null,
47202
+ access: "create"
47203
+ },
45755
47204
  "keychainAdmin.status": {
45756
47205
  capName: "keychain-admin",
45757
47206
  capScope: "system",
@@ -47198,6 +48647,12 @@ Object.freeze({
47198
48647
  addonId: null,
47199
48648
  access: "create"
47200
48649
  },
48650
+ "pipelineAnalytics.createRetrainDatasetVersion": {
48651
+ capName: "pipeline-analytics",
48652
+ capScope: "device",
48653
+ addonId: null,
48654
+ access: "create"
48655
+ },
47201
48656
  "pipelineAnalytics.deleteDeviceEvents": {
47202
48657
  capName: "pipeline-analytics",
47203
48658
  capScope: "device",
@@ -47210,6 +48665,12 @@ Object.freeze({
47210
48665
  addonId: null,
47211
48666
  access: "delete"
47212
48667
  },
48668
+ "pipelineAnalytics.deleteRetrainDatasetVersion": {
48669
+ capName: "pipeline-analytics",
48670
+ capScope: "device",
48671
+ addonId: null,
48672
+ access: "delete"
48673
+ },
47213
48674
  "pipelineAnalytics.deleteTracks": {
47214
48675
  capName: "pipeline-analytics",
47215
48676
  capScope: "device",
@@ -47432,6 +48893,12 @@ Object.freeze({
47432
48893
  addonId: null,
47433
48894
  access: "view"
47434
48895
  },
48896
+ "pipelineAnalytics.listRetrainDatasetVersions": {
48897
+ capName: "pipeline-analytics",
48898
+ capScope: "device",
48899
+ addonId: null,
48900
+ access: "view"
48901
+ },
47435
48902
  "pipelineAnalytics.listRetrainFrames": {
47436
48903
  capName: "pipeline-analytics",
47437
48904
  capScope: "device",
@@ -47462,6 +48929,12 @@ Object.freeze({
47462
48929
  addonId: null,
47463
48930
  access: "view"
47464
48931
  },
48932
+ "pipelineAnalytics.offerRetrainArchive": {
48933
+ capName: "pipeline-analytics",
48934
+ capScope: "device",
48935
+ addonId: null,
48936
+ access: "create"
48937
+ },
47465
48938
  "pipelineAnalytics.ownersWithMedia": {
47466
48939
  capName: "pipeline-analytics",
47467
48940
  capScope: "device",
@@ -47474,6 +48947,12 @@ Object.freeze({
47474
48947
  addonId: null,
47475
48948
  access: "create"
47476
48949
  },
48950
+ "pipelineAnalytics.previewRetrainDataset": {
48951
+ capName: "pipeline-analytics",
48952
+ capScope: "device",
48953
+ addonId: null,
48954
+ access: "view"
48955
+ },
47477
48956
  "pipelineAnalytics.proposeRetrainAnnotations": {
47478
48957
  capName: "pipeline-analytics",
47479
48958
  capScope: "device",
@@ -47612,6 +49091,12 @@ Object.freeze({
47612
49091
  addonId: null,
47613
49092
  access: "create"
47614
49093
  },
49094
+ "pipelineAnalytics.verifyRetrainDatasetVersion": {
49095
+ capName: "pipeline-analytics",
49096
+ capScope: "device",
49097
+ addonId: null,
49098
+ access: "view"
49099
+ },
47615
49100
  "pipelineAnalytics.wipeAllAnalytics": {
47616
49101
  capName: "pipeline-analytics",
47617
49102
  capScope: "device",
@@ -49988,6 +51473,174 @@ Object.freeze({
49988
51473
  addonId: null,
49989
51474
  access: "view"
49990
51475
  },
51476
+ "training.canaryResult": {
51477
+ capName: "training",
51478
+ capScope: "system",
51479
+ addonId: null,
51480
+ access: "create"
51481
+ },
51482
+ "training.cancelJob": {
51483
+ capName: "training",
51484
+ capScope: "system",
51485
+ addonId: null,
51486
+ access: "create"
51487
+ },
51488
+ "training.discardResult": {
51489
+ capName: "training",
51490
+ capScope: "system",
51491
+ addonId: null,
51492
+ access: "create"
51493
+ },
51494
+ "training.findDatasetVersionIdByName": {
51495
+ capName: "training",
51496
+ capScope: "system",
51497
+ addonId: null,
51498
+ access: "view"
51499
+ },
51500
+ "training.getDatasetVersion": {
51501
+ capName: "training",
51502
+ capScope: "system",
51503
+ addonId: null,
51504
+ access: "view"
51505
+ },
51506
+ "training.getJob": {
51507
+ capName: "training",
51508
+ capScope: "system",
51509
+ addonId: null,
51510
+ access: "view"
51511
+ },
51512
+ "training.getJobResult": {
51513
+ capName: "training",
51514
+ capScope: "system",
51515
+ addonId: null,
51516
+ access: "view"
51517
+ },
51518
+ "training.listBaseModels": {
51519
+ capName: "training",
51520
+ capScope: "system",
51521
+ addonId: null,
51522
+ access: "view"
51523
+ },
51524
+ "training.listDatasetVersions": {
51525
+ capName: "training",
51526
+ capScope: "system",
51527
+ addonId: null,
51528
+ access: "view"
51529
+ },
51530
+ "training.listJobs": {
51531
+ capName: "training",
51532
+ capScope: "system",
51533
+ addonId: null,
51534
+ access: "view"
51535
+ },
51536
+ "training.planJob": {
51537
+ capName: "training",
51538
+ capScope: "system",
51539
+ addonId: null,
51540
+ access: "view"
51541
+ },
51542
+ "training.putDatasetVersion": {
51543
+ capName: "training",
51544
+ capScope: "system",
51545
+ addonId: null,
51546
+ access: "create"
51547
+ },
51548
+ "training.registerResult": {
51549
+ capName: "training",
51550
+ capScope: "system",
51551
+ addonId: null,
51552
+ access: "create"
51553
+ },
51554
+ "training.removeDatasetVersion": {
51555
+ capName: "training",
51556
+ capScope: "system",
51557
+ addonId: null,
51558
+ access: "delete"
51559
+ },
51560
+ "training.rollbackCanary": {
51561
+ capName: "training",
51562
+ capScope: "system",
51563
+ addonId: null,
51564
+ access: "create"
51565
+ },
51566
+ "training.startJob": {
51567
+ capName: "training",
51568
+ capScope: "system",
51569
+ addonId: null,
51570
+ access: "create"
51571
+ },
51572
+ "trainingProvider.cancelJob": {
51573
+ capName: "training-provider",
51574
+ capScope: "system",
51575
+ addonId: null,
51576
+ access: "create"
51577
+ },
51578
+ "trainingProvider.cleanupJob": {
51579
+ capName: "training-provider",
51580
+ capScope: "system",
51581
+ addonId: null,
51582
+ access: "create"
51583
+ },
51584
+ "trainingProvider.describe": {
51585
+ capName: "training-provider",
51586
+ capScope: "system",
51587
+ addonId: null,
51588
+ access: "view"
51589
+ },
51590
+ "trainingProvider.estimateJob": {
51591
+ capName: "training-provider",
51592
+ capScope: "system",
51593
+ addonId: null,
51594
+ access: "view"
51595
+ },
51596
+ "trainingProvider.getJob": {
51597
+ capName: "training-provider",
51598
+ capScope: "system",
51599
+ addonId: null,
51600
+ access: "view"
51601
+ },
51602
+ "trainingProvider.listJobEvents": {
51603
+ capName: "training-provider",
51604
+ capScope: "system",
51605
+ addonId: null,
51606
+ access: "view"
51607
+ },
51608
+ "trainingProvider.listJobs": {
51609
+ capName: "training-provider",
51610
+ capScope: "system",
51611
+ addonId: null,
51612
+ access: "view"
51613
+ },
51614
+ "trainingProvider.offerArtifact": {
51615
+ capName: "training-provider",
51616
+ capScope: "system",
51617
+ addonId: null,
51618
+ access: "create"
51619
+ },
51620
+ "trainingProvider.readResult": {
51621
+ capName: "training-provider",
51622
+ capScope: "system",
51623
+ addonId: null,
51624
+ access: "create"
51625
+ },
51626
+ "trainingProvider.submitJob": {
51627
+ capName: "training-provider",
51628
+ capScope: "system",
51629
+ addonId: null,
51630
+ access: "create"
51631
+ },
51632
+ "trainingProvider.uploadDataset": {
51633
+ capName: "training-provider",
51634
+ capScope: "system",
51635
+ addonId: null,
51636
+ access: "create"
51637
+ },
51638
+ "trainingProvider.validateCredentials": {
51639
+ capName: "training-provider",
51640
+ capScope: "system",
51641
+ addonId: null,
51642
+ access: "create"
51643
+ },
49991
51644
  "turnProvider.getTurnServers": {
49992
51645
  capName: "turn-provider",
49993
51646
  capScope: "system",
@@ -50012,12 +51665,6 @@ Object.freeze({
50012
51665
  addonId: null,
50013
51666
  access: "create"
50014
51667
  },
50015
- "userManagement.createApiKey": {
50016
- capName: "user-management",
50017
- capScope: "system",
50018
- addonId: null,
50019
- access: "create"
50020
- },
50021
51668
  "userManagement.createScopedToken": {
50022
51669
  capName: "user-management",
50023
51670
  capScope: "system",
@@ -50054,12 +51701,6 @@ Object.freeze({
50054
51701
  addonId: null,
50055
51702
  access: "view"
50056
51703
  },
50057
- "userManagement.linkExternalIdentity": {
50058
- capName: "user-management",
50059
- capScope: "system",
50060
- addonId: null,
50061
- access: "create"
50062
- },
50063
51704
  "userManagement.listApiKeys": {
50064
51705
  capName: "user-management",
50065
51706
  capScope: "system",
@@ -50162,12 +51803,6 @@ Object.freeze({
50162
51803
  addonId: null,
50163
51804
  access: "create"
50164
51805
  },
50165
- "userManagement.validateApiKey": {
50166
- capName: "user-management",
50167
- capScope: "system",
50168
- addonId: null,
50169
- access: "view"
50170
- },
50171
51806
  "userManagement.validateCredentials": {
50172
51807
  capName: "user-management",
50173
51808
  capScope: "system",
@@ -54347,6 +55982,11 @@ Object.freeze({
54347
55982
  form: "single",
54348
55983
  optional: false
54349
55984
  }],
55985
+ "training.canaryResult": [{
55986
+ name: "deviceIds",
55987
+ form: "array",
55988
+ optional: false
55989
+ }],
54350
55990
  "update.getStatus": [{
54351
55991
  name: "deviceId",
54352
55992
  form: "single",
@@ -55649,7 +57289,12 @@ var CREDENTIAL_PARAM_PATTERNS = [
55649
57289
  /^bearer$/i,
55650
57290
  /^api[_-]?key$/i,
55651
57291
  /^access[_-]?token$/i,
55652
- /^refresh[_-]?token$/i
57292
+ /^refresh[_-]?token$/i,
57293
+ /^bridge$/i,
57294
+ /^code$/i,
57295
+ /^state$/i,
57296
+ /^challenge$/i,
57297
+ /^link$/i
55653
57298
  ];
55654
57299
  function isCredentialParam(name) {
55655
57300
  return CREDENTIAL_PARAM_PATTERNS.some((re) => re.test(name));
@@ -55671,6 +57316,10 @@ function isCredentialParam(name) {
55671
57316
  * are NOT masked (those are entity references, not credentials).
55672
57317
  */
55673
57318
  function maskUrlCredentials(rawUrl) {
57319
+ if (rawUrl.startsWith("/") && !rawUrl.startsWith("//")) {
57320
+ const masked = maskUrlCredentials(`http://relative.invalid${rawUrl}`);
57321
+ return masked.startsWith("http://relative.invalid") ? masked.slice(23) : rawUrl;
57322
+ }
55674
57323
  try {
55675
57324
  const u = new URL(rawUrl);
55676
57325
  let touched = false;