@camstack/addon-export-google 0.1.89 → 0.1.91

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.
@@ -5455,7 +5455,7 @@ var ZodIssueCode = {
5455
5455
  var ZodFirstPartyTypeKind;
5456
5456
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
5457
5457
  //#endregion
5458
- //#region ../types/dist/sleep-Cr5YOk3m.mjs
5458
+ //#region ../types/dist/sleep-r3RWkGVx.mjs
5459
5459
  /**
5460
5460
  * The audio chunk plane's byte format, and the ONE expansion from a coded
5461
5461
  * window to float samples (D455).
@@ -5572,7 +5572,7 @@ function isKeychainStoredField(field) {
5572
5572
  var SECRET_CLEAR = { $secretClear: true };
5573
5573
  /** The `'***'` token D634 redaction writes for non-admins. */
5574
5574
  var LEGACY_DEVICE_REDACTION = "***";
5575
- function isRecord$1(value) {
5575
+ function isRecord$2(value) {
5576
5576
  return typeof value === "object" && value !== null && !Array.isArray(value);
5577
5577
  }
5578
5578
  function makeSecretMarker(ref) {
@@ -5583,12 +5583,12 @@ function makeSecretMarker(ref) {
5583
5583
  }
5584
5584
  /** A stored marker: an object whose `$secret` is a non-empty string. */
5585
5585
  function isSecretMarker(value) {
5586
- if (!isRecord$1(value)) return false;
5586
+ if (!isRecord$2(value)) return false;
5587
5587
  const ref = value["$secret"];
5588
5588
  return typeof ref === "string" && ref.length > 0;
5589
5589
  }
5590
5590
  function isSecretClear(value) {
5591
- return isRecord$1(value) && value["$secretClear"] === true;
5591
+ return isRecord$2(value) && value["$secretClear"] === true;
5592
5592
  }
5593
5593
  /**
5594
5594
  * The UI view of a stored secret field value: a marker becomes "set", inline
@@ -6104,6 +6104,13 @@ function globalSecretScope() {
6104
6104
  function encodeSegment(value) {
6105
6105
  return encodeURIComponent(value);
6106
6106
  }
6107
+ function decodeSegment(value) {
6108
+ try {
6109
+ return decodeURIComponent(value);
6110
+ } catch {
6111
+ return null;
6112
+ }
6113
+ }
6107
6114
  /**
6108
6115
  * The field path of a value inside an array item, addressed by the item's id:
6109
6116
  * `arrayItemFieldPath('providers', 'authentik', 'clientSecret')` →
@@ -6112,6 +6119,75 @@ function encodeSegment(value) {
6112
6119
  function arrayItemFieldPath(arrayKey, itemId, fieldKey) {
6113
6120
  return `${arrayKey}[${encodeSegment(itemId)}].${fieldKey}`;
6114
6121
  }
6122
+ function parseScope(segments) {
6123
+ switch (segments[0]) {
6124
+ case "global": return {
6125
+ scope: GLOBAL_SCOPE,
6126
+ used: 1
6127
+ };
6128
+ case "node": {
6129
+ const nodeId = segments[1] !== void 0 ? decodeSegment(segments[1]) : null;
6130
+ return nodeId === null || nodeId.length === 0 ? null : {
6131
+ scope: {
6132
+ kind: "node",
6133
+ nodeId
6134
+ },
6135
+ used: 2
6136
+ };
6137
+ }
6138
+ case "device": {
6139
+ const raw = segments[1];
6140
+ if (raw === void 0 || !/^\d+$/.test(raw)) return null;
6141
+ return {
6142
+ scope: {
6143
+ kind: "device",
6144
+ deviceId: Number(raw)
6145
+ },
6146
+ used: 2
6147
+ };
6148
+ }
6149
+ case "integration": {
6150
+ const id = segments[1] !== void 0 ? decodeSegment(segments[1]) : null;
6151
+ return id === null || id.length === 0 ? null : {
6152
+ scope: {
6153
+ kind: "integration",
6154
+ integrationId: id
6155
+ },
6156
+ used: 2
6157
+ };
6158
+ }
6159
+ case "row": {
6160
+ const collection = segments[1] !== void 0 ? decodeSegment(segments[1]) : null;
6161
+ const rowId = segments[2] !== void 0 ? decodeSegment(segments[2]) : null;
6162
+ if (collection === null || rowId === null || collection.length === 0 || rowId.length === 0) return null;
6163
+ return {
6164
+ scope: {
6165
+ kind: "row",
6166
+ collection,
6167
+ rowId
6168
+ },
6169
+ used: 3
6170
+ };
6171
+ }
6172
+ default: return null;
6173
+ }
6174
+ }
6175
+ /** Take a ref apart; `null` when it is not a well-formed ref. */
6176
+ function parseSecretRef(ref) {
6177
+ if (!ref.startsWith("secret://")) return null;
6178
+ const segments = ref.slice(9).split("/");
6179
+ const owner = segments[0] !== void 0 ? decodeSegment(segments[0]) : null;
6180
+ if (owner === null || owner.length === 0) return null;
6181
+ const parsed = parseScope(segments.slice(1));
6182
+ if (parsed === null) return null;
6183
+ const fieldPath = segments.slice(1 + parsed.used).join("/");
6184
+ if (fieldPath.length === 0) return null;
6185
+ return {
6186
+ owner,
6187
+ scope: parsed.scope,
6188
+ fieldPath
6189
+ };
6190
+ }
6115
6191
  /** A write to a secret path could not be stored in the keychain, so it was refused. */
6116
6192
  var KeychainWriteRefusedError = class extends Error {
6117
6193
  fieldPath;
@@ -6122,7 +6198,7 @@ var KeychainWriteRefusedError = class extends Error {
6122
6198
  }
6123
6199
  };
6124
6200
  var KEEP = { kind: "keep" };
6125
- function isRecord(value) {
6201
+ function isRecord$1(value) {
6126
6202
  return typeof value === "object" && value !== null && !Array.isArray(value);
6127
6203
  }
6128
6204
  function defaultMintId() {
@@ -6135,7 +6211,7 @@ function collectSecretMarkerRefs(value, out = []) {
6135
6211
  return out;
6136
6212
  }
6137
6213
  if (Array.isArray(value)) for (const item of value) collectSecretMarkerRefs(item, out);
6138
- else if (isRecord(value)) for (const child of Object.values(value)) collectSecretMarkerRefs(child, out);
6214
+ else if (isRecord$1(value)) for (const child of Object.values(value)) collectSecretMarkerRefs(child, out);
6139
6215
  return out;
6140
6216
  }
6141
6217
  async function storedValueEquals(secrets, marker, candidate) {
@@ -6190,7 +6266,7 @@ function rowId(row, idKey) {
6190
6266
  return null;
6191
6267
  }
6192
6268
  async function writeArray(ctx, node, incoming, stored, fieldPath) {
6193
- const storedRows = Array.isArray(stored) ? stored.filter(isRecord) : [];
6269
+ const storedRows = Array.isArray(stored) ? stored.filter(isRecord$1) : [];
6194
6270
  if (!Array.isArray(incoming)) {
6195
6271
  ctx.deletes.push(...collectSecretMarkerRefs(storedRows));
6196
6272
  return {
@@ -6206,7 +6282,7 @@ async function writeArray(ctx, node, incoming, stored, fieldPath) {
6206
6282
  const kept = /* @__PURE__ */ new Set();
6207
6283
  const rows = [];
6208
6284
  for (const row of incoming) {
6209
- if (!isRecord(row)) {
6285
+ if (!isRecord$1(row)) {
6210
6286
  rows.push(row);
6211
6287
  continue;
6212
6288
  }
@@ -6231,7 +6307,7 @@ async function writeNode(ctx, node, incoming, stored, fieldPath) {
6231
6307
  case "leaf": return writeLeaf(ctx, incoming, stored, fieldPath);
6232
6308
  case "array": return writeArray(ctx, node, incoming, stored, fieldPath);
6233
6309
  case "object": {
6234
- if (!isRecord(incoming)) {
6310
+ if (!isRecord$1(incoming)) {
6235
6311
  if (incoming === void 0) return KEEP;
6236
6312
  ctx.deletes.push(...collectSecretMarkerRefs(stored));
6237
6313
  return {
@@ -6239,7 +6315,7 @@ async function writeNode(ctx, node, incoming, stored, fieldPath) {
6239
6315
  value: incoming
6240
6316
  };
6241
6317
  }
6242
- const storedObj = isRecord(stored) ? stored : {};
6318
+ const storedObj = isRecord$1(stored) ? stored : {};
6243
6319
  return {
6244
6320
  kind: "value",
6245
6321
  value: await writeMembers(ctx, node.children, incoming, storedObj, (m) => `${fieldPath}.${m}`)
@@ -6298,12 +6374,19 @@ async function transformSecretWrite(input) {
6298
6374
  }
6299
6375
  };
6300
6376
  }
6377
+ /** Is `ref` one of `owner`'s refs? */
6378
+ function isSecretRefOwnedBy(ref, owner) {
6379
+ return parseSecretRef(ref)?.owner === owner;
6380
+ }
6301
6381
  /**
6302
6382
  * Replace every marker in `value` with its keychain value. Returns the SAME
6303
6383
  * reference when there is no marker (no allocation, no keychain call).
6304
6384
  */
6305
- async function resolveSecretMarkers(value, secrets) {
6306
- const refs = collectSecretMarkerRefs(value);
6385
+ async function resolveSecretMarkers(value, secrets, options = {}) {
6386
+ const keepMarker = options.unresolved === "keep-marker";
6387
+ const owner = options.ownedBy;
6388
+ const inScope = (ref) => owner === void 0 || isSecretRefOwnedBy(ref, owner);
6389
+ const refs = collectSecretMarkerRefs(value).filter(inScope);
6307
6390
  if (refs.length === 0) return {
6308
6391
  value,
6309
6392
  unresolved: []
@@ -6327,10 +6410,18 @@ async function resolveSecretMarkers(value, secrets) {
6327
6410
  }
6328
6411
  const substitute = (v) => {
6329
6412
  if (isSecretMarker(v)) {
6413
+ if (!inScope(v.$secret)) return {
6414
+ keep: true,
6415
+ value: v
6416
+ };
6330
6417
  const answer = answers[v.$secret];
6331
- return answer?.kind === "value" ? {
6418
+ if (answer?.kind === "value") return {
6332
6419
  keep: true,
6333
6420
  value: answer.value
6421
+ };
6422
+ return keepMarker ? {
6423
+ keep: true,
6424
+ value: v
6334
6425
  } : {
6335
6426
  keep: false,
6336
6427
  value: void 0
@@ -6347,7 +6438,7 @@ async function resolveSecretMarkers(value, secrets) {
6347
6438
  value: items
6348
6439
  };
6349
6440
  }
6350
- if (isRecord(v)) {
6441
+ if (isRecord$1(v)) {
6351
6442
  const out = {};
6352
6443
  for (const [k, child] of Object.entries(v)) {
6353
6444
  const s = substitute(child);
@@ -6368,14 +6459,152 @@ async function resolveSecretMarkers(value, secrets) {
6368
6459
  unresolved
6369
6460
  };
6370
6461
  }
6371
- function touchesTree(tree, patch) {
6372
- if (tree.size === 0) return false;
6373
- for (const key of Object.keys(patch)) {
6374
- const at = key.indexOf("@");
6375
- if (tree.has(at > 0 ? key.slice(0, at) : key)) return true;
6462
+ /** An addon tried to replace a stored secret it could not read. Nothing was written. */
6463
+ var SecretOverwriteRefusedError = class extends Error {
6464
+ ref;
6465
+ reason;
6466
+ constructor(ref, reason) {
6467
+ 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.`);
6468
+ this.ref = ref;
6469
+ this.reason = reason;
6470
+ this.name = "SecretOverwriteRefusedError";
6471
+ }
6472
+ };
6473
+ function isRecord(value) {
6474
+ return typeof value === "object" && value !== null && !Array.isArray(value);
6475
+ }
6476
+ function resolvedValue(pass, marker) {
6477
+ const answer = pass.answers[marker.$secret];
6478
+ return answer?.kind === "value" ? answer.value : null;
6479
+ }
6480
+ async function atMarker(pass, incoming, stored) {
6481
+ if (incoming === null) return stored;
6482
+ if (typeof incoming !== "string") return incoming;
6483
+ if (incoming === resolvedValue(pass, stored)) return stored;
6484
+ const intent = classifySecretWrite(incoming);
6485
+ if (intent.kind !== "set") return stored;
6486
+ const ref = stored.$secret;
6487
+ if (!isSecretRefOwnedBy(ref, pass.secrets.owner)) return incoming;
6488
+ const answer = pass.answers[ref];
6489
+ 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);
6490
+ try {
6491
+ await pass.secrets.put(ref, intent.value);
6492
+ } catch (err) {
6493
+ throw new KeychainWriteRefusedError(ref, err);
6494
+ }
6495
+ pass.changedRefs.push(ref);
6496
+ return stored;
6497
+ }
6498
+ function inArray(pass, incoming, stored) {
6499
+ return incoming.map((item, index) => {
6500
+ const twin = stored[index];
6501
+ if (isSecretMarker(twin)) return typeof item === "string" && item === resolvedValue(pass, twin) ? twin : item;
6502
+ if (isRecord(item) && isRecord(twin)) return inArrayRow(pass, item, twin);
6503
+ if (Array.isArray(item) && Array.isArray(twin)) return inArray(pass, item, twin);
6504
+ return item;
6505
+ });
6506
+ }
6507
+ function inArrayRow(pass, incoming, stored) {
6508
+ const out = { ...incoming };
6509
+ for (const [key, value] of Object.entries(incoming)) {
6510
+ const twin = stored[key];
6511
+ if (isSecretMarker(twin)) {
6512
+ if (typeof value === "string" && value === resolvedValue(pass, twin)) out[key] = twin;
6513
+ } else if (isRecord(value) && isRecord(twin)) out[key] = inArrayRow(pass, value, twin);
6514
+ else if (Array.isArray(value) && Array.isArray(twin)) out[key] = inArray(pass, value, twin);
6515
+ }
6516
+ return out;
6517
+ }
6518
+ async function walk(pass, incoming, stored) {
6519
+ if (isSecretMarker(stored)) return atMarker(pass, incoming, stored);
6520
+ if (Array.isArray(incoming) && Array.isArray(stored)) return inArray(pass, incoming, stored);
6521
+ if (!isRecord(incoming) || !isRecord(stored)) return incoming;
6522
+ const out = { ...incoming };
6523
+ for (const [key, value] of Object.entries(incoming)) out[key] = await walk(pass, value, stored[key]);
6524
+ return out;
6525
+ }
6526
+ /** Restore markers a write-back carries as values. See the file doc. */
6527
+ async function restoreUnchangedSecrets(input) {
6528
+ const refs = [];
6529
+ for (const key of Object.keys(input.patch)) collectSecretMarkerRefs(input.stored[key], refs);
6530
+ const owned = refs.filter((ref) => isSecretRefOwnedBy(ref, input.secrets.owner));
6531
+ if (owned.length === 0) return {
6532
+ patch: input.patch,
6533
+ changedRefs: []
6534
+ };
6535
+ const pass = {
6536
+ secrets: input.secrets,
6537
+ answers: await input.secrets.resolve([...new Set(owned)]),
6538
+ operatorWrite: input.operatorWrite,
6539
+ changedRefs: []
6540
+ };
6541
+ const out = {};
6542
+ for (const [key, value] of Object.entries(input.patch)) out[key] = await walk(pass, value, input.stored[key]);
6543
+ return {
6544
+ patch: out,
6545
+ changedRefs: pass.changedRefs
6546
+ };
6547
+ }
6548
+ /** Structural equality over JSON-shaped values (key order does not matter). */
6549
+ function isJsonEqual(a, b) {
6550
+ if (Object.is(a, b)) return true;
6551
+ if (Array.isArray(a)) return Array.isArray(b) && a.length === b.length && a.every((v, i) => isJsonEqual(v, b[i]));
6552
+ if (isRecord(a) && isRecord(b)) {
6553
+ const keys = Object.keys(a);
6554
+ if (keys.length !== Object.keys(b).length) return false;
6555
+ return keys.every((k) => Object.prototype.hasOwnProperty.call(b, k) && isJsonEqual(a[k], b[k]));
6376
6556
  }
6377
6557
  return false;
6378
6558
  }
6559
+ /** The patch without the keys whose value already equals the stored one. */
6560
+ function dropUnchangedKeys(patch, stored) {
6561
+ const out = {};
6562
+ for (const [key, value] of Object.entries(patch)) {
6563
+ if (Object.prototype.hasOwnProperty.call(stored, key) && isJsonEqual(value, stored[key])) continue;
6564
+ out[key] = value;
6565
+ }
6566
+ return out;
6567
+ }
6568
+ /** The top-level keys of a blob that hold at least one of `owner`'s markers. */
6569
+ function markerKeysOf(blob, owner) {
6570
+ const keys = /* @__PURE__ */ new Set();
6571
+ for (const [key, value] of Object.entries(blob)) if (collectSecretMarkerRefs(value).some((ref) => isSecretRefOwnedBy(ref, owner))) keys.add(key);
6572
+ return keys;
6573
+ }
6574
+ function nodeFromStored(value, owner) {
6575
+ if (isSecretMarker(value)) return isSecretRefOwnedBy(value.$secret, owner) ? { kind: "leaf" } : null;
6576
+ if (!isRecord(value)) return null;
6577
+ const children = /* @__PURE__ */ new Map();
6578
+ for (const [key, child] of Object.entries(value)) {
6579
+ const node = nodeFromStored(child, owner);
6580
+ if (node !== null) children.set(key, node);
6581
+ }
6582
+ return children.size > 0 ? {
6583
+ kind: "object",
6584
+ children
6585
+ } : null;
6586
+ }
6587
+ /**
6588
+ * The declared secret tree, widened by every place the STORED blob holds a
6589
+ * marker under one of `keys` — so a marker the schema no longer declares (or
6590
+ * never declared: Wyze before b4906cec6) still gets the save path's
6591
+ * KEEP / SET / CLEAR semantics instead of being overwritten by whatever the
6592
+ * addon writes. Markers inside arrays are not added: a row has no id field to
6593
+ * match by unless the schema declares one. Only `owner`'s markers count: a
6594
+ * builtin that keeps another addon's marker (device-manager) never takes it
6595
+ * over.
6596
+ */
6597
+ function widenTreeWithStoredMarkers(declared, stored, keys, owner) {
6598
+ const added = /* @__PURE__ */ new Map();
6599
+ for (const key of keys) {
6600
+ const at = key.indexOf("@");
6601
+ const base = at > 0 ? key.slice(0, at) : key;
6602
+ if (declared.has(base) || added.has(base)) continue;
6603
+ const node = nodeFromStored(stored[key], owner);
6604
+ if (node !== null) added.set(base, node);
6605
+ }
6606
+ return added.size === 0 ? declared : new Map([...declared, ...added]);
6607
+ }
6379
6608
  /** The blob as stored now; a failed read REFUSES the write instead of guessing. */
6380
6609
  async function readStoredAddonBlob(raw) {
6381
6610
  const threeWay = raw.readAddonStoreResult;
@@ -6384,7 +6613,41 @@ async function readStoredAddonBlob(raw) {
6384
6613
  if (result.kind === "failed") throw new Error(`settings write refused: the stored blob could not be read (${result.error})`);
6385
6614
  return result.kind === "missing" ? {} : result.value;
6386
6615
  }
6387
- function createSecretAwareSettings(raw, opts) {
6616
+ function touchesTree(tree, patch) {
6617
+ if (tree.size === 0) return false;
6618
+ for (const key of Object.keys(patch)) {
6619
+ const at = key.indexOf("@");
6620
+ if (tree.has(at > 0 ? key.slice(0, at) : key)) return true;
6621
+ }
6622
+ return false;
6623
+ }
6624
+ /**
6625
+ * Which top-level keys of each store held markers when last seen. `undefined`
6626
+ * for a store not seen yet: its first write reads it, to be safe.
6627
+ */
6628
+ var MarkerKeyIndex = class {
6629
+ owner;
6630
+ byStore = /* @__PURE__ */ new Map();
6631
+ constructor(owner) {
6632
+ this.owner = owner;
6633
+ }
6634
+ seen(store, blob) {
6635
+ this.byStore.set(store, markerKeysOf(blob, this.owner));
6636
+ }
6637
+ wrote(store, patch) {
6638
+ const keys = this.byStore.get(store);
6639
+ if (keys === void 0) return;
6640
+ const now = markerKeysOf(patch, this.owner);
6641
+ for (const key of Object.keys(patch)) if (now.has(key)) keys.add(key);
6642
+ else keys.delete(key);
6643
+ }
6644
+ mayHoldMarkers(store, patch) {
6645
+ const keys = this.byStore.get(store);
6646
+ if (keys === void 0) return true;
6647
+ return Object.keys(patch).some((key) => keys.has(key));
6648
+ }
6649
+ };
6650
+ function createHandle(raw, opts) {
6388
6651
  const chains = /* @__PURE__ */ new Map();
6389
6652
  const serialize = (key, fn) => {
6390
6653
  const next = (chains.get(key) ?? Promise.resolve()).then(fn, fn);
@@ -6395,46 +6658,130 @@ function createSecretAwareSettings(raw, opts) {
6395
6658
  });
6396
6659
  return next;
6397
6660
  };
6398
- const write = async (chainKey, tree, scope, patch, readStored, rawWrite) => {
6399
- if (!touchesTree(tree, patch)) return rawWrite(patch);
6400
- return serialize(chainKey, async () => {
6661
+ const index = new MarkerKeyIndex(opts.secrets.owner);
6662
+ const resolveRead = async (store, blob) => {
6663
+ index.seen(store, blob);
6664
+ const { value, unresolved } = await resolveSecretMarkers(blob, opts.secrets, {
6665
+ unresolved: "keep-marker",
6666
+ ownedBy: opts.secrets.owner
6667
+ });
6668
+ if (unresolved.length > 0) opts.onUnresolved?.(unresolved);
6669
+ return value;
6670
+ };
6671
+ const write = async (store, declared, scope, patch, readStored, rawWrite) => {
6672
+ if (!touchesTree(declared, patch) && !index.mayHoldMarkers(store, patch)) {
6673
+ await rawWrite(patch);
6674
+ index.wrote(store, patch);
6675
+ return { changed: true };
6676
+ }
6677
+ return serialize(store, async () => {
6401
6678
  const stored = await readStored();
6679
+ index.seen(store, stored);
6680
+ const operatorWrite = opts.isOperatorWrite?.() === true;
6681
+ const restored = await restoreUnchangedSecrets({
6682
+ patch,
6683
+ stored,
6684
+ secrets: opts.secrets,
6685
+ operatorWrite
6686
+ });
6402
6687
  const result = await transformSecretWrite({
6403
- tree,
6688
+ tree: widenTreeWithStoredMarkers(declared, stored, Object.keys(restored.patch), opts.secrets.owner),
6404
6689
  secrets: opts.secrets,
6405
- patch,
6690
+ patch: restored.patch,
6406
6691
  stored,
6407
6692
  ...scope !== void 0 ? { scope } : {},
6408
- operatorWrite: opts.isOperatorWrite?.() === true
6693
+ operatorWrite
6409
6694
  });
6410
- if (Object.keys(result.patch).length > 0) await rawWrite(result.patch);
6695
+ const effective = dropUnchangedKeys(result.patch, stored);
6696
+ const wroteBlob = Object.keys(effective).length > 0;
6697
+ if (wroteBlob) {
6698
+ await rawWrite(effective);
6699
+ index.wrote(store, effective);
6700
+ }
6411
6701
  const { orphaned } = await result.afterWrite();
6412
6702
  if (orphaned.length > 0) opts.onOrphaned(orphaned);
6703
+ return { changed: wroteBlob || restored.changedRefs.length > 0 };
6413
6704
  });
6414
6705
  };
6415
- const wrapped = {
6416
- writeAddonStore: (patch) => write("addon", opts.addonTree(), void 0, patch, () => readStoredAddonBlob(raw), (p) => raw.writeAddonStore(p)),
6417
- writeDeviceStore: (deviceId, patch) => write(`device:${deviceId}`, opts.deviceTree(), {
6418
- kind: "device",
6419
- deviceId
6420
- }, patch, () => raw.readDeviceStore(deviceId), (p) => raw.writeDeviceStore(deviceId, p))
6706
+ const writeAddon = (patch) => write("addon", opts.addonTree(), void 0, patch, () => readStoredAddonBlob(raw), (p) => raw.writeAddonStore(p));
6707
+ const readAddonStoreResult = raw.readAddonStoreResult;
6708
+ const readAddonStoreKeyResult = raw.readAddonStoreKeyResult;
6709
+ const readDeviceStoreBatch = raw.readDeviceStoreBatch;
6710
+ const overrides = {
6711
+ readAddonStore: async () => resolveRead("addon", await raw.readAddonStore()),
6712
+ ...readAddonStoreResult !== void 0 ? { readAddonStoreResult: async () => {
6713
+ const result = await readAddonStoreResult.call(raw);
6714
+ return result.kind === "value" ? {
6715
+ kind: "value",
6716
+ value: await resolveRead("addon", result.value)
6717
+ } : result;
6718
+ } } : {},
6719
+ ...readAddonStoreKeyResult !== void 0 ? { readAddonStoreKeyResult: async (key) => {
6720
+ const result = await readAddonStoreKeyResult.call(raw, key);
6721
+ if (result.kind !== "present") return result;
6722
+ const { value, unresolved } = await resolveSecretMarkers({ [key]: result.value }, opts.secrets, {
6723
+ unresolved: "keep-marker",
6724
+ ownedBy: opts.secrets.owner
6725
+ });
6726
+ if (unresolved.length > 0) opts.onUnresolved?.(unresolved);
6727
+ return {
6728
+ kind: "present",
6729
+ value: value[key]
6730
+ };
6731
+ } } : {},
6732
+ readDeviceStore: async (deviceId) => resolveRead(`device:${deviceId}`, await raw.readDeviceStore(deviceId)),
6733
+ ...readDeviceStoreBatch !== void 0 ? { readDeviceStoreBatch: async (deviceIds) => {
6734
+ const rows = await readDeviceStoreBatch.call(raw, deviceIds);
6735
+ const out = /* @__PURE__ */ new Map();
6736
+ for (const [deviceId, blob] of rows) out.set(deviceId, await resolveRead(`device:${deviceId}`, blob));
6737
+ return out;
6738
+ } } : {},
6739
+ writeAddonStore: async (patch) => {
6740
+ await writeAddon(patch);
6741
+ },
6742
+ writeDeviceStore: async (deviceId, patch) => {
6743
+ await write(`device:${deviceId}`, opts.deviceTree(), {
6744
+ kind: "device",
6745
+ deviceId
6746
+ }, patch, () => raw.readDeviceStore(deviceId), (p) => raw.writeDeviceStore(deviceId, p));
6747
+ }
6748
+ };
6749
+ return {
6750
+ settings: new Proxy(raw, { get(target, prop, receiver) {
6751
+ if (typeof prop === "string" && Object.prototype.hasOwnProperty.call(overrides, prop)) return Reflect.get(overrides, prop);
6752
+ const value = Reflect.get(target, prop, receiver);
6753
+ return typeof value === "function" ? value.bind(target) : value;
6754
+ } }),
6755
+ raw: {
6756
+ readAddonStore: async () => {
6757
+ const blob = await raw.readAddonStore();
6758
+ index.seen("addon", blob);
6759
+ return blob;
6760
+ },
6761
+ readDeviceStore: async (deviceId) => {
6762
+ const blob = await raw.readDeviceStore(deviceId);
6763
+ index.seen(`device:${deviceId}`, blob);
6764
+ return blob;
6765
+ }
6766
+ },
6767
+ writeAddonStore: writeAddon
6421
6768
  };
6422
- return new Proxy(raw, { get(target, prop, receiver) {
6423
- if (prop === "writeAddonStore") return wrapped.writeAddonStore;
6424
- if (prop === "writeDeviceStore") return wrapped.writeDeviceStore;
6425
- const value = Reflect.get(target, prop, receiver);
6426
- return typeof value === "function" ? value.bind(target) : value;
6427
- } });
6428
6769
  }
6429
- /** The context the addon sees: identical, except that its settings writes are secret-aware. */
6430
- function withSecretAwareSettings(context, opts) {
6770
+ /** The context the addon sees, plus the private raw view and write outcome. */
6771
+ function createSecretAwareContext(context, opts) {
6431
6772
  const raw = context.settings;
6432
- if (raw === void 0) return context;
6433
- const settings = createSecretAwareSettings(raw, opts);
6434
- return new Proxy(context, { get(target, prop, receiver) {
6435
- if (prop === "settings") return settings;
6436
- return Reflect.get(target, prop, receiver);
6437
- } });
6773
+ if (raw === void 0) return {
6774
+ context,
6775
+ handle: null
6776
+ };
6777
+ const handle = createHandle(raw, opts);
6778
+ return {
6779
+ context: new Proxy(context, { get(target, prop, receiver) {
6780
+ if (prop === "settings") return handle.settings;
6781
+ return Reflect.get(target, prop, receiver);
6782
+ } }),
6783
+ handle
6784
+ };
6438
6785
  }
6439
6786
  var LEAF = { kind: "leaf" };
6440
6787
  var DEFAULT_ITEM_ID_KEY = "id";
@@ -6609,6 +6956,14 @@ var BaseAddon = class {
6609
6956
  _secretChangeUnsub = null;
6610
6957
  /** >0 while an OPERATOR's settings write is being applied. */
6611
6958
  _operatorWriteDepth = 0;
6959
+ /**
6960
+ * The keychain-aware settings handle (D798). Its `raw` view is the ONLY way
6961
+ * to the marker-bearing blobs and stays private to this class: the form
6962
+ * hydrate and config resolution need markers, addon code never does.
6963
+ */
6964
+ _secretSettings = null;
6965
+ /** Refs an addon-facing read could not resolve — each is logged once per process. */
6966
+ _loggedUnresolvedReads = /* @__PURE__ */ new Set();
6612
6967
  constructor(defaults) {
6613
6968
  this.defaults = defaults;
6614
6969
  this._config = { ...defaults };
@@ -6645,13 +7000,21 @@ var BaseAddon = class {
6645
7000
  }
6646
7001
  async initialize(context) {
6647
7002
  const secrets = context.secrets;
6648
- this._ctx = secrets !== void 0 ? withSecretAwareSettings(context, {
6649
- secrets,
6650
- addonTree: () => this.addonSecretTree(),
6651
- deviceTree: () => this.deviceSecretTree(),
6652
- onOrphaned: (refs) => context.logger.warn("keychain refs dropped by a settings write could not be deleted", { meta: { refs: [...refs] } }),
6653
- isOperatorWrite: () => this._operatorWriteDepth > 0
6654
- }) : context;
7003
+ if (secrets !== void 0) {
7004
+ const { context: wrapped, handle } = createSecretAwareContext(context, {
7005
+ secrets,
7006
+ addonTree: () => this.addonSecretTree(),
7007
+ deviceTree: () => this.deviceSecretTree(),
7008
+ onOrphaned: (refs) => context.logger.warn("keychain refs dropped by a settings write could not be deleted", { meta: { refs: [...refs] } }),
7009
+ isOperatorWrite: () => this._operatorWriteDepth > 0,
7010
+ onUnresolved: (unresolved) => this.logUnresolvedRead(unresolved)
7011
+ });
7012
+ this._ctx = wrapped;
7013
+ this._secretSettings = handle;
7014
+ } else {
7015
+ this._ctx = context;
7016
+ this._secretSettings = null;
7017
+ }
6655
7018
  await this.resolveConfig();
6656
7019
  if (secrets !== void 0) this._secretChangeUnsub = secrets.onChange((ref) => {
6657
7020
  if (this._configSecretRefs.has(ref)) this.scheduleSecretReresolve(SECRET_CHANGE_DEBOUNCE_MS);
@@ -6768,11 +7131,8 @@ var BaseAddon = class {
6768
7131
  async getGlobalSettings(overlay, cap, nodeId) {
6769
7132
  const schema = this.globalSettingsSchema(cap);
6770
7133
  if (!schema) return { sections: [] };
6771
- const projected = await this.resolveGlobalStore(nodeId, cap);
6772
- return hydrateSchema(schema, overlay ? {
6773
- ...projected,
6774
- ...overlay
6775
- } : projected, { inlineSecretsAsViews: true });
7134
+ const projected = await this.readRawProjectedStore(nodeId, cap);
7135
+ return hydrateSchema(schema, overlay ? await this.overlayKeepingMarkers(projected, overlay) : projected, { inlineSecretsAsViews: true });
6776
7136
  }
6777
7137
  /**
6778
7138
  * The integration-level view of this addon's settings: exactly the sections
@@ -6817,7 +7177,7 @@ var BaseAddon = class {
6817
7177
  });
6818
7178
  }
6819
7179
  if (sections.length === 0) return null;
6820
- const projected = await this.resolveGlobalStore(nodeId);
7180
+ const projected = await this.readRawProjectedStore(nodeId);
6821
7181
  return hydrateSchema({
6822
7182
  ...schema,
6823
7183
  sections
@@ -6834,12 +7194,50 @@ var BaseAddon = class {
6834
7194
  * the store for custom option logic (option narrowing, value snapping) to
6835
7195
  * read it per-node — never `ctx.settings.readAddonStore()` directly.
6836
7196
  * `nodeId` omitted ⇒ the local node (node-blind injection from ctx).
7197
+ *
7198
+ * Keychain values come back RESOLVED (D798): a secret reads as its value,
7199
+ * never as a `{ $secret }` marker. One the keychain cannot serve right now
7200
+ * stays a marker — "stored, unavailable" (`isSecretMarker()` is true, and it
7201
+ * is listed in {@link unresolvedSecrets}) — never `''` and never absent, so
7202
+ * it cannot be mistaken for "nothing stored, mint a new one". Writing the
7203
+ * resolved blob back is a no-op for every unchanged secret.
6837
7204
  */
6838
7205
  async resolveGlobalStore(nodeId, cap) {
6839
7206
  const raw = await this._ctx?.settings?.readAddonStore() ?? {};
7207
+ return this.projectForNode(raw, nodeId, cap);
7208
+ }
7209
+ projectForNode(store, nodeId, cap) {
6840
7210
  const keys = this.perNodeKeys(cap);
6841
7211
  const node = normalizeNodeId(nodeId ?? this._ctx?.kernel?.localNodeId);
6842
- return keys.size > 0 ? projectStore(raw, keys, node) : raw;
7212
+ return keys.size > 0 ? projectStore(store, keys, node) : store;
7213
+ }
7214
+ /** The PROJECTED store with its markers — the form hydrate only (D798). */
7215
+ async readRawProjectedStore(nodeId, cap) {
7216
+ const raw = await this.rawSettings()?.readAddonStore() ?? {};
7217
+ return this.projectForNode(raw, nodeId, cap);
7218
+ }
7219
+ /**
7220
+ * `{ ...stored, ...overlay }`, except that an overlay member equal to the
7221
+ * RESOLVED stored one keeps the stored (marker-bearing) member — so a form
7222
+ * hydrated from a resolved overlay still shows a secret as "set", never as
7223
+ * its value.
7224
+ */
7225
+ async overlayKeepingMarkers(stored, overlay) {
7226
+ const secrets = this._ctx?.secrets;
7227
+ const merged = {
7228
+ ...stored,
7229
+ ...overlay
7230
+ };
7231
+ if (secrets === void 0 || collectSecretMarkerRefs(stored).length === 0) return merged;
7232
+ const { value: resolved } = await resolveSecretMarkers(stored, secrets, {
7233
+ unresolved: "keep-marker",
7234
+ ownedBy: secrets.owner
7235
+ });
7236
+ for (const key of Object.keys(overlay)) {
7237
+ if (collectSecretMarkerRefs(stored[key]).length === 0) continue;
7238
+ if (isJsonEqual(overlay[key], resolved[key])) merged[key] = stored[key];
7239
+ }
7240
+ return merged;
6843
7241
  }
6844
7242
  /**
6845
7243
  * Whether ONE global key of this addon's store was written, read three-way
@@ -6904,8 +7302,12 @@ var BaseAddon = class {
6904
7302
  async clearSecrets(keys, nodeId) {
6905
7303
  const tree = this.addonSecretTree();
6906
7304
  const keychain = this._ctx?.secrets !== void 0;
7305
+ const stored = keychain ? await this.readAddonStoreWithRetry() : {};
6907
7306
  const patch = {};
6908
- for (const key of keys) patch[key] = keychain && tree.has(key) ? SECRET_CLEAR : "";
7307
+ for (const key of keys) {
7308
+ const keychainStored = tree.has(key) || collectSecretMarkerRefs(stored[key]).length > 0;
7309
+ patch[key] = keychain && keychainStored ? SECRET_CLEAR : "";
7310
+ }
6909
7311
  await this.applyGlobalPatch(patch, nodeId);
6910
7312
  }
6911
7313
  async applyGlobalPatch(barePatch, nodeId) {
@@ -6913,7 +7315,11 @@ var BaseAddon = class {
6913
7315
  const localNode = normalizeNodeId(this._ctx?.kernel?.localNodeId);
6914
7316
  const target = normalizeNodeId(nodeId ?? this._ctx?.kernel?.localNodeId);
6915
7317
  const scoped = keys.size > 0 ? scopePatch(barePatch, keys, target) : barePatch;
6916
- await this._ctx?.settings?.writeAddonStore(scoped);
7318
+ const handle = this._secretSettings;
7319
+ if (handle !== null) {
7320
+ const { changed } = await handle.writeAddonStore(scoped);
7321
+ if (!changed) return;
7322
+ } else await this._ctx?.settings?.writeAddonStore(scoped);
6917
7323
  if (target !== localNode) return;
6918
7324
  await this.resolveConfig();
6919
7325
  await this.onConfigChanged();
@@ -6966,7 +7372,7 @@ var BaseAddon = class {
6966
7372
  async getDeviceSettings(deviceId) {
6967
7373
  const schema = this.deviceSettingsSchema();
6968
7374
  if (!schema) return { sections: [] };
6969
- return hydrateSchema(schema, await this._ctx?.settings?.readDeviceStore(deviceId) ?? {}, { inlineSecretsAsViews: true });
7375
+ return hydrateSchema(schema, await this.rawSettings()?.readDeviceStore(deviceId) ?? {}, { inlineSecretsAsViews: true });
6970
7376
  }
6971
7377
  async updateDeviceSettings(deviceId, patch) {
6972
7378
  await this._ctx?.settings?.writeDeviceStore(deviceId, patch);
@@ -7138,7 +7544,7 @@ var BaseAddon = class {
7138
7544
  key,
7139
7545
  schema,
7140
7546
  fallback,
7141
- read: async () => this.resolveStoredSecrets(await this._ctx?.settings?.readDeviceStore(deviceId) ?? {}, false),
7547
+ read: async () => this.resolveStoredSecrets(await this.rawSettings()?.readDeviceStore(deviceId) ?? {}, false),
7142
7548
  write: async (patch) => {
7143
7549
  await this._ctx?.settings?.writeDeviceStore(deviceId, patch);
7144
7550
  },
@@ -7200,6 +7606,23 @@ var BaseAddon = class {
7200
7606
  }
7201
7607
  return value;
7202
7608
  }
7609
+ /**
7610
+ * The marker-bearing settings reads (D798) — private on purpose. Without a
7611
+ * keychain the context's own view is already raw.
7612
+ */
7613
+ rawSettings() {
7614
+ return this._secretSettings?.raw ?? this._ctx?.settings;
7615
+ }
7616
+ /** An addon-facing read met markers it could not resolve: say so once per ref. */
7617
+ logUnresolvedRead(unresolved) {
7618
+ const fresh = unresolved.filter((u) => !this._loggedUnresolvedReads.has(u.ref));
7619
+ if (fresh.length === 0) return;
7620
+ for (const u of fresh) this._loggedUnresolvedReads.add(u.ref);
7621
+ 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) => ({
7622
+ ref: u.ref,
7623
+ reason: u.reason
7624
+ })) } });
7625
+ }
7203
7626
  /** Re-resolve the config (a keychain-only change, or a retry) and apply it. */
7204
7627
  scheduleSecretReresolve(delayMs) {
7205
7628
  const timerOf = delayMs === SECRET_CHANGE_DEBOUNCE_MS ? "_secretChangeTimer" : "_secretRetryTimer";
@@ -7226,7 +7649,7 @@ var BaseAddon = class {
7226
7649
  * `{}` (defaults) — the addon's first successful patch will rehydrate.
7227
7650
  */
7228
7651
  async readAddonStoreWithRetry() {
7229
- const settings = this._ctx?.settings;
7652
+ const settings = this.rawSettings();
7230
7653
  if (!settings) return {};
7231
7654
  const delaysMs = [
7232
7655
  150,
@@ -9601,6 +10024,278 @@ var CameraSwitchGroupSchema = object({
9601
10024
  fetchedAt: number()
9602
10025
  });
9603
10026
  /**
10027
+ * The trainer contract — what the hub hands the cloud trainer and what it
10028
+ * gets back (cloud training, D805+).
10029
+ *
10030
+ * The trainer (`hf/camstack-trainer`, published as the Hugging Face repo
10031
+ * `camstack/camstack-trainer`) is a separate AGPL program the hub never
10032
+ * imports: `job.json` goes in, files come out, and progress is `CAMSTACK_EVENT`
10033
+ * lines on stdout. These schemas are the hub's half of that boundary; the
10034
+ * trainer's pydantic models (and the JSON Schemas generated from them under
10035
+ * `hf/camstack-trainer/schemas/`) are the other half. A change here is a
10036
+ * change there, in the same piece of work.
10037
+ *
10038
+ * No `.default()` anywhere: defaults do not run on the addon cap path, so the
10039
+ * orchestrator fills every field of a job spec explicitly.
10040
+ */
10041
+ var TRAINING_JOB_SCHEMA = "camstack.training/v1";
10042
+ var TRAINING_RESULT_SCHEMA = "camstack.training-result/v1";
10043
+ /** What the trainer can export. Edge TPU is a later, separate image. */
10044
+ var TrainingExportSchema = _enum([
10045
+ "onnx",
10046
+ "openvino-fp16",
10047
+ "openvino-int8",
10048
+ "coreml-fp16"
10049
+ ]);
10050
+ var FloorsSchema = record(string(), number().min(0).max(1));
10051
+ object({
10052
+ schema: literal(TRAINING_JOB_SCHEMA),
10053
+ jobKey: string().uuid(),
10054
+ target: object({
10055
+ kind: literal("detector"),
10056
+ step: literal("object-detection")
10057
+ }),
10058
+ base: object({
10059
+ modelId: string().min(1),
10060
+ /** Ultralytics weights id, e.g. `yolov9m.pt`. */
10061
+ weights: string().min(1),
10062
+ imgsz: number().int().positive()
10063
+ }),
10064
+ baseline: object({
10065
+ modelId: string().min(1),
10066
+ /** The baseline ONNX the holdout comparison runs; public mirror URL. */
10067
+ onnxUrl: string().url(),
10068
+ imgsz: number().int().positive(),
10069
+ floors: FloorsSchema
10070
+ }),
10071
+ dataset: object({
10072
+ versionId: string().min(1),
10073
+ annotationHash: string(),
10074
+ /** sha256 of the uploaded archive; the trainer refuses a mismatch (exit 65). */
10075
+ sha256: string().regex(/^[0-9a-f]{64}$/)
10076
+ }),
10077
+ split: object({
10078
+ holdoutCameras: array(number().int()),
10079
+ /** When no camera is held out: the last N days of every camera. */
10080
+ holdoutLastDays: number().int().nonnegative(),
10081
+ valFraction: number().min(0).max(.5),
10082
+ seed: number().int()
10083
+ }),
10084
+ hyper: object({
10085
+ epochs: number().int().positive(),
10086
+ batch: number().int().positive(),
10087
+ lr0: number().positive(),
10088
+ /** Layers frozen from the start of the backbone; 0 = none. */
10089
+ freeze: number().int().nonnegative(),
10090
+ patience: number().int().nonnegative(),
10091
+ seed: number().int()
10092
+ }),
10093
+ replay: object({
10094
+ source: literal("coco2017"),
10095
+ count: number().int().nonnegative()
10096
+ }),
10097
+ exports: array(TrainingExportSchema).min(1),
10098
+ calibration: object({ maxFrames: number().int().positive() }),
10099
+ floors: object({
10100
+ minSupport: number().int().positive(),
10101
+ clamp: number().min(0).max(1)
10102
+ }),
10103
+ int8Gate: object({ maxMap50Drop: number().min(0).max(1) }),
10104
+ catalog: object({
10105
+ id: string().regex(/^[a-z0-9][a-z0-9-]{2,80}$/),
10106
+ name: string().min(1).max(160)
10107
+ })
10108
+ });
10109
+ /** One regular file of the bundle. An mlpackage contributes one row per member. */
10110
+ var TrainingResultFileSchema = object({
10111
+ path: string().min(1),
10112
+ bytes: number().int().nonnegative(),
10113
+ sha256: string().regex(/^[0-9a-f]{64}$/),
10114
+ format: _enum([
10115
+ "onnx",
10116
+ "openvino",
10117
+ "coreml",
10118
+ "pt"
10119
+ ]),
10120
+ variant: _enum(["base", "int8"])
10121
+ });
10122
+ var DraftFormatSchema = object({
10123
+ /** RELATIVE path inside the bundle; the hub rewrites it to `camstack-local://`. */
10124
+ url: string().min(1),
10125
+ sizeMB: number().nonnegative(),
10126
+ isDirectory: boolean().optional(),
10127
+ files: array(string()).optional(),
10128
+ runtimes: array(literal("python")).optional(),
10129
+ revision: string().min(1)
10130
+ });
10131
+ /** The trainer's half of a catalog entry; the hub completes it (labels, licence, group). */
10132
+ var TrainingCatalogDraftSchema = object({
10133
+ id: string().min(1),
10134
+ name: string().min(1),
10135
+ description: string(),
10136
+ labels: array(unknown()),
10137
+ inputSize: object({
10138
+ width: number().int().positive(),
10139
+ height: number().int().positive()
10140
+ }),
10141
+ preprocessMode: literal("letterbox"),
10142
+ defaultClassFloors: FloorsSchema,
10143
+ formats: object({
10144
+ onnx: DraftFormatSchema.optional(),
10145
+ openvino: DraftFormatSchema.optional(),
10146
+ coreml: DraftFormatSchema.optional()
10147
+ })
10148
+ });
10149
+ /** One class of one model's holdout report (the eval harness's summary). */
10150
+ var TrainingEvalClassSchema = object({
10151
+ positives: number().int(),
10152
+ floor: number().nullable(),
10153
+ tp: number().int(),
10154
+ fp: number().int(),
10155
+ fn: number().int(),
10156
+ precision: number().nullable(),
10157
+ recall: number().nullable(),
10158
+ ap50: number().nullable(),
10159
+ recallByCamera: record(string(), number().nullable()).optional(),
10160
+ recallByLight: record(string(), number().nullable()).optional(),
10161
+ fpByCamera: record(string(), number()).optional(),
10162
+ smallFound: number().int().optional(),
10163
+ smallTotal: number().int().optional()
10164
+ }).passthrough();
10165
+ var TrainingEvalReportSchema = object({
10166
+ frames: number().int(),
10167
+ classes: record(string(), TrainingEvalClassSchema)
10168
+ }).passthrough();
10169
+ /**
10170
+ * A succeeded result carries every block; a failed one carries the error and
10171
+ * whatever was known by then — the other blocks are ABSENT, not null. The
10172
+ * orchestrator checks the blocks it needs before it trusts a success.
10173
+ */
10174
+ var TrainingResultSchema = object({
10175
+ schema: literal(TRAINING_RESULT_SCHEMA),
10176
+ jobKey: string(),
10177
+ status: _enum(["succeeded", "failed"]),
10178
+ error: object({
10179
+ stage: string(),
10180
+ code: string(),
10181
+ message: string()
10182
+ }).nullable(),
10183
+ trainer: object({
10184
+ version: string(),
10185
+ revision: string()
10186
+ }),
10187
+ toolchain: record(string(), string().nullable()),
10188
+ dataset: object({
10189
+ versionId: string(),
10190
+ annotationHash: string(),
10191
+ sha256: string(),
10192
+ frames: object({
10193
+ train: number().int(),
10194
+ val: number().int(),
10195
+ holdout: number().int()
10196
+ }),
10197
+ holdoutCameras: array(number().int()),
10198
+ replayImages: number().int()
10199
+ }).optional(),
10200
+ training: object({
10201
+ epochsRun: number().int(),
10202
+ bestEpoch: number().int(),
10203
+ bestMap50: number(),
10204
+ bestMap50_95: number(),
10205
+ seconds: number()
10206
+ }).optional(),
10207
+ evaluation: object({
10208
+ holdoutFrames: number().int(),
10209
+ baseline: TrainingEvalReportSchema.nullable(),
10210
+ candidate: TrainingEvalReportSchema.nullable(),
10211
+ candidateInt8: TrainingEvalReportSchema.nullable(),
10212
+ recallDeltaByCamera: record(string(), record(string(), number())).nullable(),
10213
+ map50: record(string(), number().nullable())
10214
+ }).optional(),
10215
+ floors: object({
10216
+ baseline: FloorsSchema,
10217
+ candidate: FloorsSchema,
10218
+ candidateInt8: FloorsSchema.nullable(),
10219
+ notes: array(string())
10220
+ }).optional(),
10221
+ int8: object({
10222
+ kept: boolean(),
10223
+ map50Fp16: number().nullable(),
10224
+ map50Int8: number().nullable(),
10225
+ reason: string().nullable()
10226
+ }).optional(),
10227
+ exportsDropped: array(object({
10228
+ export: string(),
10229
+ reason: string()
10230
+ })).optional(),
10231
+ files: array(TrainingResultFileSchema).optional(),
10232
+ bundle: object({
10233
+ path: literal("bundle.tar"),
10234
+ bytes: number().int().nonnegative(),
10235
+ sha256: string().regex(/^[0-9a-f]{64}$/)
10236
+ }).nullable().optional(),
10237
+ catalogDraft: object({
10238
+ base: TrainingCatalogDraftSchema,
10239
+ int8: TrainingCatalogDraftSchema.nullable()
10240
+ }).nullable().optional(),
10241
+ licence: string()
10242
+ });
10243
+ var TrainingStageSchema = _enum([
10244
+ "prepare",
10245
+ "replay",
10246
+ "train",
10247
+ "eval",
10248
+ "export",
10249
+ "package"
10250
+ ]);
10251
+ var EventBase = {
10252
+ v: literal(1),
10253
+ ts: number()
10254
+ };
10255
+ discriminatedUnion("type", [
10256
+ object({
10257
+ ...EventBase,
10258
+ type: literal("stage"),
10259
+ stage: TrainingStageSchema
10260
+ }),
10261
+ object({
10262
+ ...EventBase,
10263
+ type: literal("epoch"),
10264
+ epoch: number().int(),
10265
+ epochs: number().int(),
10266
+ boxLoss: number().nullable().optional(),
10267
+ map50: number().nullable().optional(),
10268
+ map50_95: number().nullable().optional(),
10269
+ etaSec: number().nullable().optional()
10270
+ }),
10271
+ object({
10272
+ ...EventBase,
10273
+ type: literal("metric"),
10274
+ name: string(),
10275
+ value: number()
10276
+ }),
10277
+ object({
10278
+ ...EventBase,
10279
+ type: literal("artifact"),
10280
+ path: string(),
10281
+ bytes: number(),
10282
+ sha256: string()
10283
+ }),
10284
+ object({
10285
+ ...EventBase,
10286
+ type: literal("done"),
10287
+ status: _enum(["succeeded", "failed"]),
10288
+ resultSha256: string().nullable().optional()
10289
+ }),
10290
+ object({
10291
+ ...EventBase,
10292
+ type: literal("error"),
10293
+ stage: string(),
10294
+ code: string(),
10295
+ message: string()
10296
+ })
10297
+ ]);
10298
+ /**
9604
10299
  * What the gate decided about a birth, from the CALLER's point of view.
9605
10300
  *
9606
10301
  * Deliberately not `ConfirmationVerdict`: `undecided` is not a birth decision
@@ -11935,7 +12630,9 @@ var AddonHttpRouteSchema = object({
11935
12630
  "authenticated",
11936
12631
  "admin"
11937
12632
  ]).optional(),
11938
- description: string().optional()
12633
+ description: string().optional(),
12634
+ /** The hub limits this route per client address before the handler runs. */
12635
+ rateLimit: _enum(["auth"]).optional()
11939
12636
  });
11940
12637
  /**
11941
12638
  * Cross-process route invocation envelope. The hub captures the
@@ -12659,6 +13356,37 @@ var BackupDestinationInfoSchema = object({
12659
13356
  lastError: string().optional()
12660
13357
  });
12661
13358
  /**
13359
+ * How an archive is encrypted (operator decision 2026-10-09): to a backup
13360
+ * PUBLIC key the hub holds, so only the operator's secret key opens it.
13361
+ * Absent on a plain `.tar.gz` — every archive made before encryption, or
13362
+ * with it off — which restores without a key.
13363
+ */
13364
+ var BackupArchiveEncryptionSchema = object({
13365
+ /** `x25519-hkdf-aes256gcm-stream-v1`. */
13366
+ scheme: string(),
13367
+ /** 16 hex — the backup key whose secret restores this archive. */
13368
+ keyId: string()
13369
+ });
13370
+ /**
13371
+ * The backup encryption setting. The hub keeps PUBLIC keys only: the active
13372
+ * one new archives are encrypted to, and the retired ones older archives
13373
+ * still need. The secret key is shown once, at `setupEncryption`.
13374
+ */
13375
+ var BackupEncryptionStatusSchema = object({
13376
+ enabled: boolean(),
13377
+ active: object({
13378
+ keyId: string(),
13379
+ publicKey: string(),
13380
+ createdAt: number()
13381
+ }).nullable(),
13382
+ /** Every key ever set up, newest first. */
13383
+ keys: array(object({
13384
+ keyId: string(),
13385
+ createdAt: number(),
13386
+ retiredAt: number().nullable()
13387
+ })).readonly()
13388
+ });
13389
+ /**
12662
13390
  * Per-archive entry returned by `backup.listArchives({ destinationId })`.
12663
13391
  * Same shape the destination drill-in renders. Sourced from the per-
12664
13392
  * location `manifests.json` (no per-archive tarball read required).
@@ -12670,7 +13398,9 @@ var BackupArchiveEntrySchema = object({
12670
13398
  sizeBytes: number(),
12671
13399
  label: string().optional(),
12672
13400
  /** Top-level locations included in the archive (db, addons, tls, …). */
12673
- locations: array(string()).readonly()
13401
+ locations: array(string()).readonly(),
13402
+ /** Present when the archive is encrypted; restore then needs that key. */
13403
+ encryption: BackupArchiveEncryptionSchema.optional()
12674
13404
  });
12675
13405
  var BackupEntrySchema = object({
12676
13406
  id: string(),
@@ -12679,7 +13409,8 @@ var BackupEntrySchema = object({
12679
13409
  label: string().optional(),
12680
13410
  createdAt: number(),
12681
13411
  sizeBytes: number(),
12682
- locations: array(string()).optional()
13412
+ locations: array(string()).optional(),
13413
+ encryption: BackupArchiveEncryptionSchema.optional()
12683
13414
  });
12684
13415
  var ArchiveEntrySchema = object({
12685
13416
  path: string(),
@@ -12868,10 +13599,40 @@ method(_void(), array(BackupDestinationInfoSchema).readonly(), { auth: "admin" }
12868
13599
  * this list and skips entries whose path doesn't start with
12869
13600
  * any of them.
12870
13601
  */
12871
- locations: array(string()).optional()
13602
+ locations: array(string()).optional(),
13603
+ /**
13604
+ * The backup SECRET key, for an encrypted archive (ignored for a plain
13605
+ * one). The archive is decrypted into the hub's private staging
13606
+ * before the restart; the key is not stored. A wrong or missing key
13607
+ * is refused before the archive is downloaded.
13608
+ */
13609
+ backupSecretKey: string().optional()
12872
13610
  }), _void(), {
12873
13611
  kind: "mutation",
12874
13612
  auth: "admin"
13613
+ }), method(_void(), BackupEncryptionStatusSchema, { auth: "admin" }), method(object({}), object({
13614
+ keyId: string(),
13615
+ secretKey: string(),
13616
+ publicKey: string(),
13617
+ createdAt: number(),
13618
+ replacedKeyId: string().nullable()
13619
+ }), {
13620
+ kind: "mutation",
13621
+ auth: "admin"
13622
+ }), method(object({}), object({ disabledKeyId: string().nullable() }), {
13623
+ kind: "mutation",
13624
+ auth: "admin"
13625
+ }), method(object({ backupSecretKey: string() }), object({
13626
+ valid: boolean(),
13627
+ keyId: string().nullable(),
13628
+ /** The hub knows this key (active or retired). */
13629
+ known: boolean(),
13630
+ /** It is the key new archives are encrypted to. */
13631
+ active: boolean(),
13632
+ error: string().optional()
13633
+ }), {
13634
+ kind: "mutation",
13635
+ auth: "admin"
12875
13636
  }), method(object({
12876
13637
  destinationId: string(),
12877
13638
  backupId: string()
@@ -14495,7 +15256,60 @@ var CustomModelDescriptorSchema = object({
14495
15256
  stepId: string(),
14496
15257
  entry: ModelCatalogEntrySchema
14497
15258
  });
14498
- method(_void(), array(CustomModelDescriptorSchema).readonly(), { auth: "admin" });
15259
+ /** One regular file of an imported bundle, as the producer measured it. */
15260
+ var ModelBundleFileSchema = object({
15261
+ /** Relative path inside the bundle tar; an mlpackage member is `<x>.mlpackage/<member>`. */
15262
+ path: string().min(1),
15263
+ bytes: number().int().nonnegative(),
15264
+ sha256: string().regex(/^[0-9a-f]{64}$/)
15265
+ });
15266
+ var ImportModelBundleInputSchema = object({
15267
+ /** The registry provider that keeps the model (Model Studio). */
15268
+ addonId: string(),
15269
+ stepId: string().min(1),
15270
+ /**
15271
+ * The catalog rows to register, complete, every format URL already
15272
+ * `camstack-local://<modelId>/<file>` naming a file of the bundle. One
15273
+ * bundle may carry several rows (a base and its INT8 variant).
15274
+ */
15275
+ entries: array(ModelCatalogEntrySchema).min(1).max(4),
15276
+ /** The bundle tar, offered by the producer over `ctx.peerBytes` (same host). */
15277
+ bundle: object({
15278
+ ticket: PeerBytesTicketSchema,
15279
+ bytes: number().int().positive(),
15280
+ sha256: string().regex(/^[0-9a-f]{64}$/)
15281
+ }),
15282
+ /** Every file the tar must hold; anything missing, extra or different is refused. */
15283
+ files: array(ModelBundleFileSchema).min(1).max(64),
15284
+ /** Convert missing engine formats and push the model to every agent afterwards. */
15285
+ distribute: boolean()
15286
+ });
15287
+ var ImportModelBundleResultSchema = discriminatedUnion("kind", [object({
15288
+ kind: literal("imported"),
15289
+ modelIds: array(string()).readonly(),
15290
+ distributed: array(object({
15291
+ modelId: string(),
15292
+ nodeId: string(),
15293
+ format: _enum(MODEL_FORMATS),
15294
+ ok: boolean(),
15295
+ error: string().optional()
15296
+ })).readonly()
15297
+ }), object({
15298
+ kind: literal("refused"),
15299
+ reason: _enum([
15300
+ "transfer-failed",
15301
+ "checksum-mismatch",
15302
+ "bundle-mismatch",
15303
+ "invalid-entry",
15304
+ "id-taken"
15305
+ ]),
15306
+ detail: string()
15307
+ })]);
15308
+ method(_void(), array(CustomModelDescriptorSchema).readonly(), { auth: "admin" }), method(ImportModelBundleInputSchema, ImportModelBundleResultSchema, {
15309
+ kind: "mutation",
15310
+ auth: "admin",
15311
+ timeoutMs: 30 * 6e4
15312
+ });
14499
15313
  /**
14500
15314
  * Query filter for settings-store collections.
14501
15315
  */
@@ -14974,6 +15788,35 @@ var KeychainKeySourceSchema = object({
14974
15788
  */
14975
15789
  sharesBackupWithDatabase: boolean()
14976
15790
  });
15791
+ /**
15792
+ * One keychain reset, as the Secrets page reports it until the operator
15793
+ * acknowledges it. Never a value: refs, counts and table names only.
15794
+ */
15795
+ var KeychainResetRecordSchema = object({
15796
+ id: string(),
15797
+ at: number(),
15798
+ /** `user:<id>` or {@link KEYCHAIN_RESET_TRIGGER_ACTOR}. */
15799
+ actor: string(),
15800
+ /** Why the keychain was locked when it was reset; `null` when it was not locked. */
15801
+ lockedReason: string().nullable(),
15802
+ /** Values moved into the archive table (ciphertext under the lost key). */
15803
+ archived: number().int(),
15804
+ /** `keychain:secrets-orphaned-<ts>`, or `null` when nothing was stored. */
15805
+ archivedCollection: string().nullable(),
15806
+ /**
15807
+ * `keychain:keys-orphaned-<ts>`: the wrapped data keys of the archive, kept
15808
+ * so the archive can still be opened if the lost master key turns up.
15809
+ */
15810
+ archivedKeysCollection: string().nullable(),
15811
+ /**
15812
+ * `system-settings` keys whose marker the reset cleared — the cluster
15813
+ * secret's: a marker left pointing at an archived value would refuse every
15814
+ * agent forever (D797).
15815
+ */
15816
+ clearedSettingsKeys: array(string()).readonly(),
15817
+ /** When an operator dismissed the notice on the Secrets page; `null` until then. */
15818
+ acknowledgedAt: number().nullable()
15819
+ });
14977
15820
  var KeychainStatusSchema = object({
14978
15821
  keychain: KeychainStateSchema,
14979
15822
  /** The source of the master key in use; `null` while locked. */
@@ -14991,7 +15834,9 @@ var KeychainStatusSchema = object({
14991
15834
  /** Wrapped copies of the data key under a previous master key, kept until purged. */
14992
15835
  retiredWraps: number().int(),
14993
15836
  recoveryKeyDownloadedAt: number().nullable(),
14994
- secretCount: number().int()
15837
+ secretCount: number().int(),
15838
+ /** The most recent reset, acknowledged or not; `null` when the keychain was never reset. */
15839
+ lastReset: KeychainResetRecordSchema.nullable()
14995
15840
  });
14996
15841
  /**
14997
15842
  * Whether a stored value is still pointed at by its owner's settings.
@@ -15013,17 +15858,26 @@ var KeychainAuditActionSchema = _enum([
15013
15858
  "download-recovery-key",
15014
15859
  "delete-orphans",
15015
15860
  "reset",
15861
+ "acknowledge-reset",
15016
15862
  "initialize"
15017
15863
  ]);
15018
15864
  var KeychainAuditEntrySchema = object({
15019
15865
  id: string(),
15020
15866
  at: number(),
15021
15867
  action: KeychainAuditActionSchema,
15022
- /** `addon:<id>` | `user:<id>` | `system`. */
15868
+ /** `addon:<id>` | `user:<id>` | `system` | `trigger-file`. */
15023
15869
  actor: string(),
15024
15870
  ref: string().nullable(),
15025
15871
  detail: string().nullable()
15026
15872
  });
15873
+ var KEYCHAIN_RESET_CONFIRMATION = "RESET KEYCHAIN";
15874
+ /**
15875
+ * Secrets the HUB itself holds (owner `system`) that no settings form shows:
15876
+ * `jwt-signing-key` — the session signing key (D797). It is always "in use",
15877
+ * never an orphan; it is generated on a fresh hub and replaced only through
15878
+ * {@link keychainAdminCapability.methods.setSystemSecret}.
15879
+ */
15880
+ var SystemHeldSecretNameSchema = _enum(["jwt-signing-key"]);
15027
15881
  method(object({}), KeychainStatusSchema, { auth: "admin" }), method(object({}), array(KeychainAdminSecretSchema).readonly(), { auth: "admin" }), method(object({ limit: number().int().min(1).max(500).optional() }), array(KeychainAuditEntrySchema).readonly(), { auth: "admin" }), method(object({ ref: string().min(1) }), object({
15028
15882
  value: string(),
15029
15883
  version: number().int()
@@ -15031,6 +15885,16 @@ method(object({}), KeychainStatusSchema, { auth: "admin" }), method(object({}),
15031
15885
  kind: "mutation",
15032
15886
  auth: "admin",
15033
15887
  caller: "required"
15888
+ }), method(object({
15889
+ name: SystemHeldSecretNameSchema,
15890
+ value: string().min(16)
15891
+ }), object({
15892
+ ref: string(),
15893
+ version: number().int()
15894
+ }), {
15895
+ kind: "mutation",
15896
+ auth: "admin",
15897
+ caller: "required"
15034
15898
  }), method(object({ refs: array(string().min(1)).max(1e3) }), object({
15035
15899
  deleted: array(string()).readonly(),
15036
15900
  kept: array(object({
@@ -15060,13 +15924,20 @@ method(object({}), KeychainStatusSchema, { auth: "admin" }), method(object({}),
15060
15924
  kind: "mutation",
15061
15925
  auth: "admin",
15062
15926
  caller: "required"
15063
- }), method(object({ confirm: literal("RESET KEYCHAIN") }), object({
15927
+ }), method(object({ confirm: literal(KEYCHAIN_RESET_CONFIRMATION) }), object({
15064
15928
  archivedCollection: string().nullable(),
15065
15929
  archived: number().int()
15066
15930
  }), {
15067
15931
  kind: "mutation",
15068
15932
  auth: "admin",
15069
15933
  caller: "required"
15934
+ }), method(object({}), object({
15935
+ reset: KeychainResetRecordSchema.nullable(),
15936
+ pendingReentry: array(KeychainSecretMetaSchema).readonly()
15937
+ }), { auth: "admin" }), method(object({}), object({ acknowledged: boolean() }), {
15938
+ kind: "mutation",
15939
+ auth: "admin",
15940
+ caller: "required"
15070
15941
  });
15071
15942
  method(_void(), object({
15072
15943
  id: string(),
@@ -17737,7 +18608,7 @@ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
17737
18608
  * `login-method` — collection cap through which auth addons contribute
17738
18609
  * their pre-auth login surfaces to the login page. This is the SINGLE,
17739
18610
  * generic mechanism that supersedes the dead `auth.listProviders` reader:
17740
- * every auth addon (OIDC, magic-link, WebAuthn/passkey) registers a
18611
+ * every auth addon (OIDC, WebAuthn/passkey) registers a
17741
18612
  * `login-method` provider and the PUBLIC `auth.listLoginMethods`
17742
18613
  * procedure aggregates them for the unauthenticated login page.
17743
18614
  *
@@ -17745,8 +18616,7 @@ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
17745
18616
  *
17746
18617
  * - `redirect` — a declarative button. The login page renders a generic
17747
18618
  * button that navigates to `startUrl` (an addon-owned HTTP route).
17748
- * Covers OIDC (`/addon/auth-oidc/<id>/start`) and magic-link with
17749
- * ZERO shell-side JS. A future SSO addon plugs in the same way — the
18619
+ * Covers OIDC (`/addon/auth-oidc/<id>/start`) with ZERO shell-side JS. A future SSO addon plugs in the same way — the
17750
18620
  * login page needs NO change.
17751
18621
  *
17752
18622
  * - `widget` — a Module-Federation widget the login page mounts (via
@@ -17765,8 +18635,8 @@ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
17765
18635
  * decision.
17766
18636
  *
17767
18637
  * Every contribution carries a `stage`:
17768
- * - `primary` — shown on the first credentials screen (OIDC /
17769
- * magic-link buttons; a future usernameless passkey).
18638
+ * - `primary` — shown on the first credentials screen (OIDC
18639
+ * buttons; a usernameless passkey).
17770
18640
  * - `second-factor` — shown AFTER the password leg, gated on the
17771
18641
  * returned `factors` (passkey-as-2FA today).
17772
18642
  *
@@ -17793,7 +18663,7 @@ var LoginMethodContributionSchema = discriminatedUnion("kind", [
17793
18663
  * The provider names an external identity a signed-in user can link to
17794
18664
  * their own account (D782): `auth.listLinkableProviders` /
17795
18665
  * `beginExternalLink` offer exactly the redirect methods that set this,
17796
- * whatever their id. Absent / false — a login button only (magic-link).
18666
+ * whatever their id. Absent / false — a login button only.
17797
18667
  */
17798
18668
  linkable: boolean().optional()
17799
18669
  }),
@@ -21610,8 +22480,7 @@ method(object({}), object({ rules: array(NcRuleSchema) }), { auth: "admin" }), m
21610
22480
  * `super_admin` — collapsed onto the single boolean because every
21611
22481
  * non-admin caller is governed by the same scope-check rules; the
21612
22482
  * distinction was only ever used to route role-specific procedures
21613
- * which we no longer have. Agents are admin sessions issued via
21614
- * `createServiceToken`; CLI / webhook integrations are `cst_*` tokens
22483
+ * which we no longer have. CLI / webhook integrations are `cst_*` tokens
21615
22484
  * with `isAdmin: false` + an explicit scope list.
21616
22485
  */
21617
22486
  /** Per-method access flavour. Materialised on every cap method via codegen. */
@@ -23302,6 +24171,9 @@ var RetrainExportFilterSchema = object({
23302
24171
  frameIds: array(string()).max(2e4).optional(),
23303
24172
  /** Only frames in at least one of these named collections. */
23304
24173
  collectionIds: array(string()).max(200).optional(),
24174
+ /** Exactly the frames of this dataset version (and its completeOnly). An
24175
+ * unknown id selects nothing. */
24176
+ datasetVersionId: string().optional(),
23305
24177
  batchId: string().optional(),
23306
24178
  /** Only frames the operator marked complete (all subjects boxed). */
23307
24179
  completeOnly: boolean().optional()
@@ -23469,6 +24341,67 @@ var RetrainLlmAssistResultSchema = discriminatedUnion("kind", [object({
23469
24341
  ]),
23470
24342
  detail: string().optional()
23471
24343
  })]);
24344
+ /** What a dataset version is cut from. Every field narrows. */
24345
+ var RetrainDatasetSelectionSchema = object({
24346
+ deviceIds: array(number()).readonly().optional(),
24347
+ collectionIds: array(string()).max(200).readonly().optional(),
24348
+ frameIds: array(string()).max(2e4).readonly().optional()
24349
+ });
24350
+ /** The counts a dataset is judged by. */
24351
+ var RetrainDatasetStatsSchema = object({
24352
+ frames: number().int(),
24353
+ completeFrames: number().int(),
24354
+ /** `completeFrames / frames`, 0..1. */
24355
+ completeness: number(),
24356
+ /** Boxes to learn (model errors excluded). */
24357
+ subjects: number().int(),
24358
+ modelErrors: number().int(),
24359
+ /** Complete frames with no subject. */
24360
+ hardNegatives: number().int(),
24361
+ /** Subjects per class × camera × day/night. */
24362
+ cells: array(object({
24363
+ macroClass: string(),
24364
+ deviceId: number(),
24365
+ lighting: _enum([
24366
+ "day",
24367
+ "night",
24368
+ "unknown"
24369
+ ]),
24370
+ subjects: number().int(),
24371
+ frames: number().int()
24372
+ })).readonly(),
24373
+ cameras: array(object({
24374
+ deviceId: number(),
24375
+ frames: number().int(),
24376
+ completeFrames: number().int()
24377
+ })).readonly()
24378
+ });
24379
+ /** An immutable dataset version, without its frame list. */
24380
+ var RetrainDatasetVersionSchema = object({
24381
+ id: string(),
24382
+ name: string(),
24383
+ createdAt: number(),
24384
+ selection: RetrainDatasetSelectionSchema,
24385
+ layout: RetrainExportLayoutSchema,
24386
+ completeOnly: boolean(),
24387
+ frameCount: number().int(),
24388
+ /** sha256 of what the frames taught when the version was frozen. */
24389
+ annotationHash: string(),
24390
+ /** The export manifest schema the version was cut under. */
24391
+ manifestSchema: string(),
24392
+ stats: RetrainDatasetStatsSchema
24393
+ });
24394
+ var CreateRetrainDatasetVersionResultSchema = discriminatedUnion("kind", [object({
24395
+ kind: literal("created"),
24396
+ version: RetrainDatasetVersionSchema
24397
+ }), object({
24398
+ kind: literal("refused"),
24399
+ reason: _enum([
24400
+ "empty-name",
24401
+ "duplicate-name",
24402
+ "no-frames"
24403
+ ])
24404
+ })]);
23472
24405
  /** The outcome of a lifecycle move owned by the retrain page. */
23473
24406
  var RetrainTransitionResultSchema = object({
23474
24407
  trackId: string(),
@@ -24258,6 +25191,47 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
24258
25191
  kind: "mutation",
24259
25192
  auth: "admin",
24260
25193
  timeoutMs: 60 * 6e4
25194
+ }), method(object({
25195
+ filter: RetrainExportFilterSchema,
25196
+ layout: RetrainExportLayoutSchema
25197
+ }), object({
25198
+ ticket: PeerBytesTicketSchema,
25199
+ frames: number().int(),
25200
+ annotations: number().int()
25201
+ }), {
25202
+ kind: "mutation",
25203
+ auth: "admin",
25204
+ timeoutMs: 12e4
25205
+ }), method(object({
25206
+ selection: RetrainDatasetSelectionSchema,
25207
+ completeOnly: boolean().optional()
25208
+ }), RetrainDatasetStatsSchema, {
25209
+ kind: "query",
25210
+ auth: "admin"
25211
+ }), method(object({
25212
+ name: string().max(120),
25213
+ selection: RetrainDatasetSelectionSchema,
25214
+ layout: RetrainExportLayoutSchema,
25215
+ completeOnly: boolean()
25216
+ }), CreateRetrainDatasetVersionResultSchema, {
25217
+ kind: "mutation",
25218
+ auth: "admin",
25219
+ timeoutMs: 12e4
25220
+ }), method(object({}), array(RetrainDatasetVersionSchema).readonly(), {
25221
+ kind: "query",
25222
+ auth: "admin"
25223
+ }), method(object({ id: string() }), object({ deleted: boolean() }), {
25224
+ kind: "mutation",
25225
+ auth: "admin"
25226
+ }), method(object({ id: string() }), object({
25227
+ found: boolean(),
25228
+ annotationHash: string(),
25229
+ matches: boolean(),
25230
+ missingFrames: number().int()
25231
+ }), {
25232
+ kind: "query",
25233
+ auth: "admin",
25234
+ timeoutMs: 12e4
24261
25235
  }), method(object({}), array(RetrainAssistProfileSchema).readonly(), {
24262
25236
  kind: "query",
24263
25237
  auth: "admin"
@@ -27796,8 +28770,8 @@ version: string().optional() }), ServerUpdateActionResultSchema, {
27796
28770
  * `smtp-provider` — pluggable email delivery surface.
27797
28771
  *
27798
28772
  * Collection cap: a deployment may install multiple SMTP relays (e.g.
27799
- * one for transactional / one for notifications). Consumers (magic-link,
27800
- * notifier addons, …) walk the collection and pick the first
28773
+ * one for transactional / one for notifications). Consumers (notifier
28774
+ * addons, …) walk the collection and pick the first
27801
28775
  * ready provider OR target a specific addonId.
27802
28776
  *
27803
28777
  * The shape stays small on purpose — `sendEmail` is enough for the
@@ -27976,7 +28950,7 @@ targets: array(object({
27976
28950
  })));
27977
28951
  /**
27978
28952
  * `sso-bridge` — internal hub-only cap that lets SSO-style auth
27979
- * providers (OIDC, SAML, magic-link, …) mint an HMAC-signed token
28953
+ * providers (OIDC, SAML, …) mint an HMAC-signed token
27980
28954
  * carrying the post-callback claims before redirecting back to
27981
28955
  * `/api/auth/sso/finish`.
27982
28956
  *
@@ -28039,7 +29013,14 @@ var SsoBridgeClaimsSchema = object({
28039
29013
  * Verified `iss` of the id_token behind an OIDC login bridge (D782). A
28040
29014
  * subject is unique only per issuer, so a link is bound to it.
28041
29015
  */
28042
- issuer: string().optional()
29016
+ issuer: string().optional(),
29017
+ /**
29018
+ * SHA-256 (hex) of the `camstack_sso_state` cookie the IdP `/start` set in
29019
+ * the browser that began this sign-in. `/api/auth/sso/finish` requires the
29020
+ * request to present the matching cookie — a login bridge is useless in
29021
+ * any other browser.
29022
+ */
29023
+ browserBinding: string().optional()
28043
29024
  });
28044
29025
  method(object({
28045
29026
  claims: SsoBridgeClaimsSchema,
@@ -33943,7 +34924,13 @@ var TopologyNodeSchema = object({
33943
34924
  })).readonly(),
33944
34925
  processes: array(TopologyProcessSchema).readonly(),
33945
34926
  categories: array(TopologyCategorySchema).readonly(),
33946
- rootPackage: TopologyRootPackageSchema.nullable()
34927
+ rootPackage: TopologyRootPackageSchema.nullable(),
34928
+ /**
34929
+ * How an online AGENT reaches the hub (mesh mTLS Release A): `tls` once it has
34930
+ * completed a mutual-TLS handshake, `clear` otherwise. Absent for the hub,
34931
+ * for offline rows and when the hub cannot tell.
34932
+ */
34933
+ meshTransport: _enum(["tls", "clear"]).optional()
33947
34934
  });
33948
34935
  var CapUsageEdgeSchema = object({
33949
34936
  callerAddonId: string(),
@@ -37978,16 +38965,6 @@ var ApiKeySummarySchema = object({
37978
38965
  createdAt: number(),
37979
38966
  lastUsedAt: number().optional()
37980
38967
  });
37981
- var CreateApiKeyInputSchema = object({
37982
- label: string(),
37983
- isAdmin: boolean().default(false),
37984
- allowedProviders: union([array(string()), literal("*")]).optional(),
37985
- allowedDevices: record(string(), union([array(string()), literal("*")])).optional()
37986
- });
37987
- var CreateApiKeyResultSchema = object({
37988
- token: string(),
37989
- record: ApiKeySummarySchema
37990
- });
37991
38968
  var ScopedTokenSummarySchema = object({
37992
38969
  id: string(),
37993
38970
  userId: string(),
@@ -38086,17 +39063,10 @@ method(_void(), array(UserSummarySchema), { auth: "admin" }), method(CreateUserI
38086
39063
  }), UserSummarySchema.extend({ passwordHash: string() }).nullable(), {
38087
39064
  kind: "mutation",
38088
39065
  access: "view"
38089
- }), method(_void(), array(ApiKeySummarySchema), { auth: "admin" }), method(CreateApiKeyInputSchema, CreateApiKeyResultSchema, {
38090
- kind: "mutation",
38091
- auth: "admin",
38092
- access: "create"
38093
- }), method(object({ id: string() }), object({ success: literal(true) }), {
39066
+ }), method(_void(), array(ApiKeySummarySchema), { auth: "admin" }), method(object({ id: string() }), object({ success: literal(true) }), {
38094
39067
  kind: "mutation",
38095
39068
  auth: "admin",
38096
39069
  access: "delete"
38097
- }), method(object({ token: string() }), ApiKeySummarySchema.nullable(), {
38098
- kind: "mutation",
38099
- access: "view"
38100
39070
  }), method(CreateScopedTokenInputSchema, CreateScopedTokenResultSchema, {
38101
39071
  kind: "mutation",
38102
39072
  auth: "admin",
@@ -38170,15 +39140,7 @@ method(_void(), array(UserSummarySchema), { auth: "admin" }), method(CreateUserI
38170
39140
  }).nullable(), { access: "view" }), method(object({ userId: string() }), array(ExternalIdentitySchema), { auth: "admin" }), method(ExternalIdentityKeySchema, object({
38171
39141
  userId: string(),
38172
39142
  issuer: string()
38173
- }).nullable(), { auth: "admin" }), method(ExternalIdentityKeySchema.extend({
38174
- userId: string(),
38175
- issuer: string().min(1),
38176
- label: string().optional()
38177
- }), object({ success: literal(true) }), {
38178
- kind: "mutation",
38179
- auth: "admin",
38180
- access: "create"
38181
- }), method(ExternalIdentityKeySchema.extend({ userId: string() }), object({ success: boolean() }), {
39143
+ }).nullable(), { auth: "admin" }), method(ExternalIdentityKeySchema.extend({ userId: string() }), object({ success: boolean() }), {
38182
39144
  kind: "mutation",
38183
39145
  auth: "admin",
38184
39146
  access: "delete"
@@ -38573,6 +39535,451 @@ DeviceType.Camera, method(object({
38573
39535
  detection: array(ZoneRuleSchema).readonly(),
38574
39536
  package: array(ZoneRuleSchema).readonly()
38575
39537
  });
39538
+ /**
39539
+ * `training-provider` — ONE cloud that can run the CamStack trainer.
39540
+ *
39541
+ * A thin, mockable translation layer: it knows how to run a container with a
39542
+ * GPU, move a dataset in, read the job's stdout and hand artefacts back. It
39543
+ * knows nothing about datasets, splits, floors, cost policy or Model Studio —
39544
+ * those are the `training` orchestrator's (D805). Every rule written there
39545
+ * once is what makes a second provider (RunPod, a local NVIDIA node) a new
39546
+ * manifest entry and nothing else.
39547
+ *
39548
+ * Collection, routed by the `addonId` in every single-row input (the `llm` /
39549
+ * `notification-output` posture); `describe` concat-fans across providers.
39550
+ * Every method is `admin`: these spend money.
39551
+ *
39552
+ * Every cloud object a provider creates is tagged with the orchestrator's
39553
+ * `jobKey`, so a retried submit finds the job it already started instead of
39554
+ * starting a second GPU, and `listJobs` can find orphans.
39555
+ *
39556
+ * Bytes never ride a cap field: the dataset arrives as a `ctx.peerBytes`
39557
+ * ticket the producer (pipeline-analytics) minted, and artefacts leave as a
39558
+ * ticket the provider mints (D613).
39559
+ */
39560
+ var TrainingGpuOptionSchema = object({
39561
+ id: string(),
39562
+ label: string(),
39563
+ /** List price, USD per GPU-hour, before any region multiplier. */
39564
+ usdPerHour: number().nonnegative(),
39565
+ vramGb: number().nonnegative()
39566
+ });
39567
+ var TrainingRegionOptionSchema = object({
39568
+ /** `''` = any region (the provider's choice). */
39569
+ id: string(),
39570
+ label: string(),
39571
+ priceMultiplier: number().positive()
39572
+ });
39573
+ /**
39574
+ * The provider's per-account settings, as the orchestrator reads them. They
39575
+ * live in the PROVIDER addon's settings (operator decision 2026-10-08: they
39576
+ * depend on the user's account), never hard-coded in the orchestrator.
39577
+ */
39578
+ var TrainingProviderDefaultsSchema = object({
39579
+ gpuType: string(),
39580
+ region: string(),
39581
+ costCapUsd: number().nonnegative(),
39582
+ maxRuntimeSec: number().int().positive(),
39583
+ /** Hours a FAILED job's cloud dataset is kept for debugging; 0 = delete at once. */
39584
+ failedDatasetGraceHours: number().nonnegative()
39585
+ });
39586
+ var TrainingProviderDescriptorSchema = object({
39587
+ addonId: string(),
39588
+ /** `modal`, `runpod`, `fake`, … */
39589
+ kind: string(),
39590
+ label: string(),
39591
+ gpuTypes: array(TrainingGpuOptionSchema).readonly(),
39592
+ regions: array(TrainingRegionOptionSchema).readonly(),
39593
+ maxDatasetBytes: number().int().positive(),
39594
+ maxRuntimeSec: number().int().positive(),
39595
+ freeTierNote: string().optional(),
39596
+ /** Where the data goes, in one sentence the confirm dialog repeats. */
39597
+ dataResidencyNote: string(),
39598
+ /** Credentials are present — never the values. */
39599
+ configured: boolean(),
39600
+ defaults: TrainingProviderDefaultsSchema
39601
+ });
39602
+ var TrainingCredentialCheckSchema = object({
39603
+ ok: boolean(),
39604
+ /** Workspace / account name, when the provider says. */
39605
+ account: string().optional(),
39606
+ reason: _enum([
39607
+ "missing",
39608
+ "invalid",
39609
+ "forbidden",
39610
+ "network",
39611
+ "quota"
39612
+ ]).optional(),
39613
+ detail: string().optional()
39614
+ });
39615
+ var ProviderJobStateSchema = _enum([
39616
+ "pending",
39617
+ "starting",
39618
+ "running",
39619
+ "succeeded",
39620
+ "failed",
39621
+ "cancelled",
39622
+ "lost"
39623
+ ]);
39624
+ var ProviderJobStatusSchema = object({
39625
+ jobKey: string(),
39626
+ providerJobId: string().optional(),
39627
+ state: ProviderJobStateSchema,
39628
+ startedAt: number().optional(),
39629
+ endedAt: number().optional(),
39630
+ exitCode: number().int().optional(),
39631
+ failureReason: string().optional(),
39632
+ gpuType: string(),
39633
+ region: string().optional(),
39634
+ billedSeconds: number().nonnegative(),
39635
+ costUsd: number().nonnegative(),
39636
+ /** True when `costUsd` is runtime × list price, not a billing answer. */
39637
+ costIsEstimate: boolean(),
39638
+ lastFetchedAt: number()
39639
+ });
39640
+ /**
39641
+ * The trainer the job runs, by SOURCE revision: the provider turns it into an
39642
+ * image its own way (Modal builds the published Dockerfile at that revision;
39643
+ * a registry-pull provider maps it to a tag). Recorded on the job and echoed
39644
+ * in `result.json`.
39645
+ */
39646
+ var TrainerSourceRefSchema = object({
39647
+ /** Hugging Face repo id, e.g. `camstack/camstack-trainer`. */
39648
+ repo: string().min(1),
39649
+ /** A commit sha (never a branch) — the job must be reproducible. */
39650
+ revision: string().regex(/^[0-9a-f]{7,64}$/)
39651
+ });
39652
+ var JobRef = {
39653
+ addonId: string(),
39654
+ jobKey: string().uuid()
39655
+ };
39656
+ var TrainingLogLineSchema = object({
39657
+ ts: number(),
39658
+ text: string()
39659
+ });
39660
+ method(object({}), array(TrainingProviderDescriptorSchema).readonly(), { auth: "admin" }), method(object({ addonId: string() }), TrainingCredentialCheckSchema, {
39661
+ kind: "mutation",
39662
+ auth: "admin",
39663
+ timeoutMs: 3e4
39664
+ }), method(object({
39665
+ addonId: string(),
39666
+ gpuType: string(),
39667
+ region: string(),
39668
+ datasetBytes: number().int().nonnegative(),
39669
+ gpuSecondsLow: number().nonnegative(),
39670
+ gpuSecondsHigh: number().nonnegative()
39671
+ }), object({
39672
+ usdLow: number().nonnegative(),
39673
+ usdHigh: number().nonnegative(),
39674
+ notes: array(string()).readonly()
39675
+ }), { auth: "admin" }), method(object({
39676
+ ...JobRef,
39677
+ ticket: PeerBytesTicketSchema
39678
+ }), object({
39679
+ bytes: number().int().nonnegative(),
39680
+ sha256: string()
39681
+ }), {
39682
+ kind: "mutation",
39683
+ auth: "admin",
39684
+ timeoutMs: 120 * 6e4
39685
+ }), method(object({
39686
+ ...JobRef,
39687
+ trainer: TrainerSourceRefSchema,
39688
+ jobSpecJson: string().min(2).max(64e3),
39689
+ gpuType: string(),
39690
+ region: string(),
39691
+ maxRuntimeSec: number().int().positive()
39692
+ }), ProviderJobStatusSchema, {
39693
+ kind: "mutation",
39694
+ auth: "admin",
39695
+ timeoutMs: 30 * 6e4
39696
+ }), method(object(JobRef), ProviderJobStatusSchema, {
39697
+ auth: "admin",
39698
+ timeoutMs: 6e4
39699
+ }), method(object({
39700
+ ...JobRef,
39701
+ cursor: string().optional(),
39702
+ max: number().int().min(1).max(500)
39703
+ }), object({
39704
+ lines: array(TrainingLogLineSchema).readonly(),
39705
+ cursor: string()
39706
+ }), {
39707
+ auth: "admin",
39708
+ timeoutMs: 6e4
39709
+ }), method(object(JobRef), object({ ok: literal(true) }), {
39710
+ kind: "mutation",
39711
+ auth: "admin",
39712
+ timeoutMs: 6e4
39713
+ }), method(object(JobRef), object({
39714
+ found: boolean(),
39715
+ text: string().optional()
39716
+ }), {
39717
+ kind: "mutation",
39718
+ auth: "admin",
39719
+ timeoutMs: 5 * 6e4
39720
+ }), method(object({
39721
+ ...JobRef,
39722
+ path: _enum(["bundle.tar"])
39723
+ }), object({ ticket: PeerBytesTicketSchema }), {
39724
+ kind: "mutation",
39725
+ auth: "admin",
39726
+ timeoutMs: 5 * 6e4
39727
+ }), method(object(JobRef), object({ deleted: array(string()).readonly() }), {
39728
+ kind: "mutation",
39729
+ auth: "admin",
39730
+ timeoutMs: 5 * 6e4
39731
+ }), method(object({ addonId: string() }), array(ProviderJobStatusSchema).readonly(), {
39732
+ auth: "admin",
39733
+ timeoutMs: 2 * 6e4
39734
+ });
39735
+ /**
39736
+ * `training` — the cloud-training orchestrator (D805). Hub-only singleton,
39737
+ * provided by `addon-training`.
39738
+ *
39739
+ * It owns what every provider must agree on, written once:
39740
+ *
39741
+ * - **Dataset versions.** Taken over from pipeline-analytics (D796): the rows
39742
+ * live here (D808); pipeline-analytics still CUTS a version (it owns the corpus and
39743
+ * the export plan) and reaches this store through the five row methods
39744
+ * below, so the Retrain page and the export did not change.
39745
+ * - **Jobs.** A persisted state machine, a reconcile loop against the
39746
+ * provider, a cost guard, a daily orphan sweep and the retention rules.
39747
+ * - **The return flow.** Verified artefacts → Model Studio
39748
+ * (`custom-model-registry.importModelBundle`) → canary on cameras →
39749
+ * rollback. Nothing is ever registered automatically.
39750
+ *
39751
+ * Every method is `admin`.
39752
+ */
39753
+ /** A version WITH its frame list — what the export and a job read. */
39754
+ var TrainingDatasetVersionRowSchema = RetrainDatasetVersionSchema.omit({ frameCount: true }).extend({ frameIds: array(string()).max(2e4).readonly() });
39755
+ /** A base model a detector job can fine-tune, and the baseline it is judged against. */
39756
+ var TrainingBaseModelSchema = object({
39757
+ modelId: string(),
39758
+ label: string(),
39759
+ weights: string(),
39760
+ imgsz: number().int(),
39761
+ baselineOnnxUrl: string(),
39762
+ baselineFloors: record(string(), number()),
39763
+ /** The base the fleet runs most — the UI's default. */
39764
+ recommended: boolean()
39765
+ });
39766
+ var TrainingPresetSchema = _enum([
39767
+ "quick",
39768
+ "standard",
39769
+ "thorough"
39770
+ ]);
39771
+ var TrainingJobRequestSchema = object({
39772
+ datasetVersionId: string().min(1),
39773
+ /** The `training-provider` addon that runs it. */
39774
+ addonId: string().min(1),
39775
+ gpuType: string().min(1),
39776
+ region: string(),
39777
+ baseModelId: string().min(1),
39778
+ preset: TrainingPresetSchema,
39779
+ /** Freeze the backbone's first N layers; `null` = the preset's choice. */
39780
+ freeze: number().int().nonnegative().nullable(),
39781
+ /** Cameras held out whole for evaluation; `null` = the orchestrator's default. */
39782
+ holdoutCameras: array(number().int()).nullable()
39783
+ });
39784
+ var TrainingSplitPlanSchema = object({
39785
+ holdoutCameras: array(number().int()).readonly(),
39786
+ /** Used when no camera is held out: the last N days of every camera. */
39787
+ holdoutLastDays: number().int().nonnegative(),
39788
+ /** Holdout subjects per class (camera holdout only; `null` = known only after the split). */
39789
+ holdoutSupport: record(string(), number().int()).nullable(),
39790
+ trainSubjects: number().int()
39791
+ });
39792
+ var TrainingRefusalReasonSchema = _enum([
39793
+ "unknown-dataset",
39794
+ "unknown-provider",
39795
+ "provider-not-configured",
39796
+ "unknown-base-model",
39797
+ "unknown-gpu",
39798
+ "dataset-too-large",
39799
+ "no-training-subjects",
39800
+ "job-already-running"
39801
+ ]);
39802
+ var TrainingJobPlanSchema = object({
39803
+ refusal: object({
39804
+ reason: TrainingRefusalReasonSchema,
39805
+ detail: string()
39806
+ }).nullable(),
39807
+ warnings: array(string()).readonly(),
39808
+ split: TrainingSplitPlanSchema.nullable(),
39809
+ estimate: object({
39810
+ datasetBytes: number().int(),
39811
+ uploadMinutesAt20Mbps: number(),
39812
+ gpuSecondsLow: number(),
39813
+ gpuSecondsHigh: number(),
39814
+ usdLow: number(),
39815
+ usdHigh: number(),
39816
+ notes: array(string()).readonly()
39817
+ }).nullable(),
39818
+ /** Pre-filled from the provider's settings; the operator may lower or raise them. */
39819
+ defaults: object({
39820
+ maxCostUsd: number(),
39821
+ maxRuntimeSec: number().int()
39822
+ }).nullable(),
39823
+ /** The sentence the confirm dialog repeats: where the frames go and when they are deleted. */
39824
+ dataNotice: string()
39825
+ });
39826
+ /**
39827
+ * Orchestrator-owned states, persisted. `uploading` covers exporting the
39828
+ * archive (it is streamed, never staged). Terminal: `failed`, `cancelled`,
39829
+ * `lost`, `expired`, `discarded`. `registered` and `canary` are where a
39830
+ * result lives after the operator acted on it.
39831
+ */
39832
+ var TrainingJobStateSchema = _enum([
39833
+ "uploading",
39834
+ "submitted",
39835
+ "starting",
39836
+ "running",
39837
+ "collecting",
39838
+ "ready",
39839
+ "registered",
39840
+ "canary",
39841
+ "failed",
39842
+ "cancelling",
39843
+ "cancelled",
39844
+ "lost",
39845
+ "expired",
39846
+ "discarded"
39847
+ ]);
39848
+ var TrainingFailureReasonSchema = _enum([
39849
+ "cost-cap",
39850
+ "runtime-cap",
39851
+ "upload-failed",
39852
+ "submit-failed",
39853
+ "trainer-failed",
39854
+ "result-invalid",
39855
+ "checksum-mismatch",
39856
+ "fetch-failed",
39857
+ "provider-error",
39858
+ "hub-restart-during-upload"
39859
+ ]);
39860
+ var TrainingProgressPointSchema = object({
39861
+ epoch: number().int(),
39862
+ map50: number().nullable(),
39863
+ map50_95: number().nullable()
39864
+ });
39865
+ var TrainingCanarySchema = object({
39866
+ deviceIds: array(number().int()).readonly(),
39867
+ since: number(),
39868
+ /** Every override the canary replaced, exactly, so rollback restores it. */
39869
+ previous: array(object({
39870
+ deviceId: number().int(),
39871
+ nodeId: string(),
39872
+ deviceKey: string(),
39873
+ patch: object({
39874
+ modelId: string().optional(),
39875
+ settings: record(string(), unknown()).readonly().optional()
39876
+ }).nullable()
39877
+ })).readonly()
39878
+ });
39879
+ var TrainingJobSchema = object({
39880
+ id: string(),
39881
+ idempotencyKey: string(),
39882
+ name: string(),
39883
+ createdAt: number(),
39884
+ updatedAt: number(),
39885
+ state: TrainingJobStateSchema,
39886
+ stage: TrainingStageSchema.nullable(),
39887
+ failure: object({
39888
+ reason: TrainingFailureReasonSchema,
39889
+ stage: string().nullable(),
39890
+ detail: string()
39891
+ }).nullable(),
39892
+ request: TrainingJobRequestSchema,
39893
+ maxCostUsd: number().nonnegative(),
39894
+ maxRuntimeSec: number().int().positive(),
39895
+ trainer: TrainerSourceRefSchema,
39896
+ datasetLayout: RetrainExportLayoutSchema,
39897
+ dataset: object({
39898
+ bytes: number().int(),
39899
+ sha256: string(),
39900
+ uploadedAt: number()
39901
+ }).nullable(),
39902
+ split: TrainingSplitPlanSchema,
39903
+ provider: object({
39904
+ state: ProviderJobStateSchema.nullable(),
39905
+ providerJobId: string().nullable(),
39906
+ startedAt: number().nullable(),
39907
+ endedAt: number().nullable(),
39908
+ billedSeconds: number(),
39909
+ costUsd: number(),
39910
+ costIsEstimate: boolean(),
39911
+ lastPolledAt: number().nullable()
39912
+ }),
39913
+ progress: object({
39914
+ epoch: number().int().nullable(),
39915
+ epochs: number().int().nullable(),
39916
+ etaSec: number().nullable(),
39917
+ series: array(TrainingProgressPointSchema).readonly()
39918
+ }),
39919
+ /** The last lines of the job's output (≤ 200), newest last. Never frame paths. */
39920
+ logTail: array(string()).readonly(),
39921
+ logCursor: string().nullable(),
39922
+ artifacts: object({
39923
+ bundleBytes: number().int(),
39924
+ bundleSha256: string(),
39925
+ fetchedAt: number(),
39926
+ /** When the staged artefacts are deleted from the hub. */
39927
+ expiresAt: number()
39928
+ }).nullable(),
39929
+ /** When the provider-side copy of the frames was deleted; null while it exists. */
39930
+ cloudDatasetDeletedAt: number().nullable(),
39931
+ /** A failed job's dataset is kept until then (the provider's grace), then deleted. */
39932
+ cloudCleanupDueAt: number().nullable(),
39933
+ /** Model ids registered from this job (base, and int8 when kept). */
39934
+ registeredModelIds: array(string()).readonly(),
39935
+ canary: TrainingCanarySchema.nullable()
39936
+ });
39937
+ var IdInput = object({ id: string().min(1) });
39938
+ method(TrainingDatasetVersionRowSchema, object({ stored: boolean() }), {
39939
+ kind: "mutation",
39940
+ auth: "admin"
39941
+ }), method(IdInput, TrainingDatasetVersionRowSchema.nullable(), { auth: "admin" }), method(object({}), array(RetrainDatasetVersionSchema).readonly(), { auth: "admin" }), method(object({ name: string() }), object({ id: string().nullable() }), { auth: "admin" }), method(IdInput, object({ removed: boolean() }), {
39942
+ kind: "mutation",
39943
+ auth: "admin"
39944
+ }), method(object({}), array(TrainingBaseModelSchema).readonly(), { auth: "admin" }), method(TrainingJobRequestSchema, TrainingJobPlanSchema, {
39945
+ auth: "admin",
39946
+ timeoutMs: 6e4
39947
+ }), method(TrainingJobRequestSchema.extend({
39948
+ name: string().min(1).max(120),
39949
+ maxCostUsd: number().positive(),
39950
+ maxRuntimeSec: number().int().positive(),
39951
+ idempotencyKey: string().min(8).max(80)
39952
+ }), discriminatedUnion("kind", [object({
39953
+ kind: literal("started"),
39954
+ job: TrainingJobSchema
39955
+ }), object({
39956
+ kind: literal("refused"),
39957
+ reason: TrainingRefusalReasonSchema,
39958
+ detail: string()
39959
+ })]), {
39960
+ kind: "mutation",
39961
+ auth: "admin",
39962
+ timeoutMs: 12e4
39963
+ }), method(object({}), array(TrainingJobSchema).readonly(), { auth: "admin" }), method(IdInput, TrainingJobSchema.nullable(), { auth: "admin" }), method(IdInput, TrainingJobSchema, {
39964
+ kind: "mutation",
39965
+ auth: "admin",
39966
+ timeoutMs: 12e4
39967
+ }), method(IdInput, TrainingResultSchema.nullable(), { auth: "admin" }), method(IdInput.extend({ canaryDeviceIds: array(number().int()).readonly() }), TrainingJobSchema, {
39968
+ kind: "mutation",
39969
+ auth: "admin",
39970
+ timeoutMs: 30 * 6e4
39971
+ }), method(IdInput.extend({ deviceIds: array(number().int()).min(1).readonly() }), TrainingJobSchema, {
39972
+ kind: "mutation",
39973
+ auth: "admin",
39974
+ timeoutMs: 12e4
39975
+ }), method(IdInput, TrainingJobSchema, {
39976
+ kind: "mutation",
39977
+ auth: "admin",
39978
+ timeoutMs: 12e4
39979
+ }), method(IdInput, TrainingJobSchema, {
39980
+ kind: "mutation",
39981
+ auth: "admin"
39982
+ });
38576
39983
  SOURCE_CAPS.filter((cap) => cap !== "switch" && cap !== "motion");
38577
39984
  Object.freeze({
38578
39985
  person: .5,
@@ -39196,6 +40603,12 @@ Object.freeze({
39196
40603
  addonId: null,
39197
40604
  access: "create"
39198
40605
  },
40606
+ "backup.checkBackupKey": {
40607
+ capName: "backup",
40608
+ capScope: "system",
40609
+ addonId: null,
40610
+ access: "create"
40611
+ },
39199
40612
  "backup.delete": {
39200
40613
  capName: "backup",
39201
40614
  capScope: "system",
@@ -39208,6 +40621,18 @@ Object.freeze({
39208
40621
  addonId: null,
39209
40622
  access: "delete"
39210
40623
  },
40624
+ "backup.disableEncryption": {
40625
+ capName: "backup",
40626
+ capScope: "system",
40627
+ addonId: null,
40628
+ access: "create"
40629
+ },
40630
+ "backup.getEncryption": {
40631
+ capName: "backup",
40632
+ capScope: "system",
40633
+ addonId: null,
40634
+ access: "view"
40635
+ },
39211
40636
  "backup.getEntries": {
39212
40637
  capName: "backup",
39213
40638
  capScope: "system",
@@ -39262,6 +40687,12 @@ Object.freeze({
39262
40687
  addonId: null,
39263
40688
  access: "create"
39264
40689
  },
40690
+ "backup.setupEncryption": {
40691
+ capName: "backup",
40692
+ capScope: "system",
40693
+ addonId: null,
40694
+ access: "create"
40695
+ },
39265
40696
  "backup.trigger": {
39266
40697
  capName: "backup",
39267
40698
  capScope: "system",
@@ -39814,6 +41245,12 @@ Object.freeze({
39814
41245
  addonId: null,
39815
41246
  access: "create"
39816
41247
  },
41248
+ "customModelRegistry.importModelBundle": {
41249
+ capName: "custom-model-registry",
41250
+ capScope: "system",
41251
+ addonId: null,
41252
+ access: "create"
41253
+ },
39817
41254
  "customModelRegistry.listModels": {
39818
41255
  capName: "custom-model-registry",
39819
41256
  capScope: "system",
@@ -41254,6 +42691,12 @@ Object.freeze({
41254
42691
  addonId: null,
41255
42692
  access: "view"
41256
42693
  },
42694
+ "keychainAdmin.acknowledgeReset": {
42695
+ capName: "keychain-admin",
42696
+ capScope: "system",
42697
+ addonId: null,
42698
+ access: "create"
42699
+ },
41257
42700
  "keychainAdmin.deleteOrphans": {
41258
42701
  capName: "keychain-admin",
41259
42702
  capScope: "system",
@@ -41290,6 +42733,12 @@ Object.freeze({
41290
42733
  addonId: null,
41291
42734
  access: "delete"
41292
42735
  },
42736
+ "keychainAdmin.resetReport": {
42737
+ capName: "keychain-admin",
42738
+ capScope: "system",
42739
+ addonId: null,
42740
+ access: "delete"
42741
+ },
41293
42742
  "keychainAdmin.reveal": {
41294
42743
  capName: "keychain-admin",
41295
42744
  capScope: "system",
@@ -41302,6 +42751,12 @@ Object.freeze({
41302
42751
  addonId: null,
41303
42752
  access: "create"
41304
42753
  },
42754
+ "keychainAdmin.setSystemSecret": {
42755
+ capName: "keychain-admin",
42756
+ capScope: "system",
42757
+ addonId: null,
42758
+ access: "create"
42759
+ },
41305
42760
  "keychainAdmin.status": {
41306
42761
  capName: "keychain-admin",
41307
42762
  capScope: "system",
@@ -42748,6 +44203,12 @@ Object.freeze({
42748
44203
  addonId: null,
42749
44204
  access: "create"
42750
44205
  },
44206
+ "pipelineAnalytics.createRetrainDatasetVersion": {
44207
+ capName: "pipeline-analytics",
44208
+ capScope: "device",
44209
+ addonId: null,
44210
+ access: "create"
44211
+ },
42751
44212
  "pipelineAnalytics.deleteDeviceEvents": {
42752
44213
  capName: "pipeline-analytics",
42753
44214
  capScope: "device",
@@ -42760,6 +44221,12 @@ Object.freeze({
42760
44221
  addonId: null,
42761
44222
  access: "delete"
42762
44223
  },
44224
+ "pipelineAnalytics.deleteRetrainDatasetVersion": {
44225
+ capName: "pipeline-analytics",
44226
+ capScope: "device",
44227
+ addonId: null,
44228
+ access: "delete"
44229
+ },
42763
44230
  "pipelineAnalytics.deleteTracks": {
42764
44231
  capName: "pipeline-analytics",
42765
44232
  capScope: "device",
@@ -42982,6 +44449,12 @@ Object.freeze({
42982
44449
  addonId: null,
42983
44450
  access: "view"
42984
44451
  },
44452
+ "pipelineAnalytics.listRetrainDatasetVersions": {
44453
+ capName: "pipeline-analytics",
44454
+ capScope: "device",
44455
+ addonId: null,
44456
+ access: "view"
44457
+ },
42985
44458
  "pipelineAnalytics.listRetrainFrames": {
42986
44459
  capName: "pipeline-analytics",
42987
44460
  capScope: "device",
@@ -43012,6 +44485,12 @@ Object.freeze({
43012
44485
  addonId: null,
43013
44486
  access: "view"
43014
44487
  },
44488
+ "pipelineAnalytics.offerRetrainArchive": {
44489
+ capName: "pipeline-analytics",
44490
+ capScope: "device",
44491
+ addonId: null,
44492
+ access: "create"
44493
+ },
43015
44494
  "pipelineAnalytics.ownersWithMedia": {
43016
44495
  capName: "pipeline-analytics",
43017
44496
  capScope: "device",
@@ -43024,6 +44503,12 @@ Object.freeze({
43024
44503
  addonId: null,
43025
44504
  access: "create"
43026
44505
  },
44506
+ "pipelineAnalytics.previewRetrainDataset": {
44507
+ capName: "pipeline-analytics",
44508
+ capScope: "device",
44509
+ addonId: null,
44510
+ access: "view"
44511
+ },
43027
44512
  "pipelineAnalytics.proposeRetrainAnnotations": {
43028
44513
  capName: "pipeline-analytics",
43029
44514
  capScope: "device",
@@ -43162,6 +44647,12 @@ Object.freeze({
43162
44647
  addonId: null,
43163
44648
  access: "create"
43164
44649
  },
44650
+ "pipelineAnalytics.verifyRetrainDatasetVersion": {
44651
+ capName: "pipeline-analytics",
44652
+ capScope: "device",
44653
+ addonId: null,
44654
+ access: "view"
44655
+ },
43165
44656
  "pipelineAnalytics.wipeAllAnalytics": {
43166
44657
  capName: "pipeline-analytics",
43167
44658
  capScope: "device",
@@ -45538,6 +47029,174 @@ Object.freeze({
45538
47029
  addonId: null,
45539
47030
  access: "view"
45540
47031
  },
47032
+ "training.canaryResult": {
47033
+ capName: "training",
47034
+ capScope: "system",
47035
+ addonId: null,
47036
+ access: "create"
47037
+ },
47038
+ "training.cancelJob": {
47039
+ capName: "training",
47040
+ capScope: "system",
47041
+ addonId: null,
47042
+ access: "create"
47043
+ },
47044
+ "training.discardResult": {
47045
+ capName: "training",
47046
+ capScope: "system",
47047
+ addonId: null,
47048
+ access: "create"
47049
+ },
47050
+ "training.findDatasetVersionIdByName": {
47051
+ capName: "training",
47052
+ capScope: "system",
47053
+ addonId: null,
47054
+ access: "view"
47055
+ },
47056
+ "training.getDatasetVersion": {
47057
+ capName: "training",
47058
+ capScope: "system",
47059
+ addonId: null,
47060
+ access: "view"
47061
+ },
47062
+ "training.getJob": {
47063
+ capName: "training",
47064
+ capScope: "system",
47065
+ addonId: null,
47066
+ access: "view"
47067
+ },
47068
+ "training.getJobResult": {
47069
+ capName: "training",
47070
+ capScope: "system",
47071
+ addonId: null,
47072
+ access: "view"
47073
+ },
47074
+ "training.listBaseModels": {
47075
+ capName: "training",
47076
+ capScope: "system",
47077
+ addonId: null,
47078
+ access: "view"
47079
+ },
47080
+ "training.listDatasetVersions": {
47081
+ capName: "training",
47082
+ capScope: "system",
47083
+ addonId: null,
47084
+ access: "view"
47085
+ },
47086
+ "training.listJobs": {
47087
+ capName: "training",
47088
+ capScope: "system",
47089
+ addonId: null,
47090
+ access: "view"
47091
+ },
47092
+ "training.planJob": {
47093
+ capName: "training",
47094
+ capScope: "system",
47095
+ addonId: null,
47096
+ access: "view"
47097
+ },
47098
+ "training.putDatasetVersion": {
47099
+ capName: "training",
47100
+ capScope: "system",
47101
+ addonId: null,
47102
+ access: "create"
47103
+ },
47104
+ "training.registerResult": {
47105
+ capName: "training",
47106
+ capScope: "system",
47107
+ addonId: null,
47108
+ access: "create"
47109
+ },
47110
+ "training.removeDatasetVersion": {
47111
+ capName: "training",
47112
+ capScope: "system",
47113
+ addonId: null,
47114
+ access: "delete"
47115
+ },
47116
+ "training.rollbackCanary": {
47117
+ capName: "training",
47118
+ capScope: "system",
47119
+ addonId: null,
47120
+ access: "create"
47121
+ },
47122
+ "training.startJob": {
47123
+ capName: "training",
47124
+ capScope: "system",
47125
+ addonId: null,
47126
+ access: "create"
47127
+ },
47128
+ "trainingProvider.cancelJob": {
47129
+ capName: "training-provider",
47130
+ capScope: "system",
47131
+ addonId: null,
47132
+ access: "create"
47133
+ },
47134
+ "trainingProvider.cleanupJob": {
47135
+ capName: "training-provider",
47136
+ capScope: "system",
47137
+ addonId: null,
47138
+ access: "create"
47139
+ },
47140
+ "trainingProvider.describe": {
47141
+ capName: "training-provider",
47142
+ capScope: "system",
47143
+ addonId: null,
47144
+ access: "view"
47145
+ },
47146
+ "trainingProvider.estimateJob": {
47147
+ capName: "training-provider",
47148
+ capScope: "system",
47149
+ addonId: null,
47150
+ access: "view"
47151
+ },
47152
+ "trainingProvider.getJob": {
47153
+ capName: "training-provider",
47154
+ capScope: "system",
47155
+ addonId: null,
47156
+ access: "view"
47157
+ },
47158
+ "trainingProvider.listJobEvents": {
47159
+ capName: "training-provider",
47160
+ capScope: "system",
47161
+ addonId: null,
47162
+ access: "view"
47163
+ },
47164
+ "trainingProvider.listJobs": {
47165
+ capName: "training-provider",
47166
+ capScope: "system",
47167
+ addonId: null,
47168
+ access: "view"
47169
+ },
47170
+ "trainingProvider.offerArtifact": {
47171
+ capName: "training-provider",
47172
+ capScope: "system",
47173
+ addonId: null,
47174
+ access: "create"
47175
+ },
47176
+ "trainingProvider.readResult": {
47177
+ capName: "training-provider",
47178
+ capScope: "system",
47179
+ addonId: null,
47180
+ access: "create"
47181
+ },
47182
+ "trainingProvider.submitJob": {
47183
+ capName: "training-provider",
47184
+ capScope: "system",
47185
+ addonId: null,
47186
+ access: "create"
47187
+ },
47188
+ "trainingProvider.uploadDataset": {
47189
+ capName: "training-provider",
47190
+ capScope: "system",
47191
+ addonId: null,
47192
+ access: "create"
47193
+ },
47194
+ "trainingProvider.validateCredentials": {
47195
+ capName: "training-provider",
47196
+ capScope: "system",
47197
+ addonId: null,
47198
+ access: "create"
47199
+ },
45541
47200
  "turnProvider.getTurnServers": {
45542
47201
  capName: "turn-provider",
45543
47202
  capScope: "system",
@@ -45562,12 +47221,6 @@ Object.freeze({
45562
47221
  addonId: null,
45563
47222
  access: "create"
45564
47223
  },
45565
- "userManagement.createApiKey": {
45566
- capName: "user-management",
45567
- capScope: "system",
45568
- addonId: null,
45569
- access: "create"
45570
- },
45571
47224
  "userManagement.createScopedToken": {
45572
47225
  capName: "user-management",
45573
47226
  capScope: "system",
@@ -45604,12 +47257,6 @@ Object.freeze({
45604
47257
  addonId: null,
45605
47258
  access: "view"
45606
47259
  },
45607
- "userManagement.linkExternalIdentity": {
45608
- capName: "user-management",
45609
- capScope: "system",
45610
- addonId: null,
45611
- access: "create"
45612
- },
45613
47260
  "userManagement.listApiKeys": {
45614
47261
  capName: "user-management",
45615
47262
  capScope: "system",
@@ -45712,12 +47359,6 @@ Object.freeze({
45712
47359
  addonId: null,
45713
47360
  access: "create"
45714
47361
  },
45715
- "userManagement.validateApiKey": {
45716
- capName: "user-management",
45717
- capScope: "system",
45718
- addonId: null,
45719
- access: "view"
45720
- },
45721
47362
  "userManagement.validateCredentials": {
45722
47363
  capName: "user-management",
45723
47364
  capScope: "system",
@@ -49831,6 +51472,11 @@ Object.freeze({
49831
51472
  form: "single",
49832
51473
  optional: false
49833
51474
  }],
51475
+ "training.canaryResult": [{
51476
+ name: "deviceIds",
51477
+ form: "array",
51478
+ optional: false
51479
+ }],
49834
51480
  "update.getStatus": [{
49835
51481
  name: "deviceId",
49836
51482
  form: "single",
@@ -50559,6 +52205,8 @@ var STATE_SUMMARY_VARS = [
50559
52205
  [...RULE_TEXT],
50560
52206
  [...RULE_TEXT],
50561
52207
  [...RULE_TEXT],
52208
+ [...RULE_TEXT],
52209
+ [...RULE_TEXT],
50562
52210
  ([...RULE_TEXT], [...UPDATES]),
50563
52211
  ([...RULE_TEXT], [...PACKAGE_UPDATES]),
50564
52212
  ([...RULE_TEXT], [...PACKAGE_UPDATES]),