@camstack/addon-decoder-nodeav 1.2.121 → 1.2.122

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/index.js +3669 -111
  2. package/dist/index.mjs +3669 -111
  3. package/package.json +1 -1
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import { randomUUID } from "node:crypto";
2
- //#region ../types/dist/event-category-B_0XEcLF.mjs
2
+ //#region ../types/dist/event-category-DaIZi00R.mjs
3
3
  var EventCategory = /* @__PURE__ */ function(EventCategory) {
4
4
  EventCategory["SystemBoot"] = "system.boot";
5
5
  EventCategory["SystemAddonsReady"] = "system.addons-ready";
@@ -78,6 +78,13 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
78
78
  */
79
79
  EventCategory["AddonLoadFailed"] = "addon.load-failed";
80
80
  /**
81
+ * A keychain value was stored or removed (D787). Carries the ref, its
82
+ * owner and the new version — NEVER the value. A process holding the ref
83
+ * drops its cached copy and the owning `BaseAddon` re-resolves its config.
84
+ * Telemetry (D8): a process that misses it still revalidates by version.
85
+ */
86
+ EventCategory["KeychainChanged"] = "keychain.changed";
87
+ /**
81
88
  * Addon recovered from a previous failure. Emitted when an addon
82
89
  * transitions from `failed` back to `healthy` (typically via the
83
90
  * monitor's auto-retry loop, or after manual `addons.retryLoad`).
@@ -5370,7 +5377,7 @@ var ZodIssueCode = {
5370
5377
  var ZodFirstPartyTypeKind;
5371
5378
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
5372
5379
  //#endregion
5373
- //#region ../types/dist/sleep-BNeXenvr.mjs
5380
+ //#region ../types/dist/sleep-r3RWkGVx.mjs
5374
5381
  /**
5375
5382
  * The audio chunk plane's byte format, and the ONE expansion from a coded
5376
5383
  * window to float samples (D455).
@@ -5449,6 +5456,97 @@ function buildAlawTable() {
5449
5456
  }
5450
5457
  buildUlawTable();
5451
5458
  buildAlawTable();
5459
+ /** Is this field's stored value a credential? */
5460
+ function isSecretConfigField(field) {
5461
+ if (field.type === "password") return true;
5462
+ return "secret" in field && field.secret === true;
5463
+ }
5464
+ /**
5465
+ * Is this field's value stored in the KEYCHAIN (D787)? Every secret field is,
5466
+ * by its TYPE, unless it opts out with `storage: 'inline'` — never by its name.
5467
+ */
5468
+ function isKeychainStoredField(field) {
5469
+ if (!isSecretConfigField(field)) return false;
5470
+ if (field.type === "textarea" && field.isJson === true) return false;
5471
+ return !("storage" in field && field.storage === "inline");
5472
+ }
5473
+ /**
5474
+ * What a settings blob holds where a secret used to be.
5475
+ *
5476
+ * A keychain-stored field never holds its value. It holds a self-describing
5477
+ * MARKER, `{"$secret":"secret://…","v":1}` — an object, never a string, so no
5478
+ * code can mistake it for a credential and no form can send it to a camera as
5479
+ * a password. The empty state is `null` / absent, never `''`.
5480
+ *
5481
+ * The same shapes travel to and from the admin UI:
5482
+ *
5483
+ * - read: `hydrateSchema` hands a secret field a {@link SecretFieldView}
5484
+ * (`{ $secret, v, set: true }`) or `null` — the browser learns whether a
5485
+ * value is set, never the value.
5486
+ * - write: an untouched field submits the view back unchanged (KEEP); a typed
5487
+ * value is a plain non-empty string (CHANGE); the Clear button submits
5488
+ * {@link SECRET_CLEAR} (CLEAR). `''`, `null` and the legacy redaction tokens
5489
+ * are KEEP — an empty string is what a defaults-fallback pushes back, and
5490
+ * treating it as "clear" is how a save destroyed a stored credential before.
5491
+ *
5492
+ * Pure and browser-safe.
5493
+ */
5494
+ var SECRET_CLEAR = { $secretClear: true };
5495
+ /** The `'***'` token D634 redaction writes for non-admins. */
5496
+ var LEGACY_DEVICE_REDACTION = "***";
5497
+ function isRecord$2(value) {
5498
+ return typeof value === "object" && value !== null && !Array.isArray(value);
5499
+ }
5500
+ function makeSecretMarker(ref) {
5501
+ return {
5502
+ $secret: ref,
5503
+ v: 1
5504
+ };
5505
+ }
5506
+ /** A stored marker: an object whose `$secret` is a non-empty string. */
5507
+ function isSecretMarker(value) {
5508
+ if (!isRecord$2(value)) return false;
5509
+ const ref = value["$secret"];
5510
+ return typeof ref === "string" && ref.length > 0;
5511
+ }
5512
+ function isSecretClear(value) {
5513
+ return isRecord$2(value) && value["$secretClear"] === true;
5514
+ }
5515
+ /**
5516
+ * The UI view of a stored secret field value: a marker becomes "set", inline
5517
+ * plaintext becomes "set (inline)", nothing becomes `null`. A value never
5518
+ * survives this function.
5519
+ */
5520
+ function toSecretFieldView(stored) {
5521
+ if (isSecretMarker(stored)) return {
5522
+ $secret: stored.$secret,
5523
+ v: 1,
5524
+ set: true
5525
+ };
5526
+ if (typeof stored === "string" && stored.length > 0) return {
5527
+ $secret: null,
5528
+ v: 1,
5529
+ set: true,
5530
+ inline: true
5531
+ };
5532
+ return null;
5533
+ }
5534
+ /**
5535
+ * Classify an incoming value for a secret path. Only a non-empty string that is
5536
+ * not a redaction token sets a value; only {@link SECRET_CLEAR} clears.
5537
+ * Everything else — a marker (ours or anyone's), a UI view, `''`, `null`,
5538
+ * `undefined`, a redaction token, a non-string — keeps what is stored.
5539
+ */
5540
+ function classifySecretWrite(incoming) {
5541
+ if (isSecretClear(incoming)) return { kind: "clear" };
5542
+ if (typeof incoming !== "string") return { kind: "keep" };
5543
+ if (incoming.length === 0) return { kind: "keep" };
5544
+ if (incoming === "__camstack_redacted__" || incoming === LEGACY_DEVICE_REDACTION) return { kind: "keep" };
5545
+ return {
5546
+ kind: "set",
5547
+ value: incoming
5548
+ };
5549
+ }
5452
5550
  Object.fromEntries([
5453
5551
  {
5454
5552
  id: "overview",
@@ -5620,33 +5718,19 @@ Object.fromEntries([
5620
5718
  function isValuelessField(field) {
5621
5719
  return field.type === "separator" || field.type === "info" || field.type === "qr-code" || field.type === "button" || field.type === "object-array" || field.type === "widget" || field.type === "addon-action-button" || field.type === "device-action-button";
5622
5720
  }
5623
- /**
5624
- * Merge a `ConfigUISchema` with a raw `values` record into a
5625
- * `ConfigUISchemaWithValues`. Used by every `get*Settings` backend endpoint
5626
- * before returning to the admin UI. Groups are walked recursively.
5627
- *
5628
- * For each leaf field:
5629
- * - structural fields (`separator`, `info`, `button`) pass through unchanged
5630
- * - other fields get `value = values[key] ?? field.default ?? null`
5631
- *
5632
- * Unknown keys in `values` (keys not declared in the schema) are silently
5633
- * ignored — they don't contribute to the output. Missing keys fall back to
5634
- * the schema default or `null`. This mirrors the old backend behaviour where
5635
- * `FormBuilder` rendered `values[key] ?? field.default`.
5636
- */
5637
- function hydrateSchema(schema, values) {
5721
+ function hydrateSchema(schema, values, options = {}) {
5638
5722
  return {
5639
5723
  ...schema.tabs ? { tabs: [...schema.tabs] } : {},
5640
5724
  sections: schema.sections.map((section) => ({
5641
5725
  ...section,
5642
- fields: section.fields.map((field) => hydrateField(field, values))
5726
+ fields: section.fields.map((field) => hydrateField(field, values, options))
5643
5727
  }))
5644
5728
  };
5645
5729
  }
5646
- function hydrateField(field, values) {
5730
+ function hydrateField(field, values, options) {
5647
5731
  if (isValuelessField(field)) return field;
5648
5732
  if (field.type === "group") {
5649
- const hydratedChildren = field.fields.map((child) => hydrateField(child, values));
5733
+ const hydratedChildren = field.fields.map((child) => hydrateField(child, values, options));
5650
5734
  return {
5651
5735
  ...field,
5652
5736
  fields: hydratedChildren
@@ -5655,7 +5739,7 @@ function hydrateField(field, values) {
5655
5739
  if (field.type === "sub-tabs") {
5656
5740
  const hydratedTabs = field.tabs.map((tab) => ({
5657
5741
  ...tab,
5658
- fields: tab.fields.map((child) => hydrateField(child, values))
5742
+ fields: tab.fields.map((child) => hydrateField(child, values, options))
5659
5743
  }));
5660
5744
  return {
5661
5745
  ...field,
@@ -5665,6 +5749,33 @@ function hydrateField(field, values) {
5665
5749
  const key = field.key;
5666
5750
  const storedValue = Object.prototype.hasOwnProperty.call(values, key) ? values[key] : void 0;
5667
5751
  const defaultValue = field.default;
5752
+ const asView = (v) => isSecretMarker(v) || options.inlineSecretsAsViews === true && v !== void 0;
5753
+ if (isKeychainStoredField(field) && asView(storedValue)) return {
5754
+ ...field,
5755
+ value: toSecretFieldView(storedValue)
5756
+ };
5757
+ if (isKeychainStoredField(field) && options.inlineSecretsAsViews === true) return {
5758
+ ...field,
5759
+ value: null
5760
+ };
5761
+ if (field.type === "editable-array" && Array.isArray(storedValue)) {
5762
+ const secretItemKeys = field.itemFields.filter((item) => "key" in item && isKeychainStoredField(item)).map((item) => "key" in item ? item.key : "");
5763
+ if (secretItemKeys.length > 0) {
5764
+ const rows = storedValue.map((row) => {
5765
+ if (row === null || typeof row !== "object" || Array.isArray(row)) return row;
5766
+ const out = { ...row };
5767
+ for (const k of secretItemKeys) {
5768
+ const v = Reflect.get(row, k);
5769
+ if (asView(v)) out[k] = toSecretFieldView(v);
5770
+ }
5771
+ return out;
5772
+ });
5773
+ return {
5774
+ ...field,
5775
+ value: rows
5776
+ };
5777
+ }
5778
+ }
5668
5779
  if (field.multiple) {
5669
5780
  const stored = Array.isArray(storedValue) ? storedValue : storedValue !== void 0 && storedValue !== null ? [storedValue] : [];
5670
5781
  const itemFallback = field.multiple.itemDefault !== void 0 ? field.multiple.itemDefault : defaultValue !== void 0 ? defaultValue : typeOf(field) === "string" ? "" : null;
@@ -5907,6 +6018,778 @@ function projectStore(store, perNodeKeys, nodeId) {
5907
6018
  }
5908
6019
  return out;
5909
6020
  }
6021
+ var GLOBAL_SCOPE = { kind: "global" };
6022
+ /** The scope every addon-wide (not per-node, not per-device) setting lives in. */
6023
+ function globalSecretScope() {
6024
+ return GLOBAL_SCOPE;
6025
+ }
6026
+ function encodeSegment(value) {
6027
+ return encodeURIComponent(value);
6028
+ }
6029
+ function decodeSegment(value) {
6030
+ try {
6031
+ return decodeURIComponent(value);
6032
+ } catch {
6033
+ return null;
6034
+ }
6035
+ }
6036
+ /**
6037
+ * The field path of a value inside an array item, addressed by the item's id:
6038
+ * `arrayItemFieldPath('providers', 'authentik', 'clientSecret')` →
6039
+ * `providers[authentik].clientSecret`.
6040
+ */
6041
+ function arrayItemFieldPath(arrayKey, itemId, fieldKey) {
6042
+ return `${arrayKey}[${encodeSegment(itemId)}].${fieldKey}`;
6043
+ }
6044
+ function parseScope(segments) {
6045
+ switch (segments[0]) {
6046
+ case "global": return {
6047
+ scope: GLOBAL_SCOPE,
6048
+ used: 1
6049
+ };
6050
+ case "node": {
6051
+ const nodeId = segments[1] !== void 0 ? decodeSegment(segments[1]) : null;
6052
+ return nodeId === null || nodeId.length === 0 ? null : {
6053
+ scope: {
6054
+ kind: "node",
6055
+ nodeId
6056
+ },
6057
+ used: 2
6058
+ };
6059
+ }
6060
+ case "device": {
6061
+ const raw = segments[1];
6062
+ if (raw === void 0 || !/^\d+$/.test(raw)) return null;
6063
+ return {
6064
+ scope: {
6065
+ kind: "device",
6066
+ deviceId: Number(raw)
6067
+ },
6068
+ used: 2
6069
+ };
6070
+ }
6071
+ case "integration": {
6072
+ const id = segments[1] !== void 0 ? decodeSegment(segments[1]) : null;
6073
+ return id === null || id.length === 0 ? null : {
6074
+ scope: {
6075
+ kind: "integration",
6076
+ integrationId: id
6077
+ },
6078
+ used: 2
6079
+ };
6080
+ }
6081
+ case "row": {
6082
+ const collection = segments[1] !== void 0 ? decodeSegment(segments[1]) : null;
6083
+ const rowId = segments[2] !== void 0 ? decodeSegment(segments[2]) : null;
6084
+ if (collection === null || rowId === null || collection.length === 0 || rowId.length === 0) return null;
6085
+ return {
6086
+ scope: {
6087
+ kind: "row",
6088
+ collection,
6089
+ rowId
6090
+ },
6091
+ used: 3
6092
+ };
6093
+ }
6094
+ default: return null;
6095
+ }
6096
+ }
6097
+ /** Take a ref apart; `null` when it is not a well-formed ref. */
6098
+ function parseSecretRef(ref) {
6099
+ if (!ref.startsWith("secret://")) return null;
6100
+ const segments = ref.slice(9).split("/");
6101
+ const owner = segments[0] !== void 0 ? decodeSegment(segments[0]) : null;
6102
+ if (owner === null || owner.length === 0) return null;
6103
+ const parsed = parseScope(segments.slice(1));
6104
+ if (parsed === null) return null;
6105
+ const fieldPath = segments.slice(1 + parsed.used).join("/");
6106
+ if (fieldPath.length === 0) return null;
6107
+ return {
6108
+ owner,
6109
+ scope: parsed.scope,
6110
+ fieldPath
6111
+ };
6112
+ }
6113
+ /** A write to a secret path could not be stored in the keychain, so it was refused. */
6114
+ var KeychainWriteRefusedError = class extends Error {
6115
+ fieldPath;
6116
+ constructor(fieldPath, cause) {
6117
+ super(`secret "${fieldPath}" was not saved: the keychain could not store it (${cause instanceof Error ? cause.message : String(cause)}). Nothing was written.`);
6118
+ this.fieldPath = fieldPath;
6119
+ this.name = "KeychainWriteRefusedError";
6120
+ }
6121
+ };
6122
+ var KEEP = { kind: "keep" };
6123
+ function isRecord$1(value) {
6124
+ return typeof value === "object" && value !== null && !Array.isArray(value);
6125
+ }
6126
+ function defaultMintId() {
6127
+ return globalThis.crypto.randomUUID();
6128
+ }
6129
+ /** Every marker ref anywhere under `value`. */
6130
+ function collectSecretMarkerRefs(value, out = []) {
6131
+ if (isSecretMarker(value)) {
6132
+ out.push(value.$secret);
6133
+ return out;
6134
+ }
6135
+ if (Array.isArray(value)) for (const item of value) collectSecretMarkerRefs(item, out);
6136
+ else if (isRecord$1(value)) for (const child of Object.values(value)) collectSecretMarkerRefs(child, out);
6137
+ return out;
6138
+ }
6139
+ async function storedValueEquals(secrets, marker, candidate) {
6140
+ const resolved = (await secrets.resolve([marker.$secret]))[marker.$secret];
6141
+ return resolved?.kind === "value" && resolved.value === candidate;
6142
+ }
6143
+ async function writeLeaf(ctx, incoming, stored, fieldPath) {
6144
+ const intent = classifySecretWrite(incoming);
6145
+ const ref = ctx.secrets.ref(ctx.scope, fieldPath);
6146
+ const storedIsOurs = isSecretMarker(stored) && stored.$secret === ref;
6147
+ if (intent.kind === "keep") return KEEP;
6148
+ if (intent.kind === "set" && !ctx.operatorWrite && typeof stored === "string" && stored === intent.value) return KEEP;
6149
+ if (intent.kind === "clear") {
6150
+ if (storedIsOurs) ctx.deletes.push(ref);
6151
+ return {
6152
+ kind: "value",
6153
+ value: null
6154
+ };
6155
+ }
6156
+ if (storedIsOurs && await storedValueEquals(ctx.secrets, stored, intent.value)) return {
6157
+ kind: "value",
6158
+ value: stored
6159
+ };
6160
+ try {
6161
+ await ctx.secrets.put(ref, intent.value);
6162
+ } catch (err) {
6163
+ throw new KeychainWriteRefusedError(fieldPath, err);
6164
+ }
6165
+ return {
6166
+ kind: "value",
6167
+ value: makeSecretMarker(ref)
6168
+ };
6169
+ }
6170
+ /** Apply a member result onto `out`: KEEP restores the stored member, or removes it. */
6171
+ function applyMember(out, key, result, storedParent) {
6172
+ if (result.kind === "value") {
6173
+ out[key] = result.value;
6174
+ return;
6175
+ }
6176
+ if (Object.prototype.hasOwnProperty.call(storedParent, key)) out[key] = storedParent[key];
6177
+ else delete out[key];
6178
+ }
6179
+ async function writeMembers(ctx, children, incoming, stored, pathOf) {
6180
+ const out = { ...incoming };
6181
+ for (const [member, node] of children) applyMember(out, member, await writeNode(ctx, node, incoming[member], stored[member], pathOf(member)), stored);
6182
+ return out;
6183
+ }
6184
+ function rowId(row, idKey) {
6185
+ const raw = row[idKey];
6186
+ if (typeof raw === "string" && raw.length > 0) return raw;
6187
+ if (typeof raw === "number" && Number.isFinite(raw)) return String(raw);
6188
+ return null;
6189
+ }
6190
+ async function writeArray(ctx, node, incoming, stored, fieldPath) {
6191
+ const storedRows = Array.isArray(stored) ? stored.filter(isRecord$1) : [];
6192
+ if (!Array.isArray(incoming)) {
6193
+ ctx.deletes.push(...collectSecretMarkerRefs(storedRows));
6194
+ return {
6195
+ kind: "value",
6196
+ value: incoming
6197
+ };
6198
+ }
6199
+ const storedById = /* @__PURE__ */ new Map();
6200
+ for (const row of storedRows) {
6201
+ const id = rowId(row, node.idKey);
6202
+ if (id !== null) storedById.set(id, row);
6203
+ }
6204
+ const kept = /* @__PURE__ */ new Set();
6205
+ const rows = [];
6206
+ for (const row of incoming) {
6207
+ if (!isRecord$1(row)) {
6208
+ rows.push(row);
6209
+ continue;
6210
+ }
6211
+ const id = rowId(row, node.idKey) ?? ctx.mintId();
6212
+ kept.add(id);
6213
+ const withId = {
6214
+ ...row,
6215
+ [node.idKey]: row[node.idKey] ?? id
6216
+ };
6217
+ if (rowId(withId, node.idKey) === null) withId[node.idKey] = id;
6218
+ const storedRow = storedById.get(id) ?? {};
6219
+ rows.push(await writeMembers(ctx, node.item, withId, storedRow, (member) => arrayItemFieldPath(fieldPath, id, member)));
6220
+ }
6221
+ for (const [id, row] of storedById) if (!kept.has(id)) ctx.deletes.push(...collectSecretMarkerRefs(row));
6222
+ return {
6223
+ kind: "value",
6224
+ value: rows
6225
+ };
6226
+ }
6227
+ async function writeNode(ctx, node, incoming, stored, fieldPath) {
6228
+ switch (node.kind) {
6229
+ case "leaf": return writeLeaf(ctx, incoming, stored, fieldPath);
6230
+ case "array": return writeArray(ctx, node, incoming, stored, fieldPath);
6231
+ case "object": {
6232
+ if (!isRecord$1(incoming)) {
6233
+ if (incoming === void 0) return KEEP;
6234
+ ctx.deletes.push(...collectSecretMarkerRefs(stored));
6235
+ return {
6236
+ kind: "value",
6237
+ value: incoming
6238
+ };
6239
+ }
6240
+ const storedObj = isRecord$1(stored) ? stored : {};
6241
+ return {
6242
+ kind: "value",
6243
+ value: await writeMembers(ctx, node.children, incoming, storedObj, (m) => `${fieldPath}.${m}`)
6244
+ };
6245
+ }
6246
+ }
6247
+ }
6248
+ /** Split a perNode-scoped key (`key@nodeId`). */
6249
+ function splitNodeKey(key) {
6250
+ const at = key.indexOf("@");
6251
+ return at <= 0 ? {
6252
+ base: key,
6253
+ nodeId: null
6254
+ } : {
6255
+ base: key.slice(0, at),
6256
+ nodeId: key.slice(at + 1)
6257
+ };
6258
+ }
6259
+ /** Rewrite a settings patch so no secret value reaches the blob. See the file doc. */
6260
+ async function transformSecretWrite(input) {
6261
+ const deletes = [];
6262
+ const base = {
6263
+ secrets: input.secrets,
6264
+ mintId: input.mintId ?? defaultMintId,
6265
+ deletes,
6266
+ operatorWrite: input.operatorWrite === true
6267
+ };
6268
+ const out = {};
6269
+ for (const [key, incoming] of Object.entries(input.patch)) {
6270
+ const { base: baseKey, nodeId } = splitNodeKey(key);
6271
+ const node = input.tree.get(baseKey);
6272
+ if (node === void 0) {
6273
+ out[key] = incoming;
6274
+ continue;
6275
+ }
6276
+ const scope = nodeId !== null && nodeId.length > 0 ? {
6277
+ kind: "node",
6278
+ nodeId
6279
+ } : input.scope ?? globalSecretScope();
6280
+ const result = await writeNode({
6281
+ ...base,
6282
+ scope
6283
+ }, node, incoming, input.stored[key], baseKey);
6284
+ if (result.kind === "value") out[key] = result.value;
6285
+ }
6286
+ return {
6287
+ patch: out,
6288
+ afterWrite: async () => {
6289
+ if (deletes.length === 0) return { orphaned: [] };
6290
+ try {
6291
+ await input.secrets.delete([...new Set(deletes)]);
6292
+ return { orphaned: [] };
6293
+ } catch {
6294
+ return { orphaned: [...new Set(deletes)] };
6295
+ }
6296
+ }
6297
+ };
6298
+ }
6299
+ /** Is `ref` one of `owner`'s refs? */
6300
+ function isSecretRefOwnedBy(ref, owner) {
6301
+ return parseSecretRef(ref)?.owner === owner;
6302
+ }
6303
+ /**
6304
+ * Replace every marker in `value` with its keychain value. Returns the SAME
6305
+ * reference when there is no marker (no allocation, no keychain call).
6306
+ */
6307
+ async function resolveSecretMarkers(value, secrets, options = {}) {
6308
+ const keepMarker = options.unresolved === "keep-marker";
6309
+ const owner = options.ownedBy;
6310
+ const inScope = (ref) => owner === void 0 || isSecretRefOwnedBy(ref, owner);
6311
+ const refs = collectSecretMarkerRefs(value).filter(inScope);
6312
+ if (refs.length === 0) return {
6313
+ value,
6314
+ unresolved: []
6315
+ };
6316
+ const answers = await secrets.resolve(refs);
6317
+ const unresolved = [];
6318
+ for (const ref of new Set(refs)) {
6319
+ const answer = answers[ref];
6320
+ if (answer === void 0) unresolved.push({
6321
+ ref,
6322
+ reason: "not-initialized"
6323
+ });
6324
+ else if (answer.kind === "unavailable") unresolved.push({
6325
+ ref,
6326
+ reason: answer.reason
6327
+ });
6328
+ else if (answer.kind === "missing" || answer.kind === "forbidden") unresolved.push({
6329
+ ref,
6330
+ reason: answer.kind
6331
+ });
6332
+ }
6333
+ const substitute = (v) => {
6334
+ if (isSecretMarker(v)) {
6335
+ if (!inScope(v.$secret)) return {
6336
+ keep: true,
6337
+ value: v
6338
+ };
6339
+ const answer = answers[v.$secret];
6340
+ if (answer?.kind === "value") return {
6341
+ keep: true,
6342
+ value: answer.value
6343
+ };
6344
+ return keepMarker ? {
6345
+ keep: true,
6346
+ value: v
6347
+ } : {
6348
+ keep: false,
6349
+ value: void 0
6350
+ };
6351
+ }
6352
+ if (Array.isArray(v)) {
6353
+ const items = [];
6354
+ for (const item of v) {
6355
+ const s = substitute(item);
6356
+ if (s.keep) items.push(s.value);
6357
+ }
6358
+ return {
6359
+ keep: true,
6360
+ value: items
6361
+ };
6362
+ }
6363
+ if (isRecord$1(v)) {
6364
+ const out = {};
6365
+ for (const [k, child] of Object.entries(v)) {
6366
+ const s = substitute(child);
6367
+ if (s.keep) out[k] = s.value;
6368
+ }
6369
+ return {
6370
+ keep: true,
6371
+ value: out
6372
+ };
6373
+ }
6374
+ return {
6375
+ keep: true,
6376
+ value: v
6377
+ };
6378
+ };
6379
+ return {
6380
+ value: substitute(value).value,
6381
+ unresolved
6382
+ };
6383
+ }
6384
+ /** An addon tried to replace a stored secret it could not read. Nothing was written. */
6385
+ var SecretOverwriteRefusedError = class extends Error {
6386
+ ref;
6387
+ reason;
6388
+ constructor(ref, reason) {
6389
+ super(`secret ${ref} was not replaced: its stored value cannot be read right now (${reason}), and an addon may not overwrite a secret it cannot see. Nothing was written.`);
6390
+ this.ref = ref;
6391
+ this.reason = reason;
6392
+ this.name = "SecretOverwriteRefusedError";
6393
+ }
6394
+ };
6395
+ function isRecord(value) {
6396
+ return typeof value === "object" && value !== null && !Array.isArray(value);
6397
+ }
6398
+ function resolvedValue(pass, marker) {
6399
+ const answer = pass.answers[marker.$secret];
6400
+ return answer?.kind === "value" ? answer.value : null;
6401
+ }
6402
+ async function atMarker(pass, incoming, stored) {
6403
+ if (incoming === null) return stored;
6404
+ if (typeof incoming !== "string") return incoming;
6405
+ if (incoming === resolvedValue(pass, stored)) return stored;
6406
+ const intent = classifySecretWrite(incoming);
6407
+ if (intent.kind !== "set") return stored;
6408
+ const ref = stored.$secret;
6409
+ if (!isSecretRefOwnedBy(ref, pass.secrets.owner)) return incoming;
6410
+ const answer = pass.answers[ref];
6411
+ if ((answer === void 0 || answer.kind === "unavailable" || answer.kind === "forbidden") && !pass.operatorWrite) throw new SecretOverwriteRefusedError(ref, answer === void 0 ? "not-initialized" : answer.kind === "unavailable" ? answer.reason : answer.kind);
6412
+ try {
6413
+ await pass.secrets.put(ref, intent.value);
6414
+ } catch (err) {
6415
+ throw new KeychainWriteRefusedError(ref, err);
6416
+ }
6417
+ pass.changedRefs.push(ref);
6418
+ return stored;
6419
+ }
6420
+ function inArray(pass, incoming, stored) {
6421
+ return incoming.map((item, index) => {
6422
+ const twin = stored[index];
6423
+ if (isSecretMarker(twin)) return typeof item === "string" && item === resolvedValue(pass, twin) ? twin : item;
6424
+ if (isRecord(item) && isRecord(twin)) return inArrayRow(pass, item, twin);
6425
+ if (Array.isArray(item) && Array.isArray(twin)) return inArray(pass, item, twin);
6426
+ return item;
6427
+ });
6428
+ }
6429
+ function inArrayRow(pass, incoming, stored) {
6430
+ const out = { ...incoming };
6431
+ for (const [key, value] of Object.entries(incoming)) {
6432
+ const twin = stored[key];
6433
+ if (isSecretMarker(twin)) {
6434
+ if (typeof value === "string" && value === resolvedValue(pass, twin)) out[key] = twin;
6435
+ } else if (isRecord(value) && isRecord(twin)) out[key] = inArrayRow(pass, value, twin);
6436
+ else if (Array.isArray(value) && Array.isArray(twin)) out[key] = inArray(pass, value, twin);
6437
+ }
6438
+ return out;
6439
+ }
6440
+ async function walk(pass, incoming, stored) {
6441
+ if (isSecretMarker(stored)) return atMarker(pass, incoming, stored);
6442
+ if (Array.isArray(incoming) && Array.isArray(stored)) return inArray(pass, incoming, stored);
6443
+ if (!isRecord(incoming) || !isRecord(stored)) return incoming;
6444
+ const out = { ...incoming };
6445
+ for (const [key, value] of Object.entries(incoming)) out[key] = await walk(pass, value, stored[key]);
6446
+ return out;
6447
+ }
6448
+ /** Restore markers a write-back carries as values. See the file doc. */
6449
+ async function restoreUnchangedSecrets(input) {
6450
+ const refs = [];
6451
+ for (const key of Object.keys(input.patch)) collectSecretMarkerRefs(input.stored[key], refs);
6452
+ const owned = refs.filter((ref) => isSecretRefOwnedBy(ref, input.secrets.owner));
6453
+ if (owned.length === 0) return {
6454
+ patch: input.patch,
6455
+ changedRefs: []
6456
+ };
6457
+ const pass = {
6458
+ secrets: input.secrets,
6459
+ answers: await input.secrets.resolve([...new Set(owned)]),
6460
+ operatorWrite: input.operatorWrite,
6461
+ changedRefs: []
6462
+ };
6463
+ const out = {};
6464
+ for (const [key, value] of Object.entries(input.patch)) out[key] = await walk(pass, value, input.stored[key]);
6465
+ return {
6466
+ patch: out,
6467
+ changedRefs: pass.changedRefs
6468
+ };
6469
+ }
6470
+ /** Structural equality over JSON-shaped values (key order does not matter). */
6471
+ function isJsonEqual(a, b) {
6472
+ if (Object.is(a, b)) return true;
6473
+ if (Array.isArray(a)) return Array.isArray(b) && a.length === b.length && a.every((v, i) => isJsonEqual(v, b[i]));
6474
+ if (isRecord(a) && isRecord(b)) {
6475
+ const keys = Object.keys(a);
6476
+ if (keys.length !== Object.keys(b).length) return false;
6477
+ return keys.every((k) => Object.prototype.hasOwnProperty.call(b, k) && isJsonEqual(a[k], b[k]));
6478
+ }
6479
+ return false;
6480
+ }
6481
+ /** The patch without the keys whose value already equals the stored one. */
6482
+ function dropUnchangedKeys(patch, stored) {
6483
+ const out = {};
6484
+ for (const [key, value] of Object.entries(patch)) {
6485
+ if (Object.prototype.hasOwnProperty.call(stored, key) && isJsonEqual(value, stored[key])) continue;
6486
+ out[key] = value;
6487
+ }
6488
+ return out;
6489
+ }
6490
+ /** The top-level keys of a blob that hold at least one of `owner`'s markers. */
6491
+ function markerKeysOf(blob, owner) {
6492
+ const keys = /* @__PURE__ */ new Set();
6493
+ for (const [key, value] of Object.entries(blob)) if (collectSecretMarkerRefs(value).some((ref) => isSecretRefOwnedBy(ref, owner))) keys.add(key);
6494
+ return keys;
6495
+ }
6496
+ function nodeFromStored(value, owner) {
6497
+ if (isSecretMarker(value)) return isSecretRefOwnedBy(value.$secret, owner) ? { kind: "leaf" } : null;
6498
+ if (!isRecord(value)) return null;
6499
+ const children = /* @__PURE__ */ new Map();
6500
+ for (const [key, child] of Object.entries(value)) {
6501
+ const node = nodeFromStored(child, owner);
6502
+ if (node !== null) children.set(key, node);
6503
+ }
6504
+ return children.size > 0 ? {
6505
+ kind: "object",
6506
+ children
6507
+ } : null;
6508
+ }
6509
+ /**
6510
+ * The declared secret tree, widened by every place the STORED blob holds a
6511
+ * marker under one of `keys` — so a marker the schema no longer declares (or
6512
+ * never declared: Wyze before b4906cec6) still gets the save path's
6513
+ * KEEP / SET / CLEAR semantics instead of being overwritten by whatever the
6514
+ * addon writes. Markers inside arrays are not added: a row has no id field to
6515
+ * match by unless the schema declares one. Only `owner`'s markers count: a
6516
+ * builtin that keeps another addon's marker (device-manager) never takes it
6517
+ * over.
6518
+ */
6519
+ function widenTreeWithStoredMarkers(declared, stored, keys, owner) {
6520
+ const added = /* @__PURE__ */ new Map();
6521
+ for (const key of keys) {
6522
+ const at = key.indexOf("@");
6523
+ const base = at > 0 ? key.slice(0, at) : key;
6524
+ if (declared.has(base) || added.has(base)) continue;
6525
+ const node = nodeFromStored(stored[key], owner);
6526
+ if (node !== null) added.set(base, node);
6527
+ }
6528
+ return added.size === 0 ? declared : new Map([...declared, ...added]);
6529
+ }
6530
+ /** The blob as stored now; a failed read REFUSES the write instead of guessing. */
6531
+ async function readStoredAddonBlob(raw) {
6532
+ const threeWay = raw.readAddonStoreResult;
6533
+ if (threeWay === void 0) return raw.readAddonStore();
6534
+ const result = await threeWay.call(raw);
6535
+ if (result.kind === "failed") throw new Error(`settings write refused: the stored blob could not be read (${result.error})`);
6536
+ return result.kind === "missing" ? {} : result.value;
6537
+ }
6538
+ function touchesTree(tree, patch) {
6539
+ if (tree.size === 0) return false;
6540
+ for (const key of Object.keys(patch)) {
6541
+ const at = key.indexOf("@");
6542
+ if (tree.has(at > 0 ? key.slice(0, at) : key)) return true;
6543
+ }
6544
+ return false;
6545
+ }
6546
+ /**
6547
+ * Which top-level keys of each store held markers when last seen. `undefined`
6548
+ * for a store not seen yet: its first write reads it, to be safe.
6549
+ */
6550
+ var MarkerKeyIndex = class {
6551
+ owner;
6552
+ byStore = /* @__PURE__ */ new Map();
6553
+ constructor(owner) {
6554
+ this.owner = owner;
6555
+ }
6556
+ seen(store, blob) {
6557
+ this.byStore.set(store, markerKeysOf(blob, this.owner));
6558
+ }
6559
+ wrote(store, patch) {
6560
+ const keys = this.byStore.get(store);
6561
+ if (keys === void 0) return;
6562
+ const now = markerKeysOf(patch, this.owner);
6563
+ for (const key of Object.keys(patch)) if (now.has(key)) keys.add(key);
6564
+ else keys.delete(key);
6565
+ }
6566
+ mayHoldMarkers(store, patch) {
6567
+ const keys = this.byStore.get(store);
6568
+ if (keys === void 0) return true;
6569
+ return Object.keys(patch).some((key) => keys.has(key));
6570
+ }
6571
+ };
6572
+ function createHandle(raw, opts) {
6573
+ const chains = /* @__PURE__ */ new Map();
6574
+ const serialize = (key, fn) => {
6575
+ const next = (chains.get(key) ?? Promise.resolve()).then(fn, fn);
6576
+ const tail = next.catch(() => void 0);
6577
+ chains.set(key, tail);
6578
+ tail.then(() => {
6579
+ if (chains.get(key) === tail) chains.delete(key);
6580
+ });
6581
+ return next;
6582
+ };
6583
+ const index = new MarkerKeyIndex(opts.secrets.owner);
6584
+ const resolveRead = async (store, blob) => {
6585
+ index.seen(store, blob);
6586
+ const { value, unresolved } = await resolveSecretMarkers(blob, opts.secrets, {
6587
+ unresolved: "keep-marker",
6588
+ ownedBy: opts.secrets.owner
6589
+ });
6590
+ if (unresolved.length > 0) opts.onUnresolved?.(unresolved);
6591
+ return value;
6592
+ };
6593
+ const write = async (store, declared, scope, patch, readStored, rawWrite) => {
6594
+ if (!touchesTree(declared, patch) && !index.mayHoldMarkers(store, patch)) {
6595
+ await rawWrite(patch);
6596
+ index.wrote(store, patch);
6597
+ return { changed: true };
6598
+ }
6599
+ return serialize(store, async () => {
6600
+ const stored = await readStored();
6601
+ index.seen(store, stored);
6602
+ const operatorWrite = opts.isOperatorWrite?.() === true;
6603
+ const restored = await restoreUnchangedSecrets({
6604
+ patch,
6605
+ stored,
6606
+ secrets: opts.secrets,
6607
+ operatorWrite
6608
+ });
6609
+ const result = await transformSecretWrite({
6610
+ tree: widenTreeWithStoredMarkers(declared, stored, Object.keys(restored.patch), opts.secrets.owner),
6611
+ secrets: opts.secrets,
6612
+ patch: restored.patch,
6613
+ stored,
6614
+ ...scope !== void 0 ? { scope } : {},
6615
+ operatorWrite
6616
+ });
6617
+ const effective = dropUnchangedKeys(result.patch, stored);
6618
+ const wroteBlob = Object.keys(effective).length > 0;
6619
+ if (wroteBlob) {
6620
+ await rawWrite(effective);
6621
+ index.wrote(store, effective);
6622
+ }
6623
+ const { orphaned } = await result.afterWrite();
6624
+ if (orphaned.length > 0) opts.onOrphaned(orphaned);
6625
+ return { changed: wroteBlob || restored.changedRefs.length > 0 };
6626
+ });
6627
+ };
6628
+ const writeAddon = (patch) => write("addon", opts.addonTree(), void 0, patch, () => readStoredAddonBlob(raw), (p) => raw.writeAddonStore(p));
6629
+ const readAddonStoreResult = raw.readAddonStoreResult;
6630
+ const readAddonStoreKeyResult = raw.readAddonStoreKeyResult;
6631
+ const readDeviceStoreBatch = raw.readDeviceStoreBatch;
6632
+ const overrides = {
6633
+ readAddonStore: async () => resolveRead("addon", await raw.readAddonStore()),
6634
+ ...readAddonStoreResult !== void 0 ? { readAddonStoreResult: async () => {
6635
+ const result = await readAddonStoreResult.call(raw);
6636
+ return result.kind === "value" ? {
6637
+ kind: "value",
6638
+ value: await resolveRead("addon", result.value)
6639
+ } : result;
6640
+ } } : {},
6641
+ ...readAddonStoreKeyResult !== void 0 ? { readAddonStoreKeyResult: async (key) => {
6642
+ const result = await readAddonStoreKeyResult.call(raw, key);
6643
+ if (result.kind !== "present") return result;
6644
+ const { value, unresolved } = await resolveSecretMarkers({ [key]: result.value }, opts.secrets, {
6645
+ unresolved: "keep-marker",
6646
+ ownedBy: opts.secrets.owner
6647
+ });
6648
+ if (unresolved.length > 0) opts.onUnresolved?.(unresolved);
6649
+ return {
6650
+ kind: "present",
6651
+ value: value[key]
6652
+ };
6653
+ } } : {},
6654
+ readDeviceStore: async (deviceId) => resolveRead(`device:${deviceId}`, await raw.readDeviceStore(deviceId)),
6655
+ ...readDeviceStoreBatch !== void 0 ? { readDeviceStoreBatch: async (deviceIds) => {
6656
+ const rows = await readDeviceStoreBatch.call(raw, deviceIds);
6657
+ const out = /* @__PURE__ */ new Map();
6658
+ for (const [deviceId, blob] of rows) out.set(deviceId, await resolveRead(`device:${deviceId}`, blob));
6659
+ return out;
6660
+ } } : {},
6661
+ writeAddonStore: async (patch) => {
6662
+ await writeAddon(patch);
6663
+ },
6664
+ writeDeviceStore: async (deviceId, patch) => {
6665
+ await write(`device:${deviceId}`, opts.deviceTree(), {
6666
+ kind: "device",
6667
+ deviceId
6668
+ }, patch, () => raw.readDeviceStore(deviceId), (p) => raw.writeDeviceStore(deviceId, p));
6669
+ }
6670
+ };
6671
+ return {
6672
+ settings: new Proxy(raw, { get(target, prop, receiver) {
6673
+ if (typeof prop === "string" && Object.prototype.hasOwnProperty.call(overrides, prop)) return Reflect.get(overrides, prop);
6674
+ const value = Reflect.get(target, prop, receiver);
6675
+ return typeof value === "function" ? value.bind(target) : value;
6676
+ } }),
6677
+ raw: {
6678
+ readAddonStore: async () => {
6679
+ const blob = await raw.readAddonStore();
6680
+ index.seen("addon", blob);
6681
+ return blob;
6682
+ },
6683
+ readDeviceStore: async (deviceId) => {
6684
+ const blob = await raw.readDeviceStore(deviceId);
6685
+ index.seen(`device:${deviceId}`, blob);
6686
+ return blob;
6687
+ }
6688
+ },
6689
+ writeAddonStore: writeAddon
6690
+ };
6691
+ }
6692
+ /** The context the addon sees, plus the private raw view and write outcome. */
6693
+ function createSecretAwareContext(context, opts) {
6694
+ const raw = context.settings;
6695
+ if (raw === void 0) return {
6696
+ context,
6697
+ handle: null
6698
+ };
6699
+ const handle = createHandle(raw, opts);
6700
+ return {
6701
+ context: new Proxy(context, { get(target, prop, receiver) {
6702
+ if (prop === "settings") return handle.settings;
6703
+ return Reflect.get(target, prop, receiver);
6704
+ } }),
6705
+ handle
6706
+ };
6707
+ }
6708
+ var LEAF = { kind: "leaf" };
6709
+ var DEFAULT_ITEM_ID_KEY = "id";
6710
+ function collectFields(fields, out) {
6711
+ for (const field of fields) {
6712
+ if (field.type === "group") {
6713
+ collectFields(field.fields, out);
6714
+ continue;
6715
+ }
6716
+ if (field.type === "sub-tabs") {
6717
+ for (const tab of field.tabs) collectFields(tab.fields, out);
6718
+ continue;
6719
+ }
6720
+ if (field.type === "editable-array") {
6721
+ const item = /* @__PURE__ */ new Map();
6722
+ for (const itemField of field.itemFields) if ("key" in itemField && isKeychainStoredField(itemField)) item.set(itemField.key, LEAF);
6723
+ if (item.size > 0) out.set(field.key, {
6724
+ kind: "array",
6725
+ idKey: field.itemIdKey ?? DEFAULT_ITEM_ID_KEY,
6726
+ item
6727
+ });
6728
+ continue;
6729
+ }
6730
+ if (!("key" in field) || typeof field.key !== "string") continue;
6731
+ if (isKeychainStoredField(field)) out.set(field.key, LEAF);
6732
+ }
6733
+ }
6734
+ /** The secret tree a settings schema declares. */
6735
+ function secretTreeFromSchema(schema) {
6736
+ const out = /* @__PURE__ */ new Map();
6737
+ if (schema === null) return out;
6738
+ for (const section of schema.sections) collectFields(section.fields, out);
6739
+ return out;
6740
+ }
6741
+ /** Parse `a.b[id].c` into segments; throws on a malformed path (a declaration bug). */
6742
+ function parseSecretStatePath(path) {
6743
+ const segments = [];
6744
+ for (const raw of path.split(".")) {
6745
+ const m = /^([^[\]]+)(?:\[([^[\]]+)\])?$/.exec(raw);
6746
+ if (m === null || m[1] === void 0) throw new Error(`secretStatePaths: malformed path "${path}"`);
6747
+ segments.push(m[2] !== void 0 ? {
6748
+ key: m[1],
6749
+ idKey: m[2]
6750
+ } : { key: m[1] });
6751
+ }
6752
+ if (segments.length === 0) throw new Error(`secretStatePaths: empty path`);
6753
+ if (segments[segments.length - 1]?.idKey !== void 0) throw new Error(`secretStatePaths: "${path}" ends on an array — name the member that is secret`);
6754
+ return segments;
6755
+ }
6756
+ function insert(into, segments) {
6757
+ const [head, ...rest] = segments;
6758
+ if (head === void 0) return;
6759
+ if (rest.length === 0) {
6760
+ into.set(head.key, LEAF);
6761
+ return;
6762
+ }
6763
+ const existing = into.get(head.key);
6764
+ if (head.idKey !== void 0) {
6765
+ const item = new Map(existing?.kind === "array" ? existing.item : []);
6766
+ insert(item, rest);
6767
+ into.set(head.key, {
6768
+ kind: "array",
6769
+ idKey: head.idKey,
6770
+ item
6771
+ });
6772
+ return;
6773
+ }
6774
+ const children = new Map(existing?.kind === "object" ? existing.children : []);
6775
+ insert(children, rest);
6776
+ into.set(head.key, {
6777
+ kind: "object",
6778
+ children
6779
+ });
6780
+ }
6781
+ /** Add hidden-state paths (`secretStatePaths`) to a schema-derived tree. */
6782
+ function mergeSecretStatePaths(tree, paths) {
6783
+ if (paths.length === 0) return tree;
6784
+ const out = new Map(tree);
6785
+ for (const path of paths) insert(out, parseSecretStatePath(path));
6786
+ return out;
6787
+ }
6788
+ /** First retry of a secret the keychain could not serve; doubles to {@link SECRET_RETRY_MAX_MS}. */
6789
+ var SECRET_RETRY_FIRST_MS = 5e3;
6790
+ var SECRET_RETRY_MAX_MS = 5 * 6e4;
6791
+ /** Coalesces a burst of `keychain.changed` events into one re-resolve. */
6792
+ var SECRET_CHANGE_DEBOUNCE_MS = 250;
5910
6793
  /**
5911
6794
  * Base class for CamStack addons. Eliminates settings boilerplate:
5912
6795
  *
@@ -5976,6 +6859,33 @@ var BaseAddon = class {
5976
6859
  settingsStoreReady = false;
5977
6860
  /** Default config values. Provided via constructor. */
5978
6861
  defaults;
6862
+ /**
6863
+ * Hidden-state paths that hold secrets (D787) — values the addon writes
6864
+ * itself (`updateGlobalSettings`, `state()`) that no form field declares.
6865
+ * Stored in the keychain exactly like a `password` field. Syntax:
6866
+ * `'snapshotSigningKey'`, `'identity.pincode'`, `'tokens[userId].accessToken'`
6867
+ * (`key[<id field>]` addresses array items by id, never by index).
6868
+ */
6869
+ secretStatePaths = [];
6870
+ _addonSecretTree = null;
6871
+ _deviceSecretTree = null;
6872
+ /** Refs the last resolved config pointed at — a change to one re-resolves. */
6873
+ _configSecretRefs = /* @__PURE__ */ new Set();
6874
+ _unresolvedSecrets = [];
6875
+ _secretRetryTimer = null;
6876
+ _secretRetryDelayMs = SECRET_RETRY_FIRST_MS;
6877
+ _secretChangeTimer = null;
6878
+ _secretChangeUnsub = null;
6879
+ /** >0 while an OPERATOR's settings write is being applied. */
6880
+ _operatorWriteDepth = 0;
6881
+ /**
6882
+ * The keychain-aware settings handle (D798). Its `raw` view is the ONLY way
6883
+ * to the marker-bearing blobs and stays private to this class: the form
6884
+ * hydrate and config resolution need markers, addon code never does.
6885
+ */
6886
+ _secretSettings = null;
6887
+ /** Refs an addon-facing read could not resolve — each is logged once per process. */
6888
+ _loggedUnresolvedReads = /* @__PURE__ */ new Set();
5979
6889
  constructor(defaults) {
5980
6890
  this.defaults = defaults;
5981
6891
  this._config = { ...defaults };
@@ -6011,8 +6921,26 @@ var BaseAddon = class {
6011
6921
  return this._config;
6012
6922
  }
6013
6923
  async initialize(context) {
6014
- this._ctx = context;
6924
+ const secrets = context.secrets;
6925
+ if (secrets !== void 0) {
6926
+ const { context: wrapped, handle } = createSecretAwareContext(context, {
6927
+ secrets,
6928
+ addonTree: () => this.addonSecretTree(),
6929
+ deviceTree: () => this.deviceSecretTree(),
6930
+ onOrphaned: (refs) => context.logger.warn("keychain refs dropped by a settings write could not be deleted", { meta: { refs: [...refs] } }),
6931
+ isOperatorWrite: () => this._operatorWriteDepth > 0,
6932
+ onUnresolved: (unresolved) => this.logUnresolvedRead(unresolved)
6933
+ });
6934
+ this._ctx = wrapped;
6935
+ this._secretSettings = handle;
6936
+ } else {
6937
+ this._ctx = context;
6938
+ this._secretSettings = null;
6939
+ }
6015
6940
  await this.resolveConfig();
6941
+ if (secrets !== void 0) this._secretChangeUnsub = secrets.onChange((ref) => {
6942
+ if (this._configSecretRefs.has(ref)) this.scheduleSecretReresolve(SECRET_CHANGE_DEBOUNCE_MS);
6943
+ });
6016
6944
  const result = await this.onInitialize();
6017
6945
  this.emitLifecycle(EventCategory.AddonStarted);
6018
6946
  const normalized = normalizeAddonInitResult(result);
@@ -6045,6 +6973,12 @@ var BaseAddon = class {
6045
6973
  */
6046
6974
  async onHubReachable() {}
6047
6975
  async shutdown() {
6976
+ this._secretChangeUnsub?.();
6977
+ this._secretChangeUnsub = null;
6978
+ if (this._secretRetryTimer !== null) clearTimeout(this._secretRetryTimer);
6979
+ if (this._secretChangeTimer !== null) clearTimeout(this._secretChangeTimer);
6980
+ this._secretRetryTimer = null;
6981
+ this._secretChangeTimer = null;
6048
6982
  this.emitLifecycle(EventCategory.AddonStopped);
6049
6983
  if (this.autoEmitReadiness) this.emitReadinessForProviders("down");
6050
6984
  await this.onShutdown();
@@ -6119,11 +7053,8 @@ var BaseAddon = class {
6119
7053
  async getGlobalSettings(overlay, cap, nodeId) {
6120
7054
  const schema = this.globalSettingsSchema(cap);
6121
7055
  if (!schema) return { sections: [] };
6122
- const projected = await this.resolveGlobalStore(nodeId, cap);
6123
- return hydrateSchema(schema, overlay ? {
6124
- ...projected,
6125
- ...overlay
6126
- } : projected);
7056
+ const projected = await this.readRawProjectedStore(nodeId, cap);
7057
+ return hydrateSchema(schema, overlay ? await this.overlayKeepingMarkers(projected, overlay) : projected, { inlineSecretsAsViews: true });
6127
7058
  }
6128
7059
  /**
6129
7060
  * The integration-level view of this addon's settings: exactly the sections
@@ -6168,11 +7099,11 @@ var BaseAddon = class {
6168
7099
  });
6169
7100
  }
6170
7101
  if (sections.length === 0) return null;
6171
- const projected = await this.resolveGlobalStore(nodeId);
7102
+ const projected = await this.readRawProjectedStore(nodeId);
6172
7103
  return hydrateSchema({
6173
7104
  ...schema,
6174
7105
  sections
6175
- }, projected);
7106
+ }, projected, { inlineSecretsAsViews: true });
6176
7107
  }
6177
7108
  /**
6178
7109
  * The raw addon store PROJECTED onto the target node's bare per-node keys:
@@ -6185,12 +7116,50 @@ var BaseAddon = class {
6185
7116
  * the store for custom option logic (option narrowing, value snapping) to
6186
7117
  * read it per-node — never `ctx.settings.readAddonStore()` directly.
6187
7118
  * `nodeId` omitted ⇒ the local node (node-blind injection from ctx).
7119
+ *
7120
+ * Keychain values come back RESOLVED (D798): a secret reads as its value,
7121
+ * never as a `{ $secret }` marker. One the keychain cannot serve right now
7122
+ * stays a marker — "stored, unavailable" (`isSecretMarker()` is true, and it
7123
+ * is listed in {@link unresolvedSecrets}) — never `''` and never absent, so
7124
+ * it cannot be mistaken for "nothing stored, mint a new one". Writing the
7125
+ * resolved blob back is a no-op for every unchanged secret.
6188
7126
  */
6189
7127
  async resolveGlobalStore(nodeId, cap) {
6190
7128
  const raw = await this._ctx?.settings?.readAddonStore() ?? {};
7129
+ return this.projectForNode(raw, nodeId, cap);
7130
+ }
7131
+ projectForNode(store, nodeId, cap) {
6191
7132
  const keys = this.perNodeKeys(cap);
6192
7133
  const node = normalizeNodeId(nodeId ?? this._ctx?.kernel?.localNodeId);
6193
- return keys.size > 0 ? projectStore(raw, keys, node) : raw;
7134
+ return keys.size > 0 ? projectStore(store, keys, node) : store;
7135
+ }
7136
+ /** The PROJECTED store with its markers — the form hydrate only (D798). */
7137
+ async readRawProjectedStore(nodeId, cap) {
7138
+ const raw = await this.rawSettings()?.readAddonStore() ?? {};
7139
+ return this.projectForNode(raw, nodeId, cap);
7140
+ }
7141
+ /**
7142
+ * `{ ...stored, ...overlay }`, except that an overlay member equal to the
7143
+ * RESOLVED stored one keeps the stored (marker-bearing) member — so a form
7144
+ * hydrated from a resolved overlay still shows a secret as "set", never as
7145
+ * its value.
7146
+ */
7147
+ async overlayKeepingMarkers(stored, overlay) {
7148
+ const secrets = this._ctx?.secrets;
7149
+ const merged = {
7150
+ ...stored,
7151
+ ...overlay
7152
+ };
7153
+ if (secrets === void 0 || collectSecretMarkerRefs(stored).length === 0) return merged;
7154
+ const { value: resolved } = await resolveSecretMarkers(stored, secrets, {
7155
+ unresolved: "keep-marker",
7156
+ ownedBy: secrets.owner
7157
+ });
7158
+ for (const key of Object.keys(overlay)) {
7159
+ if (collectSecretMarkerRefs(stored[key]).length === 0) continue;
7160
+ if (isJsonEqual(overlay[key], resolved[key])) merged[key] = stored[key];
7161
+ }
7162
+ return merged;
6194
7163
  }
6195
7164
  /**
6196
7165
  * Whether ONE global key of this addon's store was written, read three-way
@@ -6226,18 +7195,58 @@ var BaseAddon = class {
6226
7195
  value: result.value[key]
6227
7196
  };
6228
7197
  }
7198
+ /**
7199
+ * The OPERATOR's write — a settings form or an admin API call, dispatched by
7200
+ * the kernel. Identical to {@link updateGlobalSettings}, except that a secret
7201
+ * the operator sends is stored as sent even when it equals a pre-keychain
7202
+ * inline value: the operator re-entering a password is a change, an addon
7203
+ * writing back what it read is not (D787).
7204
+ */
7205
+ async updateGlobalSettingsAsOperator(patch, nodeId) {
7206
+ this._operatorWriteDepth++;
7207
+ try {
7208
+ await this.applyGlobalPatch(patch, nodeId);
7209
+ } finally {
7210
+ this._operatorWriteDepth--;
7211
+ }
7212
+ }
6229
7213
  async updateGlobalSettings(patch, nodeId) {
7214
+ await this.applyGlobalPatch(patch, nodeId);
7215
+ }
7216
+ /**
7217
+ * REMOVE stored secrets — their keychain values and their markers (D787).
7218
+ *
7219
+ * Writing `''` to a secret field KEEPS what is stored (an empty string is
7220
+ * what a defaults fallback writes back, and it must never destroy a
7221
+ * credential), so code that means "forget this token" says so here. Without
7222
+ * a keychain (an older kernel) it writes `''`, as such code always did.
7223
+ */
7224
+ async clearSecrets(keys, nodeId) {
7225
+ const tree = this.addonSecretTree();
7226
+ const keychain = this._ctx?.secrets !== void 0;
7227
+ const stored = keychain ? await this.readAddonStoreWithRetry() : {};
7228
+ const patch = {};
7229
+ for (const key of keys) {
7230
+ const keychainStored = tree.has(key) || collectSecretMarkerRefs(stored[key]).length > 0;
7231
+ patch[key] = keychain && keychainStored ? SECRET_CLEAR : "";
7232
+ }
7233
+ await this.applyGlobalPatch(patch, nodeId);
7234
+ }
7235
+ async applyGlobalPatch(barePatch, nodeId) {
6230
7236
  const keys = this.perNodeKeys();
6231
7237
  const localNode = normalizeNodeId(this._ctx?.kernel?.localNodeId);
6232
7238
  const target = normalizeNodeId(nodeId ?? this._ctx?.kernel?.localNodeId);
6233
- const barePatch = patch;
6234
7239
  const scoped = keys.size > 0 ? scopePatch(barePatch, keys, target) : barePatch;
6235
- await this._ctx?.settings?.writeAddonStore(scoped);
7240
+ const handle = this._secretSettings;
7241
+ if (handle !== null) {
7242
+ const { changed } = await handle.writeAddonStore(scoped);
7243
+ if (!changed) return;
7244
+ } else await this._ctx?.settings?.writeAddonStore(scoped);
6236
7245
  if (target !== localNode) return;
6237
7246
  await this.resolveConfig();
6238
7247
  await this.onConfigChanged();
6239
7248
  this.emitLifecycle(EventCategory.AddonUpdated, { level: "global" });
6240
- this.maybeAutoRestart(patch, this.globalSettingsSchema());
7249
+ this.maybeAutoRestart(Object.keys(barePatch), this.globalSettingsSchema());
6241
7250
  }
6242
7251
  /**
6243
7252
  * The set of field keys the global settings schema declares `perNode: true`
@@ -6262,7 +7271,7 @@ var BaseAddon = class {
6262
7271
  * time to return its response before the addon is torn down and
6263
7272
  * re-initialised by `AddonRegistryService.restartAddon`.
6264
7273
  */
6265
- maybeAutoRestart(patch, schema) {
7274
+ maybeAutoRestart(patchKeys, schema) {
6266
7275
  if (!schema) return;
6267
7276
  const restartKeys = /* @__PURE__ */ new Set();
6268
7277
  for (const section of schema.sections) for (const field of section.fields) {
@@ -6270,13 +7279,13 @@ var BaseAddon = class {
6270
7279
  if (field.requiresRestart) restartKeys.add(field.key);
6271
7280
  }
6272
7281
  if (restartKeys.size === 0) return;
6273
- if (!Object.keys(patch).some((k) => restartKeys.has(k))) return;
7282
+ if (!patchKeys.some((k) => restartKeys.has(k))) return;
6274
7283
  const ctx = this._ctx;
6275
7284
  if (!ctx) return;
6276
7285
  const addonId = ctx.id;
6277
7286
  setImmediate(() => {
6278
7287
  ctx.api.addons?.restartAddon?.mutate({ addonId }).then(() => {
6279
- ctx.logger.info("addon auto-restart triggered by restart-required setting change", { meta: { changedFields: Object.keys(patch).filter((k) => restartKeys.has(k)) } });
7288
+ ctx.logger.info("addon auto-restart triggered by restart-required setting change", { meta: { changedFields: patchKeys.filter((k) => restartKeys.has(k)) } });
6280
7289
  }).catch((err) => {
6281
7290
  ctx.logger.error("addon auto-restart failed", { meta: { error: err instanceof Error ? err.message : String(err) } });
6282
7291
  });
@@ -6285,7 +7294,7 @@ var BaseAddon = class {
6285
7294
  async getDeviceSettings(deviceId) {
6286
7295
  const schema = this.deviceSettingsSchema();
6287
7296
  if (!schema) return { sections: [] };
6288
- return hydrateSchema(schema, await this._ctx?.settings?.readDeviceStore(deviceId) ?? {});
7297
+ return hydrateSchema(schema, await this.rawSettings()?.readDeviceStore(deviceId) ?? {}, { inlineSecretsAsViews: true });
6289
7298
  }
6290
7299
  async updateDeviceSettings(deviceId, patch) {
6291
7300
  await this._ctx?.settings?.writeDeviceStore(deviceId, patch);
@@ -6415,7 +7424,7 @@ var BaseAddon = class {
6415
7424
  * selection at boot (absent scoped key ⇒ the constructor default wins).
6416
7425
  */
6417
7426
  async resolveConfig() {
6418
- const stored = await this.readAddonStoreWithRetry();
7427
+ const stored = await this.resolveStoredSecrets(await this.readAddonStoreWithRetry());
6419
7428
  const perNode = this.perNodeKeys();
6420
7429
  const localNode = normalizeNodeId(this._ctx?.kernel?.localNodeId);
6421
7430
  const resolved = { ...this.defaults };
@@ -6440,7 +7449,7 @@ var BaseAddon = class {
6440
7449
  key,
6441
7450
  schema,
6442
7451
  fallback,
6443
- read: () => this.readAddonStoreWithRetry(),
7452
+ read: async () => this.resolveStoredSecrets(await this.readAddonStoreWithRetry()),
6444
7453
  write: async (patch) => {
6445
7454
  await this._ctx?.settings?.writeAddonStore(patch);
6446
7455
  },
@@ -6457,7 +7466,7 @@ var BaseAddon = class {
6457
7466
  key,
6458
7467
  schema,
6459
7468
  fallback,
6460
- read: async () => await this._ctx?.settings?.readDeviceStore(deviceId) ?? {},
7469
+ read: async () => this.resolveStoredSecrets(await this.rawSettings()?.readDeviceStore(deviceId) ?? {}, false),
6461
7470
  write: async (patch) => {
6462
7471
  await this._ctx?.settings?.writeDeviceStore(deviceId, patch);
6463
7472
  },
@@ -6469,6 +7478,87 @@ var BaseAddon = class {
6469
7478
  } })
6470
7479
  });
6471
7480
  }
7481
+ /** The addon store's secret tree: schema fields by TYPE, plus `secretStatePaths`. */
7482
+ addonSecretTree() {
7483
+ this._addonSecretTree ??= mergeSecretStatePaths(secretTreeFromSchema(this.globalSettingsSchema()), this.secretStatePaths);
7484
+ return this._addonSecretTree;
7485
+ }
7486
+ deviceSecretTree() {
7487
+ this._deviceSecretTree ??= secretTreeFromSchema(this.deviceSettingsSchema());
7488
+ return this._deviceSecretTree;
7489
+ }
7490
+ /**
7491
+ * Secrets of this addon's stored config that could not be resolved on the
7492
+ * last read, with why. Non-empty means the addon is running WITHOUT them —
7493
+ * an addon whose function needs one should report itself degraded rather
7494
+ * than start on an empty credential.
7495
+ */
7496
+ get unresolvedSecrets() {
7497
+ return this._unresolvedSecrets;
7498
+ }
7499
+ /**
7500
+ * Substitute every keychain marker in a stored blob with its value. With no
7501
+ * keychain (no `ctx.secrets`) or no marker, the blob comes back unchanged.
7502
+ * An unresolvable value is LEFT OUT (never `''`), logged by ref — never by
7503
+ * value — and, when the cause can pass, retried with backoff. Nothing is
7504
+ * ever written back from here.
7505
+ */
7506
+ async resolveStoredSecrets(blob, trackForConfig = true) {
7507
+ const secrets = this._ctx?.secrets;
7508
+ if (secrets === void 0) return blob;
7509
+ const refs = collectSecretMarkerRefs(blob);
7510
+ if (trackForConfig) this._configSecretRefs = new Set(refs);
7511
+ if (refs.length === 0) {
7512
+ if (trackForConfig) this._unresolvedSecrets = [];
7513
+ return blob;
7514
+ }
7515
+ const { value, unresolved } = await resolveSecretMarkers(blob, secrets);
7516
+ if (trackForConfig) {
7517
+ this._unresolvedSecrets = unresolved;
7518
+ if (unresolved.length > 0) {
7519
+ this._ctx?.logger?.error?.("secret unavailable — running without it, will retry", { meta: { secrets: unresolved.map((u) => ({
7520
+ ref: u.ref,
7521
+ reason: u.reason
7522
+ })) } });
7523
+ if (unresolved.some((u) => u.reason !== "missing" && u.reason !== "forbidden")) {
7524
+ this.scheduleSecretReresolve(this._secretRetryDelayMs);
7525
+ this._secretRetryDelayMs = Math.min(this._secretRetryDelayMs * 2, SECRET_RETRY_MAX_MS);
7526
+ }
7527
+ } else this._secretRetryDelayMs = SECRET_RETRY_FIRST_MS;
7528
+ }
7529
+ return value;
7530
+ }
7531
+ /**
7532
+ * The marker-bearing settings reads (D798) — private on purpose. Without a
7533
+ * keychain the context's own view is already raw.
7534
+ */
7535
+ rawSettings() {
7536
+ return this._secretSettings?.raw ?? this._ctx?.settings;
7537
+ }
7538
+ /** An addon-facing read met markers it could not resolve: say so once per ref. */
7539
+ logUnresolvedRead(unresolved) {
7540
+ const fresh = unresolved.filter((u) => !this._loggedUnresolvedReads.has(u.ref));
7541
+ if (fresh.length === 0) return;
7542
+ for (const u of fresh) this._loggedUnresolvedReads.add(u.ref);
7543
+ this._ctx?.logger?.warn?.("settings read: a stored secret is unavailable — it reads as its marker, not as a value", { meta: { secrets: fresh.map((u) => ({
7544
+ ref: u.ref,
7545
+ reason: u.reason
7546
+ })) } });
7547
+ }
7548
+ /** Re-resolve the config (a keychain-only change, or a retry) and apply it. */
7549
+ scheduleSecretReresolve(delayMs) {
7550
+ const timerOf = delayMs === SECRET_CHANGE_DEBOUNCE_MS ? "_secretChangeTimer" : "_secretRetryTimer";
7551
+ if (this[timerOf] !== null) return;
7552
+ const timer = setTimeout(() => {
7553
+ this[timerOf] = null;
7554
+ if (this._ctx === null) return;
7555
+ this.resolveConfig().then(() => this.onConfigChanged()).catch((err) => {
7556
+ this._ctx?.logger?.error?.("re-resolving secrets failed", { meta: { error: err instanceof Error ? err.message : String(err) } });
7557
+ });
7558
+ }, delayMs);
7559
+ timer.unref?.();
7560
+ this[timerOf] = timer;
7561
+ }
6472
7562
  /**
6473
7563
  * Wrap `ctx.settings.readAddonStore()` with a short retry budget so a
6474
7564
  * transient settings-store outage (mid-restart of sqlite-settings, tsx-watch
@@ -6481,7 +7571,7 @@ var BaseAddon = class {
6481
7571
  * `{}` (defaults) — the addon's first successful patch will rehydrate.
6482
7572
  */
6483
7573
  async readAddonStoreWithRetry() {
6484
- const settings = this._ctx?.settings;
7574
+ const settings = this.rawSettings();
6485
7575
  if (!settings) return {};
6486
7576
  const delaysMs = [
6487
7577
  150,
@@ -8717,6 +9807,278 @@ var CameraSwitchGroupSchema = object({
8717
9807
  fetchedAt: number()
8718
9808
  });
8719
9809
  /**
9810
+ * The trainer contract — what the hub hands the cloud trainer and what it
9811
+ * gets back (cloud training, D805+).
9812
+ *
9813
+ * The trainer (`hf/camstack-trainer`, published as the Hugging Face repo
9814
+ * `camstack/camstack-trainer`) is a separate AGPL program the hub never
9815
+ * imports: `job.json` goes in, files come out, and progress is `CAMSTACK_EVENT`
9816
+ * lines on stdout. These schemas are the hub's half of that boundary; the
9817
+ * trainer's pydantic models (and the JSON Schemas generated from them under
9818
+ * `hf/camstack-trainer/schemas/`) are the other half. A change here is a
9819
+ * change there, in the same piece of work.
9820
+ *
9821
+ * No `.default()` anywhere: defaults do not run on the addon cap path, so the
9822
+ * orchestrator fills every field of a job spec explicitly.
9823
+ */
9824
+ var TRAINING_JOB_SCHEMA = "camstack.training/v1";
9825
+ var TRAINING_RESULT_SCHEMA = "camstack.training-result/v1";
9826
+ /** What the trainer can export. Edge TPU is a later, separate image. */
9827
+ var TrainingExportSchema = _enum([
9828
+ "onnx",
9829
+ "openvino-fp16",
9830
+ "openvino-int8",
9831
+ "coreml-fp16"
9832
+ ]);
9833
+ var FloorsSchema = record(string(), number().min(0).max(1));
9834
+ object({
9835
+ schema: literal(TRAINING_JOB_SCHEMA),
9836
+ jobKey: string().uuid(),
9837
+ target: object({
9838
+ kind: literal("detector"),
9839
+ step: literal("object-detection")
9840
+ }),
9841
+ base: object({
9842
+ modelId: string().min(1),
9843
+ /** Ultralytics weights id, e.g. `yolov9m.pt`. */
9844
+ weights: string().min(1),
9845
+ imgsz: number().int().positive()
9846
+ }),
9847
+ baseline: object({
9848
+ modelId: string().min(1),
9849
+ /** The baseline ONNX the holdout comparison runs; public mirror URL. */
9850
+ onnxUrl: string().url(),
9851
+ imgsz: number().int().positive(),
9852
+ floors: FloorsSchema
9853
+ }),
9854
+ dataset: object({
9855
+ versionId: string().min(1),
9856
+ annotationHash: string(),
9857
+ /** sha256 of the uploaded archive; the trainer refuses a mismatch (exit 65). */
9858
+ sha256: string().regex(/^[0-9a-f]{64}$/)
9859
+ }),
9860
+ split: object({
9861
+ holdoutCameras: array(number().int()),
9862
+ /** When no camera is held out: the last N days of every camera. */
9863
+ holdoutLastDays: number().int().nonnegative(),
9864
+ valFraction: number().min(0).max(.5),
9865
+ seed: number().int()
9866
+ }),
9867
+ hyper: object({
9868
+ epochs: number().int().positive(),
9869
+ batch: number().int().positive(),
9870
+ lr0: number().positive(),
9871
+ /** Layers frozen from the start of the backbone; 0 = none. */
9872
+ freeze: number().int().nonnegative(),
9873
+ patience: number().int().nonnegative(),
9874
+ seed: number().int()
9875
+ }),
9876
+ replay: object({
9877
+ source: literal("coco2017"),
9878
+ count: number().int().nonnegative()
9879
+ }),
9880
+ exports: array(TrainingExportSchema).min(1),
9881
+ calibration: object({ maxFrames: number().int().positive() }),
9882
+ floors: object({
9883
+ minSupport: number().int().positive(),
9884
+ clamp: number().min(0).max(1)
9885
+ }),
9886
+ int8Gate: object({ maxMap50Drop: number().min(0).max(1) }),
9887
+ catalog: object({
9888
+ id: string().regex(/^[a-z0-9][a-z0-9-]{2,80}$/),
9889
+ name: string().min(1).max(160)
9890
+ })
9891
+ });
9892
+ /** One regular file of the bundle. An mlpackage contributes one row per member. */
9893
+ var TrainingResultFileSchema = object({
9894
+ path: string().min(1),
9895
+ bytes: number().int().nonnegative(),
9896
+ sha256: string().regex(/^[0-9a-f]{64}$/),
9897
+ format: _enum([
9898
+ "onnx",
9899
+ "openvino",
9900
+ "coreml",
9901
+ "pt"
9902
+ ]),
9903
+ variant: _enum(["base", "int8"])
9904
+ });
9905
+ var DraftFormatSchema = object({
9906
+ /** RELATIVE path inside the bundle; the hub rewrites it to `camstack-local://`. */
9907
+ url: string().min(1),
9908
+ sizeMB: number().nonnegative(),
9909
+ isDirectory: boolean().optional(),
9910
+ files: array(string()).optional(),
9911
+ runtimes: array(literal("python")).optional(),
9912
+ revision: string().min(1)
9913
+ });
9914
+ /** The trainer's half of a catalog entry; the hub completes it (labels, licence, group). */
9915
+ var TrainingCatalogDraftSchema = object({
9916
+ id: string().min(1),
9917
+ name: string().min(1),
9918
+ description: string(),
9919
+ labels: array(unknown()),
9920
+ inputSize: object({
9921
+ width: number().int().positive(),
9922
+ height: number().int().positive()
9923
+ }),
9924
+ preprocessMode: literal("letterbox"),
9925
+ defaultClassFloors: FloorsSchema,
9926
+ formats: object({
9927
+ onnx: DraftFormatSchema.optional(),
9928
+ openvino: DraftFormatSchema.optional(),
9929
+ coreml: DraftFormatSchema.optional()
9930
+ })
9931
+ });
9932
+ /** One class of one model's holdout report (the eval harness's summary). */
9933
+ var TrainingEvalClassSchema = object({
9934
+ positives: number().int(),
9935
+ floor: number().nullable(),
9936
+ tp: number().int(),
9937
+ fp: number().int(),
9938
+ fn: number().int(),
9939
+ precision: number().nullable(),
9940
+ recall: number().nullable(),
9941
+ ap50: number().nullable(),
9942
+ recallByCamera: record(string(), number().nullable()).optional(),
9943
+ recallByLight: record(string(), number().nullable()).optional(),
9944
+ fpByCamera: record(string(), number()).optional(),
9945
+ smallFound: number().int().optional(),
9946
+ smallTotal: number().int().optional()
9947
+ }).passthrough();
9948
+ var TrainingEvalReportSchema = object({
9949
+ frames: number().int(),
9950
+ classes: record(string(), TrainingEvalClassSchema)
9951
+ }).passthrough();
9952
+ /**
9953
+ * A succeeded result carries every block; a failed one carries the error and
9954
+ * whatever was known by then — the other blocks are ABSENT, not null. The
9955
+ * orchestrator checks the blocks it needs before it trusts a success.
9956
+ */
9957
+ var TrainingResultSchema = object({
9958
+ schema: literal(TRAINING_RESULT_SCHEMA),
9959
+ jobKey: string(),
9960
+ status: _enum(["succeeded", "failed"]),
9961
+ error: object({
9962
+ stage: string(),
9963
+ code: string(),
9964
+ message: string()
9965
+ }).nullable(),
9966
+ trainer: object({
9967
+ version: string(),
9968
+ revision: string()
9969
+ }),
9970
+ toolchain: record(string(), string().nullable()),
9971
+ dataset: object({
9972
+ versionId: string(),
9973
+ annotationHash: string(),
9974
+ sha256: string(),
9975
+ frames: object({
9976
+ train: number().int(),
9977
+ val: number().int(),
9978
+ holdout: number().int()
9979
+ }),
9980
+ holdoutCameras: array(number().int()),
9981
+ replayImages: number().int()
9982
+ }).optional(),
9983
+ training: object({
9984
+ epochsRun: number().int(),
9985
+ bestEpoch: number().int(),
9986
+ bestMap50: number(),
9987
+ bestMap50_95: number(),
9988
+ seconds: number()
9989
+ }).optional(),
9990
+ evaluation: object({
9991
+ holdoutFrames: number().int(),
9992
+ baseline: TrainingEvalReportSchema.nullable(),
9993
+ candidate: TrainingEvalReportSchema.nullable(),
9994
+ candidateInt8: TrainingEvalReportSchema.nullable(),
9995
+ recallDeltaByCamera: record(string(), record(string(), number())).nullable(),
9996
+ map50: record(string(), number().nullable())
9997
+ }).optional(),
9998
+ floors: object({
9999
+ baseline: FloorsSchema,
10000
+ candidate: FloorsSchema,
10001
+ candidateInt8: FloorsSchema.nullable(),
10002
+ notes: array(string())
10003
+ }).optional(),
10004
+ int8: object({
10005
+ kept: boolean(),
10006
+ map50Fp16: number().nullable(),
10007
+ map50Int8: number().nullable(),
10008
+ reason: string().nullable()
10009
+ }).optional(),
10010
+ exportsDropped: array(object({
10011
+ export: string(),
10012
+ reason: string()
10013
+ })).optional(),
10014
+ files: array(TrainingResultFileSchema).optional(),
10015
+ bundle: object({
10016
+ path: literal("bundle.tar"),
10017
+ bytes: number().int().nonnegative(),
10018
+ sha256: string().regex(/^[0-9a-f]{64}$/)
10019
+ }).nullable().optional(),
10020
+ catalogDraft: object({
10021
+ base: TrainingCatalogDraftSchema,
10022
+ int8: TrainingCatalogDraftSchema.nullable()
10023
+ }).nullable().optional(),
10024
+ licence: string()
10025
+ });
10026
+ var TrainingStageSchema = _enum([
10027
+ "prepare",
10028
+ "replay",
10029
+ "train",
10030
+ "eval",
10031
+ "export",
10032
+ "package"
10033
+ ]);
10034
+ var EventBase = {
10035
+ v: literal(1),
10036
+ ts: number()
10037
+ };
10038
+ discriminatedUnion("type", [
10039
+ object({
10040
+ ...EventBase,
10041
+ type: literal("stage"),
10042
+ stage: TrainingStageSchema
10043
+ }),
10044
+ object({
10045
+ ...EventBase,
10046
+ type: literal("epoch"),
10047
+ epoch: number().int(),
10048
+ epochs: number().int(),
10049
+ boxLoss: number().nullable().optional(),
10050
+ map50: number().nullable().optional(),
10051
+ map50_95: number().nullable().optional(),
10052
+ etaSec: number().nullable().optional()
10053
+ }),
10054
+ object({
10055
+ ...EventBase,
10056
+ type: literal("metric"),
10057
+ name: string(),
10058
+ value: number()
10059
+ }),
10060
+ object({
10061
+ ...EventBase,
10062
+ type: literal("artifact"),
10063
+ path: string(),
10064
+ bytes: number(),
10065
+ sha256: string()
10066
+ }),
10067
+ object({
10068
+ ...EventBase,
10069
+ type: literal("done"),
10070
+ status: _enum(["succeeded", "failed"]),
10071
+ resultSha256: string().nullable().optional()
10072
+ }),
10073
+ object({
10074
+ ...EventBase,
10075
+ type: literal("error"),
10076
+ stage: string(),
10077
+ code: string(),
10078
+ message: string()
10079
+ })
10080
+ ]);
10081
+ /**
8720
10082
  * What the gate decided about a birth, from the CALLER's point of view.
8721
10083
  *
8722
10084
  * Deliberately not `ConfirmationVerdict`: `undecided` is not a birth decision
@@ -11044,7 +12406,9 @@ var AddonHttpRouteSchema = object({
11044
12406
  "authenticated",
11045
12407
  "admin"
11046
12408
  ]).optional(),
11047
- description: string().optional()
12409
+ description: string().optional(),
12410
+ /** The hub limits this route per client address before the handler runs. */
12411
+ rateLimit: _enum(["auth"]).optional()
11048
12412
  });
11049
12413
  /**
11050
12414
  * Cross-process route invocation envelope. The hub captures the
@@ -11786,6 +13150,37 @@ var BackupDestinationInfoSchema = object({
11786
13150
  lastError: string().optional()
11787
13151
  });
11788
13152
  /**
13153
+ * How an archive is encrypted (operator decision 2026-10-09): to a backup
13154
+ * PUBLIC key the hub holds, so only the operator's secret key opens it.
13155
+ * Absent on a plain `.tar.gz` — every archive made before encryption, or
13156
+ * with it off — which restores without a key.
13157
+ */
13158
+ var BackupArchiveEncryptionSchema = object({
13159
+ /** `x25519-hkdf-aes256gcm-stream-v1`. */
13160
+ scheme: string(),
13161
+ /** 16 hex — the backup key whose secret restores this archive. */
13162
+ keyId: string()
13163
+ });
13164
+ /**
13165
+ * The backup encryption setting. The hub keeps PUBLIC keys only: the active
13166
+ * one new archives are encrypted to, and the retired ones older archives
13167
+ * still need. The secret key is shown once, at `setupEncryption`.
13168
+ */
13169
+ var BackupEncryptionStatusSchema = object({
13170
+ enabled: boolean(),
13171
+ active: object({
13172
+ keyId: string(),
13173
+ publicKey: string(),
13174
+ createdAt: number()
13175
+ }).nullable(),
13176
+ /** Every key ever set up, newest first. */
13177
+ keys: array(object({
13178
+ keyId: string(),
13179
+ createdAt: number(),
13180
+ retiredAt: number().nullable()
13181
+ })).readonly()
13182
+ });
13183
+ /**
11789
13184
  * Per-archive entry returned by `backup.listArchives({ destinationId })`.
11790
13185
  * Same shape the destination drill-in renders. Sourced from the per-
11791
13186
  * location `manifests.json` (no per-archive tarball read required).
@@ -11797,7 +13192,9 @@ var BackupArchiveEntrySchema = object({
11797
13192
  sizeBytes: number(),
11798
13193
  label: string().optional(),
11799
13194
  /** Top-level locations included in the archive (db, addons, tls, …). */
11800
- locations: array(string()).readonly()
13195
+ locations: array(string()).readonly(),
13196
+ /** Present when the archive is encrypted; restore then needs that key. */
13197
+ encryption: BackupArchiveEncryptionSchema.optional()
11801
13198
  });
11802
13199
  var BackupEntrySchema = object({
11803
13200
  id: string(),
@@ -11806,7 +13203,8 @@ var BackupEntrySchema = object({
11806
13203
  label: string().optional(),
11807
13204
  createdAt: number(),
11808
13205
  sizeBytes: number(),
11809
- locations: array(string()).optional()
13206
+ locations: array(string()).optional(),
13207
+ encryption: BackupArchiveEncryptionSchema.optional()
11810
13208
  });
11811
13209
  var ArchiveEntrySchema = object({
11812
13210
  path: string(),
@@ -11995,10 +13393,40 @@ method(_void(), array(BackupDestinationInfoSchema).readonly(), { auth: "admin" }
11995
13393
  * this list and skips entries whose path doesn't start with
11996
13394
  * any of them.
11997
13395
  */
11998
- locations: array(string()).optional()
13396
+ locations: array(string()).optional(),
13397
+ /**
13398
+ * The backup SECRET key, for an encrypted archive (ignored for a plain
13399
+ * one). The archive is decrypted into the hub's private staging
13400
+ * before the restart; the key is not stored. A wrong or missing key
13401
+ * is refused before the archive is downloaded.
13402
+ */
13403
+ backupSecretKey: string().optional()
11999
13404
  }), _void(), {
12000
13405
  kind: "mutation",
12001
13406
  auth: "admin"
13407
+ }), method(_void(), BackupEncryptionStatusSchema, { auth: "admin" }), method(object({}), object({
13408
+ keyId: string(),
13409
+ secretKey: string(),
13410
+ publicKey: string(),
13411
+ createdAt: number(),
13412
+ replacedKeyId: string().nullable()
13413
+ }), {
13414
+ kind: "mutation",
13415
+ auth: "admin"
13416
+ }), method(object({}), object({ disabledKeyId: string().nullable() }), {
13417
+ kind: "mutation",
13418
+ auth: "admin"
13419
+ }), method(object({ backupSecretKey: string() }), object({
13420
+ valid: boolean(),
13421
+ keyId: string().nullable(),
13422
+ /** The hub knows this key (active or retired). */
13423
+ known: boolean(),
13424
+ /** It is the key new archives are encrypted to. */
13425
+ active: boolean(),
13426
+ error: string().optional()
13427
+ }), {
13428
+ kind: "mutation",
13429
+ auth: "admin"
12002
13430
  }), method(object({
12003
13431
  destinationId: string(),
12004
13432
  backupId: string()
@@ -13622,7 +15050,60 @@ var CustomModelDescriptorSchema = object({
13622
15050
  stepId: string(),
13623
15051
  entry: ModelCatalogEntrySchema
13624
15052
  });
13625
- method(_void(), array(CustomModelDescriptorSchema).readonly(), { auth: "admin" });
15053
+ /** One regular file of an imported bundle, as the producer measured it. */
15054
+ var ModelBundleFileSchema = object({
15055
+ /** Relative path inside the bundle tar; an mlpackage member is `<x>.mlpackage/<member>`. */
15056
+ path: string().min(1),
15057
+ bytes: number().int().nonnegative(),
15058
+ sha256: string().regex(/^[0-9a-f]{64}$/)
15059
+ });
15060
+ var ImportModelBundleInputSchema = object({
15061
+ /** The registry provider that keeps the model (Model Studio). */
15062
+ addonId: string(),
15063
+ stepId: string().min(1),
15064
+ /**
15065
+ * The catalog rows to register, complete, every format URL already
15066
+ * `camstack-local://<modelId>/<file>` naming a file of the bundle. One
15067
+ * bundle may carry several rows (a base and its INT8 variant).
15068
+ */
15069
+ entries: array(ModelCatalogEntrySchema).min(1).max(4),
15070
+ /** The bundle tar, offered by the producer over `ctx.peerBytes` (same host). */
15071
+ bundle: object({
15072
+ ticket: PeerBytesTicketSchema,
15073
+ bytes: number().int().positive(),
15074
+ sha256: string().regex(/^[0-9a-f]{64}$/)
15075
+ }),
15076
+ /** Every file the tar must hold; anything missing, extra or different is refused. */
15077
+ files: array(ModelBundleFileSchema).min(1).max(64),
15078
+ /** Convert missing engine formats and push the model to every agent afterwards. */
15079
+ distribute: boolean()
15080
+ });
15081
+ var ImportModelBundleResultSchema = discriminatedUnion("kind", [object({
15082
+ kind: literal("imported"),
15083
+ modelIds: array(string()).readonly(),
15084
+ distributed: array(object({
15085
+ modelId: string(),
15086
+ nodeId: string(),
15087
+ format: _enum(MODEL_FORMATS),
15088
+ ok: boolean(),
15089
+ error: string().optional()
15090
+ })).readonly()
15091
+ }), object({
15092
+ kind: literal("refused"),
15093
+ reason: _enum([
15094
+ "transfer-failed",
15095
+ "checksum-mismatch",
15096
+ "bundle-mismatch",
15097
+ "invalid-entry",
15098
+ "id-taken"
15099
+ ]),
15100
+ detail: string()
15101
+ })]);
15102
+ method(_void(), array(CustomModelDescriptorSchema).readonly(), { auth: "admin" }), method(ImportModelBundleInputSchema, ImportModelBundleResultSchema, {
15103
+ kind: "mutation",
15104
+ auth: "admin",
15105
+ timeoutMs: 30 * 6e4
15106
+ });
13626
15107
  /**
13627
15108
  * Query filter for settings-store collections.
13628
15109
  */
@@ -14006,6 +15487,253 @@ id: union([string(), number()]) }), {
14006
15487
  auth: "admin"
14007
15488
  });
14008
15489
  /**
15490
+ * `keychain` — the hub's encrypted store of secret values (D787).
15491
+ *
15492
+ * Settings blobs never hold a secret: they hold a marker
15493
+ * `{"$secret":"secret://<owner>/<scope>/<fieldPath>","v":1}` and the value
15494
+ * lives here, AES-256-GCM under a data key that a master key wraps. This cap
15495
+ * is the OWNER's door to its own values: every method is owner-checked
15496
+ * against the CALLER, never against anything the caller claims.
15497
+ *
15498
+ * Who the caller is: the transport stamps `callerAddonId` into the args of a
15499
+ * call that crossed a process (the parent `LocalChildRegistry` from the UDS
15500
+ * connection, the agent from its child's connection carried in
15501
+ * `$hub-cap-fwd`'s envelope). A stamp always overwrites; a wire call with no
15502
+ * stamp has its claim stripped. Only a hub in-process caller may state its own
15503
+ * identity — `ctx.secrets` does that with the addon id closed over. This is
15504
+ * identity against BUGS and misrouting, not against a malicious addon (every
15505
+ * runner is the same OS user): see the threat model in
15506
+ * `docs/design/2026-10-08-secrets-keychain.md`.
15507
+ *
15508
+ * `callerAddonId` is deliberately NOT in any input schema: the tRPC router
15509
+ * parses the input, so a session can never supply it, and the internal mount
15510
+ * floors every method to admin anyway (D240).
15511
+ *
15512
+ * Internal: addons reach it through `ctx.secrets`, never directly.
15513
+ */
15514
+ /** Why a value cannot be served right now. Never folded into "missing". */
15515
+ var KeychainUnavailableReasonSchema = _enum([
15516
+ "key-missing",
15517
+ "wrong-key",
15518
+ "key-file-unreadable",
15519
+ "store-unavailable",
15520
+ "not-initialized",
15521
+ "decrypt-failed"
15522
+ ]);
15523
+ var KeychainStateSchema = discriminatedUnion("state", [object({ state: literal("ready") }), object({
15524
+ state: literal("locked"),
15525
+ reason: KeychainUnavailableReasonSchema
15526
+ })]);
15527
+ var KeychainResolveEntrySchema = discriminatedUnion("kind", [
15528
+ object({
15529
+ kind: literal("value"),
15530
+ value: string(),
15531
+ version: number().int()
15532
+ }),
15533
+ object({ kind: literal("missing") }),
15534
+ object({
15535
+ kind: literal("unavailable"),
15536
+ reason: KeychainUnavailableReasonSchema
15537
+ }),
15538
+ object({ kind: literal("forbidden") })
15539
+ ]);
15540
+ var KeychainResolveResultSchema = record(string(), KeychainResolveEntrySchema);
15541
+ /** Metadata of one stored value — never the value. */
15542
+ var KeychainSecretMetaSchema = object({
15543
+ ref: string(),
15544
+ owner: string(),
15545
+ /** Formatted scope (`global`, `node/<id>`, `device/<id>`, …). */
15546
+ scope: string(),
15547
+ fieldPath: string(),
15548
+ version: number().int(),
15549
+ createdAt: number(),
15550
+ updatedAt: number(),
15551
+ /** `addon:<id>` | `user:<id>` | `system`. */
15552
+ updatedBy: string(),
15553
+ /** Coarse — written at most once an hour per ref. `null` = never read. */
15554
+ lastReadAt: number().nullable()
15555
+ });
15556
+ var RefListSchema = array(string().min(1)).max(512);
15557
+ method(object({
15558
+ ref: string().min(1),
15559
+ value: string().min(1)
15560
+ }), object({
15561
+ ref: string(),
15562
+ version: number().int()
15563
+ }), {
15564
+ kind: "mutation",
15565
+ auth: "admin"
15566
+ }), method(object({ refs: RefListSchema }), KeychainResolveResultSchema, { auth: "admin" }), method(object({ refs: RefListSchema }), object({ deleted: number().int() }), {
15567
+ kind: "mutation",
15568
+ auth: "admin"
15569
+ }), method(object({}), array(KeychainSecretMetaSchema).readonly(), { auth: "admin" }), method(object({}), KeychainStateSchema, { auth: "admin" });
15570
+ var KeychainKeySourceSchema = object({
15571
+ kind: _enum([
15572
+ "config-file",
15573
+ "previous-config-file",
15574
+ "platform",
15575
+ "default-file"
15576
+ ]),
15577
+ /** File sources only — a path is not a secret. */
15578
+ path: string().optional(),
15579
+ /**
15580
+ * True when a whole-volume backup of the data directory carries this key
15581
+ * next to the database it protects (the default file). The page warns.
15582
+ */
15583
+ sharesBackupWithDatabase: boolean()
15584
+ });
15585
+ /**
15586
+ * One keychain reset, as the Secrets page reports it until the operator
15587
+ * acknowledges it. Never a value: refs, counts and table names only.
15588
+ */
15589
+ var KeychainResetRecordSchema = object({
15590
+ id: string(),
15591
+ at: number(),
15592
+ /** `user:<id>` or {@link KEYCHAIN_RESET_TRIGGER_ACTOR}. */
15593
+ actor: string(),
15594
+ /** Why the keychain was locked when it was reset; `null` when it was not locked. */
15595
+ lockedReason: string().nullable(),
15596
+ /** Values moved into the archive table (ciphertext under the lost key). */
15597
+ archived: number().int(),
15598
+ /** `keychain:secrets-orphaned-<ts>`, or `null` when nothing was stored. */
15599
+ archivedCollection: string().nullable(),
15600
+ /**
15601
+ * `keychain:keys-orphaned-<ts>`: the wrapped data keys of the archive, kept
15602
+ * so the archive can still be opened if the lost master key turns up.
15603
+ */
15604
+ archivedKeysCollection: string().nullable(),
15605
+ /**
15606
+ * `system-settings` keys whose marker the reset cleared — the cluster
15607
+ * secret's: a marker left pointing at an archived value would refuse every
15608
+ * agent forever (D797).
15609
+ */
15610
+ clearedSettingsKeys: array(string()).readonly(),
15611
+ /** When an operator dismissed the notice on the Secrets page; `null` until then. */
15612
+ acknowledgedAt: number().nullable()
15613
+ });
15614
+ var KeychainStatusSchema = object({
15615
+ keychain: KeychainStateSchema,
15616
+ /** The source of the master key in use; `null` while locked. */
15617
+ keySource: KeychainKeySourceSchema.nullable(),
15618
+ /** The source configured to be primary — differs from `keySource` while a rotation is pending. */
15619
+ configuredSource: KeychainKeySourceSchema,
15620
+ /** Short fingerprint of the master key in use (`HMAC(KEK, label)`, 16 hex). */
15621
+ fingerprint: string().nullable(),
15622
+ activeKeyId: string().nullable(),
15623
+ /**
15624
+ * The keychain unlocked with a NON-primary source: the configured primary
15625
+ * key is not the one that wraps the data key yet. `rotateMasterKey` moves it.
15626
+ */
15627
+ rotationPending: boolean(),
15628
+ /** Wrapped copies of the data key under a previous master key, kept until purged. */
15629
+ retiredWraps: number().int(),
15630
+ recoveryKeyDownloadedAt: number().nullable(),
15631
+ secretCount: number().int(),
15632
+ /** The most recent reset, acknowledged or not; `null` when the keychain was never reset. */
15633
+ lastReset: KeychainResetRecordSchema.nullable()
15634
+ });
15635
+ /**
15636
+ * Whether a stored value is still pointed at by its owner's settings.
15637
+ * `unknown` is a first-class answer: a scope whose blob could not be read is
15638
+ * never reported as an orphan (and never deleted as one).
15639
+ */
15640
+ var KeychainSecretUsageSchema = _enum([
15641
+ "in-use",
15642
+ "orphan",
15643
+ "unknown"
15644
+ ]);
15645
+ var KeychainAdminSecretSchema = KeychainSecretMetaSchema.extend({ usage: KeychainSecretUsageSchema });
15646
+ var KeychainAuditActionSchema = _enum([
15647
+ "put",
15648
+ "delete",
15649
+ "reveal",
15650
+ "rotate-master-key",
15651
+ "purge-retired-keys",
15652
+ "download-recovery-key",
15653
+ "delete-orphans",
15654
+ "reset",
15655
+ "acknowledge-reset",
15656
+ "initialize"
15657
+ ]);
15658
+ var KeychainAuditEntrySchema = object({
15659
+ id: string(),
15660
+ at: number(),
15661
+ action: KeychainAuditActionSchema,
15662
+ /** `addon:<id>` | `user:<id>` | `system` | `trigger-file`. */
15663
+ actor: string(),
15664
+ ref: string().nullable(),
15665
+ detail: string().nullable()
15666
+ });
15667
+ var KEYCHAIN_RESET_CONFIRMATION = "RESET KEYCHAIN";
15668
+ /**
15669
+ * Secrets the HUB itself holds (owner `system`) that no settings form shows:
15670
+ * `jwt-signing-key` — the session signing key (D797). It is always "in use",
15671
+ * never an orphan; it is generated on a fresh hub and replaced only through
15672
+ * {@link keychainAdminCapability.methods.setSystemSecret}.
15673
+ */
15674
+ var SystemHeldSecretNameSchema = _enum(["jwt-signing-key"]);
15675
+ 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({
15676
+ value: string(),
15677
+ version: number().int()
15678
+ }), {
15679
+ kind: "mutation",
15680
+ auth: "admin",
15681
+ caller: "required"
15682
+ }), method(object({
15683
+ name: SystemHeldSecretNameSchema,
15684
+ value: string().min(16)
15685
+ }), object({
15686
+ ref: string(),
15687
+ version: number().int()
15688
+ }), {
15689
+ kind: "mutation",
15690
+ auth: "admin",
15691
+ caller: "required"
15692
+ }), method(object({ refs: array(string().min(1)).max(1e3) }), object({
15693
+ deleted: array(string()).readonly(),
15694
+ kept: array(object({
15695
+ ref: string(),
15696
+ usage: KeychainSecretUsageSchema
15697
+ })).readonly()
15698
+ }), {
15699
+ kind: "mutation",
15700
+ auth: "admin",
15701
+ caller: "required"
15702
+ }), method(object({}), object({
15703
+ fingerprint: string(),
15704
+ keySource: KeychainKeySourceSchema
15705
+ }), {
15706
+ kind: "mutation",
15707
+ auth: "admin",
15708
+ caller: "required"
15709
+ }), method(object({}), object({ purged: number().int() }), {
15710
+ kind: "mutation",
15711
+ auth: "admin",
15712
+ caller: "required"
15713
+ }), method(object({}), object({
15714
+ key: string(),
15715
+ fingerprint: string(),
15716
+ keySource: KeychainKeySourceSchema
15717
+ }), {
15718
+ kind: "mutation",
15719
+ auth: "admin",
15720
+ caller: "required"
15721
+ }), method(object({ confirm: literal(KEYCHAIN_RESET_CONFIRMATION) }), object({
15722
+ archivedCollection: string().nullable(),
15723
+ archived: number().int()
15724
+ }), {
15725
+ kind: "mutation",
15726
+ auth: "admin",
15727
+ caller: "required"
15728
+ }), method(object({}), object({
15729
+ reset: KeychainResetRecordSchema.nullable(),
15730
+ pendingReentry: array(KeychainSecretMetaSchema).readonly()
15731
+ }), { auth: "admin" }), method(object({}), object({ acknowledged: boolean() }), {
15732
+ kind: "mutation",
15733
+ auth: "admin",
15734
+ caller: "required"
15735
+ });
15736
+ /**
14009
15737
  * Stable UI option list for the `hwaccel` setting. Decoder addons
14010
15738
  * reuse this for `globalSettingsSchema()` so the dropdown is
14011
15739
  * identical everywhere. Order: auto → off → common backends by
@@ -14903,6 +16631,10 @@ var DeviceInfoSchema = object({
14903
16631
  isCamera: boolean(),
14904
16632
  /** Current config values — serializable snapshot */
14905
16633
  config: record(string(), unknown()),
16634
+ /** Paths inside `config` the device's schema declares secret (D783) —
16635
+ * what the non-admin redaction withholds. Paths, never values. Absent
16636
+ * when the owning runner has not reported them. */
16637
+ secretConfigPaths: array(string()).optional(),
14906
16638
  /** Hardware + identity blob (manufacturer / model / firmware / sn /
14907
16639
  * uid / mac / …). Populated by drivers; editable via setMetadata. */
14908
16640
  metadata: record(string(), unknown()).nullable().optional(),
@@ -15108,12 +16840,22 @@ var DeviceRegisterPayloadSchema = object({
15108
16840
  * call (workers re-register on init), so probe-driven updates
15109
16841
  * (e.g. PTZ flag flipping after the abilities probe) propagate. */
15110
16842
  features: array(string()).optional(),
15111
- config: record(string(), unknown())
16843
+ config: record(string(), unknown()),
16844
+ /** Config paths the device's own schema DECLARES secret
16845
+ * (`.meta({ secret: true })` — dotted, `[]` for array items, e.g.
16846
+ * `connection.password`). Re-published on every register; the non-admin
16847
+ * redaction withholds them at any depth (D783). Optional: an older runner
16848
+ * omits it and the keyword backstop applies. */
16849
+ secretConfigPaths: array(string()).optional()
15112
16850
  });
15113
16851
  var DeviceRemovePayloadSchema = object({ deviceId: number() });
15114
16852
  var DevicePersistConfigPayloadSchema = object({
15115
16853
  deviceId: number(),
15116
- data: record(string(), unknown())
16854
+ data: record(string(), unknown()),
16855
+ /** The paths the device's schema declares secret (D783), when the caller
16856
+ * knows them — those values are kept in the keychain, not the blob (D787).
16857
+ * Absent: the paths the device last reported at `registerDevice` apply. */
16858
+ secretConfigPaths: array(string()).optional()
15117
16859
  });
15118
16860
  /** What a migration actually did, per switch. `unreachable` is a first-class
15119
16861
  * answer: a camera that could not be asked is not a camera that was silenced. */
@@ -16716,7 +18458,7 @@ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
16716
18458
  * `login-method` — collection cap through which auth addons contribute
16717
18459
  * their pre-auth login surfaces to the login page. This is the SINGLE,
16718
18460
  * generic mechanism that supersedes the dead `auth.listProviders` reader:
16719
- * every auth addon (OIDC, magic-link, WebAuthn/passkey) registers a
18461
+ * every auth addon (OIDC, WebAuthn/passkey) registers a
16720
18462
  * `login-method` provider and the PUBLIC `auth.listLoginMethods`
16721
18463
  * procedure aggregates them for the unauthenticated login page.
16722
18464
  *
@@ -16724,8 +18466,7 @@ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
16724
18466
  *
16725
18467
  * - `redirect` — a declarative button. The login page renders a generic
16726
18468
  * button that navigates to `startUrl` (an addon-owned HTTP route).
16727
- * Covers OIDC (`/addon/auth-oidc/<id>/start`) and magic-link with
16728
- * ZERO shell-side JS. A future SSO addon plugs in the same way — the
18469
+ * Covers OIDC (`/addon/auth-oidc/<id>/start`) with ZERO shell-side JS. A future SSO addon plugs in the same way — the
16729
18470
  * login page needs NO change.
16730
18471
  *
16731
18472
  * - `widget` — a Module-Federation widget the login page mounts (via
@@ -16744,8 +18485,8 @@ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
16744
18485
  * decision.
16745
18486
  *
16746
18487
  * Every contribution carries a `stage`:
16747
- * - `primary` — shown on the first credentials screen (OIDC /
16748
- * magic-link buttons; a future usernameless passkey).
18488
+ * - `primary` — shown on the first credentials screen (OIDC
18489
+ * buttons; a usernameless passkey).
16749
18490
  * - `second-factor` — shown AFTER the password leg, gated on the
16750
18491
  * returned `factors` (passkey-as-2FA today).
16751
18492
  *
@@ -16767,7 +18508,14 @@ var LoginMethodContributionSchema = discriminatedUnion("kind", [
16767
18508
  icon: string().optional(),
16768
18509
  /** Addon-owned HTTP route the button navigates to (GET). */
16769
18510
  startUrl: string(),
16770
- stage: LoginStageEnum
18511
+ stage: LoginStageEnum,
18512
+ /**
18513
+ * The provider names an external identity a signed-in user can link to
18514
+ * their own account (D782): `auth.listLinkableProviders` /
18515
+ * `beginExternalLink` offer exactly the redirect methods that set this,
18516
+ * whatever their id. Absent / false — a login button only.
18517
+ */
18518
+ linkable: boolean().optional()
16771
18519
  }),
16772
18520
  object({
16773
18521
  kind: literal("widget"),
@@ -20582,8 +22330,7 @@ method(object({}), object({ rules: array(NcRuleSchema) }), { auth: "admin" }), m
20582
22330
  * `super_admin` — collapsed onto the single boolean because every
20583
22331
  * non-admin caller is governed by the same scope-check rules; the
20584
22332
  * distinction was only ever used to route role-specific procedures
20585
- * which we no longer have. Agents are admin sessions issued via
20586
- * `createServiceToken`; CLI / webhook integrations are `cst_*` tokens
22333
+ * which we no longer have. CLI / webhook integrations are `cst_*` tokens
20587
22334
  * with `isAdmin: false` + an explicit scope list.
20588
22335
  */
20589
22336
  /** Per-method access flavour. Materialised on every cap method via codegen. */
@@ -22085,8 +23832,23 @@ var RetrainMacroClassSchema = _enum([
22085
23832
  ]);
22086
23833
  /** A subject to learn, or a phantom to unlearn (taught by OMISSION). */
22087
23834
  var RetrainAnnotationKindSchema = _enum(["subject", "model_error"]);
22088
- /** Did a human draw this box, or did the assist propose it? */
22089
- var RetrainAnnotationSourceSchema = _enum(["operator", "assist"]);
23835
+ /**
23836
+ * Where a box came from. A machine-sourced box is a DRAFT on the page until
23837
+ * the operator confirms it; once saved it keeps its source as provenance.
23838
+ *
23839
+ * - `operator` — drawn by hand.
23840
+ * - `assist` — proposed by a detector run on the copy (the camera's own
23841
+ * model, or a larger teacher model).
23842
+ * - `pipeline` — the box the live pipeline actually drew on that frame, read
23843
+ * back from the track store (never a re-run).
23844
+ * - `llm` — proposed by a vision-capable LLM profile.
23845
+ */
23846
+ var RetrainAnnotationSourceSchema = _enum([
23847
+ "operator",
23848
+ "assist",
23849
+ "pipeline",
23850
+ "llm"
23851
+ ]);
22090
23852
  /** Normalised `[0,1]` rectangle against the FULL frame — the canonical form. */
22091
23853
  var RetrainBboxSchema = object({
22092
23854
  x: number(),
@@ -22104,7 +23866,8 @@ var RetrainBboxSchema = object({
22104
23866
  */
22105
23867
  var RetrainAnnotationSchema = object({
22106
23868
  id: string(),
22107
- trackId: string(),
23869
+ /** The frame's track. Absent on a recording still, which has none. */
23870
+ trackId: string().optional(),
22108
23871
  deviceId: number(),
22109
23872
  /** The COPY in retrain storage — never the source track's media key. */
22110
23873
  mediaKey: string(),
@@ -22153,18 +23916,63 @@ var RetrainFrameCandidateSchema = object({
22153
23916
  * fail, whatever became of the original. */
22154
23917
  copied: boolean()
22155
23918
  });
23919
+ /**
23920
+ * One box the live pipeline drew on a copied frame — what a correction starts
23921
+ * from. Derived when the frame is listed, from the track store: the subject
23922
+ * box recorded on the source media row when there is one, else the track
23923
+ * position nearest the frame's capture time. Never stored as an annotation
23924
+ * until the operator confirms it.
23925
+ */
23926
+ var RetrainPipelineBoxSchema = object({
23927
+ /** Normalised `[0,1]` against the full frame. */
23928
+ bbox: RetrainBboxSchema,
23929
+ macroClass: RetrainMacroClassSchema,
23930
+ label: string().optional(),
23931
+ subLabel: string().optional(),
23932
+ /** The detection score of the position used, when it was recorded. */
23933
+ score: number().optional(),
23934
+ /** The root model that produced the track, when it was recorded. */
23935
+ modelId: string().optional(),
23936
+ trackId: string(),
23937
+ /** `subject-box`: recorded on this very frame. `position`: the track's
23938
+ * position nearest the capture time, `deltaMs` away. */
23939
+ basis: _enum(["subject-box", "position"]),
23940
+ deltaMs: number()
23941
+ });
23942
+ /**
23943
+ * Where a retrain frame came from: a TRACK's stored media (copy-on-select),
23944
+ * or the RECORDING at an instant — the frame a model saw nothing in has no
23945
+ * track at all.
23946
+ */
23947
+ var RetrainFrameOriginSchema = _enum(["track", "recording"]);
22156
23948
  /** A frame the dataset OWNS: bytes copied at selection time. */
22157
23949
  var RetrainFrameSchema = object({
22158
23950
  frameId: string(),
22159
23951
  deviceId: number(),
22160
- trackId: string(),
22161
- /** Provenance only. It may already point at nothing — that is expected. */
22162
- sourceMediaId: number().int(),
23952
+ origin: RetrainFrameOriginSchema,
23953
+ /** The track it was copied from. Absent on a recording still. */
23954
+ trackId: string().optional(),
23955
+ /** Provenance only. It may already point at nothing — that is expected.
23956
+ * Absent on a recording still. */
23957
+ sourceMediaId: number().int().optional(),
23958
+ /** A recording still: the playhead instant it was taken at. */
23959
+ epochMs: number().optional(),
22163
23960
  sourceKind: MediaFileKindEnum,
22164
23961
  sizeBytes: number().int(),
22165
23962
  width: number().int(),
22166
23963
  height: number().int(),
22167
- copiedAt: number()
23964
+ copiedAt: number(),
23965
+ /** When the CAMERA captured the frame. Absent on a copy taken before D785. */
23966
+ capturedAt: number().optional(),
23967
+ /** The operator's "every subject in this frame is boxed". Detector
23968
+ * evaluation keeps only complete frames: an unboxed subject would count as
23969
+ * a false positive. */
23970
+ complete: boolean(),
23971
+ /** The boxes the pipeline drew on this frame. Present on list answers;
23972
+ * empty when nothing the track store holds can be placed on it. */
23973
+ pipelineBoxes: array(RetrainPipelineBoxSchema).readonly().optional(),
23974
+ /** The named collections this frame belongs to. Present on list answers. */
23975
+ collectionIds: array(string()).readonly().optional()
22168
23976
  });
22169
23977
  /** Why a copy-on-select could not be honoured — named, never a silent skip. */
22170
23978
  var RetrainCopyRefusalSchema = _enum([
@@ -22185,6 +23993,56 @@ var RetrainFrameListSchema = object({
22185
23993
  /** What the page pre-selects — the native key frame when one survives. */
22186
23994
  autoPickMediaId: number().int().optional()
22187
23995
  });
23996
+ /**
23997
+ * Which frames an annotated export carries. Every field narrows; an empty
23998
+ * filter is every annotated copy. A dataset VERSION is a frozen `frameIds`
23999
+ * list owned by whoever trains (the training orchestrator), so `frameIds` is
24000
+ * the primitive a version export uses; `batchId` re-selects what an earlier
24001
+ * export carried (`exportedInBatch`).
24002
+ */
24003
+ var RetrainExportFilterSchema = object({
24004
+ deviceIds: array(number()).optional(),
24005
+ frameIds: array(string()).max(2e4).optional(),
24006
+ /** Only frames in at least one of these named collections. */
24007
+ collectionIds: array(string()).max(200).optional(),
24008
+ /** Exactly the frames of this dataset version (and its completeOnly). An
24009
+ * unknown id selects nothing. */
24010
+ datasetVersionId: string().optional(),
24011
+ batchId: string().optional(),
24012
+ /** Only frames the operator marked complete (all subjects boxed). */
24013
+ completeOnly: boolean().optional()
24014
+ });
24015
+ /**
24016
+ * `frames`: the full frame copies, boxes in `annotations.json`.
24017
+ * `crops`: additionally one JPEG per subject, cut with the runtime detail-crop
24018
+ * convention — the classifier layout.
24019
+ */
24020
+ var RetrainExportLayoutSchema = _enum(["frames", "crops"]);
24021
+ /**
24022
+ * Where `writeRetrainArchive` streams the tar: one HTTP request whose body is
24023
+ * the archive, sent chunk by chunk. Covers a presigned PUT and a provider
24024
+ * addon's data-plane upload route alike. Headers are sent verbatim and never
24025
+ * logged.
24026
+ */
24027
+ var RetrainArchiveTargetSchema = object({
24028
+ kind: literal("http"),
24029
+ method: _enum(["PUT", "POST"]),
24030
+ url: string().url(),
24031
+ headers: record(string(), string()).optional()
24032
+ });
24033
+ var RetrainArchiveResultSchema = object({
24034
+ batchId: string(),
24035
+ frames: number().int(),
24036
+ crops: number().int(),
24037
+ annotations: number().int(),
24038
+ /** Frames planned but not shipped (unreadable copy, path too long). */
24039
+ missing: number().int(),
24040
+ bytes: number().int(),
24041
+ /** sha256 of the exact bytes sent. */
24042
+ sha256: string(),
24043
+ /** The target's HTTP status. */
24044
+ status: number().int()
24045
+ });
22188
24046
  /** What the operator asked the assist to look for. */
22189
24047
  var RetrainAssistSubjectSchema = discriminatedUnion("kind", [object({
22190
24048
  kind: literal("package"),
@@ -22214,6 +24072,170 @@ var RetrainAssistResultSchema = discriminatedUnion("kind", [object({
22214
24072
  reason: string(),
22215
24073
  detail: string().optional()
22216
24074
  })]);
24075
+ /** A named set over the retrain corpus — membership only, it owns no pixels. */
24076
+ var RetrainCollectionSchema = object({
24077
+ id: string(),
24078
+ name: string(),
24079
+ createdAt: number(),
24080
+ frameCount: number().int()
24081
+ });
24082
+ var RetrainCollectionCreateResultSchema = discriminatedUnion("kind", [object({
24083
+ kind: literal("created"),
24084
+ collection: RetrainCollectionSchema
24085
+ }), object({
24086
+ kind: literal("refused"),
24087
+ reason: _enum(["empty-name", "duplicate-name"])
24088
+ })]);
24089
+ var RetrainCollectionRenameResultSchema = discriminatedUnion("kind", [object({
24090
+ kind: literal("renamed"),
24091
+ collection: RetrainCollectionSchema
24092
+ }), object({
24093
+ kind: literal("refused"),
24094
+ reason: _enum([
24095
+ "empty-name",
24096
+ "duplicate-name",
24097
+ "unknown-collection"
24098
+ ])
24099
+ })]);
24100
+ /**
24101
+ * The outcome of adding the frame at a recording instant. Every refusal is
24102
+ * named: `still-unavailable` (not recording, a gap, or an undecodable frame —
24103
+ * `detail` says which), `still-busy` (the recorder is at its decode bound; try
24104
+ * again), `unreadable-image`, `write-failed`, `unknown-collection`.
24105
+ */
24106
+ var AddRetrainFrameFromRecordingResultSchema = discriminatedUnion("kind", [object({
24107
+ kind: literal("added"),
24108
+ collectionId: string(),
24109
+ frame: RetrainFrameSchema,
24110
+ /** The moment was already in the dataset; nothing was decoded. */
24111
+ reused: boolean()
24112
+ }), object({
24113
+ kind: literal("refused"),
24114
+ reason: _enum([
24115
+ "unknown-collection",
24116
+ "still-unavailable",
24117
+ "still-busy",
24118
+ "unreadable-image",
24119
+ "write-failed"
24120
+ ]),
24121
+ detail: string().optional()
24122
+ })]);
24123
+ /** A vision LLM profile the AI assist may use, and where it sends the frame. */
24124
+ var RetrainAssistProfileSchema = object({
24125
+ id: string(),
24126
+ name: string(),
24127
+ model: string(),
24128
+ kind: string(),
24129
+ /** `true` when the frame would leave the house (a cloud vendor, or an
24130
+ * endpoint that is not on the local network). The page confirms each such
24131
+ * run, and the provider refuses one without `allowCloud`. */
24132
+ leavesHouse: boolean()
24133
+ });
24134
+ /** A box the AI assist proposed: a draft, plus the model's own reason. */
24135
+ var RetrainLlmProposalSchema = RetrainAnnotationDraftSchema.extend({ reason: string() });
24136
+ /** What the AI assist said about a box that was already on the canvas. */
24137
+ var RetrainLlmReviewSchema = object({
24138
+ /** The `ref` the page sent the box under. */
24139
+ ref: string(),
24140
+ verdict: _enum([
24141
+ "confirmed",
24142
+ "wrong-class",
24143
+ "not-an-object",
24144
+ "uncertain"
24145
+ ]),
24146
+ suggestedClass: RetrainMacroClassSchema.optional(),
24147
+ reason: string()
24148
+ });
24149
+ /**
24150
+ * The AI assist's answer. `proposed` carries drafts (`source: 'llm'`, the
24151
+ * model and its confidence) and reviews; items the model got wrong (a box off
24152
+ * the frame, an unasked class, an unknown ref) are dropped and counted in
24153
+ * `rejected`. A whole answer that is not the schema is `malformed-answer`.
24154
+ */
24155
+ var RetrainLlmAssistResultSchema = discriminatedUnion("kind", [object({
24156
+ kind: literal("proposed"),
24157
+ profileId: string(),
24158
+ model: string(),
24159
+ /** The frame was sent outside the house for this answer. */
24160
+ leftHouse: boolean(),
24161
+ proposals: array(RetrainLlmProposalSchema).readonly(),
24162
+ reviews: array(RetrainLlmReviewSchema).readonly(),
24163
+ rejected: number().int()
24164
+ }), object({
24165
+ kind: literal("refused"),
24166
+ reason: _enum([
24167
+ "unknown-frame",
24168
+ "unreadable-frame",
24169
+ "unknown-profile",
24170
+ "profile-disabled",
24171
+ "no-vision",
24172
+ "cloud-not-confirmed",
24173
+ "llm-error",
24174
+ "malformed-answer"
24175
+ ]),
24176
+ detail: string().optional()
24177
+ })]);
24178
+ /** What a dataset version is cut from. Every field narrows. */
24179
+ var RetrainDatasetSelectionSchema = object({
24180
+ deviceIds: array(number()).readonly().optional(),
24181
+ collectionIds: array(string()).max(200).readonly().optional(),
24182
+ frameIds: array(string()).max(2e4).readonly().optional()
24183
+ });
24184
+ /** The counts a dataset is judged by. */
24185
+ var RetrainDatasetStatsSchema = object({
24186
+ frames: number().int(),
24187
+ completeFrames: number().int(),
24188
+ /** `completeFrames / frames`, 0..1. */
24189
+ completeness: number(),
24190
+ /** Boxes to learn (model errors excluded). */
24191
+ subjects: number().int(),
24192
+ modelErrors: number().int(),
24193
+ /** Complete frames with no subject. */
24194
+ hardNegatives: number().int(),
24195
+ /** Subjects per class × camera × day/night. */
24196
+ cells: array(object({
24197
+ macroClass: string(),
24198
+ deviceId: number(),
24199
+ lighting: _enum([
24200
+ "day",
24201
+ "night",
24202
+ "unknown"
24203
+ ]),
24204
+ subjects: number().int(),
24205
+ frames: number().int()
24206
+ })).readonly(),
24207
+ cameras: array(object({
24208
+ deviceId: number(),
24209
+ frames: number().int(),
24210
+ completeFrames: number().int()
24211
+ })).readonly()
24212
+ });
24213
+ /** An immutable dataset version, without its frame list. */
24214
+ var RetrainDatasetVersionSchema = object({
24215
+ id: string(),
24216
+ name: string(),
24217
+ createdAt: number(),
24218
+ selection: RetrainDatasetSelectionSchema,
24219
+ layout: RetrainExportLayoutSchema,
24220
+ completeOnly: boolean(),
24221
+ frameCount: number().int(),
24222
+ /** sha256 of what the frames taught when the version was frozen. */
24223
+ annotationHash: string(),
24224
+ /** The export manifest schema the version was cut under. */
24225
+ manifestSchema: string(),
24226
+ stats: RetrainDatasetStatsSchema
24227
+ });
24228
+ var CreateRetrainDatasetVersionResultSchema = discriminatedUnion("kind", [object({
24229
+ kind: literal("created"),
24230
+ version: RetrainDatasetVersionSchema
24231
+ }), object({
24232
+ kind: literal("refused"),
24233
+ reason: _enum([
24234
+ "empty-name",
24235
+ "duplicate-name",
24236
+ "no-frames"
24237
+ ])
24238
+ })]);
22217
24239
  /** The outcome of a lifecycle move owned by the retrain page. */
22218
24240
  var RetrainTransitionResultSchema = object({
22219
24241
  trackId: string(),
@@ -22931,7 +24953,7 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
22931
24953
  auth: "admin"
22932
24954
  }), method(object({
22933
24955
  deviceId: number(),
22934
- trackId: string(),
24956
+ trackId: string().optional(),
22935
24957
  frameId: string()
22936
24958
  }), object({
22937
24959
  removed: boolean(),
@@ -22948,7 +24970,8 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
22948
24970
  auth: "admin"
22949
24971
  }), method(object({
22950
24972
  deviceId: number(),
22951
- trackId: string(),
24973
+ /** The frame's track, when it has one — checked against the frame. */
24974
+ trackId: string().optional(),
22952
24975
  frameId: string(),
22953
24976
  subject: RetrainAssistSubjectSchema,
22954
24977
  /** Which node runs it. Absent ⇒ wherever an unowned call lands. */
@@ -22956,12 +24979,16 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
22956
24979
  }), RetrainAssistResultSchema, {
22957
24980
  kind: "mutation",
22958
24981
  auth: "admin"
22959
- }), method(object({ trackId: string() }), array(RetrainAnnotationSchema).readonly(), {
24982
+ }), method(object({
24983
+ trackId: string().optional(),
24984
+ frameIds: array(string()).max(2e3).optional()
24985
+ }), array(RetrainAnnotationSchema).readonly(), {
22960
24986
  kind: "query",
22961
24987
  auth: "admin"
22962
24988
  }), method(object({
22963
24989
  deviceId: number(),
22964
- trackId: string(),
24990
+ /** The frame's track, when it has one — checked against the frame. */
24991
+ trackId: string().optional(),
22965
24992
  frameId: string(),
22966
24993
  annotations: array(RetrainAnnotationDraftSchema)
22967
24994
  }), array(RetrainAnnotationSchema).readonly(), {
@@ -22979,7 +25006,132 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
22979
25006
  }), RetrainTransitionResultSchema, {
22980
25007
  kind: "mutation",
22981
25008
  auth: "admin"
22982
- }), method(object({ deviceIds: array(number()).optional() }), object({ url: string() }), {
25009
+ }), method(RetrainExportFilterSchema.extend({ layout: RetrainExportLayoutSchema.optional() }), object({ url: string() }), {
25010
+ kind: "query",
25011
+ auth: "admin"
25012
+ }), method(object({
25013
+ deviceId: number(),
25014
+ trackId: string().optional(),
25015
+ frameId: string(),
25016
+ complete: boolean()
25017
+ }), RetrainFrameSchema, {
25018
+ kind: "mutation",
25019
+ auth: "admin"
25020
+ }), method(object({
25021
+ filter: RetrainExportFilterSchema,
25022
+ layout: RetrainExportLayoutSchema,
25023
+ target: RetrainArchiveTargetSchema
25024
+ }), RetrainArchiveResultSchema, {
25025
+ kind: "mutation",
25026
+ auth: "admin",
25027
+ timeoutMs: 60 * 6e4
25028
+ }), method(object({
25029
+ filter: RetrainExportFilterSchema,
25030
+ layout: RetrainExportLayoutSchema
25031
+ }), object({
25032
+ ticket: PeerBytesTicketSchema,
25033
+ frames: number().int(),
25034
+ annotations: number().int()
25035
+ }), {
25036
+ kind: "mutation",
25037
+ auth: "admin",
25038
+ timeoutMs: 12e4
25039
+ }), method(object({
25040
+ selection: RetrainDatasetSelectionSchema,
25041
+ completeOnly: boolean().optional()
25042
+ }), RetrainDatasetStatsSchema, {
25043
+ kind: "query",
25044
+ auth: "admin"
25045
+ }), method(object({
25046
+ name: string().max(120),
25047
+ selection: RetrainDatasetSelectionSchema,
25048
+ layout: RetrainExportLayoutSchema,
25049
+ completeOnly: boolean()
25050
+ }), CreateRetrainDatasetVersionResultSchema, {
25051
+ kind: "mutation",
25052
+ auth: "admin",
25053
+ timeoutMs: 12e4
25054
+ }), method(object({}), array(RetrainDatasetVersionSchema).readonly(), {
25055
+ kind: "query",
25056
+ auth: "admin"
25057
+ }), method(object({ id: string() }), object({ deleted: boolean() }), {
25058
+ kind: "mutation",
25059
+ auth: "admin"
25060
+ }), method(object({ id: string() }), object({
25061
+ found: boolean(),
25062
+ annotationHash: string(),
25063
+ matches: boolean(),
25064
+ missingFrames: number().int()
25065
+ }), {
25066
+ kind: "query",
25067
+ auth: "admin",
25068
+ timeoutMs: 12e4
25069
+ }), method(object({}), array(RetrainAssistProfileSchema).readonly(), {
25070
+ kind: "query",
25071
+ auth: "admin"
25072
+ }), method(object({
25073
+ deviceId: number(),
25074
+ trackId: string().optional(),
25075
+ frameId: string(),
25076
+ profileId: string(),
25077
+ classes: array(RetrainMacroClassSchema).min(1),
25078
+ boxes: array(object({
25079
+ ref: string(),
25080
+ bbox: RetrainBboxSchema,
25081
+ macroClass: RetrainMacroClassSchema,
25082
+ label: string().optional()
25083
+ })).max(50),
25084
+ allowCloud: boolean()
25085
+ }), RetrainLlmAssistResultSchema, {
25086
+ kind: "mutation",
25087
+ auth: "admin",
25088
+ timeoutMs: 18e4
25089
+ }), method(object({ name: string().max(120) }), RetrainCollectionCreateResultSchema, {
25090
+ kind: "mutation",
25091
+ auth: "admin"
25092
+ }), method(object({}), array(RetrainCollectionSchema).readonly(), {
25093
+ kind: "query",
25094
+ auth: "admin"
25095
+ }), method(object({
25096
+ id: string(),
25097
+ name: string().max(120)
25098
+ }), RetrainCollectionRenameResultSchema, {
25099
+ kind: "mutation",
25100
+ auth: "admin"
25101
+ }), method(object({ id: string() }), object({
25102
+ deleted: boolean(),
25103
+ removedFrames: number().int()
25104
+ }), {
25105
+ kind: "mutation",
25106
+ auth: "admin"
25107
+ }), method(object({
25108
+ collectionId: string(),
25109
+ deviceId: number(),
25110
+ epochMs: number()
25111
+ }), AddRetrainFrameFromRecordingResultSchema, {
25112
+ kind: "mutation",
25113
+ auth: "admin",
25114
+ timeoutMs: 6e4
25115
+ }), method(object({
25116
+ collectionId: string(),
25117
+ frameIds: array(string()).min(1).max(500)
25118
+ }), object({
25119
+ added: number().int(),
25120
+ alreadyMember: number().int(),
25121
+ unknownFrameIds: array(string()).readonly()
25122
+ }), {
25123
+ kind: "mutation",
25124
+ auth: "admin"
25125
+ }), method(object({
25126
+ collectionId: string(),
25127
+ frameId: string()
25128
+ }), object({
25129
+ removed: boolean(),
25130
+ deletedFrame: boolean()
25131
+ }), {
25132
+ kind: "mutation",
25133
+ auth: "admin"
25134
+ }), method(object({ collectionId: string() }), array(RetrainFrameSchema).readonly(), {
22983
25135
  kind: "query",
22984
25136
  auth: "admin"
22985
25137
  }), method(object({
@@ -23605,13 +25757,31 @@ var RecommendationReasonSchema = discriminatedUnion("kind", [
23605
25757
  object({
23606
25758
  kind: literal("no-family-build"),
23607
25759
  format: ModelFormatSchema$1
25760
+ }),
25761
+ object({
25762
+ kind: literal("kept-custom-pin"),
25763
+ modelId: string(),
25764
+ deviceKey: string()
23608
25765
  })
23609
25766
  ]);
25767
+ /** Why a device is left exactly as it is, whatever the plan would pick (D786). */
25768
+ var KeptReasonSchema = _enum(["custom-pin"]);
25769
+ /**
25770
+ * Where a choice's latency came from (D791): this node's own benchmark
25771
+ * result, or the hardware-class table. Measured on the node beats the table.
25772
+ */
25773
+ var LatencySourceSchema = discriminatedUnion("kind", [object({ kind: literal("table") }), object({
25774
+ kind: literal("node-benchmark"),
25775
+ resultId: string(),
25776
+ measuredAtMs: number()
25777
+ })]);
23610
25778
  var DeviceModelChoiceSchema = object({
23611
25779
  modelId: string(),
23612
25780
  p50Ms: number(),
23613
25781
  fps: number(),
23614
25782
  measured: boolean(),
25783
+ /** Absent on a plan from before D791 — read as the table. */
25784
+ source: LatencySourceSchema.optional(),
23615
25785
  /** Parallel sessions at the camera rate with the headroom kept free: ⌊fps × (1 − headroom) / camera fps⌋. */
23616
25786
  capacitySessions: number(),
23617
25787
  personRecall: number()
@@ -23622,6 +25792,8 @@ var DeviceRecommendationSchema = object({
23622
25792
  enabled: boolean(),
23623
25793
  available: boolean(),
23624
25794
  chosen: DeviceModelChoiceSchema.nullable(),
25795
+ /** Present when the device is kept as is: Apply writes nothing on it. */
25796
+ kept: KeptReasonSchema.optional(),
23625
25797
  reasons: array(RecommendationReasonSchema).readonly()
23626
25798
  });
23627
25799
  var NodeRecommendationSchema = object({
@@ -23675,6 +25847,17 @@ var AutoTuneWarningSchema = discriminatedUnion("kind", [
23675
25847
  kind: literal("coral-enabled"),
23676
25848
  nodeId: string(),
23677
25849
  deviceKey: string()
25850
+ }),
25851
+ object({
25852
+ kind: literal("custom-pin-kept"),
25853
+ nodeId: string(),
25854
+ deviceKey: string().nullable(),
25855
+ deviceId: number().nullable(),
25856
+ modelId: string()
25857
+ }),
25858
+ object({
25859
+ kind: literal("custom-registry-unreadable"),
25860
+ error: string()
23678
25861
  })
23679
25862
  ]);
23680
25863
  var AutoTuneOptionsSchema = object({
@@ -23853,13 +26036,14 @@ var SuggestSharesResultSchema = object({
23853
26036
  nodes: array(SuggestedNodeShareSchema).readonly()
23854
26037
  });
23855
26038
  /**
23856
- * Where the node and device shares come from (D750, D755).
23857
- * - `hardware` (default) — computed by the system from each node's static
23858
- * capacity (its accelerators at their Auto tune models, from the measured
23859
- * latency table), recomputed whenever a node or device joins, leaves, is
23860
- * switched on or off, or changes model. No load input.
23861
- * - `benchmark` — the same, from each node's measured capacity (node
23862
- * benchmark results); a node without results falls back to `hardware`.
26039
+ * Where the node and device shares come from (D750, D755, D791).
26040
+ * - `benchmark` (default since D791) — each node's capacity as its own node
26041
+ * benchmark measured it; a node without fresh results is sized from
26042
+ * `hardware` and says so. Measured on the node beats the table.
26043
+ * - `hardware` — computed from each node's static capacity only (its
26044
+ * accelerators at their Auto tune models, from the latency table).
26045
+ * Both are recomputed whenever a node or device joins, leaves, is switched
26046
+ * on or off, changes model, or a benchmark result is written. No load input.
23863
26047
  * - `manual` — the operator's stored sliders.
23864
26048
  * Either way a node or device that cannot take sessions gives its share to
23865
26049
  * the others in proportion; the stored values are never rewritten for that.
@@ -23908,6 +26092,362 @@ var EffectiveSharesSchema = object({
23908
26092
  nodeWeights: record(string(), number()),
23909
26093
  deviceWeights: record(string(), record(string(), number()))
23910
26094
  });
26095
+ /**
26096
+ * Wire shapes of the node benchmark (D791): the operator's plan, the
26097
+ * preflight the confirmation shows, the run the orchestrator owns, what the
26098
+ * measuring runner reports, and the result rows Auto tune and the automatic
26099
+ * shares read.
26100
+ *
26101
+ * ONE node at a time, owned by the pipeline orchestrator. While a run is
26102
+ * active the cluster is in BENCHMARK MODE for that node: it is not a
26103
+ * detection candidate, camera pins naming it are ignored so its sessions move
26104
+ * elsewhere, and both come back when the mode ends — after a crash or a hub
26105
+ * restart too (a persisted manifest, reconciled against the registry).
26106
+ *
26107
+ * Two measurements, both on the node, driven by its own runner (frames never
26108
+ * cross a process at frame rate, D9):
26109
+ * - `device` — one accelerator × one candidate detector, root only, open
26110
+ * loop: how many streams at the camera rate it carries inside the frame
26111
+ * interval;
26112
+ * - `pipeline` — the chosen detector plus the operator's detail steps
26113
+ * (faces, plates, classifiers, CLIP…), on varied frames from the bench
26114
+ * clip: how many parallel sessions the node carries before latency, drops,
26115
+ * CPU, RAM or the event loop give out.
26116
+ */
26117
+ /** Defaults and bounds, one place. */
26118
+ var NODE_BENCHMARK_DEFAULTS = {
26119
+ fpsPerStream: 10,
26120
+ budgetMinutes: 45,
26121
+ minBudgetMinutes: 10,
26122
+ maxBudgetMinutes: 120,
26123
+ /** A result older than this no longer beats the table. */
26124
+ staleAfterDays: 30,
26125
+ /** Warm-in per ramp step (not accounted). */
26126
+ settleSec: 5,
26127
+ /** Accounted window per ramp step. */
26128
+ measureSec: 20,
26129
+ /** Longest the drain may take before the run is refused. */
26130
+ drainTimeoutSec: 120,
26131
+ /** Candidate models per device in one run. */
26132
+ maxModelsPerDevice: 6
26133
+ };
26134
+ /** The two measurements a run can make. */
26135
+ var NodeBenchmarkPhaseSchema = _enum(["device", "pipeline"]);
26136
+ var NodeBenchmarkDevicePlanSchema = object({
26137
+ /** `<backend>:<device>` — `openvino:npu`, `coreml:all`, `cpu`. */
26138
+ deviceKey: string().min(1),
26139
+ /**
26140
+ * Root detector candidates for the `device` measurement, in the order
26141
+ * measured. The FIRST is the one the `pipeline` measurement runs.
26142
+ */
26143
+ modelIds: array(string().min(1)).min(1).max(NODE_BENCHMARK_DEFAULTS.maxModelsPerDevice)
26144
+ });
26145
+ /** What the operator confirmed. */
26146
+ var NodeBenchmarkPlanSchema = object({
26147
+ nodeId: string().min(1),
26148
+ devices: array(NodeBenchmarkDevicePlanSchema).min(1),
26149
+ /** Which measurements run. At least one. */
26150
+ phases: array(NodeBenchmarkPhaseSchema).min(1).default(["device", "pipeline"]),
26151
+ /**
26152
+ * Detail steps (catalog step ids under the root: faces, plates,
26153
+ * classifiers, CLIP…) the `pipeline` measurement enables. The root
26154
+ * detector always runs.
26155
+ */
26156
+ steps: array(string().min(1)).default([]),
26157
+ /** Offered rate of one stream / session. */
26158
+ fpsPerStream: number().int().min(1).max(30).default(NODE_BENCHMARK_DEFAULTS.fpsPerStream),
26159
+ /** Hard deadline: the mode ends and the cluster is restored when it passes. */
26160
+ budgetMinutes: number().int().min(NODE_BENCHMARK_DEFAULTS.minBudgetMinutes).max(NODE_BENCHMARK_DEFAULTS.maxBudgetMinutes).default(NODE_BENCHMARK_DEFAULTS.budgetMinutes),
26161
+ /** Keep the models the run downloaded (default: delete what was not installed before). */
26162
+ keepDownloadedModels: boolean().default(false),
26163
+ /** Start although the other nodes' capacity does not cover the sessions running now. */
26164
+ acceptInsufficientHeadroom: boolean().default(false)
26165
+ });
26166
+ var NodeBenchmarkRefusalSchema = object({
26167
+ kind: _enum([
26168
+ "benchmark-active",
26169
+ "node-offline",
26170
+ "unknown-device",
26171
+ "no-phase",
26172
+ "insufficient-headroom"
26173
+ ]),
26174
+ detail: string(),
26175
+ overridable: boolean()
26176
+ });
26177
+ /** A camera whose detection leaves the node for the run. */
26178
+ var NodeBenchmarkMovingCameraSchema = object({
26179
+ deviceId: number(),
26180
+ /** Placed on the node now (a standing attach or a running session). */
26181
+ placedOnNode: boolean(),
26182
+ /** A node pin naming this node, ignored for the run. */
26183
+ pinnedToNode: boolean()
26184
+ });
26185
+ /** A camera that cannot leave: no other node can obtain its frames. */
26186
+ var NodeBenchmarkStayingCameraSchema = object({
26187
+ deviceId: number(),
26188
+ reason: literal("only-frame-source")
26189
+ });
26190
+ var NodeBenchmarkPreflightSchema = object({
26191
+ nodeId: string(),
26192
+ online: boolean(),
26193
+ moving: array(NodeBenchmarkMovingCameraSchema).readonly(),
26194
+ /** Keep running on the node during the run; the result is flagged contaminated. */
26195
+ staying: array(NodeBenchmarkStayingCameraSchema).readonly(),
26196
+ estimatedDurationMs: number(),
26197
+ /** The run ends and the cluster is restored at the latest after this long. */
26198
+ budgetMs: number(),
26199
+ phases: array(NodeBenchmarkPhaseSchema).readonly(),
26200
+ steps: array(string()).readonly(),
26201
+ devices: array(NodeBenchmarkDevicePlanSchema).readonly(),
26202
+ /** Parallel sessions the cluster runs now, and what the other nodes can carry. */
26203
+ headroom: object({
26204
+ sessionsNow: number(),
26205
+ otherNodesCapacitySessions: number().nullable()
26206
+ }),
26207
+ refusals: array(NodeBenchmarkRefusalSchema).readonly(),
26208
+ canStart: boolean()
26209
+ });
26210
+ /** Where the measuring runner is. */
26211
+ var NodeBenchProgressSchema = object({
26212
+ phase: _enum([
26213
+ "preparing",
26214
+ "device",
26215
+ "pipeline",
26216
+ "cleanup"
26217
+ ]),
26218
+ deviceKey: string().nullable(),
26219
+ modelId: string().nullable(),
26220
+ /** Streams (device) or sessions (pipeline) of the step running now. */
26221
+ load: number().nullable(),
26222
+ cellsDone: number(),
26223
+ cellsTotal: number(),
26224
+ message: string()
26225
+ });
26226
+ /** What limited a ramp. `none` = the ramp ran out of steps still passing. */
26227
+ var NodeBenchLimitSchema = _enum([
26228
+ "p95",
26229
+ "drops",
26230
+ "errors",
26231
+ "stall",
26232
+ "cpu",
26233
+ "ram",
26234
+ "none"
26235
+ ]);
26236
+ var NodeBenchRampStepSchema = object({
26237
+ load: number(),
26238
+ pass: boolean(),
26239
+ p95Ms: number(),
26240
+ dropRatio: number(),
26241
+ /** Completed frames per second over the accounted window. */
26242
+ fps: number(),
26243
+ cpuPct: number().nullable(),
26244
+ ramFreePct: number().nullable(),
26245
+ failReasons: array(string()).readonly()
26246
+ });
26247
+ var NodeBenchCellSchema = discriminatedUnion("phase", [object({
26248
+ phase: literal("device"),
26249
+ deviceKey: string(),
26250
+ modelId: string(),
26251
+ /** Single-stream latency (the K = 1 step). */
26252
+ p50Ms: number(),
26253
+ p95Ms: number(),
26254
+ p99Ms: number(),
26255
+ /** Frames per second sustained at the last passing step. */
26256
+ fps: number(),
26257
+ /** Streams at the camera rate the device carried inside the frame interval; 0 = not even one. */
26258
+ kMax: number(),
26259
+ limitedBy: NodeBenchLimitSchema,
26260
+ /** First call (model load + warm-up). */
26261
+ warmupMs: number(),
26262
+ ramp: array(NodeBenchRampStepSchema).readonly()
26263
+ }), object({
26264
+ phase: literal("pipeline"),
26265
+ deviceKey: string(),
26266
+ modelId: string(),
26267
+ steps: array(string()).readonly(),
26268
+ /** Parallel sessions at the camera rate the node carried; 0 = not even one. */
26269
+ maxSessions: number(),
26270
+ limitedBy: NodeBenchLimitSchema,
26271
+ /** Detail steps that produced at least one result on the clip — a step that never fired measured nothing. */
26272
+ stepsFired: array(string()).readonly(),
26273
+ warmupMs: number(),
26274
+ ramp: array(NodeBenchRampStepSchema).readonly()
26275
+ })]);
26276
+ /**
26277
+ * What a result was measured ON. A result whose fingerprint no longer matches
26278
+ * the node no longer beats the table.
26279
+ */
26280
+ var NodeBenchFingerprintSchema = object({
26281
+ pipelineVersion: string().nullable(),
26282
+ cpuModel: string().nullable(),
26283
+ ramGb: number().nullable(),
26284
+ os: string().nullable(),
26285
+ /** Per device: the pool the cells ran on (runtime + tuning). */
26286
+ pools: record(string(), object({
26287
+ runtime: string(),
26288
+ numWorkers: number(),
26289
+ concurrency: number(),
26290
+ batchMode: string()
26291
+ })).default({})
26292
+ });
26293
+ /** The frames the run used. */
26294
+ var NodeBenchClipSchema = object({
26295
+ /** `camstack-bench-v1` or `reference-images` (the fallback when the clip is not reachable). */
26296
+ id: string(),
26297
+ revision: string().nullable(),
26298
+ frames: number(),
26299
+ width: number(),
26300
+ height: number()
26301
+ });
26302
+ var NodeBenchRunnerInputSchema = object({
26303
+ runId: string().min(1),
26304
+ devices: array(NodeBenchmarkDevicePlanSchema).min(1),
26305
+ phases: array(NodeBenchmarkPhaseSchema).min(1),
26306
+ /** The full detail step tree root for the `pipeline` measurement is built on the node from these ids. */
26307
+ steps: array(string()).default([]),
26308
+ fpsPerStream: number().int().min(1).max(30),
26309
+ /** The runner stops on its own past this instant, whatever the hub does. */
26310
+ deadlineAtMs: number(),
26311
+ settleSec: number().min(0).max(60).default(NODE_BENCHMARK_DEFAULTS.settleSec),
26312
+ measureSec: number().min(2).max(300).default(NODE_BENCHMARK_DEFAULTS.measureSec),
26313
+ keepDownloadedModels: boolean().default(false)
26314
+ });
26315
+ var NodeBenchRunnerStateSchema = _enum([
26316
+ "running",
26317
+ "done",
26318
+ "failed",
26319
+ "aborted"
26320
+ ]);
26321
+ var NodeBenchRunnerStatusSchema = object({
26322
+ runId: string(),
26323
+ nodeId: string(),
26324
+ state: NodeBenchRunnerStateSchema,
26325
+ progress: NodeBenchProgressSchema.nullable(),
26326
+ /** Every finished cell so far — a run stopped half way keeps what it measured. */
26327
+ cells: array(NodeBenchCellSchema).readonly(),
26328
+ fingerprint: NodeBenchFingerprintSchema.nullable(),
26329
+ clip: NodeBenchClipSchema.nullable(),
26330
+ /** Cameras seen running on the node during the run (they share its pools). */
26331
+ activeCameraIds: array(number()).readonly(),
26332
+ /** Models the run downloaded and then deleted (not installed before). */
26333
+ deletedModels: array(string()).readonly(),
26334
+ error: string().nullable(),
26335
+ startedAtMs: number(),
26336
+ finishedAtMs: number().nullable()
26337
+ });
26338
+ var NodeBenchmarkStateSchema = _enum([
26339
+ "draining",
26340
+ "measuring",
26341
+ "restoring",
26342
+ "done",
26343
+ "failed",
26344
+ "aborted"
26345
+ ]);
26346
+ /** Why a run ended. */
26347
+ var NodeBenchmarkEndReasonSchema = _enum([
26348
+ "completed",
26349
+ "operator-abort",
26350
+ "deadline",
26351
+ "node-lost",
26352
+ "runner-lost",
26353
+ "hub-restart",
26354
+ "drain-timeout",
26355
+ "failed"
26356
+ ]);
26357
+ var NodeBenchmarkRunSchema = object({
26358
+ runId: string(),
26359
+ nodeId: string(),
26360
+ state: NodeBenchmarkStateSchema,
26361
+ plan: NodeBenchmarkPlanSchema,
26362
+ startedAtMs: number(),
26363
+ deadlineAtMs: number(),
26364
+ finishedAtMs: number().nullable(),
26365
+ endReason: NodeBenchmarkEndReasonSchema.nullable(),
26366
+ error: string().nullable(),
26367
+ /** Cameras moved off the node for the run. */
26368
+ moved: array(number()).readonly(),
26369
+ /** Cameras that stayed (their only frame source is the node). */
26370
+ staying: array(number()).readonly(),
26371
+ /** Something else ran on the node's pools during the run. */
26372
+ contaminated: boolean(),
26373
+ progress: NodeBenchProgressSchema.nullable(),
26374
+ resultIds: array(string()).readonly()
26375
+ });
26376
+ /** `getNodeBenchmarkStatus`: the active run (or the last one), and whether benchmark mode is on. */
26377
+ var NodeBenchmarkStatusSchema = object({
26378
+ /** The node the cluster is in benchmark mode for; null = none. */
26379
+ modeNodeId: string().nullable(),
26380
+ run: NodeBenchmarkRunSchema.nullable()
26381
+ });
26382
+ /**
26383
+ * One stored measurement — the only authority Auto tune and the automatic
26384
+ * shares read measured capacity from. Written by the orchestrator when a run
26385
+ * ends, never by anyone else.
26386
+ */
26387
+ var NodeBenchmarkResultSchema = object({
26388
+ id: string(),
26389
+ runId: string(),
26390
+ nodeId: string(),
26391
+ cell: NodeBenchCellSchema,
26392
+ fpsPerStream: number(),
26393
+ fingerprint: NodeBenchFingerprintSchema.nullable(),
26394
+ clip: NodeBenchClipSchema.nullable(),
26395
+ /** Other work shared the node's pools (a camera that could not move, or the hub's own duties). */
26396
+ contaminated: boolean(),
26397
+ stayingCameras: array(number()).readonly(),
26398
+ /** The run ended early; the cell itself completed. */
26399
+ partialRun: boolean(),
26400
+ measuredAtMs: number()
26401
+ });
26402
+ var ListNodeBenchmarkResultsInputSchema = object({
26403
+ nodeId: string().optional(),
26404
+ deviceKey: string().optional()
26405
+ });
26406
+ /** A result with its standing today: does it still beat the table? */
26407
+ var NodeBenchmarkResultViewSchema = NodeBenchmarkResultSchema.extend({
26408
+ /** `fresh` beats the table; `stale` falls back to it; `superseded` = a newer row covers the same cell. */
26409
+ standing: _enum([
26410
+ "fresh",
26411
+ "stale",
26412
+ "superseded"
26413
+ ]),
26414
+ staleWhy: _enum([
26415
+ "age",
26416
+ "runtime",
26417
+ "pool-tuning"
26418
+ ]).nullable()
26419
+ });
26420
+ object({
26421
+ runId: string(),
26422
+ nodeId: string(),
26423
+ startedAtMs: number(),
26424
+ deadlineAtMs: number(),
26425
+ plan: NodeBenchmarkPlanSchema,
26426
+ moved: array(number()).readonly(),
26427
+ staying: array(number()).readonly()
26428
+ });
26429
+ /** Candidate detectors per device, for the plan editor. */
26430
+ var NodeBenchmarkCandidatesSchema = object({
26431
+ nodeId: string(),
26432
+ reachable: boolean(),
26433
+ devices: array(object({
26434
+ deviceKey: string(),
26435
+ enabled: boolean(),
26436
+ available: boolean(),
26437
+ /** Ordered: what Auto tune would pick first, then the rest of the family by accuracy. */
26438
+ suggested: array(string()).readonly(),
26439
+ /** Every root detector the device has a build for. */
26440
+ all: array(string()).readonly(),
26441
+ /** The model the device runs now, when pinned. */
26442
+ currentModelId: string().nullable()
26443
+ })).readonly(),
26444
+ /** Detail steps the node's catalog offers under the root (for the `pipeline` measurement). */
26445
+ steps: array(object({
26446
+ id: string(),
26447
+ name: string(),
26448
+ slot: string()
26449
+ })).readonly()
26450
+ });
23911
26451
  object({
23912
26452
  activeCameras: number(),
23913
26453
  throttledCameras: number(),
@@ -24996,7 +27536,16 @@ method(RunnerCameraConfigSchema, object({ success: literal(true) }), { kind: "mu
24996
27536
  }), ParkedTrackFrameSchema.nullable()), method(object({
24997
27537
  deviceId: number(),
24998
27538
  trackId: string()
24999
- }), object({ released: number().int().nonnegative() }), { kind: "mutation" });
27539
+ }), object({ released: number().int().nonnegative() }), { kind: "mutation" }), method(NodeBenchRunnerInputSchema, object({
27540
+ accepted: literal(true),
27541
+ runId: string()
27542
+ }), {
27543
+ kind: "mutation",
27544
+ auth: "admin"
27545
+ }), method(object({ runId: string() }), NodeBenchRunnerStatusSchema.nullable(), { auth: "admin" }), method(object({ runId: string() }), object({ aborted: boolean() }), {
27546
+ kind: "mutation",
27547
+ auth: "admin"
27548
+ });
25000
27549
  var CameraPipelineConfigSchema = object({
25001
27550
  engine: PipelineEngineChoiceSchema.optional(),
25002
27551
  steps: array(PipelineStepInputSchema).readonly(),
@@ -25635,6 +28184,21 @@ method(object({
25635
28184
  }), method(PlacementStatsInputSchema, PlacementStatsSchema, { auth: "admin" }), method(SuggestSharesInputSchema, SuggestSharesResultSchema, { auth: "admin" }), method(_void(), EffectiveSharesSchema, { auth: "admin" }), method(SetShareSourceInputSchema, object({ success: literal(true) }), {
25636
28185
  kind: "mutation",
25637
28186
  auth: "admin"
28187
+ }), method(NodeBenchmarkPlanSchema, NodeBenchmarkPreflightSchema, { auth: "admin" }), method(NodeBenchmarkPlanSchema, discriminatedUnion("kind", [object({
28188
+ kind: literal("started"),
28189
+ runId: string()
28190
+ }), object({
28191
+ kind: literal("refused"),
28192
+ preflight: NodeBenchmarkPreflightSchema
28193
+ })]), {
28194
+ kind: "mutation",
28195
+ auth: "admin"
28196
+ }), method(_void(), NodeBenchmarkStatusSchema, { auth: "admin" }), method(object({ runId: string() }), object({ aborted: boolean() }), {
28197
+ kind: "mutation",
28198
+ auth: "admin"
28199
+ }), method(object({ nodeId: string() }), NodeBenchmarkCandidatesSchema, { auth: "admin" }), method(ListNodeBenchmarkResultsInputSchema, array(NodeBenchmarkResultViewSchema).readonly(), { auth: "admin" }), method(object({ id: string() }), object({ deleted: boolean() }), {
28200
+ kind: "mutation",
28201
+ auth: "admin"
25638
28202
  }), method(object({ deviceId: number() }), CameraPipelineSettingsSchema.nullable()), method(object({
25639
28203
  deviceId: number(),
25640
28204
  addonId: string(),
@@ -26040,8 +28604,8 @@ version: string().optional() }), ServerUpdateActionResultSchema, {
26040
28604
  * `smtp-provider` — pluggable email delivery surface.
26041
28605
  *
26042
28606
  * Collection cap: a deployment may install multiple SMTP relays (e.g.
26043
- * one for transactional / one for notifications). Consumers (magic-link,
26044
- * notifier addons, …) walk the collection and pick the first
28607
+ * one for transactional / one for notifications). Consumers (notifier
28608
+ * addons, …) walk the collection and pick the first
26045
28609
  * ready provider OR target a specific addonId.
26046
28610
  *
26047
28611
  * The shape stays small on purpose — `sendEmail` is enough for the
@@ -26220,7 +28784,7 @@ targets: array(object({
26220
28784
  })));
26221
28785
  /**
26222
28786
  * `sso-bridge` — internal hub-only cap that lets SSO-style auth
26223
- * providers (OIDC, SAML, magic-link, …) mint an HMAC-signed token
28787
+ * providers (OIDC, SAML, …) mint an HMAC-signed token
26224
28788
  * carrying the post-callback claims before redirecting back to
26225
28789
  * `/api/auth/sso/finish`.
26226
28790
  *
@@ -26271,7 +28835,26 @@ var SsoBridgeClaimsSchema = object({
26271
28835
  * editing a descriptor must not retroactively extend or shorten a link the
26272
28836
  * operator already consented to.
26273
28837
  */
26274
- refreshTtl: union([number().int().positive(), literal("never")]).optional()
28838
+ refreshTtl: union([number().int().positive(), literal("never")]).optional(),
28839
+ /**
28840
+ * Opaque handle of a hub-side LINK intent (D782). Set by an OIDC callback
28841
+ * that was started from a signed-in user's "Link" button: the finish then
28842
+ * links this identity to the intent's user instead of signing anyone in.
28843
+ * The handle carries no user id — the hub resolves it, single-use.
28844
+ */
28845
+ linkIntent: string().optional(),
28846
+ /**
28847
+ * Verified `iss` of the id_token behind an OIDC login bridge (D782). A
28848
+ * subject is unique only per issuer, so a link is bound to it.
28849
+ */
28850
+ issuer: string().optional(),
28851
+ /**
28852
+ * SHA-256 (hex) of the `camstack_sso_state` cookie the IdP `/start` set in
28853
+ * the browser that began this sign-in. `/api/auth/sso/finish` requires the
28854
+ * request to present the matching cookie — a login bridge is useless in
28855
+ * any other browser.
28856
+ */
28857
+ browserBinding: string().optional()
26275
28858
  });
26276
28859
  method(object({
26277
28860
  claims: SsoBridgeClaimsSchema,
@@ -28177,7 +30760,22 @@ DeviceType.Camera, method(object({ deviceId: number().int().nonnegative() }), ar
28177
30760
  * field their hints were silently stripped by the schema and the
28178
30761
  * adaptive ladder started blind on the client's display size.
28179
30762
  */
28180
- hints: webrtcClientHintsSchema.optional()
30763
+ hints: webrtcClientHintsSchema.optional(),
30764
+ /**
30765
+ * Talk-back (D771): relay the PEER's audio to the device's speaker
30766
+ * through the `intercom` cap's push-talk triple. When `true` and the
30767
+ * offer lets the peer send audio, the answer's audio is `sendrecv`
30768
+ * and every inbound frame goes to `intercom.pushTalkAudio` for this
30769
+ * `deviceId`; absent/false answers `sendonly`, as for every viewer.
30770
+ *
30771
+ * TRUSTED-CALLER ONLY. Set by the Alexa export for an Echo on a camera
30772
+ * with `intercom`, when the linked user may control that camera. The
30773
+ * hub STRIPS it from every request-bound call (a browser), exactly as
30774
+ * it overwrites `relayOnly` — a viewer's talk permission is the
30775
+ * intercom cap's own surface (share tokens gate it there), and this
30776
+ * flag must not become a second door to the camera's speaker.
30777
+ */
30778
+ talkback: boolean().optional()
28181
30779
  }), object({
28182
30780
  sessionId: string(),
28183
30781
  sdpAnswer: string()
@@ -30689,6 +33287,9 @@ var CreateIntegrationInputSchema = object({
30689
33287
  enabled: boolean().optional(),
30690
33288
  info: record(string(), unknown()).optional(),
30691
33289
  settings: record(string(), unknown()).optional(),
33290
+ /** Keys of `settings` the form's schema declares secret (by type) — kept in
33291
+ * the keychain, not the table (D787). */
33292
+ secretKeys: array(string()).optional(),
30692
33293
  skipRestart: boolean().optional()
30693
33294
  });
30694
33295
  var UpdateIntegrationInputSchema = object({
@@ -30712,7 +33313,9 @@ method(_void(), array(IntegrationWithStateSchema)), method(object({ id: string()
30712
33313
  auth: "admin"
30713
33314
  }), method(object({ id: string() }), record(string(), unknown()), { auth: "admin" }), method(object({
30714
33315
  id: string(),
30715
- settings: record(string(), unknown())
33316
+ settings: record(string(), unknown()),
33317
+ /** Keys the form's schema declares secret (by type) — keychain-stored (D787). */
33318
+ secretKeys: array(string()).optional()
30716
33319
  }), object({ success: boolean() }), {
30717
33320
  kind: "mutation",
30718
33321
  auth: "admin"
@@ -36171,16 +38774,6 @@ var ApiKeySummarySchema = object({
36171
38774
  createdAt: number(),
36172
38775
  lastUsedAt: number().optional()
36173
38776
  });
36174
- var CreateApiKeyInputSchema = object({
36175
- label: string(),
36176
- isAdmin: boolean().default(false),
36177
- allowedProviders: union([array(string()), literal("*")]).optional(),
36178
- allowedDevices: record(string(), union([array(string()), literal("*")])).optional()
36179
- });
36180
- var CreateApiKeyResultSchema = object({
36181
- token: string(),
36182
- record: ApiKeySummarySchema
36183
- });
36184
38777
  var ScopedTokenSummarySchema = object({
36185
38778
  id: string(),
36186
38779
  userId: string(),
@@ -36221,6 +38814,32 @@ var TotpStatusSchema = object({
36221
38814
  /** Null when no row exists OR the row is still pending confirmation. */
36222
38815
  confirmedAt: number().nullable()
36223
38816
  });
38817
+ /**
38818
+ * user-management — singleton capability for user accounts, API keys,
38819
+ * and scoped tokens.
38820
+ *
38821
+ * v2 model: every method gated by `auth: 'admin'`. Admin-only delegation
38822
+ * — the subset check on `setUserScopes` / `createScopedToken` is moot
38823
+ * because non-admins never reach these. If/when we open non-admin
38824
+ * delegation, structural caller-scope subset check goes inside the
38825
+ * provider.
38826
+ */
38827
+ var ExternalIdentitySchema = object({
38828
+ /** Login-method id of the provider instance, e.g. `auth-oidc/authentik`. */
38829
+ provider: string(),
38830
+ /** The IdP's stable subject (`sub`) for this account. */
38831
+ subject: string(),
38832
+ /** The verified `iss` of the IdP the identity was linked under — `sub` is unique only per issuer. */
38833
+ issuer: string(),
38834
+ userId: string(),
38835
+ /** What the IdP called the account at link time (username / email) — display only. */
38836
+ label: string().optional(),
38837
+ linkedAt: number()
38838
+ });
38839
+ var ExternalIdentityKeySchema = object({
38840
+ provider: string().min(1),
38841
+ subject: string().min(1)
38842
+ });
36224
38843
  method(_void(), array(UserSummarySchema), { auth: "admin" }), method(CreateUserInputSchema, UserSummarySchema, {
36225
38844
  kind: "mutation",
36226
38845
  auth: "admin",
@@ -36253,17 +38872,10 @@ method(_void(), array(UserSummarySchema), { auth: "admin" }), method(CreateUserI
36253
38872
  }), UserSummarySchema.extend({ passwordHash: string() }).nullable(), {
36254
38873
  kind: "mutation",
36255
38874
  access: "view"
36256
- }), method(_void(), array(ApiKeySummarySchema), { auth: "admin" }), method(CreateApiKeyInputSchema, CreateApiKeyResultSchema, {
36257
- kind: "mutation",
36258
- auth: "admin",
36259
- access: "create"
36260
- }), method(object({ id: string() }), object({ success: literal(true) }), {
38875
+ }), method(_void(), array(ApiKeySummarySchema), { auth: "admin" }), method(object({ id: string() }), object({ success: literal(true) }), {
36261
38876
  kind: "mutation",
36262
38877
  auth: "admin",
36263
38878
  access: "delete"
36264
- }), method(object({ token: string() }), ApiKeySummarySchema.nullable(), {
36265
- kind: "mutation",
36266
- access: "view"
36267
38879
  }), method(CreateScopedTokenInputSchema, CreateScopedTokenResultSchema, {
36268
38880
  kind: "mutation",
36269
38881
  auth: "admin",
@@ -36334,7 +38946,14 @@ method(_void(), array(UserSummarySchema), { auth: "admin" }), method(CreateUserI
36334
38946
  userId: string(),
36335
38947
  username: string(),
36336
38948
  scopes: array(TokenScopeSchema)
36337
- }).nullable(), { access: "view" }), method(_void(), array(OauthSessionSummarySchema), { auth: "admin" }), method(object({ id: string() }), object({ success: boolean() }), {
38949
+ }).nullable(), { access: "view" }), method(object({ userId: string() }), array(ExternalIdentitySchema), { auth: "admin" }), method(ExternalIdentityKeySchema, object({
38950
+ userId: string(),
38951
+ issuer: string()
38952
+ }).nullable(), { auth: "admin" }), method(ExternalIdentityKeySchema.extend({ userId: string() }), object({ success: boolean() }), {
38953
+ kind: "mutation",
38954
+ auth: "admin",
38955
+ access: "delete"
38956
+ }), method(_void(), array(OauthSessionSummarySchema), { auth: "admin" }), method(object({ id: string() }), object({ success: boolean() }), {
36338
38957
  kind: "mutation",
36339
38958
  auth: "admin",
36340
38959
  access: "delete"
@@ -36725,6 +39344,451 @@ DeviceType.Camera, method(object({
36725
39344
  detection: array(ZoneRuleSchema).readonly(),
36726
39345
  package: array(ZoneRuleSchema).readonly()
36727
39346
  });
39347
+ /**
39348
+ * `training-provider` — ONE cloud that can run the CamStack trainer.
39349
+ *
39350
+ * A thin, mockable translation layer: it knows how to run a container with a
39351
+ * GPU, move a dataset in, read the job's stdout and hand artefacts back. It
39352
+ * knows nothing about datasets, splits, floors, cost policy or Model Studio —
39353
+ * those are the `training` orchestrator's (D805). Every rule written there
39354
+ * once is what makes a second provider (RunPod, a local NVIDIA node) a new
39355
+ * manifest entry and nothing else.
39356
+ *
39357
+ * Collection, routed by the `addonId` in every single-row input (the `llm` /
39358
+ * `notification-output` posture); `describe` concat-fans across providers.
39359
+ * Every method is `admin`: these spend money.
39360
+ *
39361
+ * Every cloud object a provider creates is tagged with the orchestrator's
39362
+ * `jobKey`, so a retried submit finds the job it already started instead of
39363
+ * starting a second GPU, and `listJobs` can find orphans.
39364
+ *
39365
+ * Bytes never ride a cap field: the dataset arrives as a `ctx.peerBytes`
39366
+ * ticket the producer (pipeline-analytics) minted, and artefacts leave as a
39367
+ * ticket the provider mints (D613).
39368
+ */
39369
+ var TrainingGpuOptionSchema = object({
39370
+ id: string(),
39371
+ label: string(),
39372
+ /** List price, USD per GPU-hour, before any region multiplier. */
39373
+ usdPerHour: number().nonnegative(),
39374
+ vramGb: number().nonnegative()
39375
+ });
39376
+ var TrainingRegionOptionSchema = object({
39377
+ /** `''` = any region (the provider's choice). */
39378
+ id: string(),
39379
+ label: string(),
39380
+ priceMultiplier: number().positive()
39381
+ });
39382
+ /**
39383
+ * The provider's per-account settings, as the orchestrator reads them. They
39384
+ * live in the PROVIDER addon's settings (operator decision 2026-10-08: they
39385
+ * depend on the user's account), never hard-coded in the orchestrator.
39386
+ */
39387
+ var TrainingProviderDefaultsSchema = object({
39388
+ gpuType: string(),
39389
+ region: string(),
39390
+ costCapUsd: number().nonnegative(),
39391
+ maxRuntimeSec: number().int().positive(),
39392
+ /** Hours a FAILED job's cloud dataset is kept for debugging; 0 = delete at once. */
39393
+ failedDatasetGraceHours: number().nonnegative()
39394
+ });
39395
+ var TrainingProviderDescriptorSchema = object({
39396
+ addonId: string(),
39397
+ /** `modal`, `runpod`, `fake`, … */
39398
+ kind: string(),
39399
+ label: string(),
39400
+ gpuTypes: array(TrainingGpuOptionSchema).readonly(),
39401
+ regions: array(TrainingRegionOptionSchema).readonly(),
39402
+ maxDatasetBytes: number().int().positive(),
39403
+ maxRuntimeSec: number().int().positive(),
39404
+ freeTierNote: string().optional(),
39405
+ /** Where the data goes, in one sentence the confirm dialog repeats. */
39406
+ dataResidencyNote: string(),
39407
+ /** Credentials are present — never the values. */
39408
+ configured: boolean(),
39409
+ defaults: TrainingProviderDefaultsSchema
39410
+ });
39411
+ var TrainingCredentialCheckSchema = object({
39412
+ ok: boolean(),
39413
+ /** Workspace / account name, when the provider says. */
39414
+ account: string().optional(),
39415
+ reason: _enum([
39416
+ "missing",
39417
+ "invalid",
39418
+ "forbidden",
39419
+ "network",
39420
+ "quota"
39421
+ ]).optional(),
39422
+ detail: string().optional()
39423
+ });
39424
+ var ProviderJobStateSchema = _enum([
39425
+ "pending",
39426
+ "starting",
39427
+ "running",
39428
+ "succeeded",
39429
+ "failed",
39430
+ "cancelled",
39431
+ "lost"
39432
+ ]);
39433
+ var ProviderJobStatusSchema = object({
39434
+ jobKey: string(),
39435
+ providerJobId: string().optional(),
39436
+ state: ProviderJobStateSchema,
39437
+ startedAt: number().optional(),
39438
+ endedAt: number().optional(),
39439
+ exitCode: number().int().optional(),
39440
+ failureReason: string().optional(),
39441
+ gpuType: string(),
39442
+ region: string().optional(),
39443
+ billedSeconds: number().nonnegative(),
39444
+ costUsd: number().nonnegative(),
39445
+ /** True when `costUsd` is runtime × list price, not a billing answer. */
39446
+ costIsEstimate: boolean(),
39447
+ lastFetchedAt: number()
39448
+ });
39449
+ /**
39450
+ * The trainer the job runs, by SOURCE revision: the provider turns it into an
39451
+ * image its own way (Modal builds the published Dockerfile at that revision;
39452
+ * a registry-pull provider maps it to a tag). Recorded on the job and echoed
39453
+ * in `result.json`.
39454
+ */
39455
+ var TrainerSourceRefSchema = object({
39456
+ /** Hugging Face repo id, e.g. `camstack/camstack-trainer`. */
39457
+ repo: string().min(1),
39458
+ /** A commit sha (never a branch) — the job must be reproducible. */
39459
+ revision: string().regex(/^[0-9a-f]{7,64}$/)
39460
+ });
39461
+ var JobRef = {
39462
+ addonId: string(),
39463
+ jobKey: string().uuid()
39464
+ };
39465
+ var TrainingLogLineSchema = object({
39466
+ ts: number(),
39467
+ text: string()
39468
+ });
39469
+ method(object({}), array(TrainingProviderDescriptorSchema).readonly(), { auth: "admin" }), method(object({ addonId: string() }), TrainingCredentialCheckSchema, {
39470
+ kind: "mutation",
39471
+ auth: "admin",
39472
+ timeoutMs: 3e4
39473
+ }), method(object({
39474
+ addonId: string(),
39475
+ gpuType: string(),
39476
+ region: string(),
39477
+ datasetBytes: number().int().nonnegative(),
39478
+ gpuSecondsLow: number().nonnegative(),
39479
+ gpuSecondsHigh: number().nonnegative()
39480
+ }), object({
39481
+ usdLow: number().nonnegative(),
39482
+ usdHigh: number().nonnegative(),
39483
+ notes: array(string()).readonly()
39484
+ }), { auth: "admin" }), method(object({
39485
+ ...JobRef,
39486
+ ticket: PeerBytesTicketSchema
39487
+ }), object({
39488
+ bytes: number().int().nonnegative(),
39489
+ sha256: string()
39490
+ }), {
39491
+ kind: "mutation",
39492
+ auth: "admin",
39493
+ timeoutMs: 120 * 6e4
39494
+ }), method(object({
39495
+ ...JobRef,
39496
+ trainer: TrainerSourceRefSchema,
39497
+ jobSpecJson: string().min(2).max(64e3),
39498
+ gpuType: string(),
39499
+ region: string(),
39500
+ maxRuntimeSec: number().int().positive()
39501
+ }), ProviderJobStatusSchema, {
39502
+ kind: "mutation",
39503
+ auth: "admin",
39504
+ timeoutMs: 30 * 6e4
39505
+ }), method(object(JobRef), ProviderJobStatusSchema, {
39506
+ auth: "admin",
39507
+ timeoutMs: 6e4
39508
+ }), method(object({
39509
+ ...JobRef,
39510
+ cursor: string().optional(),
39511
+ max: number().int().min(1).max(500)
39512
+ }), object({
39513
+ lines: array(TrainingLogLineSchema).readonly(),
39514
+ cursor: string()
39515
+ }), {
39516
+ auth: "admin",
39517
+ timeoutMs: 6e4
39518
+ }), method(object(JobRef), object({ ok: literal(true) }), {
39519
+ kind: "mutation",
39520
+ auth: "admin",
39521
+ timeoutMs: 6e4
39522
+ }), method(object(JobRef), object({
39523
+ found: boolean(),
39524
+ text: string().optional()
39525
+ }), {
39526
+ kind: "mutation",
39527
+ auth: "admin",
39528
+ timeoutMs: 5 * 6e4
39529
+ }), method(object({
39530
+ ...JobRef,
39531
+ path: _enum(["bundle.tar"])
39532
+ }), object({ ticket: PeerBytesTicketSchema }), {
39533
+ kind: "mutation",
39534
+ auth: "admin",
39535
+ timeoutMs: 5 * 6e4
39536
+ }), method(object(JobRef), object({ deleted: array(string()).readonly() }), {
39537
+ kind: "mutation",
39538
+ auth: "admin",
39539
+ timeoutMs: 5 * 6e4
39540
+ }), method(object({ addonId: string() }), array(ProviderJobStatusSchema).readonly(), {
39541
+ auth: "admin",
39542
+ timeoutMs: 2 * 6e4
39543
+ });
39544
+ /**
39545
+ * `training` — the cloud-training orchestrator (D805). Hub-only singleton,
39546
+ * provided by `addon-training`.
39547
+ *
39548
+ * It owns what every provider must agree on, written once:
39549
+ *
39550
+ * - **Dataset versions.** Taken over from pipeline-analytics (D796): the rows
39551
+ * live here (D808); pipeline-analytics still CUTS a version (it owns the corpus and
39552
+ * the export plan) and reaches this store through the five row methods
39553
+ * below, so the Retrain page and the export did not change.
39554
+ * - **Jobs.** A persisted state machine, a reconcile loop against the
39555
+ * provider, a cost guard, a daily orphan sweep and the retention rules.
39556
+ * - **The return flow.** Verified artefacts → Model Studio
39557
+ * (`custom-model-registry.importModelBundle`) → canary on cameras →
39558
+ * rollback. Nothing is ever registered automatically.
39559
+ *
39560
+ * Every method is `admin`.
39561
+ */
39562
+ /** A version WITH its frame list — what the export and a job read. */
39563
+ var TrainingDatasetVersionRowSchema = RetrainDatasetVersionSchema.omit({ frameCount: true }).extend({ frameIds: array(string()).max(2e4).readonly() });
39564
+ /** A base model a detector job can fine-tune, and the baseline it is judged against. */
39565
+ var TrainingBaseModelSchema = object({
39566
+ modelId: string(),
39567
+ label: string(),
39568
+ weights: string(),
39569
+ imgsz: number().int(),
39570
+ baselineOnnxUrl: string(),
39571
+ baselineFloors: record(string(), number()),
39572
+ /** The base the fleet runs most — the UI's default. */
39573
+ recommended: boolean()
39574
+ });
39575
+ var TrainingPresetSchema = _enum([
39576
+ "quick",
39577
+ "standard",
39578
+ "thorough"
39579
+ ]);
39580
+ var TrainingJobRequestSchema = object({
39581
+ datasetVersionId: string().min(1),
39582
+ /** The `training-provider` addon that runs it. */
39583
+ addonId: string().min(1),
39584
+ gpuType: string().min(1),
39585
+ region: string(),
39586
+ baseModelId: string().min(1),
39587
+ preset: TrainingPresetSchema,
39588
+ /** Freeze the backbone's first N layers; `null` = the preset's choice. */
39589
+ freeze: number().int().nonnegative().nullable(),
39590
+ /** Cameras held out whole for evaluation; `null` = the orchestrator's default. */
39591
+ holdoutCameras: array(number().int()).nullable()
39592
+ });
39593
+ var TrainingSplitPlanSchema = object({
39594
+ holdoutCameras: array(number().int()).readonly(),
39595
+ /** Used when no camera is held out: the last N days of every camera. */
39596
+ holdoutLastDays: number().int().nonnegative(),
39597
+ /** Holdout subjects per class (camera holdout only; `null` = known only after the split). */
39598
+ holdoutSupport: record(string(), number().int()).nullable(),
39599
+ trainSubjects: number().int()
39600
+ });
39601
+ var TrainingRefusalReasonSchema = _enum([
39602
+ "unknown-dataset",
39603
+ "unknown-provider",
39604
+ "provider-not-configured",
39605
+ "unknown-base-model",
39606
+ "unknown-gpu",
39607
+ "dataset-too-large",
39608
+ "no-training-subjects",
39609
+ "job-already-running"
39610
+ ]);
39611
+ var TrainingJobPlanSchema = object({
39612
+ refusal: object({
39613
+ reason: TrainingRefusalReasonSchema,
39614
+ detail: string()
39615
+ }).nullable(),
39616
+ warnings: array(string()).readonly(),
39617
+ split: TrainingSplitPlanSchema.nullable(),
39618
+ estimate: object({
39619
+ datasetBytes: number().int(),
39620
+ uploadMinutesAt20Mbps: number(),
39621
+ gpuSecondsLow: number(),
39622
+ gpuSecondsHigh: number(),
39623
+ usdLow: number(),
39624
+ usdHigh: number(),
39625
+ notes: array(string()).readonly()
39626
+ }).nullable(),
39627
+ /** Pre-filled from the provider's settings; the operator may lower or raise them. */
39628
+ defaults: object({
39629
+ maxCostUsd: number(),
39630
+ maxRuntimeSec: number().int()
39631
+ }).nullable(),
39632
+ /** The sentence the confirm dialog repeats: where the frames go and when they are deleted. */
39633
+ dataNotice: string()
39634
+ });
39635
+ /**
39636
+ * Orchestrator-owned states, persisted. `uploading` covers exporting the
39637
+ * archive (it is streamed, never staged). Terminal: `failed`, `cancelled`,
39638
+ * `lost`, `expired`, `discarded`. `registered` and `canary` are where a
39639
+ * result lives after the operator acted on it.
39640
+ */
39641
+ var TrainingJobStateSchema = _enum([
39642
+ "uploading",
39643
+ "submitted",
39644
+ "starting",
39645
+ "running",
39646
+ "collecting",
39647
+ "ready",
39648
+ "registered",
39649
+ "canary",
39650
+ "failed",
39651
+ "cancelling",
39652
+ "cancelled",
39653
+ "lost",
39654
+ "expired",
39655
+ "discarded"
39656
+ ]);
39657
+ var TrainingFailureReasonSchema = _enum([
39658
+ "cost-cap",
39659
+ "runtime-cap",
39660
+ "upload-failed",
39661
+ "submit-failed",
39662
+ "trainer-failed",
39663
+ "result-invalid",
39664
+ "checksum-mismatch",
39665
+ "fetch-failed",
39666
+ "provider-error",
39667
+ "hub-restart-during-upload"
39668
+ ]);
39669
+ var TrainingProgressPointSchema = object({
39670
+ epoch: number().int(),
39671
+ map50: number().nullable(),
39672
+ map50_95: number().nullable()
39673
+ });
39674
+ var TrainingCanarySchema = object({
39675
+ deviceIds: array(number().int()).readonly(),
39676
+ since: number(),
39677
+ /** Every override the canary replaced, exactly, so rollback restores it. */
39678
+ previous: array(object({
39679
+ deviceId: number().int(),
39680
+ nodeId: string(),
39681
+ deviceKey: string(),
39682
+ patch: object({
39683
+ modelId: string().optional(),
39684
+ settings: record(string(), unknown()).readonly().optional()
39685
+ }).nullable()
39686
+ })).readonly()
39687
+ });
39688
+ var TrainingJobSchema = object({
39689
+ id: string(),
39690
+ idempotencyKey: string(),
39691
+ name: string(),
39692
+ createdAt: number(),
39693
+ updatedAt: number(),
39694
+ state: TrainingJobStateSchema,
39695
+ stage: TrainingStageSchema.nullable(),
39696
+ failure: object({
39697
+ reason: TrainingFailureReasonSchema,
39698
+ stage: string().nullable(),
39699
+ detail: string()
39700
+ }).nullable(),
39701
+ request: TrainingJobRequestSchema,
39702
+ maxCostUsd: number().nonnegative(),
39703
+ maxRuntimeSec: number().int().positive(),
39704
+ trainer: TrainerSourceRefSchema,
39705
+ datasetLayout: RetrainExportLayoutSchema,
39706
+ dataset: object({
39707
+ bytes: number().int(),
39708
+ sha256: string(),
39709
+ uploadedAt: number()
39710
+ }).nullable(),
39711
+ split: TrainingSplitPlanSchema,
39712
+ provider: object({
39713
+ state: ProviderJobStateSchema.nullable(),
39714
+ providerJobId: string().nullable(),
39715
+ startedAt: number().nullable(),
39716
+ endedAt: number().nullable(),
39717
+ billedSeconds: number(),
39718
+ costUsd: number(),
39719
+ costIsEstimate: boolean(),
39720
+ lastPolledAt: number().nullable()
39721
+ }),
39722
+ progress: object({
39723
+ epoch: number().int().nullable(),
39724
+ epochs: number().int().nullable(),
39725
+ etaSec: number().nullable(),
39726
+ series: array(TrainingProgressPointSchema).readonly()
39727
+ }),
39728
+ /** The last lines of the job's output (≤ 200), newest last. Never frame paths. */
39729
+ logTail: array(string()).readonly(),
39730
+ logCursor: string().nullable(),
39731
+ artifacts: object({
39732
+ bundleBytes: number().int(),
39733
+ bundleSha256: string(),
39734
+ fetchedAt: number(),
39735
+ /** When the staged artefacts are deleted from the hub. */
39736
+ expiresAt: number()
39737
+ }).nullable(),
39738
+ /** When the provider-side copy of the frames was deleted; null while it exists. */
39739
+ cloudDatasetDeletedAt: number().nullable(),
39740
+ /** A failed job's dataset is kept until then (the provider's grace), then deleted. */
39741
+ cloudCleanupDueAt: number().nullable(),
39742
+ /** Model ids registered from this job (base, and int8 when kept). */
39743
+ registeredModelIds: array(string()).readonly(),
39744
+ canary: TrainingCanarySchema.nullable()
39745
+ });
39746
+ var IdInput = object({ id: string().min(1) });
39747
+ method(TrainingDatasetVersionRowSchema, object({ stored: boolean() }), {
39748
+ kind: "mutation",
39749
+ auth: "admin"
39750
+ }), 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() }), {
39751
+ kind: "mutation",
39752
+ auth: "admin"
39753
+ }), method(object({}), array(TrainingBaseModelSchema).readonly(), { auth: "admin" }), method(TrainingJobRequestSchema, TrainingJobPlanSchema, {
39754
+ auth: "admin",
39755
+ timeoutMs: 6e4
39756
+ }), method(TrainingJobRequestSchema.extend({
39757
+ name: string().min(1).max(120),
39758
+ maxCostUsd: number().positive(),
39759
+ maxRuntimeSec: number().int().positive(),
39760
+ idempotencyKey: string().min(8).max(80)
39761
+ }), discriminatedUnion("kind", [object({
39762
+ kind: literal("started"),
39763
+ job: TrainingJobSchema
39764
+ }), object({
39765
+ kind: literal("refused"),
39766
+ reason: TrainingRefusalReasonSchema,
39767
+ detail: string()
39768
+ })]), {
39769
+ kind: "mutation",
39770
+ auth: "admin",
39771
+ timeoutMs: 12e4
39772
+ }), method(object({}), array(TrainingJobSchema).readonly(), { auth: "admin" }), method(IdInput, TrainingJobSchema.nullable(), { auth: "admin" }), method(IdInput, TrainingJobSchema, {
39773
+ kind: "mutation",
39774
+ auth: "admin",
39775
+ timeoutMs: 12e4
39776
+ }), method(IdInput, TrainingResultSchema.nullable(), { auth: "admin" }), method(IdInput.extend({ canaryDeviceIds: array(number().int()).readonly() }), TrainingJobSchema, {
39777
+ kind: "mutation",
39778
+ auth: "admin",
39779
+ timeoutMs: 30 * 6e4
39780
+ }), method(IdInput.extend({ deviceIds: array(number().int()).min(1).readonly() }), TrainingJobSchema, {
39781
+ kind: "mutation",
39782
+ auth: "admin",
39783
+ timeoutMs: 12e4
39784
+ }), method(IdInput, TrainingJobSchema, {
39785
+ kind: "mutation",
39786
+ auth: "admin",
39787
+ timeoutMs: 12e4
39788
+ }), method(IdInput, TrainingJobSchema, {
39789
+ kind: "mutation",
39790
+ auth: "admin"
39791
+ });
36728
39792
  SOURCE_CAPS.filter((cap) => cap !== "switch" && cap !== "motion");
36729
39793
  Object.freeze({
36730
39794
  person: .5,
@@ -37348,6 +40412,12 @@ Object.freeze({
37348
40412
  addonId: null,
37349
40413
  access: "create"
37350
40414
  },
40415
+ "backup.checkBackupKey": {
40416
+ capName: "backup",
40417
+ capScope: "system",
40418
+ addonId: null,
40419
+ access: "create"
40420
+ },
37351
40421
  "backup.delete": {
37352
40422
  capName: "backup",
37353
40423
  capScope: "system",
@@ -37360,6 +40430,18 @@ Object.freeze({
37360
40430
  addonId: null,
37361
40431
  access: "delete"
37362
40432
  },
40433
+ "backup.disableEncryption": {
40434
+ capName: "backup",
40435
+ capScope: "system",
40436
+ addonId: null,
40437
+ access: "create"
40438
+ },
40439
+ "backup.getEncryption": {
40440
+ capName: "backup",
40441
+ capScope: "system",
40442
+ addonId: null,
40443
+ access: "view"
40444
+ },
37363
40445
  "backup.getEntries": {
37364
40446
  capName: "backup",
37365
40447
  capScope: "system",
@@ -37414,6 +40496,12 @@ Object.freeze({
37414
40496
  addonId: null,
37415
40497
  access: "create"
37416
40498
  },
40499
+ "backup.setupEncryption": {
40500
+ capName: "backup",
40501
+ capScope: "system",
40502
+ addonId: null,
40503
+ access: "create"
40504
+ },
37417
40505
  "backup.trigger": {
37418
40506
  capName: "backup",
37419
40507
  capScope: "system",
@@ -37966,6 +41054,12 @@ Object.freeze({
37966
41054
  addonId: null,
37967
41055
  access: "create"
37968
41056
  },
41057
+ "customModelRegistry.importModelBundle": {
41058
+ capName: "custom-model-registry",
41059
+ capScope: "system",
41060
+ addonId: null,
41061
+ access: "create"
41062
+ },
37969
41063
  "customModelRegistry.listModels": {
37970
41064
  capName: "custom-model-registry",
37971
41065
  capScope: "system",
@@ -39376,6 +42470,108 @@ Object.freeze({
39376
42470
  addonId: null,
39377
42471
  access: "create"
39378
42472
  },
42473
+ "keychain.delete": {
42474
+ capName: "keychain",
42475
+ capScope: "system",
42476
+ addonId: null,
42477
+ access: "delete"
42478
+ },
42479
+ "keychain.getState": {
42480
+ capName: "keychain",
42481
+ capScope: "system",
42482
+ addonId: null,
42483
+ access: "view"
42484
+ },
42485
+ "keychain.listMeta": {
42486
+ capName: "keychain",
42487
+ capScope: "system",
42488
+ addonId: null,
42489
+ access: "view"
42490
+ },
42491
+ "keychain.put": {
42492
+ capName: "keychain",
42493
+ capScope: "system",
42494
+ addonId: null,
42495
+ access: "create"
42496
+ },
42497
+ "keychain.resolve": {
42498
+ capName: "keychain",
42499
+ capScope: "system",
42500
+ addonId: null,
42501
+ access: "view"
42502
+ },
42503
+ "keychainAdmin.acknowledgeReset": {
42504
+ capName: "keychain-admin",
42505
+ capScope: "system",
42506
+ addonId: null,
42507
+ access: "create"
42508
+ },
42509
+ "keychainAdmin.deleteOrphans": {
42510
+ capName: "keychain-admin",
42511
+ capScope: "system",
42512
+ addonId: null,
42513
+ access: "delete"
42514
+ },
42515
+ "keychainAdmin.downloadRecoveryKey": {
42516
+ capName: "keychain-admin",
42517
+ capScope: "system",
42518
+ addonId: null,
42519
+ access: "create"
42520
+ },
42521
+ "keychainAdmin.listAudit": {
42522
+ capName: "keychain-admin",
42523
+ capScope: "system",
42524
+ addonId: null,
42525
+ access: "view"
42526
+ },
42527
+ "keychainAdmin.listSecrets": {
42528
+ capName: "keychain-admin",
42529
+ capScope: "system",
42530
+ addonId: null,
42531
+ access: "view"
42532
+ },
42533
+ "keychainAdmin.purgeRetiredKeys": {
42534
+ capName: "keychain-admin",
42535
+ capScope: "system",
42536
+ addonId: null,
42537
+ access: "delete"
42538
+ },
42539
+ "keychainAdmin.resetKeychain": {
42540
+ capName: "keychain-admin",
42541
+ capScope: "system",
42542
+ addonId: null,
42543
+ access: "delete"
42544
+ },
42545
+ "keychainAdmin.resetReport": {
42546
+ capName: "keychain-admin",
42547
+ capScope: "system",
42548
+ addonId: null,
42549
+ access: "delete"
42550
+ },
42551
+ "keychainAdmin.reveal": {
42552
+ capName: "keychain-admin",
42553
+ capScope: "system",
42554
+ addonId: null,
42555
+ access: "create"
42556
+ },
42557
+ "keychainAdmin.rotateMasterKey": {
42558
+ capName: "keychain-admin",
42559
+ capScope: "system",
42560
+ addonId: null,
42561
+ access: "create"
42562
+ },
42563
+ "keychainAdmin.setSystemSecret": {
42564
+ capName: "keychain-admin",
42565
+ capScope: "system",
42566
+ addonId: null,
42567
+ access: "create"
42568
+ },
42569
+ "keychainAdmin.status": {
42570
+ capName: "keychain-admin",
42571
+ capScope: "system",
42572
+ addonId: null,
42573
+ access: "view"
42574
+ },
39379
42575
  "lawnMowerControl.dock": {
39380
42576
  capName: "lawn-mower-control",
39381
42577
  capScope: "device",
@@ -40750,6 +43946,18 @@ Object.freeze({
40750
43946
  addonId: null,
40751
43947
  access: "create"
40752
43948
  },
43949
+ "pipelineAnalytics.addRetrainFrameFromRecording": {
43950
+ capName: "pipeline-analytics",
43951
+ capScope: "device",
43952
+ addonId: null,
43953
+ access: "create"
43954
+ },
43955
+ "pipelineAnalytics.addRetrainFramesToCollection": {
43956
+ capName: "pipeline-analytics",
43957
+ capScope: "device",
43958
+ addonId: null,
43959
+ access: "create"
43960
+ },
40753
43961
  "pipelineAnalytics.applyDeviceSettingsPatch": {
40754
43962
  capName: "pipeline-analytics",
40755
43963
  capScope: "device",
@@ -40798,12 +44006,36 @@ Object.freeze({
40798
44006
  addonId: null,
40799
44007
  access: "view"
40800
44008
  },
44009
+ "pipelineAnalytics.createRetrainCollection": {
44010
+ capName: "pipeline-analytics",
44011
+ capScope: "device",
44012
+ addonId: null,
44013
+ access: "create"
44014
+ },
44015
+ "pipelineAnalytics.createRetrainDatasetVersion": {
44016
+ capName: "pipeline-analytics",
44017
+ capScope: "device",
44018
+ addonId: null,
44019
+ access: "create"
44020
+ },
40801
44021
  "pipelineAnalytics.deleteDeviceEvents": {
40802
44022
  capName: "pipeline-analytics",
40803
44023
  capScope: "device",
40804
44024
  addonId: null,
40805
44025
  access: "delete"
40806
44026
  },
44027
+ "pipelineAnalytics.deleteRetrainCollection": {
44028
+ capName: "pipeline-analytics",
44029
+ capScope: "device",
44030
+ addonId: null,
44031
+ access: "delete"
44032
+ },
44033
+ "pipelineAnalytics.deleteRetrainDatasetVersion": {
44034
+ capName: "pipeline-analytics",
44035
+ capScope: "device",
44036
+ addonId: null,
44037
+ access: "delete"
44038
+ },
40807
44039
  "pipelineAnalytics.deleteTracks": {
40808
44040
  capName: "pipeline-analytics",
40809
44041
  capScope: "device",
@@ -41008,6 +44240,30 @@ Object.freeze({
41008
44240
  addonId: null,
41009
44241
  access: "view"
41010
44242
  },
44243
+ "pipelineAnalytics.listRetrainAssistProfiles": {
44244
+ capName: "pipeline-analytics",
44245
+ capScope: "device",
44246
+ addonId: null,
44247
+ access: "view"
44248
+ },
44249
+ "pipelineAnalytics.listRetrainCollectionFrames": {
44250
+ capName: "pipeline-analytics",
44251
+ capScope: "device",
44252
+ addonId: null,
44253
+ access: "view"
44254
+ },
44255
+ "pipelineAnalytics.listRetrainCollections": {
44256
+ capName: "pipeline-analytics",
44257
+ capScope: "device",
44258
+ addonId: null,
44259
+ access: "view"
44260
+ },
44261
+ "pipelineAnalytics.listRetrainDatasetVersions": {
44262
+ capName: "pipeline-analytics",
44263
+ capScope: "device",
44264
+ addonId: null,
44265
+ access: "view"
44266
+ },
41011
44267
  "pipelineAnalytics.listRetrainFrames": {
41012
44268
  capName: "pipeline-analytics",
41013
44269
  capScope: "device",
@@ -41038,6 +44294,12 @@ Object.freeze({
41038
44294
  addonId: null,
41039
44295
  access: "view"
41040
44296
  },
44297
+ "pipelineAnalytics.offerRetrainArchive": {
44298
+ capName: "pipeline-analytics",
44299
+ capScope: "device",
44300
+ addonId: null,
44301
+ access: "create"
44302
+ },
41041
44303
  "pipelineAnalytics.ownersWithMedia": {
41042
44304
  capName: "pipeline-analytics",
41043
44305
  capScope: "device",
@@ -41050,12 +44312,24 @@ Object.freeze({
41050
44312
  addonId: null,
41051
44313
  access: "create"
41052
44314
  },
44315
+ "pipelineAnalytics.previewRetrainDataset": {
44316
+ capName: "pipeline-analytics",
44317
+ capScope: "device",
44318
+ addonId: null,
44319
+ access: "view"
44320
+ },
41053
44321
  "pipelineAnalytics.proposeRetrainAnnotations": {
41054
44322
  capName: "pipeline-analytics",
41055
44323
  capScope: "device",
41056
44324
  addonId: null,
41057
44325
  access: "create"
41058
44326
  },
44327
+ "pipelineAnalytics.proposeRetrainAnnotationsWithLlm": {
44328
+ capName: "pipeline-analytics",
44329
+ capScope: "device",
44330
+ addonId: null,
44331
+ access: "create"
44332
+ },
41059
44333
  "pipelineAnalytics.pruneEvents": {
41060
44334
  capName: "pipeline-analytics",
41061
44335
  capScope: "device",
@@ -41110,6 +44384,18 @@ Object.freeze({
41110
44384
  addonId: null,
41111
44385
  access: "create"
41112
44386
  },
44387
+ "pipelineAnalytics.removeRetrainFrameFromCollection": {
44388
+ capName: "pipeline-analytics",
44389
+ capScope: "device",
44390
+ addonId: null,
44391
+ access: "delete"
44392
+ },
44393
+ "pipelineAnalytics.renameRetrainCollection": {
44394
+ capName: "pipeline-analytics",
44395
+ capScope: "device",
44396
+ addonId: null,
44397
+ access: "create"
44398
+ },
41113
44399
  "pipelineAnalytics.restageRetrainTrack": {
41114
44400
  capName: "pipeline-analytics",
41115
44401
  capScope: "device",
@@ -41140,6 +44426,12 @@ Object.freeze({
41140
44426
  addonId: null,
41141
44427
  access: "create"
41142
44428
  },
44429
+ "pipelineAnalytics.setRetrainFrameComplete": {
44430
+ capName: "pipeline-analytics",
44431
+ capScope: "device",
44432
+ addonId: null,
44433
+ access: "create"
44434
+ },
41143
44435
  "pipelineAnalytics.setTrackFlags": {
41144
44436
  capName: "pipeline-analytics",
41145
44437
  capScope: "device",
@@ -41164,6 +44456,12 @@ Object.freeze({
41164
44456
  addonId: null,
41165
44457
  access: "create"
41166
44458
  },
44459
+ "pipelineAnalytics.verifyRetrainDatasetVersion": {
44460
+ capName: "pipeline-analytics",
44461
+ capScope: "device",
44462
+ addonId: null,
44463
+ access: "view"
44464
+ },
41167
44465
  "pipelineAnalytics.wipeAllAnalytics": {
41168
44466
  capName: "pipeline-analytics",
41169
44467
  capScope: "device",
@@ -41176,6 +44474,12 @@ Object.freeze({
41176
44474
  addonId: null,
41177
44475
  access: "delete"
41178
44476
  },
44477
+ "pipelineAnalytics.writeRetrainArchive": {
44478
+ capName: "pipeline-analytics",
44479
+ capScope: "device",
44480
+ addonId: null,
44481
+ access: "create"
44482
+ },
41179
44483
  "pipelineExecutor.cacheFrameInPool": {
41180
44484
  capName: "pipeline-executor",
41181
44485
  capScope: "system",
@@ -41386,6 +44690,12 @@ Object.freeze({
41386
44690
  addonId: null,
41387
44691
  access: "view"
41388
44692
  },
44693
+ "pipelineOrchestrator.abortNodeBenchmark": {
44694
+ capName: "pipeline-orchestrator",
44695
+ capScope: "system",
44696
+ addonId: null,
44697
+ access: "create"
44698
+ },
41389
44699
  "pipelineOrchestrator.applyAutoTune": {
41390
44700
  capName: "pipeline-orchestrator",
41391
44701
  capScope: "system",
@@ -41410,6 +44720,12 @@ Object.freeze({
41410
44720
  addonId: null,
41411
44721
  access: "create"
41412
44722
  },
44723
+ "pipelineOrchestrator.deleteNodeBenchmarkResult": {
44724
+ capName: "pipeline-orchestrator",
44725
+ capScope: "system",
44726
+ addonId: null,
44727
+ access: "delete"
44728
+ },
41413
44729
  "pipelineOrchestrator.getAgentLoad": {
41414
44730
  capName: "pipeline-orchestrator",
41415
44731
  capScope: "system",
@@ -41518,6 +44834,24 @@ Object.freeze({
41518
44834
  addonId: null,
41519
44835
  access: "view"
41520
44836
  },
44837
+ "pipelineOrchestrator.getNodeBenchmarkCandidates": {
44838
+ capName: "pipeline-orchestrator",
44839
+ capScope: "system",
44840
+ addonId: null,
44841
+ access: "view"
44842
+ },
44843
+ "pipelineOrchestrator.getNodeBenchmarkPreflight": {
44844
+ capName: "pipeline-orchestrator",
44845
+ capScope: "system",
44846
+ addonId: null,
44847
+ access: "view"
44848
+ },
44849
+ "pipelineOrchestrator.getNodeBenchmarkStatus": {
44850
+ capName: "pipeline-orchestrator",
44851
+ capScope: "system",
44852
+ addonId: null,
44853
+ access: "view"
44854
+ },
41521
44855
  "pipelineOrchestrator.getNodeInferenceDevices": {
41522
44856
  capName: "pipeline-orchestrator",
41523
44857
  capScope: "system",
@@ -41560,6 +44894,12 @@ Object.freeze({
41560
44894
  addonId: null,
41561
44895
  access: "view"
41562
44896
  },
44897
+ "pipelineOrchestrator.listNodeBenchmarkResults": {
44898
+ capName: "pipeline-orchestrator",
44899
+ capScope: "system",
44900
+ addonId: null,
44901
+ access: "view"
44902
+ },
41563
44903
  "pipelineOrchestrator.pauseForStorageMigration": {
41564
44904
  capName: "pipeline-orchestrator",
41565
44905
  capScope: "system",
@@ -41704,6 +45044,12 @@ Object.freeze({
41704
45044
  addonId: null,
41705
45045
  access: "create"
41706
45046
  },
45047
+ "pipelineOrchestrator.startNodeBenchmark": {
45048
+ capName: "pipeline-orchestrator",
45049
+ capScope: "system",
45050
+ addonId: null,
45051
+ access: "create"
45052
+ },
41707
45053
  "pipelineOrchestrator.suggestShares": {
41708
45054
  capName: "pipeline-orchestrator",
41709
45055
  capScope: "system",
@@ -41722,6 +45068,12 @@ Object.freeze({
41722
45068
  addonId: null,
41723
45069
  access: "create"
41724
45070
  },
45071
+ "pipelineRunner.abortNodeBench": {
45072
+ capName: "pipeline-runner",
45073
+ capScope: "system",
45074
+ addonId: null,
45075
+ access: "create"
45076
+ },
41725
45077
  "pipelineRunner.attachCamera": {
41726
45078
  capName: "pipeline-runner",
41727
45079
  capScope: "system",
@@ -41770,6 +45122,12 @@ Object.freeze({
41770
45122
  addonId: null,
41771
45123
  access: "view"
41772
45124
  },
45125
+ "pipelineRunner.getNodeBenchStatus": {
45126
+ capName: "pipeline-runner",
45127
+ capScope: "system",
45128
+ addonId: null,
45129
+ access: "view"
45130
+ },
41773
45131
  "pipelineRunner.getParkedTrackFrame": {
41774
45132
  capName: "pipeline-runner",
41775
45133
  capScope: "system",
@@ -41812,6 +45170,12 @@ Object.freeze({
41812
45170
  addonId: null,
41813
45171
  access: "create"
41814
45172
  },
45173
+ "pipelineRunner.startNodeBench": {
45174
+ capName: "pipeline-runner",
45175
+ capScope: "system",
45176
+ addonId: null,
45177
+ access: "create"
45178
+ },
41815
45179
  "plateGallery.assignPlate": {
41816
45180
  capName: "plate-gallery",
41817
45181
  capScope: "system",
@@ -43474,6 +46838,174 @@ Object.freeze({
43474
46838
  addonId: null,
43475
46839
  access: "view"
43476
46840
  },
46841
+ "training.canaryResult": {
46842
+ capName: "training",
46843
+ capScope: "system",
46844
+ addonId: null,
46845
+ access: "create"
46846
+ },
46847
+ "training.cancelJob": {
46848
+ capName: "training",
46849
+ capScope: "system",
46850
+ addonId: null,
46851
+ access: "create"
46852
+ },
46853
+ "training.discardResult": {
46854
+ capName: "training",
46855
+ capScope: "system",
46856
+ addonId: null,
46857
+ access: "create"
46858
+ },
46859
+ "training.findDatasetVersionIdByName": {
46860
+ capName: "training",
46861
+ capScope: "system",
46862
+ addonId: null,
46863
+ access: "view"
46864
+ },
46865
+ "training.getDatasetVersion": {
46866
+ capName: "training",
46867
+ capScope: "system",
46868
+ addonId: null,
46869
+ access: "view"
46870
+ },
46871
+ "training.getJob": {
46872
+ capName: "training",
46873
+ capScope: "system",
46874
+ addonId: null,
46875
+ access: "view"
46876
+ },
46877
+ "training.getJobResult": {
46878
+ capName: "training",
46879
+ capScope: "system",
46880
+ addonId: null,
46881
+ access: "view"
46882
+ },
46883
+ "training.listBaseModels": {
46884
+ capName: "training",
46885
+ capScope: "system",
46886
+ addonId: null,
46887
+ access: "view"
46888
+ },
46889
+ "training.listDatasetVersions": {
46890
+ capName: "training",
46891
+ capScope: "system",
46892
+ addonId: null,
46893
+ access: "view"
46894
+ },
46895
+ "training.listJobs": {
46896
+ capName: "training",
46897
+ capScope: "system",
46898
+ addonId: null,
46899
+ access: "view"
46900
+ },
46901
+ "training.planJob": {
46902
+ capName: "training",
46903
+ capScope: "system",
46904
+ addonId: null,
46905
+ access: "view"
46906
+ },
46907
+ "training.putDatasetVersion": {
46908
+ capName: "training",
46909
+ capScope: "system",
46910
+ addonId: null,
46911
+ access: "create"
46912
+ },
46913
+ "training.registerResult": {
46914
+ capName: "training",
46915
+ capScope: "system",
46916
+ addonId: null,
46917
+ access: "create"
46918
+ },
46919
+ "training.removeDatasetVersion": {
46920
+ capName: "training",
46921
+ capScope: "system",
46922
+ addonId: null,
46923
+ access: "delete"
46924
+ },
46925
+ "training.rollbackCanary": {
46926
+ capName: "training",
46927
+ capScope: "system",
46928
+ addonId: null,
46929
+ access: "create"
46930
+ },
46931
+ "training.startJob": {
46932
+ capName: "training",
46933
+ capScope: "system",
46934
+ addonId: null,
46935
+ access: "create"
46936
+ },
46937
+ "trainingProvider.cancelJob": {
46938
+ capName: "training-provider",
46939
+ capScope: "system",
46940
+ addonId: null,
46941
+ access: "create"
46942
+ },
46943
+ "trainingProvider.cleanupJob": {
46944
+ capName: "training-provider",
46945
+ capScope: "system",
46946
+ addonId: null,
46947
+ access: "create"
46948
+ },
46949
+ "trainingProvider.describe": {
46950
+ capName: "training-provider",
46951
+ capScope: "system",
46952
+ addonId: null,
46953
+ access: "view"
46954
+ },
46955
+ "trainingProvider.estimateJob": {
46956
+ capName: "training-provider",
46957
+ capScope: "system",
46958
+ addonId: null,
46959
+ access: "view"
46960
+ },
46961
+ "trainingProvider.getJob": {
46962
+ capName: "training-provider",
46963
+ capScope: "system",
46964
+ addonId: null,
46965
+ access: "view"
46966
+ },
46967
+ "trainingProvider.listJobEvents": {
46968
+ capName: "training-provider",
46969
+ capScope: "system",
46970
+ addonId: null,
46971
+ access: "view"
46972
+ },
46973
+ "trainingProvider.listJobs": {
46974
+ capName: "training-provider",
46975
+ capScope: "system",
46976
+ addonId: null,
46977
+ access: "view"
46978
+ },
46979
+ "trainingProvider.offerArtifact": {
46980
+ capName: "training-provider",
46981
+ capScope: "system",
46982
+ addonId: null,
46983
+ access: "create"
46984
+ },
46985
+ "trainingProvider.readResult": {
46986
+ capName: "training-provider",
46987
+ capScope: "system",
46988
+ addonId: null,
46989
+ access: "create"
46990
+ },
46991
+ "trainingProvider.submitJob": {
46992
+ capName: "training-provider",
46993
+ capScope: "system",
46994
+ addonId: null,
46995
+ access: "create"
46996
+ },
46997
+ "trainingProvider.uploadDataset": {
46998
+ capName: "training-provider",
46999
+ capScope: "system",
47000
+ addonId: null,
47001
+ access: "create"
47002
+ },
47003
+ "trainingProvider.validateCredentials": {
47004
+ capName: "training-provider",
47005
+ capScope: "system",
47006
+ addonId: null,
47007
+ access: "create"
47008
+ },
43477
47009
  "turnProvider.getTurnServers": {
43478
47010
  capName: "turn-provider",
43479
47011
  capScope: "system",
@@ -43498,12 +47030,6 @@ Object.freeze({
43498
47030
  addonId: null,
43499
47031
  access: "create"
43500
47032
  },
43501
- "userManagement.createApiKey": {
43502
- capName: "user-management",
43503
- capScope: "system",
43504
- addonId: null,
43505
- access: "create"
43506
- },
43507
47033
  "userManagement.createScopedToken": {
43508
47034
  capName: "user-management",
43509
47035
  capScope: "system",
@@ -43528,6 +47054,12 @@ Object.freeze({
43528
47054
  addonId: null,
43529
47055
  access: "delete"
43530
47056
  },
47057
+ "userManagement.findUserByExternalIdentity": {
47058
+ capName: "user-management",
47059
+ capScope: "system",
47060
+ addonId: null,
47061
+ access: "view"
47062
+ },
43531
47063
  "userManagement.getTotpStatus": {
43532
47064
  capName: "user-management",
43533
47065
  capScope: "system",
@@ -43540,6 +47072,12 @@ Object.freeze({
43540
47072
  addonId: null,
43541
47073
  access: "view"
43542
47074
  },
47075
+ "userManagement.listExternalIdentities": {
47076
+ capName: "user-management",
47077
+ capScope: "system",
47078
+ addonId: null,
47079
+ access: "view"
47080
+ },
43543
47081
  "userManagement.listOauthSessions": {
43544
47082
  capName: "user-management",
43545
47083
  capScope: "system",
@@ -43618,17 +47156,17 @@ Object.freeze({
43618
47156
  addonId: null,
43619
47157
  access: "create"
43620
47158
  },
43621
- "userManagement.updateUser": {
47159
+ "userManagement.unlinkExternalIdentity": {
43622
47160
  capName: "user-management",
43623
47161
  capScope: "system",
43624
47162
  addonId: null,
43625
- access: "create"
47163
+ access: "delete"
43626
47164
  },
43627
- "userManagement.validateApiKey": {
47165
+ "userManagement.updateUser": {
43628
47166
  capName: "user-management",
43629
47167
  capScope: "system",
43630
47168
  addonId: null,
43631
- access: "view"
47169
+ access: "create"
43632
47170
  },
43633
47171
  "userManagement.validateCredentials": {
43634
47172
  capName: "user-management",
@@ -46717,6 +50255,11 @@ Object.freeze({
46717
50255
  form: "single",
46718
50256
  optional: false
46719
50257
  }],
50258
+ "pipelineAnalytics.addRetrainFrameFromRecording": [{
50259
+ name: "deviceId",
50260
+ form: "single",
50261
+ optional: false
50262
+ }],
46720
50263
  "pipelineAnalytics.applyDeviceSettingsPatch": [{
46721
50264
  name: "deviceId",
46722
50265
  form: "single",
@@ -46907,6 +50450,11 @@ Object.freeze({
46907
50450
  form: "single",
46908
50451
  optional: false
46909
50452
  }],
50453
+ "pipelineAnalytics.proposeRetrainAnnotationsWithLlm": [{
50454
+ name: "deviceId",
50455
+ form: "single",
50456
+ optional: false
50457
+ }],
46910
50458
  "pipelineAnalytics.pruneEventsBefore": [{
46911
50459
  name: "deviceId",
46912
50460
  form: "single",
@@ -46957,6 +50505,11 @@ Object.freeze({
46957
50505
  form: "single",
46958
50506
  optional: false
46959
50507
  }],
50508
+ "pipelineAnalytics.setRetrainFrameComplete": [{
50509
+ name: "deviceId",
50510
+ form: "single",
50511
+ optional: false
50512
+ }],
46960
50513
  "pipelineAnalytics.setTrackFlags": [{
46961
50514
  name: "deviceId",
46962
50515
  form: "single",
@@ -47728,6 +51281,11 @@ Object.freeze({
47728
51281
  form: "single",
47729
51282
  optional: false
47730
51283
  }],
51284
+ "training.canaryResult": [{
51285
+ name: "deviceIds",
51286
+ form: "array",
51287
+ optional: false
51288
+ }],
47731
51289
  "update.getStatus": [{
47732
51290
  name: "deviceId",
47733
51291
  form: "single",