@camstack/addon-provider-onvif 1.2.124 → 1.2.126

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/dist/addon.js +1631 -140
  2. package/dist/addon.mjs +1631 -140
  3. package/package.json +1 -1
package/dist/addon.js CHANGED
@@ -5380,7 +5380,7 @@ var ZodIssueCode = {
5380
5380
  var ZodFirstPartyTypeKind;
5381
5381
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
5382
5382
  //#endregion
5383
- //#region ../types/dist/sleep-DujUvOcb.mjs
5383
+ //#region ../types/dist/sleep-r3RWkGVx.mjs
5384
5384
  /**
5385
5385
  * The audio chunk plane's byte format, and the ONE expansion from a coded
5386
5386
  * window to float samples (D455).
@@ -5497,7 +5497,7 @@ function isKeychainStoredField(field) {
5497
5497
  var SECRET_CLEAR = { $secretClear: true };
5498
5498
  /** The `'***'` token D634 redaction writes for non-admins. */
5499
5499
  var LEGACY_DEVICE_REDACTION = "***";
5500
- function isRecord$1(value) {
5500
+ function isRecord$2(value) {
5501
5501
  return typeof value === "object" && value !== null && !Array.isArray(value);
5502
5502
  }
5503
5503
  function makeSecretMarker(ref) {
@@ -5508,12 +5508,12 @@ function makeSecretMarker(ref) {
5508
5508
  }
5509
5509
  /** A stored marker: an object whose `$secret` is a non-empty string. */
5510
5510
  function isSecretMarker(value) {
5511
- if (!isRecord$1(value)) return false;
5511
+ if (!isRecord$2(value)) return false;
5512
5512
  const ref = value["$secret"];
5513
5513
  return typeof ref === "string" && ref.length > 0;
5514
5514
  }
5515
5515
  function isSecretClear(value) {
5516
- return isRecord$1(value) && value["$secretClear"] === true;
5516
+ return isRecord$2(value) && value["$secretClear"] === true;
5517
5517
  }
5518
5518
  /**
5519
5519
  * The UI view of a stored secret field value: a marker becomes "set", inline
@@ -6029,6 +6029,13 @@ function globalSecretScope() {
6029
6029
  function encodeSegment(value) {
6030
6030
  return encodeURIComponent(value);
6031
6031
  }
6032
+ function decodeSegment(value) {
6033
+ try {
6034
+ return decodeURIComponent(value);
6035
+ } catch {
6036
+ return null;
6037
+ }
6038
+ }
6032
6039
  /**
6033
6040
  * The field path of a value inside an array item, addressed by the item's id:
6034
6041
  * `arrayItemFieldPath('providers', 'authentik', 'clientSecret')` →
@@ -6037,6 +6044,75 @@ function encodeSegment(value) {
6037
6044
  function arrayItemFieldPath(arrayKey, itemId, fieldKey) {
6038
6045
  return `${arrayKey}[${encodeSegment(itemId)}].${fieldKey}`;
6039
6046
  }
6047
+ function parseScope(segments) {
6048
+ switch (segments[0]) {
6049
+ case "global": return {
6050
+ scope: GLOBAL_SCOPE,
6051
+ used: 1
6052
+ };
6053
+ case "node": {
6054
+ const nodeId = segments[1] !== void 0 ? decodeSegment(segments[1]) : null;
6055
+ return nodeId === null || nodeId.length === 0 ? null : {
6056
+ scope: {
6057
+ kind: "node",
6058
+ nodeId
6059
+ },
6060
+ used: 2
6061
+ };
6062
+ }
6063
+ case "device": {
6064
+ const raw = segments[1];
6065
+ if (raw === void 0 || !/^\d+$/.test(raw)) return null;
6066
+ return {
6067
+ scope: {
6068
+ kind: "device",
6069
+ deviceId: Number(raw)
6070
+ },
6071
+ used: 2
6072
+ };
6073
+ }
6074
+ case "integration": {
6075
+ const id = segments[1] !== void 0 ? decodeSegment(segments[1]) : null;
6076
+ return id === null || id.length === 0 ? null : {
6077
+ scope: {
6078
+ kind: "integration",
6079
+ integrationId: id
6080
+ },
6081
+ used: 2
6082
+ };
6083
+ }
6084
+ case "row": {
6085
+ const collection = segments[1] !== void 0 ? decodeSegment(segments[1]) : null;
6086
+ const rowId = segments[2] !== void 0 ? decodeSegment(segments[2]) : null;
6087
+ if (collection === null || rowId === null || collection.length === 0 || rowId.length === 0) return null;
6088
+ return {
6089
+ scope: {
6090
+ kind: "row",
6091
+ collection,
6092
+ rowId
6093
+ },
6094
+ used: 3
6095
+ };
6096
+ }
6097
+ default: return null;
6098
+ }
6099
+ }
6100
+ /** Take a ref apart; `null` when it is not a well-formed ref. */
6101
+ function parseSecretRef(ref) {
6102
+ if (!ref.startsWith("secret://")) return null;
6103
+ const segments = ref.slice(9).split("/");
6104
+ const owner = segments[0] !== void 0 ? decodeSegment(segments[0]) : null;
6105
+ if (owner === null || owner.length === 0) return null;
6106
+ const parsed = parseScope(segments.slice(1));
6107
+ if (parsed === null) return null;
6108
+ const fieldPath = segments.slice(1 + parsed.used).join("/");
6109
+ if (fieldPath.length === 0) return null;
6110
+ return {
6111
+ owner,
6112
+ scope: parsed.scope,
6113
+ fieldPath
6114
+ };
6115
+ }
6040
6116
  /** A write to a secret path could not be stored in the keychain, so it was refused. */
6041
6117
  var KeychainWriteRefusedError = class extends Error {
6042
6118
  fieldPath;
@@ -6047,7 +6123,7 @@ var KeychainWriteRefusedError = class extends Error {
6047
6123
  }
6048
6124
  };
6049
6125
  var KEEP = { kind: "keep" };
6050
- function isRecord(value) {
6126
+ function isRecord$1(value) {
6051
6127
  return typeof value === "object" && value !== null && !Array.isArray(value);
6052
6128
  }
6053
6129
  function defaultMintId() {
@@ -6060,7 +6136,7 @@ function collectSecretMarkerRefs(value, out = []) {
6060
6136
  return out;
6061
6137
  }
6062
6138
  if (Array.isArray(value)) for (const item of value) collectSecretMarkerRefs(item, out);
6063
- else if (isRecord(value)) for (const child of Object.values(value)) collectSecretMarkerRefs(child, out);
6139
+ else if (isRecord$1(value)) for (const child of Object.values(value)) collectSecretMarkerRefs(child, out);
6064
6140
  return out;
6065
6141
  }
6066
6142
  async function storedValueEquals(secrets, marker, candidate) {
@@ -6115,7 +6191,7 @@ function rowId(row, idKey) {
6115
6191
  return null;
6116
6192
  }
6117
6193
  async function writeArray(ctx, node, incoming, stored, fieldPath) {
6118
- const storedRows = Array.isArray(stored) ? stored.filter(isRecord) : [];
6194
+ const storedRows = Array.isArray(stored) ? stored.filter(isRecord$1) : [];
6119
6195
  if (!Array.isArray(incoming)) {
6120
6196
  ctx.deletes.push(...collectSecretMarkerRefs(storedRows));
6121
6197
  return {
@@ -6131,7 +6207,7 @@ async function writeArray(ctx, node, incoming, stored, fieldPath) {
6131
6207
  const kept = /* @__PURE__ */ new Set();
6132
6208
  const rows = [];
6133
6209
  for (const row of incoming) {
6134
- if (!isRecord(row)) {
6210
+ if (!isRecord$1(row)) {
6135
6211
  rows.push(row);
6136
6212
  continue;
6137
6213
  }
@@ -6156,7 +6232,7 @@ async function writeNode(ctx, node, incoming, stored, fieldPath) {
6156
6232
  case "leaf": return writeLeaf(ctx, incoming, stored, fieldPath);
6157
6233
  case "array": return writeArray(ctx, node, incoming, stored, fieldPath);
6158
6234
  case "object": {
6159
- if (!isRecord(incoming)) {
6235
+ if (!isRecord$1(incoming)) {
6160
6236
  if (incoming === void 0) return KEEP;
6161
6237
  ctx.deletes.push(...collectSecretMarkerRefs(stored));
6162
6238
  return {
@@ -6164,7 +6240,7 @@ async function writeNode(ctx, node, incoming, stored, fieldPath) {
6164
6240
  value: incoming
6165
6241
  };
6166
6242
  }
6167
- const storedObj = isRecord(stored) ? stored : {};
6243
+ const storedObj = isRecord$1(stored) ? stored : {};
6168
6244
  return {
6169
6245
  kind: "value",
6170
6246
  value: await writeMembers(ctx, node.children, incoming, storedObj, (m) => `${fieldPath}.${m}`)
@@ -6223,12 +6299,19 @@ async function transformSecretWrite(input) {
6223
6299
  }
6224
6300
  };
6225
6301
  }
6302
+ /** Is `ref` one of `owner`'s refs? */
6303
+ function isSecretRefOwnedBy(ref, owner) {
6304
+ return parseSecretRef(ref)?.owner === owner;
6305
+ }
6226
6306
  /**
6227
6307
  * Replace every marker in `value` with its keychain value. Returns the SAME
6228
6308
  * reference when there is no marker (no allocation, no keychain call).
6229
6309
  */
6230
- async function resolveSecretMarkers(value, secrets) {
6231
- const refs = collectSecretMarkerRefs(value);
6310
+ async function resolveSecretMarkers(value, secrets, options = {}) {
6311
+ const keepMarker = options.unresolved === "keep-marker";
6312
+ const owner = options.ownedBy;
6313
+ const inScope = (ref) => owner === void 0 || isSecretRefOwnedBy(ref, owner);
6314
+ const refs = collectSecretMarkerRefs(value).filter(inScope);
6232
6315
  if (refs.length === 0) return {
6233
6316
  value,
6234
6317
  unresolved: []
@@ -6252,10 +6335,18 @@ async function resolveSecretMarkers(value, secrets) {
6252
6335
  }
6253
6336
  const substitute = (v) => {
6254
6337
  if (isSecretMarker(v)) {
6338
+ if (!inScope(v.$secret)) return {
6339
+ keep: true,
6340
+ value: v
6341
+ };
6255
6342
  const answer = answers[v.$secret];
6256
- return answer?.kind === "value" ? {
6343
+ if (answer?.kind === "value") return {
6257
6344
  keep: true,
6258
6345
  value: answer.value
6346
+ };
6347
+ return keepMarker ? {
6348
+ keep: true,
6349
+ value: v
6259
6350
  } : {
6260
6351
  keep: false,
6261
6352
  value: void 0
@@ -6272,7 +6363,7 @@ async function resolveSecretMarkers(value, secrets) {
6272
6363
  value: items
6273
6364
  };
6274
6365
  }
6275
- if (isRecord(v)) {
6366
+ if (isRecord$1(v)) {
6276
6367
  const out = {};
6277
6368
  for (const [k, child] of Object.entries(v)) {
6278
6369
  const s = substitute(child);
@@ -6293,14 +6384,152 @@ async function resolveSecretMarkers(value, secrets) {
6293
6384
  unresolved
6294
6385
  };
6295
6386
  }
6296
- function touchesTree(tree, patch) {
6297
- if (tree.size === 0) return false;
6298
- for (const key of Object.keys(patch)) {
6299
- const at = key.indexOf("@");
6300
- if (tree.has(at > 0 ? key.slice(0, at) : key)) return true;
6387
+ /** An addon tried to replace a stored secret it could not read. Nothing was written. */
6388
+ var SecretOverwriteRefusedError = class extends Error {
6389
+ ref;
6390
+ reason;
6391
+ constructor(ref, reason) {
6392
+ 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.`);
6393
+ this.ref = ref;
6394
+ this.reason = reason;
6395
+ this.name = "SecretOverwriteRefusedError";
6396
+ }
6397
+ };
6398
+ function isRecord(value) {
6399
+ return typeof value === "object" && value !== null && !Array.isArray(value);
6400
+ }
6401
+ function resolvedValue(pass, marker) {
6402
+ const answer = pass.answers[marker.$secret];
6403
+ return answer?.kind === "value" ? answer.value : null;
6404
+ }
6405
+ async function atMarker(pass, incoming, stored) {
6406
+ if (incoming === null) return stored;
6407
+ if (typeof incoming !== "string") return incoming;
6408
+ if (incoming === resolvedValue(pass, stored)) return stored;
6409
+ const intent = classifySecretWrite(incoming);
6410
+ if (intent.kind !== "set") return stored;
6411
+ const ref = stored.$secret;
6412
+ if (!isSecretRefOwnedBy(ref, pass.secrets.owner)) return incoming;
6413
+ const answer = pass.answers[ref];
6414
+ 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);
6415
+ try {
6416
+ await pass.secrets.put(ref, intent.value);
6417
+ } catch (err) {
6418
+ throw new KeychainWriteRefusedError(ref, err);
6419
+ }
6420
+ pass.changedRefs.push(ref);
6421
+ return stored;
6422
+ }
6423
+ function inArray(pass, incoming, stored) {
6424
+ return incoming.map((item, index) => {
6425
+ const twin = stored[index];
6426
+ if (isSecretMarker(twin)) return typeof item === "string" && item === resolvedValue(pass, twin) ? twin : item;
6427
+ if (isRecord(item) && isRecord(twin)) return inArrayRow(pass, item, twin);
6428
+ if (Array.isArray(item) && Array.isArray(twin)) return inArray(pass, item, twin);
6429
+ return item;
6430
+ });
6431
+ }
6432
+ function inArrayRow(pass, incoming, stored) {
6433
+ const out = { ...incoming };
6434
+ for (const [key, value] of Object.entries(incoming)) {
6435
+ const twin = stored[key];
6436
+ if (isSecretMarker(twin)) {
6437
+ if (typeof value === "string" && value === resolvedValue(pass, twin)) out[key] = twin;
6438
+ } else if (isRecord(value) && isRecord(twin)) out[key] = inArrayRow(pass, value, twin);
6439
+ else if (Array.isArray(value) && Array.isArray(twin)) out[key] = inArray(pass, value, twin);
6440
+ }
6441
+ return out;
6442
+ }
6443
+ async function walk(pass, incoming, stored) {
6444
+ if (isSecretMarker(stored)) return atMarker(pass, incoming, stored);
6445
+ if (Array.isArray(incoming) && Array.isArray(stored)) return inArray(pass, incoming, stored);
6446
+ if (!isRecord(incoming) || !isRecord(stored)) return incoming;
6447
+ const out = { ...incoming };
6448
+ for (const [key, value] of Object.entries(incoming)) out[key] = await walk(pass, value, stored[key]);
6449
+ return out;
6450
+ }
6451
+ /** Restore markers a write-back carries as values. See the file doc. */
6452
+ async function restoreUnchangedSecrets(input) {
6453
+ const refs = [];
6454
+ for (const key of Object.keys(input.patch)) collectSecretMarkerRefs(input.stored[key], refs);
6455
+ const owned = refs.filter((ref) => isSecretRefOwnedBy(ref, input.secrets.owner));
6456
+ if (owned.length === 0) return {
6457
+ patch: input.patch,
6458
+ changedRefs: []
6459
+ };
6460
+ const pass = {
6461
+ secrets: input.secrets,
6462
+ answers: await input.secrets.resolve([...new Set(owned)]),
6463
+ operatorWrite: input.operatorWrite,
6464
+ changedRefs: []
6465
+ };
6466
+ const out = {};
6467
+ for (const [key, value] of Object.entries(input.patch)) out[key] = await walk(pass, value, input.stored[key]);
6468
+ return {
6469
+ patch: out,
6470
+ changedRefs: pass.changedRefs
6471
+ };
6472
+ }
6473
+ /** Structural equality over JSON-shaped values (key order does not matter). */
6474
+ function isJsonEqual(a, b) {
6475
+ if (Object.is(a, b)) return true;
6476
+ if (Array.isArray(a)) return Array.isArray(b) && a.length === b.length && a.every((v, i) => isJsonEqual(v, b[i]));
6477
+ if (isRecord(a) && isRecord(b)) {
6478
+ const keys = Object.keys(a);
6479
+ if (keys.length !== Object.keys(b).length) return false;
6480
+ return keys.every((k) => Object.prototype.hasOwnProperty.call(b, k) && isJsonEqual(a[k], b[k]));
6301
6481
  }
6302
6482
  return false;
6303
6483
  }
6484
+ /** The patch without the keys whose value already equals the stored one. */
6485
+ function dropUnchangedKeys(patch, stored) {
6486
+ const out = {};
6487
+ for (const [key, value] of Object.entries(patch)) {
6488
+ if (Object.prototype.hasOwnProperty.call(stored, key) && isJsonEqual(value, stored[key])) continue;
6489
+ out[key] = value;
6490
+ }
6491
+ return out;
6492
+ }
6493
+ /** The top-level keys of a blob that hold at least one of `owner`'s markers. */
6494
+ function markerKeysOf(blob, owner) {
6495
+ const keys = /* @__PURE__ */ new Set();
6496
+ for (const [key, value] of Object.entries(blob)) if (collectSecretMarkerRefs(value).some((ref) => isSecretRefOwnedBy(ref, owner))) keys.add(key);
6497
+ return keys;
6498
+ }
6499
+ function nodeFromStored(value, owner) {
6500
+ if (isSecretMarker(value)) return isSecretRefOwnedBy(value.$secret, owner) ? { kind: "leaf" } : null;
6501
+ if (!isRecord(value)) return null;
6502
+ const children = /* @__PURE__ */ new Map();
6503
+ for (const [key, child] of Object.entries(value)) {
6504
+ const node = nodeFromStored(child, owner);
6505
+ if (node !== null) children.set(key, node);
6506
+ }
6507
+ return children.size > 0 ? {
6508
+ kind: "object",
6509
+ children
6510
+ } : null;
6511
+ }
6512
+ /**
6513
+ * The declared secret tree, widened by every place the STORED blob holds a
6514
+ * marker under one of `keys` — so a marker the schema no longer declares (or
6515
+ * never declared: Wyze before b4906cec6) still gets the save path's
6516
+ * KEEP / SET / CLEAR semantics instead of being overwritten by whatever the
6517
+ * addon writes. Markers inside arrays are not added: a row has no id field to
6518
+ * match by unless the schema declares one. Only `owner`'s markers count: a
6519
+ * builtin that keeps another addon's marker (device-manager) never takes it
6520
+ * over.
6521
+ */
6522
+ function widenTreeWithStoredMarkers(declared, stored, keys, owner) {
6523
+ const added = /* @__PURE__ */ new Map();
6524
+ for (const key of keys) {
6525
+ const at = key.indexOf("@");
6526
+ const base = at > 0 ? key.slice(0, at) : key;
6527
+ if (declared.has(base) || added.has(base)) continue;
6528
+ const node = nodeFromStored(stored[key], owner);
6529
+ if (node !== null) added.set(base, node);
6530
+ }
6531
+ return added.size === 0 ? declared : new Map([...declared, ...added]);
6532
+ }
6304
6533
  /** The blob as stored now; a failed read REFUSES the write instead of guessing. */
6305
6534
  async function readStoredAddonBlob(raw) {
6306
6535
  const threeWay = raw.readAddonStoreResult;
@@ -6309,7 +6538,41 @@ async function readStoredAddonBlob(raw) {
6309
6538
  if (result.kind === "failed") throw new Error(`settings write refused: the stored blob could not be read (${result.error})`);
6310
6539
  return result.kind === "missing" ? {} : result.value;
6311
6540
  }
6312
- function createSecretAwareSettings(raw, opts) {
6541
+ function touchesTree(tree, patch) {
6542
+ if (tree.size === 0) return false;
6543
+ for (const key of Object.keys(patch)) {
6544
+ const at = key.indexOf("@");
6545
+ if (tree.has(at > 0 ? key.slice(0, at) : key)) return true;
6546
+ }
6547
+ return false;
6548
+ }
6549
+ /**
6550
+ * Which top-level keys of each store held markers when last seen. `undefined`
6551
+ * for a store not seen yet: its first write reads it, to be safe.
6552
+ */
6553
+ var MarkerKeyIndex = class {
6554
+ owner;
6555
+ byStore = /* @__PURE__ */ new Map();
6556
+ constructor(owner) {
6557
+ this.owner = owner;
6558
+ }
6559
+ seen(store, blob) {
6560
+ this.byStore.set(store, markerKeysOf(blob, this.owner));
6561
+ }
6562
+ wrote(store, patch) {
6563
+ const keys = this.byStore.get(store);
6564
+ if (keys === void 0) return;
6565
+ const now = markerKeysOf(patch, this.owner);
6566
+ for (const key of Object.keys(patch)) if (now.has(key)) keys.add(key);
6567
+ else keys.delete(key);
6568
+ }
6569
+ mayHoldMarkers(store, patch) {
6570
+ const keys = this.byStore.get(store);
6571
+ if (keys === void 0) return true;
6572
+ return Object.keys(patch).some((key) => keys.has(key));
6573
+ }
6574
+ };
6575
+ function createHandle(raw, opts) {
6313
6576
  const chains = /* @__PURE__ */ new Map();
6314
6577
  const serialize = (key, fn) => {
6315
6578
  const next = (chains.get(key) ?? Promise.resolve()).then(fn, fn);
@@ -6320,46 +6583,130 @@ function createSecretAwareSettings(raw, opts) {
6320
6583
  });
6321
6584
  return next;
6322
6585
  };
6323
- const write = async (chainKey, tree, scope, patch, readStored, rawWrite) => {
6324
- if (!touchesTree(tree, patch)) return rawWrite(patch);
6325
- return serialize(chainKey, async () => {
6586
+ const index = new MarkerKeyIndex(opts.secrets.owner);
6587
+ const resolveRead = async (store, blob) => {
6588
+ index.seen(store, blob);
6589
+ const { value, unresolved } = await resolveSecretMarkers(blob, opts.secrets, {
6590
+ unresolved: "keep-marker",
6591
+ ownedBy: opts.secrets.owner
6592
+ });
6593
+ if (unresolved.length > 0) opts.onUnresolved?.(unresolved);
6594
+ return value;
6595
+ };
6596
+ const write = async (store, declared, scope, patch, readStored, rawWrite) => {
6597
+ if (!touchesTree(declared, patch) && !index.mayHoldMarkers(store, patch)) {
6598
+ await rawWrite(patch);
6599
+ index.wrote(store, patch);
6600
+ return { changed: true };
6601
+ }
6602
+ return serialize(store, async () => {
6326
6603
  const stored = await readStored();
6604
+ index.seen(store, stored);
6605
+ const operatorWrite = opts.isOperatorWrite?.() === true;
6606
+ const restored = await restoreUnchangedSecrets({
6607
+ patch,
6608
+ stored,
6609
+ secrets: opts.secrets,
6610
+ operatorWrite
6611
+ });
6327
6612
  const result = await transformSecretWrite({
6328
- tree,
6613
+ tree: widenTreeWithStoredMarkers(declared, stored, Object.keys(restored.patch), opts.secrets.owner),
6329
6614
  secrets: opts.secrets,
6330
- patch,
6615
+ patch: restored.patch,
6331
6616
  stored,
6332
6617
  ...scope !== void 0 ? { scope } : {},
6333
- operatorWrite: opts.isOperatorWrite?.() === true
6618
+ operatorWrite
6334
6619
  });
6335
- if (Object.keys(result.patch).length > 0) await rawWrite(result.patch);
6620
+ const effective = dropUnchangedKeys(result.patch, stored);
6621
+ const wroteBlob = Object.keys(effective).length > 0;
6622
+ if (wroteBlob) {
6623
+ await rawWrite(effective);
6624
+ index.wrote(store, effective);
6625
+ }
6336
6626
  const { orphaned } = await result.afterWrite();
6337
6627
  if (orphaned.length > 0) opts.onOrphaned(orphaned);
6628
+ return { changed: wroteBlob || restored.changedRefs.length > 0 };
6338
6629
  });
6339
6630
  };
6340
- const wrapped = {
6341
- writeAddonStore: (patch) => write("addon", opts.addonTree(), void 0, patch, () => readStoredAddonBlob(raw), (p) => raw.writeAddonStore(p)),
6342
- writeDeviceStore: (deviceId, patch) => write(`device:${deviceId}`, opts.deviceTree(), {
6343
- kind: "device",
6344
- deviceId
6345
- }, patch, () => raw.readDeviceStore(deviceId), (p) => raw.writeDeviceStore(deviceId, p))
6631
+ const writeAddon = (patch) => write("addon", opts.addonTree(), void 0, patch, () => readStoredAddonBlob(raw), (p) => raw.writeAddonStore(p));
6632
+ const readAddonStoreResult = raw.readAddonStoreResult;
6633
+ const readAddonStoreKeyResult = raw.readAddonStoreKeyResult;
6634
+ const readDeviceStoreBatch = raw.readDeviceStoreBatch;
6635
+ const overrides = {
6636
+ readAddonStore: async () => resolveRead("addon", await raw.readAddonStore()),
6637
+ ...readAddonStoreResult !== void 0 ? { readAddonStoreResult: async () => {
6638
+ const result = await readAddonStoreResult.call(raw);
6639
+ return result.kind === "value" ? {
6640
+ kind: "value",
6641
+ value: await resolveRead("addon", result.value)
6642
+ } : result;
6643
+ } } : {},
6644
+ ...readAddonStoreKeyResult !== void 0 ? { readAddonStoreKeyResult: async (key) => {
6645
+ const result = await readAddonStoreKeyResult.call(raw, key);
6646
+ if (result.kind !== "present") return result;
6647
+ const { value, unresolved } = await resolveSecretMarkers({ [key]: result.value }, opts.secrets, {
6648
+ unresolved: "keep-marker",
6649
+ ownedBy: opts.secrets.owner
6650
+ });
6651
+ if (unresolved.length > 0) opts.onUnresolved?.(unresolved);
6652
+ return {
6653
+ kind: "present",
6654
+ value: value[key]
6655
+ };
6656
+ } } : {},
6657
+ readDeviceStore: async (deviceId) => resolveRead(`device:${deviceId}`, await raw.readDeviceStore(deviceId)),
6658
+ ...readDeviceStoreBatch !== void 0 ? { readDeviceStoreBatch: async (deviceIds) => {
6659
+ const rows = await readDeviceStoreBatch.call(raw, deviceIds);
6660
+ const out = /* @__PURE__ */ new Map();
6661
+ for (const [deviceId, blob] of rows) out.set(deviceId, await resolveRead(`device:${deviceId}`, blob));
6662
+ return out;
6663
+ } } : {},
6664
+ writeAddonStore: async (patch) => {
6665
+ await writeAddon(patch);
6666
+ },
6667
+ writeDeviceStore: async (deviceId, patch) => {
6668
+ await write(`device:${deviceId}`, opts.deviceTree(), {
6669
+ kind: "device",
6670
+ deviceId
6671
+ }, patch, () => raw.readDeviceStore(deviceId), (p) => raw.writeDeviceStore(deviceId, p));
6672
+ }
6673
+ };
6674
+ return {
6675
+ settings: new Proxy(raw, { get(target, prop, receiver) {
6676
+ if (typeof prop === "string" && Object.prototype.hasOwnProperty.call(overrides, prop)) return Reflect.get(overrides, prop);
6677
+ const value = Reflect.get(target, prop, receiver);
6678
+ return typeof value === "function" ? value.bind(target) : value;
6679
+ } }),
6680
+ raw: {
6681
+ readAddonStore: async () => {
6682
+ const blob = await raw.readAddonStore();
6683
+ index.seen("addon", blob);
6684
+ return blob;
6685
+ },
6686
+ readDeviceStore: async (deviceId) => {
6687
+ const blob = await raw.readDeviceStore(deviceId);
6688
+ index.seen(`device:${deviceId}`, blob);
6689
+ return blob;
6690
+ }
6691
+ },
6692
+ writeAddonStore: writeAddon
6346
6693
  };
6347
- return new Proxy(raw, { get(target, prop, receiver) {
6348
- if (prop === "writeAddonStore") return wrapped.writeAddonStore;
6349
- if (prop === "writeDeviceStore") return wrapped.writeDeviceStore;
6350
- const value = Reflect.get(target, prop, receiver);
6351
- return typeof value === "function" ? value.bind(target) : value;
6352
- } });
6353
6694
  }
6354
- /** The context the addon sees: identical, except that its settings writes are secret-aware. */
6355
- function withSecretAwareSettings(context, opts) {
6695
+ /** The context the addon sees, plus the private raw view and write outcome. */
6696
+ function createSecretAwareContext(context, opts) {
6356
6697
  const raw = context.settings;
6357
- if (raw === void 0) return context;
6358
- const settings = createSecretAwareSettings(raw, opts);
6359
- return new Proxy(context, { get(target, prop, receiver) {
6360
- if (prop === "settings") return settings;
6361
- return Reflect.get(target, prop, receiver);
6362
- } });
6698
+ if (raw === void 0) return {
6699
+ context,
6700
+ handle: null
6701
+ };
6702
+ const handle = createHandle(raw, opts);
6703
+ return {
6704
+ context: new Proxy(context, { get(target, prop, receiver) {
6705
+ if (prop === "settings") return handle.settings;
6706
+ return Reflect.get(target, prop, receiver);
6707
+ } }),
6708
+ handle
6709
+ };
6363
6710
  }
6364
6711
  var LEAF = { kind: "leaf" };
6365
6712
  var DEFAULT_ITEM_ID_KEY = "id";
@@ -6534,6 +6881,14 @@ var BaseAddon = class {
6534
6881
  _secretChangeUnsub = null;
6535
6882
  /** >0 while an OPERATOR's settings write is being applied. */
6536
6883
  _operatorWriteDepth = 0;
6884
+ /**
6885
+ * The keychain-aware settings handle (D798). Its `raw` view is the ONLY way
6886
+ * to the marker-bearing blobs and stays private to this class: the form
6887
+ * hydrate and config resolution need markers, addon code never does.
6888
+ */
6889
+ _secretSettings = null;
6890
+ /** Refs an addon-facing read could not resolve — each is logged once per process. */
6891
+ _loggedUnresolvedReads = /* @__PURE__ */ new Set();
6537
6892
  constructor(defaults) {
6538
6893
  this.defaults = defaults;
6539
6894
  this._config = { ...defaults };
@@ -6570,13 +6925,21 @@ var BaseAddon = class {
6570
6925
  }
6571
6926
  async initialize(context) {
6572
6927
  const secrets = context.secrets;
6573
- this._ctx = secrets !== void 0 ? withSecretAwareSettings(context, {
6574
- secrets,
6575
- addonTree: () => this.addonSecretTree(),
6576
- deviceTree: () => this.deviceSecretTree(),
6577
- onOrphaned: (refs) => context.logger.warn("keychain refs dropped by a settings write could not be deleted", { meta: { refs: [...refs] } }),
6578
- isOperatorWrite: () => this._operatorWriteDepth > 0
6579
- }) : context;
6928
+ if (secrets !== void 0) {
6929
+ const { context: wrapped, handle } = createSecretAwareContext(context, {
6930
+ secrets,
6931
+ addonTree: () => this.addonSecretTree(),
6932
+ deviceTree: () => this.deviceSecretTree(),
6933
+ onOrphaned: (refs) => context.logger.warn("keychain refs dropped by a settings write could not be deleted", { meta: { refs: [...refs] } }),
6934
+ isOperatorWrite: () => this._operatorWriteDepth > 0,
6935
+ onUnresolved: (unresolved) => this.logUnresolvedRead(unresolved)
6936
+ });
6937
+ this._ctx = wrapped;
6938
+ this._secretSettings = handle;
6939
+ } else {
6940
+ this._ctx = context;
6941
+ this._secretSettings = null;
6942
+ }
6580
6943
  await this.resolveConfig();
6581
6944
  if (secrets !== void 0) this._secretChangeUnsub = secrets.onChange((ref) => {
6582
6945
  if (this._configSecretRefs.has(ref)) this.scheduleSecretReresolve(SECRET_CHANGE_DEBOUNCE_MS);
@@ -6693,11 +7056,8 @@ var BaseAddon = class {
6693
7056
  async getGlobalSettings(overlay, cap, nodeId) {
6694
7057
  const schema = this.globalSettingsSchema(cap);
6695
7058
  if (!schema) return { sections: [] };
6696
- const projected = await this.resolveGlobalStore(nodeId, cap);
6697
- return hydrateSchema(schema, overlay ? {
6698
- ...projected,
6699
- ...overlay
6700
- } : projected, { inlineSecretsAsViews: true });
7059
+ const projected = await this.readRawProjectedStore(nodeId, cap);
7060
+ return hydrateSchema(schema, overlay ? await this.overlayKeepingMarkers(projected, overlay) : projected, { inlineSecretsAsViews: true });
6701
7061
  }
6702
7062
  /**
6703
7063
  * The integration-level view of this addon's settings: exactly the sections
@@ -6742,7 +7102,7 @@ var BaseAddon = class {
6742
7102
  });
6743
7103
  }
6744
7104
  if (sections.length === 0) return null;
6745
- const projected = await this.resolveGlobalStore(nodeId);
7105
+ const projected = await this.readRawProjectedStore(nodeId);
6746
7106
  return hydrateSchema({
6747
7107
  ...schema,
6748
7108
  sections
@@ -6759,12 +7119,50 @@ var BaseAddon = class {
6759
7119
  * the store for custom option logic (option narrowing, value snapping) to
6760
7120
  * read it per-node — never `ctx.settings.readAddonStore()` directly.
6761
7121
  * `nodeId` omitted ⇒ the local node (node-blind injection from ctx).
7122
+ *
7123
+ * Keychain values come back RESOLVED (D798): a secret reads as its value,
7124
+ * never as a `{ $secret }` marker. One the keychain cannot serve right now
7125
+ * stays a marker — "stored, unavailable" (`isSecretMarker()` is true, and it
7126
+ * is listed in {@link unresolvedSecrets}) — never `''` and never absent, so
7127
+ * it cannot be mistaken for "nothing stored, mint a new one". Writing the
7128
+ * resolved blob back is a no-op for every unchanged secret.
6762
7129
  */
6763
7130
  async resolveGlobalStore(nodeId, cap) {
6764
7131
  const raw = await this._ctx?.settings?.readAddonStore() ?? {};
7132
+ return this.projectForNode(raw, nodeId, cap);
7133
+ }
7134
+ projectForNode(store, nodeId, cap) {
6765
7135
  const keys = this.perNodeKeys(cap);
6766
7136
  const node = normalizeNodeId(nodeId ?? this._ctx?.kernel?.localNodeId);
6767
- return keys.size > 0 ? projectStore(raw, keys, node) : raw;
7137
+ return keys.size > 0 ? projectStore(store, keys, node) : store;
7138
+ }
7139
+ /** The PROJECTED store with its markers — the form hydrate only (D798). */
7140
+ async readRawProjectedStore(nodeId, cap) {
7141
+ const raw = await this.rawSettings()?.readAddonStore() ?? {};
7142
+ return this.projectForNode(raw, nodeId, cap);
7143
+ }
7144
+ /**
7145
+ * `{ ...stored, ...overlay }`, except that an overlay member equal to the
7146
+ * RESOLVED stored one keeps the stored (marker-bearing) member — so a form
7147
+ * hydrated from a resolved overlay still shows a secret as "set", never as
7148
+ * its value.
7149
+ */
7150
+ async overlayKeepingMarkers(stored, overlay) {
7151
+ const secrets = this._ctx?.secrets;
7152
+ const merged = {
7153
+ ...stored,
7154
+ ...overlay
7155
+ };
7156
+ if (secrets === void 0 || collectSecretMarkerRefs(stored).length === 0) return merged;
7157
+ const { value: resolved } = await resolveSecretMarkers(stored, secrets, {
7158
+ unresolved: "keep-marker",
7159
+ ownedBy: secrets.owner
7160
+ });
7161
+ for (const key of Object.keys(overlay)) {
7162
+ if (collectSecretMarkerRefs(stored[key]).length === 0) continue;
7163
+ if (isJsonEqual(overlay[key], resolved[key])) merged[key] = stored[key];
7164
+ }
7165
+ return merged;
6768
7166
  }
6769
7167
  /**
6770
7168
  * Whether ONE global key of this addon's store was written, read three-way
@@ -6829,8 +7227,12 @@ var BaseAddon = class {
6829
7227
  async clearSecrets(keys, nodeId) {
6830
7228
  const tree = this.addonSecretTree();
6831
7229
  const keychain = this._ctx?.secrets !== void 0;
7230
+ const stored = keychain ? await this.readAddonStoreWithRetry() : {};
6832
7231
  const patch = {};
6833
- for (const key of keys) patch[key] = keychain && tree.has(key) ? SECRET_CLEAR : "";
7232
+ for (const key of keys) {
7233
+ const keychainStored = tree.has(key) || collectSecretMarkerRefs(stored[key]).length > 0;
7234
+ patch[key] = keychain && keychainStored ? SECRET_CLEAR : "";
7235
+ }
6834
7236
  await this.applyGlobalPatch(patch, nodeId);
6835
7237
  }
6836
7238
  async applyGlobalPatch(barePatch, nodeId) {
@@ -6838,7 +7240,11 @@ var BaseAddon = class {
6838
7240
  const localNode = normalizeNodeId(this._ctx?.kernel?.localNodeId);
6839
7241
  const target = normalizeNodeId(nodeId ?? this._ctx?.kernel?.localNodeId);
6840
7242
  const scoped = keys.size > 0 ? scopePatch(barePatch, keys, target) : barePatch;
6841
- await this._ctx?.settings?.writeAddonStore(scoped);
7243
+ const handle = this._secretSettings;
7244
+ if (handle !== null) {
7245
+ const { changed } = await handle.writeAddonStore(scoped);
7246
+ if (!changed) return;
7247
+ } else await this._ctx?.settings?.writeAddonStore(scoped);
6842
7248
  if (target !== localNode) return;
6843
7249
  await this.resolveConfig();
6844
7250
  await this.onConfigChanged();
@@ -6891,7 +7297,7 @@ var BaseAddon = class {
6891
7297
  async getDeviceSettings(deviceId) {
6892
7298
  const schema = this.deviceSettingsSchema();
6893
7299
  if (!schema) return { sections: [] };
6894
- return hydrateSchema(schema, await this._ctx?.settings?.readDeviceStore(deviceId) ?? {}, { inlineSecretsAsViews: true });
7300
+ return hydrateSchema(schema, await this.rawSettings()?.readDeviceStore(deviceId) ?? {}, { inlineSecretsAsViews: true });
6895
7301
  }
6896
7302
  async updateDeviceSettings(deviceId, patch) {
6897
7303
  await this._ctx?.settings?.writeDeviceStore(deviceId, patch);
@@ -7063,7 +7469,7 @@ var BaseAddon = class {
7063
7469
  key,
7064
7470
  schema,
7065
7471
  fallback,
7066
- read: async () => this.resolveStoredSecrets(await this._ctx?.settings?.readDeviceStore(deviceId) ?? {}, false),
7472
+ read: async () => this.resolveStoredSecrets(await this.rawSettings()?.readDeviceStore(deviceId) ?? {}, false),
7067
7473
  write: async (patch) => {
7068
7474
  await this._ctx?.settings?.writeDeviceStore(deviceId, patch);
7069
7475
  },
@@ -7125,6 +7531,23 @@ var BaseAddon = class {
7125
7531
  }
7126
7532
  return value;
7127
7533
  }
7534
+ /**
7535
+ * The marker-bearing settings reads (D798) — private on purpose. Without a
7536
+ * keychain the context's own view is already raw.
7537
+ */
7538
+ rawSettings() {
7539
+ return this._secretSettings?.raw ?? this._ctx?.settings;
7540
+ }
7541
+ /** An addon-facing read met markers it could not resolve: say so once per ref. */
7542
+ logUnresolvedRead(unresolved) {
7543
+ const fresh = unresolved.filter((u) => !this._loggedUnresolvedReads.has(u.ref));
7544
+ if (fresh.length === 0) return;
7545
+ for (const u of fresh) this._loggedUnresolvedReads.add(u.ref);
7546
+ 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) => ({
7547
+ ref: u.ref,
7548
+ reason: u.reason
7549
+ })) } });
7550
+ }
7128
7551
  /** Re-resolve the config (a keychain-only change, or a retry) and apply it. */
7129
7552
  scheduleSecretReresolve(delayMs) {
7130
7553
  const timerOf = delayMs === SECRET_CHANGE_DEBOUNCE_MS ? "_secretChangeTimer" : "_secretRetryTimer";
@@ -7151,7 +7574,7 @@ var BaseAddon = class {
7151
7574
  * `{}` (defaults) — the addon's first successful patch will rehydrate.
7152
7575
  */
7153
7576
  async readAddonStoreWithRetry() {
7154
- const settings = this._ctx?.settings;
7577
+ const settings = this.rawSettings();
7155
7578
  if (!settings) return {};
7156
7579
  const delaysMs = [
7157
7580
  150,
@@ -9387,6 +9810,278 @@ var CameraSwitchGroupSchema = object({
9387
9810
  fetchedAt: number()
9388
9811
  });
9389
9812
  /**
9813
+ * The trainer contract — what the hub hands the cloud trainer and what it
9814
+ * gets back (cloud training, D805+).
9815
+ *
9816
+ * The trainer (`hf/camstack-trainer`, published as the Hugging Face repo
9817
+ * `camstack/camstack-trainer`) is a separate AGPL program the hub never
9818
+ * imports: `job.json` goes in, files come out, and progress is `CAMSTACK_EVENT`
9819
+ * lines on stdout. These schemas are the hub's half of that boundary; the
9820
+ * trainer's pydantic models (and the JSON Schemas generated from them under
9821
+ * `hf/camstack-trainer/schemas/`) are the other half. A change here is a
9822
+ * change there, in the same piece of work.
9823
+ *
9824
+ * No `.default()` anywhere: defaults do not run on the addon cap path, so the
9825
+ * orchestrator fills every field of a job spec explicitly.
9826
+ */
9827
+ var TRAINING_JOB_SCHEMA = "camstack.training/v1";
9828
+ var TRAINING_RESULT_SCHEMA = "camstack.training-result/v1";
9829
+ /** What the trainer can export. Edge TPU is a later, separate image. */
9830
+ var TrainingExportSchema = _enum([
9831
+ "onnx",
9832
+ "openvino-fp16",
9833
+ "openvino-int8",
9834
+ "coreml-fp16"
9835
+ ]);
9836
+ var FloorsSchema = record(string(), number().min(0).max(1));
9837
+ object({
9838
+ schema: literal(TRAINING_JOB_SCHEMA),
9839
+ jobKey: string().uuid(),
9840
+ target: object({
9841
+ kind: literal("detector"),
9842
+ step: literal("object-detection")
9843
+ }),
9844
+ base: object({
9845
+ modelId: string().min(1),
9846
+ /** Ultralytics weights id, e.g. `yolov9m.pt`. */
9847
+ weights: string().min(1),
9848
+ imgsz: number().int().positive()
9849
+ }),
9850
+ baseline: object({
9851
+ modelId: string().min(1),
9852
+ /** The baseline ONNX the holdout comparison runs; public mirror URL. */
9853
+ onnxUrl: string().url(),
9854
+ imgsz: number().int().positive(),
9855
+ floors: FloorsSchema
9856
+ }),
9857
+ dataset: object({
9858
+ versionId: string().min(1),
9859
+ annotationHash: string(),
9860
+ /** sha256 of the uploaded archive; the trainer refuses a mismatch (exit 65). */
9861
+ sha256: string().regex(/^[0-9a-f]{64}$/)
9862
+ }),
9863
+ split: object({
9864
+ holdoutCameras: array(number().int()),
9865
+ /** When no camera is held out: the last N days of every camera. */
9866
+ holdoutLastDays: number().int().nonnegative(),
9867
+ valFraction: number().min(0).max(.5),
9868
+ seed: number().int()
9869
+ }),
9870
+ hyper: object({
9871
+ epochs: number().int().positive(),
9872
+ batch: number().int().positive(),
9873
+ lr0: number().positive(),
9874
+ /** Layers frozen from the start of the backbone; 0 = none. */
9875
+ freeze: number().int().nonnegative(),
9876
+ patience: number().int().nonnegative(),
9877
+ seed: number().int()
9878
+ }),
9879
+ replay: object({
9880
+ source: literal("coco2017"),
9881
+ count: number().int().nonnegative()
9882
+ }),
9883
+ exports: array(TrainingExportSchema).min(1),
9884
+ calibration: object({ maxFrames: number().int().positive() }),
9885
+ floors: object({
9886
+ minSupport: number().int().positive(),
9887
+ clamp: number().min(0).max(1)
9888
+ }),
9889
+ int8Gate: object({ maxMap50Drop: number().min(0).max(1) }),
9890
+ catalog: object({
9891
+ id: string().regex(/^[a-z0-9][a-z0-9-]{2,80}$/),
9892
+ name: string().min(1).max(160)
9893
+ })
9894
+ });
9895
+ /** One regular file of the bundle. An mlpackage contributes one row per member. */
9896
+ var TrainingResultFileSchema = object({
9897
+ path: string().min(1),
9898
+ bytes: number().int().nonnegative(),
9899
+ sha256: string().regex(/^[0-9a-f]{64}$/),
9900
+ format: _enum([
9901
+ "onnx",
9902
+ "openvino",
9903
+ "coreml",
9904
+ "pt"
9905
+ ]),
9906
+ variant: _enum(["base", "int8"])
9907
+ });
9908
+ var DraftFormatSchema = object({
9909
+ /** RELATIVE path inside the bundle; the hub rewrites it to `camstack-local://`. */
9910
+ url: string().min(1),
9911
+ sizeMB: number().nonnegative(),
9912
+ isDirectory: boolean().optional(),
9913
+ files: array(string()).optional(),
9914
+ runtimes: array(literal("python")).optional(),
9915
+ revision: string().min(1)
9916
+ });
9917
+ /** The trainer's half of a catalog entry; the hub completes it (labels, licence, group). */
9918
+ var TrainingCatalogDraftSchema = object({
9919
+ id: string().min(1),
9920
+ name: string().min(1),
9921
+ description: string(),
9922
+ labels: array(unknown()),
9923
+ inputSize: object({
9924
+ width: number().int().positive(),
9925
+ height: number().int().positive()
9926
+ }),
9927
+ preprocessMode: literal("letterbox"),
9928
+ defaultClassFloors: FloorsSchema,
9929
+ formats: object({
9930
+ onnx: DraftFormatSchema.optional(),
9931
+ openvino: DraftFormatSchema.optional(),
9932
+ coreml: DraftFormatSchema.optional()
9933
+ })
9934
+ });
9935
+ /** One class of one model's holdout report (the eval harness's summary). */
9936
+ var TrainingEvalClassSchema = object({
9937
+ positives: number().int(),
9938
+ floor: number().nullable(),
9939
+ tp: number().int(),
9940
+ fp: number().int(),
9941
+ fn: number().int(),
9942
+ precision: number().nullable(),
9943
+ recall: number().nullable(),
9944
+ ap50: number().nullable(),
9945
+ recallByCamera: record(string(), number().nullable()).optional(),
9946
+ recallByLight: record(string(), number().nullable()).optional(),
9947
+ fpByCamera: record(string(), number()).optional(),
9948
+ smallFound: number().int().optional(),
9949
+ smallTotal: number().int().optional()
9950
+ }).passthrough();
9951
+ var TrainingEvalReportSchema = object({
9952
+ frames: number().int(),
9953
+ classes: record(string(), TrainingEvalClassSchema)
9954
+ }).passthrough();
9955
+ /**
9956
+ * A succeeded result carries every block; a failed one carries the error and
9957
+ * whatever was known by then — the other blocks are ABSENT, not null. The
9958
+ * orchestrator checks the blocks it needs before it trusts a success.
9959
+ */
9960
+ var TrainingResultSchema = object({
9961
+ schema: literal(TRAINING_RESULT_SCHEMA),
9962
+ jobKey: string(),
9963
+ status: _enum(["succeeded", "failed"]),
9964
+ error: object({
9965
+ stage: string(),
9966
+ code: string(),
9967
+ message: string()
9968
+ }).nullable(),
9969
+ trainer: object({
9970
+ version: string(),
9971
+ revision: string()
9972
+ }),
9973
+ toolchain: record(string(), string().nullable()),
9974
+ dataset: object({
9975
+ versionId: string(),
9976
+ annotationHash: string(),
9977
+ sha256: string(),
9978
+ frames: object({
9979
+ train: number().int(),
9980
+ val: number().int(),
9981
+ holdout: number().int()
9982
+ }),
9983
+ holdoutCameras: array(number().int()),
9984
+ replayImages: number().int()
9985
+ }).optional(),
9986
+ training: object({
9987
+ epochsRun: number().int(),
9988
+ bestEpoch: number().int(),
9989
+ bestMap50: number(),
9990
+ bestMap50_95: number(),
9991
+ seconds: number()
9992
+ }).optional(),
9993
+ evaluation: object({
9994
+ holdoutFrames: number().int(),
9995
+ baseline: TrainingEvalReportSchema.nullable(),
9996
+ candidate: TrainingEvalReportSchema.nullable(),
9997
+ candidateInt8: TrainingEvalReportSchema.nullable(),
9998
+ recallDeltaByCamera: record(string(), record(string(), number())).nullable(),
9999
+ map50: record(string(), number().nullable())
10000
+ }).optional(),
10001
+ floors: object({
10002
+ baseline: FloorsSchema,
10003
+ candidate: FloorsSchema,
10004
+ candidateInt8: FloorsSchema.nullable(),
10005
+ notes: array(string())
10006
+ }).optional(),
10007
+ int8: object({
10008
+ kept: boolean(),
10009
+ map50Fp16: number().nullable(),
10010
+ map50Int8: number().nullable(),
10011
+ reason: string().nullable()
10012
+ }).optional(),
10013
+ exportsDropped: array(object({
10014
+ export: string(),
10015
+ reason: string()
10016
+ })).optional(),
10017
+ files: array(TrainingResultFileSchema).optional(),
10018
+ bundle: object({
10019
+ path: literal("bundle.tar"),
10020
+ bytes: number().int().nonnegative(),
10021
+ sha256: string().regex(/^[0-9a-f]{64}$/)
10022
+ }).nullable().optional(),
10023
+ catalogDraft: object({
10024
+ base: TrainingCatalogDraftSchema,
10025
+ int8: TrainingCatalogDraftSchema.nullable()
10026
+ }).nullable().optional(),
10027
+ licence: string()
10028
+ });
10029
+ var TrainingStageSchema = _enum([
10030
+ "prepare",
10031
+ "replay",
10032
+ "train",
10033
+ "eval",
10034
+ "export",
10035
+ "package"
10036
+ ]);
10037
+ var EventBase = {
10038
+ v: literal(1),
10039
+ ts: number()
10040
+ };
10041
+ discriminatedUnion("type", [
10042
+ object({
10043
+ ...EventBase,
10044
+ type: literal("stage"),
10045
+ stage: TrainingStageSchema
10046
+ }),
10047
+ object({
10048
+ ...EventBase,
10049
+ type: literal("epoch"),
10050
+ epoch: number().int(),
10051
+ epochs: number().int(),
10052
+ boxLoss: number().nullable().optional(),
10053
+ map50: number().nullable().optional(),
10054
+ map50_95: number().nullable().optional(),
10055
+ etaSec: number().nullable().optional()
10056
+ }),
10057
+ object({
10058
+ ...EventBase,
10059
+ type: literal("metric"),
10060
+ name: string(),
10061
+ value: number()
10062
+ }),
10063
+ object({
10064
+ ...EventBase,
10065
+ type: literal("artifact"),
10066
+ path: string(),
10067
+ bytes: number(),
10068
+ sha256: string()
10069
+ }),
10070
+ object({
10071
+ ...EventBase,
10072
+ type: literal("done"),
10073
+ status: _enum(["succeeded", "failed"]),
10074
+ resultSha256: string().nullable().optional()
10075
+ }),
10076
+ object({
10077
+ ...EventBase,
10078
+ type: literal("error"),
10079
+ stage: string(),
10080
+ code: string(),
10081
+ message: string()
10082
+ })
10083
+ ]);
10084
+ /**
9390
10085
  * What the gate decided about a birth, from the CALLER's point of view.
9391
10086
  *
9392
10087
  * Deliberately not `ConfirmationVerdict`: `undecided` is not a birth decision
@@ -11714,7 +12409,9 @@ var AddonHttpRouteSchema = object({
11714
12409
  "authenticated",
11715
12410
  "admin"
11716
12411
  ]).optional(),
11717
- description: string().optional()
12412
+ description: string().optional(),
12413
+ /** The hub limits this route per client address before the handler runs. */
12414
+ rateLimit: _enum(["auth"]).optional()
11718
12415
  });
11719
12416
  /**
11720
12417
  * Cross-process route invocation envelope. The hub captures the
@@ -12419,6 +13116,37 @@ var BackupDestinationInfoSchema = object({
12419
13116
  lastError: string().optional()
12420
13117
  });
12421
13118
  /**
13119
+ * How an archive is encrypted (operator decision 2026-10-09): to a backup
13120
+ * PUBLIC key the hub holds, so only the operator's secret key opens it.
13121
+ * Absent on a plain `.tar.gz` — every archive made before encryption, or
13122
+ * with it off — which restores without a key.
13123
+ */
13124
+ var BackupArchiveEncryptionSchema = object({
13125
+ /** `x25519-hkdf-aes256gcm-stream-v1`. */
13126
+ scheme: string(),
13127
+ /** 16 hex — the backup key whose secret restores this archive. */
13128
+ keyId: string()
13129
+ });
13130
+ /**
13131
+ * The backup encryption setting. The hub keeps PUBLIC keys only: the active
13132
+ * one new archives are encrypted to, and the retired ones older archives
13133
+ * still need. The secret key is shown once, at `setupEncryption`.
13134
+ */
13135
+ var BackupEncryptionStatusSchema = object({
13136
+ enabled: boolean(),
13137
+ active: object({
13138
+ keyId: string(),
13139
+ publicKey: string(),
13140
+ createdAt: number()
13141
+ }).nullable(),
13142
+ /** Every key ever set up, newest first. */
13143
+ keys: array(object({
13144
+ keyId: string(),
13145
+ createdAt: number(),
13146
+ retiredAt: number().nullable()
13147
+ })).readonly()
13148
+ });
13149
+ /**
12422
13150
  * Per-archive entry returned by `backup.listArchives({ destinationId })`.
12423
13151
  * Same shape the destination drill-in renders. Sourced from the per-
12424
13152
  * location `manifests.json` (no per-archive tarball read required).
@@ -12430,7 +13158,9 @@ var BackupArchiveEntrySchema = object({
12430
13158
  sizeBytes: number(),
12431
13159
  label: string().optional(),
12432
13160
  /** Top-level locations included in the archive (db, addons, tls, …). */
12433
- locations: array(string()).readonly()
13161
+ locations: array(string()).readonly(),
13162
+ /** Present when the archive is encrypted; restore then needs that key. */
13163
+ encryption: BackupArchiveEncryptionSchema.optional()
12434
13164
  });
12435
13165
  var BackupEntrySchema = object({
12436
13166
  id: string(),
@@ -12439,7 +13169,8 @@ var BackupEntrySchema = object({
12439
13169
  label: string().optional(),
12440
13170
  createdAt: number(),
12441
13171
  sizeBytes: number(),
12442
- locations: array(string()).optional()
13172
+ locations: array(string()).optional(),
13173
+ encryption: BackupArchiveEncryptionSchema.optional()
12443
13174
  });
12444
13175
  var ArchiveEntrySchema = object({
12445
13176
  path: string(),
@@ -12628,10 +13359,40 @@ method(_void(), array(BackupDestinationInfoSchema).readonly(), { auth: "admin" }
12628
13359
  * this list and skips entries whose path doesn't start with
12629
13360
  * any of them.
12630
13361
  */
12631
- locations: array(string()).optional()
13362
+ locations: array(string()).optional(),
13363
+ /**
13364
+ * The backup SECRET key, for an encrypted archive (ignored for a plain
13365
+ * one). The archive is decrypted into the hub's private staging
13366
+ * before the restart; the key is not stored. A wrong or missing key
13367
+ * is refused before the archive is downloaded.
13368
+ */
13369
+ backupSecretKey: string().optional()
12632
13370
  }), _void(), {
12633
13371
  kind: "mutation",
12634
13372
  auth: "admin"
13373
+ }), method(_void(), BackupEncryptionStatusSchema, { auth: "admin" }), method(object({}), object({
13374
+ keyId: string(),
13375
+ secretKey: string(),
13376
+ publicKey: string(),
13377
+ createdAt: number(),
13378
+ replacedKeyId: string().nullable()
13379
+ }), {
13380
+ kind: "mutation",
13381
+ auth: "admin"
13382
+ }), method(object({}), object({ disabledKeyId: string().nullable() }), {
13383
+ kind: "mutation",
13384
+ auth: "admin"
13385
+ }), method(object({ backupSecretKey: string() }), object({
13386
+ valid: boolean(),
13387
+ keyId: string().nullable(),
13388
+ /** The hub knows this key (active or retired). */
13389
+ known: boolean(),
13390
+ /** It is the key new archives are encrypted to. */
13391
+ active: boolean(),
13392
+ error: string().optional()
13393
+ }), {
13394
+ kind: "mutation",
13395
+ auth: "admin"
12635
13396
  }), method(object({
12636
13397
  destinationId: string(),
12637
13398
  backupId: string()
@@ -14255,7 +15016,60 @@ var CustomModelDescriptorSchema = object({
14255
15016
  stepId: string(),
14256
15017
  entry: ModelCatalogEntrySchema
14257
15018
  });
14258
- method(_void(), array(CustomModelDescriptorSchema).readonly(), { auth: "admin" });
15019
+ /** One regular file of an imported bundle, as the producer measured it. */
15020
+ var ModelBundleFileSchema = object({
15021
+ /** Relative path inside the bundle tar; an mlpackage member is `<x>.mlpackage/<member>`. */
15022
+ path: string().min(1),
15023
+ bytes: number().int().nonnegative(),
15024
+ sha256: string().regex(/^[0-9a-f]{64}$/)
15025
+ });
15026
+ var ImportModelBundleInputSchema = object({
15027
+ /** The registry provider that keeps the model (Model Studio). */
15028
+ addonId: string(),
15029
+ stepId: string().min(1),
15030
+ /**
15031
+ * The catalog rows to register, complete, every format URL already
15032
+ * `camstack-local://<modelId>/<file>` naming a file of the bundle. One
15033
+ * bundle may carry several rows (a base and its INT8 variant).
15034
+ */
15035
+ entries: array(ModelCatalogEntrySchema).min(1).max(4),
15036
+ /** The bundle tar, offered by the producer over `ctx.peerBytes` (same host). */
15037
+ bundle: object({
15038
+ ticket: PeerBytesTicketSchema,
15039
+ bytes: number().int().positive(),
15040
+ sha256: string().regex(/^[0-9a-f]{64}$/)
15041
+ }),
15042
+ /** Every file the tar must hold; anything missing, extra or different is refused. */
15043
+ files: array(ModelBundleFileSchema).min(1).max(64),
15044
+ /** Convert missing engine formats and push the model to every agent afterwards. */
15045
+ distribute: boolean()
15046
+ });
15047
+ var ImportModelBundleResultSchema = discriminatedUnion("kind", [object({
15048
+ kind: literal("imported"),
15049
+ modelIds: array(string()).readonly(),
15050
+ distributed: array(object({
15051
+ modelId: string(),
15052
+ nodeId: string(),
15053
+ format: _enum(MODEL_FORMATS),
15054
+ ok: boolean(),
15055
+ error: string().optional()
15056
+ })).readonly()
15057
+ }), object({
15058
+ kind: literal("refused"),
15059
+ reason: _enum([
15060
+ "transfer-failed",
15061
+ "checksum-mismatch",
15062
+ "bundle-mismatch",
15063
+ "invalid-entry",
15064
+ "id-taken"
15065
+ ]),
15066
+ detail: string()
15067
+ })]);
15068
+ method(_void(), array(CustomModelDescriptorSchema).readonly(), { auth: "admin" }), method(ImportModelBundleInputSchema, ImportModelBundleResultSchema, {
15069
+ kind: "mutation",
15070
+ auth: "admin",
15071
+ timeoutMs: 30 * 6e4
15072
+ });
14259
15073
  /**
14260
15074
  * Query filter for settings-store collections.
14261
15075
  */
@@ -14734,6 +15548,35 @@ var KeychainKeySourceSchema = object({
14734
15548
  */
14735
15549
  sharesBackupWithDatabase: boolean()
14736
15550
  });
15551
+ /**
15552
+ * One keychain reset, as the Secrets page reports it until the operator
15553
+ * acknowledges it. Never a value: refs, counts and table names only.
15554
+ */
15555
+ var KeychainResetRecordSchema = object({
15556
+ id: string(),
15557
+ at: number(),
15558
+ /** `user:<id>` or {@link KEYCHAIN_RESET_TRIGGER_ACTOR}. */
15559
+ actor: string(),
15560
+ /** Why the keychain was locked when it was reset; `null` when it was not locked. */
15561
+ lockedReason: string().nullable(),
15562
+ /** Values moved into the archive table (ciphertext under the lost key). */
15563
+ archived: number().int(),
15564
+ /** `keychain:secrets-orphaned-<ts>`, or `null` when nothing was stored. */
15565
+ archivedCollection: string().nullable(),
15566
+ /**
15567
+ * `keychain:keys-orphaned-<ts>`: the wrapped data keys of the archive, kept
15568
+ * so the archive can still be opened if the lost master key turns up.
15569
+ */
15570
+ archivedKeysCollection: string().nullable(),
15571
+ /**
15572
+ * `system-settings` keys whose marker the reset cleared — the cluster
15573
+ * secret's: a marker left pointing at an archived value would refuse every
15574
+ * agent forever (D797).
15575
+ */
15576
+ clearedSettingsKeys: array(string()).readonly(),
15577
+ /** When an operator dismissed the notice on the Secrets page; `null` until then. */
15578
+ acknowledgedAt: number().nullable()
15579
+ });
14737
15580
  var KeychainStatusSchema = object({
14738
15581
  keychain: KeychainStateSchema,
14739
15582
  /** The source of the master key in use; `null` while locked. */
@@ -14751,7 +15594,9 @@ var KeychainStatusSchema = object({
14751
15594
  /** Wrapped copies of the data key under a previous master key, kept until purged. */
14752
15595
  retiredWraps: number().int(),
14753
15596
  recoveryKeyDownloadedAt: number().nullable(),
14754
- secretCount: number().int()
15597
+ secretCount: number().int(),
15598
+ /** The most recent reset, acknowledged or not; `null` when the keychain was never reset. */
15599
+ lastReset: KeychainResetRecordSchema.nullable()
14755
15600
  });
14756
15601
  /**
14757
15602
  * Whether a stored value is still pointed at by its owner's settings.
@@ -14773,13 +15618,14 @@ var KeychainAuditActionSchema = _enum([
14773
15618
  "download-recovery-key",
14774
15619
  "delete-orphans",
14775
15620
  "reset",
15621
+ "acknowledge-reset",
14776
15622
  "initialize"
14777
15623
  ]);
14778
15624
  var KeychainAuditEntrySchema = object({
14779
15625
  id: string(),
14780
15626
  at: number(),
14781
15627
  action: KeychainAuditActionSchema,
14782
- /** `addon:<id>` | `user:<id>` | `system`. */
15628
+ /** `addon:<id>` | `user:<id>` | `system` | `trigger-file`. */
14783
15629
  actor: string(),
14784
15630
  ref: string().nullable(),
14785
15631
  detail: string().nullable()
@@ -14845,6 +15691,13 @@ method(object({}), KeychainStatusSchema, { auth: "admin" }), method(object({}),
14845
15691
  kind: "mutation",
14846
15692
  auth: "admin",
14847
15693
  caller: "required"
15694
+ }), method(object({}), object({
15695
+ reset: KeychainResetRecordSchema.nullable(),
15696
+ pendingReentry: array(KeychainSecretMetaSchema).readonly()
15697
+ }), { auth: "admin" }), method(object({}), object({ acknowledged: boolean() }), {
15698
+ kind: "mutation",
15699
+ auth: "admin",
15700
+ caller: "required"
14848
15701
  });
14849
15702
  method(_void(), object({
14850
15703
  id: string(),
@@ -17684,7 +18537,7 @@ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
17684
18537
  * `login-method` — collection cap through which auth addons contribute
17685
18538
  * their pre-auth login surfaces to the login page. This is the SINGLE,
17686
18539
  * generic mechanism that supersedes the dead `auth.listProviders` reader:
17687
- * every auth addon (OIDC, magic-link, WebAuthn/passkey) registers a
18540
+ * every auth addon (OIDC, WebAuthn/passkey) registers a
17688
18541
  * `login-method` provider and the PUBLIC `auth.listLoginMethods`
17689
18542
  * procedure aggregates them for the unauthenticated login page.
17690
18543
  *
@@ -17692,8 +18545,7 @@ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
17692
18545
  *
17693
18546
  * - `redirect` — a declarative button. The login page renders a generic
17694
18547
  * button that navigates to `startUrl` (an addon-owned HTTP route).
17695
- * Covers OIDC (`/addon/auth-oidc/<id>/start`) and magic-link with
17696
- * ZERO shell-side JS. A future SSO addon plugs in the same way — the
18548
+ * Covers OIDC (`/addon/auth-oidc/<id>/start`) with ZERO shell-side JS. A future SSO addon plugs in the same way — the
17697
18549
  * login page needs NO change.
17698
18550
  *
17699
18551
  * - `widget` — a Module-Federation widget the login page mounts (via
@@ -17712,8 +18564,8 @@ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
17712
18564
  * decision.
17713
18565
  *
17714
18566
  * Every contribution carries a `stage`:
17715
- * - `primary` — shown on the first credentials screen (OIDC /
17716
- * magic-link buttons; a future usernameless passkey).
18567
+ * - `primary` — shown on the first credentials screen (OIDC
18568
+ * buttons; a usernameless passkey).
17717
18569
  * - `second-factor` — shown AFTER the password leg, gated on the
17718
18570
  * returned `factors` (passkey-as-2FA today).
17719
18571
  *
@@ -17740,7 +18592,7 @@ var LoginMethodContributionSchema = discriminatedUnion("kind", [
17740
18592
  * The provider names an external identity a signed-in user can link to
17741
18593
  * their own account (D782): `auth.listLinkableProviders` /
17742
18594
  * `beginExternalLink` offer exactly the redirect methods that set this,
17743
- * whatever their id. Absent / false — a login button only (magic-link).
18595
+ * whatever their id. Absent / false — a login button only.
17744
18596
  */
17745
18597
  linkable: boolean().optional()
17746
18598
  }),
@@ -21557,8 +22409,7 @@ method(object({}), object({ rules: array(NcRuleSchema) }), { auth: "admin" }), m
21557
22409
  * `super_admin` — collapsed onto the single boolean because every
21558
22410
  * non-admin caller is governed by the same scope-check rules; the
21559
22411
  * distinction was only ever used to route role-specific procedures
21560
- * which we no longer have. Agents are admin sessions issued via
21561
- * `createServiceToken`; CLI / webhook integrations are `cst_*` tokens
22412
+ * which we no longer have. CLI / webhook integrations are `cst_*` tokens
21562
22413
  * with `isAdmin: false` + an explicit scope list.
21563
22414
  */
21564
22415
  /** Per-method access flavour. Materialised on every cap method via codegen. */
@@ -24253,6 +25104,17 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
24253
25104
  kind: "mutation",
24254
25105
  auth: "admin",
24255
25106
  timeoutMs: 60 * 6e4
25107
+ }), method(object({
25108
+ filter: RetrainExportFilterSchema,
25109
+ layout: RetrainExportLayoutSchema
25110
+ }), object({
25111
+ ticket: PeerBytesTicketSchema,
25112
+ frames: number().int(),
25113
+ annotations: number().int()
25114
+ }), {
25115
+ kind: "mutation",
25116
+ auth: "admin",
25117
+ timeoutMs: 12e4
24256
25118
  }), method(object({
24257
25119
  selection: RetrainDatasetSelectionSchema,
24258
25120
  completeOnly: boolean().optional()
@@ -27821,8 +28683,8 @@ version: string().optional() }), ServerUpdateActionResultSchema, {
27821
28683
  * `smtp-provider` — pluggable email delivery surface.
27822
28684
  *
27823
28685
  * Collection cap: a deployment may install multiple SMTP relays (e.g.
27824
- * one for transactional / one for notifications). Consumers (magic-link,
27825
- * notifier addons, …) walk the collection and pick the first
28686
+ * one for transactional / one for notifications). Consumers (notifier
28687
+ * addons, …) walk the collection and pick the first
27826
28688
  * ready provider OR target a specific addonId.
27827
28689
  *
27828
28690
  * The shape stays small on purpose — `sendEmail` is enough for the
@@ -28105,7 +28967,7 @@ targets: array(object({
28105
28967
  };
28106
28968
  /**
28107
28969
  * `sso-bridge` — internal hub-only cap that lets SSO-style auth
28108
- * providers (OIDC, SAML, magic-link, …) mint an HMAC-signed token
28970
+ * providers (OIDC, SAML, …) mint an HMAC-signed token
28109
28971
  * carrying the post-callback claims before redirecting back to
28110
28972
  * `/api/auth/sso/finish`.
28111
28973
  *
@@ -28168,7 +29030,14 @@ var SsoBridgeClaimsSchema = object({
28168
29030
  * Verified `iss` of the id_token behind an OIDC login bridge (D782). A
28169
29031
  * subject is unique only per issuer, so a link is bound to it.
28170
29032
  */
28171
- issuer: string().optional()
29033
+ issuer: string().optional(),
29034
+ /**
29035
+ * SHA-256 (hex) of the `camstack_sso_state` cookie the IdP `/start` set in
29036
+ * the browser that began this sign-in. `/api/auth/sso/finish` requires the
29037
+ * request to present the matching cookie — a login bridge is useless in
29038
+ * any other browser.
29039
+ */
29040
+ browserBinding: string().optional()
28172
29041
  });
28173
29042
  method(object({
28174
29043
  claims: SsoBridgeClaimsSchema,
@@ -38180,16 +39049,6 @@ var ApiKeySummarySchema = object({
38180
39049
  createdAt: number(),
38181
39050
  lastUsedAt: number().optional()
38182
39051
  });
38183
- var CreateApiKeyInputSchema = object({
38184
- label: string(),
38185
- isAdmin: boolean().default(false),
38186
- allowedProviders: union([array(string()), literal("*")]).optional(),
38187
- allowedDevices: record(string(), union([array(string()), literal("*")])).optional()
38188
- });
38189
- var CreateApiKeyResultSchema = object({
38190
- token: string(),
38191
- record: ApiKeySummarySchema
38192
- });
38193
39052
  var ScopedTokenSummarySchema = object({
38194
39053
  id: string(),
38195
39054
  userId: string(),
@@ -38288,17 +39147,10 @@ method(_void(), array(UserSummarySchema), { auth: "admin" }), method(CreateUserI
38288
39147
  }), UserSummarySchema.extend({ passwordHash: string() }).nullable(), {
38289
39148
  kind: "mutation",
38290
39149
  access: "view"
38291
- }), method(_void(), array(ApiKeySummarySchema), { auth: "admin" }), method(CreateApiKeyInputSchema, CreateApiKeyResultSchema, {
38292
- kind: "mutation",
38293
- auth: "admin",
38294
- access: "create"
38295
- }), method(object({ id: string() }), object({ success: literal(true) }), {
39150
+ }), method(_void(), array(ApiKeySummarySchema), { auth: "admin" }), method(object({ id: string() }), object({ success: literal(true) }), {
38296
39151
  kind: "mutation",
38297
39152
  auth: "admin",
38298
39153
  access: "delete"
38299
- }), method(object({ token: string() }), ApiKeySummarySchema.nullable(), {
38300
- kind: "mutation",
38301
- access: "view"
38302
39154
  }), method(CreateScopedTokenInputSchema, CreateScopedTokenResultSchema, {
38303
39155
  kind: "mutation",
38304
39156
  auth: "admin",
@@ -38372,15 +39224,7 @@ method(_void(), array(UserSummarySchema), { auth: "admin" }), method(CreateUserI
38372
39224
  }).nullable(), { access: "view" }), method(object({ userId: string() }), array(ExternalIdentitySchema), { auth: "admin" }), method(ExternalIdentityKeySchema, object({
38373
39225
  userId: string(),
38374
39226
  issuer: string()
38375
- }).nullable(), { auth: "admin" }), method(ExternalIdentityKeySchema.extend({
38376
- userId: string(),
38377
- issuer: string().min(1),
38378
- label: string().optional()
38379
- }), object({ success: literal(true) }), {
38380
- kind: "mutation",
38381
- auth: "admin",
38382
- access: "create"
38383
- }), method(ExternalIdentityKeySchema.extend({ userId: string() }), object({ success: boolean() }), {
39227
+ }).nullable(), { auth: "admin" }), method(ExternalIdentityKeySchema.extend({ userId: string() }), object({ success: boolean() }), {
38384
39228
  kind: "mutation",
38385
39229
  auth: "admin",
38386
39230
  access: "delete"
@@ -38775,6 +39619,451 @@ DeviceType.Camera, method(object({
38775
39619
  detection: array(ZoneRuleSchema).readonly(),
38776
39620
  package: array(ZoneRuleSchema).readonly()
38777
39621
  });
39622
+ /**
39623
+ * `training-provider` — ONE cloud that can run the CamStack trainer.
39624
+ *
39625
+ * A thin, mockable translation layer: it knows how to run a container with a
39626
+ * GPU, move a dataset in, read the job's stdout and hand artefacts back. It
39627
+ * knows nothing about datasets, splits, floors, cost policy or Model Studio —
39628
+ * those are the `training` orchestrator's (D805). Every rule written there
39629
+ * once is what makes a second provider (RunPod, a local NVIDIA node) a new
39630
+ * manifest entry and nothing else.
39631
+ *
39632
+ * Collection, routed by the `addonId` in every single-row input (the `llm` /
39633
+ * `notification-output` posture); `describe` concat-fans across providers.
39634
+ * Every method is `admin`: these spend money.
39635
+ *
39636
+ * Every cloud object a provider creates is tagged with the orchestrator's
39637
+ * `jobKey`, so a retried submit finds the job it already started instead of
39638
+ * starting a second GPU, and `listJobs` can find orphans.
39639
+ *
39640
+ * Bytes never ride a cap field: the dataset arrives as a `ctx.peerBytes`
39641
+ * ticket the producer (pipeline-analytics) minted, and artefacts leave as a
39642
+ * ticket the provider mints (D613).
39643
+ */
39644
+ var TrainingGpuOptionSchema = object({
39645
+ id: string(),
39646
+ label: string(),
39647
+ /** List price, USD per GPU-hour, before any region multiplier. */
39648
+ usdPerHour: number().nonnegative(),
39649
+ vramGb: number().nonnegative()
39650
+ });
39651
+ var TrainingRegionOptionSchema = object({
39652
+ /** `''` = any region (the provider's choice). */
39653
+ id: string(),
39654
+ label: string(),
39655
+ priceMultiplier: number().positive()
39656
+ });
39657
+ /**
39658
+ * The provider's per-account settings, as the orchestrator reads them. They
39659
+ * live in the PROVIDER addon's settings (operator decision 2026-10-08: they
39660
+ * depend on the user's account), never hard-coded in the orchestrator.
39661
+ */
39662
+ var TrainingProviderDefaultsSchema = object({
39663
+ gpuType: string(),
39664
+ region: string(),
39665
+ costCapUsd: number().nonnegative(),
39666
+ maxRuntimeSec: number().int().positive(),
39667
+ /** Hours a FAILED job's cloud dataset is kept for debugging; 0 = delete at once. */
39668
+ failedDatasetGraceHours: number().nonnegative()
39669
+ });
39670
+ var TrainingProviderDescriptorSchema = object({
39671
+ addonId: string(),
39672
+ /** `modal`, `runpod`, `fake`, … */
39673
+ kind: string(),
39674
+ label: string(),
39675
+ gpuTypes: array(TrainingGpuOptionSchema).readonly(),
39676
+ regions: array(TrainingRegionOptionSchema).readonly(),
39677
+ maxDatasetBytes: number().int().positive(),
39678
+ maxRuntimeSec: number().int().positive(),
39679
+ freeTierNote: string().optional(),
39680
+ /** Where the data goes, in one sentence the confirm dialog repeats. */
39681
+ dataResidencyNote: string(),
39682
+ /** Credentials are present — never the values. */
39683
+ configured: boolean(),
39684
+ defaults: TrainingProviderDefaultsSchema
39685
+ });
39686
+ var TrainingCredentialCheckSchema = object({
39687
+ ok: boolean(),
39688
+ /** Workspace / account name, when the provider says. */
39689
+ account: string().optional(),
39690
+ reason: _enum([
39691
+ "missing",
39692
+ "invalid",
39693
+ "forbidden",
39694
+ "network",
39695
+ "quota"
39696
+ ]).optional(),
39697
+ detail: string().optional()
39698
+ });
39699
+ var ProviderJobStateSchema = _enum([
39700
+ "pending",
39701
+ "starting",
39702
+ "running",
39703
+ "succeeded",
39704
+ "failed",
39705
+ "cancelled",
39706
+ "lost"
39707
+ ]);
39708
+ var ProviderJobStatusSchema = object({
39709
+ jobKey: string(),
39710
+ providerJobId: string().optional(),
39711
+ state: ProviderJobStateSchema,
39712
+ startedAt: number().optional(),
39713
+ endedAt: number().optional(),
39714
+ exitCode: number().int().optional(),
39715
+ failureReason: string().optional(),
39716
+ gpuType: string(),
39717
+ region: string().optional(),
39718
+ billedSeconds: number().nonnegative(),
39719
+ costUsd: number().nonnegative(),
39720
+ /** True when `costUsd` is runtime × list price, not a billing answer. */
39721
+ costIsEstimate: boolean(),
39722
+ lastFetchedAt: number()
39723
+ });
39724
+ /**
39725
+ * The trainer the job runs, by SOURCE revision: the provider turns it into an
39726
+ * image its own way (Modal builds the published Dockerfile at that revision;
39727
+ * a registry-pull provider maps it to a tag). Recorded on the job and echoed
39728
+ * in `result.json`.
39729
+ */
39730
+ var TrainerSourceRefSchema = object({
39731
+ /** Hugging Face repo id, e.g. `camstack/camstack-trainer`. */
39732
+ repo: string().min(1),
39733
+ /** A commit sha (never a branch) — the job must be reproducible. */
39734
+ revision: string().regex(/^[0-9a-f]{7,64}$/)
39735
+ });
39736
+ var JobRef = {
39737
+ addonId: string(),
39738
+ jobKey: string().uuid()
39739
+ };
39740
+ var TrainingLogLineSchema = object({
39741
+ ts: number(),
39742
+ text: string()
39743
+ });
39744
+ method(object({}), array(TrainingProviderDescriptorSchema).readonly(), { auth: "admin" }), method(object({ addonId: string() }), TrainingCredentialCheckSchema, {
39745
+ kind: "mutation",
39746
+ auth: "admin",
39747
+ timeoutMs: 3e4
39748
+ }), method(object({
39749
+ addonId: string(),
39750
+ gpuType: string(),
39751
+ region: string(),
39752
+ datasetBytes: number().int().nonnegative(),
39753
+ gpuSecondsLow: number().nonnegative(),
39754
+ gpuSecondsHigh: number().nonnegative()
39755
+ }), object({
39756
+ usdLow: number().nonnegative(),
39757
+ usdHigh: number().nonnegative(),
39758
+ notes: array(string()).readonly()
39759
+ }), { auth: "admin" }), method(object({
39760
+ ...JobRef,
39761
+ ticket: PeerBytesTicketSchema
39762
+ }), object({
39763
+ bytes: number().int().nonnegative(),
39764
+ sha256: string()
39765
+ }), {
39766
+ kind: "mutation",
39767
+ auth: "admin",
39768
+ timeoutMs: 120 * 6e4
39769
+ }), method(object({
39770
+ ...JobRef,
39771
+ trainer: TrainerSourceRefSchema,
39772
+ jobSpecJson: string().min(2).max(64e3),
39773
+ gpuType: string(),
39774
+ region: string(),
39775
+ maxRuntimeSec: number().int().positive()
39776
+ }), ProviderJobStatusSchema, {
39777
+ kind: "mutation",
39778
+ auth: "admin",
39779
+ timeoutMs: 30 * 6e4
39780
+ }), method(object(JobRef), ProviderJobStatusSchema, {
39781
+ auth: "admin",
39782
+ timeoutMs: 6e4
39783
+ }), method(object({
39784
+ ...JobRef,
39785
+ cursor: string().optional(),
39786
+ max: number().int().min(1).max(500)
39787
+ }), object({
39788
+ lines: array(TrainingLogLineSchema).readonly(),
39789
+ cursor: string()
39790
+ }), {
39791
+ auth: "admin",
39792
+ timeoutMs: 6e4
39793
+ }), method(object(JobRef), object({ ok: literal(true) }), {
39794
+ kind: "mutation",
39795
+ auth: "admin",
39796
+ timeoutMs: 6e4
39797
+ }), method(object(JobRef), object({
39798
+ found: boolean(),
39799
+ text: string().optional()
39800
+ }), {
39801
+ kind: "mutation",
39802
+ auth: "admin",
39803
+ timeoutMs: 5 * 6e4
39804
+ }), method(object({
39805
+ ...JobRef,
39806
+ path: _enum(["bundle.tar"])
39807
+ }), object({ ticket: PeerBytesTicketSchema }), {
39808
+ kind: "mutation",
39809
+ auth: "admin",
39810
+ timeoutMs: 5 * 6e4
39811
+ }), method(object(JobRef), object({ deleted: array(string()).readonly() }), {
39812
+ kind: "mutation",
39813
+ auth: "admin",
39814
+ timeoutMs: 5 * 6e4
39815
+ }), method(object({ addonId: string() }), array(ProviderJobStatusSchema).readonly(), {
39816
+ auth: "admin",
39817
+ timeoutMs: 2 * 6e4
39818
+ });
39819
+ /**
39820
+ * `training` — the cloud-training orchestrator (D805). Hub-only singleton,
39821
+ * provided by `addon-training`.
39822
+ *
39823
+ * It owns what every provider must agree on, written once:
39824
+ *
39825
+ * - **Dataset versions.** Taken over from pipeline-analytics (D796): the rows
39826
+ * live here (D808); pipeline-analytics still CUTS a version (it owns the corpus and
39827
+ * the export plan) and reaches this store through the five row methods
39828
+ * below, so the Retrain page and the export did not change.
39829
+ * - **Jobs.** A persisted state machine, a reconcile loop against the
39830
+ * provider, a cost guard, a daily orphan sweep and the retention rules.
39831
+ * - **The return flow.** Verified artefacts → Model Studio
39832
+ * (`custom-model-registry.importModelBundle`) → canary on cameras →
39833
+ * rollback. Nothing is ever registered automatically.
39834
+ *
39835
+ * Every method is `admin`.
39836
+ */
39837
+ /** A version WITH its frame list — what the export and a job read. */
39838
+ var TrainingDatasetVersionRowSchema = RetrainDatasetVersionSchema.omit({ frameCount: true }).extend({ frameIds: array(string()).max(2e4).readonly() });
39839
+ /** A base model a detector job can fine-tune, and the baseline it is judged against. */
39840
+ var TrainingBaseModelSchema = object({
39841
+ modelId: string(),
39842
+ label: string(),
39843
+ weights: string(),
39844
+ imgsz: number().int(),
39845
+ baselineOnnxUrl: string(),
39846
+ baselineFloors: record(string(), number()),
39847
+ /** The base the fleet runs most — the UI's default. */
39848
+ recommended: boolean()
39849
+ });
39850
+ var TrainingPresetSchema = _enum([
39851
+ "quick",
39852
+ "standard",
39853
+ "thorough"
39854
+ ]);
39855
+ var TrainingJobRequestSchema = object({
39856
+ datasetVersionId: string().min(1),
39857
+ /** The `training-provider` addon that runs it. */
39858
+ addonId: string().min(1),
39859
+ gpuType: string().min(1),
39860
+ region: string(),
39861
+ baseModelId: string().min(1),
39862
+ preset: TrainingPresetSchema,
39863
+ /** Freeze the backbone's first N layers; `null` = the preset's choice. */
39864
+ freeze: number().int().nonnegative().nullable(),
39865
+ /** Cameras held out whole for evaluation; `null` = the orchestrator's default. */
39866
+ holdoutCameras: array(number().int()).nullable()
39867
+ });
39868
+ var TrainingSplitPlanSchema = object({
39869
+ holdoutCameras: array(number().int()).readonly(),
39870
+ /** Used when no camera is held out: the last N days of every camera. */
39871
+ holdoutLastDays: number().int().nonnegative(),
39872
+ /** Holdout subjects per class (camera holdout only; `null` = known only after the split). */
39873
+ holdoutSupport: record(string(), number().int()).nullable(),
39874
+ trainSubjects: number().int()
39875
+ });
39876
+ var TrainingRefusalReasonSchema = _enum([
39877
+ "unknown-dataset",
39878
+ "unknown-provider",
39879
+ "provider-not-configured",
39880
+ "unknown-base-model",
39881
+ "unknown-gpu",
39882
+ "dataset-too-large",
39883
+ "no-training-subjects",
39884
+ "job-already-running"
39885
+ ]);
39886
+ var TrainingJobPlanSchema = object({
39887
+ refusal: object({
39888
+ reason: TrainingRefusalReasonSchema,
39889
+ detail: string()
39890
+ }).nullable(),
39891
+ warnings: array(string()).readonly(),
39892
+ split: TrainingSplitPlanSchema.nullable(),
39893
+ estimate: object({
39894
+ datasetBytes: number().int(),
39895
+ uploadMinutesAt20Mbps: number(),
39896
+ gpuSecondsLow: number(),
39897
+ gpuSecondsHigh: number(),
39898
+ usdLow: number(),
39899
+ usdHigh: number(),
39900
+ notes: array(string()).readonly()
39901
+ }).nullable(),
39902
+ /** Pre-filled from the provider's settings; the operator may lower or raise them. */
39903
+ defaults: object({
39904
+ maxCostUsd: number(),
39905
+ maxRuntimeSec: number().int()
39906
+ }).nullable(),
39907
+ /** The sentence the confirm dialog repeats: where the frames go and when they are deleted. */
39908
+ dataNotice: string()
39909
+ });
39910
+ /**
39911
+ * Orchestrator-owned states, persisted. `uploading` covers exporting the
39912
+ * archive (it is streamed, never staged). Terminal: `failed`, `cancelled`,
39913
+ * `lost`, `expired`, `discarded`. `registered` and `canary` are where a
39914
+ * result lives after the operator acted on it.
39915
+ */
39916
+ var TrainingJobStateSchema = _enum([
39917
+ "uploading",
39918
+ "submitted",
39919
+ "starting",
39920
+ "running",
39921
+ "collecting",
39922
+ "ready",
39923
+ "registered",
39924
+ "canary",
39925
+ "failed",
39926
+ "cancelling",
39927
+ "cancelled",
39928
+ "lost",
39929
+ "expired",
39930
+ "discarded"
39931
+ ]);
39932
+ var TrainingFailureReasonSchema = _enum([
39933
+ "cost-cap",
39934
+ "runtime-cap",
39935
+ "upload-failed",
39936
+ "submit-failed",
39937
+ "trainer-failed",
39938
+ "result-invalid",
39939
+ "checksum-mismatch",
39940
+ "fetch-failed",
39941
+ "provider-error",
39942
+ "hub-restart-during-upload"
39943
+ ]);
39944
+ var TrainingProgressPointSchema = object({
39945
+ epoch: number().int(),
39946
+ map50: number().nullable(),
39947
+ map50_95: number().nullable()
39948
+ });
39949
+ var TrainingCanarySchema = object({
39950
+ deviceIds: array(number().int()).readonly(),
39951
+ since: number(),
39952
+ /** Every override the canary replaced, exactly, so rollback restores it. */
39953
+ previous: array(object({
39954
+ deviceId: number().int(),
39955
+ nodeId: string(),
39956
+ deviceKey: string(),
39957
+ patch: object({
39958
+ modelId: string().optional(),
39959
+ settings: record(string(), unknown()).readonly().optional()
39960
+ }).nullable()
39961
+ })).readonly()
39962
+ });
39963
+ var TrainingJobSchema = object({
39964
+ id: string(),
39965
+ idempotencyKey: string(),
39966
+ name: string(),
39967
+ createdAt: number(),
39968
+ updatedAt: number(),
39969
+ state: TrainingJobStateSchema,
39970
+ stage: TrainingStageSchema.nullable(),
39971
+ failure: object({
39972
+ reason: TrainingFailureReasonSchema,
39973
+ stage: string().nullable(),
39974
+ detail: string()
39975
+ }).nullable(),
39976
+ request: TrainingJobRequestSchema,
39977
+ maxCostUsd: number().nonnegative(),
39978
+ maxRuntimeSec: number().int().positive(),
39979
+ trainer: TrainerSourceRefSchema,
39980
+ datasetLayout: RetrainExportLayoutSchema,
39981
+ dataset: object({
39982
+ bytes: number().int(),
39983
+ sha256: string(),
39984
+ uploadedAt: number()
39985
+ }).nullable(),
39986
+ split: TrainingSplitPlanSchema,
39987
+ provider: object({
39988
+ state: ProviderJobStateSchema.nullable(),
39989
+ providerJobId: string().nullable(),
39990
+ startedAt: number().nullable(),
39991
+ endedAt: number().nullable(),
39992
+ billedSeconds: number(),
39993
+ costUsd: number(),
39994
+ costIsEstimate: boolean(),
39995
+ lastPolledAt: number().nullable()
39996
+ }),
39997
+ progress: object({
39998
+ epoch: number().int().nullable(),
39999
+ epochs: number().int().nullable(),
40000
+ etaSec: number().nullable(),
40001
+ series: array(TrainingProgressPointSchema).readonly()
40002
+ }),
40003
+ /** The last lines of the job's output (≤ 200), newest last. Never frame paths. */
40004
+ logTail: array(string()).readonly(),
40005
+ logCursor: string().nullable(),
40006
+ artifacts: object({
40007
+ bundleBytes: number().int(),
40008
+ bundleSha256: string(),
40009
+ fetchedAt: number(),
40010
+ /** When the staged artefacts are deleted from the hub. */
40011
+ expiresAt: number()
40012
+ }).nullable(),
40013
+ /** When the provider-side copy of the frames was deleted; null while it exists. */
40014
+ cloudDatasetDeletedAt: number().nullable(),
40015
+ /** A failed job's dataset is kept until then (the provider's grace), then deleted. */
40016
+ cloudCleanupDueAt: number().nullable(),
40017
+ /** Model ids registered from this job (base, and int8 when kept). */
40018
+ registeredModelIds: array(string()).readonly(),
40019
+ canary: TrainingCanarySchema.nullable()
40020
+ });
40021
+ var IdInput = object({ id: string().min(1) });
40022
+ method(TrainingDatasetVersionRowSchema, object({ stored: boolean() }), {
40023
+ kind: "mutation",
40024
+ auth: "admin"
40025
+ }), 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() }), {
40026
+ kind: "mutation",
40027
+ auth: "admin"
40028
+ }), method(object({}), array(TrainingBaseModelSchema).readonly(), { auth: "admin" }), method(TrainingJobRequestSchema, TrainingJobPlanSchema, {
40029
+ auth: "admin",
40030
+ timeoutMs: 6e4
40031
+ }), method(TrainingJobRequestSchema.extend({
40032
+ name: string().min(1).max(120),
40033
+ maxCostUsd: number().positive(),
40034
+ maxRuntimeSec: number().int().positive(),
40035
+ idempotencyKey: string().min(8).max(80)
40036
+ }), discriminatedUnion("kind", [object({
40037
+ kind: literal("started"),
40038
+ job: TrainingJobSchema
40039
+ }), object({
40040
+ kind: literal("refused"),
40041
+ reason: TrainingRefusalReasonSchema,
40042
+ detail: string()
40043
+ })]), {
40044
+ kind: "mutation",
40045
+ auth: "admin",
40046
+ timeoutMs: 12e4
40047
+ }), method(object({}), array(TrainingJobSchema).readonly(), { auth: "admin" }), method(IdInput, TrainingJobSchema.nullable(), { auth: "admin" }), method(IdInput, TrainingJobSchema, {
40048
+ kind: "mutation",
40049
+ auth: "admin",
40050
+ timeoutMs: 12e4
40051
+ }), method(IdInput, TrainingResultSchema.nullable(), { auth: "admin" }), method(IdInput.extend({ canaryDeviceIds: array(number().int()).readonly() }), TrainingJobSchema, {
40052
+ kind: "mutation",
40053
+ auth: "admin",
40054
+ timeoutMs: 30 * 6e4
40055
+ }), method(IdInput.extend({ deviceIds: array(number().int()).min(1).readonly() }), TrainingJobSchema, {
40056
+ kind: "mutation",
40057
+ auth: "admin",
40058
+ timeoutMs: 12e4
40059
+ }), method(IdInput, TrainingJobSchema, {
40060
+ kind: "mutation",
40061
+ auth: "admin",
40062
+ timeoutMs: 12e4
40063
+ }), method(IdInput, TrainingJobSchema, {
40064
+ kind: "mutation",
40065
+ auth: "admin"
40066
+ });
38778
40067
  SOURCE_CAPS.filter((cap) => cap !== "switch" && cap !== "motion");
38779
40068
  Object.freeze({
38780
40069
  person: .5,
@@ -40217,6 +41506,12 @@ Object.freeze({
40217
41506
  addonId: null,
40218
41507
  access: "create"
40219
41508
  },
41509
+ "backup.checkBackupKey": {
41510
+ capName: "backup",
41511
+ capScope: "system",
41512
+ addonId: null,
41513
+ access: "create"
41514
+ },
40220
41515
  "backup.delete": {
40221
41516
  capName: "backup",
40222
41517
  capScope: "system",
@@ -40229,6 +41524,18 @@ Object.freeze({
40229
41524
  addonId: null,
40230
41525
  access: "delete"
40231
41526
  },
41527
+ "backup.disableEncryption": {
41528
+ capName: "backup",
41529
+ capScope: "system",
41530
+ addonId: null,
41531
+ access: "create"
41532
+ },
41533
+ "backup.getEncryption": {
41534
+ capName: "backup",
41535
+ capScope: "system",
41536
+ addonId: null,
41537
+ access: "view"
41538
+ },
40232
41539
  "backup.getEntries": {
40233
41540
  capName: "backup",
40234
41541
  capScope: "system",
@@ -40283,6 +41590,12 @@ Object.freeze({
40283
41590
  addonId: null,
40284
41591
  access: "create"
40285
41592
  },
41593
+ "backup.setupEncryption": {
41594
+ capName: "backup",
41595
+ capScope: "system",
41596
+ addonId: null,
41597
+ access: "create"
41598
+ },
40286
41599
  "backup.trigger": {
40287
41600
  capName: "backup",
40288
41601
  capScope: "system",
@@ -40835,6 +42148,12 @@ Object.freeze({
40835
42148
  addonId: null,
40836
42149
  access: "create"
40837
42150
  },
42151
+ "customModelRegistry.importModelBundle": {
42152
+ capName: "custom-model-registry",
42153
+ capScope: "system",
42154
+ addonId: null,
42155
+ access: "create"
42156
+ },
40838
42157
  "customModelRegistry.listModels": {
40839
42158
  capName: "custom-model-registry",
40840
42159
  capScope: "system",
@@ -42275,6 +43594,12 @@ Object.freeze({
42275
43594
  addonId: null,
42276
43595
  access: "view"
42277
43596
  },
43597
+ "keychainAdmin.acknowledgeReset": {
43598
+ capName: "keychain-admin",
43599
+ capScope: "system",
43600
+ addonId: null,
43601
+ access: "create"
43602
+ },
42278
43603
  "keychainAdmin.deleteOrphans": {
42279
43604
  capName: "keychain-admin",
42280
43605
  capScope: "system",
@@ -42311,6 +43636,12 @@ Object.freeze({
42311
43636
  addonId: null,
42312
43637
  access: "delete"
42313
43638
  },
43639
+ "keychainAdmin.resetReport": {
43640
+ capName: "keychain-admin",
43641
+ capScope: "system",
43642
+ addonId: null,
43643
+ access: "delete"
43644
+ },
42314
43645
  "keychainAdmin.reveal": {
42315
43646
  capName: "keychain-admin",
42316
43647
  capScope: "system",
@@ -44057,6 +45388,12 @@ Object.freeze({
44057
45388
  addonId: null,
44058
45389
  access: "view"
44059
45390
  },
45391
+ "pipelineAnalytics.offerRetrainArchive": {
45392
+ capName: "pipeline-analytics",
45393
+ capScope: "device",
45394
+ addonId: null,
45395
+ access: "create"
45396
+ },
44060
45397
  "pipelineAnalytics.ownersWithMedia": {
44061
45398
  capName: "pipeline-analytics",
44062
45399
  capScope: "device",
@@ -46595,6 +47932,174 @@ Object.freeze({
46595
47932
  addonId: null,
46596
47933
  access: "view"
46597
47934
  },
47935
+ "training.canaryResult": {
47936
+ capName: "training",
47937
+ capScope: "system",
47938
+ addonId: null,
47939
+ access: "create"
47940
+ },
47941
+ "training.cancelJob": {
47942
+ capName: "training",
47943
+ capScope: "system",
47944
+ addonId: null,
47945
+ access: "create"
47946
+ },
47947
+ "training.discardResult": {
47948
+ capName: "training",
47949
+ capScope: "system",
47950
+ addonId: null,
47951
+ access: "create"
47952
+ },
47953
+ "training.findDatasetVersionIdByName": {
47954
+ capName: "training",
47955
+ capScope: "system",
47956
+ addonId: null,
47957
+ access: "view"
47958
+ },
47959
+ "training.getDatasetVersion": {
47960
+ capName: "training",
47961
+ capScope: "system",
47962
+ addonId: null,
47963
+ access: "view"
47964
+ },
47965
+ "training.getJob": {
47966
+ capName: "training",
47967
+ capScope: "system",
47968
+ addonId: null,
47969
+ access: "view"
47970
+ },
47971
+ "training.getJobResult": {
47972
+ capName: "training",
47973
+ capScope: "system",
47974
+ addonId: null,
47975
+ access: "view"
47976
+ },
47977
+ "training.listBaseModels": {
47978
+ capName: "training",
47979
+ capScope: "system",
47980
+ addonId: null,
47981
+ access: "view"
47982
+ },
47983
+ "training.listDatasetVersions": {
47984
+ capName: "training",
47985
+ capScope: "system",
47986
+ addonId: null,
47987
+ access: "view"
47988
+ },
47989
+ "training.listJobs": {
47990
+ capName: "training",
47991
+ capScope: "system",
47992
+ addonId: null,
47993
+ access: "view"
47994
+ },
47995
+ "training.planJob": {
47996
+ capName: "training",
47997
+ capScope: "system",
47998
+ addonId: null,
47999
+ access: "view"
48000
+ },
48001
+ "training.putDatasetVersion": {
48002
+ capName: "training",
48003
+ capScope: "system",
48004
+ addonId: null,
48005
+ access: "create"
48006
+ },
48007
+ "training.registerResult": {
48008
+ capName: "training",
48009
+ capScope: "system",
48010
+ addonId: null,
48011
+ access: "create"
48012
+ },
48013
+ "training.removeDatasetVersion": {
48014
+ capName: "training",
48015
+ capScope: "system",
48016
+ addonId: null,
48017
+ access: "delete"
48018
+ },
48019
+ "training.rollbackCanary": {
48020
+ capName: "training",
48021
+ capScope: "system",
48022
+ addonId: null,
48023
+ access: "create"
48024
+ },
48025
+ "training.startJob": {
48026
+ capName: "training",
48027
+ capScope: "system",
48028
+ addonId: null,
48029
+ access: "create"
48030
+ },
48031
+ "trainingProvider.cancelJob": {
48032
+ capName: "training-provider",
48033
+ capScope: "system",
48034
+ addonId: null,
48035
+ access: "create"
48036
+ },
48037
+ "trainingProvider.cleanupJob": {
48038
+ capName: "training-provider",
48039
+ capScope: "system",
48040
+ addonId: null,
48041
+ access: "create"
48042
+ },
48043
+ "trainingProvider.describe": {
48044
+ capName: "training-provider",
48045
+ capScope: "system",
48046
+ addonId: null,
48047
+ access: "view"
48048
+ },
48049
+ "trainingProvider.estimateJob": {
48050
+ capName: "training-provider",
48051
+ capScope: "system",
48052
+ addonId: null,
48053
+ access: "view"
48054
+ },
48055
+ "trainingProvider.getJob": {
48056
+ capName: "training-provider",
48057
+ capScope: "system",
48058
+ addonId: null,
48059
+ access: "view"
48060
+ },
48061
+ "trainingProvider.listJobEvents": {
48062
+ capName: "training-provider",
48063
+ capScope: "system",
48064
+ addonId: null,
48065
+ access: "view"
48066
+ },
48067
+ "trainingProvider.listJobs": {
48068
+ capName: "training-provider",
48069
+ capScope: "system",
48070
+ addonId: null,
48071
+ access: "view"
48072
+ },
48073
+ "trainingProvider.offerArtifact": {
48074
+ capName: "training-provider",
48075
+ capScope: "system",
48076
+ addonId: null,
48077
+ access: "create"
48078
+ },
48079
+ "trainingProvider.readResult": {
48080
+ capName: "training-provider",
48081
+ capScope: "system",
48082
+ addonId: null,
48083
+ access: "create"
48084
+ },
48085
+ "trainingProvider.submitJob": {
48086
+ capName: "training-provider",
48087
+ capScope: "system",
48088
+ addonId: null,
48089
+ access: "create"
48090
+ },
48091
+ "trainingProvider.uploadDataset": {
48092
+ capName: "training-provider",
48093
+ capScope: "system",
48094
+ addonId: null,
48095
+ access: "create"
48096
+ },
48097
+ "trainingProvider.validateCredentials": {
48098
+ capName: "training-provider",
48099
+ capScope: "system",
48100
+ addonId: null,
48101
+ access: "create"
48102
+ },
46598
48103
  "turnProvider.getTurnServers": {
46599
48104
  capName: "turn-provider",
46600
48105
  capScope: "system",
@@ -46619,12 +48124,6 @@ Object.freeze({
46619
48124
  addonId: null,
46620
48125
  access: "create"
46621
48126
  },
46622
- "userManagement.createApiKey": {
46623
- capName: "user-management",
46624
- capScope: "system",
46625
- addonId: null,
46626
- access: "create"
46627
- },
46628
48127
  "userManagement.createScopedToken": {
46629
48128
  capName: "user-management",
46630
48129
  capScope: "system",
@@ -46661,12 +48160,6 @@ Object.freeze({
46661
48160
  addonId: null,
46662
48161
  access: "view"
46663
48162
  },
46664
- "userManagement.linkExternalIdentity": {
46665
- capName: "user-management",
46666
- capScope: "system",
46667
- addonId: null,
46668
- access: "create"
46669
- },
46670
48163
  "userManagement.listApiKeys": {
46671
48164
  capName: "user-management",
46672
48165
  capScope: "system",
@@ -46769,12 +48262,6 @@ Object.freeze({
46769
48262
  addonId: null,
46770
48263
  access: "create"
46771
48264
  },
46772
- "userManagement.validateApiKey": {
46773
- capName: "user-management",
46774
- capScope: "system",
46775
- addonId: null,
46776
- access: "view"
46777
- },
46778
48265
  "userManagement.validateCredentials": {
46779
48266
  capName: "user-management",
46780
48267
  capScope: "system",
@@ -50954,6 +52441,11 @@ Object.freeze({
50954
52441
  form: "single",
50955
52442
  optional: false
50956
52443
  }],
52444
+ "training.canaryResult": [{
52445
+ name: "deviceIds",
52446
+ form: "array",
52447
+ optional: false
52448
+ }],
50957
52449
  "update.getStatus": [{
50958
52450
  name: "deviceId",
50959
52451
  form: "single",
@@ -61563,6 +63055,9 @@ async function discoverOnvifCameras(timeout = 5e3) {
61563
63055
  //#endregion
61564
63056
  //#region src/addon.ts
61565
63057
  var ADDON_ID = "provider-onvif";
63058
+ /** Stored flat, under its dotted schema key — the store is not nested. */
63059
+ var DISCOVERY_TIMEOUT_KEY = "discovery.timeout";
63060
+ var DEFAULT_DISCOVERY_TIMEOUT_MS = 5e3;
61566
63061
  var OnvifProviderAddon = class extends BaseDeviceProvider {
61567
63062
  addonId = ADDON_ID;
61568
63063
  providerName = "ONVIF";
@@ -61579,7 +63074,7 @@ var OnvifProviderAddon = class extends BaseDeviceProvider {
61579
63074
  }
61580
63075
  async discoverDevices() {
61581
63076
  const config = await this._getAddonConfig();
61582
- const timeout = config.discovery?.timeout ?? 5e3;
63077
+ const timeout = config.discovery?.timeout ?? DEFAULT_DISCOVERY_TIMEOUT_MS;
61583
63078
  this.ctx.logger.info("Starting ONVIF discovery", { meta: { timeoutMs: timeout } });
61584
63079
  const cameras = await discoverOnvifCameras(timeout);
61585
63080
  this.lastDiscovered = cameras;
@@ -61701,22 +63196,17 @@ var OnvifProviderAddon = class extends BaseDeviceProvider {
61701
63196
  return { sections: [{
61702
63197
  id: "discovery",
61703
63198
  title: "ONVIF Discovery",
61704
- description: "Auto-discover ONVIF cameras on the local network",
63199
+ description: "Find ONVIF cameras on the local network when you add a device",
61705
63200
  columns: 2,
61706
63201
  fields: [{
61707
- type: "boolean",
61708
- key: "discovery.enabled",
61709
- label: "Enable Auto-Discovery",
61710
- default: true
61711
- }, {
61712
63202
  type: "number",
61713
- key: "discovery.timeout",
63203
+ key: DISCOVERY_TIMEOUT_KEY,
61714
63204
  label: "Discovery Timeout",
61715
63205
  unit: "ms",
61716
63206
  min: 1e3,
61717
63207
  max: 3e4,
61718
63208
  step: 1e3,
61719
- default: 5e3
63209
+ default: DEFAULT_DISCOVERY_TIMEOUT_MS
61720
63210
  }]
61721
63211
  }, {
61722
63212
  id: "credentials",
@@ -61738,10 +63228,11 @@ var OnvifProviderAddon = class extends BaseDeviceProvider {
61738
63228
  async _getAddonConfig() {
61739
63229
  const raw = await this.resolveGlobalStore();
61740
63230
  const { defaultUsername, defaultPassword } = this.config;
63231
+ const storedTimeout = raw[DISCOVERY_TIMEOUT_KEY];
61741
63232
  return {
61742
63233
  id: typeof raw["id"] === "string" ? raw["id"] : "onvif-default",
61743
63234
  name: typeof raw["name"] === "string" ? raw["name"] : "ONVIF Cameras",
61744
- discovery: raw["discovery"],
63235
+ discovery: { timeout: typeof storedTimeout === "number" && Number.isFinite(storedTimeout) && storedTimeout > 0 ? storedTimeout : DEFAULT_DISCOVERY_TIMEOUT_MS },
61745
63236
  cameras: raw["cameras"],
61746
63237
  defaultUsername: defaultUsername !== "" ? defaultUsername : void 0,
61747
63238
  defaultPassword: defaultPassword !== "" ? defaultPassword : void 0