@camstack/addon-provider-velux 0.2.123 → 0.2.125

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