@camstack/addon-tailscale 1.2.119 → 1.2.121

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.
@@ -1,7 +1,7 @@
1
1
  import * as fs from "node:fs/promises";
2
2
  import * as os from "node:os";
3
3
  import * as path from "node:path";
4
- //#region ../types/dist/event-category-B_0XEcLF.mjs
4
+ //#region ../types/dist/event-category-DaIZi00R.mjs
5
5
  var EventCategory = /* @__PURE__ */ function(EventCategory) {
6
6
  EventCategory["SystemBoot"] = "system.boot";
7
7
  EventCategory["SystemAddonsReady"] = "system.addons-ready";
@@ -80,6 +80,13 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
80
80
  */
81
81
  EventCategory["AddonLoadFailed"] = "addon.load-failed";
82
82
  /**
83
+ * A keychain value was stored or removed (D787). Carries the ref, its
84
+ * owner and the new version — NEVER the value. A process holding the ref
85
+ * drops its cached copy and the owning `BaseAddon` re-resolves its config.
86
+ * Telemetry (D8): a process that misses it still revalidates by version.
87
+ */
88
+ EventCategory["KeychainChanged"] = "keychain.changed";
89
+ /**
83
90
  * Addon recovered from a previous failure. Emitted when an addon
84
91
  * transitions from `failed` back to `healthy` (typically via the
85
92
  * monitor's auto-retry loop, or after manual `addons.retryLoad`).
@@ -5372,7 +5379,7 @@ var ZodIssueCode = {
5372
5379
  var ZodFirstPartyTypeKind;
5373
5380
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
5374
5381
  //#endregion
5375
- //#region ../types/dist/sleep-B0JG7-_F.mjs
5382
+ //#region ../types/dist/sleep-r3RWkGVx.mjs
5376
5383
  /**
5377
5384
  * The audio chunk plane's byte format, and the ONE expansion from a coded
5378
5385
  * window to float samples (D455).
@@ -5451,6 +5458,97 @@ function buildAlawTable() {
5451
5458
  }
5452
5459
  buildUlawTable();
5453
5460
  buildAlawTable();
5461
+ /** Is this field's stored value a credential? */
5462
+ function isSecretConfigField(field) {
5463
+ if (field.type === "password") return true;
5464
+ return "secret" in field && field.secret === true;
5465
+ }
5466
+ /**
5467
+ * Is this field's value stored in the KEYCHAIN (D787)? Every secret field is,
5468
+ * by its TYPE, unless it opts out with `storage: 'inline'` — never by its name.
5469
+ */
5470
+ function isKeychainStoredField(field) {
5471
+ if (!isSecretConfigField(field)) return false;
5472
+ if (field.type === "textarea" && field.isJson === true) return false;
5473
+ return !("storage" in field && field.storage === "inline");
5474
+ }
5475
+ /**
5476
+ * What a settings blob holds where a secret used to be.
5477
+ *
5478
+ * A keychain-stored field never holds its value. It holds a self-describing
5479
+ * MARKER, `{"$secret":"secret://…","v":1}` — an object, never a string, so no
5480
+ * code can mistake it for a credential and no form can send it to a camera as
5481
+ * a password. The empty state is `null` / absent, never `''`.
5482
+ *
5483
+ * The same shapes travel to and from the admin UI:
5484
+ *
5485
+ * - read: `hydrateSchema` hands a secret field a {@link SecretFieldView}
5486
+ * (`{ $secret, v, set: true }`) or `null` — the browser learns whether a
5487
+ * value is set, never the value.
5488
+ * - write: an untouched field submits the view back unchanged (KEEP); a typed
5489
+ * value is a plain non-empty string (CHANGE); the Clear button submits
5490
+ * {@link SECRET_CLEAR} (CLEAR). `''`, `null` and the legacy redaction tokens
5491
+ * are KEEP — an empty string is what a defaults-fallback pushes back, and
5492
+ * treating it as "clear" is how a save destroyed a stored credential before.
5493
+ *
5494
+ * Pure and browser-safe.
5495
+ */
5496
+ var SECRET_CLEAR = { $secretClear: true };
5497
+ /** The `'***'` token D634 redaction writes for non-admins. */
5498
+ var LEGACY_DEVICE_REDACTION = "***";
5499
+ function isRecord$2(value) {
5500
+ return typeof value === "object" && value !== null && !Array.isArray(value);
5501
+ }
5502
+ function makeSecretMarker(ref) {
5503
+ return {
5504
+ $secret: ref,
5505
+ v: 1
5506
+ };
5507
+ }
5508
+ /** A stored marker: an object whose `$secret` is a non-empty string. */
5509
+ function isSecretMarker(value) {
5510
+ if (!isRecord$2(value)) return false;
5511
+ const ref = value["$secret"];
5512
+ return typeof ref === "string" && ref.length > 0;
5513
+ }
5514
+ function isSecretClear(value) {
5515
+ return isRecord$2(value) && value["$secretClear"] === true;
5516
+ }
5517
+ /**
5518
+ * The UI view of a stored secret field value: a marker becomes "set", inline
5519
+ * plaintext becomes "set (inline)", nothing becomes `null`. A value never
5520
+ * survives this function.
5521
+ */
5522
+ function toSecretFieldView(stored) {
5523
+ if (isSecretMarker(stored)) return {
5524
+ $secret: stored.$secret,
5525
+ v: 1,
5526
+ set: true
5527
+ };
5528
+ if (typeof stored === "string" && stored.length > 0) return {
5529
+ $secret: null,
5530
+ v: 1,
5531
+ set: true,
5532
+ inline: true
5533
+ };
5534
+ return null;
5535
+ }
5536
+ /**
5537
+ * Classify an incoming value for a secret path. Only a non-empty string that is
5538
+ * not a redaction token sets a value; only {@link SECRET_CLEAR} clears.
5539
+ * Everything else — a marker (ours or anyone's), a UI view, `''`, `null`,
5540
+ * `undefined`, a redaction token, a non-string — keeps what is stored.
5541
+ */
5542
+ function classifySecretWrite(incoming) {
5543
+ if (isSecretClear(incoming)) return { kind: "clear" };
5544
+ if (typeof incoming !== "string") return { kind: "keep" };
5545
+ if (incoming.length === 0) return { kind: "keep" };
5546
+ if (incoming === "__camstack_redacted__" || incoming === LEGACY_DEVICE_REDACTION) return { kind: "keep" };
5547
+ return {
5548
+ kind: "set",
5549
+ value: incoming
5550
+ };
5551
+ }
5454
5552
  Object.fromEntries([
5455
5553
  {
5456
5554
  id: "overview",
@@ -5622,33 +5720,19 @@ Object.fromEntries([
5622
5720
  function isValuelessField(field) {
5623
5721
  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";
5624
5722
  }
5625
- /**
5626
- * Merge a `ConfigUISchema` with a raw `values` record into a
5627
- * `ConfigUISchemaWithValues`. Used by every `get*Settings` backend endpoint
5628
- * before returning to the admin UI. Groups are walked recursively.
5629
- *
5630
- * For each leaf field:
5631
- * - structural fields (`separator`, `info`, `button`) pass through unchanged
5632
- * - other fields get `value = values[key] ?? field.default ?? null`
5633
- *
5634
- * Unknown keys in `values` (keys not declared in the schema) are silently
5635
- * ignored — they don't contribute to the output. Missing keys fall back to
5636
- * the schema default or `null`. This mirrors the old backend behaviour where
5637
- * `FormBuilder` rendered `values[key] ?? field.default`.
5638
- */
5639
- function hydrateSchema(schema, values) {
5723
+ function hydrateSchema(schema, values, options = {}) {
5640
5724
  return {
5641
5725
  ...schema.tabs ? { tabs: [...schema.tabs] } : {},
5642
5726
  sections: schema.sections.map((section) => ({
5643
5727
  ...section,
5644
- fields: section.fields.map((field) => hydrateField(field, values))
5728
+ fields: section.fields.map((field) => hydrateField(field, values, options))
5645
5729
  }))
5646
5730
  };
5647
5731
  }
5648
- function hydrateField(field, values) {
5732
+ function hydrateField(field, values, options) {
5649
5733
  if (isValuelessField(field)) return field;
5650
5734
  if (field.type === "group") {
5651
- const hydratedChildren = field.fields.map((child) => hydrateField(child, values));
5735
+ const hydratedChildren = field.fields.map((child) => hydrateField(child, values, options));
5652
5736
  return {
5653
5737
  ...field,
5654
5738
  fields: hydratedChildren
@@ -5657,7 +5741,7 @@ function hydrateField(field, values) {
5657
5741
  if (field.type === "sub-tabs") {
5658
5742
  const hydratedTabs = field.tabs.map((tab) => ({
5659
5743
  ...tab,
5660
- fields: tab.fields.map((child) => hydrateField(child, values))
5744
+ fields: tab.fields.map((child) => hydrateField(child, values, options))
5661
5745
  }));
5662
5746
  return {
5663
5747
  ...field,
@@ -5667,6 +5751,33 @@ function hydrateField(field, values) {
5667
5751
  const key = field.key;
5668
5752
  const storedValue = Object.prototype.hasOwnProperty.call(values, key) ? values[key] : void 0;
5669
5753
  const defaultValue = field.default;
5754
+ const asView = (v) => isSecretMarker(v) || options.inlineSecretsAsViews === true && v !== void 0;
5755
+ if (isKeychainStoredField(field) && asView(storedValue)) return {
5756
+ ...field,
5757
+ value: toSecretFieldView(storedValue)
5758
+ };
5759
+ if (isKeychainStoredField(field) && options.inlineSecretsAsViews === true) return {
5760
+ ...field,
5761
+ value: null
5762
+ };
5763
+ if (field.type === "editable-array" && Array.isArray(storedValue)) {
5764
+ const secretItemKeys = field.itemFields.filter((item) => "key" in item && isKeychainStoredField(item)).map((item) => "key" in item ? item.key : "");
5765
+ if (secretItemKeys.length > 0) {
5766
+ const rows = storedValue.map((row) => {
5767
+ if (row === null || typeof row !== "object" || Array.isArray(row)) return row;
5768
+ const out = { ...row };
5769
+ for (const k of secretItemKeys) {
5770
+ const v = Reflect.get(row, k);
5771
+ if (asView(v)) out[k] = toSecretFieldView(v);
5772
+ }
5773
+ return out;
5774
+ });
5775
+ return {
5776
+ ...field,
5777
+ value: rows
5778
+ };
5779
+ }
5780
+ }
5670
5781
  if (field.multiple) {
5671
5782
  const stored = Array.isArray(storedValue) ? storedValue : storedValue !== void 0 && storedValue !== null ? [storedValue] : [];
5672
5783
  const itemFallback = field.multiple.itemDefault !== void 0 ? field.multiple.itemDefault : defaultValue !== void 0 ? defaultValue : typeOf(field) === "string" ? "" : null;
@@ -5909,6 +6020,778 @@ function projectStore(store, perNodeKeys, nodeId) {
5909
6020
  }
5910
6021
  return out;
5911
6022
  }
6023
+ var GLOBAL_SCOPE = { kind: "global" };
6024
+ /** The scope every addon-wide (not per-node, not per-device) setting lives in. */
6025
+ function globalSecretScope() {
6026
+ return GLOBAL_SCOPE;
6027
+ }
6028
+ function encodeSegment(value) {
6029
+ return encodeURIComponent(value);
6030
+ }
6031
+ function decodeSegment(value) {
6032
+ try {
6033
+ return decodeURIComponent(value);
6034
+ } catch {
6035
+ return null;
6036
+ }
6037
+ }
6038
+ /**
6039
+ * The field path of a value inside an array item, addressed by the item's id:
6040
+ * `arrayItemFieldPath('providers', 'authentik', 'clientSecret')` →
6041
+ * `providers[authentik].clientSecret`.
6042
+ */
6043
+ function arrayItemFieldPath(arrayKey, itemId, fieldKey) {
6044
+ return `${arrayKey}[${encodeSegment(itemId)}].${fieldKey}`;
6045
+ }
6046
+ function parseScope(segments) {
6047
+ switch (segments[0]) {
6048
+ case "global": return {
6049
+ scope: GLOBAL_SCOPE,
6050
+ used: 1
6051
+ };
6052
+ case "node": {
6053
+ const nodeId = segments[1] !== void 0 ? decodeSegment(segments[1]) : null;
6054
+ return nodeId === null || nodeId.length === 0 ? null : {
6055
+ scope: {
6056
+ kind: "node",
6057
+ nodeId
6058
+ },
6059
+ used: 2
6060
+ };
6061
+ }
6062
+ case "device": {
6063
+ const raw = segments[1];
6064
+ if (raw === void 0 || !/^\d+$/.test(raw)) return null;
6065
+ return {
6066
+ scope: {
6067
+ kind: "device",
6068
+ deviceId: Number(raw)
6069
+ },
6070
+ used: 2
6071
+ };
6072
+ }
6073
+ case "integration": {
6074
+ const id = segments[1] !== void 0 ? decodeSegment(segments[1]) : null;
6075
+ return id === null || id.length === 0 ? null : {
6076
+ scope: {
6077
+ kind: "integration",
6078
+ integrationId: id
6079
+ },
6080
+ used: 2
6081
+ };
6082
+ }
6083
+ case "row": {
6084
+ const collection = segments[1] !== void 0 ? decodeSegment(segments[1]) : null;
6085
+ const rowId = segments[2] !== void 0 ? decodeSegment(segments[2]) : null;
6086
+ if (collection === null || rowId === null || collection.length === 0 || rowId.length === 0) return null;
6087
+ return {
6088
+ scope: {
6089
+ kind: "row",
6090
+ collection,
6091
+ rowId
6092
+ },
6093
+ used: 3
6094
+ };
6095
+ }
6096
+ default: return null;
6097
+ }
6098
+ }
6099
+ /** Take a ref apart; `null` when it is not a well-formed ref. */
6100
+ function parseSecretRef(ref) {
6101
+ if (!ref.startsWith("secret://")) return null;
6102
+ const segments = ref.slice(9).split("/");
6103
+ const owner = segments[0] !== void 0 ? decodeSegment(segments[0]) : null;
6104
+ if (owner === null || owner.length === 0) return null;
6105
+ const parsed = parseScope(segments.slice(1));
6106
+ if (parsed === null) return null;
6107
+ const fieldPath = segments.slice(1 + parsed.used).join("/");
6108
+ if (fieldPath.length === 0) return null;
6109
+ return {
6110
+ owner,
6111
+ scope: parsed.scope,
6112
+ fieldPath
6113
+ };
6114
+ }
6115
+ /** A write to a secret path could not be stored in the keychain, so it was refused. */
6116
+ var KeychainWriteRefusedError = class extends Error {
6117
+ fieldPath;
6118
+ constructor(fieldPath, cause) {
6119
+ super(`secret "${fieldPath}" was not saved: the keychain could not store it (${cause instanceof Error ? cause.message : String(cause)}). Nothing was written.`);
6120
+ this.fieldPath = fieldPath;
6121
+ this.name = "KeychainWriteRefusedError";
6122
+ }
6123
+ };
6124
+ var KEEP = { kind: "keep" };
6125
+ function isRecord$1(value) {
6126
+ return typeof value === "object" && value !== null && !Array.isArray(value);
6127
+ }
6128
+ function defaultMintId() {
6129
+ return globalThis.crypto.randomUUID();
6130
+ }
6131
+ /** Every marker ref anywhere under `value`. */
6132
+ function collectSecretMarkerRefs(value, out = []) {
6133
+ if (isSecretMarker(value)) {
6134
+ out.push(value.$secret);
6135
+ return out;
6136
+ }
6137
+ if (Array.isArray(value)) for (const item of value) collectSecretMarkerRefs(item, out);
6138
+ else if (isRecord$1(value)) for (const child of Object.values(value)) collectSecretMarkerRefs(child, out);
6139
+ return out;
6140
+ }
6141
+ async function storedValueEquals(secrets, marker, candidate) {
6142
+ const resolved = (await secrets.resolve([marker.$secret]))[marker.$secret];
6143
+ return resolved?.kind === "value" && resolved.value === candidate;
6144
+ }
6145
+ async function writeLeaf(ctx, incoming, stored, fieldPath) {
6146
+ const intent = classifySecretWrite(incoming);
6147
+ const ref = ctx.secrets.ref(ctx.scope, fieldPath);
6148
+ const storedIsOurs = isSecretMarker(stored) && stored.$secret === ref;
6149
+ if (intent.kind === "keep") return KEEP;
6150
+ if (intent.kind === "set" && !ctx.operatorWrite && typeof stored === "string" && stored === intent.value) return KEEP;
6151
+ if (intent.kind === "clear") {
6152
+ if (storedIsOurs) ctx.deletes.push(ref);
6153
+ return {
6154
+ kind: "value",
6155
+ value: null
6156
+ };
6157
+ }
6158
+ if (storedIsOurs && await storedValueEquals(ctx.secrets, stored, intent.value)) return {
6159
+ kind: "value",
6160
+ value: stored
6161
+ };
6162
+ try {
6163
+ await ctx.secrets.put(ref, intent.value);
6164
+ } catch (err) {
6165
+ throw new KeychainWriteRefusedError(fieldPath, err);
6166
+ }
6167
+ return {
6168
+ kind: "value",
6169
+ value: makeSecretMarker(ref)
6170
+ };
6171
+ }
6172
+ /** Apply a member result onto `out`: KEEP restores the stored member, or removes it. */
6173
+ function applyMember(out, key, result, storedParent) {
6174
+ if (result.kind === "value") {
6175
+ out[key] = result.value;
6176
+ return;
6177
+ }
6178
+ if (Object.prototype.hasOwnProperty.call(storedParent, key)) out[key] = storedParent[key];
6179
+ else delete out[key];
6180
+ }
6181
+ async function writeMembers(ctx, children, incoming, stored, pathOf) {
6182
+ const out = { ...incoming };
6183
+ for (const [member, node] of children) applyMember(out, member, await writeNode(ctx, node, incoming[member], stored[member], pathOf(member)), stored);
6184
+ return out;
6185
+ }
6186
+ function rowId(row, idKey) {
6187
+ const raw = row[idKey];
6188
+ if (typeof raw === "string" && raw.length > 0) return raw;
6189
+ if (typeof raw === "number" && Number.isFinite(raw)) return String(raw);
6190
+ return null;
6191
+ }
6192
+ async function writeArray(ctx, node, incoming, stored, fieldPath) {
6193
+ const storedRows = Array.isArray(stored) ? stored.filter(isRecord$1) : [];
6194
+ if (!Array.isArray(incoming)) {
6195
+ ctx.deletes.push(...collectSecretMarkerRefs(storedRows));
6196
+ return {
6197
+ kind: "value",
6198
+ value: incoming
6199
+ };
6200
+ }
6201
+ const storedById = /* @__PURE__ */ new Map();
6202
+ for (const row of storedRows) {
6203
+ const id = rowId(row, node.idKey);
6204
+ if (id !== null) storedById.set(id, row);
6205
+ }
6206
+ const kept = /* @__PURE__ */ new Set();
6207
+ const rows = [];
6208
+ for (const row of incoming) {
6209
+ if (!isRecord$1(row)) {
6210
+ rows.push(row);
6211
+ continue;
6212
+ }
6213
+ const id = rowId(row, node.idKey) ?? ctx.mintId();
6214
+ kept.add(id);
6215
+ const withId = {
6216
+ ...row,
6217
+ [node.idKey]: row[node.idKey] ?? id
6218
+ };
6219
+ if (rowId(withId, node.idKey) === null) withId[node.idKey] = id;
6220
+ const storedRow = storedById.get(id) ?? {};
6221
+ rows.push(await writeMembers(ctx, node.item, withId, storedRow, (member) => arrayItemFieldPath(fieldPath, id, member)));
6222
+ }
6223
+ for (const [id, row] of storedById) if (!kept.has(id)) ctx.deletes.push(...collectSecretMarkerRefs(row));
6224
+ return {
6225
+ kind: "value",
6226
+ value: rows
6227
+ };
6228
+ }
6229
+ async function writeNode(ctx, node, incoming, stored, fieldPath) {
6230
+ switch (node.kind) {
6231
+ case "leaf": return writeLeaf(ctx, incoming, stored, fieldPath);
6232
+ case "array": return writeArray(ctx, node, incoming, stored, fieldPath);
6233
+ case "object": {
6234
+ if (!isRecord$1(incoming)) {
6235
+ if (incoming === void 0) return KEEP;
6236
+ ctx.deletes.push(...collectSecretMarkerRefs(stored));
6237
+ return {
6238
+ kind: "value",
6239
+ value: incoming
6240
+ };
6241
+ }
6242
+ const storedObj = isRecord$1(stored) ? stored : {};
6243
+ return {
6244
+ kind: "value",
6245
+ value: await writeMembers(ctx, node.children, incoming, storedObj, (m) => `${fieldPath}.${m}`)
6246
+ };
6247
+ }
6248
+ }
6249
+ }
6250
+ /** Split a perNode-scoped key (`key@nodeId`). */
6251
+ function splitNodeKey(key) {
6252
+ const at = key.indexOf("@");
6253
+ return at <= 0 ? {
6254
+ base: key,
6255
+ nodeId: null
6256
+ } : {
6257
+ base: key.slice(0, at),
6258
+ nodeId: key.slice(at + 1)
6259
+ };
6260
+ }
6261
+ /** Rewrite a settings patch so no secret value reaches the blob. See the file doc. */
6262
+ async function transformSecretWrite(input) {
6263
+ const deletes = [];
6264
+ const base = {
6265
+ secrets: input.secrets,
6266
+ mintId: input.mintId ?? defaultMintId,
6267
+ deletes,
6268
+ operatorWrite: input.operatorWrite === true
6269
+ };
6270
+ const out = {};
6271
+ for (const [key, incoming] of Object.entries(input.patch)) {
6272
+ const { base: baseKey, nodeId } = splitNodeKey(key);
6273
+ const node = input.tree.get(baseKey);
6274
+ if (node === void 0) {
6275
+ out[key] = incoming;
6276
+ continue;
6277
+ }
6278
+ const scope = nodeId !== null && nodeId.length > 0 ? {
6279
+ kind: "node",
6280
+ nodeId
6281
+ } : input.scope ?? globalSecretScope();
6282
+ const result = await writeNode({
6283
+ ...base,
6284
+ scope
6285
+ }, node, incoming, input.stored[key], baseKey);
6286
+ if (result.kind === "value") out[key] = result.value;
6287
+ }
6288
+ return {
6289
+ patch: out,
6290
+ afterWrite: async () => {
6291
+ if (deletes.length === 0) return { orphaned: [] };
6292
+ try {
6293
+ await input.secrets.delete([...new Set(deletes)]);
6294
+ return { orphaned: [] };
6295
+ } catch {
6296
+ return { orphaned: [...new Set(deletes)] };
6297
+ }
6298
+ }
6299
+ };
6300
+ }
6301
+ /** Is `ref` one of `owner`'s refs? */
6302
+ function isSecretRefOwnedBy(ref, owner) {
6303
+ return parseSecretRef(ref)?.owner === owner;
6304
+ }
6305
+ /**
6306
+ * Replace every marker in `value` with its keychain value. Returns the SAME
6307
+ * reference when there is no marker (no allocation, no keychain call).
6308
+ */
6309
+ async function resolveSecretMarkers(value, secrets, options = {}) {
6310
+ const keepMarker = options.unresolved === "keep-marker";
6311
+ const owner = options.ownedBy;
6312
+ const inScope = (ref) => owner === void 0 || isSecretRefOwnedBy(ref, owner);
6313
+ const refs = collectSecretMarkerRefs(value).filter(inScope);
6314
+ if (refs.length === 0) return {
6315
+ value,
6316
+ unresolved: []
6317
+ };
6318
+ const answers = await secrets.resolve(refs);
6319
+ const unresolved = [];
6320
+ for (const ref of new Set(refs)) {
6321
+ const answer = answers[ref];
6322
+ if (answer === void 0) unresolved.push({
6323
+ ref,
6324
+ reason: "not-initialized"
6325
+ });
6326
+ else if (answer.kind === "unavailable") unresolved.push({
6327
+ ref,
6328
+ reason: answer.reason
6329
+ });
6330
+ else if (answer.kind === "missing" || answer.kind === "forbidden") unresolved.push({
6331
+ ref,
6332
+ reason: answer.kind
6333
+ });
6334
+ }
6335
+ const substitute = (v) => {
6336
+ if (isSecretMarker(v)) {
6337
+ if (!inScope(v.$secret)) return {
6338
+ keep: true,
6339
+ value: v
6340
+ };
6341
+ const answer = answers[v.$secret];
6342
+ if (answer?.kind === "value") return {
6343
+ keep: true,
6344
+ value: answer.value
6345
+ };
6346
+ return keepMarker ? {
6347
+ keep: true,
6348
+ value: v
6349
+ } : {
6350
+ keep: false,
6351
+ value: void 0
6352
+ };
6353
+ }
6354
+ if (Array.isArray(v)) {
6355
+ const items = [];
6356
+ for (const item of v) {
6357
+ const s = substitute(item);
6358
+ if (s.keep) items.push(s.value);
6359
+ }
6360
+ return {
6361
+ keep: true,
6362
+ value: items
6363
+ };
6364
+ }
6365
+ if (isRecord$1(v)) {
6366
+ const out = {};
6367
+ for (const [k, child] of Object.entries(v)) {
6368
+ const s = substitute(child);
6369
+ if (s.keep) out[k] = s.value;
6370
+ }
6371
+ return {
6372
+ keep: true,
6373
+ value: out
6374
+ };
6375
+ }
6376
+ return {
6377
+ keep: true,
6378
+ value: v
6379
+ };
6380
+ };
6381
+ return {
6382
+ value: substitute(value).value,
6383
+ unresolved
6384
+ };
6385
+ }
6386
+ /** An addon tried to replace a stored secret it could not read. Nothing was written. */
6387
+ var SecretOverwriteRefusedError = class extends Error {
6388
+ ref;
6389
+ reason;
6390
+ constructor(ref, reason) {
6391
+ 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.`);
6392
+ this.ref = ref;
6393
+ this.reason = reason;
6394
+ this.name = "SecretOverwriteRefusedError";
6395
+ }
6396
+ };
6397
+ function isRecord(value) {
6398
+ return typeof value === "object" && value !== null && !Array.isArray(value);
6399
+ }
6400
+ function resolvedValue(pass, marker) {
6401
+ const answer = pass.answers[marker.$secret];
6402
+ return answer?.kind === "value" ? answer.value : null;
6403
+ }
6404
+ async function atMarker(pass, incoming, stored) {
6405
+ if (incoming === null) return stored;
6406
+ if (typeof incoming !== "string") return incoming;
6407
+ if (incoming === resolvedValue(pass, stored)) return stored;
6408
+ const intent = classifySecretWrite(incoming);
6409
+ if (intent.kind !== "set") return stored;
6410
+ const ref = stored.$secret;
6411
+ if (!isSecretRefOwnedBy(ref, pass.secrets.owner)) return incoming;
6412
+ const answer = pass.answers[ref];
6413
+ 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);
6414
+ try {
6415
+ await pass.secrets.put(ref, intent.value);
6416
+ } catch (err) {
6417
+ throw new KeychainWriteRefusedError(ref, err);
6418
+ }
6419
+ pass.changedRefs.push(ref);
6420
+ return stored;
6421
+ }
6422
+ function inArray(pass, incoming, stored) {
6423
+ return incoming.map((item, index) => {
6424
+ const twin = stored[index];
6425
+ if (isSecretMarker(twin)) return typeof item === "string" && item === resolvedValue(pass, twin) ? twin : item;
6426
+ if (isRecord(item) && isRecord(twin)) return inArrayRow(pass, item, twin);
6427
+ if (Array.isArray(item) && Array.isArray(twin)) return inArray(pass, item, twin);
6428
+ return item;
6429
+ });
6430
+ }
6431
+ function inArrayRow(pass, incoming, stored) {
6432
+ const out = { ...incoming };
6433
+ for (const [key, value] of Object.entries(incoming)) {
6434
+ const twin = stored[key];
6435
+ if (isSecretMarker(twin)) {
6436
+ if (typeof value === "string" && value === resolvedValue(pass, twin)) out[key] = twin;
6437
+ } else if (isRecord(value) && isRecord(twin)) out[key] = inArrayRow(pass, value, twin);
6438
+ else if (Array.isArray(value) && Array.isArray(twin)) out[key] = inArray(pass, value, twin);
6439
+ }
6440
+ return out;
6441
+ }
6442
+ async function walk(pass, incoming, stored) {
6443
+ if (isSecretMarker(stored)) return atMarker(pass, incoming, stored);
6444
+ if (Array.isArray(incoming) && Array.isArray(stored)) return inArray(pass, incoming, stored);
6445
+ if (!isRecord(incoming) || !isRecord(stored)) return incoming;
6446
+ const out = { ...incoming };
6447
+ for (const [key, value] of Object.entries(incoming)) out[key] = await walk(pass, value, stored[key]);
6448
+ return out;
6449
+ }
6450
+ /** Restore markers a write-back carries as values. See the file doc. */
6451
+ async function restoreUnchangedSecrets(input) {
6452
+ const refs = [];
6453
+ for (const key of Object.keys(input.patch)) collectSecretMarkerRefs(input.stored[key], refs);
6454
+ const owned = refs.filter((ref) => isSecretRefOwnedBy(ref, input.secrets.owner));
6455
+ if (owned.length === 0) return {
6456
+ patch: input.patch,
6457
+ changedRefs: []
6458
+ };
6459
+ const pass = {
6460
+ secrets: input.secrets,
6461
+ answers: await input.secrets.resolve([...new Set(owned)]),
6462
+ operatorWrite: input.operatorWrite,
6463
+ changedRefs: []
6464
+ };
6465
+ const out = {};
6466
+ for (const [key, value] of Object.entries(input.patch)) out[key] = await walk(pass, value, input.stored[key]);
6467
+ return {
6468
+ patch: out,
6469
+ changedRefs: pass.changedRefs
6470
+ };
6471
+ }
6472
+ /** Structural equality over JSON-shaped values (key order does not matter). */
6473
+ function isJsonEqual(a, b) {
6474
+ if (Object.is(a, b)) return true;
6475
+ if (Array.isArray(a)) return Array.isArray(b) && a.length === b.length && a.every((v, i) => isJsonEqual(v, b[i]));
6476
+ if (isRecord(a) && isRecord(b)) {
6477
+ const keys = Object.keys(a);
6478
+ if (keys.length !== Object.keys(b).length) return false;
6479
+ return keys.every((k) => Object.prototype.hasOwnProperty.call(b, k) && isJsonEqual(a[k], b[k]));
6480
+ }
6481
+ return false;
6482
+ }
6483
+ /** The patch without the keys whose value already equals the stored one. */
6484
+ function dropUnchangedKeys(patch, stored) {
6485
+ const out = {};
6486
+ for (const [key, value] of Object.entries(patch)) {
6487
+ if (Object.prototype.hasOwnProperty.call(stored, key) && isJsonEqual(value, stored[key])) continue;
6488
+ out[key] = value;
6489
+ }
6490
+ return out;
6491
+ }
6492
+ /** The top-level keys of a blob that hold at least one of `owner`'s markers. */
6493
+ function markerKeysOf(blob, owner) {
6494
+ const keys = /* @__PURE__ */ new Set();
6495
+ for (const [key, value] of Object.entries(blob)) if (collectSecretMarkerRefs(value).some((ref) => isSecretRefOwnedBy(ref, owner))) keys.add(key);
6496
+ return keys;
6497
+ }
6498
+ function nodeFromStored(value, owner) {
6499
+ if (isSecretMarker(value)) return isSecretRefOwnedBy(value.$secret, owner) ? { kind: "leaf" } : null;
6500
+ if (!isRecord(value)) return null;
6501
+ const children = /* @__PURE__ */ new Map();
6502
+ for (const [key, child] of Object.entries(value)) {
6503
+ const node = nodeFromStored(child, owner);
6504
+ if (node !== null) children.set(key, node);
6505
+ }
6506
+ return children.size > 0 ? {
6507
+ kind: "object",
6508
+ children
6509
+ } : null;
6510
+ }
6511
+ /**
6512
+ * The declared secret tree, widened by every place the STORED blob holds a
6513
+ * marker under one of `keys` — so a marker the schema no longer declares (or
6514
+ * never declared: Wyze before b4906cec6) still gets the save path's
6515
+ * KEEP / SET / CLEAR semantics instead of being overwritten by whatever the
6516
+ * addon writes. Markers inside arrays are not added: a row has no id field to
6517
+ * match by unless the schema declares one. Only `owner`'s markers count: a
6518
+ * builtin that keeps another addon's marker (device-manager) never takes it
6519
+ * over.
6520
+ */
6521
+ function widenTreeWithStoredMarkers(declared, stored, keys, owner) {
6522
+ const added = /* @__PURE__ */ new Map();
6523
+ for (const key of keys) {
6524
+ const at = key.indexOf("@");
6525
+ const base = at > 0 ? key.slice(0, at) : key;
6526
+ if (declared.has(base) || added.has(base)) continue;
6527
+ const node = nodeFromStored(stored[key], owner);
6528
+ if (node !== null) added.set(base, node);
6529
+ }
6530
+ return added.size === 0 ? declared : new Map([...declared, ...added]);
6531
+ }
6532
+ /** The blob as stored now; a failed read REFUSES the write instead of guessing. */
6533
+ async function readStoredAddonBlob(raw) {
6534
+ const threeWay = raw.readAddonStoreResult;
6535
+ if (threeWay === void 0) return raw.readAddonStore();
6536
+ const result = await threeWay.call(raw);
6537
+ if (result.kind === "failed") throw new Error(`settings write refused: the stored blob could not be read (${result.error})`);
6538
+ return result.kind === "missing" ? {} : result.value;
6539
+ }
6540
+ function touchesTree(tree, patch) {
6541
+ if (tree.size === 0) return false;
6542
+ for (const key of Object.keys(patch)) {
6543
+ const at = key.indexOf("@");
6544
+ if (tree.has(at > 0 ? key.slice(0, at) : key)) return true;
6545
+ }
6546
+ return false;
6547
+ }
6548
+ /**
6549
+ * Which top-level keys of each store held markers when last seen. `undefined`
6550
+ * for a store not seen yet: its first write reads it, to be safe.
6551
+ */
6552
+ var MarkerKeyIndex = class {
6553
+ owner;
6554
+ byStore = /* @__PURE__ */ new Map();
6555
+ constructor(owner) {
6556
+ this.owner = owner;
6557
+ }
6558
+ seen(store, blob) {
6559
+ this.byStore.set(store, markerKeysOf(blob, this.owner));
6560
+ }
6561
+ wrote(store, patch) {
6562
+ const keys = this.byStore.get(store);
6563
+ if (keys === void 0) return;
6564
+ const now = markerKeysOf(patch, this.owner);
6565
+ for (const key of Object.keys(patch)) if (now.has(key)) keys.add(key);
6566
+ else keys.delete(key);
6567
+ }
6568
+ mayHoldMarkers(store, patch) {
6569
+ const keys = this.byStore.get(store);
6570
+ if (keys === void 0) return true;
6571
+ return Object.keys(patch).some((key) => keys.has(key));
6572
+ }
6573
+ };
6574
+ function createHandle(raw, opts) {
6575
+ const chains = /* @__PURE__ */ new Map();
6576
+ const serialize = (key, fn) => {
6577
+ const next = (chains.get(key) ?? Promise.resolve()).then(fn, fn);
6578
+ const tail = next.catch(() => void 0);
6579
+ chains.set(key, tail);
6580
+ tail.then(() => {
6581
+ if (chains.get(key) === tail) chains.delete(key);
6582
+ });
6583
+ return next;
6584
+ };
6585
+ const index = new MarkerKeyIndex(opts.secrets.owner);
6586
+ const resolveRead = async (store, blob) => {
6587
+ index.seen(store, blob);
6588
+ const { value, unresolved } = await resolveSecretMarkers(blob, opts.secrets, {
6589
+ unresolved: "keep-marker",
6590
+ ownedBy: opts.secrets.owner
6591
+ });
6592
+ if (unresolved.length > 0) opts.onUnresolved?.(unresolved);
6593
+ return value;
6594
+ };
6595
+ const write = async (store, declared, scope, patch, readStored, rawWrite) => {
6596
+ if (!touchesTree(declared, patch) && !index.mayHoldMarkers(store, patch)) {
6597
+ await rawWrite(patch);
6598
+ index.wrote(store, patch);
6599
+ return { changed: true };
6600
+ }
6601
+ return serialize(store, async () => {
6602
+ const stored = await readStored();
6603
+ index.seen(store, stored);
6604
+ const operatorWrite = opts.isOperatorWrite?.() === true;
6605
+ const restored = await restoreUnchangedSecrets({
6606
+ patch,
6607
+ stored,
6608
+ secrets: opts.secrets,
6609
+ operatorWrite
6610
+ });
6611
+ const result = await transformSecretWrite({
6612
+ tree: widenTreeWithStoredMarkers(declared, stored, Object.keys(restored.patch), opts.secrets.owner),
6613
+ secrets: opts.secrets,
6614
+ patch: restored.patch,
6615
+ stored,
6616
+ ...scope !== void 0 ? { scope } : {},
6617
+ operatorWrite
6618
+ });
6619
+ const effective = dropUnchangedKeys(result.patch, stored);
6620
+ const wroteBlob = Object.keys(effective).length > 0;
6621
+ if (wroteBlob) {
6622
+ await rawWrite(effective);
6623
+ index.wrote(store, effective);
6624
+ }
6625
+ const { orphaned } = await result.afterWrite();
6626
+ if (orphaned.length > 0) opts.onOrphaned(orphaned);
6627
+ return { changed: wroteBlob || restored.changedRefs.length > 0 };
6628
+ });
6629
+ };
6630
+ const writeAddon = (patch) => write("addon", opts.addonTree(), void 0, patch, () => readStoredAddonBlob(raw), (p) => raw.writeAddonStore(p));
6631
+ const readAddonStoreResult = raw.readAddonStoreResult;
6632
+ const readAddonStoreKeyResult = raw.readAddonStoreKeyResult;
6633
+ const readDeviceStoreBatch = raw.readDeviceStoreBatch;
6634
+ const overrides = {
6635
+ readAddonStore: async () => resolveRead("addon", await raw.readAddonStore()),
6636
+ ...readAddonStoreResult !== void 0 ? { readAddonStoreResult: async () => {
6637
+ const result = await readAddonStoreResult.call(raw);
6638
+ return result.kind === "value" ? {
6639
+ kind: "value",
6640
+ value: await resolveRead("addon", result.value)
6641
+ } : result;
6642
+ } } : {},
6643
+ ...readAddonStoreKeyResult !== void 0 ? { readAddonStoreKeyResult: async (key) => {
6644
+ const result = await readAddonStoreKeyResult.call(raw, key);
6645
+ if (result.kind !== "present") return result;
6646
+ const { value, unresolved } = await resolveSecretMarkers({ [key]: result.value }, opts.secrets, {
6647
+ unresolved: "keep-marker",
6648
+ ownedBy: opts.secrets.owner
6649
+ });
6650
+ if (unresolved.length > 0) opts.onUnresolved?.(unresolved);
6651
+ return {
6652
+ kind: "present",
6653
+ value: value[key]
6654
+ };
6655
+ } } : {},
6656
+ readDeviceStore: async (deviceId) => resolveRead(`device:${deviceId}`, await raw.readDeviceStore(deviceId)),
6657
+ ...readDeviceStoreBatch !== void 0 ? { readDeviceStoreBatch: async (deviceIds) => {
6658
+ const rows = await readDeviceStoreBatch.call(raw, deviceIds);
6659
+ const out = /* @__PURE__ */ new Map();
6660
+ for (const [deviceId, blob] of rows) out.set(deviceId, await resolveRead(`device:${deviceId}`, blob));
6661
+ return out;
6662
+ } } : {},
6663
+ writeAddonStore: async (patch) => {
6664
+ await writeAddon(patch);
6665
+ },
6666
+ writeDeviceStore: async (deviceId, patch) => {
6667
+ await write(`device:${deviceId}`, opts.deviceTree(), {
6668
+ kind: "device",
6669
+ deviceId
6670
+ }, patch, () => raw.readDeviceStore(deviceId), (p) => raw.writeDeviceStore(deviceId, p));
6671
+ }
6672
+ };
6673
+ return {
6674
+ settings: new Proxy(raw, { get(target, prop, receiver) {
6675
+ if (typeof prop === "string" && Object.prototype.hasOwnProperty.call(overrides, prop)) return Reflect.get(overrides, prop);
6676
+ const value = Reflect.get(target, prop, receiver);
6677
+ return typeof value === "function" ? value.bind(target) : value;
6678
+ } }),
6679
+ raw: {
6680
+ readAddonStore: async () => {
6681
+ const blob = await raw.readAddonStore();
6682
+ index.seen("addon", blob);
6683
+ return blob;
6684
+ },
6685
+ readDeviceStore: async (deviceId) => {
6686
+ const blob = await raw.readDeviceStore(deviceId);
6687
+ index.seen(`device:${deviceId}`, blob);
6688
+ return blob;
6689
+ }
6690
+ },
6691
+ writeAddonStore: writeAddon
6692
+ };
6693
+ }
6694
+ /** The context the addon sees, plus the private raw view and write outcome. */
6695
+ function createSecretAwareContext(context, opts) {
6696
+ const raw = context.settings;
6697
+ if (raw === void 0) return {
6698
+ context,
6699
+ handle: null
6700
+ };
6701
+ const handle = createHandle(raw, opts);
6702
+ return {
6703
+ context: new Proxy(context, { get(target, prop, receiver) {
6704
+ if (prop === "settings") return handle.settings;
6705
+ return Reflect.get(target, prop, receiver);
6706
+ } }),
6707
+ handle
6708
+ };
6709
+ }
6710
+ var LEAF = { kind: "leaf" };
6711
+ var DEFAULT_ITEM_ID_KEY = "id";
6712
+ function collectFields(fields, out) {
6713
+ for (const field of fields) {
6714
+ if (field.type === "group") {
6715
+ collectFields(field.fields, out);
6716
+ continue;
6717
+ }
6718
+ if (field.type === "sub-tabs") {
6719
+ for (const tab of field.tabs) collectFields(tab.fields, out);
6720
+ continue;
6721
+ }
6722
+ if (field.type === "editable-array") {
6723
+ const item = /* @__PURE__ */ new Map();
6724
+ for (const itemField of field.itemFields) if ("key" in itemField && isKeychainStoredField(itemField)) item.set(itemField.key, LEAF);
6725
+ if (item.size > 0) out.set(field.key, {
6726
+ kind: "array",
6727
+ idKey: field.itemIdKey ?? DEFAULT_ITEM_ID_KEY,
6728
+ item
6729
+ });
6730
+ continue;
6731
+ }
6732
+ if (!("key" in field) || typeof field.key !== "string") continue;
6733
+ if (isKeychainStoredField(field)) out.set(field.key, LEAF);
6734
+ }
6735
+ }
6736
+ /** The secret tree a settings schema declares. */
6737
+ function secretTreeFromSchema(schema) {
6738
+ const out = /* @__PURE__ */ new Map();
6739
+ if (schema === null) return out;
6740
+ for (const section of schema.sections) collectFields(section.fields, out);
6741
+ return out;
6742
+ }
6743
+ /** Parse `a.b[id].c` into segments; throws on a malformed path (a declaration bug). */
6744
+ function parseSecretStatePath(path) {
6745
+ const segments = [];
6746
+ for (const raw of path.split(".")) {
6747
+ const m = /^([^[\]]+)(?:\[([^[\]]+)\])?$/.exec(raw);
6748
+ if (m === null || m[1] === void 0) throw new Error(`secretStatePaths: malformed path "${path}"`);
6749
+ segments.push(m[2] !== void 0 ? {
6750
+ key: m[1],
6751
+ idKey: m[2]
6752
+ } : { key: m[1] });
6753
+ }
6754
+ if (segments.length === 0) throw new Error(`secretStatePaths: empty path`);
6755
+ if (segments[segments.length - 1]?.idKey !== void 0) throw new Error(`secretStatePaths: "${path}" ends on an array — name the member that is secret`);
6756
+ return segments;
6757
+ }
6758
+ function insert(into, segments) {
6759
+ const [head, ...rest] = segments;
6760
+ if (head === void 0) return;
6761
+ if (rest.length === 0) {
6762
+ into.set(head.key, LEAF);
6763
+ return;
6764
+ }
6765
+ const existing = into.get(head.key);
6766
+ if (head.idKey !== void 0) {
6767
+ const item = new Map(existing?.kind === "array" ? existing.item : []);
6768
+ insert(item, rest);
6769
+ into.set(head.key, {
6770
+ kind: "array",
6771
+ idKey: head.idKey,
6772
+ item
6773
+ });
6774
+ return;
6775
+ }
6776
+ const children = new Map(existing?.kind === "object" ? existing.children : []);
6777
+ insert(children, rest);
6778
+ into.set(head.key, {
6779
+ kind: "object",
6780
+ children
6781
+ });
6782
+ }
6783
+ /** Add hidden-state paths (`secretStatePaths`) to a schema-derived tree. */
6784
+ function mergeSecretStatePaths(tree, paths) {
6785
+ if (paths.length === 0) return tree;
6786
+ const out = new Map(tree);
6787
+ for (const path of paths) insert(out, parseSecretStatePath(path));
6788
+ return out;
6789
+ }
6790
+ /** First retry of a secret the keychain could not serve; doubles to {@link SECRET_RETRY_MAX_MS}. */
6791
+ var SECRET_RETRY_FIRST_MS = 5e3;
6792
+ var SECRET_RETRY_MAX_MS = 5 * 6e4;
6793
+ /** Coalesces a burst of `keychain.changed` events into one re-resolve. */
6794
+ var SECRET_CHANGE_DEBOUNCE_MS = 250;
5912
6795
  /**
5913
6796
  * Base class for CamStack addons. Eliminates settings boilerplate:
5914
6797
  *
@@ -5978,6 +6861,33 @@ var BaseAddon = class {
5978
6861
  settingsStoreReady = false;
5979
6862
  /** Default config values. Provided via constructor. */
5980
6863
  defaults;
6864
+ /**
6865
+ * Hidden-state paths that hold secrets (D787) — values the addon writes
6866
+ * itself (`updateGlobalSettings`, `state()`) that no form field declares.
6867
+ * Stored in the keychain exactly like a `password` field. Syntax:
6868
+ * `'snapshotSigningKey'`, `'identity.pincode'`, `'tokens[userId].accessToken'`
6869
+ * (`key[<id field>]` addresses array items by id, never by index).
6870
+ */
6871
+ secretStatePaths = [];
6872
+ _addonSecretTree = null;
6873
+ _deviceSecretTree = null;
6874
+ /** Refs the last resolved config pointed at — a change to one re-resolves. */
6875
+ _configSecretRefs = /* @__PURE__ */ new Set();
6876
+ _unresolvedSecrets = [];
6877
+ _secretRetryTimer = null;
6878
+ _secretRetryDelayMs = SECRET_RETRY_FIRST_MS;
6879
+ _secretChangeTimer = null;
6880
+ _secretChangeUnsub = null;
6881
+ /** >0 while an OPERATOR's settings write is being applied. */
6882
+ _operatorWriteDepth = 0;
6883
+ /**
6884
+ * The keychain-aware settings handle (D798). Its `raw` view is the ONLY way
6885
+ * to the marker-bearing blobs and stays private to this class: the form
6886
+ * hydrate and config resolution need markers, addon code never does.
6887
+ */
6888
+ _secretSettings = null;
6889
+ /** Refs an addon-facing read could not resolve — each is logged once per process. */
6890
+ _loggedUnresolvedReads = /* @__PURE__ */ new Set();
5981
6891
  constructor(defaults) {
5982
6892
  this.defaults = defaults;
5983
6893
  this._config = { ...defaults };
@@ -6013,8 +6923,26 @@ var BaseAddon = class {
6013
6923
  return this._config;
6014
6924
  }
6015
6925
  async initialize(context) {
6016
- this._ctx = context;
6926
+ const secrets = context.secrets;
6927
+ if (secrets !== void 0) {
6928
+ const { context: wrapped, handle } = createSecretAwareContext(context, {
6929
+ secrets,
6930
+ addonTree: () => this.addonSecretTree(),
6931
+ deviceTree: () => this.deviceSecretTree(),
6932
+ onOrphaned: (refs) => context.logger.warn("keychain refs dropped by a settings write could not be deleted", { meta: { refs: [...refs] } }),
6933
+ isOperatorWrite: () => this._operatorWriteDepth > 0,
6934
+ onUnresolved: (unresolved) => this.logUnresolvedRead(unresolved)
6935
+ });
6936
+ this._ctx = wrapped;
6937
+ this._secretSettings = handle;
6938
+ } else {
6939
+ this._ctx = context;
6940
+ this._secretSettings = null;
6941
+ }
6017
6942
  await this.resolveConfig();
6943
+ if (secrets !== void 0) this._secretChangeUnsub = secrets.onChange((ref) => {
6944
+ if (this._configSecretRefs.has(ref)) this.scheduleSecretReresolve(SECRET_CHANGE_DEBOUNCE_MS);
6945
+ });
6018
6946
  const result = await this.onInitialize();
6019
6947
  this.emitLifecycle(EventCategory.AddonStarted);
6020
6948
  const normalized = normalizeAddonInitResult(result);
@@ -6047,6 +6975,12 @@ var BaseAddon = class {
6047
6975
  */
6048
6976
  async onHubReachable() {}
6049
6977
  async shutdown() {
6978
+ this._secretChangeUnsub?.();
6979
+ this._secretChangeUnsub = null;
6980
+ if (this._secretRetryTimer !== null) clearTimeout(this._secretRetryTimer);
6981
+ if (this._secretChangeTimer !== null) clearTimeout(this._secretChangeTimer);
6982
+ this._secretRetryTimer = null;
6983
+ this._secretChangeTimer = null;
6050
6984
  this.emitLifecycle(EventCategory.AddonStopped);
6051
6985
  if (this.autoEmitReadiness) this.emitReadinessForProviders("down");
6052
6986
  await this.onShutdown();
@@ -6121,11 +7055,8 @@ var BaseAddon = class {
6121
7055
  async getGlobalSettings(overlay, cap, nodeId) {
6122
7056
  const schema = this.globalSettingsSchema(cap);
6123
7057
  if (!schema) return { sections: [] };
6124
- const projected = await this.resolveGlobalStore(nodeId, cap);
6125
- return hydrateSchema(schema, overlay ? {
6126
- ...projected,
6127
- ...overlay
6128
- } : projected);
7058
+ const projected = await this.readRawProjectedStore(nodeId, cap);
7059
+ return hydrateSchema(schema, overlay ? await this.overlayKeepingMarkers(projected, overlay) : projected, { inlineSecretsAsViews: true });
6129
7060
  }
6130
7061
  /**
6131
7062
  * The integration-level view of this addon's settings: exactly the sections
@@ -6170,11 +7101,11 @@ var BaseAddon = class {
6170
7101
  });
6171
7102
  }
6172
7103
  if (sections.length === 0) return null;
6173
- const projected = await this.resolveGlobalStore(nodeId);
7104
+ const projected = await this.readRawProjectedStore(nodeId);
6174
7105
  return hydrateSchema({
6175
7106
  ...schema,
6176
7107
  sections
6177
- }, projected);
7108
+ }, projected, { inlineSecretsAsViews: true });
6178
7109
  }
6179
7110
  /**
6180
7111
  * The raw addon store PROJECTED onto the target node's bare per-node keys:
@@ -6187,12 +7118,50 @@ var BaseAddon = class {
6187
7118
  * the store for custom option logic (option narrowing, value snapping) to
6188
7119
  * read it per-node — never `ctx.settings.readAddonStore()` directly.
6189
7120
  * `nodeId` omitted ⇒ the local node (node-blind injection from ctx).
7121
+ *
7122
+ * Keychain values come back RESOLVED (D798): a secret reads as its value,
7123
+ * never as a `{ $secret }` marker. One the keychain cannot serve right now
7124
+ * stays a marker — "stored, unavailable" (`isSecretMarker()` is true, and it
7125
+ * is listed in {@link unresolvedSecrets}) — never `''` and never absent, so
7126
+ * it cannot be mistaken for "nothing stored, mint a new one". Writing the
7127
+ * resolved blob back is a no-op for every unchanged secret.
6190
7128
  */
6191
7129
  async resolveGlobalStore(nodeId, cap) {
6192
7130
  const raw = await this._ctx?.settings?.readAddonStore() ?? {};
7131
+ return this.projectForNode(raw, nodeId, cap);
7132
+ }
7133
+ projectForNode(store, nodeId, cap) {
6193
7134
  const keys = this.perNodeKeys(cap);
6194
7135
  const node = normalizeNodeId(nodeId ?? this._ctx?.kernel?.localNodeId);
6195
- return keys.size > 0 ? projectStore(raw, keys, node) : raw;
7136
+ return keys.size > 0 ? projectStore(store, keys, node) : store;
7137
+ }
7138
+ /** The PROJECTED store with its markers — the form hydrate only (D798). */
7139
+ async readRawProjectedStore(nodeId, cap) {
7140
+ const raw = await this.rawSettings()?.readAddonStore() ?? {};
7141
+ return this.projectForNode(raw, nodeId, cap);
7142
+ }
7143
+ /**
7144
+ * `{ ...stored, ...overlay }`, except that an overlay member equal to the
7145
+ * RESOLVED stored one keeps the stored (marker-bearing) member — so a form
7146
+ * hydrated from a resolved overlay still shows a secret as "set", never as
7147
+ * its value.
7148
+ */
7149
+ async overlayKeepingMarkers(stored, overlay) {
7150
+ const secrets = this._ctx?.secrets;
7151
+ const merged = {
7152
+ ...stored,
7153
+ ...overlay
7154
+ };
7155
+ if (secrets === void 0 || collectSecretMarkerRefs(stored).length === 0) return merged;
7156
+ const { value: resolved } = await resolveSecretMarkers(stored, secrets, {
7157
+ unresolved: "keep-marker",
7158
+ ownedBy: secrets.owner
7159
+ });
7160
+ for (const key of Object.keys(overlay)) {
7161
+ if (collectSecretMarkerRefs(stored[key]).length === 0) continue;
7162
+ if (isJsonEqual(overlay[key], resolved[key])) merged[key] = stored[key];
7163
+ }
7164
+ return merged;
6196
7165
  }
6197
7166
  /**
6198
7167
  * Whether ONE global key of this addon's store was written, read three-way
@@ -6228,18 +7197,58 @@ var BaseAddon = class {
6228
7197
  value: result.value[key]
6229
7198
  };
6230
7199
  }
7200
+ /**
7201
+ * The OPERATOR's write — a settings form or an admin API call, dispatched by
7202
+ * the kernel. Identical to {@link updateGlobalSettings}, except that a secret
7203
+ * the operator sends is stored as sent even when it equals a pre-keychain
7204
+ * inline value: the operator re-entering a password is a change, an addon
7205
+ * writing back what it read is not (D787).
7206
+ */
7207
+ async updateGlobalSettingsAsOperator(patch, nodeId) {
7208
+ this._operatorWriteDepth++;
7209
+ try {
7210
+ await this.applyGlobalPatch(patch, nodeId);
7211
+ } finally {
7212
+ this._operatorWriteDepth--;
7213
+ }
7214
+ }
6231
7215
  async updateGlobalSettings(patch, nodeId) {
7216
+ await this.applyGlobalPatch(patch, nodeId);
7217
+ }
7218
+ /**
7219
+ * REMOVE stored secrets — their keychain values and their markers (D787).
7220
+ *
7221
+ * Writing `''` to a secret field KEEPS what is stored (an empty string is
7222
+ * what a defaults fallback writes back, and it must never destroy a
7223
+ * credential), so code that means "forget this token" says so here. Without
7224
+ * a keychain (an older kernel) it writes `''`, as such code always did.
7225
+ */
7226
+ async clearSecrets(keys, nodeId) {
7227
+ const tree = this.addonSecretTree();
7228
+ const keychain = this._ctx?.secrets !== void 0;
7229
+ const stored = keychain ? await this.readAddonStoreWithRetry() : {};
7230
+ const patch = {};
7231
+ for (const key of keys) {
7232
+ const keychainStored = tree.has(key) || collectSecretMarkerRefs(stored[key]).length > 0;
7233
+ patch[key] = keychain && keychainStored ? SECRET_CLEAR : "";
7234
+ }
7235
+ await this.applyGlobalPatch(patch, nodeId);
7236
+ }
7237
+ async applyGlobalPatch(barePatch, nodeId) {
6232
7238
  const keys = this.perNodeKeys();
6233
7239
  const localNode = normalizeNodeId(this._ctx?.kernel?.localNodeId);
6234
7240
  const target = normalizeNodeId(nodeId ?? this._ctx?.kernel?.localNodeId);
6235
- const barePatch = patch;
6236
7241
  const scoped = keys.size > 0 ? scopePatch(barePatch, keys, target) : barePatch;
6237
- await this._ctx?.settings?.writeAddonStore(scoped);
7242
+ const handle = this._secretSettings;
7243
+ if (handle !== null) {
7244
+ const { changed } = await handle.writeAddonStore(scoped);
7245
+ if (!changed) return;
7246
+ } else await this._ctx?.settings?.writeAddonStore(scoped);
6238
7247
  if (target !== localNode) return;
6239
7248
  await this.resolveConfig();
6240
7249
  await this.onConfigChanged();
6241
7250
  this.emitLifecycle(EventCategory.AddonUpdated, { level: "global" });
6242
- this.maybeAutoRestart(patch, this.globalSettingsSchema());
7251
+ this.maybeAutoRestart(Object.keys(barePatch), this.globalSettingsSchema());
6243
7252
  }
6244
7253
  /**
6245
7254
  * The set of field keys the global settings schema declares `perNode: true`
@@ -6264,7 +7273,7 @@ var BaseAddon = class {
6264
7273
  * time to return its response before the addon is torn down and
6265
7274
  * re-initialised by `AddonRegistryService.restartAddon`.
6266
7275
  */
6267
- maybeAutoRestart(patch, schema) {
7276
+ maybeAutoRestart(patchKeys, schema) {
6268
7277
  if (!schema) return;
6269
7278
  const restartKeys = /* @__PURE__ */ new Set();
6270
7279
  for (const section of schema.sections) for (const field of section.fields) {
@@ -6272,13 +7281,13 @@ var BaseAddon = class {
6272
7281
  if (field.requiresRestart) restartKeys.add(field.key);
6273
7282
  }
6274
7283
  if (restartKeys.size === 0) return;
6275
- if (!Object.keys(patch).some((k) => restartKeys.has(k))) return;
7284
+ if (!patchKeys.some((k) => restartKeys.has(k))) return;
6276
7285
  const ctx = this._ctx;
6277
7286
  if (!ctx) return;
6278
7287
  const addonId = ctx.id;
6279
7288
  setImmediate(() => {
6280
7289
  ctx.api.addons?.restartAddon?.mutate({ addonId }).then(() => {
6281
- ctx.logger.info("addon auto-restart triggered by restart-required setting change", { meta: { changedFields: Object.keys(patch).filter((k) => restartKeys.has(k)) } });
7290
+ ctx.logger.info("addon auto-restart triggered by restart-required setting change", { meta: { changedFields: patchKeys.filter((k) => restartKeys.has(k)) } });
6282
7291
  }).catch((err) => {
6283
7292
  ctx.logger.error("addon auto-restart failed", { meta: { error: err instanceof Error ? err.message : String(err) } });
6284
7293
  });
@@ -6287,7 +7296,7 @@ var BaseAddon = class {
6287
7296
  async getDeviceSettings(deviceId) {
6288
7297
  const schema = this.deviceSettingsSchema();
6289
7298
  if (!schema) return { sections: [] };
6290
- return hydrateSchema(schema, await this._ctx?.settings?.readDeviceStore(deviceId) ?? {});
7299
+ return hydrateSchema(schema, await this.rawSettings()?.readDeviceStore(deviceId) ?? {}, { inlineSecretsAsViews: true });
6291
7300
  }
6292
7301
  async updateDeviceSettings(deviceId, patch) {
6293
7302
  await this._ctx?.settings?.writeDeviceStore(deviceId, patch);
@@ -6417,7 +7426,7 @@ var BaseAddon = class {
6417
7426
  * selection at boot (absent scoped key ⇒ the constructor default wins).
6418
7427
  */
6419
7428
  async resolveConfig() {
6420
- const stored = await this.readAddonStoreWithRetry();
7429
+ const stored = await this.resolveStoredSecrets(await this.readAddonStoreWithRetry());
6421
7430
  const perNode = this.perNodeKeys();
6422
7431
  const localNode = normalizeNodeId(this._ctx?.kernel?.localNodeId);
6423
7432
  const resolved = { ...this.defaults };
@@ -6442,7 +7451,7 @@ var BaseAddon = class {
6442
7451
  key,
6443
7452
  schema,
6444
7453
  fallback,
6445
- read: () => this.readAddonStoreWithRetry(),
7454
+ read: async () => this.resolveStoredSecrets(await this.readAddonStoreWithRetry()),
6446
7455
  write: async (patch) => {
6447
7456
  await this._ctx?.settings?.writeAddonStore(patch);
6448
7457
  },
@@ -6459,7 +7468,7 @@ var BaseAddon = class {
6459
7468
  key,
6460
7469
  schema,
6461
7470
  fallback,
6462
- read: async () => await this._ctx?.settings?.readDeviceStore(deviceId) ?? {},
7471
+ read: async () => this.resolveStoredSecrets(await this.rawSettings()?.readDeviceStore(deviceId) ?? {}, false),
6463
7472
  write: async (patch) => {
6464
7473
  await this._ctx?.settings?.writeDeviceStore(deviceId, patch);
6465
7474
  },
@@ -6471,6 +7480,87 @@ var BaseAddon = class {
6471
7480
  } })
6472
7481
  });
6473
7482
  }
7483
+ /** The addon store's secret tree: schema fields by TYPE, plus `secretStatePaths`. */
7484
+ addonSecretTree() {
7485
+ this._addonSecretTree ??= mergeSecretStatePaths(secretTreeFromSchema(this.globalSettingsSchema()), this.secretStatePaths);
7486
+ return this._addonSecretTree;
7487
+ }
7488
+ deviceSecretTree() {
7489
+ this._deviceSecretTree ??= secretTreeFromSchema(this.deviceSettingsSchema());
7490
+ return this._deviceSecretTree;
7491
+ }
7492
+ /**
7493
+ * Secrets of this addon's stored config that could not be resolved on the
7494
+ * last read, with why. Non-empty means the addon is running WITHOUT them —
7495
+ * an addon whose function needs one should report itself degraded rather
7496
+ * than start on an empty credential.
7497
+ */
7498
+ get unresolvedSecrets() {
7499
+ return this._unresolvedSecrets;
7500
+ }
7501
+ /**
7502
+ * Substitute every keychain marker in a stored blob with its value. With no
7503
+ * keychain (no `ctx.secrets`) or no marker, the blob comes back unchanged.
7504
+ * An unresolvable value is LEFT OUT (never `''`), logged by ref — never by
7505
+ * value — and, when the cause can pass, retried with backoff. Nothing is
7506
+ * ever written back from here.
7507
+ */
7508
+ async resolveStoredSecrets(blob, trackForConfig = true) {
7509
+ const secrets = this._ctx?.secrets;
7510
+ if (secrets === void 0) return blob;
7511
+ const refs = collectSecretMarkerRefs(blob);
7512
+ if (trackForConfig) this._configSecretRefs = new Set(refs);
7513
+ if (refs.length === 0) {
7514
+ if (trackForConfig) this._unresolvedSecrets = [];
7515
+ return blob;
7516
+ }
7517
+ const { value, unresolved } = await resolveSecretMarkers(blob, secrets);
7518
+ if (trackForConfig) {
7519
+ this._unresolvedSecrets = unresolved;
7520
+ if (unresolved.length > 0) {
7521
+ this._ctx?.logger?.error?.("secret unavailable — running without it, will retry", { meta: { secrets: unresolved.map((u) => ({
7522
+ ref: u.ref,
7523
+ reason: u.reason
7524
+ })) } });
7525
+ if (unresolved.some((u) => u.reason !== "missing" && u.reason !== "forbidden")) {
7526
+ this.scheduleSecretReresolve(this._secretRetryDelayMs);
7527
+ this._secretRetryDelayMs = Math.min(this._secretRetryDelayMs * 2, SECRET_RETRY_MAX_MS);
7528
+ }
7529
+ } else this._secretRetryDelayMs = SECRET_RETRY_FIRST_MS;
7530
+ }
7531
+ return value;
7532
+ }
7533
+ /**
7534
+ * The marker-bearing settings reads (D798) — private on purpose. Without a
7535
+ * keychain the context's own view is already raw.
7536
+ */
7537
+ rawSettings() {
7538
+ return this._secretSettings?.raw ?? this._ctx?.settings;
7539
+ }
7540
+ /** An addon-facing read met markers it could not resolve: say so once per ref. */
7541
+ logUnresolvedRead(unresolved) {
7542
+ const fresh = unresolved.filter((u) => !this._loggedUnresolvedReads.has(u.ref));
7543
+ if (fresh.length === 0) return;
7544
+ for (const u of fresh) this._loggedUnresolvedReads.add(u.ref);
7545
+ 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) => ({
7546
+ ref: u.ref,
7547
+ reason: u.reason
7548
+ })) } });
7549
+ }
7550
+ /** Re-resolve the config (a keychain-only change, or a retry) and apply it. */
7551
+ scheduleSecretReresolve(delayMs) {
7552
+ const timerOf = delayMs === SECRET_CHANGE_DEBOUNCE_MS ? "_secretChangeTimer" : "_secretRetryTimer";
7553
+ if (this[timerOf] !== null) return;
7554
+ const timer = setTimeout(() => {
7555
+ this[timerOf] = null;
7556
+ if (this._ctx === null) return;
7557
+ this.resolveConfig().then(() => this.onConfigChanged()).catch((err) => {
7558
+ this._ctx?.logger?.error?.("re-resolving secrets failed", { meta: { error: err instanceof Error ? err.message : String(err) } });
7559
+ });
7560
+ }, delayMs);
7561
+ timer.unref?.();
7562
+ this[timerOf] = timer;
7563
+ }
6474
7564
  /**
6475
7565
  * Wrap `ctx.settings.readAddonStore()` with a short retry budget so a
6476
7566
  * transient settings-store outage (mid-restart of sqlite-settings, tsx-watch
@@ -6483,7 +7573,7 @@ var BaseAddon = class {
6483
7573
  * `{}` (defaults) — the addon's first successful patch will rehydrate.
6484
7574
  */
6485
7575
  async readAddonStoreWithRetry() {
6486
- const settings = this._ctx?.settings;
7576
+ const settings = this.rawSettings();
6487
7577
  if (!settings) return {};
6488
7578
  const delaysMs = [
6489
7579
  150,
@@ -8743,6 +9833,278 @@ var CameraSwitchGroupSchema = object({
8743
9833
  fetchedAt: number()
8744
9834
  });
8745
9835
  /**
9836
+ * The trainer contract — what the hub hands the cloud trainer and what it
9837
+ * gets back (cloud training, D805+).
9838
+ *
9839
+ * The trainer (`hf/camstack-trainer`, published as the Hugging Face repo
9840
+ * `camstack/camstack-trainer`) is a separate AGPL program the hub never
9841
+ * imports: `job.json` goes in, files come out, and progress is `CAMSTACK_EVENT`
9842
+ * lines on stdout. These schemas are the hub's half of that boundary; the
9843
+ * trainer's pydantic models (and the JSON Schemas generated from them under
9844
+ * `hf/camstack-trainer/schemas/`) are the other half. A change here is a
9845
+ * change there, in the same piece of work.
9846
+ *
9847
+ * No `.default()` anywhere: defaults do not run on the addon cap path, so the
9848
+ * orchestrator fills every field of a job spec explicitly.
9849
+ */
9850
+ var TRAINING_JOB_SCHEMA = "camstack.training/v1";
9851
+ var TRAINING_RESULT_SCHEMA = "camstack.training-result/v1";
9852
+ /** What the trainer can export. Edge TPU is a later, separate image. */
9853
+ var TrainingExportSchema = _enum([
9854
+ "onnx",
9855
+ "openvino-fp16",
9856
+ "openvino-int8",
9857
+ "coreml-fp16"
9858
+ ]);
9859
+ var FloorsSchema = record(string(), number().min(0).max(1));
9860
+ object({
9861
+ schema: literal(TRAINING_JOB_SCHEMA),
9862
+ jobKey: string().uuid(),
9863
+ target: object({
9864
+ kind: literal("detector"),
9865
+ step: literal("object-detection")
9866
+ }),
9867
+ base: object({
9868
+ modelId: string().min(1),
9869
+ /** Ultralytics weights id, e.g. `yolov9m.pt`. */
9870
+ weights: string().min(1),
9871
+ imgsz: number().int().positive()
9872
+ }),
9873
+ baseline: object({
9874
+ modelId: string().min(1),
9875
+ /** The baseline ONNX the holdout comparison runs; public mirror URL. */
9876
+ onnxUrl: string().url(),
9877
+ imgsz: number().int().positive(),
9878
+ floors: FloorsSchema
9879
+ }),
9880
+ dataset: object({
9881
+ versionId: string().min(1),
9882
+ annotationHash: string(),
9883
+ /** sha256 of the uploaded archive; the trainer refuses a mismatch (exit 65). */
9884
+ sha256: string().regex(/^[0-9a-f]{64}$/)
9885
+ }),
9886
+ split: object({
9887
+ holdoutCameras: array(number().int()),
9888
+ /** When no camera is held out: the last N days of every camera. */
9889
+ holdoutLastDays: number().int().nonnegative(),
9890
+ valFraction: number().min(0).max(.5),
9891
+ seed: number().int()
9892
+ }),
9893
+ hyper: object({
9894
+ epochs: number().int().positive(),
9895
+ batch: number().int().positive(),
9896
+ lr0: number().positive(),
9897
+ /** Layers frozen from the start of the backbone; 0 = none. */
9898
+ freeze: number().int().nonnegative(),
9899
+ patience: number().int().nonnegative(),
9900
+ seed: number().int()
9901
+ }),
9902
+ replay: object({
9903
+ source: literal("coco2017"),
9904
+ count: number().int().nonnegative()
9905
+ }),
9906
+ exports: array(TrainingExportSchema).min(1),
9907
+ calibration: object({ maxFrames: number().int().positive() }),
9908
+ floors: object({
9909
+ minSupport: number().int().positive(),
9910
+ clamp: number().min(0).max(1)
9911
+ }),
9912
+ int8Gate: object({ maxMap50Drop: number().min(0).max(1) }),
9913
+ catalog: object({
9914
+ id: string().regex(/^[a-z0-9][a-z0-9-]{2,80}$/),
9915
+ name: string().min(1).max(160)
9916
+ })
9917
+ });
9918
+ /** One regular file of the bundle. An mlpackage contributes one row per member. */
9919
+ var TrainingResultFileSchema = object({
9920
+ path: string().min(1),
9921
+ bytes: number().int().nonnegative(),
9922
+ sha256: string().regex(/^[0-9a-f]{64}$/),
9923
+ format: _enum([
9924
+ "onnx",
9925
+ "openvino",
9926
+ "coreml",
9927
+ "pt"
9928
+ ]),
9929
+ variant: _enum(["base", "int8"])
9930
+ });
9931
+ var DraftFormatSchema = object({
9932
+ /** RELATIVE path inside the bundle; the hub rewrites it to `camstack-local://`. */
9933
+ url: string().min(1),
9934
+ sizeMB: number().nonnegative(),
9935
+ isDirectory: boolean().optional(),
9936
+ files: array(string()).optional(),
9937
+ runtimes: array(literal("python")).optional(),
9938
+ revision: string().min(1)
9939
+ });
9940
+ /** The trainer's half of a catalog entry; the hub completes it (labels, licence, group). */
9941
+ var TrainingCatalogDraftSchema = object({
9942
+ id: string().min(1),
9943
+ name: string().min(1),
9944
+ description: string(),
9945
+ labels: array(unknown()),
9946
+ inputSize: object({
9947
+ width: number().int().positive(),
9948
+ height: number().int().positive()
9949
+ }),
9950
+ preprocessMode: literal("letterbox"),
9951
+ defaultClassFloors: FloorsSchema,
9952
+ formats: object({
9953
+ onnx: DraftFormatSchema.optional(),
9954
+ openvino: DraftFormatSchema.optional(),
9955
+ coreml: DraftFormatSchema.optional()
9956
+ })
9957
+ });
9958
+ /** One class of one model's holdout report (the eval harness's summary). */
9959
+ var TrainingEvalClassSchema = object({
9960
+ positives: number().int(),
9961
+ floor: number().nullable(),
9962
+ tp: number().int(),
9963
+ fp: number().int(),
9964
+ fn: number().int(),
9965
+ precision: number().nullable(),
9966
+ recall: number().nullable(),
9967
+ ap50: number().nullable(),
9968
+ recallByCamera: record(string(), number().nullable()).optional(),
9969
+ recallByLight: record(string(), number().nullable()).optional(),
9970
+ fpByCamera: record(string(), number()).optional(),
9971
+ smallFound: number().int().optional(),
9972
+ smallTotal: number().int().optional()
9973
+ }).passthrough();
9974
+ var TrainingEvalReportSchema = object({
9975
+ frames: number().int(),
9976
+ classes: record(string(), TrainingEvalClassSchema)
9977
+ }).passthrough();
9978
+ /**
9979
+ * A succeeded result carries every block; a failed one carries the error and
9980
+ * whatever was known by then — the other blocks are ABSENT, not null. The
9981
+ * orchestrator checks the blocks it needs before it trusts a success.
9982
+ */
9983
+ var TrainingResultSchema = object({
9984
+ schema: literal(TRAINING_RESULT_SCHEMA),
9985
+ jobKey: string(),
9986
+ status: _enum(["succeeded", "failed"]),
9987
+ error: object({
9988
+ stage: string(),
9989
+ code: string(),
9990
+ message: string()
9991
+ }).nullable(),
9992
+ trainer: object({
9993
+ version: string(),
9994
+ revision: string()
9995
+ }),
9996
+ toolchain: record(string(), string().nullable()),
9997
+ dataset: object({
9998
+ versionId: string(),
9999
+ annotationHash: string(),
10000
+ sha256: string(),
10001
+ frames: object({
10002
+ train: number().int(),
10003
+ val: number().int(),
10004
+ holdout: number().int()
10005
+ }),
10006
+ holdoutCameras: array(number().int()),
10007
+ replayImages: number().int()
10008
+ }).optional(),
10009
+ training: object({
10010
+ epochsRun: number().int(),
10011
+ bestEpoch: number().int(),
10012
+ bestMap50: number(),
10013
+ bestMap50_95: number(),
10014
+ seconds: number()
10015
+ }).optional(),
10016
+ evaluation: object({
10017
+ holdoutFrames: number().int(),
10018
+ baseline: TrainingEvalReportSchema.nullable(),
10019
+ candidate: TrainingEvalReportSchema.nullable(),
10020
+ candidateInt8: TrainingEvalReportSchema.nullable(),
10021
+ recallDeltaByCamera: record(string(), record(string(), number())).nullable(),
10022
+ map50: record(string(), number().nullable())
10023
+ }).optional(),
10024
+ floors: object({
10025
+ baseline: FloorsSchema,
10026
+ candidate: FloorsSchema,
10027
+ candidateInt8: FloorsSchema.nullable(),
10028
+ notes: array(string())
10029
+ }).optional(),
10030
+ int8: object({
10031
+ kept: boolean(),
10032
+ map50Fp16: number().nullable(),
10033
+ map50Int8: number().nullable(),
10034
+ reason: string().nullable()
10035
+ }).optional(),
10036
+ exportsDropped: array(object({
10037
+ export: string(),
10038
+ reason: string()
10039
+ })).optional(),
10040
+ files: array(TrainingResultFileSchema).optional(),
10041
+ bundle: object({
10042
+ path: literal("bundle.tar"),
10043
+ bytes: number().int().nonnegative(),
10044
+ sha256: string().regex(/^[0-9a-f]{64}$/)
10045
+ }).nullable().optional(),
10046
+ catalogDraft: object({
10047
+ base: TrainingCatalogDraftSchema,
10048
+ int8: TrainingCatalogDraftSchema.nullable()
10049
+ }).nullable().optional(),
10050
+ licence: string()
10051
+ });
10052
+ var TrainingStageSchema = _enum([
10053
+ "prepare",
10054
+ "replay",
10055
+ "train",
10056
+ "eval",
10057
+ "export",
10058
+ "package"
10059
+ ]);
10060
+ var EventBase = {
10061
+ v: literal(1),
10062
+ ts: number()
10063
+ };
10064
+ discriminatedUnion("type", [
10065
+ object({
10066
+ ...EventBase,
10067
+ type: literal("stage"),
10068
+ stage: TrainingStageSchema
10069
+ }),
10070
+ object({
10071
+ ...EventBase,
10072
+ type: literal("epoch"),
10073
+ epoch: number().int(),
10074
+ epochs: number().int(),
10075
+ boxLoss: number().nullable().optional(),
10076
+ map50: number().nullable().optional(),
10077
+ map50_95: number().nullable().optional(),
10078
+ etaSec: number().nullable().optional()
10079
+ }),
10080
+ object({
10081
+ ...EventBase,
10082
+ type: literal("metric"),
10083
+ name: string(),
10084
+ value: number()
10085
+ }),
10086
+ object({
10087
+ ...EventBase,
10088
+ type: literal("artifact"),
10089
+ path: string(),
10090
+ bytes: number(),
10091
+ sha256: string()
10092
+ }),
10093
+ object({
10094
+ ...EventBase,
10095
+ type: literal("done"),
10096
+ status: _enum(["succeeded", "failed"]),
10097
+ resultSha256: string().nullable().optional()
10098
+ }),
10099
+ object({
10100
+ ...EventBase,
10101
+ type: literal("error"),
10102
+ stage: string(),
10103
+ code: string(),
10104
+ message: string()
10105
+ })
10106
+ ]);
10107
+ /**
8746
10108
  * What the gate decided about a birth, from the CALLER's point of view.
8747
10109
  *
8748
10110
  * Deliberately not `ConfirmationVerdict`: `undecided` is not a birth decision
@@ -11070,7 +12432,9 @@ var AddonHttpRouteSchema = object({
11070
12432
  "authenticated",
11071
12433
  "admin"
11072
12434
  ]).optional(),
11073
- description: string().optional()
12435
+ description: string().optional(),
12436
+ /** The hub limits this route per client address before the handler runs. */
12437
+ rateLimit: _enum(["auth"]).optional()
11074
12438
  });
11075
12439
  /**
11076
12440
  * Cross-process route invocation envelope. The hub captures the
@@ -11775,6 +13139,37 @@ var BackupDestinationInfoSchema = object({
11775
13139
  lastError: string().optional()
11776
13140
  });
11777
13141
  /**
13142
+ * How an archive is encrypted (operator decision 2026-10-09): to a backup
13143
+ * PUBLIC key the hub holds, so only the operator's secret key opens it.
13144
+ * Absent on a plain `.tar.gz` — every archive made before encryption, or
13145
+ * with it off — which restores without a key.
13146
+ */
13147
+ var BackupArchiveEncryptionSchema = object({
13148
+ /** `x25519-hkdf-aes256gcm-stream-v1`. */
13149
+ scheme: string(),
13150
+ /** 16 hex — the backup key whose secret restores this archive. */
13151
+ keyId: string()
13152
+ });
13153
+ /**
13154
+ * The backup encryption setting. The hub keeps PUBLIC keys only: the active
13155
+ * one new archives are encrypted to, and the retired ones older archives
13156
+ * still need. The secret key is shown once, at `setupEncryption`.
13157
+ */
13158
+ var BackupEncryptionStatusSchema = object({
13159
+ enabled: boolean(),
13160
+ active: object({
13161
+ keyId: string(),
13162
+ publicKey: string(),
13163
+ createdAt: number()
13164
+ }).nullable(),
13165
+ /** Every key ever set up, newest first. */
13166
+ keys: array(object({
13167
+ keyId: string(),
13168
+ createdAt: number(),
13169
+ retiredAt: number().nullable()
13170
+ })).readonly()
13171
+ });
13172
+ /**
11778
13173
  * Per-archive entry returned by `backup.listArchives({ destinationId })`.
11779
13174
  * Same shape the destination drill-in renders. Sourced from the per-
11780
13175
  * location `manifests.json` (no per-archive tarball read required).
@@ -11786,7 +13181,9 @@ var BackupArchiveEntrySchema = object({
11786
13181
  sizeBytes: number(),
11787
13182
  label: string().optional(),
11788
13183
  /** Top-level locations included in the archive (db, addons, tls, …). */
11789
- locations: array(string()).readonly()
13184
+ locations: array(string()).readonly(),
13185
+ /** Present when the archive is encrypted; restore then needs that key. */
13186
+ encryption: BackupArchiveEncryptionSchema.optional()
11790
13187
  });
11791
13188
  var BackupEntrySchema = object({
11792
13189
  id: string(),
@@ -11795,7 +13192,8 @@ var BackupEntrySchema = object({
11795
13192
  label: string().optional(),
11796
13193
  createdAt: number(),
11797
13194
  sizeBytes: number(),
11798
- locations: array(string()).optional()
13195
+ locations: array(string()).optional(),
13196
+ encryption: BackupArchiveEncryptionSchema.optional()
11799
13197
  });
11800
13198
  var ArchiveEntrySchema = object({
11801
13199
  path: string(),
@@ -11984,10 +13382,40 @@ method(_void(), array(BackupDestinationInfoSchema).readonly(), { auth: "admin" }
11984
13382
  * this list and skips entries whose path doesn't start with
11985
13383
  * any of them.
11986
13384
  */
11987
- locations: array(string()).optional()
13385
+ locations: array(string()).optional(),
13386
+ /**
13387
+ * The backup SECRET key, for an encrypted archive (ignored for a plain
13388
+ * one). The archive is decrypted into the hub's private staging
13389
+ * before the restart; the key is not stored. A wrong or missing key
13390
+ * is refused before the archive is downloaded.
13391
+ */
13392
+ backupSecretKey: string().optional()
11988
13393
  }), _void(), {
11989
13394
  kind: "mutation",
11990
13395
  auth: "admin"
13396
+ }), method(_void(), BackupEncryptionStatusSchema, { auth: "admin" }), method(object({}), object({
13397
+ keyId: string(),
13398
+ secretKey: string(),
13399
+ publicKey: string(),
13400
+ createdAt: number(),
13401
+ replacedKeyId: string().nullable()
13402
+ }), {
13403
+ kind: "mutation",
13404
+ auth: "admin"
13405
+ }), method(object({}), object({ disabledKeyId: string().nullable() }), {
13406
+ kind: "mutation",
13407
+ auth: "admin"
13408
+ }), method(object({ backupSecretKey: string() }), object({
13409
+ valid: boolean(),
13410
+ keyId: string().nullable(),
13411
+ /** The hub knows this key (active or retired). */
13412
+ known: boolean(),
13413
+ /** It is the key new archives are encrypted to. */
13414
+ active: boolean(),
13415
+ error: string().optional()
13416
+ }), {
13417
+ kind: "mutation",
13418
+ auth: "admin"
11991
13419
  }), method(object({
11992
13420
  destinationId: string(),
11993
13421
  backupId: string()
@@ -13611,7 +15039,60 @@ var CustomModelDescriptorSchema = object({
13611
15039
  stepId: string(),
13612
15040
  entry: ModelCatalogEntrySchema
13613
15041
  });
13614
- method(_void(), array(CustomModelDescriptorSchema).readonly(), { auth: "admin" });
15042
+ /** One regular file of an imported bundle, as the producer measured it. */
15043
+ var ModelBundleFileSchema = object({
15044
+ /** Relative path inside the bundle tar; an mlpackage member is `<x>.mlpackage/<member>`. */
15045
+ path: string().min(1),
15046
+ bytes: number().int().nonnegative(),
15047
+ sha256: string().regex(/^[0-9a-f]{64}$/)
15048
+ });
15049
+ var ImportModelBundleInputSchema = object({
15050
+ /** The registry provider that keeps the model (Model Studio). */
15051
+ addonId: string(),
15052
+ stepId: string().min(1),
15053
+ /**
15054
+ * The catalog rows to register, complete, every format URL already
15055
+ * `camstack-local://<modelId>/<file>` naming a file of the bundle. One
15056
+ * bundle may carry several rows (a base and its INT8 variant).
15057
+ */
15058
+ entries: array(ModelCatalogEntrySchema).min(1).max(4),
15059
+ /** The bundle tar, offered by the producer over `ctx.peerBytes` (same host). */
15060
+ bundle: object({
15061
+ ticket: PeerBytesTicketSchema,
15062
+ bytes: number().int().positive(),
15063
+ sha256: string().regex(/^[0-9a-f]{64}$/)
15064
+ }),
15065
+ /** Every file the tar must hold; anything missing, extra or different is refused. */
15066
+ files: array(ModelBundleFileSchema).min(1).max(64),
15067
+ /** Convert missing engine formats and push the model to every agent afterwards. */
15068
+ distribute: boolean()
15069
+ });
15070
+ var ImportModelBundleResultSchema = discriminatedUnion("kind", [object({
15071
+ kind: literal("imported"),
15072
+ modelIds: array(string()).readonly(),
15073
+ distributed: array(object({
15074
+ modelId: string(),
15075
+ nodeId: string(),
15076
+ format: _enum(MODEL_FORMATS),
15077
+ ok: boolean(),
15078
+ error: string().optional()
15079
+ })).readonly()
15080
+ }), object({
15081
+ kind: literal("refused"),
15082
+ reason: _enum([
15083
+ "transfer-failed",
15084
+ "checksum-mismatch",
15085
+ "bundle-mismatch",
15086
+ "invalid-entry",
15087
+ "id-taken"
15088
+ ]),
15089
+ detail: string()
15090
+ })]);
15091
+ method(_void(), array(CustomModelDescriptorSchema).readonly(), { auth: "admin" }), method(ImportModelBundleInputSchema, ImportModelBundleResultSchema, {
15092
+ kind: "mutation",
15093
+ auth: "admin",
15094
+ timeoutMs: 30 * 6e4
15095
+ });
13615
15096
  /**
13616
15097
  * Query filter for settings-store collections.
13617
15098
  */
@@ -13994,6 +15475,253 @@ id: union([string(), number()]) }), {
13994
15475
  kind: "mutation",
13995
15476
  auth: "admin"
13996
15477
  });
15478
+ /**
15479
+ * `keychain` — the hub's encrypted store of secret values (D787).
15480
+ *
15481
+ * Settings blobs never hold a secret: they hold a marker
15482
+ * `{"$secret":"secret://<owner>/<scope>/<fieldPath>","v":1}` and the value
15483
+ * lives here, AES-256-GCM under a data key that a master key wraps. This cap
15484
+ * is the OWNER's door to its own values: every method is owner-checked
15485
+ * against the CALLER, never against anything the caller claims.
15486
+ *
15487
+ * Who the caller is: the transport stamps `callerAddonId` into the args of a
15488
+ * call that crossed a process (the parent `LocalChildRegistry` from the UDS
15489
+ * connection, the agent from its child's connection carried in
15490
+ * `$hub-cap-fwd`'s envelope). A stamp always overwrites; a wire call with no
15491
+ * stamp has its claim stripped. Only a hub in-process caller may state its own
15492
+ * identity — `ctx.secrets` does that with the addon id closed over. This is
15493
+ * identity against BUGS and misrouting, not against a malicious addon (every
15494
+ * runner is the same OS user): see the threat model in
15495
+ * `docs/design/2026-10-08-secrets-keychain.md`.
15496
+ *
15497
+ * `callerAddonId` is deliberately NOT in any input schema: the tRPC router
15498
+ * parses the input, so a session can never supply it, and the internal mount
15499
+ * floors every method to admin anyway (D240).
15500
+ *
15501
+ * Internal: addons reach it through `ctx.secrets`, never directly.
15502
+ */
15503
+ /** Why a value cannot be served right now. Never folded into "missing". */
15504
+ var KeychainUnavailableReasonSchema = _enum([
15505
+ "key-missing",
15506
+ "wrong-key",
15507
+ "key-file-unreadable",
15508
+ "store-unavailable",
15509
+ "not-initialized",
15510
+ "decrypt-failed"
15511
+ ]);
15512
+ var KeychainStateSchema = discriminatedUnion("state", [object({ state: literal("ready") }), object({
15513
+ state: literal("locked"),
15514
+ reason: KeychainUnavailableReasonSchema
15515
+ })]);
15516
+ var KeychainResolveEntrySchema = discriminatedUnion("kind", [
15517
+ object({
15518
+ kind: literal("value"),
15519
+ value: string(),
15520
+ version: number().int()
15521
+ }),
15522
+ object({ kind: literal("missing") }),
15523
+ object({
15524
+ kind: literal("unavailable"),
15525
+ reason: KeychainUnavailableReasonSchema
15526
+ }),
15527
+ object({ kind: literal("forbidden") })
15528
+ ]);
15529
+ var KeychainResolveResultSchema = record(string(), KeychainResolveEntrySchema);
15530
+ /** Metadata of one stored value — never the value. */
15531
+ var KeychainSecretMetaSchema = object({
15532
+ ref: string(),
15533
+ owner: string(),
15534
+ /** Formatted scope (`global`, `node/<id>`, `device/<id>`, …). */
15535
+ scope: string(),
15536
+ fieldPath: string(),
15537
+ version: number().int(),
15538
+ createdAt: number(),
15539
+ updatedAt: number(),
15540
+ /** `addon:<id>` | `user:<id>` | `system`. */
15541
+ updatedBy: string(),
15542
+ /** Coarse — written at most once an hour per ref. `null` = never read. */
15543
+ lastReadAt: number().nullable()
15544
+ });
15545
+ var RefListSchema = array(string().min(1)).max(512);
15546
+ method(object({
15547
+ ref: string().min(1),
15548
+ value: string().min(1)
15549
+ }), object({
15550
+ ref: string(),
15551
+ version: number().int()
15552
+ }), {
15553
+ kind: "mutation",
15554
+ auth: "admin"
15555
+ }), method(object({ refs: RefListSchema }), KeychainResolveResultSchema, { auth: "admin" }), method(object({ refs: RefListSchema }), object({ deleted: number().int() }), {
15556
+ kind: "mutation",
15557
+ auth: "admin"
15558
+ }), method(object({}), array(KeychainSecretMetaSchema).readonly(), { auth: "admin" }), method(object({}), KeychainStateSchema, { auth: "admin" });
15559
+ var KeychainKeySourceSchema = object({
15560
+ kind: _enum([
15561
+ "config-file",
15562
+ "previous-config-file",
15563
+ "platform",
15564
+ "default-file"
15565
+ ]),
15566
+ /** File sources only — a path is not a secret. */
15567
+ path: string().optional(),
15568
+ /**
15569
+ * True when a whole-volume backup of the data directory carries this key
15570
+ * next to the database it protects (the default file). The page warns.
15571
+ */
15572
+ sharesBackupWithDatabase: boolean()
15573
+ });
15574
+ /**
15575
+ * One keychain reset, as the Secrets page reports it until the operator
15576
+ * acknowledges it. Never a value: refs, counts and table names only.
15577
+ */
15578
+ var KeychainResetRecordSchema = object({
15579
+ id: string(),
15580
+ at: number(),
15581
+ /** `user:<id>` or {@link KEYCHAIN_RESET_TRIGGER_ACTOR}. */
15582
+ actor: string(),
15583
+ /** Why the keychain was locked when it was reset; `null` when it was not locked. */
15584
+ lockedReason: string().nullable(),
15585
+ /** Values moved into the archive table (ciphertext under the lost key). */
15586
+ archived: number().int(),
15587
+ /** `keychain:secrets-orphaned-<ts>`, or `null` when nothing was stored. */
15588
+ archivedCollection: string().nullable(),
15589
+ /**
15590
+ * `keychain:keys-orphaned-<ts>`: the wrapped data keys of the archive, kept
15591
+ * so the archive can still be opened if the lost master key turns up.
15592
+ */
15593
+ archivedKeysCollection: string().nullable(),
15594
+ /**
15595
+ * `system-settings` keys whose marker the reset cleared — the cluster
15596
+ * secret's: a marker left pointing at an archived value would refuse every
15597
+ * agent forever (D797).
15598
+ */
15599
+ clearedSettingsKeys: array(string()).readonly(),
15600
+ /** When an operator dismissed the notice on the Secrets page; `null` until then. */
15601
+ acknowledgedAt: number().nullable()
15602
+ });
15603
+ var KeychainStatusSchema = object({
15604
+ keychain: KeychainStateSchema,
15605
+ /** The source of the master key in use; `null` while locked. */
15606
+ keySource: KeychainKeySourceSchema.nullable(),
15607
+ /** The source configured to be primary — differs from `keySource` while a rotation is pending. */
15608
+ configuredSource: KeychainKeySourceSchema,
15609
+ /** Short fingerprint of the master key in use (`HMAC(KEK, label)`, 16 hex). */
15610
+ fingerprint: string().nullable(),
15611
+ activeKeyId: string().nullable(),
15612
+ /**
15613
+ * The keychain unlocked with a NON-primary source: the configured primary
15614
+ * key is not the one that wraps the data key yet. `rotateMasterKey` moves it.
15615
+ */
15616
+ rotationPending: boolean(),
15617
+ /** Wrapped copies of the data key under a previous master key, kept until purged. */
15618
+ retiredWraps: number().int(),
15619
+ recoveryKeyDownloadedAt: number().nullable(),
15620
+ secretCount: number().int(),
15621
+ /** The most recent reset, acknowledged or not; `null` when the keychain was never reset. */
15622
+ lastReset: KeychainResetRecordSchema.nullable()
15623
+ });
15624
+ /**
15625
+ * Whether a stored value is still pointed at by its owner's settings.
15626
+ * `unknown` is a first-class answer: a scope whose blob could not be read is
15627
+ * never reported as an orphan (and never deleted as one).
15628
+ */
15629
+ var KeychainSecretUsageSchema = _enum([
15630
+ "in-use",
15631
+ "orphan",
15632
+ "unknown"
15633
+ ]);
15634
+ var KeychainAdminSecretSchema = KeychainSecretMetaSchema.extend({ usage: KeychainSecretUsageSchema });
15635
+ var KeychainAuditActionSchema = _enum([
15636
+ "put",
15637
+ "delete",
15638
+ "reveal",
15639
+ "rotate-master-key",
15640
+ "purge-retired-keys",
15641
+ "download-recovery-key",
15642
+ "delete-orphans",
15643
+ "reset",
15644
+ "acknowledge-reset",
15645
+ "initialize"
15646
+ ]);
15647
+ var KeychainAuditEntrySchema = object({
15648
+ id: string(),
15649
+ at: number(),
15650
+ action: KeychainAuditActionSchema,
15651
+ /** `addon:<id>` | `user:<id>` | `system` | `trigger-file`. */
15652
+ actor: string(),
15653
+ ref: string().nullable(),
15654
+ detail: string().nullable()
15655
+ });
15656
+ var KEYCHAIN_RESET_CONFIRMATION = "RESET KEYCHAIN";
15657
+ /**
15658
+ * Secrets the HUB itself holds (owner `system`) that no settings form shows:
15659
+ * `jwt-signing-key` — the session signing key (D797). It is always "in use",
15660
+ * never an orphan; it is generated on a fresh hub and replaced only through
15661
+ * {@link keychainAdminCapability.methods.setSystemSecret}.
15662
+ */
15663
+ var SystemHeldSecretNameSchema = _enum(["jwt-signing-key"]);
15664
+ 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({
15665
+ value: string(),
15666
+ version: number().int()
15667
+ }), {
15668
+ kind: "mutation",
15669
+ auth: "admin",
15670
+ caller: "required"
15671
+ }), method(object({
15672
+ name: SystemHeldSecretNameSchema,
15673
+ value: string().min(16)
15674
+ }), object({
15675
+ ref: string(),
15676
+ version: number().int()
15677
+ }), {
15678
+ kind: "mutation",
15679
+ auth: "admin",
15680
+ caller: "required"
15681
+ }), method(object({ refs: array(string().min(1)).max(1e3) }), object({
15682
+ deleted: array(string()).readonly(),
15683
+ kept: array(object({
15684
+ ref: string(),
15685
+ usage: KeychainSecretUsageSchema
15686
+ })).readonly()
15687
+ }), {
15688
+ kind: "mutation",
15689
+ auth: "admin",
15690
+ caller: "required"
15691
+ }), method(object({}), object({
15692
+ fingerprint: string(),
15693
+ keySource: KeychainKeySourceSchema
15694
+ }), {
15695
+ kind: "mutation",
15696
+ auth: "admin",
15697
+ caller: "required"
15698
+ }), method(object({}), object({ purged: number().int() }), {
15699
+ kind: "mutation",
15700
+ auth: "admin",
15701
+ caller: "required"
15702
+ }), method(object({}), object({
15703
+ key: string(),
15704
+ fingerprint: string(),
15705
+ keySource: KeychainKeySourceSchema
15706
+ }), {
15707
+ kind: "mutation",
15708
+ auth: "admin",
15709
+ caller: "required"
15710
+ }), method(object({ confirm: literal(KEYCHAIN_RESET_CONFIRMATION) }), object({
15711
+ archivedCollection: string().nullable(),
15712
+ archived: number().int()
15713
+ }), {
15714
+ kind: "mutation",
15715
+ auth: "admin",
15716
+ caller: "required"
15717
+ }), method(object({}), object({
15718
+ reset: KeychainResetRecordSchema.nullable(),
15719
+ pendingReentry: array(KeychainSecretMetaSchema).readonly()
15720
+ }), { auth: "admin" }), method(object({}), object({ acknowledged: boolean() }), {
15721
+ kind: "mutation",
15722
+ auth: "admin",
15723
+ caller: "required"
15724
+ });
13997
15725
  method(_void(), object({
13998
15726
  id: string(),
13999
15727
  name: string(),
@@ -15031,7 +16759,11 @@ var DeviceRegisterPayloadSchema = object({
15031
16759
  var DeviceRemovePayloadSchema = object({ deviceId: number() });
15032
16760
  var DevicePersistConfigPayloadSchema = object({
15033
16761
  deviceId: number(),
15034
- data: record(string(), unknown())
16762
+ data: record(string(), unknown()),
16763
+ /** The paths the device's schema declares secret (D783), when the caller
16764
+ * knows them — those values are kept in the keychain, not the blob (D787).
16765
+ * Absent: the paths the device last reported at `registerDevice` apply. */
16766
+ secretConfigPaths: array(string()).optional()
15035
16767
  });
15036
16768
  /** What a migration actually did, per switch. `unreachable` is a first-class
15037
16769
  * answer: a camera that could not be asked is not a camera that was silenced. */
@@ -16634,7 +18366,7 @@ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
16634
18366
  * `login-method` — collection cap through which auth addons contribute
16635
18367
  * their pre-auth login surfaces to the login page. This is the SINGLE,
16636
18368
  * generic mechanism that supersedes the dead `auth.listProviders` reader:
16637
- * every auth addon (OIDC, magic-link, WebAuthn/passkey) registers a
18369
+ * every auth addon (OIDC, WebAuthn/passkey) registers a
16638
18370
  * `login-method` provider and the PUBLIC `auth.listLoginMethods`
16639
18371
  * procedure aggregates them for the unauthenticated login page.
16640
18372
  *
@@ -16642,8 +18374,7 @@ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
16642
18374
  *
16643
18375
  * - `redirect` — a declarative button. The login page renders a generic
16644
18376
  * button that navigates to `startUrl` (an addon-owned HTTP route).
16645
- * Covers OIDC (`/addon/auth-oidc/<id>/start`) and magic-link with
16646
- * ZERO shell-side JS. A future SSO addon plugs in the same way — the
18377
+ * Covers OIDC (`/addon/auth-oidc/<id>/start`) with ZERO shell-side JS. A future SSO addon plugs in the same way — the
16647
18378
  * login page needs NO change.
16648
18379
  *
16649
18380
  * - `widget` — a Module-Federation widget the login page mounts (via
@@ -16662,8 +18393,8 @@ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
16662
18393
  * decision.
16663
18394
  *
16664
18395
  * Every contribution carries a `stage`:
16665
- * - `primary` — shown on the first credentials screen (OIDC /
16666
- * magic-link buttons; a future usernameless passkey).
18396
+ * - `primary` — shown on the first credentials screen (OIDC
18397
+ * buttons; a usernameless passkey).
16667
18398
  * - `second-factor` — shown AFTER the password leg, gated on the
16668
18399
  * returned `factors` (passkey-as-2FA today).
16669
18400
  *
@@ -16690,7 +18421,7 @@ var LoginMethodContributionSchema = discriminatedUnion("kind", [
16690
18421
  * The provider names an external identity a signed-in user can link to
16691
18422
  * their own account (D782): `auth.listLinkableProviders` /
16692
18423
  * `beginExternalLink` offer exactly the redirect methods that set this,
16693
- * whatever their id. Absent / false — a login button only (magic-link).
18424
+ * whatever their id. Absent / false — a login button only.
16694
18425
  */
16695
18426
  linkable: boolean().optional()
16696
18427
  }),
@@ -20524,8 +22255,7 @@ method(object({}), object({ rules: array(NcRuleSchema) }), { auth: "admin" }), m
20524
22255
  * `super_admin` — collapsed onto the single boolean because every
20525
22256
  * non-admin caller is governed by the same scope-check rules; the
20526
22257
  * distinction was only ever used to route role-specific procedures
20527
- * which we no longer have. Agents are admin sessions issued via
20528
- * `createServiceToken`; CLI / webhook integrations are `cst_*` tokens
22258
+ * which we no longer have. CLI / webhook integrations are `cst_*` tokens
20529
22259
  * with `isAdmin: false` + an explicit scope list.
20530
22260
  */
20531
22261
  /** Per-method access flavour. Materialised on every cap method via codegen. */
@@ -22027,8 +23757,23 @@ var RetrainMacroClassSchema = _enum([
22027
23757
  ]);
22028
23758
  /** A subject to learn, or a phantom to unlearn (taught by OMISSION). */
22029
23759
  var RetrainAnnotationKindSchema = _enum(["subject", "model_error"]);
22030
- /** Did a human draw this box, or did the assist propose it? */
22031
- var RetrainAnnotationSourceSchema = _enum(["operator", "assist"]);
23760
+ /**
23761
+ * Where a box came from. A machine-sourced box is a DRAFT on the page until
23762
+ * the operator confirms it; once saved it keeps its source as provenance.
23763
+ *
23764
+ * - `operator` — drawn by hand.
23765
+ * - `assist` — proposed by a detector run on the copy (the camera's own
23766
+ * model, or a larger teacher model).
23767
+ * - `pipeline` — the box the live pipeline actually drew on that frame, read
23768
+ * back from the track store (never a re-run).
23769
+ * - `llm` — proposed by a vision-capable LLM profile.
23770
+ */
23771
+ var RetrainAnnotationSourceSchema = _enum([
23772
+ "operator",
23773
+ "assist",
23774
+ "pipeline",
23775
+ "llm"
23776
+ ]);
22032
23777
  /** Normalised `[0,1]` rectangle against the FULL frame — the canonical form. */
22033
23778
  var RetrainBboxSchema = object({
22034
23779
  x: number(),
@@ -22046,7 +23791,8 @@ var RetrainBboxSchema = object({
22046
23791
  */
22047
23792
  var RetrainAnnotationSchema = object({
22048
23793
  id: string(),
22049
- trackId: string(),
23794
+ /** The frame's track. Absent on a recording still, which has none. */
23795
+ trackId: string().optional(),
22050
23796
  deviceId: number(),
22051
23797
  /** The COPY in retrain storage — never the source track's media key. */
22052
23798
  mediaKey: string(),
@@ -22095,13 +23841,47 @@ var RetrainFrameCandidateSchema = object({
22095
23841
  * fail, whatever became of the original. */
22096
23842
  copied: boolean()
22097
23843
  });
23844
+ /**
23845
+ * One box the live pipeline drew on a copied frame — what a correction starts
23846
+ * from. Derived when the frame is listed, from the track store: the subject
23847
+ * box recorded on the source media row when there is one, else the track
23848
+ * position nearest the frame's capture time. Never stored as an annotation
23849
+ * until the operator confirms it.
23850
+ */
23851
+ var RetrainPipelineBoxSchema = object({
23852
+ /** Normalised `[0,1]` against the full frame. */
23853
+ bbox: RetrainBboxSchema,
23854
+ macroClass: RetrainMacroClassSchema,
23855
+ label: string().optional(),
23856
+ subLabel: string().optional(),
23857
+ /** The detection score of the position used, when it was recorded. */
23858
+ score: number().optional(),
23859
+ /** The root model that produced the track, when it was recorded. */
23860
+ modelId: string().optional(),
23861
+ trackId: string(),
23862
+ /** `subject-box`: recorded on this very frame. `position`: the track's
23863
+ * position nearest the capture time, `deltaMs` away. */
23864
+ basis: _enum(["subject-box", "position"]),
23865
+ deltaMs: number()
23866
+ });
23867
+ /**
23868
+ * Where a retrain frame came from: a TRACK's stored media (copy-on-select),
23869
+ * or the RECORDING at an instant — the frame a model saw nothing in has no
23870
+ * track at all.
23871
+ */
23872
+ var RetrainFrameOriginSchema = _enum(["track", "recording"]);
22098
23873
  /** A frame the dataset OWNS: bytes copied at selection time. */
22099
23874
  var RetrainFrameSchema = object({
22100
23875
  frameId: string(),
22101
23876
  deviceId: number(),
22102
- trackId: string(),
22103
- /** Provenance only. It may already point at nothing — that is expected. */
22104
- sourceMediaId: number().int(),
23877
+ origin: RetrainFrameOriginSchema,
23878
+ /** The track it was copied from. Absent on a recording still. */
23879
+ trackId: string().optional(),
23880
+ /** Provenance only. It may already point at nothing — that is expected.
23881
+ * Absent on a recording still. */
23882
+ sourceMediaId: number().int().optional(),
23883
+ /** A recording still: the playhead instant it was taken at. */
23884
+ epochMs: number().optional(),
22105
23885
  sourceKind: MediaFileKindEnum,
22106
23886
  sizeBytes: number().int(),
22107
23887
  width: number().int(),
@@ -22112,7 +23892,12 @@ var RetrainFrameSchema = object({
22112
23892
  /** The operator's "every subject in this frame is boxed". Detector
22113
23893
  * evaluation keeps only complete frames: an unboxed subject would count as
22114
23894
  * a false positive. */
22115
- complete: boolean()
23895
+ complete: boolean(),
23896
+ /** The boxes the pipeline drew on this frame. Present on list answers;
23897
+ * empty when nothing the track store holds can be placed on it. */
23898
+ pipelineBoxes: array(RetrainPipelineBoxSchema).readonly().optional(),
23899
+ /** The named collections this frame belongs to. Present on list answers. */
23900
+ collectionIds: array(string()).readonly().optional()
22116
23901
  });
22117
23902
  /** Why a copy-on-select could not be honoured — named, never a silent skip. */
22118
23903
  var RetrainCopyRefusalSchema = _enum([
@@ -22143,6 +23928,11 @@ var RetrainFrameListSchema = object({
22143
23928
  var RetrainExportFilterSchema = object({
22144
23929
  deviceIds: array(number()).optional(),
22145
23930
  frameIds: array(string()).max(2e4).optional(),
23931
+ /** Only frames in at least one of these named collections. */
23932
+ collectionIds: array(string()).max(200).optional(),
23933
+ /** Exactly the frames of this dataset version (and its completeOnly). An
23934
+ * unknown id selects nothing. */
23935
+ datasetVersionId: string().optional(),
22146
23936
  batchId: string().optional(),
22147
23937
  /** Only frames the operator marked complete (all subjects boxed). */
22148
23938
  completeOnly: boolean().optional()
@@ -22207,6 +23997,170 @@ var RetrainAssistResultSchema = discriminatedUnion("kind", [object({
22207
23997
  reason: string(),
22208
23998
  detail: string().optional()
22209
23999
  })]);
24000
+ /** A named set over the retrain corpus — membership only, it owns no pixels. */
24001
+ var RetrainCollectionSchema = object({
24002
+ id: string(),
24003
+ name: string(),
24004
+ createdAt: number(),
24005
+ frameCount: number().int()
24006
+ });
24007
+ var RetrainCollectionCreateResultSchema = discriminatedUnion("kind", [object({
24008
+ kind: literal("created"),
24009
+ collection: RetrainCollectionSchema
24010
+ }), object({
24011
+ kind: literal("refused"),
24012
+ reason: _enum(["empty-name", "duplicate-name"])
24013
+ })]);
24014
+ var RetrainCollectionRenameResultSchema = discriminatedUnion("kind", [object({
24015
+ kind: literal("renamed"),
24016
+ collection: RetrainCollectionSchema
24017
+ }), object({
24018
+ kind: literal("refused"),
24019
+ reason: _enum([
24020
+ "empty-name",
24021
+ "duplicate-name",
24022
+ "unknown-collection"
24023
+ ])
24024
+ })]);
24025
+ /**
24026
+ * The outcome of adding the frame at a recording instant. Every refusal is
24027
+ * named: `still-unavailable` (not recording, a gap, or an undecodable frame —
24028
+ * `detail` says which), `still-busy` (the recorder is at its decode bound; try
24029
+ * again), `unreadable-image`, `write-failed`, `unknown-collection`.
24030
+ */
24031
+ var AddRetrainFrameFromRecordingResultSchema = discriminatedUnion("kind", [object({
24032
+ kind: literal("added"),
24033
+ collectionId: string(),
24034
+ frame: RetrainFrameSchema,
24035
+ /** The moment was already in the dataset; nothing was decoded. */
24036
+ reused: boolean()
24037
+ }), object({
24038
+ kind: literal("refused"),
24039
+ reason: _enum([
24040
+ "unknown-collection",
24041
+ "still-unavailable",
24042
+ "still-busy",
24043
+ "unreadable-image",
24044
+ "write-failed"
24045
+ ]),
24046
+ detail: string().optional()
24047
+ })]);
24048
+ /** A vision LLM profile the AI assist may use, and where it sends the frame. */
24049
+ var RetrainAssistProfileSchema = object({
24050
+ id: string(),
24051
+ name: string(),
24052
+ model: string(),
24053
+ kind: string(),
24054
+ /** `true` when the frame would leave the house (a cloud vendor, or an
24055
+ * endpoint that is not on the local network). The page confirms each such
24056
+ * run, and the provider refuses one without `allowCloud`. */
24057
+ leavesHouse: boolean()
24058
+ });
24059
+ /** A box the AI assist proposed: a draft, plus the model's own reason. */
24060
+ var RetrainLlmProposalSchema = RetrainAnnotationDraftSchema.extend({ reason: string() });
24061
+ /** What the AI assist said about a box that was already on the canvas. */
24062
+ var RetrainLlmReviewSchema = object({
24063
+ /** The `ref` the page sent the box under. */
24064
+ ref: string(),
24065
+ verdict: _enum([
24066
+ "confirmed",
24067
+ "wrong-class",
24068
+ "not-an-object",
24069
+ "uncertain"
24070
+ ]),
24071
+ suggestedClass: RetrainMacroClassSchema.optional(),
24072
+ reason: string()
24073
+ });
24074
+ /**
24075
+ * The AI assist's answer. `proposed` carries drafts (`source: 'llm'`, the
24076
+ * model and its confidence) and reviews; items the model got wrong (a box off
24077
+ * the frame, an unasked class, an unknown ref) are dropped and counted in
24078
+ * `rejected`. A whole answer that is not the schema is `malformed-answer`.
24079
+ */
24080
+ var RetrainLlmAssistResultSchema = discriminatedUnion("kind", [object({
24081
+ kind: literal("proposed"),
24082
+ profileId: string(),
24083
+ model: string(),
24084
+ /** The frame was sent outside the house for this answer. */
24085
+ leftHouse: boolean(),
24086
+ proposals: array(RetrainLlmProposalSchema).readonly(),
24087
+ reviews: array(RetrainLlmReviewSchema).readonly(),
24088
+ rejected: number().int()
24089
+ }), object({
24090
+ kind: literal("refused"),
24091
+ reason: _enum([
24092
+ "unknown-frame",
24093
+ "unreadable-frame",
24094
+ "unknown-profile",
24095
+ "profile-disabled",
24096
+ "no-vision",
24097
+ "cloud-not-confirmed",
24098
+ "llm-error",
24099
+ "malformed-answer"
24100
+ ]),
24101
+ detail: string().optional()
24102
+ })]);
24103
+ /** What a dataset version is cut from. Every field narrows. */
24104
+ var RetrainDatasetSelectionSchema = object({
24105
+ deviceIds: array(number()).readonly().optional(),
24106
+ collectionIds: array(string()).max(200).readonly().optional(),
24107
+ frameIds: array(string()).max(2e4).readonly().optional()
24108
+ });
24109
+ /** The counts a dataset is judged by. */
24110
+ var RetrainDatasetStatsSchema = object({
24111
+ frames: number().int(),
24112
+ completeFrames: number().int(),
24113
+ /** `completeFrames / frames`, 0..1. */
24114
+ completeness: number(),
24115
+ /** Boxes to learn (model errors excluded). */
24116
+ subjects: number().int(),
24117
+ modelErrors: number().int(),
24118
+ /** Complete frames with no subject. */
24119
+ hardNegatives: number().int(),
24120
+ /** Subjects per class × camera × day/night. */
24121
+ cells: array(object({
24122
+ macroClass: string(),
24123
+ deviceId: number(),
24124
+ lighting: _enum([
24125
+ "day",
24126
+ "night",
24127
+ "unknown"
24128
+ ]),
24129
+ subjects: number().int(),
24130
+ frames: number().int()
24131
+ })).readonly(),
24132
+ cameras: array(object({
24133
+ deviceId: number(),
24134
+ frames: number().int(),
24135
+ completeFrames: number().int()
24136
+ })).readonly()
24137
+ });
24138
+ /** An immutable dataset version, without its frame list. */
24139
+ var RetrainDatasetVersionSchema = object({
24140
+ id: string(),
24141
+ name: string(),
24142
+ createdAt: number(),
24143
+ selection: RetrainDatasetSelectionSchema,
24144
+ layout: RetrainExportLayoutSchema,
24145
+ completeOnly: boolean(),
24146
+ frameCount: number().int(),
24147
+ /** sha256 of what the frames taught when the version was frozen. */
24148
+ annotationHash: string(),
24149
+ /** The export manifest schema the version was cut under. */
24150
+ manifestSchema: string(),
24151
+ stats: RetrainDatasetStatsSchema
24152
+ });
24153
+ var CreateRetrainDatasetVersionResultSchema = discriminatedUnion("kind", [object({
24154
+ kind: literal("created"),
24155
+ version: RetrainDatasetVersionSchema
24156
+ }), object({
24157
+ kind: literal("refused"),
24158
+ reason: _enum([
24159
+ "empty-name",
24160
+ "duplicate-name",
24161
+ "no-frames"
24162
+ ])
24163
+ })]);
22210
24164
  /** The outcome of a lifecycle move owned by the retrain page. */
22211
24165
  var RetrainTransitionResultSchema = object({
22212
24166
  trackId: string(),
@@ -22924,7 +24878,7 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
22924
24878
  auth: "admin"
22925
24879
  }), method(object({
22926
24880
  deviceId: number(),
22927
- trackId: string(),
24881
+ trackId: string().optional(),
22928
24882
  frameId: string()
22929
24883
  }), object({
22930
24884
  removed: boolean(),
@@ -22941,7 +24895,8 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
22941
24895
  auth: "admin"
22942
24896
  }), method(object({
22943
24897
  deviceId: number(),
22944
- trackId: string(),
24898
+ /** The frame's track, when it has one — checked against the frame. */
24899
+ trackId: string().optional(),
22945
24900
  frameId: string(),
22946
24901
  subject: RetrainAssistSubjectSchema,
22947
24902
  /** Which node runs it. Absent ⇒ wherever an unowned call lands. */
@@ -22949,12 +24904,16 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
22949
24904
  }), RetrainAssistResultSchema, {
22950
24905
  kind: "mutation",
22951
24906
  auth: "admin"
22952
- }), method(object({ trackId: string() }), array(RetrainAnnotationSchema).readonly(), {
24907
+ }), method(object({
24908
+ trackId: string().optional(),
24909
+ frameIds: array(string()).max(2e3).optional()
24910
+ }), array(RetrainAnnotationSchema).readonly(), {
22953
24911
  kind: "query",
22954
24912
  auth: "admin"
22955
24913
  }), method(object({
22956
24914
  deviceId: number(),
22957
- trackId: string(),
24915
+ /** The frame's track, when it has one — checked against the frame. */
24916
+ trackId: string().optional(),
22958
24917
  frameId: string(),
22959
24918
  annotations: array(RetrainAnnotationDraftSchema)
22960
24919
  }), array(RetrainAnnotationSchema).readonly(), {
@@ -22977,7 +24936,7 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
22977
24936
  auth: "admin"
22978
24937
  }), method(object({
22979
24938
  deviceId: number(),
22980
- trackId: string(),
24939
+ trackId: string().optional(),
22981
24940
  frameId: string(),
22982
24941
  complete: boolean()
22983
24942
  }), RetrainFrameSchema, {
@@ -22991,6 +24950,115 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
22991
24950
  kind: "mutation",
22992
24951
  auth: "admin",
22993
24952
  timeoutMs: 60 * 6e4
24953
+ }), method(object({
24954
+ filter: RetrainExportFilterSchema,
24955
+ layout: RetrainExportLayoutSchema
24956
+ }), object({
24957
+ ticket: PeerBytesTicketSchema,
24958
+ frames: number().int(),
24959
+ annotations: number().int()
24960
+ }), {
24961
+ kind: "mutation",
24962
+ auth: "admin",
24963
+ timeoutMs: 12e4
24964
+ }), method(object({
24965
+ selection: RetrainDatasetSelectionSchema,
24966
+ completeOnly: boolean().optional()
24967
+ }), RetrainDatasetStatsSchema, {
24968
+ kind: "query",
24969
+ auth: "admin"
24970
+ }), method(object({
24971
+ name: string().max(120),
24972
+ selection: RetrainDatasetSelectionSchema,
24973
+ layout: RetrainExportLayoutSchema,
24974
+ completeOnly: boolean()
24975
+ }), CreateRetrainDatasetVersionResultSchema, {
24976
+ kind: "mutation",
24977
+ auth: "admin",
24978
+ timeoutMs: 12e4
24979
+ }), method(object({}), array(RetrainDatasetVersionSchema).readonly(), {
24980
+ kind: "query",
24981
+ auth: "admin"
24982
+ }), method(object({ id: string() }), object({ deleted: boolean() }), {
24983
+ kind: "mutation",
24984
+ auth: "admin"
24985
+ }), method(object({ id: string() }), object({
24986
+ found: boolean(),
24987
+ annotationHash: string(),
24988
+ matches: boolean(),
24989
+ missingFrames: number().int()
24990
+ }), {
24991
+ kind: "query",
24992
+ auth: "admin",
24993
+ timeoutMs: 12e4
24994
+ }), method(object({}), array(RetrainAssistProfileSchema).readonly(), {
24995
+ kind: "query",
24996
+ auth: "admin"
24997
+ }), method(object({
24998
+ deviceId: number(),
24999
+ trackId: string().optional(),
25000
+ frameId: string(),
25001
+ profileId: string(),
25002
+ classes: array(RetrainMacroClassSchema).min(1),
25003
+ boxes: array(object({
25004
+ ref: string(),
25005
+ bbox: RetrainBboxSchema,
25006
+ macroClass: RetrainMacroClassSchema,
25007
+ label: string().optional()
25008
+ })).max(50),
25009
+ allowCloud: boolean()
25010
+ }), RetrainLlmAssistResultSchema, {
25011
+ kind: "mutation",
25012
+ auth: "admin",
25013
+ timeoutMs: 18e4
25014
+ }), method(object({ name: string().max(120) }), RetrainCollectionCreateResultSchema, {
25015
+ kind: "mutation",
25016
+ auth: "admin"
25017
+ }), method(object({}), array(RetrainCollectionSchema).readonly(), {
25018
+ kind: "query",
25019
+ auth: "admin"
25020
+ }), method(object({
25021
+ id: string(),
25022
+ name: string().max(120)
25023
+ }), RetrainCollectionRenameResultSchema, {
25024
+ kind: "mutation",
25025
+ auth: "admin"
25026
+ }), method(object({ id: string() }), object({
25027
+ deleted: boolean(),
25028
+ removedFrames: number().int()
25029
+ }), {
25030
+ kind: "mutation",
25031
+ auth: "admin"
25032
+ }), method(object({
25033
+ collectionId: string(),
25034
+ deviceId: number(),
25035
+ epochMs: number()
25036
+ }), AddRetrainFrameFromRecordingResultSchema, {
25037
+ kind: "mutation",
25038
+ auth: "admin",
25039
+ timeoutMs: 6e4
25040
+ }), method(object({
25041
+ collectionId: string(),
25042
+ frameIds: array(string()).min(1).max(500)
25043
+ }), object({
25044
+ added: number().int(),
25045
+ alreadyMember: number().int(),
25046
+ unknownFrameIds: array(string()).readonly()
25047
+ }), {
25048
+ kind: "mutation",
25049
+ auth: "admin"
25050
+ }), method(object({
25051
+ collectionId: string(),
25052
+ frameId: string()
25053
+ }), object({
25054
+ removed: boolean(),
25055
+ deletedFrame: boolean()
25056
+ }), {
25057
+ kind: "mutation",
25058
+ auth: "admin"
25059
+ }), method(object({ collectionId: string() }), array(RetrainFrameSchema).readonly(), {
25060
+ kind: "query",
25061
+ auth: "admin"
22994
25062
  }), method(object({
22995
25063
  /** Which of the three event tables owns the row. */
22996
25064
  ownerType: EventOwnerTypeSchema,
@@ -23614,13 +25682,31 @@ var RecommendationReasonSchema = discriminatedUnion("kind", [
23614
25682
  object({
23615
25683
  kind: literal("no-family-build"),
23616
25684
  format: ModelFormatSchema$1
25685
+ }),
25686
+ object({
25687
+ kind: literal("kept-custom-pin"),
25688
+ modelId: string(),
25689
+ deviceKey: string()
23617
25690
  })
23618
25691
  ]);
25692
+ /** Why a device is left exactly as it is, whatever the plan would pick (D786). */
25693
+ var KeptReasonSchema = _enum(["custom-pin"]);
25694
+ /**
25695
+ * Where a choice's latency came from (D791): this node's own benchmark
25696
+ * result, or the hardware-class table. Measured on the node beats the table.
25697
+ */
25698
+ var LatencySourceSchema = discriminatedUnion("kind", [object({ kind: literal("table") }), object({
25699
+ kind: literal("node-benchmark"),
25700
+ resultId: string(),
25701
+ measuredAtMs: number()
25702
+ })]);
23619
25703
  var DeviceModelChoiceSchema = object({
23620
25704
  modelId: string(),
23621
25705
  p50Ms: number(),
23622
25706
  fps: number(),
23623
25707
  measured: boolean(),
25708
+ /** Absent on a plan from before D791 — read as the table. */
25709
+ source: LatencySourceSchema.optional(),
23624
25710
  /** Parallel sessions at the camera rate with the headroom kept free: ⌊fps × (1 − headroom) / camera fps⌋. */
23625
25711
  capacitySessions: number(),
23626
25712
  personRecall: number()
@@ -23631,6 +25717,8 @@ var DeviceRecommendationSchema = object({
23631
25717
  enabled: boolean(),
23632
25718
  available: boolean(),
23633
25719
  chosen: DeviceModelChoiceSchema.nullable(),
25720
+ /** Present when the device is kept as is: Apply writes nothing on it. */
25721
+ kept: KeptReasonSchema.optional(),
23634
25722
  reasons: array(RecommendationReasonSchema).readonly()
23635
25723
  });
23636
25724
  var NodeRecommendationSchema = object({
@@ -23684,6 +25772,17 @@ var AutoTuneWarningSchema = discriminatedUnion("kind", [
23684
25772
  kind: literal("coral-enabled"),
23685
25773
  nodeId: string(),
23686
25774
  deviceKey: string()
25775
+ }),
25776
+ object({
25777
+ kind: literal("custom-pin-kept"),
25778
+ nodeId: string(),
25779
+ deviceKey: string().nullable(),
25780
+ deviceId: number().nullable(),
25781
+ modelId: string()
25782
+ }),
25783
+ object({
25784
+ kind: literal("custom-registry-unreadable"),
25785
+ error: string()
23687
25786
  })
23688
25787
  ]);
23689
25788
  var AutoTuneOptionsSchema = object({
@@ -23862,13 +25961,14 @@ var SuggestSharesResultSchema = object({
23862
25961
  nodes: array(SuggestedNodeShareSchema).readonly()
23863
25962
  });
23864
25963
  /**
23865
- * Where the node and device shares come from (D750, D755).
23866
- * - `hardware` (default) — computed by the system from each node's static
23867
- * capacity (its accelerators at their Auto tune models, from the measured
23868
- * latency table), recomputed whenever a node or device joins, leaves, is
23869
- * switched on or off, or changes model. No load input.
23870
- * - `benchmark` — the same, from each node's measured capacity (node
23871
- * benchmark results); a node without results falls back to `hardware`.
25964
+ * Where the node and device shares come from (D750, D755, D791).
25965
+ * - `benchmark` (default since D791) — each node's capacity as its own node
25966
+ * benchmark measured it; a node without fresh results is sized from
25967
+ * `hardware` and says so. Measured on the node beats the table.
25968
+ * - `hardware` — computed from each node's static capacity only (its
25969
+ * accelerators at their Auto tune models, from the latency table).
25970
+ * Both are recomputed whenever a node or device joins, leaves, is switched
25971
+ * on or off, changes model, or a benchmark result is written. No load input.
23872
25972
  * - `manual` — the operator's stored sliders.
23873
25973
  * Either way a node or device that cannot take sessions gives its share to
23874
25974
  * the others in proportion; the stored values are never rewritten for that.
@@ -23917,6 +26017,362 @@ var EffectiveSharesSchema = object({
23917
26017
  nodeWeights: record(string(), number()),
23918
26018
  deviceWeights: record(string(), record(string(), number()))
23919
26019
  });
26020
+ /**
26021
+ * Wire shapes of the node benchmark (D791): the operator's plan, the
26022
+ * preflight the confirmation shows, the run the orchestrator owns, what the
26023
+ * measuring runner reports, and the result rows Auto tune and the automatic
26024
+ * shares read.
26025
+ *
26026
+ * ONE node at a time, owned by the pipeline orchestrator. While a run is
26027
+ * active the cluster is in BENCHMARK MODE for that node: it is not a
26028
+ * detection candidate, camera pins naming it are ignored so its sessions move
26029
+ * elsewhere, and both come back when the mode ends — after a crash or a hub
26030
+ * restart too (a persisted manifest, reconciled against the registry).
26031
+ *
26032
+ * Two measurements, both on the node, driven by its own runner (frames never
26033
+ * cross a process at frame rate, D9):
26034
+ * - `device` — one accelerator × one candidate detector, root only, open
26035
+ * loop: how many streams at the camera rate it carries inside the frame
26036
+ * interval;
26037
+ * - `pipeline` — the chosen detector plus the operator's detail steps
26038
+ * (faces, plates, classifiers, CLIP…), on varied frames from the bench
26039
+ * clip: how many parallel sessions the node carries before latency, drops,
26040
+ * CPU, RAM or the event loop give out.
26041
+ */
26042
+ /** Defaults and bounds, one place. */
26043
+ var NODE_BENCHMARK_DEFAULTS = {
26044
+ fpsPerStream: 10,
26045
+ budgetMinutes: 45,
26046
+ minBudgetMinutes: 10,
26047
+ maxBudgetMinutes: 120,
26048
+ /** A result older than this no longer beats the table. */
26049
+ staleAfterDays: 30,
26050
+ /** Warm-in per ramp step (not accounted). */
26051
+ settleSec: 5,
26052
+ /** Accounted window per ramp step. */
26053
+ measureSec: 20,
26054
+ /** Longest the drain may take before the run is refused. */
26055
+ drainTimeoutSec: 120,
26056
+ /** Candidate models per device in one run. */
26057
+ maxModelsPerDevice: 6
26058
+ };
26059
+ /** The two measurements a run can make. */
26060
+ var NodeBenchmarkPhaseSchema = _enum(["device", "pipeline"]);
26061
+ var NodeBenchmarkDevicePlanSchema = object({
26062
+ /** `<backend>:<device>` — `openvino:npu`, `coreml:all`, `cpu`. */
26063
+ deviceKey: string().min(1),
26064
+ /**
26065
+ * Root detector candidates for the `device` measurement, in the order
26066
+ * measured. The FIRST is the one the `pipeline` measurement runs.
26067
+ */
26068
+ modelIds: array(string().min(1)).min(1).max(NODE_BENCHMARK_DEFAULTS.maxModelsPerDevice)
26069
+ });
26070
+ /** What the operator confirmed. */
26071
+ var NodeBenchmarkPlanSchema = object({
26072
+ nodeId: string().min(1),
26073
+ devices: array(NodeBenchmarkDevicePlanSchema).min(1),
26074
+ /** Which measurements run. At least one. */
26075
+ phases: array(NodeBenchmarkPhaseSchema).min(1).default(["device", "pipeline"]),
26076
+ /**
26077
+ * Detail steps (catalog step ids under the root: faces, plates,
26078
+ * classifiers, CLIP…) the `pipeline` measurement enables. The root
26079
+ * detector always runs.
26080
+ */
26081
+ steps: array(string().min(1)).default([]),
26082
+ /** Offered rate of one stream / session. */
26083
+ fpsPerStream: number().int().min(1).max(30).default(NODE_BENCHMARK_DEFAULTS.fpsPerStream),
26084
+ /** Hard deadline: the mode ends and the cluster is restored when it passes. */
26085
+ budgetMinutes: number().int().min(NODE_BENCHMARK_DEFAULTS.minBudgetMinutes).max(NODE_BENCHMARK_DEFAULTS.maxBudgetMinutes).default(NODE_BENCHMARK_DEFAULTS.budgetMinutes),
26086
+ /** Keep the models the run downloaded (default: delete what was not installed before). */
26087
+ keepDownloadedModels: boolean().default(false),
26088
+ /** Start although the other nodes' capacity does not cover the sessions running now. */
26089
+ acceptInsufficientHeadroom: boolean().default(false)
26090
+ });
26091
+ var NodeBenchmarkRefusalSchema = object({
26092
+ kind: _enum([
26093
+ "benchmark-active",
26094
+ "node-offline",
26095
+ "unknown-device",
26096
+ "no-phase",
26097
+ "insufficient-headroom"
26098
+ ]),
26099
+ detail: string(),
26100
+ overridable: boolean()
26101
+ });
26102
+ /** A camera whose detection leaves the node for the run. */
26103
+ var NodeBenchmarkMovingCameraSchema = object({
26104
+ deviceId: number(),
26105
+ /** Placed on the node now (a standing attach or a running session). */
26106
+ placedOnNode: boolean(),
26107
+ /** A node pin naming this node, ignored for the run. */
26108
+ pinnedToNode: boolean()
26109
+ });
26110
+ /** A camera that cannot leave: no other node can obtain its frames. */
26111
+ var NodeBenchmarkStayingCameraSchema = object({
26112
+ deviceId: number(),
26113
+ reason: literal("only-frame-source")
26114
+ });
26115
+ var NodeBenchmarkPreflightSchema = object({
26116
+ nodeId: string(),
26117
+ online: boolean(),
26118
+ moving: array(NodeBenchmarkMovingCameraSchema).readonly(),
26119
+ /** Keep running on the node during the run; the result is flagged contaminated. */
26120
+ staying: array(NodeBenchmarkStayingCameraSchema).readonly(),
26121
+ estimatedDurationMs: number(),
26122
+ /** The run ends and the cluster is restored at the latest after this long. */
26123
+ budgetMs: number(),
26124
+ phases: array(NodeBenchmarkPhaseSchema).readonly(),
26125
+ steps: array(string()).readonly(),
26126
+ devices: array(NodeBenchmarkDevicePlanSchema).readonly(),
26127
+ /** Parallel sessions the cluster runs now, and what the other nodes can carry. */
26128
+ headroom: object({
26129
+ sessionsNow: number(),
26130
+ otherNodesCapacitySessions: number().nullable()
26131
+ }),
26132
+ refusals: array(NodeBenchmarkRefusalSchema).readonly(),
26133
+ canStart: boolean()
26134
+ });
26135
+ /** Where the measuring runner is. */
26136
+ var NodeBenchProgressSchema = object({
26137
+ phase: _enum([
26138
+ "preparing",
26139
+ "device",
26140
+ "pipeline",
26141
+ "cleanup"
26142
+ ]),
26143
+ deviceKey: string().nullable(),
26144
+ modelId: string().nullable(),
26145
+ /** Streams (device) or sessions (pipeline) of the step running now. */
26146
+ load: number().nullable(),
26147
+ cellsDone: number(),
26148
+ cellsTotal: number(),
26149
+ message: string()
26150
+ });
26151
+ /** What limited a ramp. `none` = the ramp ran out of steps still passing. */
26152
+ var NodeBenchLimitSchema = _enum([
26153
+ "p95",
26154
+ "drops",
26155
+ "errors",
26156
+ "stall",
26157
+ "cpu",
26158
+ "ram",
26159
+ "none"
26160
+ ]);
26161
+ var NodeBenchRampStepSchema = object({
26162
+ load: number(),
26163
+ pass: boolean(),
26164
+ p95Ms: number(),
26165
+ dropRatio: number(),
26166
+ /** Completed frames per second over the accounted window. */
26167
+ fps: number(),
26168
+ cpuPct: number().nullable(),
26169
+ ramFreePct: number().nullable(),
26170
+ failReasons: array(string()).readonly()
26171
+ });
26172
+ var NodeBenchCellSchema = discriminatedUnion("phase", [object({
26173
+ phase: literal("device"),
26174
+ deviceKey: string(),
26175
+ modelId: string(),
26176
+ /** Single-stream latency (the K = 1 step). */
26177
+ p50Ms: number(),
26178
+ p95Ms: number(),
26179
+ p99Ms: number(),
26180
+ /** Frames per second sustained at the last passing step. */
26181
+ fps: number(),
26182
+ /** Streams at the camera rate the device carried inside the frame interval; 0 = not even one. */
26183
+ kMax: number(),
26184
+ limitedBy: NodeBenchLimitSchema,
26185
+ /** First call (model load + warm-up). */
26186
+ warmupMs: number(),
26187
+ ramp: array(NodeBenchRampStepSchema).readonly()
26188
+ }), object({
26189
+ phase: literal("pipeline"),
26190
+ deviceKey: string(),
26191
+ modelId: string(),
26192
+ steps: array(string()).readonly(),
26193
+ /** Parallel sessions at the camera rate the node carried; 0 = not even one. */
26194
+ maxSessions: number(),
26195
+ limitedBy: NodeBenchLimitSchema,
26196
+ /** Detail steps that produced at least one result on the clip — a step that never fired measured nothing. */
26197
+ stepsFired: array(string()).readonly(),
26198
+ warmupMs: number(),
26199
+ ramp: array(NodeBenchRampStepSchema).readonly()
26200
+ })]);
26201
+ /**
26202
+ * What a result was measured ON. A result whose fingerprint no longer matches
26203
+ * the node no longer beats the table.
26204
+ */
26205
+ var NodeBenchFingerprintSchema = object({
26206
+ pipelineVersion: string().nullable(),
26207
+ cpuModel: string().nullable(),
26208
+ ramGb: number().nullable(),
26209
+ os: string().nullable(),
26210
+ /** Per device: the pool the cells ran on (runtime + tuning). */
26211
+ pools: record(string(), object({
26212
+ runtime: string(),
26213
+ numWorkers: number(),
26214
+ concurrency: number(),
26215
+ batchMode: string()
26216
+ })).default({})
26217
+ });
26218
+ /** The frames the run used. */
26219
+ var NodeBenchClipSchema = object({
26220
+ /** `camstack-bench-v1` or `reference-images` (the fallback when the clip is not reachable). */
26221
+ id: string(),
26222
+ revision: string().nullable(),
26223
+ frames: number(),
26224
+ width: number(),
26225
+ height: number()
26226
+ });
26227
+ var NodeBenchRunnerInputSchema = object({
26228
+ runId: string().min(1),
26229
+ devices: array(NodeBenchmarkDevicePlanSchema).min(1),
26230
+ phases: array(NodeBenchmarkPhaseSchema).min(1),
26231
+ /** The full detail step tree root for the `pipeline` measurement is built on the node from these ids. */
26232
+ steps: array(string()).default([]),
26233
+ fpsPerStream: number().int().min(1).max(30),
26234
+ /** The runner stops on its own past this instant, whatever the hub does. */
26235
+ deadlineAtMs: number(),
26236
+ settleSec: number().min(0).max(60).default(NODE_BENCHMARK_DEFAULTS.settleSec),
26237
+ measureSec: number().min(2).max(300).default(NODE_BENCHMARK_DEFAULTS.measureSec),
26238
+ keepDownloadedModels: boolean().default(false)
26239
+ });
26240
+ var NodeBenchRunnerStateSchema = _enum([
26241
+ "running",
26242
+ "done",
26243
+ "failed",
26244
+ "aborted"
26245
+ ]);
26246
+ var NodeBenchRunnerStatusSchema = object({
26247
+ runId: string(),
26248
+ nodeId: string(),
26249
+ state: NodeBenchRunnerStateSchema,
26250
+ progress: NodeBenchProgressSchema.nullable(),
26251
+ /** Every finished cell so far — a run stopped half way keeps what it measured. */
26252
+ cells: array(NodeBenchCellSchema).readonly(),
26253
+ fingerprint: NodeBenchFingerprintSchema.nullable(),
26254
+ clip: NodeBenchClipSchema.nullable(),
26255
+ /** Cameras seen running on the node during the run (they share its pools). */
26256
+ activeCameraIds: array(number()).readonly(),
26257
+ /** Models the run downloaded and then deleted (not installed before). */
26258
+ deletedModels: array(string()).readonly(),
26259
+ error: string().nullable(),
26260
+ startedAtMs: number(),
26261
+ finishedAtMs: number().nullable()
26262
+ });
26263
+ var NodeBenchmarkStateSchema = _enum([
26264
+ "draining",
26265
+ "measuring",
26266
+ "restoring",
26267
+ "done",
26268
+ "failed",
26269
+ "aborted"
26270
+ ]);
26271
+ /** Why a run ended. */
26272
+ var NodeBenchmarkEndReasonSchema = _enum([
26273
+ "completed",
26274
+ "operator-abort",
26275
+ "deadline",
26276
+ "node-lost",
26277
+ "runner-lost",
26278
+ "hub-restart",
26279
+ "drain-timeout",
26280
+ "failed"
26281
+ ]);
26282
+ var NodeBenchmarkRunSchema = object({
26283
+ runId: string(),
26284
+ nodeId: string(),
26285
+ state: NodeBenchmarkStateSchema,
26286
+ plan: NodeBenchmarkPlanSchema,
26287
+ startedAtMs: number(),
26288
+ deadlineAtMs: number(),
26289
+ finishedAtMs: number().nullable(),
26290
+ endReason: NodeBenchmarkEndReasonSchema.nullable(),
26291
+ error: string().nullable(),
26292
+ /** Cameras moved off the node for the run. */
26293
+ moved: array(number()).readonly(),
26294
+ /** Cameras that stayed (their only frame source is the node). */
26295
+ staying: array(number()).readonly(),
26296
+ /** Something else ran on the node's pools during the run. */
26297
+ contaminated: boolean(),
26298
+ progress: NodeBenchProgressSchema.nullable(),
26299
+ resultIds: array(string()).readonly()
26300
+ });
26301
+ /** `getNodeBenchmarkStatus`: the active run (or the last one), and whether benchmark mode is on. */
26302
+ var NodeBenchmarkStatusSchema = object({
26303
+ /** The node the cluster is in benchmark mode for; null = none. */
26304
+ modeNodeId: string().nullable(),
26305
+ run: NodeBenchmarkRunSchema.nullable()
26306
+ });
26307
+ /**
26308
+ * One stored measurement — the only authority Auto tune and the automatic
26309
+ * shares read measured capacity from. Written by the orchestrator when a run
26310
+ * ends, never by anyone else.
26311
+ */
26312
+ var NodeBenchmarkResultSchema = object({
26313
+ id: string(),
26314
+ runId: string(),
26315
+ nodeId: string(),
26316
+ cell: NodeBenchCellSchema,
26317
+ fpsPerStream: number(),
26318
+ fingerprint: NodeBenchFingerprintSchema.nullable(),
26319
+ clip: NodeBenchClipSchema.nullable(),
26320
+ /** Other work shared the node's pools (a camera that could not move, or the hub's own duties). */
26321
+ contaminated: boolean(),
26322
+ stayingCameras: array(number()).readonly(),
26323
+ /** The run ended early; the cell itself completed. */
26324
+ partialRun: boolean(),
26325
+ measuredAtMs: number()
26326
+ });
26327
+ var ListNodeBenchmarkResultsInputSchema = object({
26328
+ nodeId: string().optional(),
26329
+ deviceKey: string().optional()
26330
+ });
26331
+ /** A result with its standing today: does it still beat the table? */
26332
+ var NodeBenchmarkResultViewSchema = NodeBenchmarkResultSchema.extend({
26333
+ /** `fresh` beats the table; `stale` falls back to it; `superseded` = a newer row covers the same cell. */
26334
+ standing: _enum([
26335
+ "fresh",
26336
+ "stale",
26337
+ "superseded"
26338
+ ]),
26339
+ staleWhy: _enum([
26340
+ "age",
26341
+ "runtime",
26342
+ "pool-tuning"
26343
+ ]).nullable()
26344
+ });
26345
+ object({
26346
+ runId: string(),
26347
+ nodeId: string(),
26348
+ startedAtMs: number(),
26349
+ deadlineAtMs: number(),
26350
+ plan: NodeBenchmarkPlanSchema,
26351
+ moved: array(number()).readonly(),
26352
+ staying: array(number()).readonly()
26353
+ });
26354
+ /** Candidate detectors per device, for the plan editor. */
26355
+ var NodeBenchmarkCandidatesSchema = object({
26356
+ nodeId: string(),
26357
+ reachable: boolean(),
26358
+ devices: array(object({
26359
+ deviceKey: string(),
26360
+ enabled: boolean(),
26361
+ available: boolean(),
26362
+ /** Ordered: what Auto tune would pick first, then the rest of the family by accuracy. */
26363
+ suggested: array(string()).readonly(),
26364
+ /** Every root detector the device has a build for. */
26365
+ all: array(string()).readonly(),
26366
+ /** The model the device runs now, when pinned. */
26367
+ currentModelId: string().nullable()
26368
+ })).readonly(),
26369
+ /** Detail steps the node's catalog offers under the root (for the `pipeline` measurement). */
26370
+ steps: array(object({
26371
+ id: string(),
26372
+ name: string(),
26373
+ slot: string()
26374
+ })).readonly()
26375
+ });
23920
26376
  object({
23921
26377
  activeCameras: number(),
23922
26378
  throttledCameras: number(),
@@ -25005,7 +27461,16 @@ method(RunnerCameraConfigSchema, object({ success: literal(true) }), { kind: "mu
25005
27461
  }), ParkedTrackFrameSchema.nullable()), method(object({
25006
27462
  deviceId: number(),
25007
27463
  trackId: string()
25008
- }), object({ released: number().int().nonnegative() }), { kind: "mutation" });
27464
+ }), object({ released: number().int().nonnegative() }), { kind: "mutation" }), method(NodeBenchRunnerInputSchema, object({
27465
+ accepted: literal(true),
27466
+ runId: string()
27467
+ }), {
27468
+ kind: "mutation",
27469
+ auth: "admin"
27470
+ }), method(object({ runId: string() }), NodeBenchRunnerStatusSchema.nullable(), { auth: "admin" }), method(object({ runId: string() }), object({ aborted: boolean() }), {
27471
+ kind: "mutation",
27472
+ auth: "admin"
27473
+ });
25009
27474
  var CameraPipelineConfigSchema = object({
25010
27475
  engine: PipelineEngineChoiceSchema.optional(),
25011
27476
  steps: array(PipelineStepInputSchema).readonly(),
@@ -25644,6 +28109,21 @@ method(object({
25644
28109
  }), method(PlacementStatsInputSchema, PlacementStatsSchema, { auth: "admin" }), method(SuggestSharesInputSchema, SuggestSharesResultSchema, { auth: "admin" }), method(_void(), EffectiveSharesSchema, { auth: "admin" }), method(SetShareSourceInputSchema, object({ success: literal(true) }), {
25645
28110
  kind: "mutation",
25646
28111
  auth: "admin"
28112
+ }), method(NodeBenchmarkPlanSchema, NodeBenchmarkPreflightSchema, { auth: "admin" }), method(NodeBenchmarkPlanSchema, discriminatedUnion("kind", [object({
28113
+ kind: literal("started"),
28114
+ runId: string()
28115
+ }), object({
28116
+ kind: literal("refused"),
28117
+ preflight: NodeBenchmarkPreflightSchema
28118
+ })]), {
28119
+ kind: "mutation",
28120
+ auth: "admin"
28121
+ }), method(_void(), NodeBenchmarkStatusSchema, { auth: "admin" }), method(object({ runId: string() }), object({ aborted: boolean() }), {
28122
+ kind: "mutation",
28123
+ auth: "admin"
28124
+ }), method(object({ nodeId: string() }), NodeBenchmarkCandidatesSchema, { auth: "admin" }), method(ListNodeBenchmarkResultsInputSchema, array(NodeBenchmarkResultViewSchema).readonly(), { auth: "admin" }), method(object({ id: string() }), object({ deleted: boolean() }), {
28125
+ kind: "mutation",
28126
+ auth: "admin"
25647
28127
  }), method(object({ deviceId: number() }), CameraPipelineSettingsSchema.nullable()), method(object({
25648
28128
  deviceId: number(),
25649
28129
  addonId: string(),
@@ -26049,8 +28529,8 @@ version: string().optional() }), ServerUpdateActionResultSchema, {
26049
28529
  * `smtp-provider` — pluggable email delivery surface.
26050
28530
  *
26051
28531
  * Collection cap: a deployment may install multiple SMTP relays (e.g.
26052
- * one for transactional / one for notifications). Consumers (magic-link,
26053
- * notifier addons, …) walk the collection and pick the first
28532
+ * one for transactional / one for notifications). Consumers (notifier
28533
+ * addons, …) walk the collection and pick the first
26054
28534
  * ready provider OR target a specific addonId.
26055
28535
  *
26056
28536
  * The shape stays small on purpose — `sendEmail` is enough for the
@@ -26229,7 +28709,7 @@ targets: array(object({
26229
28709
  })));
26230
28710
  /**
26231
28711
  * `sso-bridge` — internal hub-only cap that lets SSO-style auth
26232
- * providers (OIDC, SAML, magic-link, …) mint an HMAC-signed token
28712
+ * providers (OIDC, SAML, …) mint an HMAC-signed token
26233
28713
  * carrying the post-callback claims before redirecting back to
26234
28714
  * `/api/auth/sso/finish`.
26235
28715
  *
@@ -26292,7 +28772,14 @@ var SsoBridgeClaimsSchema = object({
26292
28772
  * Verified `iss` of the id_token behind an OIDC login bridge (D782). A
26293
28773
  * subject is unique only per issuer, so a link is bound to it.
26294
28774
  */
26295
- issuer: string().optional()
28775
+ issuer: string().optional(),
28776
+ /**
28777
+ * SHA-256 (hex) of the `camstack_sso_state` cookie the IdP `/start` set in
28778
+ * the browser that began this sign-in. `/api/auth/sso/finish` requires the
28779
+ * request to present the matching cookie — a login bridge is useless in
28780
+ * any other browser.
28781
+ */
28782
+ browserBinding: string().optional()
26296
28783
  });
26297
28784
  method(object({
26298
28785
  claims: SsoBridgeClaimsSchema,
@@ -30725,6 +33212,9 @@ var CreateIntegrationInputSchema = object({
30725
33212
  enabled: boolean().optional(),
30726
33213
  info: record(string(), unknown()).optional(),
30727
33214
  settings: record(string(), unknown()).optional(),
33215
+ /** Keys of `settings` the form's schema declares secret (by type) — kept in
33216
+ * the keychain, not the table (D787). */
33217
+ secretKeys: array(string()).optional(),
30728
33218
  skipRestart: boolean().optional()
30729
33219
  });
30730
33220
  var UpdateIntegrationInputSchema = object({
@@ -30748,7 +33238,9 @@ method(_void(), array(IntegrationWithStateSchema)), method(object({ id: string()
30748
33238
  auth: "admin"
30749
33239
  }), method(object({ id: string() }), record(string(), unknown()), { auth: "admin" }), method(object({
30750
33240
  id: string(),
30751
- settings: record(string(), unknown())
33241
+ settings: record(string(), unknown()),
33242
+ /** Keys the form's schema declares secret (by type) — keychain-stored (D787). */
33243
+ secretKeys: array(string()).optional()
30752
33244
  }), object({ success: boolean() }), {
30753
33245
  kind: "mutation",
30754
33246
  auth: "admin"
@@ -36268,16 +38760,6 @@ var ApiKeySummarySchema = object({
36268
38760
  createdAt: number(),
36269
38761
  lastUsedAt: number().optional()
36270
38762
  });
36271
- var CreateApiKeyInputSchema = object({
36272
- label: string(),
36273
- isAdmin: boolean().default(false),
36274
- allowedProviders: union([array(string()), literal("*")]).optional(),
36275
- allowedDevices: record(string(), union([array(string()), literal("*")])).optional()
36276
- });
36277
- var CreateApiKeyResultSchema = object({
36278
- token: string(),
36279
- record: ApiKeySummarySchema
36280
- });
36281
38763
  var ScopedTokenSummarySchema = object({
36282
38764
  id: string(),
36283
38765
  userId: string(),
@@ -36376,17 +38858,10 @@ method(_void(), array(UserSummarySchema), { auth: "admin" }), method(CreateUserI
36376
38858
  }), UserSummarySchema.extend({ passwordHash: string() }).nullable(), {
36377
38859
  kind: "mutation",
36378
38860
  access: "view"
36379
- }), method(_void(), array(ApiKeySummarySchema), { auth: "admin" }), method(CreateApiKeyInputSchema, CreateApiKeyResultSchema, {
36380
- kind: "mutation",
36381
- auth: "admin",
36382
- access: "create"
36383
- }), method(object({ id: string() }), object({ success: literal(true) }), {
38861
+ }), method(_void(), array(ApiKeySummarySchema), { auth: "admin" }), method(object({ id: string() }), object({ success: literal(true) }), {
36384
38862
  kind: "mutation",
36385
38863
  auth: "admin",
36386
38864
  access: "delete"
36387
- }), method(object({ token: string() }), ApiKeySummarySchema.nullable(), {
36388
- kind: "mutation",
36389
- access: "view"
36390
38865
  }), method(CreateScopedTokenInputSchema, CreateScopedTokenResultSchema, {
36391
38866
  kind: "mutation",
36392
38867
  auth: "admin",
@@ -36460,15 +38935,7 @@ method(_void(), array(UserSummarySchema), { auth: "admin" }), method(CreateUserI
36460
38935
  }).nullable(), { access: "view" }), method(object({ userId: string() }), array(ExternalIdentitySchema), { auth: "admin" }), method(ExternalIdentityKeySchema, object({
36461
38936
  userId: string(),
36462
38937
  issuer: string()
36463
- }).nullable(), { auth: "admin" }), method(ExternalIdentityKeySchema.extend({
36464
- userId: string(),
36465
- issuer: string().min(1),
36466
- label: string().optional()
36467
- }), object({ success: literal(true) }), {
36468
- kind: "mutation",
36469
- auth: "admin",
36470
- access: "create"
36471
- }), method(ExternalIdentityKeySchema.extend({ userId: string() }), object({ success: boolean() }), {
38938
+ }).nullable(), { auth: "admin" }), method(ExternalIdentityKeySchema.extend({ userId: string() }), object({ success: boolean() }), {
36472
38939
  kind: "mutation",
36473
38940
  auth: "admin",
36474
38941
  access: "delete"
@@ -36863,6 +39330,451 @@ DeviceType.Camera, method(object({
36863
39330
  detection: array(ZoneRuleSchema).readonly(),
36864
39331
  package: array(ZoneRuleSchema).readonly()
36865
39332
  });
39333
+ /**
39334
+ * `training-provider` — ONE cloud that can run the CamStack trainer.
39335
+ *
39336
+ * A thin, mockable translation layer: it knows how to run a container with a
39337
+ * GPU, move a dataset in, read the job's stdout and hand artefacts back. It
39338
+ * knows nothing about datasets, splits, floors, cost policy or Model Studio —
39339
+ * those are the `training` orchestrator's (D805). Every rule written there
39340
+ * once is what makes a second provider (RunPod, a local NVIDIA node) a new
39341
+ * manifest entry and nothing else.
39342
+ *
39343
+ * Collection, routed by the `addonId` in every single-row input (the `llm` /
39344
+ * `notification-output` posture); `describe` concat-fans across providers.
39345
+ * Every method is `admin`: these spend money.
39346
+ *
39347
+ * Every cloud object a provider creates is tagged with the orchestrator's
39348
+ * `jobKey`, so a retried submit finds the job it already started instead of
39349
+ * starting a second GPU, and `listJobs` can find orphans.
39350
+ *
39351
+ * Bytes never ride a cap field: the dataset arrives as a `ctx.peerBytes`
39352
+ * ticket the producer (pipeline-analytics) minted, and artefacts leave as a
39353
+ * ticket the provider mints (D613).
39354
+ */
39355
+ var TrainingGpuOptionSchema = object({
39356
+ id: string(),
39357
+ label: string(),
39358
+ /** List price, USD per GPU-hour, before any region multiplier. */
39359
+ usdPerHour: number().nonnegative(),
39360
+ vramGb: number().nonnegative()
39361
+ });
39362
+ var TrainingRegionOptionSchema = object({
39363
+ /** `''` = any region (the provider's choice). */
39364
+ id: string(),
39365
+ label: string(),
39366
+ priceMultiplier: number().positive()
39367
+ });
39368
+ /**
39369
+ * The provider's per-account settings, as the orchestrator reads them. They
39370
+ * live in the PROVIDER addon's settings (operator decision 2026-10-08: they
39371
+ * depend on the user's account), never hard-coded in the orchestrator.
39372
+ */
39373
+ var TrainingProviderDefaultsSchema = object({
39374
+ gpuType: string(),
39375
+ region: string(),
39376
+ costCapUsd: number().nonnegative(),
39377
+ maxRuntimeSec: number().int().positive(),
39378
+ /** Hours a FAILED job's cloud dataset is kept for debugging; 0 = delete at once. */
39379
+ failedDatasetGraceHours: number().nonnegative()
39380
+ });
39381
+ var TrainingProviderDescriptorSchema = object({
39382
+ addonId: string(),
39383
+ /** `modal`, `runpod`, `fake`, … */
39384
+ kind: string(),
39385
+ label: string(),
39386
+ gpuTypes: array(TrainingGpuOptionSchema).readonly(),
39387
+ regions: array(TrainingRegionOptionSchema).readonly(),
39388
+ maxDatasetBytes: number().int().positive(),
39389
+ maxRuntimeSec: number().int().positive(),
39390
+ freeTierNote: string().optional(),
39391
+ /** Where the data goes, in one sentence the confirm dialog repeats. */
39392
+ dataResidencyNote: string(),
39393
+ /** Credentials are present — never the values. */
39394
+ configured: boolean(),
39395
+ defaults: TrainingProviderDefaultsSchema
39396
+ });
39397
+ var TrainingCredentialCheckSchema = object({
39398
+ ok: boolean(),
39399
+ /** Workspace / account name, when the provider says. */
39400
+ account: string().optional(),
39401
+ reason: _enum([
39402
+ "missing",
39403
+ "invalid",
39404
+ "forbidden",
39405
+ "network",
39406
+ "quota"
39407
+ ]).optional(),
39408
+ detail: string().optional()
39409
+ });
39410
+ var ProviderJobStateSchema = _enum([
39411
+ "pending",
39412
+ "starting",
39413
+ "running",
39414
+ "succeeded",
39415
+ "failed",
39416
+ "cancelled",
39417
+ "lost"
39418
+ ]);
39419
+ var ProviderJobStatusSchema = object({
39420
+ jobKey: string(),
39421
+ providerJobId: string().optional(),
39422
+ state: ProviderJobStateSchema,
39423
+ startedAt: number().optional(),
39424
+ endedAt: number().optional(),
39425
+ exitCode: number().int().optional(),
39426
+ failureReason: string().optional(),
39427
+ gpuType: string(),
39428
+ region: string().optional(),
39429
+ billedSeconds: number().nonnegative(),
39430
+ costUsd: number().nonnegative(),
39431
+ /** True when `costUsd` is runtime × list price, not a billing answer. */
39432
+ costIsEstimate: boolean(),
39433
+ lastFetchedAt: number()
39434
+ });
39435
+ /**
39436
+ * The trainer the job runs, by SOURCE revision: the provider turns it into an
39437
+ * image its own way (Modal builds the published Dockerfile at that revision;
39438
+ * a registry-pull provider maps it to a tag). Recorded on the job and echoed
39439
+ * in `result.json`.
39440
+ */
39441
+ var TrainerSourceRefSchema = object({
39442
+ /** Hugging Face repo id, e.g. `camstack/camstack-trainer`. */
39443
+ repo: string().min(1),
39444
+ /** A commit sha (never a branch) — the job must be reproducible. */
39445
+ revision: string().regex(/^[0-9a-f]{7,64}$/)
39446
+ });
39447
+ var JobRef = {
39448
+ addonId: string(),
39449
+ jobKey: string().uuid()
39450
+ };
39451
+ var TrainingLogLineSchema = object({
39452
+ ts: number(),
39453
+ text: string()
39454
+ });
39455
+ method(object({}), array(TrainingProviderDescriptorSchema).readonly(), { auth: "admin" }), method(object({ addonId: string() }), TrainingCredentialCheckSchema, {
39456
+ kind: "mutation",
39457
+ auth: "admin",
39458
+ timeoutMs: 3e4
39459
+ }), method(object({
39460
+ addonId: string(),
39461
+ gpuType: string(),
39462
+ region: string(),
39463
+ datasetBytes: number().int().nonnegative(),
39464
+ gpuSecondsLow: number().nonnegative(),
39465
+ gpuSecondsHigh: number().nonnegative()
39466
+ }), object({
39467
+ usdLow: number().nonnegative(),
39468
+ usdHigh: number().nonnegative(),
39469
+ notes: array(string()).readonly()
39470
+ }), { auth: "admin" }), method(object({
39471
+ ...JobRef,
39472
+ ticket: PeerBytesTicketSchema
39473
+ }), object({
39474
+ bytes: number().int().nonnegative(),
39475
+ sha256: string()
39476
+ }), {
39477
+ kind: "mutation",
39478
+ auth: "admin",
39479
+ timeoutMs: 120 * 6e4
39480
+ }), method(object({
39481
+ ...JobRef,
39482
+ trainer: TrainerSourceRefSchema,
39483
+ jobSpecJson: string().min(2).max(64e3),
39484
+ gpuType: string(),
39485
+ region: string(),
39486
+ maxRuntimeSec: number().int().positive()
39487
+ }), ProviderJobStatusSchema, {
39488
+ kind: "mutation",
39489
+ auth: "admin",
39490
+ timeoutMs: 30 * 6e4
39491
+ }), method(object(JobRef), ProviderJobStatusSchema, {
39492
+ auth: "admin",
39493
+ timeoutMs: 6e4
39494
+ }), method(object({
39495
+ ...JobRef,
39496
+ cursor: string().optional(),
39497
+ max: number().int().min(1).max(500)
39498
+ }), object({
39499
+ lines: array(TrainingLogLineSchema).readonly(),
39500
+ cursor: string()
39501
+ }), {
39502
+ auth: "admin",
39503
+ timeoutMs: 6e4
39504
+ }), method(object(JobRef), object({ ok: literal(true) }), {
39505
+ kind: "mutation",
39506
+ auth: "admin",
39507
+ timeoutMs: 6e4
39508
+ }), method(object(JobRef), object({
39509
+ found: boolean(),
39510
+ text: string().optional()
39511
+ }), {
39512
+ kind: "mutation",
39513
+ auth: "admin",
39514
+ timeoutMs: 5 * 6e4
39515
+ }), method(object({
39516
+ ...JobRef,
39517
+ path: _enum(["bundle.tar"])
39518
+ }), object({ ticket: PeerBytesTicketSchema }), {
39519
+ kind: "mutation",
39520
+ auth: "admin",
39521
+ timeoutMs: 5 * 6e4
39522
+ }), method(object(JobRef), object({ deleted: array(string()).readonly() }), {
39523
+ kind: "mutation",
39524
+ auth: "admin",
39525
+ timeoutMs: 5 * 6e4
39526
+ }), method(object({ addonId: string() }), array(ProviderJobStatusSchema).readonly(), {
39527
+ auth: "admin",
39528
+ timeoutMs: 2 * 6e4
39529
+ });
39530
+ /**
39531
+ * `training` — the cloud-training orchestrator (D805). Hub-only singleton,
39532
+ * provided by `addon-training`.
39533
+ *
39534
+ * It owns what every provider must agree on, written once:
39535
+ *
39536
+ * - **Dataset versions.** Taken over from pipeline-analytics (D796): the rows
39537
+ * live here (D808); pipeline-analytics still CUTS a version (it owns the corpus and
39538
+ * the export plan) and reaches this store through the five row methods
39539
+ * below, so the Retrain page and the export did not change.
39540
+ * - **Jobs.** A persisted state machine, a reconcile loop against the
39541
+ * provider, a cost guard, a daily orphan sweep and the retention rules.
39542
+ * - **The return flow.** Verified artefacts → Model Studio
39543
+ * (`custom-model-registry.importModelBundle`) → canary on cameras →
39544
+ * rollback. Nothing is ever registered automatically.
39545
+ *
39546
+ * Every method is `admin`.
39547
+ */
39548
+ /** A version WITH its frame list — what the export and a job read. */
39549
+ var TrainingDatasetVersionRowSchema = RetrainDatasetVersionSchema.omit({ frameCount: true }).extend({ frameIds: array(string()).max(2e4).readonly() });
39550
+ /** A base model a detector job can fine-tune, and the baseline it is judged against. */
39551
+ var TrainingBaseModelSchema = object({
39552
+ modelId: string(),
39553
+ label: string(),
39554
+ weights: string(),
39555
+ imgsz: number().int(),
39556
+ baselineOnnxUrl: string(),
39557
+ baselineFloors: record(string(), number()),
39558
+ /** The base the fleet runs most — the UI's default. */
39559
+ recommended: boolean()
39560
+ });
39561
+ var TrainingPresetSchema = _enum([
39562
+ "quick",
39563
+ "standard",
39564
+ "thorough"
39565
+ ]);
39566
+ var TrainingJobRequestSchema = object({
39567
+ datasetVersionId: string().min(1),
39568
+ /** The `training-provider` addon that runs it. */
39569
+ addonId: string().min(1),
39570
+ gpuType: string().min(1),
39571
+ region: string(),
39572
+ baseModelId: string().min(1),
39573
+ preset: TrainingPresetSchema,
39574
+ /** Freeze the backbone's first N layers; `null` = the preset's choice. */
39575
+ freeze: number().int().nonnegative().nullable(),
39576
+ /** Cameras held out whole for evaluation; `null` = the orchestrator's default. */
39577
+ holdoutCameras: array(number().int()).nullable()
39578
+ });
39579
+ var TrainingSplitPlanSchema = object({
39580
+ holdoutCameras: array(number().int()).readonly(),
39581
+ /** Used when no camera is held out: the last N days of every camera. */
39582
+ holdoutLastDays: number().int().nonnegative(),
39583
+ /** Holdout subjects per class (camera holdout only; `null` = known only after the split). */
39584
+ holdoutSupport: record(string(), number().int()).nullable(),
39585
+ trainSubjects: number().int()
39586
+ });
39587
+ var TrainingRefusalReasonSchema = _enum([
39588
+ "unknown-dataset",
39589
+ "unknown-provider",
39590
+ "provider-not-configured",
39591
+ "unknown-base-model",
39592
+ "unknown-gpu",
39593
+ "dataset-too-large",
39594
+ "no-training-subjects",
39595
+ "job-already-running"
39596
+ ]);
39597
+ var TrainingJobPlanSchema = object({
39598
+ refusal: object({
39599
+ reason: TrainingRefusalReasonSchema,
39600
+ detail: string()
39601
+ }).nullable(),
39602
+ warnings: array(string()).readonly(),
39603
+ split: TrainingSplitPlanSchema.nullable(),
39604
+ estimate: object({
39605
+ datasetBytes: number().int(),
39606
+ uploadMinutesAt20Mbps: number(),
39607
+ gpuSecondsLow: number(),
39608
+ gpuSecondsHigh: number(),
39609
+ usdLow: number(),
39610
+ usdHigh: number(),
39611
+ notes: array(string()).readonly()
39612
+ }).nullable(),
39613
+ /** Pre-filled from the provider's settings; the operator may lower or raise them. */
39614
+ defaults: object({
39615
+ maxCostUsd: number(),
39616
+ maxRuntimeSec: number().int()
39617
+ }).nullable(),
39618
+ /** The sentence the confirm dialog repeats: where the frames go and when they are deleted. */
39619
+ dataNotice: string()
39620
+ });
39621
+ /**
39622
+ * Orchestrator-owned states, persisted. `uploading` covers exporting the
39623
+ * archive (it is streamed, never staged). Terminal: `failed`, `cancelled`,
39624
+ * `lost`, `expired`, `discarded`. `registered` and `canary` are where a
39625
+ * result lives after the operator acted on it.
39626
+ */
39627
+ var TrainingJobStateSchema = _enum([
39628
+ "uploading",
39629
+ "submitted",
39630
+ "starting",
39631
+ "running",
39632
+ "collecting",
39633
+ "ready",
39634
+ "registered",
39635
+ "canary",
39636
+ "failed",
39637
+ "cancelling",
39638
+ "cancelled",
39639
+ "lost",
39640
+ "expired",
39641
+ "discarded"
39642
+ ]);
39643
+ var TrainingFailureReasonSchema = _enum([
39644
+ "cost-cap",
39645
+ "runtime-cap",
39646
+ "upload-failed",
39647
+ "submit-failed",
39648
+ "trainer-failed",
39649
+ "result-invalid",
39650
+ "checksum-mismatch",
39651
+ "fetch-failed",
39652
+ "provider-error",
39653
+ "hub-restart-during-upload"
39654
+ ]);
39655
+ var TrainingProgressPointSchema = object({
39656
+ epoch: number().int(),
39657
+ map50: number().nullable(),
39658
+ map50_95: number().nullable()
39659
+ });
39660
+ var TrainingCanarySchema = object({
39661
+ deviceIds: array(number().int()).readonly(),
39662
+ since: number(),
39663
+ /** Every override the canary replaced, exactly, so rollback restores it. */
39664
+ previous: array(object({
39665
+ deviceId: number().int(),
39666
+ nodeId: string(),
39667
+ deviceKey: string(),
39668
+ patch: object({
39669
+ modelId: string().optional(),
39670
+ settings: record(string(), unknown()).readonly().optional()
39671
+ }).nullable()
39672
+ })).readonly()
39673
+ });
39674
+ var TrainingJobSchema = object({
39675
+ id: string(),
39676
+ idempotencyKey: string(),
39677
+ name: string(),
39678
+ createdAt: number(),
39679
+ updatedAt: number(),
39680
+ state: TrainingJobStateSchema,
39681
+ stage: TrainingStageSchema.nullable(),
39682
+ failure: object({
39683
+ reason: TrainingFailureReasonSchema,
39684
+ stage: string().nullable(),
39685
+ detail: string()
39686
+ }).nullable(),
39687
+ request: TrainingJobRequestSchema,
39688
+ maxCostUsd: number().nonnegative(),
39689
+ maxRuntimeSec: number().int().positive(),
39690
+ trainer: TrainerSourceRefSchema,
39691
+ datasetLayout: RetrainExportLayoutSchema,
39692
+ dataset: object({
39693
+ bytes: number().int(),
39694
+ sha256: string(),
39695
+ uploadedAt: number()
39696
+ }).nullable(),
39697
+ split: TrainingSplitPlanSchema,
39698
+ provider: object({
39699
+ state: ProviderJobStateSchema.nullable(),
39700
+ providerJobId: string().nullable(),
39701
+ startedAt: number().nullable(),
39702
+ endedAt: number().nullable(),
39703
+ billedSeconds: number(),
39704
+ costUsd: number(),
39705
+ costIsEstimate: boolean(),
39706
+ lastPolledAt: number().nullable()
39707
+ }),
39708
+ progress: object({
39709
+ epoch: number().int().nullable(),
39710
+ epochs: number().int().nullable(),
39711
+ etaSec: number().nullable(),
39712
+ series: array(TrainingProgressPointSchema).readonly()
39713
+ }),
39714
+ /** The last lines of the job's output (≤ 200), newest last. Never frame paths. */
39715
+ logTail: array(string()).readonly(),
39716
+ logCursor: string().nullable(),
39717
+ artifacts: object({
39718
+ bundleBytes: number().int(),
39719
+ bundleSha256: string(),
39720
+ fetchedAt: number(),
39721
+ /** When the staged artefacts are deleted from the hub. */
39722
+ expiresAt: number()
39723
+ }).nullable(),
39724
+ /** When the provider-side copy of the frames was deleted; null while it exists. */
39725
+ cloudDatasetDeletedAt: number().nullable(),
39726
+ /** A failed job's dataset is kept until then (the provider's grace), then deleted. */
39727
+ cloudCleanupDueAt: number().nullable(),
39728
+ /** Model ids registered from this job (base, and int8 when kept). */
39729
+ registeredModelIds: array(string()).readonly(),
39730
+ canary: TrainingCanarySchema.nullable()
39731
+ });
39732
+ var IdInput = object({ id: string().min(1) });
39733
+ method(TrainingDatasetVersionRowSchema, object({ stored: boolean() }), {
39734
+ kind: "mutation",
39735
+ auth: "admin"
39736
+ }), 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() }), {
39737
+ kind: "mutation",
39738
+ auth: "admin"
39739
+ }), method(object({}), array(TrainingBaseModelSchema).readonly(), { auth: "admin" }), method(TrainingJobRequestSchema, TrainingJobPlanSchema, {
39740
+ auth: "admin",
39741
+ timeoutMs: 6e4
39742
+ }), method(TrainingJobRequestSchema.extend({
39743
+ name: string().min(1).max(120),
39744
+ maxCostUsd: number().positive(),
39745
+ maxRuntimeSec: number().int().positive(),
39746
+ idempotencyKey: string().min(8).max(80)
39747
+ }), discriminatedUnion("kind", [object({
39748
+ kind: literal("started"),
39749
+ job: TrainingJobSchema
39750
+ }), object({
39751
+ kind: literal("refused"),
39752
+ reason: TrainingRefusalReasonSchema,
39753
+ detail: string()
39754
+ })]), {
39755
+ kind: "mutation",
39756
+ auth: "admin",
39757
+ timeoutMs: 12e4
39758
+ }), method(object({}), array(TrainingJobSchema).readonly(), { auth: "admin" }), method(IdInput, TrainingJobSchema.nullable(), { auth: "admin" }), method(IdInput, TrainingJobSchema, {
39759
+ kind: "mutation",
39760
+ auth: "admin",
39761
+ timeoutMs: 12e4
39762
+ }), method(IdInput, TrainingResultSchema.nullable(), { auth: "admin" }), method(IdInput.extend({ canaryDeviceIds: array(number().int()).readonly() }), TrainingJobSchema, {
39763
+ kind: "mutation",
39764
+ auth: "admin",
39765
+ timeoutMs: 30 * 6e4
39766
+ }), method(IdInput.extend({ deviceIds: array(number().int()).min(1).readonly() }), TrainingJobSchema, {
39767
+ kind: "mutation",
39768
+ auth: "admin",
39769
+ timeoutMs: 12e4
39770
+ }), method(IdInput, TrainingJobSchema, {
39771
+ kind: "mutation",
39772
+ auth: "admin",
39773
+ timeoutMs: 12e4
39774
+ }), method(IdInput, TrainingJobSchema, {
39775
+ kind: "mutation",
39776
+ auth: "admin"
39777
+ });
36866
39778
  SOURCE_CAPS.filter((cap) => cap !== "switch" && cap !== "motion");
36867
39779
  Object.freeze({
36868
39780
  person: .5,
@@ -37486,6 +40398,12 @@ Object.freeze({
37486
40398
  addonId: null,
37487
40399
  access: "create"
37488
40400
  },
40401
+ "backup.checkBackupKey": {
40402
+ capName: "backup",
40403
+ capScope: "system",
40404
+ addonId: null,
40405
+ access: "create"
40406
+ },
37489
40407
  "backup.delete": {
37490
40408
  capName: "backup",
37491
40409
  capScope: "system",
@@ -37498,6 +40416,18 @@ Object.freeze({
37498
40416
  addonId: null,
37499
40417
  access: "delete"
37500
40418
  },
40419
+ "backup.disableEncryption": {
40420
+ capName: "backup",
40421
+ capScope: "system",
40422
+ addonId: null,
40423
+ access: "create"
40424
+ },
40425
+ "backup.getEncryption": {
40426
+ capName: "backup",
40427
+ capScope: "system",
40428
+ addonId: null,
40429
+ access: "view"
40430
+ },
37501
40431
  "backup.getEntries": {
37502
40432
  capName: "backup",
37503
40433
  capScope: "system",
@@ -37552,6 +40482,12 @@ Object.freeze({
37552
40482
  addonId: null,
37553
40483
  access: "create"
37554
40484
  },
40485
+ "backup.setupEncryption": {
40486
+ capName: "backup",
40487
+ capScope: "system",
40488
+ addonId: null,
40489
+ access: "create"
40490
+ },
37555
40491
  "backup.trigger": {
37556
40492
  capName: "backup",
37557
40493
  capScope: "system",
@@ -38104,6 +41040,12 @@ Object.freeze({
38104
41040
  addonId: null,
38105
41041
  access: "create"
38106
41042
  },
41043
+ "customModelRegistry.importModelBundle": {
41044
+ capName: "custom-model-registry",
41045
+ capScope: "system",
41046
+ addonId: null,
41047
+ access: "create"
41048
+ },
38107
41049
  "customModelRegistry.listModels": {
38108
41050
  capName: "custom-model-registry",
38109
41051
  capScope: "system",
@@ -39514,6 +42456,108 @@ Object.freeze({
39514
42456
  addonId: null,
39515
42457
  access: "create"
39516
42458
  },
42459
+ "keychain.delete": {
42460
+ capName: "keychain",
42461
+ capScope: "system",
42462
+ addonId: null,
42463
+ access: "delete"
42464
+ },
42465
+ "keychain.getState": {
42466
+ capName: "keychain",
42467
+ capScope: "system",
42468
+ addonId: null,
42469
+ access: "view"
42470
+ },
42471
+ "keychain.listMeta": {
42472
+ capName: "keychain",
42473
+ capScope: "system",
42474
+ addonId: null,
42475
+ access: "view"
42476
+ },
42477
+ "keychain.put": {
42478
+ capName: "keychain",
42479
+ capScope: "system",
42480
+ addonId: null,
42481
+ access: "create"
42482
+ },
42483
+ "keychain.resolve": {
42484
+ capName: "keychain",
42485
+ capScope: "system",
42486
+ addonId: null,
42487
+ access: "view"
42488
+ },
42489
+ "keychainAdmin.acknowledgeReset": {
42490
+ capName: "keychain-admin",
42491
+ capScope: "system",
42492
+ addonId: null,
42493
+ access: "create"
42494
+ },
42495
+ "keychainAdmin.deleteOrphans": {
42496
+ capName: "keychain-admin",
42497
+ capScope: "system",
42498
+ addonId: null,
42499
+ access: "delete"
42500
+ },
42501
+ "keychainAdmin.downloadRecoveryKey": {
42502
+ capName: "keychain-admin",
42503
+ capScope: "system",
42504
+ addonId: null,
42505
+ access: "create"
42506
+ },
42507
+ "keychainAdmin.listAudit": {
42508
+ capName: "keychain-admin",
42509
+ capScope: "system",
42510
+ addonId: null,
42511
+ access: "view"
42512
+ },
42513
+ "keychainAdmin.listSecrets": {
42514
+ capName: "keychain-admin",
42515
+ capScope: "system",
42516
+ addonId: null,
42517
+ access: "view"
42518
+ },
42519
+ "keychainAdmin.purgeRetiredKeys": {
42520
+ capName: "keychain-admin",
42521
+ capScope: "system",
42522
+ addonId: null,
42523
+ access: "delete"
42524
+ },
42525
+ "keychainAdmin.resetKeychain": {
42526
+ capName: "keychain-admin",
42527
+ capScope: "system",
42528
+ addonId: null,
42529
+ access: "delete"
42530
+ },
42531
+ "keychainAdmin.resetReport": {
42532
+ capName: "keychain-admin",
42533
+ capScope: "system",
42534
+ addonId: null,
42535
+ access: "delete"
42536
+ },
42537
+ "keychainAdmin.reveal": {
42538
+ capName: "keychain-admin",
42539
+ capScope: "system",
42540
+ addonId: null,
42541
+ access: "create"
42542
+ },
42543
+ "keychainAdmin.rotateMasterKey": {
42544
+ capName: "keychain-admin",
42545
+ capScope: "system",
42546
+ addonId: null,
42547
+ access: "create"
42548
+ },
42549
+ "keychainAdmin.setSystemSecret": {
42550
+ capName: "keychain-admin",
42551
+ capScope: "system",
42552
+ addonId: null,
42553
+ access: "create"
42554
+ },
42555
+ "keychainAdmin.status": {
42556
+ capName: "keychain-admin",
42557
+ capScope: "system",
42558
+ addonId: null,
42559
+ access: "view"
42560
+ },
39517
42561
  "lawnMowerControl.dock": {
39518
42562
  capName: "lawn-mower-control",
39519
42563
  capScope: "device",
@@ -40888,6 +43932,18 @@ Object.freeze({
40888
43932
  addonId: null,
40889
43933
  access: "create"
40890
43934
  },
43935
+ "pipelineAnalytics.addRetrainFrameFromRecording": {
43936
+ capName: "pipeline-analytics",
43937
+ capScope: "device",
43938
+ addonId: null,
43939
+ access: "create"
43940
+ },
43941
+ "pipelineAnalytics.addRetrainFramesToCollection": {
43942
+ capName: "pipeline-analytics",
43943
+ capScope: "device",
43944
+ addonId: null,
43945
+ access: "create"
43946
+ },
40891
43947
  "pipelineAnalytics.applyDeviceSettingsPatch": {
40892
43948
  capName: "pipeline-analytics",
40893
43949
  capScope: "device",
@@ -40936,12 +43992,36 @@ Object.freeze({
40936
43992
  addonId: null,
40937
43993
  access: "view"
40938
43994
  },
43995
+ "pipelineAnalytics.createRetrainCollection": {
43996
+ capName: "pipeline-analytics",
43997
+ capScope: "device",
43998
+ addonId: null,
43999
+ access: "create"
44000
+ },
44001
+ "pipelineAnalytics.createRetrainDatasetVersion": {
44002
+ capName: "pipeline-analytics",
44003
+ capScope: "device",
44004
+ addonId: null,
44005
+ access: "create"
44006
+ },
40939
44007
  "pipelineAnalytics.deleteDeviceEvents": {
40940
44008
  capName: "pipeline-analytics",
40941
44009
  capScope: "device",
40942
44010
  addonId: null,
40943
44011
  access: "delete"
40944
44012
  },
44013
+ "pipelineAnalytics.deleteRetrainCollection": {
44014
+ capName: "pipeline-analytics",
44015
+ capScope: "device",
44016
+ addonId: null,
44017
+ access: "delete"
44018
+ },
44019
+ "pipelineAnalytics.deleteRetrainDatasetVersion": {
44020
+ capName: "pipeline-analytics",
44021
+ capScope: "device",
44022
+ addonId: null,
44023
+ access: "delete"
44024
+ },
40945
44025
  "pipelineAnalytics.deleteTracks": {
40946
44026
  capName: "pipeline-analytics",
40947
44027
  capScope: "device",
@@ -41146,6 +44226,30 @@ Object.freeze({
41146
44226
  addonId: null,
41147
44227
  access: "view"
41148
44228
  },
44229
+ "pipelineAnalytics.listRetrainAssistProfiles": {
44230
+ capName: "pipeline-analytics",
44231
+ capScope: "device",
44232
+ addonId: null,
44233
+ access: "view"
44234
+ },
44235
+ "pipelineAnalytics.listRetrainCollectionFrames": {
44236
+ capName: "pipeline-analytics",
44237
+ capScope: "device",
44238
+ addonId: null,
44239
+ access: "view"
44240
+ },
44241
+ "pipelineAnalytics.listRetrainCollections": {
44242
+ capName: "pipeline-analytics",
44243
+ capScope: "device",
44244
+ addonId: null,
44245
+ access: "view"
44246
+ },
44247
+ "pipelineAnalytics.listRetrainDatasetVersions": {
44248
+ capName: "pipeline-analytics",
44249
+ capScope: "device",
44250
+ addonId: null,
44251
+ access: "view"
44252
+ },
41149
44253
  "pipelineAnalytics.listRetrainFrames": {
41150
44254
  capName: "pipeline-analytics",
41151
44255
  capScope: "device",
@@ -41176,6 +44280,12 @@ Object.freeze({
41176
44280
  addonId: null,
41177
44281
  access: "view"
41178
44282
  },
44283
+ "pipelineAnalytics.offerRetrainArchive": {
44284
+ capName: "pipeline-analytics",
44285
+ capScope: "device",
44286
+ addonId: null,
44287
+ access: "create"
44288
+ },
41179
44289
  "pipelineAnalytics.ownersWithMedia": {
41180
44290
  capName: "pipeline-analytics",
41181
44291
  capScope: "device",
@@ -41188,12 +44298,24 @@ Object.freeze({
41188
44298
  addonId: null,
41189
44299
  access: "create"
41190
44300
  },
44301
+ "pipelineAnalytics.previewRetrainDataset": {
44302
+ capName: "pipeline-analytics",
44303
+ capScope: "device",
44304
+ addonId: null,
44305
+ access: "view"
44306
+ },
41191
44307
  "pipelineAnalytics.proposeRetrainAnnotations": {
41192
44308
  capName: "pipeline-analytics",
41193
44309
  capScope: "device",
41194
44310
  addonId: null,
41195
44311
  access: "create"
41196
44312
  },
44313
+ "pipelineAnalytics.proposeRetrainAnnotationsWithLlm": {
44314
+ capName: "pipeline-analytics",
44315
+ capScope: "device",
44316
+ addonId: null,
44317
+ access: "create"
44318
+ },
41197
44319
  "pipelineAnalytics.pruneEvents": {
41198
44320
  capName: "pipeline-analytics",
41199
44321
  capScope: "device",
@@ -41248,6 +44370,18 @@ Object.freeze({
41248
44370
  addonId: null,
41249
44371
  access: "create"
41250
44372
  },
44373
+ "pipelineAnalytics.removeRetrainFrameFromCollection": {
44374
+ capName: "pipeline-analytics",
44375
+ capScope: "device",
44376
+ addonId: null,
44377
+ access: "delete"
44378
+ },
44379
+ "pipelineAnalytics.renameRetrainCollection": {
44380
+ capName: "pipeline-analytics",
44381
+ capScope: "device",
44382
+ addonId: null,
44383
+ access: "create"
44384
+ },
41251
44385
  "pipelineAnalytics.restageRetrainTrack": {
41252
44386
  capName: "pipeline-analytics",
41253
44387
  capScope: "device",
@@ -41308,6 +44442,12 @@ Object.freeze({
41308
44442
  addonId: null,
41309
44443
  access: "create"
41310
44444
  },
44445
+ "pipelineAnalytics.verifyRetrainDatasetVersion": {
44446
+ capName: "pipeline-analytics",
44447
+ capScope: "device",
44448
+ addonId: null,
44449
+ access: "view"
44450
+ },
41311
44451
  "pipelineAnalytics.wipeAllAnalytics": {
41312
44452
  capName: "pipeline-analytics",
41313
44453
  capScope: "device",
@@ -41536,6 +44676,12 @@ Object.freeze({
41536
44676
  addonId: null,
41537
44677
  access: "view"
41538
44678
  },
44679
+ "pipelineOrchestrator.abortNodeBenchmark": {
44680
+ capName: "pipeline-orchestrator",
44681
+ capScope: "system",
44682
+ addonId: null,
44683
+ access: "create"
44684
+ },
41539
44685
  "pipelineOrchestrator.applyAutoTune": {
41540
44686
  capName: "pipeline-orchestrator",
41541
44687
  capScope: "system",
@@ -41560,6 +44706,12 @@ Object.freeze({
41560
44706
  addonId: null,
41561
44707
  access: "create"
41562
44708
  },
44709
+ "pipelineOrchestrator.deleteNodeBenchmarkResult": {
44710
+ capName: "pipeline-orchestrator",
44711
+ capScope: "system",
44712
+ addonId: null,
44713
+ access: "delete"
44714
+ },
41563
44715
  "pipelineOrchestrator.getAgentLoad": {
41564
44716
  capName: "pipeline-orchestrator",
41565
44717
  capScope: "system",
@@ -41668,6 +44820,24 @@ Object.freeze({
41668
44820
  addonId: null,
41669
44821
  access: "view"
41670
44822
  },
44823
+ "pipelineOrchestrator.getNodeBenchmarkCandidates": {
44824
+ capName: "pipeline-orchestrator",
44825
+ capScope: "system",
44826
+ addonId: null,
44827
+ access: "view"
44828
+ },
44829
+ "pipelineOrchestrator.getNodeBenchmarkPreflight": {
44830
+ capName: "pipeline-orchestrator",
44831
+ capScope: "system",
44832
+ addonId: null,
44833
+ access: "view"
44834
+ },
44835
+ "pipelineOrchestrator.getNodeBenchmarkStatus": {
44836
+ capName: "pipeline-orchestrator",
44837
+ capScope: "system",
44838
+ addonId: null,
44839
+ access: "view"
44840
+ },
41671
44841
  "pipelineOrchestrator.getNodeInferenceDevices": {
41672
44842
  capName: "pipeline-orchestrator",
41673
44843
  capScope: "system",
@@ -41710,6 +44880,12 @@ Object.freeze({
41710
44880
  addonId: null,
41711
44881
  access: "view"
41712
44882
  },
44883
+ "pipelineOrchestrator.listNodeBenchmarkResults": {
44884
+ capName: "pipeline-orchestrator",
44885
+ capScope: "system",
44886
+ addonId: null,
44887
+ access: "view"
44888
+ },
41713
44889
  "pipelineOrchestrator.pauseForStorageMigration": {
41714
44890
  capName: "pipeline-orchestrator",
41715
44891
  capScope: "system",
@@ -41854,6 +45030,12 @@ Object.freeze({
41854
45030
  addonId: null,
41855
45031
  access: "create"
41856
45032
  },
45033
+ "pipelineOrchestrator.startNodeBenchmark": {
45034
+ capName: "pipeline-orchestrator",
45035
+ capScope: "system",
45036
+ addonId: null,
45037
+ access: "create"
45038
+ },
41857
45039
  "pipelineOrchestrator.suggestShares": {
41858
45040
  capName: "pipeline-orchestrator",
41859
45041
  capScope: "system",
@@ -41872,6 +45054,12 @@ Object.freeze({
41872
45054
  addonId: null,
41873
45055
  access: "create"
41874
45056
  },
45057
+ "pipelineRunner.abortNodeBench": {
45058
+ capName: "pipeline-runner",
45059
+ capScope: "system",
45060
+ addonId: null,
45061
+ access: "create"
45062
+ },
41875
45063
  "pipelineRunner.attachCamera": {
41876
45064
  capName: "pipeline-runner",
41877
45065
  capScope: "system",
@@ -41920,6 +45108,12 @@ Object.freeze({
41920
45108
  addonId: null,
41921
45109
  access: "view"
41922
45110
  },
45111
+ "pipelineRunner.getNodeBenchStatus": {
45112
+ capName: "pipeline-runner",
45113
+ capScope: "system",
45114
+ addonId: null,
45115
+ access: "view"
45116
+ },
41923
45117
  "pipelineRunner.getParkedTrackFrame": {
41924
45118
  capName: "pipeline-runner",
41925
45119
  capScope: "system",
@@ -41962,6 +45156,12 @@ Object.freeze({
41962
45156
  addonId: null,
41963
45157
  access: "create"
41964
45158
  },
45159
+ "pipelineRunner.startNodeBench": {
45160
+ capName: "pipeline-runner",
45161
+ capScope: "system",
45162
+ addonId: null,
45163
+ access: "create"
45164
+ },
41965
45165
  "plateGallery.assignPlate": {
41966
45166
  capName: "plate-gallery",
41967
45167
  capScope: "system",
@@ -43624,6 +46824,174 @@ Object.freeze({
43624
46824
  addonId: null,
43625
46825
  access: "view"
43626
46826
  },
46827
+ "training.canaryResult": {
46828
+ capName: "training",
46829
+ capScope: "system",
46830
+ addonId: null,
46831
+ access: "create"
46832
+ },
46833
+ "training.cancelJob": {
46834
+ capName: "training",
46835
+ capScope: "system",
46836
+ addonId: null,
46837
+ access: "create"
46838
+ },
46839
+ "training.discardResult": {
46840
+ capName: "training",
46841
+ capScope: "system",
46842
+ addonId: null,
46843
+ access: "create"
46844
+ },
46845
+ "training.findDatasetVersionIdByName": {
46846
+ capName: "training",
46847
+ capScope: "system",
46848
+ addonId: null,
46849
+ access: "view"
46850
+ },
46851
+ "training.getDatasetVersion": {
46852
+ capName: "training",
46853
+ capScope: "system",
46854
+ addonId: null,
46855
+ access: "view"
46856
+ },
46857
+ "training.getJob": {
46858
+ capName: "training",
46859
+ capScope: "system",
46860
+ addonId: null,
46861
+ access: "view"
46862
+ },
46863
+ "training.getJobResult": {
46864
+ capName: "training",
46865
+ capScope: "system",
46866
+ addonId: null,
46867
+ access: "view"
46868
+ },
46869
+ "training.listBaseModels": {
46870
+ capName: "training",
46871
+ capScope: "system",
46872
+ addonId: null,
46873
+ access: "view"
46874
+ },
46875
+ "training.listDatasetVersions": {
46876
+ capName: "training",
46877
+ capScope: "system",
46878
+ addonId: null,
46879
+ access: "view"
46880
+ },
46881
+ "training.listJobs": {
46882
+ capName: "training",
46883
+ capScope: "system",
46884
+ addonId: null,
46885
+ access: "view"
46886
+ },
46887
+ "training.planJob": {
46888
+ capName: "training",
46889
+ capScope: "system",
46890
+ addonId: null,
46891
+ access: "view"
46892
+ },
46893
+ "training.putDatasetVersion": {
46894
+ capName: "training",
46895
+ capScope: "system",
46896
+ addonId: null,
46897
+ access: "create"
46898
+ },
46899
+ "training.registerResult": {
46900
+ capName: "training",
46901
+ capScope: "system",
46902
+ addonId: null,
46903
+ access: "create"
46904
+ },
46905
+ "training.removeDatasetVersion": {
46906
+ capName: "training",
46907
+ capScope: "system",
46908
+ addonId: null,
46909
+ access: "delete"
46910
+ },
46911
+ "training.rollbackCanary": {
46912
+ capName: "training",
46913
+ capScope: "system",
46914
+ addonId: null,
46915
+ access: "create"
46916
+ },
46917
+ "training.startJob": {
46918
+ capName: "training",
46919
+ capScope: "system",
46920
+ addonId: null,
46921
+ access: "create"
46922
+ },
46923
+ "trainingProvider.cancelJob": {
46924
+ capName: "training-provider",
46925
+ capScope: "system",
46926
+ addonId: null,
46927
+ access: "create"
46928
+ },
46929
+ "trainingProvider.cleanupJob": {
46930
+ capName: "training-provider",
46931
+ capScope: "system",
46932
+ addonId: null,
46933
+ access: "create"
46934
+ },
46935
+ "trainingProvider.describe": {
46936
+ capName: "training-provider",
46937
+ capScope: "system",
46938
+ addonId: null,
46939
+ access: "view"
46940
+ },
46941
+ "trainingProvider.estimateJob": {
46942
+ capName: "training-provider",
46943
+ capScope: "system",
46944
+ addonId: null,
46945
+ access: "view"
46946
+ },
46947
+ "trainingProvider.getJob": {
46948
+ capName: "training-provider",
46949
+ capScope: "system",
46950
+ addonId: null,
46951
+ access: "view"
46952
+ },
46953
+ "trainingProvider.listJobEvents": {
46954
+ capName: "training-provider",
46955
+ capScope: "system",
46956
+ addonId: null,
46957
+ access: "view"
46958
+ },
46959
+ "trainingProvider.listJobs": {
46960
+ capName: "training-provider",
46961
+ capScope: "system",
46962
+ addonId: null,
46963
+ access: "view"
46964
+ },
46965
+ "trainingProvider.offerArtifact": {
46966
+ capName: "training-provider",
46967
+ capScope: "system",
46968
+ addonId: null,
46969
+ access: "create"
46970
+ },
46971
+ "trainingProvider.readResult": {
46972
+ capName: "training-provider",
46973
+ capScope: "system",
46974
+ addonId: null,
46975
+ access: "create"
46976
+ },
46977
+ "trainingProvider.submitJob": {
46978
+ capName: "training-provider",
46979
+ capScope: "system",
46980
+ addonId: null,
46981
+ access: "create"
46982
+ },
46983
+ "trainingProvider.uploadDataset": {
46984
+ capName: "training-provider",
46985
+ capScope: "system",
46986
+ addonId: null,
46987
+ access: "create"
46988
+ },
46989
+ "trainingProvider.validateCredentials": {
46990
+ capName: "training-provider",
46991
+ capScope: "system",
46992
+ addonId: null,
46993
+ access: "create"
46994
+ },
43627
46995
  "turnProvider.getTurnServers": {
43628
46996
  capName: "turn-provider",
43629
46997
  capScope: "system",
@@ -43648,12 +47016,6 @@ Object.freeze({
43648
47016
  addonId: null,
43649
47017
  access: "create"
43650
47018
  },
43651
- "userManagement.createApiKey": {
43652
- capName: "user-management",
43653
- capScope: "system",
43654
- addonId: null,
43655
- access: "create"
43656
- },
43657
47019
  "userManagement.createScopedToken": {
43658
47020
  capName: "user-management",
43659
47021
  capScope: "system",
@@ -43690,12 +47052,6 @@ Object.freeze({
43690
47052
  addonId: null,
43691
47053
  access: "view"
43692
47054
  },
43693
- "userManagement.linkExternalIdentity": {
43694
- capName: "user-management",
43695
- capScope: "system",
43696
- addonId: null,
43697
- access: "create"
43698
- },
43699
47055
  "userManagement.listApiKeys": {
43700
47056
  capName: "user-management",
43701
47057
  capScope: "system",
@@ -43798,12 +47154,6 @@ Object.freeze({
43798
47154
  addonId: null,
43799
47155
  access: "create"
43800
47156
  },
43801
- "userManagement.validateApiKey": {
43802
- capName: "user-management",
43803
- capScope: "system",
43804
- addonId: null,
43805
- access: "view"
43806
- },
43807
47157
  "userManagement.validateCredentials": {
43808
47158
  capName: "user-management",
43809
47159
  capScope: "system",
@@ -46891,6 +50241,11 @@ Object.freeze({
46891
50241
  form: "single",
46892
50242
  optional: false
46893
50243
  }],
50244
+ "pipelineAnalytics.addRetrainFrameFromRecording": [{
50245
+ name: "deviceId",
50246
+ form: "single",
50247
+ optional: false
50248
+ }],
46894
50249
  "pipelineAnalytics.applyDeviceSettingsPatch": [{
46895
50250
  name: "deviceId",
46896
50251
  form: "single",
@@ -47081,6 +50436,11 @@ Object.freeze({
47081
50436
  form: "single",
47082
50437
  optional: false
47083
50438
  }],
50439
+ "pipelineAnalytics.proposeRetrainAnnotationsWithLlm": [{
50440
+ name: "deviceId",
50441
+ form: "single",
50442
+ optional: false
50443
+ }],
47084
50444
  "pipelineAnalytics.pruneEventsBefore": [{
47085
50445
  name: "deviceId",
47086
50446
  form: "single",
@@ -47907,6 +51267,11 @@ Object.freeze({
47907
51267
  form: "single",
47908
51268
  optional: false
47909
51269
  }],
51270
+ "training.canaryResult": [{
51271
+ name: "deviceIds",
51272
+ form: "array",
51273
+ optional: false
51274
+ }],
47910
51275
  "update.getStatus": [{
47911
51276
  name: "deviceId",
47912
51277
  form: "single",