@camstack/addon-pipeline-orchestrator 1.2.298 → 1.2.299

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.
package/dist/index.js CHANGED
@@ -5408,7 +5408,7 @@ var ZodIssueCode = {
5408
5408
  var ZodFirstPartyTypeKind;
5409
5409
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
5410
5410
  //#endregion
5411
- //#region ../types/dist/sleep-Cr5YOk3m.mjs
5411
+ //#region ../types/dist/sleep-r3RWkGVx.mjs
5412
5412
  /**
5413
5413
  * The audio chunk plane's byte format, and the ONE expansion from a coded
5414
5414
  * window to float samples (D455).
@@ -5525,7 +5525,7 @@ function isKeychainStoredField(field) {
5525
5525
  var SECRET_CLEAR = { $secretClear: true };
5526
5526
  /** The `'***'` token D634 redaction writes for non-admins. */
5527
5527
  var LEGACY_DEVICE_REDACTION = "***";
5528
- function isRecord$1(value) {
5528
+ function isRecord$2(value) {
5529
5529
  return typeof value === "object" && value !== null && !Array.isArray(value);
5530
5530
  }
5531
5531
  function makeSecretMarker(ref) {
@@ -5536,12 +5536,12 @@ function makeSecretMarker(ref) {
5536
5536
  }
5537
5537
  /** A stored marker: an object whose `$secret` is a non-empty string. */
5538
5538
  function isSecretMarker(value) {
5539
- if (!isRecord$1(value)) return false;
5539
+ if (!isRecord$2(value)) return false;
5540
5540
  const ref = value["$secret"];
5541
5541
  return typeof ref === "string" && ref.length > 0;
5542
5542
  }
5543
5543
  function isSecretClear(value) {
5544
- return isRecord$1(value) && value["$secretClear"] === true;
5544
+ return isRecord$2(value) && value["$secretClear"] === true;
5545
5545
  }
5546
5546
  /**
5547
5547
  * The UI view of a stored secret field value: a marker becomes "set", inline
@@ -6073,6 +6073,13 @@ function globalSecretScope() {
6073
6073
  function encodeSegment(value) {
6074
6074
  return encodeURIComponent(value);
6075
6075
  }
6076
+ function decodeSegment(value) {
6077
+ try {
6078
+ return decodeURIComponent(value);
6079
+ } catch {
6080
+ return null;
6081
+ }
6082
+ }
6076
6083
  /**
6077
6084
  * The field path of a value inside an array item, addressed by the item's id:
6078
6085
  * `arrayItemFieldPath('providers', 'authentik', 'clientSecret')` →
@@ -6081,6 +6088,75 @@ function encodeSegment(value) {
6081
6088
  function arrayItemFieldPath(arrayKey, itemId, fieldKey) {
6082
6089
  return `${arrayKey}[${encodeSegment(itemId)}].${fieldKey}`;
6083
6090
  }
6091
+ function parseScope(segments) {
6092
+ switch (segments[0]) {
6093
+ case "global": return {
6094
+ scope: GLOBAL_SCOPE,
6095
+ used: 1
6096
+ };
6097
+ case "node": {
6098
+ const nodeId = segments[1] !== void 0 ? decodeSegment(segments[1]) : null;
6099
+ return nodeId === null || nodeId.length === 0 ? null : {
6100
+ scope: {
6101
+ kind: "node",
6102
+ nodeId
6103
+ },
6104
+ used: 2
6105
+ };
6106
+ }
6107
+ case "device": {
6108
+ const raw = segments[1];
6109
+ if (raw === void 0 || !/^\d+$/.test(raw)) return null;
6110
+ return {
6111
+ scope: {
6112
+ kind: "device",
6113
+ deviceId: Number(raw)
6114
+ },
6115
+ used: 2
6116
+ };
6117
+ }
6118
+ case "integration": {
6119
+ const id = segments[1] !== void 0 ? decodeSegment(segments[1]) : null;
6120
+ return id === null || id.length === 0 ? null : {
6121
+ scope: {
6122
+ kind: "integration",
6123
+ integrationId: id
6124
+ },
6125
+ used: 2
6126
+ };
6127
+ }
6128
+ case "row": {
6129
+ const collection = segments[1] !== void 0 ? decodeSegment(segments[1]) : null;
6130
+ const rowId = segments[2] !== void 0 ? decodeSegment(segments[2]) : null;
6131
+ if (collection === null || rowId === null || collection.length === 0 || rowId.length === 0) return null;
6132
+ return {
6133
+ scope: {
6134
+ kind: "row",
6135
+ collection,
6136
+ rowId
6137
+ },
6138
+ used: 3
6139
+ };
6140
+ }
6141
+ default: return null;
6142
+ }
6143
+ }
6144
+ /** Take a ref apart; `null` when it is not a well-formed ref. */
6145
+ function parseSecretRef(ref) {
6146
+ if (!ref.startsWith("secret://")) return null;
6147
+ const segments = ref.slice(9).split("/");
6148
+ const owner = segments[0] !== void 0 ? decodeSegment(segments[0]) : null;
6149
+ if (owner === null || owner.length === 0) return null;
6150
+ const parsed = parseScope(segments.slice(1));
6151
+ if (parsed === null) return null;
6152
+ const fieldPath = segments.slice(1 + parsed.used).join("/");
6153
+ if (fieldPath.length === 0) return null;
6154
+ return {
6155
+ owner,
6156
+ scope: parsed.scope,
6157
+ fieldPath
6158
+ };
6159
+ }
6084
6160
  /** A write to a secret path could not be stored in the keychain, so it was refused. */
6085
6161
  var KeychainWriteRefusedError = class extends Error {
6086
6162
  fieldPath;
@@ -6091,7 +6167,7 @@ var KeychainWriteRefusedError = class extends Error {
6091
6167
  }
6092
6168
  };
6093
6169
  var KEEP = { kind: "keep" };
6094
- function isRecord(value) {
6170
+ function isRecord$1(value) {
6095
6171
  return typeof value === "object" && value !== null && !Array.isArray(value);
6096
6172
  }
6097
6173
  function defaultMintId() {
@@ -6104,7 +6180,7 @@ function collectSecretMarkerRefs(value, out = []) {
6104
6180
  return out;
6105
6181
  }
6106
6182
  if (Array.isArray(value)) for (const item of value) collectSecretMarkerRefs(item, out);
6107
- else if (isRecord(value)) for (const child of Object.values(value)) collectSecretMarkerRefs(child, out);
6183
+ else if (isRecord$1(value)) for (const child of Object.values(value)) collectSecretMarkerRefs(child, out);
6108
6184
  return out;
6109
6185
  }
6110
6186
  async function storedValueEquals(secrets, marker, candidate) {
@@ -6159,7 +6235,7 @@ function rowId$1(row, idKey) {
6159
6235
  return null;
6160
6236
  }
6161
6237
  async function writeArray(ctx, node, incoming, stored, fieldPath) {
6162
- const storedRows = Array.isArray(stored) ? stored.filter(isRecord) : [];
6238
+ const storedRows = Array.isArray(stored) ? stored.filter(isRecord$1) : [];
6163
6239
  if (!Array.isArray(incoming)) {
6164
6240
  ctx.deletes.push(...collectSecretMarkerRefs(storedRows));
6165
6241
  return {
@@ -6175,7 +6251,7 @@ async function writeArray(ctx, node, incoming, stored, fieldPath) {
6175
6251
  const kept = /* @__PURE__ */ new Set();
6176
6252
  const rows = [];
6177
6253
  for (const row of incoming) {
6178
- if (!isRecord(row)) {
6254
+ if (!isRecord$1(row)) {
6179
6255
  rows.push(row);
6180
6256
  continue;
6181
6257
  }
@@ -6200,7 +6276,7 @@ async function writeNode(ctx, node, incoming, stored, fieldPath) {
6200
6276
  case "leaf": return writeLeaf(ctx, incoming, stored, fieldPath);
6201
6277
  case "array": return writeArray(ctx, node, incoming, stored, fieldPath);
6202
6278
  case "object": {
6203
- if (!isRecord(incoming)) {
6279
+ if (!isRecord$1(incoming)) {
6204
6280
  if (incoming === void 0) return KEEP;
6205
6281
  ctx.deletes.push(...collectSecretMarkerRefs(stored));
6206
6282
  return {
@@ -6208,7 +6284,7 @@ async function writeNode(ctx, node, incoming, stored, fieldPath) {
6208
6284
  value: incoming
6209
6285
  };
6210
6286
  }
6211
- const storedObj = isRecord(stored) ? stored : {};
6287
+ const storedObj = isRecord$1(stored) ? stored : {};
6212
6288
  return {
6213
6289
  kind: "value",
6214
6290
  value: await writeMembers(ctx, node.children, incoming, storedObj, (m) => `${fieldPath}.${m}`)
@@ -6267,12 +6343,19 @@ async function transformSecretWrite(input) {
6267
6343
  }
6268
6344
  };
6269
6345
  }
6346
+ /** Is `ref` one of `owner`'s refs? */
6347
+ function isSecretRefOwnedBy(ref, owner) {
6348
+ return parseSecretRef(ref)?.owner === owner;
6349
+ }
6270
6350
  /**
6271
6351
  * Replace every marker in `value` with its keychain value. Returns the SAME
6272
6352
  * reference when there is no marker (no allocation, no keychain call).
6273
6353
  */
6274
- async function resolveSecretMarkers(value, secrets) {
6275
- const refs = collectSecretMarkerRefs(value);
6354
+ async function resolveSecretMarkers(value, secrets, options = {}) {
6355
+ const keepMarker = options.unresolved === "keep-marker";
6356
+ const owner = options.ownedBy;
6357
+ const inScope = (ref) => owner === void 0 || isSecretRefOwnedBy(ref, owner);
6358
+ const refs = collectSecretMarkerRefs(value).filter(inScope);
6276
6359
  if (refs.length === 0) return {
6277
6360
  value,
6278
6361
  unresolved: []
@@ -6296,10 +6379,18 @@ async function resolveSecretMarkers(value, secrets) {
6296
6379
  }
6297
6380
  const substitute = (v) => {
6298
6381
  if (isSecretMarker(v)) {
6382
+ if (!inScope(v.$secret)) return {
6383
+ keep: true,
6384
+ value: v
6385
+ };
6299
6386
  const answer = answers[v.$secret];
6300
- return answer?.kind === "value" ? {
6387
+ if (answer?.kind === "value") return {
6301
6388
  keep: true,
6302
6389
  value: answer.value
6390
+ };
6391
+ return keepMarker ? {
6392
+ keep: true,
6393
+ value: v
6303
6394
  } : {
6304
6395
  keep: false,
6305
6396
  value: void 0
@@ -6316,7 +6407,7 @@ async function resolveSecretMarkers(value, secrets) {
6316
6407
  value: items
6317
6408
  };
6318
6409
  }
6319
- if (isRecord(v)) {
6410
+ if (isRecord$1(v)) {
6320
6411
  const out = {};
6321
6412
  for (const [k, child] of Object.entries(v)) {
6322
6413
  const s = substitute(child);
@@ -6337,14 +6428,152 @@ async function resolveSecretMarkers(value, secrets) {
6337
6428
  unresolved
6338
6429
  };
6339
6430
  }
6340
- function touchesTree(tree, patch) {
6341
- if (tree.size === 0) return false;
6342
- for (const key of Object.keys(patch)) {
6343
- const at = key.indexOf("@");
6344
- if (tree.has(at > 0 ? key.slice(0, at) : key)) return true;
6431
+ /** An addon tried to replace a stored secret it could not read. Nothing was written. */
6432
+ var SecretOverwriteRefusedError = class extends Error {
6433
+ ref;
6434
+ reason;
6435
+ constructor(ref, reason) {
6436
+ 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.`);
6437
+ this.ref = ref;
6438
+ this.reason = reason;
6439
+ this.name = "SecretOverwriteRefusedError";
6440
+ }
6441
+ };
6442
+ function isRecord(value) {
6443
+ return typeof value === "object" && value !== null && !Array.isArray(value);
6444
+ }
6445
+ function resolvedValue(pass, marker) {
6446
+ const answer = pass.answers[marker.$secret];
6447
+ return answer?.kind === "value" ? answer.value : null;
6448
+ }
6449
+ async function atMarker(pass, incoming, stored) {
6450
+ if (incoming === null) return stored;
6451
+ if (typeof incoming !== "string") return incoming;
6452
+ if (incoming === resolvedValue(pass, stored)) return stored;
6453
+ const intent = classifySecretWrite(incoming);
6454
+ if (intent.kind !== "set") return stored;
6455
+ const ref = stored.$secret;
6456
+ if (!isSecretRefOwnedBy(ref, pass.secrets.owner)) return incoming;
6457
+ const answer = pass.answers[ref];
6458
+ 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);
6459
+ try {
6460
+ await pass.secrets.put(ref, intent.value);
6461
+ } catch (err) {
6462
+ throw new KeychainWriteRefusedError(ref, err);
6463
+ }
6464
+ pass.changedRefs.push(ref);
6465
+ return stored;
6466
+ }
6467
+ function inArray(pass, incoming, stored) {
6468
+ return incoming.map((item, index) => {
6469
+ const twin = stored[index];
6470
+ if (isSecretMarker(twin)) return typeof item === "string" && item === resolvedValue(pass, twin) ? twin : item;
6471
+ if (isRecord(item) && isRecord(twin)) return inArrayRow(pass, item, twin);
6472
+ if (Array.isArray(item) && Array.isArray(twin)) return inArray(pass, item, twin);
6473
+ return item;
6474
+ });
6475
+ }
6476
+ function inArrayRow(pass, incoming, stored) {
6477
+ const out = { ...incoming };
6478
+ for (const [key, value] of Object.entries(incoming)) {
6479
+ const twin = stored[key];
6480
+ if (isSecretMarker(twin)) {
6481
+ if (typeof value === "string" && value === resolvedValue(pass, twin)) out[key] = twin;
6482
+ } else if (isRecord(value) && isRecord(twin)) out[key] = inArrayRow(pass, value, twin);
6483
+ else if (Array.isArray(value) && Array.isArray(twin)) out[key] = inArray(pass, value, twin);
6484
+ }
6485
+ return out;
6486
+ }
6487
+ async function walk(pass, incoming, stored) {
6488
+ if (isSecretMarker(stored)) return atMarker(pass, incoming, stored);
6489
+ if (Array.isArray(incoming) && Array.isArray(stored)) return inArray(pass, incoming, stored);
6490
+ if (!isRecord(incoming) || !isRecord(stored)) return incoming;
6491
+ const out = { ...incoming };
6492
+ for (const [key, value] of Object.entries(incoming)) out[key] = await walk(pass, value, stored[key]);
6493
+ return out;
6494
+ }
6495
+ /** Restore markers a write-back carries as values. See the file doc. */
6496
+ async function restoreUnchangedSecrets(input) {
6497
+ const refs = [];
6498
+ for (const key of Object.keys(input.patch)) collectSecretMarkerRefs(input.stored[key], refs);
6499
+ const owned = refs.filter((ref) => isSecretRefOwnedBy(ref, input.secrets.owner));
6500
+ if (owned.length === 0) return {
6501
+ patch: input.patch,
6502
+ changedRefs: []
6503
+ };
6504
+ const pass = {
6505
+ secrets: input.secrets,
6506
+ answers: await input.secrets.resolve([...new Set(owned)]),
6507
+ operatorWrite: input.operatorWrite,
6508
+ changedRefs: []
6509
+ };
6510
+ const out = {};
6511
+ for (const [key, value] of Object.entries(input.patch)) out[key] = await walk(pass, value, input.stored[key]);
6512
+ return {
6513
+ patch: out,
6514
+ changedRefs: pass.changedRefs
6515
+ };
6516
+ }
6517
+ /** Structural equality over JSON-shaped values (key order does not matter). */
6518
+ function isJsonEqual(a, b) {
6519
+ if (Object.is(a, b)) return true;
6520
+ if (Array.isArray(a)) return Array.isArray(b) && a.length === b.length && a.every((v, i) => isJsonEqual(v, b[i]));
6521
+ if (isRecord(a) && isRecord(b)) {
6522
+ const keys = Object.keys(a);
6523
+ if (keys.length !== Object.keys(b).length) return false;
6524
+ return keys.every((k) => Object.prototype.hasOwnProperty.call(b, k) && isJsonEqual(a[k], b[k]));
6345
6525
  }
6346
6526
  return false;
6347
6527
  }
6528
+ /** The patch without the keys whose value already equals the stored one. */
6529
+ function dropUnchangedKeys(patch, stored) {
6530
+ const out = {};
6531
+ for (const [key, value] of Object.entries(patch)) {
6532
+ if (Object.prototype.hasOwnProperty.call(stored, key) && isJsonEqual(value, stored[key])) continue;
6533
+ out[key] = value;
6534
+ }
6535
+ return out;
6536
+ }
6537
+ /** The top-level keys of a blob that hold at least one of `owner`'s markers. */
6538
+ function markerKeysOf(blob, owner) {
6539
+ const keys = /* @__PURE__ */ new Set();
6540
+ for (const [key, value] of Object.entries(blob)) if (collectSecretMarkerRefs(value).some((ref) => isSecretRefOwnedBy(ref, owner))) keys.add(key);
6541
+ return keys;
6542
+ }
6543
+ function nodeFromStored(value, owner) {
6544
+ if (isSecretMarker(value)) return isSecretRefOwnedBy(value.$secret, owner) ? { kind: "leaf" } : null;
6545
+ if (!isRecord(value)) return null;
6546
+ const children = /* @__PURE__ */ new Map();
6547
+ for (const [key, child] of Object.entries(value)) {
6548
+ const node = nodeFromStored(child, owner);
6549
+ if (node !== null) children.set(key, node);
6550
+ }
6551
+ return children.size > 0 ? {
6552
+ kind: "object",
6553
+ children
6554
+ } : null;
6555
+ }
6556
+ /**
6557
+ * The declared secret tree, widened by every place the STORED blob holds a
6558
+ * marker under one of `keys` — so a marker the schema no longer declares (or
6559
+ * never declared: Wyze before b4906cec6) still gets the save path's
6560
+ * KEEP / SET / CLEAR semantics instead of being overwritten by whatever the
6561
+ * addon writes. Markers inside arrays are not added: a row has no id field to
6562
+ * match by unless the schema declares one. Only `owner`'s markers count: a
6563
+ * builtin that keeps another addon's marker (device-manager) never takes it
6564
+ * over.
6565
+ */
6566
+ function widenTreeWithStoredMarkers(declared, stored, keys, owner) {
6567
+ const added = /* @__PURE__ */ new Map();
6568
+ for (const key of keys) {
6569
+ const at = key.indexOf("@");
6570
+ const base = at > 0 ? key.slice(0, at) : key;
6571
+ if (declared.has(base) || added.has(base)) continue;
6572
+ const node = nodeFromStored(stored[key], owner);
6573
+ if (node !== null) added.set(base, node);
6574
+ }
6575
+ return added.size === 0 ? declared : new Map([...declared, ...added]);
6576
+ }
6348
6577
  /** The blob as stored now; a failed read REFUSES the write instead of guessing. */
6349
6578
  async function readStoredAddonBlob(raw) {
6350
6579
  const threeWay = raw.readAddonStoreResult;
@@ -6353,7 +6582,41 @@ async function readStoredAddonBlob(raw) {
6353
6582
  if (result.kind === "failed") throw new Error(`settings write refused: the stored blob could not be read (${result.error})`);
6354
6583
  return result.kind === "missing" ? {} : result.value;
6355
6584
  }
6356
- function createSecretAwareSettings(raw, opts) {
6585
+ function touchesTree(tree, patch) {
6586
+ if (tree.size === 0) return false;
6587
+ for (const key of Object.keys(patch)) {
6588
+ const at = key.indexOf("@");
6589
+ if (tree.has(at > 0 ? key.slice(0, at) : key)) return true;
6590
+ }
6591
+ return false;
6592
+ }
6593
+ /**
6594
+ * Which top-level keys of each store held markers when last seen. `undefined`
6595
+ * for a store not seen yet: its first write reads it, to be safe.
6596
+ */
6597
+ var MarkerKeyIndex = class {
6598
+ owner;
6599
+ byStore = /* @__PURE__ */ new Map();
6600
+ constructor(owner) {
6601
+ this.owner = owner;
6602
+ }
6603
+ seen(store, blob) {
6604
+ this.byStore.set(store, markerKeysOf(blob, this.owner));
6605
+ }
6606
+ wrote(store, patch) {
6607
+ const keys = this.byStore.get(store);
6608
+ if (keys === void 0) return;
6609
+ const now = markerKeysOf(patch, this.owner);
6610
+ for (const key of Object.keys(patch)) if (now.has(key)) keys.add(key);
6611
+ else keys.delete(key);
6612
+ }
6613
+ mayHoldMarkers(store, patch) {
6614
+ const keys = this.byStore.get(store);
6615
+ if (keys === void 0) return true;
6616
+ return Object.keys(patch).some((key) => keys.has(key));
6617
+ }
6618
+ };
6619
+ function createHandle(raw, opts) {
6357
6620
  const chains = /* @__PURE__ */ new Map();
6358
6621
  const serialize = (key, fn) => {
6359
6622
  const next = (chains.get(key) ?? Promise.resolve()).then(fn, fn);
@@ -6364,46 +6627,130 @@ function createSecretAwareSettings(raw, opts) {
6364
6627
  });
6365
6628
  return next;
6366
6629
  };
6367
- const write = async (chainKey, tree, scope, patch, readStored, rawWrite) => {
6368
- if (!touchesTree(tree, patch)) return rawWrite(patch);
6369
- return serialize(chainKey, async () => {
6630
+ const index = new MarkerKeyIndex(opts.secrets.owner);
6631
+ const resolveRead = async (store, blob) => {
6632
+ index.seen(store, blob);
6633
+ const { value, unresolved } = await resolveSecretMarkers(blob, opts.secrets, {
6634
+ unresolved: "keep-marker",
6635
+ ownedBy: opts.secrets.owner
6636
+ });
6637
+ if (unresolved.length > 0) opts.onUnresolved?.(unresolved);
6638
+ return value;
6639
+ };
6640
+ const write = async (store, declared, scope, patch, readStored, rawWrite) => {
6641
+ if (!touchesTree(declared, patch) && !index.mayHoldMarkers(store, patch)) {
6642
+ await rawWrite(patch);
6643
+ index.wrote(store, patch);
6644
+ return { changed: true };
6645
+ }
6646
+ return serialize(store, async () => {
6370
6647
  const stored = await readStored();
6648
+ index.seen(store, stored);
6649
+ const operatorWrite = opts.isOperatorWrite?.() === true;
6650
+ const restored = await restoreUnchangedSecrets({
6651
+ patch,
6652
+ stored,
6653
+ secrets: opts.secrets,
6654
+ operatorWrite
6655
+ });
6371
6656
  const result = await transformSecretWrite({
6372
- tree,
6657
+ tree: widenTreeWithStoredMarkers(declared, stored, Object.keys(restored.patch), opts.secrets.owner),
6373
6658
  secrets: opts.secrets,
6374
- patch,
6659
+ patch: restored.patch,
6375
6660
  stored,
6376
6661
  ...scope !== void 0 ? { scope } : {},
6377
- operatorWrite: opts.isOperatorWrite?.() === true
6662
+ operatorWrite
6378
6663
  });
6379
- if (Object.keys(result.patch).length > 0) await rawWrite(result.patch);
6664
+ const effective = dropUnchangedKeys(result.patch, stored);
6665
+ const wroteBlob = Object.keys(effective).length > 0;
6666
+ if (wroteBlob) {
6667
+ await rawWrite(effective);
6668
+ index.wrote(store, effective);
6669
+ }
6380
6670
  const { orphaned } = await result.afterWrite();
6381
6671
  if (orphaned.length > 0) opts.onOrphaned(orphaned);
6672
+ return { changed: wroteBlob || restored.changedRefs.length > 0 };
6382
6673
  });
6383
6674
  };
6384
- const wrapped = {
6385
- writeAddonStore: (patch) => write("addon", opts.addonTree(), void 0, patch, () => readStoredAddonBlob(raw), (p) => raw.writeAddonStore(p)),
6386
- writeDeviceStore: (deviceId, patch) => write(`device:${deviceId}`, opts.deviceTree(), {
6387
- kind: "device",
6388
- deviceId
6389
- }, patch, () => raw.readDeviceStore(deviceId), (p) => raw.writeDeviceStore(deviceId, p))
6675
+ const writeAddon = (patch) => write("addon", opts.addonTree(), void 0, patch, () => readStoredAddonBlob(raw), (p) => raw.writeAddonStore(p));
6676
+ const readAddonStoreResult = raw.readAddonStoreResult;
6677
+ const readAddonStoreKeyResult = raw.readAddonStoreKeyResult;
6678
+ const readDeviceStoreBatch = raw.readDeviceStoreBatch;
6679
+ const overrides = {
6680
+ readAddonStore: async () => resolveRead("addon", await raw.readAddonStore()),
6681
+ ...readAddonStoreResult !== void 0 ? { readAddonStoreResult: async () => {
6682
+ const result = await readAddonStoreResult.call(raw);
6683
+ return result.kind === "value" ? {
6684
+ kind: "value",
6685
+ value: await resolveRead("addon", result.value)
6686
+ } : result;
6687
+ } } : {},
6688
+ ...readAddonStoreKeyResult !== void 0 ? { readAddonStoreKeyResult: async (key) => {
6689
+ const result = await readAddonStoreKeyResult.call(raw, key);
6690
+ if (result.kind !== "present") return result;
6691
+ const { value, unresolved } = await resolveSecretMarkers({ [key]: result.value }, opts.secrets, {
6692
+ unresolved: "keep-marker",
6693
+ ownedBy: opts.secrets.owner
6694
+ });
6695
+ if (unresolved.length > 0) opts.onUnresolved?.(unresolved);
6696
+ return {
6697
+ kind: "present",
6698
+ value: value[key]
6699
+ };
6700
+ } } : {},
6701
+ readDeviceStore: async (deviceId) => resolveRead(`device:${deviceId}`, await raw.readDeviceStore(deviceId)),
6702
+ ...readDeviceStoreBatch !== void 0 ? { readDeviceStoreBatch: async (deviceIds) => {
6703
+ const rows = await readDeviceStoreBatch.call(raw, deviceIds);
6704
+ const out = /* @__PURE__ */ new Map();
6705
+ for (const [deviceId, blob] of rows) out.set(deviceId, await resolveRead(`device:${deviceId}`, blob));
6706
+ return out;
6707
+ } } : {},
6708
+ writeAddonStore: async (patch) => {
6709
+ await writeAddon(patch);
6710
+ },
6711
+ writeDeviceStore: async (deviceId, patch) => {
6712
+ await write(`device:${deviceId}`, opts.deviceTree(), {
6713
+ kind: "device",
6714
+ deviceId
6715
+ }, patch, () => raw.readDeviceStore(deviceId), (p) => raw.writeDeviceStore(deviceId, p));
6716
+ }
6717
+ };
6718
+ return {
6719
+ settings: new Proxy(raw, { get(target, prop, receiver) {
6720
+ if (typeof prop === "string" && Object.prototype.hasOwnProperty.call(overrides, prop)) return Reflect.get(overrides, prop);
6721
+ const value = Reflect.get(target, prop, receiver);
6722
+ return typeof value === "function" ? value.bind(target) : value;
6723
+ } }),
6724
+ raw: {
6725
+ readAddonStore: async () => {
6726
+ const blob = await raw.readAddonStore();
6727
+ index.seen("addon", blob);
6728
+ return blob;
6729
+ },
6730
+ readDeviceStore: async (deviceId) => {
6731
+ const blob = await raw.readDeviceStore(deviceId);
6732
+ index.seen(`device:${deviceId}`, blob);
6733
+ return blob;
6734
+ }
6735
+ },
6736
+ writeAddonStore: writeAddon
6390
6737
  };
6391
- return new Proxy(raw, { get(target, prop, receiver) {
6392
- if (prop === "writeAddonStore") return wrapped.writeAddonStore;
6393
- if (prop === "writeDeviceStore") return wrapped.writeDeviceStore;
6394
- const value = Reflect.get(target, prop, receiver);
6395
- return typeof value === "function" ? value.bind(target) : value;
6396
- } });
6397
6738
  }
6398
- /** The context the addon sees: identical, except that its settings writes are secret-aware. */
6399
- function withSecretAwareSettings(context, opts) {
6739
+ /** The context the addon sees, plus the private raw view and write outcome. */
6740
+ function createSecretAwareContext(context, opts) {
6400
6741
  const raw = context.settings;
6401
- if (raw === void 0) return context;
6402
- const settings = createSecretAwareSettings(raw, opts);
6403
- return new Proxy(context, { get(target, prop, receiver) {
6404
- if (prop === "settings") return settings;
6405
- return Reflect.get(target, prop, receiver);
6406
- } });
6742
+ if (raw === void 0) return {
6743
+ context,
6744
+ handle: null
6745
+ };
6746
+ const handle = createHandle(raw, opts);
6747
+ return {
6748
+ context: new Proxy(context, { get(target, prop, receiver) {
6749
+ if (prop === "settings") return handle.settings;
6750
+ return Reflect.get(target, prop, receiver);
6751
+ } }),
6752
+ handle
6753
+ };
6407
6754
  }
6408
6755
  var LEAF = { kind: "leaf" };
6409
6756
  var DEFAULT_ITEM_ID_KEY = "id";
@@ -6578,6 +6925,14 @@ var BaseAddon = class {
6578
6925
  _secretChangeUnsub = null;
6579
6926
  /** >0 while an OPERATOR's settings write is being applied. */
6580
6927
  _operatorWriteDepth = 0;
6928
+ /**
6929
+ * The keychain-aware settings handle (D798). Its `raw` view is the ONLY way
6930
+ * to the marker-bearing blobs and stays private to this class: the form
6931
+ * hydrate and config resolution need markers, addon code never does.
6932
+ */
6933
+ _secretSettings = null;
6934
+ /** Refs an addon-facing read could not resolve — each is logged once per process. */
6935
+ _loggedUnresolvedReads = /* @__PURE__ */ new Set();
6581
6936
  constructor(defaults) {
6582
6937
  this.defaults = defaults;
6583
6938
  this._config = { ...defaults };
@@ -6614,13 +6969,21 @@ var BaseAddon = class {
6614
6969
  }
6615
6970
  async initialize(context) {
6616
6971
  const secrets = context.secrets;
6617
- this._ctx = secrets !== void 0 ? withSecretAwareSettings(context, {
6618
- secrets,
6619
- addonTree: () => this.addonSecretTree(),
6620
- deviceTree: () => this.deviceSecretTree(),
6621
- onOrphaned: (refs) => context.logger.warn("keychain refs dropped by a settings write could not be deleted", { meta: { refs: [...refs] } }),
6622
- isOperatorWrite: () => this._operatorWriteDepth > 0
6623
- }) : context;
6972
+ if (secrets !== void 0) {
6973
+ const { context: wrapped, handle } = createSecretAwareContext(context, {
6974
+ secrets,
6975
+ addonTree: () => this.addonSecretTree(),
6976
+ deviceTree: () => this.deviceSecretTree(),
6977
+ onOrphaned: (refs) => context.logger.warn("keychain refs dropped by a settings write could not be deleted", { meta: { refs: [...refs] } }),
6978
+ isOperatorWrite: () => this._operatorWriteDepth > 0,
6979
+ onUnresolved: (unresolved) => this.logUnresolvedRead(unresolved)
6980
+ });
6981
+ this._ctx = wrapped;
6982
+ this._secretSettings = handle;
6983
+ } else {
6984
+ this._ctx = context;
6985
+ this._secretSettings = null;
6986
+ }
6624
6987
  await this.resolveConfig();
6625
6988
  if (secrets !== void 0) this._secretChangeUnsub = secrets.onChange((ref) => {
6626
6989
  if (this._configSecretRefs.has(ref)) this.scheduleSecretReresolve(SECRET_CHANGE_DEBOUNCE_MS);
@@ -6737,11 +7100,8 @@ var BaseAddon = class {
6737
7100
  async getGlobalSettings(overlay, cap, nodeId) {
6738
7101
  const schema = this.globalSettingsSchema(cap);
6739
7102
  if (!schema) return { sections: [] };
6740
- const projected = await this.resolveGlobalStore(nodeId, cap);
6741
- return hydrateSchema(schema, overlay ? {
6742
- ...projected,
6743
- ...overlay
6744
- } : projected, { inlineSecretsAsViews: true });
7103
+ const projected = await this.readRawProjectedStore(nodeId, cap);
7104
+ return hydrateSchema(schema, overlay ? await this.overlayKeepingMarkers(projected, overlay) : projected, { inlineSecretsAsViews: true });
6745
7105
  }
6746
7106
  /**
6747
7107
  * The integration-level view of this addon's settings: exactly the sections
@@ -6786,7 +7146,7 @@ var BaseAddon = class {
6786
7146
  });
6787
7147
  }
6788
7148
  if (sections.length === 0) return null;
6789
- const projected = await this.resolveGlobalStore(nodeId);
7149
+ const projected = await this.readRawProjectedStore(nodeId);
6790
7150
  return hydrateSchema({
6791
7151
  ...schema,
6792
7152
  sections
@@ -6803,12 +7163,50 @@ var BaseAddon = class {
6803
7163
  * the store for custom option logic (option narrowing, value snapping) to
6804
7164
  * read it per-node — never `ctx.settings.readAddonStore()` directly.
6805
7165
  * `nodeId` omitted ⇒ the local node (node-blind injection from ctx).
7166
+ *
7167
+ * Keychain values come back RESOLVED (D798): a secret reads as its value,
7168
+ * never as a `{ $secret }` marker. One the keychain cannot serve right now
7169
+ * stays a marker — "stored, unavailable" (`isSecretMarker()` is true, and it
7170
+ * is listed in {@link unresolvedSecrets}) — never `''` and never absent, so
7171
+ * it cannot be mistaken for "nothing stored, mint a new one". Writing the
7172
+ * resolved blob back is a no-op for every unchanged secret.
6806
7173
  */
6807
7174
  async resolveGlobalStore(nodeId, cap) {
6808
7175
  const raw = await this._ctx?.settings?.readAddonStore() ?? {};
7176
+ return this.projectForNode(raw, nodeId, cap);
7177
+ }
7178
+ projectForNode(store, nodeId, cap) {
6809
7179
  const keys = this.perNodeKeys(cap);
6810
7180
  const node = normalizeNodeId(nodeId ?? this._ctx?.kernel?.localNodeId);
6811
- return keys.size > 0 ? projectStore(raw, keys, node) : raw;
7181
+ return keys.size > 0 ? projectStore(store, keys, node) : store;
7182
+ }
7183
+ /** The PROJECTED store with its markers — the form hydrate only (D798). */
7184
+ async readRawProjectedStore(nodeId, cap) {
7185
+ const raw = await this.rawSettings()?.readAddonStore() ?? {};
7186
+ return this.projectForNode(raw, nodeId, cap);
7187
+ }
7188
+ /**
7189
+ * `{ ...stored, ...overlay }`, except that an overlay member equal to the
7190
+ * RESOLVED stored one keeps the stored (marker-bearing) member — so a form
7191
+ * hydrated from a resolved overlay still shows a secret as "set", never as
7192
+ * its value.
7193
+ */
7194
+ async overlayKeepingMarkers(stored, overlay) {
7195
+ const secrets = this._ctx?.secrets;
7196
+ const merged = {
7197
+ ...stored,
7198
+ ...overlay
7199
+ };
7200
+ if (secrets === void 0 || collectSecretMarkerRefs(stored).length === 0) return merged;
7201
+ const { value: resolved } = await resolveSecretMarkers(stored, secrets, {
7202
+ unresolved: "keep-marker",
7203
+ ownedBy: secrets.owner
7204
+ });
7205
+ for (const key of Object.keys(overlay)) {
7206
+ if (collectSecretMarkerRefs(stored[key]).length === 0) continue;
7207
+ if (isJsonEqual(overlay[key], resolved[key])) merged[key] = stored[key];
7208
+ }
7209
+ return merged;
6812
7210
  }
6813
7211
  /**
6814
7212
  * Whether ONE global key of this addon's store was written, read three-way
@@ -6873,8 +7271,12 @@ var BaseAddon = class {
6873
7271
  async clearSecrets(keys, nodeId) {
6874
7272
  const tree = this.addonSecretTree();
6875
7273
  const keychain = this._ctx?.secrets !== void 0;
7274
+ const stored = keychain ? await this.readAddonStoreWithRetry() : {};
6876
7275
  const patch = {};
6877
- for (const key of keys) patch[key] = keychain && tree.has(key) ? SECRET_CLEAR : "";
7276
+ for (const key of keys) {
7277
+ const keychainStored = tree.has(key) || collectSecretMarkerRefs(stored[key]).length > 0;
7278
+ patch[key] = keychain && keychainStored ? SECRET_CLEAR : "";
7279
+ }
6878
7280
  await this.applyGlobalPatch(patch, nodeId);
6879
7281
  }
6880
7282
  async applyGlobalPatch(barePatch, nodeId) {
@@ -6882,7 +7284,11 @@ var BaseAddon = class {
6882
7284
  const localNode = normalizeNodeId(this._ctx?.kernel?.localNodeId);
6883
7285
  const target = normalizeNodeId(nodeId ?? this._ctx?.kernel?.localNodeId);
6884
7286
  const scoped = keys.size > 0 ? scopePatch(barePatch, keys, target) : barePatch;
6885
- await this._ctx?.settings?.writeAddonStore(scoped);
7287
+ const handle = this._secretSettings;
7288
+ if (handle !== null) {
7289
+ const { changed } = await handle.writeAddonStore(scoped);
7290
+ if (!changed) return;
7291
+ } else await this._ctx?.settings?.writeAddonStore(scoped);
6886
7292
  if (target !== localNode) return;
6887
7293
  await this.resolveConfig();
6888
7294
  await this.onConfigChanged();
@@ -6935,7 +7341,7 @@ var BaseAddon = class {
6935
7341
  async getDeviceSettings(deviceId) {
6936
7342
  const schema = this.deviceSettingsSchema();
6937
7343
  if (!schema) return { sections: [] };
6938
- return hydrateSchema(schema, await this._ctx?.settings?.readDeviceStore(deviceId) ?? {}, { inlineSecretsAsViews: true });
7344
+ return hydrateSchema(schema, await this.rawSettings()?.readDeviceStore(deviceId) ?? {}, { inlineSecretsAsViews: true });
6939
7345
  }
6940
7346
  async updateDeviceSettings(deviceId, patch) {
6941
7347
  await this._ctx?.settings?.writeDeviceStore(deviceId, patch);
@@ -7107,7 +7513,7 @@ var BaseAddon = class {
7107
7513
  key,
7108
7514
  schema,
7109
7515
  fallback,
7110
- read: async () => this.resolveStoredSecrets(await this._ctx?.settings?.readDeviceStore(deviceId) ?? {}, false),
7516
+ read: async () => this.resolveStoredSecrets(await this.rawSettings()?.readDeviceStore(deviceId) ?? {}, false),
7111
7517
  write: async (patch) => {
7112
7518
  await this._ctx?.settings?.writeDeviceStore(deviceId, patch);
7113
7519
  },
@@ -7169,6 +7575,23 @@ var BaseAddon = class {
7169
7575
  }
7170
7576
  return value;
7171
7577
  }
7578
+ /**
7579
+ * The marker-bearing settings reads (D798) — private on purpose. Without a
7580
+ * keychain the context's own view is already raw.
7581
+ */
7582
+ rawSettings() {
7583
+ return this._secretSettings?.raw ?? this._ctx?.settings;
7584
+ }
7585
+ /** An addon-facing read met markers it could not resolve: say so once per ref. */
7586
+ logUnresolvedRead(unresolved) {
7587
+ const fresh = unresolved.filter((u) => !this._loggedUnresolvedReads.has(u.ref));
7588
+ if (fresh.length === 0) return;
7589
+ for (const u of fresh) this._loggedUnresolvedReads.add(u.ref);
7590
+ 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) => ({
7591
+ ref: u.ref,
7592
+ reason: u.reason
7593
+ })) } });
7594
+ }
7172
7595
  /** Re-resolve the config (a keychain-only change, or a retry) and apply it. */
7173
7596
  scheduleSecretReresolve(delayMs) {
7174
7597
  const timerOf = delayMs === SECRET_CHANGE_DEBOUNCE_MS ? "_secretChangeTimer" : "_secretRetryTimer";
@@ -7195,7 +7618,7 @@ var BaseAddon = class {
7195
7618
  * `{}` (defaults) — the addon's first successful patch will rehydrate.
7196
7619
  */
7197
7620
  async readAddonStoreWithRetry() {
7198
- const settings = this._ctx?.settings;
7621
+ const settings = this.rawSettings();
7199
7622
  if (!settings) return {};
7200
7623
  const delaysMs = [
7201
7624
  150,
@@ -10454,6 +10877,278 @@ function composeSwitchedOff(input) {
10454
10877
  };
10455
10878
  }
10456
10879
  /**
10880
+ * The trainer contract — what the hub hands the cloud trainer and what it
10881
+ * gets back (cloud training, D805+).
10882
+ *
10883
+ * The trainer (`hf/camstack-trainer`, published as the Hugging Face repo
10884
+ * `camstack/camstack-trainer`) is a separate AGPL program the hub never
10885
+ * imports: `job.json` goes in, files come out, and progress is `CAMSTACK_EVENT`
10886
+ * lines on stdout. These schemas are the hub's half of that boundary; the
10887
+ * trainer's pydantic models (and the JSON Schemas generated from them under
10888
+ * `hf/camstack-trainer/schemas/`) are the other half. A change here is a
10889
+ * change there, in the same piece of work.
10890
+ *
10891
+ * No `.default()` anywhere: defaults do not run on the addon cap path, so the
10892
+ * orchestrator fills every field of a job spec explicitly.
10893
+ */
10894
+ var TRAINING_JOB_SCHEMA = "camstack.training/v1";
10895
+ var TRAINING_RESULT_SCHEMA = "camstack.training-result/v1";
10896
+ /** What the trainer can export. Edge TPU is a later, separate image. */
10897
+ var TrainingExportSchema = _enum([
10898
+ "onnx",
10899
+ "openvino-fp16",
10900
+ "openvino-int8",
10901
+ "coreml-fp16"
10902
+ ]);
10903
+ var FloorsSchema = record(string(), number().min(0).max(1));
10904
+ object({
10905
+ schema: literal(TRAINING_JOB_SCHEMA),
10906
+ jobKey: string().uuid(),
10907
+ target: object({
10908
+ kind: literal("detector"),
10909
+ step: literal("object-detection")
10910
+ }),
10911
+ base: object({
10912
+ modelId: string().min(1),
10913
+ /** Ultralytics weights id, e.g. `yolov9m.pt`. */
10914
+ weights: string().min(1),
10915
+ imgsz: number().int().positive()
10916
+ }),
10917
+ baseline: object({
10918
+ modelId: string().min(1),
10919
+ /** The baseline ONNX the holdout comparison runs; public mirror URL. */
10920
+ onnxUrl: string().url(),
10921
+ imgsz: number().int().positive(),
10922
+ floors: FloorsSchema
10923
+ }),
10924
+ dataset: object({
10925
+ versionId: string().min(1),
10926
+ annotationHash: string(),
10927
+ /** sha256 of the uploaded archive; the trainer refuses a mismatch (exit 65). */
10928
+ sha256: string().regex(/^[0-9a-f]{64}$/)
10929
+ }),
10930
+ split: object({
10931
+ holdoutCameras: array(number().int()),
10932
+ /** When no camera is held out: the last N days of every camera. */
10933
+ holdoutLastDays: number().int().nonnegative(),
10934
+ valFraction: number().min(0).max(.5),
10935
+ seed: number().int()
10936
+ }),
10937
+ hyper: object({
10938
+ epochs: number().int().positive(),
10939
+ batch: number().int().positive(),
10940
+ lr0: number().positive(),
10941
+ /** Layers frozen from the start of the backbone; 0 = none. */
10942
+ freeze: number().int().nonnegative(),
10943
+ patience: number().int().nonnegative(),
10944
+ seed: number().int()
10945
+ }),
10946
+ replay: object({
10947
+ source: literal("coco2017"),
10948
+ count: number().int().nonnegative()
10949
+ }),
10950
+ exports: array(TrainingExportSchema).min(1),
10951
+ calibration: object({ maxFrames: number().int().positive() }),
10952
+ floors: object({
10953
+ minSupport: number().int().positive(),
10954
+ clamp: number().min(0).max(1)
10955
+ }),
10956
+ int8Gate: object({ maxMap50Drop: number().min(0).max(1) }),
10957
+ catalog: object({
10958
+ id: string().regex(/^[a-z0-9][a-z0-9-]{2,80}$/),
10959
+ name: string().min(1).max(160)
10960
+ })
10961
+ });
10962
+ /** One regular file of the bundle. An mlpackage contributes one row per member. */
10963
+ var TrainingResultFileSchema = object({
10964
+ path: string().min(1),
10965
+ bytes: number().int().nonnegative(),
10966
+ sha256: string().regex(/^[0-9a-f]{64}$/),
10967
+ format: _enum([
10968
+ "onnx",
10969
+ "openvino",
10970
+ "coreml",
10971
+ "pt"
10972
+ ]),
10973
+ variant: _enum(["base", "int8"])
10974
+ });
10975
+ var DraftFormatSchema = object({
10976
+ /** RELATIVE path inside the bundle; the hub rewrites it to `camstack-local://`. */
10977
+ url: string().min(1),
10978
+ sizeMB: number().nonnegative(),
10979
+ isDirectory: boolean().optional(),
10980
+ files: array(string()).optional(),
10981
+ runtimes: array(literal("python")).optional(),
10982
+ revision: string().min(1)
10983
+ });
10984
+ /** The trainer's half of a catalog entry; the hub completes it (labels, licence, group). */
10985
+ var TrainingCatalogDraftSchema = object({
10986
+ id: string().min(1),
10987
+ name: string().min(1),
10988
+ description: string(),
10989
+ labels: array(unknown()),
10990
+ inputSize: object({
10991
+ width: number().int().positive(),
10992
+ height: number().int().positive()
10993
+ }),
10994
+ preprocessMode: literal("letterbox"),
10995
+ defaultClassFloors: FloorsSchema,
10996
+ formats: object({
10997
+ onnx: DraftFormatSchema.optional(),
10998
+ openvino: DraftFormatSchema.optional(),
10999
+ coreml: DraftFormatSchema.optional()
11000
+ })
11001
+ });
11002
+ /** One class of one model's holdout report (the eval harness's summary). */
11003
+ var TrainingEvalClassSchema = object({
11004
+ positives: number().int(),
11005
+ floor: number().nullable(),
11006
+ tp: number().int(),
11007
+ fp: number().int(),
11008
+ fn: number().int(),
11009
+ precision: number().nullable(),
11010
+ recall: number().nullable(),
11011
+ ap50: number().nullable(),
11012
+ recallByCamera: record(string(), number().nullable()).optional(),
11013
+ recallByLight: record(string(), number().nullable()).optional(),
11014
+ fpByCamera: record(string(), number()).optional(),
11015
+ smallFound: number().int().optional(),
11016
+ smallTotal: number().int().optional()
11017
+ }).passthrough();
11018
+ var TrainingEvalReportSchema = object({
11019
+ frames: number().int(),
11020
+ classes: record(string(), TrainingEvalClassSchema)
11021
+ }).passthrough();
11022
+ /**
11023
+ * A succeeded result carries every block; a failed one carries the error and
11024
+ * whatever was known by then — the other blocks are ABSENT, not null. The
11025
+ * orchestrator checks the blocks it needs before it trusts a success.
11026
+ */
11027
+ var TrainingResultSchema = object({
11028
+ schema: literal(TRAINING_RESULT_SCHEMA),
11029
+ jobKey: string(),
11030
+ status: _enum(["succeeded", "failed"]),
11031
+ error: object({
11032
+ stage: string(),
11033
+ code: string(),
11034
+ message: string()
11035
+ }).nullable(),
11036
+ trainer: object({
11037
+ version: string(),
11038
+ revision: string()
11039
+ }),
11040
+ toolchain: record(string(), string().nullable()),
11041
+ dataset: object({
11042
+ versionId: string(),
11043
+ annotationHash: string(),
11044
+ sha256: string(),
11045
+ frames: object({
11046
+ train: number().int(),
11047
+ val: number().int(),
11048
+ holdout: number().int()
11049
+ }),
11050
+ holdoutCameras: array(number().int()),
11051
+ replayImages: number().int()
11052
+ }).optional(),
11053
+ training: object({
11054
+ epochsRun: number().int(),
11055
+ bestEpoch: number().int(),
11056
+ bestMap50: number(),
11057
+ bestMap50_95: number(),
11058
+ seconds: number()
11059
+ }).optional(),
11060
+ evaluation: object({
11061
+ holdoutFrames: number().int(),
11062
+ baseline: TrainingEvalReportSchema.nullable(),
11063
+ candidate: TrainingEvalReportSchema.nullable(),
11064
+ candidateInt8: TrainingEvalReportSchema.nullable(),
11065
+ recallDeltaByCamera: record(string(), record(string(), number())).nullable(),
11066
+ map50: record(string(), number().nullable())
11067
+ }).optional(),
11068
+ floors: object({
11069
+ baseline: FloorsSchema,
11070
+ candidate: FloorsSchema,
11071
+ candidateInt8: FloorsSchema.nullable(),
11072
+ notes: array(string())
11073
+ }).optional(),
11074
+ int8: object({
11075
+ kept: boolean(),
11076
+ map50Fp16: number().nullable(),
11077
+ map50Int8: number().nullable(),
11078
+ reason: string().nullable()
11079
+ }).optional(),
11080
+ exportsDropped: array(object({
11081
+ export: string(),
11082
+ reason: string()
11083
+ })).optional(),
11084
+ files: array(TrainingResultFileSchema).optional(),
11085
+ bundle: object({
11086
+ path: literal("bundle.tar"),
11087
+ bytes: number().int().nonnegative(),
11088
+ sha256: string().regex(/^[0-9a-f]{64}$/)
11089
+ }).nullable().optional(),
11090
+ catalogDraft: object({
11091
+ base: TrainingCatalogDraftSchema,
11092
+ int8: TrainingCatalogDraftSchema.nullable()
11093
+ }).nullable().optional(),
11094
+ licence: string()
11095
+ });
11096
+ var TrainingStageSchema = _enum([
11097
+ "prepare",
11098
+ "replay",
11099
+ "train",
11100
+ "eval",
11101
+ "export",
11102
+ "package"
11103
+ ]);
11104
+ var EventBase = {
11105
+ v: literal(1),
11106
+ ts: number()
11107
+ };
11108
+ discriminatedUnion("type", [
11109
+ object({
11110
+ ...EventBase,
11111
+ type: literal("stage"),
11112
+ stage: TrainingStageSchema
11113
+ }),
11114
+ object({
11115
+ ...EventBase,
11116
+ type: literal("epoch"),
11117
+ epoch: number().int(),
11118
+ epochs: number().int(),
11119
+ boxLoss: number().nullable().optional(),
11120
+ map50: number().nullable().optional(),
11121
+ map50_95: number().nullable().optional(),
11122
+ etaSec: number().nullable().optional()
11123
+ }),
11124
+ object({
11125
+ ...EventBase,
11126
+ type: literal("metric"),
11127
+ name: string(),
11128
+ value: number()
11129
+ }),
11130
+ object({
11131
+ ...EventBase,
11132
+ type: literal("artifact"),
11133
+ path: string(),
11134
+ bytes: number(),
11135
+ sha256: string()
11136
+ }),
11137
+ object({
11138
+ ...EventBase,
11139
+ type: literal("done"),
11140
+ status: _enum(["succeeded", "failed"]),
11141
+ resultSha256: string().nullable().optional()
11142
+ }),
11143
+ object({
11144
+ ...EventBase,
11145
+ type: literal("error"),
11146
+ stage: string(),
11147
+ code: string(),
11148
+ message: string()
11149
+ })
11150
+ ]);
11151
+ /**
10457
11152
  * What the gate decided about a birth, from the CALLER's point of view.
10458
11153
  *
10459
11154
  * Deliberately not `ConfirmationVerdict`: `undecided` is not a birth decision
@@ -12781,7 +13476,9 @@ var AddonHttpRouteSchema = object({
12781
13476
  "authenticated",
12782
13477
  "admin"
12783
13478
  ]).optional(),
12784
- description: string().optional()
13479
+ description: string().optional(),
13480
+ /** The hub limits this route per client address before the handler runs. */
13481
+ rateLimit: _enum(["auth"]).optional()
12785
13482
  });
12786
13483
  /**
12787
13484
  * Cross-process route invocation envelope. The hub captures the
@@ -13505,6 +14202,37 @@ var BackupDestinationInfoSchema = object({
13505
14202
  lastError: string().optional()
13506
14203
  });
13507
14204
  /**
14205
+ * How an archive is encrypted (operator decision 2026-10-09): to a backup
14206
+ * PUBLIC key the hub holds, so only the operator's secret key opens it.
14207
+ * Absent on a plain `.tar.gz` — every archive made before encryption, or
14208
+ * with it off — which restores without a key.
14209
+ */
14210
+ var BackupArchiveEncryptionSchema = object({
14211
+ /** `x25519-hkdf-aes256gcm-stream-v1`. */
14212
+ scheme: string(),
14213
+ /** 16 hex — the backup key whose secret restores this archive. */
14214
+ keyId: string()
14215
+ });
14216
+ /**
14217
+ * The backup encryption setting. The hub keeps PUBLIC keys only: the active
14218
+ * one new archives are encrypted to, and the retired ones older archives
14219
+ * still need. The secret key is shown once, at `setupEncryption`.
14220
+ */
14221
+ var BackupEncryptionStatusSchema = object({
14222
+ enabled: boolean(),
14223
+ active: object({
14224
+ keyId: string(),
14225
+ publicKey: string(),
14226
+ createdAt: number()
14227
+ }).nullable(),
14228
+ /** Every key ever set up, newest first. */
14229
+ keys: array(object({
14230
+ keyId: string(),
14231
+ createdAt: number(),
14232
+ retiredAt: number().nullable()
14233
+ })).readonly()
14234
+ });
14235
+ /**
13508
14236
  * Per-archive entry returned by `backup.listArchives({ destinationId })`.
13509
14237
  * Same shape the destination drill-in renders. Sourced from the per-
13510
14238
  * location `manifests.json` (no per-archive tarball read required).
@@ -13516,7 +14244,9 @@ var BackupArchiveEntrySchema = object({
13516
14244
  sizeBytes: number(),
13517
14245
  label: string().optional(),
13518
14246
  /** Top-level locations included in the archive (db, addons, tls, …). */
13519
- locations: array(string()).readonly()
14247
+ locations: array(string()).readonly(),
14248
+ /** Present when the archive is encrypted; restore then needs that key. */
14249
+ encryption: BackupArchiveEncryptionSchema.optional()
13520
14250
  });
13521
14251
  var BackupEntrySchema = object({
13522
14252
  id: string(),
@@ -13525,7 +14255,8 @@ var BackupEntrySchema = object({
13525
14255
  label: string().optional(),
13526
14256
  createdAt: number(),
13527
14257
  sizeBytes: number(),
13528
- locations: array(string()).optional()
14258
+ locations: array(string()).optional(),
14259
+ encryption: BackupArchiveEncryptionSchema.optional()
13529
14260
  });
13530
14261
  var ArchiveEntrySchema = object({
13531
14262
  path: string(),
@@ -13714,10 +14445,40 @@ method(_void(), array(BackupDestinationInfoSchema).readonly(), { auth: "admin" }
13714
14445
  * this list and skips entries whose path doesn't start with
13715
14446
  * any of them.
13716
14447
  */
13717
- locations: array(string()).optional()
14448
+ locations: array(string()).optional(),
14449
+ /**
14450
+ * The backup SECRET key, for an encrypted archive (ignored for a plain
14451
+ * one). The archive is decrypted into the hub's private staging
14452
+ * before the restart; the key is not stored. A wrong or missing key
14453
+ * is refused before the archive is downloaded.
14454
+ */
14455
+ backupSecretKey: string().optional()
13718
14456
  }), _void(), {
13719
14457
  kind: "mutation",
13720
14458
  auth: "admin"
14459
+ }), method(_void(), BackupEncryptionStatusSchema, { auth: "admin" }), method(object({}), object({
14460
+ keyId: string(),
14461
+ secretKey: string(),
14462
+ publicKey: string(),
14463
+ createdAt: number(),
14464
+ replacedKeyId: string().nullable()
14465
+ }), {
14466
+ kind: "mutation",
14467
+ auth: "admin"
14468
+ }), method(object({}), object({ disabledKeyId: string().nullable() }), {
14469
+ kind: "mutation",
14470
+ auth: "admin"
14471
+ }), method(object({ backupSecretKey: string() }), object({
14472
+ valid: boolean(),
14473
+ keyId: string().nullable(),
14474
+ /** The hub knows this key (active or retired). */
14475
+ known: boolean(),
14476
+ /** It is the key new archives are encrypted to. */
14477
+ active: boolean(),
14478
+ error: string().optional()
14479
+ }), {
14480
+ kind: "mutation",
14481
+ auth: "admin"
13721
14482
  }), method(object({
13722
14483
  destinationId: string(),
13723
14484
  backupId: string()
@@ -15379,7 +16140,60 @@ var CustomModelDescriptorSchema = object({
15379
16140
  stepId: string(),
15380
16141
  entry: ModelCatalogEntrySchema
15381
16142
  });
15382
- method(_void(), array(CustomModelDescriptorSchema).readonly(), { auth: "admin" });
16143
+ /** One regular file of an imported bundle, as the producer measured it. */
16144
+ var ModelBundleFileSchema = object({
16145
+ /** Relative path inside the bundle tar; an mlpackage member is `<x>.mlpackage/<member>`. */
16146
+ path: string().min(1),
16147
+ bytes: number().int().nonnegative(),
16148
+ sha256: string().regex(/^[0-9a-f]{64}$/)
16149
+ });
16150
+ var ImportModelBundleInputSchema = object({
16151
+ /** The registry provider that keeps the model (Model Studio). */
16152
+ addonId: string(),
16153
+ stepId: string().min(1),
16154
+ /**
16155
+ * The catalog rows to register, complete, every format URL already
16156
+ * `camstack-local://<modelId>/<file>` naming a file of the bundle. One
16157
+ * bundle may carry several rows (a base and its INT8 variant).
16158
+ */
16159
+ entries: array(ModelCatalogEntrySchema).min(1).max(4),
16160
+ /** The bundle tar, offered by the producer over `ctx.peerBytes` (same host). */
16161
+ bundle: object({
16162
+ ticket: PeerBytesTicketSchema,
16163
+ bytes: number().int().positive(),
16164
+ sha256: string().regex(/^[0-9a-f]{64}$/)
16165
+ }),
16166
+ /** Every file the tar must hold; anything missing, extra or different is refused. */
16167
+ files: array(ModelBundleFileSchema).min(1).max(64),
16168
+ /** Convert missing engine formats and push the model to every agent afterwards. */
16169
+ distribute: boolean()
16170
+ });
16171
+ var ImportModelBundleResultSchema = discriminatedUnion("kind", [object({
16172
+ kind: literal("imported"),
16173
+ modelIds: array(string()).readonly(),
16174
+ distributed: array(object({
16175
+ modelId: string(),
16176
+ nodeId: string(),
16177
+ format: _enum(MODEL_FORMATS),
16178
+ ok: boolean(),
16179
+ error: string().optional()
16180
+ })).readonly()
16181
+ }), object({
16182
+ kind: literal("refused"),
16183
+ reason: _enum([
16184
+ "transfer-failed",
16185
+ "checksum-mismatch",
16186
+ "bundle-mismatch",
16187
+ "invalid-entry",
16188
+ "id-taken"
16189
+ ]),
16190
+ detail: string()
16191
+ })]);
16192
+ method(_void(), array(CustomModelDescriptorSchema).readonly(), { auth: "admin" }), method(ImportModelBundleInputSchema, ImportModelBundleResultSchema, {
16193
+ kind: "mutation",
16194
+ auth: "admin",
16195
+ timeoutMs: 30 * 6e4
16196
+ });
15383
16197
  /**
15384
16198
  * Query filter for settings-store collections.
15385
16199
  */
@@ -15858,6 +16672,35 @@ var KeychainKeySourceSchema = object({
15858
16672
  */
15859
16673
  sharesBackupWithDatabase: boolean()
15860
16674
  });
16675
+ /**
16676
+ * One keychain reset, as the Secrets page reports it until the operator
16677
+ * acknowledges it. Never a value: refs, counts and table names only.
16678
+ */
16679
+ var KeychainResetRecordSchema = object({
16680
+ id: string(),
16681
+ at: number(),
16682
+ /** `user:<id>` or {@link KEYCHAIN_RESET_TRIGGER_ACTOR}. */
16683
+ actor: string(),
16684
+ /** Why the keychain was locked when it was reset; `null` when it was not locked. */
16685
+ lockedReason: string().nullable(),
16686
+ /** Values moved into the archive table (ciphertext under the lost key). */
16687
+ archived: number().int(),
16688
+ /** `keychain:secrets-orphaned-<ts>`, or `null` when nothing was stored. */
16689
+ archivedCollection: string().nullable(),
16690
+ /**
16691
+ * `keychain:keys-orphaned-<ts>`: the wrapped data keys of the archive, kept
16692
+ * so the archive can still be opened if the lost master key turns up.
16693
+ */
16694
+ archivedKeysCollection: string().nullable(),
16695
+ /**
16696
+ * `system-settings` keys whose marker the reset cleared — the cluster
16697
+ * secret's: a marker left pointing at an archived value would refuse every
16698
+ * agent forever (D797).
16699
+ */
16700
+ clearedSettingsKeys: array(string()).readonly(),
16701
+ /** When an operator dismissed the notice on the Secrets page; `null` until then. */
16702
+ acknowledgedAt: number().nullable()
16703
+ });
15861
16704
  var KeychainStatusSchema = object({
15862
16705
  keychain: KeychainStateSchema,
15863
16706
  /** The source of the master key in use; `null` while locked. */
@@ -15875,7 +16718,9 @@ var KeychainStatusSchema = object({
15875
16718
  /** Wrapped copies of the data key under a previous master key, kept until purged. */
15876
16719
  retiredWraps: number().int(),
15877
16720
  recoveryKeyDownloadedAt: number().nullable(),
15878
- secretCount: number().int()
16721
+ secretCount: number().int(),
16722
+ /** The most recent reset, acknowledged or not; `null` when the keychain was never reset. */
16723
+ lastReset: KeychainResetRecordSchema.nullable()
15879
16724
  });
15880
16725
  /**
15881
16726
  * Whether a stored value is still pointed at by its owner's settings.
@@ -15897,17 +16742,26 @@ var KeychainAuditActionSchema = _enum([
15897
16742
  "download-recovery-key",
15898
16743
  "delete-orphans",
15899
16744
  "reset",
16745
+ "acknowledge-reset",
15900
16746
  "initialize"
15901
16747
  ]);
15902
16748
  var KeychainAuditEntrySchema = object({
15903
16749
  id: string(),
15904
16750
  at: number(),
15905
16751
  action: KeychainAuditActionSchema,
15906
- /** `addon:<id>` | `user:<id>` | `system`. */
16752
+ /** `addon:<id>` | `user:<id>` | `system` | `trigger-file`. */
15907
16753
  actor: string(),
15908
16754
  ref: string().nullable(),
15909
16755
  detail: string().nullable()
15910
16756
  });
16757
+ var KEYCHAIN_RESET_CONFIRMATION = "RESET KEYCHAIN";
16758
+ /**
16759
+ * Secrets the HUB itself holds (owner `system`) that no settings form shows:
16760
+ * `jwt-signing-key` — the session signing key (D797). It is always "in use",
16761
+ * never an orphan; it is generated on a fresh hub and replaced only through
16762
+ * {@link keychainAdminCapability.methods.setSystemSecret}.
16763
+ */
16764
+ var SystemHeldSecretNameSchema = _enum(["jwt-signing-key"]);
15911
16765
  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({
15912
16766
  value: string(),
15913
16767
  version: number().int()
@@ -15915,6 +16769,16 @@ method(object({}), KeychainStatusSchema, { auth: "admin" }), method(object({}),
15915
16769
  kind: "mutation",
15916
16770
  auth: "admin",
15917
16771
  caller: "required"
16772
+ }), method(object({
16773
+ name: SystemHeldSecretNameSchema,
16774
+ value: string().min(16)
16775
+ }), object({
16776
+ ref: string(),
16777
+ version: number().int()
16778
+ }), {
16779
+ kind: "mutation",
16780
+ auth: "admin",
16781
+ caller: "required"
15918
16782
  }), method(object({ refs: array(string().min(1)).max(1e3) }), object({
15919
16783
  deleted: array(string()).readonly(),
15920
16784
  kept: array(object({
@@ -15944,13 +16808,20 @@ method(object({}), KeychainStatusSchema, { auth: "admin" }), method(object({}),
15944
16808
  kind: "mutation",
15945
16809
  auth: "admin",
15946
16810
  caller: "required"
15947
- }), method(object({ confirm: literal("RESET KEYCHAIN") }), object({
16811
+ }), method(object({ confirm: literal(KEYCHAIN_RESET_CONFIRMATION) }), object({
15948
16812
  archivedCollection: string().nullable(),
15949
16813
  archived: number().int()
15950
16814
  }), {
15951
16815
  kind: "mutation",
15952
16816
  auth: "admin",
15953
16817
  caller: "required"
16818
+ }), method(object({}), object({
16819
+ reset: KeychainResetRecordSchema.nullable(),
16820
+ pendingReentry: array(KeychainSecretMetaSchema).readonly()
16821
+ }), { auth: "admin" }), method(object({}), object({ acknowledged: boolean() }), {
16822
+ kind: "mutation",
16823
+ auth: "admin",
16824
+ caller: "required"
15954
16825
  });
15955
16826
  method(_void(), object({
15956
16827
  id: string(),
@@ -18596,7 +19467,7 @@ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
18596
19467
  * `login-method` — collection cap through which auth addons contribute
18597
19468
  * their pre-auth login surfaces to the login page. This is the SINGLE,
18598
19469
  * generic mechanism that supersedes the dead `auth.listProviders` reader:
18599
- * every auth addon (OIDC, magic-link, WebAuthn/passkey) registers a
19470
+ * every auth addon (OIDC, WebAuthn/passkey) registers a
18600
19471
  * `login-method` provider and the PUBLIC `auth.listLoginMethods`
18601
19472
  * procedure aggregates them for the unauthenticated login page.
18602
19473
  *
@@ -18604,8 +19475,7 @@ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
18604
19475
  *
18605
19476
  * - `redirect` — a declarative button. The login page renders a generic
18606
19477
  * button that navigates to `startUrl` (an addon-owned HTTP route).
18607
- * Covers OIDC (`/addon/auth-oidc/<id>/start`) and magic-link with
18608
- * ZERO shell-side JS. A future SSO addon plugs in the same way — the
19478
+ * Covers OIDC (`/addon/auth-oidc/<id>/start`) with ZERO shell-side JS. A future SSO addon plugs in the same way — the
18609
19479
  * login page needs NO change.
18610
19480
  *
18611
19481
  * - `widget` — a Module-Federation widget the login page mounts (via
@@ -18624,8 +19494,8 @@ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
18624
19494
  * decision.
18625
19495
  *
18626
19496
  * Every contribution carries a `stage`:
18627
- * - `primary` — shown on the first credentials screen (OIDC /
18628
- * magic-link buttons; a future usernameless passkey).
19497
+ * - `primary` — shown on the first credentials screen (OIDC
19498
+ * buttons; a usernameless passkey).
18629
19499
  * - `second-factor` — shown AFTER the password leg, gated on the
18630
19500
  * returned `factors` (passkey-as-2FA today).
18631
19501
  *
@@ -18652,7 +19522,7 @@ var LoginMethodContributionSchema = discriminatedUnion("kind", [
18652
19522
  * The provider names an external identity a signed-in user can link to
18653
19523
  * their own account (D782): `auth.listLinkableProviders` /
18654
19524
  * `beginExternalLink` offer exactly the redirect methods that set this,
18655
- * whatever their id. Absent / false — a login button only (magic-link).
19525
+ * whatever their id. Absent / false — a login button only.
18656
19526
  */
18657
19527
  linkable: boolean().optional()
18658
19528
  }),
@@ -22469,8 +23339,7 @@ method(object({}), object({ rules: array(NcRuleSchema) }), { auth: "admin" }), m
22469
23339
  * `super_admin` — collapsed onto the single boolean because every
22470
23340
  * non-admin caller is governed by the same scope-check rules; the
22471
23341
  * distinction was only ever used to route role-specific procedures
22472
- * which we no longer have. Agents are admin sessions issued via
22473
- * `createServiceToken`; CLI / webhook integrations are `cst_*` tokens
23342
+ * which we no longer have. CLI / webhook integrations are `cst_*` tokens
22474
23343
  * with `isAdmin: false` + an explicit scope list.
22475
23344
  */
22476
23345
  /** Per-method access flavour. Materialised on every cap method via codegen. */
@@ -24195,6 +25064,9 @@ var RetrainExportFilterSchema = object({
24195
25064
  frameIds: array(string()).max(2e4).optional(),
24196
25065
  /** Only frames in at least one of these named collections. */
24197
25066
  collectionIds: array(string()).max(200).optional(),
25067
+ /** Exactly the frames of this dataset version (and its completeOnly). An
25068
+ * unknown id selects nothing. */
25069
+ datasetVersionId: string().optional(),
24198
25070
  batchId: string().optional(),
24199
25071
  /** Only frames the operator marked complete (all subjects boxed). */
24200
25072
  completeOnly: boolean().optional()
@@ -24362,6 +25234,67 @@ var RetrainLlmAssistResultSchema = discriminatedUnion("kind", [object({
24362
25234
  ]),
24363
25235
  detail: string().optional()
24364
25236
  })]);
25237
+ /** What a dataset version is cut from. Every field narrows. */
25238
+ var RetrainDatasetSelectionSchema = object({
25239
+ deviceIds: array(number()).readonly().optional(),
25240
+ collectionIds: array(string()).max(200).readonly().optional(),
25241
+ frameIds: array(string()).max(2e4).readonly().optional()
25242
+ });
25243
+ /** The counts a dataset is judged by. */
25244
+ var RetrainDatasetStatsSchema = object({
25245
+ frames: number().int(),
25246
+ completeFrames: number().int(),
25247
+ /** `completeFrames / frames`, 0..1. */
25248
+ completeness: number(),
25249
+ /** Boxes to learn (model errors excluded). */
25250
+ subjects: number().int(),
25251
+ modelErrors: number().int(),
25252
+ /** Complete frames with no subject. */
25253
+ hardNegatives: number().int(),
25254
+ /** Subjects per class × camera × day/night. */
25255
+ cells: array(object({
25256
+ macroClass: string(),
25257
+ deviceId: number(),
25258
+ lighting: _enum([
25259
+ "day",
25260
+ "night",
25261
+ "unknown"
25262
+ ]),
25263
+ subjects: number().int(),
25264
+ frames: number().int()
25265
+ })).readonly(),
25266
+ cameras: array(object({
25267
+ deviceId: number(),
25268
+ frames: number().int(),
25269
+ completeFrames: number().int()
25270
+ })).readonly()
25271
+ });
25272
+ /** An immutable dataset version, without its frame list. */
25273
+ var RetrainDatasetVersionSchema = object({
25274
+ id: string(),
25275
+ name: string(),
25276
+ createdAt: number(),
25277
+ selection: RetrainDatasetSelectionSchema,
25278
+ layout: RetrainExportLayoutSchema,
25279
+ completeOnly: boolean(),
25280
+ frameCount: number().int(),
25281
+ /** sha256 of what the frames taught when the version was frozen. */
25282
+ annotationHash: string(),
25283
+ /** The export manifest schema the version was cut under. */
25284
+ manifestSchema: string(),
25285
+ stats: RetrainDatasetStatsSchema
25286
+ });
25287
+ var CreateRetrainDatasetVersionResultSchema = discriminatedUnion("kind", [object({
25288
+ kind: literal("created"),
25289
+ version: RetrainDatasetVersionSchema
25290
+ }), object({
25291
+ kind: literal("refused"),
25292
+ reason: _enum([
25293
+ "empty-name",
25294
+ "duplicate-name",
25295
+ "no-frames"
25296
+ ])
25297
+ })]);
24365
25298
  /** The outcome of a lifecycle move owned by the retrain page. */
24366
25299
  var RetrainTransitionResultSchema = object({
24367
25300
  trackId: string(),
@@ -25151,6 +26084,47 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
25151
26084
  kind: "mutation",
25152
26085
  auth: "admin",
25153
26086
  timeoutMs: 60 * 6e4
26087
+ }), method(object({
26088
+ filter: RetrainExportFilterSchema,
26089
+ layout: RetrainExportLayoutSchema
26090
+ }), object({
26091
+ ticket: PeerBytesTicketSchema,
26092
+ frames: number().int(),
26093
+ annotations: number().int()
26094
+ }), {
26095
+ kind: "mutation",
26096
+ auth: "admin",
26097
+ timeoutMs: 12e4
26098
+ }), method(object({
26099
+ selection: RetrainDatasetSelectionSchema,
26100
+ completeOnly: boolean().optional()
26101
+ }), RetrainDatasetStatsSchema, {
26102
+ kind: "query",
26103
+ auth: "admin"
26104
+ }), method(object({
26105
+ name: string().max(120),
26106
+ selection: RetrainDatasetSelectionSchema,
26107
+ layout: RetrainExportLayoutSchema,
26108
+ completeOnly: boolean()
26109
+ }), CreateRetrainDatasetVersionResultSchema, {
26110
+ kind: "mutation",
26111
+ auth: "admin",
26112
+ timeoutMs: 12e4
26113
+ }), method(object({}), array(RetrainDatasetVersionSchema).readonly(), {
26114
+ kind: "query",
26115
+ auth: "admin"
26116
+ }), method(object({ id: string() }), object({ deleted: boolean() }), {
26117
+ kind: "mutation",
26118
+ auth: "admin"
26119
+ }), method(object({ id: string() }), object({
26120
+ found: boolean(),
26121
+ annotationHash: string(),
26122
+ matches: boolean(),
26123
+ missingFrames: number().int()
26124
+ }), {
26125
+ kind: "query",
26126
+ auth: "admin",
26127
+ timeoutMs: 12e4
25154
26128
  }), method(object({}), array(RetrainAssistProfileSchema).readonly(), {
25155
26129
  kind: "query",
25156
26130
  auth: "admin"
@@ -29583,8 +30557,8 @@ version: string().optional() }), ServerUpdateActionResultSchema, {
29583
30557
  * `smtp-provider` — pluggable email delivery surface.
29584
30558
  *
29585
30559
  * Collection cap: a deployment may install multiple SMTP relays (e.g.
29586
- * one for transactional / one for notifications). Consumers (magic-link,
29587
- * notifier addons, …) walk the collection and pick the first
30560
+ * one for transactional / one for notifications). Consumers (notifier
30561
+ * addons, …) walk the collection and pick the first
29588
30562
  * ready provider OR target a specific addonId.
29589
30563
  *
29590
30564
  * The shape stays small on purpose — `sendEmail` is enough for the
@@ -29763,7 +30737,7 @@ targets: array(object({
29763
30737
  })));
29764
30738
  /**
29765
30739
  * `sso-bridge` — internal hub-only cap that lets SSO-style auth
29766
- * providers (OIDC, SAML, magic-link, …) mint an HMAC-signed token
30740
+ * providers (OIDC, SAML, …) mint an HMAC-signed token
29767
30741
  * carrying the post-callback claims before redirecting back to
29768
30742
  * `/api/auth/sso/finish`.
29769
30743
  *
@@ -29826,7 +30800,14 @@ var SsoBridgeClaimsSchema = object({
29826
30800
  * Verified `iss` of the id_token behind an OIDC login bridge (D782). A
29827
30801
  * subject is unique only per issuer, so a link is bound to it.
29828
30802
  */
29829
- issuer: string().optional()
30803
+ issuer: string().optional(),
30804
+ /**
30805
+ * SHA-256 (hex) of the `camstack_sso_state` cookie the IdP `/start` set in
30806
+ * the browser that began this sign-in. `/api/auth/sso/finish` requires the
30807
+ * request to present the matching cookie — a login bridge is useless in
30808
+ * any other browser.
30809
+ */
30810
+ browserBinding: string().optional()
29830
30811
  });
29831
30812
  method(object({
29832
30813
  claims: SsoBridgeClaimsSchema,
@@ -39801,16 +40782,6 @@ var ApiKeySummarySchema = object({
39801
40782
  createdAt: number(),
39802
40783
  lastUsedAt: number().optional()
39803
40784
  });
39804
- var CreateApiKeyInputSchema = object({
39805
- label: string(),
39806
- isAdmin: boolean().default(false),
39807
- allowedProviders: union([array(string()), literal("*")]).optional(),
39808
- allowedDevices: record(string(), union([array(string()), literal("*")])).optional()
39809
- });
39810
- var CreateApiKeyResultSchema = object({
39811
- token: string(),
39812
- record: ApiKeySummarySchema
39813
- });
39814
40785
  var ScopedTokenSummarySchema = object({
39815
40786
  id: string(),
39816
40787
  userId: string(),
@@ -39909,17 +40880,10 @@ method(_void(), array(UserSummarySchema), { auth: "admin" }), method(CreateUserI
39909
40880
  }), UserSummarySchema.extend({ passwordHash: string() }).nullable(), {
39910
40881
  kind: "mutation",
39911
40882
  access: "view"
39912
- }), method(_void(), array(ApiKeySummarySchema), { auth: "admin" }), method(CreateApiKeyInputSchema, CreateApiKeyResultSchema, {
39913
- kind: "mutation",
39914
- auth: "admin",
39915
- access: "create"
39916
- }), method(object({ id: string() }), object({ success: literal(true) }), {
40883
+ }), method(_void(), array(ApiKeySummarySchema), { auth: "admin" }), method(object({ id: string() }), object({ success: literal(true) }), {
39917
40884
  kind: "mutation",
39918
40885
  auth: "admin",
39919
40886
  access: "delete"
39920
- }), method(object({ token: string() }), ApiKeySummarySchema.nullable(), {
39921
- kind: "mutation",
39922
- access: "view"
39923
40887
  }), method(CreateScopedTokenInputSchema, CreateScopedTokenResultSchema, {
39924
40888
  kind: "mutation",
39925
40889
  auth: "admin",
@@ -39993,15 +40957,7 @@ method(_void(), array(UserSummarySchema), { auth: "admin" }), method(CreateUserI
39993
40957
  }).nullable(), { access: "view" }), method(object({ userId: string() }), array(ExternalIdentitySchema), { auth: "admin" }), method(ExternalIdentityKeySchema, object({
39994
40958
  userId: string(),
39995
40959
  issuer: string()
39996
- }).nullable(), { auth: "admin" }), method(ExternalIdentityKeySchema.extend({
39997
- userId: string(),
39998
- issuer: string().min(1),
39999
- label: string().optional()
40000
- }), object({ success: literal(true) }), {
40001
- kind: "mutation",
40002
- auth: "admin",
40003
- access: "create"
40004
- }), method(ExternalIdentityKeySchema.extend({ userId: string() }), object({ success: boolean() }), {
40960
+ }).nullable(), { auth: "admin" }), method(ExternalIdentityKeySchema.extend({ userId: string() }), object({ success: boolean() }), {
40005
40961
  kind: "mutation",
40006
40962
  auth: "admin",
40007
40963
  access: "delete"
@@ -40452,6 +41408,451 @@ var zoneRulesCapability = {
40452
41408
  */
40453
41409
  durability: "restored"
40454
41410
  };
41411
+ /**
41412
+ * `training-provider` — ONE cloud that can run the CamStack trainer.
41413
+ *
41414
+ * A thin, mockable translation layer: it knows how to run a container with a
41415
+ * GPU, move a dataset in, read the job's stdout and hand artefacts back. It
41416
+ * knows nothing about datasets, splits, floors, cost policy or Model Studio —
41417
+ * those are the `training` orchestrator's (D805). Every rule written there
41418
+ * once is what makes a second provider (RunPod, a local NVIDIA node) a new
41419
+ * manifest entry and nothing else.
41420
+ *
41421
+ * Collection, routed by the `addonId` in every single-row input (the `llm` /
41422
+ * `notification-output` posture); `describe` concat-fans across providers.
41423
+ * Every method is `admin`: these spend money.
41424
+ *
41425
+ * Every cloud object a provider creates is tagged with the orchestrator's
41426
+ * `jobKey`, so a retried submit finds the job it already started instead of
41427
+ * starting a second GPU, and `listJobs` can find orphans.
41428
+ *
41429
+ * Bytes never ride a cap field: the dataset arrives as a `ctx.peerBytes`
41430
+ * ticket the producer (pipeline-analytics) minted, and artefacts leave as a
41431
+ * ticket the provider mints (D613).
41432
+ */
41433
+ var TrainingGpuOptionSchema = object({
41434
+ id: string(),
41435
+ label: string(),
41436
+ /** List price, USD per GPU-hour, before any region multiplier. */
41437
+ usdPerHour: number().nonnegative(),
41438
+ vramGb: number().nonnegative()
41439
+ });
41440
+ var TrainingRegionOptionSchema = object({
41441
+ /** `''` = any region (the provider's choice). */
41442
+ id: string(),
41443
+ label: string(),
41444
+ priceMultiplier: number().positive()
41445
+ });
41446
+ /**
41447
+ * The provider's per-account settings, as the orchestrator reads them. They
41448
+ * live in the PROVIDER addon's settings (operator decision 2026-10-08: they
41449
+ * depend on the user's account), never hard-coded in the orchestrator.
41450
+ */
41451
+ var TrainingProviderDefaultsSchema = object({
41452
+ gpuType: string(),
41453
+ region: string(),
41454
+ costCapUsd: number().nonnegative(),
41455
+ maxRuntimeSec: number().int().positive(),
41456
+ /** Hours a FAILED job's cloud dataset is kept for debugging; 0 = delete at once. */
41457
+ failedDatasetGraceHours: number().nonnegative()
41458
+ });
41459
+ var TrainingProviderDescriptorSchema = object({
41460
+ addonId: string(),
41461
+ /** `modal`, `runpod`, `fake`, … */
41462
+ kind: string(),
41463
+ label: string(),
41464
+ gpuTypes: array(TrainingGpuOptionSchema).readonly(),
41465
+ regions: array(TrainingRegionOptionSchema).readonly(),
41466
+ maxDatasetBytes: number().int().positive(),
41467
+ maxRuntimeSec: number().int().positive(),
41468
+ freeTierNote: string().optional(),
41469
+ /** Where the data goes, in one sentence the confirm dialog repeats. */
41470
+ dataResidencyNote: string(),
41471
+ /** Credentials are present — never the values. */
41472
+ configured: boolean(),
41473
+ defaults: TrainingProviderDefaultsSchema
41474
+ });
41475
+ var TrainingCredentialCheckSchema = object({
41476
+ ok: boolean(),
41477
+ /** Workspace / account name, when the provider says. */
41478
+ account: string().optional(),
41479
+ reason: _enum([
41480
+ "missing",
41481
+ "invalid",
41482
+ "forbidden",
41483
+ "network",
41484
+ "quota"
41485
+ ]).optional(),
41486
+ detail: string().optional()
41487
+ });
41488
+ var ProviderJobStateSchema = _enum([
41489
+ "pending",
41490
+ "starting",
41491
+ "running",
41492
+ "succeeded",
41493
+ "failed",
41494
+ "cancelled",
41495
+ "lost"
41496
+ ]);
41497
+ var ProviderJobStatusSchema = object({
41498
+ jobKey: string(),
41499
+ providerJobId: string().optional(),
41500
+ state: ProviderJobStateSchema,
41501
+ startedAt: number().optional(),
41502
+ endedAt: number().optional(),
41503
+ exitCode: number().int().optional(),
41504
+ failureReason: string().optional(),
41505
+ gpuType: string(),
41506
+ region: string().optional(),
41507
+ billedSeconds: number().nonnegative(),
41508
+ costUsd: number().nonnegative(),
41509
+ /** True when `costUsd` is runtime × list price, not a billing answer. */
41510
+ costIsEstimate: boolean(),
41511
+ lastFetchedAt: number()
41512
+ });
41513
+ /**
41514
+ * The trainer the job runs, by SOURCE revision: the provider turns it into an
41515
+ * image its own way (Modal builds the published Dockerfile at that revision;
41516
+ * a registry-pull provider maps it to a tag). Recorded on the job and echoed
41517
+ * in `result.json`.
41518
+ */
41519
+ var TrainerSourceRefSchema = object({
41520
+ /** Hugging Face repo id, e.g. `camstack/camstack-trainer`. */
41521
+ repo: string().min(1),
41522
+ /** A commit sha (never a branch) — the job must be reproducible. */
41523
+ revision: string().regex(/^[0-9a-f]{7,64}$/)
41524
+ });
41525
+ var JobRef = {
41526
+ addonId: string(),
41527
+ jobKey: string().uuid()
41528
+ };
41529
+ var TrainingLogLineSchema = object({
41530
+ ts: number(),
41531
+ text: string()
41532
+ });
41533
+ method(object({}), array(TrainingProviderDescriptorSchema).readonly(), { auth: "admin" }), method(object({ addonId: string() }), TrainingCredentialCheckSchema, {
41534
+ kind: "mutation",
41535
+ auth: "admin",
41536
+ timeoutMs: 3e4
41537
+ }), method(object({
41538
+ addonId: string(),
41539
+ gpuType: string(),
41540
+ region: string(),
41541
+ datasetBytes: number().int().nonnegative(),
41542
+ gpuSecondsLow: number().nonnegative(),
41543
+ gpuSecondsHigh: number().nonnegative()
41544
+ }), object({
41545
+ usdLow: number().nonnegative(),
41546
+ usdHigh: number().nonnegative(),
41547
+ notes: array(string()).readonly()
41548
+ }), { auth: "admin" }), method(object({
41549
+ ...JobRef,
41550
+ ticket: PeerBytesTicketSchema
41551
+ }), object({
41552
+ bytes: number().int().nonnegative(),
41553
+ sha256: string()
41554
+ }), {
41555
+ kind: "mutation",
41556
+ auth: "admin",
41557
+ timeoutMs: 120 * 6e4
41558
+ }), method(object({
41559
+ ...JobRef,
41560
+ trainer: TrainerSourceRefSchema,
41561
+ jobSpecJson: string().min(2).max(64e3),
41562
+ gpuType: string(),
41563
+ region: string(),
41564
+ maxRuntimeSec: number().int().positive()
41565
+ }), ProviderJobStatusSchema, {
41566
+ kind: "mutation",
41567
+ auth: "admin",
41568
+ timeoutMs: 30 * 6e4
41569
+ }), method(object(JobRef), ProviderJobStatusSchema, {
41570
+ auth: "admin",
41571
+ timeoutMs: 6e4
41572
+ }), method(object({
41573
+ ...JobRef,
41574
+ cursor: string().optional(),
41575
+ max: number().int().min(1).max(500)
41576
+ }), object({
41577
+ lines: array(TrainingLogLineSchema).readonly(),
41578
+ cursor: string()
41579
+ }), {
41580
+ auth: "admin",
41581
+ timeoutMs: 6e4
41582
+ }), method(object(JobRef), object({ ok: literal(true) }), {
41583
+ kind: "mutation",
41584
+ auth: "admin",
41585
+ timeoutMs: 6e4
41586
+ }), method(object(JobRef), object({
41587
+ found: boolean(),
41588
+ text: string().optional()
41589
+ }), {
41590
+ kind: "mutation",
41591
+ auth: "admin",
41592
+ timeoutMs: 5 * 6e4
41593
+ }), method(object({
41594
+ ...JobRef,
41595
+ path: _enum(["bundle.tar"])
41596
+ }), object({ ticket: PeerBytesTicketSchema }), {
41597
+ kind: "mutation",
41598
+ auth: "admin",
41599
+ timeoutMs: 5 * 6e4
41600
+ }), method(object(JobRef), object({ deleted: array(string()).readonly() }), {
41601
+ kind: "mutation",
41602
+ auth: "admin",
41603
+ timeoutMs: 5 * 6e4
41604
+ }), method(object({ addonId: string() }), array(ProviderJobStatusSchema).readonly(), {
41605
+ auth: "admin",
41606
+ timeoutMs: 2 * 6e4
41607
+ });
41608
+ /**
41609
+ * `training` — the cloud-training orchestrator (D805). Hub-only singleton,
41610
+ * provided by `addon-training`.
41611
+ *
41612
+ * It owns what every provider must agree on, written once:
41613
+ *
41614
+ * - **Dataset versions.** Taken over from pipeline-analytics (D796): the rows
41615
+ * live here (D808); pipeline-analytics still CUTS a version (it owns the corpus and
41616
+ * the export plan) and reaches this store through the five row methods
41617
+ * below, so the Retrain page and the export did not change.
41618
+ * - **Jobs.** A persisted state machine, a reconcile loop against the
41619
+ * provider, a cost guard, a daily orphan sweep and the retention rules.
41620
+ * - **The return flow.** Verified artefacts → Model Studio
41621
+ * (`custom-model-registry.importModelBundle`) → canary on cameras →
41622
+ * rollback. Nothing is ever registered automatically.
41623
+ *
41624
+ * Every method is `admin`.
41625
+ */
41626
+ /** A version WITH its frame list — what the export and a job read. */
41627
+ var TrainingDatasetVersionRowSchema = RetrainDatasetVersionSchema.omit({ frameCount: true }).extend({ frameIds: array(string()).max(2e4).readonly() });
41628
+ /** A base model a detector job can fine-tune, and the baseline it is judged against. */
41629
+ var TrainingBaseModelSchema = object({
41630
+ modelId: string(),
41631
+ label: string(),
41632
+ weights: string(),
41633
+ imgsz: number().int(),
41634
+ baselineOnnxUrl: string(),
41635
+ baselineFloors: record(string(), number()),
41636
+ /** The base the fleet runs most — the UI's default. */
41637
+ recommended: boolean()
41638
+ });
41639
+ var TrainingPresetSchema = _enum([
41640
+ "quick",
41641
+ "standard",
41642
+ "thorough"
41643
+ ]);
41644
+ var TrainingJobRequestSchema = object({
41645
+ datasetVersionId: string().min(1),
41646
+ /** The `training-provider` addon that runs it. */
41647
+ addonId: string().min(1),
41648
+ gpuType: string().min(1),
41649
+ region: string(),
41650
+ baseModelId: string().min(1),
41651
+ preset: TrainingPresetSchema,
41652
+ /** Freeze the backbone's first N layers; `null` = the preset's choice. */
41653
+ freeze: number().int().nonnegative().nullable(),
41654
+ /** Cameras held out whole for evaluation; `null` = the orchestrator's default. */
41655
+ holdoutCameras: array(number().int()).nullable()
41656
+ });
41657
+ var TrainingSplitPlanSchema = object({
41658
+ holdoutCameras: array(number().int()).readonly(),
41659
+ /** Used when no camera is held out: the last N days of every camera. */
41660
+ holdoutLastDays: number().int().nonnegative(),
41661
+ /** Holdout subjects per class (camera holdout only; `null` = known only after the split). */
41662
+ holdoutSupport: record(string(), number().int()).nullable(),
41663
+ trainSubjects: number().int()
41664
+ });
41665
+ var TrainingRefusalReasonSchema = _enum([
41666
+ "unknown-dataset",
41667
+ "unknown-provider",
41668
+ "provider-not-configured",
41669
+ "unknown-base-model",
41670
+ "unknown-gpu",
41671
+ "dataset-too-large",
41672
+ "no-training-subjects",
41673
+ "job-already-running"
41674
+ ]);
41675
+ var TrainingJobPlanSchema = object({
41676
+ refusal: object({
41677
+ reason: TrainingRefusalReasonSchema,
41678
+ detail: string()
41679
+ }).nullable(),
41680
+ warnings: array(string()).readonly(),
41681
+ split: TrainingSplitPlanSchema.nullable(),
41682
+ estimate: object({
41683
+ datasetBytes: number().int(),
41684
+ uploadMinutesAt20Mbps: number(),
41685
+ gpuSecondsLow: number(),
41686
+ gpuSecondsHigh: number(),
41687
+ usdLow: number(),
41688
+ usdHigh: number(),
41689
+ notes: array(string()).readonly()
41690
+ }).nullable(),
41691
+ /** Pre-filled from the provider's settings; the operator may lower or raise them. */
41692
+ defaults: object({
41693
+ maxCostUsd: number(),
41694
+ maxRuntimeSec: number().int()
41695
+ }).nullable(),
41696
+ /** The sentence the confirm dialog repeats: where the frames go and when they are deleted. */
41697
+ dataNotice: string()
41698
+ });
41699
+ /**
41700
+ * Orchestrator-owned states, persisted. `uploading` covers exporting the
41701
+ * archive (it is streamed, never staged). Terminal: `failed`, `cancelled`,
41702
+ * `lost`, `expired`, `discarded`. `registered` and `canary` are where a
41703
+ * result lives after the operator acted on it.
41704
+ */
41705
+ var TrainingJobStateSchema = _enum([
41706
+ "uploading",
41707
+ "submitted",
41708
+ "starting",
41709
+ "running",
41710
+ "collecting",
41711
+ "ready",
41712
+ "registered",
41713
+ "canary",
41714
+ "failed",
41715
+ "cancelling",
41716
+ "cancelled",
41717
+ "lost",
41718
+ "expired",
41719
+ "discarded"
41720
+ ]);
41721
+ var TrainingFailureReasonSchema = _enum([
41722
+ "cost-cap",
41723
+ "runtime-cap",
41724
+ "upload-failed",
41725
+ "submit-failed",
41726
+ "trainer-failed",
41727
+ "result-invalid",
41728
+ "checksum-mismatch",
41729
+ "fetch-failed",
41730
+ "provider-error",
41731
+ "hub-restart-during-upload"
41732
+ ]);
41733
+ var TrainingProgressPointSchema = object({
41734
+ epoch: number().int(),
41735
+ map50: number().nullable(),
41736
+ map50_95: number().nullable()
41737
+ });
41738
+ var TrainingCanarySchema = object({
41739
+ deviceIds: array(number().int()).readonly(),
41740
+ since: number(),
41741
+ /** Every override the canary replaced, exactly, so rollback restores it. */
41742
+ previous: array(object({
41743
+ deviceId: number().int(),
41744
+ nodeId: string(),
41745
+ deviceKey: string(),
41746
+ patch: object({
41747
+ modelId: string().optional(),
41748
+ settings: record(string(), unknown()).readonly().optional()
41749
+ }).nullable()
41750
+ })).readonly()
41751
+ });
41752
+ var TrainingJobSchema = object({
41753
+ id: string(),
41754
+ idempotencyKey: string(),
41755
+ name: string(),
41756
+ createdAt: number(),
41757
+ updatedAt: number(),
41758
+ state: TrainingJobStateSchema,
41759
+ stage: TrainingStageSchema.nullable(),
41760
+ failure: object({
41761
+ reason: TrainingFailureReasonSchema,
41762
+ stage: string().nullable(),
41763
+ detail: string()
41764
+ }).nullable(),
41765
+ request: TrainingJobRequestSchema,
41766
+ maxCostUsd: number().nonnegative(),
41767
+ maxRuntimeSec: number().int().positive(),
41768
+ trainer: TrainerSourceRefSchema,
41769
+ datasetLayout: RetrainExportLayoutSchema,
41770
+ dataset: object({
41771
+ bytes: number().int(),
41772
+ sha256: string(),
41773
+ uploadedAt: number()
41774
+ }).nullable(),
41775
+ split: TrainingSplitPlanSchema,
41776
+ provider: object({
41777
+ state: ProviderJobStateSchema.nullable(),
41778
+ providerJobId: string().nullable(),
41779
+ startedAt: number().nullable(),
41780
+ endedAt: number().nullable(),
41781
+ billedSeconds: number(),
41782
+ costUsd: number(),
41783
+ costIsEstimate: boolean(),
41784
+ lastPolledAt: number().nullable()
41785
+ }),
41786
+ progress: object({
41787
+ epoch: number().int().nullable(),
41788
+ epochs: number().int().nullable(),
41789
+ etaSec: number().nullable(),
41790
+ series: array(TrainingProgressPointSchema).readonly()
41791
+ }),
41792
+ /** The last lines of the job's output (≤ 200), newest last. Never frame paths. */
41793
+ logTail: array(string()).readonly(),
41794
+ logCursor: string().nullable(),
41795
+ artifacts: object({
41796
+ bundleBytes: number().int(),
41797
+ bundleSha256: string(),
41798
+ fetchedAt: number(),
41799
+ /** When the staged artefacts are deleted from the hub. */
41800
+ expiresAt: number()
41801
+ }).nullable(),
41802
+ /** When the provider-side copy of the frames was deleted; null while it exists. */
41803
+ cloudDatasetDeletedAt: number().nullable(),
41804
+ /** A failed job's dataset is kept until then (the provider's grace), then deleted. */
41805
+ cloudCleanupDueAt: number().nullable(),
41806
+ /** Model ids registered from this job (base, and int8 when kept). */
41807
+ registeredModelIds: array(string()).readonly(),
41808
+ canary: TrainingCanarySchema.nullable()
41809
+ });
41810
+ var IdInput = object({ id: string().min(1) });
41811
+ method(TrainingDatasetVersionRowSchema, object({ stored: boolean() }), {
41812
+ kind: "mutation",
41813
+ auth: "admin"
41814
+ }), 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() }), {
41815
+ kind: "mutation",
41816
+ auth: "admin"
41817
+ }), method(object({}), array(TrainingBaseModelSchema).readonly(), { auth: "admin" }), method(TrainingJobRequestSchema, TrainingJobPlanSchema, {
41818
+ auth: "admin",
41819
+ timeoutMs: 6e4
41820
+ }), method(TrainingJobRequestSchema.extend({
41821
+ name: string().min(1).max(120),
41822
+ maxCostUsd: number().positive(),
41823
+ maxRuntimeSec: number().int().positive(),
41824
+ idempotencyKey: string().min(8).max(80)
41825
+ }), discriminatedUnion("kind", [object({
41826
+ kind: literal("started"),
41827
+ job: TrainingJobSchema
41828
+ }), object({
41829
+ kind: literal("refused"),
41830
+ reason: TrainingRefusalReasonSchema,
41831
+ detail: string()
41832
+ })]), {
41833
+ kind: "mutation",
41834
+ auth: "admin",
41835
+ timeoutMs: 12e4
41836
+ }), method(object({}), array(TrainingJobSchema).readonly(), { auth: "admin" }), method(IdInput, TrainingJobSchema.nullable(), { auth: "admin" }), method(IdInput, TrainingJobSchema, {
41837
+ kind: "mutation",
41838
+ auth: "admin",
41839
+ timeoutMs: 12e4
41840
+ }), method(IdInput, TrainingResultSchema.nullable(), { auth: "admin" }), method(IdInput.extend({ canaryDeviceIds: array(number().int()).readonly() }), TrainingJobSchema, {
41841
+ kind: "mutation",
41842
+ auth: "admin",
41843
+ timeoutMs: 30 * 6e4
41844
+ }), method(IdInput.extend({ deviceIds: array(number().int()).min(1).readonly() }), TrainingJobSchema, {
41845
+ kind: "mutation",
41846
+ auth: "admin",
41847
+ timeoutMs: 12e4
41848
+ }), method(IdInput, TrainingJobSchema, {
41849
+ kind: "mutation",
41850
+ auth: "admin",
41851
+ timeoutMs: 12e4
41852
+ }), method(IdInput, TrainingJobSchema, {
41853
+ kind: "mutation",
41854
+ auth: "admin"
41855
+ });
40455
41856
  SOURCE_CAPS.filter((cap) => cap !== "switch" && cap !== "motion");
40456
41857
  Object.freeze({
40457
41858
  person: .5,
@@ -41075,6 +42476,12 @@ Object.freeze({
41075
42476
  addonId: null,
41076
42477
  access: "create"
41077
42478
  },
42479
+ "backup.checkBackupKey": {
42480
+ capName: "backup",
42481
+ capScope: "system",
42482
+ addonId: null,
42483
+ access: "create"
42484
+ },
41078
42485
  "backup.delete": {
41079
42486
  capName: "backup",
41080
42487
  capScope: "system",
@@ -41087,6 +42494,18 @@ Object.freeze({
41087
42494
  addonId: null,
41088
42495
  access: "delete"
41089
42496
  },
42497
+ "backup.disableEncryption": {
42498
+ capName: "backup",
42499
+ capScope: "system",
42500
+ addonId: null,
42501
+ access: "create"
42502
+ },
42503
+ "backup.getEncryption": {
42504
+ capName: "backup",
42505
+ capScope: "system",
42506
+ addonId: null,
42507
+ access: "view"
42508
+ },
41090
42509
  "backup.getEntries": {
41091
42510
  capName: "backup",
41092
42511
  capScope: "system",
@@ -41141,6 +42560,12 @@ Object.freeze({
41141
42560
  addonId: null,
41142
42561
  access: "create"
41143
42562
  },
42563
+ "backup.setupEncryption": {
42564
+ capName: "backup",
42565
+ capScope: "system",
42566
+ addonId: null,
42567
+ access: "create"
42568
+ },
41144
42569
  "backup.trigger": {
41145
42570
  capName: "backup",
41146
42571
  capScope: "system",
@@ -41693,6 +43118,12 @@ Object.freeze({
41693
43118
  addonId: null,
41694
43119
  access: "create"
41695
43120
  },
43121
+ "customModelRegistry.importModelBundle": {
43122
+ capName: "custom-model-registry",
43123
+ capScope: "system",
43124
+ addonId: null,
43125
+ access: "create"
43126
+ },
41696
43127
  "customModelRegistry.listModels": {
41697
43128
  capName: "custom-model-registry",
41698
43129
  capScope: "system",
@@ -43133,6 +44564,12 @@ Object.freeze({
43133
44564
  addonId: null,
43134
44565
  access: "view"
43135
44566
  },
44567
+ "keychainAdmin.acknowledgeReset": {
44568
+ capName: "keychain-admin",
44569
+ capScope: "system",
44570
+ addonId: null,
44571
+ access: "create"
44572
+ },
43136
44573
  "keychainAdmin.deleteOrphans": {
43137
44574
  capName: "keychain-admin",
43138
44575
  capScope: "system",
@@ -43169,6 +44606,12 @@ Object.freeze({
43169
44606
  addonId: null,
43170
44607
  access: "delete"
43171
44608
  },
44609
+ "keychainAdmin.resetReport": {
44610
+ capName: "keychain-admin",
44611
+ capScope: "system",
44612
+ addonId: null,
44613
+ access: "delete"
44614
+ },
43172
44615
  "keychainAdmin.reveal": {
43173
44616
  capName: "keychain-admin",
43174
44617
  capScope: "system",
@@ -43181,6 +44624,12 @@ Object.freeze({
43181
44624
  addonId: null,
43182
44625
  access: "create"
43183
44626
  },
44627
+ "keychainAdmin.setSystemSecret": {
44628
+ capName: "keychain-admin",
44629
+ capScope: "system",
44630
+ addonId: null,
44631
+ access: "create"
44632
+ },
43184
44633
  "keychainAdmin.status": {
43185
44634
  capName: "keychain-admin",
43186
44635
  capScope: "system",
@@ -44627,6 +46076,12 @@ Object.freeze({
44627
46076
  addonId: null,
44628
46077
  access: "create"
44629
46078
  },
46079
+ "pipelineAnalytics.createRetrainDatasetVersion": {
46080
+ capName: "pipeline-analytics",
46081
+ capScope: "device",
46082
+ addonId: null,
46083
+ access: "create"
46084
+ },
44630
46085
  "pipelineAnalytics.deleteDeviceEvents": {
44631
46086
  capName: "pipeline-analytics",
44632
46087
  capScope: "device",
@@ -44639,6 +46094,12 @@ Object.freeze({
44639
46094
  addonId: null,
44640
46095
  access: "delete"
44641
46096
  },
46097
+ "pipelineAnalytics.deleteRetrainDatasetVersion": {
46098
+ capName: "pipeline-analytics",
46099
+ capScope: "device",
46100
+ addonId: null,
46101
+ access: "delete"
46102
+ },
44642
46103
  "pipelineAnalytics.deleteTracks": {
44643
46104
  capName: "pipeline-analytics",
44644
46105
  capScope: "device",
@@ -44861,6 +46322,12 @@ Object.freeze({
44861
46322
  addonId: null,
44862
46323
  access: "view"
44863
46324
  },
46325
+ "pipelineAnalytics.listRetrainDatasetVersions": {
46326
+ capName: "pipeline-analytics",
46327
+ capScope: "device",
46328
+ addonId: null,
46329
+ access: "view"
46330
+ },
44864
46331
  "pipelineAnalytics.listRetrainFrames": {
44865
46332
  capName: "pipeline-analytics",
44866
46333
  capScope: "device",
@@ -44891,6 +46358,12 @@ Object.freeze({
44891
46358
  addonId: null,
44892
46359
  access: "view"
44893
46360
  },
46361
+ "pipelineAnalytics.offerRetrainArchive": {
46362
+ capName: "pipeline-analytics",
46363
+ capScope: "device",
46364
+ addonId: null,
46365
+ access: "create"
46366
+ },
44894
46367
  "pipelineAnalytics.ownersWithMedia": {
44895
46368
  capName: "pipeline-analytics",
44896
46369
  capScope: "device",
@@ -44903,6 +46376,12 @@ Object.freeze({
44903
46376
  addonId: null,
44904
46377
  access: "create"
44905
46378
  },
46379
+ "pipelineAnalytics.previewRetrainDataset": {
46380
+ capName: "pipeline-analytics",
46381
+ capScope: "device",
46382
+ addonId: null,
46383
+ access: "view"
46384
+ },
44906
46385
  "pipelineAnalytics.proposeRetrainAnnotations": {
44907
46386
  capName: "pipeline-analytics",
44908
46387
  capScope: "device",
@@ -45041,6 +46520,12 @@ Object.freeze({
45041
46520
  addonId: null,
45042
46521
  access: "create"
45043
46522
  },
46523
+ "pipelineAnalytics.verifyRetrainDatasetVersion": {
46524
+ capName: "pipeline-analytics",
46525
+ capScope: "device",
46526
+ addonId: null,
46527
+ access: "view"
46528
+ },
45044
46529
  "pipelineAnalytics.wipeAllAnalytics": {
45045
46530
  capName: "pipeline-analytics",
45046
46531
  capScope: "device",
@@ -47417,6 +48902,174 @@ Object.freeze({
47417
48902
  addonId: null,
47418
48903
  access: "view"
47419
48904
  },
48905
+ "training.canaryResult": {
48906
+ capName: "training",
48907
+ capScope: "system",
48908
+ addonId: null,
48909
+ access: "create"
48910
+ },
48911
+ "training.cancelJob": {
48912
+ capName: "training",
48913
+ capScope: "system",
48914
+ addonId: null,
48915
+ access: "create"
48916
+ },
48917
+ "training.discardResult": {
48918
+ capName: "training",
48919
+ capScope: "system",
48920
+ addonId: null,
48921
+ access: "create"
48922
+ },
48923
+ "training.findDatasetVersionIdByName": {
48924
+ capName: "training",
48925
+ capScope: "system",
48926
+ addonId: null,
48927
+ access: "view"
48928
+ },
48929
+ "training.getDatasetVersion": {
48930
+ capName: "training",
48931
+ capScope: "system",
48932
+ addonId: null,
48933
+ access: "view"
48934
+ },
48935
+ "training.getJob": {
48936
+ capName: "training",
48937
+ capScope: "system",
48938
+ addonId: null,
48939
+ access: "view"
48940
+ },
48941
+ "training.getJobResult": {
48942
+ capName: "training",
48943
+ capScope: "system",
48944
+ addonId: null,
48945
+ access: "view"
48946
+ },
48947
+ "training.listBaseModels": {
48948
+ capName: "training",
48949
+ capScope: "system",
48950
+ addonId: null,
48951
+ access: "view"
48952
+ },
48953
+ "training.listDatasetVersions": {
48954
+ capName: "training",
48955
+ capScope: "system",
48956
+ addonId: null,
48957
+ access: "view"
48958
+ },
48959
+ "training.listJobs": {
48960
+ capName: "training",
48961
+ capScope: "system",
48962
+ addonId: null,
48963
+ access: "view"
48964
+ },
48965
+ "training.planJob": {
48966
+ capName: "training",
48967
+ capScope: "system",
48968
+ addonId: null,
48969
+ access: "view"
48970
+ },
48971
+ "training.putDatasetVersion": {
48972
+ capName: "training",
48973
+ capScope: "system",
48974
+ addonId: null,
48975
+ access: "create"
48976
+ },
48977
+ "training.registerResult": {
48978
+ capName: "training",
48979
+ capScope: "system",
48980
+ addonId: null,
48981
+ access: "create"
48982
+ },
48983
+ "training.removeDatasetVersion": {
48984
+ capName: "training",
48985
+ capScope: "system",
48986
+ addonId: null,
48987
+ access: "delete"
48988
+ },
48989
+ "training.rollbackCanary": {
48990
+ capName: "training",
48991
+ capScope: "system",
48992
+ addonId: null,
48993
+ access: "create"
48994
+ },
48995
+ "training.startJob": {
48996
+ capName: "training",
48997
+ capScope: "system",
48998
+ addonId: null,
48999
+ access: "create"
49000
+ },
49001
+ "trainingProvider.cancelJob": {
49002
+ capName: "training-provider",
49003
+ capScope: "system",
49004
+ addonId: null,
49005
+ access: "create"
49006
+ },
49007
+ "trainingProvider.cleanupJob": {
49008
+ capName: "training-provider",
49009
+ capScope: "system",
49010
+ addonId: null,
49011
+ access: "create"
49012
+ },
49013
+ "trainingProvider.describe": {
49014
+ capName: "training-provider",
49015
+ capScope: "system",
49016
+ addonId: null,
49017
+ access: "view"
49018
+ },
49019
+ "trainingProvider.estimateJob": {
49020
+ capName: "training-provider",
49021
+ capScope: "system",
49022
+ addonId: null,
49023
+ access: "view"
49024
+ },
49025
+ "trainingProvider.getJob": {
49026
+ capName: "training-provider",
49027
+ capScope: "system",
49028
+ addonId: null,
49029
+ access: "view"
49030
+ },
49031
+ "trainingProvider.listJobEvents": {
49032
+ capName: "training-provider",
49033
+ capScope: "system",
49034
+ addonId: null,
49035
+ access: "view"
49036
+ },
49037
+ "trainingProvider.listJobs": {
49038
+ capName: "training-provider",
49039
+ capScope: "system",
49040
+ addonId: null,
49041
+ access: "view"
49042
+ },
49043
+ "trainingProvider.offerArtifact": {
49044
+ capName: "training-provider",
49045
+ capScope: "system",
49046
+ addonId: null,
49047
+ access: "create"
49048
+ },
49049
+ "trainingProvider.readResult": {
49050
+ capName: "training-provider",
49051
+ capScope: "system",
49052
+ addonId: null,
49053
+ access: "create"
49054
+ },
49055
+ "trainingProvider.submitJob": {
49056
+ capName: "training-provider",
49057
+ capScope: "system",
49058
+ addonId: null,
49059
+ access: "create"
49060
+ },
49061
+ "trainingProvider.uploadDataset": {
49062
+ capName: "training-provider",
49063
+ capScope: "system",
49064
+ addonId: null,
49065
+ access: "create"
49066
+ },
49067
+ "trainingProvider.validateCredentials": {
49068
+ capName: "training-provider",
49069
+ capScope: "system",
49070
+ addonId: null,
49071
+ access: "create"
49072
+ },
47420
49073
  "turnProvider.getTurnServers": {
47421
49074
  capName: "turn-provider",
47422
49075
  capScope: "system",
@@ -47441,12 +49094,6 @@ Object.freeze({
47441
49094
  addonId: null,
47442
49095
  access: "create"
47443
49096
  },
47444
- "userManagement.createApiKey": {
47445
- capName: "user-management",
47446
- capScope: "system",
47447
- addonId: null,
47448
- access: "create"
47449
- },
47450
49097
  "userManagement.createScopedToken": {
47451
49098
  capName: "user-management",
47452
49099
  capScope: "system",
@@ -47483,12 +49130,6 @@ Object.freeze({
47483
49130
  addonId: null,
47484
49131
  access: "view"
47485
49132
  },
47486
- "userManagement.linkExternalIdentity": {
47487
- capName: "user-management",
47488
- capScope: "system",
47489
- addonId: null,
47490
- access: "create"
47491
- },
47492
49133
  "userManagement.listApiKeys": {
47493
49134
  capName: "user-management",
47494
49135
  capScope: "system",
@@ -47591,12 +49232,6 @@ Object.freeze({
47591
49232
  addonId: null,
47592
49233
  access: "create"
47593
49234
  },
47594
- "userManagement.validateApiKey": {
47595
- capName: "user-management",
47596
- capScope: "system",
47597
- addonId: null,
47598
- access: "view"
47599
- },
47600
49235
  "userManagement.validateCredentials": {
47601
49236
  capName: "user-management",
47602
49237
  capScope: "system",
@@ -51738,6 +53373,11 @@ Object.freeze({
51738
53373
  form: "single",
51739
53374
  optional: false
51740
53375
  }],
53376
+ "training.canaryResult": [{
53377
+ name: "deviceIds",
53378
+ form: "array",
53379
+ optional: false
53380
+ }],
51741
53381
  "update.getStatus": [{
51742
53382
  name: "deviceId",
51743
53383
  form: "single",