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