@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,5 +1,5 @@
1
1
  require("node:crypto");
2
- //#region ../types/dist/event-category-B_0XEcLF.mjs
2
+ //#region ../types/dist/event-category-DaIZi00R.mjs
3
3
  var EventCategory = /* @__PURE__ */ function(EventCategory) {
4
4
  EventCategory["SystemBoot"] = "system.boot";
5
5
  EventCategory["SystemAddonsReady"] = "system.addons-ready";
@@ -78,6 +78,13 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
78
78
  */
79
79
  EventCategory["AddonLoadFailed"] = "addon.load-failed";
80
80
  /**
81
+ * A keychain value was stored or removed (D787). Carries the ref, its
82
+ * owner and the new version — NEVER the value. A process holding the ref
83
+ * drops its cached copy and the owning `BaseAddon` re-resolves its config.
84
+ * Telemetry (D8): a process that misses it still revalidates by version.
85
+ */
86
+ EventCategory["KeychainChanged"] = "keychain.changed";
87
+ /**
81
88
  * Addon recovered from a previous failure. Emitted when an addon
82
89
  * transitions from `failed` back to `healthy` (typically via the
83
90
  * monitor's auto-retry loop, or after manual `addons.retryLoad`).
@@ -5370,7 +5377,7 @@ var ZodIssueCode = {
5370
5377
  var ZodFirstPartyTypeKind;
5371
5378
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
5372
5379
  //#endregion
5373
- //#region ../types/dist/sleep-B0JG7-_F.mjs
5380
+ //#region ../types/dist/sleep-r3RWkGVx.mjs
5374
5381
  /**
5375
5382
  * The audio chunk plane's byte format, and the ONE expansion from a coded
5376
5383
  * window to float samples (D455).
@@ -5449,6 +5456,97 @@ function buildAlawTable() {
5449
5456
  }
5450
5457
  buildUlawTable();
5451
5458
  buildAlawTable();
5459
+ /** Is this field's stored value a credential? */
5460
+ function isSecretConfigField(field) {
5461
+ if (field.type === "password") return true;
5462
+ return "secret" in field && field.secret === true;
5463
+ }
5464
+ /**
5465
+ * Is this field's value stored in the KEYCHAIN (D787)? Every secret field is,
5466
+ * by its TYPE, unless it opts out with `storage: 'inline'` — never by its name.
5467
+ */
5468
+ function isKeychainStoredField(field) {
5469
+ if (!isSecretConfigField(field)) return false;
5470
+ if (field.type === "textarea" && field.isJson === true) return false;
5471
+ return !("storage" in field && field.storage === "inline");
5472
+ }
5473
+ /**
5474
+ * What a settings blob holds where a secret used to be.
5475
+ *
5476
+ * A keychain-stored field never holds its value. It holds a self-describing
5477
+ * MARKER, `{"$secret":"secret://…","v":1}` — an object, never a string, so no
5478
+ * code can mistake it for a credential and no form can send it to a camera as
5479
+ * a password. The empty state is `null` / absent, never `''`.
5480
+ *
5481
+ * The same shapes travel to and from the admin UI:
5482
+ *
5483
+ * - read: `hydrateSchema` hands a secret field a {@link SecretFieldView}
5484
+ * (`{ $secret, v, set: true }`) or `null` — the browser learns whether a
5485
+ * value is set, never the value.
5486
+ * - write: an untouched field submits the view back unchanged (KEEP); a typed
5487
+ * value is a plain non-empty string (CHANGE); the Clear button submits
5488
+ * {@link SECRET_CLEAR} (CLEAR). `''`, `null` and the legacy redaction tokens
5489
+ * are KEEP — an empty string is what a defaults-fallback pushes back, and
5490
+ * treating it as "clear" is how a save destroyed a stored credential before.
5491
+ *
5492
+ * Pure and browser-safe.
5493
+ */
5494
+ var SECRET_CLEAR = { $secretClear: true };
5495
+ /** The `'***'` token D634 redaction writes for non-admins. */
5496
+ var LEGACY_DEVICE_REDACTION = "***";
5497
+ function isRecord$2(value) {
5498
+ return typeof value === "object" && value !== null && !Array.isArray(value);
5499
+ }
5500
+ function makeSecretMarker(ref) {
5501
+ return {
5502
+ $secret: ref,
5503
+ v: 1
5504
+ };
5505
+ }
5506
+ /** A stored marker: an object whose `$secret` is a non-empty string. */
5507
+ function isSecretMarker(value) {
5508
+ if (!isRecord$2(value)) return false;
5509
+ const ref = value["$secret"];
5510
+ return typeof ref === "string" && ref.length > 0;
5511
+ }
5512
+ function isSecretClear(value) {
5513
+ return isRecord$2(value) && value["$secretClear"] === true;
5514
+ }
5515
+ /**
5516
+ * The UI view of a stored secret field value: a marker becomes "set", inline
5517
+ * plaintext becomes "set (inline)", nothing becomes `null`. A value never
5518
+ * survives this function.
5519
+ */
5520
+ function toSecretFieldView(stored) {
5521
+ if (isSecretMarker(stored)) return {
5522
+ $secret: stored.$secret,
5523
+ v: 1,
5524
+ set: true
5525
+ };
5526
+ if (typeof stored === "string" && stored.length > 0) return {
5527
+ $secret: null,
5528
+ v: 1,
5529
+ set: true,
5530
+ inline: true
5531
+ };
5532
+ return null;
5533
+ }
5534
+ /**
5535
+ * Classify an incoming value for a secret path. Only a non-empty string that is
5536
+ * not a redaction token sets a value; only {@link SECRET_CLEAR} clears.
5537
+ * Everything else — a marker (ours or anyone's), a UI view, `''`, `null`,
5538
+ * `undefined`, a redaction token, a non-string — keeps what is stored.
5539
+ */
5540
+ function classifySecretWrite(incoming) {
5541
+ if (isSecretClear(incoming)) return { kind: "clear" };
5542
+ if (typeof incoming !== "string") return { kind: "keep" };
5543
+ if (incoming.length === 0) return { kind: "keep" };
5544
+ if (incoming === "__camstack_redacted__" || incoming === LEGACY_DEVICE_REDACTION) return { kind: "keep" };
5545
+ return {
5546
+ kind: "set",
5547
+ value: incoming
5548
+ };
5549
+ }
5452
5550
  Object.fromEntries([
5453
5551
  {
5454
5552
  id: "overview",
@@ -5620,33 +5718,19 @@ Object.fromEntries([
5620
5718
  function isValuelessField(field) {
5621
5719
  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";
5622
5720
  }
5623
- /**
5624
- * Merge a `ConfigUISchema` with a raw `values` record into a
5625
- * `ConfigUISchemaWithValues`. Used by every `get*Settings` backend endpoint
5626
- * before returning to the admin UI. Groups are walked recursively.
5627
- *
5628
- * For each leaf field:
5629
- * - structural fields (`separator`, `info`, `button`) pass through unchanged
5630
- * - other fields get `value = values[key] ?? field.default ?? null`
5631
- *
5632
- * Unknown keys in `values` (keys not declared in the schema) are silently
5633
- * ignored — they don't contribute to the output. Missing keys fall back to
5634
- * the schema default or `null`. This mirrors the old backend behaviour where
5635
- * `FormBuilder` rendered `values[key] ?? field.default`.
5636
- */
5637
- function hydrateSchema(schema, values) {
5721
+ function hydrateSchema(schema, values, options = {}) {
5638
5722
  return {
5639
5723
  ...schema.tabs ? { tabs: [...schema.tabs] } : {},
5640
5724
  sections: schema.sections.map((section) => ({
5641
5725
  ...section,
5642
- fields: section.fields.map((field) => hydrateField(field, values))
5726
+ fields: section.fields.map((field) => hydrateField(field, values, options))
5643
5727
  }))
5644
5728
  };
5645
5729
  }
5646
- function hydrateField(field, values) {
5730
+ function hydrateField(field, values, options) {
5647
5731
  if (isValuelessField(field)) return field;
5648
5732
  if (field.type === "group") {
5649
- const hydratedChildren = field.fields.map((child) => hydrateField(child, values));
5733
+ const hydratedChildren = field.fields.map((child) => hydrateField(child, values, options));
5650
5734
  return {
5651
5735
  ...field,
5652
5736
  fields: hydratedChildren
@@ -5655,7 +5739,7 @@ function hydrateField(field, values) {
5655
5739
  if (field.type === "sub-tabs") {
5656
5740
  const hydratedTabs = field.tabs.map((tab) => ({
5657
5741
  ...tab,
5658
- fields: tab.fields.map((child) => hydrateField(child, values))
5742
+ fields: tab.fields.map((child) => hydrateField(child, values, options))
5659
5743
  }));
5660
5744
  return {
5661
5745
  ...field,
@@ -5665,6 +5749,33 @@ function hydrateField(field, values) {
5665
5749
  const key = field.key;
5666
5750
  const storedValue = Object.prototype.hasOwnProperty.call(values, key) ? values[key] : void 0;
5667
5751
  const defaultValue = field.default;
5752
+ const asView = (v) => isSecretMarker(v) || options.inlineSecretsAsViews === true && v !== void 0;
5753
+ if (isKeychainStoredField(field) && asView(storedValue)) return {
5754
+ ...field,
5755
+ value: toSecretFieldView(storedValue)
5756
+ };
5757
+ if (isKeychainStoredField(field) && options.inlineSecretsAsViews === true) return {
5758
+ ...field,
5759
+ value: null
5760
+ };
5761
+ if (field.type === "editable-array" && Array.isArray(storedValue)) {
5762
+ const secretItemKeys = field.itemFields.filter((item) => "key" in item && isKeychainStoredField(item)).map((item) => "key" in item ? item.key : "");
5763
+ if (secretItemKeys.length > 0) {
5764
+ const rows = storedValue.map((row) => {
5765
+ if (row === null || typeof row !== "object" || Array.isArray(row)) return row;
5766
+ const out = { ...row };
5767
+ for (const k of secretItemKeys) {
5768
+ const v = Reflect.get(row, k);
5769
+ if (asView(v)) out[k] = toSecretFieldView(v);
5770
+ }
5771
+ return out;
5772
+ });
5773
+ return {
5774
+ ...field,
5775
+ value: rows
5776
+ };
5777
+ }
5778
+ }
5668
5779
  if (field.multiple) {
5669
5780
  const stored = Array.isArray(storedValue) ? storedValue : storedValue !== void 0 && storedValue !== null ? [storedValue] : [];
5670
5781
  const itemFallback = field.multiple.itemDefault !== void 0 ? field.multiple.itemDefault : defaultValue !== void 0 ? defaultValue : typeOf(field) === "string" ? "" : null;
@@ -5907,6 +6018,778 @@ function projectStore(store, perNodeKeys, nodeId) {
5907
6018
  }
5908
6019
  return out;
5909
6020
  }
6021
+ var GLOBAL_SCOPE = { kind: "global" };
6022
+ /** The scope every addon-wide (not per-node, not per-device) setting lives in. */
6023
+ function globalSecretScope() {
6024
+ return GLOBAL_SCOPE;
6025
+ }
6026
+ function encodeSegment(value) {
6027
+ return encodeURIComponent(value);
6028
+ }
6029
+ function decodeSegment(value) {
6030
+ try {
6031
+ return decodeURIComponent(value);
6032
+ } catch {
6033
+ return null;
6034
+ }
6035
+ }
6036
+ /**
6037
+ * The field path of a value inside an array item, addressed by the item's id:
6038
+ * `arrayItemFieldPath('providers', 'authentik', 'clientSecret')` →
6039
+ * `providers[authentik].clientSecret`.
6040
+ */
6041
+ function arrayItemFieldPath(arrayKey, itemId, fieldKey) {
6042
+ return `${arrayKey}[${encodeSegment(itemId)}].${fieldKey}`;
6043
+ }
6044
+ function parseScope(segments) {
6045
+ switch (segments[0]) {
6046
+ case "global": return {
6047
+ scope: GLOBAL_SCOPE,
6048
+ used: 1
6049
+ };
6050
+ case "node": {
6051
+ const nodeId = segments[1] !== void 0 ? decodeSegment(segments[1]) : null;
6052
+ return nodeId === null || nodeId.length === 0 ? null : {
6053
+ scope: {
6054
+ kind: "node",
6055
+ nodeId
6056
+ },
6057
+ used: 2
6058
+ };
6059
+ }
6060
+ case "device": {
6061
+ const raw = segments[1];
6062
+ if (raw === void 0 || !/^\d+$/.test(raw)) return null;
6063
+ return {
6064
+ scope: {
6065
+ kind: "device",
6066
+ deviceId: Number(raw)
6067
+ },
6068
+ used: 2
6069
+ };
6070
+ }
6071
+ case "integration": {
6072
+ const id = segments[1] !== void 0 ? decodeSegment(segments[1]) : null;
6073
+ return id === null || id.length === 0 ? null : {
6074
+ scope: {
6075
+ kind: "integration",
6076
+ integrationId: id
6077
+ },
6078
+ used: 2
6079
+ };
6080
+ }
6081
+ case "row": {
6082
+ const collection = segments[1] !== void 0 ? decodeSegment(segments[1]) : null;
6083
+ const rowId = segments[2] !== void 0 ? decodeSegment(segments[2]) : null;
6084
+ if (collection === null || rowId === null || collection.length === 0 || rowId.length === 0) return null;
6085
+ return {
6086
+ scope: {
6087
+ kind: "row",
6088
+ collection,
6089
+ rowId
6090
+ },
6091
+ used: 3
6092
+ };
6093
+ }
6094
+ default: return null;
6095
+ }
6096
+ }
6097
+ /** Take a ref apart; `null` when it is not a well-formed ref. */
6098
+ function parseSecretRef(ref) {
6099
+ if (!ref.startsWith("secret://")) return null;
6100
+ const segments = ref.slice(9).split("/");
6101
+ const owner = segments[0] !== void 0 ? decodeSegment(segments[0]) : null;
6102
+ if (owner === null || owner.length === 0) return null;
6103
+ const parsed = parseScope(segments.slice(1));
6104
+ if (parsed === null) return null;
6105
+ const fieldPath = segments.slice(1 + parsed.used).join("/");
6106
+ if (fieldPath.length === 0) return null;
6107
+ return {
6108
+ owner,
6109
+ scope: parsed.scope,
6110
+ fieldPath
6111
+ };
6112
+ }
6113
+ /** A write to a secret path could not be stored in the keychain, so it was refused. */
6114
+ var KeychainWriteRefusedError = class extends Error {
6115
+ fieldPath;
6116
+ constructor(fieldPath, cause) {
6117
+ super(`secret "${fieldPath}" was not saved: the keychain could not store it (${cause instanceof Error ? cause.message : String(cause)}). Nothing was written.`);
6118
+ this.fieldPath = fieldPath;
6119
+ this.name = "KeychainWriteRefusedError";
6120
+ }
6121
+ };
6122
+ var KEEP = { kind: "keep" };
6123
+ function isRecord$1(value) {
6124
+ return typeof value === "object" && value !== null && !Array.isArray(value);
6125
+ }
6126
+ function defaultMintId() {
6127
+ return globalThis.crypto.randomUUID();
6128
+ }
6129
+ /** Every marker ref anywhere under `value`. */
6130
+ function collectSecretMarkerRefs(value, out = []) {
6131
+ if (isSecretMarker(value)) {
6132
+ out.push(value.$secret);
6133
+ return out;
6134
+ }
6135
+ if (Array.isArray(value)) for (const item of value) collectSecretMarkerRefs(item, out);
6136
+ else if (isRecord$1(value)) for (const child of Object.values(value)) collectSecretMarkerRefs(child, out);
6137
+ return out;
6138
+ }
6139
+ async function storedValueEquals(secrets, marker, candidate) {
6140
+ const resolved = (await secrets.resolve([marker.$secret]))[marker.$secret];
6141
+ return resolved?.kind === "value" && resolved.value === candidate;
6142
+ }
6143
+ async function writeLeaf(ctx, incoming, stored, fieldPath) {
6144
+ const intent = classifySecretWrite(incoming);
6145
+ const ref = ctx.secrets.ref(ctx.scope, fieldPath);
6146
+ const storedIsOurs = isSecretMarker(stored) && stored.$secret === ref;
6147
+ if (intent.kind === "keep") return KEEP;
6148
+ if (intent.kind === "set" && !ctx.operatorWrite && typeof stored === "string" && stored === intent.value) return KEEP;
6149
+ if (intent.kind === "clear") {
6150
+ if (storedIsOurs) ctx.deletes.push(ref);
6151
+ return {
6152
+ kind: "value",
6153
+ value: null
6154
+ };
6155
+ }
6156
+ if (storedIsOurs && await storedValueEquals(ctx.secrets, stored, intent.value)) return {
6157
+ kind: "value",
6158
+ value: stored
6159
+ };
6160
+ try {
6161
+ await ctx.secrets.put(ref, intent.value);
6162
+ } catch (err) {
6163
+ throw new KeychainWriteRefusedError(fieldPath, err);
6164
+ }
6165
+ return {
6166
+ kind: "value",
6167
+ value: makeSecretMarker(ref)
6168
+ };
6169
+ }
6170
+ /** Apply a member result onto `out`: KEEP restores the stored member, or removes it. */
6171
+ function applyMember(out, key, result, storedParent) {
6172
+ if (result.kind === "value") {
6173
+ out[key] = result.value;
6174
+ return;
6175
+ }
6176
+ if (Object.prototype.hasOwnProperty.call(storedParent, key)) out[key] = storedParent[key];
6177
+ else delete out[key];
6178
+ }
6179
+ async function writeMembers(ctx, children, incoming, stored, pathOf) {
6180
+ const out = { ...incoming };
6181
+ for (const [member, node] of children) applyMember(out, member, await writeNode(ctx, node, incoming[member], stored[member], pathOf(member)), stored);
6182
+ return out;
6183
+ }
6184
+ function rowId(row, idKey) {
6185
+ const raw = row[idKey];
6186
+ if (typeof raw === "string" && raw.length > 0) return raw;
6187
+ if (typeof raw === "number" && Number.isFinite(raw)) return String(raw);
6188
+ return null;
6189
+ }
6190
+ async function writeArray(ctx, node, incoming, stored, fieldPath) {
6191
+ const storedRows = Array.isArray(stored) ? stored.filter(isRecord$1) : [];
6192
+ if (!Array.isArray(incoming)) {
6193
+ ctx.deletes.push(...collectSecretMarkerRefs(storedRows));
6194
+ return {
6195
+ kind: "value",
6196
+ value: incoming
6197
+ };
6198
+ }
6199
+ const storedById = /* @__PURE__ */ new Map();
6200
+ for (const row of storedRows) {
6201
+ const id = rowId(row, node.idKey);
6202
+ if (id !== null) storedById.set(id, row);
6203
+ }
6204
+ const kept = /* @__PURE__ */ new Set();
6205
+ const rows = [];
6206
+ for (const row of incoming) {
6207
+ if (!isRecord$1(row)) {
6208
+ rows.push(row);
6209
+ continue;
6210
+ }
6211
+ const id = rowId(row, node.idKey) ?? ctx.mintId();
6212
+ kept.add(id);
6213
+ const withId = {
6214
+ ...row,
6215
+ [node.idKey]: row[node.idKey] ?? id
6216
+ };
6217
+ if (rowId(withId, node.idKey) === null) withId[node.idKey] = id;
6218
+ const storedRow = storedById.get(id) ?? {};
6219
+ rows.push(await writeMembers(ctx, node.item, withId, storedRow, (member) => arrayItemFieldPath(fieldPath, id, member)));
6220
+ }
6221
+ for (const [id, row] of storedById) if (!kept.has(id)) ctx.deletes.push(...collectSecretMarkerRefs(row));
6222
+ return {
6223
+ kind: "value",
6224
+ value: rows
6225
+ };
6226
+ }
6227
+ async function writeNode(ctx, node, incoming, stored, fieldPath) {
6228
+ switch (node.kind) {
6229
+ case "leaf": return writeLeaf(ctx, incoming, stored, fieldPath);
6230
+ case "array": return writeArray(ctx, node, incoming, stored, fieldPath);
6231
+ case "object": {
6232
+ if (!isRecord$1(incoming)) {
6233
+ if (incoming === void 0) return KEEP;
6234
+ ctx.deletes.push(...collectSecretMarkerRefs(stored));
6235
+ return {
6236
+ kind: "value",
6237
+ value: incoming
6238
+ };
6239
+ }
6240
+ const storedObj = isRecord$1(stored) ? stored : {};
6241
+ return {
6242
+ kind: "value",
6243
+ value: await writeMembers(ctx, node.children, incoming, storedObj, (m) => `${fieldPath}.${m}`)
6244
+ };
6245
+ }
6246
+ }
6247
+ }
6248
+ /** Split a perNode-scoped key (`key@nodeId`). */
6249
+ function splitNodeKey(key) {
6250
+ const at = key.indexOf("@");
6251
+ return at <= 0 ? {
6252
+ base: key,
6253
+ nodeId: null
6254
+ } : {
6255
+ base: key.slice(0, at),
6256
+ nodeId: key.slice(at + 1)
6257
+ };
6258
+ }
6259
+ /** Rewrite a settings patch so no secret value reaches the blob. See the file doc. */
6260
+ async function transformSecretWrite(input) {
6261
+ const deletes = [];
6262
+ const base = {
6263
+ secrets: input.secrets,
6264
+ mintId: input.mintId ?? defaultMintId,
6265
+ deletes,
6266
+ operatorWrite: input.operatorWrite === true
6267
+ };
6268
+ const out = {};
6269
+ for (const [key, incoming] of Object.entries(input.patch)) {
6270
+ const { base: baseKey, nodeId } = splitNodeKey(key);
6271
+ const node = input.tree.get(baseKey);
6272
+ if (node === void 0) {
6273
+ out[key] = incoming;
6274
+ continue;
6275
+ }
6276
+ const scope = nodeId !== null && nodeId.length > 0 ? {
6277
+ kind: "node",
6278
+ nodeId
6279
+ } : input.scope ?? globalSecretScope();
6280
+ const result = await writeNode({
6281
+ ...base,
6282
+ scope
6283
+ }, node, incoming, input.stored[key], baseKey);
6284
+ if (result.kind === "value") out[key] = result.value;
6285
+ }
6286
+ return {
6287
+ patch: out,
6288
+ afterWrite: async () => {
6289
+ if (deletes.length === 0) return { orphaned: [] };
6290
+ try {
6291
+ await input.secrets.delete([...new Set(deletes)]);
6292
+ return { orphaned: [] };
6293
+ } catch {
6294
+ return { orphaned: [...new Set(deletes)] };
6295
+ }
6296
+ }
6297
+ };
6298
+ }
6299
+ /** Is `ref` one of `owner`'s refs? */
6300
+ function isSecretRefOwnedBy(ref, owner) {
6301
+ return parseSecretRef(ref)?.owner === owner;
6302
+ }
6303
+ /**
6304
+ * Replace every marker in `value` with its keychain value. Returns the SAME
6305
+ * reference when there is no marker (no allocation, no keychain call).
6306
+ */
6307
+ async function resolveSecretMarkers(value, secrets, options = {}) {
6308
+ const keepMarker = options.unresolved === "keep-marker";
6309
+ const owner = options.ownedBy;
6310
+ const inScope = (ref) => owner === void 0 || isSecretRefOwnedBy(ref, owner);
6311
+ const refs = collectSecretMarkerRefs(value).filter(inScope);
6312
+ if (refs.length === 0) return {
6313
+ value,
6314
+ unresolved: []
6315
+ };
6316
+ const answers = await secrets.resolve(refs);
6317
+ const unresolved = [];
6318
+ for (const ref of new Set(refs)) {
6319
+ const answer = answers[ref];
6320
+ if (answer === void 0) unresolved.push({
6321
+ ref,
6322
+ reason: "not-initialized"
6323
+ });
6324
+ else if (answer.kind === "unavailable") unresolved.push({
6325
+ ref,
6326
+ reason: answer.reason
6327
+ });
6328
+ else if (answer.kind === "missing" || answer.kind === "forbidden") unresolved.push({
6329
+ ref,
6330
+ reason: answer.kind
6331
+ });
6332
+ }
6333
+ const substitute = (v) => {
6334
+ if (isSecretMarker(v)) {
6335
+ if (!inScope(v.$secret)) return {
6336
+ keep: true,
6337
+ value: v
6338
+ };
6339
+ const answer = answers[v.$secret];
6340
+ if (answer?.kind === "value") return {
6341
+ keep: true,
6342
+ value: answer.value
6343
+ };
6344
+ return keepMarker ? {
6345
+ keep: true,
6346
+ value: v
6347
+ } : {
6348
+ keep: false,
6349
+ value: void 0
6350
+ };
6351
+ }
6352
+ if (Array.isArray(v)) {
6353
+ const items = [];
6354
+ for (const item of v) {
6355
+ const s = substitute(item);
6356
+ if (s.keep) items.push(s.value);
6357
+ }
6358
+ return {
6359
+ keep: true,
6360
+ value: items
6361
+ };
6362
+ }
6363
+ if (isRecord$1(v)) {
6364
+ const out = {};
6365
+ for (const [k, child] of Object.entries(v)) {
6366
+ const s = substitute(child);
6367
+ if (s.keep) out[k] = s.value;
6368
+ }
6369
+ return {
6370
+ keep: true,
6371
+ value: out
6372
+ };
6373
+ }
6374
+ return {
6375
+ keep: true,
6376
+ value: v
6377
+ };
6378
+ };
6379
+ return {
6380
+ value: substitute(value).value,
6381
+ unresolved
6382
+ };
6383
+ }
6384
+ /** An addon tried to replace a stored secret it could not read. Nothing was written. */
6385
+ var SecretOverwriteRefusedError = class extends Error {
6386
+ ref;
6387
+ reason;
6388
+ constructor(ref, reason) {
6389
+ 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.`);
6390
+ this.ref = ref;
6391
+ this.reason = reason;
6392
+ this.name = "SecretOverwriteRefusedError";
6393
+ }
6394
+ };
6395
+ function isRecord(value) {
6396
+ return typeof value === "object" && value !== null && !Array.isArray(value);
6397
+ }
6398
+ function resolvedValue(pass, marker) {
6399
+ const answer = pass.answers[marker.$secret];
6400
+ return answer?.kind === "value" ? answer.value : null;
6401
+ }
6402
+ async function atMarker(pass, incoming, stored) {
6403
+ if (incoming === null) return stored;
6404
+ if (typeof incoming !== "string") return incoming;
6405
+ if (incoming === resolvedValue(pass, stored)) return stored;
6406
+ const intent = classifySecretWrite(incoming);
6407
+ if (intent.kind !== "set") return stored;
6408
+ const ref = stored.$secret;
6409
+ if (!isSecretRefOwnedBy(ref, pass.secrets.owner)) return incoming;
6410
+ const answer = pass.answers[ref];
6411
+ 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);
6412
+ try {
6413
+ await pass.secrets.put(ref, intent.value);
6414
+ } catch (err) {
6415
+ throw new KeychainWriteRefusedError(ref, err);
6416
+ }
6417
+ pass.changedRefs.push(ref);
6418
+ return stored;
6419
+ }
6420
+ function inArray(pass, incoming, stored) {
6421
+ return incoming.map((item, index) => {
6422
+ const twin = stored[index];
6423
+ if (isSecretMarker(twin)) return typeof item === "string" && item === resolvedValue(pass, twin) ? twin : item;
6424
+ if (isRecord(item) && isRecord(twin)) return inArrayRow(pass, item, twin);
6425
+ if (Array.isArray(item) && Array.isArray(twin)) return inArray(pass, item, twin);
6426
+ return item;
6427
+ });
6428
+ }
6429
+ function inArrayRow(pass, incoming, stored) {
6430
+ const out = { ...incoming };
6431
+ for (const [key, value] of Object.entries(incoming)) {
6432
+ const twin = stored[key];
6433
+ if (isSecretMarker(twin)) {
6434
+ if (typeof value === "string" && value === resolvedValue(pass, twin)) out[key] = twin;
6435
+ } else if (isRecord(value) && isRecord(twin)) out[key] = inArrayRow(pass, value, twin);
6436
+ else if (Array.isArray(value) && Array.isArray(twin)) out[key] = inArray(pass, value, twin);
6437
+ }
6438
+ return out;
6439
+ }
6440
+ async function walk(pass, incoming, stored) {
6441
+ if (isSecretMarker(stored)) return atMarker(pass, incoming, stored);
6442
+ if (Array.isArray(incoming) && Array.isArray(stored)) return inArray(pass, incoming, stored);
6443
+ if (!isRecord(incoming) || !isRecord(stored)) return incoming;
6444
+ const out = { ...incoming };
6445
+ for (const [key, value] of Object.entries(incoming)) out[key] = await walk(pass, value, stored[key]);
6446
+ return out;
6447
+ }
6448
+ /** Restore markers a write-back carries as values. See the file doc. */
6449
+ async function restoreUnchangedSecrets(input) {
6450
+ const refs = [];
6451
+ for (const key of Object.keys(input.patch)) collectSecretMarkerRefs(input.stored[key], refs);
6452
+ const owned = refs.filter((ref) => isSecretRefOwnedBy(ref, input.secrets.owner));
6453
+ if (owned.length === 0) return {
6454
+ patch: input.patch,
6455
+ changedRefs: []
6456
+ };
6457
+ const pass = {
6458
+ secrets: input.secrets,
6459
+ answers: await input.secrets.resolve([...new Set(owned)]),
6460
+ operatorWrite: input.operatorWrite,
6461
+ changedRefs: []
6462
+ };
6463
+ const out = {};
6464
+ for (const [key, value] of Object.entries(input.patch)) out[key] = await walk(pass, value, input.stored[key]);
6465
+ return {
6466
+ patch: out,
6467
+ changedRefs: pass.changedRefs
6468
+ };
6469
+ }
6470
+ /** Structural equality over JSON-shaped values (key order does not matter). */
6471
+ function isJsonEqual(a, b) {
6472
+ if (Object.is(a, b)) return true;
6473
+ if (Array.isArray(a)) return Array.isArray(b) && a.length === b.length && a.every((v, i) => isJsonEqual(v, b[i]));
6474
+ if (isRecord(a) && isRecord(b)) {
6475
+ const keys = Object.keys(a);
6476
+ if (keys.length !== Object.keys(b).length) return false;
6477
+ return keys.every((k) => Object.prototype.hasOwnProperty.call(b, k) && isJsonEqual(a[k], b[k]));
6478
+ }
6479
+ return false;
6480
+ }
6481
+ /** The patch without the keys whose value already equals the stored one. */
6482
+ function dropUnchangedKeys(patch, stored) {
6483
+ const out = {};
6484
+ for (const [key, value] of Object.entries(patch)) {
6485
+ if (Object.prototype.hasOwnProperty.call(stored, key) && isJsonEqual(value, stored[key])) continue;
6486
+ out[key] = value;
6487
+ }
6488
+ return out;
6489
+ }
6490
+ /** The top-level keys of a blob that hold at least one of `owner`'s markers. */
6491
+ function markerKeysOf(blob, owner) {
6492
+ const keys = /* @__PURE__ */ new Set();
6493
+ for (const [key, value] of Object.entries(blob)) if (collectSecretMarkerRefs(value).some((ref) => isSecretRefOwnedBy(ref, owner))) keys.add(key);
6494
+ return keys;
6495
+ }
6496
+ function nodeFromStored(value, owner) {
6497
+ if (isSecretMarker(value)) return isSecretRefOwnedBy(value.$secret, owner) ? { kind: "leaf" } : null;
6498
+ if (!isRecord(value)) return null;
6499
+ const children = /* @__PURE__ */ new Map();
6500
+ for (const [key, child] of Object.entries(value)) {
6501
+ const node = nodeFromStored(child, owner);
6502
+ if (node !== null) children.set(key, node);
6503
+ }
6504
+ return children.size > 0 ? {
6505
+ kind: "object",
6506
+ children
6507
+ } : null;
6508
+ }
6509
+ /**
6510
+ * The declared secret tree, widened by every place the STORED blob holds a
6511
+ * marker under one of `keys` — so a marker the schema no longer declares (or
6512
+ * never declared: Wyze before b4906cec6) still gets the save path's
6513
+ * KEEP / SET / CLEAR semantics instead of being overwritten by whatever the
6514
+ * addon writes. Markers inside arrays are not added: a row has no id field to
6515
+ * match by unless the schema declares one. Only `owner`'s markers count: a
6516
+ * builtin that keeps another addon's marker (device-manager) never takes it
6517
+ * over.
6518
+ */
6519
+ function widenTreeWithStoredMarkers(declared, stored, keys, owner) {
6520
+ const added = /* @__PURE__ */ new Map();
6521
+ for (const key of keys) {
6522
+ const at = key.indexOf("@");
6523
+ const base = at > 0 ? key.slice(0, at) : key;
6524
+ if (declared.has(base) || added.has(base)) continue;
6525
+ const node = nodeFromStored(stored[key], owner);
6526
+ if (node !== null) added.set(base, node);
6527
+ }
6528
+ return added.size === 0 ? declared : new Map([...declared, ...added]);
6529
+ }
6530
+ /** The blob as stored now; a failed read REFUSES the write instead of guessing. */
6531
+ async function readStoredAddonBlob(raw) {
6532
+ const threeWay = raw.readAddonStoreResult;
6533
+ if (threeWay === void 0) return raw.readAddonStore();
6534
+ const result = await threeWay.call(raw);
6535
+ if (result.kind === "failed") throw new Error(`settings write refused: the stored blob could not be read (${result.error})`);
6536
+ return result.kind === "missing" ? {} : result.value;
6537
+ }
6538
+ function touchesTree(tree, patch) {
6539
+ if (tree.size === 0) return false;
6540
+ for (const key of Object.keys(patch)) {
6541
+ const at = key.indexOf("@");
6542
+ if (tree.has(at > 0 ? key.slice(0, at) : key)) return true;
6543
+ }
6544
+ return false;
6545
+ }
6546
+ /**
6547
+ * Which top-level keys of each store held markers when last seen. `undefined`
6548
+ * for a store not seen yet: its first write reads it, to be safe.
6549
+ */
6550
+ var MarkerKeyIndex = class {
6551
+ owner;
6552
+ byStore = /* @__PURE__ */ new Map();
6553
+ constructor(owner) {
6554
+ this.owner = owner;
6555
+ }
6556
+ seen(store, blob) {
6557
+ this.byStore.set(store, markerKeysOf(blob, this.owner));
6558
+ }
6559
+ wrote(store, patch) {
6560
+ const keys = this.byStore.get(store);
6561
+ if (keys === void 0) return;
6562
+ const now = markerKeysOf(patch, this.owner);
6563
+ for (const key of Object.keys(patch)) if (now.has(key)) keys.add(key);
6564
+ else keys.delete(key);
6565
+ }
6566
+ mayHoldMarkers(store, patch) {
6567
+ const keys = this.byStore.get(store);
6568
+ if (keys === void 0) return true;
6569
+ return Object.keys(patch).some((key) => keys.has(key));
6570
+ }
6571
+ };
6572
+ function createHandle(raw, opts) {
6573
+ const chains = /* @__PURE__ */ new Map();
6574
+ const serialize = (key, fn) => {
6575
+ const next = (chains.get(key) ?? Promise.resolve()).then(fn, fn);
6576
+ const tail = next.catch(() => void 0);
6577
+ chains.set(key, tail);
6578
+ tail.then(() => {
6579
+ if (chains.get(key) === tail) chains.delete(key);
6580
+ });
6581
+ return next;
6582
+ };
6583
+ const index = new MarkerKeyIndex(opts.secrets.owner);
6584
+ const resolveRead = async (store, blob) => {
6585
+ index.seen(store, blob);
6586
+ const { value, unresolved } = await resolveSecretMarkers(blob, opts.secrets, {
6587
+ unresolved: "keep-marker",
6588
+ ownedBy: opts.secrets.owner
6589
+ });
6590
+ if (unresolved.length > 0) opts.onUnresolved?.(unresolved);
6591
+ return value;
6592
+ };
6593
+ const write = async (store, declared, scope, patch, readStored, rawWrite) => {
6594
+ if (!touchesTree(declared, patch) && !index.mayHoldMarkers(store, patch)) {
6595
+ await rawWrite(patch);
6596
+ index.wrote(store, patch);
6597
+ return { changed: true };
6598
+ }
6599
+ return serialize(store, async () => {
6600
+ const stored = await readStored();
6601
+ index.seen(store, stored);
6602
+ const operatorWrite = opts.isOperatorWrite?.() === true;
6603
+ const restored = await restoreUnchangedSecrets({
6604
+ patch,
6605
+ stored,
6606
+ secrets: opts.secrets,
6607
+ operatorWrite
6608
+ });
6609
+ const result = await transformSecretWrite({
6610
+ tree: widenTreeWithStoredMarkers(declared, stored, Object.keys(restored.patch), opts.secrets.owner),
6611
+ secrets: opts.secrets,
6612
+ patch: restored.patch,
6613
+ stored,
6614
+ ...scope !== void 0 ? { scope } : {},
6615
+ operatorWrite
6616
+ });
6617
+ const effective = dropUnchangedKeys(result.patch, stored);
6618
+ const wroteBlob = Object.keys(effective).length > 0;
6619
+ if (wroteBlob) {
6620
+ await rawWrite(effective);
6621
+ index.wrote(store, effective);
6622
+ }
6623
+ const { orphaned } = await result.afterWrite();
6624
+ if (orphaned.length > 0) opts.onOrphaned(orphaned);
6625
+ return { changed: wroteBlob || restored.changedRefs.length > 0 };
6626
+ });
6627
+ };
6628
+ const writeAddon = (patch) => write("addon", opts.addonTree(), void 0, patch, () => readStoredAddonBlob(raw), (p) => raw.writeAddonStore(p));
6629
+ const readAddonStoreResult = raw.readAddonStoreResult;
6630
+ const readAddonStoreKeyResult = raw.readAddonStoreKeyResult;
6631
+ const readDeviceStoreBatch = raw.readDeviceStoreBatch;
6632
+ const overrides = {
6633
+ readAddonStore: async () => resolveRead("addon", await raw.readAddonStore()),
6634
+ ...readAddonStoreResult !== void 0 ? { readAddonStoreResult: async () => {
6635
+ const result = await readAddonStoreResult.call(raw);
6636
+ return result.kind === "value" ? {
6637
+ kind: "value",
6638
+ value: await resolveRead("addon", result.value)
6639
+ } : result;
6640
+ } } : {},
6641
+ ...readAddonStoreKeyResult !== void 0 ? { readAddonStoreKeyResult: async (key) => {
6642
+ const result = await readAddonStoreKeyResult.call(raw, key);
6643
+ if (result.kind !== "present") return result;
6644
+ const { value, unresolved } = await resolveSecretMarkers({ [key]: result.value }, opts.secrets, {
6645
+ unresolved: "keep-marker",
6646
+ ownedBy: opts.secrets.owner
6647
+ });
6648
+ if (unresolved.length > 0) opts.onUnresolved?.(unresolved);
6649
+ return {
6650
+ kind: "present",
6651
+ value: value[key]
6652
+ };
6653
+ } } : {},
6654
+ readDeviceStore: async (deviceId) => resolveRead(`device:${deviceId}`, await raw.readDeviceStore(deviceId)),
6655
+ ...readDeviceStoreBatch !== void 0 ? { readDeviceStoreBatch: async (deviceIds) => {
6656
+ const rows = await readDeviceStoreBatch.call(raw, deviceIds);
6657
+ const out = /* @__PURE__ */ new Map();
6658
+ for (const [deviceId, blob] of rows) out.set(deviceId, await resolveRead(`device:${deviceId}`, blob));
6659
+ return out;
6660
+ } } : {},
6661
+ writeAddonStore: async (patch) => {
6662
+ await writeAddon(patch);
6663
+ },
6664
+ writeDeviceStore: async (deviceId, patch) => {
6665
+ await write(`device:${deviceId}`, opts.deviceTree(), {
6666
+ kind: "device",
6667
+ deviceId
6668
+ }, patch, () => raw.readDeviceStore(deviceId), (p) => raw.writeDeviceStore(deviceId, p));
6669
+ }
6670
+ };
6671
+ return {
6672
+ settings: new Proxy(raw, { get(target, prop, receiver) {
6673
+ if (typeof prop === "string" && Object.prototype.hasOwnProperty.call(overrides, prop)) return Reflect.get(overrides, prop);
6674
+ const value = Reflect.get(target, prop, receiver);
6675
+ return typeof value === "function" ? value.bind(target) : value;
6676
+ } }),
6677
+ raw: {
6678
+ readAddonStore: async () => {
6679
+ const blob = await raw.readAddonStore();
6680
+ index.seen("addon", blob);
6681
+ return blob;
6682
+ },
6683
+ readDeviceStore: async (deviceId) => {
6684
+ const blob = await raw.readDeviceStore(deviceId);
6685
+ index.seen(`device:${deviceId}`, blob);
6686
+ return blob;
6687
+ }
6688
+ },
6689
+ writeAddonStore: writeAddon
6690
+ };
6691
+ }
6692
+ /** The context the addon sees, plus the private raw view and write outcome. */
6693
+ function createSecretAwareContext(context, opts) {
6694
+ const raw = context.settings;
6695
+ if (raw === void 0) return {
6696
+ context,
6697
+ handle: null
6698
+ };
6699
+ const handle = createHandle(raw, opts);
6700
+ return {
6701
+ context: new Proxy(context, { get(target, prop, receiver) {
6702
+ if (prop === "settings") return handle.settings;
6703
+ return Reflect.get(target, prop, receiver);
6704
+ } }),
6705
+ handle
6706
+ };
6707
+ }
6708
+ var LEAF = { kind: "leaf" };
6709
+ var DEFAULT_ITEM_ID_KEY = "id";
6710
+ function collectFields(fields, out) {
6711
+ for (const field of fields) {
6712
+ if (field.type === "group") {
6713
+ collectFields(field.fields, out);
6714
+ continue;
6715
+ }
6716
+ if (field.type === "sub-tabs") {
6717
+ for (const tab of field.tabs) collectFields(tab.fields, out);
6718
+ continue;
6719
+ }
6720
+ if (field.type === "editable-array") {
6721
+ const item = /* @__PURE__ */ new Map();
6722
+ for (const itemField of field.itemFields) if ("key" in itemField && isKeychainStoredField(itemField)) item.set(itemField.key, LEAF);
6723
+ if (item.size > 0) out.set(field.key, {
6724
+ kind: "array",
6725
+ idKey: field.itemIdKey ?? DEFAULT_ITEM_ID_KEY,
6726
+ item
6727
+ });
6728
+ continue;
6729
+ }
6730
+ if (!("key" in field) || typeof field.key !== "string") continue;
6731
+ if (isKeychainStoredField(field)) out.set(field.key, LEAF);
6732
+ }
6733
+ }
6734
+ /** The secret tree a settings schema declares. */
6735
+ function secretTreeFromSchema(schema) {
6736
+ const out = /* @__PURE__ */ new Map();
6737
+ if (schema === null) return out;
6738
+ for (const section of schema.sections) collectFields(section.fields, out);
6739
+ return out;
6740
+ }
6741
+ /** Parse `a.b[id].c` into segments; throws on a malformed path (a declaration bug). */
6742
+ function parseSecretStatePath(path) {
6743
+ const segments = [];
6744
+ for (const raw of path.split(".")) {
6745
+ const m = /^([^[\]]+)(?:\[([^[\]]+)\])?$/.exec(raw);
6746
+ if (m === null || m[1] === void 0) throw new Error(`secretStatePaths: malformed path "${path}"`);
6747
+ segments.push(m[2] !== void 0 ? {
6748
+ key: m[1],
6749
+ idKey: m[2]
6750
+ } : { key: m[1] });
6751
+ }
6752
+ if (segments.length === 0) throw new Error(`secretStatePaths: empty path`);
6753
+ if (segments[segments.length - 1]?.idKey !== void 0) throw new Error(`secretStatePaths: "${path}" ends on an array — name the member that is secret`);
6754
+ return segments;
6755
+ }
6756
+ function insert(into, segments) {
6757
+ const [head, ...rest] = segments;
6758
+ if (head === void 0) return;
6759
+ if (rest.length === 0) {
6760
+ into.set(head.key, LEAF);
6761
+ return;
6762
+ }
6763
+ const existing = into.get(head.key);
6764
+ if (head.idKey !== void 0) {
6765
+ const item = new Map(existing?.kind === "array" ? existing.item : []);
6766
+ insert(item, rest);
6767
+ into.set(head.key, {
6768
+ kind: "array",
6769
+ idKey: head.idKey,
6770
+ item
6771
+ });
6772
+ return;
6773
+ }
6774
+ const children = new Map(existing?.kind === "object" ? existing.children : []);
6775
+ insert(children, rest);
6776
+ into.set(head.key, {
6777
+ kind: "object",
6778
+ children
6779
+ });
6780
+ }
6781
+ /** Add hidden-state paths (`secretStatePaths`) to a schema-derived tree. */
6782
+ function mergeSecretStatePaths(tree, paths) {
6783
+ if (paths.length === 0) return tree;
6784
+ const out = new Map(tree);
6785
+ for (const path of paths) insert(out, parseSecretStatePath(path));
6786
+ return out;
6787
+ }
6788
+ /** First retry of a secret the keychain could not serve; doubles to {@link SECRET_RETRY_MAX_MS}. */
6789
+ var SECRET_RETRY_FIRST_MS = 5e3;
6790
+ var SECRET_RETRY_MAX_MS = 5 * 6e4;
6791
+ /** Coalesces a burst of `keychain.changed` events into one re-resolve. */
6792
+ var SECRET_CHANGE_DEBOUNCE_MS = 250;
5910
6793
  /**
5911
6794
  * Base class for CamStack addons. Eliminates settings boilerplate:
5912
6795
  *
@@ -5976,6 +6859,33 @@ var BaseAddon = class {
5976
6859
  settingsStoreReady = false;
5977
6860
  /** Default config values. Provided via constructor. */
5978
6861
  defaults;
6862
+ /**
6863
+ * Hidden-state paths that hold secrets (D787) — values the addon writes
6864
+ * itself (`updateGlobalSettings`, `state()`) that no form field declares.
6865
+ * Stored in the keychain exactly like a `password` field. Syntax:
6866
+ * `'snapshotSigningKey'`, `'identity.pincode'`, `'tokens[userId].accessToken'`
6867
+ * (`key[<id field>]` addresses array items by id, never by index).
6868
+ */
6869
+ secretStatePaths = [];
6870
+ _addonSecretTree = null;
6871
+ _deviceSecretTree = null;
6872
+ /** Refs the last resolved config pointed at — a change to one re-resolves. */
6873
+ _configSecretRefs = /* @__PURE__ */ new Set();
6874
+ _unresolvedSecrets = [];
6875
+ _secretRetryTimer = null;
6876
+ _secretRetryDelayMs = SECRET_RETRY_FIRST_MS;
6877
+ _secretChangeTimer = null;
6878
+ _secretChangeUnsub = null;
6879
+ /** >0 while an OPERATOR's settings write is being applied. */
6880
+ _operatorWriteDepth = 0;
6881
+ /**
6882
+ * The keychain-aware settings handle (D798). Its `raw` view is the ONLY way
6883
+ * to the marker-bearing blobs and stays private to this class: the form
6884
+ * hydrate and config resolution need markers, addon code never does.
6885
+ */
6886
+ _secretSettings = null;
6887
+ /** Refs an addon-facing read could not resolve — each is logged once per process. */
6888
+ _loggedUnresolvedReads = /* @__PURE__ */ new Set();
5979
6889
  constructor(defaults) {
5980
6890
  this.defaults = defaults;
5981
6891
  this._config = { ...defaults };
@@ -6011,8 +6921,26 @@ var BaseAddon = class {
6011
6921
  return this._config;
6012
6922
  }
6013
6923
  async initialize(context) {
6014
- this._ctx = context;
6924
+ const secrets = context.secrets;
6925
+ if (secrets !== void 0) {
6926
+ const { context: wrapped, handle } = createSecretAwareContext(context, {
6927
+ secrets,
6928
+ addonTree: () => this.addonSecretTree(),
6929
+ deviceTree: () => this.deviceSecretTree(),
6930
+ onOrphaned: (refs) => context.logger.warn("keychain refs dropped by a settings write could not be deleted", { meta: { refs: [...refs] } }),
6931
+ isOperatorWrite: () => this._operatorWriteDepth > 0,
6932
+ onUnresolved: (unresolved) => this.logUnresolvedRead(unresolved)
6933
+ });
6934
+ this._ctx = wrapped;
6935
+ this._secretSettings = handle;
6936
+ } else {
6937
+ this._ctx = context;
6938
+ this._secretSettings = null;
6939
+ }
6015
6940
  await this.resolveConfig();
6941
+ if (secrets !== void 0) this._secretChangeUnsub = secrets.onChange((ref) => {
6942
+ if (this._configSecretRefs.has(ref)) this.scheduleSecretReresolve(SECRET_CHANGE_DEBOUNCE_MS);
6943
+ });
6016
6944
  const result = await this.onInitialize();
6017
6945
  this.emitLifecycle(EventCategory.AddonStarted);
6018
6946
  const normalized = normalizeAddonInitResult(result);
@@ -6045,6 +6973,12 @@ var BaseAddon = class {
6045
6973
  */
6046
6974
  async onHubReachable() {}
6047
6975
  async shutdown() {
6976
+ this._secretChangeUnsub?.();
6977
+ this._secretChangeUnsub = null;
6978
+ if (this._secretRetryTimer !== null) clearTimeout(this._secretRetryTimer);
6979
+ if (this._secretChangeTimer !== null) clearTimeout(this._secretChangeTimer);
6980
+ this._secretRetryTimer = null;
6981
+ this._secretChangeTimer = null;
6048
6982
  this.emitLifecycle(EventCategory.AddonStopped);
6049
6983
  if (this.autoEmitReadiness) this.emitReadinessForProviders("down");
6050
6984
  await this.onShutdown();
@@ -6119,11 +7053,8 @@ var BaseAddon = class {
6119
7053
  async getGlobalSettings(overlay, cap, nodeId) {
6120
7054
  const schema = this.globalSettingsSchema(cap);
6121
7055
  if (!schema) return { sections: [] };
6122
- const projected = await this.resolveGlobalStore(nodeId, cap);
6123
- return hydrateSchema(schema, overlay ? {
6124
- ...projected,
6125
- ...overlay
6126
- } : projected);
7056
+ const projected = await this.readRawProjectedStore(nodeId, cap);
7057
+ return hydrateSchema(schema, overlay ? await this.overlayKeepingMarkers(projected, overlay) : projected, { inlineSecretsAsViews: true });
6127
7058
  }
6128
7059
  /**
6129
7060
  * The integration-level view of this addon's settings: exactly the sections
@@ -6168,11 +7099,11 @@ var BaseAddon = class {
6168
7099
  });
6169
7100
  }
6170
7101
  if (sections.length === 0) return null;
6171
- const projected = await this.resolveGlobalStore(nodeId);
7102
+ const projected = await this.readRawProjectedStore(nodeId);
6172
7103
  return hydrateSchema({
6173
7104
  ...schema,
6174
7105
  sections
6175
- }, projected);
7106
+ }, projected, { inlineSecretsAsViews: true });
6176
7107
  }
6177
7108
  /**
6178
7109
  * The raw addon store PROJECTED onto the target node's bare per-node keys:
@@ -6185,12 +7116,50 @@ var BaseAddon = class {
6185
7116
  * the store for custom option logic (option narrowing, value snapping) to
6186
7117
  * read it per-node — never `ctx.settings.readAddonStore()` directly.
6187
7118
  * `nodeId` omitted ⇒ the local node (node-blind injection from ctx).
7119
+ *
7120
+ * Keychain values come back RESOLVED (D798): a secret reads as its value,
7121
+ * never as a `{ $secret }` marker. One the keychain cannot serve right now
7122
+ * stays a marker — "stored, unavailable" (`isSecretMarker()` is true, and it
7123
+ * is listed in {@link unresolvedSecrets}) — never `''` and never absent, so
7124
+ * it cannot be mistaken for "nothing stored, mint a new one". Writing the
7125
+ * resolved blob back is a no-op for every unchanged secret.
6188
7126
  */
6189
7127
  async resolveGlobalStore(nodeId, cap) {
6190
7128
  const raw = await this._ctx?.settings?.readAddonStore() ?? {};
7129
+ return this.projectForNode(raw, nodeId, cap);
7130
+ }
7131
+ projectForNode(store, nodeId, cap) {
6191
7132
  const keys = this.perNodeKeys(cap);
6192
7133
  const node = normalizeNodeId(nodeId ?? this._ctx?.kernel?.localNodeId);
6193
- return keys.size > 0 ? projectStore(raw, keys, node) : raw;
7134
+ return keys.size > 0 ? projectStore(store, keys, node) : store;
7135
+ }
7136
+ /** The PROJECTED store with its markers — the form hydrate only (D798). */
7137
+ async readRawProjectedStore(nodeId, cap) {
7138
+ const raw = await this.rawSettings()?.readAddonStore() ?? {};
7139
+ return this.projectForNode(raw, nodeId, cap);
7140
+ }
7141
+ /**
7142
+ * `{ ...stored, ...overlay }`, except that an overlay member equal to the
7143
+ * RESOLVED stored one keeps the stored (marker-bearing) member — so a form
7144
+ * hydrated from a resolved overlay still shows a secret as "set", never as
7145
+ * its value.
7146
+ */
7147
+ async overlayKeepingMarkers(stored, overlay) {
7148
+ const secrets = this._ctx?.secrets;
7149
+ const merged = {
7150
+ ...stored,
7151
+ ...overlay
7152
+ };
7153
+ if (secrets === void 0 || collectSecretMarkerRefs(stored).length === 0) return merged;
7154
+ const { value: resolved } = await resolveSecretMarkers(stored, secrets, {
7155
+ unresolved: "keep-marker",
7156
+ ownedBy: secrets.owner
7157
+ });
7158
+ for (const key of Object.keys(overlay)) {
7159
+ if (collectSecretMarkerRefs(stored[key]).length === 0) continue;
7160
+ if (isJsonEqual(overlay[key], resolved[key])) merged[key] = stored[key];
7161
+ }
7162
+ return merged;
6194
7163
  }
6195
7164
  /**
6196
7165
  * Whether ONE global key of this addon's store was written, read three-way
@@ -6226,18 +7195,58 @@ var BaseAddon = class {
6226
7195
  value: result.value[key]
6227
7196
  };
6228
7197
  }
7198
+ /**
7199
+ * The OPERATOR's write — a settings form or an admin API call, dispatched by
7200
+ * the kernel. Identical to {@link updateGlobalSettings}, except that a secret
7201
+ * the operator sends is stored as sent even when it equals a pre-keychain
7202
+ * inline value: the operator re-entering a password is a change, an addon
7203
+ * writing back what it read is not (D787).
7204
+ */
7205
+ async updateGlobalSettingsAsOperator(patch, nodeId) {
7206
+ this._operatorWriteDepth++;
7207
+ try {
7208
+ await this.applyGlobalPatch(patch, nodeId);
7209
+ } finally {
7210
+ this._operatorWriteDepth--;
7211
+ }
7212
+ }
6229
7213
  async updateGlobalSettings(patch, nodeId) {
7214
+ await this.applyGlobalPatch(patch, nodeId);
7215
+ }
7216
+ /**
7217
+ * REMOVE stored secrets — their keychain values and their markers (D787).
7218
+ *
7219
+ * Writing `''` to a secret field KEEPS what is stored (an empty string is
7220
+ * what a defaults fallback writes back, and it must never destroy a
7221
+ * credential), so code that means "forget this token" says so here. Without
7222
+ * a keychain (an older kernel) it writes `''`, as such code always did.
7223
+ */
7224
+ async clearSecrets(keys, nodeId) {
7225
+ const tree = this.addonSecretTree();
7226
+ const keychain = this._ctx?.secrets !== void 0;
7227
+ const stored = keychain ? await this.readAddonStoreWithRetry() : {};
7228
+ const patch = {};
7229
+ for (const key of keys) {
7230
+ const keychainStored = tree.has(key) || collectSecretMarkerRefs(stored[key]).length > 0;
7231
+ patch[key] = keychain && keychainStored ? SECRET_CLEAR : "";
7232
+ }
7233
+ await this.applyGlobalPatch(patch, nodeId);
7234
+ }
7235
+ async applyGlobalPatch(barePatch, nodeId) {
6230
7236
  const keys = this.perNodeKeys();
6231
7237
  const localNode = normalizeNodeId(this._ctx?.kernel?.localNodeId);
6232
7238
  const target = normalizeNodeId(nodeId ?? this._ctx?.kernel?.localNodeId);
6233
- const barePatch = patch;
6234
7239
  const scoped = keys.size > 0 ? scopePatch(barePatch, keys, target) : barePatch;
6235
- await this._ctx?.settings?.writeAddonStore(scoped);
7240
+ const handle = this._secretSettings;
7241
+ if (handle !== null) {
7242
+ const { changed } = await handle.writeAddonStore(scoped);
7243
+ if (!changed) return;
7244
+ } else await this._ctx?.settings?.writeAddonStore(scoped);
6236
7245
  if (target !== localNode) return;
6237
7246
  await this.resolveConfig();
6238
7247
  await this.onConfigChanged();
6239
7248
  this.emitLifecycle(EventCategory.AddonUpdated, { level: "global" });
6240
- this.maybeAutoRestart(patch, this.globalSettingsSchema());
7249
+ this.maybeAutoRestart(Object.keys(barePatch), this.globalSettingsSchema());
6241
7250
  }
6242
7251
  /**
6243
7252
  * The set of field keys the global settings schema declares `perNode: true`
@@ -6262,7 +7271,7 @@ var BaseAddon = class {
6262
7271
  * time to return its response before the addon is torn down and
6263
7272
  * re-initialised by `AddonRegistryService.restartAddon`.
6264
7273
  */
6265
- maybeAutoRestart(patch, schema) {
7274
+ maybeAutoRestart(patchKeys, schema) {
6266
7275
  if (!schema) return;
6267
7276
  const restartKeys = /* @__PURE__ */ new Set();
6268
7277
  for (const section of schema.sections) for (const field of section.fields) {
@@ -6270,13 +7279,13 @@ var BaseAddon = class {
6270
7279
  if (field.requiresRestart) restartKeys.add(field.key);
6271
7280
  }
6272
7281
  if (restartKeys.size === 0) return;
6273
- if (!Object.keys(patch).some((k) => restartKeys.has(k))) return;
7282
+ if (!patchKeys.some((k) => restartKeys.has(k))) return;
6274
7283
  const ctx = this._ctx;
6275
7284
  if (!ctx) return;
6276
7285
  const addonId = ctx.id;
6277
7286
  setImmediate(() => {
6278
7287
  ctx.api.addons?.restartAddon?.mutate({ addonId }).then(() => {
6279
- ctx.logger.info("addon auto-restart triggered by restart-required setting change", { meta: { changedFields: Object.keys(patch).filter((k) => restartKeys.has(k)) } });
7288
+ ctx.logger.info("addon auto-restart triggered by restart-required setting change", { meta: { changedFields: patchKeys.filter((k) => restartKeys.has(k)) } });
6280
7289
  }).catch((err) => {
6281
7290
  ctx.logger.error("addon auto-restart failed", { meta: { error: err instanceof Error ? err.message : String(err) } });
6282
7291
  });
@@ -6285,7 +7294,7 @@ var BaseAddon = class {
6285
7294
  async getDeviceSettings(deviceId) {
6286
7295
  const schema = this.deviceSettingsSchema();
6287
7296
  if (!schema) return { sections: [] };
6288
- return hydrateSchema(schema, await this._ctx?.settings?.readDeviceStore(deviceId) ?? {});
7297
+ return hydrateSchema(schema, await this.rawSettings()?.readDeviceStore(deviceId) ?? {}, { inlineSecretsAsViews: true });
6289
7298
  }
6290
7299
  async updateDeviceSettings(deviceId, patch) {
6291
7300
  await this._ctx?.settings?.writeDeviceStore(deviceId, patch);
@@ -6415,7 +7424,7 @@ var BaseAddon = class {
6415
7424
  * selection at boot (absent scoped key ⇒ the constructor default wins).
6416
7425
  */
6417
7426
  async resolveConfig() {
6418
- const stored = await this.readAddonStoreWithRetry();
7427
+ const stored = await this.resolveStoredSecrets(await this.readAddonStoreWithRetry());
6419
7428
  const perNode = this.perNodeKeys();
6420
7429
  const localNode = normalizeNodeId(this._ctx?.kernel?.localNodeId);
6421
7430
  const resolved = { ...this.defaults };
@@ -6440,7 +7449,7 @@ var BaseAddon = class {
6440
7449
  key,
6441
7450
  schema,
6442
7451
  fallback,
6443
- read: () => this.readAddonStoreWithRetry(),
7452
+ read: async () => this.resolveStoredSecrets(await this.readAddonStoreWithRetry()),
6444
7453
  write: async (patch) => {
6445
7454
  await this._ctx?.settings?.writeAddonStore(patch);
6446
7455
  },
@@ -6457,7 +7466,7 @@ var BaseAddon = class {
6457
7466
  key,
6458
7467
  schema,
6459
7468
  fallback,
6460
- read: async () => await this._ctx?.settings?.readDeviceStore(deviceId) ?? {},
7469
+ read: async () => this.resolveStoredSecrets(await this.rawSettings()?.readDeviceStore(deviceId) ?? {}, false),
6461
7470
  write: async (patch) => {
6462
7471
  await this._ctx?.settings?.writeDeviceStore(deviceId, patch);
6463
7472
  },
@@ -6469,6 +7478,87 @@ var BaseAddon = class {
6469
7478
  } })
6470
7479
  });
6471
7480
  }
7481
+ /** The addon store's secret tree: schema fields by TYPE, plus `secretStatePaths`. */
7482
+ addonSecretTree() {
7483
+ this._addonSecretTree ??= mergeSecretStatePaths(secretTreeFromSchema(this.globalSettingsSchema()), this.secretStatePaths);
7484
+ return this._addonSecretTree;
7485
+ }
7486
+ deviceSecretTree() {
7487
+ this._deviceSecretTree ??= secretTreeFromSchema(this.deviceSettingsSchema());
7488
+ return this._deviceSecretTree;
7489
+ }
7490
+ /**
7491
+ * Secrets of this addon's stored config that could not be resolved on the
7492
+ * last read, with why. Non-empty means the addon is running WITHOUT them —
7493
+ * an addon whose function needs one should report itself degraded rather
7494
+ * than start on an empty credential.
7495
+ */
7496
+ get unresolvedSecrets() {
7497
+ return this._unresolvedSecrets;
7498
+ }
7499
+ /**
7500
+ * Substitute every keychain marker in a stored blob with its value. With no
7501
+ * keychain (no `ctx.secrets`) or no marker, the blob comes back unchanged.
7502
+ * An unresolvable value is LEFT OUT (never `''`), logged by ref — never by
7503
+ * value — and, when the cause can pass, retried with backoff. Nothing is
7504
+ * ever written back from here.
7505
+ */
7506
+ async resolveStoredSecrets(blob, trackForConfig = true) {
7507
+ const secrets = this._ctx?.secrets;
7508
+ if (secrets === void 0) return blob;
7509
+ const refs = collectSecretMarkerRefs(blob);
7510
+ if (trackForConfig) this._configSecretRefs = new Set(refs);
7511
+ if (refs.length === 0) {
7512
+ if (trackForConfig) this._unresolvedSecrets = [];
7513
+ return blob;
7514
+ }
7515
+ const { value, unresolved } = await resolveSecretMarkers(blob, secrets);
7516
+ if (trackForConfig) {
7517
+ this._unresolvedSecrets = unresolved;
7518
+ if (unresolved.length > 0) {
7519
+ this._ctx?.logger?.error?.("secret unavailable — running without it, will retry", { meta: { secrets: unresolved.map((u) => ({
7520
+ ref: u.ref,
7521
+ reason: u.reason
7522
+ })) } });
7523
+ if (unresolved.some((u) => u.reason !== "missing" && u.reason !== "forbidden")) {
7524
+ this.scheduleSecretReresolve(this._secretRetryDelayMs);
7525
+ this._secretRetryDelayMs = Math.min(this._secretRetryDelayMs * 2, SECRET_RETRY_MAX_MS);
7526
+ }
7527
+ } else this._secretRetryDelayMs = SECRET_RETRY_FIRST_MS;
7528
+ }
7529
+ return value;
7530
+ }
7531
+ /**
7532
+ * The marker-bearing settings reads (D798) — private on purpose. Without a
7533
+ * keychain the context's own view is already raw.
7534
+ */
7535
+ rawSettings() {
7536
+ return this._secretSettings?.raw ?? this._ctx?.settings;
7537
+ }
7538
+ /** An addon-facing read met markers it could not resolve: say so once per ref. */
7539
+ logUnresolvedRead(unresolved) {
7540
+ const fresh = unresolved.filter((u) => !this._loggedUnresolvedReads.has(u.ref));
7541
+ if (fresh.length === 0) return;
7542
+ for (const u of fresh) this._loggedUnresolvedReads.add(u.ref);
7543
+ 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) => ({
7544
+ ref: u.ref,
7545
+ reason: u.reason
7546
+ })) } });
7547
+ }
7548
+ /** Re-resolve the config (a keychain-only change, or a retry) and apply it. */
7549
+ scheduleSecretReresolve(delayMs) {
7550
+ const timerOf = delayMs === SECRET_CHANGE_DEBOUNCE_MS ? "_secretChangeTimer" : "_secretRetryTimer";
7551
+ if (this[timerOf] !== null) return;
7552
+ const timer = setTimeout(() => {
7553
+ this[timerOf] = null;
7554
+ if (this._ctx === null) return;
7555
+ this.resolveConfig().then(() => this.onConfigChanged()).catch((err) => {
7556
+ this._ctx?.logger?.error?.("re-resolving secrets failed", { meta: { error: err instanceof Error ? err.message : String(err) } });
7557
+ });
7558
+ }, delayMs);
7559
+ timer.unref?.();
7560
+ this[timerOf] = timer;
7561
+ }
6472
7562
  /**
6473
7563
  * Wrap `ctx.settings.readAddonStore()` with a short retry budget so a
6474
7564
  * transient settings-store outage (mid-restart of sqlite-settings, tsx-watch
@@ -6481,7 +7571,7 @@ var BaseAddon = class {
6481
7571
  * `{}` (defaults) — the addon's first successful patch will rehydrate.
6482
7572
  */
6483
7573
  async readAddonStoreWithRetry() {
6484
- const settings = this._ctx?.settings;
7574
+ const settings = this.rawSettings();
6485
7575
  if (!settings) return {};
6486
7576
  const delaysMs = [
6487
7577
  150,
@@ -7103,6 +8193,69 @@ method(object({ deviceId: number() }), array(StreamSourceEntrySchema)), method(o
7103
8193
  kind: "mutation",
7104
8194
  auth: "admin"
7105
8195
  }), method(object({ deviceId: number() }), unknown().nullable()), method(object({ deviceId: number() }), RawStateResultSchema.nullable(), { auth: "protected" });
8196
+ function defOf(schema) {
8197
+ return schema._zod?.def ?? {};
8198
+ }
8199
+ function declaredHere(schema) {
8200
+ return globalRegistry.get(schema)?.secret === true;
8201
+ }
8202
+ /** Wrapper kinds whose `innerType` is the field itself. */
8203
+ var WRAPPERS = new Set([
8204
+ "optional",
8205
+ "nullable",
8206
+ "default",
8207
+ "prefault",
8208
+ "catch",
8209
+ "readonly",
8210
+ "nonoptional"
8211
+ ]);
8212
+ /**
8213
+ * The schema layers that make up ONE field: the schema itself and every
8214
+ * wrapper below it (optional / default / nullable / readonly / catch), plus
8215
+ * both sides of a pipe (`z.preprocess` puts the real schema on `out`,
8216
+ * `.transform` on `in`).
8217
+ */
8218
+ function layersOf(schema) {
8219
+ const out = [];
8220
+ const queue = [schema];
8221
+ while (queue.length > 0) {
8222
+ const s = queue.shift();
8223
+ if (!s || out.includes(s)) continue;
8224
+ out.push(s);
8225
+ const def = defOf(s);
8226
+ if (def.type !== void 0 && WRAPPERS.has(def.type) && def.innerType) queue.push(def.innerType);
8227
+ if (def.type === "pipe") {
8228
+ if (def.in) queue.push(def.in);
8229
+ if (def.out) queue.push(def.out);
8230
+ }
8231
+ }
8232
+ return out;
8233
+ }
8234
+ /** True when any layer of this field declares `.meta({ secret: true })`. */
8235
+ function isZodSecret(schema) {
8236
+ return layersOf(schema).some(declaredHere);
8237
+ }
8238
+ /**
8239
+ * Every declared secret path in a config schema: dotted keys, `[]` for "each
8240
+ * element of this array" (`connection.password`, `rows[].token`). A declared
8241
+ * object or array is reported as one path and not descended into — everything
8242
+ * under it is secret.
8243
+ */
8244
+ function collectZodSecretPaths(schema, prefix = "") {
8245
+ if (isZodSecret(schema)) return prefix.length > 0 ? [prefix] : [];
8246
+ const paths = [];
8247
+ for (const layer of layersOf(schema)) {
8248
+ const def = defOf(layer);
8249
+ if (def.type === "object" && def.shape) for (const [key, child] of Object.entries(def.shape)) paths.push(...collectZodSecretPaths(child, prefix ? `${prefix}.${key}` : key));
8250
+ else if (def.type === "array" && def.element) paths.push(...collectZodSecretPaths(def.element, `${prefix}[]`));
8251
+ else if (def.type === "union" && def.options) for (const option of def.options) paths.push(...collectZodSecretPaths(option, prefix));
8252
+ else if (def.type === "intersection") {
8253
+ if (def.left) paths.push(...collectZodSecretPaths(def.left, prefix));
8254
+ if (def.right) paths.push(...collectZodSecretPaths(def.right, prefix));
8255
+ }
8256
+ }
8257
+ return [...new Set(paths)];
8258
+ }
7106
8259
  //#endregion
7107
8260
  //#region ../types/dist/err-msg-DX6i_MY4.mjs
7108
8261
  var DeviceType = /* @__PURE__ */ function(DeviceType) {
@@ -8924,6 +10077,278 @@ var CameraSwitchGroupSchema = object({
8924
10077
  fetchedAt: number()
8925
10078
  });
8926
10079
  /**
10080
+ * The trainer contract — what the hub hands the cloud trainer and what it
10081
+ * gets back (cloud training, D805+).
10082
+ *
10083
+ * The trainer (`hf/camstack-trainer`, published as the Hugging Face repo
10084
+ * `camstack/camstack-trainer`) is a separate AGPL program the hub never
10085
+ * imports: `job.json` goes in, files come out, and progress is `CAMSTACK_EVENT`
10086
+ * lines on stdout. These schemas are the hub's half of that boundary; the
10087
+ * trainer's pydantic models (and the JSON Schemas generated from them under
10088
+ * `hf/camstack-trainer/schemas/`) are the other half. A change here is a
10089
+ * change there, in the same piece of work.
10090
+ *
10091
+ * No `.default()` anywhere: defaults do not run on the addon cap path, so the
10092
+ * orchestrator fills every field of a job spec explicitly.
10093
+ */
10094
+ var TRAINING_JOB_SCHEMA = "camstack.training/v1";
10095
+ var TRAINING_RESULT_SCHEMA = "camstack.training-result/v1";
10096
+ /** What the trainer can export. Edge TPU is a later, separate image. */
10097
+ var TrainingExportSchema = _enum([
10098
+ "onnx",
10099
+ "openvino-fp16",
10100
+ "openvino-int8",
10101
+ "coreml-fp16"
10102
+ ]);
10103
+ var FloorsSchema = record(string(), number().min(0).max(1));
10104
+ object({
10105
+ schema: literal(TRAINING_JOB_SCHEMA),
10106
+ jobKey: string().uuid(),
10107
+ target: object({
10108
+ kind: literal("detector"),
10109
+ step: literal("object-detection")
10110
+ }),
10111
+ base: object({
10112
+ modelId: string().min(1),
10113
+ /** Ultralytics weights id, e.g. `yolov9m.pt`. */
10114
+ weights: string().min(1),
10115
+ imgsz: number().int().positive()
10116
+ }),
10117
+ baseline: object({
10118
+ modelId: string().min(1),
10119
+ /** The baseline ONNX the holdout comparison runs; public mirror URL. */
10120
+ onnxUrl: string().url(),
10121
+ imgsz: number().int().positive(),
10122
+ floors: FloorsSchema
10123
+ }),
10124
+ dataset: object({
10125
+ versionId: string().min(1),
10126
+ annotationHash: string(),
10127
+ /** sha256 of the uploaded archive; the trainer refuses a mismatch (exit 65). */
10128
+ sha256: string().regex(/^[0-9a-f]{64}$/)
10129
+ }),
10130
+ split: object({
10131
+ holdoutCameras: array(number().int()),
10132
+ /** When no camera is held out: the last N days of every camera. */
10133
+ holdoutLastDays: number().int().nonnegative(),
10134
+ valFraction: number().min(0).max(.5),
10135
+ seed: number().int()
10136
+ }),
10137
+ hyper: object({
10138
+ epochs: number().int().positive(),
10139
+ batch: number().int().positive(),
10140
+ lr0: number().positive(),
10141
+ /** Layers frozen from the start of the backbone; 0 = none. */
10142
+ freeze: number().int().nonnegative(),
10143
+ patience: number().int().nonnegative(),
10144
+ seed: number().int()
10145
+ }),
10146
+ replay: object({
10147
+ source: literal("coco2017"),
10148
+ count: number().int().nonnegative()
10149
+ }),
10150
+ exports: array(TrainingExportSchema).min(1),
10151
+ calibration: object({ maxFrames: number().int().positive() }),
10152
+ floors: object({
10153
+ minSupport: number().int().positive(),
10154
+ clamp: number().min(0).max(1)
10155
+ }),
10156
+ int8Gate: object({ maxMap50Drop: number().min(0).max(1) }),
10157
+ catalog: object({
10158
+ id: string().regex(/^[a-z0-9][a-z0-9-]{2,80}$/),
10159
+ name: string().min(1).max(160)
10160
+ })
10161
+ });
10162
+ /** One regular file of the bundle. An mlpackage contributes one row per member. */
10163
+ var TrainingResultFileSchema = object({
10164
+ path: string().min(1),
10165
+ bytes: number().int().nonnegative(),
10166
+ sha256: string().regex(/^[0-9a-f]{64}$/),
10167
+ format: _enum([
10168
+ "onnx",
10169
+ "openvino",
10170
+ "coreml",
10171
+ "pt"
10172
+ ]),
10173
+ variant: _enum(["base", "int8"])
10174
+ });
10175
+ var DraftFormatSchema = object({
10176
+ /** RELATIVE path inside the bundle; the hub rewrites it to `camstack-local://`. */
10177
+ url: string().min(1),
10178
+ sizeMB: number().nonnegative(),
10179
+ isDirectory: boolean().optional(),
10180
+ files: array(string()).optional(),
10181
+ runtimes: array(literal("python")).optional(),
10182
+ revision: string().min(1)
10183
+ });
10184
+ /** The trainer's half of a catalog entry; the hub completes it (labels, licence, group). */
10185
+ var TrainingCatalogDraftSchema = object({
10186
+ id: string().min(1),
10187
+ name: string().min(1),
10188
+ description: string(),
10189
+ labels: array(unknown()),
10190
+ inputSize: object({
10191
+ width: number().int().positive(),
10192
+ height: number().int().positive()
10193
+ }),
10194
+ preprocessMode: literal("letterbox"),
10195
+ defaultClassFloors: FloorsSchema,
10196
+ formats: object({
10197
+ onnx: DraftFormatSchema.optional(),
10198
+ openvino: DraftFormatSchema.optional(),
10199
+ coreml: DraftFormatSchema.optional()
10200
+ })
10201
+ });
10202
+ /** One class of one model's holdout report (the eval harness's summary). */
10203
+ var TrainingEvalClassSchema = object({
10204
+ positives: number().int(),
10205
+ floor: number().nullable(),
10206
+ tp: number().int(),
10207
+ fp: number().int(),
10208
+ fn: number().int(),
10209
+ precision: number().nullable(),
10210
+ recall: number().nullable(),
10211
+ ap50: number().nullable(),
10212
+ recallByCamera: record(string(), number().nullable()).optional(),
10213
+ recallByLight: record(string(), number().nullable()).optional(),
10214
+ fpByCamera: record(string(), number()).optional(),
10215
+ smallFound: number().int().optional(),
10216
+ smallTotal: number().int().optional()
10217
+ }).passthrough();
10218
+ var TrainingEvalReportSchema = object({
10219
+ frames: number().int(),
10220
+ classes: record(string(), TrainingEvalClassSchema)
10221
+ }).passthrough();
10222
+ /**
10223
+ * A succeeded result carries every block; a failed one carries the error and
10224
+ * whatever was known by then — the other blocks are ABSENT, not null. The
10225
+ * orchestrator checks the blocks it needs before it trusts a success.
10226
+ */
10227
+ var TrainingResultSchema = object({
10228
+ schema: literal(TRAINING_RESULT_SCHEMA),
10229
+ jobKey: string(),
10230
+ status: _enum(["succeeded", "failed"]),
10231
+ error: object({
10232
+ stage: string(),
10233
+ code: string(),
10234
+ message: string()
10235
+ }).nullable(),
10236
+ trainer: object({
10237
+ version: string(),
10238
+ revision: string()
10239
+ }),
10240
+ toolchain: record(string(), string().nullable()),
10241
+ dataset: object({
10242
+ versionId: string(),
10243
+ annotationHash: string(),
10244
+ sha256: string(),
10245
+ frames: object({
10246
+ train: number().int(),
10247
+ val: number().int(),
10248
+ holdout: number().int()
10249
+ }),
10250
+ holdoutCameras: array(number().int()),
10251
+ replayImages: number().int()
10252
+ }).optional(),
10253
+ training: object({
10254
+ epochsRun: number().int(),
10255
+ bestEpoch: number().int(),
10256
+ bestMap50: number(),
10257
+ bestMap50_95: number(),
10258
+ seconds: number()
10259
+ }).optional(),
10260
+ evaluation: object({
10261
+ holdoutFrames: number().int(),
10262
+ baseline: TrainingEvalReportSchema.nullable(),
10263
+ candidate: TrainingEvalReportSchema.nullable(),
10264
+ candidateInt8: TrainingEvalReportSchema.nullable(),
10265
+ recallDeltaByCamera: record(string(), record(string(), number())).nullable(),
10266
+ map50: record(string(), number().nullable())
10267
+ }).optional(),
10268
+ floors: object({
10269
+ baseline: FloorsSchema,
10270
+ candidate: FloorsSchema,
10271
+ candidateInt8: FloorsSchema.nullable(),
10272
+ notes: array(string())
10273
+ }).optional(),
10274
+ int8: object({
10275
+ kept: boolean(),
10276
+ map50Fp16: number().nullable(),
10277
+ map50Int8: number().nullable(),
10278
+ reason: string().nullable()
10279
+ }).optional(),
10280
+ exportsDropped: array(object({
10281
+ export: string(),
10282
+ reason: string()
10283
+ })).optional(),
10284
+ files: array(TrainingResultFileSchema).optional(),
10285
+ bundle: object({
10286
+ path: literal("bundle.tar"),
10287
+ bytes: number().int().nonnegative(),
10288
+ sha256: string().regex(/^[0-9a-f]{64}$/)
10289
+ }).nullable().optional(),
10290
+ catalogDraft: object({
10291
+ base: TrainingCatalogDraftSchema,
10292
+ int8: TrainingCatalogDraftSchema.nullable()
10293
+ }).nullable().optional(),
10294
+ licence: string()
10295
+ });
10296
+ var TrainingStageSchema = _enum([
10297
+ "prepare",
10298
+ "replay",
10299
+ "train",
10300
+ "eval",
10301
+ "export",
10302
+ "package"
10303
+ ]);
10304
+ var EventBase = {
10305
+ v: literal(1),
10306
+ ts: number()
10307
+ };
10308
+ discriminatedUnion("type", [
10309
+ object({
10310
+ ...EventBase,
10311
+ type: literal("stage"),
10312
+ stage: TrainingStageSchema
10313
+ }),
10314
+ object({
10315
+ ...EventBase,
10316
+ type: literal("epoch"),
10317
+ epoch: number().int(),
10318
+ epochs: number().int(),
10319
+ boxLoss: number().nullable().optional(),
10320
+ map50: number().nullable().optional(),
10321
+ map50_95: number().nullable().optional(),
10322
+ etaSec: number().nullable().optional()
10323
+ }),
10324
+ object({
10325
+ ...EventBase,
10326
+ type: literal("metric"),
10327
+ name: string(),
10328
+ value: number()
10329
+ }),
10330
+ object({
10331
+ ...EventBase,
10332
+ type: literal("artifact"),
10333
+ path: string(),
10334
+ bytes: number(),
10335
+ sha256: string()
10336
+ }),
10337
+ object({
10338
+ ...EventBase,
10339
+ type: literal("done"),
10340
+ status: _enum(["succeeded", "failed"]),
10341
+ resultSha256: string().nullable().optional()
10342
+ }),
10343
+ object({
10344
+ ...EventBase,
10345
+ type: literal("error"),
10346
+ stage: string(),
10347
+ code: string(),
10348
+ message: string()
10349
+ })
10350
+ ]);
10351
+ /**
8927
10352
  * What the gate decided about a birth, from the CALLER's point of view.
8928
10353
  *
8929
10354
  * Deliberately not `ConfirmationVerdict`: `undecided` is not a birth decision
@@ -11251,7 +12676,9 @@ var AddonHttpRouteSchema = object({
11251
12676
  "authenticated",
11252
12677
  "admin"
11253
12678
  ]).optional(),
11254
- description: string().optional()
12679
+ description: string().optional(),
12680
+ /** The hub limits this route per client address before the handler runs. */
12681
+ rateLimit: _enum(["auth"]).optional()
11255
12682
  });
11256
12683
  /**
11257
12684
  * Cross-process route invocation envelope. The hub captures the
@@ -11975,6 +13402,37 @@ var BackupDestinationInfoSchema = object({
11975
13402
  lastError: string().optional()
11976
13403
  });
11977
13404
  /**
13405
+ * How an archive is encrypted (operator decision 2026-10-09): to a backup
13406
+ * PUBLIC key the hub holds, so only the operator's secret key opens it.
13407
+ * Absent on a plain `.tar.gz` — every archive made before encryption, or
13408
+ * with it off — which restores without a key.
13409
+ */
13410
+ var BackupArchiveEncryptionSchema = object({
13411
+ /** `x25519-hkdf-aes256gcm-stream-v1`. */
13412
+ scheme: string(),
13413
+ /** 16 hex — the backup key whose secret restores this archive. */
13414
+ keyId: string()
13415
+ });
13416
+ /**
13417
+ * The backup encryption setting. The hub keeps PUBLIC keys only: the active
13418
+ * one new archives are encrypted to, and the retired ones older archives
13419
+ * still need. The secret key is shown once, at `setupEncryption`.
13420
+ */
13421
+ var BackupEncryptionStatusSchema = object({
13422
+ enabled: boolean(),
13423
+ active: object({
13424
+ keyId: string(),
13425
+ publicKey: string(),
13426
+ createdAt: number()
13427
+ }).nullable(),
13428
+ /** Every key ever set up, newest first. */
13429
+ keys: array(object({
13430
+ keyId: string(),
13431
+ createdAt: number(),
13432
+ retiredAt: number().nullable()
13433
+ })).readonly()
13434
+ });
13435
+ /**
11978
13436
  * Per-archive entry returned by `backup.listArchives({ destinationId })`.
11979
13437
  * Same shape the destination drill-in renders. Sourced from the per-
11980
13438
  * location `manifests.json` (no per-archive tarball read required).
@@ -11986,7 +13444,9 @@ var BackupArchiveEntrySchema = object({
11986
13444
  sizeBytes: number(),
11987
13445
  label: string().optional(),
11988
13446
  /** Top-level locations included in the archive (db, addons, tls, …). */
11989
- locations: array(string()).readonly()
13447
+ locations: array(string()).readonly(),
13448
+ /** Present when the archive is encrypted; restore then needs that key. */
13449
+ encryption: BackupArchiveEncryptionSchema.optional()
11990
13450
  });
11991
13451
  var BackupEntrySchema = object({
11992
13452
  id: string(),
@@ -11995,7 +13455,8 @@ var BackupEntrySchema = object({
11995
13455
  label: string().optional(),
11996
13456
  createdAt: number(),
11997
13457
  sizeBytes: number(),
11998
- locations: array(string()).optional()
13458
+ locations: array(string()).optional(),
13459
+ encryption: BackupArchiveEncryptionSchema.optional()
11999
13460
  });
12000
13461
  var ArchiveEntrySchema = object({
12001
13462
  path: string(),
@@ -12184,10 +13645,40 @@ method(_void(), array(BackupDestinationInfoSchema).readonly(), { auth: "admin" }
12184
13645
  * this list and skips entries whose path doesn't start with
12185
13646
  * any of them.
12186
13647
  */
12187
- locations: array(string()).optional()
13648
+ locations: array(string()).optional(),
13649
+ /**
13650
+ * The backup SECRET key, for an encrypted archive (ignored for a plain
13651
+ * one). The archive is decrypted into the hub's private staging
13652
+ * before the restart; the key is not stored. A wrong or missing key
13653
+ * is refused before the archive is downloaded.
13654
+ */
13655
+ backupSecretKey: string().optional()
12188
13656
  }), _void(), {
12189
13657
  kind: "mutation",
12190
13658
  auth: "admin"
13659
+ }), method(_void(), BackupEncryptionStatusSchema, { auth: "admin" }), method(object({}), object({
13660
+ keyId: string(),
13661
+ secretKey: string(),
13662
+ publicKey: string(),
13663
+ createdAt: number(),
13664
+ replacedKeyId: string().nullable()
13665
+ }), {
13666
+ kind: "mutation",
13667
+ auth: "admin"
13668
+ }), method(object({}), object({ disabledKeyId: string().nullable() }), {
13669
+ kind: "mutation",
13670
+ auth: "admin"
13671
+ }), method(object({ backupSecretKey: string() }), object({
13672
+ valid: boolean(),
13673
+ keyId: string().nullable(),
13674
+ /** The hub knows this key (active or retired). */
13675
+ known: boolean(),
13676
+ /** It is the key new archives are encrypted to. */
13677
+ active: boolean(),
13678
+ error: string().optional()
13679
+ }), {
13680
+ kind: "mutation",
13681
+ auth: "admin"
12191
13682
  }), method(object({
12192
13683
  destinationId: string(),
12193
13684
  backupId: string()
@@ -13962,7 +15453,60 @@ var CustomModelDescriptorSchema = object({
13962
15453
  stepId: string(),
13963
15454
  entry: ModelCatalogEntrySchema
13964
15455
  });
13965
- method(_void(), array(CustomModelDescriptorSchema).readonly(), { auth: "admin" });
15456
+ /** One regular file of an imported bundle, as the producer measured it. */
15457
+ var ModelBundleFileSchema = object({
15458
+ /** Relative path inside the bundle tar; an mlpackage member is `<x>.mlpackage/<member>`. */
15459
+ path: string().min(1),
15460
+ bytes: number().int().nonnegative(),
15461
+ sha256: string().regex(/^[0-9a-f]{64}$/)
15462
+ });
15463
+ var ImportModelBundleInputSchema = object({
15464
+ /** The registry provider that keeps the model (Model Studio). */
15465
+ addonId: string(),
15466
+ stepId: string().min(1),
15467
+ /**
15468
+ * The catalog rows to register, complete, every format URL already
15469
+ * `camstack-local://<modelId>/<file>` naming a file of the bundle. One
15470
+ * bundle may carry several rows (a base and its INT8 variant).
15471
+ */
15472
+ entries: array(ModelCatalogEntrySchema).min(1).max(4),
15473
+ /** The bundle tar, offered by the producer over `ctx.peerBytes` (same host). */
15474
+ bundle: object({
15475
+ ticket: PeerBytesTicketSchema,
15476
+ bytes: number().int().positive(),
15477
+ sha256: string().regex(/^[0-9a-f]{64}$/)
15478
+ }),
15479
+ /** Every file the tar must hold; anything missing, extra or different is refused. */
15480
+ files: array(ModelBundleFileSchema).min(1).max(64),
15481
+ /** Convert missing engine formats and push the model to every agent afterwards. */
15482
+ distribute: boolean()
15483
+ });
15484
+ var ImportModelBundleResultSchema = discriminatedUnion("kind", [object({
15485
+ kind: literal("imported"),
15486
+ modelIds: array(string()).readonly(),
15487
+ distributed: array(object({
15488
+ modelId: string(),
15489
+ nodeId: string(),
15490
+ format: _enum(MODEL_FORMATS),
15491
+ ok: boolean(),
15492
+ error: string().optional()
15493
+ })).readonly()
15494
+ }), object({
15495
+ kind: literal("refused"),
15496
+ reason: _enum([
15497
+ "transfer-failed",
15498
+ "checksum-mismatch",
15499
+ "bundle-mismatch",
15500
+ "invalid-entry",
15501
+ "id-taken"
15502
+ ]),
15503
+ detail: string()
15504
+ })]);
15505
+ method(_void(), array(CustomModelDescriptorSchema).readonly(), { auth: "admin" }), method(ImportModelBundleInputSchema, ImportModelBundleResultSchema, {
15506
+ kind: "mutation",
15507
+ auth: "admin",
15508
+ timeoutMs: 30 * 6e4
15509
+ });
13966
15510
  /**
13967
15511
  * Query filter for settings-store collections.
13968
15512
  */
@@ -14345,6 +15889,253 @@ id: union([string(), number()]) }), {
14345
15889
  kind: "mutation",
14346
15890
  auth: "admin"
14347
15891
  });
15892
+ /**
15893
+ * `keychain` — the hub's encrypted store of secret values (D787).
15894
+ *
15895
+ * Settings blobs never hold a secret: they hold a marker
15896
+ * `{"$secret":"secret://<owner>/<scope>/<fieldPath>","v":1}` and the value
15897
+ * lives here, AES-256-GCM under a data key that a master key wraps. This cap
15898
+ * is the OWNER's door to its own values: every method is owner-checked
15899
+ * against the CALLER, never against anything the caller claims.
15900
+ *
15901
+ * Who the caller is: the transport stamps `callerAddonId` into the args of a
15902
+ * call that crossed a process (the parent `LocalChildRegistry` from the UDS
15903
+ * connection, the agent from its child's connection carried in
15904
+ * `$hub-cap-fwd`'s envelope). A stamp always overwrites; a wire call with no
15905
+ * stamp has its claim stripped. Only a hub in-process caller may state its own
15906
+ * identity — `ctx.secrets` does that with the addon id closed over. This is
15907
+ * identity against BUGS and misrouting, not against a malicious addon (every
15908
+ * runner is the same OS user): see the threat model in
15909
+ * `docs/design/2026-10-08-secrets-keychain.md`.
15910
+ *
15911
+ * `callerAddonId` is deliberately NOT in any input schema: the tRPC router
15912
+ * parses the input, so a session can never supply it, and the internal mount
15913
+ * floors every method to admin anyway (D240).
15914
+ *
15915
+ * Internal: addons reach it through `ctx.secrets`, never directly.
15916
+ */
15917
+ /** Why a value cannot be served right now. Never folded into "missing". */
15918
+ var KeychainUnavailableReasonSchema = _enum([
15919
+ "key-missing",
15920
+ "wrong-key",
15921
+ "key-file-unreadable",
15922
+ "store-unavailable",
15923
+ "not-initialized",
15924
+ "decrypt-failed"
15925
+ ]);
15926
+ var KeychainStateSchema = discriminatedUnion("state", [object({ state: literal("ready") }), object({
15927
+ state: literal("locked"),
15928
+ reason: KeychainUnavailableReasonSchema
15929
+ })]);
15930
+ var KeychainResolveEntrySchema = discriminatedUnion("kind", [
15931
+ object({
15932
+ kind: literal("value"),
15933
+ value: string(),
15934
+ version: number().int()
15935
+ }),
15936
+ object({ kind: literal("missing") }),
15937
+ object({
15938
+ kind: literal("unavailable"),
15939
+ reason: KeychainUnavailableReasonSchema
15940
+ }),
15941
+ object({ kind: literal("forbidden") })
15942
+ ]);
15943
+ var KeychainResolveResultSchema = record(string(), KeychainResolveEntrySchema);
15944
+ /** Metadata of one stored value — never the value. */
15945
+ var KeychainSecretMetaSchema = object({
15946
+ ref: string(),
15947
+ owner: string(),
15948
+ /** Formatted scope (`global`, `node/<id>`, `device/<id>`, …). */
15949
+ scope: string(),
15950
+ fieldPath: string(),
15951
+ version: number().int(),
15952
+ createdAt: number(),
15953
+ updatedAt: number(),
15954
+ /** `addon:<id>` | `user:<id>` | `system`. */
15955
+ updatedBy: string(),
15956
+ /** Coarse — written at most once an hour per ref. `null` = never read. */
15957
+ lastReadAt: number().nullable()
15958
+ });
15959
+ var RefListSchema = array(string().min(1)).max(512);
15960
+ method(object({
15961
+ ref: string().min(1),
15962
+ value: string().min(1)
15963
+ }), object({
15964
+ ref: string(),
15965
+ version: number().int()
15966
+ }), {
15967
+ kind: "mutation",
15968
+ auth: "admin"
15969
+ }), method(object({ refs: RefListSchema }), KeychainResolveResultSchema, { auth: "admin" }), method(object({ refs: RefListSchema }), object({ deleted: number().int() }), {
15970
+ kind: "mutation",
15971
+ auth: "admin"
15972
+ }), method(object({}), array(KeychainSecretMetaSchema).readonly(), { auth: "admin" }), method(object({}), KeychainStateSchema, { auth: "admin" });
15973
+ var KeychainKeySourceSchema = object({
15974
+ kind: _enum([
15975
+ "config-file",
15976
+ "previous-config-file",
15977
+ "platform",
15978
+ "default-file"
15979
+ ]),
15980
+ /** File sources only — a path is not a secret. */
15981
+ path: string().optional(),
15982
+ /**
15983
+ * True when a whole-volume backup of the data directory carries this key
15984
+ * next to the database it protects (the default file). The page warns.
15985
+ */
15986
+ sharesBackupWithDatabase: boolean()
15987
+ });
15988
+ /**
15989
+ * One keychain reset, as the Secrets page reports it until the operator
15990
+ * acknowledges it. Never a value: refs, counts and table names only.
15991
+ */
15992
+ var KeychainResetRecordSchema = object({
15993
+ id: string(),
15994
+ at: number(),
15995
+ /** `user:<id>` or {@link KEYCHAIN_RESET_TRIGGER_ACTOR}. */
15996
+ actor: string(),
15997
+ /** Why the keychain was locked when it was reset; `null` when it was not locked. */
15998
+ lockedReason: string().nullable(),
15999
+ /** Values moved into the archive table (ciphertext under the lost key). */
16000
+ archived: number().int(),
16001
+ /** `keychain:secrets-orphaned-<ts>`, or `null` when nothing was stored. */
16002
+ archivedCollection: string().nullable(),
16003
+ /**
16004
+ * `keychain:keys-orphaned-<ts>`: the wrapped data keys of the archive, kept
16005
+ * so the archive can still be opened if the lost master key turns up.
16006
+ */
16007
+ archivedKeysCollection: string().nullable(),
16008
+ /**
16009
+ * `system-settings` keys whose marker the reset cleared — the cluster
16010
+ * secret's: a marker left pointing at an archived value would refuse every
16011
+ * agent forever (D797).
16012
+ */
16013
+ clearedSettingsKeys: array(string()).readonly(),
16014
+ /** When an operator dismissed the notice on the Secrets page; `null` until then. */
16015
+ acknowledgedAt: number().nullable()
16016
+ });
16017
+ var KeychainStatusSchema = object({
16018
+ keychain: KeychainStateSchema,
16019
+ /** The source of the master key in use; `null` while locked. */
16020
+ keySource: KeychainKeySourceSchema.nullable(),
16021
+ /** The source configured to be primary — differs from `keySource` while a rotation is pending. */
16022
+ configuredSource: KeychainKeySourceSchema,
16023
+ /** Short fingerprint of the master key in use (`HMAC(KEK, label)`, 16 hex). */
16024
+ fingerprint: string().nullable(),
16025
+ activeKeyId: string().nullable(),
16026
+ /**
16027
+ * The keychain unlocked with a NON-primary source: the configured primary
16028
+ * key is not the one that wraps the data key yet. `rotateMasterKey` moves it.
16029
+ */
16030
+ rotationPending: boolean(),
16031
+ /** Wrapped copies of the data key under a previous master key, kept until purged. */
16032
+ retiredWraps: number().int(),
16033
+ recoveryKeyDownloadedAt: number().nullable(),
16034
+ secretCount: number().int(),
16035
+ /** The most recent reset, acknowledged or not; `null` when the keychain was never reset. */
16036
+ lastReset: KeychainResetRecordSchema.nullable()
16037
+ });
16038
+ /**
16039
+ * Whether a stored value is still pointed at by its owner's settings.
16040
+ * `unknown` is a first-class answer: a scope whose blob could not be read is
16041
+ * never reported as an orphan (and never deleted as one).
16042
+ */
16043
+ var KeychainSecretUsageSchema = _enum([
16044
+ "in-use",
16045
+ "orphan",
16046
+ "unknown"
16047
+ ]);
16048
+ var KeychainAdminSecretSchema = KeychainSecretMetaSchema.extend({ usage: KeychainSecretUsageSchema });
16049
+ var KeychainAuditActionSchema = _enum([
16050
+ "put",
16051
+ "delete",
16052
+ "reveal",
16053
+ "rotate-master-key",
16054
+ "purge-retired-keys",
16055
+ "download-recovery-key",
16056
+ "delete-orphans",
16057
+ "reset",
16058
+ "acknowledge-reset",
16059
+ "initialize"
16060
+ ]);
16061
+ var KeychainAuditEntrySchema = object({
16062
+ id: string(),
16063
+ at: number(),
16064
+ action: KeychainAuditActionSchema,
16065
+ /** `addon:<id>` | `user:<id>` | `system` | `trigger-file`. */
16066
+ actor: string(),
16067
+ ref: string().nullable(),
16068
+ detail: string().nullable()
16069
+ });
16070
+ var KEYCHAIN_RESET_CONFIRMATION = "RESET KEYCHAIN";
16071
+ /**
16072
+ * Secrets the HUB itself holds (owner `system`) that no settings form shows:
16073
+ * `jwt-signing-key` — the session signing key (D797). It is always "in use",
16074
+ * never an orphan; it is generated on a fresh hub and replaced only through
16075
+ * {@link keychainAdminCapability.methods.setSystemSecret}.
16076
+ */
16077
+ var SystemHeldSecretNameSchema = _enum(["jwt-signing-key"]);
16078
+ 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({
16079
+ value: string(),
16080
+ version: number().int()
16081
+ }), {
16082
+ kind: "mutation",
16083
+ auth: "admin",
16084
+ caller: "required"
16085
+ }), method(object({
16086
+ name: SystemHeldSecretNameSchema,
16087
+ value: string().min(16)
16088
+ }), object({
16089
+ ref: string(),
16090
+ version: number().int()
16091
+ }), {
16092
+ kind: "mutation",
16093
+ auth: "admin",
16094
+ caller: "required"
16095
+ }), method(object({ refs: array(string().min(1)).max(1e3) }), object({
16096
+ deleted: array(string()).readonly(),
16097
+ kept: array(object({
16098
+ ref: string(),
16099
+ usage: KeychainSecretUsageSchema
16100
+ })).readonly()
16101
+ }), {
16102
+ kind: "mutation",
16103
+ auth: "admin",
16104
+ caller: "required"
16105
+ }), method(object({}), object({
16106
+ fingerprint: string(),
16107
+ keySource: KeychainKeySourceSchema
16108
+ }), {
16109
+ kind: "mutation",
16110
+ auth: "admin",
16111
+ caller: "required"
16112
+ }), method(object({}), object({ purged: number().int() }), {
16113
+ kind: "mutation",
16114
+ auth: "admin",
16115
+ caller: "required"
16116
+ }), method(object({}), object({
16117
+ key: string(),
16118
+ fingerprint: string(),
16119
+ keySource: KeychainKeySourceSchema
16120
+ }), {
16121
+ kind: "mutation",
16122
+ auth: "admin",
16123
+ caller: "required"
16124
+ }), method(object({ confirm: literal(KEYCHAIN_RESET_CONFIRMATION) }), object({
16125
+ archivedCollection: string().nullable(),
16126
+ archived: number().int()
16127
+ }), {
16128
+ kind: "mutation",
16129
+ auth: "admin",
16130
+ caller: "required"
16131
+ }), method(object({}), object({
16132
+ reset: KeychainResetRecordSchema.nullable(),
16133
+ pendingReentry: array(KeychainSecretMetaSchema).readonly()
16134
+ }), { auth: "admin" }), method(object({}), object({ acknowledged: boolean() }), {
16135
+ kind: "mutation",
16136
+ auth: "admin",
16137
+ caller: "required"
16138
+ });
14348
16139
  method(_void(), object({
14349
16140
  id: string(),
14350
16141
  name: string(),
@@ -15804,7 +17595,11 @@ var DeviceRegisterPayloadSchema = object({
15804
17595
  var DeviceRemovePayloadSchema = object({ deviceId: number() });
15805
17596
  var DevicePersistConfigPayloadSchema = object({
15806
17597
  deviceId: number(),
15807
- data: record(string(), unknown())
17598
+ data: record(string(), unknown()),
17599
+ /** The paths the device's schema declares secret (D783), when the caller
17600
+ * knows them — those values are kept in the keychain, not the blob (D787).
17601
+ * Absent: the paths the device last reported at `registerDevice` apply. */
17602
+ secretConfigPaths: array(string()).optional()
15808
17603
  });
15809
17604
  /** What a migration actually did, per switch. `unreachable` is a first-class
15810
17605
  * answer: a camera that could not be asked is not a camera that was silenced. */
@@ -17407,7 +19202,7 @@ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
17407
19202
  * `login-method` — collection cap through which auth addons contribute
17408
19203
  * their pre-auth login surfaces to the login page. This is the SINGLE,
17409
19204
  * generic mechanism that supersedes the dead `auth.listProviders` reader:
17410
- * every auth addon (OIDC, magic-link, WebAuthn/passkey) registers a
19205
+ * every auth addon (OIDC, WebAuthn/passkey) registers a
17411
19206
  * `login-method` provider and the PUBLIC `auth.listLoginMethods`
17412
19207
  * procedure aggregates them for the unauthenticated login page.
17413
19208
  *
@@ -17415,8 +19210,7 @@ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
17415
19210
  *
17416
19211
  * - `redirect` — a declarative button. The login page renders a generic
17417
19212
  * button that navigates to `startUrl` (an addon-owned HTTP route).
17418
- * Covers OIDC (`/addon/auth-oidc/<id>/start`) and magic-link with
17419
- * ZERO shell-side JS. A future SSO addon plugs in the same way — the
19213
+ * Covers OIDC (`/addon/auth-oidc/<id>/start`) with ZERO shell-side JS. A future SSO addon plugs in the same way — the
17420
19214
  * login page needs NO change.
17421
19215
  *
17422
19216
  * - `widget` — a Module-Federation widget the login page mounts (via
@@ -17435,8 +19229,8 @@ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
17435
19229
  * decision.
17436
19230
  *
17437
19231
  * Every contribution carries a `stage`:
17438
- * - `primary` — shown on the first credentials screen (OIDC /
17439
- * magic-link buttons; a future usernameless passkey).
19232
+ * - `primary` — shown on the first credentials screen (OIDC
19233
+ * buttons; a usernameless passkey).
17440
19234
  * - `second-factor` — shown AFTER the password leg, gated on the
17441
19235
  * returned `factors` (passkey-as-2FA today).
17442
19236
  *
@@ -17463,7 +19257,7 @@ var LoginMethodContributionSchema = discriminatedUnion("kind", [
17463
19257
  * The provider names an external identity a signed-in user can link to
17464
19258
  * their own account (D782): `auth.listLinkableProviders` /
17465
19259
  * `beginExternalLink` offer exactly the redirect methods that set this,
17466
- * whatever their id. Absent / false — a login button only (magic-link).
19260
+ * whatever their id. Absent / false — a login button only.
17467
19261
  */
17468
19262
  linkable: boolean().optional()
17469
19263
  }),
@@ -21340,8 +23134,7 @@ method(object({}), object({ rules: array(NcRuleSchema) }), { auth: "admin" }), m
21340
23134
  * `super_admin` — collapsed onto the single boolean because every
21341
23135
  * non-admin caller is governed by the same scope-check rules; the
21342
23136
  * distinction was only ever used to route role-specific procedures
21343
- * which we no longer have. Agents are admin sessions issued via
21344
- * `createServiceToken`; CLI / webhook integrations are `cst_*` tokens
23137
+ * which we no longer have. CLI / webhook integrations are `cst_*` tokens
21345
23138
  * with `isAdmin: false` + an explicit scope list.
21346
23139
  */
21347
23140
  /** Per-method access flavour. Materialised on every cap method via codegen. */
@@ -22859,8 +24652,23 @@ var RetrainMacroClassSchema = _enum([
22859
24652
  ]);
22860
24653
  /** A subject to learn, or a phantom to unlearn (taught by OMISSION). */
22861
24654
  var RetrainAnnotationKindSchema = _enum(["subject", "model_error"]);
22862
- /** Did a human draw this box, or did the assist propose it? */
22863
- var RetrainAnnotationSourceSchema = _enum(["operator", "assist"]);
24655
+ /**
24656
+ * Where a box came from. A machine-sourced box is a DRAFT on the page until
24657
+ * the operator confirms it; once saved it keeps its source as provenance.
24658
+ *
24659
+ * - `operator` — drawn by hand.
24660
+ * - `assist` — proposed by a detector run on the copy (the camera's own
24661
+ * model, or a larger teacher model).
24662
+ * - `pipeline` — the box the live pipeline actually drew on that frame, read
24663
+ * back from the track store (never a re-run).
24664
+ * - `llm` — proposed by a vision-capable LLM profile.
24665
+ */
24666
+ var RetrainAnnotationSourceSchema = _enum([
24667
+ "operator",
24668
+ "assist",
24669
+ "pipeline",
24670
+ "llm"
24671
+ ]);
22864
24672
  /** Normalised `[0,1]` rectangle against the FULL frame — the canonical form. */
22865
24673
  var RetrainBboxSchema = object({
22866
24674
  x: number(),
@@ -22878,7 +24686,8 @@ var RetrainBboxSchema = object({
22878
24686
  */
22879
24687
  var RetrainAnnotationSchema = object({
22880
24688
  id: string(),
22881
- trackId: string(),
24689
+ /** The frame's track. Absent on a recording still, which has none. */
24690
+ trackId: string().optional(),
22882
24691
  deviceId: number(),
22883
24692
  /** The COPY in retrain storage — never the source track's media key. */
22884
24693
  mediaKey: string(),
@@ -22927,13 +24736,47 @@ var RetrainFrameCandidateSchema = object({
22927
24736
  * fail, whatever became of the original. */
22928
24737
  copied: boolean()
22929
24738
  });
24739
+ /**
24740
+ * One box the live pipeline drew on a copied frame — what a correction starts
24741
+ * from. Derived when the frame is listed, from the track store: the subject
24742
+ * box recorded on the source media row when there is one, else the track
24743
+ * position nearest the frame's capture time. Never stored as an annotation
24744
+ * until the operator confirms it.
24745
+ */
24746
+ var RetrainPipelineBoxSchema = object({
24747
+ /** Normalised `[0,1]` against the full frame. */
24748
+ bbox: RetrainBboxSchema,
24749
+ macroClass: RetrainMacroClassSchema,
24750
+ label: string().optional(),
24751
+ subLabel: string().optional(),
24752
+ /** The detection score of the position used, when it was recorded. */
24753
+ score: number().optional(),
24754
+ /** The root model that produced the track, when it was recorded. */
24755
+ modelId: string().optional(),
24756
+ trackId: string(),
24757
+ /** `subject-box`: recorded on this very frame. `position`: the track's
24758
+ * position nearest the capture time, `deltaMs` away. */
24759
+ basis: _enum(["subject-box", "position"]),
24760
+ deltaMs: number()
24761
+ });
24762
+ /**
24763
+ * Where a retrain frame came from: a TRACK's stored media (copy-on-select),
24764
+ * or the RECORDING at an instant — the frame a model saw nothing in has no
24765
+ * track at all.
24766
+ */
24767
+ var RetrainFrameOriginSchema = _enum(["track", "recording"]);
22930
24768
  /** A frame the dataset OWNS: bytes copied at selection time. */
22931
24769
  var RetrainFrameSchema = object({
22932
24770
  frameId: string(),
22933
24771
  deviceId: number(),
22934
- trackId: string(),
22935
- /** Provenance only. It may already point at nothing — that is expected. */
22936
- sourceMediaId: number().int(),
24772
+ origin: RetrainFrameOriginSchema,
24773
+ /** The track it was copied from. Absent on a recording still. */
24774
+ trackId: string().optional(),
24775
+ /** Provenance only. It may already point at nothing — that is expected.
24776
+ * Absent on a recording still. */
24777
+ sourceMediaId: number().int().optional(),
24778
+ /** A recording still: the playhead instant it was taken at. */
24779
+ epochMs: number().optional(),
22937
24780
  sourceKind: MediaFileKindEnum,
22938
24781
  sizeBytes: number().int(),
22939
24782
  width: number().int(),
@@ -22944,7 +24787,12 @@ var RetrainFrameSchema = object({
22944
24787
  /** The operator's "every subject in this frame is boxed". Detector
22945
24788
  * evaluation keeps only complete frames: an unboxed subject would count as
22946
24789
  * a false positive. */
22947
- complete: boolean()
24790
+ complete: boolean(),
24791
+ /** The boxes the pipeline drew on this frame. Present on list answers;
24792
+ * empty when nothing the track store holds can be placed on it. */
24793
+ pipelineBoxes: array(RetrainPipelineBoxSchema).readonly().optional(),
24794
+ /** The named collections this frame belongs to. Present on list answers. */
24795
+ collectionIds: array(string()).readonly().optional()
22948
24796
  });
22949
24797
  /** Why a copy-on-select could not be honoured — named, never a silent skip. */
22950
24798
  var RetrainCopyRefusalSchema = _enum([
@@ -22975,6 +24823,11 @@ var RetrainFrameListSchema = object({
22975
24823
  var RetrainExportFilterSchema = object({
22976
24824
  deviceIds: array(number()).optional(),
22977
24825
  frameIds: array(string()).max(2e4).optional(),
24826
+ /** Only frames in at least one of these named collections. */
24827
+ collectionIds: array(string()).max(200).optional(),
24828
+ /** Exactly the frames of this dataset version (and its completeOnly). An
24829
+ * unknown id selects nothing. */
24830
+ datasetVersionId: string().optional(),
22978
24831
  batchId: string().optional(),
22979
24832
  /** Only frames the operator marked complete (all subjects boxed). */
22980
24833
  completeOnly: boolean().optional()
@@ -23039,6 +24892,170 @@ var RetrainAssistResultSchema = discriminatedUnion("kind", [object({
23039
24892
  reason: string(),
23040
24893
  detail: string().optional()
23041
24894
  })]);
24895
+ /** A named set over the retrain corpus — membership only, it owns no pixels. */
24896
+ var RetrainCollectionSchema = object({
24897
+ id: string(),
24898
+ name: string(),
24899
+ createdAt: number(),
24900
+ frameCount: number().int()
24901
+ });
24902
+ var RetrainCollectionCreateResultSchema = discriminatedUnion("kind", [object({
24903
+ kind: literal("created"),
24904
+ collection: RetrainCollectionSchema
24905
+ }), object({
24906
+ kind: literal("refused"),
24907
+ reason: _enum(["empty-name", "duplicate-name"])
24908
+ })]);
24909
+ var RetrainCollectionRenameResultSchema = discriminatedUnion("kind", [object({
24910
+ kind: literal("renamed"),
24911
+ collection: RetrainCollectionSchema
24912
+ }), object({
24913
+ kind: literal("refused"),
24914
+ reason: _enum([
24915
+ "empty-name",
24916
+ "duplicate-name",
24917
+ "unknown-collection"
24918
+ ])
24919
+ })]);
24920
+ /**
24921
+ * The outcome of adding the frame at a recording instant. Every refusal is
24922
+ * named: `still-unavailable` (not recording, a gap, or an undecodable frame —
24923
+ * `detail` says which), `still-busy` (the recorder is at its decode bound; try
24924
+ * again), `unreadable-image`, `write-failed`, `unknown-collection`.
24925
+ */
24926
+ var AddRetrainFrameFromRecordingResultSchema = discriminatedUnion("kind", [object({
24927
+ kind: literal("added"),
24928
+ collectionId: string(),
24929
+ frame: RetrainFrameSchema,
24930
+ /** The moment was already in the dataset; nothing was decoded. */
24931
+ reused: boolean()
24932
+ }), object({
24933
+ kind: literal("refused"),
24934
+ reason: _enum([
24935
+ "unknown-collection",
24936
+ "still-unavailable",
24937
+ "still-busy",
24938
+ "unreadable-image",
24939
+ "write-failed"
24940
+ ]),
24941
+ detail: string().optional()
24942
+ })]);
24943
+ /** A vision LLM profile the AI assist may use, and where it sends the frame. */
24944
+ var RetrainAssistProfileSchema = object({
24945
+ id: string(),
24946
+ name: string(),
24947
+ model: string(),
24948
+ kind: string(),
24949
+ /** `true` when the frame would leave the house (a cloud vendor, or an
24950
+ * endpoint that is not on the local network). The page confirms each such
24951
+ * run, and the provider refuses one without `allowCloud`. */
24952
+ leavesHouse: boolean()
24953
+ });
24954
+ /** A box the AI assist proposed: a draft, plus the model's own reason. */
24955
+ var RetrainLlmProposalSchema = RetrainAnnotationDraftSchema.extend({ reason: string() });
24956
+ /** What the AI assist said about a box that was already on the canvas. */
24957
+ var RetrainLlmReviewSchema = object({
24958
+ /** The `ref` the page sent the box under. */
24959
+ ref: string(),
24960
+ verdict: _enum([
24961
+ "confirmed",
24962
+ "wrong-class",
24963
+ "not-an-object",
24964
+ "uncertain"
24965
+ ]),
24966
+ suggestedClass: RetrainMacroClassSchema.optional(),
24967
+ reason: string()
24968
+ });
24969
+ /**
24970
+ * The AI assist's answer. `proposed` carries drafts (`source: 'llm'`, the
24971
+ * model and its confidence) and reviews; items the model got wrong (a box off
24972
+ * the frame, an unasked class, an unknown ref) are dropped and counted in
24973
+ * `rejected`. A whole answer that is not the schema is `malformed-answer`.
24974
+ */
24975
+ var RetrainLlmAssistResultSchema = discriminatedUnion("kind", [object({
24976
+ kind: literal("proposed"),
24977
+ profileId: string(),
24978
+ model: string(),
24979
+ /** The frame was sent outside the house for this answer. */
24980
+ leftHouse: boolean(),
24981
+ proposals: array(RetrainLlmProposalSchema).readonly(),
24982
+ reviews: array(RetrainLlmReviewSchema).readonly(),
24983
+ rejected: number().int()
24984
+ }), object({
24985
+ kind: literal("refused"),
24986
+ reason: _enum([
24987
+ "unknown-frame",
24988
+ "unreadable-frame",
24989
+ "unknown-profile",
24990
+ "profile-disabled",
24991
+ "no-vision",
24992
+ "cloud-not-confirmed",
24993
+ "llm-error",
24994
+ "malformed-answer"
24995
+ ]),
24996
+ detail: string().optional()
24997
+ })]);
24998
+ /** What a dataset version is cut from. Every field narrows. */
24999
+ var RetrainDatasetSelectionSchema = object({
25000
+ deviceIds: array(number()).readonly().optional(),
25001
+ collectionIds: array(string()).max(200).readonly().optional(),
25002
+ frameIds: array(string()).max(2e4).readonly().optional()
25003
+ });
25004
+ /** The counts a dataset is judged by. */
25005
+ var RetrainDatasetStatsSchema = object({
25006
+ frames: number().int(),
25007
+ completeFrames: number().int(),
25008
+ /** `completeFrames / frames`, 0..1. */
25009
+ completeness: number(),
25010
+ /** Boxes to learn (model errors excluded). */
25011
+ subjects: number().int(),
25012
+ modelErrors: number().int(),
25013
+ /** Complete frames with no subject. */
25014
+ hardNegatives: number().int(),
25015
+ /** Subjects per class × camera × day/night. */
25016
+ cells: array(object({
25017
+ macroClass: string(),
25018
+ deviceId: number(),
25019
+ lighting: _enum([
25020
+ "day",
25021
+ "night",
25022
+ "unknown"
25023
+ ]),
25024
+ subjects: number().int(),
25025
+ frames: number().int()
25026
+ })).readonly(),
25027
+ cameras: array(object({
25028
+ deviceId: number(),
25029
+ frames: number().int(),
25030
+ completeFrames: number().int()
25031
+ })).readonly()
25032
+ });
25033
+ /** An immutable dataset version, without its frame list. */
25034
+ var RetrainDatasetVersionSchema = object({
25035
+ id: string(),
25036
+ name: string(),
25037
+ createdAt: number(),
25038
+ selection: RetrainDatasetSelectionSchema,
25039
+ layout: RetrainExportLayoutSchema,
25040
+ completeOnly: boolean(),
25041
+ frameCount: number().int(),
25042
+ /** sha256 of what the frames taught when the version was frozen. */
25043
+ annotationHash: string(),
25044
+ /** The export manifest schema the version was cut under. */
25045
+ manifestSchema: string(),
25046
+ stats: RetrainDatasetStatsSchema
25047
+ });
25048
+ var CreateRetrainDatasetVersionResultSchema = discriminatedUnion("kind", [object({
25049
+ kind: literal("created"),
25050
+ version: RetrainDatasetVersionSchema
25051
+ }), object({
25052
+ kind: literal("refused"),
25053
+ reason: _enum([
25054
+ "empty-name",
25055
+ "duplicate-name",
25056
+ "no-frames"
25057
+ ])
25058
+ })]);
23042
25059
  /** The outcome of a lifecycle move owned by the retrain page. */
23043
25060
  var RetrainTransitionResultSchema = object({
23044
25061
  trackId: string(),
@@ -23756,7 +25773,7 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
23756
25773
  auth: "admin"
23757
25774
  }), method(object({
23758
25775
  deviceId: number(),
23759
- trackId: string(),
25776
+ trackId: string().optional(),
23760
25777
  frameId: string()
23761
25778
  }), object({
23762
25779
  removed: boolean(),
@@ -23773,7 +25790,8 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
23773
25790
  auth: "admin"
23774
25791
  }), method(object({
23775
25792
  deviceId: number(),
23776
- trackId: string(),
25793
+ /** The frame's track, when it has one — checked against the frame. */
25794
+ trackId: string().optional(),
23777
25795
  frameId: string(),
23778
25796
  subject: RetrainAssistSubjectSchema,
23779
25797
  /** Which node runs it. Absent ⇒ wherever an unowned call lands. */
@@ -23781,12 +25799,16 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
23781
25799
  }), RetrainAssistResultSchema, {
23782
25800
  kind: "mutation",
23783
25801
  auth: "admin"
23784
- }), method(object({ trackId: string() }), array(RetrainAnnotationSchema).readonly(), {
25802
+ }), method(object({
25803
+ trackId: string().optional(),
25804
+ frameIds: array(string()).max(2e3).optional()
25805
+ }), array(RetrainAnnotationSchema).readonly(), {
23785
25806
  kind: "query",
23786
25807
  auth: "admin"
23787
25808
  }), method(object({
23788
25809
  deviceId: number(),
23789
- trackId: string(),
25810
+ /** The frame's track, when it has one — checked against the frame. */
25811
+ trackId: string().optional(),
23790
25812
  frameId: string(),
23791
25813
  annotations: array(RetrainAnnotationDraftSchema)
23792
25814
  }), array(RetrainAnnotationSchema).readonly(), {
@@ -23809,7 +25831,7 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
23809
25831
  auth: "admin"
23810
25832
  }), method(object({
23811
25833
  deviceId: number(),
23812
- trackId: string(),
25834
+ trackId: string().optional(),
23813
25835
  frameId: string(),
23814
25836
  complete: boolean()
23815
25837
  }), RetrainFrameSchema, {
@@ -23823,6 +25845,115 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
23823
25845
  kind: "mutation",
23824
25846
  auth: "admin",
23825
25847
  timeoutMs: 60 * 6e4
25848
+ }), method(object({
25849
+ filter: RetrainExportFilterSchema,
25850
+ layout: RetrainExportLayoutSchema
25851
+ }), object({
25852
+ ticket: PeerBytesTicketSchema,
25853
+ frames: number().int(),
25854
+ annotations: number().int()
25855
+ }), {
25856
+ kind: "mutation",
25857
+ auth: "admin",
25858
+ timeoutMs: 12e4
25859
+ }), method(object({
25860
+ selection: RetrainDatasetSelectionSchema,
25861
+ completeOnly: boolean().optional()
25862
+ }), RetrainDatasetStatsSchema, {
25863
+ kind: "query",
25864
+ auth: "admin"
25865
+ }), method(object({
25866
+ name: string().max(120),
25867
+ selection: RetrainDatasetSelectionSchema,
25868
+ layout: RetrainExportLayoutSchema,
25869
+ completeOnly: boolean()
25870
+ }), CreateRetrainDatasetVersionResultSchema, {
25871
+ kind: "mutation",
25872
+ auth: "admin",
25873
+ timeoutMs: 12e4
25874
+ }), method(object({}), array(RetrainDatasetVersionSchema).readonly(), {
25875
+ kind: "query",
25876
+ auth: "admin"
25877
+ }), method(object({ id: string() }), object({ deleted: boolean() }), {
25878
+ kind: "mutation",
25879
+ auth: "admin"
25880
+ }), method(object({ id: string() }), object({
25881
+ found: boolean(),
25882
+ annotationHash: string(),
25883
+ matches: boolean(),
25884
+ missingFrames: number().int()
25885
+ }), {
25886
+ kind: "query",
25887
+ auth: "admin",
25888
+ timeoutMs: 12e4
25889
+ }), method(object({}), array(RetrainAssistProfileSchema).readonly(), {
25890
+ kind: "query",
25891
+ auth: "admin"
25892
+ }), method(object({
25893
+ deviceId: number(),
25894
+ trackId: string().optional(),
25895
+ frameId: string(),
25896
+ profileId: string(),
25897
+ classes: array(RetrainMacroClassSchema).min(1),
25898
+ boxes: array(object({
25899
+ ref: string(),
25900
+ bbox: RetrainBboxSchema,
25901
+ macroClass: RetrainMacroClassSchema,
25902
+ label: string().optional()
25903
+ })).max(50),
25904
+ allowCloud: boolean()
25905
+ }), RetrainLlmAssistResultSchema, {
25906
+ kind: "mutation",
25907
+ auth: "admin",
25908
+ timeoutMs: 18e4
25909
+ }), method(object({ name: string().max(120) }), RetrainCollectionCreateResultSchema, {
25910
+ kind: "mutation",
25911
+ auth: "admin"
25912
+ }), method(object({}), array(RetrainCollectionSchema).readonly(), {
25913
+ kind: "query",
25914
+ auth: "admin"
25915
+ }), method(object({
25916
+ id: string(),
25917
+ name: string().max(120)
25918
+ }), RetrainCollectionRenameResultSchema, {
25919
+ kind: "mutation",
25920
+ auth: "admin"
25921
+ }), method(object({ id: string() }), object({
25922
+ deleted: boolean(),
25923
+ removedFrames: number().int()
25924
+ }), {
25925
+ kind: "mutation",
25926
+ auth: "admin"
25927
+ }), method(object({
25928
+ collectionId: string(),
25929
+ deviceId: number(),
25930
+ epochMs: number()
25931
+ }), AddRetrainFrameFromRecordingResultSchema, {
25932
+ kind: "mutation",
25933
+ auth: "admin",
25934
+ timeoutMs: 6e4
25935
+ }), method(object({
25936
+ collectionId: string(),
25937
+ frameIds: array(string()).min(1).max(500)
25938
+ }), object({
25939
+ added: number().int(),
25940
+ alreadyMember: number().int(),
25941
+ unknownFrameIds: array(string()).readonly()
25942
+ }), {
25943
+ kind: "mutation",
25944
+ auth: "admin"
25945
+ }), method(object({
25946
+ collectionId: string(),
25947
+ frameId: string()
25948
+ }), object({
25949
+ removed: boolean(),
25950
+ deletedFrame: boolean()
25951
+ }), {
25952
+ kind: "mutation",
25953
+ auth: "admin"
25954
+ }), method(object({ collectionId: string() }), array(RetrainFrameSchema).readonly(), {
25955
+ kind: "query",
25956
+ auth: "admin"
23826
25957
  }), method(object({
23827
25958
  /** Which of the three event tables owns the row. */
23828
25959
  ownerType: EventOwnerTypeSchema,
@@ -24446,13 +26577,31 @@ var RecommendationReasonSchema = discriminatedUnion("kind", [
24446
26577
  object({
24447
26578
  kind: literal("no-family-build"),
24448
26579
  format: ModelFormatSchema$1
26580
+ }),
26581
+ object({
26582
+ kind: literal("kept-custom-pin"),
26583
+ modelId: string(),
26584
+ deviceKey: string()
24449
26585
  })
24450
26586
  ]);
26587
+ /** Why a device is left exactly as it is, whatever the plan would pick (D786). */
26588
+ var KeptReasonSchema = _enum(["custom-pin"]);
26589
+ /**
26590
+ * Where a choice's latency came from (D791): this node's own benchmark
26591
+ * result, or the hardware-class table. Measured on the node beats the table.
26592
+ */
26593
+ var LatencySourceSchema = discriminatedUnion("kind", [object({ kind: literal("table") }), object({
26594
+ kind: literal("node-benchmark"),
26595
+ resultId: string(),
26596
+ measuredAtMs: number()
26597
+ })]);
24451
26598
  var DeviceModelChoiceSchema = object({
24452
26599
  modelId: string(),
24453
26600
  p50Ms: number(),
24454
26601
  fps: number(),
24455
26602
  measured: boolean(),
26603
+ /** Absent on a plan from before D791 — read as the table. */
26604
+ source: LatencySourceSchema.optional(),
24456
26605
  /** Parallel sessions at the camera rate with the headroom kept free: ⌊fps × (1 − headroom) / camera fps⌋. */
24457
26606
  capacitySessions: number(),
24458
26607
  personRecall: number()
@@ -24463,6 +26612,8 @@ var DeviceRecommendationSchema = object({
24463
26612
  enabled: boolean(),
24464
26613
  available: boolean(),
24465
26614
  chosen: DeviceModelChoiceSchema.nullable(),
26615
+ /** Present when the device is kept as is: Apply writes nothing on it. */
26616
+ kept: KeptReasonSchema.optional(),
24466
26617
  reasons: array(RecommendationReasonSchema).readonly()
24467
26618
  });
24468
26619
  var NodeRecommendationSchema = object({
@@ -24516,6 +26667,17 @@ var AutoTuneWarningSchema = discriminatedUnion("kind", [
24516
26667
  kind: literal("coral-enabled"),
24517
26668
  nodeId: string(),
24518
26669
  deviceKey: string()
26670
+ }),
26671
+ object({
26672
+ kind: literal("custom-pin-kept"),
26673
+ nodeId: string(),
26674
+ deviceKey: string().nullable(),
26675
+ deviceId: number().nullable(),
26676
+ modelId: string()
26677
+ }),
26678
+ object({
26679
+ kind: literal("custom-registry-unreadable"),
26680
+ error: string()
24519
26681
  })
24520
26682
  ]);
24521
26683
  var AutoTuneOptionsSchema = object({
@@ -24694,13 +26856,14 @@ var SuggestSharesResultSchema = object({
24694
26856
  nodes: array(SuggestedNodeShareSchema).readonly()
24695
26857
  });
24696
26858
  /**
24697
- * Where the node and device shares come from (D750, D755).
24698
- * - `hardware` (default) — computed by the system from each node's static
24699
- * capacity (its accelerators at their Auto tune models, from the measured
24700
- * latency table), recomputed whenever a node or device joins, leaves, is
24701
- * switched on or off, or changes model. No load input.
24702
- * - `benchmark` — the same, from each node's measured capacity (node
24703
- * benchmark results); a node without results falls back to `hardware`.
26859
+ * Where the node and device shares come from (D750, D755, D791).
26860
+ * - `benchmark` (default since D791) — each node's capacity as its own node
26861
+ * benchmark measured it; a node without fresh results is sized from
26862
+ * `hardware` and says so. Measured on the node beats the table.
26863
+ * - `hardware` — computed from each node's static capacity only (its
26864
+ * accelerators at their Auto tune models, from the latency table).
26865
+ * Both are recomputed whenever a node or device joins, leaves, is switched
26866
+ * on or off, changes model, or a benchmark result is written. No load input.
24704
26867
  * - `manual` — the operator's stored sliders.
24705
26868
  * Either way a node or device that cannot take sessions gives its share to
24706
26869
  * the others in proportion; the stored values are never rewritten for that.
@@ -24749,6 +26912,362 @@ var EffectiveSharesSchema = object({
24749
26912
  nodeWeights: record(string(), number()),
24750
26913
  deviceWeights: record(string(), record(string(), number()))
24751
26914
  });
26915
+ /**
26916
+ * Wire shapes of the node benchmark (D791): the operator's plan, the
26917
+ * preflight the confirmation shows, the run the orchestrator owns, what the
26918
+ * measuring runner reports, and the result rows Auto tune and the automatic
26919
+ * shares read.
26920
+ *
26921
+ * ONE node at a time, owned by the pipeline orchestrator. While a run is
26922
+ * active the cluster is in BENCHMARK MODE for that node: it is not a
26923
+ * detection candidate, camera pins naming it are ignored so its sessions move
26924
+ * elsewhere, and both come back when the mode ends — after a crash or a hub
26925
+ * restart too (a persisted manifest, reconciled against the registry).
26926
+ *
26927
+ * Two measurements, both on the node, driven by its own runner (frames never
26928
+ * cross a process at frame rate, D9):
26929
+ * - `device` — one accelerator × one candidate detector, root only, open
26930
+ * loop: how many streams at the camera rate it carries inside the frame
26931
+ * interval;
26932
+ * - `pipeline` — the chosen detector plus the operator's detail steps
26933
+ * (faces, plates, classifiers, CLIP…), on varied frames from the bench
26934
+ * clip: how many parallel sessions the node carries before latency, drops,
26935
+ * CPU, RAM or the event loop give out.
26936
+ */
26937
+ /** Defaults and bounds, one place. */
26938
+ var NODE_BENCHMARK_DEFAULTS = {
26939
+ fpsPerStream: 10,
26940
+ budgetMinutes: 45,
26941
+ minBudgetMinutes: 10,
26942
+ maxBudgetMinutes: 120,
26943
+ /** A result older than this no longer beats the table. */
26944
+ staleAfterDays: 30,
26945
+ /** Warm-in per ramp step (not accounted). */
26946
+ settleSec: 5,
26947
+ /** Accounted window per ramp step. */
26948
+ measureSec: 20,
26949
+ /** Longest the drain may take before the run is refused. */
26950
+ drainTimeoutSec: 120,
26951
+ /** Candidate models per device in one run. */
26952
+ maxModelsPerDevice: 6
26953
+ };
26954
+ /** The two measurements a run can make. */
26955
+ var NodeBenchmarkPhaseSchema = _enum(["device", "pipeline"]);
26956
+ var NodeBenchmarkDevicePlanSchema = object({
26957
+ /** `<backend>:<device>` — `openvino:npu`, `coreml:all`, `cpu`. */
26958
+ deviceKey: string().min(1),
26959
+ /**
26960
+ * Root detector candidates for the `device` measurement, in the order
26961
+ * measured. The FIRST is the one the `pipeline` measurement runs.
26962
+ */
26963
+ modelIds: array(string().min(1)).min(1).max(NODE_BENCHMARK_DEFAULTS.maxModelsPerDevice)
26964
+ });
26965
+ /** What the operator confirmed. */
26966
+ var NodeBenchmarkPlanSchema = object({
26967
+ nodeId: string().min(1),
26968
+ devices: array(NodeBenchmarkDevicePlanSchema).min(1),
26969
+ /** Which measurements run. At least one. */
26970
+ phases: array(NodeBenchmarkPhaseSchema).min(1).default(["device", "pipeline"]),
26971
+ /**
26972
+ * Detail steps (catalog step ids under the root: faces, plates,
26973
+ * classifiers, CLIP…) the `pipeline` measurement enables. The root
26974
+ * detector always runs.
26975
+ */
26976
+ steps: array(string().min(1)).default([]),
26977
+ /** Offered rate of one stream / session. */
26978
+ fpsPerStream: number().int().min(1).max(30).default(NODE_BENCHMARK_DEFAULTS.fpsPerStream),
26979
+ /** Hard deadline: the mode ends and the cluster is restored when it passes. */
26980
+ budgetMinutes: number().int().min(NODE_BENCHMARK_DEFAULTS.minBudgetMinutes).max(NODE_BENCHMARK_DEFAULTS.maxBudgetMinutes).default(NODE_BENCHMARK_DEFAULTS.budgetMinutes),
26981
+ /** Keep the models the run downloaded (default: delete what was not installed before). */
26982
+ keepDownloadedModels: boolean().default(false),
26983
+ /** Start although the other nodes' capacity does not cover the sessions running now. */
26984
+ acceptInsufficientHeadroom: boolean().default(false)
26985
+ });
26986
+ var NodeBenchmarkRefusalSchema = object({
26987
+ kind: _enum([
26988
+ "benchmark-active",
26989
+ "node-offline",
26990
+ "unknown-device",
26991
+ "no-phase",
26992
+ "insufficient-headroom"
26993
+ ]),
26994
+ detail: string(),
26995
+ overridable: boolean()
26996
+ });
26997
+ /** A camera whose detection leaves the node for the run. */
26998
+ var NodeBenchmarkMovingCameraSchema = object({
26999
+ deviceId: number(),
27000
+ /** Placed on the node now (a standing attach or a running session). */
27001
+ placedOnNode: boolean(),
27002
+ /** A node pin naming this node, ignored for the run. */
27003
+ pinnedToNode: boolean()
27004
+ });
27005
+ /** A camera that cannot leave: no other node can obtain its frames. */
27006
+ var NodeBenchmarkStayingCameraSchema = object({
27007
+ deviceId: number(),
27008
+ reason: literal("only-frame-source")
27009
+ });
27010
+ var NodeBenchmarkPreflightSchema = object({
27011
+ nodeId: string(),
27012
+ online: boolean(),
27013
+ moving: array(NodeBenchmarkMovingCameraSchema).readonly(),
27014
+ /** Keep running on the node during the run; the result is flagged contaminated. */
27015
+ staying: array(NodeBenchmarkStayingCameraSchema).readonly(),
27016
+ estimatedDurationMs: number(),
27017
+ /** The run ends and the cluster is restored at the latest after this long. */
27018
+ budgetMs: number(),
27019
+ phases: array(NodeBenchmarkPhaseSchema).readonly(),
27020
+ steps: array(string()).readonly(),
27021
+ devices: array(NodeBenchmarkDevicePlanSchema).readonly(),
27022
+ /** Parallel sessions the cluster runs now, and what the other nodes can carry. */
27023
+ headroom: object({
27024
+ sessionsNow: number(),
27025
+ otherNodesCapacitySessions: number().nullable()
27026
+ }),
27027
+ refusals: array(NodeBenchmarkRefusalSchema).readonly(),
27028
+ canStart: boolean()
27029
+ });
27030
+ /** Where the measuring runner is. */
27031
+ var NodeBenchProgressSchema = object({
27032
+ phase: _enum([
27033
+ "preparing",
27034
+ "device",
27035
+ "pipeline",
27036
+ "cleanup"
27037
+ ]),
27038
+ deviceKey: string().nullable(),
27039
+ modelId: string().nullable(),
27040
+ /** Streams (device) or sessions (pipeline) of the step running now. */
27041
+ load: number().nullable(),
27042
+ cellsDone: number(),
27043
+ cellsTotal: number(),
27044
+ message: string()
27045
+ });
27046
+ /** What limited a ramp. `none` = the ramp ran out of steps still passing. */
27047
+ var NodeBenchLimitSchema = _enum([
27048
+ "p95",
27049
+ "drops",
27050
+ "errors",
27051
+ "stall",
27052
+ "cpu",
27053
+ "ram",
27054
+ "none"
27055
+ ]);
27056
+ var NodeBenchRampStepSchema = object({
27057
+ load: number(),
27058
+ pass: boolean(),
27059
+ p95Ms: number(),
27060
+ dropRatio: number(),
27061
+ /** Completed frames per second over the accounted window. */
27062
+ fps: number(),
27063
+ cpuPct: number().nullable(),
27064
+ ramFreePct: number().nullable(),
27065
+ failReasons: array(string()).readonly()
27066
+ });
27067
+ var NodeBenchCellSchema = discriminatedUnion("phase", [object({
27068
+ phase: literal("device"),
27069
+ deviceKey: string(),
27070
+ modelId: string(),
27071
+ /** Single-stream latency (the K = 1 step). */
27072
+ p50Ms: number(),
27073
+ p95Ms: number(),
27074
+ p99Ms: number(),
27075
+ /** Frames per second sustained at the last passing step. */
27076
+ fps: number(),
27077
+ /** Streams at the camera rate the device carried inside the frame interval; 0 = not even one. */
27078
+ kMax: number(),
27079
+ limitedBy: NodeBenchLimitSchema,
27080
+ /** First call (model load + warm-up). */
27081
+ warmupMs: number(),
27082
+ ramp: array(NodeBenchRampStepSchema).readonly()
27083
+ }), object({
27084
+ phase: literal("pipeline"),
27085
+ deviceKey: string(),
27086
+ modelId: string(),
27087
+ steps: array(string()).readonly(),
27088
+ /** Parallel sessions at the camera rate the node carried; 0 = not even one. */
27089
+ maxSessions: number(),
27090
+ limitedBy: NodeBenchLimitSchema,
27091
+ /** Detail steps that produced at least one result on the clip — a step that never fired measured nothing. */
27092
+ stepsFired: array(string()).readonly(),
27093
+ warmupMs: number(),
27094
+ ramp: array(NodeBenchRampStepSchema).readonly()
27095
+ })]);
27096
+ /**
27097
+ * What a result was measured ON. A result whose fingerprint no longer matches
27098
+ * the node no longer beats the table.
27099
+ */
27100
+ var NodeBenchFingerprintSchema = object({
27101
+ pipelineVersion: string().nullable(),
27102
+ cpuModel: string().nullable(),
27103
+ ramGb: number().nullable(),
27104
+ os: string().nullable(),
27105
+ /** Per device: the pool the cells ran on (runtime + tuning). */
27106
+ pools: record(string(), object({
27107
+ runtime: string(),
27108
+ numWorkers: number(),
27109
+ concurrency: number(),
27110
+ batchMode: string()
27111
+ })).default({})
27112
+ });
27113
+ /** The frames the run used. */
27114
+ var NodeBenchClipSchema = object({
27115
+ /** `camstack-bench-v1` or `reference-images` (the fallback when the clip is not reachable). */
27116
+ id: string(),
27117
+ revision: string().nullable(),
27118
+ frames: number(),
27119
+ width: number(),
27120
+ height: number()
27121
+ });
27122
+ var NodeBenchRunnerInputSchema = object({
27123
+ runId: string().min(1),
27124
+ devices: array(NodeBenchmarkDevicePlanSchema).min(1),
27125
+ phases: array(NodeBenchmarkPhaseSchema).min(1),
27126
+ /** The full detail step tree root for the `pipeline` measurement is built on the node from these ids. */
27127
+ steps: array(string()).default([]),
27128
+ fpsPerStream: number().int().min(1).max(30),
27129
+ /** The runner stops on its own past this instant, whatever the hub does. */
27130
+ deadlineAtMs: number(),
27131
+ settleSec: number().min(0).max(60).default(NODE_BENCHMARK_DEFAULTS.settleSec),
27132
+ measureSec: number().min(2).max(300).default(NODE_BENCHMARK_DEFAULTS.measureSec),
27133
+ keepDownloadedModels: boolean().default(false)
27134
+ });
27135
+ var NodeBenchRunnerStateSchema = _enum([
27136
+ "running",
27137
+ "done",
27138
+ "failed",
27139
+ "aborted"
27140
+ ]);
27141
+ var NodeBenchRunnerStatusSchema = object({
27142
+ runId: string(),
27143
+ nodeId: string(),
27144
+ state: NodeBenchRunnerStateSchema,
27145
+ progress: NodeBenchProgressSchema.nullable(),
27146
+ /** Every finished cell so far — a run stopped half way keeps what it measured. */
27147
+ cells: array(NodeBenchCellSchema).readonly(),
27148
+ fingerprint: NodeBenchFingerprintSchema.nullable(),
27149
+ clip: NodeBenchClipSchema.nullable(),
27150
+ /** Cameras seen running on the node during the run (they share its pools). */
27151
+ activeCameraIds: array(number()).readonly(),
27152
+ /** Models the run downloaded and then deleted (not installed before). */
27153
+ deletedModels: array(string()).readonly(),
27154
+ error: string().nullable(),
27155
+ startedAtMs: number(),
27156
+ finishedAtMs: number().nullable()
27157
+ });
27158
+ var NodeBenchmarkStateSchema = _enum([
27159
+ "draining",
27160
+ "measuring",
27161
+ "restoring",
27162
+ "done",
27163
+ "failed",
27164
+ "aborted"
27165
+ ]);
27166
+ /** Why a run ended. */
27167
+ var NodeBenchmarkEndReasonSchema = _enum([
27168
+ "completed",
27169
+ "operator-abort",
27170
+ "deadline",
27171
+ "node-lost",
27172
+ "runner-lost",
27173
+ "hub-restart",
27174
+ "drain-timeout",
27175
+ "failed"
27176
+ ]);
27177
+ var NodeBenchmarkRunSchema = object({
27178
+ runId: string(),
27179
+ nodeId: string(),
27180
+ state: NodeBenchmarkStateSchema,
27181
+ plan: NodeBenchmarkPlanSchema,
27182
+ startedAtMs: number(),
27183
+ deadlineAtMs: number(),
27184
+ finishedAtMs: number().nullable(),
27185
+ endReason: NodeBenchmarkEndReasonSchema.nullable(),
27186
+ error: string().nullable(),
27187
+ /** Cameras moved off the node for the run. */
27188
+ moved: array(number()).readonly(),
27189
+ /** Cameras that stayed (their only frame source is the node). */
27190
+ staying: array(number()).readonly(),
27191
+ /** Something else ran on the node's pools during the run. */
27192
+ contaminated: boolean(),
27193
+ progress: NodeBenchProgressSchema.nullable(),
27194
+ resultIds: array(string()).readonly()
27195
+ });
27196
+ /** `getNodeBenchmarkStatus`: the active run (or the last one), and whether benchmark mode is on. */
27197
+ var NodeBenchmarkStatusSchema = object({
27198
+ /** The node the cluster is in benchmark mode for; null = none. */
27199
+ modeNodeId: string().nullable(),
27200
+ run: NodeBenchmarkRunSchema.nullable()
27201
+ });
27202
+ /**
27203
+ * One stored measurement — the only authority Auto tune and the automatic
27204
+ * shares read measured capacity from. Written by the orchestrator when a run
27205
+ * ends, never by anyone else.
27206
+ */
27207
+ var NodeBenchmarkResultSchema = object({
27208
+ id: string(),
27209
+ runId: string(),
27210
+ nodeId: string(),
27211
+ cell: NodeBenchCellSchema,
27212
+ fpsPerStream: number(),
27213
+ fingerprint: NodeBenchFingerprintSchema.nullable(),
27214
+ clip: NodeBenchClipSchema.nullable(),
27215
+ /** Other work shared the node's pools (a camera that could not move, or the hub's own duties). */
27216
+ contaminated: boolean(),
27217
+ stayingCameras: array(number()).readonly(),
27218
+ /** The run ended early; the cell itself completed. */
27219
+ partialRun: boolean(),
27220
+ measuredAtMs: number()
27221
+ });
27222
+ var ListNodeBenchmarkResultsInputSchema = object({
27223
+ nodeId: string().optional(),
27224
+ deviceKey: string().optional()
27225
+ });
27226
+ /** A result with its standing today: does it still beat the table? */
27227
+ var NodeBenchmarkResultViewSchema = NodeBenchmarkResultSchema.extend({
27228
+ /** `fresh` beats the table; `stale` falls back to it; `superseded` = a newer row covers the same cell. */
27229
+ standing: _enum([
27230
+ "fresh",
27231
+ "stale",
27232
+ "superseded"
27233
+ ]),
27234
+ staleWhy: _enum([
27235
+ "age",
27236
+ "runtime",
27237
+ "pool-tuning"
27238
+ ]).nullable()
27239
+ });
27240
+ object({
27241
+ runId: string(),
27242
+ nodeId: string(),
27243
+ startedAtMs: number(),
27244
+ deadlineAtMs: number(),
27245
+ plan: NodeBenchmarkPlanSchema,
27246
+ moved: array(number()).readonly(),
27247
+ staying: array(number()).readonly()
27248
+ });
27249
+ /** Candidate detectors per device, for the plan editor. */
27250
+ var NodeBenchmarkCandidatesSchema = object({
27251
+ nodeId: string(),
27252
+ reachable: boolean(),
27253
+ devices: array(object({
27254
+ deviceKey: string(),
27255
+ enabled: boolean(),
27256
+ available: boolean(),
27257
+ /** Ordered: what Auto tune would pick first, then the rest of the family by accuracy. */
27258
+ suggested: array(string()).readonly(),
27259
+ /** Every root detector the device has a build for. */
27260
+ all: array(string()).readonly(),
27261
+ /** The model the device runs now, when pinned. */
27262
+ currentModelId: string().nullable()
27263
+ })).readonly(),
27264
+ /** Detail steps the node's catalog offers under the root (for the `pipeline` measurement). */
27265
+ steps: array(object({
27266
+ id: string(),
27267
+ name: string(),
27268
+ slot: string()
27269
+ })).readonly()
27270
+ });
24752
27271
  object({
24753
27272
  activeCameras: number(),
24754
27273
  throttledCameras: number(),
@@ -25877,7 +28396,16 @@ method(RunnerCameraConfigSchema, object({ success: literal(true) }), { kind: "mu
25877
28396
  }), ParkedTrackFrameSchema.nullable()), method(object({
25878
28397
  deviceId: number(),
25879
28398
  trackId: string()
25880
- }), object({ released: number().int().nonnegative() }), { kind: "mutation" });
28399
+ }), object({ released: number().int().nonnegative() }), { kind: "mutation" }), method(NodeBenchRunnerInputSchema, object({
28400
+ accepted: literal(true),
28401
+ runId: string()
28402
+ }), {
28403
+ kind: "mutation",
28404
+ auth: "admin"
28405
+ }), method(object({ runId: string() }), NodeBenchRunnerStatusSchema.nullable(), { auth: "admin" }), method(object({ runId: string() }), object({ aborted: boolean() }), {
28406
+ kind: "mutation",
28407
+ auth: "admin"
28408
+ });
25881
28409
  var CameraPipelineConfigSchema = object({
25882
28410
  engine: PipelineEngineChoiceSchema.optional(),
25883
28411
  steps: array(PipelineStepInputSchema).readonly(),
@@ -26516,6 +29044,21 @@ method(object({
26516
29044
  }), method(PlacementStatsInputSchema, PlacementStatsSchema, { auth: "admin" }), method(SuggestSharesInputSchema, SuggestSharesResultSchema, { auth: "admin" }), method(_void(), EffectiveSharesSchema, { auth: "admin" }), method(SetShareSourceInputSchema, object({ success: literal(true) }), {
26517
29045
  kind: "mutation",
26518
29046
  auth: "admin"
29047
+ }), method(NodeBenchmarkPlanSchema, NodeBenchmarkPreflightSchema, { auth: "admin" }), method(NodeBenchmarkPlanSchema, discriminatedUnion("kind", [object({
29048
+ kind: literal("started"),
29049
+ runId: string()
29050
+ }), object({
29051
+ kind: literal("refused"),
29052
+ preflight: NodeBenchmarkPreflightSchema
29053
+ })]), {
29054
+ kind: "mutation",
29055
+ auth: "admin"
29056
+ }), method(_void(), NodeBenchmarkStatusSchema, { auth: "admin" }), method(object({ runId: string() }), object({ aborted: boolean() }), {
29057
+ kind: "mutation",
29058
+ auth: "admin"
29059
+ }), method(object({ nodeId: string() }), NodeBenchmarkCandidatesSchema, { auth: "admin" }), method(ListNodeBenchmarkResultsInputSchema, array(NodeBenchmarkResultViewSchema).readonly(), { auth: "admin" }), method(object({ id: string() }), object({ deleted: boolean() }), {
29060
+ kind: "mutation",
29061
+ auth: "admin"
26519
29062
  }), method(object({ deviceId: number() }), CameraPipelineSettingsSchema.nullable()), method(object({
26520
29063
  deviceId: number(),
26521
29064
  addonId: string(),
@@ -26921,8 +29464,8 @@ version: string().optional() }), ServerUpdateActionResultSchema, {
26921
29464
  * `smtp-provider` — pluggable email delivery surface.
26922
29465
  *
26923
29466
  * Collection cap: a deployment may install multiple SMTP relays (e.g.
26924
- * one for transactional / one for notifications). Consumers (magic-link,
26925
- * notifier addons, …) walk the collection and pick the first
29467
+ * one for transactional / one for notifications). Consumers (notifier
29468
+ * addons, …) walk the collection and pick the first
26926
29469
  * ready provider OR target a specific addonId.
26927
29470
  *
26928
29471
  * The shape stays small on purpose — `sendEmail` is enough for the
@@ -27101,7 +29644,7 @@ targets: array(object({
27101
29644
  })));
27102
29645
  /**
27103
29646
  * `sso-bridge` — internal hub-only cap that lets SSO-style auth
27104
- * providers (OIDC, SAML, magic-link, …) mint an HMAC-signed token
29647
+ * providers (OIDC, SAML, …) mint an HMAC-signed token
27105
29648
  * carrying the post-callback claims before redirecting back to
27106
29649
  * `/api/auth/sso/finish`.
27107
29650
  *
@@ -27164,7 +29707,14 @@ var SsoBridgeClaimsSchema = object({
27164
29707
  * Verified `iss` of the id_token behind an OIDC login bridge (D782). A
27165
29708
  * subject is unique only per issuer, so a link is bound to it.
27166
29709
  */
27167
- issuer: string().optional()
29710
+ issuer: string().optional(),
29711
+ /**
29712
+ * SHA-256 (hex) of the `camstack_sso_state` cookie the IdP `/start` set in
29713
+ * the browser that began this sign-in. `/api/auth/sso/finish` requires the
29714
+ * request to present the matching cookie — a login bridge is useless in
29715
+ * any other browser.
29716
+ */
29717
+ browserBinding: string().optional()
27168
29718
  });
27169
29719
  method(object({
27170
29720
  claims: SsoBridgeClaimsSchema,
@@ -32721,6 +35271,9 @@ var CreateIntegrationInputSchema = object({
32721
35271
  enabled: boolean().optional(),
32722
35272
  info: record(string(), unknown()).optional(),
32723
35273
  settings: record(string(), unknown()).optional(),
35274
+ /** Keys of `settings` the form's schema declares secret (by type) — kept in
35275
+ * the keychain, not the table (D787). */
35276
+ secretKeys: array(string()).optional(),
32724
35277
  skipRestart: boolean().optional()
32725
35278
  });
32726
35279
  var UpdateIntegrationInputSchema = object({
@@ -32744,7 +35297,9 @@ method(_void(), array(IntegrationWithStateSchema)), method(object({ id: string()
32744
35297
  auth: "admin"
32745
35298
  }), method(object({ id: string() }), record(string(), unknown()), { auth: "admin" }), method(object({
32746
35299
  id: string(),
32747
- settings: record(string(), unknown())
35300
+ settings: record(string(), unknown()),
35301
+ /** Keys the form's schema declares secret (by type) — keychain-stored (D787). */
35302
+ secretKeys: array(string()).optional()
32748
35303
  }), object({ success: boolean() }), {
32749
35304
  kind: "mutation",
32750
35305
  auth: "admin"
@@ -39516,16 +42071,6 @@ var ApiKeySummarySchema = object({
39516
42071
  createdAt: number(),
39517
42072
  lastUsedAt: number().optional()
39518
42073
  });
39519
- var CreateApiKeyInputSchema = object({
39520
- label: string(),
39521
- isAdmin: boolean().default(false),
39522
- allowedProviders: union([array(string()), literal("*")]).optional(),
39523
- allowedDevices: record(string(), union([array(string()), literal("*")])).optional()
39524
- });
39525
- var CreateApiKeyResultSchema = object({
39526
- token: string(),
39527
- record: ApiKeySummarySchema
39528
- });
39529
42074
  var ScopedTokenSummarySchema = object({
39530
42075
  id: string(),
39531
42076
  userId: string(),
@@ -39624,17 +42169,10 @@ method(_void(), array(UserSummarySchema), { auth: "admin" }), method(CreateUserI
39624
42169
  }), UserSummarySchema.extend({ passwordHash: string() }).nullable(), {
39625
42170
  kind: "mutation",
39626
42171
  access: "view"
39627
- }), method(_void(), array(ApiKeySummarySchema), { auth: "admin" }), method(CreateApiKeyInputSchema, CreateApiKeyResultSchema, {
39628
- kind: "mutation",
39629
- auth: "admin",
39630
- access: "create"
39631
- }), method(object({ id: string() }), object({ success: literal(true) }), {
42172
+ }), method(_void(), array(ApiKeySummarySchema), { auth: "admin" }), method(object({ id: string() }), object({ success: literal(true) }), {
39632
42173
  kind: "mutation",
39633
42174
  auth: "admin",
39634
42175
  access: "delete"
39635
- }), method(object({ token: string() }), ApiKeySummarySchema.nullable(), {
39636
- kind: "mutation",
39637
- access: "view"
39638
42176
  }), method(CreateScopedTokenInputSchema, CreateScopedTokenResultSchema, {
39639
42177
  kind: "mutation",
39640
42178
  auth: "admin",
@@ -39708,15 +42246,7 @@ method(_void(), array(UserSummarySchema), { auth: "admin" }), method(CreateUserI
39708
42246
  }).nullable(), { access: "view" }), method(object({ userId: string() }), array(ExternalIdentitySchema), { auth: "admin" }), method(ExternalIdentityKeySchema, object({
39709
42247
  userId: string(),
39710
42248
  issuer: string()
39711
- }).nullable(), { auth: "admin" }), method(ExternalIdentityKeySchema.extend({
39712
- userId: string(),
39713
- issuer: string().min(1),
39714
- label: string().optional()
39715
- }), object({ success: literal(true) }), {
39716
- kind: "mutation",
39717
- auth: "admin",
39718
- access: "create"
39719
- }), method(ExternalIdentityKeySchema.extend({ userId: string() }), object({ success: boolean() }), {
42249
+ }).nullable(), { auth: "admin" }), method(ExternalIdentityKeySchema.extend({ userId: string() }), object({ success: boolean() }), {
39720
42250
  kind: "mutation",
39721
42251
  auth: "admin",
39722
42252
  access: "delete"
@@ -40421,6 +42951,451 @@ var zoneRulesCapability = {
40421
42951
  */
40422
42952
  durability: "restored"
40423
42953
  };
42954
+ /**
42955
+ * `training-provider` — ONE cloud that can run the CamStack trainer.
42956
+ *
42957
+ * A thin, mockable translation layer: it knows how to run a container with a
42958
+ * GPU, move a dataset in, read the job's stdout and hand artefacts back. It
42959
+ * knows nothing about datasets, splits, floors, cost policy or Model Studio —
42960
+ * those are the `training` orchestrator's (D805). Every rule written there
42961
+ * once is what makes a second provider (RunPod, a local NVIDIA node) a new
42962
+ * manifest entry and nothing else.
42963
+ *
42964
+ * Collection, routed by the `addonId` in every single-row input (the `llm` /
42965
+ * `notification-output` posture); `describe` concat-fans across providers.
42966
+ * Every method is `admin`: these spend money.
42967
+ *
42968
+ * Every cloud object a provider creates is tagged with the orchestrator's
42969
+ * `jobKey`, so a retried submit finds the job it already started instead of
42970
+ * starting a second GPU, and `listJobs` can find orphans.
42971
+ *
42972
+ * Bytes never ride a cap field: the dataset arrives as a `ctx.peerBytes`
42973
+ * ticket the producer (pipeline-analytics) minted, and artefacts leave as a
42974
+ * ticket the provider mints (D613).
42975
+ */
42976
+ var TrainingGpuOptionSchema = object({
42977
+ id: string(),
42978
+ label: string(),
42979
+ /** List price, USD per GPU-hour, before any region multiplier. */
42980
+ usdPerHour: number().nonnegative(),
42981
+ vramGb: number().nonnegative()
42982
+ });
42983
+ var TrainingRegionOptionSchema = object({
42984
+ /** `''` = any region (the provider's choice). */
42985
+ id: string(),
42986
+ label: string(),
42987
+ priceMultiplier: number().positive()
42988
+ });
42989
+ /**
42990
+ * The provider's per-account settings, as the orchestrator reads them. They
42991
+ * live in the PROVIDER addon's settings (operator decision 2026-10-08: they
42992
+ * depend on the user's account), never hard-coded in the orchestrator.
42993
+ */
42994
+ var TrainingProviderDefaultsSchema = object({
42995
+ gpuType: string(),
42996
+ region: string(),
42997
+ costCapUsd: number().nonnegative(),
42998
+ maxRuntimeSec: number().int().positive(),
42999
+ /** Hours a FAILED job's cloud dataset is kept for debugging; 0 = delete at once. */
43000
+ failedDatasetGraceHours: number().nonnegative()
43001
+ });
43002
+ var TrainingProviderDescriptorSchema = object({
43003
+ addonId: string(),
43004
+ /** `modal`, `runpod`, `fake`, … */
43005
+ kind: string(),
43006
+ label: string(),
43007
+ gpuTypes: array(TrainingGpuOptionSchema).readonly(),
43008
+ regions: array(TrainingRegionOptionSchema).readonly(),
43009
+ maxDatasetBytes: number().int().positive(),
43010
+ maxRuntimeSec: number().int().positive(),
43011
+ freeTierNote: string().optional(),
43012
+ /** Where the data goes, in one sentence the confirm dialog repeats. */
43013
+ dataResidencyNote: string(),
43014
+ /** Credentials are present — never the values. */
43015
+ configured: boolean(),
43016
+ defaults: TrainingProviderDefaultsSchema
43017
+ });
43018
+ var TrainingCredentialCheckSchema = object({
43019
+ ok: boolean(),
43020
+ /** Workspace / account name, when the provider says. */
43021
+ account: string().optional(),
43022
+ reason: _enum([
43023
+ "missing",
43024
+ "invalid",
43025
+ "forbidden",
43026
+ "network",
43027
+ "quota"
43028
+ ]).optional(),
43029
+ detail: string().optional()
43030
+ });
43031
+ var ProviderJobStateSchema = _enum([
43032
+ "pending",
43033
+ "starting",
43034
+ "running",
43035
+ "succeeded",
43036
+ "failed",
43037
+ "cancelled",
43038
+ "lost"
43039
+ ]);
43040
+ var ProviderJobStatusSchema = object({
43041
+ jobKey: string(),
43042
+ providerJobId: string().optional(),
43043
+ state: ProviderJobStateSchema,
43044
+ startedAt: number().optional(),
43045
+ endedAt: number().optional(),
43046
+ exitCode: number().int().optional(),
43047
+ failureReason: string().optional(),
43048
+ gpuType: string(),
43049
+ region: string().optional(),
43050
+ billedSeconds: number().nonnegative(),
43051
+ costUsd: number().nonnegative(),
43052
+ /** True when `costUsd` is runtime × list price, not a billing answer. */
43053
+ costIsEstimate: boolean(),
43054
+ lastFetchedAt: number()
43055
+ });
43056
+ /**
43057
+ * The trainer the job runs, by SOURCE revision: the provider turns it into an
43058
+ * image its own way (Modal builds the published Dockerfile at that revision;
43059
+ * a registry-pull provider maps it to a tag). Recorded on the job and echoed
43060
+ * in `result.json`.
43061
+ */
43062
+ var TrainerSourceRefSchema = object({
43063
+ /** Hugging Face repo id, e.g. `camstack/camstack-trainer`. */
43064
+ repo: string().min(1),
43065
+ /** A commit sha (never a branch) — the job must be reproducible. */
43066
+ revision: string().regex(/^[0-9a-f]{7,64}$/)
43067
+ });
43068
+ var JobRef = {
43069
+ addonId: string(),
43070
+ jobKey: string().uuid()
43071
+ };
43072
+ var TrainingLogLineSchema = object({
43073
+ ts: number(),
43074
+ text: string()
43075
+ });
43076
+ method(object({}), array(TrainingProviderDescriptorSchema).readonly(), { auth: "admin" }), method(object({ addonId: string() }), TrainingCredentialCheckSchema, {
43077
+ kind: "mutation",
43078
+ auth: "admin",
43079
+ timeoutMs: 3e4
43080
+ }), method(object({
43081
+ addonId: string(),
43082
+ gpuType: string(),
43083
+ region: string(),
43084
+ datasetBytes: number().int().nonnegative(),
43085
+ gpuSecondsLow: number().nonnegative(),
43086
+ gpuSecondsHigh: number().nonnegative()
43087
+ }), object({
43088
+ usdLow: number().nonnegative(),
43089
+ usdHigh: number().nonnegative(),
43090
+ notes: array(string()).readonly()
43091
+ }), { auth: "admin" }), method(object({
43092
+ ...JobRef,
43093
+ ticket: PeerBytesTicketSchema
43094
+ }), object({
43095
+ bytes: number().int().nonnegative(),
43096
+ sha256: string()
43097
+ }), {
43098
+ kind: "mutation",
43099
+ auth: "admin",
43100
+ timeoutMs: 120 * 6e4
43101
+ }), method(object({
43102
+ ...JobRef,
43103
+ trainer: TrainerSourceRefSchema,
43104
+ jobSpecJson: string().min(2).max(64e3),
43105
+ gpuType: string(),
43106
+ region: string(),
43107
+ maxRuntimeSec: number().int().positive()
43108
+ }), ProviderJobStatusSchema, {
43109
+ kind: "mutation",
43110
+ auth: "admin",
43111
+ timeoutMs: 30 * 6e4
43112
+ }), method(object(JobRef), ProviderJobStatusSchema, {
43113
+ auth: "admin",
43114
+ timeoutMs: 6e4
43115
+ }), method(object({
43116
+ ...JobRef,
43117
+ cursor: string().optional(),
43118
+ max: number().int().min(1).max(500)
43119
+ }), object({
43120
+ lines: array(TrainingLogLineSchema).readonly(),
43121
+ cursor: string()
43122
+ }), {
43123
+ auth: "admin",
43124
+ timeoutMs: 6e4
43125
+ }), method(object(JobRef), object({ ok: literal(true) }), {
43126
+ kind: "mutation",
43127
+ auth: "admin",
43128
+ timeoutMs: 6e4
43129
+ }), method(object(JobRef), object({
43130
+ found: boolean(),
43131
+ text: string().optional()
43132
+ }), {
43133
+ kind: "mutation",
43134
+ auth: "admin",
43135
+ timeoutMs: 5 * 6e4
43136
+ }), method(object({
43137
+ ...JobRef,
43138
+ path: _enum(["bundle.tar"])
43139
+ }), object({ ticket: PeerBytesTicketSchema }), {
43140
+ kind: "mutation",
43141
+ auth: "admin",
43142
+ timeoutMs: 5 * 6e4
43143
+ }), method(object(JobRef), object({ deleted: array(string()).readonly() }), {
43144
+ kind: "mutation",
43145
+ auth: "admin",
43146
+ timeoutMs: 5 * 6e4
43147
+ }), method(object({ addonId: string() }), array(ProviderJobStatusSchema).readonly(), {
43148
+ auth: "admin",
43149
+ timeoutMs: 2 * 6e4
43150
+ });
43151
+ /**
43152
+ * `training` — the cloud-training orchestrator (D805). Hub-only singleton,
43153
+ * provided by `addon-training`.
43154
+ *
43155
+ * It owns what every provider must agree on, written once:
43156
+ *
43157
+ * - **Dataset versions.** Taken over from pipeline-analytics (D796): the rows
43158
+ * live here (D808); pipeline-analytics still CUTS a version (it owns the corpus and
43159
+ * the export plan) and reaches this store through the five row methods
43160
+ * below, so the Retrain page and the export did not change.
43161
+ * - **Jobs.** A persisted state machine, a reconcile loop against the
43162
+ * provider, a cost guard, a daily orphan sweep and the retention rules.
43163
+ * - **The return flow.** Verified artefacts → Model Studio
43164
+ * (`custom-model-registry.importModelBundle`) → canary on cameras →
43165
+ * rollback. Nothing is ever registered automatically.
43166
+ *
43167
+ * Every method is `admin`.
43168
+ */
43169
+ /** A version WITH its frame list — what the export and a job read. */
43170
+ var TrainingDatasetVersionRowSchema = RetrainDatasetVersionSchema.omit({ frameCount: true }).extend({ frameIds: array(string()).max(2e4).readonly() });
43171
+ /** A base model a detector job can fine-tune, and the baseline it is judged against. */
43172
+ var TrainingBaseModelSchema = object({
43173
+ modelId: string(),
43174
+ label: string(),
43175
+ weights: string(),
43176
+ imgsz: number().int(),
43177
+ baselineOnnxUrl: string(),
43178
+ baselineFloors: record(string(), number()),
43179
+ /** The base the fleet runs most — the UI's default. */
43180
+ recommended: boolean()
43181
+ });
43182
+ var TrainingPresetSchema = _enum([
43183
+ "quick",
43184
+ "standard",
43185
+ "thorough"
43186
+ ]);
43187
+ var TrainingJobRequestSchema = object({
43188
+ datasetVersionId: string().min(1),
43189
+ /** The `training-provider` addon that runs it. */
43190
+ addonId: string().min(1),
43191
+ gpuType: string().min(1),
43192
+ region: string(),
43193
+ baseModelId: string().min(1),
43194
+ preset: TrainingPresetSchema,
43195
+ /** Freeze the backbone's first N layers; `null` = the preset's choice. */
43196
+ freeze: number().int().nonnegative().nullable(),
43197
+ /** Cameras held out whole for evaluation; `null` = the orchestrator's default. */
43198
+ holdoutCameras: array(number().int()).nullable()
43199
+ });
43200
+ var TrainingSplitPlanSchema = object({
43201
+ holdoutCameras: array(number().int()).readonly(),
43202
+ /** Used when no camera is held out: the last N days of every camera. */
43203
+ holdoutLastDays: number().int().nonnegative(),
43204
+ /** Holdout subjects per class (camera holdout only; `null` = known only after the split). */
43205
+ holdoutSupport: record(string(), number().int()).nullable(),
43206
+ trainSubjects: number().int()
43207
+ });
43208
+ var TrainingRefusalReasonSchema = _enum([
43209
+ "unknown-dataset",
43210
+ "unknown-provider",
43211
+ "provider-not-configured",
43212
+ "unknown-base-model",
43213
+ "unknown-gpu",
43214
+ "dataset-too-large",
43215
+ "no-training-subjects",
43216
+ "job-already-running"
43217
+ ]);
43218
+ var TrainingJobPlanSchema = object({
43219
+ refusal: object({
43220
+ reason: TrainingRefusalReasonSchema,
43221
+ detail: string()
43222
+ }).nullable(),
43223
+ warnings: array(string()).readonly(),
43224
+ split: TrainingSplitPlanSchema.nullable(),
43225
+ estimate: object({
43226
+ datasetBytes: number().int(),
43227
+ uploadMinutesAt20Mbps: number(),
43228
+ gpuSecondsLow: number(),
43229
+ gpuSecondsHigh: number(),
43230
+ usdLow: number(),
43231
+ usdHigh: number(),
43232
+ notes: array(string()).readonly()
43233
+ }).nullable(),
43234
+ /** Pre-filled from the provider's settings; the operator may lower or raise them. */
43235
+ defaults: object({
43236
+ maxCostUsd: number(),
43237
+ maxRuntimeSec: number().int()
43238
+ }).nullable(),
43239
+ /** The sentence the confirm dialog repeats: where the frames go and when they are deleted. */
43240
+ dataNotice: string()
43241
+ });
43242
+ /**
43243
+ * Orchestrator-owned states, persisted. `uploading` covers exporting the
43244
+ * archive (it is streamed, never staged). Terminal: `failed`, `cancelled`,
43245
+ * `lost`, `expired`, `discarded`. `registered` and `canary` are where a
43246
+ * result lives after the operator acted on it.
43247
+ */
43248
+ var TrainingJobStateSchema = _enum([
43249
+ "uploading",
43250
+ "submitted",
43251
+ "starting",
43252
+ "running",
43253
+ "collecting",
43254
+ "ready",
43255
+ "registered",
43256
+ "canary",
43257
+ "failed",
43258
+ "cancelling",
43259
+ "cancelled",
43260
+ "lost",
43261
+ "expired",
43262
+ "discarded"
43263
+ ]);
43264
+ var TrainingFailureReasonSchema = _enum([
43265
+ "cost-cap",
43266
+ "runtime-cap",
43267
+ "upload-failed",
43268
+ "submit-failed",
43269
+ "trainer-failed",
43270
+ "result-invalid",
43271
+ "checksum-mismatch",
43272
+ "fetch-failed",
43273
+ "provider-error",
43274
+ "hub-restart-during-upload"
43275
+ ]);
43276
+ var TrainingProgressPointSchema = object({
43277
+ epoch: number().int(),
43278
+ map50: number().nullable(),
43279
+ map50_95: number().nullable()
43280
+ });
43281
+ var TrainingCanarySchema = object({
43282
+ deviceIds: array(number().int()).readonly(),
43283
+ since: number(),
43284
+ /** Every override the canary replaced, exactly, so rollback restores it. */
43285
+ previous: array(object({
43286
+ deviceId: number().int(),
43287
+ nodeId: string(),
43288
+ deviceKey: string(),
43289
+ patch: object({
43290
+ modelId: string().optional(),
43291
+ settings: record(string(), unknown()).readonly().optional()
43292
+ }).nullable()
43293
+ })).readonly()
43294
+ });
43295
+ var TrainingJobSchema = object({
43296
+ id: string(),
43297
+ idempotencyKey: string(),
43298
+ name: string(),
43299
+ createdAt: number(),
43300
+ updatedAt: number(),
43301
+ state: TrainingJobStateSchema,
43302
+ stage: TrainingStageSchema.nullable(),
43303
+ failure: object({
43304
+ reason: TrainingFailureReasonSchema,
43305
+ stage: string().nullable(),
43306
+ detail: string()
43307
+ }).nullable(),
43308
+ request: TrainingJobRequestSchema,
43309
+ maxCostUsd: number().nonnegative(),
43310
+ maxRuntimeSec: number().int().positive(),
43311
+ trainer: TrainerSourceRefSchema,
43312
+ datasetLayout: RetrainExportLayoutSchema,
43313
+ dataset: object({
43314
+ bytes: number().int(),
43315
+ sha256: string(),
43316
+ uploadedAt: number()
43317
+ }).nullable(),
43318
+ split: TrainingSplitPlanSchema,
43319
+ provider: object({
43320
+ state: ProviderJobStateSchema.nullable(),
43321
+ providerJobId: string().nullable(),
43322
+ startedAt: number().nullable(),
43323
+ endedAt: number().nullable(),
43324
+ billedSeconds: number(),
43325
+ costUsd: number(),
43326
+ costIsEstimate: boolean(),
43327
+ lastPolledAt: number().nullable()
43328
+ }),
43329
+ progress: object({
43330
+ epoch: number().int().nullable(),
43331
+ epochs: number().int().nullable(),
43332
+ etaSec: number().nullable(),
43333
+ series: array(TrainingProgressPointSchema).readonly()
43334
+ }),
43335
+ /** The last lines of the job's output (≤ 200), newest last. Never frame paths. */
43336
+ logTail: array(string()).readonly(),
43337
+ logCursor: string().nullable(),
43338
+ artifacts: object({
43339
+ bundleBytes: number().int(),
43340
+ bundleSha256: string(),
43341
+ fetchedAt: number(),
43342
+ /** When the staged artefacts are deleted from the hub. */
43343
+ expiresAt: number()
43344
+ }).nullable(),
43345
+ /** When the provider-side copy of the frames was deleted; null while it exists. */
43346
+ cloudDatasetDeletedAt: number().nullable(),
43347
+ /** A failed job's dataset is kept until then (the provider's grace), then deleted. */
43348
+ cloudCleanupDueAt: number().nullable(),
43349
+ /** Model ids registered from this job (base, and int8 when kept). */
43350
+ registeredModelIds: array(string()).readonly(),
43351
+ canary: TrainingCanarySchema.nullable()
43352
+ });
43353
+ var IdInput = object({ id: string().min(1) });
43354
+ method(TrainingDatasetVersionRowSchema, object({ stored: boolean() }), {
43355
+ kind: "mutation",
43356
+ auth: "admin"
43357
+ }), 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() }), {
43358
+ kind: "mutation",
43359
+ auth: "admin"
43360
+ }), method(object({}), array(TrainingBaseModelSchema).readonly(), { auth: "admin" }), method(TrainingJobRequestSchema, TrainingJobPlanSchema, {
43361
+ auth: "admin",
43362
+ timeoutMs: 6e4
43363
+ }), method(TrainingJobRequestSchema.extend({
43364
+ name: string().min(1).max(120),
43365
+ maxCostUsd: number().positive(),
43366
+ maxRuntimeSec: number().int().positive(),
43367
+ idempotencyKey: string().min(8).max(80)
43368
+ }), discriminatedUnion("kind", [object({
43369
+ kind: literal("started"),
43370
+ job: TrainingJobSchema
43371
+ }), object({
43372
+ kind: literal("refused"),
43373
+ reason: TrainingRefusalReasonSchema,
43374
+ detail: string()
43375
+ })]), {
43376
+ kind: "mutation",
43377
+ auth: "admin",
43378
+ timeoutMs: 12e4
43379
+ }), method(object({}), array(TrainingJobSchema).readonly(), { auth: "admin" }), method(IdInput, TrainingJobSchema.nullable(), { auth: "admin" }), method(IdInput, TrainingJobSchema, {
43380
+ kind: "mutation",
43381
+ auth: "admin",
43382
+ timeoutMs: 12e4
43383
+ }), method(IdInput, TrainingResultSchema.nullable(), { auth: "admin" }), method(IdInput.extend({ canaryDeviceIds: array(number().int()).readonly() }), TrainingJobSchema, {
43384
+ kind: "mutation",
43385
+ auth: "admin",
43386
+ timeoutMs: 30 * 6e4
43387
+ }), method(IdInput.extend({ deviceIds: array(number().int()).min(1).readonly() }), TrainingJobSchema, {
43388
+ kind: "mutation",
43389
+ auth: "admin",
43390
+ timeoutMs: 12e4
43391
+ }), method(IdInput, TrainingJobSchema, {
43392
+ kind: "mutation",
43393
+ auth: "admin",
43394
+ timeoutMs: 12e4
43395
+ }), method(IdInput, TrainingJobSchema, {
43396
+ kind: "mutation",
43397
+ auth: "admin"
43398
+ });
40424
43399
  SOURCE_CAPS.filter((cap) => cap !== "switch" && cap !== "motion");
40425
43400
  Object.freeze({
40426
43401
  person: .5,
@@ -40907,7 +43882,8 @@ var BaseDevice = class {
40907
43882
  this.role = options.role;
40908
43883
  this.parentDeviceId = ctx.parentDeviceId;
40909
43884
  const seedData = ctx.persistedConfig ?? {};
40910
- this.config = DeviceConfig.fromSchema(schema, (data) => ctx.persistConfig(data), seedData, ({ droppedKeys, issues }) => {
43885
+ const declaredSecretPaths = collectZodSecretPaths(schema);
43886
+ this.config = DeviceConfig.fromSchema(schema, (data) => ctx.persistConfig(data, { secretConfigPaths: declaredSecretPaths }), seedData, ({ droppedKeys, issues }) => {
40911
43887
  ctx.logger.warn("Device config recovery: dropping invalid persisted fields", {
40912
43888
  tags: {
40913
43889
  deviceId: ctx.id,
@@ -42568,6 +45544,12 @@ Object.freeze({
42568
45544
  addonId: null,
42569
45545
  access: "create"
42570
45546
  },
45547
+ "backup.checkBackupKey": {
45548
+ capName: "backup",
45549
+ capScope: "system",
45550
+ addonId: null,
45551
+ access: "create"
45552
+ },
42571
45553
  "backup.delete": {
42572
45554
  capName: "backup",
42573
45555
  capScope: "system",
@@ -42580,6 +45562,18 @@ Object.freeze({
42580
45562
  addonId: null,
42581
45563
  access: "delete"
42582
45564
  },
45565
+ "backup.disableEncryption": {
45566
+ capName: "backup",
45567
+ capScope: "system",
45568
+ addonId: null,
45569
+ access: "create"
45570
+ },
45571
+ "backup.getEncryption": {
45572
+ capName: "backup",
45573
+ capScope: "system",
45574
+ addonId: null,
45575
+ access: "view"
45576
+ },
42583
45577
  "backup.getEntries": {
42584
45578
  capName: "backup",
42585
45579
  capScope: "system",
@@ -42634,6 +45628,12 @@ Object.freeze({
42634
45628
  addonId: null,
42635
45629
  access: "create"
42636
45630
  },
45631
+ "backup.setupEncryption": {
45632
+ capName: "backup",
45633
+ capScope: "system",
45634
+ addonId: null,
45635
+ access: "create"
45636
+ },
42637
45637
  "backup.trigger": {
42638
45638
  capName: "backup",
42639
45639
  capScope: "system",
@@ -43186,6 +46186,12 @@ Object.freeze({
43186
46186
  addonId: null,
43187
46187
  access: "create"
43188
46188
  },
46189
+ "customModelRegistry.importModelBundle": {
46190
+ capName: "custom-model-registry",
46191
+ capScope: "system",
46192
+ addonId: null,
46193
+ access: "create"
46194
+ },
43189
46195
  "customModelRegistry.listModels": {
43190
46196
  capName: "custom-model-registry",
43191
46197
  capScope: "system",
@@ -44596,6 +47602,108 @@ Object.freeze({
44596
47602
  addonId: null,
44597
47603
  access: "create"
44598
47604
  },
47605
+ "keychain.delete": {
47606
+ capName: "keychain",
47607
+ capScope: "system",
47608
+ addonId: null,
47609
+ access: "delete"
47610
+ },
47611
+ "keychain.getState": {
47612
+ capName: "keychain",
47613
+ capScope: "system",
47614
+ addonId: null,
47615
+ access: "view"
47616
+ },
47617
+ "keychain.listMeta": {
47618
+ capName: "keychain",
47619
+ capScope: "system",
47620
+ addonId: null,
47621
+ access: "view"
47622
+ },
47623
+ "keychain.put": {
47624
+ capName: "keychain",
47625
+ capScope: "system",
47626
+ addonId: null,
47627
+ access: "create"
47628
+ },
47629
+ "keychain.resolve": {
47630
+ capName: "keychain",
47631
+ capScope: "system",
47632
+ addonId: null,
47633
+ access: "view"
47634
+ },
47635
+ "keychainAdmin.acknowledgeReset": {
47636
+ capName: "keychain-admin",
47637
+ capScope: "system",
47638
+ addonId: null,
47639
+ access: "create"
47640
+ },
47641
+ "keychainAdmin.deleteOrphans": {
47642
+ capName: "keychain-admin",
47643
+ capScope: "system",
47644
+ addonId: null,
47645
+ access: "delete"
47646
+ },
47647
+ "keychainAdmin.downloadRecoveryKey": {
47648
+ capName: "keychain-admin",
47649
+ capScope: "system",
47650
+ addonId: null,
47651
+ access: "create"
47652
+ },
47653
+ "keychainAdmin.listAudit": {
47654
+ capName: "keychain-admin",
47655
+ capScope: "system",
47656
+ addonId: null,
47657
+ access: "view"
47658
+ },
47659
+ "keychainAdmin.listSecrets": {
47660
+ capName: "keychain-admin",
47661
+ capScope: "system",
47662
+ addonId: null,
47663
+ access: "view"
47664
+ },
47665
+ "keychainAdmin.purgeRetiredKeys": {
47666
+ capName: "keychain-admin",
47667
+ capScope: "system",
47668
+ addonId: null,
47669
+ access: "delete"
47670
+ },
47671
+ "keychainAdmin.resetKeychain": {
47672
+ capName: "keychain-admin",
47673
+ capScope: "system",
47674
+ addonId: null,
47675
+ access: "delete"
47676
+ },
47677
+ "keychainAdmin.resetReport": {
47678
+ capName: "keychain-admin",
47679
+ capScope: "system",
47680
+ addonId: null,
47681
+ access: "delete"
47682
+ },
47683
+ "keychainAdmin.reveal": {
47684
+ capName: "keychain-admin",
47685
+ capScope: "system",
47686
+ addonId: null,
47687
+ access: "create"
47688
+ },
47689
+ "keychainAdmin.rotateMasterKey": {
47690
+ capName: "keychain-admin",
47691
+ capScope: "system",
47692
+ addonId: null,
47693
+ access: "create"
47694
+ },
47695
+ "keychainAdmin.setSystemSecret": {
47696
+ capName: "keychain-admin",
47697
+ capScope: "system",
47698
+ addonId: null,
47699
+ access: "create"
47700
+ },
47701
+ "keychainAdmin.status": {
47702
+ capName: "keychain-admin",
47703
+ capScope: "system",
47704
+ addonId: null,
47705
+ access: "view"
47706
+ },
44599
47707
  "lawnMowerControl.dock": {
44600
47708
  capName: "lawn-mower-control",
44601
47709
  capScope: "device",
@@ -45970,6 +49078,18 @@ Object.freeze({
45970
49078
  addonId: null,
45971
49079
  access: "create"
45972
49080
  },
49081
+ "pipelineAnalytics.addRetrainFrameFromRecording": {
49082
+ capName: "pipeline-analytics",
49083
+ capScope: "device",
49084
+ addonId: null,
49085
+ access: "create"
49086
+ },
49087
+ "pipelineAnalytics.addRetrainFramesToCollection": {
49088
+ capName: "pipeline-analytics",
49089
+ capScope: "device",
49090
+ addonId: null,
49091
+ access: "create"
49092
+ },
45973
49093
  "pipelineAnalytics.applyDeviceSettingsPatch": {
45974
49094
  capName: "pipeline-analytics",
45975
49095
  capScope: "device",
@@ -46018,12 +49138,36 @@ Object.freeze({
46018
49138
  addonId: null,
46019
49139
  access: "view"
46020
49140
  },
49141
+ "pipelineAnalytics.createRetrainCollection": {
49142
+ capName: "pipeline-analytics",
49143
+ capScope: "device",
49144
+ addonId: null,
49145
+ access: "create"
49146
+ },
49147
+ "pipelineAnalytics.createRetrainDatasetVersion": {
49148
+ capName: "pipeline-analytics",
49149
+ capScope: "device",
49150
+ addonId: null,
49151
+ access: "create"
49152
+ },
46021
49153
  "pipelineAnalytics.deleteDeviceEvents": {
46022
49154
  capName: "pipeline-analytics",
46023
49155
  capScope: "device",
46024
49156
  addonId: null,
46025
49157
  access: "delete"
46026
49158
  },
49159
+ "pipelineAnalytics.deleteRetrainCollection": {
49160
+ capName: "pipeline-analytics",
49161
+ capScope: "device",
49162
+ addonId: null,
49163
+ access: "delete"
49164
+ },
49165
+ "pipelineAnalytics.deleteRetrainDatasetVersion": {
49166
+ capName: "pipeline-analytics",
49167
+ capScope: "device",
49168
+ addonId: null,
49169
+ access: "delete"
49170
+ },
46027
49171
  "pipelineAnalytics.deleteTracks": {
46028
49172
  capName: "pipeline-analytics",
46029
49173
  capScope: "device",
@@ -46228,6 +49372,30 @@ Object.freeze({
46228
49372
  addonId: null,
46229
49373
  access: "view"
46230
49374
  },
49375
+ "pipelineAnalytics.listRetrainAssistProfiles": {
49376
+ capName: "pipeline-analytics",
49377
+ capScope: "device",
49378
+ addonId: null,
49379
+ access: "view"
49380
+ },
49381
+ "pipelineAnalytics.listRetrainCollectionFrames": {
49382
+ capName: "pipeline-analytics",
49383
+ capScope: "device",
49384
+ addonId: null,
49385
+ access: "view"
49386
+ },
49387
+ "pipelineAnalytics.listRetrainCollections": {
49388
+ capName: "pipeline-analytics",
49389
+ capScope: "device",
49390
+ addonId: null,
49391
+ access: "view"
49392
+ },
49393
+ "pipelineAnalytics.listRetrainDatasetVersions": {
49394
+ capName: "pipeline-analytics",
49395
+ capScope: "device",
49396
+ addonId: null,
49397
+ access: "view"
49398
+ },
46231
49399
  "pipelineAnalytics.listRetrainFrames": {
46232
49400
  capName: "pipeline-analytics",
46233
49401
  capScope: "device",
@@ -46258,6 +49426,12 @@ Object.freeze({
46258
49426
  addonId: null,
46259
49427
  access: "view"
46260
49428
  },
49429
+ "pipelineAnalytics.offerRetrainArchive": {
49430
+ capName: "pipeline-analytics",
49431
+ capScope: "device",
49432
+ addonId: null,
49433
+ access: "create"
49434
+ },
46261
49435
  "pipelineAnalytics.ownersWithMedia": {
46262
49436
  capName: "pipeline-analytics",
46263
49437
  capScope: "device",
@@ -46270,12 +49444,24 @@ Object.freeze({
46270
49444
  addonId: null,
46271
49445
  access: "create"
46272
49446
  },
49447
+ "pipelineAnalytics.previewRetrainDataset": {
49448
+ capName: "pipeline-analytics",
49449
+ capScope: "device",
49450
+ addonId: null,
49451
+ access: "view"
49452
+ },
46273
49453
  "pipelineAnalytics.proposeRetrainAnnotations": {
46274
49454
  capName: "pipeline-analytics",
46275
49455
  capScope: "device",
46276
49456
  addonId: null,
46277
49457
  access: "create"
46278
49458
  },
49459
+ "pipelineAnalytics.proposeRetrainAnnotationsWithLlm": {
49460
+ capName: "pipeline-analytics",
49461
+ capScope: "device",
49462
+ addonId: null,
49463
+ access: "create"
49464
+ },
46279
49465
  "pipelineAnalytics.pruneEvents": {
46280
49466
  capName: "pipeline-analytics",
46281
49467
  capScope: "device",
@@ -46330,6 +49516,18 @@ Object.freeze({
46330
49516
  addonId: null,
46331
49517
  access: "create"
46332
49518
  },
49519
+ "pipelineAnalytics.removeRetrainFrameFromCollection": {
49520
+ capName: "pipeline-analytics",
49521
+ capScope: "device",
49522
+ addonId: null,
49523
+ access: "delete"
49524
+ },
49525
+ "pipelineAnalytics.renameRetrainCollection": {
49526
+ capName: "pipeline-analytics",
49527
+ capScope: "device",
49528
+ addonId: null,
49529
+ access: "create"
49530
+ },
46333
49531
  "pipelineAnalytics.restageRetrainTrack": {
46334
49532
  capName: "pipeline-analytics",
46335
49533
  capScope: "device",
@@ -46390,6 +49588,12 @@ Object.freeze({
46390
49588
  addonId: null,
46391
49589
  access: "create"
46392
49590
  },
49591
+ "pipelineAnalytics.verifyRetrainDatasetVersion": {
49592
+ capName: "pipeline-analytics",
49593
+ capScope: "device",
49594
+ addonId: null,
49595
+ access: "view"
49596
+ },
46393
49597
  "pipelineAnalytics.wipeAllAnalytics": {
46394
49598
  capName: "pipeline-analytics",
46395
49599
  capScope: "device",
@@ -46618,6 +49822,12 @@ Object.freeze({
46618
49822
  addonId: null,
46619
49823
  access: "view"
46620
49824
  },
49825
+ "pipelineOrchestrator.abortNodeBenchmark": {
49826
+ capName: "pipeline-orchestrator",
49827
+ capScope: "system",
49828
+ addonId: null,
49829
+ access: "create"
49830
+ },
46621
49831
  "pipelineOrchestrator.applyAutoTune": {
46622
49832
  capName: "pipeline-orchestrator",
46623
49833
  capScope: "system",
@@ -46642,6 +49852,12 @@ Object.freeze({
46642
49852
  addonId: null,
46643
49853
  access: "create"
46644
49854
  },
49855
+ "pipelineOrchestrator.deleteNodeBenchmarkResult": {
49856
+ capName: "pipeline-orchestrator",
49857
+ capScope: "system",
49858
+ addonId: null,
49859
+ access: "delete"
49860
+ },
46645
49861
  "pipelineOrchestrator.getAgentLoad": {
46646
49862
  capName: "pipeline-orchestrator",
46647
49863
  capScope: "system",
@@ -46750,6 +49966,24 @@ Object.freeze({
46750
49966
  addonId: null,
46751
49967
  access: "view"
46752
49968
  },
49969
+ "pipelineOrchestrator.getNodeBenchmarkCandidates": {
49970
+ capName: "pipeline-orchestrator",
49971
+ capScope: "system",
49972
+ addonId: null,
49973
+ access: "view"
49974
+ },
49975
+ "pipelineOrchestrator.getNodeBenchmarkPreflight": {
49976
+ capName: "pipeline-orchestrator",
49977
+ capScope: "system",
49978
+ addonId: null,
49979
+ access: "view"
49980
+ },
49981
+ "pipelineOrchestrator.getNodeBenchmarkStatus": {
49982
+ capName: "pipeline-orchestrator",
49983
+ capScope: "system",
49984
+ addonId: null,
49985
+ access: "view"
49986
+ },
46753
49987
  "pipelineOrchestrator.getNodeInferenceDevices": {
46754
49988
  capName: "pipeline-orchestrator",
46755
49989
  capScope: "system",
@@ -46792,6 +50026,12 @@ Object.freeze({
46792
50026
  addonId: null,
46793
50027
  access: "view"
46794
50028
  },
50029
+ "pipelineOrchestrator.listNodeBenchmarkResults": {
50030
+ capName: "pipeline-orchestrator",
50031
+ capScope: "system",
50032
+ addonId: null,
50033
+ access: "view"
50034
+ },
46795
50035
  "pipelineOrchestrator.pauseForStorageMigration": {
46796
50036
  capName: "pipeline-orchestrator",
46797
50037
  capScope: "system",
@@ -46936,6 +50176,12 @@ Object.freeze({
46936
50176
  addonId: null,
46937
50177
  access: "create"
46938
50178
  },
50179
+ "pipelineOrchestrator.startNodeBenchmark": {
50180
+ capName: "pipeline-orchestrator",
50181
+ capScope: "system",
50182
+ addonId: null,
50183
+ access: "create"
50184
+ },
46939
50185
  "pipelineOrchestrator.suggestShares": {
46940
50186
  capName: "pipeline-orchestrator",
46941
50187
  capScope: "system",
@@ -46954,6 +50200,12 @@ Object.freeze({
46954
50200
  addonId: null,
46955
50201
  access: "create"
46956
50202
  },
50203
+ "pipelineRunner.abortNodeBench": {
50204
+ capName: "pipeline-runner",
50205
+ capScope: "system",
50206
+ addonId: null,
50207
+ access: "create"
50208
+ },
46957
50209
  "pipelineRunner.attachCamera": {
46958
50210
  capName: "pipeline-runner",
46959
50211
  capScope: "system",
@@ -47002,6 +50254,12 @@ Object.freeze({
47002
50254
  addonId: null,
47003
50255
  access: "view"
47004
50256
  },
50257
+ "pipelineRunner.getNodeBenchStatus": {
50258
+ capName: "pipeline-runner",
50259
+ capScope: "system",
50260
+ addonId: null,
50261
+ access: "view"
50262
+ },
47005
50263
  "pipelineRunner.getParkedTrackFrame": {
47006
50264
  capName: "pipeline-runner",
47007
50265
  capScope: "system",
@@ -47044,6 +50302,12 @@ Object.freeze({
47044
50302
  addonId: null,
47045
50303
  access: "create"
47046
50304
  },
50305
+ "pipelineRunner.startNodeBench": {
50306
+ capName: "pipeline-runner",
50307
+ capScope: "system",
50308
+ addonId: null,
50309
+ access: "create"
50310
+ },
47047
50311
  "plateGallery.assignPlate": {
47048
50312
  capName: "plate-gallery",
47049
50313
  capScope: "system",
@@ -48706,6 +51970,174 @@ Object.freeze({
48706
51970
  addonId: null,
48707
51971
  access: "view"
48708
51972
  },
51973
+ "training.canaryResult": {
51974
+ capName: "training",
51975
+ capScope: "system",
51976
+ addonId: null,
51977
+ access: "create"
51978
+ },
51979
+ "training.cancelJob": {
51980
+ capName: "training",
51981
+ capScope: "system",
51982
+ addonId: null,
51983
+ access: "create"
51984
+ },
51985
+ "training.discardResult": {
51986
+ capName: "training",
51987
+ capScope: "system",
51988
+ addonId: null,
51989
+ access: "create"
51990
+ },
51991
+ "training.findDatasetVersionIdByName": {
51992
+ capName: "training",
51993
+ capScope: "system",
51994
+ addonId: null,
51995
+ access: "view"
51996
+ },
51997
+ "training.getDatasetVersion": {
51998
+ capName: "training",
51999
+ capScope: "system",
52000
+ addonId: null,
52001
+ access: "view"
52002
+ },
52003
+ "training.getJob": {
52004
+ capName: "training",
52005
+ capScope: "system",
52006
+ addonId: null,
52007
+ access: "view"
52008
+ },
52009
+ "training.getJobResult": {
52010
+ capName: "training",
52011
+ capScope: "system",
52012
+ addonId: null,
52013
+ access: "view"
52014
+ },
52015
+ "training.listBaseModels": {
52016
+ capName: "training",
52017
+ capScope: "system",
52018
+ addonId: null,
52019
+ access: "view"
52020
+ },
52021
+ "training.listDatasetVersions": {
52022
+ capName: "training",
52023
+ capScope: "system",
52024
+ addonId: null,
52025
+ access: "view"
52026
+ },
52027
+ "training.listJobs": {
52028
+ capName: "training",
52029
+ capScope: "system",
52030
+ addonId: null,
52031
+ access: "view"
52032
+ },
52033
+ "training.planJob": {
52034
+ capName: "training",
52035
+ capScope: "system",
52036
+ addonId: null,
52037
+ access: "view"
52038
+ },
52039
+ "training.putDatasetVersion": {
52040
+ capName: "training",
52041
+ capScope: "system",
52042
+ addonId: null,
52043
+ access: "create"
52044
+ },
52045
+ "training.registerResult": {
52046
+ capName: "training",
52047
+ capScope: "system",
52048
+ addonId: null,
52049
+ access: "create"
52050
+ },
52051
+ "training.removeDatasetVersion": {
52052
+ capName: "training",
52053
+ capScope: "system",
52054
+ addonId: null,
52055
+ access: "delete"
52056
+ },
52057
+ "training.rollbackCanary": {
52058
+ capName: "training",
52059
+ capScope: "system",
52060
+ addonId: null,
52061
+ access: "create"
52062
+ },
52063
+ "training.startJob": {
52064
+ capName: "training",
52065
+ capScope: "system",
52066
+ addonId: null,
52067
+ access: "create"
52068
+ },
52069
+ "trainingProvider.cancelJob": {
52070
+ capName: "training-provider",
52071
+ capScope: "system",
52072
+ addonId: null,
52073
+ access: "create"
52074
+ },
52075
+ "trainingProvider.cleanupJob": {
52076
+ capName: "training-provider",
52077
+ capScope: "system",
52078
+ addonId: null,
52079
+ access: "create"
52080
+ },
52081
+ "trainingProvider.describe": {
52082
+ capName: "training-provider",
52083
+ capScope: "system",
52084
+ addonId: null,
52085
+ access: "view"
52086
+ },
52087
+ "trainingProvider.estimateJob": {
52088
+ capName: "training-provider",
52089
+ capScope: "system",
52090
+ addonId: null,
52091
+ access: "view"
52092
+ },
52093
+ "trainingProvider.getJob": {
52094
+ capName: "training-provider",
52095
+ capScope: "system",
52096
+ addonId: null,
52097
+ access: "view"
52098
+ },
52099
+ "trainingProvider.listJobEvents": {
52100
+ capName: "training-provider",
52101
+ capScope: "system",
52102
+ addonId: null,
52103
+ access: "view"
52104
+ },
52105
+ "trainingProvider.listJobs": {
52106
+ capName: "training-provider",
52107
+ capScope: "system",
52108
+ addonId: null,
52109
+ access: "view"
52110
+ },
52111
+ "trainingProvider.offerArtifact": {
52112
+ capName: "training-provider",
52113
+ capScope: "system",
52114
+ addonId: null,
52115
+ access: "create"
52116
+ },
52117
+ "trainingProvider.readResult": {
52118
+ capName: "training-provider",
52119
+ capScope: "system",
52120
+ addonId: null,
52121
+ access: "create"
52122
+ },
52123
+ "trainingProvider.submitJob": {
52124
+ capName: "training-provider",
52125
+ capScope: "system",
52126
+ addonId: null,
52127
+ access: "create"
52128
+ },
52129
+ "trainingProvider.uploadDataset": {
52130
+ capName: "training-provider",
52131
+ capScope: "system",
52132
+ addonId: null,
52133
+ access: "create"
52134
+ },
52135
+ "trainingProvider.validateCredentials": {
52136
+ capName: "training-provider",
52137
+ capScope: "system",
52138
+ addonId: null,
52139
+ access: "create"
52140
+ },
48709
52141
  "turnProvider.getTurnServers": {
48710
52142
  capName: "turn-provider",
48711
52143
  capScope: "system",
@@ -48730,12 +52162,6 @@ Object.freeze({
48730
52162
  addonId: null,
48731
52163
  access: "create"
48732
52164
  },
48733
- "userManagement.createApiKey": {
48734
- capName: "user-management",
48735
- capScope: "system",
48736
- addonId: null,
48737
- access: "create"
48738
- },
48739
52165
  "userManagement.createScopedToken": {
48740
52166
  capName: "user-management",
48741
52167
  capScope: "system",
@@ -48772,12 +52198,6 @@ Object.freeze({
48772
52198
  addonId: null,
48773
52199
  access: "view"
48774
52200
  },
48775
- "userManagement.linkExternalIdentity": {
48776
- capName: "user-management",
48777
- capScope: "system",
48778
- addonId: null,
48779
- access: "create"
48780
- },
48781
52201
  "userManagement.listApiKeys": {
48782
52202
  capName: "user-management",
48783
52203
  capScope: "system",
@@ -48880,12 +52300,6 @@ Object.freeze({
48880
52300
  addonId: null,
48881
52301
  access: "create"
48882
52302
  },
48883
- "userManagement.validateApiKey": {
48884
- capName: "user-management",
48885
- capScope: "system",
48886
- addonId: null,
48887
- access: "view"
48888
- },
48889
52303
  "userManagement.validateCredentials": {
48890
52304
  capName: "user-management",
48891
52305
  capScope: "system",
@@ -51973,6 +55387,11 @@ Object.freeze({
51973
55387
  form: "single",
51974
55388
  optional: false
51975
55389
  }],
55390
+ "pipelineAnalytics.addRetrainFrameFromRecording": [{
55391
+ name: "deviceId",
55392
+ form: "single",
55393
+ optional: false
55394
+ }],
51976
55395
  "pipelineAnalytics.applyDeviceSettingsPatch": [{
51977
55396
  name: "deviceId",
51978
55397
  form: "single",
@@ -52163,6 +55582,11 @@ Object.freeze({
52163
55582
  form: "single",
52164
55583
  optional: false
52165
55584
  }],
55585
+ "pipelineAnalytics.proposeRetrainAnnotationsWithLlm": [{
55586
+ name: "deviceId",
55587
+ form: "single",
55588
+ optional: false
55589
+ }],
52166
55590
  "pipelineAnalytics.pruneEventsBefore": [{
52167
55591
  name: "deviceId",
52168
55592
  form: "single",
@@ -52989,6 +56413,11 @@ Object.freeze({
52989
56413
  form: "single",
52990
56414
  optional: false
52991
56415
  }],
56416
+ "training.canaryResult": [{
56417
+ name: "deviceIds",
56418
+ form: "array",
56419
+ optional: false
56420
+ }],
52992
56421
  "update.getStatus": [{
52993
56422
  name: "deviceId",
52994
56423
  form: "single",