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