@camstack/addon-provider-tuya 0.2.121 → 0.2.123

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 +3555 -126
  2. package/dist/addon.mjs +3555 -126
  3. package/package.json +1 -1
package/dist/addon.js CHANGED
@@ -819,7 +819,7 @@ async function discoverDevices(options = {}, binder = createDgramBinder()) {
819
819
  return [...byId.values()];
820
820
  }
821
821
  //#endregion
822
- //#region ../types/dist/event-category-B_0XEcLF.mjs
822
+ //#region ../types/dist/event-category-DaIZi00R.mjs
823
823
  var EventCategory = /* @__PURE__ */ function(EventCategory) {
824
824
  EventCategory["SystemBoot"] = "system.boot";
825
825
  EventCategory["SystemAddonsReady"] = "system.addons-ready";
@@ -898,6 +898,13 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
898
898
  */
899
899
  EventCategory["AddonLoadFailed"] = "addon.load-failed";
900
900
  /**
901
+ * A keychain value was stored or removed (D787). Carries the ref, its
902
+ * owner and the new version — NEVER the value. A process holding the ref
903
+ * drops its cached copy and the owning `BaseAddon` re-resolves its config.
904
+ * Telemetry (D8): a process that misses it still revalidates by version.
905
+ */
906
+ EventCategory["KeychainChanged"] = "keychain.changed";
907
+ /**
901
908
  * Addon recovered from a previous failure. Emitted when an addon
902
909
  * transitions from `failed` back to `healthy` (typically via the
903
910
  * monitor's auto-retry loop, or after manual `addons.retryLoad`).
@@ -6190,7 +6197,7 @@ var ZodIssueCode = {
6190
6197
  var ZodFirstPartyTypeKind;
6191
6198
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
6192
6199
  //#endregion
6193
- //#region ../types/dist/sleep-B0JG7-_F.mjs
6200
+ //#region ../types/dist/sleep-r3RWkGVx.mjs
6194
6201
  /**
6195
6202
  * The audio chunk plane's byte format, and the ONE expansion from a coded
6196
6203
  * window to float samples (D455).
@@ -6269,6 +6276,97 @@ function buildAlawTable() {
6269
6276
  }
6270
6277
  buildUlawTable();
6271
6278
  buildAlawTable();
6279
+ /** Is this field's stored value a credential? */
6280
+ function isSecretConfigField(field) {
6281
+ if (field.type === "password") return true;
6282
+ return "secret" in field && field.secret === true;
6283
+ }
6284
+ /**
6285
+ * Is this field's value stored in the KEYCHAIN (D787)? Every secret field is,
6286
+ * by its TYPE, unless it opts out with `storage: 'inline'` — never by its name.
6287
+ */
6288
+ function isKeychainStoredField(field) {
6289
+ if (!isSecretConfigField(field)) return false;
6290
+ if (field.type === "textarea" && field.isJson === true) return false;
6291
+ return !("storage" in field && field.storage === "inline");
6292
+ }
6293
+ /**
6294
+ * What a settings blob holds where a secret used to be.
6295
+ *
6296
+ * A keychain-stored field never holds its value. It holds a self-describing
6297
+ * MARKER, `{"$secret":"secret://…","v":1}` — an object, never a string, so no
6298
+ * code can mistake it for a credential and no form can send it to a camera as
6299
+ * a password. The empty state is `null` / absent, never `''`.
6300
+ *
6301
+ * The same shapes travel to and from the admin UI:
6302
+ *
6303
+ * - read: `hydrateSchema` hands a secret field a {@link SecretFieldView}
6304
+ * (`{ $secret, v, set: true }`) or `null` — the browser learns whether a
6305
+ * value is set, never the value.
6306
+ * - write: an untouched field submits the view back unchanged (KEEP); a typed
6307
+ * value is a plain non-empty string (CHANGE); the Clear button submits
6308
+ * {@link SECRET_CLEAR} (CLEAR). `''`, `null` and the legacy redaction tokens
6309
+ * are KEEP — an empty string is what a defaults-fallback pushes back, and
6310
+ * treating it as "clear" is how a save destroyed a stored credential before.
6311
+ *
6312
+ * Pure and browser-safe.
6313
+ */
6314
+ var SECRET_CLEAR = { $secretClear: true };
6315
+ /** The `'***'` token D634 redaction writes for non-admins. */
6316
+ var LEGACY_DEVICE_REDACTION = "***";
6317
+ function isRecord$2(value) {
6318
+ return typeof value === "object" && value !== null && !Array.isArray(value);
6319
+ }
6320
+ function makeSecretMarker(ref) {
6321
+ return {
6322
+ $secret: ref,
6323
+ v: 1
6324
+ };
6325
+ }
6326
+ /** A stored marker: an object whose `$secret` is a non-empty string. */
6327
+ function isSecretMarker(value) {
6328
+ if (!isRecord$2(value)) return false;
6329
+ const ref = value["$secret"];
6330
+ return typeof ref === "string" && ref.length > 0;
6331
+ }
6332
+ function isSecretClear(value) {
6333
+ return isRecord$2(value) && value["$secretClear"] === true;
6334
+ }
6335
+ /**
6336
+ * The UI view of a stored secret field value: a marker becomes "set", inline
6337
+ * plaintext becomes "set (inline)", nothing becomes `null`. A value never
6338
+ * survives this function.
6339
+ */
6340
+ function toSecretFieldView(stored) {
6341
+ if (isSecretMarker(stored)) return {
6342
+ $secret: stored.$secret,
6343
+ v: 1,
6344
+ set: true
6345
+ };
6346
+ if (typeof stored === "string" && stored.length > 0) return {
6347
+ $secret: null,
6348
+ v: 1,
6349
+ set: true,
6350
+ inline: true
6351
+ };
6352
+ return null;
6353
+ }
6354
+ /**
6355
+ * Classify an incoming value for a secret path. Only a non-empty string that is
6356
+ * not a redaction token sets a value; only {@link SECRET_CLEAR} clears.
6357
+ * Everything else — a marker (ours or anyone's), a UI view, `''`, `null`,
6358
+ * `undefined`, a redaction token, a non-string — keeps what is stored.
6359
+ */
6360
+ function classifySecretWrite(incoming) {
6361
+ if (isSecretClear(incoming)) return { kind: "clear" };
6362
+ if (typeof incoming !== "string") return { kind: "keep" };
6363
+ if (incoming.length === 0) return { kind: "keep" };
6364
+ if (incoming === "__camstack_redacted__" || incoming === LEGACY_DEVICE_REDACTION) return { kind: "keep" };
6365
+ return {
6366
+ kind: "set",
6367
+ value: incoming
6368
+ };
6369
+ }
6272
6370
  Object.fromEntries([
6273
6371
  {
6274
6372
  id: "overview",
@@ -6440,33 +6538,19 @@ Object.fromEntries([
6440
6538
  function isValuelessField(field) {
6441
6539
  return field.type === "separator" || field.type === "info" || field.type === "qr-code" || field.type === "button" || field.type === "object-array" || field.type === "widget" || field.type === "addon-action-button" || field.type === "device-action-button";
6442
6540
  }
6443
- /**
6444
- * Merge a `ConfigUISchema` with a raw `values` record into a
6445
- * `ConfigUISchemaWithValues`. Used by every `get*Settings` backend endpoint
6446
- * before returning to the admin UI. Groups are walked recursively.
6447
- *
6448
- * For each leaf field:
6449
- * - structural fields (`separator`, `info`, `button`) pass through unchanged
6450
- * - other fields get `value = values[key] ?? field.default ?? null`
6451
- *
6452
- * Unknown keys in `values` (keys not declared in the schema) are silently
6453
- * ignored — they don't contribute to the output. Missing keys fall back to
6454
- * the schema default or `null`. This mirrors the old backend behaviour where
6455
- * `FormBuilder` rendered `values[key] ?? field.default`.
6456
- */
6457
- function hydrateSchema(schema, values) {
6541
+ function hydrateSchema(schema, values, options = {}) {
6458
6542
  return {
6459
6543
  ...schema.tabs ? { tabs: [...schema.tabs] } : {},
6460
6544
  sections: schema.sections.map((section) => ({
6461
6545
  ...section,
6462
- fields: section.fields.map((field) => hydrateField(field, values))
6546
+ fields: section.fields.map((field) => hydrateField(field, values, options))
6463
6547
  }))
6464
6548
  };
6465
6549
  }
6466
- function hydrateField(field, values) {
6550
+ function hydrateField(field, values, options) {
6467
6551
  if (isValuelessField(field)) return field;
6468
6552
  if (field.type === "group") {
6469
- const hydratedChildren = field.fields.map((child) => hydrateField(child, values));
6553
+ const hydratedChildren = field.fields.map((child) => hydrateField(child, values, options));
6470
6554
  return {
6471
6555
  ...field,
6472
6556
  fields: hydratedChildren
@@ -6475,7 +6559,7 @@ function hydrateField(field, values) {
6475
6559
  if (field.type === "sub-tabs") {
6476
6560
  const hydratedTabs = field.tabs.map((tab) => ({
6477
6561
  ...tab,
6478
- fields: tab.fields.map((child) => hydrateField(child, values))
6562
+ fields: tab.fields.map((child) => hydrateField(child, values, options))
6479
6563
  }));
6480
6564
  return {
6481
6565
  ...field,
@@ -6485,6 +6569,33 @@ function hydrateField(field, values) {
6485
6569
  const key = field.key;
6486
6570
  const storedValue = Object.prototype.hasOwnProperty.call(values, key) ? values[key] : void 0;
6487
6571
  const defaultValue = field.default;
6572
+ const asView = (v) => isSecretMarker(v) || options.inlineSecretsAsViews === true && v !== void 0;
6573
+ if (isKeychainStoredField(field) && asView(storedValue)) return {
6574
+ ...field,
6575
+ value: toSecretFieldView(storedValue)
6576
+ };
6577
+ if (isKeychainStoredField(field) && options.inlineSecretsAsViews === true) return {
6578
+ ...field,
6579
+ value: null
6580
+ };
6581
+ if (field.type === "editable-array" && Array.isArray(storedValue)) {
6582
+ const secretItemKeys = field.itemFields.filter((item) => "key" in item && isKeychainStoredField(item)).map((item) => "key" in item ? item.key : "");
6583
+ if (secretItemKeys.length > 0) {
6584
+ const rows = storedValue.map((row) => {
6585
+ if (row === null || typeof row !== "object" || Array.isArray(row)) return row;
6586
+ const out = { ...row };
6587
+ for (const k of secretItemKeys) {
6588
+ const v = Reflect.get(row, k);
6589
+ if (asView(v)) out[k] = toSecretFieldView(v);
6590
+ }
6591
+ return out;
6592
+ });
6593
+ return {
6594
+ ...field,
6595
+ value: rows
6596
+ };
6597
+ }
6598
+ }
6488
6599
  if (field.multiple) {
6489
6600
  const stored = Array.isArray(storedValue) ? storedValue : storedValue !== void 0 && storedValue !== null ? [storedValue] : [];
6490
6601
  const itemFallback = field.multiple.itemDefault !== void 0 ? field.multiple.itemDefault : defaultValue !== void 0 ? defaultValue : typeOf(field) === "string" ? "" : null;
@@ -6727,6 +6838,778 @@ function projectStore(store, perNodeKeys, nodeId) {
6727
6838
  }
6728
6839
  return out;
6729
6840
  }
6841
+ var GLOBAL_SCOPE = { kind: "global" };
6842
+ /** The scope every addon-wide (not per-node, not per-device) setting lives in. */
6843
+ function globalSecretScope() {
6844
+ return GLOBAL_SCOPE;
6845
+ }
6846
+ function encodeSegment(value) {
6847
+ return encodeURIComponent(value);
6848
+ }
6849
+ function decodeSegment(value) {
6850
+ try {
6851
+ return decodeURIComponent(value);
6852
+ } catch {
6853
+ return null;
6854
+ }
6855
+ }
6856
+ /**
6857
+ * The field path of a value inside an array item, addressed by the item's id:
6858
+ * `arrayItemFieldPath('providers', 'authentik', 'clientSecret')` →
6859
+ * `providers[authentik].clientSecret`.
6860
+ */
6861
+ function arrayItemFieldPath(arrayKey, itemId, fieldKey) {
6862
+ return `${arrayKey}[${encodeSegment(itemId)}].${fieldKey}`;
6863
+ }
6864
+ function parseScope(segments) {
6865
+ switch (segments[0]) {
6866
+ case "global": return {
6867
+ scope: GLOBAL_SCOPE,
6868
+ used: 1
6869
+ };
6870
+ case "node": {
6871
+ const nodeId = segments[1] !== void 0 ? decodeSegment(segments[1]) : null;
6872
+ return nodeId === null || nodeId.length === 0 ? null : {
6873
+ scope: {
6874
+ kind: "node",
6875
+ nodeId
6876
+ },
6877
+ used: 2
6878
+ };
6879
+ }
6880
+ case "device": {
6881
+ const raw = segments[1];
6882
+ if (raw === void 0 || !/^\d+$/.test(raw)) return null;
6883
+ return {
6884
+ scope: {
6885
+ kind: "device",
6886
+ deviceId: Number(raw)
6887
+ },
6888
+ used: 2
6889
+ };
6890
+ }
6891
+ case "integration": {
6892
+ const id = segments[1] !== void 0 ? decodeSegment(segments[1]) : null;
6893
+ return id === null || id.length === 0 ? null : {
6894
+ scope: {
6895
+ kind: "integration",
6896
+ integrationId: id
6897
+ },
6898
+ used: 2
6899
+ };
6900
+ }
6901
+ case "row": {
6902
+ const collection = segments[1] !== void 0 ? decodeSegment(segments[1]) : null;
6903
+ const rowId = segments[2] !== void 0 ? decodeSegment(segments[2]) : null;
6904
+ if (collection === null || rowId === null || collection.length === 0 || rowId.length === 0) return null;
6905
+ return {
6906
+ scope: {
6907
+ kind: "row",
6908
+ collection,
6909
+ rowId
6910
+ },
6911
+ used: 3
6912
+ };
6913
+ }
6914
+ default: return null;
6915
+ }
6916
+ }
6917
+ /** Take a ref apart; `null` when it is not a well-formed ref. */
6918
+ function parseSecretRef(ref) {
6919
+ if (!ref.startsWith("secret://")) return null;
6920
+ const segments = ref.slice(9).split("/");
6921
+ const owner = segments[0] !== void 0 ? decodeSegment(segments[0]) : null;
6922
+ if (owner === null || owner.length === 0) return null;
6923
+ const parsed = parseScope(segments.slice(1));
6924
+ if (parsed === null) return null;
6925
+ const fieldPath = segments.slice(1 + parsed.used).join("/");
6926
+ if (fieldPath.length === 0) return null;
6927
+ return {
6928
+ owner,
6929
+ scope: parsed.scope,
6930
+ fieldPath
6931
+ };
6932
+ }
6933
+ /** A write to a secret path could not be stored in the keychain, so it was refused. */
6934
+ var KeychainWriteRefusedError = class extends Error {
6935
+ fieldPath;
6936
+ constructor(fieldPath, cause) {
6937
+ super(`secret "${fieldPath}" was not saved: the keychain could not store it (${cause instanceof Error ? cause.message : String(cause)}). Nothing was written.`);
6938
+ this.fieldPath = fieldPath;
6939
+ this.name = "KeychainWriteRefusedError";
6940
+ }
6941
+ };
6942
+ var KEEP = { kind: "keep" };
6943
+ function isRecord$1(value) {
6944
+ return typeof value === "object" && value !== null && !Array.isArray(value);
6945
+ }
6946
+ function defaultMintId() {
6947
+ return globalThis.crypto.randomUUID();
6948
+ }
6949
+ /** Every marker ref anywhere under `value`. */
6950
+ function collectSecretMarkerRefs(value, out = []) {
6951
+ if (isSecretMarker(value)) {
6952
+ out.push(value.$secret);
6953
+ return out;
6954
+ }
6955
+ if (Array.isArray(value)) for (const item of value) collectSecretMarkerRefs(item, out);
6956
+ else if (isRecord$1(value)) for (const child of Object.values(value)) collectSecretMarkerRefs(child, out);
6957
+ return out;
6958
+ }
6959
+ async function storedValueEquals(secrets, marker, candidate) {
6960
+ const resolved = (await secrets.resolve([marker.$secret]))[marker.$secret];
6961
+ return resolved?.kind === "value" && resolved.value === candidate;
6962
+ }
6963
+ async function writeLeaf(ctx, incoming, stored, fieldPath) {
6964
+ const intent = classifySecretWrite(incoming);
6965
+ const ref = ctx.secrets.ref(ctx.scope, fieldPath);
6966
+ const storedIsOurs = isSecretMarker(stored) && stored.$secret === ref;
6967
+ if (intent.kind === "keep") return KEEP;
6968
+ if (intent.kind === "set" && !ctx.operatorWrite && typeof stored === "string" && stored === intent.value) return KEEP;
6969
+ if (intent.kind === "clear") {
6970
+ if (storedIsOurs) ctx.deletes.push(ref);
6971
+ return {
6972
+ kind: "value",
6973
+ value: null
6974
+ };
6975
+ }
6976
+ if (storedIsOurs && await storedValueEquals(ctx.secrets, stored, intent.value)) return {
6977
+ kind: "value",
6978
+ value: stored
6979
+ };
6980
+ try {
6981
+ await ctx.secrets.put(ref, intent.value);
6982
+ } catch (err) {
6983
+ throw new KeychainWriteRefusedError(fieldPath, err);
6984
+ }
6985
+ return {
6986
+ kind: "value",
6987
+ value: makeSecretMarker(ref)
6988
+ };
6989
+ }
6990
+ /** Apply a member result onto `out`: KEEP restores the stored member, or removes it. */
6991
+ function applyMember(out, key, result, storedParent) {
6992
+ if (result.kind === "value") {
6993
+ out[key] = result.value;
6994
+ return;
6995
+ }
6996
+ if (Object.prototype.hasOwnProperty.call(storedParent, key)) out[key] = storedParent[key];
6997
+ else delete out[key];
6998
+ }
6999
+ async function writeMembers(ctx, children, incoming, stored, pathOf) {
7000
+ const out = { ...incoming };
7001
+ for (const [member, node] of children) applyMember(out, member, await writeNode(ctx, node, incoming[member], stored[member], pathOf(member)), stored);
7002
+ return out;
7003
+ }
7004
+ function rowId(row, idKey) {
7005
+ const raw = row[idKey];
7006
+ if (typeof raw === "string" && raw.length > 0) return raw;
7007
+ if (typeof raw === "number" && Number.isFinite(raw)) return String(raw);
7008
+ return null;
7009
+ }
7010
+ async function writeArray(ctx, node, incoming, stored, fieldPath) {
7011
+ const storedRows = Array.isArray(stored) ? stored.filter(isRecord$1) : [];
7012
+ if (!Array.isArray(incoming)) {
7013
+ ctx.deletes.push(...collectSecretMarkerRefs(storedRows));
7014
+ return {
7015
+ kind: "value",
7016
+ value: incoming
7017
+ };
7018
+ }
7019
+ const storedById = /* @__PURE__ */ new Map();
7020
+ for (const row of storedRows) {
7021
+ const id = rowId(row, node.idKey);
7022
+ if (id !== null) storedById.set(id, row);
7023
+ }
7024
+ const kept = /* @__PURE__ */ new Set();
7025
+ const rows = [];
7026
+ for (const row of incoming) {
7027
+ if (!isRecord$1(row)) {
7028
+ rows.push(row);
7029
+ continue;
7030
+ }
7031
+ const id = rowId(row, node.idKey) ?? ctx.mintId();
7032
+ kept.add(id);
7033
+ const withId = {
7034
+ ...row,
7035
+ [node.idKey]: row[node.idKey] ?? id
7036
+ };
7037
+ if (rowId(withId, node.idKey) === null) withId[node.idKey] = id;
7038
+ const storedRow = storedById.get(id) ?? {};
7039
+ rows.push(await writeMembers(ctx, node.item, withId, storedRow, (member) => arrayItemFieldPath(fieldPath, id, member)));
7040
+ }
7041
+ for (const [id, row] of storedById) if (!kept.has(id)) ctx.deletes.push(...collectSecretMarkerRefs(row));
7042
+ return {
7043
+ kind: "value",
7044
+ value: rows
7045
+ };
7046
+ }
7047
+ async function writeNode(ctx, node, incoming, stored, fieldPath) {
7048
+ switch (node.kind) {
7049
+ case "leaf": return writeLeaf(ctx, incoming, stored, fieldPath);
7050
+ case "array": return writeArray(ctx, node, incoming, stored, fieldPath);
7051
+ case "object": {
7052
+ if (!isRecord$1(incoming)) {
7053
+ if (incoming === void 0) return KEEP;
7054
+ ctx.deletes.push(...collectSecretMarkerRefs(stored));
7055
+ return {
7056
+ kind: "value",
7057
+ value: incoming
7058
+ };
7059
+ }
7060
+ const storedObj = isRecord$1(stored) ? stored : {};
7061
+ return {
7062
+ kind: "value",
7063
+ value: await writeMembers(ctx, node.children, incoming, storedObj, (m) => `${fieldPath}.${m}`)
7064
+ };
7065
+ }
7066
+ }
7067
+ }
7068
+ /** Split a perNode-scoped key (`key@nodeId`). */
7069
+ function splitNodeKey(key) {
7070
+ const at = key.indexOf("@");
7071
+ return at <= 0 ? {
7072
+ base: key,
7073
+ nodeId: null
7074
+ } : {
7075
+ base: key.slice(0, at),
7076
+ nodeId: key.slice(at + 1)
7077
+ };
7078
+ }
7079
+ /** Rewrite a settings patch so no secret value reaches the blob. See the file doc. */
7080
+ async function transformSecretWrite(input) {
7081
+ const deletes = [];
7082
+ const base = {
7083
+ secrets: input.secrets,
7084
+ mintId: input.mintId ?? defaultMintId,
7085
+ deletes,
7086
+ operatorWrite: input.operatorWrite === true
7087
+ };
7088
+ const out = {};
7089
+ for (const [key, incoming] of Object.entries(input.patch)) {
7090
+ const { base: baseKey, nodeId } = splitNodeKey(key);
7091
+ const node = input.tree.get(baseKey);
7092
+ if (node === void 0) {
7093
+ out[key] = incoming;
7094
+ continue;
7095
+ }
7096
+ const scope = nodeId !== null && nodeId.length > 0 ? {
7097
+ kind: "node",
7098
+ nodeId
7099
+ } : input.scope ?? globalSecretScope();
7100
+ const result = await writeNode({
7101
+ ...base,
7102
+ scope
7103
+ }, node, incoming, input.stored[key], baseKey);
7104
+ if (result.kind === "value") out[key] = result.value;
7105
+ }
7106
+ return {
7107
+ patch: out,
7108
+ afterWrite: async () => {
7109
+ if (deletes.length === 0) return { orphaned: [] };
7110
+ try {
7111
+ await input.secrets.delete([...new Set(deletes)]);
7112
+ return { orphaned: [] };
7113
+ } catch {
7114
+ return { orphaned: [...new Set(deletes)] };
7115
+ }
7116
+ }
7117
+ };
7118
+ }
7119
+ /** Is `ref` one of `owner`'s refs? */
7120
+ function isSecretRefOwnedBy(ref, owner) {
7121
+ return parseSecretRef(ref)?.owner === owner;
7122
+ }
7123
+ /**
7124
+ * Replace every marker in `value` with its keychain value. Returns the SAME
7125
+ * reference when there is no marker (no allocation, no keychain call).
7126
+ */
7127
+ async function resolveSecretMarkers(value, secrets, options = {}) {
7128
+ const keepMarker = options.unresolved === "keep-marker";
7129
+ const owner = options.ownedBy;
7130
+ const inScope = (ref) => owner === void 0 || isSecretRefOwnedBy(ref, owner);
7131
+ const refs = collectSecretMarkerRefs(value).filter(inScope);
7132
+ if (refs.length === 0) return {
7133
+ value,
7134
+ unresolved: []
7135
+ };
7136
+ const answers = await secrets.resolve(refs);
7137
+ const unresolved = [];
7138
+ for (const ref of new Set(refs)) {
7139
+ const answer = answers[ref];
7140
+ if (answer === void 0) unresolved.push({
7141
+ ref,
7142
+ reason: "not-initialized"
7143
+ });
7144
+ else if (answer.kind === "unavailable") unresolved.push({
7145
+ ref,
7146
+ reason: answer.reason
7147
+ });
7148
+ else if (answer.kind === "missing" || answer.kind === "forbidden") unresolved.push({
7149
+ ref,
7150
+ reason: answer.kind
7151
+ });
7152
+ }
7153
+ const substitute = (v) => {
7154
+ if (isSecretMarker(v)) {
7155
+ if (!inScope(v.$secret)) return {
7156
+ keep: true,
7157
+ value: v
7158
+ };
7159
+ const answer = answers[v.$secret];
7160
+ if (answer?.kind === "value") return {
7161
+ keep: true,
7162
+ value: answer.value
7163
+ };
7164
+ return keepMarker ? {
7165
+ keep: true,
7166
+ value: v
7167
+ } : {
7168
+ keep: false,
7169
+ value: void 0
7170
+ };
7171
+ }
7172
+ if (Array.isArray(v)) {
7173
+ const items = [];
7174
+ for (const item of v) {
7175
+ const s = substitute(item);
7176
+ if (s.keep) items.push(s.value);
7177
+ }
7178
+ return {
7179
+ keep: true,
7180
+ value: items
7181
+ };
7182
+ }
7183
+ if (isRecord$1(v)) {
7184
+ const out = {};
7185
+ for (const [k, child] of Object.entries(v)) {
7186
+ const s = substitute(child);
7187
+ if (s.keep) out[k] = s.value;
7188
+ }
7189
+ return {
7190
+ keep: true,
7191
+ value: out
7192
+ };
7193
+ }
7194
+ return {
7195
+ keep: true,
7196
+ value: v
7197
+ };
7198
+ };
7199
+ return {
7200
+ value: substitute(value).value,
7201
+ unresolved
7202
+ };
7203
+ }
7204
+ /** An addon tried to replace a stored secret it could not read. Nothing was written. */
7205
+ var SecretOverwriteRefusedError = class extends Error {
7206
+ ref;
7207
+ reason;
7208
+ constructor(ref, reason) {
7209
+ 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.`);
7210
+ this.ref = ref;
7211
+ this.reason = reason;
7212
+ this.name = "SecretOverwriteRefusedError";
7213
+ }
7214
+ };
7215
+ function isRecord(value) {
7216
+ return typeof value === "object" && value !== null && !Array.isArray(value);
7217
+ }
7218
+ function resolvedValue(pass, marker) {
7219
+ const answer = pass.answers[marker.$secret];
7220
+ return answer?.kind === "value" ? answer.value : null;
7221
+ }
7222
+ async function atMarker(pass, incoming, stored) {
7223
+ if (incoming === null) return stored;
7224
+ if (typeof incoming !== "string") return incoming;
7225
+ if (incoming === resolvedValue(pass, stored)) return stored;
7226
+ const intent = classifySecretWrite(incoming);
7227
+ if (intent.kind !== "set") return stored;
7228
+ const ref = stored.$secret;
7229
+ if (!isSecretRefOwnedBy(ref, pass.secrets.owner)) return incoming;
7230
+ const answer = pass.answers[ref];
7231
+ 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);
7232
+ try {
7233
+ await pass.secrets.put(ref, intent.value);
7234
+ } catch (err) {
7235
+ throw new KeychainWriteRefusedError(ref, err);
7236
+ }
7237
+ pass.changedRefs.push(ref);
7238
+ return stored;
7239
+ }
7240
+ function inArray(pass, incoming, stored) {
7241
+ return incoming.map((item, index) => {
7242
+ const twin = stored[index];
7243
+ if (isSecretMarker(twin)) return typeof item === "string" && item === resolvedValue(pass, twin) ? twin : item;
7244
+ if (isRecord(item) && isRecord(twin)) return inArrayRow(pass, item, twin);
7245
+ if (Array.isArray(item) && Array.isArray(twin)) return inArray(pass, item, twin);
7246
+ return item;
7247
+ });
7248
+ }
7249
+ function inArrayRow(pass, incoming, stored) {
7250
+ const out = { ...incoming };
7251
+ for (const [key, value] of Object.entries(incoming)) {
7252
+ const twin = stored[key];
7253
+ if (isSecretMarker(twin)) {
7254
+ if (typeof value === "string" && value === resolvedValue(pass, twin)) out[key] = twin;
7255
+ } else if (isRecord(value) && isRecord(twin)) out[key] = inArrayRow(pass, value, twin);
7256
+ else if (Array.isArray(value) && Array.isArray(twin)) out[key] = inArray(pass, value, twin);
7257
+ }
7258
+ return out;
7259
+ }
7260
+ async function walk(pass, incoming, stored) {
7261
+ if (isSecretMarker(stored)) return atMarker(pass, incoming, stored);
7262
+ if (Array.isArray(incoming) && Array.isArray(stored)) return inArray(pass, incoming, stored);
7263
+ if (!isRecord(incoming) || !isRecord(stored)) return incoming;
7264
+ const out = { ...incoming };
7265
+ for (const [key, value] of Object.entries(incoming)) out[key] = await walk(pass, value, stored[key]);
7266
+ return out;
7267
+ }
7268
+ /** Restore markers a write-back carries as values. See the file doc. */
7269
+ async function restoreUnchangedSecrets(input) {
7270
+ const refs = [];
7271
+ for (const key of Object.keys(input.patch)) collectSecretMarkerRefs(input.stored[key], refs);
7272
+ const owned = refs.filter((ref) => isSecretRefOwnedBy(ref, input.secrets.owner));
7273
+ if (owned.length === 0) return {
7274
+ patch: input.patch,
7275
+ changedRefs: []
7276
+ };
7277
+ const pass = {
7278
+ secrets: input.secrets,
7279
+ answers: await input.secrets.resolve([...new Set(owned)]),
7280
+ operatorWrite: input.operatorWrite,
7281
+ changedRefs: []
7282
+ };
7283
+ const out = {};
7284
+ for (const [key, value] of Object.entries(input.patch)) out[key] = await walk(pass, value, input.stored[key]);
7285
+ return {
7286
+ patch: out,
7287
+ changedRefs: pass.changedRefs
7288
+ };
7289
+ }
7290
+ /** Structural equality over JSON-shaped values (key order does not matter). */
7291
+ function isJsonEqual(a, b) {
7292
+ if (Object.is(a, b)) return true;
7293
+ if (Array.isArray(a)) return Array.isArray(b) && a.length === b.length && a.every((v, i) => isJsonEqual(v, b[i]));
7294
+ if (isRecord(a) && isRecord(b)) {
7295
+ const keys = Object.keys(a);
7296
+ if (keys.length !== Object.keys(b).length) return false;
7297
+ return keys.every((k) => Object.prototype.hasOwnProperty.call(b, k) && isJsonEqual(a[k], b[k]));
7298
+ }
7299
+ return false;
7300
+ }
7301
+ /** The patch without the keys whose value already equals the stored one. */
7302
+ function dropUnchangedKeys(patch, stored) {
7303
+ const out = {};
7304
+ for (const [key, value] of Object.entries(patch)) {
7305
+ if (Object.prototype.hasOwnProperty.call(stored, key) && isJsonEqual(value, stored[key])) continue;
7306
+ out[key] = value;
7307
+ }
7308
+ return out;
7309
+ }
7310
+ /** The top-level keys of a blob that hold at least one of `owner`'s markers. */
7311
+ function markerKeysOf(blob, owner) {
7312
+ const keys = /* @__PURE__ */ new Set();
7313
+ for (const [key, value] of Object.entries(blob)) if (collectSecretMarkerRefs(value).some((ref) => isSecretRefOwnedBy(ref, owner))) keys.add(key);
7314
+ return keys;
7315
+ }
7316
+ function nodeFromStored(value, owner) {
7317
+ if (isSecretMarker(value)) return isSecretRefOwnedBy(value.$secret, owner) ? { kind: "leaf" } : null;
7318
+ if (!isRecord(value)) return null;
7319
+ const children = /* @__PURE__ */ new Map();
7320
+ for (const [key, child] of Object.entries(value)) {
7321
+ const node = nodeFromStored(child, owner);
7322
+ if (node !== null) children.set(key, node);
7323
+ }
7324
+ return children.size > 0 ? {
7325
+ kind: "object",
7326
+ children
7327
+ } : null;
7328
+ }
7329
+ /**
7330
+ * The declared secret tree, widened by every place the STORED blob holds a
7331
+ * marker under one of `keys` — so a marker the schema no longer declares (or
7332
+ * never declared: Wyze before b4906cec6) still gets the save path's
7333
+ * KEEP / SET / CLEAR semantics instead of being overwritten by whatever the
7334
+ * addon writes. Markers inside arrays are not added: a row has no id field to
7335
+ * match by unless the schema declares one. Only `owner`'s markers count: a
7336
+ * builtin that keeps another addon's marker (device-manager) never takes it
7337
+ * over.
7338
+ */
7339
+ function widenTreeWithStoredMarkers(declared, stored, keys, owner) {
7340
+ const added = /* @__PURE__ */ new Map();
7341
+ for (const key of keys) {
7342
+ const at = key.indexOf("@");
7343
+ const base = at > 0 ? key.slice(0, at) : key;
7344
+ if (declared.has(base) || added.has(base)) continue;
7345
+ const node = nodeFromStored(stored[key], owner);
7346
+ if (node !== null) added.set(base, node);
7347
+ }
7348
+ return added.size === 0 ? declared : new Map([...declared, ...added]);
7349
+ }
7350
+ /** The blob as stored now; a failed read REFUSES the write instead of guessing. */
7351
+ async function readStoredAddonBlob(raw) {
7352
+ const threeWay = raw.readAddonStoreResult;
7353
+ if (threeWay === void 0) return raw.readAddonStore();
7354
+ const result = await threeWay.call(raw);
7355
+ if (result.kind === "failed") throw new Error(`settings write refused: the stored blob could not be read (${result.error})`);
7356
+ return result.kind === "missing" ? {} : result.value;
7357
+ }
7358
+ function touchesTree(tree, patch) {
7359
+ if (tree.size === 0) return false;
7360
+ for (const key of Object.keys(patch)) {
7361
+ const at = key.indexOf("@");
7362
+ if (tree.has(at > 0 ? key.slice(0, at) : key)) return true;
7363
+ }
7364
+ return false;
7365
+ }
7366
+ /**
7367
+ * Which top-level keys of each store held markers when last seen. `undefined`
7368
+ * for a store not seen yet: its first write reads it, to be safe.
7369
+ */
7370
+ var MarkerKeyIndex = class {
7371
+ owner;
7372
+ byStore = /* @__PURE__ */ new Map();
7373
+ constructor(owner) {
7374
+ this.owner = owner;
7375
+ }
7376
+ seen(store, blob) {
7377
+ this.byStore.set(store, markerKeysOf(blob, this.owner));
7378
+ }
7379
+ wrote(store, patch) {
7380
+ const keys = this.byStore.get(store);
7381
+ if (keys === void 0) return;
7382
+ const now = markerKeysOf(patch, this.owner);
7383
+ for (const key of Object.keys(patch)) if (now.has(key)) keys.add(key);
7384
+ else keys.delete(key);
7385
+ }
7386
+ mayHoldMarkers(store, patch) {
7387
+ const keys = this.byStore.get(store);
7388
+ if (keys === void 0) return true;
7389
+ return Object.keys(patch).some((key) => keys.has(key));
7390
+ }
7391
+ };
7392
+ function createHandle(raw, opts) {
7393
+ const chains = /* @__PURE__ */ new Map();
7394
+ const serialize = (key, fn) => {
7395
+ const next = (chains.get(key) ?? Promise.resolve()).then(fn, fn);
7396
+ const tail = next.catch(() => void 0);
7397
+ chains.set(key, tail);
7398
+ tail.then(() => {
7399
+ if (chains.get(key) === tail) chains.delete(key);
7400
+ });
7401
+ return next;
7402
+ };
7403
+ const index = new MarkerKeyIndex(opts.secrets.owner);
7404
+ const resolveRead = async (store, blob) => {
7405
+ index.seen(store, blob);
7406
+ const { value, unresolved } = await resolveSecretMarkers(blob, opts.secrets, {
7407
+ unresolved: "keep-marker",
7408
+ ownedBy: opts.secrets.owner
7409
+ });
7410
+ if (unresolved.length > 0) opts.onUnresolved?.(unresolved);
7411
+ return value;
7412
+ };
7413
+ const write = async (store, declared, scope, patch, readStored, rawWrite) => {
7414
+ if (!touchesTree(declared, patch) && !index.mayHoldMarkers(store, patch)) {
7415
+ await rawWrite(patch);
7416
+ index.wrote(store, patch);
7417
+ return { changed: true };
7418
+ }
7419
+ return serialize(store, async () => {
7420
+ const stored = await readStored();
7421
+ index.seen(store, stored);
7422
+ const operatorWrite = opts.isOperatorWrite?.() === true;
7423
+ const restored = await restoreUnchangedSecrets({
7424
+ patch,
7425
+ stored,
7426
+ secrets: opts.secrets,
7427
+ operatorWrite
7428
+ });
7429
+ const result = await transformSecretWrite({
7430
+ tree: widenTreeWithStoredMarkers(declared, stored, Object.keys(restored.patch), opts.secrets.owner),
7431
+ secrets: opts.secrets,
7432
+ patch: restored.patch,
7433
+ stored,
7434
+ ...scope !== void 0 ? { scope } : {},
7435
+ operatorWrite
7436
+ });
7437
+ const effective = dropUnchangedKeys(result.patch, stored);
7438
+ const wroteBlob = Object.keys(effective).length > 0;
7439
+ if (wroteBlob) {
7440
+ await rawWrite(effective);
7441
+ index.wrote(store, effective);
7442
+ }
7443
+ const { orphaned } = await result.afterWrite();
7444
+ if (orphaned.length > 0) opts.onOrphaned(orphaned);
7445
+ return { changed: wroteBlob || restored.changedRefs.length > 0 };
7446
+ });
7447
+ };
7448
+ const writeAddon = (patch) => write("addon", opts.addonTree(), void 0, patch, () => readStoredAddonBlob(raw), (p) => raw.writeAddonStore(p));
7449
+ const readAddonStoreResult = raw.readAddonStoreResult;
7450
+ const readAddonStoreKeyResult = raw.readAddonStoreKeyResult;
7451
+ const readDeviceStoreBatch = raw.readDeviceStoreBatch;
7452
+ const overrides = {
7453
+ readAddonStore: async () => resolveRead("addon", await raw.readAddonStore()),
7454
+ ...readAddonStoreResult !== void 0 ? { readAddonStoreResult: async () => {
7455
+ const result = await readAddonStoreResult.call(raw);
7456
+ return result.kind === "value" ? {
7457
+ kind: "value",
7458
+ value: await resolveRead("addon", result.value)
7459
+ } : result;
7460
+ } } : {},
7461
+ ...readAddonStoreKeyResult !== void 0 ? { readAddonStoreKeyResult: async (key) => {
7462
+ const result = await readAddonStoreKeyResult.call(raw, key);
7463
+ if (result.kind !== "present") return result;
7464
+ const { value, unresolved } = await resolveSecretMarkers({ [key]: result.value }, opts.secrets, {
7465
+ unresolved: "keep-marker",
7466
+ ownedBy: opts.secrets.owner
7467
+ });
7468
+ if (unresolved.length > 0) opts.onUnresolved?.(unresolved);
7469
+ return {
7470
+ kind: "present",
7471
+ value: value[key]
7472
+ };
7473
+ } } : {},
7474
+ readDeviceStore: async (deviceId) => resolveRead(`device:${deviceId}`, await raw.readDeviceStore(deviceId)),
7475
+ ...readDeviceStoreBatch !== void 0 ? { readDeviceStoreBatch: async (deviceIds) => {
7476
+ const rows = await readDeviceStoreBatch.call(raw, deviceIds);
7477
+ const out = /* @__PURE__ */ new Map();
7478
+ for (const [deviceId, blob] of rows) out.set(deviceId, await resolveRead(`device:${deviceId}`, blob));
7479
+ return out;
7480
+ } } : {},
7481
+ writeAddonStore: async (patch) => {
7482
+ await writeAddon(patch);
7483
+ },
7484
+ writeDeviceStore: async (deviceId, patch) => {
7485
+ await write(`device:${deviceId}`, opts.deviceTree(), {
7486
+ kind: "device",
7487
+ deviceId
7488
+ }, patch, () => raw.readDeviceStore(deviceId), (p) => raw.writeDeviceStore(deviceId, p));
7489
+ }
7490
+ };
7491
+ return {
7492
+ settings: new Proxy(raw, { get(target, prop, receiver) {
7493
+ if (typeof prop === "string" && Object.prototype.hasOwnProperty.call(overrides, prop)) return Reflect.get(overrides, prop);
7494
+ const value = Reflect.get(target, prop, receiver);
7495
+ return typeof value === "function" ? value.bind(target) : value;
7496
+ } }),
7497
+ raw: {
7498
+ readAddonStore: async () => {
7499
+ const blob = await raw.readAddonStore();
7500
+ index.seen("addon", blob);
7501
+ return blob;
7502
+ },
7503
+ readDeviceStore: async (deviceId) => {
7504
+ const blob = await raw.readDeviceStore(deviceId);
7505
+ index.seen(`device:${deviceId}`, blob);
7506
+ return blob;
7507
+ }
7508
+ },
7509
+ writeAddonStore: writeAddon
7510
+ };
7511
+ }
7512
+ /** The context the addon sees, plus the private raw view and write outcome. */
7513
+ function createSecretAwareContext(context, opts) {
7514
+ const raw = context.settings;
7515
+ if (raw === void 0) return {
7516
+ context,
7517
+ handle: null
7518
+ };
7519
+ const handle = createHandle(raw, opts);
7520
+ return {
7521
+ context: new Proxy(context, { get(target, prop, receiver) {
7522
+ if (prop === "settings") return handle.settings;
7523
+ return Reflect.get(target, prop, receiver);
7524
+ } }),
7525
+ handle
7526
+ };
7527
+ }
7528
+ var LEAF = { kind: "leaf" };
7529
+ var DEFAULT_ITEM_ID_KEY = "id";
7530
+ function collectFields(fields, out) {
7531
+ for (const field of fields) {
7532
+ if (field.type === "group") {
7533
+ collectFields(field.fields, out);
7534
+ continue;
7535
+ }
7536
+ if (field.type === "sub-tabs") {
7537
+ for (const tab of field.tabs) collectFields(tab.fields, out);
7538
+ continue;
7539
+ }
7540
+ if (field.type === "editable-array") {
7541
+ const item = /* @__PURE__ */ new Map();
7542
+ for (const itemField of field.itemFields) if ("key" in itemField && isKeychainStoredField(itemField)) item.set(itemField.key, LEAF);
7543
+ if (item.size > 0) out.set(field.key, {
7544
+ kind: "array",
7545
+ idKey: field.itemIdKey ?? DEFAULT_ITEM_ID_KEY,
7546
+ item
7547
+ });
7548
+ continue;
7549
+ }
7550
+ if (!("key" in field) || typeof field.key !== "string") continue;
7551
+ if (isKeychainStoredField(field)) out.set(field.key, LEAF);
7552
+ }
7553
+ }
7554
+ /** The secret tree a settings schema declares. */
7555
+ function secretTreeFromSchema(schema) {
7556
+ const out = /* @__PURE__ */ new Map();
7557
+ if (schema === null) return out;
7558
+ for (const section of schema.sections) collectFields(section.fields, out);
7559
+ return out;
7560
+ }
7561
+ /** Parse `a.b[id].c` into segments; throws on a malformed path (a declaration bug). */
7562
+ function parseSecretStatePath(path) {
7563
+ const segments = [];
7564
+ for (const raw of path.split(".")) {
7565
+ const m = /^([^[\]]+)(?:\[([^[\]]+)\])?$/.exec(raw);
7566
+ if (m === null || m[1] === void 0) throw new Error(`secretStatePaths: malformed path "${path}"`);
7567
+ segments.push(m[2] !== void 0 ? {
7568
+ key: m[1],
7569
+ idKey: m[2]
7570
+ } : { key: m[1] });
7571
+ }
7572
+ if (segments.length === 0) throw new Error(`secretStatePaths: empty path`);
7573
+ if (segments[segments.length - 1]?.idKey !== void 0) throw new Error(`secretStatePaths: "${path}" ends on an array — name the member that is secret`);
7574
+ return segments;
7575
+ }
7576
+ function insert(into, segments) {
7577
+ const [head, ...rest] = segments;
7578
+ if (head === void 0) return;
7579
+ if (rest.length === 0) {
7580
+ into.set(head.key, LEAF);
7581
+ return;
7582
+ }
7583
+ const existing = into.get(head.key);
7584
+ if (head.idKey !== void 0) {
7585
+ const item = new Map(existing?.kind === "array" ? existing.item : []);
7586
+ insert(item, rest);
7587
+ into.set(head.key, {
7588
+ kind: "array",
7589
+ idKey: head.idKey,
7590
+ item
7591
+ });
7592
+ return;
7593
+ }
7594
+ const children = new Map(existing?.kind === "object" ? existing.children : []);
7595
+ insert(children, rest);
7596
+ into.set(head.key, {
7597
+ kind: "object",
7598
+ children
7599
+ });
7600
+ }
7601
+ /** Add hidden-state paths (`secretStatePaths`) to a schema-derived tree. */
7602
+ function mergeSecretStatePaths(tree, paths) {
7603
+ if (paths.length === 0) return tree;
7604
+ const out = new Map(tree);
7605
+ for (const path of paths) insert(out, parseSecretStatePath(path));
7606
+ return out;
7607
+ }
7608
+ /** First retry of a secret the keychain could not serve; doubles to {@link SECRET_RETRY_MAX_MS}. */
7609
+ var SECRET_RETRY_FIRST_MS = 5e3;
7610
+ var SECRET_RETRY_MAX_MS = 5 * 6e4;
7611
+ /** Coalesces a burst of `keychain.changed` events into one re-resolve. */
7612
+ var SECRET_CHANGE_DEBOUNCE_MS = 250;
6730
7613
  /**
6731
7614
  * Base class for CamStack addons. Eliminates settings boilerplate:
6732
7615
  *
@@ -6796,6 +7679,33 @@ var BaseAddon = class {
6796
7679
  settingsStoreReady = false;
6797
7680
  /** Default config values. Provided via constructor. */
6798
7681
  defaults;
7682
+ /**
7683
+ * Hidden-state paths that hold secrets (D787) — values the addon writes
7684
+ * itself (`updateGlobalSettings`, `state()`) that no form field declares.
7685
+ * Stored in the keychain exactly like a `password` field. Syntax:
7686
+ * `'snapshotSigningKey'`, `'identity.pincode'`, `'tokens[userId].accessToken'`
7687
+ * (`key[<id field>]` addresses array items by id, never by index).
7688
+ */
7689
+ secretStatePaths = [];
7690
+ _addonSecretTree = null;
7691
+ _deviceSecretTree = null;
7692
+ /** Refs the last resolved config pointed at — a change to one re-resolves. */
7693
+ _configSecretRefs = /* @__PURE__ */ new Set();
7694
+ _unresolvedSecrets = [];
7695
+ _secretRetryTimer = null;
7696
+ _secretRetryDelayMs = SECRET_RETRY_FIRST_MS;
7697
+ _secretChangeTimer = null;
7698
+ _secretChangeUnsub = null;
7699
+ /** >0 while an OPERATOR's settings write is being applied. */
7700
+ _operatorWriteDepth = 0;
7701
+ /**
7702
+ * The keychain-aware settings handle (D798). Its `raw` view is the ONLY way
7703
+ * to the marker-bearing blobs and stays private to this class: the form
7704
+ * hydrate and config resolution need markers, addon code never does.
7705
+ */
7706
+ _secretSettings = null;
7707
+ /** Refs an addon-facing read could not resolve — each is logged once per process. */
7708
+ _loggedUnresolvedReads = /* @__PURE__ */ new Set();
6799
7709
  constructor(defaults) {
6800
7710
  this.defaults = defaults;
6801
7711
  this._config = { ...defaults };
@@ -6831,8 +7741,26 @@ var BaseAddon = class {
6831
7741
  return this._config;
6832
7742
  }
6833
7743
  async initialize(context) {
6834
- this._ctx = context;
7744
+ const secrets = context.secrets;
7745
+ if (secrets !== void 0) {
7746
+ const { context: wrapped, handle } = createSecretAwareContext(context, {
7747
+ secrets,
7748
+ addonTree: () => this.addonSecretTree(),
7749
+ deviceTree: () => this.deviceSecretTree(),
7750
+ onOrphaned: (refs) => context.logger.warn("keychain refs dropped by a settings write could not be deleted", { meta: { refs: [...refs] } }),
7751
+ isOperatorWrite: () => this._operatorWriteDepth > 0,
7752
+ onUnresolved: (unresolved) => this.logUnresolvedRead(unresolved)
7753
+ });
7754
+ this._ctx = wrapped;
7755
+ this._secretSettings = handle;
7756
+ } else {
7757
+ this._ctx = context;
7758
+ this._secretSettings = null;
7759
+ }
6835
7760
  await this.resolveConfig();
7761
+ if (secrets !== void 0) this._secretChangeUnsub = secrets.onChange((ref) => {
7762
+ if (this._configSecretRefs.has(ref)) this.scheduleSecretReresolve(SECRET_CHANGE_DEBOUNCE_MS);
7763
+ });
6836
7764
  const result = await this.onInitialize();
6837
7765
  this.emitLifecycle(EventCategory.AddonStarted);
6838
7766
  const normalized = normalizeAddonInitResult(result);
@@ -6865,6 +7793,12 @@ var BaseAddon = class {
6865
7793
  */
6866
7794
  async onHubReachable() {}
6867
7795
  async shutdown() {
7796
+ this._secretChangeUnsub?.();
7797
+ this._secretChangeUnsub = null;
7798
+ if (this._secretRetryTimer !== null) clearTimeout(this._secretRetryTimer);
7799
+ if (this._secretChangeTimer !== null) clearTimeout(this._secretChangeTimer);
7800
+ this._secretRetryTimer = null;
7801
+ this._secretChangeTimer = null;
6868
7802
  this.emitLifecycle(EventCategory.AddonStopped);
6869
7803
  if (this.autoEmitReadiness) this.emitReadinessForProviders("down");
6870
7804
  await this.onShutdown();
@@ -6939,11 +7873,8 @@ var BaseAddon = class {
6939
7873
  async getGlobalSettings(overlay, cap, nodeId) {
6940
7874
  const schema = this.globalSettingsSchema(cap);
6941
7875
  if (!schema) return { sections: [] };
6942
- const projected = await this.resolveGlobalStore(nodeId, cap);
6943
- return hydrateSchema(schema, overlay ? {
6944
- ...projected,
6945
- ...overlay
6946
- } : projected);
7876
+ const projected = await this.readRawProjectedStore(nodeId, cap);
7877
+ return hydrateSchema(schema, overlay ? await this.overlayKeepingMarkers(projected, overlay) : projected, { inlineSecretsAsViews: true });
6947
7878
  }
6948
7879
  /**
6949
7880
  * The integration-level view of this addon's settings: exactly the sections
@@ -6988,11 +7919,11 @@ var BaseAddon = class {
6988
7919
  });
6989
7920
  }
6990
7921
  if (sections.length === 0) return null;
6991
- const projected = await this.resolveGlobalStore(nodeId);
7922
+ const projected = await this.readRawProjectedStore(nodeId);
6992
7923
  return hydrateSchema({
6993
7924
  ...schema,
6994
7925
  sections
6995
- }, projected);
7926
+ }, projected, { inlineSecretsAsViews: true });
6996
7927
  }
6997
7928
  /**
6998
7929
  * The raw addon store PROJECTED onto the target node's bare per-node keys:
@@ -7005,12 +7936,50 @@ var BaseAddon = class {
7005
7936
  * the store for custom option logic (option narrowing, value snapping) to
7006
7937
  * read it per-node — never `ctx.settings.readAddonStore()` directly.
7007
7938
  * `nodeId` omitted ⇒ the local node (node-blind injection from ctx).
7939
+ *
7940
+ * Keychain values come back RESOLVED (D798): a secret reads as its value,
7941
+ * never as a `{ $secret }` marker. One the keychain cannot serve right now
7942
+ * stays a marker — "stored, unavailable" (`isSecretMarker()` is true, and it
7943
+ * is listed in {@link unresolvedSecrets}) — never `''` and never absent, so
7944
+ * it cannot be mistaken for "nothing stored, mint a new one". Writing the
7945
+ * resolved blob back is a no-op for every unchanged secret.
7008
7946
  */
7009
7947
  async resolveGlobalStore(nodeId, cap) {
7010
7948
  const raw = await this._ctx?.settings?.readAddonStore() ?? {};
7949
+ return this.projectForNode(raw, nodeId, cap);
7950
+ }
7951
+ projectForNode(store, nodeId, cap) {
7011
7952
  const keys = this.perNodeKeys(cap);
7012
7953
  const node = normalizeNodeId(nodeId ?? this._ctx?.kernel?.localNodeId);
7013
- return keys.size > 0 ? projectStore(raw, keys, node) : raw;
7954
+ return keys.size > 0 ? projectStore(store, keys, node) : store;
7955
+ }
7956
+ /** The PROJECTED store with its markers — the form hydrate only (D798). */
7957
+ async readRawProjectedStore(nodeId, cap) {
7958
+ const raw = await this.rawSettings()?.readAddonStore() ?? {};
7959
+ return this.projectForNode(raw, nodeId, cap);
7960
+ }
7961
+ /**
7962
+ * `{ ...stored, ...overlay }`, except that an overlay member equal to the
7963
+ * RESOLVED stored one keeps the stored (marker-bearing) member — so a form
7964
+ * hydrated from a resolved overlay still shows a secret as "set", never as
7965
+ * its value.
7966
+ */
7967
+ async overlayKeepingMarkers(stored, overlay) {
7968
+ const secrets = this._ctx?.secrets;
7969
+ const merged = {
7970
+ ...stored,
7971
+ ...overlay
7972
+ };
7973
+ if (secrets === void 0 || collectSecretMarkerRefs(stored).length === 0) return merged;
7974
+ const { value: resolved } = await resolveSecretMarkers(stored, secrets, {
7975
+ unresolved: "keep-marker",
7976
+ ownedBy: secrets.owner
7977
+ });
7978
+ for (const key of Object.keys(overlay)) {
7979
+ if (collectSecretMarkerRefs(stored[key]).length === 0) continue;
7980
+ if (isJsonEqual(overlay[key], resolved[key])) merged[key] = stored[key];
7981
+ }
7982
+ return merged;
7014
7983
  }
7015
7984
  /**
7016
7985
  * Whether ONE global key of this addon's store was written, read three-way
@@ -7046,18 +8015,58 @@ var BaseAddon = class {
7046
8015
  value: result.value[key]
7047
8016
  };
7048
8017
  }
8018
+ /**
8019
+ * The OPERATOR's write — a settings form or an admin API call, dispatched by
8020
+ * the kernel. Identical to {@link updateGlobalSettings}, except that a secret
8021
+ * the operator sends is stored as sent even when it equals a pre-keychain
8022
+ * inline value: the operator re-entering a password is a change, an addon
8023
+ * writing back what it read is not (D787).
8024
+ */
8025
+ async updateGlobalSettingsAsOperator(patch, nodeId) {
8026
+ this._operatorWriteDepth++;
8027
+ try {
8028
+ await this.applyGlobalPatch(patch, nodeId);
8029
+ } finally {
8030
+ this._operatorWriteDepth--;
8031
+ }
8032
+ }
7049
8033
  async updateGlobalSettings(patch, nodeId) {
8034
+ await this.applyGlobalPatch(patch, nodeId);
8035
+ }
8036
+ /**
8037
+ * REMOVE stored secrets — their keychain values and their markers (D787).
8038
+ *
8039
+ * Writing `''` to a secret field KEEPS what is stored (an empty string is
8040
+ * what a defaults fallback writes back, and it must never destroy a
8041
+ * credential), so code that means "forget this token" says so here. Without
8042
+ * a keychain (an older kernel) it writes `''`, as such code always did.
8043
+ */
8044
+ async clearSecrets(keys, nodeId) {
8045
+ const tree = this.addonSecretTree();
8046
+ const keychain = this._ctx?.secrets !== void 0;
8047
+ const stored = keychain ? await this.readAddonStoreWithRetry() : {};
8048
+ const patch = {};
8049
+ for (const key of keys) {
8050
+ const keychainStored = tree.has(key) || collectSecretMarkerRefs(stored[key]).length > 0;
8051
+ patch[key] = keychain && keychainStored ? SECRET_CLEAR : "";
8052
+ }
8053
+ await this.applyGlobalPatch(patch, nodeId);
8054
+ }
8055
+ async applyGlobalPatch(barePatch, nodeId) {
7050
8056
  const keys = this.perNodeKeys();
7051
8057
  const localNode = normalizeNodeId(this._ctx?.kernel?.localNodeId);
7052
8058
  const target = normalizeNodeId(nodeId ?? this._ctx?.kernel?.localNodeId);
7053
- const barePatch = patch;
7054
8059
  const scoped = keys.size > 0 ? scopePatch(barePatch, keys, target) : barePatch;
7055
- await this._ctx?.settings?.writeAddonStore(scoped);
8060
+ const handle = this._secretSettings;
8061
+ if (handle !== null) {
8062
+ const { changed } = await handle.writeAddonStore(scoped);
8063
+ if (!changed) return;
8064
+ } else await this._ctx?.settings?.writeAddonStore(scoped);
7056
8065
  if (target !== localNode) return;
7057
8066
  await this.resolveConfig();
7058
8067
  await this.onConfigChanged();
7059
8068
  this.emitLifecycle(EventCategory.AddonUpdated, { level: "global" });
7060
- this.maybeAutoRestart(patch, this.globalSettingsSchema());
8069
+ this.maybeAutoRestart(Object.keys(barePatch), this.globalSettingsSchema());
7061
8070
  }
7062
8071
  /**
7063
8072
  * The set of field keys the global settings schema declares `perNode: true`
@@ -7082,7 +8091,7 @@ var BaseAddon = class {
7082
8091
  * time to return its response before the addon is torn down and
7083
8092
  * re-initialised by `AddonRegistryService.restartAddon`.
7084
8093
  */
7085
- maybeAutoRestart(patch, schema) {
8094
+ maybeAutoRestart(patchKeys, schema) {
7086
8095
  if (!schema) return;
7087
8096
  const restartKeys = /* @__PURE__ */ new Set();
7088
8097
  for (const section of schema.sections) for (const field of section.fields) {
@@ -7090,13 +8099,13 @@ var BaseAddon = class {
7090
8099
  if (field.requiresRestart) restartKeys.add(field.key);
7091
8100
  }
7092
8101
  if (restartKeys.size === 0) return;
7093
- if (!Object.keys(patch).some((k) => restartKeys.has(k))) return;
8102
+ if (!patchKeys.some((k) => restartKeys.has(k))) return;
7094
8103
  const ctx = this._ctx;
7095
8104
  if (!ctx) return;
7096
8105
  const addonId = ctx.id;
7097
8106
  setImmediate(() => {
7098
8107
  ctx.api.addons?.restartAddon?.mutate({ addonId }).then(() => {
7099
- ctx.logger.info("addon auto-restart triggered by restart-required setting change", { meta: { changedFields: Object.keys(patch).filter((k) => restartKeys.has(k)) } });
8108
+ ctx.logger.info("addon auto-restart triggered by restart-required setting change", { meta: { changedFields: patchKeys.filter((k) => restartKeys.has(k)) } });
7100
8109
  }).catch((err) => {
7101
8110
  ctx.logger.error("addon auto-restart failed", { meta: { error: err instanceof Error ? err.message : String(err) } });
7102
8111
  });
@@ -7105,7 +8114,7 @@ var BaseAddon = class {
7105
8114
  async getDeviceSettings(deviceId) {
7106
8115
  const schema = this.deviceSettingsSchema();
7107
8116
  if (!schema) return { sections: [] };
7108
- return hydrateSchema(schema, await this._ctx?.settings?.readDeviceStore(deviceId) ?? {});
8117
+ return hydrateSchema(schema, await this.rawSettings()?.readDeviceStore(deviceId) ?? {}, { inlineSecretsAsViews: true });
7109
8118
  }
7110
8119
  async updateDeviceSettings(deviceId, patch) {
7111
8120
  await this._ctx?.settings?.writeDeviceStore(deviceId, patch);
@@ -7235,7 +8244,7 @@ var BaseAddon = class {
7235
8244
  * selection at boot (absent scoped key ⇒ the constructor default wins).
7236
8245
  */
7237
8246
  async resolveConfig() {
7238
- const stored = await this.readAddonStoreWithRetry();
8247
+ const stored = await this.resolveStoredSecrets(await this.readAddonStoreWithRetry());
7239
8248
  const perNode = this.perNodeKeys();
7240
8249
  const localNode = normalizeNodeId(this._ctx?.kernel?.localNodeId);
7241
8250
  const resolved = { ...this.defaults };
@@ -7260,7 +8269,7 @@ var BaseAddon = class {
7260
8269
  key,
7261
8270
  schema,
7262
8271
  fallback,
7263
- read: () => this.readAddonStoreWithRetry(),
8272
+ read: async () => this.resolveStoredSecrets(await this.readAddonStoreWithRetry()),
7264
8273
  write: async (patch) => {
7265
8274
  await this._ctx?.settings?.writeAddonStore(patch);
7266
8275
  },
@@ -7277,7 +8286,7 @@ var BaseAddon = class {
7277
8286
  key,
7278
8287
  schema,
7279
8288
  fallback,
7280
- read: async () => await this._ctx?.settings?.readDeviceStore(deviceId) ?? {},
8289
+ read: async () => this.resolveStoredSecrets(await this.rawSettings()?.readDeviceStore(deviceId) ?? {}, false),
7281
8290
  write: async (patch) => {
7282
8291
  await this._ctx?.settings?.writeDeviceStore(deviceId, patch);
7283
8292
  },
@@ -7289,6 +8298,87 @@ var BaseAddon = class {
7289
8298
  } })
7290
8299
  });
7291
8300
  }
8301
+ /** The addon store's secret tree: schema fields by TYPE, plus `secretStatePaths`. */
8302
+ addonSecretTree() {
8303
+ this._addonSecretTree ??= mergeSecretStatePaths(secretTreeFromSchema(this.globalSettingsSchema()), this.secretStatePaths);
8304
+ return this._addonSecretTree;
8305
+ }
8306
+ deviceSecretTree() {
8307
+ this._deviceSecretTree ??= secretTreeFromSchema(this.deviceSettingsSchema());
8308
+ return this._deviceSecretTree;
8309
+ }
8310
+ /**
8311
+ * Secrets of this addon's stored config that could not be resolved on the
8312
+ * last read, with why. Non-empty means the addon is running WITHOUT them —
8313
+ * an addon whose function needs one should report itself degraded rather
8314
+ * than start on an empty credential.
8315
+ */
8316
+ get unresolvedSecrets() {
8317
+ return this._unresolvedSecrets;
8318
+ }
8319
+ /**
8320
+ * Substitute every keychain marker in a stored blob with its value. With no
8321
+ * keychain (no `ctx.secrets`) or no marker, the blob comes back unchanged.
8322
+ * An unresolvable value is LEFT OUT (never `''`), logged by ref — never by
8323
+ * value — and, when the cause can pass, retried with backoff. Nothing is
8324
+ * ever written back from here.
8325
+ */
8326
+ async resolveStoredSecrets(blob, trackForConfig = true) {
8327
+ const secrets = this._ctx?.secrets;
8328
+ if (secrets === void 0) return blob;
8329
+ const refs = collectSecretMarkerRefs(blob);
8330
+ if (trackForConfig) this._configSecretRefs = new Set(refs);
8331
+ if (refs.length === 0) {
8332
+ if (trackForConfig) this._unresolvedSecrets = [];
8333
+ return blob;
8334
+ }
8335
+ const { value, unresolved } = await resolveSecretMarkers(blob, secrets);
8336
+ if (trackForConfig) {
8337
+ this._unresolvedSecrets = unresolved;
8338
+ if (unresolved.length > 0) {
8339
+ this._ctx?.logger?.error?.("secret unavailable — running without it, will retry", { meta: { secrets: unresolved.map((u) => ({
8340
+ ref: u.ref,
8341
+ reason: u.reason
8342
+ })) } });
8343
+ if (unresolved.some((u) => u.reason !== "missing" && u.reason !== "forbidden")) {
8344
+ this.scheduleSecretReresolve(this._secretRetryDelayMs);
8345
+ this._secretRetryDelayMs = Math.min(this._secretRetryDelayMs * 2, SECRET_RETRY_MAX_MS);
8346
+ }
8347
+ } else this._secretRetryDelayMs = SECRET_RETRY_FIRST_MS;
8348
+ }
8349
+ return value;
8350
+ }
8351
+ /**
8352
+ * The marker-bearing settings reads (D798) — private on purpose. Without a
8353
+ * keychain the context's own view is already raw.
8354
+ */
8355
+ rawSettings() {
8356
+ return this._secretSettings?.raw ?? this._ctx?.settings;
8357
+ }
8358
+ /** An addon-facing read met markers it could not resolve: say so once per ref. */
8359
+ logUnresolvedRead(unresolved) {
8360
+ const fresh = unresolved.filter((u) => !this._loggedUnresolvedReads.has(u.ref));
8361
+ if (fresh.length === 0) return;
8362
+ for (const u of fresh) this._loggedUnresolvedReads.add(u.ref);
8363
+ 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) => ({
8364
+ ref: u.ref,
8365
+ reason: u.reason
8366
+ })) } });
8367
+ }
8368
+ /** Re-resolve the config (a keychain-only change, or a retry) and apply it. */
8369
+ scheduleSecretReresolve(delayMs) {
8370
+ const timerOf = delayMs === SECRET_CHANGE_DEBOUNCE_MS ? "_secretChangeTimer" : "_secretRetryTimer";
8371
+ if (this[timerOf] !== null) return;
8372
+ const timer = setTimeout(() => {
8373
+ this[timerOf] = null;
8374
+ if (this._ctx === null) return;
8375
+ this.resolveConfig().then(() => this.onConfigChanged()).catch((err) => {
8376
+ this._ctx?.logger?.error?.("re-resolving secrets failed", { meta: { error: err instanceof Error ? err.message : String(err) } });
8377
+ });
8378
+ }, delayMs);
8379
+ timer.unref?.();
8380
+ this[timerOf] = timer;
8381
+ }
7292
8382
  /**
7293
8383
  * Wrap `ctx.settings.readAddonStore()` with a short retry budget so a
7294
8384
  * transient settings-store outage (mid-restart of sqlite-settings, tsx-watch
@@ -7301,7 +8391,7 @@ var BaseAddon = class {
7301
8391
  * `{}` (defaults) — the addon's first successful patch will rehydrate.
7302
8392
  */
7303
8393
  async readAddonStoreWithRetry() {
7304
- const settings = this._ctx?.settings;
8394
+ const settings = this.rawSettings();
7305
8395
  if (!settings) return {};
7306
8396
  const delaysMs = [
7307
8397
  150,
@@ -7864,6 +8954,69 @@ method(object({ deviceId: number() }), array(StreamSourceEntrySchema)), method(o
7864
8954
  kind: "mutation",
7865
8955
  auth: "admin"
7866
8956
  }), method(object({ deviceId: number() }), unknown().nullable()), method(object({ deviceId: number() }), RawStateResultSchema.nullable(), { auth: "protected" });
8957
+ function defOf(schema) {
8958
+ return schema._zod?.def ?? {};
8959
+ }
8960
+ function declaredHere(schema) {
8961
+ return globalRegistry.get(schema)?.secret === true;
8962
+ }
8963
+ /** Wrapper kinds whose `innerType` is the field itself. */
8964
+ var WRAPPERS = new Set([
8965
+ "optional",
8966
+ "nullable",
8967
+ "default",
8968
+ "prefault",
8969
+ "catch",
8970
+ "readonly",
8971
+ "nonoptional"
8972
+ ]);
8973
+ /**
8974
+ * The schema layers that make up ONE field: the schema itself and every
8975
+ * wrapper below it (optional / default / nullable / readonly / catch), plus
8976
+ * both sides of a pipe (`z.preprocess` puts the real schema on `out`,
8977
+ * `.transform` on `in`).
8978
+ */
8979
+ function layersOf(schema) {
8980
+ const out = [];
8981
+ const queue = [schema];
8982
+ while (queue.length > 0) {
8983
+ const s = queue.shift();
8984
+ if (!s || out.includes(s)) continue;
8985
+ out.push(s);
8986
+ const def = defOf(s);
8987
+ if (def.type !== void 0 && WRAPPERS.has(def.type) && def.innerType) queue.push(def.innerType);
8988
+ if (def.type === "pipe") {
8989
+ if (def.in) queue.push(def.in);
8990
+ if (def.out) queue.push(def.out);
8991
+ }
8992
+ }
8993
+ return out;
8994
+ }
8995
+ /** True when any layer of this field declares `.meta({ secret: true })`. */
8996
+ function isZodSecret(schema) {
8997
+ return layersOf(schema).some(declaredHere);
8998
+ }
8999
+ /**
9000
+ * Every declared secret path in a config schema: dotted keys, `[]` for "each
9001
+ * element of this array" (`connection.password`, `rows[].token`). A declared
9002
+ * object or array is reported as one path and not descended into — everything
9003
+ * under it is secret.
9004
+ */
9005
+ function collectZodSecretPaths(schema, prefix = "") {
9006
+ if (isZodSecret(schema)) return prefix.length > 0 ? [prefix] : [];
9007
+ const paths = [];
9008
+ for (const layer of layersOf(schema)) {
9009
+ const def = defOf(layer);
9010
+ if (def.type === "object" && def.shape) for (const [key, child] of Object.entries(def.shape)) paths.push(...collectZodSecretPaths(child, prefix ? `${prefix}.${key}` : key));
9011
+ else if (def.type === "array" && def.element) paths.push(...collectZodSecretPaths(def.element, `${prefix}[]`));
9012
+ else if (def.type === "union" && def.options) for (const option of def.options) paths.push(...collectZodSecretPaths(option, prefix));
9013
+ else if (def.type === "intersection") {
9014
+ if (def.left) paths.push(...collectZodSecretPaths(def.left, prefix));
9015
+ if (def.right) paths.push(...collectZodSecretPaths(def.right, prefix));
9016
+ }
9017
+ }
9018
+ return [...new Set(paths)];
9019
+ }
7867
9020
  //#endregion
7868
9021
  //#region ../types/dist/err-msg-DX6i_MY4.mjs
7869
9022
  var DeviceType = /* @__PURE__ */ function(DeviceType) {
@@ -9541,6 +10694,278 @@ var CameraSwitchGroupSchema = object({
9541
10694
  fetchedAt: number()
9542
10695
  });
9543
10696
  /**
10697
+ * The trainer contract — what the hub hands the cloud trainer and what it
10698
+ * gets back (cloud training, D805+).
10699
+ *
10700
+ * The trainer (`hf/camstack-trainer`, published as the Hugging Face repo
10701
+ * `camstack/camstack-trainer`) is a separate AGPL program the hub never
10702
+ * imports: `job.json` goes in, files come out, and progress is `CAMSTACK_EVENT`
10703
+ * lines on stdout. These schemas are the hub's half of that boundary; the
10704
+ * trainer's pydantic models (and the JSON Schemas generated from them under
10705
+ * `hf/camstack-trainer/schemas/`) are the other half. A change here is a
10706
+ * change there, in the same piece of work.
10707
+ *
10708
+ * No `.default()` anywhere: defaults do not run on the addon cap path, so the
10709
+ * orchestrator fills every field of a job spec explicitly.
10710
+ */
10711
+ var TRAINING_JOB_SCHEMA = "camstack.training/v1";
10712
+ var TRAINING_RESULT_SCHEMA = "camstack.training-result/v1";
10713
+ /** What the trainer can export. Edge TPU is a later, separate image. */
10714
+ var TrainingExportSchema = _enum([
10715
+ "onnx",
10716
+ "openvino-fp16",
10717
+ "openvino-int8",
10718
+ "coreml-fp16"
10719
+ ]);
10720
+ var FloorsSchema = record(string(), number().min(0).max(1));
10721
+ object({
10722
+ schema: literal(TRAINING_JOB_SCHEMA),
10723
+ jobKey: string().uuid(),
10724
+ target: object({
10725
+ kind: literal("detector"),
10726
+ step: literal("object-detection")
10727
+ }),
10728
+ base: object({
10729
+ modelId: string().min(1),
10730
+ /** Ultralytics weights id, e.g. `yolov9m.pt`. */
10731
+ weights: string().min(1),
10732
+ imgsz: number().int().positive()
10733
+ }),
10734
+ baseline: object({
10735
+ modelId: string().min(1),
10736
+ /** The baseline ONNX the holdout comparison runs; public mirror URL. */
10737
+ onnxUrl: string().url(),
10738
+ imgsz: number().int().positive(),
10739
+ floors: FloorsSchema
10740
+ }),
10741
+ dataset: object({
10742
+ versionId: string().min(1),
10743
+ annotationHash: string(),
10744
+ /** sha256 of the uploaded archive; the trainer refuses a mismatch (exit 65). */
10745
+ sha256: string().regex(/^[0-9a-f]{64}$/)
10746
+ }),
10747
+ split: object({
10748
+ holdoutCameras: array(number().int()),
10749
+ /** When no camera is held out: the last N days of every camera. */
10750
+ holdoutLastDays: number().int().nonnegative(),
10751
+ valFraction: number().min(0).max(.5),
10752
+ seed: number().int()
10753
+ }),
10754
+ hyper: object({
10755
+ epochs: number().int().positive(),
10756
+ batch: number().int().positive(),
10757
+ lr0: number().positive(),
10758
+ /** Layers frozen from the start of the backbone; 0 = none. */
10759
+ freeze: number().int().nonnegative(),
10760
+ patience: number().int().nonnegative(),
10761
+ seed: number().int()
10762
+ }),
10763
+ replay: object({
10764
+ source: literal("coco2017"),
10765
+ count: number().int().nonnegative()
10766
+ }),
10767
+ exports: array(TrainingExportSchema).min(1),
10768
+ calibration: object({ maxFrames: number().int().positive() }),
10769
+ floors: object({
10770
+ minSupport: number().int().positive(),
10771
+ clamp: number().min(0).max(1)
10772
+ }),
10773
+ int8Gate: object({ maxMap50Drop: number().min(0).max(1) }),
10774
+ catalog: object({
10775
+ id: string().regex(/^[a-z0-9][a-z0-9-]{2,80}$/),
10776
+ name: string().min(1).max(160)
10777
+ })
10778
+ });
10779
+ /** One regular file of the bundle. An mlpackage contributes one row per member. */
10780
+ var TrainingResultFileSchema = object({
10781
+ path: string().min(1),
10782
+ bytes: number().int().nonnegative(),
10783
+ sha256: string().regex(/^[0-9a-f]{64}$/),
10784
+ format: _enum([
10785
+ "onnx",
10786
+ "openvino",
10787
+ "coreml",
10788
+ "pt"
10789
+ ]),
10790
+ variant: _enum(["base", "int8"])
10791
+ });
10792
+ var DraftFormatSchema = object({
10793
+ /** RELATIVE path inside the bundle; the hub rewrites it to `camstack-local://`. */
10794
+ url: string().min(1),
10795
+ sizeMB: number().nonnegative(),
10796
+ isDirectory: boolean().optional(),
10797
+ files: array(string()).optional(),
10798
+ runtimes: array(literal("python")).optional(),
10799
+ revision: string().min(1)
10800
+ });
10801
+ /** The trainer's half of a catalog entry; the hub completes it (labels, licence, group). */
10802
+ var TrainingCatalogDraftSchema = object({
10803
+ id: string().min(1),
10804
+ name: string().min(1),
10805
+ description: string(),
10806
+ labels: array(unknown()),
10807
+ inputSize: object({
10808
+ width: number().int().positive(),
10809
+ height: number().int().positive()
10810
+ }),
10811
+ preprocessMode: literal("letterbox"),
10812
+ defaultClassFloors: FloorsSchema,
10813
+ formats: object({
10814
+ onnx: DraftFormatSchema.optional(),
10815
+ openvino: DraftFormatSchema.optional(),
10816
+ coreml: DraftFormatSchema.optional()
10817
+ })
10818
+ });
10819
+ /** One class of one model's holdout report (the eval harness's summary). */
10820
+ var TrainingEvalClassSchema = object({
10821
+ positives: number().int(),
10822
+ floor: number().nullable(),
10823
+ tp: number().int(),
10824
+ fp: number().int(),
10825
+ fn: number().int(),
10826
+ precision: number().nullable(),
10827
+ recall: number().nullable(),
10828
+ ap50: number().nullable(),
10829
+ recallByCamera: record(string(), number().nullable()).optional(),
10830
+ recallByLight: record(string(), number().nullable()).optional(),
10831
+ fpByCamera: record(string(), number()).optional(),
10832
+ smallFound: number().int().optional(),
10833
+ smallTotal: number().int().optional()
10834
+ }).passthrough();
10835
+ var TrainingEvalReportSchema = object({
10836
+ frames: number().int(),
10837
+ classes: record(string(), TrainingEvalClassSchema)
10838
+ }).passthrough();
10839
+ /**
10840
+ * A succeeded result carries every block; a failed one carries the error and
10841
+ * whatever was known by then — the other blocks are ABSENT, not null. The
10842
+ * orchestrator checks the blocks it needs before it trusts a success.
10843
+ */
10844
+ var TrainingResultSchema = object({
10845
+ schema: literal(TRAINING_RESULT_SCHEMA),
10846
+ jobKey: string(),
10847
+ status: _enum(["succeeded", "failed"]),
10848
+ error: object({
10849
+ stage: string(),
10850
+ code: string(),
10851
+ message: string()
10852
+ }).nullable(),
10853
+ trainer: object({
10854
+ version: string(),
10855
+ revision: string()
10856
+ }),
10857
+ toolchain: record(string(), string().nullable()),
10858
+ dataset: object({
10859
+ versionId: string(),
10860
+ annotationHash: string(),
10861
+ sha256: string(),
10862
+ frames: object({
10863
+ train: number().int(),
10864
+ val: number().int(),
10865
+ holdout: number().int()
10866
+ }),
10867
+ holdoutCameras: array(number().int()),
10868
+ replayImages: number().int()
10869
+ }).optional(),
10870
+ training: object({
10871
+ epochsRun: number().int(),
10872
+ bestEpoch: number().int(),
10873
+ bestMap50: number(),
10874
+ bestMap50_95: number(),
10875
+ seconds: number()
10876
+ }).optional(),
10877
+ evaluation: object({
10878
+ holdoutFrames: number().int(),
10879
+ baseline: TrainingEvalReportSchema.nullable(),
10880
+ candidate: TrainingEvalReportSchema.nullable(),
10881
+ candidateInt8: TrainingEvalReportSchema.nullable(),
10882
+ recallDeltaByCamera: record(string(), record(string(), number())).nullable(),
10883
+ map50: record(string(), number().nullable())
10884
+ }).optional(),
10885
+ floors: object({
10886
+ baseline: FloorsSchema,
10887
+ candidate: FloorsSchema,
10888
+ candidateInt8: FloorsSchema.nullable(),
10889
+ notes: array(string())
10890
+ }).optional(),
10891
+ int8: object({
10892
+ kept: boolean(),
10893
+ map50Fp16: number().nullable(),
10894
+ map50Int8: number().nullable(),
10895
+ reason: string().nullable()
10896
+ }).optional(),
10897
+ exportsDropped: array(object({
10898
+ export: string(),
10899
+ reason: string()
10900
+ })).optional(),
10901
+ files: array(TrainingResultFileSchema).optional(),
10902
+ bundle: object({
10903
+ path: literal("bundle.tar"),
10904
+ bytes: number().int().nonnegative(),
10905
+ sha256: string().regex(/^[0-9a-f]{64}$/)
10906
+ }).nullable().optional(),
10907
+ catalogDraft: object({
10908
+ base: TrainingCatalogDraftSchema,
10909
+ int8: TrainingCatalogDraftSchema.nullable()
10910
+ }).nullable().optional(),
10911
+ licence: string()
10912
+ });
10913
+ var TrainingStageSchema = _enum([
10914
+ "prepare",
10915
+ "replay",
10916
+ "train",
10917
+ "eval",
10918
+ "export",
10919
+ "package"
10920
+ ]);
10921
+ var EventBase = {
10922
+ v: literal(1),
10923
+ ts: number()
10924
+ };
10925
+ discriminatedUnion("type", [
10926
+ object({
10927
+ ...EventBase,
10928
+ type: literal("stage"),
10929
+ stage: TrainingStageSchema
10930
+ }),
10931
+ object({
10932
+ ...EventBase,
10933
+ type: literal("epoch"),
10934
+ epoch: number().int(),
10935
+ epochs: number().int(),
10936
+ boxLoss: number().nullable().optional(),
10937
+ map50: number().nullable().optional(),
10938
+ map50_95: number().nullable().optional(),
10939
+ etaSec: number().nullable().optional()
10940
+ }),
10941
+ object({
10942
+ ...EventBase,
10943
+ type: literal("metric"),
10944
+ name: string(),
10945
+ value: number()
10946
+ }),
10947
+ object({
10948
+ ...EventBase,
10949
+ type: literal("artifact"),
10950
+ path: string(),
10951
+ bytes: number(),
10952
+ sha256: string()
10953
+ }),
10954
+ object({
10955
+ ...EventBase,
10956
+ type: literal("done"),
10957
+ status: _enum(["succeeded", "failed"]),
10958
+ resultSha256: string().nullable().optional()
10959
+ }),
10960
+ object({
10961
+ ...EventBase,
10962
+ type: literal("error"),
10963
+ stage: string(),
10964
+ code: string(),
10965
+ message: string()
10966
+ })
10967
+ ]);
10968
+ /**
9544
10969
  * What the gate decided about a birth, from the CALLER's point of view.
9545
10970
  *
9546
10971
  * Deliberately not `ConfirmationVerdict`: `undecided` is not a birth decision
@@ -11868,7 +13293,9 @@ var AddonHttpRouteSchema = object({
11868
13293
  "authenticated",
11869
13294
  "admin"
11870
13295
  ]).optional(),
11871
- description: string().optional()
13296
+ description: string().optional(),
13297
+ /** The hub limits this route per client address before the handler runs. */
13298
+ rateLimit: _enum(["auth"]).optional()
11872
13299
  });
11873
13300
  /**
11874
13301
  * Cross-process route invocation envelope. The hub captures the
@@ -12573,6 +14000,37 @@ var BackupDestinationInfoSchema = object({
12573
14000
  lastError: string().optional()
12574
14001
  });
12575
14002
  /**
14003
+ * How an archive is encrypted (operator decision 2026-10-09): to a backup
14004
+ * PUBLIC key the hub holds, so only the operator's secret key opens it.
14005
+ * Absent on a plain `.tar.gz` — every archive made before encryption, or
14006
+ * with it off — which restores without a key.
14007
+ */
14008
+ var BackupArchiveEncryptionSchema = object({
14009
+ /** `x25519-hkdf-aes256gcm-stream-v1`. */
14010
+ scheme: string(),
14011
+ /** 16 hex — the backup key whose secret restores this archive. */
14012
+ keyId: string()
14013
+ });
14014
+ /**
14015
+ * The backup encryption setting. The hub keeps PUBLIC keys only: the active
14016
+ * one new archives are encrypted to, and the retired ones older archives
14017
+ * still need. The secret key is shown once, at `setupEncryption`.
14018
+ */
14019
+ var BackupEncryptionStatusSchema = object({
14020
+ enabled: boolean(),
14021
+ active: object({
14022
+ keyId: string(),
14023
+ publicKey: string(),
14024
+ createdAt: number()
14025
+ }).nullable(),
14026
+ /** Every key ever set up, newest first. */
14027
+ keys: array(object({
14028
+ keyId: string(),
14029
+ createdAt: number(),
14030
+ retiredAt: number().nullable()
14031
+ })).readonly()
14032
+ });
14033
+ /**
12576
14034
  * Per-archive entry returned by `backup.listArchives({ destinationId })`.
12577
14035
  * Same shape the destination drill-in renders. Sourced from the per-
12578
14036
  * location `manifests.json` (no per-archive tarball read required).
@@ -12584,7 +14042,9 @@ var BackupArchiveEntrySchema = object({
12584
14042
  sizeBytes: number(),
12585
14043
  label: string().optional(),
12586
14044
  /** Top-level locations included in the archive (db, addons, tls, …). */
12587
- locations: array(string()).readonly()
14045
+ locations: array(string()).readonly(),
14046
+ /** Present when the archive is encrypted; restore then needs that key. */
14047
+ encryption: BackupArchiveEncryptionSchema.optional()
12588
14048
  });
12589
14049
  var BackupEntrySchema = object({
12590
14050
  id: string(),
@@ -12593,7 +14053,8 @@ var BackupEntrySchema = object({
12593
14053
  label: string().optional(),
12594
14054
  createdAt: number(),
12595
14055
  sizeBytes: number(),
12596
- locations: array(string()).optional()
14056
+ locations: array(string()).optional(),
14057
+ encryption: BackupArchiveEncryptionSchema.optional()
12597
14058
  });
12598
14059
  var ArchiveEntrySchema = object({
12599
14060
  path: string(),
@@ -12782,10 +14243,40 @@ method(_void(), array(BackupDestinationInfoSchema).readonly(), { auth: "admin" }
12782
14243
  * this list and skips entries whose path doesn't start with
12783
14244
  * any of them.
12784
14245
  */
12785
- locations: array(string()).optional()
14246
+ locations: array(string()).optional(),
14247
+ /**
14248
+ * The backup SECRET key, for an encrypted archive (ignored for a plain
14249
+ * one). The archive is decrypted into the hub's private staging
14250
+ * before the restart; the key is not stored. A wrong or missing key
14251
+ * is refused before the archive is downloaded.
14252
+ */
14253
+ backupSecretKey: string().optional()
12786
14254
  }), _void(), {
12787
14255
  kind: "mutation",
12788
14256
  auth: "admin"
14257
+ }), method(_void(), BackupEncryptionStatusSchema, { auth: "admin" }), method(object({}), object({
14258
+ keyId: string(),
14259
+ secretKey: string(),
14260
+ publicKey: string(),
14261
+ createdAt: number(),
14262
+ replacedKeyId: string().nullable()
14263
+ }), {
14264
+ kind: "mutation",
14265
+ auth: "admin"
14266
+ }), method(object({}), object({ disabledKeyId: string().nullable() }), {
14267
+ kind: "mutation",
14268
+ auth: "admin"
14269
+ }), method(object({ backupSecretKey: string() }), object({
14270
+ valid: boolean(),
14271
+ keyId: string().nullable(),
14272
+ /** The hub knows this key (active or retired). */
14273
+ known: boolean(),
14274
+ /** It is the key new archives are encrypted to. */
14275
+ active: boolean(),
14276
+ error: string().optional()
14277
+ }), {
14278
+ kind: "mutation",
14279
+ auth: "admin"
12789
14280
  }), method(object({
12790
14281
  destinationId: string(),
12791
14282
  backupId: string()
@@ -14511,7 +16002,60 @@ var CustomModelDescriptorSchema = object({
14511
16002
  stepId: string(),
14512
16003
  entry: ModelCatalogEntrySchema
14513
16004
  });
14514
- method(_void(), array(CustomModelDescriptorSchema).readonly(), { auth: "admin" });
16005
+ /** One regular file of an imported bundle, as the producer measured it. */
16006
+ var ModelBundleFileSchema = object({
16007
+ /** Relative path inside the bundle tar; an mlpackage member is `<x>.mlpackage/<member>`. */
16008
+ path: string().min(1),
16009
+ bytes: number().int().nonnegative(),
16010
+ sha256: string().regex(/^[0-9a-f]{64}$/)
16011
+ });
16012
+ var ImportModelBundleInputSchema = object({
16013
+ /** The registry provider that keeps the model (Model Studio). */
16014
+ addonId: string(),
16015
+ stepId: string().min(1),
16016
+ /**
16017
+ * The catalog rows to register, complete, every format URL already
16018
+ * `camstack-local://<modelId>/<file>` naming a file of the bundle. One
16019
+ * bundle may carry several rows (a base and its INT8 variant).
16020
+ */
16021
+ entries: array(ModelCatalogEntrySchema).min(1).max(4),
16022
+ /** The bundle tar, offered by the producer over `ctx.peerBytes` (same host). */
16023
+ bundle: object({
16024
+ ticket: PeerBytesTicketSchema,
16025
+ bytes: number().int().positive(),
16026
+ sha256: string().regex(/^[0-9a-f]{64}$/)
16027
+ }),
16028
+ /** Every file the tar must hold; anything missing, extra or different is refused. */
16029
+ files: array(ModelBundleFileSchema).min(1).max(64),
16030
+ /** Convert missing engine formats and push the model to every agent afterwards. */
16031
+ distribute: boolean()
16032
+ });
16033
+ var ImportModelBundleResultSchema = discriminatedUnion("kind", [object({
16034
+ kind: literal("imported"),
16035
+ modelIds: array(string()).readonly(),
16036
+ distributed: array(object({
16037
+ modelId: string(),
16038
+ nodeId: string(),
16039
+ format: _enum(MODEL_FORMATS),
16040
+ ok: boolean(),
16041
+ error: string().optional()
16042
+ })).readonly()
16043
+ }), object({
16044
+ kind: literal("refused"),
16045
+ reason: _enum([
16046
+ "transfer-failed",
16047
+ "checksum-mismatch",
16048
+ "bundle-mismatch",
16049
+ "invalid-entry",
16050
+ "id-taken"
16051
+ ]),
16052
+ detail: string()
16053
+ })]);
16054
+ method(_void(), array(CustomModelDescriptorSchema).readonly(), { auth: "admin" }), method(ImportModelBundleInputSchema, ImportModelBundleResultSchema, {
16055
+ kind: "mutation",
16056
+ auth: "admin",
16057
+ timeoutMs: 30 * 6e4
16058
+ });
14515
16059
  /**
14516
16060
  * Query filter for settings-store collections.
14517
16061
  */
@@ -14894,6 +16438,253 @@ id: union([string(), number()]) }), {
14894
16438
  kind: "mutation",
14895
16439
  auth: "admin"
14896
16440
  });
16441
+ /**
16442
+ * `keychain` — the hub's encrypted store of secret values (D787).
16443
+ *
16444
+ * Settings blobs never hold a secret: they hold a marker
16445
+ * `{"$secret":"secret://<owner>/<scope>/<fieldPath>","v":1}` and the value
16446
+ * lives here, AES-256-GCM under a data key that a master key wraps. This cap
16447
+ * is the OWNER's door to its own values: every method is owner-checked
16448
+ * against the CALLER, never against anything the caller claims.
16449
+ *
16450
+ * Who the caller is: the transport stamps `callerAddonId` into the args of a
16451
+ * call that crossed a process (the parent `LocalChildRegistry` from the UDS
16452
+ * connection, the agent from its child's connection carried in
16453
+ * `$hub-cap-fwd`'s envelope). A stamp always overwrites; a wire call with no
16454
+ * stamp has its claim stripped. Only a hub in-process caller may state its own
16455
+ * identity — `ctx.secrets` does that with the addon id closed over. This is
16456
+ * identity against BUGS and misrouting, not against a malicious addon (every
16457
+ * runner is the same OS user): see the threat model in
16458
+ * `docs/design/2026-10-08-secrets-keychain.md`.
16459
+ *
16460
+ * `callerAddonId` is deliberately NOT in any input schema: the tRPC router
16461
+ * parses the input, so a session can never supply it, and the internal mount
16462
+ * floors every method to admin anyway (D240).
16463
+ *
16464
+ * Internal: addons reach it through `ctx.secrets`, never directly.
16465
+ */
16466
+ /** Why a value cannot be served right now. Never folded into "missing". */
16467
+ var KeychainUnavailableReasonSchema = _enum([
16468
+ "key-missing",
16469
+ "wrong-key",
16470
+ "key-file-unreadable",
16471
+ "store-unavailable",
16472
+ "not-initialized",
16473
+ "decrypt-failed"
16474
+ ]);
16475
+ var KeychainStateSchema = discriminatedUnion("state", [object({ state: literal("ready") }), object({
16476
+ state: literal("locked"),
16477
+ reason: KeychainUnavailableReasonSchema
16478
+ })]);
16479
+ var KeychainResolveEntrySchema = discriminatedUnion("kind", [
16480
+ object({
16481
+ kind: literal("value"),
16482
+ value: string(),
16483
+ version: number().int()
16484
+ }),
16485
+ object({ kind: literal("missing") }),
16486
+ object({
16487
+ kind: literal("unavailable"),
16488
+ reason: KeychainUnavailableReasonSchema
16489
+ }),
16490
+ object({ kind: literal("forbidden") })
16491
+ ]);
16492
+ var KeychainResolveResultSchema = record(string(), KeychainResolveEntrySchema);
16493
+ /** Metadata of one stored value — never the value. */
16494
+ var KeychainSecretMetaSchema = object({
16495
+ ref: string(),
16496
+ owner: string(),
16497
+ /** Formatted scope (`global`, `node/<id>`, `device/<id>`, …). */
16498
+ scope: string(),
16499
+ fieldPath: string(),
16500
+ version: number().int(),
16501
+ createdAt: number(),
16502
+ updatedAt: number(),
16503
+ /** `addon:<id>` | `user:<id>` | `system`. */
16504
+ updatedBy: string(),
16505
+ /** Coarse — written at most once an hour per ref. `null` = never read. */
16506
+ lastReadAt: number().nullable()
16507
+ });
16508
+ var RefListSchema = array(string().min(1)).max(512);
16509
+ method(object({
16510
+ ref: string().min(1),
16511
+ value: string().min(1)
16512
+ }), object({
16513
+ ref: string(),
16514
+ version: number().int()
16515
+ }), {
16516
+ kind: "mutation",
16517
+ auth: "admin"
16518
+ }), method(object({ refs: RefListSchema }), KeychainResolveResultSchema, { auth: "admin" }), method(object({ refs: RefListSchema }), object({ deleted: number().int() }), {
16519
+ kind: "mutation",
16520
+ auth: "admin"
16521
+ }), method(object({}), array(KeychainSecretMetaSchema).readonly(), { auth: "admin" }), method(object({}), KeychainStateSchema, { auth: "admin" });
16522
+ var KeychainKeySourceSchema = object({
16523
+ kind: _enum([
16524
+ "config-file",
16525
+ "previous-config-file",
16526
+ "platform",
16527
+ "default-file"
16528
+ ]),
16529
+ /** File sources only — a path is not a secret. */
16530
+ path: string().optional(),
16531
+ /**
16532
+ * True when a whole-volume backup of the data directory carries this key
16533
+ * next to the database it protects (the default file). The page warns.
16534
+ */
16535
+ sharesBackupWithDatabase: boolean()
16536
+ });
16537
+ /**
16538
+ * One keychain reset, as the Secrets page reports it until the operator
16539
+ * acknowledges it. Never a value: refs, counts and table names only.
16540
+ */
16541
+ var KeychainResetRecordSchema = object({
16542
+ id: string(),
16543
+ at: number(),
16544
+ /** `user:<id>` or {@link KEYCHAIN_RESET_TRIGGER_ACTOR}. */
16545
+ actor: string(),
16546
+ /** Why the keychain was locked when it was reset; `null` when it was not locked. */
16547
+ lockedReason: string().nullable(),
16548
+ /** Values moved into the archive table (ciphertext under the lost key). */
16549
+ archived: number().int(),
16550
+ /** `keychain:secrets-orphaned-<ts>`, or `null` when nothing was stored. */
16551
+ archivedCollection: string().nullable(),
16552
+ /**
16553
+ * `keychain:keys-orphaned-<ts>`: the wrapped data keys of the archive, kept
16554
+ * so the archive can still be opened if the lost master key turns up.
16555
+ */
16556
+ archivedKeysCollection: string().nullable(),
16557
+ /**
16558
+ * `system-settings` keys whose marker the reset cleared — the cluster
16559
+ * secret's: a marker left pointing at an archived value would refuse every
16560
+ * agent forever (D797).
16561
+ */
16562
+ clearedSettingsKeys: array(string()).readonly(),
16563
+ /** When an operator dismissed the notice on the Secrets page; `null` until then. */
16564
+ acknowledgedAt: number().nullable()
16565
+ });
16566
+ var KeychainStatusSchema = object({
16567
+ keychain: KeychainStateSchema,
16568
+ /** The source of the master key in use; `null` while locked. */
16569
+ keySource: KeychainKeySourceSchema.nullable(),
16570
+ /** The source configured to be primary — differs from `keySource` while a rotation is pending. */
16571
+ configuredSource: KeychainKeySourceSchema,
16572
+ /** Short fingerprint of the master key in use (`HMAC(KEK, label)`, 16 hex). */
16573
+ fingerprint: string().nullable(),
16574
+ activeKeyId: string().nullable(),
16575
+ /**
16576
+ * The keychain unlocked with a NON-primary source: the configured primary
16577
+ * key is not the one that wraps the data key yet. `rotateMasterKey` moves it.
16578
+ */
16579
+ rotationPending: boolean(),
16580
+ /** Wrapped copies of the data key under a previous master key, kept until purged. */
16581
+ retiredWraps: number().int(),
16582
+ recoveryKeyDownloadedAt: number().nullable(),
16583
+ secretCount: number().int(),
16584
+ /** The most recent reset, acknowledged or not; `null` when the keychain was never reset. */
16585
+ lastReset: KeychainResetRecordSchema.nullable()
16586
+ });
16587
+ /**
16588
+ * Whether a stored value is still pointed at by its owner's settings.
16589
+ * `unknown` is a first-class answer: a scope whose blob could not be read is
16590
+ * never reported as an orphan (and never deleted as one).
16591
+ */
16592
+ var KeychainSecretUsageSchema = _enum([
16593
+ "in-use",
16594
+ "orphan",
16595
+ "unknown"
16596
+ ]);
16597
+ var KeychainAdminSecretSchema = KeychainSecretMetaSchema.extend({ usage: KeychainSecretUsageSchema });
16598
+ var KeychainAuditActionSchema = _enum([
16599
+ "put",
16600
+ "delete",
16601
+ "reveal",
16602
+ "rotate-master-key",
16603
+ "purge-retired-keys",
16604
+ "download-recovery-key",
16605
+ "delete-orphans",
16606
+ "reset",
16607
+ "acknowledge-reset",
16608
+ "initialize"
16609
+ ]);
16610
+ var KeychainAuditEntrySchema = object({
16611
+ id: string(),
16612
+ at: number(),
16613
+ action: KeychainAuditActionSchema,
16614
+ /** `addon:<id>` | `user:<id>` | `system` | `trigger-file`. */
16615
+ actor: string(),
16616
+ ref: string().nullable(),
16617
+ detail: string().nullable()
16618
+ });
16619
+ var KEYCHAIN_RESET_CONFIRMATION = "RESET KEYCHAIN";
16620
+ /**
16621
+ * Secrets the HUB itself holds (owner `system`) that no settings form shows:
16622
+ * `jwt-signing-key` — the session signing key (D797). It is always "in use",
16623
+ * never an orphan; it is generated on a fresh hub and replaced only through
16624
+ * {@link keychainAdminCapability.methods.setSystemSecret}.
16625
+ */
16626
+ var SystemHeldSecretNameSchema = _enum(["jwt-signing-key"]);
16627
+ 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({
16628
+ value: string(),
16629
+ version: number().int()
16630
+ }), {
16631
+ kind: "mutation",
16632
+ auth: "admin",
16633
+ caller: "required"
16634
+ }), method(object({
16635
+ name: SystemHeldSecretNameSchema,
16636
+ value: string().min(16)
16637
+ }), object({
16638
+ ref: string(),
16639
+ version: number().int()
16640
+ }), {
16641
+ kind: "mutation",
16642
+ auth: "admin",
16643
+ caller: "required"
16644
+ }), method(object({ refs: array(string().min(1)).max(1e3) }), object({
16645
+ deleted: array(string()).readonly(),
16646
+ kept: array(object({
16647
+ ref: string(),
16648
+ usage: KeychainSecretUsageSchema
16649
+ })).readonly()
16650
+ }), {
16651
+ kind: "mutation",
16652
+ auth: "admin",
16653
+ caller: "required"
16654
+ }), method(object({}), object({
16655
+ fingerprint: string(),
16656
+ keySource: KeychainKeySourceSchema
16657
+ }), {
16658
+ kind: "mutation",
16659
+ auth: "admin",
16660
+ caller: "required"
16661
+ }), method(object({}), object({ purged: number().int() }), {
16662
+ kind: "mutation",
16663
+ auth: "admin",
16664
+ caller: "required"
16665
+ }), method(object({}), object({
16666
+ key: string(),
16667
+ fingerprint: string(),
16668
+ keySource: KeychainKeySourceSchema
16669
+ }), {
16670
+ kind: "mutation",
16671
+ auth: "admin",
16672
+ caller: "required"
16673
+ }), method(object({ confirm: literal(KEYCHAIN_RESET_CONFIRMATION) }), object({
16674
+ archivedCollection: string().nullable(),
16675
+ archived: number().int()
16676
+ }), {
16677
+ kind: "mutation",
16678
+ auth: "admin",
16679
+ caller: "required"
16680
+ }), method(object({}), object({
16681
+ reset: KeychainResetRecordSchema.nullable(),
16682
+ pendingReentry: array(KeychainSecretMetaSchema).readonly()
16683
+ }), { auth: "admin" }), method(object({}), object({ acknowledged: boolean() }), {
16684
+ kind: "mutation",
16685
+ auth: "admin",
16686
+ caller: "required"
16687
+ });
14897
16688
  method(_void(), object({
14898
16689
  id: string(),
14899
16690
  name: string(),
@@ -16136,7 +17927,11 @@ var DeviceRegisterPayloadSchema = object({
16136
17927
  var DeviceRemovePayloadSchema = object({ deviceId: number() });
16137
17928
  var DevicePersistConfigPayloadSchema = object({
16138
17929
  deviceId: number(),
16139
- data: record(string(), unknown())
17930
+ data: record(string(), unknown()),
17931
+ /** The paths the device's schema declares secret (D783), when the caller
17932
+ * knows them — those values are kept in the keychain, not the blob (D787).
17933
+ * Absent: the paths the device last reported at `registerDevice` apply. */
17934
+ secretConfigPaths: array(string()).optional()
16140
17935
  });
16141
17936
  /** What a migration actually did, per switch. `unreachable` is a first-class
16142
17937
  * answer: a camera that could not be asked is not a camera that was silenced. */
@@ -17739,7 +19534,7 @@ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
17739
19534
  * `login-method` — collection cap through which auth addons contribute
17740
19535
  * their pre-auth login surfaces to the login page. This is the SINGLE,
17741
19536
  * generic mechanism that supersedes the dead `auth.listProviders` reader:
17742
- * every auth addon (OIDC, magic-link, WebAuthn/passkey) registers a
19537
+ * every auth addon (OIDC, WebAuthn/passkey) registers a
17743
19538
  * `login-method` provider and the PUBLIC `auth.listLoginMethods`
17744
19539
  * procedure aggregates them for the unauthenticated login page.
17745
19540
  *
@@ -17747,8 +19542,7 @@ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
17747
19542
  *
17748
19543
  * - `redirect` — a declarative button. The login page renders a generic
17749
19544
  * button that navigates to `startUrl` (an addon-owned HTTP route).
17750
- * Covers OIDC (`/addon/auth-oidc/<id>/start`) and magic-link with
17751
- * ZERO shell-side JS. A future SSO addon plugs in the same way — the
19545
+ * Covers OIDC (`/addon/auth-oidc/<id>/start`) with ZERO shell-side JS. A future SSO addon plugs in the same way — the
17752
19546
  * login page needs NO change.
17753
19547
  *
17754
19548
  * - `widget` — a Module-Federation widget the login page mounts (via
@@ -17767,8 +19561,8 @@ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
17767
19561
  * decision.
17768
19562
  *
17769
19563
  * Every contribution carries a `stage`:
17770
- * - `primary` — shown on the first credentials screen (OIDC /
17771
- * magic-link buttons; a future usernameless passkey).
19564
+ * - `primary` — shown on the first credentials screen (OIDC
19565
+ * buttons; a usernameless passkey).
17772
19566
  * - `second-factor` — shown AFTER the password leg, gated on the
17773
19567
  * returned `factors` (passkey-as-2FA today).
17774
19568
  *
@@ -17795,7 +19589,7 @@ var LoginMethodContributionSchema = discriminatedUnion("kind", [
17795
19589
  * The provider names an external identity a signed-in user can link to
17796
19590
  * their own account (D782): `auth.listLinkableProviders` /
17797
19591
  * `beginExternalLink` offer exactly the redirect methods that set this,
17798
- * whatever their id. Absent / false — a login button only (magic-link).
19592
+ * whatever their id. Absent / false — a login button only.
17799
19593
  */
17800
19594
  linkable: boolean().optional()
17801
19595
  }),
@@ -21650,8 +23444,7 @@ method(object({}), object({ rules: array(NcRuleSchema) }), { auth: "admin" }), m
21650
23444
  * `super_admin` — collapsed onto the single boolean because every
21651
23445
  * non-admin caller is governed by the same scope-check rules; the
21652
23446
  * distinction was only ever used to route role-specific procedures
21653
- * which we no longer have. Agents are admin sessions issued via
21654
- * `createServiceToken`; CLI / webhook integrations are `cst_*` tokens
23447
+ * which we no longer have. CLI / webhook integrations are `cst_*` tokens
21655
23448
  * with `isAdmin: false` + an explicit scope list.
21656
23449
  */
21657
23450
  /** Per-method access flavour. Materialised on every cap method via codegen. */
@@ -23153,8 +24946,23 @@ var RetrainMacroClassSchema = _enum([
23153
24946
  ]);
23154
24947
  /** A subject to learn, or a phantom to unlearn (taught by OMISSION). */
23155
24948
  var RetrainAnnotationKindSchema = _enum(["subject", "model_error"]);
23156
- /** Did a human draw this box, or did the assist propose it? */
23157
- var RetrainAnnotationSourceSchema = _enum(["operator", "assist"]);
24949
+ /**
24950
+ * Where a box came from. A machine-sourced box is a DRAFT on the page until
24951
+ * the operator confirms it; once saved it keeps its source as provenance.
24952
+ *
24953
+ * - `operator` — drawn by hand.
24954
+ * - `assist` — proposed by a detector run on the copy (the camera's own
24955
+ * model, or a larger teacher model).
24956
+ * - `pipeline` — the box the live pipeline actually drew on that frame, read
24957
+ * back from the track store (never a re-run).
24958
+ * - `llm` — proposed by a vision-capable LLM profile.
24959
+ */
24960
+ var RetrainAnnotationSourceSchema = _enum([
24961
+ "operator",
24962
+ "assist",
24963
+ "pipeline",
24964
+ "llm"
24965
+ ]);
23158
24966
  /** Normalised `[0,1]` rectangle against the FULL frame — the canonical form. */
23159
24967
  var RetrainBboxSchema = object({
23160
24968
  x: number(),
@@ -23172,7 +24980,8 @@ var RetrainBboxSchema = object({
23172
24980
  */
23173
24981
  var RetrainAnnotationSchema = object({
23174
24982
  id: string(),
23175
- trackId: string(),
24983
+ /** The frame's track. Absent on a recording still, which has none. */
24984
+ trackId: string().optional(),
23176
24985
  deviceId: number(),
23177
24986
  /** The COPY in retrain storage — never the source track's media key. */
23178
24987
  mediaKey: string(),
@@ -23221,13 +25030,47 @@ var RetrainFrameCandidateSchema = object({
23221
25030
  * fail, whatever became of the original. */
23222
25031
  copied: boolean()
23223
25032
  });
25033
+ /**
25034
+ * One box the live pipeline drew on a copied frame — what a correction starts
25035
+ * from. Derived when the frame is listed, from the track store: the subject
25036
+ * box recorded on the source media row when there is one, else the track
25037
+ * position nearest the frame's capture time. Never stored as an annotation
25038
+ * until the operator confirms it.
25039
+ */
25040
+ var RetrainPipelineBoxSchema = object({
25041
+ /** Normalised `[0,1]` against the full frame. */
25042
+ bbox: RetrainBboxSchema,
25043
+ macroClass: RetrainMacroClassSchema,
25044
+ label: string().optional(),
25045
+ subLabel: string().optional(),
25046
+ /** The detection score of the position used, when it was recorded. */
25047
+ score: number().optional(),
25048
+ /** The root model that produced the track, when it was recorded. */
25049
+ modelId: string().optional(),
25050
+ trackId: string(),
25051
+ /** `subject-box`: recorded on this very frame. `position`: the track's
25052
+ * position nearest the capture time, `deltaMs` away. */
25053
+ basis: _enum(["subject-box", "position"]),
25054
+ deltaMs: number()
25055
+ });
25056
+ /**
25057
+ * Where a retrain frame came from: a TRACK's stored media (copy-on-select),
25058
+ * or the RECORDING at an instant — the frame a model saw nothing in has no
25059
+ * track at all.
25060
+ */
25061
+ var RetrainFrameOriginSchema = _enum(["track", "recording"]);
23224
25062
  /** A frame the dataset OWNS: bytes copied at selection time. */
23225
25063
  var RetrainFrameSchema = object({
23226
25064
  frameId: string(),
23227
25065
  deviceId: number(),
23228
- trackId: string(),
23229
- /** Provenance only. It may already point at nothing — that is expected. */
23230
- sourceMediaId: number().int(),
25066
+ origin: RetrainFrameOriginSchema,
25067
+ /** The track it was copied from. Absent on a recording still. */
25068
+ trackId: string().optional(),
25069
+ /** Provenance only. It may already point at nothing — that is expected.
25070
+ * Absent on a recording still. */
25071
+ sourceMediaId: number().int().optional(),
25072
+ /** A recording still: the playhead instant it was taken at. */
25073
+ epochMs: number().optional(),
23231
25074
  sourceKind: MediaFileKindEnum,
23232
25075
  sizeBytes: number().int(),
23233
25076
  width: number().int(),
@@ -23238,7 +25081,12 @@ var RetrainFrameSchema = object({
23238
25081
  /** The operator's "every subject in this frame is boxed". Detector
23239
25082
  * evaluation keeps only complete frames: an unboxed subject would count as
23240
25083
  * a false positive. */
23241
- complete: boolean()
25084
+ complete: boolean(),
25085
+ /** The boxes the pipeline drew on this frame. Present on list answers;
25086
+ * empty when nothing the track store holds can be placed on it. */
25087
+ pipelineBoxes: array(RetrainPipelineBoxSchema).readonly().optional(),
25088
+ /** The named collections this frame belongs to. Present on list answers. */
25089
+ collectionIds: array(string()).readonly().optional()
23242
25090
  });
23243
25091
  /** Why a copy-on-select could not be honoured — named, never a silent skip. */
23244
25092
  var RetrainCopyRefusalSchema = _enum([
@@ -23269,6 +25117,11 @@ var RetrainFrameListSchema = object({
23269
25117
  var RetrainExportFilterSchema = object({
23270
25118
  deviceIds: array(number()).optional(),
23271
25119
  frameIds: array(string()).max(2e4).optional(),
25120
+ /** Only frames in at least one of these named collections. */
25121
+ collectionIds: array(string()).max(200).optional(),
25122
+ /** Exactly the frames of this dataset version (and its completeOnly). An
25123
+ * unknown id selects nothing. */
25124
+ datasetVersionId: string().optional(),
23272
25125
  batchId: string().optional(),
23273
25126
  /** Only frames the operator marked complete (all subjects boxed). */
23274
25127
  completeOnly: boolean().optional()
@@ -23333,6 +25186,170 @@ var RetrainAssistResultSchema = discriminatedUnion("kind", [object({
23333
25186
  reason: string(),
23334
25187
  detail: string().optional()
23335
25188
  })]);
25189
+ /** A named set over the retrain corpus — membership only, it owns no pixels. */
25190
+ var RetrainCollectionSchema = object({
25191
+ id: string(),
25192
+ name: string(),
25193
+ createdAt: number(),
25194
+ frameCount: number().int()
25195
+ });
25196
+ var RetrainCollectionCreateResultSchema = discriminatedUnion("kind", [object({
25197
+ kind: literal("created"),
25198
+ collection: RetrainCollectionSchema
25199
+ }), object({
25200
+ kind: literal("refused"),
25201
+ reason: _enum(["empty-name", "duplicate-name"])
25202
+ })]);
25203
+ var RetrainCollectionRenameResultSchema = discriminatedUnion("kind", [object({
25204
+ kind: literal("renamed"),
25205
+ collection: RetrainCollectionSchema
25206
+ }), object({
25207
+ kind: literal("refused"),
25208
+ reason: _enum([
25209
+ "empty-name",
25210
+ "duplicate-name",
25211
+ "unknown-collection"
25212
+ ])
25213
+ })]);
25214
+ /**
25215
+ * The outcome of adding the frame at a recording instant. Every refusal is
25216
+ * named: `still-unavailable` (not recording, a gap, or an undecodable frame —
25217
+ * `detail` says which), `still-busy` (the recorder is at its decode bound; try
25218
+ * again), `unreadable-image`, `write-failed`, `unknown-collection`.
25219
+ */
25220
+ var AddRetrainFrameFromRecordingResultSchema = discriminatedUnion("kind", [object({
25221
+ kind: literal("added"),
25222
+ collectionId: string(),
25223
+ frame: RetrainFrameSchema,
25224
+ /** The moment was already in the dataset; nothing was decoded. */
25225
+ reused: boolean()
25226
+ }), object({
25227
+ kind: literal("refused"),
25228
+ reason: _enum([
25229
+ "unknown-collection",
25230
+ "still-unavailable",
25231
+ "still-busy",
25232
+ "unreadable-image",
25233
+ "write-failed"
25234
+ ]),
25235
+ detail: string().optional()
25236
+ })]);
25237
+ /** A vision LLM profile the AI assist may use, and where it sends the frame. */
25238
+ var RetrainAssistProfileSchema = object({
25239
+ id: string(),
25240
+ name: string(),
25241
+ model: string(),
25242
+ kind: string(),
25243
+ /** `true` when the frame would leave the house (a cloud vendor, or an
25244
+ * endpoint that is not on the local network). The page confirms each such
25245
+ * run, and the provider refuses one without `allowCloud`. */
25246
+ leavesHouse: boolean()
25247
+ });
25248
+ /** A box the AI assist proposed: a draft, plus the model's own reason. */
25249
+ var RetrainLlmProposalSchema = RetrainAnnotationDraftSchema.extend({ reason: string() });
25250
+ /** What the AI assist said about a box that was already on the canvas. */
25251
+ var RetrainLlmReviewSchema = object({
25252
+ /** The `ref` the page sent the box under. */
25253
+ ref: string(),
25254
+ verdict: _enum([
25255
+ "confirmed",
25256
+ "wrong-class",
25257
+ "not-an-object",
25258
+ "uncertain"
25259
+ ]),
25260
+ suggestedClass: RetrainMacroClassSchema.optional(),
25261
+ reason: string()
25262
+ });
25263
+ /**
25264
+ * The AI assist's answer. `proposed` carries drafts (`source: 'llm'`, the
25265
+ * model and its confidence) and reviews; items the model got wrong (a box off
25266
+ * the frame, an unasked class, an unknown ref) are dropped and counted in
25267
+ * `rejected`. A whole answer that is not the schema is `malformed-answer`.
25268
+ */
25269
+ var RetrainLlmAssistResultSchema = discriminatedUnion("kind", [object({
25270
+ kind: literal("proposed"),
25271
+ profileId: string(),
25272
+ model: string(),
25273
+ /** The frame was sent outside the house for this answer. */
25274
+ leftHouse: boolean(),
25275
+ proposals: array(RetrainLlmProposalSchema).readonly(),
25276
+ reviews: array(RetrainLlmReviewSchema).readonly(),
25277
+ rejected: number().int()
25278
+ }), object({
25279
+ kind: literal("refused"),
25280
+ reason: _enum([
25281
+ "unknown-frame",
25282
+ "unreadable-frame",
25283
+ "unknown-profile",
25284
+ "profile-disabled",
25285
+ "no-vision",
25286
+ "cloud-not-confirmed",
25287
+ "llm-error",
25288
+ "malformed-answer"
25289
+ ]),
25290
+ detail: string().optional()
25291
+ })]);
25292
+ /** What a dataset version is cut from. Every field narrows. */
25293
+ var RetrainDatasetSelectionSchema = object({
25294
+ deviceIds: array(number()).readonly().optional(),
25295
+ collectionIds: array(string()).max(200).readonly().optional(),
25296
+ frameIds: array(string()).max(2e4).readonly().optional()
25297
+ });
25298
+ /** The counts a dataset is judged by. */
25299
+ var RetrainDatasetStatsSchema = object({
25300
+ frames: number().int(),
25301
+ completeFrames: number().int(),
25302
+ /** `completeFrames / frames`, 0..1. */
25303
+ completeness: number(),
25304
+ /** Boxes to learn (model errors excluded). */
25305
+ subjects: number().int(),
25306
+ modelErrors: number().int(),
25307
+ /** Complete frames with no subject. */
25308
+ hardNegatives: number().int(),
25309
+ /** Subjects per class × camera × day/night. */
25310
+ cells: array(object({
25311
+ macroClass: string(),
25312
+ deviceId: number(),
25313
+ lighting: _enum([
25314
+ "day",
25315
+ "night",
25316
+ "unknown"
25317
+ ]),
25318
+ subjects: number().int(),
25319
+ frames: number().int()
25320
+ })).readonly(),
25321
+ cameras: array(object({
25322
+ deviceId: number(),
25323
+ frames: number().int(),
25324
+ completeFrames: number().int()
25325
+ })).readonly()
25326
+ });
25327
+ /** An immutable dataset version, without its frame list. */
25328
+ var RetrainDatasetVersionSchema = object({
25329
+ id: string(),
25330
+ name: string(),
25331
+ createdAt: number(),
25332
+ selection: RetrainDatasetSelectionSchema,
25333
+ layout: RetrainExportLayoutSchema,
25334
+ completeOnly: boolean(),
25335
+ frameCount: number().int(),
25336
+ /** sha256 of what the frames taught when the version was frozen. */
25337
+ annotationHash: string(),
25338
+ /** The export manifest schema the version was cut under. */
25339
+ manifestSchema: string(),
25340
+ stats: RetrainDatasetStatsSchema
25341
+ });
25342
+ var CreateRetrainDatasetVersionResultSchema = discriminatedUnion("kind", [object({
25343
+ kind: literal("created"),
25344
+ version: RetrainDatasetVersionSchema
25345
+ }), object({
25346
+ kind: literal("refused"),
25347
+ reason: _enum([
25348
+ "empty-name",
25349
+ "duplicate-name",
25350
+ "no-frames"
25351
+ ])
25352
+ })]);
23336
25353
  /** The outcome of a lifecycle move owned by the retrain page. */
23337
25354
  var RetrainTransitionResultSchema = object({
23338
25355
  trackId: string(),
@@ -24050,7 +26067,7 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
24050
26067
  auth: "admin"
24051
26068
  }), method(object({
24052
26069
  deviceId: number(),
24053
- trackId: string(),
26070
+ trackId: string().optional(),
24054
26071
  frameId: string()
24055
26072
  }), object({
24056
26073
  removed: boolean(),
@@ -24067,7 +26084,8 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
24067
26084
  auth: "admin"
24068
26085
  }), method(object({
24069
26086
  deviceId: number(),
24070
- trackId: string(),
26087
+ /** The frame's track, when it has one — checked against the frame. */
26088
+ trackId: string().optional(),
24071
26089
  frameId: string(),
24072
26090
  subject: RetrainAssistSubjectSchema,
24073
26091
  /** Which node runs it. Absent ⇒ wherever an unowned call lands. */
@@ -24075,12 +26093,16 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
24075
26093
  }), RetrainAssistResultSchema, {
24076
26094
  kind: "mutation",
24077
26095
  auth: "admin"
24078
- }), method(object({ trackId: string() }), array(RetrainAnnotationSchema).readonly(), {
26096
+ }), method(object({
26097
+ trackId: string().optional(),
26098
+ frameIds: array(string()).max(2e3).optional()
26099
+ }), array(RetrainAnnotationSchema).readonly(), {
24079
26100
  kind: "query",
24080
26101
  auth: "admin"
24081
26102
  }), method(object({
24082
26103
  deviceId: number(),
24083
- trackId: string(),
26104
+ /** The frame's track, when it has one — checked against the frame. */
26105
+ trackId: string().optional(),
24084
26106
  frameId: string(),
24085
26107
  annotations: array(RetrainAnnotationDraftSchema)
24086
26108
  }), array(RetrainAnnotationSchema).readonly(), {
@@ -24103,7 +26125,7 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
24103
26125
  auth: "admin"
24104
26126
  }), method(object({
24105
26127
  deviceId: number(),
24106
- trackId: string(),
26128
+ trackId: string().optional(),
24107
26129
  frameId: string(),
24108
26130
  complete: boolean()
24109
26131
  }), RetrainFrameSchema, {
@@ -24117,6 +26139,115 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
24117
26139
  kind: "mutation",
24118
26140
  auth: "admin",
24119
26141
  timeoutMs: 60 * 6e4
26142
+ }), method(object({
26143
+ filter: RetrainExportFilterSchema,
26144
+ layout: RetrainExportLayoutSchema
26145
+ }), object({
26146
+ ticket: PeerBytesTicketSchema,
26147
+ frames: number().int(),
26148
+ annotations: number().int()
26149
+ }), {
26150
+ kind: "mutation",
26151
+ auth: "admin",
26152
+ timeoutMs: 12e4
26153
+ }), method(object({
26154
+ selection: RetrainDatasetSelectionSchema,
26155
+ completeOnly: boolean().optional()
26156
+ }), RetrainDatasetStatsSchema, {
26157
+ kind: "query",
26158
+ auth: "admin"
26159
+ }), method(object({
26160
+ name: string().max(120),
26161
+ selection: RetrainDatasetSelectionSchema,
26162
+ layout: RetrainExportLayoutSchema,
26163
+ completeOnly: boolean()
26164
+ }), CreateRetrainDatasetVersionResultSchema, {
26165
+ kind: "mutation",
26166
+ auth: "admin",
26167
+ timeoutMs: 12e4
26168
+ }), method(object({}), array(RetrainDatasetVersionSchema).readonly(), {
26169
+ kind: "query",
26170
+ auth: "admin"
26171
+ }), method(object({ id: string() }), object({ deleted: boolean() }), {
26172
+ kind: "mutation",
26173
+ auth: "admin"
26174
+ }), method(object({ id: string() }), object({
26175
+ found: boolean(),
26176
+ annotationHash: string(),
26177
+ matches: boolean(),
26178
+ missingFrames: number().int()
26179
+ }), {
26180
+ kind: "query",
26181
+ auth: "admin",
26182
+ timeoutMs: 12e4
26183
+ }), method(object({}), array(RetrainAssistProfileSchema).readonly(), {
26184
+ kind: "query",
26185
+ auth: "admin"
26186
+ }), method(object({
26187
+ deviceId: number(),
26188
+ trackId: string().optional(),
26189
+ frameId: string(),
26190
+ profileId: string(),
26191
+ classes: array(RetrainMacroClassSchema).min(1),
26192
+ boxes: array(object({
26193
+ ref: string(),
26194
+ bbox: RetrainBboxSchema,
26195
+ macroClass: RetrainMacroClassSchema,
26196
+ label: string().optional()
26197
+ })).max(50),
26198
+ allowCloud: boolean()
26199
+ }), RetrainLlmAssistResultSchema, {
26200
+ kind: "mutation",
26201
+ auth: "admin",
26202
+ timeoutMs: 18e4
26203
+ }), method(object({ name: string().max(120) }), RetrainCollectionCreateResultSchema, {
26204
+ kind: "mutation",
26205
+ auth: "admin"
26206
+ }), method(object({}), array(RetrainCollectionSchema).readonly(), {
26207
+ kind: "query",
26208
+ auth: "admin"
26209
+ }), method(object({
26210
+ id: string(),
26211
+ name: string().max(120)
26212
+ }), RetrainCollectionRenameResultSchema, {
26213
+ kind: "mutation",
26214
+ auth: "admin"
26215
+ }), method(object({ id: string() }), object({
26216
+ deleted: boolean(),
26217
+ removedFrames: number().int()
26218
+ }), {
26219
+ kind: "mutation",
26220
+ auth: "admin"
26221
+ }), method(object({
26222
+ collectionId: string(),
26223
+ deviceId: number(),
26224
+ epochMs: number()
26225
+ }), AddRetrainFrameFromRecordingResultSchema, {
26226
+ kind: "mutation",
26227
+ auth: "admin",
26228
+ timeoutMs: 6e4
26229
+ }), method(object({
26230
+ collectionId: string(),
26231
+ frameIds: array(string()).min(1).max(500)
26232
+ }), object({
26233
+ added: number().int(),
26234
+ alreadyMember: number().int(),
26235
+ unknownFrameIds: array(string()).readonly()
26236
+ }), {
26237
+ kind: "mutation",
26238
+ auth: "admin"
26239
+ }), method(object({
26240
+ collectionId: string(),
26241
+ frameId: string()
26242
+ }), object({
26243
+ removed: boolean(),
26244
+ deletedFrame: boolean()
26245
+ }), {
26246
+ kind: "mutation",
26247
+ auth: "admin"
26248
+ }), method(object({ collectionId: string() }), array(RetrainFrameSchema).readonly(), {
26249
+ kind: "query",
26250
+ auth: "admin"
24120
26251
  }), method(object({
24121
26252
  /** Which of the three event tables owns the row. */
24122
26253
  ownerType: EventOwnerTypeSchema,
@@ -24740,13 +26871,31 @@ var RecommendationReasonSchema = discriminatedUnion("kind", [
24740
26871
  object({
24741
26872
  kind: literal("no-family-build"),
24742
26873
  format: ModelFormatSchema$1
26874
+ }),
26875
+ object({
26876
+ kind: literal("kept-custom-pin"),
26877
+ modelId: string(),
26878
+ deviceKey: string()
24743
26879
  })
24744
26880
  ]);
26881
+ /** Why a device is left exactly as it is, whatever the plan would pick (D786). */
26882
+ var KeptReasonSchema = _enum(["custom-pin"]);
26883
+ /**
26884
+ * Where a choice's latency came from (D791): this node's own benchmark
26885
+ * result, or the hardware-class table. Measured on the node beats the table.
26886
+ */
26887
+ var LatencySourceSchema = discriminatedUnion("kind", [object({ kind: literal("table") }), object({
26888
+ kind: literal("node-benchmark"),
26889
+ resultId: string(),
26890
+ measuredAtMs: number()
26891
+ })]);
24745
26892
  var DeviceModelChoiceSchema = object({
24746
26893
  modelId: string(),
24747
26894
  p50Ms: number(),
24748
26895
  fps: number(),
24749
26896
  measured: boolean(),
26897
+ /** Absent on a plan from before D791 — read as the table. */
26898
+ source: LatencySourceSchema.optional(),
24750
26899
  /** Parallel sessions at the camera rate with the headroom kept free: ⌊fps × (1 − headroom) / camera fps⌋. */
24751
26900
  capacitySessions: number(),
24752
26901
  personRecall: number()
@@ -24757,6 +26906,8 @@ var DeviceRecommendationSchema = object({
24757
26906
  enabled: boolean(),
24758
26907
  available: boolean(),
24759
26908
  chosen: DeviceModelChoiceSchema.nullable(),
26909
+ /** Present when the device is kept as is: Apply writes nothing on it. */
26910
+ kept: KeptReasonSchema.optional(),
24760
26911
  reasons: array(RecommendationReasonSchema).readonly()
24761
26912
  });
24762
26913
  var NodeRecommendationSchema = object({
@@ -24810,6 +26961,17 @@ var AutoTuneWarningSchema = discriminatedUnion("kind", [
24810
26961
  kind: literal("coral-enabled"),
24811
26962
  nodeId: string(),
24812
26963
  deviceKey: string()
26964
+ }),
26965
+ object({
26966
+ kind: literal("custom-pin-kept"),
26967
+ nodeId: string(),
26968
+ deviceKey: string().nullable(),
26969
+ deviceId: number().nullable(),
26970
+ modelId: string()
26971
+ }),
26972
+ object({
26973
+ kind: literal("custom-registry-unreadable"),
26974
+ error: string()
24813
26975
  })
24814
26976
  ]);
24815
26977
  var AutoTuneOptionsSchema = object({
@@ -24988,13 +27150,14 @@ var SuggestSharesResultSchema = object({
24988
27150
  nodes: array(SuggestedNodeShareSchema).readonly()
24989
27151
  });
24990
27152
  /**
24991
- * Where the node and device shares come from (D750, D755).
24992
- * - `hardware` (default) — computed by the system from each node's static
24993
- * capacity (its accelerators at their Auto tune models, from the measured
24994
- * latency table), recomputed whenever a node or device joins, leaves, is
24995
- * switched on or off, or changes model. No load input.
24996
- * - `benchmark` — the same, from each node's measured capacity (node
24997
- * benchmark results); a node without results falls back to `hardware`.
27153
+ * Where the node and device shares come from (D750, D755, D791).
27154
+ * - `benchmark` (default since D791) — each node's capacity as its own node
27155
+ * benchmark measured it; a node without fresh results is sized from
27156
+ * `hardware` and says so. Measured on the node beats the table.
27157
+ * - `hardware` — computed from each node's static capacity only (its
27158
+ * accelerators at their Auto tune models, from the latency table).
27159
+ * Both are recomputed whenever a node or device joins, leaves, is switched
27160
+ * on or off, changes model, or a benchmark result is written. No load input.
24998
27161
  * - `manual` — the operator's stored sliders.
24999
27162
  * Either way a node or device that cannot take sessions gives its share to
25000
27163
  * the others in proportion; the stored values are never rewritten for that.
@@ -25043,6 +27206,362 @@ var EffectiveSharesSchema = object({
25043
27206
  nodeWeights: record(string(), number()),
25044
27207
  deviceWeights: record(string(), record(string(), number()))
25045
27208
  });
27209
+ /**
27210
+ * Wire shapes of the node benchmark (D791): the operator's plan, the
27211
+ * preflight the confirmation shows, the run the orchestrator owns, what the
27212
+ * measuring runner reports, and the result rows Auto tune and the automatic
27213
+ * shares read.
27214
+ *
27215
+ * ONE node at a time, owned by the pipeline orchestrator. While a run is
27216
+ * active the cluster is in BENCHMARK MODE for that node: it is not a
27217
+ * detection candidate, camera pins naming it are ignored so its sessions move
27218
+ * elsewhere, and both come back when the mode ends — after a crash or a hub
27219
+ * restart too (a persisted manifest, reconciled against the registry).
27220
+ *
27221
+ * Two measurements, both on the node, driven by its own runner (frames never
27222
+ * cross a process at frame rate, D9):
27223
+ * - `device` — one accelerator × one candidate detector, root only, open
27224
+ * loop: how many streams at the camera rate it carries inside the frame
27225
+ * interval;
27226
+ * - `pipeline` — the chosen detector plus the operator's detail steps
27227
+ * (faces, plates, classifiers, CLIP…), on varied frames from the bench
27228
+ * clip: how many parallel sessions the node carries before latency, drops,
27229
+ * CPU, RAM or the event loop give out.
27230
+ */
27231
+ /** Defaults and bounds, one place. */
27232
+ var NODE_BENCHMARK_DEFAULTS = {
27233
+ fpsPerStream: 10,
27234
+ budgetMinutes: 45,
27235
+ minBudgetMinutes: 10,
27236
+ maxBudgetMinutes: 120,
27237
+ /** A result older than this no longer beats the table. */
27238
+ staleAfterDays: 30,
27239
+ /** Warm-in per ramp step (not accounted). */
27240
+ settleSec: 5,
27241
+ /** Accounted window per ramp step. */
27242
+ measureSec: 20,
27243
+ /** Longest the drain may take before the run is refused. */
27244
+ drainTimeoutSec: 120,
27245
+ /** Candidate models per device in one run. */
27246
+ maxModelsPerDevice: 6
27247
+ };
27248
+ /** The two measurements a run can make. */
27249
+ var NodeBenchmarkPhaseSchema = _enum(["device", "pipeline"]);
27250
+ var NodeBenchmarkDevicePlanSchema = object({
27251
+ /** `<backend>:<device>` — `openvino:npu`, `coreml:all`, `cpu`. */
27252
+ deviceKey: string().min(1),
27253
+ /**
27254
+ * Root detector candidates for the `device` measurement, in the order
27255
+ * measured. The FIRST is the one the `pipeline` measurement runs.
27256
+ */
27257
+ modelIds: array(string().min(1)).min(1).max(NODE_BENCHMARK_DEFAULTS.maxModelsPerDevice)
27258
+ });
27259
+ /** What the operator confirmed. */
27260
+ var NodeBenchmarkPlanSchema = object({
27261
+ nodeId: string().min(1),
27262
+ devices: array(NodeBenchmarkDevicePlanSchema).min(1),
27263
+ /** Which measurements run. At least one. */
27264
+ phases: array(NodeBenchmarkPhaseSchema).min(1).default(["device", "pipeline"]),
27265
+ /**
27266
+ * Detail steps (catalog step ids under the root: faces, plates,
27267
+ * classifiers, CLIP…) the `pipeline` measurement enables. The root
27268
+ * detector always runs.
27269
+ */
27270
+ steps: array(string().min(1)).default([]),
27271
+ /** Offered rate of one stream / session. */
27272
+ fpsPerStream: number().int().min(1).max(30).default(NODE_BENCHMARK_DEFAULTS.fpsPerStream),
27273
+ /** Hard deadline: the mode ends and the cluster is restored when it passes. */
27274
+ budgetMinutes: number().int().min(NODE_BENCHMARK_DEFAULTS.minBudgetMinutes).max(NODE_BENCHMARK_DEFAULTS.maxBudgetMinutes).default(NODE_BENCHMARK_DEFAULTS.budgetMinutes),
27275
+ /** Keep the models the run downloaded (default: delete what was not installed before). */
27276
+ keepDownloadedModels: boolean().default(false),
27277
+ /** Start although the other nodes' capacity does not cover the sessions running now. */
27278
+ acceptInsufficientHeadroom: boolean().default(false)
27279
+ });
27280
+ var NodeBenchmarkRefusalSchema = object({
27281
+ kind: _enum([
27282
+ "benchmark-active",
27283
+ "node-offline",
27284
+ "unknown-device",
27285
+ "no-phase",
27286
+ "insufficient-headroom"
27287
+ ]),
27288
+ detail: string(),
27289
+ overridable: boolean()
27290
+ });
27291
+ /** A camera whose detection leaves the node for the run. */
27292
+ var NodeBenchmarkMovingCameraSchema = object({
27293
+ deviceId: number(),
27294
+ /** Placed on the node now (a standing attach or a running session). */
27295
+ placedOnNode: boolean(),
27296
+ /** A node pin naming this node, ignored for the run. */
27297
+ pinnedToNode: boolean()
27298
+ });
27299
+ /** A camera that cannot leave: no other node can obtain its frames. */
27300
+ var NodeBenchmarkStayingCameraSchema = object({
27301
+ deviceId: number(),
27302
+ reason: literal("only-frame-source")
27303
+ });
27304
+ var NodeBenchmarkPreflightSchema = object({
27305
+ nodeId: string(),
27306
+ online: boolean(),
27307
+ moving: array(NodeBenchmarkMovingCameraSchema).readonly(),
27308
+ /** Keep running on the node during the run; the result is flagged contaminated. */
27309
+ staying: array(NodeBenchmarkStayingCameraSchema).readonly(),
27310
+ estimatedDurationMs: number(),
27311
+ /** The run ends and the cluster is restored at the latest after this long. */
27312
+ budgetMs: number(),
27313
+ phases: array(NodeBenchmarkPhaseSchema).readonly(),
27314
+ steps: array(string()).readonly(),
27315
+ devices: array(NodeBenchmarkDevicePlanSchema).readonly(),
27316
+ /** Parallel sessions the cluster runs now, and what the other nodes can carry. */
27317
+ headroom: object({
27318
+ sessionsNow: number(),
27319
+ otherNodesCapacitySessions: number().nullable()
27320
+ }),
27321
+ refusals: array(NodeBenchmarkRefusalSchema).readonly(),
27322
+ canStart: boolean()
27323
+ });
27324
+ /** Where the measuring runner is. */
27325
+ var NodeBenchProgressSchema = object({
27326
+ phase: _enum([
27327
+ "preparing",
27328
+ "device",
27329
+ "pipeline",
27330
+ "cleanup"
27331
+ ]),
27332
+ deviceKey: string().nullable(),
27333
+ modelId: string().nullable(),
27334
+ /** Streams (device) or sessions (pipeline) of the step running now. */
27335
+ load: number().nullable(),
27336
+ cellsDone: number(),
27337
+ cellsTotal: number(),
27338
+ message: string()
27339
+ });
27340
+ /** What limited a ramp. `none` = the ramp ran out of steps still passing. */
27341
+ var NodeBenchLimitSchema = _enum([
27342
+ "p95",
27343
+ "drops",
27344
+ "errors",
27345
+ "stall",
27346
+ "cpu",
27347
+ "ram",
27348
+ "none"
27349
+ ]);
27350
+ var NodeBenchRampStepSchema = object({
27351
+ load: number(),
27352
+ pass: boolean(),
27353
+ p95Ms: number(),
27354
+ dropRatio: number(),
27355
+ /** Completed frames per second over the accounted window. */
27356
+ fps: number(),
27357
+ cpuPct: number().nullable(),
27358
+ ramFreePct: number().nullable(),
27359
+ failReasons: array(string()).readonly()
27360
+ });
27361
+ var NodeBenchCellSchema = discriminatedUnion("phase", [object({
27362
+ phase: literal("device"),
27363
+ deviceKey: string(),
27364
+ modelId: string(),
27365
+ /** Single-stream latency (the K = 1 step). */
27366
+ p50Ms: number(),
27367
+ p95Ms: number(),
27368
+ p99Ms: number(),
27369
+ /** Frames per second sustained at the last passing step. */
27370
+ fps: number(),
27371
+ /** Streams at the camera rate the device carried inside the frame interval; 0 = not even one. */
27372
+ kMax: number(),
27373
+ limitedBy: NodeBenchLimitSchema,
27374
+ /** First call (model load + warm-up). */
27375
+ warmupMs: number(),
27376
+ ramp: array(NodeBenchRampStepSchema).readonly()
27377
+ }), object({
27378
+ phase: literal("pipeline"),
27379
+ deviceKey: string(),
27380
+ modelId: string(),
27381
+ steps: array(string()).readonly(),
27382
+ /** Parallel sessions at the camera rate the node carried; 0 = not even one. */
27383
+ maxSessions: number(),
27384
+ limitedBy: NodeBenchLimitSchema,
27385
+ /** Detail steps that produced at least one result on the clip — a step that never fired measured nothing. */
27386
+ stepsFired: array(string()).readonly(),
27387
+ warmupMs: number(),
27388
+ ramp: array(NodeBenchRampStepSchema).readonly()
27389
+ })]);
27390
+ /**
27391
+ * What a result was measured ON. A result whose fingerprint no longer matches
27392
+ * the node no longer beats the table.
27393
+ */
27394
+ var NodeBenchFingerprintSchema = object({
27395
+ pipelineVersion: string().nullable(),
27396
+ cpuModel: string().nullable(),
27397
+ ramGb: number().nullable(),
27398
+ os: string().nullable(),
27399
+ /** Per device: the pool the cells ran on (runtime + tuning). */
27400
+ pools: record(string(), object({
27401
+ runtime: string(),
27402
+ numWorkers: number(),
27403
+ concurrency: number(),
27404
+ batchMode: string()
27405
+ })).default({})
27406
+ });
27407
+ /** The frames the run used. */
27408
+ var NodeBenchClipSchema = object({
27409
+ /** `camstack-bench-v1` or `reference-images` (the fallback when the clip is not reachable). */
27410
+ id: string(),
27411
+ revision: string().nullable(),
27412
+ frames: number(),
27413
+ width: number(),
27414
+ height: number()
27415
+ });
27416
+ var NodeBenchRunnerInputSchema = object({
27417
+ runId: string().min(1),
27418
+ devices: array(NodeBenchmarkDevicePlanSchema).min(1),
27419
+ phases: array(NodeBenchmarkPhaseSchema).min(1),
27420
+ /** The full detail step tree root for the `pipeline` measurement is built on the node from these ids. */
27421
+ steps: array(string()).default([]),
27422
+ fpsPerStream: number().int().min(1).max(30),
27423
+ /** The runner stops on its own past this instant, whatever the hub does. */
27424
+ deadlineAtMs: number(),
27425
+ settleSec: number().min(0).max(60).default(NODE_BENCHMARK_DEFAULTS.settleSec),
27426
+ measureSec: number().min(2).max(300).default(NODE_BENCHMARK_DEFAULTS.measureSec),
27427
+ keepDownloadedModels: boolean().default(false)
27428
+ });
27429
+ var NodeBenchRunnerStateSchema = _enum([
27430
+ "running",
27431
+ "done",
27432
+ "failed",
27433
+ "aborted"
27434
+ ]);
27435
+ var NodeBenchRunnerStatusSchema = object({
27436
+ runId: string(),
27437
+ nodeId: string(),
27438
+ state: NodeBenchRunnerStateSchema,
27439
+ progress: NodeBenchProgressSchema.nullable(),
27440
+ /** Every finished cell so far — a run stopped half way keeps what it measured. */
27441
+ cells: array(NodeBenchCellSchema).readonly(),
27442
+ fingerprint: NodeBenchFingerprintSchema.nullable(),
27443
+ clip: NodeBenchClipSchema.nullable(),
27444
+ /** Cameras seen running on the node during the run (they share its pools). */
27445
+ activeCameraIds: array(number()).readonly(),
27446
+ /** Models the run downloaded and then deleted (not installed before). */
27447
+ deletedModels: array(string()).readonly(),
27448
+ error: string().nullable(),
27449
+ startedAtMs: number(),
27450
+ finishedAtMs: number().nullable()
27451
+ });
27452
+ var NodeBenchmarkStateSchema = _enum([
27453
+ "draining",
27454
+ "measuring",
27455
+ "restoring",
27456
+ "done",
27457
+ "failed",
27458
+ "aborted"
27459
+ ]);
27460
+ /** Why a run ended. */
27461
+ var NodeBenchmarkEndReasonSchema = _enum([
27462
+ "completed",
27463
+ "operator-abort",
27464
+ "deadline",
27465
+ "node-lost",
27466
+ "runner-lost",
27467
+ "hub-restart",
27468
+ "drain-timeout",
27469
+ "failed"
27470
+ ]);
27471
+ var NodeBenchmarkRunSchema = object({
27472
+ runId: string(),
27473
+ nodeId: string(),
27474
+ state: NodeBenchmarkStateSchema,
27475
+ plan: NodeBenchmarkPlanSchema,
27476
+ startedAtMs: number(),
27477
+ deadlineAtMs: number(),
27478
+ finishedAtMs: number().nullable(),
27479
+ endReason: NodeBenchmarkEndReasonSchema.nullable(),
27480
+ error: string().nullable(),
27481
+ /** Cameras moved off the node for the run. */
27482
+ moved: array(number()).readonly(),
27483
+ /** Cameras that stayed (their only frame source is the node). */
27484
+ staying: array(number()).readonly(),
27485
+ /** Something else ran on the node's pools during the run. */
27486
+ contaminated: boolean(),
27487
+ progress: NodeBenchProgressSchema.nullable(),
27488
+ resultIds: array(string()).readonly()
27489
+ });
27490
+ /** `getNodeBenchmarkStatus`: the active run (or the last one), and whether benchmark mode is on. */
27491
+ var NodeBenchmarkStatusSchema = object({
27492
+ /** The node the cluster is in benchmark mode for; null = none. */
27493
+ modeNodeId: string().nullable(),
27494
+ run: NodeBenchmarkRunSchema.nullable()
27495
+ });
27496
+ /**
27497
+ * One stored measurement — the only authority Auto tune and the automatic
27498
+ * shares read measured capacity from. Written by the orchestrator when a run
27499
+ * ends, never by anyone else.
27500
+ */
27501
+ var NodeBenchmarkResultSchema = object({
27502
+ id: string(),
27503
+ runId: string(),
27504
+ nodeId: string(),
27505
+ cell: NodeBenchCellSchema,
27506
+ fpsPerStream: number(),
27507
+ fingerprint: NodeBenchFingerprintSchema.nullable(),
27508
+ clip: NodeBenchClipSchema.nullable(),
27509
+ /** Other work shared the node's pools (a camera that could not move, or the hub's own duties). */
27510
+ contaminated: boolean(),
27511
+ stayingCameras: array(number()).readonly(),
27512
+ /** The run ended early; the cell itself completed. */
27513
+ partialRun: boolean(),
27514
+ measuredAtMs: number()
27515
+ });
27516
+ var ListNodeBenchmarkResultsInputSchema = object({
27517
+ nodeId: string().optional(),
27518
+ deviceKey: string().optional()
27519
+ });
27520
+ /** A result with its standing today: does it still beat the table? */
27521
+ var NodeBenchmarkResultViewSchema = NodeBenchmarkResultSchema.extend({
27522
+ /** `fresh` beats the table; `stale` falls back to it; `superseded` = a newer row covers the same cell. */
27523
+ standing: _enum([
27524
+ "fresh",
27525
+ "stale",
27526
+ "superseded"
27527
+ ]),
27528
+ staleWhy: _enum([
27529
+ "age",
27530
+ "runtime",
27531
+ "pool-tuning"
27532
+ ]).nullable()
27533
+ });
27534
+ object({
27535
+ runId: string(),
27536
+ nodeId: string(),
27537
+ startedAtMs: number(),
27538
+ deadlineAtMs: number(),
27539
+ plan: NodeBenchmarkPlanSchema,
27540
+ moved: array(number()).readonly(),
27541
+ staying: array(number()).readonly()
27542
+ });
27543
+ /** Candidate detectors per device, for the plan editor. */
27544
+ var NodeBenchmarkCandidatesSchema = object({
27545
+ nodeId: string(),
27546
+ reachable: boolean(),
27547
+ devices: array(object({
27548
+ deviceKey: string(),
27549
+ enabled: boolean(),
27550
+ available: boolean(),
27551
+ /** Ordered: what Auto tune would pick first, then the rest of the family by accuracy. */
27552
+ suggested: array(string()).readonly(),
27553
+ /** Every root detector the device has a build for. */
27554
+ all: array(string()).readonly(),
27555
+ /** The model the device runs now, when pinned. */
27556
+ currentModelId: string().nullable()
27557
+ })).readonly(),
27558
+ /** Detail steps the node's catalog offers under the root (for the `pipeline` measurement). */
27559
+ steps: array(object({
27560
+ id: string(),
27561
+ name: string(),
27562
+ slot: string()
27563
+ })).readonly()
27564
+ });
25046
27565
  object({
25047
27566
  activeCameras: number(),
25048
27567
  throttledCameras: number(),
@@ -26171,7 +28690,16 @@ method(RunnerCameraConfigSchema, object({ success: literal(true) }), { kind: "mu
26171
28690
  }), ParkedTrackFrameSchema.nullable()), method(object({
26172
28691
  deviceId: number(),
26173
28692
  trackId: string()
26174
- }), object({ released: number().int().nonnegative() }), { kind: "mutation" });
28693
+ }), object({ released: number().int().nonnegative() }), { kind: "mutation" }), method(NodeBenchRunnerInputSchema, object({
28694
+ accepted: literal(true),
28695
+ runId: string()
28696
+ }), {
28697
+ kind: "mutation",
28698
+ auth: "admin"
28699
+ }), method(object({ runId: string() }), NodeBenchRunnerStatusSchema.nullable(), { auth: "admin" }), method(object({ runId: string() }), object({ aborted: boolean() }), {
28700
+ kind: "mutation",
28701
+ auth: "admin"
28702
+ });
26175
28703
  var CameraPipelineConfigSchema = object({
26176
28704
  engine: PipelineEngineChoiceSchema.optional(),
26177
28705
  steps: array(PipelineStepInputSchema).readonly(),
@@ -26810,6 +29338,21 @@ method(object({
26810
29338
  }), method(PlacementStatsInputSchema, PlacementStatsSchema, { auth: "admin" }), method(SuggestSharesInputSchema, SuggestSharesResultSchema, { auth: "admin" }), method(_void(), EffectiveSharesSchema, { auth: "admin" }), method(SetShareSourceInputSchema, object({ success: literal(true) }), {
26811
29339
  kind: "mutation",
26812
29340
  auth: "admin"
29341
+ }), method(NodeBenchmarkPlanSchema, NodeBenchmarkPreflightSchema, { auth: "admin" }), method(NodeBenchmarkPlanSchema, discriminatedUnion("kind", [object({
29342
+ kind: literal("started"),
29343
+ runId: string()
29344
+ }), object({
29345
+ kind: literal("refused"),
29346
+ preflight: NodeBenchmarkPreflightSchema
29347
+ })]), {
29348
+ kind: "mutation",
29349
+ auth: "admin"
29350
+ }), method(_void(), NodeBenchmarkStatusSchema, { auth: "admin" }), method(object({ runId: string() }), object({ aborted: boolean() }), {
29351
+ kind: "mutation",
29352
+ auth: "admin"
29353
+ }), method(object({ nodeId: string() }), NodeBenchmarkCandidatesSchema, { auth: "admin" }), method(ListNodeBenchmarkResultsInputSchema, array(NodeBenchmarkResultViewSchema).readonly(), { auth: "admin" }), method(object({ id: string() }), object({ deleted: boolean() }), {
29354
+ kind: "mutation",
29355
+ auth: "admin"
26813
29356
  }), method(object({ deviceId: number() }), CameraPipelineSettingsSchema.nullable()), method(object({
26814
29357
  deviceId: number(),
26815
29358
  addonId: string(),
@@ -27215,8 +29758,8 @@ version: string().optional() }), ServerUpdateActionResultSchema, {
27215
29758
  * `smtp-provider` — pluggable email delivery surface.
27216
29759
  *
27217
29760
  * Collection cap: a deployment may install multiple SMTP relays (e.g.
27218
- * one for transactional / one for notifications). Consumers (magic-link,
27219
- * notifier addons, …) walk the collection and pick the first
29761
+ * one for transactional / one for notifications). Consumers (notifier
29762
+ * addons, …) walk the collection and pick the first
27220
29763
  * ready provider OR target a specific addonId.
27221
29764
  *
27222
29765
  * The shape stays small on purpose — `sendEmail` is enough for the
@@ -27395,7 +29938,7 @@ targets: array(object({
27395
29938
  })));
27396
29939
  /**
27397
29940
  * `sso-bridge` — internal hub-only cap that lets SSO-style auth
27398
- * providers (OIDC, SAML, magic-link, …) mint an HMAC-signed token
29941
+ * providers (OIDC, SAML, …) mint an HMAC-signed token
27399
29942
  * carrying the post-callback claims before redirecting back to
27400
29943
  * `/api/auth/sso/finish`.
27401
29944
  *
@@ -27458,7 +30001,14 @@ var SsoBridgeClaimsSchema = object({
27458
30001
  * Verified `iss` of the id_token behind an OIDC login bridge (D782). A
27459
30002
  * subject is unique only per issuer, so a link is bound to it.
27460
30003
  */
27461
- issuer: string().optional()
30004
+ issuer: string().optional(),
30005
+ /**
30006
+ * SHA-256 (hex) of the `camstack_sso_state` cookie the IdP `/start` set in
30007
+ * the browser that began this sign-in. `/api/auth/sso/finish` requires the
30008
+ * request to present the matching cookie — a login bridge is useless in
30009
+ * any other browser.
30010
+ */
30011
+ browserBinding: string().optional()
27462
30012
  });
27463
30013
  method(object({
27464
30014
  claims: SsoBridgeClaimsSchema,
@@ -32925,6 +35475,9 @@ var CreateIntegrationInputSchema = object({
32925
35475
  enabled: boolean().optional(),
32926
35476
  info: record(string(), unknown()).optional(),
32927
35477
  settings: record(string(), unknown()).optional(),
35478
+ /** Keys of `settings` the form's schema declares secret (by type) — kept in
35479
+ * the keychain, not the table (D787). */
35480
+ secretKeys: array(string()).optional(),
32928
35481
  skipRestart: boolean().optional()
32929
35482
  });
32930
35483
  var UpdateIntegrationInputSchema = object({
@@ -32948,7 +35501,9 @@ method(_void(), array(IntegrationWithStateSchema)), method(object({ id: string()
32948
35501
  auth: "admin"
32949
35502
  }), method(object({ id: string() }), record(string(), unknown()), { auth: "admin" }), method(object({
32950
35503
  id: string(),
32951
- settings: record(string(), unknown())
35504
+ settings: record(string(), unknown()),
35505
+ /** Keys the form's schema declares secret (by type) — keychain-stored (D787). */
35506
+ secretKeys: array(string()).optional()
32952
35507
  }), object({ success: boolean() }), {
32953
35508
  kind: "mutation",
32954
35509
  auth: "admin"
@@ -39720,16 +42275,6 @@ var ApiKeySummarySchema = object({
39720
42275
  createdAt: number(),
39721
42276
  lastUsedAt: number().optional()
39722
42277
  });
39723
- var CreateApiKeyInputSchema = object({
39724
- label: string(),
39725
- isAdmin: boolean().default(false),
39726
- allowedProviders: union([array(string()), literal("*")]).optional(),
39727
- allowedDevices: record(string(), union([array(string()), literal("*")])).optional()
39728
- });
39729
- var CreateApiKeyResultSchema = object({
39730
- token: string(),
39731
- record: ApiKeySummarySchema
39732
- });
39733
42278
  var ScopedTokenSummarySchema = object({
39734
42279
  id: string(),
39735
42280
  userId: string(),
@@ -39828,17 +42373,10 @@ method(_void(), array(UserSummarySchema), { auth: "admin" }), method(CreateUserI
39828
42373
  }), UserSummarySchema.extend({ passwordHash: string() }).nullable(), {
39829
42374
  kind: "mutation",
39830
42375
  access: "view"
39831
- }), method(_void(), array(ApiKeySummarySchema), { auth: "admin" }), method(CreateApiKeyInputSchema, CreateApiKeyResultSchema, {
39832
- kind: "mutation",
39833
- auth: "admin",
39834
- access: "create"
39835
- }), method(object({ id: string() }), object({ success: literal(true) }), {
42376
+ }), method(_void(), array(ApiKeySummarySchema), { auth: "admin" }), method(object({ id: string() }), object({ success: literal(true) }), {
39836
42377
  kind: "mutation",
39837
42378
  auth: "admin",
39838
42379
  access: "delete"
39839
- }), method(object({ token: string() }), ApiKeySummarySchema.nullable(), {
39840
- kind: "mutation",
39841
- access: "view"
39842
42380
  }), method(CreateScopedTokenInputSchema, CreateScopedTokenResultSchema, {
39843
42381
  kind: "mutation",
39844
42382
  auth: "admin",
@@ -39912,15 +42450,7 @@ method(_void(), array(UserSummarySchema), { auth: "admin" }), method(CreateUserI
39912
42450
  }).nullable(), { access: "view" }), method(object({ userId: string() }), array(ExternalIdentitySchema), { auth: "admin" }), method(ExternalIdentityKeySchema, object({
39913
42451
  userId: string(),
39914
42452
  issuer: string()
39915
- }).nullable(), { auth: "admin" }), method(ExternalIdentityKeySchema.extend({
39916
- userId: string(),
39917
- issuer: string().min(1),
39918
- label: string().optional()
39919
- }), object({ success: literal(true) }), {
39920
- kind: "mutation",
39921
- auth: "admin",
39922
- access: "create"
39923
- }), method(ExternalIdentityKeySchema.extend({ userId: string() }), object({ success: boolean() }), {
42453
+ }).nullable(), { auth: "admin" }), method(ExternalIdentityKeySchema.extend({ userId: string() }), object({ success: boolean() }), {
39924
42454
  kind: "mutation",
39925
42455
  auth: "admin",
39926
42456
  access: "delete"
@@ -40625,6 +43155,451 @@ var zoneRulesCapability = {
40625
43155
  */
40626
43156
  durability: "restored"
40627
43157
  };
43158
+ /**
43159
+ * `training-provider` — ONE cloud that can run the CamStack trainer.
43160
+ *
43161
+ * A thin, mockable translation layer: it knows how to run a container with a
43162
+ * GPU, move a dataset in, read the job's stdout and hand artefacts back. It
43163
+ * knows nothing about datasets, splits, floors, cost policy or Model Studio —
43164
+ * those are the `training` orchestrator's (D805). Every rule written there
43165
+ * once is what makes a second provider (RunPod, a local NVIDIA node) a new
43166
+ * manifest entry and nothing else.
43167
+ *
43168
+ * Collection, routed by the `addonId` in every single-row input (the `llm` /
43169
+ * `notification-output` posture); `describe` concat-fans across providers.
43170
+ * Every method is `admin`: these spend money.
43171
+ *
43172
+ * Every cloud object a provider creates is tagged with the orchestrator's
43173
+ * `jobKey`, so a retried submit finds the job it already started instead of
43174
+ * starting a second GPU, and `listJobs` can find orphans.
43175
+ *
43176
+ * Bytes never ride a cap field: the dataset arrives as a `ctx.peerBytes`
43177
+ * ticket the producer (pipeline-analytics) minted, and artefacts leave as a
43178
+ * ticket the provider mints (D613).
43179
+ */
43180
+ var TrainingGpuOptionSchema = object({
43181
+ id: string(),
43182
+ label: string(),
43183
+ /** List price, USD per GPU-hour, before any region multiplier. */
43184
+ usdPerHour: number().nonnegative(),
43185
+ vramGb: number().nonnegative()
43186
+ });
43187
+ var TrainingRegionOptionSchema = object({
43188
+ /** `''` = any region (the provider's choice). */
43189
+ id: string(),
43190
+ label: string(),
43191
+ priceMultiplier: number().positive()
43192
+ });
43193
+ /**
43194
+ * The provider's per-account settings, as the orchestrator reads them. They
43195
+ * live in the PROVIDER addon's settings (operator decision 2026-10-08: they
43196
+ * depend on the user's account), never hard-coded in the orchestrator.
43197
+ */
43198
+ var TrainingProviderDefaultsSchema = object({
43199
+ gpuType: string(),
43200
+ region: string(),
43201
+ costCapUsd: number().nonnegative(),
43202
+ maxRuntimeSec: number().int().positive(),
43203
+ /** Hours a FAILED job's cloud dataset is kept for debugging; 0 = delete at once. */
43204
+ failedDatasetGraceHours: number().nonnegative()
43205
+ });
43206
+ var TrainingProviderDescriptorSchema = object({
43207
+ addonId: string(),
43208
+ /** `modal`, `runpod`, `fake`, … */
43209
+ kind: string(),
43210
+ label: string(),
43211
+ gpuTypes: array(TrainingGpuOptionSchema).readonly(),
43212
+ regions: array(TrainingRegionOptionSchema).readonly(),
43213
+ maxDatasetBytes: number().int().positive(),
43214
+ maxRuntimeSec: number().int().positive(),
43215
+ freeTierNote: string().optional(),
43216
+ /** Where the data goes, in one sentence the confirm dialog repeats. */
43217
+ dataResidencyNote: string(),
43218
+ /** Credentials are present — never the values. */
43219
+ configured: boolean(),
43220
+ defaults: TrainingProviderDefaultsSchema
43221
+ });
43222
+ var TrainingCredentialCheckSchema = object({
43223
+ ok: boolean(),
43224
+ /** Workspace / account name, when the provider says. */
43225
+ account: string().optional(),
43226
+ reason: _enum([
43227
+ "missing",
43228
+ "invalid",
43229
+ "forbidden",
43230
+ "network",
43231
+ "quota"
43232
+ ]).optional(),
43233
+ detail: string().optional()
43234
+ });
43235
+ var ProviderJobStateSchema = _enum([
43236
+ "pending",
43237
+ "starting",
43238
+ "running",
43239
+ "succeeded",
43240
+ "failed",
43241
+ "cancelled",
43242
+ "lost"
43243
+ ]);
43244
+ var ProviderJobStatusSchema = object({
43245
+ jobKey: string(),
43246
+ providerJobId: string().optional(),
43247
+ state: ProviderJobStateSchema,
43248
+ startedAt: number().optional(),
43249
+ endedAt: number().optional(),
43250
+ exitCode: number().int().optional(),
43251
+ failureReason: string().optional(),
43252
+ gpuType: string(),
43253
+ region: string().optional(),
43254
+ billedSeconds: number().nonnegative(),
43255
+ costUsd: number().nonnegative(),
43256
+ /** True when `costUsd` is runtime × list price, not a billing answer. */
43257
+ costIsEstimate: boolean(),
43258
+ lastFetchedAt: number()
43259
+ });
43260
+ /**
43261
+ * The trainer the job runs, by SOURCE revision: the provider turns it into an
43262
+ * image its own way (Modal builds the published Dockerfile at that revision;
43263
+ * a registry-pull provider maps it to a tag). Recorded on the job and echoed
43264
+ * in `result.json`.
43265
+ */
43266
+ var TrainerSourceRefSchema = object({
43267
+ /** Hugging Face repo id, e.g. `camstack/camstack-trainer`. */
43268
+ repo: string().min(1),
43269
+ /** A commit sha (never a branch) — the job must be reproducible. */
43270
+ revision: string().regex(/^[0-9a-f]{7,64}$/)
43271
+ });
43272
+ var JobRef = {
43273
+ addonId: string(),
43274
+ jobKey: string().uuid()
43275
+ };
43276
+ var TrainingLogLineSchema = object({
43277
+ ts: number(),
43278
+ text: string()
43279
+ });
43280
+ method(object({}), array(TrainingProviderDescriptorSchema).readonly(), { auth: "admin" }), method(object({ addonId: string() }), TrainingCredentialCheckSchema, {
43281
+ kind: "mutation",
43282
+ auth: "admin",
43283
+ timeoutMs: 3e4
43284
+ }), method(object({
43285
+ addonId: string(),
43286
+ gpuType: string(),
43287
+ region: string(),
43288
+ datasetBytes: number().int().nonnegative(),
43289
+ gpuSecondsLow: number().nonnegative(),
43290
+ gpuSecondsHigh: number().nonnegative()
43291
+ }), object({
43292
+ usdLow: number().nonnegative(),
43293
+ usdHigh: number().nonnegative(),
43294
+ notes: array(string()).readonly()
43295
+ }), { auth: "admin" }), method(object({
43296
+ ...JobRef,
43297
+ ticket: PeerBytesTicketSchema
43298
+ }), object({
43299
+ bytes: number().int().nonnegative(),
43300
+ sha256: string()
43301
+ }), {
43302
+ kind: "mutation",
43303
+ auth: "admin",
43304
+ timeoutMs: 120 * 6e4
43305
+ }), method(object({
43306
+ ...JobRef,
43307
+ trainer: TrainerSourceRefSchema,
43308
+ jobSpecJson: string().min(2).max(64e3),
43309
+ gpuType: string(),
43310
+ region: string(),
43311
+ maxRuntimeSec: number().int().positive()
43312
+ }), ProviderJobStatusSchema, {
43313
+ kind: "mutation",
43314
+ auth: "admin",
43315
+ timeoutMs: 30 * 6e4
43316
+ }), method(object(JobRef), ProviderJobStatusSchema, {
43317
+ auth: "admin",
43318
+ timeoutMs: 6e4
43319
+ }), method(object({
43320
+ ...JobRef,
43321
+ cursor: string().optional(),
43322
+ max: number().int().min(1).max(500)
43323
+ }), object({
43324
+ lines: array(TrainingLogLineSchema).readonly(),
43325
+ cursor: string()
43326
+ }), {
43327
+ auth: "admin",
43328
+ timeoutMs: 6e4
43329
+ }), method(object(JobRef), object({ ok: literal(true) }), {
43330
+ kind: "mutation",
43331
+ auth: "admin",
43332
+ timeoutMs: 6e4
43333
+ }), method(object(JobRef), object({
43334
+ found: boolean(),
43335
+ text: string().optional()
43336
+ }), {
43337
+ kind: "mutation",
43338
+ auth: "admin",
43339
+ timeoutMs: 5 * 6e4
43340
+ }), method(object({
43341
+ ...JobRef,
43342
+ path: _enum(["bundle.tar"])
43343
+ }), object({ ticket: PeerBytesTicketSchema }), {
43344
+ kind: "mutation",
43345
+ auth: "admin",
43346
+ timeoutMs: 5 * 6e4
43347
+ }), method(object(JobRef), object({ deleted: array(string()).readonly() }), {
43348
+ kind: "mutation",
43349
+ auth: "admin",
43350
+ timeoutMs: 5 * 6e4
43351
+ }), method(object({ addonId: string() }), array(ProviderJobStatusSchema).readonly(), {
43352
+ auth: "admin",
43353
+ timeoutMs: 2 * 6e4
43354
+ });
43355
+ /**
43356
+ * `training` — the cloud-training orchestrator (D805). Hub-only singleton,
43357
+ * provided by `addon-training`.
43358
+ *
43359
+ * It owns what every provider must agree on, written once:
43360
+ *
43361
+ * - **Dataset versions.** Taken over from pipeline-analytics (D796): the rows
43362
+ * live here (D808); pipeline-analytics still CUTS a version (it owns the corpus and
43363
+ * the export plan) and reaches this store through the five row methods
43364
+ * below, so the Retrain page and the export did not change.
43365
+ * - **Jobs.** A persisted state machine, a reconcile loop against the
43366
+ * provider, a cost guard, a daily orphan sweep and the retention rules.
43367
+ * - **The return flow.** Verified artefacts → Model Studio
43368
+ * (`custom-model-registry.importModelBundle`) → canary on cameras →
43369
+ * rollback. Nothing is ever registered automatically.
43370
+ *
43371
+ * Every method is `admin`.
43372
+ */
43373
+ /** A version WITH its frame list — what the export and a job read. */
43374
+ var TrainingDatasetVersionRowSchema = RetrainDatasetVersionSchema.omit({ frameCount: true }).extend({ frameIds: array(string()).max(2e4).readonly() });
43375
+ /** A base model a detector job can fine-tune, and the baseline it is judged against. */
43376
+ var TrainingBaseModelSchema = object({
43377
+ modelId: string(),
43378
+ label: string(),
43379
+ weights: string(),
43380
+ imgsz: number().int(),
43381
+ baselineOnnxUrl: string(),
43382
+ baselineFloors: record(string(), number()),
43383
+ /** The base the fleet runs most — the UI's default. */
43384
+ recommended: boolean()
43385
+ });
43386
+ var TrainingPresetSchema = _enum([
43387
+ "quick",
43388
+ "standard",
43389
+ "thorough"
43390
+ ]);
43391
+ var TrainingJobRequestSchema = object({
43392
+ datasetVersionId: string().min(1),
43393
+ /** The `training-provider` addon that runs it. */
43394
+ addonId: string().min(1),
43395
+ gpuType: string().min(1),
43396
+ region: string(),
43397
+ baseModelId: string().min(1),
43398
+ preset: TrainingPresetSchema,
43399
+ /** Freeze the backbone's first N layers; `null` = the preset's choice. */
43400
+ freeze: number().int().nonnegative().nullable(),
43401
+ /** Cameras held out whole for evaluation; `null` = the orchestrator's default. */
43402
+ holdoutCameras: array(number().int()).nullable()
43403
+ });
43404
+ var TrainingSplitPlanSchema = object({
43405
+ holdoutCameras: array(number().int()).readonly(),
43406
+ /** Used when no camera is held out: the last N days of every camera. */
43407
+ holdoutLastDays: number().int().nonnegative(),
43408
+ /** Holdout subjects per class (camera holdout only; `null` = known only after the split). */
43409
+ holdoutSupport: record(string(), number().int()).nullable(),
43410
+ trainSubjects: number().int()
43411
+ });
43412
+ var TrainingRefusalReasonSchema = _enum([
43413
+ "unknown-dataset",
43414
+ "unknown-provider",
43415
+ "provider-not-configured",
43416
+ "unknown-base-model",
43417
+ "unknown-gpu",
43418
+ "dataset-too-large",
43419
+ "no-training-subjects",
43420
+ "job-already-running"
43421
+ ]);
43422
+ var TrainingJobPlanSchema = object({
43423
+ refusal: object({
43424
+ reason: TrainingRefusalReasonSchema,
43425
+ detail: string()
43426
+ }).nullable(),
43427
+ warnings: array(string()).readonly(),
43428
+ split: TrainingSplitPlanSchema.nullable(),
43429
+ estimate: object({
43430
+ datasetBytes: number().int(),
43431
+ uploadMinutesAt20Mbps: number(),
43432
+ gpuSecondsLow: number(),
43433
+ gpuSecondsHigh: number(),
43434
+ usdLow: number(),
43435
+ usdHigh: number(),
43436
+ notes: array(string()).readonly()
43437
+ }).nullable(),
43438
+ /** Pre-filled from the provider's settings; the operator may lower or raise them. */
43439
+ defaults: object({
43440
+ maxCostUsd: number(),
43441
+ maxRuntimeSec: number().int()
43442
+ }).nullable(),
43443
+ /** The sentence the confirm dialog repeats: where the frames go and when they are deleted. */
43444
+ dataNotice: string()
43445
+ });
43446
+ /**
43447
+ * Orchestrator-owned states, persisted. `uploading` covers exporting the
43448
+ * archive (it is streamed, never staged). Terminal: `failed`, `cancelled`,
43449
+ * `lost`, `expired`, `discarded`. `registered` and `canary` are where a
43450
+ * result lives after the operator acted on it.
43451
+ */
43452
+ var TrainingJobStateSchema = _enum([
43453
+ "uploading",
43454
+ "submitted",
43455
+ "starting",
43456
+ "running",
43457
+ "collecting",
43458
+ "ready",
43459
+ "registered",
43460
+ "canary",
43461
+ "failed",
43462
+ "cancelling",
43463
+ "cancelled",
43464
+ "lost",
43465
+ "expired",
43466
+ "discarded"
43467
+ ]);
43468
+ var TrainingFailureReasonSchema = _enum([
43469
+ "cost-cap",
43470
+ "runtime-cap",
43471
+ "upload-failed",
43472
+ "submit-failed",
43473
+ "trainer-failed",
43474
+ "result-invalid",
43475
+ "checksum-mismatch",
43476
+ "fetch-failed",
43477
+ "provider-error",
43478
+ "hub-restart-during-upload"
43479
+ ]);
43480
+ var TrainingProgressPointSchema = object({
43481
+ epoch: number().int(),
43482
+ map50: number().nullable(),
43483
+ map50_95: number().nullable()
43484
+ });
43485
+ var TrainingCanarySchema = object({
43486
+ deviceIds: array(number().int()).readonly(),
43487
+ since: number(),
43488
+ /** Every override the canary replaced, exactly, so rollback restores it. */
43489
+ previous: array(object({
43490
+ deviceId: number().int(),
43491
+ nodeId: string(),
43492
+ deviceKey: string(),
43493
+ patch: object({
43494
+ modelId: string().optional(),
43495
+ settings: record(string(), unknown()).readonly().optional()
43496
+ }).nullable()
43497
+ })).readonly()
43498
+ });
43499
+ var TrainingJobSchema = object({
43500
+ id: string(),
43501
+ idempotencyKey: string(),
43502
+ name: string(),
43503
+ createdAt: number(),
43504
+ updatedAt: number(),
43505
+ state: TrainingJobStateSchema,
43506
+ stage: TrainingStageSchema.nullable(),
43507
+ failure: object({
43508
+ reason: TrainingFailureReasonSchema,
43509
+ stage: string().nullable(),
43510
+ detail: string()
43511
+ }).nullable(),
43512
+ request: TrainingJobRequestSchema,
43513
+ maxCostUsd: number().nonnegative(),
43514
+ maxRuntimeSec: number().int().positive(),
43515
+ trainer: TrainerSourceRefSchema,
43516
+ datasetLayout: RetrainExportLayoutSchema,
43517
+ dataset: object({
43518
+ bytes: number().int(),
43519
+ sha256: string(),
43520
+ uploadedAt: number()
43521
+ }).nullable(),
43522
+ split: TrainingSplitPlanSchema,
43523
+ provider: object({
43524
+ state: ProviderJobStateSchema.nullable(),
43525
+ providerJobId: string().nullable(),
43526
+ startedAt: number().nullable(),
43527
+ endedAt: number().nullable(),
43528
+ billedSeconds: number(),
43529
+ costUsd: number(),
43530
+ costIsEstimate: boolean(),
43531
+ lastPolledAt: number().nullable()
43532
+ }),
43533
+ progress: object({
43534
+ epoch: number().int().nullable(),
43535
+ epochs: number().int().nullable(),
43536
+ etaSec: number().nullable(),
43537
+ series: array(TrainingProgressPointSchema).readonly()
43538
+ }),
43539
+ /** The last lines of the job's output (≤ 200), newest last. Never frame paths. */
43540
+ logTail: array(string()).readonly(),
43541
+ logCursor: string().nullable(),
43542
+ artifacts: object({
43543
+ bundleBytes: number().int(),
43544
+ bundleSha256: string(),
43545
+ fetchedAt: number(),
43546
+ /** When the staged artefacts are deleted from the hub. */
43547
+ expiresAt: number()
43548
+ }).nullable(),
43549
+ /** When the provider-side copy of the frames was deleted; null while it exists. */
43550
+ cloudDatasetDeletedAt: number().nullable(),
43551
+ /** A failed job's dataset is kept until then (the provider's grace), then deleted. */
43552
+ cloudCleanupDueAt: number().nullable(),
43553
+ /** Model ids registered from this job (base, and int8 when kept). */
43554
+ registeredModelIds: array(string()).readonly(),
43555
+ canary: TrainingCanarySchema.nullable()
43556
+ });
43557
+ var IdInput = object({ id: string().min(1) });
43558
+ method(TrainingDatasetVersionRowSchema, object({ stored: boolean() }), {
43559
+ kind: "mutation",
43560
+ auth: "admin"
43561
+ }), 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() }), {
43562
+ kind: "mutation",
43563
+ auth: "admin"
43564
+ }), method(object({}), array(TrainingBaseModelSchema).readonly(), { auth: "admin" }), method(TrainingJobRequestSchema, TrainingJobPlanSchema, {
43565
+ auth: "admin",
43566
+ timeoutMs: 6e4
43567
+ }), method(TrainingJobRequestSchema.extend({
43568
+ name: string().min(1).max(120),
43569
+ maxCostUsd: number().positive(),
43570
+ maxRuntimeSec: number().int().positive(),
43571
+ idempotencyKey: string().min(8).max(80)
43572
+ }), discriminatedUnion("kind", [object({
43573
+ kind: literal("started"),
43574
+ job: TrainingJobSchema
43575
+ }), object({
43576
+ kind: literal("refused"),
43577
+ reason: TrainingRefusalReasonSchema,
43578
+ detail: string()
43579
+ })]), {
43580
+ kind: "mutation",
43581
+ auth: "admin",
43582
+ timeoutMs: 12e4
43583
+ }), method(object({}), array(TrainingJobSchema).readonly(), { auth: "admin" }), method(IdInput, TrainingJobSchema.nullable(), { auth: "admin" }), method(IdInput, TrainingJobSchema, {
43584
+ kind: "mutation",
43585
+ auth: "admin",
43586
+ timeoutMs: 12e4
43587
+ }), method(IdInput, TrainingResultSchema.nullable(), { auth: "admin" }), method(IdInput.extend({ canaryDeviceIds: array(number().int()).readonly() }), TrainingJobSchema, {
43588
+ kind: "mutation",
43589
+ auth: "admin",
43590
+ timeoutMs: 30 * 6e4
43591
+ }), method(IdInput.extend({ deviceIds: array(number().int()).min(1).readonly() }), TrainingJobSchema, {
43592
+ kind: "mutation",
43593
+ auth: "admin",
43594
+ timeoutMs: 12e4
43595
+ }), method(IdInput, TrainingJobSchema, {
43596
+ kind: "mutation",
43597
+ auth: "admin",
43598
+ timeoutMs: 12e4
43599
+ }), method(IdInput, TrainingJobSchema, {
43600
+ kind: "mutation",
43601
+ auth: "admin"
43602
+ });
40628
43603
  SOURCE_CAPS.filter((cap) => cap !== "switch" && cap !== "motion");
40629
43604
  Object.freeze({
40630
43605
  person: .5,
@@ -41111,7 +44086,8 @@ var BaseDevice = class {
41111
44086
  this.role = options.role;
41112
44087
  this.parentDeviceId = ctx.parentDeviceId;
41113
44088
  const seedData = ctx.persistedConfig ?? {};
41114
- this.config = DeviceConfig.fromSchema(schema, (data) => ctx.persistConfig(data), seedData, ({ droppedKeys, issues }) => {
44089
+ const declaredSecretPaths = collectZodSecretPaths(schema);
44090
+ this.config = DeviceConfig.fromSchema(schema, (data) => ctx.persistConfig(data, { secretConfigPaths: declaredSecretPaths }), seedData, ({ droppedKeys, issues }) => {
41115
44091
  ctx.logger.warn("Device config recovery: dropping invalid persisted fields", {
41116
44092
  tags: {
41117
44093
  deviceId: ctx.id,
@@ -42772,6 +45748,12 @@ Object.freeze({
42772
45748
  addonId: null,
42773
45749
  access: "create"
42774
45750
  },
45751
+ "backup.checkBackupKey": {
45752
+ capName: "backup",
45753
+ capScope: "system",
45754
+ addonId: null,
45755
+ access: "create"
45756
+ },
42775
45757
  "backup.delete": {
42776
45758
  capName: "backup",
42777
45759
  capScope: "system",
@@ -42784,6 +45766,18 @@ Object.freeze({
42784
45766
  addonId: null,
42785
45767
  access: "delete"
42786
45768
  },
45769
+ "backup.disableEncryption": {
45770
+ capName: "backup",
45771
+ capScope: "system",
45772
+ addonId: null,
45773
+ access: "create"
45774
+ },
45775
+ "backup.getEncryption": {
45776
+ capName: "backup",
45777
+ capScope: "system",
45778
+ addonId: null,
45779
+ access: "view"
45780
+ },
42787
45781
  "backup.getEntries": {
42788
45782
  capName: "backup",
42789
45783
  capScope: "system",
@@ -42838,6 +45832,12 @@ Object.freeze({
42838
45832
  addonId: null,
42839
45833
  access: "create"
42840
45834
  },
45835
+ "backup.setupEncryption": {
45836
+ capName: "backup",
45837
+ capScope: "system",
45838
+ addonId: null,
45839
+ access: "create"
45840
+ },
42841
45841
  "backup.trigger": {
42842
45842
  capName: "backup",
42843
45843
  capScope: "system",
@@ -43390,6 +46390,12 @@ Object.freeze({
43390
46390
  addonId: null,
43391
46391
  access: "create"
43392
46392
  },
46393
+ "customModelRegistry.importModelBundle": {
46394
+ capName: "custom-model-registry",
46395
+ capScope: "system",
46396
+ addonId: null,
46397
+ access: "create"
46398
+ },
43393
46399
  "customModelRegistry.listModels": {
43394
46400
  capName: "custom-model-registry",
43395
46401
  capScope: "system",
@@ -44800,6 +47806,108 @@ Object.freeze({
44800
47806
  addonId: null,
44801
47807
  access: "create"
44802
47808
  },
47809
+ "keychain.delete": {
47810
+ capName: "keychain",
47811
+ capScope: "system",
47812
+ addonId: null,
47813
+ access: "delete"
47814
+ },
47815
+ "keychain.getState": {
47816
+ capName: "keychain",
47817
+ capScope: "system",
47818
+ addonId: null,
47819
+ access: "view"
47820
+ },
47821
+ "keychain.listMeta": {
47822
+ capName: "keychain",
47823
+ capScope: "system",
47824
+ addonId: null,
47825
+ access: "view"
47826
+ },
47827
+ "keychain.put": {
47828
+ capName: "keychain",
47829
+ capScope: "system",
47830
+ addonId: null,
47831
+ access: "create"
47832
+ },
47833
+ "keychain.resolve": {
47834
+ capName: "keychain",
47835
+ capScope: "system",
47836
+ addonId: null,
47837
+ access: "view"
47838
+ },
47839
+ "keychainAdmin.acknowledgeReset": {
47840
+ capName: "keychain-admin",
47841
+ capScope: "system",
47842
+ addonId: null,
47843
+ access: "create"
47844
+ },
47845
+ "keychainAdmin.deleteOrphans": {
47846
+ capName: "keychain-admin",
47847
+ capScope: "system",
47848
+ addonId: null,
47849
+ access: "delete"
47850
+ },
47851
+ "keychainAdmin.downloadRecoveryKey": {
47852
+ capName: "keychain-admin",
47853
+ capScope: "system",
47854
+ addonId: null,
47855
+ access: "create"
47856
+ },
47857
+ "keychainAdmin.listAudit": {
47858
+ capName: "keychain-admin",
47859
+ capScope: "system",
47860
+ addonId: null,
47861
+ access: "view"
47862
+ },
47863
+ "keychainAdmin.listSecrets": {
47864
+ capName: "keychain-admin",
47865
+ capScope: "system",
47866
+ addonId: null,
47867
+ access: "view"
47868
+ },
47869
+ "keychainAdmin.purgeRetiredKeys": {
47870
+ capName: "keychain-admin",
47871
+ capScope: "system",
47872
+ addonId: null,
47873
+ access: "delete"
47874
+ },
47875
+ "keychainAdmin.resetKeychain": {
47876
+ capName: "keychain-admin",
47877
+ capScope: "system",
47878
+ addonId: null,
47879
+ access: "delete"
47880
+ },
47881
+ "keychainAdmin.resetReport": {
47882
+ capName: "keychain-admin",
47883
+ capScope: "system",
47884
+ addonId: null,
47885
+ access: "delete"
47886
+ },
47887
+ "keychainAdmin.reveal": {
47888
+ capName: "keychain-admin",
47889
+ capScope: "system",
47890
+ addonId: null,
47891
+ access: "create"
47892
+ },
47893
+ "keychainAdmin.rotateMasterKey": {
47894
+ capName: "keychain-admin",
47895
+ capScope: "system",
47896
+ addonId: null,
47897
+ access: "create"
47898
+ },
47899
+ "keychainAdmin.setSystemSecret": {
47900
+ capName: "keychain-admin",
47901
+ capScope: "system",
47902
+ addonId: null,
47903
+ access: "create"
47904
+ },
47905
+ "keychainAdmin.status": {
47906
+ capName: "keychain-admin",
47907
+ capScope: "system",
47908
+ addonId: null,
47909
+ access: "view"
47910
+ },
44803
47911
  "lawnMowerControl.dock": {
44804
47912
  capName: "lawn-mower-control",
44805
47913
  capScope: "device",
@@ -46174,6 +49282,18 @@ Object.freeze({
46174
49282
  addonId: null,
46175
49283
  access: "create"
46176
49284
  },
49285
+ "pipelineAnalytics.addRetrainFrameFromRecording": {
49286
+ capName: "pipeline-analytics",
49287
+ capScope: "device",
49288
+ addonId: null,
49289
+ access: "create"
49290
+ },
49291
+ "pipelineAnalytics.addRetrainFramesToCollection": {
49292
+ capName: "pipeline-analytics",
49293
+ capScope: "device",
49294
+ addonId: null,
49295
+ access: "create"
49296
+ },
46177
49297
  "pipelineAnalytics.applyDeviceSettingsPatch": {
46178
49298
  capName: "pipeline-analytics",
46179
49299
  capScope: "device",
@@ -46222,12 +49342,36 @@ Object.freeze({
46222
49342
  addonId: null,
46223
49343
  access: "view"
46224
49344
  },
49345
+ "pipelineAnalytics.createRetrainCollection": {
49346
+ capName: "pipeline-analytics",
49347
+ capScope: "device",
49348
+ addonId: null,
49349
+ access: "create"
49350
+ },
49351
+ "pipelineAnalytics.createRetrainDatasetVersion": {
49352
+ capName: "pipeline-analytics",
49353
+ capScope: "device",
49354
+ addonId: null,
49355
+ access: "create"
49356
+ },
46225
49357
  "pipelineAnalytics.deleteDeviceEvents": {
46226
49358
  capName: "pipeline-analytics",
46227
49359
  capScope: "device",
46228
49360
  addonId: null,
46229
49361
  access: "delete"
46230
49362
  },
49363
+ "pipelineAnalytics.deleteRetrainCollection": {
49364
+ capName: "pipeline-analytics",
49365
+ capScope: "device",
49366
+ addonId: null,
49367
+ access: "delete"
49368
+ },
49369
+ "pipelineAnalytics.deleteRetrainDatasetVersion": {
49370
+ capName: "pipeline-analytics",
49371
+ capScope: "device",
49372
+ addonId: null,
49373
+ access: "delete"
49374
+ },
46231
49375
  "pipelineAnalytics.deleteTracks": {
46232
49376
  capName: "pipeline-analytics",
46233
49377
  capScope: "device",
@@ -46432,6 +49576,30 @@ Object.freeze({
46432
49576
  addonId: null,
46433
49577
  access: "view"
46434
49578
  },
49579
+ "pipelineAnalytics.listRetrainAssistProfiles": {
49580
+ capName: "pipeline-analytics",
49581
+ capScope: "device",
49582
+ addonId: null,
49583
+ access: "view"
49584
+ },
49585
+ "pipelineAnalytics.listRetrainCollectionFrames": {
49586
+ capName: "pipeline-analytics",
49587
+ capScope: "device",
49588
+ addonId: null,
49589
+ access: "view"
49590
+ },
49591
+ "pipelineAnalytics.listRetrainCollections": {
49592
+ capName: "pipeline-analytics",
49593
+ capScope: "device",
49594
+ addonId: null,
49595
+ access: "view"
49596
+ },
49597
+ "pipelineAnalytics.listRetrainDatasetVersions": {
49598
+ capName: "pipeline-analytics",
49599
+ capScope: "device",
49600
+ addonId: null,
49601
+ access: "view"
49602
+ },
46435
49603
  "pipelineAnalytics.listRetrainFrames": {
46436
49604
  capName: "pipeline-analytics",
46437
49605
  capScope: "device",
@@ -46462,6 +49630,12 @@ Object.freeze({
46462
49630
  addonId: null,
46463
49631
  access: "view"
46464
49632
  },
49633
+ "pipelineAnalytics.offerRetrainArchive": {
49634
+ capName: "pipeline-analytics",
49635
+ capScope: "device",
49636
+ addonId: null,
49637
+ access: "create"
49638
+ },
46465
49639
  "pipelineAnalytics.ownersWithMedia": {
46466
49640
  capName: "pipeline-analytics",
46467
49641
  capScope: "device",
@@ -46474,12 +49648,24 @@ Object.freeze({
46474
49648
  addonId: null,
46475
49649
  access: "create"
46476
49650
  },
49651
+ "pipelineAnalytics.previewRetrainDataset": {
49652
+ capName: "pipeline-analytics",
49653
+ capScope: "device",
49654
+ addonId: null,
49655
+ access: "view"
49656
+ },
46477
49657
  "pipelineAnalytics.proposeRetrainAnnotations": {
46478
49658
  capName: "pipeline-analytics",
46479
49659
  capScope: "device",
46480
49660
  addonId: null,
46481
49661
  access: "create"
46482
49662
  },
49663
+ "pipelineAnalytics.proposeRetrainAnnotationsWithLlm": {
49664
+ capName: "pipeline-analytics",
49665
+ capScope: "device",
49666
+ addonId: null,
49667
+ access: "create"
49668
+ },
46483
49669
  "pipelineAnalytics.pruneEvents": {
46484
49670
  capName: "pipeline-analytics",
46485
49671
  capScope: "device",
@@ -46534,6 +49720,18 @@ Object.freeze({
46534
49720
  addonId: null,
46535
49721
  access: "create"
46536
49722
  },
49723
+ "pipelineAnalytics.removeRetrainFrameFromCollection": {
49724
+ capName: "pipeline-analytics",
49725
+ capScope: "device",
49726
+ addonId: null,
49727
+ access: "delete"
49728
+ },
49729
+ "pipelineAnalytics.renameRetrainCollection": {
49730
+ capName: "pipeline-analytics",
49731
+ capScope: "device",
49732
+ addonId: null,
49733
+ access: "create"
49734
+ },
46537
49735
  "pipelineAnalytics.restageRetrainTrack": {
46538
49736
  capName: "pipeline-analytics",
46539
49737
  capScope: "device",
@@ -46594,6 +49792,12 @@ Object.freeze({
46594
49792
  addonId: null,
46595
49793
  access: "create"
46596
49794
  },
49795
+ "pipelineAnalytics.verifyRetrainDatasetVersion": {
49796
+ capName: "pipeline-analytics",
49797
+ capScope: "device",
49798
+ addonId: null,
49799
+ access: "view"
49800
+ },
46597
49801
  "pipelineAnalytics.wipeAllAnalytics": {
46598
49802
  capName: "pipeline-analytics",
46599
49803
  capScope: "device",
@@ -46822,6 +50026,12 @@ Object.freeze({
46822
50026
  addonId: null,
46823
50027
  access: "view"
46824
50028
  },
50029
+ "pipelineOrchestrator.abortNodeBenchmark": {
50030
+ capName: "pipeline-orchestrator",
50031
+ capScope: "system",
50032
+ addonId: null,
50033
+ access: "create"
50034
+ },
46825
50035
  "pipelineOrchestrator.applyAutoTune": {
46826
50036
  capName: "pipeline-orchestrator",
46827
50037
  capScope: "system",
@@ -46846,6 +50056,12 @@ Object.freeze({
46846
50056
  addonId: null,
46847
50057
  access: "create"
46848
50058
  },
50059
+ "pipelineOrchestrator.deleteNodeBenchmarkResult": {
50060
+ capName: "pipeline-orchestrator",
50061
+ capScope: "system",
50062
+ addonId: null,
50063
+ access: "delete"
50064
+ },
46849
50065
  "pipelineOrchestrator.getAgentLoad": {
46850
50066
  capName: "pipeline-orchestrator",
46851
50067
  capScope: "system",
@@ -46954,6 +50170,24 @@ Object.freeze({
46954
50170
  addonId: null,
46955
50171
  access: "view"
46956
50172
  },
50173
+ "pipelineOrchestrator.getNodeBenchmarkCandidates": {
50174
+ capName: "pipeline-orchestrator",
50175
+ capScope: "system",
50176
+ addonId: null,
50177
+ access: "view"
50178
+ },
50179
+ "pipelineOrchestrator.getNodeBenchmarkPreflight": {
50180
+ capName: "pipeline-orchestrator",
50181
+ capScope: "system",
50182
+ addonId: null,
50183
+ access: "view"
50184
+ },
50185
+ "pipelineOrchestrator.getNodeBenchmarkStatus": {
50186
+ capName: "pipeline-orchestrator",
50187
+ capScope: "system",
50188
+ addonId: null,
50189
+ access: "view"
50190
+ },
46957
50191
  "pipelineOrchestrator.getNodeInferenceDevices": {
46958
50192
  capName: "pipeline-orchestrator",
46959
50193
  capScope: "system",
@@ -46996,6 +50230,12 @@ Object.freeze({
46996
50230
  addonId: null,
46997
50231
  access: "view"
46998
50232
  },
50233
+ "pipelineOrchestrator.listNodeBenchmarkResults": {
50234
+ capName: "pipeline-orchestrator",
50235
+ capScope: "system",
50236
+ addonId: null,
50237
+ access: "view"
50238
+ },
46999
50239
  "pipelineOrchestrator.pauseForStorageMigration": {
47000
50240
  capName: "pipeline-orchestrator",
47001
50241
  capScope: "system",
@@ -47140,6 +50380,12 @@ Object.freeze({
47140
50380
  addonId: null,
47141
50381
  access: "create"
47142
50382
  },
50383
+ "pipelineOrchestrator.startNodeBenchmark": {
50384
+ capName: "pipeline-orchestrator",
50385
+ capScope: "system",
50386
+ addonId: null,
50387
+ access: "create"
50388
+ },
47143
50389
  "pipelineOrchestrator.suggestShares": {
47144
50390
  capName: "pipeline-orchestrator",
47145
50391
  capScope: "system",
@@ -47158,6 +50404,12 @@ Object.freeze({
47158
50404
  addonId: null,
47159
50405
  access: "create"
47160
50406
  },
50407
+ "pipelineRunner.abortNodeBench": {
50408
+ capName: "pipeline-runner",
50409
+ capScope: "system",
50410
+ addonId: null,
50411
+ access: "create"
50412
+ },
47161
50413
  "pipelineRunner.attachCamera": {
47162
50414
  capName: "pipeline-runner",
47163
50415
  capScope: "system",
@@ -47206,6 +50458,12 @@ Object.freeze({
47206
50458
  addonId: null,
47207
50459
  access: "view"
47208
50460
  },
50461
+ "pipelineRunner.getNodeBenchStatus": {
50462
+ capName: "pipeline-runner",
50463
+ capScope: "system",
50464
+ addonId: null,
50465
+ access: "view"
50466
+ },
47209
50467
  "pipelineRunner.getParkedTrackFrame": {
47210
50468
  capName: "pipeline-runner",
47211
50469
  capScope: "system",
@@ -47248,6 +50506,12 @@ Object.freeze({
47248
50506
  addonId: null,
47249
50507
  access: "create"
47250
50508
  },
50509
+ "pipelineRunner.startNodeBench": {
50510
+ capName: "pipeline-runner",
50511
+ capScope: "system",
50512
+ addonId: null,
50513
+ access: "create"
50514
+ },
47251
50515
  "plateGallery.assignPlate": {
47252
50516
  capName: "plate-gallery",
47253
50517
  capScope: "system",
@@ -48910,6 +52174,174 @@ Object.freeze({
48910
52174
  addonId: null,
48911
52175
  access: "view"
48912
52176
  },
52177
+ "training.canaryResult": {
52178
+ capName: "training",
52179
+ capScope: "system",
52180
+ addonId: null,
52181
+ access: "create"
52182
+ },
52183
+ "training.cancelJob": {
52184
+ capName: "training",
52185
+ capScope: "system",
52186
+ addonId: null,
52187
+ access: "create"
52188
+ },
52189
+ "training.discardResult": {
52190
+ capName: "training",
52191
+ capScope: "system",
52192
+ addonId: null,
52193
+ access: "create"
52194
+ },
52195
+ "training.findDatasetVersionIdByName": {
52196
+ capName: "training",
52197
+ capScope: "system",
52198
+ addonId: null,
52199
+ access: "view"
52200
+ },
52201
+ "training.getDatasetVersion": {
52202
+ capName: "training",
52203
+ capScope: "system",
52204
+ addonId: null,
52205
+ access: "view"
52206
+ },
52207
+ "training.getJob": {
52208
+ capName: "training",
52209
+ capScope: "system",
52210
+ addonId: null,
52211
+ access: "view"
52212
+ },
52213
+ "training.getJobResult": {
52214
+ capName: "training",
52215
+ capScope: "system",
52216
+ addonId: null,
52217
+ access: "view"
52218
+ },
52219
+ "training.listBaseModels": {
52220
+ capName: "training",
52221
+ capScope: "system",
52222
+ addonId: null,
52223
+ access: "view"
52224
+ },
52225
+ "training.listDatasetVersions": {
52226
+ capName: "training",
52227
+ capScope: "system",
52228
+ addonId: null,
52229
+ access: "view"
52230
+ },
52231
+ "training.listJobs": {
52232
+ capName: "training",
52233
+ capScope: "system",
52234
+ addonId: null,
52235
+ access: "view"
52236
+ },
52237
+ "training.planJob": {
52238
+ capName: "training",
52239
+ capScope: "system",
52240
+ addonId: null,
52241
+ access: "view"
52242
+ },
52243
+ "training.putDatasetVersion": {
52244
+ capName: "training",
52245
+ capScope: "system",
52246
+ addonId: null,
52247
+ access: "create"
52248
+ },
52249
+ "training.registerResult": {
52250
+ capName: "training",
52251
+ capScope: "system",
52252
+ addonId: null,
52253
+ access: "create"
52254
+ },
52255
+ "training.removeDatasetVersion": {
52256
+ capName: "training",
52257
+ capScope: "system",
52258
+ addonId: null,
52259
+ access: "delete"
52260
+ },
52261
+ "training.rollbackCanary": {
52262
+ capName: "training",
52263
+ capScope: "system",
52264
+ addonId: null,
52265
+ access: "create"
52266
+ },
52267
+ "training.startJob": {
52268
+ capName: "training",
52269
+ capScope: "system",
52270
+ addonId: null,
52271
+ access: "create"
52272
+ },
52273
+ "trainingProvider.cancelJob": {
52274
+ capName: "training-provider",
52275
+ capScope: "system",
52276
+ addonId: null,
52277
+ access: "create"
52278
+ },
52279
+ "trainingProvider.cleanupJob": {
52280
+ capName: "training-provider",
52281
+ capScope: "system",
52282
+ addonId: null,
52283
+ access: "create"
52284
+ },
52285
+ "trainingProvider.describe": {
52286
+ capName: "training-provider",
52287
+ capScope: "system",
52288
+ addonId: null,
52289
+ access: "view"
52290
+ },
52291
+ "trainingProvider.estimateJob": {
52292
+ capName: "training-provider",
52293
+ capScope: "system",
52294
+ addonId: null,
52295
+ access: "view"
52296
+ },
52297
+ "trainingProvider.getJob": {
52298
+ capName: "training-provider",
52299
+ capScope: "system",
52300
+ addonId: null,
52301
+ access: "view"
52302
+ },
52303
+ "trainingProvider.listJobEvents": {
52304
+ capName: "training-provider",
52305
+ capScope: "system",
52306
+ addonId: null,
52307
+ access: "view"
52308
+ },
52309
+ "trainingProvider.listJobs": {
52310
+ capName: "training-provider",
52311
+ capScope: "system",
52312
+ addonId: null,
52313
+ access: "view"
52314
+ },
52315
+ "trainingProvider.offerArtifact": {
52316
+ capName: "training-provider",
52317
+ capScope: "system",
52318
+ addonId: null,
52319
+ access: "create"
52320
+ },
52321
+ "trainingProvider.readResult": {
52322
+ capName: "training-provider",
52323
+ capScope: "system",
52324
+ addonId: null,
52325
+ access: "create"
52326
+ },
52327
+ "trainingProvider.submitJob": {
52328
+ capName: "training-provider",
52329
+ capScope: "system",
52330
+ addonId: null,
52331
+ access: "create"
52332
+ },
52333
+ "trainingProvider.uploadDataset": {
52334
+ capName: "training-provider",
52335
+ capScope: "system",
52336
+ addonId: null,
52337
+ access: "create"
52338
+ },
52339
+ "trainingProvider.validateCredentials": {
52340
+ capName: "training-provider",
52341
+ capScope: "system",
52342
+ addonId: null,
52343
+ access: "create"
52344
+ },
48913
52345
  "turnProvider.getTurnServers": {
48914
52346
  capName: "turn-provider",
48915
52347
  capScope: "system",
@@ -48934,12 +52366,6 @@ Object.freeze({
48934
52366
  addonId: null,
48935
52367
  access: "create"
48936
52368
  },
48937
- "userManagement.createApiKey": {
48938
- capName: "user-management",
48939
- capScope: "system",
48940
- addonId: null,
48941
- access: "create"
48942
- },
48943
52369
  "userManagement.createScopedToken": {
48944
52370
  capName: "user-management",
48945
52371
  capScope: "system",
@@ -48976,12 +52402,6 @@ Object.freeze({
48976
52402
  addonId: null,
48977
52403
  access: "view"
48978
52404
  },
48979
- "userManagement.linkExternalIdentity": {
48980
- capName: "user-management",
48981
- capScope: "system",
48982
- addonId: null,
48983
- access: "create"
48984
- },
48985
52405
  "userManagement.listApiKeys": {
48986
52406
  capName: "user-management",
48987
52407
  capScope: "system",
@@ -49084,12 +52504,6 @@ Object.freeze({
49084
52504
  addonId: null,
49085
52505
  access: "create"
49086
52506
  },
49087
- "userManagement.validateApiKey": {
49088
- capName: "user-management",
49089
- capScope: "system",
49090
- addonId: null,
49091
- access: "view"
49092
- },
49093
52507
  "userManagement.validateCredentials": {
49094
52508
  capName: "user-management",
49095
52509
  capScope: "system",
@@ -52177,6 +55591,11 @@ Object.freeze({
52177
55591
  form: "single",
52178
55592
  optional: false
52179
55593
  }],
55594
+ "pipelineAnalytics.addRetrainFrameFromRecording": [{
55595
+ name: "deviceId",
55596
+ form: "single",
55597
+ optional: false
55598
+ }],
52180
55599
  "pipelineAnalytics.applyDeviceSettingsPatch": [{
52181
55600
  name: "deviceId",
52182
55601
  form: "single",
@@ -52367,6 +55786,11 @@ Object.freeze({
52367
55786
  form: "single",
52368
55787
  optional: false
52369
55788
  }],
55789
+ "pipelineAnalytics.proposeRetrainAnnotationsWithLlm": [{
55790
+ name: "deviceId",
55791
+ form: "single",
55792
+ optional: false
55793
+ }],
52370
55794
  "pipelineAnalytics.pruneEventsBefore": [{
52371
55795
  name: "deviceId",
52372
55796
  form: "single",
@@ -53193,6 +56617,11 @@ Object.freeze({
53193
56617
  form: "single",
53194
56618
  optional: false
53195
56619
  }],
56620
+ "training.canaryResult": [{
56621
+ name: "deviceIds",
56622
+ form: "array",
56623
+ optional: false
56624
+ }],
53196
56625
  "update.getStatus": [{
53197
56626
  name: "deviceId",
53198
56627
  form: "single",