@camstack/addon-export-google 0.1.88 → 0.1.90

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.
@@ -73,7 +73,7 @@ function createApiDeviceGateway(deps) {
73
73
  };
74
74
  }
75
75
  //#endregion
76
- //#region ../types/dist/event-category-B_0XEcLF.mjs
76
+ //#region ../types/dist/event-category-DaIZi00R.mjs
77
77
  var EventCategory = /* @__PURE__ */ function(EventCategory) {
78
78
  EventCategory["SystemBoot"] = "system.boot";
79
79
  EventCategory["SystemAddonsReady"] = "system.addons-ready";
@@ -152,6 +152,13 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
152
152
  */
153
153
  EventCategory["AddonLoadFailed"] = "addon.load-failed";
154
154
  /**
155
+ * A keychain value was stored or removed (D787). Carries the ref, its
156
+ * owner and the new version — NEVER the value. A process holding the ref
157
+ * drops its cached copy and the owning `BaseAddon` re-resolves its config.
158
+ * Telemetry (D8): a process that misses it still revalidates by version.
159
+ */
160
+ EventCategory["KeychainChanged"] = "keychain.changed";
161
+ /**
155
162
  * Addon recovered from a previous failure. Emitted when an addon
156
163
  * transitions from `failed` back to `healthy` (typically via the
157
164
  * monitor's auto-retry loop, or after manual `addons.retryLoad`).
@@ -5444,7 +5451,7 @@ var ZodIssueCode = {
5444
5451
  var ZodFirstPartyTypeKind;
5445
5452
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
5446
5453
  //#endregion
5447
- //#region ../types/dist/sleep-B0JG7-_F.mjs
5454
+ //#region ../types/dist/sleep-r3RWkGVx.mjs
5448
5455
  /**
5449
5456
  * The audio chunk plane's byte format, and the ONE expansion from a coded
5450
5457
  * window to float samples (D455).
@@ -5523,6 +5530,97 @@ function buildAlawTable() {
5523
5530
  }
5524
5531
  buildUlawTable();
5525
5532
  buildAlawTable();
5533
+ /** Is this field's stored value a credential? */
5534
+ function isSecretConfigField(field) {
5535
+ if (field.type === "password") return true;
5536
+ return "secret" in field && field.secret === true;
5537
+ }
5538
+ /**
5539
+ * Is this field's value stored in the KEYCHAIN (D787)? Every secret field is,
5540
+ * by its TYPE, unless it opts out with `storage: 'inline'` — never by its name.
5541
+ */
5542
+ function isKeychainStoredField(field) {
5543
+ if (!isSecretConfigField(field)) return false;
5544
+ if (field.type === "textarea" && field.isJson === true) return false;
5545
+ return !("storage" in field && field.storage === "inline");
5546
+ }
5547
+ /**
5548
+ * What a settings blob holds where a secret used to be.
5549
+ *
5550
+ * A keychain-stored field never holds its value. It holds a self-describing
5551
+ * MARKER, `{"$secret":"secret://…","v":1}` — an object, never a string, so no
5552
+ * code can mistake it for a credential and no form can send it to a camera as
5553
+ * a password. The empty state is `null` / absent, never `''`.
5554
+ *
5555
+ * The same shapes travel to and from the admin UI:
5556
+ *
5557
+ * - read: `hydrateSchema` hands a secret field a {@link SecretFieldView}
5558
+ * (`{ $secret, v, set: true }`) or `null` — the browser learns whether a
5559
+ * value is set, never the value.
5560
+ * - write: an untouched field submits the view back unchanged (KEEP); a typed
5561
+ * value is a plain non-empty string (CHANGE); the Clear button submits
5562
+ * {@link SECRET_CLEAR} (CLEAR). `''`, `null` and the legacy redaction tokens
5563
+ * are KEEP — an empty string is what a defaults-fallback pushes back, and
5564
+ * treating it as "clear" is how a save destroyed a stored credential before.
5565
+ *
5566
+ * Pure and browser-safe.
5567
+ */
5568
+ var SECRET_CLEAR = { $secretClear: true };
5569
+ /** The `'***'` token D634 redaction writes for non-admins. */
5570
+ var LEGACY_DEVICE_REDACTION = "***";
5571
+ function isRecord$2(value) {
5572
+ return typeof value === "object" && value !== null && !Array.isArray(value);
5573
+ }
5574
+ function makeSecretMarker(ref) {
5575
+ return {
5576
+ $secret: ref,
5577
+ v: 1
5578
+ };
5579
+ }
5580
+ /** A stored marker: an object whose `$secret` is a non-empty string. */
5581
+ function isSecretMarker(value) {
5582
+ if (!isRecord$2(value)) return false;
5583
+ const ref = value["$secret"];
5584
+ return typeof ref === "string" && ref.length > 0;
5585
+ }
5586
+ function isSecretClear(value) {
5587
+ return isRecord$2(value) && value["$secretClear"] === true;
5588
+ }
5589
+ /**
5590
+ * The UI view of a stored secret field value: a marker becomes "set", inline
5591
+ * plaintext becomes "set (inline)", nothing becomes `null`. A value never
5592
+ * survives this function.
5593
+ */
5594
+ function toSecretFieldView(stored) {
5595
+ if (isSecretMarker(stored)) return {
5596
+ $secret: stored.$secret,
5597
+ v: 1,
5598
+ set: true
5599
+ };
5600
+ if (typeof stored === "string" && stored.length > 0) return {
5601
+ $secret: null,
5602
+ v: 1,
5603
+ set: true,
5604
+ inline: true
5605
+ };
5606
+ return null;
5607
+ }
5608
+ /**
5609
+ * Classify an incoming value for a secret path. Only a non-empty string that is
5610
+ * not a redaction token sets a value; only {@link SECRET_CLEAR} clears.
5611
+ * Everything else — a marker (ours or anyone's), a UI view, `''`, `null`,
5612
+ * `undefined`, a redaction token, a non-string — keeps what is stored.
5613
+ */
5614
+ function classifySecretWrite(incoming) {
5615
+ if (isSecretClear(incoming)) return { kind: "clear" };
5616
+ if (typeof incoming !== "string") return { kind: "keep" };
5617
+ if (incoming.length === 0) return { kind: "keep" };
5618
+ if (incoming === "__camstack_redacted__" || incoming === LEGACY_DEVICE_REDACTION) return { kind: "keep" };
5619
+ return {
5620
+ kind: "set",
5621
+ value: incoming
5622
+ };
5623
+ }
5526
5624
  Object.fromEntries([
5527
5625
  {
5528
5626
  id: "overview",
@@ -5694,33 +5792,19 @@ Object.fromEntries([
5694
5792
  function isValuelessField(field) {
5695
5793
  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";
5696
5794
  }
5697
- /**
5698
- * Merge a `ConfigUISchema` with a raw `values` record into a
5699
- * `ConfigUISchemaWithValues`. Used by every `get*Settings` backend endpoint
5700
- * before returning to the admin UI. Groups are walked recursively.
5701
- *
5702
- * For each leaf field:
5703
- * - structural fields (`separator`, `info`, `button`) pass through unchanged
5704
- * - other fields get `value = values[key] ?? field.default ?? null`
5705
- *
5706
- * Unknown keys in `values` (keys not declared in the schema) are silently
5707
- * ignored — they don't contribute to the output. Missing keys fall back to
5708
- * the schema default or `null`. This mirrors the old backend behaviour where
5709
- * `FormBuilder` rendered `values[key] ?? field.default`.
5710
- */
5711
- function hydrateSchema(schema, values) {
5795
+ function hydrateSchema(schema, values, options = {}) {
5712
5796
  return {
5713
5797
  ...schema.tabs ? { tabs: [...schema.tabs] } : {},
5714
5798
  sections: schema.sections.map((section) => ({
5715
5799
  ...section,
5716
- fields: section.fields.map((field) => hydrateField(field, values))
5800
+ fields: section.fields.map((field) => hydrateField(field, values, options))
5717
5801
  }))
5718
5802
  };
5719
5803
  }
5720
- function hydrateField(field, values) {
5804
+ function hydrateField(field, values, options) {
5721
5805
  if (isValuelessField(field)) return field;
5722
5806
  if (field.type === "group") {
5723
- const hydratedChildren = field.fields.map((child) => hydrateField(child, values));
5807
+ const hydratedChildren = field.fields.map((child) => hydrateField(child, values, options));
5724
5808
  return {
5725
5809
  ...field,
5726
5810
  fields: hydratedChildren
@@ -5729,7 +5813,7 @@ function hydrateField(field, values) {
5729
5813
  if (field.type === "sub-tabs") {
5730
5814
  const hydratedTabs = field.tabs.map((tab) => ({
5731
5815
  ...tab,
5732
- fields: tab.fields.map((child) => hydrateField(child, values))
5816
+ fields: tab.fields.map((child) => hydrateField(child, values, options))
5733
5817
  }));
5734
5818
  return {
5735
5819
  ...field,
@@ -5739,6 +5823,33 @@ function hydrateField(field, values) {
5739
5823
  const key = field.key;
5740
5824
  const storedValue = Object.prototype.hasOwnProperty.call(values, key) ? values[key] : void 0;
5741
5825
  const defaultValue = field.default;
5826
+ const asView = (v) => isSecretMarker(v) || options.inlineSecretsAsViews === true && v !== void 0;
5827
+ if (isKeychainStoredField(field) && asView(storedValue)) return {
5828
+ ...field,
5829
+ value: toSecretFieldView(storedValue)
5830
+ };
5831
+ if (isKeychainStoredField(field) && options.inlineSecretsAsViews === true) return {
5832
+ ...field,
5833
+ value: null
5834
+ };
5835
+ if (field.type === "editable-array" && Array.isArray(storedValue)) {
5836
+ const secretItemKeys = field.itemFields.filter((item) => "key" in item && isKeychainStoredField(item)).map((item) => "key" in item ? item.key : "");
5837
+ if (secretItemKeys.length > 0) {
5838
+ const rows = storedValue.map((row) => {
5839
+ if (row === null || typeof row !== "object" || Array.isArray(row)) return row;
5840
+ const out = { ...row };
5841
+ for (const k of secretItemKeys) {
5842
+ const v = Reflect.get(row, k);
5843
+ if (asView(v)) out[k] = toSecretFieldView(v);
5844
+ }
5845
+ return out;
5846
+ });
5847
+ return {
5848
+ ...field,
5849
+ value: rows
5850
+ };
5851
+ }
5852
+ }
5742
5853
  if (field.multiple) {
5743
5854
  const stored = Array.isArray(storedValue) ? storedValue : storedValue !== void 0 && storedValue !== null ? [storedValue] : [];
5744
5855
  const itemFallback = field.multiple.itemDefault !== void 0 ? field.multiple.itemDefault : defaultValue !== void 0 ? defaultValue : typeOf(field) === "string" ? "" : null;
@@ -5981,6 +6092,778 @@ function projectStore(store, perNodeKeys, nodeId) {
5981
6092
  }
5982
6093
  return out;
5983
6094
  }
6095
+ var GLOBAL_SCOPE = { kind: "global" };
6096
+ /** The scope every addon-wide (not per-node, not per-device) setting lives in. */
6097
+ function globalSecretScope() {
6098
+ return GLOBAL_SCOPE;
6099
+ }
6100
+ function encodeSegment(value) {
6101
+ return encodeURIComponent(value);
6102
+ }
6103
+ function decodeSegment(value) {
6104
+ try {
6105
+ return decodeURIComponent(value);
6106
+ } catch {
6107
+ return null;
6108
+ }
6109
+ }
6110
+ /**
6111
+ * The field path of a value inside an array item, addressed by the item's id:
6112
+ * `arrayItemFieldPath('providers', 'authentik', 'clientSecret')` →
6113
+ * `providers[authentik].clientSecret`.
6114
+ */
6115
+ function arrayItemFieldPath(arrayKey, itemId, fieldKey) {
6116
+ return `${arrayKey}[${encodeSegment(itemId)}].${fieldKey}`;
6117
+ }
6118
+ function parseScope(segments) {
6119
+ switch (segments[0]) {
6120
+ case "global": return {
6121
+ scope: GLOBAL_SCOPE,
6122
+ used: 1
6123
+ };
6124
+ case "node": {
6125
+ const nodeId = segments[1] !== void 0 ? decodeSegment(segments[1]) : null;
6126
+ return nodeId === null || nodeId.length === 0 ? null : {
6127
+ scope: {
6128
+ kind: "node",
6129
+ nodeId
6130
+ },
6131
+ used: 2
6132
+ };
6133
+ }
6134
+ case "device": {
6135
+ const raw = segments[1];
6136
+ if (raw === void 0 || !/^\d+$/.test(raw)) return null;
6137
+ return {
6138
+ scope: {
6139
+ kind: "device",
6140
+ deviceId: Number(raw)
6141
+ },
6142
+ used: 2
6143
+ };
6144
+ }
6145
+ case "integration": {
6146
+ const id = segments[1] !== void 0 ? decodeSegment(segments[1]) : null;
6147
+ return id === null || id.length === 0 ? null : {
6148
+ scope: {
6149
+ kind: "integration",
6150
+ integrationId: id
6151
+ },
6152
+ used: 2
6153
+ };
6154
+ }
6155
+ case "row": {
6156
+ const collection = segments[1] !== void 0 ? decodeSegment(segments[1]) : null;
6157
+ const rowId = segments[2] !== void 0 ? decodeSegment(segments[2]) : null;
6158
+ if (collection === null || rowId === null || collection.length === 0 || rowId.length === 0) return null;
6159
+ return {
6160
+ scope: {
6161
+ kind: "row",
6162
+ collection,
6163
+ rowId
6164
+ },
6165
+ used: 3
6166
+ };
6167
+ }
6168
+ default: return null;
6169
+ }
6170
+ }
6171
+ /** Take a ref apart; `null` when it is not a well-formed ref. */
6172
+ function parseSecretRef(ref) {
6173
+ if (!ref.startsWith("secret://")) return null;
6174
+ const segments = ref.slice(9).split("/");
6175
+ const owner = segments[0] !== void 0 ? decodeSegment(segments[0]) : null;
6176
+ if (owner === null || owner.length === 0) return null;
6177
+ const parsed = parseScope(segments.slice(1));
6178
+ if (parsed === null) return null;
6179
+ const fieldPath = segments.slice(1 + parsed.used).join("/");
6180
+ if (fieldPath.length === 0) return null;
6181
+ return {
6182
+ owner,
6183
+ scope: parsed.scope,
6184
+ fieldPath
6185
+ };
6186
+ }
6187
+ /** A write to a secret path could not be stored in the keychain, so it was refused. */
6188
+ var KeychainWriteRefusedError = class extends Error {
6189
+ fieldPath;
6190
+ constructor(fieldPath, cause) {
6191
+ super(`secret "${fieldPath}" was not saved: the keychain could not store it (${cause instanceof Error ? cause.message : String(cause)}). Nothing was written.`);
6192
+ this.fieldPath = fieldPath;
6193
+ this.name = "KeychainWriteRefusedError";
6194
+ }
6195
+ };
6196
+ var KEEP = { kind: "keep" };
6197
+ function isRecord$1(value) {
6198
+ return typeof value === "object" && value !== null && !Array.isArray(value);
6199
+ }
6200
+ function defaultMintId() {
6201
+ return globalThis.crypto.randomUUID();
6202
+ }
6203
+ /** Every marker ref anywhere under `value`. */
6204
+ function collectSecretMarkerRefs(value, out = []) {
6205
+ if (isSecretMarker(value)) {
6206
+ out.push(value.$secret);
6207
+ return out;
6208
+ }
6209
+ if (Array.isArray(value)) for (const item of value) collectSecretMarkerRefs(item, out);
6210
+ else if (isRecord$1(value)) for (const child of Object.values(value)) collectSecretMarkerRefs(child, out);
6211
+ return out;
6212
+ }
6213
+ async function storedValueEquals(secrets, marker, candidate) {
6214
+ const resolved = (await secrets.resolve([marker.$secret]))[marker.$secret];
6215
+ return resolved?.kind === "value" && resolved.value === candidate;
6216
+ }
6217
+ async function writeLeaf(ctx, incoming, stored, fieldPath) {
6218
+ const intent = classifySecretWrite(incoming);
6219
+ const ref = ctx.secrets.ref(ctx.scope, fieldPath);
6220
+ const storedIsOurs = isSecretMarker(stored) && stored.$secret === ref;
6221
+ if (intent.kind === "keep") return KEEP;
6222
+ if (intent.kind === "set" && !ctx.operatorWrite && typeof stored === "string" && stored === intent.value) return KEEP;
6223
+ if (intent.kind === "clear") {
6224
+ if (storedIsOurs) ctx.deletes.push(ref);
6225
+ return {
6226
+ kind: "value",
6227
+ value: null
6228
+ };
6229
+ }
6230
+ if (storedIsOurs && await storedValueEquals(ctx.secrets, stored, intent.value)) return {
6231
+ kind: "value",
6232
+ value: stored
6233
+ };
6234
+ try {
6235
+ await ctx.secrets.put(ref, intent.value);
6236
+ } catch (err) {
6237
+ throw new KeychainWriteRefusedError(fieldPath, err);
6238
+ }
6239
+ return {
6240
+ kind: "value",
6241
+ value: makeSecretMarker(ref)
6242
+ };
6243
+ }
6244
+ /** Apply a member result onto `out`: KEEP restores the stored member, or removes it. */
6245
+ function applyMember(out, key, result, storedParent) {
6246
+ if (result.kind === "value") {
6247
+ out[key] = result.value;
6248
+ return;
6249
+ }
6250
+ if (Object.prototype.hasOwnProperty.call(storedParent, key)) out[key] = storedParent[key];
6251
+ else delete out[key];
6252
+ }
6253
+ async function writeMembers(ctx, children, incoming, stored, pathOf) {
6254
+ const out = { ...incoming };
6255
+ for (const [member, node] of children) applyMember(out, member, await writeNode(ctx, node, incoming[member], stored[member], pathOf(member)), stored);
6256
+ return out;
6257
+ }
6258
+ function rowId(row, idKey) {
6259
+ const raw = row[idKey];
6260
+ if (typeof raw === "string" && raw.length > 0) return raw;
6261
+ if (typeof raw === "number" && Number.isFinite(raw)) return String(raw);
6262
+ return null;
6263
+ }
6264
+ async function writeArray(ctx, node, incoming, stored, fieldPath) {
6265
+ const storedRows = Array.isArray(stored) ? stored.filter(isRecord$1) : [];
6266
+ if (!Array.isArray(incoming)) {
6267
+ ctx.deletes.push(...collectSecretMarkerRefs(storedRows));
6268
+ return {
6269
+ kind: "value",
6270
+ value: incoming
6271
+ };
6272
+ }
6273
+ const storedById = /* @__PURE__ */ new Map();
6274
+ for (const row of storedRows) {
6275
+ const id = rowId(row, node.idKey);
6276
+ if (id !== null) storedById.set(id, row);
6277
+ }
6278
+ const kept = /* @__PURE__ */ new Set();
6279
+ const rows = [];
6280
+ for (const row of incoming) {
6281
+ if (!isRecord$1(row)) {
6282
+ rows.push(row);
6283
+ continue;
6284
+ }
6285
+ const id = rowId(row, node.idKey) ?? ctx.mintId();
6286
+ kept.add(id);
6287
+ const withId = {
6288
+ ...row,
6289
+ [node.idKey]: row[node.idKey] ?? id
6290
+ };
6291
+ if (rowId(withId, node.idKey) === null) withId[node.idKey] = id;
6292
+ const storedRow = storedById.get(id) ?? {};
6293
+ rows.push(await writeMembers(ctx, node.item, withId, storedRow, (member) => arrayItemFieldPath(fieldPath, id, member)));
6294
+ }
6295
+ for (const [id, row] of storedById) if (!kept.has(id)) ctx.deletes.push(...collectSecretMarkerRefs(row));
6296
+ return {
6297
+ kind: "value",
6298
+ value: rows
6299
+ };
6300
+ }
6301
+ async function writeNode(ctx, node, incoming, stored, fieldPath) {
6302
+ switch (node.kind) {
6303
+ case "leaf": return writeLeaf(ctx, incoming, stored, fieldPath);
6304
+ case "array": return writeArray(ctx, node, incoming, stored, fieldPath);
6305
+ case "object": {
6306
+ if (!isRecord$1(incoming)) {
6307
+ if (incoming === void 0) return KEEP;
6308
+ ctx.deletes.push(...collectSecretMarkerRefs(stored));
6309
+ return {
6310
+ kind: "value",
6311
+ value: incoming
6312
+ };
6313
+ }
6314
+ const storedObj = isRecord$1(stored) ? stored : {};
6315
+ return {
6316
+ kind: "value",
6317
+ value: await writeMembers(ctx, node.children, incoming, storedObj, (m) => `${fieldPath}.${m}`)
6318
+ };
6319
+ }
6320
+ }
6321
+ }
6322
+ /** Split a perNode-scoped key (`key@nodeId`). */
6323
+ function splitNodeKey(key) {
6324
+ const at = key.indexOf("@");
6325
+ return at <= 0 ? {
6326
+ base: key,
6327
+ nodeId: null
6328
+ } : {
6329
+ base: key.slice(0, at),
6330
+ nodeId: key.slice(at + 1)
6331
+ };
6332
+ }
6333
+ /** Rewrite a settings patch so no secret value reaches the blob. See the file doc. */
6334
+ async function transformSecretWrite(input) {
6335
+ const deletes = [];
6336
+ const base = {
6337
+ secrets: input.secrets,
6338
+ mintId: input.mintId ?? defaultMintId,
6339
+ deletes,
6340
+ operatorWrite: input.operatorWrite === true
6341
+ };
6342
+ const out = {};
6343
+ for (const [key, incoming] of Object.entries(input.patch)) {
6344
+ const { base: baseKey, nodeId } = splitNodeKey(key);
6345
+ const node = input.tree.get(baseKey);
6346
+ if (node === void 0) {
6347
+ out[key] = incoming;
6348
+ continue;
6349
+ }
6350
+ const scope = nodeId !== null && nodeId.length > 0 ? {
6351
+ kind: "node",
6352
+ nodeId
6353
+ } : input.scope ?? globalSecretScope();
6354
+ const result = await writeNode({
6355
+ ...base,
6356
+ scope
6357
+ }, node, incoming, input.stored[key], baseKey);
6358
+ if (result.kind === "value") out[key] = result.value;
6359
+ }
6360
+ return {
6361
+ patch: out,
6362
+ afterWrite: async () => {
6363
+ if (deletes.length === 0) return { orphaned: [] };
6364
+ try {
6365
+ await input.secrets.delete([...new Set(deletes)]);
6366
+ return { orphaned: [] };
6367
+ } catch {
6368
+ return { orphaned: [...new Set(deletes)] };
6369
+ }
6370
+ }
6371
+ };
6372
+ }
6373
+ /** Is `ref` one of `owner`'s refs? */
6374
+ function isSecretRefOwnedBy(ref, owner) {
6375
+ return parseSecretRef(ref)?.owner === owner;
6376
+ }
6377
+ /**
6378
+ * Replace every marker in `value` with its keychain value. Returns the SAME
6379
+ * reference when there is no marker (no allocation, no keychain call).
6380
+ */
6381
+ async function resolveSecretMarkers(value, secrets, options = {}) {
6382
+ const keepMarker = options.unresolved === "keep-marker";
6383
+ const owner = options.ownedBy;
6384
+ const inScope = (ref) => owner === void 0 || isSecretRefOwnedBy(ref, owner);
6385
+ const refs = collectSecretMarkerRefs(value).filter(inScope);
6386
+ if (refs.length === 0) return {
6387
+ value,
6388
+ unresolved: []
6389
+ };
6390
+ const answers = await secrets.resolve(refs);
6391
+ const unresolved = [];
6392
+ for (const ref of new Set(refs)) {
6393
+ const answer = answers[ref];
6394
+ if (answer === void 0) unresolved.push({
6395
+ ref,
6396
+ reason: "not-initialized"
6397
+ });
6398
+ else if (answer.kind === "unavailable") unresolved.push({
6399
+ ref,
6400
+ reason: answer.reason
6401
+ });
6402
+ else if (answer.kind === "missing" || answer.kind === "forbidden") unresolved.push({
6403
+ ref,
6404
+ reason: answer.kind
6405
+ });
6406
+ }
6407
+ const substitute = (v) => {
6408
+ if (isSecretMarker(v)) {
6409
+ if (!inScope(v.$secret)) return {
6410
+ keep: true,
6411
+ value: v
6412
+ };
6413
+ const answer = answers[v.$secret];
6414
+ if (answer?.kind === "value") return {
6415
+ keep: true,
6416
+ value: answer.value
6417
+ };
6418
+ return keepMarker ? {
6419
+ keep: true,
6420
+ value: v
6421
+ } : {
6422
+ keep: false,
6423
+ value: void 0
6424
+ };
6425
+ }
6426
+ if (Array.isArray(v)) {
6427
+ const items = [];
6428
+ for (const item of v) {
6429
+ const s = substitute(item);
6430
+ if (s.keep) items.push(s.value);
6431
+ }
6432
+ return {
6433
+ keep: true,
6434
+ value: items
6435
+ };
6436
+ }
6437
+ if (isRecord$1(v)) {
6438
+ const out = {};
6439
+ for (const [k, child] of Object.entries(v)) {
6440
+ const s = substitute(child);
6441
+ if (s.keep) out[k] = s.value;
6442
+ }
6443
+ return {
6444
+ keep: true,
6445
+ value: out
6446
+ };
6447
+ }
6448
+ return {
6449
+ keep: true,
6450
+ value: v
6451
+ };
6452
+ };
6453
+ return {
6454
+ value: substitute(value).value,
6455
+ unresolved
6456
+ };
6457
+ }
6458
+ /** An addon tried to replace a stored secret it could not read. Nothing was written. */
6459
+ var SecretOverwriteRefusedError = class extends Error {
6460
+ ref;
6461
+ reason;
6462
+ constructor(ref, reason) {
6463
+ 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.`);
6464
+ this.ref = ref;
6465
+ this.reason = reason;
6466
+ this.name = "SecretOverwriteRefusedError";
6467
+ }
6468
+ };
6469
+ function isRecord(value) {
6470
+ return typeof value === "object" && value !== null && !Array.isArray(value);
6471
+ }
6472
+ function resolvedValue(pass, marker) {
6473
+ const answer = pass.answers[marker.$secret];
6474
+ return answer?.kind === "value" ? answer.value : null;
6475
+ }
6476
+ async function atMarker(pass, incoming, stored) {
6477
+ if (incoming === null) return stored;
6478
+ if (typeof incoming !== "string") return incoming;
6479
+ if (incoming === resolvedValue(pass, stored)) return stored;
6480
+ const intent = classifySecretWrite(incoming);
6481
+ if (intent.kind !== "set") return stored;
6482
+ const ref = stored.$secret;
6483
+ if (!isSecretRefOwnedBy(ref, pass.secrets.owner)) return incoming;
6484
+ const answer = pass.answers[ref];
6485
+ 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);
6486
+ try {
6487
+ await pass.secrets.put(ref, intent.value);
6488
+ } catch (err) {
6489
+ throw new KeychainWriteRefusedError(ref, err);
6490
+ }
6491
+ pass.changedRefs.push(ref);
6492
+ return stored;
6493
+ }
6494
+ function inArray(pass, incoming, stored) {
6495
+ return incoming.map((item, index) => {
6496
+ const twin = stored[index];
6497
+ if (isSecretMarker(twin)) return typeof item === "string" && item === resolvedValue(pass, twin) ? twin : item;
6498
+ if (isRecord(item) && isRecord(twin)) return inArrayRow(pass, item, twin);
6499
+ if (Array.isArray(item) && Array.isArray(twin)) return inArray(pass, item, twin);
6500
+ return item;
6501
+ });
6502
+ }
6503
+ function inArrayRow(pass, incoming, stored) {
6504
+ const out = { ...incoming };
6505
+ for (const [key, value] of Object.entries(incoming)) {
6506
+ const twin = stored[key];
6507
+ if (isSecretMarker(twin)) {
6508
+ if (typeof value === "string" && value === resolvedValue(pass, twin)) out[key] = twin;
6509
+ } else if (isRecord(value) && isRecord(twin)) out[key] = inArrayRow(pass, value, twin);
6510
+ else if (Array.isArray(value) && Array.isArray(twin)) out[key] = inArray(pass, value, twin);
6511
+ }
6512
+ return out;
6513
+ }
6514
+ async function walk(pass, incoming, stored) {
6515
+ if (isSecretMarker(stored)) return atMarker(pass, incoming, stored);
6516
+ if (Array.isArray(incoming) && Array.isArray(stored)) return inArray(pass, incoming, stored);
6517
+ if (!isRecord(incoming) || !isRecord(stored)) return incoming;
6518
+ const out = { ...incoming };
6519
+ for (const [key, value] of Object.entries(incoming)) out[key] = await walk(pass, value, stored[key]);
6520
+ return out;
6521
+ }
6522
+ /** Restore markers a write-back carries as values. See the file doc. */
6523
+ async function restoreUnchangedSecrets(input) {
6524
+ const refs = [];
6525
+ for (const key of Object.keys(input.patch)) collectSecretMarkerRefs(input.stored[key], refs);
6526
+ const owned = refs.filter((ref) => isSecretRefOwnedBy(ref, input.secrets.owner));
6527
+ if (owned.length === 0) return {
6528
+ patch: input.patch,
6529
+ changedRefs: []
6530
+ };
6531
+ const pass = {
6532
+ secrets: input.secrets,
6533
+ answers: await input.secrets.resolve([...new Set(owned)]),
6534
+ operatorWrite: input.operatorWrite,
6535
+ changedRefs: []
6536
+ };
6537
+ const out = {};
6538
+ for (const [key, value] of Object.entries(input.patch)) out[key] = await walk(pass, value, input.stored[key]);
6539
+ return {
6540
+ patch: out,
6541
+ changedRefs: pass.changedRefs
6542
+ };
6543
+ }
6544
+ /** Structural equality over JSON-shaped values (key order does not matter). */
6545
+ function isJsonEqual(a, b) {
6546
+ if (Object.is(a, b)) return true;
6547
+ if (Array.isArray(a)) return Array.isArray(b) && a.length === b.length && a.every((v, i) => isJsonEqual(v, b[i]));
6548
+ if (isRecord(a) && isRecord(b)) {
6549
+ const keys = Object.keys(a);
6550
+ if (keys.length !== Object.keys(b).length) return false;
6551
+ return keys.every((k) => Object.prototype.hasOwnProperty.call(b, k) && isJsonEqual(a[k], b[k]));
6552
+ }
6553
+ return false;
6554
+ }
6555
+ /** The patch without the keys whose value already equals the stored one. */
6556
+ function dropUnchangedKeys(patch, stored) {
6557
+ const out = {};
6558
+ for (const [key, value] of Object.entries(patch)) {
6559
+ if (Object.prototype.hasOwnProperty.call(stored, key) && isJsonEqual(value, stored[key])) continue;
6560
+ out[key] = value;
6561
+ }
6562
+ return out;
6563
+ }
6564
+ /** The top-level keys of a blob that hold at least one of `owner`'s markers. */
6565
+ function markerKeysOf(blob, owner) {
6566
+ const keys = /* @__PURE__ */ new Set();
6567
+ for (const [key, value] of Object.entries(blob)) if (collectSecretMarkerRefs(value).some((ref) => isSecretRefOwnedBy(ref, owner))) keys.add(key);
6568
+ return keys;
6569
+ }
6570
+ function nodeFromStored(value, owner) {
6571
+ if (isSecretMarker(value)) return isSecretRefOwnedBy(value.$secret, owner) ? { kind: "leaf" } : null;
6572
+ if (!isRecord(value)) return null;
6573
+ const children = /* @__PURE__ */ new Map();
6574
+ for (const [key, child] of Object.entries(value)) {
6575
+ const node = nodeFromStored(child, owner);
6576
+ if (node !== null) children.set(key, node);
6577
+ }
6578
+ return children.size > 0 ? {
6579
+ kind: "object",
6580
+ children
6581
+ } : null;
6582
+ }
6583
+ /**
6584
+ * The declared secret tree, widened by every place the STORED blob holds a
6585
+ * marker under one of `keys` — so a marker the schema no longer declares (or
6586
+ * never declared: Wyze before b4906cec6) still gets the save path's
6587
+ * KEEP / SET / CLEAR semantics instead of being overwritten by whatever the
6588
+ * addon writes. Markers inside arrays are not added: a row has no id field to
6589
+ * match by unless the schema declares one. Only `owner`'s markers count: a
6590
+ * builtin that keeps another addon's marker (device-manager) never takes it
6591
+ * over.
6592
+ */
6593
+ function widenTreeWithStoredMarkers(declared, stored, keys, owner) {
6594
+ const added = /* @__PURE__ */ new Map();
6595
+ for (const key of keys) {
6596
+ const at = key.indexOf("@");
6597
+ const base = at > 0 ? key.slice(0, at) : key;
6598
+ if (declared.has(base) || added.has(base)) continue;
6599
+ const node = nodeFromStored(stored[key], owner);
6600
+ if (node !== null) added.set(base, node);
6601
+ }
6602
+ return added.size === 0 ? declared : new Map([...declared, ...added]);
6603
+ }
6604
+ /** The blob as stored now; a failed read REFUSES the write instead of guessing. */
6605
+ async function readStoredAddonBlob(raw) {
6606
+ const threeWay = raw.readAddonStoreResult;
6607
+ if (threeWay === void 0) return raw.readAddonStore();
6608
+ const result = await threeWay.call(raw);
6609
+ if (result.kind === "failed") throw new Error(`settings write refused: the stored blob could not be read (${result.error})`);
6610
+ return result.kind === "missing" ? {} : result.value;
6611
+ }
6612
+ function touchesTree(tree, patch) {
6613
+ if (tree.size === 0) return false;
6614
+ for (const key of Object.keys(patch)) {
6615
+ const at = key.indexOf("@");
6616
+ if (tree.has(at > 0 ? key.slice(0, at) : key)) return true;
6617
+ }
6618
+ return false;
6619
+ }
6620
+ /**
6621
+ * Which top-level keys of each store held markers when last seen. `undefined`
6622
+ * for a store not seen yet: its first write reads it, to be safe.
6623
+ */
6624
+ var MarkerKeyIndex = class {
6625
+ owner;
6626
+ byStore = /* @__PURE__ */ new Map();
6627
+ constructor(owner) {
6628
+ this.owner = owner;
6629
+ }
6630
+ seen(store, blob) {
6631
+ this.byStore.set(store, markerKeysOf(blob, this.owner));
6632
+ }
6633
+ wrote(store, patch) {
6634
+ const keys = this.byStore.get(store);
6635
+ if (keys === void 0) return;
6636
+ const now = markerKeysOf(patch, this.owner);
6637
+ for (const key of Object.keys(patch)) if (now.has(key)) keys.add(key);
6638
+ else keys.delete(key);
6639
+ }
6640
+ mayHoldMarkers(store, patch) {
6641
+ const keys = this.byStore.get(store);
6642
+ if (keys === void 0) return true;
6643
+ return Object.keys(patch).some((key) => keys.has(key));
6644
+ }
6645
+ };
6646
+ function createHandle(raw, opts) {
6647
+ const chains = /* @__PURE__ */ new Map();
6648
+ const serialize = (key, fn) => {
6649
+ const next = (chains.get(key) ?? Promise.resolve()).then(fn, fn);
6650
+ const tail = next.catch(() => void 0);
6651
+ chains.set(key, tail);
6652
+ tail.then(() => {
6653
+ if (chains.get(key) === tail) chains.delete(key);
6654
+ });
6655
+ return next;
6656
+ };
6657
+ const index = new MarkerKeyIndex(opts.secrets.owner);
6658
+ const resolveRead = async (store, blob) => {
6659
+ index.seen(store, blob);
6660
+ const { value, unresolved } = await resolveSecretMarkers(blob, opts.secrets, {
6661
+ unresolved: "keep-marker",
6662
+ ownedBy: opts.secrets.owner
6663
+ });
6664
+ if (unresolved.length > 0) opts.onUnresolved?.(unresolved);
6665
+ return value;
6666
+ };
6667
+ const write = async (store, declared, scope, patch, readStored, rawWrite) => {
6668
+ if (!touchesTree(declared, patch) && !index.mayHoldMarkers(store, patch)) {
6669
+ await rawWrite(patch);
6670
+ index.wrote(store, patch);
6671
+ return { changed: true };
6672
+ }
6673
+ return serialize(store, async () => {
6674
+ const stored = await readStored();
6675
+ index.seen(store, stored);
6676
+ const operatorWrite = opts.isOperatorWrite?.() === true;
6677
+ const restored = await restoreUnchangedSecrets({
6678
+ patch,
6679
+ stored,
6680
+ secrets: opts.secrets,
6681
+ operatorWrite
6682
+ });
6683
+ const result = await transformSecretWrite({
6684
+ tree: widenTreeWithStoredMarkers(declared, stored, Object.keys(restored.patch), opts.secrets.owner),
6685
+ secrets: opts.secrets,
6686
+ patch: restored.patch,
6687
+ stored,
6688
+ ...scope !== void 0 ? { scope } : {},
6689
+ operatorWrite
6690
+ });
6691
+ const effective = dropUnchangedKeys(result.patch, stored);
6692
+ const wroteBlob = Object.keys(effective).length > 0;
6693
+ if (wroteBlob) {
6694
+ await rawWrite(effective);
6695
+ index.wrote(store, effective);
6696
+ }
6697
+ const { orphaned } = await result.afterWrite();
6698
+ if (orphaned.length > 0) opts.onOrphaned(orphaned);
6699
+ return { changed: wroteBlob || restored.changedRefs.length > 0 };
6700
+ });
6701
+ };
6702
+ const writeAddon = (patch) => write("addon", opts.addonTree(), void 0, patch, () => readStoredAddonBlob(raw), (p) => raw.writeAddonStore(p));
6703
+ const readAddonStoreResult = raw.readAddonStoreResult;
6704
+ const readAddonStoreKeyResult = raw.readAddonStoreKeyResult;
6705
+ const readDeviceStoreBatch = raw.readDeviceStoreBatch;
6706
+ const overrides = {
6707
+ readAddonStore: async () => resolveRead("addon", await raw.readAddonStore()),
6708
+ ...readAddonStoreResult !== void 0 ? { readAddonStoreResult: async () => {
6709
+ const result = await readAddonStoreResult.call(raw);
6710
+ return result.kind === "value" ? {
6711
+ kind: "value",
6712
+ value: await resolveRead("addon", result.value)
6713
+ } : result;
6714
+ } } : {},
6715
+ ...readAddonStoreKeyResult !== void 0 ? { readAddonStoreKeyResult: async (key) => {
6716
+ const result = await readAddonStoreKeyResult.call(raw, key);
6717
+ if (result.kind !== "present") return result;
6718
+ const { value, unresolved } = await resolveSecretMarkers({ [key]: result.value }, opts.secrets, {
6719
+ unresolved: "keep-marker",
6720
+ ownedBy: opts.secrets.owner
6721
+ });
6722
+ if (unresolved.length > 0) opts.onUnresolved?.(unresolved);
6723
+ return {
6724
+ kind: "present",
6725
+ value: value[key]
6726
+ };
6727
+ } } : {},
6728
+ readDeviceStore: async (deviceId) => resolveRead(`device:${deviceId}`, await raw.readDeviceStore(deviceId)),
6729
+ ...readDeviceStoreBatch !== void 0 ? { readDeviceStoreBatch: async (deviceIds) => {
6730
+ const rows = await readDeviceStoreBatch.call(raw, deviceIds);
6731
+ const out = /* @__PURE__ */ new Map();
6732
+ for (const [deviceId, blob] of rows) out.set(deviceId, await resolveRead(`device:${deviceId}`, blob));
6733
+ return out;
6734
+ } } : {},
6735
+ writeAddonStore: async (patch) => {
6736
+ await writeAddon(patch);
6737
+ },
6738
+ writeDeviceStore: async (deviceId, patch) => {
6739
+ await write(`device:${deviceId}`, opts.deviceTree(), {
6740
+ kind: "device",
6741
+ deviceId
6742
+ }, patch, () => raw.readDeviceStore(deviceId), (p) => raw.writeDeviceStore(deviceId, p));
6743
+ }
6744
+ };
6745
+ return {
6746
+ settings: new Proxy(raw, { get(target, prop, receiver) {
6747
+ if (typeof prop === "string" && Object.prototype.hasOwnProperty.call(overrides, prop)) return Reflect.get(overrides, prop);
6748
+ const value = Reflect.get(target, prop, receiver);
6749
+ return typeof value === "function" ? value.bind(target) : value;
6750
+ } }),
6751
+ raw: {
6752
+ readAddonStore: async () => {
6753
+ const blob = await raw.readAddonStore();
6754
+ index.seen("addon", blob);
6755
+ return blob;
6756
+ },
6757
+ readDeviceStore: async (deviceId) => {
6758
+ const blob = await raw.readDeviceStore(deviceId);
6759
+ index.seen(`device:${deviceId}`, blob);
6760
+ return blob;
6761
+ }
6762
+ },
6763
+ writeAddonStore: writeAddon
6764
+ };
6765
+ }
6766
+ /** The context the addon sees, plus the private raw view and write outcome. */
6767
+ function createSecretAwareContext(context, opts) {
6768
+ const raw = context.settings;
6769
+ if (raw === void 0) return {
6770
+ context,
6771
+ handle: null
6772
+ };
6773
+ const handle = createHandle(raw, opts);
6774
+ return {
6775
+ context: new Proxy(context, { get(target, prop, receiver) {
6776
+ if (prop === "settings") return handle.settings;
6777
+ return Reflect.get(target, prop, receiver);
6778
+ } }),
6779
+ handle
6780
+ };
6781
+ }
6782
+ var LEAF = { kind: "leaf" };
6783
+ var DEFAULT_ITEM_ID_KEY = "id";
6784
+ function collectFields(fields, out) {
6785
+ for (const field of fields) {
6786
+ if (field.type === "group") {
6787
+ collectFields(field.fields, out);
6788
+ continue;
6789
+ }
6790
+ if (field.type === "sub-tabs") {
6791
+ for (const tab of field.tabs) collectFields(tab.fields, out);
6792
+ continue;
6793
+ }
6794
+ if (field.type === "editable-array") {
6795
+ const item = /* @__PURE__ */ new Map();
6796
+ for (const itemField of field.itemFields) if ("key" in itemField && isKeychainStoredField(itemField)) item.set(itemField.key, LEAF);
6797
+ if (item.size > 0) out.set(field.key, {
6798
+ kind: "array",
6799
+ idKey: field.itemIdKey ?? DEFAULT_ITEM_ID_KEY,
6800
+ item
6801
+ });
6802
+ continue;
6803
+ }
6804
+ if (!("key" in field) || typeof field.key !== "string") continue;
6805
+ if (isKeychainStoredField(field)) out.set(field.key, LEAF);
6806
+ }
6807
+ }
6808
+ /** The secret tree a settings schema declares. */
6809
+ function secretTreeFromSchema(schema) {
6810
+ const out = /* @__PURE__ */ new Map();
6811
+ if (schema === null) return out;
6812
+ for (const section of schema.sections) collectFields(section.fields, out);
6813
+ return out;
6814
+ }
6815
+ /** Parse `a.b[id].c` into segments; throws on a malformed path (a declaration bug). */
6816
+ function parseSecretStatePath(path) {
6817
+ const segments = [];
6818
+ for (const raw of path.split(".")) {
6819
+ const m = /^([^[\]]+)(?:\[([^[\]]+)\])?$/.exec(raw);
6820
+ if (m === null || m[1] === void 0) throw new Error(`secretStatePaths: malformed path "${path}"`);
6821
+ segments.push(m[2] !== void 0 ? {
6822
+ key: m[1],
6823
+ idKey: m[2]
6824
+ } : { key: m[1] });
6825
+ }
6826
+ if (segments.length === 0) throw new Error(`secretStatePaths: empty path`);
6827
+ if (segments[segments.length - 1]?.idKey !== void 0) throw new Error(`secretStatePaths: "${path}" ends on an array — name the member that is secret`);
6828
+ return segments;
6829
+ }
6830
+ function insert(into, segments) {
6831
+ const [head, ...rest] = segments;
6832
+ if (head === void 0) return;
6833
+ if (rest.length === 0) {
6834
+ into.set(head.key, LEAF);
6835
+ return;
6836
+ }
6837
+ const existing = into.get(head.key);
6838
+ if (head.idKey !== void 0) {
6839
+ const item = new Map(existing?.kind === "array" ? existing.item : []);
6840
+ insert(item, rest);
6841
+ into.set(head.key, {
6842
+ kind: "array",
6843
+ idKey: head.idKey,
6844
+ item
6845
+ });
6846
+ return;
6847
+ }
6848
+ const children = new Map(existing?.kind === "object" ? existing.children : []);
6849
+ insert(children, rest);
6850
+ into.set(head.key, {
6851
+ kind: "object",
6852
+ children
6853
+ });
6854
+ }
6855
+ /** Add hidden-state paths (`secretStatePaths`) to a schema-derived tree. */
6856
+ function mergeSecretStatePaths(tree, paths) {
6857
+ if (paths.length === 0) return tree;
6858
+ const out = new Map(tree);
6859
+ for (const path of paths) insert(out, parseSecretStatePath(path));
6860
+ return out;
6861
+ }
6862
+ /** First retry of a secret the keychain could not serve; doubles to {@link SECRET_RETRY_MAX_MS}. */
6863
+ var SECRET_RETRY_FIRST_MS = 5e3;
6864
+ var SECRET_RETRY_MAX_MS = 5 * 6e4;
6865
+ /** Coalesces a burst of `keychain.changed` events into one re-resolve. */
6866
+ var SECRET_CHANGE_DEBOUNCE_MS = 250;
5984
6867
  /**
5985
6868
  * Base class for CamStack addons. Eliminates settings boilerplate:
5986
6869
  *
@@ -6050,6 +6933,33 @@ var BaseAddon = class {
6050
6933
  settingsStoreReady = false;
6051
6934
  /** Default config values. Provided via constructor. */
6052
6935
  defaults;
6936
+ /**
6937
+ * Hidden-state paths that hold secrets (D787) — values the addon writes
6938
+ * itself (`updateGlobalSettings`, `state()`) that no form field declares.
6939
+ * Stored in the keychain exactly like a `password` field. Syntax:
6940
+ * `'snapshotSigningKey'`, `'identity.pincode'`, `'tokens[userId].accessToken'`
6941
+ * (`key[<id field>]` addresses array items by id, never by index).
6942
+ */
6943
+ secretStatePaths = [];
6944
+ _addonSecretTree = null;
6945
+ _deviceSecretTree = null;
6946
+ /** Refs the last resolved config pointed at — a change to one re-resolves. */
6947
+ _configSecretRefs = /* @__PURE__ */ new Set();
6948
+ _unresolvedSecrets = [];
6949
+ _secretRetryTimer = null;
6950
+ _secretRetryDelayMs = SECRET_RETRY_FIRST_MS;
6951
+ _secretChangeTimer = null;
6952
+ _secretChangeUnsub = null;
6953
+ /** >0 while an OPERATOR's settings write is being applied. */
6954
+ _operatorWriteDepth = 0;
6955
+ /**
6956
+ * The keychain-aware settings handle (D798). Its `raw` view is the ONLY way
6957
+ * to the marker-bearing blobs and stays private to this class: the form
6958
+ * hydrate and config resolution need markers, addon code never does.
6959
+ */
6960
+ _secretSettings = null;
6961
+ /** Refs an addon-facing read could not resolve — each is logged once per process. */
6962
+ _loggedUnresolvedReads = /* @__PURE__ */ new Set();
6053
6963
  constructor(defaults) {
6054
6964
  this.defaults = defaults;
6055
6965
  this._config = { ...defaults };
@@ -6085,8 +6995,26 @@ var BaseAddon = class {
6085
6995
  return this._config;
6086
6996
  }
6087
6997
  async initialize(context) {
6088
- this._ctx = context;
6998
+ const secrets = context.secrets;
6999
+ if (secrets !== void 0) {
7000
+ const { context: wrapped, handle } = createSecretAwareContext(context, {
7001
+ secrets,
7002
+ addonTree: () => this.addonSecretTree(),
7003
+ deviceTree: () => this.deviceSecretTree(),
7004
+ onOrphaned: (refs) => context.logger.warn("keychain refs dropped by a settings write could not be deleted", { meta: { refs: [...refs] } }),
7005
+ isOperatorWrite: () => this._operatorWriteDepth > 0,
7006
+ onUnresolved: (unresolved) => this.logUnresolvedRead(unresolved)
7007
+ });
7008
+ this._ctx = wrapped;
7009
+ this._secretSettings = handle;
7010
+ } else {
7011
+ this._ctx = context;
7012
+ this._secretSettings = null;
7013
+ }
6089
7014
  await this.resolveConfig();
7015
+ if (secrets !== void 0) this._secretChangeUnsub = secrets.onChange((ref) => {
7016
+ if (this._configSecretRefs.has(ref)) this.scheduleSecretReresolve(SECRET_CHANGE_DEBOUNCE_MS);
7017
+ });
6090
7018
  const result = await this.onInitialize();
6091
7019
  this.emitLifecycle(EventCategory.AddonStarted);
6092
7020
  const normalized = normalizeAddonInitResult(result);
@@ -6119,6 +7047,12 @@ var BaseAddon = class {
6119
7047
  */
6120
7048
  async onHubReachable() {}
6121
7049
  async shutdown() {
7050
+ this._secretChangeUnsub?.();
7051
+ this._secretChangeUnsub = null;
7052
+ if (this._secretRetryTimer !== null) clearTimeout(this._secretRetryTimer);
7053
+ if (this._secretChangeTimer !== null) clearTimeout(this._secretChangeTimer);
7054
+ this._secretRetryTimer = null;
7055
+ this._secretChangeTimer = null;
6122
7056
  this.emitLifecycle(EventCategory.AddonStopped);
6123
7057
  if (this.autoEmitReadiness) this.emitReadinessForProviders("down");
6124
7058
  await this.onShutdown();
@@ -6193,11 +7127,8 @@ var BaseAddon = class {
6193
7127
  async getGlobalSettings(overlay, cap, nodeId) {
6194
7128
  const schema = this.globalSettingsSchema(cap);
6195
7129
  if (!schema) return { sections: [] };
6196
- const projected = await this.resolveGlobalStore(nodeId, cap);
6197
- return hydrateSchema(schema, overlay ? {
6198
- ...projected,
6199
- ...overlay
6200
- } : projected);
7130
+ const projected = await this.readRawProjectedStore(nodeId, cap);
7131
+ return hydrateSchema(schema, overlay ? await this.overlayKeepingMarkers(projected, overlay) : projected, { inlineSecretsAsViews: true });
6201
7132
  }
6202
7133
  /**
6203
7134
  * The integration-level view of this addon's settings: exactly the sections
@@ -6242,11 +7173,11 @@ var BaseAddon = class {
6242
7173
  });
6243
7174
  }
6244
7175
  if (sections.length === 0) return null;
6245
- const projected = await this.resolveGlobalStore(nodeId);
7176
+ const projected = await this.readRawProjectedStore(nodeId);
6246
7177
  return hydrateSchema({
6247
7178
  ...schema,
6248
7179
  sections
6249
- }, projected);
7180
+ }, projected, { inlineSecretsAsViews: true });
6250
7181
  }
6251
7182
  /**
6252
7183
  * The raw addon store PROJECTED onto the target node's bare per-node keys:
@@ -6259,12 +7190,50 @@ var BaseAddon = class {
6259
7190
  * the store for custom option logic (option narrowing, value snapping) to
6260
7191
  * read it per-node — never `ctx.settings.readAddonStore()` directly.
6261
7192
  * `nodeId` omitted ⇒ the local node (node-blind injection from ctx).
7193
+ *
7194
+ * Keychain values come back RESOLVED (D798): a secret reads as its value,
7195
+ * never as a `{ $secret }` marker. One the keychain cannot serve right now
7196
+ * stays a marker — "stored, unavailable" (`isSecretMarker()` is true, and it
7197
+ * is listed in {@link unresolvedSecrets}) — never `''` and never absent, so
7198
+ * it cannot be mistaken for "nothing stored, mint a new one". Writing the
7199
+ * resolved blob back is a no-op for every unchanged secret.
6262
7200
  */
6263
7201
  async resolveGlobalStore(nodeId, cap) {
6264
7202
  const raw = await this._ctx?.settings?.readAddonStore() ?? {};
7203
+ return this.projectForNode(raw, nodeId, cap);
7204
+ }
7205
+ projectForNode(store, nodeId, cap) {
6265
7206
  const keys = this.perNodeKeys(cap);
6266
7207
  const node = normalizeNodeId(nodeId ?? this._ctx?.kernel?.localNodeId);
6267
- return keys.size > 0 ? projectStore(raw, keys, node) : raw;
7208
+ return keys.size > 0 ? projectStore(store, keys, node) : store;
7209
+ }
7210
+ /** The PROJECTED store with its markers — the form hydrate only (D798). */
7211
+ async readRawProjectedStore(nodeId, cap) {
7212
+ const raw = await this.rawSettings()?.readAddonStore() ?? {};
7213
+ return this.projectForNode(raw, nodeId, cap);
7214
+ }
7215
+ /**
7216
+ * `{ ...stored, ...overlay }`, except that an overlay member equal to the
7217
+ * RESOLVED stored one keeps the stored (marker-bearing) member — so a form
7218
+ * hydrated from a resolved overlay still shows a secret as "set", never as
7219
+ * its value.
7220
+ */
7221
+ async overlayKeepingMarkers(stored, overlay) {
7222
+ const secrets = this._ctx?.secrets;
7223
+ const merged = {
7224
+ ...stored,
7225
+ ...overlay
7226
+ };
7227
+ if (secrets === void 0 || collectSecretMarkerRefs(stored).length === 0) return merged;
7228
+ const { value: resolved } = await resolveSecretMarkers(stored, secrets, {
7229
+ unresolved: "keep-marker",
7230
+ ownedBy: secrets.owner
7231
+ });
7232
+ for (const key of Object.keys(overlay)) {
7233
+ if (collectSecretMarkerRefs(stored[key]).length === 0) continue;
7234
+ if (isJsonEqual(overlay[key], resolved[key])) merged[key] = stored[key];
7235
+ }
7236
+ return merged;
6268
7237
  }
6269
7238
  /**
6270
7239
  * Whether ONE global key of this addon's store was written, read three-way
@@ -6300,18 +7269,58 @@ var BaseAddon = class {
6300
7269
  value: result.value[key]
6301
7270
  };
6302
7271
  }
7272
+ /**
7273
+ * The OPERATOR's write — a settings form or an admin API call, dispatched by
7274
+ * the kernel. Identical to {@link updateGlobalSettings}, except that a secret
7275
+ * the operator sends is stored as sent even when it equals a pre-keychain
7276
+ * inline value: the operator re-entering a password is a change, an addon
7277
+ * writing back what it read is not (D787).
7278
+ */
7279
+ async updateGlobalSettingsAsOperator(patch, nodeId) {
7280
+ this._operatorWriteDepth++;
7281
+ try {
7282
+ await this.applyGlobalPatch(patch, nodeId);
7283
+ } finally {
7284
+ this._operatorWriteDepth--;
7285
+ }
7286
+ }
6303
7287
  async updateGlobalSettings(patch, nodeId) {
7288
+ await this.applyGlobalPatch(patch, nodeId);
7289
+ }
7290
+ /**
7291
+ * REMOVE stored secrets — their keychain values and their markers (D787).
7292
+ *
7293
+ * Writing `''` to a secret field KEEPS what is stored (an empty string is
7294
+ * what a defaults fallback writes back, and it must never destroy a
7295
+ * credential), so code that means "forget this token" says so here. Without
7296
+ * a keychain (an older kernel) it writes `''`, as such code always did.
7297
+ */
7298
+ async clearSecrets(keys, nodeId) {
7299
+ const tree = this.addonSecretTree();
7300
+ const keychain = this._ctx?.secrets !== void 0;
7301
+ const stored = keychain ? await this.readAddonStoreWithRetry() : {};
7302
+ const patch = {};
7303
+ for (const key of keys) {
7304
+ const keychainStored = tree.has(key) || collectSecretMarkerRefs(stored[key]).length > 0;
7305
+ patch[key] = keychain && keychainStored ? SECRET_CLEAR : "";
7306
+ }
7307
+ await this.applyGlobalPatch(patch, nodeId);
7308
+ }
7309
+ async applyGlobalPatch(barePatch, nodeId) {
6304
7310
  const keys = this.perNodeKeys();
6305
7311
  const localNode = normalizeNodeId(this._ctx?.kernel?.localNodeId);
6306
7312
  const target = normalizeNodeId(nodeId ?? this._ctx?.kernel?.localNodeId);
6307
- const barePatch = patch;
6308
7313
  const scoped = keys.size > 0 ? scopePatch(barePatch, keys, target) : barePatch;
6309
- await this._ctx?.settings?.writeAddonStore(scoped);
7314
+ const handle = this._secretSettings;
7315
+ if (handle !== null) {
7316
+ const { changed } = await handle.writeAddonStore(scoped);
7317
+ if (!changed) return;
7318
+ } else await this._ctx?.settings?.writeAddonStore(scoped);
6310
7319
  if (target !== localNode) return;
6311
7320
  await this.resolveConfig();
6312
7321
  await this.onConfigChanged();
6313
7322
  this.emitLifecycle(EventCategory.AddonUpdated, { level: "global" });
6314
- this.maybeAutoRestart(patch, this.globalSettingsSchema());
7323
+ this.maybeAutoRestart(Object.keys(barePatch), this.globalSettingsSchema());
6315
7324
  }
6316
7325
  /**
6317
7326
  * The set of field keys the global settings schema declares `perNode: true`
@@ -6336,7 +7345,7 @@ var BaseAddon = class {
6336
7345
  * time to return its response before the addon is torn down and
6337
7346
  * re-initialised by `AddonRegistryService.restartAddon`.
6338
7347
  */
6339
- maybeAutoRestart(patch, schema) {
7348
+ maybeAutoRestart(patchKeys, schema) {
6340
7349
  if (!schema) return;
6341
7350
  const restartKeys = /* @__PURE__ */ new Set();
6342
7351
  for (const section of schema.sections) for (const field of section.fields) {
@@ -6344,13 +7353,13 @@ var BaseAddon = class {
6344
7353
  if (field.requiresRestart) restartKeys.add(field.key);
6345
7354
  }
6346
7355
  if (restartKeys.size === 0) return;
6347
- if (!Object.keys(patch).some((k) => restartKeys.has(k))) return;
7356
+ if (!patchKeys.some((k) => restartKeys.has(k))) return;
6348
7357
  const ctx = this._ctx;
6349
7358
  if (!ctx) return;
6350
7359
  const addonId = ctx.id;
6351
7360
  setImmediate(() => {
6352
7361
  ctx.api.addons?.restartAddon?.mutate({ addonId }).then(() => {
6353
- ctx.logger.info("addon auto-restart triggered by restart-required setting change", { meta: { changedFields: Object.keys(patch).filter((k) => restartKeys.has(k)) } });
7362
+ ctx.logger.info("addon auto-restart triggered by restart-required setting change", { meta: { changedFields: patchKeys.filter((k) => restartKeys.has(k)) } });
6354
7363
  }).catch((err) => {
6355
7364
  ctx.logger.error("addon auto-restart failed", { meta: { error: err instanceof Error ? err.message : String(err) } });
6356
7365
  });
@@ -6359,7 +7368,7 @@ var BaseAddon = class {
6359
7368
  async getDeviceSettings(deviceId) {
6360
7369
  const schema = this.deviceSettingsSchema();
6361
7370
  if (!schema) return { sections: [] };
6362
- return hydrateSchema(schema, await this._ctx?.settings?.readDeviceStore(deviceId) ?? {});
7371
+ return hydrateSchema(schema, await this.rawSettings()?.readDeviceStore(deviceId) ?? {}, { inlineSecretsAsViews: true });
6363
7372
  }
6364
7373
  async updateDeviceSettings(deviceId, patch) {
6365
7374
  await this._ctx?.settings?.writeDeviceStore(deviceId, patch);
@@ -6489,7 +7498,7 @@ var BaseAddon = class {
6489
7498
  * selection at boot (absent scoped key ⇒ the constructor default wins).
6490
7499
  */
6491
7500
  async resolveConfig() {
6492
- const stored = await this.readAddonStoreWithRetry();
7501
+ const stored = await this.resolveStoredSecrets(await this.readAddonStoreWithRetry());
6493
7502
  const perNode = this.perNodeKeys();
6494
7503
  const localNode = normalizeNodeId(this._ctx?.kernel?.localNodeId);
6495
7504
  const resolved = { ...this.defaults };
@@ -6514,7 +7523,7 @@ var BaseAddon = class {
6514
7523
  key,
6515
7524
  schema,
6516
7525
  fallback,
6517
- read: () => this.readAddonStoreWithRetry(),
7526
+ read: async () => this.resolveStoredSecrets(await this.readAddonStoreWithRetry()),
6518
7527
  write: async (patch) => {
6519
7528
  await this._ctx?.settings?.writeAddonStore(patch);
6520
7529
  },
@@ -6531,7 +7540,7 @@ var BaseAddon = class {
6531
7540
  key,
6532
7541
  schema,
6533
7542
  fallback,
6534
- read: async () => await this._ctx?.settings?.readDeviceStore(deviceId) ?? {},
7543
+ read: async () => this.resolveStoredSecrets(await this.rawSettings()?.readDeviceStore(deviceId) ?? {}, false),
6535
7544
  write: async (patch) => {
6536
7545
  await this._ctx?.settings?.writeDeviceStore(deviceId, patch);
6537
7546
  },
@@ -6543,6 +7552,87 @@ var BaseAddon = class {
6543
7552
  } })
6544
7553
  });
6545
7554
  }
7555
+ /** The addon store's secret tree: schema fields by TYPE, plus `secretStatePaths`. */
7556
+ addonSecretTree() {
7557
+ this._addonSecretTree ??= mergeSecretStatePaths(secretTreeFromSchema(this.globalSettingsSchema()), this.secretStatePaths);
7558
+ return this._addonSecretTree;
7559
+ }
7560
+ deviceSecretTree() {
7561
+ this._deviceSecretTree ??= secretTreeFromSchema(this.deviceSettingsSchema());
7562
+ return this._deviceSecretTree;
7563
+ }
7564
+ /**
7565
+ * Secrets of this addon's stored config that could not be resolved on the
7566
+ * last read, with why. Non-empty means the addon is running WITHOUT them —
7567
+ * an addon whose function needs one should report itself degraded rather
7568
+ * than start on an empty credential.
7569
+ */
7570
+ get unresolvedSecrets() {
7571
+ return this._unresolvedSecrets;
7572
+ }
7573
+ /**
7574
+ * Substitute every keychain marker in a stored blob with its value. With no
7575
+ * keychain (no `ctx.secrets`) or no marker, the blob comes back unchanged.
7576
+ * An unresolvable value is LEFT OUT (never `''`), logged by ref — never by
7577
+ * value — and, when the cause can pass, retried with backoff. Nothing is
7578
+ * ever written back from here.
7579
+ */
7580
+ async resolveStoredSecrets(blob, trackForConfig = true) {
7581
+ const secrets = this._ctx?.secrets;
7582
+ if (secrets === void 0) return blob;
7583
+ const refs = collectSecretMarkerRefs(blob);
7584
+ if (trackForConfig) this._configSecretRefs = new Set(refs);
7585
+ if (refs.length === 0) {
7586
+ if (trackForConfig) this._unresolvedSecrets = [];
7587
+ return blob;
7588
+ }
7589
+ const { value, unresolved } = await resolveSecretMarkers(blob, secrets);
7590
+ if (trackForConfig) {
7591
+ this._unresolvedSecrets = unresolved;
7592
+ if (unresolved.length > 0) {
7593
+ this._ctx?.logger?.error?.("secret unavailable — running without it, will retry", { meta: { secrets: unresolved.map((u) => ({
7594
+ ref: u.ref,
7595
+ reason: u.reason
7596
+ })) } });
7597
+ if (unresolved.some((u) => u.reason !== "missing" && u.reason !== "forbidden")) {
7598
+ this.scheduleSecretReresolve(this._secretRetryDelayMs);
7599
+ this._secretRetryDelayMs = Math.min(this._secretRetryDelayMs * 2, SECRET_RETRY_MAX_MS);
7600
+ }
7601
+ } else this._secretRetryDelayMs = SECRET_RETRY_FIRST_MS;
7602
+ }
7603
+ return value;
7604
+ }
7605
+ /**
7606
+ * The marker-bearing settings reads (D798) — private on purpose. Without a
7607
+ * keychain the context's own view is already raw.
7608
+ */
7609
+ rawSettings() {
7610
+ return this._secretSettings?.raw ?? this._ctx?.settings;
7611
+ }
7612
+ /** An addon-facing read met markers it could not resolve: say so once per ref. */
7613
+ logUnresolvedRead(unresolved) {
7614
+ const fresh = unresolved.filter((u) => !this._loggedUnresolvedReads.has(u.ref));
7615
+ if (fresh.length === 0) return;
7616
+ for (const u of fresh) this._loggedUnresolvedReads.add(u.ref);
7617
+ 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) => ({
7618
+ ref: u.ref,
7619
+ reason: u.reason
7620
+ })) } });
7621
+ }
7622
+ /** Re-resolve the config (a keychain-only change, or a retry) and apply it. */
7623
+ scheduleSecretReresolve(delayMs) {
7624
+ const timerOf = delayMs === SECRET_CHANGE_DEBOUNCE_MS ? "_secretChangeTimer" : "_secretRetryTimer";
7625
+ if (this[timerOf] !== null) return;
7626
+ const timer = setTimeout(() => {
7627
+ this[timerOf] = null;
7628
+ if (this._ctx === null) return;
7629
+ this.resolveConfig().then(() => this.onConfigChanged()).catch((err) => {
7630
+ this._ctx?.logger?.error?.("re-resolving secrets failed", { meta: { error: err instanceof Error ? err.message : String(err) } });
7631
+ });
7632
+ }, delayMs);
7633
+ timer.unref?.();
7634
+ this[timerOf] = timer;
7635
+ }
6546
7636
  /**
6547
7637
  * Wrap `ctx.settings.readAddonStore()` with a short retry budget so a
6548
7638
  * transient settings-store outage (mid-restart of sqlite-settings, tsx-watch
@@ -6555,7 +7645,7 @@ var BaseAddon = class {
6555
7645
  * `{}` (defaults) — the addon's first successful patch will rehydrate.
6556
7646
  */
6557
7647
  async readAddonStoreWithRetry() {
6558
- const settings = this._ctx?.settings;
7648
+ const settings = this.rawSettings();
6559
7649
  if (!settings) return {};
6560
7650
  const delaysMs = [
6561
7651
  150,
@@ -8930,6 +10020,278 @@ var CameraSwitchGroupSchema = object({
8930
10020
  fetchedAt: number()
8931
10021
  });
8932
10022
  /**
10023
+ * The trainer contract — what the hub hands the cloud trainer and what it
10024
+ * gets back (cloud training, D805+).
10025
+ *
10026
+ * The trainer (`hf/camstack-trainer`, published as the Hugging Face repo
10027
+ * `camstack/camstack-trainer`) is a separate AGPL program the hub never
10028
+ * imports: `job.json` goes in, files come out, and progress is `CAMSTACK_EVENT`
10029
+ * lines on stdout. These schemas are the hub's half of that boundary; the
10030
+ * trainer's pydantic models (and the JSON Schemas generated from them under
10031
+ * `hf/camstack-trainer/schemas/`) are the other half. A change here is a
10032
+ * change there, in the same piece of work.
10033
+ *
10034
+ * No `.default()` anywhere: defaults do not run on the addon cap path, so the
10035
+ * orchestrator fills every field of a job spec explicitly.
10036
+ */
10037
+ var TRAINING_JOB_SCHEMA = "camstack.training/v1";
10038
+ var TRAINING_RESULT_SCHEMA = "camstack.training-result/v1";
10039
+ /** What the trainer can export. Edge TPU is a later, separate image. */
10040
+ var TrainingExportSchema = _enum([
10041
+ "onnx",
10042
+ "openvino-fp16",
10043
+ "openvino-int8",
10044
+ "coreml-fp16"
10045
+ ]);
10046
+ var FloorsSchema = record(string(), number().min(0).max(1));
10047
+ object({
10048
+ schema: literal(TRAINING_JOB_SCHEMA),
10049
+ jobKey: string().uuid(),
10050
+ target: object({
10051
+ kind: literal("detector"),
10052
+ step: literal("object-detection")
10053
+ }),
10054
+ base: object({
10055
+ modelId: string().min(1),
10056
+ /** Ultralytics weights id, e.g. `yolov9m.pt`. */
10057
+ weights: string().min(1),
10058
+ imgsz: number().int().positive()
10059
+ }),
10060
+ baseline: object({
10061
+ modelId: string().min(1),
10062
+ /** The baseline ONNX the holdout comparison runs; public mirror URL. */
10063
+ onnxUrl: string().url(),
10064
+ imgsz: number().int().positive(),
10065
+ floors: FloorsSchema
10066
+ }),
10067
+ dataset: object({
10068
+ versionId: string().min(1),
10069
+ annotationHash: string(),
10070
+ /** sha256 of the uploaded archive; the trainer refuses a mismatch (exit 65). */
10071
+ sha256: string().regex(/^[0-9a-f]{64}$/)
10072
+ }),
10073
+ split: object({
10074
+ holdoutCameras: array(number().int()),
10075
+ /** When no camera is held out: the last N days of every camera. */
10076
+ holdoutLastDays: number().int().nonnegative(),
10077
+ valFraction: number().min(0).max(.5),
10078
+ seed: number().int()
10079
+ }),
10080
+ hyper: object({
10081
+ epochs: number().int().positive(),
10082
+ batch: number().int().positive(),
10083
+ lr0: number().positive(),
10084
+ /** Layers frozen from the start of the backbone; 0 = none. */
10085
+ freeze: number().int().nonnegative(),
10086
+ patience: number().int().nonnegative(),
10087
+ seed: number().int()
10088
+ }),
10089
+ replay: object({
10090
+ source: literal("coco2017"),
10091
+ count: number().int().nonnegative()
10092
+ }),
10093
+ exports: array(TrainingExportSchema).min(1),
10094
+ calibration: object({ maxFrames: number().int().positive() }),
10095
+ floors: object({
10096
+ minSupport: number().int().positive(),
10097
+ clamp: number().min(0).max(1)
10098
+ }),
10099
+ int8Gate: object({ maxMap50Drop: number().min(0).max(1) }),
10100
+ catalog: object({
10101
+ id: string().regex(/^[a-z0-9][a-z0-9-]{2,80}$/),
10102
+ name: string().min(1).max(160)
10103
+ })
10104
+ });
10105
+ /** One regular file of the bundle. An mlpackage contributes one row per member. */
10106
+ var TrainingResultFileSchema = object({
10107
+ path: string().min(1),
10108
+ bytes: number().int().nonnegative(),
10109
+ sha256: string().regex(/^[0-9a-f]{64}$/),
10110
+ format: _enum([
10111
+ "onnx",
10112
+ "openvino",
10113
+ "coreml",
10114
+ "pt"
10115
+ ]),
10116
+ variant: _enum(["base", "int8"])
10117
+ });
10118
+ var DraftFormatSchema = object({
10119
+ /** RELATIVE path inside the bundle; the hub rewrites it to `camstack-local://`. */
10120
+ url: string().min(1),
10121
+ sizeMB: number().nonnegative(),
10122
+ isDirectory: boolean().optional(),
10123
+ files: array(string()).optional(),
10124
+ runtimes: array(literal("python")).optional(),
10125
+ revision: string().min(1)
10126
+ });
10127
+ /** The trainer's half of a catalog entry; the hub completes it (labels, licence, group). */
10128
+ var TrainingCatalogDraftSchema = object({
10129
+ id: string().min(1),
10130
+ name: string().min(1),
10131
+ description: string(),
10132
+ labels: array(unknown()),
10133
+ inputSize: object({
10134
+ width: number().int().positive(),
10135
+ height: number().int().positive()
10136
+ }),
10137
+ preprocessMode: literal("letterbox"),
10138
+ defaultClassFloors: FloorsSchema,
10139
+ formats: object({
10140
+ onnx: DraftFormatSchema.optional(),
10141
+ openvino: DraftFormatSchema.optional(),
10142
+ coreml: DraftFormatSchema.optional()
10143
+ })
10144
+ });
10145
+ /** One class of one model's holdout report (the eval harness's summary). */
10146
+ var TrainingEvalClassSchema = object({
10147
+ positives: number().int(),
10148
+ floor: number().nullable(),
10149
+ tp: number().int(),
10150
+ fp: number().int(),
10151
+ fn: number().int(),
10152
+ precision: number().nullable(),
10153
+ recall: number().nullable(),
10154
+ ap50: number().nullable(),
10155
+ recallByCamera: record(string(), number().nullable()).optional(),
10156
+ recallByLight: record(string(), number().nullable()).optional(),
10157
+ fpByCamera: record(string(), number()).optional(),
10158
+ smallFound: number().int().optional(),
10159
+ smallTotal: number().int().optional()
10160
+ }).passthrough();
10161
+ var TrainingEvalReportSchema = object({
10162
+ frames: number().int(),
10163
+ classes: record(string(), TrainingEvalClassSchema)
10164
+ }).passthrough();
10165
+ /**
10166
+ * A succeeded result carries every block; a failed one carries the error and
10167
+ * whatever was known by then — the other blocks are ABSENT, not null. The
10168
+ * orchestrator checks the blocks it needs before it trusts a success.
10169
+ */
10170
+ var TrainingResultSchema = object({
10171
+ schema: literal(TRAINING_RESULT_SCHEMA),
10172
+ jobKey: string(),
10173
+ status: _enum(["succeeded", "failed"]),
10174
+ error: object({
10175
+ stage: string(),
10176
+ code: string(),
10177
+ message: string()
10178
+ }).nullable(),
10179
+ trainer: object({
10180
+ version: string(),
10181
+ revision: string()
10182
+ }),
10183
+ toolchain: record(string(), string().nullable()),
10184
+ dataset: object({
10185
+ versionId: string(),
10186
+ annotationHash: string(),
10187
+ sha256: string(),
10188
+ frames: object({
10189
+ train: number().int(),
10190
+ val: number().int(),
10191
+ holdout: number().int()
10192
+ }),
10193
+ holdoutCameras: array(number().int()),
10194
+ replayImages: number().int()
10195
+ }).optional(),
10196
+ training: object({
10197
+ epochsRun: number().int(),
10198
+ bestEpoch: number().int(),
10199
+ bestMap50: number(),
10200
+ bestMap50_95: number(),
10201
+ seconds: number()
10202
+ }).optional(),
10203
+ evaluation: object({
10204
+ holdoutFrames: number().int(),
10205
+ baseline: TrainingEvalReportSchema.nullable(),
10206
+ candidate: TrainingEvalReportSchema.nullable(),
10207
+ candidateInt8: TrainingEvalReportSchema.nullable(),
10208
+ recallDeltaByCamera: record(string(), record(string(), number())).nullable(),
10209
+ map50: record(string(), number().nullable())
10210
+ }).optional(),
10211
+ floors: object({
10212
+ baseline: FloorsSchema,
10213
+ candidate: FloorsSchema,
10214
+ candidateInt8: FloorsSchema.nullable(),
10215
+ notes: array(string())
10216
+ }).optional(),
10217
+ int8: object({
10218
+ kept: boolean(),
10219
+ map50Fp16: number().nullable(),
10220
+ map50Int8: number().nullable(),
10221
+ reason: string().nullable()
10222
+ }).optional(),
10223
+ exportsDropped: array(object({
10224
+ export: string(),
10225
+ reason: string()
10226
+ })).optional(),
10227
+ files: array(TrainingResultFileSchema).optional(),
10228
+ bundle: object({
10229
+ path: literal("bundle.tar"),
10230
+ bytes: number().int().nonnegative(),
10231
+ sha256: string().regex(/^[0-9a-f]{64}$/)
10232
+ }).nullable().optional(),
10233
+ catalogDraft: object({
10234
+ base: TrainingCatalogDraftSchema,
10235
+ int8: TrainingCatalogDraftSchema.nullable()
10236
+ }).nullable().optional(),
10237
+ licence: string()
10238
+ });
10239
+ var TrainingStageSchema = _enum([
10240
+ "prepare",
10241
+ "replay",
10242
+ "train",
10243
+ "eval",
10244
+ "export",
10245
+ "package"
10246
+ ]);
10247
+ var EventBase = {
10248
+ v: literal(1),
10249
+ ts: number()
10250
+ };
10251
+ discriminatedUnion("type", [
10252
+ object({
10253
+ ...EventBase,
10254
+ type: literal("stage"),
10255
+ stage: TrainingStageSchema
10256
+ }),
10257
+ object({
10258
+ ...EventBase,
10259
+ type: literal("epoch"),
10260
+ epoch: number().int(),
10261
+ epochs: number().int(),
10262
+ boxLoss: number().nullable().optional(),
10263
+ map50: number().nullable().optional(),
10264
+ map50_95: number().nullable().optional(),
10265
+ etaSec: number().nullable().optional()
10266
+ }),
10267
+ object({
10268
+ ...EventBase,
10269
+ type: literal("metric"),
10270
+ name: string(),
10271
+ value: number()
10272
+ }),
10273
+ object({
10274
+ ...EventBase,
10275
+ type: literal("artifact"),
10276
+ path: string(),
10277
+ bytes: number(),
10278
+ sha256: string()
10279
+ }),
10280
+ object({
10281
+ ...EventBase,
10282
+ type: literal("done"),
10283
+ status: _enum(["succeeded", "failed"]),
10284
+ resultSha256: string().nullable().optional()
10285
+ }),
10286
+ object({
10287
+ ...EventBase,
10288
+ type: literal("error"),
10289
+ stage: string(),
10290
+ code: string(),
10291
+ message: string()
10292
+ })
10293
+ ]);
10294
+ /**
8933
10295
  * What the gate decided about a birth, from the CALLER's point of view.
8934
10296
  *
8935
10297
  * Deliberately not `ConfirmationVerdict`: `undecided` is not a birth decision
@@ -11264,7 +12626,9 @@ var AddonHttpRouteSchema = object({
11264
12626
  "authenticated",
11265
12627
  "admin"
11266
12628
  ]).optional(),
11267
- description: string().optional()
12629
+ description: string().optional(),
12630
+ /** The hub limits this route per client address before the handler runs. */
12631
+ rateLimit: _enum(["auth"]).optional()
11268
12632
  });
11269
12633
  /**
11270
12634
  * Cross-process route invocation envelope. The hub captures the
@@ -11988,6 +13352,37 @@ var BackupDestinationInfoSchema = object({
11988
13352
  lastError: string().optional()
11989
13353
  });
11990
13354
  /**
13355
+ * How an archive is encrypted (operator decision 2026-10-09): to a backup
13356
+ * PUBLIC key the hub holds, so only the operator's secret key opens it.
13357
+ * Absent on a plain `.tar.gz` — every archive made before encryption, or
13358
+ * with it off — which restores without a key.
13359
+ */
13360
+ var BackupArchiveEncryptionSchema = object({
13361
+ /** `x25519-hkdf-aes256gcm-stream-v1`. */
13362
+ scheme: string(),
13363
+ /** 16 hex — the backup key whose secret restores this archive. */
13364
+ keyId: string()
13365
+ });
13366
+ /**
13367
+ * The backup encryption setting. The hub keeps PUBLIC keys only: the active
13368
+ * one new archives are encrypted to, and the retired ones older archives
13369
+ * still need. The secret key is shown once, at `setupEncryption`.
13370
+ */
13371
+ var BackupEncryptionStatusSchema = object({
13372
+ enabled: boolean(),
13373
+ active: object({
13374
+ keyId: string(),
13375
+ publicKey: string(),
13376
+ createdAt: number()
13377
+ }).nullable(),
13378
+ /** Every key ever set up, newest first. */
13379
+ keys: array(object({
13380
+ keyId: string(),
13381
+ createdAt: number(),
13382
+ retiredAt: number().nullable()
13383
+ })).readonly()
13384
+ });
13385
+ /**
11991
13386
  * Per-archive entry returned by `backup.listArchives({ destinationId })`.
11992
13387
  * Same shape the destination drill-in renders. Sourced from the per-
11993
13388
  * location `manifests.json` (no per-archive tarball read required).
@@ -11999,7 +13394,9 @@ var BackupArchiveEntrySchema = object({
11999
13394
  sizeBytes: number(),
12000
13395
  label: string().optional(),
12001
13396
  /** Top-level locations included in the archive (db, addons, tls, …). */
12002
- locations: array(string()).readonly()
13397
+ locations: array(string()).readonly(),
13398
+ /** Present when the archive is encrypted; restore then needs that key. */
13399
+ encryption: BackupArchiveEncryptionSchema.optional()
12003
13400
  });
12004
13401
  var BackupEntrySchema = object({
12005
13402
  id: string(),
@@ -12008,7 +13405,8 @@ var BackupEntrySchema = object({
12008
13405
  label: string().optional(),
12009
13406
  createdAt: number(),
12010
13407
  sizeBytes: number(),
12011
- locations: array(string()).optional()
13408
+ locations: array(string()).optional(),
13409
+ encryption: BackupArchiveEncryptionSchema.optional()
12012
13410
  });
12013
13411
  var ArchiveEntrySchema = object({
12014
13412
  path: string(),
@@ -12197,10 +13595,40 @@ method(_void(), array(BackupDestinationInfoSchema).readonly(), { auth: "admin" }
12197
13595
  * this list and skips entries whose path doesn't start with
12198
13596
  * any of them.
12199
13597
  */
12200
- locations: array(string()).optional()
13598
+ locations: array(string()).optional(),
13599
+ /**
13600
+ * The backup SECRET key, for an encrypted archive (ignored for a plain
13601
+ * one). The archive is decrypted into the hub's private staging
13602
+ * before the restart; the key is not stored. A wrong or missing key
13603
+ * is refused before the archive is downloaded.
13604
+ */
13605
+ backupSecretKey: string().optional()
12201
13606
  }), _void(), {
12202
13607
  kind: "mutation",
12203
13608
  auth: "admin"
13609
+ }), method(_void(), BackupEncryptionStatusSchema, { auth: "admin" }), method(object({}), object({
13610
+ keyId: string(),
13611
+ secretKey: string(),
13612
+ publicKey: string(),
13613
+ createdAt: number(),
13614
+ replacedKeyId: string().nullable()
13615
+ }), {
13616
+ kind: "mutation",
13617
+ auth: "admin"
13618
+ }), method(object({}), object({ disabledKeyId: string().nullable() }), {
13619
+ kind: "mutation",
13620
+ auth: "admin"
13621
+ }), method(object({ backupSecretKey: string() }), object({
13622
+ valid: boolean(),
13623
+ keyId: string().nullable(),
13624
+ /** The hub knows this key (active or retired). */
13625
+ known: boolean(),
13626
+ /** It is the key new archives are encrypted to. */
13627
+ active: boolean(),
13628
+ error: string().optional()
13629
+ }), {
13630
+ kind: "mutation",
13631
+ auth: "admin"
12204
13632
  }), method(object({
12205
13633
  destinationId: string(),
12206
13634
  backupId: string()
@@ -13824,7 +15252,60 @@ var CustomModelDescriptorSchema = object({
13824
15252
  stepId: string(),
13825
15253
  entry: ModelCatalogEntrySchema
13826
15254
  });
13827
- method(_void(), array(CustomModelDescriptorSchema).readonly(), { auth: "admin" });
15255
+ /** One regular file of an imported bundle, as the producer measured it. */
15256
+ var ModelBundleFileSchema = object({
15257
+ /** Relative path inside the bundle tar; an mlpackage member is `<x>.mlpackage/<member>`. */
15258
+ path: string().min(1),
15259
+ bytes: number().int().nonnegative(),
15260
+ sha256: string().regex(/^[0-9a-f]{64}$/)
15261
+ });
15262
+ var ImportModelBundleInputSchema = object({
15263
+ /** The registry provider that keeps the model (Model Studio). */
15264
+ addonId: string(),
15265
+ stepId: string().min(1),
15266
+ /**
15267
+ * The catalog rows to register, complete, every format URL already
15268
+ * `camstack-local://<modelId>/<file>` naming a file of the bundle. One
15269
+ * bundle may carry several rows (a base and its INT8 variant).
15270
+ */
15271
+ entries: array(ModelCatalogEntrySchema).min(1).max(4),
15272
+ /** The bundle tar, offered by the producer over `ctx.peerBytes` (same host). */
15273
+ bundle: object({
15274
+ ticket: PeerBytesTicketSchema,
15275
+ bytes: number().int().positive(),
15276
+ sha256: string().regex(/^[0-9a-f]{64}$/)
15277
+ }),
15278
+ /** Every file the tar must hold; anything missing, extra or different is refused. */
15279
+ files: array(ModelBundleFileSchema).min(1).max(64),
15280
+ /** Convert missing engine formats and push the model to every agent afterwards. */
15281
+ distribute: boolean()
15282
+ });
15283
+ var ImportModelBundleResultSchema = discriminatedUnion("kind", [object({
15284
+ kind: literal("imported"),
15285
+ modelIds: array(string()).readonly(),
15286
+ distributed: array(object({
15287
+ modelId: string(),
15288
+ nodeId: string(),
15289
+ format: _enum(MODEL_FORMATS),
15290
+ ok: boolean(),
15291
+ error: string().optional()
15292
+ })).readonly()
15293
+ }), object({
15294
+ kind: literal("refused"),
15295
+ reason: _enum([
15296
+ "transfer-failed",
15297
+ "checksum-mismatch",
15298
+ "bundle-mismatch",
15299
+ "invalid-entry",
15300
+ "id-taken"
15301
+ ]),
15302
+ detail: string()
15303
+ })]);
15304
+ method(_void(), array(CustomModelDescriptorSchema).readonly(), { auth: "admin" }), method(ImportModelBundleInputSchema, ImportModelBundleResultSchema, {
15305
+ kind: "mutation",
15306
+ auth: "admin",
15307
+ timeoutMs: 30 * 6e4
15308
+ });
13828
15309
  /**
13829
15310
  * Query filter for settings-store collections.
13830
15311
  */
@@ -14207,6 +15688,253 @@ id: union([string(), number()]) }), {
14207
15688
  kind: "mutation",
14208
15689
  auth: "admin"
14209
15690
  });
15691
+ /**
15692
+ * `keychain` — the hub's encrypted store of secret values (D787).
15693
+ *
15694
+ * Settings blobs never hold a secret: they hold a marker
15695
+ * `{"$secret":"secret://<owner>/<scope>/<fieldPath>","v":1}` and the value
15696
+ * lives here, AES-256-GCM under a data key that a master key wraps. This cap
15697
+ * is the OWNER's door to its own values: every method is owner-checked
15698
+ * against the CALLER, never against anything the caller claims.
15699
+ *
15700
+ * Who the caller is: the transport stamps `callerAddonId` into the args of a
15701
+ * call that crossed a process (the parent `LocalChildRegistry` from the UDS
15702
+ * connection, the agent from its child's connection carried in
15703
+ * `$hub-cap-fwd`'s envelope). A stamp always overwrites; a wire call with no
15704
+ * stamp has its claim stripped. Only a hub in-process caller may state its own
15705
+ * identity — `ctx.secrets` does that with the addon id closed over. This is
15706
+ * identity against BUGS and misrouting, not against a malicious addon (every
15707
+ * runner is the same OS user): see the threat model in
15708
+ * `docs/design/2026-10-08-secrets-keychain.md`.
15709
+ *
15710
+ * `callerAddonId` is deliberately NOT in any input schema: the tRPC router
15711
+ * parses the input, so a session can never supply it, and the internal mount
15712
+ * floors every method to admin anyway (D240).
15713
+ *
15714
+ * Internal: addons reach it through `ctx.secrets`, never directly.
15715
+ */
15716
+ /** Why a value cannot be served right now. Never folded into "missing". */
15717
+ var KeychainUnavailableReasonSchema = _enum([
15718
+ "key-missing",
15719
+ "wrong-key",
15720
+ "key-file-unreadable",
15721
+ "store-unavailable",
15722
+ "not-initialized",
15723
+ "decrypt-failed"
15724
+ ]);
15725
+ var KeychainStateSchema = discriminatedUnion("state", [object({ state: literal("ready") }), object({
15726
+ state: literal("locked"),
15727
+ reason: KeychainUnavailableReasonSchema
15728
+ })]);
15729
+ var KeychainResolveEntrySchema = discriminatedUnion("kind", [
15730
+ object({
15731
+ kind: literal("value"),
15732
+ value: string(),
15733
+ version: number().int()
15734
+ }),
15735
+ object({ kind: literal("missing") }),
15736
+ object({
15737
+ kind: literal("unavailable"),
15738
+ reason: KeychainUnavailableReasonSchema
15739
+ }),
15740
+ object({ kind: literal("forbidden") })
15741
+ ]);
15742
+ var KeychainResolveResultSchema = record(string(), KeychainResolveEntrySchema);
15743
+ /** Metadata of one stored value — never the value. */
15744
+ var KeychainSecretMetaSchema = object({
15745
+ ref: string(),
15746
+ owner: string(),
15747
+ /** Formatted scope (`global`, `node/<id>`, `device/<id>`, …). */
15748
+ scope: string(),
15749
+ fieldPath: string(),
15750
+ version: number().int(),
15751
+ createdAt: number(),
15752
+ updatedAt: number(),
15753
+ /** `addon:<id>` | `user:<id>` | `system`. */
15754
+ updatedBy: string(),
15755
+ /** Coarse — written at most once an hour per ref. `null` = never read. */
15756
+ lastReadAt: number().nullable()
15757
+ });
15758
+ var RefListSchema = array(string().min(1)).max(512);
15759
+ method(object({
15760
+ ref: string().min(1),
15761
+ value: string().min(1)
15762
+ }), object({
15763
+ ref: string(),
15764
+ version: number().int()
15765
+ }), {
15766
+ kind: "mutation",
15767
+ auth: "admin"
15768
+ }), method(object({ refs: RefListSchema }), KeychainResolveResultSchema, { auth: "admin" }), method(object({ refs: RefListSchema }), object({ deleted: number().int() }), {
15769
+ kind: "mutation",
15770
+ auth: "admin"
15771
+ }), method(object({}), array(KeychainSecretMetaSchema).readonly(), { auth: "admin" }), method(object({}), KeychainStateSchema, { auth: "admin" });
15772
+ var KeychainKeySourceSchema = object({
15773
+ kind: _enum([
15774
+ "config-file",
15775
+ "previous-config-file",
15776
+ "platform",
15777
+ "default-file"
15778
+ ]),
15779
+ /** File sources only — a path is not a secret. */
15780
+ path: string().optional(),
15781
+ /**
15782
+ * True when a whole-volume backup of the data directory carries this key
15783
+ * next to the database it protects (the default file). The page warns.
15784
+ */
15785
+ sharesBackupWithDatabase: boolean()
15786
+ });
15787
+ /**
15788
+ * One keychain reset, as the Secrets page reports it until the operator
15789
+ * acknowledges it. Never a value: refs, counts and table names only.
15790
+ */
15791
+ var KeychainResetRecordSchema = object({
15792
+ id: string(),
15793
+ at: number(),
15794
+ /** `user:<id>` or {@link KEYCHAIN_RESET_TRIGGER_ACTOR}. */
15795
+ actor: string(),
15796
+ /** Why the keychain was locked when it was reset; `null` when it was not locked. */
15797
+ lockedReason: string().nullable(),
15798
+ /** Values moved into the archive table (ciphertext under the lost key). */
15799
+ archived: number().int(),
15800
+ /** `keychain:secrets-orphaned-<ts>`, or `null` when nothing was stored. */
15801
+ archivedCollection: string().nullable(),
15802
+ /**
15803
+ * `keychain:keys-orphaned-<ts>`: the wrapped data keys of the archive, kept
15804
+ * so the archive can still be opened if the lost master key turns up.
15805
+ */
15806
+ archivedKeysCollection: string().nullable(),
15807
+ /**
15808
+ * `system-settings` keys whose marker the reset cleared — the cluster
15809
+ * secret's: a marker left pointing at an archived value would refuse every
15810
+ * agent forever (D797).
15811
+ */
15812
+ clearedSettingsKeys: array(string()).readonly(),
15813
+ /** When an operator dismissed the notice on the Secrets page; `null` until then. */
15814
+ acknowledgedAt: number().nullable()
15815
+ });
15816
+ var KeychainStatusSchema = object({
15817
+ keychain: KeychainStateSchema,
15818
+ /** The source of the master key in use; `null` while locked. */
15819
+ keySource: KeychainKeySourceSchema.nullable(),
15820
+ /** The source configured to be primary — differs from `keySource` while a rotation is pending. */
15821
+ configuredSource: KeychainKeySourceSchema,
15822
+ /** Short fingerprint of the master key in use (`HMAC(KEK, label)`, 16 hex). */
15823
+ fingerprint: string().nullable(),
15824
+ activeKeyId: string().nullable(),
15825
+ /**
15826
+ * The keychain unlocked with a NON-primary source: the configured primary
15827
+ * key is not the one that wraps the data key yet. `rotateMasterKey` moves it.
15828
+ */
15829
+ rotationPending: boolean(),
15830
+ /** Wrapped copies of the data key under a previous master key, kept until purged. */
15831
+ retiredWraps: number().int(),
15832
+ recoveryKeyDownloadedAt: number().nullable(),
15833
+ secretCount: number().int(),
15834
+ /** The most recent reset, acknowledged or not; `null` when the keychain was never reset. */
15835
+ lastReset: KeychainResetRecordSchema.nullable()
15836
+ });
15837
+ /**
15838
+ * Whether a stored value is still pointed at by its owner's settings.
15839
+ * `unknown` is a first-class answer: a scope whose blob could not be read is
15840
+ * never reported as an orphan (and never deleted as one).
15841
+ */
15842
+ var KeychainSecretUsageSchema = _enum([
15843
+ "in-use",
15844
+ "orphan",
15845
+ "unknown"
15846
+ ]);
15847
+ var KeychainAdminSecretSchema = KeychainSecretMetaSchema.extend({ usage: KeychainSecretUsageSchema });
15848
+ var KeychainAuditActionSchema = _enum([
15849
+ "put",
15850
+ "delete",
15851
+ "reveal",
15852
+ "rotate-master-key",
15853
+ "purge-retired-keys",
15854
+ "download-recovery-key",
15855
+ "delete-orphans",
15856
+ "reset",
15857
+ "acknowledge-reset",
15858
+ "initialize"
15859
+ ]);
15860
+ var KeychainAuditEntrySchema = object({
15861
+ id: string(),
15862
+ at: number(),
15863
+ action: KeychainAuditActionSchema,
15864
+ /** `addon:<id>` | `user:<id>` | `system` | `trigger-file`. */
15865
+ actor: string(),
15866
+ ref: string().nullable(),
15867
+ detail: string().nullable()
15868
+ });
15869
+ var KEYCHAIN_RESET_CONFIRMATION = "RESET KEYCHAIN";
15870
+ /**
15871
+ * Secrets the HUB itself holds (owner `system`) that no settings form shows:
15872
+ * `jwt-signing-key` — the session signing key (D797). It is always "in use",
15873
+ * never an orphan; it is generated on a fresh hub and replaced only through
15874
+ * {@link keychainAdminCapability.methods.setSystemSecret}.
15875
+ */
15876
+ var SystemHeldSecretNameSchema = _enum(["jwt-signing-key"]);
15877
+ 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({
15878
+ value: string(),
15879
+ version: number().int()
15880
+ }), {
15881
+ kind: "mutation",
15882
+ auth: "admin",
15883
+ caller: "required"
15884
+ }), method(object({
15885
+ name: SystemHeldSecretNameSchema,
15886
+ value: string().min(16)
15887
+ }), object({
15888
+ ref: string(),
15889
+ version: number().int()
15890
+ }), {
15891
+ kind: "mutation",
15892
+ auth: "admin",
15893
+ caller: "required"
15894
+ }), method(object({ refs: array(string().min(1)).max(1e3) }), object({
15895
+ deleted: array(string()).readonly(),
15896
+ kept: array(object({
15897
+ ref: string(),
15898
+ usage: KeychainSecretUsageSchema
15899
+ })).readonly()
15900
+ }), {
15901
+ kind: "mutation",
15902
+ auth: "admin",
15903
+ caller: "required"
15904
+ }), method(object({}), object({
15905
+ fingerprint: string(),
15906
+ keySource: KeychainKeySourceSchema
15907
+ }), {
15908
+ kind: "mutation",
15909
+ auth: "admin",
15910
+ caller: "required"
15911
+ }), method(object({}), object({ purged: number().int() }), {
15912
+ kind: "mutation",
15913
+ auth: "admin",
15914
+ caller: "required"
15915
+ }), method(object({}), object({
15916
+ key: string(),
15917
+ fingerprint: string(),
15918
+ keySource: KeychainKeySourceSchema
15919
+ }), {
15920
+ kind: "mutation",
15921
+ auth: "admin",
15922
+ caller: "required"
15923
+ }), method(object({ confirm: literal(KEYCHAIN_RESET_CONFIRMATION) }), object({
15924
+ archivedCollection: string().nullable(),
15925
+ archived: number().int()
15926
+ }), {
15927
+ kind: "mutation",
15928
+ auth: "admin",
15929
+ caller: "required"
15930
+ }), method(object({}), object({
15931
+ reset: KeychainResetRecordSchema.nullable(),
15932
+ pendingReentry: array(KeychainSecretMetaSchema).readonly()
15933
+ }), { auth: "admin" }), method(object({}), object({ acknowledged: boolean() }), {
15934
+ kind: "mutation",
15935
+ auth: "admin",
15936
+ caller: "required"
15937
+ });
14210
15938
  method(_void(), object({
14211
15939
  id: string(),
14212
15940
  name: string(),
@@ -15269,7 +16997,11 @@ var DeviceRegisterPayloadSchema = object({
15269
16997
  var DeviceRemovePayloadSchema = object({ deviceId: number() });
15270
16998
  var DevicePersistConfigPayloadSchema = object({
15271
16999
  deviceId: number(),
15272
- data: record(string(), unknown())
17000
+ data: record(string(), unknown()),
17001
+ /** The paths the device's schema declares secret (D783), when the caller
17002
+ * knows them — those values are kept in the keychain, not the blob (D787).
17003
+ * Absent: the paths the device last reported at `registerDevice` apply. */
17004
+ secretConfigPaths: array(string()).optional()
15273
17005
  });
15274
17006
  /** What a migration actually did, per switch. `unreachable` is a first-class
15275
17007
  * answer: a camera that could not be asked is not a camera that was silenced. */
@@ -16872,7 +18604,7 @@ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
16872
18604
  * `login-method` — collection cap through which auth addons contribute
16873
18605
  * their pre-auth login surfaces to the login page. This is the SINGLE,
16874
18606
  * generic mechanism that supersedes the dead `auth.listProviders` reader:
16875
- * every auth addon (OIDC, magic-link, WebAuthn/passkey) registers a
18607
+ * every auth addon (OIDC, WebAuthn/passkey) registers a
16876
18608
  * `login-method` provider and the PUBLIC `auth.listLoginMethods`
16877
18609
  * procedure aggregates them for the unauthenticated login page.
16878
18610
  *
@@ -16880,8 +18612,7 @@ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
16880
18612
  *
16881
18613
  * - `redirect` — a declarative button. The login page renders a generic
16882
18614
  * button that navigates to `startUrl` (an addon-owned HTTP route).
16883
- * Covers OIDC (`/addon/auth-oidc/<id>/start`) and magic-link with
16884
- * ZERO shell-side JS. A future SSO addon plugs in the same way — the
18615
+ * Covers OIDC (`/addon/auth-oidc/<id>/start`) with ZERO shell-side JS. A future SSO addon plugs in the same way — the
16885
18616
  * login page needs NO change.
16886
18617
  *
16887
18618
  * - `widget` — a Module-Federation widget the login page mounts (via
@@ -16900,8 +18631,8 @@ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
16900
18631
  * decision.
16901
18632
  *
16902
18633
  * Every contribution carries a `stage`:
16903
- * - `primary` — shown on the first credentials screen (OIDC /
16904
- * magic-link buttons; a future usernameless passkey).
18634
+ * - `primary` — shown on the first credentials screen (OIDC
18635
+ * buttons; a usernameless passkey).
16905
18636
  * - `second-factor` — shown AFTER the password leg, gated on the
16906
18637
  * returned `factors` (passkey-as-2FA today).
16907
18638
  *
@@ -16928,7 +18659,7 @@ var LoginMethodContributionSchema = discriminatedUnion("kind", [
16928
18659
  * The provider names an external identity a signed-in user can link to
16929
18660
  * their own account (D782): `auth.listLinkableProviders` /
16930
18661
  * `beginExternalLink` offer exactly the redirect methods that set this,
16931
- * whatever their id. Absent / false — a login button only (magic-link).
18662
+ * whatever their id. Absent / false — a login button only.
16932
18663
  */
16933
18664
  linkable: boolean().optional()
16934
18665
  }),
@@ -20745,8 +22476,7 @@ method(object({}), object({ rules: array(NcRuleSchema) }), { auth: "admin" }), m
20745
22476
  * `super_admin` — collapsed onto the single boolean because every
20746
22477
  * non-admin caller is governed by the same scope-check rules; the
20747
22478
  * distinction was only ever used to route role-specific procedures
20748
- * which we no longer have. Agents are admin sessions issued via
20749
- * `createServiceToken`; CLI / webhook integrations are `cst_*` tokens
22479
+ * which we no longer have. CLI / webhook integrations are `cst_*` tokens
20750
22480
  * with `isAdmin: false` + an explicit scope list.
20751
22481
  */
20752
22482
  /** Per-method access flavour. Materialised on every cap method via codegen. */
@@ -22264,8 +23994,23 @@ var RetrainMacroClassSchema = _enum([
22264
23994
  ]);
22265
23995
  /** A subject to learn, or a phantom to unlearn (taught by OMISSION). */
22266
23996
  var RetrainAnnotationKindSchema = _enum(["subject", "model_error"]);
22267
- /** Did a human draw this box, or did the assist propose it? */
22268
- var RetrainAnnotationSourceSchema = _enum(["operator", "assist"]);
23997
+ /**
23998
+ * Where a box came from. A machine-sourced box is a DRAFT on the page until
23999
+ * the operator confirms it; once saved it keeps its source as provenance.
24000
+ *
24001
+ * - `operator` — drawn by hand.
24002
+ * - `assist` — proposed by a detector run on the copy (the camera's own
24003
+ * model, or a larger teacher model).
24004
+ * - `pipeline` — the box the live pipeline actually drew on that frame, read
24005
+ * back from the track store (never a re-run).
24006
+ * - `llm` — proposed by a vision-capable LLM profile.
24007
+ */
24008
+ var RetrainAnnotationSourceSchema = _enum([
24009
+ "operator",
24010
+ "assist",
24011
+ "pipeline",
24012
+ "llm"
24013
+ ]);
22269
24014
  /** Normalised `[0,1]` rectangle against the FULL frame — the canonical form. */
22270
24015
  var RetrainBboxSchema = object({
22271
24016
  x: number(),
@@ -22283,7 +24028,8 @@ var RetrainBboxSchema = object({
22283
24028
  */
22284
24029
  var RetrainAnnotationSchema = object({
22285
24030
  id: string(),
22286
- trackId: string(),
24031
+ /** The frame's track. Absent on a recording still, which has none. */
24032
+ trackId: string().optional(),
22287
24033
  deviceId: number(),
22288
24034
  /** The COPY in retrain storage — never the source track's media key. */
22289
24035
  mediaKey: string(),
@@ -22332,13 +24078,47 @@ var RetrainFrameCandidateSchema = object({
22332
24078
  * fail, whatever became of the original. */
22333
24079
  copied: boolean()
22334
24080
  });
24081
+ /**
24082
+ * One box the live pipeline drew on a copied frame — what a correction starts
24083
+ * from. Derived when the frame is listed, from the track store: the subject
24084
+ * box recorded on the source media row when there is one, else the track
24085
+ * position nearest the frame's capture time. Never stored as an annotation
24086
+ * until the operator confirms it.
24087
+ */
24088
+ var RetrainPipelineBoxSchema = object({
24089
+ /** Normalised `[0,1]` against the full frame. */
24090
+ bbox: RetrainBboxSchema,
24091
+ macroClass: RetrainMacroClassSchema,
24092
+ label: string().optional(),
24093
+ subLabel: string().optional(),
24094
+ /** The detection score of the position used, when it was recorded. */
24095
+ score: number().optional(),
24096
+ /** The root model that produced the track, when it was recorded. */
24097
+ modelId: string().optional(),
24098
+ trackId: string(),
24099
+ /** `subject-box`: recorded on this very frame. `position`: the track's
24100
+ * position nearest the capture time, `deltaMs` away. */
24101
+ basis: _enum(["subject-box", "position"]),
24102
+ deltaMs: number()
24103
+ });
24104
+ /**
24105
+ * Where a retrain frame came from: a TRACK's stored media (copy-on-select),
24106
+ * or the RECORDING at an instant — the frame a model saw nothing in has no
24107
+ * track at all.
24108
+ */
24109
+ var RetrainFrameOriginSchema = _enum(["track", "recording"]);
22335
24110
  /** A frame the dataset OWNS: bytes copied at selection time. */
22336
24111
  var RetrainFrameSchema = object({
22337
24112
  frameId: string(),
22338
24113
  deviceId: number(),
22339
- trackId: string(),
22340
- /** Provenance only. It may already point at nothing — that is expected. */
22341
- sourceMediaId: number().int(),
24114
+ origin: RetrainFrameOriginSchema,
24115
+ /** The track it was copied from. Absent on a recording still. */
24116
+ trackId: string().optional(),
24117
+ /** Provenance only. It may already point at nothing — that is expected.
24118
+ * Absent on a recording still. */
24119
+ sourceMediaId: number().int().optional(),
24120
+ /** A recording still: the playhead instant it was taken at. */
24121
+ epochMs: number().optional(),
22342
24122
  sourceKind: MediaFileKindEnum,
22343
24123
  sizeBytes: number().int(),
22344
24124
  width: number().int(),
@@ -22349,7 +24129,12 @@ var RetrainFrameSchema = object({
22349
24129
  /** The operator's "every subject in this frame is boxed". Detector
22350
24130
  * evaluation keeps only complete frames: an unboxed subject would count as
22351
24131
  * a false positive. */
22352
- complete: boolean()
24132
+ complete: boolean(),
24133
+ /** The boxes the pipeline drew on this frame. Present on list answers;
24134
+ * empty when nothing the track store holds can be placed on it. */
24135
+ pipelineBoxes: array(RetrainPipelineBoxSchema).readonly().optional(),
24136
+ /** The named collections this frame belongs to. Present on list answers. */
24137
+ collectionIds: array(string()).readonly().optional()
22353
24138
  });
22354
24139
  /** Why a copy-on-select could not be honoured — named, never a silent skip. */
22355
24140
  var RetrainCopyRefusalSchema = _enum([
@@ -22380,6 +24165,11 @@ var RetrainFrameListSchema = object({
22380
24165
  var RetrainExportFilterSchema = object({
22381
24166
  deviceIds: array(number()).optional(),
22382
24167
  frameIds: array(string()).max(2e4).optional(),
24168
+ /** Only frames in at least one of these named collections. */
24169
+ collectionIds: array(string()).max(200).optional(),
24170
+ /** Exactly the frames of this dataset version (and its completeOnly). An
24171
+ * unknown id selects nothing. */
24172
+ datasetVersionId: string().optional(),
22383
24173
  batchId: string().optional(),
22384
24174
  /** Only frames the operator marked complete (all subjects boxed). */
22385
24175
  completeOnly: boolean().optional()
@@ -22444,6 +24234,170 @@ var RetrainAssistResultSchema = discriminatedUnion("kind", [object({
22444
24234
  reason: string(),
22445
24235
  detail: string().optional()
22446
24236
  })]);
24237
+ /** A named set over the retrain corpus — membership only, it owns no pixels. */
24238
+ var RetrainCollectionSchema = object({
24239
+ id: string(),
24240
+ name: string(),
24241
+ createdAt: number(),
24242
+ frameCount: number().int()
24243
+ });
24244
+ var RetrainCollectionCreateResultSchema = discriminatedUnion("kind", [object({
24245
+ kind: literal("created"),
24246
+ collection: RetrainCollectionSchema
24247
+ }), object({
24248
+ kind: literal("refused"),
24249
+ reason: _enum(["empty-name", "duplicate-name"])
24250
+ })]);
24251
+ var RetrainCollectionRenameResultSchema = discriminatedUnion("kind", [object({
24252
+ kind: literal("renamed"),
24253
+ collection: RetrainCollectionSchema
24254
+ }), object({
24255
+ kind: literal("refused"),
24256
+ reason: _enum([
24257
+ "empty-name",
24258
+ "duplicate-name",
24259
+ "unknown-collection"
24260
+ ])
24261
+ })]);
24262
+ /**
24263
+ * The outcome of adding the frame at a recording instant. Every refusal is
24264
+ * named: `still-unavailable` (not recording, a gap, or an undecodable frame —
24265
+ * `detail` says which), `still-busy` (the recorder is at its decode bound; try
24266
+ * again), `unreadable-image`, `write-failed`, `unknown-collection`.
24267
+ */
24268
+ var AddRetrainFrameFromRecordingResultSchema = discriminatedUnion("kind", [object({
24269
+ kind: literal("added"),
24270
+ collectionId: string(),
24271
+ frame: RetrainFrameSchema,
24272
+ /** The moment was already in the dataset; nothing was decoded. */
24273
+ reused: boolean()
24274
+ }), object({
24275
+ kind: literal("refused"),
24276
+ reason: _enum([
24277
+ "unknown-collection",
24278
+ "still-unavailable",
24279
+ "still-busy",
24280
+ "unreadable-image",
24281
+ "write-failed"
24282
+ ]),
24283
+ detail: string().optional()
24284
+ })]);
24285
+ /** A vision LLM profile the AI assist may use, and where it sends the frame. */
24286
+ var RetrainAssistProfileSchema = object({
24287
+ id: string(),
24288
+ name: string(),
24289
+ model: string(),
24290
+ kind: string(),
24291
+ /** `true` when the frame would leave the house (a cloud vendor, or an
24292
+ * endpoint that is not on the local network). The page confirms each such
24293
+ * run, and the provider refuses one without `allowCloud`. */
24294
+ leavesHouse: boolean()
24295
+ });
24296
+ /** A box the AI assist proposed: a draft, plus the model's own reason. */
24297
+ var RetrainLlmProposalSchema = RetrainAnnotationDraftSchema.extend({ reason: string() });
24298
+ /** What the AI assist said about a box that was already on the canvas. */
24299
+ var RetrainLlmReviewSchema = object({
24300
+ /** The `ref` the page sent the box under. */
24301
+ ref: string(),
24302
+ verdict: _enum([
24303
+ "confirmed",
24304
+ "wrong-class",
24305
+ "not-an-object",
24306
+ "uncertain"
24307
+ ]),
24308
+ suggestedClass: RetrainMacroClassSchema.optional(),
24309
+ reason: string()
24310
+ });
24311
+ /**
24312
+ * The AI assist's answer. `proposed` carries drafts (`source: 'llm'`, the
24313
+ * model and its confidence) and reviews; items the model got wrong (a box off
24314
+ * the frame, an unasked class, an unknown ref) are dropped and counted in
24315
+ * `rejected`. A whole answer that is not the schema is `malformed-answer`.
24316
+ */
24317
+ var RetrainLlmAssistResultSchema = discriminatedUnion("kind", [object({
24318
+ kind: literal("proposed"),
24319
+ profileId: string(),
24320
+ model: string(),
24321
+ /** The frame was sent outside the house for this answer. */
24322
+ leftHouse: boolean(),
24323
+ proposals: array(RetrainLlmProposalSchema).readonly(),
24324
+ reviews: array(RetrainLlmReviewSchema).readonly(),
24325
+ rejected: number().int()
24326
+ }), object({
24327
+ kind: literal("refused"),
24328
+ reason: _enum([
24329
+ "unknown-frame",
24330
+ "unreadable-frame",
24331
+ "unknown-profile",
24332
+ "profile-disabled",
24333
+ "no-vision",
24334
+ "cloud-not-confirmed",
24335
+ "llm-error",
24336
+ "malformed-answer"
24337
+ ]),
24338
+ detail: string().optional()
24339
+ })]);
24340
+ /** What a dataset version is cut from. Every field narrows. */
24341
+ var RetrainDatasetSelectionSchema = object({
24342
+ deviceIds: array(number()).readonly().optional(),
24343
+ collectionIds: array(string()).max(200).readonly().optional(),
24344
+ frameIds: array(string()).max(2e4).readonly().optional()
24345
+ });
24346
+ /** The counts a dataset is judged by. */
24347
+ var RetrainDatasetStatsSchema = object({
24348
+ frames: number().int(),
24349
+ completeFrames: number().int(),
24350
+ /** `completeFrames / frames`, 0..1. */
24351
+ completeness: number(),
24352
+ /** Boxes to learn (model errors excluded). */
24353
+ subjects: number().int(),
24354
+ modelErrors: number().int(),
24355
+ /** Complete frames with no subject. */
24356
+ hardNegatives: number().int(),
24357
+ /** Subjects per class × camera × day/night. */
24358
+ cells: array(object({
24359
+ macroClass: string(),
24360
+ deviceId: number(),
24361
+ lighting: _enum([
24362
+ "day",
24363
+ "night",
24364
+ "unknown"
24365
+ ]),
24366
+ subjects: number().int(),
24367
+ frames: number().int()
24368
+ })).readonly(),
24369
+ cameras: array(object({
24370
+ deviceId: number(),
24371
+ frames: number().int(),
24372
+ completeFrames: number().int()
24373
+ })).readonly()
24374
+ });
24375
+ /** An immutable dataset version, without its frame list. */
24376
+ var RetrainDatasetVersionSchema = object({
24377
+ id: string(),
24378
+ name: string(),
24379
+ createdAt: number(),
24380
+ selection: RetrainDatasetSelectionSchema,
24381
+ layout: RetrainExportLayoutSchema,
24382
+ completeOnly: boolean(),
24383
+ frameCount: number().int(),
24384
+ /** sha256 of what the frames taught when the version was frozen. */
24385
+ annotationHash: string(),
24386
+ /** The export manifest schema the version was cut under. */
24387
+ manifestSchema: string(),
24388
+ stats: RetrainDatasetStatsSchema
24389
+ });
24390
+ var CreateRetrainDatasetVersionResultSchema = discriminatedUnion("kind", [object({
24391
+ kind: literal("created"),
24392
+ version: RetrainDatasetVersionSchema
24393
+ }), object({
24394
+ kind: literal("refused"),
24395
+ reason: _enum([
24396
+ "empty-name",
24397
+ "duplicate-name",
24398
+ "no-frames"
24399
+ ])
24400
+ })]);
22447
24401
  /** The outcome of a lifecycle move owned by the retrain page. */
22448
24402
  var RetrainTransitionResultSchema = object({
22449
24403
  trackId: string(),
@@ -23161,7 +25115,7 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
23161
25115
  auth: "admin"
23162
25116
  }), method(object({
23163
25117
  deviceId: number(),
23164
- trackId: string(),
25118
+ trackId: string().optional(),
23165
25119
  frameId: string()
23166
25120
  }), object({
23167
25121
  removed: boolean(),
@@ -23178,7 +25132,8 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
23178
25132
  auth: "admin"
23179
25133
  }), method(object({
23180
25134
  deviceId: number(),
23181
- trackId: string(),
25135
+ /** The frame's track, when it has one — checked against the frame. */
25136
+ trackId: string().optional(),
23182
25137
  frameId: string(),
23183
25138
  subject: RetrainAssistSubjectSchema,
23184
25139
  /** Which node runs it. Absent ⇒ wherever an unowned call lands. */
@@ -23186,12 +25141,16 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
23186
25141
  }), RetrainAssistResultSchema, {
23187
25142
  kind: "mutation",
23188
25143
  auth: "admin"
23189
- }), method(object({ trackId: string() }), array(RetrainAnnotationSchema).readonly(), {
25144
+ }), method(object({
25145
+ trackId: string().optional(),
25146
+ frameIds: array(string()).max(2e3).optional()
25147
+ }), array(RetrainAnnotationSchema).readonly(), {
23190
25148
  kind: "query",
23191
25149
  auth: "admin"
23192
25150
  }), method(object({
23193
25151
  deviceId: number(),
23194
- trackId: string(),
25152
+ /** The frame's track, when it has one — checked against the frame. */
25153
+ trackId: string().optional(),
23195
25154
  frameId: string(),
23196
25155
  annotations: array(RetrainAnnotationDraftSchema)
23197
25156
  }), array(RetrainAnnotationSchema).readonly(), {
@@ -23214,7 +25173,7 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
23214
25173
  auth: "admin"
23215
25174
  }), method(object({
23216
25175
  deviceId: number(),
23217
- trackId: string(),
25176
+ trackId: string().optional(),
23218
25177
  frameId: string(),
23219
25178
  complete: boolean()
23220
25179
  }), RetrainFrameSchema, {
@@ -23228,6 +25187,115 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
23228
25187
  kind: "mutation",
23229
25188
  auth: "admin",
23230
25189
  timeoutMs: 60 * 6e4
25190
+ }), method(object({
25191
+ filter: RetrainExportFilterSchema,
25192
+ layout: RetrainExportLayoutSchema
25193
+ }), object({
25194
+ ticket: PeerBytesTicketSchema,
25195
+ frames: number().int(),
25196
+ annotations: number().int()
25197
+ }), {
25198
+ kind: "mutation",
25199
+ auth: "admin",
25200
+ timeoutMs: 12e4
25201
+ }), method(object({
25202
+ selection: RetrainDatasetSelectionSchema,
25203
+ completeOnly: boolean().optional()
25204
+ }), RetrainDatasetStatsSchema, {
25205
+ kind: "query",
25206
+ auth: "admin"
25207
+ }), method(object({
25208
+ name: string().max(120),
25209
+ selection: RetrainDatasetSelectionSchema,
25210
+ layout: RetrainExportLayoutSchema,
25211
+ completeOnly: boolean()
25212
+ }), CreateRetrainDatasetVersionResultSchema, {
25213
+ kind: "mutation",
25214
+ auth: "admin",
25215
+ timeoutMs: 12e4
25216
+ }), method(object({}), array(RetrainDatasetVersionSchema).readonly(), {
25217
+ kind: "query",
25218
+ auth: "admin"
25219
+ }), method(object({ id: string() }), object({ deleted: boolean() }), {
25220
+ kind: "mutation",
25221
+ auth: "admin"
25222
+ }), method(object({ id: string() }), object({
25223
+ found: boolean(),
25224
+ annotationHash: string(),
25225
+ matches: boolean(),
25226
+ missingFrames: number().int()
25227
+ }), {
25228
+ kind: "query",
25229
+ auth: "admin",
25230
+ timeoutMs: 12e4
25231
+ }), method(object({}), array(RetrainAssistProfileSchema).readonly(), {
25232
+ kind: "query",
25233
+ auth: "admin"
25234
+ }), method(object({
25235
+ deviceId: number(),
25236
+ trackId: string().optional(),
25237
+ frameId: string(),
25238
+ profileId: string(),
25239
+ classes: array(RetrainMacroClassSchema).min(1),
25240
+ boxes: array(object({
25241
+ ref: string(),
25242
+ bbox: RetrainBboxSchema,
25243
+ macroClass: RetrainMacroClassSchema,
25244
+ label: string().optional()
25245
+ })).max(50),
25246
+ allowCloud: boolean()
25247
+ }), RetrainLlmAssistResultSchema, {
25248
+ kind: "mutation",
25249
+ auth: "admin",
25250
+ timeoutMs: 18e4
25251
+ }), method(object({ name: string().max(120) }), RetrainCollectionCreateResultSchema, {
25252
+ kind: "mutation",
25253
+ auth: "admin"
25254
+ }), method(object({}), array(RetrainCollectionSchema).readonly(), {
25255
+ kind: "query",
25256
+ auth: "admin"
25257
+ }), method(object({
25258
+ id: string(),
25259
+ name: string().max(120)
25260
+ }), RetrainCollectionRenameResultSchema, {
25261
+ kind: "mutation",
25262
+ auth: "admin"
25263
+ }), method(object({ id: string() }), object({
25264
+ deleted: boolean(),
25265
+ removedFrames: number().int()
25266
+ }), {
25267
+ kind: "mutation",
25268
+ auth: "admin"
25269
+ }), method(object({
25270
+ collectionId: string(),
25271
+ deviceId: number(),
25272
+ epochMs: number()
25273
+ }), AddRetrainFrameFromRecordingResultSchema, {
25274
+ kind: "mutation",
25275
+ auth: "admin",
25276
+ timeoutMs: 6e4
25277
+ }), method(object({
25278
+ collectionId: string(),
25279
+ frameIds: array(string()).min(1).max(500)
25280
+ }), object({
25281
+ added: number().int(),
25282
+ alreadyMember: number().int(),
25283
+ unknownFrameIds: array(string()).readonly()
25284
+ }), {
25285
+ kind: "mutation",
25286
+ auth: "admin"
25287
+ }), method(object({
25288
+ collectionId: string(),
25289
+ frameId: string()
25290
+ }), object({
25291
+ removed: boolean(),
25292
+ deletedFrame: boolean()
25293
+ }), {
25294
+ kind: "mutation",
25295
+ auth: "admin"
25296
+ }), method(object({ collectionId: string() }), array(RetrainFrameSchema).readonly(), {
25297
+ kind: "query",
25298
+ auth: "admin"
23231
25299
  }), method(object({
23232
25300
  /** Which of the three event tables owns the row. */
23233
25301
  ownerType: EventOwnerTypeSchema,
@@ -23851,13 +25919,31 @@ var RecommendationReasonSchema = discriminatedUnion("kind", [
23851
25919
  object({
23852
25920
  kind: literal("no-family-build"),
23853
25921
  format: ModelFormatSchema$1
25922
+ }),
25923
+ object({
25924
+ kind: literal("kept-custom-pin"),
25925
+ modelId: string(),
25926
+ deviceKey: string()
23854
25927
  })
23855
25928
  ]);
25929
+ /** Why a device is left exactly as it is, whatever the plan would pick (D786). */
25930
+ var KeptReasonSchema = _enum(["custom-pin"]);
25931
+ /**
25932
+ * Where a choice's latency came from (D791): this node's own benchmark
25933
+ * result, or the hardware-class table. Measured on the node beats the table.
25934
+ */
25935
+ var LatencySourceSchema = discriminatedUnion("kind", [object({ kind: literal("table") }), object({
25936
+ kind: literal("node-benchmark"),
25937
+ resultId: string(),
25938
+ measuredAtMs: number()
25939
+ })]);
23856
25940
  var DeviceModelChoiceSchema = object({
23857
25941
  modelId: string(),
23858
25942
  p50Ms: number(),
23859
25943
  fps: number(),
23860
25944
  measured: boolean(),
25945
+ /** Absent on a plan from before D791 — read as the table. */
25946
+ source: LatencySourceSchema.optional(),
23861
25947
  /** Parallel sessions at the camera rate with the headroom kept free: ⌊fps × (1 − headroom) / camera fps⌋. */
23862
25948
  capacitySessions: number(),
23863
25949
  personRecall: number()
@@ -23868,6 +25954,8 @@ var DeviceRecommendationSchema = object({
23868
25954
  enabled: boolean(),
23869
25955
  available: boolean(),
23870
25956
  chosen: DeviceModelChoiceSchema.nullable(),
25957
+ /** Present when the device is kept as is: Apply writes nothing on it. */
25958
+ kept: KeptReasonSchema.optional(),
23871
25959
  reasons: array(RecommendationReasonSchema).readonly()
23872
25960
  });
23873
25961
  var NodeRecommendationSchema = object({
@@ -23921,6 +26009,17 @@ var AutoTuneWarningSchema = discriminatedUnion("kind", [
23921
26009
  kind: literal("coral-enabled"),
23922
26010
  nodeId: string(),
23923
26011
  deviceKey: string()
26012
+ }),
26013
+ object({
26014
+ kind: literal("custom-pin-kept"),
26015
+ nodeId: string(),
26016
+ deviceKey: string().nullable(),
26017
+ deviceId: number().nullable(),
26018
+ modelId: string()
26019
+ }),
26020
+ object({
26021
+ kind: literal("custom-registry-unreadable"),
26022
+ error: string()
23924
26023
  })
23925
26024
  ]);
23926
26025
  var AutoTuneOptionsSchema = object({
@@ -24099,13 +26198,14 @@ var SuggestSharesResultSchema = object({
24099
26198
  nodes: array(SuggestedNodeShareSchema).readonly()
24100
26199
  });
24101
26200
  /**
24102
- * Where the node and device shares come from (D750, D755).
24103
- * - `hardware` (default) — computed by the system from each node's static
24104
- * capacity (its accelerators at their Auto tune models, from the measured
24105
- * latency table), recomputed whenever a node or device joins, leaves, is
24106
- * switched on or off, or changes model. No load input.
24107
- * - `benchmark` — the same, from each node's measured capacity (node
24108
- * benchmark results); a node without results falls back to `hardware`.
26201
+ * Where the node and device shares come from (D750, D755, D791).
26202
+ * - `benchmark` (default since D791) — each node's capacity as its own node
26203
+ * benchmark measured it; a node without fresh results is sized from
26204
+ * `hardware` and says so. Measured on the node beats the table.
26205
+ * - `hardware` — computed from each node's static capacity only (its
26206
+ * accelerators at their Auto tune models, from the latency table).
26207
+ * Both are recomputed whenever a node or device joins, leaves, is switched
26208
+ * on or off, changes model, or a benchmark result is written. No load input.
24109
26209
  * - `manual` — the operator's stored sliders.
24110
26210
  * Either way a node or device that cannot take sessions gives its share to
24111
26211
  * the others in proportion; the stored values are never rewritten for that.
@@ -24154,6 +26254,362 @@ var EffectiveSharesSchema = object({
24154
26254
  nodeWeights: record(string(), number()),
24155
26255
  deviceWeights: record(string(), record(string(), number()))
24156
26256
  });
26257
+ /**
26258
+ * Wire shapes of the node benchmark (D791): the operator's plan, the
26259
+ * preflight the confirmation shows, the run the orchestrator owns, what the
26260
+ * measuring runner reports, and the result rows Auto tune and the automatic
26261
+ * shares read.
26262
+ *
26263
+ * ONE node at a time, owned by the pipeline orchestrator. While a run is
26264
+ * active the cluster is in BENCHMARK MODE for that node: it is not a
26265
+ * detection candidate, camera pins naming it are ignored so its sessions move
26266
+ * elsewhere, and both come back when the mode ends — after a crash or a hub
26267
+ * restart too (a persisted manifest, reconciled against the registry).
26268
+ *
26269
+ * Two measurements, both on the node, driven by its own runner (frames never
26270
+ * cross a process at frame rate, D9):
26271
+ * - `device` — one accelerator × one candidate detector, root only, open
26272
+ * loop: how many streams at the camera rate it carries inside the frame
26273
+ * interval;
26274
+ * - `pipeline` — the chosen detector plus the operator's detail steps
26275
+ * (faces, plates, classifiers, CLIP…), on varied frames from the bench
26276
+ * clip: how many parallel sessions the node carries before latency, drops,
26277
+ * CPU, RAM or the event loop give out.
26278
+ */
26279
+ /** Defaults and bounds, one place. */
26280
+ var NODE_BENCHMARK_DEFAULTS = {
26281
+ fpsPerStream: 10,
26282
+ budgetMinutes: 45,
26283
+ minBudgetMinutes: 10,
26284
+ maxBudgetMinutes: 120,
26285
+ /** A result older than this no longer beats the table. */
26286
+ staleAfterDays: 30,
26287
+ /** Warm-in per ramp step (not accounted). */
26288
+ settleSec: 5,
26289
+ /** Accounted window per ramp step. */
26290
+ measureSec: 20,
26291
+ /** Longest the drain may take before the run is refused. */
26292
+ drainTimeoutSec: 120,
26293
+ /** Candidate models per device in one run. */
26294
+ maxModelsPerDevice: 6
26295
+ };
26296
+ /** The two measurements a run can make. */
26297
+ var NodeBenchmarkPhaseSchema = _enum(["device", "pipeline"]);
26298
+ var NodeBenchmarkDevicePlanSchema = object({
26299
+ /** `<backend>:<device>` — `openvino:npu`, `coreml:all`, `cpu`. */
26300
+ deviceKey: string().min(1),
26301
+ /**
26302
+ * Root detector candidates for the `device` measurement, in the order
26303
+ * measured. The FIRST is the one the `pipeline` measurement runs.
26304
+ */
26305
+ modelIds: array(string().min(1)).min(1).max(NODE_BENCHMARK_DEFAULTS.maxModelsPerDevice)
26306
+ });
26307
+ /** What the operator confirmed. */
26308
+ var NodeBenchmarkPlanSchema = object({
26309
+ nodeId: string().min(1),
26310
+ devices: array(NodeBenchmarkDevicePlanSchema).min(1),
26311
+ /** Which measurements run. At least one. */
26312
+ phases: array(NodeBenchmarkPhaseSchema).min(1).default(["device", "pipeline"]),
26313
+ /**
26314
+ * Detail steps (catalog step ids under the root: faces, plates,
26315
+ * classifiers, CLIP…) the `pipeline` measurement enables. The root
26316
+ * detector always runs.
26317
+ */
26318
+ steps: array(string().min(1)).default([]),
26319
+ /** Offered rate of one stream / session. */
26320
+ fpsPerStream: number().int().min(1).max(30).default(NODE_BENCHMARK_DEFAULTS.fpsPerStream),
26321
+ /** Hard deadline: the mode ends and the cluster is restored when it passes. */
26322
+ budgetMinutes: number().int().min(NODE_BENCHMARK_DEFAULTS.minBudgetMinutes).max(NODE_BENCHMARK_DEFAULTS.maxBudgetMinutes).default(NODE_BENCHMARK_DEFAULTS.budgetMinutes),
26323
+ /** Keep the models the run downloaded (default: delete what was not installed before). */
26324
+ keepDownloadedModels: boolean().default(false),
26325
+ /** Start although the other nodes' capacity does not cover the sessions running now. */
26326
+ acceptInsufficientHeadroom: boolean().default(false)
26327
+ });
26328
+ var NodeBenchmarkRefusalSchema = object({
26329
+ kind: _enum([
26330
+ "benchmark-active",
26331
+ "node-offline",
26332
+ "unknown-device",
26333
+ "no-phase",
26334
+ "insufficient-headroom"
26335
+ ]),
26336
+ detail: string(),
26337
+ overridable: boolean()
26338
+ });
26339
+ /** A camera whose detection leaves the node for the run. */
26340
+ var NodeBenchmarkMovingCameraSchema = object({
26341
+ deviceId: number(),
26342
+ /** Placed on the node now (a standing attach or a running session). */
26343
+ placedOnNode: boolean(),
26344
+ /** A node pin naming this node, ignored for the run. */
26345
+ pinnedToNode: boolean()
26346
+ });
26347
+ /** A camera that cannot leave: no other node can obtain its frames. */
26348
+ var NodeBenchmarkStayingCameraSchema = object({
26349
+ deviceId: number(),
26350
+ reason: literal("only-frame-source")
26351
+ });
26352
+ var NodeBenchmarkPreflightSchema = object({
26353
+ nodeId: string(),
26354
+ online: boolean(),
26355
+ moving: array(NodeBenchmarkMovingCameraSchema).readonly(),
26356
+ /** Keep running on the node during the run; the result is flagged contaminated. */
26357
+ staying: array(NodeBenchmarkStayingCameraSchema).readonly(),
26358
+ estimatedDurationMs: number(),
26359
+ /** The run ends and the cluster is restored at the latest after this long. */
26360
+ budgetMs: number(),
26361
+ phases: array(NodeBenchmarkPhaseSchema).readonly(),
26362
+ steps: array(string()).readonly(),
26363
+ devices: array(NodeBenchmarkDevicePlanSchema).readonly(),
26364
+ /** Parallel sessions the cluster runs now, and what the other nodes can carry. */
26365
+ headroom: object({
26366
+ sessionsNow: number(),
26367
+ otherNodesCapacitySessions: number().nullable()
26368
+ }),
26369
+ refusals: array(NodeBenchmarkRefusalSchema).readonly(),
26370
+ canStart: boolean()
26371
+ });
26372
+ /** Where the measuring runner is. */
26373
+ var NodeBenchProgressSchema = object({
26374
+ phase: _enum([
26375
+ "preparing",
26376
+ "device",
26377
+ "pipeline",
26378
+ "cleanup"
26379
+ ]),
26380
+ deviceKey: string().nullable(),
26381
+ modelId: string().nullable(),
26382
+ /** Streams (device) or sessions (pipeline) of the step running now. */
26383
+ load: number().nullable(),
26384
+ cellsDone: number(),
26385
+ cellsTotal: number(),
26386
+ message: string()
26387
+ });
26388
+ /** What limited a ramp. `none` = the ramp ran out of steps still passing. */
26389
+ var NodeBenchLimitSchema = _enum([
26390
+ "p95",
26391
+ "drops",
26392
+ "errors",
26393
+ "stall",
26394
+ "cpu",
26395
+ "ram",
26396
+ "none"
26397
+ ]);
26398
+ var NodeBenchRampStepSchema = object({
26399
+ load: number(),
26400
+ pass: boolean(),
26401
+ p95Ms: number(),
26402
+ dropRatio: number(),
26403
+ /** Completed frames per second over the accounted window. */
26404
+ fps: number(),
26405
+ cpuPct: number().nullable(),
26406
+ ramFreePct: number().nullable(),
26407
+ failReasons: array(string()).readonly()
26408
+ });
26409
+ var NodeBenchCellSchema = discriminatedUnion("phase", [object({
26410
+ phase: literal("device"),
26411
+ deviceKey: string(),
26412
+ modelId: string(),
26413
+ /** Single-stream latency (the K = 1 step). */
26414
+ p50Ms: number(),
26415
+ p95Ms: number(),
26416
+ p99Ms: number(),
26417
+ /** Frames per second sustained at the last passing step. */
26418
+ fps: number(),
26419
+ /** Streams at the camera rate the device carried inside the frame interval; 0 = not even one. */
26420
+ kMax: number(),
26421
+ limitedBy: NodeBenchLimitSchema,
26422
+ /** First call (model load + warm-up). */
26423
+ warmupMs: number(),
26424
+ ramp: array(NodeBenchRampStepSchema).readonly()
26425
+ }), object({
26426
+ phase: literal("pipeline"),
26427
+ deviceKey: string(),
26428
+ modelId: string(),
26429
+ steps: array(string()).readonly(),
26430
+ /** Parallel sessions at the camera rate the node carried; 0 = not even one. */
26431
+ maxSessions: number(),
26432
+ limitedBy: NodeBenchLimitSchema,
26433
+ /** Detail steps that produced at least one result on the clip — a step that never fired measured nothing. */
26434
+ stepsFired: array(string()).readonly(),
26435
+ warmupMs: number(),
26436
+ ramp: array(NodeBenchRampStepSchema).readonly()
26437
+ })]);
26438
+ /**
26439
+ * What a result was measured ON. A result whose fingerprint no longer matches
26440
+ * the node no longer beats the table.
26441
+ */
26442
+ var NodeBenchFingerprintSchema = object({
26443
+ pipelineVersion: string().nullable(),
26444
+ cpuModel: string().nullable(),
26445
+ ramGb: number().nullable(),
26446
+ os: string().nullable(),
26447
+ /** Per device: the pool the cells ran on (runtime + tuning). */
26448
+ pools: record(string(), object({
26449
+ runtime: string(),
26450
+ numWorkers: number(),
26451
+ concurrency: number(),
26452
+ batchMode: string()
26453
+ })).default({})
26454
+ });
26455
+ /** The frames the run used. */
26456
+ var NodeBenchClipSchema = object({
26457
+ /** `camstack-bench-v1` or `reference-images` (the fallback when the clip is not reachable). */
26458
+ id: string(),
26459
+ revision: string().nullable(),
26460
+ frames: number(),
26461
+ width: number(),
26462
+ height: number()
26463
+ });
26464
+ var NodeBenchRunnerInputSchema = object({
26465
+ runId: string().min(1),
26466
+ devices: array(NodeBenchmarkDevicePlanSchema).min(1),
26467
+ phases: array(NodeBenchmarkPhaseSchema).min(1),
26468
+ /** The full detail step tree root for the `pipeline` measurement is built on the node from these ids. */
26469
+ steps: array(string()).default([]),
26470
+ fpsPerStream: number().int().min(1).max(30),
26471
+ /** The runner stops on its own past this instant, whatever the hub does. */
26472
+ deadlineAtMs: number(),
26473
+ settleSec: number().min(0).max(60).default(NODE_BENCHMARK_DEFAULTS.settleSec),
26474
+ measureSec: number().min(2).max(300).default(NODE_BENCHMARK_DEFAULTS.measureSec),
26475
+ keepDownloadedModels: boolean().default(false)
26476
+ });
26477
+ var NodeBenchRunnerStateSchema = _enum([
26478
+ "running",
26479
+ "done",
26480
+ "failed",
26481
+ "aborted"
26482
+ ]);
26483
+ var NodeBenchRunnerStatusSchema = object({
26484
+ runId: string(),
26485
+ nodeId: string(),
26486
+ state: NodeBenchRunnerStateSchema,
26487
+ progress: NodeBenchProgressSchema.nullable(),
26488
+ /** Every finished cell so far — a run stopped half way keeps what it measured. */
26489
+ cells: array(NodeBenchCellSchema).readonly(),
26490
+ fingerprint: NodeBenchFingerprintSchema.nullable(),
26491
+ clip: NodeBenchClipSchema.nullable(),
26492
+ /** Cameras seen running on the node during the run (they share its pools). */
26493
+ activeCameraIds: array(number()).readonly(),
26494
+ /** Models the run downloaded and then deleted (not installed before). */
26495
+ deletedModels: array(string()).readonly(),
26496
+ error: string().nullable(),
26497
+ startedAtMs: number(),
26498
+ finishedAtMs: number().nullable()
26499
+ });
26500
+ var NodeBenchmarkStateSchema = _enum([
26501
+ "draining",
26502
+ "measuring",
26503
+ "restoring",
26504
+ "done",
26505
+ "failed",
26506
+ "aborted"
26507
+ ]);
26508
+ /** Why a run ended. */
26509
+ var NodeBenchmarkEndReasonSchema = _enum([
26510
+ "completed",
26511
+ "operator-abort",
26512
+ "deadline",
26513
+ "node-lost",
26514
+ "runner-lost",
26515
+ "hub-restart",
26516
+ "drain-timeout",
26517
+ "failed"
26518
+ ]);
26519
+ var NodeBenchmarkRunSchema = object({
26520
+ runId: string(),
26521
+ nodeId: string(),
26522
+ state: NodeBenchmarkStateSchema,
26523
+ plan: NodeBenchmarkPlanSchema,
26524
+ startedAtMs: number(),
26525
+ deadlineAtMs: number(),
26526
+ finishedAtMs: number().nullable(),
26527
+ endReason: NodeBenchmarkEndReasonSchema.nullable(),
26528
+ error: string().nullable(),
26529
+ /** Cameras moved off the node for the run. */
26530
+ moved: array(number()).readonly(),
26531
+ /** Cameras that stayed (their only frame source is the node). */
26532
+ staying: array(number()).readonly(),
26533
+ /** Something else ran on the node's pools during the run. */
26534
+ contaminated: boolean(),
26535
+ progress: NodeBenchProgressSchema.nullable(),
26536
+ resultIds: array(string()).readonly()
26537
+ });
26538
+ /** `getNodeBenchmarkStatus`: the active run (or the last one), and whether benchmark mode is on. */
26539
+ var NodeBenchmarkStatusSchema = object({
26540
+ /** The node the cluster is in benchmark mode for; null = none. */
26541
+ modeNodeId: string().nullable(),
26542
+ run: NodeBenchmarkRunSchema.nullable()
26543
+ });
26544
+ /**
26545
+ * One stored measurement — the only authority Auto tune and the automatic
26546
+ * shares read measured capacity from. Written by the orchestrator when a run
26547
+ * ends, never by anyone else.
26548
+ */
26549
+ var NodeBenchmarkResultSchema = object({
26550
+ id: string(),
26551
+ runId: string(),
26552
+ nodeId: string(),
26553
+ cell: NodeBenchCellSchema,
26554
+ fpsPerStream: number(),
26555
+ fingerprint: NodeBenchFingerprintSchema.nullable(),
26556
+ clip: NodeBenchClipSchema.nullable(),
26557
+ /** Other work shared the node's pools (a camera that could not move, or the hub's own duties). */
26558
+ contaminated: boolean(),
26559
+ stayingCameras: array(number()).readonly(),
26560
+ /** The run ended early; the cell itself completed. */
26561
+ partialRun: boolean(),
26562
+ measuredAtMs: number()
26563
+ });
26564
+ var ListNodeBenchmarkResultsInputSchema = object({
26565
+ nodeId: string().optional(),
26566
+ deviceKey: string().optional()
26567
+ });
26568
+ /** A result with its standing today: does it still beat the table? */
26569
+ var NodeBenchmarkResultViewSchema = NodeBenchmarkResultSchema.extend({
26570
+ /** `fresh` beats the table; `stale` falls back to it; `superseded` = a newer row covers the same cell. */
26571
+ standing: _enum([
26572
+ "fresh",
26573
+ "stale",
26574
+ "superseded"
26575
+ ]),
26576
+ staleWhy: _enum([
26577
+ "age",
26578
+ "runtime",
26579
+ "pool-tuning"
26580
+ ]).nullable()
26581
+ });
26582
+ object({
26583
+ runId: string(),
26584
+ nodeId: string(),
26585
+ startedAtMs: number(),
26586
+ deadlineAtMs: number(),
26587
+ plan: NodeBenchmarkPlanSchema,
26588
+ moved: array(number()).readonly(),
26589
+ staying: array(number()).readonly()
26590
+ });
26591
+ /** Candidate detectors per device, for the plan editor. */
26592
+ var NodeBenchmarkCandidatesSchema = object({
26593
+ nodeId: string(),
26594
+ reachable: boolean(),
26595
+ devices: array(object({
26596
+ deviceKey: string(),
26597
+ enabled: boolean(),
26598
+ available: boolean(),
26599
+ /** Ordered: what Auto tune would pick first, then the rest of the family by accuracy. */
26600
+ suggested: array(string()).readonly(),
26601
+ /** Every root detector the device has a build for. */
26602
+ all: array(string()).readonly(),
26603
+ /** The model the device runs now, when pinned. */
26604
+ currentModelId: string().nullable()
26605
+ })).readonly(),
26606
+ /** Detail steps the node's catalog offers under the root (for the `pipeline` measurement). */
26607
+ steps: array(object({
26608
+ id: string(),
26609
+ name: string(),
26610
+ slot: string()
26611
+ })).readonly()
26612
+ });
24157
26613
  object({
24158
26614
  activeCameras: number(),
24159
26615
  throttledCameras: number(),
@@ -25242,7 +27698,16 @@ method(RunnerCameraConfigSchema, object({ success: literal(true) }), { kind: "mu
25242
27698
  }), ParkedTrackFrameSchema.nullable()), method(object({
25243
27699
  deviceId: number(),
25244
27700
  trackId: string()
25245
- }), object({ released: number().int().nonnegative() }), { kind: "mutation" });
27701
+ }), object({ released: number().int().nonnegative() }), { kind: "mutation" }), method(NodeBenchRunnerInputSchema, object({
27702
+ accepted: literal(true),
27703
+ runId: string()
27704
+ }), {
27705
+ kind: "mutation",
27706
+ auth: "admin"
27707
+ }), method(object({ runId: string() }), NodeBenchRunnerStatusSchema.nullable(), { auth: "admin" }), method(object({ runId: string() }), object({ aborted: boolean() }), {
27708
+ kind: "mutation",
27709
+ auth: "admin"
27710
+ });
25246
27711
  var CameraPipelineConfigSchema = object({
25247
27712
  engine: PipelineEngineChoiceSchema.optional(),
25248
27713
  steps: array(PipelineStepInputSchema).readonly(),
@@ -25881,6 +28346,21 @@ method(object({
25881
28346
  }), method(PlacementStatsInputSchema, PlacementStatsSchema, { auth: "admin" }), method(SuggestSharesInputSchema, SuggestSharesResultSchema, { auth: "admin" }), method(_void(), EffectiveSharesSchema, { auth: "admin" }), method(SetShareSourceInputSchema, object({ success: literal(true) }), {
25882
28347
  kind: "mutation",
25883
28348
  auth: "admin"
28349
+ }), method(NodeBenchmarkPlanSchema, NodeBenchmarkPreflightSchema, { auth: "admin" }), method(NodeBenchmarkPlanSchema, discriminatedUnion("kind", [object({
28350
+ kind: literal("started"),
28351
+ runId: string()
28352
+ }), object({
28353
+ kind: literal("refused"),
28354
+ preflight: NodeBenchmarkPreflightSchema
28355
+ })]), {
28356
+ kind: "mutation",
28357
+ auth: "admin"
28358
+ }), method(_void(), NodeBenchmarkStatusSchema, { auth: "admin" }), method(object({ runId: string() }), object({ aborted: boolean() }), {
28359
+ kind: "mutation",
28360
+ auth: "admin"
28361
+ }), method(object({ nodeId: string() }), NodeBenchmarkCandidatesSchema, { auth: "admin" }), method(ListNodeBenchmarkResultsInputSchema, array(NodeBenchmarkResultViewSchema).readonly(), { auth: "admin" }), method(object({ id: string() }), object({ deleted: boolean() }), {
28362
+ kind: "mutation",
28363
+ auth: "admin"
25884
28364
  }), method(object({ deviceId: number() }), CameraPipelineSettingsSchema.nullable()), method(object({
25885
28365
  deviceId: number(),
25886
28366
  addonId: string(),
@@ -26286,8 +28766,8 @@ version: string().optional() }), ServerUpdateActionResultSchema, {
26286
28766
  * `smtp-provider` — pluggable email delivery surface.
26287
28767
  *
26288
28768
  * Collection cap: a deployment may install multiple SMTP relays (e.g.
26289
- * one for transactional / one for notifications). Consumers (magic-link,
26290
- * notifier addons, …) walk the collection and pick the first
28769
+ * one for transactional / one for notifications). Consumers (notifier
28770
+ * addons, …) walk the collection and pick the first
26291
28771
  * ready provider OR target a specific addonId.
26292
28772
  *
26293
28773
  * The shape stays small on purpose — `sendEmail` is enough for the
@@ -26466,7 +28946,7 @@ targets: array(object({
26466
28946
  })));
26467
28947
  /**
26468
28948
  * `sso-bridge` — internal hub-only cap that lets SSO-style auth
26469
- * providers (OIDC, SAML, magic-link, …) mint an HMAC-signed token
28949
+ * providers (OIDC, SAML, …) mint an HMAC-signed token
26470
28950
  * carrying the post-callback claims before redirecting back to
26471
28951
  * `/api/auth/sso/finish`.
26472
28952
  *
@@ -26529,7 +29009,14 @@ var SsoBridgeClaimsSchema = object({
26529
29009
  * Verified `iss` of the id_token behind an OIDC login bridge (D782). A
26530
29010
  * subject is unique only per issuer, so a link is bound to it.
26531
29011
  */
26532
- issuer: string().optional()
29012
+ issuer: string().optional(),
29013
+ /**
29014
+ * SHA-256 (hex) of the `camstack_sso_state` cookie the IdP `/start` set in
29015
+ * the browser that began this sign-in. `/api/auth/sso/finish` requires the
29016
+ * request to present the matching cookie — a login bridge is useless in
29017
+ * any other browser.
29018
+ */
29019
+ browserBinding: string().optional()
26533
29020
  });
26534
29021
  method(object({
26535
29022
  claims: SsoBridgeClaimsSchema,
@@ -30974,6 +33461,9 @@ var CreateIntegrationInputSchema = object({
30974
33461
  enabled: boolean().optional(),
30975
33462
  info: record(string(), unknown()).optional(),
30976
33463
  settings: record(string(), unknown()).optional(),
33464
+ /** Keys of `settings` the form's schema declares secret (by type) — kept in
33465
+ * the keychain, not the table (D787). */
33466
+ secretKeys: array(string()).optional(),
30977
33467
  skipRestart: boolean().optional()
30978
33468
  });
30979
33469
  var UpdateIntegrationInputSchema = object({
@@ -30997,7 +33487,9 @@ method(_void(), array(IntegrationWithStateSchema)), method(object({ id: string()
30997
33487
  auth: "admin"
30998
33488
  }), method(object({ id: string() }), record(string(), unknown()), { auth: "admin" }), method(object({
30999
33489
  id: string(),
31000
- settings: record(string(), unknown())
33490
+ settings: record(string(), unknown()),
33491
+ /** Keys the form's schema declares secret (by type) — keychain-stored (D787). */
33492
+ secretKeys: array(string()).optional()
31001
33493
  }), object({ success: boolean() }), {
31002
33494
  kind: "mutation",
31003
33495
  auth: "admin"
@@ -36463,16 +38955,6 @@ var ApiKeySummarySchema = object({
36463
38955
  createdAt: number(),
36464
38956
  lastUsedAt: number().optional()
36465
38957
  });
36466
- var CreateApiKeyInputSchema = object({
36467
- label: string(),
36468
- isAdmin: boolean().default(false),
36469
- allowedProviders: union([array(string()), literal("*")]).optional(),
36470
- allowedDevices: record(string(), union([array(string()), literal("*")])).optional()
36471
- });
36472
- var CreateApiKeyResultSchema = object({
36473
- token: string(),
36474
- record: ApiKeySummarySchema
36475
- });
36476
38958
  var ScopedTokenSummarySchema = object({
36477
38959
  id: string(),
36478
38960
  userId: string(),
@@ -36571,17 +39053,10 @@ method(_void(), array(UserSummarySchema), { auth: "admin" }), method(CreateUserI
36571
39053
  }), UserSummarySchema.extend({ passwordHash: string() }).nullable(), {
36572
39054
  kind: "mutation",
36573
39055
  access: "view"
36574
- }), method(_void(), array(ApiKeySummarySchema), { auth: "admin" }), method(CreateApiKeyInputSchema, CreateApiKeyResultSchema, {
36575
- kind: "mutation",
36576
- auth: "admin",
36577
- access: "create"
36578
- }), method(object({ id: string() }), object({ success: literal(true) }), {
39056
+ }), method(_void(), array(ApiKeySummarySchema), { auth: "admin" }), method(object({ id: string() }), object({ success: literal(true) }), {
36579
39057
  kind: "mutation",
36580
39058
  auth: "admin",
36581
39059
  access: "delete"
36582
- }), method(object({ token: string() }), ApiKeySummarySchema.nullable(), {
36583
- kind: "mutation",
36584
- access: "view"
36585
39060
  }), method(CreateScopedTokenInputSchema, CreateScopedTokenResultSchema, {
36586
39061
  kind: "mutation",
36587
39062
  auth: "admin",
@@ -36655,15 +39130,7 @@ method(_void(), array(UserSummarySchema), { auth: "admin" }), method(CreateUserI
36655
39130
  }).nullable(), { access: "view" }), method(object({ userId: string() }), array(ExternalIdentitySchema), { auth: "admin" }), method(ExternalIdentityKeySchema, object({
36656
39131
  userId: string(),
36657
39132
  issuer: string()
36658
- }).nullable(), { auth: "admin" }), method(ExternalIdentityKeySchema.extend({
36659
- userId: string(),
36660
- issuer: string().min(1),
36661
- label: string().optional()
36662
- }), object({ success: literal(true) }), {
36663
- kind: "mutation",
36664
- auth: "admin",
36665
- access: "create"
36666
- }), method(ExternalIdentityKeySchema.extend({ userId: string() }), object({ success: boolean() }), {
39133
+ }).nullable(), { auth: "admin" }), method(ExternalIdentityKeySchema.extend({ userId: string() }), object({ success: boolean() }), {
36667
39134
  kind: "mutation",
36668
39135
  auth: "admin",
36669
39136
  access: "delete"
@@ -37058,6 +39525,451 @@ DeviceType.Camera, method(object({
37058
39525
  detection: array(ZoneRuleSchema).readonly(),
37059
39526
  package: array(ZoneRuleSchema).readonly()
37060
39527
  });
39528
+ /**
39529
+ * `training-provider` — ONE cloud that can run the CamStack trainer.
39530
+ *
39531
+ * A thin, mockable translation layer: it knows how to run a container with a
39532
+ * GPU, move a dataset in, read the job's stdout and hand artefacts back. It
39533
+ * knows nothing about datasets, splits, floors, cost policy or Model Studio —
39534
+ * those are the `training` orchestrator's (D805). Every rule written there
39535
+ * once is what makes a second provider (RunPod, a local NVIDIA node) a new
39536
+ * manifest entry and nothing else.
39537
+ *
39538
+ * Collection, routed by the `addonId` in every single-row input (the `llm` /
39539
+ * `notification-output` posture); `describe` concat-fans across providers.
39540
+ * Every method is `admin`: these spend money.
39541
+ *
39542
+ * Every cloud object a provider creates is tagged with the orchestrator's
39543
+ * `jobKey`, so a retried submit finds the job it already started instead of
39544
+ * starting a second GPU, and `listJobs` can find orphans.
39545
+ *
39546
+ * Bytes never ride a cap field: the dataset arrives as a `ctx.peerBytes`
39547
+ * ticket the producer (pipeline-analytics) minted, and artefacts leave as a
39548
+ * ticket the provider mints (D613).
39549
+ */
39550
+ var TrainingGpuOptionSchema = object({
39551
+ id: string(),
39552
+ label: string(),
39553
+ /** List price, USD per GPU-hour, before any region multiplier. */
39554
+ usdPerHour: number().nonnegative(),
39555
+ vramGb: number().nonnegative()
39556
+ });
39557
+ var TrainingRegionOptionSchema = object({
39558
+ /** `''` = any region (the provider's choice). */
39559
+ id: string(),
39560
+ label: string(),
39561
+ priceMultiplier: number().positive()
39562
+ });
39563
+ /**
39564
+ * The provider's per-account settings, as the orchestrator reads them. They
39565
+ * live in the PROVIDER addon's settings (operator decision 2026-10-08: they
39566
+ * depend on the user's account), never hard-coded in the orchestrator.
39567
+ */
39568
+ var TrainingProviderDefaultsSchema = object({
39569
+ gpuType: string(),
39570
+ region: string(),
39571
+ costCapUsd: number().nonnegative(),
39572
+ maxRuntimeSec: number().int().positive(),
39573
+ /** Hours a FAILED job's cloud dataset is kept for debugging; 0 = delete at once. */
39574
+ failedDatasetGraceHours: number().nonnegative()
39575
+ });
39576
+ var TrainingProviderDescriptorSchema = object({
39577
+ addonId: string(),
39578
+ /** `modal`, `runpod`, `fake`, … */
39579
+ kind: string(),
39580
+ label: string(),
39581
+ gpuTypes: array(TrainingGpuOptionSchema).readonly(),
39582
+ regions: array(TrainingRegionOptionSchema).readonly(),
39583
+ maxDatasetBytes: number().int().positive(),
39584
+ maxRuntimeSec: number().int().positive(),
39585
+ freeTierNote: string().optional(),
39586
+ /** Where the data goes, in one sentence the confirm dialog repeats. */
39587
+ dataResidencyNote: string(),
39588
+ /** Credentials are present — never the values. */
39589
+ configured: boolean(),
39590
+ defaults: TrainingProviderDefaultsSchema
39591
+ });
39592
+ var TrainingCredentialCheckSchema = object({
39593
+ ok: boolean(),
39594
+ /** Workspace / account name, when the provider says. */
39595
+ account: string().optional(),
39596
+ reason: _enum([
39597
+ "missing",
39598
+ "invalid",
39599
+ "forbidden",
39600
+ "network",
39601
+ "quota"
39602
+ ]).optional(),
39603
+ detail: string().optional()
39604
+ });
39605
+ var ProviderJobStateSchema = _enum([
39606
+ "pending",
39607
+ "starting",
39608
+ "running",
39609
+ "succeeded",
39610
+ "failed",
39611
+ "cancelled",
39612
+ "lost"
39613
+ ]);
39614
+ var ProviderJobStatusSchema = object({
39615
+ jobKey: string(),
39616
+ providerJobId: string().optional(),
39617
+ state: ProviderJobStateSchema,
39618
+ startedAt: number().optional(),
39619
+ endedAt: number().optional(),
39620
+ exitCode: number().int().optional(),
39621
+ failureReason: string().optional(),
39622
+ gpuType: string(),
39623
+ region: string().optional(),
39624
+ billedSeconds: number().nonnegative(),
39625
+ costUsd: number().nonnegative(),
39626
+ /** True when `costUsd` is runtime × list price, not a billing answer. */
39627
+ costIsEstimate: boolean(),
39628
+ lastFetchedAt: number()
39629
+ });
39630
+ /**
39631
+ * The trainer the job runs, by SOURCE revision: the provider turns it into an
39632
+ * image its own way (Modal builds the published Dockerfile at that revision;
39633
+ * a registry-pull provider maps it to a tag). Recorded on the job and echoed
39634
+ * in `result.json`.
39635
+ */
39636
+ var TrainerSourceRefSchema = object({
39637
+ /** Hugging Face repo id, e.g. `camstack/camstack-trainer`. */
39638
+ repo: string().min(1),
39639
+ /** A commit sha (never a branch) — the job must be reproducible. */
39640
+ revision: string().regex(/^[0-9a-f]{7,64}$/)
39641
+ });
39642
+ var JobRef = {
39643
+ addonId: string(),
39644
+ jobKey: string().uuid()
39645
+ };
39646
+ var TrainingLogLineSchema = object({
39647
+ ts: number(),
39648
+ text: string()
39649
+ });
39650
+ method(object({}), array(TrainingProviderDescriptorSchema).readonly(), { auth: "admin" }), method(object({ addonId: string() }), TrainingCredentialCheckSchema, {
39651
+ kind: "mutation",
39652
+ auth: "admin",
39653
+ timeoutMs: 3e4
39654
+ }), method(object({
39655
+ addonId: string(),
39656
+ gpuType: string(),
39657
+ region: string(),
39658
+ datasetBytes: number().int().nonnegative(),
39659
+ gpuSecondsLow: number().nonnegative(),
39660
+ gpuSecondsHigh: number().nonnegative()
39661
+ }), object({
39662
+ usdLow: number().nonnegative(),
39663
+ usdHigh: number().nonnegative(),
39664
+ notes: array(string()).readonly()
39665
+ }), { auth: "admin" }), method(object({
39666
+ ...JobRef,
39667
+ ticket: PeerBytesTicketSchema
39668
+ }), object({
39669
+ bytes: number().int().nonnegative(),
39670
+ sha256: string()
39671
+ }), {
39672
+ kind: "mutation",
39673
+ auth: "admin",
39674
+ timeoutMs: 120 * 6e4
39675
+ }), method(object({
39676
+ ...JobRef,
39677
+ trainer: TrainerSourceRefSchema,
39678
+ jobSpecJson: string().min(2).max(64e3),
39679
+ gpuType: string(),
39680
+ region: string(),
39681
+ maxRuntimeSec: number().int().positive()
39682
+ }), ProviderJobStatusSchema, {
39683
+ kind: "mutation",
39684
+ auth: "admin",
39685
+ timeoutMs: 30 * 6e4
39686
+ }), method(object(JobRef), ProviderJobStatusSchema, {
39687
+ auth: "admin",
39688
+ timeoutMs: 6e4
39689
+ }), method(object({
39690
+ ...JobRef,
39691
+ cursor: string().optional(),
39692
+ max: number().int().min(1).max(500)
39693
+ }), object({
39694
+ lines: array(TrainingLogLineSchema).readonly(),
39695
+ cursor: string()
39696
+ }), {
39697
+ auth: "admin",
39698
+ timeoutMs: 6e4
39699
+ }), method(object(JobRef), object({ ok: literal(true) }), {
39700
+ kind: "mutation",
39701
+ auth: "admin",
39702
+ timeoutMs: 6e4
39703
+ }), method(object(JobRef), object({
39704
+ found: boolean(),
39705
+ text: string().optional()
39706
+ }), {
39707
+ kind: "mutation",
39708
+ auth: "admin",
39709
+ timeoutMs: 5 * 6e4
39710
+ }), method(object({
39711
+ ...JobRef,
39712
+ path: _enum(["bundle.tar"])
39713
+ }), object({ ticket: PeerBytesTicketSchema }), {
39714
+ kind: "mutation",
39715
+ auth: "admin",
39716
+ timeoutMs: 5 * 6e4
39717
+ }), method(object(JobRef), object({ deleted: array(string()).readonly() }), {
39718
+ kind: "mutation",
39719
+ auth: "admin",
39720
+ timeoutMs: 5 * 6e4
39721
+ }), method(object({ addonId: string() }), array(ProviderJobStatusSchema).readonly(), {
39722
+ auth: "admin",
39723
+ timeoutMs: 2 * 6e4
39724
+ });
39725
+ /**
39726
+ * `training` — the cloud-training orchestrator (D805). Hub-only singleton,
39727
+ * provided by `addon-training`.
39728
+ *
39729
+ * It owns what every provider must agree on, written once:
39730
+ *
39731
+ * - **Dataset versions.** Taken over from pipeline-analytics (D796): the rows
39732
+ * live here (D808); pipeline-analytics still CUTS a version (it owns the corpus and
39733
+ * the export plan) and reaches this store through the five row methods
39734
+ * below, so the Retrain page and the export did not change.
39735
+ * - **Jobs.** A persisted state machine, a reconcile loop against the
39736
+ * provider, a cost guard, a daily orphan sweep and the retention rules.
39737
+ * - **The return flow.** Verified artefacts → Model Studio
39738
+ * (`custom-model-registry.importModelBundle`) → canary on cameras →
39739
+ * rollback. Nothing is ever registered automatically.
39740
+ *
39741
+ * Every method is `admin`.
39742
+ */
39743
+ /** A version WITH its frame list — what the export and a job read. */
39744
+ var TrainingDatasetVersionRowSchema = RetrainDatasetVersionSchema.omit({ frameCount: true }).extend({ frameIds: array(string()).max(2e4).readonly() });
39745
+ /** A base model a detector job can fine-tune, and the baseline it is judged against. */
39746
+ var TrainingBaseModelSchema = object({
39747
+ modelId: string(),
39748
+ label: string(),
39749
+ weights: string(),
39750
+ imgsz: number().int(),
39751
+ baselineOnnxUrl: string(),
39752
+ baselineFloors: record(string(), number()),
39753
+ /** The base the fleet runs most — the UI's default. */
39754
+ recommended: boolean()
39755
+ });
39756
+ var TrainingPresetSchema = _enum([
39757
+ "quick",
39758
+ "standard",
39759
+ "thorough"
39760
+ ]);
39761
+ var TrainingJobRequestSchema = object({
39762
+ datasetVersionId: string().min(1),
39763
+ /** The `training-provider` addon that runs it. */
39764
+ addonId: string().min(1),
39765
+ gpuType: string().min(1),
39766
+ region: string(),
39767
+ baseModelId: string().min(1),
39768
+ preset: TrainingPresetSchema,
39769
+ /** Freeze the backbone's first N layers; `null` = the preset's choice. */
39770
+ freeze: number().int().nonnegative().nullable(),
39771
+ /** Cameras held out whole for evaluation; `null` = the orchestrator's default. */
39772
+ holdoutCameras: array(number().int()).nullable()
39773
+ });
39774
+ var TrainingSplitPlanSchema = object({
39775
+ holdoutCameras: array(number().int()).readonly(),
39776
+ /** Used when no camera is held out: the last N days of every camera. */
39777
+ holdoutLastDays: number().int().nonnegative(),
39778
+ /** Holdout subjects per class (camera holdout only; `null` = known only after the split). */
39779
+ holdoutSupport: record(string(), number().int()).nullable(),
39780
+ trainSubjects: number().int()
39781
+ });
39782
+ var TrainingRefusalReasonSchema = _enum([
39783
+ "unknown-dataset",
39784
+ "unknown-provider",
39785
+ "provider-not-configured",
39786
+ "unknown-base-model",
39787
+ "unknown-gpu",
39788
+ "dataset-too-large",
39789
+ "no-training-subjects",
39790
+ "job-already-running"
39791
+ ]);
39792
+ var TrainingJobPlanSchema = object({
39793
+ refusal: object({
39794
+ reason: TrainingRefusalReasonSchema,
39795
+ detail: string()
39796
+ }).nullable(),
39797
+ warnings: array(string()).readonly(),
39798
+ split: TrainingSplitPlanSchema.nullable(),
39799
+ estimate: object({
39800
+ datasetBytes: number().int(),
39801
+ uploadMinutesAt20Mbps: number(),
39802
+ gpuSecondsLow: number(),
39803
+ gpuSecondsHigh: number(),
39804
+ usdLow: number(),
39805
+ usdHigh: number(),
39806
+ notes: array(string()).readonly()
39807
+ }).nullable(),
39808
+ /** Pre-filled from the provider's settings; the operator may lower or raise them. */
39809
+ defaults: object({
39810
+ maxCostUsd: number(),
39811
+ maxRuntimeSec: number().int()
39812
+ }).nullable(),
39813
+ /** The sentence the confirm dialog repeats: where the frames go and when they are deleted. */
39814
+ dataNotice: string()
39815
+ });
39816
+ /**
39817
+ * Orchestrator-owned states, persisted. `uploading` covers exporting the
39818
+ * archive (it is streamed, never staged). Terminal: `failed`, `cancelled`,
39819
+ * `lost`, `expired`, `discarded`. `registered` and `canary` are where a
39820
+ * result lives after the operator acted on it.
39821
+ */
39822
+ var TrainingJobStateSchema = _enum([
39823
+ "uploading",
39824
+ "submitted",
39825
+ "starting",
39826
+ "running",
39827
+ "collecting",
39828
+ "ready",
39829
+ "registered",
39830
+ "canary",
39831
+ "failed",
39832
+ "cancelling",
39833
+ "cancelled",
39834
+ "lost",
39835
+ "expired",
39836
+ "discarded"
39837
+ ]);
39838
+ var TrainingFailureReasonSchema = _enum([
39839
+ "cost-cap",
39840
+ "runtime-cap",
39841
+ "upload-failed",
39842
+ "submit-failed",
39843
+ "trainer-failed",
39844
+ "result-invalid",
39845
+ "checksum-mismatch",
39846
+ "fetch-failed",
39847
+ "provider-error",
39848
+ "hub-restart-during-upload"
39849
+ ]);
39850
+ var TrainingProgressPointSchema = object({
39851
+ epoch: number().int(),
39852
+ map50: number().nullable(),
39853
+ map50_95: number().nullable()
39854
+ });
39855
+ var TrainingCanarySchema = object({
39856
+ deviceIds: array(number().int()).readonly(),
39857
+ since: number(),
39858
+ /** Every override the canary replaced, exactly, so rollback restores it. */
39859
+ previous: array(object({
39860
+ deviceId: number().int(),
39861
+ nodeId: string(),
39862
+ deviceKey: string(),
39863
+ patch: object({
39864
+ modelId: string().optional(),
39865
+ settings: record(string(), unknown()).readonly().optional()
39866
+ }).nullable()
39867
+ })).readonly()
39868
+ });
39869
+ var TrainingJobSchema = object({
39870
+ id: string(),
39871
+ idempotencyKey: string(),
39872
+ name: string(),
39873
+ createdAt: number(),
39874
+ updatedAt: number(),
39875
+ state: TrainingJobStateSchema,
39876
+ stage: TrainingStageSchema.nullable(),
39877
+ failure: object({
39878
+ reason: TrainingFailureReasonSchema,
39879
+ stage: string().nullable(),
39880
+ detail: string()
39881
+ }).nullable(),
39882
+ request: TrainingJobRequestSchema,
39883
+ maxCostUsd: number().nonnegative(),
39884
+ maxRuntimeSec: number().int().positive(),
39885
+ trainer: TrainerSourceRefSchema,
39886
+ datasetLayout: RetrainExportLayoutSchema,
39887
+ dataset: object({
39888
+ bytes: number().int(),
39889
+ sha256: string(),
39890
+ uploadedAt: number()
39891
+ }).nullable(),
39892
+ split: TrainingSplitPlanSchema,
39893
+ provider: object({
39894
+ state: ProviderJobStateSchema.nullable(),
39895
+ providerJobId: string().nullable(),
39896
+ startedAt: number().nullable(),
39897
+ endedAt: number().nullable(),
39898
+ billedSeconds: number(),
39899
+ costUsd: number(),
39900
+ costIsEstimate: boolean(),
39901
+ lastPolledAt: number().nullable()
39902
+ }),
39903
+ progress: object({
39904
+ epoch: number().int().nullable(),
39905
+ epochs: number().int().nullable(),
39906
+ etaSec: number().nullable(),
39907
+ series: array(TrainingProgressPointSchema).readonly()
39908
+ }),
39909
+ /** The last lines of the job's output (≤ 200), newest last. Never frame paths. */
39910
+ logTail: array(string()).readonly(),
39911
+ logCursor: string().nullable(),
39912
+ artifacts: object({
39913
+ bundleBytes: number().int(),
39914
+ bundleSha256: string(),
39915
+ fetchedAt: number(),
39916
+ /** When the staged artefacts are deleted from the hub. */
39917
+ expiresAt: number()
39918
+ }).nullable(),
39919
+ /** When the provider-side copy of the frames was deleted; null while it exists. */
39920
+ cloudDatasetDeletedAt: number().nullable(),
39921
+ /** A failed job's dataset is kept until then (the provider's grace), then deleted. */
39922
+ cloudCleanupDueAt: number().nullable(),
39923
+ /** Model ids registered from this job (base, and int8 when kept). */
39924
+ registeredModelIds: array(string()).readonly(),
39925
+ canary: TrainingCanarySchema.nullable()
39926
+ });
39927
+ var IdInput = object({ id: string().min(1) });
39928
+ method(TrainingDatasetVersionRowSchema, object({ stored: boolean() }), {
39929
+ kind: "mutation",
39930
+ auth: "admin"
39931
+ }), 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() }), {
39932
+ kind: "mutation",
39933
+ auth: "admin"
39934
+ }), method(object({}), array(TrainingBaseModelSchema).readonly(), { auth: "admin" }), method(TrainingJobRequestSchema, TrainingJobPlanSchema, {
39935
+ auth: "admin",
39936
+ timeoutMs: 6e4
39937
+ }), method(TrainingJobRequestSchema.extend({
39938
+ name: string().min(1).max(120),
39939
+ maxCostUsd: number().positive(),
39940
+ maxRuntimeSec: number().int().positive(),
39941
+ idempotencyKey: string().min(8).max(80)
39942
+ }), discriminatedUnion("kind", [object({
39943
+ kind: literal("started"),
39944
+ job: TrainingJobSchema
39945
+ }), object({
39946
+ kind: literal("refused"),
39947
+ reason: TrainingRefusalReasonSchema,
39948
+ detail: string()
39949
+ })]), {
39950
+ kind: "mutation",
39951
+ auth: "admin",
39952
+ timeoutMs: 12e4
39953
+ }), method(object({}), array(TrainingJobSchema).readonly(), { auth: "admin" }), method(IdInput, TrainingJobSchema.nullable(), { auth: "admin" }), method(IdInput, TrainingJobSchema, {
39954
+ kind: "mutation",
39955
+ auth: "admin",
39956
+ timeoutMs: 12e4
39957
+ }), method(IdInput, TrainingResultSchema.nullable(), { auth: "admin" }), method(IdInput.extend({ canaryDeviceIds: array(number().int()).readonly() }), TrainingJobSchema, {
39958
+ kind: "mutation",
39959
+ auth: "admin",
39960
+ timeoutMs: 30 * 6e4
39961
+ }), method(IdInput.extend({ deviceIds: array(number().int()).min(1).readonly() }), TrainingJobSchema, {
39962
+ kind: "mutation",
39963
+ auth: "admin",
39964
+ timeoutMs: 12e4
39965
+ }), method(IdInput, TrainingJobSchema, {
39966
+ kind: "mutation",
39967
+ auth: "admin",
39968
+ timeoutMs: 12e4
39969
+ }), method(IdInput, TrainingJobSchema, {
39970
+ kind: "mutation",
39971
+ auth: "admin"
39972
+ });
37061
39973
  SOURCE_CAPS.filter((cap) => cap !== "switch" && cap !== "motion");
37062
39974
  Object.freeze({
37063
39975
  person: .5,
@@ -37681,6 +40593,12 @@ Object.freeze({
37681
40593
  addonId: null,
37682
40594
  access: "create"
37683
40595
  },
40596
+ "backup.checkBackupKey": {
40597
+ capName: "backup",
40598
+ capScope: "system",
40599
+ addonId: null,
40600
+ access: "create"
40601
+ },
37684
40602
  "backup.delete": {
37685
40603
  capName: "backup",
37686
40604
  capScope: "system",
@@ -37693,6 +40611,18 @@ Object.freeze({
37693
40611
  addonId: null,
37694
40612
  access: "delete"
37695
40613
  },
40614
+ "backup.disableEncryption": {
40615
+ capName: "backup",
40616
+ capScope: "system",
40617
+ addonId: null,
40618
+ access: "create"
40619
+ },
40620
+ "backup.getEncryption": {
40621
+ capName: "backup",
40622
+ capScope: "system",
40623
+ addonId: null,
40624
+ access: "view"
40625
+ },
37696
40626
  "backup.getEntries": {
37697
40627
  capName: "backup",
37698
40628
  capScope: "system",
@@ -37747,6 +40677,12 @@ Object.freeze({
37747
40677
  addonId: null,
37748
40678
  access: "create"
37749
40679
  },
40680
+ "backup.setupEncryption": {
40681
+ capName: "backup",
40682
+ capScope: "system",
40683
+ addonId: null,
40684
+ access: "create"
40685
+ },
37750
40686
  "backup.trigger": {
37751
40687
  capName: "backup",
37752
40688
  capScope: "system",
@@ -38299,6 +41235,12 @@ Object.freeze({
38299
41235
  addonId: null,
38300
41236
  access: "create"
38301
41237
  },
41238
+ "customModelRegistry.importModelBundle": {
41239
+ capName: "custom-model-registry",
41240
+ capScope: "system",
41241
+ addonId: null,
41242
+ access: "create"
41243
+ },
38302
41244
  "customModelRegistry.listModels": {
38303
41245
  capName: "custom-model-registry",
38304
41246
  capScope: "system",
@@ -39709,6 +42651,108 @@ Object.freeze({
39709
42651
  addonId: null,
39710
42652
  access: "create"
39711
42653
  },
42654
+ "keychain.delete": {
42655
+ capName: "keychain",
42656
+ capScope: "system",
42657
+ addonId: null,
42658
+ access: "delete"
42659
+ },
42660
+ "keychain.getState": {
42661
+ capName: "keychain",
42662
+ capScope: "system",
42663
+ addonId: null,
42664
+ access: "view"
42665
+ },
42666
+ "keychain.listMeta": {
42667
+ capName: "keychain",
42668
+ capScope: "system",
42669
+ addonId: null,
42670
+ access: "view"
42671
+ },
42672
+ "keychain.put": {
42673
+ capName: "keychain",
42674
+ capScope: "system",
42675
+ addonId: null,
42676
+ access: "create"
42677
+ },
42678
+ "keychain.resolve": {
42679
+ capName: "keychain",
42680
+ capScope: "system",
42681
+ addonId: null,
42682
+ access: "view"
42683
+ },
42684
+ "keychainAdmin.acknowledgeReset": {
42685
+ capName: "keychain-admin",
42686
+ capScope: "system",
42687
+ addonId: null,
42688
+ access: "create"
42689
+ },
42690
+ "keychainAdmin.deleteOrphans": {
42691
+ capName: "keychain-admin",
42692
+ capScope: "system",
42693
+ addonId: null,
42694
+ access: "delete"
42695
+ },
42696
+ "keychainAdmin.downloadRecoveryKey": {
42697
+ capName: "keychain-admin",
42698
+ capScope: "system",
42699
+ addonId: null,
42700
+ access: "create"
42701
+ },
42702
+ "keychainAdmin.listAudit": {
42703
+ capName: "keychain-admin",
42704
+ capScope: "system",
42705
+ addonId: null,
42706
+ access: "view"
42707
+ },
42708
+ "keychainAdmin.listSecrets": {
42709
+ capName: "keychain-admin",
42710
+ capScope: "system",
42711
+ addonId: null,
42712
+ access: "view"
42713
+ },
42714
+ "keychainAdmin.purgeRetiredKeys": {
42715
+ capName: "keychain-admin",
42716
+ capScope: "system",
42717
+ addonId: null,
42718
+ access: "delete"
42719
+ },
42720
+ "keychainAdmin.resetKeychain": {
42721
+ capName: "keychain-admin",
42722
+ capScope: "system",
42723
+ addonId: null,
42724
+ access: "delete"
42725
+ },
42726
+ "keychainAdmin.resetReport": {
42727
+ capName: "keychain-admin",
42728
+ capScope: "system",
42729
+ addonId: null,
42730
+ access: "delete"
42731
+ },
42732
+ "keychainAdmin.reveal": {
42733
+ capName: "keychain-admin",
42734
+ capScope: "system",
42735
+ addonId: null,
42736
+ access: "create"
42737
+ },
42738
+ "keychainAdmin.rotateMasterKey": {
42739
+ capName: "keychain-admin",
42740
+ capScope: "system",
42741
+ addonId: null,
42742
+ access: "create"
42743
+ },
42744
+ "keychainAdmin.setSystemSecret": {
42745
+ capName: "keychain-admin",
42746
+ capScope: "system",
42747
+ addonId: null,
42748
+ access: "create"
42749
+ },
42750
+ "keychainAdmin.status": {
42751
+ capName: "keychain-admin",
42752
+ capScope: "system",
42753
+ addonId: null,
42754
+ access: "view"
42755
+ },
39712
42756
  "lawnMowerControl.dock": {
39713
42757
  capName: "lawn-mower-control",
39714
42758
  capScope: "device",
@@ -41083,6 +44127,18 @@ Object.freeze({
41083
44127
  addonId: null,
41084
44128
  access: "create"
41085
44129
  },
44130
+ "pipelineAnalytics.addRetrainFrameFromRecording": {
44131
+ capName: "pipeline-analytics",
44132
+ capScope: "device",
44133
+ addonId: null,
44134
+ access: "create"
44135
+ },
44136
+ "pipelineAnalytics.addRetrainFramesToCollection": {
44137
+ capName: "pipeline-analytics",
44138
+ capScope: "device",
44139
+ addonId: null,
44140
+ access: "create"
44141
+ },
41086
44142
  "pipelineAnalytics.applyDeviceSettingsPatch": {
41087
44143
  capName: "pipeline-analytics",
41088
44144
  capScope: "device",
@@ -41131,12 +44187,36 @@ Object.freeze({
41131
44187
  addonId: null,
41132
44188
  access: "view"
41133
44189
  },
44190
+ "pipelineAnalytics.createRetrainCollection": {
44191
+ capName: "pipeline-analytics",
44192
+ capScope: "device",
44193
+ addonId: null,
44194
+ access: "create"
44195
+ },
44196
+ "pipelineAnalytics.createRetrainDatasetVersion": {
44197
+ capName: "pipeline-analytics",
44198
+ capScope: "device",
44199
+ addonId: null,
44200
+ access: "create"
44201
+ },
41134
44202
  "pipelineAnalytics.deleteDeviceEvents": {
41135
44203
  capName: "pipeline-analytics",
41136
44204
  capScope: "device",
41137
44205
  addonId: null,
41138
44206
  access: "delete"
41139
44207
  },
44208
+ "pipelineAnalytics.deleteRetrainCollection": {
44209
+ capName: "pipeline-analytics",
44210
+ capScope: "device",
44211
+ addonId: null,
44212
+ access: "delete"
44213
+ },
44214
+ "pipelineAnalytics.deleteRetrainDatasetVersion": {
44215
+ capName: "pipeline-analytics",
44216
+ capScope: "device",
44217
+ addonId: null,
44218
+ access: "delete"
44219
+ },
41140
44220
  "pipelineAnalytics.deleteTracks": {
41141
44221
  capName: "pipeline-analytics",
41142
44222
  capScope: "device",
@@ -41341,6 +44421,30 @@ Object.freeze({
41341
44421
  addonId: null,
41342
44422
  access: "view"
41343
44423
  },
44424
+ "pipelineAnalytics.listRetrainAssistProfiles": {
44425
+ capName: "pipeline-analytics",
44426
+ capScope: "device",
44427
+ addonId: null,
44428
+ access: "view"
44429
+ },
44430
+ "pipelineAnalytics.listRetrainCollectionFrames": {
44431
+ capName: "pipeline-analytics",
44432
+ capScope: "device",
44433
+ addonId: null,
44434
+ access: "view"
44435
+ },
44436
+ "pipelineAnalytics.listRetrainCollections": {
44437
+ capName: "pipeline-analytics",
44438
+ capScope: "device",
44439
+ addonId: null,
44440
+ access: "view"
44441
+ },
44442
+ "pipelineAnalytics.listRetrainDatasetVersions": {
44443
+ capName: "pipeline-analytics",
44444
+ capScope: "device",
44445
+ addonId: null,
44446
+ access: "view"
44447
+ },
41344
44448
  "pipelineAnalytics.listRetrainFrames": {
41345
44449
  capName: "pipeline-analytics",
41346
44450
  capScope: "device",
@@ -41371,6 +44475,12 @@ Object.freeze({
41371
44475
  addonId: null,
41372
44476
  access: "view"
41373
44477
  },
44478
+ "pipelineAnalytics.offerRetrainArchive": {
44479
+ capName: "pipeline-analytics",
44480
+ capScope: "device",
44481
+ addonId: null,
44482
+ access: "create"
44483
+ },
41374
44484
  "pipelineAnalytics.ownersWithMedia": {
41375
44485
  capName: "pipeline-analytics",
41376
44486
  capScope: "device",
@@ -41383,12 +44493,24 @@ Object.freeze({
41383
44493
  addonId: null,
41384
44494
  access: "create"
41385
44495
  },
44496
+ "pipelineAnalytics.previewRetrainDataset": {
44497
+ capName: "pipeline-analytics",
44498
+ capScope: "device",
44499
+ addonId: null,
44500
+ access: "view"
44501
+ },
41386
44502
  "pipelineAnalytics.proposeRetrainAnnotations": {
41387
44503
  capName: "pipeline-analytics",
41388
44504
  capScope: "device",
41389
44505
  addonId: null,
41390
44506
  access: "create"
41391
44507
  },
44508
+ "pipelineAnalytics.proposeRetrainAnnotationsWithLlm": {
44509
+ capName: "pipeline-analytics",
44510
+ capScope: "device",
44511
+ addonId: null,
44512
+ access: "create"
44513
+ },
41392
44514
  "pipelineAnalytics.pruneEvents": {
41393
44515
  capName: "pipeline-analytics",
41394
44516
  capScope: "device",
@@ -41443,6 +44565,18 @@ Object.freeze({
41443
44565
  addonId: null,
41444
44566
  access: "create"
41445
44567
  },
44568
+ "pipelineAnalytics.removeRetrainFrameFromCollection": {
44569
+ capName: "pipeline-analytics",
44570
+ capScope: "device",
44571
+ addonId: null,
44572
+ access: "delete"
44573
+ },
44574
+ "pipelineAnalytics.renameRetrainCollection": {
44575
+ capName: "pipeline-analytics",
44576
+ capScope: "device",
44577
+ addonId: null,
44578
+ access: "create"
44579
+ },
41446
44580
  "pipelineAnalytics.restageRetrainTrack": {
41447
44581
  capName: "pipeline-analytics",
41448
44582
  capScope: "device",
@@ -41503,6 +44637,12 @@ Object.freeze({
41503
44637
  addonId: null,
41504
44638
  access: "create"
41505
44639
  },
44640
+ "pipelineAnalytics.verifyRetrainDatasetVersion": {
44641
+ capName: "pipeline-analytics",
44642
+ capScope: "device",
44643
+ addonId: null,
44644
+ access: "view"
44645
+ },
41506
44646
  "pipelineAnalytics.wipeAllAnalytics": {
41507
44647
  capName: "pipeline-analytics",
41508
44648
  capScope: "device",
@@ -41731,6 +44871,12 @@ Object.freeze({
41731
44871
  addonId: null,
41732
44872
  access: "view"
41733
44873
  },
44874
+ "pipelineOrchestrator.abortNodeBenchmark": {
44875
+ capName: "pipeline-orchestrator",
44876
+ capScope: "system",
44877
+ addonId: null,
44878
+ access: "create"
44879
+ },
41734
44880
  "pipelineOrchestrator.applyAutoTune": {
41735
44881
  capName: "pipeline-orchestrator",
41736
44882
  capScope: "system",
@@ -41755,6 +44901,12 @@ Object.freeze({
41755
44901
  addonId: null,
41756
44902
  access: "create"
41757
44903
  },
44904
+ "pipelineOrchestrator.deleteNodeBenchmarkResult": {
44905
+ capName: "pipeline-orchestrator",
44906
+ capScope: "system",
44907
+ addonId: null,
44908
+ access: "delete"
44909
+ },
41758
44910
  "pipelineOrchestrator.getAgentLoad": {
41759
44911
  capName: "pipeline-orchestrator",
41760
44912
  capScope: "system",
@@ -41863,6 +45015,24 @@ Object.freeze({
41863
45015
  addonId: null,
41864
45016
  access: "view"
41865
45017
  },
45018
+ "pipelineOrchestrator.getNodeBenchmarkCandidates": {
45019
+ capName: "pipeline-orchestrator",
45020
+ capScope: "system",
45021
+ addonId: null,
45022
+ access: "view"
45023
+ },
45024
+ "pipelineOrchestrator.getNodeBenchmarkPreflight": {
45025
+ capName: "pipeline-orchestrator",
45026
+ capScope: "system",
45027
+ addonId: null,
45028
+ access: "view"
45029
+ },
45030
+ "pipelineOrchestrator.getNodeBenchmarkStatus": {
45031
+ capName: "pipeline-orchestrator",
45032
+ capScope: "system",
45033
+ addonId: null,
45034
+ access: "view"
45035
+ },
41866
45036
  "pipelineOrchestrator.getNodeInferenceDevices": {
41867
45037
  capName: "pipeline-orchestrator",
41868
45038
  capScope: "system",
@@ -41905,6 +45075,12 @@ Object.freeze({
41905
45075
  addonId: null,
41906
45076
  access: "view"
41907
45077
  },
45078
+ "pipelineOrchestrator.listNodeBenchmarkResults": {
45079
+ capName: "pipeline-orchestrator",
45080
+ capScope: "system",
45081
+ addonId: null,
45082
+ access: "view"
45083
+ },
41908
45084
  "pipelineOrchestrator.pauseForStorageMigration": {
41909
45085
  capName: "pipeline-orchestrator",
41910
45086
  capScope: "system",
@@ -42049,6 +45225,12 @@ Object.freeze({
42049
45225
  addonId: null,
42050
45226
  access: "create"
42051
45227
  },
45228
+ "pipelineOrchestrator.startNodeBenchmark": {
45229
+ capName: "pipeline-orchestrator",
45230
+ capScope: "system",
45231
+ addonId: null,
45232
+ access: "create"
45233
+ },
42052
45234
  "pipelineOrchestrator.suggestShares": {
42053
45235
  capName: "pipeline-orchestrator",
42054
45236
  capScope: "system",
@@ -42067,6 +45249,12 @@ Object.freeze({
42067
45249
  addonId: null,
42068
45250
  access: "create"
42069
45251
  },
45252
+ "pipelineRunner.abortNodeBench": {
45253
+ capName: "pipeline-runner",
45254
+ capScope: "system",
45255
+ addonId: null,
45256
+ access: "create"
45257
+ },
42070
45258
  "pipelineRunner.attachCamera": {
42071
45259
  capName: "pipeline-runner",
42072
45260
  capScope: "system",
@@ -42115,6 +45303,12 @@ Object.freeze({
42115
45303
  addonId: null,
42116
45304
  access: "view"
42117
45305
  },
45306
+ "pipelineRunner.getNodeBenchStatus": {
45307
+ capName: "pipeline-runner",
45308
+ capScope: "system",
45309
+ addonId: null,
45310
+ access: "view"
45311
+ },
42118
45312
  "pipelineRunner.getParkedTrackFrame": {
42119
45313
  capName: "pipeline-runner",
42120
45314
  capScope: "system",
@@ -42157,6 +45351,12 @@ Object.freeze({
42157
45351
  addonId: null,
42158
45352
  access: "create"
42159
45353
  },
45354
+ "pipelineRunner.startNodeBench": {
45355
+ capName: "pipeline-runner",
45356
+ capScope: "system",
45357
+ addonId: null,
45358
+ access: "create"
45359
+ },
42160
45360
  "plateGallery.assignPlate": {
42161
45361
  capName: "plate-gallery",
42162
45362
  capScope: "system",
@@ -43819,6 +47019,174 @@ Object.freeze({
43819
47019
  addonId: null,
43820
47020
  access: "view"
43821
47021
  },
47022
+ "training.canaryResult": {
47023
+ capName: "training",
47024
+ capScope: "system",
47025
+ addonId: null,
47026
+ access: "create"
47027
+ },
47028
+ "training.cancelJob": {
47029
+ capName: "training",
47030
+ capScope: "system",
47031
+ addonId: null,
47032
+ access: "create"
47033
+ },
47034
+ "training.discardResult": {
47035
+ capName: "training",
47036
+ capScope: "system",
47037
+ addonId: null,
47038
+ access: "create"
47039
+ },
47040
+ "training.findDatasetVersionIdByName": {
47041
+ capName: "training",
47042
+ capScope: "system",
47043
+ addonId: null,
47044
+ access: "view"
47045
+ },
47046
+ "training.getDatasetVersion": {
47047
+ capName: "training",
47048
+ capScope: "system",
47049
+ addonId: null,
47050
+ access: "view"
47051
+ },
47052
+ "training.getJob": {
47053
+ capName: "training",
47054
+ capScope: "system",
47055
+ addonId: null,
47056
+ access: "view"
47057
+ },
47058
+ "training.getJobResult": {
47059
+ capName: "training",
47060
+ capScope: "system",
47061
+ addonId: null,
47062
+ access: "view"
47063
+ },
47064
+ "training.listBaseModels": {
47065
+ capName: "training",
47066
+ capScope: "system",
47067
+ addonId: null,
47068
+ access: "view"
47069
+ },
47070
+ "training.listDatasetVersions": {
47071
+ capName: "training",
47072
+ capScope: "system",
47073
+ addonId: null,
47074
+ access: "view"
47075
+ },
47076
+ "training.listJobs": {
47077
+ capName: "training",
47078
+ capScope: "system",
47079
+ addonId: null,
47080
+ access: "view"
47081
+ },
47082
+ "training.planJob": {
47083
+ capName: "training",
47084
+ capScope: "system",
47085
+ addonId: null,
47086
+ access: "view"
47087
+ },
47088
+ "training.putDatasetVersion": {
47089
+ capName: "training",
47090
+ capScope: "system",
47091
+ addonId: null,
47092
+ access: "create"
47093
+ },
47094
+ "training.registerResult": {
47095
+ capName: "training",
47096
+ capScope: "system",
47097
+ addonId: null,
47098
+ access: "create"
47099
+ },
47100
+ "training.removeDatasetVersion": {
47101
+ capName: "training",
47102
+ capScope: "system",
47103
+ addonId: null,
47104
+ access: "delete"
47105
+ },
47106
+ "training.rollbackCanary": {
47107
+ capName: "training",
47108
+ capScope: "system",
47109
+ addonId: null,
47110
+ access: "create"
47111
+ },
47112
+ "training.startJob": {
47113
+ capName: "training",
47114
+ capScope: "system",
47115
+ addonId: null,
47116
+ access: "create"
47117
+ },
47118
+ "trainingProvider.cancelJob": {
47119
+ capName: "training-provider",
47120
+ capScope: "system",
47121
+ addonId: null,
47122
+ access: "create"
47123
+ },
47124
+ "trainingProvider.cleanupJob": {
47125
+ capName: "training-provider",
47126
+ capScope: "system",
47127
+ addonId: null,
47128
+ access: "create"
47129
+ },
47130
+ "trainingProvider.describe": {
47131
+ capName: "training-provider",
47132
+ capScope: "system",
47133
+ addonId: null,
47134
+ access: "view"
47135
+ },
47136
+ "trainingProvider.estimateJob": {
47137
+ capName: "training-provider",
47138
+ capScope: "system",
47139
+ addonId: null,
47140
+ access: "view"
47141
+ },
47142
+ "trainingProvider.getJob": {
47143
+ capName: "training-provider",
47144
+ capScope: "system",
47145
+ addonId: null,
47146
+ access: "view"
47147
+ },
47148
+ "trainingProvider.listJobEvents": {
47149
+ capName: "training-provider",
47150
+ capScope: "system",
47151
+ addonId: null,
47152
+ access: "view"
47153
+ },
47154
+ "trainingProvider.listJobs": {
47155
+ capName: "training-provider",
47156
+ capScope: "system",
47157
+ addonId: null,
47158
+ access: "view"
47159
+ },
47160
+ "trainingProvider.offerArtifact": {
47161
+ capName: "training-provider",
47162
+ capScope: "system",
47163
+ addonId: null,
47164
+ access: "create"
47165
+ },
47166
+ "trainingProvider.readResult": {
47167
+ capName: "training-provider",
47168
+ capScope: "system",
47169
+ addonId: null,
47170
+ access: "create"
47171
+ },
47172
+ "trainingProvider.submitJob": {
47173
+ capName: "training-provider",
47174
+ capScope: "system",
47175
+ addonId: null,
47176
+ access: "create"
47177
+ },
47178
+ "trainingProvider.uploadDataset": {
47179
+ capName: "training-provider",
47180
+ capScope: "system",
47181
+ addonId: null,
47182
+ access: "create"
47183
+ },
47184
+ "trainingProvider.validateCredentials": {
47185
+ capName: "training-provider",
47186
+ capScope: "system",
47187
+ addonId: null,
47188
+ access: "create"
47189
+ },
43822
47190
  "turnProvider.getTurnServers": {
43823
47191
  capName: "turn-provider",
43824
47192
  capScope: "system",
@@ -43843,12 +47211,6 @@ Object.freeze({
43843
47211
  addonId: null,
43844
47212
  access: "create"
43845
47213
  },
43846
- "userManagement.createApiKey": {
43847
- capName: "user-management",
43848
- capScope: "system",
43849
- addonId: null,
43850
- access: "create"
43851
- },
43852
47214
  "userManagement.createScopedToken": {
43853
47215
  capName: "user-management",
43854
47216
  capScope: "system",
@@ -43885,12 +47247,6 @@ Object.freeze({
43885
47247
  addonId: null,
43886
47248
  access: "view"
43887
47249
  },
43888
- "userManagement.linkExternalIdentity": {
43889
- capName: "user-management",
43890
- capScope: "system",
43891
- addonId: null,
43892
- access: "create"
43893
- },
43894
47250
  "userManagement.listApiKeys": {
43895
47251
  capName: "user-management",
43896
47252
  capScope: "system",
@@ -43993,12 +47349,6 @@ Object.freeze({
43993
47349
  addonId: null,
43994
47350
  access: "create"
43995
47351
  },
43996
- "userManagement.validateApiKey": {
43997
- capName: "user-management",
43998
- capScope: "system",
43999
- addonId: null,
44000
- access: "view"
44001
- },
44002
47352
  "userManagement.validateCredentials": {
44003
47353
  capName: "user-management",
44004
47354
  capScope: "system",
@@ -47086,6 +50436,11 @@ Object.freeze({
47086
50436
  form: "single",
47087
50437
  optional: false
47088
50438
  }],
50439
+ "pipelineAnalytics.addRetrainFrameFromRecording": [{
50440
+ name: "deviceId",
50441
+ form: "single",
50442
+ optional: false
50443
+ }],
47089
50444
  "pipelineAnalytics.applyDeviceSettingsPatch": [{
47090
50445
  name: "deviceId",
47091
50446
  form: "single",
@@ -47276,6 +50631,11 @@ Object.freeze({
47276
50631
  form: "single",
47277
50632
  optional: false
47278
50633
  }],
50634
+ "pipelineAnalytics.proposeRetrainAnnotationsWithLlm": [{
50635
+ name: "deviceId",
50636
+ form: "single",
50637
+ optional: false
50638
+ }],
47279
50639
  "pipelineAnalytics.pruneEventsBefore": [{
47280
50640
  name: "deviceId",
47281
50641
  form: "single",
@@ -48102,6 +51462,11 @@ Object.freeze({
48102
51462
  form: "single",
48103
51463
  optional: false
48104
51464
  }],
51465
+ "training.canaryResult": [{
51466
+ name: "deviceIds",
51467
+ form: "array",
51468
+ optional: false
51469
+ }],
48105
51470
  "update.getStatus": [{
48106
51471
  name: "deviceId",
48107
51472
  form: "single",