@camstack/addon-provider-homeassistant 1.2.163 → 1.2.165

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,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,
@@ -7102,6 +8192,69 @@ method(object({ deviceId: number() }), array(StreamSourceEntrySchema)), method(o
7102
8192
  kind: "mutation",
7103
8193
  auth: "admin"
7104
8194
  }), method(object({ deviceId: number() }), unknown().nullable()), method(object({ deviceId: number() }), RawStateResultSchema.nullable(), { auth: "protected" });
8195
+ function defOf(schema) {
8196
+ return schema._zod?.def ?? {};
8197
+ }
8198
+ function declaredHere(schema) {
8199
+ return globalRegistry.get(schema)?.secret === true;
8200
+ }
8201
+ /** Wrapper kinds whose `innerType` is the field itself. */
8202
+ var WRAPPERS = new Set([
8203
+ "optional",
8204
+ "nullable",
8205
+ "default",
8206
+ "prefault",
8207
+ "catch",
8208
+ "readonly",
8209
+ "nonoptional"
8210
+ ]);
8211
+ /**
8212
+ * The schema layers that make up ONE field: the schema itself and every
8213
+ * wrapper below it (optional / default / nullable / readonly / catch), plus
8214
+ * both sides of a pipe (`z.preprocess` puts the real schema on `out`,
8215
+ * `.transform` on `in`).
8216
+ */
8217
+ function layersOf(schema) {
8218
+ const out = [];
8219
+ const queue = [schema];
8220
+ while (queue.length > 0) {
8221
+ const s = queue.shift();
8222
+ if (!s || out.includes(s)) continue;
8223
+ out.push(s);
8224
+ const def = defOf(s);
8225
+ if (def.type !== void 0 && WRAPPERS.has(def.type) && def.innerType) queue.push(def.innerType);
8226
+ if (def.type === "pipe") {
8227
+ if (def.in) queue.push(def.in);
8228
+ if (def.out) queue.push(def.out);
8229
+ }
8230
+ }
8231
+ return out;
8232
+ }
8233
+ /** True when any layer of this field declares `.meta({ secret: true })`. */
8234
+ function isZodSecret(schema) {
8235
+ return layersOf(schema).some(declaredHere);
8236
+ }
8237
+ /**
8238
+ * Every declared secret path in a config schema: dotted keys, `[]` for "each
8239
+ * element of this array" (`connection.password`, `rows[].token`). A declared
8240
+ * object or array is reported as one path and not descended into — everything
8241
+ * under it is secret.
8242
+ */
8243
+ function collectZodSecretPaths(schema, prefix = "") {
8244
+ if (isZodSecret(schema)) return prefix.length > 0 ? [prefix] : [];
8245
+ const paths = [];
8246
+ for (const layer of layersOf(schema)) {
8247
+ const def = defOf(layer);
8248
+ if (def.type === "object" && def.shape) for (const [key, child] of Object.entries(def.shape)) paths.push(...collectZodSecretPaths(child, prefix ? `${prefix}.${key}` : key));
8249
+ else if (def.type === "array" && def.element) paths.push(...collectZodSecretPaths(def.element, `${prefix}[]`));
8250
+ else if (def.type === "union" && def.options) for (const option of def.options) paths.push(...collectZodSecretPaths(option, prefix));
8251
+ else if (def.type === "intersection") {
8252
+ if (def.left) paths.push(...collectZodSecretPaths(def.left, prefix));
8253
+ if (def.right) paths.push(...collectZodSecretPaths(def.right, prefix));
8254
+ }
8255
+ }
8256
+ return [...new Set(paths)];
8257
+ }
7105
8258
  //#endregion
7106
8259
  //#region ../types/dist/err-msg-DX6i_MY4.mjs
7107
8260
  var DeviceType = /* @__PURE__ */ function(DeviceType) {
@@ -8923,6 +10076,278 @@ var CameraSwitchGroupSchema = object({
8923
10076
  fetchedAt: number()
8924
10077
  });
8925
10078
  /**
10079
+ * The trainer contract — what the hub hands the cloud trainer and what it
10080
+ * gets back (cloud training, D805+).
10081
+ *
10082
+ * The trainer (`hf/camstack-trainer`, published as the Hugging Face repo
10083
+ * `camstack/camstack-trainer`) is a separate AGPL program the hub never
10084
+ * imports: `job.json` goes in, files come out, and progress is `CAMSTACK_EVENT`
10085
+ * lines on stdout. These schemas are the hub's half of that boundary; the
10086
+ * trainer's pydantic models (and the JSON Schemas generated from them under
10087
+ * `hf/camstack-trainer/schemas/`) are the other half. A change here is a
10088
+ * change there, in the same piece of work.
10089
+ *
10090
+ * No `.default()` anywhere: defaults do not run on the addon cap path, so the
10091
+ * orchestrator fills every field of a job spec explicitly.
10092
+ */
10093
+ var TRAINING_JOB_SCHEMA = "camstack.training/v1";
10094
+ var TRAINING_RESULT_SCHEMA = "camstack.training-result/v1";
10095
+ /** What the trainer can export. Edge TPU is a later, separate image. */
10096
+ var TrainingExportSchema = _enum([
10097
+ "onnx",
10098
+ "openvino-fp16",
10099
+ "openvino-int8",
10100
+ "coreml-fp16"
10101
+ ]);
10102
+ var FloorsSchema = record(string(), number().min(0).max(1));
10103
+ object({
10104
+ schema: literal(TRAINING_JOB_SCHEMA),
10105
+ jobKey: string().uuid(),
10106
+ target: object({
10107
+ kind: literal("detector"),
10108
+ step: literal("object-detection")
10109
+ }),
10110
+ base: object({
10111
+ modelId: string().min(1),
10112
+ /** Ultralytics weights id, e.g. `yolov9m.pt`. */
10113
+ weights: string().min(1),
10114
+ imgsz: number().int().positive()
10115
+ }),
10116
+ baseline: object({
10117
+ modelId: string().min(1),
10118
+ /** The baseline ONNX the holdout comparison runs; public mirror URL. */
10119
+ onnxUrl: string().url(),
10120
+ imgsz: number().int().positive(),
10121
+ floors: FloorsSchema
10122
+ }),
10123
+ dataset: object({
10124
+ versionId: string().min(1),
10125
+ annotationHash: string(),
10126
+ /** sha256 of the uploaded archive; the trainer refuses a mismatch (exit 65). */
10127
+ sha256: string().regex(/^[0-9a-f]{64}$/)
10128
+ }),
10129
+ split: object({
10130
+ holdoutCameras: array(number().int()),
10131
+ /** When no camera is held out: the last N days of every camera. */
10132
+ holdoutLastDays: number().int().nonnegative(),
10133
+ valFraction: number().min(0).max(.5),
10134
+ seed: number().int()
10135
+ }),
10136
+ hyper: object({
10137
+ epochs: number().int().positive(),
10138
+ batch: number().int().positive(),
10139
+ lr0: number().positive(),
10140
+ /** Layers frozen from the start of the backbone; 0 = none. */
10141
+ freeze: number().int().nonnegative(),
10142
+ patience: number().int().nonnegative(),
10143
+ seed: number().int()
10144
+ }),
10145
+ replay: object({
10146
+ source: literal("coco2017"),
10147
+ count: number().int().nonnegative()
10148
+ }),
10149
+ exports: array(TrainingExportSchema).min(1),
10150
+ calibration: object({ maxFrames: number().int().positive() }),
10151
+ floors: object({
10152
+ minSupport: number().int().positive(),
10153
+ clamp: number().min(0).max(1)
10154
+ }),
10155
+ int8Gate: object({ maxMap50Drop: number().min(0).max(1) }),
10156
+ catalog: object({
10157
+ id: string().regex(/^[a-z0-9][a-z0-9-]{2,80}$/),
10158
+ name: string().min(1).max(160)
10159
+ })
10160
+ });
10161
+ /** One regular file of the bundle. An mlpackage contributes one row per member. */
10162
+ var TrainingResultFileSchema = object({
10163
+ path: string().min(1),
10164
+ bytes: number().int().nonnegative(),
10165
+ sha256: string().regex(/^[0-9a-f]{64}$/),
10166
+ format: _enum([
10167
+ "onnx",
10168
+ "openvino",
10169
+ "coreml",
10170
+ "pt"
10171
+ ]),
10172
+ variant: _enum(["base", "int8"])
10173
+ });
10174
+ var DraftFormatSchema = object({
10175
+ /** RELATIVE path inside the bundle; the hub rewrites it to `camstack-local://`. */
10176
+ url: string().min(1),
10177
+ sizeMB: number().nonnegative(),
10178
+ isDirectory: boolean().optional(),
10179
+ files: array(string()).optional(),
10180
+ runtimes: array(literal("python")).optional(),
10181
+ revision: string().min(1)
10182
+ });
10183
+ /** The trainer's half of a catalog entry; the hub completes it (labels, licence, group). */
10184
+ var TrainingCatalogDraftSchema = object({
10185
+ id: string().min(1),
10186
+ name: string().min(1),
10187
+ description: string(),
10188
+ labels: array(unknown()),
10189
+ inputSize: object({
10190
+ width: number().int().positive(),
10191
+ height: number().int().positive()
10192
+ }),
10193
+ preprocessMode: literal("letterbox"),
10194
+ defaultClassFloors: FloorsSchema,
10195
+ formats: object({
10196
+ onnx: DraftFormatSchema.optional(),
10197
+ openvino: DraftFormatSchema.optional(),
10198
+ coreml: DraftFormatSchema.optional()
10199
+ })
10200
+ });
10201
+ /** One class of one model's holdout report (the eval harness's summary). */
10202
+ var TrainingEvalClassSchema = object({
10203
+ positives: number().int(),
10204
+ floor: number().nullable(),
10205
+ tp: number().int(),
10206
+ fp: number().int(),
10207
+ fn: number().int(),
10208
+ precision: number().nullable(),
10209
+ recall: number().nullable(),
10210
+ ap50: number().nullable(),
10211
+ recallByCamera: record(string(), number().nullable()).optional(),
10212
+ recallByLight: record(string(), number().nullable()).optional(),
10213
+ fpByCamera: record(string(), number()).optional(),
10214
+ smallFound: number().int().optional(),
10215
+ smallTotal: number().int().optional()
10216
+ }).passthrough();
10217
+ var TrainingEvalReportSchema = object({
10218
+ frames: number().int(),
10219
+ classes: record(string(), TrainingEvalClassSchema)
10220
+ }).passthrough();
10221
+ /**
10222
+ * A succeeded result carries every block; a failed one carries the error and
10223
+ * whatever was known by then — the other blocks are ABSENT, not null. The
10224
+ * orchestrator checks the blocks it needs before it trusts a success.
10225
+ */
10226
+ var TrainingResultSchema = object({
10227
+ schema: literal(TRAINING_RESULT_SCHEMA),
10228
+ jobKey: string(),
10229
+ status: _enum(["succeeded", "failed"]),
10230
+ error: object({
10231
+ stage: string(),
10232
+ code: string(),
10233
+ message: string()
10234
+ }).nullable(),
10235
+ trainer: object({
10236
+ version: string(),
10237
+ revision: string()
10238
+ }),
10239
+ toolchain: record(string(), string().nullable()),
10240
+ dataset: object({
10241
+ versionId: string(),
10242
+ annotationHash: string(),
10243
+ sha256: string(),
10244
+ frames: object({
10245
+ train: number().int(),
10246
+ val: number().int(),
10247
+ holdout: number().int()
10248
+ }),
10249
+ holdoutCameras: array(number().int()),
10250
+ replayImages: number().int()
10251
+ }).optional(),
10252
+ training: object({
10253
+ epochsRun: number().int(),
10254
+ bestEpoch: number().int(),
10255
+ bestMap50: number(),
10256
+ bestMap50_95: number(),
10257
+ seconds: number()
10258
+ }).optional(),
10259
+ evaluation: object({
10260
+ holdoutFrames: number().int(),
10261
+ baseline: TrainingEvalReportSchema.nullable(),
10262
+ candidate: TrainingEvalReportSchema.nullable(),
10263
+ candidateInt8: TrainingEvalReportSchema.nullable(),
10264
+ recallDeltaByCamera: record(string(), record(string(), number())).nullable(),
10265
+ map50: record(string(), number().nullable())
10266
+ }).optional(),
10267
+ floors: object({
10268
+ baseline: FloorsSchema,
10269
+ candidate: FloorsSchema,
10270
+ candidateInt8: FloorsSchema.nullable(),
10271
+ notes: array(string())
10272
+ }).optional(),
10273
+ int8: object({
10274
+ kept: boolean(),
10275
+ map50Fp16: number().nullable(),
10276
+ map50Int8: number().nullable(),
10277
+ reason: string().nullable()
10278
+ }).optional(),
10279
+ exportsDropped: array(object({
10280
+ export: string(),
10281
+ reason: string()
10282
+ })).optional(),
10283
+ files: array(TrainingResultFileSchema).optional(),
10284
+ bundle: object({
10285
+ path: literal("bundle.tar"),
10286
+ bytes: number().int().nonnegative(),
10287
+ sha256: string().regex(/^[0-9a-f]{64}$/)
10288
+ }).nullable().optional(),
10289
+ catalogDraft: object({
10290
+ base: TrainingCatalogDraftSchema,
10291
+ int8: TrainingCatalogDraftSchema.nullable()
10292
+ }).nullable().optional(),
10293
+ licence: string()
10294
+ });
10295
+ var TrainingStageSchema = _enum([
10296
+ "prepare",
10297
+ "replay",
10298
+ "train",
10299
+ "eval",
10300
+ "export",
10301
+ "package"
10302
+ ]);
10303
+ var EventBase = {
10304
+ v: literal(1),
10305
+ ts: number()
10306
+ };
10307
+ discriminatedUnion("type", [
10308
+ object({
10309
+ ...EventBase,
10310
+ type: literal("stage"),
10311
+ stage: TrainingStageSchema
10312
+ }),
10313
+ object({
10314
+ ...EventBase,
10315
+ type: literal("epoch"),
10316
+ epoch: number().int(),
10317
+ epochs: number().int(),
10318
+ boxLoss: number().nullable().optional(),
10319
+ map50: number().nullable().optional(),
10320
+ map50_95: number().nullable().optional(),
10321
+ etaSec: number().nullable().optional()
10322
+ }),
10323
+ object({
10324
+ ...EventBase,
10325
+ type: literal("metric"),
10326
+ name: string(),
10327
+ value: number()
10328
+ }),
10329
+ object({
10330
+ ...EventBase,
10331
+ type: literal("artifact"),
10332
+ path: string(),
10333
+ bytes: number(),
10334
+ sha256: string()
10335
+ }),
10336
+ object({
10337
+ ...EventBase,
10338
+ type: literal("done"),
10339
+ status: _enum(["succeeded", "failed"]),
10340
+ resultSha256: string().nullable().optional()
10341
+ }),
10342
+ object({
10343
+ ...EventBase,
10344
+ type: literal("error"),
10345
+ stage: string(),
10346
+ code: string(),
10347
+ message: string()
10348
+ })
10349
+ ]);
10350
+ /**
8926
10351
  * What the gate decided about a birth, from the CALLER's point of view.
8927
10352
  *
8928
10353
  * Deliberately not `ConfirmationVerdict`: `undecided` is not a birth decision
@@ -11250,7 +12675,9 @@ var AddonHttpRouteSchema = object({
11250
12675
  "authenticated",
11251
12676
  "admin"
11252
12677
  ]).optional(),
11253
- description: string().optional()
12678
+ description: string().optional(),
12679
+ /** The hub limits this route per client address before the handler runs. */
12680
+ rateLimit: _enum(["auth"]).optional()
11254
12681
  });
11255
12682
  /**
11256
12683
  * Cross-process route invocation envelope. The hub captures the
@@ -11974,6 +13401,37 @@ var BackupDestinationInfoSchema = object({
11974
13401
  lastError: string().optional()
11975
13402
  });
11976
13403
  /**
13404
+ * How an archive is encrypted (operator decision 2026-10-09): to a backup
13405
+ * PUBLIC key the hub holds, so only the operator's secret key opens it.
13406
+ * Absent on a plain `.tar.gz` — every archive made before encryption, or
13407
+ * with it off — which restores without a key.
13408
+ */
13409
+ var BackupArchiveEncryptionSchema = object({
13410
+ /** `x25519-hkdf-aes256gcm-stream-v1`. */
13411
+ scheme: string(),
13412
+ /** 16 hex — the backup key whose secret restores this archive. */
13413
+ keyId: string()
13414
+ });
13415
+ /**
13416
+ * The backup encryption setting. The hub keeps PUBLIC keys only: the active
13417
+ * one new archives are encrypted to, and the retired ones older archives
13418
+ * still need. The secret key is shown once, at `setupEncryption`.
13419
+ */
13420
+ var BackupEncryptionStatusSchema = object({
13421
+ enabled: boolean(),
13422
+ active: object({
13423
+ keyId: string(),
13424
+ publicKey: string(),
13425
+ createdAt: number()
13426
+ }).nullable(),
13427
+ /** Every key ever set up, newest first. */
13428
+ keys: array(object({
13429
+ keyId: string(),
13430
+ createdAt: number(),
13431
+ retiredAt: number().nullable()
13432
+ })).readonly()
13433
+ });
13434
+ /**
11977
13435
  * Per-archive entry returned by `backup.listArchives({ destinationId })`.
11978
13436
  * Same shape the destination drill-in renders. Sourced from the per-
11979
13437
  * location `manifests.json` (no per-archive tarball read required).
@@ -11985,7 +13443,9 @@ var BackupArchiveEntrySchema = object({
11985
13443
  sizeBytes: number(),
11986
13444
  label: string().optional(),
11987
13445
  /** Top-level locations included in the archive (db, addons, tls, …). */
11988
- locations: array(string()).readonly()
13446
+ locations: array(string()).readonly(),
13447
+ /** Present when the archive is encrypted; restore then needs that key. */
13448
+ encryption: BackupArchiveEncryptionSchema.optional()
11989
13449
  });
11990
13450
  var BackupEntrySchema = object({
11991
13451
  id: string(),
@@ -11994,7 +13454,8 @@ var BackupEntrySchema = object({
11994
13454
  label: string().optional(),
11995
13455
  createdAt: number(),
11996
13456
  sizeBytes: number(),
11997
- locations: array(string()).optional()
13457
+ locations: array(string()).optional(),
13458
+ encryption: BackupArchiveEncryptionSchema.optional()
11998
13459
  });
11999
13460
  var ArchiveEntrySchema = object({
12000
13461
  path: string(),
@@ -12183,10 +13644,40 @@ method(_void(), array(BackupDestinationInfoSchema).readonly(), { auth: "admin" }
12183
13644
  * this list and skips entries whose path doesn't start with
12184
13645
  * any of them.
12185
13646
  */
12186
- locations: array(string()).optional()
13647
+ locations: array(string()).optional(),
13648
+ /**
13649
+ * The backup SECRET key, for an encrypted archive (ignored for a plain
13650
+ * one). The archive is decrypted into the hub's private staging
13651
+ * before the restart; the key is not stored. A wrong or missing key
13652
+ * is refused before the archive is downloaded.
13653
+ */
13654
+ backupSecretKey: string().optional()
12187
13655
  }), _void(), {
12188
13656
  kind: "mutation",
12189
13657
  auth: "admin"
13658
+ }), method(_void(), BackupEncryptionStatusSchema, { auth: "admin" }), method(object({}), object({
13659
+ keyId: string(),
13660
+ secretKey: string(),
13661
+ publicKey: string(),
13662
+ createdAt: number(),
13663
+ replacedKeyId: string().nullable()
13664
+ }), {
13665
+ kind: "mutation",
13666
+ auth: "admin"
13667
+ }), method(object({}), object({ disabledKeyId: string().nullable() }), {
13668
+ kind: "mutation",
13669
+ auth: "admin"
13670
+ }), method(object({ backupSecretKey: string() }), object({
13671
+ valid: boolean(),
13672
+ keyId: string().nullable(),
13673
+ /** The hub knows this key (active or retired). */
13674
+ known: boolean(),
13675
+ /** It is the key new archives are encrypted to. */
13676
+ active: boolean(),
13677
+ error: string().optional()
13678
+ }), {
13679
+ kind: "mutation",
13680
+ auth: "admin"
12190
13681
  }), method(object({
12191
13682
  destinationId: string(),
12192
13683
  backupId: string()
@@ -13961,7 +15452,60 @@ var CustomModelDescriptorSchema = object({
13961
15452
  stepId: string(),
13962
15453
  entry: ModelCatalogEntrySchema
13963
15454
  });
13964
- method(_void(), array(CustomModelDescriptorSchema).readonly(), { auth: "admin" });
15455
+ /** One regular file of an imported bundle, as the producer measured it. */
15456
+ var ModelBundleFileSchema = object({
15457
+ /** Relative path inside the bundle tar; an mlpackage member is `<x>.mlpackage/<member>`. */
15458
+ path: string().min(1),
15459
+ bytes: number().int().nonnegative(),
15460
+ sha256: string().regex(/^[0-9a-f]{64}$/)
15461
+ });
15462
+ var ImportModelBundleInputSchema = object({
15463
+ /** The registry provider that keeps the model (Model Studio). */
15464
+ addonId: string(),
15465
+ stepId: string().min(1),
15466
+ /**
15467
+ * The catalog rows to register, complete, every format URL already
15468
+ * `camstack-local://<modelId>/<file>` naming a file of the bundle. One
15469
+ * bundle may carry several rows (a base and its INT8 variant).
15470
+ */
15471
+ entries: array(ModelCatalogEntrySchema).min(1).max(4),
15472
+ /** The bundle tar, offered by the producer over `ctx.peerBytes` (same host). */
15473
+ bundle: object({
15474
+ ticket: PeerBytesTicketSchema,
15475
+ bytes: number().int().positive(),
15476
+ sha256: string().regex(/^[0-9a-f]{64}$/)
15477
+ }),
15478
+ /** Every file the tar must hold; anything missing, extra or different is refused. */
15479
+ files: array(ModelBundleFileSchema).min(1).max(64),
15480
+ /** Convert missing engine formats and push the model to every agent afterwards. */
15481
+ distribute: boolean()
15482
+ });
15483
+ var ImportModelBundleResultSchema = discriminatedUnion("kind", [object({
15484
+ kind: literal("imported"),
15485
+ modelIds: array(string()).readonly(),
15486
+ distributed: array(object({
15487
+ modelId: string(),
15488
+ nodeId: string(),
15489
+ format: _enum(MODEL_FORMATS),
15490
+ ok: boolean(),
15491
+ error: string().optional()
15492
+ })).readonly()
15493
+ }), object({
15494
+ kind: literal("refused"),
15495
+ reason: _enum([
15496
+ "transfer-failed",
15497
+ "checksum-mismatch",
15498
+ "bundle-mismatch",
15499
+ "invalid-entry",
15500
+ "id-taken"
15501
+ ]),
15502
+ detail: string()
15503
+ })]);
15504
+ method(_void(), array(CustomModelDescriptorSchema).readonly(), { auth: "admin" }), method(ImportModelBundleInputSchema, ImportModelBundleResultSchema, {
15505
+ kind: "mutation",
15506
+ auth: "admin",
15507
+ timeoutMs: 30 * 6e4
15508
+ });
13965
15509
  /**
13966
15510
  * Query filter for settings-store collections.
13967
15511
  */
@@ -14344,6 +15888,253 @@ id: union([string(), number()]) }), {
14344
15888
  kind: "mutation",
14345
15889
  auth: "admin"
14346
15890
  });
15891
+ /**
15892
+ * `keychain` — the hub's encrypted store of secret values (D787).
15893
+ *
15894
+ * Settings blobs never hold a secret: they hold a marker
15895
+ * `{"$secret":"secret://<owner>/<scope>/<fieldPath>","v":1}` and the value
15896
+ * lives here, AES-256-GCM under a data key that a master key wraps. This cap
15897
+ * is the OWNER's door to its own values: every method is owner-checked
15898
+ * against the CALLER, never against anything the caller claims.
15899
+ *
15900
+ * Who the caller is: the transport stamps `callerAddonId` into the args of a
15901
+ * call that crossed a process (the parent `LocalChildRegistry` from the UDS
15902
+ * connection, the agent from its child's connection carried in
15903
+ * `$hub-cap-fwd`'s envelope). A stamp always overwrites; a wire call with no
15904
+ * stamp has its claim stripped. Only a hub in-process caller may state its own
15905
+ * identity — `ctx.secrets` does that with the addon id closed over. This is
15906
+ * identity against BUGS and misrouting, not against a malicious addon (every
15907
+ * runner is the same OS user): see the threat model in
15908
+ * `docs/design/2026-10-08-secrets-keychain.md`.
15909
+ *
15910
+ * `callerAddonId` is deliberately NOT in any input schema: the tRPC router
15911
+ * parses the input, so a session can never supply it, and the internal mount
15912
+ * floors every method to admin anyway (D240).
15913
+ *
15914
+ * Internal: addons reach it through `ctx.secrets`, never directly.
15915
+ */
15916
+ /** Why a value cannot be served right now. Never folded into "missing". */
15917
+ var KeychainUnavailableReasonSchema = _enum([
15918
+ "key-missing",
15919
+ "wrong-key",
15920
+ "key-file-unreadable",
15921
+ "store-unavailable",
15922
+ "not-initialized",
15923
+ "decrypt-failed"
15924
+ ]);
15925
+ var KeychainStateSchema = discriminatedUnion("state", [object({ state: literal("ready") }), object({
15926
+ state: literal("locked"),
15927
+ reason: KeychainUnavailableReasonSchema
15928
+ })]);
15929
+ var KeychainResolveEntrySchema = discriminatedUnion("kind", [
15930
+ object({
15931
+ kind: literal("value"),
15932
+ value: string(),
15933
+ version: number().int()
15934
+ }),
15935
+ object({ kind: literal("missing") }),
15936
+ object({
15937
+ kind: literal("unavailable"),
15938
+ reason: KeychainUnavailableReasonSchema
15939
+ }),
15940
+ object({ kind: literal("forbidden") })
15941
+ ]);
15942
+ var KeychainResolveResultSchema = record(string(), KeychainResolveEntrySchema);
15943
+ /** Metadata of one stored value — never the value. */
15944
+ var KeychainSecretMetaSchema = object({
15945
+ ref: string(),
15946
+ owner: string(),
15947
+ /** Formatted scope (`global`, `node/<id>`, `device/<id>`, …). */
15948
+ scope: string(),
15949
+ fieldPath: string(),
15950
+ version: number().int(),
15951
+ createdAt: number(),
15952
+ updatedAt: number(),
15953
+ /** `addon:<id>` | `user:<id>` | `system`. */
15954
+ updatedBy: string(),
15955
+ /** Coarse — written at most once an hour per ref. `null` = never read. */
15956
+ lastReadAt: number().nullable()
15957
+ });
15958
+ var RefListSchema = array(string().min(1)).max(512);
15959
+ method(object({
15960
+ ref: string().min(1),
15961
+ value: string().min(1)
15962
+ }), object({
15963
+ ref: string(),
15964
+ version: number().int()
15965
+ }), {
15966
+ kind: "mutation",
15967
+ auth: "admin"
15968
+ }), method(object({ refs: RefListSchema }), KeychainResolveResultSchema, { auth: "admin" }), method(object({ refs: RefListSchema }), object({ deleted: number().int() }), {
15969
+ kind: "mutation",
15970
+ auth: "admin"
15971
+ }), method(object({}), array(KeychainSecretMetaSchema).readonly(), { auth: "admin" }), method(object({}), KeychainStateSchema, { auth: "admin" });
15972
+ var KeychainKeySourceSchema = object({
15973
+ kind: _enum([
15974
+ "config-file",
15975
+ "previous-config-file",
15976
+ "platform",
15977
+ "default-file"
15978
+ ]),
15979
+ /** File sources only — a path is not a secret. */
15980
+ path: string().optional(),
15981
+ /**
15982
+ * True when a whole-volume backup of the data directory carries this key
15983
+ * next to the database it protects (the default file). The page warns.
15984
+ */
15985
+ sharesBackupWithDatabase: boolean()
15986
+ });
15987
+ /**
15988
+ * One keychain reset, as the Secrets page reports it until the operator
15989
+ * acknowledges it. Never a value: refs, counts and table names only.
15990
+ */
15991
+ var KeychainResetRecordSchema = object({
15992
+ id: string(),
15993
+ at: number(),
15994
+ /** `user:<id>` or {@link KEYCHAIN_RESET_TRIGGER_ACTOR}. */
15995
+ actor: string(),
15996
+ /** Why the keychain was locked when it was reset; `null` when it was not locked. */
15997
+ lockedReason: string().nullable(),
15998
+ /** Values moved into the archive table (ciphertext under the lost key). */
15999
+ archived: number().int(),
16000
+ /** `keychain:secrets-orphaned-<ts>`, or `null` when nothing was stored. */
16001
+ archivedCollection: string().nullable(),
16002
+ /**
16003
+ * `keychain:keys-orphaned-<ts>`: the wrapped data keys of the archive, kept
16004
+ * so the archive can still be opened if the lost master key turns up.
16005
+ */
16006
+ archivedKeysCollection: string().nullable(),
16007
+ /**
16008
+ * `system-settings` keys whose marker the reset cleared — the cluster
16009
+ * secret's: a marker left pointing at an archived value would refuse every
16010
+ * agent forever (D797).
16011
+ */
16012
+ clearedSettingsKeys: array(string()).readonly(),
16013
+ /** When an operator dismissed the notice on the Secrets page; `null` until then. */
16014
+ acknowledgedAt: number().nullable()
16015
+ });
16016
+ var KeychainStatusSchema = object({
16017
+ keychain: KeychainStateSchema,
16018
+ /** The source of the master key in use; `null` while locked. */
16019
+ keySource: KeychainKeySourceSchema.nullable(),
16020
+ /** The source configured to be primary — differs from `keySource` while a rotation is pending. */
16021
+ configuredSource: KeychainKeySourceSchema,
16022
+ /** Short fingerprint of the master key in use (`HMAC(KEK, label)`, 16 hex). */
16023
+ fingerprint: string().nullable(),
16024
+ activeKeyId: string().nullable(),
16025
+ /**
16026
+ * The keychain unlocked with a NON-primary source: the configured primary
16027
+ * key is not the one that wraps the data key yet. `rotateMasterKey` moves it.
16028
+ */
16029
+ rotationPending: boolean(),
16030
+ /** Wrapped copies of the data key under a previous master key, kept until purged. */
16031
+ retiredWraps: number().int(),
16032
+ recoveryKeyDownloadedAt: number().nullable(),
16033
+ secretCount: number().int(),
16034
+ /** The most recent reset, acknowledged or not; `null` when the keychain was never reset. */
16035
+ lastReset: KeychainResetRecordSchema.nullable()
16036
+ });
16037
+ /**
16038
+ * Whether a stored value is still pointed at by its owner's settings.
16039
+ * `unknown` is a first-class answer: a scope whose blob could not be read is
16040
+ * never reported as an orphan (and never deleted as one).
16041
+ */
16042
+ var KeychainSecretUsageSchema = _enum([
16043
+ "in-use",
16044
+ "orphan",
16045
+ "unknown"
16046
+ ]);
16047
+ var KeychainAdminSecretSchema = KeychainSecretMetaSchema.extend({ usage: KeychainSecretUsageSchema });
16048
+ var KeychainAuditActionSchema = _enum([
16049
+ "put",
16050
+ "delete",
16051
+ "reveal",
16052
+ "rotate-master-key",
16053
+ "purge-retired-keys",
16054
+ "download-recovery-key",
16055
+ "delete-orphans",
16056
+ "reset",
16057
+ "acknowledge-reset",
16058
+ "initialize"
16059
+ ]);
16060
+ var KeychainAuditEntrySchema = object({
16061
+ id: string(),
16062
+ at: number(),
16063
+ action: KeychainAuditActionSchema,
16064
+ /** `addon:<id>` | `user:<id>` | `system` | `trigger-file`. */
16065
+ actor: string(),
16066
+ ref: string().nullable(),
16067
+ detail: string().nullable()
16068
+ });
16069
+ var KEYCHAIN_RESET_CONFIRMATION = "RESET KEYCHAIN";
16070
+ /**
16071
+ * Secrets the HUB itself holds (owner `system`) that no settings form shows:
16072
+ * `jwt-signing-key` — the session signing key (D797). It is always "in use",
16073
+ * never an orphan; it is generated on a fresh hub and replaced only through
16074
+ * {@link keychainAdminCapability.methods.setSystemSecret}.
16075
+ */
16076
+ var SystemHeldSecretNameSchema = _enum(["jwt-signing-key"]);
16077
+ 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({
16078
+ value: string(),
16079
+ version: number().int()
16080
+ }), {
16081
+ kind: "mutation",
16082
+ auth: "admin",
16083
+ caller: "required"
16084
+ }), method(object({
16085
+ name: SystemHeldSecretNameSchema,
16086
+ value: string().min(16)
16087
+ }), object({
16088
+ ref: string(),
16089
+ version: number().int()
16090
+ }), {
16091
+ kind: "mutation",
16092
+ auth: "admin",
16093
+ caller: "required"
16094
+ }), method(object({ refs: array(string().min(1)).max(1e3) }), object({
16095
+ deleted: array(string()).readonly(),
16096
+ kept: array(object({
16097
+ ref: string(),
16098
+ usage: KeychainSecretUsageSchema
16099
+ })).readonly()
16100
+ }), {
16101
+ kind: "mutation",
16102
+ auth: "admin",
16103
+ caller: "required"
16104
+ }), method(object({}), object({
16105
+ fingerprint: string(),
16106
+ keySource: KeychainKeySourceSchema
16107
+ }), {
16108
+ kind: "mutation",
16109
+ auth: "admin",
16110
+ caller: "required"
16111
+ }), method(object({}), object({ purged: number().int() }), {
16112
+ kind: "mutation",
16113
+ auth: "admin",
16114
+ caller: "required"
16115
+ }), method(object({}), object({
16116
+ key: string(),
16117
+ fingerprint: string(),
16118
+ keySource: KeychainKeySourceSchema
16119
+ }), {
16120
+ kind: "mutation",
16121
+ auth: "admin",
16122
+ caller: "required"
16123
+ }), method(object({ confirm: literal(KEYCHAIN_RESET_CONFIRMATION) }), object({
16124
+ archivedCollection: string().nullable(),
16125
+ archived: number().int()
16126
+ }), {
16127
+ kind: "mutation",
16128
+ auth: "admin",
16129
+ caller: "required"
16130
+ }), method(object({}), object({
16131
+ reset: KeychainResetRecordSchema.nullable(),
16132
+ pendingReentry: array(KeychainSecretMetaSchema).readonly()
16133
+ }), { auth: "admin" }), method(object({}), object({ acknowledged: boolean() }), {
16134
+ kind: "mutation",
16135
+ auth: "admin",
16136
+ caller: "required"
16137
+ });
14347
16138
  method(_void(), object({
14348
16139
  id: string(),
14349
16140
  name: string(),
@@ -15803,7 +17594,11 @@ var DeviceRegisterPayloadSchema = object({
15803
17594
  var DeviceRemovePayloadSchema = object({ deviceId: number() });
15804
17595
  var DevicePersistConfigPayloadSchema = object({
15805
17596
  deviceId: number(),
15806
- data: record(string(), unknown())
17597
+ data: record(string(), unknown()),
17598
+ /** The paths the device's schema declares secret (D783), when the caller
17599
+ * knows them — those values are kept in the keychain, not the blob (D787).
17600
+ * Absent: the paths the device last reported at `registerDevice` apply. */
17601
+ secretConfigPaths: array(string()).optional()
15807
17602
  });
15808
17603
  /** What a migration actually did, per switch. `unreachable` is a first-class
15809
17604
  * answer: a camera that could not be asked is not a camera that was silenced. */
@@ -17406,7 +19201,7 @@ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
17406
19201
  * `login-method` — collection cap through which auth addons contribute
17407
19202
  * their pre-auth login surfaces to the login page. This is the SINGLE,
17408
19203
  * generic mechanism that supersedes the dead `auth.listProviders` reader:
17409
- * every auth addon (OIDC, magic-link, WebAuthn/passkey) registers a
19204
+ * every auth addon (OIDC, WebAuthn/passkey) registers a
17410
19205
  * `login-method` provider and the PUBLIC `auth.listLoginMethods`
17411
19206
  * procedure aggregates them for the unauthenticated login page.
17412
19207
  *
@@ -17414,8 +19209,7 @@ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
17414
19209
  *
17415
19210
  * - `redirect` — a declarative button. The login page renders a generic
17416
19211
  * button that navigates to `startUrl` (an addon-owned HTTP route).
17417
- * Covers OIDC (`/addon/auth-oidc/<id>/start`) and magic-link with
17418
- * ZERO shell-side JS. A future SSO addon plugs in the same way — the
19212
+ * Covers OIDC (`/addon/auth-oidc/<id>/start`) with ZERO shell-side JS. A future SSO addon plugs in the same way — the
17419
19213
  * login page needs NO change.
17420
19214
  *
17421
19215
  * - `widget` — a Module-Federation widget the login page mounts (via
@@ -17434,8 +19228,8 @@ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
17434
19228
  * decision.
17435
19229
  *
17436
19230
  * Every contribution carries a `stage`:
17437
- * - `primary` — shown on the first credentials screen (OIDC /
17438
- * magic-link buttons; a future usernameless passkey).
19231
+ * - `primary` — shown on the first credentials screen (OIDC
19232
+ * buttons; a usernameless passkey).
17439
19233
  * - `second-factor` — shown AFTER the password leg, gated on the
17440
19234
  * returned `factors` (passkey-as-2FA today).
17441
19235
  *
@@ -17462,7 +19256,7 @@ var LoginMethodContributionSchema = discriminatedUnion("kind", [
17462
19256
  * The provider names an external identity a signed-in user can link to
17463
19257
  * their own account (D782): `auth.listLinkableProviders` /
17464
19258
  * `beginExternalLink` offer exactly the redirect methods that set this,
17465
- * whatever their id. Absent / false — a login button only (magic-link).
19259
+ * whatever their id. Absent / false — a login button only.
17466
19260
  */
17467
19261
  linkable: boolean().optional()
17468
19262
  }),
@@ -21339,8 +23133,7 @@ method(object({}), object({ rules: array(NcRuleSchema) }), { auth: "admin" }), m
21339
23133
  * `super_admin` — collapsed onto the single boolean because every
21340
23134
  * non-admin caller is governed by the same scope-check rules; the
21341
23135
  * distinction was only ever used to route role-specific procedures
21342
- * which we no longer have. Agents are admin sessions issued via
21343
- * `createServiceToken`; CLI / webhook integrations are `cst_*` tokens
23136
+ * which we no longer have. CLI / webhook integrations are `cst_*` tokens
21344
23137
  * with `isAdmin: false` + an explicit scope list.
21345
23138
  */
21346
23139
  /** Per-method access flavour. Materialised on every cap method via codegen. */
@@ -22858,8 +24651,23 @@ var RetrainMacroClassSchema = _enum([
22858
24651
  ]);
22859
24652
  /** A subject to learn, or a phantom to unlearn (taught by OMISSION). */
22860
24653
  var RetrainAnnotationKindSchema = _enum(["subject", "model_error"]);
22861
- /** Did a human draw this box, or did the assist propose it? */
22862
- var RetrainAnnotationSourceSchema = _enum(["operator", "assist"]);
24654
+ /**
24655
+ * Where a box came from. A machine-sourced box is a DRAFT on the page until
24656
+ * the operator confirms it; once saved it keeps its source as provenance.
24657
+ *
24658
+ * - `operator` — drawn by hand.
24659
+ * - `assist` — proposed by a detector run on the copy (the camera's own
24660
+ * model, or a larger teacher model).
24661
+ * - `pipeline` — the box the live pipeline actually drew on that frame, read
24662
+ * back from the track store (never a re-run).
24663
+ * - `llm` — proposed by a vision-capable LLM profile.
24664
+ */
24665
+ var RetrainAnnotationSourceSchema = _enum([
24666
+ "operator",
24667
+ "assist",
24668
+ "pipeline",
24669
+ "llm"
24670
+ ]);
22863
24671
  /** Normalised `[0,1]` rectangle against the FULL frame — the canonical form. */
22864
24672
  var RetrainBboxSchema = object({
22865
24673
  x: number(),
@@ -22877,7 +24685,8 @@ var RetrainBboxSchema = object({
22877
24685
  */
22878
24686
  var RetrainAnnotationSchema = object({
22879
24687
  id: string(),
22880
- trackId: string(),
24688
+ /** The frame's track. Absent on a recording still, which has none. */
24689
+ trackId: string().optional(),
22881
24690
  deviceId: number(),
22882
24691
  /** The COPY in retrain storage — never the source track's media key. */
22883
24692
  mediaKey: string(),
@@ -22926,13 +24735,47 @@ var RetrainFrameCandidateSchema = object({
22926
24735
  * fail, whatever became of the original. */
22927
24736
  copied: boolean()
22928
24737
  });
24738
+ /**
24739
+ * One box the live pipeline drew on a copied frame — what a correction starts
24740
+ * from. Derived when the frame is listed, from the track store: the subject
24741
+ * box recorded on the source media row when there is one, else the track
24742
+ * position nearest the frame's capture time. Never stored as an annotation
24743
+ * until the operator confirms it.
24744
+ */
24745
+ var RetrainPipelineBoxSchema = object({
24746
+ /** Normalised `[0,1]` against the full frame. */
24747
+ bbox: RetrainBboxSchema,
24748
+ macroClass: RetrainMacroClassSchema,
24749
+ label: string().optional(),
24750
+ subLabel: string().optional(),
24751
+ /** The detection score of the position used, when it was recorded. */
24752
+ score: number().optional(),
24753
+ /** The root model that produced the track, when it was recorded. */
24754
+ modelId: string().optional(),
24755
+ trackId: string(),
24756
+ /** `subject-box`: recorded on this very frame. `position`: the track's
24757
+ * position nearest the capture time, `deltaMs` away. */
24758
+ basis: _enum(["subject-box", "position"]),
24759
+ deltaMs: number()
24760
+ });
24761
+ /**
24762
+ * Where a retrain frame came from: a TRACK's stored media (copy-on-select),
24763
+ * or the RECORDING at an instant — the frame a model saw nothing in has no
24764
+ * track at all.
24765
+ */
24766
+ var RetrainFrameOriginSchema = _enum(["track", "recording"]);
22929
24767
  /** A frame the dataset OWNS: bytes copied at selection time. */
22930
24768
  var RetrainFrameSchema = object({
22931
24769
  frameId: string(),
22932
24770
  deviceId: number(),
22933
- trackId: string(),
22934
- /** Provenance only. It may already point at nothing — that is expected. */
22935
- sourceMediaId: number().int(),
24771
+ origin: RetrainFrameOriginSchema,
24772
+ /** The track it was copied from. Absent on a recording still. */
24773
+ trackId: string().optional(),
24774
+ /** Provenance only. It may already point at nothing — that is expected.
24775
+ * Absent on a recording still. */
24776
+ sourceMediaId: number().int().optional(),
24777
+ /** A recording still: the playhead instant it was taken at. */
24778
+ epochMs: number().optional(),
22936
24779
  sourceKind: MediaFileKindEnum,
22937
24780
  sizeBytes: number().int(),
22938
24781
  width: number().int(),
@@ -22943,7 +24786,12 @@ var RetrainFrameSchema = object({
22943
24786
  /** The operator's "every subject in this frame is boxed". Detector
22944
24787
  * evaluation keeps only complete frames: an unboxed subject would count as
22945
24788
  * a false positive. */
22946
- complete: boolean()
24789
+ complete: boolean(),
24790
+ /** The boxes the pipeline drew on this frame. Present on list answers;
24791
+ * empty when nothing the track store holds can be placed on it. */
24792
+ pipelineBoxes: array(RetrainPipelineBoxSchema).readonly().optional(),
24793
+ /** The named collections this frame belongs to. Present on list answers. */
24794
+ collectionIds: array(string()).readonly().optional()
22947
24795
  });
22948
24796
  /** Why a copy-on-select could not be honoured — named, never a silent skip. */
22949
24797
  var RetrainCopyRefusalSchema = _enum([
@@ -22974,6 +24822,11 @@ var RetrainFrameListSchema = object({
22974
24822
  var RetrainExportFilterSchema = object({
22975
24823
  deviceIds: array(number()).optional(),
22976
24824
  frameIds: array(string()).max(2e4).optional(),
24825
+ /** Only frames in at least one of these named collections. */
24826
+ collectionIds: array(string()).max(200).optional(),
24827
+ /** Exactly the frames of this dataset version (and its completeOnly). An
24828
+ * unknown id selects nothing. */
24829
+ datasetVersionId: string().optional(),
22977
24830
  batchId: string().optional(),
22978
24831
  /** Only frames the operator marked complete (all subjects boxed). */
22979
24832
  completeOnly: boolean().optional()
@@ -23038,6 +24891,170 @@ var RetrainAssistResultSchema = discriminatedUnion("kind", [object({
23038
24891
  reason: string(),
23039
24892
  detail: string().optional()
23040
24893
  })]);
24894
+ /** A named set over the retrain corpus — membership only, it owns no pixels. */
24895
+ var RetrainCollectionSchema = object({
24896
+ id: string(),
24897
+ name: string(),
24898
+ createdAt: number(),
24899
+ frameCount: number().int()
24900
+ });
24901
+ var RetrainCollectionCreateResultSchema = discriminatedUnion("kind", [object({
24902
+ kind: literal("created"),
24903
+ collection: RetrainCollectionSchema
24904
+ }), object({
24905
+ kind: literal("refused"),
24906
+ reason: _enum(["empty-name", "duplicate-name"])
24907
+ })]);
24908
+ var RetrainCollectionRenameResultSchema = discriminatedUnion("kind", [object({
24909
+ kind: literal("renamed"),
24910
+ collection: RetrainCollectionSchema
24911
+ }), object({
24912
+ kind: literal("refused"),
24913
+ reason: _enum([
24914
+ "empty-name",
24915
+ "duplicate-name",
24916
+ "unknown-collection"
24917
+ ])
24918
+ })]);
24919
+ /**
24920
+ * The outcome of adding the frame at a recording instant. Every refusal is
24921
+ * named: `still-unavailable` (not recording, a gap, or an undecodable frame —
24922
+ * `detail` says which), `still-busy` (the recorder is at its decode bound; try
24923
+ * again), `unreadable-image`, `write-failed`, `unknown-collection`.
24924
+ */
24925
+ var AddRetrainFrameFromRecordingResultSchema = discriminatedUnion("kind", [object({
24926
+ kind: literal("added"),
24927
+ collectionId: string(),
24928
+ frame: RetrainFrameSchema,
24929
+ /** The moment was already in the dataset; nothing was decoded. */
24930
+ reused: boolean()
24931
+ }), object({
24932
+ kind: literal("refused"),
24933
+ reason: _enum([
24934
+ "unknown-collection",
24935
+ "still-unavailable",
24936
+ "still-busy",
24937
+ "unreadable-image",
24938
+ "write-failed"
24939
+ ]),
24940
+ detail: string().optional()
24941
+ })]);
24942
+ /** A vision LLM profile the AI assist may use, and where it sends the frame. */
24943
+ var RetrainAssistProfileSchema = object({
24944
+ id: string(),
24945
+ name: string(),
24946
+ model: string(),
24947
+ kind: string(),
24948
+ /** `true` when the frame would leave the house (a cloud vendor, or an
24949
+ * endpoint that is not on the local network). The page confirms each such
24950
+ * run, and the provider refuses one without `allowCloud`. */
24951
+ leavesHouse: boolean()
24952
+ });
24953
+ /** A box the AI assist proposed: a draft, plus the model's own reason. */
24954
+ var RetrainLlmProposalSchema = RetrainAnnotationDraftSchema.extend({ reason: string() });
24955
+ /** What the AI assist said about a box that was already on the canvas. */
24956
+ var RetrainLlmReviewSchema = object({
24957
+ /** The `ref` the page sent the box under. */
24958
+ ref: string(),
24959
+ verdict: _enum([
24960
+ "confirmed",
24961
+ "wrong-class",
24962
+ "not-an-object",
24963
+ "uncertain"
24964
+ ]),
24965
+ suggestedClass: RetrainMacroClassSchema.optional(),
24966
+ reason: string()
24967
+ });
24968
+ /**
24969
+ * The AI assist's answer. `proposed` carries drafts (`source: 'llm'`, the
24970
+ * model and its confidence) and reviews; items the model got wrong (a box off
24971
+ * the frame, an unasked class, an unknown ref) are dropped and counted in
24972
+ * `rejected`. A whole answer that is not the schema is `malformed-answer`.
24973
+ */
24974
+ var RetrainLlmAssistResultSchema = discriminatedUnion("kind", [object({
24975
+ kind: literal("proposed"),
24976
+ profileId: string(),
24977
+ model: string(),
24978
+ /** The frame was sent outside the house for this answer. */
24979
+ leftHouse: boolean(),
24980
+ proposals: array(RetrainLlmProposalSchema).readonly(),
24981
+ reviews: array(RetrainLlmReviewSchema).readonly(),
24982
+ rejected: number().int()
24983
+ }), object({
24984
+ kind: literal("refused"),
24985
+ reason: _enum([
24986
+ "unknown-frame",
24987
+ "unreadable-frame",
24988
+ "unknown-profile",
24989
+ "profile-disabled",
24990
+ "no-vision",
24991
+ "cloud-not-confirmed",
24992
+ "llm-error",
24993
+ "malformed-answer"
24994
+ ]),
24995
+ detail: string().optional()
24996
+ })]);
24997
+ /** What a dataset version is cut from. Every field narrows. */
24998
+ var RetrainDatasetSelectionSchema = object({
24999
+ deviceIds: array(number()).readonly().optional(),
25000
+ collectionIds: array(string()).max(200).readonly().optional(),
25001
+ frameIds: array(string()).max(2e4).readonly().optional()
25002
+ });
25003
+ /** The counts a dataset is judged by. */
25004
+ var RetrainDatasetStatsSchema = object({
25005
+ frames: number().int(),
25006
+ completeFrames: number().int(),
25007
+ /** `completeFrames / frames`, 0..1. */
25008
+ completeness: number(),
25009
+ /** Boxes to learn (model errors excluded). */
25010
+ subjects: number().int(),
25011
+ modelErrors: number().int(),
25012
+ /** Complete frames with no subject. */
25013
+ hardNegatives: number().int(),
25014
+ /** Subjects per class × camera × day/night. */
25015
+ cells: array(object({
25016
+ macroClass: string(),
25017
+ deviceId: number(),
25018
+ lighting: _enum([
25019
+ "day",
25020
+ "night",
25021
+ "unknown"
25022
+ ]),
25023
+ subjects: number().int(),
25024
+ frames: number().int()
25025
+ })).readonly(),
25026
+ cameras: array(object({
25027
+ deviceId: number(),
25028
+ frames: number().int(),
25029
+ completeFrames: number().int()
25030
+ })).readonly()
25031
+ });
25032
+ /** An immutable dataset version, without its frame list. */
25033
+ var RetrainDatasetVersionSchema = object({
25034
+ id: string(),
25035
+ name: string(),
25036
+ createdAt: number(),
25037
+ selection: RetrainDatasetSelectionSchema,
25038
+ layout: RetrainExportLayoutSchema,
25039
+ completeOnly: boolean(),
25040
+ frameCount: number().int(),
25041
+ /** sha256 of what the frames taught when the version was frozen. */
25042
+ annotationHash: string(),
25043
+ /** The export manifest schema the version was cut under. */
25044
+ manifestSchema: string(),
25045
+ stats: RetrainDatasetStatsSchema
25046
+ });
25047
+ var CreateRetrainDatasetVersionResultSchema = discriminatedUnion("kind", [object({
25048
+ kind: literal("created"),
25049
+ version: RetrainDatasetVersionSchema
25050
+ }), object({
25051
+ kind: literal("refused"),
25052
+ reason: _enum([
25053
+ "empty-name",
25054
+ "duplicate-name",
25055
+ "no-frames"
25056
+ ])
25057
+ })]);
23041
25058
  /** The outcome of a lifecycle move owned by the retrain page. */
23042
25059
  var RetrainTransitionResultSchema = object({
23043
25060
  trackId: string(),
@@ -23755,7 +25772,7 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
23755
25772
  auth: "admin"
23756
25773
  }), method(object({
23757
25774
  deviceId: number(),
23758
- trackId: string(),
25775
+ trackId: string().optional(),
23759
25776
  frameId: string()
23760
25777
  }), object({
23761
25778
  removed: boolean(),
@@ -23772,7 +25789,8 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
23772
25789
  auth: "admin"
23773
25790
  }), method(object({
23774
25791
  deviceId: number(),
23775
- trackId: string(),
25792
+ /** The frame's track, when it has one — checked against the frame. */
25793
+ trackId: string().optional(),
23776
25794
  frameId: string(),
23777
25795
  subject: RetrainAssistSubjectSchema,
23778
25796
  /** Which node runs it. Absent ⇒ wherever an unowned call lands. */
@@ -23780,12 +25798,16 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
23780
25798
  }), RetrainAssistResultSchema, {
23781
25799
  kind: "mutation",
23782
25800
  auth: "admin"
23783
- }), method(object({ trackId: string() }), array(RetrainAnnotationSchema).readonly(), {
25801
+ }), method(object({
25802
+ trackId: string().optional(),
25803
+ frameIds: array(string()).max(2e3).optional()
25804
+ }), array(RetrainAnnotationSchema).readonly(), {
23784
25805
  kind: "query",
23785
25806
  auth: "admin"
23786
25807
  }), method(object({
23787
25808
  deviceId: number(),
23788
- trackId: string(),
25809
+ /** The frame's track, when it has one — checked against the frame. */
25810
+ trackId: string().optional(),
23789
25811
  frameId: string(),
23790
25812
  annotations: array(RetrainAnnotationDraftSchema)
23791
25813
  }), array(RetrainAnnotationSchema).readonly(), {
@@ -23808,7 +25830,7 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
23808
25830
  auth: "admin"
23809
25831
  }), method(object({
23810
25832
  deviceId: number(),
23811
- trackId: string(),
25833
+ trackId: string().optional(),
23812
25834
  frameId: string(),
23813
25835
  complete: boolean()
23814
25836
  }), RetrainFrameSchema, {
@@ -23822,6 +25844,115 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
23822
25844
  kind: "mutation",
23823
25845
  auth: "admin",
23824
25846
  timeoutMs: 60 * 6e4
25847
+ }), method(object({
25848
+ filter: RetrainExportFilterSchema,
25849
+ layout: RetrainExportLayoutSchema
25850
+ }), object({
25851
+ ticket: PeerBytesTicketSchema,
25852
+ frames: number().int(),
25853
+ annotations: number().int()
25854
+ }), {
25855
+ kind: "mutation",
25856
+ auth: "admin",
25857
+ timeoutMs: 12e4
25858
+ }), method(object({
25859
+ selection: RetrainDatasetSelectionSchema,
25860
+ completeOnly: boolean().optional()
25861
+ }), RetrainDatasetStatsSchema, {
25862
+ kind: "query",
25863
+ auth: "admin"
25864
+ }), method(object({
25865
+ name: string().max(120),
25866
+ selection: RetrainDatasetSelectionSchema,
25867
+ layout: RetrainExportLayoutSchema,
25868
+ completeOnly: boolean()
25869
+ }), CreateRetrainDatasetVersionResultSchema, {
25870
+ kind: "mutation",
25871
+ auth: "admin",
25872
+ timeoutMs: 12e4
25873
+ }), method(object({}), array(RetrainDatasetVersionSchema).readonly(), {
25874
+ kind: "query",
25875
+ auth: "admin"
25876
+ }), method(object({ id: string() }), object({ deleted: boolean() }), {
25877
+ kind: "mutation",
25878
+ auth: "admin"
25879
+ }), method(object({ id: string() }), object({
25880
+ found: boolean(),
25881
+ annotationHash: string(),
25882
+ matches: boolean(),
25883
+ missingFrames: number().int()
25884
+ }), {
25885
+ kind: "query",
25886
+ auth: "admin",
25887
+ timeoutMs: 12e4
25888
+ }), method(object({}), array(RetrainAssistProfileSchema).readonly(), {
25889
+ kind: "query",
25890
+ auth: "admin"
25891
+ }), method(object({
25892
+ deviceId: number(),
25893
+ trackId: string().optional(),
25894
+ frameId: string(),
25895
+ profileId: string(),
25896
+ classes: array(RetrainMacroClassSchema).min(1),
25897
+ boxes: array(object({
25898
+ ref: string(),
25899
+ bbox: RetrainBboxSchema,
25900
+ macroClass: RetrainMacroClassSchema,
25901
+ label: string().optional()
25902
+ })).max(50),
25903
+ allowCloud: boolean()
25904
+ }), RetrainLlmAssistResultSchema, {
25905
+ kind: "mutation",
25906
+ auth: "admin",
25907
+ timeoutMs: 18e4
25908
+ }), method(object({ name: string().max(120) }), RetrainCollectionCreateResultSchema, {
25909
+ kind: "mutation",
25910
+ auth: "admin"
25911
+ }), method(object({}), array(RetrainCollectionSchema).readonly(), {
25912
+ kind: "query",
25913
+ auth: "admin"
25914
+ }), method(object({
25915
+ id: string(),
25916
+ name: string().max(120)
25917
+ }), RetrainCollectionRenameResultSchema, {
25918
+ kind: "mutation",
25919
+ auth: "admin"
25920
+ }), method(object({ id: string() }), object({
25921
+ deleted: boolean(),
25922
+ removedFrames: number().int()
25923
+ }), {
25924
+ kind: "mutation",
25925
+ auth: "admin"
25926
+ }), method(object({
25927
+ collectionId: string(),
25928
+ deviceId: number(),
25929
+ epochMs: number()
25930
+ }), AddRetrainFrameFromRecordingResultSchema, {
25931
+ kind: "mutation",
25932
+ auth: "admin",
25933
+ timeoutMs: 6e4
25934
+ }), method(object({
25935
+ collectionId: string(),
25936
+ frameIds: array(string()).min(1).max(500)
25937
+ }), object({
25938
+ added: number().int(),
25939
+ alreadyMember: number().int(),
25940
+ unknownFrameIds: array(string()).readonly()
25941
+ }), {
25942
+ kind: "mutation",
25943
+ auth: "admin"
25944
+ }), method(object({
25945
+ collectionId: string(),
25946
+ frameId: string()
25947
+ }), object({
25948
+ removed: boolean(),
25949
+ deletedFrame: boolean()
25950
+ }), {
25951
+ kind: "mutation",
25952
+ auth: "admin"
25953
+ }), method(object({ collectionId: string() }), array(RetrainFrameSchema).readonly(), {
25954
+ kind: "query",
25955
+ auth: "admin"
23825
25956
  }), method(object({
23826
25957
  /** Which of the three event tables owns the row. */
23827
25958
  ownerType: EventOwnerTypeSchema,
@@ -24445,13 +26576,31 @@ var RecommendationReasonSchema = discriminatedUnion("kind", [
24445
26576
  object({
24446
26577
  kind: literal("no-family-build"),
24447
26578
  format: ModelFormatSchema$1
26579
+ }),
26580
+ object({
26581
+ kind: literal("kept-custom-pin"),
26582
+ modelId: string(),
26583
+ deviceKey: string()
24448
26584
  })
24449
26585
  ]);
26586
+ /** Why a device is left exactly as it is, whatever the plan would pick (D786). */
26587
+ var KeptReasonSchema = _enum(["custom-pin"]);
26588
+ /**
26589
+ * Where a choice's latency came from (D791): this node's own benchmark
26590
+ * result, or the hardware-class table. Measured on the node beats the table.
26591
+ */
26592
+ var LatencySourceSchema = discriminatedUnion("kind", [object({ kind: literal("table") }), object({
26593
+ kind: literal("node-benchmark"),
26594
+ resultId: string(),
26595
+ measuredAtMs: number()
26596
+ })]);
24450
26597
  var DeviceModelChoiceSchema = object({
24451
26598
  modelId: string(),
24452
26599
  p50Ms: number(),
24453
26600
  fps: number(),
24454
26601
  measured: boolean(),
26602
+ /** Absent on a plan from before D791 — read as the table. */
26603
+ source: LatencySourceSchema.optional(),
24455
26604
  /** Parallel sessions at the camera rate with the headroom kept free: ⌊fps × (1 − headroom) / camera fps⌋. */
24456
26605
  capacitySessions: number(),
24457
26606
  personRecall: number()
@@ -24462,6 +26611,8 @@ var DeviceRecommendationSchema = object({
24462
26611
  enabled: boolean(),
24463
26612
  available: boolean(),
24464
26613
  chosen: DeviceModelChoiceSchema.nullable(),
26614
+ /** Present when the device is kept as is: Apply writes nothing on it. */
26615
+ kept: KeptReasonSchema.optional(),
24465
26616
  reasons: array(RecommendationReasonSchema).readonly()
24466
26617
  });
24467
26618
  var NodeRecommendationSchema = object({
@@ -24515,6 +26666,17 @@ var AutoTuneWarningSchema = discriminatedUnion("kind", [
24515
26666
  kind: literal("coral-enabled"),
24516
26667
  nodeId: string(),
24517
26668
  deviceKey: string()
26669
+ }),
26670
+ object({
26671
+ kind: literal("custom-pin-kept"),
26672
+ nodeId: string(),
26673
+ deviceKey: string().nullable(),
26674
+ deviceId: number().nullable(),
26675
+ modelId: string()
26676
+ }),
26677
+ object({
26678
+ kind: literal("custom-registry-unreadable"),
26679
+ error: string()
24518
26680
  })
24519
26681
  ]);
24520
26682
  var AutoTuneOptionsSchema = object({
@@ -24693,13 +26855,14 @@ var SuggestSharesResultSchema = object({
24693
26855
  nodes: array(SuggestedNodeShareSchema).readonly()
24694
26856
  });
24695
26857
  /**
24696
- * Where the node and device shares come from (D750, D755).
24697
- * - `hardware` (default) — computed by the system from each node's static
24698
- * capacity (its accelerators at their Auto tune models, from the measured
24699
- * latency table), recomputed whenever a node or device joins, leaves, is
24700
- * switched on or off, or changes model. No load input.
24701
- * - `benchmark` — the same, from each node's measured capacity (node
24702
- * benchmark results); a node without results falls back to `hardware`.
26858
+ * Where the node and device shares come from (D750, D755, D791).
26859
+ * - `benchmark` (default since D791) — each node's capacity as its own node
26860
+ * benchmark measured it; a node without fresh results is sized from
26861
+ * `hardware` and says so. Measured on the node beats the table.
26862
+ * - `hardware` — computed from each node's static capacity only (its
26863
+ * accelerators at their Auto tune models, from the latency table).
26864
+ * Both are recomputed whenever a node or device joins, leaves, is switched
26865
+ * on or off, changes model, or a benchmark result is written. No load input.
24703
26866
  * - `manual` — the operator's stored sliders.
24704
26867
  * Either way a node or device that cannot take sessions gives its share to
24705
26868
  * the others in proportion; the stored values are never rewritten for that.
@@ -24748,6 +26911,362 @@ var EffectiveSharesSchema = object({
24748
26911
  nodeWeights: record(string(), number()),
24749
26912
  deviceWeights: record(string(), record(string(), number()))
24750
26913
  });
26914
+ /**
26915
+ * Wire shapes of the node benchmark (D791): the operator's plan, the
26916
+ * preflight the confirmation shows, the run the orchestrator owns, what the
26917
+ * measuring runner reports, and the result rows Auto tune and the automatic
26918
+ * shares read.
26919
+ *
26920
+ * ONE node at a time, owned by the pipeline orchestrator. While a run is
26921
+ * active the cluster is in BENCHMARK MODE for that node: it is not a
26922
+ * detection candidate, camera pins naming it are ignored so its sessions move
26923
+ * elsewhere, and both come back when the mode ends — after a crash or a hub
26924
+ * restart too (a persisted manifest, reconciled against the registry).
26925
+ *
26926
+ * Two measurements, both on the node, driven by its own runner (frames never
26927
+ * cross a process at frame rate, D9):
26928
+ * - `device` — one accelerator × one candidate detector, root only, open
26929
+ * loop: how many streams at the camera rate it carries inside the frame
26930
+ * interval;
26931
+ * - `pipeline` — the chosen detector plus the operator's detail steps
26932
+ * (faces, plates, classifiers, CLIP…), on varied frames from the bench
26933
+ * clip: how many parallel sessions the node carries before latency, drops,
26934
+ * CPU, RAM or the event loop give out.
26935
+ */
26936
+ /** Defaults and bounds, one place. */
26937
+ var NODE_BENCHMARK_DEFAULTS = {
26938
+ fpsPerStream: 10,
26939
+ budgetMinutes: 45,
26940
+ minBudgetMinutes: 10,
26941
+ maxBudgetMinutes: 120,
26942
+ /** A result older than this no longer beats the table. */
26943
+ staleAfterDays: 30,
26944
+ /** Warm-in per ramp step (not accounted). */
26945
+ settleSec: 5,
26946
+ /** Accounted window per ramp step. */
26947
+ measureSec: 20,
26948
+ /** Longest the drain may take before the run is refused. */
26949
+ drainTimeoutSec: 120,
26950
+ /** Candidate models per device in one run. */
26951
+ maxModelsPerDevice: 6
26952
+ };
26953
+ /** The two measurements a run can make. */
26954
+ var NodeBenchmarkPhaseSchema = _enum(["device", "pipeline"]);
26955
+ var NodeBenchmarkDevicePlanSchema = object({
26956
+ /** `<backend>:<device>` — `openvino:npu`, `coreml:all`, `cpu`. */
26957
+ deviceKey: string().min(1),
26958
+ /**
26959
+ * Root detector candidates for the `device` measurement, in the order
26960
+ * measured. The FIRST is the one the `pipeline` measurement runs.
26961
+ */
26962
+ modelIds: array(string().min(1)).min(1).max(NODE_BENCHMARK_DEFAULTS.maxModelsPerDevice)
26963
+ });
26964
+ /** What the operator confirmed. */
26965
+ var NodeBenchmarkPlanSchema = object({
26966
+ nodeId: string().min(1),
26967
+ devices: array(NodeBenchmarkDevicePlanSchema).min(1),
26968
+ /** Which measurements run. At least one. */
26969
+ phases: array(NodeBenchmarkPhaseSchema).min(1).default(["device", "pipeline"]),
26970
+ /**
26971
+ * Detail steps (catalog step ids under the root: faces, plates,
26972
+ * classifiers, CLIP…) the `pipeline` measurement enables. The root
26973
+ * detector always runs.
26974
+ */
26975
+ steps: array(string().min(1)).default([]),
26976
+ /** Offered rate of one stream / session. */
26977
+ fpsPerStream: number().int().min(1).max(30).default(NODE_BENCHMARK_DEFAULTS.fpsPerStream),
26978
+ /** Hard deadline: the mode ends and the cluster is restored when it passes. */
26979
+ budgetMinutes: number().int().min(NODE_BENCHMARK_DEFAULTS.minBudgetMinutes).max(NODE_BENCHMARK_DEFAULTS.maxBudgetMinutes).default(NODE_BENCHMARK_DEFAULTS.budgetMinutes),
26980
+ /** Keep the models the run downloaded (default: delete what was not installed before). */
26981
+ keepDownloadedModels: boolean().default(false),
26982
+ /** Start although the other nodes' capacity does not cover the sessions running now. */
26983
+ acceptInsufficientHeadroom: boolean().default(false)
26984
+ });
26985
+ var NodeBenchmarkRefusalSchema = object({
26986
+ kind: _enum([
26987
+ "benchmark-active",
26988
+ "node-offline",
26989
+ "unknown-device",
26990
+ "no-phase",
26991
+ "insufficient-headroom"
26992
+ ]),
26993
+ detail: string(),
26994
+ overridable: boolean()
26995
+ });
26996
+ /** A camera whose detection leaves the node for the run. */
26997
+ var NodeBenchmarkMovingCameraSchema = object({
26998
+ deviceId: number(),
26999
+ /** Placed on the node now (a standing attach or a running session). */
27000
+ placedOnNode: boolean(),
27001
+ /** A node pin naming this node, ignored for the run. */
27002
+ pinnedToNode: boolean()
27003
+ });
27004
+ /** A camera that cannot leave: no other node can obtain its frames. */
27005
+ var NodeBenchmarkStayingCameraSchema = object({
27006
+ deviceId: number(),
27007
+ reason: literal("only-frame-source")
27008
+ });
27009
+ var NodeBenchmarkPreflightSchema = object({
27010
+ nodeId: string(),
27011
+ online: boolean(),
27012
+ moving: array(NodeBenchmarkMovingCameraSchema).readonly(),
27013
+ /** Keep running on the node during the run; the result is flagged contaminated. */
27014
+ staying: array(NodeBenchmarkStayingCameraSchema).readonly(),
27015
+ estimatedDurationMs: number(),
27016
+ /** The run ends and the cluster is restored at the latest after this long. */
27017
+ budgetMs: number(),
27018
+ phases: array(NodeBenchmarkPhaseSchema).readonly(),
27019
+ steps: array(string()).readonly(),
27020
+ devices: array(NodeBenchmarkDevicePlanSchema).readonly(),
27021
+ /** Parallel sessions the cluster runs now, and what the other nodes can carry. */
27022
+ headroom: object({
27023
+ sessionsNow: number(),
27024
+ otherNodesCapacitySessions: number().nullable()
27025
+ }),
27026
+ refusals: array(NodeBenchmarkRefusalSchema).readonly(),
27027
+ canStart: boolean()
27028
+ });
27029
+ /** Where the measuring runner is. */
27030
+ var NodeBenchProgressSchema = object({
27031
+ phase: _enum([
27032
+ "preparing",
27033
+ "device",
27034
+ "pipeline",
27035
+ "cleanup"
27036
+ ]),
27037
+ deviceKey: string().nullable(),
27038
+ modelId: string().nullable(),
27039
+ /** Streams (device) or sessions (pipeline) of the step running now. */
27040
+ load: number().nullable(),
27041
+ cellsDone: number(),
27042
+ cellsTotal: number(),
27043
+ message: string()
27044
+ });
27045
+ /** What limited a ramp. `none` = the ramp ran out of steps still passing. */
27046
+ var NodeBenchLimitSchema = _enum([
27047
+ "p95",
27048
+ "drops",
27049
+ "errors",
27050
+ "stall",
27051
+ "cpu",
27052
+ "ram",
27053
+ "none"
27054
+ ]);
27055
+ var NodeBenchRampStepSchema = object({
27056
+ load: number(),
27057
+ pass: boolean(),
27058
+ p95Ms: number(),
27059
+ dropRatio: number(),
27060
+ /** Completed frames per second over the accounted window. */
27061
+ fps: number(),
27062
+ cpuPct: number().nullable(),
27063
+ ramFreePct: number().nullable(),
27064
+ failReasons: array(string()).readonly()
27065
+ });
27066
+ var NodeBenchCellSchema = discriminatedUnion("phase", [object({
27067
+ phase: literal("device"),
27068
+ deviceKey: string(),
27069
+ modelId: string(),
27070
+ /** Single-stream latency (the K = 1 step). */
27071
+ p50Ms: number(),
27072
+ p95Ms: number(),
27073
+ p99Ms: number(),
27074
+ /** Frames per second sustained at the last passing step. */
27075
+ fps: number(),
27076
+ /** Streams at the camera rate the device carried inside the frame interval; 0 = not even one. */
27077
+ kMax: number(),
27078
+ limitedBy: NodeBenchLimitSchema,
27079
+ /** First call (model load + warm-up). */
27080
+ warmupMs: number(),
27081
+ ramp: array(NodeBenchRampStepSchema).readonly()
27082
+ }), object({
27083
+ phase: literal("pipeline"),
27084
+ deviceKey: string(),
27085
+ modelId: string(),
27086
+ steps: array(string()).readonly(),
27087
+ /** Parallel sessions at the camera rate the node carried; 0 = not even one. */
27088
+ maxSessions: number(),
27089
+ limitedBy: NodeBenchLimitSchema,
27090
+ /** Detail steps that produced at least one result on the clip — a step that never fired measured nothing. */
27091
+ stepsFired: array(string()).readonly(),
27092
+ warmupMs: number(),
27093
+ ramp: array(NodeBenchRampStepSchema).readonly()
27094
+ })]);
27095
+ /**
27096
+ * What a result was measured ON. A result whose fingerprint no longer matches
27097
+ * the node no longer beats the table.
27098
+ */
27099
+ var NodeBenchFingerprintSchema = object({
27100
+ pipelineVersion: string().nullable(),
27101
+ cpuModel: string().nullable(),
27102
+ ramGb: number().nullable(),
27103
+ os: string().nullable(),
27104
+ /** Per device: the pool the cells ran on (runtime + tuning). */
27105
+ pools: record(string(), object({
27106
+ runtime: string(),
27107
+ numWorkers: number(),
27108
+ concurrency: number(),
27109
+ batchMode: string()
27110
+ })).default({})
27111
+ });
27112
+ /** The frames the run used. */
27113
+ var NodeBenchClipSchema = object({
27114
+ /** `camstack-bench-v1` or `reference-images` (the fallback when the clip is not reachable). */
27115
+ id: string(),
27116
+ revision: string().nullable(),
27117
+ frames: number(),
27118
+ width: number(),
27119
+ height: number()
27120
+ });
27121
+ var NodeBenchRunnerInputSchema = object({
27122
+ runId: string().min(1),
27123
+ devices: array(NodeBenchmarkDevicePlanSchema).min(1),
27124
+ phases: array(NodeBenchmarkPhaseSchema).min(1),
27125
+ /** The full detail step tree root for the `pipeline` measurement is built on the node from these ids. */
27126
+ steps: array(string()).default([]),
27127
+ fpsPerStream: number().int().min(1).max(30),
27128
+ /** The runner stops on its own past this instant, whatever the hub does. */
27129
+ deadlineAtMs: number(),
27130
+ settleSec: number().min(0).max(60).default(NODE_BENCHMARK_DEFAULTS.settleSec),
27131
+ measureSec: number().min(2).max(300).default(NODE_BENCHMARK_DEFAULTS.measureSec),
27132
+ keepDownloadedModels: boolean().default(false)
27133
+ });
27134
+ var NodeBenchRunnerStateSchema = _enum([
27135
+ "running",
27136
+ "done",
27137
+ "failed",
27138
+ "aborted"
27139
+ ]);
27140
+ var NodeBenchRunnerStatusSchema = object({
27141
+ runId: string(),
27142
+ nodeId: string(),
27143
+ state: NodeBenchRunnerStateSchema,
27144
+ progress: NodeBenchProgressSchema.nullable(),
27145
+ /** Every finished cell so far — a run stopped half way keeps what it measured. */
27146
+ cells: array(NodeBenchCellSchema).readonly(),
27147
+ fingerprint: NodeBenchFingerprintSchema.nullable(),
27148
+ clip: NodeBenchClipSchema.nullable(),
27149
+ /** Cameras seen running on the node during the run (they share its pools). */
27150
+ activeCameraIds: array(number()).readonly(),
27151
+ /** Models the run downloaded and then deleted (not installed before). */
27152
+ deletedModels: array(string()).readonly(),
27153
+ error: string().nullable(),
27154
+ startedAtMs: number(),
27155
+ finishedAtMs: number().nullable()
27156
+ });
27157
+ var NodeBenchmarkStateSchema = _enum([
27158
+ "draining",
27159
+ "measuring",
27160
+ "restoring",
27161
+ "done",
27162
+ "failed",
27163
+ "aborted"
27164
+ ]);
27165
+ /** Why a run ended. */
27166
+ var NodeBenchmarkEndReasonSchema = _enum([
27167
+ "completed",
27168
+ "operator-abort",
27169
+ "deadline",
27170
+ "node-lost",
27171
+ "runner-lost",
27172
+ "hub-restart",
27173
+ "drain-timeout",
27174
+ "failed"
27175
+ ]);
27176
+ var NodeBenchmarkRunSchema = object({
27177
+ runId: string(),
27178
+ nodeId: string(),
27179
+ state: NodeBenchmarkStateSchema,
27180
+ plan: NodeBenchmarkPlanSchema,
27181
+ startedAtMs: number(),
27182
+ deadlineAtMs: number(),
27183
+ finishedAtMs: number().nullable(),
27184
+ endReason: NodeBenchmarkEndReasonSchema.nullable(),
27185
+ error: string().nullable(),
27186
+ /** Cameras moved off the node for the run. */
27187
+ moved: array(number()).readonly(),
27188
+ /** Cameras that stayed (their only frame source is the node). */
27189
+ staying: array(number()).readonly(),
27190
+ /** Something else ran on the node's pools during the run. */
27191
+ contaminated: boolean(),
27192
+ progress: NodeBenchProgressSchema.nullable(),
27193
+ resultIds: array(string()).readonly()
27194
+ });
27195
+ /** `getNodeBenchmarkStatus`: the active run (or the last one), and whether benchmark mode is on. */
27196
+ var NodeBenchmarkStatusSchema = object({
27197
+ /** The node the cluster is in benchmark mode for; null = none. */
27198
+ modeNodeId: string().nullable(),
27199
+ run: NodeBenchmarkRunSchema.nullable()
27200
+ });
27201
+ /**
27202
+ * One stored measurement — the only authority Auto tune and the automatic
27203
+ * shares read measured capacity from. Written by the orchestrator when a run
27204
+ * ends, never by anyone else.
27205
+ */
27206
+ var NodeBenchmarkResultSchema = object({
27207
+ id: string(),
27208
+ runId: string(),
27209
+ nodeId: string(),
27210
+ cell: NodeBenchCellSchema,
27211
+ fpsPerStream: number(),
27212
+ fingerprint: NodeBenchFingerprintSchema.nullable(),
27213
+ clip: NodeBenchClipSchema.nullable(),
27214
+ /** Other work shared the node's pools (a camera that could not move, or the hub's own duties). */
27215
+ contaminated: boolean(),
27216
+ stayingCameras: array(number()).readonly(),
27217
+ /** The run ended early; the cell itself completed. */
27218
+ partialRun: boolean(),
27219
+ measuredAtMs: number()
27220
+ });
27221
+ var ListNodeBenchmarkResultsInputSchema = object({
27222
+ nodeId: string().optional(),
27223
+ deviceKey: string().optional()
27224
+ });
27225
+ /** A result with its standing today: does it still beat the table? */
27226
+ var NodeBenchmarkResultViewSchema = NodeBenchmarkResultSchema.extend({
27227
+ /** `fresh` beats the table; `stale` falls back to it; `superseded` = a newer row covers the same cell. */
27228
+ standing: _enum([
27229
+ "fresh",
27230
+ "stale",
27231
+ "superseded"
27232
+ ]),
27233
+ staleWhy: _enum([
27234
+ "age",
27235
+ "runtime",
27236
+ "pool-tuning"
27237
+ ]).nullable()
27238
+ });
27239
+ object({
27240
+ runId: string(),
27241
+ nodeId: string(),
27242
+ startedAtMs: number(),
27243
+ deadlineAtMs: number(),
27244
+ plan: NodeBenchmarkPlanSchema,
27245
+ moved: array(number()).readonly(),
27246
+ staying: array(number()).readonly()
27247
+ });
27248
+ /** Candidate detectors per device, for the plan editor. */
27249
+ var NodeBenchmarkCandidatesSchema = object({
27250
+ nodeId: string(),
27251
+ reachable: boolean(),
27252
+ devices: array(object({
27253
+ deviceKey: string(),
27254
+ enabled: boolean(),
27255
+ available: boolean(),
27256
+ /** Ordered: what Auto tune would pick first, then the rest of the family by accuracy. */
27257
+ suggested: array(string()).readonly(),
27258
+ /** Every root detector the device has a build for. */
27259
+ all: array(string()).readonly(),
27260
+ /** The model the device runs now, when pinned. */
27261
+ currentModelId: string().nullable()
27262
+ })).readonly(),
27263
+ /** Detail steps the node's catalog offers under the root (for the `pipeline` measurement). */
27264
+ steps: array(object({
27265
+ id: string(),
27266
+ name: string(),
27267
+ slot: string()
27268
+ })).readonly()
27269
+ });
24751
27270
  object({
24752
27271
  activeCameras: number(),
24753
27272
  throttledCameras: number(),
@@ -25876,7 +28395,16 @@ method(RunnerCameraConfigSchema, object({ success: literal(true) }), { kind: "mu
25876
28395
  }), ParkedTrackFrameSchema.nullable()), method(object({
25877
28396
  deviceId: number(),
25878
28397
  trackId: string()
25879
- }), object({ released: number().int().nonnegative() }), { kind: "mutation" });
28398
+ }), object({ released: number().int().nonnegative() }), { kind: "mutation" }), method(NodeBenchRunnerInputSchema, object({
28399
+ accepted: literal(true),
28400
+ runId: string()
28401
+ }), {
28402
+ kind: "mutation",
28403
+ auth: "admin"
28404
+ }), method(object({ runId: string() }), NodeBenchRunnerStatusSchema.nullable(), { auth: "admin" }), method(object({ runId: string() }), object({ aborted: boolean() }), {
28405
+ kind: "mutation",
28406
+ auth: "admin"
28407
+ });
25880
28408
  var CameraPipelineConfigSchema = object({
25881
28409
  engine: PipelineEngineChoiceSchema.optional(),
25882
28410
  steps: array(PipelineStepInputSchema).readonly(),
@@ -26515,6 +29043,21 @@ method(object({
26515
29043
  }), method(PlacementStatsInputSchema, PlacementStatsSchema, { auth: "admin" }), method(SuggestSharesInputSchema, SuggestSharesResultSchema, { auth: "admin" }), method(_void(), EffectiveSharesSchema, { auth: "admin" }), method(SetShareSourceInputSchema, object({ success: literal(true) }), {
26516
29044
  kind: "mutation",
26517
29045
  auth: "admin"
29046
+ }), method(NodeBenchmarkPlanSchema, NodeBenchmarkPreflightSchema, { auth: "admin" }), method(NodeBenchmarkPlanSchema, discriminatedUnion("kind", [object({
29047
+ kind: literal("started"),
29048
+ runId: string()
29049
+ }), object({
29050
+ kind: literal("refused"),
29051
+ preflight: NodeBenchmarkPreflightSchema
29052
+ })]), {
29053
+ kind: "mutation",
29054
+ auth: "admin"
29055
+ }), method(_void(), NodeBenchmarkStatusSchema, { auth: "admin" }), method(object({ runId: string() }), object({ aborted: boolean() }), {
29056
+ kind: "mutation",
29057
+ auth: "admin"
29058
+ }), method(object({ nodeId: string() }), NodeBenchmarkCandidatesSchema, { auth: "admin" }), method(ListNodeBenchmarkResultsInputSchema, array(NodeBenchmarkResultViewSchema).readonly(), { auth: "admin" }), method(object({ id: string() }), object({ deleted: boolean() }), {
29059
+ kind: "mutation",
29060
+ auth: "admin"
26518
29061
  }), method(object({ deviceId: number() }), CameraPipelineSettingsSchema.nullable()), method(object({
26519
29062
  deviceId: number(),
26520
29063
  addonId: string(),
@@ -26920,8 +29463,8 @@ version: string().optional() }), ServerUpdateActionResultSchema, {
26920
29463
  * `smtp-provider` — pluggable email delivery surface.
26921
29464
  *
26922
29465
  * Collection cap: a deployment may install multiple SMTP relays (e.g.
26923
- * one for transactional / one for notifications). Consumers (magic-link,
26924
- * notifier addons, …) walk the collection and pick the first
29466
+ * one for transactional / one for notifications). Consumers (notifier
29467
+ * addons, …) walk the collection and pick the first
26925
29468
  * ready provider OR target a specific addonId.
26926
29469
  *
26927
29470
  * The shape stays small on purpose — `sendEmail` is enough for the
@@ -27100,7 +29643,7 @@ targets: array(object({
27100
29643
  })));
27101
29644
  /**
27102
29645
  * `sso-bridge` — internal hub-only cap that lets SSO-style auth
27103
- * providers (OIDC, SAML, magic-link, …) mint an HMAC-signed token
29646
+ * providers (OIDC, SAML, …) mint an HMAC-signed token
27104
29647
  * carrying the post-callback claims before redirecting back to
27105
29648
  * `/api/auth/sso/finish`.
27106
29649
  *
@@ -27163,7 +29706,14 @@ var SsoBridgeClaimsSchema = object({
27163
29706
  * Verified `iss` of the id_token behind an OIDC login bridge (D782). A
27164
29707
  * subject is unique only per issuer, so a link is bound to it.
27165
29708
  */
27166
- issuer: string().optional()
29709
+ issuer: string().optional(),
29710
+ /**
29711
+ * SHA-256 (hex) of the `camstack_sso_state` cookie the IdP `/start` set in
29712
+ * the browser that began this sign-in. `/api/auth/sso/finish` requires the
29713
+ * request to present the matching cookie — a login bridge is useless in
29714
+ * any other browser.
29715
+ */
29716
+ browserBinding: string().optional()
27167
29717
  });
27168
29718
  method(object({
27169
29719
  claims: SsoBridgeClaimsSchema,
@@ -32720,6 +35270,9 @@ var CreateIntegrationInputSchema = object({
32720
35270
  enabled: boolean().optional(),
32721
35271
  info: record(string(), unknown()).optional(),
32722
35272
  settings: record(string(), unknown()).optional(),
35273
+ /** Keys of `settings` the form's schema declares secret (by type) — kept in
35274
+ * the keychain, not the table (D787). */
35275
+ secretKeys: array(string()).optional(),
32723
35276
  skipRestart: boolean().optional()
32724
35277
  });
32725
35278
  var UpdateIntegrationInputSchema = object({
@@ -32743,7 +35296,9 @@ method(_void(), array(IntegrationWithStateSchema)), method(object({ id: string()
32743
35296
  auth: "admin"
32744
35297
  }), method(object({ id: string() }), record(string(), unknown()), { auth: "admin" }), method(object({
32745
35298
  id: string(),
32746
- settings: record(string(), unknown())
35299
+ settings: record(string(), unknown()),
35300
+ /** Keys the form's schema declares secret (by type) — keychain-stored (D787). */
35301
+ secretKeys: array(string()).optional()
32747
35302
  }), object({ success: boolean() }), {
32748
35303
  kind: "mutation",
32749
35304
  auth: "admin"
@@ -39515,16 +42070,6 @@ var ApiKeySummarySchema = object({
39515
42070
  createdAt: number(),
39516
42071
  lastUsedAt: number().optional()
39517
42072
  });
39518
- var CreateApiKeyInputSchema = object({
39519
- label: string(),
39520
- isAdmin: boolean().default(false),
39521
- allowedProviders: union([array(string()), literal("*")]).optional(),
39522
- allowedDevices: record(string(), union([array(string()), literal("*")])).optional()
39523
- });
39524
- var CreateApiKeyResultSchema = object({
39525
- token: string(),
39526
- record: ApiKeySummarySchema
39527
- });
39528
42073
  var ScopedTokenSummarySchema = object({
39529
42074
  id: string(),
39530
42075
  userId: string(),
@@ -39623,17 +42168,10 @@ method(_void(), array(UserSummarySchema), { auth: "admin" }), method(CreateUserI
39623
42168
  }), UserSummarySchema.extend({ passwordHash: string() }).nullable(), {
39624
42169
  kind: "mutation",
39625
42170
  access: "view"
39626
- }), method(_void(), array(ApiKeySummarySchema), { auth: "admin" }), method(CreateApiKeyInputSchema, CreateApiKeyResultSchema, {
39627
- kind: "mutation",
39628
- auth: "admin",
39629
- access: "create"
39630
- }), method(object({ id: string() }), object({ success: literal(true) }), {
42171
+ }), method(_void(), array(ApiKeySummarySchema), { auth: "admin" }), method(object({ id: string() }), object({ success: literal(true) }), {
39631
42172
  kind: "mutation",
39632
42173
  auth: "admin",
39633
42174
  access: "delete"
39634
- }), method(object({ token: string() }), ApiKeySummarySchema.nullable(), {
39635
- kind: "mutation",
39636
- access: "view"
39637
42175
  }), method(CreateScopedTokenInputSchema, CreateScopedTokenResultSchema, {
39638
42176
  kind: "mutation",
39639
42177
  auth: "admin",
@@ -39707,15 +42245,7 @@ method(_void(), array(UserSummarySchema), { auth: "admin" }), method(CreateUserI
39707
42245
  }).nullable(), { access: "view" }), method(object({ userId: string() }), array(ExternalIdentitySchema), { auth: "admin" }), method(ExternalIdentityKeySchema, object({
39708
42246
  userId: string(),
39709
42247
  issuer: string()
39710
- }).nullable(), { auth: "admin" }), method(ExternalIdentityKeySchema.extend({
39711
- userId: string(),
39712
- issuer: string().min(1),
39713
- label: string().optional()
39714
- }), object({ success: literal(true) }), {
39715
- kind: "mutation",
39716
- auth: "admin",
39717
- access: "create"
39718
- }), method(ExternalIdentityKeySchema.extend({ userId: string() }), object({ success: boolean() }), {
42248
+ }).nullable(), { auth: "admin" }), method(ExternalIdentityKeySchema.extend({ userId: string() }), object({ success: boolean() }), {
39719
42249
  kind: "mutation",
39720
42250
  auth: "admin",
39721
42251
  access: "delete"
@@ -40420,6 +42950,451 @@ var zoneRulesCapability = {
40420
42950
  */
40421
42951
  durability: "restored"
40422
42952
  };
42953
+ /**
42954
+ * `training-provider` — ONE cloud that can run the CamStack trainer.
42955
+ *
42956
+ * A thin, mockable translation layer: it knows how to run a container with a
42957
+ * GPU, move a dataset in, read the job's stdout and hand artefacts back. It
42958
+ * knows nothing about datasets, splits, floors, cost policy or Model Studio —
42959
+ * those are the `training` orchestrator's (D805). Every rule written there
42960
+ * once is what makes a second provider (RunPod, a local NVIDIA node) a new
42961
+ * manifest entry and nothing else.
42962
+ *
42963
+ * Collection, routed by the `addonId` in every single-row input (the `llm` /
42964
+ * `notification-output` posture); `describe` concat-fans across providers.
42965
+ * Every method is `admin`: these spend money.
42966
+ *
42967
+ * Every cloud object a provider creates is tagged with the orchestrator's
42968
+ * `jobKey`, so a retried submit finds the job it already started instead of
42969
+ * starting a second GPU, and `listJobs` can find orphans.
42970
+ *
42971
+ * Bytes never ride a cap field: the dataset arrives as a `ctx.peerBytes`
42972
+ * ticket the producer (pipeline-analytics) minted, and artefacts leave as a
42973
+ * ticket the provider mints (D613).
42974
+ */
42975
+ var TrainingGpuOptionSchema = object({
42976
+ id: string(),
42977
+ label: string(),
42978
+ /** List price, USD per GPU-hour, before any region multiplier. */
42979
+ usdPerHour: number().nonnegative(),
42980
+ vramGb: number().nonnegative()
42981
+ });
42982
+ var TrainingRegionOptionSchema = object({
42983
+ /** `''` = any region (the provider's choice). */
42984
+ id: string(),
42985
+ label: string(),
42986
+ priceMultiplier: number().positive()
42987
+ });
42988
+ /**
42989
+ * The provider's per-account settings, as the orchestrator reads them. They
42990
+ * live in the PROVIDER addon's settings (operator decision 2026-10-08: they
42991
+ * depend on the user's account), never hard-coded in the orchestrator.
42992
+ */
42993
+ var TrainingProviderDefaultsSchema = object({
42994
+ gpuType: string(),
42995
+ region: string(),
42996
+ costCapUsd: number().nonnegative(),
42997
+ maxRuntimeSec: number().int().positive(),
42998
+ /** Hours a FAILED job's cloud dataset is kept for debugging; 0 = delete at once. */
42999
+ failedDatasetGraceHours: number().nonnegative()
43000
+ });
43001
+ var TrainingProviderDescriptorSchema = object({
43002
+ addonId: string(),
43003
+ /** `modal`, `runpod`, `fake`, … */
43004
+ kind: string(),
43005
+ label: string(),
43006
+ gpuTypes: array(TrainingGpuOptionSchema).readonly(),
43007
+ regions: array(TrainingRegionOptionSchema).readonly(),
43008
+ maxDatasetBytes: number().int().positive(),
43009
+ maxRuntimeSec: number().int().positive(),
43010
+ freeTierNote: string().optional(),
43011
+ /** Where the data goes, in one sentence the confirm dialog repeats. */
43012
+ dataResidencyNote: string(),
43013
+ /** Credentials are present — never the values. */
43014
+ configured: boolean(),
43015
+ defaults: TrainingProviderDefaultsSchema
43016
+ });
43017
+ var TrainingCredentialCheckSchema = object({
43018
+ ok: boolean(),
43019
+ /** Workspace / account name, when the provider says. */
43020
+ account: string().optional(),
43021
+ reason: _enum([
43022
+ "missing",
43023
+ "invalid",
43024
+ "forbidden",
43025
+ "network",
43026
+ "quota"
43027
+ ]).optional(),
43028
+ detail: string().optional()
43029
+ });
43030
+ var ProviderJobStateSchema = _enum([
43031
+ "pending",
43032
+ "starting",
43033
+ "running",
43034
+ "succeeded",
43035
+ "failed",
43036
+ "cancelled",
43037
+ "lost"
43038
+ ]);
43039
+ var ProviderJobStatusSchema = object({
43040
+ jobKey: string(),
43041
+ providerJobId: string().optional(),
43042
+ state: ProviderJobStateSchema,
43043
+ startedAt: number().optional(),
43044
+ endedAt: number().optional(),
43045
+ exitCode: number().int().optional(),
43046
+ failureReason: string().optional(),
43047
+ gpuType: string(),
43048
+ region: string().optional(),
43049
+ billedSeconds: number().nonnegative(),
43050
+ costUsd: number().nonnegative(),
43051
+ /** True when `costUsd` is runtime × list price, not a billing answer. */
43052
+ costIsEstimate: boolean(),
43053
+ lastFetchedAt: number()
43054
+ });
43055
+ /**
43056
+ * The trainer the job runs, by SOURCE revision: the provider turns it into an
43057
+ * image its own way (Modal builds the published Dockerfile at that revision;
43058
+ * a registry-pull provider maps it to a tag). Recorded on the job and echoed
43059
+ * in `result.json`.
43060
+ */
43061
+ var TrainerSourceRefSchema = object({
43062
+ /** Hugging Face repo id, e.g. `camstack/camstack-trainer`. */
43063
+ repo: string().min(1),
43064
+ /** A commit sha (never a branch) — the job must be reproducible. */
43065
+ revision: string().regex(/^[0-9a-f]{7,64}$/)
43066
+ });
43067
+ var JobRef = {
43068
+ addonId: string(),
43069
+ jobKey: string().uuid()
43070
+ };
43071
+ var TrainingLogLineSchema = object({
43072
+ ts: number(),
43073
+ text: string()
43074
+ });
43075
+ method(object({}), array(TrainingProviderDescriptorSchema).readonly(), { auth: "admin" }), method(object({ addonId: string() }), TrainingCredentialCheckSchema, {
43076
+ kind: "mutation",
43077
+ auth: "admin",
43078
+ timeoutMs: 3e4
43079
+ }), method(object({
43080
+ addonId: string(),
43081
+ gpuType: string(),
43082
+ region: string(),
43083
+ datasetBytes: number().int().nonnegative(),
43084
+ gpuSecondsLow: number().nonnegative(),
43085
+ gpuSecondsHigh: number().nonnegative()
43086
+ }), object({
43087
+ usdLow: number().nonnegative(),
43088
+ usdHigh: number().nonnegative(),
43089
+ notes: array(string()).readonly()
43090
+ }), { auth: "admin" }), method(object({
43091
+ ...JobRef,
43092
+ ticket: PeerBytesTicketSchema
43093
+ }), object({
43094
+ bytes: number().int().nonnegative(),
43095
+ sha256: string()
43096
+ }), {
43097
+ kind: "mutation",
43098
+ auth: "admin",
43099
+ timeoutMs: 120 * 6e4
43100
+ }), method(object({
43101
+ ...JobRef,
43102
+ trainer: TrainerSourceRefSchema,
43103
+ jobSpecJson: string().min(2).max(64e3),
43104
+ gpuType: string(),
43105
+ region: string(),
43106
+ maxRuntimeSec: number().int().positive()
43107
+ }), ProviderJobStatusSchema, {
43108
+ kind: "mutation",
43109
+ auth: "admin",
43110
+ timeoutMs: 30 * 6e4
43111
+ }), method(object(JobRef), ProviderJobStatusSchema, {
43112
+ auth: "admin",
43113
+ timeoutMs: 6e4
43114
+ }), method(object({
43115
+ ...JobRef,
43116
+ cursor: string().optional(),
43117
+ max: number().int().min(1).max(500)
43118
+ }), object({
43119
+ lines: array(TrainingLogLineSchema).readonly(),
43120
+ cursor: string()
43121
+ }), {
43122
+ auth: "admin",
43123
+ timeoutMs: 6e4
43124
+ }), method(object(JobRef), object({ ok: literal(true) }), {
43125
+ kind: "mutation",
43126
+ auth: "admin",
43127
+ timeoutMs: 6e4
43128
+ }), method(object(JobRef), object({
43129
+ found: boolean(),
43130
+ text: string().optional()
43131
+ }), {
43132
+ kind: "mutation",
43133
+ auth: "admin",
43134
+ timeoutMs: 5 * 6e4
43135
+ }), method(object({
43136
+ ...JobRef,
43137
+ path: _enum(["bundle.tar"])
43138
+ }), object({ ticket: PeerBytesTicketSchema }), {
43139
+ kind: "mutation",
43140
+ auth: "admin",
43141
+ timeoutMs: 5 * 6e4
43142
+ }), method(object(JobRef), object({ deleted: array(string()).readonly() }), {
43143
+ kind: "mutation",
43144
+ auth: "admin",
43145
+ timeoutMs: 5 * 6e4
43146
+ }), method(object({ addonId: string() }), array(ProviderJobStatusSchema).readonly(), {
43147
+ auth: "admin",
43148
+ timeoutMs: 2 * 6e4
43149
+ });
43150
+ /**
43151
+ * `training` — the cloud-training orchestrator (D805). Hub-only singleton,
43152
+ * provided by `addon-training`.
43153
+ *
43154
+ * It owns what every provider must agree on, written once:
43155
+ *
43156
+ * - **Dataset versions.** Taken over from pipeline-analytics (D796): the rows
43157
+ * live here (D808); pipeline-analytics still CUTS a version (it owns the corpus and
43158
+ * the export plan) and reaches this store through the five row methods
43159
+ * below, so the Retrain page and the export did not change.
43160
+ * - **Jobs.** A persisted state machine, a reconcile loop against the
43161
+ * provider, a cost guard, a daily orphan sweep and the retention rules.
43162
+ * - **The return flow.** Verified artefacts → Model Studio
43163
+ * (`custom-model-registry.importModelBundle`) → canary on cameras →
43164
+ * rollback. Nothing is ever registered automatically.
43165
+ *
43166
+ * Every method is `admin`.
43167
+ */
43168
+ /** A version WITH its frame list — what the export and a job read. */
43169
+ var TrainingDatasetVersionRowSchema = RetrainDatasetVersionSchema.omit({ frameCount: true }).extend({ frameIds: array(string()).max(2e4).readonly() });
43170
+ /** A base model a detector job can fine-tune, and the baseline it is judged against. */
43171
+ var TrainingBaseModelSchema = object({
43172
+ modelId: string(),
43173
+ label: string(),
43174
+ weights: string(),
43175
+ imgsz: number().int(),
43176
+ baselineOnnxUrl: string(),
43177
+ baselineFloors: record(string(), number()),
43178
+ /** The base the fleet runs most — the UI's default. */
43179
+ recommended: boolean()
43180
+ });
43181
+ var TrainingPresetSchema = _enum([
43182
+ "quick",
43183
+ "standard",
43184
+ "thorough"
43185
+ ]);
43186
+ var TrainingJobRequestSchema = object({
43187
+ datasetVersionId: string().min(1),
43188
+ /** The `training-provider` addon that runs it. */
43189
+ addonId: string().min(1),
43190
+ gpuType: string().min(1),
43191
+ region: string(),
43192
+ baseModelId: string().min(1),
43193
+ preset: TrainingPresetSchema,
43194
+ /** Freeze the backbone's first N layers; `null` = the preset's choice. */
43195
+ freeze: number().int().nonnegative().nullable(),
43196
+ /** Cameras held out whole for evaluation; `null` = the orchestrator's default. */
43197
+ holdoutCameras: array(number().int()).nullable()
43198
+ });
43199
+ var TrainingSplitPlanSchema = object({
43200
+ holdoutCameras: array(number().int()).readonly(),
43201
+ /** Used when no camera is held out: the last N days of every camera. */
43202
+ holdoutLastDays: number().int().nonnegative(),
43203
+ /** Holdout subjects per class (camera holdout only; `null` = known only after the split). */
43204
+ holdoutSupport: record(string(), number().int()).nullable(),
43205
+ trainSubjects: number().int()
43206
+ });
43207
+ var TrainingRefusalReasonSchema = _enum([
43208
+ "unknown-dataset",
43209
+ "unknown-provider",
43210
+ "provider-not-configured",
43211
+ "unknown-base-model",
43212
+ "unknown-gpu",
43213
+ "dataset-too-large",
43214
+ "no-training-subjects",
43215
+ "job-already-running"
43216
+ ]);
43217
+ var TrainingJobPlanSchema = object({
43218
+ refusal: object({
43219
+ reason: TrainingRefusalReasonSchema,
43220
+ detail: string()
43221
+ }).nullable(),
43222
+ warnings: array(string()).readonly(),
43223
+ split: TrainingSplitPlanSchema.nullable(),
43224
+ estimate: object({
43225
+ datasetBytes: number().int(),
43226
+ uploadMinutesAt20Mbps: number(),
43227
+ gpuSecondsLow: number(),
43228
+ gpuSecondsHigh: number(),
43229
+ usdLow: number(),
43230
+ usdHigh: number(),
43231
+ notes: array(string()).readonly()
43232
+ }).nullable(),
43233
+ /** Pre-filled from the provider's settings; the operator may lower or raise them. */
43234
+ defaults: object({
43235
+ maxCostUsd: number(),
43236
+ maxRuntimeSec: number().int()
43237
+ }).nullable(),
43238
+ /** The sentence the confirm dialog repeats: where the frames go and when they are deleted. */
43239
+ dataNotice: string()
43240
+ });
43241
+ /**
43242
+ * Orchestrator-owned states, persisted. `uploading` covers exporting the
43243
+ * archive (it is streamed, never staged). Terminal: `failed`, `cancelled`,
43244
+ * `lost`, `expired`, `discarded`. `registered` and `canary` are where a
43245
+ * result lives after the operator acted on it.
43246
+ */
43247
+ var TrainingJobStateSchema = _enum([
43248
+ "uploading",
43249
+ "submitted",
43250
+ "starting",
43251
+ "running",
43252
+ "collecting",
43253
+ "ready",
43254
+ "registered",
43255
+ "canary",
43256
+ "failed",
43257
+ "cancelling",
43258
+ "cancelled",
43259
+ "lost",
43260
+ "expired",
43261
+ "discarded"
43262
+ ]);
43263
+ var TrainingFailureReasonSchema = _enum([
43264
+ "cost-cap",
43265
+ "runtime-cap",
43266
+ "upload-failed",
43267
+ "submit-failed",
43268
+ "trainer-failed",
43269
+ "result-invalid",
43270
+ "checksum-mismatch",
43271
+ "fetch-failed",
43272
+ "provider-error",
43273
+ "hub-restart-during-upload"
43274
+ ]);
43275
+ var TrainingProgressPointSchema = object({
43276
+ epoch: number().int(),
43277
+ map50: number().nullable(),
43278
+ map50_95: number().nullable()
43279
+ });
43280
+ var TrainingCanarySchema = object({
43281
+ deviceIds: array(number().int()).readonly(),
43282
+ since: number(),
43283
+ /** Every override the canary replaced, exactly, so rollback restores it. */
43284
+ previous: array(object({
43285
+ deviceId: number().int(),
43286
+ nodeId: string(),
43287
+ deviceKey: string(),
43288
+ patch: object({
43289
+ modelId: string().optional(),
43290
+ settings: record(string(), unknown()).readonly().optional()
43291
+ }).nullable()
43292
+ })).readonly()
43293
+ });
43294
+ var TrainingJobSchema = object({
43295
+ id: string(),
43296
+ idempotencyKey: string(),
43297
+ name: string(),
43298
+ createdAt: number(),
43299
+ updatedAt: number(),
43300
+ state: TrainingJobStateSchema,
43301
+ stage: TrainingStageSchema.nullable(),
43302
+ failure: object({
43303
+ reason: TrainingFailureReasonSchema,
43304
+ stage: string().nullable(),
43305
+ detail: string()
43306
+ }).nullable(),
43307
+ request: TrainingJobRequestSchema,
43308
+ maxCostUsd: number().nonnegative(),
43309
+ maxRuntimeSec: number().int().positive(),
43310
+ trainer: TrainerSourceRefSchema,
43311
+ datasetLayout: RetrainExportLayoutSchema,
43312
+ dataset: object({
43313
+ bytes: number().int(),
43314
+ sha256: string(),
43315
+ uploadedAt: number()
43316
+ }).nullable(),
43317
+ split: TrainingSplitPlanSchema,
43318
+ provider: object({
43319
+ state: ProviderJobStateSchema.nullable(),
43320
+ providerJobId: string().nullable(),
43321
+ startedAt: number().nullable(),
43322
+ endedAt: number().nullable(),
43323
+ billedSeconds: number(),
43324
+ costUsd: number(),
43325
+ costIsEstimate: boolean(),
43326
+ lastPolledAt: number().nullable()
43327
+ }),
43328
+ progress: object({
43329
+ epoch: number().int().nullable(),
43330
+ epochs: number().int().nullable(),
43331
+ etaSec: number().nullable(),
43332
+ series: array(TrainingProgressPointSchema).readonly()
43333
+ }),
43334
+ /** The last lines of the job's output (≤ 200), newest last. Never frame paths. */
43335
+ logTail: array(string()).readonly(),
43336
+ logCursor: string().nullable(),
43337
+ artifacts: object({
43338
+ bundleBytes: number().int(),
43339
+ bundleSha256: string(),
43340
+ fetchedAt: number(),
43341
+ /** When the staged artefacts are deleted from the hub. */
43342
+ expiresAt: number()
43343
+ }).nullable(),
43344
+ /** When the provider-side copy of the frames was deleted; null while it exists. */
43345
+ cloudDatasetDeletedAt: number().nullable(),
43346
+ /** A failed job's dataset is kept until then (the provider's grace), then deleted. */
43347
+ cloudCleanupDueAt: number().nullable(),
43348
+ /** Model ids registered from this job (base, and int8 when kept). */
43349
+ registeredModelIds: array(string()).readonly(),
43350
+ canary: TrainingCanarySchema.nullable()
43351
+ });
43352
+ var IdInput = object({ id: string().min(1) });
43353
+ method(TrainingDatasetVersionRowSchema, object({ stored: boolean() }), {
43354
+ kind: "mutation",
43355
+ auth: "admin"
43356
+ }), 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() }), {
43357
+ kind: "mutation",
43358
+ auth: "admin"
43359
+ }), method(object({}), array(TrainingBaseModelSchema).readonly(), { auth: "admin" }), method(TrainingJobRequestSchema, TrainingJobPlanSchema, {
43360
+ auth: "admin",
43361
+ timeoutMs: 6e4
43362
+ }), method(TrainingJobRequestSchema.extend({
43363
+ name: string().min(1).max(120),
43364
+ maxCostUsd: number().positive(),
43365
+ maxRuntimeSec: number().int().positive(),
43366
+ idempotencyKey: string().min(8).max(80)
43367
+ }), discriminatedUnion("kind", [object({
43368
+ kind: literal("started"),
43369
+ job: TrainingJobSchema
43370
+ }), object({
43371
+ kind: literal("refused"),
43372
+ reason: TrainingRefusalReasonSchema,
43373
+ detail: string()
43374
+ })]), {
43375
+ kind: "mutation",
43376
+ auth: "admin",
43377
+ timeoutMs: 12e4
43378
+ }), method(object({}), array(TrainingJobSchema).readonly(), { auth: "admin" }), method(IdInput, TrainingJobSchema.nullable(), { auth: "admin" }), method(IdInput, TrainingJobSchema, {
43379
+ kind: "mutation",
43380
+ auth: "admin",
43381
+ timeoutMs: 12e4
43382
+ }), method(IdInput, TrainingResultSchema.nullable(), { auth: "admin" }), method(IdInput.extend({ canaryDeviceIds: array(number().int()).readonly() }), TrainingJobSchema, {
43383
+ kind: "mutation",
43384
+ auth: "admin",
43385
+ timeoutMs: 30 * 6e4
43386
+ }), method(IdInput.extend({ deviceIds: array(number().int()).min(1).readonly() }), TrainingJobSchema, {
43387
+ kind: "mutation",
43388
+ auth: "admin",
43389
+ timeoutMs: 12e4
43390
+ }), method(IdInput, TrainingJobSchema, {
43391
+ kind: "mutation",
43392
+ auth: "admin",
43393
+ timeoutMs: 12e4
43394
+ }), method(IdInput, TrainingJobSchema, {
43395
+ kind: "mutation",
43396
+ auth: "admin"
43397
+ });
40423
43398
  SOURCE_CAPS.filter((cap) => cap !== "switch" && cap !== "motion");
40424
43399
  Object.freeze({
40425
43400
  person: .5,
@@ -40906,7 +43881,8 @@ var BaseDevice = class {
40906
43881
  this.role = options.role;
40907
43882
  this.parentDeviceId = ctx.parentDeviceId;
40908
43883
  const seedData = ctx.persistedConfig ?? {};
40909
- this.config = DeviceConfig.fromSchema(schema, (data) => ctx.persistConfig(data), seedData, ({ droppedKeys, issues }) => {
43884
+ const declaredSecretPaths = collectZodSecretPaths(schema);
43885
+ this.config = DeviceConfig.fromSchema(schema, (data) => ctx.persistConfig(data, { secretConfigPaths: declaredSecretPaths }), seedData, ({ droppedKeys, issues }) => {
40910
43886
  ctx.logger.warn("Device config recovery: dropping invalid persisted fields", {
40911
43887
  tags: {
40912
43888
  deviceId: ctx.id,
@@ -42567,6 +45543,12 @@ Object.freeze({
42567
45543
  addonId: null,
42568
45544
  access: "create"
42569
45545
  },
45546
+ "backup.checkBackupKey": {
45547
+ capName: "backup",
45548
+ capScope: "system",
45549
+ addonId: null,
45550
+ access: "create"
45551
+ },
42570
45552
  "backup.delete": {
42571
45553
  capName: "backup",
42572
45554
  capScope: "system",
@@ -42579,6 +45561,18 @@ Object.freeze({
42579
45561
  addonId: null,
42580
45562
  access: "delete"
42581
45563
  },
45564
+ "backup.disableEncryption": {
45565
+ capName: "backup",
45566
+ capScope: "system",
45567
+ addonId: null,
45568
+ access: "create"
45569
+ },
45570
+ "backup.getEncryption": {
45571
+ capName: "backup",
45572
+ capScope: "system",
45573
+ addonId: null,
45574
+ access: "view"
45575
+ },
42582
45576
  "backup.getEntries": {
42583
45577
  capName: "backup",
42584
45578
  capScope: "system",
@@ -42633,6 +45627,12 @@ Object.freeze({
42633
45627
  addonId: null,
42634
45628
  access: "create"
42635
45629
  },
45630
+ "backup.setupEncryption": {
45631
+ capName: "backup",
45632
+ capScope: "system",
45633
+ addonId: null,
45634
+ access: "create"
45635
+ },
42636
45636
  "backup.trigger": {
42637
45637
  capName: "backup",
42638
45638
  capScope: "system",
@@ -43185,6 +46185,12 @@ Object.freeze({
43185
46185
  addonId: null,
43186
46186
  access: "create"
43187
46187
  },
46188
+ "customModelRegistry.importModelBundle": {
46189
+ capName: "custom-model-registry",
46190
+ capScope: "system",
46191
+ addonId: null,
46192
+ access: "create"
46193
+ },
43188
46194
  "customModelRegistry.listModels": {
43189
46195
  capName: "custom-model-registry",
43190
46196
  capScope: "system",
@@ -44595,6 +47601,108 @@ Object.freeze({
44595
47601
  addonId: null,
44596
47602
  access: "create"
44597
47603
  },
47604
+ "keychain.delete": {
47605
+ capName: "keychain",
47606
+ capScope: "system",
47607
+ addonId: null,
47608
+ access: "delete"
47609
+ },
47610
+ "keychain.getState": {
47611
+ capName: "keychain",
47612
+ capScope: "system",
47613
+ addonId: null,
47614
+ access: "view"
47615
+ },
47616
+ "keychain.listMeta": {
47617
+ capName: "keychain",
47618
+ capScope: "system",
47619
+ addonId: null,
47620
+ access: "view"
47621
+ },
47622
+ "keychain.put": {
47623
+ capName: "keychain",
47624
+ capScope: "system",
47625
+ addonId: null,
47626
+ access: "create"
47627
+ },
47628
+ "keychain.resolve": {
47629
+ capName: "keychain",
47630
+ capScope: "system",
47631
+ addonId: null,
47632
+ access: "view"
47633
+ },
47634
+ "keychainAdmin.acknowledgeReset": {
47635
+ capName: "keychain-admin",
47636
+ capScope: "system",
47637
+ addonId: null,
47638
+ access: "create"
47639
+ },
47640
+ "keychainAdmin.deleteOrphans": {
47641
+ capName: "keychain-admin",
47642
+ capScope: "system",
47643
+ addonId: null,
47644
+ access: "delete"
47645
+ },
47646
+ "keychainAdmin.downloadRecoveryKey": {
47647
+ capName: "keychain-admin",
47648
+ capScope: "system",
47649
+ addonId: null,
47650
+ access: "create"
47651
+ },
47652
+ "keychainAdmin.listAudit": {
47653
+ capName: "keychain-admin",
47654
+ capScope: "system",
47655
+ addonId: null,
47656
+ access: "view"
47657
+ },
47658
+ "keychainAdmin.listSecrets": {
47659
+ capName: "keychain-admin",
47660
+ capScope: "system",
47661
+ addonId: null,
47662
+ access: "view"
47663
+ },
47664
+ "keychainAdmin.purgeRetiredKeys": {
47665
+ capName: "keychain-admin",
47666
+ capScope: "system",
47667
+ addonId: null,
47668
+ access: "delete"
47669
+ },
47670
+ "keychainAdmin.resetKeychain": {
47671
+ capName: "keychain-admin",
47672
+ capScope: "system",
47673
+ addonId: null,
47674
+ access: "delete"
47675
+ },
47676
+ "keychainAdmin.resetReport": {
47677
+ capName: "keychain-admin",
47678
+ capScope: "system",
47679
+ addonId: null,
47680
+ access: "delete"
47681
+ },
47682
+ "keychainAdmin.reveal": {
47683
+ capName: "keychain-admin",
47684
+ capScope: "system",
47685
+ addonId: null,
47686
+ access: "create"
47687
+ },
47688
+ "keychainAdmin.rotateMasterKey": {
47689
+ capName: "keychain-admin",
47690
+ capScope: "system",
47691
+ addonId: null,
47692
+ access: "create"
47693
+ },
47694
+ "keychainAdmin.setSystemSecret": {
47695
+ capName: "keychain-admin",
47696
+ capScope: "system",
47697
+ addonId: null,
47698
+ access: "create"
47699
+ },
47700
+ "keychainAdmin.status": {
47701
+ capName: "keychain-admin",
47702
+ capScope: "system",
47703
+ addonId: null,
47704
+ access: "view"
47705
+ },
44598
47706
  "lawnMowerControl.dock": {
44599
47707
  capName: "lawn-mower-control",
44600
47708
  capScope: "device",
@@ -45969,6 +49077,18 @@ Object.freeze({
45969
49077
  addonId: null,
45970
49078
  access: "create"
45971
49079
  },
49080
+ "pipelineAnalytics.addRetrainFrameFromRecording": {
49081
+ capName: "pipeline-analytics",
49082
+ capScope: "device",
49083
+ addonId: null,
49084
+ access: "create"
49085
+ },
49086
+ "pipelineAnalytics.addRetrainFramesToCollection": {
49087
+ capName: "pipeline-analytics",
49088
+ capScope: "device",
49089
+ addonId: null,
49090
+ access: "create"
49091
+ },
45972
49092
  "pipelineAnalytics.applyDeviceSettingsPatch": {
45973
49093
  capName: "pipeline-analytics",
45974
49094
  capScope: "device",
@@ -46017,12 +49137,36 @@ Object.freeze({
46017
49137
  addonId: null,
46018
49138
  access: "view"
46019
49139
  },
49140
+ "pipelineAnalytics.createRetrainCollection": {
49141
+ capName: "pipeline-analytics",
49142
+ capScope: "device",
49143
+ addonId: null,
49144
+ access: "create"
49145
+ },
49146
+ "pipelineAnalytics.createRetrainDatasetVersion": {
49147
+ capName: "pipeline-analytics",
49148
+ capScope: "device",
49149
+ addonId: null,
49150
+ access: "create"
49151
+ },
46020
49152
  "pipelineAnalytics.deleteDeviceEvents": {
46021
49153
  capName: "pipeline-analytics",
46022
49154
  capScope: "device",
46023
49155
  addonId: null,
46024
49156
  access: "delete"
46025
49157
  },
49158
+ "pipelineAnalytics.deleteRetrainCollection": {
49159
+ capName: "pipeline-analytics",
49160
+ capScope: "device",
49161
+ addonId: null,
49162
+ access: "delete"
49163
+ },
49164
+ "pipelineAnalytics.deleteRetrainDatasetVersion": {
49165
+ capName: "pipeline-analytics",
49166
+ capScope: "device",
49167
+ addonId: null,
49168
+ access: "delete"
49169
+ },
46026
49170
  "pipelineAnalytics.deleteTracks": {
46027
49171
  capName: "pipeline-analytics",
46028
49172
  capScope: "device",
@@ -46227,6 +49371,30 @@ Object.freeze({
46227
49371
  addonId: null,
46228
49372
  access: "view"
46229
49373
  },
49374
+ "pipelineAnalytics.listRetrainAssistProfiles": {
49375
+ capName: "pipeline-analytics",
49376
+ capScope: "device",
49377
+ addonId: null,
49378
+ access: "view"
49379
+ },
49380
+ "pipelineAnalytics.listRetrainCollectionFrames": {
49381
+ capName: "pipeline-analytics",
49382
+ capScope: "device",
49383
+ addonId: null,
49384
+ access: "view"
49385
+ },
49386
+ "pipelineAnalytics.listRetrainCollections": {
49387
+ capName: "pipeline-analytics",
49388
+ capScope: "device",
49389
+ addonId: null,
49390
+ access: "view"
49391
+ },
49392
+ "pipelineAnalytics.listRetrainDatasetVersions": {
49393
+ capName: "pipeline-analytics",
49394
+ capScope: "device",
49395
+ addonId: null,
49396
+ access: "view"
49397
+ },
46230
49398
  "pipelineAnalytics.listRetrainFrames": {
46231
49399
  capName: "pipeline-analytics",
46232
49400
  capScope: "device",
@@ -46257,6 +49425,12 @@ Object.freeze({
46257
49425
  addonId: null,
46258
49426
  access: "view"
46259
49427
  },
49428
+ "pipelineAnalytics.offerRetrainArchive": {
49429
+ capName: "pipeline-analytics",
49430
+ capScope: "device",
49431
+ addonId: null,
49432
+ access: "create"
49433
+ },
46260
49434
  "pipelineAnalytics.ownersWithMedia": {
46261
49435
  capName: "pipeline-analytics",
46262
49436
  capScope: "device",
@@ -46269,12 +49443,24 @@ Object.freeze({
46269
49443
  addonId: null,
46270
49444
  access: "create"
46271
49445
  },
49446
+ "pipelineAnalytics.previewRetrainDataset": {
49447
+ capName: "pipeline-analytics",
49448
+ capScope: "device",
49449
+ addonId: null,
49450
+ access: "view"
49451
+ },
46272
49452
  "pipelineAnalytics.proposeRetrainAnnotations": {
46273
49453
  capName: "pipeline-analytics",
46274
49454
  capScope: "device",
46275
49455
  addonId: null,
46276
49456
  access: "create"
46277
49457
  },
49458
+ "pipelineAnalytics.proposeRetrainAnnotationsWithLlm": {
49459
+ capName: "pipeline-analytics",
49460
+ capScope: "device",
49461
+ addonId: null,
49462
+ access: "create"
49463
+ },
46278
49464
  "pipelineAnalytics.pruneEvents": {
46279
49465
  capName: "pipeline-analytics",
46280
49466
  capScope: "device",
@@ -46329,6 +49515,18 @@ Object.freeze({
46329
49515
  addonId: null,
46330
49516
  access: "create"
46331
49517
  },
49518
+ "pipelineAnalytics.removeRetrainFrameFromCollection": {
49519
+ capName: "pipeline-analytics",
49520
+ capScope: "device",
49521
+ addonId: null,
49522
+ access: "delete"
49523
+ },
49524
+ "pipelineAnalytics.renameRetrainCollection": {
49525
+ capName: "pipeline-analytics",
49526
+ capScope: "device",
49527
+ addonId: null,
49528
+ access: "create"
49529
+ },
46332
49530
  "pipelineAnalytics.restageRetrainTrack": {
46333
49531
  capName: "pipeline-analytics",
46334
49532
  capScope: "device",
@@ -46389,6 +49587,12 @@ Object.freeze({
46389
49587
  addonId: null,
46390
49588
  access: "create"
46391
49589
  },
49590
+ "pipelineAnalytics.verifyRetrainDatasetVersion": {
49591
+ capName: "pipeline-analytics",
49592
+ capScope: "device",
49593
+ addonId: null,
49594
+ access: "view"
49595
+ },
46392
49596
  "pipelineAnalytics.wipeAllAnalytics": {
46393
49597
  capName: "pipeline-analytics",
46394
49598
  capScope: "device",
@@ -46617,6 +49821,12 @@ Object.freeze({
46617
49821
  addonId: null,
46618
49822
  access: "view"
46619
49823
  },
49824
+ "pipelineOrchestrator.abortNodeBenchmark": {
49825
+ capName: "pipeline-orchestrator",
49826
+ capScope: "system",
49827
+ addonId: null,
49828
+ access: "create"
49829
+ },
46620
49830
  "pipelineOrchestrator.applyAutoTune": {
46621
49831
  capName: "pipeline-orchestrator",
46622
49832
  capScope: "system",
@@ -46641,6 +49851,12 @@ Object.freeze({
46641
49851
  addonId: null,
46642
49852
  access: "create"
46643
49853
  },
49854
+ "pipelineOrchestrator.deleteNodeBenchmarkResult": {
49855
+ capName: "pipeline-orchestrator",
49856
+ capScope: "system",
49857
+ addonId: null,
49858
+ access: "delete"
49859
+ },
46644
49860
  "pipelineOrchestrator.getAgentLoad": {
46645
49861
  capName: "pipeline-orchestrator",
46646
49862
  capScope: "system",
@@ -46749,6 +49965,24 @@ Object.freeze({
46749
49965
  addonId: null,
46750
49966
  access: "view"
46751
49967
  },
49968
+ "pipelineOrchestrator.getNodeBenchmarkCandidates": {
49969
+ capName: "pipeline-orchestrator",
49970
+ capScope: "system",
49971
+ addonId: null,
49972
+ access: "view"
49973
+ },
49974
+ "pipelineOrchestrator.getNodeBenchmarkPreflight": {
49975
+ capName: "pipeline-orchestrator",
49976
+ capScope: "system",
49977
+ addonId: null,
49978
+ access: "view"
49979
+ },
49980
+ "pipelineOrchestrator.getNodeBenchmarkStatus": {
49981
+ capName: "pipeline-orchestrator",
49982
+ capScope: "system",
49983
+ addonId: null,
49984
+ access: "view"
49985
+ },
46752
49986
  "pipelineOrchestrator.getNodeInferenceDevices": {
46753
49987
  capName: "pipeline-orchestrator",
46754
49988
  capScope: "system",
@@ -46791,6 +50025,12 @@ Object.freeze({
46791
50025
  addonId: null,
46792
50026
  access: "view"
46793
50027
  },
50028
+ "pipelineOrchestrator.listNodeBenchmarkResults": {
50029
+ capName: "pipeline-orchestrator",
50030
+ capScope: "system",
50031
+ addonId: null,
50032
+ access: "view"
50033
+ },
46794
50034
  "pipelineOrchestrator.pauseForStorageMigration": {
46795
50035
  capName: "pipeline-orchestrator",
46796
50036
  capScope: "system",
@@ -46935,6 +50175,12 @@ Object.freeze({
46935
50175
  addonId: null,
46936
50176
  access: "create"
46937
50177
  },
50178
+ "pipelineOrchestrator.startNodeBenchmark": {
50179
+ capName: "pipeline-orchestrator",
50180
+ capScope: "system",
50181
+ addonId: null,
50182
+ access: "create"
50183
+ },
46938
50184
  "pipelineOrchestrator.suggestShares": {
46939
50185
  capName: "pipeline-orchestrator",
46940
50186
  capScope: "system",
@@ -46953,6 +50199,12 @@ Object.freeze({
46953
50199
  addonId: null,
46954
50200
  access: "create"
46955
50201
  },
50202
+ "pipelineRunner.abortNodeBench": {
50203
+ capName: "pipeline-runner",
50204
+ capScope: "system",
50205
+ addonId: null,
50206
+ access: "create"
50207
+ },
46956
50208
  "pipelineRunner.attachCamera": {
46957
50209
  capName: "pipeline-runner",
46958
50210
  capScope: "system",
@@ -47001,6 +50253,12 @@ Object.freeze({
47001
50253
  addonId: null,
47002
50254
  access: "view"
47003
50255
  },
50256
+ "pipelineRunner.getNodeBenchStatus": {
50257
+ capName: "pipeline-runner",
50258
+ capScope: "system",
50259
+ addonId: null,
50260
+ access: "view"
50261
+ },
47004
50262
  "pipelineRunner.getParkedTrackFrame": {
47005
50263
  capName: "pipeline-runner",
47006
50264
  capScope: "system",
@@ -47043,6 +50301,12 @@ Object.freeze({
47043
50301
  addonId: null,
47044
50302
  access: "create"
47045
50303
  },
50304
+ "pipelineRunner.startNodeBench": {
50305
+ capName: "pipeline-runner",
50306
+ capScope: "system",
50307
+ addonId: null,
50308
+ access: "create"
50309
+ },
47046
50310
  "plateGallery.assignPlate": {
47047
50311
  capName: "plate-gallery",
47048
50312
  capScope: "system",
@@ -48705,6 +51969,174 @@ Object.freeze({
48705
51969
  addonId: null,
48706
51970
  access: "view"
48707
51971
  },
51972
+ "training.canaryResult": {
51973
+ capName: "training",
51974
+ capScope: "system",
51975
+ addonId: null,
51976
+ access: "create"
51977
+ },
51978
+ "training.cancelJob": {
51979
+ capName: "training",
51980
+ capScope: "system",
51981
+ addonId: null,
51982
+ access: "create"
51983
+ },
51984
+ "training.discardResult": {
51985
+ capName: "training",
51986
+ capScope: "system",
51987
+ addonId: null,
51988
+ access: "create"
51989
+ },
51990
+ "training.findDatasetVersionIdByName": {
51991
+ capName: "training",
51992
+ capScope: "system",
51993
+ addonId: null,
51994
+ access: "view"
51995
+ },
51996
+ "training.getDatasetVersion": {
51997
+ capName: "training",
51998
+ capScope: "system",
51999
+ addonId: null,
52000
+ access: "view"
52001
+ },
52002
+ "training.getJob": {
52003
+ capName: "training",
52004
+ capScope: "system",
52005
+ addonId: null,
52006
+ access: "view"
52007
+ },
52008
+ "training.getJobResult": {
52009
+ capName: "training",
52010
+ capScope: "system",
52011
+ addonId: null,
52012
+ access: "view"
52013
+ },
52014
+ "training.listBaseModels": {
52015
+ capName: "training",
52016
+ capScope: "system",
52017
+ addonId: null,
52018
+ access: "view"
52019
+ },
52020
+ "training.listDatasetVersions": {
52021
+ capName: "training",
52022
+ capScope: "system",
52023
+ addonId: null,
52024
+ access: "view"
52025
+ },
52026
+ "training.listJobs": {
52027
+ capName: "training",
52028
+ capScope: "system",
52029
+ addonId: null,
52030
+ access: "view"
52031
+ },
52032
+ "training.planJob": {
52033
+ capName: "training",
52034
+ capScope: "system",
52035
+ addonId: null,
52036
+ access: "view"
52037
+ },
52038
+ "training.putDatasetVersion": {
52039
+ capName: "training",
52040
+ capScope: "system",
52041
+ addonId: null,
52042
+ access: "create"
52043
+ },
52044
+ "training.registerResult": {
52045
+ capName: "training",
52046
+ capScope: "system",
52047
+ addonId: null,
52048
+ access: "create"
52049
+ },
52050
+ "training.removeDatasetVersion": {
52051
+ capName: "training",
52052
+ capScope: "system",
52053
+ addonId: null,
52054
+ access: "delete"
52055
+ },
52056
+ "training.rollbackCanary": {
52057
+ capName: "training",
52058
+ capScope: "system",
52059
+ addonId: null,
52060
+ access: "create"
52061
+ },
52062
+ "training.startJob": {
52063
+ capName: "training",
52064
+ capScope: "system",
52065
+ addonId: null,
52066
+ access: "create"
52067
+ },
52068
+ "trainingProvider.cancelJob": {
52069
+ capName: "training-provider",
52070
+ capScope: "system",
52071
+ addonId: null,
52072
+ access: "create"
52073
+ },
52074
+ "trainingProvider.cleanupJob": {
52075
+ capName: "training-provider",
52076
+ capScope: "system",
52077
+ addonId: null,
52078
+ access: "create"
52079
+ },
52080
+ "trainingProvider.describe": {
52081
+ capName: "training-provider",
52082
+ capScope: "system",
52083
+ addonId: null,
52084
+ access: "view"
52085
+ },
52086
+ "trainingProvider.estimateJob": {
52087
+ capName: "training-provider",
52088
+ capScope: "system",
52089
+ addonId: null,
52090
+ access: "view"
52091
+ },
52092
+ "trainingProvider.getJob": {
52093
+ capName: "training-provider",
52094
+ capScope: "system",
52095
+ addonId: null,
52096
+ access: "view"
52097
+ },
52098
+ "trainingProvider.listJobEvents": {
52099
+ capName: "training-provider",
52100
+ capScope: "system",
52101
+ addonId: null,
52102
+ access: "view"
52103
+ },
52104
+ "trainingProvider.listJobs": {
52105
+ capName: "training-provider",
52106
+ capScope: "system",
52107
+ addonId: null,
52108
+ access: "view"
52109
+ },
52110
+ "trainingProvider.offerArtifact": {
52111
+ capName: "training-provider",
52112
+ capScope: "system",
52113
+ addonId: null,
52114
+ access: "create"
52115
+ },
52116
+ "trainingProvider.readResult": {
52117
+ capName: "training-provider",
52118
+ capScope: "system",
52119
+ addonId: null,
52120
+ access: "create"
52121
+ },
52122
+ "trainingProvider.submitJob": {
52123
+ capName: "training-provider",
52124
+ capScope: "system",
52125
+ addonId: null,
52126
+ access: "create"
52127
+ },
52128
+ "trainingProvider.uploadDataset": {
52129
+ capName: "training-provider",
52130
+ capScope: "system",
52131
+ addonId: null,
52132
+ access: "create"
52133
+ },
52134
+ "trainingProvider.validateCredentials": {
52135
+ capName: "training-provider",
52136
+ capScope: "system",
52137
+ addonId: null,
52138
+ access: "create"
52139
+ },
48708
52140
  "turnProvider.getTurnServers": {
48709
52141
  capName: "turn-provider",
48710
52142
  capScope: "system",
@@ -48729,12 +52161,6 @@ Object.freeze({
48729
52161
  addonId: null,
48730
52162
  access: "create"
48731
52163
  },
48732
- "userManagement.createApiKey": {
48733
- capName: "user-management",
48734
- capScope: "system",
48735
- addonId: null,
48736
- access: "create"
48737
- },
48738
52164
  "userManagement.createScopedToken": {
48739
52165
  capName: "user-management",
48740
52166
  capScope: "system",
@@ -48771,12 +52197,6 @@ Object.freeze({
48771
52197
  addonId: null,
48772
52198
  access: "view"
48773
52199
  },
48774
- "userManagement.linkExternalIdentity": {
48775
- capName: "user-management",
48776
- capScope: "system",
48777
- addonId: null,
48778
- access: "create"
48779
- },
48780
52200
  "userManagement.listApiKeys": {
48781
52201
  capName: "user-management",
48782
52202
  capScope: "system",
@@ -48879,12 +52299,6 @@ Object.freeze({
48879
52299
  addonId: null,
48880
52300
  access: "create"
48881
52301
  },
48882
- "userManagement.validateApiKey": {
48883
- capName: "user-management",
48884
- capScope: "system",
48885
- addonId: null,
48886
- access: "view"
48887
- },
48888
52302
  "userManagement.validateCredentials": {
48889
52303
  capName: "user-management",
48890
52304
  capScope: "system",
@@ -51972,6 +55386,11 @@ Object.freeze({
51972
55386
  form: "single",
51973
55387
  optional: false
51974
55388
  }],
55389
+ "pipelineAnalytics.addRetrainFrameFromRecording": [{
55390
+ name: "deviceId",
55391
+ form: "single",
55392
+ optional: false
55393
+ }],
51975
55394
  "pipelineAnalytics.applyDeviceSettingsPatch": [{
51976
55395
  name: "deviceId",
51977
55396
  form: "single",
@@ -52162,6 +55581,11 @@ Object.freeze({
52162
55581
  form: "single",
52163
55582
  optional: false
52164
55583
  }],
55584
+ "pipelineAnalytics.proposeRetrainAnnotationsWithLlm": [{
55585
+ name: "deviceId",
55586
+ form: "single",
55587
+ optional: false
55588
+ }],
52165
55589
  "pipelineAnalytics.pruneEventsBefore": [{
52166
55590
  name: "deviceId",
52167
55591
  form: "single",
@@ -52988,6 +56412,11 @@ Object.freeze({
52988
56412
  form: "single",
52989
56413
  optional: false
52990
56414
  }],
56415
+ "training.canaryResult": [{
56416
+ name: "deviceIds",
56417
+ form: "array",
56418
+ optional: false
56419
+ }],
52991
56420
  "update.getStatus": [{
52992
56421
  name: "deviceId",
52993
56422
  form: "single",