@camstack/addon-pipeline 1.2.346 → 1.2.347

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 (35) hide show
  1. package/dist/audio-analyzer/index.js +3 -3
  2. package/dist/audio-analyzer/index.mjs +3 -3
  3. package/dist/{custom-model-catalog-C4LhTrew.mjs → custom-model-catalog-B_3TaGyS.mjs} +2 -2
  4. package/dist/{custom-model-catalog-B0QdF7dJ.js → custom-model-catalog-VPiA2VLl.js} +2 -2
  5. package/dist/detection-pipeline/index.js +4 -4
  6. package/dist/detection-pipeline/index.mjs +4 -4
  7. package/dist/{dist-qBCVRsyf.js → dist-BK74zWWV.js} +1781 -132
  8. package/dist/{dist-Dj26w1od.mjs → dist-mCRj-pzB.mjs} +1781 -132
  9. package/dist/{model-catalogs-C6tbm7vF.js → model-catalogs-0h3q8aik.js} +15 -4
  10. package/dist/{model-catalogs-CsxkEiiz.mjs → model-catalogs-CwzQMyNC.mjs} +15 -4
  11. package/dist/motion-wasm/index.js +1 -1
  12. package/dist/motion-wasm/index.mjs +1 -1
  13. package/dist/{node-Cc9bQ8ZM.mjs → node-BbmYK6W-.mjs} +1 -1
  14. package/dist/{node-DmCpPH58.js → node-BdTn3tlc.js} +1 -1
  15. package/dist/pipeline-runner/index.js +3 -3
  16. package/dist/pipeline-runner/index.mjs +3 -3
  17. package/dist/{process-memory-BxIflT01.js → process-memory-CnZ_X4eQ.js} +1 -1
  18. package/dist/{process-memory-BrI4evjl.mjs → process-memory-bOQf34ya.mjs} +1 -1
  19. package/dist/recorder/index.js +4 -6
  20. package/dist/recorder/index.mjs +4 -6
  21. package/dist/{segment-demux-js-CmuAuckE.mjs → segment-demux-js-5MO-ia8o.mjs} +1 -1
  22. package/dist/{segment-demux-js-DCLzkQTf.js → segment-demux-js-C4jnKQoX.js} +1 -1
  23. package/dist/stream-broker/_stub.js +2 -2
  24. package/dist/stream-broker/{_virtual_mf-localSharedImportMap___mfe_internal__addon_stream_broker_widgets-BX73joE9.mjs → _virtual_mf-localSharedImportMap___mfe_internal__addon_stream_broker_widgets-C8GBSIhY.mjs} +3 -3
  25. package/dist/stream-broker/_virtual_mf___mfe_internal__addon_stream_broker_widgets__loadShare___mf_0_camstack_mf_1_types__loadShare__.js-CNhTe1NS.mjs +26 -0
  26. package/dist/stream-broker/_virtual_mf___mfe_internal__addon_stream_broker_widgets__loadShare___mf_0_camstack_mf_1_ui_mf_2_library__loadShare__.js-uvybMzaE.mjs +26 -0
  27. package/dist/stream-broker/demux-worker-child.js +1 -1
  28. package/dist/stream-broker/demux-worker-child.mjs +1 -1
  29. package/dist/stream-broker/{hostInit-DKWabjpO.mjs → hostInit-IWX_cy7U.mjs} +3 -3
  30. package/dist/stream-broker/index.js +3 -3
  31. package/dist/stream-broker/index.mjs +3 -3
  32. package/dist/stream-broker/remoteEntry.js +1 -1
  33. package/package.json +1 -1
  34. package/dist/stream-broker/_virtual_mf___mfe_internal__addon_stream_broker_widgets__loadShare___mf_0_camstack_mf_1_types__loadShare__.js-B38GLERV.mjs +0 -26
  35. package/dist/stream-broker/_virtual_mf___mfe_internal__addon_stream_broker_widgets__loadShare___mf_0_camstack_mf_1_ui_mf_2_library__loadShare__.js-pieGo_tC.mjs +0 -26
@@ -5377,7 +5377,7 @@ var ZodIssueCode = {
5377
5377
  var ZodFirstPartyTypeKind;
5378
5378
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
5379
5379
  //#endregion
5380
- //#region ../types/dist/sleep-Cr5YOk3m.mjs
5380
+ //#region ../types/dist/sleep-r3RWkGVx.mjs
5381
5381
  /**
5382
5382
  * The audio chunk plane's byte format, and the ONE expansion from a coded
5383
5383
  * window to float samples (D455).
@@ -5526,7 +5526,7 @@ function isKeychainStoredField(field) {
5526
5526
  var SECRET_CLEAR = { $secretClear: true };
5527
5527
  /** The `'***'` token D634 redaction writes for non-admins. */
5528
5528
  var LEGACY_DEVICE_REDACTION = "***";
5529
- function isRecord$1$1(value) {
5529
+ function isRecord$2(value) {
5530
5530
  return typeof value === "object" && value !== null && !Array.isArray(value);
5531
5531
  }
5532
5532
  function makeSecretMarker(ref) {
@@ -5537,12 +5537,12 @@ function makeSecretMarker(ref) {
5537
5537
  }
5538
5538
  /** A stored marker: an object whose `$secret` is a non-empty string. */
5539
5539
  function isSecretMarker(value) {
5540
- if (!isRecord$1$1(value)) return false;
5540
+ if (!isRecord$2(value)) return false;
5541
5541
  const ref = value["$secret"];
5542
5542
  return typeof ref === "string" && ref.length > 0;
5543
5543
  }
5544
5544
  function isSecretClear(value) {
5545
- return isRecord$1$1(value) && value["$secretClear"] === true;
5545
+ return isRecord$2(value) && value["$secretClear"] === true;
5546
5546
  }
5547
5547
  /**
5548
5548
  * The UI view of a stored secret field value: a marker becomes "set", inline
@@ -6074,6 +6074,13 @@ function globalSecretScope() {
6074
6074
  function encodeSegment(value) {
6075
6075
  return encodeURIComponent(value);
6076
6076
  }
6077
+ function decodeSegment(value) {
6078
+ try {
6079
+ return decodeURIComponent(value);
6080
+ } catch {
6081
+ return null;
6082
+ }
6083
+ }
6077
6084
  /**
6078
6085
  * The field path of a value inside an array item, addressed by the item's id:
6079
6086
  * `arrayItemFieldPath('providers', 'authentik', 'clientSecret')` →
@@ -6082,6 +6089,75 @@ function encodeSegment(value) {
6082
6089
  function arrayItemFieldPath(arrayKey, itemId, fieldKey) {
6083
6090
  return `${arrayKey}[${encodeSegment(itemId)}].${fieldKey}`;
6084
6091
  }
6092
+ function parseScope(segments) {
6093
+ switch (segments[0]) {
6094
+ case "global": return {
6095
+ scope: GLOBAL_SCOPE,
6096
+ used: 1
6097
+ };
6098
+ case "node": {
6099
+ const nodeId = segments[1] !== void 0 ? decodeSegment(segments[1]) : null;
6100
+ return nodeId === null || nodeId.length === 0 ? null : {
6101
+ scope: {
6102
+ kind: "node",
6103
+ nodeId
6104
+ },
6105
+ used: 2
6106
+ };
6107
+ }
6108
+ case "device": {
6109
+ const raw = segments[1];
6110
+ if (raw === void 0 || !/^\d+$/.test(raw)) return null;
6111
+ return {
6112
+ scope: {
6113
+ kind: "device",
6114
+ deviceId: Number(raw)
6115
+ },
6116
+ used: 2
6117
+ };
6118
+ }
6119
+ case "integration": {
6120
+ const id = segments[1] !== void 0 ? decodeSegment(segments[1]) : null;
6121
+ return id === null || id.length === 0 ? null : {
6122
+ scope: {
6123
+ kind: "integration",
6124
+ integrationId: id
6125
+ },
6126
+ used: 2
6127
+ };
6128
+ }
6129
+ case "row": {
6130
+ const collection = segments[1] !== void 0 ? decodeSegment(segments[1]) : null;
6131
+ const rowId = segments[2] !== void 0 ? decodeSegment(segments[2]) : null;
6132
+ if (collection === null || rowId === null || collection.length === 0 || rowId.length === 0) return null;
6133
+ return {
6134
+ scope: {
6135
+ kind: "row",
6136
+ collection,
6137
+ rowId
6138
+ },
6139
+ used: 3
6140
+ };
6141
+ }
6142
+ default: return null;
6143
+ }
6144
+ }
6145
+ /** Take a ref apart; `null` when it is not a well-formed ref. */
6146
+ function parseSecretRef(ref) {
6147
+ if (!ref.startsWith("secret://")) return null;
6148
+ const segments = ref.slice(9).split("/");
6149
+ const owner = segments[0] !== void 0 ? decodeSegment(segments[0]) : null;
6150
+ if (owner === null || owner.length === 0) return null;
6151
+ const parsed = parseScope(segments.slice(1));
6152
+ if (parsed === null) return null;
6153
+ const fieldPath = segments.slice(1 + parsed.used).join("/");
6154
+ if (fieldPath.length === 0) return null;
6155
+ return {
6156
+ owner,
6157
+ scope: parsed.scope,
6158
+ fieldPath
6159
+ };
6160
+ }
6085
6161
  /** A write to a secret path could not be stored in the keychain, so it was refused. */
6086
6162
  var KeychainWriteRefusedError = class extends Error {
6087
6163
  fieldPath;
@@ -6092,7 +6168,7 @@ var KeychainWriteRefusedError = class extends Error {
6092
6168
  }
6093
6169
  };
6094
6170
  var KEEP = { kind: "keep" };
6095
- function isRecord(value) {
6171
+ function isRecord$1$1(value) {
6096
6172
  return typeof value === "object" && value !== null && !Array.isArray(value);
6097
6173
  }
6098
6174
  function defaultMintId() {
@@ -6105,7 +6181,7 @@ function collectSecretMarkerRefs(value, out = []) {
6105
6181
  return out;
6106
6182
  }
6107
6183
  if (Array.isArray(value)) for (const item of value) collectSecretMarkerRefs(item, out);
6108
- else if (isRecord(value)) for (const child of Object.values(value)) collectSecretMarkerRefs(child, out);
6184
+ else if (isRecord$1$1(value)) for (const child of Object.values(value)) collectSecretMarkerRefs(child, out);
6109
6185
  return out;
6110
6186
  }
6111
6187
  async function storedValueEquals(secrets, marker, candidate) {
@@ -6160,7 +6236,7 @@ function rowId(row, idKey) {
6160
6236
  return null;
6161
6237
  }
6162
6238
  async function writeArray(ctx, node, incoming, stored, fieldPath) {
6163
- const storedRows = Array.isArray(stored) ? stored.filter(isRecord) : [];
6239
+ const storedRows = Array.isArray(stored) ? stored.filter(isRecord$1$1) : [];
6164
6240
  if (!Array.isArray(incoming)) {
6165
6241
  ctx.deletes.push(...collectSecretMarkerRefs(storedRows));
6166
6242
  return {
@@ -6176,7 +6252,7 @@ async function writeArray(ctx, node, incoming, stored, fieldPath) {
6176
6252
  const kept = /* @__PURE__ */ new Set();
6177
6253
  const rows = [];
6178
6254
  for (const row of incoming) {
6179
- if (!isRecord(row)) {
6255
+ if (!isRecord$1$1(row)) {
6180
6256
  rows.push(row);
6181
6257
  continue;
6182
6258
  }
@@ -6201,7 +6277,7 @@ async function writeNode(ctx, node, incoming, stored, fieldPath) {
6201
6277
  case "leaf": return writeLeaf(ctx, incoming, stored, fieldPath);
6202
6278
  case "array": return writeArray(ctx, node, incoming, stored, fieldPath);
6203
6279
  case "object": {
6204
- if (!isRecord(incoming)) {
6280
+ if (!isRecord$1$1(incoming)) {
6205
6281
  if (incoming === void 0) return KEEP;
6206
6282
  ctx.deletes.push(...collectSecretMarkerRefs(stored));
6207
6283
  return {
@@ -6209,7 +6285,7 @@ async function writeNode(ctx, node, incoming, stored, fieldPath) {
6209
6285
  value: incoming
6210
6286
  };
6211
6287
  }
6212
- const storedObj = isRecord(stored) ? stored : {};
6288
+ const storedObj = isRecord$1$1(stored) ? stored : {};
6213
6289
  return {
6214
6290
  kind: "value",
6215
6291
  value: await writeMembers(ctx, node.children, incoming, storedObj, (m) => `${fieldPath}.${m}`)
@@ -6268,12 +6344,19 @@ async function transformSecretWrite(input) {
6268
6344
  }
6269
6345
  };
6270
6346
  }
6347
+ /** Is `ref` one of `owner`'s refs? */
6348
+ function isSecretRefOwnedBy(ref, owner) {
6349
+ return parseSecretRef(ref)?.owner === owner;
6350
+ }
6271
6351
  /**
6272
6352
  * Replace every marker in `value` with its keychain value. Returns the SAME
6273
6353
  * reference when there is no marker (no allocation, no keychain call).
6274
6354
  */
6275
- async function resolveSecretMarkers(value, secrets) {
6276
- const refs = collectSecretMarkerRefs(value);
6355
+ async function resolveSecretMarkers(value, secrets, options = {}) {
6356
+ const keepMarker = options.unresolved === "keep-marker";
6357
+ const owner = options.ownedBy;
6358
+ const inScope = (ref) => owner === void 0 || isSecretRefOwnedBy(ref, owner);
6359
+ const refs = collectSecretMarkerRefs(value).filter(inScope);
6277
6360
  if (refs.length === 0) return {
6278
6361
  value,
6279
6362
  unresolved: []
@@ -6297,10 +6380,18 @@ async function resolveSecretMarkers(value, secrets) {
6297
6380
  }
6298
6381
  const substitute = (v) => {
6299
6382
  if (isSecretMarker(v)) {
6383
+ if (!inScope(v.$secret)) return {
6384
+ keep: true,
6385
+ value: v
6386
+ };
6300
6387
  const answer = answers[v.$secret];
6301
- return answer?.kind === "value" ? {
6388
+ if (answer?.kind === "value") return {
6302
6389
  keep: true,
6303
6390
  value: answer.value
6391
+ };
6392
+ return keepMarker ? {
6393
+ keep: true,
6394
+ value: v
6304
6395
  } : {
6305
6396
  keep: false,
6306
6397
  value: void 0
@@ -6317,7 +6408,7 @@ async function resolveSecretMarkers(value, secrets) {
6317
6408
  value: items
6318
6409
  };
6319
6410
  }
6320
- if (isRecord(v)) {
6411
+ if (isRecord$1$1(v)) {
6321
6412
  const out = {};
6322
6413
  for (const [k, child] of Object.entries(v)) {
6323
6414
  const s = substitute(child);
@@ -6338,14 +6429,152 @@ async function resolveSecretMarkers(value, secrets) {
6338
6429
  unresolved
6339
6430
  };
6340
6431
  }
6341
- function touchesTree(tree, patch) {
6342
- if (tree.size === 0) return false;
6343
- for (const key of Object.keys(patch)) {
6344
- const at = key.indexOf("@");
6345
- if (tree.has(at > 0 ? key.slice(0, at) : key)) return true;
6432
+ /** An addon tried to replace a stored secret it could not read. Nothing was written. */
6433
+ var SecretOverwriteRefusedError = class extends Error {
6434
+ ref;
6435
+ reason;
6436
+ constructor(ref, reason) {
6437
+ 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.`);
6438
+ this.ref = ref;
6439
+ this.reason = reason;
6440
+ this.name = "SecretOverwriteRefusedError";
6441
+ }
6442
+ };
6443
+ function isRecord(value) {
6444
+ return typeof value === "object" && value !== null && !Array.isArray(value);
6445
+ }
6446
+ function resolvedValue(pass, marker) {
6447
+ const answer = pass.answers[marker.$secret];
6448
+ return answer?.kind === "value" ? answer.value : null;
6449
+ }
6450
+ async function atMarker(pass, incoming, stored) {
6451
+ if (incoming === null) return stored;
6452
+ if (typeof incoming !== "string") return incoming;
6453
+ if (incoming === resolvedValue(pass, stored)) return stored;
6454
+ const intent = classifySecretWrite(incoming);
6455
+ if (intent.kind !== "set") return stored;
6456
+ const ref = stored.$secret;
6457
+ if (!isSecretRefOwnedBy(ref, pass.secrets.owner)) return incoming;
6458
+ const answer = pass.answers[ref];
6459
+ 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);
6460
+ try {
6461
+ await pass.secrets.put(ref, intent.value);
6462
+ } catch (err) {
6463
+ throw new KeychainWriteRefusedError(ref, err);
6464
+ }
6465
+ pass.changedRefs.push(ref);
6466
+ return stored;
6467
+ }
6468
+ function inArray(pass, incoming, stored) {
6469
+ return incoming.map((item, index) => {
6470
+ const twin = stored[index];
6471
+ if (isSecretMarker(twin)) return typeof item === "string" && item === resolvedValue(pass, twin) ? twin : item;
6472
+ if (isRecord(item) && isRecord(twin)) return inArrayRow(pass, item, twin);
6473
+ if (Array.isArray(item) && Array.isArray(twin)) return inArray(pass, item, twin);
6474
+ return item;
6475
+ });
6476
+ }
6477
+ function inArrayRow(pass, incoming, stored) {
6478
+ const out = { ...incoming };
6479
+ for (const [key, value] of Object.entries(incoming)) {
6480
+ const twin = stored[key];
6481
+ if (isSecretMarker(twin)) {
6482
+ if (typeof value === "string" && value === resolvedValue(pass, twin)) out[key] = twin;
6483
+ } else if (isRecord(value) && isRecord(twin)) out[key] = inArrayRow(pass, value, twin);
6484
+ else if (Array.isArray(value) && Array.isArray(twin)) out[key] = inArray(pass, value, twin);
6485
+ }
6486
+ return out;
6487
+ }
6488
+ async function walk(pass, incoming, stored) {
6489
+ if (isSecretMarker(stored)) return atMarker(pass, incoming, stored);
6490
+ if (Array.isArray(incoming) && Array.isArray(stored)) return inArray(pass, incoming, stored);
6491
+ if (!isRecord(incoming) || !isRecord(stored)) return incoming;
6492
+ const out = { ...incoming };
6493
+ for (const [key, value] of Object.entries(incoming)) out[key] = await walk(pass, value, stored[key]);
6494
+ return out;
6495
+ }
6496
+ /** Restore markers a write-back carries as values. See the file doc. */
6497
+ async function restoreUnchangedSecrets(input) {
6498
+ const refs = [];
6499
+ for (const key of Object.keys(input.patch)) collectSecretMarkerRefs(input.stored[key], refs);
6500
+ const owned = refs.filter((ref) => isSecretRefOwnedBy(ref, input.secrets.owner));
6501
+ if (owned.length === 0) return {
6502
+ patch: input.patch,
6503
+ changedRefs: []
6504
+ };
6505
+ const pass = {
6506
+ secrets: input.secrets,
6507
+ answers: await input.secrets.resolve([...new Set(owned)]),
6508
+ operatorWrite: input.operatorWrite,
6509
+ changedRefs: []
6510
+ };
6511
+ const out = {};
6512
+ for (const [key, value] of Object.entries(input.patch)) out[key] = await walk(pass, value, input.stored[key]);
6513
+ return {
6514
+ patch: out,
6515
+ changedRefs: pass.changedRefs
6516
+ };
6517
+ }
6518
+ /** Structural equality over JSON-shaped values (key order does not matter). */
6519
+ function isJsonEqual(a, b) {
6520
+ if (Object.is(a, b)) return true;
6521
+ if (Array.isArray(a)) return Array.isArray(b) && a.length === b.length && a.every((v, i) => isJsonEqual(v, b[i]));
6522
+ if (isRecord(a) && isRecord(b)) {
6523
+ const keys = Object.keys(a);
6524
+ if (keys.length !== Object.keys(b).length) return false;
6525
+ return keys.every((k) => Object.prototype.hasOwnProperty.call(b, k) && isJsonEqual(a[k], b[k]));
6346
6526
  }
6347
6527
  return false;
6348
6528
  }
6529
+ /** The patch without the keys whose value already equals the stored one. */
6530
+ function dropUnchangedKeys(patch, stored) {
6531
+ const out = {};
6532
+ for (const [key, value] of Object.entries(patch)) {
6533
+ if (Object.prototype.hasOwnProperty.call(stored, key) && isJsonEqual(value, stored[key])) continue;
6534
+ out[key] = value;
6535
+ }
6536
+ return out;
6537
+ }
6538
+ /** The top-level keys of a blob that hold at least one of `owner`'s markers. */
6539
+ function markerKeysOf(blob, owner) {
6540
+ const keys = /* @__PURE__ */ new Set();
6541
+ for (const [key, value] of Object.entries(blob)) if (collectSecretMarkerRefs(value).some((ref) => isSecretRefOwnedBy(ref, owner))) keys.add(key);
6542
+ return keys;
6543
+ }
6544
+ function nodeFromStored(value, owner) {
6545
+ if (isSecretMarker(value)) return isSecretRefOwnedBy(value.$secret, owner) ? { kind: "leaf" } : null;
6546
+ if (!isRecord(value)) return null;
6547
+ const children = /* @__PURE__ */ new Map();
6548
+ for (const [key, child] of Object.entries(value)) {
6549
+ const node = nodeFromStored(child, owner);
6550
+ if (node !== null) children.set(key, node);
6551
+ }
6552
+ return children.size > 0 ? {
6553
+ kind: "object",
6554
+ children
6555
+ } : null;
6556
+ }
6557
+ /**
6558
+ * The declared secret tree, widened by every place the STORED blob holds a
6559
+ * marker under one of `keys` — so a marker the schema no longer declares (or
6560
+ * never declared: Wyze before b4906cec6) still gets the save path's
6561
+ * KEEP / SET / CLEAR semantics instead of being overwritten by whatever the
6562
+ * addon writes. Markers inside arrays are not added: a row has no id field to
6563
+ * match by unless the schema declares one. Only `owner`'s markers count: a
6564
+ * builtin that keeps another addon's marker (device-manager) never takes it
6565
+ * over.
6566
+ */
6567
+ function widenTreeWithStoredMarkers(declared, stored, keys, owner) {
6568
+ const added = /* @__PURE__ */ new Map();
6569
+ for (const key of keys) {
6570
+ const at = key.indexOf("@");
6571
+ const base = at > 0 ? key.slice(0, at) : key;
6572
+ if (declared.has(base) || added.has(base)) continue;
6573
+ const node = nodeFromStored(stored[key], owner);
6574
+ if (node !== null) added.set(base, node);
6575
+ }
6576
+ return added.size === 0 ? declared : new Map([...declared, ...added]);
6577
+ }
6349
6578
  /** The blob as stored now; a failed read REFUSES the write instead of guessing. */
6350
6579
  async function readStoredAddonBlob(raw) {
6351
6580
  const threeWay = raw.readAddonStoreResult;
@@ -6354,7 +6583,41 @@ async function readStoredAddonBlob(raw) {
6354
6583
  if (result.kind === "failed") throw new Error(`settings write refused: the stored blob could not be read (${result.error})`);
6355
6584
  return result.kind === "missing" ? {} : result.value;
6356
6585
  }
6357
- function createSecretAwareSettings(raw, opts) {
6586
+ function touchesTree(tree, patch) {
6587
+ if (tree.size === 0) return false;
6588
+ for (const key of Object.keys(patch)) {
6589
+ const at = key.indexOf("@");
6590
+ if (tree.has(at > 0 ? key.slice(0, at) : key)) return true;
6591
+ }
6592
+ return false;
6593
+ }
6594
+ /**
6595
+ * Which top-level keys of each store held markers when last seen. `undefined`
6596
+ * for a store not seen yet: its first write reads it, to be safe.
6597
+ */
6598
+ var MarkerKeyIndex = class {
6599
+ owner;
6600
+ byStore = /* @__PURE__ */ new Map();
6601
+ constructor(owner) {
6602
+ this.owner = owner;
6603
+ }
6604
+ seen(store, blob) {
6605
+ this.byStore.set(store, markerKeysOf(blob, this.owner));
6606
+ }
6607
+ wrote(store, patch) {
6608
+ const keys = this.byStore.get(store);
6609
+ if (keys === void 0) return;
6610
+ const now = markerKeysOf(patch, this.owner);
6611
+ for (const key of Object.keys(patch)) if (now.has(key)) keys.add(key);
6612
+ else keys.delete(key);
6613
+ }
6614
+ mayHoldMarkers(store, patch) {
6615
+ const keys = this.byStore.get(store);
6616
+ if (keys === void 0) return true;
6617
+ return Object.keys(patch).some((key) => keys.has(key));
6618
+ }
6619
+ };
6620
+ function createHandle(raw, opts) {
6358
6621
  const chains = /* @__PURE__ */ new Map();
6359
6622
  const serialize = (key, fn) => {
6360
6623
  const next = (chains.get(key) ?? Promise.resolve()).then(fn, fn);
@@ -6365,46 +6628,130 @@ function createSecretAwareSettings(raw, opts) {
6365
6628
  });
6366
6629
  return next;
6367
6630
  };
6368
- const write = async (chainKey, tree, scope, patch, readStored, rawWrite) => {
6369
- if (!touchesTree(tree, patch)) return rawWrite(patch);
6370
- return serialize(chainKey, async () => {
6631
+ const index = new MarkerKeyIndex(opts.secrets.owner);
6632
+ const resolveRead = async (store, blob) => {
6633
+ index.seen(store, blob);
6634
+ const { value, unresolved } = await resolveSecretMarkers(blob, opts.secrets, {
6635
+ unresolved: "keep-marker",
6636
+ ownedBy: opts.secrets.owner
6637
+ });
6638
+ if (unresolved.length > 0) opts.onUnresolved?.(unresolved);
6639
+ return value;
6640
+ };
6641
+ const write = async (store, declared, scope, patch, readStored, rawWrite) => {
6642
+ if (!touchesTree(declared, patch) && !index.mayHoldMarkers(store, patch)) {
6643
+ await rawWrite(patch);
6644
+ index.wrote(store, patch);
6645
+ return { changed: true };
6646
+ }
6647
+ return serialize(store, async () => {
6371
6648
  const stored = await readStored();
6649
+ index.seen(store, stored);
6650
+ const operatorWrite = opts.isOperatorWrite?.() === true;
6651
+ const restored = await restoreUnchangedSecrets({
6652
+ patch,
6653
+ stored,
6654
+ secrets: opts.secrets,
6655
+ operatorWrite
6656
+ });
6372
6657
  const result = await transformSecretWrite({
6373
- tree,
6658
+ tree: widenTreeWithStoredMarkers(declared, stored, Object.keys(restored.patch), opts.secrets.owner),
6374
6659
  secrets: opts.secrets,
6375
- patch,
6660
+ patch: restored.patch,
6376
6661
  stored,
6377
6662
  ...scope !== void 0 ? { scope } : {},
6378
- operatorWrite: opts.isOperatorWrite?.() === true
6663
+ operatorWrite
6379
6664
  });
6380
- if (Object.keys(result.patch).length > 0) await rawWrite(result.patch);
6665
+ const effective = dropUnchangedKeys(result.patch, stored);
6666
+ const wroteBlob = Object.keys(effective).length > 0;
6667
+ if (wroteBlob) {
6668
+ await rawWrite(effective);
6669
+ index.wrote(store, effective);
6670
+ }
6381
6671
  const { orphaned } = await result.afterWrite();
6382
6672
  if (orphaned.length > 0) opts.onOrphaned(orphaned);
6673
+ return { changed: wroteBlob || restored.changedRefs.length > 0 };
6383
6674
  });
6384
6675
  };
6385
- const wrapped = {
6386
- writeAddonStore: (patch) => write("addon", opts.addonTree(), void 0, patch, () => readStoredAddonBlob(raw), (p) => raw.writeAddonStore(p)),
6387
- writeDeviceStore: (deviceId, patch) => write(`device:${deviceId}`, opts.deviceTree(), {
6388
- kind: "device",
6389
- deviceId
6390
- }, patch, () => raw.readDeviceStore(deviceId), (p) => raw.writeDeviceStore(deviceId, p))
6676
+ const writeAddon = (patch) => write("addon", opts.addonTree(), void 0, patch, () => readStoredAddonBlob(raw), (p) => raw.writeAddonStore(p));
6677
+ const readAddonStoreResult = raw.readAddonStoreResult;
6678
+ const readAddonStoreKeyResult = raw.readAddonStoreKeyResult;
6679
+ const readDeviceStoreBatch = raw.readDeviceStoreBatch;
6680
+ const overrides = {
6681
+ readAddonStore: async () => resolveRead("addon", await raw.readAddonStore()),
6682
+ ...readAddonStoreResult !== void 0 ? { readAddonStoreResult: async () => {
6683
+ const result = await readAddonStoreResult.call(raw);
6684
+ return result.kind === "value" ? {
6685
+ kind: "value",
6686
+ value: await resolveRead("addon", result.value)
6687
+ } : result;
6688
+ } } : {},
6689
+ ...readAddonStoreKeyResult !== void 0 ? { readAddonStoreKeyResult: async (key) => {
6690
+ const result = await readAddonStoreKeyResult.call(raw, key);
6691
+ if (result.kind !== "present") return result;
6692
+ const { value, unresolved } = await resolveSecretMarkers({ [key]: result.value }, opts.secrets, {
6693
+ unresolved: "keep-marker",
6694
+ ownedBy: opts.secrets.owner
6695
+ });
6696
+ if (unresolved.length > 0) opts.onUnresolved?.(unresolved);
6697
+ return {
6698
+ kind: "present",
6699
+ value: value[key]
6700
+ };
6701
+ } } : {},
6702
+ readDeviceStore: async (deviceId) => resolveRead(`device:${deviceId}`, await raw.readDeviceStore(deviceId)),
6703
+ ...readDeviceStoreBatch !== void 0 ? { readDeviceStoreBatch: async (deviceIds) => {
6704
+ const rows = await readDeviceStoreBatch.call(raw, deviceIds);
6705
+ const out = /* @__PURE__ */ new Map();
6706
+ for (const [deviceId, blob] of rows) out.set(deviceId, await resolveRead(`device:${deviceId}`, blob));
6707
+ return out;
6708
+ } } : {},
6709
+ writeAddonStore: async (patch) => {
6710
+ await writeAddon(patch);
6711
+ },
6712
+ writeDeviceStore: async (deviceId, patch) => {
6713
+ await write(`device:${deviceId}`, opts.deviceTree(), {
6714
+ kind: "device",
6715
+ deviceId
6716
+ }, patch, () => raw.readDeviceStore(deviceId), (p) => raw.writeDeviceStore(deviceId, p));
6717
+ }
6718
+ };
6719
+ return {
6720
+ settings: new Proxy(raw, { get(target, prop, receiver) {
6721
+ if (typeof prop === "string" && Object.prototype.hasOwnProperty.call(overrides, prop)) return Reflect.get(overrides, prop);
6722
+ const value = Reflect.get(target, prop, receiver);
6723
+ return typeof value === "function" ? value.bind(target) : value;
6724
+ } }),
6725
+ raw: {
6726
+ readAddonStore: async () => {
6727
+ const blob = await raw.readAddonStore();
6728
+ index.seen("addon", blob);
6729
+ return blob;
6730
+ },
6731
+ readDeviceStore: async (deviceId) => {
6732
+ const blob = await raw.readDeviceStore(deviceId);
6733
+ index.seen(`device:${deviceId}`, blob);
6734
+ return blob;
6735
+ }
6736
+ },
6737
+ writeAddonStore: writeAddon
6391
6738
  };
6392
- return new Proxy(raw, { get(target, prop, receiver) {
6393
- if (prop === "writeAddonStore") return wrapped.writeAddonStore;
6394
- if (prop === "writeDeviceStore") return wrapped.writeDeviceStore;
6395
- const value = Reflect.get(target, prop, receiver);
6396
- return typeof value === "function" ? value.bind(target) : value;
6397
- } });
6398
6739
  }
6399
- /** The context the addon sees: identical, except that its settings writes are secret-aware. */
6400
- function withSecretAwareSettings(context, opts) {
6740
+ /** The context the addon sees, plus the private raw view and write outcome. */
6741
+ function createSecretAwareContext(context, opts) {
6401
6742
  const raw = context.settings;
6402
- if (raw === void 0) return context;
6403
- const settings = createSecretAwareSettings(raw, opts);
6404
- return new Proxy(context, { get(target, prop, receiver) {
6405
- if (prop === "settings") return settings;
6406
- return Reflect.get(target, prop, receiver);
6407
- } });
6743
+ if (raw === void 0) return {
6744
+ context,
6745
+ handle: null
6746
+ };
6747
+ const handle = createHandle(raw, opts);
6748
+ return {
6749
+ context: new Proxy(context, { get(target, prop, receiver) {
6750
+ if (prop === "settings") return handle.settings;
6751
+ return Reflect.get(target, prop, receiver);
6752
+ } }),
6753
+ handle
6754
+ };
6408
6755
  }
6409
6756
  var LEAF = { kind: "leaf" };
6410
6757
  var DEFAULT_ITEM_ID_KEY = "id";
@@ -6579,6 +6926,14 @@ var BaseAddon = class {
6579
6926
  _secretChangeUnsub = null;
6580
6927
  /** >0 while an OPERATOR's settings write is being applied. */
6581
6928
  _operatorWriteDepth = 0;
6929
+ /**
6930
+ * The keychain-aware settings handle (D798). Its `raw` view is the ONLY way
6931
+ * to the marker-bearing blobs and stays private to this class: the form
6932
+ * hydrate and config resolution need markers, addon code never does.
6933
+ */
6934
+ _secretSettings = null;
6935
+ /** Refs an addon-facing read could not resolve — each is logged once per process. */
6936
+ _loggedUnresolvedReads = /* @__PURE__ */ new Set();
6582
6937
  constructor(defaults) {
6583
6938
  this.defaults = defaults;
6584
6939
  this._config = { ...defaults };
@@ -6615,13 +6970,21 @@ var BaseAddon = class {
6615
6970
  }
6616
6971
  async initialize(context) {
6617
6972
  const secrets = context.secrets;
6618
- this._ctx = secrets !== void 0 ? withSecretAwareSettings(context, {
6619
- secrets,
6620
- addonTree: () => this.addonSecretTree(),
6621
- deviceTree: () => this.deviceSecretTree(),
6622
- onOrphaned: (refs) => context.logger.warn("keychain refs dropped by a settings write could not be deleted", { meta: { refs: [...refs] } }),
6623
- isOperatorWrite: () => this._operatorWriteDepth > 0
6624
- }) : context;
6973
+ if (secrets !== void 0) {
6974
+ const { context: wrapped, handle } = createSecretAwareContext(context, {
6975
+ secrets,
6976
+ addonTree: () => this.addonSecretTree(),
6977
+ deviceTree: () => this.deviceSecretTree(),
6978
+ onOrphaned: (refs) => context.logger.warn("keychain refs dropped by a settings write could not be deleted", { meta: { refs: [...refs] } }),
6979
+ isOperatorWrite: () => this._operatorWriteDepth > 0,
6980
+ onUnresolved: (unresolved) => this.logUnresolvedRead(unresolved)
6981
+ });
6982
+ this._ctx = wrapped;
6983
+ this._secretSettings = handle;
6984
+ } else {
6985
+ this._ctx = context;
6986
+ this._secretSettings = null;
6987
+ }
6625
6988
  await this.resolveConfig();
6626
6989
  if (secrets !== void 0) this._secretChangeUnsub = secrets.onChange((ref) => {
6627
6990
  if (this._configSecretRefs.has(ref)) this.scheduleSecretReresolve(SECRET_CHANGE_DEBOUNCE_MS);
@@ -6738,11 +7101,8 @@ var BaseAddon = class {
6738
7101
  async getGlobalSettings(overlay, cap, nodeId) {
6739
7102
  const schema = this.globalSettingsSchema(cap);
6740
7103
  if (!schema) return { sections: [] };
6741
- const projected = await this.resolveGlobalStore(nodeId, cap);
6742
- return hydrateSchema(schema, overlay ? {
6743
- ...projected,
6744
- ...overlay
6745
- } : projected, { inlineSecretsAsViews: true });
7104
+ const projected = await this.readRawProjectedStore(nodeId, cap);
7105
+ return hydrateSchema(schema, overlay ? await this.overlayKeepingMarkers(projected, overlay) : projected, { inlineSecretsAsViews: true });
6746
7106
  }
6747
7107
  /**
6748
7108
  * The integration-level view of this addon's settings: exactly the sections
@@ -6787,7 +7147,7 @@ var BaseAddon = class {
6787
7147
  });
6788
7148
  }
6789
7149
  if (sections.length === 0) return null;
6790
- const projected = await this.resolveGlobalStore(nodeId);
7150
+ const projected = await this.readRawProjectedStore(nodeId);
6791
7151
  return hydrateSchema({
6792
7152
  ...schema,
6793
7153
  sections
@@ -6804,12 +7164,50 @@ var BaseAddon = class {
6804
7164
  * the store for custom option logic (option narrowing, value snapping) to
6805
7165
  * read it per-node — never `ctx.settings.readAddonStore()` directly.
6806
7166
  * `nodeId` omitted ⇒ the local node (node-blind injection from ctx).
7167
+ *
7168
+ * Keychain values come back RESOLVED (D798): a secret reads as its value,
7169
+ * never as a `{ $secret }` marker. One the keychain cannot serve right now
7170
+ * stays a marker — "stored, unavailable" (`isSecretMarker()` is true, and it
7171
+ * is listed in {@link unresolvedSecrets}) — never `''` and never absent, so
7172
+ * it cannot be mistaken for "nothing stored, mint a new one". Writing the
7173
+ * resolved blob back is a no-op for every unchanged secret.
6807
7174
  */
6808
7175
  async resolveGlobalStore(nodeId, cap) {
6809
7176
  const raw = await this._ctx?.settings?.readAddonStore() ?? {};
7177
+ return this.projectForNode(raw, nodeId, cap);
7178
+ }
7179
+ projectForNode(store, nodeId, cap) {
6810
7180
  const keys = this.perNodeKeys(cap);
6811
7181
  const node = normalizeNodeId(nodeId ?? this._ctx?.kernel?.localNodeId);
6812
- return keys.size > 0 ? projectStore(raw, keys, node) : raw;
7182
+ return keys.size > 0 ? projectStore(store, keys, node) : store;
7183
+ }
7184
+ /** The PROJECTED store with its markers — the form hydrate only (D798). */
7185
+ async readRawProjectedStore(nodeId, cap) {
7186
+ const raw = await this.rawSettings()?.readAddonStore() ?? {};
7187
+ return this.projectForNode(raw, nodeId, cap);
7188
+ }
7189
+ /**
7190
+ * `{ ...stored, ...overlay }`, except that an overlay member equal to the
7191
+ * RESOLVED stored one keeps the stored (marker-bearing) member — so a form
7192
+ * hydrated from a resolved overlay still shows a secret as "set", never as
7193
+ * its value.
7194
+ */
7195
+ async overlayKeepingMarkers(stored, overlay) {
7196
+ const secrets = this._ctx?.secrets;
7197
+ const merged = {
7198
+ ...stored,
7199
+ ...overlay
7200
+ };
7201
+ if (secrets === void 0 || collectSecretMarkerRefs(stored).length === 0) return merged;
7202
+ const { value: resolved } = await resolveSecretMarkers(stored, secrets, {
7203
+ unresolved: "keep-marker",
7204
+ ownedBy: secrets.owner
7205
+ });
7206
+ for (const key of Object.keys(overlay)) {
7207
+ if (collectSecretMarkerRefs(stored[key]).length === 0) continue;
7208
+ if (isJsonEqual(overlay[key], resolved[key])) merged[key] = stored[key];
7209
+ }
7210
+ return merged;
6813
7211
  }
6814
7212
  /**
6815
7213
  * Whether ONE global key of this addon's store was written, read three-way
@@ -6874,8 +7272,12 @@ var BaseAddon = class {
6874
7272
  async clearSecrets(keys, nodeId) {
6875
7273
  const tree = this.addonSecretTree();
6876
7274
  const keychain = this._ctx?.secrets !== void 0;
7275
+ const stored = keychain ? await this.readAddonStoreWithRetry() : {};
6877
7276
  const patch = {};
6878
- for (const key of keys) patch[key] = keychain && tree.has(key) ? SECRET_CLEAR : "";
7277
+ for (const key of keys) {
7278
+ const keychainStored = tree.has(key) || collectSecretMarkerRefs(stored[key]).length > 0;
7279
+ patch[key] = keychain && keychainStored ? SECRET_CLEAR : "";
7280
+ }
6879
7281
  await this.applyGlobalPatch(patch, nodeId);
6880
7282
  }
6881
7283
  async applyGlobalPatch(barePatch, nodeId) {
@@ -6883,7 +7285,11 @@ var BaseAddon = class {
6883
7285
  const localNode = normalizeNodeId(this._ctx?.kernel?.localNodeId);
6884
7286
  const target = normalizeNodeId(nodeId ?? this._ctx?.kernel?.localNodeId);
6885
7287
  const scoped = keys.size > 0 ? scopePatch(barePatch, keys, target) : barePatch;
6886
- await this._ctx?.settings?.writeAddonStore(scoped);
7288
+ const handle = this._secretSettings;
7289
+ if (handle !== null) {
7290
+ const { changed } = await handle.writeAddonStore(scoped);
7291
+ if (!changed) return;
7292
+ } else await this._ctx?.settings?.writeAddonStore(scoped);
6887
7293
  if (target !== localNode) return;
6888
7294
  await this.resolveConfig();
6889
7295
  await this.onConfigChanged();
@@ -6936,7 +7342,7 @@ var BaseAddon = class {
6936
7342
  async getDeviceSettings(deviceId) {
6937
7343
  const schema = this.deviceSettingsSchema();
6938
7344
  if (!schema) return { sections: [] };
6939
- return hydrateSchema(schema, await this._ctx?.settings?.readDeviceStore(deviceId) ?? {}, { inlineSecretsAsViews: true });
7345
+ return hydrateSchema(schema, await this.rawSettings()?.readDeviceStore(deviceId) ?? {}, { inlineSecretsAsViews: true });
6940
7346
  }
6941
7347
  async updateDeviceSettings(deviceId, patch) {
6942
7348
  await this._ctx?.settings?.writeDeviceStore(deviceId, patch);
@@ -7108,7 +7514,7 @@ var BaseAddon = class {
7108
7514
  key,
7109
7515
  schema,
7110
7516
  fallback,
7111
- read: async () => this.resolveStoredSecrets(await this._ctx?.settings?.readDeviceStore(deviceId) ?? {}, false),
7517
+ read: async () => this.resolveStoredSecrets(await this.rawSettings()?.readDeviceStore(deviceId) ?? {}, false),
7112
7518
  write: async (patch) => {
7113
7519
  await this._ctx?.settings?.writeDeviceStore(deviceId, patch);
7114
7520
  },
@@ -7170,6 +7576,23 @@ var BaseAddon = class {
7170
7576
  }
7171
7577
  return value;
7172
7578
  }
7579
+ /**
7580
+ * The marker-bearing settings reads (D798) — private on purpose. Without a
7581
+ * keychain the context's own view is already raw.
7582
+ */
7583
+ rawSettings() {
7584
+ return this._secretSettings?.raw ?? this._ctx?.settings;
7585
+ }
7586
+ /** An addon-facing read met markers it could not resolve: say so once per ref. */
7587
+ logUnresolvedRead(unresolved) {
7588
+ const fresh = unresolved.filter((u) => !this._loggedUnresolvedReads.has(u.ref));
7589
+ if (fresh.length === 0) return;
7590
+ for (const u of fresh) this._loggedUnresolvedReads.add(u.ref);
7591
+ 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) => ({
7592
+ ref: u.ref,
7593
+ reason: u.reason
7594
+ })) } });
7595
+ }
7173
7596
  /** Re-resolve the config (a keychain-only change, or a retry) and apply it. */
7174
7597
  scheduleSecretReresolve(delayMs) {
7175
7598
  const timerOf = delayMs === SECRET_CHANGE_DEBOUNCE_MS ? "_secretChangeTimer" : "_secretRetryTimer";
@@ -7196,7 +7619,7 @@ var BaseAddon = class {
7196
7619
  * `{}` (defaults) — the addon's first successful patch will rehydrate.
7197
7620
  */
7198
7621
  async readAddonStoreWithRetry() {
7199
- const settings = this._ctx?.settings;
7622
+ const settings = this.rawSettings();
7200
7623
  if (!settings) return {};
7201
7624
  const delaysMs = [
7202
7625
  150,
@@ -10809,6 +11232,278 @@ var CameraSwitchGroupSchema = object({
10809
11232
  fetchedAt: number()
10810
11233
  });
10811
11234
  /**
11235
+ * The trainer contract — what the hub hands the cloud trainer and what it
11236
+ * gets back (cloud training, D805+).
11237
+ *
11238
+ * The trainer (`hf/camstack-trainer`, published as the Hugging Face repo
11239
+ * `camstack/camstack-trainer`) is a separate AGPL program the hub never
11240
+ * imports: `job.json` goes in, files come out, and progress is `CAMSTACK_EVENT`
11241
+ * lines on stdout. These schemas are the hub's half of that boundary; the
11242
+ * trainer's pydantic models (and the JSON Schemas generated from them under
11243
+ * `hf/camstack-trainer/schemas/`) are the other half. A change here is a
11244
+ * change there, in the same piece of work.
11245
+ *
11246
+ * No `.default()` anywhere: defaults do not run on the addon cap path, so the
11247
+ * orchestrator fills every field of a job spec explicitly.
11248
+ */
11249
+ var TRAINING_JOB_SCHEMA = "camstack.training/v1";
11250
+ var TRAINING_RESULT_SCHEMA = "camstack.training-result/v1";
11251
+ /** What the trainer can export. Edge TPU is a later, separate image. */
11252
+ var TrainingExportSchema = _enum([
11253
+ "onnx",
11254
+ "openvino-fp16",
11255
+ "openvino-int8",
11256
+ "coreml-fp16"
11257
+ ]);
11258
+ var FloorsSchema = record(string(), number().min(0).max(1));
11259
+ object({
11260
+ schema: literal(TRAINING_JOB_SCHEMA),
11261
+ jobKey: string().uuid(),
11262
+ target: object({
11263
+ kind: literal("detector"),
11264
+ step: literal("object-detection")
11265
+ }),
11266
+ base: object({
11267
+ modelId: string().min(1),
11268
+ /** Ultralytics weights id, e.g. `yolov9m.pt`. */
11269
+ weights: string().min(1),
11270
+ imgsz: number().int().positive()
11271
+ }),
11272
+ baseline: object({
11273
+ modelId: string().min(1),
11274
+ /** The baseline ONNX the holdout comparison runs; public mirror URL. */
11275
+ onnxUrl: string().url(),
11276
+ imgsz: number().int().positive(),
11277
+ floors: FloorsSchema
11278
+ }),
11279
+ dataset: object({
11280
+ versionId: string().min(1),
11281
+ annotationHash: string(),
11282
+ /** sha256 of the uploaded archive; the trainer refuses a mismatch (exit 65). */
11283
+ sha256: string().regex(/^[0-9a-f]{64}$/)
11284
+ }),
11285
+ split: object({
11286
+ holdoutCameras: array(number().int()),
11287
+ /** When no camera is held out: the last N days of every camera. */
11288
+ holdoutLastDays: number().int().nonnegative(),
11289
+ valFraction: number().min(0).max(.5),
11290
+ seed: number().int()
11291
+ }),
11292
+ hyper: object({
11293
+ epochs: number().int().positive(),
11294
+ batch: number().int().positive(),
11295
+ lr0: number().positive(),
11296
+ /** Layers frozen from the start of the backbone; 0 = none. */
11297
+ freeze: number().int().nonnegative(),
11298
+ patience: number().int().nonnegative(),
11299
+ seed: number().int()
11300
+ }),
11301
+ replay: object({
11302
+ source: literal("coco2017"),
11303
+ count: number().int().nonnegative()
11304
+ }),
11305
+ exports: array(TrainingExportSchema).min(1),
11306
+ calibration: object({ maxFrames: number().int().positive() }),
11307
+ floors: object({
11308
+ minSupport: number().int().positive(),
11309
+ clamp: number().min(0).max(1)
11310
+ }),
11311
+ int8Gate: object({ maxMap50Drop: number().min(0).max(1) }),
11312
+ catalog: object({
11313
+ id: string().regex(/^[a-z0-9][a-z0-9-]{2,80}$/),
11314
+ name: string().min(1).max(160)
11315
+ })
11316
+ });
11317
+ /** One regular file of the bundle. An mlpackage contributes one row per member. */
11318
+ var TrainingResultFileSchema = object({
11319
+ path: string().min(1),
11320
+ bytes: number().int().nonnegative(),
11321
+ sha256: string().regex(/^[0-9a-f]{64}$/),
11322
+ format: _enum([
11323
+ "onnx",
11324
+ "openvino",
11325
+ "coreml",
11326
+ "pt"
11327
+ ]),
11328
+ variant: _enum(["base", "int8"])
11329
+ });
11330
+ var DraftFormatSchema = object({
11331
+ /** RELATIVE path inside the bundle; the hub rewrites it to `camstack-local://`. */
11332
+ url: string().min(1),
11333
+ sizeMB: number().nonnegative(),
11334
+ isDirectory: boolean().optional(),
11335
+ files: array(string()).optional(),
11336
+ runtimes: array(literal("python")).optional(),
11337
+ revision: string().min(1)
11338
+ });
11339
+ /** The trainer's half of a catalog entry; the hub completes it (labels, licence, group). */
11340
+ var TrainingCatalogDraftSchema = object({
11341
+ id: string().min(1),
11342
+ name: string().min(1),
11343
+ description: string(),
11344
+ labels: array(unknown()),
11345
+ inputSize: object({
11346
+ width: number().int().positive(),
11347
+ height: number().int().positive()
11348
+ }),
11349
+ preprocessMode: literal("letterbox"),
11350
+ defaultClassFloors: FloorsSchema,
11351
+ formats: object({
11352
+ onnx: DraftFormatSchema.optional(),
11353
+ openvino: DraftFormatSchema.optional(),
11354
+ coreml: DraftFormatSchema.optional()
11355
+ })
11356
+ });
11357
+ /** One class of one model's holdout report (the eval harness's summary). */
11358
+ var TrainingEvalClassSchema = object({
11359
+ positives: number().int(),
11360
+ floor: number().nullable(),
11361
+ tp: number().int(),
11362
+ fp: number().int(),
11363
+ fn: number().int(),
11364
+ precision: number().nullable(),
11365
+ recall: number().nullable(),
11366
+ ap50: number().nullable(),
11367
+ recallByCamera: record(string(), number().nullable()).optional(),
11368
+ recallByLight: record(string(), number().nullable()).optional(),
11369
+ fpByCamera: record(string(), number()).optional(),
11370
+ smallFound: number().int().optional(),
11371
+ smallTotal: number().int().optional()
11372
+ }).passthrough();
11373
+ var TrainingEvalReportSchema = object({
11374
+ frames: number().int(),
11375
+ classes: record(string(), TrainingEvalClassSchema)
11376
+ }).passthrough();
11377
+ /**
11378
+ * A succeeded result carries every block; a failed one carries the error and
11379
+ * whatever was known by then — the other blocks are ABSENT, not null. The
11380
+ * orchestrator checks the blocks it needs before it trusts a success.
11381
+ */
11382
+ var TrainingResultSchema = object({
11383
+ schema: literal(TRAINING_RESULT_SCHEMA),
11384
+ jobKey: string(),
11385
+ status: _enum(["succeeded", "failed"]),
11386
+ error: object({
11387
+ stage: string(),
11388
+ code: string(),
11389
+ message: string()
11390
+ }).nullable(),
11391
+ trainer: object({
11392
+ version: string(),
11393
+ revision: string()
11394
+ }),
11395
+ toolchain: record(string(), string().nullable()),
11396
+ dataset: object({
11397
+ versionId: string(),
11398
+ annotationHash: string(),
11399
+ sha256: string(),
11400
+ frames: object({
11401
+ train: number().int(),
11402
+ val: number().int(),
11403
+ holdout: number().int()
11404
+ }),
11405
+ holdoutCameras: array(number().int()),
11406
+ replayImages: number().int()
11407
+ }).optional(),
11408
+ training: object({
11409
+ epochsRun: number().int(),
11410
+ bestEpoch: number().int(),
11411
+ bestMap50: number(),
11412
+ bestMap50_95: number(),
11413
+ seconds: number()
11414
+ }).optional(),
11415
+ evaluation: object({
11416
+ holdoutFrames: number().int(),
11417
+ baseline: TrainingEvalReportSchema.nullable(),
11418
+ candidate: TrainingEvalReportSchema.nullable(),
11419
+ candidateInt8: TrainingEvalReportSchema.nullable(),
11420
+ recallDeltaByCamera: record(string(), record(string(), number())).nullable(),
11421
+ map50: record(string(), number().nullable())
11422
+ }).optional(),
11423
+ floors: object({
11424
+ baseline: FloorsSchema,
11425
+ candidate: FloorsSchema,
11426
+ candidateInt8: FloorsSchema.nullable(),
11427
+ notes: array(string())
11428
+ }).optional(),
11429
+ int8: object({
11430
+ kept: boolean(),
11431
+ map50Fp16: number().nullable(),
11432
+ map50Int8: number().nullable(),
11433
+ reason: string().nullable()
11434
+ }).optional(),
11435
+ exportsDropped: array(object({
11436
+ export: string(),
11437
+ reason: string()
11438
+ })).optional(),
11439
+ files: array(TrainingResultFileSchema).optional(),
11440
+ bundle: object({
11441
+ path: literal("bundle.tar"),
11442
+ bytes: number().int().nonnegative(),
11443
+ sha256: string().regex(/^[0-9a-f]{64}$/)
11444
+ }).nullable().optional(),
11445
+ catalogDraft: object({
11446
+ base: TrainingCatalogDraftSchema,
11447
+ int8: TrainingCatalogDraftSchema.nullable()
11448
+ }).nullable().optional(),
11449
+ licence: string()
11450
+ });
11451
+ var TrainingStageSchema = _enum([
11452
+ "prepare",
11453
+ "replay",
11454
+ "train",
11455
+ "eval",
11456
+ "export",
11457
+ "package"
11458
+ ]);
11459
+ var EventBase = {
11460
+ v: literal(1),
11461
+ ts: number()
11462
+ };
11463
+ discriminatedUnion("type", [
11464
+ object({
11465
+ ...EventBase,
11466
+ type: literal("stage"),
11467
+ stage: TrainingStageSchema
11468
+ }),
11469
+ object({
11470
+ ...EventBase,
11471
+ type: literal("epoch"),
11472
+ epoch: number().int(),
11473
+ epochs: number().int(),
11474
+ boxLoss: number().nullable().optional(),
11475
+ map50: number().nullable().optional(),
11476
+ map50_95: number().nullable().optional(),
11477
+ etaSec: number().nullable().optional()
11478
+ }),
11479
+ object({
11480
+ ...EventBase,
11481
+ type: literal("metric"),
11482
+ name: string(),
11483
+ value: number()
11484
+ }),
11485
+ object({
11486
+ ...EventBase,
11487
+ type: literal("artifact"),
11488
+ path: string(),
11489
+ bytes: number(),
11490
+ sha256: string()
11491
+ }),
11492
+ object({
11493
+ ...EventBase,
11494
+ type: literal("done"),
11495
+ status: _enum(["succeeded", "failed"]),
11496
+ resultSha256: string().nullable().optional()
11497
+ }),
11498
+ object({
11499
+ ...EventBase,
11500
+ type: literal("error"),
11501
+ stage: string(),
11502
+ code: string(),
11503
+ message: string()
11504
+ })
11505
+ ]);
11506
+ /**
10812
11507
  * What the gate decided about a birth, from the CALLER's point of view.
10813
11508
  *
10814
11509
  * Deliberately not `ConfirmationVerdict`: `undecided` is not a birth decision
@@ -14123,7 +14818,9 @@ var AddonHttpRouteSchema = object({
14123
14818
  "authenticated",
14124
14819
  "admin"
14125
14820
  ]).optional(),
14126
- description: string().optional()
14821
+ description: string().optional(),
14822
+ /** The hub limits this route per client address before the handler runs. */
14823
+ rateLimit: _enum(["auth"]).optional()
14127
14824
  });
14128
14825
  /**
14129
14826
  * Cross-process route invocation envelope. The hub captures the
@@ -14946,6 +15643,37 @@ var BackupDestinationInfoSchema = object({
14946
15643
  lastError: string().optional()
14947
15644
  });
14948
15645
  /**
15646
+ * How an archive is encrypted (operator decision 2026-10-09): to a backup
15647
+ * PUBLIC key the hub holds, so only the operator's secret key opens it.
15648
+ * Absent on a plain `.tar.gz` — every archive made before encryption, or
15649
+ * with it off — which restores without a key.
15650
+ */
15651
+ var BackupArchiveEncryptionSchema = object({
15652
+ /** `x25519-hkdf-aes256gcm-stream-v1`. */
15653
+ scheme: string(),
15654
+ /** 16 hex — the backup key whose secret restores this archive. */
15655
+ keyId: string()
15656
+ });
15657
+ /**
15658
+ * The backup encryption setting. The hub keeps PUBLIC keys only: the active
15659
+ * one new archives are encrypted to, and the retired ones older archives
15660
+ * still need. The secret key is shown once, at `setupEncryption`.
15661
+ */
15662
+ var BackupEncryptionStatusSchema = object({
15663
+ enabled: boolean(),
15664
+ active: object({
15665
+ keyId: string(),
15666
+ publicKey: string(),
15667
+ createdAt: number()
15668
+ }).nullable(),
15669
+ /** Every key ever set up, newest first. */
15670
+ keys: array(object({
15671
+ keyId: string(),
15672
+ createdAt: number(),
15673
+ retiredAt: number().nullable()
15674
+ })).readonly()
15675
+ });
15676
+ /**
14949
15677
  * Per-archive entry returned by `backup.listArchives({ destinationId })`.
14950
15678
  * Same shape the destination drill-in renders. Sourced from the per-
14951
15679
  * location `manifests.json` (no per-archive tarball read required).
@@ -14957,7 +15685,9 @@ var BackupArchiveEntrySchema = object({
14957
15685
  sizeBytes: number(),
14958
15686
  label: string().optional(),
14959
15687
  /** Top-level locations included in the archive (db, addons, tls, …). */
14960
- locations: array(string()).readonly()
15688
+ locations: array(string()).readonly(),
15689
+ /** Present when the archive is encrypted; restore then needs that key. */
15690
+ encryption: BackupArchiveEncryptionSchema.optional()
14961
15691
  });
14962
15692
  var BackupEntrySchema = object({
14963
15693
  id: string(),
@@ -14966,7 +15696,8 @@ var BackupEntrySchema = object({
14966
15696
  label: string().optional(),
14967
15697
  createdAt: number(),
14968
15698
  sizeBytes: number(),
14969
- locations: array(string()).optional()
15699
+ locations: array(string()).optional(),
15700
+ encryption: BackupArchiveEncryptionSchema.optional()
14970
15701
  });
14971
15702
  var ArchiveEntrySchema = object({
14972
15703
  path: string(),
@@ -15155,10 +15886,40 @@ method(_void(), array(BackupDestinationInfoSchema).readonly(), { auth: "admin" }
15155
15886
  * this list and skips entries whose path doesn't start with
15156
15887
  * any of them.
15157
15888
  */
15158
- locations: array(string()).optional()
15889
+ locations: array(string()).optional(),
15890
+ /**
15891
+ * The backup SECRET key, for an encrypted archive (ignored for a plain
15892
+ * one). The archive is decrypted into the hub's private staging
15893
+ * before the restart; the key is not stored. A wrong or missing key
15894
+ * is refused before the archive is downloaded.
15895
+ */
15896
+ backupSecretKey: string().optional()
15159
15897
  }), _void(), {
15160
15898
  kind: "mutation",
15161
15899
  auth: "admin"
15900
+ }), method(_void(), BackupEncryptionStatusSchema, { auth: "admin" }), method(object({}), object({
15901
+ keyId: string(),
15902
+ secretKey: string(),
15903
+ publicKey: string(),
15904
+ createdAt: number(),
15905
+ replacedKeyId: string().nullable()
15906
+ }), {
15907
+ kind: "mutation",
15908
+ auth: "admin"
15909
+ }), method(object({}), object({ disabledKeyId: string().nullable() }), {
15910
+ kind: "mutation",
15911
+ auth: "admin"
15912
+ }), method(object({ backupSecretKey: string() }), object({
15913
+ valid: boolean(),
15914
+ keyId: string().nullable(),
15915
+ /** The hub knows this key (active or retired). */
15916
+ known: boolean(),
15917
+ /** It is the key new archives are encrypted to. */
15918
+ active: boolean(),
15919
+ error: string().optional()
15920
+ }), {
15921
+ kind: "mutation",
15922
+ auth: "admin"
15162
15923
  }), method(object({
15163
15924
  destinationId: string(),
15164
15925
  backupId: string()
@@ -17114,7 +17875,60 @@ var CustomModelDescriptorSchema = object({
17114
17875
  stepId: string(),
17115
17876
  entry: ModelCatalogEntrySchema
17116
17877
  });
17117
- method(_void(), array(CustomModelDescriptorSchema).readonly(), { auth: "admin" });
17878
+ /** One regular file of an imported bundle, as the producer measured it. */
17879
+ var ModelBundleFileSchema = object({
17880
+ /** Relative path inside the bundle tar; an mlpackage member is `<x>.mlpackage/<member>`. */
17881
+ path: string().min(1),
17882
+ bytes: number().int().nonnegative(),
17883
+ sha256: string().regex(/^[0-9a-f]{64}$/)
17884
+ });
17885
+ var ImportModelBundleInputSchema = object({
17886
+ /** The registry provider that keeps the model (Model Studio). */
17887
+ addonId: string(),
17888
+ stepId: string().min(1),
17889
+ /**
17890
+ * The catalog rows to register, complete, every format URL already
17891
+ * `camstack-local://<modelId>/<file>` naming a file of the bundle. One
17892
+ * bundle may carry several rows (a base and its INT8 variant).
17893
+ */
17894
+ entries: array(ModelCatalogEntrySchema).min(1).max(4),
17895
+ /** The bundle tar, offered by the producer over `ctx.peerBytes` (same host). */
17896
+ bundle: object({
17897
+ ticket: PeerBytesTicketSchema,
17898
+ bytes: number().int().positive(),
17899
+ sha256: string().regex(/^[0-9a-f]{64}$/)
17900
+ }),
17901
+ /** Every file the tar must hold; anything missing, extra or different is refused. */
17902
+ files: array(ModelBundleFileSchema).min(1).max(64),
17903
+ /** Convert missing engine formats and push the model to every agent afterwards. */
17904
+ distribute: boolean()
17905
+ });
17906
+ var ImportModelBundleResultSchema = discriminatedUnion("kind", [object({
17907
+ kind: literal("imported"),
17908
+ modelIds: array(string()).readonly(),
17909
+ distributed: array(object({
17910
+ modelId: string(),
17911
+ nodeId: string(),
17912
+ format: _enum(MODEL_FORMATS),
17913
+ ok: boolean(),
17914
+ error: string().optional()
17915
+ })).readonly()
17916
+ }), object({
17917
+ kind: literal("refused"),
17918
+ reason: _enum([
17919
+ "transfer-failed",
17920
+ "checksum-mismatch",
17921
+ "bundle-mismatch",
17922
+ "invalid-entry",
17923
+ "id-taken"
17924
+ ]),
17925
+ detail: string()
17926
+ })]);
17927
+ method(_void(), array(CustomModelDescriptorSchema).readonly(), { auth: "admin" }), method(ImportModelBundleInputSchema, ImportModelBundleResultSchema, {
17928
+ kind: "mutation",
17929
+ auth: "admin",
17930
+ timeoutMs: 30 * 6e4
17931
+ });
17118
17932
  /**
17119
17933
  * Query filter for settings-store collections.
17120
17934
  */
@@ -17593,6 +18407,35 @@ var KeychainKeySourceSchema = object({
17593
18407
  */
17594
18408
  sharesBackupWithDatabase: boolean()
17595
18409
  });
18410
+ /**
18411
+ * One keychain reset, as the Secrets page reports it until the operator
18412
+ * acknowledges it. Never a value: refs, counts and table names only.
18413
+ */
18414
+ var KeychainResetRecordSchema = object({
18415
+ id: string(),
18416
+ at: number(),
18417
+ /** `user:<id>` or {@link KEYCHAIN_RESET_TRIGGER_ACTOR}. */
18418
+ actor: string(),
18419
+ /** Why the keychain was locked when it was reset; `null` when it was not locked. */
18420
+ lockedReason: string().nullable(),
18421
+ /** Values moved into the archive table (ciphertext under the lost key). */
18422
+ archived: number().int(),
18423
+ /** `keychain:secrets-orphaned-<ts>`, or `null` when nothing was stored. */
18424
+ archivedCollection: string().nullable(),
18425
+ /**
18426
+ * `keychain:keys-orphaned-<ts>`: the wrapped data keys of the archive, kept
18427
+ * so the archive can still be opened if the lost master key turns up.
18428
+ */
18429
+ archivedKeysCollection: string().nullable(),
18430
+ /**
18431
+ * `system-settings` keys whose marker the reset cleared — the cluster
18432
+ * secret's: a marker left pointing at an archived value would refuse every
18433
+ * agent forever (D797).
18434
+ */
18435
+ clearedSettingsKeys: array(string()).readonly(),
18436
+ /** When an operator dismissed the notice on the Secrets page; `null` until then. */
18437
+ acknowledgedAt: number().nullable()
18438
+ });
17596
18439
  var KeychainStatusSchema = object({
17597
18440
  keychain: KeychainStateSchema,
17598
18441
  /** The source of the master key in use; `null` while locked. */
@@ -17610,7 +18453,9 @@ var KeychainStatusSchema = object({
17610
18453
  /** Wrapped copies of the data key under a previous master key, kept until purged. */
17611
18454
  retiredWraps: number().int(),
17612
18455
  recoveryKeyDownloadedAt: number().nullable(),
17613
- secretCount: number().int()
18456
+ secretCount: number().int(),
18457
+ /** The most recent reset, acknowledged or not; `null` when the keychain was never reset. */
18458
+ lastReset: KeychainResetRecordSchema.nullable()
17614
18459
  });
17615
18460
  /**
17616
18461
  * Whether a stored value is still pointed at by its owner's settings.
@@ -17632,17 +18477,26 @@ var KeychainAuditActionSchema = _enum([
17632
18477
  "download-recovery-key",
17633
18478
  "delete-orphans",
17634
18479
  "reset",
18480
+ "acknowledge-reset",
17635
18481
  "initialize"
17636
18482
  ]);
17637
18483
  var KeychainAuditEntrySchema = object({
17638
18484
  id: string(),
17639
18485
  at: number(),
17640
18486
  action: KeychainAuditActionSchema,
17641
- /** `addon:<id>` | `user:<id>` | `system`. */
18487
+ /** `addon:<id>` | `user:<id>` | `system` | `trigger-file`. */
17642
18488
  actor: string(),
17643
18489
  ref: string().nullable(),
17644
18490
  detail: string().nullable()
17645
18491
  });
18492
+ var KEYCHAIN_RESET_CONFIRMATION = "RESET KEYCHAIN";
18493
+ /**
18494
+ * Secrets the HUB itself holds (owner `system`) that no settings form shows:
18495
+ * `jwt-signing-key` — the session signing key (D797). It is always "in use",
18496
+ * never an orphan; it is generated on a fresh hub and replaced only through
18497
+ * {@link keychainAdminCapability.methods.setSystemSecret}.
18498
+ */
18499
+ var SystemHeldSecretNameSchema = _enum(["jwt-signing-key"]);
17646
18500
  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({
17647
18501
  value: string(),
17648
18502
  version: number().int()
@@ -17650,6 +18504,16 @@ method(object({}), KeychainStatusSchema, { auth: "admin" }), method(object({}),
17650
18504
  kind: "mutation",
17651
18505
  auth: "admin",
17652
18506
  caller: "required"
18507
+ }), method(object({
18508
+ name: SystemHeldSecretNameSchema,
18509
+ value: string().min(16)
18510
+ }), object({
18511
+ ref: string(),
18512
+ version: number().int()
18513
+ }), {
18514
+ kind: "mutation",
18515
+ auth: "admin",
18516
+ caller: "required"
17653
18517
  }), method(object({ refs: array(string().min(1)).max(1e3) }), object({
17654
18518
  deleted: array(string()).readonly(),
17655
18519
  kept: array(object({
@@ -17679,13 +18543,20 @@ method(object({}), KeychainStatusSchema, { auth: "admin" }), method(object({}),
17679
18543
  kind: "mutation",
17680
18544
  auth: "admin",
17681
18545
  caller: "required"
17682
- }), method(object({ confirm: literal("RESET KEYCHAIN") }), object({
18546
+ }), method(object({ confirm: literal(KEYCHAIN_RESET_CONFIRMATION) }), object({
17683
18547
  archivedCollection: string().nullable(),
17684
18548
  archived: number().int()
17685
18549
  }), {
17686
18550
  kind: "mutation",
17687
18551
  auth: "admin",
17688
18552
  caller: "required"
18553
+ }), method(object({}), object({
18554
+ reset: KeychainResetRecordSchema.nullable(),
18555
+ pendingReentry: array(KeychainSecretMetaSchema).readonly()
18556
+ }), { auth: "admin" }), method(object({}), object({ acknowledged: boolean() }), {
18557
+ kind: "mutation",
18558
+ auth: "admin",
18559
+ caller: "required"
17689
18560
  });
17690
18561
  method(_void(), object({
17691
18562
  id: string(),
@@ -20416,7 +21287,7 @@ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
20416
21287
  * `login-method` — collection cap through which auth addons contribute
20417
21288
  * their pre-auth login surfaces to the login page. This is the SINGLE,
20418
21289
  * generic mechanism that supersedes the dead `auth.listProviders` reader:
20419
- * every auth addon (OIDC, magic-link, WebAuthn/passkey) registers a
21290
+ * every auth addon (OIDC, WebAuthn/passkey) registers a
20420
21291
  * `login-method` provider and the PUBLIC `auth.listLoginMethods`
20421
21292
  * procedure aggregates them for the unauthenticated login page.
20422
21293
  *
@@ -20424,8 +21295,7 @@ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
20424
21295
  *
20425
21296
  * - `redirect` — a declarative button. The login page renders a generic
20426
21297
  * button that navigates to `startUrl` (an addon-owned HTTP route).
20427
- * Covers OIDC (`/addon/auth-oidc/<id>/start`) and magic-link with
20428
- * ZERO shell-side JS. A future SSO addon plugs in the same way — the
21298
+ * Covers OIDC (`/addon/auth-oidc/<id>/start`) with ZERO shell-side JS. A future SSO addon plugs in the same way — the
20429
21299
  * login page needs NO change.
20430
21300
  *
20431
21301
  * - `widget` — a Module-Federation widget the login page mounts (via
@@ -20444,8 +21314,8 @@ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
20444
21314
  * decision.
20445
21315
  *
20446
21316
  * Every contribution carries a `stage`:
20447
- * - `primary` — shown on the first credentials screen (OIDC /
20448
- * magic-link buttons; a future usernameless passkey).
21317
+ * - `primary` — shown on the first credentials screen (OIDC
21318
+ * buttons; a usernameless passkey).
20449
21319
  * - `second-factor` — shown AFTER the password leg, gated on the
20450
21320
  * returned `factors` (passkey-as-2FA today).
20451
21321
  *
@@ -20472,7 +21342,7 @@ var LoginMethodContributionSchema = discriminatedUnion("kind", [
20472
21342
  * The provider names an external identity a signed-in user can link to
20473
21343
  * their own account (D782): `auth.listLinkableProviders` /
20474
21344
  * `beginExternalLink` offer exactly the redirect methods that set this,
20475
- * whatever their id. Absent / false — a login button only (magic-link).
21345
+ * whatever their id. Absent / false — a login button only.
20476
21346
  */
20477
21347
  linkable: boolean().optional()
20478
21348
  }),
@@ -24632,8 +25502,7 @@ method(object({}), object({ rules: array(NcRuleSchema) }), { auth: "admin" }), m
24632
25502
  * `super_admin` — collapsed onto the single boolean because every
24633
25503
  * non-admin caller is governed by the same scope-check rules; the
24634
25504
  * distinction was only ever used to route role-specific procedures
24635
- * which we no longer have. Agents are admin sessions issued via
24636
- * `createServiceToken`; CLI / webhook integrations are `cst_*` tokens
25505
+ * which we no longer have. CLI / webhook integrations are `cst_*` tokens
24637
25506
  * with `isAdmin: false` + an explicit scope list.
24638
25507
  */
24639
25508
  /** Per-method access flavour. Materialised on every cap method via codegen. */
@@ -26355,6 +27224,9 @@ var RetrainExportFilterSchema = object({
26355
27224
  frameIds: array(string()).max(2e4).optional(),
26356
27225
  /** Only frames in at least one of these named collections. */
26357
27226
  collectionIds: array(string()).max(200).optional(),
27227
+ /** Exactly the frames of this dataset version (and its completeOnly). An
27228
+ * unknown id selects nothing. */
27229
+ datasetVersionId: string().optional(),
26358
27230
  batchId: string().optional(),
26359
27231
  /** Only frames the operator marked complete (all subjects boxed). */
26360
27232
  completeOnly: boolean().optional()
@@ -26522,6 +27394,67 @@ var RetrainLlmAssistResultSchema = discriminatedUnion("kind", [object({
26522
27394
  ]),
26523
27395
  detail: string().optional()
26524
27396
  })]);
27397
+ /** What a dataset version is cut from. Every field narrows. */
27398
+ var RetrainDatasetSelectionSchema = object({
27399
+ deviceIds: array(number()).readonly().optional(),
27400
+ collectionIds: array(string()).max(200).readonly().optional(),
27401
+ frameIds: array(string()).max(2e4).readonly().optional()
27402
+ });
27403
+ /** The counts a dataset is judged by. */
27404
+ var RetrainDatasetStatsSchema = object({
27405
+ frames: number().int(),
27406
+ completeFrames: number().int(),
27407
+ /** `completeFrames / frames`, 0..1. */
27408
+ completeness: number(),
27409
+ /** Boxes to learn (model errors excluded). */
27410
+ subjects: number().int(),
27411
+ modelErrors: number().int(),
27412
+ /** Complete frames with no subject. */
27413
+ hardNegatives: number().int(),
27414
+ /** Subjects per class × camera × day/night. */
27415
+ cells: array(object({
27416
+ macroClass: string(),
27417
+ deviceId: number(),
27418
+ lighting: _enum([
27419
+ "day",
27420
+ "night",
27421
+ "unknown"
27422
+ ]),
27423
+ subjects: number().int(),
27424
+ frames: number().int()
27425
+ })).readonly(),
27426
+ cameras: array(object({
27427
+ deviceId: number(),
27428
+ frames: number().int(),
27429
+ completeFrames: number().int()
27430
+ })).readonly()
27431
+ });
27432
+ /** An immutable dataset version, without its frame list. */
27433
+ var RetrainDatasetVersionSchema = object({
27434
+ id: string(),
27435
+ name: string(),
27436
+ createdAt: number(),
27437
+ selection: RetrainDatasetSelectionSchema,
27438
+ layout: RetrainExportLayoutSchema,
27439
+ completeOnly: boolean(),
27440
+ frameCount: number().int(),
27441
+ /** sha256 of what the frames taught when the version was frozen. */
27442
+ annotationHash: string(),
27443
+ /** The export manifest schema the version was cut under. */
27444
+ manifestSchema: string(),
27445
+ stats: RetrainDatasetStatsSchema
27446
+ });
27447
+ var CreateRetrainDatasetVersionResultSchema = discriminatedUnion("kind", [object({
27448
+ kind: literal("created"),
27449
+ version: RetrainDatasetVersionSchema
27450
+ }), object({
27451
+ kind: literal("refused"),
27452
+ reason: _enum([
27453
+ "empty-name",
27454
+ "duplicate-name",
27455
+ "no-frames"
27456
+ ])
27457
+ })]);
26525
27458
  /** The outcome of a lifecycle move owned by the retrain page. */
26526
27459
  var RetrainTransitionResultSchema = object({
26527
27460
  trackId: string(),
@@ -27311,6 +28244,47 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
27311
28244
  kind: "mutation",
27312
28245
  auth: "admin",
27313
28246
  timeoutMs: 60 * 6e4
28247
+ }), method(object({
28248
+ filter: RetrainExportFilterSchema,
28249
+ layout: RetrainExportLayoutSchema
28250
+ }), object({
28251
+ ticket: PeerBytesTicketSchema,
28252
+ frames: number().int(),
28253
+ annotations: number().int()
28254
+ }), {
28255
+ kind: "mutation",
28256
+ auth: "admin",
28257
+ timeoutMs: 12e4
28258
+ }), method(object({
28259
+ selection: RetrainDatasetSelectionSchema,
28260
+ completeOnly: boolean().optional()
28261
+ }), RetrainDatasetStatsSchema, {
28262
+ kind: "query",
28263
+ auth: "admin"
28264
+ }), method(object({
28265
+ name: string().max(120),
28266
+ selection: RetrainDatasetSelectionSchema,
28267
+ layout: RetrainExportLayoutSchema,
28268
+ completeOnly: boolean()
28269
+ }), CreateRetrainDatasetVersionResultSchema, {
28270
+ kind: "mutation",
28271
+ auth: "admin",
28272
+ timeoutMs: 12e4
28273
+ }), method(object({}), array(RetrainDatasetVersionSchema).readonly(), {
28274
+ kind: "query",
28275
+ auth: "admin"
28276
+ }), method(object({ id: string() }), object({ deleted: boolean() }), {
28277
+ kind: "mutation",
28278
+ auth: "admin"
28279
+ }), method(object({ id: string() }), object({
28280
+ found: boolean(),
28281
+ annotationHash: string(),
28282
+ matches: boolean(),
28283
+ missingFrames: number().int()
28284
+ }), {
28285
+ kind: "query",
28286
+ auth: "admin",
28287
+ timeoutMs: 12e4
27314
28288
  }), method(object({}), array(RetrainAssistProfileSchema).readonly(), {
27315
28289
  kind: "query",
27316
28290
  auth: "admin"
@@ -31257,8 +32231,8 @@ version: string().optional() }), ServerUpdateActionResultSchema, {
31257
32231
  * `smtp-provider` — pluggable email delivery surface.
31258
32232
  *
31259
32233
  * Collection cap: a deployment may install multiple SMTP relays (e.g.
31260
- * one for transactional / one for notifications). Consumers (magic-link,
31261
- * notifier addons, …) walk the collection and pick the first
32234
+ * one for transactional / one for notifications). Consumers (notifier
32235
+ * addons, …) walk the collection and pick the first
31262
32236
  * ready provider OR target a specific addonId.
31263
32237
  *
31264
32238
  * The shape stays small on purpose — `sendEmail` is enough for the
@@ -31437,7 +32411,7 @@ targets: array(object({
31437
32411
  })));
31438
32412
  /**
31439
32413
  * `sso-bridge` — internal hub-only cap that lets SSO-style auth
31440
- * providers (OIDC, SAML, magic-link, …) mint an HMAC-signed token
32414
+ * providers (OIDC, SAML, …) mint an HMAC-signed token
31441
32415
  * carrying the post-callback claims before redirecting back to
31442
32416
  * `/api/auth/sso/finish`.
31443
32417
  *
@@ -31500,7 +32474,14 @@ var SsoBridgeClaimsSchema = object({
31500
32474
  * Verified `iss` of the id_token behind an OIDC login bridge (D782). A
31501
32475
  * subject is unique only per issuer, so a link is bound to it.
31502
32476
  */
31503
- issuer: string().optional()
32477
+ issuer: string().optional(),
32478
+ /**
32479
+ * SHA-256 (hex) of the `camstack_sso_state` cookie the IdP `/start` set in
32480
+ * the browser that began this sign-in. `/api/auth/sso/finish` requires the
32481
+ * request to present the matching cookie — a login bridge is useless in
32482
+ * any other browser.
32483
+ */
32484
+ browserBinding: string().optional()
31504
32485
  });
31505
32486
  method(object({
31506
32487
  claims: SsoBridgeClaimsSchema,
@@ -42436,16 +43417,6 @@ var ApiKeySummarySchema = object({
42436
43417
  createdAt: number(),
42437
43418
  lastUsedAt: number().optional()
42438
43419
  });
42439
- var CreateApiKeyInputSchema = object({
42440
- label: string(),
42441
- isAdmin: boolean().default(false),
42442
- allowedProviders: union([array(string()), literal("*")]).optional(),
42443
- allowedDevices: record(string(), union([array(string()), literal("*")])).optional()
42444
- });
42445
- var CreateApiKeyResultSchema = object({
42446
- token: string(),
42447
- record: ApiKeySummarySchema
42448
- });
42449
43420
  var ScopedTokenSummarySchema = object({
42450
43421
  id: string(),
42451
43422
  userId: string(),
@@ -42544,17 +43515,10 @@ method(_void(), array(UserSummarySchema), { auth: "admin" }), method(CreateUserI
42544
43515
  }), UserSummarySchema.extend({ passwordHash: string() }).nullable(), {
42545
43516
  kind: "mutation",
42546
43517
  access: "view"
42547
- }), method(_void(), array(ApiKeySummarySchema), { auth: "admin" }), method(CreateApiKeyInputSchema, CreateApiKeyResultSchema, {
42548
- kind: "mutation",
42549
- auth: "admin",
42550
- access: "create"
42551
- }), method(object({ id: string() }), object({ success: literal(true) }), {
43518
+ }), method(_void(), array(ApiKeySummarySchema), { auth: "admin" }), method(object({ id: string() }), object({ success: literal(true) }), {
42552
43519
  kind: "mutation",
42553
43520
  auth: "admin",
42554
43521
  access: "delete"
42555
- }), method(object({ token: string() }), ApiKeySummarySchema.nullable(), {
42556
- kind: "mutation",
42557
- access: "view"
42558
43522
  }), method(CreateScopedTokenInputSchema, CreateScopedTokenResultSchema, {
42559
43523
  kind: "mutation",
42560
43524
  auth: "admin",
@@ -42628,15 +43592,7 @@ method(_void(), array(UserSummarySchema), { auth: "admin" }), method(CreateUserI
42628
43592
  }).nullable(), { access: "view" }), method(object({ userId: string() }), array(ExternalIdentitySchema), { auth: "admin" }), method(ExternalIdentityKeySchema, object({
42629
43593
  userId: string(),
42630
43594
  issuer: string()
42631
- }).nullable(), { auth: "admin" }), method(ExternalIdentityKeySchema.extend({
42632
- userId: string(),
42633
- issuer: string().min(1),
42634
- label: string().optional()
42635
- }), object({ success: literal(true) }), {
42636
- kind: "mutation",
42637
- auth: "admin",
42638
- access: "create"
42639
- }), method(ExternalIdentityKeySchema.extend({ userId: string() }), object({ success: boolean() }), {
43595
+ }).nullable(), { auth: "admin" }), method(ExternalIdentityKeySchema.extend({ userId: string() }), object({ success: boolean() }), {
42640
43596
  kind: "mutation",
42641
43597
  auth: "admin",
42642
43598
  access: "delete"
@@ -43031,6 +43987,451 @@ DeviceType.Camera, method(object({
43031
43987
  detection: array(ZoneRuleSchema).readonly(),
43032
43988
  package: array(ZoneRuleSchema).readonly()
43033
43989
  });
43990
+ /**
43991
+ * `training-provider` — ONE cloud that can run the CamStack trainer.
43992
+ *
43993
+ * A thin, mockable translation layer: it knows how to run a container with a
43994
+ * GPU, move a dataset in, read the job's stdout and hand artefacts back. It
43995
+ * knows nothing about datasets, splits, floors, cost policy or Model Studio —
43996
+ * those are the `training` orchestrator's (D805). Every rule written there
43997
+ * once is what makes a second provider (RunPod, a local NVIDIA node) a new
43998
+ * manifest entry and nothing else.
43999
+ *
44000
+ * Collection, routed by the `addonId` in every single-row input (the `llm` /
44001
+ * `notification-output` posture); `describe` concat-fans across providers.
44002
+ * Every method is `admin`: these spend money.
44003
+ *
44004
+ * Every cloud object a provider creates is tagged with the orchestrator's
44005
+ * `jobKey`, so a retried submit finds the job it already started instead of
44006
+ * starting a second GPU, and `listJobs` can find orphans.
44007
+ *
44008
+ * Bytes never ride a cap field: the dataset arrives as a `ctx.peerBytes`
44009
+ * ticket the producer (pipeline-analytics) minted, and artefacts leave as a
44010
+ * ticket the provider mints (D613).
44011
+ */
44012
+ var TrainingGpuOptionSchema = object({
44013
+ id: string(),
44014
+ label: string(),
44015
+ /** List price, USD per GPU-hour, before any region multiplier. */
44016
+ usdPerHour: number().nonnegative(),
44017
+ vramGb: number().nonnegative()
44018
+ });
44019
+ var TrainingRegionOptionSchema = object({
44020
+ /** `''` = any region (the provider's choice). */
44021
+ id: string(),
44022
+ label: string(),
44023
+ priceMultiplier: number().positive()
44024
+ });
44025
+ /**
44026
+ * The provider's per-account settings, as the orchestrator reads them. They
44027
+ * live in the PROVIDER addon's settings (operator decision 2026-10-08: they
44028
+ * depend on the user's account), never hard-coded in the orchestrator.
44029
+ */
44030
+ var TrainingProviderDefaultsSchema = object({
44031
+ gpuType: string(),
44032
+ region: string(),
44033
+ costCapUsd: number().nonnegative(),
44034
+ maxRuntimeSec: number().int().positive(),
44035
+ /** Hours a FAILED job's cloud dataset is kept for debugging; 0 = delete at once. */
44036
+ failedDatasetGraceHours: number().nonnegative()
44037
+ });
44038
+ var TrainingProviderDescriptorSchema = object({
44039
+ addonId: string(),
44040
+ /** `modal`, `runpod`, `fake`, … */
44041
+ kind: string(),
44042
+ label: string(),
44043
+ gpuTypes: array(TrainingGpuOptionSchema).readonly(),
44044
+ regions: array(TrainingRegionOptionSchema).readonly(),
44045
+ maxDatasetBytes: number().int().positive(),
44046
+ maxRuntimeSec: number().int().positive(),
44047
+ freeTierNote: string().optional(),
44048
+ /** Where the data goes, in one sentence the confirm dialog repeats. */
44049
+ dataResidencyNote: string(),
44050
+ /** Credentials are present — never the values. */
44051
+ configured: boolean(),
44052
+ defaults: TrainingProviderDefaultsSchema
44053
+ });
44054
+ var TrainingCredentialCheckSchema = object({
44055
+ ok: boolean(),
44056
+ /** Workspace / account name, when the provider says. */
44057
+ account: string().optional(),
44058
+ reason: _enum([
44059
+ "missing",
44060
+ "invalid",
44061
+ "forbidden",
44062
+ "network",
44063
+ "quota"
44064
+ ]).optional(),
44065
+ detail: string().optional()
44066
+ });
44067
+ var ProviderJobStateSchema = _enum([
44068
+ "pending",
44069
+ "starting",
44070
+ "running",
44071
+ "succeeded",
44072
+ "failed",
44073
+ "cancelled",
44074
+ "lost"
44075
+ ]);
44076
+ var ProviderJobStatusSchema = object({
44077
+ jobKey: string(),
44078
+ providerJobId: string().optional(),
44079
+ state: ProviderJobStateSchema,
44080
+ startedAt: number().optional(),
44081
+ endedAt: number().optional(),
44082
+ exitCode: number().int().optional(),
44083
+ failureReason: string().optional(),
44084
+ gpuType: string(),
44085
+ region: string().optional(),
44086
+ billedSeconds: number().nonnegative(),
44087
+ costUsd: number().nonnegative(),
44088
+ /** True when `costUsd` is runtime × list price, not a billing answer. */
44089
+ costIsEstimate: boolean(),
44090
+ lastFetchedAt: number()
44091
+ });
44092
+ /**
44093
+ * The trainer the job runs, by SOURCE revision: the provider turns it into an
44094
+ * image its own way (Modal builds the published Dockerfile at that revision;
44095
+ * a registry-pull provider maps it to a tag). Recorded on the job and echoed
44096
+ * in `result.json`.
44097
+ */
44098
+ var TrainerSourceRefSchema = object({
44099
+ /** Hugging Face repo id, e.g. `camstack/camstack-trainer`. */
44100
+ repo: string().min(1),
44101
+ /** A commit sha (never a branch) — the job must be reproducible. */
44102
+ revision: string().regex(/^[0-9a-f]{7,64}$/)
44103
+ });
44104
+ var JobRef = {
44105
+ addonId: string(),
44106
+ jobKey: string().uuid()
44107
+ };
44108
+ var TrainingLogLineSchema = object({
44109
+ ts: number(),
44110
+ text: string()
44111
+ });
44112
+ method(object({}), array(TrainingProviderDescriptorSchema).readonly(), { auth: "admin" }), method(object({ addonId: string() }), TrainingCredentialCheckSchema, {
44113
+ kind: "mutation",
44114
+ auth: "admin",
44115
+ timeoutMs: 3e4
44116
+ }), method(object({
44117
+ addonId: string(),
44118
+ gpuType: string(),
44119
+ region: string(),
44120
+ datasetBytes: number().int().nonnegative(),
44121
+ gpuSecondsLow: number().nonnegative(),
44122
+ gpuSecondsHigh: number().nonnegative()
44123
+ }), object({
44124
+ usdLow: number().nonnegative(),
44125
+ usdHigh: number().nonnegative(),
44126
+ notes: array(string()).readonly()
44127
+ }), { auth: "admin" }), method(object({
44128
+ ...JobRef,
44129
+ ticket: PeerBytesTicketSchema
44130
+ }), object({
44131
+ bytes: number().int().nonnegative(),
44132
+ sha256: string()
44133
+ }), {
44134
+ kind: "mutation",
44135
+ auth: "admin",
44136
+ timeoutMs: 120 * 6e4
44137
+ }), method(object({
44138
+ ...JobRef,
44139
+ trainer: TrainerSourceRefSchema,
44140
+ jobSpecJson: string().min(2).max(64e3),
44141
+ gpuType: string(),
44142
+ region: string(),
44143
+ maxRuntimeSec: number().int().positive()
44144
+ }), ProviderJobStatusSchema, {
44145
+ kind: "mutation",
44146
+ auth: "admin",
44147
+ timeoutMs: 30 * 6e4
44148
+ }), method(object(JobRef), ProviderJobStatusSchema, {
44149
+ auth: "admin",
44150
+ timeoutMs: 6e4
44151
+ }), method(object({
44152
+ ...JobRef,
44153
+ cursor: string().optional(),
44154
+ max: number().int().min(1).max(500)
44155
+ }), object({
44156
+ lines: array(TrainingLogLineSchema).readonly(),
44157
+ cursor: string()
44158
+ }), {
44159
+ auth: "admin",
44160
+ timeoutMs: 6e4
44161
+ }), method(object(JobRef), object({ ok: literal(true) }), {
44162
+ kind: "mutation",
44163
+ auth: "admin",
44164
+ timeoutMs: 6e4
44165
+ }), method(object(JobRef), object({
44166
+ found: boolean(),
44167
+ text: string().optional()
44168
+ }), {
44169
+ kind: "mutation",
44170
+ auth: "admin",
44171
+ timeoutMs: 5 * 6e4
44172
+ }), method(object({
44173
+ ...JobRef,
44174
+ path: _enum(["bundle.tar"])
44175
+ }), object({ ticket: PeerBytesTicketSchema }), {
44176
+ kind: "mutation",
44177
+ auth: "admin",
44178
+ timeoutMs: 5 * 6e4
44179
+ }), method(object(JobRef), object({ deleted: array(string()).readonly() }), {
44180
+ kind: "mutation",
44181
+ auth: "admin",
44182
+ timeoutMs: 5 * 6e4
44183
+ }), method(object({ addonId: string() }), array(ProviderJobStatusSchema).readonly(), {
44184
+ auth: "admin",
44185
+ timeoutMs: 2 * 6e4
44186
+ });
44187
+ /**
44188
+ * `training` — the cloud-training orchestrator (D805). Hub-only singleton,
44189
+ * provided by `addon-training`.
44190
+ *
44191
+ * It owns what every provider must agree on, written once:
44192
+ *
44193
+ * - **Dataset versions.** Taken over from pipeline-analytics (D796): the rows
44194
+ * live here (D808); pipeline-analytics still CUTS a version (it owns the corpus and
44195
+ * the export plan) and reaches this store through the five row methods
44196
+ * below, so the Retrain page and the export did not change.
44197
+ * - **Jobs.** A persisted state machine, a reconcile loop against the
44198
+ * provider, a cost guard, a daily orphan sweep and the retention rules.
44199
+ * - **The return flow.** Verified artefacts → Model Studio
44200
+ * (`custom-model-registry.importModelBundle`) → canary on cameras →
44201
+ * rollback. Nothing is ever registered automatically.
44202
+ *
44203
+ * Every method is `admin`.
44204
+ */
44205
+ /** A version WITH its frame list — what the export and a job read. */
44206
+ var TrainingDatasetVersionRowSchema = RetrainDatasetVersionSchema.omit({ frameCount: true }).extend({ frameIds: array(string()).max(2e4).readonly() });
44207
+ /** A base model a detector job can fine-tune, and the baseline it is judged against. */
44208
+ var TrainingBaseModelSchema = object({
44209
+ modelId: string(),
44210
+ label: string(),
44211
+ weights: string(),
44212
+ imgsz: number().int(),
44213
+ baselineOnnxUrl: string(),
44214
+ baselineFloors: record(string(), number()),
44215
+ /** The base the fleet runs most — the UI's default. */
44216
+ recommended: boolean()
44217
+ });
44218
+ var TrainingPresetSchema = _enum([
44219
+ "quick",
44220
+ "standard",
44221
+ "thorough"
44222
+ ]);
44223
+ var TrainingJobRequestSchema = object({
44224
+ datasetVersionId: string().min(1),
44225
+ /** The `training-provider` addon that runs it. */
44226
+ addonId: string().min(1),
44227
+ gpuType: string().min(1),
44228
+ region: string(),
44229
+ baseModelId: string().min(1),
44230
+ preset: TrainingPresetSchema,
44231
+ /** Freeze the backbone's first N layers; `null` = the preset's choice. */
44232
+ freeze: number().int().nonnegative().nullable(),
44233
+ /** Cameras held out whole for evaluation; `null` = the orchestrator's default. */
44234
+ holdoutCameras: array(number().int()).nullable()
44235
+ });
44236
+ var TrainingSplitPlanSchema = object({
44237
+ holdoutCameras: array(number().int()).readonly(),
44238
+ /** Used when no camera is held out: the last N days of every camera. */
44239
+ holdoutLastDays: number().int().nonnegative(),
44240
+ /** Holdout subjects per class (camera holdout only; `null` = known only after the split). */
44241
+ holdoutSupport: record(string(), number().int()).nullable(),
44242
+ trainSubjects: number().int()
44243
+ });
44244
+ var TrainingRefusalReasonSchema = _enum([
44245
+ "unknown-dataset",
44246
+ "unknown-provider",
44247
+ "provider-not-configured",
44248
+ "unknown-base-model",
44249
+ "unknown-gpu",
44250
+ "dataset-too-large",
44251
+ "no-training-subjects",
44252
+ "job-already-running"
44253
+ ]);
44254
+ var TrainingJobPlanSchema = object({
44255
+ refusal: object({
44256
+ reason: TrainingRefusalReasonSchema,
44257
+ detail: string()
44258
+ }).nullable(),
44259
+ warnings: array(string()).readonly(),
44260
+ split: TrainingSplitPlanSchema.nullable(),
44261
+ estimate: object({
44262
+ datasetBytes: number().int(),
44263
+ uploadMinutesAt20Mbps: number(),
44264
+ gpuSecondsLow: number(),
44265
+ gpuSecondsHigh: number(),
44266
+ usdLow: number(),
44267
+ usdHigh: number(),
44268
+ notes: array(string()).readonly()
44269
+ }).nullable(),
44270
+ /** Pre-filled from the provider's settings; the operator may lower or raise them. */
44271
+ defaults: object({
44272
+ maxCostUsd: number(),
44273
+ maxRuntimeSec: number().int()
44274
+ }).nullable(),
44275
+ /** The sentence the confirm dialog repeats: where the frames go and when they are deleted. */
44276
+ dataNotice: string()
44277
+ });
44278
+ /**
44279
+ * Orchestrator-owned states, persisted. `uploading` covers exporting the
44280
+ * archive (it is streamed, never staged). Terminal: `failed`, `cancelled`,
44281
+ * `lost`, `expired`, `discarded`. `registered` and `canary` are where a
44282
+ * result lives after the operator acted on it.
44283
+ */
44284
+ var TrainingJobStateSchema = _enum([
44285
+ "uploading",
44286
+ "submitted",
44287
+ "starting",
44288
+ "running",
44289
+ "collecting",
44290
+ "ready",
44291
+ "registered",
44292
+ "canary",
44293
+ "failed",
44294
+ "cancelling",
44295
+ "cancelled",
44296
+ "lost",
44297
+ "expired",
44298
+ "discarded"
44299
+ ]);
44300
+ var TrainingFailureReasonSchema = _enum([
44301
+ "cost-cap",
44302
+ "runtime-cap",
44303
+ "upload-failed",
44304
+ "submit-failed",
44305
+ "trainer-failed",
44306
+ "result-invalid",
44307
+ "checksum-mismatch",
44308
+ "fetch-failed",
44309
+ "provider-error",
44310
+ "hub-restart-during-upload"
44311
+ ]);
44312
+ var TrainingProgressPointSchema = object({
44313
+ epoch: number().int(),
44314
+ map50: number().nullable(),
44315
+ map50_95: number().nullable()
44316
+ });
44317
+ var TrainingCanarySchema = object({
44318
+ deviceIds: array(number().int()).readonly(),
44319
+ since: number(),
44320
+ /** Every override the canary replaced, exactly, so rollback restores it. */
44321
+ previous: array(object({
44322
+ deviceId: number().int(),
44323
+ nodeId: string(),
44324
+ deviceKey: string(),
44325
+ patch: object({
44326
+ modelId: string().optional(),
44327
+ settings: record(string(), unknown()).readonly().optional()
44328
+ }).nullable()
44329
+ })).readonly()
44330
+ });
44331
+ var TrainingJobSchema = object({
44332
+ id: string(),
44333
+ idempotencyKey: string(),
44334
+ name: string(),
44335
+ createdAt: number(),
44336
+ updatedAt: number(),
44337
+ state: TrainingJobStateSchema,
44338
+ stage: TrainingStageSchema.nullable(),
44339
+ failure: object({
44340
+ reason: TrainingFailureReasonSchema,
44341
+ stage: string().nullable(),
44342
+ detail: string()
44343
+ }).nullable(),
44344
+ request: TrainingJobRequestSchema,
44345
+ maxCostUsd: number().nonnegative(),
44346
+ maxRuntimeSec: number().int().positive(),
44347
+ trainer: TrainerSourceRefSchema,
44348
+ datasetLayout: RetrainExportLayoutSchema,
44349
+ dataset: object({
44350
+ bytes: number().int(),
44351
+ sha256: string(),
44352
+ uploadedAt: number()
44353
+ }).nullable(),
44354
+ split: TrainingSplitPlanSchema,
44355
+ provider: object({
44356
+ state: ProviderJobStateSchema.nullable(),
44357
+ providerJobId: string().nullable(),
44358
+ startedAt: number().nullable(),
44359
+ endedAt: number().nullable(),
44360
+ billedSeconds: number(),
44361
+ costUsd: number(),
44362
+ costIsEstimate: boolean(),
44363
+ lastPolledAt: number().nullable()
44364
+ }),
44365
+ progress: object({
44366
+ epoch: number().int().nullable(),
44367
+ epochs: number().int().nullable(),
44368
+ etaSec: number().nullable(),
44369
+ series: array(TrainingProgressPointSchema).readonly()
44370
+ }),
44371
+ /** The last lines of the job's output (≤ 200), newest last. Never frame paths. */
44372
+ logTail: array(string()).readonly(),
44373
+ logCursor: string().nullable(),
44374
+ artifacts: object({
44375
+ bundleBytes: number().int(),
44376
+ bundleSha256: string(),
44377
+ fetchedAt: number(),
44378
+ /** When the staged artefacts are deleted from the hub. */
44379
+ expiresAt: number()
44380
+ }).nullable(),
44381
+ /** When the provider-side copy of the frames was deleted; null while it exists. */
44382
+ cloudDatasetDeletedAt: number().nullable(),
44383
+ /** A failed job's dataset is kept until then (the provider's grace), then deleted. */
44384
+ cloudCleanupDueAt: number().nullable(),
44385
+ /** Model ids registered from this job (base, and int8 when kept). */
44386
+ registeredModelIds: array(string()).readonly(),
44387
+ canary: TrainingCanarySchema.nullable()
44388
+ });
44389
+ var IdInput = object({ id: string().min(1) });
44390
+ method(TrainingDatasetVersionRowSchema, object({ stored: boolean() }), {
44391
+ kind: "mutation",
44392
+ auth: "admin"
44393
+ }), 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() }), {
44394
+ kind: "mutation",
44395
+ auth: "admin"
44396
+ }), method(object({}), array(TrainingBaseModelSchema).readonly(), { auth: "admin" }), method(TrainingJobRequestSchema, TrainingJobPlanSchema, {
44397
+ auth: "admin",
44398
+ timeoutMs: 6e4
44399
+ }), method(TrainingJobRequestSchema.extend({
44400
+ name: string().min(1).max(120),
44401
+ maxCostUsd: number().positive(),
44402
+ maxRuntimeSec: number().int().positive(),
44403
+ idempotencyKey: string().min(8).max(80)
44404
+ }), discriminatedUnion("kind", [object({
44405
+ kind: literal("started"),
44406
+ job: TrainingJobSchema
44407
+ }), object({
44408
+ kind: literal("refused"),
44409
+ reason: TrainingRefusalReasonSchema,
44410
+ detail: string()
44411
+ })]), {
44412
+ kind: "mutation",
44413
+ auth: "admin",
44414
+ timeoutMs: 12e4
44415
+ }), method(object({}), array(TrainingJobSchema).readonly(), { auth: "admin" }), method(IdInput, TrainingJobSchema.nullable(), { auth: "admin" }), method(IdInput, TrainingJobSchema, {
44416
+ kind: "mutation",
44417
+ auth: "admin",
44418
+ timeoutMs: 12e4
44419
+ }), method(IdInput, TrainingResultSchema.nullable(), { auth: "admin" }), method(IdInput.extend({ canaryDeviceIds: array(number().int()).readonly() }), TrainingJobSchema, {
44420
+ kind: "mutation",
44421
+ auth: "admin",
44422
+ timeoutMs: 30 * 6e4
44423
+ }), method(IdInput.extend({ deviceIds: array(number().int()).min(1).readonly() }), TrainingJobSchema, {
44424
+ kind: "mutation",
44425
+ auth: "admin",
44426
+ timeoutMs: 12e4
44427
+ }), method(IdInput, TrainingJobSchema, {
44428
+ kind: "mutation",
44429
+ auth: "admin",
44430
+ timeoutMs: 12e4
44431
+ }), method(IdInput, TrainingJobSchema, {
44432
+ kind: "mutation",
44433
+ auth: "admin"
44434
+ });
43034
44435
  SOURCE_CAPS.filter((cap) => cap !== "switch" && cap !== "motion");
43035
44436
  Object.freeze({
43036
44437
  person: .5,
@@ -43674,6 +45075,12 @@ Object.freeze({
43674
45075
  addonId: null,
43675
45076
  access: "create"
43676
45077
  },
45078
+ "backup.checkBackupKey": {
45079
+ capName: "backup",
45080
+ capScope: "system",
45081
+ addonId: null,
45082
+ access: "create"
45083
+ },
43677
45084
  "backup.delete": {
43678
45085
  capName: "backup",
43679
45086
  capScope: "system",
@@ -43686,6 +45093,18 @@ Object.freeze({
43686
45093
  addonId: null,
43687
45094
  access: "delete"
43688
45095
  },
45096
+ "backup.disableEncryption": {
45097
+ capName: "backup",
45098
+ capScope: "system",
45099
+ addonId: null,
45100
+ access: "create"
45101
+ },
45102
+ "backup.getEncryption": {
45103
+ capName: "backup",
45104
+ capScope: "system",
45105
+ addonId: null,
45106
+ access: "view"
45107
+ },
43689
45108
  "backup.getEntries": {
43690
45109
  capName: "backup",
43691
45110
  capScope: "system",
@@ -43740,6 +45159,12 @@ Object.freeze({
43740
45159
  addonId: null,
43741
45160
  access: "create"
43742
45161
  },
45162
+ "backup.setupEncryption": {
45163
+ capName: "backup",
45164
+ capScope: "system",
45165
+ addonId: null,
45166
+ access: "create"
45167
+ },
43743
45168
  "backup.trigger": {
43744
45169
  capName: "backup",
43745
45170
  capScope: "system",
@@ -44292,6 +45717,12 @@ Object.freeze({
44292
45717
  addonId: null,
44293
45718
  access: "create"
44294
45719
  },
45720
+ "customModelRegistry.importModelBundle": {
45721
+ capName: "custom-model-registry",
45722
+ capScope: "system",
45723
+ addonId: null,
45724
+ access: "create"
45725
+ },
44295
45726
  "customModelRegistry.listModels": {
44296
45727
  capName: "custom-model-registry",
44297
45728
  capScope: "system",
@@ -45732,6 +47163,12 @@ Object.freeze({
45732
47163
  addonId: null,
45733
47164
  access: "view"
45734
47165
  },
47166
+ "keychainAdmin.acknowledgeReset": {
47167
+ capName: "keychain-admin",
47168
+ capScope: "system",
47169
+ addonId: null,
47170
+ access: "create"
47171
+ },
45735
47172
  "keychainAdmin.deleteOrphans": {
45736
47173
  capName: "keychain-admin",
45737
47174
  capScope: "system",
@@ -45768,6 +47205,12 @@ Object.freeze({
45768
47205
  addonId: null,
45769
47206
  access: "delete"
45770
47207
  },
47208
+ "keychainAdmin.resetReport": {
47209
+ capName: "keychain-admin",
47210
+ capScope: "system",
47211
+ addonId: null,
47212
+ access: "delete"
47213
+ },
45771
47214
  "keychainAdmin.reveal": {
45772
47215
  capName: "keychain-admin",
45773
47216
  capScope: "system",
@@ -45780,6 +47223,12 @@ Object.freeze({
45780
47223
  addonId: null,
45781
47224
  access: "create"
45782
47225
  },
47226
+ "keychainAdmin.setSystemSecret": {
47227
+ capName: "keychain-admin",
47228
+ capScope: "system",
47229
+ addonId: null,
47230
+ access: "create"
47231
+ },
45783
47232
  "keychainAdmin.status": {
45784
47233
  capName: "keychain-admin",
45785
47234
  capScope: "system",
@@ -47226,6 +48675,12 @@ Object.freeze({
47226
48675
  addonId: null,
47227
48676
  access: "create"
47228
48677
  },
48678
+ "pipelineAnalytics.createRetrainDatasetVersion": {
48679
+ capName: "pipeline-analytics",
48680
+ capScope: "device",
48681
+ addonId: null,
48682
+ access: "create"
48683
+ },
47229
48684
  "pipelineAnalytics.deleteDeviceEvents": {
47230
48685
  capName: "pipeline-analytics",
47231
48686
  capScope: "device",
@@ -47238,6 +48693,12 @@ Object.freeze({
47238
48693
  addonId: null,
47239
48694
  access: "delete"
47240
48695
  },
48696
+ "pipelineAnalytics.deleteRetrainDatasetVersion": {
48697
+ capName: "pipeline-analytics",
48698
+ capScope: "device",
48699
+ addonId: null,
48700
+ access: "delete"
48701
+ },
47241
48702
  "pipelineAnalytics.deleteTracks": {
47242
48703
  capName: "pipeline-analytics",
47243
48704
  capScope: "device",
@@ -47460,6 +48921,12 @@ Object.freeze({
47460
48921
  addonId: null,
47461
48922
  access: "view"
47462
48923
  },
48924
+ "pipelineAnalytics.listRetrainDatasetVersions": {
48925
+ capName: "pipeline-analytics",
48926
+ capScope: "device",
48927
+ addonId: null,
48928
+ access: "view"
48929
+ },
47463
48930
  "pipelineAnalytics.listRetrainFrames": {
47464
48931
  capName: "pipeline-analytics",
47465
48932
  capScope: "device",
@@ -47490,6 +48957,12 @@ Object.freeze({
47490
48957
  addonId: null,
47491
48958
  access: "view"
47492
48959
  },
48960
+ "pipelineAnalytics.offerRetrainArchive": {
48961
+ capName: "pipeline-analytics",
48962
+ capScope: "device",
48963
+ addonId: null,
48964
+ access: "create"
48965
+ },
47493
48966
  "pipelineAnalytics.ownersWithMedia": {
47494
48967
  capName: "pipeline-analytics",
47495
48968
  capScope: "device",
@@ -47502,6 +48975,12 @@ Object.freeze({
47502
48975
  addonId: null,
47503
48976
  access: "create"
47504
48977
  },
48978
+ "pipelineAnalytics.previewRetrainDataset": {
48979
+ capName: "pipeline-analytics",
48980
+ capScope: "device",
48981
+ addonId: null,
48982
+ access: "view"
48983
+ },
47505
48984
  "pipelineAnalytics.proposeRetrainAnnotations": {
47506
48985
  capName: "pipeline-analytics",
47507
48986
  capScope: "device",
@@ -47640,6 +49119,12 @@ Object.freeze({
47640
49119
  addonId: null,
47641
49120
  access: "create"
47642
49121
  },
49122
+ "pipelineAnalytics.verifyRetrainDatasetVersion": {
49123
+ capName: "pipeline-analytics",
49124
+ capScope: "device",
49125
+ addonId: null,
49126
+ access: "view"
49127
+ },
47643
49128
  "pipelineAnalytics.wipeAllAnalytics": {
47644
49129
  capName: "pipeline-analytics",
47645
49130
  capScope: "device",
@@ -50016,6 +51501,174 @@ Object.freeze({
50016
51501
  addonId: null,
50017
51502
  access: "view"
50018
51503
  },
51504
+ "training.canaryResult": {
51505
+ capName: "training",
51506
+ capScope: "system",
51507
+ addonId: null,
51508
+ access: "create"
51509
+ },
51510
+ "training.cancelJob": {
51511
+ capName: "training",
51512
+ capScope: "system",
51513
+ addonId: null,
51514
+ access: "create"
51515
+ },
51516
+ "training.discardResult": {
51517
+ capName: "training",
51518
+ capScope: "system",
51519
+ addonId: null,
51520
+ access: "create"
51521
+ },
51522
+ "training.findDatasetVersionIdByName": {
51523
+ capName: "training",
51524
+ capScope: "system",
51525
+ addonId: null,
51526
+ access: "view"
51527
+ },
51528
+ "training.getDatasetVersion": {
51529
+ capName: "training",
51530
+ capScope: "system",
51531
+ addonId: null,
51532
+ access: "view"
51533
+ },
51534
+ "training.getJob": {
51535
+ capName: "training",
51536
+ capScope: "system",
51537
+ addonId: null,
51538
+ access: "view"
51539
+ },
51540
+ "training.getJobResult": {
51541
+ capName: "training",
51542
+ capScope: "system",
51543
+ addonId: null,
51544
+ access: "view"
51545
+ },
51546
+ "training.listBaseModels": {
51547
+ capName: "training",
51548
+ capScope: "system",
51549
+ addonId: null,
51550
+ access: "view"
51551
+ },
51552
+ "training.listDatasetVersions": {
51553
+ capName: "training",
51554
+ capScope: "system",
51555
+ addonId: null,
51556
+ access: "view"
51557
+ },
51558
+ "training.listJobs": {
51559
+ capName: "training",
51560
+ capScope: "system",
51561
+ addonId: null,
51562
+ access: "view"
51563
+ },
51564
+ "training.planJob": {
51565
+ capName: "training",
51566
+ capScope: "system",
51567
+ addonId: null,
51568
+ access: "view"
51569
+ },
51570
+ "training.putDatasetVersion": {
51571
+ capName: "training",
51572
+ capScope: "system",
51573
+ addonId: null,
51574
+ access: "create"
51575
+ },
51576
+ "training.registerResult": {
51577
+ capName: "training",
51578
+ capScope: "system",
51579
+ addonId: null,
51580
+ access: "create"
51581
+ },
51582
+ "training.removeDatasetVersion": {
51583
+ capName: "training",
51584
+ capScope: "system",
51585
+ addonId: null,
51586
+ access: "delete"
51587
+ },
51588
+ "training.rollbackCanary": {
51589
+ capName: "training",
51590
+ capScope: "system",
51591
+ addonId: null,
51592
+ access: "create"
51593
+ },
51594
+ "training.startJob": {
51595
+ capName: "training",
51596
+ capScope: "system",
51597
+ addonId: null,
51598
+ access: "create"
51599
+ },
51600
+ "trainingProvider.cancelJob": {
51601
+ capName: "training-provider",
51602
+ capScope: "system",
51603
+ addonId: null,
51604
+ access: "create"
51605
+ },
51606
+ "trainingProvider.cleanupJob": {
51607
+ capName: "training-provider",
51608
+ capScope: "system",
51609
+ addonId: null,
51610
+ access: "create"
51611
+ },
51612
+ "trainingProvider.describe": {
51613
+ capName: "training-provider",
51614
+ capScope: "system",
51615
+ addonId: null,
51616
+ access: "view"
51617
+ },
51618
+ "trainingProvider.estimateJob": {
51619
+ capName: "training-provider",
51620
+ capScope: "system",
51621
+ addonId: null,
51622
+ access: "view"
51623
+ },
51624
+ "trainingProvider.getJob": {
51625
+ capName: "training-provider",
51626
+ capScope: "system",
51627
+ addonId: null,
51628
+ access: "view"
51629
+ },
51630
+ "trainingProvider.listJobEvents": {
51631
+ capName: "training-provider",
51632
+ capScope: "system",
51633
+ addonId: null,
51634
+ access: "view"
51635
+ },
51636
+ "trainingProvider.listJobs": {
51637
+ capName: "training-provider",
51638
+ capScope: "system",
51639
+ addonId: null,
51640
+ access: "view"
51641
+ },
51642
+ "trainingProvider.offerArtifact": {
51643
+ capName: "training-provider",
51644
+ capScope: "system",
51645
+ addonId: null,
51646
+ access: "create"
51647
+ },
51648
+ "trainingProvider.readResult": {
51649
+ capName: "training-provider",
51650
+ capScope: "system",
51651
+ addonId: null,
51652
+ access: "create"
51653
+ },
51654
+ "trainingProvider.submitJob": {
51655
+ capName: "training-provider",
51656
+ capScope: "system",
51657
+ addonId: null,
51658
+ access: "create"
51659
+ },
51660
+ "trainingProvider.uploadDataset": {
51661
+ capName: "training-provider",
51662
+ capScope: "system",
51663
+ addonId: null,
51664
+ access: "create"
51665
+ },
51666
+ "trainingProvider.validateCredentials": {
51667
+ capName: "training-provider",
51668
+ capScope: "system",
51669
+ addonId: null,
51670
+ access: "create"
51671
+ },
50019
51672
  "turnProvider.getTurnServers": {
50020
51673
  capName: "turn-provider",
50021
51674
  capScope: "system",
@@ -50040,12 +51693,6 @@ Object.freeze({
50040
51693
  addonId: null,
50041
51694
  access: "create"
50042
51695
  },
50043
- "userManagement.createApiKey": {
50044
- capName: "user-management",
50045
- capScope: "system",
50046
- addonId: null,
50047
- access: "create"
50048
- },
50049
51696
  "userManagement.createScopedToken": {
50050
51697
  capName: "user-management",
50051
51698
  capScope: "system",
@@ -50082,12 +51729,6 @@ Object.freeze({
50082
51729
  addonId: null,
50083
51730
  access: "view"
50084
51731
  },
50085
- "userManagement.linkExternalIdentity": {
50086
- capName: "user-management",
50087
- capScope: "system",
50088
- addonId: null,
50089
- access: "create"
50090
- },
50091
51732
  "userManagement.listApiKeys": {
50092
51733
  capName: "user-management",
50093
51734
  capScope: "system",
@@ -50190,12 +51831,6 @@ Object.freeze({
50190
51831
  addonId: null,
50191
51832
  access: "create"
50192
51833
  },
50193
- "userManagement.validateApiKey": {
50194
- capName: "user-management",
50195
- capScope: "system",
50196
- addonId: null,
50197
- access: "view"
50198
- },
50199
51834
  "userManagement.validateCredentials": {
50200
51835
  capName: "user-management",
50201
51836
  capScope: "system",
@@ -54309,6 +55944,11 @@ Object.freeze({
54309
55944
  form: "single",
54310
55945
  optional: false
54311
55946
  }],
55947
+ "training.canaryResult": [{
55948
+ name: "deviceIds",
55949
+ form: "array",
55950
+ optional: false
55951
+ }],
54312
55952
  "update.getStatus": [{
54313
55953
  name: "deviceId",
54314
55954
  form: "single",
@@ -56156,7 +57796,12 @@ var CREDENTIAL_PARAM_PATTERNS = [
56156
57796
  /^bearer$/i,
56157
57797
  /^api[_-]?key$/i,
56158
57798
  /^access[_-]?token$/i,
56159
- /^refresh[_-]?token$/i
57799
+ /^refresh[_-]?token$/i,
57800
+ /^bridge$/i,
57801
+ /^code$/i,
57802
+ /^state$/i,
57803
+ /^challenge$/i,
57804
+ /^link$/i
56160
57805
  ];
56161
57806
  function isCredentialParam(name) {
56162
57807
  return CREDENTIAL_PARAM_PATTERNS.some((re) => re.test(name));
@@ -56178,6 +57823,10 @@ function isCredentialParam(name) {
56178
57823
  * are NOT masked (those are entity references, not credentials).
56179
57824
  */
56180
57825
  function maskUrlCredentials(rawUrl) {
57826
+ if (rawUrl.startsWith("/") && !rawUrl.startsWith("//")) {
57827
+ const masked = maskUrlCredentials(`http://relative.invalid${rawUrl}`);
57828
+ return masked.startsWith("http://relative.invalid") ? masked.slice(23) : rawUrl;
57829
+ }
56181
57830
  try {
56182
57831
  const u = new URL(rawUrl);
56183
57832
  let touched = false;