@camstack/addon-provider-dreo 0.2.123 → 0.2.124

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/dist/addon.js +1771 -131
  2. package/dist/addon.mjs +1771 -131
  3. package/package.json +1 -1
package/dist/addon.mjs CHANGED
@@ -5414,7 +5414,7 @@ var ZodIssueCode = {
5414
5414
  var ZodFirstPartyTypeKind;
5415
5415
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
5416
5416
  //#endregion
5417
- //#region ../types/dist/sleep-Cr5YOk3m.mjs
5417
+ //#region ../types/dist/sleep-r3RWkGVx.mjs
5418
5418
  /**
5419
5419
  * The audio chunk plane's byte format, and the ONE expansion from a coded
5420
5420
  * window to float samples (D455).
@@ -5531,7 +5531,7 @@ function isKeychainStoredField(field) {
5531
5531
  var SECRET_CLEAR = { $secretClear: true };
5532
5532
  /** The `'***'` token D634 redaction writes for non-admins. */
5533
5533
  var LEGACY_DEVICE_REDACTION = "***";
5534
- function isRecord$1(value) {
5534
+ function isRecord$2(value) {
5535
5535
  return typeof value === "object" && value !== null && !Array.isArray(value);
5536
5536
  }
5537
5537
  function makeSecretMarker(ref) {
@@ -5542,12 +5542,12 @@ function makeSecretMarker(ref) {
5542
5542
  }
5543
5543
  /** A stored marker: an object whose `$secret` is a non-empty string. */
5544
5544
  function isSecretMarker(value) {
5545
- if (!isRecord$1(value)) return false;
5545
+ if (!isRecord$2(value)) return false;
5546
5546
  const ref = value["$secret"];
5547
5547
  return typeof ref === "string" && ref.length > 0;
5548
5548
  }
5549
5549
  function isSecretClear(value) {
5550
- return isRecord$1(value) && value["$secretClear"] === true;
5550
+ return isRecord$2(value) && value["$secretClear"] === true;
5551
5551
  }
5552
5552
  /**
5553
5553
  * The UI view of a stored secret field value: a marker becomes "set", inline
@@ -6063,6 +6063,13 @@ function globalSecretScope() {
6063
6063
  function encodeSegment(value) {
6064
6064
  return encodeURIComponent(value);
6065
6065
  }
6066
+ function decodeSegment(value) {
6067
+ try {
6068
+ return decodeURIComponent(value);
6069
+ } catch {
6070
+ return null;
6071
+ }
6072
+ }
6066
6073
  /**
6067
6074
  * The field path of a value inside an array item, addressed by the item's id:
6068
6075
  * `arrayItemFieldPath('providers', 'authentik', 'clientSecret')` →
@@ -6071,6 +6078,75 @@ function encodeSegment(value) {
6071
6078
  function arrayItemFieldPath(arrayKey, itemId, fieldKey) {
6072
6079
  return `${arrayKey}[${encodeSegment(itemId)}].${fieldKey}`;
6073
6080
  }
6081
+ function parseScope(segments) {
6082
+ switch (segments[0]) {
6083
+ case "global": return {
6084
+ scope: GLOBAL_SCOPE,
6085
+ used: 1
6086
+ };
6087
+ case "node": {
6088
+ const nodeId = segments[1] !== void 0 ? decodeSegment(segments[1]) : null;
6089
+ return nodeId === null || nodeId.length === 0 ? null : {
6090
+ scope: {
6091
+ kind: "node",
6092
+ nodeId
6093
+ },
6094
+ used: 2
6095
+ };
6096
+ }
6097
+ case "device": {
6098
+ const raw = segments[1];
6099
+ if (raw === void 0 || !/^\d+$/.test(raw)) return null;
6100
+ return {
6101
+ scope: {
6102
+ kind: "device",
6103
+ deviceId: Number(raw)
6104
+ },
6105
+ used: 2
6106
+ };
6107
+ }
6108
+ case "integration": {
6109
+ const id = segments[1] !== void 0 ? decodeSegment(segments[1]) : null;
6110
+ return id === null || id.length === 0 ? null : {
6111
+ scope: {
6112
+ kind: "integration",
6113
+ integrationId: id
6114
+ },
6115
+ used: 2
6116
+ };
6117
+ }
6118
+ case "row": {
6119
+ const collection = segments[1] !== void 0 ? decodeSegment(segments[1]) : null;
6120
+ const rowId = segments[2] !== void 0 ? decodeSegment(segments[2]) : null;
6121
+ if (collection === null || rowId === null || collection.length === 0 || rowId.length === 0) return null;
6122
+ return {
6123
+ scope: {
6124
+ kind: "row",
6125
+ collection,
6126
+ rowId
6127
+ },
6128
+ used: 3
6129
+ };
6130
+ }
6131
+ default: return null;
6132
+ }
6133
+ }
6134
+ /** Take a ref apart; `null` when it is not a well-formed ref. */
6135
+ function parseSecretRef(ref) {
6136
+ if (!ref.startsWith("secret://")) return null;
6137
+ const segments = ref.slice(9).split("/");
6138
+ const owner = segments[0] !== void 0 ? decodeSegment(segments[0]) : null;
6139
+ if (owner === null || owner.length === 0) return null;
6140
+ const parsed = parseScope(segments.slice(1));
6141
+ if (parsed === null) return null;
6142
+ const fieldPath = segments.slice(1 + parsed.used).join("/");
6143
+ if (fieldPath.length === 0) return null;
6144
+ return {
6145
+ owner,
6146
+ scope: parsed.scope,
6147
+ fieldPath
6148
+ };
6149
+ }
6074
6150
  /** A write to a secret path could not be stored in the keychain, so it was refused. */
6075
6151
  var KeychainWriteRefusedError = class extends Error {
6076
6152
  fieldPath;
@@ -6081,7 +6157,7 @@ var KeychainWriteRefusedError = class extends Error {
6081
6157
  }
6082
6158
  };
6083
6159
  var KEEP = { kind: "keep" };
6084
- function isRecord(value) {
6160
+ function isRecord$1(value) {
6085
6161
  return typeof value === "object" && value !== null && !Array.isArray(value);
6086
6162
  }
6087
6163
  function defaultMintId() {
@@ -6094,7 +6170,7 @@ function collectSecretMarkerRefs(value, out = []) {
6094
6170
  return out;
6095
6171
  }
6096
6172
  if (Array.isArray(value)) for (const item of value) collectSecretMarkerRefs(item, out);
6097
- else if (isRecord(value)) for (const child of Object.values(value)) collectSecretMarkerRefs(child, out);
6173
+ else if (isRecord$1(value)) for (const child of Object.values(value)) collectSecretMarkerRefs(child, out);
6098
6174
  return out;
6099
6175
  }
6100
6176
  async function storedValueEquals(secrets, marker, candidate) {
@@ -6149,7 +6225,7 @@ function rowId(row, idKey) {
6149
6225
  return null;
6150
6226
  }
6151
6227
  async function writeArray(ctx, node, incoming, stored, fieldPath) {
6152
- const storedRows = Array.isArray(stored) ? stored.filter(isRecord) : [];
6228
+ const storedRows = Array.isArray(stored) ? stored.filter(isRecord$1) : [];
6153
6229
  if (!Array.isArray(incoming)) {
6154
6230
  ctx.deletes.push(...collectSecretMarkerRefs(storedRows));
6155
6231
  return {
@@ -6165,7 +6241,7 @@ async function writeArray(ctx, node, incoming, stored, fieldPath) {
6165
6241
  const kept = /* @__PURE__ */ new Set();
6166
6242
  const rows = [];
6167
6243
  for (const row of incoming) {
6168
- if (!isRecord(row)) {
6244
+ if (!isRecord$1(row)) {
6169
6245
  rows.push(row);
6170
6246
  continue;
6171
6247
  }
@@ -6190,7 +6266,7 @@ async function writeNode(ctx, node, incoming, stored, fieldPath) {
6190
6266
  case "leaf": return writeLeaf(ctx, incoming, stored, fieldPath);
6191
6267
  case "array": return writeArray(ctx, node, incoming, stored, fieldPath);
6192
6268
  case "object": {
6193
- if (!isRecord(incoming)) {
6269
+ if (!isRecord$1(incoming)) {
6194
6270
  if (incoming === void 0) return KEEP;
6195
6271
  ctx.deletes.push(...collectSecretMarkerRefs(stored));
6196
6272
  return {
@@ -6198,7 +6274,7 @@ async function writeNode(ctx, node, incoming, stored, fieldPath) {
6198
6274
  value: incoming
6199
6275
  };
6200
6276
  }
6201
- const storedObj = isRecord(stored) ? stored : {};
6277
+ const storedObj = isRecord$1(stored) ? stored : {};
6202
6278
  return {
6203
6279
  kind: "value",
6204
6280
  value: await writeMembers(ctx, node.children, incoming, storedObj, (m) => `${fieldPath}.${m}`)
@@ -6257,12 +6333,19 @@ async function transformSecretWrite(input) {
6257
6333
  }
6258
6334
  };
6259
6335
  }
6336
+ /** Is `ref` one of `owner`'s refs? */
6337
+ function isSecretRefOwnedBy(ref, owner) {
6338
+ return parseSecretRef(ref)?.owner === owner;
6339
+ }
6260
6340
  /**
6261
6341
  * Replace every marker in `value` with its keychain value. Returns the SAME
6262
6342
  * reference when there is no marker (no allocation, no keychain call).
6263
6343
  */
6264
- async function resolveSecretMarkers(value, secrets) {
6265
- const refs = collectSecretMarkerRefs(value);
6344
+ async function resolveSecretMarkers(value, secrets, options = {}) {
6345
+ const keepMarker = options.unresolved === "keep-marker";
6346
+ const owner = options.ownedBy;
6347
+ const inScope = (ref) => owner === void 0 || isSecretRefOwnedBy(ref, owner);
6348
+ const refs = collectSecretMarkerRefs(value).filter(inScope);
6266
6349
  if (refs.length === 0) return {
6267
6350
  value,
6268
6351
  unresolved: []
@@ -6286,10 +6369,18 @@ async function resolveSecretMarkers(value, secrets) {
6286
6369
  }
6287
6370
  const substitute = (v) => {
6288
6371
  if (isSecretMarker(v)) {
6372
+ if (!inScope(v.$secret)) return {
6373
+ keep: true,
6374
+ value: v
6375
+ };
6289
6376
  const answer = answers[v.$secret];
6290
- return answer?.kind === "value" ? {
6377
+ if (answer?.kind === "value") return {
6291
6378
  keep: true,
6292
6379
  value: answer.value
6380
+ };
6381
+ return keepMarker ? {
6382
+ keep: true,
6383
+ value: v
6293
6384
  } : {
6294
6385
  keep: false,
6295
6386
  value: void 0
@@ -6306,7 +6397,7 @@ async function resolveSecretMarkers(value, secrets) {
6306
6397
  value: items
6307
6398
  };
6308
6399
  }
6309
- if (isRecord(v)) {
6400
+ if (isRecord$1(v)) {
6310
6401
  const out = {};
6311
6402
  for (const [k, child] of Object.entries(v)) {
6312
6403
  const s = substitute(child);
@@ -6327,14 +6418,152 @@ async function resolveSecretMarkers(value, secrets) {
6327
6418
  unresolved
6328
6419
  };
6329
6420
  }
6330
- function touchesTree(tree, patch) {
6331
- if (tree.size === 0) return false;
6332
- for (const key of Object.keys(patch)) {
6333
- const at = key.indexOf("@");
6334
- if (tree.has(at > 0 ? key.slice(0, at) : key)) return true;
6421
+ /** An addon tried to replace a stored secret it could not read. Nothing was written. */
6422
+ var SecretOverwriteRefusedError = class extends Error {
6423
+ ref;
6424
+ reason;
6425
+ constructor(ref, reason) {
6426
+ 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.`);
6427
+ this.ref = ref;
6428
+ this.reason = reason;
6429
+ this.name = "SecretOverwriteRefusedError";
6430
+ }
6431
+ };
6432
+ function isRecord(value) {
6433
+ return typeof value === "object" && value !== null && !Array.isArray(value);
6434
+ }
6435
+ function resolvedValue(pass, marker) {
6436
+ const answer = pass.answers[marker.$secret];
6437
+ return answer?.kind === "value" ? answer.value : null;
6438
+ }
6439
+ async function atMarker(pass, incoming, stored) {
6440
+ if (incoming === null) return stored;
6441
+ if (typeof incoming !== "string") return incoming;
6442
+ if (incoming === resolvedValue(pass, stored)) return stored;
6443
+ const intent = classifySecretWrite(incoming);
6444
+ if (intent.kind !== "set") return stored;
6445
+ const ref = stored.$secret;
6446
+ if (!isSecretRefOwnedBy(ref, pass.secrets.owner)) return incoming;
6447
+ const answer = pass.answers[ref];
6448
+ 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);
6449
+ try {
6450
+ await pass.secrets.put(ref, intent.value);
6451
+ } catch (err) {
6452
+ throw new KeychainWriteRefusedError(ref, err);
6453
+ }
6454
+ pass.changedRefs.push(ref);
6455
+ return stored;
6456
+ }
6457
+ function inArray(pass, incoming, stored) {
6458
+ return incoming.map((item, index) => {
6459
+ const twin = stored[index];
6460
+ if (isSecretMarker(twin)) return typeof item === "string" && item === resolvedValue(pass, twin) ? twin : item;
6461
+ if (isRecord(item) && isRecord(twin)) return inArrayRow(pass, item, twin);
6462
+ if (Array.isArray(item) && Array.isArray(twin)) return inArray(pass, item, twin);
6463
+ return item;
6464
+ });
6465
+ }
6466
+ function inArrayRow(pass, incoming, stored) {
6467
+ const out = { ...incoming };
6468
+ for (const [key, value] of Object.entries(incoming)) {
6469
+ const twin = stored[key];
6470
+ if (isSecretMarker(twin)) {
6471
+ if (typeof value === "string" && value === resolvedValue(pass, twin)) out[key] = twin;
6472
+ } else if (isRecord(value) && isRecord(twin)) out[key] = inArrayRow(pass, value, twin);
6473
+ else if (Array.isArray(value) && Array.isArray(twin)) out[key] = inArray(pass, value, twin);
6474
+ }
6475
+ return out;
6476
+ }
6477
+ async function walk(pass, incoming, stored) {
6478
+ if (isSecretMarker(stored)) return atMarker(pass, incoming, stored);
6479
+ if (Array.isArray(incoming) && Array.isArray(stored)) return inArray(pass, incoming, stored);
6480
+ if (!isRecord(incoming) || !isRecord(stored)) return incoming;
6481
+ const out = { ...incoming };
6482
+ for (const [key, value] of Object.entries(incoming)) out[key] = await walk(pass, value, stored[key]);
6483
+ return out;
6484
+ }
6485
+ /** Restore markers a write-back carries as values. See the file doc. */
6486
+ async function restoreUnchangedSecrets(input) {
6487
+ const refs = [];
6488
+ for (const key of Object.keys(input.patch)) collectSecretMarkerRefs(input.stored[key], refs);
6489
+ const owned = refs.filter((ref) => isSecretRefOwnedBy(ref, input.secrets.owner));
6490
+ if (owned.length === 0) return {
6491
+ patch: input.patch,
6492
+ changedRefs: []
6493
+ };
6494
+ const pass = {
6495
+ secrets: input.secrets,
6496
+ answers: await input.secrets.resolve([...new Set(owned)]),
6497
+ operatorWrite: input.operatorWrite,
6498
+ changedRefs: []
6499
+ };
6500
+ const out = {};
6501
+ for (const [key, value] of Object.entries(input.patch)) out[key] = await walk(pass, value, input.stored[key]);
6502
+ return {
6503
+ patch: out,
6504
+ changedRefs: pass.changedRefs
6505
+ };
6506
+ }
6507
+ /** Structural equality over JSON-shaped values (key order does not matter). */
6508
+ function isJsonEqual(a, b) {
6509
+ if (Object.is(a, b)) return true;
6510
+ if (Array.isArray(a)) return Array.isArray(b) && a.length === b.length && a.every((v, i) => isJsonEqual(v, b[i]));
6511
+ if (isRecord(a) && isRecord(b)) {
6512
+ const keys = Object.keys(a);
6513
+ if (keys.length !== Object.keys(b).length) return false;
6514
+ return keys.every((k) => Object.prototype.hasOwnProperty.call(b, k) && isJsonEqual(a[k], b[k]));
6335
6515
  }
6336
6516
  return false;
6337
6517
  }
6518
+ /** The patch without the keys whose value already equals the stored one. */
6519
+ function dropUnchangedKeys(patch, stored) {
6520
+ const out = {};
6521
+ for (const [key, value] of Object.entries(patch)) {
6522
+ if (Object.prototype.hasOwnProperty.call(stored, key) && isJsonEqual(value, stored[key])) continue;
6523
+ out[key] = value;
6524
+ }
6525
+ return out;
6526
+ }
6527
+ /** The top-level keys of a blob that hold at least one of `owner`'s markers. */
6528
+ function markerKeysOf(blob, owner) {
6529
+ const keys = /* @__PURE__ */ new Set();
6530
+ for (const [key, value] of Object.entries(blob)) if (collectSecretMarkerRefs(value).some((ref) => isSecretRefOwnedBy(ref, owner))) keys.add(key);
6531
+ return keys;
6532
+ }
6533
+ function nodeFromStored(value, owner) {
6534
+ if (isSecretMarker(value)) return isSecretRefOwnedBy(value.$secret, owner) ? { kind: "leaf" } : null;
6535
+ if (!isRecord(value)) return null;
6536
+ const children = /* @__PURE__ */ new Map();
6537
+ for (const [key, child] of Object.entries(value)) {
6538
+ const node = nodeFromStored(child, owner);
6539
+ if (node !== null) children.set(key, node);
6540
+ }
6541
+ return children.size > 0 ? {
6542
+ kind: "object",
6543
+ children
6544
+ } : null;
6545
+ }
6546
+ /**
6547
+ * The declared secret tree, widened by every place the STORED blob holds a
6548
+ * marker under one of `keys` — so a marker the schema no longer declares (or
6549
+ * never declared: Wyze before b4906cec6) still gets the save path's
6550
+ * KEEP / SET / CLEAR semantics instead of being overwritten by whatever the
6551
+ * addon writes. Markers inside arrays are not added: a row has no id field to
6552
+ * match by unless the schema declares one. Only `owner`'s markers count: a
6553
+ * builtin that keeps another addon's marker (device-manager) never takes it
6554
+ * over.
6555
+ */
6556
+ function widenTreeWithStoredMarkers(declared, stored, keys, owner) {
6557
+ const added = /* @__PURE__ */ new Map();
6558
+ for (const key of keys) {
6559
+ const at = key.indexOf("@");
6560
+ const base = at > 0 ? key.slice(0, at) : key;
6561
+ if (declared.has(base) || added.has(base)) continue;
6562
+ const node = nodeFromStored(stored[key], owner);
6563
+ if (node !== null) added.set(base, node);
6564
+ }
6565
+ return added.size === 0 ? declared : new Map([...declared, ...added]);
6566
+ }
6338
6567
  /** The blob as stored now; a failed read REFUSES the write instead of guessing. */
6339
6568
  async function readStoredAddonBlob(raw) {
6340
6569
  const threeWay = raw.readAddonStoreResult;
@@ -6343,7 +6572,41 @@ async function readStoredAddonBlob(raw) {
6343
6572
  if (result.kind === "failed") throw new Error(`settings write refused: the stored blob could not be read (${result.error})`);
6344
6573
  return result.kind === "missing" ? {} : result.value;
6345
6574
  }
6346
- function createSecretAwareSettings(raw, opts) {
6575
+ function touchesTree(tree, patch) {
6576
+ if (tree.size === 0) return false;
6577
+ for (const key of Object.keys(patch)) {
6578
+ const at = key.indexOf("@");
6579
+ if (tree.has(at > 0 ? key.slice(0, at) : key)) return true;
6580
+ }
6581
+ return false;
6582
+ }
6583
+ /**
6584
+ * Which top-level keys of each store held markers when last seen. `undefined`
6585
+ * for a store not seen yet: its first write reads it, to be safe.
6586
+ */
6587
+ var MarkerKeyIndex = class {
6588
+ owner;
6589
+ byStore = /* @__PURE__ */ new Map();
6590
+ constructor(owner) {
6591
+ this.owner = owner;
6592
+ }
6593
+ seen(store, blob) {
6594
+ this.byStore.set(store, markerKeysOf(blob, this.owner));
6595
+ }
6596
+ wrote(store, patch) {
6597
+ const keys = this.byStore.get(store);
6598
+ if (keys === void 0) return;
6599
+ const now = markerKeysOf(patch, this.owner);
6600
+ for (const key of Object.keys(patch)) if (now.has(key)) keys.add(key);
6601
+ else keys.delete(key);
6602
+ }
6603
+ mayHoldMarkers(store, patch) {
6604
+ const keys = this.byStore.get(store);
6605
+ if (keys === void 0) return true;
6606
+ return Object.keys(patch).some((key) => keys.has(key));
6607
+ }
6608
+ };
6609
+ function createHandle(raw, opts) {
6347
6610
  const chains = /* @__PURE__ */ new Map();
6348
6611
  const serialize = (key, fn) => {
6349
6612
  const next = (chains.get(key) ?? Promise.resolve()).then(fn, fn);
@@ -6354,46 +6617,130 @@ function createSecretAwareSettings(raw, opts) {
6354
6617
  });
6355
6618
  return next;
6356
6619
  };
6357
- const write = async (chainKey, tree, scope, patch, readStored, rawWrite) => {
6358
- if (!touchesTree(tree, patch)) return rawWrite(patch);
6359
- return serialize(chainKey, async () => {
6620
+ const index = new MarkerKeyIndex(opts.secrets.owner);
6621
+ const resolveRead = async (store, blob) => {
6622
+ index.seen(store, blob);
6623
+ const { value, unresolved } = await resolveSecretMarkers(blob, opts.secrets, {
6624
+ unresolved: "keep-marker",
6625
+ ownedBy: opts.secrets.owner
6626
+ });
6627
+ if (unresolved.length > 0) opts.onUnresolved?.(unresolved);
6628
+ return value;
6629
+ };
6630
+ const write = async (store, declared, scope, patch, readStored, rawWrite) => {
6631
+ if (!touchesTree(declared, patch) && !index.mayHoldMarkers(store, patch)) {
6632
+ await rawWrite(patch);
6633
+ index.wrote(store, patch);
6634
+ return { changed: true };
6635
+ }
6636
+ return serialize(store, async () => {
6360
6637
  const stored = await readStored();
6638
+ index.seen(store, stored);
6639
+ const operatorWrite = opts.isOperatorWrite?.() === true;
6640
+ const restored = await restoreUnchangedSecrets({
6641
+ patch,
6642
+ stored,
6643
+ secrets: opts.secrets,
6644
+ operatorWrite
6645
+ });
6361
6646
  const result = await transformSecretWrite({
6362
- tree,
6647
+ tree: widenTreeWithStoredMarkers(declared, stored, Object.keys(restored.patch), opts.secrets.owner),
6363
6648
  secrets: opts.secrets,
6364
- patch,
6649
+ patch: restored.patch,
6365
6650
  stored,
6366
6651
  ...scope !== void 0 ? { scope } : {},
6367
- operatorWrite: opts.isOperatorWrite?.() === true
6652
+ operatorWrite
6368
6653
  });
6369
- if (Object.keys(result.patch).length > 0) await rawWrite(result.patch);
6654
+ const effective = dropUnchangedKeys(result.patch, stored);
6655
+ const wroteBlob = Object.keys(effective).length > 0;
6656
+ if (wroteBlob) {
6657
+ await rawWrite(effective);
6658
+ index.wrote(store, effective);
6659
+ }
6370
6660
  const { orphaned } = await result.afterWrite();
6371
6661
  if (orphaned.length > 0) opts.onOrphaned(orphaned);
6662
+ return { changed: wroteBlob || restored.changedRefs.length > 0 };
6372
6663
  });
6373
6664
  };
6374
- const wrapped = {
6375
- writeAddonStore: (patch) => write("addon", opts.addonTree(), void 0, patch, () => readStoredAddonBlob(raw), (p) => raw.writeAddonStore(p)),
6376
- writeDeviceStore: (deviceId, patch) => write(`device:${deviceId}`, opts.deviceTree(), {
6377
- kind: "device",
6378
- deviceId
6379
- }, patch, () => raw.readDeviceStore(deviceId), (p) => raw.writeDeviceStore(deviceId, p))
6665
+ const writeAddon = (patch) => write("addon", opts.addonTree(), void 0, patch, () => readStoredAddonBlob(raw), (p) => raw.writeAddonStore(p));
6666
+ const readAddonStoreResult = raw.readAddonStoreResult;
6667
+ const readAddonStoreKeyResult = raw.readAddonStoreKeyResult;
6668
+ const readDeviceStoreBatch = raw.readDeviceStoreBatch;
6669
+ const overrides = {
6670
+ readAddonStore: async () => resolveRead("addon", await raw.readAddonStore()),
6671
+ ...readAddonStoreResult !== void 0 ? { readAddonStoreResult: async () => {
6672
+ const result = await readAddonStoreResult.call(raw);
6673
+ return result.kind === "value" ? {
6674
+ kind: "value",
6675
+ value: await resolveRead("addon", result.value)
6676
+ } : result;
6677
+ } } : {},
6678
+ ...readAddonStoreKeyResult !== void 0 ? { readAddonStoreKeyResult: async (key) => {
6679
+ const result = await readAddonStoreKeyResult.call(raw, key);
6680
+ if (result.kind !== "present") return result;
6681
+ const { value, unresolved } = await resolveSecretMarkers({ [key]: result.value }, opts.secrets, {
6682
+ unresolved: "keep-marker",
6683
+ ownedBy: opts.secrets.owner
6684
+ });
6685
+ if (unresolved.length > 0) opts.onUnresolved?.(unresolved);
6686
+ return {
6687
+ kind: "present",
6688
+ value: value[key]
6689
+ };
6690
+ } } : {},
6691
+ readDeviceStore: async (deviceId) => resolveRead(`device:${deviceId}`, await raw.readDeviceStore(deviceId)),
6692
+ ...readDeviceStoreBatch !== void 0 ? { readDeviceStoreBatch: async (deviceIds) => {
6693
+ const rows = await readDeviceStoreBatch.call(raw, deviceIds);
6694
+ const out = /* @__PURE__ */ new Map();
6695
+ for (const [deviceId, blob] of rows) out.set(deviceId, await resolveRead(`device:${deviceId}`, blob));
6696
+ return out;
6697
+ } } : {},
6698
+ writeAddonStore: async (patch) => {
6699
+ await writeAddon(patch);
6700
+ },
6701
+ writeDeviceStore: async (deviceId, patch) => {
6702
+ await write(`device:${deviceId}`, opts.deviceTree(), {
6703
+ kind: "device",
6704
+ deviceId
6705
+ }, patch, () => raw.readDeviceStore(deviceId), (p) => raw.writeDeviceStore(deviceId, p));
6706
+ }
6707
+ };
6708
+ return {
6709
+ settings: new Proxy(raw, { get(target, prop, receiver) {
6710
+ if (typeof prop === "string" && Object.prototype.hasOwnProperty.call(overrides, prop)) return Reflect.get(overrides, prop);
6711
+ const value = Reflect.get(target, prop, receiver);
6712
+ return typeof value === "function" ? value.bind(target) : value;
6713
+ } }),
6714
+ raw: {
6715
+ readAddonStore: async () => {
6716
+ const blob = await raw.readAddonStore();
6717
+ index.seen("addon", blob);
6718
+ return blob;
6719
+ },
6720
+ readDeviceStore: async (deviceId) => {
6721
+ const blob = await raw.readDeviceStore(deviceId);
6722
+ index.seen(`device:${deviceId}`, blob);
6723
+ return blob;
6724
+ }
6725
+ },
6726
+ writeAddonStore: writeAddon
6380
6727
  };
6381
- return new Proxy(raw, { get(target, prop, receiver) {
6382
- if (prop === "writeAddonStore") return wrapped.writeAddonStore;
6383
- if (prop === "writeDeviceStore") return wrapped.writeDeviceStore;
6384
- const value = Reflect.get(target, prop, receiver);
6385
- return typeof value === "function" ? value.bind(target) : value;
6386
- } });
6387
6728
  }
6388
- /** The context the addon sees: identical, except that its settings writes are secret-aware. */
6389
- function withSecretAwareSettings(context, opts) {
6729
+ /** The context the addon sees, plus the private raw view and write outcome. */
6730
+ function createSecretAwareContext(context, opts) {
6390
6731
  const raw = context.settings;
6391
- if (raw === void 0) return context;
6392
- const settings = createSecretAwareSettings(raw, opts);
6393
- return new Proxy(context, { get(target, prop, receiver) {
6394
- if (prop === "settings") return settings;
6395
- return Reflect.get(target, prop, receiver);
6396
- } });
6732
+ if (raw === void 0) return {
6733
+ context,
6734
+ handle: null
6735
+ };
6736
+ const handle = createHandle(raw, opts);
6737
+ return {
6738
+ context: new Proxy(context, { get(target, prop, receiver) {
6739
+ if (prop === "settings") return handle.settings;
6740
+ return Reflect.get(target, prop, receiver);
6741
+ } }),
6742
+ handle
6743
+ };
6397
6744
  }
6398
6745
  var LEAF = { kind: "leaf" };
6399
6746
  var DEFAULT_ITEM_ID_KEY = "id";
@@ -6568,6 +6915,14 @@ var BaseAddon = class {
6568
6915
  _secretChangeUnsub = null;
6569
6916
  /** >0 while an OPERATOR's settings write is being applied. */
6570
6917
  _operatorWriteDepth = 0;
6918
+ /**
6919
+ * The keychain-aware settings handle (D798). Its `raw` view is the ONLY way
6920
+ * to the marker-bearing blobs and stays private to this class: the form
6921
+ * hydrate and config resolution need markers, addon code never does.
6922
+ */
6923
+ _secretSettings = null;
6924
+ /** Refs an addon-facing read could not resolve — each is logged once per process. */
6925
+ _loggedUnresolvedReads = /* @__PURE__ */ new Set();
6571
6926
  constructor(defaults) {
6572
6927
  this.defaults = defaults;
6573
6928
  this._config = { ...defaults };
@@ -6604,13 +6959,21 @@ var BaseAddon = class {
6604
6959
  }
6605
6960
  async initialize(context) {
6606
6961
  const secrets = context.secrets;
6607
- this._ctx = secrets !== void 0 ? withSecretAwareSettings(context, {
6608
- secrets,
6609
- addonTree: () => this.addonSecretTree(),
6610
- deviceTree: () => this.deviceSecretTree(),
6611
- onOrphaned: (refs) => context.logger.warn("keychain refs dropped by a settings write could not be deleted", { meta: { refs: [...refs] } }),
6612
- isOperatorWrite: () => this._operatorWriteDepth > 0
6613
- }) : context;
6962
+ if (secrets !== void 0) {
6963
+ const { context: wrapped, handle } = createSecretAwareContext(context, {
6964
+ secrets,
6965
+ addonTree: () => this.addonSecretTree(),
6966
+ deviceTree: () => this.deviceSecretTree(),
6967
+ onOrphaned: (refs) => context.logger.warn("keychain refs dropped by a settings write could not be deleted", { meta: { refs: [...refs] } }),
6968
+ isOperatorWrite: () => this._operatorWriteDepth > 0,
6969
+ onUnresolved: (unresolved) => this.logUnresolvedRead(unresolved)
6970
+ });
6971
+ this._ctx = wrapped;
6972
+ this._secretSettings = handle;
6973
+ } else {
6974
+ this._ctx = context;
6975
+ this._secretSettings = null;
6976
+ }
6614
6977
  await this.resolveConfig();
6615
6978
  if (secrets !== void 0) this._secretChangeUnsub = secrets.onChange((ref) => {
6616
6979
  if (this._configSecretRefs.has(ref)) this.scheduleSecretReresolve(SECRET_CHANGE_DEBOUNCE_MS);
@@ -6727,11 +7090,8 @@ var BaseAddon = class {
6727
7090
  async getGlobalSettings(overlay, cap, nodeId) {
6728
7091
  const schema = this.globalSettingsSchema(cap);
6729
7092
  if (!schema) return { sections: [] };
6730
- const projected = await this.resolveGlobalStore(nodeId, cap);
6731
- return hydrateSchema(schema, overlay ? {
6732
- ...projected,
6733
- ...overlay
6734
- } : projected, { inlineSecretsAsViews: true });
7093
+ const projected = await this.readRawProjectedStore(nodeId, cap);
7094
+ return hydrateSchema(schema, overlay ? await this.overlayKeepingMarkers(projected, overlay) : projected, { inlineSecretsAsViews: true });
6735
7095
  }
6736
7096
  /**
6737
7097
  * The integration-level view of this addon's settings: exactly the sections
@@ -6776,7 +7136,7 @@ var BaseAddon = class {
6776
7136
  });
6777
7137
  }
6778
7138
  if (sections.length === 0) return null;
6779
- const projected = await this.resolveGlobalStore(nodeId);
7139
+ const projected = await this.readRawProjectedStore(nodeId);
6780
7140
  return hydrateSchema({
6781
7141
  ...schema,
6782
7142
  sections
@@ -6793,12 +7153,50 @@ var BaseAddon = class {
6793
7153
  * the store for custom option logic (option narrowing, value snapping) to
6794
7154
  * read it per-node — never `ctx.settings.readAddonStore()` directly.
6795
7155
  * `nodeId` omitted ⇒ the local node (node-blind injection from ctx).
7156
+ *
7157
+ * Keychain values come back RESOLVED (D798): a secret reads as its value,
7158
+ * never as a `{ $secret }` marker. One the keychain cannot serve right now
7159
+ * stays a marker — "stored, unavailable" (`isSecretMarker()` is true, and it
7160
+ * is listed in {@link unresolvedSecrets}) — never `''` and never absent, so
7161
+ * it cannot be mistaken for "nothing stored, mint a new one". Writing the
7162
+ * resolved blob back is a no-op for every unchanged secret.
6796
7163
  */
6797
7164
  async resolveGlobalStore(nodeId, cap) {
6798
7165
  const raw = await this._ctx?.settings?.readAddonStore() ?? {};
7166
+ return this.projectForNode(raw, nodeId, cap);
7167
+ }
7168
+ projectForNode(store, nodeId, cap) {
6799
7169
  const keys = this.perNodeKeys(cap);
6800
7170
  const node = normalizeNodeId(nodeId ?? this._ctx?.kernel?.localNodeId);
6801
- return keys.size > 0 ? projectStore(raw, keys, node) : raw;
7171
+ return keys.size > 0 ? projectStore(store, keys, node) : store;
7172
+ }
7173
+ /** The PROJECTED store with its markers — the form hydrate only (D798). */
7174
+ async readRawProjectedStore(nodeId, cap) {
7175
+ const raw = await this.rawSettings()?.readAddonStore() ?? {};
7176
+ return this.projectForNode(raw, nodeId, cap);
7177
+ }
7178
+ /**
7179
+ * `{ ...stored, ...overlay }`, except that an overlay member equal to the
7180
+ * RESOLVED stored one keeps the stored (marker-bearing) member — so a form
7181
+ * hydrated from a resolved overlay still shows a secret as "set", never as
7182
+ * its value.
7183
+ */
7184
+ async overlayKeepingMarkers(stored, overlay) {
7185
+ const secrets = this._ctx?.secrets;
7186
+ const merged = {
7187
+ ...stored,
7188
+ ...overlay
7189
+ };
7190
+ if (secrets === void 0 || collectSecretMarkerRefs(stored).length === 0) return merged;
7191
+ const { value: resolved } = await resolveSecretMarkers(stored, secrets, {
7192
+ unresolved: "keep-marker",
7193
+ ownedBy: secrets.owner
7194
+ });
7195
+ for (const key of Object.keys(overlay)) {
7196
+ if (collectSecretMarkerRefs(stored[key]).length === 0) continue;
7197
+ if (isJsonEqual(overlay[key], resolved[key])) merged[key] = stored[key];
7198
+ }
7199
+ return merged;
6802
7200
  }
6803
7201
  /**
6804
7202
  * Whether ONE global key of this addon's store was written, read three-way
@@ -6863,8 +7261,12 @@ var BaseAddon = class {
6863
7261
  async clearSecrets(keys, nodeId) {
6864
7262
  const tree = this.addonSecretTree();
6865
7263
  const keychain = this._ctx?.secrets !== void 0;
7264
+ const stored = keychain ? await this.readAddonStoreWithRetry() : {};
6866
7265
  const patch = {};
6867
- for (const key of keys) patch[key] = keychain && tree.has(key) ? SECRET_CLEAR : "";
7266
+ for (const key of keys) {
7267
+ const keychainStored = tree.has(key) || collectSecretMarkerRefs(stored[key]).length > 0;
7268
+ patch[key] = keychain && keychainStored ? SECRET_CLEAR : "";
7269
+ }
6868
7270
  await this.applyGlobalPatch(patch, nodeId);
6869
7271
  }
6870
7272
  async applyGlobalPatch(barePatch, nodeId) {
@@ -6872,7 +7274,11 @@ var BaseAddon = class {
6872
7274
  const localNode = normalizeNodeId(this._ctx?.kernel?.localNodeId);
6873
7275
  const target = normalizeNodeId(nodeId ?? this._ctx?.kernel?.localNodeId);
6874
7276
  const scoped = keys.size > 0 ? scopePatch(barePatch, keys, target) : barePatch;
6875
- await this._ctx?.settings?.writeAddonStore(scoped);
7277
+ const handle = this._secretSettings;
7278
+ if (handle !== null) {
7279
+ const { changed } = await handle.writeAddonStore(scoped);
7280
+ if (!changed) return;
7281
+ } else await this._ctx?.settings?.writeAddonStore(scoped);
6876
7282
  if (target !== localNode) return;
6877
7283
  await this.resolveConfig();
6878
7284
  await this.onConfigChanged();
@@ -6925,7 +7331,7 @@ var BaseAddon = class {
6925
7331
  async getDeviceSettings(deviceId) {
6926
7332
  const schema = this.deviceSettingsSchema();
6927
7333
  if (!schema) return { sections: [] };
6928
- return hydrateSchema(schema, await this._ctx?.settings?.readDeviceStore(deviceId) ?? {}, { inlineSecretsAsViews: true });
7334
+ return hydrateSchema(schema, await this.rawSettings()?.readDeviceStore(deviceId) ?? {}, { inlineSecretsAsViews: true });
6929
7335
  }
6930
7336
  async updateDeviceSettings(deviceId, patch) {
6931
7337
  await this._ctx?.settings?.writeDeviceStore(deviceId, patch);
@@ -7097,7 +7503,7 @@ var BaseAddon = class {
7097
7503
  key,
7098
7504
  schema,
7099
7505
  fallback,
7100
- read: async () => this.resolveStoredSecrets(await this._ctx?.settings?.readDeviceStore(deviceId) ?? {}, false),
7506
+ read: async () => this.resolveStoredSecrets(await this.rawSettings()?.readDeviceStore(deviceId) ?? {}, false),
7101
7507
  write: async (patch) => {
7102
7508
  await this._ctx?.settings?.writeDeviceStore(deviceId, patch);
7103
7509
  },
@@ -7159,6 +7565,23 @@ var BaseAddon = class {
7159
7565
  }
7160
7566
  return value;
7161
7567
  }
7568
+ /**
7569
+ * The marker-bearing settings reads (D798) — private on purpose. Without a
7570
+ * keychain the context's own view is already raw.
7571
+ */
7572
+ rawSettings() {
7573
+ return this._secretSettings?.raw ?? this._ctx?.settings;
7574
+ }
7575
+ /** An addon-facing read met markers it could not resolve: say so once per ref. */
7576
+ logUnresolvedRead(unresolved) {
7577
+ const fresh = unresolved.filter((u) => !this._loggedUnresolvedReads.has(u.ref));
7578
+ if (fresh.length === 0) return;
7579
+ for (const u of fresh) this._loggedUnresolvedReads.add(u.ref);
7580
+ 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) => ({
7581
+ ref: u.ref,
7582
+ reason: u.reason
7583
+ })) } });
7584
+ }
7162
7585
  /** Re-resolve the config (a keychain-only change, or a retry) and apply it. */
7163
7586
  scheduleSecretReresolve(delayMs) {
7164
7587
  const timerOf = delayMs === SECRET_CHANGE_DEBOUNCE_MS ? "_secretChangeTimer" : "_secretRetryTimer";
@@ -7185,7 +7608,7 @@ var BaseAddon = class {
7185
7608
  * `{}` (defaults) — the addon's first successful patch will rehydrate.
7186
7609
  */
7187
7610
  async readAddonStoreWithRetry() {
7188
- const settings = this._ctx?.settings;
7611
+ const settings = this.rawSettings();
7189
7612
  if (!settings) return {};
7190
7613
  const delaysMs = [
7191
7614
  150,
@@ -9488,6 +9911,278 @@ var CameraSwitchGroupSchema = object({
9488
9911
  fetchedAt: number()
9489
9912
  });
9490
9913
  /**
9914
+ * The trainer contract — what the hub hands the cloud trainer and what it
9915
+ * gets back (cloud training, D805+).
9916
+ *
9917
+ * The trainer (`hf/camstack-trainer`, published as the Hugging Face repo
9918
+ * `camstack/camstack-trainer`) is a separate AGPL program the hub never
9919
+ * imports: `job.json` goes in, files come out, and progress is `CAMSTACK_EVENT`
9920
+ * lines on stdout. These schemas are the hub's half of that boundary; the
9921
+ * trainer's pydantic models (and the JSON Schemas generated from them under
9922
+ * `hf/camstack-trainer/schemas/`) are the other half. A change here is a
9923
+ * change there, in the same piece of work.
9924
+ *
9925
+ * No `.default()` anywhere: defaults do not run on the addon cap path, so the
9926
+ * orchestrator fills every field of a job spec explicitly.
9927
+ */
9928
+ var TRAINING_JOB_SCHEMA = "camstack.training/v1";
9929
+ var TRAINING_RESULT_SCHEMA = "camstack.training-result/v1";
9930
+ /** What the trainer can export. Edge TPU is a later, separate image. */
9931
+ var TrainingExportSchema = _enum([
9932
+ "onnx",
9933
+ "openvino-fp16",
9934
+ "openvino-int8",
9935
+ "coreml-fp16"
9936
+ ]);
9937
+ var FloorsSchema = record(string(), number().min(0).max(1));
9938
+ object({
9939
+ schema: literal(TRAINING_JOB_SCHEMA),
9940
+ jobKey: string().uuid(),
9941
+ target: object({
9942
+ kind: literal("detector"),
9943
+ step: literal("object-detection")
9944
+ }),
9945
+ base: object({
9946
+ modelId: string().min(1),
9947
+ /** Ultralytics weights id, e.g. `yolov9m.pt`. */
9948
+ weights: string().min(1),
9949
+ imgsz: number().int().positive()
9950
+ }),
9951
+ baseline: object({
9952
+ modelId: string().min(1),
9953
+ /** The baseline ONNX the holdout comparison runs; public mirror URL. */
9954
+ onnxUrl: string().url(),
9955
+ imgsz: number().int().positive(),
9956
+ floors: FloorsSchema
9957
+ }),
9958
+ dataset: object({
9959
+ versionId: string().min(1),
9960
+ annotationHash: string(),
9961
+ /** sha256 of the uploaded archive; the trainer refuses a mismatch (exit 65). */
9962
+ sha256: string().regex(/^[0-9a-f]{64}$/)
9963
+ }),
9964
+ split: object({
9965
+ holdoutCameras: array(number().int()),
9966
+ /** When no camera is held out: the last N days of every camera. */
9967
+ holdoutLastDays: number().int().nonnegative(),
9968
+ valFraction: number().min(0).max(.5),
9969
+ seed: number().int()
9970
+ }),
9971
+ hyper: object({
9972
+ epochs: number().int().positive(),
9973
+ batch: number().int().positive(),
9974
+ lr0: number().positive(),
9975
+ /** Layers frozen from the start of the backbone; 0 = none. */
9976
+ freeze: number().int().nonnegative(),
9977
+ patience: number().int().nonnegative(),
9978
+ seed: number().int()
9979
+ }),
9980
+ replay: object({
9981
+ source: literal("coco2017"),
9982
+ count: number().int().nonnegative()
9983
+ }),
9984
+ exports: array(TrainingExportSchema).min(1),
9985
+ calibration: object({ maxFrames: number().int().positive() }),
9986
+ floors: object({
9987
+ minSupport: number().int().positive(),
9988
+ clamp: number().min(0).max(1)
9989
+ }),
9990
+ int8Gate: object({ maxMap50Drop: number().min(0).max(1) }),
9991
+ catalog: object({
9992
+ id: string().regex(/^[a-z0-9][a-z0-9-]{2,80}$/),
9993
+ name: string().min(1).max(160)
9994
+ })
9995
+ });
9996
+ /** One regular file of the bundle. An mlpackage contributes one row per member. */
9997
+ var TrainingResultFileSchema = object({
9998
+ path: string().min(1),
9999
+ bytes: number().int().nonnegative(),
10000
+ sha256: string().regex(/^[0-9a-f]{64}$/),
10001
+ format: _enum([
10002
+ "onnx",
10003
+ "openvino",
10004
+ "coreml",
10005
+ "pt"
10006
+ ]),
10007
+ variant: _enum(["base", "int8"])
10008
+ });
10009
+ var DraftFormatSchema = object({
10010
+ /** RELATIVE path inside the bundle; the hub rewrites it to `camstack-local://`. */
10011
+ url: string().min(1),
10012
+ sizeMB: number().nonnegative(),
10013
+ isDirectory: boolean().optional(),
10014
+ files: array(string()).optional(),
10015
+ runtimes: array(literal("python")).optional(),
10016
+ revision: string().min(1)
10017
+ });
10018
+ /** The trainer's half of a catalog entry; the hub completes it (labels, licence, group). */
10019
+ var TrainingCatalogDraftSchema = object({
10020
+ id: string().min(1),
10021
+ name: string().min(1),
10022
+ description: string(),
10023
+ labels: array(unknown()),
10024
+ inputSize: object({
10025
+ width: number().int().positive(),
10026
+ height: number().int().positive()
10027
+ }),
10028
+ preprocessMode: literal("letterbox"),
10029
+ defaultClassFloors: FloorsSchema,
10030
+ formats: object({
10031
+ onnx: DraftFormatSchema.optional(),
10032
+ openvino: DraftFormatSchema.optional(),
10033
+ coreml: DraftFormatSchema.optional()
10034
+ })
10035
+ });
10036
+ /** One class of one model's holdout report (the eval harness's summary). */
10037
+ var TrainingEvalClassSchema = object({
10038
+ positives: number().int(),
10039
+ floor: number().nullable(),
10040
+ tp: number().int(),
10041
+ fp: number().int(),
10042
+ fn: number().int(),
10043
+ precision: number().nullable(),
10044
+ recall: number().nullable(),
10045
+ ap50: number().nullable(),
10046
+ recallByCamera: record(string(), number().nullable()).optional(),
10047
+ recallByLight: record(string(), number().nullable()).optional(),
10048
+ fpByCamera: record(string(), number()).optional(),
10049
+ smallFound: number().int().optional(),
10050
+ smallTotal: number().int().optional()
10051
+ }).passthrough();
10052
+ var TrainingEvalReportSchema = object({
10053
+ frames: number().int(),
10054
+ classes: record(string(), TrainingEvalClassSchema)
10055
+ }).passthrough();
10056
+ /**
10057
+ * A succeeded result carries every block; a failed one carries the error and
10058
+ * whatever was known by then — the other blocks are ABSENT, not null. The
10059
+ * orchestrator checks the blocks it needs before it trusts a success.
10060
+ */
10061
+ var TrainingResultSchema = object({
10062
+ schema: literal(TRAINING_RESULT_SCHEMA),
10063
+ jobKey: string(),
10064
+ status: _enum(["succeeded", "failed"]),
10065
+ error: object({
10066
+ stage: string(),
10067
+ code: string(),
10068
+ message: string()
10069
+ }).nullable(),
10070
+ trainer: object({
10071
+ version: string(),
10072
+ revision: string()
10073
+ }),
10074
+ toolchain: record(string(), string().nullable()),
10075
+ dataset: object({
10076
+ versionId: string(),
10077
+ annotationHash: string(),
10078
+ sha256: string(),
10079
+ frames: object({
10080
+ train: number().int(),
10081
+ val: number().int(),
10082
+ holdout: number().int()
10083
+ }),
10084
+ holdoutCameras: array(number().int()),
10085
+ replayImages: number().int()
10086
+ }).optional(),
10087
+ training: object({
10088
+ epochsRun: number().int(),
10089
+ bestEpoch: number().int(),
10090
+ bestMap50: number(),
10091
+ bestMap50_95: number(),
10092
+ seconds: number()
10093
+ }).optional(),
10094
+ evaluation: object({
10095
+ holdoutFrames: number().int(),
10096
+ baseline: TrainingEvalReportSchema.nullable(),
10097
+ candidate: TrainingEvalReportSchema.nullable(),
10098
+ candidateInt8: TrainingEvalReportSchema.nullable(),
10099
+ recallDeltaByCamera: record(string(), record(string(), number())).nullable(),
10100
+ map50: record(string(), number().nullable())
10101
+ }).optional(),
10102
+ floors: object({
10103
+ baseline: FloorsSchema,
10104
+ candidate: FloorsSchema,
10105
+ candidateInt8: FloorsSchema.nullable(),
10106
+ notes: array(string())
10107
+ }).optional(),
10108
+ int8: object({
10109
+ kept: boolean(),
10110
+ map50Fp16: number().nullable(),
10111
+ map50Int8: number().nullable(),
10112
+ reason: string().nullable()
10113
+ }).optional(),
10114
+ exportsDropped: array(object({
10115
+ export: string(),
10116
+ reason: string()
10117
+ })).optional(),
10118
+ files: array(TrainingResultFileSchema).optional(),
10119
+ bundle: object({
10120
+ path: literal("bundle.tar"),
10121
+ bytes: number().int().nonnegative(),
10122
+ sha256: string().regex(/^[0-9a-f]{64}$/)
10123
+ }).nullable().optional(),
10124
+ catalogDraft: object({
10125
+ base: TrainingCatalogDraftSchema,
10126
+ int8: TrainingCatalogDraftSchema.nullable()
10127
+ }).nullable().optional(),
10128
+ licence: string()
10129
+ });
10130
+ var TrainingStageSchema = _enum([
10131
+ "prepare",
10132
+ "replay",
10133
+ "train",
10134
+ "eval",
10135
+ "export",
10136
+ "package"
10137
+ ]);
10138
+ var EventBase = {
10139
+ v: literal(1),
10140
+ ts: number()
10141
+ };
10142
+ discriminatedUnion("type", [
10143
+ object({
10144
+ ...EventBase,
10145
+ type: literal("stage"),
10146
+ stage: TrainingStageSchema
10147
+ }),
10148
+ object({
10149
+ ...EventBase,
10150
+ type: literal("epoch"),
10151
+ epoch: number().int(),
10152
+ epochs: number().int(),
10153
+ boxLoss: number().nullable().optional(),
10154
+ map50: number().nullable().optional(),
10155
+ map50_95: number().nullable().optional(),
10156
+ etaSec: number().nullable().optional()
10157
+ }),
10158
+ object({
10159
+ ...EventBase,
10160
+ type: literal("metric"),
10161
+ name: string(),
10162
+ value: number()
10163
+ }),
10164
+ object({
10165
+ ...EventBase,
10166
+ type: literal("artifact"),
10167
+ path: string(),
10168
+ bytes: number(),
10169
+ sha256: string()
10170
+ }),
10171
+ object({
10172
+ ...EventBase,
10173
+ type: literal("done"),
10174
+ status: _enum(["succeeded", "failed"]),
10175
+ resultSha256: string().nullable().optional()
10176
+ }),
10177
+ object({
10178
+ ...EventBase,
10179
+ type: literal("error"),
10180
+ stage: string(),
10181
+ code: string(),
10182
+ message: string()
10183
+ })
10184
+ ]);
10185
+ /**
9491
10186
  * What the gate decided about a birth, from the CALLER's point of view.
9492
10187
  *
9493
10188
  * Deliberately not `ConfirmationVerdict`: `undecided` is not a birth decision
@@ -11815,7 +12510,9 @@ var AddonHttpRouteSchema = object({
11815
12510
  "authenticated",
11816
12511
  "admin"
11817
12512
  ]).optional(),
11818
- description: string().optional()
12513
+ description: string().optional(),
12514
+ /** The hub limits this route per client address before the handler runs. */
12515
+ rateLimit: _enum(["auth"]).optional()
11819
12516
  });
11820
12517
  /**
11821
12518
  * Cross-process route invocation envelope. The hub captures the
@@ -12520,6 +13217,37 @@ var BackupDestinationInfoSchema = object({
12520
13217
  lastError: string().optional()
12521
13218
  });
12522
13219
  /**
13220
+ * How an archive is encrypted (operator decision 2026-10-09): to a backup
13221
+ * PUBLIC key the hub holds, so only the operator's secret key opens it.
13222
+ * Absent on a plain `.tar.gz` — every archive made before encryption, or
13223
+ * with it off — which restores without a key.
13224
+ */
13225
+ var BackupArchiveEncryptionSchema = object({
13226
+ /** `x25519-hkdf-aes256gcm-stream-v1`. */
13227
+ scheme: string(),
13228
+ /** 16 hex — the backup key whose secret restores this archive. */
13229
+ keyId: string()
13230
+ });
13231
+ /**
13232
+ * The backup encryption setting. The hub keeps PUBLIC keys only: the active
13233
+ * one new archives are encrypted to, and the retired ones older archives
13234
+ * still need. The secret key is shown once, at `setupEncryption`.
13235
+ */
13236
+ var BackupEncryptionStatusSchema = object({
13237
+ enabled: boolean(),
13238
+ active: object({
13239
+ keyId: string(),
13240
+ publicKey: string(),
13241
+ createdAt: number()
13242
+ }).nullable(),
13243
+ /** Every key ever set up, newest first. */
13244
+ keys: array(object({
13245
+ keyId: string(),
13246
+ createdAt: number(),
13247
+ retiredAt: number().nullable()
13248
+ })).readonly()
13249
+ });
13250
+ /**
12523
13251
  * Per-archive entry returned by `backup.listArchives({ destinationId })`.
12524
13252
  * Same shape the destination drill-in renders. Sourced from the per-
12525
13253
  * location `manifests.json` (no per-archive tarball read required).
@@ -12531,7 +13259,9 @@ var BackupArchiveEntrySchema = object({
12531
13259
  sizeBytes: number(),
12532
13260
  label: string().optional(),
12533
13261
  /** Top-level locations included in the archive (db, addons, tls, …). */
12534
- locations: array(string()).readonly()
13262
+ locations: array(string()).readonly(),
13263
+ /** Present when the archive is encrypted; restore then needs that key. */
13264
+ encryption: BackupArchiveEncryptionSchema.optional()
12535
13265
  });
12536
13266
  var BackupEntrySchema = object({
12537
13267
  id: string(),
@@ -12540,7 +13270,8 @@ var BackupEntrySchema = object({
12540
13270
  label: string().optional(),
12541
13271
  createdAt: number(),
12542
13272
  sizeBytes: number(),
12543
- locations: array(string()).optional()
13273
+ locations: array(string()).optional(),
13274
+ encryption: BackupArchiveEncryptionSchema.optional()
12544
13275
  });
12545
13276
  var ArchiveEntrySchema = object({
12546
13277
  path: string(),
@@ -12729,10 +13460,40 @@ method(_void(), array(BackupDestinationInfoSchema).readonly(), { auth: "admin" }
12729
13460
  * this list and skips entries whose path doesn't start with
12730
13461
  * any of them.
12731
13462
  */
12732
- locations: array(string()).optional()
13463
+ locations: array(string()).optional(),
13464
+ /**
13465
+ * The backup SECRET key, for an encrypted archive (ignored for a plain
13466
+ * one). The archive is decrypted into the hub's private staging
13467
+ * before the restart; the key is not stored. A wrong or missing key
13468
+ * is refused before the archive is downloaded.
13469
+ */
13470
+ backupSecretKey: string().optional()
12733
13471
  }), _void(), {
12734
13472
  kind: "mutation",
12735
13473
  auth: "admin"
13474
+ }), method(_void(), BackupEncryptionStatusSchema, { auth: "admin" }), method(object({}), object({
13475
+ keyId: string(),
13476
+ secretKey: string(),
13477
+ publicKey: string(),
13478
+ createdAt: number(),
13479
+ replacedKeyId: string().nullable()
13480
+ }), {
13481
+ kind: "mutation",
13482
+ auth: "admin"
13483
+ }), method(object({}), object({ disabledKeyId: string().nullable() }), {
13484
+ kind: "mutation",
13485
+ auth: "admin"
13486
+ }), method(object({ backupSecretKey: string() }), object({
13487
+ valid: boolean(),
13488
+ keyId: string().nullable(),
13489
+ /** The hub knows this key (active or retired). */
13490
+ known: boolean(),
13491
+ /** It is the key new archives are encrypted to. */
13492
+ active: boolean(),
13493
+ error: string().optional()
13494
+ }), {
13495
+ kind: "mutation",
13496
+ auth: "admin"
12736
13497
  }), method(object({
12737
13498
  destinationId: string(),
12738
13499
  backupId: string()
@@ -14458,7 +15219,60 @@ var CustomModelDescriptorSchema = object({
14458
15219
  stepId: string(),
14459
15220
  entry: ModelCatalogEntrySchema
14460
15221
  });
14461
- method(_void(), array(CustomModelDescriptorSchema).readonly(), { auth: "admin" });
15222
+ /** One regular file of an imported bundle, as the producer measured it. */
15223
+ var ModelBundleFileSchema = object({
15224
+ /** Relative path inside the bundle tar; an mlpackage member is `<x>.mlpackage/<member>`. */
15225
+ path: string().min(1),
15226
+ bytes: number().int().nonnegative(),
15227
+ sha256: string().regex(/^[0-9a-f]{64}$/)
15228
+ });
15229
+ var ImportModelBundleInputSchema = object({
15230
+ /** The registry provider that keeps the model (Model Studio). */
15231
+ addonId: string(),
15232
+ stepId: string().min(1),
15233
+ /**
15234
+ * The catalog rows to register, complete, every format URL already
15235
+ * `camstack-local://<modelId>/<file>` naming a file of the bundle. One
15236
+ * bundle may carry several rows (a base and its INT8 variant).
15237
+ */
15238
+ entries: array(ModelCatalogEntrySchema).min(1).max(4),
15239
+ /** The bundle tar, offered by the producer over `ctx.peerBytes` (same host). */
15240
+ bundle: object({
15241
+ ticket: PeerBytesTicketSchema,
15242
+ bytes: number().int().positive(),
15243
+ sha256: string().regex(/^[0-9a-f]{64}$/)
15244
+ }),
15245
+ /** Every file the tar must hold; anything missing, extra or different is refused. */
15246
+ files: array(ModelBundleFileSchema).min(1).max(64),
15247
+ /** Convert missing engine formats and push the model to every agent afterwards. */
15248
+ distribute: boolean()
15249
+ });
15250
+ var ImportModelBundleResultSchema = discriminatedUnion("kind", [object({
15251
+ kind: literal("imported"),
15252
+ modelIds: array(string()).readonly(),
15253
+ distributed: array(object({
15254
+ modelId: string(),
15255
+ nodeId: string(),
15256
+ format: _enum(MODEL_FORMATS),
15257
+ ok: boolean(),
15258
+ error: string().optional()
15259
+ })).readonly()
15260
+ }), object({
15261
+ kind: literal("refused"),
15262
+ reason: _enum([
15263
+ "transfer-failed",
15264
+ "checksum-mismatch",
15265
+ "bundle-mismatch",
15266
+ "invalid-entry",
15267
+ "id-taken"
15268
+ ]),
15269
+ detail: string()
15270
+ })]);
15271
+ method(_void(), array(CustomModelDescriptorSchema).readonly(), { auth: "admin" }), method(ImportModelBundleInputSchema, ImportModelBundleResultSchema, {
15272
+ kind: "mutation",
15273
+ auth: "admin",
15274
+ timeoutMs: 30 * 6e4
15275
+ });
14462
15276
  /**
14463
15277
  * Query filter for settings-store collections.
14464
15278
  */
@@ -14937,6 +15751,35 @@ var KeychainKeySourceSchema = object({
14937
15751
  */
14938
15752
  sharesBackupWithDatabase: boolean()
14939
15753
  });
15754
+ /**
15755
+ * One keychain reset, as the Secrets page reports it until the operator
15756
+ * acknowledges it. Never a value: refs, counts and table names only.
15757
+ */
15758
+ var KeychainResetRecordSchema = object({
15759
+ id: string(),
15760
+ at: number(),
15761
+ /** `user:<id>` or {@link KEYCHAIN_RESET_TRIGGER_ACTOR}. */
15762
+ actor: string(),
15763
+ /** Why the keychain was locked when it was reset; `null` when it was not locked. */
15764
+ lockedReason: string().nullable(),
15765
+ /** Values moved into the archive table (ciphertext under the lost key). */
15766
+ archived: number().int(),
15767
+ /** `keychain:secrets-orphaned-<ts>`, or `null` when nothing was stored. */
15768
+ archivedCollection: string().nullable(),
15769
+ /**
15770
+ * `keychain:keys-orphaned-<ts>`: the wrapped data keys of the archive, kept
15771
+ * so the archive can still be opened if the lost master key turns up.
15772
+ */
15773
+ archivedKeysCollection: string().nullable(),
15774
+ /**
15775
+ * `system-settings` keys whose marker the reset cleared — the cluster
15776
+ * secret's: a marker left pointing at an archived value would refuse every
15777
+ * agent forever (D797).
15778
+ */
15779
+ clearedSettingsKeys: array(string()).readonly(),
15780
+ /** When an operator dismissed the notice on the Secrets page; `null` until then. */
15781
+ acknowledgedAt: number().nullable()
15782
+ });
14940
15783
  var KeychainStatusSchema = object({
14941
15784
  keychain: KeychainStateSchema,
14942
15785
  /** The source of the master key in use; `null` while locked. */
@@ -14954,7 +15797,9 @@ var KeychainStatusSchema = object({
14954
15797
  /** Wrapped copies of the data key under a previous master key, kept until purged. */
14955
15798
  retiredWraps: number().int(),
14956
15799
  recoveryKeyDownloadedAt: number().nullable(),
14957
- secretCount: number().int()
15800
+ secretCount: number().int(),
15801
+ /** The most recent reset, acknowledged or not; `null` when the keychain was never reset. */
15802
+ lastReset: KeychainResetRecordSchema.nullable()
14958
15803
  });
14959
15804
  /**
14960
15805
  * Whether a stored value is still pointed at by its owner's settings.
@@ -14976,17 +15821,26 @@ var KeychainAuditActionSchema = _enum([
14976
15821
  "download-recovery-key",
14977
15822
  "delete-orphans",
14978
15823
  "reset",
15824
+ "acknowledge-reset",
14979
15825
  "initialize"
14980
15826
  ]);
14981
15827
  var KeychainAuditEntrySchema = object({
14982
15828
  id: string(),
14983
15829
  at: number(),
14984
15830
  action: KeychainAuditActionSchema,
14985
- /** `addon:<id>` | `user:<id>` | `system`. */
15831
+ /** `addon:<id>` | `user:<id>` | `system` | `trigger-file`. */
14986
15832
  actor: string(),
14987
15833
  ref: string().nullable(),
14988
15834
  detail: string().nullable()
14989
15835
  });
15836
+ var KEYCHAIN_RESET_CONFIRMATION = "RESET KEYCHAIN";
15837
+ /**
15838
+ * Secrets the HUB itself holds (owner `system`) that no settings form shows:
15839
+ * `jwt-signing-key` — the session signing key (D797). It is always "in use",
15840
+ * never an orphan; it is generated on a fresh hub and replaced only through
15841
+ * {@link keychainAdminCapability.methods.setSystemSecret}.
15842
+ */
15843
+ var SystemHeldSecretNameSchema = _enum(["jwt-signing-key"]);
14990
15844
  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({
14991
15845
  value: string(),
14992
15846
  version: number().int()
@@ -14994,6 +15848,16 @@ method(object({}), KeychainStatusSchema, { auth: "admin" }), method(object({}),
14994
15848
  kind: "mutation",
14995
15849
  auth: "admin",
14996
15850
  caller: "required"
15851
+ }), method(object({
15852
+ name: SystemHeldSecretNameSchema,
15853
+ value: string().min(16)
15854
+ }), object({
15855
+ ref: string(),
15856
+ version: number().int()
15857
+ }), {
15858
+ kind: "mutation",
15859
+ auth: "admin",
15860
+ caller: "required"
14997
15861
  }), method(object({ refs: array(string().min(1)).max(1e3) }), object({
14998
15862
  deleted: array(string()).readonly(),
14999
15863
  kept: array(object({
@@ -15023,13 +15887,20 @@ method(object({}), KeychainStatusSchema, { auth: "admin" }), method(object({}),
15023
15887
  kind: "mutation",
15024
15888
  auth: "admin",
15025
15889
  caller: "required"
15026
- }), method(object({ confirm: literal("RESET KEYCHAIN") }), object({
15890
+ }), method(object({ confirm: literal(KEYCHAIN_RESET_CONFIRMATION) }), object({
15027
15891
  archivedCollection: string().nullable(),
15028
15892
  archived: number().int()
15029
15893
  }), {
15030
15894
  kind: "mutation",
15031
15895
  auth: "admin",
15032
15896
  caller: "required"
15897
+ }), method(object({}), object({
15898
+ reset: KeychainResetRecordSchema.nullable(),
15899
+ pendingReentry: array(KeychainSecretMetaSchema).readonly()
15900
+ }), { auth: "admin" }), method(object({}), object({ acknowledged: boolean() }), {
15901
+ kind: "mutation",
15902
+ auth: "admin",
15903
+ caller: "required"
15033
15904
  });
15034
15905
  method(_void(), object({
15035
15906
  id: string(),
@@ -17880,7 +18751,7 @@ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
17880
18751
  * `login-method` — collection cap through which auth addons contribute
17881
18752
  * their pre-auth login surfaces to the login page. This is the SINGLE,
17882
18753
  * generic mechanism that supersedes the dead `auth.listProviders` reader:
17883
- * every auth addon (OIDC, magic-link, WebAuthn/passkey) registers a
18754
+ * every auth addon (OIDC, WebAuthn/passkey) registers a
17884
18755
  * `login-method` provider and the PUBLIC `auth.listLoginMethods`
17885
18756
  * procedure aggregates them for the unauthenticated login page.
17886
18757
  *
@@ -17888,8 +18759,7 @@ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
17888
18759
  *
17889
18760
  * - `redirect` — a declarative button. The login page renders a generic
17890
18761
  * button that navigates to `startUrl` (an addon-owned HTTP route).
17891
- * Covers OIDC (`/addon/auth-oidc/<id>/start`) and magic-link with
17892
- * ZERO shell-side JS. A future SSO addon plugs in the same way — the
18762
+ * Covers OIDC (`/addon/auth-oidc/<id>/start`) with ZERO shell-side JS. A future SSO addon plugs in the same way — the
17893
18763
  * login page needs NO change.
17894
18764
  *
17895
18765
  * - `widget` — a Module-Federation widget the login page mounts (via
@@ -17908,8 +18778,8 @@ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
17908
18778
  * decision.
17909
18779
  *
17910
18780
  * Every contribution carries a `stage`:
17911
- * - `primary` — shown on the first credentials screen (OIDC /
17912
- * magic-link buttons; a future usernameless passkey).
18781
+ * - `primary` — shown on the first credentials screen (OIDC
18782
+ * buttons; a usernameless passkey).
17913
18783
  * - `second-factor` — shown AFTER the password leg, gated on the
17914
18784
  * returned `factors` (passkey-as-2FA today).
17915
18785
  *
@@ -17936,7 +18806,7 @@ var LoginMethodContributionSchema = discriminatedUnion("kind", [
17936
18806
  * The provider names an external identity a signed-in user can link to
17937
18807
  * their own account (D782): `auth.listLinkableProviders` /
17938
18808
  * `beginExternalLink` offer exactly the redirect methods that set this,
17939
- * whatever their id. Absent / false — a login button only (magic-link).
18809
+ * whatever their id. Absent / false — a login button only.
17940
18810
  */
17941
18811
  linkable: boolean().optional()
17942
18812
  }),
@@ -21791,8 +22661,7 @@ method(object({}), object({ rules: array(NcRuleSchema) }), { auth: "admin" }), m
21791
22661
  * `super_admin` — collapsed onto the single boolean because every
21792
22662
  * non-admin caller is governed by the same scope-check rules; the
21793
22663
  * distinction was only ever used to route role-specific procedures
21794
- * which we no longer have. Agents are admin sessions issued via
21795
- * `createServiceToken`; CLI / webhook integrations are `cst_*` tokens
22664
+ * which we no longer have. CLI / webhook integrations are `cst_*` tokens
21796
22665
  * with `isAdmin: false` + an explicit scope list.
21797
22666
  */
21798
22667
  /** Per-method access flavour. Materialised on every cap method via codegen. */
@@ -23467,6 +24336,9 @@ var RetrainExportFilterSchema = object({
23467
24336
  frameIds: array(string()).max(2e4).optional(),
23468
24337
  /** Only frames in at least one of these named collections. */
23469
24338
  collectionIds: array(string()).max(200).optional(),
24339
+ /** Exactly the frames of this dataset version (and its completeOnly). An
24340
+ * unknown id selects nothing. */
24341
+ datasetVersionId: string().optional(),
23470
24342
  batchId: string().optional(),
23471
24343
  /** Only frames the operator marked complete (all subjects boxed). */
23472
24344
  completeOnly: boolean().optional()
@@ -23634,6 +24506,67 @@ var RetrainLlmAssistResultSchema = discriminatedUnion("kind", [object({
23634
24506
  ]),
23635
24507
  detail: string().optional()
23636
24508
  })]);
24509
+ /** What a dataset version is cut from. Every field narrows. */
24510
+ var RetrainDatasetSelectionSchema = object({
24511
+ deviceIds: array(number()).readonly().optional(),
24512
+ collectionIds: array(string()).max(200).readonly().optional(),
24513
+ frameIds: array(string()).max(2e4).readonly().optional()
24514
+ });
24515
+ /** The counts a dataset is judged by. */
24516
+ var RetrainDatasetStatsSchema = object({
24517
+ frames: number().int(),
24518
+ completeFrames: number().int(),
24519
+ /** `completeFrames / frames`, 0..1. */
24520
+ completeness: number(),
24521
+ /** Boxes to learn (model errors excluded). */
24522
+ subjects: number().int(),
24523
+ modelErrors: number().int(),
24524
+ /** Complete frames with no subject. */
24525
+ hardNegatives: number().int(),
24526
+ /** Subjects per class × camera × day/night. */
24527
+ cells: array(object({
24528
+ macroClass: string(),
24529
+ deviceId: number(),
24530
+ lighting: _enum([
24531
+ "day",
24532
+ "night",
24533
+ "unknown"
24534
+ ]),
24535
+ subjects: number().int(),
24536
+ frames: number().int()
24537
+ })).readonly(),
24538
+ cameras: array(object({
24539
+ deviceId: number(),
24540
+ frames: number().int(),
24541
+ completeFrames: number().int()
24542
+ })).readonly()
24543
+ });
24544
+ /** An immutable dataset version, without its frame list. */
24545
+ var RetrainDatasetVersionSchema = object({
24546
+ id: string(),
24547
+ name: string(),
24548
+ createdAt: number(),
24549
+ selection: RetrainDatasetSelectionSchema,
24550
+ layout: RetrainExportLayoutSchema,
24551
+ completeOnly: boolean(),
24552
+ frameCount: number().int(),
24553
+ /** sha256 of what the frames taught when the version was frozen. */
24554
+ annotationHash: string(),
24555
+ /** The export manifest schema the version was cut under. */
24556
+ manifestSchema: string(),
24557
+ stats: RetrainDatasetStatsSchema
24558
+ });
24559
+ var CreateRetrainDatasetVersionResultSchema = discriminatedUnion("kind", [object({
24560
+ kind: literal("created"),
24561
+ version: RetrainDatasetVersionSchema
24562
+ }), object({
24563
+ kind: literal("refused"),
24564
+ reason: _enum([
24565
+ "empty-name",
24566
+ "duplicate-name",
24567
+ "no-frames"
24568
+ ])
24569
+ })]);
23637
24570
  /** The outcome of a lifecycle move owned by the retrain page. */
23638
24571
  var RetrainTransitionResultSchema = object({
23639
24572
  trackId: string(),
@@ -24423,6 +25356,47 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
24423
25356
  kind: "mutation",
24424
25357
  auth: "admin",
24425
25358
  timeoutMs: 60 * 6e4
25359
+ }), method(object({
25360
+ filter: RetrainExportFilterSchema,
25361
+ layout: RetrainExportLayoutSchema
25362
+ }), object({
25363
+ ticket: PeerBytesTicketSchema,
25364
+ frames: number().int(),
25365
+ annotations: number().int()
25366
+ }), {
25367
+ kind: "mutation",
25368
+ auth: "admin",
25369
+ timeoutMs: 12e4
25370
+ }), method(object({
25371
+ selection: RetrainDatasetSelectionSchema,
25372
+ completeOnly: boolean().optional()
25373
+ }), RetrainDatasetStatsSchema, {
25374
+ kind: "query",
25375
+ auth: "admin"
25376
+ }), method(object({
25377
+ name: string().max(120),
25378
+ selection: RetrainDatasetSelectionSchema,
25379
+ layout: RetrainExportLayoutSchema,
25380
+ completeOnly: boolean()
25381
+ }), CreateRetrainDatasetVersionResultSchema, {
25382
+ kind: "mutation",
25383
+ auth: "admin",
25384
+ timeoutMs: 12e4
25385
+ }), method(object({}), array(RetrainDatasetVersionSchema).readonly(), {
25386
+ kind: "query",
25387
+ auth: "admin"
25388
+ }), method(object({ id: string() }), object({ deleted: boolean() }), {
25389
+ kind: "mutation",
25390
+ auth: "admin"
25391
+ }), method(object({ id: string() }), object({
25392
+ found: boolean(),
25393
+ annotationHash: string(),
25394
+ matches: boolean(),
25395
+ missingFrames: number().int()
25396
+ }), {
25397
+ kind: "query",
25398
+ auth: "admin",
25399
+ timeoutMs: 12e4
24426
25400
  }), method(object({}), array(RetrainAssistProfileSchema).readonly(), {
24427
25401
  kind: "query",
24428
25402
  auth: "admin"
@@ -28001,8 +28975,8 @@ version: string().optional() }), ServerUpdateActionResultSchema, {
28001
28975
  * `smtp-provider` — pluggable email delivery surface.
28002
28976
  *
28003
28977
  * Collection cap: a deployment may install multiple SMTP relays (e.g.
28004
- * one for transactional / one for notifications). Consumers (magic-link,
28005
- * notifier addons, …) walk the collection and pick the first
28978
+ * one for transactional / one for notifications). Consumers (notifier
28979
+ * addons, …) walk the collection and pick the first
28006
28980
  * ready provider OR target a specific addonId.
28007
28981
  *
28008
28982
  * The shape stays small on purpose — `sendEmail` is enough for the
@@ -28181,7 +29155,7 @@ targets: array(object({
28181
29155
  })));
28182
29156
  /**
28183
29157
  * `sso-bridge` — internal hub-only cap that lets SSO-style auth
28184
- * providers (OIDC, SAML, magic-link, …) mint an HMAC-signed token
29158
+ * providers (OIDC, SAML, …) mint an HMAC-signed token
28185
29159
  * carrying the post-callback claims before redirecting back to
28186
29160
  * `/api/auth/sso/finish`.
28187
29161
  *
@@ -28244,7 +29218,14 @@ var SsoBridgeClaimsSchema = object({
28244
29218
  * Verified `iss` of the id_token behind an OIDC login bridge (D782). A
28245
29219
  * subject is unique only per issuer, so a link is bound to it.
28246
29220
  */
28247
- issuer: string().optional()
29221
+ issuer: string().optional(),
29222
+ /**
29223
+ * SHA-256 (hex) of the `camstack_sso_state` cookie the IdP `/start` set in
29224
+ * the browser that began this sign-in. `/api/auth/sso/finish` requires the
29225
+ * request to present the matching cookie — a login bridge is useless in
29226
+ * any other browser.
29227
+ */
29228
+ browserBinding: string().optional()
28248
29229
  });
28249
29230
  method(object({
28250
29231
  claims: SsoBridgeClaimsSchema,
@@ -40511,16 +41492,6 @@ var ApiKeySummarySchema = object({
40511
41492
  createdAt: number(),
40512
41493
  lastUsedAt: number().optional()
40513
41494
  });
40514
- var CreateApiKeyInputSchema = object({
40515
- label: string(),
40516
- isAdmin: boolean().default(false),
40517
- allowedProviders: union([array(string()), literal("*")]).optional(),
40518
- allowedDevices: record(string(), union([array(string()), literal("*")])).optional()
40519
- });
40520
- var CreateApiKeyResultSchema = object({
40521
- token: string(),
40522
- record: ApiKeySummarySchema
40523
- });
40524
41495
  var ScopedTokenSummarySchema = object({
40525
41496
  id: string(),
40526
41497
  userId: string(),
@@ -40619,17 +41590,10 @@ method(_void(), array(UserSummarySchema), { auth: "admin" }), method(CreateUserI
40619
41590
  }), UserSummarySchema.extend({ passwordHash: string() }).nullable(), {
40620
41591
  kind: "mutation",
40621
41592
  access: "view"
40622
- }), method(_void(), array(ApiKeySummarySchema), { auth: "admin" }), method(CreateApiKeyInputSchema, CreateApiKeyResultSchema, {
40623
- kind: "mutation",
40624
- auth: "admin",
40625
- access: "create"
40626
- }), method(object({ id: string() }), object({ success: literal(true) }), {
41593
+ }), method(_void(), array(ApiKeySummarySchema), { auth: "admin" }), method(object({ id: string() }), object({ success: literal(true) }), {
40627
41594
  kind: "mutation",
40628
41595
  auth: "admin",
40629
41596
  access: "delete"
40630
- }), method(object({ token: string() }), ApiKeySummarySchema.nullable(), {
40631
- kind: "mutation",
40632
- access: "view"
40633
41597
  }), method(CreateScopedTokenInputSchema, CreateScopedTokenResultSchema, {
40634
41598
  kind: "mutation",
40635
41599
  auth: "admin",
@@ -40703,15 +41667,7 @@ method(_void(), array(UserSummarySchema), { auth: "admin" }), method(CreateUserI
40703
41667
  }).nullable(), { access: "view" }), method(object({ userId: string() }), array(ExternalIdentitySchema), { auth: "admin" }), method(ExternalIdentityKeySchema, object({
40704
41668
  userId: string(),
40705
41669
  issuer: string()
40706
- }).nullable(), { auth: "admin" }), method(ExternalIdentityKeySchema.extend({
40707
- userId: string(),
40708
- issuer: string().min(1),
40709
- label: string().optional()
40710
- }), object({ success: literal(true) }), {
40711
- kind: "mutation",
40712
- auth: "admin",
40713
- access: "create"
40714
- }), method(ExternalIdentityKeySchema.extend({ userId: string() }), object({ success: boolean() }), {
41670
+ }).nullable(), { auth: "admin" }), method(ExternalIdentityKeySchema.extend({ userId: string() }), object({ success: boolean() }), {
40715
41671
  kind: "mutation",
40716
41672
  auth: "admin",
40717
41673
  access: "delete"
@@ -41416,6 +42372,451 @@ var zoneRulesCapability = {
41416
42372
  */
41417
42373
  durability: "restored"
41418
42374
  };
42375
+ /**
42376
+ * `training-provider` — ONE cloud that can run the CamStack trainer.
42377
+ *
42378
+ * A thin, mockable translation layer: it knows how to run a container with a
42379
+ * GPU, move a dataset in, read the job's stdout and hand artefacts back. It
42380
+ * knows nothing about datasets, splits, floors, cost policy or Model Studio —
42381
+ * those are the `training` orchestrator's (D805). Every rule written there
42382
+ * once is what makes a second provider (RunPod, a local NVIDIA node) a new
42383
+ * manifest entry and nothing else.
42384
+ *
42385
+ * Collection, routed by the `addonId` in every single-row input (the `llm` /
42386
+ * `notification-output` posture); `describe` concat-fans across providers.
42387
+ * Every method is `admin`: these spend money.
42388
+ *
42389
+ * Every cloud object a provider creates is tagged with the orchestrator's
42390
+ * `jobKey`, so a retried submit finds the job it already started instead of
42391
+ * starting a second GPU, and `listJobs` can find orphans.
42392
+ *
42393
+ * Bytes never ride a cap field: the dataset arrives as a `ctx.peerBytes`
42394
+ * ticket the producer (pipeline-analytics) minted, and artefacts leave as a
42395
+ * ticket the provider mints (D613).
42396
+ */
42397
+ var TrainingGpuOptionSchema = object({
42398
+ id: string(),
42399
+ label: string(),
42400
+ /** List price, USD per GPU-hour, before any region multiplier. */
42401
+ usdPerHour: number().nonnegative(),
42402
+ vramGb: number().nonnegative()
42403
+ });
42404
+ var TrainingRegionOptionSchema = object({
42405
+ /** `''` = any region (the provider's choice). */
42406
+ id: string(),
42407
+ label: string(),
42408
+ priceMultiplier: number().positive()
42409
+ });
42410
+ /**
42411
+ * The provider's per-account settings, as the orchestrator reads them. They
42412
+ * live in the PROVIDER addon's settings (operator decision 2026-10-08: they
42413
+ * depend on the user's account), never hard-coded in the orchestrator.
42414
+ */
42415
+ var TrainingProviderDefaultsSchema = object({
42416
+ gpuType: string(),
42417
+ region: string(),
42418
+ costCapUsd: number().nonnegative(),
42419
+ maxRuntimeSec: number().int().positive(),
42420
+ /** Hours a FAILED job's cloud dataset is kept for debugging; 0 = delete at once. */
42421
+ failedDatasetGraceHours: number().nonnegative()
42422
+ });
42423
+ var TrainingProviderDescriptorSchema = object({
42424
+ addonId: string(),
42425
+ /** `modal`, `runpod`, `fake`, … */
42426
+ kind: string(),
42427
+ label: string(),
42428
+ gpuTypes: array(TrainingGpuOptionSchema).readonly(),
42429
+ regions: array(TrainingRegionOptionSchema).readonly(),
42430
+ maxDatasetBytes: number().int().positive(),
42431
+ maxRuntimeSec: number().int().positive(),
42432
+ freeTierNote: string().optional(),
42433
+ /** Where the data goes, in one sentence the confirm dialog repeats. */
42434
+ dataResidencyNote: string(),
42435
+ /** Credentials are present — never the values. */
42436
+ configured: boolean(),
42437
+ defaults: TrainingProviderDefaultsSchema
42438
+ });
42439
+ var TrainingCredentialCheckSchema = object({
42440
+ ok: boolean(),
42441
+ /** Workspace / account name, when the provider says. */
42442
+ account: string().optional(),
42443
+ reason: _enum([
42444
+ "missing",
42445
+ "invalid",
42446
+ "forbidden",
42447
+ "network",
42448
+ "quota"
42449
+ ]).optional(),
42450
+ detail: string().optional()
42451
+ });
42452
+ var ProviderJobStateSchema = _enum([
42453
+ "pending",
42454
+ "starting",
42455
+ "running",
42456
+ "succeeded",
42457
+ "failed",
42458
+ "cancelled",
42459
+ "lost"
42460
+ ]);
42461
+ var ProviderJobStatusSchema = object({
42462
+ jobKey: string(),
42463
+ providerJobId: string().optional(),
42464
+ state: ProviderJobStateSchema,
42465
+ startedAt: number().optional(),
42466
+ endedAt: number().optional(),
42467
+ exitCode: number().int().optional(),
42468
+ failureReason: string().optional(),
42469
+ gpuType: string(),
42470
+ region: string().optional(),
42471
+ billedSeconds: number().nonnegative(),
42472
+ costUsd: number().nonnegative(),
42473
+ /** True when `costUsd` is runtime × list price, not a billing answer. */
42474
+ costIsEstimate: boolean(),
42475
+ lastFetchedAt: number()
42476
+ });
42477
+ /**
42478
+ * The trainer the job runs, by SOURCE revision: the provider turns it into an
42479
+ * image its own way (Modal builds the published Dockerfile at that revision;
42480
+ * a registry-pull provider maps it to a tag). Recorded on the job and echoed
42481
+ * in `result.json`.
42482
+ */
42483
+ var TrainerSourceRefSchema = object({
42484
+ /** Hugging Face repo id, e.g. `camstack/camstack-trainer`. */
42485
+ repo: string().min(1),
42486
+ /** A commit sha (never a branch) — the job must be reproducible. */
42487
+ revision: string().regex(/^[0-9a-f]{7,64}$/)
42488
+ });
42489
+ var JobRef = {
42490
+ addonId: string(),
42491
+ jobKey: string().uuid()
42492
+ };
42493
+ var TrainingLogLineSchema = object({
42494
+ ts: number(),
42495
+ text: string()
42496
+ });
42497
+ method(object({}), array(TrainingProviderDescriptorSchema).readonly(), { auth: "admin" }), method(object({ addonId: string() }), TrainingCredentialCheckSchema, {
42498
+ kind: "mutation",
42499
+ auth: "admin",
42500
+ timeoutMs: 3e4
42501
+ }), method(object({
42502
+ addonId: string(),
42503
+ gpuType: string(),
42504
+ region: string(),
42505
+ datasetBytes: number().int().nonnegative(),
42506
+ gpuSecondsLow: number().nonnegative(),
42507
+ gpuSecondsHigh: number().nonnegative()
42508
+ }), object({
42509
+ usdLow: number().nonnegative(),
42510
+ usdHigh: number().nonnegative(),
42511
+ notes: array(string()).readonly()
42512
+ }), { auth: "admin" }), method(object({
42513
+ ...JobRef,
42514
+ ticket: PeerBytesTicketSchema
42515
+ }), object({
42516
+ bytes: number().int().nonnegative(),
42517
+ sha256: string()
42518
+ }), {
42519
+ kind: "mutation",
42520
+ auth: "admin",
42521
+ timeoutMs: 120 * 6e4
42522
+ }), method(object({
42523
+ ...JobRef,
42524
+ trainer: TrainerSourceRefSchema,
42525
+ jobSpecJson: string().min(2).max(64e3),
42526
+ gpuType: string(),
42527
+ region: string(),
42528
+ maxRuntimeSec: number().int().positive()
42529
+ }), ProviderJobStatusSchema, {
42530
+ kind: "mutation",
42531
+ auth: "admin",
42532
+ timeoutMs: 30 * 6e4
42533
+ }), method(object(JobRef), ProviderJobStatusSchema, {
42534
+ auth: "admin",
42535
+ timeoutMs: 6e4
42536
+ }), method(object({
42537
+ ...JobRef,
42538
+ cursor: string().optional(),
42539
+ max: number().int().min(1).max(500)
42540
+ }), object({
42541
+ lines: array(TrainingLogLineSchema).readonly(),
42542
+ cursor: string()
42543
+ }), {
42544
+ auth: "admin",
42545
+ timeoutMs: 6e4
42546
+ }), method(object(JobRef), object({ ok: literal(true) }), {
42547
+ kind: "mutation",
42548
+ auth: "admin",
42549
+ timeoutMs: 6e4
42550
+ }), method(object(JobRef), object({
42551
+ found: boolean(),
42552
+ text: string().optional()
42553
+ }), {
42554
+ kind: "mutation",
42555
+ auth: "admin",
42556
+ timeoutMs: 5 * 6e4
42557
+ }), method(object({
42558
+ ...JobRef,
42559
+ path: _enum(["bundle.tar"])
42560
+ }), object({ ticket: PeerBytesTicketSchema }), {
42561
+ kind: "mutation",
42562
+ auth: "admin",
42563
+ timeoutMs: 5 * 6e4
42564
+ }), method(object(JobRef), object({ deleted: array(string()).readonly() }), {
42565
+ kind: "mutation",
42566
+ auth: "admin",
42567
+ timeoutMs: 5 * 6e4
42568
+ }), method(object({ addonId: string() }), array(ProviderJobStatusSchema).readonly(), {
42569
+ auth: "admin",
42570
+ timeoutMs: 2 * 6e4
42571
+ });
42572
+ /**
42573
+ * `training` — the cloud-training orchestrator (D805). Hub-only singleton,
42574
+ * provided by `addon-training`.
42575
+ *
42576
+ * It owns what every provider must agree on, written once:
42577
+ *
42578
+ * - **Dataset versions.** Taken over from pipeline-analytics (D796): the rows
42579
+ * live here (D808); pipeline-analytics still CUTS a version (it owns the corpus and
42580
+ * the export plan) and reaches this store through the five row methods
42581
+ * below, so the Retrain page and the export did not change.
42582
+ * - **Jobs.** A persisted state machine, a reconcile loop against the
42583
+ * provider, a cost guard, a daily orphan sweep and the retention rules.
42584
+ * - **The return flow.** Verified artefacts → Model Studio
42585
+ * (`custom-model-registry.importModelBundle`) → canary on cameras →
42586
+ * rollback. Nothing is ever registered automatically.
42587
+ *
42588
+ * Every method is `admin`.
42589
+ */
42590
+ /** A version WITH its frame list — what the export and a job read. */
42591
+ var TrainingDatasetVersionRowSchema = RetrainDatasetVersionSchema.omit({ frameCount: true }).extend({ frameIds: array(string()).max(2e4).readonly() });
42592
+ /** A base model a detector job can fine-tune, and the baseline it is judged against. */
42593
+ var TrainingBaseModelSchema = object({
42594
+ modelId: string(),
42595
+ label: string(),
42596
+ weights: string(),
42597
+ imgsz: number().int(),
42598
+ baselineOnnxUrl: string(),
42599
+ baselineFloors: record(string(), number()),
42600
+ /** The base the fleet runs most — the UI's default. */
42601
+ recommended: boolean()
42602
+ });
42603
+ var TrainingPresetSchema = _enum([
42604
+ "quick",
42605
+ "standard",
42606
+ "thorough"
42607
+ ]);
42608
+ var TrainingJobRequestSchema = object({
42609
+ datasetVersionId: string().min(1),
42610
+ /** The `training-provider` addon that runs it. */
42611
+ addonId: string().min(1),
42612
+ gpuType: string().min(1),
42613
+ region: string(),
42614
+ baseModelId: string().min(1),
42615
+ preset: TrainingPresetSchema,
42616
+ /** Freeze the backbone's first N layers; `null` = the preset's choice. */
42617
+ freeze: number().int().nonnegative().nullable(),
42618
+ /** Cameras held out whole for evaluation; `null` = the orchestrator's default. */
42619
+ holdoutCameras: array(number().int()).nullable()
42620
+ });
42621
+ var TrainingSplitPlanSchema = object({
42622
+ holdoutCameras: array(number().int()).readonly(),
42623
+ /** Used when no camera is held out: the last N days of every camera. */
42624
+ holdoutLastDays: number().int().nonnegative(),
42625
+ /** Holdout subjects per class (camera holdout only; `null` = known only after the split). */
42626
+ holdoutSupport: record(string(), number().int()).nullable(),
42627
+ trainSubjects: number().int()
42628
+ });
42629
+ var TrainingRefusalReasonSchema = _enum([
42630
+ "unknown-dataset",
42631
+ "unknown-provider",
42632
+ "provider-not-configured",
42633
+ "unknown-base-model",
42634
+ "unknown-gpu",
42635
+ "dataset-too-large",
42636
+ "no-training-subjects",
42637
+ "job-already-running"
42638
+ ]);
42639
+ var TrainingJobPlanSchema = object({
42640
+ refusal: object({
42641
+ reason: TrainingRefusalReasonSchema,
42642
+ detail: string()
42643
+ }).nullable(),
42644
+ warnings: array(string()).readonly(),
42645
+ split: TrainingSplitPlanSchema.nullable(),
42646
+ estimate: object({
42647
+ datasetBytes: number().int(),
42648
+ uploadMinutesAt20Mbps: number(),
42649
+ gpuSecondsLow: number(),
42650
+ gpuSecondsHigh: number(),
42651
+ usdLow: number(),
42652
+ usdHigh: number(),
42653
+ notes: array(string()).readonly()
42654
+ }).nullable(),
42655
+ /** Pre-filled from the provider's settings; the operator may lower or raise them. */
42656
+ defaults: object({
42657
+ maxCostUsd: number(),
42658
+ maxRuntimeSec: number().int()
42659
+ }).nullable(),
42660
+ /** The sentence the confirm dialog repeats: where the frames go and when they are deleted. */
42661
+ dataNotice: string()
42662
+ });
42663
+ /**
42664
+ * Orchestrator-owned states, persisted. `uploading` covers exporting the
42665
+ * archive (it is streamed, never staged). Terminal: `failed`, `cancelled`,
42666
+ * `lost`, `expired`, `discarded`. `registered` and `canary` are where a
42667
+ * result lives after the operator acted on it.
42668
+ */
42669
+ var TrainingJobStateSchema = _enum([
42670
+ "uploading",
42671
+ "submitted",
42672
+ "starting",
42673
+ "running",
42674
+ "collecting",
42675
+ "ready",
42676
+ "registered",
42677
+ "canary",
42678
+ "failed",
42679
+ "cancelling",
42680
+ "cancelled",
42681
+ "lost",
42682
+ "expired",
42683
+ "discarded"
42684
+ ]);
42685
+ var TrainingFailureReasonSchema = _enum([
42686
+ "cost-cap",
42687
+ "runtime-cap",
42688
+ "upload-failed",
42689
+ "submit-failed",
42690
+ "trainer-failed",
42691
+ "result-invalid",
42692
+ "checksum-mismatch",
42693
+ "fetch-failed",
42694
+ "provider-error",
42695
+ "hub-restart-during-upload"
42696
+ ]);
42697
+ var TrainingProgressPointSchema = object({
42698
+ epoch: number().int(),
42699
+ map50: number().nullable(),
42700
+ map50_95: number().nullable()
42701
+ });
42702
+ var TrainingCanarySchema = object({
42703
+ deviceIds: array(number().int()).readonly(),
42704
+ since: number(),
42705
+ /** Every override the canary replaced, exactly, so rollback restores it. */
42706
+ previous: array(object({
42707
+ deviceId: number().int(),
42708
+ nodeId: string(),
42709
+ deviceKey: string(),
42710
+ patch: object({
42711
+ modelId: string().optional(),
42712
+ settings: record(string(), unknown()).readonly().optional()
42713
+ }).nullable()
42714
+ })).readonly()
42715
+ });
42716
+ var TrainingJobSchema = object({
42717
+ id: string(),
42718
+ idempotencyKey: string(),
42719
+ name: string(),
42720
+ createdAt: number(),
42721
+ updatedAt: number(),
42722
+ state: TrainingJobStateSchema,
42723
+ stage: TrainingStageSchema.nullable(),
42724
+ failure: object({
42725
+ reason: TrainingFailureReasonSchema,
42726
+ stage: string().nullable(),
42727
+ detail: string()
42728
+ }).nullable(),
42729
+ request: TrainingJobRequestSchema,
42730
+ maxCostUsd: number().nonnegative(),
42731
+ maxRuntimeSec: number().int().positive(),
42732
+ trainer: TrainerSourceRefSchema,
42733
+ datasetLayout: RetrainExportLayoutSchema,
42734
+ dataset: object({
42735
+ bytes: number().int(),
42736
+ sha256: string(),
42737
+ uploadedAt: number()
42738
+ }).nullable(),
42739
+ split: TrainingSplitPlanSchema,
42740
+ provider: object({
42741
+ state: ProviderJobStateSchema.nullable(),
42742
+ providerJobId: string().nullable(),
42743
+ startedAt: number().nullable(),
42744
+ endedAt: number().nullable(),
42745
+ billedSeconds: number(),
42746
+ costUsd: number(),
42747
+ costIsEstimate: boolean(),
42748
+ lastPolledAt: number().nullable()
42749
+ }),
42750
+ progress: object({
42751
+ epoch: number().int().nullable(),
42752
+ epochs: number().int().nullable(),
42753
+ etaSec: number().nullable(),
42754
+ series: array(TrainingProgressPointSchema).readonly()
42755
+ }),
42756
+ /** The last lines of the job's output (≤ 200), newest last. Never frame paths. */
42757
+ logTail: array(string()).readonly(),
42758
+ logCursor: string().nullable(),
42759
+ artifacts: object({
42760
+ bundleBytes: number().int(),
42761
+ bundleSha256: string(),
42762
+ fetchedAt: number(),
42763
+ /** When the staged artefacts are deleted from the hub. */
42764
+ expiresAt: number()
42765
+ }).nullable(),
42766
+ /** When the provider-side copy of the frames was deleted; null while it exists. */
42767
+ cloudDatasetDeletedAt: number().nullable(),
42768
+ /** A failed job's dataset is kept until then (the provider's grace), then deleted. */
42769
+ cloudCleanupDueAt: number().nullable(),
42770
+ /** Model ids registered from this job (base, and int8 when kept). */
42771
+ registeredModelIds: array(string()).readonly(),
42772
+ canary: TrainingCanarySchema.nullable()
42773
+ });
42774
+ var IdInput = object({ id: string().min(1) });
42775
+ method(TrainingDatasetVersionRowSchema, object({ stored: boolean() }), {
42776
+ kind: "mutation",
42777
+ auth: "admin"
42778
+ }), 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() }), {
42779
+ kind: "mutation",
42780
+ auth: "admin"
42781
+ }), method(object({}), array(TrainingBaseModelSchema).readonly(), { auth: "admin" }), method(TrainingJobRequestSchema, TrainingJobPlanSchema, {
42782
+ auth: "admin",
42783
+ timeoutMs: 6e4
42784
+ }), method(TrainingJobRequestSchema.extend({
42785
+ name: string().min(1).max(120),
42786
+ maxCostUsd: number().positive(),
42787
+ maxRuntimeSec: number().int().positive(),
42788
+ idempotencyKey: string().min(8).max(80)
42789
+ }), discriminatedUnion("kind", [object({
42790
+ kind: literal("started"),
42791
+ job: TrainingJobSchema
42792
+ }), object({
42793
+ kind: literal("refused"),
42794
+ reason: TrainingRefusalReasonSchema,
42795
+ detail: string()
42796
+ })]), {
42797
+ kind: "mutation",
42798
+ auth: "admin",
42799
+ timeoutMs: 12e4
42800
+ }), method(object({}), array(TrainingJobSchema).readonly(), { auth: "admin" }), method(IdInput, TrainingJobSchema.nullable(), { auth: "admin" }), method(IdInput, TrainingJobSchema, {
42801
+ kind: "mutation",
42802
+ auth: "admin",
42803
+ timeoutMs: 12e4
42804
+ }), method(IdInput, TrainingResultSchema.nullable(), { auth: "admin" }), method(IdInput.extend({ canaryDeviceIds: array(number().int()).readonly() }), TrainingJobSchema, {
42805
+ kind: "mutation",
42806
+ auth: "admin",
42807
+ timeoutMs: 30 * 6e4
42808
+ }), method(IdInput.extend({ deviceIds: array(number().int()).min(1).readonly() }), TrainingJobSchema, {
42809
+ kind: "mutation",
42810
+ auth: "admin",
42811
+ timeoutMs: 12e4
42812
+ }), method(IdInput, TrainingJobSchema, {
42813
+ kind: "mutation",
42814
+ auth: "admin",
42815
+ timeoutMs: 12e4
42816
+ }), method(IdInput, TrainingJobSchema, {
42817
+ kind: "mutation",
42818
+ auth: "admin"
42819
+ });
41419
42820
  SOURCE_CAPS.filter((cap) => cap !== "switch" && cap !== "motion");
41420
42821
  Object.freeze({
41421
42822
  person: .5,
@@ -43564,6 +44965,12 @@ Object.freeze({
43564
44965
  addonId: null,
43565
44966
  access: "create"
43566
44967
  },
44968
+ "backup.checkBackupKey": {
44969
+ capName: "backup",
44970
+ capScope: "system",
44971
+ addonId: null,
44972
+ access: "create"
44973
+ },
43567
44974
  "backup.delete": {
43568
44975
  capName: "backup",
43569
44976
  capScope: "system",
@@ -43576,6 +44983,18 @@ Object.freeze({
43576
44983
  addonId: null,
43577
44984
  access: "delete"
43578
44985
  },
44986
+ "backup.disableEncryption": {
44987
+ capName: "backup",
44988
+ capScope: "system",
44989
+ addonId: null,
44990
+ access: "create"
44991
+ },
44992
+ "backup.getEncryption": {
44993
+ capName: "backup",
44994
+ capScope: "system",
44995
+ addonId: null,
44996
+ access: "view"
44997
+ },
43579
44998
  "backup.getEntries": {
43580
44999
  capName: "backup",
43581
45000
  capScope: "system",
@@ -43630,6 +45049,12 @@ Object.freeze({
43630
45049
  addonId: null,
43631
45050
  access: "create"
43632
45051
  },
45052
+ "backup.setupEncryption": {
45053
+ capName: "backup",
45054
+ capScope: "system",
45055
+ addonId: null,
45056
+ access: "create"
45057
+ },
43633
45058
  "backup.trigger": {
43634
45059
  capName: "backup",
43635
45060
  capScope: "system",
@@ -44182,6 +45607,12 @@ Object.freeze({
44182
45607
  addonId: null,
44183
45608
  access: "create"
44184
45609
  },
45610
+ "customModelRegistry.importModelBundle": {
45611
+ capName: "custom-model-registry",
45612
+ capScope: "system",
45613
+ addonId: null,
45614
+ access: "create"
45615
+ },
44185
45616
  "customModelRegistry.listModels": {
44186
45617
  capName: "custom-model-registry",
44187
45618
  capScope: "system",
@@ -45622,6 +47053,12 @@ Object.freeze({
45622
47053
  addonId: null,
45623
47054
  access: "view"
45624
47055
  },
47056
+ "keychainAdmin.acknowledgeReset": {
47057
+ capName: "keychain-admin",
47058
+ capScope: "system",
47059
+ addonId: null,
47060
+ access: "create"
47061
+ },
45625
47062
  "keychainAdmin.deleteOrphans": {
45626
47063
  capName: "keychain-admin",
45627
47064
  capScope: "system",
@@ -45658,6 +47095,12 @@ Object.freeze({
45658
47095
  addonId: null,
45659
47096
  access: "delete"
45660
47097
  },
47098
+ "keychainAdmin.resetReport": {
47099
+ capName: "keychain-admin",
47100
+ capScope: "system",
47101
+ addonId: null,
47102
+ access: "delete"
47103
+ },
45661
47104
  "keychainAdmin.reveal": {
45662
47105
  capName: "keychain-admin",
45663
47106
  capScope: "system",
@@ -45670,6 +47113,12 @@ Object.freeze({
45670
47113
  addonId: null,
45671
47114
  access: "create"
45672
47115
  },
47116
+ "keychainAdmin.setSystemSecret": {
47117
+ capName: "keychain-admin",
47118
+ capScope: "system",
47119
+ addonId: null,
47120
+ access: "create"
47121
+ },
45673
47122
  "keychainAdmin.status": {
45674
47123
  capName: "keychain-admin",
45675
47124
  capScope: "system",
@@ -47116,6 +48565,12 @@ Object.freeze({
47116
48565
  addonId: null,
47117
48566
  access: "create"
47118
48567
  },
48568
+ "pipelineAnalytics.createRetrainDatasetVersion": {
48569
+ capName: "pipeline-analytics",
48570
+ capScope: "device",
48571
+ addonId: null,
48572
+ access: "create"
48573
+ },
47119
48574
  "pipelineAnalytics.deleteDeviceEvents": {
47120
48575
  capName: "pipeline-analytics",
47121
48576
  capScope: "device",
@@ -47128,6 +48583,12 @@ Object.freeze({
47128
48583
  addonId: null,
47129
48584
  access: "delete"
47130
48585
  },
48586
+ "pipelineAnalytics.deleteRetrainDatasetVersion": {
48587
+ capName: "pipeline-analytics",
48588
+ capScope: "device",
48589
+ addonId: null,
48590
+ access: "delete"
48591
+ },
47131
48592
  "pipelineAnalytics.deleteTracks": {
47132
48593
  capName: "pipeline-analytics",
47133
48594
  capScope: "device",
@@ -47350,6 +48811,12 @@ Object.freeze({
47350
48811
  addonId: null,
47351
48812
  access: "view"
47352
48813
  },
48814
+ "pipelineAnalytics.listRetrainDatasetVersions": {
48815
+ capName: "pipeline-analytics",
48816
+ capScope: "device",
48817
+ addonId: null,
48818
+ access: "view"
48819
+ },
47353
48820
  "pipelineAnalytics.listRetrainFrames": {
47354
48821
  capName: "pipeline-analytics",
47355
48822
  capScope: "device",
@@ -47380,6 +48847,12 @@ Object.freeze({
47380
48847
  addonId: null,
47381
48848
  access: "view"
47382
48849
  },
48850
+ "pipelineAnalytics.offerRetrainArchive": {
48851
+ capName: "pipeline-analytics",
48852
+ capScope: "device",
48853
+ addonId: null,
48854
+ access: "create"
48855
+ },
47383
48856
  "pipelineAnalytics.ownersWithMedia": {
47384
48857
  capName: "pipeline-analytics",
47385
48858
  capScope: "device",
@@ -47392,6 +48865,12 @@ Object.freeze({
47392
48865
  addonId: null,
47393
48866
  access: "create"
47394
48867
  },
48868
+ "pipelineAnalytics.previewRetrainDataset": {
48869
+ capName: "pipeline-analytics",
48870
+ capScope: "device",
48871
+ addonId: null,
48872
+ access: "view"
48873
+ },
47395
48874
  "pipelineAnalytics.proposeRetrainAnnotations": {
47396
48875
  capName: "pipeline-analytics",
47397
48876
  capScope: "device",
@@ -47530,6 +49009,12 @@ Object.freeze({
47530
49009
  addonId: null,
47531
49010
  access: "create"
47532
49011
  },
49012
+ "pipelineAnalytics.verifyRetrainDatasetVersion": {
49013
+ capName: "pipeline-analytics",
49014
+ capScope: "device",
49015
+ addonId: null,
49016
+ access: "view"
49017
+ },
47533
49018
  "pipelineAnalytics.wipeAllAnalytics": {
47534
49019
  capName: "pipeline-analytics",
47535
49020
  capScope: "device",
@@ -49906,6 +51391,174 @@ Object.freeze({
49906
51391
  addonId: null,
49907
51392
  access: "view"
49908
51393
  },
51394
+ "training.canaryResult": {
51395
+ capName: "training",
51396
+ capScope: "system",
51397
+ addonId: null,
51398
+ access: "create"
51399
+ },
51400
+ "training.cancelJob": {
51401
+ capName: "training",
51402
+ capScope: "system",
51403
+ addonId: null,
51404
+ access: "create"
51405
+ },
51406
+ "training.discardResult": {
51407
+ capName: "training",
51408
+ capScope: "system",
51409
+ addonId: null,
51410
+ access: "create"
51411
+ },
51412
+ "training.findDatasetVersionIdByName": {
51413
+ capName: "training",
51414
+ capScope: "system",
51415
+ addonId: null,
51416
+ access: "view"
51417
+ },
51418
+ "training.getDatasetVersion": {
51419
+ capName: "training",
51420
+ capScope: "system",
51421
+ addonId: null,
51422
+ access: "view"
51423
+ },
51424
+ "training.getJob": {
51425
+ capName: "training",
51426
+ capScope: "system",
51427
+ addonId: null,
51428
+ access: "view"
51429
+ },
51430
+ "training.getJobResult": {
51431
+ capName: "training",
51432
+ capScope: "system",
51433
+ addonId: null,
51434
+ access: "view"
51435
+ },
51436
+ "training.listBaseModels": {
51437
+ capName: "training",
51438
+ capScope: "system",
51439
+ addonId: null,
51440
+ access: "view"
51441
+ },
51442
+ "training.listDatasetVersions": {
51443
+ capName: "training",
51444
+ capScope: "system",
51445
+ addonId: null,
51446
+ access: "view"
51447
+ },
51448
+ "training.listJobs": {
51449
+ capName: "training",
51450
+ capScope: "system",
51451
+ addonId: null,
51452
+ access: "view"
51453
+ },
51454
+ "training.planJob": {
51455
+ capName: "training",
51456
+ capScope: "system",
51457
+ addonId: null,
51458
+ access: "view"
51459
+ },
51460
+ "training.putDatasetVersion": {
51461
+ capName: "training",
51462
+ capScope: "system",
51463
+ addonId: null,
51464
+ access: "create"
51465
+ },
51466
+ "training.registerResult": {
51467
+ capName: "training",
51468
+ capScope: "system",
51469
+ addonId: null,
51470
+ access: "create"
51471
+ },
51472
+ "training.removeDatasetVersion": {
51473
+ capName: "training",
51474
+ capScope: "system",
51475
+ addonId: null,
51476
+ access: "delete"
51477
+ },
51478
+ "training.rollbackCanary": {
51479
+ capName: "training",
51480
+ capScope: "system",
51481
+ addonId: null,
51482
+ access: "create"
51483
+ },
51484
+ "training.startJob": {
51485
+ capName: "training",
51486
+ capScope: "system",
51487
+ addonId: null,
51488
+ access: "create"
51489
+ },
51490
+ "trainingProvider.cancelJob": {
51491
+ capName: "training-provider",
51492
+ capScope: "system",
51493
+ addonId: null,
51494
+ access: "create"
51495
+ },
51496
+ "trainingProvider.cleanupJob": {
51497
+ capName: "training-provider",
51498
+ capScope: "system",
51499
+ addonId: null,
51500
+ access: "create"
51501
+ },
51502
+ "trainingProvider.describe": {
51503
+ capName: "training-provider",
51504
+ capScope: "system",
51505
+ addonId: null,
51506
+ access: "view"
51507
+ },
51508
+ "trainingProvider.estimateJob": {
51509
+ capName: "training-provider",
51510
+ capScope: "system",
51511
+ addonId: null,
51512
+ access: "view"
51513
+ },
51514
+ "trainingProvider.getJob": {
51515
+ capName: "training-provider",
51516
+ capScope: "system",
51517
+ addonId: null,
51518
+ access: "view"
51519
+ },
51520
+ "trainingProvider.listJobEvents": {
51521
+ capName: "training-provider",
51522
+ capScope: "system",
51523
+ addonId: null,
51524
+ access: "view"
51525
+ },
51526
+ "trainingProvider.listJobs": {
51527
+ capName: "training-provider",
51528
+ capScope: "system",
51529
+ addonId: null,
51530
+ access: "view"
51531
+ },
51532
+ "trainingProvider.offerArtifact": {
51533
+ capName: "training-provider",
51534
+ capScope: "system",
51535
+ addonId: null,
51536
+ access: "create"
51537
+ },
51538
+ "trainingProvider.readResult": {
51539
+ capName: "training-provider",
51540
+ capScope: "system",
51541
+ addonId: null,
51542
+ access: "create"
51543
+ },
51544
+ "trainingProvider.submitJob": {
51545
+ capName: "training-provider",
51546
+ capScope: "system",
51547
+ addonId: null,
51548
+ access: "create"
51549
+ },
51550
+ "trainingProvider.uploadDataset": {
51551
+ capName: "training-provider",
51552
+ capScope: "system",
51553
+ addonId: null,
51554
+ access: "create"
51555
+ },
51556
+ "trainingProvider.validateCredentials": {
51557
+ capName: "training-provider",
51558
+ capScope: "system",
51559
+ addonId: null,
51560
+ access: "create"
51561
+ },
49909
51562
  "turnProvider.getTurnServers": {
49910
51563
  capName: "turn-provider",
49911
51564
  capScope: "system",
@@ -49930,12 +51583,6 @@ Object.freeze({
49930
51583
  addonId: null,
49931
51584
  access: "create"
49932
51585
  },
49933
- "userManagement.createApiKey": {
49934
- capName: "user-management",
49935
- capScope: "system",
49936
- addonId: null,
49937
- access: "create"
49938
- },
49939
51586
  "userManagement.createScopedToken": {
49940
51587
  capName: "user-management",
49941
51588
  capScope: "system",
@@ -49972,12 +51619,6 @@ Object.freeze({
49972
51619
  addonId: null,
49973
51620
  access: "view"
49974
51621
  },
49975
- "userManagement.linkExternalIdentity": {
49976
- capName: "user-management",
49977
- capScope: "system",
49978
- addonId: null,
49979
- access: "create"
49980
- },
49981
51622
  "userManagement.listApiKeys": {
49982
51623
  capName: "user-management",
49983
51624
  capScope: "system",
@@ -50080,12 +51721,6 @@ Object.freeze({
50080
51721
  addonId: null,
50081
51722
  access: "create"
50082
51723
  },
50083
- "userManagement.validateApiKey": {
50084
- capName: "user-management",
50085
- capScope: "system",
50086
- addonId: null,
50087
- access: "view"
50088
- },
50089
51724
  "userManagement.validateCredentials": {
50090
51725
  capName: "user-management",
50091
51726
  capScope: "system",
@@ -54199,6 +55834,11 @@ Object.freeze({
54199
55834
  form: "single",
54200
55835
  optional: false
54201
55836
  }],
55837
+ "training.canaryResult": [{
55838
+ name: "deviceIds",
55839
+ form: "array",
55840
+ optional: false
55841
+ }],
54202
55842
  "update.getStatus": [{
54203
55843
  name: "deviceId",
54204
55844
  form: "single",