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