@camstack/addon-provider-unifi 0.2.123 → 0.2.125

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.
Files changed (3) hide show
  1. package/dist/addon.js +3555 -126
  2. package/dist/addon.mjs +3555 -126
  3. package/package.json +1 -1
package/dist/addon.mjs CHANGED
@@ -1,4 +1,4 @@
1
- //#region ../types/dist/event-category-B_0XEcLF.mjs
1
+ //#region ../types/dist/event-category-DaIZi00R.mjs
2
2
  var EventCategory = /* @__PURE__ */ function(EventCategory) {
3
3
  EventCategory["SystemBoot"] = "system.boot";
4
4
  EventCategory["SystemAddonsReady"] = "system.addons-ready";
@@ -77,6 +77,13 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
77
77
  */
78
78
  EventCategory["AddonLoadFailed"] = "addon.load-failed";
79
79
  /**
80
+ * A keychain value was stored or removed (D787). Carries the ref, its
81
+ * owner and the new version — NEVER the value. A process holding the ref
82
+ * drops its cached copy and the owning `BaseAddon` re-resolves its config.
83
+ * Telemetry (D8): a process that misses it still revalidates by version.
84
+ */
85
+ EventCategory["KeychainChanged"] = "keychain.changed";
86
+ /**
80
87
  * Addon recovered from a previous failure. Emitted when an addon
81
88
  * transitions from `failed` back to `healthy` (typically via the
82
89
  * monitor's auto-retry loop, or after manual `addons.retryLoad`).
@@ -5369,7 +5376,7 @@ var ZodIssueCode = {
5369
5376
  var ZodFirstPartyTypeKind;
5370
5377
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
5371
5378
  //#endregion
5372
- //#region ../types/dist/sleep-B0JG7-_F.mjs
5379
+ //#region ../types/dist/sleep-r3RWkGVx.mjs
5373
5380
  /**
5374
5381
  * The audio chunk plane's byte format, and the ONE expansion from a coded
5375
5382
  * window to float samples (D455).
@@ -5448,6 +5455,97 @@ function buildAlawTable() {
5448
5455
  }
5449
5456
  buildUlawTable();
5450
5457
  buildAlawTable();
5458
+ /** Is this field's stored value a credential? */
5459
+ function isSecretConfigField(field) {
5460
+ if (field.type === "password") return true;
5461
+ return "secret" in field && field.secret === true;
5462
+ }
5463
+ /**
5464
+ * Is this field's value stored in the KEYCHAIN (D787)? Every secret field is,
5465
+ * by its TYPE, unless it opts out with `storage: 'inline'` — never by its name.
5466
+ */
5467
+ function isKeychainStoredField(field) {
5468
+ if (!isSecretConfigField(field)) return false;
5469
+ if (field.type === "textarea" && field.isJson === true) return false;
5470
+ return !("storage" in field && field.storage === "inline");
5471
+ }
5472
+ /**
5473
+ * What a settings blob holds where a secret used to be.
5474
+ *
5475
+ * A keychain-stored field never holds its value. It holds a self-describing
5476
+ * MARKER, `{"$secret":"secret://…","v":1}` — an object, never a string, so no
5477
+ * code can mistake it for a credential and no form can send it to a camera as
5478
+ * a password. The empty state is `null` / absent, never `''`.
5479
+ *
5480
+ * The same shapes travel to and from the admin UI:
5481
+ *
5482
+ * - read: `hydrateSchema` hands a secret field a {@link SecretFieldView}
5483
+ * (`{ $secret, v, set: true }`) or `null` — the browser learns whether a
5484
+ * value is set, never the value.
5485
+ * - write: an untouched field submits the view back unchanged (KEEP); a typed
5486
+ * value is a plain non-empty string (CHANGE); the Clear button submits
5487
+ * {@link SECRET_CLEAR} (CLEAR). `''`, `null` and the legacy redaction tokens
5488
+ * are KEEP — an empty string is what a defaults-fallback pushes back, and
5489
+ * treating it as "clear" is how a save destroyed a stored credential before.
5490
+ *
5491
+ * Pure and browser-safe.
5492
+ */
5493
+ var SECRET_CLEAR = { $secretClear: true };
5494
+ /** The `'***'` token D634 redaction writes for non-admins. */
5495
+ var LEGACY_DEVICE_REDACTION = "***";
5496
+ function isRecord$2(value) {
5497
+ return typeof value === "object" && value !== null && !Array.isArray(value);
5498
+ }
5499
+ function makeSecretMarker(ref) {
5500
+ return {
5501
+ $secret: ref,
5502
+ v: 1
5503
+ };
5504
+ }
5505
+ /** A stored marker: an object whose `$secret` is a non-empty string. */
5506
+ function isSecretMarker(value) {
5507
+ if (!isRecord$2(value)) return false;
5508
+ const ref = value["$secret"];
5509
+ return typeof ref === "string" && ref.length > 0;
5510
+ }
5511
+ function isSecretClear(value) {
5512
+ return isRecord$2(value) && value["$secretClear"] === true;
5513
+ }
5514
+ /**
5515
+ * The UI view of a stored secret field value: a marker becomes "set", inline
5516
+ * plaintext becomes "set (inline)", nothing becomes `null`. A value never
5517
+ * survives this function.
5518
+ */
5519
+ function toSecretFieldView(stored) {
5520
+ if (isSecretMarker(stored)) return {
5521
+ $secret: stored.$secret,
5522
+ v: 1,
5523
+ set: true
5524
+ };
5525
+ if (typeof stored === "string" && stored.length > 0) return {
5526
+ $secret: null,
5527
+ v: 1,
5528
+ set: true,
5529
+ inline: true
5530
+ };
5531
+ return null;
5532
+ }
5533
+ /**
5534
+ * Classify an incoming value for a secret path. Only a non-empty string that is
5535
+ * not a redaction token sets a value; only {@link SECRET_CLEAR} clears.
5536
+ * Everything else — a marker (ours or anyone's), a UI view, `''`, `null`,
5537
+ * `undefined`, a redaction token, a non-string — keeps what is stored.
5538
+ */
5539
+ function classifySecretWrite(incoming) {
5540
+ if (isSecretClear(incoming)) return { kind: "clear" };
5541
+ if (typeof incoming !== "string") return { kind: "keep" };
5542
+ if (incoming.length === 0) return { kind: "keep" };
5543
+ if (incoming === "__camstack_redacted__" || incoming === LEGACY_DEVICE_REDACTION) return { kind: "keep" };
5544
+ return {
5545
+ kind: "set",
5546
+ value: incoming
5547
+ };
5548
+ }
5451
5549
  Object.fromEntries([
5452
5550
  {
5453
5551
  id: "overview",
@@ -5619,33 +5717,19 @@ Object.fromEntries([
5619
5717
  function isValuelessField(field) {
5620
5718
  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";
5621
5719
  }
5622
- /**
5623
- * Merge a `ConfigUISchema` with a raw `values` record into a
5624
- * `ConfigUISchemaWithValues`. Used by every `get*Settings` backend endpoint
5625
- * before returning to the admin UI. Groups are walked recursively.
5626
- *
5627
- * For each leaf field:
5628
- * - structural fields (`separator`, `info`, `button`) pass through unchanged
5629
- * - other fields get `value = values[key] ?? field.default ?? null`
5630
- *
5631
- * Unknown keys in `values` (keys not declared in the schema) are silently
5632
- * ignored — they don't contribute to the output. Missing keys fall back to
5633
- * the schema default or `null`. This mirrors the old backend behaviour where
5634
- * `FormBuilder` rendered `values[key] ?? field.default`.
5635
- */
5636
- function hydrateSchema(schema, values) {
5720
+ function hydrateSchema(schema, values, options = {}) {
5637
5721
  return {
5638
5722
  ...schema.tabs ? { tabs: [...schema.tabs] } : {},
5639
5723
  sections: schema.sections.map((section) => ({
5640
5724
  ...section,
5641
- fields: section.fields.map((field) => hydrateField(field, values))
5725
+ fields: section.fields.map((field) => hydrateField(field, values, options))
5642
5726
  }))
5643
5727
  };
5644
5728
  }
5645
- function hydrateField(field, values) {
5729
+ function hydrateField(field, values, options) {
5646
5730
  if (isValuelessField(field)) return field;
5647
5731
  if (field.type === "group") {
5648
- const hydratedChildren = field.fields.map((child) => hydrateField(child, values));
5732
+ const hydratedChildren = field.fields.map((child) => hydrateField(child, values, options));
5649
5733
  return {
5650
5734
  ...field,
5651
5735
  fields: hydratedChildren
@@ -5654,7 +5738,7 @@ function hydrateField(field, values) {
5654
5738
  if (field.type === "sub-tabs") {
5655
5739
  const hydratedTabs = field.tabs.map((tab) => ({
5656
5740
  ...tab,
5657
- fields: tab.fields.map((child) => hydrateField(child, values))
5741
+ fields: tab.fields.map((child) => hydrateField(child, values, options))
5658
5742
  }));
5659
5743
  return {
5660
5744
  ...field,
@@ -5664,6 +5748,33 @@ function hydrateField(field, values) {
5664
5748
  const key = field.key;
5665
5749
  const storedValue = Object.prototype.hasOwnProperty.call(values, key) ? values[key] : void 0;
5666
5750
  const defaultValue = field.default;
5751
+ const asView = (v) => isSecretMarker(v) || options.inlineSecretsAsViews === true && v !== void 0;
5752
+ if (isKeychainStoredField(field) && asView(storedValue)) return {
5753
+ ...field,
5754
+ value: toSecretFieldView(storedValue)
5755
+ };
5756
+ if (isKeychainStoredField(field) && options.inlineSecretsAsViews === true) return {
5757
+ ...field,
5758
+ value: null
5759
+ };
5760
+ if (field.type === "editable-array" && Array.isArray(storedValue)) {
5761
+ const secretItemKeys = field.itemFields.filter((item) => "key" in item && isKeychainStoredField(item)).map((item) => "key" in item ? item.key : "");
5762
+ if (secretItemKeys.length > 0) {
5763
+ const rows = storedValue.map((row) => {
5764
+ if (row === null || typeof row !== "object" || Array.isArray(row)) return row;
5765
+ const out = { ...row };
5766
+ for (const k of secretItemKeys) {
5767
+ const v = Reflect.get(row, k);
5768
+ if (asView(v)) out[k] = toSecretFieldView(v);
5769
+ }
5770
+ return out;
5771
+ });
5772
+ return {
5773
+ ...field,
5774
+ value: rows
5775
+ };
5776
+ }
5777
+ }
5667
5778
  if (field.multiple) {
5668
5779
  const stored = Array.isArray(storedValue) ? storedValue : storedValue !== void 0 && storedValue !== null ? [storedValue] : [];
5669
5780
  const itemFallback = field.multiple.itemDefault !== void 0 ? field.multiple.itemDefault : defaultValue !== void 0 ? defaultValue : typeOf(field) === "string" ? "" : null;
@@ -5906,6 +6017,778 @@ function projectStore(store, perNodeKeys, nodeId) {
5906
6017
  }
5907
6018
  return out;
5908
6019
  }
6020
+ var GLOBAL_SCOPE = { kind: "global" };
6021
+ /** The scope every addon-wide (not per-node, not per-device) setting lives in. */
6022
+ function globalSecretScope() {
6023
+ return GLOBAL_SCOPE;
6024
+ }
6025
+ function encodeSegment(value) {
6026
+ return encodeURIComponent(value);
6027
+ }
6028
+ function decodeSegment(value) {
6029
+ try {
6030
+ return decodeURIComponent(value);
6031
+ } catch {
6032
+ return null;
6033
+ }
6034
+ }
6035
+ /**
6036
+ * The field path of a value inside an array item, addressed by the item's id:
6037
+ * `arrayItemFieldPath('providers', 'authentik', 'clientSecret')` →
6038
+ * `providers[authentik].clientSecret`.
6039
+ */
6040
+ function arrayItemFieldPath(arrayKey, itemId, fieldKey) {
6041
+ return `${arrayKey}[${encodeSegment(itemId)}].${fieldKey}`;
6042
+ }
6043
+ function parseScope(segments) {
6044
+ switch (segments[0]) {
6045
+ case "global": return {
6046
+ scope: GLOBAL_SCOPE,
6047
+ used: 1
6048
+ };
6049
+ case "node": {
6050
+ const nodeId = segments[1] !== void 0 ? decodeSegment(segments[1]) : null;
6051
+ return nodeId === null || nodeId.length === 0 ? null : {
6052
+ scope: {
6053
+ kind: "node",
6054
+ nodeId
6055
+ },
6056
+ used: 2
6057
+ };
6058
+ }
6059
+ case "device": {
6060
+ const raw = segments[1];
6061
+ if (raw === void 0 || !/^\d+$/.test(raw)) return null;
6062
+ return {
6063
+ scope: {
6064
+ kind: "device",
6065
+ deviceId: Number(raw)
6066
+ },
6067
+ used: 2
6068
+ };
6069
+ }
6070
+ case "integration": {
6071
+ const id = segments[1] !== void 0 ? decodeSegment(segments[1]) : null;
6072
+ return id === null || id.length === 0 ? null : {
6073
+ scope: {
6074
+ kind: "integration",
6075
+ integrationId: id
6076
+ },
6077
+ used: 2
6078
+ };
6079
+ }
6080
+ case "row": {
6081
+ const collection = segments[1] !== void 0 ? decodeSegment(segments[1]) : null;
6082
+ const rowId = segments[2] !== void 0 ? decodeSegment(segments[2]) : null;
6083
+ if (collection === null || rowId === null || collection.length === 0 || rowId.length === 0) return null;
6084
+ return {
6085
+ scope: {
6086
+ kind: "row",
6087
+ collection,
6088
+ rowId
6089
+ },
6090
+ used: 3
6091
+ };
6092
+ }
6093
+ default: return null;
6094
+ }
6095
+ }
6096
+ /** Take a ref apart; `null` when it is not a well-formed ref. */
6097
+ function parseSecretRef(ref) {
6098
+ if (!ref.startsWith("secret://")) return null;
6099
+ const segments = ref.slice(9).split("/");
6100
+ const owner = segments[0] !== void 0 ? decodeSegment(segments[0]) : null;
6101
+ if (owner === null || owner.length === 0) return null;
6102
+ const parsed = parseScope(segments.slice(1));
6103
+ if (parsed === null) return null;
6104
+ const fieldPath = segments.slice(1 + parsed.used).join("/");
6105
+ if (fieldPath.length === 0) return null;
6106
+ return {
6107
+ owner,
6108
+ scope: parsed.scope,
6109
+ fieldPath
6110
+ };
6111
+ }
6112
+ /** A write to a secret path could not be stored in the keychain, so it was refused. */
6113
+ var KeychainWriteRefusedError = class extends Error {
6114
+ fieldPath;
6115
+ constructor(fieldPath, cause) {
6116
+ super(`secret "${fieldPath}" was not saved: the keychain could not store it (${cause instanceof Error ? cause.message : String(cause)}). Nothing was written.`);
6117
+ this.fieldPath = fieldPath;
6118
+ this.name = "KeychainWriteRefusedError";
6119
+ }
6120
+ };
6121
+ var KEEP = { kind: "keep" };
6122
+ function isRecord$1(value) {
6123
+ return typeof value === "object" && value !== null && !Array.isArray(value);
6124
+ }
6125
+ function defaultMintId() {
6126
+ return globalThis.crypto.randomUUID();
6127
+ }
6128
+ /** Every marker ref anywhere under `value`. */
6129
+ function collectSecretMarkerRefs(value, out = []) {
6130
+ if (isSecretMarker(value)) {
6131
+ out.push(value.$secret);
6132
+ return out;
6133
+ }
6134
+ if (Array.isArray(value)) for (const item of value) collectSecretMarkerRefs(item, out);
6135
+ else if (isRecord$1(value)) for (const child of Object.values(value)) collectSecretMarkerRefs(child, out);
6136
+ return out;
6137
+ }
6138
+ async function storedValueEquals(secrets, marker, candidate) {
6139
+ const resolved = (await secrets.resolve([marker.$secret]))[marker.$secret];
6140
+ return resolved?.kind === "value" && resolved.value === candidate;
6141
+ }
6142
+ async function writeLeaf(ctx, incoming, stored, fieldPath) {
6143
+ const intent = classifySecretWrite(incoming);
6144
+ const ref = ctx.secrets.ref(ctx.scope, fieldPath);
6145
+ const storedIsOurs = isSecretMarker(stored) && stored.$secret === ref;
6146
+ if (intent.kind === "keep") return KEEP;
6147
+ if (intent.kind === "set" && !ctx.operatorWrite && typeof stored === "string" && stored === intent.value) return KEEP;
6148
+ if (intent.kind === "clear") {
6149
+ if (storedIsOurs) ctx.deletes.push(ref);
6150
+ return {
6151
+ kind: "value",
6152
+ value: null
6153
+ };
6154
+ }
6155
+ if (storedIsOurs && await storedValueEquals(ctx.secrets, stored, intent.value)) return {
6156
+ kind: "value",
6157
+ value: stored
6158
+ };
6159
+ try {
6160
+ await ctx.secrets.put(ref, intent.value);
6161
+ } catch (err) {
6162
+ throw new KeychainWriteRefusedError(fieldPath, err);
6163
+ }
6164
+ return {
6165
+ kind: "value",
6166
+ value: makeSecretMarker(ref)
6167
+ };
6168
+ }
6169
+ /** Apply a member result onto `out`: KEEP restores the stored member, or removes it. */
6170
+ function applyMember(out, key, result, storedParent) {
6171
+ if (result.kind === "value") {
6172
+ out[key] = result.value;
6173
+ return;
6174
+ }
6175
+ if (Object.prototype.hasOwnProperty.call(storedParent, key)) out[key] = storedParent[key];
6176
+ else delete out[key];
6177
+ }
6178
+ async function writeMembers(ctx, children, incoming, stored, pathOf) {
6179
+ const out = { ...incoming };
6180
+ for (const [member, node] of children) applyMember(out, member, await writeNode(ctx, node, incoming[member], stored[member], pathOf(member)), stored);
6181
+ return out;
6182
+ }
6183
+ function rowId(row, idKey) {
6184
+ const raw = row[idKey];
6185
+ if (typeof raw === "string" && raw.length > 0) return raw;
6186
+ if (typeof raw === "number" && Number.isFinite(raw)) return String(raw);
6187
+ return null;
6188
+ }
6189
+ async function writeArray(ctx, node, incoming, stored, fieldPath) {
6190
+ const storedRows = Array.isArray(stored) ? stored.filter(isRecord$1) : [];
6191
+ if (!Array.isArray(incoming)) {
6192
+ ctx.deletes.push(...collectSecretMarkerRefs(storedRows));
6193
+ return {
6194
+ kind: "value",
6195
+ value: incoming
6196
+ };
6197
+ }
6198
+ const storedById = /* @__PURE__ */ new Map();
6199
+ for (const row of storedRows) {
6200
+ const id = rowId(row, node.idKey);
6201
+ if (id !== null) storedById.set(id, row);
6202
+ }
6203
+ const kept = /* @__PURE__ */ new Set();
6204
+ const rows = [];
6205
+ for (const row of incoming) {
6206
+ if (!isRecord$1(row)) {
6207
+ rows.push(row);
6208
+ continue;
6209
+ }
6210
+ const id = rowId(row, node.idKey) ?? ctx.mintId();
6211
+ kept.add(id);
6212
+ const withId = {
6213
+ ...row,
6214
+ [node.idKey]: row[node.idKey] ?? id
6215
+ };
6216
+ if (rowId(withId, node.idKey) === null) withId[node.idKey] = id;
6217
+ const storedRow = storedById.get(id) ?? {};
6218
+ rows.push(await writeMembers(ctx, node.item, withId, storedRow, (member) => arrayItemFieldPath(fieldPath, id, member)));
6219
+ }
6220
+ for (const [id, row] of storedById) if (!kept.has(id)) ctx.deletes.push(...collectSecretMarkerRefs(row));
6221
+ return {
6222
+ kind: "value",
6223
+ value: rows
6224
+ };
6225
+ }
6226
+ async function writeNode(ctx, node, incoming, stored, fieldPath) {
6227
+ switch (node.kind) {
6228
+ case "leaf": return writeLeaf(ctx, incoming, stored, fieldPath);
6229
+ case "array": return writeArray(ctx, node, incoming, stored, fieldPath);
6230
+ case "object": {
6231
+ if (!isRecord$1(incoming)) {
6232
+ if (incoming === void 0) return KEEP;
6233
+ ctx.deletes.push(...collectSecretMarkerRefs(stored));
6234
+ return {
6235
+ kind: "value",
6236
+ value: incoming
6237
+ };
6238
+ }
6239
+ const storedObj = isRecord$1(stored) ? stored : {};
6240
+ return {
6241
+ kind: "value",
6242
+ value: await writeMembers(ctx, node.children, incoming, storedObj, (m) => `${fieldPath}.${m}`)
6243
+ };
6244
+ }
6245
+ }
6246
+ }
6247
+ /** Split a perNode-scoped key (`key@nodeId`). */
6248
+ function splitNodeKey(key) {
6249
+ const at = key.indexOf("@");
6250
+ return at <= 0 ? {
6251
+ base: key,
6252
+ nodeId: null
6253
+ } : {
6254
+ base: key.slice(0, at),
6255
+ nodeId: key.slice(at + 1)
6256
+ };
6257
+ }
6258
+ /** Rewrite a settings patch so no secret value reaches the blob. See the file doc. */
6259
+ async function transformSecretWrite(input) {
6260
+ const deletes = [];
6261
+ const base = {
6262
+ secrets: input.secrets,
6263
+ mintId: input.mintId ?? defaultMintId,
6264
+ deletes,
6265
+ operatorWrite: input.operatorWrite === true
6266
+ };
6267
+ const out = {};
6268
+ for (const [key, incoming] of Object.entries(input.patch)) {
6269
+ const { base: baseKey, nodeId } = splitNodeKey(key);
6270
+ const node = input.tree.get(baseKey);
6271
+ if (node === void 0) {
6272
+ out[key] = incoming;
6273
+ continue;
6274
+ }
6275
+ const scope = nodeId !== null && nodeId.length > 0 ? {
6276
+ kind: "node",
6277
+ nodeId
6278
+ } : input.scope ?? globalSecretScope();
6279
+ const result = await writeNode({
6280
+ ...base,
6281
+ scope
6282
+ }, node, incoming, input.stored[key], baseKey);
6283
+ if (result.kind === "value") out[key] = result.value;
6284
+ }
6285
+ return {
6286
+ patch: out,
6287
+ afterWrite: async () => {
6288
+ if (deletes.length === 0) return { orphaned: [] };
6289
+ try {
6290
+ await input.secrets.delete([...new Set(deletes)]);
6291
+ return { orphaned: [] };
6292
+ } catch {
6293
+ return { orphaned: [...new Set(deletes)] };
6294
+ }
6295
+ }
6296
+ };
6297
+ }
6298
+ /** Is `ref` one of `owner`'s refs? */
6299
+ function isSecretRefOwnedBy(ref, owner) {
6300
+ return parseSecretRef(ref)?.owner === owner;
6301
+ }
6302
+ /**
6303
+ * Replace every marker in `value` with its keychain value. Returns the SAME
6304
+ * reference when there is no marker (no allocation, no keychain call).
6305
+ */
6306
+ async function resolveSecretMarkers(value, secrets, options = {}) {
6307
+ const keepMarker = options.unresolved === "keep-marker";
6308
+ const owner = options.ownedBy;
6309
+ const inScope = (ref) => owner === void 0 || isSecretRefOwnedBy(ref, owner);
6310
+ const refs = collectSecretMarkerRefs(value).filter(inScope);
6311
+ if (refs.length === 0) return {
6312
+ value,
6313
+ unresolved: []
6314
+ };
6315
+ const answers = await secrets.resolve(refs);
6316
+ const unresolved = [];
6317
+ for (const ref of new Set(refs)) {
6318
+ const answer = answers[ref];
6319
+ if (answer === void 0) unresolved.push({
6320
+ ref,
6321
+ reason: "not-initialized"
6322
+ });
6323
+ else if (answer.kind === "unavailable") unresolved.push({
6324
+ ref,
6325
+ reason: answer.reason
6326
+ });
6327
+ else if (answer.kind === "missing" || answer.kind === "forbidden") unresolved.push({
6328
+ ref,
6329
+ reason: answer.kind
6330
+ });
6331
+ }
6332
+ const substitute = (v) => {
6333
+ if (isSecretMarker(v)) {
6334
+ if (!inScope(v.$secret)) return {
6335
+ keep: true,
6336
+ value: v
6337
+ };
6338
+ const answer = answers[v.$secret];
6339
+ if (answer?.kind === "value") return {
6340
+ keep: true,
6341
+ value: answer.value
6342
+ };
6343
+ return keepMarker ? {
6344
+ keep: true,
6345
+ value: v
6346
+ } : {
6347
+ keep: false,
6348
+ value: void 0
6349
+ };
6350
+ }
6351
+ if (Array.isArray(v)) {
6352
+ const items = [];
6353
+ for (const item of v) {
6354
+ const s = substitute(item);
6355
+ if (s.keep) items.push(s.value);
6356
+ }
6357
+ return {
6358
+ keep: true,
6359
+ value: items
6360
+ };
6361
+ }
6362
+ if (isRecord$1(v)) {
6363
+ const out = {};
6364
+ for (const [k, child] of Object.entries(v)) {
6365
+ const s = substitute(child);
6366
+ if (s.keep) out[k] = s.value;
6367
+ }
6368
+ return {
6369
+ keep: true,
6370
+ value: out
6371
+ };
6372
+ }
6373
+ return {
6374
+ keep: true,
6375
+ value: v
6376
+ };
6377
+ };
6378
+ return {
6379
+ value: substitute(value).value,
6380
+ unresolved
6381
+ };
6382
+ }
6383
+ /** An addon tried to replace a stored secret it could not read. Nothing was written. */
6384
+ var SecretOverwriteRefusedError = class extends Error {
6385
+ ref;
6386
+ reason;
6387
+ constructor(ref, reason) {
6388
+ 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.`);
6389
+ this.ref = ref;
6390
+ this.reason = reason;
6391
+ this.name = "SecretOverwriteRefusedError";
6392
+ }
6393
+ };
6394
+ function isRecord(value) {
6395
+ return typeof value === "object" && value !== null && !Array.isArray(value);
6396
+ }
6397
+ function resolvedValue(pass, marker) {
6398
+ const answer = pass.answers[marker.$secret];
6399
+ return answer?.kind === "value" ? answer.value : null;
6400
+ }
6401
+ async function atMarker(pass, incoming, stored) {
6402
+ if (incoming === null) return stored;
6403
+ if (typeof incoming !== "string") return incoming;
6404
+ if (incoming === resolvedValue(pass, stored)) return stored;
6405
+ const intent = classifySecretWrite(incoming);
6406
+ if (intent.kind !== "set") return stored;
6407
+ const ref = stored.$secret;
6408
+ if (!isSecretRefOwnedBy(ref, pass.secrets.owner)) return incoming;
6409
+ const answer = pass.answers[ref];
6410
+ 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);
6411
+ try {
6412
+ await pass.secrets.put(ref, intent.value);
6413
+ } catch (err) {
6414
+ throw new KeychainWriteRefusedError(ref, err);
6415
+ }
6416
+ pass.changedRefs.push(ref);
6417
+ return stored;
6418
+ }
6419
+ function inArray(pass, incoming, stored) {
6420
+ return incoming.map((item, index) => {
6421
+ const twin = stored[index];
6422
+ if (isSecretMarker(twin)) return typeof item === "string" && item === resolvedValue(pass, twin) ? twin : item;
6423
+ if (isRecord(item) && isRecord(twin)) return inArrayRow(pass, item, twin);
6424
+ if (Array.isArray(item) && Array.isArray(twin)) return inArray(pass, item, twin);
6425
+ return item;
6426
+ });
6427
+ }
6428
+ function inArrayRow(pass, incoming, stored) {
6429
+ const out = { ...incoming };
6430
+ for (const [key, value] of Object.entries(incoming)) {
6431
+ const twin = stored[key];
6432
+ if (isSecretMarker(twin)) {
6433
+ if (typeof value === "string" && value === resolvedValue(pass, twin)) out[key] = twin;
6434
+ } else if (isRecord(value) && isRecord(twin)) out[key] = inArrayRow(pass, value, twin);
6435
+ else if (Array.isArray(value) && Array.isArray(twin)) out[key] = inArray(pass, value, twin);
6436
+ }
6437
+ return out;
6438
+ }
6439
+ async function walk(pass, incoming, stored) {
6440
+ if (isSecretMarker(stored)) return atMarker(pass, incoming, stored);
6441
+ if (Array.isArray(incoming) && Array.isArray(stored)) return inArray(pass, incoming, stored);
6442
+ if (!isRecord(incoming) || !isRecord(stored)) return incoming;
6443
+ const out = { ...incoming };
6444
+ for (const [key, value] of Object.entries(incoming)) out[key] = await walk(pass, value, stored[key]);
6445
+ return out;
6446
+ }
6447
+ /** Restore markers a write-back carries as values. See the file doc. */
6448
+ async function restoreUnchangedSecrets(input) {
6449
+ const refs = [];
6450
+ for (const key of Object.keys(input.patch)) collectSecretMarkerRefs(input.stored[key], refs);
6451
+ const owned = refs.filter((ref) => isSecretRefOwnedBy(ref, input.secrets.owner));
6452
+ if (owned.length === 0) return {
6453
+ patch: input.patch,
6454
+ changedRefs: []
6455
+ };
6456
+ const pass = {
6457
+ secrets: input.secrets,
6458
+ answers: await input.secrets.resolve([...new Set(owned)]),
6459
+ operatorWrite: input.operatorWrite,
6460
+ changedRefs: []
6461
+ };
6462
+ const out = {};
6463
+ for (const [key, value] of Object.entries(input.patch)) out[key] = await walk(pass, value, input.stored[key]);
6464
+ return {
6465
+ patch: out,
6466
+ changedRefs: pass.changedRefs
6467
+ };
6468
+ }
6469
+ /** Structural equality over JSON-shaped values (key order does not matter). */
6470
+ function isJsonEqual(a, b) {
6471
+ if (Object.is(a, b)) return true;
6472
+ if (Array.isArray(a)) return Array.isArray(b) && a.length === b.length && a.every((v, i) => isJsonEqual(v, b[i]));
6473
+ if (isRecord(a) && isRecord(b)) {
6474
+ const keys = Object.keys(a);
6475
+ if (keys.length !== Object.keys(b).length) return false;
6476
+ return keys.every((k) => Object.prototype.hasOwnProperty.call(b, k) && isJsonEqual(a[k], b[k]));
6477
+ }
6478
+ return false;
6479
+ }
6480
+ /** The patch without the keys whose value already equals the stored one. */
6481
+ function dropUnchangedKeys(patch, stored) {
6482
+ const out = {};
6483
+ for (const [key, value] of Object.entries(patch)) {
6484
+ if (Object.prototype.hasOwnProperty.call(stored, key) && isJsonEqual(value, stored[key])) continue;
6485
+ out[key] = value;
6486
+ }
6487
+ return out;
6488
+ }
6489
+ /** The top-level keys of a blob that hold at least one of `owner`'s markers. */
6490
+ function markerKeysOf(blob, owner) {
6491
+ const keys = /* @__PURE__ */ new Set();
6492
+ for (const [key, value] of Object.entries(blob)) if (collectSecretMarkerRefs(value).some((ref) => isSecretRefOwnedBy(ref, owner))) keys.add(key);
6493
+ return keys;
6494
+ }
6495
+ function nodeFromStored(value, owner) {
6496
+ if (isSecretMarker(value)) return isSecretRefOwnedBy(value.$secret, owner) ? { kind: "leaf" } : null;
6497
+ if (!isRecord(value)) return null;
6498
+ const children = /* @__PURE__ */ new Map();
6499
+ for (const [key, child] of Object.entries(value)) {
6500
+ const node = nodeFromStored(child, owner);
6501
+ if (node !== null) children.set(key, node);
6502
+ }
6503
+ return children.size > 0 ? {
6504
+ kind: "object",
6505
+ children
6506
+ } : null;
6507
+ }
6508
+ /**
6509
+ * The declared secret tree, widened by every place the STORED blob holds a
6510
+ * marker under one of `keys` — so a marker the schema no longer declares (or
6511
+ * never declared: Wyze before b4906cec6) still gets the save path's
6512
+ * KEEP / SET / CLEAR semantics instead of being overwritten by whatever the
6513
+ * addon writes. Markers inside arrays are not added: a row has no id field to
6514
+ * match by unless the schema declares one. Only `owner`'s markers count: a
6515
+ * builtin that keeps another addon's marker (device-manager) never takes it
6516
+ * over.
6517
+ */
6518
+ function widenTreeWithStoredMarkers(declared, stored, keys, owner) {
6519
+ const added = /* @__PURE__ */ new Map();
6520
+ for (const key of keys) {
6521
+ const at = key.indexOf("@");
6522
+ const base = at > 0 ? key.slice(0, at) : key;
6523
+ if (declared.has(base) || added.has(base)) continue;
6524
+ const node = nodeFromStored(stored[key], owner);
6525
+ if (node !== null) added.set(base, node);
6526
+ }
6527
+ return added.size === 0 ? declared : new Map([...declared, ...added]);
6528
+ }
6529
+ /** The blob as stored now; a failed read REFUSES the write instead of guessing. */
6530
+ async function readStoredAddonBlob(raw) {
6531
+ const threeWay = raw.readAddonStoreResult;
6532
+ if (threeWay === void 0) return raw.readAddonStore();
6533
+ const result = await threeWay.call(raw);
6534
+ if (result.kind === "failed") throw new Error(`settings write refused: the stored blob could not be read (${result.error})`);
6535
+ return result.kind === "missing" ? {} : result.value;
6536
+ }
6537
+ function touchesTree(tree, patch) {
6538
+ if (tree.size === 0) return false;
6539
+ for (const key of Object.keys(patch)) {
6540
+ const at = key.indexOf("@");
6541
+ if (tree.has(at > 0 ? key.slice(0, at) : key)) return true;
6542
+ }
6543
+ return false;
6544
+ }
6545
+ /**
6546
+ * Which top-level keys of each store held markers when last seen. `undefined`
6547
+ * for a store not seen yet: its first write reads it, to be safe.
6548
+ */
6549
+ var MarkerKeyIndex = class {
6550
+ owner;
6551
+ byStore = /* @__PURE__ */ new Map();
6552
+ constructor(owner) {
6553
+ this.owner = owner;
6554
+ }
6555
+ seen(store, blob) {
6556
+ this.byStore.set(store, markerKeysOf(blob, this.owner));
6557
+ }
6558
+ wrote(store, patch) {
6559
+ const keys = this.byStore.get(store);
6560
+ if (keys === void 0) return;
6561
+ const now = markerKeysOf(patch, this.owner);
6562
+ for (const key of Object.keys(patch)) if (now.has(key)) keys.add(key);
6563
+ else keys.delete(key);
6564
+ }
6565
+ mayHoldMarkers(store, patch) {
6566
+ const keys = this.byStore.get(store);
6567
+ if (keys === void 0) return true;
6568
+ return Object.keys(patch).some((key) => keys.has(key));
6569
+ }
6570
+ };
6571
+ function createHandle(raw, opts) {
6572
+ const chains = /* @__PURE__ */ new Map();
6573
+ const serialize = (key, fn) => {
6574
+ const next = (chains.get(key) ?? Promise.resolve()).then(fn, fn);
6575
+ const tail = next.catch(() => void 0);
6576
+ chains.set(key, tail);
6577
+ tail.then(() => {
6578
+ if (chains.get(key) === tail) chains.delete(key);
6579
+ });
6580
+ return next;
6581
+ };
6582
+ const index = new MarkerKeyIndex(opts.secrets.owner);
6583
+ const resolveRead = async (store, blob) => {
6584
+ index.seen(store, blob);
6585
+ const { value, unresolved } = await resolveSecretMarkers(blob, opts.secrets, {
6586
+ unresolved: "keep-marker",
6587
+ ownedBy: opts.secrets.owner
6588
+ });
6589
+ if (unresolved.length > 0) opts.onUnresolved?.(unresolved);
6590
+ return value;
6591
+ };
6592
+ const write = async (store, declared, scope, patch, readStored, rawWrite) => {
6593
+ if (!touchesTree(declared, patch) && !index.mayHoldMarkers(store, patch)) {
6594
+ await rawWrite(patch);
6595
+ index.wrote(store, patch);
6596
+ return { changed: true };
6597
+ }
6598
+ return serialize(store, async () => {
6599
+ const stored = await readStored();
6600
+ index.seen(store, stored);
6601
+ const operatorWrite = opts.isOperatorWrite?.() === true;
6602
+ const restored = await restoreUnchangedSecrets({
6603
+ patch,
6604
+ stored,
6605
+ secrets: opts.secrets,
6606
+ operatorWrite
6607
+ });
6608
+ const result = await transformSecretWrite({
6609
+ tree: widenTreeWithStoredMarkers(declared, stored, Object.keys(restored.patch), opts.secrets.owner),
6610
+ secrets: opts.secrets,
6611
+ patch: restored.patch,
6612
+ stored,
6613
+ ...scope !== void 0 ? { scope } : {},
6614
+ operatorWrite
6615
+ });
6616
+ const effective = dropUnchangedKeys(result.patch, stored);
6617
+ const wroteBlob = Object.keys(effective).length > 0;
6618
+ if (wroteBlob) {
6619
+ await rawWrite(effective);
6620
+ index.wrote(store, effective);
6621
+ }
6622
+ const { orphaned } = await result.afterWrite();
6623
+ if (orphaned.length > 0) opts.onOrphaned(orphaned);
6624
+ return { changed: wroteBlob || restored.changedRefs.length > 0 };
6625
+ });
6626
+ };
6627
+ const writeAddon = (patch) => write("addon", opts.addonTree(), void 0, patch, () => readStoredAddonBlob(raw), (p) => raw.writeAddonStore(p));
6628
+ const readAddonStoreResult = raw.readAddonStoreResult;
6629
+ const readAddonStoreKeyResult = raw.readAddonStoreKeyResult;
6630
+ const readDeviceStoreBatch = raw.readDeviceStoreBatch;
6631
+ const overrides = {
6632
+ readAddonStore: async () => resolveRead("addon", await raw.readAddonStore()),
6633
+ ...readAddonStoreResult !== void 0 ? { readAddonStoreResult: async () => {
6634
+ const result = await readAddonStoreResult.call(raw);
6635
+ return result.kind === "value" ? {
6636
+ kind: "value",
6637
+ value: await resolveRead("addon", result.value)
6638
+ } : result;
6639
+ } } : {},
6640
+ ...readAddonStoreKeyResult !== void 0 ? { readAddonStoreKeyResult: async (key) => {
6641
+ const result = await readAddonStoreKeyResult.call(raw, key);
6642
+ if (result.kind !== "present") return result;
6643
+ const { value, unresolved } = await resolveSecretMarkers({ [key]: result.value }, opts.secrets, {
6644
+ unresolved: "keep-marker",
6645
+ ownedBy: opts.secrets.owner
6646
+ });
6647
+ if (unresolved.length > 0) opts.onUnresolved?.(unresolved);
6648
+ return {
6649
+ kind: "present",
6650
+ value: value[key]
6651
+ };
6652
+ } } : {},
6653
+ readDeviceStore: async (deviceId) => resolveRead(`device:${deviceId}`, await raw.readDeviceStore(deviceId)),
6654
+ ...readDeviceStoreBatch !== void 0 ? { readDeviceStoreBatch: async (deviceIds) => {
6655
+ const rows = await readDeviceStoreBatch.call(raw, deviceIds);
6656
+ const out = /* @__PURE__ */ new Map();
6657
+ for (const [deviceId, blob] of rows) out.set(deviceId, await resolveRead(`device:${deviceId}`, blob));
6658
+ return out;
6659
+ } } : {},
6660
+ writeAddonStore: async (patch) => {
6661
+ await writeAddon(patch);
6662
+ },
6663
+ writeDeviceStore: async (deviceId, patch) => {
6664
+ await write(`device:${deviceId}`, opts.deviceTree(), {
6665
+ kind: "device",
6666
+ deviceId
6667
+ }, patch, () => raw.readDeviceStore(deviceId), (p) => raw.writeDeviceStore(deviceId, p));
6668
+ }
6669
+ };
6670
+ return {
6671
+ settings: new Proxy(raw, { get(target, prop, receiver) {
6672
+ if (typeof prop === "string" && Object.prototype.hasOwnProperty.call(overrides, prop)) return Reflect.get(overrides, prop);
6673
+ const value = Reflect.get(target, prop, receiver);
6674
+ return typeof value === "function" ? value.bind(target) : value;
6675
+ } }),
6676
+ raw: {
6677
+ readAddonStore: async () => {
6678
+ const blob = await raw.readAddonStore();
6679
+ index.seen("addon", blob);
6680
+ return blob;
6681
+ },
6682
+ readDeviceStore: async (deviceId) => {
6683
+ const blob = await raw.readDeviceStore(deviceId);
6684
+ index.seen(`device:${deviceId}`, blob);
6685
+ return blob;
6686
+ }
6687
+ },
6688
+ writeAddonStore: writeAddon
6689
+ };
6690
+ }
6691
+ /** The context the addon sees, plus the private raw view and write outcome. */
6692
+ function createSecretAwareContext(context, opts) {
6693
+ const raw = context.settings;
6694
+ if (raw === void 0) return {
6695
+ context,
6696
+ handle: null
6697
+ };
6698
+ const handle = createHandle(raw, opts);
6699
+ return {
6700
+ context: new Proxy(context, { get(target, prop, receiver) {
6701
+ if (prop === "settings") return handle.settings;
6702
+ return Reflect.get(target, prop, receiver);
6703
+ } }),
6704
+ handle
6705
+ };
6706
+ }
6707
+ var LEAF = { kind: "leaf" };
6708
+ var DEFAULT_ITEM_ID_KEY = "id";
6709
+ function collectFields(fields, out) {
6710
+ for (const field of fields) {
6711
+ if (field.type === "group") {
6712
+ collectFields(field.fields, out);
6713
+ continue;
6714
+ }
6715
+ if (field.type === "sub-tabs") {
6716
+ for (const tab of field.tabs) collectFields(tab.fields, out);
6717
+ continue;
6718
+ }
6719
+ if (field.type === "editable-array") {
6720
+ const item = /* @__PURE__ */ new Map();
6721
+ for (const itemField of field.itemFields) if ("key" in itemField && isKeychainStoredField(itemField)) item.set(itemField.key, LEAF);
6722
+ if (item.size > 0) out.set(field.key, {
6723
+ kind: "array",
6724
+ idKey: field.itemIdKey ?? DEFAULT_ITEM_ID_KEY,
6725
+ item
6726
+ });
6727
+ continue;
6728
+ }
6729
+ if (!("key" in field) || typeof field.key !== "string") continue;
6730
+ if (isKeychainStoredField(field)) out.set(field.key, LEAF);
6731
+ }
6732
+ }
6733
+ /** The secret tree a settings schema declares. */
6734
+ function secretTreeFromSchema(schema) {
6735
+ const out = /* @__PURE__ */ new Map();
6736
+ if (schema === null) return out;
6737
+ for (const section of schema.sections) collectFields(section.fields, out);
6738
+ return out;
6739
+ }
6740
+ /** Parse `a.b[id].c` into segments; throws on a malformed path (a declaration bug). */
6741
+ function parseSecretStatePath(path) {
6742
+ const segments = [];
6743
+ for (const raw of path.split(".")) {
6744
+ const m = /^([^[\]]+)(?:\[([^[\]]+)\])?$/.exec(raw);
6745
+ if (m === null || m[1] === void 0) throw new Error(`secretStatePaths: malformed path "${path}"`);
6746
+ segments.push(m[2] !== void 0 ? {
6747
+ key: m[1],
6748
+ idKey: m[2]
6749
+ } : { key: m[1] });
6750
+ }
6751
+ if (segments.length === 0) throw new Error(`secretStatePaths: empty path`);
6752
+ if (segments[segments.length - 1]?.idKey !== void 0) throw new Error(`secretStatePaths: "${path}" ends on an array — name the member that is secret`);
6753
+ return segments;
6754
+ }
6755
+ function insert(into, segments) {
6756
+ const [head, ...rest] = segments;
6757
+ if (head === void 0) return;
6758
+ if (rest.length === 0) {
6759
+ into.set(head.key, LEAF);
6760
+ return;
6761
+ }
6762
+ const existing = into.get(head.key);
6763
+ if (head.idKey !== void 0) {
6764
+ const item = new Map(existing?.kind === "array" ? existing.item : []);
6765
+ insert(item, rest);
6766
+ into.set(head.key, {
6767
+ kind: "array",
6768
+ idKey: head.idKey,
6769
+ item
6770
+ });
6771
+ return;
6772
+ }
6773
+ const children = new Map(existing?.kind === "object" ? existing.children : []);
6774
+ insert(children, rest);
6775
+ into.set(head.key, {
6776
+ kind: "object",
6777
+ children
6778
+ });
6779
+ }
6780
+ /** Add hidden-state paths (`secretStatePaths`) to a schema-derived tree. */
6781
+ function mergeSecretStatePaths(tree, paths) {
6782
+ if (paths.length === 0) return tree;
6783
+ const out = new Map(tree);
6784
+ for (const path of paths) insert(out, parseSecretStatePath(path));
6785
+ return out;
6786
+ }
6787
+ /** First retry of a secret the keychain could not serve; doubles to {@link SECRET_RETRY_MAX_MS}. */
6788
+ var SECRET_RETRY_FIRST_MS = 5e3;
6789
+ var SECRET_RETRY_MAX_MS = 5 * 6e4;
6790
+ /** Coalesces a burst of `keychain.changed` events into one re-resolve. */
6791
+ var SECRET_CHANGE_DEBOUNCE_MS = 250;
5909
6792
  /**
5910
6793
  * Base class for CamStack addons. Eliminates settings boilerplate:
5911
6794
  *
@@ -5975,6 +6858,33 @@ var BaseAddon = class {
5975
6858
  settingsStoreReady = false;
5976
6859
  /** Default config values. Provided via constructor. */
5977
6860
  defaults;
6861
+ /**
6862
+ * Hidden-state paths that hold secrets (D787) — values the addon writes
6863
+ * itself (`updateGlobalSettings`, `state()`) that no form field declares.
6864
+ * Stored in the keychain exactly like a `password` field. Syntax:
6865
+ * `'snapshotSigningKey'`, `'identity.pincode'`, `'tokens[userId].accessToken'`
6866
+ * (`key[<id field>]` addresses array items by id, never by index).
6867
+ */
6868
+ secretStatePaths = [];
6869
+ _addonSecretTree = null;
6870
+ _deviceSecretTree = null;
6871
+ /** Refs the last resolved config pointed at — a change to one re-resolves. */
6872
+ _configSecretRefs = /* @__PURE__ */ new Set();
6873
+ _unresolvedSecrets = [];
6874
+ _secretRetryTimer = null;
6875
+ _secretRetryDelayMs = SECRET_RETRY_FIRST_MS;
6876
+ _secretChangeTimer = null;
6877
+ _secretChangeUnsub = null;
6878
+ /** >0 while an OPERATOR's settings write is being applied. */
6879
+ _operatorWriteDepth = 0;
6880
+ /**
6881
+ * The keychain-aware settings handle (D798). Its `raw` view is the ONLY way
6882
+ * to the marker-bearing blobs and stays private to this class: the form
6883
+ * hydrate and config resolution need markers, addon code never does.
6884
+ */
6885
+ _secretSettings = null;
6886
+ /** Refs an addon-facing read could not resolve — each is logged once per process. */
6887
+ _loggedUnresolvedReads = /* @__PURE__ */ new Set();
5978
6888
  constructor(defaults) {
5979
6889
  this.defaults = defaults;
5980
6890
  this._config = { ...defaults };
@@ -6010,8 +6920,26 @@ var BaseAddon = class {
6010
6920
  return this._config;
6011
6921
  }
6012
6922
  async initialize(context) {
6013
- this._ctx = context;
6923
+ const secrets = context.secrets;
6924
+ if (secrets !== void 0) {
6925
+ const { context: wrapped, handle } = createSecretAwareContext(context, {
6926
+ secrets,
6927
+ addonTree: () => this.addonSecretTree(),
6928
+ deviceTree: () => this.deviceSecretTree(),
6929
+ onOrphaned: (refs) => context.logger.warn("keychain refs dropped by a settings write could not be deleted", { meta: { refs: [...refs] } }),
6930
+ isOperatorWrite: () => this._operatorWriteDepth > 0,
6931
+ onUnresolved: (unresolved) => this.logUnresolvedRead(unresolved)
6932
+ });
6933
+ this._ctx = wrapped;
6934
+ this._secretSettings = handle;
6935
+ } else {
6936
+ this._ctx = context;
6937
+ this._secretSettings = null;
6938
+ }
6014
6939
  await this.resolveConfig();
6940
+ if (secrets !== void 0) this._secretChangeUnsub = secrets.onChange((ref) => {
6941
+ if (this._configSecretRefs.has(ref)) this.scheduleSecretReresolve(SECRET_CHANGE_DEBOUNCE_MS);
6942
+ });
6015
6943
  const result = await this.onInitialize();
6016
6944
  this.emitLifecycle(EventCategory.AddonStarted);
6017
6945
  const normalized = normalizeAddonInitResult(result);
@@ -6044,6 +6972,12 @@ var BaseAddon = class {
6044
6972
  */
6045
6973
  async onHubReachable() {}
6046
6974
  async shutdown() {
6975
+ this._secretChangeUnsub?.();
6976
+ this._secretChangeUnsub = null;
6977
+ if (this._secretRetryTimer !== null) clearTimeout(this._secretRetryTimer);
6978
+ if (this._secretChangeTimer !== null) clearTimeout(this._secretChangeTimer);
6979
+ this._secretRetryTimer = null;
6980
+ this._secretChangeTimer = null;
6047
6981
  this.emitLifecycle(EventCategory.AddonStopped);
6048
6982
  if (this.autoEmitReadiness) this.emitReadinessForProviders("down");
6049
6983
  await this.onShutdown();
@@ -6118,11 +7052,8 @@ var BaseAddon = class {
6118
7052
  async getGlobalSettings(overlay, cap, nodeId) {
6119
7053
  const schema = this.globalSettingsSchema(cap);
6120
7054
  if (!schema) return { sections: [] };
6121
- const projected = await this.resolveGlobalStore(nodeId, cap);
6122
- return hydrateSchema(schema, overlay ? {
6123
- ...projected,
6124
- ...overlay
6125
- } : projected);
7055
+ const projected = await this.readRawProjectedStore(nodeId, cap);
7056
+ return hydrateSchema(schema, overlay ? await this.overlayKeepingMarkers(projected, overlay) : projected, { inlineSecretsAsViews: true });
6126
7057
  }
6127
7058
  /**
6128
7059
  * The integration-level view of this addon's settings: exactly the sections
@@ -6167,11 +7098,11 @@ var BaseAddon = class {
6167
7098
  });
6168
7099
  }
6169
7100
  if (sections.length === 0) return null;
6170
- const projected = await this.resolveGlobalStore(nodeId);
7101
+ const projected = await this.readRawProjectedStore(nodeId);
6171
7102
  return hydrateSchema({
6172
7103
  ...schema,
6173
7104
  sections
6174
- }, projected);
7105
+ }, projected, { inlineSecretsAsViews: true });
6175
7106
  }
6176
7107
  /**
6177
7108
  * The raw addon store PROJECTED onto the target node's bare per-node keys:
@@ -6184,12 +7115,50 @@ var BaseAddon = class {
6184
7115
  * the store for custom option logic (option narrowing, value snapping) to
6185
7116
  * read it per-node — never `ctx.settings.readAddonStore()` directly.
6186
7117
  * `nodeId` omitted ⇒ the local node (node-blind injection from ctx).
7118
+ *
7119
+ * Keychain values come back RESOLVED (D798): a secret reads as its value,
7120
+ * never as a `{ $secret }` marker. One the keychain cannot serve right now
7121
+ * stays a marker — "stored, unavailable" (`isSecretMarker()` is true, and it
7122
+ * is listed in {@link unresolvedSecrets}) — never `''` and never absent, so
7123
+ * it cannot be mistaken for "nothing stored, mint a new one". Writing the
7124
+ * resolved blob back is a no-op for every unchanged secret.
6187
7125
  */
6188
7126
  async resolveGlobalStore(nodeId, cap) {
6189
7127
  const raw = await this._ctx?.settings?.readAddonStore() ?? {};
7128
+ return this.projectForNode(raw, nodeId, cap);
7129
+ }
7130
+ projectForNode(store, nodeId, cap) {
6190
7131
  const keys = this.perNodeKeys(cap);
6191
7132
  const node = normalizeNodeId(nodeId ?? this._ctx?.kernel?.localNodeId);
6192
- return keys.size > 0 ? projectStore(raw, keys, node) : raw;
7133
+ return keys.size > 0 ? projectStore(store, keys, node) : store;
7134
+ }
7135
+ /** The PROJECTED store with its markers — the form hydrate only (D798). */
7136
+ async readRawProjectedStore(nodeId, cap) {
7137
+ const raw = await this.rawSettings()?.readAddonStore() ?? {};
7138
+ return this.projectForNode(raw, nodeId, cap);
7139
+ }
7140
+ /**
7141
+ * `{ ...stored, ...overlay }`, except that an overlay member equal to the
7142
+ * RESOLVED stored one keeps the stored (marker-bearing) member — so a form
7143
+ * hydrated from a resolved overlay still shows a secret as "set", never as
7144
+ * its value.
7145
+ */
7146
+ async overlayKeepingMarkers(stored, overlay) {
7147
+ const secrets = this._ctx?.secrets;
7148
+ const merged = {
7149
+ ...stored,
7150
+ ...overlay
7151
+ };
7152
+ if (secrets === void 0 || collectSecretMarkerRefs(stored).length === 0) return merged;
7153
+ const { value: resolved } = await resolveSecretMarkers(stored, secrets, {
7154
+ unresolved: "keep-marker",
7155
+ ownedBy: secrets.owner
7156
+ });
7157
+ for (const key of Object.keys(overlay)) {
7158
+ if (collectSecretMarkerRefs(stored[key]).length === 0) continue;
7159
+ if (isJsonEqual(overlay[key], resolved[key])) merged[key] = stored[key];
7160
+ }
7161
+ return merged;
6193
7162
  }
6194
7163
  /**
6195
7164
  * Whether ONE global key of this addon's store was written, read three-way
@@ -6225,18 +7194,58 @@ var BaseAddon = class {
6225
7194
  value: result.value[key]
6226
7195
  };
6227
7196
  }
7197
+ /**
7198
+ * The OPERATOR's write — a settings form or an admin API call, dispatched by
7199
+ * the kernel. Identical to {@link updateGlobalSettings}, except that a secret
7200
+ * the operator sends is stored as sent even when it equals a pre-keychain
7201
+ * inline value: the operator re-entering a password is a change, an addon
7202
+ * writing back what it read is not (D787).
7203
+ */
7204
+ async updateGlobalSettingsAsOperator(patch, nodeId) {
7205
+ this._operatorWriteDepth++;
7206
+ try {
7207
+ await this.applyGlobalPatch(patch, nodeId);
7208
+ } finally {
7209
+ this._operatorWriteDepth--;
7210
+ }
7211
+ }
6228
7212
  async updateGlobalSettings(patch, nodeId) {
7213
+ await this.applyGlobalPatch(patch, nodeId);
7214
+ }
7215
+ /**
7216
+ * REMOVE stored secrets — their keychain values and their markers (D787).
7217
+ *
7218
+ * Writing `''` to a secret field KEEPS what is stored (an empty string is
7219
+ * what a defaults fallback writes back, and it must never destroy a
7220
+ * credential), so code that means "forget this token" says so here. Without
7221
+ * a keychain (an older kernel) it writes `''`, as such code always did.
7222
+ */
7223
+ async clearSecrets(keys, nodeId) {
7224
+ const tree = this.addonSecretTree();
7225
+ const keychain = this._ctx?.secrets !== void 0;
7226
+ const stored = keychain ? await this.readAddonStoreWithRetry() : {};
7227
+ const patch = {};
7228
+ for (const key of keys) {
7229
+ const keychainStored = tree.has(key) || collectSecretMarkerRefs(stored[key]).length > 0;
7230
+ patch[key] = keychain && keychainStored ? SECRET_CLEAR : "";
7231
+ }
7232
+ await this.applyGlobalPatch(patch, nodeId);
7233
+ }
7234
+ async applyGlobalPatch(barePatch, nodeId) {
6229
7235
  const keys = this.perNodeKeys();
6230
7236
  const localNode = normalizeNodeId(this._ctx?.kernel?.localNodeId);
6231
7237
  const target = normalizeNodeId(nodeId ?? this._ctx?.kernel?.localNodeId);
6232
- const barePatch = patch;
6233
7238
  const scoped = keys.size > 0 ? scopePatch(barePatch, keys, target) : barePatch;
6234
- await this._ctx?.settings?.writeAddonStore(scoped);
7239
+ const handle = this._secretSettings;
7240
+ if (handle !== null) {
7241
+ const { changed } = await handle.writeAddonStore(scoped);
7242
+ if (!changed) return;
7243
+ } else await this._ctx?.settings?.writeAddonStore(scoped);
6235
7244
  if (target !== localNode) return;
6236
7245
  await this.resolveConfig();
6237
7246
  await this.onConfigChanged();
6238
7247
  this.emitLifecycle(EventCategory.AddonUpdated, { level: "global" });
6239
- this.maybeAutoRestart(patch, this.globalSettingsSchema());
7248
+ this.maybeAutoRestart(Object.keys(barePatch), this.globalSettingsSchema());
6240
7249
  }
6241
7250
  /**
6242
7251
  * The set of field keys the global settings schema declares `perNode: true`
@@ -6261,7 +7270,7 @@ var BaseAddon = class {
6261
7270
  * time to return its response before the addon is torn down and
6262
7271
  * re-initialised by `AddonRegistryService.restartAddon`.
6263
7272
  */
6264
- maybeAutoRestart(patch, schema) {
7273
+ maybeAutoRestart(patchKeys, schema) {
6265
7274
  if (!schema) return;
6266
7275
  const restartKeys = /* @__PURE__ */ new Set();
6267
7276
  for (const section of schema.sections) for (const field of section.fields) {
@@ -6269,13 +7278,13 @@ var BaseAddon = class {
6269
7278
  if (field.requiresRestart) restartKeys.add(field.key);
6270
7279
  }
6271
7280
  if (restartKeys.size === 0) return;
6272
- if (!Object.keys(patch).some((k) => restartKeys.has(k))) return;
7281
+ if (!patchKeys.some((k) => restartKeys.has(k))) return;
6273
7282
  const ctx = this._ctx;
6274
7283
  if (!ctx) return;
6275
7284
  const addonId = ctx.id;
6276
7285
  setImmediate(() => {
6277
7286
  ctx.api.addons?.restartAddon?.mutate({ addonId }).then(() => {
6278
- ctx.logger.info("addon auto-restart triggered by restart-required setting change", { meta: { changedFields: Object.keys(patch).filter((k) => restartKeys.has(k)) } });
7287
+ ctx.logger.info("addon auto-restart triggered by restart-required setting change", { meta: { changedFields: patchKeys.filter((k) => restartKeys.has(k)) } });
6279
7288
  }).catch((err) => {
6280
7289
  ctx.logger.error("addon auto-restart failed", { meta: { error: err instanceof Error ? err.message : String(err) } });
6281
7290
  });
@@ -6284,7 +7293,7 @@ var BaseAddon = class {
6284
7293
  async getDeviceSettings(deviceId) {
6285
7294
  const schema = this.deviceSettingsSchema();
6286
7295
  if (!schema) return { sections: [] };
6287
- return hydrateSchema(schema, await this._ctx?.settings?.readDeviceStore(deviceId) ?? {});
7296
+ return hydrateSchema(schema, await this.rawSettings()?.readDeviceStore(deviceId) ?? {}, { inlineSecretsAsViews: true });
6288
7297
  }
6289
7298
  async updateDeviceSettings(deviceId, patch) {
6290
7299
  await this._ctx?.settings?.writeDeviceStore(deviceId, patch);
@@ -6414,7 +7423,7 @@ var BaseAddon = class {
6414
7423
  * selection at boot (absent scoped key ⇒ the constructor default wins).
6415
7424
  */
6416
7425
  async resolveConfig() {
6417
- const stored = await this.readAddonStoreWithRetry();
7426
+ const stored = await this.resolveStoredSecrets(await this.readAddonStoreWithRetry());
6418
7427
  const perNode = this.perNodeKeys();
6419
7428
  const localNode = normalizeNodeId(this._ctx?.kernel?.localNodeId);
6420
7429
  const resolved = { ...this.defaults };
@@ -6439,7 +7448,7 @@ var BaseAddon = class {
6439
7448
  key,
6440
7449
  schema,
6441
7450
  fallback,
6442
- read: () => this.readAddonStoreWithRetry(),
7451
+ read: async () => this.resolveStoredSecrets(await this.readAddonStoreWithRetry()),
6443
7452
  write: async (patch) => {
6444
7453
  await this._ctx?.settings?.writeAddonStore(patch);
6445
7454
  },
@@ -6456,7 +7465,7 @@ var BaseAddon = class {
6456
7465
  key,
6457
7466
  schema,
6458
7467
  fallback,
6459
- read: async () => await this._ctx?.settings?.readDeviceStore(deviceId) ?? {},
7468
+ read: async () => this.resolveStoredSecrets(await this.rawSettings()?.readDeviceStore(deviceId) ?? {}, false),
6460
7469
  write: async (patch) => {
6461
7470
  await this._ctx?.settings?.writeDeviceStore(deviceId, patch);
6462
7471
  },
@@ -6468,6 +7477,87 @@ var BaseAddon = class {
6468
7477
  } })
6469
7478
  });
6470
7479
  }
7480
+ /** The addon store's secret tree: schema fields by TYPE, plus `secretStatePaths`. */
7481
+ addonSecretTree() {
7482
+ this._addonSecretTree ??= mergeSecretStatePaths(secretTreeFromSchema(this.globalSettingsSchema()), this.secretStatePaths);
7483
+ return this._addonSecretTree;
7484
+ }
7485
+ deviceSecretTree() {
7486
+ this._deviceSecretTree ??= secretTreeFromSchema(this.deviceSettingsSchema());
7487
+ return this._deviceSecretTree;
7488
+ }
7489
+ /**
7490
+ * Secrets of this addon's stored config that could not be resolved on the
7491
+ * last read, with why. Non-empty means the addon is running WITHOUT them —
7492
+ * an addon whose function needs one should report itself degraded rather
7493
+ * than start on an empty credential.
7494
+ */
7495
+ get unresolvedSecrets() {
7496
+ return this._unresolvedSecrets;
7497
+ }
7498
+ /**
7499
+ * Substitute every keychain marker in a stored blob with its value. With no
7500
+ * keychain (no `ctx.secrets`) or no marker, the blob comes back unchanged.
7501
+ * An unresolvable value is LEFT OUT (never `''`), logged by ref — never by
7502
+ * value — and, when the cause can pass, retried with backoff. Nothing is
7503
+ * ever written back from here.
7504
+ */
7505
+ async resolveStoredSecrets(blob, trackForConfig = true) {
7506
+ const secrets = this._ctx?.secrets;
7507
+ if (secrets === void 0) return blob;
7508
+ const refs = collectSecretMarkerRefs(blob);
7509
+ if (trackForConfig) this._configSecretRefs = new Set(refs);
7510
+ if (refs.length === 0) {
7511
+ if (trackForConfig) this._unresolvedSecrets = [];
7512
+ return blob;
7513
+ }
7514
+ const { value, unresolved } = await resolveSecretMarkers(blob, secrets);
7515
+ if (trackForConfig) {
7516
+ this._unresolvedSecrets = unresolved;
7517
+ if (unresolved.length > 0) {
7518
+ this._ctx?.logger?.error?.("secret unavailable — running without it, will retry", { meta: { secrets: unresolved.map((u) => ({
7519
+ ref: u.ref,
7520
+ reason: u.reason
7521
+ })) } });
7522
+ if (unresolved.some((u) => u.reason !== "missing" && u.reason !== "forbidden")) {
7523
+ this.scheduleSecretReresolve(this._secretRetryDelayMs);
7524
+ this._secretRetryDelayMs = Math.min(this._secretRetryDelayMs * 2, SECRET_RETRY_MAX_MS);
7525
+ }
7526
+ } else this._secretRetryDelayMs = SECRET_RETRY_FIRST_MS;
7527
+ }
7528
+ return value;
7529
+ }
7530
+ /**
7531
+ * The marker-bearing settings reads (D798) — private on purpose. Without a
7532
+ * keychain the context's own view is already raw.
7533
+ */
7534
+ rawSettings() {
7535
+ return this._secretSettings?.raw ?? this._ctx?.settings;
7536
+ }
7537
+ /** An addon-facing read met markers it could not resolve: say so once per ref. */
7538
+ logUnresolvedRead(unresolved) {
7539
+ const fresh = unresolved.filter((u) => !this._loggedUnresolvedReads.has(u.ref));
7540
+ if (fresh.length === 0) return;
7541
+ for (const u of fresh) this._loggedUnresolvedReads.add(u.ref);
7542
+ 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) => ({
7543
+ ref: u.ref,
7544
+ reason: u.reason
7545
+ })) } });
7546
+ }
7547
+ /** Re-resolve the config (a keychain-only change, or a retry) and apply it. */
7548
+ scheduleSecretReresolve(delayMs) {
7549
+ const timerOf = delayMs === SECRET_CHANGE_DEBOUNCE_MS ? "_secretChangeTimer" : "_secretRetryTimer";
7550
+ if (this[timerOf] !== null) return;
7551
+ const timer = setTimeout(() => {
7552
+ this[timerOf] = null;
7553
+ if (this._ctx === null) return;
7554
+ this.resolveConfig().then(() => this.onConfigChanged()).catch((err) => {
7555
+ this._ctx?.logger?.error?.("re-resolving secrets failed", { meta: { error: err instanceof Error ? err.message : String(err) } });
7556
+ });
7557
+ }, delayMs);
7558
+ timer.unref?.();
7559
+ this[timerOf] = timer;
7560
+ }
6471
7561
  /**
6472
7562
  * Wrap `ctx.settings.readAddonStore()` with a short retry budget so a
6473
7563
  * transient settings-store outage (mid-restart of sqlite-settings, tsx-watch
@@ -6480,7 +7570,7 @@ var BaseAddon = class {
6480
7570
  * `{}` (defaults) — the addon's first successful patch will rehydrate.
6481
7571
  */
6482
7572
  async readAddonStoreWithRetry() {
6483
- const settings = this._ctx?.settings;
7573
+ const settings = this.rawSettings();
6484
7574
  if (!settings) return {};
6485
7575
  const delaysMs = [
6486
7576
  150,
@@ -7043,6 +8133,69 @@ method(object({ deviceId: number() }), array(StreamSourceEntrySchema)), method(o
7043
8133
  kind: "mutation",
7044
8134
  auth: "admin"
7045
8135
  }), method(object({ deviceId: number() }), unknown().nullable()), method(object({ deviceId: number() }), RawStateResultSchema.nullable(), { auth: "protected" });
8136
+ function defOf(schema) {
8137
+ return schema._zod?.def ?? {};
8138
+ }
8139
+ function declaredHere(schema) {
8140
+ return globalRegistry.get(schema)?.secret === true;
8141
+ }
8142
+ /** Wrapper kinds whose `innerType` is the field itself. */
8143
+ var WRAPPERS = new Set([
8144
+ "optional",
8145
+ "nullable",
8146
+ "default",
8147
+ "prefault",
8148
+ "catch",
8149
+ "readonly",
8150
+ "nonoptional"
8151
+ ]);
8152
+ /**
8153
+ * The schema layers that make up ONE field: the schema itself and every
8154
+ * wrapper below it (optional / default / nullable / readonly / catch), plus
8155
+ * both sides of a pipe (`z.preprocess` puts the real schema on `out`,
8156
+ * `.transform` on `in`).
8157
+ */
8158
+ function layersOf(schema) {
8159
+ const out = [];
8160
+ const queue = [schema];
8161
+ while (queue.length > 0) {
8162
+ const s = queue.shift();
8163
+ if (!s || out.includes(s)) continue;
8164
+ out.push(s);
8165
+ const def = defOf(s);
8166
+ if (def.type !== void 0 && WRAPPERS.has(def.type) && def.innerType) queue.push(def.innerType);
8167
+ if (def.type === "pipe") {
8168
+ if (def.in) queue.push(def.in);
8169
+ if (def.out) queue.push(def.out);
8170
+ }
8171
+ }
8172
+ return out;
8173
+ }
8174
+ /** True when any layer of this field declares `.meta({ secret: true })`. */
8175
+ function isZodSecret(schema) {
8176
+ return layersOf(schema).some(declaredHere);
8177
+ }
8178
+ /**
8179
+ * Every declared secret path in a config schema: dotted keys, `[]` for "each
8180
+ * element of this array" (`connection.password`, `rows[].token`). A declared
8181
+ * object or array is reported as one path and not descended into — everything
8182
+ * under it is secret.
8183
+ */
8184
+ function collectZodSecretPaths(schema, prefix = "") {
8185
+ if (isZodSecret(schema)) return prefix.length > 0 ? [prefix] : [];
8186
+ const paths = [];
8187
+ for (const layer of layersOf(schema)) {
8188
+ const def = defOf(layer);
8189
+ if (def.type === "object" && def.shape) for (const [key, child] of Object.entries(def.shape)) paths.push(...collectZodSecretPaths(child, prefix ? `${prefix}.${key}` : key));
8190
+ else if (def.type === "array" && def.element) paths.push(...collectZodSecretPaths(def.element, `${prefix}[]`));
8191
+ else if (def.type === "union" && def.options) for (const option of def.options) paths.push(...collectZodSecretPaths(option, prefix));
8192
+ else if (def.type === "intersection") {
8193
+ if (def.left) paths.push(...collectZodSecretPaths(def.left, prefix));
8194
+ if (def.right) paths.push(...collectZodSecretPaths(def.right, prefix));
8195
+ }
8196
+ }
8197
+ return [...new Set(paths)];
8198
+ }
7046
8199
  //#endregion
7047
8200
  //#region ../types/dist/err-msg-DX6i_MY4.mjs
7048
8201
  var DeviceType = /* @__PURE__ */ function(DeviceType) {
@@ -8720,6 +9873,278 @@ var CameraSwitchGroupSchema = object({
8720
9873
  fetchedAt: number()
8721
9874
  });
8722
9875
  /**
9876
+ * The trainer contract — what the hub hands the cloud trainer and what it
9877
+ * gets back (cloud training, D805+).
9878
+ *
9879
+ * The trainer (`hf/camstack-trainer`, published as the Hugging Face repo
9880
+ * `camstack/camstack-trainer`) is a separate AGPL program the hub never
9881
+ * imports: `job.json` goes in, files come out, and progress is `CAMSTACK_EVENT`
9882
+ * lines on stdout. These schemas are the hub's half of that boundary; the
9883
+ * trainer's pydantic models (and the JSON Schemas generated from them under
9884
+ * `hf/camstack-trainer/schemas/`) are the other half. A change here is a
9885
+ * change there, in the same piece of work.
9886
+ *
9887
+ * No `.default()` anywhere: defaults do not run on the addon cap path, so the
9888
+ * orchestrator fills every field of a job spec explicitly.
9889
+ */
9890
+ var TRAINING_JOB_SCHEMA = "camstack.training/v1";
9891
+ var TRAINING_RESULT_SCHEMA = "camstack.training-result/v1";
9892
+ /** What the trainer can export. Edge TPU is a later, separate image. */
9893
+ var TrainingExportSchema = _enum([
9894
+ "onnx",
9895
+ "openvino-fp16",
9896
+ "openvino-int8",
9897
+ "coreml-fp16"
9898
+ ]);
9899
+ var FloorsSchema = record(string(), number().min(0).max(1));
9900
+ object({
9901
+ schema: literal(TRAINING_JOB_SCHEMA),
9902
+ jobKey: string().uuid(),
9903
+ target: object({
9904
+ kind: literal("detector"),
9905
+ step: literal("object-detection")
9906
+ }),
9907
+ base: object({
9908
+ modelId: string().min(1),
9909
+ /** Ultralytics weights id, e.g. `yolov9m.pt`. */
9910
+ weights: string().min(1),
9911
+ imgsz: number().int().positive()
9912
+ }),
9913
+ baseline: object({
9914
+ modelId: string().min(1),
9915
+ /** The baseline ONNX the holdout comparison runs; public mirror URL. */
9916
+ onnxUrl: string().url(),
9917
+ imgsz: number().int().positive(),
9918
+ floors: FloorsSchema
9919
+ }),
9920
+ dataset: object({
9921
+ versionId: string().min(1),
9922
+ annotationHash: string(),
9923
+ /** sha256 of the uploaded archive; the trainer refuses a mismatch (exit 65). */
9924
+ sha256: string().regex(/^[0-9a-f]{64}$/)
9925
+ }),
9926
+ split: object({
9927
+ holdoutCameras: array(number().int()),
9928
+ /** When no camera is held out: the last N days of every camera. */
9929
+ holdoutLastDays: number().int().nonnegative(),
9930
+ valFraction: number().min(0).max(.5),
9931
+ seed: number().int()
9932
+ }),
9933
+ hyper: object({
9934
+ epochs: number().int().positive(),
9935
+ batch: number().int().positive(),
9936
+ lr0: number().positive(),
9937
+ /** Layers frozen from the start of the backbone; 0 = none. */
9938
+ freeze: number().int().nonnegative(),
9939
+ patience: number().int().nonnegative(),
9940
+ seed: number().int()
9941
+ }),
9942
+ replay: object({
9943
+ source: literal("coco2017"),
9944
+ count: number().int().nonnegative()
9945
+ }),
9946
+ exports: array(TrainingExportSchema).min(1),
9947
+ calibration: object({ maxFrames: number().int().positive() }),
9948
+ floors: object({
9949
+ minSupport: number().int().positive(),
9950
+ clamp: number().min(0).max(1)
9951
+ }),
9952
+ int8Gate: object({ maxMap50Drop: number().min(0).max(1) }),
9953
+ catalog: object({
9954
+ id: string().regex(/^[a-z0-9][a-z0-9-]{2,80}$/),
9955
+ name: string().min(1).max(160)
9956
+ })
9957
+ });
9958
+ /** One regular file of the bundle. An mlpackage contributes one row per member. */
9959
+ var TrainingResultFileSchema = object({
9960
+ path: string().min(1),
9961
+ bytes: number().int().nonnegative(),
9962
+ sha256: string().regex(/^[0-9a-f]{64}$/),
9963
+ format: _enum([
9964
+ "onnx",
9965
+ "openvino",
9966
+ "coreml",
9967
+ "pt"
9968
+ ]),
9969
+ variant: _enum(["base", "int8"])
9970
+ });
9971
+ var DraftFormatSchema = object({
9972
+ /** RELATIVE path inside the bundle; the hub rewrites it to `camstack-local://`. */
9973
+ url: string().min(1),
9974
+ sizeMB: number().nonnegative(),
9975
+ isDirectory: boolean().optional(),
9976
+ files: array(string()).optional(),
9977
+ runtimes: array(literal("python")).optional(),
9978
+ revision: string().min(1)
9979
+ });
9980
+ /** The trainer's half of a catalog entry; the hub completes it (labels, licence, group). */
9981
+ var TrainingCatalogDraftSchema = object({
9982
+ id: string().min(1),
9983
+ name: string().min(1),
9984
+ description: string(),
9985
+ labels: array(unknown()),
9986
+ inputSize: object({
9987
+ width: number().int().positive(),
9988
+ height: number().int().positive()
9989
+ }),
9990
+ preprocessMode: literal("letterbox"),
9991
+ defaultClassFloors: FloorsSchema,
9992
+ formats: object({
9993
+ onnx: DraftFormatSchema.optional(),
9994
+ openvino: DraftFormatSchema.optional(),
9995
+ coreml: DraftFormatSchema.optional()
9996
+ })
9997
+ });
9998
+ /** One class of one model's holdout report (the eval harness's summary). */
9999
+ var TrainingEvalClassSchema = object({
10000
+ positives: number().int(),
10001
+ floor: number().nullable(),
10002
+ tp: number().int(),
10003
+ fp: number().int(),
10004
+ fn: number().int(),
10005
+ precision: number().nullable(),
10006
+ recall: number().nullable(),
10007
+ ap50: number().nullable(),
10008
+ recallByCamera: record(string(), number().nullable()).optional(),
10009
+ recallByLight: record(string(), number().nullable()).optional(),
10010
+ fpByCamera: record(string(), number()).optional(),
10011
+ smallFound: number().int().optional(),
10012
+ smallTotal: number().int().optional()
10013
+ }).passthrough();
10014
+ var TrainingEvalReportSchema = object({
10015
+ frames: number().int(),
10016
+ classes: record(string(), TrainingEvalClassSchema)
10017
+ }).passthrough();
10018
+ /**
10019
+ * A succeeded result carries every block; a failed one carries the error and
10020
+ * whatever was known by then — the other blocks are ABSENT, not null. The
10021
+ * orchestrator checks the blocks it needs before it trusts a success.
10022
+ */
10023
+ var TrainingResultSchema = object({
10024
+ schema: literal(TRAINING_RESULT_SCHEMA),
10025
+ jobKey: string(),
10026
+ status: _enum(["succeeded", "failed"]),
10027
+ error: object({
10028
+ stage: string(),
10029
+ code: string(),
10030
+ message: string()
10031
+ }).nullable(),
10032
+ trainer: object({
10033
+ version: string(),
10034
+ revision: string()
10035
+ }),
10036
+ toolchain: record(string(), string().nullable()),
10037
+ dataset: object({
10038
+ versionId: string(),
10039
+ annotationHash: string(),
10040
+ sha256: string(),
10041
+ frames: object({
10042
+ train: number().int(),
10043
+ val: number().int(),
10044
+ holdout: number().int()
10045
+ }),
10046
+ holdoutCameras: array(number().int()),
10047
+ replayImages: number().int()
10048
+ }).optional(),
10049
+ training: object({
10050
+ epochsRun: number().int(),
10051
+ bestEpoch: number().int(),
10052
+ bestMap50: number(),
10053
+ bestMap50_95: number(),
10054
+ seconds: number()
10055
+ }).optional(),
10056
+ evaluation: object({
10057
+ holdoutFrames: number().int(),
10058
+ baseline: TrainingEvalReportSchema.nullable(),
10059
+ candidate: TrainingEvalReportSchema.nullable(),
10060
+ candidateInt8: TrainingEvalReportSchema.nullable(),
10061
+ recallDeltaByCamera: record(string(), record(string(), number())).nullable(),
10062
+ map50: record(string(), number().nullable())
10063
+ }).optional(),
10064
+ floors: object({
10065
+ baseline: FloorsSchema,
10066
+ candidate: FloorsSchema,
10067
+ candidateInt8: FloorsSchema.nullable(),
10068
+ notes: array(string())
10069
+ }).optional(),
10070
+ int8: object({
10071
+ kept: boolean(),
10072
+ map50Fp16: number().nullable(),
10073
+ map50Int8: number().nullable(),
10074
+ reason: string().nullable()
10075
+ }).optional(),
10076
+ exportsDropped: array(object({
10077
+ export: string(),
10078
+ reason: string()
10079
+ })).optional(),
10080
+ files: array(TrainingResultFileSchema).optional(),
10081
+ bundle: object({
10082
+ path: literal("bundle.tar"),
10083
+ bytes: number().int().nonnegative(),
10084
+ sha256: string().regex(/^[0-9a-f]{64}$/)
10085
+ }).nullable().optional(),
10086
+ catalogDraft: object({
10087
+ base: TrainingCatalogDraftSchema,
10088
+ int8: TrainingCatalogDraftSchema.nullable()
10089
+ }).nullable().optional(),
10090
+ licence: string()
10091
+ });
10092
+ var TrainingStageSchema = _enum([
10093
+ "prepare",
10094
+ "replay",
10095
+ "train",
10096
+ "eval",
10097
+ "export",
10098
+ "package"
10099
+ ]);
10100
+ var EventBase = {
10101
+ v: literal(1),
10102
+ ts: number()
10103
+ };
10104
+ discriminatedUnion("type", [
10105
+ object({
10106
+ ...EventBase,
10107
+ type: literal("stage"),
10108
+ stage: TrainingStageSchema
10109
+ }),
10110
+ object({
10111
+ ...EventBase,
10112
+ type: literal("epoch"),
10113
+ epoch: number().int(),
10114
+ epochs: number().int(),
10115
+ boxLoss: number().nullable().optional(),
10116
+ map50: number().nullable().optional(),
10117
+ map50_95: number().nullable().optional(),
10118
+ etaSec: number().nullable().optional()
10119
+ }),
10120
+ object({
10121
+ ...EventBase,
10122
+ type: literal("metric"),
10123
+ name: string(),
10124
+ value: number()
10125
+ }),
10126
+ object({
10127
+ ...EventBase,
10128
+ type: literal("artifact"),
10129
+ path: string(),
10130
+ bytes: number(),
10131
+ sha256: string()
10132
+ }),
10133
+ object({
10134
+ ...EventBase,
10135
+ type: literal("done"),
10136
+ status: _enum(["succeeded", "failed"]),
10137
+ resultSha256: string().nullable().optional()
10138
+ }),
10139
+ object({
10140
+ ...EventBase,
10141
+ type: literal("error"),
10142
+ stage: string(),
10143
+ code: string(),
10144
+ message: string()
10145
+ })
10146
+ ]);
10147
+ /**
8723
10148
  * What the gate decided about a birth, from the CALLER's point of view.
8724
10149
  *
8725
10150
  * Deliberately not `ConfirmationVerdict`: `undecided` is not a birth decision
@@ -11047,7 +12472,9 @@ var AddonHttpRouteSchema = object({
11047
12472
  "authenticated",
11048
12473
  "admin"
11049
12474
  ]).optional(),
11050
- description: string().optional()
12475
+ description: string().optional(),
12476
+ /** The hub limits this route per client address before the handler runs. */
12477
+ rateLimit: _enum(["auth"]).optional()
11051
12478
  });
11052
12479
  /**
11053
12480
  * Cross-process route invocation envelope. The hub captures the
@@ -11752,6 +13179,37 @@ var BackupDestinationInfoSchema = object({
11752
13179
  lastError: string().optional()
11753
13180
  });
11754
13181
  /**
13182
+ * How an archive is encrypted (operator decision 2026-10-09): to a backup
13183
+ * PUBLIC key the hub holds, so only the operator's secret key opens it.
13184
+ * Absent on a plain `.tar.gz` — every archive made before encryption, or
13185
+ * with it off — which restores without a key.
13186
+ */
13187
+ var BackupArchiveEncryptionSchema = object({
13188
+ /** `x25519-hkdf-aes256gcm-stream-v1`. */
13189
+ scheme: string(),
13190
+ /** 16 hex — the backup key whose secret restores this archive. */
13191
+ keyId: string()
13192
+ });
13193
+ /**
13194
+ * The backup encryption setting. The hub keeps PUBLIC keys only: the active
13195
+ * one new archives are encrypted to, and the retired ones older archives
13196
+ * still need. The secret key is shown once, at `setupEncryption`.
13197
+ */
13198
+ var BackupEncryptionStatusSchema = object({
13199
+ enabled: boolean(),
13200
+ active: object({
13201
+ keyId: string(),
13202
+ publicKey: string(),
13203
+ createdAt: number()
13204
+ }).nullable(),
13205
+ /** Every key ever set up, newest first. */
13206
+ keys: array(object({
13207
+ keyId: string(),
13208
+ createdAt: number(),
13209
+ retiredAt: number().nullable()
13210
+ })).readonly()
13211
+ });
13212
+ /**
11755
13213
  * Per-archive entry returned by `backup.listArchives({ destinationId })`.
11756
13214
  * Same shape the destination drill-in renders. Sourced from the per-
11757
13215
  * location `manifests.json` (no per-archive tarball read required).
@@ -11763,7 +13221,9 @@ var BackupArchiveEntrySchema = object({
11763
13221
  sizeBytes: number(),
11764
13222
  label: string().optional(),
11765
13223
  /** Top-level locations included in the archive (db, addons, tls, …). */
11766
- locations: array(string()).readonly()
13224
+ locations: array(string()).readonly(),
13225
+ /** Present when the archive is encrypted; restore then needs that key. */
13226
+ encryption: BackupArchiveEncryptionSchema.optional()
11767
13227
  });
11768
13228
  var BackupEntrySchema = object({
11769
13229
  id: string(),
@@ -11772,7 +13232,8 @@ var BackupEntrySchema = object({
11772
13232
  label: string().optional(),
11773
13233
  createdAt: number(),
11774
13234
  sizeBytes: number(),
11775
- locations: array(string()).optional()
13235
+ locations: array(string()).optional(),
13236
+ encryption: BackupArchiveEncryptionSchema.optional()
11776
13237
  });
11777
13238
  var ArchiveEntrySchema = object({
11778
13239
  path: string(),
@@ -11961,10 +13422,40 @@ method(_void(), array(BackupDestinationInfoSchema).readonly(), { auth: "admin" }
11961
13422
  * this list and skips entries whose path doesn't start with
11962
13423
  * any of them.
11963
13424
  */
11964
- locations: array(string()).optional()
13425
+ locations: array(string()).optional(),
13426
+ /**
13427
+ * The backup SECRET key, for an encrypted archive (ignored for a plain
13428
+ * one). The archive is decrypted into the hub's private staging
13429
+ * before the restart; the key is not stored. A wrong or missing key
13430
+ * is refused before the archive is downloaded.
13431
+ */
13432
+ backupSecretKey: string().optional()
11965
13433
  }), _void(), {
11966
13434
  kind: "mutation",
11967
13435
  auth: "admin"
13436
+ }), method(_void(), BackupEncryptionStatusSchema, { auth: "admin" }), method(object({}), object({
13437
+ keyId: string(),
13438
+ secretKey: string(),
13439
+ publicKey: string(),
13440
+ createdAt: number(),
13441
+ replacedKeyId: string().nullable()
13442
+ }), {
13443
+ kind: "mutation",
13444
+ auth: "admin"
13445
+ }), method(object({}), object({ disabledKeyId: string().nullable() }), {
13446
+ kind: "mutation",
13447
+ auth: "admin"
13448
+ }), method(object({ backupSecretKey: string() }), object({
13449
+ valid: boolean(),
13450
+ keyId: string().nullable(),
13451
+ /** The hub knows this key (active or retired). */
13452
+ known: boolean(),
13453
+ /** It is the key new archives are encrypted to. */
13454
+ active: boolean(),
13455
+ error: string().optional()
13456
+ }), {
13457
+ kind: "mutation",
13458
+ auth: "admin"
11968
13459
  }), method(object({
11969
13460
  destinationId: string(),
11970
13461
  backupId: string()
@@ -13690,7 +15181,60 @@ var CustomModelDescriptorSchema = object({
13690
15181
  stepId: string(),
13691
15182
  entry: ModelCatalogEntrySchema
13692
15183
  });
13693
- method(_void(), array(CustomModelDescriptorSchema).readonly(), { auth: "admin" });
15184
+ /** One regular file of an imported bundle, as the producer measured it. */
15185
+ var ModelBundleFileSchema = object({
15186
+ /** Relative path inside the bundle tar; an mlpackage member is `<x>.mlpackage/<member>`. */
15187
+ path: string().min(1),
15188
+ bytes: number().int().nonnegative(),
15189
+ sha256: string().regex(/^[0-9a-f]{64}$/)
15190
+ });
15191
+ var ImportModelBundleInputSchema = object({
15192
+ /** The registry provider that keeps the model (Model Studio). */
15193
+ addonId: string(),
15194
+ stepId: string().min(1),
15195
+ /**
15196
+ * The catalog rows to register, complete, every format URL already
15197
+ * `camstack-local://<modelId>/<file>` naming a file of the bundle. One
15198
+ * bundle may carry several rows (a base and its INT8 variant).
15199
+ */
15200
+ entries: array(ModelCatalogEntrySchema).min(1).max(4),
15201
+ /** The bundle tar, offered by the producer over `ctx.peerBytes` (same host). */
15202
+ bundle: object({
15203
+ ticket: PeerBytesTicketSchema,
15204
+ bytes: number().int().positive(),
15205
+ sha256: string().regex(/^[0-9a-f]{64}$/)
15206
+ }),
15207
+ /** Every file the tar must hold; anything missing, extra or different is refused. */
15208
+ files: array(ModelBundleFileSchema).min(1).max(64),
15209
+ /** Convert missing engine formats and push the model to every agent afterwards. */
15210
+ distribute: boolean()
15211
+ });
15212
+ var ImportModelBundleResultSchema = discriminatedUnion("kind", [object({
15213
+ kind: literal("imported"),
15214
+ modelIds: array(string()).readonly(),
15215
+ distributed: array(object({
15216
+ modelId: string(),
15217
+ nodeId: string(),
15218
+ format: _enum(MODEL_FORMATS),
15219
+ ok: boolean(),
15220
+ error: string().optional()
15221
+ })).readonly()
15222
+ }), object({
15223
+ kind: literal("refused"),
15224
+ reason: _enum([
15225
+ "transfer-failed",
15226
+ "checksum-mismatch",
15227
+ "bundle-mismatch",
15228
+ "invalid-entry",
15229
+ "id-taken"
15230
+ ]),
15231
+ detail: string()
15232
+ })]);
15233
+ method(_void(), array(CustomModelDescriptorSchema).readonly(), { auth: "admin" }), method(ImportModelBundleInputSchema, ImportModelBundleResultSchema, {
15234
+ kind: "mutation",
15235
+ auth: "admin",
15236
+ timeoutMs: 30 * 6e4
15237
+ });
13694
15238
  /**
13695
15239
  * Query filter for settings-store collections.
13696
15240
  */
@@ -14073,6 +15617,253 @@ id: union([string(), number()]) }), {
14073
15617
  kind: "mutation",
14074
15618
  auth: "admin"
14075
15619
  });
15620
+ /**
15621
+ * `keychain` — the hub's encrypted store of secret values (D787).
15622
+ *
15623
+ * Settings blobs never hold a secret: they hold a marker
15624
+ * `{"$secret":"secret://<owner>/<scope>/<fieldPath>","v":1}` and the value
15625
+ * lives here, AES-256-GCM under a data key that a master key wraps. This cap
15626
+ * is the OWNER's door to its own values: every method is owner-checked
15627
+ * against the CALLER, never against anything the caller claims.
15628
+ *
15629
+ * Who the caller is: the transport stamps `callerAddonId` into the args of a
15630
+ * call that crossed a process (the parent `LocalChildRegistry` from the UDS
15631
+ * connection, the agent from its child's connection carried in
15632
+ * `$hub-cap-fwd`'s envelope). A stamp always overwrites; a wire call with no
15633
+ * stamp has its claim stripped. Only a hub in-process caller may state its own
15634
+ * identity — `ctx.secrets` does that with the addon id closed over. This is
15635
+ * identity against BUGS and misrouting, not against a malicious addon (every
15636
+ * runner is the same OS user): see the threat model in
15637
+ * `docs/design/2026-10-08-secrets-keychain.md`.
15638
+ *
15639
+ * `callerAddonId` is deliberately NOT in any input schema: the tRPC router
15640
+ * parses the input, so a session can never supply it, and the internal mount
15641
+ * floors every method to admin anyway (D240).
15642
+ *
15643
+ * Internal: addons reach it through `ctx.secrets`, never directly.
15644
+ */
15645
+ /** Why a value cannot be served right now. Never folded into "missing". */
15646
+ var KeychainUnavailableReasonSchema = _enum([
15647
+ "key-missing",
15648
+ "wrong-key",
15649
+ "key-file-unreadable",
15650
+ "store-unavailable",
15651
+ "not-initialized",
15652
+ "decrypt-failed"
15653
+ ]);
15654
+ var KeychainStateSchema = discriminatedUnion("state", [object({ state: literal("ready") }), object({
15655
+ state: literal("locked"),
15656
+ reason: KeychainUnavailableReasonSchema
15657
+ })]);
15658
+ var KeychainResolveEntrySchema = discriminatedUnion("kind", [
15659
+ object({
15660
+ kind: literal("value"),
15661
+ value: string(),
15662
+ version: number().int()
15663
+ }),
15664
+ object({ kind: literal("missing") }),
15665
+ object({
15666
+ kind: literal("unavailable"),
15667
+ reason: KeychainUnavailableReasonSchema
15668
+ }),
15669
+ object({ kind: literal("forbidden") })
15670
+ ]);
15671
+ var KeychainResolveResultSchema = record(string(), KeychainResolveEntrySchema);
15672
+ /** Metadata of one stored value — never the value. */
15673
+ var KeychainSecretMetaSchema = object({
15674
+ ref: string(),
15675
+ owner: string(),
15676
+ /** Formatted scope (`global`, `node/<id>`, `device/<id>`, …). */
15677
+ scope: string(),
15678
+ fieldPath: string(),
15679
+ version: number().int(),
15680
+ createdAt: number(),
15681
+ updatedAt: number(),
15682
+ /** `addon:<id>` | `user:<id>` | `system`. */
15683
+ updatedBy: string(),
15684
+ /** Coarse — written at most once an hour per ref. `null` = never read. */
15685
+ lastReadAt: number().nullable()
15686
+ });
15687
+ var RefListSchema = array(string().min(1)).max(512);
15688
+ method(object({
15689
+ ref: string().min(1),
15690
+ value: string().min(1)
15691
+ }), object({
15692
+ ref: string(),
15693
+ version: number().int()
15694
+ }), {
15695
+ kind: "mutation",
15696
+ auth: "admin"
15697
+ }), method(object({ refs: RefListSchema }), KeychainResolveResultSchema, { auth: "admin" }), method(object({ refs: RefListSchema }), object({ deleted: number().int() }), {
15698
+ kind: "mutation",
15699
+ auth: "admin"
15700
+ }), method(object({}), array(KeychainSecretMetaSchema).readonly(), { auth: "admin" }), method(object({}), KeychainStateSchema, { auth: "admin" });
15701
+ var KeychainKeySourceSchema = object({
15702
+ kind: _enum([
15703
+ "config-file",
15704
+ "previous-config-file",
15705
+ "platform",
15706
+ "default-file"
15707
+ ]),
15708
+ /** File sources only — a path is not a secret. */
15709
+ path: string().optional(),
15710
+ /**
15711
+ * True when a whole-volume backup of the data directory carries this key
15712
+ * next to the database it protects (the default file). The page warns.
15713
+ */
15714
+ sharesBackupWithDatabase: boolean()
15715
+ });
15716
+ /**
15717
+ * One keychain reset, as the Secrets page reports it until the operator
15718
+ * acknowledges it. Never a value: refs, counts and table names only.
15719
+ */
15720
+ var KeychainResetRecordSchema = object({
15721
+ id: string(),
15722
+ at: number(),
15723
+ /** `user:<id>` or {@link KEYCHAIN_RESET_TRIGGER_ACTOR}. */
15724
+ actor: string(),
15725
+ /** Why the keychain was locked when it was reset; `null` when it was not locked. */
15726
+ lockedReason: string().nullable(),
15727
+ /** Values moved into the archive table (ciphertext under the lost key). */
15728
+ archived: number().int(),
15729
+ /** `keychain:secrets-orphaned-<ts>`, or `null` when nothing was stored. */
15730
+ archivedCollection: string().nullable(),
15731
+ /**
15732
+ * `keychain:keys-orphaned-<ts>`: the wrapped data keys of the archive, kept
15733
+ * so the archive can still be opened if the lost master key turns up.
15734
+ */
15735
+ archivedKeysCollection: string().nullable(),
15736
+ /**
15737
+ * `system-settings` keys whose marker the reset cleared — the cluster
15738
+ * secret's: a marker left pointing at an archived value would refuse every
15739
+ * agent forever (D797).
15740
+ */
15741
+ clearedSettingsKeys: array(string()).readonly(),
15742
+ /** When an operator dismissed the notice on the Secrets page; `null` until then. */
15743
+ acknowledgedAt: number().nullable()
15744
+ });
15745
+ var KeychainStatusSchema = object({
15746
+ keychain: KeychainStateSchema,
15747
+ /** The source of the master key in use; `null` while locked. */
15748
+ keySource: KeychainKeySourceSchema.nullable(),
15749
+ /** The source configured to be primary — differs from `keySource` while a rotation is pending. */
15750
+ configuredSource: KeychainKeySourceSchema,
15751
+ /** Short fingerprint of the master key in use (`HMAC(KEK, label)`, 16 hex). */
15752
+ fingerprint: string().nullable(),
15753
+ activeKeyId: string().nullable(),
15754
+ /**
15755
+ * The keychain unlocked with a NON-primary source: the configured primary
15756
+ * key is not the one that wraps the data key yet. `rotateMasterKey` moves it.
15757
+ */
15758
+ rotationPending: boolean(),
15759
+ /** Wrapped copies of the data key under a previous master key, kept until purged. */
15760
+ retiredWraps: number().int(),
15761
+ recoveryKeyDownloadedAt: number().nullable(),
15762
+ secretCount: number().int(),
15763
+ /** The most recent reset, acknowledged or not; `null` when the keychain was never reset. */
15764
+ lastReset: KeychainResetRecordSchema.nullable()
15765
+ });
15766
+ /**
15767
+ * Whether a stored value is still pointed at by its owner's settings.
15768
+ * `unknown` is a first-class answer: a scope whose blob could not be read is
15769
+ * never reported as an orphan (and never deleted as one).
15770
+ */
15771
+ var KeychainSecretUsageSchema = _enum([
15772
+ "in-use",
15773
+ "orphan",
15774
+ "unknown"
15775
+ ]);
15776
+ var KeychainAdminSecretSchema = KeychainSecretMetaSchema.extend({ usage: KeychainSecretUsageSchema });
15777
+ var KeychainAuditActionSchema = _enum([
15778
+ "put",
15779
+ "delete",
15780
+ "reveal",
15781
+ "rotate-master-key",
15782
+ "purge-retired-keys",
15783
+ "download-recovery-key",
15784
+ "delete-orphans",
15785
+ "reset",
15786
+ "acknowledge-reset",
15787
+ "initialize"
15788
+ ]);
15789
+ var KeychainAuditEntrySchema = object({
15790
+ id: string(),
15791
+ at: number(),
15792
+ action: KeychainAuditActionSchema,
15793
+ /** `addon:<id>` | `user:<id>` | `system` | `trigger-file`. */
15794
+ actor: string(),
15795
+ ref: string().nullable(),
15796
+ detail: string().nullable()
15797
+ });
15798
+ var KEYCHAIN_RESET_CONFIRMATION = "RESET KEYCHAIN";
15799
+ /**
15800
+ * Secrets the HUB itself holds (owner `system`) that no settings form shows:
15801
+ * `jwt-signing-key` — the session signing key (D797). It is always "in use",
15802
+ * never an orphan; it is generated on a fresh hub and replaced only through
15803
+ * {@link keychainAdminCapability.methods.setSystemSecret}.
15804
+ */
15805
+ var SystemHeldSecretNameSchema = _enum(["jwt-signing-key"]);
15806
+ 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({
15807
+ value: string(),
15808
+ version: number().int()
15809
+ }), {
15810
+ kind: "mutation",
15811
+ auth: "admin",
15812
+ caller: "required"
15813
+ }), method(object({
15814
+ name: SystemHeldSecretNameSchema,
15815
+ value: string().min(16)
15816
+ }), object({
15817
+ ref: string(),
15818
+ version: number().int()
15819
+ }), {
15820
+ kind: "mutation",
15821
+ auth: "admin",
15822
+ caller: "required"
15823
+ }), method(object({ refs: array(string().min(1)).max(1e3) }), object({
15824
+ deleted: array(string()).readonly(),
15825
+ kept: array(object({
15826
+ ref: string(),
15827
+ usage: KeychainSecretUsageSchema
15828
+ })).readonly()
15829
+ }), {
15830
+ kind: "mutation",
15831
+ auth: "admin",
15832
+ caller: "required"
15833
+ }), method(object({}), object({
15834
+ fingerprint: string(),
15835
+ keySource: KeychainKeySourceSchema
15836
+ }), {
15837
+ kind: "mutation",
15838
+ auth: "admin",
15839
+ caller: "required"
15840
+ }), method(object({}), object({ purged: number().int() }), {
15841
+ kind: "mutation",
15842
+ auth: "admin",
15843
+ caller: "required"
15844
+ }), method(object({}), object({
15845
+ key: string(),
15846
+ fingerprint: string(),
15847
+ keySource: KeychainKeySourceSchema
15848
+ }), {
15849
+ kind: "mutation",
15850
+ auth: "admin",
15851
+ caller: "required"
15852
+ }), method(object({ confirm: literal(KEYCHAIN_RESET_CONFIRMATION) }), object({
15853
+ archivedCollection: string().nullable(),
15854
+ archived: number().int()
15855
+ }), {
15856
+ kind: "mutation",
15857
+ auth: "admin",
15858
+ caller: "required"
15859
+ }), method(object({}), object({
15860
+ reset: KeychainResetRecordSchema.nullable(),
15861
+ pendingReentry: array(KeychainSecretMetaSchema).readonly()
15862
+ }), { auth: "admin" }), method(object({}), object({ acknowledged: boolean() }), {
15863
+ kind: "mutation",
15864
+ auth: "admin",
15865
+ caller: "required"
15866
+ });
14076
15867
  method(_void(), object({
14077
15868
  id: string(),
14078
15869
  name: string(),
@@ -15411,7 +17202,11 @@ var DeviceRegisterPayloadSchema = object({
15411
17202
  var DeviceRemovePayloadSchema = object({ deviceId: number() });
15412
17203
  var DevicePersistConfigPayloadSchema = object({
15413
17204
  deviceId: number(),
15414
- data: record(string(), unknown())
17205
+ data: record(string(), unknown()),
17206
+ /** The paths the device's schema declares secret (D783), when the caller
17207
+ * knows them — those values are kept in the keychain, not the blob (D787).
17208
+ * Absent: the paths the device last reported at `registerDevice` apply. */
17209
+ secretConfigPaths: array(string()).optional()
15415
17210
  });
15416
17211
  /** What a migration actually did, per switch. `unreachable` is a first-class
15417
17212
  * answer: a camera that could not be asked is not a camera that was silenced. */
@@ -17014,7 +18809,7 @@ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
17014
18809
  * `login-method` — collection cap through which auth addons contribute
17015
18810
  * their pre-auth login surfaces to the login page. This is the SINGLE,
17016
18811
  * generic mechanism that supersedes the dead `auth.listProviders` reader:
17017
- * every auth addon (OIDC, magic-link, WebAuthn/passkey) registers a
18812
+ * every auth addon (OIDC, WebAuthn/passkey) registers a
17018
18813
  * `login-method` provider and the PUBLIC `auth.listLoginMethods`
17019
18814
  * procedure aggregates them for the unauthenticated login page.
17020
18815
  *
@@ -17022,8 +18817,7 @@ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
17022
18817
  *
17023
18818
  * - `redirect` — a declarative button. The login page renders a generic
17024
18819
  * button that navigates to `startUrl` (an addon-owned HTTP route).
17025
- * Covers OIDC (`/addon/auth-oidc/<id>/start`) and magic-link with
17026
- * ZERO shell-side JS. A future SSO addon plugs in the same way — the
18820
+ * Covers OIDC (`/addon/auth-oidc/<id>/start`) with ZERO shell-side JS. A future SSO addon plugs in the same way — the
17027
18821
  * login page needs NO change.
17028
18822
  *
17029
18823
  * - `widget` — a Module-Federation widget the login page mounts (via
@@ -17042,8 +18836,8 @@ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
17042
18836
  * decision.
17043
18837
  *
17044
18838
  * Every contribution carries a `stage`:
17045
- * - `primary` — shown on the first credentials screen (OIDC /
17046
- * magic-link buttons; a future usernameless passkey).
18839
+ * - `primary` — shown on the first credentials screen (OIDC
18840
+ * buttons; a usernameless passkey).
17047
18841
  * - `second-factor` — shown AFTER the password leg, gated on the
17048
18842
  * returned `factors` (passkey-as-2FA today).
17049
18843
  *
@@ -17070,7 +18864,7 @@ var LoginMethodContributionSchema = discriminatedUnion("kind", [
17070
18864
  * The provider names an external identity a signed-in user can link to
17071
18865
  * their own account (D782): `auth.listLinkableProviders` /
17072
18866
  * `beginExternalLink` offer exactly the redirect methods that set this,
17073
- * whatever their id. Absent / false — a login button only (magic-link).
18867
+ * whatever their id. Absent / false — a login button only.
17074
18868
  */
17075
18869
  linkable: boolean().optional()
17076
18870
  }),
@@ -20925,8 +22719,7 @@ method(object({}), object({ rules: array(NcRuleSchema) }), { auth: "admin" }), m
20925
22719
  * `super_admin` — collapsed onto the single boolean because every
20926
22720
  * non-admin caller is governed by the same scope-check rules; the
20927
22721
  * distinction was only ever used to route role-specific procedures
20928
- * which we no longer have. Agents are admin sessions issued via
20929
- * `createServiceToken`; CLI / webhook integrations are `cst_*` tokens
22722
+ * which we no longer have. CLI / webhook integrations are `cst_*` tokens
20930
22723
  * with `isAdmin: false` + an explicit scope list.
20931
22724
  */
20932
22725
  /** Per-method access flavour. Materialised on every cap method via codegen. */
@@ -22428,8 +24221,23 @@ var RetrainMacroClassSchema = _enum([
22428
24221
  ]);
22429
24222
  /** A subject to learn, or a phantom to unlearn (taught by OMISSION). */
22430
24223
  var RetrainAnnotationKindSchema = _enum(["subject", "model_error"]);
22431
- /** Did a human draw this box, or did the assist propose it? */
22432
- var RetrainAnnotationSourceSchema = _enum(["operator", "assist"]);
24224
+ /**
24225
+ * Where a box came from. A machine-sourced box is a DRAFT on the page until
24226
+ * the operator confirms it; once saved it keeps its source as provenance.
24227
+ *
24228
+ * - `operator` — drawn by hand.
24229
+ * - `assist` — proposed by a detector run on the copy (the camera's own
24230
+ * model, or a larger teacher model).
24231
+ * - `pipeline` — the box the live pipeline actually drew on that frame, read
24232
+ * back from the track store (never a re-run).
24233
+ * - `llm` — proposed by a vision-capable LLM profile.
24234
+ */
24235
+ var RetrainAnnotationSourceSchema = _enum([
24236
+ "operator",
24237
+ "assist",
24238
+ "pipeline",
24239
+ "llm"
24240
+ ]);
22433
24241
  /** Normalised `[0,1]` rectangle against the FULL frame — the canonical form. */
22434
24242
  var RetrainBboxSchema = object({
22435
24243
  x: number(),
@@ -22447,7 +24255,8 @@ var RetrainBboxSchema = object({
22447
24255
  */
22448
24256
  var RetrainAnnotationSchema = object({
22449
24257
  id: string(),
22450
- trackId: string(),
24258
+ /** The frame's track. Absent on a recording still, which has none. */
24259
+ trackId: string().optional(),
22451
24260
  deviceId: number(),
22452
24261
  /** The COPY in retrain storage — never the source track's media key. */
22453
24262
  mediaKey: string(),
@@ -22496,13 +24305,47 @@ var RetrainFrameCandidateSchema = object({
22496
24305
  * fail, whatever became of the original. */
22497
24306
  copied: boolean()
22498
24307
  });
24308
+ /**
24309
+ * One box the live pipeline drew on a copied frame — what a correction starts
24310
+ * from. Derived when the frame is listed, from the track store: the subject
24311
+ * box recorded on the source media row when there is one, else the track
24312
+ * position nearest the frame's capture time. Never stored as an annotation
24313
+ * until the operator confirms it.
24314
+ */
24315
+ var RetrainPipelineBoxSchema = object({
24316
+ /** Normalised `[0,1]` against the full frame. */
24317
+ bbox: RetrainBboxSchema,
24318
+ macroClass: RetrainMacroClassSchema,
24319
+ label: string().optional(),
24320
+ subLabel: string().optional(),
24321
+ /** The detection score of the position used, when it was recorded. */
24322
+ score: number().optional(),
24323
+ /** The root model that produced the track, when it was recorded. */
24324
+ modelId: string().optional(),
24325
+ trackId: string(),
24326
+ /** `subject-box`: recorded on this very frame. `position`: the track's
24327
+ * position nearest the capture time, `deltaMs` away. */
24328
+ basis: _enum(["subject-box", "position"]),
24329
+ deltaMs: number()
24330
+ });
24331
+ /**
24332
+ * Where a retrain frame came from: a TRACK's stored media (copy-on-select),
24333
+ * or the RECORDING at an instant — the frame a model saw nothing in has no
24334
+ * track at all.
24335
+ */
24336
+ var RetrainFrameOriginSchema = _enum(["track", "recording"]);
22499
24337
  /** A frame the dataset OWNS: bytes copied at selection time. */
22500
24338
  var RetrainFrameSchema = object({
22501
24339
  frameId: string(),
22502
24340
  deviceId: number(),
22503
- trackId: string(),
22504
- /** Provenance only. It may already point at nothing — that is expected. */
22505
- sourceMediaId: number().int(),
24341
+ origin: RetrainFrameOriginSchema,
24342
+ /** The track it was copied from. Absent on a recording still. */
24343
+ trackId: string().optional(),
24344
+ /** Provenance only. It may already point at nothing — that is expected.
24345
+ * Absent on a recording still. */
24346
+ sourceMediaId: number().int().optional(),
24347
+ /** A recording still: the playhead instant it was taken at. */
24348
+ epochMs: number().optional(),
22506
24349
  sourceKind: MediaFileKindEnum,
22507
24350
  sizeBytes: number().int(),
22508
24351
  width: number().int(),
@@ -22513,7 +24356,12 @@ var RetrainFrameSchema = object({
22513
24356
  /** The operator's "every subject in this frame is boxed". Detector
22514
24357
  * evaluation keeps only complete frames: an unboxed subject would count as
22515
24358
  * a false positive. */
22516
- complete: boolean()
24359
+ complete: boolean(),
24360
+ /** The boxes the pipeline drew on this frame. Present on list answers;
24361
+ * empty when nothing the track store holds can be placed on it. */
24362
+ pipelineBoxes: array(RetrainPipelineBoxSchema).readonly().optional(),
24363
+ /** The named collections this frame belongs to. Present on list answers. */
24364
+ collectionIds: array(string()).readonly().optional()
22517
24365
  });
22518
24366
  /** Why a copy-on-select could not be honoured — named, never a silent skip. */
22519
24367
  var RetrainCopyRefusalSchema = _enum([
@@ -22544,6 +24392,11 @@ var RetrainFrameListSchema = object({
22544
24392
  var RetrainExportFilterSchema = object({
22545
24393
  deviceIds: array(number()).optional(),
22546
24394
  frameIds: array(string()).max(2e4).optional(),
24395
+ /** Only frames in at least one of these named collections. */
24396
+ collectionIds: array(string()).max(200).optional(),
24397
+ /** Exactly the frames of this dataset version (and its completeOnly). An
24398
+ * unknown id selects nothing. */
24399
+ datasetVersionId: string().optional(),
22547
24400
  batchId: string().optional(),
22548
24401
  /** Only frames the operator marked complete (all subjects boxed). */
22549
24402
  completeOnly: boolean().optional()
@@ -22608,6 +24461,170 @@ var RetrainAssistResultSchema = discriminatedUnion("kind", [object({
22608
24461
  reason: string(),
22609
24462
  detail: string().optional()
22610
24463
  })]);
24464
+ /** A named set over the retrain corpus — membership only, it owns no pixels. */
24465
+ var RetrainCollectionSchema = object({
24466
+ id: string(),
24467
+ name: string(),
24468
+ createdAt: number(),
24469
+ frameCount: number().int()
24470
+ });
24471
+ var RetrainCollectionCreateResultSchema = discriminatedUnion("kind", [object({
24472
+ kind: literal("created"),
24473
+ collection: RetrainCollectionSchema
24474
+ }), object({
24475
+ kind: literal("refused"),
24476
+ reason: _enum(["empty-name", "duplicate-name"])
24477
+ })]);
24478
+ var RetrainCollectionRenameResultSchema = discriminatedUnion("kind", [object({
24479
+ kind: literal("renamed"),
24480
+ collection: RetrainCollectionSchema
24481
+ }), object({
24482
+ kind: literal("refused"),
24483
+ reason: _enum([
24484
+ "empty-name",
24485
+ "duplicate-name",
24486
+ "unknown-collection"
24487
+ ])
24488
+ })]);
24489
+ /**
24490
+ * The outcome of adding the frame at a recording instant. Every refusal is
24491
+ * named: `still-unavailable` (not recording, a gap, or an undecodable frame —
24492
+ * `detail` says which), `still-busy` (the recorder is at its decode bound; try
24493
+ * again), `unreadable-image`, `write-failed`, `unknown-collection`.
24494
+ */
24495
+ var AddRetrainFrameFromRecordingResultSchema = discriminatedUnion("kind", [object({
24496
+ kind: literal("added"),
24497
+ collectionId: string(),
24498
+ frame: RetrainFrameSchema,
24499
+ /** The moment was already in the dataset; nothing was decoded. */
24500
+ reused: boolean()
24501
+ }), object({
24502
+ kind: literal("refused"),
24503
+ reason: _enum([
24504
+ "unknown-collection",
24505
+ "still-unavailable",
24506
+ "still-busy",
24507
+ "unreadable-image",
24508
+ "write-failed"
24509
+ ]),
24510
+ detail: string().optional()
24511
+ })]);
24512
+ /** A vision LLM profile the AI assist may use, and where it sends the frame. */
24513
+ var RetrainAssistProfileSchema = object({
24514
+ id: string(),
24515
+ name: string(),
24516
+ model: string(),
24517
+ kind: string(),
24518
+ /** `true` when the frame would leave the house (a cloud vendor, or an
24519
+ * endpoint that is not on the local network). The page confirms each such
24520
+ * run, and the provider refuses one without `allowCloud`. */
24521
+ leavesHouse: boolean()
24522
+ });
24523
+ /** A box the AI assist proposed: a draft, plus the model's own reason. */
24524
+ var RetrainLlmProposalSchema = RetrainAnnotationDraftSchema.extend({ reason: string() });
24525
+ /** What the AI assist said about a box that was already on the canvas. */
24526
+ var RetrainLlmReviewSchema = object({
24527
+ /** The `ref` the page sent the box under. */
24528
+ ref: string(),
24529
+ verdict: _enum([
24530
+ "confirmed",
24531
+ "wrong-class",
24532
+ "not-an-object",
24533
+ "uncertain"
24534
+ ]),
24535
+ suggestedClass: RetrainMacroClassSchema.optional(),
24536
+ reason: string()
24537
+ });
24538
+ /**
24539
+ * The AI assist's answer. `proposed` carries drafts (`source: 'llm'`, the
24540
+ * model and its confidence) and reviews; items the model got wrong (a box off
24541
+ * the frame, an unasked class, an unknown ref) are dropped and counted in
24542
+ * `rejected`. A whole answer that is not the schema is `malformed-answer`.
24543
+ */
24544
+ var RetrainLlmAssistResultSchema = discriminatedUnion("kind", [object({
24545
+ kind: literal("proposed"),
24546
+ profileId: string(),
24547
+ model: string(),
24548
+ /** The frame was sent outside the house for this answer. */
24549
+ leftHouse: boolean(),
24550
+ proposals: array(RetrainLlmProposalSchema).readonly(),
24551
+ reviews: array(RetrainLlmReviewSchema).readonly(),
24552
+ rejected: number().int()
24553
+ }), object({
24554
+ kind: literal("refused"),
24555
+ reason: _enum([
24556
+ "unknown-frame",
24557
+ "unreadable-frame",
24558
+ "unknown-profile",
24559
+ "profile-disabled",
24560
+ "no-vision",
24561
+ "cloud-not-confirmed",
24562
+ "llm-error",
24563
+ "malformed-answer"
24564
+ ]),
24565
+ detail: string().optional()
24566
+ })]);
24567
+ /** What a dataset version is cut from. Every field narrows. */
24568
+ var RetrainDatasetSelectionSchema = object({
24569
+ deviceIds: array(number()).readonly().optional(),
24570
+ collectionIds: array(string()).max(200).readonly().optional(),
24571
+ frameIds: array(string()).max(2e4).readonly().optional()
24572
+ });
24573
+ /** The counts a dataset is judged by. */
24574
+ var RetrainDatasetStatsSchema = object({
24575
+ frames: number().int(),
24576
+ completeFrames: number().int(),
24577
+ /** `completeFrames / frames`, 0..1. */
24578
+ completeness: number(),
24579
+ /** Boxes to learn (model errors excluded). */
24580
+ subjects: number().int(),
24581
+ modelErrors: number().int(),
24582
+ /** Complete frames with no subject. */
24583
+ hardNegatives: number().int(),
24584
+ /** Subjects per class × camera × day/night. */
24585
+ cells: array(object({
24586
+ macroClass: string(),
24587
+ deviceId: number(),
24588
+ lighting: _enum([
24589
+ "day",
24590
+ "night",
24591
+ "unknown"
24592
+ ]),
24593
+ subjects: number().int(),
24594
+ frames: number().int()
24595
+ })).readonly(),
24596
+ cameras: array(object({
24597
+ deviceId: number(),
24598
+ frames: number().int(),
24599
+ completeFrames: number().int()
24600
+ })).readonly()
24601
+ });
24602
+ /** An immutable dataset version, without its frame list. */
24603
+ var RetrainDatasetVersionSchema = object({
24604
+ id: string(),
24605
+ name: string(),
24606
+ createdAt: number(),
24607
+ selection: RetrainDatasetSelectionSchema,
24608
+ layout: RetrainExportLayoutSchema,
24609
+ completeOnly: boolean(),
24610
+ frameCount: number().int(),
24611
+ /** sha256 of what the frames taught when the version was frozen. */
24612
+ annotationHash: string(),
24613
+ /** The export manifest schema the version was cut under. */
24614
+ manifestSchema: string(),
24615
+ stats: RetrainDatasetStatsSchema
24616
+ });
24617
+ var CreateRetrainDatasetVersionResultSchema = discriminatedUnion("kind", [object({
24618
+ kind: literal("created"),
24619
+ version: RetrainDatasetVersionSchema
24620
+ }), object({
24621
+ kind: literal("refused"),
24622
+ reason: _enum([
24623
+ "empty-name",
24624
+ "duplicate-name",
24625
+ "no-frames"
24626
+ ])
24627
+ })]);
22611
24628
  /** The outcome of a lifecycle move owned by the retrain page. */
22612
24629
  var RetrainTransitionResultSchema = object({
22613
24630
  trackId: string(),
@@ -23325,7 +25342,7 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
23325
25342
  auth: "admin"
23326
25343
  }), method(object({
23327
25344
  deviceId: number(),
23328
- trackId: string(),
25345
+ trackId: string().optional(),
23329
25346
  frameId: string()
23330
25347
  }), object({
23331
25348
  removed: boolean(),
@@ -23342,7 +25359,8 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
23342
25359
  auth: "admin"
23343
25360
  }), method(object({
23344
25361
  deviceId: number(),
23345
- trackId: string(),
25362
+ /** The frame's track, when it has one — checked against the frame. */
25363
+ trackId: string().optional(),
23346
25364
  frameId: string(),
23347
25365
  subject: RetrainAssistSubjectSchema,
23348
25366
  /** Which node runs it. Absent ⇒ wherever an unowned call lands. */
@@ -23350,12 +25368,16 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
23350
25368
  }), RetrainAssistResultSchema, {
23351
25369
  kind: "mutation",
23352
25370
  auth: "admin"
23353
- }), method(object({ trackId: string() }), array(RetrainAnnotationSchema).readonly(), {
25371
+ }), method(object({
25372
+ trackId: string().optional(),
25373
+ frameIds: array(string()).max(2e3).optional()
25374
+ }), array(RetrainAnnotationSchema).readonly(), {
23354
25375
  kind: "query",
23355
25376
  auth: "admin"
23356
25377
  }), method(object({
23357
25378
  deviceId: number(),
23358
- trackId: string(),
25379
+ /** The frame's track, when it has one — checked against the frame. */
25380
+ trackId: string().optional(),
23359
25381
  frameId: string(),
23360
25382
  annotations: array(RetrainAnnotationDraftSchema)
23361
25383
  }), array(RetrainAnnotationSchema).readonly(), {
@@ -23378,7 +25400,7 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
23378
25400
  auth: "admin"
23379
25401
  }), method(object({
23380
25402
  deviceId: number(),
23381
- trackId: string(),
25403
+ trackId: string().optional(),
23382
25404
  frameId: string(),
23383
25405
  complete: boolean()
23384
25406
  }), RetrainFrameSchema, {
@@ -23392,6 +25414,115 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
23392
25414
  kind: "mutation",
23393
25415
  auth: "admin",
23394
25416
  timeoutMs: 60 * 6e4
25417
+ }), method(object({
25418
+ filter: RetrainExportFilterSchema,
25419
+ layout: RetrainExportLayoutSchema
25420
+ }), object({
25421
+ ticket: PeerBytesTicketSchema,
25422
+ frames: number().int(),
25423
+ annotations: number().int()
25424
+ }), {
25425
+ kind: "mutation",
25426
+ auth: "admin",
25427
+ timeoutMs: 12e4
25428
+ }), method(object({
25429
+ selection: RetrainDatasetSelectionSchema,
25430
+ completeOnly: boolean().optional()
25431
+ }), RetrainDatasetStatsSchema, {
25432
+ kind: "query",
25433
+ auth: "admin"
25434
+ }), method(object({
25435
+ name: string().max(120),
25436
+ selection: RetrainDatasetSelectionSchema,
25437
+ layout: RetrainExportLayoutSchema,
25438
+ completeOnly: boolean()
25439
+ }), CreateRetrainDatasetVersionResultSchema, {
25440
+ kind: "mutation",
25441
+ auth: "admin",
25442
+ timeoutMs: 12e4
25443
+ }), method(object({}), array(RetrainDatasetVersionSchema).readonly(), {
25444
+ kind: "query",
25445
+ auth: "admin"
25446
+ }), method(object({ id: string() }), object({ deleted: boolean() }), {
25447
+ kind: "mutation",
25448
+ auth: "admin"
25449
+ }), method(object({ id: string() }), object({
25450
+ found: boolean(),
25451
+ annotationHash: string(),
25452
+ matches: boolean(),
25453
+ missingFrames: number().int()
25454
+ }), {
25455
+ kind: "query",
25456
+ auth: "admin",
25457
+ timeoutMs: 12e4
25458
+ }), method(object({}), array(RetrainAssistProfileSchema).readonly(), {
25459
+ kind: "query",
25460
+ auth: "admin"
25461
+ }), method(object({
25462
+ deviceId: number(),
25463
+ trackId: string().optional(),
25464
+ frameId: string(),
25465
+ profileId: string(),
25466
+ classes: array(RetrainMacroClassSchema).min(1),
25467
+ boxes: array(object({
25468
+ ref: string(),
25469
+ bbox: RetrainBboxSchema,
25470
+ macroClass: RetrainMacroClassSchema,
25471
+ label: string().optional()
25472
+ })).max(50),
25473
+ allowCloud: boolean()
25474
+ }), RetrainLlmAssistResultSchema, {
25475
+ kind: "mutation",
25476
+ auth: "admin",
25477
+ timeoutMs: 18e4
25478
+ }), method(object({ name: string().max(120) }), RetrainCollectionCreateResultSchema, {
25479
+ kind: "mutation",
25480
+ auth: "admin"
25481
+ }), method(object({}), array(RetrainCollectionSchema).readonly(), {
25482
+ kind: "query",
25483
+ auth: "admin"
25484
+ }), method(object({
25485
+ id: string(),
25486
+ name: string().max(120)
25487
+ }), RetrainCollectionRenameResultSchema, {
25488
+ kind: "mutation",
25489
+ auth: "admin"
25490
+ }), method(object({ id: string() }), object({
25491
+ deleted: boolean(),
25492
+ removedFrames: number().int()
25493
+ }), {
25494
+ kind: "mutation",
25495
+ auth: "admin"
25496
+ }), method(object({
25497
+ collectionId: string(),
25498
+ deviceId: number(),
25499
+ epochMs: number()
25500
+ }), AddRetrainFrameFromRecordingResultSchema, {
25501
+ kind: "mutation",
25502
+ auth: "admin",
25503
+ timeoutMs: 6e4
25504
+ }), method(object({
25505
+ collectionId: string(),
25506
+ frameIds: array(string()).min(1).max(500)
25507
+ }), object({
25508
+ added: number().int(),
25509
+ alreadyMember: number().int(),
25510
+ unknownFrameIds: array(string()).readonly()
25511
+ }), {
25512
+ kind: "mutation",
25513
+ auth: "admin"
25514
+ }), method(object({
25515
+ collectionId: string(),
25516
+ frameId: string()
25517
+ }), object({
25518
+ removed: boolean(),
25519
+ deletedFrame: boolean()
25520
+ }), {
25521
+ kind: "mutation",
25522
+ auth: "admin"
25523
+ }), method(object({ collectionId: string() }), array(RetrainFrameSchema).readonly(), {
25524
+ kind: "query",
25525
+ auth: "admin"
23395
25526
  }), method(object({
23396
25527
  /** Which of the three event tables owns the row. */
23397
25528
  ownerType: EventOwnerTypeSchema,
@@ -24015,13 +26146,31 @@ var RecommendationReasonSchema = discriminatedUnion("kind", [
24015
26146
  object({
24016
26147
  kind: literal("no-family-build"),
24017
26148
  format: ModelFormatSchema$1
26149
+ }),
26150
+ object({
26151
+ kind: literal("kept-custom-pin"),
26152
+ modelId: string(),
26153
+ deviceKey: string()
24018
26154
  })
24019
26155
  ]);
26156
+ /** Why a device is left exactly as it is, whatever the plan would pick (D786). */
26157
+ var KeptReasonSchema = _enum(["custom-pin"]);
26158
+ /**
26159
+ * Where a choice's latency came from (D791): this node's own benchmark
26160
+ * result, or the hardware-class table. Measured on the node beats the table.
26161
+ */
26162
+ var LatencySourceSchema = discriminatedUnion("kind", [object({ kind: literal("table") }), object({
26163
+ kind: literal("node-benchmark"),
26164
+ resultId: string(),
26165
+ measuredAtMs: number()
26166
+ })]);
24020
26167
  var DeviceModelChoiceSchema = object({
24021
26168
  modelId: string(),
24022
26169
  p50Ms: number(),
24023
26170
  fps: number(),
24024
26171
  measured: boolean(),
26172
+ /** Absent on a plan from before D791 — read as the table. */
26173
+ source: LatencySourceSchema.optional(),
24025
26174
  /** Parallel sessions at the camera rate with the headroom kept free: ⌊fps × (1 − headroom) / camera fps⌋. */
24026
26175
  capacitySessions: number(),
24027
26176
  personRecall: number()
@@ -24032,6 +26181,8 @@ var DeviceRecommendationSchema = object({
24032
26181
  enabled: boolean(),
24033
26182
  available: boolean(),
24034
26183
  chosen: DeviceModelChoiceSchema.nullable(),
26184
+ /** Present when the device is kept as is: Apply writes nothing on it. */
26185
+ kept: KeptReasonSchema.optional(),
24035
26186
  reasons: array(RecommendationReasonSchema).readonly()
24036
26187
  });
24037
26188
  var NodeRecommendationSchema = object({
@@ -24085,6 +26236,17 @@ var AutoTuneWarningSchema = discriminatedUnion("kind", [
24085
26236
  kind: literal("coral-enabled"),
24086
26237
  nodeId: string(),
24087
26238
  deviceKey: string()
26239
+ }),
26240
+ object({
26241
+ kind: literal("custom-pin-kept"),
26242
+ nodeId: string(),
26243
+ deviceKey: string().nullable(),
26244
+ deviceId: number().nullable(),
26245
+ modelId: string()
26246
+ }),
26247
+ object({
26248
+ kind: literal("custom-registry-unreadable"),
26249
+ error: string()
24088
26250
  })
24089
26251
  ]);
24090
26252
  var AutoTuneOptionsSchema = object({
@@ -24263,13 +26425,14 @@ var SuggestSharesResultSchema = object({
24263
26425
  nodes: array(SuggestedNodeShareSchema).readonly()
24264
26426
  });
24265
26427
  /**
24266
- * Where the node and device shares come from (D750, D755).
24267
- * - `hardware` (default) — computed by the system from each node's static
24268
- * capacity (its accelerators at their Auto tune models, from the measured
24269
- * latency table), recomputed whenever a node or device joins, leaves, is
24270
- * switched on or off, or changes model. No load input.
24271
- * - `benchmark` — the same, from each node's measured capacity (node
24272
- * benchmark results); a node without results falls back to `hardware`.
26428
+ * Where the node and device shares come from (D750, D755, D791).
26429
+ * - `benchmark` (default since D791) — each node's capacity as its own node
26430
+ * benchmark measured it; a node without fresh results is sized from
26431
+ * `hardware` and says so. Measured on the node beats the table.
26432
+ * - `hardware` — computed from each node's static capacity only (its
26433
+ * accelerators at their Auto tune models, from the latency table).
26434
+ * Both are recomputed whenever a node or device joins, leaves, is switched
26435
+ * on or off, changes model, or a benchmark result is written. No load input.
24273
26436
  * - `manual` — the operator's stored sliders.
24274
26437
  * Either way a node or device that cannot take sessions gives its share to
24275
26438
  * the others in proportion; the stored values are never rewritten for that.
@@ -24318,6 +26481,362 @@ var EffectiveSharesSchema = object({
24318
26481
  nodeWeights: record(string(), number()),
24319
26482
  deviceWeights: record(string(), record(string(), number()))
24320
26483
  });
26484
+ /**
26485
+ * Wire shapes of the node benchmark (D791): the operator's plan, the
26486
+ * preflight the confirmation shows, the run the orchestrator owns, what the
26487
+ * measuring runner reports, and the result rows Auto tune and the automatic
26488
+ * shares read.
26489
+ *
26490
+ * ONE node at a time, owned by the pipeline orchestrator. While a run is
26491
+ * active the cluster is in BENCHMARK MODE for that node: it is not a
26492
+ * detection candidate, camera pins naming it are ignored so its sessions move
26493
+ * elsewhere, and both come back when the mode ends — after a crash or a hub
26494
+ * restart too (a persisted manifest, reconciled against the registry).
26495
+ *
26496
+ * Two measurements, both on the node, driven by its own runner (frames never
26497
+ * cross a process at frame rate, D9):
26498
+ * - `device` — one accelerator × one candidate detector, root only, open
26499
+ * loop: how many streams at the camera rate it carries inside the frame
26500
+ * interval;
26501
+ * - `pipeline` — the chosen detector plus the operator's detail steps
26502
+ * (faces, plates, classifiers, CLIP…), on varied frames from the bench
26503
+ * clip: how many parallel sessions the node carries before latency, drops,
26504
+ * CPU, RAM or the event loop give out.
26505
+ */
26506
+ /** Defaults and bounds, one place. */
26507
+ var NODE_BENCHMARK_DEFAULTS = {
26508
+ fpsPerStream: 10,
26509
+ budgetMinutes: 45,
26510
+ minBudgetMinutes: 10,
26511
+ maxBudgetMinutes: 120,
26512
+ /** A result older than this no longer beats the table. */
26513
+ staleAfterDays: 30,
26514
+ /** Warm-in per ramp step (not accounted). */
26515
+ settleSec: 5,
26516
+ /** Accounted window per ramp step. */
26517
+ measureSec: 20,
26518
+ /** Longest the drain may take before the run is refused. */
26519
+ drainTimeoutSec: 120,
26520
+ /** Candidate models per device in one run. */
26521
+ maxModelsPerDevice: 6
26522
+ };
26523
+ /** The two measurements a run can make. */
26524
+ var NodeBenchmarkPhaseSchema = _enum(["device", "pipeline"]);
26525
+ var NodeBenchmarkDevicePlanSchema = object({
26526
+ /** `<backend>:<device>` — `openvino:npu`, `coreml:all`, `cpu`. */
26527
+ deviceKey: string().min(1),
26528
+ /**
26529
+ * Root detector candidates for the `device` measurement, in the order
26530
+ * measured. The FIRST is the one the `pipeline` measurement runs.
26531
+ */
26532
+ modelIds: array(string().min(1)).min(1).max(NODE_BENCHMARK_DEFAULTS.maxModelsPerDevice)
26533
+ });
26534
+ /** What the operator confirmed. */
26535
+ var NodeBenchmarkPlanSchema = object({
26536
+ nodeId: string().min(1),
26537
+ devices: array(NodeBenchmarkDevicePlanSchema).min(1),
26538
+ /** Which measurements run. At least one. */
26539
+ phases: array(NodeBenchmarkPhaseSchema).min(1).default(["device", "pipeline"]),
26540
+ /**
26541
+ * Detail steps (catalog step ids under the root: faces, plates,
26542
+ * classifiers, CLIP…) the `pipeline` measurement enables. The root
26543
+ * detector always runs.
26544
+ */
26545
+ steps: array(string().min(1)).default([]),
26546
+ /** Offered rate of one stream / session. */
26547
+ fpsPerStream: number().int().min(1).max(30).default(NODE_BENCHMARK_DEFAULTS.fpsPerStream),
26548
+ /** Hard deadline: the mode ends and the cluster is restored when it passes. */
26549
+ budgetMinutes: number().int().min(NODE_BENCHMARK_DEFAULTS.minBudgetMinutes).max(NODE_BENCHMARK_DEFAULTS.maxBudgetMinutes).default(NODE_BENCHMARK_DEFAULTS.budgetMinutes),
26550
+ /** Keep the models the run downloaded (default: delete what was not installed before). */
26551
+ keepDownloadedModels: boolean().default(false),
26552
+ /** Start although the other nodes' capacity does not cover the sessions running now. */
26553
+ acceptInsufficientHeadroom: boolean().default(false)
26554
+ });
26555
+ var NodeBenchmarkRefusalSchema = object({
26556
+ kind: _enum([
26557
+ "benchmark-active",
26558
+ "node-offline",
26559
+ "unknown-device",
26560
+ "no-phase",
26561
+ "insufficient-headroom"
26562
+ ]),
26563
+ detail: string(),
26564
+ overridable: boolean()
26565
+ });
26566
+ /** A camera whose detection leaves the node for the run. */
26567
+ var NodeBenchmarkMovingCameraSchema = object({
26568
+ deviceId: number(),
26569
+ /** Placed on the node now (a standing attach or a running session). */
26570
+ placedOnNode: boolean(),
26571
+ /** A node pin naming this node, ignored for the run. */
26572
+ pinnedToNode: boolean()
26573
+ });
26574
+ /** A camera that cannot leave: no other node can obtain its frames. */
26575
+ var NodeBenchmarkStayingCameraSchema = object({
26576
+ deviceId: number(),
26577
+ reason: literal("only-frame-source")
26578
+ });
26579
+ var NodeBenchmarkPreflightSchema = object({
26580
+ nodeId: string(),
26581
+ online: boolean(),
26582
+ moving: array(NodeBenchmarkMovingCameraSchema).readonly(),
26583
+ /** Keep running on the node during the run; the result is flagged contaminated. */
26584
+ staying: array(NodeBenchmarkStayingCameraSchema).readonly(),
26585
+ estimatedDurationMs: number(),
26586
+ /** The run ends and the cluster is restored at the latest after this long. */
26587
+ budgetMs: number(),
26588
+ phases: array(NodeBenchmarkPhaseSchema).readonly(),
26589
+ steps: array(string()).readonly(),
26590
+ devices: array(NodeBenchmarkDevicePlanSchema).readonly(),
26591
+ /** Parallel sessions the cluster runs now, and what the other nodes can carry. */
26592
+ headroom: object({
26593
+ sessionsNow: number(),
26594
+ otherNodesCapacitySessions: number().nullable()
26595
+ }),
26596
+ refusals: array(NodeBenchmarkRefusalSchema).readonly(),
26597
+ canStart: boolean()
26598
+ });
26599
+ /** Where the measuring runner is. */
26600
+ var NodeBenchProgressSchema = object({
26601
+ phase: _enum([
26602
+ "preparing",
26603
+ "device",
26604
+ "pipeline",
26605
+ "cleanup"
26606
+ ]),
26607
+ deviceKey: string().nullable(),
26608
+ modelId: string().nullable(),
26609
+ /** Streams (device) or sessions (pipeline) of the step running now. */
26610
+ load: number().nullable(),
26611
+ cellsDone: number(),
26612
+ cellsTotal: number(),
26613
+ message: string()
26614
+ });
26615
+ /** What limited a ramp. `none` = the ramp ran out of steps still passing. */
26616
+ var NodeBenchLimitSchema = _enum([
26617
+ "p95",
26618
+ "drops",
26619
+ "errors",
26620
+ "stall",
26621
+ "cpu",
26622
+ "ram",
26623
+ "none"
26624
+ ]);
26625
+ var NodeBenchRampStepSchema = object({
26626
+ load: number(),
26627
+ pass: boolean(),
26628
+ p95Ms: number(),
26629
+ dropRatio: number(),
26630
+ /** Completed frames per second over the accounted window. */
26631
+ fps: number(),
26632
+ cpuPct: number().nullable(),
26633
+ ramFreePct: number().nullable(),
26634
+ failReasons: array(string()).readonly()
26635
+ });
26636
+ var NodeBenchCellSchema = discriminatedUnion("phase", [object({
26637
+ phase: literal("device"),
26638
+ deviceKey: string(),
26639
+ modelId: string(),
26640
+ /** Single-stream latency (the K = 1 step). */
26641
+ p50Ms: number(),
26642
+ p95Ms: number(),
26643
+ p99Ms: number(),
26644
+ /** Frames per second sustained at the last passing step. */
26645
+ fps: number(),
26646
+ /** Streams at the camera rate the device carried inside the frame interval; 0 = not even one. */
26647
+ kMax: number(),
26648
+ limitedBy: NodeBenchLimitSchema,
26649
+ /** First call (model load + warm-up). */
26650
+ warmupMs: number(),
26651
+ ramp: array(NodeBenchRampStepSchema).readonly()
26652
+ }), object({
26653
+ phase: literal("pipeline"),
26654
+ deviceKey: string(),
26655
+ modelId: string(),
26656
+ steps: array(string()).readonly(),
26657
+ /** Parallel sessions at the camera rate the node carried; 0 = not even one. */
26658
+ maxSessions: number(),
26659
+ limitedBy: NodeBenchLimitSchema,
26660
+ /** Detail steps that produced at least one result on the clip — a step that never fired measured nothing. */
26661
+ stepsFired: array(string()).readonly(),
26662
+ warmupMs: number(),
26663
+ ramp: array(NodeBenchRampStepSchema).readonly()
26664
+ })]);
26665
+ /**
26666
+ * What a result was measured ON. A result whose fingerprint no longer matches
26667
+ * the node no longer beats the table.
26668
+ */
26669
+ var NodeBenchFingerprintSchema = object({
26670
+ pipelineVersion: string().nullable(),
26671
+ cpuModel: string().nullable(),
26672
+ ramGb: number().nullable(),
26673
+ os: string().nullable(),
26674
+ /** Per device: the pool the cells ran on (runtime + tuning). */
26675
+ pools: record(string(), object({
26676
+ runtime: string(),
26677
+ numWorkers: number(),
26678
+ concurrency: number(),
26679
+ batchMode: string()
26680
+ })).default({})
26681
+ });
26682
+ /** The frames the run used. */
26683
+ var NodeBenchClipSchema = object({
26684
+ /** `camstack-bench-v1` or `reference-images` (the fallback when the clip is not reachable). */
26685
+ id: string(),
26686
+ revision: string().nullable(),
26687
+ frames: number(),
26688
+ width: number(),
26689
+ height: number()
26690
+ });
26691
+ var NodeBenchRunnerInputSchema = object({
26692
+ runId: string().min(1),
26693
+ devices: array(NodeBenchmarkDevicePlanSchema).min(1),
26694
+ phases: array(NodeBenchmarkPhaseSchema).min(1),
26695
+ /** The full detail step tree root for the `pipeline` measurement is built on the node from these ids. */
26696
+ steps: array(string()).default([]),
26697
+ fpsPerStream: number().int().min(1).max(30),
26698
+ /** The runner stops on its own past this instant, whatever the hub does. */
26699
+ deadlineAtMs: number(),
26700
+ settleSec: number().min(0).max(60).default(NODE_BENCHMARK_DEFAULTS.settleSec),
26701
+ measureSec: number().min(2).max(300).default(NODE_BENCHMARK_DEFAULTS.measureSec),
26702
+ keepDownloadedModels: boolean().default(false)
26703
+ });
26704
+ var NodeBenchRunnerStateSchema = _enum([
26705
+ "running",
26706
+ "done",
26707
+ "failed",
26708
+ "aborted"
26709
+ ]);
26710
+ var NodeBenchRunnerStatusSchema = object({
26711
+ runId: string(),
26712
+ nodeId: string(),
26713
+ state: NodeBenchRunnerStateSchema,
26714
+ progress: NodeBenchProgressSchema.nullable(),
26715
+ /** Every finished cell so far — a run stopped half way keeps what it measured. */
26716
+ cells: array(NodeBenchCellSchema).readonly(),
26717
+ fingerprint: NodeBenchFingerprintSchema.nullable(),
26718
+ clip: NodeBenchClipSchema.nullable(),
26719
+ /** Cameras seen running on the node during the run (they share its pools). */
26720
+ activeCameraIds: array(number()).readonly(),
26721
+ /** Models the run downloaded and then deleted (not installed before). */
26722
+ deletedModels: array(string()).readonly(),
26723
+ error: string().nullable(),
26724
+ startedAtMs: number(),
26725
+ finishedAtMs: number().nullable()
26726
+ });
26727
+ var NodeBenchmarkStateSchema = _enum([
26728
+ "draining",
26729
+ "measuring",
26730
+ "restoring",
26731
+ "done",
26732
+ "failed",
26733
+ "aborted"
26734
+ ]);
26735
+ /** Why a run ended. */
26736
+ var NodeBenchmarkEndReasonSchema = _enum([
26737
+ "completed",
26738
+ "operator-abort",
26739
+ "deadline",
26740
+ "node-lost",
26741
+ "runner-lost",
26742
+ "hub-restart",
26743
+ "drain-timeout",
26744
+ "failed"
26745
+ ]);
26746
+ var NodeBenchmarkRunSchema = object({
26747
+ runId: string(),
26748
+ nodeId: string(),
26749
+ state: NodeBenchmarkStateSchema,
26750
+ plan: NodeBenchmarkPlanSchema,
26751
+ startedAtMs: number(),
26752
+ deadlineAtMs: number(),
26753
+ finishedAtMs: number().nullable(),
26754
+ endReason: NodeBenchmarkEndReasonSchema.nullable(),
26755
+ error: string().nullable(),
26756
+ /** Cameras moved off the node for the run. */
26757
+ moved: array(number()).readonly(),
26758
+ /** Cameras that stayed (their only frame source is the node). */
26759
+ staying: array(number()).readonly(),
26760
+ /** Something else ran on the node's pools during the run. */
26761
+ contaminated: boolean(),
26762
+ progress: NodeBenchProgressSchema.nullable(),
26763
+ resultIds: array(string()).readonly()
26764
+ });
26765
+ /** `getNodeBenchmarkStatus`: the active run (or the last one), and whether benchmark mode is on. */
26766
+ var NodeBenchmarkStatusSchema = object({
26767
+ /** The node the cluster is in benchmark mode for; null = none. */
26768
+ modeNodeId: string().nullable(),
26769
+ run: NodeBenchmarkRunSchema.nullable()
26770
+ });
26771
+ /**
26772
+ * One stored measurement — the only authority Auto tune and the automatic
26773
+ * shares read measured capacity from. Written by the orchestrator when a run
26774
+ * ends, never by anyone else.
26775
+ */
26776
+ var NodeBenchmarkResultSchema = object({
26777
+ id: string(),
26778
+ runId: string(),
26779
+ nodeId: string(),
26780
+ cell: NodeBenchCellSchema,
26781
+ fpsPerStream: number(),
26782
+ fingerprint: NodeBenchFingerprintSchema.nullable(),
26783
+ clip: NodeBenchClipSchema.nullable(),
26784
+ /** Other work shared the node's pools (a camera that could not move, or the hub's own duties). */
26785
+ contaminated: boolean(),
26786
+ stayingCameras: array(number()).readonly(),
26787
+ /** The run ended early; the cell itself completed. */
26788
+ partialRun: boolean(),
26789
+ measuredAtMs: number()
26790
+ });
26791
+ var ListNodeBenchmarkResultsInputSchema = object({
26792
+ nodeId: string().optional(),
26793
+ deviceKey: string().optional()
26794
+ });
26795
+ /** A result with its standing today: does it still beat the table? */
26796
+ var NodeBenchmarkResultViewSchema = NodeBenchmarkResultSchema.extend({
26797
+ /** `fresh` beats the table; `stale` falls back to it; `superseded` = a newer row covers the same cell. */
26798
+ standing: _enum([
26799
+ "fresh",
26800
+ "stale",
26801
+ "superseded"
26802
+ ]),
26803
+ staleWhy: _enum([
26804
+ "age",
26805
+ "runtime",
26806
+ "pool-tuning"
26807
+ ]).nullable()
26808
+ });
26809
+ object({
26810
+ runId: string(),
26811
+ nodeId: string(),
26812
+ startedAtMs: number(),
26813
+ deadlineAtMs: number(),
26814
+ plan: NodeBenchmarkPlanSchema,
26815
+ moved: array(number()).readonly(),
26816
+ staying: array(number()).readonly()
26817
+ });
26818
+ /** Candidate detectors per device, for the plan editor. */
26819
+ var NodeBenchmarkCandidatesSchema = object({
26820
+ nodeId: string(),
26821
+ reachable: boolean(),
26822
+ devices: array(object({
26823
+ deviceKey: string(),
26824
+ enabled: boolean(),
26825
+ available: boolean(),
26826
+ /** Ordered: what Auto tune would pick first, then the rest of the family by accuracy. */
26827
+ suggested: array(string()).readonly(),
26828
+ /** Every root detector the device has a build for. */
26829
+ all: array(string()).readonly(),
26830
+ /** The model the device runs now, when pinned. */
26831
+ currentModelId: string().nullable()
26832
+ })).readonly(),
26833
+ /** Detail steps the node's catalog offers under the root (for the `pipeline` measurement). */
26834
+ steps: array(object({
26835
+ id: string(),
26836
+ name: string(),
26837
+ slot: string()
26838
+ })).readonly()
26839
+ });
24321
26840
  object({
24322
26841
  activeCameras: number(),
24323
26842
  throttledCameras: number(),
@@ -25446,7 +27965,16 @@ method(RunnerCameraConfigSchema, object({ success: literal(true) }), { kind: "mu
25446
27965
  }), ParkedTrackFrameSchema.nullable()), method(object({
25447
27966
  deviceId: number(),
25448
27967
  trackId: string()
25449
- }), object({ released: number().int().nonnegative() }), { kind: "mutation" });
27968
+ }), object({ released: number().int().nonnegative() }), { kind: "mutation" }), method(NodeBenchRunnerInputSchema, object({
27969
+ accepted: literal(true),
27970
+ runId: string()
27971
+ }), {
27972
+ kind: "mutation",
27973
+ auth: "admin"
27974
+ }), method(object({ runId: string() }), NodeBenchRunnerStatusSchema.nullable(), { auth: "admin" }), method(object({ runId: string() }), object({ aborted: boolean() }), {
27975
+ kind: "mutation",
27976
+ auth: "admin"
27977
+ });
25450
27978
  var CameraPipelineConfigSchema = object({
25451
27979
  engine: PipelineEngineChoiceSchema.optional(),
25452
27980
  steps: array(PipelineStepInputSchema).readonly(),
@@ -26085,6 +28613,21 @@ method(object({
26085
28613
  }), method(PlacementStatsInputSchema, PlacementStatsSchema, { auth: "admin" }), method(SuggestSharesInputSchema, SuggestSharesResultSchema, { auth: "admin" }), method(_void(), EffectiveSharesSchema, { auth: "admin" }), method(SetShareSourceInputSchema, object({ success: literal(true) }), {
26086
28614
  kind: "mutation",
26087
28615
  auth: "admin"
28616
+ }), method(NodeBenchmarkPlanSchema, NodeBenchmarkPreflightSchema, { auth: "admin" }), method(NodeBenchmarkPlanSchema, discriminatedUnion("kind", [object({
28617
+ kind: literal("started"),
28618
+ runId: string()
28619
+ }), object({
28620
+ kind: literal("refused"),
28621
+ preflight: NodeBenchmarkPreflightSchema
28622
+ })]), {
28623
+ kind: "mutation",
28624
+ auth: "admin"
28625
+ }), method(_void(), NodeBenchmarkStatusSchema, { auth: "admin" }), method(object({ runId: string() }), object({ aborted: boolean() }), {
28626
+ kind: "mutation",
28627
+ auth: "admin"
28628
+ }), method(object({ nodeId: string() }), NodeBenchmarkCandidatesSchema, { auth: "admin" }), method(ListNodeBenchmarkResultsInputSchema, array(NodeBenchmarkResultViewSchema).readonly(), { auth: "admin" }), method(object({ id: string() }), object({ deleted: boolean() }), {
28629
+ kind: "mutation",
28630
+ auth: "admin"
26088
28631
  }), method(object({ deviceId: number() }), CameraPipelineSettingsSchema.nullable()), method(object({
26089
28632
  deviceId: number(),
26090
28633
  addonId: string(),
@@ -26490,8 +29033,8 @@ version: string().optional() }), ServerUpdateActionResultSchema, {
26490
29033
  * `smtp-provider` — pluggable email delivery surface.
26491
29034
  *
26492
29035
  * Collection cap: a deployment may install multiple SMTP relays (e.g.
26493
- * one for transactional / one for notifications). Consumers (magic-link,
26494
- * notifier addons, …) walk the collection and pick the first
29036
+ * one for transactional / one for notifications). Consumers (notifier
29037
+ * addons, …) walk the collection and pick the first
26495
29038
  * ready provider OR target a specific addonId.
26496
29039
  *
26497
29040
  * The shape stays small on purpose — `sendEmail` is enough for the
@@ -26670,7 +29213,7 @@ targets: array(object({
26670
29213
  })));
26671
29214
  /**
26672
29215
  * `sso-bridge` — internal hub-only cap that lets SSO-style auth
26673
- * providers (OIDC, SAML, magic-link, …) mint an HMAC-signed token
29216
+ * providers (OIDC, SAML, …) mint an HMAC-signed token
26674
29217
  * carrying the post-callback claims before redirecting back to
26675
29218
  * `/api/auth/sso/finish`.
26676
29219
  *
@@ -26733,7 +29276,14 @@ var SsoBridgeClaimsSchema = object({
26733
29276
  * Verified `iss` of the id_token behind an OIDC login bridge (D782). A
26734
29277
  * subject is unique only per issuer, so a link is bound to it.
26735
29278
  */
26736
- issuer: string().optional()
29279
+ issuer: string().optional(),
29280
+ /**
29281
+ * SHA-256 (hex) of the `camstack_sso_state` cookie the IdP `/start` set in
29282
+ * the browser that began this sign-in. `/api/auth/sso/finish` requires the
29283
+ * request to present the matching cookie — a login bridge is useless in
29284
+ * any other browser.
29285
+ */
29286
+ browserBinding: string().optional()
26737
29287
  });
26738
29288
  method(object({
26739
29289
  claims: SsoBridgeClaimsSchema,
@@ -32209,6 +34759,9 @@ var CreateIntegrationInputSchema = object({
32209
34759
  enabled: boolean().optional(),
32210
34760
  info: record(string(), unknown()).optional(),
32211
34761
  settings: record(string(), unknown()).optional(),
34762
+ /** Keys of `settings` the form's schema declares secret (by type) — kept in
34763
+ * the keychain, not the table (D787). */
34764
+ secretKeys: array(string()).optional(),
32212
34765
  skipRestart: boolean().optional()
32213
34766
  });
32214
34767
  var UpdateIntegrationInputSchema = object({
@@ -32232,7 +34785,9 @@ method(_void(), array(IntegrationWithStateSchema)), method(object({ id: string()
32232
34785
  auth: "admin"
32233
34786
  }), method(object({ id: string() }), record(string(), unknown()), { auth: "admin" }), method(object({
32234
34787
  id: string(),
32235
- settings: record(string(), unknown())
34788
+ settings: record(string(), unknown()),
34789
+ /** Keys the form's schema declares secret (by type) — keychain-stored (D787). */
34790
+ secretKeys: array(string()).optional()
32236
34791
  }), object({ success: boolean() }), {
32237
34792
  kind: "mutation",
32238
34793
  auth: "admin"
@@ -39004,16 +41559,6 @@ var ApiKeySummarySchema = object({
39004
41559
  createdAt: number(),
39005
41560
  lastUsedAt: number().optional()
39006
41561
  });
39007
- var CreateApiKeyInputSchema = object({
39008
- label: string(),
39009
- isAdmin: boolean().default(false),
39010
- allowedProviders: union([array(string()), literal("*")]).optional(),
39011
- allowedDevices: record(string(), union([array(string()), literal("*")])).optional()
39012
- });
39013
- var CreateApiKeyResultSchema = object({
39014
- token: string(),
39015
- record: ApiKeySummarySchema
39016
- });
39017
41562
  var ScopedTokenSummarySchema = object({
39018
41563
  id: string(),
39019
41564
  userId: string(),
@@ -39112,17 +41657,10 @@ method(_void(), array(UserSummarySchema), { auth: "admin" }), method(CreateUserI
39112
41657
  }), UserSummarySchema.extend({ passwordHash: string() }).nullable(), {
39113
41658
  kind: "mutation",
39114
41659
  access: "view"
39115
- }), method(_void(), array(ApiKeySummarySchema), { auth: "admin" }), method(CreateApiKeyInputSchema, CreateApiKeyResultSchema, {
39116
- kind: "mutation",
39117
- auth: "admin",
39118
- access: "create"
39119
- }), method(object({ id: string() }), object({ success: literal(true) }), {
41660
+ }), method(_void(), array(ApiKeySummarySchema), { auth: "admin" }), method(object({ id: string() }), object({ success: literal(true) }), {
39120
41661
  kind: "mutation",
39121
41662
  auth: "admin",
39122
41663
  access: "delete"
39123
- }), method(object({ token: string() }), ApiKeySummarySchema.nullable(), {
39124
- kind: "mutation",
39125
- access: "view"
39126
41664
  }), method(CreateScopedTokenInputSchema, CreateScopedTokenResultSchema, {
39127
41665
  kind: "mutation",
39128
41666
  auth: "admin",
@@ -39196,15 +41734,7 @@ method(_void(), array(UserSummarySchema), { auth: "admin" }), method(CreateUserI
39196
41734
  }).nullable(), { access: "view" }), method(object({ userId: string() }), array(ExternalIdentitySchema), { auth: "admin" }), method(ExternalIdentityKeySchema, object({
39197
41735
  userId: string(),
39198
41736
  issuer: string()
39199
- }).nullable(), { auth: "admin" }), method(ExternalIdentityKeySchema.extend({
39200
- userId: string(),
39201
- issuer: string().min(1),
39202
- label: string().optional()
39203
- }), object({ success: literal(true) }), {
39204
- kind: "mutation",
39205
- auth: "admin",
39206
- access: "create"
39207
- }), method(ExternalIdentityKeySchema.extend({ userId: string() }), object({ success: boolean() }), {
41737
+ }).nullable(), { auth: "admin" }), method(ExternalIdentityKeySchema.extend({ userId: string() }), object({ success: boolean() }), {
39208
41738
  kind: "mutation",
39209
41739
  auth: "admin",
39210
41740
  access: "delete"
@@ -39909,6 +42439,451 @@ var zoneRulesCapability = {
39909
42439
  */
39910
42440
  durability: "restored"
39911
42441
  };
42442
+ /**
42443
+ * `training-provider` — ONE cloud that can run the CamStack trainer.
42444
+ *
42445
+ * A thin, mockable translation layer: it knows how to run a container with a
42446
+ * GPU, move a dataset in, read the job's stdout and hand artefacts back. It
42447
+ * knows nothing about datasets, splits, floors, cost policy or Model Studio —
42448
+ * those are the `training` orchestrator's (D805). Every rule written there
42449
+ * once is what makes a second provider (RunPod, a local NVIDIA node) a new
42450
+ * manifest entry and nothing else.
42451
+ *
42452
+ * Collection, routed by the `addonId` in every single-row input (the `llm` /
42453
+ * `notification-output` posture); `describe` concat-fans across providers.
42454
+ * Every method is `admin`: these spend money.
42455
+ *
42456
+ * Every cloud object a provider creates is tagged with the orchestrator's
42457
+ * `jobKey`, so a retried submit finds the job it already started instead of
42458
+ * starting a second GPU, and `listJobs` can find orphans.
42459
+ *
42460
+ * Bytes never ride a cap field: the dataset arrives as a `ctx.peerBytes`
42461
+ * ticket the producer (pipeline-analytics) minted, and artefacts leave as a
42462
+ * ticket the provider mints (D613).
42463
+ */
42464
+ var TrainingGpuOptionSchema = object({
42465
+ id: string(),
42466
+ label: string(),
42467
+ /** List price, USD per GPU-hour, before any region multiplier. */
42468
+ usdPerHour: number().nonnegative(),
42469
+ vramGb: number().nonnegative()
42470
+ });
42471
+ var TrainingRegionOptionSchema = object({
42472
+ /** `''` = any region (the provider's choice). */
42473
+ id: string(),
42474
+ label: string(),
42475
+ priceMultiplier: number().positive()
42476
+ });
42477
+ /**
42478
+ * The provider's per-account settings, as the orchestrator reads them. They
42479
+ * live in the PROVIDER addon's settings (operator decision 2026-10-08: they
42480
+ * depend on the user's account), never hard-coded in the orchestrator.
42481
+ */
42482
+ var TrainingProviderDefaultsSchema = object({
42483
+ gpuType: string(),
42484
+ region: string(),
42485
+ costCapUsd: number().nonnegative(),
42486
+ maxRuntimeSec: number().int().positive(),
42487
+ /** Hours a FAILED job's cloud dataset is kept for debugging; 0 = delete at once. */
42488
+ failedDatasetGraceHours: number().nonnegative()
42489
+ });
42490
+ var TrainingProviderDescriptorSchema = object({
42491
+ addonId: string(),
42492
+ /** `modal`, `runpod`, `fake`, … */
42493
+ kind: string(),
42494
+ label: string(),
42495
+ gpuTypes: array(TrainingGpuOptionSchema).readonly(),
42496
+ regions: array(TrainingRegionOptionSchema).readonly(),
42497
+ maxDatasetBytes: number().int().positive(),
42498
+ maxRuntimeSec: number().int().positive(),
42499
+ freeTierNote: string().optional(),
42500
+ /** Where the data goes, in one sentence the confirm dialog repeats. */
42501
+ dataResidencyNote: string(),
42502
+ /** Credentials are present — never the values. */
42503
+ configured: boolean(),
42504
+ defaults: TrainingProviderDefaultsSchema
42505
+ });
42506
+ var TrainingCredentialCheckSchema = object({
42507
+ ok: boolean(),
42508
+ /** Workspace / account name, when the provider says. */
42509
+ account: string().optional(),
42510
+ reason: _enum([
42511
+ "missing",
42512
+ "invalid",
42513
+ "forbidden",
42514
+ "network",
42515
+ "quota"
42516
+ ]).optional(),
42517
+ detail: string().optional()
42518
+ });
42519
+ var ProviderJobStateSchema = _enum([
42520
+ "pending",
42521
+ "starting",
42522
+ "running",
42523
+ "succeeded",
42524
+ "failed",
42525
+ "cancelled",
42526
+ "lost"
42527
+ ]);
42528
+ var ProviderJobStatusSchema = object({
42529
+ jobKey: string(),
42530
+ providerJobId: string().optional(),
42531
+ state: ProviderJobStateSchema,
42532
+ startedAt: number().optional(),
42533
+ endedAt: number().optional(),
42534
+ exitCode: number().int().optional(),
42535
+ failureReason: string().optional(),
42536
+ gpuType: string(),
42537
+ region: string().optional(),
42538
+ billedSeconds: number().nonnegative(),
42539
+ costUsd: number().nonnegative(),
42540
+ /** True when `costUsd` is runtime × list price, not a billing answer. */
42541
+ costIsEstimate: boolean(),
42542
+ lastFetchedAt: number()
42543
+ });
42544
+ /**
42545
+ * The trainer the job runs, by SOURCE revision: the provider turns it into an
42546
+ * image its own way (Modal builds the published Dockerfile at that revision;
42547
+ * a registry-pull provider maps it to a tag). Recorded on the job and echoed
42548
+ * in `result.json`.
42549
+ */
42550
+ var TrainerSourceRefSchema = object({
42551
+ /** Hugging Face repo id, e.g. `camstack/camstack-trainer`. */
42552
+ repo: string().min(1),
42553
+ /** A commit sha (never a branch) — the job must be reproducible. */
42554
+ revision: string().regex(/^[0-9a-f]{7,64}$/)
42555
+ });
42556
+ var JobRef = {
42557
+ addonId: string(),
42558
+ jobKey: string().uuid()
42559
+ };
42560
+ var TrainingLogLineSchema = object({
42561
+ ts: number(),
42562
+ text: string()
42563
+ });
42564
+ method(object({}), array(TrainingProviderDescriptorSchema).readonly(), { auth: "admin" }), method(object({ addonId: string() }), TrainingCredentialCheckSchema, {
42565
+ kind: "mutation",
42566
+ auth: "admin",
42567
+ timeoutMs: 3e4
42568
+ }), method(object({
42569
+ addonId: string(),
42570
+ gpuType: string(),
42571
+ region: string(),
42572
+ datasetBytes: number().int().nonnegative(),
42573
+ gpuSecondsLow: number().nonnegative(),
42574
+ gpuSecondsHigh: number().nonnegative()
42575
+ }), object({
42576
+ usdLow: number().nonnegative(),
42577
+ usdHigh: number().nonnegative(),
42578
+ notes: array(string()).readonly()
42579
+ }), { auth: "admin" }), method(object({
42580
+ ...JobRef,
42581
+ ticket: PeerBytesTicketSchema
42582
+ }), object({
42583
+ bytes: number().int().nonnegative(),
42584
+ sha256: string()
42585
+ }), {
42586
+ kind: "mutation",
42587
+ auth: "admin",
42588
+ timeoutMs: 120 * 6e4
42589
+ }), method(object({
42590
+ ...JobRef,
42591
+ trainer: TrainerSourceRefSchema,
42592
+ jobSpecJson: string().min(2).max(64e3),
42593
+ gpuType: string(),
42594
+ region: string(),
42595
+ maxRuntimeSec: number().int().positive()
42596
+ }), ProviderJobStatusSchema, {
42597
+ kind: "mutation",
42598
+ auth: "admin",
42599
+ timeoutMs: 30 * 6e4
42600
+ }), method(object(JobRef), ProviderJobStatusSchema, {
42601
+ auth: "admin",
42602
+ timeoutMs: 6e4
42603
+ }), method(object({
42604
+ ...JobRef,
42605
+ cursor: string().optional(),
42606
+ max: number().int().min(1).max(500)
42607
+ }), object({
42608
+ lines: array(TrainingLogLineSchema).readonly(),
42609
+ cursor: string()
42610
+ }), {
42611
+ auth: "admin",
42612
+ timeoutMs: 6e4
42613
+ }), method(object(JobRef), object({ ok: literal(true) }), {
42614
+ kind: "mutation",
42615
+ auth: "admin",
42616
+ timeoutMs: 6e4
42617
+ }), method(object(JobRef), object({
42618
+ found: boolean(),
42619
+ text: string().optional()
42620
+ }), {
42621
+ kind: "mutation",
42622
+ auth: "admin",
42623
+ timeoutMs: 5 * 6e4
42624
+ }), method(object({
42625
+ ...JobRef,
42626
+ path: _enum(["bundle.tar"])
42627
+ }), object({ ticket: PeerBytesTicketSchema }), {
42628
+ kind: "mutation",
42629
+ auth: "admin",
42630
+ timeoutMs: 5 * 6e4
42631
+ }), method(object(JobRef), object({ deleted: array(string()).readonly() }), {
42632
+ kind: "mutation",
42633
+ auth: "admin",
42634
+ timeoutMs: 5 * 6e4
42635
+ }), method(object({ addonId: string() }), array(ProviderJobStatusSchema).readonly(), {
42636
+ auth: "admin",
42637
+ timeoutMs: 2 * 6e4
42638
+ });
42639
+ /**
42640
+ * `training` — the cloud-training orchestrator (D805). Hub-only singleton,
42641
+ * provided by `addon-training`.
42642
+ *
42643
+ * It owns what every provider must agree on, written once:
42644
+ *
42645
+ * - **Dataset versions.** Taken over from pipeline-analytics (D796): the rows
42646
+ * live here (D808); pipeline-analytics still CUTS a version (it owns the corpus and
42647
+ * the export plan) and reaches this store through the five row methods
42648
+ * below, so the Retrain page and the export did not change.
42649
+ * - **Jobs.** A persisted state machine, a reconcile loop against the
42650
+ * provider, a cost guard, a daily orphan sweep and the retention rules.
42651
+ * - **The return flow.** Verified artefacts → Model Studio
42652
+ * (`custom-model-registry.importModelBundle`) → canary on cameras →
42653
+ * rollback. Nothing is ever registered automatically.
42654
+ *
42655
+ * Every method is `admin`.
42656
+ */
42657
+ /** A version WITH its frame list — what the export and a job read. */
42658
+ var TrainingDatasetVersionRowSchema = RetrainDatasetVersionSchema.omit({ frameCount: true }).extend({ frameIds: array(string()).max(2e4).readonly() });
42659
+ /** A base model a detector job can fine-tune, and the baseline it is judged against. */
42660
+ var TrainingBaseModelSchema = object({
42661
+ modelId: string(),
42662
+ label: string(),
42663
+ weights: string(),
42664
+ imgsz: number().int(),
42665
+ baselineOnnxUrl: string(),
42666
+ baselineFloors: record(string(), number()),
42667
+ /** The base the fleet runs most — the UI's default. */
42668
+ recommended: boolean()
42669
+ });
42670
+ var TrainingPresetSchema = _enum([
42671
+ "quick",
42672
+ "standard",
42673
+ "thorough"
42674
+ ]);
42675
+ var TrainingJobRequestSchema = object({
42676
+ datasetVersionId: string().min(1),
42677
+ /** The `training-provider` addon that runs it. */
42678
+ addonId: string().min(1),
42679
+ gpuType: string().min(1),
42680
+ region: string(),
42681
+ baseModelId: string().min(1),
42682
+ preset: TrainingPresetSchema,
42683
+ /** Freeze the backbone's first N layers; `null` = the preset's choice. */
42684
+ freeze: number().int().nonnegative().nullable(),
42685
+ /** Cameras held out whole for evaluation; `null` = the orchestrator's default. */
42686
+ holdoutCameras: array(number().int()).nullable()
42687
+ });
42688
+ var TrainingSplitPlanSchema = object({
42689
+ holdoutCameras: array(number().int()).readonly(),
42690
+ /** Used when no camera is held out: the last N days of every camera. */
42691
+ holdoutLastDays: number().int().nonnegative(),
42692
+ /** Holdout subjects per class (camera holdout only; `null` = known only after the split). */
42693
+ holdoutSupport: record(string(), number().int()).nullable(),
42694
+ trainSubjects: number().int()
42695
+ });
42696
+ var TrainingRefusalReasonSchema = _enum([
42697
+ "unknown-dataset",
42698
+ "unknown-provider",
42699
+ "provider-not-configured",
42700
+ "unknown-base-model",
42701
+ "unknown-gpu",
42702
+ "dataset-too-large",
42703
+ "no-training-subjects",
42704
+ "job-already-running"
42705
+ ]);
42706
+ var TrainingJobPlanSchema = object({
42707
+ refusal: object({
42708
+ reason: TrainingRefusalReasonSchema,
42709
+ detail: string()
42710
+ }).nullable(),
42711
+ warnings: array(string()).readonly(),
42712
+ split: TrainingSplitPlanSchema.nullable(),
42713
+ estimate: object({
42714
+ datasetBytes: number().int(),
42715
+ uploadMinutesAt20Mbps: number(),
42716
+ gpuSecondsLow: number(),
42717
+ gpuSecondsHigh: number(),
42718
+ usdLow: number(),
42719
+ usdHigh: number(),
42720
+ notes: array(string()).readonly()
42721
+ }).nullable(),
42722
+ /** Pre-filled from the provider's settings; the operator may lower or raise them. */
42723
+ defaults: object({
42724
+ maxCostUsd: number(),
42725
+ maxRuntimeSec: number().int()
42726
+ }).nullable(),
42727
+ /** The sentence the confirm dialog repeats: where the frames go and when they are deleted. */
42728
+ dataNotice: string()
42729
+ });
42730
+ /**
42731
+ * Orchestrator-owned states, persisted. `uploading` covers exporting the
42732
+ * archive (it is streamed, never staged). Terminal: `failed`, `cancelled`,
42733
+ * `lost`, `expired`, `discarded`. `registered` and `canary` are where a
42734
+ * result lives after the operator acted on it.
42735
+ */
42736
+ var TrainingJobStateSchema = _enum([
42737
+ "uploading",
42738
+ "submitted",
42739
+ "starting",
42740
+ "running",
42741
+ "collecting",
42742
+ "ready",
42743
+ "registered",
42744
+ "canary",
42745
+ "failed",
42746
+ "cancelling",
42747
+ "cancelled",
42748
+ "lost",
42749
+ "expired",
42750
+ "discarded"
42751
+ ]);
42752
+ var TrainingFailureReasonSchema = _enum([
42753
+ "cost-cap",
42754
+ "runtime-cap",
42755
+ "upload-failed",
42756
+ "submit-failed",
42757
+ "trainer-failed",
42758
+ "result-invalid",
42759
+ "checksum-mismatch",
42760
+ "fetch-failed",
42761
+ "provider-error",
42762
+ "hub-restart-during-upload"
42763
+ ]);
42764
+ var TrainingProgressPointSchema = object({
42765
+ epoch: number().int(),
42766
+ map50: number().nullable(),
42767
+ map50_95: number().nullable()
42768
+ });
42769
+ var TrainingCanarySchema = object({
42770
+ deviceIds: array(number().int()).readonly(),
42771
+ since: number(),
42772
+ /** Every override the canary replaced, exactly, so rollback restores it. */
42773
+ previous: array(object({
42774
+ deviceId: number().int(),
42775
+ nodeId: string(),
42776
+ deviceKey: string(),
42777
+ patch: object({
42778
+ modelId: string().optional(),
42779
+ settings: record(string(), unknown()).readonly().optional()
42780
+ }).nullable()
42781
+ })).readonly()
42782
+ });
42783
+ var TrainingJobSchema = object({
42784
+ id: string(),
42785
+ idempotencyKey: string(),
42786
+ name: string(),
42787
+ createdAt: number(),
42788
+ updatedAt: number(),
42789
+ state: TrainingJobStateSchema,
42790
+ stage: TrainingStageSchema.nullable(),
42791
+ failure: object({
42792
+ reason: TrainingFailureReasonSchema,
42793
+ stage: string().nullable(),
42794
+ detail: string()
42795
+ }).nullable(),
42796
+ request: TrainingJobRequestSchema,
42797
+ maxCostUsd: number().nonnegative(),
42798
+ maxRuntimeSec: number().int().positive(),
42799
+ trainer: TrainerSourceRefSchema,
42800
+ datasetLayout: RetrainExportLayoutSchema,
42801
+ dataset: object({
42802
+ bytes: number().int(),
42803
+ sha256: string(),
42804
+ uploadedAt: number()
42805
+ }).nullable(),
42806
+ split: TrainingSplitPlanSchema,
42807
+ provider: object({
42808
+ state: ProviderJobStateSchema.nullable(),
42809
+ providerJobId: string().nullable(),
42810
+ startedAt: number().nullable(),
42811
+ endedAt: number().nullable(),
42812
+ billedSeconds: number(),
42813
+ costUsd: number(),
42814
+ costIsEstimate: boolean(),
42815
+ lastPolledAt: number().nullable()
42816
+ }),
42817
+ progress: object({
42818
+ epoch: number().int().nullable(),
42819
+ epochs: number().int().nullable(),
42820
+ etaSec: number().nullable(),
42821
+ series: array(TrainingProgressPointSchema).readonly()
42822
+ }),
42823
+ /** The last lines of the job's output (≤ 200), newest last. Never frame paths. */
42824
+ logTail: array(string()).readonly(),
42825
+ logCursor: string().nullable(),
42826
+ artifacts: object({
42827
+ bundleBytes: number().int(),
42828
+ bundleSha256: string(),
42829
+ fetchedAt: number(),
42830
+ /** When the staged artefacts are deleted from the hub. */
42831
+ expiresAt: number()
42832
+ }).nullable(),
42833
+ /** When the provider-side copy of the frames was deleted; null while it exists. */
42834
+ cloudDatasetDeletedAt: number().nullable(),
42835
+ /** A failed job's dataset is kept until then (the provider's grace), then deleted. */
42836
+ cloudCleanupDueAt: number().nullable(),
42837
+ /** Model ids registered from this job (base, and int8 when kept). */
42838
+ registeredModelIds: array(string()).readonly(),
42839
+ canary: TrainingCanarySchema.nullable()
42840
+ });
42841
+ var IdInput = object({ id: string().min(1) });
42842
+ method(TrainingDatasetVersionRowSchema, object({ stored: boolean() }), {
42843
+ kind: "mutation",
42844
+ auth: "admin"
42845
+ }), 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() }), {
42846
+ kind: "mutation",
42847
+ auth: "admin"
42848
+ }), method(object({}), array(TrainingBaseModelSchema).readonly(), { auth: "admin" }), method(TrainingJobRequestSchema, TrainingJobPlanSchema, {
42849
+ auth: "admin",
42850
+ timeoutMs: 6e4
42851
+ }), method(TrainingJobRequestSchema.extend({
42852
+ name: string().min(1).max(120),
42853
+ maxCostUsd: number().positive(),
42854
+ maxRuntimeSec: number().int().positive(),
42855
+ idempotencyKey: string().min(8).max(80)
42856
+ }), discriminatedUnion("kind", [object({
42857
+ kind: literal("started"),
42858
+ job: TrainingJobSchema
42859
+ }), object({
42860
+ kind: literal("refused"),
42861
+ reason: TrainingRefusalReasonSchema,
42862
+ detail: string()
42863
+ })]), {
42864
+ kind: "mutation",
42865
+ auth: "admin",
42866
+ timeoutMs: 12e4
42867
+ }), method(object({}), array(TrainingJobSchema).readonly(), { auth: "admin" }), method(IdInput, TrainingJobSchema.nullable(), { auth: "admin" }), method(IdInput, TrainingJobSchema, {
42868
+ kind: "mutation",
42869
+ auth: "admin",
42870
+ timeoutMs: 12e4
42871
+ }), method(IdInput, TrainingResultSchema.nullable(), { auth: "admin" }), method(IdInput.extend({ canaryDeviceIds: array(number().int()).readonly() }), TrainingJobSchema, {
42872
+ kind: "mutation",
42873
+ auth: "admin",
42874
+ timeoutMs: 30 * 6e4
42875
+ }), method(IdInput.extend({ deviceIds: array(number().int()).min(1).readonly() }), TrainingJobSchema, {
42876
+ kind: "mutation",
42877
+ auth: "admin",
42878
+ timeoutMs: 12e4
42879
+ }), method(IdInput, TrainingJobSchema, {
42880
+ kind: "mutation",
42881
+ auth: "admin",
42882
+ timeoutMs: 12e4
42883
+ }), method(IdInput, TrainingJobSchema, {
42884
+ kind: "mutation",
42885
+ auth: "admin"
42886
+ });
39912
42887
  SOURCE_CAPS.filter((cap) => cap !== "switch" && cap !== "motion");
39913
42888
  Object.freeze({
39914
42889
  person: .5,
@@ -40395,7 +43370,8 @@ var BaseDevice = class {
40395
43370
  this.role = options.role;
40396
43371
  this.parentDeviceId = ctx.parentDeviceId;
40397
43372
  const seedData = ctx.persistedConfig ?? {};
40398
- this.config = DeviceConfig.fromSchema(schema, (data) => ctx.persistConfig(data), seedData, ({ droppedKeys, issues }) => {
43373
+ const declaredSecretPaths = collectZodSecretPaths(schema);
43374
+ this.config = DeviceConfig.fromSchema(schema, (data) => ctx.persistConfig(data, { secretConfigPaths: declaredSecretPaths }), seedData, ({ droppedKeys, issues }) => {
40399
43375
  ctx.logger.warn("Device config recovery: dropping invalid persisted fields", {
40400
43376
  tags: {
40401
43377
  deviceId: ctx.id,
@@ -42056,6 +45032,12 @@ Object.freeze({
42056
45032
  addonId: null,
42057
45033
  access: "create"
42058
45034
  },
45035
+ "backup.checkBackupKey": {
45036
+ capName: "backup",
45037
+ capScope: "system",
45038
+ addonId: null,
45039
+ access: "create"
45040
+ },
42059
45041
  "backup.delete": {
42060
45042
  capName: "backup",
42061
45043
  capScope: "system",
@@ -42068,6 +45050,18 @@ Object.freeze({
42068
45050
  addonId: null,
42069
45051
  access: "delete"
42070
45052
  },
45053
+ "backup.disableEncryption": {
45054
+ capName: "backup",
45055
+ capScope: "system",
45056
+ addonId: null,
45057
+ access: "create"
45058
+ },
45059
+ "backup.getEncryption": {
45060
+ capName: "backup",
45061
+ capScope: "system",
45062
+ addonId: null,
45063
+ access: "view"
45064
+ },
42071
45065
  "backup.getEntries": {
42072
45066
  capName: "backup",
42073
45067
  capScope: "system",
@@ -42122,6 +45116,12 @@ Object.freeze({
42122
45116
  addonId: null,
42123
45117
  access: "create"
42124
45118
  },
45119
+ "backup.setupEncryption": {
45120
+ capName: "backup",
45121
+ capScope: "system",
45122
+ addonId: null,
45123
+ access: "create"
45124
+ },
42125
45125
  "backup.trigger": {
42126
45126
  capName: "backup",
42127
45127
  capScope: "system",
@@ -42674,6 +45674,12 @@ Object.freeze({
42674
45674
  addonId: null,
42675
45675
  access: "create"
42676
45676
  },
45677
+ "customModelRegistry.importModelBundle": {
45678
+ capName: "custom-model-registry",
45679
+ capScope: "system",
45680
+ addonId: null,
45681
+ access: "create"
45682
+ },
42677
45683
  "customModelRegistry.listModels": {
42678
45684
  capName: "custom-model-registry",
42679
45685
  capScope: "system",
@@ -44084,6 +47090,108 @@ Object.freeze({
44084
47090
  addonId: null,
44085
47091
  access: "create"
44086
47092
  },
47093
+ "keychain.delete": {
47094
+ capName: "keychain",
47095
+ capScope: "system",
47096
+ addonId: null,
47097
+ access: "delete"
47098
+ },
47099
+ "keychain.getState": {
47100
+ capName: "keychain",
47101
+ capScope: "system",
47102
+ addonId: null,
47103
+ access: "view"
47104
+ },
47105
+ "keychain.listMeta": {
47106
+ capName: "keychain",
47107
+ capScope: "system",
47108
+ addonId: null,
47109
+ access: "view"
47110
+ },
47111
+ "keychain.put": {
47112
+ capName: "keychain",
47113
+ capScope: "system",
47114
+ addonId: null,
47115
+ access: "create"
47116
+ },
47117
+ "keychain.resolve": {
47118
+ capName: "keychain",
47119
+ capScope: "system",
47120
+ addonId: null,
47121
+ access: "view"
47122
+ },
47123
+ "keychainAdmin.acknowledgeReset": {
47124
+ capName: "keychain-admin",
47125
+ capScope: "system",
47126
+ addonId: null,
47127
+ access: "create"
47128
+ },
47129
+ "keychainAdmin.deleteOrphans": {
47130
+ capName: "keychain-admin",
47131
+ capScope: "system",
47132
+ addonId: null,
47133
+ access: "delete"
47134
+ },
47135
+ "keychainAdmin.downloadRecoveryKey": {
47136
+ capName: "keychain-admin",
47137
+ capScope: "system",
47138
+ addonId: null,
47139
+ access: "create"
47140
+ },
47141
+ "keychainAdmin.listAudit": {
47142
+ capName: "keychain-admin",
47143
+ capScope: "system",
47144
+ addonId: null,
47145
+ access: "view"
47146
+ },
47147
+ "keychainAdmin.listSecrets": {
47148
+ capName: "keychain-admin",
47149
+ capScope: "system",
47150
+ addonId: null,
47151
+ access: "view"
47152
+ },
47153
+ "keychainAdmin.purgeRetiredKeys": {
47154
+ capName: "keychain-admin",
47155
+ capScope: "system",
47156
+ addonId: null,
47157
+ access: "delete"
47158
+ },
47159
+ "keychainAdmin.resetKeychain": {
47160
+ capName: "keychain-admin",
47161
+ capScope: "system",
47162
+ addonId: null,
47163
+ access: "delete"
47164
+ },
47165
+ "keychainAdmin.resetReport": {
47166
+ capName: "keychain-admin",
47167
+ capScope: "system",
47168
+ addonId: null,
47169
+ access: "delete"
47170
+ },
47171
+ "keychainAdmin.reveal": {
47172
+ capName: "keychain-admin",
47173
+ capScope: "system",
47174
+ addonId: null,
47175
+ access: "create"
47176
+ },
47177
+ "keychainAdmin.rotateMasterKey": {
47178
+ capName: "keychain-admin",
47179
+ capScope: "system",
47180
+ addonId: null,
47181
+ access: "create"
47182
+ },
47183
+ "keychainAdmin.setSystemSecret": {
47184
+ capName: "keychain-admin",
47185
+ capScope: "system",
47186
+ addonId: null,
47187
+ access: "create"
47188
+ },
47189
+ "keychainAdmin.status": {
47190
+ capName: "keychain-admin",
47191
+ capScope: "system",
47192
+ addonId: null,
47193
+ access: "view"
47194
+ },
44087
47195
  "lawnMowerControl.dock": {
44088
47196
  capName: "lawn-mower-control",
44089
47197
  capScope: "device",
@@ -45458,6 +48566,18 @@ Object.freeze({
45458
48566
  addonId: null,
45459
48567
  access: "create"
45460
48568
  },
48569
+ "pipelineAnalytics.addRetrainFrameFromRecording": {
48570
+ capName: "pipeline-analytics",
48571
+ capScope: "device",
48572
+ addonId: null,
48573
+ access: "create"
48574
+ },
48575
+ "pipelineAnalytics.addRetrainFramesToCollection": {
48576
+ capName: "pipeline-analytics",
48577
+ capScope: "device",
48578
+ addonId: null,
48579
+ access: "create"
48580
+ },
45461
48581
  "pipelineAnalytics.applyDeviceSettingsPatch": {
45462
48582
  capName: "pipeline-analytics",
45463
48583
  capScope: "device",
@@ -45506,12 +48626,36 @@ Object.freeze({
45506
48626
  addonId: null,
45507
48627
  access: "view"
45508
48628
  },
48629
+ "pipelineAnalytics.createRetrainCollection": {
48630
+ capName: "pipeline-analytics",
48631
+ capScope: "device",
48632
+ addonId: null,
48633
+ access: "create"
48634
+ },
48635
+ "pipelineAnalytics.createRetrainDatasetVersion": {
48636
+ capName: "pipeline-analytics",
48637
+ capScope: "device",
48638
+ addonId: null,
48639
+ access: "create"
48640
+ },
45509
48641
  "pipelineAnalytics.deleteDeviceEvents": {
45510
48642
  capName: "pipeline-analytics",
45511
48643
  capScope: "device",
45512
48644
  addonId: null,
45513
48645
  access: "delete"
45514
48646
  },
48647
+ "pipelineAnalytics.deleteRetrainCollection": {
48648
+ capName: "pipeline-analytics",
48649
+ capScope: "device",
48650
+ addonId: null,
48651
+ access: "delete"
48652
+ },
48653
+ "pipelineAnalytics.deleteRetrainDatasetVersion": {
48654
+ capName: "pipeline-analytics",
48655
+ capScope: "device",
48656
+ addonId: null,
48657
+ access: "delete"
48658
+ },
45515
48659
  "pipelineAnalytics.deleteTracks": {
45516
48660
  capName: "pipeline-analytics",
45517
48661
  capScope: "device",
@@ -45716,6 +48860,30 @@ Object.freeze({
45716
48860
  addonId: null,
45717
48861
  access: "view"
45718
48862
  },
48863
+ "pipelineAnalytics.listRetrainAssistProfiles": {
48864
+ capName: "pipeline-analytics",
48865
+ capScope: "device",
48866
+ addonId: null,
48867
+ access: "view"
48868
+ },
48869
+ "pipelineAnalytics.listRetrainCollectionFrames": {
48870
+ capName: "pipeline-analytics",
48871
+ capScope: "device",
48872
+ addonId: null,
48873
+ access: "view"
48874
+ },
48875
+ "pipelineAnalytics.listRetrainCollections": {
48876
+ capName: "pipeline-analytics",
48877
+ capScope: "device",
48878
+ addonId: null,
48879
+ access: "view"
48880
+ },
48881
+ "pipelineAnalytics.listRetrainDatasetVersions": {
48882
+ capName: "pipeline-analytics",
48883
+ capScope: "device",
48884
+ addonId: null,
48885
+ access: "view"
48886
+ },
45719
48887
  "pipelineAnalytics.listRetrainFrames": {
45720
48888
  capName: "pipeline-analytics",
45721
48889
  capScope: "device",
@@ -45746,6 +48914,12 @@ Object.freeze({
45746
48914
  addonId: null,
45747
48915
  access: "view"
45748
48916
  },
48917
+ "pipelineAnalytics.offerRetrainArchive": {
48918
+ capName: "pipeline-analytics",
48919
+ capScope: "device",
48920
+ addonId: null,
48921
+ access: "create"
48922
+ },
45749
48923
  "pipelineAnalytics.ownersWithMedia": {
45750
48924
  capName: "pipeline-analytics",
45751
48925
  capScope: "device",
@@ -45758,12 +48932,24 @@ Object.freeze({
45758
48932
  addonId: null,
45759
48933
  access: "create"
45760
48934
  },
48935
+ "pipelineAnalytics.previewRetrainDataset": {
48936
+ capName: "pipeline-analytics",
48937
+ capScope: "device",
48938
+ addonId: null,
48939
+ access: "view"
48940
+ },
45761
48941
  "pipelineAnalytics.proposeRetrainAnnotations": {
45762
48942
  capName: "pipeline-analytics",
45763
48943
  capScope: "device",
45764
48944
  addonId: null,
45765
48945
  access: "create"
45766
48946
  },
48947
+ "pipelineAnalytics.proposeRetrainAnnotationsWithLlm": {
48948
+ capName: "pipeline-analytics",
48949
+ capScope: "device",
48950
+ addonId: null,
48951
+ access: "create"
48952
+ },
45767
48953
  "pipelineAnalytics.pruneEvents": {
45768
48954
  capName: "pipeline-analytics",
45769
48955
  capScope: "device",
@@ -45818,6 +49004,18 @@ Object.freeze({
45818
49004
  addonId: null,
45819
49005
  access: "create"
45820
49006
  },
49007
+ "pipelineAnalytics.removeRetrainFrameFromCollection": {
49008
+ capName: "pipeline-analytics",
49009
+ capScope: "device",
49010
+ addonId: null,
49011
+ access: "delete"
49012
+ },
49013
+ "pipelineAnalytics.renameRetrainCollection": {
49014
+ capName: "pipeline-analytics",
49015
+ capScope: "device",
49016
+ addonId: null,
49017
+ access: "create"
49018
+ },
45821
49019
  "pipelineAnalytics.restageRetrainTrack": {
45822
49020
  capName: "pipeline-analytics",
45823
49021
  capScope: "device",
@@ -45878,6 +49076,12 @@ Object.freeze({
45878
49076
  addonId: null,
45879
49077
  access: "create"
45880
49078
  },
49079
+ "pipelineAnalytics.verifyRetrainDatasetVersion": {
49080
+ capName: "pipeline-analytics",
49081
+ capScope: "device",
49082
+ addonId: null,
49083
+ access: "view"
49084
+ },
45881
49085
  "pipelineAnalytics.wipeAllAnalytics": {
45882
49086
  capName: "pipeline-analytics",
45883
49087
  capScope: "device",
@@ -46106,6 +49310,12 @@ Object.freeze({
46106
49310
  addonId: null,
46107
49311
  access: "view"
46108
49312
  },
49313
+ "pipelineOrchestrator.abortNodeBenchmark": {
49314
+ capName: "pipeline-orchestrator",
49315
+ capScope: "system",
49316
+ addonId: null,
49317
+ access: "create"
49318
+ },
46109
49319
  "pipelineOrchestrator.applyAutoTune": {
46110
49320
  capName: "pipeline-orchestrator",
46111
49321
  capScope: "system",
@@ -46130,6 +49340,12 @@ Object.freeze({
46130
49340
  addonId: null,
46131
49341
  access: "create"
46132
49342
  },
49343
+ "pipelineOrchestrator.deleteNodeBenchmarkResult": {
49344
+ capName: "pipeline-orchestrator",
49345
+ capScope: "system",
49346
+ addonId: null,
49347
+ access: "delete"
49348
+ },
46133
49349
  "pipelineOrchestrator.getAgentLoad": {
46134
49350
  capName: "pipeline-orchestrator",
46135
49351
  capScope: "system",
@@ -46238,6 +49454,24 @@ Object.freeze({
46238
49454
  addonId: null,
46239
49455
  access: "view"
46240
49456
  },
49457
+ "pipelineOrchestrator.getNodeBenchmarkCandidates": {
49458
+ capName: "pipeline-orchestrator",
49459
+ capScope: "system",
49460
+ addonId: null,
49461
+ access: "view"
49462
+ },
49463
+ "pipelineOrchestrator.getNodeBenchmarkPreflight": {
49464
+ capName: "pipeline-orchestrator",
49465
+ capScope: "system",
49466
+ addonId: null,
49467
+ access: "view"
49468
+ },
49469
+ "pipelineOrchestrator.getNodeBenchmarkStatus": {
49470
+ capName: "pipeline-orchestrator",
49471
+ capScope: "system",
49472
+ addonId: null,
49473
+ access: "view"
49474
+ },
46241
49475
  "pipelineOrchestrator.getNodeInferenceDevices": {
46242
49476
  capName: "pipeline-orchestrator",
46243
49477
  capScope: "system",
@@ -46280,6 +49514,12 @@ Object.freeze({
46280
49514
  addonId: null,
46281
49515
  access: "view"
46282
49516
  },
49517
+ "pipelineOrchestrator.listNodeBenchmarkResults": {
49518
+ capName: "pipeline-orchestrator",
49519
+ capScope: "system",
49520
+ addonId: null,
49521
+ access: "view"
49522
+ },
46283
49523
  "pipelineOrchestrator.pauseForStorageMigration": {
46284
49524
  capName: "pipeline-orchestrator",
46285
49525
  capScope: "system",
@@ -46424,6 +49664,12 @@ Object.freeze({
46424
49664
  addonId: null,
46425
49665
  access: "create"
46426
49666
  },
49667
+ "pipelineOrchestrator.startNodeBenchmark": {
49668
+ capName: "pipeline-orchestrator",
49669
+ capScope: "system",
49670
+ addonId: null,
49671
+ access: "create"
49672
+ },
46427
49673
  "pipelineOrchestrator.suggestShares": {
46428
49674
  capName: "pipeline-orchestrator",
46429
49675
  capScope: "system",
@@ -46442,6 +49688,12 @@ Object.freeze({
46442
49688
  addonId: null,
46443
49689
  access: "create"
46444
49690
  },
49691
+ "pipelineRunner.abortNodeBench": {
49692
+ capName: "pipeline-runner",
49693
+ capScope: "system",
49694
+ addonId: null,
49695
+ access: "create"
49696
+ },
46445
49697
  "pipelineRunner.attachCamera": {
46446
49698
  capName: "pipeline-runner",
46447
49699
  capScope: "system",
@@ -46490,6 +49742,12 @@ Object.freeze({
46490
49742
  addonId: null,
46491
49743
  access: "view"
46492
49744
  },
49745
+ "pipelineRunner.getNodeBenchStatus": {
49746
+ capName: "pipeline-runner",
49747
+ capScope: "system",
49748
+ addonId: null,
49749
+ access: "view"
49750
+ },
46493
49751
  "pipelineRunner.getParkedTrackFrame": {
46494
49752
  capName: "pipeline-runner",
46495
49753
  capScope: "system",
@@ -46532,6 +49790,12 @@ Object.freeze({
46532
49790
  addonId: null,
46533
49791
  access: "create"
46534
49792
  },
49793
+ "pipelineRunner.startNodeBench": {
49794
+ capName: "pipeline-runner",
49795
+ capScope: "system",
49796
+ addonId: null,
49797
+ access: "create"
49798
+ },
46535
49799
  "plateGallery.assignPlate": {
46536
49800
  capName: "plate-gallery",
46537
49801
  capScope: "system",
@@ -48194,6 +51458,174 @@ Object.freeze({
48194
51458
  addonId: null,
48195
51459
  access: "view"
48196
51460
  },
51461
+ "training.canaryResult": {
51462
+ capName: "training",
51463
+ capScope: "system",
51464
+ addonId: null,
51465
+ access: "create"
51466
+ },
51467
+ "training.cancelJob": {
51468
+ capName: "training",
51469
+ capScope: "system",
51470
+ addonId: null,
51471
+ access: "create"
51472
+ },
51473
+ "training.discardResult": {
51474
+ capName: "training",
51475
+ capScope: "system",
51476
+ addonId: null,
51477
+ access: "create"
51478
+ },
51479
+ "training.findDatasetVersionIdByName": {
51480
+ capName: "training",
51481
+ capScope: "system",
51482
+ addonId: null,
51483
+ access: "view"
51484
+ },
51485
+ "training.getDatasetVersion": {
51486
+ capName: "training",
51487
+ capScope: "system",
51488
+ addonId: null,
51489
+ access: "view"
51490
+ },
51491
+ "training.getJob": {
51492
+ capName: "training",
51493
+ capScope: "system",
51494
+ addonId: null,
51495
+ access: "view"
51496
+ },
51497
+ "training.getJobResult": {
51498
+ capName: "training",
51499
+ capScope: "system",
51500
+ addonId: null,
51501
+ access: "view"
51502
+ },
51503
+ "training.listBaseModels": {
51504
+ capName: "training",
51505
+ capScope: "system",
51506
+ addonId: null,
51507
+ access: "view"
51508
+ },
51509
+ "training.listDatasetVersions": {
51510
+ capName: "training",
51511
+ capScope: "system",
51512
+ addonId: null,
51513
+ access: "view"
51514
+ },
51515
+ "training.listJobs": {
51516
+ capName: "training",
51517
+ capScope: "system",
51518
+ addonId: null,
51519
+ access: "view"
51520
+ },
51521
+ "training.planJob": {
51522
+ capName: "training",
51523
+ capScope: "system",
51524
+ addonId: null,
51525
+ access: "view"
51526
+ },
51527
+ "training.putDatasetVersion": {
51528
+ capName: "training",
51529
+ capScope: "system",
51530
+ addonId: null,
51531
+ access: "create"
51532
+ },
51533
+ "training.registerResult": {
51534
+ capName: "training",
51535
+ capScope: "system",
51536
+ addonId: null,
51537
+ access: "create"
51538
+ },
51539
+ "training.removeDatasetVersion": {
51540
+ capName: "training",
51541
+ capScope: "system",
51542
+ addonId: null,
51543
+ access: "delete"
51544
+ },
51545
+ "training.rollbackCanary": {
51546
+ capName: "training",
51547
+ capScope: "system",
51548
+ addonId: null,
51549
+ access: "create"
51550
+ },
51551
+ "training.startJob": {
51552
+ capName: "training",
51553
+ capScope: "system",
51554
+ addonId: null,
51555
+ access: "create"
51556
+ },
51557
+ "trainingProvider.cancelJob": {
51558
+ capName: "training-provider",
51559
+ capScope: "system",
51560
+ addonId: null,
51561
+ access: "create"
51562
+ },
51563
+ "trainingProvider.cleanupJob": {
51564
+ capName: "training-provider",
51565
+ capScope: "system",
51566
+ addonId: null,
51567
+ access: "create"
51568
+ },
51569
+ "trainingProvider.describe": {
51570
+ capName: "training-provider",
51571
+ capScope: "system",
51572
+ addonId: null,
51573
+ access: "view"
51574
+ },
51575
+ "trainingProvider.estimateJob": {
51576
+ capName: "training-provider",
51577
+ capScope: "system",
51578
+ addonId: null,
51579
+ access: "view"
51580
+ },
51581
+ "trainingProvider.getJob": {
51582
+ capName: "training-provider",
51583
+ capScope: "system",
51584
+ addonId: null,
51585
+ access: "view"
51586
+ },
51587
+ "trainingProvider.listJobEvents": {
51588
+ capName: "training-provider",
51589
+ capScope: "system",
51590
+ addonId: null,
51591
+ access: "view"
51592
+ },
51593
+ "trainingProvider.listJobs": {
51594
+ capName: "training-provider",
51595
+ capScope: "system",
51596
+ addonId: null,
51597
+ access: "view"
51598
+ },
51599
+ "trainingProvider.offerArtifact": {
51600
+ capName: "training-provider",
51601
+ capScope: "system",
51602
+ addonId: null,
51603
+ access: "create"
51604
+ },
51605
+ "trainingProvider.readResult": {
51606
+ capName: "training-provider",
51607
+ capScope: "system",
51608
+ addonId: null,
51609
+ access: "create"
51610
+ },
51611
+ "trainingProvider.submitJob": {
51612
+ capName: "training-provider",
51613
+ capScope: "system",
51614
+ addonId: null,
51615
+ access: "create"
51616
+ },
51617
+ "trainingProvider.uploadDataset": {
51618
+ capName: "training-provider",
51619
+ capScope: "system",
51620
+ addonId: null,
51621
+ access: "create"
51622
+ },
51623
+ "trainingProvider.validateCredentials": {
51624
+ capName: "training-provider",
51625
+ capScope: "system",
51626
+ addonId: null,
51627
+ access: "create"
51628
+ },
48197
51629
  "turnProvider.getTurnServers": {
48198
51630
  capName: "turn-provider",
48199
51631
  capScope: "system",
@@ -48218,12 +51650,6 @@ Object.freeze({
48218
51650
  addonId: null,
48219
51651
  access: "create"
48220
51652
  },
48221
- "userManagement.createApiKey": {
48222
- capName: "user-management",
48223
- capScope: "system",
48224
- addonId: null,
48225
- access: "create"
48226
- },
48227
51653
  "userManagement.createScopedToken": {
48228
51654
  capName: "user-management",
48229
51655
  capScope: "system",
@@ -48260,12 +51686,6 @@ Object.freeze({
48260
51686
  addonId: null,
48261
51687
  access: "view"
48262
51688
  },
48263
- "userManagement.linkExternalIdentity": {
48264
- capName: "user-management",
48265
- capScope: "system",
48266
- addonId: null,
48267
- access: "create"
48268
- },
48269
51689
  "userManagement.listApiKeys": {
48270
51690
  capName: "user-management",
48271
51691
  capScope: "system",
@@ -48368,12 +51788,6 @@ Object.freeze({
48368
51788
  addonId: null,
48369
51789
  access: "create"
48370
51790
  },
48371
- "userManagement.validateApiKey": {
48372
- capName: "user-management",
48373
- capScope: "system",
48374
- addonId: null,
48375
- access: "view"
48376
- },
48377
51791
  "userManagement.validateCredentials": {
48378
51792
  capName: "user-management",
48379
51793
  capScope: "system",
@@ -51461,6 +54875,11 @@ Object.freeze({
51461
54875
  form: "single",
51462
54876
  optional: false
51463
54877
  }],
54878
+ "pipelineAnalytics.addRetrainFrameFromRecording": [{
54879
+ name: "deviceId",
54880
+ form: "single",
54881
+ optional: false
54882
+ }],
51464
54883
  "pipelineAnalytics.applyDeviceSettingsPatch": [{
51465
54884
  name: "deviceId",
51466
54885
  form: "single",
@@ -51651,6 +55070,11 @@ Object.freeze({
51651
55070
  form: "single",
51652
55071
  optional: false
51653
55072
  }],
55073
+ "pipelineAnalytics.proposeRetrainAnnotationsWithLlm": [{
55074
+ name: "deviceId",
55075
+ form: "single",
55076
+ optional: false
55077
+ }],
51654
55078
  "pipelineAnalytics.pruneEventsBefore": [{
51655
55079
  name: "deviceId",
51656
55080
  form: "single",
@@ -52477,6 +55901,11 @@ Object.freeze({
52477
55901
  form: "single",
52478
55902
  optional: false
52479
55903
  }],
55904
+ "training.canaryResult": [{
55905
+ name: "deviceIds",
55906
+ form: "array",
55907
+ optional: false
55908
+ }],
52480
55909
  "update.getStatus": [{
52481
55910
  name: "deviceId",
52482
55911
  form: "single",