@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.js CHANGED
@@ -5401,7 +5401,7 @@ var ZodIssueCode = {
5401
5401
  var ZodFirstPartyTypeKind;
5402
5402
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
5403
5403
  //#endregion
5404
- //#region ../types/dist/sleep-Cr5YOk3m.mjs
5404
+ //#region ../types/dist/sleep-r3RWkGVx.mjs
5405
5405
  /**
5406
5406
  * The audio chunk plane's byte format, and the ONE expansion from a coded
5407
5407
  * window to float samples (D455).
@@ -5518,7 +5518,7 @@ function isKeychainStoredField(field) {
5518
5518
  var SECRET_CLEAR = { $secretClear: true };
5519
5519
  /** The `'***'` token D634 redaction writes for non-admins. */
5520
5520
  var LEGACY_DEVICE_REDACTION = "***";
5521
- function isRecord$1(value) {
5521
+ function isRecord$2(value) {
5522
5522
  return typeof value === "object" && value !== null && !Array.isArray(value);
5523
5523
  }
5524
5524
  function makeSecretMarker(ref) {
@@ -5529,12 +5529,12 @@ function makeSecretMarker(ref) {
5529
5529
  }
5530
5530
  /** A stored marker: an object whose `$secret` is a non-empty string. */
5531
5531
  function isSecretMarker(value) {
5532
- if (!isRecord$1(value)) return false;
5532
+ if (!isRecord$2(value)) return false;
5533
5533
  const ref = value["$secret"];
5534
5534
  return typeof ref === "string" && ref.length > 0;
5535
5535
  }
5536
5536
  function isSecretClear(value) {
5537
- return isRecord$1(value) && value["$secretClear"] === true;
5537
+ return isRecord$2(value) && value["$secretClear"] === true;
5538
5538
  }
5539
5539
  /**
5540
5540
  * The UI view of a stored secret field value: a marker becomes "set", inline
@@ -6050,6 +6050,13 @@ function globalSecretScope() {
6050
6050
  function encodeSegment(value) {
6051
6051
  return encodeURIComponent(value);
6052
6052
  }
6053
+ function decodeSegment(value) {
6054
+ try {
6055
+ return decodeURIComponent(value);
6056
+ } catch {
6057
+ return null;
6058
+ }
6059
+ }
6053
6060
  /**
6054
6061
  * The field path of a value inside an array item, addressed by the item's id:
6055
6062
  * `arrayItemFieldPath('providers', 'authentik', 'clientSecret')` →
@@ -6058,6 +6065,75 @@ function encodeSegment(value) {
6058
6065
  function arrayItemFieldPath(arrayKey, itemId, fieldKey) {
6059
6066
  return `${arrayKey}[${encodeSegment(itemId)}].${fieldKey}`;
6060
6067
  }
6068
+ function parseScope(segments) {
6069
+ switch (segments[0]) {
6070
+ case "global": return {
6071
+ scope: GLOBAL_SCOPE,
6072
+ used: 1
6073
+ };
6074
+ case "node": {
6075
+ const nodeId = segments[1] !== void 0 ? decodeSegment(segments[1]) : null;
6076
+ return nodeId === null || nodeId.length === 0 ? null : {
6077
+ scope: {
6078
+ kind: "node",
6079
+ nodeId
6080
+ },
6081
+ used: 2
6082
+ };
6083
+ }
6084
+ case "device": {
6085
+ const raw = segments[1];
6086
+ if (raw === void 0 || !/^\d+$/.test(raw)) return null;
6087
+ return {
6088
+ scope: {
6089
+ kind: "device",
6090
+ deviceId: Number(raw)
6091
+ },
6092
+ used: 2
6093
+ };
6094
+ }
6095
+ case "integration": {
6096
+ const id = segments[1] !== void 0 ? decodeSegment(segments[1]) : null;
6097
+ return id === null || id.length === 0 ? null : {
6098
+ scope: {
6099
+ kind: "integration",
6100
+ integrationId: id
6101
+ },
6102
+ used: 2
6103
+ };
6104
+ }
6105
+ case "row": {
6106
+ const collection = segments[1] !== void 0 ? decodeSegment(segments[1]) : null;
6107
+ const rowId = segments[2] !== void 0 ? decodeSegment(segments[2]) : null;
6108
+ if (collection === null || rowId === null || collection.length === 0 || rowId.length === 0) return null;
6109
+ return {
6110
+ scope: {
6111
+ kind: "row",
6112
+ collection,
6113
+ rowId
6114
+ },
6115
+ used: 3
6116
+ };
6117
+ }
6118
+ default: return null;
6119
+ }
6120
+ }
6121
+ /** Take a ref apart; `null` when it is not a well-formed ref. */
6122
+ function parseSecretRef(ref) {
6123
+ if (!ref.startsWith("secret://")) return null;
6124
+ const segments = ref.slice(9).split("/");
6125
+ const owner = segments[0] !== void 0 ? decodeSegment(segments[0]) : null;
6126
+ if (owner === null || owner.length === 0) return null;
6127
+ const parsed = parseScope(segments.slice(1));
6128
+ if (parsed === null) return null;
6129
+ const fieldPath = segments.slice(1 + parsed.used).join("/");
6130
+ if (fieldPath.length === 0) return null;
6131
+ return {
6132
+ owner,
6133
+ scope: parsed.scope,
6134
+ fieldPath
6135
+ };
6136
+ }
6061
6137
  /** A write to a secret path could not be stored in the keychain, so it was refused. */
6062
6138
  var KeychainWriteRefusedError = class extends Error {
6063
6139
  fieldPath;
@@ -6068,7 +6144,7 @@ var KeychainWriteRefusedError = class extends Error {
6068
6144
  }
6069
6145
  };
6070
6146
  var KEEP = { kind: "keep" };
6071
- function isRecord(value) {
6147
+ function isRecord$1(value) {
6072
6148
  return typeof value === "object" && value !== null && !Array.isArray(value);
6073
6149
  }
6074
6150
  function defaultMintId() {
@@ -6081,7 +6157,7 @@ function collectSecretMarkerRefs(value, out = []) {
6081
6157
  return out;
6082
6158
  }
6083
6159
  if (Array.isArray(value)) for (const item of value) collectSecretMarkerRefs(item, out);
6084
- else if (isRecord(value)) for (const child of Object.values(value)) collectSecretMarkerRefs(child, out);
6160
+ else if (isRecord$1(value)) for (const child of Object.values(value)) collectSecretMarkerRefs(child, out);
6085
6161
  return out;
6086
6162
  }
6087
6163
  async function storedValueEquals(secrets, marker, candidate) {
@@ -6136,7 +6212,7 @@ function rowId(row, idKey) {
6136
6212
  return null;
6137
6213
  }
6138
6214
  async function writeArray(ctx, node, incoming, stored, fieldPath) {
6139
- const storedRows = Array.isArray(stored) ? stored.filter(isRecord) : [];
6215
+ const storedRows = Array.isArray(stored) ? stored.filter(isRecord$1) : [];
6140
6216
  if (!Array.isArray(incoming)) {
6141
6217
  ctx.deletes.push(...collectSecretMarkerRefs(storedRows));
6142
6218
  return {
@@ -6152,7 +6228,7 @@ async function writeArray(ctx, node, incoming, stored, fieldPath) {
6152
6228
  const kept = /* @__PURE__ */ new Set();
6153
6229
  const rows = [];
6154
6230
  for (const row of incoming) {
6155
- if (!isRecord(row)) {
6231
+ if (!isRecord$1(row)) {
6156
6232
  rows.push(row);
6157
6233
  continue;
6158
6234
  }
@@ -6177,7 +6253,7 @@ async function writeNode(ctx, node, incoming, stored, fieldPath) {
6177
6253
  case "leaf": return writeLeaf(ctx, incoming, stored, fieldPath);
6178
6254
  case "array": return writeArray(ctx, node, incoming, stored, fieldPath);
6179
6255
  case "object": {
6180
- if (!isRecord(incoming)) {
6256
+ if (!isRecord$1(incoming)) {
6181
6257
  if (incoming === void 0) return KEEP;
6182
6258
  ctx.deletes.push(...collectSecretMarkerRefs(stored));
6183
6259
  return {
@@ -6185,7 +6261,7 @@ async function writeNode(ctx, node, incoming, stored, fieldPath) {
6185
6261
  value: incoming
6186
6262
  };
6187
6263
  }
6188
- const storedObj = isRecord(stored) ? stored : {};
6264
+ const storedObj = isRecord$1(stored) ? stored : {};
6189
6265
  return {
6190
6266
  kind: "value",
6191
6267
  value: await writeMembers(ctx, node.children, incoming, storedObj, (m) => `${fieldPath}.${m}`)
@@ -6244,12 +6320,19 @@ async function transformSecretWrite(input) {
6244
6320
  }
6245
6321
  };
6246
6322
  }
6323
+ /** Is `ref` one of `owner`'s refs? */
6324
+ function isSecretRefOwnedBy(ref, owner) {
6325
+ return parseSecretRef(ref)?.owner === owner;
6326
+ }
6247
6327
  /**
6248
6328
  * Replace every marker in `value` with its keychain value. Returns the SAME
6249
6329
  * reference when there is no marker (no allocation, no keychain call).
6250
6330
  */
6251
- async function resolveSecretMarkers(value, secrets) {
6252
- const refs = collectSecretMarkerRefs(value);
6331
+ async function resolveSecretMarkers(value, secrets, options = {}) {
6332
+ const keepMarker = options.unresolved === "keep-marker";
6333
+ const owner = options.ownedBy;
6334
+ const inScope = (ref) => owner === void 0 || isSecretRefOwnedBy(ref, owner);
6335
+ const refs = collectSecretMarkerRefs(value).filter(inScope);
6253
6336
  if (refs.length === 0) return {
6254
6337
  value,
6255
6338
  unresolved: []
@@ -6273,10 +6356,18 @@ async function resolveSecretMarkers(value, secrets) {
6273
6356
  }
6274
6357
  const substitute = (v) => {
6275
6358
  if (isSecretMarker(v)) {
6359
+ if (!inScope(v.$secret)) return {
6360
+ keep: true,
6361
+ value: v
6362
+ };
6276
6363
  const answer = answers[v.$secret];
6277
- return answer?.kind === "value" ? {
6364
+ if (answer?.kind === "value") return {
6278
6365
  keep: true,
6279
6366
  value: answer.value
6367
+ };
6368
+ return keepMarker ? {
6369
+ keep: true,
6370
+ value: v
6280
6371
  } : {
6281
6372
  keep: false,
6282
6373
  value: void 0
@@ -6293,7 +6384,7 @@ async function resolveSecretMarkers(value, secrets) {
6293
6384
  value: items
6294
6385
  };
6295
6386
  }
6296
- if (isRecord(v)) {
6387
+ if (isRecord$1(v)) {
6297
6388
  const out = {};
6298
6389
  for (const [k, child] of Object.entries(v)) {
6299
6390
  const s = substitute(child);
@@ -6314,14 +6405,152 @@ async function resolveSecretMarkers(value, secrets) {
6314
6405
  unresolved
6315
6406
  };
6316
6407
  }
6317
- function touchesTree(tree, patch) {
6318
- if (tree.size === 0) return false;
6319
- for (const key of Object.keys(patch)) {
6320
- const at = key.indexOf("@");
6321
- if (tree.has(at > 0 ? key.slice(0, at) : key)) return true;
6408
+ /** An addon tried to replace a stored secret it could not read. Nothing was written. */
6409
+ var SecretOverwriteRefusedError = class extends Error {
6410
+ ref;
6411
+ reason;
6412
+ constructor(ref, reason) {
6413
+ 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.`);
6414
+ this.ref = ref;
6415
+ this.reason = reason;
6416
+ this.name = "SecretOverwriteRefusedError";
6417
+ }
6418
+ };
6419
+ function isRecord(value) {
6420
+ return typeof value === "object" && value !== null && !Array.isArray(value);
6421
+ }
6422
+ function resolvedValue(pass, marker) {
6423
+ const answer = pass.answers[marker.$secret];
6424
+ return answer?.kind === "value" ? answer.value : null;
6425
+ }
6426
+ async function atMarker(pass, incoming, stored) {
6427
+ if (incoming === null) return stored;
6428
+ if (typeof incoming !== "string") return incoming;
6429
+ if (incoming === resolvedValue(pass, stored)) return stored;
6430
+ const intent = classifySecretWrite(incoming);
6431
+ if (intent.kind !== "set") return stored;
6432
+ const ref = stored.$secret;
6433
+ if (!isSecretRefOwnedBy(ref, pass.secrets.owner)) return incoming;
6434
+ const answer = pass.answers[ref];
6435
+ 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);
6436
+ try {
6437
+ await pass.secrets.put(ref, intent.value);
6438
+ } catch (err) {
6439
+ throw new KeychainWriteRefusedError(ref, err);
6440
+ }
6441
+ pass.changedRefs.push(ref);
6442
+ return stored;
6443
+ }
6444
+ function inArray(pass, incoming, stored) {
6445
+ return incoming.map((item, index) => {
6446
+ const twin = stored[index];
6447
+ if (isSecretMarker(twin)) return typeof item === "string" && item === resolvedValue(pass, twin) ? twin : item;
6448
+ if (isRecord(item) && isRecord(twin)) return inArrayRow(pass, item, twin);
6449
+ if (Array.isArray(item) && Array.isArray(twin)) return inArray(pass, item, twin);
6450
+ return item;
6451
+ });
6452
+ }
6453
+ function inArrayRow(pass, incoming, stored) {
6454
+ const out = { ...incoming };
6455
+ for (const [key, value] of Object.entries(incoming)) {
6456
+ const twin = stored[key];
6457
+ if (isSecretMarker(twin)) {
6458
+ if (typeof value === "string" && value === resolvedValue(pass, twin)) out[key] = twin;
6459
+ } else if (isRecord(value) && isRecord(twin)) out[key] = inArrayRow(pass, value, twin);
6460
+ else if (Array.isArray(value) && Array.isArray(twin)) out[key] = inArray(pass, value, twin);
6461
+ }
6462
+ return out;
6463
+ }
6464
+ async function walk(pass, incoming, stored) {
6465
+ if (isSecretMarker(stored)) return atMarker(pass, incoming, stored);
6466
+ if (Array.isArray(incoming) && Array.isArray(stored)) return inArray(pass, incoming, stored);
6467
+ if (!isRecord(incoming) || !isRecord(stored)) return incoming;
6468
+ const out = { ...incoming };
6469
+ for (const [key, value] of Object.entries(incoming)) out[key] = await walk(pass, value, stored[key]);
6470
+ return out;
6471
+ }
6472
+ /** Restore markers a write-back carries as values. See the file doc. */
6473
+ async function restoreUnchangedSecrets(input) {
6474
+ const refs = [];
6475
+ for (const key of Object.keys(input.patch)) collectSecretMarkerRefs(input.stored[key], refs);
6476
+ const owned = refs.filter((ref) => isSecretRefOwnedBy(ref, input.secrets.owner));
6477
+ if (owned.length === 0) return {
6478
+ patch: input.patch,
6479
+ changedRefs: []
6480
+ };
6481
+ const pass = {
6482
+ secrets: input.secrets,
6483
+ answers: await input.secrets.resolve([...new Set(owned)]),
6484
+ operatorWrite: input.operatorWrite,
6485
+ changedRefs: []
6486
+ };
6487
+ const out = {};
6488
+ for (const [key, value] of Object.entries(input.patch)) out[key] = await walk(pass, value, input.stored[key]);
6489
+ return {
6490
+ patch: out,
6491
+ changedRefs: pass.changedRefs
6492
+ };
6493
+ }
6494
+ /** Structural equality over JSON-shaped values (key order does not matter). */
6495
+ function isJsonEqual(a, b) {
6496
+ if (Object.is(a, b)) return true;
6497
+ if (Array.isArray(a)) return Array.isArray(b) && a.length === b.length && a.every((v, i) => isJsonEqual(v, b[i]));
6498
+ if (isRecord(a) && isRecord(b)) {
6499
+ const keys = Object.keys(a);
6500
+ if (keys.length !== Object.keys(b).length) return false;
6501
+ return keys.every((k) => Object.prototype.hasOwnProperty.call(b, k) && isJsonEqual(a[k], b[k]));
6322
6502
  }
6323
6503
  return false;
6324
6504
  }
6505
+ /** The patch without the keys whose value already equals the stored one. */
6506
+ function dropUnchangedKeys(patch, stored) {
6507
+ const out = {};
6508
+ for (const [key, value] of Object.entries(patch)) {
6509
+ if (Object.prototype.hasOwnProperty.call(stored, key) && isJsonEqual(value, stored[key])) continue;
6510
+ out[key] = value;
6511
+ }
6512
+ return out;
6513
+ }
6514
+ /** The top-level keys of a blob that hold at least one of `owner`'s markers. */
6515
+ function markerKeysOf(blob, owner) {
6516
+ const keys = /* @__PURE__ */ new Set();
6517
+ for (const [key, value] of Object.entries(blob)) if (collectSecretMarkerRefs(value).some((ref) => isSecretRefOwnedBy(ref, owner))) keys.add(key);
6518
+ return keys;
6519
+ }
6520
+ function nodeFromStored(value, owner) {
6521
+ if (isSecretMarker(value)) return isSecretRefOwnedBy(value.$secret, owner) ? { kind: "leaf" } : null;
6522
+ if (!isRecord(value)) return null;
6523
+ const children = /* @__PURE__ */ new Map();
6524
+ for (const [key, child] of Object.entries(value)) {
6525
+ const node = nodeFromStored(child, owner);
6526
+ if (node !== null) children.set(key, node);
6527
+ }
6528
+ return children.size > 0 ? {
6529
+ kind: "object",
6530
+ children
6531
+ } : null;
6532
+ }
6533
+ /**
6534
+ * The declared secret tree, widened by every place the STORED blob holds a
6535
+ * marker under one of `keys` — so a marker the schema no longer declares (or
6536
+ * never declared: Wyze before b4906cec6) still gets the save path's
6537
+ * KEEP / SET / CLEAR semantics instead of being overwritten by whatever the
6538
+ * addon writes. Markers inside arrays are not added: a row has no id field to
6539
+ * match by unless the schema declares one. Only `owner`'s markers count: a
6540
+ * builtin that keeps another addon's marker (device-manager) never takes it
6541
+ * over.
6542
+ */
6543
+ function widenTreeWithStoredMarkers(declared, stored, keys, owner) {
6544
+ const added = /* @__PURE__ */ new Map();
6545
+ for (const key of keys) {
6546
+ const at = key.indexOf("@");
6547
+ const base = at > 0 ? key.slice(0, at) : key;
6548
+ if (declared.has(base) || added.has(base)) continue;
6549
+ const node = nodeFromStored(stored[key], owner);
6550
+ if (node !== null) added.set(base, node);
6551
+ }
6552
+ return added.size === 0 ? declared : new Map([...declared, ...added]);
6553
+ }
6325
6554
  /** The blob as stored now; a failed read REFUSES the write instead of guessing. */
6326
6555
  async function readStoredAddonBlob(raw) {
6327
6556
  const threeWay = raw.readAddonStoreResult;
@@ -6330,7 +6559,41 @@ async function readStoredAddonBlob(raw) {
6330
6559
  if (result.kind === "failed") throw new Error(`settings write refused: the stored blob could not be read (${result.error})`);
6331
6560
  return result.kind === "missing" ? {} : result.value;
6332
6561
  }
6333
- function createSecretAwareSettings(raw, opts) {
6562
+ function touchesTree(tree, patch) {
6563
+ if (tree.size === 0) return false;
6564
+ for (const key of Object.keys(patch)) {
6565
+ const at = key.indexOf("@");
6566
+ if (tree.has(at > 0 ? key.slice(0, at) : key)) return true;
6567
+ }
6568
+ return false;
6569
+ }
6570
+ /**
6571
+ * Which top-level keys of each store held markers when last seen. `undefined`
6572
+ * for a store not seen yet: its first write reads it, to be safe.
6573
+ */
6574
+ var MarkerKeyIndex = class {
6575
+ owner;
6576
+ byStore = /* @__PURE__ */ new Map();
6577
+ constructor(owner) {
6578
+ this.owner = owner;
6579
+ }
6580
+ seen(store, blob) {
6581
+ this.byStore.set(store, markerKeysOf(blob, this.owner));
6582
+ }
6583
+ wrote(store, patch) {
6584
+ const keys = this.byStore.get(store);
6585
+ if (keys === void 0) return;
6586
+ const now = markerKeysOf(patch, this.owner);
6587
+ for (const key of Object.keys(patch)) if (now.has(key)) keys.add(key);
6588
+ else keys.delete(key);
6589
+ }
6590
+ mayHoldMarkers(store, patch) {
6591
+ const keys = this.byStore.get(store);
6592
+ if (keys === void 0) return true;
6593
+ return Object.keys(patch).some((key) => keys.has(key));
6594
+ }
6595
+ };
6596
+ function createHandle(raw, opts) {
6334
6597
  const chains = /* @__PURE__ */ new Map();
6335
6598
  const serialize = (key, fn) => {
6336
6599
  const next = (chains.get(key) ?? Promise.resolve()).then(fn, fn);
@@ -6341,46 +6604,130 @@ function createSecretAwareSettings(raw, opts) {
6341
6604
  });
6342
6605
  return next;
6343
6606
  };
6344
- const write = async (chainKey, tree, scope, patch, readStored, rawWrite) => {
6345
- if (!touchesTree(tree, patch)) return rawWrite(patch);
6346
- return serialize(chainKey, async () => {
6607
+ const index = new MarkerKeyIndex(opts.secrets.owner);
6608
+ const resolveRead = async (store, blob) => {
6609
+ index.seen(store, blob);
6610
+ const { value, unresolved } = await resolveSecretMarkers(blob, opts.secrets, {
6611
+ unresolved: "keep-marker",
6612
+ ownedBy: opts.secrets.owner
6613
+ });
6614
+ if (unresolved.length > 0) opts.onUnresolved?.(unresolved);
6615
+ return value;
6616
+ };
6617
+ const write = async (store, declared, scope, patch, readStored, rawWrite) => {
6618
+ if (!touchesTree(declared, patch) && !index.mayHoldMarkers(store, patch)) {
6619
+ await rawWrite(patch);
6620
+ index.wrote(store, patch);
6621
+ return { changed: true };
6622
+ }
6623
+ return serialize(store, async () => {
6347
6624
  const stored = await readStored();
6625
+ index.seen(store, stored);
6626
+ const operatorWrite = opts.isOperatorWrite?.() === true;
6627
+ const restored = await restoreUnchangedSecrets({
6628
+ patch,
6629
+ stored,
6630
+ secrets: opts.secrets,
6631
+ operatorWrite
6632
+ });
6348
6633
  const result = await transformSecretWrite({
6349
- tree,
6634
+ tree: widenTreeWithStoredMarkers(declared, stored, Object.keys(restored.patch), opts.secrets.owner),
6350
6635
  secrets: opts.secrets,
6351
- patch,
6636
+ patch: restored.patch,
6352
6637
  stored,
6353
6638
  ...scope !== void 0 ? { scope } : {},
6354
- operatorWrite: opts.isOperatorWrite?.() === true
6639
+ operatorWrite
6355
6640
  });
6356
- if (Object.keys(result.patch).length > 0) await rawWrite(result.patch);
6641
+ const effective = dropUnchangedKeys(result.patch, stored);
6642
+ const wroteBlob = Object.keys(effective).length > 0;
6643
+ if (wroteBlob) {
6644
+ await rawWrite(effective);
6645
+ index.wrote(store, effective);
6646
+ }
6357
6647
  const { orphaned } = await result.afterWrite();
6358
6648
  if (orphaned.length > 0) opts.onOrphaned(orphaned);
6649
+ return { changed: wroteBlob || restored.changedRefs.length > 0 };
6359
6650
  });
6360
6651
  };
6361
- const wrapped = {
6362
- writeAddonStore: (patch) => write("addon", opts.addonTree(), void 0, patch, () => readStoredAddonBlob(raw), (p) => raw.writeAddonStore(p)),
6363
- writeDeviceStore: (deviceId, patch) => write(`device:${deviceId}`, opts.deviceTree(), {
6364
- kind: "device",
6365
- deviceId
6366
- }, patch, () => raw.readDeviceStore(deviceId), (p) => raw.writeDeviceStore(deviceId, p))
6652
+ const writeAddon = (patch) => write("addon", opts.addonTree(), void 0, patch, () => readStoredAddonBlob(raw), (p) => raw.writeAddonStore(p));
6653
+ const readAddonStoreResult = raw.readAddonStoreResult;
6654
+ const readAddonStoreKeyResult = raw.readAddonStoreKeyResult;
6655
+ const readDeviceStoreBatch = raw.readDeviceStoreBatch;
6656
+ const overrides = {
6657
+ readAddonStore: async () => resolveRead("addon", await raw.readAddonStore()),
6658
+ ...readAddonStoreResult !== void 0 ? { readAddonStoreResult: async () => {
6659
+ const result = await readAddonStoreResult.call(raw);
6660
+ return result.kind === "value" ? {
6661
+ kind: "value",
6662
+ value: await resolveRead("addon", result.value)
6663
+ } : result;
6664
+ } } : {},
6665
+ ...readAddonStoreKeyResult !== void 0 ? { readAddonStoreKeyResult: async (key) => {
6666
+ const result = await readAddonStoreKeyResult.call(raw, key);
6667
+ if (result.kind !== "present") return result;
6668
+ const { value, unresolved } = await resolveSecretMarkers({ [key]: result.value }, opts.secrets, {
6669
+ unresolved: "keep-marker",
6670
+ ownedBy: opts.secrets.owner
6671
+ });
6672
+ if (unresolved.length > 0) opts.onUnresolved?.(unresolved);
6673
+ return {
6674
+ kind: "present",
6675
+ value: value[key]
6676
+ };
6677
+ } } : {},
6678
+ readDeviceStore: async (deviceId) => resolveRead(`device:${deviceId}`, await raw.readDeviceStore(deviceId)),
6679
+ ...readDeviceStoreBatch !== void 0 ? { readDeviceStoreBatch: async (deviceIds) => {
6680
+ const rows = await readDeviceStoreBatch.call(raw, deviceIds);
6681
+ const out = /* @__PURE__ */ new Map();
6682
+ for (const [deviceId, blob] of rows) out.set(deviceId, await resolveRead(`device:${deviceId}`, blob));
6683
+ return out;
6684
+ } } : {},
6685
+ writeAddonStore: async (patch) => {
6686
+ await writeAddon(patch);
6687
+ },
6688
+ writeDeviceStore: async (deviceId, patch) => {
6689
+ await write(`device:${deviceId}`, opts.deviceTree(), {
6690
+ kind: "device",
6691
+ deviceId
6692
+ }, patch, () => raw.readDeviceStore(deviceId), (p) => raw.writeDeviceStore(deviceId, p));
6693
+ }
6694
+ };
6695
+ return {
6696
+ settings: new Proxy(raw, { get(target, prop, receiver) {
6697
+ if (typeof prop === "string" && Object.prototype.hasOwnProperty.call(overrides, prop)) return Reflect.get(overrides, prop);
6698
+ const value = Reflect.get(target, prop, receiver);
6699
+ return typeof value === "function" ? value.bind(target) : value;
6700
+ } }),
6701
+ raw: {
6702
+ readAddonStore: async () => {
6703
+ const blob = await raw.readAddonStore();
6704
+ index.seen("addon", blob);
6705
+ return blob;
6706
+ },
6707
+ readDeviceStore: async (deviceId) => {
6708
+ const blob = await raw.readDeviceStore(deviceId);
6709
+ index.seen(`device:${deviceId}`, blob);
6710
+ return blob;
6711
+ }
6712
+ },
6713
+ writeAddonStore: writeAddon
6367
6714
  };
6368
- return new Proxy(raw, { get(target, prop, receiver) {
6369
- if (prop === "writeAddonStore") return wrapped.writeAddonStore;
6370
- if (prop === "writeDeviceStore") return wrapped.writeDeviceStore;
6371
- const value = Reflect.get(target, prop, receiver);
6372
- return typeof value === "function" ? value.bind(target) : value;
6373
- } });
6374
6715
  }
6375
- /** The context the addon sees: identical, except that its settings writes are secret-aware. */
6376
- function withSecretAwareSettings(context, opts) {
6716
+ /** The context the addon sees, plus the private raw view and write outcome. */
6717
+ function createSecretAwareContext(context, opts) {
6377
6718
  const raw = context.settings;
6378
- if (raw === void 0) return context;
6379
- const settings = createSecretAwareSettings(raw, opts);
6380
- return new Proxy(context, { get(target, prop, receiver) {
6381
- if (prop === "settings") return settings;
6382
- return Reflect.get(target, prop, receiver);
6383
- } });
6719
+ if (raw === void 0) return {
6720
+ context,
6721
+ handle: null
6722
+ };
6723
+ const handle = createHandle(raw, opts);
6724
+ return {
6725
+ context: new Proxy(context, { get(target, prop, receiver) {
6726
+ if (prop === "settings") return handle.settings;
6727
+ return Reflect.get(target, prop, receiver);
6728
+ } }),
6729
+ handle
6730
+ };
6384
6731
  }
6385
6732
  var LEAF = { kind: "leaf" };
6386
6733
  var DEFAULT_ITEM_ID_KEY = "id";
@@ -6555,6 +6902,14 @@ var BaseAddon = class {
6555
6902
  _secretChangeUnsub = null;
6556
6903
  /** >0 while an OPERATOR's settings write is being applied. */
6557
6904
  _operatorWriteDepth = 0;
6905
+ /**
6906
+ * The keychain-aware settings handle (D798). Its `raw` view is the ONLY way
6907
+ * to the marker-bearing blobs and stays private to this class: the form
6908
+ * hydrate and config resolution need markers, addon code never does.
6909
+ */
6910
+ _secretSettings = null;
6911
+ /** Refs an addon-facing read could not resolve — each is logged once per process. */
6912
+ _loggedUnresolvedReads = /* @__PURE__ */ new Set();
6558
6913
  constructor(defaults) {
6559
6914
  this.defaults = defaults;
6560
6915
  this._config = { ...defaults };
@@ -6591,13 +6946,21 @@ var BaseAddon = class {
6591
6946
  }
6592
6947
  async initialize(context) {
6593
6948
  const secrets = context.secrets;
6594
- this._ctx = secrets !== void 0 ? withSecretAwareSettings(context, {
6595
- secrets,
6596
- addonTree: () => this.addonSecretTree(),
6597
- deviceTree: () => this.deviceSecretTree(),
6598
- onOrphaned: (refs) => context.logger.warn("keychain refs dropped by a settings write could not be deleted", { meta: { refs: [...refs] } }),
6599
- isOperatorWrite: () => this._operatorWriteDepth > 0
6600
- }) : context;
6949
+ if (secrets !== void 0) {
6950
+ const { context: wrapped, handle } = createSecretAwareContext(context, {
6951
+ secrets,
6952
+ addonTree: () => this.addonSecretTree(),
6953
+ deviceTree: () => this.deviceSecretTree(),
6954
+ onOrphaned: (refs) => context.logger.warn("keychain refs dropped by a settings write could not be deleted", { meta: { refs: [...refs] } }),
6955
+ isOperatorWrite: () => this._operatorWriteDepth > 0,
6956
+ onUnresolved: (unresolved) => this.logUnresolvedRead(unresolved)
6957
+ });
6958
+ this._ctx = wrapped;
6959
+ this._secretSettings = handle;
6960
+ } else {
6961
+ this._ctx = context;
6962
+ this._secretSettings = null;
6963
+ }
6601
6964
  await this.resolveConfig();
6602
6965
  if (secrets !== void 0) this._secretChangeUnsub = secrets.onChange((ref) => {
6603
6966
  if (this._configSecretRefs.has(ref)) this.scheduleSecretReresolve(SECRET_CHANGE_DEBOUNCE_MS);
@@ -6714,11 +7077,8 @@ var BaseAddon = class {
6714
7077
  async getGlobalSettings(overlay, cap, nodeId) {
6715
7078
  const schema = this.globalSettingsSchema(cap);
6716
7079
  if (!schema) return { sections: [] };
6717
- const projected = await this.resolveGlobalStore(nodeId, cap);
6718
- return hydrateSchema(schema, overlay ? {
6719
- ...projected,
6720
- ...overlay
6721
- } : projected, { inlineSecretsAsViews: true });
7080
+ const projected = await this.readRawProjectedStore(nodeId, cap);
7081
+ return hydrateSchema(schema, overlay ? await this.overlayKeepingMarkers(projected, overlay) : projected, { inlineSecretsAsViews: true });
6722
7082
  }
6723
7083
  /**
6724
7084
  * The integration-level view of this addon's settings: exactly the sections
@@ -6763,7 +7123,7 @@ var BaseAddon = class {
6763
7123
  });
6764
7124
  }
6765
7125
  if (sections.length === 0) return null;
6766
- const projected = await this.resolveGlobalStore(nodeId);
7126
+ const projected = await this.readRawProjectedStore(nodeId);
6767
7127
  return hydrateSchema({
6768
7128
  ...schema,
6769
7129
  sections
@@ -6780,12 +7140,50 @@ var BaseAddon = class {
6780
7140
  * the store for custom option logic (option narrowing, value snapping) to
6781
7141
  * read it per-node — never `ctx.settings.readAddonStore()` directly.
6782
7142
  * `nodeId` omitted ⇒ the local node (node-blind injection from ctx).
7143
+ *
7144
+ * Keychain values come back RESOLVED (D798): a secret reads as its value,
7145
+ * never as a `{ $secret }` marker. One the keychain cannot serve right now
7146
+ * stays a marker — "stored, unavailable" (`isSecretMarker()` is true, and it
7147
+ * is listed in {@link unresolvedSecrets}) — never `''` and never absent, so
7148
+ * it cannot be mistaken for "nothing stored, mint a new one". Writing the
7149
+ * resolved blob back is a no-op for every unchanged secret.
6783
7150
  */
6784
7151
  async resolveGlobalStore(nodeId, cap) {
6785
7152
  const raw = await this._ctx?.settings?.readAddonStore() ?? {};
7153
+ return this.projectForNode(raw, nodeId, cap);
7154
+ }
7155
+ projectForNode(store, nodeId, cap) {
6786
7156
  const keys = this.perNodeKeys(cap);
6787
7157
  const node = normalizeNodeId(nodeId ?? this._ctx?.kernel?.localNodeId);
6788
- return keys.size > 0 ? projectStore(raw, keys, node) : raw;
7158
+ return keys.size > 0 ? projectStore(store, keys, node) : store;
7159
+ }
7160
+ /** The PROJECTED store with its markers — the form hydrate only (D798). */
7161
+ async readRawProjectedStore(nodeId, cap) {
7162
+ const raw = await this.rawSettings()?.readAddonStore() ?? {};
7163
+ return this.projectForNode(raw, nodeId, cap);
7164
+ }
7165
+ /**
7166
+ * `{ ...stored, ...overlay }`, except that an overlay member equal to the
7167
+ * RESOLVED stored one keeps the stored (marker-bearing) member — so a form
7168
+ * hydrated from a resolved overlay still shows a secret as "set", never as
7169
+ * its value.
7170
+ */
7171
+ async overlayKeepingMarkers(stored, overlay) {
7172
+ const secrets = this._ctx?.secrets;
7173
+ const merged = {
7174
+ ...stored,
7175
+ ...overlay
7176
+ };
7177
+ if (secrets === void 0 || collectSecretMarkerRefs(stored).length === 0) return merged;
7178
+ const { value: resolved } = await resolveSecretMarkers(stored, secrets, {
7179
+ unresolved: "keep-marker",
7180
+ ownedBy: secrets.owner
7181
+ });
7182
+ for (const key of Object.keys(overlay)) {
7183
+ if (collectSecretMarkerRefs(stored[key]).length === 0) continue;
7184
+ if (isJsonEqual(overlay[key], resolved[key])) merged[key] = stored[key];
7185
+ }
7186
+ return merged;
6789
7187
  }
6790
7188
  /**
6791
7189
  * Whether ONE global key of this addon's store was written, read three-way
@@ -6850,8 +7248,12 @@ var BaseAddon = class {
6850
7248
  async clearSecrets(keys, nodeId) {
6851
7249
  const tree = this.addonSecretTree();
6852
7250
  const keychain = this._ctx?.secrets !== void 0;
7251
+ const stored = keychain ? await this.readAddonStoreWithRetry() : {};
6853
7252
  const patch = {};
6854
- for (const key of keys) patch[key] = keychain && tree.has(key) ? SECRET_CLEAR : "";
7253
+ for (const key of keys) {
7254
+ const keychainStored = tree.has(key) || collectSecretMarkerRefs(stored[key]).length > 0;
7255
+ patch[key] = keychain && keychainStored ? SECRET_CLEAR : "";
7256
+ }
6855
7257
  await this.applyGlobalPatch(patch, nodeId);
6856
7258
  }
6857
7259
  async applyGlobalPatch(barePatch, nodeId) {
@@ -6859,7 +7261,11 @@ var BaseAddon = class {
6859
7261
  const localNode = normalizeNodeId(this._ctx?.kernel?.localNodeId);
6860
7262
  const target = normalizeNodeId(nodeId ?? this._ctx?.kernel?.localNodeId);
6861
7263
  const scoped = keys.size > 0 ? scopePatch(barePatch, keys, target) : barePatch;
6862
- await this._ctx?.settings?.writeAddonStore(scoped);
7264
+ const handle = this._secretSettings;
7265
+ if (handle !== null) {
7266
+ const { changed } = await handle.writeAddonStore(scoped);
7267
+ if (!changed) return;
7268
+ } else await this._ctx?.settings?.writeAddonStore(scoped);
6863
7269
  if (target !== localNode) return;
6864
7270
  await this.resolveConfig();
6865
7271
  await this.onConfigChanged();
@@ -6912,7 +7318,7 @@ var BaseAddon = class {
6912
7318
  async getDeviceSettings(deviceId) {
6913
7319
  const schema = this.deviceSettingsSchema();
6914
7320
  if (!schema) return { sections: [] };
6915
- return hydrateSchema(schema, await this._ctx?.settings?.readDeviceStore(deviceId) ?? {}, { inlineSecretsAsViews: true });
7321
+ return hydrateSchema(schema, await this.rawSettings()?.readDeviceStore(deviceId) ?? {}, { inlineSecretsAsViews: true });
6916
7322
  }
6917
7323
  async updateDeviceSettings(deviceId, patch) {
6918
7324
  await this._ctx?.settings?.writeDeviceStore(deviceId, patch);
@@ -7084,7 +7490,7 @@ var BaseAddon = class {
7084
7490
  key,
7085
7491
  schema,
7086
7492
  fallback,
7087
- read: async () => this.resolveStoredSecrets(await this._ctx?.settings?.readDeviceStore(deviceId) ?? {}, false),
7493
+ read: async () => this.resolveStoredSecrets(await this.rawSettings()?.readDeviceStore(deviceId) ?? {}, false),
7088
7494
  write: async (patch) => {
7089
7495
  await this._ctx?.settings?.writeDeviceStore(deviceId, patch);
7090
7496
  },
@@ -7146,6 +7552,23 @@ var BaseAddon = class {
7146
7552
  }
7147
7553
  return value;
7148
7554
  }
7555
+ /**
7556
+ * The marker-bearing settings reads (D798) — private on purpose. Without a
7557
+ * keychain the context's own view is already raw.
7558
+ */
7559
+ rawSettings() {
7560
+ return this._secretSettings?.raw ?? this._ctx?.settings;
7561
+ }
7562
+ /** An addon-facing read met markers it could not resolve: say so once per ref. */
7563
+ logUnresolvedRead(unresolved) {
7564
+ const fresh = unresolved.filter((u) => !this._loggedUnresolvedReads.has(u.ref));
7565
+ if (fresh.length === 0) return;
7566
+ for (const u of fresh) this._loggedUnresolvedReads.add(u.ref);
7567
+ 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) => ({
7568
+ ref: u.ref,
7569
+ reason: u.reason
7570
+ })) } });
7571
+ }
7149
7572
  /** Re-resolve the config (a keychain-only change, or a retry) and apply it. */
7150
7573
  scheduleSecretReresolve(delayMs) {
7151
7574
  const timerOf = delayMs === SECRET_CHANGE_DEBOUNCE_MS ? "_secretChangeTimer" : "_secretRetryTimer";
@@ -7172,7 +7595,7 @@ var BaseAddon = class {
7172
7595
  * `{}` (defaults) — the addon's first successful patch will rehydrate.
7173
7596
  */
7174
7597
  async readAddonStoreWithRetry() {
7175
- const settings = this._ctx?.settings;
7598
+ const settings = this.rawSettings();
7176
7599
  if (!settings) return {};
7177
7600
  const delaysMs = [
7178
7601
  150,
@@ -9475,6 +9898,278 @@ var CameraSwitchGroupSchema = object({
9475
9898
  fetchedAt: number()
9476
9899
  });
9477
9900
  /**
9901
+ * The trainer contract — what the hub hands the cloud trainer and what it
9902
+ * gets back (cloud training, D805+).
9903
+ *
9904
+ * The trainer (`hf/camstack-trainer`, published as the Hugging Face repo
9905
+ * `camstack/camstack-trainer`) is a separate AGPL program the hub never
9906
+ * imports: `job.json` goes in, files come out, and progress is `CAMSTACK_EVENT`
9907
+ * lines on stdout. These schemas are the hub's half of that boundary; the
9908
+ * trainer's pydantic models (and the JSON Schemas generated from them under
9909
+ * `hf/camstack-trainer/schemas/`) are the other half. A change here is a
9910
+ * change there, in the same piece of work.
9911
+ *
9912
+ * No `.default()` anywhere: defaults do not run on the addon cap path, so the
9913
+ * orchestrator fills every field of a job spec explicitly.
9914
+ */
9915
+ var TRAINING_JOB_SCHEMA = "camstack.training/v1";
9916
+ var TRAINING_RESULT_SCHEMA = "camstack.training-result/v1";
9917
+ /** What the trainer can export. Edge TPU is a later, separate image. */
9918
+ var TrainingExportSchema = _enum([
9919
+ "onnx",
9920
+ "openvino-fp16",
9921
+ "openvino-int8",
9922
+ "coreml-fp16"
9923
+ ]);
9924
+ var FloorsSchema = record(string(), number().min(0).max(1));
9925
+ object({
9926
+ schema: literal(TRAINING_JOB_SCHEMA),
9927
+ jobKey: string().uuid(),
9928
+ target: object({
9929
+ kind: literal("detector"),
9930
+ step: literal("object-detection")
9931
+ }),
9932
+ base: object({
9933
+ modelId: string().min(1),
9934
+ /** Ultralytics weights id, e.g. `yolov9m.pt`. */
9935
+ weights: string().min(1),
9936
+ imgsz: number().int().positive()
9937
+ }),
9938
+ baseline: object({
9939
+ modelId: string().min(1),
9940
+ /** The baseline ONNX the holdout comparison runs; public mirror URL. */
9941
+ onnxUrl: string().url(),
9942
+ imgsz: number().int().positive(),
9943
+ floors: FloorsSchema
9944
+ }),
9945
+ dataset: object({
9946
+ versionId: string().min(1),
9947
+ annotationHash: string(),
9948
+ /** sha256 of the uploaded archive; the trainer refuses a mismatch (exit 65). */
9949
+ sha256: string().regex(/^[0-9a-f]{64}$/)
9950
+ }),
9951
+ split: object({
9952
+ holdoutCameras: array(number().int()),
9953
+ /** When no camera is held out: the last N days of every camera. */
9954
+ holdoutLastDays: number().int().nonnegative(),
9955
+ valFraction: number().min(0).max(.5),
9956
+ seed: number().int()
9957
+ }),
9958
+ hyper: object({
9959
+ epochs: number().int().positive(),
9960
+ batch: number().int().positive(),
9961
+ lr0: number().positive(),
9962
+ /** Layers frozen from the start of the backbone; 0 = none. */
9963
+ freeze: number().int().nonnegative(),
9964
+ patience: number().int().nonnegative(),
9965
+ seed: number().int()
9966
+ }),
9967
+ replay: object({
9968
+ source: literal("coco2017"),
9969
+ count: number().int().nonnegative()
9970
+ }),
9971
+ exports: array(TrainingExportSchema).min(1),
9972
+ calibration: object({ maxFrames: number().int().positive() }),
9973
+ floors: object({
9974
+ minSupport: number().int().positive(),
9975
+ clamp: number().min(0).max(1)
9976
+ }),
9977
+ int8Gate: object({ maxMap50Drop: number().min(0).max(1) }),
9978
+ catalog: object({
9979
+ id: string().regex(/^[a-z0-9][a-z0-9-]{2,80}$/),
9980
+ name: string().min(1).max(160)
9981
+ })
9982
+ });
9983
+ /** One regular file of the bundle. An mlpackage contributes one row per member. */
9984
+ var TrainingResultFileSchema = object({
9985
+ path: string().min(1),
9986
+ bytes: number().int().nonnegative(),
9987
+ sha256: string().regex(/^[0-9a-f]{64}$/),
9988
+ format: _enum([
9989
+ "onnx",
9990
+ "openvino",
9991
+ "coreml",
9992
+ "pt"
9993
+ ]),
9994
+ variant: _enum(["base", "int8"])
9995
+ });
9996
+ var DraftFormatSchema = object({
9997
+ /** RELATIVE path inside the bundle; the hub rewrites it to `camstack-local://`. */
9998
+ url: string().min(1),
9999
+ sizeMB: number().nonnegative(),
10000
+ isDirectory: boolean().optional(),
10001
+ files: array(string()).optional(),
10002
+ runtimes: array(literal("python")).optional(),
10003
+ revision: string().min(1)
10004
+ });
10005
+ /** The trainer's half of a catalog entry; the hub completes it (labels, licence, group). */
10006
+ var TrainingCatalogDraftSchema = object({
10007
+ id: string().min(1),
10008
+ name: string().min(1),
10009
+ description: string(),
10010
+ labels: array(unknown()),
10011
+ inputSize: object({
10012
+ width: number().int().positive(),
10013
+ height: number().int().positive()
10014
+ }),
10015
+ preprocessMode: literal("letterbox"),
10016
+ defaultClassFloors: FloorsSchema,
10017
+ formats: object({
10018
+ onnx: DraftFormatSchema.optional(),
10019
+ openvino: DraftFormatSchema.optional(),
10020
+ coreml: DraftFormatSchema.optional()
10021
+ })
10022
+ });
10023
+ /** One class of one model's holdout report (the eval harness's summary). */
10024
+ var TrainingEvalClassSchema = object({
10025
+ positives: number().int(),
10026
+ floor: number().nullable(),
10027
+ tp: number().int(),
10028
+ fp: number().int(),
10029
+ fn: number().int(),
10030
+ precision: number().nullable(),
10031
+ recall: number().nullable(),
10032
+ ap50: number().nullable(),
10033
+ recallByCamera: record(string(), number().nullable()).optional(),
10034
+ recallByLight: record(string(), number().nullable()).optional(),
10035
+ fpByCamera: record(string(), number()).optional(),
10036
+ smallFound: number().int().optional(),
10037
+ smallTotal: number().int().optional()
10038
+ }).passthrough();
10039
+ var TrainingEvalReportSchema = object({
10040
+ frames: number().int(),
10041
+ classes: record(string(), TrainingEvalClassSchema)
10042
+ }).passthrough();
10043
+ /**
10044
+ * A succeeded result carries every block; a failed one carries the error and
10045
+ * whatever was known by then — the other blocks are ABSENT, not null. The
10046
+ * orchestrator checks the blocks it needs before it trusts a success.
10047
+ */
10048
+ var TrainingResultSchema = object({
10049
+ schema: literal(TRAINING_RESULT_SCHEMA),
10050
+ jobKey: string(),
10051
+ status: _enum(["succeeded", "failed"]),
10052
+ error: object({
10053
+ stage: string(),
10054
+ code: string(),
10055
+ message: string()
10056
+ }).nullable(),
10057
+ trainer: object({
10058
+ version: string(),
10059
+ revision: string()
10060
+ }),
10061
+ toolchain: record(string(), string().nullable()),
10062
+ dataset: object({
10063
+ versionId: string(),
10064
+ annotationHash: string(),
10065
+ sha256: string(),
10066
+ frames: object({
10067
+ train: number().int(),
10068
+ val: number().int(),
10069
+ holdout: number().int()
10070
+ }),
10071
+ holdoutCameras: array(number().int()),
10072
+ replayImages: number().int()
10073
+ }).optional(),
10074
+ training: object({
10075
+ epochsRun: number().int(),
10076
+ bestEpoch: number().int(),
10077
+ bestMap50: number(),
10078
+ bestMap50_95: number(),
10079
+ seconds: number()
10080
+ }).optional(),
10081
+ evaluation: object({
10082
+ holdoutFrames: number().int(),
10083
+ baseline: TrainingEvalReportSchema.nullable(),
10084
+ candidate: TrainingEvalReportSchema.nullable(),
10085
+ candidateInt8: TrainingEvalReportSchema.nullable(),
10086
+ recallDeltaByCamera: record(string(), record(string(), number())).nullable(),
10087
+ map50: record(string(), number().nullable())
10088
+ }).optional(),
10089
+ floors: object({
10090
+ baseline: FloorsSchema,
10091
+ candidate: FloorsSchema,
10092
+ candidateInt8: FloorsSchema.nullable(),
10093
+ notes: array(string())
10094
+ }).optional(),
10095
+ int8: object({
10096
+ kept: boolean(),
10097
+ map50Fp16: number().nullable(),
10098
+ map50Int8: number().nullable(),
10099
+ reason: string().nullable()
10100
+ }).optional(),
10101
+ exportsDropped: array(object({
10102
+ export: string(),
10103
+ reason: string()
10104
+ })).optional(),
10105
+ files: array(TrainingResultFileSchema).optional(),
10106
+ bundle: object({
10107
+ path: literal("bundle.tar"),
10108
+ bytes: number().int().nonnegative(),
10109
+ sha256: string().regex(/^[0-9a-f]{64}$/)
10110
+ }).nullable().optional(),
10111
+ catalogDraft: object({
10112
+ base: TrainingCatalogDraftSchema,
10113
+ int8: TrainingCatalogDraftSchema.nullable()
10114
+ }).nullable().optional(),
10115
+ licence: string()
10116
+ });
10117
+ var TrainingStageSchema = _enum([
10118
+ "prepare",
10119
+ "replay",
10120
+ "train",
10121
+ "eval",
10122
+ "export",
10123
+ "package"
10124
+ ]);
10125
+ var EventBase = {
10126
+ v: literal(1),
10127
+ ts: number()
10128
+ };
10129
+ discriminatedUnion("type", [
10130
+ object({
10131
+ ...EventBase,
10132
+ type: literal("stage"),
10133
+ stage: TrainingStageSchema
10134
+ }),
10135
+ object({
10136
+ ...EventBase,
10137
+ type: literal("epoch"),
10138
+ epoch: number().int(),
10139
+ epochs: number().int(),
10140
+ boxLoss: number().nullable().optional(),
10141
+ map50: number().nullable().optional(),
10142
+ map50_95: number().nullable().optional(),
10143
+ etaSec: number().nullable().optional()
10144
+ }),
10145
+ object({
10146
+ ...EventBase,
10147
+ type: literal("metric"),
10148
+ name: string(),
10149
+ value: number()
10150
+ }),
10151
+ object({
10152
+ ...EventBase,
10153
+ type: literal("artifact"),
10154
+ path: string(),
10155
+ bytes: number(),
10156
+ sha256: string()
10157
+ }),
10158
+ object({
10159
+ ...EventBase,
10160
+ type: literal("done"),
10161
+ status: _enum(["succeeded", "failed"]),
10162
+ resultSha256: string().nullable().optional()
10163
+ }),
10164
+ object({
10165
+ ...EventBase,
10166
+ type: literal("error"),
10167
+ stage: string(),
10168
+ code: string(),
10169
+ message: string()
10170
+ })
10171
+ ]);
10172
+ /**
9478
10173
  * What the gate decided about a birth, from the CALLER's point of view.
9479
10174
  *
9480
10175
  * Deliberately not `ConfirmationVerdict`: `undecided` is not a birth decision
@@ -11834,7 +12529,9 @@ var AddonHttpRouteSchema = object({
11834
12529
  "authenticated",
11835
12530
  "admin"
11836
12531
  ]).optional(),
11837
- description: string().optional()
12532
+ description: string().optional(),
12533
+ /** The hub limits this route per client address before the handler runs. */
12534
+ rateLimit: _enum(["auth"]).optional()
11838
12535
  });
11839
12536
  /**
11840
12537
  * Cross-process route invocation envelope. The hub captures the
@@ -12539,6 +13236,37 @@ var BackupDestinationInfoSchema = object({
12539
13236
  lastError: string().optional()
12540
13237
  });
12541
13238
  /**
13239
+ * How an archive is encrypted (operator decision 2026-10-09): to a backup
13240
+ * PUBLIC key the hub holds, so only the operator's secret key opens it.
13241
+ * Absent on a plain `.tar.gz` — every archive made before encryption, or
13242
+ * with it off — which restores without a key.
13243
+ */
13244
+ var BackupArchiveEncryptionSchema = object({
13245
+ /** `x25519-hkdf-aes256gcm-stream-v1`. */
13246
+ scheme: string(),
13247
+ /** 16 hex — the backup key whose secret restores this archive. */
13248
+ keyId: string()
13249
+ });
13250
+ /**
13251
+ * The backup encryption setting. The hub keeps PUBLIC keys only: the active
13252
+ * one new archives are encrypted to, and the retired ones older archives
13253
+ * still need. The secret key is shown once, at `setupEncryption`.
13254
+ */
13255
+ var BackupEncryptionStatusSchema = object({
13256
+ enabled: boolean(),
13257
+ active: object({
13258
+ keyId: string(),
13259
+ publicKey: string(),
13260
+ createdAt: number()
13261
+ }).nullable(),
13262
+ /** Every key ever set up, newest first. */
13263
+ keys: array(object({
13264
+ keyId: string(),
13265
+ createdAt: number(),
13266
+ retiredAt: number().nullable()
13267
+ })).readonly()
13268
+ });
13269
+ /**
12542
13270
  * Per-archive entry returned by `backup.listArchives({ destinationId })`.
12543
13271
  * Same shape the destination drill-in renders. Sourced from the per-
12544
13272
  * location `manifests.json` (no per-archive tarball read required).
@@ -12550,7 +13278,9 @@ var BackupArchiveEntrySchema = object({
12550
13278
  sizeBytes: number(),
12551
13279
  label: string().optional(),
12552
13280
  /** Top-level locations included in the archive (db, addons, tls, …). */
12553
- locations: array(string()).readonly()
13281
+ locations: array(string()).readonly(),
13282
+ /** Present when the archive is encrypted; restore then needs that key. */
13283
+ encryption: BackupArchiveEncryptionSchema.optional()
12554
13284
  });
12555
13285
  var BackupEntrySchema = object({
12556
13286
  id: string(),
@@ -12559,7 +13289,8 @@ var BackupEntrySchema = object({
12559
13289
  label: string().optional(),
12560
13290
  createdAt: number(),
12561
13291
  sizeBytes: number(),
12562
- locations: array(string()).optional()
13292
+ locations: array(string()).optional(),
13293
+ encryption: BackupArchiveEncryptionSchema.optional()
12563
13294
  });
12564
13295
  var ArchiveEntrySchema = object({
12565
13296
  path: string(),
@@ -12748,10 +13479,40 @@ method(_void(), array(BackupDestinationInfoSchema).readonly(), { auth: "admin" }
12748
13479
  * this list and skips entries whose path doesn't start with
12749
13480
  * any of them.
12750
13481
  */
12751
- locations: array(string()).optional()
13482
+ locations: array(string()).optional(),
13483
+ /**
13484
+ * The backup SECRET key, for an encrypted archive (ignored for a plain
13485
+ * one). The archive is decrypted into the hub's private staging
13486
+ * before the restart; the key is not stored. A wrong or missing key
13487
+ * is refused before the archive is downloaded.
13488
+ */
13489
+ backupSecretKey: string().optional()
12752
13490
  }), _void(), {
12753
13491
  kind: "mutation",
12754
13492
  auth: "admin"
13493
+ }), method(_void(), BackupEncryptionStatusSchema, { auth: "admin" }), method(object({}), object({
13494
+ keyId: string(),
13495
+ secretKey: string(),
13496
+ publicKey: string(),
13497
+ createdAt: number(),
13498
+ replacedKeyId: string().nullable()
13499
+ }), {
13500
+ kind: "mutation",
13501
+ auth: "admin"
13502
+ }), method(object({}), object({ disabledKeyId: string().nullable() }), {
13503
+ kind: "mutation",
13504
+ auth: "admin"
13505
+ }), method(object({ backupSecretKey: string() }), object({
13506
+ valid: boolean(),
13507
+ keyId: string().nullable(),
13508
+ /** The hub knows this key (active or retired). */
13509
+ known: boolean(),
13510
+ /** It is the key new archives are encrypted to. */
13511
+ active: boolean(),
13512
+ error: string().optional()
13513
+ }), {
13514
+ kind: "mutation",
13515
+ auth: "admin"
12755
13516
  }), method(object({
12756
13517
  destinationId: string(),
12757
13518
  backupId: string()
@@ -14477,7 +15238,60 @@ var CustomModelDescriptorSchema = object({
14477
15238
  stepId: string(),
14478
15239
  entry: ModelCatalogEntrySchema
14479
15240
  });
14480
- method(_void(), array(CustomModelDescriptorSchema).readonly(), { auth: "admin" });
15241
+ /** One regular file of an imported bundle, as the producer measured it. */
15242
+ var ModelBundleFileSchema = object({
15243
+ /** Relative path inside the bundle tar; an mlpackage member is `<x>.mlpackage/<member>`. */
15244
+ path: string().min(1),
15245
+ bytes: number().int().nonnegative(),
15246
+ sha256: string().regex(/^[0-9a-f]{64}$/)
15247
+ });
15248
+ var ImportModelBundleInputSchema = object({
15249
+ /** The registry provider that keeps the model (Model Studio). */
15250
+ addonId: string(),
15251
+ stepId: string().min(1),
15252
+ /**
15253
+ * The catalog rows to register, complete, every format URL already
15254
+ * `camstack-local://<modelId>/<file>` naming a file of the bundle. One
15255
+ * bundle may carry several rows (a base and its INT8 variant).
15256
+ */
15257
+ entries: array(ModelCatalogEntrySchema).min(1).max(4),
15258
+ /** The bundle tar, offered by the producer over `ctx.peerBytes` (same host). */
15259
+ bundle: object({
15260
+ ticket: PeerBytesTicketSchema,
15261
+ bytes: number().int().positive(),
15262
+ sha256: string().regex(/^[0-9a-f]{64}$/)
15263
+ }),
15264
+ /** Every file the tar must hold; anything missing, extra or different is refused. */
15265
+ files: array(ModelBundleFileSchema).min(1).max(64),
15266
+ /** Convert missing engine formats and push the model to every agent afterwards. */
15267
+ distribute: boolean()
15268
+ });
15269
+ var ImportModelBundleResultSchema = discriminatedUnion("kind", [object({
15270
+ kind: literal("imported"),
15271
+ modelIds: array(string()).readonly(),
15272
+ distributed: array(object({
15273
+ modelId: string(),
15274
+ nodeId: string(),
15275
+ format: _enum(MODEL_FORMATS),
15276
+ ok: boolean(),
15277
+ error: string().optional()
15278
+ })).readonly()
15279
+ }), object({
15280
+ kind: literal("refused"),
15281
+ reason: _enum([
15282
+ "transfer-failed",
15283
+ "checksum-mismatch",
15284
+ "bundle-mismatch",
15285
+ "invalid-entry",
15286
+ "id-taken"
15287
+ ]),
15288
+ detail: string()
15289
+ })]);
15290
+ method(_void(), array(CustomModelDescriptorSchema).readonly(), { auth: "admin" }), method(ImportModelBundleInputSchema, ImportModelBundleResultSchema, {
15291
+ kind: "mutation",
15292
+ auth: "admin",
15293
+ timeoutMs: 30 * 6e4
15294
+ });
14481
15295
  /**
14482
15296
  * Query filter for settings-store collections.
14483
15297
  */
@@ -14956,6 +15770,35 @@ var KeychainKeySourceSchema = object({
14956
15770
  */
14957
15771
  sharesBackupWithDatabase: boolean()
14958
15772
  });
15773
+ /**
15774
+ * One keychain reset, as the Secrets page reports it until the operator
15775
+ * acknowledges it. Never a value: refs, counts and table names only.
15776
+ */
15777
+ var KeychainResetRecordSchema = object({
15778
+ id: string(),
15779
+ at: number(),
15780
+ /** `user:<id>` or {@link KEYCHAIN_RESET_TRIGGER_ACTOR}. */
15781
+ actor: string(),
15782
+ /** Why the keychain was locked when it was reset; `null` when it was not locked. */
15783
+ lockedReason: string().nullable(),
15784
+ /** Values moved into the archive table (ciphertext under the lost key). */
15785
+ archived: number().int(),
15786
+ /** `keychain:secrets-orphaned-<ts>`, or `null` when nothing was stored. */
15787
+ archivedCollection: string().nullable(),
15788
+ /**
15789
+ * `keychain:keys-orphaned-<ts>`: the wrapped data keys of the archive, kept
15790
+ * so the archive can still be opened if the lost master key turns up.
15791
+ */
15792
+ archivedKeysCollection: string().nullable(),
15793
+ /**
15794
+ * `system-settings` keys whose marker the reset cleared — the cluster
15795
+ * secret's: a marker left pointing at an archived value would refuse every
15796
+ * agent forever (D797).
15797
+ */
15798
+ clearedSettingsKeys: array(string()).readonly(),
15799
+ /** When an operator dismissed the notice on the Secrets page; `null` until then. */
15800
+ acknowledgedAt: number().nullable()
15801
+ });
14959
15802
  var KeychainStatusSchema = object({
14960
15803
  keychain: KeychainStateSchema,
14961
15804
  /** The source of the master key in use; `null` while locked. */
@@ -14973,7 +15816,9 @@ var KeychainStatusSchema = object({
14973
15816
  /** Wrapped copies of the data key under a previous master key, kept until purged. */
14974
15817
  retiredWraps: number().int(),
14975
15818
  recoveryKeyDownloadedAt: number().nullable(),
14976
- secretCount: number().int()
15819
+ secretCount: number().int(),
15820
+ /** The most recent reset, acknowledged or not; `null` when the keychain was never reset. */
15821
+ lastReset: KeychainResetRecordSchema.nullable()
14977
15822
  });
14978
15823
  /**
14979
15824
  * Whether a stored value is still pointed at by its owner's settings.
@@ -14995,17 +15840,26 @@ var KeychainAuditActionSchema = _enum([
14995
15840
  "download-recovery-key",
14996
15841
  "delete-orphans",
14997
15842
  "reset",
15843
+ "acknowledge-reset",
14998
15844
  "initialize"
14999
15845
  ]);
15000
15846
  var KeychainAuditEntrySchema = object({
15001
15847
  id: string(),
15002
15848
  at: number(),
15003
15849
  action: KeychainAuditActionSchema,
15004
- /** `addon:<id>` | `user:<id>` | `system`. */
15850
+ /** `addon:<id>` | `user:<id>` | `system` | `trigger-file`. */
15005
15851
  actor: string(),
15006
15852
  ref: string().nullable(),
15007
15853
  detail: string().nullable()
15008
15854
  });
15855
+ var KEYCHAIN_RESET_CONFIRMATION = "RESET KEYCHAIN";
15856
+ /**
15857
+ * Secrets the HUB itself holds (owner `system`) that no settings form shows:
15858
+ * `jwt-signing-key` — the session signing key (D797). It is always "in use",
15859
+ * never an orphan; it is generated on a fresh hub and replaced only through
15860
+ * {@link keychainAdminCapability.methods.setSystemSecret}.
15861
+ */
15862
+ var SystemHeldSecretNameSchema = _enum(["jwt-signing-key"]);
15009
15863
  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({
15010
15864
  value: string(),
15011
15865
  version: number().int()
@@ -15013,6 +15867,16 @@ method(object({}), KeychainStatusSchema, { auth: "admin" }), method(object({}),
15013
15867
  kind: "mutation",
15014
15868
  auth: "admin",
15015
15869
  caller: "required"
15870
+ }), method(object({
15871
+ name: SystemHeldSecretNameSchema,
15872
+ value: string().min(16)
15873
+ }), object({
15874
+ ref: string(),
15875
+ version: number().int()
15876
+ }), {
15877
+ kind: "mutation",
15878
+ auth: "admin",
15879
+ caller: "required"
15016
15880
  }), method(object({ refs: array(string().min(1)).max(1e3) }), object({
15017
15881
  deleted: array(string()).readonly(),
15018
15882
  kept: array(object({
@@ -15042,13 +15906,20 @@ method(object({}), KeychainStatusSchema, { auth: "admin" }), method(object({}),
15042
15906
  kind: "mutation",
15043
15907
  auth: "admin",
15044
15908
  caller: "required"
15045
- }), method(object({ confirm: literal("RESET KEYCHAIN") }), object({
15909
+ }), method(object({ confirm: literal(KEYCHAIN_RESET_CONFIRMATION) }), object({
15046
15910
  archivedCollection: string().nullable(),
15047
15911
  archived: number().int()
15048
15912
  }), {
15049
15913
  kind: "mutation",
15050
15914
  auth: "admin",
15051
15915
  caller: "required"
15916
+ }), method(object({}), object({
15917
+ reset: KeychainResetRecordSchema.nullable(),
15918
+ pendingReentry: array(KeychainSecretMetaSchema).readonly()
15919
+ }), { auth: "admin" }), method(object({}), object({ acknowledged: boolean() }), {
15920
+ kind: "mutation",
15921
+ auth: "admin",
15922
+ caller: "required"
15052
15923
  });
15053
15924
  method(_void(), object({
15054
15925
  id: string(),
@@ -17882,7 +18753,7 @@ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
17882
18753
  * `login-method` — collection cap through which auth addons contribute
17883
18754
  * their pre-auth login surfaces to the login page. This is the SINGLE,
17884
18755
  * generic mechanism that supersedes the dead `auth.listProviders` reader:
17885
- * every auth addon (OIDC, magic-link, WebAuthn/passkey) registers a
18756
+ * every auth addon (OIDC, WebAuthn/passkey) registers a
17886
18757
  * `login-method` provider and the PUBLIC `auth.listLoginMethods`
17887
18758
  * procedure aggregates them for the unauthenticated login page.
17888
18759
  *
@@ -17890,8 +18761,7 @@ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
17890
18761
  *
17891
18762
  * - `redirect` — a declarative button. The login page renders a generic
17892
18763
  * button that navigates to `startUrl` (an addon-owned HTTP route).
17893
- * Covers OIDC (`/addon/auth-oidc/<id>/start`) and magic-link with
17894
- * ZERO shell-side JS. A future SSO addon plugs in the same way — the
18764
+ * Covers OIDC (`/addon/auth-oidc/<id>/start`) with ZERO shell-side JS. A future SSO addon plugs in the same way — the
17895
18765
  * login page needs NO change.
17896
18766
  *
17897
18767
  * - `widget` — a Module-Federation widget the login page mounts (via
@@ -17910,8 +18780,8 @@ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
17910
18780
  * decision.
17911
18781
  *
17912
18782
  * Every contribution carries a `stage`:
17913
- * - `primary` — shown on the first credentials screen (OIDC /
17914
- * magic-link buttons; a future usernameless passkey).
18783
+ * - `primary` — shown on the first credentials screen (OIDC
18784
+ * buttons; a usernameless passkey).
17915
18785
  * - `second-factor` — shown AFTER the password leg, gated on the
17916
18786
  * returned `factors` (passkey-as-2FA today).
17917
18787
  *
@@ -17938,7 +18808,7 @@ var LoginMethodContributionSchema = discriminatedUnion("kind", [
17938
18808
  * The provider names an external identity a signed-in user can link to
17939
18809
  * their own account (D782): `auth.listLinkableProviders` /
17940
18810
  * `beginExternalLink` offer exactly the redirect methods that set this,
17941
- * whatever their id. Absent / false — a login button only (magic-link).
18811
+ * whatever their id. Absent / false — a login button only.
17942
18812
  */
17943
18813
  linkable: boolean().optional()
17944
18814
  }),
@@ -21793,8 +22663,7 @@ method(object({}), object({ rules: array(NcRuleSchema) }), { auth: "admin" }), m
21793
22663
  * `super_admin` — collapsed onto the single boolean because every
21794
22664
  * non-admin caller is governed by the same scope-check rules; the
21795
22665
  * distinction was only ever used to route role-specific procedures
21796
- * which we no longer have. Agents are admin sessions issued via
21797
- * `createServiceToken`; CLI / webhook integrations are `cst_*` tokens
22666
+ * which we no longer have. CLI / webhook integrations are `cst_*` tokens
21798
22667
  * with `isAdmin: false` + an explicit scope list.
21799
22668
  */
21800
22669
  /** Per-method access flavour. Materialised on every cap method via codegen. */
@@ -23469,6 +24338,9 @@ var RetrainExportFilterSchema = object({
23469
24338
  frameIds: array(string()).max(2e4).optional(),
23470
24339
  /** Only frames in at least one of these named collections. */
23471
24340
  collectionIds: array(string()).max(200).optional(),
24341
+ /** Exactly the frames of this dataset version (and its completeOnly). An
24342
+ * unknown id selects nothing. */
24343
+ datasetVersionId: string().optional(),
23472
24344
  batchId: string().optional(),
23473
24345
  /** Only frames the operator marked complete (all subjects boxed). */
23474
24346
  completeOnly: boolean().optional()
@@ -23636,6 +24508,67 @@ var RetrainLlmAssistResultSchema = discriminatedUnion("kind", [object({
23636
24508
  ]),
23637
24509
  detail: string().optional()
23638
24510
  })]);
24511
+ /** What a dataset version is cut from. Every field narrows. */
24512
+ var RetrainDatasetSelectionSchema = object({
24513
+ deviceIds: array(number()).readonly().optional(),
24514
+ collectionIds: array(string()).max(200).readonly().optional(),
24515
+ frameIds: array(string()).max(2e4).readonly().optional()
24516
+ });
24517
+ /** The counts a dataset is judged by. */
24518
+ var RetrainDatasetStatsSchema = object({
24519
+ frames: number().int(),
24520
+ completeFrames: number().int(),
24521
+ /** `completeFrames / frames`, 0..1. */
24522
+ completeness: number(),
24523
+ /** Boxes to learn (model errors excluded). */
24524
+ subjects: number().int(),
24525
+ modelErrors: number().int(),
24526
+ /** Complete frames with no subject. */
24527
+ hardNegatives: number().int(),
24528
+ /** Subjects per class × camera × day/night. */
24529
+ cells: array(object({
24530
+ macroClass: string(),
24531
+ deviceId: number(),
24532
+ lighting: _enum([
24533
+ "day",
24534
+ "night",
24535
+ "unknown"
24536
+ ]),
24537
+ subjects: number().int(),
24538
+ frames: number().int()
24539
+ })).readonly(),
24540
+ cameras: array(object({
24541
+ deviceId: number(),
24542
+ frames: number().int(),
24543
+ completeFrames: number().int()
24544
+ })).readonly()
24545
+ });
24546
+ /** An immutable dataset version, without its frame list. */
24547
+ var RetrainDatasetVersionSchema = object({
24548
+ id: string(),
24549
+ name: string(),
24550
+ createdAt: number(),
24551
+ selection: RetrainDatasetSelectionSchema,
24552
+ layout: RetrainExportLayoutSchema,
24553
+ completeOnly: boolean(),
24554
+ frameCount: number().int(),
24555
+ /** sha256 of what the frames taught when the version was frozen. */
24556
+ annotationHash: string(),
24557
+ /** The export manifest schema the version was cut under. */
24558
+ manifestSchema: string(),
24559
+ stats: RetrainDatasetStatsSchema
24560
+ });
24561
+ var CreateRetrainDatasetVersionResultSchema = discriminatedUnion("kind", [object({
24562
+ kind: literal("created"),
24563
+ version: RetrainDatasetVersionSchema
24564
+ }), object({
24565
+ kind: literal("refused"),
24566
+ reason: _enum([
24567
+ "empty-name",
24568
+ "duplicate-name",
24569
+ "no-frames"
24570
+ ])
24571
+ })]);
23639
24572
  /** The outcome of a lifecycle move owned by the retrain page. */
23640
24573
  var RetrainTransitionResultSchema = object({
23641
24574
  trackId: string(),
@@ -24425,6 +25358,47 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
24425
25358
  kind: "mutation",
24426
25359
  auth: "admin",
24427
25360
  timeoutMs: 60 * 6e4
25361
+ }), method(object({
25362
+ filter: RetrainExportFilterSchema,
25363
+ layout: RetrainExportLayoutSchema
25364
+ }), object({
25365
+ ticket: PeerBytesTicketSchema,
25366
+ frames: number().int(),
25367
+ annotations: number().int()
25368
+ }), {
25369
+ kind: "mutation",
25370
+ auth: "admin",
25371
+ timeoutMs: 12e4
25372
+ }), method(object({
25373
+ selection: RetrainDatasetSelectionSchema,
25374
+ completeOnly: boolean().optional()
25375
+ }), RetrainDatasetStatsSchema, {
25376
+ kind: "query",
25377
+ auth: "admin"
25378
+ }), method(object({
25379
+ name: string().max(120),
25380
+ selection: RetrainDatasetSelectionSchema,
25381
+ layout: RetrainExportLayoutSchema,
25382
+ completeOnly: boolean()
25383
+ }), CreateRetrainDatasetVersionResultSchema, {
25384
+ kind: "mutation",
25385
+ auth: "admin",
25386
+ timeoutMs: 12e4
25387
+ }), method(object({}), array(RetrainDatasetVersionSchema).readonly(), {
25388
+ kind: "query",
25389
+ auth: "admin"
25390
+ }), method(object({ id: string() }), object({ deleted: boolean() }), {
25391
+ kind: "mutation",
25392
+ auth: "admin"
25393
+ }), method(object({ id: string() }), object({
25394
+ found: boolean(),
25395
+ annotationHash: string(),
25396
+ matches: boolean(),
25397
+ missingFrames: number().int()
25398
+ }), {
25399
+ kind: "query",
25400
+ auth: "admin",
25401
+ timeoutMs: 12e4
24428
25402
  }), method(object({}), array(RetrainAssistProfileSchema).readonly(), {
24429
25403
  kind: "query",
24430
25404
  auth: "admin"
@@ -28003,8 +28977,8 @@ version: string().optional() }), ServerUpdateActionResultSchema, {
28003
28977
  * `smtp-provider` — pluggable email delivery surface.
28004
28978
  *
28005
28979
  * Collection cap: a deployment may install multiple SMTP relays (e.g.
28006
- * one for transactional / one for notifications). Consumers (magic-link,
28007
- * notifier addons, …) walk the collection and pick the first
28980
+ * one for transactional / one for notifications). Consumers (notifier
28981
+ * addons, …) walk the collection and pick the first
28008
28982
  * ready provider OR target a specific addonId.
28009
28983
  *
28010
28984
  * The shape stays small on purpose — `sendEmail` is enough for the
@@ -28287,7 +29261,7 @@ targets: array(object({
28287
29261
  };
28288
29262
  /**
28289
29263
  * `sso-bridge` — internal hub-only cap that lets SSO-style auth
28290
- * providers (OIDC, SAML, magic-link, …) mint an HMAC-signed token
29264
+ * providers (OIDC, SAML, …) mint an HMAC-signed token
28291
29265
  * carrying the post-callback claims before redirecting back to
28292
29266
  * `/api/auth/sso/finish`.
28293
29267
  *
@@ -28350,7 +29324,14 @@ var SsoBridgeClaimsSchema = object({
28350
29324
  * Verified `iss` of the id_token behind an OIDC login bridge (D782). A
28351
29325
  * subject is unique only per issuer, so a link is bound to it.
28352
29326
  */
28353
- issuer: string().optional()
29327
+ issuer: string().optional(),
29328
+ /**
29329
+ * SHA-256 (hex) of the `camstack_sso_state` cookie the IdP `/start` set in
29330
+ * the browser that began this sign-in. `/api/auth/sso/finish` requires the
29331
+ * request to present the matching cookie — a login bridge is useless in
29332
+ * any other browser.
29333
+ */
29334
+ browserBinding: string().optional()
28354
29335
  });
28355
29336
  method(object({
28356
29337
  claims: SsoBridgeClaimsSchema,
@@ -40617,16 +41598,6 @@ var ApiKeySummarySchema = object({
40617
41598
  createdAt: number(),
40618
41599
  lastUsedAt: number().optional()
40619
41600
  });
40620
- var CreateApiKeyInputSchema = object({
40621
- label: string(),
40622
- isAdmin: boolean().default(false),
40623
- allowedProviders: union([array(string()), literal("*")]).optional(),
40624
- allowedDevices: record(string(), union([array(string()), literal("*")])).optional()
40625
- });
40626
- var CreateApiKeyResultSchema = object({
40627
- token: string(),
40628
- record: ApiKeySummarySchema
40629
- });
40630
41601
  var ScopedTokenSummarySchema = object({
40631
41602
  id: string(),
40632
41603
  userId: string(),
@@ -40725,17 +41696,10 @@ method(_void(), array(UserSummarySchema), { auth: "admin" }), method(CreateUserI
40725
41696
  }), UserSummarySchema.extend({ passwordHash: string() }).nullable(), {
40726
41697
  kind: "mutation",
40727
41698
  access: "view"
40728
- }), method(_void(), array(ApiKeySummarySchema), { auth: "admin" }), method(CreateApiKeyInputSchema, CreateApiKeyResultSchema, {
40729
- kind: "mutation",
40730
- auth: "admin",
40731
- access: "create"
40732
- }), method(object({ id: string() }), object({ success: literal(true) }), {
41699
+ }), method(_void(), array(ApiKeySummarySchema), { auth: "admin" }), method(object({ id: string() }), object({ success: literal(true) }), {
40733
41700
  kind: "mutation",
40734
41701
  auth: "admin",
40735
41702
  access: "delete"
40736
- }), method(object({ token: string() }), ApiKeySummarySchema.nullable(), {
40737
- kind: "mutation",
40738
- access: "view"
40739
41703
  }), method(CreateScopedTokenInputSchema, CreateScopedTokenResultSchema, {
40740
41704
  kind: "mutation",
40741
41705
  auth: "admin",
@@ -40809,15 +41773,7 @@ method(_void(), array(UserSummarySchema), { auth: "admin" }), method(CreateUserI
40809
41773
  }).nullable(), { access: "view" }), method(object({ userId: string() }), array(ExternalIdentitySchema), { auth: "admin" }), method(ExternalIdentityKeySchema, object({
40810
41774
  userId: string(),
40811
41775
  issuer: string()
40812
- }).nullable(), { auth: "admin" }), method(ExternalIdentityKeySchema.extend({
40813
- userId: string(),
40814
- issuer: string().min(1),
40815
- label: string().optional()
40816
- }), object({ success: literal(true) }), {
40817
- kind: "mutation",
40818
- auth: "admin",
40819
- access: "create"
40820
- }), method(ExternalIdentityKeySchema.extend({ userId: string() }), object({ success: boolean() }), {
41776
+ }).nullable(), { auth: "admin" }), method(ExternalIdentityKeySchema.extend({ userId: string() }), object({ success: boolean() }), {
40821
41777
  kind: "mutation",
40822
41778
  auth: "admin",
40823
41779
  access: "delete"
@@ -41522,6 +42478,451 @@ var zoneRulesCapability = {
41522
42478
  */
41523
42479
  durability: "restored"
41524
42480
  };
42481
+ /**
42482
+ * `training-provider` — ONE cloud that can run the CamStack trainer.
42483
+ *
42484
+ * A thin, mockable translation layer: it knows how to run a container with a
42485
+ * GPU, move a dataset in, read the job's stdout and hand artefacts back. It
42486
+ * knows nothing about datasets, splits, floors, cost policy or Model Studio —
42487
+ * those are the `training` orchestrator's (D805). Every rule written there
42488
+ * once is what makes a second provider (RunPod, a local NVIDIA node) a new
42489
+ * manifest entry and nothing else.
42490
+ *
42491
+ * Collection, routed by the `addonId` in every single-row input (the `llm` /
42492
+ * `notification-output` posture); `describe` concat-fans across providers.
42493
+ * Every method is `admin`: these spend money.
42494
+ *
42495
+ * Every cloud object a provider creates is tagged with the orchestrator's
42496
+ * `jobKey`, so a retried submit finds the job it already started instead of
42497
+ * starting a second GPU, and `listJobs` can find orphans.
42498
+ *
42499
+ * Bytes never ride a cap field: the dataset arrives as a `ctx.peerBytes`
42500
+ * ticket the producer (pipeline-analytics) minted, and artefacts leave as a
42501
+ * ticket the provider mints (D613).
42502
+ */
42503
+ var TrainingGpuOptionSchema = object({
42504
+ id: string(),
42505
+ label: string(),
42506
+ /** List price, USD per GPU-hour, before any region multiplier. */
42507
+ usdPerHour: number().nonnegative(),
42508
+ vramGb: number().nonnegative()
42509
+ });
42510
+ var TrainingRegionOptionSchema = object({
42511
+ /** `''` = any region (the provider's choice). */
42512
+ id: string(),
42513
+ label: string(),
42514
+ priceMultiplier: number().positive()
42515
+ });
42516
+ /**
42517
+ * The provider's per-account settings, as the orchestrator reads them. They
42518
+ * live in the PROVIDER addon's settings (operator decision 2026-10-08: they
42519
+ * depend on the user's account), never hard-coded in the orchestrator.
42520
+ */
42521
+ var TrainingProviderDefaultsSchema = object({
42522
+ gpuType: string(),
42523
+ region: string(),
42524
+ costCapUsd: number().nonnegative(),
42525
+ maxRuntimeSec: number().int().positive(),
42526
+ /** Hours a FAILED job's cloud dataset is kept for debugging; 0 = delete at once. */
42527
+ failedDatasetGraceHours: number().nonnegative()
42528
+ });
42529
+ var TrainingProviderDescriptorSchema = object({
42530
+ addonId: string(),
42531
+ /** `modal`, `runpod`, `fake`, … */
42532
+ kind: string(),
42533
+ label: string(),
42534
+ gpuTypes: array(TrainingGpuOptionSchema).readonly(),
42535
+ regions: array(TrainingRegionOptionSchema).readonly(),
42536
+ maxDatasetBytes: number().int().positive(),
42537
+ maxRuntimeSec: number().int().positive(),
42538
+ freeTierNote: string().optional(),
42539
+ /** Where the data goes, in one sentence the confirm dialog repeats. */
42540
+ dataResidencyNote: string(),
42541
+ /** Credentials are present — never the values. */
42542
+ configured: boolean(),
42543
+ defaults: TrainingProviderDefaultsSchema
42544
+ });
42545
+ var TrainingCredentialCheckSchema = object({
42546
+ ok: boolean(),
42547
+ /** Workspace / account name, when the provider says. */
42548
+ account: string().optional(),
42549
+ reason: _enum([
42550
+ "missing",
42551
+ "invalid",
42552
+ "forbidden",
42553
+ "network",
42554
+ "quota"
42555
+ ]).optional(),
42556
+ detail: string().optional()
42557
+ });
42558
+ var ProviderJobStateSchema = _enum([
42559
+ "pending",
42560
+ "starting",
42561
+ "running",
42562
+ "succeeded",
42563
+ "failed",
42564
+ "cancelled",
42565
+ "lost"
42566
+ ]);
42567
+ var ProviderJobStatusSchema = object({
42568
+ jobKey: string(),
42569
+ providerJobId: string().optional(),
42570
+ state: ProviderJobStateSchema,
42571
+ startedAt: number().optional(),
42572
+ endedAt: number().optional(),
42573
+ exitCode: number().int().optional(),
42574
+ failureReason: string().optional(),
42575
+ gpuType: string(),
42576
+ region: string().optional(),
42577
+ billedSeconds: number().nonnegative(),
42578
+ costUsd: number().nonnegative(),
42579
+ /** True when `costUsd` is runtime × list price, not a billing answer. */
42580
+ costIsEstimate: boolean(),
42581
+ lastFetchedAt: number()
42582
+ });
42583
+ /**
42584
+ * The trainer the job runs, by SOURCE revision: the provider turns it into an
42585
+ * image its own way (Modal builds the published Dockerfile at that revision;
42586
+ * a registry-pull provider maps it to a tag). Recorded on the job and echoed
42587
+ * in `result.json`.
42588
+ */
42589
+ var TrainerSourceRefSchema = object({
42590
+ /** Hugging Face repo id, e.g. `camstack/camstack-trainer`. */
42591
+ repo: string().min(1),
42592
+ /** A commit sha (never a branch) — the job must be reproducible. */
42593
+ revision: string().regex(/^[0-9a-f]{7,64}$/)
42594
+ });
42595
+ var JobRef = {
42596
+ addonId: string(),
42597
+ jobKey: string().uuid()
42598
+ };
42599
+ var TrainingLogLineSchema = object({
42600
+ ts: number(),
42601
+ text: string()
42602
+ });
42603
+ method(object({}), array(TrainingProviderDescriptorSchema).readonly(), { auth: "admin" }), method(object({ addonId: string() }), TrainingCredentialCheckSchema, {
42604
+ kind: "mutation",
42605
+ auth: "admin",
42606
+ timeoutMs: 3e4
42607
+ }), method(object({
42608
+ addonId: string(),
42609
+ gpuType: string(),
42610
+ region: string(),
42611
+ datasetBytes: number().int().nonnegative(),
42612
+ gpuSecondsLow: number().nonnegative(),
42613
+ gpuSecondsHigh: number().nonnegative()
42614
+ }), object({
42615
+ usdLow: number().nonnegative(),
42616
+ usdHigh: number().nonnegative(),
42617
+ notes: array(string()).readonly()
42618
+ }), { auth: "admin" }), method(object({
42619
+ ...JobRef,
42620
+ ticket: PeerBytesTicketSchema
42621
+ }), object({
42622
+ bytes: number().int().nonnegative(),
42623
+ sha256: string()
42624
+ }), {
42625
+ kind: "mutation",
42626
+ auth: "admin",
42627
+ timeoutMs: 120 * 6e4
42628
+ }), method(object({
42629
+ ...JobRef,
42630
+ trainer: TrainerSourceRefSchema,
42631
+ jobSpecJson: string().min(2).max(64e3),
42632
+ gpuType: string(),
42633
+ region: string(),
42634
+ maxRuntimeSec: number().int().positive()
42635
+ }), ProviderJobStatusSchema, {
42636
+ kind: "mutation",
42637
+ auth: "admin",
42638
+ timeoutMs: 30 * 6e4
42639
+ }), method(object(JobRef), ProviderJobStatusSchema, {
42640
+ auth: "admin",
42641
+ timeoutMs: 6e4
42642
+ }), method(object({
42643
+ ...JobRef,
42644
+ cursor: string().optional(),
42645
+ max: number().int().min(1).max(500)
42646
+ }), object({
42647
+ lines: array(TrainingLogLineSchema).readonly(),
42648
+ cursor: string()
42649
+ }), {
42650
+ auth: "admin",
42651
+ timeoutMs: 6e4
42652
+ }), method(object(JobRef), object({ ok: literal(true) }), {
42653
+ kind: "mutation",
42654
+ auth: "admin",
42655
+ timeoutMs: 6e4
42656
+ }), method(object(JobRef), object({
42657
+ found: boolean(),
42658
+ text: string().optional()
42659
+ }), {
42660
+ kind: "mutation",
42661
+ auth: "admin",
42662
+ timeoutMs: 5 * 6e4
42663
+ }), method(object({
42664
+ ...JobRef,
42665
+ path: _enum(["bundle.tar"])
42666
+ }), object({ ticket: PeerBytesTicketSchema }), {
42667
+ kind: "mutation",
42668
+ auth: "admin",
42669
+ timeoutMs: 5 * 6e4
42670
+ }), method(object(JobRef), object({ deleted: array(string()).readonly() }), {
42671
+ kind: "mutation",
42672
+ auth: "admin",
42673
+ timeoutMs: 5 * 6e4
42674
+ }), method(object({ addonId: string() }), array(ProviderJobStatusSchema).readonly(), {
42675
+ auth: "admin",
42676
+ timeoutMs: 2 * 6e4
42677
+ });
42678
+ /**
42679
+ * `training` — the cloud-training orchestrator (D805). Hub-only singleton,
42680
+ * provided by `addon-training`.
42681
+ *
42682
+ * It owns what every provider must agree on, written once:
42683
+ *
42684
+ * - **Dataset versions.** Taken over from pipeline-analytics (D796): the rows
42685
+ * live here (D808); pipeline-analytics still CUTS a version (it owns the corpus and
42686
+ * the export plan) and reaches this store through the five row methods
42687
+ * below, so the Retrain page and the export did not change.
42688
+ * - **Jobs.** A persisted state machine, a reconcile loop against the
42689
+ * provider, a cost guard, a daily orphan sweep and the retention rules.
42690
+ * - **The return flow.** Verified artefacts → Model Studio
42691
+ * (`custom-model-registry.importModelBundle`) → canary on cameras →
42692
+ * rollback. Nothing is ever registered automatically.
42693
+ *
42694
+ * Every method is `admin`.
42695
+ */
42696
+ /** A version WITH its frame list — what the export and a job read. */
42697
+ var TrainingDatasetVersionRowSchema = RetrainDatasetVersionSchema.omit({ frameCount: true }).extend({ frameIds: array(string()).max(2e4).readonly() });
42698
+ /** A base model a detector job can fine-tune, and the baseline it is judged against. */
42699
+ var TrainingBaseModelSchema = object({
42700
+ modelId: string(),
42701
+ label: string(),
42702
+ weights: string(),
42703
+ imgsz: number().int(),
42704
+ baselineOnnxUrl: string(),
42705
+ baselineFloors: record(string(), number()),
42706
+ /** The base the fleet runs most — the UI's default. */
42707
+ recommended: boolean()
42708
+ });
42709
+ var TrainingPresetSchema = _enum([
42710
+ "quick",
42711
+ "standard",
42712
+ "thorough"
42713
+ ]);
42714
+ var TrainingJobRequestSchema = object({
42715
+ datasetVersionId: string().min(1),
42716
+ /** The `training-provider` addon that runs it. */
42717
+ addonId: string().min(1),
42718
+ gpuType: string().min(1),
42719
+ region: string(),
42720
+ baseModelId: string().min(1),
42721
+ preset: TrainingPresetSchema,
42722
+ /** Freeze the backbone's first N layers; `null` = the preset's choice. */
42723
+ freeze: number().int().nonnegative().nullable(),
42724
+ /** Cameras held out whole for evaluation; `null` = the orchestrator's default. */
42725
+ holdoutCameras: array(number().int()).nullable()
42726
+ });
42727
+ var TrainingSplitPlanSchema = object({
42728
+ holdoutCameras: array(number().int()).readonly(),
42729
+ /** Used when no camera is held out: the last N days of every camera. */
42730
+ holdoutLastDays: number().int().nonnegative(),
42731
+ /** Holdout subjects per class (camera holdout only; `null` = known only after the split). */
42732
+ holdoutSupport: record(string(), number().int()).nullable(),
42733
+ trainSubjects: number().int()
42734
+ });
42735
+ var TrainingRefusalReasonSchema = _enum([
42736
+ "unknown-dataset",
42737
+ "unknown-provider",
42738
+ "provider-not-configured",
42739
+ "unknown-base-model",
42740
+ "unknown-gpu",
42741
+ "dataset-too-large",
42742
+ "no-training-subjects",
42743
+ "job-already-running"
42744
+ ]);
42745
+ var TrainingJobPlanSchema = object({
42746
+ refusal: object({
42747
+ reason: TrainingRefusalReasonSchema,
42748
+ detail: string()
42749
+ }).nullable(),
42750
+ warnings: array(string()).readonly(),
42751
+ split: TrainingSplitPlanSchema.nullable(),
42752
+ estimate: object({
42753
+ datasetBytes: number().int(),
42754
+ uploadMinutesAt20Mbps: number(),
42755
+ gpuSecondsLow: number(),
42756
+ gpuSecondsHigh: number(),
42757
+ usdLow: number(),
42758
+ usdHigh: number(),
42759
+ notes: array(string()).readonly()
42760
+ }).nullable(),
42761
+ /** Pre-filled from the provider's settings; the operator may lower or raise them. */
42762
+ defaults: object({
42763
+ maxCostUsd: number(),
42764
+ maxRuntimeSec: number().int()
42765
+ }).nullable(),
42766
+ /** The sentence the confirm dialog repeats: where the frames go and when they are deleted. */
42767
+ dataNotice: string()
42768
+ });
42769
+ /**
42770
+ * Orchestrator-owned states, persisted. `uploading` covers exporting the
42771
+ * archive (it is streamed, never staged). Terminal: `failed`, `cancelled`,
42772
+ * `lost`, `expired`, `discarded`. `registered` and `canary` are where a
42773
+ * result lives after the operator acted on it.
42774
+ */
42775
+ var TrainingJobStateSchema = _enum([
42776
+ "uploading",
42777
+ "submitted",
42778
+ "starting",
42779
+ "running",
42780
+ "collecting",
42781
+ "ready",
42782
+ "registered",
42783
+ "canary",
42784
+ "failed",
42785
+ "cancelling",
42786
+ "cancelled",
42787
+ "lost",
42788
+ "expired",
42789
+ "discarded"
42790
+ ]);
42791
+ var TrainingFailureReasonSchema = _enum([
42792
+ "cost-cap",
42793
+ "runtime-cap",
42794
+ "upload-failed",
42795
+ "submit-failed",
42796
+ "trainer-failed",
42797
+ "result-invalid",
42798
+ "checksum-mismatch",
42799
+ "fetch-failed",
42800
+ "provider-error",
42801
+ "hub-restart-during-upload"
42802
+ ]);
42803
+ var TrainingProgressPointSchema = object({
42804
+ epoch: number().int(),
42805
+ map50: number().nullable(),
42806
+ map50_95: number().nullable()
42807
+ });
42808
+ var TrainingCanarySchema = object({
42809
+ deviceIds: array(number().int()).readonly(),
42810
+ since: number(),
42811
+ /** Every override the canary replaced, exactly, so rollback restores it. */
42812
+ previous: array(object({
42813
+ deviceId: number().int(),
42814
+ nodeId: string(),
42815
+ deviceKey: string(),
42816
+ patch: object({
42817
+ modelId: string().optional(),
42818
+ settings: record(string(), unknown()).readonly().optional()
42819
+ }).nullable()
42820
+ })).readonly()
42821
+ });
42822
+ var TrainingJobSchema = object({
42823
+ id: string(),
42824
+ idempotencyKey: string(),
42825
+ name: string(),
42826
+ createdAt: number(),
42827
+ updatedAt: number(),
42828
+ state: TrainingJobStateSchema,
42829
+ stage: TrainingStageSchema.nullable(),
42830
+ failure: object({
42831
+ reason: TrainingFailureReasonSchema,
42832
+ stage: string().nullable(),
42833
+ detail: string()
42834
+ }).nullable(),
42835
+ request: TrainingJobRequestSchema,
42836
+ maxCostUsd: number().nonnegative(),
42837
+ maxRuntimeSec: number().int().positive(),
42838
+ trainer: TrainerSourceRefSchema,
42839
+ datasetLayout: RetrainExportLayoutSchema,
42840
+ dataset: object({
42841
+ bytes: number().int(),
42842
+ sha256: string(),
42843
+ uploadedAt: number()
42844
+ }).nullable(),
42845
+ split: TrainingSplitPlanSchema,
42846
+ provider: object({
42847
+ state: ProviderJobStateSchema.nullable(),
42848
+ providerJobId: string().nullable(),
42849
+ startedAt: number().nullable(),
42850
+ endedAt: number().nullable(),
42851
+ billedSeconds: number(),
42852
+ costUsd: number(),
42853
+ costIsEstimate: boolean(),
42854
+ lastPolledAt: number().nullable()
42855
+ }),
42856
+ progress: object({
42857
+ epoch: number().int().nullable(),
42858
+ epochs: number().int().nullable(),
42859
+ etaSec: number().nullable(),
42860
+ series: array(TrainingProgressPointSchema).readonly()
42861
+ }),
42862
+ /** The last lines of the job's output (≤ 200), newest last. Never frame paths. */
42863
+ logTail: array(string()).readonly(),
42864
+ logCursor: string().nullable(),
42865
+ artifacts: object({
42866
+ bundleBytes: number().int(),
42867
+ bundleSha256: string(),
42868
+ fetchedAt: number(),
42869
+ /** When the staged artefacts are deleted from the hub. */
42870
+ expiresAt: number()
42871
+ }).nullable(),
42872
+ /** When the provider-side copy of the frames was deleted; null while it exists. */
42873
+ cloudDatasetDeletedAt: number().nullable(),
42874
+ /** A failed job's dataset is kept until then (the provider's grace), then deleted. */
42875
+ cloudCleanupDueAt: number().nullable(),
42876
+ /** Model ids registered from this job (base, and int8 when kept). */
42877
+ registeredModelIds: array(string()).readonly(),
42878
+ canary: TrainingCanarySchema.nullable()
42879
+ });
42880
+ var IdInput = object({ id: string().min(1) });
42881
+ method(TrainingDatasetVersionRowSchema, object({ stored: boolean() }), {
42882
+ kind: "mutation",
42883
+ auth: "admin"
42884
+ }), 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() }), {
42885
+ kind: "mutation",
42886
+ auth: "admin"
42887
+ }), method(object({}), array(TrainingBaseModelSchema).readonly(), { auth: "admin" }), method(TrainingJobRequestSchema, TrainingJobPlanSchema, {
42888
+ auth: "admin",
42889
+ timeoutMs: 6e4
42890
+ }), method(TrainingJobRequestSchema.extend({
42891
+ name: string().min(1).max(120),
42892
+ maxCostUsd: number().positive(),
42893
+ maxRuntimeSec: number().int().positive(),
42894
+ idempotencyKey: string().min(8).max(80)
42895
+ }), discriminatedUnion("kind", [object({
42896
+ kind: literal("started"),
42897
+ job: TrainingJobSchema
42898
+ }), object({
42899
+ kind: literal("refused"),
42900
+ reason: TrainingRefusalReasonSchema,
42901
+ detail: string()
42902
+ })]), {
42903
+ kind: "mutation",
42904
+ auth: "admin",
42905
+ timeoutMs: 12e4
42906
+ }), method(object({}), array(TrainingJobSchema).readonly(), { auth: "admin" }), method(IdInput, TrainingJobSchema.nullable(), { auth: "admin" }), method(IdInput, TrainingJobSchema, {
42907
+ kind: "mutation",
42908
+ auth: "admin",
42909
+ timeoutMs: 12e4
42910
+ }), method(IdInput, TrainingResultSchema.nullable(), { auth: "admin" }), method(IdInput.extend({ canaryDeviceIds: array(number().int()).readonly() }), TrainingJobSchema, {
42911
+ kind: "mutation",
42912
+ auth: "admin",
42913
+ timeoutMs: 30 * 6e4
42914
+ }), method(IdInput.extend({ deviceIds: array(number().int()).min(1).readonly() }), TrainingJobSchema, {
42915
+ kind: "mutation",
42916
+ auth: "admin",
42917
+ timeoutMs: 12e4
42918
+ }), method(IdInput, TrainingJobSchema, {
42919
+ kind: "mutation",
42920
+ auth: "admin",
42921
+ timeoutMs: 12e4
42922
+ }), method(IdInput, TrainingJobSchema, {
42923
+ kind: "mutation",
42924
+ auth: "admin"
42925
+ });
41525
42926
  SOURCE_CAPS.filter((cap) => cap !== "switch" && cap !== "motion");
41526
42927
  Object.freeze({
41527
42928
  person: .5,
@@ -43670,6 +45071,12 @@ Object.freeze({
43670
45071
  addonId: null,
43671
45072
  access: "create"
43672
45073
  },
45074
+ "backup.checkBackupKey": {
45075
+ capName: "backup",
45076
+ capScope: "system",
45077
+ addonId: null,
45078
+ access: "create"
45079
+ },
43673
45080
  "backup.delete": {
43674
45081
  capName: "backup",
43675
45082
  capScope: "system",
@@ -43682,6 +45089,18 @@ Object.freeze({
43682
45089
  addonId: null,
43683
45090
  access: "delete"
43684
45091
  },
45092
+ "backup.disableEncryption": {
45093
+ capName: "backup",
45094
+ capScope: "system",
45095
+ addonId: null,
45096
+ access: "create"
45097
+ },
45098
+ "backup.getEncryption": {
45099
+ capName: "backup",
45100
+ capScope: "system",
45101
+ addonId: null,
45102
+ access: "view"
45103
+ },
43685
45104
  "backup.getEntries": {
43686
45105
  capName: "backup",
43687
45106
  capScope: "system",
@@ -43736,6 +45155,12 @@ Object.freeze({
43736
45155
  addonId: null,
43737
45156
  access: "create"
43738
45157
  },
45158
+ "backup.setupEncryption": {
45159
+ capName: "backup",
45160
+ capScope: "system",
45161
+ addonId: null,
45162
+ access: "create"
45163
+ },
43739
45164
  "backup.trigger": {
43740
45165
  capName: "backup",
43741
45166
  capScope: "system",
@@ -44288,6 +45713,12 @@ Object.freeze({
44288
45713
  addonId: null,
44289
45714
  access: "create"
44290
45715
  },
45716
+ "customModelRegistry.importModelBundle": {
45717
+ capName: "custom-model-registry",
45718
+ capScope: "system",
45719
+ addonId: null,
45720
+ access: "create"
45721
+ },
44291
45722
  "customModelRegistry.listModels": {
44292
45723
  capName: "custom-model-registry",
44293
45724
  capScope: "system",
@@ -45728,6 +47159,12 @@ Object.freeze({
45728
47159
  addonId: null,
45729
47160
  access: "view"
45730
47161
  },
47162
+ "keychainAdmin.acknowledgeReset": {
47163
+ capName: "keychain-admin",
47164
+ capScope: "system",
47165
+ addonId: null,
47166
+ access: "create"
47167
+ },
45731
47168
  "keychainAdmin.deleteOrphans": {
45732
47169
  capName: "keychain-admin",
45733
47170
  capScope: "system",
@@ -45764,6 +47201,12 @@ Object.freeze({
45764
47201
  addonId: null,
45765
47202
  access: "delete"
45766
47203
  },
47204
+ "keychainAdmin.resetReport": {
47205
+ capName: "keychain-admin",
47206
+ capScope: "system",
47207
+ addonId: null,
47208
+ access: "delete"
47209
+ },
45767
47210
  "keychainAdmin.reveal": {
45768
47211
  capName: "keychain-admin",
45769
47212
  capScope: "system",
@@ -45776,6 +47219,12 @@ Object.freeze({
45776
47219
  addonId: null,
45777
47220
  access: "create"
45778
47221
  },
47222
+ "keychainAdmin.setSystemSecret": {
47223
+ capName: "keychain-admin",
47224
+ capScope: "system",
47225
+ addonId: null,
47226
+ access: "create"
47227
+ },
45779
47228
  "keychainAdmin.status": {
45780
47229
  capName: "keychain-admin",
45781
47230
  capScope: "system",
@@ -47222,6 +48671,12 @@ Object.freeze({
47222
48671
  addonId: null,
47223
48672
  access: "create"
47224
48673
  },
48674
+ "pipelineAnalytics.createRetrainDatasetVersion": {
48675
+ capName: "pipeline-analytics",
48676
+ capScope: "device",
48677
+ addonId: null,
48678
+ access: "create"
48679
+ },
47225
48680
  "pipelineAnalytics.deleteDeviceEvents": {
47226
48681
  capName: "pipeline-analytics",
47227
48682
  capScope: "device",
@@ -47234,6 +48689,12 @@ Object.freeze({
47234
48689
  addonId: null,
47235
48690
  access: "delete"
47236
48691
  },
48692
+ "pipelineAnalytics.deleteRetrainDatasetVersion": {
48693
+ capName: "pipeline-analytics",
48694
+ capScope: "device",
48695
+ addonId: null,
48696
+ access: "delete"
48697
+ },
47237
48698
  "pipelineAnalytics.deleteTracks": {
47238
48699
  capName: "pipeline-analytics",
47239
48700
  capScope: "device",
@@ -47456,6 +48917,12 @@ Object.freeze({
47456
48917
  addonId: null,
47457
48918
  access: "view"
47458
48919
  },
48920
+ "pipelineAnalytics.listRetrainDatasetVersions": {
48921
+ capName: "pipeline-analytics",
48922
+ capScope: "device",
48923
+ addonId: null,
48924
+ access: "view"
48925
+ },
47459
48926
  "pipelineAnalytics.listRetrainFrames": {
47460
48927
  capName: "pipeline-analytics",
47461
48928
  capScope: "device",
@@ -47486,6 +48953,12 @@ Object.freeze({
47486
48953
  addonId: null,
47487
48954
  access: "view"
47488
48955
  },
48956
+ "pipelineAnalytics.offerRetrainArchive": {
48957
+ capName: "pipeline-analytics",
48958
+ capScope: "device",
48959
+ addonId: null,
48960
+ access: "create"
48961
+ },
47489
48962
  "pipelineAnalytics.ownersWithMedia": {
47490
48963
  capName: "pipeline-analytics",
47491
48964
  capScope: "device",
@@ -47498,6 +48971,12 @@ Object.freeze({
47498
48971
  addonId: null,
47499
48972
  access: "create"
47500
48973
  },
48974
+ "pipelineAnalytics.previewRetrainDataset": {
48975
+ capName: "pipeline-analytics",
48976
+ capScope: "device",
48977
+ addonId: null,
48978
+ access: "view"
48979
+ },
47501
48980
  "pipelineAnalytics.proposeRetrainAnnotations": {
47502
48981
  capName: "pipeline-analytics",
47503
48982
  capScope: "device",
@@ -47636,6 +49115,12 @@ Object.freeze({
47636
49115
  addonId: null,
47637
49116
  access: "create"
47638
49117
  },
49118
+ "pipelineAnalytics.verifyRetrainDatasetVersion": {
49119
+ capName: "pipeline-analytics",
49120
+ capScope: "device",
49121
+ addonId: null,
49122
+ access: "view"
49123
+ },
47639
49124
  "pipelineAnalytics.wipeAllAnalytics": {
47640
49125
  capName: "pipeline-analytics",
47641
49126
  capScope: "device",
@@ -50012,6 +51497,174 @@ Object.freeze({
50012
51497
  addonId: null,
50013
51498
  access: "view"
50014
51499
  },
51500
+ "training.canaryResult": {
51501
+ capName: "training",
51502
+ capScope: "system",
51503
+ addonId: null,
51504
+ access: "create"
51505
+ },
51506
+ "training.cancelJob": {
51507
+ capName: "training",
51508
+ capScope: "system",
51509
+ addonId: null,
51510
+ access: "create"
51511
+ },
51512
+ "training.discardResult": {
51513
+ capName: "training",
51514
+ capScope: "system",
51515
+ addonId: null,
51516
+ access: "create"
51517
+ },
51518
+ "training.findDatasetVersionIdByName": {
51519
+ capName: "training",
51520
+ capScope: "system",
51521
+ addonId: null,
51522
+ access: "view"
51523
+ },
51524
+ "training.getDatasetVersion": {
51525
+ capName: "training",
51526
+ capScope: "system",
51527
+ addonId: null,
51528
+ access: "view"
51529
+ },
51530
+ "training.getJob": {
51531
+ capName: "training",
51532
+ capScope: "system",
51533
+ addonId: null,
51534
+ access: "view"
51535
+ },
51536
+ "training.getJobResult": {
51537
+ capName: "training",
51538
+ capScope: "system",
51539
+ addonId: null,
51540
+ access: "view"
51541
+ },
51542
+ "training.listBaseModels": {
51543
+ capName: "training",
51544
+ capScope: "system",
51545
+ addonId: null,
51546
+ access: "view"
51547
+ },
51548
+ "training.listDatasetVersions": {
51549
+ capName: "training",
51550
+ capScope: "system",
51551
+ addonId: null,
51552
+ access: "view"
51553
+ },
51554
+ "training.listJobs": {
51555
+ capName: "training",
51556
+ capScope: "system",
51557
+ addonId: null,
51558
+ access: "view"
51559
+ },
51560
+ "training.planJob": {
51561
+ capName: "training",
51562
+ capScope: "system",
51563
+ addonId: null,
51564
+ access: "view"
51565
+ },
51566
+ "training.putDatasetVersion": {
51567
+ capName: "training",
51568
+ capScope: "system",
51569
+ addonId: null,
51570
+ access: "create"
51571
+ },
51572
+ "training.registerResult": {
51573
+ capName: "training",
51574
+ capScope: "system",
51575
+ addonId: null,
51576
+ access: "create"
51577
+ },
51578
+ "training.removeDatasetVersion": {
51579
+ capName: "training",
51580
+ capScope: "system",
51581
+ addonId: null,
51582
+ access: "delete"
51583
+ },
51584
+ "training.rollbackCanary": {
51585
+ capName: "training",
51586
+ capScope: "system",
51587
+ addonId: null,
51588
+ access: "create"
51589
+ },
51590
+ "training.startJob": {
51591
+ capName: "training",
51592
+ capScope: "system",
51593
+ addonId: null,
51594
+ access: "create"
51595
+ },
51596
+ "trainingProvider.cancelJob": {
51597
+ capName: "training-provider",
51598
+ capScope: "system",
51599
+ addonId: null,
51600
+ access: "create"
51601
+ },
51602
+ "trainingProvider.cleanupJob": {
51603
+ capName: "training-provider",
51604
+ capScope: "system",
51605
+ addonId: null,
51606
+ access: "create"
51607
+ },
51608
+ "trainingProvider.describe": {
51609
+ capName: "training-provider",
51610
+ capScope: "system",
51611
+ addonId: null,
51612
+ access: "view"
51613
+ },
51614
+ "trainingProvider.estimateJob": {
51615
+ capName: "training-provider",
51616
+ capScope: "system",
51617
+ addonId: null,
51618
+ access: "view"
51619
+ },
51620
+ "trainingProvider.getJob": {
51621
+ capName: "training-provider",
51622
+ capScope: "system",
51623
+ addonId: null,
51624
+ access: "view"
51625
+ },
51626
+ "trainingProvider.listJobEvents": {
51627
+ capName: "training-provider",
51628
+ capScope: "system",
51629
+ addonId: null,
51630
+ access: "view"
51631
+ },
51632
+ "trainingProvider.listJobs": {
51633
+ capName: "training-provider",
51634
+ capScope: "system",
51635
+ addonId: null,
51636
+ access: "view"
51637
+ },
51638
+ "trainingProvider.offerArtifact": {
51639
+ capName: "training-provider",
51640
+ capScope: "system",
51641
+ addonId: null,
51642
+ access: "create"
51643
+ },
51644
+ "trainingProvider.readResult": {
51645
+ capName: "training-provider",
51646
+ capScope: "system",
51647
+ addonId: null,
51648
+ access: "create"
51649
+ },
51650
+ "trainingProvider.submitJob": {
51651
+ capName: "training-provider",
51652
+ capScope: "system",
51653
+ addonId: null,
51654
+ access: "create"
51655
+ },
51656
+ "trainingProvider.uploadDataset": {
51657
+ capName: "training-provider",
51658
+ capScope: "system",
51659
+ addonId: null,
51660
+ access: "create"
51661
+ },
51662
+ "trainingProvider.validateCredentials": {
51663
+ capName: "training-provider",
51664
+ capScope: "system",
51665
+ addonId: null,
51666
+ access: "create"
51667
+ },
50015
51668
  "turnProvider.getTurnServers": {
50016
51669
  capName: "turn-provider",
50017
51670
  capScope: "system",
@@ -50036,12 +51689,6 @@ Object.freeze({
50036
51689
  addonId: null,
50037
51690
  access: "create"
50038
51691
  },
50039
- "userManagement.createApiKey": {
50040
- capName: "user-management",
50041
- capScope: "system",
50042
- addonId: null,
50043
- access: "create"
50044
- },
50045
51692
  "userManagement.createScopedToken": {
50046
51693
  capName: "user-management",
50047
51694
  capScope: "system",
@@ -50078,12 +51725,6 @@ Object.freeze({
50078
51725
  addonId: null,
50079
51726
  access: "view"
50080
51727
  },
50081
- "userManagement.linkExternalIdentity": {
50082
- capName: "user-management",
50083
- capScope: "system",
50084
- addonId: null,
50085
- access: "create"
50086
- },
50087
51728
  "userManagement.listApiKeys": {
50088
51729
  capName: "user-management",
50089
51730
  capScope: "system",
@@ -50186,12 +51827,6 @@ Object.freeze({
50186
51827
  addonId: null,
50187
51828
  access: "create"
50188
51829
  },
50189
- "userManagement.validateApiKey": {
50190
- capName: "user-management",
50191
- capScope: "system",
50192
- addonId: null,
50193
- access: "view"
50194
- },
50195
51830
  "userManagement.validateCredentials": {
50196
51831
  capName: "user-management",
50197
51832
  capScope: "system",
@@ -54371,6 +56006,11 @@ Object.freeze({
54371
56006
  form: "single",
54372
56007
  optional: false
54373
56008
  }],
56009
+ "training.canaryResult": [{
56010
+ name: "deviceIds",
56011
+ form: "array",
56012
+ optional: false
56013
+ }],
54374
56014
  "update.getStatus": [{
54375
56015
  name: "deviceId",
54376
56016
  form: "single",
@@ -55673,7 +57313,12 @@ var CREDENTIAL_PARAM_PATTERNS = [
55673
57313
  /^bearer$/i,
55674
57314
  /^api[_-]?key$/i,
55675
57315
  /^access[_-]?token$/i,
55676
- /^refresh[_-]?token$/i
57316
+ /^refresh[_-]?token$/i,
57317
+ /^bridge$/i,
57318
+ /^code$/i,
57319
+ /^state$/i,
57320
+ /^challenge$/i,
57321
+ /^link$/i
55677
57322
  ];
55678
57323
  function isCredentialParam(name) {
55679
57324
  return CREDENTIAL_PARAM_PATTERNS.some((re) => re.test(name));
@@ -55695,6 +57340,10 @@ function isCredentialParam(name) {
55695
57340
  * are NOT masked (those are entity references, not credentials).
55696
57341
  */
55697
57342
  function maskUrlCredentials(rawUrl) {
57343
+ if (rawUrl.startsWith("/") && !rawUrl.startsWith("//")) {
57344
+ const masked = maskUrlCredentials(`http://relative.invalid${rawUrl}`);
57345
+ return masked.startsWith("http://relative.invalid") ? masked.slice(23) : rawUrl;
57346
+ }
55698
57347
  try {
55699
57348
  const u = new URL(rawUrl);
55700
57349
  let touched = false;