@camstack/addon-smtp-nodemailer 1.2.118 → 1.2.120

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.
@@ -36,7 +36,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
36
36
  }) : target, mod));
37
37
  var __toCommonJS = (mod) => __hasOwnProp.call(mod, "module.exports") ? mod["module.exports"] : __copyProps(__defProp({}, "__esModule", { value: true }), mod);
38
38
  //#endregion
39
- //#region ../types/dist/event-category-B_0XEcLF.mjs
39
+ //#region ../types/dist/event-category-DaIZi00R.mjs
40
40
  var EventCategory = /* @__PURE__ */ function(EventCategory) {
41
41
  EventCategory["SystemBoot"] = "system.boot";
42
42
  EventCategory["SystemAddonsReady"] = "system.addons-ready";
@@ -115,6 +115,13 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
115
115
  */
116
116
  EventCategory["AddonLoadFailed"] = "addon.load-failed";
117
117
  /**
118
+ * A keychain value was stored or removed (D787). Carries the ref, its
119
+ * owner and the new version — NEVER the value. A process holding the ref
120
+ * drops its cached copy and the owning `BaseAddon` re-resolves its config.
121
+ * Telemetry (D8): a process that misses it still revalidates by version.
122
+ */
123
+ EventCategory["KeychainChanged"] = "keychain.changed";
124
+ /**
118
125
  * Addon recovered from a previous failure. Emitted when an addon
119
126
  * transitions from `failed` back to `healthy` (typically via the
120
127
  * monitor's auto-retry loop, or after manual `addons.retryLoad`).
@@ -5407,7 +5414,7 @@ var ZodIssueCode = {
5407
5414
  var ZodFirstPartyTypeKind;
5408
5415
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
5409
5416
  //#endregion
5410
- //#region ../types/dist/sleep-B0JG7-_F.mjs
5417
+ //#region ../types/dist/sleep-r3RWkGVx.mjs
5411
5418
  /**
5412
5419
  * The audio chunk plane's byte format, and the ONE expansion from a coded
5413
5420
  * window to float samples (D455).
@@ -5486,6 +5493,97 @@ function buildAlawTable() {
5486
5493
  }
5487
5494
  buildUlawTable();
5488
5495
  buildAlawTable();
5496
+ /** Is this field's stored value a credential? */
5497
+ function isSecretConfigField(field) {
5498
+ if (field.type === "password") return true;
5499
+ return "secret" in field && field.secret === true;
5500
+ }
5501
+ /**
5502
+ * Is this field's value stored in the KEYCHAIN (D787)? Every secret field is,
5503
+ * by its TYPE, unless it opts out with `storage: 'inline'` — never by its name.
5504
+ */
5505
+ function isKeychainStoredField(field) {
5506
+ if (!isSecretConfigField(field)) return false;
5507
+ if (field.type === "textarea" && field.isJson === true) return false;
5508
+ return !("storage" in field && field.storage === "inline");
5509
+ }
5510
+ /**
5511
+ * What a settings blob holds where a secret used to be.
5512
+ *
5513
+ * A keychain-stored field never holds its value. It holds a self-describing
5514
+ * MARKER, `{"$secret":"secret://…","v":1}` — an object, never a string, so no
5515
+ * code can mistake it for a credential and no form can send it to a camera as
5516
+ * a password. The empty state is `null` / absent, never `''`.
5517
+ *
5518
+ * The same shapes travel to and from the admin UI:
5519
+ *
5520
+ * - read: `hydrateSchema` hands a secret field a {@link SecretFieldView}
5521
+ * (`{ $secret, v, set: true }`) or `null` — the browser learns whether a
5522
+ * value is set, never the value.
5523
+ * - write: an untouched field submits the view back unchanged (KEEP); a typed
5524
+ * value is a plain non-empty string (CHANGE); the Clear button submits
5525
+ * {@link SECRET_CLEAR} (CLEAR). `''`, `null` and the legacy redaction tokens
5526
+ * are KEEP — an empty string is what a defaults-fallback pushes back, and
5527
+ * treating it as "clear" is how a save destroyed a stored credential before.
5528
+ *
5529
+ * Pure and browser-safe.
5530
+ */
5531
+ var SECRET_CLEAR = { $secretClear: true };
5532
+ /** The `'***'` token D634 redaction writes for non-admins. */
5533
+ var LEGACY_DEVICE_REDACTION = "***";
5534
+ function isRecord$2(value) {
5535
+ return typeof value === "object" && value !== null && !Array.isArray(value);
5536
+ }
5537
+ function makeSecretMarker(ref) {
5538
+ return {
5539
+ $secret: ref,
5540
+ v: 1
5541
+ };
5542
+ }
5543
+ /** A stored marker: an object whose `$secret` is a non-empty string. */
5544
+ function isSecretMarker(value) {
5545
+ if (!isRecord$2(value)) return false;
5546
+ const ref = value["$secret"];
5547
+ return typeof ref === "string" && ref.length > 0;
5548
+ }
5549
+ function isSecretClear(value) {
5550
+ return isRecord$2(value) && value["$secretClear"] === true;
5551
+ }
5552
+ /**
5553
+ * The UI view of a stored secret field value: a marker becomes "set", inline
5554
+ * plaintext becomes "set (inline)", nothing becomes `null`. A value never
5555
+ * survives this function.
5556
+ */
5557
+ function toSecretFieldView(stored) {
5558
+ if (isSecretMarker(stored)) return {
5559
+ $secret: stored.$secret,
5560
+ v: 1,
5561
+ set: true
5562
+ };
5563
+ if (typeof stored === "string" && stored.length > 0) return {
5564
+ $secret: null,
5565
+ v: 1,
5566
+ set: true,
5567
+ inline: true
5568
+ };
5569
+ return null;
5570
+ }
5571
+ /**
5572
+ * Classify an incoming value for a secret path. Only a non-empty string that is
5573
+ * not a redaction token sets a value; only {@link SECRET_CLEAR} clears.
5574
+ * Everything else — a marker (ours or anyone's), a UI view, `''`, `null`,
5575
+ * `undefined`, a redaction token, a non-string — keeps what is stored.
5576
+ */
5577
+ function classifySecretWrite(incoming) {
5578
+ if (isSecretClear(incoming)) return { kind: "clear" };
5579
+ if (typeof incoming !== "string") return { kind: "keep" };
5580
+ if (incoming.length === 0) return { kind: "keep" };
5581
+ if (incoming === "__camstack_redacted__" || incoming === LEGACY_DEVICE_REDACTION) return { kind: "keep" };
5582
+ return {
5583
+ kind: "set",
5584
+ value: incoming
5585
+ };
5586
+ }
5489
5587
  Object.fromEntries([
5490
5588
  {
5491
5589
  id: "overview",
@@ -5657,33 +5755,19 @@ Object.fromEntries([
5657
5755
  function isValuelessField(field) {
5658
5756
  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";
5659
5757
  }
5660
- /**
5661
- * Merge a `ConfigUISchema` with a raw `values` record into a
5662
- * `ConfigUISchemaWithValues`. Used by every `get*Settings` backend endpoint
5663
- * before returning to the admin UI. Groups are walked recursively.
5664
- *
5665
- * For each leaf field:
5666
- * - structural fields (`separator`, `info`, `button`) pass through unchanged
5667
- * - other fields get `value = values[key] ?? field.default ?? null`
5668
- *
5669
- * Unknown keys in `values` (keys not declared in the schema) are silently
5670
- * ignored — they don't contribute to the output. Missing keys fall back to
5671
- * the schema default or `null`. This mirrors the old backend behaviour where
5672
- * `FormBuilder` rendered `values[key] ?? field.default`.
5673
- */
5674
- function hydrateSchema(schema, values) {
5758
+ function hydrateSchema(schema, values, options = {}) {
5675
5759
  return {
5676
5760
  ...schema.tabs ? { tabs: [...schema.tabs] } : {},
5677
5761
  sections: schema.sections.map((section) => ({
5678
5762
  ...section,
5679
- fields: section.fields.map((field) => hydrateField(field, values))
5763
+ fields: section.fields.map((field) => hydrateField(field, values, options))
5680
5764
  }))
5681
5765
  };
5682
5766
  }
5683
- function hydrateField(field, values) {
5767
+ function hydrateField(field, values, options) {
5684
5768
  if (isValuelessField(field)) return field;
5685
5769
  if (field.type === "group") {
5686
- const hydratedChildren = field.fields.map((child) => hydrateField(child, values));
5770
+ const hydratedChildren = field.fields.map((child) => hydrateField(child, values, options));
5687
5771
  return {
5688
5772
  ...field,
5689
5773
  fields: hydratedChildren
@@ -5692,7 +5776,7 @@ function hydrateField(field, values) {
5692
5776
  if (field.type === "sub-tabs") {
5693
5777
  const hydratedTabs = field.tabs.map((tab) => ({
5694
5778
  ...tab,
5695
- fields: tab.fields.map((child) => hydrateField(child, values))
5779
+ fields: tab.fields.map((child) => hydrateField(child, values, options))
5696
5780
  }));
5697
5781
  return {
5698
5782
  ...field,
@@ -5702,6 +5786,33 @@ function hydrateField(field, values) {
5702
5786
  const key = field.key;
5703
5787
  const storedValue = Object.prototype.hasOwnProperty.call(values, key) ? values[key] : void 0;
5704
5788
  const defaultValue = field.default;
5789
+ const asView = (v) => isSecretMarker(v) || options.inlineSecretsAsViews === true && v !== void 0;
5790
+ if (isKeychainStoredField(field) && asView(storedValue)) return {
5791
+ ...field,
5792
+ value: toSecretFieldView(storedValue)
5793
+ };
5794
+ if (isKeychainStoredField(field) && options.inlineSecretsAsViews === true) return {
5795
+ ...field,
5796
+ value: null
5797
+ };
5798
+ if (field.type === "editable-array" && Array.isArray(storedValue)) {
5799
+ const secretItemKeys = field.itemFields.filter((item) => "key" in item && isKeychainStoredField(item)).map((item) => "key" in item ? item.key : "");
5800
+ if (secretItemKeys.length > 0) {
5801
+ const rows = storedValue.map((row) => {
5802
+ if (row === null || typeof row !== "object" || Array.isArray(row)) return row;
5803
+ const out = { ...row };
5804
+ for (const k of secretItemKeys) {
5805
+ const v = Reflect.get(row, k);
5806
+ if (asView(v)) out[k] = toSecretFieldView(v);
5807
+ }
5808
+ return out;
5809
+ });
5810
+ return {
5811
+ ...field,
5812
+ value: rows
5813
+ };
5814
+ }
5815
+ }
5705
5816
  if (field.multiple) {
5706
5817
  const stored = Array.isArray(storedValue) ? storedValue : storedValue !== void 0 && storedValue !== null ? [storedValue] : [];
5707
5818
  const itemFallback = field.multiple.itemDefault !== void 0 ? field.multiple.itemDefault : defaultValue !== void 0 ? defaultValue : typeOf(field) === "string" ? "" : null;
@@ -5944,6 +6055,778 @@ function projectStore(store, perNodeKeys, nodeId) {
5944
6055
  }
5945
6056
  return out;
5946
6057
  }
6058
+ var GLOBAL_SCOPE = { kind: "global" };
6059
+ /** The scope every addon-wide (not per-node, not per-device) setting lives in. */
6060
+ function globalSecretScope() {
6061
+ return GLOBAL_SCOPE;
6062
+ }
6063
+ function encodeSegment(value) {
6064
+ return encodeURIComponent(value);
6065
+ }
6066
+ function decodeSegment(value) {
6067
+ try {
6068
+ return decodeURIComponent(value);
6069
+ } catch {
6070
+ return null;
6071
+ }
6072
+ }
6073
+ /**
6074
+ * The field path of a value inside an array item, addressed by the item's id:
6075
+ * `arrayItemFieldPath('providers', 'authentik', 'clientSecret')` →
6076
+ * `providers[authentik].clientSecret`.
6077
+ */
6078
+ function arrayItemFieldPath(arrayKey, itemId, fieldKey) {
6079
+ return `${arrayKey}[${encodeSegment(itemId)}].${fieldKey}`;
6080
+ }
6081
+ function parseScope(segments) {
6082
+ switch (segments[0]) {
6083
+ case "global": return {
6084
+ scope: GLOBAL_SCOPE,
6085
+ used: 1
6086
+ };
6087
+ case "node": {
6088
+ const nodeId = segments[1] !== void 0 ? decodeSegment(segments[1]) : null;
6089
+ return nodeId === null || nodeId.length === 0 ? null : {
6090
+ scope: {
6091
+ kind: "node",
6092
+ nodeId
6093
+ },
6094
+ used: 2
6095
+ };
6096
+ }
6097
+ case "device": {
6098
+ const raw = segments[1];
6099
+ if (raw === void 0 || !/^\d+$/.test(raw)) return null;
6100
+ return {
6101
+ scope: {
6102
+ kind: "device",
6103
+ deviceId: Number(raw)
6104
+ },
6105
+ used: 2
6106
+ };
6107
+ }
6108
+ case "integration": {
6109
+ const id = segments[1] !== void 0 ? decodeSegment(segments[1]) : null;
6110
+ return id === null || id.length === 0 ? null : {
6111
+ scope: {
6112
+ kind: "integration",
6113
+ integrationId: id
6114
+ },
6115
+ used: 2
6116
+ };
6117
+ }
6118
+ case "row": {
6119
+ const collection = segments[1] !== void 0 ? decodeSegment(segments[1]) : null;
6120
+ const rowId = segments[2] !== void 0 ? decodeSegment(segments[2]) : null;
6121
+ if (collection === null || rowId === null || collection.length === 0 || rowId.length === 0) return null;
6122
+ return {
6123
+ scope: {
6124
+ kind: "row",
6125
+ collection,
6126
+ rowId
6127
+ },
6128
+ used: 3
6129
+ };
6130
+ }
6131
+ default: return null;
6132
+ }
6133
+ }
6134
+ /** Take a ref apart; `null` when it is not a well-formed ref. */
6135
+ function parseSecretRef(ref) {
6136
+ if (!ref.startsWith("secret://")) return null;
6137
+ const segments = ref.slice(9).split("/");
6138
+ const owner = segments[0] !== void 0 ? decodeSegment(segments[0]) : null;
6139
+ if (owner === null || owner.length === 0) return null;
6140
+ const parsed = parseScope(segments.slice(1));
6141
+ if (parsed === null) return null;
6142
+ const fieldPath = segments.slice(1 + parsed.used).join("/");
6143
+ if (fieldPath.length === 0) return null;
6144
+ return {
6145
+ owner,
6146
+ scope: parsed.scope,
6147
+ fieldPath
6148
+ };
6149
+ }
6150
+ /** A write to a secret path could not be stored in the keychain, so it was refused. */
6151
+ var KeychainWriteRefusedError = class extends Error {
6152
+ fieldPath;
6153
+ constructor(fieldPath, cause) {
6154
+ super(`secret "${fieldPath}" was not saved: the keychain could not store it (${cause instanceof Error ? cause.message : String(cause)}). Nothing was written.`);
6155
+ this.fieldPath = fieldPath;
6156
+ this.name = "KeychainWriteRefusedError";
6157
+ }
6158
+ };
6159
+ var KEEP = { kind: "keep" };
6160
+ function isRecord$1(value) {
6161
+ return typeof value === "object" && value !== null && !Array.isArray(value);
6162
+ }
6163
+ function defaultMintId() {
6164
+ return globalThis.crypto.randomUUID();
6165
+ }
6166
+ /** Every marker ref anywhere under `value`. */
6167
+ function collectSecretMarkerRefs(value, out = []) {
6168
+ if (isSecretMarker(value)) {
6169
+ out.push(value.$secret);
6170
+ return out;
6171
+ }
6172
+ if (Array.isArray(value)) for (const item of value) collectSecretMarkerRefs(item, out);
6173
+ else if (isRecord$1(value)) for (const child of Object.values(value)) collectSecretMarkerRefs(child, out);
6174
+ return out;
6175
+ }
6176
+ async function storedValueEquals(secrets, marker, candidate) {
6177
+ const resolved = (await secrets.resolve([marker.$secret]))[marker.$secret];
6178
+ return resolved?.kind === "value" && resolved.value === candidate;
6179
+ }
6180
+ async function writeLeaf(ctx, incoming, stored, fieldPath) {
6181
+ const intent = classifySecretWrite(incoming);
6182
+ const ref = ctx.secrets.ref(ctx.scope, fieldPath);
6183
+ const storedIsOurs = isSecretMarker(stored) && stored.$secret === ref;
6184
+ if (intent.kind === "keep") return KEEP;
6185
+ if (intent.kind === "set" && !ctx.operatorWrite && typeof stored === "string" && stored === intent.value) return KEEP;
6186
+ if (intent.kind === "clear") {
6187
+ if (storedIsOurs) ctx.deletes.push(ref);
6188
+ return {
6189
+ kind: "value",
6190
+ value: null
6191
+ };
6192
+ }
6193
+ if (storedIsOurs && await storedValueEquals(ctx.secrets, stored, intent.value)) return {
6194
+ kind: "value",
6195
+ value: stored
6196
+ };
6197
+ try {
6198
+ await ctx.secrets.put(ref, intent.value);
6199
+ } catch (err) {
6200
+ throw new KeychainWriteRefusedError(fieldPath, err);
6201
+ }
6202
+ return {
6203
+ kind: "value",
6204
+ value: makeSecretMarker(ref)
6205
+ };
6206
+ }
6207
+ /** Apply a member result onto `out`: KEEP restores the stored member, or removes it. */
6208
+ function applyMember(out, key, result, storedParent) {
6209
+ if (result.kind === "value") {
6210
+ out[key] = result.value;
6211
+ return;
6212
+ }
6213
+ if (Object.prototype.hasOwnProperty.call(storedParent, key)) out[key] = storedParent[key];
6214
+ else delete out[key];
6215
+ }
6216
+ async function writeMembers(ctx, children, incoming, stored, pathOf) {
6217
+ const out = { ...incoming };
6218
+ for (const [member, node] of children) applyMember(out, member, await writeNode(ctx, node, incoming[member], stored[member], pathOf(member)), stored);
6219
+ return out;
6220
+ }
6221
+ function rowId(row, idKey) {
6222
+ const raw = row[idKey];
6223
+ if (typeof raw === "string" && raw.length > 0) return raw;
6224
+ if (typeof raw === "number" && Number.isFinite(raw)) return String(raw);
6225
+ return null;
6226
+ }
6227
+ async function writeArray(ctx, node, incoming, stored, fieldPath) {
6228
+ const storedRows = Array.isArray(stored) ? stored.filter(isRecord$1) : [];
6229
+ if (!Array.isArray(incoming)) {
6230
+ ctx.deletes.push(...collectSecretMarkerRefs(storedRows));
6231
+ return {
6232
+ kind: "value",
6233
+ value: incoming
6234
+ };
6235
+ }
6236
+ const storedById = /* @__PURE__ */ new Map();
6237
+ for (const row of storedRows) {
6238
+ const id = rowId(row, node.idKey);
6239
+ if (id !== null) storedById.set(id, row);
6240
+ }
6241
+ const kept = /* @__PURE__ */ new Set();
6242
+ const rows = [];
6243
+ for (const row of incoming) {
6244
+ if (!isRecord$1(row)) {
6245
+ rows.push(row);
6246
+ continue;
6247
+ }
6248
+ const id = rowId(row, node.idKey) ?? ctx.mintId();
6249
+ kept.add(id);
6250
+ const withId = {
6251
+ ...row,
6252
+ [node.idKey]: row[node.idKey] ?? id
6253
+ };
6254
+ if (rowId(withId, node.idKey) === null) withId[node.idKey] = id;
6255
+ const storedRow = storedById.get(id) ?? {};
6256
+ rows.push(await writeMembers(ctx, node.item, withId, storedRow, (member) => arrayItemFieldPath(fieldPath, id, member)));
6257
+ }
6258
+ for (const [id, row] of storedById) if (!kept.has(id)) ctx.deletes.push(...collectSecretMarkerRefs(row));
6259
+ return {
6260
+ kind: "value",
6261
+ value: rows
6262
+ };
6263
+ }
6264
+ async function writeNode(ctx, node, incoming, stored, fieldPath) {
6265
+ switch (node.kind) {
6266
+ case "leaf": return writeLeaf(ctx, incoming, stored, fieldPath);
6267
+ case "array": return writeArray(ctx, node, incoming, stored, fieldPath);
6268
+ case "object": {
6269
+ if (!isRecord$1(incoming)) {
6270
+ if (incoming === void 0) return KEEP;
6271
+ ctx.deletes.push(...collectSecretMarkerRefs(stored));
6272
+ return {
6273
+ kind: "value",
6274
+ value: incoming
6275
+ };
6276
+ }
6277
+ const storedObj = isRecord$1(stored) ? stored : {};
6278
+ return {
6279
+ kind: "value",
6280
+ value: await writeMembers(ctx, node.children, incoming, storedObj, (m) => `${fieldPath}.${m}`)
6281
+ };
6282
+ }
6283
+ }
6284
+ }
6285
+ /** Split a perNode-scoped key (`key@nodeId`). */
6286
+ function splitNodeKey(key) {
6287
+ const at = key.indexOf("@");
6288
+ return at <= 0 ? {
6289
+ base: key,
6290
+ nodeId: null
6291
+ } : {
6292
+ base: key.slice(0, at),
6293
+ nodeId: key.slice(at + 1)
6294
+ };
6295
+ }
6296
+ /** Rewrite a settings patch so no secret value reaches the blob. See the file doc. */
6297
+ async function transformSecretWrite(input) {
6298
+ const deletes = [];
6299
+ const base = {
6300
+ secrets: input.secrets,
6301
+ mintId: input.mintId ?? defaultMintId,
6302
+ deletes,
6303
+ operatorWrite: input.operatorWrite === true
6304
+ };
6305
+ const out = {};
6306
+ for (const [key, incoming] of Object.entries(input.patch)) {
6307
+ const { base: baseKey, nodeId } = splitNodeKey(key);
6308
+ const node = input.tree.get(baseKey);
6309
+ if (node === void 0) {
6310
+ out[key] = incoming;
6311
+ continue;
6312
+ }
6313
+ const scope = nodeId !== null && nodeId.length > 0 ? {
6314
+ kind: "node",
6315
+ nodeId
6316
+ } : input.scope ?? globalSecretScope();
6317
+ const result = await writeNode({
6318
+ ...base,
6319
+ scope
6320
+ }, node, incoming, input.stored[key], baseKey);
6321
+ if (result.kind === "value") out[key] = result.value;
6322
+ }
6323
+ return {
6324
+ patch: out,
6325
+ afterWrite: async () => {
6326
+ if (deletes.length === 0) return { orphaned: [] };
6327
+ try {
6328
+ await input.secrets.delete([...new Set(deletes)]);
6329
+ return { orphaned: [] };
6330
+ } catch {
6331
+ return { orphaned: [...new Set(deletes)] };
6332
+ }
6333
+ }
6334
+ };
6335
+ }
6336
+ /** Is `ref` one of `owner`'s refs? */
6337
+ function isSecretRefOwnedBy(ref, owner) {
6338
+ return parseSecretRef(ref)?.owner === owner;
6339
+ }
6340
+ /**
6341
+ * Replace every marker in `value` with its keychain value. Returns the SAME
6342
+ * reference when there is no marker (no allocation, no keychain call).
6343
+ */
6344
+ async function resolveSecretMarkers(value, secrets, options = {}) {
6345
+ const keepMarker = options.unresolved === "keep-marker";
6346
+ const owner = options.ownedBy;
6347
+ const inScope = (ref) => owner === void 0 || isSecretRefOwnedBy(ref, owner);
6348
+ const refs = collectSecretMarkerRefs(value).filter(inScope);
6349
+ if (refs.length === 0) return {
6350
+ value,
6351
+ unresolved: []
6352
+ };
6353
+ const answers = await secrets.resolve(refs);
6354
+ const unresolved = [];
6355
+ for (const ref of new Set(refs)) {
6356
+ const answer = answers[ref];
6357
+ if (answer === void 0) unresolved.push({
6358
+ ref,
6359
+ reason: "not-initialized"
6360
+ });
6361
+ else if (answer.kind === "unavailable") unresolved.push({
6362
+ ref,
6363
+ reason: answer.reason
6364
+ });
6365
+ else if (answer.kind === "missing" || answer.kind === "forbidden") unresolved.push({
6366
+ ref,
6367
+ reason: answer.kind
6368
+ });
6369
+ }
6370
+ const substitute = (v) => {
6371
+ if (isSecretMarker(v)) {
6372
+ if (!inScope(v.$secret)) return {
6373
+ keep: true,
6374
+ value: v
6375
+ };
6376
+ const answer = answers[v.$secret];
6377
+ if (answer?.kind === "value") return {
6378
+ keep: true,
6379
+ value: answer.value
6380
+ };
6381
+ return keepMarker ? {
6382
+ keep: true,
6383
+ value: v
6384
+ } : {
6385
+ keep: false,
6386
+ value: void 0
6387
+ };
6388
+ }
6389
+ if (Array.isArray(v)) {
6390
+ const items = [];
6391
+ for (const item of v) {
6392
+ const s = substitute(item);
6393
+ if (s.keep) items.push(s.value);
6394
+ }
6395
+ return {
6396
+ keep: true,
6397
+ value: items
6398
+ };
6399
+ }
6400
+ if (isRecord$1(v)) {
6401
+ const out = {};
6402
+ for (const [k, child] of Object.entries(v)) {
6403
+ const s = substitute(child);
6404
+ if (s.keep) out[k] = s.value;
6405
+ }
6406
+ return {
6407
+ keep: true,
6408
+ value: out
6409
+ };
6410
+ }
6411
+ return {
6412
+ keep: true,
6413
+ value: v
6414
+ };
6415
+ };
6416
+ return {
6417
+ value: substitute(value).value,
6418
+ unresolved
6419
+ };
6420
+ }
6421
+ /** An addon tried to replace a stored secret it could not read. Nothing was written. */
6422
+ var SecretOverwriteRefusedError = class extends Error {
6423
+ ref;
6424
+ reason;
6425
+ constructor(ref, reason) {
6426
+ super(`secret ${ref} was not replaced: its stored value cannot be read right now (${reason}), and an addon may not overwrite a secret it cannot see. Nothing was written.`);
6427
+ this.ref = ref;
6428
+ this.reason = reason;
6429
+ this.name = "SecretOverwriteRefusedError";
6430
+ }
6431
+ };
6432
+ function isRecord(value) {
6433
+ return typeof value === "object" && value !== null && !Array.isArray(value);
6434
+ }
6435
+ function resolvedValue(pass, marker) {
6436
+ const answer = pass.answers[marker.$secret];
6437
+ return answer?.kind === "value" ? answer.value : null;
6438
+ }
6439
+ async function atMarker(pass, incoming, stored) {
6440
+ if (incoming === null) return stored;
6441
+ if (typeof incoming !== "string") return incoming;
6442
+ if (incoming === resolvedValue(pass, stored)) return stored;
6443
+ const intent = classifySecretWrite(incoming);
6444
+ if (intent.kind !== "set") return stored;
6445
+ const ref = stored.$secret;
6446
+ if (!isSecretRefOwnedBy(ref, pass.secrets.owner)) return incoming;
6447
+ const answer = pass.answers[ref];
6448
+ if ((answer === void 0 || answer.kind === "unavailable" || answer.kind === "forbidden") && !pass.operatorWrite) throw new SecretOverwriteRefusedError(ref, answer === void 0 ? "not-initialized" : answer.kind === "unavailable" ? answer.reason : answer.kind);
6449
+ try {
6450
+ await pass.secrets.put(ref, intent.value);
6451
+ } catch (err) {
6452
+ throw new KeychainWriteRefusedError(ref, err);
6453
+ }
6454
+ pass.changedRefs.push(ref);
6455
+ return stored;
6456
+ }
6457
+ function inArray(pass, incoming, stored) {
6458
+ return incoming.map((item, index) => {
6459
+ const twin = stored[index];
6460
+ if (isSecretMarker(twin)) return typeof item === "string" && item === resolvedValue(pass, twin) ? twin : item;
6461
+ if (isRecord(item) && isRecord(twin)) return inArrayRow(pass, item, twin);
6462
+ if (Array.isArray(item) && Array.isArray(twin)) return inArray(pass, item, twin);
6463
+ return item;
6464
+ });
6465
+ }
6466
+ function inArrayRow(pass, incoming, stored) {
6467
+ const out = { ...incoming };
6468
+ for (const [key, value] of Object.entries(incoming)) {
6469
+ const twin = stored[key];
6470
+ if (isSecretMarker(twin)) {
6471
+ if (typeof value === "string" && value === resolvedValue(pass, twin)) out[key] = twin;
6472
+ } else if (isRecord(value) && isRecord(twin)) out[key] = inArrayRow(pass, value, twin);
6473
+ else if (Array.isArray(value) && Array.isArray(twin)) out[key] = inArray(pass, value, twin);
6474
+ }
6475
+ return out;
6476
+ }
6477
+ async function walk(pass, incoming, stored) {
6478
+ if (isSecretMarker(stored)) return atMarker(pass, incoming, stored);
6479
+ if (Array.isArray(incoming) && Array.isArray(stored)) return inArray(pass, incoming, stored);
6480
+ if (!isRecord(incoming) || !isRecord(stored)) return incoming;
6481
+ const out = { ...incoming };
6482
+ for (const [key, value] of Object.entries(incoming)) out[key] = await walk(pass, value, stored[key]);
6483
+ return out;
6484
+ }
6485
+ /** Restore markers a write-back carries as values. See the file doc. */
6486
+ async function restoreUnchangedSecrets(input) {
6487
+ const refs = [];
6488
+ for (const key of Object.keys(input.patch)) collectSecretMarkerRefs(input.stored[key], refs);
6489
+ const owned = refs.filter((ref) => isSecretRefOwnedBy(ref, input.secrets.owner));
6490
+ if (owned.length === 0) return {
6491
+ patch: input.patch,
6492
+ changedRefs: []
6493
+ };
6494
+ const pass = {
6495
+ secrets: input.secrets,
6496
+ answers: await input.secrets.resolve([...new Set(owned)]),
6497
+ operatorWrite: input.operatorWrite,
6498
+ changedRefs: []
6499
+ };
6500
+ const out = {};
6501
+ for (const [key, value] of Object.entries(input.patch)) out[key] = await walk(pass, value, input.stored[key]);
6502
+ return {
6503
+ patch: out,
6504
+ changedRefs: pass.changedRefs
6505
+ };
6506
+ }
6507
+ /** Structural equality over JSON-shaped values (key order does not matter). */
6508
+ function isJsonEqual(a, b) {
6509
+ if (Object.is(a, b)) return true;
6510
+ if (Array.isArray(a)) return Array.isArray(b) && a.length === b.length && a.every((v, i) => isJsonEqual(v, b[i]));
6511
+ if (isRecord(a) && isRecord(b)) {
6512
+ const keys = Object.keys(a);
6513
+ if (keys.length !== Object.keys(b).length) return false;
6514
+ return keys.every((k) => Object.prototype.hasOwnProperty.call(b, k) && isJsonEqual(a[k], b[k]));
6515
+ }
6516
+ return false;
6517
+ }
6518
+ /** The patch without the keys whose value already equals the stored one. */
6519
+ function dropUnchangedKeys(patch, stored) {
6520
+ const out = {};
6521
+ for (const [key, value] of Object.entries(patch)) {
6522
+ if (Object.prototype.hasOwnProperty.call(stored, key) && isJsonEqual(value, stored[key])) continue;
6523
+ out[key] = value;
6524
+ }
6525
+ return out;
6526
+ }
6527
+ /** The top-level keys of a blob that hold at least one of `owner`'s markers. */
6528
+ function markerKeysOf(blob, owner) {
6529
+ const keys = /* @__PURE__ */ new Set();
6530
+ for (const [key, value] of Object.entries(blob)) if (collectSecretMarkerRefs(value).some((ref) => isSecretRefOwnedBy(ref, owner))) keys.add(key);
6531
+ return keys;
6532
+ }
6533
+ function nodeFromStored(value, owner) {
6534
+ if (isSecretMarker(value)) return isSecretRefOwnedBy(value.$secret, owner) ? { kind: "leaf" } : null;
6535
+ if (!isRecord(value)) return null;
6536
+ const children = /* @__PURE__ */ new Map();
6537
+ for (const [key, child] of Object.entries(value)) {
6538
+ const node = nodeFromStored(child, owner);
6539
+ if (node !== null) children.set(key, node);
6540
+ }
6541
+ return children.size > 0 ? {
6542
+ kind: "object",
6543
+ children
6544
+ } : null;
6545
+ }
6546
+ /**
6547
+ * The declared secret tree, widened by every place the STORED blob holds a
6548
+ * marker under one of `keys` — so a marker the schema no longer declares (or
6549
+ * never declared: Wyze before b4906cec6) still gets the save path's
6550
+ * KEEP / SET / CLEAR semantics instead of being overwritten by whatever the
6551
+ * addon writes. Markers inside arrays are not added: a row has no id field to
6552
+ * match by unless the schema declares one. Only `owner`'s markers count: a
6553
+ * builtin that keeps another addon's marker (device-manager) never takes it
6554
+ * over.
6555
+ */
6556
+ function widenTreeWithStoredMarkers(declared, stored, keys, owner) {
6557
+ const added = /* @__PURE__ */ new Map();
6558
+ for (const key of keys) {
6559
+ const at = key.indexOf("@");
6560
+ const base = at > 0 ? key.slice(0, at) : key;
6561
+ if (declared.has(base) || added.has(base)) continue;
6562
+ const node = nodeFromStored(stored[key], owner);
6563
+ if (node !== null) added.set(base, node);
6564
+ }
6565
+ return added.size === 0 ? declared : new Map([...declared, ...added]);
6566
+ }
6567
+ /** The blob as stored now; a failed read REFUSES the write instead of guessing. */
6568
+ async function readStoredAddonBlob(raw) {
6569
+ const threeWay = raw.readAddonStoreResult;
6570
+ if (threeWay === void 0) return raw.readAddonStore();
6571
+ const result = await threeWay.call(raw);
6572
+ if (result.kind === "failed") throw new Error(`settings write refused: the stored blob could not be read (${result.error})`);
6573
+ return result.kind === "missing" ? {} : result.value;
6574
+ }
6575
+ function touchesTree(tree, patch) {
6576
+ if (tree.size === 0) return false;
6577
+ for (const key of Object.keys(patch)) {
6578
+ const at = key.indexOf("@");
6579
+ if (tree.has(at > 0 ? key.slice(0, at) : key)) return true;
6580
+ }
6581
+ return false;
6582
+ }
6583
+ /**
6584
+ * Which top-level keys of each store held markers when last seen. `undefined`
6585
+ * for a store not seen yet: its first write reads it, to be safe.
6586
+ */
6587
+ var MarkerKeyIndex = class {
6588
+ owner;
6589
+ byStore = /* @__PURE__ */ new Map();
6590
+ constructor(owner) {
6591
+ this.owner = owner;
6592
+ }
6593
+ seen(store, blob) {
6594
+ this.byStore.set(store, markerKeysOf(blob, this.owner));
6595
+ }
6596
+ wrote(store, patch) {
6597
+ const keys = this.byStore.get(store);
6598
+ if (keys === void 0) return;
6599
+ const now = markerKeysOf(patch, this.owner);
6600
+ for (const key of Object.keys(patch)) if (now.has(key)) keys.add(key);
6601
+ else keys.delete(key);
6602
+ }
6603
+ mayHoldMarkers(store, patch) {
6604
+ const keys = this.byStore.get(store);
6605
+ if (keys === void 0) return true;
6606
+ return Object.keys(patch).some((key) => keys.has(key));
6607
+ }
6608
+ };
6609
+ function createHandle(raw, opts) {
6610
+ const chains = /* @__PURE__ */ new Map();
6611
+ const serialize = (key, fn) => {
6612
+ const next = (chains.get(key) ?? Promise.resolve()).then(fn, fn);
6613
+ const tail = next.catch(() => void 0);
6614
+ chains.set(key, tail);
6615
+ tail.then(() => {
6616
+ if (chains.get(key) === tail) chains.delete(key);
6617
+ });
6618
+ return next;
6619
+ };
6620
+ const index = new MarkerKeyIndex(opts.secrets.owner);
6621
+ const resolveRead = async (store, blob) => {
6622
+ index.seen(store, blob);
6623
+ const { value, unresolved } = await resolveSecretMarkers(blob, opts.secrets, {
6624
+ unresolved: "keep-marker",
6625
+ ownedBy: opts.secrets.owner
6626
+ });
6627
+ if (unresolved.length > 0) opts.onUnresolved?.(unresolved);
6628
+ return value;
6629
+ };
6630
+ const write = async (store, declared, scope, patch, readStored, rawWrite) => {
6631
+ if (!touchesTree(declared, patch) && !index.mayHoldMarkers(store, patch)) {
6632
+ await rawWrite(patch);
6633
+ index.wrote(store, patch);
6634
+ return { changed: true };
6635
+ }
6636
+ return serialize(store, async () => {
6637
+ const stored = await readStored();
6638
+ index.seen(store, stored);
6639
+ const operatorWrite = opts.isOperatorWrite?.() === true;
6640
+ const restored = await restoreUnchangedSecrets({
6641
+ patch,
6642
+ stored,
6643
+ secrets: opts.secrets,
6644
+ operatorWrite
6645
+ });
6646
+ const result = await transformSecretWrite({
6647
+ tree: widenTreeWithStoredMarkers(declared, stored, Object.keys(restored.patch), opts.secrets.owner),
6648
+ secrets: opts.secrets,
6649
+ patch: restored.patch,
6650
+ stored,
6651
+ ...scope !== void 0 ? { scope } : {},
6652
+ operatorWrite
6653
+ });
6654
+ const effective = dropUnchangedKeys(result.patch, stored);
6655
+ const wroteBlob = Object.keys(effective).length > 0;
6656
+ if (wroteBlob) {
6657
+ await rawWrite(effective);
6658
+ index.wrote(store, effective);
6659
+ }
6660
+ const { orphaned } = await result.afterWrite();
6661
+ if (orphaned.length > 0) opts.onOrphaned(orphaned);
6662
+ return { changed: wroteBlob || restored.changedRefs.length > 0 };
6663
+ });
6664
+ };
6665
+ const writeAddon = (patch) => write("addon", opts.addonTree(), void 0, patch, () => readStoredAddonBlob(raw), (p) => raw.writeAddonStore(p));
6666
+ const readAddonStoreResult = raw.readAddonStoreResult;
6667
+ const readAddonStoreKeyResult = raw.readAddonStoreKeyResult;
6668
+ const readDeviceStoreBatch = raw.readDeviceStoreBatch;
6669
+ const overrides = {
6670
+ readAddonStore: async () => resolveRead("addon", await raw.readAddonStore()),
6671
+ ...readAddonStoreResult !== void 0 ? { readAddonStoreResult: async () => {
6672
+ const result = await readAddonStoreResult.call(raw);
6673
+ return result.kind === "value" ? {
6674
+ kind: "value",
6675
+ value: await resolveRead("addon", result.value)
6676
+ } : result;
6677
+ } } : {},
6678
+ ...readAddonStoreKeyResult !== void 0 ? { readAddonStoreKeyResult: async (key) => {
6679
+ const result = await readAddonStoreKeyResult.call(raw, key);
6680
+ if (result.kind !== "present") return result;
6681
+ const { value, unresolved } = await resolveSecretMarkers({ [key]: result.value }, opts.secrets, {
6682
+ unresolved: "keep-marker",
6683
+ ownedBy: opts.secrets.owner
6684
+ });
6685
+ if (unresolved.length > 0) opts.onUnresolved?.(unresolved);
6686
+ return {
6687
+ kind: "present",
6688
+ value: value[key]
6689
+ };
6690
+ } } : {},
6691
+ readDeviceStore: async (deviceId) => resolveRead(`device:${deviceId}`, await raw.readDeviceStore(deviceId)),
6692
+ ...readDeviceStoreBatch !== void 0 ? { readDeviceStoreBatch: async (deviceIds) => {
6693
+ const rows = await readDeviceStoreBatch.call(raw, deviceIds);
6694
+ const out = /* @__PURE__ */ new Map();
6695
+ for (const [deviceId, blob] of rows) out.set(deviceId, await resolveRead(`device:${deviceId}`, blob));
6696
+ return out;
6697
+ } } : {},
6698
+ writeAddonStore: async (patch) => {
6699
+ await writeAddon(patch);
6700
+ },
6701
+ writeDeviceStore: async (deviceId, patch) => {
6702
+ await write(`device:${deviceId}`, opts.deviceTree(), {
6703
+ kind: "device",
6704
+ deviceId
6705
+ }, patch, () => raw.readDeviceStore(deviceId), (p) => raw.writeDeviceStore(deviceId, p));
6706
+ }
6707
+ };
6708
+ return {
6709
+ settings: new Proxy(raw, { get(target, prop, receiver) {
6710
+ if (typeof prop === "string" && Object.prototype.hasOwnProperty.call(overrides, prop)) return Reflect.get(overrides, prop);
6711
+ const value = Reflect.get(target, prop, receiver);
6712
+ return typeof value === "function" ? value.bind(target) : value;
6713
+ } }),
6714
+ raw: {
6715
+ readAddonStore: async () => {
6716
+ const blob = await raw.readAddonStore();
6717
+ index.seen("addon", blob);
6718
+ return blob;
6719
+ },
6720
+ readDeviceStore: async (deviceId) => {
6721
+ const blob = await raw.readDeviceStore(deviceId);
6722
+ index.seen(`device:${deviceId}`, blob);
6723
+ return blob;
6724
+ }
6725
+ },
6726
+ writeAddonStore: writeAddon
6727
+ };
6728
+ }
6729
+ /** The context the addon sees, plus the private raw view and write outcome. */
6730
+ function createSecretAwareContext(context, opts) {
6731
+ const raw = context.settings;
6732
+ if (raw === void 0) return {
6733
+ context,
6734
+ handle: null
6735
+ };
6736
+ const handle = createHandle(raw, opts);
6737
+ return {
6738
+ context: new Proxy(context, { get(target, prop, receiver) {
6739
+ if (prop === "settings") return handle.settings;
6740
+ return Reflect.get(target, prop, receiver);
6741
+ } }),
6742
+ handle
6743
+ };
6744
+ }
6745
+ var LEAF = { kind: "leaf" };
6746
+ var DEFAULT_ITEM_ID_KEY = "id";
6747
+ function collectFields(fields, out) {
6748
+ for (const field of fields) {
6749
+ if (field.type === "group") {
6750
+ collectFields(field.fields, out);
6751
+ continue;
6752
+ }
6753
+ if (field.type === "sub-tabs") {
6754
+ for (const tab of field.tabs) collectFields(tab.fields, out);
6755
+ continue;
6756
+ }
6757
+ if (field.type === "editable-array") {
6758
+ const item = /* @__PURE__ */ new Map();
6759
+ for (const itemField of field.itemFields) if ("key" in itemField && isKeychainStoredField(itemField)) item.set(itemField.key, LEAF);
6760
+ if (item.size > 0) out.set(field.key, {
6761
+ kind: "array",
6762
+ idKey: field.itemIdKey ?? DEFAULT_ITEM_ID_KEY,
6763
+ item
6764
+ });
6765
+ continue;
6766
+ }
6767
+ if (!("key" in field) || typeof field.key !== "string") continue;
6768
+ if (isKeychainStoredField(field)) out.set(field.key, LEAF);
6769
+ }
6770
+ }
6771
+ /** The secret tree a settings schema declares. */
6772
+ function secretTreeFromSchema(schema) {
6773
+ const out = /* @__PURE__ */ new Map();
6774
+ if (schema === null) return out;
6775
+ for (const section of schema.sections) collectFields(section.fields, out);
6776
+ return out;
6777
+ }
6778
+ /** Parse `a.b[id].c` into segments; throws on a malformed path (a declaration bug). */
6779
+ function parseSecretStatePath(path) {
6780
+ const segments = [];
6781
+ for (const raw of path.split(".")) {
6782
+ const m = /^([^[\]]+)(?:\[([^[\]]+)\])?$/.exec(raw);
6783
+ if (m === null || m[1] === void 0) throw new Error(`secretStatePaths: malformed path "${path}"`);
6784
+ segments.push(m[2] !== void 0 ? {
6785
+ key: m[1],
6786
+ idKey: m[2]
6787
+ } : { key: m[1] });
6788
+ }
6789
+ if (segments.length === 0) throw new Error(`secretStatePaths: empty path`);
6790
+ if (segments[segments.length - 1]?.idKey !== void 0) throw new Error(`secretStatePaths: "${path}" ends on an array — name the member that is secret`);
6791
+ return segments;
6792
+ }
6793
+ function insert(into, segments) {
6794
+ const [head, ...rest] = segments;
6795
+ if (head === void 0) return;
6796
+ if (rest.length === 0) {
6797
+ into.set(head.key, LEAF);
6798
+ return;
6799
+ }
6800
+ const existing = into.get(head.key);
6801
+ if (head.idKey !== void 0) {
6802
+ const item = new Map(existing?.kind === "array" ? existing.item : []);
6803
+ insert(item, rest);
6804
+ into.set(head.key, {
6805
+ kind: "array",
6806
+ idKey: head.idKey,
6807
+ item
6808
+ });
6809
+ return;
6810
+ }
6811
+ const children = new Map(existing?.kind === "object" ? existing.children : []);
6812
+ insert(children, rest);
6813
+ into.set(head.key, {
6814
+ kind: "object",
6815
+ children
6816
+ });
6817
+ }
6818
+ /** Add hidden-state paths (`secretStatePaths`) to a schema-derived tree. */
6819
+ function mergeSecretStatePaths(tree, paths) {
6820
+ if (paths.length === 0) return tree;
6821
+ const out = new Map(tree);
6822
+ for (const path of paths) insert(out, parseSecretStatePath(path));
6823
+ return out;
6824
+ }
6825
+ /** First retry of a secret the keychain could not serve; doubles to {@link SECRET_RETRY_MAX_MS}. */
6826
+ var SECRET_RETRY_FIRST_MS = 5e3;
6827
+ var SECRET_RETRY_MAX_MS = 5 * 6e4;
6828
+ /** Coalesces a burst of `keychain.changed` events into one re-resolve. */
6829
+ var SECRET_CHANGE_DEBOUNCE_MS = 250;
5947
6830
  /**
5948
6831
  * Base class for CamStack addons. Eliminates settings boilerplate:
5949
6832
  *
@@ -6013,6 +6896,33 @@ var BaseAddon = class {
6013
6896
  settingsStoreReady = false;
6014
6897
  /** Default config values. Provided via constructor. */
6015
6898
  defaults;
6899
+ /**
6900
+ * Hidden-state paths that hold secrets (D787) — values the addon writes
6901
+ * itself (`updateGlobalSettings`, `state()`) that no form field declares.
6902
+ * Stored in the keychain exactly like a `password` field. Syntax:
6903
+ * `'snapshotSigningKey'`, `'identity.pincode'`, `'tokens[userId].accessToken'`
6904
+ * (`key[<id field>]` addresses array items by id, never by index).
6905
+ */
6906
+ secretStatePaths = [];
6907
+ _addonSecretTree = null;
6908
+ _deviceSecretTree = null;
6909
+ /** Refs the last resolved config pointed at — a change to one re-resolves. */
6910
+ _configSecretRefs = /* @__PURE__ */ new Set();
6911
+ _unresolvedSecrets = [];
6912
+ _secretRetryTimer = null;
6913
+ _secretRetryDelayMs = SECRET_RETRY_FIRST_MS;
6914
+ _secretChangeTimer = null;
6915
+ _secretChangeUnsub = null;
6916
+ /** >0 while an OPERATOR's settings write is being applied. */
6917
+ _operatorWriteDepth = 0;
6918
+ /**
6919
+ * The keychain-aware settings handle (D798). Its `raw` view is the ONLY way
6920
+ * to the marker-bearing blobs and stays private to this class: the form
6921
+ * hydrate and config resolution need markers, addon code never does.
6922
+ */
6923
+ _secretSettings = null;
6924
+ /** Refs an addon-facing read could not resolve — each is logged once per process. */
6925
+ _loggedUnresolvedReads = /* @__PURE__ */ new Set();
6016
6926
  constructor(defaults) {
6017
6927
  this.defaults = defaults;
6018
6928
  this._config = { ...defaults };
@@ -6048,8 +6958,26 @@ var BaseAddon = class {
6048
6958
  return this._config;
6049
6959
  }
6050
6960
  async initialize(context) {
6051
- this._ctx = context;
6961
+ const secrets = context.secrets;
6962
+ if (secrets !== void 0) {
6963
+ const { context: wrapped, handle } = createSecretAwareContext(context, {
6964
+ secrets,
6965
+ addonTree: () => this.addonSecretTree(),
6966
+ deviceTree: () => this.deviceSecretTree(),
6967
+ onOrphaned: (refs) => context.logger.warn("keychain refs dropped by a settings write could not be deleted", { meta: { refs: [...refs] } }),
6968
+ isOperatorWrite: () => this._operatorWriteDepth > 0,
6969
+ onUnresolved: (unresolved) => this.logUnresolvedRead(unresolved)
6970
+ });
6971
+ this._ctx = wrapped;
6972
+ this._secretSettings = handle;
6973
+ } else {
6974
+ this._ctx = context;
6975
+ this._secretSettings = null;
6976
+ }
6052
6977
  await this.resolveConfig();
6978
+ if (secrets !== void 0) this._secretChangeUnsub = secrets.onChange((ref) => {
6979
+ if (this._configSecretRefs.has(ref)) this.scheduleSecretReresolve(SECRET_CHANGE_DEBOUNCE_MS);
6980
+ });
6053
6981
  const result = await this.onInitialize();
6054
6982
  this.emitLifecycle(EventCategory.AddonStarted);
6055
6983
  const normalized = normalizeAddonInitResult(result);
@@ -6082,6 +7010,12 @@ var BaseAddon = class {
6082
7010
  */
6083
7011
  async onHubReachable() {}
6084
7012
  async shutdown() {
7013
+ this._secretChangeUnsub?.();
7014
+ this._secretChangeUnsub = null;
7015
+ if (this._secretRetryTimer !== null) clearTimeout(this._secretRetryTimer);
7016
+ if (this._secretChangeTimer !== null) clearTimeout(this._secretChangeTimer);
7017
+ this._secretRetryTimer = null;
7018
+ this._secretChangeTimer = null;
6085
7019
  this.emitLifecycle(EventCategory.AddonStopped);
6086
7020
  if (this.autoEmitReadiness) this.emitReadinessForProviders("down");
6087
7021
  await this.onShutdown();
@@ -6156,11 +7090,8 @@ var BaseAddon = class {
6156
7090
  async getGlobalSettings(overlay, cap, nodeId) {
6157
7091
  const schema = this.globalSettingsSchema(cap);
6158
7092
  if (!schema) return { sections: [] };
6159
- const projected = await this.resolveGlobalStore(nodeId, cap);
6160
- return hydrateSchema(schema, overlay ? {
6161
- ...projected,
6162
- ...overlay
6163
- } : projected);
7093
+ const projected = await this.readRawProjectedStore(nodeId, cap);
7094
+ return hydrateSchema(schema, overlay ? await this.overlayKeepingMarkers(projected, overlay) : projected, { inlineSecretsAsViews: true });
6164
7095
  }
6165
7096
  /**
6166
7097
  * The integration-level view of this addon's settings: exactly the sections
@@ -6205,11 +7136,11 @@ var BaseAddon = class {
6205
7136
  });
6206
7137
  }
6207
7138
  if (sections.length === 0) return null;
6208
- const projected = await this.resolveGlobalStore(nodeId);
7139
+ const projected = await this.readRawProjectedStore(nodeId);
6209
7140
  return hydrateSchema({
6210
7141
  ...schema,
6211
7142
  sections
6212
- }, projected);
7143
+ }, projected, { inlineSecretsAsViews: true });
6213
7144
  }
6214
7145
  /**
6215
7146
  * The raw addon store PROJECTED onto the target node's bare per-node keys:
@@ -6222,12 +7153,50 @@ var BaseAddon = class {
6222
7153
  * the store for custom option logic (option narrowing, value snapping) to
6223
7154
  * read it per-node — never `ctx.settings.readAddonStore()` directly.
6224
7155
  * `nodeId` omitted ⇒ the local node (node-blind injection from ctx).
7156
+ *
7157
+ * Keychain values come back RESOLVED (D798): a secret reads as its value,
7158
+ * never as a `{ $secret }` marker. One the keychain cannot serve right now
7159
+ * stays a marker — "stored, unavailable" (`isSecretMarker()` is true, and it
7160
+ * is listed in {@link unresolvedSecrets}) — never `''` and never absent, so
7161
+ * it cannot be mistaken for "nothing stored, mint a new one". Writing the
7162
+ * resolved blob back is a no-op for every unchanged secret.
6225
7163
  */
6226
7164
  async resolveGlobalStore(nodeId, cap) {
6227
7165
  const raw = await this._ctx?.settings?.readAddonStore() ?? {};
7166
+ return this.projectForNode(raw, nodeId, cap);
7167
+ }
7168
+ projectForNode(store, nodeId, cap) {
6228
7169
  const keys = this.perNodeKeys(cap);
6229
7170
  const node = normalizeNodeId(nodeId ?? this._ctx?.kernel?.localNodeId);
6230
- return keys.size > 0 ? projectStore(raw, keys, node) : raw;
7171
+ return keys.size > 0 ? projectStore(store, keys, node) : store;
7172
+ }
7173
+ /** The PROJECTED store with its markers — the form hydrate only (D798). */
7174
+ async readRawProjectedStore(nodeId, cap) {
7175
+ const raw = await this.rawSettings()?.readAddonStore() ?? {};
7176
+ return this.projectForNode(raw, nodeId, cap);
7177
+ }
7178
+ /**
7179
+ * `{ ...stored, ...overlay }`, except that an overlay member equal to the
7180
+ * RESOLVED stored one keeps the stored (marker-bearing) member — so a form
7181
+ * hydrated from a resolved overlay still shows a secret as "set", never as
7182
+ * its value.
7183
+ */
7184
+ async overlayKeepingMarkers(stored, overlay) {
7185
+ const secrets = this._ctx?.secrets;
7186
+ const merged = {
7187
+ ...stored,
7188
+ ...overlay
7189
+ };
7190
+ if (secrets === void 0 || collectSecretMarkerRefs(stored).length === 0) return merged;
7191
+ const { value: resolved } = await resolveSecretMarkers(stored, secrets, {
7192
+ unresolved: "keep-marker",
7193
+ ownedBy: secrets.owner
7194
+ });
7195
+ for (const key of Object.keys(overlay)) {
7196
+ if (collectSecretMarkerRefs(stored[key]).length === 0) continue;
7197
+ if (isJsonEqual(overlay[key], resolved[key])) merged[key] = stored[key];
7198
+ }
7199
+ return merged;
6231
7200
  }
6232
7201
  /**
6233
7202
  * Whether ONE global key of this addon's store was written, read three-way
@@ -6263,18 +7232,58 @@ var BaseAddon = class {
6263
7232
  value: result.value[key]
6264
7233
  };
6265
7234
  }
7235
+ /**
7236
+ * The OPERATOR's write — a settings form or an admin API call, dispatched by
7237
+ * the kernel. Identical to {@link updateGlobalSettings}, except that a secret
7238
+ * the operator sends is stored as sent even when it equals a pre-keychain
7239
+ * inline value: the operator re-entering a password is a change, an addon
7240
+ * writing back what it read is not (D787).
7241
+ */
7242
+ async updateGlobalSettingsAsOperator(patch, nodeId) {
7243
+ this._operatorWriteDepth++;
7244
+ try {
7245
+ await this.applyGlobalPatch(patch, nodeId);
7246
+ } finally {
7247
+ this._operatorWriteDepth--;
7248
+ }
7249
+ }
6266
7250
  async updateGlobalSettings(patch, nodeId) {
7251
+ await this.applyGlobalPatch(patch, nodeId);
7252
+ }
7253
+ /**
7254
+ * REMOVE stored secrets — their keychain values and their markers (D787).
7255
+ *
7256
+ * Writing `''` to a secret field KEEPS what is stored (an empty string is
7257
+ * what a defaults fallback writes back, and it must never destroy a
7258
+ * credential), so code that means "forget this token" says so here. Without
7259
+ * a keychain (an older kernel) it writes `''`, as such code always did.
7260
+ */
7261
+ async clearSecrets(keys, nodeId) {
7262
+ const tree = this.addonSecretTree();
7263
+ const keychain = this._ctx?.secrets !== void 0;
7264
+ const stored = keychain ? await this.readAddonStoreWithRetry() : {};
7265
+ const patch = {};
7266
+ for (const key of keys) {
7267
+ const keychainStored = tree.has(key) || collectSecretMarkerRefs(stored[key]).length > 0;
7268
+ patch[key] = keychain && keychainStored ? SECRET_CLEAR : "";
7269
+ }
7270
+ await this.applyGlobalPatch(patch, nodeId);
7271
+ }
7272
+ async applyGlobalPatch(barePatch, nodeId) {
6267
7273
  const keys = this.perNodeKeys();
6268
7274
  const localNode = normalizeNodeId(this._ctx?.kernel?.localNodeId);
6269
7275
  const target = normalizeNodeId(nodeId ?? this._ctx?.kernel?.localNodeId);
6270
- const barePatch = patch;
6271
7276
  const scoped = keys.size > 0 ? scopePatch(barePatch, keys, target) : barePatch;
6272
- await this._ctx?.settings?.writeAddonStore(scoped);
7277
+ const handle = this._secretSettings;
7278
+ if (handle !== null) {
7279
+ const { changed } = await handle.writeAddonStore(scoped);
7280
+ if (!changed) return;
7281
+ } else await this._ctx?.settings?.writeAddonStore(scoped);
6273
7282
  if (target !== localNode) return;
6274
7283
  await this.resolveConfig();
6275
7284
  await this.onConfigChanged();
6276
7285
  this.emitLifecycle(EventCategory.AddonUpdated, { level: "global" });
6277
- this.maybeAutoRestart(patch, this.globalSettingsSchema());
7286
+ this.maybeAutoRestart(Object.keys(barePatch), this.globalSettingsSchema());
6278
7287
  }
6279
7288
  /**
6280
7289
  * The set of field keys the global settings schema declares `perNode: true`
@@ -6299,7 +7308,7 @@ var BaseAddon = class {
6299
7308
  * time to return its response before the addon is torn down and
6300
7309
  * re-initialised by `AddonRegistryService.restartAddon`.
6301
7310
  */
6302
- maybeAutoRestart(patch, schema) {
7311
+ maybeAutoRestart(patchKeys, schema) {
6303
7312
  if (!schema) return;
6304
7313
  const restartKeys = /* @__PURE__ */ new Set();
6305
7314
  for (const section of schema.sections) for (const field of section.fields) {
@@ -6307,13 +7316,13 @@ var BaseAddon = class {
6307
7316
  if (field.requiresRestart) restartKeys.add(field.key);
6308
7317
  }
6309
7318
  if (restartKeys.size === 0) return;
6310
- if (!Object.keys(patch).some((k) => restartKeys.has(k))) return;
7319
+ if (!patchKeys.some((k) => restartKeys.has(k))) return;
6311
7320
  const ctx = this._ctx;
6312
7321
  if (!ctx) return;
6313
7322
  const addonId = ctx.id;
6314
7323
  setImmediate(() => {
6315
7324
  ctx.api.addons?.restartAddon?.mutate({ addonId }).then(() => {
6316
- ctx.logger.info("addon auto-restart triggered by restart-required setting change", { meta: { changedFields: Object.keys(patch).filter((k) => restartKeys.has(k)) } });
7325
+ ctx.logger.info("addon auto-restart triggered by restart-required setting change", { meta: { changedFields: patchKeys.filter((k) => restartKeys.has(k)) } });
6317
7326
  }).catch((err) => {
6318
7327
  ctx.logger.error("addon auto-restart failed", { meta: { error: err instanceof Error ? err.message : String(err) } });
6319
7328
  });
@@ -6322,7 +7331,7 @@ var BaseAddon = class {
6322
7331
  async getDeviceSettings(deviceId) {
6323
7332
  const schema = this.deviceSettingsSchema();
6324
7333
  if (!schema) return { sections: [] };
6325
- return hydrateSchema(schema, await this._ctx?.settings?.readDeviceStore(deviceId) ?? {});
7334
+ return hydrateSchema(schema, await this.rawSettings()?.readDeviceStore(deviceId) ?? {}, { inlineSecretsAsViews: true });
6326
7335
  }
6327
7336
  async updateDeviceSettings(deviceId, patch) {
6328
7337
  await this._ctx?.settings?.writeDeviceStore(deviceId, patch);
@@ -6452,7 +7461,7 @@ var BaseAddon = class {
6452
7461
  * selection at boot (absent scoped key ⇒ the constructor default wins).
6453
7462
  */
6454
7463
  async resolveConfig() {
6455
- const stored = await this.readAddonStoreWithRetry();
7464
+ const stored = await this.resolveStoredSecrets(await this.readAddonStoreWithRetry());
6456
7465
  const perNode = this.perNodeKeys();
6457
7466
  const localNode = normalizeNodeId(this._ctx?.kernel?.localNodeId);
6458
7467
  const resolved = { ...this.defaults };
@@ -6477,7 +7486,7 @@ var BaseAddon = class {
6477
7486
  key,
6478
7487
  schema,
6479
7488
  fallback,
6480
- read: () => this.readAddonStoreWithRetry(),
7489
+ read: async () => this.resolveStoredSecrets(await this.readAddonStoreWithRetry()),
6481
7490
  write: async (patch) => {
6482
7491
  await this._ctx?.settings?.writeAddonStore(patch);
6483
7492
  },
@@ -6494,7 +7503,7 @@ var BaseAddon = class {
6494
7503
  key,
6495
7504
  schema,
6496
7505
  fallback,
6497
- read: async () => await this._ctx?.settings?.readDeviceStore(deviceId) ?? {},
7506
+ read: async () => this.resolveStoredSecrets(await this.rawSettings()?.readDeviceStore(deviceId) ?? {}, false),
6498
7507
  write: async (patch) => {
6499
7508
  await this._ctx?.settings?.writeDeviceStore(deviceId, patch);
6500
7509
  },
@@ -6506,6 +7515,87 @@ var BaseAddon = class {
6506
7515
  } })
6507
7516
  });
6508
7517
  }
7518
+ /** The addon store's secret tree: schema fields by TYPE, plus `secretStatePaths`. */
7519
+ addonSecretTree() {
7520
+ this._addonSecretTree ??= mergeSecretStatePaths(secretTreeFromSchema(this.globalSettingsSchema()), this.secretStatePaths);
7521
+ return this._addonSecretTree;
7522
+ }
7523
+ deviceSecretTree() {
7524
+ this._deviceSecretTree ??= secretTreeFromSchema(this.deviceSettingsSchema());
7525
+ return this._deviceSecretTree;
7526
+ }
7527
+ /**
7528
+ * Secrets of this addon's stored config that could not be resolved on the
7529
+ * last read, with why. Non-empty means the addon is running WITHOUT them —
7530
+ * an addon whose function needs one should report itself degraded rather
7531
+ * than start on an empty credential.
7532
+ */
7533
+ get unresolvedSecrets() {
7534
+ return this._unresolvedSecrets;
7535
+ }
7536
+ /**
7537
+ * Substitute every keychain marker in a stored blob with its value. With no
7538
+ * keychain (no `ctx.secrets`) or no marker, the blob comes back unchanged.
7539
+ * An unresolvable value is LEFT OUT (never `''`), logged by ref — never by
7540
+ * value — and, when the cause can pass, retried with backoff. Nothing is
7541
+ * ever written back from here.
7542
+ */
7543
+ async resolveStoredSecrets(blob, trackForConfig = true) {
7544
+ const secrets = this._ctx?.secrets;
7545
+ if (secrets === void 0) return blob;
7546
+ const refs = collectSecretMarkerRefs(blob);
7547
+ if (trackForConfig) this._configSecretRefs = new Set(refs);
7548
+ if (refs.length === 0) {
7549
+ if (trackForConfig) this._unresolvedSecrets = [];
7550
+ return blob;
7551
+ }
7552
+ const { value, unresolved } = await resolveSecretMarkers(blob, secrets);
7553
+ if (trackForConfig) {
7554
+ this._unresolvedSecrets = unresolved;
7555
+ if (unresolved.length > 0) {
7556
+ this._ctx?.logger?.error?.("secret unavailable — running without it, will retry", { meta: { secrets: unresolved.map((u) => ({
7557
+ ref: u.ref,
7558
+ reason: u.reason
7559
+ })) } });
7560
+ if (unresolved.some((u) => u.reason !== "missing" && u.reason !== "forbidden")) {
7561
+ this.scheduleSecretReresolve(this._secretRetryDelayMs);
7562
+ this._secretRetryDelayMs = Math.min(this._secretRetryDelayMs * 2, SECRET_RETRY_MAX_MS);
7563
+ }
7564
+ } else this._secretRetryDelayMs = SECRET_RETRY_FIRST_MS;
7565
+ }
7566
+ return value;
7567
+ }
7568
+ /**
7569
+ * The marker-bearing settings reads (D798) — private on purpose. Without a
7570
+ * keychain the context's own view is already raw.
7571
+ */
7572
+ rawSettings() {
7573
+ return this._secretSettings?.raw ?? this._ctx?.settings;
7574
+ }
7575
+ /** An addon-facing read met markers it could not resolve: say so once per ref. */
7576
+ logUnresolvedRead(unresolved) {
7577
+ const fresh = unresolved.filter((u) => !this._loggedUnresolvedReads.has(u.ref));
7578
+ if (fresh.length === 0) return;
7579
+ for (const u of fresh) this._loggedUnresolvedReads.add(u.ref);
7580
+ this._ctx?.logger?.warn?.("settings read: a stored secret is unavailable — it reads as its marker, not as a value", { meta: { secrets: fresh.map((u) => ({
7581
+ ref: u.ref,
7582
+ reason: u.reason
7583
+ })) } });
7584
+ }
7585
+ /** Re-resolve the config (a keychain-only change, or a retry) and apply it. */
7586
+ scheduleSecretReresolve(delayMs) {
7587
+ const timerOf = delayMs === SECRET_CHANGE_DEBOUNCE_MS ? "_secretChangeTimer" : "_secretRetryTimer";
7588
+ if (this[timerOf] !== null) return;
7589
+ const timer = setTimeout(() => {
7590
+ this[timerOf] = null;
7591
+ if (this._ctx === null) return;
7592
+ this.resolveConfig().then(() => this.onConfigChanged()).catch((err) => {
7593
+ this._ctx?.logger?.error?.("re-resolving secrets failed", { meta: { error: err instanceof Error ? err.message : String(err) } });
7594
+ });
7595
+ }, delayMs);
7596
+ timer.unref?.();
7597
+ this[timerOf] = timer;
7598
+ }
6509
7599
  /**
6510
7600
  * Wrap `ctx.settings.readAddonStore()` with a short retry budget so a
6511
7601
  * transient settings-store outage (mid-restart of sqlite-settings, tsx-watch
@@ -6518,7 +7608,7 @@ var BaseAddon = class {
6518
7608
  * `{}` (defaults) — the addon's first successful patch will rehydrate.
6519
7609
  */
6520
7610
  async readAddonStoreWithRetry() {
6521
- const settings = this._ctx?.settings;
7611
+ const settings = this.rawSettings();
6522
7612
  if (!settings) return {};
6523
7613
  const delaysMs = [
6524
7614
  150,
@@ -8744,6 +9834,278 @@ var CameraSwitchGroupSchema = object({
8744
9834
  fetchedAt: number()
8745
9835
  });
8746
9836
  /**
9837
+ * The trainer contract — what the hub hands the cloud trainer and what it
9838
+ * gets back (cloud training, D805+).
9839
+ *
9840
+ * The trainer (`hf/camstack-trainer`, published as the Hugging Face repo
9841
+ * `camstack/camstack-trainer`) is a separate AGPL program the hub never
9842
+ * imports: `job.json` goes in, files come out, and progress is `CAMSTACK_EVENT`
9843
+ * lines on stdout. These schemas are the hub's half of that boundary; the
9844
+ * trainer's pydantic models (and the JSON Schemas generated from them under
9845
+ * `hf/camstack-trainer/schemas/`) are the other half. A change here is a
9846
+ * change there, in the same piece of work.
9847
+ *
9848
+ * No `.default()` anywhere: defaults do not run on the addon cap path, so the
9849
+ * orchestrator fills every field of a job spec explicitly.
9850
+ */
9851
+ var TRAINING_JOB_SCHEMA = "camstack.training/v1";
9852
+ var TRAINING_RESULT_SCHEMA = "camstack.training-result/v1";
9853
+ /** What the trainer can export. Edge TPU is a later, separate image. */
9854
+ var TrainingExportSchema = _enum([
9855
+ "onnx",
9856
+ "openvino-fp16",
9857
+ "openvino-int8",
9858
+ "coreml-fp16"
9859
+ ]);
9860
+ var FloorsSchema = record(string(), number().min(0).max(1));
9861
+ object({
9862
+ schema: literal(TRAINING_JOB_SCHEMA),
9863
+ jobKey: string().uuid(),
9864
+ target: object({
9865
+ kind: literal("detector"),
9866
+ step: literal("object-detection")
9867
+ }),
9868
+ base: object({
9869
+ modelId: string().min(1),
9870
+ /** Ultralytics weights id, e.g. `yolov9m.pt`. */
9871
+ weights: string().min(1),
9872
+ imgsz: number().int().positive()
9873
+ }),
9874
+ baseline: object({
9875
+ modelId: string().min(1),
9876
+ /** The baseline ONNX the holdout comparison runs; public mirror URL. */
9877
+ onnxUrl: string().url(),
9878
+ imgsz: number().int().positive(),
9879
+ floors: FloorsSchema
9880
+ }),
9881
+ dataset: object({
9882
+ versionId: string().min(1),
9883
+ annotationHash: string(),
9884
+ /** sha256 of the uploaded archive; the trainer refuses a mismatch (exit 65). */
9885
+ sha256: string().regex(/^[0-9a-f]{64}$/)
9886
+ }),
9887
+ split: object({
9888
+ holdoutCameras: array(number().int()),
9889
+ /** When no camera is held out: the last N days of every camera. */
9890
+ holdoutLastDays: number().int().nonnegative(),
9891
+ valFraction: number().min(0).max(.5),
9892
+ seed: number().int()
9893
+ }),
9894
+ hyper: object({
9895
+ epochs: number().int().positive(),
9896
+ batch: number().int().positive(),
9897
+ lr0: number().positive(),
9898
+ /** Layers frozen from the start of the backbone; 0 = none. */
9899
+ freeze: number().int().nonnegative(),
9900
+ patience: number().int().nonnegative(),
9901
+ seed: number().int()
9902
+ }),
9903
+ replay: object({
9904
+ source: literal("coco2017"),
9905
+ count: number().int().nonnegative()
9906
+ }),
9907
+ exports: array(TrainingExportSchema).min(1),
9908
+ calibration: object({ maxFrames: number().int().positive() }),
9909
+ floors: object({
9910
+ minSupport: number().int().positive(),
9911
+ clamp: number().min(0).max(1)
9912
+ }),
9913
+ int8Gate: object({ maxMap50Drop: number().min(0).max(1) }),
9914
+ catalog: object({
9915
+ id: string().regex(/^[a-z0-9][a-z0-9-]{2,80}$/),
9916
+ name: string().min(1).max(160)
9917
+ })
9918
+ });
9919
+ /** One regular file of the bundle. An mlpackage contributes one row per member. */
9920
+ var TrainingResultFileSchema = object({
9921
+ path: string().min(1),
9922
+ bytes: number().int().nonnegative(),
9923
+ sha256: string().regex(/^[0-9a-f]{64}$/),
9924
+ format: _enum([
9925
+ "onnx",
9926
+ "openvino",
9927
+ "coreml",
9928
+ "pt"
9929
+ ]),
9930
+ variant: _enum(["base", "int8"])
9931
+ });
9932
+ var DraftFormatSchema = object({
9933
+ /** RELATIVE path inside the bundle; the hub rewrites it to `camstack-local://`. */
9934
+ url: string().min(1),
9935
+ sizeMB: number().nonnegative(),
9936
+ isDirectory: boolean().optional(),
9937
+ files: array(string()).optional(),
9938
+ runtimes: array(literal("python")).optional(),
9939
+ revision: string().min(1)
9940
+ });
9941
+ /** The trainer's half of a catalog entry; the hub completes it (labels, licence, group). */
9942
+ var TrainingCatalogDraftSchema = object({
9943
+ id: string().min(1),
9944
+ name: string().min(1),
9945
+ description: string(),
9946
+ labels: array(unknown()),
9947
+ inputSize: object({
9948
+ width: number().int().positive(),
9949
+ height: number().int().positive()
9950
+ }),
9951
+ preprocessMode: literal("letterbox"),
9952
+ defaultClassFloors: FloorsSchema,
9953
+ formats: object({
9954
+ onnx: DraftFormatSchema.optional(),
9955
+ openvino: DraftFormatSchema.optional(),
9956
+ coreml: DraftFormatSchema.optional()
9957
+ })
9958
+ });
9959
+ /** One class of one model's holdout report (the eval harness's summary). */
9960
+ var TrainingEvalClassSchema = object({
9961
+ positives: number().int(),
9962
+ floor: number().nullable(),
9963
+ tp: number().int(),
9964
+ fp: number().int(),
9965
+ fn: number().int(),
9966
+ precision: number().nullable(),
9967
+ recall: number().nullable(),
9968
+ ap50: number().nullable(),
9969
+ recallByCamera: record(string(), number().nullable()).optional(),
9970
+ recallByLight: record(string(), number().nullable()).optional(),
9971
+ fpByCamera: record(string(), number()).optional(),
9972
+ smallFound: number().int().optional(),
9973
+ smallTotal: number().int().optional()
9974
+ }).passthrough();
9975
+ var TrainingEvalReportSchema = object({
9976
+ frames: number().int(),
9977
+ classes: record(string(), TrainingEvalClassSchema)
9978
+ }).passthrough();
9979
+ /**
9980
+ * A succeeded result carries every block; a failed one carries the error and
9981
+ * whatever was known by then — the other blocks are ABSENT, not null. The
9982
+ * orchestrator checks the blocks it needs before it trusts a success.
9983
+ */
9984
+ var TrainingResultSchema = object({
9985
+ schema: literal(TRAINING_RESULT_SCHEMA),
9986
+ jobKey: string(),
9987
+ status: _enum(["succeeded", "failed"]),
9988
+ error: object({
9989
+ stage: string(),
9990
+ code: string(),
9991
+ message: string()
9992
+ }).nullable(),
9993
+ trainer: object({
9994
+ version: string(),
9995
+ revision: string()
9996
+ }),
9997
+ toolchain: record(string(), string().nullable()),
9998
+ dataset: object({
9999
+ versionId: string(),
10000
+ annotationHash: string(),
10001
+ sha256: string(),
10002
+ frames: object({
10003
+ train: number().int(),
10004
+ val: number().int(),
10005
+ holdout: number().int()
10006
+ }),
10007
+ holdoutCameras: array(number().int()),
10008
+ replayImages: number().int()
10009
+ }).optional(),
10010
+ training: object({
10011
+ epochsRun: number().int(),
10012
+ bestEpoch: number().int(),
10013
+ bestMap50: number(),
10014
+ bestMap50_95: number(),
10015
+ seconds: number()
10016
+ }).optional(),
10017
+ evaluation: object({
10018
+ holdoutFrames: number().int(),
10019
+ baseline: TrainingEvalReportSchema.nullable(),
10020
+ candidate: TrainingEvalReportSchema.nullable(),
10021
+ candidateInt8: TrainingEvalReportSchema.nullable(),
10022
+ recallDeltaByCamera: record(string(), record(string(), number())).nullable(),
10023
+ map50: record(string(), number().nullable())
10024
+ }).optional(),
10025
+ floors: object({
10026
+ baseline: FloorsSchema,
10027
+ candidate: FloorsSchema,
10028
+ candidateInt8: FloorsSchema.nullable(),
10029
+ notes: array(string())
10030
+ }).optional(),
10031
+ int8: object({
10032
+ kept: boolean(),
10033
+ map50Fp16: number().nullable(),
10034
+ map50Int8: number().nullable(),
10035
+ reason: string().nullable()
10036
+ }).optional(),
10037
+ exportsDropped: array(object({
10038
+ export: string(),
10039
+ reason: string()
10040
+ })).optional(),
10041
+ files: array(TrainingResultFileSchema).optional(),
10042
+ bundle: object({
10043
+ path: literal("bundle.tar"),
10044
+ bytes: number().int().nonnegative(),
10045
+ sha256: string().regex(/^[0-9a-f]{64}$/)
10046
+ }).nullable().optional(),
10047
+ catalogDraft: object({
10048
+ base: TrainingCatalogDraftSchema,
10049
+ int8: TrainingCatalogDraftSchema.nullable()
10050
+ }).nullable().optional(),
10051
+ licence: string()
10052
+ });
10053
+ var TrainingStageSchema = _enum([
10054
+ "prepare",
10055
+ "replay",
10056
+ "train",
10057
+ "eval",
10058
+ "export",
10059
+ "package"
10060
+ ]);
10061
+ var EventBase = {
10062
+ v: literal(1),
10063
+ ts: number()
10064
+ };
10065
+ discriminatedUnion("type", [
10066
+ object({
10067
+ ...EventBase,
10068
+ type: literal("stage"),
10069
+ stage: TrainingStageSchema
10070
+ }),
10071
+ object({
10072
+ ...EventBase,
10073
+ type: literal("epoch"),
10074
+ epoch: number().int(),
10075
+ epochs: number().int(),
10076
+ boxLoss: number().nullable().optional(),
10077
+ map50: number().nullable().optional(),
10078
+ map50_95: number().nullable().optional(),
10079
+ etaSec: number().nullable().optional()
10080
+ }),
10081
+ object({
10082
+ ...EventBase,
10083
+ type: literal("metric"),
10084
+ name: string(),
10085
+ value: number()
10086
+ }),
10087
+ object({
10088
+ ...EventBase,
10089
+ type: literal("artifact"),
10090
+ path: string(),
10091
+ bytes: number(),
10092
+ sha256: string()
10093
+ }),
10094
+ object({
10095
+ ...EventBase,
10096
+ type: literal("done"),
10097
+ status: _enum(["succeeded", "failed"]),
10098
+ resultSha256: string().nullable().optional()
10099
+ }),
10100
+ object({
10101
+ ...EventBase,
10102
+ type: literal("error"),
10103
+ stage: string(),
10104
+ code: string(),
10105
+ message: string()
10106
+ })
10107
+ ]);
10108
+ /**
8747
10109
  * What the gate decided about a birth, from the CALLER's point of view.
8748
10110
  *
8749
10111
  * Deliberately not `ConfirmationVerdict`: `undecided` is not a birth decision
@@ -11071,7 +12433,9 @@ var AddonHttpRouteSchema = object({
11071
12433
  "authenticated",
11072
12434
  "admin"
11073
12435
  ]).optional(),
11074
- description: string().optional()
12436
+ description: string().optional(),
12437
+ /** The hub limits this route per client address before the handler runs. */
12438
+ rateLimit: _enum(["auth"]).optional()
11075
12439
  });
11076
12440
  /**
11077
12441
  * Cross-process route invocation envelope. The hub captures the
@@ -11776,6 +13140,37 @@ var BackupDestinationInfoSchema = object({
11776
13140
  lastError: string().optional()
11777
13141
  });
11778
13142
  /**
13143
+ * How an archive is encrypted (operator decision 2026-10-09): to a backup
13144
+ * PUBLIC key the hub holds, so only the operator's secret key opens it.
13145
+ * Absent on a plain `.tar.gz` — every archive made before encryption, or
13146
+ * with it off — which restores without a key.
13147
+ */
13148
+ var BackupArchiveEncryptionSchema = object({
13149
+ /** `x25519-hkdf-aes256gcm-stream-v1`. */
13150
+ scheme: string(),
13151
+ /** 16 hex — the backup key whose secret restores this archive. */
13152
+ keyId: string()
13153
+ });
13154
+ /**
13155
+ * The backup encryption setting. The hub keeps PUBLIC keys only: the active
13156
+ * one new archives are encrypted to, and the retired ones older archives
13157
+ * still need. The secret key is shown once, at `setupEncryption`.
13158
+ */
13159
+ var BackupEncryptionStatusSchema = object({
13160
+ enabled: boolean(),
13161
+ active: object({
13162
+ keyId: string(),
13163
+ publicKey: string(),
13164
+ createdAt: number()
13165
+ }).nullable(),
13166
+ /** Every key ever set up, newest first. */
13167
+ keys: array(object({
13168
+ keyId: string(),
13169
+ createdAt: number(),
13170
+ retiredAt: number().nullable()
13171
+ })).readonly()
13172
+ });
13173
+ /**
11779
13174
  * Per-archive entry returned by `backup.listArchives({ destinationId })`.
11780
13175
  * Same shape the destination drill-in renders. Sourced from the per-
11781
13176
  * location `manifests.json` (no per-archive tarball read required).
@@ -11787,7 +13182,9 @@ var BackupArchiveEntrySchema = object({
11787
13182
  sizeBytes: number(),
11788
13183
  label: string().optional(),
11789
13184
  /** Top-level locations included in the archive (db, addons, tls, …). */
11790
- locations: array(string()).readonly()
13185
+ locations: array(string()).readonly(),
13186
+ /** Present when the archive is encrypted; restore then needs that key. */
13187
+ encryption: BackupArchiveEncryptionSchema.optional()
11791
13188
  });
11792
13189
  var BackupEntrySchema = object({
11793
13190
  id: string(),
@@ -11796,7 +13193,8 @@ var BackupEntrySchema = object({
11796
13193
  label: string().optional(),
11797
13194
  createdAt: number(),
11798
13195
  sizeBytes: number(),
11799
- locations: array(string()).optional()
13196
+ locations: array(string()).optional(),
13197
+ encryption: BackupArchiveEncryptionSchema.optional()
11800
13198
  });
11801
13199
  var ArchiveEntrySchema = object({
11802
13200
  path: string(),
@@ -11985,10 +13383,40 @@ method(_void(), array(BackupDestinationInfoSchema).readonly(), { auth: "admin" }
11985
13383
  * this list and skips entries whose path doesn't start with
11986
13384
  * any of them.
11987
13385
  */
11988
- locations: array(string()).optional()
13386
+ locations: array(string()).optional(),
13387
+ /**
13388
+ * The backup SECRET key, for an encrypted archive (ignored for a plain
13389
+ * one). The archive is decrypted into the hub's private staging
13390
+ * before the restart; the key is not stored. A wrong or missing key
13391
+ * is refused before the archive is downloaded.
13392
+ */
13393
+ backupSecretKey: string().optional()
11989
13394
  }), _void(), {
11990
13395
  kind: "mutation",
11991
13396
  auth: "admin"
13397
+ }), method(_void(), BackupEncryptionStatusSchema, { auth: "admin" }), method(object({}), object({
13398
+ keyId: string(),
13399
+ secretKey: string(),
13400
+ publicKey: string(),
13401
+ createdAt: number(),
13402
+ replacedKeyId: string().nullable()
13403
+ }), {
13404
+ kind: "mutation",
13405
+ auth: "admin"
13406
+ }), method(object({}), object({ disabledKeyId: string().nullable() }), {
13407
+ kind: "mutation",
13408
+ auth: "admin"
13409
+ }), method(object({ backupSecretKey: string() }), object({
13410
+ valid: boolean(),
13411
+ keyId: string().nullable(),
13412
+ /** The hub knows this key (active or retired). */
13413
+ known: boolean(),
13414
+ /** It is the key new archives are encrypted to. */
13415
+ active: boolean(),
13416
+ error: string().optional()
13417
+ }), {
13418
+ kind: "mutation",
13419
+ auth: "admin"
11992
13420
  }), method(object({
11993
13421
  destinationId: string(),
11994
13422
  backupId: string()
@@ -13612,7 +15040,60 @@ var CustomModelDescriptorSchema = object({
13612
15040
  stepId: string(),
13613
15041
  entry: ModelCatalogEntrySchema
13614
15042
  });
13615
- method(_void(), array(CustomModelDescriptorSchema).readonly(), { auth: "admin" });
15043
+ /** One regular file of an imported bundle, as the producer measured it. */
15044
+ var ModelBundleFileSchema = object({
15045
+ /** Relative path inside the bundle tar; an mlpackage member is `<x>.mlpackage/<member>`. */
15046
+ path: string().min(1),
15047
+ bytes: number().int().nonnegative(),
15048
+ sha256: string().regex(/^[0-9a-f]{64}$/)
15049
+ });
15050
+ var ImportModelBundleInputSchema = object({
15051
+ /** The registry provider that keeps the model (Model Studio). */
15052
+ addonId: string(),
15053
+ stepId: string().min(1),
15054
+ /**
15055
+ * The catalog rows to register, complete, every format URL already
15056
+ * `camstack-local://<modelId>/<file>` naming a file of the bundle. One
15057
+ * bundle may carry several rows (a base and its INT8 variant).
15058
+ */
15059
+ entries: array(ModelCatalogEntrySchema).min(1).max(4),
15060
+ /** The bundle tar, offered by the producer over `ctx.peerBytes` (same host). */
15061
+ bundle: object({
15062
+ ticket: PeerBytesTicketSchema,
15063
+ bytes: number().int().positive(),
15064
+ sha256: string().regex(/^[0-9a-f]{64}$/)
15065
+ }),
15066
+ /** Every file the tar must hold; anything missing, extra or different is refused. */
15067
+ files: array(ModelBundleFileSchema).min(1).max(64),
15068
+ /** Convert missing engine formats and push the model to every agent afterwards. */
15069
+ distribute: boolean()
15070
+ });
15071
+ var ImportModelBundleResultSchema = discriminatedUnion("kind", [object({
15072
+ kind: literal("imported"),
15073
+ modelIds: array(string()).readonly(),
15074
+ distributed: array(object({
15075
+ modelId: string(),
15076
+ nodeId: string(),
15077
+ format: _enum(MODEL_FORMATS),
15078
+ ok: boolean(),
15079
+ error: string().optional()
15080
+ })).readonly()
15081
+ }), object({
15082
+ kind: literal("refused"),
15083
+ reason: _enum([
15084
+ "transfer-failed",
15085
+ "checksum-mismatch",
15086
+ "bundle-mismatch",
15087
+ "invalid-entry",
15088
+ "id-taken"
15089
+ ]),
15090
+ detail: string()
15091
+ })]);
15092
+ method(_void(), array(CustomModelDescriptorSchema).readonly(), { auth: "admin" }), method(ImportModelBundleInputSchema, ImportModelBundleResultSchema, {
15093
+ kind: "mutation",
15094
+ auth: "admin",
15095
+ timeoutMs: 30 * 6e4
15096
+ });
13616
15097
  /**
13617
15098
  * Query filter for settings-store collections.
13618
15099
  */
@@ -13995,6 +15476,253 @@ id: union([string(), number()]) }), {
13995
15476
  kind: "mutation",
13996
15477
  auth: "admin"
13997
15478
  });
15479
+ /**
15480
+ * `keychain` — the hub's encrypted store of secret values (D787).
15481
+ *
15482
+ * Settings blobs never hold a secret: they hold a marker
15483
+ * `{"$secret":"secret://<owner>/<scope>/<fieldPath>","v":1}` and the value
15484
+ * lives here, AES-256-GCM under a data key that a master key wraps. This cap
15485
+ * is the OWNER's door to its own values: every method is owner-checked
15486
+ * against the CALLER, never against anything the caller claims.
15487
+ *
15488
+ * Who the caller is: the transport stamps `callerAddonId` into the args of a
15489
+ * call that crossed a process (the parent `LocalChildRegistry` from the UDS
15490
+ * connection, the agent from its child's connection carried in
15491
+ * `$hub-cap-fwd`'s envelope). A stamp always overwrites; a wire call with no
15492
+ * stamp has its claim stripped. Only a hub in-process caller may state its own
15493
+ * identity — `ctx.secrets` does that with the addon id closed over. This is
15494
+ * identity against BUGS and misrouting, not against a malicious addon (every
15495
+ * runner is the same OS user): see the threat model in
15496
+ * `docs/design/2026-10-08-secrets-keychain.md`.
15497
+ *
15498
+ * `callerAddonId` is deliberately NOT in any input schema: the tRPC router
15499
+ * parses the input, so a session can never supply it, and the internal mount
15500
+ * floors every method to admin anyway (D240).
15501
+ *
15502
+ * Internal: addons reach it through `ctx.secrets`, never directly.
15503
+ */
15504
+ /** Why a value cannot be served right now. Never folded into "missing". */
15505
+ var KeychainUnavailableReasonSchema = _enum([
15506
+ "key-missing",
15507
+ "wrong-key",
15508
+ "key-file-unreadable",
15509
+ "store-unavailable",
15510
+ "not-initialized",
15511
+ "decrypt-failed"
15512
+ ]);
15513
+ var KeychainStateSchema = discriminatedUnion("state", [object({ state: literal("ready") }), object({
15514
+ state: literal("locked"),
15515
+ reason: KeychainUnavailableReasonSchema
15516
+ })]);
15517
+ var KeychainResolveEntrySchema = discriminatedUnion("kind", [
15518
+ object({
15519
+ kind: literal("value"),
15520
+ value: string(),
15521
+ version: number().int()
15522
+ }),
15523
+ object({ kind: literal("missing") }),
15524
+ object({
15525
+ kind: literal("unavailable"),
15526
+ reason: KeychainUnavailableReasonSchema
15527
+ }),
15528
+ object({ kind: literal("forbidden") })
15529
+ ]);
15530
+ var KeychainResolveResultSchema = record(string(), KeychainResolveEntrySchema);
15531
+ /** Metadata of one stored value — never the value. */
15532
+ var KeychainSecretMetaSchema = object({
15533
+ ref: string(),
15534
+ owner: string(),
15535
+ /** Formatted scope (`global`, `node/<id>`, `device/<id>`, …). */
15536
+ scope: string(),
15537
+ fieldPath: string(),
15538
+ version: number().int(),
15539
+ createdAt: number(),
15540
+ updatedAt: number(),
15541
+ /** `addon:<id>` | `user:<id>` | `system`. */
15542
+ updatedBy: string(),
15543
+ /** Coarse — written at most once an hour per ref. `null` = never read. */
15544
+ lastReadAt: number().nullable()
15545
+ });
15546
+ var RefListSchema = array(string().min(1)).max(512);
15547
+ method(object({
15548
+ ref: string().min(1),
15549
+ value: string().min(1)
15550
+ }), object({
15551
+ ref: string(),
15552
+ version: number().int()
15553
+ }), {
15554
+ kind: "mutation",
15555
+ auth: "admin"
15556
+ }), method(object({ refs: RefListSchema }), KeychainResolveResultSchema, { auth: "admin" }), method(object({ refs: RefListSchema }), object({ deleted: number().int() }), {
15557
+ kind: "mutation",
15558
+ auth: "admin"
15559
+ }), method(object({}), array(KeychainSecretMetaSchema).readonly(), { auth: "admin" }), method(object({}), KeychainStateSchema, { auth: "admin" });
15560
+ var KeychainKeySourceSchema = object({
15561
+ kind: _enum([
15562
+ "config-file",
15563
+ "previous-config-file",
15564
+ "platform",
15565
+ "default-file"
15566
+ ]),
15567
+ /** File sources only — a path is not a secret. */
15568
+ path: string().optional(),
15569
+ /**
15570
+ * True when a whole-volume backup of the data directory carries this key
15571
+ * next to the database it protects (the default file). The page warns.
15572
+ */
15573
+ sharesBackupWithDatabase: boolean()
15574
+ });
15575
+ /**
15576
+ * One keychain reset, as the Secrets page reports it until the operator
15577
+ * acknowledges it. Never a value: refs, counts and table names only.
15578
+ */
15579
+ var KeychainResetRecordSchema = object({
15580
+ id: string(),
15581
+ at: number(),
15582
+ /** `user:<id>` or {@link KEYCHAIN_RESET_TRIGGER_ACTOR}. */
15583
+ actor: string(),
15584
+ /** Why the keychain was locked when it was reset; `null` when it was not locked. */
15585
+ lockedReason: string().nullable(),
15586
+ /** Values moved into the archive table (ciphertext under the lost key). */
15587
+ archived: number().int(),
15588
+ /** `keychain:secrets-orphaned-<ts>`, or `null` when nothing was stored. */
15589
+ archivedCollection: string().nullable(),
15590
+ /**
15591
+ * `keychain:keys-orphaned-<ts>`: the wrapped data keys of the archive, kept
15592
+ * so the archive can still be opened if the lost master key turns up.
15593
+ */
15594
+ archivedKeysCollection: string().nullable(),
15595
+ /**
15596
+ * `system-settings` keys whose marker the reset cleared — the cluster
15597
+ * secret's: a marker left pointing at an archived value would refuse every
15598
+ * agent forever (D797).
15599
+ */
15600
+ clearedSettingsKeys: array(string()).readonly(),
15601
+ /** When an operator dismissed the notice on the Secrets page; `null` until then. */
15602
+ acknowledgedAt: number().nullable()
15603
+ });
15604
+ var KeychainStatusSchema = object({
15605
+ keychain: KeychainStateSchema,
15606
+ /** The source of the master key in use; `null` while locked. */
15607
+ keySource: KeychainKeySourceSchema.nullable(),
15608
+ /** The source configured to be primary — differs from `keySource` while a rotation is pending. */
15609
+ configuredSource: KeychainKeySourceSchema,
15610
+ /** Short fingerprint of the master key in use (`HMAC(KEK, label)`, 16 hex). */
15611
+ fingerprint: string().nullable(),
15612
+ activeKeyId: string().nullable(),
15613
+ /**
15614
+ * The keychain unlocked with a NON-primary source: the configured primary
15615
+ * key is not the one that wraps the data key yet. `rotateMasterKey` moves it.
15616
+ */
15617
+ rotationPending: boolean(),
15618
+ /** Wrapped copies of the data key under a previous master key, kept until purged. */
15619
+ retiredWraps: number().int(),
15620
+ recoveryKeyDownloadedAt: number().nullable(),
15621
+ secretCount: number().int(),
15622
+ /** The most recent reset, acknowledged or not; `null` when the keychain was never reset. */
15623
+ lastReset: KeychainResetRecordSchema.nullable()
15624
+ });
15625
+ /**
15626
+ * Whether a stored value is still pointed at by its owner's settings.
15627
+ * `unknown` is a first-class answer: a scope whose blob could not be read is
15628
+ * never reported as an orphan (and never deleted as one).
15629
+ */
15630
+ var KeychainSecretUsageSchema = _enum([
15631
+ "in-use",
15632
+ "orphan",
15633
+ "unknown"
15634
+ ]);
15635
+ var KeychainAdminSecretSchema = KeychainSecretMetaSchema.extend({ usage: KeychainSecretUsageSchema });
15636
+ var KeychainAuditActionSchema = _enum([
15637
+ "put",
15638
+ "delete",
15639
+ "reveal",
15640
+ "rotate-master-key",
15641
+ "purge-retired-keys",
15642
+ "download-recovery-key",
15643
+ "delete-orphans",
15644
+ "reset",
15645
+ "acknowledge-reset",
15646
+ "initialize"
15647
+ ]);
15648
+ var KeychainAuditEntrySchema = object({
15649
+ id: string(),
15650
+ at: number(),
15651
+ action: KeychainAuditActionSchema,
15652
+ /** `addon:<id>` | `user:<id>` | `system` | `trigger-file`. */
15653
+ actor: string(),
15654
+ ref: string().nullable(),
15655
+ detail: string().nullable()
15656
+ });
15657
+ var KEYCHAIN_RESET_CONFIRMATION = "RESET KEYCHAIN";
15658
+ /**
15659
+ * Secrets the HUB itself holds (owner `system`) that no settings form shows:
15660
+ * `jwt-signing-key` — the session signing key (D797). It is always "in use",
15661
+ * never an orphan; it is generated on a fresh hub and replaced only through
15662
+ * {@link keychainAdminCapability.methods.setSystemSecret}.
15663
+ */
15664
+ var SystemHeldSecretNameSchema = _enum(["jwt-signing-key"]);
15665
+ 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({
15666
+ value: string(),
15667
+ version: number().int()
15668
+ }), {
15669
+ kind: "mutation",
15670
+ auth: "admin",
15671
+ caller: "required"
15672
+ }), method(object({
15673
+ name: SystemHeldSecretNameSchema,
15674
+ value: string().min(16)
15675
+ }), object({
15676
+ ref: string(),
15677
+ version: number().int()
15678
+ }), {
15679
+ kind: "mutation",
15680
+ auth: "admin",
15681
+ caller: "required"
15682
+ }), method(object({ refs: array(string().min(1)).max(1e3) }), object({
15683
+ deleted: array(string()).readonly(),
15684
+ kept: array(object({
15685
+ ref: string(),
15686
+ usage: KeychainSecretUsageSchema
15687
+ })).readonly()
15688
+ }), {
15689
+ kind: "mutation",
15690
+ auth: "admin",
15691
+ caller: "required"
15692
+ }), method(object({}), object({
15693
+ fingerprint: string(),
15694
+ keySource: KeychainKeySourceSchema
15695
+ }), {
15696
+ kind: "mutation",
15697
+ auth: "admin",
15698
+ caller: "required"
15699
+ }), method(object({}), object({ purged: number().int() }), {
15700
+ kind: "mutation",
15701
+ auth: "admin",
15702
+ caller: "required"
15703
+ }), method(object({}), object({
15704
+ key: string(),
15705
+ fingerprint: string(),
15706
+ keySource: KeychainKeySourceSchema
15707
+ }), {
15708
+ kind: "mutation",
15709
+ auth: "admin",
15710
+ caller: "required"
15711
+ }), method(object({ confirm: literal(KEYCHAIN_RESET_CONFIRMATION) }), object({
15712
+ archivedCollection: string().nullable(),
15713
+ archived: number().int()
15714
+ }), {
15715
+ kind: "mutation",
15716
+ auth: "admin",
15717
+ caller: "required"
15718
+ }), method(object({}), object({
15719
+ reset: KeychainResetRecordSchema.nullable(),
15720
+ pendingReentry: array(KeychainSecretMetaSchema).readonly()
15721
+ }), { auth: "admin" }), method(object({}), object({ acknowledged: boolean() }), {
15722
+ kind: "mutation",
15723
+ auth: "admin",
15724
+ caller: "required"
15725
+ });
13998
15726
  method(_void(), object({
13999
15727
  id: string(),
14000
15728
  name: string(),
@@ -15032,7 +16760,11 @@ var DeviceRegisterPayloadSchema = object({
15032
16760
  var DeviceRemovePayloadSchema = object({ deviceId: number() });
15033
16761
  var DevicePersistConfigPayloadSchema = object({
15034
16762
  deviceId: number(),
15035
- data: record(string(), unknown())
16763
+ data: record(string(), unknown()),
16764
+ /** The paths the device's schema declares secret (D783), when the caller
16765
+ * knows them — those values are kept in the keychain, not the blob (D787).
16766
+ * Absent: the paths the device last reported at `registerDevice` apply. */
16767
+ secretConfigPaths: array(string()).optional()
15036
16768
  });
15037
16769
  /** What a migration actually did, per switch. `unreachable` is a first-class
15038
16770
  * answer: a camera that could not be asked is not a camera that was silenced. */
@@ -16635,7 +18367,7 @@ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
16635
18367
  * `login-method` — collection cap through which auth addons contribute
16636
18368
  * their pre-auth login surfaces to the login page. This is the SINGLE,
16637
18369
  * generic mechanism that supersedes the dead `auth.listProviders` reader:
16638
- * every auth addon (OIDC, magic-link, WebAuthn/passkey) registers a
18370
+ * every auth addon (OIDC, WebAuthn/passkey) registers a
16639
18371
  * `login-method` provider and the PUBLIC `auth.listLoginMethods`
16640
18372
  * procedure aggregates them for the unauthenticated login page.
16641
18373
  *
@@ -16643,8 +18375,7 @@ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
16643
18375
  *
16644
18376
  * - `redirect` — a declarative button. The login page renders a generic
16645
18377
  * button that navigates to `startUrl` (an addon-owned HTTP route).
16646
- * Covers OIDC (`/addon/auth-oidc/<id>/start`) and magic-link with
16647
- * ZERO shell-side JS. A future SSO addon plugs in the same way — the
18378
+ * Covers OIDC (`/addon/auth-oidc/<id>/start`) with ZERO shell-side JS. A future SSO addon plugs in the same way — the
16648
18379
  * login page needs NO change.
16649
18380
  *
16650
18381
  * - `widget` — a Module-Federation widget the login page mounts (via
@@ -16663,8 +18394,8 @@ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
16663
18394
  * decision.
16664
18395
  *
16665
18396
  * Every contribution carries a `stage`:
16666
- * - `primary` — shown on the first credentials screen (OIDC /
16667
- * magic-link buttons; a future usernameless passkey).
18397
+ * - `primary` — shown on the first credentials screen (OIDC
18398
+ * buttons; a usernameless passkey).
16668
18399
  * - `second-factor` — shown AFTER the password leg, gated on the
16669
18400
  * returned `factors` (passkey-as-2FA today).
16670
18401
  *
@@ -16691,7 +18422,7 @@ var LoginMethodContributionSchema = discriminatedUnion("kind", [
16691
18422
  * The provider names an external identity a signed-in user can link to
16692
18423
  * their own account (D782): `auth.listLinkableProviders` /
16693
18424
  * `beginExternalLink` offer exactly the redirect methods that set this,
16694
- * whatever their id. Absent / false — a login button only (magic-link).
18425
+ * whatever their id. Absent / false — a login button only.
16695
18426
  */
16696
18427
  linkable: boolean().optional()
16697
18428
  }),
@@ -20508,8 +22239,7 @@ method(object({}), object({ rules: array(NcRuleSchema) }), { auth: "admin" }), m
20508
22239
  * `super_admin` — collapsed onto the single boolean because every
20509
22240
  * non-admin caller is governed by the same scope-check rules; the
20510
22241
  * distinction was only ever used to route role-specific procedures
20511
- * which we no longer have. Agents are admin sessions issued via
20512
- * `createServiceToken`; CLI / webhook integrations are `cst_*` tokens
22242
+ * which we no longer have. CLI / webhook integrations are `cst_*` tokens
20513
22243
  * with `isAdmin: false` + an explicit scope list.
20514
22244
  */
20515
22245
  /** Per-method access flavour. Materialised on every cap method via codegen. */
@@ -22011,8 +23741,23 @@ var RetrainMacroClassSchema = _enum([
22011
23741
  ]);
22012
23742
  /** A subject to learn, or a phantom to unlearn (taught by OMISSION). */
22013
23743
  var RetrainAnnotationKindSchema = _enum(["subject", "model_error"]);
22014
- /** Did a human draw this box, or did the assist propose it? */
22015
- var RetrainAnnotationSourceSchema = _enum(["operator", "assist"]);
23744
+ /**
23745
+ * Where a box came from. A machine-sourced box is a DRAFT on the page until
23746
+ * the operator confirms it; once saved it keeps its source as provenance.
23747
+ *
23748
+ * - `operator` — drawn by hand.
23749
+ * - `assist` — proposed by a detector run on the copy (the camera's own
23750
+ * model, or a larger teacher model).
23751
+ * - `pipeline` — the box the live pipeline actually drew on that frame, read
23752
+ * back from the track store (never a re-run).
23753
+ * - `llm` — proposed by a vision-capable LLM profile.
23754
+ */
23755
+ var RetrainAnnotationSourceSchema = _enum([
23756
+ "operator",
23757
+ "assist",
23758
+ "pipeline",
23759
+ "llm"
23760
+ ]);
22016
23761
  /** Normalised `[0,1]` rectangle against the FULL frame — the canonical form. */
22017
23762
  var RetrainBboxSchema = object({
22018
23763
  x: number(),
@@ -22030,7 +23775,8 @@ var RetrainBboxSchema = object({
22030
23775
  */
22031
23776
  var RetrainAnnotationSchema = object({
22032
23777
  id: string(),
22033
- trackId: string(),
23778
+ /** The frame's track. Absent on a recording still, which has none. */
23779
+ trackId: string().optional(),
22034
23780
  deviceId: number(),
22035
23781
  /** The COPY in retrain storage — never the source track's media key. */
22036
23782
  mediaKey: string(),
@@ -22079,13 +23825,47 @@ var RetrainFrameCandidateSchema = object({
22079
23825
  * fail, whatever became of the original. */
22080
23826
  copied: boolean()
22081
23827
  });
23828
+ /**
23829
+ * One box the live pipeline drew on a copied frame — what a correction starts
23830
+ * from. Derived when the frame is listed, from the track store: the subject
23831
+ * box recorded on the source media row when there is one, else the track
23832
+ * position nearest the frame's capture time. Never stored as an annotation
23833
+ * until the operator confirms it.
23834
+ */
23835
+ var RetrainPipelineBoxSchema = object({
23836
+ /** Normalised `[0,1]` against the full frame. */
23837
+ bbox: RetrainBboxSchema,
23838
+ macroClass: RetrainMacroClassSchema,
23839
+ label: string().optional(),
23840
+ subLabel: string().optional(),
23841
+ /** The detection score of the position used, when it was recorded. */
23842
+ score: number().optional(),
23843
+ /** The root model that produced the track, when it was recorded. */
23844
+ modelId: string().optional(),
23845
+ trackId: string(),
23846
+ /** `subject-box`: recorded on this very frame. `position`: the track's
23847
+ * position nearest the capture time, `deltaMs` away. */
23848
+ basis: _enum(["subject-box", "position"]),
23849
+ deltaMs: number()
23850
+ });
23851
+ /**
23852
+ * Where a retrain frame came from: a TRACK's stored media (copy-on-select),
23853
+ * or the RECORDING at an instant — the frame a model saw nothing in has no
23854
+ * track at all.
23855
+ */
23856
+ var RetrainFrameOriginSchema = _enum(["track", "recording"]);
22082
23857
  /** A frame the dataset OWNS: bytes copied at selection time. */
22083
23858
  var RetrainFrameSchema = object({
22084
23859
  frameId: string(),
22085
23860
  deviceId: number(),
22086
- trackId: string(),
22087
- /** Provenance only. It may already point at nothing — that is expected. */
22088
- sourceMediaId: number().int(),
23861
+ origin: RetrainFrameOriginSchema,
23862
+ /** The track it was copied from. Absent on a recording still. */
23863
+ trackId: string().optional(),
23864
+ /** Provenance only. It may already point at nothing — that is expected.
23865
+ * Absent on a recording still. */
23866
+ sourceMediaId: number().int().optional(),
23867
+ /** A recording still: the playhead instant it was taken at. */
23868
+ epochMs: number().optional(),
22089
23869
  sourceKind: MediaFileKindEnum,
22090
23870
  sizeBytes: number().int(),
22091
23871
  width: number().int(),
@@ -22096,7 +23876,12 @@ var RetrainFrameSchema = object({
22096
23876
  /** The operator's "every subject in this frame is boxed". Detector
22097
23877
  * evaluation keeps only complete frames: an unboxed subject would count as
22098
23878
  * a false positive. */
22099
- complete: boolean()
23879
+ complete: boolean(),
23880
+ /** The boxes the pipeline drew on this frame. Present on list answers;
23881
+ * empty when nothing the track store holds can be placed on it. */
23882
+ pipelineBoxes: array(RetrainPipelineBoxSchema).readonly().optional(),
23883
+ /** The named collections this frame belongs to. Present on list answers. */
23884
+ collectionIds: array(string()).readonly().optional()
22100
23885
  });
22101
23886
  /** Why a copy-on-select could not be honoured — named, never a silent skip. */
22102
23887
  var RetrainCopyRefusalSchema = _enum([
@@ -22127,6 +23912,11 @@ var RetrainFrameListSchema = object({
22127
23912
  var RetrainExportFilterSchema = object({
22128
23913
  deviceIds: array(number()).optional(),
22129
23914
  frameIds: array(string()).max(2e4).optional(),
23915
+ /** Only frames in at least one of these named collections. */
23916
+ collectionIds: array(string()).max(200).optional(),
23917
+ /** Exactly the frames of this dataset version (and its completeOnly). An
23918
+ * unknown id selects nothing. */
23919
+ datasetVersionId: string().optional(),
22130
23920
  batchId: string().optional(),
22131
23921
  /** Only frames the operator marked complete (all subjects boxed). */
22132
23922
  completeOnly: boolean().optional()
@@ -22191,6 +23981,170 @@ var RetrainAssistResultSchema = discriminatedUnion("kind", [object({
22191
23981
  reason: string(),
22192
23982
  detail: string().optional()
22193
23983
  })]);
23984
+ /** A named set over the retrain corpus — membership only, it owns no pixels. */
23985
+ var RetrainCollectionSchema = object({
23986
+ id: string(),
23987
+ name: string(),
23988
+ createdAt: number(),
23989
+ frameCount: number().int()
23990
+ });
23991
+ var RetrainCollectionCreateResultSchema = discriminatedUnion("kind", [object({
23992
+ kind: literal("created"),
23993
+ collection: RetrainCollectionSchema
23994
+ }), object({
23995
+ kind: literal("refused"),
23996
+ reason: _enum(["empty-name", "duplicate-name"])
23997
+ })]);
23998
+ var RetrainCollectionRenameResultSchema = discriminatedUnion("kind", [object({
23999
+ kind: literal("renamed"),
24000
+ collection: RetrainCollectionSchema
24001
+ }), object({
24002
+ kind: literal("refused"),
24003
+ reason: _enum([
24004
+ "empty-name",
24005
+ "duplicate-name",
24006
+ "unknown-collection"
24007
+ ])
24008
+ })]);
24009
+ /**
24010
+ * The outcome of adding the frame at a recording instant. Every refusal is
24011
+ * named: `still-unavailable` (not recording, a gap, or an undecodable frame —
24012
+ * `detail` says which), `still-busy` (the recorder is at its decode bound; try
24013
+ * again), `unreadable-image`, `write-failed`, `unknown-collection`.
24014
+ */
24015
+ var AddRetrainFrameFromRecordingResultSchema = discriminatedUnion("kind", [object({
24016
+ kind: literal("added"),
24017
+ collectionId: string(),
24018
+ frame: RetrainFrameSchema,
24019
+ /** The moment was already in the dataset; nothing was decoded. */
24020
+ reused: boolean()
24021
+ }), object({
24022
+ kind: literal("refused"),
24023
+ reason: _enum([
24024
+ "unknown-collection",
24025
+ "still-unavailable",
24026
+ "still-busy",
24027
+ "unreadable-image",
24028
+ "write-failed"
24029
+ ]),
24030
+ detail: string().optional()
24031
+ })]);
24032
+ /** A vision LLM profile the AI assist may use, and where it sends the frame. */
24033
+ var RetrainAssistProfileSchema = object({
24034
+ id: string(),
24035
+ name: string(),
24036
+ model: string(),
24037
+ kind: string(),
24038
+ /** `true` when the frame would leave the house (a cloud vendor, or an
24039
+ * endpoint that is not on the local network). The page confirms each such
24040
+ * run, and the provider refuses one without `allowCloud`. */
24041
+ leavesHouse: boolean()
24042
+ });
24043
+ /** A box the AI assist proposed: a draft, plus the model's own reason. */
24044
+ var RetrainLlmProposalSchema = RetrainAnnotationDraftSchema.extend({ reason: string() });
24045
+ /** What the AI assist said about a box that was already on the canvas. */
24046
+ var RetrainLlmReviewSchema = object({
24047
+ /** The `ref` the page sent the box under. */
24048
+ ref: string(),
24049
+ verdict: _enum([
24050
+ "confirmed",
24051
+ "wrong-class",
24052
+ "not-an-object",
24053
+ "uncertain"
24054
+ ]),
24055
+ suggestedClass: RetrainMacroClassSchema.optional(),
24056
+ reason: string()
24057
+ });
24058
+ /**
24059
+ * The AI assist's answer. `proposed` carries drafts (`source: 'llm'`, the
24060
+ * model and its confidence) and reviews; items the model got wrong (a box off
24061
+ * the frame, an unasked class, an unknown ref) are dropped and counted in
24062
+ * `rejected`. A whole answer that is not the schema is `malformed-answer`.
24063
+ */
24064
+ var RetrainLlmAssistResultSchema = discriminatedUnion("kind", [object({
24065
+ kind: literal("proposed"),
24066
+ profileId: string(),
24067
+ model: string(),
24068
+ /** The frame was sent outside the house for this answer. */
24069
+ leftHouse: boolean(),
24070
+ proposals: array(RetrainLlmProposalSchema).readonly(),
24071
+ reviews: array(RetrainLlmReviewSchema).readonly(),
24072
+ rejected: number().int()
24073
+ }), object({
24074
+ kind: literal("refused"),
24075
+ reason: _enum([
24076
+ "unknown-frame",
24077
+ "unreadable-frame",
24078
+ "unknown-profile",
24079
+ "profile-disabled",
24080
+ "no-vision",
24081
+ "cloud-not-confirmed",
24082
+ "llm-error",
24083
+ "malformed-answer"
24084
+ ]),
24085
+ detail: string().optional()
24086
+ })]);
24087
+ /** What a dataset version is cut from. Every field narrows. */
24088
+ var RetrainDatasetSelectionSchema = object({
24089
+ deviceIds: array(number()).readonly().optional(),
24090
+ collectionIds: array(string()).max(200).readonly().optional(),
24091
+ frameIds: array(string()).max(2e4).readonly().optional()
24092
+ });
24093
+ /** The counts a dataset is judged by. */
24094
+ var RetrainDatasetStatsSchema = object({
24095
+ frames: number().int(),
24096
+ completeFrames: number().int(),
24097
+ /** `completeFrames / frames`, 0..1. */
24098
+ completeness: number(),
24099
+ /** Boxes to learn (model errors excluded). */
24100
+ subjects: number().int(),
24101
+ modelErrors: number().int(),
24102
+ /** Complete frames with no subject. */
24103
+ hardNegatives: number().int(),
24104
+ /** Subjects per class × camera × day/night. */
24105
+ cells: array(object({
24106
+ macroClass: string(),
24107
+ deviceId: number(),
24108
+ lighting: _enum([
24109
+ "day",
24110
+ "night",
24111
+ "unknown"
24112
+ ]),
24113
+ subjects: number().int(),
24114
+ frames: number().int()
24115
+ })).readonly(),
24116
+ cameras: array(object({
24117
+ deviceId: number(),
24118
+ frames: number().int(),
24119
+ completeFrames: number().int()
24120
+ })).readonly()
24121
+ });
24122
+ /** An immutable dataset version, without its frame list. */
24123
+ var RetrainDatasetVersionSchema = object({
24124
+ id: string(),
24125
+ name: string(),
24126
+ createdAt: number(),
24127
+ selection: RetrainDatasetSelectionSchema,
24128
+ layout: RetrainExportLayoutSchema,
24129
+ completeOnly: boolean(),
24130
+ frameCount: number().int(),
24131
+ /** sha256 of what the frames taught when the version was frozen. */
24132
+ annotationHash: string(),
24133
+ /** The export manifest schema the version was cut under. */
24134
+ manifestSchema: string(),
24135
+ stats: RetrainDatasetStatsSchema
24136
+ });
24137
+ var CreateRetrainDatasetVersionResultSchema = discriminatedUnion("kind", [object({
24138
+ kind: literal("created"),
24139
+ version: RetrainDatasetVersionSchema
24140
+ }), object({
24141
+ kind: literal("refused"),
24142
+ reason: _enum([
24143
+ "empty-name",
24144
+ "duplicate-name",
24145
+ "no-frames"
24146
+ ])
24147
+ })]);
22194
24148
  /** The outcome of a lifecycle move owned by the retrain page. */
22195
24149
  var RetrainTransitionResultSchema = object({
22196
24150
  trackId: string(),
@@ -22908,7 +24862,7 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
22908
24862
  auth: "admin"
22909
24863
  }), method(object({
22910
24864
  deviceId: number(),
22911
- trackId: string(),
24865
+ trackId: string().optional(),
22912
24866
  frameId: string()
22913
24867
  }), object({
22914
24868
  removed: boolean(),
@@ -22925,7 +24879,8 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
22925
24879
  auth: "admin"
22926
24880
  }), method(object({
22927
24881
  deviceId: number(),
22928
- trackId: string(),
24882
+ /** The frame's track, when it has one — checked against the frame. */
24883
+ trackId: string().optional(),
22929
24884
  frameId: string(),
22930
24885
  subject: RetrainAssistSubjectSchema,
22931
24886
  /** Which node runs it. Absent ⇒ wherever an unowned call lands. */
@@ -22933,12 +24888,16 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
22933
24888
  }), RetrainAssistResultSchema, {
22934
24889
  kind: "mutation",
22935
24890
  auth: "admin"
22936
- }), method(object({ trackId: string() }), array(RetrainAnnotationSchema).readonly(), {
24891
+ }), method(object({
24892
+ trackId: string().optional(),
24893
+ frameIds: array(string()).max(2e3).optional()
24894
+ }), array(RetrainAnnotationSchema).readonly(), {
22937
24895
  kind: "query",
22938
24896
  auth: "admin"
22939
24897
  }), method(object({
22940
24898
  deviceId: number(),
22941
- trackId: string(),
24899
+ /** The frame's track, when it has one — checked against the frame. */
24900
+ trackId: string().optional(),
22942
24901
  frameId: string(),
22943
24902
  annotations: array(RetrainAnnotationDraftSchema)
22944
24903
  }), array(RetrainAnnotationSchema).readonly(), {
@@ -22961,7 +24920,7 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
22961
24920
  auth: "admin"
22962
24921
  }), method(object({
22963
24922
  deviceId: number(),
22964
- trackId: string(),
24923
+ trackId: string().optional(),
22965
24924
  frameId: string(),
22966
24925
  complete: boolean()
22967
24926
  }), RetrainFrameSchema, {
@@ -22975,6 +24934,115 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
22975
24934
  kind: "mutation",
22976
24935
  auth: "admin",
22977
24936
  timeoutMs: 60 * 6e4
24937
+ }), method(object({
24938
+ filter: RetrainExportFilterSchema,
24939
+ layout: RetrainExportLayoutSchema
24940
+ }), object({
24941
+ ticket: PeerBytesTicketSchema,
24942
+ frames: number().int(),
24943
+ annotations: number().int()
24944
+ }), {
24945
+ kind: "mutation",
24946
+ auth: "admin",
24947
+ timeoutMs: 12e4
24948
+ }), method(object({
24949
+ selection: RetrainDatasetSelectionSchema,
24950
+ completeOnly: boolean().optional()
24951
+ }), RetrainDatasetStatsSchema, {
24952
+ kind: "query",
24953
+ auth: "admin"
24954
+ }), method(object({
24955
+ name: string().max(120),
24956
+ selection: RetrainDatasetSelectionSchema,
24957
+ layout: RetrainExportLayoutSchema,
24958
+ completeOnly: boolean()
24959
+ }), CreateRetrainDatasetVersionResultSchema, {
24960
+ kind: "mutation",
24961
+ auth: "admin",
24962
+ timeoutMs: 12e4
24963
+ }), method(object({}), array(RetrainDatasetVersionSchema).readonly(), {
24964
+ kind: "query",
24965
+ auth: "admin"
24966
+ }), method(object({ id: string() }), object({ deleted: boolean() }), {
24967
+ kind: "mutation",
24968
+ auth: "admin"
24969
+ }), method(object({ id: string() }), object({
24970
+ found: boolean(),
24971
+ annotationHash: string(),
24972
+ matches: boolean(),
24973
+ missingFrames: number().int()
24974
+ }), {
24975
+ kind: "query",
24976
+ auth: "admin",
24977
+ timeoutMs: 12e4
24978
+ }), method(object({}), array(RetrainAssistProfileSchema).readonly(), {
24979
+ kind: "query",
24980
+ auth: "admin"
24981
+ }), method(object({
24982
+ deviceId: number(),
24983
+ trackId: string().optional(),
24984
+ frameId: string(),
24985
+ profileId: string(),
24986
+ classes: array(RetrainMacroClassSchema).min(1),
24987
+ boxes: array(object({
24988
+ ref: string(),
24989
+ bbox: RetrainBboxSchema,
24990
+ macroClass: RetrainMacroClassSchema,
24991
+ label: string().optional()
24992
+ })).max(50),
24993
+ allowCloud: boolean()
24994
+ }), RetrainLlmAssistResultSchema, {
24995
+ kind: "mutation",
24996
+ auth: "admin",
24997
+ timeoutMs: 18e4
24998
+ }), method(object({ name: string().max(120) }), RetrainCollectionCreateResultSchema, {
24999
+ kind: "mutation",
25000
+ auth: "admin"
25001
+ }), method(object({}), array(RetrainCollectionSchema).readonly(), {
25002
+ kind: "query",
25003
+ auth: "admin"
25004
+ }), method(object({
25005
+ id: string(),
25006
+ name: string().max(120)
25007
+ }), RetrainCollectionRenameResultSchema, {
25008
+ kind: "mutation",
25009
+ auth: "admin"
25010
+ }), method(object({ id: string() }), object({
25011
+ deleted: boolean(),
25012
+ removedFrames: number().int()
25013
+ }), {
25014
+ kind: "mutation",
25015
+ auth: "admin"
25016
+ }), method(object({
25017
+ collectionId: string(),
25018
+ deviceId: number(),
25019
+ epochMs: number()
25020
+ }), AddRetrainFrameFromRecordingResultSchema, {
25021
+ kind: "mutation",
25022
+ auth: "admin",
25023
+ timeoutMs: 6e4
25024
+ }), method(object({
25025
+ collectionId: string(),
25026
+ frameIds: array(string()).min(1).max(500)
25027
+ }), object({
25028
+ added: number().int(),
25029
+ alreadyMember: number().int(),
25030
+ unknownFrameIds: array(string()).readonly()
25031
+ }), {
25032
+ kind: "mutation",
25033
+ auth: "admin"
25034
+ }), method(object({
25035
+ collectionId: string(),
25036
+ frameId: string()
25037
+ }), object({
25038
+ removed: boolean(),
25039
+ deletedFrame: boolean()
25040
+ }), {
25041
+ kind: "mutation",
25042
+ auth: "admin"
25043
+ }), method(object({ collectionId: string() }), array(RetrainFrameSchema).readonly(), {
25044
+ kind: "query",
25045
+ auth: "admin"
22978
25046
  }), method(object({
22979
25047
  /** Which of the three event tables owns the row. */
22980
25048
  ownerType: EventOwnerTypeSchema,
@@ -23598,13 +25666,31 @@ var RecommendationReasonSchema = discriminatedUnion("kind", [
23598
25666
  object({
23599
25667
  kind: literal("no-family-build"),
23600
25668
  format: ModelFormatSchema$1
25669
+ }),
25670
+ object({
25671
+ kind: literal("kept-custom-pin"),
25672
+ modelId: string(),
25673
+ deviceKey: string()
23601
25674
  })
23602
25675
  ]);
25676
+ /** Why a device is left exactly as it is, whatever the plan would pick (D786). */
25677
+ var KeptReasonSchema = _enum(["custom-pin"]);
25678
+ /**
25679
+ * Where a choice's latency came from (D791): this node's own benchmark
25680
+ * result, or the hardware-class table. Measured on the node beats the table.
25681
+ */
25682
+ var LatencySourceSchema = discriminatedUnion("kind", [object({ kind: literal("table") }), object({
25683
+ kind: literal("node-benchmark"),
25684
+ resultId: string(),
25685
+ measuredAtMs: number()
25686
+ })]);
23603
25687
  var DeviceModelChoiceSchema = object({
23604
25688
  modelId: string(),
23605
25689
  p50Ms: number(),
23606
25690
  fps: number(),
23607
25691
  measured: boolean(),
25692
+ /** Absent on a plan from before D791 — read as the table. */
25693
+ source: LatencySourceSchema.optional(),
23608
25694
  /** Parallel sessions at the camera rate with the headroom kept free: ⌊fps × (1 − headroom) / camera fps⌋. */
23609
25695
  capacitySessions: number(),
23610
25696
  personRecall: number()
@@ -23615,6 +25701,8 @@ var DeviceRecommendationSchema = object({
23615
25701
  enabled: boolean(),
23616
25702
  available: boolean(),
23617
25703
  chosen: DeviceModelChoiceSchema.nullable(),
25704
+ /** Present when the device is kept as is: Apply writes nothing on it. */
25705
+ kept: KeptReasonSchema.optional(),
23618
25706
  reasons: array(RecommendationReasonSchema).readonly()
23619
25707
  });
23620
25708
  var NodeRecommendationSchema = object({
@@ -23668,6 +25756,17 @@ var AutoTuneWarningSchema = discriminatedUnion("kind", [
23668
25756
  kind: literal("coral-enabled"),
23669
25757
  nodeId: string(),
23670
25758
  deviceKey: string()
25759
+ }),
25760
+ object({
25761
+ kind: literal("custom-pin-kept"),
25762
+ nodeId: string(),
25763
+ deviceKey: string().nullable(),
25764
+ deviceId: number().nullable(),
25765
+ modelId: string()
25766
+ }),
25767
+ object({
25768
+ kind: literal("custom-registry-unreadable"),
25769
+ error: string()
23671
25770
  })
23672
25771
  ]);
23673
25772
  var AutoTuneOptionsSchema = object({
@@ -23846,13 +25945,14 @@ var SuggestSharesResultSchema = object({
23846
25945
  nodes: array(SuggestedNodeShareSchema).readonly()
23847
25946
  });
23848
25947
  /**
23849
- * Where the node and device shares come from (D750, D755).
23850
- * - `hardware` (default) — computed by the system from each node's static
23851
- * capacity (its accelerators at their Auto tune models, from the measured
23852
- * latency table), recomputed whenever a node or device joins, leaves, is
23853
- * switched on or off, or changes model. No load input.
23854
- * - `benchmark` — the same, from each node's measured capacity (node
23855
- * benchmark results); a node without results falls back to `hardware`.
25948
+ * Where the node and device shares come from (D750, D755, D791).
25949
+ * - `benchmark` (default since D791) — each node's capacity as its own node
25950
+ * benchmark measured it; a node without fresh results is sized from
25951
+ * `hardware` and says so. Measured on the node beats the table.
25952
+ * - `hardware` — computed from each node's static capacity only (its
25953
+ * accelerators at their Auto tune models, from the latency table).
25954
+ * Both are recomputed whenever a node or device joins, leaves, is switched
25955
+ * on or off, changes model, or a benchmark result is written. No load input.
23856
25956
  * - `manual` — the operator's stored sliders.
23857
25957
  * Either way a node or device that cannot take sessions gives its share to
23858
25958
  * the others in proportion; the stored values are never rewritten for that.
@@ -23901,6 +26001,362 @@ var EffectiveSharesSchema = object({
23901
26001
  nodeWeights: record(string(), number()),
23902
26002
  deviceWeights: record(string(), record(string(), number()))
23903
26003
  });
26004
+ /**
26005
+ * Wire shapes of the node benchmark (D791): the operator's plan, the
26006
+ * preflight the confirmation shows, the run the orchestrator owns, what the
26007
+ * measuring runner reports, and the result rows Auto tune and the automatic
26008
+ * shares read.
26009
+ *
26010
+ * ONE node at a time, owned by the pipeline orchestrator. While a run is
26011
+ * active the cluster is in BENCHMARK MODE for that node: it is not a
26012
+ * detection candidate, camera pins naming it are ignored so its sessions move
26013
+ * elsewhere, and both come back when the mode ends — after a crash or a hub
26014
+ * restart too (a persisted manifest, reconciled against the registry).
26015
+ *
26016
+ * Two measurements, both on the node, driven by its own runner (frames never
26017
+ * cross a process at frame rate, D9):
26018
+ * - `device` — one accelerator × one candidate detector, root only, open
26019
+ * loop: how many streams at the camera rate it carries inside the frame
26020
+ * interval;
26021
+ * - `pipeline` — the chosen detector plus the operator's detail steps
26022
+ * (faces, plates, classifiers, CLIP…), on varied frames from the bench
26023
+ * clip: how many parallel sessions the node carries before latency, drops,
26024
+ * CPU, RAM or the event loop give out.
26025
+ */
26026
+ /** Defaults and bounds, one place. */
26027
+ var NODE_BENCHMARK_DEFAULTS = {
26028
+ fpsPerStream: 10,
26029
+ budgetMinutes: 45,
26030
+ minBudgetMinutes: 10,
26031
+ maxBudgetMinutes: 120,
26032
+ /** A result older than this no longer beats the table. */
26033
+ staleAfterDays: 30,
26034
+ /** Warm-in per ramp step (not accounted). */
26035
+ settleSec: 5,
26036
+ /** Accounted window per ramp step. */
26037
+ measureSec: 20,
26038
+ /** Longest the drain may take before the run is refused. */
26039
+ drainTimeoutSec: 120,
26040
+ /** Candidate models per device in one run. */
26041
+ maxModelsPerDevice: 6
26042
+ };
26043
+ /** The two measurements a run can make. */
26044
+ var NodeBenchmarkPhaseSchema = _enum(["device", "pipeline"]);
26045
+ var NodeBenchmarkDevicePlanSchema = object({
26046
+ /** `<backend>:<device>` — `openvino:npu`, `coreml:all`, `cpu`. */
26047
+ deviceKey: string().min(1),
26048
+ /**
26049
+ * Root detector candidates for the `device` measurement, in the order
26050
+ * measured. The FIRST is the one the `pipeline` measurement runs.
26051
+ */
26052
+ modelIds: array(string().min(1)).min(1).max(NODE_BENCHMARK_DEFAULTS.maxModelsPerDevice)
26053
+ });
26054
+ /** What the operator confirmed. */
26055
+ var NodeBenchmarkPlanSchema = object({
26056
+ nodeId: string().min(1),
26057
+ devices: array(NodeBenchmarkDevicePlanSchema).min(1),
26058
+ /** Which measurements run. At least one. */
26059
+ phases: array(NodeBenchmarkPhaseSchema).min(1).default(["device", "pipeline"]),
26060
+ /**
26061
+ * Detail steps (catalog step ids under the root: faces, plates,
26062
+ * classifiers, CLIP…) the `pipeline` measurement enables. The root
26063
+ * detector always runs.
26064
+ */
26065
+ steps: array(string().min(1)).default([]),
26066
+ /** Offered rate of one stream / session. */
26067
+ fpsPerStream: number().int().min(1).max(30).default(NODE_BENCHMARK_DEFAULTS.fpsPerStream),
26068
+ /** Hard deadline: the mode ends and the cluster is restored when it passes. */
26069
+ budgetMinutes: number().int().min(NODE_BENCHMARK_DEFAULTS.minBudgetMinutes).max(NODE_BENCHMARK_DEFAULTS.maxBudgetMinutes).default(NODE_BENCHMARK_DEFAULTS.budgetMinutes),
26070
+ /** Keep the models the run downloaded (default: delete what was not installed before). */
26071
+ keepDownloadedModels: boolean().default(false),
26072
+ /** Start although the other nodes' capacity does not cover the sessions running now. */
26073
+ acceptInsufficientHeadroom: boolean().default(false)
26074
+ });
26075
+ var NodeBenchmarkRefusalSchema = object({
26076
+ kind: _enum([
26077
+ "benchmark-active",
26078
+ "node-offline",
26079
+ "unknown-device",
26080
+ "no-phase",
26081
+ "insufficient-headroom"
26082
+ ]),
26083
+ detail: string(),
26084
+ overridable: boolean()
26085
+ });
26086
+ /** A camera whose detection leaves the node for the run. */
26087
+ var NodeBenchmarkMovingCameraSchema = object({
26088
+ deviceId: number(),
26089
+ /** Placed on the node now (a standing attach or a running session). */
26090
+ placedOnNode: boolean(),
26091
+ /** A node pin naming this node, ignored for the run. */
26092
+ pinnedToNode: boolean()
26093
+ });
26094
+ /** A camera that cannot leave: no other node can obtain its frames. */
26095
+ var NodeBenchmarkStayingCameraSchema = object({
26096
+ deviceId: number(),
26097
+ reason: literal("only-frame-source")
26098
+ });
26099
+ var NodeBenchmarkPreflightSchema = object({
26100
+ nodeId: string(),
26101
+ online: boolean(),
26102
+ moving: array(NodeBenchmarkMovingCameraSchema).readonly(),
26103
+ /** Keep running on the node during the run; the result is flagged contaminated. */
26104
+ staying: array(NodeBenchmarkStayingCameraSchema).readonly(),
26105
+ estimatedDurationMs: number(),
26106
+ /** The run ends and the cluster is restored at the latest after this long. */
26107
+ budgetMs: number(),
26108
+ phases: array(NodeBenchmarkPhaseSchema).readonly(),
26109
+ steps: array(string()).readonly(),
26110
+ devices: array(NodeBenchmarkDevicePlanSchema).readonly(),
26111
+ /** Parallel sessions the cluster runs now, and what the other nodes can carry. */
26112
+ headroom: object({
26113
+ sessionsNow: number(),
26114
+ otherNodesCapacitySessions: number().nullable()
26115
+ }),
26116
+ refusals: array(NodeBenchmarkRefusalSchema).readonly(),
26117
+ canStart: boolean()
26118
+ });
26119
+ /** Where the measuring runner is. */
26120
+ var NodeBenchProgressSchema = object({
26121
+ phase: _enum([
26122
+ "preparing",
26123
+ "device",
26124
+ "pipeline",
26125
+ "cleanup"
26126
+ ]),
26127
+ deviceKey: string().nullable(),
26128
+ modelId: string().nullable(),
26129
+ /** Streams (device) or sessions (pipeline) of the step running now. */
26130
+ load: number().nullable(),
26131
+ cellsDone: number(),
26132
+ cellsTotal: number(),
26133
+ message: string()
26134
+ });
26135
+ /** What limited a ramp. `none` = the ramp ran out of steps still passing. */
26136
+ var NodeBenchLimitSchema = _enum([
26137
+ "p95",
26138
+ "drops",
26139
+ "errors",
26140
+ "stall",
26141
+ "cpu",
26142
+ "ram",
26143
+ "none"
26144
+ ]);
26145
+ var NodeBenchRampStepSchema = object({
26146
+ load: number(),
26147
+ pass: boolean(),
26148
+ p95Ms: number(),
26149
+ dropRatio: number(),
26150
+ /** Completed frames per second over the accounted window. */
26151
+ fps: number(),
26152
+ cpuPct: number().nullable(),
26153
+ ramFreePct: number().nullable(),
26154
+ failReasons: array(string()).readonly()
26155
+ });
26156
+ var NodeBenchCellSchema = discriminatedUnion("phase", [object({
26157
+ phase: literal("device"),
26158
+ deviceKey: string(),
26159
+ modelId: string(),
26160
+ /** Single-stream latency (the K = 1 step). */
26161
+ p50Ms: number(),
26162
+ p95Ms: number(),
26163
+ p99Ms: number(),
26164
+ /** Frames per second sustained at the last passing step. */
26165
+ fps: number(),
26166
+ /** Streams at the camera rate the device carried inside the frame interval; 0 = not even one. */
26167
+ kMax: number(),
26168
+ limitedBy: NodeBenchLimitSchema,
26169
+ /** First call (model load + warm-up). */
26170
+ warmupMs: number(),
26171
+ ramp: array(NodeBenchRampStepSchema).readonly()
26172
+ }), object({
26173
+ phase: literal("pipeline"),
26174
+ deviceKey: string(),
26175
+ modelId: string(),
26176
+ steps: array(string()).readonly(),
26177
+ /** Parallel sessions at the camera rate the node carried; 0 = not even one. */
26178
+ maxSessions: number(),
26179
+ limitedBy: NodeBenchLimitSchema,
26180
+ /** Detail steps that produced at least one result on the clip — a step that never fired measured nothing. */
26181
+ stepsFired: array(string()).readonly(),
26182
+ warmupMs: number(),
26183
+ ramp: array(NodeBenchRampStepSchema).readonly()
26184
+ })]);
26185
+ /**
26186
+ * What a result was measured ON. A result whose fingerprint no longer matches
26187
+ * the node no longer beats the table.
26188
+ */
26189
+ var NodeBenchFingerprintSchema = object({
26190
+ pipelineVersion: string().nullable(),
26191
+ cpuModel: string().nullable(),
26192
+ ramGb: number().nullable(),
26193
+ os: string().nullable(),
26194
+ /** Per device: the pool the cells ran on (runtime + tuning). */
26195
+ pools: record(string(), object({
26196
+ runtime: string(),
26197
+ numWorkers: number(),
26198
+ concurrency: number(),
26199
+ batchMode: string()
26200
+ })).default({})
26201
+ });
26202
+ /** The frames the run used. */
26203
+ var NodeBenchClipSchema = object({
26204
+ /** `camstack-bench-v1` or `reference-images` (the fallback when the clip is not reachable). */
26205
+ id: string(),
26206
+ revision: string().nullable(),
26207
+ frames: number(),
26208
+ width: number(),
26209
+ height: number()
26210
+ });
26211
+ var NodeBenchRunnerInputSchema = object({
26212
+ runId: string().min(1),
26213
+ devices: array(NodeBenchmarkDevicePlanSchema).min(1),
26214
+ phases: array(NodeBenchmarkPhaseSchema).min(1),
26215
+ /** The full detail step tree root for the `pipeline` measurement is built on the node from these ids. */
26216
+ steps: array(string()).default([]),
26217
+ fpsPerStream: number().int().min(1).max(30),
26218
+ /** The runner stops on its own past this instant, whatever the hub does. */
26219
+ deadlineAtMs: number(),
26220
+ settleSec: number().min(0).max(60).default(NODE_BENCHMARK_DEFAULTS.settleSec),
26221
+ measureSec: number().min(2).max(300).default(NODE_BENCHMARK_DEFAULTS.measureSec),
26222
+ keepDownloadedModels: boolean().default(false)
26223
+ });
26224
+ var NodeBenchRunnerStateSchema = _enum([
26225
+ "running",
26226
+ "done",
26227
+ "failed",
26228
+ "aborted"
26229
+ ]);
26230
+ var NodeBenchRunnerStatusSchema = object({
26231
+ runId: string(),
26232
+ nodeId: string(),
26233
+ state: NodeBenchRunnerStateSchema,
26234
+ progress: NodeBenchProgressSchema.nullable(),
26235
+ /** Every finished cell so far — a run stopped half way keeps what it measured. */
26236
+ cells: array(NodeBenchCellSchema).readonly(),
26237
+ fingerprint: NodeBenchFingerprintSchema.nullable(),
26238
+ clip: NodeBenchClipSchema.nullable(),
26239
+ /** Cameras seen running on the node during the run (they share its pools). */
26240
+ activeCameraIds: array(number()).readonly(),
26241
+ /** Models the run downloaded and then deleted (not installed before). */
26242
+ deletedModels: array(string()).readonly(),
26243
+ error: string().nullable(),
26244
+ startedAtMs: number(),
26245
+ finishedAtMs: number().nullable()
26246
+ });
26247
+ var NodeBenchmarkStateSchema = _enum([
26248
+ "draining",
26249
+ "measuring",
26250
+ "restoring",
26251
+ "done",
26252
+ "failed",
26253
+ "aborted"
26254
+ ]);
26255
+ /** Why a run ended. */
26256
+ var NodeBenchmarkEndReasonSchema = _enum([
26257
+ "completed",
26258
+ "operator-abort",
26259
+ "deadline",
26260
+ "node-lost",
26261
+ "runner-lost",
26262
+ "hub-restart",
26263
+ "drain-timeout",
26264
+ "failed"
26265
+ ]);
26266
+ var NodeBenchmarkRunSchema = object({
26267
+ runId: string(),
26268
+ nodeId: string(),
26269
+ state: NodeBenchmarkStateSchema,
26270
+ plan: NodeBenchmarkPlanSchema,
26271
+ startedAtMs: number(),
26272
+ deadlineAtMs: number(),
26273
+ finishedAtMs: number().nullable(),
26274
+ endReason: NodeBenchmarkEndReasonSchema.nullable(),
26275
+ error: string().nullable(),
26276
+ /** Cameras moved off the node for the run. */
26277
+ moved: array(number()).readonly(),
26278
+ /** Cameras that stayed (their only frame source is the node). */
26279
+ staying: array(number()).readonly(),
26280
+ /** Something else ran on the node's pools during the run. */
26281
+ contaminated: boolean(),
26282
+ progress: NodeBenchProgressSchema.nullable(),
26283
+ resultIds: array(string()).readonly()
26284
+ });
26285
+ /** `getNodeBenchmarkStatus`: the active run (or the last one), and whether benchmark mode is on. */
26286
+ var NodeBenchmarkStatusSchema = object({
26287
+ /** The node the cluster is in benchmark mode for; null = none. */
26288
+ modeNodeId: string().nullable(),
26289
+ run: NodeBenchmarkRunSchema.nullable()
26290
+ });
26291
+ /**
26292
+ * One stored measurement — the only authority Auto tune and the automatic
26293
+ * shares read measured capacity from. Written by the orchestrator when a run
26294
+ * ends, never by anyone else.
26295
+ */
26296
+ var NodeBenchmarkResultSchema = object({
26297
+ id: string(),
26298
+ runId: string(),
26299
+ nodeId: string(),
26300
+ cell: NodeBenchCellSchema,
26301
+ fpsPerStream: number(),
26302
+ fingerprint: NodeBenchFingerprintSchema.nullable(),
26303
+ clip: NodeBenchClipSchema.nullable(),
26304
+ /** Other work shared the node's pools (a camera that could not move, or the hub's own duties). */
26305
+ contaminated: boolean(),
26306
+ stayingCameras: array(number()).readonly(),
26307
+ /** The run ended early; the cell itself completed. */
26308
+ partialRun: boolean(),
26309
+ measuredAtMs: number()
26310
+ });
26311
+ var ListNodeBenchmarkResultsInputSchema = object({
26312
+ nodeId: string().optional(),
26313
+ deviceKey: string().optional()
26314
+ });
26315
+ /** A result with its standing today: does it still beat the table? */
26316
+ var NodeBenchmarkResultViewSchema = NodeBenchmarkResultSchema.extend({
26317
+ /** `fresh` beats the table; `stale` falls back to it; `superseded` = a newer row covers the same cell. */
26318
+ standing: _enum([
26319
+ "fresh",
26320
+ "stale",
26321
+ "superseded"
26322
+ ]),
26323
+ staleWhy: _enum([
26324
+ "age",
26325
+ "runtime",
26326
+ "pool-tuning"
26327
+ ]).nullable()
26328
+ });
26329
+ object({
26330
+ runId: string(),
26331
+ nodeId: string(),
26332
+ startedAtMs: number(),
26333
+ deadlineAtMs: number(),
26334
+ plan: NodeBenchmarkPlanSchema,
26335
+ moved: array(number()).readonly(),
26336
+ staying: array(number()).readonly()
26337
+ });
26338
+ /** Candidate detectors per device, for the plan editor. */
26339
+ var NodeBenchmarkCandidatesSchema = object({
26340
+ nodeId: string(),
26341
+ reachable: boolean(),
26342
+ devices: array(object({
26343
+ deviceKey: string(),
26344
+ enabled: boolean(),
26345
+ available: boolean(),
26346
+ /** Ordered: what Auto tune would pick first, then the rest of the family by accuracy. */
26347
+ suggested: array(string()).readonly(),
26348
+ /** Every root detector the device has a build for. */
26349
+ all: array(string()).readonly(),
26350
+ /** The model the device runs now, when pinned. */
26351
+ currentModelId: string().nullable()
26352
+ })).readonly(),
26353
+ /** Detail steps the node's catalog offers under the root (for the `pipeline` measurement). */
26354
+ steps: array(object({
26355
+ id: string(),
26356
+ name: string(),
26357
+ slot: string()
26358
+ })).readonly()
26359
+ });
23904
26360
  object({
23905
26361
  activeCameras: number(),
23906
26362
  throttledCameras: number(),
@@ -24989,7 +27445,16 @@ method(RunnerCameraConfigSchema, object({ success: literal(true) }), { kind: "mu
24989
27445
  }), ParkedTrackFrameSchema.nullable()), method(object({
24990
27446
  deviceId: number(),
24991
27447
  trackId: string()
24992
- }), object({ released: number().int().nonnegative() }), { kind: "mutation" });
27448
+ }), object({ released: number().int().nonnegative() }), { kind: "mutation" }), method(NodeBenchRunnerInputSchema, object({
27449
+ accepted: literal(true),
27450
+ runId: string()
27451
+ }), {
27452
+ kind: "mutation",
27453
+ auth: "admin"
27454
+ }), method(object({ runId: string() }), NodeBenchRunnerStatusSchema.nullable(), { auth: "admin" }), method(object({ runId: string() }), object({ aborted: boolean() }), {
27455
+ kind: "mutation",
27456
+ auth: "admin"
27457
+ });
24993
27458
  var CameraPipelineConfigSchema = object({
24994
27459
  engine: PipelineEngineChoiceSchema.optional(),
24995
27460
  steps: array(PipelineStepInputSchema).readonly(),
@@ -25628,6 +28093,21 @@ method(object({
25628
28093
  }), method(PlacementStatsInputSchema, PlacementStatsSchema, { auth: "admin" }), method(SuggestSharesInputSchema, SuggestSharesResultSchema, { auth: "admin" }), method(_void(), EffectiveSharesSchema, { auth: "admin" }), method(SetShareSourceInputSchema, object({ success: literal(true) }), {
25629
28094
  kind: "mutation",
25630
28095
  auth: "admin"
28096
+ }), method(NodeBenchmarkPlanSchema, NodeBenchmarkPreflightSchema, { auth: "admin" }), method(NodeBenchmarkPlanSchema, discriminatedUnion("kind", [object({
28097
+ kind: literal("started"),
28098
+ runId: string()
28099
+ }), object({
28100
+ kind: literal("refused"),
28101
+ preflight: NodeBenchmarkPreflightSchema
28102
+ })]), {
28103
+ kind: "mutation",
28104
+ auth: "admin"
28105
+ }), method(_void(), NodeBenchmarkStatusSchema, { auth: "admin" }), method(object({ runId: string() }), object({ aborted: boolean() }), {
28106
+ kind: "mutation",
28107
+ auth: "admin"
28108
+ }), method(object({ nodeId: string() }), NodeBenchmarkCandidatesSchema, { auth: "admin" }), method(ListNodeBenchmarkResultsInputSchema, array(NodeBenchmarkResultViewSchema).readonly(), { auth: "admin" }), method(object({ id: string() }), object({ deleted: boolean() }), {
28109
+ kind: "mutation",
28110
+ auth: "admin"
25631
28111
  }), method(object({ deviceId: number() }), CameraPipelineSettingsSchema.nullable()), method(object({
25632
28112
  deviceId: number(),
25633
28113
  addonId: string(),
@@ -26033,8 +28513,8 @@ version: string().optional() }), ServerUpdateActionResultSchema, {
26033
28513
  * `smtp-provider` — pluggable email delivery surface.
26034
28514
  *
26035
28515
  * Collection cap: a deployment may install multiple SMTP relays (e.g.
26036
- * one for transactional / one for notifications). Consumers (magic-link,
26037
- * notifier addons, …) walk the collection and pick the first
28516
+ * one for transactional / one for notifications). Consumers (notifier
28517
+ * addons, …) walk the collection and pick the first
26038
28518
  * ready provider OR target a specific addonId.
26039
28519
  *
26040
28520
  * The shape stays small on purpose — `sendEmail` is enough for the
@@ -26226,7 +28706,7 @@ targets: array(object({
26226
28706
  })));
26227
28707
  /**
26228
28708
  * `sso-bridge` — internal hub-only cap that lets SSO-style auth
26229
- * providers (OIDC, SAML, magic-link, …) mint an HMAC-signed token
28709
+ * providers (OIDC, SAML, …) mint an HMAC-signed token
26230
28710
  * carrying the post-callback claims before redirecting back to
26231
28711
  * `/api/auth/sso/finish`.
26232
28712
  *
@@ -26289,7 +28769,14 @@ var SsoBridgeClaimsSchema = object({
26289
28769
  * Verified `iss` of the id_token behind an OIDC login bridge (D782). A
26290
28770
  * subject is unique only per issuer, so a link is bound to it.
26291
28771
  */
26292
- issuer: string().optional()
28772
+ issuer: string().optional(),
28773
+ /**
28774
+ * SHA-256 (hex) of the `camstack_sso_state` cookie the IdP `/start` set in
28775
+ * the browser that began this sign-in. `/api/auth/sso/finish` requires the
28776
+ * request to present the matching cookie — a login bridge is useless in
28777
+ * any other browser.
28778
+ */
28779
+ browserBinding: string().optional()
26293
28780
  });
26294
28781
  method(object({
26295
28782
  claims: SsoBridgeClaimsSchema,
@@ -30722,6 +33209,9 @@ var CreateIntegrationInputSchema = object({
30722
33209
  enabled: boolean().optional(),
30723
33210
  info: record(string(), unknown()).optional(),
30724
33211
  settings: record(string(), unknown()).optional(),
33212
+ /** Keys of `settings` the form's schema declares secret (by type) — kept in
33213
+ * the keychain, not the table (D787). */
33214
+ secretKeys: array(string()).optional(),
30725
33215
  skipRestart: boolean().optional()
30726
33216
  });
30727
33217
  var UpdateIntegrationInputSchema = object({
@@ -30745,7 +33235,9 @@ method(_void(), array(IntegrationWithStateSchema)), method(object({ id: string()
30745
33235
  auth: "admin"
30746
33236
  }), method(object({ id: string() }), record(string(), unknown()), { auth: "admin" }), method(object({
30747
33237
  id: string(),
30748
- settings: record(string(), unknown())
33238
+ settings: record(string(), unknown()),
33239
+ /** Keys the form's schema declares secret (by type) — keychain-stored (D787). */
33240
+ secretKeys: array(string()).optional()
30749
33241
  }), object({ success: boolean() }), {
30750
33242
  kind: "mutation",
30751
33243
  auth: "admin"
@@ -36204,16 +38696,6 @@ var ApiKeySummarySchema = object({
36204
38696
  createdAt: number(),
36205
38697
  lastUsedAt: number().optional()
36206
38698
  });
36207
- var CreateApiKeyInputSchema = object({
36208
- label: string(),
36209
- isAdmin: boolean().default(false),
36210
- allowedProviders: union([array(string()), literal("*")]).optional(),
36211
- allowedDevices: record(string(), union([array(string()), literal("*")])).optional()
36212
- });
36213
- var CreateApiKeyResultSchema = object({
36214
- token: string(),
36215
- record: ApiKeySummarySchema
36216
- });
36217
38699
  var ScopedTokenSummarySchema = object({
36218
38700
  id: string(),
36219
38701
  userId: string(),
@@ -36312,17 +38794,10 @@ method(_void(), array(UserSummarySchema), { auth: "admin" }), method(CreateUserI
36312
38794
  }), UserSummarySchema.extend({ passwordHash: string() }).nullable(), {
36313
38795
  kind: "mutation",
36314
38796
  access: "view"
36315
- }), method(_void(), array(ApiKeySummarySchema), { auth: "admin" }), method(CreateApiKeyInputSchema, CreateApiKeyResultSchema, {
36316
- kind: "mutation",
36317
- auth: "admin",
36318
- access: "create"
36319
- }), method(object({ id: string() }), object({ success: literal(true) }), {
38797
+ }), method(_void(), array(ApiKeySummarySchema), { auth: "admin" }), method(object({ id: string() }), object({ success: literal(true) }), {
36320
38798
  kind: "mutation",
36321
38799
  auth: "admin",
36322
38800
  access: "delete"
36323
- }), method(object({ token: string() }), ApiKeySummarySchema.nullable(), {
36324
- kind: "mutation",
36325
- access: "view"
36326
38801
  }), method(CreateScopedTokenInputSchema, CreateScopedTokenResultSchema, {
36327
38802
  kind: "mutation",
36328
38803
  auth: "admin",
@@ -36396,15 +38871,7 @@ method(_void(), array(UserSummarySchema), { auth: "admin" }), method(CreateUserI
36396
38871
  }).nullable(), { access: "view" }), method(object({ userId: string() }), array(ExternalIdentitySchema), { auth: "admin" }), method(ExternalIdentityKeySchema, object({
36397
38872
  userId: string(),
36398
38873
  issuer: string()
36399
- }).nullable(), { auth: "admin" }), method(ExternalIdentityKeySchema.extend({
36400
- userId: string(),
36401
- issuer: string().min(1),
36402
- label: string().optional()
36403
- }), object({ success: literal(true) }), {
36404
- kind: "mutation",
36405
- auth: "admin",
36406
- access: "create"
36407
- }), method(ExternalIdentityKeySchema.extend({ userId: string() }), object({ success: boolean() }), {
38874
+ }).nullable(), { auth: "admin" }), method(ExternalIdentityKeySchema.extend({ userId: string() }), object({ success: boolean() }), {
36408
38875
  kind: "mutation",
36409
38876
  auth: "admin",
36410
38877
  access: "delete"
@@ -36799,6 +39266,451 @@ DeviceType.Camera, method(object({
36799
39266
  detection: array(ZoneRuleSchema).readonly(),
36800
39267
  package: array(ZoneRuleSchema).readonly()
36801
39268
  });
39269
+ /**
39270
+ * `training-provider` — ONE cloud that can run the CamStack trainer.
39271
+ *
39272
+ * A thin, mockable translation layer: it knows how to run a container with a
39273
+ * GPU, move a dataset in, read the job's stdout and hand artefacts back. It
39274
+ * knows nothing about datasets, splits, floors, cost policy or Model Studio —
39275
+ * those are the `training` orchestrator's (D805). Every rule written there
39276
+ * once is what makes a second provider (RunPod, a local NVIDIA node) a new
39277
+ * manifest entry and nothing else.
39278
+ *
39279
+ * Collection, routed by the `addonId` in every single-row input (the `llm` /
39280
+ * `notification-output` posture); `describe` concat-fans across providers.
39281
+ * Every method is `admin`: these spend money.
39282
+ *
39283
+ * Every cloud object a provider creates is tagged with the orchestrator's
39284
+ * `jobKey`, so a retried submit finds the job it already started instead of
39285
+ * starting a second GPU, and `listJobs` can find orphans.
39286
+ *
39287
+ * Bytes never ride a cap field: the dataset arrives as a `ctx.peerBytes`
39288
+ * ticket the producer (pipeline-analytics) minted, and artefacts leave as a
39289
+ * ticket the provider mints (D613).
39290
+ */
39291
+ var TrainingGpuOptionSchema = object({
39292
+ id: string(),
39293
+ label: string(),
39294
+ /** List price, USD per GPU-hour, before any region multiplier. */
39295
+ usdPerHour: number().nonnegative(),
39296
+ vramGb: number().nonnegative()
39297
+ });
39298
+ var TrainingRegionOptionSchema = object({
39299
+ /** `''` = any region (the provider's choice). */
39300
+ id: string(),
39301
+ label: string(),
39302
+ priceMultiplier: number().positive()
39303
+ });
39304
+ /**
39305
+ * The provider's per-account settings, as the orchestrator reads them. They
39306
+ * live in the PROVIDER addon's settings (operator decision 2026-10-08: they
39307
+ * depend on the user's account), never hard-coded in the orchestrator.
39308
+ */
39309
+ var TrainingProviderDefaultsSchema = object({
39310
+ gpuType: string(),
39311
+ region: string(),
39312
+ costCapUsd: number().nonnegative(),
39313
+ maxRuntimeSec: number().int().positive(),
39314
+ /** Hours a FAILED job's cloud dataset is kept for debugging; 0 = delete at once. */
39315
+ failedDatasetGraceHours: number().nonnegative()
39316
+ });
39317
+ var TrainingProviderDescriptorSchema = object({
39318
+ addonId: string(),
39319
+ /** `modal`, `runpod`, `fake`, … */
39320
+ kind: string(),
39321
+ label: string(),
39322
+ gpuTypes: array(TrainingGpuOptionSchema).readonly(),
39323
+ regions: array(TrainingRegionOptionSchema).readonly(),
39324
+ maxDatasetBytes: number().int().positive(),
39325
+ maxRuntimeSec: number().int().positive(),
39326
+ freeTierNote: string().optional(),
39327
+ /** Where the data goes, in one sentence the confirm dialog repeats. */
39328
+ dataResidencyNote: string(),
39329
+ /** Credentials are present — never the values. */
39330
+ configured: boolean(),
39331
+ defaults: TrainingProviderDefaultsSchema
39332
+ });
39333
+ var TrainingCredentialCheckSchema = object({
39334
+ ok: boolean(),
39335
+ /** Workspace / account name, when the provider says. */
39336
+ account: string().optional(),
39337
+ reason: _enum([
39338
+ "missing",
39339
+ "invalid",
39340
+ "forbidden",
39341
+ "network",
39342
+ "quota"
39343
+ ]).optional(),
39344
+ detail: string().optional()
39345
+ });
39346
+ var ProviderJobStateSchema = _enum([
39347
+ "pending",
39348
+ "starting",
39349
+ "running",
39350
+ "succeeded",
39351
+ "failed",
39352
+ "cancelled",
39353
+ "lost"
39354
+ ]);
39355
+ var ProviderJobStatusSchema = object({
39356
+ jobKey: string(),
39357
+ providerJobId: string().optional(),
39358
+ state: ProviderJobStateSchema,
39359
+ startedAt: number().optional(),
39360
+ endedAt: number().optional(),
39361
+ exitCode: number().int().optional(),
39362
+ failureReason: string().optional(),
39363
+ gpuType: string(),
39364
+ region: string().optional(),
39365
+ billedSeconds: number().nonnegative(),
39366
+ costUsd: number().nonnegative(),
39367
+ /** True when `costUsd` is runtime × list price, not a billing answer. */
39368
+ costIsEstimate: boolean(),
39369
+ lastFetchedAt: number()
39370
+ });
39371
+ /**
39372
+ * The trainer the job runs, by SOURCE revision: the provider turns it into an
39373
+ * image its own way (Modal builds the published Dockerfile at that revision;
39374
+ * a registry-pull provider maps it to a tag). Recorded on the job and echoed
39375
+ * in `result.json`.
39376
+ */
39377
+ var TrainerSourceRefSchema = object({
39378
+ /** Hugging Face repo id, e.g. `camstack/camstack-trainer`. */
39379
+ repo: string().min(1),
39380
+ /** A commit sha (never a branch) — the job must be reproducible. */
39381
+ revision: string().regex(/^[0-9a-f]{7,64}$/)
39382
+ });
39383
+ var JobRef = {
39384
+ addonId: string(),
39385
+ jobKey: string().uuid()
39386
+ };
39387
+ var TrainingLogLineSchema = object({
39388
+ ts: number(),
39389
+ text: string()
39390
+ });
39391
+ method(object({}), array(TrainingProviderDescriptorSchema).readonly(), { auth: "admin" }), method(object({ addonId: string() }), TrainingCredentialCheckSchema, {
39392
+ kind: "mutation",
39393
+ auth: "admin",
39394
+ timeoutMs: 3e4
39395
+ }), method(object({
39396
+ addonId: string(),
39397
+ gpuType: string(),
39398
+ region: string(),
39399
+ datasetBytes: number().int().nonnegative(),
39400
+ gpuSecondsLow: number().nonnegative(),
39401
+ gpuSecondsHigh: number().nonnegative()
39402
+ }), object({
39403
+ usdLow: number().nonnegative(),
39404
+ usdHigh: number().nonnegative(),
39405
+ notes: array(string()).readonly()
39406
+ }), { auth: "admin" }), method(object({
39407
+ ...JobRef,
39408
+ ticket: PeerBytesTicketSchema
39409
+ }), object({
39410
+ bytes: number().int().nonnegative(),
39411
+ sha256: string()
39412
+ }), {
39413
+ kind: "mutation",
39414
+ auth: "admin",
39415
+ timeoutMs: 120 * 6e4
39416
+ }), method(object({
39417
+ ...JobRef,
39418
+ trainer: TrainerSourceRefSchema,
39419
+ jobSpecJson: string().min(2).max(64e3),
39420
+ gpuType: string(),
39421
+ region: string(),
39422
+ maxRuntimeSec: number().int().positive()
39423
+ }), ProviderJobStatusSchema, {
39424
+ kind: "mutation",
39425
+ auth: "admin",
39426
+ timeoutMs: 30 * 6e4
39427
+ }), method(object(JobRef), ProviderJobStatusSchema, {
39428
+ auth: "admin",
39429
+ timeoutMs: 6e4
39430
+ }), method(object({
39431
+ ...JobRef,
39432
+ cursor: string().optional(),
39433
+ max: number().int().min(1).max(500)
39434
+ }), object({
39435
+ lines: array(TrainingLogLineSchema).readonly(),
39436
+ cursor: string()
39437
+ }), {
39438
+ auth: "admin",
39439
+ timeoutMs: 6e4
39440
+ }), method(object(JobRef), object({ ok: literal(true) }), {
39441
+ kind: "mutation",
39442
+ auth: "admin",
39443
+ timeoutMs: 6e4
39444
+ }), method(object(JobRef), object({
39445
+ found: boolean(),
39446
+ text: string().optional()
39447
+ }), {
39448
+ kind: "mutation",
39449
+ auth: "admin",
39450
+ timeoutMs: 5 * 6e4
39451
+ }), method(object({
39452
+ ...JobRef,
39453
+ path: _enum(["bundle.tar"])
39454
+ }), object({ ticket: PeerBytesTicketSchema }), {
39455
+ kind: "mutation",
39456
+ auth: "admin",
39457
+ timeoutMs: 5 * 6e4
39458
+ }), method(object(JobRef), object({ deleted: array(string()).readonly() }), {
39459
+ kind: "mutation",
39460
+ auth: "admin",
39461
+ timeoutMs: 5 * 6e4
39462
+ }), method(object({ addonId: string() }), array(ProviderJobStatusSchema).readonly(), {
39463
+ auth: "admin",
39464
+ timeoutMs: 2 * 6e4
39465
+ });
39466
+ /**
39467
+ * `training` — the cloud-training orchestrator (D805). Hub-only singleton,
39468
+ * provided by `addon-training`.
39469
+ *
39470
+ * It owns what every provider must agree on, written once:
39471
+ *
39472
+ * - **Dataset versions.** Taken over from pipeline-analytics (D796): the rows
39473
+ * live here (D808); pipeline-analytics still CUTS a version (it owns the corpus and
39474
+ * the export plan) and reaches this store through the five row methods
39475
+ * below, so the Retrain page and the export did not change.
39476
+ * - **Jobs.** A persisted state machine, a reconcile loop against the
39477
+ * provider, a cost guard, a daily orphan sweep and the retention rules.
39478
+ * - **The return flow.** Verified artefacts → Model Studio
39479
+ * (`custom-model-registry.importModelBundle`) → canary on cameras →
39480
+ * rollback. Nothing is ever registered automatically.
39481
+ *
39482
+ * Every method is `admin`.
39483
+ */
39484
+ /** A version WITH its frame list — what the export and a job read. */
39485
+ var TrainingDatasetVersionRowSchema = RetrainDatasetVersionSchema.omit({ frameCount: true }).extend({ frameIds: array(string()).max(2e4).readonly() });
39486
+ /** A base model a detector job can fine-tune, and the baseline it is judged against. */
39487
+ var TrainingBaseModelSchema = object({
39488
+ modelId: string(),
39489
+ label: string(),
39490
+ weights: string(),
39491
+ imgsz: number().int(),
39492
+ baselineOnnxUrl: string(),
39493
+ baselineFloors: record(string(), number()),
39494
+ /** The base the fleet runs most — the UI's default. */
39495
+ recommended: boolean()
39496
+ });
39497
+ var TrainingPresetSchema = _enum([
39498
+ "quick",
39499
+ "standard",
39500
+ "thorough"
39501
+ ]);
39502
+ var TrainingJobRequestSchema = object({
39503
+ datasetVersionId: string().min(1),
39504
+ /** The `training-provider` addon that runs it. */
39505
+ addonId: string().min(1),
39506
+ gpuType: string().min(1),
39507
+ region: string(),
39508
+ baseModelId: string().min(1),
39509
+ preset: TrainingPresetSchema,
39510
+ /** Freeze the backbone's first N layers; `null` = the preset's choice. */
39511
+ freeze: number().int().nonnegative().nullable(),
39512
+ /** Cameras held out whole for evaluation; `null` = the orchestrator's default. */
39513
+ holdoutCameras: array(number().int()).nullable()
39514
+ });
39515
+ var TrainingSplitPlanSchema = object({
39516
+ holdoutCameras: array(number().int()).readonly(),
39517
+ /** Used when no camera is held out: the last N days of every camera. */
39518
+ holdoutLastDays: number().int().nonnegative(),
39519
+ /** Holdout subjects per class (camera holdout only; `null` = known only after the split). */
39520
+ holdoutSupport: record(string(), number().int()).nullable(),
39521
+ trainSubjects: number().int()
39522
+ });
39523
+ var TrainingRefusalReasonSchema = _enum([
39524
+ "unknown-dataset",
39525
+ "unknown-provider",
39526
+ "provider-not-configured",
39527
+ "unknown-base-model",
39528
+ "unknown-gpu",
39529
+ "dataset-too-large",
39530
+ "no-training-subjects",
39531
+ "job-already-running"
39532
+ ]);
39533
+ var TrainingJobPlanSchema = object({
39534
+ refusal: object({
39535
+ reason: TrainingRefusalReasonSchema,
39536
+ detail: string()
39537
+ }).nullable(),
39538
+ warnings: array(string()).readonly(),
39539
+ split: TrainingSplitPlanSchema.nullable(),
39540
+ estimate: object({
39541
+ datasetBytes: number().int(),
39542
+ uploadMinutesAt20Mbps: number(),
39543
+ gpuSecondsLow: number(),
39544
+ gpuSecondsHigh: number(),
39545
+ usdLow: number(),
39546
+ usdHigh: number(),
39547
+ notes: array(string()).readonly()
39548
+ }).nullable(),
39549
+ /** Pre-filled from the provider's settings; the operator may lower or raise them. */
39550
+ defaults: object({
39551
+ maxCostUsd: number(),
39552
+ maxRuntimeSec: number().int()
39553
+ }).nullable(),
39554
+ /** The sentence the confirm dialog repeats: where the frames go and when they are deleted. */
39555
+ dataNotice: string()
39556
+ });
39557
+ /**
39558
+ * Orchestrator-owned states, persisted. `uploading` covers exporting the
39559
+ * archive (it is streamed, never staged). Terminal: `failed`, `cancelled`,
39560
+ * `lost`, `expired`, `discarded`. `registered` and `canary` are where a
39561
+ * result lives after the operator acted on it.
39562
+ */
39563
+ var TrainingJobStateSchema = _enum([
39564
+ "uploading",
39565
+ "submitted",
39566
+ "starting",
39567
+ "running",
39568
+ "collecting",
39569
+ "ready",
39570
+ "registered",
39571
+ "canary",
39572
+ "failed",
39573
+ "cancelling",
39574
+ "cancelled",
39575
+ "lost",
39576
+ "expired",
39577
+ "discarded"
39578
+ ]);
39579
+ var TrainingFailureReasonSchema = _enum([
39580
+ "cost-cap",
39581
+ "runtime-cap",
39582
+ "upload-failed",
39583
+ "submit-failed",
39584
+ "trainer-failed",
39585
+ "result-invalid",
39586
+ "checksum-mismatch",
39587
+ "fetch-failed",
39588
+ "provider-error",
39589
+ "hub-restart-during-upload"
39590
+ ]);
39591
+ var TrainingProgressPointSchema = object({
39592
+ epoch: number().int(),
39593
+ map50: number().nullable(),
39594
+ map50_95: number().nullable()
39595
+ });
39596
+ var TrainingCanarySchema = object({
39597
+ deviceIds: array(number().int()).readonly(),
39598
+ since: number(),
39599
+ /** Every override the canary replaced, exactly, so rollback restores it. */
39600
+ previous: array(object({
39601
+ deviceId: number().int(),
39602
+ nodeId: string(),
39603
+ deviceKey: string(),
39604
+ patch: object({
39605
+ modelId: string().optional(),
39606
+ settings: record(string(), unknown()).readonly().optional()
39607
+ }).nullable()
39608
+ })).readonly()
39609
+ });
39610
+ var TrainingJobSchema = object({
39611
+ id: string(),
39612
+ idempotencyKey: string(),
39613
+ name: string(),
39614
+ createdAt: number(),
39615
+ updatedAt: number(),
39616
+ state: TrainingJobStateSchema,
39617
+ stage: TrainingStageSchema.nullable(),
39618
+ failure: object({
39619
+ reason: TrainingFailureReasonSchema,
39620
+ stage: string().nullable(),
39621
+ detail: string()
39622
+ }).nullable(),
39623
+ request: TrainingJobRequestSchema,
39624
+ maxCostUsd: number().nonnegative(),
39625
+ maxRuntimeSec: number().int().positive(),
39626
+ trainer: TrainerSourceRefSchema,
39627
+ datasetLayout: RetrainExportLayoutSchema,
39628
+ dataset: object({
39629
+ bytes: number().int(),
39630
+ sha256: string(),
39631
+ uploadedAt: number()
39632
+ }).nullable(),
39633
+ split: TrainingSplitPlanSchema,
39634
+ provider: object({
39635
+ state: ProviderJobStateSchema.nullable(),
39636
+ providerJobId: string().nullable(),
39637
+ startedAt: number().nullable(),
39638
+ endedAt: number().nullable(),
39639
+ billedSeconds: number(),
39640
+ costUsd: number(),
39641
+ costIsEstimate: boolean(),
39642
+ lastPolledAt: number().nullable()
39643
+ }),
39644
+ progress: object({
39645
+ epoch: number().int().nullable(),
39646
+ epochs: number().int().nullable(),
39647
+ etaSec: number().nullable(),
39648
+ series: array(TrainingProgressPointSchema).readonly()
39649
+ }),
39650
+ /** The last lines of the job's output (≤ 200), newest last. Never frame paths. */
39651
+ logTail: array(string()).readonly(),
39652
+ logCursor: string().nullable(),
39653
+ artifacts: object({
39654
+ bundleBytes: number().int(),
39655
+ bundleSha256: string(),
39656
+ fetchedAt: number(),
39657
+ /** When the staged artefacts are deleted from the hub. */
39658
+ expiresAt: number()
39659
+ }).nullable(),
39660
+ /** When the provider-side copy of the frames was deleted; null while it exists. */
39661
+ cloudDatasetDeletedAt: number().nullable(),
39662
+ /** A failed job's dataset is kept until then (the provider's grace), then deleted. */
39663
+ cloudCleanupDueAt: number().nullable(),
39664
+ /** Model ids registered from this job (base, and int8 when kept). */
39665
+ registeredModelIds: array(string()).readonly(),
39666
+ canary: TrainingCanarySchema.nullable()
39667
+ });
39668
+ var IdInput = object({ id: string().min(1) });
39669
+ method(TrainingDatasetVersionRowSchema, object({ stored: boolean() }), {
39670
+ kind: "mutation",
39671
+ auth: "admin"
39672
+ }), 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() }), {
39673
+ kind: "mutation",
39674
+ auth: "admin"
39675
+ }), method(object({}), array(TrainingBaseModelSchema).readonly(), { auth: "admin" }), method(TrainingJobRequestSchema, TrainingJobPlanSchema, {
39676
+ auth: "admin",
39677
+ timeoutMs: 6e4
39678
+ }), method(TrainingJobRequestSchema.extend({
39679
+ name: string().min(1).max(120),
39680
+ maxCostUsd: number().positive(),
39681
+ maxRuntimeSec: number().int().positive(),
39682
+ idempotencyKey: string().min(8).max(80)
39683
+ }), discriminatedUnion("kind", [object({
39684
+ kind: literal("started"),
39685
+ job: TrainingJobSchema
39686
+ }), object({
39687
+ kind: literal("refused"),
39688
+ reason: TrainingRefusalReasonSchema,
39689
+ detail: string()
39690
+ })]), {
39691
+ kind: "mutation",
39692
+ auth: "admin",
39693
+ timeoutMs: 12e4
39694
+ }), method(object({}), array(TrainingJobSchema).readonly(), { auth: "admin" }), method(IdInput, TrainingJobSchema.nullable(), { auth: "admin" }), method(IdInput, TrainingJobSchema, {
39695
+ kind: "mutation",
39696
+ auth: "admin",
39697
+ timeoutMs: 12e4
39698
+ }), method(IdInput, TrainingResultSchema.nullable(), { auth: "admin" }), method(IdInput.extend({ canaryDeviceIds: array(number().int()).readonly() }), TrainingJobSchema, {
39699
+ kind: "mutation",
39700
+ auth: "admin",
39701
+ timeoutMs: 30 * 6e4
39702
+ }), method(IdInput.extend({ deviceIds: array(number().int()).min(1).readonly() }), TrainingJobSchema, {
39703
+ kind: "mutation",
39704
+ auth: "admin",
39705
+ timeoutMs: 12e4
39706
+ }), method(IdInput, TrainingJobSchema, {
39707
+ kind: "mutation",
39708
+ auth: "admin",
39709
+ timeoutMs: 12e4
39710
+ }), method(IdInput, TrainingJobSchema, {
39711
+ kind: "mutation",
39712
+ auth: "admin"
39713
+ });
36802
39714
  SOURCE_CAPS.filter((cap) => cap !== "switch" && cap !== "motion");
36803
39715
  Object.freeze({
36804
39716
  person: .5,
@@ -37422,6 +40334,12 @@ Object.freeze({
37422
40334
  addonId: null,
37423
40335
  access: "create"
37424
40336
  },
40337
+ "backup.checkBackupKey": {
40338
+ capName: "backup",
40339
+ capScope: "system",
40340
+ addonId: null,
40341
+ access: "create"
40342
+ },
37425
40343
  "backup.delete": {
37426
40344
  capName: "backup",
37427
40345
  capScope: "system",
@@ -37434,6 +40352,18 @@ Object.freeze({
37434
40352
  addonId: null,
37435
40353
  access: "delete"
37436
40354
  },
40355
+ "backup.disableEncryption": {
40356
+ capName: "backup",
40357
+ capScope: "system",
40358
+ addonId: null,
40359
+ access: "create"
40360
+ },
40361
+ "backup.getEncryption": {
40362
+ capName: "backup",
40363
+ capScope: "system",
40364
+ addonId: null,
40365
+ access: "view"
40366
+ },
37437
40367
  "backup.getEntries": {
37438
40368
  capName: "backup",
37439
40369
  capScope: "system",
@@ -37488,6 +40418,12 @@ Object.freeze({
37488
40418
  addonId: null,
37489
40419
  access: "create"
37490
40420
  },
40421
+ "backup.setupEncryption": {
40422
+ capName: "backup",
40423
+ capScope: "system",
40424
+ addonId: null,
40425
+ access: "create"
40426
+ },
37491
40427
  "backup.trigger": {
37492
40428
  capName: "backup",
37493
40429
  capScope: "system",
@@ -38040,6 +40976,12 @@ Object.freeze({
38040
40976
  addonId: null,
38041
40977
  access: "create"
38042
40978
  },
40979
+ "customModelRegistry.importModelBundle": {
40980
+ capName: "custom-model-registry",
40981
+ capScope: "system",
40982
+ addonId: null,
40983
+ access: "create"
40984
+ },
38043
40985
  "customModelRegistry.listModels": {
38044
40986
  capName: "custom-model-registry",
38045
40987
  capScope: "system",
@@ -39450,6 +42392,108 @@ Object.freeze({
39450
42392
  addonId: null,
39451
42393
  access: "create"
39452
42394
  },
42395
+ "keychain.delete": {
42396
+ capName: "keychain",
42397
+ capScope: "system",
42398
+ addonId: null,
42399
+ access: "delete"
42400
+ },
42401
+ "keychain.getState": {
42402
+ capName: "keychain",
42403
+ capScope: "system",
42404
+ addonId: null,
42405
+ access: "view"
42406
+ },
42407
+ "keychain.listMeta": {
42408
+ capName: "keychain",
42409
+ capScope: "system",
42410
+ addonId: null,
42411
+ access: "view"
42412
+ },
42413
+ "keychain.put": {
42414
+ capName: "keychain",
42415
+ capScope: "system",
42416
+ addonId: null,
42417
+ access: "create"
42418
+ },
42419
+ "keychain.resolve": {
42420
+ capName: "keychain",
42421
+ capScope: "system",
42422
+ addonId: null,
42423
+ access: "view"
42424
+ },
42425
+ "keychainAdmin.acknowledgeReset": {
42426
+ capName: "keychain-admin",
42427
+ capScope: "system",
42428
+ addonId: null,
42429
+ access: "create"
42430
+ },
42431
+ "keychainAdmin.deleteOrphans": {
42432
+ capName: "keychain-admin",
42433
+ capScope: "system",
42434
+ addonId: null,
42435
+ access: "delete"
42436
+ },
42437
+ "keychainAdmin.downloadRecoveryKey": {
42438
+ capName: "keychain-admin",
42439
+ capScope: "system",
42440
+ addonId: null,
42441
+ access: "create"
42442
+ },
42443
+ "keychainAdmin.listAudit": {
42444
+ capName: "keychain-admin",
42445
+ capScope: "system",
42446
+ addonId: null,
42447
+ access: "view"
42448
+ },
42449
+ "keychainAdmin.listSecrets": {
42450
+ capName: "keychain-admin",
42451
+ capScope: "system",
42452
+ addonId: null,
42453
+ access: "view"
42454
+ },
42455
+ "keychainAdmin.purgeRetiredKeys": {
42456
+ capName: "keychain-admin",
42457
+ capScope: "system",
42458
+ addonId: null,
42459
+ access: "delete"
42460
+ },
42461
+ "keychainAdmin.resetKeychain": {
42462
+ capName: "keychain-admin",
42463
+ capScope: "system",
42464
+ addonId: null,
42465
+ access: "delete"
42466
+ },
42467
+ "keychainAdmin.resetReport": {
42468
+ capName: "keychain-admin",
42469
+ capScope: "system",
42470
+ addonId: null,
42471
+ access: "delete"
42472
+ },
42473
+ "keychainAdmin.reveal": {
42474
+ capName: "keychain-admin",
42475
+ capScope: "system",
42476
+ addonId: null,
42477
+ access: "create"
42478
+ },
42479
+ "keychainAdmin.rotateMasterKey": {
42480
+ capName: "keychain-admin",
42481
+ capScope: "system",
42482
+ addonId: null,
42483
+ access: "create"
42484
+ },
42485
+ "keychainAdmin.setSystemSecret": {
42486
+ capName: "keychain-admin",
42487
+ capScope: "system",
42488
+ addonId: null,
42489
+ access: "create"
42490
+ },
42491
+ "keychainAdmin.status": {
42492
+ capName: "keychain-admin",
42493
+ capScope: "system",
42494
+ addonId: null,
42495
+ access: "view"
42496
+ },
39453
42497
  "lawnMowerControl.dock": {
39454
42498
  capName: "lawn-mower-control",
39455
42499
  capScope: "device",
@@ -40824,6 +43868,18 @@ Object.freeze({
40824
43868
  addonId: null,
40825
43869
  access: "create"
40826
43870
  },
43871
+ "pipelineAnalytics.addRetrainFrameFromRecording": {
43872
+ capName: "pipeline-analytics",
43873
+ capScope: "device",
43874
+ addonId: null,
43875
+ access: "create"
43876
+ },
43877
+ "pipelineAnalytics.addRetrainFramesToCollection": {
43878
+ capName: "pipeline-analytics",
43879
+ capScope: "device",
43880
+ addonId: null,
43881
+ access: "create"
43882
+ },
40827
43883
  "pipelineAnalytics.applyDeviceSettingsPatch": {
40828
43884
  capName: "pipeline-analytics",
40829
43885
  capScope: "device",
@@ -40872,12 +43928,36 @@ Object.freeze({
40872
43928
  addonId: null,
40873
43929
  access: "view"
40874
43930
  },
43931
+ "pipelineAnalytics.createRetrainCollection": {
43932
+ capName: "pipeline-analytics",
43933
+ capScope: "device",
43934
+ addonId: null,
43935
+ access: "create"
43936
+ },
43937
+ "pipelineAnalytics.createRetrainDatasetVersion": {
43938
+ capName: "pipeline-analytics",
43939
+ capScope: "device",
43940
+ addonId: null,
43941
+ access: "create"
43942
+ },
40875
43943
  "pipelineAnalytics.deleteDeviceEvents": {
40876
43944
  capName: "pipeline-analytics",
40877
43945
  capScope: "device",
40878
43946
  addonId: null,
40879
43947
  access: "delete"
40880
43948
  },
43949
+ "pipelineAnalytics.deleteRetrainCollection": {
43950
+ capName: "pipeline-analytics",
43951
+ capScope: "device",
43952
+ addonId: null,
43953
+ access: "delete"
43954
+ },
43955
+ "pipelineAnalytics.deleteRetrainDatasetVersion": {
43956
+ capName: "pipeline-analytics",
43957
+ capScope: "device",
43958
+ addonId: null,
43959
+ access: "delete"
43960
+ },
40881
43961
  "pipelineAnalytics.deleteTracks": {
40882
43962
  capName: "pipeline-analytics",
40883
43963
  capScope: "device",
@@ -41082,6 +44162,30 @@ Object.freeze({
41082
44162
  addonId: null,
41083
44163
  access: "view"
41084
44164
  },
44165
+ "pipelineAnalytics.listRetrainAssistProfiles": {
44166
+ capName: "pipeline-analytics",
44167
+ capScope: "device",
44168
+ addonId: null,
44169
+ access: "view"
44170
+ },
44171
+ "pipelineAnalytics.listRetrainCollectionFrames": {
44172
+ capName: "pipeline-analytics",
44173
+ capScope: "device",
44174
+ addonId: null,
44175
+ access: "view"
44176
+ },
44177
+ "pipelineAnalytics.listRetrainCollections": {
44178
+ capName: "pipeline-analytics",
44179
+ capScope: "device",
44180
+ addonId: null,
44181
+ access: "view"
44182
+ },
44183
+ "pipelineAnalytics.listRetrainDatasetVersions": {
44184
+ capName: "pipeline-analytics",
44185
+ capScope: "device",
44186
+ addonId: null,
44187
+ access: "view"
44188
+ },
41085
44189
  "pipelineAnalytics.listRetrainFrames": {
41086
44190
  capName: "pipeline-analytics",
41087
44191
  capScope: "device",
@@ -41112,6 +44216,12 @@ Object.freeze({
41112
44216
  addonId: null,
41113
44217
  access: "view"
41114
44218
  },
44219
+ "pipelineAnalytics.offerRetrainArchive": {
44220
+ capName: "pipeline-analytics",
44221
+ capScope: "device",
44222
+ addonId: null,
44223
+ access: "create"
44224
+ },
41115
44225
  "pipelineAnalytics.ownersWithMedia": {
41116
44226
  capName: "pipeline-analytics",
41117
44227
  capScope: "device",
@@ -41124,12 +44234,24 @@ Object.freeze({
41124
44234
  addonId: null,
41125
44235
  access: "create"
41126
44236
  },
44237
+ "pipelineAnalytics.previewRetrainDataset": {
44238
+ capName: "pipeline-analytics",
44239
+ capScope: "device",
44240
+ addonId: null,
44241
+ access: "view"
44242
+ },
41127
44243
  "pipelineAnalytics.proposeRetrainAnnotations": {
41128
44244
  capName: "pipeline-analytics",
41129
44245
  capScope: "device",
41130
44246
  addonId: null,
41131
44247
  access: "create"
41132
44248
  },
44249
+ "pipelineAnalytics.proposeRetrainAnnotationsWithLlm": {
44250
+ capName: "pipeline-analytics",
44251
+ capScope: "device",
44252
+ addonId: null,
44253
+ access: "create"
44254
+ },
41133
44255
  "pipelineAnalytics.pruneEvents": {
41134
44256
  capName: "pipeline-analytics",
41135
44257
  capScope: "device",
@@ -41184,6 +44306,18 @@ Object.freeze({
41184
44306
  addonId: null,
41185
44307
  access: "create"
41186
44308
  },
44309
+ "pipelineAnalytics.removeRetrainFrameFromCollection": {
44310
+ capName: "pipeline-analytics",
44311
+ capScope: "device",
44312
+ addonId: null,
44313
+ access: "delete"
44314
+ },
44315
+ "pipelineAnalytics.renameRetrainCollection": {
44316
+ capName: "pipeline-analytics",
44317
+ capScope: "device",
44318
+ addonId: null,
44319
+ access: "create"
44320
+ },
41187
44321
  "pipelineAnalytics.restageRetrainTrack": {
41188
44322
  capName: "pipeline-analytics",
41189
44323
  capScope: "device",
@@ -41244,6 +44378,12 @@ Object.freeze({
41244
44378
  addonId: null,
41245
44379
  access: "create"
41246
44380
  },
44381
+ "pipelineAnalytics.verifyRetrainDatasetVersion": {
44382
+ capName: "pipeline-analytics",
44383
+ capScope: "device",
44384
+ addonId: null,
44385
+ access: "view"
44386
+ },
41247
44387
  "pipelineAnalytics.wipeAllAnalytics": {
41248
44388
  capName: "pipeline-analytics",
41249
44389
  capScope: "device",
@@ -41472,6 +44612,12 @@ Object.freeze({
41472
44612
  addonId: null,
41473
44613
  access: "view"
41474
44614
  },
44615
+ "pipelineOrchestrator.abortNodeBenchmark": {
44616
+ capName: "pipeline-orchestrator",
44617
+ capScope: "system",
44618
+ addonId: null,
44619
+ access: "create"
44620
+ },
41475
44621
  "pipelineOrchestrator.applyAutoTune": {
41476
44622
  capName: "pipeline-orchestrator",
41477
44623
  capScope: "system",
@@ -41496,6 +44642,12 @@ Object.freeze({
41496
44642
  addonId: null,
41497
44643
  access: "create"
41498
44644
  },
44645
+ "pipelineOrchestrator.deleteNodeBenchmarkResult": {
44646
+ capName: "pipeline-orchestrator",
44647
+ capScope: "system",
44648
+ addonId: null,
44649
+ access: "delete"
44650
+ },
41499
44651
  "pipelineOrchestrator.getAgentLoad": {
41500
44652
  capName: "pipeline-orchestrator",
41501
44653
  capScope: "system",
@@ -41604,6 +44756,24 @@ Object.freeze({
41604
44756
  addonId: null,
41605
44757
  access: "view"
41606
44758
  },
44759
+ "pipelineOrchestrator.getNodeBenchmarkCandidates": {
44760
+ capName: "pipeline-orchestrator",
44761
+ capScope: "system",
44762
+ addonId: null,
44763
+ access: "view"
44764
+ },
44765
+ "pipelineOrchestrator.getNodeBenchmarkPreflight": {
44766
+ capName: "pipeline-orchestrator",
44767
+ capScope: "system",
44768
+ addonId: null,
44769
+ access: "view"
44770
+ },
44771
+ "pipelineOrchestrator.getNodeBenchmarkStatus": {
44772
+ capName: "pipeline-orchestrator",
44773
+ capScope: "system",
44774
+ addonId: null,
44775
+ access: "view"
44776
+ },
41607
44777
  "pipelineOrchestrator.getNodeInferenceDevices": {
41608
44778
  capName: "pipeline-orchestrator",
41609
44779
  capScope: "system",
@@ -41646,6 +44816,12 @@ Object.freeze({
41646
44816
  addonId: null,
41647
44817
  access: "view"
41648
44818
  },
44819
+ "pipelineOrchestrator.listNodeBenchmarkResults": {
44820
+ capName: "pipeline-orchestrator",
44821
+ capScope: "system",
44822
+ addonId: null,
44823
+ access: "view"
44824
+ },
41649
44825
  "pipelineOrchestrator.pauseForStorageMigration": {
41650
44826
  capName: "pipeline-orchestrator",
41651
44827
  capScope: "system",
@@ -41790,6 +44966,12 @@ Object.freeze({
41790
44966
  addonId: null,
41791
44967
  access: "create"
41792
44968
  },
44969
+ "pipelineOrchestrator.startNodeBenchmark": {
44970
+ capName: "pipeline-orchestrator",
44971
+ capScope: "system",
44972
+ addonId: null,
44973
+ access: "create"
44974
+ },
41793
44975
  "pipelineOrchestrator.suggestShares": {
41794
44976
  capName: "pipeline-orchestrator",
41795
44977
  capScope: "system",
@@ -41808,6 +44990,12 @@ Object.freeze({
41808
44990
  addonId: null,
41809
44991
  access: "create"
41810
44992
  },
44993
+ "pipelineRunner.abortNodeBench": {
44994
+ capName: "pipeline-runner",
44995
+ capScope: "system",
44996
+ addonId: null,
44997
+ access: "create"
44998
+ },
41811
44999
  "pipelineRunner.attachCamera": {
41812
45000
  capName: "pipeline-runner",
41813
45001
  capScope: "system",
@@ -41856,6 +45044,12 @@ Object.freeze({
41856
45044
  addonId: null,
41857
45045
  access: "view"
41858
45046
  },
45047
+ "pipelineRunner.getNodeBenchStatus": {
45048
+ capName: "pipeline-runner",
45049
+ capScope: "system",
45050
+ addonId: null,
45051
+ access: "view"
45052
+ },
41859
45053
  "pipelineRunner.getParkedTrackFrame": {
41860
45054
  capName: "pipeline-runner",
41861
45055
  capScope: "system",
@@ -41898,6 +45092,12 @@ Object.freeze({
41898
45092
  addonId: null,
41899
45093
  access: "create"
41900
45094
  },
45095
+ "pipelineRunner.startNodeBench": {
45096
+ capName: "pipeline-runner",
45097
+ capScope: "system",
45098
+ addonId: null,
45099
+ access: "create"
45100
+ },
41901
45101
  "plateGallery.assignPlate": {
41902
45102
  capName: "plate-gallery",
41903
45103
  capScope: "system",
@@ -43560,6 +46760,174 @@ Object.freeze({
43560
46760
  addonId: null,
43561
46761
  access: "view"
43562
46762
  },
46763
+ "training.canaryResult": {
46764
+ capName: "training",
46765
+ capScope: "system",
46766
+ addonId: null,
46767
+ access: "create"
46768
+ },
46769
+ "training.cancelJob": {
46770
+ capName: "training",
46771
+ capScope: "system",
46772
+ addonId: null,
46773
+ access: "create"
46774
+ },
46775
+ "training.discardResult": {
46776
+ capName: "training",
46777
+ capScope: "system",
46778
+ addonId: null,
46779
+ access: "create"
46780
+ },
46781
+ "training.findDatasetVersionIdByName": {
46782
+ capName: "training",
46783
+ capScope: "system",
46784
+ addonId: null,
46785
+ access: "view"
46786
+ },
46787
+ "training.getDatasetVersion": {
46788
+ capName: "training",
46789
+ capScope: "system",
46790
+ addonId: null,
46791
+ access: "view"
46792
+ },
46793
+ "training.getJob": {
46794
+ capName: "training",
46795
+ capScope: "system",
46796
+ addonId: null,
46797
+ access: "view"
46798
+ },
46799
+ "training.getJobResult": {
46800
+ capName: "training",
46801
+ capScope: "system",
46802
+ addonId: null,
46803
+ access: "view"
46804
+ },
46805
+ "training.listBaseModels": {
46806
+ capName: "training",
46807
+ capScope: "system",
46808
+ addonId: null,
46809
+ access: "view"
46810
+ },
46811
+ "training.listDatasetVersions": {
46812
+ capName: "training",
46813
+ capScope: "system",
46814
+ addonId: null,
46815
+ access: "view"
46816
+ },
46817
+ "training.listJobs": {
46818
+ capName: "training",
46819
+ capScope: "system",
46820
+ addonId: null,
46821
+ access: "view"
46822
+ },
46823
+ "training.planJob": {
46824
+ capName: "training",
46825
+ capScope: "system",
46826
+ addonId: null,
46827
+ access: "view"
46828
+ },
46829
+ "training.putDatasetVersion": {
46830
+ capName: "training",
46831
+ capScope: "system",
46832
+ addonId: null,
46833
+ access: "create"
46834
+ },
46835
+ "training.registerResult": {
46836
+ capName: "training",
46837
+ capScope: "system",
46838
+ addonId: null,
46839
+ access: "create"
46840
+ },
46841
+ "training.removeDatasetVersion": {
46842
+ capName: "training",
46843
+ capScope: "system",
46844
+ addonId: null,
46845
+ access: "delete"
46846
+ },
46847
+ "training.rollbackCanary": {
46848
+ capName: "training",
46849
+ capScope: "system",
46850
+ addonId: null,
46851
+ access: "create"
46852
+ },
46853
+ "training.startJob": {
46854
+ capName: "training",
46855
+ capScope: "system",
46856
+ addonId: null,
46857
+ access: "create"
46858
+ },
46859
+ "trainingProvider.cancelJob": {
46860
+ capName: "training-provider",
46861
+ capScope: "system",
46862
+ addonId: null,
46863
+ access: "create"
46864
+ },
46865
+ "trainingProvider.cleanupJob": {
46866
+ capName: "training-provider",
46867
+ capScope: "system",
46868
+ addonId: null,
46869
+ access: "create"
46870
+ },
46871
+ "trainingProvider.describe": {
46872
+ capName: "training-provider",
46873
+ capScope: "system",
46874
+ addonId: null,
46875
+ access: "view"
46876
+ },
46877
+ "trainingProvider.estimateJob": {
46878
+ capName: "training-provider",
46879
+ capScope: "system",
46880
+ addonId: null,
46881
+ access: "view"
46882
+ },
46883
+ "trainingProvider.getJob": {
46884
+ capName: "training-provider",
46885
+ capScope: "system",
46886
+ addonId: null,
46887
+ access: "view"
46888
+ },
46889
+ "trainingProvider.listJobEvents": {
46890
+ capName: "training-provider",
46891
+ capScope: "system",
46892
+ addonId: null,
46893
+ access: "view"
46894
+ },
46895
+ "trainingProvider.listJobs": {
46896
+ capName: "training-provider",
46897
+ capScope: "system",
46898
+ addonId: null,
46899
+ access: "view"
46900
+ },
46901
+ "trainingProvider.offerArtifact": {
46902
+ capName: "training-provider",
46903
+ capScope: "system",
46904
+ addonId: null,
46905
+ access: "create"
46906
+ },
46907
+ "trainingProvider.readResult": {
46908
+ capName: "training-provider",
46909
+ capScope: "system",
46910
+ addonId: null,
46911
+ access: "create"
46912
+ },
46913
+ "trainingProvider.submitJob": {
46914
+ capName: "training-provider",
46915
+ capScope: "system",
46916
+ addonId: null,
46917
+ access: "create"
46918
+ },
46919
+ "trainingProvider.uploadDataset": {
46920
+ capName: "training-provider",
46921
+ capScope: "system",
46922
+ addonId: null,
46923
+ access: "create"
46924
+ },
46925
+ "trainingProvider.validateCredentials": {
46926
+ capName: "training-provider",
46927
+ capScope: "system",
46928
+ addonId: null,
46929
+ access: "create"
46930
+ },
43563
46931
  "turnProvider.getTurnServers": {
43564
46932
  capName: "turn-provider",
43565
46933
  capScope: "system",
@@ -43584,12 +46952,6 @@ Object.freeze({
43584
46952
  addonId: null,
43585
46953
  access: "create"
43586
46954
  },
43587
- "userManagement.createApiKey": {
43588
- capName: "user-management",
43589
- capScope: "system",
43590
- addonId: null,
43591
- access: "create"
43592
- },
43593
46955
  "userManagement.createScopedToken": {
43594
46956
  capName: "user-management",
43595
46957
  capScope: "system",
@@ -43626,12 +46988,6 @@ Object.freeze({
43626
46988
  addonId: null,
43627
46989
  access: "view"
43628
46990
  },
43629
- "userManagement.linkExternalIdentity": {
43630
- capName: "user-management",
43631
- capScope: "system",
43632
- addonId: null,
43633
- access: "create"
43634
- },
43635
46991
  "userManagement.listApiKeys": {
43636
46992
  capName: "user-management",
43637
46993
  capScope: "system",
@@ -43734,12 +47090,6 @@ Object.freeze({
43734
47090
  addonId: null,
43735
47091
  access: "create"
43736
47092
  },
43737
- "userManagement.validateApiKey": {
43738
- capName: "user-management",
43739
- capScope: "system",
43740
- addonId: null,
43741
- access: "view"
43742
- },
43743
47093
  "userManagement.validateCredentials": {
43744
47094
  capName: "user-management",
43745
47095
  capScope: "system",
@@ -46827,6 +50177,11 @@ Object.freeze({
46827
50177
  form: "single",
46828
50178
  optional: false
46829
50179
  }],
50180
+ "pipelineAnalytics.addRetrainFrameFromRecording": [{
50181
+ name: "deviceId",
50182
+ form: "single",
50183
+ optional: false
50184
+ }],
46830
50185
  "pipelineAnalytics.applyDeviceSettingsPatch": [{
46831
50186
  name: "deviceId",
46832
50187
  form: "single",
@@ -47017,6 +50372,11 @@ Object.freeze({
47017
50372
  form: "single",
47018
50373
  optional: false
47019
50374
  }],
50375
+ "pipelineAnalytics.proposeRetrainAnnotationsWithLlm": [{
50376
+ name: "deviceId",
50377
+ form: "single",
50378
+ optional: false
50379
+ }],
47020
50380
  "pipelineAnalytics.pruneEventsBefore": [{
47021
50381
  name: "deviceId",
47022
50382
  form: "single",
@@ -47843,6 +51203,11 @@ Object.freeze({
47843
51203
  form: "single",
47844
51204
  optional: false
47845
51205
  }],
51206
+ "training.canaryResult": [{
51207
+ name: "deviceIds",
51208
+ form: "array",
51209
+ optional: false
51210
+ }],
47846
51211
  "update.getStatus": [{
47847
51212
  name: "deviceId",
47848
51213
  form: "single",
@@ -60318,7 +63683,7 @@ var SmtpNodemailerAddon = class extends BaseAddon {
60318
63683
  return this.schema({ sections: [{
60319
63684
  id: "smtp-relay",
60320
63685
  title: "SMTP Relay",
60321
- description: "Outbound SMTP relay used by magic-link logins, notifications, and alerts. Tested with the per-cap `verify()` button — see the Integrations status badge for the last result.",
63686
+ description: "Outbound SMTP relay used by notifications and alerts. Tested with the per-cap `verify()` button — see the Integrations status badge for the last result.",
60322
63687
  columns: 2,
60323
63688
  fields: [
60324
63689
  {