@camstack/addon-provider-petkit 0.2.123 → 0.2.124

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/dist/addon.js +1771 -131
  2. package/dist/addon.mjs +1771 -131
  3. package/package.json +1 -1
package/dist/addon.mjs CHANGED
@@ -6478,7 +6478,7 @@ var ZodIssueCode = {
6478
6478
  var ZodFirstPartyTypeKind;
6479
6479
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
6480
6480
  //#endregion
6481
- //#region ../types/dist/sleep-Cr5YOk3m.mjs
6481
+ //#region ../types/dist/sleep-r3RWkGVx.mjs
6482
6482
  /**
6483
6483
  * The audio chunk plane's byte format, and the ONE expansion from a coded
6484
6484
  * window to float samples (D455).
@@ -6595,7 +6595,7 @@ function isKeychainStoredField(field) {
6595
6595
  var SECRET_CLEAR = { $secretClear: true };
6596
6596
  /** The `'***'` token D634 redaction writes for non-admins. */
6597
6597
  var LEGACY_DEVICE_REDACTION = "***";
6598
- function isRecord$1(value) {
6598
+ function isRecord$2(value) {
6599
6599
  return typeof value === "object" && value !== null && !Array.isArray(value);
6600
6600
  }
6601
6601
  function makeSecretMarker(ref) {
@@ -6606,12 +6606,12 @@ function makeSecretMarker(ref) {
6606
6606
  }
6607
6607
  /** A stored marker: an object whose `$secret` is a non-empty string. */
6608
6608
  function isSecretMarker(value) {
6609
- if (!isRecord$1(value)) return false;
6609
+ if (!isRecord$2(value)) return false;
6610
6610
  const ref = value["$secret"];
6611
6611
  return typeof ref === "string" && ref.length > 0;
6612
6612
  }
6613
6613
  function isSecretClear(value) {
6614
- return isRecord$1(value) && value["$secretClear"] === true;
6614
+ return isRecord$2(value) && value["$secretClear"] === true;
6615
6615
  }
6616
6616
  /**
6617
6617
  * The UI view of a stored secret field value: a marker becomes "set", inline
@@ -7127,6 +7127,13 @@ function globalSecretScope() {
7127
7127
  function encodeSegment(value) {
7128
7128
  return encodeURIComponent(value);
7129
7129
  }
7130
+ function decodeSegment(value) {
7131
+ try {
7132
+ return decodeURIComponent(value);
7133
+ } catch {
7134
+ return null;
7135
+ }
7136
+ }
7130
7137
  /**
7131
7138
  * The field path of a value inside an array item, addressed by the item's id:
7132
7139
  * `arrayItemFieldPath('providers', 'authentik', 'clientSecret')` →
@@ -7135,6 +7142,75 @@ function encodeSegment(value) {
7135
7142
  function arrayItemFieldPath(arrayKey, itemId, fieldKey) {
7136
7143
  return `${arrayKey}[${encodeSegment(itemId)}].${fieldKey}`;
7137
7144
  }
7145
+ function parseScope(segments) {
7146
+ switch (segments[0]) {
7147
+ case "global": return {
7148
+ scope: GLOBAL_SCOPE,
7149
+ used: 1
7150
+ };
7151
+ case "node": {
7152
+ const nodeId = segments[1] !== void 0 ? decodeSegment(segments[1]) : null;
7153
+ return nodeId === null || nodeId.length === 0 ? null : {
7154
+ scope: {
7155
+ kind: "node",
7156
+ nodeId
7157
+ },
7158
+ used: 2
7159
+ };
7160
+ }
7161
+ case "device": {
7162
+ const raw = segments[1];
7163
+ if (raw === void 0 || !/^\d+$/.test(raw)) return null;
7164
+ return {
7165
+ scope: {
7166
+ kind: "device",
7167
+ deviceId: Number(raw)
7168
+ },
7169
+ used: 2
7170
+ };
7171
+ }
7172
+ case "integration": {
7173
+ const id = segments[1] !== void 0 ? decodeSegment(segments[1]) : null;
7174
+ return id === null || id.length === 0 ? null : {
7175
+ scope: {
7176
+ kind: "integration",
7177
+ integrationId: id
7178
+ },
7179
+ used: 2
7180
+ };
7181
+ }
7182
+ case "row": {
7183
+ const collection = segments[1] !== void 0 ? decodeSegment(segments[1]) : null;
7184
+ const rowId = segments[2] !== void 0 ? decodeSegment(segments[2]) : null;
7185
+ if (collection === null || rowId === null || collection.length === 0 || rowId.length === 0) return null;
7186
+ return {
7187
+ scope: {
7188
+ kind: "row",
7189
+ collection,
7190
+ rowId
7191
+ },
7192
+ used: 3
7193
+ };
7194
+ }
7195
+ default: return null;
7196
+ }
7197
+ }
7198
+ /** Take a ref apart; `null` when it is not a well-formed ref. */
7199
+ function parseSecretRef(ref) {
7200
+ if (!ref.startsWith("secret://")) return null;
7201
+ const segments = ref.slice(9).split("/");
7202
+ const owner = segments[0] !== void 0 ? decodeSegment(segments[0]) : null;
7203
+ if (owner === null || owner.length === 0) return null;
7204
+ const parsed = parseScope(segments.slice(1));
7205
+ if (parsed === null) return null;
7206
+ const fieldPath = segments.slice(1 + parsed.used).join("/");
7207
+ if (fieldPath.length === 0) return null;
7208
+ return {
7209
+ owner,
7210
+ scope: parsed.scope,
7211
+ fieldPath
7212
+ };
7213
+ }
7138
7214
  /** A write to a secret path could not be stored in the keychain, so it was refused. */
7139
7215
  var KeychainWriteRefusedError = class extends Error {
7140
7216
  fieldPath;
@@ -7145,7 +7221,7 @@ var KeychainWriteRefusedError = class extends Error {
7145
7221
  }
7146
7222
  };
7147
7223
  var KEEP = { kind: "keep" };
7148
- function isRecord(value) {
7224
+ function isRecord$1(value) {
7149
7225
  return typeof value === "object" && value !== null && !Array.isArray(value);
7150
7226
  }
7151
7227
  function defaultMintId() {
@@ -7158,7 +7234,7 @@ function collectSecretMarkerRefs(value, out = []) {
7158
7234
  return out;
7159
7235
  }
7160
7236
  if (Array.isArray(value)) for (const item of value) collectSecretMarkerRefs(item, out);
7161
- else if (isRecord(value)) for (const child of Object.values(value)) collectSecretMarkerRefs(child, out);
7237
+ else if (isRecord$1(value)) for (const child of Object.values(value)) collectSecretMarkerRefs(child, out);
7162
7238
  return out;
7163
7239
  }
7164
7240
  async function storedValueEquals(secrets, marker, candidate) {
@@ -7213,7 +7289,7 @@ function rowId(row, idKey) {
7213
7289
  return null;
7214
7290
  }
7215
7291
  async function writeArray(ctx, node, incoming, stored, fieldPath) {
7216
- const storedRows = Array.isArray(stored) ? stored.filter(isRecord) : [];
7292
+ const storedRows = Array.isArray(stored) ? stored.filter(isRecord$1) : [];
7217
7293
  if (!Array.isArray(incoming)) {
7218
7294
  ctx.deletes.push(...collectSecretMarkerRefs(storedRows));
7219
7295
  return {
@@ -7229,7 +7305,7 @@ async function writeArray(ctx, node, incoming, stored, fieldPath) {
7229
7305
  const kept = /* @__PURE__ */ new Set();
7230
7306
  const rows = [];
7231
7307
  for (const row of incoming) {
7232
- if (!isRecord(row)) {
7308
+ if (!isRecord$1(row)) {
7233
7309
  rows.push(row);
7234
7310
  continue;
7235
7311
  }
@@ -7254,7 +7330,7 @@ async function writeNode(ctx, node, incoming, stored, fieldPath) {
7254
7330
  case "leaf": return writeLeaf(ctx, incoming, stored, fieldPath);
7255
7331
  case "array": return writeArray(ctx, node, incoming, stored, fieldPath);
7256
7332
  case "object": {
7257
- if (!isRecord(incoming)) {
7333
+ if (!isRecord$1(incoming)) {
7258
7334
  if (incoming === void 0) return KEEP;
7259
7335
  ctx.deletes.push(...collectSecretMarkerRefs(stored));
7260
7336
  return {
@@ -7262,7 +7338,7 @@ async function writeNode(ctx, node, incoming, stored, fieldPath) {
7262
7338
  value: incoming
7263
7339
  };
7264
7340
  }
7265
- const storedObj = isRecord(stored) ? stored : {};
7341
+ const storedObj = isRecord$1(stored) ? stored : {};
7266
7342
  return {
7267
7343
  kind: "value",
7268
7344
  value: await writeMembers(ctx, node.children, incoming, storedObj, (m) => `${fieldPath}.${m}`)
@@ -7321,12 +7397,19 @@ async function transformSecretWrite(input) {
7321
7397
  }
7322
7398
  };
7323
7399
  }
7400
+ /** Is `ref` one of `owner`'s refs? */
7401
+ function isSecretRefOwnedBy(ref, owner) {
7402
+ return parseSecretRef(ref)?.owner === owner;
7403
+ }
7324
7404
  /**
7325
7405
  * Replace every marker in `value` with its keychain value. Returns the SAME
7326
7406
  * reference when there is no marker (no allocation, no keychain call).
7327
7407
  */
7328
- async function resolveSecretMarkers(value, secrets) {
7329
- const refs = collectSecretMarkerRefs(value);
7408
+ async function resolveSecretMarkers(value, secrets, options = {}) {
7409
+ const keepMarker = options.unresolved === "keep-marker";
7410
+ const owner = options.ownedBy;
7411
+ const inScope = (ref) => owner === void 0 || isSecretRefOwnedBy(ref, owner);
7412
+ const refs = collectSecretMarkerRefs(value).filter(inScope);
7330
7413
  if (refs.length === 0) return {
7331
7414
  value,
7332
7415
  unresolved: []
@@ -7350,10 +7433,18 @@ async function resolveSecretMarkers(value, secrets) {
7350
7433
  }
7351
7434
  const substitute = (v) => {
7352
7435
  if (isSecretMarker(v)) {
7436
+ if (!inScope(v.$secret)) return {
7437
+ keep: true,
7438
+ value: v
7439
+ };
7353
7440
  const answer = answers[v.$secret];
7354
- return answer?.kind === "value" ? {
7441
+ if (answer?.kind === "value") return {
7355
7442
  keep: true,
7356
7443
  value: answer.value
7444
+ };
7445
+ return keepMarker ? {
7446
+ keep: true,
7447
+ value: v
7357
7448
  } : {
7358
7449
  keep: false,
7359
7450
  value: void 0
@@ -7370,7 +7461,7 @@ async function resolveSecretMarkers(value, secrets) {
7370
7461
  value: items
7371
7462
  };
7372
7463
  }
7373
- if (isRecord(v)) {
7464
+ if (isRecord$1(v)) {
7374
7465
  const out = {};
7375
7466
  for (const [k, child] of Object.entries(v)) {
7376
7467
  const s = substitute(child);
@@ -7391,14 +7482,152 @@ async function resolveSecretMarkers(value, secrets) {
7391
7482
  unresolved
7392
7483
  };
7393
7484
  }
7394
- function touchesTree(tree, patch) {
7395
- if (tree.size === 0) return false;
7396
- for (const key of Object.keys(patch)) {
7397
- const at = key.indexOf("@");
7398
- if (tree.has(at > 0 ? key.slice(0, at) : key)) return true;
7485
+ /** An addon tried to replace a stored secret it could not read. Nothing was written. */
7486
+ var SecretOverwriteRefusedError = class extends Error {
7487
+ ref;
7488
+ reason;
7489
+ constructor(ref, reason) {
7490
+ 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.`);
7491
+ this.ref = ref;
7492
+ this.reason = reason;
7493
+ this.name = "SecretOverwriteRefusedError";
7494
+ }
7495
+ };
7496
+ function isRecord(value) {
7497
+ return typeof value === "object" && value !== null && !Array.isArray(value);
7498
+ }
7499
+ function resolvedValue(pass, marker) {
7500
+ const answer = pass.answers[marker.$secret];
7501
+ return answer?.kind === "value" ? answer.value : null;
7502
+ }
7503
+ async function atMarker(pass, incoming, stored) {
7504
+ if (incoming === null) return stored;
7505
+ if (typeof incoming !== "string") return incoming;
7506
+ if (incoming === resolvedValue(pass, stored)) return stored;
7507
+ const intent = classifySecretWrite(incoming);
7508
+ if (intent.kind !== "set") return stored;
7509
+ const ref = stored.$secret;
7510
+ if (!isSecretRefOwnedBy(ref, pass.secrets.owner)) return incoming;
7511
+ const answer = pass.answers[ref];
7512
+ 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);
7513
+ try {
7514
+ await pass.secrets.put(ref, intent.value);
7515
+ } catch (err) {
7516
+ throw new KeychainWriteRefusedError(ref, err);
7517
+ }
7518
+ pass.changedRefs.push(ref);
7519
+ return stored;
7520
+ }
7521
+ function inArray(pass, incoming, stored) {
7522
+ return incoming.map((item, index) => {
7523
+ const twin = stored[index];
7524
+ if (isSecretMarker(twin)) return typeof item === "string" && item === resolvedValue(pass, twin) ? twin : item;
7525
+ if (isRecord(item) && isRecord(twin)) return inArrayRow(pass, item, twin);
7526
+ if (Array.isArray(item) && Array.isArray(twin)) return inArray(pass, item, twin);
7527
+ return item;
7528
+ });
7529
+ }
7530
+ function inArrayRow(pass, incoming, stored) {
7531
+ const out = { ...incoming };
7532
+ for (const [key, value] of Object.entries(incoming)) {
7533
+ const twin = stored[key];
7534
+ if (isSecretMarker(twin)) {
7535
+ if (typeof value === "string" && value === resolvedValue(pass, twin)) out[key] = twin;
7536
+ } else if (isRecord(value) && isRecord(twin)) out[key] = inArrayRow(pass, value, twin);
7537
+ else if (Array.isArray(value) && Array.isArray(twin)) out[key] = inArray(pass, value, twin);
7538
+ }
7539
+ return out;
7540
+ }
7541
+ async function walk(pass, incoming, stored) {
7542
+ if (isSecretMarker(stored)) return atMarker(pass, incoming, stored);
7543
+ if (Array.isArray(incoming) && Array.isArray(stored)) return inArray(pass, incoming, stored);
7544
+ if (!isRecord(incoming) || !isRecord(stored)) return incoming;
7545
+ const out = { ...incoming };
7546
+ for (const [key, value] of Object.entries(incoming)) out[key] = await walk(pass, value, stored[key]);
7547
+ return out;
7548
+ }
7549
+ /** Restore markers a write-back carries as values. See the file doc. */
7550
+ async function restoreUnchangedSecrets(input) {
7551
+ const refs = [];
7552
+ for (const key of Object.keys(input.patch)) collectSecretMarkerRefs(input.stored[key], refs);
7553
+ const owned = refs.filter((ref) => isSecretRefOwnedBy(ref, input.secrets.owner));
7554
+ if (owned.length === 0) return {
7555
+ patch: input.patch,
7556
+ changedRefs: []
7557
+ };
7558
+ const pass = {
7559
+ secrets: input.secrets,
7560
+ answers: await input.secrets.resolve([...new Set(owned)]),
7561
+ operatorWrite: input.operatorWrite,
7562
+ changedRefs: []
7563
+ };
7564
+ const out = {};
7565
+ for (const [key, value] of Object.entries(input.patch)) out[key] = await walk(pass, value, input.stored[key]);
7566
+ return {
7567
+ patch: out,
7568
+ changedRefs: pass.changedRefs
7569
+ };
7570
+ }
7571
+ /** Structural equality over JSON-shaped values (key order does not matter). */
7572
+ function isJsonEqual(a, b) {
7573
+ if (Object.is(a, b)) return true;
7574
+ if (Array.isArray(a)) return Array.isArray(b) && a.length === b.length && a.every((v, i) => isJsonEqual(v, b[i]));
7575
+ if (isRecord(a) && isRecord(b)) {
7576
+ const keys = Object.keys(a);
7577
+ if (keys.length !== Object.keys(b).length) return false;
7578
+ return keys.every((k) => Object.prototype.hasOwnProperty.call(b, k) && isJsonEqual(a[k], b[k]));
7399
7579
  }
7400
7580
  return false;
7401
7581
  }
7582
+ /** The patch without the keys whose value already equals the stored one. */
7583
+ function dropUnchangedKeys(patch, stored) {
7584
+ const out = {};
7585
+ for (const [key, value] of Object.entries(patch)) {
7586
+ if (Object.prototype.hasOwnProperty.call(stored, key) && isJsonEqual(value, stored[key])) continue;
7587
+ out[key] = value;
7588
+ }
7589
+ return out;
7590
+ }
7591
+ /** The top-level keys of a blob that hold at least one of `owner`'s markers. */
7592
+ function markerKeysOf(blob, owner) {
7593
+ const keys = /* @__PURE__ */ new Set();
7594
+ for (const [key, value] of Object.entries(blob)) if (collectSecretMarkerRefs(value).some((ref) => isSecretRefOwnedBy(ref, owner))) keys.add(key);
7595
+ return keys;
7596
+ }
7597
+ function nodeFromStored(value, owner) {
7598
+ if (isSecretMarker(value)) return isSecretRefOwnedBy(value.$secret, owner) ? { kind: "leaf" } : null;
7599
+ if (!isRecord(value)) return null;
7600
+ const children = /* @__PURE__ */ new Map();
7601
+ for (const [key, child] of Object.entries(value)) {
7602
+ const node = nodeFromStored(child, owner);
7603
+ if (node !== null) children.set(key, node);
7604
+ }
7605
+ return children.size > 0 ? {
7606
+ kind: "object",
7607
+ children
7608
+ } : null;
7609
+ }
7610
+ /**
7611
+ * The declared secret tree, widened by every place the STORED blob holds a
7612
+ * marker under one of `keys` — so a marker the schema no longer declares (or
7613
+ * never declared: Wyze before b4906cec6) still gets the save path's
7614
+ * KEEP / SET / CLEAR semantics instead of being overwritten by whatever the
7615
+ * addon writes. Markers inside arrays are not added: a row has no id field to
7616
+ * match by unless the schema declares one. Only `owner`'s markers count: a
7617
+ * builtin that keeps another addon's marker (device-manager) never takes it
7618
+ * over.
7619
+ */
7620
+ function widenTreeWithStoredMarkers(declared, stored, keys, owner) {
7621
+ const added = /* @__PURE__ */ new Map();
7622
+ for (const key of keys) {
7623
+ const at = key.indexOf("@");
7624
+ const base = at > 0 ? key.slice(0, at) : key;
7625
+ if (declared.has(base) || added.has(base)) continue;
7626
+ const node = nodeFromStored(stored[key], owner);
7627
+ if (node !== null) added.set(base, node);
7628
+ }
7629
+ return added.size === 0 ? declared : new Map([...declared, ...added]);
7630
+ }
7402
7631
  /** The blob as stored now; a failed read REFUSES the write instead of guessing. */
7403
7632
  async function readStoredAddonBlob(raw) {
7404
7633
  const threeWay = raw.readAddonStoreResult;
@@ -7407,7 +7636,41 @@ async function readStoredAddonBlob(raw) {
7407
7636
  if (result.kind === "failed") throw new Error(`settings write refused: the stored blob could not be read (${result.error})`);
7408
7637
  return result.kind === "missing" ? {} : result.value;
7409
7638
  }
7410
- function createSecretAwareSettings(raw, opts) {
7639
+ function touchesTree(tree, patch) {
7640
+ if (tree.size === 0) return false;
7641
+ for (const key of Object.keys(patch)) {
7642
+ const at = key.indexOf("@");
7643
+ if (tree.has(at > 0 ? key.slice(0, at) : key)) return true;
7644
+ }
7645
+ return false;
7646
+ }
7647
+ /**
7648
+ * Which top-level keys of each store held markers when last seen. `undefined`
7649
+ * for a store not seen yet: its first write reads it, to be safe.
7650
+ */
7651
+ var MarkerKeyIndex = class {
7652
+ owner;
7653
+ byStore = /* @__PURE__ */ new Map();
7654
+ constructor(owner) {
7655
+ this.owner = owner;
7656
+ }
7657
+ seen(store, blob) {
7658
+ this.byStore.set(store, markerKeysOf(blob, this.owner));
7659
+ }
7660
+ wrote(store, patch) {
7661
+ const keys = this.byStore.get(store);
7662
+ if (keys === void 0) return;
7663
+ const now = markerKeysOf(patch, this.owner);
7664
+ for (const key of Object.keys(patch)) if (now.has(key)) keys.add(key);
7665
+ else keys.delete(key);
7666
+ }
7667
+ mayHoldMarkers(store, patch) {
7668
+ const keys = this.byStore.get(store);
7669
+ if (keys === void 0) return true;
7670
+ return Object.keys(patch).some((key) => keys.has(key));
7671
+ }
7672
+ };
7673
+ function createHandle(raw, opts) {
7411
7674
  const chains = /* @__PURE__ */ new Map();
7412
7675
  const serialize = (key, fn) => {
7413
7676
  const next = (chains.get(key) ?? Promise.resolve()).then(fn, fn);
@@ -7418,46 +7681,130 @@ function createSecretAwareSettings(raw, opts) {
7418
7681
  });
7419
7682
  return next;
7420
7683
  };
7421
- const write = async (chainKey, tree, scope, patch, readStored, rawWrite) => {
7422
- if (!touchesTree(tree, patch)) return rawWrite(patch);
7423
- return serialize(chainKey, async () => {
7684
+ const index = new MarkerKeyIndex(opts.secrets.owner);
7685
+ const resolveRead = async (store, blob) => {
7686
+ index.seen(store, blob);
7687
+ const { value, unresolved } = await resolveSecretMarkers(blob, opts.secrets, {
7688
+ unresolved: "keep-marker",
7689
+ ownedBy: opts.secrets.owner
7690
+ });
7691
+ if (unresolved.length > 0) opts.onUnresolved?.(unresolved);
7692
+ return value;
7693
+ };
7694
+ const write = async (store, declared, scope, patch, readStored, rawWrite) => {
7695
+ if (!touchesTree(declared, patch) && !index.mayHoldMarkers(store, patch)) {
7696
+ await rawWrite(patch);
7697
+ index.wrote(store, patch);
7698
+ return { changed: true };
7699
+ }
7700
+ return serialize(store, async () => {
7424
7701
  const stored = await readStored();
7702
+ index.seen(store, stored);
7703
+ const operatorWrite = opts.isOperatorWrite?.() === true;
7704
+ const restored = await restoreUnchangedSecrets({
7705
+ patch,
7706
+ stored,
7707
+ secrets: opts.secrets,
7708
+ operatorWrite
7709
+ });
7425
7710
  const result = await transformSecretWrite({
7426
- tree,
7711
+ tree: widenTreeWithStoredMarkers(declared, stored, Object.keys(restored.patch), opts.secrets.owner),
7427
7712
  secrets: opts.secrets,
7428
- patch,
7713
+ patch: restored.patch,
7429
7714
  stored,
7430
7715
  ...scope !== void 0 ? { scope } : {},
7431
- operatorWrite: opts.isOperatorWrite?.() === true
7716
+ operatorWrite
7432
7717
  });
7433
- if (Object.keys(result.patch).length > 0) await rawWrite(result.patch);
7718
+ const effective = dropUnchangedKeys(result.patch, stored);
7719
+ const wroteBlob = Object.keys(effective).length > 0;
7720
+ if (wroteBlob) {
7721
+ await rawWrite(effective);
7722
+ index.wrote(store, effective);
7723
+ }
7434
7724
  const { orphaned } = await result.afterWrite();
7435
7725
  if (orphaned.length > 0) opts.onOrphaned(orphaned);
7726
+ return { changed: wroteBlob || restored.changedRefs.length > 0 };
7436
7727
  });
7437
7728
  };
7438
- const wrapped = {
7439
- writeAddonStore: (patch) => write("addon", opts.addonTree(), void 0, patch, () => readStoredAddonBlob(raw), (p) => raw.writeAddonStore(p)),
7440
- writeDeviceStore: (deviceId, patch) => write(`device:${deviceId}`, opts.deviceTree(), {
7441
- kind: "device",
7442
- deviceId
7443
- }, patch, () => raw.readDeviceStore(deviceId), (p) => raw.writeDeviceStore(deviceId, p))
7729
+ const writeAddon = (patch) => write("addon", opts.addonTree(), void 0, patch, () => readStoredAddonBlob(raw), (p) => raw.writeAddonStore(p));
7730
+ const readAddonStoreResult = raw.readAddonStoreResult;
7731
+ const readAddonStoreKeyResult = raw.readAddonStoreKeyResult;
7732
+ const readDeviceStoreBatch = raw.readDeviceStoreBatch;
7733
+ const overrides = {
7734
+ readAddonStore: async () => resolveRead("addon", await raw.readAddonStore()),
7735
+ ...readAddonStoreResult !== void 0 ? { readAddonStoreResult: async () => {
7736
+ const result = await readAddonStoreResult.call(raw);
7737
+ return result.kind === "value" ? {
7738
+ kind: "value",
7739
+ value: await resolveRead("addon", result.value)
7740
+ } : result;
7741
+ } } : {},
7742
+ ...readAddonStoreKeyResult !== void 0 ? { readAddonStoreKeyResult: async (key) => {
7743
+ const result = await readAddonStoreKeyResult.call(raw, key);
7744
+ if (result.kind !== "present") return result;
7745
+ const { value, unresolved } = await resolveSecretMarkers({ [key]: result.value }, opts.secrets, {
7746
+ unresolved: "keep-marker",
7747
+ ownedBy: opts.secrets.owner
7748
+ });
7749
+ if (unresolved.length > 0) opts.onUnresolved?.(unresolved);
7750
+ return {
7751
+ kind: "present",
7752
+ value: value[key]
7753
+ };
7754
+ } } : {},
7755
+ readDeviceStore: async (deviceId) => resolveRead(`device:${deviceId}`, await raw.readDeviceStore(deviceId)),
7756
+ ...readDeviceStoreBatch !== void 0 ? { readDeviceStoreBatch: async (deviceIds) => {
7757
+ const rows = await readDeviceStoreBatch.call(raw, deviceIds);
7758
+ const out = /* @__PURE__ */ new Map();
7759
+ for (const [deviceId, blob] of rows) out.set(deviceId, await resolveRead(`device:${deviceId}`, blob));
7760
+ return out;
7761
+ } } : {},
7762
+ writeAddonStore: async (patch) => {
7763
+ await writeAddon(patch);
7764
+ },
7765
+ writeDeviceStore: async (deviceId, patch) => {
7766
+ await write(`device:${deviceId}`, opts.deviceTree(), {
7767
+ kind: "device",
7768
+ deviceId
7769
+ }, patch, () => raw.readDeviceStore(deviceId), (p) => raw.writeDeviceStore(deviceId, p));
7770
+ }
7771
+ };
7772
+ return {
7773
+ settings: new Proxy(raw, { get(target, prop, receiver) {
7774
+ if (typeof prop === "string" && Object.prototype.hasOwnProperty.call(overrides, prop)) return Reflect.get(overrides, prop);
7775
+ const value = Reflect.get(target, prop, receiver);
7776
+ return typeof value === "function" ? value.bind(target) : value;
7777
+ } }),
7778
+ raw: {
7779
+ readAddonStore: async () => {
7780
+ const blob = await raw.readAddonStore();
7781
+ index.seen("addon", blob);
7782
+ return blob;
7783
+ },
7784
+ readDeviceStore: async (deviceId) => {
7785
+ const blob = await raw.readDeviceStore(deviceId);
7786
+ index.seen(`device:${deviceId}`, blob);
7787
+ return blob;
7788
+ }
7789
+ },
7790
+ writeAddonStore: writeAddon
7444
7791
  };
7445
- return new Proxy(raw, { get(target, prop, receiver) {
7446
- if (prop === "writeAddonStore") return wrapped.writeAddonStore;
7447
- if (prop === "writeDeviceStore") return wrapped.writeDeviceStore;
7448
- const value = Reflect.get(target, prop, receiver);
7449
- return typeof value === "function" ? value.bind(target) : value;
7450
- } });
7451
7792
  }
7452
- /** The context the addon sees: identical, except that its settings writes are secret-aware. */
7453
- function withSecretAwareSettings(context, opts) {
7793
+ /** The context the addon sees, plus the private raw view and write outcome. */
7794
+ function createSecretAwareContext(context, opts) {
7454
7795
  const raw = context.settings;
7455
- if (raw === void 0) return context;
7456
- const settings = createSecretAwareSettings(raw, opts);
7457
- return new Proxy(context, { get(target, prop, receiver) {
7458
- if (prop === "settings") return settings;
7459
- return Reflect.get(target, prop, receiver);
7460
- } });
7796
+ if (raw === void 0) return {
7797
+ context,
7798
+ handle: null
7799
+ };
7800
+ const handle = createHandle(raw, opts);
7801
+ return {
7802
+ context: new Proxy(context, { get(target, prop, receiver) {
7803
+ if (prop === "settings") return handle.settings;
7804
+ return Reflect.get(target, prop, receiver);
7805
+ } }),
7806
+ handle
7807
+ };
7461
7808
  }
7462
7809
  var LEAF = { kind: "leaf" };
7463
7810
  var DEFAULT_ITEM_ID_KEY = "id";
@@ -7632,6 +7979,14 @@ var BaseAddon = class {
7632
7979
  _secretChangeUnsub = null;
7633
7980
  /** >0 while an OPERATOR's settings write is being applied. */
7634
7981
  _operatorWriteDepth = 0;
7982
+ /**
7983
+ * The keychain-aware settings handle (D798). Its `raw` view is the ONLY way
7984
+ * to the marker-bearing blobs and stays private to this class: the form
7985
+ * hydrate and config resolution need markers, addon code never does.
7986
+ */
7987
+ _secretSettings = null;
7988
+ /** Refs an addon-facing read could not resolve — each is logged once per process. */
7989
+ _loggedUnresolvedReads = /* @__PURE__ */ new Set();
7635
7990
  constructor(defaults) {
7636
7991
  this.defaults = defaults;
7637
7992
  this._config = { ...defaults };
@@ -7668,13 +8023,21 @@ var BaseAddon = class {
7668
8023
  }
7669
8024
  async initialize(context) {
7670
8025
  const secrets = context.secrets;
7671
- this._ctx = secrets !== void 0 ? withSecretAwareSettings(context, {
7672
- secrets,
7673
- addonTree: () => this.addonSecretTree(),
7674
- deviceTree: () => this.deviceSecretTree(),
7675
- onOrphaned: (refs) => context.logger.warn("keychain refs dropped by a settings write could not be deleted", { meta: { refs: [...refs] } }),
7676
- isOperatorWrite: () => this._operatorWriteDepth > 0
7677
- }) : context;
8026
+ if (secrets !== void 0) {
8027
+ const { context: wrapped, handle } = createSecretAwareContext(context, {
8028
+ secrets,
8029
+ addonTree: () => this.addonSecretTree(),
8030
+ deviceTree: () => this.deviceSecretTree(),
8031
+ onOrphaned: (refs) => context.logger.warn("keychain refs dropped by a settings write could not be deleted", { meta: { refs: [...refs] } }),
8032
+ isOperatorWrite: () => this._operatorWriteDepth > 0,
8033
+ onUnresolved: (unresolved) => this.logUnresolvedRead(unresolved)
8034
+ });
8035
+ this._ctx = wrapped;
8036
+ this._secretSettings = handle;
8037
+ } else {
8038
+ this._ctx = context;
8039
+ this._secretSettings = null;
8040
+ }
7678
8041
  await this.resolveConfig();
7679
8042
  if (secrets !== void 0) this._secretChangeUnsub = secrets.onChange((ref) => {
7680
8043
  if (this._configSecretRefs.has(ref)) this.scheduleSecretReresolve(SECRET_CHANGE_DEBOUNCE_MS);
@@ -7791,11 +8154,8 @@ var BaseAddon = class {
7791
8154
  async getGlobalSettings(overlay, cap, nodeId) {
7792
8155
  const schema = this.globalSettingsSchema(cap);
7793
8156
  if (!schema) return { sections: [] };
7794
- const projected = await this.resolveGlobalStore(nodeId, cap);
7795
- return hydrateSchema(schema, overlay ? {
7796
- ...projected,
7797
- ...overlay
7798
- } : projected, { inlineSecretsAsViews: true });
8157
+ const projected = await this.readRawProjectedStore(nodeId, cap);
8158
+ return hydrateSchema(schema, overlay ? await this.overlayKeepingMarkers(projected, overlay) : projected, { inlineSecretsAsViews: true });
7799
8159
  }
7800
8160
  /**
7801
8161
  * The integration-level view of this addon's settings: exactly the sections
@@ -7840,7 +8200,7 @@ var BaseAddon = class {
7840
8200
  });
7841
8201
  }
7842
8202
  if (sections.length === 0) return null;
7843
- const projected = await this.resolveGlobalStore(nodeId);
8203
+ const projected = await this.readRawProjectedStore(nodeId);
7844
8204
  return hydrateSchema({
7845
8205
  ...schema,
7846
8206
  sections
@@ -7857,12 +8217,50 @@ var BaseAddon = class {
7857
8217
  * the store for custom option logic (option narrowing, value snapping) to
7858
8218
  * read it per-node — never `ctx.settings.readAddonStore()` directly.
7859
8219
  * `nodeId` omitted ⇒ the local node (node-blind injection from ctx).
8220
+ *
8221
+ * Keychain values come back RESOLVED (D798): a secret reads as its value,
8222
+ * never as a `{ $secret }` marker. One the keychain cannot serve right now
8223
+ * stays a marker — "stored, unavailable" (`isSecretMarker()` is true, and it
8224
+ * is listed in {@link unresolvedSecrets}) — never `''` and never absent, so
8225
+ * it cannot be mistaken for "nothing stored, mint a new one". Writing the
8226
+ * resolved blob back is a no-op for every unchanged secret.
7860
8227
  */
7861
8228
  async resolveGlobalStore(nodeId, cap) {
7862
8229
  const raw = await this._ctx?.settings?.readAddonStore() ?? {};
8230
+ return this.projectForNode(raw, nodeId, cap);
8231
+ }
8232
+ projectForNode(store, nodeId, cap) {
7863
8233
  const keys = this.perNodeKeys(cap);
7864
8234
  const node = normalizeNodeId(nodeId ?? this._ctx?.kernel?.localNodeId);
7865
- return keys.size > 0 ? projectStore(raw, keys, node) : raw;
8235
+ return keys.size > 0 ? projectStore(store, keys, node) : store;
8236
+ }
8237
+ /** The PROJECTED store with its markers — the form hydrate only (D798). */
8238
+ async readRawProjectedStore(nodeId, cap) {
8239
+ const raw = await this.rawSettings()?.readAddonStore() ?? {};
8240
+ return this.projectForNode(raw, nodeId, cap);
8241
+ }
8242
+ /**
8243
+ * `{ ...stored, ...overlay }`, except that an overlay member equal to the
8244
+ * RESOLVED stored one keeps the stored (marker-bearing) member — so a form
8245
+ * hydrated from a resolved overlay still shows a secret as "set", never as
8246
+ * its value.
8247
+ */
8248
+ async overlayKeepingMarkers(stored, overlay) {
8249
+ const secrets = this._ctx?.secrets;
8250
+ const merged = {
8251
+ ...stored,
8252
+ ...overlay
8253
+ };
8254
+ if (secrets === void 0 || collectSecretMarkerRefs(stored).length === 0) return merged;
8255
+ const { value: resolved } = await resolveSecretMarkers(stored, secrets, {
8256
+ unresolved: "keep-marker",
8257
+ ownedBy: secrets.owner
8258
+ });
8259
+ for (const key of Object.keys(overlay)) {
8260
+ if (collectSecretMarkerRefs(stored[key]).length === 0) continue;
8261
+ if (isJsonEqual(overlay[key], resolved[key])) merged[key] = stored[key];
8262
+ }
8263
+ return merged;
7866
8264
  }
7867
8265
  /**
7868
8266
  * Whether ONE global key of this addon's store was written, read three-way
@@ -7927,8 +8325,12 @@ var BaseAddon = class {
7927
8325
  async clearSecrets(keys, nodeId) {
7928
8326
  const tree = this.addonSecretTree();
7929
8327
  const keychain = this._ctx?.secrets !== void 0;
8328
+ const stored = keychain ? await this.readAddonStoreWithRetry() : {};
7930
8329
  const patch = {};
7931
- for (const key of keys) patch[key] = keychain && tree.has(key) ? SECRET_CLEAR : "";
8330
+ for (const key of keys) {
8331
+ const keychainStored = tree.has(key) || collectSecretMarkerRefs(stored[key]).length > 0;
8332
+ patch[key] = keychain && keychainStored ? SECRET_CLEAR : "";
8333
+ }
7932
8334
  await this.applyGlobalPatch(patch, nodeId);
7933
8335
  }
7934
8336
  async applyGlobalPatch(barePatch, nodeId) {
@@ -7936,7 +8338,11 @@ var BaseAddon = class {
7936
8338
  const localNode = normalizeNodeId(this._ctx?.kernel?.localNodeId);
7937
8339
  const target = normalizeNodeId(nodeId ?? this._ctx?.kernel?.localNodeId);
7938
8340
  const scoped = keys.size > 0 ? scopePatch(barePatch, keys, target) : barePatch;
7939
- await this._ctx?.settings?.writeAddonStore(scoped);
8341
+ const handle = this._secretSettings;
8342
+ if (handle !== null) {
8343
+ const { changed } = await handle.writeAddonStore(scoped);
8344
+ if (!changed) return;
8345
+ } else await this._ctx?.settings?.writeAddonStore(scoped);
7940
8346
  if (target !== localNode) return;
7941
8347
  await this.resolveConfig();
7942
8348
  await this.onConfigChanged();
@@ -7989,7 +8395,7 @@ var BaseAddon = class {
7989
8395
  async getDeviceSettings(deviceId) {
7990
8396
  const schema = this.deviceSettingsSchema();
7991
8397
  if (!schema) return { sections: [] };
7992
- return hydrateSchema(schema, await this._ctx?.settings?.readDeviceStore(deviceId) ?? {}, { inlineSecretsAsViews: true });
8398
+ return hydrateSchema(schema, await this.rawSettings()?.readDeviceStore(deviceId) ?? {}, { inlineSecretsAsViews: true });
7993
8399
  }
7994
8400
  async updateDeviceSettings(deviceId, patch) {
7995
8401
  await this._ctx?.settings?.writeDeviceStore(deviceId, patch);
@@ -8161,7 +8567,7 @@ var BaseAddon = class {
8161
8567
  key,
8162
8568
  schema,
8163
8569
  fallback,
8164
- read: async () => this.resolveStoredSecrets(await this._ctx?.settings?.readDeviceStore(deviceId) ?? {}, false),
8570
+ read: async () => this.resolveStoredSecrets(await this.rawSettings()?.readDeviceStore(deviceId) ?? {}, false),
8165
8571
  write: async (patch) => {
8166
8572
  await this._ctx?.settings?.writeDeviceStore(deviceId, patch);
8167
8573
  },
@@ -8223,6 +8629,23 @@ var BaseAddon = class {
8223
8629
  }
8224
8630
  return value;
8225
8631
  }
8632
+ /**
8633
+ * The marker-bearing settings reads (D798) — private on purpose. Without a
8634
+ * keychain the context's own view is already raw.
8635
+ */
8636
+ rawSettings() {
8637
+ return this._secretSettings?.raw ?? this._ctx?.settings;
8638
+ }
8639
+ /** An addon-facing read met markers it could not resolve: say so once per ref. */
8640
+ logUnresolvedRead(unresolved) {
8641
+ const fresh = unresolved.filter((u) => !this._loggedUnresolvedReads.has(u.ref));
8642
+ if (fresh.length === 0) return;
8643
+ for (const u of fresh) this._loggedUnresolvedReads.add(u.ref);
8644
+ 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) => ({
8645
+ ref: u.ref,
8646
+ reason: u.reason
8647
+ })) } });
8648
+ }
8226
8649
  /** Re-resolve the config (a keychain-only change, or a retry) and apply it. */
8227
8650
  scheduleSecretReresolve(delayMs) {
8228
8651
  const timerOf = delayMs === SECRET_CHANGE_DEBOUNCE_MS ? "_secretChangeTimer" : "_secretRetryTimer";
@@ -8249,7 +8672,7 @@ var BaseAddon = class {
8249
8672
  * `{}` (defaults) — the addon's first successful patch will rehydrate.
8250
8673
  */
8251
8674
  async readAddonStoreWithRetry() {
8252
- const settings = this._ctx?.settings;
8675
+ const settings = this.rawSettings();
8253
8676
  if (!settings) return {};
8254
8677
  const delaysMs = [
8255
8678
  150,
@@ -10552,6 +10975,278 @@ var CameraSwitchGroupSchema = object({
10552
10975
  fetchedAt: number()
10553
10976
  });
10554
10977
  /**
10978
+ * The trainer contract — what the hub hands the cloud trainer and what it
10979
+ * gets back (cloud training, D805+).
10980
+ *
10981
+ * The trainer (`hf/camstack-trainer`, published as the Hugging Face repo
10982
+ * `camstack/camstack-trainer`) is a separate AGPL program the hub never
10983
+ * imports: `job.json` goes in, files come out, and progress is `CAMSTACK_EVENT`
10984
+ * lines on stdout. These schemas are the hub's half of that boundary; the
10985
+ * trainer's pydantic models (and the JSON Schemas generated from them under
10986
+ * `hf/camstack-trainer/schemas/`) are the other half. A change here is a
10987
+ * change there, in the same piece of work.
10988
+ *
10989
+ * No `.default()` anywhere: defaults do not run on the addon cap path, so the
10990
+ * orchestrator fills every field of a job spec explicitly.
10991
+ */
10992
+ var TRAINING_JOB_SCHEMA = "camstack.training/v1";
10993
+ var TRAINING_RESULT_SCHEMA = "camstack.training-result/v1";
10994
+ /** What the trainer can export. Edge TPU is a later, separate image. */
10995
+ var TrainingExportSchema = _enum([
10996
+ "onnx",
10997
+ "openvino-fp16",
10998
+ "openvino-int8",
10999
+ "coreml-fp16"
11000
+ ]);
11001
+ var FloorsSchema = record(string(), number().min(0).max(1));
11002
+ object({
11003
+ schema: literal(TRAINING_JOB_SCHEMA),
11004
+ jobKey: string().uuid(),
11005
+ target: object({
11006
+ kind: literal("detector"),
11007
+ step: literal("object-detection")
11008
+ }),
11009
+ base: object({
11010
+ modelId: string().min(1),
11011
+ /** Ultralytics weights id, e.g. `yolov9m.pt`. */
11012
+ weights: string().min(1),
11013
+ imgsz: number().int().positive()
11014
+ }),
11015
+ baseline: object({
11016
+ modelId: string().min(1),
11017
+ /** The baseline ONNX the holdout comparison runs; public mirror URL. */
11018
+ onnxUrl: string().url(),
11019
+ imgsz: number().int().positive(),
11020
+ floors: FloorsSchema
11021
+ }),
11022
+ dataset: object({
11023
+ versionId: string().min(1),
11024
+ annotationHash: string(),
11025
+ /** sha256 of the uploaded archive; the trainer refuses a mismatch (exit 65). */
11026
+ sha256: string().regex(/^[0-9a-f]{64}$/)
11027
+ }),
11028
+ split: object({
11029
+ holdoutCameras: array(number().int()),
11030
+ /** When no camera is held out: the last N days of every camera. */
11031
+ holdoutLastDays: number().int().nonnegative(),
11032
+ valFraction: number().min(0).max(.5),
11033
+ seed: number().int()
11034
+ }),
11035
+ hyper: object({
11036
+ epochs: number().int().positive(),
11037
+ batch: number().int().positive(),
11038
+ lr0: number().positive(),
11039
+ /** Layers frozen from the start of the backbone; 0 = none. */
11040
+ freeze: number().int().nonnegative(),
11041
+ patience: number().int().nonnegative(),
11042
+ seed: number().int()
11043
+ }),
11044
+ replay: object({
11045
+ source: literal("coco2017"),
11046
+ count: number().int().nonnegative()
11047
+ }),
11048
+ exports: array(TrainingExportSchema).min(1),
11049
+ calibration: object({ maxFrames: number().int().positive() }),
11050
+ floors: object({
11051
+ minSupport: number().int().positive(),
11052
+ clamp: number().min(0).max(1)
11053
+ }),
11054
+ int8Gate: object({ maxMap50Drop: number().min(0).max(1) }),
11055
+ catalog: object({
11056
+ id: string().regex(/^[a-z0-9][a-z0-9-]{2,80}$/),
11057
+ name: string().min(1).max(160)
11058
+ })
11059
+ });
11060
+ /** One regular file of the bundle. An mlpackage contributes one row per member. */
11061
+ var TrainingResultFileSchema = object({
11062
+ path: string().min(1),
11063
+ bytes: number().int().nonnegative(),
11064
+ sha256: string().regex(/^[0-9a-f]{64}$/),
11065
+ format: _enum([
11066
+ "onnx",
11067
+ "openvino",
11068
+ "coreml",
11069
+ "pt"
11070
+ ]),
11071
+ variant: _enum(["base", "int8"])
11072
+ });
11073
+ var DraftFormatSchema = object({
11074
+ /** RELATIVE path inside the bundle; the hub rewrites it to `camstack-local://`. */
11075
+ url: string().min(1),
11076
+ sizeMB: number().nonnegative(),
11077
+ isDirectory: boolean().optional(),
11078
+ files: array(string()).optional(),
11079
+ runtimes: array(literal("python")).optional(),
11080
+ revision: string().min(1)
11081
+ });
11082
+ /** The trainer's half of a catalog entry; the hub completes it (labels, licence, group). */
11083
+ var TrainingCatalogDraftSchema = object({
11084
+ id: string().min(1),
11085
+ name: string().min(1),
11086
+ description: string(),
11087
+ labels: array(unknown()),
11088
+ inputSize: object({
11089
+ width: number().int().positive(),
11090
+ height: number().int().positive()
11091
+ }),
11092
+ preprocessMode: literal("letterbox"),
11093
+ defaultClassFloors: FloorsSchema,
11094
+ formats: object({
11095
+ onnx: DraftFormatSchema.optional(),
11096
+ openvino: DraftFormatSchema.optional(),
11097
+ coreml: DraftFormatSchema.optional()
11098
+ })
11099
+ });
11100
+ /** One class of one model's holdout report (the eval harness's summary). */
11101
+ var TrainingEvalClassSchema = object({
11102
+ positives: number().int(),
11103
+ floor: number().nullable(),
11104
+ tp: number().int(),
11105
+ fp: number().int(),
11106
+ fn: number().int(),
11107
+ precision: number().nullable(),
11108
+ recall: number().nullable(),
11109
+ ap50: number().nullable(),
11110
+ recallByCamera: record(string(), number().nullable()).optional(),
11111
+ recallByLight: record(string(), number().nullable()).optional(),
11112
+ fpByCamera: record(string(), number()).optional(),
11113
+ smallFound: number().int().optional(),
11114
+ smallTotal: number().int().optional()
11115
+ }).passthrough();
11116
+ var TrainingEvalReportSchema = object({
11117
+ frames: number().int(),
11118
+ classes: record(string(), TrainingEvalClassSchema)
11119
+ }).passthrough();
11120
+ /**
11121
+ * A succeeded result carries every block; a failed one carries the error and
11122
+ * whatever was known by then — the other blocks are ABSENT, not null. The
11123
+ * orchestrator checks the blocks it needs before it trusts a success.
11124
+ */
11125
+ var TrainingResultSchema = object({
11126
+ schema: literal(TRAINING_RESULT_SCHEMA),
11127
+ jobKey: string(),
11128
+ status: _enum(["succeeded", "failed"]),
11129
+ error: object({
11130
+ stage: string(),
11131
+ code: string(),
11132
+ message: string()
11133
+ }).nullable(),
11134
+ trainer: object({
11135
+ version: string(),
11136
+ revision: string()
11137
+ }),
11138
+ toolchain: record(string(), string().nullable()),
11139
+ dataset: object({
11140
+ versionId: string(),
11141
+ annotationHash: string(),
11142
+ sha256: string(),
11143
+ frames: object({
11144
+ train: number().int(),
11145
+ val: number().int(),
11146
+ holdout: number().int()
11147
+ }),
11148
+ holdoutCameras: array(number().int()),
11149
+ replayImages: number().int()
11150
+ }).optional(),
11151
+ training: object({
11152
+ epochsRun: number().int(),
11153
+ bestEpoch: number().int(),
11154
+ bestMap50: number(),
11155
+ bestMap50_95: number(),
11156
+ seconds: number()
11157
+ }).optional(),
11158
+ evaluation: object({
11159
+ holdoutFrames: number().int(),
11160
+ baseline: TrainingEvalReportSchema.nullable(),
11161
+ candidate: TrainingEvalReportSchema.nullable(),
11162
+ candidateInt8: TrainingEvalReportSchema.nullable(),
11163
+ recallDeltaByCamera: record(string(), record(string(), number())).nullable(),
11164
+ map50: record(string(), number().nullable())
11165
+ }).optional(),
11166
+ floors: object({
11167
+ baseline: FloorsSchema,
11168
+ candidate: FloorsSchema,
11169
+ candidateInt8: FloorsSchema.nullable(),
11170
+ notes: array(string())
11171
+ }).optional(),
11172
+ int8: object({
11173
+ kept: boolean(),
11174
+ map50Fp16: number().nullable(),
11175
+ map50Int8: number().nullable(),
11176
+ reason: string().nullable()
11177
+ }).optional(),
11178
+ exportsDropped: array(object({
11179
+ export: string(),
11180
+ reason: string()
11181
+ })).optional(),
11182
+ files: array(TrainingResultFileSchema).optional(),
11183
+ bundle: object({
11184
+ path: literal("bundle.tar"),
11185
+ bytes: number().int().nonnegative(),
11186
+ sha256: string().regex(/^[0-9a-f]{64}$/)
11187
+ }).nullable().optional(),
11188
+ catalogDraft: object({
11189
+ base: TrainingCatalogDraftSchema,
11190
+ int8: TrainingCatalogDraftSchema.nullable()
11191
+ }).nullable().optional(),
11192
+ licence: string()
11193
+ });
11194
+ var TrainingStageSchema = _enum([
11195
+ "prepare",
11196
+ "replay",
11197
+ "train",
11198
+ "eval",
11199
+ "export",
11200
+ "package"
11201
+ ]);
11202
+ var EventBase = {
11203
+ v: literal(1),
11204
+ ts: number()
11205
+ };
11206
+ discriminatedUnion("type", [
11207
+ object({
11208
+ ...EventBase,
11209
+ type: literal("stage"),
11210
+ stage: TrainingStageSchema
11211
+ }),
11212
+ object({
11213
+ ...EventBase,
11214
+ type: literal("epoch"),
11215
+ epoch: number().int(),
11216
+ epochs: number().int(),
11217
+ boxLoss: number().nullable().optional(),
11218
+ map50: number().nullable().optional(),
11219
+ map50_95: number().nullable().optional(),
11220
+ etaSec: number().nullable().optional()
11221
+ }),
11222
+ object({
11223
+ ...EventBase,
11224
+ type: literal("metric"),
11225
+ name: string(),
11226
+ value: number()
11227
+ }),
11228
+ object({
11229
+ ...EventBase,
11230
+ type: literal("artifact"),
11231
+ path: string(),
11232
+ bytes: number(),
11233
+ sha256: string()
11234
+ }),
11235
+ object({
11236
+ ...EventBase,
11237
+ type: literal("done"),
11238
+ status: _enum(["succeeded", "failed"]),
11239
+ resultSha256: string().nullable().optional()
11240
+ }),
11241
+ object({
11242
+ ...EventBase,
11243
+ type: literal("error"),
11244
+ stage: string(),
11245
+ code: string(),
11246
+ message: string()
11247
+ })
11248
+ ]);
11249
+ /**
10555
11250
  * What the gate decided about a birth, from the CALLER's point of view.
10556
11251
  *
10557
11252
  * Deliberately not `ConfirmationVerdict`: `undecided` is not a birth decision
@@ -12879,7 +13574,9 @@ var AddonHttpRouteSchema = object({
12879
13574
  "authenticated",
12880
13575
  "admin"
12881
13576
  ]).optional(),
12882
- description: string().optional()
13577
+ description: string().optional(),
13578
+ /** The hub limits this route per client address before the handler runs. */
13579
+ rateLimit: _enum(["auth"]).optional()
12883
13580
  });
12884
13581
  /**
12885
13582
  * Cross-process route invocation envelope. The hub captures the
@@ -13584,6 +14281,37 @@ var BackupDestinationInfoSchema = object({
13584
14281
  lastError: string().optional()
13585
14282
  });
13586
14283
  /**
14284
+ * How an archive is encrypted (operator decision 2026-10-09): to a backup
14285
+ * PUBLIC key the hub holds, so only the operator's secret key opens it.
14286
+ * Absent on a plain `.tar.gz` — every archive made before encryption, or
14287
+ * with it off — which restores without a key.
14288
+ */
14289
+ var BackupArchiveEncryptionSchema = object({
14290
+ /** `x25519-hkdf-aes256gcm-stream-v1`. */
14291
+ scheme: string(),
14292
+ /** 16 hex — the backup key whose secret restores this archive. */
14293
+ keyId: string()
14294
+ });
14295
+ /**
14296
+ * The backup encryption setting. The hub keeps PUBLIC keys only: the active
14297
+ * one new archives are encrypted to, and the retired ones older archives
14298
+ * still need. The secret key is shown once, at `setupEncryption`.
14299
+ */
14300
+ var BackupEncryptionStatusSchema = object({
14301
+ enabled: boolean(),
14302
+ active: object({
14303
+ keyId: string(),
14304
+ publicKey: string(),
14305
+ createdAt: number()
14306
+ }).nullable(),
14307
+ /** Every key ever set up, newest first. */
14308
+ keys: array(object({
14309
+ keyId: string(),
14310
+ createdAt: number(),
14311
+ retiredAt: number().nullable()
14312
+ })).readonly()
14313
+ });
14314
+ /**
13587
14315
  * Per-archive entry returned by `backup.listArchives({ destinationId })`.
13588
14316
  * Same shape the destination drill-in renders. Sourced from the per-
13589
14317
  * location `manifests.json` (no per-archive tarball read required).
@@ -13595,7 +14323,9 @@ var BackupArchiveEntrySchema = object({
13595
14323
  sizeBytes: number(),
13596
14324
  label: string().optional(),
13597
14325
  /** Top-level locations included in the archive (db, addons, tls, …). */
13598
- locations: array(string()).readonly()
14326
+ locations: array(string()).readonly(),
14327
+ /** Present when the archive is encrypted; restore then needs that key. */
14328
+ encryption: BackupArchiveEncryptionSchema.optional()
13599
14329
  });
13600
14330
  var BackupEntrySchema = object({
13601
14331
  id: string(),
@@ -13604,7 +14334,8 @@ var BackupEntrySchema = object({
13604
14334
  label: string().optional(),
13605
14335
  createdAt: number(),
13606
14336
  sizeBytes: number(),
13607
- locations: array(string()).optional()
14337
+ locations: array(string()).optional(),
14338
+ encryption: BackupArchiveEncryptionSchema.optional()
13608
14339
  });
13609
14340
  var ArchiveEntrySchema = object({
13610
14341
  path: string(),
@@ -13793,10 +14524,40 @@ method(_void(), array(BackupDestinationInfoSchema).readonly(), { auth: "admin" }
13793
14524
  * this list and skips entries whose path doesn't start with
13794
14525
  * any of them.
13795
14526
  */
13796
- locations: array(string()).optional()
14527
+ locations: array(string()).optional(),
14528
+ /**
14529
+ * The backup SECRET key, for an encrypted archive (ignored for a plain
14530
+ * one). The archive is decrypted into the hub's private staging
14531
+ * before the restart; the key is not stored. A wrong or missing key
14532
+ * is refused before the archive is downloaded.
14533
+ */
14534
+ backupSecretKey: string().optional()
13797
14535
  }), _void(), {
13798
14536
  kind: "mutation",
13799
14537
  auth: "admin"
14538
+ }), method(_void(), BackupEncryptionStatusSchema, { auth: "admin" }), method(object({}), object({
14539
+ keyId: string(),
14540
+ secretKey: string(),
14541
+ publicKey: string(),
14542
+ createdAt: number(),
14543
+ replacedKeyId: string().nullable()
14544
+ }), {
14545
+ kind: "mutation",
14546
+ auth: "admin"
14547
+ }), method(object({}), object({ disabledKeyId: string().nullable() }), {
14548
+ kind: "mutation",
14549
+ auth: "admin"
14550
+ }), method(object({ backupSecretKey: string() }), object({
14551
+ valid: boolean(),
14552
+ keyId: string().nullable(),
14553
+ /** The hub knows this key (active or retired). */
14554
+ known: boolean(),
14555
+ /** It is the key new archives are encrypted to. */
14556
+ active: boolean(),
14557
+ error: string().optional()
14558
+ }), {
14559
+ kind: "mutation",
14560
+ auth: "admin"
13800
14561
  }), method(object({
13801
14562
  destinationId: string(),
13802
14563
  backupId: string()
@@ -15522,7 +16283,60 @@ var CustomModelDescriptorSchema = object({
15522
16283
  stepId: string(),
15523
16284
  entry: ModelCatalogEntrySchema
15524
16285
  });
15525
- method(_void(), array(CustomModelDescriptorSchema).readonly(), { auth: "admin" });
16286
+ /** One regular file of an imported bundle, as the producer measured it. */
16287
+ var ModelBundleFileSchema = object({
16288
+ /** Relative path inside the bundle tar; an mlpackage member is `<x>.mlpackage/<member>`. */
16289
+ path: string().min(1),
16290
+ bytes: number().int().nonnegative(),
16291
+ sha256: string().regex(/^[0-9a-f]{64}$/)
16292
+ });
16293
+ var ImportModelBundleInputSchema = object({
16294
+ /** The registry provider that keeps the model (Model Studio). */
16295
+ addonId: string(),
16296
+ stepId: string().min(1),
16297
+ /**
16298
+ * The catalog rows to register, complete, every format URL already
16299
+ * `camstack-local://<modelId>/<file>` naming a file of the bundle. One
16300
+ * bundle may carry several rows (a base and its INT8 variant).
16301
+ */
16302
+ entries: array(ModelCatalogEntrySchema).min(1).max(4),
16303
+ /** The bundle tar, offered by the producer over `ctx.peerBytes` (same host). */
16304
+ bundle: object({
16305
+ ticket: PeerBytesTicketSchema,
16306
+ bytes: number().int().positive(),
16307
+ sha256: string().regex(/^[0-9a-f]{64}$/)
16308
+ }),
16309
+ /** Every file the tar must hold; anything missing, extra or different is refused. */
16310
+ files: array(ModelBundleFileSchema).min(1).max(64),
16311
+ /** Convert missing engine formats and push the model to every agent afterwards. */
16312
+ distribute: boolean()
16313
+ });
16314
+ var ImportModelBundleResultSchema = discriminatedUnion("kind", [object({
16315
+ kind: literal("imported"),
16316
+ modelIds: array(string()).readonly(),
16317
+ distributed: array(object({
16318
+ modelId: string(),
16319
+ nodeId: string(),
16320
+ format: _enum(MODEL_FORMATS),
16321
+ ok: boolean(),
16322
+ error: string().optional()
16323
+ })).readonly()
16324
+ }), object({
16325
+ kind: literal("refused"),
16326
+ reason: _enum([
16327
+ "transfer-failed",
16328
+ "checksum-mismatch",
16329
+ "bundle-mismatch",
16330
+ "invalid-entry",
16331
+ "id-taken"
16332
+ ]),
16333
+ detail: string()
16334
+ })]);
16335
+ method(_void(), array(CustomModelDescriptorSchema).readonly(), { auth: "admin" }), method(ImportModelBundleInputSchema, ImportModelBundleResultSchema, {
16336
+ kind: "mutation",
16337
+ auth: "admin",
16338
+ timeoutMs: 30 * 6e4
16339
+ });
15526
16340
  /**
15527
16341
  * Query filter for settings-store collections.
15528
16342
  */
@@ -16001,6 +16815,35 @@ var KeychainKeySourceSchema = object({
16001
16815
  */
16002
16816
  sharesBackupWithDatabase: boolean()
16003
16817
  });
16818
+ /**
16819
+ * One keychain reset, as the Secrets page reports it until the operator
16820
+ * acknowledges it. Never a value: refs, counts and table names only.
16821
+ */
16822
+ var KeychainResetRecordSchema = object({
16823
+ id: string(),
16824
+ at: number(),
16825
+ /** `user:<id>` or {@link KEYCHAIN_RESET_TRIGGER_ACTOR}. */
16826
+ actor: string(),
16827
+ /** Why the keychain was locked when it was reset; `null` when it was not locked. */
16828
+ lockedReason: string().nullable(),
16829
+ /** Values moved into the archive table (ciphertext under the lost key). */
16830
+ archived: number().int(),
16831
+ /** `keychain:secrets-orphaned-<ts>`, or `null` when nothing was stored. */
16832
+ archivedCollection: string().nullable(),
16833
+ /**
16834
+ * `keychain:keys-orphaned-<ts>`: the wrapped data keys of the archive, kept
16835
+ * so the archive can still be opened if the lost master key turns up.
16836
+ */
16837
+ archivedKeysCollection: string().nullable(),
16838
+ /**
16839
+ * `system-settings` keys whose marker the reset cleared — the cluster
16840
+ * secret's: a marker left pointing at an archived value would refuse every
16841
+ * agent forever (D797).
16842
+ */
16843
+ clearedSettingsKeys: array(string()).readonly(),
16844
+ /** When an operator dismissed the notice on the Secrets page; `null` until then. */
16845
+ acknowledgedAt: number().nullable()
16846
+ });
16004
16847
  var KeychainStatusSchema = object({
16005
16848
  keychain: KeychainStateSchema,
16006
16849
  /** The source of the master key in use; `null` while locked. */
@@ -16018,7 +16861,9 @@ var KeychainStatusSchema = object({
16018
16861
  /** Wrapped copies of the data key under a previous master key, kept until purged. */
16019
16862
  retiredWraps: number().int(),
16020
16863
  recoveryKeyDownloadedAt: number().nullable(),
16021
- secretCount: number().int()
16864
+ secretCount: number().int(),
16865
+ /** The most recent reset, acknowledged or not; `null` when the keychain was never reset. */
16866
+ lastReset: KeychainResetRecordSchema.nullable()
16022
16867
  });
16023
16868
  /**
16024
16869
  * Whether a stored value is still pointed at by its owner's settings.
@@ -16040,17 +16885,26 @@ var KeychainAuditActionSchema = _enum([
16040
16885
  "download-recovery-key",
16041
16886
  "delete-orphans",
16042
16887
  "reset",
16888
+ "acknowledge-reset",
16043
16889
  "initialize"
16044
16890
  ]);
16045
16891
  var KeychainAuditEntrySchema = object({
16046
16892
  id: string(),
16047
16893
  at: number(),
16048
16894
  action: KeychainAuditActionSchema,
16049
- /** `addon:<id>` | `user:<id>` | `system`. */
16895
+ /** `addon:<id>` | `user:<id>` | `system` | `trigger-file`. */
16050
16896
  actor: string(),
16051
16897
  ref: string().nullable(),
16052
16898
  detail: string().nullable()
16053
16899
  });
16900
+ var KEYCHAIN_RESET_CONFIRMATION = "RESET KEYCHAIN";
16901
+ /**
16902
+ * Secrets the HUB itself holds (owner `system`) that no settings form shows:
16903
+ * `jwt-signing-key` — the session signing key (D797). It is always "in use",
16904
+ * never an orphan; it is generated on a fresh hub and replaced only through
16905
+ * {@link keychainAdminCapability.methods.setSystemSecret}.
16906
+ */
16907
+ var SystemHeldSecretNameSchema = _enum(["jwt-signing-key"]);
16054
16908
  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({
16055
16909
  value: string(),
16056
16910
  version: number().int()
@@ -16058,6 +16912,16 @@ method(object({}), KeychainStatusSchema, { auth: "admin" }), method(object({}),
16058
16912
  kind: "mutation",
16059
16913
  auth: "admin",
16060
16914
  caller: "required"
16915
+ }), method(object({
16916
+ name: SystemHeldSecretNameSchema,
16917
+ value: string().min(16)
16918
+ }), object({
16919
+ ref: string(),
16920
+ version: number().int()
16921
+ }), {
16922
+ kind: "mutation",
16923
+ auth: "admin",
16924
+ caller: "required"
16061
16925
  }), method(object({ refs: array(string().min(1)).max(1e3) }), object({
16062
16926
  deleted: array(string()).readonly(),
16063
16927
  kept: array(object({
@@ -16087,13 +16951,20 @@ method(object({}), KeychainStatusSchema, { auth: "admin" }), method(object({}),
16087
16951
  kind: "mutation",
16088
16952
  auth: "admin",
16089
16953
  caller: "required"
16090
- }), method(object({ confirm: literal("RESET KEYCHAIN") }), object({
16954
+ }), method(object({ confirm: literal(KEYCHAIN_RESET_CONFIRMATION) }), object({
16091
16955
  archivedCollection: string().nullable(),
16092
16956
  archived: number().int()
16093
16957
  }), {
16094
16958
  kind: "mutation",
16095
16959
  auth: "admin",
16096
16960
  caller: "required"
16961
+ }), method(object({}), object({
16962
+ reset: KeychainResetRecordSchema.nullable(),
16963
+ pendingReentry: array(KeychainSecretMetaSchema).readonly()
16964
+ }), { auth: "admin" }), method(object({}), object({ acknowledged: boolean() }), {
16965
+ kind: "mutation",
16966
+ auth: "admin",
16967
+ caller: "required"
16097
16968
  });
16098
16969
  method(_void(), object({
16099
16970
  id: string(),
@@ -18944,7 +19815,7 @@ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
18944
19815
  * `login-method` — collection cap through which auth addons contribute
18945
19816
  * their pre-auth login surfaces to the login page. This is the SINGLE,
18946
19817
  * generic mechanism that supersedes the dead `auth.listProviders` reader:
18947
- * every auth addon (OIDC, magic-link, WebAuthn/passkey) registers a
19818
+ * every auth addon (OIDC, WebAuthn/passkey) registers a
18948
19819
  * `login-method` provider and the PUBLIC `auth.listLoginMethods`
18949
19820
  * procedure aggregates them for the unauthenticated login page.
18950
19821
  *
@@ -18952,8 +19823,7 @@ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
18952
19823
  *
18953
19824
  * - `redirect` — a declarative button. The login page renders a generic
18954
19825
  * button that navigates to `startUrl` (an addon-owned HTTP route).
18955
- * Covers OIDC (`/addon/auth-oidc/<id>/start`) and magic-link with
18956
- * ZERO shell-side JS. A future SSO addon plugs in the same way — the
19826
+ * Covers OIDC (`/addon/auth-oidc/<id>/start`) with ZERO shell-side JS. A future SSO addon plugs in the same way — the
18957
19827
  * login page needs NO change.
18958
19828
  *
18959
19829
  * - `widget` — a Module-Federation widget the login page mounts (via
@@ -18972,8 +19842,8 @@ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
18972
19842
  * decision.
18973
19843
  *
18974
19844
  * Every contribution carries a `stage`:
18975
- * - `primary` — shown on the first credentials screen (OIDC /
18976
- * magic-link buttons; a future usernameless passkey).
19845
+ * - `primary` — shown on the first credentials screen (OIDC
19846
+ * buttons; a usernameless passkey).
18977
19847
  * - `second-factor` — shown AFTER the password leg, gated on the
18978
19848
  * returned `factors` (passkey-as-2FA today).
18979
19849
  *
@@ -19000,7 +19870,7 @@ var LoginMethodContributionSchema = discriminatedUnion("kind", [
19000
19870
  * The provider names an external identity a signed-in user can link to
19001
19871
  * their own account (D782): `auth.listLinkableProviders` /
19002
19872
  * `beginExternalLink` offer exactly the redirect methods that set this,
19003
- * whatever their id. Absent / false — a login button only (magic-link).
19873
+ * whatever their id. Absent / false — a login button only.
19004
19874
  */
19005
19875
  linkable: boolean().optional()
19006
19876
  }),
@@ -22855,8 +23725,7 @@ method(object({}), object({ rules: array(NcRuleSchema) }), { auth: "admin" }), m
22855
23725
  * `super_admin` — collapsed onto the single boolean because every
22856
23726
  * non-admin caller is governed by the same scope-check rules; the
22857
23727
  * distinction was only ever used to route role-specific procedures
22858
- * which we no longer have. Agents are admin sessions issued via
22859
- * `createServiceToken`; CLI / webhook integrations are `cst_*` tokens
23728
+ * which we no longer have. CLI / webhook integrations are `cst_*` tokens
22860
23729
  * with `isAdmin: false` + an explicit scope list.
22861
23730
  */
22862
23731
  /** Per-method access flavour. Materialised on every cap method via codegen. */
@@ -24531,6 +25400,9 @@ var RetrainExportFilterSchema = object({
24531
25400
  frameIds: array(string()).max(2e4).optional(),
24532
25401
  /** Only frames in at least one of these named collections. */
24533
25402
  collectionIds: array(string()).max(200).optional(),
25403
+ /** Exactly the frames of this dataset version (and its completeOnly). An
25404
+ * unknown id selects nothing. */
25405
+ datasetVersionId: string().optional(),
24534
25406
  batchId: string().optional(),
24535
25407
  /** Only frames the operator marked complete (all subjects boxed). */
24536
25408
  completeOnly: boolean().optional()
@@ -24698,6 +25570,67 @@ var RetrainLlmAssistResultSchema = discriminatedUnion("kind", [object({
24698
25570
  ]),
24699
25571
  detail: string().optional()
24700
25572
  })]);
25573
+ /** What a dataset version is cut from. Every field narrows. */
25574
+ var RetrainDatasetSelectionSchema = object({
25575
+ deviceIds: array(number()).readonly().optional(),
25576
+ collectionIds: array(string()).max(200).readonly().optional(),
25577
+ frameIds: array(string()).max(2e4).readonly().optional()
25578
+ });
25579
+ /** The counts a dataset is judged by. */
25580
+ var RetrainDatasetStatsSchema = object({
25581
+ frames: number().int(),
25582
+ completeFrames: number().int(),
25583
+ /** `completeFrames / frames`, 0..1. */
25584
+ completeness: number(),
25585
+ /** Boxes to learn (model errors excluded). */
25586
+ subjects: number().int(),
25587
+ modelErrors: number().int(),
25588
+ /** Complete frames with no subject. */
25589
+ hardNegatives: number().int(),
25590
+ /** Subjects per class × camera × day/night. */
25591
+ cells: array(object({
25592
+ macroClass: string(),
25593
+ deviceId: number(),
25594
+ lighting: _enum([
25595
+ "day",
25596
+ "night",
25597
+ "unknown"
25598
+ ]),
25599
+ subjects: number().int(),
25600
+ frames: number().int()
25601
+ })).readonly(),
25602
+ cameras: array(object({
25603
+ deviceId: number(),
25604
+ frames: number().int(),
25605
+ completeFrames: number().int()
25606
+ })).readonly()
25607
+ });
25608
+ /** An immutable dataset version, without its frame list. */
25609
+ var RetrainDatasetVersionSchema = object({
25610
+ id: string(),
25611
+ name: string(),
25612
+ createdAt: number(),
25613
+ selection: RetrainDatasetSelectionSchema,
25614
+ layout: RetrainExportLayoutSchema,
25615
+ completeOnly: boolean(),
25616
+ frameCount: number().int(),
25617
+ /** sha256 of what the frames taught when the version was frozen. */
25618
+ annotationHash: string(),
25619
+ /** The export manifest schema the version was cut under. */
25620
+ manifestSchema: string(),
25621
+ stats: RetrainDatasetStatsSchema
25622
+ });
25623
+ var CreateRetrainDatasetVersionResultSchema = discriminatedUnion("kind", [object({
25624
+ kind: literal("created"),
25625
+ version: RetrainDatasetVersionSchema
25626
+ }), object({
25627
+ kind: literal("refused"),
25628
+ reason: _enum([
25629
+ "empty-name",
25630
+ "duplicate-name",
25631
+ "no-frames"
25632
+ ])
25633
+ })]);
24701
25634
  /** The outcome of a lifecycle move owned by the retrain page. */
24702
25635
  var RetrainTransitionResultSchema = object({
24703
25636
  trackId: string(),
@@ -25487,6 +26420,47 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
25487
26420
  kind: "mutation",
25488
26421
  auth: "admin",
25489
26422
  timeoutMs: 60 * 6e4
26423
+ }), method(object({
26424
+ filter: RetrainExportFilterSchema,
26425
+ layout: RetrainExportLayoutSchema
26426
+ }), object({
26427
+ ticket: PeerBytesTicketSchema,
26428
+ frames: number().int(),
26429
+ annotations: number().int()
26430
+ }), {
26431
+ kind: "mutation",
26432
+ auth: "admin",
26433
+ timeoutMs: 12e4
26434
+ }), method(object({
26435
+ selection: RetrainDatasetSelectionSchema,
26436
+ completeOnly: boolean().optional()
26437
+ }), RetrainDatasetStatsSchema, {
26438
+ kind: "query",
26439
+ auth: "admin"
26440
+ }), method(object({
26441
+ name: string().max(120),
26442
+ selection: RetrainDatasetSelectionSchema,
26443
+ layout: RetrainExportLayoutSchema,
26444
+ completeOnly: boolean()
26445
+ }), CreateRetrainDatasetVersionResultSchema, {
26446
+ kind: "mutation",
26447
+ auth: "admin",
26448
+ timeoutMs: 12e4
26449
+ }), method(object({}), array(RetrainDatasetVersionSchema).readonly(), {
26450
+ kind: "query",
26451
+ auth: "admin"
26452
+ }), method(object({ id: string() }), object({ deleted: boolean() }), {
26453
+ kind: "mutation",
26454
+ auth: "admin"
26455
+ }), method(object({ id: string() }), object({
26456
+ found: boolean(),
26457
+ annotationHash: string(),
26458
+ matches: boolean(),
26459
+ missingFrames: number().int()
26460
+ }), {
26461
+ kind: "query",
26462
+ auth: "admin",
26463
+ timeoutMs: 12e4
25490
26464
  }), method(object({}), array(RetrainAssistProfileSchema).readonly(), {
25491
26465
  kind: "query",
25492
26466
  auth: "admin"
@@ -29065,8 +30039,8 @@ version: string().optional() }), ServerUpdateActionResultSchema, {
29065
30039
  * `smtp-provider` — pluggable email delivery surface.
29066
30040
  *
29067
30041
  * Collection cap: a deployment may install multiple SMTP relays (e.g.
29068
- * one for transactional / one for notifications). Consumers (magic-link,
29069
- * notifier addons, …) walk the collection and pick the first
30042
+ * one for transactional / one for notifications). Consumers (notifier
30043
+ * addons, …) walk the collection and pick the first
29070
30044
  * ready provider OR target a specific addonId.
29071
30045
  *
29072
30046
  * The shape stays small on purpose — `sendEmail` is enough for the
@@ -29245,7 +30219,7 @@ targets: array(object({
29245
30219
  })));
29246
30220
  /**
29247
30221
  * `sso-bridge` — internal hub-only cap that lets SSO-style auth
29248
- * providers (OIDC, SAML, magic-link, …) mint an HMAC-signed token
30222
+ * providers (OIDC, SAML, …) mint an HMAC-signed token
29249
30223
  * carrying the post-callback claims before redirecting back to
29250
30224
  * `/api/auth/sso/finish`.
29251
30225
  *
@@ -29308,7 +30282,14 @@ var SsoBridgeClaimsSchema = object({
29308
30282
  * Verified `iss` of the id_token behind an OIDC login bridge (D782). A
29309
30283
  * subject is unique only per issuer, so a link is bound to it.
29310
30284
  */
29311
- issuer: string().optional()
30285
+ issuer: string().optional(),
30286
+ /**
30287
+ * SHA-256 (hex) of the `camstack_sso_state` cookie the IdP `/start` set in
30288
+ * the browser that began this sign-in. `/api/auth/sso/finish` requires the
30289
+ * request to present the matching cookie — a login bridge is useless in
30290
+ * any other browser.
30291
+ */
30292
+ browserBinding: string().optional()
29312
30293
  });
29313
30294
  method(object({
29314
30295
  claims: SsoBridgeClaimsSchema,
@@ -41575,16 +42556,6 @@ var ApiKeySummarySchema = object({
41575
42556
  createdAt: number(),
41576
42557
  lastUsedAt: number().optional()
41577
42558
  });
41578
- var CreateApiKeyInputSchema = object({
41579
- label: string(),
41580
- isAdmin: boolean().default(false),
41581
- allowedProviders: union([array(string()), literal("*")]).optional(),
41582
- allowedDevices: record(string(), union([array(string()), literal("*")])).optional()
41583
- });
41584
- var CreateApiKeyResultSchema = object({
41585
- token: string(),
41586
- record: ApiKeySummarySchema
41587
- });
41588
42559
  var ScopedTokenSummarySchema = object({
41589
42560
  id: string(),
41590
42561
  userId: string(),
@@ -41683,17 +42654,10 @@ method(_void(), array(UserSummarySchema), { auth: "admin" }), method(CreateUserI
41683
42654
  }), UserSummarySchema.extend({ passwordHash: string() }).nullable(), {
41684
42655
  kind: "mutation",
41685
42656
  access: "view"
41686
- }), method(_void(), array(ApiKeySummarySchema), { auth: "admin" }), method(CreateApiKeyInputSchema, CreateApiKeyResultSchema, {
41687
- kind: "mutation",
41688
- auth: "admin",
41689
- access: "create"
41690
- }), method(object({ id: string() }), object({ success: literal(true) }), {
42657
+ }), method(_void(), array(ApiKeySummarySchema), { auth: "admin" }), method(object({ id: string() }), object({ success: literal(true) }), {
41691
42658
  kind: "mutation",
41692
42659
  auth: "admin",
41693
42660
  access: "delete"
41694
- }), method(object({ token: string() }), ApiKeySummarySchema.nullable(), {
41695
- kind: "mutation",
41696
- access: "view"
41697
42661
  }), method(CreateScopedTokenInputSchema, CreateScopedTokenResultSchema, {
41698
42662
  kind: "mutation",
41699
42663
  auth: "admin",
@@ -41767,15 +42731,7 @@ method(_void(), array(UserSummarySchema), { auth: "admin" }), method(CreateUserI
41767
42731
  }).nullable(), { access: "view" }), method(object({ userId: string() }), array(ExternalIdentitySchema), { auth: "admin" }), method(ExternalIdentityKeySchema, object({
41768
42732
  userId: string(),
41769
42733
  issuer: string()
41770
- }).nullable(), { auth: "admin" }), method(ExternalIdentityKeySchema.extend({
41771
- userId: string(),
41772
- issuer: string().min(1),
41773
- label: string().optional()
41774
- }), object({ success: literal(true) }), {
41775
- kind: "mutation",
41776
- auth: "admin",
41777
- access: "create"
41778
- }), method(ExternalIdentityKeySchema.extend({ userId: string() }), object({ success: boolean() }), {
42734
+ }).nullable(), { auth: "admin" }), method(ExternalIdentityKeySchema.extend({ userId: string() }), object({ success: boolean() }), {
41779
42735
  kind: "mutation",
41780
42736
  auth: "admin",
41781
42737
  access: "delete"
@@ -42480,6 +43436,451 @@ var zoneRulesCapability = {
42480
43436
  */
42481
43437
  durability: "restored"
42482
43438
  };
43439
+ /**
43440
+ * `training-provider` — ONE cloud that can run the CamStack trainer.
43441
+ *
43442
+ * A thin, mockable translation layer: it knows how to run a container with a
43443
+ * GPU, move a dataset in, read the job's stdout and hand artefacts back. It
43444
+ * knows nothing about datasets, splits, floors, cost policy or Model Studio —
43445
+ * those are the `training` orchestrator's (D805). Every rule written there
43446
+ * once is what makes a second provider (RunPod, a local NVIDIA node) a new
43447
+ * manifest entry and nothing else.
43448
+ *
43449
+ * Collection, routed by the `addonId` in every single-row input (the `llm` /
43450
+ * `notification-output` posture); `describe` concat-fans across providers.
43451
+ * Every method is `admin`: these spend money.
43452
+ *
43453
+ * Every cloud object a provider creates is tagged with the orchestrator's
43454
+ * `jobKey`, so a retried submit finds the job it already started instead of
43455
+ * starting a second GPU, and `listJobs` can find orphans.
43456
+ *
43457
+ * Bytes never ride a cap field: the dataset arrives as a `ctx.peerBytes`
43458
+ * ticket the producer (pipeline-analytics) minted, and artefacts leave as a
43459
+ * ticket the provider mints (D613).
43460
+ */
43461
+ var TrainingGpuOptionSchema = object({
43462
+ id: string(),
43463
+ label: string(),
43464
+ /** List price, USD per GPU-hour, before any region multiplier. */
43465
+ usdPerHour: number().nonnegative(),
43466
+ vramGb: number().nonnegative()
43467
+ });
43468
+ var TrainingRegionOptionSchema = object({
43469
+ /** `''` = any region (the provider's choice). */
43470
+ id: string(),
43471
+ label: string(),
43472
+ priceMultiplier: number().positive()
43473
+ });
43474
+ /**
43475
+ * The provider's per-account settings, as the orchestrator reads them. They
43476
+ * live in the PROVIDER addon's settings (operator decision 2026-10-08: they
43477
+ * depend on the user's account), never hard-coded in the orchestrator.
43478
+ */
43479
+ var TrainingProviderDefaultsSchema = object({
43480
+ gpuType: string(),
43481
+ region: string(),
43482
+ costCapUsd: number().nonnegative(),
43483
+ maxRuntimeSec: number().int().positive(),
43484
+ /** Hours a FAILED job's cloud dataset is kept for debugging; 0 = delete at once. */
43485
+ failedDatasetGraceHours: number().nonnegative()
43486
+ });
43487
+ var TrainingProviderDescriptorSchema = object({
43488
+ addonId: string(),
43489
+ /** `modal`, `runpod`, `fake`, … */
43490
+ kind: string(),
43491
+ label: string(),
43492
+ gpuTypes: array(TrainingGpuOptionSchema).readonly(),
43493
+ regions: array(TrainingRegionOptionSchema).readonly(),
43494
+ maxDatasetBytes: number().int().positive(),
43495
+ maxRuntimeSec: number().int().positive(),
43496
+ freeTierNote: string().optional(),
43497
+ /** Where the data goes, in one sentence the confirm dialog repeats. */
43498
+ dataResidencyNote: string(),
43499
+ /** Credentials are present — never the values. */
43500
+ configured: boolean(),
43501
+ defaults: TrainingProviderDefaultsSchema
43502
+ });
43503
+ var TrainingCredentialCheckSchema = object({
43504
+ ok: boolean(),
43505
+ /** Workspace / account name, when the provider says. */
43506
+ account: string().optional(),
43507
+ reason: _enum([
43508
+ "missing",
43509
+ "invalid",
43510
+ "forbidden",
43511
+ "network",
43512
+ "quota"
43513
+ ]).optional(),
43514
+ detail: string().optional()
43515
+ });
43516
+ var ProviderJobStateSchema = _enum([
43517
+ "pending",
43518
+ "starting",
43519
+ "running",
43520
+ "succeeded",
43521
+ "failed",
43522
+ "cancelled",
43523
+ "lost"
43524
+ ]);
43525
+ var ProviderJobStatusSchema = object({
43526
+ jobKey: string(),
43527
+ providerJobId: string().optional(),
43528
+ state: ProviderJobStateSchema,
43529
+ startedAt: number().optional(),
43530
+ endedAt: number().optional(),
43531
+ exitCode: number().int().optional(),
43532
+ failureReason: string().optional(),
43533
+ gpuType: string(),
43534
+ region: string().optional(),
43535
+ billedSeconds: number().nonnegative(),
43536
+ costUsd: number().nonnegative(),
43537
+ /** True when `costUsd` is runtime × list price, not a billing answer. */
43538
+ costIsEstimate: boolean(),
43539
+ lastFetchedAt: number()
43540
+ });
43541
+ /**
43542
+ * The trainer the job runs, by SOURCE revision: the provider turns it into an
43543
+ * image its own way (Modal builds the published Dockerfile at that revision;
43544
+ * a registry-pull provider maps it to a tag). Recorded on the job and echoed
43545
+ * in `result.json`.
43546
+ */
43547
+ var TrainerSourceRefSchema = object({
43548
+ /** Hugging Face repo id, e.g. `camstack/camstack-trainer`. */
43549
+ repo: string().min(1),
43550
+ /** A commit sha (never a branch) — the job must be reproducible. */
43551
+ revision: string().regex(/^[0-9a-f]{7,64}$/)
43552
+ });
43553
+ var JobRef = {
43554
+ addonId: string(),
43555
+ jobKey: string().uuid()
43556
+ };
43557
+ var TrainingLogLineSchema = object({
43558
+ ts: number(),
43559
+ text: string()
43560
+ });
43561
+ method(object({}), array(TrainingProviderDescriptorSchema).readonly(), { auth: "admin" }), method(object({ addonId: string() }), TrainingCredentialCheckSchema, {
43562
+ kind: "mutation",
43563
+ auth: "admin",
43564
+ timeoutMs: 3e4
43565
+ }), method(object({
43566
+ addonId: string(),
43567
+ gpuType: string(),
43568
+ region: string(),
43569
+ datasetBytes: number().int().nonnegative(),
43570
+ gpuSecondsLow: number().nonnegative(),
43571
+ gpuSecondsHigh: number().nonnegative()
43572
+ }), object({
43573
+ usdLow: number().nonnegative(),
43574
+ usdHigh: number().nonnegative(),
43575
+ notes: array(string()).readonly()
43576
+ }), { auth: "admin" }), method(object({
43577
+ ...JobRef,
43578
+ ticket: PeerBytesTicketSchema
43579
+ }), object({
43580
+ bytes: number().int().nonnegative(),
43581
+ sha256: string()
43582
+ }), {
43583
+ kind: "mutation",
43584
+ auth: "admin",
43585
+ timeoutMs: 120 * 6e4
43586
+ }), method(object({
43587
+ ...JobRef,
43588
+ trainer: TrainerSourceRefSchema,
43589
+ jobSpecJson: string().min(2).max(64e3),
43590
+ gpuType: string(),
43591
+ region: string(),
43592
+ maxRuntimeSec: number().int().positive()
43593
+ }), ProviderJobStatusSchema, {
43594
+ kind: "mutation",
43595
+ auth: "admin",
43596
+ timeoutMs: 30 * 6e4
43597
+ }), method(object(JobRef), ProviderJobStatusSchema, {
43598
+ auth: "admin",
43599
+ timeoutMs: 6e4
43600
+ }), method(object({
43601
+ ...JobRef,
43602
+ cursor: string().optional(),
43603
+ max: number().int().min(1).max(500)
43604
+ }), object({
43605
+ lines: array(TrainingLogLineSchema).readonly(),
43606
+ cursor: string()
43607
+ }), {
43608
+ auth: "admin",
43609
+ timeoutMs: 6e4
43610
+ }), method(object(JobRef), object({ ok: literal(true) }), {
43611
+ kind: "mutation",
43612
+ auth: "admin",
43613
+ timeoutMs: 6e4
43614
+ }), method(object(JobRef), object({
43615
+ found: boolean(),
43616
+ text: string().optional()
43617
+ }), {
43618
+ kind: "mutation",
43619
+ auth: "admin",
43620
+ timeoutMs: 5 * 6e4
43621
+ }), method(object({
43622
+ ...JobRef,
43623
+ path: _enum(["bundle.tar"])
43624
+ }), object({ ticket: PeerBytesTicketSchema }), {
43625
+ kind: "mutation",
43626
+ auth: "admin",
43627
+ timeoutMs: 5 * 6e4
43628
+ }), method(object(JobRef), object({ deleted: array(string()).readonly() }), {
43629
+ kind: "mutation",
43630
+ auth: "admin",
43631
+ timeoutMs: 5 * 6e4
43632
+ }), method(object({ addonId: string() }), array(ProviderJobStatusSchema).readonly(), {
43633
+ auth: "admin",
43634
+ timeoutMs: 2 * 6e4
43635
+ });
43636
+ /**
43637
+ * `training` — the cloud-training orchestrator (D805). Hub-only singleton,
43638
+ * provided by `addon-training`.
43639
+ *
43640
+ * It owns what every provider must agree on, written once:
43641
+ *
43642
+ * - **Dataset versions.** Taken over from pipeline-analytics (D796): the rows
43643
+ * live here (D808); pipeline-analytics still CUTS a version (it owns the corpus and
43644
+ * the export plan) and reaches this store through the five row methods
43645
+ * below, so the Retrain page and the export did not change.
43646
+ * - **Jobs.** A persisted state machine, a reconcile loop against the
43647
+ * provider, a cost guard, a daily orphan sweep and the retention rules.
43648
+ * - **The return flow.** Verified artefacts → Model Studio
43649
+ * (`custom-model-registry.importModelBundle`) → canary on cameras →
43650
+ * rollback. Nothing is ever registered automatically.
43651
+ *
43652
+ * Every method is `admin`.
43653
+ */
43654
+ /** A version WITH its frame list — what the export and a job read. */
43655
+ var TrainingDatasetVersionRowSchema = RetrainDatasetVersionSchema.omit({ frameCount: true }).extend({ frameIds: array(string()).max(2e4).readonly() });
43656
+ /** A base model a detector job can fine-tune, and the baseline it is judged against. */
43657
+ var TrainingBaseModelSchema = object({
43658
+ modelId: string(),
43659
+ label: string(),
43660
+ weights: string(),
43661
+ imgsz: number().int(),
43662
+ baselineOnnxUrl: string(),
43663
+ baselineFloors: record(string(), number()),
43664
+ /** The base the fleet runs most — the UI's default. */
43665
+ recommended: boolean()
43666
+ });
43667
+ var TrainingPresetSchema = _enum([
43668
+ "quick",
43669
+ "standard",
43670
+ "thorough"
43671
+ ]);
43672
+ var TrainingJobRequestSchema = object({
43673
+ datasetVersionId: string().min(1),
43674
+ /** The `training-provider` addon that runs it. */
43675
+ addonId: string().min(1),
43676
+ gpuType: string().min(1),
43677
+ region: string(),
43678
+ baseModelId: string().min(1),
43679
+ preset: TrainingPresetSchema,
43680
+ /** Freeze the backbone's first N layers; `null` = the preset's choice. */
43681
+ freeze: number().int().nonnegative().nullable(),
43682
+ /** Cameras held out whole for evaluation; `null` = the orchestrator's default. */
43683
+ holdoutCameras: array(number().int()).nullable()
43684
+ });
43685
+ var TrainingSplitPlanSchema = object({
43686
+ holdoutCameras: array(number().int()).readonly(),
43687
+ /** Used when no camera is held out: the last N days of every camera. */
43688
+ holdoutLastDays: number().int().nonnegative(),
43689
+ /** Holdout subjects per class (camera holdout only; `null` = known only after the split). */
43690
+ holdoutSupport: record(string(), number().int()).nullable(),
43691
+ trainSubjects: number().int()
43692
+ });
43693
+ var TrainingRefusalReasonSchema = _enum([
43694
+ "unknown-dataset",
43695
+ "unknown-provider",
43696
+ "provider-not-configured",
43697
+ "unknown-base-model",
43698
+ "unknown-gpu",
43699
+ "dataset-too-large",
43700
+ "no-training-subjects",
43701
+ "job-already-running"
43702
+ ]);
43703
+ var TrainingJobPlanSchema = object({
43704
+ refusal: object({
43705
+ reason: TrainingRefusalReasonSchema,
43706
+ detail: string()
43707
+ }).nullable(),
43708
+ warnings: array(string()).readonly(),
43709
+ split: TrainingSplitPlanSchema.nullable(),
43710
+ estimate: object({
43711
+ datasetBytes: number().int(),
43712
+ uploadMinutesAt20Mbps: number(),
43713
+ gpuSecondsLow: number(),
43714
+ gpuSecondsHigh: number(),
43715
+ usdLow: number(),
43716
+ usdHigh: number(),
43717
+ notes: array(string()).readonly()
43718
+ }).nullable(),
43719
+ /** Pre-filled from the provider's settings; the operator may lower or raise them. */
43720
+ defaults: object({
43721
+ maxCostUsd: number(),
43722
+ maxRuntimeSec: number().int()
43723
+ }).nullable(),
43724
+ /** The sentence the confirm dialog repeats: where the frames go and when they are deleted. */
43725
+ dataNotice: string()
43726
+ });
43727
+ /**
43728
+ * Orchestrator-owned states, persisted. `uploading` covers exporting the
43729
+ * archive (it is streamed, never staged). Terminal: `failed`, `cancelled`,
43730
+ * `lost`, `expired`, `discarded`. `registered` and `canary` are where a
43731
+ * result lives after the operator acted on it.
43732
+ */
43733
+ var TrainingJobStateSchema = _enum([
43734
+ "uploading",
43735
+ "submitted",
43736
+ "starting",
43737
+ "running",
43738
+ "collecting",
43739
+ "ready",
43740
+ "registered",
43741
+ "canary",
43742
+ "failed",
43743
+ "cancelling",
43744
+ "cancelled",
43745
+ "lost",
43746
+ "expired",
43747
+ "discarded"
43748
+ ]);
43749
+ var TrainingFailureReasonSchema = _enum([
43750
+ "cost-cap",
43751
+ "runtime-cap",
43752
+ "upload-failed",
43753
+ "submit-failed",
43754
+ "trainer-failed",
43755
+ "result-invalid",
43756
+ "checksum-mismatch",
43757
+ "fetch-failed",
43758
+ "provider-error",
43759
+ "hub-restart-during-upload"
43760
+ ]);
43761
+ var TrainingProgressPointSchema = object({
43762
+ epoch: number().int(),
43763
+ map50: number().nullable(),
43764
+ map50_95: number().nullable()
43765
+ });
43766
+ var TrainingCanarySchema = object({
43767
+ deviceIds: array(number().int()).readonly(),
43768
+ since: number(),
43769
+ /** Every override the canary replaced, exactly, so rollback restores it. */
43770
+ previous: array(object({
43771
+ deviceId: number().int(),
43772
+ nodeId: string(),
43773
+ deviceKey: string(),
43774
+ patch: object({
43775
+ modelId: string().optional(),
43776
+ settings: record(string(), unknown()).readonly().optional()
43777
+ }).nullable()
43778
+ })).readonly()
43779
+ });
43780
+ var TrainingJobSchema = object({
43781
+ id: string(),
43782
+ idempotencyKey: string(),
43783
+ name: string(),
43784
+ createdAt: number(),
43785
+ updatedAt: number(),
43786
+ state: TrainingJobStateSchema,
43787
+ stage: TrainingStageSchema.nullable(),
43788
+ failure: object({
43789
+ reason: TrainingFailureReasonSchema,
43790
+ stage: string().nullable(),
43791
+ detail: string()
43792
+ }).nullable(),
43793
+ request: TrainingJobRequestSchema,
43794
+ maxCostUsd: number().nonnegative(),
43795
+ maxRuntimeSec: number().int().positive(),
43796
+ trainer: TrainerSourceRefSchema,
43797
+ datasetLayout: RetrainExportLayoutSchema,
43798
+ dataset: object({
43799
+ bytes: number().int(),
43800
+ sha256: string(),
43801
+ uploadedAt: number()
43802
+ }).nullable(),
43803
+ split: TrainingSplitPlanSchema,
43804
+ provider: object({
43805
+ state: ProviderJobStateSchema.nullable(),
43806
+ providerJobId: string().nullable(),
43807
+ startedAt: number().nullable(),
43808
+ endedAt: number().nullable(),
43809
+ billedSeconds: number(),
43810
+ costUsd: number(),
43811
+ costIsEstimate: boolean(),
43812
+ lastPolledAt: number().nullable()
43813
+ }),
43814
+ progress: object({
43815
+ epoch: number().int().nullable(),
43816
+ epochs: number().int().nullable(),
43817
+ etaSec: number().nullable(),
43818
+ series: array(TrainingProgressPointSchema).readonly()
43819
+ }),
43820
+ /** The last lines of the job's output (≤ 200), newest last. Never frame paths. */
43821
+ logTail: array(string()).readonly(),
43822
+ logCursor: string().nullable(),
43823
+ artifacts: object({
43824
+ bundleBytes: number().int(),
43825
+ bundleSha256: string(),
43826
+ fetchedAt: number(),
43827
+ /** When the staged artefacts are deleted from the hub. */
43828
+ expiresAt: number()
43829
+ }).nullable(),
43830
+ /** When the provider-side copy of the frames was deleted; null while it exists. */
43831
+ cloudDatasetDeletedAt: number().nullable(),
43832
+ /** A failed job's dataset is kept until then (the provider's grace), then deleted. */
43833
+ cloudCleanupDueAt: number().nullable(),
43834
+ /** Model ids registered from this job (base, and int8 when kept). */
43835
+ registeredModelIds: array(string()).readonly(),
43836
+ canary: TrainingCanarySchema.nullable()
43837
+ });
43838
+ var IdInput = object({ id: string().min(1) });
43839
+ method(TrainingDatasetVersionRowSchema, object({ stored: boolean() }), {
43840
+ kind: "mutation",
43841
+ auth: "admin"
43842
+ }), 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() }), {
43843
+ kind: "mutation",
43844
+ auth: "admin"
43845
+ }), method(object({}), array(TrainingBaseModelSchema).readonly(), { auth: "admin" }), method(TrainingJobRequestSchema, TrainingJobPlanSchema, {
43846
+ auth: "admin",
43847
+ timeoutMs: 6e4
43848
+ }), method(TrainingJobRequestSchema.extend({
43849
+ name: string().min(1).max(120),
43850
+ maxCostUsd: number().positive(),
43851
+ maxRuntimeSec: number().int().positive(),
43852
+ idempotencyKey: string().min(8).max(80)
43853
+ }), discriminatedUnion("kind", [object({
43854
+ kind: literal("started"),
43855
+ job: TrainingJobSchema
43856
+ }), object({
43857
+ kind: literal("refused"),
43858
+ reason: TrainingRefusalReasonSchema,
43859
+ detail: string()
43860
+ })]), {
43861
+ kind: "mutation",
43862
+ auth: "admin",
43863
+ timeoutMs: 12e4
43864
+ }), method(object({}), array(TrainingJobSchema).readonly(), { auth: "admin" }), method(IdInput, TrainingJobSchema.nullable(), { auth: "admin" }), method(IdInput, TrainingJobSchema, {
43865
+ kind: "mutation",
43866
+ auth: "admin",
43867
+ timeoutMs: 12e4
43868
+ }), method(IdInput, TrainingResultSchema.nullable(), { auth: "admin" }), method(IdInput.extend({ canaryDeviceIds: array(number().int()).readonly() }), TrainingJobSchema, {
43869
+ kind: "mutation",
43870
+ auth: "admin",
43871
+ timeoutMs: 30 * 6e4
43872
+ }), method(IdInput.extend({ deviceIds: array(number().int()).min(1).readonly() }), TrainingJobSchema, {
43873
+ kind: "mutation",
43874
+ auth: "admin",
43875
+ timeoutMs: 12e4
43876
+ }), method(IdInput, TrainingJobSchema, {
43877
+ kind: "mutation",
43878
+ auth: "admin",
43879
+ timeoutMs: 12e4
43880
+ }), method(IdInput, TrainingJobSchema, {
43881
+ kind: "mutation",
43882
+ auth: "admin"
43883
+ });
42483
43884
  SOURCE_CAPS.filter((cap) => cap !== "switch" && cap !== "motion");
42484
43885
  Object.freeze({
42485
43886
  person: .5,
@@ -44628,6 +46029,12 @@ Object.freeze({
44628
46029
  addonId: null,
44629
46030
  access: "create"
44630
46031
  },
46032
+ "backup.checkBackupKey": {
46033
+ capName: "backup",
46034
+ capScope: "system",
46035
+ addonId: null,
46036
+ access: "create"
46037
+ },
44631
46038
  "backup.delete": {
44632
46039
  capName: "backup",
44633
46040
  capScope: "system",
@@ -44640,6 +46047,18 @@ Object.freeze({
44640
46047
  addonId: null,
44641
46048
  access: "delete"
44642
46049
  },
46050
+ "backup.disableEncryption": {
46051
+ capName: "backup",
46052
+ capScope: "system",
46053
+ addonId: null,
46054
+ access: "create"
46055
+ },
46056
+ "backup.getEncryption": {
46057
+ capName: "backup",
46058
+ capScope: "system",
46059
+ addonId: null,
46060
+ access: "view"
46061
+ },
44643
46062
  "backup.getEntries": {
44644
46063
  capName: "backup",
44645
46064
  capScope: "system",
@@ -44694,6 +46113,12 @@ Object.freeze({
44694
46113
  addonId: null,
44695
46114
  access: "create"
44696
46115
  },
46116
+ "backup.setupEncryption": {
46117
+ capName: "backup",
46118
+ capScope: "system",
46119
+ addonId: null,
46120
+ access: "create"
46121
+ },
44697
46122
  "backup.trigger": {
44698
46123
  capName: "backup",
44699
46124
  capScope: "system",
@@ -45246,6 +46671,12 @@ Object.freeze({
45246
46671
  addonId: null,
45247
46672
  access: "create"
45248
46673
  },
46674
+ "customModelRegistry.importModelBundle": {
46675
+ capName: "custom-model-registry",
46676
+ capScope: "system",
46677
+ addonId: null,
46678
+ access: "create"
46679
+ },
45249
46680
  "customModelRegistry.listModels": {
45250
46681
  capName: "custom-model-registry",
45251
46682
  capScope: "system",
@@ -46686,6 +48117,12 @@ Object.freeze({
46686
48117
  addonId: null,
46687
48118
  access: "view"
46688
48119
  },
48120
+ "keychainAdmin.acknowledgeReset": {
48121
+ capName: "keychain-admin",
48122
+ capScope: "system",
48123
+ addonId: null,
48124
+ access: "create"
48125
+ },
46689
48126
  "keychainAdmin.deleteOrphans": {
46690
48127
  capName: "keychain-admin",
46691
48128
  capScope: "system",
@@ -46722,6 +48159,12 @@ Object.freeze({
46722
48159
  addonId: null,
46723
48160
  access: "delete"
46724
48161
  },
48162
+ "keychainAdmin.resetReport": {
48163
+ capName: "keychain-admin",
48164
+ capScope: "system",
48165
+ addonId: null,
48166
+ access: "delete"
48167
+ },
46725
48168
  "keychainAdmin.reveal": {
46726
48169
  capName: "keychain-admin",
46727
48170
  capScope: "system",
@@ -46734,6 +48177,12 @@ Object.freeze({
46734
48177
  addonId: null,
46735
48178
  access: "create"
46736
48179
  },
48180
+ "keychainAdmin.setSystemSecret": {
48181
+ capName: "keychain-admin",
48182
+ capScope: "system",
48183
+ addonId: null,
48184
+ access: "create"
48185
+ },
46737
48186
  "keychainAdmin.status": {
46738
48187
  capName: "keychain-admin",
46739
48188
  capScope: "system",
@@ -48180,6 +49629,12 @@ Object.freeze({
48180
49629
  addonId: null,
48181
49630
  access: "create"
48182
49631
  },
49632
+ "pipelineAnalytics.createRetrainDatasetVersion": {
49633
+ capName: "pipeline-analytics",
49634
+ capScope: "device",
49635
+ addonId: null,
49636
+ access: "create"
49637
+ },
48183
49638
  "pipelineAnalytics.deleteDeviceEvents": {
48184
49639
  capName: "pipeline-analytics",
48185
49640
  capScope: "device",
@@ -48192,6 +49647,12 @@ Object.freeze({
48192
49647
  addonId: null,
48193
49648
  access: "delete"
48194
49649
  },
49650
+ "pipelineAnalytics.deleteRetrainDatasetVersion": {
49651
+ capName: "pipeline-analytics",
49652
+ capScope: "device",
49653
+ addonId: null,
49654
+ access: "delete"
49655
+ },
48195
49656
  "pipelineAnalytics.deleteTracks": {
48196
49657
  capName: "pipeline-analytics",
48197
49658
  capScope: "device",
@@ -48414,6 +49875,12 @@ Object.freeze({
48414
49875
  addonId: null,
48415
49876
  access: "view"
48416
49877
  },
49878
+ "pipelineAnalytics.listRetrainDatasetVersions": {
49879
+ capName: "pipeline-analytics",
49880
+ capScope: "device",
49881
+ addonId: null,
49882
+ access: "view"
49883
+ },
48417
49884
  "pipelineAnalytics.listRetrainFrames": {
48418
49885
  capName: "pipeline-analytics",
48419
49886
  capScope: "device",
@@ -48444,6 +49911,12 @@ Object.freeze({
48444
49911
  addonId: null,
48445
49912
  access: "view"
48446
49913
  },
49914
+ "pipelineAnalytics.offerRetrainArchive": {
49915
+ capName: "pipeline-analytics",
49916
+ capScope: "device",
49917
+ addonId: null,
49918
+ access: "create"
49919
+ },
48447
49920
  "pipelineAnalytics.ownersWithMedia": {
48448
49921
  capName: "pipeline-analytics",
48449
49922
  capScope: "device",
@@ -48456,6 +49929,12 @@ Object.freeze({
48456
49929
  addonId: null,
48457
49930
  access: "create"
48458
49931
  },
49932
+ "pipelineAnalytics.previewRetrainDataset": {
49933
+ capName: "pipeline-analytics",
49934
+ capScope: "device",
49935
+ addonId: null,
49936
+ access: "view"
49937
+ },
48459
49938
  "pipelineAnalytics.proposeRetrainAnnotations": {
48460
49939
  capName: "pipeline-analytics",
48461
49940
  capScope: "device",
@@ -48594,6 +50073,12 @@ Object.freeze({
48594
50073
  addonId: null,
48595
50074
  access: "create"
48596
50075
  },
50076
+ "pipelineAnalytics.verifyRetrainDatasetVersion": {
50077
+ capName: "pipeline-analytics",
50078
+ capScope: "device",
50079
+ addonId: null,
50080
+ access: "view"
50081
+ },
48597
50082
  "pipelineAnalytics.wipeAllAnalytics": {
48598
50083
  capName: "pipeline-analytics",
48599
50084
  capScope: "device",
@@ -50970,6 +52455,174 @@ Object.freeze({
50970
52455
  addonId: null,
50971
52456
  access: "view"
50972
52457
  },
52458
+ "training.canaryResult": {
52459
+ capName: "training",
52460
+ capScope: "system",
52461
+ addonId: null,
52462
+ access: "create"
52463
+ },
52464
+ "training.cancelJob": {
52465
+ capName: "training",
52466
+ capScope: "system",
52467
+ addonId: null,
52468
+ access: "create"
52469
+ },
52470
+ "training.discardResult": {
52471
+ capName: "training",
52472
+ capScope: "system",
52473
+ addonId: null,
52474
+ access: "create"
52475
+ },
52476
+ "training.findDatasetVersionIdByName": {
52477
+ capName: "training",
52478
+ capScope: "system",
52479
+ addonId: null,
52480
+ access: "view"
52481
+ },
52482
+ "training.getDatasetVersion": {
52483
+ capName: "training",
52484
+ capScope: "system",
52485
+ addonId: null,
52486
+ access: "view"
52487
+ },
52488
+ "training.getJob": {
52489
+ capName: "training",
52490
+ capScope: "system",
52491
+ addonId: null,
52492
+ access: "view"
52493
+ },
52494
+ "training.getJobResult": {
52495
+ capName: "training",
52496
+ capScope: "system",
52497
+ addonId: null,
52498
+ access: "view"
52499
+ },
52500
+ "training.listBaseModels": {
52501
+ capName: "training",
52502
+ capScope: "system",
52503
+ addonId: null,
52504
+ access: "view"
52505
+ },
52506
+ "training.listDatasetVersions": {
52507
+ capName: "training",
52508
+ capScope: "system",
52509
+ addonId: null,
52510
+ access: "view"
52511
+ },
52512
+ "training.listJobs": {
52513
+ capName: "training",
52514
+ capScope: "system",
52515
+ addonId: null,
52516
+ access: "view"
52517
+ },
52518
+ "training.planJob": {
52519
+ capName: "training",
52520
+ capScope: "system",
52521
+ addonId: null,
52522
+ access: "view"
52523
+ },
52524
+ "training.putDatasetVersion": {
52525
+ capName: "training",
52526
+ capScope: "system",
52527
+ addonId: null,
52528
+ access: "create"
52529
+ },
52530
+ "training.registerResult": {
52531
+ capName: "training",
52532
+ capScope: "system",
52533
+ addonId: null,
52534
+ access: "create"
52535
+ },
52536
+ "training.removeDatasetVersion": {
52537
+ capName: "training",
52538
+ capScope: "system",
52539
+ addonId: null,
52540
+ access: "delete"
52541
+ },
52542
+ "training.rollbackCanary": {
52543
+ capName: "training",
52544
+ capScope: "system",
52545
+ addonId: null,
52546
+ access: "create"
52547
+ },
52548
+ "training.startJob": {
52549
+ capName: "training",
52550
+ capScope: "system",
52551
+ addonId: null,
52552
+ access: "create"
52553
+ },
52554
+ "trainingProvider.cancelJob": {
52555
+ capName: "training-provider",
52556
+ capScope: "system",
52557
+ addonId: null,
52558
+ access: "create"
52559
+ },
52560
+ "trainingProvider.cleanupJob": {
52561
+ capName: "training-provider",
52562
+ capScope: "system",
52563
+ addonId: null,
52564
+ access: "create"
52565
+ },
52566
+ "trainingProvider.describe": {
52567
+ capName: "training-provider",
52568
+ capScope: "system",
52569
+ addonId: null,
52570
+ access: "view"
52571
+ },
52572
+ "trainingProvider.estimateJob": {
52573
+ capName: "training-provider",
52574
+ capScope: "system",
52575
+ addonId: null,
52576
+ access: "view"
52577
+ },
52578
+ "trainingProvider.getJob": {
52579
+ capName: "training-provider",
52580
+ capScope: "system",
52581
+ addonId: null,
52582
+ access: "view"
52583
+ },
52584
+ "trainingProvider.listJobEvents": {
52585
+ capName: "training-provider",
52586
+ capScope: "system",
52587
+ addonId: null,
52588
+ access: "view"
52589
+ },
52590
+ "trainingProvider.listJobs": {
52591
+ capName: "training-provider",
52592
+ capScope: "system",
52593
+ addonId: null,
52594
+ access: "view"
52595
+ },
52596
+ "trainingProvider.offerArtifact": {
52597
+ capName: "training-provider",
52598
+ capScope: "system",
52599
+ addonId: null,
52600
+ access: "create"
52601
+ },
52602
+ "trainingProvider.readResult": {
52603
+ capName: "training-provider",
52604
+ capScope: "system",
52605
+ addonId: null,
52606
+ access: "create"
52607
+ },
52608
+ "trainingProvider.submitJob": {
52609
+ capName: "training-provider",
52610
+ capScope: "system",
52611
+ addonId: null,
52612
+ access: "create"
52613
+ },
52614
+ "trainingProvider.uploadDataset": {
52615
+ capName: "training-provider",
52616
+ capScope: "system",
52617
+ addonId: null,
52618
+ access: "create"
52619
+ },
52620
+ "trainingProvider.validateCredentials": {
52621
+ capName: "training-provider",
52622
+ capScope: "system",
52623
+ addonId: null,
52624
+ access: "create"
52625
+ },
50973
52626
  "turnProvider.getTurnServers": {
50974
52627
  capName: "turn-provider",
50975
52628
  capScope: "system",
@@ -50994,12 +52647,6 @@ Object.freeze({
50994
52647
  addonId: null,
50995
52648
  access: "create"
50996
52649
  },
50997
- "userManagement.createApiKey": {
50998
- capName: "user-management",
50999
- capScope: "system",
51000
- addonId: null,
51001
- access: "create"
51002
- },
51003
52650
  "userManagement.createScopedToken": {
51004
52651
  capName: "user-management",
51005
52652
  capScope: "system",
@@ -51036,12 +52683,6 @@ Object.freeze({
51036
52683
  addonId: null,
51037
52684
  access: "view"
51038
52685
  },
51039
- "userManagement.linkExternalIdentity": {
51040
- capName: "user-management",
51041
- capScope: "system",
51042
- addonId: null,
51043
- access: "create"
51044
- },
51045
52686
  "userManagement.listApiKeys": {
51046
52687
  capName: "user-management",
51047
52688
  capScope: "system",
@@ -51144,12 +52785,6 @@ Object.freeze({
51144
52785
  addonId: null,
51145
52786
  access: "create"
51146
52787
  },
51147
- "userManagement.validateApiKey": {
51148
- capName: "user-management",
51149
- capScope: "system",
51150
- addonId: null,
51151
- access: "view"
51152
- },
51153
52788
  "userManagement.validateCredentials": {
51154
52789
  capName: "user-management",
51155
52790
  capScope: "system",
@@ -55263,6 +56898,11 @@ Object.freeze({
55263
56898
  form: "single",
55264
56899
  optional: false
55265
56900
  }],
56901
+ "training.canaryResult": [{
56902
+ name: "deviceIds",
56903
+ form: "array",
56904
+ optional: false
56905
+ }],
55266
56906
  "update.getStatus": [{
55267
56907
  name: "deviceId",
55268
56908
  form: "single",