@camstack/addon-export-alexa 1.2.139 → 1.2.141

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.
@@ -5406,7 +5406,7 @@ var ZodIssueCode = {
5406
5406
  var ZodFirstPartyTypeKind;
5407
5407
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
5408
5408
  //#endregion
5409
- //#region ../types/dist/sleep-Cr5YOk3m.mjs
5409
+ //#region ../types/dist/sleep-r3RWkGVx.mjs
5410
5410
  /**
5411
5411
  * The audio chunk plane's byte format, and the ONE expansion from a coded
5412
5412
  * window to float samples (D455).
@@ -5523,7 +5523,7 @@ function isKeychainStoredField(field) {
5523
5523
  var SECRET_CLEAR = { $secretClear: true };
5524
5524
  /** The `'***'` token D634 redaction writes for non-admins. */
5525
5525
  var LEGACY_DEVICE_REDACTION = "***";
5526
- function isRecord$1(value) {
5526
+ function isRecord$2(value) {
5527
5527
  return typeof value === "object" && value !== null && !Array.isArray(value);
5528
5528
  }
5529
5529
  function makeSecretMarker(ref) {
@@ -5534,12 +5534,12 @@ function makeSecretMarker(ref) {
5534
5534
  }
5535
5535
  /** A stored marker: an object whose `$secret` is a non-empty string. */
5536
5536
  function isSecretMarker(value) {
5537
- if (!isRecord$1(value)) return false;
5537
+ if (!isRecord$2(value)) return false;
5538
5538
  const ref = value["$secret"];
5539
5539
  return typeof ref === "string" && ref.length > 0;
5540
5540
  }
5541
5541
  function isSecretClear(value) {
5542
- return isRecord$1(value) && value["$secretClear"] === true;
5542
+ return isRecord$2(value) && value["$secretClear"] === true;
5543
5543
  }
5544
5544
  /**
5545
5545
  * The UI view of a stored secret field value: a marker becomes "set", inline
@@ -6055,6 +6055,13 @@ function globalSecretScope() {
6055
6055
  function encodeSegment(value) {
6056
6056
  return encodeURIComponent(value);
6057
6057
  }
6058
+ function decodeSegment(value) {
6059
+ try {
6060
+ return decodeURIComponent(value);
6061
+ } catch {
6062
+ return null;
6063
+ }
6064
+ }
6058
6065
  /**
6059
6066
  * The field path of a value inside an array item, addressed by the item's id:
6060
6067
  * `arrayItemFieldPath('providers', 'authentik', 'clientSecret')` →
@@ -6063,6 +6070,75 @@ function encodeSegment(value) {
6063
6070
  function arrayItemFieldPath(arrayKey, itemId, fieldKey) {
6064
6071
  return `${arrayKey}[${encodeSegment(itemId)}].${fieldKey}`;
6065
6072
  }
6073
+ function parseScope(segments) {
6074
+ switch (segments[0]) {
6075
+ case "global": return {
6076
+ scope: GLOBAL_SCOPE,
6077
+ used: 1
6078
+ };
6079
+ case "node": {
6080
+ const nodeId = segments[1] !== void 0 ? decodeSegment(segments[1]) : null;
6081
+ return nodeId === null || nodeId.length === 0 ? null : {
6082
+ scope: {
6083
+ kind: "node",
6084
+ nodeId
6085
+ },
6086
+ used: 2
6087
+ };
6088
+ }
6089
+ case "device": {
6090
+ const raw = segments[1];
6091
+ if (raw === void 0 || !/^\d+$/.test(raw)) return null;
6092
+ return {
6093
+ scope: {
6094
+ kind: "device",
6095
+ deviceId: Number(raw)
6096
+ },
6097
+ used: 2
6098
+ };
6099
+ }
6100
+ case "integration": {
6101
+ const id = segments[1] !== void 0 ? decodeSegment(segments[1]) : null;
6102
+ return id === null || id.length === 0 ? null : {
6103
+ scope: {
6104
+ kind: "integration",
6105
+ integrationId: id
6106
+ },
6107
+ used: 2
6108
+ };
6109
+ }
6110
+ case "row": {
6111
+ const collection = segments[1] !== void 0 ? decodeSegment(segments[1]) : null;
6112
+ const rowId = segments[2] !== void 0 ? decodeSegment(segments[2]) : null;
6113
+ if (collection === null || rowId === null || collection.length === 0 || rowId.length === 0) return null;
6114
+ return {
6115
+ scope: {
6116
+ kind: "row",
6117
+ collection,
6118
+ rowId
6119
+ },
6120
+ used: 3
6121
+ };
6122
+ }
6123
+ default: return null;
6124
+ }
6125
+ }
6126
+ /** Take a ref apart; `null` when it is not a well-formed ref. */
6127
+ function parseSecretRef(ref) {
6128
+ if (!ref.startsWith("secret://")) return null;
6129
+ const segments = ref.slice(9).split("/");
6130
+ const owner = segments[0] !== void 0 ? decodeSegment(segments[0]) : null;
6131
+ if (owner === null || owner.length === 0) return null;
6132
+ const parsed = parseScope(segments.slice(1));
6133
+ if (parsed === null) return null;
6134
+ const fieldPath = segments.slice(1 + parsed.used).join("/");
6135
+ if (fieldPath.length === 0) return null;
6136
+ return {
6137
+ owner,
6138
+ scope: parsed.scope,
6139
+ fieldPath
6140
+ };
6141
+ }
6066
6142
  /** A write to a secret path could not be stored in the keychain, so it was refused. */
6067
6143
  var KeychainWriteRefusedError = class extends Error {
6068
6144
  fieldPath;
@@ -6073,7 +6149,7 @@ var KeychainWriteRefusedError = class extends Error {
6073
6149
  }
6074
6150
  };
6075
6151
  var KEEP = { kind: "keep" };
6076
- function isRecord(value) {
6152
+ function isRecord$1(value) {
6077
6153
  return typeof value === "object" && value !== null && !Array.isArray(value);
6078
6154
  }
6079
6155
  function defaultMintId() {
@@ -6086,7 +6162,7 @@ function collectSecretMarkerRefs(value, out = []) {
6086
6162
  return out;
6087
6163
  }
6088
6164
  if (Array.isArray(value)) for (const item of value) collectSecretMarkerRefs(item, out);
6089
- else if (isRecord(value)) for (const child of Object.values(value)) collectSecretMarkerRefs(child, out);
6165
+ else if (isRecord$1(value)) for (const child of Object.values(value)) collectSecretMarkerRefs(child, out);
6090
6166
  return out;
6091
6167
  }
6092
6168
  async function storedValueEquals(secrets, marker, candidate) {
@@ -6141,7 +6217,7 @@ function rowId(row, idKey) {
6141
6217
  return null;
6142
6218
  }
6143
6219
  async function writeArray(ctx, node, incoming, stored, fieldPath) {
6144
- const storedRows = Array.isArray(stored) ? stored.filter(isRecord) : [];
6220
+ const storedRows = Array.isArray(stored) ? stored.filter(isRecord$1) : [];
6145
6221
  if (!Array.isArray(incoming)) {
6146
6222
  ctx.deletes.push(...collectSecretMarkerRefs(storedRows));
6147
6223
  return {
@@ -6157,7 +6233,7 @@ async function writeArray(ctx, node, incoming, stored, fieldPath) {
6157
6233
  const kept = /* @__PURE__ */ new Set();
6158
6234
  const rows = [];
6159
6235
  for (const row of incoming) {
6160
- if (!isRecord(row)) {
6236
+ if (!isRecord$1(row)) {
6161
6237
  rows.push(row);
6162
6238
  continue;
6163
6239
  }
@@ -6182,7 +6258,7 @@ async function writeNode(ctx, node, incoming, stored, fieldPath) {
6182
6258
  case "leaf": return writeLeaf(ctx, incoming, stored, fieldPath);
6183
6259
  case "array": return writeArray(ctx, node, incoming, stored, fieldPath);
6184
6260
  case "object": {
6185
- if (!isRecord(incoming)) {
6261
+ if (!isRecord$1(incoming)) {
6186
6262
  if (incoming === void 0) return KEEP;
6187
6263
  ctx.deletes.push(...collectSecretMarkerRefs(stored));
6188
6264
  return {
@@ -6190,7 +6266,7 @@ async function writeNode(ctx, node, incoming, stored, fieldPath) {
6190
6266
  value: incoming
6191
6267
  };
6192
6268
  }
6193
- const storedObj = isRecord(stored) ? stored : {};
6269
+ const storedObj = isRecord$1(stored) ? stored : {};
6194
6270
  return {
6195
6271
  kind: "value",
6196
6272
  value: await writeMembers(ctx, node.children, incoming, storedObj, (m) => `${fieldPath}.${m}`)
@@ -6249,12 +6325,19 @@ async function transformSecretWrite(input) {
6249
6325
  }
6250
6326
  };
6251
6327
  }
6328
+ /** Is `ref` one of `owner`'s refs? */
6329
+ function isSecretRefOwnedBy(ref, owner) {
6330
+ return parseSecretRef(ref)?.owner === owner;
6331
+ }
6252
6332
  /**
6253
6333
  * Replace every marker in `value` with its keychain value. Returns the SAME
6254
6334
  * reference when there is no marker (no allocation, no keychain call).
6255
6335
  */
6256
- async function resolveSecretMarkers(value, secrets) {
6257
- const refs = collectSecretMarkerRefs(value);
6336
+ async function resolveSecretMarkers(value, secrets, options = {}) {
6337
+ const keepMarker = options.unresolved === "keep-marker";
6338
+ const owner = options.ownedBy;
6339
+ const inScope = (ref) => owner === void 0 || isSecretRefOwnedBy(ref, owner);
6340
+ const refs = collectSecretMarkerRefs(value).filter(inScope);
6258
6341
  if (refs.length === 0) return {
6259
6342
  value,
6260
6343
  unresolved: []
@@ -6278,10 +6361,18 @@ async function resolveSecretMarkers(value, secrets) {
6278
6361
  }
6279
6362
  const substitute = (v) => {
6280
6363
  if (isSecretMarker(v)) {
6364
+ if (!inScope(v.$secret)) return {
6365
+ keep: true,
6366
+ value: v
6367
+ };
6281
6368
  const answer = answers[v.$secret];
6282
- return answer?.kind === "value" ? {
6369
+ if (answer?.kind === "value") return {
6283
6370
  keep: true,
6284
6371
  value: answer.value
6372
+ };
6373
+ return keepMarker ? {
6374
+ keep: true,
6375
+ value: v
6285
6376
  } : {
6286
6377
  keep: false,
6287
6378
  value: void 0
@@ -6298,7 +6389,7 @@ async function resolveSecretMarkers(value, secrets) {
6298
6389
  value: items
6299
6390
  };
6300
6391
  }
6301
- if (isRecord(v)) {
6392
+ if (isRecord$1(v)) {
6302
6393
  const out = {};
6303
6394
  for (const [k, child] of Object.entries(v)) {
6304
6395
  const s = substitute(child);
@@ -6319,14 +6410,152 @@ async function resolveSecretMarkers(value, secrets) {
6319
6410
  unresolved
6320
6411
  };
6321
6412
  }
6322
- function touchesTree(tree, patch) {
6323
- if (tree.size === 0) return false;
6324
- for (const key of Object.keys(patch)) {
6325
- const at = key.indexOf("@");
6326
- if (tree.has(at > 0 ? key.slice(0, at) : key)) return true;
6413
+ /** An addon tried to replace a stored secret it could not read. Nothing was written. */
6414
+ var SecretOverwriteRefusedError = class extends Error {
6415
+ ref;
6416
+ reason;
6417
+ constructor(ref, reason) {
6418
+ 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.`);
6419
+ this.ref = ref;
6420
+ this.reason = reason;
6421
+ this.name = "SecretOverwriteRefusedError";
6422
+ }
6423
+ };
6424
+ function isRecord(value) {
6425
+ return typeof value === "object" && value !== null && !Array.isArray(value);
6426
+ }
6427
+ function resolvedValue(pass, marker) {
6428
+ const answer = pass.answers[marker.$secret];
6429
+ return answer?.kind === "value" ? answer.value : null;
6430
+ }
6431
+ async function atMarker(pass, incoming, stored) {
6432
+ if (incoming === null) return stored;
6433
+ if (typeof incoming !== "string") return incoming;
6434
+ if (incoming === resolvedValue(pass, stored)) return stored;
6435
+ const intent = classifySecretWrite(incoming);
6436
+ if (intent.kind !== "set") return stored;
6437
+ const ref = stored.$secret;
6438
+ if (!isSecretRefOwnedBy(ref, pass.secrets.owner)) return incoming;
6439
+ const answer = pass.answers[ref];
6440
+ 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);
6441
+ try {
6442
+ await pass.secrets.put(ref, intent.value);
6443
+ } catch (err) {
6444
+ throw new KeychainWriteRefusedError(ref, err);
6445
+ }
6446
+ pass.changedRefs.push(ref);
6447
+ return stored;
6448
+ }
6449
+ function inArray(pass, incoming, stored) {
6450
+ return incoming.map((item, index) => {
6451
+ const twin = stored[index];
6452
+ if (isSecretMarker(twin)) return typeof item === "string" && item === resolvedValue(pass, twin) ? twin : item;
6453
+ if (isRecord(item) && isRecord(twin)) return inArrayRow(pass, item, twin);
6454
+ if (Array.isArray(item) && Array.isArray(twin)) return inArray(pass, item, twin);
6455
+ return item;
6456
+ });
6457
+ }
6458
+ function inArrayRow(pass, incoming, stored) {
6459
+ const out = { ...incoming };
6460
+ for (const [key, value] of Object.entries(incoming)) {
6461
+ const twin = stored[key];
6462
+ if (isSecretMarker(twin)) {
6463
+ if (typeof value === "string" && value === resolvedValue(pass, twin)) out[key] = twin;
6464
+ } else if (isRecord(value) && isRecord(twin)) out[key] = inArrayRow(pass, value, twin);
6465
+ else if (Array.isArray(value) && Array.isArray(twin)) out[key] = inArray(pass, value, twin);
6466
+ }
6467
+ return out;
6468
+ }
6469
+ async function walk(pass, incoming, stored) {
6470
+ if (isSecretMarker(stored)) return atMarker(pass, incoming, stored);
6471
+ if (Array.isArray(incoming) && Array.isArray(stored)) return inArray(pass, incoming, stored);
6472
+ if (!isRecord(incoming) || !isRecord(stored)) return incoming;
6473
+ const out = { ...incoming };
6474
+ for (const [key, value] of Object.entries(incoming)) out[key] = await walk(pass, value, stored[key]);
6475
+ return out;
6476
+ }
6477
+ /** Restore markers a write-back carries as values. See the file doc. */
6478
+ async function restoreUnchangedSecrets(input) {
6479
+ const refs = [];
6480
+ for (const key of Object.keys(input.patch)) collectSecretMarkerRefs(input.stored[key], refs);
6481
+ const owned = refs.filter((ref) => isSecretRefOwnedBy(ref, input.secrets.owner));
6482
+ if (owned.length === 0) return {
6483
+ patch: input.patch,
6484
+ changedRefs: []
6485
+ };
6486
+ const pass = {
6487
+ secrets: input.secrets,
6488
+ answers: await input.secrets.resolve([...new Set(owned)]),
6489
+ operatorWrite: input.operatorWrite,
6490
+ changedRefs: []
6491
+ };
6492
+ const out = {};
6493
+ for (const [key, value] of Object.entries(input.patch)) out[key] = await walk(pass, value, input.stored[key]);
6494
+ return {
6495
+ patch: out,
6496
+ changedRefs: pass.changedRefs
6497
+ };
6498
+ }
6499
+ /** Structural equality over JSON-shaped values (key order does not matter). */
6500
+ function isJsonEqual(a, b) {
6501
+ if (Object.is(a, b)) return true;
6502
+ if (Array.isArray(a)) return Array.isArray(b) && a.length === b.length && a.every((v, i) => isJsonEqual(v, b[i]));
6503
+ if (isRecord(a) && isRecord(b)) {
6504
+ const keys = Object.keys(a);
6505
+ if (keys.length !== Object.keys(b).length) return false;
6506
+ return keys.every((k) => Object.prototype.hasOwnProperty.call(b, k) && isJsonEqual(a[k], b[k]));
6327
6507
  }
6328
6508
  return false;
6329
6509
  }
6510
+ /** The patch without the keys whose value already equals the stored one. */
6511
+ function dropUnchangedKeys(patch, stored) {
6512
+ const out = {};
6513
+ for (const [key, value] of Object.entries(patch)) {
6514
+ if (Object.prototype.hasOwnProperty.call(stored, key) && isJsonEqual(value, stored[key])) continue;
6515
+ out[key] = value;
6516
+ }
6517
+ return out;
6518
+ }
6519
+ /** The top-level keys of a blob that hold at least one of `owner`'s markers. */
6520
+ function markerKeysOf(blob, owner) {
6521
+ const keys = /* @__PURE__ */ new Set();
6522
+ for (const [key, value] of Object.entries(blob)) if (collectSecretMarkerRefs(value).some((ref) => isSecretRefOwnedBy(ref, owner))) keys.add(key);
6523
+ return keys;
6524
+ }
6525
+ function nodeFromStored(value, owner) {
6526
+ if (isSecretMarker(value)) return isSecretRefOwnedBy(value.$secret, owner) ? { kind: "leaf" } : null;
6527
+ if (!isRecord(value)) return null;
6528
+ const children = /* @__PURE__ */ new Map();
6529
+ for (const [key, child] of Object.entries(value)) {
6530
+ const node = nodeFromStored(child, owner);
6531
+ if (node !== null) children.set(key, node);
6532
+ }
6533
+ return children.size > 0 ? {
6534
+ kind: "object",
6535
+ children
6536
+ } : null;
6537
+ }
6538
+ /**
6539
+ * The declared secret tree, widened by every place the STORED blob holds a
6540
+ * marker under one of `keys` — so a marker the schema no longer declares (or
6541
+ * never declared: Wyze before b4906cec6) still gets the save path's
6542
+ * KEEP / SET / CLEAR semantics instead of being overwritten by whatever the
6543
+ * addon writes. Markers inside arrays are not added: a row has no id field to
6544
+ * match by unless the schema declares one. Only `owner`'s markers count: a
6545
+ * builtin that keeps another addon's marker (device-manager) never takes it
6546
+ * over.
6547
+ */
6548
+ function widenTreeWithStoredMarkers(declared, stored, keys, owner) {
6549
+ const added = /* @__PURE__ */ new Map();
6550
+ for (const key of keys) {
6551
+ const at = key.indexOf("@");
6552
+ const base = at > 0 ? key.slice(0, at) : key;
6553
+ if (declared.has(base) || added.has(base)) continue;
6554
+ const node = nodeFromStored(stored[key], owner);
6555
+ if (node !== null) added.set(base, node);
6556
+ }
6557
+ return added.size === 0 ? declared : new Map([...declared, ...added]);
6558
+ }
6330
6559
  /** The blob as stored now; a failed read REFUSES the write instead of guessing. */
6331
6560
  async function readStoredAddonBlob(raw) {
6332
6561
  const threeWay = raw.readAddonStoreResult;
@@ -6335,7 +6564,41 @@ async function readStoredAddonBlob(raw) {
6335
6564
  if (result.kind === "failed") throw new Error(`settings write refused: the stored blob could not be read (${result.error})`);
6336
6565
  return result.kind === "missing" ? {} : result.value;
6337
6566
  }
6338
- function createSecretAwareSettings(raw, opts) {
6567
+ function touchesTree(tree, patch) {
6568
+ if (tree.size === 0) return false;
6569
+ for (const key of Object.keys(patch)) {
6570
+ const at = key.indexOf("@");
6571
+ if (tree.has(at > 0 ? key.slice(0, at) : key)) return true;
6572
+ }
6573
+ return false;
6574
+ }
6575
+ /**
6576
+ * Which top-level keys of each store held markers when last seen. `undefined`
6577
+ * for a store not seen yet: its first write reads it, to be safe.
6578
+ */
6579
+ var MarkerKeyIndex = class {
6580
+ owner;
6581
+ byStore = /* @__PURE__ */ new Map();
6582
+ constructor(owner) {
6583
+ this.owner = owner;
6584
+ }
6585
+ seen(store, blob) {
6586
+ this.byStore.set(store, markerKeysOf(blob, this.owner));
6587
+ }
6588
+ wrote(store, patch) {
6589
+ const keys = this.byStore.get(store);
6590
+ if (keys === void 0) return;
6591
+ const now = markerKeysOf(patch, this.owner);
6592
+ for (const key of Object.keys(patch)) if (now.has(key)) keys.add(key);
6593
+ else keys.delete(key);
6594
+ }
6595
+ mayHoldMarkers(store, patch) {
6596
+ const keys = this.byStore.get(store);
6597
+ if (keys === void 0) return true;
6598
+ return Object.keys(patch).some((key) => keys.has(key));
6599
+ }
6600
+ };
6601
+ function createHandle(raw, opts) {
6339
6602
  const chains = /* @__PURE__ */ new Map();
6340
6603
  const serialize = (key, fn) => {
6341
6604
  const next = (chains.get(key) ?? Promise.resolve()).then(fn, fn);
@@ -6346,46 +6609,130 @@ function createSecretAwareSettings(raw, opts) {
6346
6609
  });
6347
6610
  return next;
6348
6611
  };
6349
- const write = async (chainKey, tree, scope, patch, readStored, rawWrite) => {
6350
- if (!touchesTree(tree, patch)) return rawWrite(patch);
6351
- return serialize(chainKey, async () => {
6612
+ const index = new MarkerKeyIndex(opts.secrets.owner);
6613
+ const resolveRead = async (store, blob) => {
6614
+ index.seen(store, blob);
6615
+ const { value, unresolved } = await resolveSecretMarkers(blob, opts.secrets, {
6616
+ unresolved: "keep-marker",
6617
+ ownedBy: opts.secrets.owner
6618
+ });
6619
+ if (unresolved.length > 0) opts.onUnresolved?.(unresolved);
6620
+ return value;
6621
+ };
6622
+ const write = async (store, declared, scope, patch, readStored, rawWrite) => {
6623
+ if (!touchesTree(declared, patch) && !index.mayHoldMarkers(store, patch)) {
6624
+ await rawWrite(patch);
6625
+ index.wrote(store, patch);
6626
+ return { changed: true };
6627
+ }
6628
+ return serialize(store, async () => {
6352
6629
  const stored = await readStored();
6630
+ index.seen(store, stored);
6631
+ const operatorWrite = opts.isOperatorWrite?.() === true;
6632
+ const restored = await restoreUnchangedSecrets({
6633
+ patch,
6634
+ stored,
6635
+ secrets: opts.secrets,
6636
+ operatorWrite
6637
+ });
6353
6638
  const result = await transformSecretWrite({
6354
- tree,
6639
+ tree: widenTreeWithStoredMarkers(declared, stored, Object.keys(restored.patch), opts.secrets.owner),
6355
6640
  secrets: opts.secrets,
6356
- patch,
6641
+ patch: restored.patch,
6357
6642
  stored,
6358
6643
  ...scope !== void 0 ? { scope } : {},
6359
- operatorWrite: opts.isOperatorWrite?.() === true
6644
+ operatorWrite
6360
6645
  });
6361
- if (Object.keys(result.patch).length > 0) await rawWrite(result.patch);
6646
+ const effective = dropUnchangedKeys(result.patch, stored);
6647
+ const wroteBlob = Object.keys(effective).length > 0;
6648
+ if (wroteBlob) {
6649
+ await rawWrite(effective);
6650
+ index.wrote(store, effective);
6651
+ }
6362
6652
  const { orphaned } = await result.afterWrite();
6363
6653
  if (orphaned.length > 0) opts.onOrphaned(orphaned);
6654
+ return { changed: wroteBlob || restored.changedRefs.length > 0 };
6364
6655
  });
6365
6656
  };
6366
- const wrapped = {
6367
- writeAddonStore: (patch) => write("addon", opts.addonTree(), void 0, patch, () => readStoredAddonBlob(raw), (p) => raw.writeAddonStore(p)),
6368
- writeDeviceStore: (deviceId, patch) => write(`device:${deviceId}`, opts.deviceTree(), {
6369
- kind: "device",
6370
- deviceId
6371
- }, patch, () => raw.readDeviceStore(deviceId), (p) => raw.writeDeviceStore(deviceId, p))
6657
+ const writeAddon = (patch) => write("addon", opts.addonTree(), void 0, patch, () => readStoredAddonBlob(raw), (p) => raw.writeAddonStore(p));
6658
+ const readAddonStoreResult = raw.readAddonStoreResult;
6659
+ const readAddonStoreKeyResult = raw.readAddonStoreKeyResult;
6660
+ const readDeviceStoreBatch = raw.readDeviceStoreBatch;
6661
+ const overrides = {
6662
+ readAddonStore: async () => resolveRead("addon", await raw.readAddonStore()),
6663
+ ...readAddonStoreResult !== void 0 ? { readAddonStoreResult: async () => {
6664
+ const result = await readAddonStoreResult.call(raw);
6665
+ return result.kind === "value" ? {
6666
+ kind: "value",
6667
+ value: await resolveRead("addon", result.value)
6668
+ } : result;
6669
+ } } : {},
6670
+ ...readAddonStoreKeyResult !== void 0 ? { readAddonStoreKeyResult: async (key) => {
6671
+ const result = await readAddonStoreKeyResult.call(raw, key);
6672
+ if (result.kind !== "present") return result;
6673
+ const { value, unresolved } = await resolveSecretMarkers({ [key]: result.value }, opts.secrets, {
6674
+ unresolved: "keep-marker",
6675
+ ownedBy: opts.secrets.owner
6676
+ });
6677
+ if (unresolved.length > 0) opts.onUnresolved?.(unresolved);
6678
+ return {
6679
+ kind: "present",
6680
+ value: value[key]
6681
+ };
6682
+ } } : {},
6683
+ readDeviceStore: async (deviceId) => resolveRead(`device:${deviceId}`, await raw.readDeviceStore(deviceId)),
6684
+ ...readDeviceStoreBatch !== void 0 ? { readDeviceStoreBatch: async (deviceIds) => {
6685
+ const rows = await readDeviceStoreBatch.call(raw, deviceIds);
6686
+ const out = /* @__PURE__ */ new Map();
6687
+ for (const [deviceId, blob] of rows) out.set(deviceId, await resolveRead(`device:${deviceId}`, blob));
6688
+ return out;
6689
+ } } : {},
6690
+ writeAddonStore: async (patch) => {
6691
+ await writeAddon(patch);
6692
+ },
6693
+ writeDeviceStore: async (deviceId, patch) => {
6694
+ await write(`device:${deviceId}`, opts.deviceTree(), {
6695
+ kind: "device",
6696
+ deviceId
6697
+ }, patch, () => raw.readDeviceStore(deviceId), (p) => raw.writeDeviceStore(deviceId, p));
6698
+ }
6699
+ };
6700
+ return {
6701
+ settings: new Proxy(raw, { get(target, prop, receiver) {
6702
+ if (typeof prop === "string" && Object.prototype.hasOwnProperty.call(overrides, prop)) return Reflect.get(overrides, prop);
6703
+ const value = Reflect.get(target, prop, receiver);
6704
+ return typeof value === "function" ? value.bind(target) : value;
6705
+ } }),
6706
+ raw: {
6707
+ readAddonStore: async () => {
6708
+ const blob = await raw.readAddonStore();
6709
+ index.seen("addon", blob);
6710
+ return blob;
6711
+ },
6712
+ readDeviceStore: async (deviceId) => {
6713
+ const blob = await raw.readDeviceStore(deviceId);
6714
+ index.seen(`device:${deviceId}`, blob);
6715
+ return blob;
6716
+ }
6717
+ },
6718
+ writeAddonStore: writeAddon
6372
6719
  };
6373
- return new Proxy(raw, { get(target, prop, receiver) {
6374
- if (prop === "writeAddonStore") return wrapped.writeAddonStore;
6375
- if (prop === "writeDeviceStore") return wrapped.writeDeviceStore;
6376
- const value = Reflect.get(target, prop, receiver);
6377
- return typeof value === "function" ? value.bind(target) : value;
6378
- } });
6379
6720
  }
6380
- /** The context the addon sees: identical, except that its settings writes are secret-aware. */
6381
- function withSecretAwareSettings(context, opts) {
6721
+ /** The context the addon sees, plus the private raw view and write outcome. */
6722
+ function createSecretAwareContext(context, opts) {
6382
6723
  const raw = context.settings;
6383
- if (raw === void 0) return context;
6384
- const settings = createSecretAwareSettings(raw, opts);
6385
- return new Proxy(context, { get(target, prop, receiver) {
6386
- if (prop === "settings") return settings;
6387
- return Reflect.get(target, prop, receiver);
6388
- } });
6724
+ if (raw === void 0) return {
6725
+ context,
6726
+ handle: null
6727
+ };
6728
+ const handle = createHandle(raw, opts);
6729
+ return {
6730
+ context: new Proxy(context, { get(target, prop, receiver) {
6731
+ if (prop === "settings") return handle.settings;
6732
+ return Reflect.get(target, prop, receiver);
6733
+ } }),
6734
+ handle
6735
+ };
6389
6736
  }
6390
6737
  var LEAF = { kind: "leaf" };
6391
6738
  var DEFAULT_ITEM_ID_KEY = "id";
@@ -6560,6 +6907,14 @@ var BaseAddon = class {
6560
6907
  _secretChangeUnsub = null;
6561
6908
  /** >0 while an OPERATOR's settings write is being applied. */
6562
6909
  _operatorWriteDepth = 0;
6910
+ /**
6911
+ * The keychain-aware settings handle (D798). Its `raw` view is the ONLY way
6912
+ * to the marker-bearing blobs and stays private to this class: the form
6913
+ * hydrate and config resolution need markers, addon code never does.
6914
+ */
6915
+ _secretSettings = null;
6916
+ /** Refs an addon-facing read could not resolve — each is logged once per process. */
6917
+ _loggedUnresolvedReads = /* @__PURE__ */ new Set();
6563
6918
  constructor(defaults) {
6564
6919
  this.defaults = defaults;
6565
6920
  this._config = { ...defaults };
@@ -6596,13 +6951,21 @@ var BaseAddon = class {
6596
6951
  }
6597
6952
  async initialize(context) {
6598
6953
  const secrets = context.secrets;
6599
- this._ctx = secrets !== void 0 ? withSecretAwareSettings(context, {
6600
- secrets,
6601
- addonTree: () => this.addonSecretTree(),
6602
- deviceTree: () => this.deviceSecretTree(),
6603
- onOrphaned: (refs) => context.logger.warn("keychain refs dropped by a settings write could not be deleted", { meta: { refs: [...refs] } }),
6604
- isOperatorWrite: () => this._operatorWriteDepth > 0
6605
- }) : context;
6954
+ if (secrets !== void 0) {
6955
+ const { context: wrapped, handle } = createSecretAwareContext(context, {
6956
+ secrets,
6957
+ addonTree: () => this.addonSecretTree(),
6958
+ deviceTree: () => this.deviceSecretTree(),
6959
+ onOrphaned: (refs) => context.logger.warn("keychain refs dropped by a settings write could not be deleted", { meta: { refs: [...refs] } }),
6960
+ isOperatorWrite: () => this._operatorWriteDepth > 0,
6961
+ onUnresolved: (unresolved) => this.logUnresolvedRead(unresolved)
6962
+ });
6963
+ this._ctx = wrapped;
6964
+ this._secretSettings = handle;
6965
+ } else {
6966
+ this._ctx = context;
6967
+ this._secretSettings = null;
6968
+ }
6606
6969
  await this.resolveConfig();
6607
6970
  if (secrets !== void 0) this._secretChangeUnsub = secrets.onChange((ref) => {
6608
6971
  if (this._configSecretRefs.has(ref)) this.scheduleSecretReresolve(SECRET_CHANGE_DEBOUNCE_MS);
@@ -6719,11 +7082,8 @@ var BaseAddon = class {
6719
7082
  async getGlobalSettings(overlay, cap, nodeId) {
6720
7083
  const schema = this.globalSettingsSchema(cap);
6721
7084
  if (!schema) return { sections: [] };
6722
- const projected = await this.resolveGlobalStore(nodeId, cap);
6723
- return hydrateSchema(schema, overlay ? {
6724
- ...projected,
6725
- ...overlay
6726
- } : projected, { inlineSecretsAsViews: true });
7085
+ const projected = await this.readRawProjectedStore(nodeId, cap);
7086
+ return hydrateSchema(schema, overlay ? await this.overlayKeepingMarkers(projected, overlay) : projected, { inlineSecretsAsViews: true });
6727
7087
  }
6728
7088
  /**
6729
7089
  * The integration-level view of this addon's settings: exactly the sections
@@ -6768,7 +7128,7 @@ var BaseAddon = class {
6768
7128
  });
6769
7129
  }
6770
7130
  if (sections.length === 0) return null;
6771
- const projected = await this.resolveGlobalStore(nodeId);
7131
+ const projected = await this.readRawProjectedStore(nodeId);
6772
7132
  return hydrateSchema({
6773
7133
  ...schema,
6774
7134
  sections
@@ -6785,12 +7145,50 @@ var BaseAddon = class {
6785
7145
  * the store for custom option logic (option narrowing, value snapping) to
6786
7146
  * read it per-node — never `ctx.settings.readAddonStore()` directly.
6787
7147
  * `nodeId` omitted ⇒ the local node (node-blind injection from ctx).
7148
+ *
7149
+ * Keychain values come back RESOLVED (D798): a secret reads as its value,
7150
+ * never as a `{ $secret }` marker. One the keychain cannot serve right now
7151
+ * stays a marker — "stored, unavailable" (`isSecretMarker()` is true, and it
7152
+ * is listed in {@link unresolvedSecrets}) — never `''` and never absent, so
7153
+ * it cannot be mistaken for "nothing stored, mint a new one". Writing the
7154
+ * resolved blob back is a no-op for every unchanged secret.
6788
7155
  */
6789
7156
  async resolveGlobalStore(nodeId, cap) {
6790
7157
  const raw = await this._ctx?.settings?.readAddonStore() ?? {};
7158
+ return this.projectForNode(raw, nodeId, cap);
7159
+ }
7160
+ projectForNode(store, nodeId, cap) {
6791
7161
  const keys = this.perNodeKeys(cap);
6792
7162
  const node = normalizeNodeId(nodeId ?? this._ctx?.kernel?.localNodeId);
6793
- return keys.size > 0 ? projectStore(raw, keys, node) : raw;
7163
+ return keys.size > 0 ? projectStore(store, keys, node) : store;
7164
+ }
7165
+ /** The PROJECTED store with its markers — the form hydrate only (D798). */
7166
+ async readRawProjectedStore(nodeId, cap) {
7167
+ const raw = await this.rawSettings()?.readAddonStore() ?? {};
7168
+ return this.projectForNode(raw, nodeId, cap);
7169
+ }
7170
+ /**
7171
+ * `{ ...stored, ...overlay }`, except that an overlay member equal to the
7172
+ * RESOLVED stored one keeps the stored (marker-bearing) member — so a form
7173
+ * hydrated from a resolved overlay still shows a secret as "set", never as
7174
+ * its value.
7175
+ */
7176
+ async overlayKeepingMarkers(stored, overlay) {
7177
+ const secrets = this._ctx?.secrets;
7178
+ const merged = {
7179
+ ...stored,
7180
+ ...overlay
7181
+ };
7182
+ if (secrets === void 0 || collectSecretMarkerRefs(stored).length === 0) return merged;
7183
+ const { value: resolved } = await resolveSecretMarkers(stored, secrets, {
7184
+ unresolved: "keep-marker",
7185
+ ownedBy: secrets.owner
7186
+ });
7187
+ for (const key of Object.keys(overlay)) {
7188
+ if (collectSecretMarkerRefs(stored[key]).length === 0) continue;
7189
+ if (isJsonEqual(overlay[key], resolved[key])) merged[key] = stored[key];
7190
+ }
7191
+ return merged;
6794
7192
  }
6795
7193
  /**
6796
7194
  * Whether ONE global key of this addon's store was written, read three-way
@@ -6855,8 +7253,12 @@ var BaseAddon = class {
6855
7253
  async clearSecrets(keys, nodeId) {
6856
7254
  const tree = this.addonSecretTree();
6857
7255
  const keychain = this._ctx?.secrets !== void 0;
7256
+ const stored = keychain ? await this.readAddonStoreWithRetry() : {};
6858
7257
  const patch = {};
6859
- for (const key of keys) patch[key] = keychain && tree.has(key) ? SECRET_CLEAR : "";
7258
+ for (const key of keys) {
7259
+ const keychainStored = tree.has(key) || collectSecretMarkerRefs(stored[key]).length > 0;
7260
+ patch[key] = keychain && keychainStored ? SECRET_CLEAR : "";
7261
+ }
6860
7262
  await this.applyGlobalPatch(patch, nodeId);
6861
7263
  }
6862
7264
  async applyGlobalPatch(barePatch, nodeId) {
@@ -6864,7 +7266,11 @@ var BaseAddon = class {
6864
7266
  const localNode = normalizeNodeId(this._ctx?.kernel?.localNodeId);
6865
7267
  const target = normalizeNodeId(nodeId ?? this._ctx?.kernel?.localNodeId);
6866
7268
  const scoped = keys.size > 0 ? scopePatch(barePatch, keys, target) : barePatch;
6867
- await this._ctx?.settings?.writeAddonStore(scoped);
7269
+ const handle = this._secretSettings;
7270
+ if (handle !== null) {
7271
+ const { changed } = await handle.writeAddonStore(scoped);
7272
+ if (!changed) return;
7273
+ } else await this._ctx?.settings?.writeAddonStore(scoped);
6868
7274
  if (target !== localNode) return;
6869
7275
  await this.resolveConfig();
6870
7276
  await this.onConfigChanged();
@@ -6917,7 +7323,7 @@ var BaseAddon = class {
6917
7323
  async getDeviceSettings(deviceId) {
6918
7324
  const schema = this.deviceSettingsSchema();
6919
7325
  if (!schema) return { sections: [] };
6920
- return hydrateSchema(schema, await this._ctx?.settings?.readDeviceStore(deviceId) ?? {}, { inlineSecretsAsViews: true });
7326
+ return hydrateSchema(schema, await this.rawSettings()?.readDeviceStore(deviceId) ?? {}, { inlineSecretsAsViews: true });
6921
7327
  }
6922
7328
  async updateDeviceSettings(deviceId, patch) {
6923
7329
  await this._ctx?.settings?.writeDeviceStore(deviceId, patch);
@@ -7089,7 +7495,7 @@ var BaseAddon = class {
7089
7495
  key,
7090
7496
  schema,
7091
7497
  fallback,
7092
- read: async () => this.resolveStoredSecrets(await this._ctx?.settings?.readDeviceStore(deviceId) ?? {}, false),
7498
+ read: async () => this.resolveStoredSecrets(await this.rawSettings()?.readDeviceStore(deviceId) ?? {}, false),
7093
7499
  write: async (patch) => {
7094
7500
  await this._ctx?.settings?.writeDeviceStore(deviceId, patch);
7095
7501
  },
@@ -7151,6 +7557,23 @@ var BaseAddon = class {
7151
7557
  }
7152
7558
  return value;
7153
7559
  }
7560
+ /**
7561
+ * The marker-bearing settings reads (D798) — private on purpose. Without a
7562
+ * keychain the context's own view is already raw.
7563
+ */
7564
+ rawSettings() {
7565
+ return this._secretSettings?.raw ?? this._ctx?.settings;
7566
+ }
7567
+ /** An addon-facing read met markers it could not resolve: say so once per ref. */
7568
+ logUnresolvedRead(unresolved) {
7569
+ const fresh = unresolved.filter((u) => !this._loggedUnresolvedReads.has(u.ref));
7570
+ if (fresh.length === 0) return;
7571
+ for (const u of fresh) this._loggedUnresolvedReads.add(u.ref);
7572
+ 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) => ({
7573
+ ref: u.ref,
7574
+ reason: u.reason
7575
+ })) } });
7576
+ }
7154
7577
  /** Re-resolve the config (a keychain-only change, or a retry) and apply it. */
7155
7578
  scheduleSecretReresolve(delayMs) {
7156
7579
  const timerOf = delayMs === SECRET_CHANGE_DEBOUNCE_MS ? "_secretChangeTimer" : "_secretRetryTimer";
@@ -7177,7 +7600,7 @@ var BaseAddon = class {
7177
7600
  * `{}` (defaults) — the addon's first successful patch will rehydrate.
7178
7601
  */
7179
7602
  async readAddonStoreWithRetry() {
7180
- const settings = this._ctx?.settings;
7603
+ const settings = this.rawSettings();
7181
7604
  if (!settings) return {};
7182
7605
  const delaysMs = [
7183
7606
  150,
@@ -9604,6 +10027,278 @@ var CameraSwitchGroupSchema = object({
9604
10027
  fetchedAt: number()
9605
10028
  });
9606
10029
  /**
10030
+ * The trainer contract — what the hub hands the cloud trainer and what it
10031
+ * gets back (cloud training, D805+).
10032
+ *
10033
+ * The trainer (`hf/camstack-trainer`, published as the Hugging Face repo
10034
+ * `camstack/camstack-trainer`) is a separate AGPL program the hub never
10035
+ * imports: `job.json` goes in, files come out, and progress is `CAMSTACK_EVENT`
10036
+ * lines on stdout. These schemas are the hub's half of that boundary; the
10037
+ * trainer's pydantic models (and the JSON Schemas generated from them under
10038
+ * `hf/camstack-trainer/schemas/`) are the other half. A change here is a
10039
+ * change there, in the same piece of work.
10040
+ *
10041
+ * No `.default()` anywhere: defaults do not run on the addon cap path, so the
10042
+ * orchestrator fills every field of a job spec explicitly.
10043
+ */
10044
+ var TRAINING_JOB_SCHEMA = "camstack.training/v1";
10045
+ var TRAINING_RESULT_SCHEMA = "camstack.training-result/v1";
10046
+ /** What the trainer can export. Edge TPU is a later, separate image. */
10047
+ var TrainingExportSchema = _enum([
10048
+ "onnx",
10049
+ "openvino-fp16",
10050
+ "openvino-int8",
10051
+ "coreml-fp16"
10052
+ ]);
10053
+ var FloorsSchema = record(string(), number().min(0).max(1));
10054
+ object({
10055
+ schema: literal(TRAINING_JOB_SCHEMA),
10056
+ jobKey: string().uuid(),
10057
+ target: object({
10058
+ kind: literal("detector"),
10059
+ step: literal("object-detection")
10060
+ }),
10061
+ base: object({
10062
+ modelId: string().min(1),
10063
+ /** Ultralytics weights id, e.g. `yolov9m.pt`. */
10064
+ weights: string().min(1),
10065
+ imgsz: number().int().positive()
10066
+ }),
10067
+ baseline: object({
10068
+ modelId: string().min(1),
10069
+ /** The baseline ONNX the holdout comparison runs; public mirror URL. */
10070
+ onnxUrl: string().url(),
10071
+ imgsz: number().int().positive(),
10072
+ floors: FloorsSchema
10073
+ }),
10074
+ dataset: object({
10075
+ versionId: string().min(1),
10076
+ annotationHash: string(),
10077
+ /** sha256 of the uploaded archive; the trainer refuses a mismatch (exit 65). */
10078
+ sha256: string().regex(/^[0-9a-f]{64}$/)
10079
+ }),
10080
+ split: object({
10081
+ holdoutCameras: array(number().int()),
10082
+ /** When no camera is held out: the last N days of every camera. */
10083
+ holdoutLastDays: number().int().nonnegative(),
10084
+ valFraction: number().min(0).max(.5),
10085
+ seed: number().int()
10086
+ }),
10087
+ hyper: object({
10088
+ epochs: number().int().positive(),
10089
+ batch: number().int().positive(),
10090
+ lr0: number().positive(),
10091
+ /** Layers frozen from the start of the backbone; 0 = none. */
10092
+ freeze: number().int().nonnegative(),
10093
+ patience: number().int().nonnegative(),
10094
+ seed: number().int()
10095
+ }),
10096
+ replay: object({
10097
+ source: literal("coco2017"),
10098
+ count: number().int().nonnegative()
10099
+ }),
10100
+ exports: array(TrainingExportSchema).min(1),
10101
+ calibration: object({ maxFrames: number().int().positive() }),
10102
+ floors: object({
10103
+ minSupport: number().int().positive(),
10104
+ clamp: number().min(0).max(1)
10105
+ }),
10106
+ int8Gate: object({ maxMap50Drop: number().min(0).max(1) }),
10107
+ catalog: object({
10108
+ id: string().regex(/^[a-z0-9][a-z0-9-]{2,80}$/),
10109
+ name: string().min(1).max(160)
10110
+ })
10111
+ });
10112
+ /** One regular file of the bundle. An mlpackage contributes one row per member. */
10113
+ var TrainingResultFileSchema = object({
10114
+ path: string().min(1),
10115
+ bytes: number().int().nonnegative(),
10116
+ sha256: string().regex(/^[0-9a-f]{64}$/),
10117
+ format: _enum([
10118
+ "onnx",
10119
+ "openvino",
10120
+ "coreml",
10121
+ "pt"
10122
+ ]),
10123
+ variant: _enum(["base", "int8"])
10124
+ });
10125
+ var DraftFormatSchema = object({
10126
+ /** RELATIVE path inside the bundle; the hub rewrites it to `camstack-local://`. */
10127
+ url: string().min(1),
10128
+ sizeMB: number().nonnegative(),
10129
+ isDirectory: boolean().optional(),
10130
+ files: array(string()).optional(),
10131
+ runtimes: array(literal("python")).optional(),
10132
+ revision: string().min(1)
10133
+ });
10134
+ /** The trainer's half of a catalog entry; the hub completes it (labels, licence, group). */
10135
+ var TrainingCatalogDraftSchema = object({
10136
+ id: string().min(1),
10137
+ name: string().min(1),
10138
+ description: string(),
10139
+ labels: array(unknown()),
10140
+ inputSize: object({
10141
+ width: number().int().positive(),
10142
+ height: number().int().positive()
10143
+ }),
10144
+ preprocessMode: literal("letterbox"),
10145
+ defaultClassFloors: FloorsSchema,
10146
+ formats: object({
10147
+ onnx: DraftFormatSchema.optional(),
10148
+ openvino: DraftFormatSchema.optional(),
10149
+ coreml: DraftFormatSchema.optional()
10150
+ })
10151
+ });
10152
+ /** One class of one model's holdout report (the eval harness's summary). */
10153
+ var TrainingEvalClassSchema = object({
10154
+ positives: number().int(),
10155
+ floor: number().nullable(),
10156
+ tp: number().int(),
10157
+ fp: number().int(),
10158
+ fn: number().int(),
10159
+ precision: number().nullable(),
10160
+ recall: number().nullable(),
10161
+ ap50: number().nullable(),
10162
+ recallByCamera: record(string(), number().nullable()).optional(),
10163
+ recallByLight: record(string(), number().nullable()).optional(),
10164
+ fpByCamera: record(string(), number()).optional(),
10165
+ smallFound: number().int().optional(),
10166
+ smallTotal: number().int().optional()
10167
+ }).passthrough();
10168
+ var TrainingEvalReportSchema = object({
10169
+ frames: number().int(),
10170
+ classes: record(string(), TrainingEvalClassSchema)
10171
+ }).passthrough();
10172
+ /**
10173
+ * A succeeded result carries every block; a failed one carries the error and
10174
+ * whatever was known by then — the other blocks are ABSENT, not null. The
10175
+ * orchestrator checks the blocks it needs before it trusts a success.
10176
+ */
10177
+ var TrainingResultSchema = object({
10178
+ schema: literal(TRAINING_RESULT_SCHEMA),
10179
+ jobKey: string(),
10180
+ status: _enum(["succeeded", "failed"]),
10181
+ error: object({
10182
+ stage: string(),
10183
+ code: string(),
10184
+ message: string()
10185
+ }).nullable(),
10186
+ trainer: object({
10187
+ version: string(),
10188
+ revision: string()
10189
+ }),
10190
+ toolchain: record(string(), string().nullable()),
10191
+ dataset: object({
10192
+ versionId: string(),
10193
+ annotationHash: string(),
10194
+ sha256: string(),
10195
+ frames: object({
10196
+ train: number().int(),
10197
+ val: number().int(),
10198
+ holdout: number().int()
10199
+ }),
10200
+ holdoutCameras: array(number().int()),
10201
+ replayImages: number().int()
10202
+ }).optional(),
10203
+ training: object({
10204
+ epochsRun: number().int(),
10205
+ bestEpoch: number().int(),
10206
+ bestMap50: number(),
10207
+ bestMap50_95: number(),
10208
+ seconds: number()
10209
+ }).optional(),
10210
+ evaluation: object({
10211
+ holdoutFrames: number().int(),
10212
+ baseline: TrainingEvalReportSchema.nullable(),
10213
+ candidate: TrainingEvalReportSchema.nullable(),
10214
+ candidateInt8: TrainingEvalReportSchema.nullable(),
10215
+ recallDeltaByCamera: record(string(), record(string(), number())).nullable(),
10216
+ map50: record(string(), number().nullable())
10217
+ }).optional(),
10218
+ floors: object({
10219
+ baseline: FloorsSchema,
10220
+ candidate: FloorsSchema,
10221
+ candidateInt8: FloorsSchema.nullable(),
10222
+ notes: array(string())
10223
+ }).optional(),
10224
+ int8: object({
10225
+ kept: boolean(),
10226
+ map50Fp16: number().nullable(),
10227
+ map50Int8: number().nullable(),
10228
+ reason: string().nullable()
10229
+ }).optional(),
10230
+ exportsDropped: array(object({
10231
+ export: string(),
10232
+ reason: string()
10233
+ })).optional(),
10234
+ files: array(TrainingResultFileSchema).optional(),
10235
+ bundle: object({
10236
+ path: literal("bundle.tar"),
10237
+ bytes: number().int().nonnegative(),
10238
+ sha256: string().regex(/^[0-9a-f]{64}$/)
10239
+ }).nullable().optional(),
10240
+ catalogDraft: object({
10241
+ base: TrainingCatalogDraftSchema,
10242
+ int8: TrainingCatalogDraftSchema.nullable()
10243
+ }).nullable().optional(),
10244
+ licence: string()
10245
+ });
10246
+ var TrainingStageSchema = _enum([
10247
+ "prepare",
10248
+ "replay",
10249
+ "train",
10250
+ "eval",
10251
+ "export",
10252
+ "package"
10253
+ ]);
10254
+ var EventBase = {
10255
+ v: literal(1),
10256
+ ts: number()
10257
+ };
10258
+ discriminatedUnion("type", [
10259
+ object({
10260
+ ...EventBase,
10261
+ type: literal("stage"),
10262
+ stage: TrainingStageSchema
10263
+ }),
10264
+ object({
10265
+ ...EventBase,
10266
+ type: literal("epoch"),
10267
+ epoch: number().int(),
10268
+ epochs: number().int(),
10269
+ boxLoss: number().nullable().optional(),
10270
+ map50: number().nullable().optional(),
10271
+ map50_95: number().nullable().optional(),
10272
+ etaSec: number().nullable().optional()
10273
+ }),
10274
+ object({
10275
+ ...EventBase,
10276
+ type: literal("metric"),
10277
+ name: string(),
10278
+ value: number()
10279
+ }),
10280
+ object({
10281
+ ...EventBase,
10282
+ type: literal("artifact"),
10283
+ path: string(),
10284
+ bytes: number(),
10285
+ sha256: string()
10286
+ }),
10287
+ object({
10288
+ ...EventBase,
10289
+ type: literal("done"),
10290
+ status: _enum(["succeeded", "failed"]),
10291
+ resultSha256: string().nullable().optional()
10292
+ }),
10293
+ object({
10294
+ ...EventBase,
10295
+ type: literal("error"),
10296
+ stage: string(),
10297
+ code: string(),
10298
+ message: string()
10299
+ })
10300
+ ]);
10301
+ /**
9607
10302
  * What the gate decided about a birth, from the CALLER's point of view.
9608
10303
  *
9609
10304
  * Deliberately not `ConfirmationVerdict`: `undecided` is not a birth decision
@@ -12026,7 +12721,9 @@ var AddonHttpRouteSchema = object({
12026
12721
  "authenticated",
12027
12722
  "admin"
12028
12723
  ]).optional(),
12029
- description: string().optional()
12724
+ description: string().optional(),
12725
+ /** The hub limits this route per client address before the handler runs. */
12726
+ rateLimit: _enum(["auth"]).optional()
12030
12727
  });
12031
12728
  /**
12032
12729
  * Cross-process route invocation envelope. The hub captures the
@@ -12750,6 +13447,37 @@ var BackupDestinationInfoSchema = object({
12750
13447
  lastError: string().optional()
12751
13448
  });
12752
13449
  /**
13450
+ * How an archive is encrypted (operator decision 2026-10-09): to a backup
13451
+ * PUBLIC key the hub holds, so only the operator's secret key opens it.
13452
+ * Absent on a plain `.tar.gz` — every archive made before encryption, or
13453
+ * with it off — which restores without a key.
13454
+ */
13455
+ var BackupArchiveEncryptionSchema = object({
13456
+ /** `x25519-hkdf-aes256gcm-stream-v1`. */
13457
+ scheme: string(),
13458
+ /** 16 hex — the backup key whose secret restores this archive. */
13459
+ keyId: string()
13460
+ });
13461
+ /**
13462
+ * The backup encryption setting. The hub keeps PUBLIC keys only: the active
13463
+ * one new archives are encrypted to, and the retired ones older archives
13464
+ * still need. The secret key is shown once, at `setupEncryption`.
13465
+ */
13466
+ var BackupEncryptionStatusSchema = object({
13467
+ enabled: boolean(),
13468
+ active: object({
13469
+ keyId: string(),
13470
+ publicKey: string(),
13471
+ createdAt: number()
13472
+ }).nullable(),
13473
+ /** Every key ever set up, newest first. */
13474
+ keys: array(object({
13475
+ keyId: string(),
13476
+ createdAt: number(),
13477
+ retiredAt: number().nullable()
13478
+ })).readonly()
13479
+ });
13480
+ /**
12753
13481
  * Per-archive entry returned by `backup.listArchives({ destinationId })`.
12754
13482
  * Same shape the destination drill-in renders. Sourced from the per-
12755
13483
  * location `manifests.json` (no per-archive tarball read required).
@@ -12761,7 +13489,9 @@ var BackupArchiveEntrySchema = object({
12761
13489
  sizeBytes: number(),
12762
13490
  label: string().optional(),
12763
13491
  /** Top-level locations included in the archive (db, addons, tls, …). */
12764
- locations: array(string()).readonly()
13492
+ locations: array(string()).readonly(),
13493
+ /** Present when the archive is encrypted; restore then needs that key. */
13494
+ encryption: BackupArchiveEncryptionSchema.optional()
12765
13495
  });
12766
13496
  var BackupEntrySchema = object({
12767
13497
  id: string(),
@@ -12770,7 +13500,8 @@ var BackupEntrySchema = object({
12770
13500
  label: string().optional(),
12771
13501
  createdAt: number(),
12772
13502
  sizeBytes: number(),
12773
- locations: array(string()).optional()
13503
+ locations: array(string()).optional(),
13504
+ encryption: BackupArchiveEncryptionSchema.optional()
12774
13505
  });
12775
13506
  var ArchiveEntrySchema = object({
12776
13507
  path: string(),
@@ -12959,10 +13690,40 @@ method(_void(), array(BackupDestinationInfoSchema).readonly(), { auth: "admin" }
12959
13690
  * this list and skips entries whose path doesn't start with
12960
13691
  * any of them.
12961
13692
  */
12962
- locations: array(string()).optional()
13693
+ locations: array(string()).optional(),
13694
+ /**
13695
+ * The backup SECRET key, for an encrypted archive (ignored for a plain
13696
+ * one). The archive is decrypted into the hub's private staging
13697
+ * before the restart; the key is not stored. A wrong or missing key
13698
+ * is refused before the archive is downloaded.
13699
+ */
13700
+ backupSecretKey: string().optional()
12963
13701
  }), _void(), {
12964
13702
  kind: "mutation",
12965
13703
  auth: "admin"
13704
+ }), method(_void(), BackupEncryptionStatusSchema, { auth: "admin" }), method(object({}), object({
13705
+ keyId: string(),
13706
+ secretKey: string(),
13707
+ publicKey: string(),
13708
+ createdAt: number(),
13709
+ replacedKeyId: string().nullable()
13710
+ }), {
13711
+ kind: "mutation",
13712
+ auth: "admin"
13713
+ }), method(object({}), object({ disabledKeyId: string().nullable() }), {
13714
+ kind: "mutation",
13715
+ auth: "admin"
13716
+ }), method(object({ backupSecretKey: string() }), object({
13717
+ valid: boolean(),
13718
+ keyId: string().nullable(),
13719
+ /** The hub knows this key (active or retired). */
13720
+ known: boolean(),
13721
+ /** It is the key new archives are encrypted to. */
13722
+ active: boolean(),
13723
+ error: string().optional()
13724
+ }), {
13725
+ kind: "mutation",
13726
+ auth: "admin"
12966
13727
  }), method(object({
12967
13728
  destinationId: string(),
12968
13729
  backupId: string()
@@ -14586,7 +15347,60 @@ var CustomModelDescriptorSchema = object({
14586
15347
  stepId: string(),
14587
15348
  entry: ModelCatalogEntrySchema
14588
15349
  });
14589
- method(_void(), array(CustomModelDescriptorSchema).readonly(), { auth: "admin" });
15350
+ /** One regular file of an imported bundle, as the producer measured it. */
15351
+ var ModelBundleFileSchema = object({
15352
+ /** Relative path inside the bundle tar; an mlpackage member is `<x>.mlpackage/<member>`. */
15353
+ path: string().min(1),
15354
+ bytes: number().int().nonnegative(),
15355
+ sha256: string().regex(/^[0-9a-f]{64}$/)
15356
+ });
15357
+ var ImportModelBundleInputSchema = object({
15358
+ /** The registry provider that keeps the model (Model Studio). */
15359
+ addonId: string(),
15360
+ stepId: string().min(1),
15361
+ /**
15362
+ * The catalog rows to register, complete, every format URL already
15363
+ * `camstack-local://<modelId>/<file>` naming a file of the bundle. One
15364
+ * bundle may carry several rows (a base and its INT8 variant).
15365
+ */
15366
+ entries: array(ModelCatalogEntrySchema).min(1).max(4),
15367
+ /** The bundle tar, offered by the producer over `ctx.peerBytes` (same host). */
15368
+ bundle: object({
15369
+ ticket: PeerBytesTicketSchema,
15370
+ bytes: number().int().positive(),
15371
+ sha256: string().regex(/^[0-9a-f]{64}$/)
15372
+ }),
15373
+ /** Every file the tar must hold; anything missing, extra or different is refused. */
15374
+ files: array(ModelBundleFileSchema).min(1).max(64),
15375
+ /** Convert missing engine formats and push the model to every agent afterwards. */
15376
+ distribute: boolean()
15377
+ });
15378
+ var ImportModelBundleResultSchema = discriminatedUnion("kind", [object({
15379
+ kind: literal("imported"),
15380
+ modelIds: array(string()).readonly(),
15381
+ distributed: array(object({
15382
+ modelId: string(),
15383
+ nodeId: string(),
15384
+ format: _enum(MODEL_FORMATS),
15385
+ ok: boolean(),
15386
+ error: string().optional()
15387
+ })).readonly()
15388
+ }), object({
15389
+ kind: literal("refused"),
15390
+ reason: _enum([
15391
+ "transfer-failed",
15392
+ "checksum-mismatch",
15393
+ "bundle-mismatch",
15394
+ "invalid-entry",
15395
+ "id-taken"
15396
+ ]),
15397
+ detail: string()
15398
+ })]);
15399
+ method(_void(), array(CustomModelDescriptorSchema).readonly(), { auth: "admin" }), method(ImportModelBundleInputSchema, ImportModelBundleResultSchema, {
15400
+ kind: "mutation",
15401
+ auth: "admin",
15402
+ timeoutMs: 30 * 6e4
15403
+ });
14590
15404
  /**
14591
15405
  * Query filter for settings-store collections.
14592
15406
  */
@@ -15065,6 +15879,35 @@ var KeychainKeySourceSchema = object({
15065
15879
  */
15066
15880
  sharesBackupWithDatabase: boolean()
15067
15881
  });
15882
+ /**
15883
+ * One keychain reset, as the Secrets page reports it until the operator
15884
+ * acknowledges it. Never a value: refs, counts and table names only.
15885
+ */
15886
+ var KeychainResetRecordSchema = object({
15887
+ id: string(),
15888
+ at: number(),
15889
+ /** `user:<id>` or {@link KEYCHAIN_RESET_TRIGGER_ACTOR}. */
15890
+ actor: string(),
15891
+ /** Why the keychain was locked when it was reset; `null` when it was not locked. */
15892
+ lockedReason: string().nullable(),
15893
+ /** Values moved into the archive table (ciphertext under the lost key). */
15894
+ archived: number().int(),
15895
+ /** `keychain:secrets-orphaned-<ts>`, or `null` when nothing was stored. */
15896
+ archivedCollection: string().nullable(),
15897
+ /**
15898
+ * `keychain:keys-orphaned-<ts>`: the wrapped data keys of the archive, kept
15899
+ * so the archive can still be opened if the lost master key turns up.
15900
+ */
15901
+ archivedKeysCollection: string().nullable(),
15902
+ /**
15903
+ * `system-settings` keys whose marker the reset cleared — the cluster
15904
+ * secret's: a marker left pointing at an archived value would refuse every
15905
+ * agent forever (D797).
15906
+ */
15907
+ clearedSettingsKeys: array(string()).readonly(),
15908
+ /** When an operator dismissed the notice on the Secrets page; `null` until then. */
15909
+ acknowledgedAt: number().nullable()
15910
+ });
15068
15911
  var KeychainStatusSchema = object({
15069
15912
  keychain: KeychainStateSchema,
15070
15913
  /** The source of the master key in use; `null` while locked. */
@@ -15082,7 +15925,9 @@ var KeychainStatusSchema = object({
15082
15925
  /** Wrapped copies of the data key under a previous master key, kept until purged. */
15083
15926
  retiredWraps: number().int(),
15084
15927
  recoveryKeyDownloadedAt: number().nullable(),
15085
- secretCount: number().int()
15928
+ secretCount: number().int(),
15929
+ /** The most recent reset, acknowledged or not; `null` when the keychain was never reset. */
15930
+ lastReset: KeychainResetRecordSchema.nullable()
15086
15931
  });
15087
15932
  /**
15088
15933
  * Whether a stored value is still pointed at by its owner's settings.
@@ -15104,17 +15949,26 @@ var KeychainAuditActionSchema = _enum([
15104
15949
  "download-recovery-key",
15105
15950
  "delete-orphans",
15106
15951
  "reset",
15952
+ "acknowledge-reset",
15107
15953
  "initialize"
15108
15954
  ]);
15109
15955
  var KeychainAuditEntrySchema = object({
15110
15956
  id: string(),
15111
15957
  at: number(),
15112
15958
  action: KeychainAuditActionSchema,
15113
- /** `addon:<id>` | `user:<id>` | `system`. */
15959
+ /** `addon:<id>` | `user:<id>` | `system` | `trigger-file`. */
15114
15960
  actor: string(),
15115
15961
  ref: string().nullable(),
15116
15962
  detail: string().nullable()
15117
15963
  });
15964
+ var KEYCHAIN_RESET_CONFIRMATION = "RESET KEYCHAIN";
15965
+ /**
15966
+ * Secrets the HUB itself holds (owner `system`) that no settings form shows:
15967
+ * `jwt-signing-key` — the session signing key (D797). It is always "in use",
15968
+ * never an orphan; it is generated on a fresh hub and replaced only through
15969
+ * {@link keychainAdminCapability.methods.setSystemSecret}.
15970
+ */
15971
+ var SystemHeldSecretNameSchema = _enum(["jwt-signing-key"]);
15118
15972
  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({
15119
15973
  value: string(),
15120
15974
  version: number().int()
@@ -15122,6 +15976,16 @@ method(object({}), KeychainStatusSchema, { auth: "admin" }), method(object({}),
15122
15976
  kind: "mutation",
15123
15977
  auth: "admin",
15124
15978
  caller: "required"
15979
+ }), method(object({
15980
+ name: SystemHeldSecretNameSchema,
15981
+ value: string().min(16)
15982
+ }), object({
15983
+ ref: string(),
15984
+ version: number().int()
15985
+ }), {
15986
+ kind: "mutation",
15987
+ auth: "admin",
15988
+ caller: "required"
15125
15989
  }), method(object({ refs: array(string().min(1)).max(1e3) }), object({
15126
15990
  deleted: array(string()).readonly(),
15127
15991
  kept: array(object({
@@ -15151,13 +16015,20 @@ method(object({}), KeychainStatusSchema, { auth: "admin" }), method(object({}),
15151
16015
  kind: "mutation",
15152
16016
  auth: "admin",
15153
16017
  caller: "required"
15154
- }), method(object({ confirm: literal("RESET KEYCHAIN") }), object({
16018
+ }), method(object({ confirm: literal(KEYCHAIN_RESET_CONFIRMATION) }), object({
15155
16019
  archivedCollection: string().nullable(),
15156
16020
  archived: number().int()
15157
16021
  }), {
15158
16022
  kind: "mutation",
15159
16023
  auth: "admin",
15160
16024
  caller: "required"
16025
+ }), method(object({}), object({
16026
+ reset: KeychainResetRecordSchema.nullable(),
16027
+ pendingReentry: array(KeychainSecretMetaSchema).readonly()
16028
+ }), { auth: "admin" }), method(object({}), object({ acknowledged: boolean() }), {
16029
+ kind: "mutation",
16030
+ auth: "admin",
16031
+ caller: "required"
15161
16032
  });
15162
16033
  method(_void(), object({
15163
16034
  id: string(),
@@ -17828,7 +18699,7 @@ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
17828
18699
  * `login-method` — collection cap through which auth addons contribute
17829
18700
  * their pre-auth login surfaces to the login page. This is the SINGLE,
17830
18701
  * generic mechanism that supersedes the dead `auth.listProviders` reader:
17831
- * every auth addon (OIDC, magic-link, WebAuthn/passkey) registers a
18702
+ * every auth addon (OIDC, WebAuthn/passkey) registers a
17832
18703
  * `login-method` provider and the PUBLIC `auth.listLoginMethods`
17833
18704
  * procedure aggregates them for the unauthenticated login page.
17834
18705
  *
@@ -17836,8 +18707,7 @@ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
17836
18707
  *
17837
18708
  * - `redirect` — a declarative button. The login page renders a generic
17838
18709
  * button that navigates to `startUrl` (an addon-owned HTTP route).
17839
- * Covers OIDC (`/addon/auth-oidc/<id>/start`) and magic-link with
17840
- * ZERO shell-side JS. A future SSO addon plugs in the same way — the
18710
+ * Covers OIDC (`/addon/auth-oidc/<id>/start`) with ZERO shell-side JS. A future SSO addon plugs in the same way — the
17841
18711
  * login page needs NO change.
17842
18712
  *
17843
18713
  * - `widget` — a Module-Federation widget the login page mounts (via
@@ -17856,8 +18726,8 @@ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
17856
18726
  * decision.
17857
18727
  *
17858
18728
  * Every contribution carries a `stage`:
17859
- * - `primary` — shown on the first credentials screen (OIDC /
17860
- * magic-link buttons; a future usernameless passkey).
18729
+ * - `primary` — shown on the first credentials screen (OIDC
18730
+ * buttons; a usernameless passkey).
17861
18731
  * - `second-factor` — shown AFTER the password leg, gated on the
17862
18732
  * returned `factors` (passkey-as-2FA today).
17863
18733
  *
@@ -17884,7 +18754,7 @@ var LoginMethodContributionSchema = discriminatedUnion("kind", [
17884
18754
  * The provider names an external identity a signed-in user can link to
17885
18755
  * their own account (D782): `auth.listLinkableProviders` /
17886
18756
  * `beginExternalLink` offer exactly the redirect methods that set this,
17887
- * whatever their id. Absent / false — a login button only (magic-link).
18757
+ * whatever their id. Absent / false — a login button only.
17888
18758
  */
17889
18759
  linkable: boolean().optional()
17890
18760
  }),
@@ -21701,8 +22571,7 @@ method(object({}), object({ rules: array(NcRuleSchema) }), { auth: "admin" }), m
21701
22571
  * `super_admin` — collapsed onto the single boolean because every
21702
22572
  * non-admin caller is governed by the same scope-check rules; the
21703
22573
  * distinction was only ever used to route role-specific procedures
21704
- * which we no longer have. Agents are admin sessions issued via
21705
- * `createServiceToken`; CLI / webhook integrations are `cst_*` tokens
22574
+ * which we no longer have. CLI / webhook integrations are `cst_*` tokens
21706
22575
  * with `isAdmin: false` + an explicit scope list.
21707
22576
  */
21708
22577
  /** Per-method access flavour. Materialised on every cap method via codegen. */
@@ -23393,6 +24262,9 @@ var RetrainExportFilterSchema = object({
23393
24262
  frameIds: array(string()).max(2e4).optional(),
23394
24263
  /** Only frames in at least one of these named collections. */
23395
24264
  collectionIds: array(string()).max(200).optional(),
24265
+ /** Exactly the frames of this dataset version (and its completeOnly). An
24266
+ * unknown id selects nothing. */
24267
+ datasetVersionId: string().optional(),
23396
24268
  batchId: string().optional(),
23397
24269
  /** Only frames the operator marked complete (all subjects boxed). */
23398
24270
  completeOnly: boolean().optional()
@@ -23560,6 +24432,67 @@ var RetrainLlmAssistResultSchema = discriminatedUnion("kind", [object({
23560
24432
  ]),
23561
24433
  detail: string().optional()
23562
24434
  })]);
24435
+ /** What a dataset version is cut from. Every field narrows. */
24436
+ var RetrainDatasetSelectionSchema = object({
24437
+ deviceIds: array(number()).readonly().optional(),
24438
+ collectionIds: array(string()).max(200).readonly().optional(),
24439
+ frameIds: array(string()).max(2e4).readonly().optional()
24440
+ });
24441
+ /** The counts a dataset is judged by. */
24442
+ var RetrainDatasetStatsSchema = object({
24443
+ frames: number().int(),
24444
+ completeFrames: number().int(),
24445
+ /** `completeFrames / frames`, 0..1. */
24446
+ completeness: number(),
24447
+ /** Boxes to learn (model errors excluded). */
24448
+ subjects: number().int(),
24449
+ modelErrors: number().int(),
24450
+ /** Complete frames with no subject. */
24451
+ hardNegatives: number().int(),
24452
+ /** Subjects per class × camera × day/night. */
24453
+ cells: array(object({
24454
+ macroClass: string(),
24455
+ deviceId: number(),
24456
+ lighting: _enum([
24457
+ "day",
24458
+ "night",
24459
+ "unknown"
24460
+ ]),
24461
+ subjects: number().int(),
24462
+ frames: number().int()
24463
+ })).readonly(),
24464
+ cameras: array(object({
24465
+ deviceId: number(),
24466
+ frames: number().int(),
24467
+ completeFrames: number().int()
24468
+ })).readonly()
24469
+ });
24470
+ /** An immutable dataset version, without its frame list. */
24471
+ var RetrainDatasetVersionSchema = object({
24472
+ id: string(),
24473
+ name: string(),
24474
+ createdAt: number(),
24475
+ selection: RetrainDatasetSelectionSchema,
24476
+ layout: RetrainExportLayoutSchema,
24477
+ completeOnly: boolean(),
24478
+ frameCount: number().int(),
24479
+ /** sha256 of what the frames taught when the version was frozen. */
24480
+ annotationHash: string(),
24481
+ /** The export manifest schema the version was cut under. */
24482
+ manifestSchema: string(),
24483
+ stats: RetrainDatasetStatsSchema
24484
+ });
24485
+ var CreateRetrainDatasetVersionResultSchema = discriminatedUnion("kind", [object({
24486
+ kind: literal("created"),
24487
+ version: RetrainDatasetVersionSchema
24488
+ }), object({
24489
+ kind: literal("refused"),
24490
+ reason: _enum([
24491
+ "empty-name",
24492
+ "duplicate-name",
24493
+ "no-frames"
24494
+ ])
24495
+ })]);
23563
24496
  /** The outcome of a lifecycle move owned by the retrain page. */
23564
24497
  var RetrainTransitionResultSchema = object({
23565
24498
  trackId: string(),
@@ -24349,6 +25282,47 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema$1).r
24349
25282
  kind: "mutation",
24350
25283
  auth: "admin",
24351
25284
  timeoutMs: 60 * 6e4
25285
+ }), method(object({
25286
+ filter: RetrainExportFilterSchema,
25287
+ layout: RetrainExportLayoutSchema
25288
+ }), object({
25289
+ ticket: PeerBytesTicketSchema,
25290
+ frames: number().int(),
25291
+ annotations: number().int()
25292
+ }), {
25293
+ kind: "mutation",
25294
+ auth: "admin",
25295
+ timeoutMs: 12e4
25296
+ }), method(object({
25297
+ selection: RetrainDatasetSelectionSchema,
25298
+ completeOnly: boolean().optional()
25299
+ }), RetrainDatasetStatsSchema, {
25300
+ kind: "query",
25301
+ auth: "admin"
25302
+ }), method(object({
25303
+ name: string().max(120),
25304
+ selection: RetrainDatasetSelectionSchema,
25305
+ layout: RetrainExportLayoutSchema,
25306
+ completeOnly: boolean()
25307
+ }), CreateRetrainDatasetVersionResultSchema, {
25308
+ kind: "mutation",
25309
+ auth: "admin",
25310
+ timeoutMs: 12e4
25311
+ }), method(object({}), array(RetrainDatasetVersionSchema).readonly(), {
25312
+ kind: "query",
25313
+ auth: "admin"
25314
+ }), method(object({ id: string() }), object({ deleted: boolean() }), {
25315
+ kind: "mutation",
25316
+ auth: "admin"
25317
+ }), method(object({ id: string() }), object({
25318
+ found: boolean(),
25319
+ annotationHash: string(),
25320
+ matches: boolean(),
25321
+ missingFrames: number().int()
25322
+ }), {
25323
+ kind: "query",
25324
+ auth: "admin",
25325
+ timeoutMs: 12e4
24352
25326
  }), method(object({}), array(RetrainAssistProfileSchema).readonly(), {
24353
25327
  kind: "query",
24354
25328
  auth: "admin"
@@ -27887,8 +28861,8 @@ version: string().optional() }), ServerUpdateActionResultSchema, {
27887
28861
  * `smtp-provider` — pluggable email delivery surface.
27888
28862
  *
27889
28863
  * Collection cap: a deployment may install multiple SMTP relays (e.g.
27890
- * one for transactional / one for notifications). Consumers (magic-link,
27891
- * notifier addons, …) walk the collection and pick the first
28864
+ * one for transactional / one for notifications). Consumers (notifier
28865
+ * addons, …) walk the collection and pick the first
27892
28866
  * ready provider OR target a specific addonId.
27893
28867
  *
27894
28868
  * The shape stays small on purpose — `sendEmail` is enough for the
@@ -28067,7 +29041,7 @@ targets: array(object({
28067
29041
  })));
28068
29042
  /**
28069
29043
  * `sso-bridge` — internal hub-only cap that lets SSO-style auth
28070
- * providers (OIDC, SAML, magic-link, …) mint an HMAC-signed token
29044
+ * providers (OIDC, SAML, …) mint an HMAC-signed token
28071
29045
  * carrying the post-callback claims before redirecting back to
28072
29046
  * `/api/auth/sso/finish`.
28073
29047
  *
@@ -28130,7 +29104,14 @@ var SsoBridgeClaimsSchema = object({
28130
29104
  * Verified `iss` of the id_token behind an OIDC login bridge (D782). A
28131
29105
  * subject is unique only per issuer, so a link is bound to it.
28132
29106
  */
28133
- issuer: string().optional()
29107
+ issuer: string().optional(),
29108
+ /**
29109
+ * SHA-256 (hex) of the `camstack_sso_state` cookie the IdP `/start` set in
29110
+ * the browser that began this sign-in. `/api/auth/sso/finish` requires the
29111
+ * request to present the matching cookie — a login bridge is useless in
29112
+ * any other browser.
29113
+ */
29114
+ browserBinding: string().optional()
28134
29115
  });
28135
29116
  method(object({
28136
29117
  claims: SsoBridgeClaimsSchema,
@@ -34054,7 +35035,13 @@ var TopologyNodeSchema = object({
34054
35035
  })).readonly(),
34055
35036
  processes: array(TopologyProcessSchema).readonly(),
34056
35037
  categories: array(TopologyCategorySchema).readonly(),
34057
- rootPackage: TopologyRootPackageSchema.nullable()
35038
+ rootPackage: TopologyRootPackageSchema.nullable(),
35039
+ /**
35040
+ * How an online AGENT reaches the hub (mesh mTLS Release A): `tls` once it has
35041
+ * completed a mutual-TLS handshake, `clear` otherwise. Absent for the hub,
35042
+ * for offline rows and when the hub cannot tell.
35043
+ */
35044
+ meshTransport: _enum(["tls", "clear"]).optional()
34058
35045
  });
34059
35046
  var CapUsageEdgeSchema = object({
34060
35047
  callerAddonId: string(),
@@ -38105,16 +39092,6 @@ var ApiKeySummarySchema = object({
38105
39092
  createdAt: number(),
38106
39093
  lastUsedAt: number().optional()
38107
39094
  });
38108
- var CreateApiKeyInputSchema = object({
38109
- label: string(),
38110
- isAdmin: boolean().default(false),
38111
- allowedProviders: union([array(string()), literal("*")]).optional(),
38112
- allowedDevices: record(string(), union([array(string()), literal("*")])).optional()
38113
- });
38114
- var CreateApiKeyResultSchema = object({
38115
- token: string(),
38116
- record: ApiKeySummarySchema
38117
- });
38118
39095
  var ScopedTokenSummarySchema = object({
38119
39096
  id: string(),
38120
39097
  userId: string(),
@@ -38213,17 +39190,10 @@ method(_void(), array(UserSummarySchema), { auth: "admin" }), method(CreateUserI
38213
39190
  }), UserSummarySchema.extend({ passwordHash: string() }).nullable(), {
38214
39191
  kind: "mutation",
38215
39192
  access: "view"
38216
- }), method(_void(), array(ApiKeySummarySchema), { auth: "admin" }), method(CreateApiKeyInputSchema, CreateApiKeyResultSchema, {
38217
- kind: "mutation",
38218
- auth: "admin",
38219
- access: "create"
38220
- }), method(object({ id: string() }), object({ success: literal(true) }), {
39193
+ }), method(_void(), array(ApiKeySummarySchema), { auth: "admin" }), method(object({ id: string() }), object({ success: literal(true) }), {
38221
39194
  kind: "mutation",
38222
39195
  auth: "admin",
38223
39196
  access: "delete"
38224
- }), method(object({ token: string() }), ApiKeySummarySchema.nullable(), {
38225
- kind: "mutation",
38226
- access: "view"
38227
39197
  }), method(CreateScopedTokenInputSchema, CreateScopedTokenResultSchema, {
38228
39198
  kind: "mutation",
38229
39199
  auth: "admin",
@@ -38297,15 +39267,7 @@ method(_void(), array(UserSummarySchema), { auth: "admin" }), method(CreateUserI
38297
39267
  }).nullable(), { access: "view" }), method(object({ userId: string() }), array(ExternalIdentitySchema), { auth: "admin" }), method(ExternalIdentityKeySchema, object({
38298
39268
  userId: string(),
38299
39269
  issuer: string()
38300
- }).nullable(), { auth: "admin" }), method(ExternalIdentityKeySchema.extend({
38301
- userId: string(),
38302
- issuer: string().min(1),
38303
- label: string().optional()
38304
- }), object({ success: literal(true) }), {
38305
- kind: "mutation",
38306
- auth: "admin",
38307
- access: "create"
38308
- }), method(ExternalIdentityKeySchema.extend({ userId: string() }), object({ success: boolean() }), {
39270
+ }).nullable(), { auth: "admin" }), method(ExternalIdentityKeySchema.extend({ userId: string() }), object({ success: boolean() }), {
38309
39271
  kind: "mutation",
38310
39272
  auth: "admin",
38311
39273
  access: "delete"
@@ -38700,6 +39662,451 @@ DeviceType.Camera, method(object({
38700
39662
  detection: array(ZoneRuleSchema).readonly(),
38701
39663
  package: array(ZoneRuleSchema).readonly()
38702
39664
  });
39665
+ /**
39666
+ * `training-provider` — ONE cloud that can run the CamStack trainer.
39667
+ *
39668
+ * A thin, mockable translation layer: it knows how to run a container with a
39669
+ * GPU, move a dataset in, read the job's stdout and hand artefacts back. It
39670
+ * knows nothing about datasets, splits, floors, cost policy or Model Studio —
39671
+ * those are the `training` orchestrator's (D805). Every rule written there
39672
+ * once is what makes a second provider (RunPod, a local NVIDIA node) a new
39673
+ * manifest entry and nothing else.
39674
+ *
39675
+ * Collection, routed by the `addonId` in every single-row input (the `llm` /
39676
+ * `notification-output` posture); `describe` concat-fans across providers.
39677
+ * Every method is `admin`: these spend money.
39678
+ *
39679
+ * Every cloud object a provider creates is tagged with the orchestrator's
39680
+ * `jobKey`, so a retried submit finds the job it already started instead of
39681
+ * starting a second GPU, and `listJobs` can find orphans.
39682
+ *
39683
+ * Bytes never ride a cap field: the dataset arrives as a `ctx.peerBytes`
39684
+ * ticket the producer (pipeline-analytics) minted, and artefacts leave as a
39685
+ * ticket the provider mints (D613).
39686
+ */
39687
+ var TrainingGpuOptionSchema = object({
39688
+ id: string(),
39689
+ label: string(),
39690
+ /** List price, USD per GPU-hour, before any region multiplier. */
39691
+ usdPerHour: number().nonnegative(),
39692
+ vramGb: number().nonnegative()
39693
+ });
39694
+ var TrainingRegionOptionSchema = object({
39695
+ /** `''` = any region (the provider's choice). */
39696
+ id: string(),
39697
+ label: string(),
39698
+ priceMultiplier: number().positive()
39699
+ });
39700
+ /**
39701
+ * The provider's per-account settings, as the orchestrator reads them. They
39702
+ * live in the PROVIDER addon's settings (operator decision 2026-10-08: they
39703
+ * depend on the user's account), never hard-coded in the orchestrator.
39704
+ */
39705
+ var TrainingProviderDefaultsSchema = object({
39706
+ gpuType: string(),
39707
+ region: string(),
39708
+ costCapUsd: number().nonnegative(),
39709
+ maxRuntimeSec: number().int().positive(),
39710
+ /** Hours a FAILED job's cloud dataset is kept for debugging; 0 = delete at once. */
39711
+ failedDatasetGraceHours: number().nonnegative()
39712
+ });
39713
+ var TrainingProviderDescriptorSchema = object({
39714
+ addonId: string(),
39715
+ /** `modal`, `runpod`, `fake`, … */
39716
+ kind: string(),
39717
+ label: string(),
39718
+ gpuTypes: array(TrainingGpuOptionSchema).readonly(),
39719
+ regions: array(TrainingRegionOptionSchema).readonly(),
39720
+ maxDatasetBytes: number().int().positive(),
39721
+ maxRuntimeSec: number().int().positive(),
39722
+ freeTierNote: string().optional(),
39723
+ /** Where the data goes, in one sentence the confirm dialog repeats. */
39724
+ dataResidencyNote: string(),
39725
+ /** Credentials are present — never the values. */
39726
+ configured: boolean(),
39727
+ defaults: TrainingProviderDefaultsSchema
39728
+ });
39729
+ var TrainingCredentialCheckSchema = object({
39730
+ ok: boolean(),
39731
+ /** Workspace / account name, when the provider says. */
39732
+ account: string().optional(),
39733
+ reason: _enum([
39734
+ "missing",
39735
+ "invalid",
39736
+ "forbidden",
39737
+ "network",
39738
+ "quota"
39739
+ ]).optional(),
39740
+ detail: string().optional()
39741
+ });
39742
+ var ProviderJobStateSchema = _enum([
39743
+ "pending",
39744
+ "starting",
39745
+ "running",
39746
+ "succeeded",
39747
+ "failed",
39748
+ "cancelled",
39749
+ "lost"
39750
+ ]);
39751
+ var ProviderJobStatusSchema = object({
39752
+ jobKey: string(),
39753
+ providerJobId: string().optional(),
39754
+ state: ProviderJobStateSchema,
39755
+ startedAt: number().optional(),
39756
+ endedAt: number().optional(),
39757
+ exitCode: number().int().optional(),
39758
+ failureReason: string().optional(),
39759
+ gpuType: string(),
39760
+ region: string().optional(),
39761
+ billedSeconds: number().nonnegative(),
39762
+ costUsd: number().nonnegative(),
39763
+ /** True when `costUsd` is runtime × list price, not a billing answer. */
39764
+ costIsEstimate: boolean(),
39765
+ lastFetchedAt: number()
39766
+ });
39767
+ /**
39768
+ * The trainer the job runs, by SOURCE revision: the provider turns it into an
39769
+ * image its own way (Modal builds the published Dockerfile at that revision;
39770
+ * a registry-pull provider maps it to a tag). Recorded on the job and echoed
39771
+ * in `result.json`.
39772
+ */
39773
+ var TrainerSourceRefSchema = object({
39774
+ /** Hugging Face repo id, e.g. `camstack/camstack-trainer`. */
39775
+ repo: string().min(1),
39776
+ /** A commit sha (never a branch) — the job must be reproducible. */
39777
+ revision: string().regex(/^[0-9a-f]{7,64}$/)
39778
+ });
39779
+ var JobRef = {
39780
+ addonId: string(),
39781
+ jobKey: string().uuid()
39782
+ };
39783
+ var TrainingLogLineSchema = object({
39784
+ ts: number(),
39785
+ text: string()
39786
+ });
39787
+ method(object({}), array(TrainingProviderDescriptorSchema).readonly(), { auth: "admin" }), method(object({ addonId: string() }), TrainingCredentialCheckSchema, {
39788
+ kind: "mutation",
39789
+ auth: "admin",
39790
+ timeoutMs: 3e4
39791
+ }), method(object({
39792
+ addonId: string(),
39793
+ gpuType: string(),
39794
+ region: string(),
39795
+ datasetBytes: number().int().nonnegative(),
39796
+ gpuSecondsLow: number().nonnegative(),
39797
+ gpuSecondsHigh: number().nonnegative()
39798
+ }), object({
39799
+ usdLow: number().nonnegative(),
39800
+ usdHigh: number().nonnegative(),
39801
+ notes: array(string()).readonly()
39802
+ }), { auth: "admin" }), method(object({
39803
+ ...JobRef,
39804
+ ticket: PeerBytesTicketSchema
39805
+ }), object({
39806
+ bytes: number().int().nonnegative(),
39807
+ sha256: string()
39808
+ }), {
39809
+ kind: "mutation",
39810
+ auth: "admin",
39811
+ timeoutMs: 120 * 6e4
39812
+ }), method(object({
39813
+ ...JobRef,
39814
+ trainer: TrainerSourceRefSchema,
39815
+ jobSpecJson: string().min(2).max(64e3),
39816
+ gpuType: string(),
39817
+ region: string(),
39818
+ maxRuntimeSec: number().int().positive()
39819
+ }), ProviderJobStatusSchema, {
39820
+ kind: "mutation",
39821
+ auth: "admin",
39822
+ timeoutMs: 30 * 6e4
39823
+ }), method(object(JobRef), ProviderJobStatusSchema, {
39824
+ auth: "admin",
39825
+ timeoutMs: 6e4
39826
+ }), method(object({
39827
+ ...JobRef,
39828
+ cursor: string().optional(),
39829
+ max: number().int().min(1).max(500)
39830
+ }), object({
39831
+ lines: array(TrainingLogLineSchema).readonly(),
39832
+ cursor: string()
39833
+ }), {
39834
+ auth: "admin",
39835
+ timeoutMs: 6e4
39836
+ }), method(object(JobRef), object({ ok: literal(true) }), {
39837
+ kind: "mutation",
39838
+ auth: "admin",
39839
+ timeoutMs: 6e4
39840
+ }), method(object(JobRef), object({
39841
+ found: boolean(),
39842
+ text: string().optional()
39843
+ }), {
39844
+ kind: "mutation",
39845
+ auth: "admin",
39846
+ timeoutMs: 5 * 6e4
39847
+ }), method(object({
39848
+ ...JobRef,
39849
+ path: _enum(["bundle.tar"])
39850
+ }), object({ ticket: PeerBytesTicketSchema }), {
39851
+ kind: "mutation",
39852
+ auth: "admin",
39853
+ timeoutMs: 5 * 6e4
39854
+ }), method(object(JobRef), object({ deleted: array(string()).readonly() }), {
39855
+ kind: "mutation",
39856
+ auth: "admin",
39857
+ timeoutMs: 5 * 6e4
39858
+ }), method(object({ addonId: string() }), array(ProviderJobStatusSchema).readonly(), {
39859
+ auth: "admin",
39860
+ timeoutMs: 2 * 6e4
39861
+ });
39862
+ /**
39863
+ * `training` — the cloud-training orchestrator (D805). Hub-only singleton,
39864
+ * provided by `addon-training`.
39865
+ *
39866
+ * It owns what every provider must agree on, written once:
39867
+ *
39868
+ * - **Dataset versions.** Taken over from pipeline-analytics (D796): the rows
39869
+ * live here (D808); pipeline-analytics still CUTS a version (it owns the corpus and
39870
+ * the export plan) and reaches this store through the five row methods
39871
+ * below, so the Retrain page and the export did not change.
39872
+ * - **Jobs.** A persisted state machine, a reconcile loop against the
39873
+ * provider, a cost guard, a daily orphan sweep and the retention rules.
39874
+ * - **The return flow.** Verified artefacts → Model Studio
39875
+ * (`custom-model-registry.importModelBundle`) → canary on cameras →
39876
+ * rollback. Nothing is ever registered automatically.
39877
+ *
39878
+ * Every method is `admin`.
39879
+ */
39880
+ /** A version WITH its frame list — what the export and a job read. */
39881
+ var TrainingDatasetVersionRowSchema = RetrainDatasetVersionSchema.omit({ frameCount: true }).extend({ frameIds: array(string()).max(2e4).readonly() });
39882
+ /** A base model a detector job can fine-tune, and the baseline it is judged against. */
39883
+ var TrainingBaseModelSchema = object({
39884
+ modelId: string(),
39885
+ label: string(),
39886
+ weights: string(),
39887
+ imgsz: number().int(),
39888
+ baselineOnnxUrl: string(),
39889
+ baselineFloors: record(string(), number()),
39890
+ /** The base the fleet runs most — the UI's default. */
39891
+ recommended: boolean()
39892
+ });
39893
+ var TrainingPresetSchema = _enum([
39894
+ "quick",
39895
+ "standard",
39896
+ "thorough"
39897
+ ]);
39898
+ var TrainingJobRequestSchema = object({
39899
+ datasetVersionId: string().min(1),
39900
+ /** The `training-provider` addon that runs it. */
39901
+ addonId: string().min(1),
39902
+ gpuType: string().min(1),
39903
+ region: string(),
39904
+ baseModelId: string().min(1),
39905
+ preset: TrainingPresetSchema,
39906
+ /** Freeze the backbone's first N layers; `null` = the preset's choice. */
39907
+ freeze: number().int().nonnegative().nullable(),
39908
+ /** Cameras held out whole for evaluation; `null` = the orchestrator's default. */
39909
+ holdoutCameras: array(number().int()).nullable()
39910
+ });
39911
+ var TrainingSplitPlanSchema = object({
39912
+ holdoutCameras: array(number().int()).readonly(),
39913
+ /** Used when no camera is held out: the last N days of every camera. */
39914
+ holdoutLastDays: number().int().nonnegative(),
39915
+ /** Holdout subjects per class (camera holdout only; `null` = known only after the split). */
39916
+ holdoutSupport: record(string(), number().int()).nullable(),
39917
+ trainSubjects: number().int()
39918
+ });
39919
+ var TrainingRefusalReasonSchema = _enum([
39920
+ "unknown-dataset",
39921
+ "unknown-provider",
39922
+ "provider-not-configured",
39923
+ "unknown-base-model",
39924
+ "unknown-gpu",
39925
+ "dataset-too-large",
39926
+ "no-training-subjects",
39927
+ "job-already-running"
39928
+ ]);
39929
+ var TrainingJobPlanSchema = object({
39930
+ refusal: object({
39931
+ reason: TrainingRefusalReasonSchema,
39932
+ detail: string()
39933
+ }).nullable(),
39934
+ warnings: array(string()).readonly(),
39935
+ split: TrainingSplitPlanSchema.nullable(),
39936
+ estimate: object({
39937
+ datasetBytes: number().int(),
39938
+ uploadMinutesAt20Mbps: number(),
39939
+ gpuSecondsLow: number(),
39940
+ gpuSecondsHigh: number(),
39941
+ usdLow: number(),
39942
+ usdHigh: number(),
39943
+ notes: array(string()).readonly()
39944
+ }).nullable(),
39945
+ /** Pre-filled from the provider's settings; the operator may lower or raise them. */
39946
+ defaults: object({
39947
+ maxCostUsd: number(),
39948
+ maxRuntimeSec: number().int()
39949
+ }).nullable(),
39950
+ /** The sentence the confirm dialog repeats: where the frames go and when they are deleted. */
39951
+ dataNotice: string()
39952
+ });
39953
+ /**
39954
+ * Orchestrator-owned states, persisted. `uploading` covers exporting the
39955
+ * archive (it is streamed, never staged). Terminal: `failed`, `cancelled`,
39956
+ * `lost`, `expired`, `discarded`. `registered` and `canary` are where a
39957
+ * result lives after the operator acted on it.
39958
+ */
39959
+ var TrainingJobStateSchema = _enum([
39960
+ "uploading",
39961
+ "submitted",
39962
+ "starting",
39963
+ "running",
39964
+ "collecting",
39965
+ "ready",
39966
+ "registered",
39967
+ "canary",
39968
+ "failed",
39969
+ "cancelling",
39970
+ "cancelled",
39971
+ "lost",
39972
+ "expired",
39973
+ "discarded"
39974
+ ]);
39975
+ var TrainingFailureReasonSchema = _enum([
39976
+ "cost-cap",
39977
+ "runtime-cap",
39978
+ "upload-failed",
39979
+ "submit-failed",
39980
+ "trainer-failed",
39981
+ "result-invalid",
39982
+ "checksum-mismatch",
39983
+ "fetch-failed",
39984
+ "provider-error",
39985
+ "hub-restart-during-upload"
39986
+ ]);
39987
+ var TrainingProgressPointSchema = object({
39988
+ epoch: number().int(),
39989
+ map50: number().nullable(),
39990
+ map50_95: number().nullable()
39991
+ });
39992
+ var TrainingCanarySchema = object({
39993
+ deviceIds: array(number().int()).readonly(),
39994
+ since: number(),
39995
+ /** Every override the canary replaced, exactly, so rollback restores it. */
39996
+ previous: array(object({
39997
+ deviceId: number().int(),
39998
+ nodeId: string(),
39999
+ deviceKey: string(),
40000
+ patch: object({
40001
+ modelId: string().optional(),
40002
+ settings: record(string(), unknown()).readonly().optional()
40003
+ }).nullable()
40004
+ })).readonly()
40005
+ });
40006
+ var TrainingJobSchema = object({
40007
+ id: string(),
40008
+ idempotencyKey: string(),
40009
+ name: string(),
40010
+ createdAt: number(),
40011
+ updatedAt: number(),
40012
+ state: TrainingJobStateSchema,
40013
+ stage: TrainingStageSchema.nullable(),
40014
+ failure: object({
40015
+ reason: TrainingFailureReasonSchema,
40016
+ stage: string().nullable(),
40017
+ detail: string()
40018
+ }).nullable(),
40019
+ request: TrainingJobRequestSchema,
40020
+ maxCostUsd: number().nonnegative(),
40021
+ maxRuntimeSec: number().int().positive(),
40022
+ trainer: TrainerSourceRefSchema,
40023
+ datasetLayout: RetrainExportLayoutSchema,
40024
+ dataset: object({
40025
+ bytes: number().int(),
40026
+ sha256: string(),
40027
+ uploadedAt: number()
40028
+ }).nullable(),
40029
+ split: TrainingSplitPlanSchema,
40030
+ provider: object({
40031
+ state: ProviderJobStateSchema.nullable(),
40032
+ providerJobId: string().nullable(),
40033
+ startedAt: number().nullable(),
40034
+ endedAt: number().nullable(),
40035
+ billedSeconds: number(),
40036
+ costUsd: number(),
40037
+ costIsEstimate: boolean(),
40038
+ lastPolledAt: number().nullable()
40039
+ }),
40040
+ progress: object({
40041
+ epoch: number().int().nullable(),
40042
+ epochs: number().int().nullable(),
40043
+ etaSec: number().nullable(),
40044
+ series: array(TrainingProgressPointSchema).readonly()
40045
+ }),
40046
+ /** The last lines of the job's output (≤ 200), newest last. Never frame paths. */
40047
+ logTail: array(string()).readonly(),
40048
+ logCursor: string().nullable(),
40049
+ artifacts: object({
40050
+ bundleBytes: number().int(),
40051
+ bundleSha256: string(),
40052
+ fetchedAt: number(),
40053
+ /** When the staged artefacts are deleted from the hub. */
40054
+ expiresAt: number()
40055
+ }).nullable(),
40056
+ /** When the provider-side copy of the frames was deleted; null while it exists. */
40057
+ cloudDatasetDeletedAt: number().nullable(),
40058
+ /** A failed job's dataset is kept until then (the provider's grace), then deleted. */
40059
+ cloudCleanupDueAt: number().nullable(),
40060
+ /** Model ids registered from this job (base, and int8 when kept). */
40061
+ registeredModelIds: array(string()).readonly(),
40062
+ canary: TrainingCanarySchema.nullable()
40063
+ });
40064
+ var IdInput = object({ id: string().min(1) });
40065
+ method(TrainingDatasetVersionRowSchema, object({ stored: boolean() }), {
40066
+ kind: "mutation",
40067
+ auth: "admin"
40068
+ }), 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() }), {
40069
+ kind: "mutation",
40070
+ auth: "admin"
40071
+ }), method(object({}), array(TrainingBaseModelSchema).readonly(), { auth: "admin" }), method(TrainingJobRequestSchema, TrainingJobPlanSchema, {
40072
+ auth: "admin",
40073
+ timeoutMs: 6e4
40074
+ }), method(TrainingJobRequestSchema.extend({
40075
+ name: string().min(1).max(120),
40076
+ maxCostUsd: number().positive(),
40077
+ maxRuntimeSec: number().int().positive(),
40078
+ idempotencyKey: string().min(8).max(80)
40079
+ }), discriminatedUnion("kind", [object({
40080
+ kind: literal("started"),
40081
+ job: TrainingJobSchema
40082
+ }), object({
40083
+ kind: literal("refused"),
40084
+ reason: TrainingRefusalReasonSchema,
40085
+ detail: string()
40086
+ })]), {
40087
+ kind: "mutation",
40088
+ auth: "admin",
40089
+ timeoutMs: 12e4
40090
+ }), method(object({}), array(TrainingJobSchema).readonly(), { auth: "admin" }), method(IdInput, TrainingJobSchema.nullable(), { auth: "admin" }), method(IdInput, TrainingJobSchema, {
40091
+ kind: "mutation",
40092
+ auth: "admin",
40093
+ timeoutMs: 12e4
40094
+ }), method(IdInput, TrainingResultSchema.nullable(), { auth: "admin" }), method(IdInput.extend({ canaryDeviceIds: array(number().int()).readonly() }), TrainingJobSchema, {
40095
+ kind: "mutation",
40096
+ auth: "admin",
40097
+ timeoutMs: 30 * 6e4
40098
+ }), method(IdInput.extend({ deviceIds: array(number().int()).min(1).readonly() }), TrainingJobSchema, {
40099
+ kind: "mutation",
40100
+ auth: "admin",
40101
+ timeoutMs: 12e4
40102
+ }), method(IdInput, TrainingJobSchema, {
40103
+ kind: "mutation",
40104
+ auth: "admin",
40105
+ timeoutMs: 12e4
40106
+ }), method(IdInput, TrainingJobSchema, {
40107
+ kind: "mutation",
40108
+ auth: "admin"
40109
+ });
38703
40110
  SOURCE_CAPS.filter((cap) => cap !== "switch" && cap !== "motion");
38704
40111
  Object.freeze({
38705
40112
  person: .5,
@@ -39323,6 +40730,12 @@ Object.freeze({
39323
40730
  addonId: null,
39324
40731
  access: "create"
39325
40732
  },
40733
+ "backup.checkBackupKey": {
40734
+ capName: "backup",
40735
+ capScope: "system",
40736
+ addonId: null,
40737
+ access: "create"
40738
+ },
39326
40739
  "backup.delete": {
39327
40740
  capName: "backup",
39328
40741
  capScope: "system",
@@ -39335,6 +40748,18 @@ Object.freeze({
39335
40748
  addonId: null,
39336
40749
  access: "delete"
39337
40750
  },
40751
+ "backup.disableEncryption": {
40752
+ capName: "backup",
40753
+ capScope: "system",
40754
+ addonId: null,
40755
+ access: "create"
40756
+ },
40757
+ "backup.getEncryption": {
40758
+ capName: "backup",
40759
+ capScope: "system",
40760
+ addonId: null,
40761
+ access: "view"
40762
+ },
39338
40763
  "backup.getEntries": {
39339
40764
  capName: "backup",
39340
40765
  capScope: "system",
@@ -39389,6 +40814,12 @@ Object.freeze({
39389
40814
  addonId: null,
39390
40815
  access: "create"
39391
40816
  },
40817
+ "backup.setupEncryption": {
40818
+ capName: "backup",
40819
+ capScope: "system",
40820
+ addonId: null,
40821
+ access: "create"
40822
+ },
39392
40823
  "backup.trigger": {
39393
40824
  capName: "backup",
39394
40825
  capScope: "system",
@@ -39941,6 +41372,12 @@ Object.freeze({
39941
41372
  addonId: null,
39942
41373
  access: "create"
39943
41374
  },
41375
+ "customModelRegistry.importModelBundle": {
41376
+ capName: "custom-model-registry",
41377
+ capScope: "system",
41378
+ addonId: null,
41379
+ access: "create"
41380
+ },
39944
41381
  "customModelRegistry.listModels": {
39945
41382
  capName: "custom-model-registry",
39946
41383
  capScope: "system",
@@ -41381,6 +42818,12 @@ Object.freeze({
41381
42818
  addonId: null,
41382
42819
  access: "view"
41383
42820
  },
42821
+ "keychainAdmin.acknowledgeReset": {
42822
+ capName: "keychain-admin",
42823
+ capScope: "system",
42824
+ addonId: null,
42825
+ access: "create"
42826
+ },
41384
42827
  "keychainAdmin.deleteOrphans": {
41385
42828
  capName: "keychain-admin",
41386
42829
  capScope: "system",
@@ -41417,6 +42860,12 @@ Object.freeze({
41417
42860
  addonId: null,
41418
42861
  access: "delete"
41419
42862
  },
42863
+ "keychainAdmin.resetReport": {
42864
+ capName: "keychain-admin",
42865
+ capScope: "system",
42866
+ addonId: null,
42867
+ access: "delete"
42868
+ },
41420
42869
  "keychainAdmin.reveal": {
41421
42870
  capName: "keychain-admin",
41422
42871
  capScope: "system",
@@ -41429,6 +42878,12 @@ Object.freeze({
41429
42878
  addonId: null,
41430
42879
  access: "create"
41431
42880
  },
42881
+ "keychainAdmin.setSystemSecret": {
42882
+ capName: "keychain-admin",
42883
+ capScope: "system",
42884
+ addonId: null,
42885
+ access: "create"
42886
+ },
41432
42887
  "keychainAdmin.status": {
41433
42888
  capName: "keychain-admin",
41434
42889
  capScope: "system",
@@ -42875,6 +44330,12 @@ Object.freeze({
42875
44330
  addonId: null,
42876
44331
  access: "create"
42877
44332
  },
44333
+ "pipelineAnalytics.createRetrainDatasetVersion": {
44334
+ capName: "pipeline-analytics",
44335
+ capScope: "device",
44336
+ addonId: null,
44337
+ access: "create"
44338
+ },
42878
44339
  "pipelineAnalytics.deleteDeviceEvents": {
42879
44340
  capName: "pipeline-analytics",
42880
44341
  capScope: "device",
@@ -42887,6 +44348,12 @@ Object.freeze({
42887
44348
  addonId: null,
42888
44349
  access: "delete"
42889
44350
  },
44351
+ "pipelineAnalytics.deleteRetrainDatasetVersion": {
44352
+ capName: "pipeline-analytics",
44353
+ capScope: "device",
44354
+ addonId: null,
44355
+ access: "delete"
44356
+ },
42890
44357
  "pipelineAnalytics.deleteTracks": {
42891
44358
  capName: "pipeline-analytics",
42892
44359
  capScope: "device",
@@ -43109,6 +44576,12 @@ Object.freeze({
43109
44576
  addonId: null,
43110
44577
  access: "view"
43111
44578
  },
44579
+ "pipelineAnalytics.listRetrainDatasetVersions": {
44580
+ capName: "pipeline-analytics",
44581
+ capScope: "device",
44582
+ addonId: null,
44583
+ access: "view"
44584
+ },
43112
44585
  "pipelineAnalytics.listRetrainFrames": {
43113
44586
  capName: "pipeline-analytics",
43114
44587
  capScope: "device",
@@ -43139,6 +44612,12 @@ Object.freeze({
43139
44612
  addonId: null,
43140
44613
  access: "view"
43141
44614
  },
44615
+ "pipelineAnalytics.offerRetrainArchive": {
44616
+ capName: "pipeline-analytics",
44617
+ capScope: "device",
44618
+ addonId: null,
44619
+ access: "create"
44620
+ },
43142
44621
  "pipelineAnalytics.ownersWithMedia": {
43143
44622
  capName: "pipeline-analytics",
43144
44623
  capScope: "device",
@@ -43151,6 +44630,12 @@ Object.freeze({
43151
44630
  addonId: null,
43152
44631
  access: "create"
43153
44632
  },
44633
+ "pipelineAnalytics.previewRetrainDataset": {
44634
+ capName: "pipeline-analytics",
44635
+ capScope: "device",
44636
+ addonId: null,
44637
+ access: "view"
44638
+ },
43154
44639
  "pipelineAnalytics.proposeRetrainAnnotations": {
43155
44640
  capName: "pipeline-analytics",
43156
44641
  capScope: "device",
@@ -43289,6 +44774,12 @@ Object.freeze({
43289
44774
  addonId: null,
43290
44775
  access: "create"
43291
44776
  },
44777
+ "pipelineAnalytics.verifyRetrainDatasetVersion": {
44778
+ capName: "pipeline-analytics",
44779
+ capScope: "device",
44780
+ addonId: null,
44781
+ access: "view"
44782
+ },
43292
44783
  "pipelineAnalytics.wipeAllAnalytics": {
43293
44784
  capName: "pipeline-analytics",
43294
44785
  capScope: "device",
@@ -45665,6 +47156,174 @@ Object.freeze({
45665
47156
  addonId: null,
45666
47157
  access: "view"
45667
47158
  },
47159
+ "training.canaryResult": {
47160
+ capName: "training",
47161
+ capScope: "system",
47162
+ addonId: null,
47163
+ access: "create"
47164
+ },
47165
+ "training.cancelJob": {
47166
+ capName: "training",
47167
+ capScope: "system",
47168
+ addonId: null,
47169
+ access: "create"
47170
+ },
47171
+ "training.discardResult": {
47172
+ capName: "training",
47173
+ capScope: "system",
47174
+ addonId: null,
47175
+ access: "create"
47176
+ },
47177
+ "training.findDatasetVersionIdByName": {
47178
+ capName: "training",
47179
+ capScope: "system",
47180
+ addonId: null,
47181
+ access: "view"
47182
+ },
47183
+ "training.getDatasetVersion": {
47184
+ capName: "training",
47185
+ capScope: "system",
47186
+ addonId: null,
47187
+ access: "view"
47188
+ },
47189
+ "training.getJob": {
47190
+ capName: "training",
47191
+ capScope: "system",
47192
+ addonId: null,
47193
+ access: "view"
47194
+ },
47195
+ "training.getJobResult": {
47196
+ capName: "training",
47197
+ capScope: "system",
47198
+ addonId: null,
47199
+ access: "view"
47200
+ },
47201
+ "training.listBaseModels": {
47202
+ capName: "training",
47203
+ capScope: "system",
47204
+ addonId: null,
47205
+ access: "view"
47206
+ },
47207
+ "training.listDatasetVersions": {
47208
+ capName: "training",
47209
+ capScope: "system",
47210
+ addonId: null,
47211
+ access: "view"
47212
+ },
47213
+ "training.listJobs": {
47214
+ capName: "training",
47215
+ capScope: "system",
47216
+ addonId: null,
47217
+ access: "view"
47218
+ },
47219
+ "training.planJob": {
47220
+ capName: "training",
47221
+ capScope: "system",
47222
+ addonId: null,
47223
+ access: "view"
47224
+ },
47225
+ "training.putDatasetVersion": {
47226
+ capName: "training",
47227
+ capScope: "system",
47228
+ addonId: null,
47229
+ access: "create"
47230
+ },
47231
+ "training.registerResult": {
47232
+ capName: "training",
47233
+ capScope: "system",
47234
+ addonId: null,
47235
+ access: "create"
47236
+ },
47237
+ "training.removeDatasetVersion": {
47238
+ capName: "training",
47239
+ capScope: "system",
47240
+ addonId: null,
47241
+ access: "delete"
47242
+ },
47243
+ "training.rollbackCanary": {
47244
+ capName: "training",
47245
+ capScope: "system",
47246
+ addonId: null,
47247
+ access: "create"
47248
+ },
47249
+ "training.startJob": {
47250
+ capName: "training",
47251
+ capScope: "system",
47252
+ addonId: null,
47253
+ access: "create"
47254
+ },
47255
+ "trainingProvider.cancelJob": {
47256
+ capName: "training-provider",
47257
+ capScope: "system",
47258
+ addonId: null,
47259
+ access: "create"
47260
+ },
47261
+ "trainingProvider.cleanupJob": {
47262
+ capName: "training-provider",
47263
+ capScope: "system",
47264
+ addonId: null,
47265
+ access: "create"
47266
+ },
47267
+ "trainingProvider.describe": {
47268
+ capName: "training-provider",
47269
+ capScope: "system",
47270
+ addonId: null,
47271
+ access: "view"
47272
+ },
47273
+ "trainingProvider.estimateJob": {
47274
+ capName: "training-provider",
47275
+ capScope: "system",
47276
+ addonId: null,
47277
+ access: "view"
47278
+ },
47279
+ "trainingProvider.getJob": {
47280
+ capName: "training-provider",
47281
+ capScope: "system",
47282
+ addonId: null,
47283
+ access: "view"
47284
+ },
47285
+ "trainingProvider.listJobEvents": {
47286
+ capName: "training-provider",
47287
+ capScope: "system",
47288
+ addonId: null,
47289
+ access: "view"
47290
+ },
47291
+ "trainingProvider.listJobs": {
47292
+ capName: "training-provider",
47293
+ capScope: "system",
47294
+ addonId: null,
47295
+ access: "view"
47296
+ },
47297
+ "trainingProvider.offerArtifact": {
47298
+ capName: "training-provider",
47299
+ capScope: "system",
47300
+ addonId: null,
47301
+ access: "create"
47302
+ },
47303
+ "trainingProvider.readResult": {
47304
+ capName: "training-provider",
47305
+ capScope: "system",
47306
+ addonId: null,
47307
+ access: "create"
47308
+ },
47309
+ "trainingProvider.submitJob": {
47310
+ capName: "training-provider",
47311
+ capScope: "system",
47312
+ addonId: null,
47313
+ access: "create"
47314
+ },
47315
+ "trainingProvider.uploadDataset": {
47316
+ capName: "training-provider",
47317
+ capScope: "system",
47318
+ addonId: null,
47319
+ access: "create"
47320
+ },
47321
+ "trainingProvider.validateCredentials": {
47322
+ capName: "training-provider",
47323
+ capScope: "system",
47324
+ addonId: null,
47325
+ access: "create"
47326
+ },
45668
47327
  "turnProvider.getTurnServers": {
45669
47328
  capName: "turn-provider",
45670
47329
  capScope: "system",
@@ -45689,12 +47348,6 @@ Object.freeze({
45689
47348
  addonId: null,
45690
47349
  access: "create"
45691
47350
  },
45692
- "userManagement.createApiKey": {
45693
- capName: "user-management",
45694
- capScope: "system",
45695
- addonId: null,
45696
- access: "create"
45697
- },
45698
47351
  "userManagement.createScopedToken": {
45699
47352
  capName: "user-management",
45700
47353
  capScope: "system",
@@ -45731,12 +47384,6 @@ Object.freeze({
45731
47384
  addonId: null,
45732
47385
  access: "view"
45733
47386
  },
45734
- "userManagement.linkExternalIdentity": {
45735
- capName: "user-management",
45736
- capScope: "system",
45737
- addonId: null,
45738
- access: "create"
45739
- },
45740
47387
  "userManagement.listApiKeys": {
45741
47388
  capName: "user-management",
45742
47389
  capScope: "system",
@@ -45839,12 +47486,6 @@ Object.freeze({
45839
47486
  addonId: null,
45840
47487
  access: "create"
45841
47488
  },
45842
- "userManagement.validateApiKey": {
45843
- capName: "user-management",
45844
- capScope: "system",
45845
- addonId: null,
45846
- access: "view"
45847
- },
45848
47489
  "userManagement.validateCredentials": {
45849
47490
  capName: "user-management",
45850
47491
  capScope: "system",
@@ -49958,6 +51599,11 @@ Object.freeze({
49958
51599
  form: "single",
49959
51600
  optional: false
49960
51601
  }],
51602
+ "training.canaryResult": [{
51603
+ name: "deviceIds",
51604
+ form: "array",
51605
+ optional: false
51606
+ }],
49961
51607
  "update.getStatus": [{
49962
51608
  name: "deviceId",
49963
51609
  form: "single",
@@ -50686,6 +52332,8 @@ var STATE_SUMMARY_VARS = [
50686
52332
  [...RULE_TEXT],
50687
52333
  [...RULE_TEXT],
50688
52334
  [...RULE_TEXT],
52335
+ [...RULE_TEXT],
52336
+ [...RULE_TEXT],
50689
52337
  ([...RULE_TEXT], [...UPDATES]),
50690
52338
  ([...RULE_TEXT], [...PACKAGE_UPDATES]),
50691
52339
  ([...RULE_TEXT], [...PACKAGE_UPDATES]),