@camstack/addon-provider-onvif 1.2.125 → 1.2.127

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 +1994 -220
  2. package/dist/addon.mjs +1994 -220
  3. package/package.json +1 -1
package/dist/addon.mjs CHANGED
@@ -5381,7 +5381,7 @@ var ZodIssueCode = {
5381
5381
  var ZodFirstPartyTypeKind;
5382
5382
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
5383
5383
  //#endregion
5384
- //#region ../types/dist/sleep-DujUvOcb.mjs
5384
+ //#region ../types/dist/sleep-DwAQ9sqX.mjs
5385
5385
  /**
5386
5386
  * The audio chunk plane's byte format, and the ONE expansion from a coded
5387
5387
  * window to float samples (D455).
@@ -5498,7 +5498,7 @@ function isKeychainStoredField(field) {
5498
5498
  var SECRET_CLEAR = { $secretClear: true };
5499
5499
  /** The `'***'` token D634 redaction writes for non-admins. */
5500
5500
  var LEGACY_DEVICE_REDACTION = "***";
5501
- function isRecord$1(value) {
5501
+ function isRecord$2(value) {
5502
5502
  return typeof value === "object" && value !== null && !Array.isArray(value);
5503
5503
  }
5504
5504
  function makeSecretMarker(ref) {
@@ -5509,12 +5509,12 @@ function makeSecretMarker(ref) {
5509
5509
  }
5510
5510
  /** A stored marker: an object whose `$secret` is a non-empty string. */
5511
5511
  function isSecretMarker(value) {
5512
- if (!isRecord$1(value)) return false;
5512
+ if (!isRecord$2(value)) return false;
5513
5513
  const ref = value["$secret"];
5514
5514
  return typeof ref === "string" && ref.length > 0;
5515
5515
  }
5516
5516
  function isSecretClear(value) {
5517
- return isRecord$1(value) && value["$secretClear"] === true;
5517
+ return isRecord$2(value) && value["$secretClear"] === true;
5518
5518
  }
5519
5519
  /**
5520
5520
  * The UI view of a stored secret field value: a marker becomes "set", inline
@@ -6030,6 +6030,13 @@ function globalSecretScope() {
6030
6030
  function encodeSegment(value) {
6031
6031
  return encodeURIComponent(value);
6032
6032
  }
6033
+ function decodeSegment(value) {
6034
+ try {
6035
+ return decodeURIComponent(value);
6036
+ } catch {
6037
+ return null;
6038
+ }
6039
+ }
6033
6040
  /**
6034
6041
  * The field path of a value inside an array item, addressed by the item's id:
6035
6042
  * `arrayItemFieldPath('providers', 'authentik', 'clientSecret')` →
@@ -6038,6 +6045,75 @@ function encodeSegment(value) {
6038
6045
  function arrayItemFieldPath(arrayKey, itemId, fieldKey) {
6039
6046
  return `${arrayKey}[${encodeSegment(itemId)}].${fieldKey}`;
6040
6047
  }
6048
+ function parseScope(segments) {
6049
+ switch (segments[0]) {
6050
+ case "global": return {
6051
+ scope: GLOBAL_SCOPE,
6052
+ used: 1
6053
+ };
6054
+ case "node": {
6055
+ const nodeId = segments[1] !== void 0 ? decodeSegment(segments[1]) : null;
6056
+ return nodeId === null || nodeId.length === 0 ? null : {
6057
+ scope: {
6058
+ kind: "node",
6059
+ nodeId
6060
+ },
6061
+ used: 2
6062
+ };
6063
+ }
6064
+ case "device": {
6065
+ const raw = segments[1];
6066
+ if (raw === void 0 || !/^\d+$/.test(raw)) return null;
6067
+ return {
6068
+ scope: {
6069
+ kind: "device",
6070
+ deviceId: Number(raw)
6071
+ },
6072
+ used: 2
6073
+ };
6074
+ }
6075
+ case "integration": {
6076
+ const id = segments[1] !== void 0 ? decodeSegment(segments[1]) : null;
6077
+ return id === null || id.length === 0 ? null : {
6078
+ scope: {
6079
+ kind: "integration",
6080
+ integrationId: id
6081
+ },
6082
+ used: 2
6083
+ };
6084
+ }
6085
+ case "row": {
6086
+ const collection = segments[1] !== void 0 ? decodeSegment(segments[1]) : null;
6087
+ const rowId = segments[2] !== void 0 ? decodeSegment(segments[2]) : null;
6088
+ if (collection === null || rowId === null || collection.length === 0 || rowId.length === 0) return null;
6089
+ return {
6090
+ scope: {
6091
+ kind: "row",
6092
+ collection,
6093
+ rowId
6094
+ },
6095
+ used: 3
6096
+ };
6097
+ }
6098
+ default: return null;
6099
+ }
6100
+ }
6101
+ /** Take a ref apart; `null` when it is not a well-formed ref. */
6102
+ function parseSecretRef(ref) {
6103
+ if (!ref.startsWith("secret://")) return null;
6104
+ const segments = ref.slice(9).split("/");
6105
+ const owner = segments[0] !== void 0 ? decodeSegment(segments[0]) : null;
6106
+ if (owner === null || owner.length === 0) return null;
6107
+ const parsed = parseScope(segments.slice(1));
6108
+ if (parsed === null) return null;
6109
+ const fieldPath = segments.slice(1 + parsed.used).join("/");
6110
+ if (fieldPath.length === 0) return null;
6111
+ return {
6112
+ owner,
6113
+ scope: parsed.scope,
6114
+ fieldPath
6115
+ };
6116
+ }
6041
6117
  /** A write to a secret path could not be stored in the keychain, so it was refused. */
6042
6118
  var KeychainWriteRefusedError = class extends Error {
6043
6119
  fieldPath;
@@ -6048,7 +6124,7 @@ var KeychainWriteRefusedError = class extends Error {
6048
6124
  }
6049
6125
  };
6050
6126
  var KEEP = { kind: "keep" };
6051
- function isRecord(value) {
6127
+ function isRecord$1(value) {
6052
6128
  return typeof value === "object" && value !== null && !Array.isArray(value);
6053
6129
  }
6054
6130
  function defaultMintId() {
@@ -6061,7 +6137,7 @@ function collectSecretMarkerRefs(value, out = []) {
6061
6137
  return out;
6062
6138
  }
6063
6139
  if (Array.isArray(value)) for (const item of value) collectSecretMarkerRefs(item, out);
6064
- else if (isRecord(value)) for (const child of Object.values(value)) collectSecretMarkerRefs(child, out);
6140
+ else if (isRecord$1(value)) for (const child of Object.values(value)) collectSecretMarkerRefs(child, out);
6065
6141
  return out;
6066
6142
  }
6067
6143
  async function storedValueEquals(secrets, marker, candidate) {
@@ -6116,7 +6192,7 @@ function rowId(row, idKey) {
6116
6192
  return null;
6117
6193
  }
6118
6194
  async function writeArray(ctx, node, incoming, stored, fieldPath) {
6119
- const storedRows = Array.isArray(stored) ? stored.filter(isRecord) : [];
6195
+ const storedRows = Array.isArray(stored) ? stored.filter(isRecord$1) : [];
6120
6196
  if (!Array.isArray(incoming)) {
6121
6197
  ctx.deletes.push(...collectSecretMarkerRefs(storedRows));
6122
6198
  return {
@@ -6132,7 +6208,7 @@ async function writeArray(ctx, node, incoming, stored, fieldPath) {
6132
6208
  const kept = /* @__PURE__ */ new Set();
6133
6209
  const rows = [];
6134
6210
  for (const row of incoming) {
6135
- if (!isRecord(row)) {
6211
+ if (!isRecord$1(row)) {
6136
6212
  rows.push(row);
6137
6213
  continue;
6138
6214
  }
@@ -6157,7 +6233,7 @@ async function writeNode(ctx, node, incoming, stored, fieldPath) {
6157
6233
  case "leaf": return writeLeaf(ctx, incoming, stored, fieldPath);
6158
6234
  case "array": return writeArray(ctx, node, incoming, stored, fieldPath);
6159
6235
  case "object": {
6160
- if (!isRecord(incoming)) {
6236
+ if (!isRecord$1(incoming)) {
6161
6237
  if (incoming === void 0) return KEEP;
6162
6238
  ctx.deletes.push(...collectSecretMarkerRefs(stored));
6163
6239
  return {
@@ -6165,7 +6241,7 @@ async function writeNode(ctx, node, incoming, stored, fieldPath) {
6165
6241
  value: incoming
6166
6242
  };
6167
6243
  }
6168
- const storedObj = isRecord(stored) ? stored : {};
6244
+ const storedObj = isRecord$1(stored) ? stored : {};
6169
6245
  return {
6170
6246
  kind: "value",
6171
6247
  value: await writeMembers(ctx, node.children, incoming, storedObj, (m) => `${fieldPath}.${m}`)
@@ -6224,12 +6300,19 @@ async function transformSecretWrite(input) {
6224
6300
  }
6225
6301
  };
6226
6302
  }
6303
+ /** Is `ref` one of `owner`'s refs? */
6304
+ function isSecretRefOwnedBy(ref, owner) {
6305
+ return parseSecretRef(ref)?.owner === owner;
6306
+ }
6227
6307
  /**
6228
6308
  * Replace every marker in `value` with its keychain value. Returns the SAME
6229
6309
  * reference when there is no marker (no allocation, no keychain call).
6230
6310
  */
6231
- async function resolveSecretMarkers(value, secrets) {
6232
- const refs = collectSecretMarkerRefs(value);
6311
+ async function resolveSecretMarkers(value, secrets, options = {}) {
6312
+ const keepMarker = options.unresolved === "keep-marker";
6313
+ const owner = options.ownedBy;
6314
+ const inScope = (ref) => owner === void 0 || isSecretRefOwnedBy(ref, owner);
6315
+ const refs = collectSecretMarkerRefs(value).filter(inScope);
6233
6316
  if (refs.length === 0) return {
6234
6317
  value,
6235
6318
  unresolved: []
@@ -6253,10 +6336,18 @@ async function resolveSecretMarkers(value, secrets) {
6253
6336
  }
6254
6337
  const substitute = (v) => {
6255
6338
  if (isSecretMarker(v)) {
6339
+ if (!inScope(v.$secret)) return {
6340
+ keep: true,
6341
+ value: v
6342
+ };
6256
6343
  const answer = answers[v.$secret];
6257
- return answer?.kind === "value" ? {
6344
+ if (answer?.kind === "value") return {
6258
6345
  keep: true,
6259
6346
  value: answer.value
6347
+ };
6348
+ return keepMarker ? {
6349
+ keep: true,
6350
+ value: v
6260
6351
  } : {
6261
6352
  keep: false,
6262
6353
  value: void 0
@@ -6273,7 +6364,7 @@ async function resolveSecretMarkers(value, secrets) {
6273
6364
  value: items
6274
6365
  };
6275
6366
  }
6276
- if (isRecord(v)) {
6367
+ if (isRecord$1(v)) {
6277
6368
  const out = {};
6278
6369
  for (const [k, child] of Object.entries(v)) {
6279
6370
  const s = substitute(child);
@@ -6294,14 +6385,152 @@ async function resolveSecretMarkers(value, secrets) {
6294
6385
  unresolved
6295
6386
  };
6296
6387
  }
6297
- function touchesTree(tree, patch) {
6298
- if (tree.size === 0) return false;
6299
- for (const key of Object.keys(patch)) {
6300
- const at = key.indexOf("@");
6301
- if (tree.has(at > 0 ? key.slice(0, at) : key)) return true;
6388
+ /** An addon tried to replace a stored secret it could not read. Nothing was written. */
6389
+ var SecretOverwriteRefusedError = class extends Error {
6390
+ ref;
6391
+ reason;
6392
+ constructor(ref, reason) {
6393
+ 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.`);
6394
+ this.ref = ref;
6395
+ this.reason = reason;
6396
+ this.name = "SecretOverwriteRefusedError";
6397
+ }
6398
+ };
6399
+ function isRecord(value) {
6400
+ return typeof value === "object" && value !== null && !Array.isArray(value);
6401
+ }
6402
+ function resolvedValue(pass, marker) {
6403
+ const answer = pass.answers[marker.$secret];
6404
+ return answer?.kind === "value" ? answer.value : null;
6405
+ }
6406
+ async function atMarker(pass, incoming, stored) {
6407
+ if (incoming === null) return stored;
6408
+ if (typeof incoming !== "string") return incoming;
6409
+ if (incoming === resolvedValue(pass, stored)) return stored;
6410
+ const intent = classifySecretWrite(incoming);
6411
+ if (intent.kind !== "set") return stored;
6412
+ const ref = stored.$secret;
6413
+ if (!isSecretRefOwnedBy(ref, pass.secrets.owner)) return incoming;
6414
+ const answer = pass.answers[ref];
6415
+ 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);
6416
+ try {
6417
+ await pass.secrets.put(ref, intent.value);
6418
+ } catch (err) {
6419
+ throw new KeychainWriteRefusedError(ref, err);
6420
+ }
6421
+ pass.changedRefs.push(ref);
6422
+ return stored;
6423
+ }
6424
+ function inArray(pass, incoming, stored) {
6425
+ return incoming.map((item, index) => {
6426
+ const twin = stored[index];
6427
+ if (isSecretMarker(twin)) return typeof item === "string" && item === resolvedValue(pass, twin) ? twin : item;
6428
+ if (isRecord(item) && isRecord(twin)) return inArrayRow(pass, item, twin);
6429
+ if (Array.isArray(item) && Array.isArray(twin)) return inArray(pass, item, twin);
6430
+ return item;
6431
+ });
6432
+ }
6433
+ function inArrayRow(pass, incoming, stored) {
6434
+ const out = { ...incoming };
6435
+ for (const [key, value] of Object.entries(incoming)) {
6436
+ const twin = stored[key];
6437
+ if (isSecretMarker(twin)) {
6438
+ if (typeof value === "string" && value === resolvedValue(pass, twin)) out[key] = twin;
6439
+ } else if (isRecord(value) && isRecord(twin)) out[key] = inArrayRow(pass, value, twin);
6440
+ else if (Array.isArray(value) && Array.isArray(twin)) out[key] = inArray(pass, value, twin);
6441
+ }
6442
+ return out;
6443
+ }
6444
+ async function walk(pass, incoming, stored) {
6445
+ if (isSecretMarker(stored)) return atMarker(pass, incoming, stored);
6446
+ if (Array.isArray(incoming) && Array.isArray(stored)) return inArray(pass, incoming, stored);
6447
+ if (!isRecord(incoming) || !isRecord(stored)) return incoming;
6448
+ const out = { ...incoming };
6449
+ for (const [key, value] of Object.entries(incoming)) out[key] = await walk(pass, value, stored[key]);
6450
+ return out;
6451
+ }
6452
+ /** Restore markers a write-back carries as values. See the file doc. */
6453
+ async function restoreUnchangedSecrets(input) {
6454
+ const refs = [];
6455
+ for (const key of Object.keys(input.patch)) collectSecretMarkerRefs(input.stored[key], refs);
6456
+ const owned = refs.filter((ref) => isSecretRefOwnedBy(ref, input.secrets.owner));
6457
+ if (owned.length === 0) return {
6458
+ patch: input.patch,
6459
+ changedRefs: []
6460
+ };
6461
+ const pass = {
6462
+ secrets: input.secrets,
6463
+ answers: await input.secrets.resolve([...new Set(owned)]),
6464
+ operatorWrite: input.operatorWrite,
6465
+ changedRefs: []
6466
+ };
6467
+ const out = {};
6468
+ for (const [key, value] of Object.entries(input.patch)) out[key] = await walk(pass, value, input.stored[key]);
6469
+ return {
6470
+ patch: out,
6471
+ changedRefs: pass.changedRefs
6472
+ };
6473
+ }
6474
+ /** Structural equality over JSON-shaped values (key order does not matter). */
6475
+ function isJsonEqual(a, b) {
6476
+ if (Object.is(a, b)) return true;
6477
+ if (Array.isArray(a)) return Array.isArray(b) && a.length === b.length && a.every((v, i) => isJsonEqual(v, b[i]));
6478
+ if (isRecord(a) && isRecord(b)) {
6479
+ const keys = Object.keys(a);
6480
+ if (keys.length !== Object.keys(b).length) return false;
6481
+ return keys.every((k) => Object.prototype.hasOwnProperty.call(b, k) && isJsonEqual(a[k], b[k]));
6302
6482
  }
6303
6483
  return false;
6304
6484
  }
6485
+ /** The patch without the keys whose value already equals the stored one. */
6486
+ function dropUnchangedKeys(patch, stored) {
6487
+ const out = {};
6488
+ for (const [key, value] of Object.entries(patch)) {
6489
+ if (Object.prototype.hasOwnProperty.call(stored, key) && isJsonEqual(value, stored[key])) continue;
6490
+ out[key] = value;
6491
+ }
6492
+ return out;
6493
+ }
6494
+ /** The top-level keys of a blob that hold at least one of `owner`'s markers. */
6495
+ function markerKeysOf(blob, owner) {
6496
+ const keys = /* @__PURE__ */ new Set();
6497
+ for (const [key, value] of Object.entries(blob)) if (collectSecretMarkerRefs(value).some((ref) => isSecretRefOwnedBy(ref, owner))) keys.add(key);
6498
+ return keys;
6499
+ }
6500
+ function nodeFromStored(value, owner) {
6501
+ if (isSecretMarker(value)) return isSecretRefOwnedBy(value.$secret, owner) ? { kind: "leaf" } : null;
6502
+ if (!isRecord(value)) return null;
6503
+ const children = /* @__PURE__ */ new Map();
6504
+ for (const [key, child] of Object.entries(value)) {
6505
+ const node = nodeFromStored(child, owner);
6506
+ if (node !== null) children.set(key, node);
6507
+ }
6508
+ return children.size > 0 ? {
6509
+ kind: "object",
6510
+ children
6511
+ } : null;
6512
+ }
6513
+ /**
6514
+ * The declared secret tree, widened by every place the STORED blob holds a
6515
+ * marker under one of `keys` — so a marker the schema no longer declares (or
6516
+ * never declared: Wyze before b4906cec6) still gets the save path's
6517
+ * KEEP / SET / CLEAR semantics instead of being overwritten by whatever the
6518
+ * addon writes. Markers inside arrays are not added: a row has no id field to
6519
+ * match by unless the schema declares one. Only `owner`'s markers count: a
6520
+ * builtin that keeps another addon's marker (device-manager) never takes it
6521
+ * over.
6522
+ */
6523
+ function widenTreeWithStoredMarkers(declared, stored, keys, owner) {
6524
+ const added = /* @__PURE__ */ new Map();
6525
+ for (const key of keys) {
6526
+ const at = key.indexOf("@");
6527
+ const base = at > 0 ? key.slice(0, at) : key;
6528
+ if (declared.has(base) || added.has(base)) continue;
6529
+ const node = nodeFromStored(stored[key], owner);
6530
+ if (node !== null) added.set(base, node);
6531
+ }
6532
+ return added.size === 0 ? declared : new Map([...declared, ...added]);
6533
+ }
6305
6534
  /** The blob as stored now; a failed read REFUSES the write instead of guessing. */
6306
6535
  async function readStoredAddonBlob(raw) {
6307
6536
  const threeWay = raw.readAddonStoreResult;
@@ -6310,7 +6539,41 @@ async function readStoredAddonBlob(raw) {
6310
6539
  if (result.kind === "failed") throw new Error(`settings write refused: the stored blob could not be read (${result.error})`);
6311
6540
  return result.kind === "missing" ? {} : result.value;
6312
6541
  }
6313
- function createSecretAwareSettings(raw, opts) {
6542
+ function touchesTree(tree, patch) {
6543
+ if (tree.size === 0) return false;
6544
+ for (const key of Object.keys(patch)) {
6545
+ const at = key.indexOf("@");
6546
+ if (tree.has(at > 0 ? key.slice(0, at) : key)) return true;
6547
+ }
6548
+ return false;
6549
+ }
6550
+ /**
6551
+ * Which top-level keys of each store held markers when last seen. `undefined`
6552
+ * for a store not seen yet: its first write reads it, to be safe.
6553
+ */
6554
+ var MarkerKeyIndex = class {
6555
+ owner;
6556
+ byStore = /* @__PURE__ */ new Map();
6557
+ constructor(owner) {
6558
+ this.owner = owner;
6559
+ }
6560
+ seen(store, blob) {
6561
+ this.byStore.set(store, markerKeysOf(blob, this.owner));
6562
+ }
6563
+ wrote(store, patch) {
6564
+ const keys = this.byStore.get(store);
6565
+ if (keys === void 0) return;
6566
+ const now = markerKeysOf(patch, this.owner);
6567
+ for (const key of Object.keys(patch)) if (now.has(key)) keys.add(key);
6568
+ else keys.delete(key);
6569
+ }
6570
+ mayHoldMarkers(store, patch) {
6571
+ const keys = this.byStore.get(store);
6572
+ if (keys === void 0) return true;
6573
+ return Object.keys(patch).some((key) => keys.has(key));
6574
+ }
6575
+ };
6576
+ function createHandle(raw, opts) {
6314
6577
  const chains = /* @__PURE__ */ new Map();
6315
6578
  const serialize = (key, fn) => {
6316
6579
  const next = (chains.get(key) ?? Promise.resolve()).then(fn, fn);
@@ -6321,46 +6584,130 @@ function createSecretAwareSettings(raw, opts) {
6321
6584
  });
6322
6585
  return next;
6323
6586
  };
6324
- const write = async (chainKey, tree, scope, patch, readStored, rawWrite) => {
6325
- if (!touchesTree(tree, patch)) return rawWrite(patch);
6326
- return serialize(chainKey, async () => {
6587
+ const index = new MarkerKeyIndex(opts.secrets.owner);
6588
+ const resolveRead = async (store, blob) => {
6589
+ index.seen(store, blob);
6590
+ const { value, unresolved } = await resolveSecretMarkers(blob, opts.secrets, {
6591
+ unresolved: "keep-marker",
6592
+ ownedBy: opts.secrets.owner
6593
+ });
6594
+ if (unresolved.length > 0) opts.onUnresolved?.(unresolved);
6595
+ return value;
6596
+ };
6597
+ const write = async (store, declared, scope, patch, readStored, rawWrite) => {
6598
+ if (!touchesTree(declared, patch) && !index.mayHoldMarkers(store, patch)) {
6599
+ await rawWrite(patch);
6600
+ index.wrote(store, patch);
6601
+ return { changed: true };
6602
+ }
6603
+ return serialize(store, async () => {
6327
6604
  const stored = await readStored();
6605
+ index.seen(store, stored);
6606
+ const operatorWrite = opts.isOperatorWrite?.() === true;
6607
+ const restored = await restoreUnchangedSecrets({
6608
+ patch,
6609
+ stored,
6610
+ secrets: opts.secrets,
6611
+ operatorWrite
6612
+ });
6328
6613
  const result = await transformSecretWrite({
6329
- tree,
6614
+ tree: widenTreeWithStoredMarkers(declared, stored, Object.keys(restored.patch), opts.secrets.owner),
6330
6615
  secrets: opts.secrets,
6331
- patch,
6616
+ patch: restored.patch,
6332
6617
  stored,
6333
6618
  ...scope !== void 0 ? { scope } : {},
6334
- operatorWrite: opts.isOperatorWrite?.() === true
6619
+ operatorWrite
6335
6620
  });
6336
- if (Object.keys(result.patch).length > 0) await rawWrite(result.patch);
6621
+ const effective = dropUnchangedKeys(result.patch, stored);
6622
+ const wroteBlob = Object.keys(effective).length > 0;
6623
+ if (wroteBlob) {
6624
+ await rawWrite(effective);
6625
+ index.wrote(store, effective);
6626
+ }
6337
6627
  const { orphaned } = await result.afterWrite();
6338
6628
  if (orphaned.length > 0) opts.onOrphaned(orphaned);
6629
+ return { changed: wroteBlob || restored.changedRefs.length > 0 };
6339
6630
  });
6340
6631
  };
6341
- const wrapped = {
6342
- writeAddonStore: (patch) => write("addon", opts.addonTree(), void 0, patch, () => readStoredAddonBlob(raw), (p) => raw.writeAddonStore(p)),
6343
- writeDeviceStore: (deviceId, patch) => write(`device:${deviceId}`, opts.deviceTree(), {
6344
- kind: "device",
6345
- deviceId
6346
- }, patch, () => raw.readDeviceStore(deviceId), (p) => raw.writeDeviceStore(deviceId, p))
6632
+ const writeAddon = (patch) => write("addon", opts.addonTree(), void 0, patch, () => readStoredAddonBlob(raw), (p) => raw.writeAddonStore(p));
6633
+ const readAddonStoreResult = raw.readAddonStoreResult;
6634
+ const readAddonStoreKeyResult = raw.readAddonStoreKeyResult;
6635
+ const readDeviceStoreBatch = raw.readDeviceStoreBatch;
6636
+ const overrides = {
6637
+ readAddonStore: async () => resolveRead("addon", await raw.readAddonStore()),
6638
+ ...readAddonStoreResult !== void 0 ? { readAddonStoreResult: async () => {
6639
+ const result = await readAddonStoreResult.call(raw);
6640
+ return result.kind === "value" ? {
6641
+ kind: "value",
6642
+ value: await resolveRead("addon", result.value)
6643
+ } : result;
6644
+ } } : {},
6645
+ ...readAddonStoreKeyResult !== void 0 ? { readAddonStoreKeyResult: async (key) => {
6646
+ const result = await readAddonStoreKeyResult.call(raw, key);
6647
+ if (result.kind !== "present") return result;
6648
+ const { value, unresolved } = await resolveSecretMarkers({ [key]: result.value }, opts.secrets, {
6649
+ unresolved: "keep-marker",
6650
+ ownedBy: opts.secrets.owner
6651
+ });
6652
+ if (unresolved.length > 0) opts.onUnresolved?.(unresolved);
6653
+ return {
6654
+ kind: "present",
6655
+ value: value[key]
6656
+ };
6657
+ } } : {},
6658
+ readDeviceStore: async (deviceId) => resolveRead(`device:${deviceId}`, await raw.readDeviceStore(deviceId)),
6659
+ ...readDeviceStoreBatch !== void 0 ? { readDeviceStoreBatch: async (deviceIds) => {
6660
+ const rows = await readDeviceStoreBatch.call(raw, deviceIds);
6661
+ const out = /* @__PURE__ */ new Map();
6662
+ for (const [deviceId, blob] of rows) out.set(deviceId, await resolveRead(`device:${deviceId}`, blob));
6663
+ return out;
6664
+ } } : {},
6665
+ writeAddonStore: async (patch) => {
6666
+ await writeAddon(patch);
6667
+ },
6668
+ writeDeviceStore: async (deviceId, patch) => {
6669
+ await write(`device:${deviceId}`, opts.deviceTree(), {
6670
+ kind: "device",
6671
+ deviceId
6672
+ }, patch, () => raw.readDeviceStore(deviceId), (p) => raw.writeDeviceStore(deviceId, p));
6673
+ }
6674
+ };
6675
+ return {
6676
+ settings: new Proxy(raw, { get(target, prop, receiver) {
6677
+ if (typeof prop === "string" && Object.prototype.hasOwnProperty.call(overrides, prop)) return Reflect.get(overrides, prop);
6678
+ const value = Reflect.get(target, prop, receiver);
6679
+ return typeof value === "function" ? value.bind(target) : value;
6680
+ } }),
6681
+ raw: {
6682
+ readAddonStore: async () => {
6683
+ const blob = await raw.readAddonStore();
6684
+ index.seen("addon", blob);
6685
+ return blob;
6686
+ },
6687
+ readDeviceStore: async (deviceId) => {
6688
+ const blob = await raw.readDeviceStore(deviceId);
6689
+ index.seen(`device:${deviceId}`, blob);
6690
+ return blob;
6691
+ }
6692
+ },
6693
+ writeAddonStore: writeAddon
6347
6694
  };
6348
- return new Proxy(raw, { get(target, prop, receiver) {
6349
- if (prop === "writeAddonStore") return wrapped.writeAddonStore;
6350
- if (prop === "writeDeviceStore") return wrapped.writeDeviceStore;
6351
- const value = Reflect.get(target, prop, receiver);
6352
- return typeof value === "function" ? value.bind(target) : value;
6353
- } });
6354
6695
  }
6355
- /** The context the addon sees: identical, except that its settings writes are secret-aware. */
6356
- function withSecretAwareSettings(context, opts) {
6696
+ /** The context the addon sees, plus the private raw view and write outcome. */
6697
+ function createSecretAwareContext(context, opts) {
6357
6698
  const raw = context.settings;
6358
- if (raw === void 0) return context;
6359
- const settings = createSecretAwareSettings(raw, opts);
6360
- return new Proxy(context, { get(target, prop, receiver) {
6361
- if (prop === "settings") return settings;
6362
- return Reflect.get(target, prop, receiver);
6363
- } });
6699
+ if (raw === void 0) return {
6700
+ context,
6701
+ handle: null
6702
+ };
6703
+ const handle = createHandle(raw, opts);
6704
+ return {
6705
+ context: new Proxy(context, { get(target, prop, receiver) {
6706
+ if (prop === "settings") return handle.settings;
6707
+ return Reflect.get(target, prop, receiver);
6708
+ } }),
6709
+ handle
6710
+ };
6364
6711
  }
6365
6712
  var LEAF = { kind: "leaf" };
6366
6713
  var DEFAULT_ITEM_ID_KEY = "id";
@@ -6535,6 +6882,14 @@ var BaseAddon = class {
6535
6882
  _secretChangeUnsub = null;
6536
6883
  /** >0 while an OPERATOR's settings write is being applied. */
6537
6884
  _operatorWriteDepth = 0;
6885
+ /**
6886
+ * The keychain-aware settings handle (D798). Its `raw` view is the ONLY way
6887
+ * to the marker-bearing blobs and stays private to this class: the form
6888
+ * hydrate and config resolution need markers, addon code never does.
6889
+ */
6890
+ _secretSettings = null;
6891
+ /** Refs an addon-facing read could not resolve — each is logged once per process. */
6892
+ _loggedUnresolvedReads = /* @__PURE__ */ new Set();
6538
6893
  constructor(defaults) {
6539
6894
  this.defaults = defaults;
6540
6895
  this._config = { ...defaults };
@@ -6571,13 +6926,21 @@ var BaseAddon = class {
6571
6926
  }
6572
6927
  async initialize(context) {
6573
6928
  const secrets = context.secrets;
6574
- this._ctx = secrets !== void 0 ? withSecretAwareSettings(context, {
6575
- secrets,
6576
- addonTree: () => this.addonSecretTree(),
6577
- deviceTree: () => this.deviceSecretTree(),
6578
- onOrphaned: (refs) => context.logger.warn("keychain refs dropped by a settings write could not be deleted", { meta: { refs: [...refs] } }),
6579
- isOperatorWrite: () => this._operatorWriteDepth > 0
6580
- }) : context;
6929
+ if (secrets !== void 0) {
6930
+ const { context: wrapped, handle } = createSecretAwareContext(context, {
6931
+ secrets,
6932
+ addonTree: () => this.addonSecretTree(),
6933
+ deviceTree: () => this.deviceSecretTree(),
6934
+ onOrphaned: (refs) => context.logger.warn("keychain refs dropped by a settings write could not be deleted", { meta: { refs: [...refs] } }),
6935
+ isOperatorWrite: () => this._operatorWriteDepth > 0,
6936
+ onUnresolved: (unresolved) => this.logUnresolvedRead(unresolved)
6937
+ });
6938
+ this._ctx = wrapped;
6939
+ this._secretSettings = handle;
6940
+ } else {
6941
+ this._ctx = context;
6942
+ this._secretSettings = null;
6943
+ }
6581
6944
  await this.resolveConfig();
6582
6945
  if (secrets !== void 0) this._secretChangeUnsub = secrets.onChange((ref) => {
6583
6946
  if (this._configSecretRefs.has(ref)) this.scheduleSecretReresolve(SECRET_CHANGE_DEBOUNCE_MS);
@@ -6694,11 +7057,8 @@ var BaseAddon = class {
6694
7057
  async getGlobalSettings(overlay, cap, nodeId) {
6695
7058
  const schema = this.globalSettingsSchema(cap);
6696
7059
  if (!schema) return { sections: [] };
6697
- const projected = await this.resolveGlobalStore(nodeId, cap);
6698
- return hydrateSchema(schema, overlay ? {
6699
- ...projected,
6700
- ...overlay
6701
- } : projected, { inlineSecretsAsViews: true });
7060
+ const projected = await this.readRawProjectedStore(nodeId, cap);
7061
+ return hydrateSchema(schema, overlay ? await this.overlayKeepingMarkers(projected, overlay) : projected, { inlineSecretsAsViews: true });
6702
7062
  }
6703
7063
  /**
6704
7064
  * The integration-level view of this addon's settings: exactly the sections
@@ -6743,7 +7103,7 @@ var BaseAddon = class {
6743
7103
  });
6744
7104
  }
6745
7105
  if (sections.length === 0) return null;
6746
- const projected = await this.resolveGlobalStore(nodeId);
7106
+ const projected = await this.readRawProjectedStore(nodeId);
6747
7107
  return hydrateSchema({
6748
7108
  ...schema,
6749
7109
  sections
@@ -6760,12 +7120,50 @@ var BaseAddon = class {
6760
7120
  * the store for custom option logic (option narrowing, value snapping) to
6761
7121
  * read it per-node — never `ctx.settings.readAddonStore()` directly.
6762
7122
  * `nodeId` omitted ⇒ the local node (node-blind injection from ctx).
7123
+ *
7124
+ * Keychain values come back RESOLVED (D798): a secret reads as its value,
7125
+ * never as a `{ $secret }` marker. One the keychain cannot serve right now
7126
+ * stays a marker — "stored, unavailable" (`isSecretMarker()` is true, and it
7127
+ * is listed in {@link unresolvedSecrets}) — never `''` and never absent, so
7128
+ * it cannot be mistaken for "nothing stored, mint a new one". Writing the
7129
+ * resolved blob back is a no-op for every unchanged secret.
6763
7130
  */
6764
7131
  async resolveGlobalStore(nodeId, cap) {
6765
7132
  const raw = await this._ctx?.settings?.readAddonStore() ?? {};
7133
+ return this.projectForNode(raw, nodeId, cap);
7134
+ }
7135
+ projectForNode(store, nodeId, cap) {
6766
7136
  const keys = this.perNodeKeys(cap);
6767
7137
  const node = normalizeNodeId(nodeId ?? this._ctx?.kernel?.localNodeId);
6768
- return keys.size > 0 ? projectStore(raw, keys, node) : raw;
7138
+ return keys.size > 0 ? projectStore(store, keys, node) : store;
7139
+ }
7140
+ /** The PROJECTED store with its markers — the form hydrate only (D798). */
7141
+ async readRawProjectedStore(nodeId, cap) {
7142
+ const raw = await this.rawSettings()?.readAddonStore() ?? {};
7143
+ return this.projectForNode(raw, nodeId, cap);
7144
+ }
7145
+ /**
7146
+ * `{ ...stored, ...overlay }`, except that an overlay member equal to the
7147
+ * RESOLVED stored one keeps the stored (marker-bearing) member — so a form
7148
+ * hydrated from a resolved overlay still shows a secret as "set", never as
7149
+ * its value.
7150
+ */
7151
+ async overlayKeepingMarkers(stored, overlay) {
7152
+ const secrets = this._ctx?.secrets;
7153
+ const merged = {
7154
+ ...stored,
7155
+ ...overlay
7156
+ };
7157
+ if (secrets === void 0 || collectSecretMarkerRefs(stored).length === 0) return merged;
7158
+ const { value: resolved } = await resolveSecretMarkers(stored, secrets, {
7159
+ unresolved: "keep-marker",
7160
+ ownedBy: secrets.owner
7161
+ });
7162
+ for (const key of Object.keys(overlay)) {
7163
+ if (collectSecretMarkerRefs(stored[key]).length === 0) continue;
7164
+ if (isJsonEqual(overlay[key], resolved[key])) merged[key] = stored[key];
7165
+ }
7166
+ return merged;
6769
7167
  }
6770
7168
  /**
6771
7169
  * Whether ONE global key of this addon's store was written, read three-way
@@ -6830,8 +7228,12 @@ var BaseAddon = class {
6830
7228
  async clearSecrets(keys, nodeId) {
6831
7229
  const tree = this.addonSecretTree();
6832
7230
  const keychain = this._ctx?.secrets !== void 0;
7231
+ const stored = keychain ? await this.readAddonStoreWithRetry() : {};
6833
7232
  const patch = {};
6834
- for (const key of keys) patch[key] = keychain && tree.has(key) ? SECRET_CLEAR : "";
7233
+ for (const key of keys) {
7234
+ const keychainStored = tree.has(key) || collectSecretMarkerRefs(stored[key]).length > 0;
7235
+ patch[key] = keychain && keychainStored ? SECRET_CLEAR : "";
7236
+ }
6835
7237
  await this.applyGlobalPatch(patch, nodeId);
6836
7238
  }
6837
7239
  async applyGlobalPatch(barePatch, nodeId) {
@@ -6839,7 +7241,11 @@ var BaseAddon = class {
6839
7241
  const localNode = normalizeNodeId(this._ctx?.kernel?.localNodeId);
6840
7242
  const target = normalizeNodeId(nodeId ?? this._ctx?.kernel?.localNodeId);
6841
7243
  const scoped = keys.size > 0 ? scopePatch(barePatch, keys, target) : barePatch;
6842
- await this._ctx?.settings?.writeAddonStore(scoped);
7244
+ const handle = this._secretSettings;
7245
+ if (handle !== null) {
7246
+ const { changed } = await handle.writeAddonStore(scoped);
7247
+ if (!changed) return;
7248
+ } else await this._ctx?.settings?.writeAddonStore(scoped);
6843
7249
  if (target !== localNode) return;
6844
7250
  await this.resolveConfig();
6845
7251
  await this.onConfigChanged();
@@ -6892,7 +7298,7 @@ var BaseAddon = class {
6892
7298
  async getDeviceSettings(deviceId) {
6893
7299
  const schema = this.deviceSettingsSchema();
6894
7300
  if (!schema) return { sections: [] };
6895
- return hydrateSchema(schema, await this._ctx?.settings?.readDeviceStore(deviceId) ?? {}, { inlineSecretsAsViews: true });
7301
+ return hydrateSchema(schema, await this.rawSettings()?.readDeviceStore(deviceId) ?? {}, { inlineSecretsAsViews: true });
6896
7302
  }
6897
7303
  async updateDeviceSettings(deviceId, patch) {
6898
7304
  await this._ctx?.settings?.writeDeviceStore(deviceId, patch);
@@ -7064,7 +7470,7 @@ var BaseAddon = class {
7064
7470
  key,
7065
7471
  schema,
7066
7472
  fallback,
7067
- read: async () => this.resolveStoredSecrets(await this._ctx?.settings?.readDeviceStore(deviceId) ?? {}, false),
7473
+ read: async () => this.resolveStoredSecrets(await this.rawSettings()?.readDeviceStore(deviceId) ?? {}, false),
7068
7474
  write: async (patch) => {
7069
7475
  await this._ctx?.settings?.writeDeviceStore(deviceId, patch);
7070
7476
  },
@@ -7126,6 +7532,23 @@ var BaseAddon = class {
7126
7532
  }
7127
7533
  return value;
7128
7534
  }
7535
+ /**
7536
+ * The marker-bearing settings reads (D798) — private on purpose. Without a
7537
+ * keychain the context's own view is already raw.
7538
+ */
7539
+ rawSettings() {
7540
+ return this._secretSettings?.raw ?? this._ctx?.settings;
7541
+ }
7542
+ /** An addon-facing read met markers it could not resolve: say so once per ref. */
7543
+ logUnresolvedRead(unresolved) {
7544
+ const fresh = unresolved.filter((u) => !this._loggedUnresolvedReads.has(u.ref));
7545
+ if (fresh.length === 0) return;
7546
+ for (const u of fresh) this._loggedUnresolvedReads.add(u.ref);
7547
+ 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) => ({
7548
+ ref: u.ref,
7549
+ reason: u.reason
7550
+ })) } });
7551
+ }
7129
7552
  /** Re-resolve the config (a keychain-only change, or a retry) and apply it. */
7130
7553
  scheduleSecretReresolve(delayMs) {
7131
7554
  const timerOf = delayMs === SECRET_CHANGE_DEBOUNCE_MS ? "_secretChangeTimer" : "_secretRetryTimer";
@@ -7152,7 +7575,7 @@ var BaseAddon = class {
7152
7575
  * `{}` (defaults) — the addon's first successful patch will rehydrate.
7153
7576
  */
7154
7577
  async readAddonStoreWithRetry() {
7155
- const settings = this._ctx?.settings;
7578
+ const settings = this.rawSettings();
7156
7579
  if (!settings) return {};
7157
7580
  const delaysMs = [
7158
7581
  150,
@@ -8897,6 +9320,16 @@ var CompositionSchema = object({
8897
9320
  seen.add(feature.cap);
8898
9321
  });
8899
9322
  });
9323
+ var NodeColorIdSchema = _enum([
9324
+ "node-a",
9325
+ "node-b",
9326
+ "node-c",
9327
+ "node-d",
9328
+ "node-e",
9329
+ "node-f",
9330
+ "node-g",
9331
+ "node-h"
9332
+ ]);
8900
9333
  new Set([
8901
9334
  "track",
8902
9335
  "face",
@@ -9388,6 +9821,278 @@ var CameraSwitchGroupSchema = object({
9388
9821
  fetchedAt: number()
9389
9822
  });
9390
9823
  /**
9824
+ * The trainer contract — what the hub hands the cloud trainer and what it
9825
+ * gets back (cloud training, D805+).
9826
+ *
9827
+ * The trainer (`hf/camstack-trainer`, published as the Hugging Face repo
9828
+ * `camstack/camstack-trainer`) is a separate AGPL program the hub never
9829
+ * imports: `job.json` goes in, files come out, and progress is `CAMSTACK_EVENT`
9830
+ * lines on stdout. These schemas are the hub's half of that boundary; the
9831
+ * trainer's pydantic models (and the JSON Schemas generated from them under
9832
+ * `hf/camstack-trainer/schemas/`) are the other half. A change here is a
9833
+ * change there, in the same piece of work.
9834
+ *
9835
+ * No `.default()` anywhere: defaults do not run on the addon cap path, so the
9836
+ * orchestrator fills every field of a job spec explicitly.
9837
+ */
9838
+ var TRAINING_JOB_SCHEMA = "camstack.training/v1";
9839
+ var TRAINING_RESULT_SCHEMA = "camstack.training-result/v1";
9840
+ /** What the trainer can export. Edge TPU is a later, separate image. */
9841
+ var TrainingExportSchema = _enum([
9842
+ "onnx",
9843
+ "openvino-fp16",
9844
+ "openvino-int8",
9845
+ "coreml-fp16"
9846
+ ]);
9847
+ var FloorsSchema = record(string(), number().min(0).max(1));
9848
+ object({
9849
+ schema: literal(TRAINING_JOB_SCHEMA),
9850
+ jobKey: string().uuid(),
9851
+ target: object({
9852
+ kind: literal("detector"),
9853
+ step: literal("object-detection")
9854
+ }),
9855
+ base: object({
9856
+ modelId: string().min(1),
9857
+ /** Ultralytics weights id, e.g. `yolov9m.pt`. */
9858
+ weights: string().min(1),
9859
+ imgsz: number().int().positive()
9860
+ }),
9861
+ baseline: object({
9862
+ modelId: string().min(1),
9863
+ /** The baseline ONNX the holdout comparison runs; public mirror URL. */
9864
+ onnxUrl: string().url(),
9865
+ imgsz: number().int().positive(),
9866
+ floors: FloorsSchema
9867
+ }),
9868
+ dataset: object({
9869
+ versionId: string().min(1),
9870
+ annotationHash: string(),
9871
+ /** sha256 of the uploaded archive; the trainer refuses a mismatch (exit 65). */
9872
+ sha256: string().regex(/^[0-9a-f]{64}$/)
9873
+ }),
9874
+ split: object({
9875
+ holdoutCameras: array(number().int()),
9876
+ /** When no camera is held out: the last N days of every camera. */
9877
+ holdoutLastDays: number().int().nonnegative(),
9878
+ valFraction: number().min(0).max(.5),
9879
+ seed: number().int()
9880
+ }),
9881
+ hyper: object({
9882
+ epochs: number().int().positive(),
9883
+ batch: number().int().positive(),
9884
+ lr0: number().positive(),
9885
+ /** Layers frozen from the start of the backbone; 0 = none. */
9886
+ freeze: number().int().nonnegative(),
9887
+ patience: number().int().nonnegative(),
9888
+ seed: number().int()
9889
+ }),
9890
+ replay: object({
9891
+ source: literal("coco2017"),
9892
+ count: number().int().nonnegative()
9893
+ }),
9894
+ exports: array(TrainingExportSchema).min(1),
9895
+ calibration: object({ maxFrames: number().int().positive() }),
9896
+ floors: object({
9897
+ minSupport: number().int().positive(),
9898
+ clamp: number().min(0).max(1)
9899
+ }),
9900
+ int8Gate: object({ maxMap50Drop: number().min(0).max(1) }),
9901
+ catalog: object({
9902
+ id: string().regex(/^[a-z0-9][a-z0-9-]{2,80}$/),
9903
+ name: string().min(1).max(160)
9904
+ })
9905
+ });
9906
+ /** One regular file of the bundle. An mlpackage contributes one row per member. */
9907
+ var TrainingResultFileSchema = object({
9908
+ path: string().min(1),
9909
+ bytes: number().int().nonnegative(),
9910
+ sha256: string().regex(/^[0-9a-f]{64}$/),
9911
+ format: _enum([
9912
+ "onnx",
9913
+ "openvino",
9914
+ "coreml",
9915
+ "pt"
9916
+ ]),
9917
+ variant: _enum(["base", "int8"])
9918
+ });
9919
+ var DraftFormatSchema = object({
9920
+ /** RELATIVE path inside the bundle; the hub rewrites it to `camstack-local://`. */
9921
+ url: string().min(1),
9922
+ sizeMB: number().nonnegative(),
9923
+ isDirectory: boolean().optional(),
9924
+ files: array(string()).optional(),
9925
+ runtimes: array(literal("python")).optional(),
9926
+ revision: string().min(1)
9927
+ });
9928
+ /** The trainer's half of a catalog entry; the hub completes it (labels, licence, group). */
9929
+ var TrainingCatalogDraftSchema = object({
9930
+ id: string().min(1),
9931
+ name: string().min(1),
9932
+ description: string(),
9933
+ labels: array(unknown()),
9934
+ inputSize: object({
9935
+ width: number().int().positive(),
9936
+ height: number().int().positive()
9937
+ }),
9938
+ preprocessMode: literal("letterbox"),
9939
+ defaultClassFloors: FloorsSchema,
9940
+ formats: object({
9941
+ onnx: DraftFormatSchema.optional(),
9942
+ openvino: DraftFormatSchema.optional(),
9943
+ coreml: DraftFormatSchema.optional()
9944
+ })
9945
+ });
9946
+ /** One class of one model's holdout report (the eval harness's summary). */
9947
+ var TrainingEvalClassSchema = object({
9948
+ positives: number().int(),
9949
+ floor: number().nullable(),
9950
+ tp: number().int(),
9951
+ fp: number().int(),
9952
+ fn: number().int(),
9953
+ precision: number().nullable(),
9954
+ recall: number().nullable(),
9955
+ ap50: number().nullable(),
9956
+ recallByCamera: record(string(), number().nullable()).optional(),
9957
+ recallByLight: record(string(), number().nullable()).optional(),
9958
+ fpByCamera: record(string(), number()).optional(),
9959
+ smallFound: number().int().optional(),
9960
+ smallTotal: number().int().optional()
9961
+ }).passthrough();
9962
+ var TrainingEvalReportSchema = object({
9963
+ frames: number().int(),
9964
+ classes: record(string(), TrainingEvalClassSchema)
9965
+ }).passthrough();
9966
+ /**
9967
+ * A succeeded result carries every block; a failed one carries the error and
9968
+ * whatever was known by then — the other blocks are ABSENT, not null. The
9969
+ * orchestrator checks the blocks it needs before it trusts a success.
9970
+ */
9971
+ var TrainingResultSchema = object({
9972
+ schema: literal(TRAINING_RESULT_SCHEMA),
9973
+ jobKey: string(),
9974
+ status: _enum(["succeeded", "failed"]),
9975
+ error: object({
9976
+ stage: string(),
9977
+ code: string(),
9978
+ message: string()
9979
+ }).nullable(),
9980
+ trainer: object({
9981
+ version: string(),
9982
+ revision: string()
9983
+ }),
9984
+ toolchain: record(string(), string().nullable()),
9985
+ dataset: object({
9986
+ versionId: string(),
9987
+ annotationHash: string(),
9988
+ sha256: string(),
9989
+ frames: object({
9990
+ train: number().int(),
9991
+ val: number().int(),
9992
+ holdout: number().int()
9993
+ }),
9994
+ holdoutCameras: array(number().int()),
9995
+ replayImages: number().int()
9996
+ }).optional(),
9997
+ training: object({
9998
+ epochsRun: number().int(),
9999
+ bestEpoch: number().int(),
10000
+ bestMap50: number(),
10001
+ bestMap50_95: number(),
10002
+ seconds: number()
10003
+ }).optional(),
10004
+ evaluation: object({
10005
+ holdoutFrames: number().int(),
10006
+ baseline: TrainingEvalReportSchema.nullable(),
10007
+ candidate: TrainingEvalReportSchema.nullable(),
10008
+ candidateInt8: TrainingEvalReportSchema.nullable(),
10009
+ recallDeltaByCamera: record(string(), record(string(), number())).nullable(),
10010
+ map50: record(string(), number().nullable())
10011
+ }).optional(),
10012
+ floors: object({
10013
+ baseline: FloorsSchema,
10014
+ candidate: FloorsSchema,
10015
+ candidateInt8: FloorsSchema.nullable(),
10016
+ notes: array(string())
10017
+ }).optional(),
10018
+ int8: object({
10019
+ kept: boolean(),
10020
+ map50Fp16: number().nullable(),
10021
+ map50Int8: number().nullable(),
10022
+ reason: string().nullable()
10023
+ }).optional(),
10024
+ exportsDropped: array(object({
10025
+ export: string(),
10026
+ reason: string()
10027
+ })).optional(),
10028
+ files: array(TrainingResultFileSchema).optional(),
10029
+ bundle: object({
10030
+ path: literal("bundle.tar"),
10031
+ bytes: number().int().nonnegative(),
10032
+ sha256: string().regex(/^[0-9a-f]{64}$/)
10033
+ }).nullable().optional(),
10034
+ catalogDraft: object({
10035
+ base: TrainingCatalogDraftSchema,
10036
+ int8: TrainingCatalogDraftSchema.nullable()
10037
+ }).nullable().optional(),
10038
+ licence: string()
10039
+ });
10040
+ var TrainingStageSchema = _enum([
10041
+ "prepare",
10042
+ "replay",
10043
+ "train",
10044
+ "eval",
10045
+ "export",
10046
+ "package"
10047
+ ]);
10048
+ var EventBase = {
10049
+ v: literal(1),
10050
+ ts: number()
10051
+ };
10052
+ discriminatedUnion("type", [
10053
+ object({
10054
+ ...EventBase,
10055
+ type: literal("stage"),
10056
+ stage: TrainingStageSchema
10057
+ }),
10058
+ object({
10059
+ ...EventBase,
10060
+ type: literal("epoch"),
10061
+ epoch: number().int(),
10062
+ epochs: number().int(),
10063
+ boxLoss: number().nullable().optional(),
10064
+ map50: number().nullable().optional(),
10065
+ map50_95: number().nullable().optional(),
10066
+ etaSec: number().nullable().optional()
10067
+ }),
10068
+ object({
10069
+ ...EventBase,
10070
+ type: literal("metric"),
10071
+ name: string(),
10072
+ value: number()
10073
+ }),
10074
+ object({
10075
+ ...EventBase,
10076
+ type: literal("artifact"),
10077
+ path: string(),
10078
+ bytes: number(),
10079
+ sha256: string()
10080
+ }),
10081
+ object({
10082
+ ...EventBase,
10083
+ type: literal("done"),
10084
+ status: _enum(["succeeded", "failed"]),
10085
+ resultSha256: string().nullable().optional()
10086
+ }),
10087
+ object({
10088
+ ...EventBase,
10089
+ type: literal("error"),
10090
+ stage: string(),
10091
+ code: string(),
10092
+ message: string()
10093
+ })
10094
+ ]);
10095
+ /**
9391
10096
  * What the gate decided about a birth, from the CALLER's point of view.
9392
10097
  *
9393
10098
  * Deliberately not `ConfirmationVerdict`: `undecided` is not a birth decision
@@ -11715,7 +12420,9 @@ var AddonHttpRouteSchema = object({
11715
12420
  "authenticated",
11716
12421
  "admin"
11717
12422
  ]).optional(),
11718
- description: string().optional()
12423
+ description: string().optional(),
12424
+ /** The hub limits this route per client address before the handler runs. */
12425
+ rateLimit: _enum(["auth"]).optional()
11719
12426
  });
11720
12427
  /**
11721
12428
  * Cross-process route invocation envelope. The hub captures the
@@ -12420,6 +13127,37 @@ var BackupDestinationInfoSchema = object({
12420
13127
  lastError: string().optional()
12421
13128
  });
12422
13129
  /**
13130
+ * How an archive is encrypted (operator decision 2026-10-09): to a backup
13131
+ * PUBLIC key the hub holds, so only the operator's secret key opens it.
13132
+ * Absent on a plain `.tar.gz` — every archive made before encryption, or
13133
+ * with it off — which restores without a key.
13134
+ */
13135
+ var BackupArchiveEncryptionSchema = object({
13136
+ /** `x25519-hkdf-aes256gcm-stream-v1`. */
13137
+ scheme: string(),
13138
+ /** 16 hex — the backup key whose secret restores this archive. */
13139
+ keyId: string()
13140
+ });
13141
+ /**
13142
+ * The backup encryption setting. The hub keeps PUBLIC keys only: the active
13143
+ * one new archives are encrypted to, and the retired ones older archives
13144
+ * still need. The secret key is shown once, at `setupEncryption`.
13145
+ */
13146
+ var BackupEncryptionStatusSchema = object({
13147
+ enabled: boolean(),
13148
+ active: object({
13149
+ keyId: string(),
13150
+ publicKey: string(),
13151
+ createdAt: number()
13152
+ }).nullable(),
13153
+ /** Every key ever set up, newest first. */
13154
+ keys: array(object({
13155
+ keyId: string(),
13156
+ createdAt: number(),
13157
+ retiredAt: number().nullable()
13158
+ })).readonly()
13159
+ });
13160
+ /**
12423
13161
  * Per-archive entry returned by `backup.listArchives({ destinationId })`.
12424
13162
  * Same shape the destination drill-in renders. Sourced from the per-
12425
13163
  * location `manifests.json` (no per-archive tarball read required).
@@ -12431,7 +13169,9 @@ var BackupArchiveEntrySchema = object({
12431
13169
  sizeBytes: number(),
12432
13170
  label: string().optional(),
12433
13171
  /** Top-level locations included in the archive (db, addons, tls, …). */
12434
- locations: array(string()).readonly()
13172
+ locations: array(string()).readonly(),
13173
+ /** Present when the archive is encrypted; restore then needs that key. */
13174
+ encryption: BackupArchiveEncryptionSchema.optional()
12435
13175
  });
12436
13176
  var BackupEntrySchema = object({
12437
13177
  id: string(),
@@ -12440,7 +13180,8 @@ var BackupEntrySchema = object({
12440
13180
  label: string().optional(),
12441
13181
  createdAt: number(),
12442
13182
  sizeBytes: number(),
12443
- locations: array(string()).optional()
13183
+ locations: array(string()).optional(),
13184
+ encryption: BackupArchiveEncryptionSchema.optional()
12444
13185
  });
12445
13186
  var ArchiveEntrySchema = object({
12446
13187
  path: string(),
@@ -12629,10 +13370,40 @@ method(_void(), array(BackupDestinationInfoSchema).readonly(), { auth: "admin" }
12629
13370
  * this list and skips entries whose path doesn't start with
12630
13371
  * any of them.
12631
13372
  */
12632
- locations: array(string()).optional()
13373
+ locations: array(string()).optional(),
13374
+ /**
13375
+ * The backup SECRET key, for an encrypted archive (ignored for a plain
13376
+ * one). The archive is decrypted into the hub's private staging
13377
+ * before the restart; the key is not stored. A wrong or missing key
13378
+ * is refused before the archive is downloaded.
13379
+ */
13380
+ backupSecretKey: string().optional()
12633
13381
  }), _void(), {
12634
13382
  kind: "mutation",
12635
13383
  auth: "admin"
13384
+ }), method(_void(), BackupEncryptionStatusSchema, { auth: "admin" }), method(object({}), object({
13385
+ keyId: string(),
13386
+ secretKey: string(),
13387
+ publicKey: string(),
13388
+ createdAt: number(),
13389
+ replacedKeyId: string().nullable()
13390
+ }), {
13391
+ kind: "mutation",
13392
+ auth: "admin"
13393
+ }), method(object({}), object({ disabledKeyId: string().nullable() }), {
13394
+ kind: "mutation",
13395
+ auth: "admin"
13396
+ }), method(object({ backupSecretKey: string() }), object({
13397
+ valid: boolean(),
13398
+ keyId: string().nullable(),
13399
+ /** The hub knows this key (active or retired). */
13400
+ known: boolean(),
13401
+ /** It is the key new archives are encrypted to. */
13402
+ active: boolean(),
13403
+ error: string().optional()
13404
+ }), {
13405
+ kind: "mutation",
13406
+ auth: "admin"
12636
13407
  }), method(object({
12637
13408
  destinationId: string(),
12638
13409
  backupId: string()
@@ -14256,7 +15027,60 @@ var CustomModelDescriptorSchema = object({
14256
15027
  stepId: string(),
14257
15028
  entry: ModelCatalogEntrySchema
14258
15029
  });
14259
- method(_void(), array(CustomModelDescriptorSchema).readonly(), { auth: "admin" });
15030
+ /** One regular file of an imported bundle, as the producer measured it. */
15031
+ var ModelBundleFileSchema = object({
15032
+ /** Relative path inside the bundle tar; an mlpackage member is `<x>.mlpackage/<member>`. */
15033
+ path: string().min(1),
15034
+ bytes: number().int().nonnegative(),
15035
+ sha256: string().regex(/^[0-9a-f]{64}$/)
15036
+ });
15037
+ var ImportModelBundleInputSchema = object({
15038
+ /** The registry provider that keeps the model (Model Studio). */
15039
+ addonId: string(),
15040
+ stepId: string().min(1),
15041
+ /**
15042
+ * The catalog rows to register, complete, every format URL already
15043
+ * `camstack-local://<modelId>/<file>` naming a file of the bundle. One
15044
+ * bundle may carry several rows (a base and its INT8 variant).
15045
+ */
15046
+ entries: array(ModelCatalogEntrySchema).min(1).max(4),
15047
+ /** The bundle tar, offered by the producer over `ctx.peerBytes` (same host). */
15048
+ bundle: object({
15049
+ ticket: PeerBytesTicketSchema,
15050
+ bytes: number().int().positive(),
15051
+ sha256: string().regex(/^[0-9a-f]{64}$/)
15052
+ }),
15053
+ /** Every file the tar must hold; anything missing, extra or different is refused. */
15054
+ files: array(ModelBundleFileSchema).min(1).max(64),
15055
+ /** Convert missing engine formats and push the model to every agent afterwards. */
15056
+ distribute: boolean()
15057
+ });
15058
+ var ImportModelBundleResultSchema = discriminatedUnion("kind", [object({
15059
+ kind: literal("imported"),
15060
+ modelIds: array(string()).readonly(),
15061
+ distributed: array(object({
15062
+ modelId: string(),
15063
+ nodeId: string(),
15064
+ format: _enum(MODEL_FORMATS),
15065
+ ok: boolean(),
15066
+ error: string().optional()
15067
+ })).readonly()
15068
+ }), object({
15069
+ kind: literal("refused"),
15070
+ reason: _enum([
15071
+ "transfer-failed",
15072
+ "checksum-mismatch",
15073
+ "bundle-mismatch",
15074
+ "invalid-entry",
15075
+ "id-taken"
15076
+ ]),
15077
+ detail: string()
15078
+ })]);
15079
+ method(_void(), array(CustomModelDescriptorSchema).readonly(), { auth: "admin" }), method(ImportModelBundleInputSchema, ImportModelBundleResultSchema, {
15080
+ kind: "mutation",
15081
+ auth: "admin",
15082
+ timeoutMs: 30 * 6e4
15083
+ });
14260
15084
  /**
14261
15085
  * Query filter for settings-store collections.
14262
15086
  */
@@ -14735,6 +15559,35 @@ var KeychainKeySourceSchema = object({
14735
15559
  */
14736
15560
  sharesBackupWithDatabase: boolean()
14737
15561
  });
15562
+ /**
15563
+ * One keychain reset, as the Secrets page reports it until the operator
15564
+ * acknowledges it. Never a value: refs, counts and table names only.
15565
+ */
15566
+ var KeychainResetRecordSchema = object({
15567
+ id: string(),
15568
+ at: number(),
15569
+ /** `user:<id>` or {@link KEYCHAIN_RESET_TRIGGER_ACTOR}. */
15570
+ actor: string(),
15571
+ /** Why the keychain was locked when it was reset; `null` when it was not locked. */
15572
+ lockedReason: string().nullable(),
15573
+ /** Values moved into the archive table (ciphertext under the lost key). */
15574
+ archived: number().int(),
15575
+ /** `keychain:secrets-orphaned-<ts>`, or `null` when nothing was stored. */
15576
+ archivedCollection: string().nullable(),
15577
+ /**
15578
+ * `keychain:keys-orphaned-<ts>`: the wrapped data keys of the archive, kept
15579
+ * so the archive can still be opened if the lost master key turns up.
15580
+ */
15581
+ archivedKeysCollection: string().nullable(),
15582
+ /**
15583
+ * `system-settings` keys whose marker the reset cleared — the cluster
15584
+ * secret's: a marker left pointing at an archived value would refuse every
15585
+ * agent forever (D797).
15586
+ */
15587
+ clearedSettingsKeys: array(string()).readonly(),
15588
+ /** When an operator dismissed the notice on the Secrets page; `null` until then. */
15589
+ acknowledgedAt: number().nullable()
15590
+ });
14738
15591
  var KeychainStatusSchema = object({
14739
15592
  keychain: KeychainStateSchema,
14740
15593
  /** The source of the master key in use; `null` while locked. */
@@ -14752,7 +15605,9 @@ var KeychainStatusSchema = object({
14752
15605
  /** Wrapped copies of the data key under a previous master key, kept until purged. */
14753
15606
  retiredWraps: number().int(),
14754
15607
  recoveryKeyDownloadedAt: number().nullable(),
14755
- secretCount: number().int()
15608
+ secretCount: number().int(),
15609
+ /** The most recent reset, acknowledged or not; `null` when the keychain was never reset. */
15610
+ lastReset: KeychainResetRecordSchema.nullable()
14756
15611
  });
14757
15612
  /**
14758
15613
  * Whether a stored value is still pointed at by its owner's settings.
@@ -14774,13 +15629,14 @@ var KeychainAuditActionSchema = _enum([
14774
15629
  "download-recovery-key",
14775
15630
  "delete-orphans",
14776
15631
  "reset",
15632
+ "acknowledge-reset",
14777
15633
  "initialize"
14778
15634
  ]);
14779
15635
  var KeychainAuditEntrySchema = object({
14780
15636
  id: string(),
14781
15637
  at: number(),
14782
15638
  action: KeychainAuditActionSchema,
14783
- /** `addon:<id>` | `user:<id>` | `system`. */
15639
+ /** `addon:<id>` | `user:<id>` | `system` | `trigger-file`. */
14784
15640
  actor: string(),
14785
15641
  ref: string().nullable(),
14786
15642
  detail: string().nullable()
@@ -14846,6 +15702,13 @@ method(object({}), KeychainStatusSchema, { auth: "admin" }), method(object({}),
14846
15702
  kind: "mutation",
14847
15703
  auth: "admin",
14848
15704
  caller: "required"
15705
+ }), method(object({}), object({
15706
+ reset: KeychainResetRecordSchema.nullable(),
15707
+ pendingReentry: array(KeychainSecretMetaSchema).readonly()
15708
+ }), { auth: "admin" }), method(object({}), object({ acknowledged: boolean() }), {
15709
+ kind: "mutation",
15710
+ auth: "admin",
15711
+ caller: "required"
14849
15712
  });
14850
15713
  method(_void(), object({
14851
15714
  id: string(),
@@ -17400,14 +18263,14 @@ var LlmProfileSchema = object({
17400
18263
  /** ConfigUISchema tree passed through untyped on the wire (the
17401
18264
  * notification-output `ConfigSchemaPassthrough` precedent at
17402
18265
  * notification-output.cap.ts:151); the exported TS type re-tightens it. */
17403
- var ConfigSchemaPassthrough$1 = unknown();
18266
+ var ConfigSchemaPassthrough$3 = unknown();
17404
18267
  var LlmProfileKindDescriptorSchema = object({
17405
18268
  kind: LlmProfileKindSchema,
17406
18269
  label: string(),
17407
18270
  icon: string(),
17408
18271
  /** Stamped by each provider so the concat-fanned catalog stays routable. */
17409
18272
  addonId: string(),
17410
- configSchema: ConfigSchemaPassthrough$1
18273
+ configSchema: ConfigSchemaPassthrough$3
17411
18274
  });
17412
18275
  var LlmDefaultSelectorSchema = union([object({ consumer: string() }), object({ purpose: _enum(["text", "vision"]) })]);
17413
18276
  var LlmDefaultSchema = object({
@@ -17685,7 +18548,7 @@ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
17685
18548
  * `login-method` — collection cap through which auth addons contribute
17686
18549
  * their pre-auth login surfaces to the login page. This is the SINGLE,
17687
18550
  * generic mechanism that supersedes the dead `auth.listProviders` reader:
17688
- * every auth addon (OIDC, magic-link, WebAuthn/passkey) registers a
18551
+ * every auth addon (OIDC, WebAuthn/passkey) registers a
17689
18552
  * `login-method` provider and the PUBLIC `auth.listLoginMethods`
17690
18553
  * procedure aggregates them for the unauthenticated login page.
17691
18554
  *
@@ -17693,8 +18556,7 @@ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
17693
18556
  *
17694
18557
  * - `redirect` — a declarative button. The login page renders a generic
17695
18558
  * button that navigates to `startUrl` (an addon-owned HTTP route).
17696
- * Covers OIDC (`/addon/auth-oidc/<id>/start`) and magic-link with
17697
- * ZERO shell-side JS. A future SSO addon plugs in the same way — the
18559
+ * Covers OIDC (`/addon/auth-oidc/<id>/start`) with ZERO shell-side JS. A future SSO addon plugs in the same way — the
17698
18560
  * login page needs NO change.
17699
18561
  *
17700
18562
  * - `widget` — a Module-Federation widget the login page mounts (via
@@ -17713,8 +18575,8 @@ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
17713
18575
  * decision.
17714
18576
  *
17715
18577
  * Every contribution carries a `stage`:
17716
- * - `primary` — shown on the first credentials screen (OIDC /
17717
- * magic-link buttons; a future usernameless passkey).
18578
+ * - `primary` — shown on the first credentials screen (OIDC
18579
+ * buttons; a usernameless passkey).
17718
18580
  * - `second-factor` — shown AFTER the password leg, gated on the
17719
18581
  * returned `factors` (passkey-as-2FA today).
17720
18582
  *
@@ -17741,7 +18603,7 @@ var LoginMethodContributionSchema = discriminatedUnion("kind", [
17741
18603
  * The provider names an external identity a signed-in user can link to
17742
18604
  * their own account (D782): `auth.listLinkableProviders` /
17743
18605
  * `beginExternalLink` offer exactly the redirect methods that set this,
17744
- * whatever their id. Absent / false — a login button only (magic-link).
18606
+ * whatever their id. Absent / false — a login button only.
17745
18607
  */
17746
18608
  linkable: boolean().optional()
17747
18609
  }),
@@ -18529,7 +19391,7 @@ var TargetKindCapsSchema = object({
18529
19391
  * the union is large and not meant for runtime validation here; the exported
18530
19392
  * `TargetKind` type re-tightens `configSchema` to `ConfigUISchema`.
18531
19393
  */
18532
- var ConfigSchemaPassthrough = unknown();
19394
+ var ConfigSchemaPassthrough$2 = unknown();
18533
19395
  var TargetKindSchema = object({
18534
19396
  kind: string(),
18535
19397
  label: string(),
@@ -18566,7 +19428,7 @@ var TargetKindSchema = object({
18566
19428
  * its raster path, which is the safe default for an unknown image.
18567
19429
  */
18568
19430
  iconMediaType: string().optional(),
18569
- configSchema: ConfigSchemaPassthrough,
19431
+ configSchema: ConfigSchemaPassthrough$2,
18570
19432
  /**
18571
19433
  * The config keys that decide WHERE this kind's secrets are sent (server,
18572
19434
  * base URL, instance, chat, recipient). A save that changes any of them
@@ -21558,8 +22420,7 @@ method(object({}), object({ rules: array(NcRuleSchema) }), { auth: "admin" }), m
21558
22420
  * `super_admin` — collapsed onto the single boolean because every
21559
22421
  * non-admin caller is governed by the same scope-check rules; the
21560
22422
  * distinction was only ever used to route role-specific procedures
21561
- * which we no longer have. Agents are admin sessions issued via
21562
- * `createServiceToken`; CLI / webhook integrations are `cst_*` tokens
22423
+ * which we no longer have. CLI / webhook integrations are `cst_*` tokens
21563
22424
  * with `isAdmin: false` + an explicit scope list.
21564
22425
  */
21565
22426
  /** Per-method access flavour. Materialised on every cap method via codegen. */
@@ -21866,6 +22727,61 @@ var OauthIntegrationDescriptorSchema = object({
21866
22727
  });
21867
22728
  method(_void(), OauthIntegrationDescriptorSchema, { auth: "admin" });
21868
22729
  /**
22730
+ * `oidc-connections` — CRUD for IdP rows under `auth-oidc` (D828 sibling).
22731
+ *
22732
+ * One hub-only singleton (`auth-oidc`). The Settings UI is a DataTable +
22733
+ * ItemFormDialog; there is no `editable-array` in `globalSettingsSchema`.
22734
+ * Operator-chosen `id` is the URL slug (`/addon/auth-oidc/<id>/…`) and is
22735
+ * immutable after create.
22736
+ */
22737
+ var ConfigSchemaPassthrough$1 = unknown();
22738
+ var OidcConnectionSchema = object({
22739
+ id: string().min(1),
22740
+ displayName: string(),
22741
+ icon: string(),
22742
+ issuerUrl: string(),
22743
+ clientId: string(),
22744
+ /** Client id + secret present — never the secret value. */
22745
+ configured: boolean(),
22746
+ /**
22747
+ * Values for the connection form schema. `clientSecret` is a keychain
22748
+ * {@link SecretFieldView} or `null` / `''`, never plaintext (D789).
22749
+ */
22750
+ formValues: record(string(), unknown()).optional()
22751
+ });
22752
+ /**
22753
+ * Patch one connection. Omitted or empty `clientSecret` keeps the stored
22754
+ * secret (D787). `{ $secretClear: true }` clears it. `id` is never renamed.
22755
+ */
22756
+ var OidcConnectionUpdateInputSchema = object({
22757
+ id: string().min(1),
22758
+ displayName: string().min(1),
22759
+ icon: string().optional(),
22760
+ issuerUrl: string().optional(),
22761
+ clientId: string().optional(),
22762
+ clientSecret: union([string(), object({ $secretClear: literal(true) })]).optional(),
22763
+ redirectUri: string().optional(),
22764
+ scopes: string().optional(),
22765
+ usernameClaim: _enum([
22766
+ "preferred_username",
22767
+ "email",
22768
+ "sub"
22769
+ ]).optional()
22770
+ });
22771
+ method(object({}), ConfigSchemaPassthrough$1, { auth: "admin" }), method(object({}), array(OidcConnectionSchema).readonly(), { auth: "admin" }), method(object({
22772
+ id: string().min(1).regex(/^[a-z0-9][a-z0-9-]{0,63}$/, "id must be a lowercase slug"),
22773
+ displayName: string().min(1)
22774
+ }), object({ id: string() }), {
22775
+ kind: "mutation",
22776
+ auth: "admin"
22777
+ }), method(OidcConnectionUpdateInputSchema, object({ ok: literal(true) }), {
22778
+ kind: "mutation",
22779
+ auth: "admin"
22780
+ }), method(object({ id: string().min(1) }), object({ ok: literal(true) }), {
22781
+ kind: "mutation",
22782
+ auth: "admin"
22783
+ });
22784
+ /**
21869
22785
  * What started a camera's onboard motion (D672). `camera` is the camera's own
21870
22786
  * firmware; `sensor` is a device the operator ATTACHED to it. Absent on the
21871
22787
  * wire means the camera: only the camera-sensors bridge ever says `sensor`.
@@ -23222,24 +24138,69 @@ var RetrainFrameListSchema = object({
23222
24138
  /** What the page pre-selects — the native key frame when one survives. */
23223
24139
  autoPickMediaId: number().int().optional()
23224
24140
  });
24141
+ /** Exclusive partition of a corpus copy's annotation progress (design §4.2). */
24142
+ var RetrainFrameWorkStateSchema = _enum([
24143
+ "unannotated",
24144
+ "annotated",
24145
+ "complete"
24146
+ ]);
24147
+ /**
24148
+ * Filters for paginated corpus list, KPI, and matching export (design §4.4).
24149
+ * Every narrowing field is ANDed; omitted fields impose no constraint.
24150
+ */
24151
+ var RetrainCorpusFilterSchema = object({
24152
+ workState: RetrainFrameWorkStateSchema.optional(),
24153
+ deviceIds: array(number()).max(500).optional(),
24154
+ /** When set, only frames in this named collection. */
24155
+ collectionId: string().optional(),
24156
+ /** Frames that carry at least one saved annotation in one of these classes. */
24157
+ classes: array(RetrainMacroClassSchema).optional(),
24158
+ page: number().int().positive().default(1),
24159
+ pageSize: number().int().positive().max(100).default(50)
24160
+ });
24161
+ var RetrainCorpusPageSchema = object({
24162
+ frames: array(RetrainFrameSchema.extend({ workState: RetrainFrameWorkStateSchema })).readonly(),
24163
+ total: number().int().nonnegative(),
24164
+ page: number().int().positive(),
24165
+ pageSize: number().int().positive()
24166
+ });
24167
+ var RetrainCorpusKpiCameraRowSchema = object({
24168
+ deviceId: number(),
24169
+ unannotated: number().int().nonnegative(),
24170
+ annotated: number().int().nonnegative(),
24171
+ complete: number().int().nonnegative(),
24172
+ /** This camera's `complete` count divided by corpus `total`, in `[0,1]`.
24173
+ * `null` when the corpus is empty (no ratio). */
24174
+ pctOfCorpus: number().min(0).max(1).nullable()
24175
+ });
24176
+ var RetrainCorpusKpiSchema = object({
24177
+ total: number().int().nonnegative(),
24178
+ unannotated: number().int().nonnegative(),
24179
+ annotated: number().int().nonnegative(),
24180
+ complete: number().int().nonnegative(),
24181
+ cameras: array(RetrainCorpusKpiCameraRowSchema).readonly()
24182
+ });
23225
24183
  /**
23226
24184
  * Which frames an annotated export carries. Every field narrows; an empty
23227
- * filter is every annotated copy. A dataset VERSION is a frozen `frameIds`
23228
- * list owned by whoever trains (the training orchestrator), so `frameIds` is
23229
- * the primitive a version export uses; `batchId` re-selects what an earlier
23230
- * export carried (`exportedInBatch`).
24185
+ * filter is every annotated copy. `frameIds` is the primitive a job or
24186
+ * download uses; `batchId` re-selects what an earlier export carried
24187
+ * (`exportedInBatch`). Frozen dataset versions were removed — live selection
24188
+ * resolves to `frameIds` at plan/start.
23231
24189
  */
23232
24190
  var RetrainExportFilterSchema = object({
23233
24191
  deviceIds: array(number()).optional(),
23234
24192
  frameIds: array(string()).max(2e4).optional(),
23235
24193
  /** Only frames in at least one of these named collections. */
23236
24194
  collectionIds: array(string()).max(200).optional(),
23237
- /** Exactly the frames of this dataset version (and its completeOnly). An
23238
- * unknown id selects nothing. */
23239
- datasetVersionId: string().optional(),
24195
+ /** Single collection (Frames filter bar). ANDed with `collectionIds` when both set. */
24196
+ collectionId: string().optional(),
23240
24197
  batchId: string().optional(),
23241
24198
  /** Only frames the operator marked complete (all subjects boxed). */
23242
- completeOnly: boolean().optional()
24199
+ completeOnly: boolean().optional(),
24200
+ /** Exclusive work-state partition (`workStateOf`); same as the corpus list. */
24201
+ workState: RetrainFrameWorkStateSchema.optional(),
24202
+ /** Frames with at least one saved annotation in one of these classes. */
24203
+ classes: array(RetrainMacroClassSchema).optional()
23243
24204
  });
23244
24205
  /**
23245
24206
  * `frames`: the full frame copies, boxes in `annotations.json`.
@@ -23439,8 +24400,7 @@ var RetrainDatasetStatsSchema = object({
23439
24400
  completeFrames: number().int()
23440
24401
  })).readonly()
23441
24402
  });
23442
- /** An immutable dataset version, without its frame list. */
23443
- var RetrainDatasetVersionSchema = object({
24403
+ object({
23444
24404
  id: string(),
23445
24405
  name: string(),
23446
24406
  createdAt: number(),
@@ -23448,22 +24408,33 @@ var RetrainDatasetVersionSchema = object({
23448
24408
  layout: RetrainExportLayoutSchema,
23449
24409
  completeOnly: boolean(),
23450
24410
  frameCount: number().int(),
23451
- /** sha256 of what the frames taught when the version was frozen. */
23452
24411
  annotationHash: string(),
23453
- /** The export manifest schema the version was cut under. */
23454
24412
  manifestSchema: string(),
23455
24413
  stats: RetrainDatasetStatsSchema
23456
24414
  });
23457
- var CreateRetrainDatasetVersionResultSchema = discriminatedUnion("kind", [object({
23458
- kind: literal("created"),
23459
- version: RetrainDatasetVersionSchema
24415
+ /**
24416
+ * Live training corpus criteria — same shape as `TrainingCorpusSelection` on
24417
+ * the training cap. Resolved here so plan/start and the annotated export share
24418
+ * one definition of "the frames" (`buildRetrainExportPlan`).
24419
+ */
24420
+ var RetrainTrainingCorpusSelectionSchema = object({
24421
+ collectionIds: array(string()).min(1),
24422
+ workState: _enum([
24423
+ "complete",
24424
+ "annotated_or_complete",
24425
+ "any_annotated"
24426
+ ]).default("complete")
24427
+ });
24428
+ var RetrainTrainingCorpusResolveResultSchema = discriminatedUnion("kind", [object({
24429
+ kind: literal("resolved"),
24430
+ frameIds: array(string()).max(2e4).readonly(),
24431
+ stats: RetrainDatasetStatsSchema,
24432
+ annotationHash: string(),
24433
+ layout: RetrainExportLayoutSchema
23460
24434
  }), object({
23461
24435
  kind: literal("refused"),
23462
- reason: _enum([
23463
- "empty-name",
23464
- "duplicate-name",
23465
- "no-frames"
23466
- ])
24436
+ reason: _enum(["unknown-collection", "no-frames"]),
24437
+ detail: string()
23467
24438
  })]);
23468
24439
  /** The outcome of a lifecycle move owned by the retrain page. */
23469
24440
  var RetrainTransitionResultSchema = object({
@@ -24170,6 +25141,12 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
24170
25141
  }), array(RetrainTrackSchema).readonly(), {
24171
25142
  kind: "query",
24172
25143
  auth: "admin"
25144
+ }), method(RetrainCorpusFilterSchema, RetrainCorpusPageSchema, {
25145
+ kind: "query",
25146
+ auth: "admin"
25147
+ }), method(object({}), RetrainCorpusKpiSchema, {
25148
+ kind: "query",
25149
+ auth: "admin"
24173
25150
  }), method(object({ trackId: string() }), RetrainFrameListSchema, {
24174
25151
  kind: "query",
24175
25152
  auth: "admin"
@@ -24255,33 +25232,14 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
24255
25232
  auth: "admin",
24256
25233
  timeoutMs: 60 * 6e4
24257
25234
  }), method(object({
24258
- selection: RetrainDatasetSelectionSchema,
24259
- completeOnly: boolean().optional()
24260
- }), RetrainDatasetStatsSchema, {
24261
- kind: "query",
24262
- auth: "admin"
24263
- }), method(object({
24264
- name: string().max(120),
24265
- selection: RetrainDatasetSelectionSchema,
24266
- layout: RetrainExportLayoutSchema,
24267
- completeOnly: boolean()
24268
- }), CreateRetrainDatasetVersionResultSchema, {
24269
- kind: "mutation",
24270
- auth: "admin",
24271
- timeoutMs: 12e4
24272
- }), method(object({}), array(RetrainDatasetVersionSchema).readonly(), {
24273
- kind: "query",
24274
- auth: "admin"
24275
- }), method(object({ id: string() }), object({ deleted: boolean() }), {
24276
- kind: "mutation",
24277
- auth: "admin"
24278
- }), method(object({ id: string() }), object({
24279
- found: boolean(),
24280
- annotationHash: string(),
24281
- matches: boolean(),
24282
- missingFrames: number().int()
25235
+ filter: RetrainExportFilterSchema,
25236
+ layout: RetrainExportLayoutSchema
25237
+ }), object({
25238
+ ticket: PeerBytesTicketSchema,
25239
+ frames: number().int(),
25240
+ annotations: number().int()
24283
25241
  }), {
24284
- kind: "query",
25242
+ kind: "mutation",
24285
25243
  auth: "admin",
24286
25244
  timeoutMs: 12e4
24287
25245
  }), method(object({}), array(RetrainAssistProfileSchema).readonly(), {
@@ -24310,6 +25268,10 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
24310
25268
  }), method(object({}), array(RetrainCollectionSchema).readonly(), {
24311
25269
  kind: "query",
24312
25270
  auth: "admin"
25271
+ }), method(RetrainTrainingCorpusSelectionSchema, RetrainTrainingCorpusResolveResultSchema, {
25272
+ kind: "query",
25273
+ auth: "admin",
25274
+ timeoutMs: 6e4
24313
25275
  }), method(object({
24314
25276
  id: string(),
24315
25277
  name: string().max(120)
@@ -24926,11 +25888,14 @@ var HardwareClassIdSchema = _enum([
24926
25888
  "intel-n-series",
24927
25889
  "apple-m-base",
24928
25890
  "apple-m-pro",
25891
+ "amd-phoenix",
24929
25892
  "unknown"
24930
25893
  ]);
24931
25894
  var AcceleratorKindSchema = _enum([
24932
25895
  "intel-npu",
24933
25896
  "intel-igpu",
25897
+ "amd-igpu",
25898
+ "amd-npu",
24934
25899
  "x86-cpu",
24935
25900
  "arm-cpu",
24936
25901
  "apple-ane",
@@ -26820,6 +27785,8 @@ var AgentPipelineSettingsSchema = object({
26820
27785
  * address is wrong (multi-homed host, NAT, custom interface).
26821
27786
  */
26822
27787
  reachableHost: string().optional(),
27788
+ /** Hub-persisted UI colour (`--color-node-*` theme tokens). */
27789
+ color: NodeColorIdSchema.optional(),
26823
27790
  /**
26824
27791
  * Multi-device inference opt-in (Phase 4). Per-node map deviceKey → {enabled,
26825
27792
  * weight, steps}. Absent / all-disabled ⇒ the node's single default
@@ -27369,8 +28336,9 @@ method(object({
27369
28336
  auth: "admin"
27370
28337
  }), method(object({
27371
28338
  agentNodeId: string(),
27372
- reachableHost: string().nullable()
27373
- }), object({ success: literal(true) }), {
28339
+ reachableHost: string().nullable().optional(),
28340
+ color: NodeColorIdSchema.nullable().optional()
28341
+ }).refine((v) => v.reachableHost !== void 0 || v.color !== void 0, { message: "reachableHost or color required" }), object({ success: literal(true) }), {
27374
28342
  kind: "mutation",
27375
28343
  auth: "admin"
27376
28344
  }), method(object({
@@ -27822,8 +28790,8 @@ version: string().optional() }), ServerUpdateActionResultSchema, {
27822
28790
  * `smtp-provider` — pluggable email delivery surface.
27823
28791
  *
27824
28792
  * Collection cap: a deployment may install multiple SMTP relays (e.g.
27825
- * one for transactional / one for notifications). Consumers (magic-link,
27826
- * notifier addons, …) walk the collection and pick the first
28793
+ * one for transactional / one for notifications). Consumers (notifier
28794
+ * addons, …) walk the collection and pick the first
27827
28795
  * ready provider OR target a specific addonId.
27828
28796
  *
27829
28797
  * The shape stays small on purpose — `sendEmail` is enough for the
@@ -28106,7 +29074,7 @@ targets: array(object({
28106
29074
  };
28107
29075
  /**
28108
29076
  * `sso-bridge` — internal hub-only cap that lets SSO-style auth
28109
- * providers (OIDC, SAML, magic-link, …) mint an HMAC-signed token
29077
+ * providers (OIDC, SAML, …) mint an HMAC-signed token
28110
29078
  * carrying the post-callback claims before redirecting back to
28111
29079
  * `/api/auth/sso/finish`.
28112
29080
  *
@@ -28169,7 +29137,14 @@ var SsoBridgeClaimsSchema = object({
28169
29137
  * Verified `iss` of the id_token behind an OIDC login bridge (D782). A
28170
29138
  * subject is unique only per issuer, so a link is bound to it.
28171
29139
  */
28172
- issuer: string().optional()
29140
+ issuer: string().optional(),
29141
+ /**
29142
+ * SHA-256 (hex) of the `camstack_sso_state` cookie the IdP `/start` set in
29143
+ * the browser that began this sign-in. `/api/auth/sso/finish` requires the
29144
+ * request to present the matching cookie — a login bridge is useless in
29145
+ * any other browser.
29146
+ */
29147
+ browserBinding: string().optional()
28173
29148
  });
28174
29149
  method(object({
28175
29150
  claims: SsoBridgeClaimsSchema,
@@ -30514,7 +31489,7 @@ var CustomActionInputSchema = object({
30514
31489
  action: string().min(1),
30515
31490
  input: unknown()
30516
31491
  });
30517
- method(_void(), array(AddonListItemSchema).readonly()), method(object({
31492
+ method(object({ nodeId: string().optional() }).optional(), array(AddonListItemSchema).readonly()), method(object({
30518
31493
  addonId: string(),
30519
31494
  limit: number().min(1).max(500).default(100),
30520
31495
  level: LogLevelSchema$2.optional()
@@ -34061,7 +35036,13 @@ var TopologyNodeSchema = object({
34061
35036
  })).readonly(),
34062
35037
  processes: array(TopologyProcessSchema).readonly(),
34063
35038
  categories: array(TopologyCategorySchema).readonly(),
34064
- rootPackage: TopologyRootPackageSchema.nullable()
35039
+ rootPackage: TopologyRootPackageSchema.nullable(),
35040
+ /**
35041
+ * How an online AGENT reaches the hub (mesh mTLS Release A): `tls` once it has
35042
+ * completed a mutual-TLS handshake, `clear` otherwise. Absent for the hub,
35043
+ * for offline rows and when the hub cannot tell.
35044
+ */
35045
+ meshTransport: _enum(["tls", "clear"]).optional()
34065
35046
  });
34066
35047
  var CapUsageEdgeSchema = object({
34067
35048
  callerAddonId: string(),
@@ -34401,6 +35382,7 @@ var OsdNamedTemplateSchema = object({
34401
35382
  });
34402
35383
  /** Where a slot's value comes from. */
34403
35384
  var OsdSourceSchema = discriminatedUnion("kind", [
35385
+ object({ kind: literal("none") }),
34404
35386
  object({
34405
35387
  kind: literal("static"),
34406
35388
  text: string().max(64)
@@ -34527,6 +35509,13 @@ method(object({ deviceId: number().int() }), object({
34527
35509
  }), object({ success: literal(true) }), {
34528
35510
  kind: "mutation",
34529
35511
  auth: "admin"
35512
+ }), method(object({
35513
+ deviceId: number().int(),
35514
+ slotId: string().min(1),
35515
+ enabled: boolean()
35516
+ }), object({ success: literal(true) }), {
35517
+ kind: "mutation",
35518
+ auth: "admin"
34530
35519
  }), method(object({
34531
35520
  sourceDeviceId: number().int(),
34532
35521
  targetDeviceId: number().int()
@@ -34907,7 +35896,15 @@ var GpuInfoSchema = object({
34907
35896
  name: string(),
34908
35897
  memoryMB: number().optional()
34909
35898
  });
34910
- var NpuInfoSchema = object({ type: _enum(["apple-ane", "intel-npu"]) });
35899
+ var NpuInfoSchema = object({
35900
+ type: _enum([
35901
+ "apple-ane",
35902
+ "intel-npu",
35903
+ "amd-xdna"
35904
+ ]),
35905
+ name: string().optional(),
35906
+ generation: _enum(["xdna1", "xdna2"]).optional()
35907
+ });
34911
35908
  var CoralInfoSchema = object({
34912
35909
  type: literal("coral-edgetpu"),
34913
35910
  bus: string().optional()
@@ -38181,16 +39178,6 @@ var ApiKeySummarySchema = object({
38181
39178
  createdAt: number(),
38182
39179
  lastUsedAt: number().optional()
38183
39180
  });
38184
- var CreateApiKeyInputSchema = object({
38185
- label: string(),
38186
- isAdmin: boolean().default(false),
38187
- allowedProviders: union([array(string()), literal("*")]).optional(),
38188
- allowedDevices: record(string(), union([array(string()), literal("*")])).optional()
38189
- });
38190
- var CreateApiKeyResultSchema = object({
38191
- token: string(),
38192
- record: ApiKeySummarySchema
38193
- });
38194
39181
  var ScopedTokenSummarySchema = object({
38195
39182
  id: string(),
38196
39183
  userId: string(),
@@ -38289,17 +39276,10 @@ method(_void(), array(UserSummarySchema), { auth: "admin" }), method(CreateUserI
38289
39276
  }), UserSummarySchema.extend({ passwordHash: string() }).nullable(), {
38290
39277
  kind: "mutation",
38291
39278
  access: "view"
38292
- }), method(_void(), array(ApiKeySummarySchema), { auth: "admin" }), method(CreateApiKeyInputSchema, CreateApiKeyResultSchema, {
38293
- kind: "mutation",
38294
- auth: "admin",
38295
- access: "create"
38296
- }), method(object({ id: string() }), object({ success: literal(true) }), {
39279
+ }), method(_void(), array(ApiKeySummarySchema), { auth: "admin" }), method(object({ id: string() }), object({ success: literal(true) }), {
38297
39280
  kind: "mutation",
38298
39281
  auth: "admin",
38299
39282
  access: "delete"
38300
- }), method(object({ token: string() }), ApiKeySummarySchema.nullable(), {
38301
- kind: "mutation",
38302
- access: "view"
38303
39283
  }), method(CreateScopedTokenInputSchema, CreateScopedTokenResultSchema, {
38304
39284
  kind: "mutation",
38305
39285
  auth: "admin",
@@ -38373,15 +39353,7 @@ method(_void(), array(UserSummarySchema), { auth: "admin" }), method(CreateUserI
38373
39353
  }).nullable(), { access: "view" }), method(object({ userId: string() }), array(ExternalIdentitySchema), { auth: "admin" }), method(ExternalIdentityKeySchema, object({
38374
39354
  userId: string(),
38375
39355
  issuer: string()
38376
- }).nullable(), { auth: "admin" }), method(ExternalIdentityKeySchema.extend({
38377
- userId: string(),
38378
- issuer: string().min(1),
38379
- label: string().optional()
38380
- }), object({ success: literal(true) }), {
38381
- kind: "mutation",
38382
- auth: "admin",
38383
- access: "create"
38384
- }), method(ExternalIdentityKeySchema.extend({ userId: string() }), object({ success: boolean() }), {
39356
+ }).nullable(), { auth: "admin" }), method(ExternalIdentityKeySchema.extend({ userId: string() }), object({ success: boolean() }), {
38385
39357
  kind: "mutation",
38386
39358
  auth: "admin",
38387
39359
  access: "delete"
@@ -38776,6 +39748,563 @@ DeviceType.Camera, method(object({
38776
39748
  detection: array(ZoneRuleSchema).readonly(),
38777
39749
  package: array(ZoneRuleSchema).readonly()
38778
39750
  });
39751
+ /**
39752
+ * `training-provider` — ONE cloud that can run the CamStack trainer.
39753
+ *
39754
+ * A thin, mockable translation layer: it knows how to run a container with a
39755
+ * GPU, move a dataset in, read the job's stdout and hand artefacts back. It
39756
+ * knows nothing about datasets, splits, floors, cost policy or Model Studio —
39757
+ * those are the `training` orchestrator's (D805). Every rule written there
39758
+ * once is what makes a second provider (RunPod, a local NVIDIA node) a new
39759
+ * manifest entry and nothing else.
39760
+ *
39761
+ * Collection of provider **types** (addons). Each addon owns zero or more
39762
+ * **entries** (credentials + defaults). Concat-fans: `describe`,
39763
+ * `describeTypes`, `listEntries`, `listJobs`. Single-row work is keyed by
39764
+ * `entryId`; callers also pass the owning `addonId` as the collection
39765
+ * selector (broker posture). Every method is `admin`: these spend money.
39766
+ *
39767
+ * Every cloud object a provider creates is tagged with the orchestrator's
39768
+ * `jobKey`, so a retried submit finds the job it already started instead of
39769
+ * starting a second GPU, and `listJobs` can find orphans.
39770
+ *
39771
+ * Bytes never ride a cap field: the dataset arrives as a `ctx.peerBytes`
39772
+ * ticket the producer (pipeline-analytics) minted, and artefacts leave as a
39773
+ * ticket the provider mints (D613).
39774
+ */
39775
+ var TrainingGpuOptionSchema = object({
39776
+ id: string(),
39777
+ label: string(),
39778
+ /** List price, USD per GPU-hour, before any region multiplier. */
39779
+ usdPerHour: number().nonnegative(),
39780
+ vramGb: number().nonnegative()
39781
+ });
39782
+ var TrainingRegionOptionSchema = object({
39783
+ /** `''` = any region (the provider's choice). */
39784
+ id: string(),
39785
+ label: string(),
39786
+ priceMultiplier: number().positive()
39787
+ });
39788
+ /**
39789
+ * The provider's per-entry settings, as the orchestrator reads them. They
39790
+ * live on the PROVIDER addon's entry (operator decision 2026-10-08: they
39791
+ * depend on the user's account), never hard-coded in the orchestrator.
39792
+ */
39793
+ var TrainingProviderDefaultsSchema = object({
39794
+ gpuType: string(),
39795
+ region: string(),
39796
+ costCapUsd: number().nonnegative(),
39797
+ maxRuntimeSec: number().int().positive(),
39798
+ /** Hours a FAILED job's cloud dataset is kept for debugging; 0 = delete at once. */
39799
+ failedDatasetGraceHours: number().nonnegative()
39800
+ });
39801
+ /**
39802
+ * Entry form schema for a provider type — same seam as notification
39803
+ * `TargetKind.configSchema` (`z.unknown()` at the wire; callers tighten to
39804
+ * {@link ConfigUISchema}). Drives `ConfigFormBuilder` on Training → Providers.
39805
+ */
39806
+ var ConfigSchemaPassthrough = unknown();
39807
+ /** One creatable provider type, for the Add-entry dialog. */
39808
+ var TrainingProviderTypeSchema = object({
39809
+ typeId: string(),
39810
+ label: string(),
39811
+ /** Path under the addon package (e.g. `assets/training-modal/icon.svg`). */
39812
+ iconAsset: string(),
39813
+ /** Owning `training-provider` addon — collection selector for createEntry. */
39814
+ addonId: string(),
39815
+ /**
39816
+ * Fields for one entry of this type (credentials + defaults). Absent on a
39817
+ * type that only needs a name. Password fields are keychain-backed on the
39818
+ * provider addon (`secretStatePaths`), not D634 plaintext.
39819
+ */
39820
+ configSchema: ConfigSchemaPassthrough.optional()
39821
+ });
39822
+ /** One configured account / workspace under a provider type. */
39823
+ var TrainingProviderEntrySchema = object({
39824
+ entryId: string(),
39825
+ typeId: string(),
39826
+ name: string(),
39827
+ addonId: string(),
39828
+ /** Credentials are present — never the values. */
39829
+ configured: boolean()
39830
+ });
39831
+ var TrainingProviderDescriptorSchema = object({
39832
+ addonId: string(),
39833
+ entryId: string(),
39834
+ typeId: string(),
39835
+ /** Operator-chosen entry name. */
39836
+ name: string(),
39837
+ iconAsset: string(),
39838
+ /** `modal`, `runpod`, `fake`, … — same as typeId for current providers. */
39839
+ kind: string(),
39840
+ label: string(),
39841
+ gpuTypes: array(TrainingGpuOptionSchema).readonly(),
39842
+ regions: array(TrainingRegionOptionSchema).readonly(),
39843
+ maxDatasetBytes: number().int().positive(),
39844
+ maxRuntimeSec: number().int().positive(),
39845
+ freeTierNote: string().optional(),
39846
+ /** Where the data goes, in one sentence the confirm dialog repeats. */
39847
+ dataResidencyNote: string(),
39848
+ /** Credentials are present — never the values. */
39849
+ configured: boolean(),
39850
+ defaults: TrainingProviderDefaultsSchema,
39851
+ /**
39852
+ * Values for {@link TrainingProviderTypeSchema}'s `configSchema` — password
39853
+ * fields are keychain {@link SecretFieldView} or `null` / `''` (create),
39854
+ * never plaintext. Same hydrate contract as settings forms (D789).
39855
+ */
39856
+ formValues: record(string(), unknown()).optional()
39857
+ });
39858
+ /**
39859
+ * Patch one entry's name, credentials and defaults. Pin with owning `{ addonId }`.
39860
+ * An omitted or empty `tokenSecret` means KEEP the stored secret (D787).
39861
+ * `{ $secretClear: true }` clears it.
39862
+ */
39863
+ var TrainingProviderUpdateEntryInputSchema = object({
39864
+ entryId: string().min(1),
39865
+ name: string().min(1),
39866
+ tokenId: string().optional(),
39867
+ tokenSecret: union([string(), object({ $secretClear: literal(true) })]).optional(),
39868
+ environment: string().optional(),
39869
+ gpuType: string().optional(),
39870
+ region: string().optional(),
39871
+ costCapUsd: number().nonnegative().optional(),
39872
+ maxRuntimeSec: number().int().positive().optional(),
39873
+ failedDatasetGraceHours: number().nonnegative().optional()
39874
+ });
39875
+ var TrainingCredentialCheckSchema = object({
39876
+ ok: boolean(),
39877
+ /** Workspace / account name, when the provider says. */
39878
+ account: string().optional(),
39879
+ reason: _enum([
39880
+ "missing",
39881
+ "invalid",
39882
+ "forbidden",
39883
+ "network",
39884
+ "quota"
39885
+ ]).optional(),
39886
+ detail: string().optional()
39887
+ });
39888
+ var ProviderJobStateSchema = _enum([
39889
+ "pending",
39890
+ "starting",
39891
+ "running",
39892
+ "succeeded",
39893
+ "failed",
39894
+ "cancelled",
39895
+ "lost"
39896
+ ]);
39897
+ var ProviderJobStatusSchema = object({
39898
+ jobKey: string(),
39899
+ providerJobId: string().optional(),
39900
+ state: ProviderJobStateSchema,
39901
+ startedAt: number().optional(),
39902
+ endedAt: number().optional(),
39903
+ exitCode: number().int().optional(),
39904
+ failureReason: string().optional(),
39905
+ gpuType: string(),
39906
+ region: string().optional(),
39907
+ billedSeconds: number().nonnegative(),
39908
+ costUsd: number().nonnegative(),
39909
+ /** True when `costUsd` is runtime × list price, not a billing answer. */
39910
+ costIsEstimate: boolean(),
39911
+ lastFetchedAt: number()
39912
+ });
39913
+ /**
39914
+ * The trainer the job runs, by SOURCE revision: the provider turns it into an
39915
+ * image its own way (Modal builds the published Dockerfile at that revision;
39916
+ * a registry-pull provider maps it to a tag). Recorded on the job and echoed
39917
+ * in `result.json`.
39918
+ */
39919
+ var TrainerSourceRefSchema = object({
39920
+ /** Hugging Face repo id, e.g. `camstack/camstack-trainer`. */
39921
+ repo: string().min(1),
39922
+ /** A commit sha (never a branch) — the job must be reproducible. */
39923
+ revision: string().regex(/^[0-9a-f]{7,64}$/)
39924
+ });
39925
+ /** Cloud job identity — route with the owning addon's `addonId` selector. */
39926
+ var JobRef = {
39927
+ entryId: string().min(1),
39928
+ jobKey: string().uuid()
39929
+ };
39930
+ var TrainingLogLineSchema = object({
39931
+ ts: number(),
39932
+ text: string()
39933
+ });
39934
+ method(object({}), array(TrainingProviderDescriptorSchema).readonly(), { auth: "admin" }), method(object({}), array(TrainingProviderTypeSchema).readonly(), { auth: "admin" }), method(object({}), array(TrainingProviderEntrySchema).readonly(), { auth: "admin" }), method(object({
39935
+ typeId: string().min(1),
39936
+ name: string().min(1)
39937
+ }), object({ entryId: string() }), {
39938
+ kind: "mutation",
39939
+ auth: "admin"
39940
+ }), method(object({ entryId: string().min(1) }), object({ ok: literal(true) }), {
39941
+ kind: "mutation",
39942
+ auth: "admin"
39943
+ }), method(TrainingProviderUpdateEntryInputSchema, object({ ok: literal(true) }), {
39944
+ kind: "mutation",
39945
+ auth: "admin"
39946
+ }), method(object({ entryId: string().min(1) }), TrainingCredentialCheckSchema, {
39947
+ kind: "mutation",
39948
+ auth: "admin",
39949
+ timeoutMs: 3e4
39950
+ }), method(object({
39951
+ entryId: string().min(1),
39952
+ gpuType: string(),
39953
+ region: string(),
39954
+ datasetBytes: number().int().nonnegative(),
39955
+ gpuSecondsLow: number().nonnegative(),
39956
+ gpuSecondsHigh: number().nonnegative()
39957
+ }), object({
39958
+ usdLow: number().nonnegative(),
39959
+ usdHigh: number().nonnegative(),
39960
+ notes: array(string()).readonly()
39961
+ }), { auth: "admin" }), method(object({
39962
+ ...JobRef,
39963
+ ticket: PeerBytesTicketSchema
39964
+ }), object({
39965
+ bytes: number().int().nonnegative(),
39966
+ sha256: string()
39967
+ }), {
39968
+ kind: "mutation",
39969
+ auth: "admin",
39970
+ timeoutMs: 120 * 6e4
39971
+ }), method(object({
39972
+ ...JobRef,
39973
+ trainer: TrainerSourceRefSchema,
39974
+ jobSpecJson: string().min(2).max(64e3),
39975
+ gpuType: string(),
39976
+ region: string(),
39977
+ maxRuntimeSec: number().int().positive()
39978
+ }), ProviderJobStatusSchema, {
39979
+ kind: "mutation",
39980
+ auth: "admin",
39981
+ timeoutMs: 30 * 6e4
39982
+ }), method(object(JobRef), ProviderJobStatusSchema, {
39983
+ auth: "admin",
39984
+ timeoutMs: 6e4
39985
+ }), method(object({
39986
+ ...JobRef,
39987
+ cursor: string().optional(),
39988
+ max: number().int().min(1).max(500)
39989
+ }), object({
39990
+ lines: array(TrainingLogLineSchema).readonly(),
39991
+ cursor: string()
39992
+ }), {
39993
+ auth: "admin",
39994
+ timeoutMs: 6e4
39995
+ }), method(object(JobRef), object({ ok: literal(true) }), {
39996
+ kind: "mutation",
39997
+ auth: "admin",
39998
+ timeoutMs: 6e4
39999
+ }), method(object(JobRef), object({
40000
+ found: boolean(),
40001
+ text: string().optional()
40002
+ }), {
40003
+ kind: "mutation",
40004
+ auth: "admin",
40005
+ timeoutMs: 5 * 6e4
40006
+ }), method(object({
40007
+ ...JobRef,
40008
+ path: _enum(["bundle.tar"])
40009
+ }), object({ ticket: PeerBytesTicketSchema }), {
40010
+ kind: "mutation",
40011
+ auth: "admin",
40012
+ timeoutMs: 5 * 6e4
40013
+ }), method(object(JobRef), object({ deleted: array(string()).readonly() }), {
40014
+ kind: "mutation",
40015
+ auth: "admin",
40016
+ timeoutMs: 5 * 6e4
40017
+ }), method(object({ entryId: string().min(1).optional() }), array(ProviderJobStatusSchema).readonly(), {
40018
+ auth: "admin",
40019
+ timeoutMs: 2 * 6e4
40020
+ });
40021
+ /**
40022
+ * `training` — the cloud-training orchestrator (D805). Hub-only singleton,
40023
+ * provided by `addon-training`.
40024
+ *
40025
+ * It owns what every provider must agree on, written once:
40026
+ *
40027
+ * - **Jobs.** A persisted state machine, a reconcile loop against the
40028
+ * provider, a cost guard, a daily orphan sweep and the retention rules.
40029
+ * - **The return flow.** Verified artefacts → Model Studio
40030
+ * (`custom-model-registry.importModelBundle`) → canary on cameras →
40031
+ * rollback. Nothing is ever registered automatically.
40032
+ *
40033
+ * Plan/start takes a live {@link TrainingCorpusSelection} (collections +
40034
+ * work-state rule); frame ids are resolved via pipeline-analytics at that
40035
+ * moment and snapshotted on the job. No frozen dataset version.
40036
+ *
40037
+ * Every method is `admin`.
40038
+ */
40039
+ /**
40040
+ * Live corpus criteria for plan/start (design §5.2). Default is complete-only.
40041
+ * Frame ids are resolved at plan/start — never a frozen version id.
40042
+ */
40043
+ var TrainingCorpusSelectionSchema = object({
40044
+ collectionIds: array(string()).min(1),
40045
+ /** Default complete-only for v1 */
40046
+ workState: _enum([
40047
+ "complete",
40048
+ "annotated_or_complete",
40049
+ "any_annotated"
40050
+ ]).default("complete")
40051
+ });
40052
+ /** A base model a detector job can fine-tune, and the baseline it is judged against. */
40053
+ var TrainingBaseModelSchema = object({
40054
+ modelId: string(),
40055
+ label: string(),
40056
+ weights: string(),
40057
+ imgsz: number().int(),
40058
+ baselineOnnxUrl: string(),
40059
+ baselineFloors: record(string(), number()),
40060
+ /** The base the fleet runs most — the UI's default. */
40061
+ recommended: boolean()
40062
+ });
40063
+ var TrainingPresetSchema = _enum([
40064
+ "quick",
40065
+ "standard",
40066
+ "thorough"
40067
+ ]);
40068
+ var TrainingJobRequestSchema = object({
40069
+ /** Live collection + work-state criteria; resolved at plan/start. */
40070
+ selection: TrainingCorpusSelectionSchema,
40071
+ /**
40072
+ * The provider **entry** that runs it (credentials + defaults).
40073
+ * Resolve to an owning addon via `training-provider.describe` / `listEntries`.
40074
+ */
40075
+ entryId: string().min(1),
40076
+ gpuType: string().min(1),
40077
+ region: string(),
40078
+ baseModelId: string().min(1),
40079
+ preset: TrainingPresetSchema,
40080
+ /** Freeze the backbone's first N layers; `null` = the preset's choice. */
40081
+ freeze: number().int().nonnegative().nullable(),
40082
+ /** Cameras held out whole for evaluation; `null` = the orchestrator's default. */
40083
+ holdoutCameras: array(number().int()).nullable()
40084
+ });
40085
+ var TrainingSplitPlanSchema = object({
40086
+ holdoutCameras: array(number().int()).readonly(),
40087
+ /** Used when no camera is held out: the last N days of every camera. */
40088
+ holdoutLastDays: number().int().nonnegative(),
40089
+ /** Holdout subjects per class (camera holdout only; `null` = known only after the split). */
40090
+ holdoutSupport: record(string(), number().int()).nullable(),
40091
+ trainSubjects: number().int()
40092
+ });
40093
+ var TrainingRefusalReasonSchema = _enum([
40094
+ "unknown-dataset",
40095
+ "unknown-provider",
40096
+ "provider-not-configured",
40097
+ "unknown-base-model",
40098
+ "unknown-gpu",
40099
+ "dataset-too-large",
40100
+ "no-training-subjects",
40101
+ "job-already-running"
40102
+ ]);
40103
+ var TrainingJobPlanSchema = object({
40104
+ refusal: object({
40105
+ reason: TrainingRefusalReasonSchema,
40106
+ detail: string()
40107
+ }).nullable(),
40108
+ warnings: array(string()).readonly(),
40109
+ split: TrainingSplitPlanSchema.nullable(),
40110
+ estimate: object({
40111
+ datasetBytes: number().int(),
40112
+ uploadMinutesAt20Mbps: number(),
40113
+ gpuSecondsLow: number(),
40114
+ gpuSecondsHigh: number(),
40115
+ usdLow: number(),
40116
+ usdHigh: number(),
40117
+ notes: array(string()).readonly()
40118
+ }).nullable(),
40119
+ /** Pre-filled from the provider's settings; the operator may lower or raise them. */
40120
+ defaults: object({
40121
+ maxCostUsd: number(),
40122
+ maxRuntimeSec: number().int()
40123
+ }).nullable(),
40124
+ /** The sentence the confirm dialog repeats: where the frames go and when they are deleted. */
40125
+ dataNotice: string()
40126
+ });
40127
+ /**
40128
+ * Orchestrator-owned states, persisted. `uploading` covers exporting the
40129
+ * archive (it is streamed, never staged). Terminal: `failed`, `cancelled`,
40130
+ * `lost`, `expired`, `discarded`. `registered` and `canary` are where a
40131
+ * result lives after the operator acted on it.
40132
+ */
40133
+ var TrainingJobStateSchema = _enum([
40134
+ "queued",
40135
+ "uploading",
40136
+ "submitted",
40137
+ "starting",
40138
+ "running",
40139
+ "collecting",
40140
+ "ready",
40141
+ "registered",
40142
+ "canary",
40143
+ "failed",
40144
+ "cancelling",
40145
+ "cancelled",
40146
+ "lost",
40147
+ "expired",
40148
+ "discarded"
40149
+ ]);
40150
+ var TrainingFailureReasonSchema = _enum([
40151
+ "cost-cap",
40152
+ "runtime-cap",
40153
+ "upload-failed",
40154
+ "submit-failed",
40155
+ "trainer-failed",
40156
+ "result-invalid",
40157
+ "checksum-mismatch",
40158
+ "fetch-failed",
40159
+ "provider-error",
40160
+ "hub-restart-during-upload"
40161
+ ]);
40162
+ var TrainingProgressPointSchema = object({
40163
+ epoch: number().int(),
40164
+ map50: number().nullable(),
40165
+ map50_95: number().nullable()
40166
+ });
40167
+ var TrainingCanarySchema = object({
40168
+ deviceIds: array(number().int()).readonly(),
40169
+ since: number(),
40170
+ /** Every override the canary replaced, exactly, so rollback restores it. */
40171
+ previous: array(object({
40172
+ deviceId: number().int(),
40173
+ nodeId: string(),
40174
+ deviceKey: string(),
40175
+ patch: object({
40176
+ modelId: string().optional(),
40177
+ settings: record(string(), unknown()).readonly().optional()
40178
+ }).nullable()
40179
+ })).readonly()
40180
+ });
40181
+ var TrainingJobSchema = object({
40182
+ id: string(),
40183
+ idempotencyKey: string(),
40184
+ name: string(),
40185
+ createdAt: number(),
40186
+ updatedAt: number(),
40187
+ state: TrainingJobStateSchema,
40188
+ /**
40189
+ * Shared by every job enqueued together via `startJobBatch`.
40190
+ * `null` for a lone `startJob`. The engine advances queued siblings by this id.
40191
+ */
40192
+ batchId: string().nullable().default(null),
40193
+ stage: TrainingStageSchema.nullable(),
40194
+ failure: object({
40195
+ reason: TrainingFailureReasonSchema,
40196
+ stage: string().nullable(),
40197
+ detail: string()
40198
+ }).nullable(),
40199
+ request: TrainingJobRequestSchema,
40200
+ maxCostUsd: number().nonnegative(),
40201
+ maxRuntimeSec: number().int().positive(),
40202
+ trainer: TrainerSourceRefSchema,
40203
+ datasetLayout: RetrainExportLayoutSchema,
40204
+ /** Frame count snapshotted when the job started (audit; equals `frameIds.length`). */
40205
+ frameCount: number().int().nonnegative(),
40206
+ /** Resolved frame ids at start — the archive ships exactly these. */
40207
+ frameIds: array(string()).max(2e4).readonly(),
40208
+ /** Hash of what those frames taught at start (trainer `dataset.annotationHash`). */
40209
+ annotationHash: string(),
40210
+ dataset: object({
40211
+ bytes: number().int(),
40212
+ sha256: string(),
40213
+ uploadedAt: number()
40214
+ }).nullable(),
40215
+ split: TrainingSplitPlanSchema,
40216
+ provider: object({
40217
+ state: ProviderJobStateSchema.nullable(),
40218
+ providerJobId: string().nullable(),
40219
+ startedAt: number().nullable(),
40220
+ endedAt: number().nullable(),
40221
+ billedSeconds: number(),
40222
+ costUsd: number(),
40223
+ costIsEstimate: boolean(),
40224
+ lastPolledAt: number().nullable()
40225
+ }),
40226
+ progress: object({
40227
+ epoch: number().int().nullable(),
40228
+ epochs: number().int().nullable(),
40229
+ etaSec: number().nullable(),
40230
+ series: array(TrainingProgressPointSchema).readonly()
40231
+ }),
40232
+ /** The last lines of the job's output (≤ 200), newest last. Never frame paths. */
40233
+ logTail: array(string()).readonly(),
40234
+ logCursor: string().nullable(),
40235
+ artifacts: object({
40236
+ bundleBytes: number().int(),
40237
+ bundleSha256: string(),
40238
+ fetchedAt: number(),
40239
+ /** When the staged artefacts are deleted from the hub. */
40240
+ expiresAt: number()
40241
+ }).nullable(),
40242
+ /** When the provider-side copy of the frames was deleted; null while it exists. */
40243
+ cloudDatasetDeletedAt: number().nullable(),
40244
+ /** A failed job's dataset is kept until then (the provider's grace), then deleted. */
40245
+ cloudCleanupDueAt: number().nullable(),
40246
+ /** Model ids registered from this job (base, and int8 when kept). */
40247
+ registeredModelIds: array(string()).readonly(),
40248
+ canary: TrainingCanarySchema.nullable()
40249
+ });
40250
+ var IdInput = object({ id: string().min(1) });
40251
+ method(object({}), array(TrainingBaseModelSchema).readonly(), { auth: "admin" }), method(TrainingJobRequestSchema, TrainingJobPlanSchema, {
40252
+ auth: "admin",
40253
+ timeoutMs: 6e4
40254
+ }), method(TrainingJobRequestSchema.extend({
40255
+ name: string().min(1).max(120),
40256
+ maxCostUsd: number().positive(),
40257
+ maxRuntimeSec: number().int().positive(),
40258
+ idempotencyKey: string().min(8).max(80)
40259
+ }), discriminatedUnion("kind", [object({
40260
+ kind: literal("started"),
40261
+ job: TrainingJobSchema
40262
+ }), object({
40263
+ kind: literal("refused"),
40264
+ reason: TrainingRefusalReasonSchema,
40265
+ detail: string()
40266
+ })]), {
40267
+ kind: "mutation",
40268
+ auth: "admin",
40269
+ timeoutMs: 12e4
40270
+ }), method(TrainingJobRequestSchema.omit({ baseModelId: true }).extend({
40271
+ baseModelIds: array(string().min(1)).min(1),
40272
+ name: string().min(1).max(120),
40273
+ maxCostUsd: number().positive(),
40274
+ maxRuntimeSec: number().int().positive(),
40275
+ idempotencyKey: string().min(8).max(80)
40276
+ }), discriminatedUnion("kind", [object({
40277
+ kind: literal("started"),
40278
+ batchId: string(),
40279
+ jobs: array(TrainingJobSchema).min(1).readonly()
40280
+ }), object({
40281
+ kind: literal("refused"),
40282
+ reason: TrainingRefusalReasonSchema,
40283
+ detail: string()
40284
+ })]), {
40285
+ kind: "mutation",
40286
+ auth: "admin",
40287
+ timeoutMs: 12e4
40288
+ }), method(object({}), array(TrainingJobSchema).readonly(), { auth: "admin" }), method(IdInput, TrainingJobSchema.nullable(), { auth: "admin" }), method(IdInput, TrainingJobSchema, {
40289
+ kind: "mutation",
40290
+ auth: "admin",
40291
+ timeoutMs: 12e4
40292
+ }), method(IdInput, TrainingResultSchema.nullable(), { auth: "admin" }), method(IdInput.extend({ canaryDeviceIds: array(number().int()).readonly() }), TrainingJobSchema, {
40293
+ kind: "mutation",
40294
+ auth: "admin",
40295
+ timeoutMs: 30 * 6e4
40296
+ }), method(IdInput.extend({ deviceIds: array(number().int()).min(1).readonly() }), TrainingJobSchema, {
40297
+ kind: "mutation",
40298
+ auth: "admin",
40299
+ timeoutMs: 12e4
40300
+ }), method(IdInput, TrainingJobSchema, {
40301
+ kind: "mutation",
40302
+ auth: "admin",
40303
+ timeoutMs: 12e4
40304
+ }), method(IdInput, TrainingJobSchema, {
40305
+ kind: "mutation",
40306
+ auth: "admin"
40307
+ });
38779
40308
  SOURCE_CAPS.filter((cap) => cap !== "switch" && cap !== "motion");
38780
40309
  Object.freeze({
38781
40310
  person: .5,
@@ -40218,6 +41747,12 @@ Object.freeze({
40218
41747
  addonId: null,
40219
41748
  access: "create"
40220
41749
  },
41750
+ "backup.checkBackupKey": {
41751
+ capName: "backup",
41752
+ capScope: "system",
41753
+ addonId: null,
41754
+ access: "create"
41755
+ },
40221
41756
  "backup.delete": {
40222
41757
  capName: "backup",
40223
41758
  capScope: "system",
@@ -40230,6 +41765,18 @@ Object.freeze({
40230
41765
  addonId: null,
40231
41766
  access: "delete"
40232
41767
  },
41768
+ "backup.disableEncryption": {
41769
+ capName: "backup",
41770
+ capScope: "system",
41771
+ addonId: null,
41772
+ access: "create"
41773
+ },
41774
+ "backup.getEncryption": {
41775
+ capName: "backup",
41776
+ capScope: "system",
41777
+ addonId: null,
41778
+ access: "view"
41779
+ },
40233
41780
  "backup.getEntries": {
40234
41781
  capName: "backup",
40235
41782
  capScope: "system",
@@ -40284,6 +41831,12 @@ Object.freeze({
40284
41831
  addonId: null,
40285
41832
  access: "create"
40286
41833
  },
41834
+ "backup.setupEncryption": {
41835
+ capName: "backup",
41836
+ capScope: "system",
41837
+ addonId: null,
41838
+ access: "create"
41839
+ },
40287
41840
  "backup.trigger": {
40288
41841
  capName: "backup",
40289
41842
  capScope: "system",
@@ -40836,6 +42389,12 @@ Object.freeze({
40836
42389
  addonId: null,
40837
42390
  access: "create"
40838
42391
  },
42392
+ "customModelRegistry.importModelBundle": {
42393
+ capName: "custom-model-registry",
42394
+ capScope: "system",
42395
+ addonId: null,
42396
+ access: "create"
42397
+ },
40839
42398
  "customModelRegistry.listModels": {
40840
42399
  capName: "custom-model-registry",
40841
42400
  capScope: "system",
@@ -42276,6 +43835,12 @@ Object.freeze({
42276
43835
  addonId: null,
42277
43836
  access: "view"
42278
43837
  },
43838
+ "keychainAdmin.acknowledgeReset": {
43839
+ capName: "keychain-admin",
43840
+ capScope: "system",
43841
+ addonId: null,
43842
+ access: "create"
43843
+ },
42279
43844
  "keychainAdmin.deleteOrphans": {
42280
43845
  capName: "keychain-admin",
42281
43846
  capScope: "system",
@@ -42312,6 +43877,12 @@ Object.freeze({
42312
43877
  addonId: null,
42313
43878
  access: "delete"
42314
43879
  },
43880
+ "keychainAdmin.resetReport": {
43881
+ capName: "keychain-admin",
43882
+ capScope: "system",
43883
+ addonId: null,
43884
+ access: "delete"
43885
+ },
42315
43886
  "keychainAdmin.reveal": {
42316
43887
  capName: "keychain-admin",
42317
43888
  capScope: "system",
@@ -43566,6 +45137,36 @@ Object.freeze({
43566
45137
  addonId: null,
43567
45138
  access: "view"
43568
45139
  },
45140
+ "oidcConnections.connectionFormSchema": {
45141
+ capName: "oidc-connections",
45142
+ capScope: "system",
45143
+ addonId: null,
45144
+ access: "view"
45145
+ },
45146
+ "oidcConnections.createConnection": {
45147
+ capName: "oidc-connections",
45148
+ capScope: "system",
45149
+ addonId: null,
45150
+ access: "create"
45151
+ },
45152
+ "oidcConnections.deleteConnection": {
45153
+ capName: "oidc-connections",
45154
+ capScope: "system",
45155
+ addonId: null,
45156
+ access: "delete"
45157
+ },
45158
+ "oidcConnections.listConnections": {
45159
+ capName: "oidc-connections",
45160
+ capScope: "system",
45161
+ addonId: null,
45162
+ access: "view"
45163
+ },
45164
+ "oidcConnections.updateConnection": {
45165
+ capName: "oidc-connections",
45166
+ capScope: "system",
45167
+ addonId: null,
45168
+ access: "create"
45169
+ },
43569
45170
  "osd.getStatus": {
43570
45171
  capName: "osd",
43571
45172
  capScope: "device",
@@ -43638,6 +45239,12 @@ Object.freeze({
43638
45239
  addonId: null,
43639
45240
  access: "create"
43640
45241
  },
45242
+ "osdManager.setSlotCameraEnabled": {
45243
+ capName: "osd-manager",
45244
+ capScope: "system",
45245
+ addonId: null,
45246
+ access: "create"
45247
+ },
43641
45248
  "osdManager.upsertTemplate": {
43642
45249
  capName: "osd-manager",
43643
45250
  capScope: "system",
@@ -43776,12 +45383,6 @@ Object.freeze({
43776
45383
  addonId: null,
43777
45384
  access: "create"
43778
45385
  },
43779
- "pipelineAnalytics.createRetrainDatasetVersion": {
43780
- capName: "pipeline-analytics",
43781
- capScope: "device",
43782
- addonId: null,
43783
- access: "create"
43784
- },
43785
45386
  "pipelineAnalytics.deleteDeviceEvents": {
43786
45387
  capName: "pipeline-analytics",
43787
45388
  capScope: "device",
@@ -43794,12 +45395,6 @@ Object.freeze({
43794
45395
  addonId: null,
43795
45396
  access: "delete"
43796
45397
  },
43797
- "pipelineAnalytics.deleteRetrainDatasetVersion": {
43798
- capName: "pipeline-analytics",
43799
- capScope: "device",
43800
- addonId: null,
43801
- access: "delete"
43802
- },
43803
45398
  "pipelineAnalytics.deleteTracks": {
43804
45399
  capName: "pipeline-analytics",
43805
45400
  capScope: "device",
@@ -43902,6 +45497,12 @@ Object.freeze({
43902
45497
  addonId: null,
43903
45498
  access: "view"
43904
45499
  },
45500
+ "pipelineAnalytics.getRetrainCorpusKpi": {
45501
+ capName: "pipeline-analytics",
45502
+ capScope: "device",
45503
+ addonId: null,
45504
+ access: "view"
45505
+ },
43905
45506
  "pipelineAnalytics.getRetrainExportUrl": {
43906
45507
  capName: "pipeline-analytics",
43907
45508
  capScope: "device",
@@ -44022,7 +45623,7 @@ Object.freeze({
44022
45623
  addonId: null,
44023
45624
  access: "view"
44024
45625
  },
44025
- "pipelineAnalytics.listRetrainDatasetVersions": {
45626
+ "pipelineAnalytics.listRetrainCorpusPage": {
44026
45627
  capName: "pipeline-analytics",
44027
45628
  capScope: "device",
44028
45629
  addonId: null,
@@ -44058,23 +45659,23 @@ Object.freeze({
44058
45659
  addonId: null,
44059
45660
  access: "view"
44060
45661
  },
44061
- "pipelineAnalytics.ownersWithMedia": {
45662
+ "pipelineAnalytics.offerRetrainArchive": {
44062
45663
  capName: "pipeline-analytics",
44063
45664
  capScope: "device",
44064
45665
  addonId: null,
44065
- access: "view"
45666
+ access: "create"
44066
45667
  },
44067
- "pipelineAnalytics.pauseForStorageMigration": {
45668
+ "pipelineAnalytics.ownersWithMedia": {
44068
45669
  capName: "pipeline-analytics",
44069
45670
  capScope: "device",
44070
45671
  addonId: null,
44071
- access: "create"
45672
+ access: "view"
44072
45673
  },
44073
- "pipelineAnalytics.previewRetrainDataset": {
45674
+ "pipelineAnalytics.pauseForStorageMigration": {
44074
45675
  capName: "pipeline-analytics",
44075
45676
  capScope: "device",
44076
45677
  addonId: null,
44077
- access: "view"
45678
+ access: "create"
44078
45679
  },
44079
45680
  "pipelineAnalytics.proposeRetrainAnnotations": {
44080
45681
  capName: "pipeline-analytics",
@@ -44154,6 +45755,12 @@ Object.freeze({
44154
45755
  addonId: null,
44155
45756
  access: "create"
44156
45757
  },
45758
+ "pipelineAnalytics.resolveRetrainTrainingCorpus": {
45759
+ capName: "pipeline-analytics",
45760
+ capScope: "device",
45761
+ addonId: null,
45762
+ access: "view"
45763
+ },
44157
45764
  "pipelineAnalytics.restageRetrainTrack": {
44158
45765
  capName: "pipeline-analytics",
44159
45766
  capScope: "device",
@@ -44214,12 +45821,6 @@ Object.freeze({
44214
45821
  addonId: null,
44215
45822
  access: "create"
44216
45823
  },
44217
- "pipelineAnalytics.verifyRetrainDatasetVersion": {
44218
- capName: "pipeline-analytics",
44219
- capScope: "device",
44220
- addonId: null,
44221
- access: "view"
44222
- },
44223
45824
  "pipelineAnalytics.wipeAllAnalytics": {
44224
45825
  capName: "pipeline-analytics",
44225
45826
  capScope: "device",
@@ -46596,6 +48197,180 @@ Object.freeze({
46596
48197
  addonId: null,
46597
48198
  access: "view"
46598
48199
  },
48200
+ "training.canaryResult": {
48201
+ capName: "training",
48202
+ capScope: "system",
48203
+ addonId: null,
48204
+ access: "create"
48205
+ },
48206
+ "training.cancelJob": {
48207
+ capName: "training",
48208
+ capScope: "system",
48209
+ addonId: null,
48210
+ access: "create"
48211
+ },
48212
+ "training.discardResult": {
48213
+ capName: "training",
48214
+ capScope: "system",
48215
+ addonId: null,
48216
+ access: "create"
48217
+ },
48218
+ "training.getJob": {
48219
+ capName: "training",
48220
+ capScope: "system",
48221
+ addonId: null,
48222
+ access: "view"
48223
+ },
48224
+ "training.getJobResult": {
48225
+ capName: "training",
48226
+ capScope: "system",
48227
+ addonId: null,
48228
+ access: "view"
48229
+ },
48230
+ "training.listBaseModels": {
48231
+ capName: "training",
48232
+ capScope: "system",
48233
+ addonId: null,
48234
+ access: "view"
48235
+ },
48236
+ "training.listJobs": {
48237
+ capName: "training",
48238
+ capScope: "system",
48239
+ addonId: null,
48240
+ access: "view"
48241
+ },
48242
+ "training.planJob": {
48243
+ capName: "training",
48244
+ capScope: "system",
48245
+ addonId: null,
48246
+ access: "view"
48247
+ },
48248
+ "training.registerResult": {
48249
+ capName: "training",
48250
+ capScope: "system",
48251
+ addonId: null,
48252
+ access: "create"
48253
+ },
48254
+ "training.rollbackCanary": {
48255
+ capName: "training",
48256
+ capScope: "system",
48257
+ addonId: null,
48258
+ access: "create"
48259
+ },
48260
+ "training.startJob": {
48261
+ capName: "training",
48262
+ capScope: "system",
48263
+ addonId: null,
48264
+ access: "create"
48265
+ },
48266
+ "training.startJobBatch": {
48267
+ capName: "training",
48268
+ capScope: "system",
48269
+ addonId: null,
48270
+ access: "create"
48271
+ },
48272
+ "trainingProvider.cancelJob": {
48273
+ capName: "training-provider",
48274
+ capScope: "system",
48275
+ addonId: null,
48276
+ access: "create"
48277
+ },
48278
+ "trainingProvider.cleanupJob": {
48279
+ capName: "training-provider",
48280
+ capScope: "system",
48281
+ addonId: null,
48282
+ access: "create"
48283
+ },
48284
+ "trainingProvider.createEntry": {
48285
+ capName: "training-provider",
48286
+ capScope: "system",
48287
+ addonId: null,
48288
+ access: "create"
48289
+ },
48290
+ "trainingProvider.deleteEntry": {
48291
+ capName: "training-provider",
48292
+ capScope: "system",
48293
+ addonId: null,
48294
+ access: "delete"
48295
+ },
48296
+ "trainingProvider.describe": {
48297
+ capName: "training-provider",
48298
+ capScope: "system",
48299
+ addonId: null,
48300
+ access: "view"
48301
+ },
48302
+ "trainingProvider.describeTypes": {
48303
+ capName: "training-provider",
48304
+ capScope: "system",
48305
+ addonId: null,
48306
+ access: "view"
48307
+ },
48308
+ "trainingProvider.estimateJob": {
48309
+ capName: "training-provider",
48310
+ capScope: "system",
48311
+ addonId: null,
48312
+ access: "view"
48313
+ },
48314
+ "trainingProvider.getJob": {
48315
+ capName: "training-provider",
48316
+ capScope: "system",
48317
+ addonId: null,
48318
+ access: "view"
48319
+ },
48320
+ "trainingProvider.listEntries": {
48321
+ capName: "training-provider",
48322
+ capScope: "system",
48323
+ addonId: null,
48324
+ access: "view"
48325
+ },
48326
+ "trainingProvider.listJobEvents": {
48327
+ capName: "training-provider",
48328
+ capScope: "system",
48329
+ addonId: null,
48330
+ access: "view"
48331
+ },
48332
+ "trainingProvider.listJobs": {
48333
+ capName: "training-provider",
48334
+ capScope: "system",
48335
+ addonId: null,
48336
+ access: "view"
48337
+ },
48338
+ "trainingProvider.offerArtifact": {
48339
+ capName: "training-provider",
48340
+ capScope: "system",
48341
+ addonId: null,
48342
+ access: "create"
48343
+ },
48344
+ "trainingProvider.readResult": {
48345
+ capName: "training-provider",
48346
+ capScope: "system",
48347
+ addonId: null,
48348
+ access: "create"
48349
+ },
48350
+ "trainingProvider.submitJob": {
48351
+ capName: "training-provider",
48352
+ capScope: "system",
48353
+ addonId: null,
48354
+ access: "create"
48355
+ },
48356
+ "trainingProvider.updateEntry": {
48357
+ capName: "training-provider",
48358
+ capScope: "system",
48359
+ addonId: null,
48360
+ access: "create"
48361
+ },
48362
+ "trainingProvider.uploadDataset": {
48363
+ capName: "training-provider",
48364
+ capScope: "system",
48365
+ addonId: null,
48366
+ access: "create"
48367
+ },
48368
+ "trainingProvider.validateCredentials": {
48369
+ capName: "training-provider",
48370
+ capScope: "system",
48371
+ addonId: null,
48372
+ access: "create"
48373
+ },
46599
48374
  "turnProvider.getTurnServers": {
46600
48375
  capName: "turn-provider",
46601
48376
  capScope: "system",
@@ -46620,12 +48395,6 @@ Object.freeze({
46620
48395
  addonId: null,
46621
48396
  access: "create"
46622
48397
  },
46623
- "userManagement.createApiKey": {
46624
- capName: "user-management",
46625
- capScope: "system",
46626
- addonId: null,
46627
- access: "create"
46628
- },
46629
48398
  "userManagement.createScopedToken": {
46630
48399
  capName: "user-management",
46631
48400
  capScope: "system",
@@ -46662,12 +48431,6 @@ Object.freeze({
46662
48431
  addonId: null,
46663
48432
  access: "view"
46664
48433
  },
46665
- "userManagement.linkExternalIdentity": {
46666
- capName: "user-management",
46667
- capScope: "system",
46668
- addonId: null,
46669
- access: "create"
46670
- },
46671
48434
  "userManagement.listApiKeys": {
46672
48435
  capName: "user-management",
46673
48436
  capScope: "system",
@@ -46770,12 +48533,6 @@ Object.freeze({
46770
48533
  addonId: null,
46771
48534
  access: "create"
46772
48535
  },
46773
- "userManagement.validateApiKey": {
46774
- capName: "user-management",
46775
- capScope: "system",
46776
- addonId: null,
46777
- access: "view"
46778
- },
46779
48536
  "userManagement.validateCredentials": {
46780
48537
  capName: "user-management",
46781
48538
  capScope: "system",
@@ -49874,6 +51631,11 @@ Object.freeze({
49874
51631
  form: "single",
49875
51632
  optional: false
49876
51633
  }],
51634
+ "osdManager.setSlotCameraEnabled": [{
51635
+ name: "deviceId",
51636
+ form: "single",
51637
+ optional: false
51638
+ }],
49877
51639
  "petFeeder.callPet": [{
49878
51640
  name: "deviceId",
49879
51641
  form: "single",
@@ -50094,6 +51856,11 @@ Object.freeze({
50094
51856
  form: "array",
50095
51857
  optional: false
50096
51858
  }],
51859
+ "pipelineAnalytics.listRetrainCorpusPage": [{
51860
+ name: "deviceIds",
51861
+ form: "array",
51862
+ optional: true
51863
+ }],
50097
51864
  "pipelineAnalytics.listRetrainStaging": [{
50098
51865
  name: "deviceIds",
50099
51866
  form: "array",
@@ -50955,6 +52722,11 @@ Object.freeze({
50955
52722
  form: "single",
50956
52723
  optional: false
50957
52724
  }],
52725
+ "training.canaryResult": [{
52726
+ name: "deviceIds",
52727
+ form: "array",
52728
+ optional: false
52729
+ }],
50958
52730
  "update.getStatus": [{
50959
52731
  name: "deviceId",
50960
52732
  form: "single",
@@ -51198,6 +52970,7 @@ Object.freeze({
51198
52970
  });
51199
52971
  Object.freeze({
51200
52972
  "broker": "broker",
52973
+ "calendar-source": "calendar",
51201
52974
  "device-export": "device-export",
51202
52975
  "llm": "ai",
51203
52976
  "mesh-network": "mesh",
@@ -51683,6 +53456,8 @@ var STATE_SUMMARY_VARS = [
51683
53456
  [...RULE_TEXT],
51684
53457
  [...RULE_TEXT],
51685
53458
  [...RULE_TEXT],
53459
+ [...RULE_TEXT],
53460
+ [...RULE_TEXT],
51686
53461
  ([...RULE_TEXT], [...UPDATES]),
51687
53462
  ([...RULE_TEXT], [...PACKAGE_UPDATES]),
51688
53463
  ([...RULE_TEXT], [...PACKAGE_UPDATES]),
@@ -61564,6 +63339,9 @@ async function discoverOnvifCameras(timeout = 5e3) {
61564
63339
  //#endregion
61565
63340
  //#region src/addon.ts
61566
63341
  var ADDON_ID = "provider-onvif";
63342
+ /** Stored flat, under its dotted schema key — the store is not nested. */
63343
+ var DISCOVERY_TIMEOUT_KEY = "discovery.timeout";
63344
+ var DEFAULT_DISCOVERY_TIMEOUT_MS = 5e3;
61567
63345
  var OnvifProviderAddon = class extends BaseDeviceProvider {
61568
63346
  addonId = ADDON_ID;
61569
63347
  providerName = "ONVIF";
@@ -61580,7 +63358,7 @@ var OnvifProviderAddon = class extends BaseDeviceProvider {
61580
63358
  }
61581
63359
  async discoverDevices() {
61582
63360
  const config = await this._getAddonConfig();
61583
- const timeout = config.discovery?.timeout ?? 5e3;
63361
+ const timeout = config.discovery?.timeout ?? DEFAULT_DISCOVERY_TIMEOUT_MS;
61584
63362
  this.ctx.logger.info("Starting ONVIF discovery", { meta: { timeoutMs: timeout } });
61585
63363
  const cameras = await discoverOnvifCameras(timeout);
61586
63364
  this.lastDiscovered = cameras;
@@ -61702,22 +63480,17 @@ var OnvifProviderAddon = class extends BaseDeviceProvider {
61702
63480
  return { sections: [{
61703
63481
  id: "discovery",
61704
63482
  title: "ONVIF Discovery",
61705
- description: "Auto-discover ONVIF cameras on the local network",
63483
+ description: "Find ONVIF cameras on the local network when you add a device",
61706
63484
  columns: 2,
61707
63485
  fields: [{
61708
- type: "boolean",
61709
- key: "discovery.enabled",
61710
- label: "Enable Auto-Discovery",
61711
- default: true
61712
- }, {
61713
63486
  type: "number",
61714
- key: "discovery.timeout",
63487
+ key: DISCOVERY_TIMEOUT_KEY,
61715
63488
  label: "Discovery Timeout",
61716
63489
  unit: "ms",
61717
63490
  min: 1e3,
61718
63491
  max: 3e4,
61719
63492
  step: 1e3,
61720
- default: 5e3
63493
+ default: DEFAULT_DISCOVERY_TIMEOUT_MS
61721
63494
  }]
61722
63495
  }, {
61723
63496
  id: "credentials",
@@ -61739,10 +63512,11 @@ var OnvifProviderAddon = class extends BaseDeviceProvider {
61739
63512
  async _getAddonConfig() {
61740
63513
  const raw = await this.resolveGlobalStore();
61741
63514
  const { defaultUsername, defaultPassword } = this.config;
63515
+ const storedTimeout = raw[DISCOVERY_TIMEOUT_KEY];
61742
63516
  return {
61743
63517
  id: typeof raw["id"] === "string" ? raw["id"] : "onvif-default",
61744
63518
  name: typeof raw["name"] === "string" ? raw["name"] : "ONVIF Cameras",
61745
- discovery: raw["discovery"],
63519
+ discovery: { timeout: typeof storedTimeout === "number" && Number.isFinite(storedTimeout) && storedTimeout > 0 ? storedTimeout : DEFAULT_DISCOVERY_TIMEOUT_MS },
61746
63520
  cameras: raw["cameras"],
61747
63521
  defaultUsername: defaultUsername !== "" ? defaultUsername : void 0,
61748
63522
  defaultPassword: defaultPassword !== "" ? defaultPassword : void 0