@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.mjs CHANGED
@@ -12,7 +12,7 @@ import { networkInterfaces } from "node:os";
12
12
  var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
13
13
  var __require = /* @__PURE__ */ createRequire(import.meta.url);
14
14
  //#endregion
15
- //#region ../types/dist/event-category-B_0XEcLF.mjs
15
+ //#region ../types/dist/event-category-DaIZi00R.mjs
16
16
  var EventCategory = /* @__PURE__ */ function(EventCategory) {
17
17
  EventCategory["SystemBoot"] = "system.boot";
18
18
  EventCategory["SystemAddonsReady"] = "system.addons-ready";
@@ -91,6 +91,13 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
91
91
  */
92
92
  EventCategory["AddonLoadFailed"] = "addon.load-failed";
93
93
  /**
94
+ * A keychain value was stored or removed (D787). Carries the ref, its
95
+ * owner and the new version — NEVER the value. A process holding the ref
96
+ * drops its cached copy and the owning `BaseAddon` re-resolves its config.
97
+ * Telemetry (D8): a process that misses it still revalidates by version.
98
+ */
99
+ EventCategory["KeychainChanged"] = "keychain.changed";
100
+ /**
94
101
  * Addon recovered from a previous failure. Emitted when an addon
95
102
  * transitions from `failed` back to `healthy` (typically via the
96
103
  * monitor's auto-retry loop, or after manual `addons.retryLoad`).
@@ -5383,7 +5390,7 @@ var ZodIssueCode = {
5383
5390
  var ZodFirstPartyTypeKind;
5384
5391
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
5385
5392
  //#endregion
5386
- //#region ../types/dist/sleep-B0JG7-_F.mjs
5393
+ //#region ../types/dist/sleep-r3RWkGVx.mjs
5387
5394
  /**
5388
5395
  * The audio chunk plane's byte format, and the ONE expansion from a coded
5389
5396
  * window to float samples (D455).
@@ -5462,6 +5469,97 @@ function buildAlawTable() {
5462
5469
  }
5463
5470
  buildUlawTable();
5464
5471
  buildAlawTable();
5472
+ /** Is this field's stored value a credential? */
5473
+ function isSecretConfigField(field) {
5474
+ if (field.type === "password") return true;
5475
+ return "secret" in field && field.secret === true;
5476
+ }
5477
+ /**
5478
+ * Is this field's value stored in the KEYCHAIN (D787)? Every secret field is,
5479
+ * by its TYPE, unless it opts out with `storage: 'inline'` — never by its name.
5480
+ */
5481
+ function isKeychainStoredField(field) {
5482
+ if (!isSecretConfigField(field)) return false;
5483
+ if (field.type === "textarea" && field.isJson === true) return false;
5484
+ return !("storage" in field && field.storage === "inline");
5485
+ }
5486
+ /**
5487
+ * What a settings blob holds where a secret used to be.
5488
+ *
5489
+ * A keychain-stored field never holds its value. It holds a self-describing
5490
+ * MARKER, `{"$secret":"secret://…","v":1}` — an object, never a string, so no
5491
+ * code can mistake it for a credential and no form can send it to a camera as
5492
+ * a password. The empty state is `null` / absent, never `''`.
5493
+ *
5494
+ * The same shapes travel to and from the admin UI:
5495
+ *
5496
+ * - read: `hydrateSchema` hands a secret field a {@link SecretFieldView}
5497
+ * (`{ $secret, v, set: true }`) or `null` — the browser learns whether a
5498
+ * value is set, never the value.
5499
+ * - write: an untouched field submits the view back unchanged (KEEP); a typed
5500
+ * value is a plain non-empty string (CHANGE); the Clear button submits
5501
+ * {@link SECRET_CLEAR} (CLEAR). `''`, `null` and the legacy redaction tokens
5502
+ * are KEEP — an empty string is what a defaults-fallback pushes back, and
5503
+ * treating it as "clear" is how a save destroyed a stored credential before.
5504
+ *
5505
+ * Pure and browser-safe.
5506
+ */
5507
+ var SECRET_CLEAR = { $secretClear: true };
5508
+ /** The `'***'` token D634 redaction writes for non-admins. */
5509
+ var LEGACY_DEVICE_REDACTION = "***";
5510
+ function isRecord$2(value) {
5511
+ return typeof value === "object" && value !== null && !Array.isArray(value);
5512
+ }
5513
+ function makeSecretMarker(ref) {
5514
+ return {
5515
+ $secret: ref,
5516
+ v: 1
5517
+ };
5518
+ }
5519
+ /** A stored marker: an object whose `$secret` is a non-empty string. */
5520
+ function isSecretMarker(value) {
5521
+ if (!isRecord$2(value)) return false;
5522
+ const ref = value["$secret"];
5523
+ return typeof ref === "string" && ref.length > 0;
5524
+ }
5525
+ function isSecretClear(value) {
5526
+ return isRecord$2(value) && value["$secretClear"] === true;
5527
+ }
5528
+ /**
5529
+ * The UI view of a stored secret field value: a marker becomes "set", inline
5530
+ * plaintext becomes "set (inline)", nothing becomes `null`. A value never
5531
+ * survives this function.
5532
+ */
5533
+ function toSecretFieldView(stored) {
5534
+ if (isSecretMarker(stored)) return {
5535
+ $secret: stored.$secret,
5536
+ v: 1,
5537
+ set: true
5538
+ };
5539
+ if (typeof stored === "string" && stored.length > 0) return {
5540
+ $secret: null,
5541
+ v: 1,
5542
+ set: true,
5543
+ inline: true
5544
+ };
5545
+ return null;
5546
+ }
5547
+ /**
5548
+ * Classify an incoming value for a secret path. Only a non-empty string that is
5549
+ * not a redaction token sets a value; only {@link SECRET_CLEAR} clears.
5550
+ * Everything else — a marker (ours or anyone's), a UI view, `''`, `null`,
5551
+ * `undefined`, a redaction token, a non-string — keeps what is stored.
5552
+ */
5553
+ function classifySecretWrite(incoming) {
5554
+ if (isSecretClear(incoming)) return { kind: "clear" };
5555
+ if (typeof incoming !== "string") return { kind: "keep" };
5556
+ if (incoming.length === 0) return { kind: "keep" };
5557
+ if (incoming === "__camstack_redacted__" || incoming === LEGACY_DEVICE_REDACTION) return { kind: "keep" };
5558
+ return {
5559
+ kind: "set",
5560
+ value: incoming
5561
+ };
5562
+ }
5465
5563
  Object.fromEntries([
5466
5564
  {
5467
5565
  id: "overview",
@@ -5633,33 +5731,19 @@ Object.fromEntries([
5633
5731
  function isValuelessField(field) {
5634
5732
  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";
5635
5733
  }
5636
- /**
5637
- * Merge a `ConfigUISchema` with a raw `values` record into a
5638
- * `ConfigUISchemaWithValues`. Used by every `get*Settings` backend endpoint
5639
- * before returning to the admin UI. Groups are walked recursively.
5640
- *
5641
- * For each leaf field:
5642
- * - structural fields (`separator`, `info`, `button`) pass through unchanged
5643
- * - other fields get `value = values[key] ?? field.default ?? null`
5644
- *
5645
- * Unknown keys in `values` (keys not declared in the schema) are silently
5646
- * ignored — they don't contribute to the output. Missing keys fall back to
5647
- * the schema default or `null`. This mirrors the old backend behaviour where
5648
- * `FormBuilder` rendered `values[key] ?? field.default`.
5649
- */
5650
- function hydrateSchema(schema, values) {
5734
+ function hydrateSchema(schema, values, options = {}) {
5651
5735
  return {
5652
5736
  ...schema.tabs ? { tabs: [...schema.tabs] } : {},
5653
5737
  sections: schema.sections.map((section) => ({
5654
5738
  ...section,
5655
- fields: section.fields.map((field) => hydrateField(field, values))
5739
+ fields: section.fields.map((field) => hydrateField(field, values, options))
5656
5740
  }))
5657
5741
  };
5658
5742
  }
5659
- function hydrateField(field, values) {
5743
+ function hydrateField(field, values, options) {
5660
5744
  if (isValuelessField(field)) return field;
5661
5745
  if (field.type === "group") {
5662
- const hydratedChildren = field.fields.map((child) => hydrateField(child, values));
5746
+ const hydratedChildren = field.fields.map((child) => hydrateField(child, values, options));
5663
5747
  return {
5664
5748
  ...field,
5665
5749
  fields: hydratedChildren
@@ -5668,7 +5752,7 @@ function hydrateField(field, values) {
5668
5752
  if (field.type === "sub-tabs") {
5669
5753
  const hydratedTabs = field.tabs.map((tab) => ({
5670
5754
  ...tab,
5671
- fields: tab.fields.map((child) => hydrateField(child, values))
5755
+ fields: tab.fields.map((child) => hydrateField(child, values, options))
5672
5756
  }));
5673
5757
  return {
5674
5758
  ...field,
@@ -5678,6 +5762,33 @@ function hydrateField(field, values) {
5678
5762
  const key = field.key;
5679
5763
  const storedValue = Object.prototype.hasOwnProperty.call(values, key) ? values[key] : void 0;
5680
5764
  const defaultValue = field.default;
5765
+ const asView = (v) => isSecretMarker(v) || options.inlineSecretsAsViews === true && v !== void 0;
5766
+ if (isKeychainStoredField(field) && asView(storedValue)) return {
5767
+ ...field,
5768
+ value: toSecretFieldView(storedValue)
5769
+ };
5770
+ if (isKeychainStoredField(field) && options.inlineSecretsAsViews === true) return {
5771
+ ...field,
5772
+ value: null
5773
+ };
5774
+ if (field.type === "editable-array" && Array.isArray(storedValue)) {
5775
+ const secretItemKeys = field.itemFields.filter((item) => "key" in item && isKeychainStoredField(item)).map((item) => "key" in item ? item.key : "");
5776
+ if (secretItemKeys.length > 0) {
5777
+ const rows = storedValue.map((row) => {
5778
+ if (row === null || typeof row !== "object" || Array.isArray(row)) return row;
5779
+ const out = { ...row };
5780
+ for (const k of secretItemKeys) {
5781
+ const v = Reflect.get(row, k);
5782
+ if (asView(v)) out[k] = toSecretFieldView(v);
5783
+ }
5784
+ return out;
5785
+ });
5786
+ return {
5787
+ ...field,
5788
+ value: rows
5789
+ };
5790
+ }
5791
+ }
5681
5792
  if (field.multiple) {
5682
5793
  const stored = Array.isArray(storedValue) ? storedValue : storedValue !== void 0 && storedValue !== null ? [storedValue] : [];
5683
5794
  const itemFallback = field.multiple.itemDefault !== void 0 ? field.multiple.itemDefault : defaultValue !== void 0 ? defaultValue : typeOf(field) === "string" ? "" : null;
@@ -5920,6 +6031,778 @@ function projectStore(store, perNodeKeys, nodeId) {
5920
6031
  }
5921
6032
  return out;
5922
6033
  }
6034
+ var GLOBAL_SCOPE = { kind: "global" };
6035
+ /** The scope every addon-wide (not per-node, not per-device) setting lives in. */
6036
+ function globalSecretScope() {
6037
+ return GLOBAL_SCOPE;
6038
+ }
6039
+ function encodeSegment(value) {
6040
+ return encodeURIComponent(value);
6041
+ }
6042
+ function decodeSegment(value) {
6043
+ try {
6044
+ return decodeURIComponent(value);
6045
+ } catch {
6046
+ return null;
6047
+ }
6048
+ }
6049
+ /**
6050
+ * The field path of a value inside an array item, addressed by the item's id:
6051
+ * `arrayItemFieldPath('providers', 'authentik', 'clientSecret')` →
6052
+ * `providers[authentik].clientSecret`.
6053
+ */
6054
+ function arrayItemFieldPath(arrayKey, itemId, fieldKey) {
6055
+ return `${arrayKey}[${encodeSegment(itemId)}].${fieldKey}`;
6056
+ }
6057
+ function parseScope(segments) {
6058
+ switch (segments[0]) {
6059
+ case "global": return {
6060
+ scope: GLOBAL_SCOPE,
6061
+ used: 1
6062
+ };
6063
+ case "node": {
6064
+ const nodeId = segments[1] !== void 0 ? decodeSegment(segments[1]) : null;
6065
+ return nodeId === null || nodeId.length === 0 ? null : {
6066
+ scope: {
6067
+ kind: "node",
6068
+ nodeId
6069
+ },
6070
+ used: 2
6071
+ };
6072
+ }
6073
+ case "device": {
6074
+ const raw = segments[1];
6075
+ if (raw === void 0 || !/^\d+$/.test(raw)) return null;
6076
+ return {
6077
+ scope: {
6078
+ kind: "device",
6079
+ deviceId: Number(raw)
6080
+ },
6081
+ used: 2
6082
+ };
6083
+ }
6084
+ case "integration": {
6085
+ const id = segments[1] !== void 0 ? decodeSegment(segments[1]) : null;
6086
+ return id === null || id.length === 0 ? null : {
6087
+ scope: {
6088
+ kind: "integration",
6089
+ integrationId: id
6090
+ },
6091
+ used: 2
6092
+ };
6093
+ }
6094
+ case "row": {
6095
+ const collection = segments[1] !== void 0 ? decodeSegment(segments[1]) : null;
6096
+ const rowId = segments[2] !== void 0 ? decodeSegment(segments[2]) : null;
6097
+ if (collection === null || rowId === null || collection.length === 0 || rowId.length === 0) return null;
6098
+ return {
6099
+ scope: {
6100
+ kind: "row",
6101
+ collection,
6102
+ rowId
6103
+ },
6104
+ used: 3
6105
+ };
6106
+ }
6107
+ default: return null;
6108
+ }
6109
+ }
6110
+ /** Take a ref apart; `null` when it is not a well-formed ref. */
6111
+ function parseSecretRef(ref) {
6112
+ if (!ref.startsWith("secret://")) return null;
6113
+ const segments = ref.slice(9).split("/");
6114
+ const owner = segments[0] !== void 0 ? decodeSegment(segments[0]) : null;
6115
+ if (owner === null || owner.length === 0) return null;
6116
+ const parsed = parseScope(segments.slice(1));
6117
+ if (parsed === null) return null;
6118
+ const fieldPath = segments.slice(1 + parsed.used).join("/");
6119
+ if (fieldPath.length === 0) return null;
6120
+ return {
6121
+ owner,
6122
+ scope: parsed.scope,
6123
+ fieldPath
6124
+ };
6125
+ }
6126
+ /** A write to a secret path could not be stored in the keychain, so it was refused. */
6127
+ var KeychainWriteRefusedError = class extends Error {
6128
+ fieldPath;
6129
+ constructor(fieldPath, cause) {
6130
+ super(`secret "${fieldPath}" was not saved: the keychain could not store it (${cause instanceof Error ? cause.message : String(cause)}). Nothing was written.`);
6131
+ this.fieldPath = fieldPath;
6132
+ this.name = "KeychainWriteRefusedError";
6133
+ }
6134
+ };
6135
+ var KEEP = { kind: "keep" };
6136
+ function isRecord$1(value) {
6137
+ return typeof value === "object" && value !== null && !Array.isArray(value);
6138
+ }
6139
+ function defaultMintId() {
6140
+ return globalThis.crypto.randomUUID();
6141
+ }
6142
+ /** Every marker ref anywhere under `value`. */
6143
+ function collectSecretMarkerRefs(value, out = []) {
6144
+ if (isSecretMarker(value)) {
6145
+ out.push(value.$secret);
6146
+ return out;
6147
+ }
6148
+ if (Array.isArray(value)) for (const item of value) collectSecretMarkerRefs(item, out);
6149
+ else if (isRecord$1(value)) for (const child of Object.values(value)) collectSecretMarkerRefs(child, out);
6150
+ return out;
6151
+ }
6152
+ async function storedValueEquals(secrets, marker, candidate) {
6153
+ const resolved = (await secrets.resolve([marker.$secret]))[marker.$secret];
6154
+ return resolved?.kind === "value" && resolved.value === candidate;
6155
+ }
6156
+ async function writeLeaf(ctx, incoming, stored, fieldPath) {
6157
+ const intent = classifySecretWrite(incoming);
6158
+ const ref = ctx.secrets.ref(ctx.scope, fieldPath);
6159
+ const storedIsOurs = isSecretMarker(stored) && stored.$secret === ref;
6160
+ if (intent.kind === "keep") return KEEP;
6161
+ if (intent.kind === "set" && !ctx.operatorWrite && typeof stored === "string" && stored === intent.value) return KEEP;
6162
+ if (intent.kind === "clear") {
6163
+ if (storedIsOurs) ctx.deletes.push(ref);
6164
+ return {
6165
+ kind: "value",
6166
+ value: null
6167
+ };
6168
+ }
6169
+ if (storedIsOurs && await storedValueEquals(ctx.secrets, stored, intent.value)) return {
6170
+ kind: "value",
6171
+ value: stored
6172
+ };
6173
+ try {
6174
+ await ctx.secrets.put(ref, intent.value);
6175
+ } catch (err) {
6176
+ throw new KeychainWriteRefusedError(fieldPath, err);
6177
+ }
6178
+ return {
6179
+ kind: "value",
6180
+ value: makeSecretMarker(ref)
6181
+ };
6182
+ }
6183
+ /** Apply a member result onto `out`: KEEP restores the stored member, or removes it. */
6184
+ function applyMember(out, key, result, storedParent) {
6185
+ if (result.kind === "value") {
6186
+ out[key] = result.value;
6187
+ return;
6188
+ }
6189
+ if (Object.prototype.hasOwnProperty.call(storedParent, key)) out[key] = storedParent[key];
6190
+ else delete out[key];
6191
+ }
6192
+ async function writeMembers(ctx, children, incoming, stored, pathOf) {
6193
+ const out = { ...incoming };
6194
+ for (const [member, node] of children) applyMember(out, member, await writeNode(ctx, node, incoming[member], stored[member], pathOf(member)), stored);
6195
+ return out;
6196
+ }
6197
+ function rowId(row, idKey) {
6198
+ const raw = row[idKey];
6199
+ if (typeof raw === "string" && raw.length > 0) return raw;
6200
+ if (typeof raw === "number" && Number.isFinite(raw)) return String(raw);
6201
+ return null;
6202
+ }
6203
+ async function writeArray(ctx, node, incoming, stored, fieldPath) {
6204
+ const storedRows = Array.isArray(stored) ? stored.filter(isRecord$1) : [];
6205
+ if (!Array.isArray(incoming)) {
6206
+ ctx.deletes.push(...collectSecretMarkerRefs(storedRows));
6207
+ return {
6208
+ kind: "value",
6209
+ value: incoming
6210
+ };
6211
+ }
6212
+ const storedById = /* @__PURE__ */ new Map();
6213
+ for (const row of storedRows) {
6214
+ const id = rowId(row, node.idKey);
6215
+ if (id !== null) storedById.set(id, row);
6216
+ }
6217
+ const kept = /* @__PURE__ */ new Set();
6218
+ const rows = [];
6219
+ for (const row of incoming) {
6220
+ if (!isRecord$1(row)) {
6221
+ rows.push(row);
6222
+ continue;
6223
+ }
6224
+ const id = rowId(row, node.idKey) ?? ctx.mintId();
6225
+ kept.add(id);
6226
+ const withId = {
6227
+ ...row,
6228
+ [node.idKey]: row[node.idKey] ?? id
6229
+ };
6230
+ if (rowId(withId, node.idKey) === null) withId[node.idKey] = id;
6231
+ const storedRow = storedById.get(id) ?? {};
6232
+ rows.push(await writeMembers(ctx, node.item, withId, storedRow, (member) => arrayItemFieldPath(fieldPath, id, member)));
6233
+ }
6234
+ for (const [id, row] of storedById) if (!kept.has(id)) ctx.deletes.push(...collectSecretMarkerRefs(row));
6235
+ return {
6236
+ kind: "value",
6237
+ value: rows
6238
+ };
6239
+ }
6240
+ async function writeNode(ctx, node, incoming, stored, fieldPath) {
6241
+ switch (node.kind) {
6242
+ case "leaf": return writeLeaf(ctx, incoming, stored, fieldPath);
6243
+ case "array": return writeArray(ctx, node, incoming, stored, fieldPath);
6244
+ case "object": {
6245
+ if (!isRecord$1(incoming)) {
6246
+ if (incoming === void 0) return KEEP;
6247
+ ctx.deletes.push(...collectSecretMarkerRefs(stored));
6248
+ return {
6249
+ kind: "value",
6250
+ value: incoming
6251
+ };
6252
+ }
6253
+ const storedObj = isRecord$1(stored) ? stored : {};
6254
+ return {
6255
+ kind: "value",
6256
+ value: await writeMembers(ctx, node.children, incoming, storedObj, (m) => `${fieldPath}.${m}`)
6257
+ };
6258
+ }
6259
+ }
6260
+ }
6261
+ /** Split a perNode-scoped key (`key@nodeId`). */
6262
+ function splitNodeKey(key) {
6263
+ const at = key.indexOf("@");
6264
+ return at <= 0 ? {
6265
+ base: key,
6266
+ nodeId: null
6267
+ } : {
6268
+ base: key.slice(0, at),
6269
+ nodeId: key.slice(at + 1)
6270
+ };
6271
+ }
6272
+ /** Rewrite a settings patch so no secret value reaches the blob. See the file doc. */
6273
+ async function transformSecretWrite(input) {
6274
+ const deletes = [];
6275
+ const base = {
6276
+ secrets: input.secrets,
6277
+ mintId: input.mintId ?? defaultMintId,
6278
+ deletes,
6279
+ operatorWrite: input.operatorWrite === true
6280
+ };
6281
+ const out = {};
6282
+ for (const [key, incoming] of Object.entries(input.patch)) {
6283
+ const { base: baseKey, nodeId } = splitNodeKey(key);
6284
+ const node = input.tree.get(baseKey);
6285
+ if (node === void 0) {
6286
+ out[key] = incoming;
6287
+ continue;
6288
+ }
6289
+ const scope = nodeId !== null && nodeId.length > 0 ? {
6290
+ kind: "node",
6291
+ nodeId
6292
+ } : input.scope ?? globalSecretScope();
6293
+ const result = await writeNode({
6294
+ ...base,
6295
+ scope
6296
+ }, node, incoming, input.stored[key], baseKey);
6297
+ if (result.kind === "value") out[key] = result.value;
6298
+ }
6299
+ return {
6300
+ patch: out,
6301
+ afterWrite: async () => {
6302
+ if (deletes.length === 0) return { orphaned: [] };
6303
+ try {
6304
+ await input.secrets.delete([...new Set(deletes)]);
6305
+ return { orphaned: [] };
6306
+ } catch {
6307
+ return { orphaned: [...new Set(deletes)] };
6308
+ }
6309
+ }
6310
+ };
6311
+ }
6312
+ /** Is `ref` one of `owner`'s refs? */
6313
+ function isSecretRefOwnedBy(ref, owner) {
6314
+ return parseSecretRef(ref)?.owner === owner;
6315
+ }
6316
+ /**
6317
+ * Replace every marker in `value` with its keychain value. Returns the SAME
6318
+ * reference when there is no marker (no allocation, no keychain call).
6319
+ */
6320
+ async function resolveSecretMarkers(value, secrets, options = {}) {
6321
+ const keepMarker = options.unresolved === "keep-marker";
6322
+ const owner = options.ownedBy;
6323
+ const inScope = (ref) => owner === void 0 || isSecretRefOwnedBy(ref, owner);
6324
+ const refs = collectSecretMarkerRefs(value).filter(inScope);
6325
+ if (refs.length === 0) return {
6326
+ value,
6327
+ unresolved: []
6328
+ };
6329
+ const answers = await secrets.resolve(refs);
6330
+ const unresolved = [];
6331
+ for (const ref of new Set(refs)) {
6332
+ const answer = answers[ref];
6333
+ if (answer === void 0) unresolved.push({
6334
+ ref,
6335
+ reason: "not-initialized"
6336
+ });
6337
+ else if (answer.kind === "unavailable") unresolved.push({
6338
+ ref,
6339
+ reason: answer.reason
6340
+ });
6341
+ else if (answer.kind === "missing" || answer.kind === "forbidden") unresolved.push({
6342
+ ref,
6343
+ reason: answer.kind
6344
+ });
6345
+ }
6346
+ const substitute = (v) => {
6347
+ if (isSecretMarker(v)) {
6348
+ if (!inScope(v.$secret)) return {
6349
+ keep: true,
6350
+ value: v
6351
+ };
6352
+ const answer = answers[v.$secret];
6353
+ if (answer?.kind === "value") return {
6354
+ keep: true,
6355
+ value: answer.value
6356
+ };
6357
+ return keepMarker ? {
6358
+ keep: true,
6359
+ value: v
6360
+ } : {
6361
+ keep: false,
6362
+ value: void 0
6363
+ };
6364
+ }
6365
+ if (Array.isArray(v)) {
6366
+ const items = [];
6367
+ for (const item of v) {
6368
+ const s = substitute(item);
6369
+ if (s.keep) items.push(s.value);
6370
+ }
6371
+ return {
6372
+ keep: true,
6373
+ value: items
6374
+ };
6375
+ }
6376
+ if (isRecord$1(v)) {
6377
+ const out = {};
6378
+ for (const [k, child] of Object.entries(v)) {
6379
+ const s = substitute(child);
6380
+ if (s.keep) out[k] = s.value;
6381
+ }
6382
+ return {
6383
+ keep: true,
6384
+ value: out
6385
+ };
6386
+ }
6387
+ return {
6388
+ keep: true,
6389
+ value: v
6390
+ };
6391
+ };
6392
+ return {
6393
+ value: substitute(value).value,
6394
+ unresolved
6395
+ };
6396
+ }
6397
+ /** An addon tried to replace a stored secret it could not read. Nothing was written. */
6398
+ var SecretOverwriteRefusedError = class extends Error {
6399
+ ref;
6400
+ reason;
6401
+ constructor(ref, reason) {
6402
+ 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.`);
6403
+ this.ref = ref;
6404
+ this.reason = reason;
6405
+ this.name = "SecretOverwriteRefusedError";
6406
+ }
6407
+ };
6408
+ function isRecord(value) {
6409
+ return typeof value === "object" && value !== null && !Array.isArray(value);
6410
+ }
6411
+ function resolvedValue(pass, marker) {
6412
+ const answer = pass.answers[marker.$secret];
6413
+ return answer?.kind === "value" ? answer.value : null;
6414
+ }
6415
+ async function atMarker(pass, incoming, stored) {
6416
+ if (incoming === null) return stored;
6417
+ if (typeof incoming !== "string") return incoming;
6418
+ if (incoming === resolvedValue(pass, stored)) return stored;
6419
+ const intent = classifySecretWrite(incoming);
6420
+ if (intent.kind !== "set") return stored;
6421
+ const ref = stored.$secret;
6422
+ if (!isSecretRefOwnedBy(ref, pass.secrets.owner)) return incoming;
6423
+ const answer = pass.answers[ref];
6424
+ 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);
6425
+ try {
6426
+ await pass.secrets.put(ref, intent.value);
6427
+ } catch (err) {
6428
+ throw new KeychainWriteRefusedError(ref, err);
6429
+ }
6430
+ pass.changedRefs.push(ref);
6431
+ return stored;
6432
+ }
6433
+ function inArray(pass, incoming, stored) {
6434
+ return incoming.map((item, index) => {
6435
+ const twin = stored[index];
6436
+ if (isSecretMarker(twin)) return typeof item === "string" && item === resolvedValue(pass, twin) ? twin : item;
6437
+ if (isRecord(item) && isRecord(twin)) return inArrayRow(pass, item, twin);
6438
+ if (Array.isArray(item) && Array.isArray(twin)) return inArray(pass, item, twin);
6439
+ return item;
6440
+ });
6441
+ }
6442
+ function inArrayRow(pass, incoming, stored) {
6443
+ const out = { ...incoming };
6444
+ for (const [key, value] of Object.entries(incoming)) {
6445
+ const twin = stored[key];
6446
+ if (isSecretMarker(twin)) {
6447
+ if (typeof value === "string" && value === resolvedValue(pass, twin)) out[key] = twin;
6448
+ } else if (isRecord(value) && isRecord(twin)) out[key] = inArrayRow(pass, value, twin);
6449
+ else if (Array.isArray(value) && Array.isArray(twin)) out[key] = inArray(pass, value, twin);
6450
+ }
6451
+ return out;
6452
+ }
6453
+ async function walk(pass, incoming, stored) {
6454
+ if (isSecretMarker(stored)) return atMarker(pass, incoming, stored);
6455
+ if (Array.isArray(incoming) && Array.isArray(stored)) return inArray(pass, incoming, stored);
6456
+ if (!isRecord(incoming) || !isRecord(stored)) return incoming;
6457
+ const out = { ...incoming };
6458
+ for (const [key, value] of Object.entries(incoming)) out[key] = await walk(pass, value, stored[key]);
6459
+ return out;
6460
+ }
6461
+ /** Restore markers a write-back carries as values. See the file doc. */
6462
+ async function restoreUnchangedSecrets(input) {
6463
+ const refs = [];
6464
+ for (const key of Object.keys(input.patch)) collectSecretMarkerRefs(input.stored[key], refs);
6465
+ const owned = refs.filter((ref) => isSecretRefOwnedBy(ref, input.secrets.owner));
6466
+ if (owned.length === 0) return {
6467
+ patch: input.patch,
6468
+ changedRefs: []
6469
+ };
6470
+ const pass = {
6471
+ secrets: input.secrets,
6472
+ answers: await input.secrets.resolve([...new Set(owned)]),
6473
+ operatorWrite: input.operatorWrite,
6474
+ changedRefs: []
6475
+ };
6476
+ const out = {};
6477
+ for (const [key, value] of Object.entries(input.patch)) out[key] = await walk(pass, value, input.stored[key]);
6478
+ return {
6479
+ patch: out,
6480
+ changedRefs: pass.changedRefs
6481
+ };
6482
+ }
6483
+ /** Structural equality over JSON-shaped values (key order does not matter). */
6484
+ function isJsonEqual(a, b) {
6485
+ if (Object.is(a, b)) return true;
6486
+ if (Array.isArray(a)) return Array.isArray(b) && a.length === b.length && a.every((v, i) => isJsonEqual(v, b[i]));
6487
+ if (isRecord(a) && isRecord(b)) {
6488
+ const keys = Object.keys(a);
6489
+ if (keys.length !== Object.keys(b).length) return false;
6490
+ return keys.every((k) => Object.prototype.hasOwnProperty.call(b, k) && isJsonEqual(a[k], b[k]));
6491
+ }
6492
+ return false;
6493
+ }
6494
+ /** The patch without the keys whose value already equals the stored one. */
6495
+ function dropUnchangedKeys(patch, stored) {
6496
+ const out = {};
6497
+ for (const [key, value] of Object.entries(patch)) {
6498
+ if (Object.prototype.hasOwnProperty.call(stored, key) && isJsonEqual(value, stored[key])) continue;
6499
+ out[key] = value;
6500
+ }
6501
+ return out;
6502
+ }
6503
+ /** The top-level keys of a blob that hold at least one of `owner`'s markers. */
6504
+ function markerKeysOf(blob, owner) {
6505
+ const keys = /* @__PURE__ */ new Set();
6506
+ for (const [key, value] of Object.entries(blob)) if (collectSecretMarkerRefs(value).some((ref) => isSecretRefOwnedBy(ref, owner))) keys.add(key);
6507
+ return keys;
6508
+ }
6509
+ function nodeFromStored(value, owner) {
6510
+ if (isSecretMarker(value)) return isSecretRefOwnedBy(value.$secret, owner) ? { kind: "leaf" } : null;
6511
+ if (!isRecord(value)) return null;
6512
+ const children = /* @__PURE__ */ new Map();
6513
+ for (const [key, child] of Object.entries(value)) {
6514
+ const node = nodeFromStored(child, owner);
6515
+ if (node !== null) children.set(key, node);
6516
+ }
6517
+ return children.size > 0 ? {
6518
+ kind: "object",
6519
+ children
6520
+ } : null;
6521
+ }
6522
+ /**
6523
+ * The declared secret tree, widened by every place the STORED blob holds a
6524
+ * marker under one of `keys` — so a marker the schema no longer declares (or
6525
+ * never declared: Wyze before b4906cec6) still gets the save path's
6526
+ * KEEP / SET / CLEAR semantics instead of being overwritten by whatever the
6527
+ * addon writes. Markers inside arrays are not added: a row has no id field to
6528
+ * match by unless the schema declares one. Only `owner`'s markers count: a
6529
+ * builtin that keeps another addon's marker (device-manager) never takes it
6530
+ * over.
6531
+ */
6532
+ function widenTreeWithStoredMarkers(declared, stored, keys, owner) {
6533
+ const added = /* @__PURE__ */ new Map();
6534
+ for (const key of keys) {
6535
+ const at = key.indexOf("@");
6536
+ const base = at > 0 ? key.slice(0, at) : key;
6537
+ if (declared.has(base) || added.has(base)) continue;
6538
+ const node = nodeFromStored(stored[key], owner);
6539
+ if (node !== null) added.set(base, node);
6540
+ }
6541
+ return added.size === 0 ? declared : new Map([...declared, ...added]);
6542
+ }
6543
+ /** The blob as stored now; a failed read REFUSES the write instead of guessing. */
6544
+ async function readStoredAddonBlob(raw) {
6545
+ const threeWay = raw.readAddonStoreResult;
6546
+ if (threeWay === void 0) return raw.readAddonStore();
6547
+ const result = await threeWay.call(raw);
6548
+ if (result.kind === "failed") throw new Error(`settings write refused: the stored blob could not be read (${result.error})`);
6549
+ return result.kind === "missing" ? {} : result.value;
6550
+ }
6551
+ function touchesTree(tree, patch) {
6552
+ if (tree.size === 0) return false;
6553
+ for (const key of Object.keys(patch)) {
6554
+ const at = key.indexOf("@");
6555
+ if (tree.has(at > 0 ? key.slice(0, at) : key)) return true;
6556
+ }
6557
+ return false;
6558
+ }
6559
+ /**
6560
+ * Which top-level keys of each store held markers when last seen. `undefined`
6561
+ * for a store not seen yet: its first write reads it, to be safe.
6562
+ */
6563
+ var MarkerKeyIndex = class {
6564
+ owner;
6565
+ byStore = /* @__PURE__ */ new Map();
6566
+ constructor(owner) {
6567
+ this.owner = owner;
6568
+ }
6569
+ seen(store, blob) {
6570
+ this.byStore.set(store, markerKeysOf(blob, this.owner));
6571
+ }
6572
+ wrote(store, patch) {
6573
+ const keys = this.byStore.get(store);
6574
+ if (keys === void 0) return;
6575
+ const now = markerKeysOf(patch, this.owner);
6576
+ for (const key of Object.keys(patch)) if (now.has(key)) keys.add(key);
6577
+ else keys.delete(key);
6578
+ }
6579
+ mayHoldMarkers(store, patch) {
6580
+ const keys = this.byStore.get(store);
6581
+ if (keys === void 0) return true;
6582
+ return Object.keys(patch).some((key) => keys.has(key));
6583
+ }
6584
+ };
6585
+ function createHandle(raw, opts) {
6586
+ const chains = /* @__PURE__ */ new Map();
6587
+ const serialize = (key, fn) => {
6588
+ const next = (chains.get(key) ?? Promise.resolve()).then(fn, fn);
6589
+ const tail = next.catch(() => void 0);
6590
+ chains.set(key, tail);
6591
+ tail.then(() => {
6592
+ if (chains.get(key) === tail) chains.delete(key);
6593
+ });
6594
+ return next;
6595
+ };
6596
+ const index = new MarkerKeyIndex(opts.secrets.owner);
6597
+ const resolveRead = async (store, blob) => {
6598
+ index.seen(store, blob);
6599
+ const { value, unresolved } = await resolveSecretMarkers(blob, opts.secrets, {
6600
+ unresolved: "keep-marker",
6601
+ ownedBy: opts.secrets.owner
6602
+ });
6603
+ if (unresolved.length > 0) opts.onUnresolved?.(unresolved);
6604
+ return value;
6605
+ };
6606
+ const write = async (store, declared, scope, patch, readStored, rawWrite) => {
6607
+ if (!touchesTree(declared, patch) && !index.mayHoldMarkers(store, patch)) {
6608
+ await rawWrite(patch);
6609
+ index.wrote(store, patch);
6610
+ return { changed: true };
6611
+ }
6612
+ return serialize(store, async () => {
6613
+ const stored = await readStored();
6614
+ index.seen(store, stored);
6615
+ const operatorWrite = opts.isOperatorWrite?.() === true;
6616
+ const restored = await restoreUnchangedSecrets({
6617
+ patch,
6618
+ stored,
6619
+ secrets: opts.secrets,
6620
+ operatorWrite
6621
+ });
6622
+ const result = await transformSecretWrite({
6623
+ tree: widenTreeWithStoredMarkers(declared, stored, Object.keys(restored.patch), opts.secrets.owner),
6624
+ secrets: opts.secrets,
6625
+ patch: restored.patch,
6626
+ stored,
6627
+ ...scope !== void 0 ? { scope } : {},
6628
+ operatorWrite
6629
+ });
6630
+ const effective = dropUnchangedKeys(result.patch, stored);
6631
+ const wroteBlob = Object.keys(effective).length > 0;
6632
+ if (wroteBlob) {
6633
+ await rawWrite(effective);
6634
+ index.wrote(store, effective);
6635
+ }
6636
+ const { orphaned } = await result.afterWrite();
6637
+ if (orphaned.length > 0) opts.onOrphaned(orphaned);
6638
+ return { changed: wroteBlob || restored.changedRefs.length > 0 };
6639
+ });
6640
+ };
6641
+ const writeAddon = (patch) => write("addon", opts.addonTree(), void 0, patch, () => readStoredAddonBlob(raw), (p) => raw.writeAddonStore(p));
6642
+ const readAddonStoreResult = raw.readAddonStoreResult;
6643
+ const readAddonStoreKeyResult = raw.readAddonStoreKeyResult;
6644
+ const readDeviceStoreBatch = raw.readDeviceStoreBatch;
6645
+ const overrides = {
6646
+ readAddonStore: async () => resolveRead("addon", await raw.readAddonStore()),
6647
+ ...readAddonStoreResult !== void 0 ? { readAddonStoreResult: async () => {
6648
+ const result = await readAddonStoreResult.call(raw);
6649
+ return result.kind === "value" ? {
6650
+ kind: "value",
6651
+ value: await resolveRead("addon", result.value)
6652
+ } : result;
6653
+ } } : {},
6654
+ ...readAddonStoreKeyResult !== void 0 ? { readAddonStoreKeyResult: async (key) => {
6655
+ const result = await readAddonStoreKeyResult.call(raw, key);
6656
+ if (result.kind !== "present") return result;
6657
+ const { value, unresolved } = await resolveSecretMarkers({ [key]: result.value }, opts.secrets, {
6658
+ unresolved: "keep-marker",
6659
+ ownedBy: opts.secrets.owner
6660
+ });
6661
+ if (unresolved.length > 0) opts.onUnresolved?.(unresolved);
6662
+ return {
6663
+ kind: "present",
6664
+ value: value[key]
6665
+ };
6666
+ } } : {},
6667
+ readDeviceStore: async (deviceId) => resolveRead(`device:${deviceId}`, await raw.readDeviceStore(deviceId)),
6668
+ ...readDeviceStoreBatch !== void 0 ? { readDeviceStoreBatch: async (deviceIds) => {
6669
+ const rows = await readDeviceStoreBatch.call(raw, deviceIds);
6670
+ const out = /* @__PURE__ */ new Map();
6671
+ for (const [deviceId, blob] of rows) out.set(deviceId, await resolveRead(`device:${deviceId}`, blob));
6672
+ return out;
6673
+ } } : {},
6674
+ writeAddonStore: async (patch) => {
6675
+ await writeAddon(patch);
6676
+ },
6677
+ writeDeviceStore: async (deviceId, patch) => {
6678
+ await write(`device:${deviceId}`, opts.deviceTree(), {
6679
+ kind: "device",
6680
+ deviceId
6681
+ }, patch, () => raw.readDeviceStore(deviceId), (p) => raw.writeDeviceStore(deviceId, p));
6682
+ }
6683
+ };
6684
+ return {
6685
+ settings: new Proxy(raw, { get(target, prop, receiver) {
6686
+ if (typeof prop === "string" && Object.prototype.hasOwnProperty.call(overrides, prop)) return Reflect.get(overrides, prop);
6687
+ const value = Reflect.get(target, prop, receiver);
6688
+ return typeof value === "function" ? value.bind(target) : value;
6689
+ } }),
6690
+ raw: {
6691
+ readAddonStore: async () => {
6692
+ const blob = await raw.readAddonStore();
6693
+ index.seen("addon", blob);
6694
+ return blob;
6695
+ },
6696
+ readDeviceStore: async (deviceId) => {
6697
+ const blob = await raw.readDeviceStore(deviceId);
6698
+ index.seen(`device:${deviceId}`, blob);
6699
+ return blob;
6700
+ }
6701
+ },
6702
+ writeAddonStore: writeAddon
6703
+ };
6704
+ }
6705
+ /** The context the addon sees, plus the private raw view and write outcome. */
6706
+ function createSecretAwareContext(context, opts) {
6707
+ const raw = context.settings;
6708
+ if (raw === void 0) return {
6709
+ context,
6710
+ handle: null
6711
+ };
6712
+ const handle = createHandle(raw, opts);
6713
+ return {
6714
+ context: new Proxy(context, { get(target, prop, receiver) {
6715
+ if (prop === "settings") return handle.settings;
6716
+ return Reflect.get(target, prop, receiver);
6717
+ } }),
6718
+ handle
6719
+ };
6720
+ }
6721
+ var LEAF = { kind: "leaf" };
6722
+ var DEFAULT_ITEM_ID_KEY = "id";
6723
+ function collectFields(fields, out) {
6724
+ for (const field of fields) {
6725
+ if (field.type === "group") {
6726
+ collectFields(field.fields, out);
6727
+ continue;
6728
+ }
6729
+ if (field.type === "sub-tabs") {
6730
+ for (const tab of field.tabs) collectFields(tab.fields, out);
6731
+ continue;
6732
+ }
6733
+ if (field.type === "editable-array") {
6734
+ const item = /* @__PURE__ */ new Map();
6735
+ for (const itemField of field.itemFields) if ("key" in itemField && isKeychainStoredField(itemField)) item.set(itemField.key, LEAF);
6736
+ if (item.size > 0) out.set(field.key, {
6737
+ kind: "array",
6738
+ idKey: field.itemIdKey ?? DEFAULT_ITEM_ID_KEY,
6739
+ item
6740
+ });
6741
+ continue;
6742
+ }
6743
+ if (!("key" in field) || typeof field.key !== "string") continue;
6744
+ if (isKeychainStoredField(field)) out.set(field.key, LEAF);
6745
+ }
6746
+ }
6747
+ /** The secret tree a settings schema declares. */
6748
+ function secretTreeFromSchema(schema) {
6749
+ const out = /* @__PURE__ */ new Map();
6750
+ if (schema === null) return out;
6751
+ for (const section of schema.sections) collectFields(section.fields, out);
6752
+ return out;
6753
+ }
6754
+ /** Parse `a.b[id].c` into segments; throws on a malformed path (a declaration bug). */
6755
+ function parseSecretStatePath(path) {
6756
+ const segments = [];
6757
+ for (const raw of path.split(".")) {
6758
+ const m = /^([^[\]]+)(?:\[([^[\]]+)\])?$/.exec(raw);
6759
+ if (m === null || m[1] === void 0) throw new Error(`secretStatePaths: malformed path "${path}"`);
6760
+ segments.push(m[2] !== void 0 ? {
6761
+ key: m[1],
6762
+ idKey: m[2]
6763
+ } : { key: m[1] });
6764
+ }
6765
+ if (segments.length === 0) throw new Error(`secretStatePaths: empty path`);
6766
+ if (segments[segments.length - 1]?.idKey !== void 0) throw new Error(`secretStatePaths: "${path}" ends on an array — name the member that is secret`);
6767
+ return segments;
6768
+ }
6769
+ function insert(into, segments) {
6770
+ const [head, ...rest] = segments;
6771
+ if (head === void 0) return;
6772
+ if (rest.length === 0) {
6773
+ into.set(head.key, LEAF);
6774
+ return;
6775
+ }
6776
+ const existing = into.get(head.key);
6777
+ if (head.idKey !== void 0) {
6778
+ const item = new Map(existing?.kind === "array" ? existing.item : []);
6779
+ insert(item, rest);
6780
+ into.set(head.key, {
6781
+ kind: "array",
6782
+ idKey: head.idKey,
6783
+ item
6784
+ });
6785
+ return;
6786
+ }
6787
+ const children = new Map(existing?.kind === "object" ? existing.children : []);
6788
+ insert(children, rest);
6789
+ into.set(head.key, {
6790
+ kind: "object",
6791
+ children
6792
+ });
6793
+ }
6794
+ /** Add hidden-state paths (`secretStatePaths`) to a schema-derived tree. */
6795
+ function mergeSecretStatePaths(tree, paths) {
6796
+ if (paths.length === 0) return tree;
6797
+ const out = new Map(tree);
6798
+ for (const path of paths) insert(out, parseSecretStatePath(path));
6799
+ return out;
6800
+ }
6801
+ /** First retry of a secret the keychain could not serve; doubles to {@link SECRET_RETRY_MAX_MS}. */
6802
+ var SECRET_RETRY_FIRST_MS = 5e3;
6803
+ var SECRET_RETRY_MAX_MS = 5 * 6e4;
6804
+ /** Coalesces a burst of `keychain.changed` events into one re-resolve. */
6805
+ var SECRET_CHANGE_DEBOUNCE_MS = 250;
5923
6806
  /**
5924
6807
  * Base class for CamStack addons. Eliminates settings boilerplate:
5925
6808
  *
@@ -5989,6 +6872,33 @@ var BaseAddon = class {
5989
6872
  settingsStoreReady = false;
5990
6873
  /** Default config values. Provided via constructor. */
5991
6874
  defaults;
6875
+ /**
6876
+ * Hidden-state paths that hold secrets (D787) — values the addon writes
6877
+ * itself (`updateGlobalSettings`, `state()`) that no form field declares.
6878
+ * Stored in the keychain exactly like a `password` field. Syntax:
6879
+ * `'snapshotSigningKey'`, `'identity.pincode'`, `'tokens[userId].accessToken'`
6880
+ * (`key[<id field>]` addresses array items by id, never by index).
6881
+ */
6882
+ secretStatePaths = [];
6883
+ _addonSecretTree = null;
6884
+ _deviceSecretTree = null;
6885
+ /** Refs the last resolved config pointed at — a change to one re-resolves. */
6886
+ _configSecretRefs = /* @__PURE__ */ new Set();
6887
+ _unresolvedSecrets = [];
6888
+ _secretRetryTimer = null;
6889
+ _secretRetryDelayMs = SECRET_RETRY_FIRST_MS;
6890
+ _secretChangeTimer = null;
6891
+ _secretChangeUnsub = null;
6892
+ /** >0 while an OPERATOR's settings write is being applied. */
6893
+ _operatorWriteDepth = 0;
6894
+ /**
6895
+ * The keychain-aware settings handle (D798). Its `raw` view is the ONLY way
6896
+ * to the marker-bearing blobs and stays private to this class: the form
6897
+ * hydrate and config resolution need markers, addon code never does.
6898
+ */
6899
+ _secretSettings = null;
6900
+ /** Refs an addon-facing read could not resolve — each is logged once per process. */
6901
+ _loggedUnresolvedReads = /* @__PURE__ */ new Set();
5992
6902
  constructor(defaults) {
5993
6903
  this.defaults = defaults;
5994
6904
  this._config = { ...defaults };
@@ -6024,8 +6934,26 @@ var BaseAddon = class {
6024
6934
  return this._config;
6025
6935
  }
6026
6936
  async initialize(context) {
6027
- this._ctx = context;
6937
+ const secrets = context.secrets;
6938
+ if (secrets !== void 0) {
6939
+ const { context: wrapped, handle } = createSecretAwareContext(context, {
6940
+ secrets,
6941
+ addonTree: () => this.addonSecretTree(),
6942
+ deviceTree: () => this.deviceSecretTree(),
6943
+ onOrphaned: (refs) => context.logger.warn("keychain refs dropped by a settings write could not be deleted", { meta: { refs: [...refs] } }),
6944
+ isOperatorWrite: () => this._operatorWriteDepth > 0,
6945
+ onUnresolved: (unresolved) => this.logUnresolvedRead(unresolved)
6946
+ });
6947
+ this._ctx = wrapped;
6948
+ this._secretSettings = handle;
6949
+ } else {
6950
+ this._ctx = context;
6951
+ this._secretSettings = null;
6952
+ }
6028
6953
  await this.resolveConfig();
6954
+ if (secrets !== void 0) this._secretChangeUnsub = secrets.onChange((ref) => {
6955
+ if (this._configSecretRefs.has(ref)) this.scheduleSecretReresolve(SECRET_CHANGE_DEBOUNCE_MS);
6956
+ });
6029
6957
  const result = await this.onInitialize();
6030
6958
  this.emitLifecycle(EventCategory.AddonStarted);
6031
6959
  const normalized = normalizeAddonInitResult(result);
@@ -6058,6 +6986,12 @@ var BaseAddon = class {
6058
6986
  */
6059
6987
  async onHubReachable() {}
6060
6988
  async shutdown() {
6989
+ this._secretChangeUnsub?.();
6990
+ this._secretChangeUnsub = null;
6991
+ if (this._secretRetryTimer !== null) clearTimeout(this._secretRetryTimer);
6992
+ if (this._secretChangeTimer !== null) clearTimeout(this._secretChangeTimer);
6993
+ this._secretRetryTimer = null;
6994
+ this._secretChangeTimer = null;
6061
6995
  this.emitLifecycle(EventCategory.AddonStopped);
6062
6996
  if (this.autoEmitReadiness) this.emitReadinessForProviders("down");
6063
6997
  await this.onShutdown();
@@ -6132,11 +7066,8 @@ var BaseAddon = class {
6132
7066
  async getGlobalSettings(overlay, cap, nodeId) {
6133
7067
  const schema = this.globalSettingsSchema(cap);
6134
7068
  if (!schema) return { sections: [] };
6135
- const projected = await this.resolveGlobalStore(nodeId, cap);
6136
- return hydrateSchema(schema, overlay ? {
6137
- ...projected,
6138
- ...overlay
6139
- } : projected);
7069
+ const projected = await this.readRawProjectedStore(nodeId, cap);
7070
+ return hydrateSchema(schema, overlay ? await this.overlayKeepingMarkers(projected, overlay) : projected, { inlineSecretsAsViews: true });
6140
7071
  }
6141
7072
  /**
6142
7073
  * The integration-level view of this addon's settings: exactly the sections
@@ -6181,11 +7112,11 @@ var BaseAddon = class {
6181
7112
  });
6182
7113
  }
6183
7114
  if (sections.length === 0) return null;
6184
- const projected = await this.resolveGlobalStore(nodeId);
7115
+ const projected = await this.readRawProjectedStore(nodeId);
6185
7116
  return hydrateSchema({
6186
7117
  ...schema,
6187
7118
  sections
6188
- }, projected);
7119
+ }, projected, { inlineSecretsAsViews: true });
6189
7120
  }
6190
7121
  /**
6191
7122
  * The raw addon store PROJECTED onto the target node's bare per-node keys:
@@ -6198,12 +7129,50 @@ var BaseAddon = class {
6198
7129
  * the store for custom option logic (option narrowing, value snapping) to
6199
7130
  * read it per-node — never `ctx.settings.readAddonStore()` directly.
6200
7131
  * `nodeId` omitted ⇒ the local node (node-blind injection from ctx).
7132
+ *
7133
+ * Keychain values come back RESOLVED (D798): a secret reads as its value,
7134
+ * never as a `{ $secret }` marker. One the keychain cannot serve right now
7135
+ * stays a marker — "stored, unavailable" (`isSecretMarker()` is true, and it
7136
+ * is listed in {@link unresolvedSecrets}) — never `''` and never absent, so
7137
+ * it cannot be mistaken for "nothing stored, mint a new one". Writing the
7138
+ * resolved blob back is a no-op for every unchanged secret.
6201
7139
  */
6202
7140
  async resolveGlobalStore(nodeId, cap) {
6203
7141
  const raw = await this._ctx?.settings?.readAddonStore() ?? {};
7142
+ return this.projectForNode(raw, nodeId, cap);
7143
+ }
7144
+ projectForNode(store, nodeId, cap) {
6204
7145
  const keys = this.perNodeKeys(cap);
6205
7146
  const node = normalizeNodeId(nodeId ?? this._ctx?.kernel?.localNodeId);
6206
- return keys.size > 0 ? projectStore(raw, keys, node) : raw;
7147
+ return keys.size > 0 ? projectStore(store, keys, node) : store;
7148
+ }
7149
+ /** The PROJECTED store with its markers — the form hydrate only (D798). */
7150
+ async readRawProjectedStore(nodeId, cap) {
7151
+ const raw = await this.rawSettings()?.readAddonStore() ?? {};
7152
+ return this.projectForNode(raw, nodeId, cap);
7153
+ }
7154
+ /**
7155
+ * `{ ...stored, ...overlay }`, except that an overlay member equal to the
7156
+ * RESOLVED stored one keeps the stored (marker-bearing) member — so a form
7157
+ * hydrated from a resolved overlay still shows a secret as "set", never as
7158
+ * its value.
7159
+ */
7160
+ async overlayKeepingMarkers(stored, overlay) {
7161
+ const secrets = this._ctx?.secrets;
7162
+ const merged = {
7163
+ ...stored,
7164
+ ...overlay
7165
+ };
7166
+ if (secrets === void 0 || collectSecretMarkerRefs(stored).length === 0) return merged;
7167
+ const { value: resolved } = await resolveSecretMarkers(stored, secrets, {
7168
+ unresolved: "keep-marker",
7169
+ ownedBy: secrets.owner
7170
+ });
7171
+ for (const key of Object.keys(overlay)) {
7172
+ if (collectSecretMarkerRefs(stored[key]).length === 0) continue;
7173
+ if (isJsonEqual(overlay[key], resolved[key])) merged[key] = stored[key];
7174
+ }
7175
+ return merged;
6207
7176
  }
6208
7177
  /**
6209
7178
  * Whether ONE global key of this addon's store was written, read three-way
@@ -6239,18 +7208,58 @@ var BaseAddon = class {
6239
7208
  value: result.value[key]
6240
7209
  };
6241
7210
  }
7211
+ /**
7212
+ * The OPERATOR's write — a settings form or an admin API call, dispatched by
7213
+ * the kernel. Identical to {@link updateGlobalSettings}, except that a secret
7214
+ * the operator sends is stored as sent even when it equals a pre-keychain
7215
+ * inline value: the operator re-entering a password is a change, an addon
7216
+ * writing back what it read is not (D787).
7217
+ */
7218
+ async updateGlobalSettingsAsOperator(patch, nodeId) {
7219
+ this._operatorWriteDepth++;
7220
+ try {
7221
+ await this.applyGlobalPatch(patch, nodeId);
7222
+ } finally {
7223
+ this._operatorWriteDepth--;
7224
+ }
7225
+ }
6242
7226
  async updateGlobalSettings(patch, nodeId) {
7227
+ await this.applyGlobalPatch(patch, nodeId);
7228
+ }
7229
+ /**
7230
+ * REMOVE stored secrets — their keychain values and their markers (D787).
7231
+ *
7232
+ * Writing `''` to a secret field KEEPS what is stored (an empty string is
7233
+ * what a defaults fallback writes back, and it must never destroy a
7234
+ * credential), so code that means "forget this token" says so here. Without
7235
+ * a keychain (an older kernel) it writes `''`, as such code always did.
7236
+ */
7237
+ async clearSecrets(keys, nodeId) {
7238
+ const tree = this.addonSecretTree();
7239
+ const keychain = this._ctx?.secrets !== void 0;
7240
+ const stored = keychain ? await this.readAddonStoreWithRetry() : {};
7241
+ const patch = {};
7242
+ for (const key of keys) {
7243
+ const keychainStored = tree.has(key) || collectSecretMarkerRefs(stored[key]).length > 0;
7244
+ patch[key] = keychain && keychainStored ? SECRET_CLEAR : "";
7245
+ }
7246
+ await this.applyGlobalPatch(patch, nodeId);
7247
+ }
7248
+ async applyGlobalPatch(barePatch, nodeId) {
6243
7249
  const keys = this.perNodeKeys();
6244
7250
  const localNode = normalizeNodeId(this._ctx?.kernel?.localNodeId);
6245
7251
  const target = normalizeNodeId(nodeId ?? this._ctx?.kernel?.localNodeId);
6246
- const barePatch = patch;
6247
7252
  const scoped = keys.size > 0 ? scopePatch(barePatch, keys, target) : barePatch;
6248
- await this._ctx?.settings?.writeAddonStore(scoped);
7253
+ const handle = this._secretSettings;
7254
+ if (handle !== null) {
7255
+ const { changed } = await handle.writeAddonStore(scoped);
7256
+ if (!changed) return;
7257
+ } else await this._ctx?.settings?.writeAddonStore(scoped);
6249
7258
  if (target !== localNode) return;
6250
7259
  await this.resolveConfig();
6251
7260
  await this.onConfigChanged();
6252
7261
  this.emitLifecycle(EventCategory.AddonUpdated, { level: "global" });
6253
- this.maybeAutoRestart(patch, this.globalSettingsSchema());
7262
+ this.maybeAutoRestart(Object.keys(barePatch), this.globalSettingsSchema());
6254
7263
  }
6255
7264
  /**
6256
7265
  * The set of field keys the global settings schema declares `perNode: true`
@@ -6275,7 +7284,7 @@ var BaseAddon = class {
6275
7284
  * time to return its response before the addon is torn down and
6276
7285
  * re-initialised by `AddonRegistryService.restartAddon`.
6277
7286
  */
6278
- maybeAutoRestart(patch, schema) {
7287
+ maybeAutoRestart(patchKeys, schema) {
6279
7288
  if (!schema) return;
6280
7289
  const restartKeys = /* @__PURE__ */ new Set();
6281
7290
  for (const section of schema.sections) for (const field of section.fields) {
@@ -6283,13 +7292,13 @@ var BaseAddon = class {
6283
7292
  if (field.requiresRestart) restartKeys.add(field.key);
6284
7293
  }
6285
7294
  if (restartKeys.size === 0) return;
6286
- if (!Object.keys(patch).some((k) => restartKeys.has(k))) return;
7295
+ if (!patchKeys.some((k) => restartKeys.has(k))) return;
6287
7296
  const ctx = this._ctx;
6288
7297
  if (!ctx) return;
6289
7298
  const addonId = ctx.id;
6290
7299
  setImmediate(() => {
6291
7300
  ctx.api.addons?.restartAddon?.mutate({ addonId }).then(() => {
6292
- ctx.logger.info("addon auto-restart triggered by restart-required setting change", { meta: { changedFields: Object.keys(patch).filter((k) => restartKeys.has(k)) } });
7301
+ ctx.logger.info("addon auto-restart triggered by restart-required setting change", { meta: { changedFields: patchKeys.filter((k) => restartKeys.has(k)) } });
6293
7302
  }).catch((err) => {
6294
7303
  ctx.logger.error("addon auto-restart failed", { meta: { error: err instanceof Error ? err.message : String(err) } });
6295
7304
  });
@@ -6298,7 +7307,7 @@ var BaseAddon = class {
6298
7307
  async getDeviceSettings(deviceId) {
6299
7308
  const schema = this.deviceSettingsSchema();
6300
7309
  if (!schema) return { sections: [] };
6301
- return hydrateSchema(schema, await this._ctx?.settings?.readDeviceStore(deviceId) ?? {});
7310
+ return hydrateSchema(schema, await this.rawSettings()?.readDeviceStore(deviceId) ?? {}, { inlineSecretsAsViews: true });
6302
7311
  }
6303
7312
  async updateDeviceSettings(deviceId, patch) {
6304
7313
  await this._ctx?.settings?.writeDeviceStore(deviceId, patch);
@@ -6428,7 +7437,7 @@ var BaseAddon = class {
6428
7437
  * selection at boot (absent scoped key ⇒ the constructor default wins).
6429
7438
  */
6430
7439
  async resolveConfig() {
6431
- const stored = await this.readAddonStoreWithRetry();
7440
+ const stored = await this.resolveStoredSecrets(await this.readAddonStoreWithRetry());
6432
7441
  const perNode = this.perNodeKeys();
6433
7442
  const localNode = normalizeNodeId(this._ctx?.kernel?.localNodeId);
6434
7443
  const resolved = { ...this.defaults };
@@ -6453,7 +7462,7 @@ var BaseAddon = class {
6453
7462
  key,
6454
7463
  schema,
6455
7464
  fallback,
6456
- read: () => this.readAddonStoreWithRetry(),
7465
+ read: async () => this.resolveStoredSecrets(await this.readAddonStoreWithRetry()),
6457
7466
  write: async (patch) => {
6458
7467
  await this._ctx?.settings?.writeAddonStore(patch);
6459
7468
  },
@@ -6470,7 +7479,7 @@ var BaseAddon = class {
6470
7479
  key,
6471
7480
  schema,
6472
7481
  fallback,
6473
- read: async () => await this._ctx?.settings?.readDeviceStore(deviceId) ?? {},
7482
+ read: async () => this.resolveStoredSecrets(await this.rawSettings()?.readDeviceStore(deviceId) ?? {}, false),
6474
7483
  write: async (patch) => {
6475
7484
  await this._ctx?.settings?.writeDeviceStore(deviceId, patch);
6476
7485
  },
@@ -6482,6 +7491,87 @@ var BaseAddon = class {
6482
7491
  } })
6483
7492
  });
6484
7493
  }
7494
+ /** The addon store's secret tree: schema fields by TYPE, plus `secretStatePaths`. */
7495
+ addonSecretTree() {
7496
+ this._addonSecretTree ??= mergeSecretStatePaths(secretTreeFromSchema(this.globalSettingsSchema()), this.secretStatePaths);
7497
+ return this._addonSecretTree;
7498
+ }
7499
+ deviceSecretTree() {
7500
+ this._deviceSecretTree ??= secretTreeFromSchema(this.deviceSettingsSchema());
7501
+ return this._deviceSecretTree;
7502
+ }
7503
+ /**
7504
+ * Secrets of this addon's stored config that could not be resolved on the
7505
+ * last read, with why. Non-empty means the addon is running WITHOUT them —
7506
+ * an addon whose function needs one should report itself degraded rather
7507
+ * than start on an empty credential.
7508
+ */
7509
+ get unresolvedSecrets() {
7510
+ return this._unresolvedSecrets;
7511
+ }
7512
+ /**
7513
+ * Substitute every keychain marker in a stored blob with its value. With no
7514
+ * keychain (no `ctx.secrets`) or no marker, the blob comes back unchanged.
7515
+ * An unresolvable value is LEFT OUT (never `''`), logged by ref — never by
7516
+ * value — and, when the cause can pass, retried with backoff. Nothing is
7517
+ * ever written back from here.
7518
+ */
7519
+ async resolveStoredSecrets(blob, trackForConfig = true) {
7520
+ const secrets = this._ctx?.secrets;
7521
+ if (secrets === void 0) return blob;
7522
+ const refs = collectSecretMarkerRefs(blob);
7523
+ if (trackForConfig) this._configSecretRefs = new Set(refs);
7524
+ if (refs.length === 0) {
7525
+ if (trackForConfig) this._unresolvedSecrets = [];
7526
+ return blob;
7527
+ }
7528
+ const { value, unresolved } = await resolveSecretMarkers(blob, secrets);
7529
+ if (trackForConfig) {
7530
+ this._unresolvedSecrets = unresolved;
7531
+ if (unresolved.length > 0) {
7532
+ this._ctx?.logger?.error?.("secret unavailable — running without it, will retry", { meta: { secrets: unresolved.map((u) => ({
7533
+ ref: u.ref,
7534
+ reason: u.reason
7535
+ })) } });
7536
+ if (unresolved.some((u) => u.reason !== "missing" && u.reason !== "forbidden")) {
7537
+ this.scheduleSecretReresolve(this._secretRetryDelayMs);
7538
+ this._secretRetryDelayMs = Math.min(this._secretRetryDelayMs * 2, SECRET_RETRY_MAX_MS);
7539
+ }
7540
+ } else this._secretRetryDelayMs = SECRET_RETRY_FIRST_MS;
7541
+ }
7542
+ return value;
7543
+ }
7544
+ /**
7545
+ * The marker-bearing settings reads (D798) — private on purpose. Without a
7546
+ * keychain the context's own view is already raw.
7547
+ */
7548
+ rawSettings() {
7549
+ return this._secretSettings?.raw ?? this._ctx?.settings;
7550
+ }
7551
+ /** An addon-facing read met markers it could not resolve: say so once per ref. */
7552
+ logUnresolvedRead(unresolved) {
7553
+ const fresh = unresolved.filter((u) => !this._loggedUnresolvedReads.has(u.ref));
7554
+ if (fresh.length === 0) return;
7555
+ for (const u of fresh) this._loggedUnresolvedReads.add(u.ref);
7556
+ 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) => ({
7557
+ ref: u.ref,
7558
+ reason: u.reason
7559
+ })) } });
7560
+ }
7561
+ /** Re-resolve the config (a keychain-only change, or a retry) and apply it. */
7562
+ scheduleSecretReresolve(delayMs) {
7563
+ const timerOf = delayMs === SECRET_CHANGE_DEBOUNCE_MS ? "_secretChangeTimer" : "_secretRetryTimer";
7564
+ if (this[timerOf] !== null) return;
7565
+ const timer = setTimeout(() => {
7566
+ this[timerOf] = null;
7567
+ if (this._ctx === null) return;
7568
+ this.resolveConfig().then(() => this.onConfigChanged()).catch((err) => {
7569
+ this._ctx?.logger?.error?.("re-resolving secrets failed", { meta: { error: err instanceof Error ? err.message : String(err) } });
7570
+ });
7571
+ }, delayMs);
7572
+ timer.unref?.();
7573
+ this[timerOf] = timer;
7574
+ }
6485
7575
  /**
6486
7576
  * Wrap `ctx.settings.readAddonStore()` with a short retry budget so a
6487
7577
  * transient settings-store outage (mid-restart of sqlite-settings, tsx-watch
@@ -6494,7 +7584,7 @@ var BaseAddon = class {
6494
7584
  * `{}` (defaults) — the addon's first successful patch will rehydrate.
6495
7585
  */
6496
7586
  async readAddonStoreWithRetry() {
6497
- const settings = this._ctx?.settings;
7587
+ const settings = this.rawSettings();
6498
7588
  if (!settings) return {};
6499
7589
  const delaysMs = [
6500
7590
  150,
@@ -7069,6 +8159,69 @@ method(object({ deviceId: number() }), array(StreamSourceEntrySchema)), method(o
7069
8159
  kind: "mutation",
7070
8160
  auth: "admin"
7071
8161
  }), method(object({ deviceId: number() }), unknown().nullable()), method(object({ deviceId: number() }), RawStateResultSchema.nullable(), { auth: "protected" });
8162
+ function defOf(schema) {
8163
+ return schema._zod?.def ?? {};
8164
+ }
8165
+ function declaredHere(schema) {
8166
+ return globalRegistry.get(schema)?.secret === true;
8167
+ }
8168
+ /** Wrapper kinds whose `innerType` is the field itself. */
8169
+ var WRAPPERS = new Set([
8170
+ "optional",
8171
+ "nullable",
8172
+ "default",
8173
+ "prefault",
8174
+ "catch",
8175
+ "readonly",
8176
+ "nonoptional"
8177
+ ]);
8178
+ /**
8179
+ * The schema layers that make up ONE field: the schema itself and every
8180
+ * wrapper below it (optional / default / nullable / readonly / catch), plus
8181
+ * both sides of a pipe (`z.preprocess` puts the real schema on `out`,
8182
+ * `.transform` on `in`).
8183
+ */
8184
+ function layersOf(schema) {
8185
+ const out = [];
8186
+ const queue = [schema];
8187
+ while (queue.length > 0) {
8188
+ const s = queue.shift();
8189
+ if (!s || out.includes(s)) continue;
8190
+ out.push(s);
8191
+ const def = defOf(s);
8192
+ if (def.type !== void 0 && WRAPPERS.has(def.type) && def.innerType) queue.push(def.innerType);
8193
+ if (def.type === "pipe") {
8194
+ if (def.in) queue.push(def.in);
8195
+ if (def.out) queue.push(def.out);
8196
+ }
8197
+ }
8198
+ return out;
8199
+ }
8200
+ /** True when any layer of this field declares `.meta({ secret: true })`. */
8201
+ function isZodSecret(schema) {
8202
+ return layersOf(schema).some(declaredHere);
8203
+ }
8204
+ /**
8205
+ * Every declared secret path in a config schema: dotted keys, `[]` for "each
8206
+ * element of this array" (`connection.password`, `rows[].token`). A declared
8207
+ * object or array is reported as one path and not descended into — everything
8208
+ * under it is secret.
8209
+ */
8210
+ function collectZodSecretPaths(schema, prefix = "") {
8211
+ if (isZodSecret(schema)) return prefix.length > 0 ? [prefix] : [];
8212
+ const paths = [];
8213
+ for (const layer of layersOf(schema)) {
8214
+ const def = defOf(layer);
8215
+ if (def.type === "object" && def.shape) for (const [key, child] of Object.entries(def.shape)) paths.push(...collectZodSecretPaths(child, prefix ? `${prefix}.${key}` : key));
8216
+ else if (def.type === "array" && def.element) paths.push(...collectZodSecretPaths(def.element, `${prefix}[]`));
8217
+ else if (def.type === "union" && def.options) for (const option of def.options) paths.push(...collectZodSecretPaths(option, prefix));
8218
+ else if (def.type === "intersection") {
8219
+ if (def.left) paths.push(...collectZodSecretPaths(def.left, prefix));
8220
+ if (def.right) paths.push(...collectZodSecretPaths(def.right, prefix));
8221
+ }
8222
+ }
8223
+ return [...new Set(paths)];
8224
+ }
7072
8225
  //#endregion
7073
8226
  //#region ../types/dist/err-msg-DX6i_MY4.mjs
7074
8227
  var DeviceType = /* @__PURE__ */ function(DeviceType) {
@@ -8756,6 +9909,278 @@ var CameraSwitchGroupSchema = object({
8756
9909
  fetchedAt: number()
8757
9910
  });
8758
9911
  /**
9912
+ * The trainer contract — what the hub hands the cloud trainer and what it
9913
+ * gets back (cloud training, D805+).
9914
+ *
9915
+ * The trainer (`hf/camstack-trainer`, published as the Hugging Face repo
9916
+ * `camstack/camstack-trainer`) is a separate AGPL program the hub never
9917
+ * imports: `job.json` goes in, files come out, and progress is `CAMSTACK_EVENT`
9918
+ * lines on stdout. These schemas are the hub's half of that boundary; the
9919
+ * trainer's pydantic models (and the JSON Schemas generated from them under
9920
+ * `hf/camstack-trainer/schemas/`) are the other half. A change here is a
9921
+ * change there, in the same piece of work.
9922
+ *
9923
+ * No `.default()` anywhere: defaults do not run on the addon cap path, so the
9924
+ * orchestrator fills every field of a job spec explicitly.
9925
+ */
9926
+ var TRAINING_JOB_SCHEMA = "camstack.training/v1";
9927
+ var TRAINING_RESULT_SCHEMA = "camstack.training-result/v1";
9928
+ /** What the trainer can export. Edge TPU is a later, separate image. */
9929
+ var TrainingExportSchema = _enum([
9930
+ "onnx",
9931
+ "openvino-fp16",
9932
+ "openvino-int8",
9933
+ "coreml-fp16"
9934
+ ]);
9935
+ var FloorsSchema = record(string(), number().min(0).max(1));
9936
+ object({
9937
+ schema: literal(TRAINING_JOB_SCHEMA),
9938
+ jobKey: string().uuid(),
9939
+ target: object({
9940
+ kind: literal("detector"),
9941
+ step: literal("object-detection")
9942
+ }),
9943
+ base: object({
9944
+ modelId: string().min(1),
9945
+ /** Ultralytics weights id, e.g. `yolov9m.pt`. */
9946
+ weights: string().min(1),
9947
+ imgsz: number().int().positive()
9948
+ }),
9949
+ baseline: object({
9950
+ modelId: string().min(1),
9951
+ /** The baseline ONNX the holdout comparison runs; public mirror URL. */
9952
+ onnxUrl: string().url(),
9953
+ imgsz: number().int().positive(),
9954
+ floors: FloorsSchema
9955
+ }),
9956
+ dataset: object({
9957
+ versionId: string().min(1),
9958
+ annotationHash: string(),
9959
+ /** sha256 of the uploaded archive; the trainer refuses a mismatch (exit 65). */
9960
+ sha256: string().regex(/^[0-9a-f]{64}$/)
9961
+ }),
9962
+ split: object({
9963
+ holdoutCameras: array(number().int()),
9964
+ /** When no camera is held out: the last N days of every camera. */
9965
+ holdoutLastDays: number().int().nonnegative(),
9966
+ valFraction: number().min(0).max(.5),
9967
+ seed: number().int()
9968
+ }),
9969
+ hyper: object({
9970
+ epochs: number().int().positive(),
9971
+ batch: number().int().positive(),
9972
+ lr0: number().positive(),
9973
+ /** Layers frozen from the start of the backbone; 0 = none. */
9974
+ freeze: number().int().nonnegative(),
9975
+ patience: number().int().nonnegative(),
9976
+ seed: number().int()
9977
+ }),
9978
+ replay: object({
9979
+ source: literal("coco2017"),
9980
+ count: number().int().nonnegative()
9981
+ }),
9982
+ exports: array(TrainingExportSchema).min(1),
9983
+ calibration: object({ maxFrames: number().int().positive() }),
9984
+ floors: object({
9985
+ minSupport: number().int().positive(),
9986
+ clamp: number().min(0).max(1)
9987
+ }),
9988
+ int8Gate: object({ maxMap50Drop: number().min(0).max(1) }),
9989
+ catalog: object({
9990
+ id: string().regex(/^[a-z0-9][a-z0-9-]{2,80}$/),
9991
+ name: string().min(1).max(160)
9992
+ })
9993
+ });
9994
+ /** One regular file of the bundle. An mlpackage contributes one row per member. */
9995
+ var TrainingResultFileSchema = object({
9996
+ path: string().min(1),
9997
+ bytes: number().int().nonnegative(),
9998
+ sha256: string().regex(/^[0-9a-f]{64}$/),
9999
+ format: _enum([
10000
+ "onnx",
10001
+ "openvino",
10002
+ "coreml",
10003
+ "pt"
10004
+ ]),
10005
+ variant: _enum(["base", "int8"])
10006
+ });
10007
+ var DraftFormatSchema = object({
10008
+ /** RELATIVE path inside the bundle; the hub rewrites it to `camstack-local://`. */
10009
+ url: string().min(1),
10010
+ sizeMB: number().nonnegative(),
10011
+ isDirectory: boolean().optional(),
10012
+ files: array(string()).optional(),
10013
+ runtimes: array(literal("python")).optional(),
10014
+ revision: string().min(1)
10015
+ });
10016
+ /** The trainer's half of a catalog entry; the hub completes it (labels, licence, group). */
10017
+ var TrainingCatalogDraftSchema = object({
10018
+ id: string().min(1),
10019
+ name: string().min(1),
10020
+ description: string(),
10021
+ labels: array(unknown()),
10022
+ inputSize: object({
10023
+ width: number().int().positive(),
10024
+ height: number().int().positive()
10025
+ }),
10026
+ preprocessMode: literal("letterbox"),
10027
+ defaultClassFloors: FloorsSchema,
10028
+ formats: object({
10029
+ onnx: DraftFormatSchema.optional(),
10030
+ openvino: DraftFormatSchema.optional(),
10031
+ coreml: DraftFormatSchema.optional()
10032
+ })
10033
+ });
10034
+ /** One class of one model's holdout report (the eval harness's summary). */
10035
+ var TrainingEvalClassSchema = object({
10036
+ positives: number().int(),
10037
+ floor: number().nullable(),
10038
+ tp: number().int(),
10039
+ fp: number().int(),
10040
+ fn: number().int(),
10041
+ precision: number().nullable(),
10042
+ recall: number().nullable(),
10043
+ ap50: number().nullable(),
10044
+ recallByCamera: record(string(), number().nullable()).optional(),
10045
+ recallByLight: record(string(), number().nullable()).optional(),
10046
+ fpByCamera: record(string(), number()).optional(),
10047
+ smallFound: number().int().optional(),
10048
+ smallTotal: number().int().optional()
10049
+ }).passthrough();
10050
+ var TrainingEvalReportSchema = object({
10051
+ frames: number().int(),
10052
+ classes: record(string(), TrainingEvalClassSchema)
10053
+ }).passthrough();
10054
+ /**
10055
+ * A succeeded result carries every block; a failed one carries the error and
10056
+ * whatever was known by then — the other blocks are ABSENT, not null. The
10057
+ * orchestrator checks the blocks it needs before it trusts a success.
10058
+ */
10059
+ var TrainingResultSchema = object({
10060
+ schema: literal(TRAINING_RESULT_SCHEMA),
10061
+ jobKey: string(),
10062
+ status: _enum(["succeeded", "failed"]),
10063
+ error: object({
10064
+ stage: string(),
10065
+ code: string(),
10066
+ message: string()
10067
+ }).nullable(),
10068
+ trainer: object({
10069
+ version: string(),
10070
+ revision: string()
10071
+ }),
10072
+ toolchain: record(string(), string().nullable()),
10073
+ dataset: object({
10074
+ versionId: string(),
10075
+ annotationHash: string(),
10076
+ sha256: string(),
10077
+ frames: object({
10078
+ train: number().int(),
10079
+ val: number().int(),
10080
+ holdout: number().int()
10081
+ }),
10082
+ holdoutCameras: array(number().int()),
10083
+ replayImages: number().int()
10084
+ }).optional(),
10085
+ training: object({
10086
+ epochsRun: number().int(),
10087
+ bestEpoch: number().int(),
10088
+ bestMap50: number(),
10089
+ bestMap50_95: number(),
10090
+ seconds: number()
10091
+ }).optional(),
10092
+ evaluation: object({
10093
+ holdoutFrames: number().int(),
10094
+ baseline: TrainingEvalReportSchema.nullable(),
10095
+ candidate: TrainingEvalReportSchema.nullable(),
10096
+ candidateInt8: TrainingEvalReportSchema.nullable(),
10097
+ recallDeltaByCamera: record(string(), record(string(), number())).nullable(),
10098
+ map50: record(string(), number().nullable())
10099
+ }).optional(),
10100
+ floors: object({
10101
+ baseline: FloorsSchema,
10102
+ candidate: FloorsSchema,
10103
+ candidateInt8: FloorsSchema.nullable(),
10104
+ notes: array(string())
10105
+ }).optional(),
10106
+ int8: object({
10107
+ kept: boolean(),
10108
+ map50Fp16: number().nullable(),
10109
+ map50Int8: number().nullable(),
10110
+ reason: string().nullable()
10111
+ }).optional(),
10112
+ exportsDropped: array(object({
10113
+ export: string(),
10114
+ reason: string()
10115
+ })).optional(),
10116
+ files: array(TrainingResultFileSchema).optional(),
10117
+ bundle: object({
10118
+ path: literal("bundle.tar"),
10119
+ bytes: number().int().nonnegative(),
10120
+ sha256: string().regex(/^[0-9a-f]{64}$/)
10121
+ }).nullable().optional(),
10122
+ catalogDraft: object({
10123
+ base: TrainingCatalogDraftSchema,
10124
+ int8: TrainingCatalogDraftSchema.nullable()
10125
+ }).nullable().optional(),
10126
+ licence: string()
10127
+ });
10128
+ var TrainingStageSchema = _enum([
10129
+ "prepare",
10130
+ "replay",
10131
+ "train",
10132
+ "eval",
10133
+ "export",
10134
+ "package"
10135
+ ]);
10136
+ var EventBase = {
10137
+ v: literal(1),
10138
+ ts: number()
10139
+ };
10140
+ discriminatedUnion("type", [
10141
+ object({
10142
+ ...EventBase,
10143
+ type: literal("stage"),
10144
+ stage: TrainingStageSchema
10145
+ }),
10146
+ object({
10147
+ ...EventBase,
10148
+ type: literal("epoch"),
10149
+ epoch: number().int(),
10150
+ epochs: number().int(),
10151
+ boxLoss: number().nullable().optional(),
10152
+ map50: number().nullable().optional(),
10153
+ map50_95: number().nullable().optional(),
10154
+ etaSec: number().nullable().optional()
10155
+ }),
10156
+ object({
10157
+ ...EventBase,
10158
+ type: literal("metric"),
10159
+ name: string(),
10160
+ value: number()
10161
+ }),
10162
+ object({
10163
+ ...EventBase,
10164
+ type: literal("artifact"),
10165
+ path: string(),
10166
+ bytes: number(),
10167
+ sha256: string()
10168
+ }),
10169
+ object({
10170
+ ...EventBase,
10171
+ type: literal("done"),
10172
+ status: _enum(["succeeded", "failed"]),
10173
+ resultSha256: string().nullable().optional()
10174
+ }),
10175
+ object({
10176
+ ...EventBase,
10177
+ type: literal("error"),
10178
+ stage: string(),
10179
+ code: string(),
10180
+ message: string()
10181
+ })
10182
+ ]);
10183
+ /**
8759
10184
  * What the gate decided about a birth, from the CALLER's point of view.
8760
10185
  *
8761
10186
  * Deliberately not `ConfirmationVerdict`: `undecided` is not a birth decision
@@ -11364,7 +12789,9 @@ var AddonHttpRouteSchema = object({
11364
12789
  "authenticated",
11365
12790
  "admin"
11366
12791
  ]).optional(),
11367
- description: string().optional()
12792
+ description: string().optional(),
12793
+ /** The hub limits this route per client address before the handler runs. */
12794
+ rateLimit: _enum(["auth"]).optional()
11368
12795
  });
11369
12796
  /**
11370
12797
  * Cross-process route invocation envelope. The hub captures the
@@ -12069,6 +13496,37 @@ var BackupDestinationInfoSchema = object({
12069
13496
  lastError: string().optional()
12070
13497
  });
12071
13498
  /**
13499
+ * How an archive is encrypted (operator decision 2026-10-09): to a backup
13500
+ * PUBLIC key the hub holds, so only the operator's secret key opens it.
13501
+ * Absent on a plain `.tar.gz` — every archive made before encryption, or
13502
+ * with it off — which restores without a key.
13503
+ */
13504
+ var BackupArchiveEncryptionSchema = object({
13505
+ /** `x25519-hkdf-aes256gcm-stream-v1`. */
13506
+ scheme: string(),
13507
+ /** 16 hex — the backup key whose secret restores this archive. */
13508
+ keyId: string()
13509
+ });
13510
+ /**
13511
+ * The backup encryption setting. The hub keeps PUBLIC keys only: the active
13512
+ * one new archives are encrypted to, and the retired ones older archives
13513
+ * still need. The secret key is shown once, at `setupEncryption`.
13514
+ */
13515
+ var BackupEncryptionStatusSchema = object({
13516
+ enabled: boolean(),
13517
+ active: object({
13518
+ keyId: string(),
13519
+ publicKey: string(),
13520
+ createdAt: number()
13521
+ }).nullable(),
13522
+ /** Every key ever set up, newest first. */
13523
+ keys: array(object({
13524
+ keyId: string(),
13525
+ createdAt: number(),
13526
+ retiredAt: number().nullable()
13527
+ })).readonly()
13528
+ });
13529
+ /**
12072
13530
  * Per-archive entry returned by `backup.listArchives({ destinationId })`.
12073
13531
  * Same shape the destination drill-in renders. Sourced from the per-
12074
13532
  * location `manifests.json` (no per-archive tarball read required).
@@ -12080,7 +13538,9 @@ var BackupArchiveEntrySchema = object({
12080
13538
  sizeBytes: number(),
12081
13539
  label: string().optional(),
12082
13540
  /** Top-level locations included in the archive (db, addons, tls, …). */
12083
- locations: array(string()).readonly()
13541
+ locations: array(string()).readonly(),
13542
+ /** Present when the archive is encrypted; restore then needs that key. */
13543
+ encryption: BackupArchiveEncryptionSchema.optional()
12084
13544
  });
12085
13545
  var BackupEntrySchema = object({
12086
13546
  id: string(),
@@ -12089,7 +13549,8 @@ var BackupEntrySchema = object({
12089
13549
  label: string().optional(),
12090
13550
  createdAt: number(),
12091
13551
  sizeBytes: number(),
12092
- locations: array(string()).optional()
13552
+ locations: array(string()).optional(),
13553
+ encryption: BackupArchiveEncryptionSchema.optional()
12093
13554
  });
12094
13555
  var ArchiveEntrySchema = object({
12095
13556
  path: string(),
@@ -12278,10 +13739,40 @@ method(_void(), array(BackupDestinationInfoSchema).readonly(), { auth: "admin" }
12278
13739
  * this list and skips entries whose path doesn't start with
12279
13740
  * any of them.
12280
13741
  */
12281
- locations: array(string()).optional()
13742
+ locations: array(string()).optional(),
13743
+ /**
13744
+ * The backup SECRET key, for an encrypted archive (ignored for a plain
13745
+ * one). The archive is decrypted into the hub's private staging
13746
+ * before the restart; the key is not stored. A wrong or missing key
13747
+ * is refused before the archive is downloaded.
13748
+ */
13749
+ backupSecretKey: string().optional()
12282
13750
  }), _void(), {
12283
13751
  kind: "mutation",
12284
13752
  auth: "admin"
13753
+ }), method(_void(), BackupEncryptionStatusSchema, { auth: "admin" }), method(object({}), object({
13754
+ keyId: string(),
13755
+ secretKey: string(),
13756
+ publicKey: string(),
13757
+ createdAt: number(),
13758
+ replacedKeyId: string().nullable()
13759
+ }), {
13760
+ kind: "mutation",
13761
+ auth: "admin"
13762
+ }), method(object({}), object({ disabledKeyId: string().nullable() }), {
13763
+ kind: "mutation",
13764
+ auth: "admin"
13765
+ }), method(object({ backupSecretKey: string() }), object({
13766
+ valid: boolean(),
13767
+ keyId: string().nullable(),
13768
+ /** The hub knows this key (active or retired). */
13769
+ known: boolean(),
13770
+ /** It is the key new archives are encrypted to. */
13771
+ active: boolean(),
13772
+ error: string().optional()
13773
+ }), {
13774
+ kind: "mutation",
13775
+ auth: "admin"
12285
13776
  }), method(object({
12286
13777
  destinationId: string(),
12287
13778
  backupId: string()
@@ -14007,7 +15498,60 @@ var CustomModelDescriptorSchema = object({
14007
15498
  stepId: string(),
14008
15499
  entry: ModelCatalogEntrySchema
14009
15500
  });
14010
- method(_void(), array(CustomModelDescriptorSchema).readonly(), { auth: "admin" });
15501
+ /** One regular file of an imported bundle, as the producer measured it. */
15502
+ var ModelBundleFileSchema = object({
15503
+ /** Relative path inside the bundle tar; an mlpackage member is `<x>.mlpackage/<member>`. */
15504
+ path: string().min(1),
15505
+ bytes: number().int().nonnegative(),
15506
+ sha256: string().regex(/^[0-9a-f]{64}$/)
15507
+ });
15508
+ var ImportModelBundleInputSchema = object({
15509
+ /** The registry provider that keeps the model (Model Studio). */
15510
+ addonId: string(),
15511
+ stepId: string().min(1),
15512
+ /**
15513
+ * The catalog rows to register, complete, every format URL already
15514
+ * `camstack-local://<modelId>/<file>` naming a file of the bundle. One
15515
+ * bundle may carry several rows (a base and its INT8 variant).
15516
+ */
15517
+ entries: array(ModelCatalogEntrySchema).min(1).max(4),
15518
+ /** The bundle tar, offered by the producer over `ctx.peerBytes` (same host). */
15519
+ bundle: object({
15520
+ ticket: PeerBytesTicketSchema,
15521
+ bytes: number().int().positive(),
15522
+ sha256: string().regex(/^[0-9a-f]{64}$/)
15523
+ }),
15524
+ /** Every file the tar must hold; anything missing, extra or different is refused. */
15525
+ files: array(ModelBundleFileSchema).min(1).max(64),
15526
+ /** Convert missing engine formats and push the model to every agent afterwards. */
15527
+ distribute: boolean()
15528
+ });
15529
+ var ImportModelBundleResultSchema = discriminatedUnion("kind", [object({
15530
+ kind: literal("imported"),
15531
+ modelIds: array(string()).readonly(),
15532
+ distributed: array(object({
15533
+ modelId: string(),
15534
+ nodeId: string(),
15535
+ format: _enum(MODEL_FORMATS),
15536
+ ok: boolean(),
15537
+ error: string().optional()
15538
+ })).readonly()
15539
+ }), object({
15540
+ kind: literal("refused"),
15541
+ reason: _enum([
15542
+ "transfer-failed",
15543
+ "checksum-mismatch",
15544
+ "bundle-mismatch",
15545
+ "invalid-entry",
15546
+ "id-taken"
15547
+ ]),
15548
+ detail: string()
15549
+ })]);
15550
+ method(_void(), array(CustomModelDescriptorSchema).readonly(), { auth: "admin" }), method(ImportModelBundleInputSchema, ImportModelBundleResultSchema, {
15551
+ kind: "mutation",
15552
+ auth: "admin",
15553
+ timeoutMs: 30 * 6e4
15554
+ });
14011
15555
  /**
14012
15556
  * Query filter for settings-store collections.
14013
15557
  */
@@ -14390,6 +15934,253 @@ id: union([string(), number()]) }), {
14390
15934
  kind: "mutation",
14391
15935
  auth: "admin"
14392
15936
  });
15937
+ /**
15938
+ * `keychain` — the hub's encrypted store of secret values (D787).
15939
+ *
15940
+ * Settings blobs never hold a secret: they hold a marker
15941
+ * `{"$secret":"secret://<owner>/<scope>/<fieldPath>","v":1}` and the value
15942
+ * lives here, AES-256-GCM under a data key that a master key wraps. This cap
15943
+ * is the OWNER's door to its own values: every method is owner-checked
15944
+ * against the CALLER, never against anything the caller claims.
15945
+ *
15946
+ * Who the caller is: the transport stamps `callerAddonId` into the args of a
15947
+ * call that crossed a process (the parent `LocalChildRegistry` from the UDS
15948
+ * connection, the agent from its child's connection carried in
15949
+ * `$hub-cap-fwd`'s envelope). A stamp always overwrites; a wire call with no
15950
+ * stamp has its claim stripped. Only a hub in-process caller may state its own
15951
+ * identity — `ctx.secrets` does that with the addon id closed over. This is
15952
+ * identity against BUGS and misrouting, not against a malicious addon (every
15953
+ * runner is the same OS user): see the threat model in
15954
+ * `docs/design/2026-10-08-secrets-keychain.md`.
15955
+ *
15956
+ * `callerAddonId` is deliberately NOT in any input schema: the tRPC router
15957
+ * parses the input, so a session can never supply it, and the internal mount
15958
+ * floors every method to admin anyway (D240).
15959
+ *
15960
+ * Internal: addons reach it through `ctx.secrets`, never directly.
15961
+ */
15962
+ /** Why a value cannot be served right now. Never folded into "missing". */
15963
+ var KeychainUnavailableReasonSchema = _enum([
15964
+ "key-missing",
15965
+ "wrong-key",
15966
+ "key-file-unreadable",
15967
+ "store-unavailable",
15968
+ "not-initialized",
15969
+ "decrypt-failed"
15970
+ ]);
15971
+ var KeychainStateSchema = discriminatedUnion("state", [object({ state: literal("ready") }), object({
15972
+ state: literal("locked"),
15973
+ reason: KeychainUnavailableReasonSchema
15974
+ })]);
15975
+ var KeychainResolveEntrySchema = discriminatedUnion("kind", [
15976
+ object({
15977
+ kind: literal("value"),
15978
+ value: string(),
15979
+ version: number().int()
15980
+ }),
15981
+ object({ kind: literal("missing") }),
15982
+ object({
15983
+ kind: literal("unavailable"),
15984
+ reason: KeychainUnavailableReasonSchema
15985
+ }),
15986
+ object({ kind: literal("forbidden") })
15987
+ ]);
15988
+ var KeychainResolveResultSchema = record(string(), KeychainResolveEntrySchema);
15989
+ /** Metadata of one stored value — never the value. */
15990
+ var KeychainSecretMetaSchema = object({
15991
+ ref: string(),
15992
+ owner: string(),
15993
+ /** Formatted scope (`global`, `node/<id>`, `device/<id>`, …). */
15994
+ scope: string(),
15995
+ fieldPath: string(),
15996
+ version: number().int(),
15997
+ createdAt: number(),
15998
+ updatedAt: number(),
15999
+ /** `addon:<id>` | `user:<id>` | `system`. */
16000
+ updatedBy: string(),
16001
+ /** Coarse — written at most once an hour per ref. `null` = never read. */
16002
+ lastReadAt: number().nullable()
16003
+ });
16004
+ var RefListSchema = array(string().min(1)).max(512);
16005
+ method(object({
16006
+ ref: string().min(1),
16007
+ value: string().min(1)
16008
+ }), object({
16009
+ ref: string(),
16010
+ version: number().int()
16011
+ }), {
16012
+ kind: "mutation",
16013
+ auth: "admin"
16014
+ }), method(object({ refs: RefListSchema }), KeychainResolveResultSchema, { auth: "admin" }), method(object({ refs: RefListSchema }), object({ deleted: number().int() }), {
16015
+ kind: "mutation",
16016
+ auth: "admin"
16017
+ }), method(object({}), array(KeychainSecretMetaSchema).readonly(), { auth: "admin" }), method(object({}), KeychainStateSchema, { auth: "admin" });
16018
+ var KeychainKeySourceSchema = object({
16019
+ kind: _enum([
16020
+ "config-file",
16021
+ "previous-config-file",
16022
+ "platform",
16023
+ "default-file"
16024
+ ]),
16025
+ /** File sources only — a path is not a secret. */
16026
+ path: string().optional(),
16027
+ /**
16028
+ * True when a whole-volume backup of the data directory carries this key
16029
+ * next to the database it protects (the default file). The page warns.
16030
+ */
16031
+ sharesBackupWithDatabase: boolean()
16032
+ });
16033
+ /**
16034
+ * One keychain reset, as the Secrets page reports it until the operator
16035
+ * acknowledges it. Never a value: refs, counts and table names only.
16036
+ */
16037
+ var KeychainResetRecordSchema = object({
16038
+ id: string(),
16039
+ at: number(),
16040
+ /** `user:<id>` or {@link KEYCHAIN_RESET_TRIGGER_ACTOR}. */
16041
+ actor: string(),
16042
+ /** Why the keychain was locked when it was reset; `null` when it was not locked. */
16043
+ lockedReason: string().nullable(),
16044
+ /** Values moved into the archive table (ciphertext under the lost key). */
16045
+ archived: number().int(),
16046
+ /** `keychain:secrets-orphaned-<ts>`, or `null` when nothing was stored. */
16047
+ archivedCollection: string().nullable(),
16048
+ /**
16049
+ * `keychain:keys-orphaned-<ts>`: the wrapped data keys of the archive, kept
16050
+ * so the archive can still be opened if the lost master key turns up.
16051
+ */
16052
+ archivedKeysCollection: string().nullable(),
16053
+ /**
16054
+ * `system-settings` keys whose marker the reset cleared — the cluster
16055
+ * secret's: a marker left pointing at an archived value would refuse every
16056
+ * agent forever (D797).
16057
+ */
16058
+ clearedSettingsKeys: array(string()).readonly(),
16059
+ /** When an operator dismissed the notice on the Secrets page; `null` until then. */
16060
+ acknowledgedAt: number().nullable()
16061
+ });
16062
+ var KeychainStatusSchema = object({
16063
+ keychain: KeychainStateSchema,
16064
+ /** The source of the master key in use; `null` while locked. */
16065
+ keySource: KeychainKeySourceSchema.nullable(),
16066
+ /** The source configured to be primary — differs from `keySource` while a rotation is pending. */
16067
+ configuredSource: KeychainKeySourceSchema,
16068
+ /** Short fingerprint of the master key in use (`HMAC(KEK, label)`, 16 hex). */
16069
+ fingerprint: string().nullable(),
16070
+ activeKeyId: string().nullable(),
16071
+ /**
16072
+ * The keychain unlocked with a NON-primary source: the configured primary
16073
+ * key is not the one that wraps the data key yet. `rotateMasterKey` moves it.
16074
+ */
16075
+ rotationPending: boolean(),
16076
+ /** Wrapped copies of the data key under a previous master key, kept until purged. */
16077
+ retiredWraps: number().int(),
16078
+ recoveryKeyDownloadedAt: number().nullable(),
16079
+ secretCount: number().int(),
16080
+ /** The most recent reset, acknowledged or not; `null` when the keychain was never reset. */
16081
+ lastReset: KeychainResetRecordSchema.nullable()
16082
+ });
16083
+ /**
16084
+ * Whether a stored value is still pointed at by its owner's settings.
16085
+ * `unknown` is a first-class answer: a scope whose blob could not be read is
16086
+ * never reported as an orphan (and never deleted as one).
16087
+ */
16088
+ var KeychainSecretUsageSchema = _enum([
16089
+ "in-use",
16090
+ "orphan",
16091
+ "unknown"
16092
+ ]);
16093
+ var KeychainAdminSecretSchema = KeychainSecretMetaSchema.extend({ usage: KeychainSecretUsageSchema });
16094
+ var KeychainAuditActionSchema = _enum([
16095
+ "put",
16096
+ "delete",
16097
+ "reveal",
16098
+ "rotate-master-key",
16099
+ "purge-retired-keys",
16100
+ "download-recovery-key",
16101
+ "delete-orphans",
16102
+ "reset",
16103
+ "acknowledge-reset",
16104
+ "initialize"
16105
+ ]);
16106
+ var KeychainAuditEntrySchema = object({
16107
+ id: string(),
16108
+ at: number(),
16109
+ action: KeychainAuditActionSchema,
16110
+ /** `addon:<id>` | `user:<id>` | `system` | `trigger-file`. */
16111
+ actor: string(),
16112
+ ref: string().nullable(),
16113
+ detail: string().nullable()
16114
+ });
16115
+ var KEYCHAIN_RESET_CONFIRMATION = "RESET KEYCHAIN";
16116
+ /**
16117
+ * Secrets the HUB itself holds (owner `system`) that no settings form shows:
16118
+ * `jwt-signing-key` — the session signing key (D797). It is always "in use",
16119
+ * never an orphan; it is generated on a fresh hub and replaced only through
16120
+ * {@link keychainAdminCapability.methods.setSystemSecret}.
16121
+ */
16122
+ var SystemHeldSecretNameSchema = _enum(["jwt-signing-key"]);
16123
+ 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({
16124
+ value: string(),
16125
+ version: number().int()
16126
+ }), {
16127
+ kind: "mutation",
16128
+ auth: "admin",
16129
+ caller: "required"
16130
+ }), method(object({
16131
+ name: SystemHeldSecretNameSchema,
16132
+ value: string().min(16)
16133
+ }), object({
16134
+ ref: string(),
16135
+ version: number().int()
16136
+ }), {
16137
+ kind: "mutation",
16138
+ auth: "admin",
16139
+ caller: "required"
16140
+ }), method(object({ refs: array(string().min(1)).max(1e3) }), object({
16141
+ deleted: array(string()).readonly(),
16142
+ kept: array(object({
16143
+ ref: string(),
16144
+ usage: KeychainSecretUsageSchema
16145
+ })).readonly()
16146
+ }), {
16147
+ kind: "mutation",
16148
+ auth: "admin",
16149
+ caller: "required"
16150
+ }), method(object({}), object({
16151
+ fingerprint: string(),
16152
+ keySource: KeychainKeySourceSchema
16153
+ }), {
16154
+ kind: "mutation",
16155
+ auth: "admin",
16156
+ caller: "required"
16157
+ }), method(object({}), object({ purged: number().int() }), {
16158
+ kind: "mutation",
16159
+ auth: "admin",
16160
+ caller: "required"
16161
+ }), method(object({}), object({
16162
+ key: string(),
16163
+ fingerprint: string(),
16164
+ keySource: KeychainKeySourceSchema
16165
+ }), {
16166
+ kind: "mutation",
16167
+ auth: "admin",
16168
+ caller: "required"
16169
+ }), method(object({ confirm: literal(KEYCHAIN_RESET_CONFIRMATION) }), object({
16170
+ archivedCollection: string().nullable(),
16171
+ archived: number().int()
16172
+ }), {
16173
+ kind: "mutation",
16174
+ auth: "admin",
16175
+ caller: "required"
16176
+ }), method(object({}), object({
16177
+ reset: KeychainResetRecordSchema.nullable(),
16178
+ pendingReentry: array(KeychainSecretMetaSchema).readonly()
16179
+ }), { auth: "admin" }), method(object({}), object({ acknowledged: boolean() }), {
16180
+ kind: "mutation",
16181
+ auth: "admin",
16182
+ caller: "required"
16183
+ });
14393
16184
  method(_void(), object({
14394
16185
  id: string(),
14395
16186
  name: string(),
@@ -15728,7 +17519,11 @@ var DeviceRegisterPayloadSchema = object({
15728
17519
  var DeviceRemovePayloadSchema = object({ deviceId: number() });
15729
17520
  var DevicePersistConfigPayloadSchema = object({
15730
17521
  deviceId: number(),
15731
- data: record(string(), unknown())
17522
+ data: record(string(), unknown()),
17523
+ /** The paths the device's schema declares secret (D783), when the caller
17524
+ * knows them — those values are kept in the keychain, not the blob (D787).
17525
+ * Absent: the paths the device last reported at `registerDevice` apply. */
17526
+ secretConfigPaths: array(string()).optional()
15732
17527
  });
15733
17528
  /** What a migration actually did, per switch. `unreachable` is a first-class
15734
17529
  * answer: a camera that could not be asked is not a camera that was silenced. */
@@ -17350,7 +19145,7 @@ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
17350
19145
  * `login-method` — collection cap through which auth addons contribute
17351
19146
  * their pre-auth login surfaces to the login page. This is the SINGLE,
17352
19147
  * generic mechanism that supersedes the dead `auth.listProviders` reader:
17353
- * every auth addon (OIDC, magic-link, WebAuthn/passkey) registers a
19148
+ * every auth addon (OIDC, WebAuthn/passkey) registers a
17354
19149
  * `login-method` provider and the PUBLIC `auth.listLoginMethods`
17355
19150
  * procedure aggregates them for the unauthenticated login page.
17356
19151
  *
@@ -17358,8 +19153,7 @@ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
17358
19153
  *
17359
19154
  * - `redirect` — a declarative button. The login page renders a generic
17360
19155
  * button that navigates to `startUrl` (an addon-owned HTTP route).
17361
- * Covers OIDC (`/addon/auth-oidc/<id>/start`) and magic-link with
17362
- * ZERO shell-side JS. A future SSO addon plugs in the same way — the
19156
+ * Covers OIDC (`/addon/auth-oidc/<id>/start`) with ZERO shell-side JS. A future SSO addon plugs in the same way — the
17363
19157
  * login page needs NO change.
17364
19158
  *
17365
19159
  * - `widget` — a Module-Federation widget the login page mounts (via
@@ -17378,8 +19172,8 @@ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
17378
19172
  * decision.
17379
19173
  *
17380
19174
  * Every contribution carries a `stage`:
17381
- * - `primary` — shown on the first credentials screen (OIDC /
17382
- * magic-link buttons; a future usernameless passkey).
19175
+ * - `primary` — shown on the first credentials screen (OIDC
19176
+ * buttons; a usernameless passkey).
17383
19177
  * - `second-factor` — shown AFTER the password leg, gated on the
17384
19178
  * returned `factors` (passkey-as-2FA today).
17385
19179
  *
@@ -17406,7 +19200,7 @@ var LoginMethodContributionSchema = discriminatedUnion("kind", [
17406
19200
  * The provider names an external identity a signed-in user can link to
17407
19201
  * their own account (D782): `auth.listLinkableProviders` /
17408
19202
  * `beginExternalLink` offer exactly the redirect methods that set this,
17409
- * whatever their id. Absent / false — a login button only (magic-link).
19203
+ * whatever their id. Absent / false — a login button only.
17410
19204
  */
17411
19205
  linkable: boolean().optional()
17412
19206
  }),
@@ -21261,8 +23055,7 @@ method(object({}), object({ rules: array(NcRuleSchema) }), { auth: "admin" }), m
21261
23055
  * `super_admin` — collapsed onto the single boolean because every
21262
23056
  * non-admin caller is governed by the same scope-check rules; the
21263
23057
  * distinction was only ever used to route role-specific procedures
21264
- * which we no longer have. Agents are admin sessions issued via
21265
- * `createServiceToken`; CLI / webhook integrations are `cst_*` tokens
23058
+ * which we no longer have. CLI / webhook integrations are `cst_*` tokens
21266
23059
  * with `isAdmin: false` + an explicit scope list.
21267
23060
  */
21268
23061
  /** Per-method access flavour. Materialised on every cap method via codegen. */
@@ -22764,8 +24557,23 @@ var RetrainMacroClassSchema = _enum([
22764
24557
  ]);
22765
24558
  /** A subject to learn, or a phantom to unlearn (taught by OMISSION). */
22766
24559
  var RetrainAnnotationKindSchema = _enum(["subject", "model_error"]);
22767
- /** Did a human draw this box, or did the assist propose it? */
22768
- var RetrainAnnotationSourceSchema = _enum(["operator", "assist"]);
24560
+ /**
24561
+ * Where a box came from. A machine-sourced box is a DRAFT on the page until
24562
+ * the operator confirms it; once saved it keeps its source as provenance.
24563
+ *
24564
+ * - `operator` — drawn by hand.
24565
+ * - `assist` — proposed by a detector run on the copy (the camera's own
24566
+ * model, or a larger teacher model).
24567
+ * - `pipeline` — the box the live pipeline actually drew on that frame, read
24568
+ * back from the track store (never a re-run).
24569
+ * - `llm` — proposed by a vision-capable LLM profile.
24570
+ */
24571
+ var RetrainAnnotationSourceSchema = _enum([
24572
+ "operator",
24573
+ "assist",
24574
+ "pipeline",
24575
+ "llm"
24576
+ ]);
22769
24577
  /** Normalised `[0,1]` rectangle against the FULL frame — the canonical form. */
22770
24578
  var RetrainBboxSchema = object({
22771
24579
  x: number(),
@@ -22783,7 +24591,8 @@ var RetrainBboxSchema = object({
22783
24591
  */
22784
24592
  var RetrainAnnotationSchema = object({
22785
24593
  id: string(),
22786
- trackId: string(),
24594
+ /** The frame's track. Absent on a recording still, which has none. */
24595
+ trackId: string().optional(),
22787
24596
  deviceId: number(),
22788
24597
  /** The COPY in retrain storage — never the source track's media key. */
22789
24598
  mediaKey: string(),
@@ -22832,13 +24641,47 @@ var RetrainFrameCandidateSchema = object({
22832
24641
  * fail, whatever became of the original. */
22833
24642
  copied: boolean()
22834
24643
  });
24644
+ /**
24645
+ * One box the live pipeline drew on a copied frame — what a correction starts
24646
+ * from. Derived when the frame is listed, from the track store: the subject
24647
+ * box recorded on the source media row when there is one, else the track
24648
+ * position nearest the frame's capture time. Never stored as an annotation
24649
+ * until the operator confirms it.
24650
+ */
24651
+ var RetrainPipelineBoxSchema = object({
24652
+ /** Normalised `[0,1]` against the full frame. */
24653
+ bbox: RetrainBboxSchema,
24654
+ macroClass: RetrainMacroClassSchema,
24655
+ label: string().optional(),
24656
+ subLabel: string().optional(),
24657
+ /** The detection score of the position used, when it was recorded. */
24658
+ score: number().optional(),
24659
+ /** The root model that produced the track, when it was recorded. */
24660
+ modelId: string().optional(),
24661
+ trackId: string(),
24662
+ /** `subject-box`: recorded on this very frame. `position`: the track's
24663
+ * position nearest the capture time, `deltaMs` away. */
24664
+ basis: _enum(["subject-box", "position"]),
24665
+ deltaMs: number()
24666
+ });
24667
+ /**
24668
+ * Where a retrain frame came from: a TRACK's stored media (copy-on-select),
24669
+ * or the RECORDING at an instant — the frame a model saw nothing in has no
24670
+ * track at all.
24671
+ */
24672
+ var RetrainFrameOriginSchema = _enum(["track", "recording"]);
22835
24673
  /** A frame the dataset OWNS: bytes copied at selection time. */
22836
24674
  var RetrainFrameSchema = object({
22837
24675
  frameId: string(),
22838
24676
  deviceId: number(),
22839
- trackId: string(),
22840
- /** Provenance only. It may already point at nothing — that is expected. */
22841
- sourceMediaId: number().int(),
24677
+ origin: RetrainFrameOriginSchema,
24678
+ /** The track it was copied from. Absent on a recording still. */
24679
+ trackId: string().optional(),
24680
+ /** Provenance only. It may already point at nothing — that is expected.
24681
+ * Absent on a recording still. */
24682
+ sourceMediaId: number().int().optional(),
24683
+ /** A recording still: the playhead instant it was taken at. */
24684
+ epochMs: number().optional(),
22842
24685
  sourceKind: MediaFileKindEnum,
22843
24686
  sizeBytes: number().int(),
22844
24687
  width: number().int(),
@@ -22849,7 +24692,12 @@ var RetrainFrameSchema = object({
22849
24692
  /** The operator's "every subject in this frame is boxed". Detector
22850
24693
  * evaluation keeps only complete frames: an unboxed subject would count as
22851
24694
  * a false positive. */
22852
- complete: boolean()
24695
+ complete: boolean(),
24696
+ /** The boxes the pipeline drew on this frame. Present on list answers;
24697
+ * empty when nothing the track store holds can be placed on it. */
24698
+ pipelineBoxes: array(RetrainPipelineBoxSchema).readonly().optional(),
24699
+ /** The named collections this frame belongs to. Present on list answers. */
24700
+ collectionIds: array(string()).readonly().optional()
22853
24701
  });
22854
24702
  /** Why a copy-on-select could not be honoured — named, never a silent skip. */
22855
24703
  var RetrainCopyRefusalSchema = _enum([
@@ -22880,6 +24728,11 @@ var RetrainFrameListSchema = object({
22880
24728
  var RetrainExportFilterSchema = object({
22881
24729
  deviceIds: array(number()).optional(),
22882
24730
  frameIds: array(string()).max(2e4).optional(),
24731
+ /** Only frames in at least one of these named collections. */
24732
+ collectionIds: array(string()).max(200).optional(),
24733
+ /** Exactly the frames of this dataset version (and its completeOnly). An
24734
+ * unknown id selects nothing. */
24735
+ datasetVersionId: string().optional(),
22883
24736
  batchId: string().optional(),
22884
24737
  /** Only frames the operator marked complete (all subjects boxed). */
22885
24738
  completeOnly: boolean().optional()
@@ -22944,6 +24797,170 @@ var RetrainAssistResultSchema = discriminatedUnion("kind", [object({
22944
24797
  reason: string(),
22945
24798
  detail: string().optional()
22946
24799
  })]);
24800
+ /** A named set over the retrain corpus — membership only, it owns no pixels. */
24801
+ var RetrainCollectionSchema = object({
24802
+ id: string(),
24803
+ name: string(),
24804
+ createdAt: number(),
24805
+ frameCount: number().int()
24806
+ });
24807
+ var RetrainCollectionCreateResultSchema = discriminatedUnion("kind", [object({
24808
+ kind: literal("created"),
24809
+ collection: RetrainCollectionSchema
24810
+ }), object({
24811
+ kind: literal("refused"),
24812
+ reason: _enum(["empty-name", "duplicate-name"])
24813
+ })]);
24814
+ var RetrainCollectionRenameResultSchema = discriminatedUnion("kind", [object({
24815
+ kind: literal("renamed"),
24816
+ collection: RetrainCollectionSchema
24817
+ }), object({
24818
+ kind: literal("refused"),
24819
+ reason: _enum([
24820
+ "empty-name",
24821
+ "duplicate-name",
24822
+ "unknown-collection"
24823
+ ])
24824
+ })]);
24825
+ /**
24826
+ * The outcome of adding the frame at a recording instant. Every refusal is
24827
+ * named: `still-unavailable` (not recording, a gap, or an undecodable frame —
24828
+ * `detail` says which), `still-busy` (the recorder is at its decode bound; try
24829
+ * again), `unreadable-image`, `write-failed`, `unknown-collection`.
24830
+ */
24831
+ var AddRetrainFrameFromRecordingResultSchema = discriminatedUnion("kind", [object({
24832
+ kind: literal("added"),
24833
+ collectionId: string(),
24834
+ frame: RetrainFrameSchema,
24835
+ /** The moment was already in the dataset; nothing was decoded. */
24836
+ reused: boolean()
24837
+ }), object({
24838
+ kind: literal("refused"),
24839
+ reason: _enum([
24840
+ "unknown-collection",
24841
+ "still-unavailable",
24842
+ "still-busy",
24843
+ "unreadable-image",
24844
+ "write-failed"
24845
+ ]),
24846
+ detail: string().optional()
24847
+ })]);
24848
+ /** A vision LLM profile the AI assist may use, and where it sends the frame. */
24849
+ var RetrainAssistProfileSchema = object({
24850
+ id: string(),
24851
+ name: string(),
24852
+ model: string(),
24853
+ kind: string(),
24854
+ /** `true` when the frame would leave the house (a cloud vendor, or an
24855
+ * endpoint that is not on the local network). The page confirms each such
24856
+ * run, and the provider refuses one without `allowCloud`. */
24857
+ leavesHouse: boolean()
24858
+ });
24859
+ /** A box the AI assist proposed: a draft, plus the model's own reason. */
24860
+ var RetrainLlmProposalSchema = RetrainAnnotationDraftSchema.extend({ reason: string() });
24861
+ /** What the AI assist said about a box that was already on the canvas. */
24862
+ var RetrainLlmReviewSchema = object({
24863
+ /** The `ref` the page sent the box under. */
24864
+ ref: string(),
24865
+ verdict: _enum([
24866
+ "confirmed",
24867
+ "wrong-class",
24868
+ "not-an-object",
24869
+ "uncertain"
24870
+ ]),
24871
+ suggestedClass: RetrainMacroClassSchema.optional(),
24872
+ reason: string()
24873
+ });
24874
+ /**
24875
+ * The AI assist's answer. `proposed` carries drafts (`source: 'llm'`, the
24876
+ * model and its confidence) and reviews; items the model got wrong (a box off
24877
+ * the frame, an unasked class, an unknown ref) are dropped and counted in
24878
+ * `rejected`. A whole answer that is not the schema is `malformed-answer`.
24879
+ */
24880
+ var RetrainLlmAssistResultSchema = discriminatedUnion("kind", [object({
24881
+ kind: literal("proposed"),
24882
+ profileId: string(),
24883
+ model: string(),
24884
+ /** The frame was sent outside the house for this answer. */
24885
+ leftHouse: boolean(),
24886
+ proposals: array(RetrainLlmProposalSchema).readonly(),
24887
+ reviews: array(RetrainLlmReviewSchema).readonly(),
24888
+ rejected: number().int()
24889
+ }), object({
24890
+ kind: literal("refused"),
24891
+ reason: _enum([
24892
+ "unknown-frame",
24893
+ "unreadable-frame",
24894
+ "unknown-profile",
24895
+ "profile-disabled",
24896
+ "no-vision",
24897
+ "cloud-not-confirmed",
24898
+ "llm-error",
24899
+ "malformed-answer"
24900
+ ]),
24901
+ detail: string().optional()
24902
+ })]);
24903
+ /** What a dataset version is cut from. Every field narrows. */
24904
+ var RetrainDatasetSelectionSchema = object({
24905
+ deviceIds: array(number()).readonly().optional(),
24906
+ collectionIds: array(string()).max(200).readonly().optional(),
24907
+ frameIds: array(string()).max(2e4).readonly().optional()
24908
+ });
24909
+ /** The counts a dataset is judged by. */
24910
+ var RetrainDatasetStatsSchema = object({
24911
+ frames: number().int(),
24912
+ completeFrames: number().int(),
24913
+ /** `completeFrames / frames`, 0..1. */
24914
+ completeness: number(),
24915
+ /** Boxes to learn (model errors excluded). */
24916
+ subjects: number().int(),
24917
+ modelErrors: number().int(),
24918
+ /** Complete frames with no subject. */
24919
+ hardNegatives: number().int(),
24920
+ /** Subjects per class × camera × day/night. */
24921
+ cells: array(object({
24922
+ macroClass: string(),
24923
+ deviceId: number(),
24924
+ lighting: _enum([
24925
+ "day",
24926
+ "night",
24927
+ "unknown"
24928
+ ]),
24929
+ subjects: number().int(),
24930
+ frames: number().int()
24931
+ })).readonly(),
24932
+ cameras: array(object({
24933
+ deviceId: number(),
24934
+ frames: number().int(),
24935
+ completeFrames: number().int()
24936
+ })).readonly()
24937
+ });
24938
+ /** An immutable dataset version, without its frame list. */
24939
+ var RetrainDatasetVersionSchema = object({
24940
+ id: string(),
24941
+ name: string(),
24942
+ createdAt: number(),
24943
+ selection: RetrainDatasetSelectionSchema,
24944
+ layout: RetrainExportLayoutSchema,
24945
+ completeOnly: boolean(),
24946
+ frameCount: number().int(),
24947
+ /** sha256 of what the frames taught when the version was frozen. */
24948
+ annotationHash: string(),
24949
+ /** The export manifest schema the version was cut under. */
24950
+ manifestSchema: string(),
24951
+ stats: RetrainDatasetStatsSchema
24952
+ });
24953
+ var CreateRetrainDatasetVersionResultSchema = discriminatedUnion("kind", [object({
24954
+ kind: literal("created"),
24955
+ version: RetrainDatasetVersionSchema
24956
+ }), object({
24957
+ kind: literal("refused"),
24958
+ reason: _enum([
24959
+ "empty-name",
24960
+ "duplicate-name",
24961
+ "no-frames"
24962
+ ])
24963
+ })]);
22947
24964
  /** The outcome of a lifecycle move owned by the retrain page. */
22948
24965
  var RetrainTransitionResultSchema = object({
22949
24966
  trackId: string(),
@@ -23661,7 +25678,7 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
23661
25678
  auth: "admin"
23662
25679
  }), method(object({
23663
25680
  deviceId: number(),
23664
- trackId: string(),
25681
+ trackId: string().optional(),
23665
25682
  frameId: string()
23666
25683
  }), object({
23667
25684
  removed: boolean(),
@@ -23678,7 +25695,8 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
23678
25695
  auth: "admin"
23679
25696
  }), method(object({
23680
25697
  deviceId: number(),
23681
- trackId: string(),
25698
+ /** The frame's track, when it has one — checked against the frame. */
25699
+ trackId: string().optional(),
23682
25700
  frameId: string(),
23683
25701
  subject: RetrainAssistSubjectSchema,
23684
25702
  /** Which node runs it. Absent ⇒ wherever an unowned call lands. */
@@ -23686,12 +25704,16 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
23686
25704
  }), RetrainAssistResultSchema, {
23687
25705
  kind: "mutation",
23688
25706
  auth: "admin"
23689
- }), method(object({ trackId: string() }), array(RetrainAnnotationSchema).readonly(), {
25707
+ }), method(object({
25708
+ trackId: string().optional(),
25709
+ frameIds: array(string()).max(2e3).optional()
25710
+ }), array(RetrainAnnotationSchema).readonly(), {
23690
25711
  kind: "query",
23691
25712
  auth: "admin"
23692
25713
  }), method(object({
23693
25714
  deviceId: number(),
23694
- trackId: string(),
25715
+ /** The frame's track, when it has one — checked against the frame. */
25716
+ trackId: string().optional(),
23695
25717
  frameId: string(),
23696
25718
  annotations: array(RetrainAnnotationDraftSchema)
23697
25719
  }), array(RetrainAnnotationSchema).readonly(), {
@@ -23714,7 +25736,7 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
23714
25736
  auth: "admin"
23715
25737
  }), method(object({
23716
25738
  deviceId: number(),
23717
- trackId: string(),
25739
+ trackId: string().optional(),
23718
25740
  frameId: string(),
23719
25741
  complete: boolean()
23720
25742
  }), RetrainFrameSchema, {
@@ -23728,6 +25750,115 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
23728
25750
  kind: "mutation",
23729
25751
  auth: "admin",
23730
25752
  timeoutMs: 60 * 6e4
25753
+ }), method(object({
25754
+ filter: RetrainExportFilterSchema,
25755
+ layout: RetrainExportLayoutSchema
25756
+ }), object({
25757
+ ticket: PeerBytesTicketSchema,
25758
+ frames: number().int(),
25759
+ annotations: number().int()
25760
+ }), {
25761
+ kind: "mutation",
25762
+ auth: "admin",
25763
+ timeoutMs: 12e4
25764
+ }), method(object({
25765
+ selection: RetrainDatasetSelectionSchema,
25766
+ completeOnly: boolean().optional()
25767
+ }), RetrainDatasetStatsSchema, {
25768
+ kind: "query",
25769
+ auth: "admin"
25770
+ }), method(object({
25771
+ name: string().max(120),
25772
+ selection: RetrainDatasetSelectionSchema,
25773
+ layout: RetrainExportLayoutSchema,
25774
+ completeOnly: boolean()
25775
+ }), CreateRetrainDatasetVersionResultSchema, {
25776
+ kind: "mutation",
25777
+ auth: "admin",
25778
+ timeoutMs: 12e4
25779
+ }), method(object({}), array(RetrainDatasetVersionSchema).readonly(), {
25780
+ kind: "query",
25781
+ auth: "admin"
25782
+ }), method(object({ id: string() }), object({ deleted: boolean() }), {
25783
+ kind: "mutation",
25784
+ auth: "admin"
25785
+ }), method(object({ id: string() }), object({
25786
+ found: boolean(),
25787
+ annotationHash: string(),
25788
+ matches: boolean(),
25789
+ missingFrames: number().int()
25790
+ }), {
25791
+ kind: "query",
25792
+ auth: "admin",
25793
+ timeoutMs: 12e4
25794
+ }), method(object({}), array(RetrainAssistProfileSchema).readonly(), {
25795
+ kind: "query",
25796
+ auth: "admin"
25797
+ }), method(object({
25798
+ deviceId: number(),
25799
+ trackId: string().optional(),
25800
+ frameId: string(),
25801
+ profileId: string(),
25802
+ classes: array(RetrainMacroClassSchema).min(1),
25803
+ boxes: array(object({
25804
+ ref: string(),
25805
+ bbox: RetrainBboxSchema,
25806
+ macroClass: RetrainMacroClassSchema,
25807
+ label: string().optional()
25808
+ })).max(50),
25809
+ allowCloud: boolean()
25810
+ }), RetrainLlmAssistResultSchema, {
25811
+ kind: "mutation",
25812
+ auth: "admin",
25813
+ timeoutMs: 18e4
25814
+ }), method(object({ name: string().max(120) }), RetrainCollectionCreateResultSchema, {
25815
+ kind: "mutation",
25816
+ auth: "admin"
25817
+ }), method(object({}), array(RetrainCollectionSchema).readonly(), {
25818
+ kind: "query",
25819
+ auth: "admin"
25820
+ }), method(object({
25821
+ id: string(),
25822
+ name: string().max(120)
25823
+ }), RetrainCollectionRenameResultSchema, {
25824
+ kind: "mutation",
25825
+ auth: "admin"
25826
+ }), method(object({ id: string() }), object({
25827
+ deleted: boolean(),
25828
+ removedFrames: number().int()
25829
+ }), {
25830
+ kind: "mutation",
25831
+ auth: "admin"
25832
+ }), method(object({
25833
+ collectionId: string(),
25834
+ deviceId: number(),
25835
+ epochMs: number()
25836
+ }), AddRetrainFrameFromRecordingResultSchema, {
25837
+ kind: "mutation",
25838
+ auth: "admin",
25839
+ timeoutMs: 6e4
25840
+ }), method(object({
25841
+ collectionId: string(),
25842
+ frameIds: array(string()).min(1).max(500)
25843
+ }), object({
25844
+ added: number().int(),
25845
+ alreadyMember: number().int(),
25846
+ unknownFrameIds: array(string()).readonly()
25847
+ }), {
25848
+ kind: "mutation",
25849
+ auth: "admin"
25850
+ }), method(object({
25851
+ collectionId: string(),
25852
+ frameId: string()
25853
+ }), object({
25854
+ removed: boolean(),
25855
+ deletedFrame: boolean()
25856
+ }), {
25857
+ kind: "mutation",
25858
+ auth: "admin"
25859
+ }), method(object({ collectionId: string() }), array(RetrainFrameSchema).readonly(), {
25860
+ kind: "query",
25861
+ auth: "admin"
23731
25862
  }), method(object({
23732
25863
  /** Which of the three event tables owns the row. */
23733
25864
  ownerType: EventOwnerTypeSchema,
@@ -24351,13 +26482,31 @@ var RecommendationReasonSchema = discriminatedUnion("kind", [
24351
26482
  object({
24352
26483
  kind: literal("no-family-build"),
24353
26484
  format: ModelFormatSchema$1
26485
+ }),
26486
+ object({
26487
+ kind: literal("kept-custom-pin"),
26488
+ modelId: string(),
26489
+ deviceKey: string()
24354
26490
  })
24355
26491
  ]);
26492
+ /** Why a device is left exactly as it is, whatever the plan would pick (D786). */
26493
+ var KeptReasonSchema = _enum(["custom-pin"]);
26494
+ /**
26495
+ * Where a choice's latency came from (D791): this node's own benchmark
26496
+ * result, or the hardware-class table. Measured on the node beats the table.
26497
+ */
26498
+ var LatencySourceSchema = discriminatedUnion("kind", [object({ kind: literal("table") }), object({
26499
+ kind: literal("node-benchmark"),
26500
+ resultId: string(),
26501
+ measuredAtMs: number()
26502
+ })]);
24356
26503
  var DeviceModelChoiceSchema = object({
24357
26504
  modelId: string(),
24358
26505
  p50Ms: number(),
24359
26506
  fps: number(),
24360
26507
  measured: boolean(),
26508
+ /** Absent on a plan from before D791 — read as the table. */
26509
+ source: LatencySourceSchema.optional(),
24361
26510
  /** Parallel sessions at the camera rate with the headroom kept free: ⌊fps × (1 − headroom) / camera fps⌋. */
24362
26511
  capacitySessions: number(),
24363
26512
  personRecall: number()
@@ -24368,6 +26517,8 @@ var DeviceRecommendationSchema = object({
24368
26517
  enabled: boolean(),
24369
26518
  available: boolean(),
24370
26519
  chosen: DeviceModelChoiceSchema.nullable(),
26520
+ /** Present when the device is kept as is: Apply writes nothing on it. */
26521
+ kept: KeptReasonSchema.optional(),
24371
26522
  reasons: array(RecommendationReasonSchema).readonly()
24372
26523
  });
24373
26524
  var NodeRecommendationSchema = object({
@@ -24421,6 +26572,17 @@ var AutoTuneWarningSchema = discriminatedUnion("kind", [
24421
26572
  kind: literal("coral-enabled"),
24422
26573
  nodeId: string(),
24423
26574
  deviceKey: string()
26575
+ }),
26576
+ object({
26577
+ kind: literal("custom-pin-kept"),
26578
+ nodeId: string(),
26579
+ deviceKey: string().nullable(),
26580
+ deviceId: number().nullable(),
26581
+ modelId: string()
26582
+ }),
26583
+ object({
26584
+ kind: literal("custom-registry-unreadable"),
26585
+ error: string()
24424
26586
  })
24425
26587
  ]);
24426
26588
  var AutoTuneOptionsSchema = object({
@@ -24599,13 +26761,14 @@ var SuggestSharesResultSchema = object({
24599
26761
  nodes: array(SuggestedNodeShareSchema).readonly()
24600
26762
  });
24601
26763
  /**
24602
- * Where the node and device shares come from (D750, D755).
24603
- * - `hardware` (default) — computed by the system from each node's static
24604
- * capacity (its accelerators at their Auto tune models, from the measured
24605
- * latency table), recomputed whenever a node or device joins, leaves, is
24606
- * switched on or off, or changes model. No load input.
24607
- * - `benchmark` — the same, from each node's measured capacity (node
24608
- * benchmark results); a node without results falls back to `hardware`.
26764
+ * Where the node and device shares come from (D750, D755, D791).
26765
+ * - `benchmark` (default since D791) — each node's capacity as its own node
26766
+ * benchmark measured it; a node without fresh results is sized from
26767
+ * `hardware` and says so. Measured on the node beats the table.
26768
+ * - `hardware` — computed from each node's static capacity only (its
26769
+ * accelerators at their Auto tune models, from the latency table).
26770
+ * Both are recomputed whenever a node or device joins, leaves, is switched
26771
+ * on or off, changes model, or a benchmark result is written. No load input.
24609
26772
  * - `manual` — the operator's stored sliders.
24610
26773
  * Either way a node or device that cannot take sessions gives its share to
24611
26774
  * the others in proportion; the stored values are never rewritten for that.
@@ -24654,6 +26817,362 @@ var EffectiveSharesSchema = object({
24654
26817
  nodeWeights: record(string(), number()),
24655
26818
  deviceWeights: record(string(), record(string(), number()))
24656
26819
  });
26820
+ /**
26821
+ * Wire shapes of the node benchmark (D791): the operator's plan, the
26822
+ * preflight the confirmation shows, the run the orchestrator owns, what the
26823
+ * measuring runner reports, and the result rows Auto tune and the automatic
26824
+ * shares read.
26825
+ *
26826
+ * ONE node at a time, owned by the pipeline orchestrator. While a run is
26827
+ * active the cluster is in BENCHMARK MODE for that node: it is not a
26828
+ * detection candidate, camera pins naming it are ignored so its sessions move
26829
+ * elsewhere, and both come back when the mode ends — after a crash or a hub
26830
+ * restart too (a persisted manifest, reconciled against the registry).
26831
+ *
26832
+ * Two measurements, both on the node, driven by its own runner (frames never
26833
+ * cross a process at frame rate, D9):
26834
+ * - `device` — one accelerator × one candidate detector, root only, open
26835
+ * loop: how many streams at the camera rate it carries inside the frame
26836
+ * interval;
26837
+ * - `pipeline` — the chosen detector plus the operator's detail steps
26838
+ * (faces, plates, classifiers, CLIP…), on varied frames from the bench
26839
+ * clip: how many parallel sessions the node carries before latency, drops,
26840
+ * CPU, RAM or the event loop give out.
26841
+ */
26842
+ /** Defaults and bounds, one place. */
26843
+ var NODE_BENCHMARK_DEFAULTS = {
26844
+ fpsPerStream: 10,
26845
+ budgetMinutes: 45,
26846
+ minBudgetMinutes: 10,
26847
+ maxBudgetMinutes: 120,
26848
+ /** A result older than this no longer beats the table. */
26849
+ staleAfterDays: 30,
26850
+ /** Warm-in per ramp step (not accounted). */
26851
+ settleSec: 5,
26852
+ /** Accounted window per ramp step. */
26853
+ measureSec: 20,
26854
+ /** Longest the drain may take before the run is refused. */
26855
+ drainTimeoutSec: 120,
26856
+ /** Candidate models per device in one run. */
26857
+ maxModelsPerDevice: 6
26858
+ };
26859
+ /** The two measurements a run can make. */
26860
+ var NodeBenchmarkPhaseSchema = _enum(["device", "pipeline"]);
26861
+ var NodeBenchmarkDevicePlanSchema = object({
26862
+ /** `<backend>:<device>` — `openvino:npu`, `coreml:all`, `cpu`. */
26863
+ deviceKey: string().min(1),
26864
+ /**
26865
+ * Root detector candidates for the `device` measurement, in the order
26866
+ * measured. The FIRST is the one the `pipeline` measurement runs.
26867
+ */
26868
+ modelIds: array(string().min(1)).min(1).max(NODE_BENCHMARK_DEFAULTS.maxModelsPerDevice)
26869
+ });
26870
+ /** What the operator confirmed. */
26871
+ var NodeBenchmarkPlanSchema = object({
26872
+ nodeId: string().min(1),
26873
+ devices: array(NodeBenchmarkDevicePlanSchema).min(1),
26874
+ /** Which measurements run. At least one. */
26875
+ phases: array(NodeBenchmarkPhaseSchema).min(1).default(["device", "pipeline"]),
26876
+ /**
26877
+ * Detail steps (catalog step ids under the root: faces, plates,
26878
+ * classifiers, CLIP…) the `pipeline` measurement enables. The root
26879
+ * detector always runs.
26880
+ */
26881
+ steps: array(string().min(1)).default([]),
26882
+ /** Offered rate of one stream / session. */
26883
+ fpsPerStream: number().int().min(1).max(30).default(NODE_BENCHMARK_DEFAULTS.fpsPerStream),
26884
+ /** Hard deadline: the mode ends and the cluster is restored when it passes. */
26885
+ budgetMinutes: number().int().min(NODE_BENCHMARK_DEFAULTS.minBudgetMinutes).max(NODE_BENCHMARK_DEFAULTS.maxBudgetMinutes).default(NODE_BENCHMARK_DEFAULTS.budgetMinutes),
26886
+ /** Keep the models the run downloaded (default: delete what was not installed before). */
26887
+ keepDownloadedModels: boolean().default(false),
26888
+ /** Start although the other nodes' capacity does not cover the sessions running now. */
26889
+ acceptInsufficientHeadroom: boolean().default(false)
26890
+ });
26891
+ var NodeBenchmarkRefusalSchema = object({
26892
+ kind: _enum([
26893
+ "benchmark-active",
26894
+ "node-offline",
26895
+ "unknown-device",
26896
+ "no-phase",
26897
+ "insufficient-headroom"
26898
+ ]),
26899
+ detail: string(),
26900
+ overridable: boolean()
26901
+ });
26902
+ /** A camera whose detection leaves the node for the run. */
26903
+ var NodeBenchmarkMovingCameraSchema = object({
26904
+ deviceId: number(),
26905
+ /** Placed on the node now (a standing attach or a running session). */
26906
+ placedOnNode: boolean(),
26907
+ /** A node pin naming this node, ignored for the run. */
26908
+ pinnedToNode: boolean()
26909
+ });
26910
+ /** A camera that cannot leave: no other node can obtain its frames. */
26911
+ var NodeBenchmarkStayingCameraSchema = object({
26912
+ deviceId: number(),
26913
+ reason: literal("only-frame-source")
26914
+ });
26915
+ var NodeBenchmarkPreflightSchema = object({
26916
+ nodeId: string(),
26917
+ online: boolean(),
26918
+ moving: array(NodeBenchmarkMovingCameraSchema).readonly(),
26919
+ /** Keep running on the node during the run; the result is flagged contaminated. */
26920
+ staying: array(NodeBenchmarkStayingCameraSchema).readonly(),
26921
+ estimatedDurationMs: number(),
26922
+ /** The run ends and the cluster is restored at the latest after this long. */
26923
+ budgetMs: number(),
26924
+ phases: array(NodeBenchmarkPhaseSchema).readonly(),
26925
+ steps: array(string()).readonly(),
26926
+ devices: array(NodeBenchmarkDevicePlanSchema).readonly(),
26927
+ /** Parallel sessions the cluster runs now, and what the other nodes can carry. */
26928
+ headroom: object({
26929
+ sessionsNow: number(),
26930
+ otherNodesCapacitySessions: number().nullable()
26931
+ }),
26932
+ refusals: array(NodeBenchmarkRefusalSchema).readonly(),
26933
+ canStart: boolean()
26934
+ });
26935
+ /** Where the measuring runner is. */
26936
+ var NodeBenchProgressSchema = object({
26937
+ phase: _enum([
26938
+ "preparing",
26939
+ "device",
26940
+ "pipeline",
26941
+ "cleanup"
26942
+ ]),
26943
+ deviceKey: string().nullable(),
26944
+ modelId: string().nullable(),
26945
+ /** Streams (device) or sessions (pipeline) of the step running now. */
26946
+ load: number().nullable(),
26947
+ cellsDone: number(),
26948
+ cellsTotal: number(),
26949
+ message: string()
26950
+ });
26951
+ /** What limited a ramp. `none` = the ramp ran out of steps still passing. */
26952
+ var NodeBenchLimitSchema = _enum([
26953
+ "p95",
26954
+ "drops",
26955
+ "errors",
26956
+ "stall",
26957
+ "cpu",
26958
+ "ram",
26959
+ "none"
26960
+ ]);
26961
+ var NodeBenchRampStepSchema = object({
26962
+ load: number(),
26963
+ pass: boolean(),
26964
+ p95Ms: number(),
26965
+ dropRatio: number(),
26966
+ /** Completed frames per second over the accounted window. */
26967
+ fps: number(),
26968
+ cpuPct: number().nullable(),
26969
+ ramFreePct: number().nullable(),
26970
+ failReasons: array(string()).readonly()
26971
+ });
26972
+ var NodeBenchCellSchema = discriminatedUnion("phase", [object({
26973
+ phase: literal("device"),
26974
+ deviceKey: string(),
26975
+ modelId: string(),
26976
+ /** Single-stream latency (the K = 1 step). */
26977
+ p50Ms: number(),
26978
+ p95Ms: number(),
26979
+ p99Ms: number(),
26980
+ /** Frames per second sustained at the last passing step. */
26981
+ fps: number(),
26982
+ /** Streams at the camera rate the device carried inside the frame interval; 0 = not even one. */
26983
+ kMax: number(),
26984
+ limitedBy: NodeBenchLimitSchema,
26985
+ /** First call (model load + warm-up). */
26986
+ warmupMs: number(),
26987
+ ramp: array(NodeBenchRampStepSchema).readonly()
26988
+ }), object({
26989
+ phase: literal("pipeline"),
26990
+ deviceKey: string(),
26991
+ modelId: string(),
26992
+ steps: array(string()).readonly(),
26993
+ /** Parallel sessions at the camera rate the node carried; 0 = not even one. */
26994
+ maxSessions: number(),
26995
+ limitedBy: NodeBenchLimitSchema,
26996
+ /** Detail steps that produced at least one result on the clip — a step that never fired measured nothing. */
26997
+ stepsFired: array(string()).readonly(),
26998
+ warmupMs: number(),
26999
+ ramp: array(NodeBenchRampStepSchema).readonly()
27000
+ })]);
27001
+ /**
27002
+ * What a result was measured ON. A result whose fingerprint no longer matches
27003
+ * the node no longer beats the table.
27004
+ */
27005
+ var NodeBenchFingerprintSchema = object({
27006
+ pipelineVersion: string().nullable(),
27007
+ cpuModel: string().nullable(),
27008
+ ramGb: number().nullable(),
27009
+ os: string().nullable(),
27010
+ /** Per device: the pool the cells ran on (runtime + tuning). */
27011
+ pools: record(string(), object({
27012
+ runtime: string(),
27013
+ numWorkers: number(),
27014
+ concurrency: number(),
27015
+ batchMode: string()
27016
+ })).default({})
27017
+ });
27018
+ /** The frames the run used. */
27019
+ var NodeBenchClipSchema = object({
27020
+ /** `camstack-bench-v1` or `reference-images` (the fallback when the clip is not reachable). */
27021
+ id: string(),
27022
+ revision: string().nullable(),
27023
+ frames: number(),
27024
+ width: number(),
27025
+ height: number()
27026
+ });
27027
+ var NodeBenchRunnerInputSchema = object({
27028
+ runId: string().min(1),
27029
+ devices: array(NodeBenchmarkDevicePlanSchema).min(1),
27030
+ phases: array(NodeBenchmarkPhaseSchema).min(1),
27031
+ /** The full detail step tree root for the `pipeline` measurement is built on the node from these ids. */
27032
+ steps: array(string()).default([]),
27033
+ fpsPerStream: number().int().min(1).max(30),
27034
+ /** The runner stops on its own past this instant, whatever the hub does. */
27035
+ deadlineAtMs: number(),
27036
+ settleSec: number().min(0).max(60).default(NODE_BENCHMARK_DEFAULTS.settleSec),
27037
+ measureSec: number().min(2).max(300).default(NODE_BENCHMARK_DEFAULTS.measureSec),
27038
+ keepDownloadedModels: boolean().default(false)
27039
+ });
27040
+ var NodeBenchRunnerStateSchema = _enum([
27041
+ "running",
27042
+ "done",
27043
+ "failed",
27044
+ "aborted"
27045
+ ]);
27046
+ var NodeBenchRunnerStatusSchema = object({
27047
+ runId: string(),
27048
+ nodeId: string(),
27049
+ state: NodeBenchRunnerStateSchema,
27050
+ progress: NodeBenchProgressSchema.nullable(),
27051
+ /** Every finished cell so far — a run stopped half way keeps what it measured. */
27052
+ cells: array(NodeBenchCellSchema).readonly(),
27053
+ fingerprint: NodeBenchFingerprintSchema.nullable(),
27054
+ clip: NodeBenchClipSchema.nullable(),
27055
+ /** Cameras seen running on the node during the run (they share its pools). */
27056
+ activeCameraIds: array(number()).readonly(),
27057
+ /** Models the run downloaded and then deleted (not installed before). */
27058
+ deletedModels: array(string()).readonly(),
27059
+ error: string().nullable(),
27060
+ startedAtMs: number(),
27061
+ finishedAtMs: number().nullable()
27062
+ });
27063
+ var NodeBenchmarkStateSchema = _enum([
27064
+ "draining",
27065
+ "measuring",
27066
+ "restoring",
27067
+ "done",
27068
+ "failed",
27069
+ "aborted"
27070
+ ]);
27071
+ /** Why a run ended. */
27072
+ var NodeBenchmarkEndReasonSchema = _enum([
27073
+ "completed",
27074
+ "operator-abort",
27075
+ "deadline",
27076
+ "node-lost",
27077
+ "runner-lost",
27078
+ "hub-restart",
27079
+ "drain-timeout",
27080
+ "failed"
27081
+ ]);
27082
+ var NodeBenchmarkRunSchema = object({
27083
+ runId: string(),
27084
+ nodeId: string(),
27085
+ state: NodeBenchmarkStateSchema,
27086
+ plan: NodeBenchmarkPlanSchema,
27087
+ startedAtMs: number(),
27088
+ deadlineAtMs: number(),
27089
+ finishedAtMs: number().nullable(),
27090
+ endReason: NodeBenchmarkEndReasonSchema.nullable(),
27091
+ error: string().nullable(),
27092
+ /** Cameras moved off the node for the run. */
27093
+ moved: array(number()).readonly(),
27094
+ /** Cameras that stayed (their only frame source is the node). */
27095
+ staying: array(number()).readonly(),
27096
+ /** Something else ran on the node's pools during the run. */
27097
+ contaminated: boolean(),
27098
+ progress: NodeBenchProgressSchema.nullable(),
27099
+ resultIds: array(string()).readonly()
27100
+ });
27101
+ /** `getNodeBenchmarkStatus`: the active run (or the last one), and whether benchmark mode is on. */
27102
+ var NodeBenchmarkStatusSchema = object({
27103
+ /** The node the cluster is in benchmark mode for; null = none. */
27104
+ modeNodeId: string().nullable(),
27105
+ run: NodeBenchmarkRunSchema.nullable()
27106
+ });
27107
+ /**
27108
+ * One stored measurement — the only authority Auto tune and the automatic
27109
+ * shares read measured capacity from. Written by the orchestrator when a run
27110
+ * ends, never by anyone else.
27111
+ */
27112
+ var NodeBenchmarkResultSchema = object({
27113
+ id: string(),
27114
+ runId: string(),
27115
+ nodeId: string(),
27116
+ cell: NodeBenchCellSchema,
27117
+ fpsPerStream: number(),
27118
+ fingerprint: NodeBenchFingerprintSchema.nullable(),
27119
+ clip: NodeBenchClipSchema.nullable(),
27120
+ /** Other work shared the node's pools (a camera that could not move, or the hub's own duties). */
27121
+ contaminated: boolean(),
27122
+ stayingCameras: array(number()).readonly(),
27123
+ /** The run ended early; the cell itself completed. */
27124
+ partialRun: boolean(),
27125
+ measuredAtMs: number()
27126
+ });
27127
+ var ListNodeBenchmarkResultsInputSchema = object({
27128
+ nodeId: string().optional(),
27129
+ deviceKey: string().optional()
27130
+ });
27131
+ /** A result with its standing today: does it still beat the table? */
27132
+ var NodeBenchmarkResultViewSchema = NodeBenchmarkResultSchema.extend({
27133
+ /** `fresh` beats the table; `stale` falls back to it; `superseded` = a newer row covers the same cell. */
27134
+ standing: _enum([
27135
+ "fresh",
27136
+ "stale",
27137
+ "superseded"
27138
+ ]),
27139
+ staleWhy: _enum([
27140
+ "age",
27141
+ "runtime",
27142
+ "pool-tuning"
27143
+ ]).nullable()
27144
+ });
27145
+ object({
27146
+ runId: string(),
27147
+ nodeId: string(),
27148
+ startedAtMs: number(),
27149
+ deadlineAtMs: number(),
27150
+ plan: NodeBenchmarkPlanSchema,
27151
+ moved: array(number()).readonly(),
27152
+ staying: array(number()).readonly()
27153
+ });
27154
+ /** Candidate detectors per device, for the plan editor. */
27155
+ var NodeBenchmarkCandidatesSchema = object({
27156
+ nodeId: string(),
27157
+ reachable: boolean(),
27158
+ devices: array(object({
27159
+ deviceKey: string(),
27160
+ enabled: boolean(),
27161
+ available: boolean(),
27162
+ /** Ordered: what Auto tune would pick first, then the rest of the family by accuracy. */
27163
+ suggested: array(string()).readonly(),
27164
+ /** Every root detector the device has a build for. */
27165
+ all: array(string()).readonly(),
27166
+ /** The model the device runs now, when pinned. */
27167
+ currentModelId: string().nullable()
27168
+ })).readonly(),
27169
+ /** Detail steps the node's catalog offers under the root (for the `pipeline` measurement). */
27170
+ steps: array(object({
27171
+ id: string(),
27172
+ name: string(),
27173
+ slot: string()
27174
+ })).readonly()
27175
+ });
24657
27176
  object({
24658
27177
  activeCameras: number(),
24659
27178
  throttledCameras: number(),
@@ -25782,7 +28301,16 @@ method(RunnerCameraConfigSchema, object({ success: literal(true) }), { kind: "mu
25782
28301
  }), ParkedTrackFrameSchema.nullable()), method(object({
25783
28302
  deviceId: number(),
25784
28303
  trackId: string()
25785
- }), object({ released: number().int().nonnegative() }), { kind: "mutation" });
28304
+ }), object({ released: number().int().nonnegative() }), { kind: "mutation" }), method(NodeBenchRunnerInputSchema, object({
28305
+ accepted: literal(true),
28306
+ runId: string()
28307
+ }), {
28308
+ kind: "mutation",
28309
+ auth: "admin"
28310
+ }), method(object({ runId: string() }), NodeBenchRunnerStatusSchema.nullable(), { auth: "admin" }), method(object({ runId: string() }), object({ aborted: boolean() }), {
28311
+ kind: "mutation",
28312
+ auth: "admin"
28313
+ });
25786
28314
  var CameraPipelineConfigSchema = object({
25787
28315
  engine: PipelineEngineChoiceSchema.optional(),
25788
28316
  steps: array(PipelineStepInputSchema).readonly(),
@@ -26421,6 +28949,21 @@ method(object({
26421
28949
  }), method(PlacementStatsInputSchema, PlacementStatsSchema, { auth: "admin" }), method(SuggestSharesInputSchema, SuggestSharesResultSchema, { auth: "admin" }), method(_void(), EffectiveSharesSchema, { auth: "admin" }), method(SetShareSourceInputSchema, object({ success: literal(true) }), {
26422
28950
  kind: "mutation",
26423
28951
  auth: "admin"
28952
+ }), method(NodeBenchmarkPlanSchema, NodeBenchmarkPreflightSchema, { auth: "admin" }), method(NodeBenchmarkPlanSchema, discriminatedUnion("kind", [object({
28953
+ kind: literal("started"),
28954
+ runId: string()
28955
+ }), object({
28956
+ kind: literal("refused"),
28957
+ preflight: NodeBenchmarkPreflightSchema
28958
+ })]), {
28959
+ kind: "mutation",
28960
+ auth: "admin"
28961
+ }), method(_void(), NodeBenchmarkStatusSchema, { auth: "admin" }), method(object({ runId: string() }), object({ aborted: boolean() }), {
28962
+ kind: "mutation",
28963
+ auth: "admin"
28964
+ }), method(object({ nodeId: string() }), NodeBenchmarkCandidatesSchema, { auth: "admin" }), method(ListNodeBenchmarkResultsInputSchema, array(NodeBenchmarkResultViewSchema).readonly(), { auth: "admin" }), method(object({ id: string() }), object({ deleted: boolean() }), {
28965
+ kind: "mutation",
28966
+ auth: "admin"
26424
28967
  }), method(object({ deviceId: number() }), CameraPipelineSettingsSchema.nullable()), method(object({
26425
28968
  deviceId: number(),
26426
28969
  addonId: string(),
@@ -26826,8 +29369,8 @@ version: string().optional() }), ServerUpdateActionResultSchema, {
26826
29369
  * `smtp-provider` — pluggable email delivery surface.
26827
29370
  *
26828
29371
  * Collection cap: a deployment may install multiple SMTP relays (e.g.
26829
- * one for transactional / one for notifications). Consumers (magic-link,
26830
- * notifier addons, …) walk the collection and pick the first
29372
+ * one for transactional / one for notifications). Consumers (notifier
29373
+ * addons, …) walk the collection and pick the first
26831
29374
  * ready provider OR target a specific addonId.
26832
29375
  *
26833
29376
  * The shape stays small on purpose — `sendEmail` is enough for the
@@ -27110,7 +29653,7 @@ targets: array(object({
27110
29653
  };
27111
29654
  /**
27112
29655
  * `sso-bridge` — internal hub-only cap that lets SSO-style auth
27113
- * providers (OIDC, SAML, magic-link, …) mint an HMAC-signed token
29656
+ * providers (OIDC, SAML, …) mint an HMAC-signed token
27114
29657
  * carrying the post-callback claims before redirecting back to
27115
29658
  * `/api/auth/sso/finish`.
27116
29659
  *
@@ -27173,7 +29716,14 @@ var SsoBridgeClaimsSchema = object({
27173
29716
  * Verified `iss` of the id_token behind an OIDC login bridge (D782). A
27174
29717
  * subject is unique only per issuer, so a link is bound to it.
27175
29718
  */
27176
- issuer: string().optional()
29719
+ issuer: string().optional(),
29720
+ /**
29721
+ * SHA-256 (hex) of the `camstack_sso_state` cookie the IdP `/start` set in
29722
+ * the browser that began this sign-in. `/api/auth/sso/finish` requires the
29723
+ * request to present the matching cookie — a login bridge is useless in
29724
+ * any other browser.
29725
+ */
29726
+ browserBinding: string().optional()
27177
29727
  });
27178
29728
  method(object({
27179
29729
  claims: SsoBridgeClaimsSchema,
@@ -33050,6 +35600,9 @@ var CreateIntegrationInputSchema = object({
33050
35600
  enabled: boolean().optional(),
33051
35601
  info: record(string(), unknown()).optional(),
33052
35602
  settings: record(string(), unknown()).optional(),
35603
+ /** Keys of `settings` the form's schema declares secret (by type) — kept in
35604
+ * the keychain, not the table (D787). */
35605
+ secretKeys: array(string()).optional(),
33053
35606
  skipRestart: boolean().optional()
33054
35607
  });
33055
35608
  var UpdateIntegrationInputSchema = object({
@@ -33073,7 +35626,9 @@ method(_void(), array(IntegrationWithStateSchema)), method(object({ id: string()
33073
35626
  auth: "admin"
33074
35627
  }), method(object({ id: string() }), record(string(), unknown()), { auth: "admin" }), method(object({
33075
35628
  id: string(),
33076
- settings: record(string(), unknown())
35629
+ settings: record(string(), unknown()),
35630
+ /** Keys the form's schema declares secret (by type) — keychain-stored (D787). */
35631
+ secretKeys: array(string()).optional()
33077
35632
  }), object({ success: boolean() }), {
33078
35633
  kind: "mutation",
33079
35634
  auth: "admin"
@@ -40406,16 +42961,6 @@ var ApiKeySummarySchema = object({
40406
42961
  createdAt: number(),
40407
42962
  lastUsedAt: number().optional()
40408
42963
  });
40409
- var CreateApiKeyInputSchema = object({
40410
- label: string(),
40411
- isAdmin: boolean().default(false),
40412
- allowedProviders: union([array(string()), literal("*")]).optional(),
40413
- allowedDevices: record(string(), union([array(string()), literal("*")])).optional()
40414
- });
40415
- var CreateApiKeyResultSchema = object({
40416
- token: string(),
40417
- record: ApiKeySummarySchema
40418
- });
40419
42964
  var ScopedTokenSummarySchema = object({
40420
42965
  id: string(),
40421
42966
  userId: string(),
@@ -40514,17 +43059,10 @@ method(_void(), array(UserSummarySchema), { auth: "admin" }), method(CreateUserI
40514
43059
  }), UserSummarySchema.extend({ passwordHash: string() }).nullable(), {
40515
43060
  kind: "mutation",
40516
43061
  access: "view"
40517
- }), method(_void(), array(ApiKeySummarySchema), { auth: "admin" }), method(CreateApiKeyInputSchema, CreateApiKeyResultSchema, {
40518
- kind: "mutation",
40519
- auth: "admin",
40520
- access: "create"
40521
- }), method(object({ id: string() }), object({ success: literal(true) }), {
43062
+ }), method(_void(), array(ApiKeySummarySchema), { auth: "admin" }), method(object({ id: string() }), object({ success: literal(true) }), {
40522
43063
  kind: "mutation",
40523
43064
  auth: "admin",
40524
43065
  access: "delete"
40525
- }), method(object({ token: string() }), ApiKeySummarySchema.nullable(), {
40526
- kind: "mutation",
40527
- access: "view"
40528
43066
  }), method(CreateScopedTokenInputSchema, CreateScopedTokenResultSchema, {
40529
43067
  kind: "mutation",
40530
43068
  auth: "admin",
@@ -40598,15 +43136,7 @@ method(_void(), array(UserSummarySchema), { auth: "admin" }), method(CreateUserI
40598
43136
  }).nullable(), { access: "view" }), method(object({ userId: string() }), array(ExternalIdentitySchema), { auth: "admin" }), method(ExternalIdentityKeySchema, object({
40599
43137
  userId: string(),
40600
43138
  issuer: string()
40601
- }).nullable(), { auth: "admin" }), method(ExternalIdentityKeySchema.extend({
40602
- userId: string(),
40603
- issuer: string().min(1),
40604
- label: string().optional()
40605
- }), object({ success: literal(true) }), {
40606
- kind: "mutation",
40607
- auth: "admin",
40608
- access: "create"
40609
- }), method(ExternalIdentityKeySchema.extend({ userId: string() }), object({ success: boolean() }), {
43139
+ }).nullable(), { auth: "admin" }), method(ExternalIdentityKeySchema.extend({ userId: string() }), object({ success: boolean() }), {
40610
43140
  kind: "mutation",
40611
43141
  auth: "admin",
40612
43142
  access: "delete"
@@ -41311,6 +43841,451 @@ var zoneRulesCapability = {
41311
43841
  */
41312
43842
  durability: "restored"
41313
43843
  };
43844
+ /**
43845
+ * `training-provider` — ONE cloud that can run the CamStack trainer.
43846
+ *
43847
+ * A thin, mockable translation layer: it knows how to run a container with a
43848
+ * GPU, move a dataset in, read the job's stdout and hand artefacts back. It
43849
+ * knows nothing about datasets, splits, floors, cost policy or Model Studio —
43850
+ * those are the `training` orchestrator's (D805). Every rule written there
43851
+ * once is what makes a second provider (RunPod, a local NVIDIA node) a new
43852
+ * manifest entry and nothing else.
43853
+ *
43854
+ * Collection, routed by the `addonId` in every single-row input (the `llm` /
43855
+ * `notification-output` posture); `describe` concat-fans across providers.
43856
+ * Every method is `admin`: these spend money.
43857
+ *
43858
+ * Every cloud object a provider creates is tagged with the orchestrator's
43859
+ * `jobKey`, so a retried submit finds the job it already started instead of
43860
+ * starting a second GPU, and `listJobs` can find orphans.
43861
+ *
43862
+ * Bytes never ride a cap field: the dataset arrives as a `ctx.peerBytes`
43863
+ * ticket the producer (pipeline-analytics) minted, and artefacts leave as a
43864
+ * ticket the provider mints (D613).
43865
+ */
43866
+ var TrainingGpuOptionSchema = object({
43867
+ id: string(),
43868
+ label: string(),
43869
+ /** List price, USD per GPU-hour, before any region multiplier. */
43870
+ usdPerHour: number().nonnegative(),
43871
+ vramGb: number().nonnegative()
43872
+ });
43873
+ var TrainingRegionOptionSchema = object({
43874
+ /** `''` = any region (the provider's choice). */
43875
+ id: string(),
43876
+ label: string(),
43877
+ priceMultiplier: number().positive()
43878
+ });
43879
+ /**
43880
+ * The provider's per-account settings, as the orchestrator reads them. They
43881
+ * live in the PROVIDER addon's settings (operator decision 2026-10-08: they
43882
+ * depend on the user's account), never hard-coded in the orchestrator.
43883
+ */
43884
+ var TrainingProviderDefaultsSchema = object({
43885
+ gpuType: string(),
43886
+ region: string(),
43887
+ costCapUsd: number().nonnegative(),
43888
+ maxRuntimeSec: number().int().positive(),
43889
+ /** Hours a FAILED job's cloud dataset is kept for debugging; 0 = delete at once. */
43890
+ failedDatasetGraceHours: number().nonnegative()
43891
+ });
43892
+ var TrainingProviderDescriptorSchema = object({
43893
+ addonId: string(),
43894
+ /** `modal`, `runpod`, `fake`, … */
43895
+ kind: string(),
43896
+ label: string(),
43897
+ gpuTypes: array(TrainingGpuOptionSchema).readonly(),
43898
+ regions: array(TrainingRegionOptionSchema).readonly(),
43899
+ maxDatasetBytes: number().int().positive(),
43900
+ maxRuntimeSec: number().int().positive(),
43901
+ freeTierNote: string().optional(),
43902
+ /** Where the data goes, in one sentence the confirm dialog repeats. */
43903
+ dataResidencyNote: string(),
43904
+ /** Credentials are present — never the values. */
43905
+ configured: boolean(),
43906
+ defaults: TrainingProviderDefaultsSchema
43907
+ });
43908
+ var TrainingCredentialCheckSchema = object({
43909
+ ok: boolean(),
43910
+ /** Workspace / account name, when the provider says. */
43911
+ account: string().optional(),
43912
+ reason: _enum([
43913
+ "missing",
43914
+ "invalid",
43915
+ "forbidden",
43916
+ "network",
43917
+ "quota"
43918
+ ]).optional(),
43919
+ detail: string().optional()
43920
+ });
43921
+ var ProviderJobStateSchema = _enum([
43922
+ "pending",
43923
+ "starting",
43924
+ "running",
43925
+ "succeeded",
43926
+ "failed",
43927
+ "cancelled",
43928
+ "lost"
43929
+ ]);
43930
+ var ProviderJobStatusSchema = object({
43931
+ jobKey: string(),
43932
+ providerJobId: string().optional(),
43933
+ state: ProviderJobStateSchema,
43934
+ startedAt: number().optional(),
43935
+ endedAt: number().optional(),
43936
+ exitCode: number().int().optional(),
43937
+ failureReason: string().optional(),
43938
+ gpuType: string(),
43939
+ region: string().optional(),
43940
+ billedSeconds: number().nonnegative(),
43941
+ costUsd: number().nonnegative(),
43942
+ /** True when `costUsd` is runtime × list price, not a billing answer. */
43943
+ costIsEstimate: boolean(),
43944
+ lastFetchedAt: number()
43945
+ });
43946
+ /**
43947
+ * The trainer the job runs, by SOURCE revision: the provider turns it into an
43948
+ * image its own way (Modal builds the published Dockerfile at that revision;
43949
+ * a registry-pull provider maps it to a tag). Recorded on the job and echoed
43950
+ * in `result.json`.
43951
+ */
43952
+ var TrainerSourceRefSchema = object({
43953
+ /** Hugging Face repo id, e.g. `camstack/camstack-trainer`. */
43954
+ repo: string().min(1),
43955
+ /** A commit sha (never a branch) — the job must be reproducible. */
43956
+ revision: string().regex(/^[0-9a-f]{7,64}$/)
43957
+ });
43958
+ var JobRef = {
43959
+ addonId: string(),
43960
+ jobKey: string().uuid()
43961
+ };
43962
+ var TrainingLogLineSchema = object({
43963
+ ts: number(),
43964
+ text: string()
43965
+ });
43966
+ method(object({}), array(TrainingProviderDescriptorSchema).readonly(), { auth: "admin" }), method(object({ addonId: string() }), TrainingCredentialCheckSchema, {
43967
+ kind: "mutation",
43968
+ auth: "admin",
43969
+ timeoutMs: 3e4
43970
+ }), method(object({
43971
+ addonId: string(),
43972
+ gpuType: string(),
43973
+ region: string(),
43974
+ datasetBytes: number().int().nonnegative(),
43975
+ gpuSecondsLow: number().nonnegative(),
43976
+ gpuSecondsHigh: number().nonnegative()
43977
+ }), object({
43978
+ usdLow: number().nonnegative(),
43979
+ usdHigh: number().nonnegative(),
43980
+ notes: array(string()).readonly()
43981
+ }), { auth: "admin" }), method(object({
43982
+ ...JobRef,
43983
+ ticket: PeerBytesTicketSchema
43984
+ }), object({
43985
+ bytes: number().int().nonnegative(),
43986
+ sha256: string()
43987
+ }), {
43988
+ kind: "mutation",
43989
+ auth: "admin",
43990
+ timeoutMs: 120 * 6e4
43991
+ }), method(object({
43992
+ ...JobRef,
43993
+ trainer: TrainerSourceRefSchema,
43994
+ jobSpecJson: string().min(2).max(64e3),
43995
+ gpuType: string(),
43996
+ region: string(),
43997
+ maxRuntimeSec: number().int().positive()
43998
+ }), ProviderJobStatusSchema, {
43999
+ kind: "mutation",
44000
+ auth: "admin",
44001
+ timeoutMs: 30 * 6e4
44002
+ }), method(object(JobRef), ProviderJobStatusSchema, {
44003
+ auth: "admin",
44004
+ timeoutMs: 6e4
44005
+ }), method(object({
44006
+ ...JobRef,
44007
+ cursor: string().optional(),
44008
+ max: number().int().min(1).max(500)
44009
+ }), object({
44010
+ lines: array(TrainingLogLineSchema).readonly(),
44011
+ cursor: string()
44012
+ }), {
44013
+ auth: "admin",
44014
+ timeoutMs: 6e4
44015
+ }), method(object(JobRef), object({ ok: literal(true) }), {
44016
+ kind: "mutation",
44017
+ auth: "admin",
44018
+ timeoutMs: 6e4
44019
+ }), method(object(JobRef), object({
44020
+ found: boolean(),
44021
+ text: string().optional()
44022
+ }), {
44023
+ kind: "mutation",
44024
+ auth: "admin",
44025
+ timeoutMs: 5 * 6e4
44026
+ }), method(object({
44027
+ ...JobRef,
44028
+ path: _enum(["bundle.tar"])
44029
+ }), object({ ticket: PeerBytesTicketSchema }), {
44030
+ kind: "mutation",
44031
+ auth: "admin",
44032
+ timeoutMs: 5 * 6e4
44033
+ }), method(object(JobRef), object({ deleted: array(string()).readonly() }), {
44034
+ kind: "mutation",
44035
+ auth: "admin",
44036
+ timeoutMs: 5 * 6e4
44037
+ }), method(object({ addonId: string() }), array(ProviderJobStatusSchema).readonly(), {
44038
+ auth: "admin",
44039
+ timeoutMs: 2 * 6e4
44040
+ });
44041
+ /**
44042
+ * `training` — the cloud-training orchestrator (D805). Hub-only singleton,
44043
+ * provided by `addon-training`.
44044
+ *
44045
+ * It owns what every provider must agree on, written once:
44046
+ *
44047
+ * - **Dataset versions.** Taken over from pipeline-analytics (D796): the rows
44048
+ * live here (D808); pipeline-analytics still CUTS a version (it owns the corpus and
44049
+ * the export plan) and reaches this store through the five row methods
44050
+ * below, so the Retrain page and the export did not change.
44051
+ * - **Jobs.** A persisted state machine, a reconcile loop against the
44052
+ * provider, a cost guard, a daily orphan sweep and the retention rules.
44053
+ * - **The return flow.** Verified artefacts → Model Studio
44054
+ * (`custom-model-registry.importModelBundle`) → canary on cameras →
44055
+ * rollback. Nothing is ever registered automatically.
44056
+ *
44057
+ * Every method is `admin`.
44058
+ */
44059
+ /** A version WITH its frame list — what the export and a job read. */
44060
+ var TrainingDatasetVersionRowSchema = RetrainDatasetVersionSchema.omit({ frameCount: true }).extend({ frameIds: array(string()).max(2e4).readonly() });
44061
+ /** A base model a detector job can fine-tune, and the baseline it is judged against. */
44062
+ var TrainingBaseModelSchema = object({
44063
+ modelId: string(),
44064
+ label: string(),
44065
+ weights: string(),
44066
+ imgsz: number().int(),
44067
+ baselineOnnxUrl: string(),
44068
+ baselineFloors: record(string(), number()),
44069
+ /** The base the fleet runs most — the UI's default. */
44070
+ recommended: boolean()
44071
+ });
44072
+ var TrainingPresetSchema = _enum([
44073
+ "quick",
44074
+ "standard",
44075
+ "thorough"
44076
+ ]);
44077
+ var TrainingJobRequestSchema = object({
44078
+ datasetVersionId: string().min(1),
44079
+ /** The `training-provider` addon that runs it. */
44080
+ addonId: string().min(1),
44081
+ gpuType: string().min(1),
44082
+ region: string(),
44083
+ baseModelId: string().min(1),
44084
+ preset: TrainingPresetSchema,
44085
+ /** Freeze the backbone's first N layers; `null` = the preset's choice. */
44086
+ freeze: number().int().nonnegative().nullable(),
44087
+ /** Cameras held out whole for evaluation; `null` = the orchestrator's default. */
44088
+ holdoutCameras: array(number().int()).nullable()
44089
+ });
44090
+ var TrainingSplitPlanSchema = object({
44091
+ holdoutCameras: array(number().int()).readonly(),
44092
+ /** Used when no camera is held out: the last N days of every camera. */
44093
+ holdoutLastDays: number().int().nonnegative(),
44094
+ /** Holdout subjects per class (camera holdout only; `null` = known only after the split). */
44095
+ holdoutSupport: record(string(), number().int()).nullable(),
44096
+ trainSubjects: number().int()
44097
+ });
44098
+ var TrainingRefusalReasonSchema = _enum([
44099
+ "unknown-dataset",
44100
+ "unknown-provider",
44101
+ "provider-not-configured",
44102
+ "unknown-base-model",
44103
+ "unknown-gpu",
44104
+ "dataset-too-large",
44105
+ "no-training-subjects",
44106
+ "job-already-running"
44107
+ ]);
44108
+ var TrainingJobPlanSchema = object({
44109
+ refusal: object({
44110
+ reason: TrainingRefusalReasonSchema,
44111
+ detail: string()
44112
+ }).nullable(),
44113
+ warnings: array(string()).readonly(),
44114
+ split: TrainingSplitPlanSchema.nullable(),
44115
+ estimate: object({
44116
+ datasetBytes: number().int(),
44117
+ uploadMinutesAt20Mbps: number(),
44118
+ gpuSecondsLow: number(),
44119
+ gpuSecondsHigh: number(),
44120
+ usdLow: number(),
44121
+ usdHigh: number(),
44122
+ notes: array(string()).readonly()
44123
+ }).nullable(),
44124
+ /** Pre-filled from the provider's settings; the operator may lower or raise them. */
44125
+ defaults: object({
44126
+ maxCostUsd: number(),
44127
+ maxRuntimeSec: number().int()
44128
+ }).nullable(),
44129
+ /** The sentence the confirm dialog repeats: where the frames go and when they are deleted. */
44130
+ dataNotice: string()
44131
+ });
44132
+ /**
44133
+ * Orchestrator-owned states, persisted. `uploading` covers exporting the
44134
+ * archive (it is streamed, never staged). Terminal: `failed`, `cancelled`,
44135
+ * `lost`, `expired`, `discarded`. `registered` and `canary` are where a
44136
+ * result lives after the operator acted on it.
44137
+ */
44138
+ var TrainingJobStateSchema = _enum([
44139
+ "uploading",
44140
+ "submitted",
44141
+ "starting",
44142
+ "running",
44143
+ "collecting",
44144
+ "ready",
44145
+ "registered",
44146
+ "canary",
44147
+ "failed",
44148
+ "cancelling",
44149
+ "cancelled",
44150
+ "lost",
44151
+ "expired",
44152
+ "discarded"
44153
+ ]);
44154
+ var TrainingFailureReasonSchema = _enum([
44155
+ "cost-cap",
44156
+ "runtime-cap",
44157
+ "upload-failed",
44158
+ "submit-failed",
44159
+ "trainer-failed",
44160
+ "result-invalid",
44161
+ "checksum-mismatch",
44162
+ "fetch-failed",
44163
+ "provider-error",
44164
+ "hub-restart-during-upload"
44165
+ ]);
44166
+ var TrainingProgressPointSchema = object({
44167
+ epoch: number().int(),
44168
+ map50: number().nullable(),
44169
+ map50_95: number().nullable()
44170
+ });
44171
+ var TrainingCanarySchema = object({
44172
+ deviceIds: array(number().int()).readonly(),
44173
+ since: number(),
44174
+ /** Every override the canary replaced, exactly, so rollback restores it. */
44175
+ previous: array(object({
44176
+ deviceId: number().int(),
44177
+ nodeId: string(),
44178
+ deviceKey: string(),
44179
+ patch: object({
44180
+ modelId: string().optional(),
44181
+ settings: record(string(), unknown()).readonly().optional()
44182
+ }).nullable()
44183
+ })).readonly()
44184
+ });
44185
+ var TrainingJobSchema = object({
44186
+ id: string(),
44187
+ idempotencyKey: string(),
44188
+ name: string(),
44189
+ createdAt: number(),
44190
+ updatedAt: number(),
44191
+ state: TrainingJobStateSchema,
44192
+ stage: TrainingStageSchema.nullable(),
44193
+ failure: object({
44194
+ reason: TrainingFailureReasonSchema,
44195
+ stage: string().nullable(),
44196
+ detail: string()
44197
+ }).nullable(),
44198
+ request: TrainingJobRequestSchema,
44199
+ maxCostUsd: number().nonnegative(),
44200
+ maxRuntimeSec: number().int().positive(),
44201
+ trainer: TrainerSourceRefSchema,
44202
+ datasetLayout: RetrainExportLayoutSchema,
44203
+ dataset: object({
44204
+ bytes: number().int(),
44205
+ sha256: string(),
44206
+ uploadedAt: number()
44207
+ }).nullable(),
44208
+ split: TrainingSplitPlanSchema,
44209
+ provider: object({
44210
+ state: ProviderJobStateSchema.nullable(),
44211
+ providerJobId: string().nullable(),
44212
+ startedAt: number().nullable(),
44213
+ endedAt: number().nullable(),
44214
+ billedSeconds: number(),
44215
+ costUsd: number(),
44216
+ costIsEstimate: boolean(),
44217
+ lastPolledAt: number().nullable()
44218
+ }),
44219
+ progress: object({
44220
+ epoch: number().int().nullable(),
44221
+ epochs: number().int().nullable(),
44222
+ etaSec: number().nullable(),
44223
+ series: array(TrainingProgressPointSchema).readonly()
44224
+ }),
44225
+ /** The last lines of the job's output (≤ 200), newest last. Never frame paths. */
44226
+ logTail: array(string()).readonly(),
44227
+ logCursor: string().nullable(),
44228
+ artifacts: object({
44229
+ bundleBytes: number().int(),
44230
+ bundleSha256: string(),
44231
+ fetchedAt: number(),
44232
+ /** When the staged artefacts are deleted from the hub. */
44233
+ expiresAt: number()
44234
+ }).nullable(),
44235
+ /** When the provider-side copy of the frames was deleted; null while it exists. */
44236
+ cloudDatasetDeletedAt: number().nullable(),
44237
+ /** A failed job's dataset is kept until then (the provider's grace), then deleted. */
44238
+ cloudCleanupDueAt: number().nullable(),
44239
+ /** Model ids registered from this job (base, and int8 when kept). */
44240
+ registeredModelIds: array(string()).readonly(),
44241
+ canary: TrainingCanarySchema.nullable()
44242
+ });
44243
+ var IdInput = object({ id: string().min(1) });
44244
+ method(TrainingDatasetVersionRowSchema, object({ stored: boolean() }), {
44245
+ kind: "mutation",
44246
+ auth: "admin"
44247
+ }), 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() }), {
44248
+ kind: "mutation",
44249
+ auth: "admin"
44250
+ }), method(object({}), array(TrainingBaseModelSchema).readonly(), { auth: "admin" }), method(TrainingJobRequestSchema, TrainingJobPlanSchema, {
44251
+ auth: "admin",
44252
+ timeoutMs: 6e4
44253
+ }), method(TrainingJobRequestSchema.extend({
44254
+ name: string().min(1).max(120),
44255
+ maxCostUsd: number().positive(),
44256
+ maxRuntimeSec: number().int().positive(),
44257
+ idempotencyKey: string().min(8).max(80)
44258
+ }), discriminatedUnion("kind", [object({
44259
+ kind: literal("started"),
44260
+ job: TrainingJobSchema
44261
+ }), object({
44262
+ kind: literal("refused"),
44263
+ reason: TrainingRefusalReasonSchema,
44264
+ detail: string()
44265
+ })]), {
44266
+ kind: "mutation",
44267
+ auth: "admin",
44268
+ timeoutMs: 12e4
44269
+ }), method(object({}), array(TrainingJobSchema).readonly(), { auth: "admin" }), method(IdInput, TrainingJobSchema.nullable(), { auth: "admin" }), method(IdInput, TrainingJobSchema, {
44270
+ kind: "mutation",
44271
+ auth: "admin",
44272
+ timeoutMs: 12e4
44273
+ }), method(IdInput, TrainingResultSchema.nullable(), { auth: "admin" }), method(IdInput.extend({ canaryDeviceIds: array(number().int()).readonly() }), TrainingJobSchema, {
44274
+ kind: "mutation",
44275
+ auth: "admin",
44276
+ timeoutMs: 30 * 6e4
44277
+ }), method(IdInput.extend({ deviceIds: array(number().int()).min(1).readonly() }), TrainingJobSchema, {
44278
+ kind: "mutation",
44279
+ auth: "admin",
44280
+ timeoutMs: 12e4
44281
+ }), method(IdInput, TrainingJobSchema, {
44282
+ kind: "mutation",
44283
+ auth: "admin",
44284
+ timeoutMs: 12e4
44285
+ }), method(IdInput, TrainingJobSchema, {
44286
+ kind: "mutation",
44287
+ auth: "admin"
44288
+ });
41314
44289
  SOURCE_CAPS.filter((cap) => cap !== "switch" && cap !== "motion");
41315
44290
  Object.freeze({
41316
44291
  person: .5,
@@ -41812,7 +44787,8 @@ var BaseDevice = class {
41812
44787
  this.role = options.role;
41813
44788
  this.parentDeviceId = ctx.parentDeviceId;
41814
44789
  const seedData = ctx.persistedConfig ?? {};
41815
- this.config = DeviceConfig.fromSchema(schema, (data) => ctx.persistConfig(data), seedData, ({ droppedKeys, issues }) => {
44790
+ const declaredSecretPaths = collectZodSecretPaths(schema);
44791
+ this.config = DeviceConfig.fromSchema(schema, (data) => ctx.persistConfig(data, { secretConfigPaths: declaredSecretPaths }), seedData, ({ droppedKeys, issues }) => {
41816
44792
  ctx.logger.warn("Device config recovery: dropping invalid persisted fields", {
41817
44793
  tags: {
41818
44794
  deviceId: ctx.id,
@@ -43473,6 +46449,12 @@ Object.freeze({
43473
46449
  addonId: null,
43474
46450
  access: "create"
43475
46451
  },
46452
+ "backup.checkBackupKey": {
46453
+ capName: "backup",
46454
+ capScope: "system",
46455
+ addonId: null,
46456
+ access: "create"
46457
+ },
43476
46458
  "backup.delete": {
43477
46459
  capName: "backup",
43478
46460
  capScope: "system",
@@ -43485,6 +46467,18 @@ Object.freeze({
43485
46467
  addonId: null,
43486
46468
  access: "delete"
43487
46469
  },
46470
+ "backup.disableEncryption": {
46471
+ capName: "backup",
46472
+ capScope: "system",
46473
+ addonId: null,
46474
+ access: "create"
46475
+ },
46476
+ "backup.getEncryption": {
46477
+ capName: "backup",
46478
+ capScope: "system",
46479
+ addonId: null,
46480
+ access: "view"
46481
+ },
43488
46482
  "backup.getEntries": {
43489
46483
  capName: "backup",
43490
46484
  capScope: "system",
@@ -43539,6 +46533,12 @@ Object.freeze({
43539
46533
  addonId: null,
43540
46534
  access: "create"
43541
46535
  },
46536
+ "backup.setupEncryption": {
46537
+ capName: "backup",
46538
+ capScope: "system",
46539
+ addonId: null,
46540
+ access: "create"
46541
+ },
43542
46542
  "backup.trigger": {
43543
46543
  capName: "backup",
43544
46544
  capScope: "system",
@@ -44091,6 +47091,12 @@ Object.freeze({
44091
47091
  addonId: null,
44092
47092
  access: "create"
44093
47093
  },
47094
+ "customModelRegistry.importModelBundle": {
47095
+ capName: "custom-model-registry",
47096
+ capScope: "system",
47097
+ addonId: null,
47098
+ access: "create"
47099
+ },
44094
47100
  "customModelRegistry.listModels": {
44095
47101
  capName: "custom-model-registry",
44096
47102
  capScope: "system",
@@ -45501,6 +48507,108 @@ Object.freeze({
45501
48507
  addonId: null,
45502
48508
  access: "create"
45503
48509
  },
48510
+ "keychain.delete": {
48511
+ capName: "keychain",
48512
+ capScope: "system",
48513
+ addonId: null,
48514
+ access: "delete"
48515
+ },
48516
+ "keychain.getState": {
48517
+ capName: "keychain",
48518
+ capScope: "system",
48519
+ addonId: null,
48520
+ access: "view"
48521
+ },
48522
+ "keychain.listMeta": {
48523
+ capName: "keychain",
48524
+ capScope: "system",
48525
+ addonId: null,
48526
+ access: "view"
48527
+ },
48528
+ "keychain.put": {
48529
+ capName: "keychain",
48530
+ capScope: "system",
48531
+ addonId: null,
48532
+ access: "create"
48533
+ },
48534
+ "keychain.resolve": {
48535
+ capName: "keychain",
48536
+ capScope: "system",
48537
+ addonId: null,
48538
+ access: "view"
48539
+ },
48540
+ "keychainAdmin.acknowledgeReset": {
48541
+ capName: "keychain-admin",
48542
+ capScope: "system",
48543
+ addonId: null,
48544
+ access: "create"
48545
+ },
48546
+ "keychainAdmin.deleteOrphans": {
48547
+ capName: "keychain-admin",
48548
+ capScope: "system",
48549
+ addonId: null,
48550
+ access: "delete"
48551
+ },
48552
+ "keychainAdmin.downloadRecoveryKey": {
48553
+ capName: "keychain-admin",
48554
+ capScope: "system",
48555
+ addonId: null,
48556
+ access: "create"
48557
+ },
48558
+ "keychainAdmin.listAudit": {
48559
+ capName: "keychain-admin",
48560
+ capScope: "system",
48561
+ addonId: null,
48562
+ access: "view"
48563
+ },
48564
+ "keychainAdmin.listSecrets": {
48565
+ capName: "keychain-admin",
48566
+ capScope: "system",
48567
+ addonId: null,
48568
+ access: "view"
48569
+ },
48570
+ "keychainAdmin.purgeRetiredKeys": {
48571
+ capName: "keychain-admin",
48572
+ capScope: "system",
48573
+ addonId: null,
48574
+ access: "delete"
48575
+ },
48576
+ "keychainAdmin.resetKeychain": {
48577
+ capName: "keychain-admin",
48578
+ capScope: "system",
48579
+ addonId: null,
48580
+ access: "delete"
48581
+ },
48582
+ "keychainAdmin.resetReport": {
48583
+ capName: "keychain-admin",
48584
+ capScope: "system",
48585
+ addonId: null,
48586
+ access: "delete"
48587
+ },
48588
+ "keychainAdmin.reveal": {
48589
+ capName: "keychain-admin",
48590
+ capScope: "system",
48591
+ addonId: null,
48592
+ access: "create"
48593
+ },
48594
+ "keychainAdmin.rotateMasterKey": {
48595
+ capName: "keychain-admin",
48596
+ capScope: "system",
48597
+ addonId: null,
48598
+ access: "create"
48599
+ },
48600
+ "keychainAdmin.setSystemSecret": {
48601
+ capName: "keychain-admin",
48602
+ capScope: "system",
48603
+ addonId: null,
48604
+ access: "create"
48605
+ },
48606
+ "keychainAdmin.status": {
48607
+ capName: "keychain-admin",
48608
+ capScope: "system",
48609
+ addonId: null,
48610
+ access: "view"
48611
+ },
45504
48612
  "lawnMowerControl.dock": {
45505
48613
  capName: "lawn-mower-control",
45506
48614
  capScope: "device",
@@ -46875,6 +49983,18 @@ Object.freeze({
46875
49983
  addonId: null,
46876
49984
  access: "create"
46877
49985
  },
49986
+ "pipelineAnalytics.addRetrainFrameFromRecording": {
49987
+ capName: "pipeline-analytics",
49988
+ capScope: "device",
49989
+ addonId: null,
49990
+ access: "create"
49991
+ },
49992
+ "pipelineAnalytics.addRetrainFramesToCollection": {
49993
+ capName: "pipeline-analytics",
49994
+ capScope: "device",
49995
+ addonId: null,
49996
+ access: "create"
49997
+ },
46878
49998
  "pipelineAnalytics.applyDeviceSettingsPatch": {
46879
49999
  capName: "pipeline-analytics",
46880
50000
  capScope: "device",
@@ -46923,12 +50043,36 @@ Object.freeze({
46923
50043
  addonId: null,
46924
50044
  access: "view"
46925
50045
  },
50046
+ "pipelineAnalytics.createRetrainCollection": {
50047
+ capName: "pipeline-analytics",
50048
+ capScope: "device",
50049
+ addonId: null,
50050
+ access: "create"
50051
+ },
50052
+ "pipelineAnalytics.createRetrainDatasetVersion": {
50053
+ capName: "pipeline-analytics",
50054
+ capScope: "device",
50055
+ addonId: null,
50056
+ access: "create"
50057
+ },
46926
50058
  "pipelineAnalytics.deleteDeviceEvents": {
46927
50059
  capName: "pipeline-analytics",
46928
50060
  capScope: "device",
46929
50061
  addonId: null,
46930
50062
  access: "delete"
46931
50063
  },
50064
+ "pipelineAnalytics.deleteRetrainCollection": {
50065
+ capName: "pipeline-analytics",
50066
+ capScope: "device",
50067
+ addonId: null,
50068
+ access: "delete"
50069
+ },
50070
+ "pipelineAnalytics.deleteRetrainDatasetVersion": {
50071
+ capName: "pipeline-analytics",
50072
+ capScope: "device",
50073
+ addonId: null,
50074
+ access: "delete"
50075
+ },
46932
50076
  "pipelineAnalytics.deleteTracks": {
46933
50077
  capName: "pipeline-analytics",
46934
50078
  capScope: "device",
@@ -47133,6 +50277,30 @@ Object.freeze({
47133
50277
  addonId: null,
47134
50278
  access: "view"
47135
50279
  },
50280
+ "pipelineAnalytics.listRetrainAssistProfiles": {
50281
+ capName: "pipeline-analytics",
50282
+ capScope: "device",
50283
+ addonId: null,
50284
+ access: "view"
50285
+ },
50286
+ "pipelineAnalytics.listRetrainCollectionFrames": {
50287
+ capName: "pipeline-analytics",
50288
+ capScope: "device",
50289
+ addonId: null,
50290
+ access: "view"
50291
+ },
50292
+ "pipelineAnalytics.listRetrainCollections": {
50293
+ capName: "pipeline-analytics",
50294
+ capScope: "device",
50295
+ addonId: null,
50296
+ access: "view"
50297
+ },
50298
+ "pipelineAnalytics.listRetrainDatasetVersions": {
50299
+ capName: "pipeline-analytics",
50300
+ capScope: "device",
50301
+ addonId: null,
50302
+ access: "view"
50303
+ },
47136
50304
  "pipelineAnalytics.listRetrainFrames": {
47137
50305
  capName: "pipeline-analytics",
47138
50306
  capScope: "device",
@@ -47163,6 +50331,12 @@ Object.freeze({
47163
50331
  addonId: null,
47164
50332
  access: "view"
47165
50333
  },
50334
+ "pipelineAnalytics.offerRetrainArchive": {
50335
+ capName: "pipeline-analytics",
50336
+ capScope: "device",
50337
+ addonId: null,
50338
+ access: "create"
50339
+ },
47166
50340
  "pipelineAnalytics.ownersWithMedia": {
47167
50341
  capName: "pipeline-analytics",
47168
50342
  capScope: "device",
@@ -47175,12 +50349,24 @@ Object.freeze({
47175
50349
  addonId: null,
47176
50350
  access: "create"
47177
50351
  },
50352
+ "pipelineAnalytics.previewRetrainDataset": {
50353
+ capName: "pipeline-analytics",
50354
+ capScope: "device",
50355
+ addonId: null,
50356
+ access: "view"
50357
+ },
47178
50358
  "pipelineAnalytics.proposeRetrainAnnotations": {
47179
50359
  capName: "pipeline-analytics",
47180
50360
  capScope: "device",
47181
50361
  addonId: null,
47182
50362
  access: "create"
47183
50363
  },
50364
+ "pipelineAnalytics.proposeRetrainAnnotationsWithLlm": {
50365
+ capName: "pipeline-analytics",
50366
+ capScope: "device",
50367
+ addonId: null,
50368
+ access: "create"
50369
+ },
47184
50370
  "pipelineAnalytics.pruneEvents": {
47185
50371
  capName: "pipeline-analytics",
47186
50372
  capScope: "device",
@@ -47235,6 +50421,18 @@ Object.freeze({
47235
50421
  addonId: null,
47236
50422
  access: "create"
47237
50423
  },
50424
+ "pipelineAnalytics.removeRetrainFrameFromCollection": {
50425
+ capName: "pipeline-analytics",
50426
+ capScope: "device",
50427
+ addonId: null,
50428
+ access: "delete"
50429
+ },
50430
+ "pipelineAnalytics.renameRetrainCollection": {
50431
+ capName: "pipeline-analytics",
50432
+ capScope: "device",
50433
+ addonId: null,
50434
+ access: "create"
50435
+ },
47238
50436
  "pipelineAnalytics.restageRetrainTrack": {
47239
50437
  capName: "pipeline-analytics",
47240
50438
  capScope: "device",
@@ -47295,6 +50493,12 @@ Object.freeze({
47295
50493
  addonId: null,
47296
50494
  access: "create"
47297
50495
  },
50496
+ "pipelineAnalytics.verifyRetrainDatasetVersion": {
50497
+ capName: "pipeline-analytics",
50498
+ capScope: "device",
50499
+ addonId: null,
50500
+ access: "view"
50501
+ },
47298
50502
  "pipelineAnalytics.wipeAllAnalytics": {
47299
50503
  capName: "pipeline-analytics",
47300
50504
  capScope: "device",
@@ -47523,6 +50727,12 @@ Object.freeze({
47523
50727
  addonId: null,
47524
50728
  access: "view"
47525
50729
  },
50730
+ "pipelineOrchestrator.abortNodeBenchmark": {
50731
+ capName: "pipeline-orchestrator",
50732
+ capScope: "system",
50733
+ addonId: null,
50734
+ access: "create"
50735
+ },
47526
50736
  "pipelineOrchestrator.applyAutoTune": {
47527
50737
  capName: "pipeline-orchestrator",
47528
50738
  capScope: "system",
@@ -47547,6 +50757,12 @@ Object.freeze({
47547
50757
  addonId: null,
47548
50758
  access: "create"
47549
50759
  },
50760
+ "pipelineOrchestrator.deleteNodeBenchmarkResult": {
50761
+ capName: "pipeline-orchestrator",
50762
+ capScope: "system",
50763
+ addonId: null,
50764
+ access: "delete"
50765
+ },
47550
50766
  "pipelineOrchestrator.getAgentLoad": {
47551
50767
  capName: "pipeline-orchestrator",
47552
50768
  capScope: "system",
@@ -47655,6 +50871,24 @@ Object.freeze({
47655
50871
  addonId: null,
47656
50872
  access: "view"
47657
50873
  },
50874
+ "pipelineOrchestrator.getNodeBenchmarkCandidates": {
50875
+ capName: "pipeline-orchestrator",
50876
+ capScope: "system",
50877
+ addonId: null,
50878
+ access: "view"
50879
+ },
50880
+ "pipelineOrchestrator.getNodeBenchmarkPreflight": {
50881
+ capName: "pipeline-orchestrator",
50882
+ capScope: "system",
50883
+ addonId: null,
50884
+ access: "view"
50885
+ },
50886
+ "pipelineOrchestrator.getNodeBenchmarkStatus": {
50887
+ capName: "pipeline-orchestrator",
50888
+ capScope: "system",
50889
+ addonId: null,
50890
+ access: "view"
50891
+ },
47658
50892
  "pipelineOrchestrator.getNodeInferenceDevices": {
47659
50893
  capName: "pipeline-orchestrator",
47660
50894
  capScope: "system",
@@ -47697,6 +50931,12 @@ Object.freeze({
47697
50931
  addonId: null,
47698
50932
  access: "view"
47699
50933
  },
50934
+ "pipelineOrchestrator.listNodeBenchmarkResults": {
50935
+ capName: "pipeline-orchestrator",
50936
+ capScope: "system",
50937
+ addonId: null,
50938
+ access: "view"
50939
+ },
47700
50940
  "pipelineOrchestrator.pauseForStorageMigration": {
47701
50941
  capName: "pipeline-orchestrator",
47702
50942
  capScope: "system",
@@ -47841,6 +51081,12 @@ Object.freeze({
47841
51081
  addonId: null,
47842
51082
  access: "create"
47843
51083
  },
51084
+ "pipelineOrchestrator.startNodeBenchmark": {
51085
+ capName: "pipeline-orchestrator",
51086
+ capScope: "system",
51087
+ addonId: null,
51088
+ access: "create"
51089
+ },
47844
51090
  "pipelineOrchestrator.suggestShares": {
47845
51091
  capName: "pipeline-orchestrator",
47846
51092
  capScope: "system",
@@ -47859,6 +51105,12 @@ Object.freeze({
47859
51105
  addonId: null,
47860
51106
  access: "create"
47861
51107
  },
51108
+ "pipelineRunner.abortNodeBench": {
51109
+ capName: "pipeline-runner",
51110
+ capScope: "system",
51111
+ addonId: null,
51112
+ access: "create"
51113
+ },
47862
51114
  "pipelineRunner.attachCamera": {
47863
51115
  capName: "pipeline-runner",
47864
51116
  capScope: "system",
@@ -47907,6 +51159,12 @@ Object.freeze({
47907
51159
  addonId: null,
47908
51160
  access: "view"
47909
51161
  },
51162
+ "pipelineRunner.getNodeBenchStatus": {
51163
+ capName: "pipeline-runner",
51164
+ capScope: "system",
51165
+ addonId: null,
51166
+ access: "view"
51167
+ },
47910
51168
  "pipelineRunner.getParkedTrackFrame": {
47911
51169
  capName: "pipeline-runner",
47912
51170
  capScope: "system",
@@ -47949,6 +51207,12 @@ Object.freeze({
47949
51207
  addonId: null,
47950
51208
  access: "create"
47951
51209
  },
51210
+ "pipelineRunner.startNodeBench": {
51211
+ capName: "pipeline-runner",
51212
+ capScope: "system",
51213
+ addonId: null,
51214
+ access: "create"
51215
+ },
47952
51216
  "plateGallery.assignPlate": {
47953
51217
  capName: "plate-gallery",
47954
51218
  capScope: "system",
@@ -49611,6 +52875,174 @@ Object.freeze({
49611
52875
  addonId: null,
49612
52876
  access: "view"
49613
52877
  },
52878
+ "training.canaryResult": {
52879
+ capName: "training",
52880
+ capScope: "system",
52881
+ addonId: null,
52882
+ access: "create"
52883
+ },
52884
+ "training.cancelJob": {
52885
+ capName: "training",
52886
+ capScope: "system",
52887
+ addonId: null,
52888
+ access: "create"
52889
+ },
52890
+ "training.discardResult": {
52891
+ capName: "training",
52892
+ capScope: "system",
52893
+ addonId: null,
52894
+ access: "create"
52895
+ },
52896
+ "training.findDatasetVersionIdByName": {
52897
+ capName: "training",
52898
+ capScope: "system",
52899
+ addonId: null,
52900
+ access: "view"
52901
+ },
52902
+ "training.getDatasetVersion": {
52903
+ capName: "training",
52904
+ capScope: "system",
52905
+ addonId: null,
52906
+ access: "view"
52907
+ },
52908
+ "training.getJob": {
52909
+ capName: "training",
52910
+ capScope: "system",
52911
+ addonId: null,
52912
+ access: "view"
52913
+ },
52914
+ "training.getJobResult": {
52915
+ capName: "training",
52916
+ capScope: "system",
52917
+ addonId: null,
52918
+ access: "view"
52919
+ },
52920
+ "training.listBaseModels": {
52921
+ capName: "training",
52922
+ capScope: "system",
52923
+ addonId: null,
52924
+ access: "view"
52925
+ },
52926
+ "training.listDatasetVersions": {
52927
+ capName: "training",
52928
+ capScope: "system",
52929
+ addonId: null,
52930
+ access: "view"
52931
+ },
52932
+ "training.listJobs": {
52933
+ capName: "training",
52934
+ capScope: "system",
52935
+ addonId: null,
52936
+ access: "view"
52937
+ },
52938
+ "training.planJob": {
52939
+ capName: "training",
52940
+ capScope: "system",
52941
+ addonId: null,
52942
+ access: "view"
52943
+ },
52944
+ "training.putDatasetVersion": {
52945
+ capName: "training",
52946
+ capScope: "system",
52947
+ addonId: null,
52948
+ access: "create"
52949
+ },
52950
+ "training.registerResult": {
52951
+ capName: "training",
52952
+ capScope: "system",
52953
+ addonId: null,
52954
+ access: "create"
52955
+ },
52956
+ "training.removeDatasetVersion": {
52957
+ capName: "training",
52958
+ capScope: "system",
52959
+ addonId: null,
52960
+ access: "delete"
52961
+ },
52962
+ "training.rollbackCanary": {
52963
+ capName: "training",
52964
+ capScope: "system",
52965
+ addonId: null,
52966
+ access: "create"
52967
+ },
52968
+ "training.startJob": {
52969
+ capName: "training",
52970
+ capScope: "system",
52971
+ addonId: null,
52972
+ access: "create"
52973
+ },
52974
+ "trainingProvider.cancelJob": {
52975
+ capName: "training-provider",
52976
+ capScope: "system",
52977
+ addonId: null,
52978
+ access: "create"
52979
+ },
52980
+ "trainingProvider.cleanupJob": {
52981
+ capName: "training-provider",
52982
+ capScope: "system",
52983
+ addonId: null,
52984
+ access: "create"
52985
+ },
52986
+ "trainingProvider.describe": {
52987
+ capName: "training-provider",
52988
+ capScope: "system",
52989
+ addonId: null,
52990
+ access: "view"
52991
+ },
52992
+ "trainingProvider.estimateJob": {
52993
+ capName: "training-provider",
52994
+ capScope: "system",
52995
+ addonId: null,
52996
+ access: "view"
52997
+ },
52998
+ "trainingProvider.getJob": {
52999
+ capName: "training-provider",
53000
+ capScope: "system",
53001
+ addonId: null,
53002
+ access: "view"
53003
+ },
53004
+ "trainingProvider.listJobEvents": {
53005
+ capName: "training-provider",
53006
+ capScope: "system",
53007
+ addonId: null,
53008
+ access: "view"
53009
+ },
53010
+ "trainingProvider.listJobs": {
53011
+ capName: "training-provider",
53012
+ capScope: "system",
53013
+ addonId: null,
53014
+ access: "view"
53015
+ },
53016
+ "trainingProvider.offerArtifact": {
53017
+ capName: "training-provider",
53018
+ capScope: "system",
53019
+ addonId: null,
53020
+ access: "create"
53021
+ },
53022
+ "trainingProvider.readResult": {
53023
+ capName: "training-provider",
53024
+ capScope: "system",
53025
+ addonId: null,
53026
+ access: "create"
53027
+ },
53028
+ "trainingProvider.submitJob": {
53029
+ capName: "training-provider",
53030
+ capScope: "system",
53031
+ addonId: null,
53032
+ access: "create"
53033
+ },
53034
+ "trainingProvider.uploadDataset": {
53035
+ capName: "training-provider",
53036
+ capScope: "system",
53037
+ addonId: null,
53038
+ access: "create"
53039
+ },
53040
+ "trainingProvider.validateCredentials": {
53041
+ capName: "training-provider",
53042
+ capScope: "system",
53043
+ addonId: null,
53044
+ access: "create"
53045
+ },
49614
53046
  "turnProvider.getTurnServers": {
49615
53047
  capName: "turn-provider",
49616
53048
  capScope: "system",
@@ -49635,12 +53067,6 @@ Object.freeze({
49635
53067
  addonId: null,
49636
53068
  access: "create"
49637
53069
  },
49638
- "userManagement.createApiKey": {
49639
- capName: "user-management",
49640
- capScope: "system",
49641
- addonId: null,
49642
- access: "create"
49643
- },
49644
53070
  "userManagement.createScopedToken": {
49645
53071
  capName: "user-management",
49646
53072
  capScope: "system",
@@ -49677,12 +53103,6 @@ Object.freeze({
49677
53103
  addonId: null,
49678
53104
  access: "view"
49679
53105
  },
49680
- "userManagement.linkExternalIdentity": {
49681
- capName: "user-management",
49682
- capScope: "system",
49683
- addonId: null,
49684
- access: "create"
49685
- },
49686
53106
  "userManagement.listApiKeys": {
49687
53107
  capName: "user-management",
49688
53108
  capScope: "system",
@@ -49785,12 +53205,6 @@ Object.freeze({
49785
53205
  addonId: null,
49786
53206
  access: "create"
49787
53207
  },
49788
- "userManagement.validateApiKey": {
49789
- capName: "user-management",
49790
- capScope: "system",
49791
- addonId: null,
49792
- access: "view"
49793
- },
49794
53208
  "userManagement.validateCredentials": {
49795
53209
  capName: "user-management",
49796
53210
  capScope: "system",
@@ -53096,6 +56510,11 @@ Object.freeze({
53096
56510
  form: "single",
53097
56511
  optional: false
53098
56512
  }],
56513
+ "pipelineAnalytics.addRetrainFrameFromRecording": [{
56514
+ name: "deviceId",
56515
+ form: "single",
56516
+ optional: false
56517
+ }],
53099
56518
  "pipelineAnalytics.applyDeviceSettingsPatch": [{
53100
56519
  name: "deviceId",
53101
56520
  form: "single",
@@ -53286,6 +56705,11 @@ Object.freeze({
53286
56705
  form: "single",
53287
56706
  optional: false
53288
56707
  }],
56708
+ "pipelineAnalytics.proposeRetrainAnnotationsWithLlm": [{
56709
+ name: "deviceId",
56710
+ form: "single",
56711
+ optional: false
56712
+ }],
53289
56713
  "pipelineAnalytics.pruneEventsBefore": [{
53290
56714
  name: "deviceId",
53291
56715
  form: "single",
@@ -54112,6 +57536,11 @@ Object.freeze({
54112
57536
  form: "single",
54113
57537
  optional: false
54114
57538
  }],
57539
+ "training.canaryResult": [{
57540
+ name: "deviceIds",
57541
+ form: "array",
57542
+ optional: false
57543
+ }],
54115
57544
  "update.getStatus": [{
54116
57545
  name: "deviceId",
54117
57546
  form: "single",