@camstack/addon-provider-petkit 0.2.122 → 0.2.124

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/dist/addon.js +3555 -126
  2. package/dist/addon.mjs +3555 -126
  3. package/package.json +1 -1
package/dist/addon.js CHANGED
@@ -1101,7 +1101,7 @@ var Nodepetkit = class {
1101
1101
  }
1102
1102
  };
1103
1103
  //#endregion
1104
- //#region ../types/dist/event-category-B_0XEcLF.mjs
1104
+ //#region ../types/dist/event-category-DaIZi00R.mjs
1105
1105
  var EventCategory = /* @__PURE__ */ function(EventCategory) {
1106
1106
  EventCategory["SystemBoot"] = "system.boot";
1107
1107
  EventCategory["SystemAddonsReady"] = "system.addons-ready";
@@ -1180,6 +1180,13 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
1180
1180
  */
1181
1181
  EventCategory["AddonLoadFailed"] = "addon.load-failed";
1182
1182
  /**
1183
+ * A keychain value was stored or removed (D787). Carries the ref, its
1184
+ * owner and the new version — NEVER the value. A process holding the ref
1185
+ * drops its cached copy and the owning `BaseAddon` re-resolves its config.
1186
+ * Telemetry (D8): a process that misses it still revalidates by version.
1187
+ */
1188
+ EventCategory["KeychainChanged"] = "keychain.changed";
1189
+ /**
1183
1190
  * Addon recovered from a previous failure. Emitted when an addon
1184
1191
  * transitions from `failed` back to `healthy` (typically via the
1185
1192
  * monitor's auto-retry loop, or after manual `addons.retryLoad`).
@@ -6472,7 +6479,7 @@ var ZodIssueCode = {
6472
6479
  var ZodFirstPartyTypeKind;
6473
6480
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
6474
6481
  //#endregion
6475
- //#region ../types/dist/sleep-B0JG7-_F.mjs
6482
+ //#region ../types/dist/sleep-r3RWkGVx.mjs
6476
6483
  /**
6477
6484
  * The audio chunk plane's byte format, and the ONE expansion from a coded
6478
6485
  * window to float samples (D455).
@@ -6551,6 +6558,97 @@ function buildAlawTable() {
6551
6558
  }
6552
6559
  buildUlawTable();
6553
6560
  buildAlawTable();
6561
+ /** Is this field's stored value a credential? */
6562
+ function isSecretConfigField(field) {
6563
+ if (field.type === "password") return true;
6564
+ return "secret" in field && field.secret === true;
6565
+ }
6566
+ /**
6567
+ * Is this field's value stored in the KEYCHAIN (D787)? Every secret field is,
6568
+ * by its TYPE, unless it opts out with `storage: 'inline'` — never by its name.
6569
+ */
6570
+ function isKeychainStoredField(field) {
6571
+ if (!isSecretConfigField(field)) return false;
6572
+ if (field.type === "textarea" && field.isJson === true) return false;
6573
+ return !("storage" in field && field.storage === "inline");
6574
+ }
6575
+ /**
6576
+ * What a settings blob holds where a secret used to be.
6577
+ *
6578
+ * A keychain-stored field never holds its value. It holds a self-describing
6579
+ * MARKER, `{"$secret":"secret://…","v":1}` — an object, never a string, so no
6580
+ * code can mistake it for a credential and no form can send it to a camera as
6581
+ * a password. The empty state is `null` / absent, never `''`.
6582
+ *
6583
+ * The same shapes travel to and from the admin UI:
6584
+ *
6585
+ * - read: `hydrateSchema` hands a secret field a {@link SecretFieldView}
6586
+ * (`{ $secret, v, set: true }`) or `null` — the browser learns whether a
6587
+ * value is set, never the value.
6588
+ * - write: an untouched field submits the view back unchanged (KEEP); a typed
6589
+ * value is a plain non-empty string (CHANGE); the Clear button submits
6590
+ * {@link SECRET_CLEAR} (CLEAR). `''`, `null` and the legacy redaction tokens
6591
+ * are KEEP — an empty string is what a defaults-fallback pushes back, and
6592
+ * treating it as "clear" is how a save destroyed a stored credential before.
6593
+ *
6594
+ * Pure and browser-safe.
6595
+ */
6596
+ var SECRET_CLEAR = { $secretClear: true };
6597
+ /** The `'***'` token D634 redaction writes for non-admins. */
6598
+ var LEGACY_DEVICE_REDACTION = "***";
6599
+ function isRecord$2(value) {
6600
+ return typeof value === "object" && value !== null && !Array.isArray(value);
6601
+ }
6602
+ function makeSecretMarker(ref) {
6603
+ return {
6604
+ $secret: ref,
6605
+ v: 1
6606
+ };
6607
+ }
6608
+ /** A stored marker: an object whose `$secret` is a non-empty string. */
6609
+ function isSecretMarker(value) {
6610
+ if (!isRecord$2(value)) return false;
6611
+ const ref = value["$secret"];
6612
+ return typeof ref === "string" && ref.length > 0;
6613
+ }
6614
+ function isSecretClear(value) {
6615
+ return isRecord$2(value) && value["$secretClear"] === true;
6616
+ }
6617
+ /**
6618
+ * The UI view of a stored secret field value: a marker becomes "set", inline
6619
+ * plaintext becomes "set (inline)", nothing becomes `null`. A value never
6620
+ * survives this function.
6621
+ */
6622
+ function toSecretFieldView(stored) {
6623
+ if (isSecretMarker(stored)) return {
6624
+ $secret: stored.$secret,
6625
+ v: 1,
6626
+ set: true
6627
+ };
6628
+ if (typeof stored === "string" && stored.length > 0) return {
6629
+ $secret: null,
6630
+ v: 1,
6631
+ set: true,
6632
+ inline: true
6633
+ };
6634
+ return null;
6635
+ }
6636
+ /**
6637
+ * Classify an incoming value for a secret path. Only a non-empty string that is
6638
+ * not a redaction token sets a value; only {@link SECRET_CLEAR} clears.
6639
+ * Everything else — a marker (ours or anyone's), a UI view, `''`, `null`,
6640
+ * `undefined`, a redaction token, a non-string — keeps what is stored.
6641
+ */
6642
+ function classifySecretWrite(incoming) {
6643
+ if (isSecretClear(incoming)) return { kind: "clear" };
6644
+ if (typeof incoming !== "string") return { kind: "keep" };
6645
+ if (incoming.length === 0) return { kind: "keep" };
6646
+ if (incoming === "__camstack_redacted__" || incoming === LEGACY_DEVICE_REDACTION) return { kind: "keep" };
6647
+ return {
6648
+ kind: "set",
6649
+ value: incoming
6650
+ };
6651
+ }
6554
6652
  Object.fromEntries([
6555
6653
  {
6556
6654
  id: "overview",
@@ -6722,33 +6820,19 @@ Object.fromEntries([
6722
6820
  function isValuelessField(field) {
6723
6821
  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";
6724
6822
  }
6725
- /**
6726
- * Merge a `ConfigUISchema` with a raw `values` record into a
6727
- * `ConfigUISchemaWithValues`. Used by every `get*Settings` backend endpoint
6728
- * before returning to the admin UI. Groups are walked recursively.
6729
- *
6730
- * For each leaf field:
6731
- * - structural fields (`separator`, `info`, `button`) pass through unchanged
6732
- * - other fields get `value = values[key] ?? field.default ?? null`
6733
- *
6734
- * Unknown keys in `values` (keys not declared in the schema) are silently
6735
- * ignored — they don't contribute to the output. Missing keys fall back to
6736
- * the schema default or `null`. This mirrors the old backend behaviour where
6737
- * `FormBuilder` rendered `values[key] ?? field.default`.
6738
- */
6739
- function hydrateSchema(schema, values) {
6823
+ function hydrateSchema(schema, values, options = {}) {
6740
6824
  return {
6741
6825
  ...schema.tabs ? { tabs: [...schema.tabs] } : {},
6742
6826
  sections: schema.sections.map((section) => ({
6743
6827
  ...section,
6744
- fields: section.fields.map((field) => hydrateField(field, values))
6828
+ fields: section.fields.map((field) => hydrateField(field, values, options))
6745
6829
  }))
6746
6830
  };
6747
6831
  }
6748
- function hydrateField(field, values) {
6832
+ function hydrateField(field, values, options) {
6749
6833
  if (isValuelessField(field)) return field;
6750
6834
  if (field.type === "group") {
6751
- const hydratedChildren = field.fields.map((child) => hydrateField(child, values));
6835
+ const hydratedChildren = field.fields.map((child) => hydrateField(child, values, options));
6752
6836
  return {
6753
6837
  ...field,
6754
6838
  fields: hydratedChildren
@@ -6757,7 +6841,7 @@ function hydrateField(field, values) {
6757
6841
  if (field.type === "sub-tabs") {
6758
6842
  const hydratedTabs = field.tabs.map((tab) => ({
6759
6843
  ...tab,
6760
- fields: tab.fields.map((child) => hydrateField(child, values))
6844
+ fields: tab.fields.map((child) => hydrateField(child, values, options))
6761
6845
  }));
6762
6846
  return {
6763
6847
  ...field,
@@ -6767,6 +6851,33 @@ function hydrateField(field, values) {
6767
6851
  const key = field.key;
6768
6852
  const storedValue = Object.prototype.hasOwnProperty.call(values, key) ? values[key] : void 0;
6769
6853
  const defaultValue = field.default;
6854
+ const asView = (v) => isSecretMarker(v) || options.inlineSecretsAsViews === true && v !== void 0;
6855
+ if (isKeychainStoredField(field) && asView(storedValue)) return {
6856
+ ...field,
6857
+ value: toSecretFieldView(storedValue)
6858
+ };
6859
+ if (isKeychainStoredField(field) && options.inlineSecretsAsViews === true) return {
6860
+ ...field,
6861
+ value: null
6862
+ };
6863
+ if (field.type === "editable-array" && Array.isArray(storedValue)) {
6864
+ const secretItemKeys = field.itemFields.filter((item) => "key" in item && isKeychainStoredField(item)).map((item) => "key" in item ? item.key : "");
6865
+ if (secretItemKeys.length > 0) {
6866
+ const rows = storedValue.map((row) => {
6867
+ if (row === null || typeof row !== "object" || Array.isArray(row)) return row;
6868
+ const out = { ...row };
6869
+ for (const k of secretItemKeys) {
6870
+ const v = Reflect.get(row, k);
6871
+ if (asView(v)) out[k] = toSecretFieldView(v);
6872
+ }
6873
+ return out;
6874
+ });
6875
+ return {
6876
+ ...field,
6877
+ value: rows
6878
+ };
6879
+ }
6880
+ }
6770
6881
  if (field.multiple) {
6771
6882
  const stored = Array.isArray(storedValue) ? storedValue : storedValue !== void 0 && storedValue !== null ? [storedValue] : [];
6772
6883
  const itemFallback = field.multiple.itemDefault !== void 0 ? field.multiple.itemDefault : defaultValue !== void 0 ? defaultValue : typeOf(field) === "string" ? "" : null;
@@ -7009,6 +7120,778 @@ function projectStore(store, perNodeKeys, nodeId) {
7009
7120
  }
7010
7121
  return out;
7011
7122
  }
7123
+ var GLOBAL_SCOPE = { kind: "global" };
7124
+ /** The scope every addon-wide (not per-node, not per-device) setting lives in. */
7125
+ function globalSecretScope() {
7126
+ return GLOBAL_SCOPE;
7127
+ }
7128
+ function encodeSegment(value) {
7129
+ return encodeURIComponent(value);
7130
+ }
7131
+ function decodeSegment(value) {
7132
+ try {
7133
+ return decodeURIComponent(value);
7134
+ } catch {
7135
+ return null;
7136
+ }
7137
+ }
7138
+ /**
7139
+ * The field path of a value inside an array item, addressed by the item's id:
7140
+ * `arrayItemFieldPath('providers', 'authentik', 'clientSecret')` →
7141
+ * `providers[authentik].clientSecret`.
7142
+ */
7143
+ function arrayItemFieldPath(arrayKey, itemId, fieldKey) {
7144
+ return `${arrayKey}[${encodeSegment(itemId)}].${fieldKey}`;
7145
+ }
7146
+ function parseScope(segments) {
7147
+ switch (segments[0]) {
7148
+ case "global": return {
7149
+ scope: GLOBAL_SCOPE,
7150
+ used: 1
7151
+ };
7152
+ case "node": {
7153
+ const nodeId = segments[1] !== void 0 ? decodeSegment(segments[1]) : null;
7154
+ return nodeId === null || nodeId.length === 0 ? null : {
7155
+ scope: {
7156
+ kind: "node",
7157
+ nodeId
7158
+ },
7159
+ used: 2
7160
+ };
7161
+ }
7162
+ case "device": {
7163
+ const raw = segments[1];
7164
+ if (raw === void 0 || !/^\d+$/.test(raw)) return null;
7165
+ return {
7166
+ scope: {
7167
+ kind: "device",
7168
+ deviceId: Number(raw)
7169
+ },
7170
+ used: 2
7171
+ };
7172
+ }
7173
+ case "integration": {
7174
+ const id = segments[1] !== void 0 ? decodeSegment(segments[1]) : null;
7175
+ return id === null || id.length === 0 ? null : {
7176
+ scope: {
7177
+ kind: "integration",
7178
+ integrationId: id
7179
+ },
7180
+ used: 2
7181
+ };
7182
+ }
7183
+ case "row": {
7184
+ const collection = segments[1] !== void 0 ? decodeSegment(segments[1]) : null;
7185
+ const rowId = segments[2] !== void 0 ? decodeSegment(segments[2]) : null;
7186
+ if (collection === null || rowId === null || collection.length === 0 || rowId.length === 0) return null;
7187
+ return {
7188
+ scope: {
7189
+ kind: "row",
7190
+ collection,
7191
+ rowId
7192
+ },
7193
+ used: 3
7194
+ };
7195
+ }
7196
+ default: return null;
7197
+ }
7198
+ }
7199
+ /** Take a ref apart; `null` when it is not a well-formed ref. */
7200
+ function parseSecretRef(ref) {
7201
+ if (!ref.startsWith("secret://")) return null;
7202
+ const segments = ref.slice(9).split("/");
7203
+ const owner = segments[0] !== void 0 ? decodeSegment(segments[0]) : null;
7204
+ if (owner === null || owner.length === 0) return null;
7205
+ const parsed = parseScope(segments.slice(1));
7206
+ if (parsed === null) return null;
7207
+ const fieldPath = segments.slice(1 + parsed.used).join("/");
7208
+ if (fieldPath.length === 0) return null;
7209
+ return {
7210
+ owner,
7211
+ scope: parsed.scope,
7212
+ fieldPath
7213
+ };
7214
+ }
7215
+ /** A write to a secret path could not be stored in the keychain, so it was refused. */
7216
+ var KeychainWriteRefusedError = class extends Error {
7217
+ fieldPath;
7218
+ constructor(fieldPath, cause) {
7219
+ super(`secret "${fieldPath}" was not saved: the keychain could not store it (${cause instanceof Error ? cause.message : String(cause)}). Nothing was written.`);
7220
+ this.fieldPath = fieldPath;
7221
+ this.name = "KeychainWriteRefusedError";
7222
+ }
7223
+ };
7224
+ var KEEP = { kind: "keep" };
7225
+ function isRecord$1(value) {
7226
+ return typeof value === "object" && value !== null && !Array.isArray(value);
7227
+ }
7228
+ function defaultMintId() {
7229
+ return globalThis.crypto.randomUUID();
7230
+ }
7231
+ /** Every marker ref anywhere under `value`. */
7232
+ function collectSecretMarkerRefs(value, out = []) {
7233
+ if (isSecretMarker(value)) {
7234
+ out.push(value.$secret);
7235
+ return out;
7236
+ }
7237
+ if (Array.isArray(value)) for (const item of value) collectSecretMarkerRefs(item, out);
7238
+ else if (isRecord$1(value)) for (const child of Object.values(value)) collectSecretMarkerRefs(child, out);
7239
+ return out;
7240
+ }
7241
+ async function storedValueEquals(secrets, marker, candidate) {
7242
+ const resolved = (await secrets.resolve([marker.$secret]))[marker.$secret];
7243
+ return resolved?.kind === "value" && resolved.value === candidate;
7244
+ }
7245
+ async function writeLeaf(ctx, incoming, stored, fieldPath) {
7246
+ const intent = classifySecretWrite(incoming);
7247
+ const ref = ctx.secrets.ref(ctx.scope, fieldPath);
7248
+ const storedIsOurs = isSecretMarker(stored) && stored.$secret === ref;
7249
+ if (intent.kind === "keep") return KEEP;
7250
+ if (intent.kind === "set" && !ctx.operatorWrite && typeof stored === "string" && stored === intent.value) return KEEP;
7251
+ if (intent.kind === "clear") {
7252
+ if (storedIsOurs) ctx.deletes.push(ref);
7253
+ return {
7254
+ kind: "value",
7255
+ value: null
7256
+ };
7257
+ }
7258
+ if (storedIsOurs && await storedValueEquals(ctx.secrets, stored, intent.value)) return {
7259
+ kind: "value",
7260
+ value: stored
7261
+ };
7262
+ try {
7263
+ await ctx.secrets.put(ref, intent.value);
7264
+ } catch (err) {
7265
+ throw new KeychainWriteRefusedError(fieldPath, err);
7266
+ }
7267
+ return {
7268
+ kind: "value",
7269
+ value: makeSecretMarker(ref)
7270
+ };
7271
+ }
7272
+ /** Apply a member result onto `out`: KEEP restores the stored member, or removes it. */
7273
+ function applyMember(out, key, result, storedParent) {
7274
+ if (result.kind === "value") {
7275
+ out[key] = result.value;
7276
+ return;
7277
+ }
7278
+ if (Object.prototype.hasOwnProperty.call(storedParent, key)) out[key] = storedParent[key];
7279
+ else delete out[key];
7280
+ }
7281
+ async function writeMembers(ctx, children, incoming, stored, pathOf) {
7282
+ const out = { ...incoming };
7283
+ for (const [member, node] of children) applyMember(out, member, await writeNode(ctx, node, incoming[member], stored[member], pathOf(member)), stored);
7284
+ return out;
7285
+ }
7286
+ function rowId(row, idKey) {
7287
+ const raw = row[idKey];
7288
+ if (typeof raw === "string" && raw.length > 0) return raw;
7289
+ if (typeof raw === "number" && Number.isFinite(raw)) return String(raw);
7290
+ return null;
7291
+ }
7292
+ async function writeArray(ctx, node, incoming, stored, fieldPath) {
7293
+ const storedRows = Array.isArray(stored) ? stored.filter(isRecord$1) : [];
7294
+ if (!Array.isArray(incoming)) {
7295
+ ctx.deletes.push(...collectSecretMarkerRefs(storedRows));
7296
+ return {
7297
+ kind: "value",
7298
+ value: incoming
7299
+ };
7300
+ }
7301
+ const storedById = /* @__PURE__ */ new Map();
7302
+ for (const row of storedRows) {
7303
+ const id = rowId(row, node.idKey);
7304
+ if (id !== null) storedById.set(id, row);
7305
+ }
7306
+ const kept = /* @__PURE__ */ new Set();
7307
+ const rows = [];
7308
+ for (const row of incoming) {
7309
+ if (!isRecord$1(row)) {
7310
+ rows.push(row);
7311
+ continue;
7312
+ }
7313
+ const id = rowId(row, node.idKey) ?? ctx.mintId();
7314
+ kept.add(id);
7315
+ const withId = {
7316
+ ...row,
7317
+ [node.idKey]: row[node.idKey] ?? id
7318
+ };
7319
+ if (rowId(withId, node.idKey) === null) withId[node.idKey] = id;
7320
+ const storedRow = storedById.get(id) ?? {};
7321
+ rows.push(await writeMembers(ctx, node.item, withId, storedRow, (member) => arrayItemFieldPath(fieldPath, id, member)));
7322
+ }
7323
+ for (const [id, row] of storedById) if (!kept.has(id)) ctx.deletes.push(...collectSecretMarkerRefs(row));
7324
+ return {
7325
+ kind: "value",
7326
+ value: rows
7327
+ };
7328
+ }
7329
+ async function writeNode(ctx, node, incoming, stored, fieldPath) {
7330
+ switch (node.kind) {
7331
+ case "leaf": return writeLeaf(ctx, incoming, stored, fieldPath);
7332
+ case "array": return writeArray(ctx, node, incoming, stored, fieldPath);
7333
+ case "object": {
7334
+ if (!isRecord$1(incoming)) {
7335
+ if (incoming === void 0) return KEEP;
7336
+ ctx.deletes.push(...collectSecretMarkerRefs(stored));
7337
+ return {
7338
+ kind: "value",
7339
+ value: incoming
7340
+ };
7341
+ }
7342
+ const storedObj = isRecord$1(stored) ? stored : {};
7343
+ return {
7344
+ kind: "value",
7345
+ value: await writeMembers(ctx, node.children, incoming, storedObj, (m) => `${fieldPath}.${m}`)
7346
+ };
7347
+ }
7348
+ }
7349
+ }
7350
+ /** Split a perNode-scoped key (`key@nodeId`). */
7351
+ function splitNodeKey(key) {
7352
+ const at = key.indexOf("@");
7353
+ return at <= 0 ? {
7354
+ base: key,
7355
+ nodeId: null
7356
+ } : {
7357
+ base: key.slice(0, at),
7358
+ nodeId: key.slice(at + 1)
7359
+ };
7360
+ }
7361
+ /** Rewrite a settings patch so no secret value reaches the blob. See the file doc. */
7362
+ async function transformSecretWrite(input) {
7363
+ const deletes = [];
7364
+ const base = {
7365
+ secrets: input.secrets,
7366
+ mintId: input.mintId ?? defaultMintId,
7367
+ deletes,
7368
+ operatorWrite: input.operatorWrite === true
7369
+ };
7370
+ const out = {};
7371
+ for (const [key, incoming] of Object.entries(input.patch)) {
7372
+ const { base: baseKey, nodeId } = splitNodeKey(key);
7373
+ const node = input.tree.get(baseKey);
7374
+ if (node === void 0) {
7375
+ out[key] = incoming;
7376
+ continue;
7377
+ }
7378
+ const scope = nodeId !== null && nodeId.length > 0 ? {
7379
+ kind: "node",
7380
+ nodeId
7381
+ } : input.scope ?? globalSecretScope();
7382
+ const result = await writeNode({
7383
+ ...base,
7384
+ scope
7385
+ }, node, incoming, input.stored[key], baseKey);
7386
+ if (result.kind === "value") out[key] = result.value;
7387
+ }
7388
+ return {
7389
+ patch: out,
7390
+ afterWrite: async () => {
7391
+ if (deletes.length === 0) return { orphaned: [] };
7392
+ try {
7393
+ await input.secrets.delete([...new Set(deletes)]);
7394
+ return { orphaned: [] };
7395
+ } catch {
7396
+ return { orphaned: [...new Set(deletes)] };
7397
+ }
7398
+ }
7399
+ };
7400
+ }
7401
+ /** Is `ref` one of `owner`'s refs? */
7402
+ function isSecretRefOwnedBy(ref, owner) {
7403
+ return parseSecretRef(ref)?.owner === owner;
7404
+ }
7405
+ /**
7406
+ * Replace every marker in `value` with its keychain value. Returns the SAME
7407
+ * reference when there is no marker (no allocation, no keychain call).
7408
+ */
7409
+ async function resolveSecretMarkers(value, secrets, options = {}) {
7410
+ const keepMarker = options.unresolved === "keep-marker";
7411
+ const owner = options.ownedBy;
7412
+ const inScope = (ref) => owner === void 0 || isSecretRefOwnedBy(ref, owner);
7413
+ const refs = collectSecretMarkerRefs(value).filter(inScope);
7414
+ if (refs.length === 0) return {
7415
+ value,
7416
+ unresolved: []
7417
+ };
7418
+ const answers = await secrets.resolve(refs);
7419
+ const unresolved = [];
7420
+ for (const ref of new Set(refs)) {
7421
+ const answer = answers[ref];
7422
+ if (answer === void 0) unresolved.push({
7423
+ ref,
7424
+ reason: "not-initialized"
7425
+ });
7426
+ else if (answer.kind === "unavailable") unresolved.push({
7427
+ ref,
7428
+ reason: answer.reason
7429
+ });
7430
+ else if (answer.kind === "missing" || answer.kind === "forbidden") unresolved.push({
7431
+ ref,
7432
+ reason: answer.kind
7433
+ });
7434
+ }
7435
+ const substitute = (v) => {
7436
+ if (isSecretMarker(v)) {
7437
+ if (!inScope(v.$secret)) return {
7438
+ keep: true,
7439
+ value: v
7440
+ };
7441
+ const answer = answers[v.$secret];
7442
+ if (answer?.kind === "value") return {
7443
+ keep: true,
7444
+ value: answer.value
7445
+ };
7446
+ return keepMarker ? {
7447
+ keep: true,
7448
+ value: v
7449
+ } : {
7450
+ keep: false,
7451
+ value: void 0
7452
+ };
7453
+ }
7454
+ if (Array.isArray(v)) {
7455
+ const items = [];
7456
+ for (const item of v) {
7457
+ const s = substitute(item);
7458
+ if (s.keep) items.push(s.value);
7459
+ }
7460
+ return {
7461
+ keep: true,
7462
+ value: items
7463
+ };
7464
+ }
7465
+ if (isRecord$1(v)) {
7466
+ const out = {};
7467
+ for (const [k, child] of Object.entries(v)) {
7468
+ const s = substitute(child);
7469
+ if (s.keep) out[k] = s.value;
7470
+ }
7471
+ return {
7472
+ keep: true,
7473
+ value: out
7474
+ };
7475
+ }
7476
+ return {
7477
+ keep: true,
7478
+ value: v
7479
+ };
7480
+ };
7481
+ return {
7482
+ value: substitute(value).value,
7483
+ unresolved
7484
+ };
7485
+ }
7486
+ /** An addon tried to replace a stored secret it could not read. Nothing was written. */
7487
+ var SecretOverwriteRefusedError = class extends Error {
7488
+ ref;
7489
+ reason;
7490
+ constructor(ref, reason) {
7491
+ 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.`);
7492
+ this.ref = ref;
7493
+ this.reason = reason;
7494
+ this.name = "SecretOverwriteRefusedError";
7495
+ }
7496
+ };
7497
+ function isRecord(value) {
7498
+ return typeof value === "object" && value !== null && !Array.isArray(value);
7499
+ }
7500
+ function resolvedValue(pass, marker) {
7501
+ const answer = pass.answers[marker.$secret];
7502
+ return answer?.kind === "value" ? answer.value : null;
7503
+ }
7504
+ async function atMarker(pass, incoming, stored) {
7505
+ if (incoming === null) return stored;
7506
+ if (typeof incoming !== "string") return incoming;
7507
+ if (incoming === resolvedValue(pass, stored)) return stored;
7508
+ const intent = classifySecretWrite(incoming);
7509
+ if (intent.kind !== "set") return stored;
7510
+ const ref = stored.$secret;
7511
+ if (!isSecretRefOwnedBy(ref, pass.secrets.owner)) return incoming;
7512
+ const answer = pass.answers[ref];
7513
+ 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);
7514
+ try {
7515
+ await pass.secrets.put(ref, intent.value);
7516
+ } catch (err) {
7517
+ throw new KeychainWriteRefusedError(ref, err);
7518
+ }
7519
+ pass.changedRefs.push(ref);
7520
+ return stored;
7521
+ }
7522
+ function inArray(pass, incoming, stored) {
7523
+ return incoming.map((item, index) => {
7524
+ const twin = stored[index];
7525
+ if (isSecretMarker(twin)) return typeof item === "string" && item === resolvedValue(pass, twin) ? twin : item;
7526
+ if (isRecord(item) && isRecord(twin)) return inArrayRow(pass, item, twin);
7527
+ if (Array.isArray(item) && Array.isArray(twin)) return inArray(pass, item, twin);
7528
+ return item;
7529
+ });
7530
+ }
7531
+ function inArrayRow(pass, incoming, stored) {
7532
+ const out = { ...incoming };
7533
+ for (const [key, value] of Object.entries(incoming)) {
7534
+ const twin = stored[key];
7535
+ if (isSecretMarker(twin)) {
7536
+ if (typeof value === "string" && value === resolvedValue(pass, twin)) out[key] = twin;
7537
+ } else if (isRecord(value) && isRecord(twin)) out[key] = inArrayRow(pass, value, twin);
7538
+ else if (Array.isArray(value) && Array.isArray(twin)) out[key] = inArray(pass, value, twin);
7539
+ }
7540
+ return out;
7541
+ }
7542
+ async function walk(pass, incoming, stored) {
7543
+ if (isSecretMarker(stored)) return atMarker(pass, incoming, stored);
7544
+ if (Array.isArray(incoming) && Array.isArray(stored)) return inArray(pass, incoming, stored);
7545
+ if (!isRecord(incoming) || !isRecord(stored)) return incoming;
7546
+ const out = { ...incoming };
7547
+ for (const [key, value] of Object.entries(incoming)) out[key] = await walk(pass, value, stored[key]);
7548
+ return out;
7549
+ }
7550
+ /** Restore markers a write-back carries as values. See the file doc. */
7551
+ async function restoreUnchangedSecrets(input) {
7552
+ const refs = [];
7553
+ for (const key of Object.keys(input.patch)) collectSecretMarkerRefs(input.stored[key], refs);
7554
+ const owned = refs.filter((ref) => isSecretRefOwnedBy(ref, input.secrets.owner));
7555
+ if (owned.length === 0) return {
7556
+ patch: input.patch,
7557
+ changedRefs: []
7558
+ };
7559
+ const pass = {
7560
+ secrets: input.secrets,
7561
+ answers: await input.secrets.resolve([...new Set(owned)]),
7562
+ operatorWrite: input.operatorWrite,
7563
+ changedRefs: []
7564
+ };
7565
+ const out = {};
7566
+ for (const [key, value] of Object.entries(input.patch)) out[key] = await walk(pass, value, input.stored[key]);
7567
+ return {
7568
+ patch: out,
7569
+ changedRefs: pass.changedRefs
7570
+ };
7571
+ }
7572
+ /** Structural equality over JSON-shaped values (key order does not matter). */
7573
+ function isJsonEqual(a, b) {
7574
+ if (Object.is(a, b)) return true;
7575
+ if (Array.isArray(a)) return Array.isArray(b) && a.length === b.length && a.every((v, i) => isJsonEqual(v, b[i]));
7576
+ if (isRecord(a) && isRecord(b)) {
7577
+ const keys = Object.keys(a);
7578
+ if (keys.length !== Object.keys(b).length) return false;
7579
+ return keys.every((k) => Object.prototype.hasOwnProperty.call(b, k) && isJsonEqual(a[k], b[k]));
7580
+ }
7581
+ return false;
7582
+ }
7583
+ /** The patch without the keys whose value already equals the stored one. */
7584
+ function dropUnchangedKeys(patch, stored) {
7585
+ const out = {};
7586
+ for (const [key, value] of Object.entries(patch)) {
7587
+ if (Object.prototype.hasOwnProperty.call(stored, key) && isJsonEqual(value, stored[key])) continue;
7588
+ out[key] = value;
7589
+ }
7590
+ return out;
7591
+ }
7592
+ /** The top-level keys of a blob that hold at least one of `owner`'s markers. */
7593
+ function markerKeysOf(blob, owner) {
7594
+ const keys = /* @__PURE__ */ new Set();
7595
+ for (const [key, value] of Object.entries(blob)) if (collectSecretMarkerRefs(value).some((ref) => isSecretRefOwnedBy(ref, owner))) keys.add(key);
7596
+ return keys;
7597
+ }
7598
+ function nodeFromStored(value, owner) {
7599
+ if (isSecretMarker(value)) return isSecretRefOwnedBy(value.$secret, owner) ? { kind: "leaf" } : null;
7600
+ if (!isRecord(value)) return null;
7601
+ const children = /* @__PURE__ */ new Map();
7602
+ for (const [key, child] of Object.entries(value)) {
7603
+ const node = nodeFromStored(child, owner);
7604
+ if (node !== null) children.set(key, node);
7605
+ }
7606
+ return children.size > 0 ? {
7607
+ kind: "object",
7608
+ children
7609
+ } : null;
7610
+ }
7611
+ /**
7612
+ * The declared secret tree, widened by every place the STORED blob holds a
7613
+ * marker under one of `keys` — so a marker the schema no longer declares (or
7614
+ * never declared: Wyze before b4906cec6) still gets the save path's
7615
+ * KEEP / SET / CLEAR semantics instead of being overwritten by whatever the
7616
+ * addon writes. Markers inside arrays are not added: a row has no id field to
7617
+ * match by unless the schema declares one. Only `owner`'s markers count: a
7618
+ * builtin that keeps another addon's marker (device-manager) never takes it
7619
+ * over.
7620
+ */
7621
+ function widenTreeWithStoredMarkers(declared, stored, keys, owner) {
7622
+ const added = /* @__PURE__ */ new Map();
7623
+ for (const key of keys) {
7624
+ const at = key.indexOf("@");
7625
+ const base = at > 0 ? key.slice(0, at) : key;
7626
+ if (declared.has(base) || added.has(base)) continue;
7627
+ const node = nodeFromStored(stored[key], owner);
7628
+ if (node !== null) added.set(base, node);
7629
+ }
7630
+ return added.size === 0 ? declared : new Map([...declared, ...added]);
7631
+ }
7632
+ /** The blob as stored now; a failed read REFUSES the write instead of guessing. */
7633
+ async function readStoredAddonBlob(raw) {
7634
+ const threeWay = raw.readAddonStoreResult;
7635
+ if (threeWay === void 0) return raw.readAddonStore();
7636
+ const result = await threeWay.call(raw);
7637
+ if (result.kind === "failed") throw new Error(`settings write refused: the stored blob could not be read (${result.error})`);
7638
+ return result.kind === "missing" ? {} : result.value;
7639
+ }
7640
+ function touchesTree(tree, patch) {
7641
+ if (tree.size === 0) return false;
7642
+ for (const key of Object.keys(patch)) {
7643
+ const at = key.indexOf("@");
7644
+ if (tree.has(at > 0 ? key.slice(0, at) : key)) return true;
7645
+ }
7646
+ return false;
7647
+ }
7648
+ /**
7649
+ * Which top-level keys of each store held markers when last seen. `undefined`
7650
+ * for a store not seen yet: its first write reads it, to be safe.
7651
+ */
7652
+ var MarkerKeyIndex = class {
7653
+ owner;
7654
+ byStore = /* @__PURE__ */ new Map();
7655
+ constructor(owner) {
7656
+ this.owner = owner;
7657
+ }
7658
+ seen(store, blob) {
7659
+ this.byStore.set(store, markerKeysOf(blob, this.owner));
7660
+ }
7661
+ wrote(store, patch) {
7662
+ const keys = this.byStore.get(store);
7663
+ if (keys === void 0) return;
7664
+ const now = markerKeysOf(patch, this.owner);
7665
+ for (const key of Object.keys(patch)) if (now.has(key)) keys.add(key);
7666
+ else keys.delete(key);
7667
+ }
7668
+ mayHoldMarkers(store, patch) {
7669
+ const keys = this.byStore.get(store);
7670
+ if (keys === void 0) return true;
7671
+ return Object.keys(patch).some((key) => keys.has(key));
7672
+ }
7673
+ };
7674
+ function createHandle(raw, opts) {
7675
+ const chains = /* @__PURE__ */ new Map();
7676
+ const serialize = (key, fn) => {
7677
+ const next = (chains.get(key) ?? Promise.resolve()).then(fn, fn);
7678
+ const tail = next.catch(() => void 0);
7679
+ chains.set(key, tail);
7680
+ tail.then(() => {
7681
+ if (chains.get(key) === tail) chains.delete(key);
7682
+ });
7683
+ return next;
7684
+ };
7685
+ const index = new MarkerKeyIndex(opts.secrets.owner);
7686
+ const resolveRead = async (store, blob) => {
7687
+ index.seen(store, blob);
7688
+ const { value, unresolved } = await resolveSecretMarkers(blob, opts.secrets, {
7689
+ unresolved: "keep-marker",
7690
+ ownedBy: opts.secrets.owner
7691
+ });
7692
+ if (unresolved.length > 0) opts.onUnresolved?.(unresolved);
7693
+ return value;
7694
+ };
7695
+ const write = async (store, declared, scope, patch, readStored, rawWrite) => {
7696
+ if (!touchesTree(declared, patch) && !index.mayHoldMarkers(store, patch)) {
7697
+ await rawWrite(patch);
7698
+ index.wrote(store, patch);
7699
+ return { changed: true };
7700
+ }
7701
+ return serialize(store, async () => {
7702
+ const stored = await readStored();
7703
+ index.seen(store, stored);
7704
+ const operatorWrite = opts.isOperatorWrite?.() === true;
7705
+ const restored = await restoreUnchangedSecrets({
7706
+ patch,
7707
+ stored,
7708
+ secrets: opts.secrets,
7709
+ operatorWrite
7710
+ });
7711
+ const result = await transformSecretWrite({
7712
+ tree: widenTreeWithStoredMarkers(declared, stored, Object.keys(restored.patch), opts.secrets.owner),
7713
+ secrets: opts.secrets,
7714
+ patch: restored.patch,
7715
+ stored,
7716
+ ...scope !== void 0 ? { scope } : {},
7717
+ operatorWrite
7718
+ });
7719
+ const effective = dropUnchangedKeys(result.patch, stored);
7720
+ const wroteBlob = Object.keys(effective).length > 0;
7721
+ if (wroteBlob) {
7722
+ await rawWrite(effective);
7723
+ index.wrote(store, effective);
7724
+ }
7725
+ const { orphaned } = await result.afterWrite();
7726
+ if (orphaned.length > 0) opts.onOrphaned(orphaned);
7727
+ return { changed: wroteBlob || restored.changedRefs.length > 0 };
7728
+ });
7729
+ };
7730
+ const writeAddon = (patch) => write("addon", opts.addonTree(), void 0, patch, () => readStoredAddonBlob(raw), (p) => raw.writeAddonStore(p));
7731
+ const readAddonStoreResult = raw.readAddonStoreResult;
7732
+ const readAddonStoreKeyResult = raw.readAddonStoreKeyResult;
7733
+ const readDeviceStoreBatch = raw.readDeviceStoreBatch;
7734
+ const overrides = {
7735
+ readAddonStore: async () => resolveRead("addon", await raw.readAddonStore()),
7736
+ ...readAddonStoreResult !== void 0 ? { readAddonStoreResult: async () => {
7737
+ const result = await readAddonStoreResult.call(raw);
7738
+ return result.kind === "value" ? {
7739
+ kind: "value",
7740
+ value: await resolveRead("addon", result.value)
7741
+ } : result;
7742
+ } } : {},
7743
+ ...readAddonStoreKeyResult !== void 0 ? { readAddonStoreKeyResult: async (key) => {
7744
+ const result = await readAddonStoreKeyResult.call(raw, key);
7745
+ if (result.kind !== "present") return result;
7746
+ const { value, unresolved } = await resolveSecretMarkers({ [key]: result.value }, opts.secrets, {
7747
+ unresolved: "keep-marker",
7748
+ ownedBy: opts.secrets.owner
7749
+ });
7750
+ if (unresolved.length > 0) opts.onUnresolved?.(unresolved);
7751
+ return {
7752
+ kind: "present",
7753
+ value: value[key]
7754
+ };
7755
+ } } : {},
7756
+ readDeviceStore: async (deviceId) => resolveRead(`device:${deviceId}`, await raw.readDeviceStore(deviceId)),
7757
+ ...readDeviceStoreBatch !== void 0 ? { readDeviceStoreBatch: async (deviceIds) => {
7758
+ const rows = await readDeviceStoreBatch.call(raw, deviceIds);
7759
+ const out = /* @__PURE__ */ new Map();
7760
+ for (const [deviceId, blob] of rows) out.set(deviceId, await resolveRead(`device:${deviceId}`, blob));
7761
+ return out;
7762
+ } } : {},
7763
+ writeAddonStore: async (patch) => {
7764
+ await writeAddon(patch);
7765
+ },
7766
+ writeDeviceStore: async (deviceId, patch) => {
7767
+ await write(`device:${deviceId}`, opts.deviceTree(), {
7768
+ kind: "device",
7769
+ deviceId
7770
+ }, patch, () => raw.readDeviceStore(deviceId), (p) => raw.writeDeviceStore(deviceId, p));
7771
+ }
7772
+ };
7773
+ return {
7774
+ settings: new Proxy(raw, { get(target, prop, receiver) {
7775
+ if (typeof prop === "string" && Object.prototype.hasOwnProperty.call(overrides, prop)) return Reflect.get(overrides, prop);
7776
+ const value = Reflect.get(target, prop, receiver);
7777
+ return typeof value === "function" ? value.bind(target) : value;
7778
+ } }),
7779
+ raw: {
7780
+ readAddonStore: async () => {
7781
+ const blob = await raw.readAddonStore();
7782
+ index.seen("addon", blob);
7783
+ return blob;
7784
+ },
7785
+ readDeviceStore: async (deviceId) => {
7786
+ const blob = await raw.readDeviceStore(deviceId);
7787
+ index.seen(`device:${deviceId}`, blob);
7788
+ return blob;
7789
+ }
7790
+ },
7791
+ writeAddonStore: writeAddon
7792
+ };
7793
+ }
7794
+ /** The context the addon sees, plus the private raw view and write outcome. */
7795
+ function createSecretAwareContext(context, opts) {
7796
+ const raw = context.settings;
7797
+ if (raw === void 0) return {
7798
+ context,
7799
+ handle: null
7800
+ };
7801
+ const handle = createHandle(raw, opts);
7802
+ return {
7803
+ context: new Proxy(context, { get(target, prop, receiver) {
7804
+ if (prop === "settings") return handle.settings;
7805
+ return Reflect.get(target, prop, receiver);
7806
+ } }),
7807
+ handle
7808
+ };
7809
+ }
7810
+ var LEAF = { kind: "leaf" };
7811
+ var DEFAULT_ITEM_ID_KEY = "id";
7812
+ function collectFields(fields, out) {
7813
+ for (const field of fields) {
7814
+ if (field.type === "group") {
7815
+ collectFields(field.fields, out);
7816
+ continue;
7817
+ }
7818
+ if (field.type === "sub-tabs") {
7819
+ for (const tab of field.tabs) collectFields(tab.fields, out);
7820
+ continue;
7821
+ }
7822
+ if (field.type === "editable-array") {
7823
+ const item = /* @__PURE__ */ new Map();
7824
+ for (const itemField of field.itemFields) if ("key" in itemField && isKeychainStoredField(itemField)) item.set(itemField.key, LEAF);
7825
+ if (item.size > 0) out.set(field.key, {
7826
+ kind: "array",
7827
+ idKey: field.itemIdKey ?? DEFAULT_ITEM_ID_KEY,
7828
+ item
7829
+ });
7830
+ continue;
7831
+ }
7832
+ if (!("key" in field) || typeof field.key !== "string") continue;
7833
+ if (isKeychainStoredField(field)) out.set(field.key, LEAF);
7834
+ }
7835
+ }
7836
+ /** The secret tree a settings schema declares. */
7837
+ function secretTreeFromSchema(schema) {
7838
+ const out = /* @__PURE__ */ new Map();
7839
+ if (schema === null) return out;
7840
+ for (const section of schema.sections) collectFields(section.fields, out);
7841
+ return out;
7842
+ }
7843
+ /** Parse `a.b[id].c` into segments; throws on a malformed path (a declaration bug). */
7844
+ function parseSecretStatePath(path) {
7845
+ const segments = [];
7846
+ for (const raw of path.split(".")) {
7847
+ const m = /^([^[\]]+)(?:\[([^[\]]+)\])?$/.exec(raw);
7848
+ if (m === null || m[1] === void 0) throw new Error(`secretStatePaths: malformed path "${path}"`);
7849
+ segments.push(m[2] !== void 0 ? {
7850
+ key: m[1],
7851
+ idKey: m[2]
7852
+ } : { key: m[1] });
7853
+ }
7854
+ if (segments.length === 0) throw new Error(`secretStatePaths: empty path`);
7855
+ if (segments[segments.length - 1]?.idKey !== void 0) throw new Error(`secretStatePaths: "${path}" ends on an array — name the member that is secret`);
7856
+ return segments;
7857
+ }
7858
+ function insert(into, segments) {
7859
+ const [head, ...rest] = segments;
7860
+ if (head === void 0) return;
7861
+ if (rest.length === 0) {
7862
+ into.set(head.key, LEAF);
7863
+ return;
7864
+ }
7865
+ const existing = into.get(head.key);
7866
+ if (head.idKey !== void 0) {
7867
+ const item = new Map(existing?.kind === "array" ? existing.item : []);
7868
+ insert(item, rest);
7869
+ into.set(head.key, {
7870
+ kind: "array",
7871
+ idKey: head.idKey,
7872
+ item
7873
+ });
7874
+ return;
7875
+ }
7876
+ const children = new Map(existing?.kind === "object" ? existing.children : []);
7877
+ insert(children, rest);
7878
+ into.set(head.key, {
7879
+ kind: "object",
7880
+ children
7881
+ });
7882
+ }
7883
+ /** Add hidden-state paths (`secretStatePaths`) to a schema-derived tree. */
7884
+ function mergeSecretStatePaths(tree, paths) {
7885
+ if (paths.length === 0) return tree;
7886
+ const out = new Map(tree);
7887
+ for (const path of paths) insert(out, parseSecretStatePath(path));
7888
+ return out;
7889
+ }
7890
+ /** First retry of a secret the keychain could not serve; doubles to {@link SECRET_RETRY_MAX_MS}. */
7891
+ var SECRET_RETRY_FIRST_MS = 5e3;
7892
+ var SECRET_RETRY_MAX_MS = 5 * 6e4;
7893
+ /** Coalesces a burst of `keychain.changed` events into one re-resolve. */
7894
+ var SECRET_CHANGE_DEBOUNCE_MS = 250;
7012
7895
  /**
7013
7896
  * Base class for CamStack addons. Eliminates settings boilerplate:
7014
7897
  *
@@ -7078,6 +7961,33 @@ var BaseAddon = class {
7078
7961
  settingsStoreReady = false;
7079
7962
  /** Default config values. Provided via constructor. */
7080
7963
  defaults;
7964
+ /**
7965
+ * Hidden-state paths that hold secrets (D787) — values the addon writes
7966
+ * itself (`updateGlobalSettings`, `state()`) that no form field declares.
7967
+ * Stored in the keychain exactly like a `password` field. Syntax:
7968
+ * `'snapshotSigningKey'`, `'identity.pincode'`, `'tokens[userId].accessToken'`
7969
+ * (`key[<id field>]` addresses array items by id, never by index).
7970
+ */
7971
+ secretStatePaths = [];
7972
+ _addonSecretTree = null;
7973
+ _deviceSecretTree = null;
7974
+ /** Refs the last resolved config pointed at — a change to one re-resolves. */
7975
+ _configSecretRefs = /* @__PURE__ */ new Set();
7976
+ _unresolvedSecrets = [];
7977
+ _secretRetryTimer = null;
7978
+ _secretRetryDelayMs = SECRET_RETRY_FIRST_MS;
7979
+ _secretChangeTimer = null;
7980
+ _secretChangeUnsub = null;
7981
+ /** >0 while an OPERATOR's settings write is being applied. */
7982
+ _operatorWriteDepth = 0;
7983
+ /**
7984
+ * The keychain-aware settings handle (D798). Its `raw` view is the ONLY way
7985
+ * to the marker-bearing blobs and stays private to this class: the form
7986
+ * hydrate and config resolution need markers, addon code never does.
7987
+ */
7988
+ _secretSettings = null;
7989
+ /** Refs an addon-facing read could not resolve — each is logged once per process. */
7990
+ _loggedUnresolvedReads = /* @__PURE__ */ new Set();
7081
7991
  constructor(defaults) {
7082
7992
  this.defaults = defaults;
7083
7993
  this._config = { ...defaults };
@@ -7113,8 +8023,26 @@ var BaseAddon = class {
7113
8023
  return this._config;
7114
8024
  }
7115
8025
  async initialize(context) {
7116
- this._ctx = context;
8026
+ const secrets = context.secrets;
8027
+ if (secrets !== void 0) {
8028
+ const { context: wrapped, handle } = createSecretAwareContext(context, {
8029
+ secrets,
8030
+ addonTree: () => this.addonSecretTree(),
8031
+ deviceTree: () => this.deviceSecretTree(),
8032
+ onOrphaned: (refs) => context.logger.warn("keychain refs dropped by a settings write could not be deleted", { meta: { refs: [...refs] } }),
8033
+ isOperatorWrite: () => this._operatorWriteDepth > 0,
8034
+ onUnresolved: (unresolved) => this.logUnresolvedRead(unresolved)
8035
+ });
8036
+ this._ctx = wrapped;
8037
+ this._secretSettings = handle;
8038
+ } else {
8039
+ this._ctx = context;
8040
+ this._secretSettings = null;
8041
+ }
7117
8042
  await this.resolveConfig();
8043
+ if (secrets !== void 0) this._secretChangeUnsub = secrets.onChange((ref) => {
8044
+ if (this._configSecretRefs.has(ref)) this.scheduleSecretReresolve(SECRET_CHANGE_DEBOUNCE_MS);
8045
+ });
7118
8046
  const result = await this.onInitialize();
7119
8047
  this.emitLifecycle(EventCategory.AddonStarted);
7120
8048
  const normalized = normalizeAddonInitResult(result);
@@ -7147,6 +8075,12 @@ var BaseAddon = class {
7147
8075
  */
7148
8076
  async onHubReachable() {}
7149
8077
  async shutdown() {
8078
+ this._secretChangeUnsub?.();
8079
+ this._secretChangeUnsub = null;
8080
+ if (this._secretRetryTimer !== null) clearTimeout(this._secretRetryTimer);
8081
+ if (this._secretChangeTimer !== null) clearTimeout(this._secretChangeTimer);
8082
+ this._secretRetryTimer = null;
8083
+ this._secretChangeTimer = null;
7150
8084
  this.emitLifecycle(EventCategory.AddonStopped);
7151
8085
  if (this.autoEmitReadiness) this.emitReadinessForProviders("down");
7152
8086
  await this.onShutdown();
@@ -7221,11 +8155,8 @@ var BaseAddon = class {
7221
8155
  async getGlobalSettings(overlay, cap, nodeId) {
7222
8156
  const schema = this.globalSettingsSchema(cap);
7223
8157
  if (!schema) return { sections: [] };
7224
- const projected = await this.resolveGlobalStore(nodeId, cap);
7225
- return hydrateSchema(schema, overlay ? {
7226
- ...projected,
7227
- ...overlay
7228
- } : projected);
8158
+ const projected = await this.readRawProjectedStore(nodeId, cap);
8159
+ return hydrateSchema(schema, overlay ? await this.overlayKeepingMarkers(projected, overlay) : projected, { inlineSecretsAsViews: true });
7229
8160
  }
7230
8161
  /**
7231
8162
  * The integration-level view of this addon's settings: exactly the sections
@@ -7270,11 +8201,11 @@ var BaseAddon = class {
7270
8201
  });
7271
8202
  }
7272
8203
  if (sections.length === 0) return null;
7273
- const projected = await this.resolveGlobalStore(nodeId);
8204
+ const projected = await this.readRawProjectedStore(nodeId);
7274
8205
  return hydrateSchema({
7275
8206
  ...schema,
7276
8207
  sections
7277
- }, projected);
8208
+ }, projected, { inlineSecretsAsViews: true });
7278
8209
  }
7279
8210
  /**
7280
8211
  * The raw addon store PROJECTED onto the target node's bare per-node keys:
@@ -7287,12 +8218,50 @@ var BaseAddon = class {
7287
8218
  * the store for custom option logic (option narrowing, value snapping) to
7288
8219
  * read it per-node — never `ctx.settings.readAddonStore()` directly.
7289
8220
  * `nodeId` omitted ⇒ the local node (node-blind injection from ctx).
8221
+ *
8222
+ * Keychain values come back RESOLVED (D798): a secret reads as its value,
8223
+ * never as a `{ $secret }` marker. One the keychain cannot serve right now
8224
+ * stays a marker — "stored, unavailable" (`isSecretMarker()` is true, and it
8225
+ * is listed in {@link unresolvedSecrets}) — never `''` and never absent, so
8226
+ * it cannot be mistaken for "nothing stored, mint a new one". Writing the
8227
+ * resolved blob back is a no-op for every unchanged secret.
7290
8228
  */
7291
8229
  async resolveGlobalStore(nodeId, cap) {
7292
8230
  const raw = await this._ctx?.settings?.readAddonStore() ?? {};
8231
+ return this.projectForNode(raw, nodeId, cap);
8232
+ }
8233
+ projectForNode(store, nodeId, cap) {
7293
8234
  const keys = this.perNodeKeys(cap);
7294
8235
  const node = normalizeNodeId(nodeId ?? this._ctx?.kernel?.localNodeId);
7295
- return keys.size > 0 ? projectStore(raw, keys, node) : raw;
8236
+ return keys.size > 0 ? projectStore(store, keys, node) : store;
8237
+ }
8238
+ /** The PROJECTED store with its markers — the form hydrate only (D798). */
8239
+ async readRawProjectedStore(nodeId, cap) {
8240
+ const raw = await this.rawSettings()?.readAddonStore() ?? {};
8241
+ return this.projectForNode(raw, nodeId, cap);
8242
+ }
8243
+ /**
8244
+ * `{ ...stored, ...overlay }`, except that an overlay member equal to the
8245
+ * RESOLVED stored one keeps the stored (marker-bearing) member — so a form
8246
+ * hydrated from a resolved overlay still shows a secret as "set", never as
8247
+ * its value.
8248
+ */
8249
+ async overlayKeepingMarkers(stored, overlay) {
8250
+ const secrets = this._ctx?.secrets;
8251
+ const merged = {
8252
+ ...stored,
8253
+ ...overlay
8254
+ };
8255
+ if (secrets === void 0 || collectSecretMarkerRefs(stored).length === 0) return merged;
8256
+ const { value: resolved } = await resolveSecretMarkers(stored, secrets, {
8257
+ unresolved: "keep-marker",
8258
+ ownedBy: secrets.owner
8259
+ });
8260
+ for (const key of Object.keys(overlay)) {
8261
+ if (collectSecretMarkerRefs(stored[key]).length === 0) continue;
8262
+ if (isJsonEqual(overlay[key], resolved[key])) merged[key] = stored[key];
8263
+ }
8264
+ return merged;
7296
8265
  }
7297
8266
  /**
7298
8267
  * Whether ONE global key of this addon's store was written, read three-way
@@ -7328,18 +8297,58 @@ var BaseAddon = class {
7328
8297
  value: result.value[key]
7329
8298
  };
7330
8299
  }
8300
+ /**
8301
+ * The OPERATOR's write — a settings form or an admin API call, dispatched by
8302
+ * the kernel. Identical to {@link updateGlobalSettings}, except that a secret
8303
+ * the operator sends is stored as sent even when it equals a pre-keychain
8304
+ * inline value: the operator re-entering a password is a change, an addon
8305
+ * writing back what it read is not (D787).
8306
+ */
8307
+ async updateGlobalSettingsAsOperator(patch, nodeId) {
8308
+ this._operatorWriteDepth++;
8309
+ try {
8310
+ await this.applyGlobalPatch(patch, nodeId);
8311
+ } finally {
8312
+ this._operatorWriteDepth--;
8313
+ }
8314
+ }
7331
8315
  async updateGlobalSettings(patch, nodeId) {
8316
+ await this.applyGlobalPatch(patch, nodeId);
8317
+ }
8318
+ /**
8319
+ * REMOVE stored secrets — their keychain values and their markers (D787).
8320
+ *
8321
+ * Writing `''` to a secret field KEEPS what is stored (an empty string is
8322
+ * what a defaults fallback writes back, and it must never destroy a
8323
+ * credential), so code that means "forget this token" says so here. Without
8324
+ * a keychain (an older kernel) it writes `''`, as such code always did.
8325
+ */
8326
+ async clearSecrets(keys, nodeId) {
8327
+ const tree = this.addonSecretTree();
8328
+ const keychain = this._ctx?.secrets !== void 0;
8329
+ const stored = keychain ? await this.readAddonStoreWithRetry() : {};
8330
+ const patch = {};
8331
+ for (const key of keys) {
8332
+ const keychainStored = tree.has(key) || collectSecretMarkerRefs(stored[key]).length > 0;
8333
+ patch[key] = keychain && keychainStored ? SECRET_CLEAR : "";
8334
+ }
8335
+ await this.applyGlobalPatch(patch, nodeId);
8336
+ }
8337
+ async applyGlobalPatch(barePatch, nodeId) {
7332
8338
  const keys = this.perNodeKeys();
7333
8339
  const localNode = normalizeNodeId(this._ctx?.kernel?.localNodeId);
7334
8340
  const target = normalizeNodeId(nodeId ?? this._ctx?.kernel?.localNodeId);
7335
- const barePatch = patch;
7336
8341
  const scoped = keys.size > 0 ? scopePatch(barePatch, keys, target) : barePatch;
7337
- await this._ctx?.settings?.writeAddonStore(scoped);
8342
+ const handle = this._secretSettings;
8343
+ if (handle !== null) {
8344
+ const { changed } = await handle.writeAddonStore(scoped);
8345
+ if (!changed) return;
8346
+ } else await this._ctx?.settings?.writeAddonStore(scoped);
7338
8347
  if (target !== localNode) return;
7339
8348
  await this.resolveConfig();
7340
8349
  await this.onConfigChanged();
7341
8350
  this.emitLifecycle(EventCategory.AddonUpdated, { level: "global" });
7342
- this.maybeAutoRestart(patch, this.globalSettingsSchema());
8351
+ this.maybeAutoRestart(Object.keys(barePatch), this.globalSettingsSchema());
7343
8352
  }
7344
8353
  /**
7345
8354
  * The set of field keys the global settings schema declares `perNode: true`
@@ -7364,7 +8373,7 @@ var BaseAddon = class {
7364
8373
  * time to return its response before the addon is torn down and
7365
8374
  * re-initialised by `AddonRegistryService.restartAddon`.
7366
8375
  */
7367
- maybeAutoRestart(patch, schema) {
8376
+ maybeAutoRestart(patchKeys, schema) {
7368
8377
  if (!schema) return;
7369
8378
  const restartKeys = /* @__PURE__ */ new Set();
7370
8379
  for (const section of schema.sections) for (const field of section.fields) {
@@ -7372,13 +8381,13 @@ var BaseAddon = class {
7372
8381
  if (field.requiresRestart) restartKeys.add(field.key);
7373
8382
  }
7374
8383
  if (restartKeys.size === 0) return;
7375
- if (!Object.keys(patch).some((k) => restartKeys.has(k))) return;
8384
+ if (!patchKeys.some((k) => restartKeys.has(k))) return;
7376
8385
  const ctx = this._ctx;
7377
8386
  if (!ctx) return;
7378
8387
  const addonId = ctx.id;
7379
8388
  setImmediate(() => {
7380
8389
  ctx.api.addons?.restartAddon?.mutate({ addonId }).then(() => {
7381
- ctx.logger.info("addon auto-restart triggered by restart-required setting change", { meta: { changedFields: Object.keys(patch).filter((k) => restartKeys.has(k)) } });
8390
+ ctx.logger.info("addon auto-restart triggered by restart-required setting change", { meta: { changedFields: patchKeys.filter((k) => restartKeys.has(k)) } });
7382
8391
  }).catch((err) => {
7383
8392
  ctx.logger.error("addon auto-restart failed", { meta: { error: err instanceof Error ? err.message : String(err) } });
7384
8393
  });
@@ -7387,7 +8396,7 @@ var BaseAddon = class {
7387
8396
  async getDeviceSettings(deviceId) {
7388
8397
  const schema = this.deviceSettingsSchema();
7389
8398
  if (!schema) return { sections: [] };
7390
- return hydrateSchema(schema, await this._ctx?.settings?.readDeviceStore(deviceId) ?? {});
8399
+ return hydrateSchema(schema, await this.rawSettings()?.readDeviceStore(deviceId) ?? {}, { inlineSecretsAsViews: true });
7391
8400
  }
7392
8401
  async updateDeviceSettings(deviceId, patch) {
7393
8402
  await this._ctx?.settings?.writeDeviceStore(deviceId, patch);
@@ -7517,7 +8526,7 @@ var BaseAddon = class {
7517
8526
  * selection at boot (absent scoped key ⇒ the constructor default wins).
7518
8527
  */
7519
8528
  async resolveConfig() {
7520
- const stored = await this.readAddonStoreWithRetry();
8529
+ const stored = await this.resolveStoredSecrets(await this.readAddonStoreWithRetry());
7521
8530
  const perNode = this.perNodeKeys();
7522
8531
  const localNode = normalizeNodeId(this._ctx?.kernel?.localNodeId);
7523
8532
  const resolved = { ...this.defaults };
@@ -7542,7 +8551,7 @@ var BaseAddon = class {
7542
8551
  key,
7543
8552
  schema,
7544
8553
  fallback,
7545
- read: () => this.readAddonStoreWithRetry(),
8554
+ read: async () => this.resolveStoredSecrets(await this.readAddonStoreWithRetry()),
7546
8555
  write: async (patch) => {
7547
8556
  await this._ctx?.settings?.writeAddonStore(patch);
7548
8557
  },
@@ -7559,7 +8568,7 @@ var BaseAddon = class {
7559
8568
  key,
7560
8569
  schema,
7561
8570
  fallback,
7562
- read: async () => await this._ctx?.settings?.readDeviceStore(deviceId) ?? {},
8571
+ read: async () => this.resolveStoredSecrets(await this.rawSettings()?.readDeviceStore(deviceId) ?? {}, false),
7563
8572
  write: async (patch) => {
7564
8573
  await this._ctx?.settings?.writeDeviceStore(deviceId, patch);
7565
8574
  },
@@ -7571,6 +8580,87 @@ var BaseAddon = class {
7571
8580
  } })
7572
8581
  });
7573
8582
  }
8583
+ /** The addon store's secret tree: schema fields by TYPE, plus `secretStatePaths`. */
8584
+ addonSecretTree() {
8585
+ this._addonSecretTree ??= mergeSecretStatePaths(secretTreeFromSchema(this.globalSettingsSchema()), this.secretStatePaths);
8586
+ return this._addonSecretTree;
8587
+ }
8588
+ deviceSecretTree() {
8589
+ this._deviceSecretTree ??= secretTreeFromSchema(this.deviceSettingsSchema());
8590
+ return this._deviceSecretTree;
8591
+ }
8592
+ /**
8593
+ * Secrets of this addon's stored config that could not be resolved on the
8594
+ * last read, with why. Non-empty means the addon is running WITHOUT them —
8595
+ * an addon whose function needs one should report itself degraded rather
8596
+ * than start on an empty credential.
8597
+ */
8598
+ get unresolvedSecrets() {
8599
+ return this._unresolvedSecrets;
8600
+ }
8601
+ /**
8602
+ * Substitute every keychain marker in a stored blob with its value. With no
8603
+ * keychain (no `ctx.secrets`) or no marker, the blob comes back unchanged.
8604
+ * An unresolvable value is LEFT OUT (never `''`), logged by ref — never by
8605
+ * value — and, when the cause can pass, retried with backoff. Nothing is
8606
+ * ever written back from here.
8607
+ */
8608
+ async resolveStoredSecrets(blob, trackForConfig = true) {
8609
+ const secrets = this._ctx?.secrets;
8610
+ if (secrets === void 0) return blob;
8611
+ const refs = collectSecretMarkerRefs(blob);
8612
+ if (trackForConfig) this._configSecretRefs = new Set(refs);
8613
+ if (refs.length === 0) {
8614
+ if (trackForConfig) this._unresolvedSecrets = [];
8615
+ return blob;
8616
+ }
8617
+ const { value, unresolved } = await resolveSecretMarkers(blob, secrets);
8618
+ if (trackForConfig) {
8619
+ this._unresolvedSecrets = unresolved;
8620
+ if (unresolved.length > 0) {
8621
+ this._ctx?.logger?.error?.("secret unavailable — running without it, will retry", { meta: { secrets: unresolved.map((u) => ({
8622
+ ref: u.ref,
8623
+ reason: u.reason
8624
+ })) } });
8625
+ if (unresolved.some((u) => u.reason !== "missing" && u.reason !== "forbidden")) {
8626
+ this.scheduleSecretReresolve(this._secretRetryDelayMs);
8627
+ this._secretRetryDelayMs = Math.min(this._secretRetryDelayMs * 2, SECRET_RETRY_MAX_MS);
8628
+ }
8629
+ } else this._secretRetryDelayMs = SECRET_RETRY_FIRST_MS;
8630
+ }
8631
+ return value;
8632
+ }
8633
+ /**
8634
+ * The marker-bearing settings reads (D798) — private on purpose. Without a
8635
+ * keychain the context's own view is already raw.
8636
+ */
8637
+ rawSettings() {
8638
+ return this._secretSettings?.raw ?? this._ctx?.settings;
8639
+ }
8640
+ /** An addon-facing read met markers it could not resolve: say so once per ref. */
8641
+ logUnresolvedRead(unresolved) {
8642
+ const fresh = unresolved.filter((u) => !this._loggedUnresolvedReads.has(u.ref));
8643
+ if (fresh.length === 0) return;
8644
+ for (const u of fresh) this._loggedUnresolvedReads.add(u.ref);
8645
+ 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) => ({
8646
+ ref: u.ref,
8647
+ reason: u.reason
8648
+ })) } });
8649
+ }
8650
+ /** Re-resolve the config (a keychain-only change, or a retry) and apply it. */
8651
+ scheduleSecretReresolve(delayMs) {
8652
+ const timerOf = delayMs === SECRET_CHANGE_DEBOUNCE_MS ? "_secretChangeTimer" : "_secretRetryTimer";
8653
+ if (this[timerOf] !== null) return;
8654
+ const timer = setTimeout(() => {
8655
+ this[timerOf] = null;
8656
+ if (this._ctx === null) return;
8657
+ this.resolveConfig().then(() => this.onConfigChanged()).catch((err) => {
8658
+ this._ctx?.logger?.error?.("re-resolving secrets failed", { meta: { error: err instanceof Error ? err.message : String(err) } });
8659
+ });
8660
+ }, delayMs);
8661
+ timer.unref?.();
8662
+ this[timerOf] = timer;
8663
+ }
7574
8664
  /**
7575
8665
  * Wrap `ctx.settings.readAddonStore()` with a short retry budget so a
7576
8666
  * transient settings-store outage (mid-restart of sqlite-settings, tsx-watch
@@ -7583,7 +8673,7 @@ var BaseAddon = class {
7583
8673
  * `{}` (defaults) — the addon's first successful patch will rehydrate.
7584
8674
  */
7585
8675
  async readAddonStoreWithRetry() {
7586
- const settings = this._ctx?.settings;
8676
+ const settings = this.rawSettings();
7587
8677
  if (!settings) return {};
7588
8678
  const delaysMs = [
7589
8679
  150,
@@ -8146,6 +9236,69 @@ method(object({ deviceId: number() }), array(StreamSourceEntrySchema)), method(o
8146
9236
  kind: "mutation",
8147
9237
  auth: "admin"
8148
9238
  }), method(object({ deviceId: number() }), unknown().nullable()), method(object({ deviceId: number() }), RawStateResultSchema.nullable(), { auth: "protected" });
9239
+ function defOf(schema) {
9240
+ return schema._zod?.def ?? {};
9241
+ }
9242
+ function declaredHere(schema) {
9243
+ return globalRegistry.get(schema)?.secret === true;
9244
+ }
9245
+ /** Wrapper kinds whose `innerType` is the field itself. */
9246
+ var WRAPPERS = new Set([
9247
+ "optional",
9248
+ "nullable",
9249
+ "default",
9250
+ "prefault",
9251
+ "catch",
9252
+ "readonly",
9253
+ "nonoptional"
9254
+ ]);
9255
+ /**
9256
+ * The schema layers that make up ONE field: the schema itself and every
9257
+ * wrapper below it (optional / default / nullable / readonly / catch), plus
9258
+ * both sides of a pipe (`z.preprocess` puts the real schema on `out`,
9259
+ * `.transform` on `in`).
9260
+ */
9261
+ function layersOf(schema) {
9262
+ const out = [];
9263
+ const queue = [schema];
9264
+ while (queue.length > 0) {
9265
+ const s = queue.shift();
9266
+ if (!s || out.includes(s)) continue;
9267
+ out.push(s);
9268
+ const def = defOf(s);
9269
+ if (def.type !== void 0 && WRAPPERS.has(def.type) && def.innerType) queue.push(def.innerType);
9270
+ if (def.type === "pipe") {
9271
+ if (def.in) queue.push(def.in);
9272
+ if (def.out) queue.push(def.out);
9273
+ }
9274
+ }
9275
+ return out;
9276
+ }
9277
+ /** True when any layer of this field declares `.meta({ secret: true })`. */
9278
+ function isZodSecret(schema) {
9279
+ return layersOf(schema).some(declaredHere);
9280
+ }
9281
+ /**
9282
+ * Every declared secret path in a config schema: dotted keys, `[]` for "each
9283
+ * element of this array" (`connection.password`, `rows[].token`). A declared
9284
+ * object or array is reported as one path and not descended into — everything
9285
+ * under it is secret.
9286
+ */
9287
+ function collectZodSecretPaths(schema, prefix = "") {
9288
+ if (isZodSecret(schema)) return prefix.length > 0 ? [prefix] : [];
9289
+ const paths = [];
9290
+ for (const layer of layersOf(schema)) {
9291
+ const def = defOf(layer);
9292
+ if (def.type === "object" && def.shape) for (const [key, child] of Object.entries(def.shape)) paths.push(...collectZodSecretPaths(child, prefix ? `${prefix}.${key}` : key));
9293
+ else if (def.type === "array" && def.element) paths.push(...collectZodSecretPaths(def.element, `${prefix}[]`));
9294
+ else if (def.type === "union" && def.options) for (const option of def.options) paths.push(...collectZodSecretPaths(option, prefix));
9295
+ else if (def.type === "intersection") {
9296
+ if (def.left) paths.push(...collectZodSecretPaths(def.left, prefix));
9297
+ if (def.right) paths.push(...collectZodSecretPaths(def.right, prefix));
9298
+ }
9299
+ }
9300
+ return [...new Set(paths)];
9301
+ }
8149
9302
  //#endregion
8150
9303
  //#region ../types/dist/err-msg-DX6i_MY4.mjs
8151
9304
  var DeviceType = /* @__PURE__ */ function(DeviceType) {
@@ -9823,6 +10976,278 @@ var CameraSwitchGroupSchema = object({
9823
10976
  fetchedAt: number()
9824
10977
  });
9825
10978
  /**
10979
+ * The trainer contract — what the hub hands the cloud trainer and what it
10980
+ * gets back (cloud training, D805+).
10981
+ *
10982
+ * The trainer (`hf/camstack-trainer`, published as the Hugging Face repo
10983
+ * `camstack/camstack-trainer`) is a separate AGPL program the hub never
10984
+ * imports: `job.json` goes in, files come out, and progress is `CAMSTACK_EVENT`
10985
+ * lines on stdout. These schemas are the hub's half of that boundary; the
10986
+ * trainer's pydantic models (and the JSON Schemas generated from them under
10987
+ * `hf/camstack-trainer/schemas/`) are the other half. A change here is a
10988
+ * change there, in the same piece of work.
10989
+ *
10990
+ * No `.default()` anywhere: defaults do not run on the addon cap path, so the
10991
+ * orchestrator fills every field of a job spec explicitly.
10992
+ */
10993
+ var TRAINING_JOB_SCHEMA = "camstack.training/v1";
10994
+ var TRAINING_RESULT_SCHEMA = "camstack.training-result/v1";
10995
+ /** What the trainer can export. Edge TPU is a later, separate image. */
10996
+ var TrainingExportSchema = _enum([
10997
+ "onnx",
10998
+ "openvino-fp16",
10999
+ "openvino-int8",
11000
+ "coreml-fp16"
11001
+ ]);
11002
+ var FloorsSchema = record(string(), number().min(0).max(1));
11003
+ object({
11004
+ schema: literal(TRAINING_JOB_SCHEMA),
11005
+ jobKey: string().uuid(),
11006
+ target: object({
11007
+ kind: literal("detector"),
11008
+ step: literal("object-detection")
11009
+ }),
11010
+ base: object({
11011
+ modelId: string().min(1),
11012
+ /** Ultralytics weights id, e.g. `yolov9m.pt`. */
11013
+ weights: string().min(1),
11014
+ imgsz: number().int().positive()
11015
+ }),
11016
+ baseline: object({
11017
+ modelId: string().min(1),
11018
+ /** The baseline ONNX the holdout comparison runs; public mirror URL. */
11019
+ onnxUrl: string().url(),
11020
+ imgsz: number().int().positive(),
11021
+ floors: FloorsSchema
11022
+ }),
11023
+ dataset: object({
11024
+ versionId: string().min(1),
11025
+ annotationHash: string(),
11026
+ /** sha256 of the uploaded archive; the trainer refuses a mismatch (exit 65). */
11027
+ sha256: string().regex(/^[0-9a-f]{64}$/)
11028
+ }),
11029
+ split: object({
11030
+ holdoutCameras: array(number().int()),
11031
+ /** When no camera is held out: the last N days of every camera. */
11032
+ holdoutLastDays: number().int().nonnegative(),
11033
+ valFraction: number().min(0).max(.5),
11034
+ seed: number().int()
11035
+ }),
11036
+ hyper: object({
11037
+ epochs: number().int().positive(),
11038
+ batch: number().int().positive(),
11039
+ lr0: number().positive(),
11040
+ /** Layers frozen from the start of the backbone; 0 = none. */
11041
+ freeze: number().int().nonnegative(),
11042
+ patience: number().int().nonnegative(),
11043
+ seed: number().int()
11044
+ }),
11045
+ replay: object({
11046
+ source: literal("coco2017"),
11047
+ count: number().int().nonnegative()
11048
+ }),
11049
+ exports: array(TrainingExportSchema).min(1),
11050
+ calibration: object({ maxFrames: number().int().positive() }),
11051
+ floors: object({
11052
+ minSupport: number().int().positive(),
11053
+ clamp: number().min(0).max(1)
11054
+ }),
11055
+ int8Gate: object({ maxMap50Drop: number().min(0).max(1) }),
11056
+ catalog: object({
11057
+ id: string().regex(/^[a-z0-9][a-z0-9-]{2,80}$/),
11058
+ name: string().min(1).max(160)
11059
+ })
11060
+ });
11061
+ /** One regular file of the bundle. An mlpackage contributes one row per member. */
11062
+ var TrainingResultFileSchema = object({
11063
+ path: string().min(1),
11064
+ bytes: number().int().nonnegative(),
11065
+ sha256: string().regex(/^[0-9a-f]{64}$/),
11066
+ format: _enum([
11067
+ "onnx",
11068
+ "openvino",
11069
+ "coreml",
11070
+ "pt"
11071
+ ]),
11072
+ variant: _enum(["base", "int8"])
11073
+ });
11074
+ var DraftFormatSchema = object({
11075
+ /** RELATIVE path inside the bundle; the hub rewrites it to `camstack-local://`. */
11076
+ url: string().min(1),
11077
+ sizeMB: number().nonnegative(),
11078
+ isDirectory: boolean().optional(),
11079
+ files: array(string()).optional(),
11080
+ runtimes: array(literal("python")).optional(),
11081
+ revision: string().min(1)
11082
+ });
11083
+ /** The trainer's half of a catalog entry; the hub completes it (labels, licence, group). */
11084
+ var TrainingCatalogDraftSchema = object({
11085
+ id: string().min(1),
11086
+ name: string().min(1),
11087
+ description: string(),
11088
+ labels: array(unknown()),
11089
+ inputSize: object({
11090
+ width: number().int().positive(),
11091
+ height: number().int().positive()
11092
+ }),
11093
+ preprocessMode: literal("letterbox"),
11094
+ defaultClassFloors: FloorsSchema,
11095
+ formats: object({
11096
+ onnx: DraftFormatSchema.optional(),
11097
+ openvino: DraftFormatSchema.optional(),
11098
+ coreml: DraftFormatSchema.optional()
11099
+ })
11100
+ });
11101
+ /** One class of one model's holdout report (the eval harness's summary). */
11102
+ var TrainingEvalClassSchema = object({
11103
+ positives: number().int(),
11104
+ floor: number().nullable(),
11105
+ tp: number().int(),
11106
+ fp: number().int(),
11107
+ fn: number().int(),
11108
+ precision: number().nullable(),
11109
+ recall: number().nullable(),
11110
+ ap50: number().nullable(),
11111
+ recallByCamera: record(string(), number().nullable()).optional(),
11112
+ recallByLight: record(string(), number().nullable()).optional(),
11113
+ fpByCamera: record(string(), number()).optional(),
11114
+ smallFound: number().int().optional(),
11115
+ smallTotal: number().int().optional()
11116
+ }).passthrough();
11117
+ var TrainingEvalReportSchema = object({
11118
+ frames: number().int(),
11119
+ classes: record(string(), TrainingEvalClassSchema)
11120
+ }).passthrough();
11121
+ /**
11122
+ * A succeeded result carries every block; a failed one carries the error and
11123
+ * whatever was known by then — the other blocks are ABSENT, not null. The
11124
+ * orchestrator checks the blocks it needs before it trusts a success.
11125
+ */
11126
+ var TrainingResultSchema = object({
11127
+ schema: literal(TRAINING_RESULT_SCHEMA),
11128
+ jobKey: string(),
11129
+ status: _enum(["succeeded", "failed"]),
11130
+ error: object({
11131
+ stage: string(),
11132
+ code: string(),
11133
+ message: string()
11134
+ }).nullable(),
11135
+ trainer: object({
11136
+ version: string(),
11137
+ revision: string()
11138
+ }),
11139
+ toolchain: record(string(), string().nullable()),
11140
+ dataset: object({
11141
+ versionId: string(),
11142
+ annotationHash: string(),
11143
+ sha256: string(),
11144
+ frames: object({
11145
+ train: number().int(),
11146
+ val: number().int(),
11147
+ holdout: number().int()
11148
+ }),
11149
+ holdoutCameras: array(number().int()),
11150
+ replayImages: number().int()
11151
+ }).optional(),
11152
+ training: object({
11153
+ epochsRun: number().int(),
11154
+ bestEpoch: number().int(),
11155
+ bestMap50: number(),
11156
+ bestMap50_95: number(),
11157
+ seconds: number()
11158
+ }).optional(),
11159
+ evaluation: object({
11160
+ holdoutFrames: number().int(),
11161
+ baseline: TrainingEvalReportSchema.nullable(),
11162
+ candidate: TrainingEvalReportSchema.nullable(),
11163
+ candidateInt8: TrainingEvalReportSchema.nullable(),
11164
+ recallDeltaByCamera: record(string(), record(string(), number())).nullable(),
11165
+ map50: record(string(), number().nullable())
11166
+ }).optional(),
11167
+ floors: object({
11168
+ baseline: FloorsSchema,
11169
+ candidate: FloorsSchema,
11170
+ candidateInt8: FloorsSchema.nullable(),
11171
+ notes: array(string())
11172
+ }).optional(),
11173
+ int8: object({
11174
+ kept: boolean(),
11175
+ map50Fp16: number().nullable(),
11176
+ map50Int8: number().nullable(),
11177
+ reason: string().nullable()
11178
+ }).optional(),
11179
+ exportsDropped: array(object({
11180
+ export: string(),
11181
+ reason: string()
11182
+ })).optional(),
11183
+ files: array(TrainingResultFileSchema).optional(),
11184
+ bundle: object({
11185
+ path: literal("bundle.tar"),
11186
+ bytes: number().int().nonnegative(),
11187
+ sha256: string().regex(/^[0-9a-f]{64}$/)
11188
+ }).nullable().optional(),
11189
+ catalogDraft: object({
11190
+ base: TrainingCatalogDraftSchema,
11191
+ int8: TrainingCatalogDraftSchema.nullable()
11192
+ }).nullable().optional(),
11193
+ licence: string()
11194
+ });
11195
+ var TrainingStageSchema = _enum([
11196
+ "prepare",
11197
+ "replay",
11198
+ "train",
11199
+ "eval",
11200
+ "export",
11201
+ "package"
11202
+ ]);
11203
+ var EventBase = {
11204
+ v: literal(1),
11205
+ ts: number()
11206
+ };
11207
+ discriminatedUnion("type", [
11208
+ object({
11209
+ ...EventBase,
11210
+ type: literal("stage"),
11211
+ stage: TrainingStageSchema
11212
+ }),
11213
+ object({
11214
+ ...EventBase,
11215
+ type: literal("epoch"),
11216
+ epoch: number().int(),
11217
+ epochs: number().int(),
11218
+ boxLoss: number().nullable().optional(),
11219
+ map50: number().nullable().optional(),
11220
+ map50_95: number().nullable().optional(),
11221
+ etaSec: number().nullable().optional()
11222
+ }),
11223
+ object({
11224
+ ...EventBase,
11225
+ type: literal("metric"),
11226
+ name: string(),
11227
+ value: number()
11228
+ }),
11229
+ object({
11230
+ ...EventBase,
11231
+ type: literal("artifact"),
11232
+ path: string(),
11233
+ bytes: number(),
11234
+ sha256: string()
11235
+ }),
11236
+ object({
11237
+ ...EventBase,
11238
+ type: literal("done"),
11239
+ status: _enum(["succeeded", "failed"]),
11240
+ resultSha256: string().nullable().optional()
11241
+ }),
11242
+ object({
11243
+ ...EventBase,
11244
+ type: literal("error"),
11245
+ stage: string(),
11246
+ code: string(),
11247
+ message: string()
11248
+ })
11249
+ ]);
11250
+ /**
9826
11251
  * What the gate decided about a birth, from the CALLER's point of view.
9827
11252
  *
9828
11253
  * Deliberately not `ConfirmationVerdict`: `undecided` is not a birth decision
@@ -12150,7 +13575,9 @@ var AddonHttpRouteSchema = object({
12150
13575
  "authenticated",
12151
13576
  "admin"
12152
13577
  ]).optional(),
12153
- description: string().optional()
13578
+ description: string().optional(),
13579
+ /** The hub limits this route per client address before the handler runs. */
13580
+ rateLimit: _enum(["auth"]).optional()
12154
13581
  });
12155
13582
  /**
12156
13583
  * Cross-process route invocation envelope. The hub captures the
@@ -12855,6 +14282,37 @@ var BackupDestinationInfoSchema = object({
12855
14282
  lastError: string().optional()
12856
14283
  });
12857
14284
  /**
14285
+ * How an archive is encrypted (operator decision 2026-10-09): to a backup
14286
+ * PUBLIC key the hub holds, so only the operator's secret key opens it.
14287
+ * Absent on a plain `.tar.gz` — every archive made before encryption, or
14288
+ * with it off — which restores without a key.
14289
+ */
14290
+ var BackupArchiveEncryptionSchema = object({
14291
+ /** `x25519-hkdf-aes256gcm-stream-v1`. */
14292
+ scheme: string(),
14293
+ /** 16 hex — the backup key whose secret restores this archive. */
14294
+ keyId: string()
14295
+ });
14296
+ /**
14297
+ * The backup encryption setting. The hub keeps PUBLIC keys only: the active
14298
+ * one new archives are encrypted to, and the retired ones older archives
14299
+ * still need. The secret key is shown once, at `setupEncryption`.
14300
+ */
14301
+ var BackupEncryptionStatusSchema = object({
14302
+ enabled: boolean(),
14303
+ active: object({
14304
+ keyId: string(),
14305
+ publicKey: string(),
14306
+ createdAt: number()
14307
+ }).nullable(),
14308
+ /** Every key ever set up, newest first. */
14309
+ keys: array(object({
14310
+ keyId: string(),
14311
+ createdAt: number(),
14312
+ retiredAt: number().nullable()
14313
+ })).readonly()
14314
+ });
14315
+ /**
12858
14316
  * Per-archive entry returned by `backup.listArchives({ destinationId })`.
12859
14317
  * Same shape the destination drill-in renders. Sourced from the per-
12860
14318
  * location `manifests.json` (no per-archive tarball read required).
@@ -12866,7 +14324,9 @@ var BackupArchiveEntrySchema = object({
12866
14324
  sizeBytes: number(),
12867
14325
  label: string().optional(),
12868
14326
  /** Top-level locations included in the archive (db, addons, tls, …). */
12869
- locations: array(string()).readonly()
14327
+ locations: array(string()).readonly(),
14328
+ /** Present when the archive is encrypted; restore then needs that key. */
14329
+ encryption: BackupArchiveEncryptionSchema.optional()
12870
14330
  });
12871
14331
  var BackupEntrySchema = object({
12872
14332
  id: string(),
@@ -12875,7 +14335,8 @@ var BackupEntrySchema = object({
12875
14335
  label: string().optional(),
12876
14336
  createdAt: number(),
12877
14337
  sizeBytes: number(),
12878
- locations: array(string()).optional()
14338
+ locations: array(string()).optional(),
14339
+ encryption: BackupArchiveEncryptionSchema.optional()
12879
14340
  });
12880
14341
  var ArchiveEntrySchema = object({
12881
14342
  path: string(),
@@ -13064,10 +14525,40 @@ method(_void(), array(BackupDestinationInfoSchema).readonly(), { auth: "admin" }
13064
14525
  * this list and skips entries whose path doesn't start with
13065
14526
  * any of them.
13066
14527
  */
13067
- locations: array(string()).optional()
14528
+ locations: array(string()).optional(),
14529
+ /**
14530
+ * The backup SECRET key, for an encrypted archive (ignored for a plain
14531
+ * one). The archive is decrypted into the hub's private staging
14532
+ * before the restart; the key is not stored. A wrong or missing key
14533
+ * is refused before the archive is downloaded.
14534
+ */
14535
+ backupSecretKey: string().optional()
13068
14536
  }), _void(), {
13069
14537
  kind: "mutation",
13070
14538
  auth: "admin"
14539
+ }), method(_void(), BackupEncryptionStatusSchema, { auth: "admin" }), method(object({}), object({
14540
+ keyId: string(),
14541
+ secretKey: string(),
14542
+ publicKey: string(),
14543
+ createdAt: number(),
14544
+ replacedKeyId: string().nullable()
14545
+ }), {
14546
+ kind: "mutation",
14547
+ auth: "admin"
14548
+ }), method(object({}), object({ disabledKeyId: string().nullable() }), {
14549
+ kind: "mutation",
14550
+ auth: "admin"
14551
+ }), method(object({ backupSecretKey: string() }), object({
14552
+ valid: boolean(),
14553
+ keyId: string().nullable(),
14554
+ /** The hub knows this key (active or retired). */
14555
+ known: boolean(),
14556
+ /** It is the key new archives are encrypted to. */
14557
+ active: boolean(),
14558
+ error: string().optional()
14559
+ }), {
14560
+ kind: "mutation",
14561
+ auth: "admin"
13071
14562
  }), method(object({
13072
14563
  destinationId: string(),
13073
14564
  backupId: string()
@@ -14793,7 +16284,60 @@ var CustomModelDescriptorSchema = object({
14793
16284
  stepId: string(),
14794
16285
  entry: ModelCatalogEntrySchema
14795
16286
  });
14796
- method(_void(), array(CustomModelDescriptorSchema).readonly(), { auth: "admin" });
16287
+ /** One regular file of an imported bundle, as the producer measured it. */
16288
+ var ModelBundleFileSchema = object({
16289
+ /** Relative path inside the bundle tar; an mlpackage member is `<x>.mlpackage/<member>`. */
16290
+ path: string().min(1),
16291
+ bytes: number().int().nonnegative(),
16292
+ sha256: string().regex(/^[0-9a-f]{64}$/)
16293
+ });
16294
+ var ImportModelBundleInputSchema = object({
16295
+ /** The registry provider that keeps the model (Model Studio). */
16296
+ addonId: string(),
16297
+ stepId: string().min(1),
16298
+ /**
16299
+ * The catalog rows to register, complete, every format URL already
16300
+ * `camstack-local://<modelId>/<file>` naming a file of the bundle. One
16301
+ * bundle may carry several rows (a base and its INT8 variant).
16302
+ */
16303
+ entries: array(ModelCatalogEntrySchema).min(1).max(4),
16304
+ /** The bundle tar, offered by the producer over `ctx.peerBytes` (same host). */
16305
+ bundle: object({
16306
+ ticket: PeerBytesTicketSchema,
16307
+ bytes: number().int().positive(),
16308
+ sha256: string().regex(/^[0-9a-f]{64}$/)
16309
+ }),
16310
+ /** Every file the tar must hold; anything missing, extra or different is refused. */
16311
+ files: array(ModelBundleFileSchema).min(1).max(64),
16312
+ /** Convert missing engine formats and push the model to every agent afterwards. */
16313
+ distribute: boolean()
16314
+ });
16315
+ var ImportModelBundleResultSchema = discriminatedUnion("kind", [object({
16316
+ kind: literal("imported"),
16317
+ modelIds: array(string()).readonly(),
16318
+ distributed: array(object({
16319
+ modelId: string(),
16320
+ nodeId: string(),
16321
+ format: _enum(MODEL_FORMATS),
16322
+ ok: boolean(),
16323
+ error: string().optional()
16324
+ })).readonly()
16325
+ }), object({
16326
+ kind: literal("refused"),
16327
+ reason: _enum([
16328
+ "transfer-failed",
16329
+ "checksum-mismatch",
16330
+ "bundle-mismatch",
16331
+ "invalid-entry",
16332
+ "id-taken"
16333
+ ]),
16334
+ detail: string()
16335
+ })]);
16336
+ method(_void(), array(CustomModelDescriptorSchema).readonly(), { auth: "admin" }), method(ImportModelBundleInputSchema, ImportModelBundleResultSchema, {
16337
+ kind: "mutation",
16338
+ auth: "admin",
16339
+ timeoutMs: 30 * 6e4
16340
+ });
14797
16341
  /**
14798
16342
  * Query filter for settings-store collections.
14799
16343
  */
@@ -15176,6 +16720,253 @@ id: union([string(), number()]) }), {
15176
16720
  kind: "mutation",
15177
16721
  auth: "admin"
15178
16722
  });
16723
+ /**
16724
+ * `keychain` — the hub's encrypted store of secret values (D787).
16725
+ *
16726
+ * Settings blobs never hold a secret: they hold a marker
16727
+ * `{"$secret":"secret://<owner>/<scope>/<fieldPath>","v":1}` and the value
16728
+ * lives here, AES-256-GCM under a data key that a master key wraps. This cap
16729
+ * is the OWNER's door to its own values: every method is owner-checked
16730
+ * against the CALLER, never against anything the caller claims.
16731
+ *
16732
+ * Who the caller is: the transport stamps `callerAddonId` into the args of a
16733
+ * call that crossed a process (the parent `LocalChildRegistry` from the UDS
16734
+ * connection, the agent from its child's connection carried in
16735
+ * `$hub-cap-fwd`'s envelope). A stamp always overwrites; a wire call with no
16736
+ * stamp has its claim stripped. Only a hub in-process caller may state its own
16737
+ * identity — `ctx.secrets` does that with the addon id closed over. This is
16738
+ * identity against BUGS and misrouting, not against a malicious addon (every
16739
+ * runner is the same OS user): see the threat model in
16740
+ * `docs/design/2026-10-08-secrets-keychain.md`.
16741
+ *
16742
+ * `callerAddonId` is deliberately NOT in any input schema: the tRPC router
16743
+ * parses the input, so a session can never supply it, and the internal mount
16744
+ * floors every method to admin anyway (D240).
16745
+ *
16746
+ * Internal: addons reach it through `ctx.secrets`, never directly.
16747
+ */
16748
+ /** Why a value cannot be served right now. Never folded into "missing". */
16749
+ var KeychainUnavailableReasonSchema = _enum([
16750
+ "key-missing",
16751
+ "wrong-key",
16752
+ "key-file-unreadable",
16753
+ "store-unavailable",
16754
+ "not-initialized",
16755
+ "decrypt-failed"
16756
+ ]);
16757
+ var KeychainStateSchema = discriminatedUnion("state", [object({ state: literal("ready") }), object({
16758
+ state: literal("locked"),
16759
+ reason: KeychainUnavailableReasonSchema
16760
+ })]);
16761
+ var KeychainResolveEntrySchema = discriminatedUnion("kind", [
16762
+ object({
16763
+ kind: literal("value"),
16764
+ value: string(),
16765
+ version: number().int()
16766
+ }),
16767
+ object({ kind: literal("missing") }),
16768
+ object({
16769
+ kind: literal("unavailable"),
16770
+ reason: KeychainUnavailableReasonSchema
16771
+ }),
16772
+ object({ kind: literal("forbidden") })
16773
+ ]);
16774
+ var KeychainResolveResultSchema = record(string(), KeychainResolveEntrySchema);
16775
+ /** Metadata of one stored value — never the value. */
16776
+ var KeychainSecretMetaSchema = object({
16777
+ ref: string(),
16778
+ owner: string(),
16779
+ /** Formatted scope (`global`, `node/<id>`, `device/<id>`, …). */
16780
+ scope: string(),
16781
+ fieldPath: string(),
16782
+ version: number().int(),
16783
+ createdAt: number(),
16784
+ updatedAt: number(),
16785
+ /** `addon:<id>` | `user:<id>` | `system`. */
16786
+ updatedBy: string(),
16787
+ /** Coarse — written at most once an hour per ref. `null` = never read. */
16788
+ lastReadAt: number().nullable()
16789
+ });
16790
+ var RefListSchema = array(string().min(1)).max(512);
16791
+ method(object({
16792
+ ref: string().min(1),
16793
+ value: string().min(1)
16794
+ }), object({
16795
+ ref: string(),
16796
+ version: number().int()
16797
+ }), {
16798
+ kind: "mutation",
16799
+ auth: "admin"
16800
+ }), method(object({ refs: RefListSchema }), KeychainResolveResultSchema, { auth: "admin" }), method(object({ refs: RefListSchema }), object({ deleted: number().int() }), {
16801
+ kind: "mutation",
16802
+ auth: "admin"
16803
+ }), method(object({}), array(KeychainSecretMetaSchema).readonly(), { auth: "admin" }), method(object({}), KeychainStateSchema, { auth: "admin" });
16804
+ var KeychainKeySourceSchema = object({
16805
+ kind: _enum([
16806
+ "config-file",
16807
+ "previous-config-file",
16808
+ "platform",
16809
+ "default-file"
16810
+ ]),
16811
+ /** File sources only — a path is not a secret. */
16812
+ path: string().optional(),
16813
+ /**
16814
+ * True when a whole-volume backup of the data directory carries this key
16815
+ * next to the database it protects (the default file). The page warns.
16816
+ */
16817
+ sharesBackupWithDatabase: boolean()
16818
+ });
16819
+ /**
16820
+ * One keychain reset, as the Secrets page reports it until the operator
16821
+ * acknowledges it. Never a value: refs, counts and table names only.
16822
+ */
16823
+ var KeychainResetRecordSchema = object({
16824
+ id: string(),
16825
+ at: number(),
16826
+ /** `user:<id>` or {@link KEYCHAIN_RESET_TRIGGER_ACTOR}. */
16827
+ actor: string(),
16828
+ /** Why the keychain was locked when it was reset; `null` when it was not locked. */
16829
+ lockedReason: string().nullable(),
16830
+ /** Values moved into the archive table (ciphertext under the lost key). */
16831
+ archived: number().int(),
16832
+ /** `keychain:secrets-orphaned-<ts>`, or `null` when nothing was stored. */
16833
+ archivedCollection: string().nullable(),
16834
+ /**
16835
+ * `keychain:keys-orphaned-<ts>`: the wrapped data keys of the archive, kept
16836
+ * so the archive can still be opened if the lost master key turns up.
16837
+ */
16838
+ archivedKeysCollection: string().nullable(),
16839
+ /**
16840
+ * `system-settings` keys whose marker the reset cleared — the cluster
16841
+ * secret's: a marker left pointing at an archived value would refuse every
16842
+ * agent forever (D797).
16843
+ */
16844
+ clearedSettingsKeys: array(string()).readonly(),
16845
+ /** When an operator dismissed the notice on the Secrets page; `null` until then. */
16846
+ acknowledgedAt: number().nullable()
16847
+ });
16848
+ var KeychainStatusSchema = object({
16849
+ keychain: KeychainStateSchema,
16850
+ /** The source of the master key in use; `null` while locked. */
16851
+ keySource: KeychainKeySourceSchema.nullable(),
16852
+ /** The source configured to be primary — differs from `keySource` while a rotation is pending. */
16853
+ configuredSource: KeychainKeySourceSchema,
16854
+ /** Short fingerprint of the master key in use (`HMAC(KEK, label)`, 16 hex). */
16855
+ fingerprint: string().nullable(),
16856
+ activeKeyId: string().nullable(),
16857
+ /**
16858
+ * The keychain unlocked with a NON-primary source: the configured primary
16859
+ * key is not the one that wraps the data key yet. `rotateMasterKey` moves it.
16860
+ */
16861
+ rotationPending: boolean(),
16862
+ /** Wrapped copies of the data key under a previous master key, kept until purged. */
16863
+ retiredWraps: number().int(),
16864
+ recoveryKeyDownloadedAt: number().nullable(),
16865
+ secretCount: number().int(),
16866
+ /** The most recent reset, acknowledged or not; `null` when the keychain was never reset. */
16867
+ lastReset: KeychainResetRecordSchema.nullable()
16868
+ });
16869
+ /**
16870
+ * Whether a stored value is still pointed at by its owner's settings.
16871
+ * `unknown` is a first-class answer: a scope whose blob could not be read is
16872
+ * never reported as an orphan (and never deleted as one).
16873
+ */
16874
+ var KeychainSecretUsageSchema = _enum([
16875
+ "in-use",
16876
+ "orphan",
16877
+ "unknown"
16878
+ ]);
16879
+ var KeychainAdminSecretSchema = KeychainSecretMetaSchema.extend({ usage: KeychainSecretUsageSchema });
16880
+ var KeychainAuditActionSchema = _enum([
16881
+ "put",
16882
+ "delete",
16883
+ "reveal",
16884
+ "rotate-master-key",
16885
+ "purge-retired-keys",
16886
+ "download-recovery-key",
16887
+ "delete-orphans",
16888
+ "reset",
16889
+ "acknowledge-reset",
16890
+ "initialize"
16891
+ ]);
16892
+ var KeychainAuditEntrySchema = object({
16893
+ id: string(),
16894
+ at: number(),
16895
+ action: KeychainAuditActionSchema,
16896
+ /** `addon:<id>` | `user:<id>` | `system` | `trigger-file`. */
16897
+ actor: string(),
16898
+ ref: string().nullable(),
16899
+ detail: string().nullable()
16900
+ });
16901
+ var KEYCHAIN_RESET_CONFIRMATION = "RESET KEYCHAIN";
16902
+ /**
16903
+ * Secrets the HUB itself holds (owner `system`) that no settings form shows:
16904
+ * `jwt-signing-key` — the session signing key (D797). It is always "in use",
16905
+ * never an orphan; it is generated on a fresh hub and replaced only through
16906
+ * {@link keychainAdminCapability.methods.setSystemSecret}.
16907
+ */
16908
+ var SystemHeldSecretNameSchema = _enum(["jwt-signing-key"]);
16909
+ 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({
16910
+ value: string(),
16911
+ version: number().int()
16912
+ }), {
16913
+ kind: "mutation",
16914
+ auth: "admin",
16915
+ caller: "required"
16916
+ }), method(object({
16917
+ name: SystemHeldSecretNameSchema,
16918
+ value: string().min(16)
16919
+ }), object({
16920
+ ref: string(),
16921
+ version: number().int()
16922
+ }), {
16923
+ kind: "mutation",
16924
+ auth: "admin",
16925
+ caller: "required"
16926
+ }), method(object({ refs: array(string().min(1)).max(1e3) }), object({
16927
+ deleted: array(string()).readonly(),
16928
+ kept: array(object({
16929
+ ref: string(),
16930
+ usage: KeychainSecretUsageSchema
16931
+ })).readonly()
16932
+ }), {
16933
+ kind: "mutation",
16934
+ auth: "admin",
16935
+ caller: "required"
16936
+ }), method(object({}), object({
16937
+ fingerprint: string(),
16938
+ keySource: KeychainKeySourceSchema
16939
+ }), {
16940
+ kind: "mutation",
16941
+ auth: "admin",
16942
+ caller: "required"
16943
+ }), method(object({}), object({ purged: number().int() }), {
16944
+ kind: "mutation",
16945
+ auth: "admin",
16946
+ caller: "required"
16947
+ }), method(object({}), object({
16948
+ key: string(),
16949
+ fingerprint: string(),
16950
+ keySource: KeychainKeySourceSchema
16951
+ }), {
16952
+ kind: "mutation",
16953
+ auth: "admin",
16954
+ caller: "required"
16955
+ }), method(object({ confirm: literal(KEYCHAIN_RESET_CONFIRMATION) }), object({
16956
+ archivedCollection: string().nullable(),
16957
+ archived: number().int()
16958
+ }), {
16959
+ kind: "mutation",
16960
+ auth: "admin",
16961
+ caller: "required"
16962
+ }), method(object({}), object({
16963
+ reset: KeychainResetRecordSchema.nullable(),
16964
+ pendingReentry: array(KeychainSecretMetaSchema).readonly()
16965
+ }), { auth: "admin" }), method(object({}), object({ acknowledged: boolean() }), {
16966
+ kind: "mutation",
16967
+ auth: "admin",
16968
+ caller: "required"
16969
+ });
15179
16970
  method(_void(), object({
15180
16971
  id: string(),
15181
16972
  name: string(),
@@ -16418,7 +18209,11 @@ var DeviceRegisterPayloadSchema = object({
16418
18209
  var DeviceRemovePayloadSchema = object({ deviceId: number() });
16419
18210
  var DevicePersistConfigPayloadSchema = object({
16420
18211
  deviceId: number(),
16421
- data: record(string(), unknown())
18212
+ data: record(string(), unknown()),
18213
+ /** The paths the device's schema declares secret (D783), when the caller
18214
+ * knows them — those values are kept in the keychain, not the blob (D787).
18215
+ * Absent: the paths the device last reported at `registerDevice` apply. */
18216
+ secretConfigPaths: array(string()).optional()
16422
18217
  });
16423
18218
  /** What a migration actually did, per switch. `unreachable` is a first-class
16424
18219
  * answer: a camera that could not be asked is not a camera that was silenced. */
@@ -18021,7 +19816,7 @@ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
18021
19816
  * `login-method` — collection cap through which auth addons contribute
18022
19817
  * their pre-auth login surfaces to the login page. This is the SINGLE,
18023
19818
  * generic mechanism that supersedes the dead `auth.listProviders` reader:
18024
- * every auth addon (OIDC, magic-link, WebAuthn/passkey) registers a
19819
+ * every auth addon (OIDC, WebAuthn/passkey) registers a
18025
19820
  * `login-method` provider and the PUBLIC `auth.listLoginMethods`
18026
19821
  * procedure aggregates them for the unauthenticated login page.
18027
19822
  *
@@ -18029,8 +19824,7 @@ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
18029
19824
  *
18030
19825
  * - `redirect` — a declarative button. The login page renders a generic
18031
19826
  * button that navigates to `startUrl` (an addon-owned HTTP route).
18032
- * Covers OIDC (`/addon/auth-oidc/<id>/start`) and magic-link with
18033
- * ZERO shell-side JS. A future SSO addon plugs in the same way — the
19827
+ * Covers OIDC (`/addon/auth-oidc/<id>/start`) with ZERO shell-side JS. A future SSO addon plugs in the same way — the
18034
19828
  * login page needs NO change.
18035
19829
  *
18036
19830
  * - `widget` — a Module-Federation widget the login page mounts (via
@@ -18049,8 +19843,8 @@ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
18049
19843
  * decision.
18050
19844
  *
18051
19845
  * Every contribution carries a `stage`:
18052
- * - `primary` — shown on the first credentials screen (OIDC /
18053
- * magic-link buttons; a future usernameless passkey).
19846
+ * - `primary` — shown on the first credentials screen (OIDC
19847
+ * buttons; a usernameless passkey).
18054
19848
  * - `second-factor` — shown AFTER the password leg, gated on the
18055
19849
  * returned `factors` (passkey-as-2FA today).
18056
19850
  *
@@ -18077,7 +19871,7 @@ var LoginMethodContributionSchema = discriminatedUnion("kind", [
18077
19871
  * The provider names an external identity a signed-in user can link to
18078
19872
  * their own account (D782): `auth.listLinkableProviders` /
18079
19873
  * `beginExternalLink` offer exactly the redirect methods that set this,
18080
- * whatever their id. Absent / false — a login button only (magic-link).
19874
+ * whatever their id. Absent / false — a login button only.
18081
19875
  */
18082
19876
  linkable: boolean().optional()
18083
19877
  }),
@@ -21932,8 +23726,7 @@ method(object({}), object({ rules: array(NcRuleSchema) }), { auth: "admin" }), m
21932
23726
  * `super_admin` — collapsed onto the single boolean because every
21933
23727
  * non-admin caller is governed by the same scope-check rules; the
21934
23728
  * distinction was only ever used to route role-specific procedures
21935
- * which we no longer have. Agents are admin sessions issued via
21936
- * `createServiceToken`; CLI / webhook integrations are `cst_*` tokens
23729
+ * which we no longer have. CLI / webhook integrations are `cst_*` tokens
21937
23730
  * with `isAdmin: false` + an explicit scope list.
21938
23731
  */
21939
23732
  /** Per-method access flavour. Materialised on every cap method via codegen. */
@@ -23435,8 +25228,23 @@ var RetrainMacroClassSchema = _enum([
23435
25228
  ]);
23436
25229
  /** A subject to learn, or a phantom to unlearn (taught by OMISSION). */
23437
25230
  var RetrainAnnotationKindSchema = _enum(["subject", "model_error"]);
23438
- /** Did a human draw this box, or did the assist propose it? */
23439
- var RetrainAnnotationSourceSchema = _enum(["operator", "assist"]);
25231
+ /**
25232
+ * Where a box came from. A machine-sourced box is a DRAFT on the page until
25233
+ * the operator confirms it; once saved it keeps its source as provenance.
25234
+ *
25235
+ * - `operator` — drawn by hand.
25236
+ * - `assist` — proposed by a detector run on the copy (the camera's own
25237
+ * model, or a larger teacher model).
25238
+ * - `pipeline` — the box the live pipeline actually drew on that frame, read
25239
+ * back from the track store (never a re-run).
25240
+ * - `llm` — proposed by a vision-capable LLM profile.
25241
+ */
25242
+ var RetrainAnnotationSourceSchema = _enum([
25243
+ "operator",
25244
+ "assist",
25245
+ "pipeline",
25246
+ "llm"
25247
+ ]);
23440
25248
  /** Normalised `[0,1]` rectangle against the FULL frame — the canonical form. */
23441
25249
  var RetrainBboxSchema = object({
23442
25250
  x: number(),
@@ -23454,7 +25262,8 @@ var RetrainBboxSchema = object({
23454
25262
  */
23455
25263
  var RetrainAnnotationSchema = object({
23456
25264
  id: string(),
23457
- trackId: string(),
25265
+ /** The frame's track. Absent on a recording still, which has none. */
25266
+ trackId: string().optional(),
23458
25267
  deviceId: number(),
23459
25268
  /** The COPY in retrain storage — never the source track's media key. */
23460
25269
  mediaKey: string(),
@@ -23503,13 +25312,47 @@ var RetrainFrameCandidateSchema = object({
23503
25312
  * fail, whatever became of the original. */
23504
25313
  copied: boolean()
23505
25314
  });
25315
+ /**
25316
+ * One box the live pipeline drew on a copied frame — what a correction starts
25317
+ * from. Derived when the frame is listed, from the track store: the subject
25318
+ * box recorded on the source media row when there is one, else the track
25319
+ * position nearest the frame's capture time. Never stored as an annotation
25320
+ * until the operator confirms it.
25321
+ */
25322
+ var RetrainPipelineBoxSchema = object({
25323
+ /** Normalised `[0,1]` against the full frame. */
25324
+ bbox: RetrainBboxSchema,
25325
+ macroClass: RetrainMacroClassSchema,
25326
+ label: string().optional(),
25327
+ subLabel: string().optional(),
25328
+ /** The detection score of the position used, when it was recorded. */
25329
+ score: number().optional(),
25330
+ /** The root model that produced the track, when it was recorded. */
25331
+ modelId: string().optional(),
25332
+ trackId: string(),
25333
+ /** `subject-box`: recorded on this very frame. `position`: the track's
25334
+ * position nearest the capture time, `deltaMs` away. */
25335
+ basis: _enum(["subject-box", "position"]),
25336
+ deltaMs: number()
25337
+ });
25338
+ /**
25339
+ * Where a retrain frame came from: a TRACK's stored media (copy-on-select),
25340
+ * or the RECORDING at an instant — the frame a model saw nothing in has no
25341
+ * track at all.
25342
+ */
25343
+ var RetrainFrameOriginSchema = _enum(["track", "recording"]);
23506
25344
  /** A frame the dataset OWNS: bytes copied at selection time. */
23507
25345
  var RetrainFrameSchema = object({
23508
25346
  frameId: string(),
23509
25347
  deviceId: number(),
23510
- trackId: string(),
23511
- /** Provenance only. It may already point at nothing — that is expected. */
23512
- sourceMediaId: number().int(),
25348
+ origin: RetrainFrameOriginSchema,
25349
+ /** The track it was copied from. Absent on a recording still. */
25350
+ trackId: string().optional(),
25351
+ /** Provenance only. It may already point at nothing — that is expected.
25352
+ * Absent on a recording still. */
25353
+ sourceMediaId: number().int().optional(),
25354
+ /** A recording still: the playhead instant it was taken at. */
25355
+ epochMs: number().optional(),
23513
25356
  sourceKind: MediaFileKindEnum,
23514
25357
  sizeBytes: number().int(),
23515
25358
  width: number().int(),
@@ -23520,7 +25363,12 @@ var RetrainFrameSchema = object({
23520
25363
  /** The operator's "every subject in this frame is boxed". Detector
23521
25364
  * evaluation keeps only complete frames: an unboxed subject would count as
23522
25365
  * a false positive. */
23523
- complete: boolean()
25366
+ complete: boolean(),
25367
+ /** The boxes the pipeline drew on this frame. Present on list answers;
25368
+ * empty when nothing the track store holds can be placed on it. */
25369
+ pipelineBoxes: array(RetrainPipelineBoxSchema).readonly().optional(),
25370
+ /** The named collections this frame belongs to. Present on list answers. */
25371
+ collectionIds: array(string()).readonly().optional()
23524
25372
  });
23525
25373
  /** Why a copy-on-select could not be honoured — named, never a silent skip. */
23526
25374
  var RetrainCopyRefusalSchema = _enum([
@@ -23551,6 +25399,11 @@ var RetrainFrameListSchema = object({
23551
25399
  var RetrainExportFilterSchema = object({
23552
25400
  deviceIds: array(number()).optional(),
23553
25401
  frameIds: array(string()).max(2e4).optional(),
25402
+ /** Only frames in at least one of these named collections. */
25403
+ collectionIds: array(string()).max(200).optional(),
25404
+ /** Exactly the frames of this dataset version (and its completeOnly). An
25405
+ * unknown id selects nothing. */
25406
+ datasetVersionId: string().optional(),
23554
25407
  batchId: string().optional(),
23555
25408
  /** Only frames the operator marked complete (all subjects boxed). */
23556
25409
  completeOnly: boolean().optional()
@@ -23615,6 +25468,170 @@ var RetrainAssistResultSchema = discriminatedUnion("kind", [object({
23615
25468
  reason: string(),
23616
25469
  detail: string().optional()
23617
25470
  })]);
25471
+ /** A named set over the retrain corpus — membership only, it owns no pixels. */
25472
+ var RetrainCollectionSchema = object({
25473
+ id: string(),
25474
+ name: string(),
25475
+ createdAt: number(),
25476
+ frameCount: number().int()
25477
+ });
25478
+ var RetrainCollectionCreateResultSchema = discriminatedUnion("kind", [object({
25479
+ kind: literal("created"),
25480
+ collection: RetrainCollectionSchema
25481
+ }), object({
25482
+ kind: literal("refused"),
25483
+ reason: _enum(["empty-name", "duplicate-name"])
25484
+ })]);
25485
+ var RetrainCollectionRenameResultSchema = discriminatedUnion("kind", [object({
25486
+ kind: literal("renamed"),
25487
+ collection: RetrainCollectionSchema
25488
+ }), object({
25489
+ kind: literal("refused"),
25490
+ reason: _enum([
25491
+ "empty-name",
25492
+ "duplicate-name",
25493
+ "unknown-collection"
25494
+ ])
25495
+ })]);
25496
+ /**
25497
+ * The outcome of adding the frame at a recording instant. Every refusal is
25498
+ * named: `still-unavailable` (not recording, a gap, or an undecodable frame —
25499
+ * `detail` says which), `still-busy` (the recorder is at its decode bound; try
25500
+ * again), `unreadable-image`, `write-failed`, `unknown-collection`.
25501
+ */
25502
+ var AddRetrainFrameFromRecordingResultSchema = discriminatedUnion("kind", [object({
25503
+ kind: literal("added"),
25504
+ collectionId: string(),
25505
+ frame: RetrainFrameSchema,
25506
+ /** The moment was already in the dataset; nothing was decoded. */
25507
+ reused: boolean()
25508
+ }), object({
25509
+ kind: literal("refused"),
25510
+ reason: _enum([
25511
+ "unknown-collection",
25512
+ "still-unavailable",
25513
+ "still-busy",
25514
+ "unreadable-image",
25515
+ "write-failed"
25516
+ ]),
25517
+ detail: string().optional()
25518
+ })]);
25519
+ /** A vision LLM profile the AI assist may use, and where it sends the frame. */
25520
+ var RetrainAssistProfileSchema = object({
25521
+ id: string(),
25522
+ name: string(),
25523
+ model: string(),
25524
+ kind: string(),
25525
+ /** `true` when the frame would leave the house (a cloud vendor, or an
25526
+ * endpoint that is not on the local network). The page confirms each such
25527
+ * run, and the provider refuses one without `allowCloud`. */
25528
+ leavesHouse: boolean()
25529
+ });
25530
+ /** A box the AI assist proposed: a draft, plus the model's own reason. */
25531
+ var RetrainLlmProposalSchema = RetrainAnnotationDraftSchema.extend({ reason: string() });
25532
+ /** What the AI assist said about a box that was already on the canvas. */
25533
+ var RetrainLlmReviewSchema = object({
25534
+ /** The `ref` the page sent the box under. */
25535
+ ref: string(),
25536
+ verdict: _enum([
25537
+ "confirmed",
25538
+ "wrong-class",
25539
+ "not-an-object",
25540
+ "uncertain"
25541
+ ]),
25542
+ suggestedClass: RetrainMacroClassSchema.optional(),
25543
+ reason: string()
25544
+ });
25545
+ /**
25546
+ * The AI assist's answer. `proposed` carries drafts (`source: 'llm'`, the
25547
+ * model and its confidence) and reviews; items the model got wrong (a box off
25548
+ * the frame, an unasked class, an unknown ref) are dropped and counted in
25549
+ * `rejected`. A whole answer that is not the schema is `malformed-answer`.
25550
+ */
25551
+ var RetrainLlmAssistResultSchema = discriminatedUnion("kind", [object({
25552
+ kind: literal("proposed"),
25553
+ profileId: string(),
25554
+ model: string(),
25555
+ /** The frame was sent outside the house for this answer. */
25556
+ leftHouse: boolean(),
25557
+ proposals: array(RetrainLlmProposalSchema).readonly(),
25558
+ reviews: array(RetrainLlmReviewSchema).readonly(),
25559
+ rejected: number().int()
25560
+ }), object({
25561
+ kind: literal("refused"),
25562
+ reason: _enum([
25563
+ "unknown-frame",
25564
+ "unreadable-frame",
25565
+ "unknown-profile",
25566
+ "profile-disabled",
25567
+ "no-vision",
25568
+ "cloud-not-confirmed",
25569
+ "llm-error",
25570
+ "malformed-answer"
25571
+ ]),
25572
+ detail: string().optional()
25573
+ })]);
25574
+ /** What a dataset version is cut from. Every field narrows. */
25575
+ var RetrainDatasetSelectionSchema = object({
25576
+ deviceIds: array(number()).readonly().optional(),
25577
+ collectionIds: array(string()).max(200).readonly().optional(),
25578
+ frameIds: array(string()).max(2e4).readonly().optional()
25579
+ });
25580
+ /** The counts a dataset is judged by. */
25581
+ var RetrainDatasetStatsSchema = object({
25582
+ frames: number().int(),
25583
+ completeFrames: number().int(),
25584
+ /** `completeFrames / frames`, 0..1. */
25585
+ completeness: number(),
25586
+ /** Boxes to learn (model errors excluded). */
25587
+ subjects: number().int(),
25588
+ modelErrors: number().int(),
25589
+ /** Complete frames with no subject. */
25590
+ hardNegatives: number().int(),
25591
+ /** Subjects per class × camera × day/night. */
25592
+ cells: array(object({
25593
+ macroClass: string(),
25594
+ deviceId: number(),
25595
+ lighting: _enum([
25596
+ "day",
25597
+ "night",
25598
+ "unknown"
25599
+ ]),
25600
+ subjects: number().int(),
25601
+ frames: number().int()
25602
+ })).readonly(),
25603
+ cameras: array(object({
25604
+ deviceId: number(),
25605
+ frames: number().int(),
25606
+ completeFrames: number().int()
25607
+ })).readonly()
25608
+ });
25609
+ /** An immutable dataset version, without its frame list. */
25610
+ var RetrainDatasetVersionSchema = object({
25611
+ id: string(),
25612
+ name: string(),
25613
+ createdAt: number(),
25614
+ selection: RetrainDatasetSelectionSchema,
25615
+ layout: RetrainExportLayoutSchema,
25616
+ completeOnly: boolean(),
25617
+ frameCount: number().int(),
25618
+ /** sha256 of what the frames taught when the version was frozen. */
25619
+ annotationHash: string(),
25620
+ /** The export manifest schema the version was cut under. */
25621
+ manifestSchema: string(),
25622
+ stats: RetrainDatasetStatsSchema
25623
+ });
25624
+ var CreateRetrainDatasetVersionResultSchema = discriminatedUnion("kind", [object({
25625
+ kind: literal("created"),
25626
+ version: RetrainDatasetVersionSchema
25627
+ }), object({
25628
+ kind: literal("refused"),
25629
+ reason: _enum([
25630
+ "empty-name",
25631
+ "duplicate-name",
25632
+ "no-frames"
25633
+ ])
25634
+ })]);
23618
25635
  /** The outcome of a lifecycle move owned by the retrain page. */
23619
25636
  var RetrainTransitionResultSchema = object({
23620
25637
  trackId: string(),
@@ -24332,7 +26349,7 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
24332
26349
  auth: "admin"
24333
26350
  }), method(object({
24334
26351
  deviceId: number(),
24335
- trackId: string(),
26352
+ trackId: string().optional(),
24336
26353
  frameId: string()
24337
26354
  }), object({
24338
26355
  removed: boolean(),
@@ -24349,7 +26366,8 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
24349
26366
  auth: "admin"
24350
26367
  }), method(object({
24351
26368
  deviceId: number(),
24352
- trackId: string(),
26369
+ /** The frame's track, when it has one — checked against the frame. */
26370
+ trackId: string().optional(),
24353
26371
  frameId: string(),
24354
26372
  subject: RetrainAssistSubjectSchema,
24355
26373
  /** Which node runs it. Absent ⇒ wherever an unowned call lands. */
@@ -24357,12 +26375,16 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
24357
26375
  }), RetrainAssistResultSchema, {
24358
26376
  kind: "mutation",
24359
26377
  auth: "admin"
24360
- }), method(object({ trackId: string() }), array(RetrainAnnotationSchema).readonly(), {
26378
+ }), method(object({
26379
+ trackId: string().optional(),
26380
+ frameIds: array(string()).max(2e3).optional()
26381
+ }), array(RetrainAnnotationSchema).readonly(), {
24361
26382
  kind: "query",
24362
26383
  auth: "admin"
24363
26384
  }), method(object({
24364
26385
  deviceId: number(),
24365
- trackId: string(),
26386
+ /** The frame's track, when it has one — checked against the frame. */
26387
+ trackId: string().optional(),
24366
26388
  frameId: string(),
24367
26389
  annotations: array(RetrainAnnotationDraftSchema)
24368
26390
  }), array(RetrainAnnotationSchema).readonly(), {
@@ -24385,7 +26407,7 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
24385
26407
  auth: "admin"
24386
26408
  }), method(object({
24387
26409
  deviceId: number(),
24388
- trackId: string(),
26410
+ trackId: string().optional(),
24389
26411
  frameId: string(),
24390
26412
  complete: boolean()
24391
26413
  }), RetrainFrameSchema, {
@@ -24399,6 +26421,115 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
24399
26421
  kind: "mutation",
24400
26422
  auth: "admin",
24401
26423
  timeoutMs: 60 * 6e4
26424
+ }), method(object({
26425
+ filter: RetrainExportFilterSchema,
26426
+ layout: RetrainExportLayoutSchema
26427
+ }), object({
26428
+ ticket: PeerBytesTicketSchema,
26429
+ frames: number().int(),
26430
+ annotations: number().int()
26431
+ }), {
26432
+ kind: "mutation",
26433
+ auth: "admin",
26434
+ timeoutMs: 12e4
26435
+ }), method(object({
26436
+ selection: RetrainDatasetSelectionSchema,
26437
+ completeOnly: boolean().optional()
26438
+ }), RetrainDatasetStatsSchema, {
26439
+ kind: "query",
26440
+ auth: "admin"
26441
+ }), method(object({
26442
+ name: string().max(120),
26443
+ selection: RetrainDatasetSelectionSchema,
26444
+ layout: RetrainExportLayoutSchema,
26445
+ completeOnly: boolean()
26446
+ }), CreateRetrainDatasetVersionResultSchema, {
26447
+ kind: "mutation",
26448
+ auth: "admin",
26449
+ timeoutMs: 12e4
26450
+ }), method(object({}), array(RetrainDatasetVersionSchema).readonly(), {
26451
+ kind: "query",
26452
+ auth: "admin"
26453
+ }), method(object({ id: string() }), object({ deleted: boolean() }), {
26454
+ kind: "mutation",
26455
+ auth: "admin"
26456
+ }), method(object({ id: string() }), object({
26457
+ found: boolean(),
26458
+ annotationHash: string(),
26459
+ matches: boolean(),
26460
+ missingFrames: number().int()
26461
+ }), {
26462
+ kind: "query",
26463
+ auth: "admin",
26464
+ timeoutMs: 12e4
26465
+ }), method(object({}), array(RetrainAssistProfileSchema).readonly(), {
26466
+ kind: "query",
26467
+ auth: "admin"
26468
+ }), method(object({
26469
+ deviceId: number(),
26470
+ trackId: string().optional(),
26471
+ frameId: string(),
26472
+ profileId: string(),
26473
+ classes: array(RetrainMacroClassSchema).min(1),
26474
+ boxes: array(object({
26475
+ ref: string(),
26476
+ bbox: RetrainBboxSchema,
26477
+ macroClass: RetrainMacroClassSchema,
26478
+ label: string().optional()
26479
+ })).max(50),
26480
+ allowCloud: boolean()
26481
+ }), RetrainLlmAssistResultSchema, {
26482
+ kind: "mutation",
26483
+ auth: "admin",
26484
+ timeoutMs: 18e4
26485
+ }), method(object({ name: string().max(120) }), RetrainCollectionCreateResultSchema, {
26486
+ kind: "mutation",
26487
+ auth: "admin"
26488
+ }), method(object({}), array(RetrainCollectionSchema).readonly(), {
26489
+ kind: "query",
26490
+ auth: "admin"
26491
+ }), method(object({
26492
+ id: string(),
26493
+ name: string().max(120)
26494
+ }), RetrainCollectionRenameResultSchema, {
26495
+ kind: "mutation",
26496
+ auth: "admin"
26497
+ }), method(object({ id: string() }), object({
26498
+ deleted: boolean(),
26499
+ removedFrames: number().int()
26500
+ }), {
26501
+ kind: "mutation",
26502
+ auth: "admin"
26503
+ }), method(object({
26504
+ collectionId: string(),
26505
+ deviceId: number(),
26506
+ epochMs: number()
26507
+ }), AddRetrainFrameFromRecordingResultSchema, {
26508
+ kind: "mutation",
26509
+ auth: "admin",
26510
+ timeoutMs: 6e4
26511
+ }), method(object({
26512
+ collectionId: string(),
26513
+ frameIds: array(string()).min(1).max(500)
26514
+ }), object({
26515
+ added: number().int(),
26516
+ alreadyMember: number().int(),
26517
+ unknownFrameIds: array(string()).readonly()
26518
+ }), {
26519
+ kind: "mutation",
26520
+ auth: "admin"
26521
+ }), method(object({
26522
+ collectionId: string(),
26523
+ frameId: string()
26524
+ }), object({
26525
+ removed: boolean(),
26526
+ deletedFrame: boolean()
26527
+ }), {
26528
+ kind: "mutation",
26529
+ auth: "admin"
26530
+ }), method(object({ collectionId: string() }), array(RetrainFrameSchema).readonly(), {
26531
+ kind: "query",
26532
+ auth: "admin"
24402
26533
  }), method(object({
24403
26534
  /** Which of the three event tables owns the row. */
24404
26535
  ownerType: EventOwnerTypeSchema,
@@ -25022,13 +27153,31 @@ var RecommendationReasonSchema = discriminatedUnion("kind", [
25022
27153
  object({
25023
27154
  kind: literal("no-family-build"),
25024
27155
  format: ModelFormatSchema$1
27156
+ }),
27157
+ object({
27158
+ kind: literal("kept-custom-pin"),
27159
+ modelId: string(),
27160
+ deviceKey: string()
25025
27161
  })
25026
27162
  ]);
27163
+ /** Why a device is left exactly as it is, whatever the plan would pick (D786). */
27164
+ var KeptReasonSchema = _enum(["custom-pin"]);
27165
+ /**
27166
+ * Where a choice's latency came from (D791): this node's own benchmark
27167
+ * result, or the hardware-class table. Measured on the node beats the table.
27168
+ */
27169
+ var LatencySourceSchema = discriminatedUnion("kind", [object({ kind: literal("table") }), object({
27170
+ kind: literal("node-benchmark"),
27171
+ resultId: string(),
27172
+ measuredAtMs: number()
27173
+ })]);
25027
27174
  var DeviceModelChoiceSchema = object({
25028
27175
  modelId: string(),
25029
27176
  p50Ms: number(),
25030
27177
  fps: number(),
25031
27178
  measured: boolean(),
27179
+ /** Absent on a plan from before D791 — read as the table. */
27180
+ source: LatencySourceSchema.optional(),
25032
27181
  /** Parallel sessions at the camera rate with the headroom kept free: ⌊fps × (1 − headroom) / camera fps⌋. */
25033
27182
  capacitySessions: number(),
25034
27183
  personRecall: number()
@@ -25039,6 +27188,8 @@ var DeviceRecommendationSchema = object({
25039
27188
  enabled: boolean(),
25040
27189
  available: boolean(),
25041
27190
  chosen: DeviceModelChoiceSchema.nullable(),
27191
+ /** Present when the device is kept as is: Apply writes nothing on it. */
27192
+ kept: KeptReasonSchema.optional(),
25042
27193
  reasons: array(RecommendationReasonSchema).readonly()
25043
27194
  });
25044
27195
  var NodeRecommendationSchema = object({
@@ -25092,6 +27243,17 @@ var AutoTuneWarningSchema = discriminatedUnion("kind", [
25092
27243
  kind: literal("coral-enabled"),
25093
27244
  nodeId: string(),
25094
27245
  deviceKey: string()
27246
+ }),
27247
+ object({
27248
+ kind: literal("custom-pin-kept"),
27249
+ nodeId: string(),
27250
+ deviceKey: string().nullable(),
27251
+ deviceId: number().nullable(),
27252
+ modelId: string()
27253
+ }),
27254
+ object({
27255
+ kind: literal("custom-registry-unreadable"),
27256
+ error: string()
25095
27257
  })
25096
27258
  ]);
25097
27259
  var AutoTuneOptionsSchema = object({
@@ -25270,13 +27432,14 @@ var SuggestSharesResultSchema = object({
25270
27432
  nodes: array(SuggestedNodeShareSchema).readonly()
25271
27433
  });
25272
27434
  /**
25273
- * Where the node and device shares come from (D750, D755).
25274
- * - `hardware` (default) — computed by the system from each node's static
25275
- * capacity (its accelerators at their Auto tune models, from the measured
25276
- * latency table), recomputed whenever a node or device joins, leaves, is
25277
- * switched on or off, or changes model. No load input.
25278
- * - `benchmark` — the same, from each node's measured capacity (node
25279
- * benchmark results); a node without results falls back to `hardware`.
27435
+ * Where the node and device shares come from (D750, D755, D791).
27436
+ * - `benchmark` (default since D791) — each node's capacity as its own node
27437
+ * benchmark measured it; a node without fresh results is sized from
27438
+ * `hardware` and says so. Measured on the node beats the table.
27439
+ * - `hardware` — computed from each node's static capacity only (its
27440
+ * accelerators at their Auto tune models, from the latency table).
27441
+ * Both are recomputed whenever a node or device joins, leaves, is switched
27442
+ * on or off, changes model, or a benchmark result is written. No load input.
25280
27443
  * - `manual` — the operator's stored sliders.
25281
27444
  * Either way a node or device that cannot take sessions gives its share to
25282
27445
  * the others in proportion; the stored values are never rewritten for that.
@@ -25325,6 +27488,362 @@ var EffectiveSharesSchema = object({
25325
27488
  nodeWeights: record(string(), number()),
25326
27489
  deviceWeights: record(string(), record(string(), number()))
25327
27490
  });
27491
+ /**
27492
+ * Wire shapes of the node benchmark (D791): the operator's plan, the
27493
+ * preflight the confirmation shows, the run the orchestrator owns, what the
27494
+ * measuring runner reports, and the result rows Auto tune and the automatic
27495
+ * shares read.
27496
+ *
27497
+ * ONE node at a time, owned by the pipeline orchestrator. While a run is
27498
+ * active the cluster is in BENCHMARK MODE for that node: it is not a
27499
+ * detection candidate, camera pins naming it are ignored so its sessions move
27500
+ * elsewhere, and both come back when the mode ends — after a crash or a hub
27501
+ * restart too (a persisted manifest, reconciled against the registry).
27502
+ *
27503
+ * Two measurements, both on the node, driven by its own runner (frames never
27504
+ * cross a process at frame rate, D9):
27505
+ * - `device` — one accelerator × one candidate detector, root only, open
27506
+ * loop: how many streams at the camera rate it carries inside the frame
27507
+ * interval;
27508
+ * - `pipeline` — the chosen detector plus the operator's detail steps
27509
+ * (faces, plates, classifiers, CLIP…), on varied frames from the bench
27510
+ * clip: how many parallel sessions the node carries before latency, drops,
27511
+ * CPU, RAM or the event loop give out.
27512
+ */
27513
+ /** Defaults and bounds, one place. */
27514
+ var NODE_BENCHMARK_DEFAULTS = {
27515
+ fpsPerStream: 10,
27516
+ budgetMinutes: 45,
27517
+ minBudgetMinutes: 10,
27518
+ maxBudgetMinutes: 120,
27519
+ /** A result older than this no longer beats the table. */
27520
+ staleAfterDays: 30,
27521
+ /** Warm-in per ramp step (not accounted). */
27522
+ settleSec: 5,
27523
+ /** Accounted window per ramp step. */
27524
+ measureSec: 20,
27525
+ /** Longest the drain may take before the run is refused. */
27526
+ drainTimeoutSec: 120,
27527
+ /** Candidate models per device in one run. */
27528
+ maxModelsPerDevice: 6
27529
+ };
27530
+ /** The two measurements a run can make. */
27531
+ var NodeBenchmarkPhaseSchema = _enum(["device", "pipeline"]);
27532
+ var NodeBenchmarkDevicePlanSchema = object({
27533
+ /** `<backend>:<device>` — `openvino:npu`, `coreml:all`, `cpu`. */
27534
+ deviceKey: string().min(1),
27535
+ /**
27536
+ * Root detector candidates for the `device` measurement, in the order
27537
+ * measured. The FIRST is the one the `pipeline` measurement runs.
27538
+ */
27539
+ modelIds: array(string().min(1)).min(1).max(NODE_BENCHMARK_DEFAULTS.maxModelsPerDevice)
27540
+ });
27541
+ /** What the operator confirmed. */
27542
+ var NodeBenchmarkPlanSchema = object({
27543
+ nodeId: string().min(1),
27544
+ devices: array(NodeBenchmarkDevicePlanSchema).min(1),
27545
+ /** Which measurements run. At least one. */
27546
+ phases: array(NodeBenchmarkPhaseSchema).min(1).default(["device", "pipeline"]),
27547
+ /**
27548
+ * Detail steps (catalog step ids under the root: faces, plates,
27549
+ * classifiers, CLIP…) the `pipeline` measurement enables. The root
27550
+ * detector always runs.
27551
+ */
27552
+ steps: array(string().min(1)).default([]),
27553
+ /** Offered rate of one stream / session. */
27554
+ fpsPerStream: number().int().min(1).max(30).default(NODE_BENCHMARK_DEFAULTS.fpsPerStream),
27555
+ /** Hard deadline: the mode ends and the cluster is restored when it passes. */
27556
+ budgetMinutes: number().int().min(NODE_BENCHMARK_DEFAULTS.minBudgetMinutes).max(NODE_BENCHMARK_DEFAULTS.maxBudgetMinutes).default(NODE_BENCHMARK_DEFAULTS.budgetMinutes),
27557
+ /** Keep the models the run downloaded (default: delete what was not installed before). */
27558
+ keepDownloadedModels: boolean().default(false),
27559
+ /** Start although the other nodes' capacity does not cover the sessions running now. */
27560
+ acceptInsufficientHeadroom: boolean().default(false)
27561
+ });
27562
+ var NodeBenchmarkRefusalSchema = object({
27563
+ kind: _enum([
27564
+ "benchmark-active",
27565
+ "node-offline",
27566
+ "unknown-device",
27567
+ "no-phase",
27568
+ "insufficient-headroom"
27569
+ ]),
27570
+ detail: string(),
27571
+ overridable: boolean()
27572
+ });
27573
+ /** A camera whose detection leaves the node for the run. */
27574
+ var NodeBenchmarkMovingCameraSchema = object({
27575
+ deviceId: number(),
27576
+ /** Placed on the node now (a standing attach or a running session). */
27577
+ placedOnNode: boolean(),
27578
+ /** A node pin naming this node, ignored for the run. */
27579
+ pinnedToNode: boolean()
27580
+ });
27581
+ /** A camera that cannot leave: no other node can obtain its frames. */
27582
+ var NodeBenchmarkStayingCameraSchema = object({
27583
+ deviceId: number(),
27584
+ reason: literal("only-frame-source")
27585
+ });
27586
+ var NodeBenchmarkPreflightSchema = object({
27587
+ nodeId: string(),
27588
+ online: boolean(),
27589
+ moving: array(NodeBenchmarkMovingCameraSchema).readonly(),
27590
+ /** Keep running on the node during the run; the result is flagged contaminated. */
27591
+ staying: array(NodeBenchmarkStayingCameraSchema).readonly(),
27592
+ estimatedDurationMs: number(),
27593
+ /** The run ends and the cluster is restored at the latest after this long. */
27594
+ budgetMs: number(),
27595
+ phases: array(NodeBenchmarkPhaseSchema).readonly(),
27596
+ steps: array(string()).readonly(),
27597
+ devices: array(NodeBenchmarkDevicePlanSchema).readonly(),
27598
+ /** Parallel sessions the cluster runs now, and what the other nodes can carry. */
27599
+ headroom: object({
27600
+ sessionsNow: number(),
27601
+ otherNodesCapacitySessions: number().nullable()
27602
+ }),
27603
+ refusals: array(NodeBenchmarkRefusalSchema).readonly(),
27604
+ canStart: boolean()
27605
+ });
27606
+ /** Where the measuring runner is. */
27607
+ var NodeBenchProgressSchema = object({
27608
+ phase: _enum([
27609
+ "preparing",
27610
+ "device",
27611
+ "pipeline",
27612
+ "cleanup"
27613
+ ]),
27614
+ deviceKey: string().nullable(),
27615
+ modelId: string().nullable(),
27616
+ /** Streams (device) or sessions (pipeline) of the step running now. */
27617
+ load: number().nullable(),
27618
+ cellsDone: number(),
27619
+ cellsTotal: number(),
27620
+ message: string()
27621
+ });
27622
+ /** What limited a ramp. `none` = the ramp ran out of steps still passing. */
27623
+ var NodeBenchLimitSchema = _enum([
27624
+ "p95",
27625
+ "drops",
27626
+ "errors",
27627
+ "stall",
27628
+ "cpu",
27629
+ "ram",
27630
+ "none"
27631
+ ]);
27632
+ var NodeBenchRampStepSchema = object({
27633
+ load: number(),
27634
+ pass: boolean(),
27635
+ p95Ms: number(),
27636
+ dropRatio: number(),
27637
+ /** Completed frames per second over the accounted window. */
27638
+ fps: number(),
27639
+ cpuPct: number().nullable(),
27640
+ ramFreePct: number().nullable(),
27641
+ failReasons: array(string()).readonly()
27642
+ });
27643
+ var NodeBenchCellSchema = discriminatedUnion("phase", [object({
27644
+ phase: literal("device"),
27645
+ deviceKey: string(),
27646
+ modelId: string(),
27647
+ /** Single-stream latency (the K = 1 step). */
27648
+ p50Ms: number(),
27649
+ p95Ms: number(),
27650
+ p99Ms: number(),
27651
+ /** Frames per second sustained at the last passing step. */
27652
+ fps: number(),
27653
+ /** Streams at the camera rate the device carried inside the frame interval; 0 = not even one. */
27654
+ kMax: number(),
27655
+ limitedBy: NodeBenchLimitSchema,
27656
+ /** First call (model load + warm-up). */
27657
+ warmupMs: number(),
27658
+ ramp: array(NodeBenchRampStepSchema).readonly()
27659
+ }), object({
27660
+ phase: literal("pipeline"),
27661
+ deviceKey: string(),
27662
+ modelId: string(),
27663
+ steps: array(string()).readonly(),
27664
+ /** Parallel sessions at the camera rate the node carried; 0 = not even one. */
27665
+ maxSessions: number(),
27666
+ limitedBy: NodeBenchLimitSchema,
27667
+ /** Detail steps that produced at least one result on the clip — a step that never fired measured nothing. */
27668
+ stepsFired: array(string()).readonly(),
27669
+ warmupMs: number(),
27670
+ ramp: array(NodeBenchRampStepSchema).readonly()
27671
+ })]);
27672
+ /**
27673
+ * What a result was measured ON. A result whose fingerprint no longer matches
27674
+ * the node no longer beats the table.
27675
+ */
27676
+ var NodeBenchFingerprintSchema = object({
27677
+ pipelineVersion: string().nullable(),
27678
+ cpuModel: string().nullable(),
27679
+ ramGb: number().nullable(),
27680
+ os: string().nullable(),
27681
+ /** Per device: the pool the cells ran on (runtime + tuning). */
27682
+ pools: record(string(), object({
27683
+ runtime: string(),
27684
+ numWorkers: number(),
27685
+ concurrency: number(),
27686
+ batchMode: string()
27687
+ })).default({})
27688
+ });
27689
+ /** The frames the run used. */
27690
+ var NodeBenchClipSchema = object({
27691
+ /** `camstack-bench-v1` or `reference-images` (the fallback when the clip is not reachable). */
27692
+ id: string(),
27693
+ revision: string().nullable(),
27694
+ frames: number(),
27695
+ width: number(),
27696
+ height: number()
27697
+ });
27698
+ var NodeBenchRunnerInputSchema = object({
27699
+ runId: string().min(1),
27700
+ devices: array(NodeBenchmarkDevicePlanSchema).min(1),
27701
+ phases: array(NodeBenchmarkPhaseSchema).min(1),
27702
+ /** The full detail step tree root for the `pipeline` measurement is built on the node from these ids. */
27703
+ steps: array(string()).default([]),
27704
+ fpsPerStream: number().int().min(1).max(30),
27705
+ /** The runner stops on its own past this instant, whatever the hub does. */
27706
+ deadlineAtMs: number(),
27707
+ settleSec: number().min(0).max(60).default(NODE_BENCHMARK_DEFAULTS.settleSec),
27708
+ measureSec: number().min(2).max(300).default(NODE_BENCHMARK_DEFAULTS.measureSec),
27709
+ keepDownloadedModels: boolean().default(false)
27710
+ });
27711
+ var NodeBenchRunnerStateSchema = _enum([
27712
+ "running",
27713
+ "done",
27714
+ "failed",
27715
+ "aborted"
27716
+ ]);
27717
+ var NodeBenchRunnerStatusSchema = object({
27718
+ runId: string(),
27719
+ nodeId: string(),
27720
+ state: NodeBenchRunnerStateSchema,
27721
+ progress: NodeBenchProgressSchema.nullable(),
27722
+ /** Every finished cell so far — a run stopped half way keeps what it measured. */
27723
+ cells: array(NodeBenchCellSchema).readonly(),
27724
+ fingerprint: NodeBenchFingerprintSchema.nullable(),
27725
+ clip: NodeBenchClipSchema.nullable(),
27726
+ /** Cameras seen running on the node during the run (they share its pools). */
27727
+ activeCameraIds: array(number()).readonly(),
27728
+ /** Models the run downloaded and then deleted (not installed before). */
27729
+ deletedModels: array(string()).readonly(),
27730
+ error: string().nullable(),
27731
+ startedAtMs: number(),
27732
+ finishedAtMs: number().nullable()
27733
+ });
27734
+ var NodeBenchmarkStateSchema = _enum([
27735
+ "draining",
27736
+ "measuring",
27737
+ "restoring",
27738
+ "done",
27739
+ "failed",
27740
+ "aborted"
27741
+ ]);
27742
+ /** Why a run ended. */
27743
+ var NodeBenchmarkEndReasonSchema = _enum([
27744
+ "completed",
27745
+ "operator-abort",
27746
+ "deadline",
27747
+ "node-lost",
27748
+ "runner-lost",
27749
+ "hub-restart",
27750
+ "drain-timeout",
27751
+ "failed"
27752
+ ]);
27753
+ var NodeBenchmarkRunSchema = object({
27754
+ runId: string(),
27755
+ nodeId: string(),
27756
+ state: NodeBenchmarkStateSchema,
27757
+ plan: NodeBenchmarkPlanSchema,
27758
+ startedAtMs: number(),
27759
+ deadlineAtMs: number(),
27760
+ finishedAtMs: number().nullable(),
27761
+ endReason: NodeBenchmarkEndReasonSchema.nullable(),
27762
+ error: string().nullable(),
27763
+ /** Cameras moved off the node for the run. */
27764
+ moved: array(number()).readonly(),
27765
+ /** Cameras that stayed (their only frame source is the node). */
27766
+ staying: array(number()).readonly(),
27767
+ /** Something else ran on the node's pools during the run. */
27768
+ contaminated: boolean(),
27769
+ progress: NodeBenchProgressSchema.nullable(),
27770
+ resultIds: array(string()).readonly()
27771
+ });
27772
+ /** `getNodeBenchmarkStatus`: the active run (or the last one), and whether benchmark mode is on. */
27773
+ var NodeBenchmarkStatusSchema = object({
27774
+ /** The node the cluster is in benchmark mode for; null = none. */
27775
+ modeNodeId: string().nullable(),
27776
+ run: NodeBenchmarkRunSchema.nullable()
27777
+ });
27778
+ /**
27779
+ * One stored measurement — the only authority Auto tune and the automatic
27780
+ * shares read measured capacity from. Written by the orchestrator when a run
27781
+ * ends, never by anyone else.
27782
+ */
27783
+ var NodeBenchmarkResultSchema = object({
27784
+ id: string(),
27785
+ runId: string(),
27786
+ nodeId: string(),
27787
+ cell: NodeBenchCellSchema,
27788
+ fpsPerStream: number(),
27789
+ fingerprint: NodeBenchFingerprintSchema.nullable(),
27790
+ clip: NodeBenchClipSchema.nullable(),
27791
+ /** Other work shared the node's pools (a camera that could not move, or the hub's own duties). */
27792
+ contaminated: boolean(),
27793
+ stayingCameras: array(number()).readonly(),
27794
+ /** The run ended early; the cell itself completed. */
27795
+ partialRun: boolean(),
27796
+ measuredAtMs: number()
27797
+ });
27798
+ var ListNodeBenchmarkResultsInputSchema = object({
27799
+ nodeId: string().optional(),
27800
+ deviceKey: string().optional()
27801
+ });
27802
+ /** A result with its standing today: does it still beat the table? */
27803
+ var NodeBenchmarkResultViewSchema = NodeBenchmarkResultSchema.extend({
27804
+ /** `fresh` beats the table; `stale` falls back to it; `superseded` = a newer row covers the same cell. */
27805
+ standing: _enum([
27806
+ "fresh",
27807
+ "stale",
27808
+ "superseded"
27809
+ ]),
27810
+ staleWhy: _enum([
27811
+ "age",
27812
+ "runtime",
27813
+ "pool-tuning"
27814
+ ]).nullable()
27815
+ });
27816
+ object({
27817
+ runId: string(),
27818
+ nodeId: string(),
27819
+ startedAtMs: number(),
27820
+ deadlineAtMs: number(),
27821
+ plan: NodeBenchmarkPlanSchema,
27822
+ moved: array(number()).readonly(),
27823
+ staying: array(number()).readonly()
27824
+ });
27825
+ /** Candidate detectors per device, for the plan editor. */
27826
+ var NodeBenchmarkCandidatesSchema = object({
27827
+ nodeId: string(),
27828
+ reachable: boolean(),
27829
+ devices: array(object({
27830
+ deviceKey: string(),
27831
+ enabled: boolean(),
27832
+ available: boolean(),
27833
+ /** Ordered: what Auto tune would pick first, then the rest of the family by accuracy. */
27834
+ suggested: array(string()).readonly(),
27835
+ /** Every root detector the device has a build for. */
27836
+ all: array(string()).readonly(),
27837
+ /** The model the device runs now, when pinned. */
27838
+ currentModelId: string().nullable()
27839
+ })).readonly(),
27840
+ /** Detail steps the node's catalog offers under the root (for the `pipeline` measurement). */
27841
+ steps: array(object({
27842
+ id: string(),
27843
+ name: string(),
27844
+ slot: string()
27845
+ })).readonly()
27846
+ });
25328
27847
  object({
25329
27848
  activeCameras: number(),
25330
27849
  throttledCameras: number(),
@@ -26453,7 +28972,16 @@ method(RunnerCameraConfigSchema, object({ success: literal(true) }), { kind: "mu
26453
28972
  }), ParkedTrackFrameSchema.nullable()), method(object({
26454
28973
  deviceId: number(),
26455
28974
  trackId: string()
26456
- }), object({ released: number().int().nonnegative() }), { kind: "mutation" });
28975
+ }), object({ released: number().int().nonnegative() }), { kind: "mutation" }), method(NodeBenchRunnerInputSchema, object({
28976
+ accepted: literal(true),
28977
+ runId: string()
28978
+ }), {
28979
+ kind: "mutation",
28980
+ auth: "admin"
28981
+ }), method(object({ runId: string() }), NodeBenchRunnerStatusSchema.nullable(), { auth: "admin" }), method(object({ runId: string() }), object({ aborted: boolean() }), {
28982
+ kind: "mutation",
28983
+ auth: "admin"
28984
+ });
26457
28985
  var CameraPipelineConfigSchema = object({
26458
28986
  engine: PipelineEngineChoiceSchema.optional(),
26459
28987
  steps: array(PipelineStepInputSchema).readonly(),
@@ -27092,6 +29620,21 @@ method(object({
27092
29620
  }), method(PlacementStatsInputSchema, PlacementStatsSchema, { auth: "admin" }), method(SuggestSharesInputSchema, SuggestSharesResultSchema, { auth: "admin" }), method(_void(), EffectiveSharesSchema, { auth: "admin" }), method(SetShareSourceInputSchema, object({ success: literal(true) }), {
27093
29621
  kind: "mutation",
27094
29622
  auth: "admin"
29623
+ }), method(NodeBenchmarkPlanSchema, NodeBenchmarkPreflightSchema, { auth: "admin" }), method(NodeBenchmarkPlanSchema, discriminatedUnion("kind", [object({
29624
+ kind: literal("started"),
29625
+ runId: string()
29626
+ }), object({
29627
+ kind: literal("refused"),
29628
+ preflight: NodeBenchmarkPreflightSchema
29629
+ })]), {
29630
+ kind: "mutation",
29631
+ auth: "admin"
29632
+ }), method(_void(), NodeBenchmarkStatusSchema, { auth: "admin" }), method(object({ runId: string() }), object({ aborted: boolean() }), {
29633
+ kind: "mutation",
29634
+ auth: "admin"
29635
+ }), method(object({ nodeId: string() }), NodeBenchmarkCandidatesSchema, { auth: "admin" }), method(ListNodeBenchmarkResultsInputSchema, array(NodeBenchmarkResultViewSchema).readonly(), { auth: "admin" }), method(object({ id: string() }), object({ deleted: boolean() }), {
29636
+ kind: "mutation",
29637
+ auth: "admin"
27095
29638
  }), method(object({ deviceId: number() }), CameraPipelineSettingsSchema.nullable()), method(object({
27096
29639
  deviceId: number(),
27097
29640
  addonId: string(),
@@ -27497,8 +30040,8 @@ version: string().optional() }), ServerUpdateActionResultSchema, {
27497
30040
  * `smtp-provider` — pluggable email delivery surface.
27498
30041
  *
27499
30042
  * Collection cap: a deployment may install multiple SMTP relays (e.g.
27500
- * one for transactional / one for notifications). Consumers (magic-link,
27501
- * notifier addons, …) walk the collection and pick the first
30043
+ * one for transactional / one for notifications). Consumers (notifier
30044
+ * addons, …) walk the collection and pick the first
27502
30045
  * ready provider OR target a specific addonId.
27503
30046
  *
27504
30047
  * The shape stays small on purpose — `sendEmail` is enough for the
@@ -27677,7 +30220,7 @@ targets: array(object({
27677
30220
  })));
27678
30221
  /**
27679
30222
  * `sso-bridge` — internal hub-only cap that lets SSO-style auth
27680
- * providers (OIDC, SAML, magic-link, …) mint an HMAC-signed token
30223
+ * providers (OIDC, SAML, …) mint an HMAC-signed token
27681
30224
  * carrying the post-callback claims before redirecting back to
27682
30225
  * `/api/auth/sso/finish`.
27683
30226
  *
@@ -27740,7 +30283,14 @@ var SsoBridgeClaimsSchema = object({
27740
30283
  * Verified `iss` of the id_token behind an OIDC login bridge (D782). A
27741
30284
  * subject is unique only per issuer, so a link is bound to it.
27742
30285
  */
27743
- issuer: string().optional()
30286
+ issuer: string().optional(),
30287
+ /**
30288
+ * SHA-256 (hex) of the `camstack_sso_state` cookie the IdP `/start` set in
30289
+ * the browser that began this sign-in. `/api/auth/sso/finish` requires the
30290
+ * request to present the matching cookie — a login bridge is useless in
30291
+ * any other browser.
30292
+ */
30293
+ browserBinding: string().optional()
27744
30294
  });
27745
30295
  method(object({
27746
30296
  claims: SsoBridgeClaimsSchema,
@@ -33207,6 +35757,9 @@ var CreateIntegrationInputSchema = object({
33207
35757
  enabled: boolean().optional(),
33208
35758
  info: record(string(), unknown()).optional(),
33209
35759
  settings: record(string(), unknown()).optional(),
35760
+ /** Keys of `settings` the form's schema declares secret (by type) — kept in
35761
+ * the keychain, not the table (D787). */
35762
+ secretKeys: array(string()).optional(),
33210
35763
  skipRestart: boolean().optional()
33211
35764
  });
33212
35765
  var UpdateIntegrationInputSchema = object({
@@ -33230,7 +35783,9 @@ method(_void(), array(IntegrationWithStateSchema)), method(object({ id: string()
33230
35783
  auth: "admin"
33231
35784
  }), method(object({ id: string() }), record(string(), unknown()), { auth: "admin" }), method(object({
33232
35785
  id: string(),
33233
- settings: record(string(), unknown())
35786
+ settings: record(string(), unknown()),
35787
+ /** Keys the form's schema declares secret (by type) — keychain-stored (D787). */
35788
+ secretKeys: array(string()).optional()
33234
35789
  }), object({ success: boolean() }), {
33235
35790
  kind: "mutation",
33236
35791
  auth: "admin"
@@ -40002,16 +42557,6 @@ var ApiKeySummarySchema = object({
40002
42557
  createdAt: number(),
40003
42558
  lastUsedAt: number().optional()
40004
42559
  });
40005
- var CreateApiKeyInputSchema = object({
40006
- label: string(),
40007
- isAdmin: boolean().default(false),
40008
- allowedProviders: union([array(string()), literal("*")]).optional(),
40009
- allowedDevices: record(string(), union([array(string()), literal("*")])).optional()
40010
- });
40011
- var CreateApiKeyResultSchema = object({
40012
- token: string(),
40013
- record: ApiKeySummarySchema
40014
- });
40015
42560
  var ScopedTokenSummarySchema = object({
40016
42561
  id: string(),
40017
42562
  userId: string(),
@@ -40110,17 +42655,10 @@ method(_void(), array(UserSummarySchema), { auth: "admin" }), method(CreateUserI
40110
42655
  }), UserSummarySchema.extend({ passwordHash: string() }).nullable(), {
40111
42656
  kind: "mutation",
40112
42657
  access: "view"
40113
- }), method(_void(), array(ApiKeySummarySchema), { auth: "admin" }), method(CreateApiKeyInputSchema, CreateApiKeyResultSchema, {
40114
- kind: "mutation",
40115
- auth: "admin",
40116
- access: "create"
40117
- }), method(object({ id: string() }), object({ success: literal(true) }), {
42658
+ }), method(_void(), array(ApiKeySummarySchema), { auth: "admin" }), method(object({ id: string() }), object({ success: literal(true) }), {
40118
42659
  kind: "mutation",
40119
42660
  auth: "admin",
40120
42661
  access: "delete"
40121
- }), method(object({ token: string() }), ApiKeySummarySchema.nullable(), {
40122
- kind: "mutation",
40123
- access: "view"
40124
42662
  }), method(CreateScopedTokenInputSchema, CreateScopedTokenResultSchema, {
40125
42663
  kind: "mutation",
40126
42664
  auth: "admin",
@@ -40194,15 +42732,7 @@ method(_void(), array(UserSummarySchema), { auth: "admin" }), method(CreateUserI
40194
42732
  }).nullable(), { access: "view" }), method(object({ userId: string() }), array(ExternalIdentitySchema), { auth: "admin" }), method(ExternalIdentityKeySchema, object({
40195
42733
  userId: string(),
40196
42734
  issuer: string()
40197
- }).nullable(), { auth: "admin" }), method(ExternalIdentityKeySchema.extend({
40198
- userId: string(),
40199
- issuer: string().min(1),
40200
- label: string().optional()
40201
- }), object({ success: literal(true) }), {
40202
- kind: "mutation",
40203
- auth: "admin",
40204
- access: "create"
40205
- }), method(ExternalIdentityKeySchema.extend({ userId: string() }), object({ success: boolean() }), {
42735
+ }).nullable(), { auth: "admin" }), method(ExternalIdentityKeySchema.extend({ userId: string() }), object({ success: boolean() }), {
40206
42736
  kind: "mutation",
40207
42737
  auth: "admin",
40208
42738
  access: "delete"
@@ -40907,6 +43437,451 @@ var zoneRulesCapability = {
40907
43437
  */
40908
43438
  durability: "restored"
40909
43439
  };
43440
+ /**
43441
+ * `training-provider` — ONE cloud that can run the CamStack trainer.
43442
+ *
43443
+ * A thin, mockable translation layer: it knows how to run a container with a
43444
+ * GPU, move a dataset in, read the job's stdout and hand artefacts back. It
43445
+ * knows nothing about datasets, splits, floors, cost policy or Model Studio —
43446
+ * those are the `training` orchestrator's (D805). Every rule written there
43447
+ * once is what makes a second provider (RunPod, a local NVIDIA node) a new
43448
+ * manifest entry and nothing else.
43449
+ *
43450
+ * Collection, routed by the `addonId` in every single-row input (the `llm` /
43451
+ * `notification-output` posture); `describe` concat-fans across providers.
43452
+ * Every method is `admin`: these spend money.
43453
+ *
43454
+ * Every cloud object a provider creates is tagged with the orchestrator's
43455
+ * `jobKey`, so a retried submit finds the job it already started instead of
43456
+ * starting a second GPU, and `listJobs` can find orphans.
43457
+ *
43458
+ * Bytes never ride a cap field: the dataset arrives as a `ctx.peerBytes`
43459
+ * ticket the producer (pipeline-analytics) minted, and artefacts leave as a
43460
+ * ticket the provider mints (D613).
43461
+ */
43462
+ var TrainingGpuOptionSchema = object({
43463
+ id: string(),
43464
+ label: string(),
43465
+ /** List price, USD per GPU-hour, before any region multiplier. */
43466
+ usdPerHour: number().nonnegative(),
43467
+ vramGb: number().nonnegative()
43468
+ });
43469
+ var TrainingRegionOptionSchema = object({
43470
+ /** `''` = any region (the provider's choice). */
43471
+ id: string(),
43472
+ label: string(),
43473
+ priceMultiplier: number().positive()
43474
+ });
43475
+ /**
43476
+ * The provider's per-account settings, as the orchestrator reads them. They
43477
+ * live in the PROVIDER addon's settings (operator decision 2026-10-08: they
43478
+ * depend on the user's account), never hard-coded in the orchestrator.
43479
+ */
43480
+ var TrainingProviderDefaultsSchema = object({
43481
+ gpuType: string(),
43482
+ region: string(),
43483
+ costCapUsd: number().nonnegative(),
43484
+ maxRuntimeSec: number().int().positive(),
43485
+ /** Hours a FAILED job's cloud dataset is kept for debugging; 0 = delete at once. */
43486
+ failedDatasetGraceHours: number().nonnegative()
43487
+ });
43488
+ var TrainingProviderDescriptorSchema = object({
43489
+ addonId: string(),
43490
+ /** `modal`, `runpod`, `fake`, … */
43491
+ kind: string(),
43492
+ label: string(),
43493
+ gpuTypes: array(TrainingGpuOptionSchema).readonly(),
43494
+ regions: array(TrainingRegionOptionSchema).readonly(),
43495
+ maxDatasetBytes: number().int().positive(),
43496
+ maxRuntimeSec: number().int().positive(),
43497
+ freeTierNote: string().optional(),
43498
+ /** Where the data goes, in one sentence the confirm dialog repeats. */
43499
+ dataResidencyNote: string(),
43500
+ /** Credentials are present — never the values. */
43501
+ configured: boolean(),
43502
+ defaults: TrainingProviderDefaultsSchema
43503
+ });
43504
+ var TrainingCredentialCheckSchema = object({
43505
+ ok: boolean(),
43506
+ /** Workspace / account name, when the provider says. */
43507
+ account: string().optional(),
43508
+ reason: _enum([
43509
+ "missing",
43510
+ "invalid",
43511
+ "forbidden",
43512
+ "network",
43513
+ "quota"
43514
+ ]).optional(),
43515
+ detail: string().optional()
43516
+ });
43517
+ var ProviderJobStateSchema = _enum([
43518
+ "pending",
43519
+ "starting",
43520
+ "running",
43521
+ "succeeded",
43522
+ "failed",
43523
+ "cancelled",
43524
+ "lost"
43525
+ ]);
43526
+ var ProviderJobStatusSchema = object({
43527
+ jobKey: string(),
43528
+ providerJobId: string().optional(),
43529
+ state: ProviderJobStateSchema,
43530
+ startedAt: number().optional(),
43531
+ endedAt: number().optional(),
43532
+ exitCode: number().int().optional(),
43533
+ failureReason: string().optional(),
43534
+ gpuType: string(),
43535
+ region: string().optional(),
43536
+ billedSeconds: number().nonnegative(),
43537
+ costUsd: number().nonnegative(),
43538
+ /** True when `costUsd` is runtime × list price, not a billing answer. */
43539
+ costIsEstimate: boolean(),
43540
+ lastFetchedAt: number()
43541
+ });
43542
+ /**
43543
+ * The trainer the job runs, by SOURCE revision: the provider turns it into an
43544
+ * image its own way (Modal builds the published Dockerfile at that revision;
43545
+ * a registry-pull provider maps it to a tag). Recorded on the job and echoed
43546
+ * in `result.json`.
43547
+ */
43548
+ var TrainerSourceRefSchema = object({
43549
+ /** Hugging Face repo id, e.g. `camstack/camstack-trainer`. */
43550
+ repo: string().min(1),
43551
+ /** A commit sha (never a branch) — the job must be reproducible. */
43552
+ revision: string().regex(/^[0-9a-f]{7,64}$/)
43553
+ });
43554
+ var JobRef = {
43555
+ addonId: string(),
43556
+ jobKey: string().uuid()
43557
+ };
43558
+ var TrainingLogLineSchema = object({
43559
+ ts: number(),
43560
+ text: string()
43561
+ });
43562
+ method(object({}), array(TrainingProviderDescriptorSchema).readonly(), { auth: "admin" }), method(object({ addonId: string() }), TrainingCredentialCheckSchema, {
43563
+ kind: "mutation",
43564
+ auth: "admin",
43565
+ timeoutMs: 3e4
43566
+ }), method(object({
43567
+ addonId: string(),
43568
+ gpuType: string(),
43569
+ region: string(),
43570
+ datasetBytes: number().int().nonnegative(),
43571
+ gpuSecondsLow: number().nonnegative(),
43572
+ gpuSecondsHigh: number().nonnegative()
43573
+ }), object({
43574
+ usdLow: number().nonnegative(),
43575
+ usdHigh: number().nonnegative(),
43576
+ notes: array(string()).readonly()
43577
+ }), { auth: "admin" }), method(object({
43578
+ ...JobRef,
43579
+ ticket: PeerBytesTicketSchema
43580
+ }), object({
43581
+ bytes: number().int().nonnegative(),
43582
+ sha256: string()
43583
+ }), {
43584
+ kind: "mutation",
43585
+ auth: "admin",
43586
+ timeoutMs: 120 * 6e4
43587
+ }), method(object({
43588
+ ...JobRef,
43589
+ trainer: TrainerSourceRefSchema,
43590
+ jobSpecJson: string().min(2).max(64e3),
43591
+ gpuType: string(),
43592
+ region: string(),
43593
+ maxRuntimeSec: number().int().positive()
43594
+ }), ProviderJobStatusSchema, {
43595
+ kind: "mutation",
43596
+ auth: "admin",
43597
+ timeoutMs: 30 * 6e4
43598
+ }), method(object(JobRef), ProviderJobStatusSchema, {
43599
+ auth: "admin",
43600
+ timeoutMs: 6e4
43601
+ }), method(object({
43602
+ ...JobRef,
43603
+ cursor: string().optional(),
43604
+ max: number().int().min(1).max(500)
43605
+ }), object({
43606
+ lines: array(TrainingLogLineSchema).readonly(),
43607
+ cursor: string()
43608
+ }), {
43609
+ auth: "admin",
43610
+ timeoutMs: 6e4
43611
+ }), method(object(JobRef), object({ ok: literal(true) }), {
43612
+ kind: "mutation",
43613
+ auth: "admin",
43614
+ timeoutMs: 6e4
43615
+ }), method(object(JobRef), object({
43616
+ found: boolean(),
43617
+ text: string().optional()
43618
+ }), {
43619
+ kind: "mutation",
43620
+ auth: "admin",
43621
+ timeoutMs: 5 * 6e4
43622
+ }), method(object({
43623
+ ...JobRef,
43624
+ path: _enum(["bundle.tar"])
43625
+ }), object({ ticket: PeerBytesTicketSchema }), {
43626
+ kind: "mutation",
43627
+ auth: "admin",
43628
+ timeoutMs: 5 * 6e4
43629
+ }), method(object(JobRef), object({ deleted: array(string()).readonly() }), {
43630
+ kind: "mutation",
43631
+ auth: "admin",
43632
+ timeoutMs: 5 * 6e4
43633
+ }), method(object({ addonId: string() }), array(ProviderJobStatusSchema).readonly(), {
43634
+ auth: "admin",
43635
+ timeoutMs: 2 * 6e4
43636
+ });
43637
+ /**
43638
+ * `training` — the cloud-training orchestrator (D805). Hub-only singleton,
43639
+ * provided by `addon-training`.
43640
+ *
43641
+ * It owns what every provider must agree on, written once:
43642
+ *
43643
+ * - **Dataset versions.** Taken over from pipeline-analytics (D796): the rows
43644
+ * live here (D808); pipeline-analytics still CUTS a version (it owns the corpus and
43645
+ * the export plan) and reaches this store through the five row methods
43646
+ * below, so the Retrain page and the export did not change.
43647
+ * - **Jobs.** A persisted state machine, a reconcile loop against the
43648
+ * provider, a cost guard, a daily orphan sweep and the retention rules.
43649
+ * - **The return flow.** Verified artefacts → Model Studio
43650
+ * (`custom-model-registry.importModelBundle`) → canary on cameras →
43651
+ * rollback. Nothing is ever registered automatically.
43652
+ *
43653
+ * Every method is `admin`.
43654
+ */
43655
+ /** A version WITH its frame list — what the export and a job read. */
43656
+ var TrainingDatasetVersionRowSchema = RetrainDatasetVersionSchema.omit({ frameCount: true }).extend({ frameIds: array(string()).max(2e4).readonly() });
43657
+ /** A base model a detector job can fine-tune, and the baseline it is judged against. */
43658
+ var TrainingBaseModelSchema = object({
43659
+ modelId: string(),
43660
+ label: string(),
43661
+ weights: string(),
43662
+ imgsz: number().int(),
43663
+ baselineOnnxUrl: string(),
43664
+ baselineFloors: record(string(), number()),
43665
+ /** The base the fleet runs most — the UI's default. */
43666
+ recommended: boolean()
43667
+ });
43668
+ var TrainingPresetSchema = _enum([
43669
+ "quick",
43670
+ "standard",
43671
+ "thorough"
43672
+ ]);
43673
+ var TrainingJobRequestSchema = object({
43674
+ datasetVersionId: string().min(1),
43675
+ /** The `training-provider` addon that runs it. */
43676
+ addonId: string().min(1),
43677
+ gpuType: string().min(1),
43678
+ region: string(),
43679
+ baseModelId: string().min(1),
43680
+ preset: TrainingPresetSchema,
43681
+ /** Freeze the backbone's first N layers; `null` = the preset's choice. */
43682
+ freeze: number().int().nonnegative().nullable(),
43683
+ /** Cameras held out whole for evaluation; `null` = the orchestrator's default. */
43684
+ holdoutCameras: array(number().int()).nullable()
43685
+ });
43686
+ var TrainingSplitPlanSchema = object({
43687
+ holdoutCameras: array(number().int()).readonly(),
43688
+ /** Used when no camera is held out: the last N days of every camera. */
43689
+ holdoutLastDays: number().int().nonnegative(),
43690
+ /** Holdout subjects per class (camera holdout only; `null` = known only after the split). */
43691
+ holdoutSupport: record(string(), number().int()).nullable(),
43692
+ trainSubjects: number().int()
43693
+ });
43694
+ var TrainingRefusalReasonSchema = _enum([
43695
+ "unknown-dataset",
43696
+ "unknown-provider",
43697
+ "provider-not-configured",
43698
+ "unknown-base-model",
43699
+ "unknown-gpu",
43700
+ "dataset-too-large",
43701
+ "no-training-subjects",
43702
+ "job-already-running"
43703
+ ]);
43704
+ var TrainingJobPlanSchema = object({
43705
+ refusal: object({
43706
+ reason: TrainingRefusalReasonSchema,
43707
+ detail: string()
43708
+ }).nullable(),
43709
+ warnings: array(string()).readonly(),
43710
+ split: TrainingSplitPlanSchema.nullable(),
43711
+ estimate: object({
43712
+ datasetBytes: number().int(),
43713
+ uploadMinutesAt20Mbps: number(),
43714
+ gpuSecondsLow: number(),
43715
+ gpuSecondsHigh: number(),
43716
+ usdLow: number(),
43717
+ usdHigh: number(),
43718
+ notes: array(string()).readonly()
43719
+ }).nullable(),
43720
+ /** Pre-filled from the provider's settings; the operator may lower or raise them. */
43721
+ defaults: object({
43722
+ maxCostUsd: number(),
43723
+ maxRuntimeSec: number().int()
43724
+ }).nullable(),
43725
+ /** The sentence the confirm dialog repeats: where the frames go and when they are deleted. */
43726
+ dataNotice: string()
43727
+ });
43728
+ /**
43729
+ * Orchestrator-owned states, persisted. `uploading` covers exporting the
43730
+ * archive (it is streamed, never staged). Terminal: `failed`, `cancelled`,
43731
+ * `lost`, `expired`, `discarded`. `registered` and `canary` are where a
43732
+ * result lives after the operator acted on it.
43733
+ */
43734
+ var TrainingJobStateSchema = _enum([
43735
+ "uploading",
43736
+ "submitted",
43737
+ "starting",
43738
+ "running",
43739
+ "collecting",
43740
+ "ready",
43741
+ "registered",
43742
+ "canary",
43743
+ "failed",
43744
+ "cancelling",
43745
+ "cancelled",
43746
+ "lost",
43747
+ "expired",
43748
+ "discarded"
43749
+ ]);
43750
+ var TrainingFailureReasonSchema = _enum([
43751
+ "cost-cap",
43752
+ "runtime-cap",
43753
+ "upload-failed",
43754
+ "submit-failed",
43755
+ "trainer-failed",
43756
+ "result-invalid",
43757
+ "checksum-mismatch",
43758
+ "fetch-failed",
43759
+ "provider-error",
43760
+ "hub-restart-during-upload"
43761
+ ]);
43762
+ var TrainingProgressPointSchema = object({
43763
+ epoch: number().int(),
43764
+ map50: number().nullable(),
43765
+ map50_95: number().nullable()
43766
+ });
43767
+ var TrainingCanarySchema = object({
43768
+ deviceIds: array(number().int()).readonly(),
43769
+ since: number(),
43770
+ /** Every override the canary replaced, exactly, so rollback restores it. */
43771
+ previous: array(object({
43772
+ deviceId: number().int(),
43773
+ nodeId: string(),
43774
+ deviceKey: string(),
43775
+ patch: object({
43776
+ modelId: string().optional(),
43777
+ settings: record(string(), unknown()).readonly().optional()
43778
+ }).nullable()
43779
+ })).readonly()
43780
+ });
43781
+ var TrainingJobSchema = object({
43782
+ id: string(),
43783
+ idempotencyKey: string(),
43784
+ name: string(),
43785
+ createdAt: number(),
43786
+ updatedAt: number(),
43787
+ state: TrainingJobStateSchema,
43788
+ stage: TrainingStageSchema.nullable(),
43789
+ failure: object({
43790
+ reason: TrainingFailureReasonSchema,
43791
+ stage: string().nullable(),
43792
+ detail: string()
43793
+ }).nullable(),
43794
+ request: TrainingJobRequestSchema,
43795
+ maxCostUsd: number().nonnegative(),
43796
+ maxRuntimeSec: number().int().positive(),
43797
+ trainer: TrainerSourceRefSchema,
43798
+ datasetLayout: RetrainExportLayoutSchema,
43799
+ dataset: object({
43800
+ bytes: number().int(),
43801
+ sha256: string(),
43802
+ uploadedAt: number()
43803
+ }).nullable(),
43804
+ split: TrainingSplitPlanSchema,
43805
+ provider: object({
43806
+ state: ProviderJobStateSchema.nullable(),
43807
+ providerJobId: string().nullable(),
43808
+ startedAt: number().nullable(),
43809
+ endedAt: number().nullable(),
43810
+ billedSeconds: number(),
43811
+ costUsd: number(),
43812
+ costIsEstimate: boolean(),
43813
+ lastPolledAt: number().nullable()
43814
+ }),
43815
+ progress: object({
43816
+ epoch: number().int().nullable(),
43817
+ epochs: number().int().nullable(),
43818
+ etaSec: number().nullable(),
43819
+ series: array(TrainingProgressPointSchema).readonly()
43820
+ }),
43821
+ /** The last lines of the job's output (≤ 200), newest last. Never frame paths. */
43822
+ logTail: array(string()).readonly(),
43823
+ logCursor: string().nullable(),
43824
+ artifacts: object({
43825
+ bundleBytes: number().int(),
43826
+ bundleSha256: string(),
43827
+ fetchedAt: number(),
43828
+ /** When the staged artefacts are deleted from the hub. */
43829
+ expiresAt: number()
43830
+ }).nullable(),
43831
+ /** When the provider-side copy of the frames was deleted; null while it exists. */
43832
+ cloudDatasetDeletedAt: number().nullable(),
43833
+ /** A failed job's dataset is kept until then (the provider's grace), then deleted. */
43834
+ cloudCleanupDueAt: number().nullable(),
43835
+ /** Model ids registered from this job (base, and int8 when kept). */
43836
+ registeredModelIds: array(string()).readonly(),
43837
+ canary: TrainingCanarySchema.nullable()
43838
+ });
43839
+ var IdInput = object({ id: string().min(1) });
43840
+ method(TrainingDatasetVersionRowSchema, object({ stored: boolean() }), {
43841
+ kind: "mutation",
43842
+ auth: "admin"
43843
+ }), 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() }), {
43844
+ kind: "mutation",
43845
+ auth: "admin"
43846
+ }), method(object({}), array(TrainingBaseModelSchema).readonly(), { auth: "admin" }), method(TrainingJobRequestSchema, TrainingJobPlanSchema, {
43847
+ auth: "admin",
43848
+ timeoutMs: 6e4
43849
+ }), method(TrainingJobRequestSchema.extend({
43850
+ name: string().min(1).max(120),
43851
+ maxCostUsd: number().positive(),
43852
+ maxRuntimeSec: number().int().positive(),
43853
+ idempotencyKey: string().min(8).max(80)
43854
+ }), discriminatedUnion("kind", [object({
43855
+ kind: literal("started"),
43856
+ job: TrainingJobSchema
43857
+ }), object({
43858
+ kind: literal("refused"),
43859
+ reason: TrainingRefusalReasonSchema,
43860
+ detail: string()
43861
+ })]), {
43862
+ kind: "mutation",
43863
+ auth: "admin",
43864
+ timeoutMs: 12e4
43865
+ }), method(object({}), array(TrainingJobSchema).readonly(), { auth: "admin" }), method(IdInput, TrainingJobSchema.nullable(), { auth: "admin" }), method(IdInput, TrainingJobSchema, {
43866
+ kind: "mutation",
43867
+ auth: "admin",
43868
+ timeoutMs: 12e4
43869
+ }), method(IdInput, TrainingResultSchema.nullable(), { auth: "admin" }), method(IdInput.extend({ canaryDeviceIds: array(number().int()).readonly() }), TrainingJobSchema, {
43870
+ kind: "mutation",
43871
+ auth: "admin",
43872
+ timeoutMs: 30 * 6e4
43873
+ }), method(IdInput.extend({ deviceIds: array(number().int()).min(1).readonly() }), TrainingJobSchema, {
43874
+ kind: "mutation",
43875
+ auth: "admin",
43876
+ timeoutMs: 12e4
43877
+ }), method(IdInput, TrainingJobSchema, {
43878
+ kind: "mutation",
43879
+ auth: "admin",
43880
+ timeoutMs: 12e4
43881
+ }), method(IdInput, TrainingJobSchema, {
43882
+ kind: "mutation",
43883
+ auth: "admin"
43884
+ });
40910
43885
  SOURCE_CAPS.filter((cap) => cap !== "switch" && cap !== "motion");
40911
43886
  Object.freeze({
40912
43887
  person: .5,
@@ -41393,7 +44368,8 @@ var BaseDevice = class {
41393
44368
  this.role = options.role;
41394
44369
  this.parentDeviceId = ctx.parentDeviceId;
41395
44370
  const seedData = ctx.persistedConfig ?? {};
41396
- this.config = DeviceConfig.fromSchema(schema, (data) => ctx.persistConfig(data), seedData, ({ droppedKeys, issues }) => {
44371
+ const declaredSecretPaths = collectZodSecretPaths(schema);
44372
+ this.config = DeviceConfig.fromSchema(schema, (data) => ctx.persistConfig(data, { secretConfigPaths: declaredSecretPaths }), seedData, ({ droppedKeys, issues }) => {
41397
44373
  ctx.logger.warn("Device config recovery: dropping invalid persisted fields", {
41398
44374
  tags: {
41399
44375
  deviceId: ctx.id,
@@ -43054,6 +46030,12 @@ Object.freeze({
43054
46030
  addonId: null,
43055
46031
  access: "create"
43056
46032
  },
46033
+ "backup.checkBackupKey": {
46034
+ capName: "backup",
46035
+ capScope: "system",
46036
+ addonId: null,
46037
+ access: "create"
46038
+ },
43057
46039
  "backup.delete": {
43058
46040
  capName: "backup",
43059
46041
  capScope: "system",
@@ -43066,6 +46048,18 @@ Object.freeze({
43066
46048
  addonId: null,
43067
46049
  access: "delete"
43068
46050
  },
46051
+ "backup.disableEncryption": {
46052
+ capName: "backup",
46053
+ capScope: "system",
46054
+ addonId: null,
46055
+ access: "create"
46056
+ },
46057
+ "backup.getEncryption": {
46058
+ capName: "backup",
46059
+ capScope: "system",
46060
+ addonId: null,
46061
+ access: "view"
46062
+ },
43069
46063
  "backup.getEntries": {
43070
46064
  capName: "backup",
43071
46065
  capScope: "system",
@@ -43120,6 +46114,12 @@ Object.freeze({
43120
46114
  addonId: null,
43121
46115
  access: "create"
43122
46116
  },
46117
+ "backup.setupEncryption": {
46118
+ capName: "backup",
46119
+ capScope: "system",
46120
+ addonId: null,
46121
+ access: "create"
46122
+ },
43123
46123
  "backup.trigger": {
43124
46124
  capName: "backup",
43125
46125
  capScope: "system",
@@ -43672,6 +46672,12 @@ Object.freeze({
43672
46672
  addonId: null,
43673
46673
  access: "create"
43674
46674
  },
46675
+ "customModelRegistry.importModelBundle": {
46676
+ capName: "custom-model-registry",
46677
+ capScope: "system",
46678
+ addonId: null,
46679
+ access: "create"
46680
+ },
43675
46681
  "customModelRegistry.listModels": {
43676
46682
  capName: "custom-model-registry",
43677
46683
  capScope: "system",
@@ -45082,6 +48088,108 @@ Object.freeze({
45082
48088
  addonId: null,
45083
48089
  access: "create"
45084
48090
  },
48091
+ "keychain.delete": {
48092
+ capName: "keychain",
48093
+ capScope: "system",
48094
+ addonId: null,
48095
+ access: "delete"
48096
+ },
48097
+ "keychain.getState": {
48098
+ capName: "keychain",
48099
+ capScope: "system",
48100
+ addonId: null,
48101
+ access: "view"
48102
+ },
48103
+ "keychain.listMeta": {
48104
+ capName: "keychain",
48105
+ capScope: "system",
48106
+ addonId: null,
48107
+ access: "view"
48108
+ },
48109
+ "keychain.put": {
48110
+ capName: "keychain",
48111
+ capScope: "system",
48112
+ addonId: null,
48113
+ access: "create"
48114
+ },
48115
+ "keychain.resolve": {
48116
+ capName: "keychain",
48117
+ capScope: "system",
48118
+ addonId: null,
48119
+ access: "view"
48120
+ },
48121
+ "keychainAdmin.acknowledgeReset": {
48122
+ capName: "keychain-admin",
48123
+ capScope: "system",
48124
+ addonId: null,
48125
+ access: "create"
48126
+ },
48127
+ "keychainAdmin.deleteOrphans": {
48128
+ capName: "keychain-admin",
48129
+ capScope: "system",
48130
+ addonId: null,
48131
+ access: "delete"
48132
+ },
48133
+ "keychainAdmin.downloadRecoveryKey": {
48134
+ capName: "keychain-admin",
48135
+ capScope: "system",
48136
+ addonId: null,
48137
+ access: "create"
48138
+ },
48139
+ "keychainAdmin.listAudit": {
48140
+ capName: "keychain-admin",
48141
+ capScope: "system",
48142
+ addonId: null,
48143
+ access: "view"
48144
+ },
48145
+ "keychainAdmin.listSecrets": {
48146
+ capName: "keychain-admin",
48147
+ capScope: "system",
48148
+ addonId: null,
48149
+ access: "view"
48150
+ },
48151
+ "keychainAdmin.purgeRetiredKeys": {
48152
+ capName: "keychain-admin",
48153
+ capScope: "system",
48154
+ addonId: null,
48155
+ access: "delete"
48156
+ },
48157
+ "keychainAdmin.resetKeychain": {
48158
+ capName: "keychain-admin",
48159
+ capScope: "system",
48160
+ addonId: null,
48161
+ access: "delete"
48162
+ },
48163
+ "keychainAdmin.resetReport": {
48164
+ capName: "keychain-admin",
48165
+ capScope: "system",
48166
+ addonId: null,
48167
+ access: "delete"
48168
+ },
48169
+ "keychainAdmin.reveal": {
48170
+ capName: "keychain-admin",
48171
+ capScope: "system",
48172
+ addonId: null,
48173
+ access: "create"
48174
+ },
48175
+ "keychainAdmin.rotateMasterKey": {
48176
+ capName: "keychain-admin",
48177
+ capScope: "system",
48178
+ addonId: null,
48179
+ access: "create"
48180
+ },
48181
+ "keychainAdmin.setSystemSecret": {
48182
+ capName: "keychain-admin",
48183
+ capScope: "system",
48184
+ addonId: null,
48185
+ access: "create"
48186
+ },
48187
+ "keychainAdmin.status": {
48188
+ capName: "keychain-admin",
48189
+ capScope: "system",
48190
+ addonId: null,
48191
+ access: "view"
48192
+ },
45085
48193
  "lawnMowerControl.dock": {
45086
48194
  capName: "lawn-mower-control",
45087
48195
  capScope: "device",
@@ -46456,6 +49564,18 @@ Object.freeze({
46456
49564
  addonId: null,
46457
49565
  access: "create"
46458
49566
  },
49567
+ "pipelineAnalytics.addRetrainFrameFromRecording": {
49568
+ capName: "pipeline-analytics",
49569
+ capScope: "device",
49570
+ addonId: null,
49571
+ access: "create"
49572
+ },
49573
+ "pipelineAnalytics.addRetrainFramesToCollection": {
49574
+ capName: "pipeline-analytics",
49575
+ capScope: "device",
49576
+ addonId: null,
49577
+ access: "create"
49578
+ },
46459
49579
  "pipelineAnalytics.applyDeviceSettingsPatch": {
46460
49580
  capName: "pipeline-analytics",
46461
49581
  capScope: "device",
@@ -46504,12 +49624,36 @@ Object.freeze({
46504
49624
  addonId: null,
46505
49625
  access: "view"
46506
49626
  },
49627
+ "pipelineAnalytics.createRetrainCollection": {
49628
+ capName: "pipeline-analytics",
49629
+ capScope: "device",
49630
+ addonId: null,
49631
+ access: "create"
49632
+ },
49633
+ "pipelineAnalytics.createRetrainDatasetVersion": {
49634
+ capName: "pipeline-analytics",
49635
+ capScope: "device",
49636
+ addonId: null,
49637
+ access: "create"
49638
+ },
46507
49639
  "pipelineAnalytics.deleteDeviceEvents": {
46508
49640
  capName: "pipeline-analytics",
46509
49641
  capScope: "device",
46510
49642
  addonId: null,
46511
49643
  access: "delete"
46512
49644
  },
49645
+ "pipelineAnalytics.deleteRetrainCollection": {
49646
+ capName: "pipeline-analytics",
49647
+ capScope: "device",
49648
+ addonId: null,
49649
+ access: "delete"
49650
+ },
49651
+ "pipelineAnalytics.deleteRetrainDatasetVersion": {
49652
+ capName: "pipeline-analytics",
49653
+ capScope: "device",
49654
+ addonId: null,
49655
+ access: "delete"
49656
+ },
46513
49657
  "pipelineAnalytics.deleteTracks": {
46514
49658
  capName: "pipeline-analytics",
46515
49659
  capScope: "device",
@@ -46714,6 +49858,30 @@ Object.freeze({
46714
49858
  addonId: null,
46715
49859
  access: "view"
46716
49860
  },
49861
+ "pipelineAnalytics.listRetrainAssistProfiles": {
49862
+ capName: "pipeline-analytics",
49863
+ capScope: "device",
49864
+ addonId: null,
49865
+ access: "view"
49866
+ },
49867
+ "pipelineAnalytics.listRetrainCollectionFrames": {
49868
+ capName: "pipeline-analytics",
49869
+ capScope: "device",
49870
+ addonId: null,
49871
+ access: "view"
49872
+ },
49873
+ "pipelineAnalytics.listRetrainCollections": {
49874
+ capName: "pipeline-analytics",
49875
+ capScope: "device",
49876
+ addonId: null,
49877
+ access: "view"
49878
+ },
49879
+ "pipelineAnalytics.listRetrainDatasetVersions": {
49880
+ capName: "pipeline-analytics",
49881
+ capScope: "device",
49882
+ addonId: null,
49883
+ access: "view"
49884
+ },
46717
49885
  "pipelineAnalytics.listRetrainFrames": {
46718
49886
  capName: "pipeline-analytics",
46719
49887
  capScope: "device",
@@ -46744,6 +49912,12 @@ Object.freeze({
46744
49912
  addonId: null,
46745
49913
  access: "view"
46746
49914
  },
49915
+ "pipelineAnalytics.offerRetrainArchive": {
49916
+ capName: "pipeline-analytics",
49917
+ capScope: "device",
49918
+ addonId: null,
49919
+ access: "create"
49920
+ },
46747
49921
  "pipelineAnalytics.ownersWithMedia": {
46748
49922
  capName: "pipeline-analytics",
46749
49923
  capScope: "device",
@@ -46756,12 +49930,24 @@ Object.freeze({
46756
49930
  addonId: null,
46757
49931
  access: "create"
46758
49932
  },
49933
+ "pipelineAnalytics.previewRetrainDataset": {
49934
+ capName: "pipeline-analytics",
49935
+ capScope: "device",
49936
+ addonId: null,
49937
+ access: "view"
49938
+ },
46759
49939
  "pipelineAnalytics.proposeRetrainAnnotations": {
46760
49940
  capName: "pipeline-analytics",
46761
49941
  capScope: "device",
46762
49942
  addonId: null,
46763
49943
  access: "create"
46764
49944
  },
49945
+ "pipelineAnalytics.proposeRetrainAnnotationsWithLlm": {
49946
+ capName: "pipeline-analytics",
49947
+ capScope: "device",
49948
+ addonId: null,
49949
+ access: "create"
49950
+ },
46765
49951
  "pipelineAnalytics.pruneEvents": {
46766
49952
  capName: "pipeline-analytics",
46767
49953
  capScope: "device",
@@ -46816,6 +50002,18 @@ Object.freeze({
46816
50002
  addonId: null,
46817
50003
  access: "create"
46818
50004
  },
50005
+ "pipelineAnalytics.removeRetrainFrameFromCollection": {
50006
+ capName: "pipeline-analytics",
50007
+ capScope: "device",
50008
+ addonId: null,
50009
+ access: "delete"
50010
+ },
50011
+ "pipelineAnalytics.renameRetrainCollection": {
50012
+ capName: "pipeline-analytics",
50013
+ capScope: "device",
50014
+ addonId: null,
50015
+ access: "create"
50016
+ },
46819
50017
  "pipelineAnalytics.restageRetrainTrack": {
46820
50018
  capName: "pipeline-analytics",
46821
50019
  capScope: "device",
@@ -46876,6 +50074,12 @@ Object.freeze({
46876
50074
  addonId: null,
46877
50075
  access: "create"
46878
50076
  },
50077
+ "pipelineAnalytics.verifyRetrainDatasetVersion": {
50078
+ capName: "pipeline-analytics",
50079
+ capScope: "device",
50080
+ addonId: null,
50081
+ access: "view"
50082
+ },
46879
50083
  "pipelineAnalytics.wipeAllAnalytics": {
46880
50084
  capName: "pipeline-analytics",
46881
50085
  capScope: "device",
@@ -47104,6 +50308,12 @@ Object.freeze({
47104
50308
  addonId: null,
47105
50309
  access: "view"
47106
50310
  },
50311
+ "pipelineOrchestrator.abortNodeBenchmark": {
50312
+ capName: "pipeline-orchestrator",
50313
+ capScope: "system",
50314
+ addonId: null,
50315
+ access: "create"
50316
+ },
47107
50317
  "pipelineOrchestrator.applyAutoTune": {
47108
50318
  capName: "pipeline-orchestrator",
47109
50319
  capScope: "system",
@@ -47128,6 +50338,12 @@ Object.freeze({
47128
50338
  addonId: null,
47129
50339
  access: "create"
47130
50340
  },
50341
+ "pipelineOrchestrator.deleteNodeBenchmarkResult": {
50342
+ capName: "pipeline-orchestrator",
50343
+ capScope: "system",
50344
+ addonId: null,
50345
+ access: "delete"
50346
+ },
47131
50347
  "pipelineOrchestrator.getAgentLoad": {
47132
50348
  capName: "pipeline-orchestrator",
47133
50349
  capScope: "system",
@@ -47236,6 +50452,24 @@ Object.freeze({
47236
50452
  addonId: null,
47237
50453
  access: "view"
47238
50454
  },
50455
+ "pipelineOrchestrator.getNodeBenchmarkCandidates": {
50456
+ capName: "pipeline-orchestrator",
50457
+ capScope: "system",
50458
+ addonId: null,
50459
+ access: "view"
50460
+ },
50461
+ "pipelineOrchestrator.getNodeBenchmarkPreflight": {
50462
+ capName: "pipeline-orchestrator",
50463
+ capScope: "system",
50464
+ addonId: null,
50465
+ access: "view"
50466
+ },
50467
+ "pipelineOrchestrator.getNodeBenchmarkStatus": {
50468
+ capName: "pipeline-orchestrator",
50469
+ capScope: "system",
50470
+ addonId: null,
50471
+ access: "view"
50472
+ },
47239
50473
  "pipelineOrchestrator.getNodeInferenceDevices": {
47240
50474
  capName: "pipeline-orchestrator",
47241
50475
  capScope: "system",
@@ -47278,6 +50512,12 @@ Object.freeze({
47278
50512
  addonId: null,
47279
50513
  access: "view"
47280
50514
  },
50515
+ "pipelineOrchestrator.listNodeBenchmarkResults": {
50516
+ capName: "pipeline-orchestrator",
50517
+ capScope: "system",
50518
+ addonId: null,
50519
+ access: "view"
50520
+ },
47281
50521
  "pipelineOrchestrator.pauseForStorageMigration": {
47282
50522
  capName: "pipeline-orchestrator",
47283
50523
  capScope: "system",
@@ -47422,6 +50662,12 @@ Object.freeze({
47422
50662
  addonId: null,
47423
50663
  access: "create"
47424
50664
  },
50665
+ "pipelineOrchestrator.startNodeBenchmark": {
50666
+ capName: "pipeline-orchestrator",
50667
+ capScope: "system",
50668
+ addonId: null,
50669
+ access: "create"
50670
+ },
47425
50671
  "pipelineOrchestrator.suggestShares": {
47426
50672
  capName: "pipeline-orchestrator",
47427
50673
  capScope: "system",
@@ -47440,6 +50686,12 @@ Object.freeze({
47440
50686
  addonId: null,
47441
50687
  access: "create"
47442
50688
  },
50689
+ "pipelineRunner.abortNodeBench": {
50690
+ capName: "pipeline-runner",
50691
+ capScope: "system",
50692
+ addonId: null,
50693
+ access: "create"
50694
+ },
47443
50695
  "pipelineRunner.attachCamera": {
47444
50696
  capName: "pipeline-runner",
47445
50697
  capScope: "system",
@@ -47488,6 +50740,12 @@ Object.freeze({
47488
50740
  addonId: null,
47489
50741
  access: "view"
47490
50742
  },
50743
+ "pipelineRunner.getNodeBenchStatus": {
50744
+ capName: "pipeline-runner",
50745
+ capScope: "system",
50746
+ addonId: null,
50747
+ access: "view"
50748
+ },
47491
50749
  "pipelineRunner.getParkedTrackFrame": {
47492
50750
  capName: "pipeline-runner",
47493
50751
  capScope: "system",
@@ -47530,6 +50788,12 @@ Object.freeze({
47530
50788
  addonId: null,
47531
50789
  access: "create"
47532
50790
  },
50791
+ "pipelineRunner.startNodeBench": {
50792
+ capName: "pipeline-runner",
50793
+ capScope: "system",
50794
+ addonId: null,
50795
+ access: "create"
50796
+ },
47533
50797
  "plateGallery.assignPlate": {
47534
50798
  capName: "plate-gallery",
47535
50799
  capScope: "system",
@@ -49192,6 +52456,174 @@ Object.freeze({
49192
52456
  addonId: null,
49193
52457
  access: "view"
49194
52458
  },
52459
+ "training.canaryResult": {
52460
+ capName: "training",
52461
+ capScope: "system",
52462
+ addonId: null,
52463
+ access: "create"
52464
+ },
52465
+ "training.cancelJob": {
52466
+ capName: "training",
52467
+ capScope: "system",
52468
+ addonId: null,
52469
+ access: "create"
52470
+ },
52471
+ "training.discardResult": {
52472
+ capName: "training",
52473
+ capScope: "system",
52474
+ addonId: null,
52475
+ access: "create"
52476
+ },
52477
+ "training.findDatasetVersionIdByName": {
52478
+ capName: "training",
52479
+ capScope: "system",
52480
+ addonId: null,
52481
+ access: "view"
52482
+ },
52483
+ "training.getDatasetVersion": {
52484
+ capName: "training",
52485
+ capScope: "system",
52486
+ addonId: null,
52487
+ access: "view"
52488
+ },
52489
+ "training.getJob": {
52490
+ capName: "training",
52491
+ capScope: "system",
52492
+ addonId: null,
52493
+ access: "view"
52494
+ },
52495
+ "training.getJobResult": {
52496
+ capName: "training",
52497
+ capScope: "system",
52498
+ addonId: null,
52499
+ access: "view"
52500
+ },
52501
+ "training.listBaseModels": {
52502
+ capName: "training",
52503
+ capScope: "system",
52504
+ addonId: null,
52505
+ access: "view"
52506
+ },
52507
+ "training.listDatasetVersions": {
52508
+ capName: "training",
52509
+ capScope: "system",
52510
+ addonId: null,
52511
+ access: "view"
52512
+ },
52513
+ "training.listJobs": {
52514
+ capName: "training",
52515
+ capScope: "system",
52516
+ addonId: null,
52517
+ access: "view"
52518
+ },
52519
+ "training.planJob": {
52520
+ capName: "training",
52521
+ capScope: "system",
52522
+ addonId: null,
52523
+ access: "view"
52524
+ },
52525
+ "training.putDatasetVersion": {
52526
+ capName: "training",
52527
+ capScope: "system",
52528
+ addonId: null,
52529
+ access: "create"
52530
+ },
52531
+ "training.registerResult": {
52532
+ capName: "training",
52533
+ capScope: "system",
52534
+ addonId: null,
52535
+ access: "create"
52536
+ },
52537
+ "training.removeDatasetVersion": {
52538
+ capName: "training",
52539
+ capScope: "system",
52540
+ addonId: null,
52541
+ access: "delete"
52542
+ },
52543
+ "training.rollbackCanary": {
52544
+ capName: "training",
52545
+ capScope: "system",
52546
+ addonId: null,
52547
+ access: "create"
52548
+ },
52549
+ "training.startJob": {
52550
+ capName: "training",
52551
+ capScope: "system",
52552
+ addonId: null,
52553
+ access: "create"
52554
+ },
52555
+ "trainingProvider.cancelJob": {
52556
+ capName: "training-provider",
52557
+ capScope: "system",
52558
+ addonId: null,
52559
+ access: "create"
52560
+ },
52561
+ "trainingProvider.cleanupJob": {
52562
+ capName: "training-provider",
52563
+ capScope: "system",
52564
+ addonId: null,
52565
+ access: "create"
52566
+ },
52567
+ "trainingProvider.describe": {
52568
+ capName: "training-provider",
52569
+ capScope: "system",
52570
+ addonId: null,
52571
+ access: "view"
52572
+ },
52573
+ "trainingProvider.estimateJob": {
52574
+ capName: "training-provider",
52575
+ capScope: "system",
52576
+ addonId: null,
52577
+ access: "view"
52578
+ },
52579
+ "trainingProvider.getJob": {
52580
+ capName: "training-provider",
52581
+ capScope: "system",
52582
+ addonId: null,
52583
+ access: "view"
52584
+ },
52585
+ "trainingProvider.listJobEvents": {
52586
+ capName: "training-provider",
52587
+ capScope: "system",
52588
+ addonId: null,
52589
+ access: "view"
52590
+ },
52591
+ "trainingProvider.listJobs": {
52592
+ capName: "training-provider",
52593
+ capScope: "system",
52594
+ addonId: null,
52595
+ access: "view"
52596
+ },
52597
+ "trainingProvider.offerArtifact": {
52598
+ capName: "training-provider",
52599
+ capScope: "system",
52600
+ addonId: null,
52601
+ access: "create"
52602
+ },
52603
+ "trainingProvider.readResult": {
52604
+ capName: "training-provider",
52605
+ capScope: "system",
52606
+ addonId: null,
52607
+ access: "create"
52608
+ },
52609
+ "trainingProvider.submitJob": {
52610
+ capName: "training-provider",
52611
+ capScope: "system",
52612
+ addonId: null,
52613
+ access: "create"
52614
+ },
52615
+ "trainingProvider.uploadDataset": {
52616
+ capName: "training-provider",
52617
+ capScope: "system",
52618
+ addonId: null,
52619
+ access: "create"
52620
+ },
52621
+ "trainingProvider.validateCredentials": {
52622
+ capName: "training-provider",
52623
+ capScope: "system",
52624
+ addonId: null,
52625
+ access: "create"
52626
+ },
49195
52627
  "turnProvider.getTurnServers": {
49196
52628
  capName: "turn-provider",
49197
52629
  capScope: "system",
@@ -49216,12 +52648,6 @@ Object.freeze({
49216
52648
  addonId: null,
49217
52649
  access: "create"
49218
52650
  },
49219
- "userManagement.createApiKey": {
49220
- capName: "user-management",
49221
- capScope: "system",
49222
- addonId: null,
49223
- access: "create"
49224
- },
49225
52651
  "userManagement.createScopedToken": {
49226
52652
  capName: "user-management",
49227
52653
  capScope: "system",
@@ -49258,12 +52684,6 @@ Object.freeze({
49258
52684
  addonId: null,
49259
52685
  access: "view"
49260
52686
  },
49261
- "userManagement.linkExternalIdentity": {
49262
- capName: "user-management",
49263
- capScope: "system",
49264
- addonId: null,
49265
- access: "create"
49266
- },
49267
52687
  "userManagement.listApiKeys": {
49268
52688
  capName: "user-management",
49269
52689
  capScope: "system",
@@ -49366,12 +52786,6 @@ Object.freeze({
49366
52786
  addonId: null,
49367
52787
  access: "create"
49368
52788
  },
49369
- "userManagement.validateApiKey": {
49370
- capName: "user-management",
49371
- capScope: "system",
49372
- addonId: null,
49373
- access: "view"
49374
- },
49375
52789
  "userManagement.validateCredentials": {
49376
52790
  capName: "user-management",
49377
52791
  capScope: "system",
@@ -52459,6 +55873,11 @@ Object.freeze({
52459
55873
  form: "single",
52460
55874
  optional: false
52461
55875
  }],
55876
+ "pipelineAnalytics.addRetrainFrameFromRecording": [{
55877
+ name: "deviceId",
55878
+ form: "single",
55879
+ optional: false
55880
+ }],
52462
55881
  "pipelineAnalytics.applyDeviceSettingsPatch": [{
52463
55882
  name: "deviceId",
52464
55883
  form: "single",
@@ -52649,6 +56068,11 @@ Object.freeze({
52649
56068
  form: "single",
52650
56069
  optional: false
52651
56070
  }],
56071
+ "pipelineAnalytics.proposeRetrainAnnotationsWithLlm": [{
56072
+ name: "deviceId",
56073
+ form: "single",
56074
+ optional: false
56075
+ }],
52652
56076
  "pipelineAnalytics.pruneEventsBefore": [{
52653
56077
  name: "deviceId",
52654
56078
  form: "single",
@@ -53475,6 +56899,11 @@ Object.freeze({
53475
56899
  form: "single",
53476
56900
  optional: false
53477
56901
  }],
56902
+ "training.canaryResult": [{
56903
+ name: "deviceIds",
56904
+ form: "array",
56905
+ optional: false
56906
+ }],
53478
56907
  "update.getStatus": [{
53479
56908
  name: "deviceId",
53480
56909
  form: "single",