@camstack/addon-matter-broker 0.2.123 → 0.2.124

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/dist/addon.js +1771 -131
  2. package/dist/addon.mjs +1771 -131
  3. package/package.json +1 -1
package/dist/addon.mjs CHANGED
@@ -5389,7 +5389,7 @@ var ZodIssueCode = {
5389
5389
  var ZodFirstPartyTypeKind;
5390
5390
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
5391
5391
  //#endregion
5392
- //#region ../types/dist/sleep-Cr5YOk3m.mjs
5392
+ //#region ../types/dist/sleep-r3RWkGVx.mjs
5393
5393
  /**
5394
5394
  * The audio chunk plane's byte format, and the ONE expansion from a coded
5395
5395
  * window to float samples (D455).
@@ -5506,7 +5506,7 @@ function isKeychainStoredField(field) {
5506
5506
  var SECRET_CLEAR = { $secretClear: true };
5507
5507
  /** The `'***'` token D634 redaction writes for non-admins. */
5508
5508
  var LEGACY_DEVICE_REDACTION = "***";
5509
- function isRecord$1$1(value) {
5509
+ function isRecord$2(value) {
5510
5510
  return typeof value === "object" && value !== null && !Array.isArray(value);
5511
5511
  }
5512
5512
  function makeSecretMarker(ref) {
@@ -5517,12 +5517,12 @@ function makeSecretMarker(ref) {
5517
5517
  }
5518
5518
  /** A stored marker: an object whose `$secret` is a non-empty string. */
5519
5519
  function isSecretMarker(value) {
5520
- if (!isRecord$1$1(value)) return false;
5520
+ if (!isRecord$2(value)) return false;
5521
5521
  const ref = value["$secret"];
5522
5522
  return typeof ref === "string" && ref.length > 0;
5523
5523
  }
5524
5524
  function isSecretClear(value) {
5525
- return isRecord$1$1(value) && value["$secretClear"] === true;
5525
+ return isRecord$2(value) && value["$secretClear"] === true;
5526
5526
  }
5527
5527
  /**
5528
5528
  * The UI view of a stored secret field value: a marker becomes "set", inline
@@ -6038,6 +6038,13 @@ function globalSecretScope() {
6038
6038
  function encodeSegment(value) {
6039
6039
  return encodeURIComponent(value);
6040
6040
  }
6041
+ function decodeSegment(value) {
6042
+ try {
6043
+ return decodeURIComponent(value);
6044
+ } catch {
6045
+ return null;
6046
+ }
6047
+ }
6041
6048
  /**
6042
6049
  * The field path of a value inside an array item, addressed by the item's id:
6043
6050
  * `arrayItemFieldPath('providers', 'authentik', 'clientSecret')` →
@@ -6046,6 +6053,75 @@ function encodeSegment(value) {
6046
6053
  function arrayItemFieldPath(arrayKey, itemId, fieldKey) {
6047
6054
  return `${arrayKey}[${encodeSegment(itemId)}].${fieldKey}`;
6048
6055
  }
6056
+ function parseScope(segments) {
6057
+ switch (segments[0]) {
6058
+ case "global": return {
6059
+ scope: GLOBAL_SCOPE,
6060
+ used: 1
6061
+ };
6062
+ case "node": {
6063
+ const nodeId = segments[1] !== void 0 ? decodeSegment(segments[1]) : null;
6064
+ return nodeId === null || nodeId.length === 0 ? null : {
6065
+ scope: {
6066
+ kind: "node",
6067
+ nodeId
6068
+ },
6069
+ used: 2
6070
+ };
6071
+ }
6072
+ case "device": {
6073
+ const raw = segments[1];
6074
+ if (raw === void 0 || !/^\d+$/.test(raw)) return null;
6075
+ return {
6076
+ scope: {
6077
+ kind: "device",
6078
+ deviceId: Number(raw)
6079
+ },
6080
+ used: 2
6081
+ };
6082
+ }
6083
+ case "integration": {
6084
+ const id = segments[1] !== void 0 ? decodeSegment(segments[1]) : null;
6085
+ return id === null || id.length === 0 ? null : {
6086
+ scope: {
6087
+ kind: "integration",
6088
+ integrationId: id
6089
+ },
6090
+ used: 2
6091
+ };
6092
+ }
6093
+ case "row": {
6094
+ const collection = segments[1] !== void 0 ? decodeSegment(segments[1]) : null;
6095
+ const rowId = segments[2] !== void 0 ? decodeSegment(segments[2]) : null;
6096
+ if (collection === null || rowId === null || collection.length === 0 || rowId.length === 0) return null;
6097
+ return {
6098
+ scope: {
6099
+ kind: "row",
6100
+ collection,
6101
+ rowId
6102
+ },
6103
+ used: 3
6104
+ };
6105
+ }
6106
+ default: return null;
6107
+ }
6108
+ }
6109
+ /** Take a ref apart; `null` when it is not a well-formed ref. */
6110
+ function parseSecretRef(ref) {
6111
+ if (!ref.startsWith("secret://")) return null;
6112
+ const segments = ref.slice(9).split("/");
6113
+ const owner = segments[0] !== void 0 ? decodeSegment(segments[0]) : null;
6114
+ if (owner === null || owner.length === 0) return null;
6115
+ const parsed = parseScope(segments.slice(1));
6116
+ if (parsed === null) return null;
6117
+ const fieldPath = segments.slice(1 + parsed.used).join("/");
6118
+ if (fieldPath.length === 0) return null;
6119
+ return {
6120
+ owner,
6121
+ scope: parsed.scope,
6122
+ fieldPath
6123
+ };
6124
+ }
6049
6125
  /** A write to a secret path could not be stored in the keychain, so it was refused. */
6050
6126
  var KeychainWriteRefusedError = class extends Error {
6051
6127
  fieldPath;
@@ -6056,7 +6132,7 @@ var KeychainWriteRefusedError = class extends Error {
6056
6132
  }
6057
6133
  };
6058
6134
  var KEEP = { kind: "keep" };
6059
- function isRecord$2(value) {
6135
+ function isRecord$1$1(value) {
6060
6136
  return typeof value === "object" && value !== null && !Array.isArray(value);
6061
6137
  }
6062
6138
  function defaultMintId() {
@@ -6069,7 +6145,7 @@ function collectSecretMarkerRefs(value, out = []) {
6069
6145
  return out;
6070
6146
  }
6071
6147
  if (Array.isArray(value)) for (const item of value) collectSecretMarkerRefs(item, out);
6072
- else if (isRecord$2(value)) for (const child of Object.values(value)) collectSecretMarkerRefs(child, out);
6148
+ else if (isRecord$1$1(value)) for (const child of Object.values(value)) collectSecretMarkerRefs(child, out);
6073
6149
  return out;
6074
6150
  }
6075
6151
  async function storedValueEquals(secrets, marker, candidate) {
@@ -6124,7 +6200,7 @@ function rowId(row, idKey) {
6124
6200
  return null;
6125
6201
  }
6126
6202
  async function writeArray(ctx, node, incoming, stored, fieldPath) {
6127
- const storedRows = Array.isArray(stored) ? stored.filter(isRecord$2) : [];
6203
+ const storedRows = Array.isArray(stored) ? stored.filter(isRecord$1$1) : [];
6128
6204
  if (!Array.isArray(incoming)) {
6129
6205
  ctx.deletes.push(...collectSecretMarkerRefs(storedRows));
6130
6206
  return {
@@ -6140,7 +6216,7 @@ async function writeArray(ctx, node, incoming, stored, fieldPath) {
6140
6216
  const kept = /* @__PURE__ */ new Set();
6141
6217
  const rows = [];
6142
6218
  for (const row of incoming) {
6143
- if (!isRecord$2(row)) {
6219
+ if (!isRecord$1$1(row)) {
6144
6220
  rows.push(row);
6145
6221
  continue;
6146
6222
  }
@@ -6165,7 +6241,7 @@ async function writeNode(ctx, node, incoming, stored, fieldPath) {
6165
6241
  case "leaf": return writeLeaf(ctx, incoming, stored, fieldPath);
6166
6242
  case "array": return writeArray(ctx, node, incoming, stored, fieldPath);
6167
6243
  case "object": {
6168
- if (!isRecord$2(incoming)) {
6244
+ if (!isRecord$1$1(incoming)) {
6169
6245
  if (incoming === void 0) return KEEP;
6170
6246
  ctx.deletes.push(...collectSecretMarkerRefs(stored));
6171
6247
  return {
@@ -6173,7 +6249,7 @@ async function writeNode(ctx, node, incoming, stored, fieldPath) {
6173
6249
  value: incoming
6174
6250
  };
6175
6251
  }
6176
- const storedObj = isRecord$2(stored) ? stored : {};
6252
+ const storedObj = isRecord$1$1(stored) ? stored : {};
6177
6253
  return {
6178
6254
  kind: "value",
6179
6255
  value: await writeMembers(ctx, node.children, incoming, storedObj, (m) => `${fieldPath}.${m}`)
@@ -6232,12 +6308,19 @@ async function transformSecretWrite(input) {
6232
6308
  }
6233
6309
  };
6234
6310
  }
6311
+ /** Is `ref` one of `owner`'s refs? */
6312
+ function isSecretRefOwnedBy(ref, owner) {
6313
+ return parseSecretRef(ref)?.owner === owner;
6314
+ }
6235
6315
  /**
6236
6316
  * Replace every marker in `value` with its keychain value. Returns the SAME
6237
6317
  * reference when there is no marker (no allocation, no keychain call).
6238
6318
  */
6239
- async function resolveSecretMarkers(value, secrets) {
6240
- const refs = collectSecretMarkerRefs(value);
6319
+ async function resolveSecretMarkers(value, secrets, options = {}) {
6320
+ const keepMarker = options.unresolved === "keep-marker";
6321
+ const owner = options.ownedBy;
6322
+ const inScope = (ref) => owner === void 0 || isSecretRefOwnedBy(ref, owner);
6323
+ const refs = collectSecretMarkerRefs(value).filter(inScope);
6241
6324
  if (refs.length === 0) return {
6242
6325
  value,
6243
6326
  unresolved: []
@@ -6261,10 +6344,18 @@ async function resolveSecretMarkers(value, secrets) {
6261
6344
  }
6262
6345
  const substitute = (v) => {
6263
6346
  if (isSecretMarker(v)) {
6347
+ if (!inScope(v.$secret)) return {
6348
+ keep: true,
6349
+ value: v
6350
+ };
6264
6351
  const answer = answers[v.$secret];
6265
- return answer?.kind === "value" ? {
6352
+ if (answer?.kind === "value") return {
6266
6353
  keep: true,
6267
6354
  value: answer.value
6355
+ };
6356
+ return keepMarker ? {
6357
+ keep: true,
6358
+ value: v
6268
6359
  } : {
6269
6360
  keep: false,
6270
6361
  value: void 0
@@ -6281,7 +6372,7 @@ async function resolveSecretMarkers(value, secrets) {
6281
6372
  value: items
6282
6373
  };
6283
6374
  }
6284
- if (isRecord$2(v)) {
6375
+ if (isRecord$1$1(v)) {
6285
6376
  const out = {};
6286
6377
  for (const [k, child] of Object.entries(v)) {
6287
6378
  const s = substitute(child);
@@ -6302,14 +6393,152 @@ async function resolveSecretMarkers(value, secrets) {
6302
6393
  unresolved
6303
6394
  };
6304
6395
  }
6305
- function touchesTree(tree, patch) {
6306
- if (tree.size === 0) return false;
6307
- for (const key of Object.keys(patch)) {
6308
- const at = key.indexOf("@");
6309
- if (tree.has(at > 0 ? key.slice(0, at) : key)) return true;
6396
+ /** An addon tried to replace a stored secret it could not read. Nothing was written. */
6397
+ var SecretOverwriteRefusedError = class extends Error {
6398
+ ref;
6399
+ reason;
6400
+ constructor(ref, reason) {
6401
+ 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.`);
6402
+ this.ref = ref;
6403
+ this.reason = reason;
6404
+ this.name = "SecretOverwriteRefusedError";
6405
+ }
6406
+ };
6407
+ function isRecord$3(value) {
6408
+ return typeof value === "object" && value !== null && !Array.isArray(value);
6409
+ }
6410
+ function resolvedValue(pass, marker) {
6411
+ const answer = pass.answers[marker.$secret];
6412
+ return answer?.kind === "value" ? answer.value : null;
6413
+ }
6414
+ async function atMarker(pass, incoming, stored) {
6415
+ if (incoming === null) return stored;
6416
+ if (typeof incoming !== "string") return incoming;
6417
+ if (incoming === resolvedValue(pass, stored)) return stored;
6418
+ const intent = classifySecretWrite(incoming);
6419
+ if (intent.kind !== "set") return stored;
6420
+ const ref = stored.$secret;
6421
+ if (!isSecretRefOwnedBy(ref, pass.secrets.owner)) return incoming;
6422
+ const answer = pass.answers[ref];
6423
+ 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);
6424
+ try {
6425
+ await pass.secrets.put(ref, intent.value);
6426
+ } catch (err) {
6427
+ throw new KeychainWriteRefusedError(ref, err);
6428
+ }
6429
+ pass.changedRefs.push(ref);
6430
+ return stored;
6431
+ }
6432
+ function inArray(pass, incoming, stored) {
6433
+ return incoming.map((item, index) => {
6434
+ const twin = stored[index];
6435
+ if (isSecretMarker(twin)) return typeof item === "string" && item === resolvedValue(pass, twin) ? twin : item;
6436
+ if (isRecord$3(item) && isRecord$3(twin)) return inArrayRow(pass, item, twin);
6437
+ if (Array.isArray(item) && Array.isArray(twin)) return inArray(pass, item, twin);
6438
+ return item;
6439
+ });
6440
+ }
6441
+ function inArrayRow(pass, incoming, stored) {
6442
+ const out = { ...incoming };
6443
+ for (const [key, value] of Object.entries(incoming)) {
6444
+ const twin = stored[key];
6445
+ if (isSecretMarker(twin)) {
6446
+ if (typeof value === "string" && value === resolvedValue(pass, twin)) out[key] = twin;
6447
+ } else if (isRecord$3(value) && isRecord$3(twin)) out[key] = inArrayRow(pass, value, twin);
6448
+ else if (Array.isArray(value) && Array.isArray(twin)) out[key] = inArray(pass, value, twin);
6449
+ }
6450
+ return out;
6451
+ }
6452
+ async function walk(pass, incoming, stored) {
6453
+ if (isSecretMarker(stored)) return atMarker(pass, incoming, stored);
6454
+ if (Array.isArray(incoming) && Array.isArray(stored)) return inArray(pass, incoming, stored);
6455
+ if (!isRecord$3(incoming) || !isRecord$3(stored)) return incoming;
6456
+ const out = { ...incoming };
6457
+ for (const [key, value] of Object.entries(incoming)) out[key] = await walk(pass, value, stored[key]);
6458
+ return out;
6459
+ }
6460
+ /** Restore markers a write-back carries as values. See the file doc. */
6461
+ async function restoreUnchangedSecrets(input) {
6462
+ const refs = [];
6463
+ for (const key of Object.keys(input.patch)) collectSecretMarkerRefs(input.stored[key], refs);
6464
+ const owned = refs.filter((ref) => isSecretRefOwnedBy(ref, input.secrets.owner));
6465
+ if (owned.length === 0) return {
6466
+ patch: input.patch,
6467
+ changedRefs: []
6468
+ };
6469
+ const pass = {
6470
+ secrets: input.secrets,
6471
+ answers: await input.secrets.resolve([...new Set(owned)]),
6472
+ operatorWrite: input.operatorWrite,
6473
+ changedRefs: []
6474
+ };
6475
+ const out = {};
6476
+ for (const [key, value] of Object.entries(input.patch)) out[key] = await walk(pass, value, input.stored[key]);
6477
+ return {
6478
+ patch: out,
6479
+ changedRefs: pass.changedRefs
6480
+ };
6481
+ }
6482
+ /** Structural equality over JSON-shaped values (key order does not matter). */
6483
+ function isJsonEqual(a, b) {
6484
+ if (Object.is(a, b)) return true;
6485
+ if (Array.isArray(a)) return Array.isArray(b) && a.length === b.length && a.every((v, i) => isJsonEqual(v, b[i]));
6486
+ if (isRecord$3(a) && isRecord$3(b)) {
6487
+ const keys = Object.keys(a);
6488
+ if (keys.length !== Object.keys(b).length) return false;
6489
+ return keys.every((k) => Object.prototype.hasOwnProperty.call(b, k) && isJsonEqual(a[k], b[k]));
6310
6490
  }
6311
6491
  return false;
6312
6492
  }
6493
+ /** The patch without the keys whose value already equals the stored one. */
6494
+ function dropUnchangedKeys(patch, stored) {
6495
+ const out = {};
6496
+ for (const [key, value] of Object.entries(patch)) {
6497
+ if (Object.prototype.hasOwnProperty.call(stored, key) && isJsonEqual(value, stored[key])) continue;
6498
+ out[key] = value;
6499
+ }
6500
+ return out;
6501
+ }
6502
+ /** The top-level keys of a blob that hold at least one of `owner`'s markers. */
6503
+ function markerKeysOf(blob, owner) {
6504
+ const keys = /* @__PURE__ */ new Set();
6505
+ for (const [key, value] of Object.entries(blob)) if (collectSecretMarkerRefs(value).some((ref) => isSecretRefOwnedBy(ref, owner))) keys.add(key);
6506
+ return keys;
6507
+ }
6508
+ function nodeFromStored(value, owner) {
6509
+ if (isSecretMarker(value)) return isSecretRefOwnedBy(value.$secret, owner) ? { kind: "leaf" } : null;
6510
+ if (!isRecord$3(value)) return null;
6511
+ const children = /* @__PURE__ */ new Map();
6512
+ for (const [key, child] of Object.entries(value)) {
6513
+ const node = nodeFromStored(child, owner);
6514
+ if (node !== null) children.set(key, node);
6515
+ }
6516
+ return children.size > 0 ? {
6517
+ kind: "object",
6518
+ children
6519
+ } : null;
6520
+ }
6521
+ /**
6522
+ * The declared secret tree, widened by every place the STORED blob holds a
6523
+ * marker under one of `keys` — so a marker the schema no longer declares (or
6524
+ * never declared: Wyze before b4906cec6) still gets the save path's
6525
+ * KEEP / SET / CLEAR semantics instead of being overwritten by whatever the
6526
+ * addon writes. Markers inside arrays are not added: a row has no id field to
6527
+ * match by unless the schema declares one. Only `owner`'s markers count: a
6528
+ * builtin that keeps another addon's marker (device-manager) never takes it
6529
+ * over.
6530
+ */
6531
+ function widenTreeWithStoredMarkers(declared, stored, keys, owner) {
6532
+ const added = /* @__PURE__ */ new Map();
6533
+ for (const key of keys) {
6534
+ const at = key.indexOf("@");
6535
+ const base = at > 0 ? key.slice(0, at) : key;
6536
+ if (declared.has(base) || added.has(base)) continue;
6537
+ const node = nodeFromStored(stored[key], owner);
6538
+ if (node !== null) added.set(base, node);
6539
+ }
6540
+ return added.size === 0 ? declared : new Map([...declared, ...added]);
6541
+ }
6313
6542
  /** The blob as stored now; a failed read REFUSES the write instead of guessing. */
6314
6543
  async function readStoredAddonBlob(raw) {
6315
6544
  const threeWay = raw.readAddonStoreResult;
@@ -6318,7 +6547,41 @@ async function readStoredAddonBlob(raw) {
6318
6547
  if (result.kind === "failed") throw new Error(`settings write refused: the stored blob could not be read (${result.error})`);
6319
6548
  return result.kind === "missing" ? {} : result.value;
6320
6549
  }
6321
- function createSecretAwareSettings(raw, opts) {
6550
+ function touchesTree(tree, patch) {
6551
+ if (tree.size === 0) return false;
6552
+ for (const key of Object.keys(patch)) {
6553
+ const at = key.indexOf("@");
6554
+ if (tree.has(at > 0 ? key.slice(0, at) : key)) return true;
6555
+ }
6556
+ return false;
6557
+ }
6558
+ /**
6559
+ * Which top-level keys of each store held markers when last seen. `undefined`
6560
+ * for a store not seen yet: its first write reads it, to be safe.
6561
+ */
6562
+ var MarkerKeyIndex = class {
6563
+ owner;
6564
+ byStore = /* @__PURE__ */ new Map();
6565
+ constructor(owner) {
6566
+ this.owner = owner;
6567
+ }
6568
+ seen(store, blob) {
6569
+ this.byStore.set(store, markerKeysOf(blob, this.owner));
6570
+ }
6571
+ wrote(store, patch) {
6572
+ const keys = this.byStore.get(store);
6573
+ if (keys === void 0) return;
6574
+ const now = markerKeysOf(patch, this.owner);
6575
+ for (const key of Object.keys(patch)) if (now.has(key)) keys.add(key);
6576
+ else keys.delete(key);
6577
+ }
6578
+ mayHoldMarkers(store, patch) {
6579
+ const keys = this.byStore.get(store);
6580
+ if (keys === void 0) return true;
6581
+ return Object.keys(patch).some((key) => keys.has(key));
6582
+ }
6583
+ };
6584
+ function createHandle(raw, opts) {
6322
6585
  const chains = /* @__PURE__ */ new Map();
6323
6586
  const serialize = (key, fn) => {
6324
6587
  const next = (chains.get(key) ?? Promise.resolve()).then(fn, fn);
@@ -6329,46 +6592,130 @@ function createSecretAwareSettings(raw, opts) {
6329
6592
  });
6330
6593
  return next;
6331
6594
  };
6332
- const write = async (chainKey, tree, scope, patch, readStored, rawWrite) => {
6333
- if (!touchesTree(tree, patch)) return rawWrite(patch);
6334
- return serialize(chainKey, async () => {
6595
+ const index = new MarkerKeyIndex(opts.secrets.owner);
6596
+ const resolveRead = async (store, blob) => {
6597
+ index.seen(store, blob);
6598
+ const { value, unresolved } = await resolveSecretMarkers(blob, opts.secrets, {
6599
+ unresolved: "keep-marker",
6600
+ ownedBy: opts.secrets.owner
6601
+ });
6602
+ if (unresolved.length > 0) opts.onUnresolved?.(unresolved);
6603
+ return value;
6604
+ };
6605
+ const write = async (store, declared, scope, patch, readStored, rawWrite) => {
6606
+ if (!touchesTree(declared, patch) && !index.mayHoldMarkers(store, patch)) {
6607
+ await rawWrite(patch);
6608
+ index.wrote(store, patch);
6609
+ return { changed: true };
6610
+ }
6611
+ return serialize(store, async () => {
6335
6612
  const stored = await readStored();
6613
+ index.seen(store, stored);
6614
+ const operatorWrite = opts.isOperatorWrite?.() === true;
6615
+ const restored = await restoreUnchangedSecrets({
6616
+ patch,
6617
+ stored,
6618
+ secrets: opts.secrets,
6619
+ operatorWrite
6620
+ });
6336
6621
  const result = await transformSecretWrite({
6337
- tree,
6622
+ tree: widenTreeWithStoredMarkers(declared, stored, Object.keys(restored.patch), opts.secrets.owner),
6338
6623
  secrets: opts.secrets,
6339
- patch,
6624
+ patch: restored.patch,
6340
6625
  stored,
6341
6626
  ...scope !== void 0 ? { scope } : {},
6342
- operatorWrite: opts.isOperatorWrite?.() === true
6627
+ operatorWrite
6343
6628
  });
6344
- if (Object.keys(result.patch).length > 0) await rawWrite(result.patch);
6629
+ const effective = dropUnchangedKeys(result.patch, stored);
6630
+ const wroteBlob = Object.keys(effective).length > 0;
6631
+ if (wroteBlob) {
6632
+ await rawWrite(effective);
6633
+ index.wrote(store, effective);
6634
+ }
6345
6635
  const { orphaned } = await result.afterWrite();
6346
6636
  if (orphaned.length > 0) opts.onOrphaned(orphaned);
6637
+ return { changed: wroteBlob || restored.changedRefs.length > 0 };
6347
6638
  });
6348
6639
  };
6349
- const wrapped = {
6350
- writeAddonStore: (patch) => write("addon", opts.addonTree(), void 0, patch, () => readStoredAddonBlob(raw), (p) => raw.writeAddonStore(p)),
6351
- writeDeviceStore: (deviceId, patch) => write(`device:${deviceId}`, opts.deviceTree(), {
6352
- kind: "device",
6353
- deviceId
6354
- }, patch, () => raw.readDeviceStore(deviceId), (p) => raw.writeDeviceStore(deviceId, p))
6640
+ const writeAddon = (patch) => write("addon", opts.addonTree(), void 0, patch, () => readStoredAddonBlob(raw), (p) => raw.writeAddonStore(p));
6641
+ const readAddonStoreResult = raw.readAddonStoreResult;
6642
+ const readAddonStoreKeyResult = raw.readAddonStoreKeyResult;
6643
+ const readDeviceStoreBatch = raw.readDeviceStoreBatch;
6644
+ const overrides = {
6645
+ readAddonStore: async () => resolveRead("addon", await raw.readAddonStore()),
6646
+ ...readAddonStoreResult !== void 0 ? { readAddonStoreResult: async () => {
6647
+ const result = await readAddonStoreResult.call(raw);
6648
+ return result.kind === "value" ? {
6649
+ kind: "value",
6650
+ value: await resolveRead("addon", result.value)
6651
+ } : result;
6652
+ } } : {},
6653
+ ...readAddonStoreKeyResult !== void 0 ? { readAddonStoreKeyResult: async (key) => {
6654
+ const result = await readAddonStoreKeyResult.call(raw, key);
6655
+ if (result.kind !== "present") return result;
6656
+ const { value, unresolved } = await resolveSecretMarkers({ [key]: result.value }, opts.secrets, {
6657
+ unresolved: "keep-marker",
6658
+ ownedBy: opts.secrets.owner
6659
+ });
6660
+ if (unresolved.length > 0) opts.onUnresolved?.(unresolved);
6661
+ return {
6662
+ kind: "present",
6663
+ value: value[key]
6664
+ };
6665
+ } } : {},
6666
+ readDeviceStore: async (deviceId) => resolveRead(`device:${deviceId}`, await raw.readDeviceStore(deviceId)),
6667
+ ...readDeviceStoreBatch !== void 0 ? { readDeviceStoreBatch: async (deviceIds) => {
6668
+ const rows = await readDeviceStoreBatch.call(raw, deviceIds);
6669
+ const out = /* @__PURE__ */ new Map();
6670
+ for (const [deviceId, blob] of rows) out.set(deviceId, await resolveRead(`device:${deviceId}`, blob));
6671
+ return out;
6672
+ } } : {},
6673
+ writeAddonStore: async (patch) => {
6674
+ await writeAddon(patch);
6675
+ },
6676
+ writeDeviceStore: async (deviceId, patch) => {
6677
+ await write(`device:${deviceId}`, opts.deviceTree(), {
6678
+ kind: "device",
6679
+ deviceId
6680
+ }, patch, () => raw.readDeviceStore(deviceId), (p) => raw.writeDeviceStore(deviceId, p));
6681
+ }
6682
+ };
6683
+ return {
6684
+ settings: new Proxy(raw, { get(target, prop, receiver) {
6685
+ if (typeof prop === "string" && Object.prototype.hasOwnProperty.call(overrides, prop)) return Reflect.get(overrides, prop);
6686
+ const value = Reflect.get(target, prop, receiver);
6687
+ return typeof value === "function" ? value.bind(target) : value;
6688
+ } }),
6689
+ raw: {
6690
+ readAddonStore: async () => {
6691
+ const blob = await raw.readAddonStore();
6692
+ index.seen("addon", blob);
6693
+ return blob;
6694
+ },
6695
+ readDeviceStore: async (deviceId) => {
6696
+ const blob = await raw.readDeviceStore(deviceId);
6697
+ index.seen(`device:${deviceId}`, blob);
6698
+ return blob;
6699
+ }
6700
+ },
6701
+ writeAddonStore: writeAddon
6355
6702
  };
6356
- return new Proxy(raw, { get(target, prop, receiver) {
6357
- if (prop === "writeAddonStore") return wrapped.writeAddonStore;
6358
- if (prop === "writeDeviceStore") return wrapped.writeDeviceStore;
6359
- const value = Reflect.get(target, prop, receiver);
6360
- return typeof value === "function" ? value.bind(target) : value;
6361
- } });
6362
6703
  }
6363
- /** The context the addon sees: identical, except that its settings writes are secret-aware. */
6364
- function withSecretAwareSettings(context, opts) {
6704
+ /** The context the addon sees, plus the private raw view and write outcome. */
6705
+ function createSecretAwareContext(context, opts) {
6365
6706
  const raw = context.settings;
6366
- if (raw === void 0) return context;
6367
- const settings = createSecretAwareSettings(raw, opts);
6368
- return new Proxy(context, { get(target, prop, receiver) {
6369
- if (prop === "settings") return settings;
6370
- return Reflect.get(target, prop, receiver);
6371
- } });
6707
+ if (raw === void 0) return {
6708
+ context,
6709
+ handle: null
6710
+ };
6711
+ const handle = createHandle(raw, opts);
6712
+ return {
6713
+ context: new Proxy(context, { get(target, prop, receiver) {
6714
+ if (prop === "settings") return handle.settings;
6715
+ return Reflect.get(target, prop, receiver);
6716
+ } }),
6717
+ handle
6718
+ };
6372
6719
  }
6373
6720
  var LEAF = { kind: "leaf" };
6374
6721
  var DEFAULT_ITEM_ID_KEY = "id";
@@ -6543,6 +6890,14 @@ var BaseAddon = class {
6543
6890
  _secretChangeUnsub = null;
6544
6891
  /** >0 while an OPERATOR's settings write is being applied. */
6545
6892
  _operatorWriteDepth = 0;
6893
+ /**
6894
+ * The keychain-aware settings handle (D798). Its `raw` view is the ONLY way
6895
+ * to the marker-bearing blobs and stays private to this class: the form
6896
+ * hydrate and config resolution need markers, addon code never does.
6897
+ */
6898
+ _secretSettings = null;
6899
+ /** Refs an addon-facing read could not resolve — each is logged once per process. */
6900
+ _loggedUnresolvedReads = /* @__PURE__ */ new Set();
6546
6901
  constructor(defaults) {
6547
6902
  this.defaults = defaults;
6548
6903
  this._config = { ...defaults };
@@ -6579,13 +6934,21 @@ var BaseAddon = class {
6579
6934
  }
6580
6935
  async initialize(context) {
6581
6936
  const secrets = context.secrets;
6582
- this._ctx = secrets !== void 0 ? withSecretAwareSettings(context, {
6583
- secrets,
6584
- addonTree: () => this.addonSecretTree(),
6585
- deviceTree: () => this.deviceSecretTree(),
6586
- onOrphaned: (refs) => context.logger.warn("keychain refs dropped by a settings write could not be deleted", { meta: { refs: [...refs] } }),
6587
- isOperatorWrite: () => this._operatorWriteDepth > 0
6588
- }) : context;
6937
+ if (secrets !== void 0) {
6938
+ const { context: wrapped, handle } = createSecretAwareContext(context, {
6939
+ secrets,
6940
+ addonTree: () => this.addonSecretTree(),
6941
+ deviceTree: () => this.deviceSecretTree(),
6942
+ onOrphaned: (refs) => context.logger.warn("keychain refs dropped by a settings write could not be deleted", { meta: { refs: [...refs] } }),
6943
+ isOperatorWrite: () => this._operatorWriteDepth > 0,
6944
+ onUnresolved: (unresolved) => this.logUnresolvedRead(unresolved)
6945
+ });
6946
+ this._ctx = wrapped;
6947
+ this._secretSettings = handle;
6948
+ } else {
6949
+ this._ctx = context;
6950
+ this._secretSettings = null;
6951
+ }
6589
6952
  await this.resolveConfig();
6590
6953
  if (secrets !== void 0) this._secretChangeUnsub = secrets.onChange((ref) => {
6591
6954
  if (this._configSecretRefs.has(ref)) this.scheduleSecretReresolve(SECRET_CHANGE_DEBOUNCE_MS);
@@ -6702,11 +7065,8 @@ var BaseAddon = class {
6702
7065
  async getGlobalSettings(overlay, cap, nodeId) {
6703
7066
  const schema = this.globalSettingsSchema(cap);
6704
7067
  if (!schema) return { sections: [] };
6705
- const projected = await this.resolveGlobalStore(nodeId, cap);
6706
- return hydrateSchema(schema, overlay ? {
6707
- ...projected,
6708
- ...overlay
6709
- } : projected, { inlineSecretsAsViews: true });
7068
+ const projected = await this.readRawProjectedStore(nodeId, cap);
7069
+ return hydrateSchema(schema, overlay ? await this.overlayKeepingMarkers(projected, overlay) : projected, { inlineSecretsAsViews: true });
6710
7070
  }
6711
7071
  /**
6712
7072
  * The integration-level view of this addon's settings: exactly the sections
@@ -6751,7 +7111,7 @@ var BaseAddon = class {
6751
7111
  });
6752
7112
  }
6753
7113
  if (sections.length === 0) return null;
6754
- const projected = await this.resolveGlobalStore(nodeId);
7114
+ const projected = await this.readRawProjectedStore(nodeId);
6755
7115
  return hydrateSchema({
6756
7116
  ...schema,
6757
7117
  sections
@@ -6768,12 +7128,50 @@ var BaseAddon = class {
6768
7128
  * the store for custom option logic (option narrowing, value snapping) to
6769
7129
  * read it per-node — never `ctx.settings.readAddonStore()` directly.
6770
7130
  * `nodeId` omitted ⇒ the local node (node-blind injection from ctx).
7131
+ *
7132
+ * Keychain values come back RESOLVED (D798): a secret reads as its value,
7133
+ * never as a `{ $secret }` marker. One the keychain cannot serve right now
7134
+ * stays a marker — "stored, unavailable" (`isSecretMarker()` is true, and it
7135
+ * is listed in {@link unresolvedSecrets}) — never `''` and never absent, so
7136
+ * it cannot be mistaken for "nothing stored, mint a new one". Writing the
7137
+ * resolved blob back is a no-op for every unchanged secret.
6771
7138
  */
6772
7139
  async resolveGlobalStore(nodeId, cap) {
6773
7140
  const raw = await this._ctx?.settings?.readAddonStore() ?? {};
7141
+ return this.projectForNode(raw, nodeId, cap);
7142
+ }
7143
+ projectForNode(store, nodeId, cap) {
6774
7144
  const keys = this.perNodeKeys(cap);
6775
7145
  const node = normalizeNodeId(nodeId ?? this._ctx?.kernel?.localNodeId);
6776
- return keys.size > 0 ? projectStore(raw, keys, node) : raw;
7146
+ return keys.size > 0 ? projectStore(store, keys, node) : store;
7147
+ }
7148
+ /** The PROJECTED store with its markers — the form hydrate only (D798). */
7149
+ async readRawProjectedStore(nodeId, cap) {
7150
+ const raw = await this.rawSettings()?.readAddonStore() ?? {};
7151
+ return this.projectForNode(raw, nodeId, cap);
7152
+ }
7153
+ /**
7154
+ * `{ ...stored, ...overlay }`, except that an overlay member equal to the
7155
+ * RESOLVED stored one keeps the stored (marker-bearing) member — so a form
7156
+ * hydrated from a resolved overlay still shows a secret as "set", never as
7157
+ * its value.
7158
+ */
7159
+ async overlayKeepingMarkers(stored, overlay) {
7160
+ const secrets = this._ctx?.secrets;
7161
+ const merged = {
7162
+ ...stored,
7163
+ ...overlay
7164
+ };
7165
+ if (secrets === void 0 || collectSecretMarkerRefs(stored).length === 0) return merged;
7166
+ const { value: resolved } = await resolveSecretMarkers(stored, secrets, {
7167
+ unresolved: "keep-marker",
7168
+ ownedBy: secrets.owner
7169
+ });
7170
+ for (const key of Object.keys(overlay)) {
7171
+ if (collectSecretMarkerRefs(stored[key]).length === 0) continue;
7172
+ if (isJsonEqual(overlay[key], resolved[key])) merged[key] = stored[key];
7173
+ }
7174
+ return merged;
6777
7175
  }
6778
7176
  /**
6779
7177
  * Whether ONE global key of this addon's store was written, read three-way
@@ -6838,8 +7236,12 @@ var BaseAddon = class {
6838
7236
  async clearSecrets(keys, nodeId) {
6839
7237
  const tree = this.addonSecretTree();
6840
7238
  const keychain = this._ctx?.secrets !== void 0;
7239
+ const stored = keychain ? await this.readAddonStoreWithRetry() : {};
6841
7240
  const patch = {};
6842
- for (const key of keys) patch[key] = keychain && tree.has(key) ? SECRET_CLEAR : "";
7241
+ for (const key of keys) {
7242
+ const keychainStored = tree.has(key) || collectSecretMarkerRefs(stored[key]).length > 0;
7243
+ patch[key] = keychain && keychainStored ? SECRET_CLEAR : "";
7244
+ }
6843
7245
  await this.applyGlobalPatch(patch, nodeId);
6844
7246
  }
6845
7247
  async applyGlobalPatch(barePatch, nodeId) {
@@ -6847,7 +7249,11 @@ var BaseAddon = class {
6847
7249
  const localNode = normalizeNodeId(this._ctx?.kernel?.localNodeId);
6848
7250
  const target = normalizeNodeId(nodeId ?? this._ctx?.kernel?.localNodeId);
6849
7251
  const scoped = keys.size > 0 ? scopePatch(barePatch, keys, target) : barePatch;
6850
- await this._ctx?.settings?.writeAddonStore(scoped);
7252
+ const handle = this._secretSettings;
7253
+ if (handle !== null) {
7254
+ const { changed } = await handle.writeAddonStore(scoped);
7255
+ if (!changed) return;
7256
+ } else await this._ctx?.settings?.writeAddonStore(scoped);
6851
7257
  if (target !== localNode) return;
6852
7258
  await this.resolveConfig();
6853
7259
  await this.onConfigChanged();
@@ -6900,7 +7306,7 @@ var BaseAddon = class {
6900
7306
  async getDeviceSettings(deviceId) {
6901
7307
  const schema = this.deviceSettingsSchema();
6902
7308
  if (!schema) return { sections: [] };
6903
- return hydrateSchema(schema, await this._ctx?.settings?.readDeviceStore(deviceId) ?? {}, { inlineSecretsAsViews: true });
7309
+ return hydrateSchema(schema, await this.rawSettings()?.readDeviceStore(deviceId) ?? {}, { inlineSecretsAsViews: true });
6904
7310
  }
6905
7311
  async updateDeviceSettings(deviceId, patch) {
6906
7312
  await this._ctx?.settings?.writeDeviceStore(deviceId, patch);
@@ -7072,7 +7478,7 @@ var BaseAddon = class {
7072
7478
  key,
7073
7479
  schema,
7074
7480
  fallback,
7075
- read: async () => this.resolveStoredSecrets(await this._ctx?.settings?.readDeviceStore(deviceId) ?? {}, false),
7481
+ read: async () => this.resolveStoredSecrets(await this.rawSettings()?.readDeviceStore(deviceId) ?? {}, false),
7076
7482
  write: async (patch) => {
7077
7483
  await this._ctx?.settings?.writeDeviceStore(deviceId, patch);
7078
7484
  },
@@ -7134,6 +7540,23 @@ var BaseAddon = class {
7134
7540
  }
7135
7541
  return value;
7136
7542
  }
7543
+ /**
7544
+ * The marker-bearing settings reads (D798) — private on purpose. Without a
7545
+ * keychain the context's own view is already raw.
7546
+ */
7547
+ rawSettings() {
7548
+ return this._secretSettings?.raw ?? this._ctx?.settings;
7549
+ }
7550
+ /** An addon-facing read met markers it could not resolve: say so once per ref. */
7551
+ logUnresolvedRead(unresolved) {
7552
+ const fresh = unresolved.filter((u) => !this._loggedUnresolvedReads.has(u.ref));
7553
+ if (fresh.length === 0) return;
7554
+ for (const u of fresh) this._loggedUnresolvedReads.add(u.ref);
7555
+ 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) => ({
7556
+ ref: u.ref,
7557
+ reason: u.reason
7558
+ })) } });
7559
+ }
7137
7560
  /** Re-resolve the config (a keychain-only change, or a retry) and apply it. */
7138
7561
  scheduleSecretReresolve(delayMs) {
7139
7562
  const timerOf = delayMs === SECRET_CHANGE_DEBOUNCE_MS ? "_secretChangeTimer" : "_secretRetryTimer";
@@ -7160,7 +7583,7 @@ var BaseAddon = class {
7160
7583
  * `{}` (defaults) — the addon's first successful patch will rehydrate.
7161
7584
  */
7162
7585
  async readAddonStoreWithRetry() {
7163
- const settings = this._ctx?.settings;
7586
+ const settings = this.rawSettings();
7164
7587
  if (!settings) return {};
7165
7588
  const delaysMs = [
7166
7589
  150,
@@ -9463,6 +9886,278 @@ var CameraSwitchGroupSchema = object({
9463
9886
  fetchedAt: number()
9464
9887
  });
9465
9888
  /**
9889
+ * The trainer contract — what the hub hands the cloud trainer and what it
9890
+ * gets back (cloud training, D805+).
9891
+ *
9892
+ * The trainer (`hf/camstack-trainer`, published as the Hugging Face repo
9893
+ * `camstack/camstack-trainer`) is a separate AGPL program the hub never
9894
+ * imports: `job.json` goes in, files come out, and progress is `CAMSTACK_EVENT`
9895
+ * lines on stdout. These schemas are the hub's half of that boundary; the
9896
+ * trainer's pydantic models (and the JSON Schemas generated from them under
9897
+ * `hf/camstack-trainer/schemas/`) are the other half. A change here is a
9898
+ * change there, in the same piece of work.
9899
+ *
9900
+ * No `.default()` anywhere: defaults do not run on the addon cap path, so the
9901
+ * orchestrator fills every field of a job spec explicitly.
9902
+ */
9903
+ var TRAINING_JOB_SCHEMA = "camstack.training/v1";
9904
+ var TRAINING_RESULT_SCHEMA = "camstack.training-result/v1";
9905
+ /** What the trainer can export. Edge TPU is a later, separate image. */
9906
+ var TrainingExportSchema = _enum([
9907
+ "onnx",
9908
+ "openvino-fp16",
9909
+ "openvino-int8",
9910
+ "coreml-fp16"
9911
+ ]);
9912
+ var FloorsSchema = record(string$2(), number().min(0).max(1));
9913
+ object({
9914
+ schema: literal(TRAINING_JOB_SCHEMA),
9915
+ jobKey: string$2().uuid(),
9916
+ target: object({
9917
+ kind: literal("detector"),
9918
+ step: literal("object-detection")
9919
+ }),
9920
+ base: object({
9921
+ modelId: string$2().min(1),
9922
+ /** Ultralytics weights id, e.g. `yolov9m.pt`. */
9923
+ weights: string$2().min(1),
9924
+ imgsz: number().int().positive()
9925
+ }),
9926
+ baseline: object({
9927
+ modelId: string$2().min(1),
9928
+ /** The baseline ONNX the holdout comparison runs; public mirror URL. */
9929
+ onnxUrl: string$2().url(),
9930
+ imgsz: number().int().positive(),
9931
+ floors: FloorsSchema
9932
+ }),
9933
+ dataset: object({
9934
+ versionId: string$2().min(1),
9935
+ annotationHash: string$2(),
9936
+ /** sha256 of the uploaded archive; the trainer refuses a mismatch (exit 65). */
9937
+ sha256: string$2().regex(/^[0-9a-f]{64}$/)
9938
+ }),
9939
+ split: object({
9940
+ holdoutCameras: array(number().int()),
9941
+ /** When no camera is held out: the last N days of every camera. */
9942
+ holdoutLastDays: number().int().nonnegative(),
9943
+ valFraction: number().min(0).max(.5),
9944
+ seed: number().int()
9945
+ }),
9946
+ hyper: object({
9947
+ epochs: number().int().positive(),
9948
+ batch: number().int().positive(),
9949
+ lr0: number().positive(),
9950
+ /** Layers frozen from the start of the backbone; 0 = none. */
9951
+ freeze: number().int().nonnegative(),
9952
+ patience: number().int().nonnegative(),
9953
+ seed: number().int()
9954
+ }),
9955
+ replay: object({
9956
+ source: literal("coco2017"),
9957
+ count: number().int().nonnegative()
9958
+ }),
9959
+ exports: array(TrainingExportSchema).min(1),
9960
+ calibration: object({ maxFrames: number().int().positive() }),
9961
+ floors: object({
9962
+ minSupport: number().int().positive(),
9963
+ clamp: number().min(0).max(1)
9964
+ }),
9965
+ int8Gate: object({ maxMap50Drop: number().min(0).max(1) }),
9966
+ catalog: object({
9967
+ id: string$2().regex(/^[a-z0-9][a-z0-9-]{2,80}$/),
9968
+ name: string$2().min(1).max(160)
9969
+ })
9970
+ });
9971
+ /** One regular file of the bundle. An mlpackage contributes one row per member. */
9972
+ var TrainingResultFileSchema = object({
9973
+ path: string$2().min(1),
9974
+ bytes: number().int().nonnegative(),
9975
+ sha256: string$2().regex(/^[0-9a-f]{64}$/),
9976
+ format: _enum([
9977
+ "onnx",
9978
+ "openvino",
9979
+ "coreml",
9980
+ "pt"
9981
+ ]),
9982
+ variant: _enum(["base", "int8"])
9983
+ });
9984
+ var DraftFormatSchema = object({
9985
+ /** RELATIVE path inside the bundle; the hub rewrites it to `camstack-local://`. */
9986
+ url: string$2().min(1),
9987
+ sizeMB: number().nonnegative(),
9988
+ isDirectory: boolean().optional(),
9989
+ files: array(string$2()).optional(),
9990
+ runtimes: array(literal("python")).optional(),
9991
+ revision: string$2().min(1)
9992
+ });
9993
+ /** The trainer's half of a catalog entry; the hub completes it (labels, licence, group). */
9994
+ var TrainingCatalogDraftSchema = object({
9995
+ id: string$2().min(1),
9996
+ name: string$2().min(1),
9997
+ description: string$2(),
9998
+ labels: array(unknown()),
9999
+ inputSize: object({
10000
+ width: number().int().positive(),
10001
+ height: number().int().positive()
10002
+ }),
10003
+ preprocessMode: literal("letterbox"),
10004
+ defaultClassFloors: FloorsSchema,
10005
+ formats: object({
10006
+ onnx: DraftFormatSchema.optional(),
10007
+ openvino: DraftFormatSchema.optional(),
10008
+ coreml: DraftFormatSchema.optional()
10009
+ })
10010
+ });
10011
+ /** One class of one model's holdout report (the eval harness's summary). */
10012
+ var TrainingEvalClassSchema = object({
10013
+ positives: number().int(),
10014
+ floor: number().nullable(),
10015
+ tp: number().int(),
10016
+ fp: number().int(),
10017
+ fn: number().int(),
10018
+ precision: number().nullable(),
10019
+ recall: number().nullable(),
10020
+ ap50: number().nullable(),
10021
+ recallByCamera: record(string$2(), number().nullable()).optional(),
10022
+ recallByLight: record(string$2(), number().nullable()).optional(),
10023
+ fpByCamera: record(string$2(), number()).optional(),
10024
+ smallFound: number().int().optional(),
10025
+ smallTotal: number().int().optional()
10026
+ }).passthrough();
10027
+ var TrainingEvalReportSchema = object({
10028
+ frames: number().int(),
10029
+ classes: record(string$2(), TrainingEvalClassSchema)
10030
+ }).passthrough();
10031
+ /**
10032
+ * A succeeded result carries every block; a failed one carries the error and
10033
+ * whatever was known by then — the other blocks are ABSENT, not null. The
10034
+ * orchestrator checks the blocks it needs before it trusts a success.
10035
+ */
10036
+ var TrainingResultSchema = object({
10037
+ schema: literal(TRAINING_RESULT_SCHEMA),
10038
+ jobKey: string$2(),
10039
+ status: _enum(["succeeded", "failed"]),
10040
+ error: object({
10041
+ stage: string$2(),
10042
+ code: string$2(),
10043
+ message: string$2()
10044
+ }).nullable(),
10045
+ trainer: object({
10046
+ version: string$2(),
10047
+ revision: string$2()
10048
+ }),
10049
+ toolchain: record(string$2(), string$2().nullable()),
10050
+ dataset: object({
10051
+ versionId: string$2(),
10052
+ annotationHash: string$2(),
10053
+ sha256: string$2(),
10054
+ frames: object({
10055
+ train: number().int(),
10056
+ val: number().int(),
10057
+ holdout: number().int()
10058
+ }),
10059
+ holdoutCameras: array(number().int()),
10060
+ replayImages: number().int()
10061
+ }).optional(),
10062
+ training: object({
10063
+ epochsRun: number().int(),
10064
+ bestEpoch: number().int(),
10065
+ bestMap50: number(),
10066
+ bestMap50_95: number(),
10067
+ seconds: number()
10068
+ }).optional(),
10069
+ evaluation: object({
10070
+ holdoutFrames: number().int(),
10071
+ baseline: TrainingEvalReportSchema.nullable(),
10072
+ candidate: TrainingEvalReportSchema.nullable(),
10073
+ candidateInt8: TrainingEvalReportSchema.nullable(),
10074
+ recallDeltaByCamera: record(string$2(), record(string$2(), number())).nullable(),
10075
+ map50: record(string$2(), number().nullable())
10076
+ }).optional(),
10077
+ floors: object({
10078
+ baseline: FloorsSchema,
10079
+ candidate: FloorsSchema,
10080
+ candidateInt8: FloorsSchema.nullable(),
10081
+ notes: array(string$2())
10082
+ }).optional(),
10083
+ int8: object({
10084
+ kept: boolean(),
10085
+ map50Fp16: number().nullable(),
10086
+ map50Int8: number().nullable(),
10087
+ reason: string$2().nullable()
10088
+ }).optional(),
10089
+ exportsDropped: array(object({
10090
+ export: string$2(),
10091
+ reason: string$2()
10092
+ })).optional(),
10093
+ files: array(TrainingResultFileSchema).optional(),
10094
+ bundle: object({
10095
+ path: literal("bundle.tar"),
10096
+ bytes: number().int().nonnegative(),
10097
+ sha256: string$2().regex(/^[0-9a-f]{64}$/)
10098
+ }).nullable().optional(),
10099
+ catalogDraft: object({
10100
+ base: TrainingCatalogDraftSchema,
10101
+ int8: TrainingCatalogDraftSchema.nullable()
10102
+ }).nullable().optional(),
10103
+ licence: string$2()
10104
+ });
10105
+ var TrainingStageSchema = _enum([
10106
+ "prepare",
10107
+ "replay",
10108
+ "train",
10109
+ "eval",
10110
+ "export",
10111
+ "package"
10112
+ ]);
10113
+ var EventBase = {
10114
+ v: literal(1),
10115
+ ts: number()
10116
+ };
10117
+ discriminatedUnion("type", [
10118
+ object({
10119
+ ...EventBase,
10120
+ type: literal("stage"),
10121
+ stage: TrainingStageSchema
10122
+ }),
10123
+ object({
10124
+ ...EventBase,
10125
+ type: literal("epoch"),
10126
+ epoch: number().int(),
10127
+ epochs: number().int(),
10128
+ boxLoss: number().nullable().optional(),
10129
+ map50: number().nullable().optional(),
10130
+ map50_95: number().nullable().optional(),
10131
+ etaSec: number().nullable().optional()
10132
+ }),
10133
+ object({
10134
+ ...EventBase,
10135
+ type: literal("metric"),
10136
+ name: string$2(),
10137
+ value: number()
10138
+ }),
10139
+ object({
10140
+ ...EventBase,
10141
+ type: literal("artifact"),
10142
+ path: string$2(),
10143
+ bytes: number(),
10144
+ sha256: string$2()
10145
+ }),
10146
+ object({
10147
+ ...EventBase,
10148
+ type: literal("done"),
10149
+ status: _enum(["succeeded", "failed"]),
10150
+ resultSha256: string$2().nullable().optional()
10151
+ }),
10152
+ object({
10153
+ ...EventBase,
10154
+ type: literal("error"),
10155
+ stage: string$2(),
10156
+ code: string$2(),
10157
+ message: string$2()
10158
+ })
10159
+ ]);
10160
+ /**
9466
10161
  * What the gate decided about a birth, from the CALLER's point of view.
9467
10162
  *
9468
10163
  * Deliberately not `ConfirmationVerdict`: `undecided` is not a birth decision
@@ -11790,7 +12485,9 @@ var AddonHttpRouteSchema = object({
11790
12485
  "authenticated",
11791
12486
  "admin"
11792
12487
  ]).optional(),
11793
- description: string$2().optional()
12488
+ description: string$2().optional(),
12489
+ /** The hub limits this route per client address before the handler runs. */
12490
+ rateLimit: _enum(["auth"]).optional()
11794
12491
  });
11795
12492
  /**
11796
12493
  * Cross-process route invocation envelope. The hub captures the
@@ -12495,6 +13192,37 @@ var BackupDestinationInfoSchema = object({
12495
13192
  lastError: string$2().optional()
12496
13193
  });
12497
13194
  /**
13195
+ * How an archive is encrypted (operator decision 2026-10-09): to a backup
13196
+ * PUBLIC key the hub holds, so only the operator's secret key opens it.
13197
+ * Absent on a plain `.tar.gz` — every archive made before encryption, or
13198
+ * with it off — which restores without a key.
13199
+ */
13200
+ var BackupArchiveEncryptionSchema = object({
13201
+ /** `x25519-hkdf-aes256gcm-stream-v1`. */
13202
+ scheme: string$2(),
13203
+ /** 16 hex — the backup key whose secret restores this archive. */
13204
+ keyId: string$2()
13205
+ });
13206
+ /**
13207
+ * The backup encryption setting. The hub keeps PUBLIC keys only: the active
13208
+ * one new archives are encrypted to, and the retired ones older archives
13209
+ * still need. The secret key is shown once, at `setupEncryption`.
13210
+ */
13211
+ var BackupEncryptionStatusSchema = object({
13212
+ enabled: boolean(),
13213
+ active: object({
13214
+ keyId: string$2(),
13215
+ publicKey: string$2(),
13216
+ createdAt: number()
13217
+ }).nullable(),
13218
+ /** Every key ever set up, newest first. */
13219
+ keys: array(object({
13220
+ keyId: string$2(),
13221
+ createdAt: number(),
13222
+ retiredAt: number().nullable()
13223
+ })).readonly()
13224
+ });
13225
+ /**
12498
13226
  * Per-archive entry returned by `backup.listArchives({ destinationId })`.
12499
13227
  * Same shape the destination drill-in renders. Sourced from the per-
12500
13228
  * location `manifests.json` (no per-archive tarball read required).
@@ -12506,7 +13234,9 @@ var BackupArchiveEntrySchema = object({
12506
13234
  sizeBytes: number(),
12507
13235
  label: string$2().optional(),
12508
13236
  /** Top-level locations included in the archive (db, addons, tls, …). */
12509
- locations: array(string$2()).readonly()
13237
+ locations: array(string$2()).readonly(),
13238
+ /** Present when the archive is encrypted; restore then needs that key. */
13239
+ encryption: BackupArchiveEncryptionSchema.optional()
12510
13240
  });
12511
13241
  var BackupEntrySchema = object({
12512
13242
  id: string$2(),
@@ -12515,7 +13245,8 @@ var BackupEntrySchema = object({
12515
13245
  label: string$2().optional(),
12516
13246
  createdAt: number(),
12517
13247
  sizeBytes: number(),
12518
- locations: array(string$2()).optional()
13248
+ locations: array(string$2()).optional(),
13249
+ encryption: BackupArchiveEncryptionSchema.optional()
12519
13250
  });
12520
13251
  var ArchiveEntrySchema = object({
12521
13252
  path: string$2(),
@@ -12704,10 +13435,40 @@ method(_void(), array(BackupDestinationInfoSchema).readonly(), { auth: "admin" }
12704
13435
  * this list and skips entries whose path doesn't start with
12705
13436
  * any of them.
12706
13437
  */
12707
- locations: array(string$2()).optional()
13438
+ locations: array(string$2()).optional(),
13439
+ /**
13440
+ * The backup SECRET key, for an encrypted archive (ignored for a plain
13441
+ * one). The archive is decrypted into the hub's private staging
13442
+ * before the restart; the key is not stored. A wrong or missing key
13443
+ * is refused before the archive is downloaded.
13444
+ */
13445
+ backupSecretKey: string$2().optional()
12708
13446
  }), _void(), {
12709
13447
  kind: "mutation",
12710
13448
  auth: "admin"
13449
+ }), method(_void(), BackupEncryptionStatusSchema, { auth: "admin" }), method(object({}), object({
13450
+ keyId: string$2(),
13451
+ secretKey: string$2(),
13452
+ publicKey: string$2(),
13453
+ createdAt: number(),
13454
+ replacedKeyId: string$2().nullable()
13455
+ }), {
13456
+ kind: "mutation",
13457
+ auth: "admin"
13458
+ }), method(object({}), object({ disabledKeyId: string$2().nullable() }), {
13459
+ kind: "mutation",
13460
+ auth: "admin"
13461
+ }), method(object({ backupSecretKey: string$2() }), object({
13462
+ valid: boolean(),
13463
+ keyId: string$2().nullable(),
13464
+ /** The hub knows this key (active or retired). */
13465
+ known: boolean(),
13466
+ /** It is the key new archives are encrypted to. */
13467
+ active: boolean(),
13468
+ error: string$2().optional()
13469
+ }), {
13470
+ kind: "mutation",
13471
+ auth: "admin"
12711
13472
  }), method(object({
12712
13473
  destinationId: string$2(),
12713
13474
  backupId: string$2()
@@ -14482,7 +15243,60 @@ var CustomModelDescriptorSchema = object({
14482
15243
  stepId: string$2(),
14483
15244
  entry: ModelCatalogEntrySchema
14484
15245
  });
14485
- method(_void(), array(CustomModelDescriptorSchema).readonly(), { auth: "admin" });
15246
+ /** One regular file of an imported bundle, as the producer measured it. */
15247
+ var ModelBundleFileSchema = object({
15248
+ /** Relative path inside the bundle tar; an mlpackage member is `<x>.mlpackage/<member>`. */
15249
+ path: string$2().min(1),
15250
+ bytes: number().int().nonnegative(),
15251
+ sha256: string$2().regex(/^[0-9a-f]{64}$/)
15252
+ });
15253
+ var ImportModelBundleInputSchema = object({
15254
+ /** The registry provider that keeps the model (Model Studio). */
15255
+ addonId: string$2(),
15256
+ stepId: string$2().min(1),
15257
+ /**
15258
+ * The catalog rows to register, complete, every format URL already
15259
+ * `camstack-local://<modelId>/<file>` naming a file of the bundle. One
15260
+ * bundle may carry several rows (a base and its INT8 variant).
15261
+ */
15262
+ entries: array(ModelCatalogEntrySchema).min(1).max(4),
15263
+ /** The bundle tar, offered by the producer over `ctx.peerBytes` (same host). */
15264
+ bundle: object({
15265
+ ticket: PeerBytesTicketSchema,
15266
+ bytes: number().int().positive(),
15267
+ sha256: string$2().regex(/^[0-9a-f]{64}$/)
15268
+ }),
15269
+ /** Every file the tar must hold; anything missing, extra or different is refused. */
15270
+ files: array(ModelBundleFileSchema).min(1).max(64),
15271
+ /** Convert missing engine formats and push the model to every agent afterwards. */
15272
+ distribute: boolean()
15273
+ });
15274
+ var ImportModelBundleResultSchema = discriminatedUnion("kind", [object({
15275
+ kind: literal("imported"),
15276
+ modelIds: array(string$2()).readonly(),
15277
+ distributed: array(object({
15278
+ modelId: string$2(),
15279
+ nodeId: string$2(),
15280
+ format: _enum(MODEL_FORMATS),
15281
+ ok: boolean(),
15282
+ error: string$2().optional()
15283
+ })).readonly()
15284
+ }), object({
15285
+ kind: literal("refused"),
15286
+ reason: _enum([
15287
+ "transfer-failed",
15288
+ "checksum-mismatch",
15289
+ "bundle-mismatch",
15290
+ "invalid-entry",
15291
+ "id-taken"
15292
+ ]),
15293
+ detail: string$2()
15294
+ })]);
15295
+ method(_void(), array(CustomModelDescriptorSchema).readonly(), { auth: "admin" }), method(ImportModelBundleInputSchema, ImportModelBundleResultSchema, {
15296
+ kind: "mutation",
15297
+ auth: "admin",
15298
+ timeoutMs: 30 * 6e4
15299
+ });
14486
15300
  /**
14487
15301
  * Query filter for settings-store collections.
14488
15302
  */
@@ -14961,6 +15775,35 @@ var KeychainKeySourceSchema = object({
14961
15775
  */
14962
15776
  sharesBackupWithDatabase: boolean()
14963
15777
  });
15778
+ /**
15779
+ * One keychain reset, as the Secrets page reports it until the operator
15780
+ * acknowledges it. Never a value: refs, counts and table names only.
15781
+ */
15782
+ var KeychainResetRecordSchema = object({
15783
+ id: string$2(),
15784
+ at: number(),
15785
+ /** `user:<id>` or {@link KEYCHAIN_RESET_TRIGGER_ACTOR}. */
15786
+ actor: string$2(),
15787
+ /** Why the keychain was locked when it was reset; `null` when it was not locked. */
15788
+ lockedReason: string$2().nullable(),
15789
+ /** Values moved into the archive table (ciphertext under the lost key). */
15790
+ archived: number().int(),
15791
+ /** `keychain:secrets-orphaned-<ts>`, or `null` when nothing was stored. */
15792
+ archivedCollection: string$2().nullable(),
15793
+ /**
15794
+ * `keychain:keys-orphaned-<ts>`: the wrapped data keys of the archive, kept
15795
+ * so the archive can still be opened if the lost master key turns up.
15796
+ */
15797
+ archivedKeysCollection: string$2().nullable(),
15798
+ /**
15799
+ * `system-settings` keys whose marker the reset cleared — the cluster
15800
+ * secret's: a marker left pointing at an archived value would refuse every
15801
+ * agent forever (D797).
15802
+ */
15803
+ clearedSettingsKeys: array(string$2()).readonly(),
15804
+ /** When an operator dismissed the notice on the Secrets page; `null` until then. */
15805
+ acknowledgedAt: number().nullable()
15806
+ });
14964
15807
  var KeychainStatusSchema = object({
14965
15808
  keychain: KeychainStateSchema,
14966
15809
  /** The source of the master key in use; `null` while locked. */
@@ -14978,7 +15821,9 @@ var KeychainStatusSchema = object({
14978
15821
  /** Wrapped copies of the data key under a previous master key, kept until purged. */
14979
15822
  retiredWraps: number().int(),
14980
15823
  recoveryKeyDownloadedAt: number().nullable(),
14981
- secretCount: number().int()
15824
+ secretCount: number().int(),
15825
+ /** The most recent reset, acknowledged or not; `null` when the keychain was never reset. */
15826
+ lastReset: KeychainResetRecordSchema.nullable()
14982
15827
  });
14983
15828
  /**
14984
15829
  * Whether a stored value is still pointed at by its owner's settings.
@@ -15000,17 +15845,26 @@ var KeychainAuditActionSchema = _enum([
15000
15845
  "download-recovery-key",
15001
15846
  "delete-orphans",
15002
15847
  "reset",
15848
+ "acknowledge-reset",
15003
15849
  "initialize"
15004
15850
  ]);
15005
15851
  var KeychainAuditEntrySchema = object({
15006
15852
  id: string$2(),
15007
15853
  at: number(),
15008
15854
  action: KeychainAuditActionSchema,
15009
- /** `addon:<id>` | `user:<id>` | `system`. */
15855
+ /** `addon:<id>` | `user:<id>` | `system` | `trigger-file`. */
15010
15856
  actor: string$2(),
15011
15857
  ref: string$2().nullable(),
15012
15858
  detail: string$2().nullable()
15013
15859
  });
15860
+ var KEYCHAIN_RESET_CONFIRMATION = "RESET KEYCHAIN";
15861
+ /**
15862
+ * Secrets the HUB itself holds (owner `system`) that no settings form shows:
15863
+ * `jwt-signing-key` — the session signing key (D797). It is always "in use",
15864
+ * never an orphan; it is generated on a fresh hub and replaced only through
15865
+ * {@link keychainAdminCapability.methods.setSystemSecret}.
15866
+ */
15867
+ var SystemHeldSecretNameSchema = _enum(["jwt-signing-key"]);
15014
15868
  method(object({}), KeychainStatusSchema, { auth: "admin" }), method(object({}), array(KeychainAdminSecretSchema).readonly(), { auth: "admin" }), method(object({ limit: number().int().min(1).max(500).optional() }), array(KeychainAuditEntrySchema).readonly(), { auth: "admin" }), method(object({ ref: string$2().min(1) }), object({
15015
15869
  value: string$2(),
15016
15870
  version: number().int()
@@ -15018,6 +15872,16 @@ method(object({}), KeychainStatusSchema, { auth: "admin" }), method(object({}),
15018
15872
  kind: "mutation",
15019
15873
  auth: "admin",
15020
15874
  caller: "required"
15875
+ }), method(object({
15876
+ name: SystemHeldSecretNameSchema,
15877
+ value: string$2().min(16)
15878
+ }), object({
15879
+ ref: string$2(),
15880
+ version: number().int()
15881
+ }), {
15882
+ kind: "mutation",
15883
+ auth: "admin",
15884
+ caller: "required"
15021
15885
  }), method(object({ refs: array(string$2().min(1)).max(1e3) }), object({
15022
15886
  deleted: array(string$2()).readonly(),
15023
15887
  kept: array(object({
@@ -15047,13 +15911,20 @@ method(object({}), KeychainStatusSchema, { auth: "admin" }), method(object({}),
15047
15911
  kind: "mutation",
15048
15912
  auth: "admin",
15049
15913
  caller: "required"
15050
- }), method(object({ confirm: literal("RESET KEYCHAIN") }), object({
15914
+ }), method(object({ confirm: literal(KEYCHAIN_RESET_CONFIRMATION) }), object({
15051
15915
  archivedCollection: string$2().nullable(),
15052
15916
  archived: number().int()
15053
15917
  }), {
15054
15918
  kind: "mutation",
15055
15919
  auth: "admin",
15056
15920
  caller: "required"
15921
+ }), method(object({}), object({
15922
+ reset: KeychainResetRecordSchema.nullable(),
15923
+ pendingReentry: array(KeychainSecretMetaSchema).readonly()
15924
+ }), { auth: "admin" }), method(object({}), object({ acknowledged: boolean() }), {
15925
+ kind: "mutation",
15926
+ auth: "admin",
15927
+ caller: "required"
15057
15928
  });
15058
15929
  method(_void(), object({
15059
15930
  id: string$2(),
@@ -17904,7 +18775,7 @@ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
17904
18775
  * `login-method` — collection cap through which auth addons contribute
17905
18776
  * their pre-auth login surfaces to the login page. This is the SINGLE,
17906
18777
  * generic mechanism that supersedes the dead `auth.listProviders` reader:
17907
- * every auth addon (OIDC, magic-link, WebAuthn/passkey) registers a
18778
+ * every auth addon (OIDC, WebAuthn/passkey) registers a
17908
18779
  * `login-method` provider and the PUBLIC `auth.listLoginMethods`
17909
18780
  * procedure aggregates them for the unauthenticated login page.
17910
18781
  *
@@ -17912,8 +18783,7 @@ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
17912
18783
  *
17913
18784
  * - `redirect` — a declarative button. The login page renders a generic
17914
18785
  * button that navigates to `startUrl` (an addon-owned HTTP route).
17915
- * Covers OIDC (`/addon/auth-oidc/<id>/start`) and magic-link with
17916
- * ZERO shell-side JS. A future SSO addon plugs in the same way — the
18786
+ * Covers OIDC (`/addon/auth-oidc/<id>/start`) with ZERO shell-side JS. A future SSO addon plugs in the same way — the
17917
18787
  * login page needs NO change.
17918
18788
  *
17919
18789
  * - `widget` — a Module-Federation widget the login page mounts (via
@@ -17932,8 +18802,8 @@ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
17932
18802
  * decision.
17933
18803
  *
17934
18804
  * Every contribution carries a `stage`:
17935
- * - `primary` — shown on the first credentials screen (OIDC /
17936
- * magic-link buttons; a future usernameless passkey).
18805
+ * - `primary` — shown on the first credentials screen (OIDC
18806
+ * buttons; a usernameless passkey).
17937
18807
  * - `second-factor` — shown AFTER the password leg, gated on the
17938
18808
  * returned `factors` (passkey-as-2FA today).
17939
18809
  *
@@ -17960,7 +18830,7 @@ var LoginMethodContributionSchema = discriminatedUnion("kind", [
17960
18830
  * The provider names an external identity a signed-in user can link to
17961
18831
  * their own account (D782): `auth.listLinkableProviders` /
17962
18832
  * `beginExternalLink` offer exactly the redirect methods that set this,
17963
- * whatever their id. Absent / false — a login button only (magic-link).
18833
+ * whatever their id. Absent / false — a login button only.
17964
18834
  */
17965
18835
  linkable: boolean().optional()
17966
18836
  }),
@@ -21815,8 +22685,7 @@ method(object({}), object({ rules: array(NcRuleSchema) }), { auth: "admin" }), m
21815
22685
  * `super_admin` — collapsed onto the single boolean because every
21816
22686
  * non-admin caller is governed by the same scope-check rules; the
21817
22687
  * distinction was only ever used to route role-specific procedures
21818
- * which we no longer have. Agents are admin sessions issued via
21819
- * `createServiceToken`; CLI / webhook integrations are `cst_*` tokens
22688
+ * which we no longer have. CLI / webhook integrations are `cst_*` tokens
21820
22689
  * with `isAdmin: false` + an explicit scope list.
21821
22690
  */
21822
22691
  /** Per-method access flavour. Materialised on every cap method via codegen. */
@@ -23491,6 +24360,9 @@ var RetrainExportFilterSchema = object({
23491
24360
  frameIds: array(string$2()).max(2e4).optional(),
23492
24361
  /** Only frames in at least one of these named collections. */
23493
24362
  collectionIds: array(string$2()).max(200).optional(),
24363
+ /** Exactly the frames of this dataset version (and its completeOnly). An
24364
+ * unknown id selects nothing. */
24365
+ datasetVersionId: string$2().optional(),
23494
24366
  batchId: string$2().optional(),
23495
24367
  /** Only frames the operator marked complete (all subjects boxed). */
23496
24368
  completeOnly: boolean().optional()
@@ -23658,6 +24530,67 @@ var RetrainLlmAssistResultSchema = discriminatedUnion("kind", [object({
23658
24530
  ]),
23659
24531
  detail: string$2().optional()
23660
24532
  })]);
24533
+ /** What a dataset version is cut from. Every field narrows. */
24534
+ var RetrainDatasetSelectionSchema = object({
24535
+ deviceIds: array(number()).readonly().optional(),
24536
+ collectionIds: array(string$2()).max(200).readonly().optional(),
24537
+ frameIds: array(string$2()).max(2e4).readonly().optional()
24538
+ });
24539
+ /** The counts a dataset is judged by. */
24540
+ var RetrainDatasetStatsSchema = object({
24541
+ frames: number().int(),
24542
+ completeFrames: number().int(),
24543
+ /** `completeFrames / frames`, 0..1. */
24544
+ completeness: number(),
24545
+ /** Boxes to learn (model errors excluded). */
24546
+ subjects: number().int(),
24547
+ modelErrors: number().int(),
24548
+ /** Complete frames with no subject. */
24549
+ hardNegatives: number().int(),
24550
+ /** Subjects per class × camera × day/night. */
24551
+ cells: array(object({
24552
+ macroClass: string$2(),
24553
+ deviceId: number(),
24554
+ lighting: _enum([
24555
+ "day",
24556
+ "night",
24557
+ "unknown"
24558
+ ]),
24559
+ subjects: number().int(),
24560
+ frames: number().int()
24561
+ })).readonly(),
24562
+ cameras: array(object({
24563
+ deviceId: number(),
24564
+ frames: number().int(),
24565
+ completeFrames: number().int()
24566
+ })).readonly()
24567
+ });
24568
+ /** An immutable dataset version, without its frame list. */
24569
+ var RetrainDatasetVersionSchema = object({
24570
+ id: string$2(),
24571
+ name: string$2(),
24572
+ createdAt: number(),
24573
+ selection: RetrainDatasetSelectionSchema,
24574
+ layout: RetrainExportLayoutSchema,
24575
+ completeOnly: boolean(),
24576
+ frameCount: number().int(),
24577
+ /** sha256 of what the frames taught when the version was frozen. */
24578
+ annotationHash: string$2(),
24579
+ /** The export manifest schema the version was cut under. */
24580
+ manifestSchema: string$2(),
24581
+ stats: RetrainDatasetStatsSchema
24582
+ });
24583
+ var CreateRetrainDatasetVersionResultSchema = discriminatedUnion("kind", [object({
24584
+ kind: literal("created"),
24585
+ version: RetrainDatasetVersionSchema
24586
+ }), object({
24587
+ kind: literal("refused"),
24588
+ reason: _enum([
24589
+ "empty-name",
24590
+ "duplicate-name",
24591
+ "no-frames"
24592
+ ])
24593
+ })]);
23661
24594
  /** The outcome of a lifecycle move owned by the retrain page. */
23662
24595
  var RetrainTransitionResultSchema = object({
23663
24596
  trackId: string$2(),
@@ -24447,6 +25380,47 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
24447
25380
  kind: "mutation",
24448
25381
  auth: "admin",
24449
25382
  timeoutMs: 60 * 6e4
25383
+ }), method(object({
25384
+ filter: RetrainExportFilterSchema,
25385
+ layout: RetrainExportLayoutSchema
25386
+ }), object({
25387
+ ticket: PeerBytesTicketSchema,
25388
+ frames: number().int(),
25389
+ annotations: number().int()
25390
+ }), {
25391
+ kind: "mutation",
25392
+ auth: "admin",
25393
+ timeoutMs: 12e4
25394
+ }), method(object({
25395
+ selection: RetrainDatasetSelectionSchema,
25396
+ completeOnly: boolean().optional()
25397
+ }), RetrainDatasetStatsSchema, {
25398
+ kind: "query",
25399
+ auth: "admin"
25400
+ }), method(object({
25401
+ name: string$2().max(120),
25402
+ selection: RetrainDatasetSelectionSchema,
25403
+ layout: RetrainExportLayoutSchema,
25404
+ completeOnly: boolean()
25405
+ }), CreateRetrainDatasetVersionResultSchema, {
25406
+ kind: "mutation",
25407
+ auth: "admin",
25408
+ timeoutMs: 12e4
25409
+ }), method(object({}), array(RetrainDatasetVersionSchema).readonly(), {
25410
+ kind: "query",
25411
+ auth: "admin"
25412
+ }), method(object({ id: string$2() }), object({ deleted: boolean() }), {
25413
+ kind: "mutation",
25414
+ auth: "admin"
25415
+ }), method(object({ id: string$2() }), object({
25416
+ found: boolean(),
25417
+ annotationHash: string$2(),
25418
+ matches: boolean(),
25419
+ missingFrames: number().int()
25420
+ }), {
25421
+ kind: "query",
25422
+ auth: "admin",
25423
+ timeoutMs: 12e4
24450
25424
  }), method(object({}), array(RetrainAssistProfileSchema).readonly(), {
24451
25425
  kind: "query",
24452
25426
  auth: "admin"
@@ -28025,8 +28999,8 @@ version: string$2().optional() }), ServerUpdateActionResultSchema, {
28025
28999
  * `smtp-provider` — pluggable email delivery surface.
28026
29000
  *
28027
29001
  * Collection cap: a deployment may install multiple SMTP relays (e.g.
28028
- * one for transactional / one for notifications). Consumers (magic-link,
28029
- * notifier addons, …) walk the collection and pick the first
29002
+ * one for transactional / one for notifications). Consumers (notifier
29003
+ * addons, …) walk the collection and pick the first
28030
29004
  * ready provider OR target a specific addonId.
28031
29005
  *
28032
29006
  * The shape stays small on purpose — `sendEmail` is enough for the
@@ -28205,7 +29179,7 @@ targets: array(object({
28205
29179
  })));
28206
29180
  /**
28207
29181
  * `sso-bridge` — internal hub-only cap that lets SSO-style auth
28208
- * providers (OIDC, SAML, magic-link, …) mint an HMAC-signed token
29182
+ * providers (OIDC, SAML, …) mint an HMAC-signed token
28209
29183
  * carrying the post-callback claims before redirecting back to
28210
29184
  * `/api/auth/sso/finish`.
28211
29185
  *
@@ -28268,7 +29242,14 @@ var SsoBridgeClaimsSchema = object({
28268
29242
  * Verified `iss` of the id_token behind an OIDC login bridge (D782). A
28269
29243
  * subject is unique only per issuer, so a link is bound to it.
28270
29244
  */
28271
- issuer: string$2().optional()
29245
+ issuer: string$2().optional(),
29246
+ /**
29247
+ * SHA-256 (hex) of the `camstack_sso_state` cookie the IdP `/start` set in
29248
+ * the browser that began this sign-in. `/api/auth/sso/finish` requires the
29249
+ * request to present the matching cookie — a login bridge is useless in
29250
+ * any other browser.
29251
+ */
29252
+ browserBinding: string$2().optional()
28272
29253
  });
28273
29254
  method(object({
28274
29255
  claims: SsoBridgeClaimsSchema,
@@ -40544,16 +41525,6 @@ var ApiKeySummarySchema = object({
40544
41525
  createdAt: number(),
40545
41526
  lastUsedAt: number().optional()
40546
41527
  });
40547
- var CreateApiKeyInputSchema = object({
40548
- label: string$2(),
40549
- isAdmin: boolean().default(false),
40550
- allowedProviders: union([array(string$2()), literal("*")]).optional(),
40551
- allowedDevices: record(string$2(), union([array(string$2()), literal("*")])).optional()
40552
- });
40553
- var CreateApiKeyResultSchema = object({
40554
- token: string$2(),
40555
- record: ApiKeySummarySchema
40556
- });
40557
41528
  var ScopedTokenSummarySchema = object({
40558
41529
  id: string$2(),
40559
41530
  userId: string$2(),
@@ -40652,17 +41623,10 @@ method(_void(), array(UserSummarySchema), { auth: "admin" }), method(CreateUserI
40652
41623
  }), UserSummarySchema.extend({ passwordHash: string$2() }).nullable(), {
40653
41624
  kind: "mutation",
40654
41625
  access: "view"
40655
- }), method(_void(), array(ApiKeySummarySchema), { auth: "admin" }), method(CreateApiKeyInputSchema, CreateApiKeyResultSchema, {
40656
- kind: "mutation",
40657
- auth: "admin",
40658
- access: "create"
40659
- }), method(object({ id: string$2() }), object({ success: literal(true) }), {
41626
+ }), method(_void(), array(ApiKeySummarySchema), { auth: "admin" }), method(object({ id: string$2() }), object({ success: literal(true) }), {
40660
41627
  kind: "mutation",
40661
41628
  auth: "admin",
40662
41629
  access: "delete"
40663
- }), method(object({ token: string$2() }), ApiKeySummarySchema.nullable(), {
40664
- kind: "mutation",
40665
- access: "view"
40666
41630
  }), method(CreateScopedTokenInputSchema, CreateScopedTokenResultSchema, {
40667
41631
  kind: "mutation",
40668
41632
  auth: "admin",
@@ -40736,15 +41700,7 @@ method(_void(), array(UserSummarySchema), { auth: "admin" }), method(CreateUserI
40736
41700
  }).nullable(), { access: "view" }), method(object({ userId: string$2() }), array(ExternalIdentitySchema), { auth: "admin" }), method(ExternalIdentityKeySchema, object({
40737
41701
  userId: string$2(),
40738
41702
  issuer: string$2()
40739
- }).nullable(), { auth: "admin" }), method(ExternalIdentityKeySchema.extend({
40740
- userId: string$2(),
40741
- issuer: string$2().min(1),
40742
- label: string$2().optional()
40743
- }), object({ success: literal(true) }), {
40744
- kind: "mutation",
40745
- auth: "admin",
40746
- access: "create"
40747
- }), method(ExternalIdentityKeySchema.extend({ userId: string$2() }), object({ success: boolean() }), {
41703
+ }).nullable(), { auth: "admin" }), method(ExternalIdentityKeySchema.extend({ userId: string$2() }), object({ success: boolean() }), {
40748
41704
  kind: "mutation",
40749
41705
  auth: "admin",
40750
41706
  access: "delete"
@@ -41449,6 +42405,451 @@ var zoneRulesCapability = {
41449
42405
  */
41450
42406
  durability: "restored"
41451
42407
  };
42408
+ /**
42409
+ * `training-provider` — ONE cloud that can run the CamStack trainer.
42410
+ *
42411
+ * A thin, mockable translation layer: it knows how to run a container with a
42412
+ * GPU, move a dataset in, read the job's stdout and hand artefacts back. It
42413
+ * knows nothing about datasets, splits, floors, cost policy or Model Studio —
42414
+ * those are the `training` orchestrator's (D805). Every rule written there
42415
+ * once is what makes a second provider (RunPod, a local NVIDIA node) a new
42416
+ * manifest entry and nothing else.
42417
+ *
42418
+ * Collection, routed by the `addonId` in every single-row input (the `llm` /
42419
+ * `notification-output` posture); `describe` concat-fans across providers.
42420
+ * Every method is `admin`: these spend money.
42421
+ *
42422
+ * Every cloud object a provider creates is tagged with the orchestrator's
42423
+ * `jobKey`, so a retried submit finds the job it already started instead of
42424
+ * starting a second GPU, and `listJobs` can find orphans.
42425
+ *
42426
+ * Bytes never ride a cap field: the dataset arrives as a `ctx.peerBytes`
42427
+ * ticket the producer (pipeline-analytics) minted, and artefacts leave as a
42428
+ * ticket the provider mints (D613).
42429
+ */
42430
+ var TrainingGpuOptionSchema = object({
42431
+ id: string$2(),
42432
+ label: string$2(),
42433
+ /** List price, USD per GPU-hour, before any region multiplier. */
42434
+ usdPerHour: number().nonnegative(),
42435
+ vramGb: number().nonnegative()
42436
+ });
42437
+ var TrainingRegionOptionSchema = object({
42438
+ /** `''` = any region (the provider's choice). */
42439
+ id: string$2(),
42440
+ label: string$2(),
42441
+ priceMultiplier: number().positive()
42442
+ });
42443
+ /**
42444
+ * The provider's per-account settings, as the orchestrator reads them. They
42445
+ * live in the PROVIDER addon's settings (operator decision 2026-10-08: they
42446
+ * depend on the user's account), never hard-coded in the orchestrator.
42447
+ */
42448
+ var TrainingProviderDefaultsSchema = object({
42449
+ gpuType: string$2(),
42450
+ region: string$2(),
42451
+ costCapUsd: number().nonnegative(),
42452
+ maxRuntimeSec: number().int().positive(),
42453
+ /** Hours a FAILED job's cloud dataset is kept for debugging; 0 = delete at once. */
42454
+ failedDatasetGraceHours: number().nonnegative()
42455
+ });
42456
+ var TrainingProviderDescriptorSchema = object({
42457
+ addonId: string$2(),
42458
+ /** `modal`, `runpod`, `fake`, … */
42459
+ kind: string$2(),
42460
+ label: string$2(),
42461
+ gpuTypes: array(TrainingGpuOptionSchema).readonly(),
42462
+ regions: array(TrainingRegionOptionSchema).readonly(),
42463
+ maxDatasetBytes: number().int().positive(),
42464
+ maxRuntimeSec: number().int().positive(),
42465
+ freeTierNote: string$2().optional(),
42466
+ /** Where the data goes, in one sentence the confirm dialog repeats. */
42467
+ dataResidencyNote: string$2(),
42468
+ /** Credentials are present — never the values. */
42469
+ configured: boolean(),
42470
+ defaults: TrainingProviderDefaultsSchema
42471
+ });
42472
+ var TrainingCredentialCheckSchema = object({
42473
+ ok: boolean(),
42474
+ /** Workspace / account name, when the provider says. */
42475
+ account: string$2().optional(),
42476
+ reason: _enum([
42477
+ "missing",
42478
+ "invalid",
42479
+ "forbidden",
42480
+ "network",
42481
+ "quota"
42482
+ ]).optional(),
42483
+ detail: string$2().optional()
42484
+ });
42485
+ var ProviderJobStateSchema = _enum([
42486
+ "pending",
42487
+ "starting",
42488
+ "running",
42489
+ "succeeded",
42490
+ "failed",
42491
+ "cancelled",
42492
+ "lost"
42493
+ ]);
42494
+ var ProviderJobStatusSchema = object({
42495
+ jobKey: string$2(),
42496
+ providerJobId: string$2().optional(),
42497
+ state: ProviderJobStateSchema,
42498
+ startedAt: number().optional(),
42499
+ endedAt: number().optional(),
42500
+ exitCode: number().int().optional(),
42501
+ failureReason: string$2().optional(),
42502
+ gpuType: string$2(),
42503
+ region: string$2().optional(),
42504
+ billedSeconds: number().nonnegative(),
42505
+ costUsd: number().nonnegative(),
42506
+ /** True when `costUsd` is runtime × list price, not a billing answer. */
42507
+ costIsEstimate: boolean(),
42508
+ lastFetchedAt: number()
42509
+ });
42510
+ /**
42511
+ * The trainer the job runs, by SOURCE revision: the provider turns it into an
42512
+ * image its own way (Modal builds the published Dockerfile at that revision;
42513
+ * a registry-pull provider maps it to a tag). Recorded on the job and echoed
42514
+ * in `result.json`.
42515
+ */
42516
+ var TrainerSourceRefSchema = object({
42517
+ /** Hugging Face repo id, e.g. `camstack/camstack-trainer`. */
42518
+ repo: string$2().min(1),
42519
+ /** A commit sha (never a branch) — the job must be reproducible. */
42520
+ revision: string$2().regex(/^[0-9a-f]{7,64}$/)
42521
+ });
42522
+ var JobRef = {
42523
+ addonId: string$2(),
42524
+ jobKey: string$2().uuid()
42525
+ };
42526
+ var TrainingLogLineSchema = object({
42527
+ ts: number(),
42528
+ text: string$2()
42529
+ });
42530
+ method(object({}), array(TrainingProviderDescriptorSchema).readonly(), { auth: "admin" }), method(object({ addonId: string$2() }), TrainingCredentialCheckSchema, {
42531
+ kind: "mutation",
42532
+ auth: "admin",
42533
+ timeoutMs: 3e4
42534
+ }), method(object({
42535
+ addonId: string$2(),
42536
+ gpuType: string$2(),
42537
+ region: string$2(),
42538
+ datasetBytes: number().int().nonnegative(),
42539
+ gpuSecondsLow: number().nonnegative(),
42540
+ gpuSecondsHigh: number().nonnegative()
42541
+ }), object({
42542
+ usdLow: number().nonnegative(),
42543
+ usdHigh: number().nonnegative(),
42544
+ notes: array(string$2()).readonly()
42545
+ }), { auth: "admin" }), method(object({
42546
+ ...JobRef,
42547
+ ticket: PeerBytesTicketSchema
42548
+ }), object({
42549
+ bytes: number().int().nonnegative(),
42550
+ sha256: string$2()
42551
+ }), {
42552
+ kind: "mutation",
42553
+ auth: "admin",
42554
+ timeoutMs: 120 * 6e4
42555
+ }), method(object({
42556
+ ...JobRef,
42557
+ trainer: TrainerSourceRefSchema,
42558
+ jobSpecJson: string$2().min(2).max(64e3),
42559
+ gpuType: string$2(),
42560
+ region: string$2(),
42561
+ maxRuntimeSec: number().int().positive()
42562
+ }), ProviderJobStatusSchema, {
42563
+ kind: "mutation",
42564
+ auth: "admin",
42565
+ timeoutMs: 30 * 6e4
42566
+ }), method(object(JobRef), ProviderJobStatusSchema, {
42567
+ auth: "admin",
42568
+ timeoutMs: 6e4
42569
+ }), method(object({
42570
+ ...JobRef,
42571
+ cursor: string$2().optional(),
42572
+ max: number().int().min(1).max(500)
42573
+ }), object({
42574
+ lines: array(TrainingLogLineSchema).readonly(),
42575
+ cursor: string$2()
42576
+ }), {
42577
+ auth: "admin",
42578
+ timeoutMs: 6e4
42579
+ }), method(object(JobRef), object({ ok: literal(true) }), {
42580
+ kind: "mutation",
42581
+ auth: "admin",
42582
+ timeoutMs: 6e4
42583
+ }), method(object(JobRef), object({
42584
+ found: boolean(),
42585
+ text: string$2().optional()
42586
+ }), {
42587
+ kind: "mutation",
42588
+ auth: "admin",
42589
+ timeoutMs: 5 * 6e4
42590
+ }), method(object({
42591
+ ...JobRef,
42592
+ path: _enum(["bundle.tar"])
42593
+ }), object({ ticket: PeerBytesTicketSchema }), {
42594
+ kind: "mutation",
42595
+ auth: "admin",
42596
+ timeoutMs: 5 * 6e4
42597
+ }), method(object(JobRef), object({ deleted: array(string$2()).readonly() }), {
42598
+ kind: "mutation",
42599
+ auth: "admin",
42600
+ timeoutMs: 5 * 6e4
42601
+ }), method(object({ addonId: string$2() }), array(ProviderJobStatusSchema).readonly(), {
42602
+ auth: "admin",
42603
+ timeoutMs: 2 * 6e4
42604
+ });
42605
+ /**
42606
+ * `training` — the cloud-training orchestrator (D805). Hub-only singleton,
42607
+ * provided by `addon-training`.
42608
+ *
42609
+ * It owns what every provider must agree on, written once:
42610
+ *
42611
+ * - **Dataset versions.** Taken over from pipeline-analytics (D796): the rows
42612
+ * live here (D808); pipeline-analytics still CUTS a version (it owns the corpus and
42613
+ * the export plan) and reaches this store through the five row methods
42614
+ * below, so the Retrain page and the export did not change.
42615
+ * - **Jobs.** A persisted state machine, a reconcile loop against the
42616
+ * provider, a cost guard, a daily orphan sweep and the retention rules.
42617
+ * - **The return flow.** Verified artefacts → Model Studio
42618
+ * (`custom-model-registry.importModelBundle`) → canary on cameras →
42619
+ * rollback. Nothing is ever registered automatically.
42620
+ *
42621
+ * Every method is `admin`.
42622
+ */
42623
+ /** A version WITH its frame list — what the export and a job read. */
42624
+ var TrainingDatasetVersionRowSchema = RetrainDatasetVersionSchema.omit({ frameCount: true }).extend({ frameIds: array(string$2()).max(2e4).readonly() });
42625
+ /** A base model a detector job can fine-tune, and the baseline it is judged against. */
42626
+ var TrainingBaseModelSchema = object({
42627
+ modelId: string$2(),
42628
+ label: string$2(),
42629
+ weights: string$2(),
42630
+ imgsz: number().int(),
42631
+ baselineOnnxUrl: string$2(),
42632
+ baselineFloors: record(string$2(), number()),
42633
+ /** The base the fleet runs most — the UI's default. */
42634
+ recommended: boolean()
42635
+ });
42636
+ var TrainingPresetSchema = _enum([
42637
+ "quick",
42638
+ "standard",
42639
+ "thorough"
42640
+ ]);
42641
+ var TrainingJobRequestSchema = object({
42642
+ datasetVersionId: string$2().min(1),
42643
+ /** The `training-provider` addon that runs it. */
42644
+ addonId: string$2().min(1),
42645
+ gpuType: string$2().min(1),
42646
+ region: string$2(),
42647
+ baseModelId: string$2().min(1),
42648
+ preset: TrainingPresetSchema,
42649
+ /** Freeze the backbone's first N layers; `null` = the preset's choice. */
42650
+ freeze: number().int().nonnegative().nullable(),
42651
+ /** Cameras held out whole for evaluation; `null` = the orchestrator's default. */
42652
+ holdoutCameras: array(number().int()).nullable()
42653
+ });
42654
+ var TrainingSplitPlanSchema = object({
42655
+ holdoutCameras: array(number().int()).readonly(),
42656
+ /** Used when no camera is held out: the last N days of every camera. */
42657
+ holdoutLastDays: number().int().nonnegative(),
42658
+ /** Holdout subjects per class (camera holdout only; `null` = known only after the split). */
42659
+ holdoutSupport: record(string$2(), number().int()).nullable(),
42660
+ trainSubjects: number().int()
42661
+ });
42662
+ var TrainingRefusalReasonSchema = _enum([
42663
+ "unknown-dataset",
42664
+ "unknown-provider",
42665
+ "provider-not-configured",
42666
+ "unknown-base-model",
42667
+ "unknown-gpu",
42668
+ "dataset-too-large",
42669
+ "no-training-subjects",
42670
+ "job-already-running"
42671
+ ]);
42672
+ var TrainingJobPlanSchema = object({
42673
+ refusal: object({
42674
+ reason: TrainingRefusalReasonSchema,
42675
+ detail: string$2()
42676
+ }).nullable(),
42677
+ warnings: array(string$2()).readonly(),
42678
+ split: TrainingSplitPlanSchema.nullable(),
42679
+ estimate: object({
42680
+ datasetBytes: number().int(),
42681
+ uploadMinutesAt20Mbps: number(),
42682
+ gpuSecondsLow: number(),
42683
+ gpuSecondsHigh: number(),
42684
+ usdLow: number(),
42685
+ usdHigh: number(),
42686
+ notes: array(string$2()).readonly()
42687
+ }).nullable(),
42688
+ /** Pre-filled from the provider's settings; the operator may lower or raise them. */
42689
+ defaults: object({
42690
+ maxCostUsd: number(),
42691
+ maxRuntimeSec: number().int()
42692
+ }).nullable(),
42693
+ /** The sentence the confirm dialog repeats: where the frames go and when they are deleted. */
42694
+ dataNotice: string$2()
42695
+ });
42696
+ /**
42697
+ * Orchestrator-owned states, persisted. `uploading` covers exporting the
42698
+ * archive (it is streamed, never staged). Terminal: `failed`, `cancelled`,
42699
+ * `lost`, `expired`, `discarded`. `registered` and `canary` are where a
42700
+ * result lives after the operator acted on it.
42701
+ */
42702
+ var TrainingJobStateSchema = _enum([
42703
+ "uploading",
42704
+ "submitted",
42705
+ "starting",
42706
+ "running",
42707
+ "collecting",
42708
+ "ready",
42709
+ "registered",
42710
+ "canary",
42711
+ "failed",
42712
+ "cancelling",
42713
+ "cancelled",
42714
+ "lost",
42715
+ "expired",
42716
+ "discarded"
42717
+ ]);
42718
+ var TrainingFailureReasonSchema = _enum([
42719
+ "cost-cap",
42720
+ "runtime-cap",
42721
+ "upload-failed",
42722
+ "submit-failed",
42723
+ "trainer-failed",
42724
+ "result-invalid",
42725
+ "checksum-mismatch",
42726
+ "fetch-failed",
42727
+ "provider-error",
42728
+ "hub-restart-during-upload"
42729
+ ]);
42730
+ var TrainingProgressPointSchema = object({
42731
+ epoch: number().int(),
42732
+ map50: number().nullable(),
42733
+ map50_95: number().nullable()
42734
+ });
42735
+ var TrainingCanarySchema = object({
42736
+ deviceIds: array(number().int()).readonly(),
42737
+ since: number(),
42738
+ /** Every override the canary replaced, exactly, so rollback restores it. */
42739
+ previous: array(object({
42740
+ deviceId: number().int(),
42741
+ nodeId: string$2(),
42742
+ deviceKey: string$2(),
42743
+ patch: object({
42744
+ modelId: string$2().optional(),
42745
+ settings: record(string$2(), unknown()).readonly().optional()
42746
+ }).nullable()
42747
+ })).readonly()
42748
+ });
42749
+ var TrainingJobSchema = object({
42750
+ id: string$2(),
42751
+ idempotencyKey: string$2(),
42752
+ name: string$2(),
42753
+ createdAt: number(),
42754
+ updatedAt: number(),
42755
+ state: TrainingJobStateSchema,
42756
+ stage: TrainingStageSchema.nullable(),
42757
+ failure: object({
42758
+ reason: TrainingFailureReasonSchema,
42759
+ stage: string$2().nullable(),
42760
+ detail: string$2()
42761
+ }).nullable(),
42762
+ request: TrainingJobRequestSchema,
42763
+ maxCostUsd: number().nonnegative(),
42764
+ maxRuntimeSec: number().int().positive(),
42765
+ trainer: TrainerSourceRefSchema,
42766
+ datasetLayout: RetrainExportLayoutSchema,
42767
+ dataset: object({
42768
+ bytes: number().int(),
42769
+ sha256: string$2(),
42770
+ uploadedAt: number()
42771
+ }).nullable(),
42772
+ split: TrainingSplitPlanSchema,
42773
+ provider: object({
42774
+ state: ProviderJobStateSchema.nullable(),
42775
+ providerJobId: string$2().nullable(),
42776
+ startedAt: number().nullable(),
42777
+ endedAt: number().nullable(),
42778
+ billedSeconds: number(),
42779
+ costUsd: number(),
42780
+ costIsEstimate: boolean(),
42781
+ lastPolledAt: number().nullable()
42782
+ }),
42783
+ progress: object({
42784
+ epoch: number().int().nullable(),
42785
+ epochs: number().int().nullable(),
42786
+ etaSec: number().nullable(),
42787
+ series: array(TrainingProgressPointSchema).readonly()
42788
+ }),
42789
+ /** The last lines of the job's output (≤ 200), newest last. Never frame paths. */
42790
+ logTail: array(string$2()).readonly(),
42791
+ logCursor: string$2().nullable(),
42792
+ artifacts: object({
42793
+ bundleBytes: number().int(),
42794
+ bundleSha256: string$2(),
42795
+ fetchedAt: number(),
42796
+ /** When the staged artefacts are deleted from the hub. */
42797
+ expiresAt: number()
42798
+ }).nullable(),
42799
+ /** When the provider-side copy of the frames was deleted; null while it exists. */
42800
+ cloudDatasetDeletedAt: number().nullable(),
42801
+ /** A failed job's dataset is kept until then (the provider's grace), then deleted. */
42802
+ cloudCleanupDueAt: number().nullable(),
42803
+ /** Model ids registered from this job (base, and int8 when kept). */
42804
+ registeredModelIds: array(string$2()).readonly(),
42805
+ canary: TrainingCanarySchema.nullable()
42806
+ });
42807
+ var IdInput = object({ id: string$2().min(1) });
42808
+ method(TrainingDatasetVersionRowSchema, object({ stored: boolean() }), {
42809
+ kind: "mutation",
42810
+ auth: "admin"
42811
+ }), method(IdInput, TrainingDatasetVersionRowSchema.nullable(), { auth: "admin" }), method(object({}), array(RetrainDatasetVersionSchema).readonly(), { auth: "admin" }), method(object({ name: string$2() }), object({ id: string$2().nullable() }), { auth: "admin" }), method(IdInput, object({ removed: boolean() }), {
42812
+ kind: "mutation",
42813
+ auth: "admin"
42814
+ }), method(object({}), array(TrainingBaseModelSchema).readonly(), { auth: "admin" }), method(TrainingJobRequestSchema, TrainingJobPlanSchema, {
42815
+ auth: "admin",
42816
+ timeoutMs: 6e4
42817
+ }), method(TrainingJobRequestSchema.extend({
42818
+ name: string$2().min(1).max(120),
42819
+ maxCostUsd: number().positive(),
42820
+ maxRuntimeSec: number().int().positive(),
42821
+ idempotencyKey: string$2().min(8).max(80)
42822
+ }), discriminatedUnion("kind", [object({
42823
+ kind: literal("started"),
42824
+ job: TrainingJobSchema
42825
+ }), object({
42826
+ kind: literal("refused"),
42827
+ reason: TrainingRefusalReasonSchema,
42828
+ detail: string$2()
42829
+ })]), {
42830
+ kind: "mutation",
42831
+ auth: "admin",
42832
+ timeoutMs: 12e4
42833
+ }), method(object({}), array(TrainingJobSchema).readonly(), { auth: "admin" }), method(IdInput, TrainingJobSchema.nullable(), { auth: "admin" }), method(IdInput, TrainingJobSchema, {
42834
+ kind: "mutation",
42835
+ auth: "admin",
42836
+ timeoutMs: 12e4
42837
+ }), method(IdInput, TrainingResultSchema.nullable(), { auth: "admin" }), method(IdInput.extend({ canaryDeviceIds: array(number().int()).readonly() }), TrainingJobSchema, {
42838
+ kind: "mutation",
42839
+ auth: "admin",
42840
+ timeoutMs: 30 * 6e4
42841
+ }), method(IdInput.extend({ deviceIds: array(number().int()).min(1).readonly() }), TrainingJobSchema, {
42842
+ kind: "mutation",
42843
+ auth: "admin",
42844
+ timeoutMs: 12e4
42845
+ }), method(IdInput, TrainingJobSchema, {
42846
+ kind: "mutation",
42847
+ auth: "admin",
42848
+ timeoutMs: 12e4
42849
+ }), method(IdInput, TrainingJobSchema, {
42850
+ kind: "mutation",
42851
+ auth: "admin"
42852
+ });
41452
42853
  SOURCE_CAPS.filter((cap) => cap !== "switch" && cap !== "motion");
41453
42854
  Object.freeze({
41454
42855
  person: .5,
@@ -43597,6 +44998,12 @@ Object.freeze({
43597
44998
  addonId: null,
43598
44999
  access: "create"
43599
45000
  },
45001
+ "backup.checkBackupKey": {
45002
+ capName: "backup",
45003
+ capScope: "system",
45004
+ addonId: null,
45005
+ access: "create"
45006
+ },
43600
45007
  "backup.delete": {
43601
45008
  capName: "backup",
43602
45009
  capScope: "system",
@@ -43609,6 +45016,18 @@ Object.freeze({
43609
45016
  addonId: null,
43610
45017
  access: "delete"
43611
45018
  },
45019
+ "backup.disableEncryption": {
45020
+ capName: "backup",
45021
+ capScope: "system",
45022
+ addonId: null,
45023
+ access: "create"
45024
+ },
45025
+ "backup.getEncryption": {
45026
+ capName: "backup",
45027
+ capScope: "system",
45028
+ addonId: null,
45029
+ access: "view"
45030
+ },
43612
45031
  "backup.getEntries": {
43613
45032
  capName: "backup",
43614
45033
  capScope: "system",
@@ -43663,6 +45082,12 @@ Object.freeze({
43663
45082
  addonId: null,
43664
45083
  access: "create"
43665
45084
  },
45085
+ "backup.setupEncryption": {
45086
+ capName: "backup",
45087
+ capScope: "system",
45088
+ addonId: null,
45089
+ access: "create"
45090
+ },
43666
45091
  "backup.trigger": {
43667
45092
  capName: "backup",
43668
45093
  capScope: "system",
@@ -44215,6 +45640,12 @@ Object.freeze({
44215
45640
  addonId: null,
44216
45641
  access: "create"
44217
45642
  },
45643
+ "customModelRegistry.importModelBundle": {
45644
+ capName: "custom-model-registry",
45645
+ capScope: "system",
45646
+ addonId: null,
45647
+ access: "create"
45648
+ },
44218
45649
  "customModelRegistry.listModels": {
44219
45650
  capName: "custom-model-registry",
44220
45651
  capScope: "system",
@@ -45655,6 +47086,12 @@ Object.freeze({
45655
47086
  addonId: null,
45656
47087
  access: "view"
45657
47088
  },
47089
+ "keychainAdmin.acknowledgeReset": {
47090
+ capName: "keychain-admin",
47091
+ capScope: "system",
47092
+ addonId: null,
47093
+ access: "create"
47094
+ },
45658
47095
  "keychainAdmin.deleteOrphans": {
45659
47096
  capName: "keychain-admin",
45660
47097
  capScope: "system",
@@ -45691,6 +47128,12 @@ Object.freeze({
45691
47128
  addonId: null,
45692
47129
  access: "delete"
45693
47130
  },
47131
+ "keychainAdmin.resetReport": {
47132
+ capName: "keychain-admin",
47133
+ capScope: "system",
47134
+ addonId: null,
47135
+ access: "delete"
47136
+ },
45694
47137
  "keychainAdmin.reveal": {
45695
47138
  capName: "keychain-admin",
45696
47139
  capScope: "system",
@@ -45703,6 +47146,12 @@ Object.freeze({
45703
47146
  addonId: null,
45704
47147
  access: "create"
45705
47148
  },
47149
+ "keychainAdmin.setSystemSecret": {
47150
+ capName: "keychain-admin",
47151
+ capScope: "system",
47152
+ addonId: null,
47153
+ access: "create"
47154
+ },
45706
47155
  "keychainAdmin.status": {
45707
47156
  capName: "keychain-admin",
45708
47157
  capScope: "system",
@@ -47149,6 +48598,12 @@ Object.freeze({
47149
48598
  addonId: null,
47150
48599
  access: "create"
47151
48600
  },
48601
+ "pipelineAnalytics.createRetrainDatasetVersion": {
48602
+ capName: "pipeline-analytics",
48603
+ capScope: "device",
48604
+ addonId: null,
48605
+ access: "create"
48606
+ },
47152
48607
  "pipelineAnalytics.deleteDeviceEvents": {
47153
48608
  capName: "pipeline-analytics",
47154
48609
  capScope: "device",
@@ -47161,6 +48616,12 @@ Object.freeze({
47161
48616
  addonId: null,
47162
48617
  access: "delete"
47163
48618
  },
48619
+ "pipelineAnalytics.deleteRetrainDatasetVersion": {
48620
+ capName: "pipeline-analytics",
48621
+ capScope: "device",
48622
+ addonId: null,
48623
+ access: "delete"
48624
+ },
47164
48625
  "pipelineAnalytics.deleteTracks": {
47165
48626
  capName: "pipeline-analytics",
47166
48627
  capScope: "device",
@@ -47383,6 +48844,12 @@ Object.freeze({
47383
48844
  addonId: null,
47384
48845
  access: "view"
47385
48846
  },
48847
+ "pipelineAnalytics.listRetrainDatasetVersions": {
48848
+ capName: "pipeline-analytics",
48849
+ capScope: "device",
48850
+ addonId: null,
48851
+ access: "view"
48852
+ },
47386
48853
  "pipelineAnalytics.listRetrainFrames": {
47387
48854
  capName: "pipeline-analytics",
47388
48855
  capScope: "device",
@@ -47413,6 +48880,12 @@ Object.freeze({
47413
48880
  addonId: null,
47414
48881
  access: "view"
47415
48882
  },
48883
+ "pipelineAnalytics.offerRetrainArchive": {
48884
+ capName: "pipeline-analytics",
48885
+ capScope: "device",
48886
+ addonId: null,
48887
+ access: "create"
48888
+ },
47416
48889
  "pipelineAnalytics.ownersWithMedia": {
47417
48890
  capName: "pipeline-analytics",
47418
48891
  capScope: "device",
@@ -47425,6 +48898,12 @@ Object.freeze({
47425
48898
  addonId: null,
47426
48899
  access: "create"
47427
48900
  },
48901
+ "pipelineAnalytics.previewRetrainDataset": {
48902
+ capName: "pipeline-analytics",
48903
+ capScope: "device",
48904
+ addonId: null,
48905
+ access: "view"
48906
+ },
47428
48907
  "pipelineAnalytics.proposeRetrainAnnotations": {
47429
48908
  capName: "pipeline-analytics",
47430
48909
  capScope: "device",
@@ -47563,6 +49042,12 @@ Object.freeze({
47563
49042
  addonId: null,
47564
49043
  access: "create"
47565
49044
  },
49045
+ "pipelineAnalytics.verifyRetrainDatasetVersion": {
49046
+ capName: "pipeline-analytics",
49047
+ capScope: "device",
49048
+ addonId: null,
49049
+ access: "view"
49050
+ },
47566
49051
  "pipelineAnalytics.wipeAllAnalytics": {
47567
49052
  capName: "pipeline-analytics",
47568
49053
  capScope: "device",
@@ -49939,6 +51424,174 @@ Object.freeze({
49939
51424
  addonId: null,
49940
51425
  access: "view"
49941
51426
  },
51427
+ "training.canaryResult": {
51428
+ capName: "training",
51429
+ capScope: "system",
51430
+ addonId: null,
51431
+ access: "create"
51432
+ },
51433
+ "training.cancelJob": {
51434
+ capName: "training",
51435
+ capScope: "system",
51436
+ addonId: null,
51437
+ access: "create"
51438
+ },
51439
+ "training.discardResult": {
51440
+ capName: "training",
51441
+ capScope: "system",
51442
+ addonId: null,
51443
+ access: "create"
51444
+ },
51445
+ "training.findDatasetVersionIdByName": {
51446
+ capName: "training",
51447
+ capScope: "system",
51448
+ addonId: null,
51449
+ access: "view"
51450
+ },
51451
+ "training.getDatasetVersion": {
51452
+ capName: "training",
51453
+ capScope: "system",
51454
+ addonId: null,
51455
+ access: "view"
51456
+ },
51457
+ "training.getJob": {
51458
+ capName: "training",
51459
+ capScope: "system",
51460
+ addonId: null,
51461
+ access: "view"
51462
+ },
51463
+ "training.getJobResult": {
51464
+ capName: "training",
51465
+ capScope: "system",
51466
+ addonId: null,
51467
+ access: "view"
51468
+ },
51469
+ "training.listBaseModels": {
51470
+ capName: "training",
51471
+ capScope: "system",
51472
+ addonId: null,
51473
+ access: "view"
51474
+ },
51475
+ "training.listDatasetVersions": {
51476
+ capName: "training",
51477
+ capScope: "system",
51478
+ addonId: null,
51479
+ access: "view"
51480
+ },
51481
+ "training.listJobs": {
51482
+ capName: "training",
51483
+ capScope: "system",
51484
+ addonId: null,
51485
+ access: "view"
51486
+ },
51487
+ "training.planJob": {
51488
+ capName: "training",
51489
+ capScope: "system",
51490
+ addonId: null,
51491
+ access: "view"
51492
+ },
51493
+ "training.putDatasetVersion": {
51494
+ capName: "training",
51495
+ capScope: "system",
51496
+ addonId: null,
51497
+ access: "create"
51498
+ },
51499
+ "training.registerResult": {
51500
+ capName: "training",
51501
+ capScope: "system",
51502
+ addonId: null,
51503
+ access: "create"
51504
+ },
51505
+ "training.removeDatasetVersion": {
51506
+ capName: "training",
51507
+ capScope: "system",
51508
+ addonId: null,
51509
+ access: "delete"
51510
+ },
51511
+ "training.rollbackCanary": {
51512
+ capName: "training",
51513
+ capScope: "system",
51514
+ addonId: null,
51515
+ access: "create"
51516
+ },
51517
+ "training.startJob": {
51518
+ capName: "training",
51519
+ capScope: "system",
51520
+ addonId: null,
51521
+ access: "create"
51522
+ },
51523
+ "trainingProvider.cancelJob": {
51524
+ capName: "training-provider",
51525
+ capScope: "system",
51526
+ addonId: null,
51527
+ access: "create"
51528
+ },
51529
+ "trainingProvider.cleanupJob": {
51530
+ capName: "training-provider",
51531
+ capScope: "system",
51532
+ addonId: null,
51533
+ access: "create"
51534
+ },
51535
+ "trainingProvider.describe": {
51536
+ capName: "training-provider",
51537
+ capScope: "system",
51538
+ addonId: null,
51539
+ access: "view"
51540
+ },
51541
+ "trainingProvider.estimateJob": {
51542
+ capName: "training-provider",
51543
+ capScope: "system",
51544
+ addonId: null,
51545
+ access: "view"
51546
+ },
51547
+ "trainingProvider.getJob": {
51548
+ capName: "training-provider",
51549
+ capScope: "system",
51550
+ addonId: null,
51551
+ access: "view"
51552
+ },
51553
+ "trainingProvider.listJobEvents": {
51554
+ capName: "training-provider",
51555
+ capScope: "system",
51556
+ addonId: null,
51557
+ access: "view"
51558
+ },
51559
+ "trainingProvider.listJobs": {
51560
+ capName: "training-provider",
51561
+ capScope: "system",
51562
+ addonId: null,
51563
+ access: "view"
51564
+ },
51565
+ "trainingProvider.offerArtifact": {
51566
+ capName: "training-provider",
51567
+ capScope: "system",
51568
+ addonId: null,
51569
+ access: "create"
51570
+ },
51571
+ "trainingProvider.readResult": {
51572
+ capName: "training-provider",
51573
+ capScope: "system",
51574
+ addonId: null,
51575
+ access: "create"
51576
+ },
51577
+ "trainingProvider.submitJob": {
51578
+ capName: "training-provider",
51579
+ capScope: "system",
51580
+ addonId: null,
51581
+ access: "create"
51582
+ },
51583
+ "trainingProvider.uploadDataset": {
51584
+ capName: "training-provider",
51585
+ capScope: "system",
51586
+ addonId: null,
51587
+ access: "create"
51588
+ },
51589
+ "trainingProvider.validateCredentials": {
51590
+ capName: "training-provider",
51591
+ capScope: "system",
51592
+ addonId: null,
51593
+ access: "create"
51594
+ },
49942
51595
  "turnProvider.getTurnServers": {
49943
51596
  capName: "turn-provider",
49944
51597
  capScope: "system",
@@ -49963,12 +51616,6 @@ Object.freeze({
49963
51616
  addonId: null,
49964
51617
  access: "create"
49965
51618
  },
49966
- "userManagement.createApiKey": {
49967
- capName: "user-management",
49968
- capScope: "system",
49969
- addonId: null,
49970
- access: "create"
49971
- },
49972
51619
  "userManagement.createScopedToken": {
49973
51620
  capName: "user-management",
49974
51621
  capScope: "system",
@@ -50005,12 +51652,6 @@ Object.freeze({
50005
51652
  addonId: null,
50006
51653
  access: "view"
50007
51654
  },
50008
- "userManagement.linkExternalIdentity": {
50009
- capName: "user-management",
50010
- capScope: "system",
50011
- addonId: null,
50012
- access: "create"
50013
- },
50014
51655
  "userManagement.listApiKeys": {
50015
51656
  capName: "user-management",
50016
51657
  capScope: "system",
@@ -50113,12 +51754,6 @@ Object.freeze({
50113
51754
  addonId: null,
50114
51755
  access: "create"
50115
51756
  },
50116
- "userManagement.validateApiKey": {
50117
- capName: "user-management",
50118
- capScope: "system",
50119
- addonId: null,
50120
- access: "view"
50121
- },
50122
51757
  "userManagement.validateCredentials": {
50123
51758
  capName: "user-management",
50124
51759
  capScope: "system",
@@ -54232,6 +55867,11 @@ Object.freeze({
54232
55867
  form: "single",
54233
55868
  optional: false
54234
55869
  }],
55870
+ "training.canaryResult": [{
55871
+ name: "deviceIds",
55872
+ form: "array",
55873
+ optional: false
55874
+ }],
54235
55875
  "update.getStatus": [{
54236
55876
  name: "deviceId",
54237
55877
  form: "single",