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