@camstack/addon-provider-hikvision 1.2.146 → 1.2.148

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.js CHANGED
@@ -33,7 +33,7 @@ let node_net = require("node:net");
33
33
  let node_http = require("node:http");
34
34
  let node_https = require("node:https");
35
35
  let node_os = require("node:os");
36
- //#region ../types/dist/event-category-B_0XEcLF.mjs
36
+ //#region ../types/dist/event-category-DaIZi00R.mjs
37
37
  var EventCategory = /* @__PURE__ */ function(EventCategory) {
38
38
  EventCategory["SystemBoot"] = "system.boot";
39
39
  EventCategory["SystemAddonsReady"] = "system.addons-ready";
@@ -112,6 +112,13 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
112
112
  */
113
113
  EventCategory["AddonLoadFailed"] = "addon.load-failed";
114
114
  /**
115
+ * A keychain value was stored or removed (D787). Carries the ref, its
116
+ * owner and the new version — NEVER the value. A process holding the ref
117
+ * drops its cached copy and the owning `BaseAddon` re-resolves its config.
118
+ * Telemetry (D8): a process that misses it still revalidates by version.
119
+ */
120
+ EventCategory["KeychainChanged"] = "keychain.changed";
121
+ /**
115
122
  * Addon recovered from a previous failure. Emitted when an addon
116
123
  * transitions from `failed` back to `healthy` (typically via the
117
124
  * monitor's auto-retry loop, or after manual `addons.retryLoad`).
@@ -5404,7 +5411,7 @@ var ZodIssueCode = {
5404
5411
  var ZodFirstPartyTypeKind;
5405
5412
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
5406
5413
  //#endregion
5407
- //#region ../types/dist/sleep-B0JG7-_F.mjs
5414
+ //#region ../types/dist/sleep-r3RWkGVx.mjs
5408
5415
  /**
5409
5416
  * The audio chunk plane's byte format, and the ONE expansion from a coded
5410
5417
  * window to float samples (D455).
@@ -5483,6 +5490,97 @@ function buildAlawTable() {
5483
5490
  }
5484
5491
  buildUlawTable();
5485
5492
  buildAlawTable();
5493
+ /** Is this field's stored value a credential? */
5494
+ function isSecretConfigField(field) {
5495
+ if (field.type === "password") return true;
5496
+ return "secret" in field && field.secret === true;
5497
+ }
5498
+ /**
5499
+ * Is this field's value stored in the KEYCHAIN (D787)? Every secret field is,
5500
+ * by its TYPE, unless it opts out with `storage: 'inline'` — never by its name.
5501
+ */
5502
+ function isKeychainStoredField(field) {
5503
+ if (!isSecretConfigField(field)) return false;
5504
+ if (field.type === "textarea" && field.isJson === true) return false;
5505
+ return !("storage" in field && field.storage === "inline");
5506
+ }
5507
+ /**
5508
+ * What a settings blob holds where a secret used to be.
5509
+ *
5510
+ * A keychain-stored field never holds its value. It holds a self-describing
5511
+ * MARKER, `{"$secret":"secret://…","v":1}` — an object, never a string, so no
5512
+ * code can mistake it for a credential and no form can send it to a camera as
5513
+ * a password. The empty state is `null` / absent, never `''`.
5514
+ *
5515
+ * The same shapes travel to and from the admin UI:
5516
+ *
5517
+ * - read: `hydrateSchema` hands a secret field a {@link SecretFieldView}
5518
+ * (`{ $secret, v, set: true }`) or `null` — the browser learns whether a
5519
+ * value is set, never the value.
5520
+ * - write: an untouched field submits the view back unchanged (KEEP); a typed
5521
+ * value is a plain non-empty string (CHANGE); the Clear button submits
5522
+ * {@link SECRET_CLEAR} (CLEAR). `''`, `null` and the legacy redaction tokens
5523
+ * are KEEP — an empty string is what a defaults-fallback pushes back, and
5524
+ * treating it as "clear" is how a save destroyed a stored credential before.
5525
+ *
5526
+ * Pure and browser-safe.
5527
+ */
5528
+ var SECRET_CLEAR = { $secretClear: true };
5529
+ /** The `'***'` token D634 redaction writes for non-admins. */
5530
+ var LEGACY_DEVICE_REDACTION = "***";
5531
+ function isRecord$2(value) {
5532
+ return typeof value === "object" && value !== null && !Array.isArray(value);
5533
+ }
5534
+ function makeSecretMarker(ref) {
5535
+ return {
5536
+ $secret: ref,
5537
+ v: 1
5538
+ };
5539
+ }
5540
+ /** A stored marker: an object whose `$secret` is a non-empty string. */
5541
+ function isSecretMarker(value) {
5542
+ if (!isRecord$2(value)) return false;
5543
+ const ref = value["$secret"];
5544
+ return typeof ref === "string" && ref.length > 0;
5545
+ }
5546
+ function isSecretClear(value) {
5547
+ return isRecord$2(value) && value["$secretClear"] === true;
5548
+ }
5549
+ /**
5550
+ * The UI view of a stored secret field value: a marker becomes "set", inline
5551
+ * plaintext becomes "set (inline)", nothing becomes `null`. A value never
5552
+ * survives this function.
5553
+ */
5554
+ function toSecretFieldView(stored) {
5555
+ if (isSecretMarker(stored)) return {
5556
+ $secret: stored.$secret,
5557
+ v: 1,
5558
+ set: true
5559
+ };
5560
+ if (typeof stored === "string" && stored.length > 0) return {
5561
+ $secret: null,
5562
+ v: 1,
5563
+ set: true,
5564
+ inline: true
5565
+ };
5566
+ return null;
5567
+ }
5568
+ /**
5569
+ * Classify an incoming value for a secret path. Only a non-empty string that is
5570
+ * not a redaction token sets a value; only {@link SECRET_CLEAR} clears.
5571
+ * Everything else — a marker (ours or anyone's), a UI view, `''`, `null`,
5572
+ * `undefined`, a redaction token, a non-string — keeps what is stored.
5573
+ */
5574
+ function classifySecretWrite(incoming) {
5575
+ if (isSecretClear(incoming)) return { kind: "clear" };
5576
+ if (typeof incoming !== "string") return { kind: "keep" };
5577
+ if (incoming.length === 0) return { kind: "keep" };
5578
+ if (incoming === "__camstack_redacted__" || incoming === LEGACY_DEVICE_REDACTION) return { kind: "keep" };
5579
+ return {
5580
+ kind: "set",
5581
+ value: incoming
5582
+ };
5583
+ }
5486
5584
  Object.fromEntries([
5487
5585
  {
5488
5586
  id: "overview",
@@ -5654,33 +5752,19 @@ Object.fromEntries([
5654
5752
  function isValuelessField(field) {
5655
5753
  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";
5656
5754
  }
5657
- /**
5658
- * Merge a `ConfigUISchema` with a raw `values` record into a
5659
- * `ConfigUISchemaWithValues`. Used by every `get*Settings` backend endpoint
5660
- * before returning to the admin UI. Groups are walked recursively.
5661
- *
5662
- * For each leaf field:
5663
- * - structural fields (`separator`, `info`, `button`) pass through unchanged
5664
- * - other fields get `value = values[key] ?? field.default ?? null`
5665
- *
5666
- * Unknown keys in `values` (keys not declared in the schema) are silently
5667
- * ignored — they don't contribute to the output. Missing keys fall back to
5668
- * the schema default or `null`. This mirrors the old backend behaviour where
5669
- * `FormBuilder` rendered `values[key] ?? field.default`.
5670
- */
5671
- function hydrateSchema(schema, values) {
5755
+ function hydrateSchema(schema, values, options = {}) {
5672
5756
  return {
5673
5757
  ...schema.tabs ? { tabs: [...schema.tabs] } : {},
5674
5758
  sections: schema.sections.map((section) => ({
5675
5759
  ...section,
5676
- fields: section.fields.map((field) => hydrateField(field, values))
5760
+ fields: section.fields.map((field) => hydrateField(field, values, options))
5677
5761
  }))
5678
5762
  };
5679
5763
  }
5680
- function hydrateField(field, values) {
5764
+ function hydrateField(field, values, options) {
5681
5765
  if (isValuelessField(field)) return field;
5682
5766
  if (field.type === "group") {
5683
- const hydratedChildren = field.fields.map((child) => hydrateField(child, values));
5767
+ const hydratedChildren = field.fields.map((child) => hydrateField(child, values, options));
5684
5768
  return {
5685
5769
  ...field,
5686
5770
  fields: hydratedChildren
@@ -5689,7 +5773,7 @@ function hydrateField(field, values) {
5689
5773
  if (field.type === "sub-tabs") {
5690
5774
  const hydratedTabs = field.tabs.map((tab) => ({
5691
5775
  ...tab,
5692
- fields: tab.fields.map((child) => hydrateField(child, values))
5776
+ fields: tab.fields.map((child) => hydrateField(child, values, options))
5693
5777
  }));
5694
5778
  return {
5695
5779
  ...field,
@@ -5699,6 +5783,33 @@ function hydrateField(field, values) {
5699
5783
  const key = field.key;
5700
5784
  const storedValue = Object.prototype.hasOwnProperty.call(values, key) ? values[key] : void 0;
5701
5785
  const defaultValue = field.default;
5786
+ const asView = (v) => isSecretMarker(v) || options.inlineSecretsAsViews === true && v !== void 0;
5787
+ if (isKeychainStoredField(field) && asView(storedValue)) return {
5788
+ ...field,
5789
+ value: toSecretFieldView(storedValue)
5790
+ };
5791
+ if (isKeychainStoredField(field) && options.inlineSecretsAsViews === true) return {
5792
+ ...field,
5793
+ value: null
5794
+ };
5795
+ if (field.type === "editable-array" && Array.isArray(storedValue)) {
5796
+ const secretItemKeys = field.itemFields.filter((item) => "key" in item && isKeychainStoredField(item)).map((item) => "key" in item ? item.key : "");
5797
+ if (secretItemKeys.length > 0) {
5798
+ const rows = storedValue.map((row) => {
5799
+ if (row === null || typeof row !== "object" || Array.isArray(row)) return row;
5800
+ const out = { ...row };
5801
+ for (const k of secretItemKeys) {
5802
+ const v = Reflect.get(row, k);
5803
+ if (asView(v)) out[k] = toSecretFieldView(v);
5804
+ }
5805
+ return out;
5806
+ });
5807
+ return {
5808
+ ...field,
5809
+ value: rows
5810
+ };
5811
+ }
5812
+ }
5702
5813
  if (field.multiple) {
5703
5814
  const stored = Array.isArray(storedValue) ? storedValue : storedValue !== void 0 && storedValue !== null ? [storedValue] : [];
5704
5815
  const itemFallback = field.multiple.itemDefault !== void 0 ? field.multiple.itemDefault : defaultValue !== void 0 ? defaultValue : typeOf(field) === "string" ? "" : null;
@@ -5941,6 +6052,778 @@ function projectStore(store, perNodeKeys, nodeId) {
5941
6052
  }
5942
6053
  return out;
5943
6054
  }
6055
+ var GLOBAL_SCOPE = { kind: "global" };
6056
+ /** The scope every addon-wide (not per-node, not per-device) setting lives in. */
6057
+ function globalSecretScope() {
6058
+ return GLOBAL_SCOPE;
6059
+ }
6060
+ function encodeSegment(value) {
6061
+ return encodeURIComponent(value);
6062
+ }
6063
+ function decodeSegment(value) {
6064
+ try {
6065
+ return decodeURIComponent(value);
6066
+ } catch {
6067
+ return null;
6068
+ }
6069
+ }
6070
+ /**
6071
+ * The field path of a value inside an array item, addressed by the item's id:
6072
+ * `arrayItemFieldPath('providers', 'authentik', 'clientSecret')` →
6073
+ * `providers[authentik].clientSecret`.
6074
+ */
6075
+ function arrayItemFieldPath(arrayKey, itemId, fieldKey) {
6076
+ return `${arrayKey}[${encodeSegment(itemId)}].${fieldKey}`;
6077
+ }
6078
+ function parseScope(segments) {
6079
+ switch (segments[0]) {
6080
+ case "global": return {
6081
+ scope: GLOBAL_SCOPE,
6082
+ used: 1
6083
+ };
6084
+ case "node": {
6085
+ const nodeId = segments[1] !== void 0 ? decodeSegment(segments[1]) : null;
6086
+ return nodeId === null || nodeId.length === 0 ? null : {
6087
+ scope: {
6088
+ kind: "node",
6089
+ nodeId
6090
+ },
6091
+ used: 2
6092
+ };
6093
+ }
6094
+ case "device": {
6095
+ const raw = segments[1];
6096
+ if (raw === void 0 || !/^\d+$/.test(raw)) return null;
6097
+ return {
6098
+ scope: {
6099
+ kind: "device",
6100
+ deviceId: Number(raw)
6101
+ },
6102
+ used: 2
6103
+ };
6104
+ }
6105
+ case "integration": {
6106
+ const id = segments[1] !== void 0 ? decodeSegment(segments[1]) : null;
6107
+ return id === null || id.length === 0 ? null : {
6108
+ scope: {
6109
+ kind: "integration",
6110
+ integrationId: id
6111
+ },
6112
+ used: 2
6113
+ };
6114
+ }
6115
+ case "row": {
6116
+ const collection = segments[1] !== void 0 ? decodeSegment(segments[1]) : null;
6117
+ const rowId = segments[2] !== void 0 ? decodeSegment(segments[2]) : null;
6118
+ if (collection === null || rowId === null || collection.length === 0 || rowId.length === 0) return null;
6119
+ return {
6120
+ scope: {
6121
+ kind: "row",
6122
+ collection,
6123
+ rowId
6124
+ },
6125
+ used: 3
6126
+ };
6127
+ }
6128
+ default: return null;
6129
+ }
6130
+ }
6131
+ /** Take a ref apart; `null` when it is not a well-formed ref. */
6132
+ function parseSecretRef(ref) {
6133
+ if (!ref.startsWith("secret://")) return null;
6134
+ const segments = ref.slice(9).split("/");
6135
+ const owner = segments[0] !== void 0 ? decodeSegment(segments[0]) : null;
6136
+ if (owner === null || owner.length === 0) return null;
6137
+ const parsed = parseScope(segments.slice(1));
6138
+ if (parsed === null) return null;
6139
+ const fieldPath = segments.slice(1 + parsed.used).join("/");
6140
+ if (fieldPath.length === 0) return null;
6141
+ return {
6142
+ owner,
6143
+ scope: parsed.scope,
6144
+ fieldPath
6145
+ };
6146
+ }
6147
+ /** A write to a secret path could not be stored in the keychain, so it was refused. */
6148
+ var KeychainWriteRefusedError = class extends Error {
6149
+ fieldPath;
6150
+ constructor(fieldPath, cause) {
6151
+ super(`secret "${fieldPath}" was not saved: the keychain could not store it (${cause instanceof Error ? cause.message : String(cause)}). Nothing was written.`);
6152
+ this.fieldPath = fieldPath;
6153
+ this.name = "KeychainWriteRefusedError";
6154
+ }
6155
+ };
6156
+ var KEEP = { kind: "keep" };
6157
+ function isRecord$1(value) {
6158
+ return typeof value === "object" && value !== null && !Array.isArray(value);
6159
+ }
6160
+ function defaultMintId() {
6161
+ return globalThis.crypto.randomUUID();
6162
+ }
6163
+ /** Every marker ref anywhere under `value`. */
6164
+ function collectSecretMarkerRefs(value, out = []) {
6165
+ if (isSecretMarker(value)) {
6166
+ out.push(value.$secret);
6167
+ return out;
6168
+ }
6169
+ if (Array.isArray(value)) for (const item of value) collectSecretMarkerRefs(item, out);
6170
+ else if (isRecord$1(value)) for (const child of Object.values(value)) collectSecretMarkerRefs(child, out);
6171
+ return out;
6172
+ }
6173
+ async function storedValueEquals(secrets, marker, candidate) {
6174
+ const resolved = (await secrets.resolve([marker.$secret]))[marker.$secret];
6175
+ return resolved?.kind === "value" && resolved.value === candidate;
6176
+ }
6177
+ async function writeLeaf(ctx, incoming, stored, fieldPath) {
6178
+ const intent = classifySecretWrite(incoming);
6179
+ const ref = ctx.secrets.ref(ctx.scope, fieldPath);
6180
+ const storedIsOurs = isSecretMarker(stored) && stored.$secret === ref;
6181
+ if (intent.kind === "keep") return KEEP;
6182
+ if (intent.kind === "set" && !ctx.operatorWrite && typeof stored === "string" && stored === intent.value) return KEEP;
6183
+ if (intent.kind === "clear") {
6184
+ if (storedIsOurs) ctx.deletes.push(ref);
6185
+ return {
6186
+ kind: "value",
6187
+ value: null
6188
+ };
6189
+ }
6190
+ if (storedIsOurs && await storedValueEquals(ctx.secrets, stored, intent.value)) return {
6191
+ kind: "value",
6192
+ value: stored
6193
+ };
6194
+ try {
6195
+ await ctx.secrets.put(ref, intent.value);
6196
+ } catch (err) {
6197
+ throw new KeychainWriteRefusedError(fieldPath, err);
6198
+ }
6199
+ return {
6200
+ kind: "value",
6201
+ value: makeSecretMarker(ref)
6202
+ };
6203
+ }
6204
+ /** Apply a member result onto `out`: KEEP restores the stored member, or removes it. */
6205
+ function applyMember(out, key, result, storedParent) {
6206
+ if (result.kind === "value") {
6207
+ out[key] = result.value;
6208
+ return;
6209
+ }
6210
+ if (Object.prototype.hasOwnProperty.call(storedParent, key)) out[key] = storedParent[key];
6211
+ else delete out[key];
6212
+ }
6213
+ async function writeMembers(ctx, children, incoming, stored, pathOf) {
6214
+ const out = { ...incoming };
6215
+ for (const [member, node] of children) applyMember(out, member, await writeNode(ctx, node, incoming[member], stored[member], pathOf(member)), stored);
6216
+ return out;
6217
+ }
6218
+ function rowId(row, idKey) {
6219
+ const raw = row[idKey];
6220
+ if (typeof raw === "string" && raw.length > 0) return raw;
6221
+ if (typeof raw === "number" && Number.isFinite(raw)) return String(raw);
6222
+ return null;
6223
+ }
6224
+ async function writeArray(ctx, node, incoming, stored, fieldPath) {
6225
+ const storedRows = Array.isArray(stored) ? stored.filter(isRecord$1) : [];
6226
+ if (!Array.isArray(incoming)) {
6227
+ ctx.deletes.push(...collectSecretMarkerRefs(storedRows));
6228
+ return {
6229
+ kind: "value",
6230
+ value: incoming
6231
+ };
6232
+ }
6233
+ const storedById = /* @__PURE__ */ new Map();
6234
+ for (const row of storedRows) {
6235
+ const id = rowId(row, node.idKey);
6236
+ if (id !== null) storedById.set(id, row);
6237
+ }
6238
+ const kept = /* @__PURE__ */ new Set();
6239
+ const rows = [];
6240
+ for (const row of incoming) {
6241
+ if (!isRecord$1(row)) {
6242
+ rows.push(row);
6243
+ continue;
6244
+ }
6245
+ const id = rowId(row, node.idKey) ?? ctx.mintId();
6246
+ kept.add(id);
6247
+ const withId = {
6248
+ ...row,
6249
+ [node.idKey]: row[node.idKey] ?? id
6250
+ };
6251
+ if (rowId(withId, node.idKey) === null) withId[node.idKey] = id;
6252
+ const storedRow = storedById.get(id) ?? {};
6253
+ rows.push(await writeMembers(ctx, node.item, withId, storedRow, (member) => arrayItemFieldPath(fieldPath, id, member)));
6254
+ }
6255
+ for (const [id, row] of storedById) if (!kept.has(id)) ctx.deletes.push(...collectSecretMarkerRefs(row));
6256
+ return {
6257
+ kind: "value",
6258
+ value: rows
6259
+ };
6260
+ }
6261
+ async function writeNode(ctx, node, incoming, stored, fieldPath) {
6262
+ switch (node.kind) {
6263
+ case "leaf": return writeLeaf(ctx, incoming, stored, fieldPath);
6264
+ case "array": return writeArray(ctx, node, incoming, stored, fieldPath);
6265
+ case "object": {
6266
+ if (!isRecord$1(incoming)) {
6267
+ if (incoming === void 0) return KEEP;
6268
+ ctx.deletes.push(...collectSecretMarkerRefs(stored));
6269
+ return {
6270
+ kind: "value",
6271
+ value: incoming
6272
+ };
6273
+ }
6274
+ const storedObj = isRecord$1(stored) ? stored : {};
6275
+ return {
6276
+ kind: "value",
6277
+ value: await writeMembers(ctx, node.children, incoming, storedObj, (m) => `${fieldPath}.${m}`)
6278
+ };
6279
+ }
6280
+ }
6281
+ }
6282
+ /** Split a perNode-scoped key (`key@nodeId`). */
6283
+ function splitNodeKey(key) {
6284
+ const at = key.indexOf("@");
6285
+ return at <= 0 ? {
6286
+ base: key,
6287
+ nodeId: null
6288
+ } : {
6289
+ base: key.slice(0, at),
6290
+ nodeId: key.slice(at + 1)
6291
+ };
6292
+ }
6293
+ /** Rewrite a settings patch so no secret value reaches the blob. See the file doc. */
6294
+ async function transformSecretWrite(input) {
6295
+ const deletes = [];
6296
+ const base = {
6297
+ secrets: input.secrets,
6298
+ mintId: input.mintId ?? defaultMintId,
6299
+ deletes,
6300
+ operatorWrite: input.operatorWrite === true
6301
+ };
6302
+ const out = {};
6303
+ for (const [key, incoming] of Object.entries(input.patch)) {
6304
+ const { base: baseKey, nodeId } = splitNodeKey(key);
6305
+ const node = input.tree.get(baseKey);
6306
+ if (node === void 0) {
6307
+ out[key] = incoming;
6308
+ continue;
6309
+ }
6310
+ const scope = nodeId !== null && nodeId.length > 0 ? {
6311
+ kind: "node",
6312
+ nodeId
6313
+ } : input.scope ?? globalSecretScope();
6314
+ const result = await writeNode({
6315
+ ...base,
6316
+ scope
6317
+ }, node, incoming, input.stored[key], baseKey);
6318
+ if (result.kind === "value") out[key] = result.value;
6319
+ }
6320
+ return {
6321
+ patch: out,
6322
+ afterWrite: async () => {
6323
+ if (deletes.length === 0) return { orphaned: [] };
6324
+ try {
6325
+ await input.secrets.delete([...new Set(deletes)]);
6326
+ return { orphaned: [] };
6327
+ } catch {
6328
+ return { orphaned: [...new Set(deletes)] };
6329
+ }
6330
+ }
6331
+ };
6332
+ }
6333
+ /** Is `ref` one of `owner`'s refs? */
6334
+ function isSecretRefOwnedBy(ref, owner) {
6335
+ return parseSecretRef(ref)?.owner === owner;
6336
+ }
6337
+ /**
6338
+ * Replace every marker in `value` with its keychain value. Returns the SAME
6339
+ * reference when there is no marker (no allocation, no keychain call).
6340
+ */
6341
+ async function resolveSecretMarkers(value, secrets, options = {}) {
6342
+ const keepMarker = options.unresolved === "keep-marker";
6343
+ const owner = options.ownedBy;
6344
+ const inScope = (ref) => owner === void 0 || isSecretRefOwnedBy(ref, owner);
6345
+ const refs = collectSecretMarkerRefs(value).filter(inScope);
6346
+ if (refs.length === 0) return {
6347
+ value,
6348
+ unresolved: []
6349
+ };
6350
+ const answers = await secrets.resolve(refs);
6351
+ const unresolved = [];
6352
+ for (const ref of new Set(refs)) {
6353
+ const answer = answers[ref];
6354
+ if (answer === void 0) unresolved.push({
6355
+ ref,
6356
+ reason: "not-initialized"
6357
+ });
6358
+ else if (answer.kind === "unavailable") unresolved.push({
6359
+ ref,
6360
+ reason: answer.reason
6361
+ });
6362
+ else if (answer.kind === "missing" || answer.kind === "forbidden") unresolved.push({
6363
+ ref,
6364
+ reason: answer.kind
6365
+ });
6366
+ }
6367
+ const substitute = (v) => {
6368
+ if (isSecretMarker(v)) {
6369
+ if (!inScope(v.$secret)) return {
6370
+ keep: true,
6371
+ value: v
6372
+ };
6373
+ const answer = answers[v.$secret];
6374
+ if (answer?.kind === "value") return {
6375
+ keep: true,
6376
+ value: answer.value
6377
+ };
6378
+ return keepMarker ? {
6379
+ keep: true,
6380
+ value: v
6381
+ } : {
6382
+ keep: false,
6383
+ value: void 0
6384
+ };
6385
+ }
6386
+ if (Array.isArray(v)) {
6387
+ const items = [];
6388
+ for (const item of v) {
6389
+ const s = substitute(item);
6390
+ if (s.keep) items.push(s.value);
6391
+ }
6392
+ return {
6393
+ keep: true,
6394
+ value: items
6395
+ };
6396
+ }
6397
+ if (isRecord$1(v)) {
6398
+ const out = {};
6399
+ for (const [k, child] of Object.entries(v)) {
6400
+ const s = substitute(child);
6401
+ if (s.keep) out[k] = s.value;
6402
+ }
6403
+ return {
6404
+ keep: true,
6405
+ value: out
6406
+ };
6407
+ }
6408
+ return {
6409
+ keep: true,
6410
+ value: v
6411
+ };
6412
+ };
6413
+ return {
6414
+ value: substitute(value).value,
6415
+ unresolved
6416
+ };
6417
+ }
6418
+ /** An addon tried to replace a stored secret it could not read. Nothing was written. */
6419
+ var SecretOverwriteRefusedError = class extends Error {
6420
+ ref;
6421
+ reason;
6422
+ constructor(ref, reason) {
6423
+ 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.`);
6424
+ this.ref = ref;
6425
+ this.reason = reason;
6426
+ this.name = "SecretOverwriteRefusedError";
6427
+ }
6428
+ };
6429
+ function isRecord(value) {
6430
+ return typeof value === "object" && value !== null && !Array.isArray(value);
6431
+ }
6432
+ function resolvedValue(pass, marker) {
6433
+ const answer = pass.answers[marker.$secret];
6434
+ return answer?.kind === "value" ? answer.value : null;
6435
+ }
6436
+ async function atMarker(pass, incoming, stored) {
6437
+ if (incoming === null) return stored;
6438
+ if (typeof incoming !== "string") return incoming;
6439
+ if (incoming === resolvedValue(pass, stored)) return stored;
6440
+ const intent = classifySecretWrite(incoming);
6441
+ if (intent.kind !== "set") return stored;
6442
+ const ref = stored.$secret;
6443
+ if (!isSecretRefOwnedBy(ref, pass.secrets.owner)) return incoming;
6444
+ const answer = pass.answers[ref];
6445
+ 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);
6446
+ try {
6447
+ await pass.secrets.put(ref, intent.value);
6448
+ } catch (err) {
6449
+ throw new KeychainWriteRefusedError(ref, err);
6450
+ }
6451
+ pass.changedRefs.push(ref);
6452
+ return stored;
6453
+ }
6454
+ function inArray(pass, incoming, stored) {
6455
+ return incoming.map((item, index) => {
6456
+ const twin = stored[index];
6457
+ if (isSecretMarker(twin)) return typeof item === "string" && item === resolvedValue(pass, twin) ? twin : item;
6458
+ if (isRecord(item) && isRecord(twin)) return inArrayRow(pass, item, twin);
6459
+ if (Array.isArray(item) && Array.isArray(twin)) return inArray(pass, item, twin);
6460
+ return item;
6461
+ });
6462
+ }
6463
+ function inArrayRow(pass, incoming, stored) {
6464
+ const out = { ...incoming };
6465
+ for (const [key, value] of Object.entries(incoming)) {
6466
+ const twin = stored[key];
6467
+ if (isSecretMarker(twin)) {
6468
+ if (typeof value === "string" && value === resolvedValue(pass, twin)) out[key] = twin;
6469
+ } else if (isRecord(value) && isRecord(twin)) out[key] = inArrayRow(pass, value, twin);
6470
+ else if (Array.isArray(value) && Array.isArray(twin)) out[key] = inArray(pass, value, twin);
6471
+ }
6472
+ return out;
6473
+ }
6474
+ async function walk(pass, incoming, stored) {
6475
+ if (isSecretMarker(stored)) return atMarker(pass, incoming, stored);
6476
+ if (Array.isArray(incoming) && Array.isArray(stored)) return inArray(pass, incoming, stored);
6477
+ if (!isRecord(incoming) || !isRecord(stored)) return incoming;
6478
+ const out = { ...incoming };
6479
+ for (const [key, value] of Object.entries(incoming)) out[key] = await walk(pass, value, stored[key]);
6480
+ return out;
6481
+ }
6482
+ /** Restore markers a write-back carries as values. See the file doc. */
6483
+ async function restoreUnchangedSecrets(input) {
6484
+ const refs = [];
6485
+ for (const key of Object.keys(input.patch)) collectSecretMarkerRefs(input.stored[key], refs);
6486
+ const owned = refs.filter((ref) => isSecretRefOwnedBy(ref, input.secrets.owner));
6487
+ if (owned.length === 0) return {
6488
+ patch: input.patch,
6489
+ changedRefs: []
6490
+ };
6491
+ const pass = {
6492
+ secrets: input.secrets,
6493
+ answers: await input.secrets.resolve([...new Set(owned)]),
6494
+ operatorWrite: input.operatorWrite,
6495
+ changedRefs: []
6496
+ };
6497
+ const out = {};
6498
+ for (const [key, value] of Object.entries(input.patch)) out[key] = await walk(pass, value, input.stored[key]);
6499
+ return {
6500
+ patch: out,
6501
+ changedRefs: pass.changedRefs
6502
+ };
6503
+ }
6504
+ /** Structural equality over JSON-shaped values (key order does not matter). */
6505
+ function isJsonEqual(a, b) {
6506
+ if (Object.is(a, b)) return true;
6507
+ if (Array.isArray(a)) return Array.isArray(b) && a.length === b.length && a.every((v, i) => isJsonEqual(v, b[i]));
6508
+ if (isRecord(a) && isRecord(b)) {
6509
+ const keys = Object.keys(a);
6510
+ if (keys.length !== Object.keys(b).length) return false;
6511
+ return keys.every((k) => Object.prototype.hasOwnProperty.call(b, k) && isJsonEqual(a[k], b[k]));
6512
+ }
6513
+ return false;
6514
+ }
6515
+ /** The patch without the keys whose value already equals the stored one. */
6516
+ function dropUnchangedKeys(patch, stored) {
6517
+ const out = {};
6518
+ for (const [key, value] of Object.entries(patch)) {
6519
+ if (Object.prototype.hasOwnProperty.call(stored, key) && isJsonEqual(value, stored[key])) continue;
6520
+ out[key] = value;
6521
+ }
6522
+ return out;
6523
+ }
6524
+ /** The top-level keys of a blob that hold at least one of `owner`'s markers. */
6525
+ function markerKeysOf(blob, owner) {
6526
+ const keys = /* @__PURE__ */ new Set();
6527
+ for (const [key, value] of Object.entries(blob)) if (collectSecretMarkerRefs(value).some((ref) => isSecretRefOwnedBy(ref, owner))) keys.add(key);
6528
+ return keys;
6529
+ }
6530
+ function nodeFromStored(value, owner) {
6531
+ if (isSecretMarker(value)) return isSecretRefOwnedBy(value.$secret, owner) ? { kind: "leaf" } : null;
6532
+ if (!isRecord(value)) return null;
6533
+ const children = /* @__PURE__ */ new Map();
6534
+ for (const [key, child] of Object.entries(value)) {
6535
+ const node = nodeFromStored(child, owner);
6536
+ if (node !== null) children.set(key, node);
6537
+ }
6538
+ return children.size > 0 ? {
6539
+ kind: "object",
6540
+ children
6541
+ } : null;
6542
+ }
6543
+ /**
6544
+ * The declared secret tree, widened by every place the STORED blob holds a
6545
+ * marker under one of `keys` — so a marker the schema no longer declares (or
6546
+ * never declared: Wyze before b4906cec6) still gets the save path's
6547
+ * KEEP / SET / CLEAR semantics instead of being overwritten by whatever the
6548
+ * addon writes. Markers inside arrays are not added: a row has no id field to
6549
+ * match by unless the schema declares one. Only `owner`'s markers count: a
6550
+ * builtin that keeps another addon's marker (device-manager) never takes it
6551
+ * over.
6552
+ */
6553
+ function widenTreeWithStoredMarkers(declared, stored, keys, owner) {
6554
+ const added = /* @__PURE__ */ new Map();
6555
+ for (const key of keys) {
6556
+ const at = key.indexOf("@");
6557
+ const base = at > 0 ? key.slice(0, at) : key;
6558
+ if (declared.has(base) || added.has(base)) continue;
6559
+ const node = nodeFromStored(stored[key], owner);
6560
+ if (node !== null) added.set(base, node);
6561
+ }
6562
+ return added.size === 0 ? declared : new Map([...declared, ...added]);
6563
+ }
6564
+ /** The blob as stored now; a failed read REFUSES the write instead of guessing. */
6565
+ async function readStoredAddonBlob(raw) {
6566
+ const threeWay = raw.readAddonStoreResult;
6567
+ if (threeWay === void 0) return raw.readAddonStore();
6568
+ const result = await threeWay.call(raw);
6569
+ if (result.kind === "failed") throw new Error(`settings write refused: the stored blob could not be read (${result.error})`);
6570
+ return result.kind === "missing" ? {} : result.value;
6571
+ }
6572
+ function touchesTree(tree, patch) {
6573
+ if (tree.size === 0) return false;
6574
+ for (const key of Object.keys(patch)) {
6575
+ const at = key.indexOf("@");
6576
+ if (tree.has(at > 0 ? key.slice(0, at) : key)) return true;
6577
+ }
6578
+ return false;
6579
+ }
6580
+ /**
6581
+ * Which top-level keys of each store held markers when last seen. `undefined`
6582
+ * for a store not seen yet: its first write reads it, to be safe.
6583
+ */
6584
+ var MarkerKeyIndex = class {
6585
+ owner;
6586
+ byStore = /* @__PURE__ */ new Map();
6587
+ constructor(owner) {
6588
+ this.owner = owner;
6589
+ }
6590
+ seen(store, blob) {
6591
+ this.byStore.set(store, markerKeysOf(blob, this.owner));
6592
+ }
6593
+ wrote(store, patch) {
6594
+ const keys = this.byStore.get(store);
6595
+ if (keys === void 0) return;
6596
+ const now = markerKeysOf(patch, this.owner);
6597
+ for (const key of Object.keys(patch)) if (now.has(key)) keys.add(key);
6598
+ else keys.delete(key);
6599
+ }
6600
+ mayHoldMarkers(store, patch) {
6601
+ const keys = this.byStore.get(store);
6602
+ if (keys === void 0) return true;
6603
+ return Object.keys(patch).some((key) => keys.has(key));
6604
+ }
6605
+ };
6606
+ function createHandle(raw, opts) {
6607
+ const chains = /* @__PURE__ */ new Map();
6608
+ const serialize = (key, fn) => {
6609
+ const next = (chains.get(key) ?? Promise.resolve()).then(fn, fn);
6610
+ const tail = next.catch(() => void 0);
6611
+ chains.set(key, tail);
6612
+ tail.then(() => {
6613
+ if (chains.get(key) === tail) chains.delete(key);
6614
+ });
6615
+ return next;
6616
+ };
6617
+ const index = new MarkerKeyIndex(opts.secrets.owner);
6618
+ const resolveRead = async (store, blob) => {
6619
+ index.seen(store, blob);
6620
+ const { value, unresolved } = await resolveSecretMarkers(blob, opts.secrets, {
6621
+ unresolved: "keep-marker",
6622
+ ownedBy: opts.secrets.owner
6623
+ });
6624
+ if (unresolved.length > 0) opts.onUnresolved?.(unresolved);
6625
+ return value;
6626
+ };
6627
+ const write = async (store, declared, scope, patch, readStored, rawWrite) => {
6628
+ if (!touchesTree(declared, patch) && !index.mayHoldMarkers(store, patch)) {
6629
+ await rawWrite(patch);
6630
+ index.wrote(store, patch);
6631
+ return { changed: true };
6632
+ }
6633
+ return serialize(store, async () => {
6634
+ const stored = await readStored();
6635
+ index.seen(store, stored);
6636
+ const operatorWrite = opts.isOperatorWrite?.() === true;
6637
+ const restored = await restoreUnchangedSecrets({
6638
+ patch,
6639
+ stored,
6640
+ secrets: opts.secrets,
6641
+ operatorWrite
6642
+ });
6643
+ const result = await transformSecretWrite({
6644
+ tree: widenTreeWithStoredMarkers(declared, stored, Object.keys(restored.patch), opts.secrets.owner),
6645
+ secrets: opts.secrets,
6646
+ patch: restored.patch,
6647
+ stored,
6648
+ ...scope !== void 0 ? { scope } : {},
6649
+ operatorWrite
6650
+ });
6651
+ const effective = dropUnchangedKeys(result.patch, stored);
6652
+ const wroteBlob = Object.keys(effective).length > 0;
6653
+ if (wroteBlob) {
6654
+ await rawWrite(effective);
6655
+ index.wrote(store, effective);
6656
+ }
6657
+ const { orphaned } = await result.afterWrite();
6658
+ if (orphaned.length > 0) opts.onOrphaned(orphaned);
6659
+ return { changed: wroteBlob || restored.changedRefs.length > 0 };
6660
+ });
6661
+ };
6662
+ const writeAddon = (patch) => write("addon", opts.addonTree(), void 0, patch, () => readStoredAddonBlob(raw), (p) => raw.writeAddonStore(p));
6663
+ const readAddonStoreResult = raw.readAddonStoreResult;
6664
+ const readAddonStoreKeyResult = raw.readAddonStoreKeyResult;
6665
+ const readDeviceStoreBatch = raw.readDeviceStoreBatch;
6666
+ const overrides = {
6667
+ readAddonStore: async () => resolveRead("addon", await raw.readAddonStore()),
6668
+ ...readAddonStoreResult !== void 0 ? { readAddonStoreResult: async () => {
6669
+ const result = await readAddonStoreResult.call(raw);
6670
+ return result.kind === "value" ? {
6671
+ kind: "value",
6672
+ value: await resolveRead("addon", result.value)
6673
+ } : result;
6674
+ } } : {},
6675
+ ...readAddonStoreKeyResult !== void 0 ? { readAddonStoreKeyResult: async (key) => {
6676
+ const result = await readAddonStoreKeyResult.call(raw, key);
6677
+ if (result.kind !== "present") return result;
6678
+ const { value, unresolved } = await resolveSecretMarkers({ [key]: result.value }, opts.secrets, {
6679
+ unresolved: "keep-marker",
6680
+ ownedBy: opts.secrets.owner
6681
+ });
6682
+ if (unresolved.length > 0) opts.onUnresolved?.(unresolved);
6683
+ return {
6684
+ kind: "present",
6685
+ value: value[key]
6686
+ };
6687
+ } } : {},
6688
+ readDeviceStore: async (deviceId) => resolveRead(`device:${deviceId}`, await raw.readDeviceStore(deviceId)),
6689
+ ...readDeviceStoreBatch !== void 0 ? { readDeviceStoreBatch: async (deviceIds) => {
6690
+ const rows = await readDeviceStoreBatch.call(raw, deviceIds);
6691
+ const out = /* @__PURE__ */ new Map();
6692
+ for (const [deviceId, blob] of rows) out.set(deviceId, await resolveRead(`device:${deviceId}`, blob));
6693
+ return out;
6694
+ } } : {},
6695
+ writeAddonStore: async (patch) => {
6696
+ await writeAddon(patch);
6697
+ },
6698
+ writeDeviceStore: async (deviceId, patch) => {
6699
+ await write(`device:${deviceId}`, opts.deviceTree(), {
6700
+ kind: "device",
6701
+ deviceId
6702
+ }, patch, () => raw.readDeviceStore(deviceId), (p) => raw.writeDeviceStore(deviceId, p));
6703
+ }
6704
+ };
6705
+ return {
6706
+ settings: new Proxy(raw, { get(target, prop, receiver) {
6707
+ if (typeof prop === "string" && Object.prototype.hasOwnProperty.call(overrides, prop)) return Reflect.get(overrides, prop);
6708
+ const value = Reflect.get(target, prop, receiver);
6709
+ return typeof value === "function" ? value.bind(target) : value;
6710
+ } }),
6711
+ raw: {
6712
+ readAddonStore: async () => {
6713
+ const blob = await raw.readAddonStore();
6714
+ index.seen("addon", blob);
6715
+ return blob;
6716
+ },
6717
+ readDeviceStore: async (deviceId) => {
6718
+ const blob = await raw.readDeviceStore(deviceId);
6719
+ index.seen(`device:${deviceId}`, blob);
6720
+ return blob;
6721
+ }
6722
+ },
6723
+ writeAddonStore: writeAddon
6724
+ };
6725
+ }
6726
+ /** The context the addon sees, plus the private raw view and write outcome. */
6727
+ function createSecretAwareContext(context, opts) {
6728
+ const raw = context.settings;
6729
+ if (raw === void 0) return {
6730
+ context,
6731
+ handle: null
6732
+ };
6733
+ const handle = createHandle(raw, opts);
6734
+ return {
6735
+ context: new Proxy(context, { get(target, prop, receiver) {
6736
+ if (prop === "settings") return handle.settings;
6737
+ return Reflect.get(target, prop, receiver);
6738
+ } }),
6739
+ handle
6740
+ };
6741
+ }
6742
+ var LEAF = { kind: "leaf" };
6743
+ var DEFAULT_ITEM_ID_KEY = "id";
6744
+ function collectFields(fields, out) {
6745
+ for (const field of fields) {
6746
+ if (field.type === "group") {
6747
+ collectFields(field.fields, out);
6748
+ continue;
6749
+ }
6750
+ if (field.type === "sub-tabs") {
6751
+ for (const tab of field.tabs) collectFields(tab.fields, out);
6752
+ continue;
6753
+ }
6754
+ if (field.type === "editable-array") {
6755
+ const item = /* @__PURE__ */ new Map();
6756
+ for (const itemField of field.itemFields) if ("key" in itemField && isKeychainStoredField(itemField)) item.set(itemField.key, LEAF);
6757
+ if (item.size > 0) out.set(field.key, {
6758
+ kind: "array",
6759
+ idKey: field.itemIdKey ?? DEFAULT_ITEM_ID_KEY,
6760
+ item
6761
+ });
6762
+ continue;
6763
+ }
6764
+ if (!("key" in field) || typeof field.key !== "string") continue;
6765
+ if (isKeychainStoredField(field)) out.set(field.key, LEAF);
6766
+ }
6767
+ }
6768
+ /** The secret tree a settings schema declares. */
6769
+ function secretTreeFromSchema(schema) {
6770
+ const out = /* @__PURE__ */ new Map();
6771
+ if (schema === null) return out;
6772
+ for (const section of schema.sections) collectFields(section.fields, out);
6773
+ return out;
6774
+ }
6775
+ /** Parse `a.b[id].c` into segments; throws on a malformed path (a declaration bug). */
6776
+ function parseSecretStatePath(path) {
6777
+ const segments = [];
6778
+ for (const raw of path.split(".")) {
6779
+ const m = /^([^[\]]+)(?:\[([^[\]]+)\])?$/.exec(raw);
6780
+ if (m === null || m[1] === void 0) throw new Error(`secretStatePaths: malformed path "${path}"`);
6781
+ segments.push(m[2] !== void 0 ? {
6782
+ key: m[1],
6783
+ idKey: m[2]
6784
+ } : { key: m[1] });
6785
+ }
6786
+ if (segments.length === 0) throw new Error(`secretStatePaths: empty path`);
6787
+ if (segments[segments.length - 1]?.idKey !== void 0) throw new Error(`secretStatePaths: "${path}" ends on an array — name the member that is secret`);
6788
+ return segments;
6789
+ }
6790
+ function insert(into, segments) {
6791
+ const [head, ...rest] = segments;
6792
+ if (head === void 0) return;
6793
+ if (rest.length === 0) {
6794
+ into.set(head.key, LEAF);
6795
+ return;
6796
+ }
6797
+ const existing = into.get(head.key);
6798
+ if (head.idKey !== void 0) {
6799
+ const item = new Map(existing?.kind === "array" ? existing.item : []);
6800
+ insert(item, rest);
6801
+ into.set(head.key, {
6802
+ kind: "array",
6803
+ idKey: head.idKey,
6804
+ item
6805
+ });
6806
+ return;
6807
+ }
6808
+ const children = new Map(existing?.kind === "object" ? existing.children : []);
6809
+ insert(children, rest);
6810
+ into.set(head.key, {
6811
+ kind: "object",
6812
+ children
6813
+ });
6814
+ }
6815
+ /** Add hidden-state paths (`secretStatePaths`) to a schema-derived tree. */
6816
+ function mergeSecretStatePaths(tree, paths) {
6817
+ if (paths.length === 0) return tree;
6818
+ const out = new Map(tree);
6819
+ for (const path of paths) insert(out, parseSecretStatePath(path));
6820
+ return out;
6821
+ }
6822
+ /** First retry of a secret the keychain could not serve; doubles to {@link SECRET_RETRY_MAX_MS}. */
6823
+ var SECRET_RETRY_FIRST_MS = 5e3;
6824
+ var SECRET_RETRY_MAX_MS = 5 * 6e4;
6825
+ /** Coalesces a burst of `keychain.changed` events into one re-resolve. */
6826
+ var SECRET_CHANGE_DEBOUNCE_MS = 250;
5944
6827
  /**
5945
6828
  * Base class for CamStack addons. Eliminates settings boilerplate:
5946
6829
  *
@@ -6010,6 +6893,33 @@ var BaseAddon = class {
6010
6893
  settingsStoreReady = false;
6011
6894
  /** Default config values. Provided via constructor. */
6012
6895
  defaults;
6896
+ /**
6897
+ * Hidden-state paths that hold secrets (D787) — values the addon writes
6898
+ * itself (`updateGlobalSettings`, `state()`) that no form field declares.
6899
+ * Stored in the keychain exactly like a `password` field. Syntax:
6900
+ * `'snapshotSigningKey'`, `'identity.pincode'`, `'tokens[userId].accessToken'`
6901
+ * (`key[<id field>]` addresses array items by id, never by index).
6902
+ */
6903
+ secretStatePaths = [];
6904
+ _addonSecretTree = null;
6905
+ _deviceSecretTree = null;
6906
+ /** Refs the last resolved config pointed at — a change to one re-resolves. */
6907
+ _configSecretRefs = /* @__PURE__ */ new Set();
6908
+ _unresolvedSecrets = [];
6909
+ _secretRetryTimer = null;
6910
+ _secretRetryDelayMs = SECRET_RETRY_FIRST_MS;
6911
+ _secretChangeTimer = null;
6912
+ _secretChangeUnsub = null;
6913
+ /** >0 while an OPERATOR's settings write is being applied. */
6914
+ _operatorWriteDepth = 0;
6915
+ /**
6916
+ * The keychain-aware settings handle (D798). Its `raw` view is the ONLY way
6917
+ * to the marker-bearing blobs and stays private to this class: the form
6918
+ * hydrate and config resolution need markers, addon code never does.
6919
+ */
6920
+ _secretSettings = null;
6921
+ /** Refs an addon-facing read could not resolve — each is logged once per process. */
6922
+ _loggedUnresolvedReads = /* @__PURE__ */ new Set();
6013
6923
  constructor(defaults) {
6014
6924
  this.defaults = defaults;
6015
6925
  this._config = { ...defaults };
@@ -6045,8 +6955,26 @@ var BaseAddon = class {
6045
6955
  return this._config;
6046
6956
  }
6047
6957
  async initialize(context) {
6048
- this._ctx = context;
6958
+ const secrets = context.secrets;
6959
+ if (secrets !== void 0) {
6960
+ const { context: wrapped, handle } = createSecretAwareContext(context, {
6961
+ secrets,
6962
+ addonTree: () => this.addonSecretTree(),
6963
+ deviceTree: () => this.deviceSecretTree(),
6964
+ onOrphaned: (refs) => context.logger.warn("keychain refs dropped by a settings write could not be deleted", { meta: { refs: [...refs] } }),
6965
+ isOperatorWrite: () => this._operatorWriteDepth > 0,
6966
+ onUnresolved: (unresolved) => this.logUnresolvedRead(unresolved)
6967
+ });
6968
+ this._ctx = wrapped;
6969
+ this._secretSettings = handle;
6970
+ } else {
6971
+ this._ctx = context;
6972
+ this._secretSettings = null;
6973
+ }
6049
6974
  await this.resolveConfig();
6975
+ if (secrets !== void 0) this._secretChangeUnsub = secrets.onChange((ref) => {
6976
+ if (this._configSecretRefs.has(ref)) this.scheduleSecretReresolve(SECRET_CHANGE_DEBOUNCE_MS);
6977
+ });
6050
6978
  const result = await this.onInitialize();
6051
6979
  this.emitLifecycle(EventCategory.AddonStarted);
6052
6980
  const normalized = normalizeAddonInitResult(result);
@@ -6079,6 +7007,12 @@ var BaseAddon = class {
6079
7007
  */
6080
7008
  async onHubReachable() {}
6081
7009
  async shutdown() {
7010
+ this._secretChangeUnsub?.();
7011
+ this._secretChangeUnsub = null;
7012
+ if (this._secretRetryTimer !== null) clearTimeout(this._secretRetryTimer);
7013
+ if (this._secretChangeTimer !== null) clearTimeout(this._secretChangeTimer);
7014
+ this._secretRetryTimer = null;
7015
+ this._secretChangeTimer = null;
6082
7016
  this.emitLifecycle(EventCategory.AddonStopped);
6083
7017
  if (this.autoEmitReadiness) this.emitReadinessForProviders("down");
6084
7018
  await this.onShutdown();
@@ -6153,11 +7087,8 @@ var BaseAddon = class {
6153
7087
  async getGlobalSettings(overlay, cap, nodeId) {
6154
7088
  const schema = this.globalSettingsSchema(cap);
6155
7089
  if (!schema) return { sections: [] };
6156
- const projected = await this.resolveGlobalStore(nodeId, cap);
6157
- return hydrateSchema(schema, overlay ? {
6158
- ...projected,
6159
- ...overlay
6160
- } : projected);
7090
+ const projected = await this.readRawProjectedStore(nodeId, cap);
7091
+ return hydrateSchema(schema, overlay ? await this.overlayKeepingMarkers(projected, overlay) : projected, { inlineSecretsAsViews: true });
6161
7092
  }
6162
7093
  /**
6163
7094
  * The integration-level view of this addon's settings: exactly the sections
@@ -6202,11 +7133,11 @@ var BaseAddon = class {
6202
7133
  });
6203
7134
  }
6204
7135
  if (sections.length === 0) return null;
6205
- const projected = await this.resolveGlobalStore(nodeId);
7136
+ const projected = await this.readRawProjectedStore(nodeId);
6206
7137
  return hydrateSchema({
6207
7138
  ...schema,
6208
7139
  sections
6209
- }, projected);
7140
+ }, projected, { inlineSecretsAsViews: true });
6210
7141
  }
6211
7142
  /**
6212
7143
  * The raw addon store PROJECTED onto the target node's bare per-node keys:
@@ -6219,12 +7150,50 @@ var BaseAddon = class {
6219
7150
  * the store for custom option logic (option narrowing, value snapping) to
6220
7151
  * read it per-node — never `ctx.settings.readAddonStore()` directly.
6221
7152
  * `nodeId` omitted ⇒ the local node (node-blind injection from ctx).
7153
+ *
7154
+ * Keychain values come back RESOLVED (D798): a secret reads as its value,
7155
+ * never as a `{ $secret }` marker. One the keychain cannot serve right now
7156
+ * stays a marker — "stored, unavailable" (`isSecretMarker()` is true, and it
7157
+ * is listed in {@link unresolvedSecrets}) — never `''` and never absent, so
7158
+ * it cannot be mistaken for "nothing stored, mint a new one". Writing the
7159
+ * resolved blob back is a no-op for every unchanged secret.
6222
7160
  */
6223
7161
  async resolveGlobalStore(nodeId, cap) {
6224
7162
  const raw = await this._ctx?.settings?.readAddonStore() ?? {};
7163
+ return this.projectForNode(raw, nodeId, cap);
7164
+ }
7165
+ projectForNode(store, nodeId, cap) {
6225
7166
  const keys = this.perNodeKeys(cap);
6226
7167
  const node = normalizeNodeId(nodeId ?? this._ctx?.kernel?.localNodeId);
6227
- return keys.size > 0 ? projectStore(raw, keys, node) : raw;
7168
+ return keys.size > 0 ? projectStore(store, keys, node) : store;
7169
+ }
7170
+ /** The PROJECTED store with its markers — the form hydrate only (D798). */
7171
+ async readRawProjectedStore(nodeId, cap) {
7172
+ const raw = await this.rawSettings()?.readAddonStore() ?? {};
7173
+ return this.projectForNode(raw, nodeId, cap);
7174
+ }
7175
+ /**
7176
+ * `{ ...stored, ...overlay }`, except that an overlay member equal to the
7177
+ * RESOLVED stored one keeps the stored (marker-bearing) member — so a form
7178
+ * hydrated from a resolved overlay still shows a secret as "set", never as
7179
+ * its value.
7180
+ */
7181
+ async overlayKeepingMarkers(stored, overlay) {
7182
+ const secrets = this._ctx?.secrets;
7183
+ const merged = {
7184
+ ...stored,
7185
+ ...overlay
7186
+ };
7187
+ if (secrets === void 0 || collectSecretMarkerRefs(stored).length === 0) return merged;
7188
+ const { value: resolved } = await resolveSecretMarkers(stored, secrets, {
7189
+ unresolved: "keep-marker",
7190
+ ownedBy: secrets.owner
7191
+ });
7192
+ for (const key of Object.keys(overlay)) {
7193
+ if (collectSecretMarkerRefs(stored[key]).length === 0) continue;
7194
+ if (isJsonEqual(overlay[key], resolved[key])) merged[key] = stored[key];
7195
+ }
7196
+ return merged;
6228
7197
  }
6229
7198
  /**
6230
7199
  * Whether ONE global key of this addon's store was written, read three-way
@@ -6260,18 +7229,58 @@ var BaseAddon = class {
6260
7229
  value: result.value[key]
6261
7230
  };
6262
7231
  }
7232
+ /**
7233
+ * The OPERATOR's write — a settings form or an admin API call, dispatched by
7234
+ * the kernel. Identical to {@link updateGlobalSettings}, except that a secret
7235
+ * the operator sends is stored as sent even when it equals a pre-keychain
7236
+ * inline value: the operator re-entering a password is a change, an addon
7237
+ * writing back what it read is not (D787).
7238
+ */
7239
+ async updateGlobalSettingsAsOperator(patch, nodeId) {
7240
+ this._operatorWriteDepth++;
7241
+ try {
7242
+ await this.applyGlobalPatch(patch, nodeId);
7243
+ } finally {
7244
+ this._operatorWriteDepth--;
7245
+ }
7246
+ }
6263
7247
  async updateGlobalSettings(patch, nodeId) {
7248
+ await this.applyGlobalPatch(patch, nodeId);
7249
+ }
7250
+ /**
7251
+ * REMOVE stored secrets — their keychain values and their markers (D787).
7252
+ *
7253
+ * Writing `''` to a secret field KEEPS what is stored (an empty string is
7254
+ * what a defaults fallback writes back, and it must never destroy a
7255
+ * credential), so code that means "forget this token" says so here. Without
7256
+ * a keychain (an older kernel) it writes `''`, as such code always did.
7257
+ */
7258
+ async clearSecrets(keys, nodeId) {
7259
+ const tree = this.addonSecretTree();
7260
+ const keychain = this._ctx?.secrets !== void 0;
7261
+ const stored = keychain ? await this.readAddonStoreWithRetry() : {};
7262
+ const patch = {};
7263
+ for (const key of keys) {
7264
+ const keychainStored = tree.has(key) || collectSecretMarkerRefs(stored[key]).length > 0;
7265
+ patch[key] = keychain && keychainStored ? SECRET_CLEAR : "";
7266
+ }
7267
+ await this.applyGlobalPatch(patch, nodeId);
7268
+ }
7269
+ async applyGlobalPatch(barePatch, nodeId) {
6264
7270
  const keys = this.perNodeKeys();
6265
7271
  const localNode = normalizeNodeId(this._ctx?.kernel?.localNodeId);
6266
7272
  const target = normalizeNodeId(nodeId ?? this._ctx?.kernel?.localNodeId);
6267
- const barePatch = patch;
6268
7273
  const scoped = keys.size > 0 ? scopePatch(barePatch, keys, target) : barePatch;
6269
- await this._ctx?.settings?.writeAddonStore(scoped);
7274
+ const handle = this._secretSettings;
7275
+ if (handle !== null) {
7276
+ const { changed } = await handle.writeAddonStore(scoped);
7277
+ if (!changed) return;
7278
+ } else await this._ctx?.settings?.writeAddonStore(scoped);
6270
7279
  if (target !== localNode) return;
6271
7280
  await this.resolveConfig();
6272
7281
  await this.onConfigChanged();
6273
7282
  this.emitLifecycle(EventCategory.AddonUpdated, { level: "global" });
6274
- this.maybeAutoRestart(patch, this.globalSettingsSchema());
7283
+ this.maybeAutoRestart(Object.keys(barePatch), this.globalSettingsSchema());
6275
7284
  }
6276
7285
  /**
6277
7286
  * The set of field keys the global settings schema declares `perNode: true`
@@ -6296,7 +7305,7 @@ var BaseAddon = class {
6296
7305
  * time to return its response before the addon is torn down and
6297
7306
  * re-initialised by `AddonRegistryService.restartAddon`.
6298
7307
  */
6299
- maybeAutoRestart(patch, schema) {
7308
+ maybeAutoRestart(patchKeys, schema) {
6300
7309
  if (!schema) return;
6301
7310
  const restartKeys = /* @__PURE__ */ new Set();
6302
7311
  for (const section of schema.sections) for (const field of section.fields) {
@@ -6304,13 +7313,13 @@ var BaseAddon = class {
6304
7313
  if (field.requiresRestart) restartKeys.add(field.key);
6305
7314
  }
6306
7315
  if (restartKeys.size === 0) return;
6307
- if (!Object.keys(patch).some((k) => restartKeys.has(k))) return;
7316
+ if (!patchKeys.some((k) => restartKeys.has(k))) return;
6308
7317
  const ctx = this._ctx;
6309
7318
  if (!ctx) return;
6310
7319
  const addonId = ctx.id;
6311
7320
  setImmediate(() => {
6312
7321
  ctx.api.addons?.restartAddon?.mutate({ addonId }).then(() => {
6313
- ctx.logger.info("addon auto-restart triggered by restart-required setting change", { meta: { changedFields: Object.keys(patch).filter((k) => restartKeys.has(k)) } });
7322
+ ctx.logger.info("addon auto-restart triggered by restart-required setting change", { meta: { changedFields: patchKeys.filter((k) => restartKeys.has(k)) } });
6314
7323
  }).catch((err) => {
6315
7324
  ctx.logger.error("addon auto-restart failed", { meta: { error: err instanceof Error ? err.message : String(err) } });
6316
7325
  });
@@ -6319,7 +7328,7 @@ var BaseAddon = class {
6319
7328
  async getDeviceSettings(deviceId) {
6320
7329
  const schema = this.deviceSettingsSchema();
6321
7330
  if (!schema) return { sections: [] };
6322
- return hydrateSchema(schema, await this._ctx?.settings?.readDeviceStore(deviceId) ?? {});
7331
+ return hydrateSchema(schema, await this.rawSettings()?.readDeviceStore(deviceId) ?? {}, { inlineSecretsAsViews: true });
6323
7332
  }
6324
7333
  async updateDeviceSettings(deviceId, patch) {
6325
7334
  await this._ctx?.settings?.writeDeviceStore(deviceId, patch);
@@ -6449,7 +7458,7 @@ var BaseAddon = class {
6449
7458
  * selection at boot (absent scoped key ⇒ the constructor default wins).
6450
7459
  */
6451
7460
  async resolveConfig() {
6452
- const stored = await this.readAddonStoreWithRetry();
7461
+ const stored = await this.resolveStoredSecrets(await this.readAddonStoreWithRetry());
6453
7462
  const perNode = this.perNodeKeys();
6454
7463
  const localNode = normalizeNodeId(this._ctx?.kernel?.localNodeId);
6455
7464
  const resolved = { ...this.defaults };
@@ -6474,7 +7483,7 @@ var BaseAddon = class {
6474
7483
  key,
6475
7484
  schema,
6476
7485
  fallback,
6477
- read: () => this.readAddonStoreWithRetry(),
7486
+ read: async () => this.resolveStoredSecrets(await this.readAddonStoreWithRetry()),
6478
7487
  write: async (patch) => {
6479
7488
  await this._ctx?.settings?.writeAddonStore(patch);
6480
7489
  },
@@ -6491,7 +7500,7 @@ var BaseAddon = class {
6491
7500
  key,
6492
7501
  schema,
6493
7502
  fallback,
6494
- read: async () => await this._ctx?.settings?.readDeviceStore(deviceId) ?? {},
7503
+ read: async () => this.resolveStoredSecrets(await this.rawSettings()?.readDeviceStore(deviceId) ?? {}, false),
6495
7504
  write: async (patch) => {
6496
7505
  await this._ctx?.settings?.writeDeviceStore(deviceId, patch);
6497
7506
  },
@@ -6503,6 +7512,87 @@ var BaseAddon = class {
6503
7512
  } })
6504
7513
  });
6505
7514
  }
7515
+ /** The addon store's secret tree: schema fields by TYPE, plus `secretStatePaths`. */
7516
+ addonSecretTree() {
7517
+ this._addonSecretTree ??= mergeSecretStatePaths(secretTreeFromSchema(this.globalSettingsSchema()), this.secretStatePaths);
7518
+ return this._addonSecretTree;
7519
+ }
7520
+ deviceSecretTree() {
7521
+ this._deviceSecretTree ??= secretTreeFromSchema(this.deviceSettingsSchema());
7522
+ return this._deviceSecretTree;
7523
+ }
7524
+ /**
7525
+ * Secrets of this addon's stored config that could not be resolved on the
7526
+ * last read, with why. Non-empty means the addon is running WITHOUT them —
7527
+ * an addon whose function needs one should report itself degraded rather
7528
+ * than start on an empty credential.
7529
+ */
7530
+ get unresolvedSecrets() {
7531
+ return this._unresolvedSecrets;
7532
+ }
7533
+ /**
7534
+ * Substitute every keychain marker in a stored blob with its value. With no
7535
+ * keychain (no `ctx.secrets`) or no marker, the blob comes back unchanged.
7536
+ * An unresolvable value is LEFT OUT (never `''`), logged by ref — never by
7537
+ * value — and, when the cause can pass, retried with backoff. Nothing is
7538
+ * ever written back from here.
7539
+ */
7540
+ async resolveStoredSecrets(blob, trackForConfig = true) {
7541
+ const secrets = this._ctx?.secrets;
7542
+ if (secrets === void 0) return blob;
7543
+ const refs = collectSecretMarkerRefs(blob);
7544
+ if (trackForConfig) this._configSecretRefs = new Set(refs);
7545
+ if (refs.length === 0) {
7546
+ if (trackForConfig) this._unresolvedSecrets = [];
7547
+ return blob;
7548
+ }
7549
+ const { value, unresolved } = await resolveSecretMarkers(blob, secrets);
7550
+ if (trackForConfig) {
7551
+ this._unresolvedSecrets = unresolved;
7552
+ if (unresolved.length > 0) {
7553
+ this._ctx?.logger?.error?.("secret unavailable — running without it, will retry", { meta: { secrets: unresolved.map((u) => ({
7554
+ ref: u.ref,
7555
+ reason: u.reason
7556
+ })) } });
7557
+ if (unresolved.some((u) => u.reason !== "missing" && u.reason !== "forbidden")) {
7558
+ this.scheduleSecretReresolve(this._secretRetryDelayMs);
7559
+ this._secretRetryDelayMs = Math.min(this._secretRetryDelayMs * 2, SECRET_RETRY_MAX_MS);
7560
+ }
7561
+ } else this._secretRetryDelayMs = SECRET_RETRY_FIRST_MS;
7562
+ }
7563
+ return value;
7564
+ }
7565
+ /**
7566
+ * The marker-bearing settings reads (D798) — private on purpose. Without a
7567
+ * keychain the context's own view is already raw.
7568
+ */
7569
+ rawSettings() {
7570
+ return this._secretSettings?.raw ?? this._ctx?.settings;
7571
+ }
7572
+ /** An addon-facing read met markers it could not resolve: say so once per ref. */
7573
+ logUnresolvedRead(unresolved) {
7574
+ const fresh = unresolved.filter((u) => !this._loggedUnresolvedReads.has(u.ref));
7575
+ if (fresh.length === 0) return;
7576
+ for (const u of fresh) this._loggedUnresolvedReads.add(u.ref);
7577
+ 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) => ({
7578
+ ref: u.ref,
7579
+ reason: u.reason
7580
+ })) } });
7581
+ }
7582
+ /** Re-resolve the config (a keychain-only change, or a retry) and apply it. */
7583
+ scheduleSecretReresolve(delayMs) {
7584
+ const timerOf = delayMs === SECRET_CHANGE_DEBOUNCE_MS ? "_secretChangeTimer" : "_secretRetryTimer";
7585
+ if (this[timerOf] !== null) return;
7586
+ const timer = setTimeout(() => {
7587
+ this[timerOf] = null;
7588
+ if (this._ctx === null) return;
7589
+ this.resolveConfig().then(() => this.onConfigChanged()).catch((err) => {
7590
+ this._ctx?.logger?.error?.("re-resolving secrets failed", { meta: { error: err instanceof Error ? err.message : String(err) } });
7591
+ });
7592
+ }, delayMs);
7593
+ timer.unref?.();
7594
+ this[timerOf] = timer;
7595
+ }
6506
7596
  /**
6507
7597
  * Wrap `ctx.settings.readAddonStore()` with a short retry budget so a
6508
7598
  * transient settings-store outage (mid-restart of sqlite-settings, tsx-watch
@@ -6515,7 +7605,7 @@ var BaseAddon = class {
6515
7605
  * `{}` (defaults) — the addon's first successful patch will rehydrate.
6516
7606
  */
6517
7607
  async readAddonStoreWithRetry() {
6518
- const settings = this._ctx?.settings;
7608
+ const settings = this.rawSettings();
6519
7609
  if (!settings) return {};
6520
7610
  const delaysMs = [
6521
7611
  150,
@@ -7090,6 +8180,69 @@ method(object({ deviceId: number() }), array(StreamSourceEntrySchema)), method(o
7090
8180
  kind: "mutation",
7091
8181
  auth: "admin"
7092
8182
  }), method(object({ deviceId: number() }), unknown().nullable()), method(object({ deviceId: number() }), RawStateResultSchema.nullable(), { auth: "protected" });
8183
+ function defOf(schema) {
8184
+ return schema._zod?.def ?? {};
8185
+ }
8186
+ function declaredHere(schema) {
8187
+ return globalRegistry.get(schema)?.secret === true;
8188
+ }
8189
+ /** Wrapper kinds whose `innerType` is the field itself. */
8190
+ var WRAPPERS = new Set([
8191
+ "optional",
8192
+ "nullable",
8193
+ "default",
8194
+ "prefault",
8195
+ "catch",
8196
+ "readonly",
8197
+ "nonoptional"
8198
+ ]);
8199
+ /**
8200
+ * The schema layers that make up ONE field: the schema itself and every
8201
+ * wrapper below it (optional / default / nullable / readonly / catch), plus
8202
+ * both sides of a pipe (`z.preprocess` puts the real schema on `out`,
8203
+ * `.transform` on `in`).
8204
+ */
8205
+ function layersOf(schema) {
8206
+ const out = [];
8207
+ const queue = [schema];
8208
+ while (queue.length > 0) {
8209
+ const s = queue.shift();
8210
+ if (!s || out.includes(s)) continue;
8211
+ out.push(s);
8212
+ const def = defOf(s);
8213
+ if (def.type !== void 0 && WRAPPERS.has(def.type) && def.innerType) queue.push(def.innerType);
8214
+ if (def.type === "pipe") {
8215
+ if (def.in) queue.push(def.in);
8216
+ if (def.out) queue.push(def.out);
8217
+ }
8218
+ }
8219
+ return out;
8220
+ }
8221
+ /** True when any layer of this field declares `.meta({ secret: true })`. */
8222
+ function isZodSecret(schema) {
8223
+ return layersOf(schema).some(declaredHere);
8224
+ }
8225
+ /**
8226
+ * Every declared secret path in a config schema: dotted keys, `[]` for "each
8227
+ * element of this array" (`connection.password`, `rows[].token`). A declared
8228
+ * object or array is reported as one path and not descended into — everything
8229
+ * under it is secret.
8230
+ */
8231
+ function collectZodSecretPaths(schema, prefix = "") {
8232
+ if (isZodSecret(schema)) return prefix.length > 0 ? [prefix] : [];
8233
+ const paths = [];
8234
+ for (const layer of layersOf(schema)) {
8235
+ const def = defOf(layer);
8236
+ if (def.type === "object" && def.shape) for (const [key, child] of Object.entries(def.shape)) paths.push(...collectZodSecretPaths(child, prefix ? `${prefix}.${key}` : key));
8237
+ else if (def.type === "array" && def.element) paths.push(...collectZodSecretPaths(def.element, `${prefix}[]`));
8238
+ else if (def.type === "union" && def.options) for (const option of def.options) paths.push(...collectZodSecretPaths(option, prefix));
8239
+ else if (def.type === "intersection") {
8240
+ if (def.left) paths.push(...collectZodSecretPaths(def.left, prefix));
8241
+ if (def.right) paths.push(...collectZodSecretPaths(def.right, prefix));
8242
+ }
8243
+ }
8244
+ return [...new Set(paths)];
8245
+ }
7093
8246
  //#endregion
7094
8247
  //#region ../types/dist/err-msg-DX6i_MY4.mjs
7095
8248
  var DeviceType = /* @__PURE__ */ function(DeviceType) {
@@ -8777,6 +9930,278 @@ var CameraSwitchGroupSchema = object({
8777
9930
  fetchedAt: number()
8778
9931
  });
8779
9932
  /**
9933
+ * The trainer contract — what the hub hands the cloud trainer and what it
9934
+ * gets back (cloud training, D805+).
9935
+ *
9936
+ * The trainer (`hf/camstack-trainer`, published as the Hugging Face repo
9937
+ * `camstack/camstack-trainer`) is a separate AGPL program the hub never
9938
+ * imports: `job.json` goes in, files come out, and progress is `CAMSTACK_EVENT`
9939
+ * lines on stdout. These schemas are the hub's half of that boundary; the
9940
+ * trainer's pydantic models (and the JSON Schemas generated from them under
9941
+ * `hf/camstack-trainer/schemas/`) are the other half. A change here is a
9942
+ * change there, in the same piece of work.
9943
+ *
9944
+ * No `.default()` anywhere: defaults do not run on the addon cap path, so the
9945
+ * orchestrator fills every field of a job spec explicitly.
9946
+ */
9947
+ var TRAINING_JOB_SCHEMA = "camstack.training/v1";
9948
+ var TRAINING_RESULT_SCHEMA = "camstack.training-result/v1";
9949
+ /** What the trainer can export. Edge TPU is a later, separate image. */
9950
+ var TrainingExportSchema = _enum([
9951
+ "onnx",
9952
+ "openvino-fp16",
9953
+ "openvino-int8",
9954
+ "coreml-fp16"
9955
+ ]);
9956
+ var FloorsSchema = record(string(), number().min(0).max(1));
9957
+ object({
9958
+ schema: literal(TRAINING_JOB_SCHEMA),
9959
+ jobKey: string().uuid(),
9960
+ target: object({
9961
+ kind: literal("detector"),
9962
+ step: literal("object-detection")
9963
+ }),
9964
+ base: object({
9965
+ modelId: string().min(1),
9966
+ /** Ultralytics weights id, e.g. `yolov9m.pt`. */
9967
+ weights: string().min(1),
9968
+ imgsz: number().int().positive()
9969
+ }),
9970
+ baseline: object({
9971
+ modelId: string().min(1),
9972
+ /** The baseline ONNX the holdout comparison runs; public mirror URL. */
9973
+ onnxUrl: string().url(),
9974
+ imgsz: number().int().positive(),
9975
+ floors: FloorsSchema
9976
+ }),
9977
+ dataset: object({
9978
+ versionId: string().min(1),
9979
+ annotationHash: string(),
9980
+ /** sha256 of the uploaded archive; the trainer refuses a mismatch (exit 65). */
9981
+ sha256: string().regex(/^[0-9a-f]{64}$/)
9982
+ }),
9983
+ split: object({
9984
+ holdoutCameras: array(number().int()),
9985
+ /** When no camera is held out: the last N days of every camera. */
9986
+ holdoutLastDays: number().int().nonnegative(),
9987
+ valFraction: number().min(0).max(.5),
9988
+ seed: number().int()
9989
+ }),
9990
+ hyper: object({
9991
+ epochs: number().int().positive(),
9992
+ batch: number().int().positive(),
9993
+ lr0: number().positive(),
9994
+ /** Layers frozen from the start of the backbone; 0 = none. */
9995
+ freeze: number().int().nonnegative(),
9996
+ patience: number().int().nonnegative(),
9997
+ seed: number().int()
9998
+ }),
9999
+ replay: object({
10000
+ source: literal("coco2017"),
10001
+ count: number().int().nonnegative()
10002
+ }),
10003
+ exports: array(TrainingExportSchema).min(1),
10004
+ calibration: object({ maxFrames: number().int().positive() }),
10005
+ floors: object({
10006
+ minSupport: number().int().positive(),
10007
+ clamp: number().min(0).max(1)
10008
+ }),
10009
+ int8Gate: object({ maxMap50Drop: number().min(0).max(1) }),
10010
+ catalog: object({
10011
+ id: string().regex(/^[a-z0-9][a-z0-9-]{2,80}$/),
10012
+ name: string().min(1).max(160)
10013
+ })
10014
+ });
10015
+ /** One regular file of the bundle. An mlpackage contributes one row per member. */
10016
+ var TrainingResultFileSchema = object({
10017
+ path: string().min(1),
10018
+ bytes: number().int().nonnegative(),
10019
+ sha256: string().regex(/^[0-9a-f]{64}$/),
10020
+ format: _enum([
10021
+ "onnx",
10022
+ "openvino",
10023
+ "coreml",
10024
+ "pt"
10025
+ ]),
10026
+ variant: _enum(["base", "int8"])
10027
+ });
10028
+ var DraftFormatSchema = object({
10029
+ /** RELATIVE path inside the bundle; the hub rewrites it to `camstack-local://`. */
10030
+ url: string().min(1),
10031
+ sizeMB: number().nonnegative(),
10032
+ isDirectory: boolean().optional(),
10033
+ files: array(string()).optional(),
10034
+ runtimes: array(literal("python")).optional(),
10035
+ revision: string().min(1)
10036
+ });
10037
+ /** The trainer's half of a catalog entry; the hub completes it (labels, licence, group). */
10038
+ var TrainingCatalogDraftSchema = object({
10039
+ id: string().min(1),
10040
+ name: string().min(1),
10041
+ description: string(),
10042
+ labels: array(unknown()),
10043
+ inputSize: object({
10044
+ width: number().int().positive(),
10045
+ height: number().int().positive()
10046
+ }),
10047
+ preprocessMode: literal("letterbox"),
10048
+ defaultClassFloors: FloorsSchema,
10049
+ formats: object({
10050
+ onnx: DraftFormatSchema.optional(),
10051
+ openvino: DraftFormatSchema.optional(),
10052
+ coreml: DraftFormatSchema.optional()
10053
+ })
10054
+ });
10055
+ /** One class of one model's holdout report (the eval harness's summary). */
10056
+ var TrainingEvalClassSchema = object({
10057
+ positives: number().int(),
10058
+ floor: number().nullable(),
10059
+ tp: number().int(),
10060
+ fp: number().int(),
10061
+ fn: number().int(),
10062
+ precision: number().nullable(),
10063
+ recall: number().nullable(),
10064
+ ap50: number().nullable(),
10065
+ recallByCamera: record(string(), number().nullable()).optional(),
10066
+ recallByLight: record(string(), number().nullable()).optional(),
10067
+ fpByCamera: record(string(), number()).optional(),
10068
+ smallFound: number().int().optional(),
10069
+ smallTotal: number().int().optional()
10070
+ }).passthrough();
10071
+ var TrainingEvalReportSchema = object({
10072
+ frames: number().int(),
10073
+ classes: record(string(), TrainingEvalClassSchema)
10074
+ }).passthrough();
10075
+ /**
10076
+ * A succeeded result carries every block; a failed one carries the error and
10077
+ * whatever was known by then — the other blocks are ABSENT, not null. The
10078
+ * orchestrator checks the blocks it needs before it trusts a success.
10079
+ */
10080
+ var TrainingResultSchema = object({
10081
+ schema: literal(TRAINING_RESULT_SCHEMA),
10082
+ jobKey: string(),
10083
+ status: _enum(["succeeded", "failed"]),
10084
+ error: object({
10085
+ stage: string(),
10086
+ code: string(),
10087
+ message: string()
10088
+ }).nullable(),
10089
+ trainer: object({
10090
+ version: string(),
10091
+ revision: string()
10092
+ }),
10093
+ toolchain: record(string(), string().nullable()),
10094
+ dataset: object({
10095
+ versionId: string(),
10096
+ annotationHash: string(),
10097
+ sha256: string(),
10098
+ frames: object({
10099
+ train: number().int(),
10100
+ val: number().int(),
10101
+ holdout: number().int()
10102
+ }),
10103
+ holdoutCameras: array(number().int()),
10104
+ replayImages: number().int()
10105
+ }).optional(),
10106
+ training: object({
10107
+ epochsRun: number().int(),
10108
+ bestEpoch: number().int(),
10109
+ bestMap50: number(),
10110
+ bestMap50_95: number(),
10111
+ seconds: number()
10112
+ }).optional(),
10113
+ evaluation: object({
10114
+ holdoutFrames: number().int(),
10115
+ baseline: TrainingEvalReportSchema.nullable(),
10116
+ candidate: TrainingEvalReportSchema.nullable(),
10117
+ candidateInt8: TrainingEvalReportSchema.nullable(),
10118
+ recallDeltaByCamera: record(string(), record(string(), number())).nullable(),
10119
+ map50: record(string(), number().nullable())
10120
+ }).optional(),
10121
+ floors: object({
10122
+ baseline: FloorsSchema,
10123
+ candidate: FloorsSchema,
10124
+ candidateInt8: FloorsSchema.nullable(),
10125
+ notes: array(string())
10126
+ }).optional(),
10127
+ int8: object({
10128
+ kept: boolean(),
10129
+ map50Fp16: number().nullable(),
10130
+ map50Int8: number().nullable(),
10131
+ reason: string().nullable()
10132
+ }).optional(),
10133
+ exportsDropped: array(object({
10134
+ export: string(),
10135
+ reason: string()
10136
+ })).optional(),
10137
+ files: array(TrainingResultFileSchema).optional(),
10138
+ bundle: object({
10139
+ path: literal("bundle.tar"),
10140
+ bytes: number().int().nonnegative(),
10141
+ sha256: string().regex(/^[0-9a-f]{64}$/)
10142
+ }).nullable().optional(),
10143
+ catalogDraft: object({
10144
+ base: TrainingCatalogDraftSchema,
10145
+ int8: TrainingCatalogDraftSchema.nullable()
10146
+ }).nullable().optional(),
10147
+ licence: string()
10148
+ });
10149
+ var TrainingStageSchema = _enum([
10150
+ "prepare",
10151
+ "replay",
10152
+ "train",
10153
+ "eval",
10154
+ "export",
10155
+ "package"
10156
+ ]);
10157
+ var EventBase = {
10158
+ v: literal(1),
10159
+ ts: number()
10160
+ };
10161
+ discriminatedUnion("type", [
10162
+ object({
10163
+ ...EventBase,
10164
+ type: literal("stage"),
10165
+ stage: TrainingStageSchema
10166
+ }),
10167
+ object({
10168
+ ...EventBase,
10169
+ type: literal("epoch"),
10170
+ epoch: number().int(),
10171
+ epochs: number().int(),
10172
+ boxLoss: number().nullable().optional(),
10173
+ map50: number().nullable().optional(),
10174
+ map50_95: number().nullable().optional(),
10175
+ etaSec: number().nullable().optional()
10176
+ }),
10177
+ object({
10178
+ ...EventBase,
10179
+ type: literal("metric"),
10180
+ name: string(),
10181
+ value: number()
10182
+ }),
10183
+ object({
10184
+ ...EventBase,
10185
+ type: literal("artifact"),
10186
+ path: string(),
10187
+ bytes: number(),
10188
+ sha256: string()
10189
+ }),
10190
+ object({
10191
+ ...EventBase,
10192
+ type: literal("done"),
10193
+ status: _enum(["succeeded", "failed"]),
10194
+ resultSha256: string().nullable().optional()
10195
+ }),
10196
+ object({
10197
+ ...EventBase,
10198
+ type: literal("error"),
10199
+ stage: string(),
10200
+ code: string(),
10201
+ message: string()
10202
+ })
10203
+ ]);
10204
+ /**
8780
10205
  * What the gate decided about a birth, from the CALLER's point of view.
8781
10206
  *
8782
10207
  * Deliberately not `ConfirmationVerdict`: `undecided` is not a birth decision
@@ -11385,7 +12810,9 @@ var AddonHttpRouteSchema = object({
11385
12810
  "authenticated",
11386
12811
  "admin"
11387
12812
  ]).optional(),
11388
- description: string().optional()
12813
+ description: string().optional(),
12814
+ /** The hub limits this route per client address before the handler runs. */
12815
+ rateLimit: _enum(["auth"]).optional()
11389
12816
  });
11390
12817
  /**
11391
12818
  * Cross-process route invocation envelope. The hub captures the
@@ -12090,6 +13517,37 @@ var BackupDestinationInfoSchema = object({
12090
13517
  lastError: string().optional()
12091
13518
  });
12092
13519
  /**
13520
+ * How an archive is encrypted (operator decision 2026-10-09): to a backup
13521
+ * PUBLIC key the hub holds, so only the operator's secret key opens it.
13522
+ * Absent on a plain `.tar.gz` — every archive made before encryption, or
13523
+ * with it off — which restores without a key.
13524
+ */
13525
+ var BackupArchiveEncryptionSchema = object({
13526
+ /** `x25519-hkdf-aes256gcm-stream-v1`. */
13527
+ scheme: string(),
13528
+ /** 16 hex — the backup key whose secret restores this archive. */
13529
+ keyId: string()
13530
+ });
13531
+ /**
13532
+ * The backup encryption setting. The hub keeps PUBLIC keys only: the active
13533
+ * one new archives are encrypted to, and the retired ones older archives
13534
+ * still need. The secret key is shown once, at `setupEncryption`.
13535
+ */
13536
+ var BackupEncryptionStatusSchema = object({
13537
+ enabled: boolean(),
13538
+ active: object({
13539
+ keyId: string(),
13540
+ publicKey: string(),
13541
+ createdAt: number()
13542
+ }).nullable(),
13543
+ /** Every key ever set up, newest first. */
13544
+ keys: array(object({
13545
+ keyId: string(),
13546
+ createdAt: number(),
13547
+ retiredAt: number().nullable()
13548
+ })).readonly()
13549
+ });
13550
+ /**
12093
13551
  * Per-archive entry returned by `backup.listArchives({ destinationId })`.
12094
13552
  * Same shape the destination drill-in renders. Sourced from the per-
12095
13553
  * location `manifests.json` (no per-archive tarball read required).
@@ -12101,7 +13559,9 @@ var BackupArchiveEntrySchema = object({
12101
13559
  sizeBytes: number(),
12102
13560
  label: string().optional(),
12103
13561
  /** Top-level locations included in the archive (db, addons, tls, …). */
12104
- locations: array(string()).readonly()
13562
+ locations: array(string()).readonly(),
13563
+ /** Present when the archive is encrypted; restore then needs that key. */
13564
+ encryption: BackupArchiveEncryptionSchema.optional()
12105
13565
  });
12106
13566
  var BackupEntrySchema = object({
12107
13567
  id: string(),
@@ -12110,7 +13570,8 @@ var BackupEntrySchema = object({
12110
13570
  label: string().optional(),
12111
13571
  createdAt: number(),
12112
13572
  sizeBytes: number(),
12113
- locations: array(string()).optional()
13573
+ locations: array(string()).optional(),
13574
+ encryption: BackupArchiveEncryptionSchema.optional()
12114
13575
  });
12115
13576
  var ArchiveEntrySchema = object({
12116
13577
  path: string(),
@@ -12299,10 +13760,40 @@ method(_void(), array(BackupDestinationInfoSchema).readonly(), { auth: "admin" }
12299
13760
  * this list and skips entries whose path doesn't start with
12300
13761
  * any of them.
12301
13762
  */
12302
- locations: array(string()).optional()
13763
+ locations: array(string()).optional(),
13764
+ /**
13765
+ * The backup SECRET key, for an encrypted archive (ignored for a plain
13766
+ * one). The archive is decrypted into the hub's private staging
13767
+ * before the restart; the key is not stored. A wrong or missing key
13768
+ * is refused before the archive is downloaded.
13769
+ */
13770
+ backupSecretKey: string().optional()
12303
13771
  }), _void(), {
12304
13772
  kind: "mutation",
12305
13773
  auth: "admin"
13774
+ }), method(_void(), BackupEncryptionStatusSchema, { auth: "admin" }), method(object({}), object({
13775
+ keyId: string(),
13776
+ secretKey: string(),
13777
+ publicKey: string(),
13778
+ createdAt: number(),
13779
+ replacedKeyId: string().nullable()
13780
+ }), {
13781
+ kind: "mutation",
13782
+ auth: "admin"
13783
+ }), method(object({}), object({ disabledKeyId: string().nullable() }), {
13784
+ kind: "mutation",
13785
+ auth: "admin"
13786
+ }), method(object({ backupSecretKey: string() }), object({
13787
+ valid: boolean(),
13788
+ keyId: string().nullable(),
13789
+ /** The hub knows this key (active or retired). */
13790
+ known: boolean(),
13791
+ /** It is the key new archives are encrypted to. */
13792
+ active: boolean(),
13793
+ error: string().optional()
13794
+ }), {
13795
+ kind: "mutation",
13796
+ auth: "admin"
12306
13797
  }), method(object({
12307
13798
  destinationId: string(),
12308
13799
  backupId: string()
@@ -14028,7 +15519,60 @@ var CustomModelDescriptorSchema = object({
14028
15519
  stepId: string(),
14029
15520
  entry: ModelCatalogEntrySchema
14030
15521
  });
14031
- method(_void(), array(CustomModelDescriptorSchema).readonly(), { auth: "admin" });
15522
+ /** One regular file of an imported bundle, as the producer measured it. */
15523
+ var ModelBundleFileSchema = object({
15524
+ /** Relative path inside the bundle tar; an mlpackage member is `<x>.mlpackage/<member>`. */
15525
+ path: string().min(1),
15526
+ bytes: number().int().nonnegative(),
15527
+ sha256: string().regex(/^[0-9a-f]{64}$/)
15528
+ });
15529
+ var ImportModelBundleInputSchema = object({
15530
+ /** The registry provider that keeps the model (Model Studio). */
15531
+ addonId: string(),
15532
+ stepId: string().min(1),
15533
+ /**
15534
+ * The catalog rows to register, complete, every format URL already
15535
+ * `camstack-local://<modelId>/<file>` naming a file of the bundle. One
15536
+ * bundle may carry several rows (a base and its INT8 variant).
15537
+ */
15538
+ entries: array(ModelCatalogEntrySchema).min(1).max(4),
15539
+ /** The bundle tar, offered by the producer over `ctx.peerBytes` (same host). */
15540
+ bundle: object({
15541
+ ticket: PeerBytesTicketSchema,
15542
+ bytes: number().int().positive(),
15543
+ sha256: string().regex(/^[0-9a-f]{64}$/)
15544
+ }),
15545
+ /** Every file the tar must hold; anything missing, extra or different is refused. */
15546
+ files: array(ModelBundleFileSchema).min(1).max(64),
15547
+ /** Convert missing engine formats and push the model to every agent afterwards. */
15548
+ distribute: boolean()
15549
+ });
15550
+ var ImportModelBundleResultSchema = discriminatedUnion("kind", [object({
15551
+ kind: literal("imported"),
15552
+ modelIds: array(string()).readonly(),
15553
+ distributed: array(object({
15554
+ modelId: string(),
15555
+ nodeId: string(),
15556
+ format: _enum(MODEL_FORMATS),
15557
+ ok: boolean(),
15558
+ error: string().optional()
15559
+ })).readonly()
15560
+ }), object({
15561
+ kind: literal("refused"),
15562
+ reason: _enum([
15563
+ "transfer-failed",
15564
+ "checksum-mismatch",
15565
+ "bundle-mismatch",
15566
+ "invalid-entry",
15567
+ "id-taken"
15568
+ ]),
15569
+ detail: string()
15570
+ })]);
15571
+ method(_void(), array(CustomModelDescriptorSchema).readonly(), { auth: "admin" }), method(ImportModelBundleInputSchema, ImportModelBundleResultSchema, {
15572
+ kind: "mutation",
15573
+ auth: "admin",
15574
+ timeoutMs: 30 * 6e4
15575
+ });
14032
15576
  /**
14033
15577
  * Query filter for settings-store collections.
14034
15578
  */
@@ -14411,6 +15955,253 @@ id: union([string(), number()]) }), {
14411
15955
  kind: "mutation",
14412
15956
  auth: "admin"
14413
15957
  });
15958
+ /**
15959
+ * `keychain` — the hub's encrypted store of secret values (D787).
15960
+ *
15961
+ * Settings blobs never hold a secret: they hold a marker
15962
+ * `{"$secret":"secret://<owner>/<scope>/<fieldPath>","v":1}` and the value
15963
+ * lives here, AES-256-GCM under a data key that a master key wraps. This cap
15964
+ * is the OWNER's door to its own values: every method is owner-checked
15965
+ * against the CALLER, never against anything the caller claims.
15966
+ *
15967
+ * Who the caller is: the transport stamps `callerAddonId` into the args of a
15968
+ * call that crossed a process (the parent `LocalChildRegistry` from the UDS
15969
+ * connection, the agent from its child's connection carried in
15970
+ * `$hub-cap-fwd`'s envelope). A stamp always overwrites; a wire call with no
15971
+ * stamp has its claim stripped. Only a hub in-process caller may state its own
15972
+ * identity — `ctx.secrets` does that with the addon id closed over. This is
15973
+ * identity against BUGS and misrouting, not against a malicious addon (every
15974
+ * runner is the same OS user): see the threat model in
15975
+ * `docs/design/2026-10-08-secrets-keychain.md`.
15976
+ *
15977
+ * `callerAddonId` is deliberately NOT in any input schema: the tRPC router
15978
+ * parses the input, so a session can never supply it, and the internal mount
15979
+ * floors every method to admin anyway (D240).
15980
+ *
15981
+ * Internal: addons reach it through `ctx.secrets`, never directly.
15982
+ */
15983
+ /** Why a value cannot be served right now. Never folded into "missing". */
15984
+ var KeychainUnavailableReasonSchema = _enum([
15985
+ "key-missing",
15986
+ "wrong-key",
15987
+ "key-file-unreadable",
15988
+ "store-unavailable",
15989
+ "not-initialized",
15990
+ "decrypt-failed"
15991
+ ]);
15992
+ var KeychainStateSchema = discriminatedUnion("state", [object({ state: literal("ready") }), object({
15993
+ state: literal("locked"),
15994
+ reason: KeychainUnavailableReasonSchema
15995
+ })]);
15996
+ var KeychainResolveEntrySchema = discriminatedUnion("kind", [
15997
+ object({
15998
+ kind: literal("value"),
15999
+ value: string(),
16000
+ version: number().int()
16001
+ }),
16002
+ object({ kind: literal("missing") }),
16003
+ object({
16004
+ kind: literal("unavailable"),
16005
+ reason: KeychainUnavailableReasonSchema
16006
+ }),
16007
+ object({ kind: literal("forbidden") })
16008
+ ]);
16009
+ var KeychainResolveResultSchema = record(string(), KeychainResolveEntrySchema);
16010
+ /** Metadata of one stored value — never the value. */
16011
+ var KeychainSecretMetaSchema = object({
16012
+ ref: string(),
16013
+ owner: string(),
16014
+ /** Formatted scope (`global`, `node/<id>`, `device/<id>`, …). */
16015
+ scope: string(),
16016
+ fieldPath: string(),
16017
+ version: number().int(),
16018
+ createdAt: number(),
16019
+ updatedAt: number(),
16020
+ /** `addon:<id>` | `user:<id>` | `system`. */
16021
+ updatedBy: string(),
16022
+ /** Coarse — written at most once an hour per ref. `null` = never read. */
16023
+ lastReadAt: number().nullable()
16024
+ });
16025
+ var RefListSchema = array(string().min(1)).max(512);
16026
+ method(object({
16027
+ ref: string().min(1),
16028
+ value: string().min(1)
16029
+ }), object({
16030
+ ref: string(),
16031
+ version: number().int()
16032
+ }), {
16033
+ kind: "mutation",
16034
+ auth: "admin"
16035
+ }), method(object({ refs: RefListSchema }), KeychainResolveResultSchema, { auth: "admin" }), method(object({ refs: RefListSchema }), object({ deleted: number().int() }), {
16036
+ kind: "mutation",
16037
+ auth: "admin"
16038
+ }), method(object({}), array(KeychainSecretMetaSchema).readonly(), { auth: "admin" }), method(object({}), KeychainStateSchema, { auth: "admin" });
16039
+ var KeychainKeySourceSchema = object({
16040
+ kind: _enum([
16041
+ "config-file",
16042
+ "previous-config-file",
16043
+ "platform",
16044
+ "default-file"
16045
+ ]),
16046
+ /** File sources only — a path is not a secret. */
16047
+ path: string().optional(),
16048
+ /**
16049
+ * True when a whole-volume backup of the data directory carries this key
16050
+ * next to the database it protects (the default file). The page warns.
16051
+ */
16052
+ sharesBackupWithDatabase: boolean()
16053
+ });
16054
+ /**
16055
+ * One keychain reset, as the Secrets page reports it until the operator
16056
+ * acknowledges it. Never a value: refs, counts and table names only.
16057
+ */
16058
+ var KeychainResetRecordSchema = object({
16059
+ id: string(),
16060
+ at: number(),
16061
+ /** `user:<id>` or {@link KEYCHAIN_RESET_TRIGGER_ACTOR}. */
16062
+ actor: string(),
16063
+ /** Why the keychain was locked when it was reset; `null` when it was not locked. */
16064
+ lockedReason: string().nullable(),
16065
+ /** Values moved into the archive table (ciphertext under the lost key). */
16066
+ archived: number().int(),
16067
+ /** `keychain:secrets-orphaned-<ts>`, or `null` when nothing was stored. */
16068
+ archivedCollection: string().nullable(),
16069
+ /**
16070
+ * `keychain:keys-orphaned-<ts>`: the wrapped data keys of the archive, kept
16071
+ * so the archive can still be opened if the lost master key turns up.
16072
+ */
16073
+ archivedKeysCollection: string().nullable(),
16074
+ /**
16075
+ * `system-settings` keys whose marker the reset cleared — the cluster
16076
+ * secret's: a marker left pointing at an archived value would refuse every
16077
+ * agent forever (D797).
16078
+ */
16079
+ clearedSettingsKeys: array(string()).readonly(),
16080
+ /** When an operator dismissed the notice on the Secrets page; `null` until then. */
16081
+ acknowledgedAt: number().nullable()
16082
+ });
16083
+ var KeychainStatusSchema = object({
16084
+ keychain: KeychainStateSchema,
16085
+ /** The source of the master key in use; `null` while locked. */
16086
+ keySource: KeychainKeySourceSchema.nullable(),
16087
+ /** The source configured to be primary — differs from `keySource` while a rotation is pending. */
16088
+ configuredSource: KeychainKeySourceSchema,
16089
+ /** Short fingerprint of the master key in use (`HMAC(KEK, label)`, 16 hex). */
16090
+ fingerprint: string().nullable(),
16091
+ activeKeyId: string().nullable(),
16092
+ /**
16093
+ * The keychain unlocked with a NON-primary source: the configured primary
16094
+ * key is not the one that wraps the data key yet. `rotateMasterKey` moves it.
16095
+ */
16096
+ rotationPending: boolean(),
16097
+ /** Wrapped copies of the data key under a previous master key, kept until purged. */
16098
+ retiredWraps: number().int(),
16099
+ recoveryKeyDownloadedAt: number().nullable(),
16100
+ secretCount: number().int(),
16101
+ /** The most recent reset, acknowledged or not; `null` when the keychain was never reset. */
16102
+ lastReset: KeychainResetRecordSchema.nullable()
16103
+ });
16104
+ /**
16105
+ * Whether a stored value is still pointed at by its owner's settings.
16106
+ * `unknown` is a first-class answer: a scope whose blob could not be read is
16107
+ * never reported as an orphan (and never deleted as one).
16108
+ */
16109
+ var KeychainSecretUsageSchema = _enum([
16110
+ "in-use",
16111
+ "orphan",
16112
+ "unknown"
16113
+ ]);
16114
+ var KeychainAdminSecretSchema = KeychainSecretMetaSchema.extend({ usage: KeychainSecretUsageSchema });
16115
+ var KeychainAuditActionSchema = _enum([
16116
+ "put",
16117
+ "delete",
16118
+ "reveal",
16119
+ "rotate-master-key",
16120
+ "purge-retired-keys",
16121
+ "download-recovery-key",
16122
+ "delete-orphans",
16123
+ "reset",
16124
+ "acknowledge-reset",
16125
+ "initialize"
16126
+ ]);
16127
+ var KeychainAuditEntrySchema = object({
16128
+ id: string(),
16129
+ at: number(),
16130
+ action: KeychainAuditActionSchema,
16131
+ /** `addon:<id>` | `user:<id>` | `system` | `trigger-file`. */
16132
+ actor: string(),
16133
+ ref: string().nullable(),
16134
+ detail: string().nullable()
16135
+ });
16136
+ var KEYCHAIN_RESET_CONFIRMATION = "RESET KEYCHAIN";
16137
+ /**
16138
+ * Secrets the HUB itself holds (owner `system`) that no settings form shows:
16139
+ * `jwt-signing-key` — the session signing key (D797). It is always "in use",
16140
+ * never an orphan; it is generated on a fresh hub and replaced only through
16141
+ * {@link keychainAdminCapability.methods.setSystemSecret}.
16142
+ */
16143
+ var SystemHeldSecretNameSchema = _enum(["jwt-signing-key"]);
16144
+ 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({
16145
+ value: string(),
16146
+ version: number().int()
16147
+ }), {
16148
+ kind: "mutation",
16149
+ auth: "admin",
16150
+ caller: "required"
16151
+ }), method(object({
16152
+ name: SystemHeldSecretNameSchema,
16153
+ value: string().min(16)
16154
+ }), object({
16155
+ ref: string(),
16156
+ version: number().int()
16157
+ }), {
16158
+ kind: "mutation",
16159
+ auth: "admin",
16160
+ caller: "required"
16161
+ }), method(object({ refs: array(string().min(1)).max(1e3) }), object({
16162
+ deleted: array(string()).readonly(),
16163
+ kept: array(object({
16164
+ ref: string(),
16165
+ usage: KeychainSecretUsageSchema
16166
+ })).readonly()
16167
+ }), {
16168
+ kind: "mutation",
16169
+ auth: "admin",
16170
+ caller: "required"
16171
+ }), method(object({}), object({
16172
+ fingerprint: string(),
16173
+ keySource: KeychainKeySourceSchema
16174
+ }), {
16175
+ kind: "mutation",
16176
+ auth: "admin",
16177
+ caller: "required"
16178
+ }), method(object({}), object({ purged: number().int() }), {
16179
+ kind: "mutation",
16180
+ auth: "admin",
16181
+ caller: "required"
16182
+ }), method(object({}), object({
16183
+ key: string(),
16184
+ fingerprint: string(),
16185
+ keySource: KeychainKeySourceSchema
16186
+ }), {
16187
+ kind: "mutation",
16188
+ auth: "admin",
16189
+ caller: "required"
16190
+ }), method(object({ confirm: literal(KEYCHAIN_RESET_CONFIRMATION) }), object({
16191
+ archivedCollection: string().nullable(),
16192
+ archived: number().int()
16193
+ }), {
16194
+ kind: "mutation",
16195
+ auth: "admin",
16196
+ caller: "required"
16197
+ }), method(object({}), object({
16198
+ reset: KeychainResetRecordSchema.nullable(),
16199
+ pendingReentry: array(KeychainSecretMetaSchema).readonly()
16200
+ }), { auth: "admin" }), method(object({}), object({ acknowledged: boolean() }), {
16201
+ kind: "mutation",
16202
+ auth: "admin",
16203
+ caller: "required"
16204
+ });
14414
16205
  method(_void(), object({
14415
16206
  id: string(),
14416
16207
  name: string(),
@@ -15749,7 +17540,11 @@ var DeviceRegisterPayloadSchema = object({
15749
17540
  var DeviceRemovePayloadSchema = object({ deviceId: number() });
15750
17541
  var DevicePersistConfigPayloadSchema = object({
15751
17542
  deviceId: number(),
15752
- data: record(string(), unknown())
17543
+ data: record(string(), unknown()),
17544
+ /** The paths the device's schema declares secret (D783), when the caller
17545
+ * knows them — those values are kept in the keychain, not the blob (D787).
17546
+ * Absent: the paths the device last reported at `registerDevice` apply. */
17547
+ secretConfigPaths: array(string()).optional()
15753
17548
  });
15754
17549
  /** What a migration actually did, per switch. `unreachable` is a first-class
15755
17550
  * answer: a camera that could not be asked is not a camera that was silenced. */
@@ -17371,7 +19166,7 @@ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
17371
19166
  * `login-method` — collection cap through which auth addons contribute
17372
19167
  * their pre-auth login surfaces to the login page. This is the SINGLE,
17373
19168
  * generic mechanism that supersedes the dead `auth.listProviders` reader:
17374
- * every auth addon (OIDC, magic-link, WebAuthn/passkey) registers a
19169
+ * every auth addon (OIDC, WebAuthn/passkey) registers a
17375
19170
  * `login-method` provider and the PUBLIC `auth.listLoginMethods`
17376
19171
  * procedure aggregates them for the unauthenticated login page.
17377
19172
  *
@@ -17379,8 +19174,7 @@ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
17379
19174
  *
17380
19175
  * - `redirect` — a declarative button. The login page renders a generic
17381
19176
  * button that navigates to `startUrl` (an addon-owned HTTP route).
17382
- * Covers OIDC (`/addon/auth-oidc/<id>/start`) and magic-link with
17383
- * ZERO shell-side JS. A future SSO addon plugs in the same way — the
19177
+ * Covers OIDC (`/addon/auth-oidc/<id>/start`) with ZERO shell-side JS. A future SSO addon plugs in the same way — the
17384
19178
  * login page needs NO change.
17385
19179
  *
17386
19180
  * - `widget` — a Module-Federation widget the login page mounts (via
@@ -17399,8 +19193,8 @@ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
17399
19193
  * decision.
17400
19194
  *
17401
19195
  * Every contribution carries a `stage`:
17402
- * - `primary` — shown on the first credentials screen (OIDC /
17403
- * magic-link buttons; a future usernameless passkey).
19196
+ * - `primary` — shown on the first credentials screen (OIDC
19197
+ * buttons; a usernameless passkey).
17404
19198
  * - `second-factor` — shown AFTER the password leg, gated on the
17405
19199
  * returned `factors` (passkey-as-2FA today).
17406
19200
  *
@@ -17427,7 +19221,7 @@ var LoginMethodContributionSchema = discriminatedUnion("kind", [
17427
19221
  * The provider names an external identity a signed-in user can link to
17428
19222
  * their own account (D782): `auth.listLinkableProviders` /
17429
19223
  * `beginExternalLink` offer exactly the redirect methods that set this,
17430
- * whatever their id. Absent / false — a login button only (magic-link).
19224
+ * whatever their id. Absent / false — a login button only.
17431
19225
  */
17432
19226
  linkable: boolean().optional()
17433
19227
  }),
@@ -21282,8 +23076,7 @@ method(object({}), object({ rules: array(NcRuleSchema) }), { auth: "admin" }), m
21282
23076
  * `super_admin` — collapsed onto the single boolean because every
21283
23077
  * non-admin caller is governed by the same scope-check rules; the
21284
23078
  * distinction was only ever used to route role-specific procedures
21285
- * which we no longer have. Agents are admin sessions issued via
21286
- * `createServiceToken`; CLI / webhook integrations are `cst_*` tokens
23079
+ * which we no longer have. CLI / webhook integrations are `cst_*` tokens
21287
23080
  * with `isAdmin: false` + an explicit scope list.
21288
23081
  */
21289
23082
  /** Per-method access flavour. Materialised on every cap method via codegen. */
@@ -22785,8 +24578,23 @@ var RetrainMacroClassSchema = _enum([
22785
24578
  ]);
22786
24579
  /** A subject to learn, or a phantom to unlearn (taught by OMISSION). */
22787
24580
  var RetrainAnnotationKindSchema = _enum(["subject", "model_error"]);
22788
- /** Did a human draw this box, or did the assist propose it? */
22789
- var RetrainAnnotationSourceSchema = _enum(["operator", "assist"]);
24581
+ /**
24582
+ * Where a box came from. A machine-sourced box is a DRAFT on the page until
24583
+ * the operator confirms it; once saved it keeps its source as provenance.
24584
+ *
24585
+ * - `operator` — drawn by hand.
24586
+ * - `assist` — proposed by a detector run on the copy (the camera's own
24587
+ * model, or a larger teacher model).
24588
+ * - `pipeline` — the box the live pipeline actually drew on that frame, read
24589
+ * back from the track store (never a re-run).
24590
+ * - `llm` — proposed by a vision-capable LLM profile.
24591
+ */
24592
+ var RetrainAnnotationSourceSchema = _enum([
24593
+ "operator",
24594
+ "assist",
24595
+ "pipeline",
24596
+ "llm"
24597
+ ]);
22790
24598
  /** Normalised `[0,1]` rectangle against the FULL frame — the canonical form. */
22791
24599
  var RetrainBboxSchema = object({
22792
24600
  x: number(),
@@ -22804,7 +24612,8 @@ var RetrainBboxSchema = object({
22804
24612
  */
22805
24613
  var RetrainAnnotationSchema = object({
22806
24614
  id: string(),
22807
- trackId: string(),
24615
+ /** The frame's track. Absent on a recording still, which has none. */
24616
+ trackId: string().optional(),
22808
24617
  deviceId: number(),
22809
24618
  /** The COPY in retrain storage — never the source track's media key. */
22810
24619
  mediaKey: string(),
@@ -22853,13 +24662,47 @@ var RetrainFrameCandidateSchema = object({
22853
24662
  * fail, whatever became of the original. */
22854
24663
  copied: boolean()
22855
24664
  });
24665
+ /**
24666
+ * One box the live pipeline drew on a copied frame — what a correction starts
24667
+ * from. Derived when the frame is listed, from the track store: the subject
24668
+ * box recorded on the source media row when there is one, else the track
24669
+ * position nearest the frame's capture time. Never stored as an annotation
24670
+ * until the operator confirms it.
24671
+ */
24672
+ var RetrainPipelineBoxSchema = object({
24673
+ /** Normalised `[0,1]` against the full frame. */
24674
+ bbox: RetrainBboxSchema,
24675
+ macroClass: RetrainMacroClassSchema,
24676
+ label: string().optional(),
24677
+ subLabel: string().optional(),
24678
+ /** The detection score of the position used, when it was recorded. */
24679
+ score: number().optional(),
24680
+ /** The root model that produced the track, when it was recorded. */
24681
+ modelId: string().optional(),
24682
+ trackId: string(),
24683
+ /** `subject-box`: recorded on this very frame. `position`: the track's
24684
+ * position nearest the capture time, `deltaMs` away. */
24685
+ basis: _enum(["subject-box", "position"]),
24686
+ deltaMs: number()
24687
+ });
24688
+ /**
24689
+ * Where a retrain frame came from: a TRACK's stored media (copy-on-select),
24690
+ * or the RECORDING at an instant — the frame a model saw nothing in has no
24691
+ * track at all.
24692
+ */
24693
+ var RetrainFrameOriginSchema = _enum(["track", "recording"]);
22856
24694
  /** A frame the dataset OWNS: bytes copied at selection time. */
22857
24695
  var RetrainFrameSchema = object({
22858
24696
  frameId: string(),
22859
24697
  deviceId: number(),
22860
- trackId: string(),
22861
- /** Provenance only. It may already point at nothing — that is expected. */
22862
- sourceMediaId: number().int(),
24698
+ origin: RetrainFrameOriginSchema,
24699
+ /** The track it was copied from. Absent on a recording still. */
24700
+ trackId: string().optional(),
24701
+ /** Provenance only. It may already point at nothing — that is expected.
24702
+ * Absent on a recording still. */
24703
+ sourceMediaId: number().int().optional(),
24704
+ /** A recording still: the playhead instant it was taken at. */
24705
+ epochMs: number().optional(),
22863
24706
  sourceKind: MediaFileKindEnum,
22864
24707
  sizeBytes: number().int(),
22865
24708
  width: number().int(),
@@ -22870,7 +24713,12 @@ var RetrainFrameSchema = object({
22870
24713
  /** The operator's "every subject in this frame is boxed". Detector
22871
24714
  * evaluation keeps only complete frames: an unboxed subject would count as
22872
24715
  * a false positive. */
22873
- complete: boolean()
24716
+ complete: boolean(),
24717
+ /** The boxes the pipeline drew on this frame. Present on list answers;
24718
+ * empty when nothing the track store holds can be placed on it. */
24719
+ pipelineBoxes: array(RetrainPipelineBoxSchema).readonly().optional(),
24720
+ /** The named collections this frame belongs to. Present on list answers. */
24721
+ collectionIds: array(string()).readonly().optional()
22874
24722
  });
22875
24723
  /** Why a copy-on-select could not be honoured — named, never a silent skip. */
22876
24724
  var RetrainCopyRefusalSchema = _enum([
@@ -22901,6 +24749,11 @@ var RetrainFrameListSchema = object({
22901
24749
  var RetrainExportFilterSchema = object({
22902
24750
  deviceIds: array(number()).optional(),
22903
24751
  frameIds: array(string()).max(2e4).optional(),
24752
+ /** Only frames in at least one of these named collections. */
24753
+ collectionIds: array(string()).max(200).optional(),
24754
+ /** Exactly the frames of this dataset version (and its completeOnly). An
24755
+ * unknown id selects nothing. */
24756
+ datasetVersionId: string().optional(),
22904
24757
  batchId: string().optional(),
22905
24758
  /** Only frames the operator marked complete (all subjects boxed). */
22906
24759
  completeOnly: boolean().optional()
@@ -22965,6 +24818,170 @@ var RetrainAssistResultSchema = discriminatedUnion("kind", [object({
22965
24818
  reason: string(),
22966
24819
  detail: string().optional()
22967
24820
  })]);
24821
+ /** A named set over the retrain corpus — membership only, it owns no pixels. */
24822
+ var RetrainCollectionSchema = object({
24823
+ id: string(),
24824
+ name: string(),
24825
+ createdAt: number(),
24826
+ frameCount: number().int()
24827
+ });
24828
+ var RetrainCollectionCreateResultSchema = discriminatedUnion("kind", [object({
24829
+ kind: literal("created"),
24830
+ collection: RetrainCollectionSchema
24831
+ }), object({
24832
+ kind: literal("refused"),
24833
+ reason: _enum(["empty-name", "duplicate-name"])
24834
+ })]);
24835
+ var RetrainCollectionRenameResultSchema = discriminatedUnion("kind", [object({
24836
+ kind: literal("renamed"),
24837
+ collection: RetrainCollectionSchema
24838
+ }), object({
24839
+ kind: literal("refused"),
24840
+ reason: _enum([
24841
+ "empty-name",
24842
+ "duplicate-name",
24843
+ "unknown-collection"
24844
+ ])
24845
+ })]);
24846
+ /**
24847
+ * The outcome of adding the frame at a recording instant. Every refusal is
24848
+ * named: `still-unavailable` (not recording, a gap, or an undecodable frame —
24849
+ * `detail` says which), `still-busy` (the recorder is at its decode bound; try
24850
+ * again), `unreadable-image`, `write-failed`, `unknown-collection`.
24851
+ */
24852
+ var AddRetrainFrameFromRecordingResultSchema = discriminatedUnion("kind", [object({
24853
+ kind: literal("added"),
24854
+ collectionId: string(),
24855
+ frame: RetrainFrameSchema,
24856
+ /** The moment was already in the dataset; nothing was decoded. */
24857
+ reused: boolean()
24858
+ }), object({
24859
+ kind: literal("refused"),
24860
+ reason: _enum([
24861
+ "unknown-collection",
24862
+ "still-unavailable",
24863
+ "still-busy",
24864
+ "unreadable-image",
24865
+ "write-failed"
24866
+ ]),
24867
+ detail: string().optional()
24868
+ })]);
24869
+ /** A vision LLM profile the AI assist may use, and where it sends the frame. */
24870
+ var RetrainAssistProfileSchema = object({
24871
+ id: string(),
24872
+ name: string(),
24873
+ model: string(),
24874
+ kind: string(),
24875
+ /** `true` when the frame would leave the house (a cloud vendor, or an
24876
+ * endpoint that is not on the local network). The page confirms each such
24877
+ * run, and the provider refuses one without `allowCloud`. */
24878
+ leavesHouse: boolean()
24879
+ });
24880
+ /** A box the AI assist proposed: a draft, plus the model's own reason. */
24881
+ var RetrainLlmProposalSchema = RetrainAnnotationDraftSchema.extend({ reason: string() });
24882
+ /** What the AI assist said about a box that was already on the canvas. */
24883
+ var RetrainLlmReviewSchema = object({
24884
+ /** The `ref` the page sent the box under. */
24885
+ ref: string(),
24886
+ verdict: _enum([
24887
+ "confirmed",
24888
+ "wrong-class",
24889
+ "not-an-object",
24890
+ "uncertain"
24891
+ ]),
24892
+ suggestedClass: RetrainMacroClassSchema.optional(),
24893
+ reason: string()
24894
+ });
24895
+ /**
24896
+ * The AI assist's answer. `proposed` carries drafts (`source: 'llm'`, the
24897
+ * model and its confidence) and reviews; items the model got wrong (a box off
24898
+ * the frame, an unasked class, an unknown ref) are dropped and counted in
24899
+ * `rejected`. A whole answer that is not the schema is `malformed-answer`.
24900
+ */
24901
+ var RetrainLlmAssistResultSchema = discriminatedUnion("kind", [object({
24902
+ kind: literal("proposed"),
24903
+ profileId: string(),
24904
+ model: string(),
24905
+ /** The frame was sent outside the house for this answer. */
24906
+ leftHouse: boolean(),
24907
+ proposals: array(RetrainLlmProposalSchema).readonly(),
24908
+ reviews: array(RetrainLlmReviewSchema).readonly(),
24909
+ rejected: number().int()
24910
+ }), object({
24911
+ kind: literal("refused"),
24912
+ reason: _enum([
24913
+ "unknown-frame",
24914
+ "unreadable-frame",
24915
+ "unknown-profile",
24916
+ "profile-disabled",
24917
+ "no-vision",
24918
+ "cloud-not-confirmed",
24919
+ "llm-error",
24920
+ "malformed-answer"
24921
+ ]),
24922
+ detail: string().optional()
24923
+ })]);
24924
+ /** What a dataset version is cut from. Every field narrows. */
24925
+ var RetrainDatasetSelectionSchema = object({
24926
+ deviceIds: array(number()).readonly().optional(),
24927
+ collectionIds: array(string()).max(200).readonly().optional(),
24928
+ frameIds: array(string()).max(2e4).readonly().optional()
24929
+ });
24930
+ /** The counts a dataset is judged by. */
24931
+ var RetrainDatasetStatsSchema = object({
24932
+ frames: number().int(),
24933
+ completeFrames: number().int(),
24934
+ /** `completeFrames / frames`, 0..1. */
24935
+ completeness: number(),
24936
+ /** Boxes to learn (model errors excluded). */
24937
+ subjects: number().int(),
24938
+ modelErrors: number().int(),
24939
+ /** Complete frames with no subject. */
24940
+ hardNegatives: number().int(),
24941
+ /** Subjects per class × camera × day/night. */
24942
+ cells: array(object({
24943
+ macroClass: string(),
24944
+ deviceId: number(),
24945
+ lighting: _enum([
24946
+ "day",
24947
+ "night",
24948
+ "unknown"
24949
+ ]),
24950
+ subjects: number().int(),
24951
+ frames: number().int()
24952
+ })).readonly(),
24953
+ cameras: array(object({
24954
+ deviceId: number(),
24955
+ frames: number().int(),
24956
+ completeFrames: number().int()
24957
+ })).readonly()
24958
+ });
24959
+ /** An immutable dataset version, without its frame list. */
24960
+ var RetrainDatasetVersionSchema = object({
24961
+ id: string(),
24962
+ name: string(),
24963
+ createdAt: number(),
24964
+ selection: RetrainDatasetSelectionSchema,
24965
+ layout: RetrainExportLayoutSchema,
24966
+ completeOnly: boolean(),
24967
+ frameCount: number().int(),
24968
+ /** sha256 of what the frames taught when the version was frozen. */
24969
+ annotationHash: string(),
24970
+ /** The export manifest schema the version was cut under. */
24971
+ manifestSchema: string(),
24972
+ stats: RetrainDatasetStatsSchema
24973
+ });
24974
+ var CreateRetrainDatasetVersionResultSchema = discriminatedUnion("kind", [object({
24975
+ kind: literal("created"),
24976
+ version: RetrainDatasetVersionSchema
24977
+ }), object({
24978
+ kind: literal("refused"),
24979
+ reason: _enum([
24980
+ "empty-name",
24981
+ "duplicate-name",
24982
+ "no-frames"
24983
+ ])
24984
+ })]);
22968
24985
  /** The outcome of a lifecycle move owned by the retrain page. */
22969
24986
  var RetrainTransitionResultSchema = object({
22970
24987
  trackId: string(),
@@ -23682,7 +25699,7 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
23682
25699
  auth: "admin"
23683
25700
  }), method(object({
23684
25701
  deviceId: number(),
23685
- trackId: string(),
25702
+ trackId: string().optional(),
23686
25703
  frameId: string()
23687
25704
  }), object({
23688
25705
  removed: boolean(),
@@ -23699,7 +25716,8 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
23699
25716
  auth: "admin"
23700
25717
  }), method(object({
23701
25718
  deviceId: number(),
23702
- trackId: string(),
25719
+ /** The frame's track, when it has one — checked against the frame. */
25720
+ trackId: string().optional(),
23703
25721
  frameId: string(),
23704
25722
  subject: RetrainAssistSubjectSchema,
23705
25723
  /** Which node runs it. Absent ⇒ wherever an unowned call lands. */
@@ -23707,12 +25725,16 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
23707
25725
  }), RetrainAssistResultSchema, {
23708
25726
  kind: "mutation",
23709
25727
  auth: "admin"
23710
- }), method(object({ trackId: string() }), array(RetrainAnnotationSchema).readonly(), {
25728
+ }), method(object({
25729
+ trackId: string().optional(),
25730
+ frameIds: array(string()).max(2e3).optional()
25731
+ }), array(RetrainAnnotationSchema).readonly(), {
23711
25732
  kind: "query",
23712
25733
  auth: "admin"
23713
25734
  }), method(object({
23714
25735
  deviceId: number(),
23715
- trackId: string(),
25736
+ /** The frame's track, when it has one — checked against the frame. */
25737
+ trackId: string().optional(),
23716
25738
  frameId: string(),
23717
25739
  annotations: array(RetrainAnnotationDraftSchema)
23718
25740
  }), array(RetrainAnnotationSchema).readonly(), {
@@ -23735,7 +25757,7 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
23735
25757
  auth: "admin"
23736
25758
  }), method(object({
23737
25759
  deviceId: number(),
23738
- trackId: string(),
25760
+ trackId: string().optional(),
23739
25761
  frameId: string(),
23740
25762
  complete: boolean()
23741
25763
  }), RetrainFrameSchema, {
@@ -23749,6 +25771,115 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
23749
25771
  kind: "mutation",
23750
25772
  auth: "admin",
23751
25773
  timeoutMs: 60 * 6e4
25774
+ }), method(object({
25775
+ filter: RetrainExportFilterSchema,
25776
+ layout: RetrainExportLayoutSchema
25777
+ }), object({
25778
+ ticket: PeerBytesTicketSchema,
25779
+ frames: number().int(),
25780
+ annotations: number().int()
25781
+ }), {
25782
+ kind: "mutation",
25783
+ auth: "admin",
25784
+ timeoutMs: 12e4
25785
+ }), method(object({
25786
+ selection: RetrainDatasetSelectionSchema,
25787
+ completeOnly: boolean().optional()
25788
+ }), RetrainDatasetStatsSchema, {
25789
+ kind: "query",
25790
+ auth: "admin"
25791
+ }), method(object({
25792
+ name: string().max(120),
25793
+ selection: RetrainDatasetSelectionSchema,
25794
+ layout: RetrainExportLayoutSchema,
25795
+ completeOnly: boolean()
25796
+ }), CreateRetrainDatasetVersionResultSchema, {
25797
+ kind: "mutation",
25798
+ auth: "admin",
25799
+ timeoutMs: 12e4
25800
+ }), method(object({}), array(RetrainDatasetVersionSchema).readonly(), {
25801
+ kind: "query",
25802
+ auth: "admin"
25803
+ }), method(object({ id: string() }), object({ deleted: boolean() }), {
25804
+ kind: "mutation",
25805
+ auth: "admin"
25806
+ }), method(object({ id: string() }), object({
25807
+ found: boolean(),
25808
+ annotationHash: string(),
25809
+ matches: boolean(),
25810
+ missingFrames: number().int()
25811
+ }), {
25812
+ kind: "query",
25813
+ auth: "admin",
25814
+ timeoutMs: 12e4
25815
+ }), method(object({}), array(RetrainAssistProfileSchema).readonly(), {
25816
+ kind: "query",
25817
+ auth: "admin"
25818
+ }), method(object({
25819
+ deviceId: number(),
25820
+ trackId: string().optional(),
25821
+ frameId: string(),
25822
+ profileId: string(),
25823
+ classes: array(RetrainMacroClassSchema).min(1),
25824
+ boxes: array(object({
25825
+ ref: string(),
25826
+ bbox: RetrainBboxSchema,
25827
+ macroClass: RetrainMacroClassSchema,
25828
+ label: string().optional()
25829
+ })).max(50),
25830
+ allowCloud: boolean()
25831
+ }), RetrainLlmAssistResultSchema, {
25832
+ kind: "mutation",
25833
+ auth: "admin",
25834
+ timeoutMs: 18e4
25835
+ }), method(object({ name: string().max(120) }), RetrainCollectionCreateResultSchema, {
25836
+ kind: "mutation",
25837
+ auth: "admin"
25838
+ }), method(object({}), array(RetrainCollectionSchema).readonly(), {
25839
+ kind: "query",
25840
+ auth: "admin"
25841
+ }), method(object({
25842
+ id: string(),
25843
+ name: string().max(120)
25844
+ }), RetrainCollectionRenameResultSchema, {
25845
+ kind: "mutation",
25846
+ auth: "admin"
25847
+ }), method(object({ id: string() }), object({
25848
+ deleted: boolean(),
25849
+ removedFrames: number().int()
25850
+ }), {
25851
+ kind: "mutation",
25852
+ auth: "admin"
25853
+ }), method(object({
25854
+ collectionId: string(),
25855
+ deviceId: number(),
25856
+ epochMs: number()
25857
+ }), AddRetrainFrameFromRecordingResultSchema, {
25858
+ kind: "mutation",
25859
+ auth: "admin",
25860
+ timeoutMs: 6e4
25861
+ }), method(object({
25862
+ collectionId: string(),
25863
+ frameIds: array(string()).min(1).max(500)
25864
+ }), object({
25865
+ added: number().int(),
25866
+ alreadyMember: number().int(),
25867
+ unknownFrameIds: array(string()).readonly()
25868
+ }), {
25869
+ kind: "mutation",
25870
+ auth: "admin"
25871
+ }), method(object({
25872
+ collectionId: string(),
25873
+ frameId: string()
25874
+ }), object({
25875
+ removed: boolean(),
25876
+ deletedFrame: boolean()
25877
+ }), {
25878
+ kind: "mutation",
25879
+ auth: "admin"
25880
+ }), method(object({ collectionId: string() }), array(RetrainFrameSchema).readonly(), {
25881
+ kind: "query",
25882
+ auth: "admin"
23752
25883
  }), method(object({
23753
25884
  /** Which of the three event tables owns the row. */
23754
25885
  ownerType: EventOwnerTypeSchema,
@@ -24372,13 +26503,31 @@ var RecommendationReasonSchema = discriminatedUnion("kind", [
24372
26503
  object({
24373
26504
  kind: literal("no-family-build"),
24374
26505
  format: ModelFormatSchema$1
26506
+ }),
26507
+ object({
26508
+ kind: literal("kept-custom-pin"),
26509
+ modelId: string(),
26510
+ deviceKey: string()
24375
26511
  })
24376
26512
  ]);
26513
+ /** Why a device is left exactly as it is, whatever the plan would pick (D786). */
26514
+ var KeptReasonSchema = _enum(["custom-pin"]);
26515
+ /**
26516
+ * Where a choice's latency came from (D791): this node's own benchmark
26517
+ * result, or the hardware-class table. Measured on the node beats the table.
26518
+ */
26519
+ var LatencySourceSchema = discriminatedUnion("kind", [object({ kind: literal("table") }), object({
26520
+ kind: literal("node-benchmark"),
26521
+ resultId: string(),
26522
+ measuredAtMs: number()
26523
+ })]);
24377
26524
  var DeviceModelChoiceSchema = object({
24378
26525
  modelId: string(),
24379
26526
  p50Ms: number(),
24380
26527
  fps: number(),
24381
26528
  measured: boolean(),
26529
+ /** Absent on a plan from before D791 — read as the table. */
26530
+ source: LatencySourceSchema.optional(),
24382
26531
  /** Parallel sessions at the camera rate with the headroom kept free: ⌊fps × (1 − headroom) / camera fps⌋. */
24383
26532
  capacitySessions: number(),
24384
26533
  personRecall: number()
@@ -24389,6 +26538,8 @@ var DeviceRecommendationSchema = object({
24389
26538
  enabled: boolean(),
24390
26539
  available: boolean(),
24391
26540
  chosen: DeviceModelChoiceSchema.nullable(),
26541
+ /** Present when the device is kept as is: Apply writes nothing on it. */
26542
+ kept: KeptReasonSchema.optional(),
24392
26543
  reasons: array(RecommendationReasonSchema).readonly()
24393
26544
  });
24394
26545
  var NodeRecommendationSchema = object({
@@ -24442,6 +26593,17 @@ var AutoTuneWarningSchema = discriminatedUnion("kind", [
24442
26593
  kind: literal("coral-enabled"),
24443
26594
  nodeId: string(),
24444
26595
  deviceKey: string()
26596
+ }),
26597
+ object({
26598
+ kind: literal("custom-pin-kept"),
26599
+ nodeId: string(),
26600
+ deviceKey: string().nullable(),
26601
+ deviceId: number().nullable(),
26602
+ modelId: string()
26603
+ }),
26604
+ object({
26605
+ kind: literal("custom-registry-unreadable"),
26606
+ error: string()
24445
26607
  })
24446
26608
  ]);
24447
26609
  var AutoTuneOptionsSchema = object({
@@ -24620,13 +26782,14 @@ var SuggestSharesResultSchema = object({
24620
26782
  nodes: array(SuggestedNodeShareSchema).readonly()
24621
26783
  });
24622
26784
  /**
24623
- * Where the node and device shares come from (D750, D755).
24624
- * - `hardware` (default) — computed by the system from each node's static
24625
- * capacity (its accelerators at their Auto tune models, from the measured
24626
- * latency table), recomputed whenever a node or device joins, leaves, is
24627
- * switched on or off, or changes model. No load input.
24628
- * - `benchmark` — the same, from each node's measured capacity (node
24629
- * benchmark results); a node without results falls back to `hardware`.
26785
+ * Where the node and device shares come from (D750, D755, D791).
26786
+ * - `benchmark` (default since D791) — each node's capacity as its own node
26787
+ * benchmark measured it; a node without fresh results is sized from
26788
+ * `hardware` and says so. Measured on the node beats the table.
26789
+ * - `hardware` — computed from each node's static capacity only (its
26790
+ * accelerators at their Auto tune models, from the latency table).
26791
+ * Both are recomputed whenever a node or device joins, leaves, is switched
26792
+ * on or off, changes model, or a benchmark result is written. No load input.
24630
26793
  * - `manual` — the operator's stored sliders.
24631
26794
  * Either way a node or device that cannot take sessions gives its share to
24632
26795
  * the others in proportion; the stored values are never rewritten for that.
@@ -24675,6 +26838,362 @@ var EffectiveSharesSchema = object({
24675
26838
  nodeWeights: record(string(), number()),
24676
26839
  deviceWeights: record(string(), record(string(), number()))
24677
26840
  });
26841
+ /**
26842
+ * Wire shapes of the node benchmark (D791): the operator's plan, the
26843
+ * preflight the confirmation shows, the run the orchestrator owns, what the
26844
+ * measuring runner reports, and the result rows Auto tune and the automatic
26845
+ * shares read.
26846
+ *
26847
+ * ONE node at a time, owned by the pipeline orchestrator. While a run is
26848
+ * active the cluster is in BENCHMARK MODE for that node: it is not a
26849
+ * detection candidate, camera pins naming it are ignored so its sessions move
26850
+ * elsewhere, and both come back when the mode ends — after a crash or a hub
26851
+ * restart too (a persisted manifest, reconciled against the registry).
26852
+ *
26853
+ * Two measurements, both on the node, driven by its own runner (frames never
26854
+ * cross a process at frame rate, D9):
26855
+ * - `device` — one accelerator × one candidate detector, root only, open
26856
+ * loop: how many streams at the camera rate it carries inside the frame
26857
+ * interval;
26858
+ * - `pipeline` — the chosen detector plus the operator's detail steps
26859
+ * (faces, plates, classifiers, CLIP…), on varied frames from the bench
26860
+ * clip: how many parallel sessions the node carries before latency, drops,
26861
+ * CPU, RAM or the event loop give out.
26862
+ */
26863
+ /** Defaults and bounds, one place. */
26864
+ var NODE_BENCHMARK_DEFAULTS = {
26865
+ fpsPerStream: 10,
26866
+ budgetMinutes: 45,
26867
+ minBudgetMinutes: 10,
26868
+ maxBudgetMinutes: 120,
26869
+ /** A result older than this no longer beats the table. */
26870
+ staleAfterDays: 30,
26871
+ /** Warm-in per ramp step (not accounted). */
26872
+ settleSec: 5,
26873
+ /** Accounted window per ramp step. */
26874
+ measureSec: 20,
26875
+ /** Longest the drain may take before the run is refused. */
26876
+ drainTimeoutSec: 120,
26877
+ /** Candidate models per device in one run. */
26878
+ maxModelsPerDevice: 6
26879
+ };
26880
+ /** The two measurements a run can make. */
26881
+ var NodeBenchmarkPhaseSchema = _enum(["device", "pipeline"]);
26882
+ var NodeBenchmarkDevicePlanSchema = object({
26883
+ /** `<backend>:<device>` — `openvino:npu`, `coreml:all`, `cpu`. */
26884
+ deviceKey: string().min(1),
26885
+ /**
26886
+ * Root detector candidates for the `device` measurement, in the order
26887
+ * measured. The FIRST is the one the `pipeline` measurement runs.
26888
+ */
26889
+ modelIds: array(string().min(1)).min(1).max(NODE_BENCHMARK_DEFAULTS.maxModelsPerDevice)
26890
+ });
26891
+ /** What the operator confirmed. */
26892
+ var NodeBenchmarkPlanSchema = object({
26893
+ nodeId: string().min(1),
26894
+ devices: array(NodeBenchmarkDevicePlanSchema).min(1),
26895
+ /** Which measurements run. At least one. */
26896
+ phases: array(NodeBenchmarkPhaseSchema).min(1).default(["device", "pipeline"]),
26897
+ /**
26898
+ * Detail steps (catalog step ids under the root: faces, plates,
26899
+ * classifiers, CLIP…) the `pipeline` measurement enables. The root
26900
+ * detector always runs.
26901
+ */
26902
+ steps: array(string().min(1)).default([]),
26903
+ /** Offered rate of one stream / session. */
26904
+ fpsPerStream: number().int().min(1).max(30).default(NODE_BENCHMARK_DEFAULTS.fpsPerStream),
26905
+ /** Hard deadline: the mode ends and the cluster is restored when it passes. */
26906
+ budgetMinutes: number().int().min(NODE_BENCHMARK_DEFAULTS.minBudgetMinutes).max(NODE_BENCHMARK_DEFAULTS.maxBudgetMinutes).default(NODE_BENCHMARK_DEFAULTS.budgetMinutes),
26907
+ /** Keep the models the run downloaded (default: delete what was not installed before). */
26908
+ keepDownloadedModels: boolean().default(false),
26909
+ /** Start although the other nodes' capacity does not cover the sessions running now. */
26910
+ acceptInsufficientHeadroom: boolean().default(false)
26911
+ });
26912
+ var NodeBenchmarkRefusalSchema = object({
26913
+ kind: _enum([
26914
+ "benchmark-active",
26915
+ "node-offline",
26916
+ "unknown-device",
26917
+ "no-phase",
26918
+ "insufficient-headroom"
26919
+ ]),
26920
+ detail: string(),
26921
+ overridable: boolean()
26922
+ });
26923
+ /** A camera whose detection leaves the node for the run. */
26924
+ var NodeBenchmarkMovingCameraSchema = object({
26925
+ deviceId: number(),
26926
+ /** Placed on the node now (a standing attach or a running session). */
26927
+ placedOnNode: boolean(),
26928
+ /** A node pin naming this node, ignored for the run. */
26929
+ pinnedToNode: boolean()
26930
+ });
26931
+ /** A camera that cannot leave: no other node can obtain its frames. */
26932
+ var NodeBenchmarkStayingCameraSchema = object({
26933
+ deviceId: number(),
26934
+ reason: literal("only-frame-source")
26935
+ });
26936
+ var NodeBenchmarkPreflightSchema = object({
26937
+ nodeId: string(),
26938
+ online: boolean(),
26939
+ moving: array(NodeBenchmarkMovingCameraSchema).readonly(),
26940
+ /** Keep running on the node during the run; the result is flagged contaminated. */
26941
+ staying: array(NodeBenchmarkStayingCameraSchema).readonly(),
26942
+ estimatedDurationMs: number(),
26943
+ /** The run ends and the cluster is restored at the latest after this long. */
26944
+ budgetMs: number(),
26945
+ phases: array(NodeBenchmarkPhaseSchema).readonly(),
26946
+ steps: array(string()).readonly(),
26947
+ devices: array(NodeBenchmarkDevicePlanSchema).readonly(),
26948
+ /** Parallel sessions the cluster runs now, and what the other nodes can carry. */
26949
+ headroom: object({
26950
+ sessionsNow: number(),
26951
+ otherNodesCapacitySessions: number().nullable()
26952
+ }),
26953
+ refusals: array(NodeBenchmarkRefusalSchema).readonly(),
26954
+ canStart: boolean()
26955
+ });
26956
+ /** Where the measuring runner is. */
26957
+ var NodeBenchProgressSchema = object({
26958
+ phase: _enum([
26959
+ "preparing",
26960
+ "device",
26961
+ "pipeline",
26962
+ "cleanup"
26963
+ ]),
26964
+ deviceKey: string().nullable(),
26965
+ modelId: string().nullable(),
26966
+ /** Streams (device) or sessions (pipeline) of the step running now. */
26967
+ load: number().nullable(),
26968
+ cellsDone: number(),
26969
+ cellsTotal: number(),
26970
+ message: string()
26971
+ });
26972
+ /** What limited a ramp. `none` = the ramp ran out of steps still passing. */
26973
+ var NodeBenchLimitSchema = _enum([
26974
+ "p95",
26975
+ "drops",
26976
+ "errors",
26977
+ "stall",
26978
+ "cpu",
26979
+ "ram",
26980
+ "none"
26981
+ ]);
26982
+ var NodeBenchRampStepSchema = object({
26983
+ load: number(),
26984
+ pass: boolean(),
26985
+ p95Ms: number(),
26986
+ dropRatio: number(),
26987
+ /** Completed frames per second over the accounted window. */
26988
+ fps: number(),
26989
+ cpuPct: number().nullable(),
26990
+ ramFreePct: number().nullable(),
26991
+ failReasons: array(string()).readonly()
26992
+ });
26993
+ var NodeBenchCellSchema = discriminatedUnion("phase", [object({
26994
+ phase: literal("device"),
26995
+ deviceKey: string(),
26996
+ modelId: string(),
26997
+ /** Single-stream latency (the K = 1 step). */
26998
+ p50Ms: number(),
26999
+ p95Ms: number(),
27000
+ p99Ms: number(),
27001
+ /** Frames per second sustained at the last passing step. */
27002
+ fps: number(),
27003
+ /** Streams at the camera rate the device carried inside the frame interval; 0 = not even one. */
27004
+ kMax: number(),
27005
+ limitedBy: NodeBenchLimitSchema,
27006
+ /** First call (model load + warm-up). */
27007
+ warmupMs: number(),
27008
+ ramp: array(NodeBenchRampStepSchema).readonly()
27009
+ }), object({
27010
+ phase: literal("pipeline"),
27011
+ deviceKey: string(),
27012
+ modelId: string(),
27013
+ steps: array(string()).readonly(),
27014
+ /** Parallel sessions at the camera rate the node carried; 0 = not even one. */
27015
+ maxSessions: number(),
27016
+ limitedBy: NodeBenchLimitSchema,
27017
+ /** Detail steps that produced at least one result on the clip — a step that never fired measured nothing. */
27018
+ stepsFired: array(string()).readonly(),
27019
+ warmupMs: number(),
27020
+ ramp: array(NodeBenchRampStepSchema).readonly()
27021
+ })]);
27022
+ /**
27023
+ * What a result was measured ON. A result whose fingerprint no longer matches
27024
+ * the node no longer beats the table.
27025
+ */
27026
+ var NodeBenchFingerprintSchema = object({
27027
+ pipelineVersion: string().nullable(),
27028
+ cpuModel: string().nullable(),
27029
+ ramGb: number().nullable(),
27030
+ os: string().nullable(),
27031
+ /** Per device: the pool the cells ran on (runtime + tuning). */
27032
+ pools: record(string(), object({
27033
+ runtime: string(),
27034
+ numWorkers: number(),
27035
+ concurrency: number(),
27036
+ batchMode: string()
27037
+ })).default({})
27038
+ });
27039
+ /** The frames the run used. */
27040
+ var NodeBenchClipSchema = object({
27041
+ /** `camstack-bench-v1` or `reference-images` (the fallback when the clip is not reachable). */
27042
+ id: string(),
27043
+ revision: string().nullable(),
27044
+ frames: number(),
27045
+ width: number(),
27046
+ height: number()
27047
+ });
27048
+ var NodeBenchRunnerInputSchema = object({
27049
+ runId: string().min(1),
27050
+ devices: array(NodeBenchmarkDevicePlanSchema).min(1),
27051
+ phases: array(NodeBenchmarkPhaseSchema).min(1),
27052
+ /** The full detail step tree root for the `pipeline` measurement is built on the node from these ids. */
27053
+ steps: array(string()).default([]),
27054
+ fpsPerStream: number().int().min(1).max(30),
27055
+ /** The runner stops on its own past this instant, whatever the hub does. */
27056
+ deadlineAtMs: number(),
27057
+ settleSec: number().min(0).max(60).default(NODE_BENCHMARK_DEFAULTS.settleSec),
27058
+ measureSec: number().min(2).max(300).default(NODE_BENCHMARK_DEFAULTS.measureSec),
27059
+ keepDownloadedModels: boolean().default(false)
27060
+ });
27061
+ var NodeBenchRunnerStateSchema = _enum([
27062
+ "running",
27063
+ "done",
27064
+ "failed",
27065
+ "aborted"
27066
+ ]);
27067
+ var NodeBenchRunnerStatusSchema = object({
27068
+ runId: string(),
27069
+ nodeId: string(),
27070
+ state: NodeBenchRunnerStateSchema,
27071
+ progress: NodeBenchProgressSchema.nullable(),
27072
+ /** Every finished cell so far — a run stopped half way keeps what it measured. */
27073
+ cells: array(NodeBenchCellSchema).readonly(),
27074
+ fingerprint: NodeBenchFingerprintSchema.nullable(),
27075
+ clip: NodeBenchClipSchema.nullable(),
27076
+ /** Cameras seen running on the node during the run (they share its pools). */
27077
+ activeCameraIds: array(number()).readonly(),
27078
+ /** Models the run downloaded and then deleted (not installed before). */
27079
+ deletedModels: array(string()).readonly(),
27080
+ error: string().nullable(),
27081
+ startedAtMs: number(),
27082
+ finishedAtMs: number().nullable()
27083
+ });
27084
+ var NodeBenchmarkStateSchema = _enum([
27085
+ "draining",
27086
+ "measuring",
27087
+ "restoring",
27088
+ "done",
27089
+ "failed",
27090
+ "aborted"
27091
+ ]);
27092
+ /** Why a run ended. */
27093
+ var NodeBenchmarkEndReasonSchema = _enum([
27094
+ "completed",
27095
+ "operator-abort",
27096
+ "deadline",
27097
+ "node-lost",
27098
+ "runner-lost",
27099
+ "hub-restart",
27100
+ "drain-timeout",
27101
+ "failed"
27102
+ ]);
27103
+ var NodeBenchmarkRunSchema = object({
27104
+ runId: string(),
27105
+ nodeId: string(),
27106
+ state: NodeBenchmarkStateSchema,
27107
+ plan: NodeBenchmarkPlanSchema,
27108
+ startedAtMs: number(),
27109
+ deadlineAtMs: number(),
27110
+ finishedAtMs: number().nullable(),
27111
+ endReason: NodeBenchmarkEndReasonSchema.nullable(),
27112
+ error: string().nullable(),
27113
+ /** Cameras moved off the node for the run. */
27114
+ moved: array(number()).readonly(),
27115
+ /** Cameras that stayed (their only frame source is the node). */
27116
+ staying: array(number()).readonly(),
27117
+ /** Something else ran on the node's pools during the run. */
27118
+ contaminated: boolean(),
27119
+ progress: NodeBenchProgressSchema.nullable(),
27120
+ resultIds: array(string()).readonly()
27121
+ });
27122
+ /** `getNodeBenchmarkStatus`: the active run (or the last one), and whether benchmark mode is on. */
27123
+ var NodeBenchmarkStatusSchema = object({
27124
+ /** The node the cluster is in benchmark mode for; null = none. */
27125
+ modeNodeId: string().nullable(),
27126
+ run: NodeBenchmarkRunSchema.nullable()
27127
+ });
27128
+ /**
27129
+ * One stored measurement — the only authority Auto tune and the automatic
27130
+ * shares read measured capacity from. Written by the orchestrator when a run
27131
+ * ends, never by anyone else.
27132
+ */
27133
+ var NodeBenchmarkResultSchema = object({
27134
+ id: string(),
27135
+ runId: string(),
27136
+ nodeId: string(),
27137
+ cell: NodeBenchCellSchema,
27138
+ fpsPerStream: number(),
27139
+ fingerprint: NodeBenchFingerprintSchema.nullable(),
27140
+ clip: NodeBenchClipSchema.nullable(),
27141
+ /** Other work shared the node's pools (a camera that could not move, or the hub's own duties). */
27142
+ contaminated: boolean(),
27143
+ stayingCameras: array(number()).readonly(),
27144
+ /** The run ended early; the cell itself completed. */
27145
+ partialRun: boolean(),
27146
+ measuredAtMs: number()
27147
+ });
27148
+ var ListNodeBenchmarkResultsInputSchema = object({
27149
+ nodeId: string().optional(),
27150
+ deviceKey: string().optional()
27151
+ });
27152
+ /** A result with its standing today: does it still beat the table? */
27153
+ var NodeBenchmarkResultViewSchema = NodeBenchmarkResultSchema.extend({
27154
+ /** `fresh` beats the table; `stale` falls back to it; `superseded` = a newer row covers the same cell. */
27155
+ standing: _enum([
27156
+ "fresh",
27157
+ "stale",
27158
+ "superseded"
27159
+ ]),
27160
+ staleWhy: _enum([
27161
+ "age",
27162
+ "runtime",
27163
+ "pool-tuning"
27164
+ ]).nullable()
27165
+ });
27166
+ object({
27167
+ runId: string(),
27168
+ nodeId: string(),
27169
+ startedAtMs: number(),
27170
+ deadlineAtMs: number(),
27171
+ plan: NodeBenchmarkPlanSchema,
27172
+ moved: array(number()).readonly(),
27173
+ staying: array(number()).readonly()
27174
+ });
27175
+ /** Candidate detectors per device, for the plan editor. */
27176
+ var NodeBenchmarkCandidatesSchema = object({
27177
+ nodeId: string(),
27178
+ reachable: boolean(),
27179
+ devices: array(object({
27180
+ deviceKey: string(),
27181
+ enabled: boolean(),
27182
+ available: boolean(),
27183
+ /** Ordered: what Auto tune would pick first, then the rest of the family by accuracy. */
27184
+ suggested: array(string()).readonly(),
27185
+ /** Every root detector the device has a build for. */
27186
+ all: array(string()).readonly(),
27187
+ /** The model the device runs now, when pinned. */
27188
+ currentModelId: string().nullable()
27189
+ })).readonly(),
27190
+ /** Detail steps the node's catalog offers under the root (for the `pipeline` measurement). */
27191
+ steps: array(object({
27192
+ id: string(),
27193
+ name: string(),
27194
+ slot: string()
27195
+ })).readonly()
27196
+ });
24678
27197
  object({
24679
27198
  activeCameras: number(),
24680
27199
  throttledCameras: number(),
@@ -25803,7 +28322,16 @@ method(RunnerCameraConfigSchema, object({ success: literal(true) }), { kind: "mu
25803
28322
  }), ParkedTrackFrameSchema.nullable()), method(object({
25804
28323
  deviceId: number(),
25805
28324
  trackId: string()
25806
- }), object({ released: number().int().nonnegative() }), { kind: "mutation" });
28325
+ }), object({ released: number().int().nonnegative() }), { kind: "mutation" }), method(NodeBenchRunnerInputSchema, object({
28326
+ accepted: literal(true),
28327
+ runId: string()
28328
+ }), {
28329
+ kind: "mutation",
28330
+ auth: "admin"
28331
+ }), method(object({ runId: string() }), NodeBenchRunnerStatusSchema.nullable(), { auth: "admin" }), method(object({ runId: string() }), object({ aborted: boolean() }), {
28332
+ kind: "mutation",
28333
+ auth: "admin"
28334
+ });
25807
28335
  var CameraPipelineConfigSchema = object({
25808
28336
  engine: PipelineEngineChoiceSchema.optional(),
25809
28337
  steps: array(PipelineStepInputSchema).readonly(),
@@ -26442,6 +28970,21 @@ method(object({
26442
28970
  }), method(PlacementStatsInputSchema, PlacementStatsSchema, { auth: "admin" }), method(SuggestSharesInputSchema, SuggestSharesResultSchema, { auth: "admin" }), method(_void(), EffectiveSharesSchema, { auth: "admin" }), method(SetShareSourceInputSchema, object({ success: literal(true) }), {
26443
28971
  kind: "mutation",
26444
28972
  auth: "admin"
28973
+ }), method(NodeBenchmarkPlanSchema, NodeBenchmarkPreflightSchema, { auth: "admin" }), method(NodeBenchmarkPlanSchema, discriminatedUnion("kind", [object({
28974
+ kind: literal("started"),
28975
+ runId: string()
28976
+ }), object({
28977
+ kind: literal("refused"),
28978
+ preflight: NodeBenchmarkPreflightSchema
28979
+ })]), {
28980
+ kind: "mutation",
28981
+ auth: "admin"
28982
+ }), method(_void(), NodeBenchmarkStatusSchema, { auth: "admin" }), method(object({ runId: string() }), object({ aborted: boolean() }), {
28983
+ kind: "mutation",
28984
+ auth: "admin"
28985
+ }), method(object({ nodeId: string() }), NodeBenchmarkCandidatesSchema, { auth: "admin" }), method(ListNodeBenchmarkResultsInputSchema, array(NodeBenchmarkResultViewSchema).readonly(), { auth: "admin" }), method(object({ id: string() }), object({ deleted: boolean() }), {
28986
+ kind: "mutation",
28987
+ auth: "admin"
26445
28988
  }), method(object({ deviceId: number() }), CameraPipelineSettingsSchema.nullable()), method(object({
26446
28989
  deviceId: number(),
26447
28990
  addonId: string(),
@@ -26847,8 +29390,8 @@ version: string().optional() }), ServerUpdateActionResultSchema, {
26847
29390
  * `smtp-provider` — pluggable email delivery surface.
26848
29391
  *
26849
29392
  * Collection cap: a deployment may install multiple SMTP relays (e.g.
26850
- * one for transactional / one for notifications). Consumers (magic-link,
26851
- * notifier addons, …) walk the collection and pick the first
29393
+ * one for transactional / one for notifications). Consumers (notifier
29394
+ * addons, …) walk the collection and pick the first
26852
29395
  * ready provider OR target a specific addonId.
26853
29396
  *
26854
29397
  * The shape stays small on purpose — `sendEmail` is enough for the
@@ -27131,7 +29674,7 @@ targets: array(object({
27131
29674
  };
27132
29675
  /**
27133
29676
  * `sso-bridge` — internal hub-only cap that lets SSO-style auth
27134
- * providers (OIDC, SAML, magic-link, …) mint an HMAC-signed token
29677
+ * providers (OIDC, SAML, …) mint an HMAC-signed token
27135
29678
  * carrying the post-callback claims before redirecting back to
27136
29679
  * `/api/auth/sso/finish`.
27137
29680
  *
@@ -27194,7 +29737,14 @@ var SsoBridgeClaimsSchema = object({
27194
29737
  * Verified `iss` of the id_token behind an OIDC login bridge (D782). A
27195
29738
  * subject is unique only per issuer, so a link is bound to it.
27196
29739
  */
27197
- issuer: string().optional()
29740
+ issuer: string().optional(),
29741
+ /**
29742
+ * SHA-256 (hex) of the `camstack_sso_state` cookie the IdP `/start` set in
29743
+ * the browser that began this sign-in. `/api/auth/sso/finish` requires the
29744
+ * request to present the matching cookie — a login bridge is useless in
29745
+ * any other browser.
29746
+ */
29747
+ browserBinding: string().optional()
27198
29748
  });
27199
29749
  method(object({
27200
29750
  claims: SsoBridgeClaimsSchema,
@@ -33071,6 +35621,9 @@ var CreateIntegrationInputSchema = object({
33071
35621
  enabled: boolean().optional(),
33072
35622
  info: record(string(), unknown()).optional(),
33073
35623
  settings: record(string(), unknown()).optional(),
35624
+ /** Keys of `settings` the form's schema declares secret (by type) — kept in
35625
+ * the keychain, not the table (D787). */
35626
+ secretKeys: array(string()).optional(),
33074
35627
  skipRestart: boolean().optional()
33075
35628
  });
33076
35629
  var UpdateIntegrationInputSchema = object({
@@ -33094,7 +35647,9 @@ method(_void(), array(IntegrationWithStateSchema)), method(object({ id: string()
33094
35647
  auth: "admin"
33095
35648
  }), method(object({ id: string() }), record(string(), unknown()), { auth: "admin" }), method(object({
33096
35649
  id: string(),
33097
- settings: record(string(), unknown())
35650
+ settings: record(string(), unknown()),
35651
+ /** Keys the form's schema declares secret (by type) — keychain-stored (D787). */
35652
+ secretKeys: array(string()).optional()
33098
35653
  }), object({ success: boolean() }), {
33099
35654
  kind: "mutation",
33100
35655
  auth: "admin"
@@ -40427,16 +42982,6 @@ var ApiKeySummarySchema = object({
40427
42982
  createdAt: number(),
40428
42983
  lastUsedAt: number().optional()
40429
42984
  });
40430
- var CreateApiKeyInputSchema = object({
40431
- label: string(),
40432
- isAdmin: boolean().default(false),
40433
- allowedProviders: union([array(string()), literal("*")]).optional(),
40434
- allowedDevices: record(string(), union([array(string()), literal("*")])).optional()
40435
- });
40436
- var CreateApiKeyResultSchema = object({
40437
- token: string(),
40438
- record: ApiKeySummarySchema
40439
- });
40440
42985
  var ScopedTokenSummarySchema = object({
40441
42986
  id: string(),
40442
42987
  userId: string(),
@@ -40535,17 +43080,10 @@ method(_void(), array(UserSummarySchema), { auth: "admin" }), method(CreateUserI
40535
43080
  }), UserSummarySchema.extend({ passwordHash: string() }).nullable(), {
40536
43081
  kind: "mutation",
40537
43082
  access: "view"
40538
- }), method(_void(), array(ApiKeySummarySchema), { auth: "admin" }), method(CreateApiKeyInputSchema, CreateApiKeyResultSchema, {
40539
- kind: "mutation",
40540
- auth: "admin",
40541
- access: "create"
40542
- }), method(object({ id: string() }), object({ success: literal(true) }), {
43083
+ }), method(_void(), array(ApiKeySummarySchema), { auth: "admin" }), method(object({ id: string() }), object({ success: literal(true) }), {
40543
43084
  kind: "mutation",
40544
43085
  auth: "admin",
40545
43086
  access: "delete"
40546
- }), method(object({ token: string() }), ApiKeySummarySchema.nullable(), {
40547
- kind: "mutation",
40548
- access: "view"
40549
43087
  }), method(CreateScopedTokenInputSchema, CreateScopedTokenResultSchema, {
40550
43088
  kind: "mutation",
40551
43089
  auth: "admin",
@@ -40619,15 +43157,7 @@ method(_void(), array(UserSummarySchema), { auth: "admin" }), method(CreateUserI
40619
43157
  }).nullable(), { access: "view" }), method(object({ userId: string() }), array(ExternalIdentitySchema), { auth: "admin" }), method(ExternalIdentityKeySchema, object({
40620
43158
  userId: string(),
40621
43159
  issuer: string()
40622
- }).nullable(), { auth: "admin" }), method(ExternalIdentityKeySchema.extend({
40623
- userId: string(),
40624
- issuer: string().min(1),
40625
- label: string().optional()
40626
- }), object({ success: literal(true) }), {
40627
- kind: "mutation",
40628
- auth: "admin",
40629
- access: "create"
40630
- }), method(ExternalIdentityKeySchema.extend({ userId: string() }), object({ success: boolean() }), {
43160
+ }).nullable(), { auth: "admin" }), method(ExternalIdentityKeySchema.extend({ userId: string() }), object({ success: boolean() }), {
40631
43161
  kind: "mutation",
40632
43162
  auth: "admin",
40633
43163
  access: "delete"
@@ -41332,6 +43862,451 @@ var zoneRulesCapability = {
41332
43862
  */
41333
43863
  durability: "restored"
41334
43864
  };
43865
+ /**
43866
+ * `training-provider` — ONE cloud that can run the CamStack trainer.
43867
+ *
43868
+ * A thin, mockable translation layer: it knows how to run a container with a
43869
+ * GPU, move a dataset in, read the job's stdout and hand artefacts back. It
43870
+ * knows nothing about datasets, splits, floors, cost policy or Model Studio —
43871
+ * those are the `training` orchestrator's (D805). Every rule written there
43872
+ * once is what makes a second provider (RunPod, a local NVIDIA node) a new
43873
+ * manifest entry and nothing else.
43874
+ *
43875
+ * Collection, routed by the `addonId` in every single-row input (the `llm` /
43876
+ * `notification-output` posture); `describe` concat-fans across providers.
43877
+ * Every method is `admin`: these spend money.
43878
+ *
43879
+ * Every cloud object a provider creates is tagged with the orchestrator's
43880
+ * `jobKey`, so a retried submit finds the job it already started instead of
43881
+ * starting a second GPU, and `listJobs` can find orphans.
43882
+ *
43883
+ * Bytes never ride a cap field: the dataset arrives as a `ctx.peerBytes`
43884
+ * ticket the producer (pipeline-analytics) minted, and artefacts leave as a
43885
+ * ticket the provider mints (D613).
43886
+ */
43887
+ var TrainingGpuOptionSchema = object({
43888
+ id: string(),
43889
+ label: string(),
43890
+ /** List price, USD per GPU-hour, before any region multiplier. */
43891
+ usdPerHour: number().nonnegative(),
43892
+ vramGb: number().nonnegative()
43893
+ });
43894
+ var TrainingRegionOptionSchema = object({
43895
+ /** `''` = any region (the provider's choice). */
43896
+ id: string(),
43897
+ label: string(),
43898
+ priceMultiplier: number().positive()
43899
+ });
43900
+ /**
43901
+ * The provider's per-account settings, as the orchestrator reads them. They
43902
+ * live in the PROVIDER addon's settings (operator decision 2026-10-08: they
43903
+ * depend on the user's account), never hard-coded in the orchestrator.
43904
+ */
43905
+ var TrainingProviderDefaultsSchema = object({
43906
+ gpuType: string(),
43907
+ region: string(),
43908
+ costCapUsd: number().nonnegative(),
43909
+ maxRuntimeSec: number().int().positive(),
43910
+ /** Hours a FAILED job's cloud dataset is kept for debugging; 0 = delete at once. */
43911
+ failedDatasetGraceHours: number().nonnegative()
43912
+ });
43913
+ var TrainingProviderDescriptorSchema = object({
43914
+ addonId: string(),
43915
+ /** `modal`, `runpod`, `fake`, … */
43916
+ kind: string(),
43917
+ label: string(),
43918
+ gpuTypes: array(TrainingGpuOptionSchema).readonly(),
43919
+ regions: array(TrainingRegionOptionSchema).readonly(),
43920
+ maxDatasetBytes: number().int().positive(),
43921
+ maxRuntimeSec: number().int().positive(),
43922
+ freeTierNote: string().optional(),
43923
+ /** Where the data goes, in one sentence the confirm dialog repeats. */
43924
+ dataResidencyNote: string(),
43925
+ /** Credentials are present — never the values. */
43926
+ configured: boolean(),
43927
+ defaults: TrainingProviderDefaultsSchema
43928
+ });
43929
+ var TrainingCredentialCheckSchema = object({
43930
+ ok: boolean(),
43931
+ /** Workspace / account name, when the provider says. */
43932
+ account: string().optional(),
43933
+ reason: _enum([
43934
+ "missing",
43935
+ "invalid",
43936
+ "forbidden",
43937
+ "network",
43938
+ "quota"
43939
+ ]).optional(),
43940
+ detail: string().optional()
43941
+ });
43942
+ var ProviderJobStateSchema = _enum([
43943
+ "pending",
43944
+ "starting",
43945
+ "running",
43946
+ "succeeded",
43947
+ "failed",
43948
+ "cancelled",
43949
+ "lost"
43950
+ ]);
43951
+ var ProviderJobStatusSchema = object({
43952
+ jobKey: string(),
43953
+ providerJobId: string().optional(),
43954
+ state: ProviderJobStateSchema,
43955
+ startedAt: number().optional(),
43956
+ endedAt: number().optional(),
43957
+ exitCode: number().int().optional(),
43958
+ failureReason: string().optional(),
43959
+ gpuType: string(),
43960
+ region: string().optional(),
43961
+ billedSeconds: number().nonnegative(),
43962
+ costUsd: number().nonnegative(),
43963
+ /** True when `costUsd` is runtime × list price, not a billing answer. */
43964
+ costIsEstimate: boolean(),
43965
+ lastFetchedAt: number()
43966
+ });
43967
+ /**
43968
+ * The trainer the job runs, by SOURCE revision: the provider turns it into an
43969
+ * image its own way (Modal builds the published Dockerfile at that revision;
43970
+ * a registry-pull provider maps it to a tag). Recorded on the job and echoed
43971
+ * in `result.json`.
43972
+ */
43973
+ var TrainerSourceRefSchema = object({
43974
+ /** Hugging Face repo id, e.g. `camstack/camstack-trainer`. */
43975
+ repo: string().min(1),
43976
+ /** A commit sha (never a branch) — the job must be reproducible. */
43977
+ revision: string().regex(/^[0-9a-f]{7,64}$/)
43978
+ });
43979
+ var JobRef = {
43980
+ addonId: string(),
43981
+ jobKey: string().uuid()
43982
+ };
43983
+ var TrainingLogLineSchema = object({
43984
+ ts: number(),
43985
+ text: string()
43986
+ });
43987
+ method(object({}), array(TrainingProviderDescriptorSchema).readonly(), { auth: "admin" }), method(object({ addonId: string() }), TrainingCredentialCheckSchema, {
43988
+ kind: "mutation",
43989
+ auth: "admin",
43990
+ timeoutMs: 3e4
43991
+ }), method(object({
43992
+ addonId: string(),
43993
+ gpuType: string(),
43994
+ region: string(),
43995
+ datasetBytes: number().int().nonnegative(),
43996
+ gpuSecondsLow: number().nonnegative(),
43997
+ gpuSecondsHigh: number().nonnegative()
43998
+ }), object({
43999
+ usdLow: number().nonnegative(),
44000
+ usdHigh: number().nonnegative(),
44001
+ notes: array(string()).readonly()
44002
+ }), { auth: "admin" }), method(object({
44003
+ ...JobRef,
44004
+ ticket: PeerBytesTicketSchema
44005
+ }), object({
44006
+ bytes: number().int().nonnegative(),
44007
+ sha256: string()
44008
+ }), {
44009
+ kind: "mutation",
44010
+ auth: "admin",
44011
+ timeoutMs: 120 * 6e4
44012
+ }), method(object({
44013
+ ...JobRef,
44014
+ trainer: TrainerSourceRefSchema,
44015
+ jobSpecJson: string().min(2).max(64e3),
44016
+ gpuType: string(),
44017
+ region: string(),
44018
+ maxRuntimeSec: number().int().positive()
44019
+ }), ProviderJobStatusSchema, {
44020
+ kind: "mutation",
44021
+ auth: "admin",
44022
+ timeoutMs: 30 * 6e4
44023
+ }), method(object(JobRef), ProviderJobStatusSchema, {
44024
+ auth: "admin",
44025
+ timeoutMs: 6e4
44026
+ }), method(object({
44027
+ ...JobRef,
44028
+ cursor: string().optional(),
44029
+ max: number().int().min(1).max(500)
44030
+ }), object({
44031
+ lines: array(TrainingLogLineSchema).readonly(),
44032
+ cursor: string()
44033
+ }), {
44034
+ auth: "admin",
44035
+ timeoutMs: 6e4
44036
+ }), method(object(JobRef), object({ ok: literal(true) }), {
44037
+ kind: "mutation",
44038
+ auth: "admin",
44039
+ timeoutMs: 6e4
44040
+ }), method(object(JobRef), object({
44041
+ found: boolean(),
44042
+ text: string().optional()
44043
+ }), {
44044
+ kind: "mutation",
44045
+ auth: "admin",
44046
+ timeoutMs: 5 * 6e4
44047
+ }), method(object({
44048
+ ...JobRef,
44049
+ path: _enum(["bundle.tar"])
44050
+ }), object({ ticket: PeerBytesTicketSchema }), {
44051
+ kind: "mutation",
44052
+ auth: "admin",
44053
+ timeoutMs: 5 * 6e4
44054
+ }), method(object(JobRef), object({ deleted: array(string()).readonly() }), {
44055
+ kind: "mutation",
44056
+ auth: "admin",
44057
+ timeoutMs: 5 * 6e4
44058
+ }), method(object({ addonId: string() }), array(ProviderJobStatusSchema).readonly(), {
44059
+ auth: "admin",
44060
+ timeoutMs: 2 * 6e4
44061
+ });
44062
+ /**
44063
+ * `training` — the cloud-training orchestrator (D805). Hub-only singleton,
44064
+ * provided by `addon-training`.
44065
+ *
44066
+ * It owns what every provider must agree on, written once:
44067
+ *
44068
+ * - **Dataset versions.** Taken over from pipeline-analytics (D796): the rows
44069
+ * live here (D808); pipeline-analytics still CUTS a version (it owns the corpus and
44070
+ * the export plan) and reaches this store through the five row methods
44071
+ * below, so the Retrain page and the export did not change.
44072
+ * - **Jobs.** A persisted state machine, a reconcile loop against the
44073
+ * provider, a cost guard, a daily orphan sweep and the retention rules.
44074
+ * - **The return flow.** Verified artefacts → Model Studio
44075
+ * (`custom-model-registry.importModelBundle`) → canary on cameras →
44076
+ * rollback. Nothing is ever registered automatically.
44077
+ *
44078
+ * Every method is `admin`.
44079
+ */
44080
+ /** A version WITH its frame list — what the export and a job read. */
44081
+ var TrainingDatasetVersionRowSchema = RetrainDatasetVersionSchema.omit({ frameCount: true }).extend({ frameIds: array(string()).max(2e4).readonly() });
44082
+ /** A base model a detector job can fine-tune, and the baseline it is judged against. */
44083
+ var TrainingBaseModelSchema = object({
44084
+ modelId: string(),
44085
+ label: string(),
44086
+ weights: string(),
44087
+ imgsz: number().int(),
44088
+ baselineOnnxUrl: string(),
44089
+ baselineFloors: record(string(), number()),
44090
+ /** The base the fleet runs most — the UI's default. */
44091
+ recommended: boolean()
44092
+ });
44093
+ var TrainingPresetSchema = _enum([
44094
+ "quick",
44095
+ "standard",
44096
+ "thorough"
44097
+ ]);
44098
+ var TrainingJobRequestSchema = object({
44099
+ datasetVersionId: string().min(1),
44100
+ /** The `training-provider` addon that runs it. */
44101
+ addonId: string().min(1),
44102
+ gpuType: string().min(1),
44103
+ region: string(),
44104
+ baseModelId: string().min(1),
44105
+ preset: TrainingPresetSchema,
44106
+ /** Freeze the backbone's first N layers; `null` = the preset's choice. */
44107
+ freeze: number().int().nonnegative().nullable(),
44108
+ /** Cameras held out whole for evaluation; `null` = the orchestrator's default. */
44109
+ holdoutCameras: array(number().int()).nullable()
44110
+ });
44111
+ var TrainingSplitPlanSchema = object({
44112
+ holdoutCameras: array(number().int()).readonly(),
44113
+ /** Used when no camera is held out: the last N days of every camera. */
44114
+ holdoutLastDays: number().int().nonnegative(),
44115
+ /** Holdout subjects per class (camera holdout only; `null` = known only after the split). */
44116
+ holdoutSupport: record(string(), number().int()).nullable(),
44117
+ trainSubjects: number().int()
44118
+ });
44119
+ var TrainingRefusalReasonSchema = _enum([
44120
+ "unknown-dataset",
44121
+ "unknown-provider",
44122
+ "provider-not-configured",
44123
+ "unknown-base-model",
44124
+ "unknown-gpu",
44125
+ "dataset-too-large",
44126
+ "no-training-subjects",
44127
+ "job-already-running"
44128
+ ]);
44129
+ var TrainingJobPlanSchema = object({
44130
+ refusal: object({
44131
+ reason: TrainingRefusalReasonSchema,
44132
+ detail: string()
44133
+ }).nullable(),
44134
+ warnings: array(string()).readonly(),
44135
+ split: TrainingSplitPlanSchema.nullable(),
44136
+ estimate: object({
44137
+ datasetBytes: number().int(),
44138
+ uploadMinutesAt20Mbps: number(),
44139
+ gpuSecondsLow: number(),
44140
+ gpuSecondsHigh: number(),
44141
+ usdLow: number(),
44142
+ usdHigh: number(),
44143
+ notes: array(string()).readonly()
44144
+ }).nullable(),
44145
+ /** Pre-filled from the provider's settings; the operator may lower or raise them. */
44146
+ defaults: object({
44147
+ maxCostUsd: number(),
44148
+ maxRuntimeSec: number().int()
44149
+ }).nullable(),
44150
+ /** The sentence the confirm dialog repeats: where the frames go and when they are deleted. */
44151
+ dataNotice: string()
44152
+ });
44153
+ /**
44154
+ * Orchestrator-owned states, persisted. `uploading` covers exporting the
44155
+ * archive (it is streamed, never staged). Terminal: `failed`, `cancelled`,
44156
+ * `lost`, `expired`, `discarded`. `registered` and `canary` are where a
44157
+ * result lives after the operator acted on it.
44158
+ */
44159
+ var TrainingJobStateSchema = _enum([
44160
+ "uploading",
44161
+ "submitted",
44162
+ "starting",
44163
+ "running",
44164
+ "collecting",
44165
+ "ready",
44166
+ "registered",
44167
+ "canary",
44168
+ "failed",
44169
+ "cancelling",
44170
+ "cancelled",
44171
+ "lost",
44172
+ "expired",
44173
+ "discarded"
44174
+ ]);
44175
+ var TrainingFailureReasonSchema = _enum([
44176
+ "cost-cap",
44177
+ "runtime-cap",
44178
+ "upload-failed",
44179
+ "submit-failed",
44180
+ "trainer-failed",
44181
+ "result-invalid",
44182
+ "checksum-mismatch",
44183
+ "fetch-failed",
44184
+ "provider-error",
44185
+ "hub-restart-during-upload"
44186
+ ]);
44187
+ var TrainingProgressPointSchema = object({
44188
+ epoch: number().int(),
44189
+ map50: number().nullable(),
44190
+ map50_95: number().nullable()
44191
+ });
44192
+ var TrainingCanarySchema = object({
44193
+ deviceIds: array(number().int()).readonly(),
44194
+ since: number(),
44195
+ /** Every override the canary replaced, exactly, so rollback restores it. */
44196
+ previous: array(object({
44197
+ deviceId: number().int(),
44198
+ nodeId: string(),
44199
+ deviceKey: string(),
44200
+ patch: object({
44201
+ modelId: string().optional(),
44202
+ settings: record(string(), unknown()).readonly().optional()
44203
+ }).nullable()
44204
+ })).readonly()
44205
+ });
44206
+ var TrainingJobSchema = object({
44207
+ id: string(),
44208
+ idempotencyKey: string(),
44209
+ name: string(),
44210
+ createdAt: number(),
44211
+ updatedAt: number(),
44212
+ state: TrainingJobStateSchema,
44213
+ stage: TrainingStageSchema.nullable(),
44214
+ failure: object({
44215
+ reason: TrainingFailureReasonSchema,
44216
+ stage: string().nullable(),
44217
+ detail: string()
44218
+ }).nullable(),
44219
+ request: TrainingJobRequestSchema,
44220
+ maxCostUsd: number().nonnegative(),
44221
+ maxRuntimeSec: number().int().positive(),
44222
+ trainer: TrainerSourceRefSchema,
44223
+ datasetLayout: RetrainExportLayoutSchema,
44224
+ dataset: object({
44225
+ bytes: number().int(),
44226
+ sha256: string(),
44227
+ uploadedAt: number()
44228
+ }).nullable(),
44229
+ split: TrainingSplitPlanSchema,
44230
+ provider: object({
44231
+ state: ProviderJobStateSchema.nullable(),
44232
+ providerJobId: string().nullable(),
44233
+ startedAt: number().nullable(),
44234
+ endedAt: number().nullable(),
44235
+ billedSeconds: number(),
44236
+ costUsd: number(),
44237
+ costIsEstimate: boolean(),
44238
+ lastPolledAt: number().nullable()
44239
+ }),
44240
+ progress: object({
44241
+ epoch: number().int().nullable(),
44242
+ epochs: number().int().nullable(),
44243
+ etaSec: number().nullable(),
44244
+ series: array(TrainingProgressPointSchema).readonly()
44245
+ }),
44246
+ /** The last lines of the job's output (≤ 200), newest last. Never frame paths. */
44247
+ logTail: array(string()).readonly(),
44248
+ logCursor: string().nullable(),
44249
+ artifacts: object({
44250
+ bundleBytes: number().int(),
44251
+ bundleSha256: string(),
44252
+ fetchedAt: number(),
44253
+ /** When the staged artefacts are deleted from the hub. */
44254
+ expiresAt: number()
44255
+ }).nullable(),
44256
+ /** When the provider-side copy of the frames was deleted; null while it exists. */
44257
+ cloudDatasetDeletedAt: number().nullable(),
44258
+ /** A failed job's dataset is kept until then (the provider's grace), then deleted. */
44259
+ cloudCleanupDueAt: number().nullable(),
44260
+ /** Model ids registered from this job (base, and int8 when kept). */
44261
+ registeredModelIds: array(string()).readonly(),
44262
+ canary: TrainingCanarySchema.nullable()
44263
+ });
44264
+ var IdInput = object({ id: string().min(1) });
44265
+ method(TrainingDatasetVersionRowSchema, object({ stored: boolean() }), {
44266
+ kind: "mutation",
44267
+ auth: "admin"
44268
+ }), 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() }), {
44269
+ kind: "mutation",
44270
+ auth: "admin"
44271
+ }), method(object({}), array(TrainingBaseModelSchema).readonly(), { auth: "admin" }), method(TrainingJobRequestSchema, TrainingJobPlanSchema, {
44272
+ auth: "admin",
44273
+ timeoutMs: 6e4
44274
+ }), method(TrainingJobRequestSchema.extend({
44275
+ name: string().min(1).max(120),
44276
+ maxCostUsd: number().positive(),
44277
+ maxRuntimeSec: number().int().positive(),
44278
+ idempotencyKey: string().min(8).max(80)
44279
+ }), discriminatedUnion("kind", [object({
44280
+ kind: literal("started"),
44281
+ job: TrainingJobSchema
44282
+ }), object({
44283
+ kind: literal("refused"),
44284
+ reason: TrainingRefusalReasonSchema,
44285
+ detail: string()
44286
+ })]), {
44287
+ kind: "mutation",
44288
+ auth: "admin",
44289
+ timeoutMs: 12e4
44290
+ }), method(object({}), array(TrainingJobSchema).readonly(), { auth: "admin" }), method(IdInput, TrainingJobSchema.nullable(), { auth: "admin" }), method(IdInput, TrainingJobSchema, {
44291
+ kind: "mutation",
44292
+ auth: "admin",
44293
+ timeoutMs: 12e4
44294
+ }), method(IdInput, TrainingResultSchema.nullable(), { auth: "admin" }), method(IdInput.extend({ canaryDeviceIds: array(number().int()).readonly() }), TrainingJobSchema, {
44295
+ kind: "mutation",
44296
+ auth: "admin",
44297
+ timeoutMs: 30 * 6e4
44298
+ }), method(IdInput.extend({ deviceIds: array(number().int()).min(1).readonly() }), TrainingJobSchema, {
44299
+ kind: "mutation",
44300
+ auth: "admin",
44301
+ timeoutMs: 12e4
44302
+ }), method(IdInput, TrainingJobSchema, {
44303
+ kind: "mutation",
44304
+ auth: "admin",
44305
+ timeoutMs: 12e4
44306
+ }), method(IdInput, TrainingJobSchema, {
44307
+ kind: "mutation",
44308
+ auth: "admin"
44309
+ });
41335
44310
  SOURCE_CAPS.filter((cap) => cap !== "switch" && cap !== "motion");
41336
44311
  Object.freeze({
41337
44312
  person: .5,
@@ -41833,7 +44808,8 @@ var BaseDevice = class {
41833
44808
  this.role = options.role;
41834
44809
  this.parentDeviceId = ctx.parentDeviceId;
41835
44810
  const seedData = ctx.persistedConfig ?? {};
41836
- this.config = DeviceConfig.fromSchema(schema, (data) => ctx.persistConfig(data), seedData, ({ droppedKeys, issues }) => {
44811
+ const declaredSecretPaths = collectZodSecretPaths(schema);
44812
+ this.config = DeviceConfig.fromSchema(schema, (data) => ctx.persistConfig(data, { secretConfigPaths: declaredSecretPaths }), seedData, ({ droppedKeys, issues }) => {
41837
44813
  ctx.logger.warn("Device config recovery: dropping invalid persisted fields", {
41838
44814
  tags: {
41839
44815
  deviceId: ctx.id,
@@ -43494,6 +46470,12 @@ Object.freeze({
43494
46470
  addonId: null,
43495
46471
  access: "create"
43496
46472
  },
46473
+ "backup.checkBackupKey": {
46474
+ capName: "backup",
46475
+ capScope: "system",
46476
+ addonId: null,
46477
+ access: "create"
46478
+ },
43497
46479
  "backup.delete": {
43498
46480
  capName: "backup",
43499
46481
  capScope: "system",
@@ -43506,6 +46488,18 @@ Object.freeze({
43506
46488
  addonId: null,
43507
46489
  access: "delete"
43508
46490
  },
46491
+ "backup.disableEncryption": {
46492
+ capName: "backup",
46493
+ capScope: "system",
46494
+ addonId: null,
46495
+ access: "create"
46496
+ },
46497
+ "backup.getEncryption": {
46498
+ capName: "backup",
46499
+ capScope: "system",
46500
+ addonId: null,
46501
+ access: "view"
46502
+ },
43509
46503
  "backup.getEntries": {
43510
46504
  capName: "backup",
43511
46505
  capScope: "system",
@@ -43560,6 +46554,12 @@ Object.freeze({
43560
46554
  addonId: null,
43561
46555
  access: "create"
43562
46556
  },
46557
+ "backup.setupEncryption": {
46558
+ capName: "backup",
46559
+ capScope: "system",
46560
+ addonId: null,
46561
+ access: "create"
46562
+ },
43563
46563
  "backup.trigger": {
43564
46564
  capName: "backup",
43565
46565
  capScope: "system",
@@ -44112,6 +47112,12 @@ Object.freeze({
44112
47112
  addonId: null,
44113
47113
  access: "create"
44114
47114
  },
47115
+ "customModelRegistry.importModelBundle": {
47116
+ capName: "custom-model-registry",
47117
+ capScope: "system",
47118
+ addonId: null,
47119
+ access: "create"
47120
+ },
44115
47121
  "customModelRegistry.listModels": {
44116
47122
  capName: "custom-model-registry",
44117
47123
  capScope: "system",
@@ -45522,6 +48528,108 @@ Object.freeze({
45522
48528
  addonId: null,
45523
48529
  access: "create"
45524
48530
  },
48531
+ "keychain.delete": {
48532
+ capName: "keychain",
48533
+ capScope: "system",
48534
+ addonId: null,
48535
+ access: "delete"
48536
+ },
48537
+ "keychain.getState": {
48538
+ capName: "keychain",
48539
+ capScope: "system",
48540
+ addonId: null,
48541
+ access: "view"
48542
+ },
48543
+ "keychain.listMeta": {
48544
+ capName: "keychain",
48545
+ capScope: "system",
48546
+ addonId: null,
48547
+ access: "view"
48548
+ },
48549
+ "keychain.put": {
48550
+ capName: "keychain",
48551
+ capScope: "system",
48552
+ addonId: null,
48553
+ access: "create"
48554
+ },
48555
+ "keychain.resolve": {
48556
+ capName: "keychain",
48557
+ capScope: "system",
48558
+ addonId: null,
48559
+ access: "view"
48560
+ },
48561
+ "keychainAdmin.acknowledgeReset": {
48562
+ capName: "keychain-admin",
48563
+ capScope: "system",
48564
+ addonId: null,
48565
+ access: "create"
48566
+ },
48567
+ "keychainAdmin.deleteOrphans": {
48568
+ capName: "keychain-admin",
48569
+ capScope: "system",
48570
+ addonId: null,
48571
+ access: "delete"
48572
+ },
48573
+ "keychainAdmin.downloadRecoveryKey": {
48574
+ capName: "keychain-admin",
48575
+ capScope: "system",
48576
+ addonId: null,
48577
+ access: "create"
48578
+ },
48579
+ "keychainAdmin.listAudit": {
48580
+ capName: "keychain-admin",
48581
+ capScope: "system",
48582
+ addonId: null,
48583
+ access: "view"
48584
+ },
48585
+ "keychainAdmin.listSecrets": {
48586
+ capName: "keychain-admin",
48587
+ capScope: "system",
48588
+ addonId: null,
48589
+ access: "view"
48590
+ },
48591
+ "keychainAdmin.purgeRetiredKeys": {
48592
+ capName: "keychain-admin",
48593
+ capScope: "system",
48594
+ addonId: null,
48595
+ access: "delete"
48596
+ },
48597
+ "keychainAdmin.resetKeychain": {
48598
+ capName: "keychain-admin",
48599
+ capScope: "system",
48600
+ addonId: null,
48601
+ access: "delete"
48602
+ },
48603
+ "keychainAdmin.resetReport": {
48604
+ capName: "keychain-admin",
48605
+ capScope: "system",
48606
+ addonId: null,
48607
+ access: "delete"
48608
+ },
48609
+ "keychainAdmin.reveal": {
48610
+ capName: "keychain-admin",
48611
+ capScope: "system",
48612
+ addonId: null,
48613
+ access: "create"
48614
+ },
48615
+ "keychainAdmin.rotateMasterKey": {
48616
+ capName: "keychain-admin",
48617
+ capScope: "system",
48618
+ addonId: null,
48619
+ access: "create"
48620
+ },
48621
+ "keychainAdmin.setSystemSecret": {
48622
+ capName: "keychain-admin",
48623
+ capScope: "system",
48624
+ addonId: null,
48625
+ access: "create"
48626
+ },
48627
+ "keychainAdmin.status": {
48628
+ capName: "keychain-admin",
48629
+ capScope: "system",
48630
+ addonId: null,
48631
+ access: "view"
48632
+ },
45525
48633
  "lawnMowerControl.dock": {
45526
48634
  capName: "lawn-mower-control",
45527
48635
  capScope: "device",
@@ -46896,6 +50004,18 @@ Object.freeze({
46896
50004
  addonId: null,
46897
50005
  access: "create"
46898
50006
  },
50007
+ "pipelineAnalytics.addRetrainFrameFromRecording": {
50008
+ capName: "pipeline-analytics",
50009
+ capScope: "device",
50010
+ addonId: null,
50011
+ access: "create"
50012
+ },
50013
+ "pipelineAnalytics.addRetrainFramesToCollection": {
50014
+ capName: "pipeline-analytics",
50015
+ capScope: "device",
50016
+ addonId: null,
50017
+ access: "create"
50018
+ },
46899
50019
  "pipelineAnalytics.applyDeviceSettingsPatch": {
46900
50020
  capName: "pipeline-analytics",
46901
50021
  capScope: "device",
@@ -46944,12 +50064,36 @@ Object.freeze({
46944
50064
  addonId: null,
46945
50065
  access: "view"
46946
50066
  },
50067
+ "pipelineAnalytics.createRetrainCollection": {
50068
+ capName: "pipeline-analytics",
50069
+ capScope: "device",
50070
+ addonId: null,
50071
+ access: "create"
50072
+ },
50073
+ "pipelineAnalytics.createRetrainDatasetVersion": {
50074
+ capName: "pipeline-analytics",
50075
+ capScope: "device",
50076
+ addonId: null,
50077
+ access: "create"
50078
+ },
46947
50079
  "pipelineAnalytics.deleteDeviceEvents": {
46948
50080
  capName: "pipeline-analytics",
46949
50081
  capScope: "device",
46950
50082
  addonId: null,
46951
50083
  access: "delete"
46952
50084
  },
50085
+ "pipelineAnalytics.deleteRetrainCollection": {
50086
+ capName: "pipeline-analytics",
50087
+ capScope: "device",
50088
+ addonId: null,
50089
+ access: "delete"
50090
+ },
50091
+ "pipelineAnalytics.deleteRetrainDatasetVersion": {
50092
+ capName: "pipeline-analytics",
50093
+ capScope: "device",
50094
+ addonId: null,
50095
+ access: "delete"
50096
+ },
46953
50097
  "pipelineAnalytics.deleteTracks": {
46954
50098
  capName: "pipeline-analytics",
46955
50099
  capScope: "device",
@@ -47154,6 +50298,30 @@ Object.freeze({
47154
50298
  addonId: null,
47155
50299
  access: "view"
47156
50300
  },
50301
+ "pipelineAnalytics.listRetrainAssistProfiles": {
50302
+ capName: "pipeline-analytics",
50303
+ capScope: "device",
50304
+ addonId: null,
50305
+ access: "view"
50306
+ },
50307
+ "pipelineAnalytics.listRetrainCollectionFrames": {
50308
+ capName: "pipeline-analytics",
50309
+ capScope: "device",
50310
+ addonId: null,
50311
+ access: "view"
50312
+ },
50313
+ "pipelineAnalytics.listRetrainCollections": {
50314
+ capName: "pipeline-analytics",
50315
+ capScope: "device",
50316
+ addonId: null,
50317
+ access: "view"
50318
+ },
50319
+ "pipelineAnalytics.listRetrainDatasetVersions": {
50320
+ capName: "pipeline-analytics",
50321
+ capScope: "device",
50322
+ addonId: null,
50323
+ access: "view"
50324
+ },
47157
50325
  "pipelineAnalytics.listRetrainFrames": {
47158
50326
  capName: "pipeline-analytics",
47159
50327
  capScope: "device",
@@ -47184,6 +50352,12 @@ Object.freeze({
47184
50352
  addonId: null,
47185
50353
  access: "view"
47186
50354
  },
50355
+ "pipelineAnalytics.offerRetrainArchive": {
50356
+ capName: "pipeline-analytics",
50357
+ capScope: "device",
50358
+ addonId: null,
50359
+ access: "create"
50360
+ },
47187
50361
  "pipelineAnalytics.ownersWithMedia": {
47188
50362
  capName: "pipeline-analytics",
47189
50363
  capScope: "device",
@@ -47196,12 +50370,24 @@ Object.freeze({
47196
50370
  addonId: null,
47197
50371
  access: "create"
47198
50372
  },
50373
+ "pipelineAnalytics.previewRetrainDataset": {
50374
+ capName: "pipeline-analytics",
50375
+ capScope: "device",
50376
+ addonId: null,
50377
+ access: "view"
50378
+ },
47199
50379
  "pipelineAnalytics.proposeRetrainAnnotations": {
47200
50380
  capName: "pipeline-analytics",
47201
50381
  capScope: "device",
47202
50382
  addonId: null,
47203
50383
  access: "create"
47204
50384
  },
50385
+ "pipelineAnalytics.proposeRetrainAnnotationsWithLlm": {
50386
+ capName: "pipeline-analytics",
50387
+ capScope: "device",
50388
+ addonId: null,
50389
+ access: "create"
50390
+ },
47205
50391
  "pipelineAnalytics.pruneEvents": {
47206
50392
  capName: "pipeline-analytics",
47207
50393
  capScope: "device",
@@ -47256,6 +50442,18 @@ Object.freeze({
47256
50442
  addonId: null,
47257
50443
  access: "create"
47258
50444
  },
50445
+ "pipelineAnalytics.removeRetrainFrameFromCollection": {
50446
+ capName: "pipeline-analytics",
50447
+ capScope: "device",
50448
+ addonId: null,
50449
+ access: "delete"
50450
+ },
50451
+ "pipelineAnalytics.renameRetrainCollection": {
50452
+ capName: "pipeline-analytics",
50453
+ capScope: "device",
50454
+ addonId: null,
50455
+ access: "create"
50456
+ },
47259
50457
  "pipelineAnalytics.restageRetrainTrack": {
47260
50458
  capName: "pipeline-analytics",
47261
50459
  capScope: "device",
@@ -47316,6 +50514,12 @@ Object.freeze({
47316
50514
  addonId: null,
47317
50515
  access: "create"
47318
50516
  },
50517
+ "pipelineAnalytics.verifyRetrainDatasetVersion": {
50518
+ capName: "pipeline-analytics",
50519
+ capScope: "device",
50520
+ addonId: null,
50521
+ access: "view"
50522
+ },
47319
50523
  "pipelineAnalytics.wipeAllAnalytics": {
47320
50524
  capName: "pipeline-analytics",
47321
50525
  capScope: "device",
@@ -47544,6 +50748,12 @@ Object.freeze({
47544
50748
  addonId: null,
47545
50749
  access: "view"
47546
50750
  },
50751
+ "pipelineOrchestrator.abortNodeBenchmark": {
50752
+ capName: "pipeline-orchestrator",
50753
+ capScope: "system",
50754
+ addonId: null,
50755
+ access: "create"
50756
+ },
47547
50757
  "pipelineOrchestrator.applyAutoTune": {
47548
50758
  capName: "pipeline-orchestrator",
47549
50759
  capScope: "system",
@@ -47568,6 +50778,12 @@ Object.freeze({
47568
50778
  addonId: null,
47569
50779
  access: "create"
47570
50780
  },
50781
+ "pipelineOrchestrator.deleteNodeBenchmarkResult": {
50782
+ capName: "pipeline-orchestrator",
50783
+ capScope: "system",
50784
+ addonId: null,
50785
+ access: "delete"
50786
+ },
47571
50787
  "pipelineOrchestrator.getAgentLoad": {
47572
50788
  capName: "pipeline-orchestrator",
47573
50789
  capScope: "system",
@@ -47676,6 +50892,24 @@ Object.freeze({
47676
50892
  addonId: null,
47677
50893
  access: "view"
47678
50894
  },
50895
+ "pipelineOrchestrator.getNodeBenchmarkCandidates": {
50896
+ capName: "pipeline-orchestrator",
50897
+ capScope: "system",
50898
+ addonId: null,
50899
+ access: "view"
50900
+ },
50901
+ "pipelineOrchestrator.getNodeBenchmarkPreflight": {
50902
+ capName: "pipeline-orchestrator",
50903
+ capScope: "system",
50904
+ addonId: null,
50905
+ access: "view"
50906
+ },
50907
+ "pipelineOrchestrator.getNodeBenchmarkStatus": {
50908
+ capName: "pipeline-orchestrator",
50909
+ capScope: "system",
50910
+ addonId: null,
50911
+ access: "view"
50912
+ },
47679
50913
  "pipelineOrchestrator.getNodeInferenceDevices": {
47680
50914
  capName: "pipeline-orchestrator",
47681
50915
  capScope: "system",
@@ -47718,6 +50952,12 @@ Object.freeze({
47718
50952
  addonId: null,
47719
50953
  access: "view"
47720
50954
  },
50955
+ "pipelineOrchestrator.listNodeBenchmarkResults": {
50956
+ capName: "pipeline-orchestrator",
50957
+ capScope: "system",
50958
+ addonId: null,
50959
+ access: "view"
50960
+ },
47721
50961
  "pipelineOrchestrator.pauseForStorageMigration": {
47722
50962
  capName: "pipeline-orchestrator",
47723
50963
  capScope: "system",
@@ -47862,6 +51102,12 @@ Object.freeze({
47862
51102
  addonId: null,
47863
51103
  access: "create"
47864
51104
  },
51105
+ "pipelineOrchestrator.startNodeBenchmark": {
51106
+ capName: "pipeline-orchestrator",
51107
+ capScope: "system",
51108
+ addonId: null,
51109
+ access: "create"
51110
+ },
47865
51111
  "pipelineOrchestrator.suggestShares": {
47866
51112
  capName: "pipeline-orchestrator",
47867
51113
  capScope: "system",
@@ -47880,6 +51126,12 @@ Object.freeze({
47880
51126
  addonId: null,
47881
51127
  access: "create"
47882
51128
  },
51129
+ "pipelineRunner.abortNodeBench": {
51130
+ capName: "pipeline-runner",
51131
+ capScope: "system",
51132
+ addonId: null,
51133
+ access: "create"
51134
+ },
47883
51135
  "pipelineRunner.attachCamera": {
47884
51136
  capName: "pipeline-runner",
47885
51137
  capScope: "system",
@@ -47928,6 +51180,12 @@ Object.freeze({
47928
51180
  addonId: null,
47929
51181
  access: "view"
47930
51182
  },
51183
+ "pipelineRunner.getNodeBenchStatus": {
51184
+ capName: "pipeline-runner",
51185
+ capScope: "system",
51186
+ addonId: null,
51187
+ access: "view"
51188
+ },
47931
51189
  "pipelineRunner.getParkedTrackFrame": {
47932
51190
  capName: "pipeline-runner",
47933
51191
  capScope: "system",
@@ -47970,6 +51228,12 @@ Object.freeze({
47970
51228
  addonId: null,
47971
51229
  access: "create"
47972
51230
  },
51231
+ "pipelineRunner.startNodeBench": {
51232
+ capName: "pipeline-runner",
51233
+ capScope: "system",
51234
+ addonId: null,
51235
+ access: "create"
51236
+ },
47973
51237
  "plateGallery.assignPlate": {
47974
51238
  capName: "plate-gallery",
47975
51239
  capScope: "system",
@@ -49632,6 +52896,174 @@ Object.freeze({
49632
52896
  addonId: null,
49633
52897
  access: "view"
49634
52898
  },
52899
+ "training.canaryResult": {
52900
+ capName: "training",
52901
+ capScope: "system",
52902
+ addonId: null,
52903
+ access: "create"
52904
+ },
52905
+ "training.cancelJob": {
52906
+ capName: "training",
52907
+ capScope: "system",
52908
+ addonId: null,
52909
+ access: "create"
52910
+ },
52911
+ "training.discardResult": {
52912
+ capName: "training",
52913
+ capScope: "system",
52914
+ addonId: null,
52915
+ access: "create"
52916
+ },
52917
+ "training.findDatasetVersionIdByName": {
52918
+ capName: "training",
52919
+ capScope: "system",
52920
+ addonId: null,
52921
+ access: "view"
52922
+ },
52923
+ "training.getDatasetVersion": {
52924
+ capName: "training",
52925
+ capScope: "system",
52926
+ addonId: null,
52927
+ access: "view"
52928
+ },
52929
+ "training.getJob": {
52930
+ capName: "training",
52931
+ capScope: "system",
52932
+ addonId: null,
52933
+ access: "view"
52934
+ },
52935
+ "training.getJobResult": {
52936
+ capName: "training",
52937
+ capScope: "system",
52938
+ addonId: null,
52939
+ access: "view"
52940
+ },
52941
+ "training.listBaseModels": {
52942
+ capName: "training",
52943
+ capScope: "system",
52944
+ addonId: null,
52945
+ access: "view"
52946
+ },
52947
+ "training.listDatasetVersions": {
52948
+ capName: "training",
52949
+ capScope: "system",
52950
+ addonId: null,
52951
+ access: "view"
52952
+ },
52953
+ "training.listJobs": {
52954
+ capName: "training",
52955
+ capScope: "system",
52956
+ addonId: null,
52957
+ access: "view"
52958
+ },
52959
+ "training.planJob": {
52960
+ capName: "training",
52961
+ capScope: "system",
52962
+ addonId: null,
52963
+ access: "view"
52964
+ },
52965
+ "training.putDatasetVersion": {
52966
+ capName: "training",
52967
+ capScope: "system",
52968
+ addonId: null,
52969
+ access: "create"
52970
+ },
52971
+ "training.registerResult": {
52972
+ capName: "training",
52973
+ capScope: "system",
52974
+ addonId: null,
52975
+ access: "create"
52976
+ },
52977
+ "training.removeDatasetVersion": {
52978
+ capName: "training",
52979
+ capScope: "system",
52980
+ addonId: null,
52981
+ access: "delete"
52982
+ },
52983
+ "training.rollbackCanary": {
52984
+ capName: "training",
52985
+ capScope: "system",
52986
+ addonId: null,
52987
+ access: "create"
52988
+ },
52989
+ "training.startJob": {
52990
+ capName: "training",
52991
+ capScope: "system",
52992
+ addonId: null,
52993
+ access: "create"
52994
+ },
52995
+ "trainingProvider.cancelJob": {
52996
+ capName: "training-provider",
52997
+ capScope: "system",
52998
+ addonId: null,
52999
+ access: "create"
53000
+ },
53001
+ "trainingProvider.cleanupJob": {
53002
+ capName: "training-provider",
53003
+ capScope: "system",
53004
+ addonId: null,
53005
+ access: "create"
53006
+ },
53007
+ "trainingProvider.describe": {
53008
+ capName: "training-provider",
53009
+ capScope: "system",
53010
+ addonId: null,
53011
+ access: "view"
53012
+ },
53013
+ "trainingProvider.estimateJob": {
53014
+ capName: "training-provider",
53015
+ capScope: "system",
53016
+ addonId: null,
53017
+ access: "view"
53018
+ },
53019
+ "trainingProvider.getJob": {
53020
+ capName: "training-provider",
53021
+ capScope: "system",
53022
+ addonId: null,
53023
+ access: "view"
53024
+ },
53025
+ "trainingProvider.listJobEvents": {
53026
+ capName: "training-provider",
53027
+ capScope: "system",
53028
+ addonId: null,
53029
+ access: "view"
53030
+ },
53031
+ "trainingProvider.listJobs": {
53032
+ capName: "training-provider",
53033
+ capScope: "system",
53034
+ addonId: null,
53035
+ access: "view"
53036
+ },
53037
+ "trainingProvider.offerArtifact": {
53038
+ capName: "training-provider",
53039
+ capScope: "system",
53040
+ addonId: null,
53041
+ access: "create"
53042
+ },
53043
+ "trainingProvider.readResult": {
53044
+ capName: "training-provider",
53045
+ capScope: "system",
53046
+ addonId: null,
53047
+ access: "create"
53048
+ },
53049
+ "trainingProvider.submitJob": {
53050
+ capName: "training-provider",
53051
+ capScope: "system",
53052
+ addonId: null,
53053
+ access: "create"
53054
+ },
53055
+ "trainingProvider.uploadDataset": {
53056
+ capName: "training-provider",
53057
+ capScope: "system",
53058
+ addonId: null,
53059
+ access: "create"
53060
+ },
53061
+ "trainingProvider.validateCredentials": {
53062
+ capName: "training-provider",
53063
+ capScope: "system",
53064
+ addonId: null,
53065
+ access: "create"
53066
+ },
49635
53067
  "turnProvider.getTurnServers": {
49636
53068
  capName: "turn-provider",
49637
53069
  capScope: "system",
@@ -49656,12 +53088,6 @@ Object.freeze({
49656
53088
  addonId: null,
49657
53089
  access: "create"
49658
53090
  },
49659
- "userManagement.createApiKey": {
49660
- capName: "user-management",
49661
- capScope: "system",
49662
- addonId: null,
49663
- access: "create"
49664
- },
49665
53091
  "userManagement.createScopedToken": {
49666
53092
  capName: "user-management",
49667
53093
  capScope: "system",
@@ -49698,12 +53124,6 @@ Object.freeze({
49698
53124
  addonId: null,
49699
53125
  access: "view"
49700
53126
  },
49701
- "userManagement.linkExternalIdentity": {
49702
- capName: "user-management",
49703
- capScope: "system",
49704
- addonId: null,
49705
- access: "create"
49706
- },
49707
53127
  "userManagement.listApiKeys": {
49708
53128
  capName: "user-management",
49709
53129
  capScope: "system",
@@ -49806,12 +53226,6 @@ Object.freeze({
49806
53226
  addonId: null,
49807
53227
  access: "create"
49808
53228
  },
49809
- "userManagement.validateApiKey": {
49810
- capName: "user-management",
49811
- capScope: "system",
49812
- addonId: null,
49813
- access: "view"
49814
- },
49815
53229
  "userManagement.validateCredentials": {
49816
53230
  capName: "user-management",
49817
53231
  capScope: "system",
@@ -53117,6 +56531,11 @@ Object.freeze({
53117
56531
  form: "single",
53118
56532
  optional: false
53119
56533
  }],
56534
+ "pipelineAnalytics.addRetrainFrameFromRecording": [{
56535
+ name: "deviceId",
56536
+ form: "single",
56537
+ optional: false
56538
+ }],
53120
56539
  "pipelineAnalytics.applyDeviceSettingsPatch": [{
53121
56540
  name: "deviceId",
53122
56541
  form: "single",
@@ -53307,6 +56726,11 @@ Object.freeze({
53307
56726
  form: "single",
53308
56727
  optional: false
53309
56728
  }],
56729
+ "pipelineAnalytics.proposeRetrainAnnotationsWithLlm": [{
56730
+ name: "deviceId",
56731
+ form: "single",
56732
+ optional: false
56733
+ }],
53310
56734
  "pipelineAnalytics.pruneEventsBefore": [{
53311
56735
  name: "deviceId",
53312
56736
  form: "single",
@@ -54133,6 +57557,11 @@ Object.freeze({
54133
57557
  form: "single",
54134
57558
  optional: false
54135
57559
  }],
57560
+ "training.canaryResult": [{
57561
+ name: "deviceIds",
57562
+ form: "array",
57563
+ optional: false
57564
+ }],
54136
57565
  "update.getStatus": [{
54137
57566
  name: "deviceId",
54138
57567
  form: "single",