@camstack/addon-provider-dreo 0.2.122 → 0.2.124

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/dist/addon.js +3555 -126
  2. package/dist/addon.mjs +3555 -126
  3. package/package.json +1 -1
package/dist/addon.js CHANGED
@@ -35,7 +35,7 @@ var __toCommonJS = (mod) => __hasOwnProp.call(mod, "module.exports") ? mod["modu
35
35
  //#endregion
36
36
  let crypto$1 = require("crypto");
37
37
  let events = require("events");
38
- //#region ../types/dist/event-category-B_0XEcLF.mjs
38
+ //#region ../types/dist/event-category-DaIZi00R.mjs
39
39
  var EventCategory = /* @__PURE__ */ function(EventCategory) {
40
40
  EventCategory["SystemBoot"] = "system.boot";
41
41
  EventCategory["SystemAddonsReady"] = "system.addons-ready";
@@ -114,6 +114,13 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
114
114
  */
115
115
  EventCategory["AddonLoadFailed"] = "addon.load-failed";
116
116
  /**
117
+ * A keychain value was stored or removed (D787). Carries the ref, its
118
+ * owner and the new version — NEVER the value. A process holding the ref
119
+ * drops its cached copy and the owning `BaseAddon` re-resolves its config.
120
+ * Telemetry (D8): a process that misses it still revalidates by version.
121
+ */
122
+ EventCategory["KeychainChanged"] = "keychain.changed";
123
+ /**
117
124
  * Addon recovered from a previous failure. Emitted when an addon
118
125
  * transitions from `failed` back to `healthy` (typically via the
119
126
  * monitor's auto-retry loop, or after manual `addons.retryLoad`).
@@ -5406,7 +5413,7 @@ var ZodIssueCode = {
5406
5413
  var ZodFirstPartyTypeKind;
5407
5414
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
5408
5415
  //#endregion
5409
- //#region ../types/dist/sleep-B0JG7-_F.mjs
5416
+ //#region ../types/dist/sleep-r3RWkGVx.mjs
5410
5417
  /**
5411
5418
  * The audio chunk plane's byte format, and the ONE expansion from a coded
5412
5419
  * window to float samples (D455).
@@ -5485,6 +5492,97 @@ function buildAlawTable() {
5485
5492
  }
5486
5493
  buildUlawTable();
5487
5494
  buildAlawTable();
5495
+ /** Is this field's stored value a credential? */
5496
+ function isSecretConfigField(field) {
5497
+ if (field.type === "password") return true;
5498
+ return "secret" in field && field.secret === true;
5499
+ }
5500
+ /**
5501
+ * Is this field's value stored in the KEYCHAIN (D787)? Every secret field is,
5502
+ * by its TYPE, unless it opts out with `storage: 'inline'` — never by its name.
5503
+ */
5504
+ function isKeychainStoredField(field) {
5505
+ if (!isSecretConfigField(field)) return false;
5506
+ if (field.type === "textarea" && field.isJson === true) return false;
5507
+ return !("storage" in field && field.storage === "inline");
5508
+ }
5509
+ /**
5510
+ * What a settings blob holds where a secret used to be.
5511
+ *
5512
+ * A keychain-stored field never holds its value. It holds a self-describing
5513
+ * MARKER, `{"$secret":"secret://…","v":1}` — an object, never a string, so no
5514
+ * code can mistake it for a credential and no form can send it to a camera as
5515
+ * a password. The empty state is `null` / absent, never `''`.
5516
+ *
5517
+ * The same shapes travel to and from the admin UI:
5518
+ *
5519
+ * - read: `hydrateSchema` hands a secret field a {@link SecretFieldView}
5520
+ * (`{ $secret, v, set: true }`) or `null` — the browser learns whether a
5521
+ * value is set, never the value.
5522
+ * - write: an untouched field submits the view back unchanged (KEEP); a typed
5523
+ * value is a plain non-empty string (CHANGE); the Clear button submits
5524
+ * {@link SECRET_CLEAR} (CLEAR). `''`, `null` and the legacy redaction tokens
5525
+ * are KEEP — an empty string is what a defaults-fallback pushes back, and
5526
+ * treating it as "clear" is how a save destroyed a stored credential before.
5527
+ *
5528
+ * Pure and browser-safe.
5529
+ */
5530
+ var SECRET_CLEAR = { $secretClear: true };
5531
+ /** The `'***'` token D634 redaction writes for non-admins. */
5532
+ var LEGACY_DEVICE_REDACTION = "***";
5533
+ function isRecord$2(value) {
5534
+ return typeof value === "object" && value !== null && !Array.isArray(value);
5535
+ }
5536
+ function makeSecretMarker(ref) {
5537
+ return {
5538
+ $secret: ref,
5539
+ v: 1
5540
+ };
5541
+ }
5542
+ /** A stored marker: an object whose `$secret` is a non-empty string. */
5543
+ function isSecretMarker(value) {
5544
+ if (!isRecord$2(value)) return false;
5545
+ const ref = value["$secret"];
5546
+ return typeof ref === "string" && ref.length > 0;
5547
+ }
5548
+ function isSecretClear(value) {
5549
+ return isRecord$2(value) && value["$secretClear"] === true;
5550
+ }
5551
+ /**
5552
+ * The UI view of a stored secret field value: a marker becomes "set", inline
5553
+ * plaintext becomes "set (inline)", nothing becomes `null`. A value never
5554
+ * survives this function.
5555
+ */
5556
+ function toSecretFieldView(stored) {
5557
+ if (isSecretMarker(stored)) return {
5558
+ $secret: stored.$secret,
5559
+ v: 1,
5560
+ set: true
5561
+ };
5562
+ if (typeof stored === "string" && stored.length > 0) return {
5563
+ $secret: null,
5564
+ v: 1,
5565
+ set: true,
5566
+ inline: true
5567
+ };
5568
+ return null;
5569
+ }
5570
+ /**
5571
+ * Classify an incoming value for a secret path. Only a non-empty string that is
5572
+ * not a redaction token sets a value; only {@link SECRET_CLEAR} clears.
5573
+ * Everything else — a marker (ours or anyone's), a UI view, `''`, `null`,
5574
+ * `undefined`, a redaction token, a non-string — keeps what is stored.
5575
+ */
5576
+ function classifySecretWrite(incoming) {
5577
+ if (isSecretClear(incoming)) return { kind: "clear" };
5578
+ if (typeof incoming !== "string") return { kind: "keep" };
5579
+ if (incoming.length === 0) return { kind: "keep" };
5580
+ if (incoming === "__camstack_redacted__" || incoming === LEGACY_DEVICE_REDACTION) return { kind: "keep" };
5581
+ return {
5582
+ kind: "set",
5583
+ value: incoming
5584
+ };
5585
+ }
5488
5586
  Object.fromEntries([
5489
5587
  {
5490
5588
  id: "overview",
@@ -5656,33 +5754,19 @@ Object.fromEntries([
5656
5754
  function isValuelessField(field) {
5657
5755
  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";
5658
5756
  }
5659
- /**
5660
- * Merge a `ConfigUISchema` with a raw `values` record into a
5661
- * `ConfigUISchemaWithValues`. Used by every `get*Settings` backend endpoint
5662
- * before returning to the admin UI. Groups are walked recursively.
5663
- *
5664
- * For each leaf field:
5665
- * - structural fields (`separator`, `info`, `button`) pass through unchanged
5666
- * - other fields get `value = values[key] ?? field.default ?? null`
5667
- *
5668
- * Unknown keys in `values` (keys not declared in the schema) are silently
5669
- * ignored — they don't contribute to the output. Missing keys fall back to
5670
- * the schema default or `null`. This mirrors the old backend behaviour where
5671
- * `FormBuilder` rendered `values[key] ?? field.default`.
5672
- */
5673
- function hydrateSchema(schema, values) {
5757
+ function hydrateSchema(schema, values, options = {}) {
5674
5758
  return {
5675
5759
  ...schema.tabs ? { tabs: [...schema.tabs] } : {},
5676
5760
  sections: schema.sections.map((section) => ({
5677
5761
  ...section,
5678
- fields: section.fields.map((field) => hydrateField(field, values))
5762
+ fields: section.fields.map((field) => hydrateField(field, values, options))
5679
5763
  }))
5680
5764
  };
5681
5765
  }
5682
- function hydrateField(field, values) {
5766
+ function hydrateField(field, values, options) {
5683
5767
  if (isValuelessField(field)) return field;
5684
5768
  if (field.type === "group") {
5685
- const hydratedChildren = field.fields.map((child) => hydrateField(child, values));
5769
+ const hydratedChildren = field.fields.map((child) => hydrateField(child, values, options));
5686
5770
  return {
5687
5771
  ...field,
5688
5772
  fields: hydratedChildren
@@ -5691,7 +5775,7 @@ function hydrateField(field, values) {
5691
5775
  if (field.type === "sub-tabs") {
5692
5776
  const hydratedTabs = field.tabs.map((tab) => ({
5693
5777
  ...tab,
5694
- fields: tab.fields.map((child) => hydrateField(child, values))
5778
+ fields: tab.fields.map((child) => hydrateField(child, values, options))
5695
5779
  }));
5696
5780
  return {
5697
5781
  ...field,
@@ -5701,6 +5785,33 @@ function hydrateField(field, values) {
5701
5785
  const key = field.key;
5702
5786
  const storedValue = Object.prototype.hasOwnProperty.call(values, key) ? values[key] : void 0;
5703
5787
  const defaultValue = field.default;
5788
+ const asView = (v) => isSecretMarker(v) || options.inlineSecretsAsViews === true && v !== void 0;
5789
+ if (isKeychainStoredField(field) && asView(storedValue)) return {
5790
+ ...field,
5791
+ value: toSecretFieldView(storedValue)
5792
+ };
5793
+ if (isKeychainStoredField(field) && options.inlineSecretsAsViews === true) return {
5794
+ ...field,
5795
+ value: null
5796
+ };
5797
+ if (field.type === "editable-array" && Array.isArray(storedValue)) {
5798
+ const secretItemKeys = field.itemFields.filter((item) => "key" in item && isKeychainStoredField(item)).map((item) => "key" in item ? item.key : "");
5799
+ if (secretItemKeys.length > 0) {
5800
+ const rows = storedValue.map((row) => {
5801
+ if (row === null || typeof row !== "object" || Array.isArray(row)) return row;
5802
+ const out = { ...row };
5803
+ for (const k of secretItemKeys) {
5804
+ const v = Reflect.get(row, k);
5805
+ if (asView(v)) out[k] = toSecretFieldView(v);
5806
+ }
5807
+ return out;
5808
+ });
5809
+ return {
5810
+ ...field,
5811
+ value: rows
5812
+ };
5813
+ }
5814
+ }
5704
5815
  if (field.multiple) {
5705
5816
  const stored = Array.isArray(storedValue) ? storedValue : storedValue !== void 0 && storedValue !== null ? [storedValue] : [];
5706
5817
  const itemFallback = field.multiple.itemDefault !== void 0 ? field.multiple.itemDefault : defaultValue !== void 0 ? defaultValue : typeOf(field) === "string" ? "" : null;
@@ -5943,6 +6054,778 @@ function projectStore(store, perNodeKeys, nodeId) {
5943
6054
  }
5944
6055
  return out;
5945
6056
  }
6057
+ var GLOBAL_SCOPE = { kind: "global" };
6058
+ /** The scope every addon-wide (not per-node, not per-device) setting lives in. */
6059
+ function globalSecretScope() {
6060
+ return GLOBAL_SCOPE;
6061
+ }
6062
+ function encodeSegment(value) {
6063
+ return encodeURIComponent(value);
6064
+ }
6065
+ function decodeSegment(value) {
6066
+ try {
6067
+ return decodeURIComponent(value);
6068
+ } catch {
6069
+ return null;
6070
+ }
6071
+ }
6072
+ /**
6073
+ * The field path of a value inside an array item, addressed by the item's id:
6074
+ * `arrayItemFieldPath('providers', 'authentik', 'clientSecret')` →
6075
+ * `providers[authentik].clientSecret`.
6076
+ */
6077
+ function arrayItemFieldPath(arrayKey, itemId, fieldKey) {
6078
+ return `${arrayKey}[${encodeSegment(itemId)}].${fieldKey}`;
6079
+ }
6080
+ function parseScope(segments) {
6081
+ switch (segments[0]) {
6082
+ case "global": return {
6083
+ scope: GLOBAL_SCOPE,
6084
+ used: 1
6085
+ };
6086
+ case "node": {
6087
+ const nodeId = segments[1] !== void 0 ? decodeSegment(segments[1]) : null;
6088
+ return nodeId === null || nodeId.length === 0 ? null : {
6089
+ scope: {
6090
+ kind: "node",
6091
+ nodeId
6092
+ },
6093
+ used: 2
6094
+ };
6095
+ }
6096
+ case "device": {
6097
+ const raw = segments[1];
6098
+ if (raw === void 0 || !/^\d+$/.test(raw)) return null;
6099
+ return {
6100
+ scope: {
6101
+ kind: "device",
6102
+ deviceId: Number(raw)
6103
+ },
6104
+ used: 2
6105
+ };
6106
+ }
6107
+ case "integration": {
6108
+ const id = segments[1] !== void 0 ? decodeSegment(segments[1]) : null;
6109
+ return id === null || id.length === 0 ? null : {
6110
+ scope: {
6111
+ kind: "integration",
6112
+ integrationId: id
6113
+ },
6114
+ used: 2
6115
+ };
6116
+ }
6117
+ case "row": {
6118
+ const collection = segments[1] !== void 0 ? decodeSegment(segments[1]) : null;
6119
+ const rowId = segments[2] !== void 0 ? decodeSegment(segments[2]) : null;
6120
+ if (collection === null || rowId === null || collection.length === 0 || rowId.length === 0) return null;
6121
+ return {
6122
+ scope: {
6123
+ kind: "row",
6124
+ collection,
6125
+ rowId
6126
+ },
6127
+ used: 3
6128
+ };
6129
+ }
6130
+ default: return null;
6131
+ }
6132
+ }
6133
+ /** Take a ref apart; `null` when it is not a well-formed ref. */
6134
+ function parseSecretRef(ref) {
6135
+ if (!ref.startsWith("secret://")) return null;
6136
+ const segments = ref.slice(9).split("/");
6137
+ const owner = segments[0] !== void 0 ? decodeSegment(segments[0]) : null;
6138
+ if (owner === null || owner.length === 0) return null;
6139
+ const parsed = parseScope(segments.slice(1));
6140
+ if (parsed === null) return null;
6141
+ const fieldPath = segments.slice(1 + parsed.used).join("/");
6142
+ if (fieldPath.length === 0) return null;
6143
+ return {
6144
+ owner,
6145
+ scope: parsed.scope,
6146
+ fieldPath
6147
+ };
6148
+ }
6149
+ /** A write to a secret path could not be stored in the keychain, so it was refused. */
6150
+ var KeychainWriteRefusedError = class extends Error {
6151
+ fieldPath;
6152
+ constructor(fieldPath, cause) {
6153
+ super(`secret "${fieldPath}" was not saved: the keychain could not store it (${cause instanceof Error ? cause.message : String(cause)}). Nothing was written.`);
6154
+ this.fieldPath = fieldPath;
6155
+ this.name = "KeychainWriteRefusedError";
6156
+ }
6157
+ };
6158
+ var KEEP = { kind: "keep" };
6159
+ function isRecord$1(value) {
6160
+ return typeof value === "object" && value !== null && !Array.isArray(value);
6161
+ }
6162
+ function defaultMintId() {
6163
+ return globalThis.crypto.randomUUID();
6164
+ }
6165
+ /** Every marker ref anywhere under `value`. */
6166
+ function collectSecretMarkerRefs(value, out = []) {
6167
+ if (isSecretMarker(value)) {
6168
+ out.push(value.$secret);
6169
+ return out;
6170
+ }
6171
+ if (Array.isArray(value)) for (const item of value) collectSecretMarkerRefs(item, out);
6172
+ else if (isRecord$1(value)) for (const child of Object.values(value)) collectSecretMarkerRefs(child, out);
6173
+ return out;
6174
+ }
6175
+ async function storedValueEquals(secrets, marker, candidate) {
6176
+ const resolved = (await secrets.resolve([marker.$secret]))[marker.$secret];
6177
+ return resolved?.kind === "value" && resolved.value === candidate;
6178
+ }
6179
+ async function writeLeaf(ctx, incoming, stored, fieldPath) {
6180
+ const intent = classifySecretWrite(incoming);
6181
+ const ref = ctx.secrets.ref(ctx.scope, fieldPath);
6182
+ const storedIsOurs = isSecretMarker(stored) && stored.$secret === ref;
6183
+ if (intent.kind === "keep") return KEEP;
6184
+ if (intent.kind === "set" && !ctx.operatorWrite && typeof stored === "string" && stored === intent.value) return KEEP;
6185
+ if (intent.kind === "clear") {
6186
+ if (storedIsOurs) ctx.deletes.push(ref);
6187
+ return {
6188
+ kind: "value",
6189
+ value: null
6190
+ };
6191
+ }
6192
+ if (storedIsOurs && await storedValueEquals(ctx.secrets, stored, intent.value)) return {
6193
+ kind: "value",
6194
+ value: stored
6195
+ };
6196
+ try {
6197
+ await ctx.secrets.put(ref, intent.value);
6198
+ } catch (err) {
6199
+ throw new KeychainWriteRefusedError(fieldPath, err);
6200
+ }
6201
+ return {
6202
+ kind: "value",
6203
+ value: makeSecretMarker(ref)
6204
+ };
6205
+ }
6206
+ /** Apply a member result onto `out`: KEEP restores the stored member, or removes it. */
6207
+ function applyMember(out, key, result, storedParent) {
6208
+ if (result.kind === "value") {
6209
+ out[key] = result.value;
6210
+ return;
6211
+ }
6212
+ if (Object.prototype.hasOwnProperty.call(storedParent, key)) out[key] = storedParent[key];
6213
+ else delete out[key];
6214
+ }
6215
+ async function writeMembers(ctx, children, incoming, stored, pathOf) {
6216
+ const out = { ...incoming };
6217
+ for (const [member, node] of children) applyMember(out, member, await writeNode(ctx, node, incoming[member], stored[member], pathOf(member)), stored);
6218
+ return out;
6219
+ }
6220
+ function rowId(row, idKey) {
6221
+ const raw = row[idKey];
6222
+ if (typeof raw === "string" && raw.length > 0) return raw;
6223
+ if (typeof raw === "number" && Number.isFinite(raw)) return String(raw);
6224
+ return null;
6225
+ }
6226
+ async function writeArray(ctx, node, incoming, stored, fieldPath) {
6227
+ const storedRows = Array.isArray(stored) ? stored.filter(isRecord$1) : [];
6228
+ if (!Array.isArray(incoming)) {
6229
+ ctx.deletes.push(...collectSecretMarkerRefs(storedRows));
6230
+ return {
6231
+ kind: "value",
6232
+ value: incoming
6233
+ };
6234
+ }
6235
+ const storedById = /* @__PURE__ */ new Map();
6236
+ for (const row of storedRows) {
6237
+ const id = rowId(row, node.idKey);
6238
+ if (id !== null) storedById.set(id, row);
6239
+ }
6240
+ const kept = /* @__PURE__ */ new Set();
6241
+ const rows = [];
6242
+ for (const row of incoming) {
6243
+ if (!isRecord$1(row)) {
6244
+ rows.push(row);
6245
+ continue;
6246
+ }
6247
+ const id = rowId(row, node.idKey) ?? ctx.mintId();
6248
+ kept.add(id);
6249
+ const withId = {
6250
+ ...row,
6251
+ [node.idKey]: row[node.idKey] ?? id
6252
+ };
6253
+ if (rowId(withId, node.idKey) === null) withId[node.idKey] = id;
6254
+ const storedRow = storedById.get(id) ?? {};
6255
+ rows.push(await writeMembers(ctx, node.item, withId, storedRow, (member) => arrayItemFieldPath(fieldPath, id, member)));
6256
+ }
6257
+ for (const [id, row] of storedById) if (!kept.has(id)) ctx.deletes.push(...collectSecretMarkerRefs(row));
6258
+ return {
6259
+ kind: "value",
6260
+ value: rows
6261
+ };
6262
+ }
6263
+ async function writeNode(ctx, node, incoming, stored, fieldPath) {
6264
+ switch (node.kind) {
6265
+ case "leaf": return writeLeaf(ctx, incoming, stored, fieldPath);
6266
+ case "array": return writeArray(ctx, node, incoming, stored, fieldPath);
6267
+ case "object": {
6268
+ if (!isRecord$1(incoming)) {
6269
+ if (incoming === void 0) return KEEP;
6270
+ ctx.deletes.push(...collectSecretMarkerRefs(stored));
6271
+ return {
6272
+ kind: "value",
6273
+ value: incoming
6274
+ };
6275
+ }
6276
+ const storedObj = isRecord$1(stored) ? stored : {};
6277
+ return {
6278
+ kind: "value",
6279
+ value: await writeMembers(ctx, node.children, incoming, storedObj, (m) => `${fieldPath}.${m}`)
6280
+ };
6281
+ }
6282
+ }
6283
+ }
6284
+ /** Split a perNode-scoped key (`key@nodeId`). */
6285
+ function splitNodeKey(key) {
6286
+ const at = key.indexOf("@");
6287
+ return at <= 0 ? {
6288
+ base: key,
6289
+ nodeId: null
6290
+ } : {
6291
+ base: key.slice(0, at),
6292
+ nodeId: key.slice(at + 1)
6293
+ };
6294
+ }
6295
+ /** Rewrite a settings patch so no secret value reaches the blob. See the file doc. */
6296
+ async function transformSecretWrite(input) {
6297
+ const deletes = [];
6298
+ const base = {
6299
+ secrets: input.secrets,
6300
+ mintId: input.mintId ?? defaultMintId,
6301
+ deletes,
6302
+ operatorWrite: input.operatorWrite === true
6303
+ };
6304
+ const out = {};
6305
+ for (const [key, incoming] of Object.entries(input.patch)) {
6306
+ const { base: baseKey, nodeId } = splitNodeKey(key);
6307
+ const node = input.tree.get(baseKey);
6308
+ if (node === void 0) {
6309
+ out[key] = incoming;
6310
+ continue;
6311
+ }
6312
+ const scope = nodeId !== null && nodeId.length > 0 ? {
6313
+ kind: "node",
6314
+ nodeId
6315
+ } : input.scope ?? globalSecretScope();
6316
+ const result = await writeNode({
6317
+ ...base,
6318
+ scope
6319
+ }, node, incoming, input.stored[key], baseKey);
6320
+ if (result.kind === "value") out[key] = result.value;
6321
+ }
6322
+ return {
6323
+ patch: out,
6324
+ afterWrite: async () => {
6325
+ if (deletes.length === 0) return { orphaned: [] };
6326
+ try {
6327
+ await input.secrets.delete([...new Set(deletes)]);
6328
+ return { orphaned: [] };
6329
+ } catch {
6330
+ return { orphaned: [...new Set(deletes)] };
6331
+ }
6332
+ }
6333
+ };
6334
+ }
6335
+ /** Is `ref` one of `owner`'s refs? */
6336
+ function isSecretRefOwnedBy(ref, owner) {
6337
+ return parseSecretRef(ref)?.owner === owner;
6338
+ }
6339
+ /**
6340
+ * Replace every marker in `value` with its keychain value. Returns the SAME
6341
+ * reference when there is no marker (no allocation, no keychain call).
6342
+ */
6343
+ async function resolveSecretMarkers(value, secrets, options = {}) {
6344
+ const keepMarker = options.unresolved === "keep-marker";
6345
+ const owner = options.ownedBy;
6346
+ const inScope = (ref) => owner === void 0 || isSecretRefOwnedBy(ref, owner);
6347
+ const refs = collectSecretMarkerRefs(value).filter(inScope);
6348
+ if (refs.length === 0) return {
6349
+ value,
6350
+ unresolved: []
6351
+ };
6352
+ const answers = await secrets.resolve(refs);
6353
+ const unresolved = [];
6354
+ for (const ref of new Set(refs)) {
6355
+ const answer = answers[ref];
6356
+ if (answer === void 0) unresolved.push({
6357
+ ref,
6358
+ reason: "not-initialized"
6359
+ });
6360
+ else if (answer.kind === "unavailable") unresolved.push({
6361
+ ref,
6362
+ reason: answer.reason
6363
+ });
6364
+ else if (answer.kind === "missing" || answer.kind === "forbidden") unresolved.push({
6365
+ ref,
6366
+ reason: answer.kind
6367
+ });
6368
+ }
6369
+ const substitute = (v) => {
6370
+ if (isSecretMarker(v)) {
6371
+ if (!inScope(v.$secret)) return {
6372
+ keep: true,
6373
+ value: v
6374
+ };
6375
+ const answer = answers[v.$secret];
6376
+ if (answer?.kind === "value") return {
6377
+ keep: true,
6378
+ value: answer.value
6379
+ };
6380
+ return keepMarker ? {
6381
+ keep: true,
6382
+ value: v
6383
+ } : {
6384
+ keep: false,
6385
+ value: void 0
6386
+ };
6387
+ }
6388
+ if (Array.isArray(v)) {
6389
+ const items = [];
6390
+ for (const item of v) {
6391
+ const s = substitute(item);
6392
+ if (s.keep) items.push(s.value);
6393
+ }
6394
+ return {
6395
+ keep: true,
6396
+ value: items
6397
+ };
6398
+ }
6399
+ if (isRecord$1(v)) {
6400
+ const out = {};
6401
+ for (const [k, child] of Object.entries(v)) {
6402
+ const s = substitute(child);
6403
+ if (s.keep) out[k] = s.value;
6404
+ }
6405
+ return {
6406
+ keep: true,
6407
+ value: out
6408
+ };
6409
+ }
6410
+ return {
6411
+ keep: true,
6412
+ value: v
6413
+ };
6414
+ };
6415
+ return {
6416
+ value: substitute(value).value,
6417
+ unresolved
6418
+ };
6419
+ }
6420
+ /** An addon tried to replace a stored secret it could not read. Nothing was written. */
6421
+ var SecretOverwriteRefusedError = class extends Error {
6422
+ ref;
6423
+ reason;
6424
+ constructor(ref, reason) {
6425
+ 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.`);
6426
+ this.ref = ref;
6427
+ this.reason = reason;
6428
+ this.name = "SecretOverwriteRefusedError";
6429
+ }
6430
+ };
6431
+ function isRecord(value) {
6432
+ return typeof value === "object" && value !== null && !Array.isArray(value);
6433
+ }
6434
+ function resolvedValue(pass, marker) {
6435
+ const answer = pass.answers[marker.$secret];
6436
+ return answer?.kind === "value" ? answer.value : null;
6437
+ }
6438
+ async function atMarker(pass, incoming, stored) {
6439
+ if (incoming === null) return stored;
6440
+ if (typeof incoming !== "string") return incoming;
6441
+ if (incoming === resolvedValue(pass, stored)) return stored;
6442
+ const intent = classifySecretWrite(incoming);
6443
+ if (intent.kind !== "set") return stored;
6444
+ const ref = stored.$secret;
6445
+ if (!isSecretRefOwnedBy(ref, pass.secrets.owner)) return incoming;
6446
+ const answer = pass.answers[ref];
6447
+ 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);
6448
+ try {
6449
+ await pass.secrets.put(ref, intent.value);
6450
+ } catch (err) {
6451
+ throw new KeychainWriteRefusedError(ref, err);
6452
+ }
6453
+ pass.changedRefs.push(ref);
6454
+ return stored;
6455
+ }
6456
+ function inArray(pass, incoming, stored) {
6457
+ return incoming.map((item, index) => {
6458
+ const twin = stored[index];
6459
+ if (isSecretMarker(twin)) return typeof item === "string" && item === resolvedValue(pass, twin) ? twin : item;
6460
+ if (isRecord(item) && isRecord(twin)) return inArrayRow(pass, item, twin);
6461
+ if (Array.isArray(item) && Array.isArray(twin)) return inArray(pass, item, twin);
6462
+ return item;
6463
+ });
6464
+ }
6465
+ function inArrayRow(pass, incoming, stored) {
6466
+ const out = { ...incoming };
6467
+ for (const [key, value] of Object.entries(incoming)) {
6468
+ const twin = stored[key];
6469
+ if (isSecretMarker(twin)) {
6470
+ if (typeof value === "string" && value === resolvedValue(pass, twin)) out[key] = twin;
6471
+ } else if (isRecord(value) && isRecord(twin)) out[key] = inArrayRow(pass, value, twin);
6472
+ else if (Array.isArray(value) && Array.isArray(twin)) out[key] = inArray(pass, value, twin);
6473
+ }
6474
+ return out;
6475
+ }
6476
+ async function walk(pass, incoming, stored) {
6477
+ if (isSecretMarker(stored)) return atMarker(pass, incoming, stored);
6478
+ if (Array.isArray(incoming) && Array.isArray(stored)) return inArray(pass, incoming, stored);
6479
+ if (!isRecord(incoming) || !isRecord(stored)) return incoming;
6480
+ const out = { ...incoming };
6481
+ for (const [key, value] of Object.entries(incoming)) out[key] = await walk(pass, value, stored[key]);
6482
+ return out;
6483
+ }
6484
+ /** Restore markers a write-back carries as values. See the file doc. */
6485
+ async function restoreUnchangedSecrets(input) {
6486
+ const refs = [];
6487
+ for (const key of Object.keys(input.patch)) collectSecretMarkerRefs(input.stored[key], refs);
6488
+ const owned = refs.filter((ref) => isSecretRefOwnedBy(ref, input.secrets.owner));
6489
+ if (owned.length === 0) return {
6490
+ patch: input.patch,
6491
+ changedRefs: []
6492
+ };
6493
+ const pass = {
6494
+ secrets: input.secrets,
6495
+ answers: await input.secrets.resolve([...new Set(owned)]),
6496
+ operatorWrite: input.operatorWrite,
6497
+ changedRefs: []
6498
+ };
6499
+ const out = {};
6500
+ for (const [key, value] of Object.entries(input.patch)) out[key] = await walk(pass, value, input.stored[key]);
6501
+ return {
6502
+ patch: out,
6503
+ changedRefs: pass.changedRefs
6504
+ };
6505
+ }
6506
+ /** Structural equality over JSON-shaped values (key order does not matter). */
6507
+ function isJsonEqual(a, b) {
6508
+ if (Object.is(a, b)) return true;
6509
+ if (Array.isArray(a)) return Array.isArray(b) && a.length === b.length && a.every((v, i) => isJsonEqual(v, b[i]));
6510
+ if (isRecord(a) && isRecord(b)) {
6511
+ const keys = Object.keys(a);
6512
+ if (keys.length !== Object.keys(b).length) return false;
6513
+ return keys.every((k) => Object.prototype.hasOwnProperty.call(b, k) && isJsonEqual(a[k], b[k]));
6514
+ }
6515
+ return false;
6516
+ }
6517
+ /** The patch without the keys whose value already equals the stored one. */
6518
+ function dropUnchangedKeys(patch, stored) {
6519
+ const out = {};
6520
+ for (const [key, value] of Object.entries(patch)) {
6521
+ if (Object.prototype.hasOwnProperty.call(stored, key) && isJsonEqual(value, stored[key])) continue;
6522
+ out[key] = value;
6523
+ }
6524
+ return out;
6525
+ }
6526
+ /** The top-level keys of a blob that hold at least one of `owner`'s markers. */
6527
+ function markerKeysOf(blob, owner) {
6528
+ const keys = /* @__PURE__ */ new Set();
6529
+ for (const [key, value] of Object.entries(blob)) if (collectSecretMarkerRefs(value).some((ref) => isSecretRefOwnedBy(ref, owner))) keys.add(key);
6530
+ return keys;
6531
+ }
6532
+ function nodeFromStored(value, owner) {
6533
+ if (isSecretMarker(value)) return isSecretRefOwnedBy(value.$secret, owner) ? { kind: "leaf" } : null;
6534
+ if (!isRecord(value)) return null;
6535
+ const children = /* @__PURE__ */ new Map();
6536
+ for (const [key, child] of Object.entries(value)) {
6537
+ const node = nodeFromStored(child, owner);
6538
+ if (node !== null) children.set(key, node);
6539
+ }
6540
+ return children.size > 0 ? {
6541
+ kind: "object",
6542
+ children
6543
+ } : null;
6544
+ }
6545
+ /**
6546
+ * The declared secret tree, widened by every place the STORED blob holds a
6547
+ * marker under one of `keys` — so a marker the schema no longer declares (or
6548
+ * never declared: Wyze before b4906cec6) still gets the save path's
6549
+ * KEEP / SET / CLEAR semantics instead of being overwritten by whatever the
6550
+ * addon writes. Markers inside arrays are not added: a row has no id field to
6551
+ * match by unless the schema declares one. Only `owner`'s markers count: a
6552
+ * builtin that keeps another addon's marker (device-manager) never takes it
6553
+ * over.
6554
+ */
6555
+ function widenTreeWithStoredMarkers(declared, stored, keys, owner) {
6556
+ const added = /* @__PURE__ */ new Map();
6557
+ for (const key of keys) {
6558
+ const at = key.indexOf("@");
6559
+ const base = at > 0 ? key.slice(0, at) : key;
6560
+ if (declared.has(base) || added.has(base)) continue;
6561
+ const node = nodeFromStored(stored[key], owner);
6562
+ if (node !== null) added.set(base, node);
6563
+ }
6564
+ return added.size === 0 ? declared : new Map([...declared, ...added]);
6565
+ }
6566
+ /** The blob as stored now; a failed read REFUSES the write instead of guessing. */
6567
+ async function readStoredAddonBlob(raw) {
6568
+ const threeWay = raw.readAddonStoreResult;
6569
+ if (threeWay === void 0) return raw.readAddonStore();
6570
+ const result = await threeWay.call(raw);
6571
+ if (result.kind === "failed") throw new Error(`settings write refused: the stored blob could not be read (${result.error})`);
6572
+ return result.kind === "missing" ? {} : result.value;
6573
+ }
6574
+ function touchesTree(tree, patch) {
6575
+ if (tree.size === 0) return false;
6576
+ for (const key of Object.keys(patch)) {
6577
+ const at = key.indexOf("@");
6578
+ if (tree.has(at > 0 ? key.slice(0, at) : key)) return true;
6579
+ }
6580
+ return false;
6581
+ }
6582
+ /**
6583
+ * Which top-level keys of each store held markers when last seen. `undefined`
6584
+ * for a store not seen yet: its first write reads it, to be safe.
6585
+ */
6586
+ var MarkerKeyIndex = class {
6587
+ owner;
6588
+ byStore = /* @__PURE__ */ new Map();
6589
+ constructor(owner) {
6590
+ this.owner = owner;
6591
+ }
6592
+ seen(store, blob) {
6593
+ this.byStore.set(store, markerKeysOf(blob, this.owner));
6594
+ }
6595
+ wrote(store, patch) {
6596
+ const keys = this.byStore.get(store);
6597
+ if (keys === void 0) return;
6598
+ const now = markerKeysOf(patch, this.owner);
6599
+ for (const key of Object.keys(patch)) if (now.has(key)) keys.add(key);
6600
+ else keys.delete(key);
6601
+ }
6602
+ mayHoldMarkers(store, patch) {
6603
+ const keys = this.byStore.get(store);
6604
+ if (keys === void 0) return true;
6605
+ return Object.keys(patch).some((key) => keys.has(key));
6606
+ }
6607
+ };
6608
+ function createHandle(raw, opts) {
6609
+ const chains = /* @__PURE__ */ new Map();
6610
+ const serialize = (key, fn) => {
6611
+ const next = (chains.get(key) ?? Promise.resolve()).then(fn, fn);
6612
+ const tail = next.catch(() => void 0);
6613
+ chains.set(key, tail);
6614
+ tail.then(() => {
6615
+ if (chains.get(key) === tail) chains.delete(key);
6616
+ });
6617
+ return next;
6618
+ };
6619
+ const index = new MarkerKeyIndex(opts.secrets.owner);
6620
+ const resolveRead = async (store, blob) => {
6621
+ index.seen(store, blob);
6622
+ const { value, unresolved } = await resolveSecretMarkers(blob, opts.secrets, {
6623
+ unresolved: "keep-marker",
6624
+ ownedBy: opts.secrets.owner
6625
+ });
6626
+ if (unresolved.length > 0) opts.onUnresolved?.(unresolved);
6627
+ return value;
6628
+ };
6629
+ const write = async (store, declared, scope, patch, readStored, rawWrite) => {
6630
+ if (!touchesTree(declared, patch) && !index.mayHoldMarkers(store, patch)) {
6631
+ await rawWrite(patch);
6632
+ index.wrote(store, patch);
6633
+ return { changed: true };
6634
+ }
6635
+ return serialize(store, async () => {
6636
+ const stored = await readStored();
6637
+ index.seen(store, stored);
6638
+ const operatorWrite = opts.isOperatorWrite?.() === true;
6639
+ const restored = await restoreUnchangedSecrets({
6640
+ patch,
6641
+ stored,
6642
+ secrets: opts.secrets,
6643
+ operatorWrite
6644
+ });
6645
+ const result = await transformSecretWrite({
6646
+ tree: widenTreeWithStoredMarkers(declared, stored, Object.keys(restored.patch), opts.secrets.owner),
6647
+ secrets: opts.secrets,
6648
+ patch: restored.patch,
6649
+ stored,
6650
+ ...scope !== void 0 ? { scope } : {},
6651
+ operatorWrite
6652
+ });
6653
+ const effective = dropUnchangedKeys(result.patch, stored);
6654
+ const wroteBlob = Object.keys(effective).length > 0;
6655
+ if (wroteBlob) {
6656
+ await rawWrite(effective);
6657
+ index.wrote(store, effective);
6658
+ }
6659
+ const { orphaned } = await result.afterWrite();
6660
+ if (orphaned.length > 0) opts.onOrphaned(orphaned);
6661
+ return { changed: wroteBlob || restored.changedRefs.length > 0 };
6662
+ });
6663
+ };
6664
+ const writeAddon = (patch) => write("addon", opts.addonTree(), void 0, patch, () => readStoredAddonBlob(raw), (p) => raw.writeAddonStore(p));
6665
+ const readAddonStoreResult = raw.readAddonStoreResult;
6666
+ const readAddonStoreKeyResult = raw.readAddonStoreKeyResult;
6667
+ const readDeviceStoreBatch = raw.readDeviceStoreBatch;
6668
+ const overrides = {
6669
+ readAddonStore: async () => resolveRead("addon", await raw.readAddonStore()),
6670
+ ...readAddonStoreResult !== void 0 ? { readAddonStoreResult: async () => {
6671
+ const result = await readAddonStoreResult.call(raw);
6672
+ return result.kind === "value" ? {
6673
+ kind: "value",
6674
+ value: await resolveRead("addon", result.value)
6675
+ } : result;
6676
+ } } : {},
6677
+ ...readAddonStoreKeyResult !== void 0 ? { readAddonStoreKeyResult: async (key) => {
6678
+ const result = await readAddonStoreKeyResult.call(raw, key);
6679
+ if (result.kind !== "present") return result;
6680
+ const { value, unresolved } = await resolveSecretMarkers({ [key]: result.value }, opts.secrets, {
6681
+ unresolved: "keep-marker",
6682
+ ownedBy: opts.secrets.owner
6683
+ });
6684
+ if (unresolved.length > 0) opts.onUnresolved?.(unresolved);
6685
+ return {
6686
+ kind: "present",
6687
+ value: value[key]
6688
+ };
6689
+ } } : {},
6690
+ readDeviceStore: async (deviceId) => resolveRead(`device:${deviceId}`, await raw.readDeviceStore(deviceId)),
6691
+ ...readDeviceStoreBatch !== void 0 ? { readDeviceStoreBatch: async (deviceIds) => {
6692
+ const rows = await readDeviceStoreBatch.call(raw, deviceIds);
6693
+ const out = /* @__PURE__ */ new Map();
6694
+ for (const [deviceId, blob] of rows) out.set(deviceId, await resolveRead(`device:${deviceId}`, blob));
6695
+ return out;
6696
+ } } : {},
6697
+ writeAddonStore: async (patch) => {
6698
+ await writeAddon(patch);
6699
+ },
6700
+ writeDeviceStore: async (deviceId, patch) => {
6701
+ await write(`device:${deviceId}`, opts.deviceTree(), {
6702
+ kind: "device",
6703
+ deviceId
6704
+ }, patch, () => raw.readDeviceStore(deviceId), (p) => raw.writeDeviceStore(deviceId, p));
6705
+ }
6706
+ };
6707
+ return {
6708
+ settings: new Proxy(raw, { get(target, prop, receiver) {
6709
+ if (typeof prop === "string" && Object.prototype.hasOwnProperty.call(overrides, prop)) return Reflect.get(overrides, prop);
6710
+ const value = Reflect.get(target, prop, receiver);
6711
+ return typeof value === "function" ? value.bind(target) : value;
6712
+ } }),
6713
+ raw: {
6714
+ readAddonStore: async () => {
6715
+ const blob = await raw.readAddonStore();
6716
+ index.seen("addon", blob);
6717
+ return blob;
6718
+ },
6719
+ readDeviceStore: async (deviceId) => {
6720
+ const blob = await raw.readDeviceStore(deviceId);
6721
+ index.seen(`device:${deviceId}`, blob);
6722
+ return blob;
6723
+ }
6724
+ },
6725
+ writeAddonStore: writeAddon
6726
+ };
6727
+ }
6728
+ /** The context the addon sees, plus the private raw view and write outcome. */
6729
+ function createSecretAwareContext(context, opts) {
6730
+ const raw = context.settings;
6731
+ if (raw === void 0) return {
6732
+ context,
6733
+ handle: null
6734
+ };
6735
+ const handle = createHandle(raw, opts);
6736
+ return {
6737
+ context: new Proxy(context, { get(target, prop, receiver) {
6738
+ if (prop === "settings") return handle.settings;
6739
+ return Reflect.get(target, prop, receiver);
6740
+ } }),
6741
+ handle
6742
+ };
6743
+ }
6744
+ var LEAF = { kind: "leaf" };
6745
+ var DEFAULT_ITEM_ID_KEY = "id";
6746
+ function collectFields(fields, out) {
6747
+ for (const field of fields) {
6748
+ if (field.type === "group") {
6749
+ collectFields(field.fields, out);
6750
+ continue;
6751
+ }
6752
+ if (field.type === "sub-tabs") {
6753
+ for (const tab of field.tabs) collectFields(tab.fields, out);
6754
+ continue;
6755
+ }
6756
+ if (field.type === "editable-array") {
6757
+ const item = /* @__PURE__ */ new Map();
6758
+ for (const itemField of field.itemFields) if ("key" in itemField && isKeychainStoredField(itemField)) item.set(itemField.key, LEAF);
6759
+ if (item.size > 0) out.set(field.key, {
6760
+ kind: "array",
6761
+ idKey: field.itemIdKey ?? DEFAULT_ITEM_ID_KEY,
6762
+ item
6763
+ });
6764
+ continue;
6765
+ }
6766
+ if (!("key" in field) || typeof field.key !== "string") continue;
6767
+ if (isKeychainStoredField(field)) out.set(field.key, LEAF);
6768
+ }
6769
+ }
6770
+ /** The secret tree a settings schema declares. */
6771
+ function secretTreeFromSchema(schema) {
6772
+ const out = /* @__PURE__ */ new Map();
6773
+ if (schema === null) return out;
6774
+ for (const section of schema.sections) collectFields(section.fields, out);
6775
+ return out;
6776
+ }
6777
+ /** Parse `a.b[id].c` into segments; throws on a malformed path (a declaration bug). */
6778
+ function parseSecretStatePath(path) {
6779
+ const segments = [];
6780
+ for (const raw of path.split(".")) {
6781
+ const m = /^([^[\]]+)(?:\[([^[\]]+)\])?$/.exec(raw);
6782
+ if (m === null || m[1] === void 0) throw new Error(`secretStatePaths: malformed path "${path}"`);
6783
+ segments.push(m[2] !== void 0 ? {
6784
+ key: m[1],
6785
+ idKey: m[2]
6786
+ } : { key: m[1] });
6787
+ }
6788
+ if (segments.length === 0) throw new Error(`secretStatePaths: empty path`);
6789
+ if (segments[segments.length - 1]?.idKey !== void 0) throw new Error(`secretStatePaths: "${path}" ends on an array — name the member that is secret`);
6790
+ return segments;
6791
+ }
6792
+ function insert(into, segments) {
6793
+ const [head, ...rest] = segments;
6794
+ if (head === void 0) return;
6795
+ if (rest.length === 0) {
6796
+ into.set(head.key, LEAF);
6797
+ return;
6798
+ }
6799
+ const existing = into.get(head.key);
6800
+ if (head.idKey !== void 0) {
6801
+ const item = new Map(existing?.kind === "array" ? existing.item : []);
6802
+ insert(item, rest);
6803
+ into.set(head.key, {
6804
+ kind: "array",
6805
+ idKey: head.idKey,
6806
+ item
6807
+ });
6808
+ return;
6809
+ }
6810
+ const children = new Map(existing?.kind === "object" ? existing.children : []);
6811
+ insert(children, rest);
6812
+ into.set(head.key, {
6813
+ kind: "object",
6814
+ children
6815
+ });
6816
+ }
6817
+ /** Add hidden-state paths (`secretStatePaths`) to a schema-derived tree. */
6818
+ function mergeSecretStatePaths(tree, paths) {
6819
+ if (paths.length === 0) return tree;
6820
+ const out = new Map(tree);
6821
+ for (const path of paths) insert(out, parseSecretStatePath(path));
6822
+ return out;
6823
+ }
6824
+ /** First retry of a secret the keychain could not serve; doubles to {@link SECRET_RETRY_MAX_MS}. */
6825
+ var SECRET_RETRY_FIRST_MS = 5e3;
6826
+ var SECRET_RETRY_MAX_MS = 5 * 6e4;
6827
+ /** Coalesces a burst of `keychain.changed` events into one re-resolve. */
6828
+ var SECRET_CHANGE_DEBOUNCE_MS = 250;
5946
6829
  /**
5947
6830
  * Base class for CamStack addons. Eliminates settings boilerplate:
5948
6831
  *
@@ -6012,6 +6895,33 @@ var BaseAddon = class {
6012
6895
  settingsStoreReady = false;
6013
6896
  /** Default config values. Provided via constructor. */
6014
6897
  defaults;
6898
+ /**
6899
+ * Hidden-state paths that hold secrets (D787) — values the addon writes
6900
+ * itself (`updateGlobalSettings`, `state()`) that no form field declares.
6901
+ * Stored in the keychain exactly like a `password` field. Syntax:
6902
+ * `'snapshotSigningKey'`, `'identity.pincode'`, `'tokens[userId].accessToken'`
6903
+ * (`key[<id field>]` addresses array items by id, never by index).
6904
+ */
6905
+ secretStatePaths = [];
6906
+ _addonSecretTree = null;
6907
+ _deviceSecretTree = null;
6908
+ /** Refs the last resolved config pointed at — a change to one re-resolves. */
6909
+ _configSecretRefs = /* @__PURE__ */ new Set();
6910
+ _unresolvedSecrets = [];
6911
+ _secretRetryTimer = null;
6912
+ _secretRetryDelayMs = SECRET_RETRY_FIRST_MS;
6913
+ _secretChangeTimer = null;
6914
+ _secretChangeUnsub = null;
6915
+ /** >0 while an OPERATOR's settings write is being applied. */
6916
+ _operatorWriteDepth = 0;
6917
+ /**
6918
+ * The keychain-aware settings handle (D798). Its `raw` view is the ONLY way
6919
+ * to the marker-bearing blobs and stays private to this class: the form
6920
+ * hydrate and config resolution need markers, addon code never does.
6921
+ */
6922
+ _secretSettings = null;
6923
+ /** Refs an addon-facing read could not resolve — each is logged once per process. */
6924
+ _loggedUnresolvedReads = /* @__PURE__ */ new Set();
6015
6925
  constructor(defaults) {
6016
6926
  this.defaults = defaults;
6017
6927
  this._config = { ...defaults };
@@ -6047,8 +6957,26 @@ var BaseAddon = class {
6047
6957
  return this._config;
6048
6958
  }
6049
6959
  async initialize(context) {
6050
- this._ctx = context;
6960
+ const secrets = context.secrets;
6961
+ if (secrets !== void 0) {
6962
+ const { context: wrapped, handle } = createSecretAwareContext(context, {
6963
+ secrets,
6964
+ addonTree: () => this.addonSecretTree(),
6965
+ deviceTree: () => this.deviceSecretTree(),
6966
+ onOrphaned: (refs) => context.logger.warn("keychain refs dropped by a settings write could not be deleted", { meta: { refs: [...refs] } }),
6967
+ isOperatorWrite: () => this._operatorWriteDepth > 0,
6968
+ onUnresolved: (unresolved) => this.logUnresolvedRead(unresolved)
6969
+ });
6970
+ this._ctx = wrapped;
6971
+ this._secretSettings = handle;
6972
+ } else {
6973
+ this._ctx = context;
6974
+ this._secretSettings = null;
6975
+ }
6051
6976
  await this.resolveConfig();
6977
+ if (secrets !== void 0) this._secretChangeUnsub = secrets.onChange((ref) => {
6978
+ if (this._configSecretRefs.has(ref)) this.scheduleSecretReresolve(SECRET_CHANGE_DEBOUNCE_MS);
6979
+ });
6052
6980
  const result = await this.onInitialize();
6053
6981
  this.emitLifecycle(EventCategory.AddonStarted);
6054
6982
  const normalized = normalizeAddonInitResult(result);
@@ -6081,6 +7009,12 @@ var BaseAddon = class {
6081
7009
  */
6082
7010
  async onHubReachable() {}
6083
7011
  async shutdown() {
7012
+ this._secretChangeUnsub?.();
7013
+ this._secretChangeUnsub = null;
7014
+ if (this._secretRetryTimer !== null) clearTimeout(this._secretRetryTimer);
7015
+ if (this._secretChangeTimer !== null) clearTimeout(this._secretChangeTimer);
7016
+ this._secretRetryTimer = null;
7017
+ this._secretChangeTimer = null;
6084
7018
  this.emitLifecycle(EventCategory.AddonStopped);
6085
7019
  if (this.autoEmitReadiness) this.emitReadinessForProviders("down");
6086
7020
  await this.onShutdown();
@@ -6155,11 +7089,8 @@ var BaseAddon = class {
6155
7089
  async getGlobalSettings(overlay, cap, nodeId) {
6156
7090
  const schema = this.globalSettingsSchema(cap);
6157
7091
  if (!schema) return { sections: [] };
6158
- const projected = await this.resolveGlobalStore(nodeId, cap);
6159
- return hydrateSchema(schema, overlay ? {
6160
- ...projected,
6161
- ...overlay
6162
- } : projected);
7092
+ const projected = await this.readRawProjectedStore(nodeId, cap);
7093
+ return hydrateSchema(schema, overlay ? await this.overlayKeepingMarkers(projected, overlay) : projected, { inlineSecretsAsViews: true });
6163
7094
  }
6164
7095
  /**
6165
7096
  * The integration-level view of this addon's settings: exactly the sections
@@ -6204,11 +7135,11 @@ var BaseAddon = class {
6204
7135
  });
6205
7136
  }
6206
7137
  if (sections.length === 0) return null;
6207
- const projected = await this.resolveGlobalStore(nodeId);
7138
+ const projected = await this.readRawProjectedStore(nodeId);
6208
7139
  return hydrateSchema({
6209
7140
  ...schema,
6210
7141
  sections
6211
- }, projected);
7142
+ }, projected, { inlineSecretsAsViews: true });
6212
7143
  }
6213
7144
  /**
6214
7145
  * The raw addon store PROJECTED onto the target node's bare per-node keys:
@@ -6221,12 +7152,50 @@ var BaseAddon = class {
6221
7152
  * the store for custom option logic (option narrowing, value snapping) to
6222
7153
  * read it per-node — never `ctx.settings.readAddonStore()` directly.
6223
7154
  * `nodeId` omitted ⇒ the local node (node-blind injection from ctx).
7155
+ *
7156
+ * Keychain values come back RESOLVED (D798): a secret reads as its value,
7157
+ * never as a `{ $secret }` marker. One the keychain cannot serve right now
7158
+ * stays a marker — "stored, unavailable" (`isSecretMarker()` is true, and it
7159
+ * is listed in {@link unresolvedSecrets}) — never `''` and never absent, so
7160
+ * it cannot be mistaken for "nothing stored, mint a new one". Writing the
7161
+ * resolved blob back is a no-op for every unchanged secret.
6224
7162
  */
6225
7163
  async resolveGlobalStore(nodeId, cap) {
6226
7164
  const raw = await this._ctx?.settings?.readAddonStore() ?? {};
7165
+ return this.projectForNode(raw, nodeId, cap);
7166
+ }
7167
+ projectForNode(store, nodeId, cap) {
6227
7168
  const keys = this.perNodeKeys(cap);
6228
7169
  const node = normalizeNodeId(nodeId ?? this._ctx?.kernel?.localNodeId);
6229
- return keys.size > 0 ? projectStore(raw, keys, node) : raw;
7170
+ return keys.size > 0 ? projectStore(store, keys, node) : store;
7171
+ }
7172
+ /** The PROJECTED store with its markers — the form hydrate only (D798). */
7173
+ async readRawProjectedStore(nodeId, cap) {
7174
+ const raw = await this.rawSettings()?.readAddonStore() ?? {};
7175
+ return this.projectForNode(raw, nodeId, cap);
7176
+ }
7177
+ /**
7178
+ * `{ ...stored, ...overlay }`, except that an overlay member equal to the
7179
+ * RESOLVED stored one keeps the stored (marker-bearing) member — so a form
7180
+ * hydrated from a resolved overlay still shows a secret as "set", never as
7181
+ * its value.
7182
+ */
7183
+ async overlayKeepingMarkers(stored, overlay) {
7184
+ const secrets = this._ctx?.secrets;
7185
+ const merged = {
7186
+ ...stored,
7187
+ ...overlay
7188
+ };
7189
+ if (secrets === void 0 || collectSecretMarkerRefs(stored).length === 0) return merged;
7190
+ const { value: resolved } = await resolveSecretMarkers(stored, secrets, {
7191
+ unresolved: "keep-marker",
7192
+ ownedBy: secrets.owner
7193
+ });
7194
+ for (const key of Object.keys(overlay)) {
7195
+ if (collectSecretMarkerRefs(stored[key]).length === 0) continue;
7196
+ if (isJsonEqual(overlay[key], resolved[key])) merged[key] = stored[key];
7197
+ }
7198
+ return merged;
6230
7199
  }
6231
7200
  /**
6232
7201
  * Whether ONE global key of this addon's store was written, read three-way
@@ -6262,18 +7231,58 @@ var BaseAddon = class {
6262
7231
  value: result.value[key]
6263
7232
  };
6264
7233
  }
7234
+ /**
7235
+ * The OPERATOR's write — a settings form or an admin API call, dispatched by
7236
+ * the kernel. Identical to {@link updateGlobalSettings}, except that a secret
7237
+ * the operator sends is stored as sent even when it equals a pre-keychain
7238
+ * inline value: the operator re-entering a password is a change, an addon
7239
+ * writing back what it read is not (D787).
7240
+ */
7241
+ async updateGlobalSettingsAsOperator(patch, nodeId) {
7242
+ this._operatorWriteDepth++;
7243
+ try {
7244
+ await this.applyGlobalPatch(patch, nodeId);
7245
+ } finally {
7246
+ this._operatorWriteDepth--;
7247
+ }
7248
+ }
6265
7249
  async updateGlobalSettings(patch, nodeId) {
7250
+ await this.applyGlobalPatch(patch, nodeId);
7251
+ }
7252
+ /**
7253
+ * REMOVE stored secrets — their keychain values and their markers (D787).
7254
+ *
7255
+ * Writing `''` to a secret field KEEPS what is stored (an empty string is
7256
+ * what a defaults fallback writes back, and it must never destroy a
7257
+ * credential), so code that means "forget this token" says so here. Without
7258
+ * a keychain (an older kernel) it writes `''`, as such code always did.
7259
+ */
7260
+ async clearSecrets(keys, nodeId) {
7261
+ const tree = this.addonSecretTree();
7262
+ const keychain = this._ctx?.secrets !== void 0;
7263
+ const stored = keychain ? await this.readAddonStoreWithRetry() : {};
7264
+ const patch = {};
7265
+ for (const key of keys) {
7266
+ const keychainStored = tree.has(key) || collectSecretMarkerRefs(stored[key]).length > 0;
7267
+ patch[key] = keychain && keychainStored ? SECRET_CLEAR : "";
7268
+ }
7269
+ await this.applyGlobalPatch(patch, nodeId);
7270
+ }
7271
+ async applyGlobalPatch(barePatch, nodeId) {
6266
7272
  const keys = this.perNodeKeys();
6267
7273
  const localNode = normalizeNodeId(this._ctx?.kernel?.localNodeId);
6268
7274
  const target = normalizeNodeId(nodeId ?? this._ctx?.kernel?.localNodeId);
6269
- const barePatch = patch;
6270
7275
  const scoped = keys.size > 0 ? scopePatch(barePatch, keys, target) : barePatch;
6271
- await this._ctx?.settings?.writeAddonStore(scoped);
7276
+ const handle = this._secretSettings;
7277
+ if (handle !== null) {
7278
+ const { changed } = await handle.writeAddonStore(scoped);
7279
+ if (!changed) return;
7280
+ } else await this._ctx?.settings?.writeAddonStore(scoped);
6272
7281
  if (target !== localNode) return;
6273
7282
  await this.resolveConfig();
6274
7283
  await this.onConfigChanged();
6275
7284
  this.emitLifecycle(EventCategory.AddonUpdated, { level: "global" });
6276
- this.maybeAutoRestart(patch, this.globalSettingsSchema());
7285
+ this.maybeAutoRestart(Object.keys(barePatch), this.globalSettingsSchema());
6277
7286
  }
6278
7287
  /**
6279
7288
  * The set of field keys the global settings schema declares `perNode: true`
@@ -6298,7 +7307,7 @@ var BaseAddon = class {
6298
7307
  * time to return its response before the addon is torn down and
6299
7308
  * re-initialised by `AddonRegistryService.restartAddon`.
6300
7309
  */
6301
- maybeAutoRestart(patch, schema) {
7310
+ maybeAutoRestart(patchKeys, schema) {
6302
7311
  if (!schema) return;
6303
7312
  const restartKeys = /* @__PURE__ */ new Set();
6304
7313
  for (const section of schema.sections) for (const field of section.fields) {
@@ -6306,13 +7315,13 @@ var BaseAddon = class {
6306
7315
  if (field.requiresRestart) restartKeys.add(field.key);
6307
7316
  }
6308
7317
  if (restartKeys.size === 0) return;
6309
- if (!Object.keys(patch).some((k) => restartKeys.has(k))) return;
7318
+ if (!patchKeys.some((k) => restartKeys.has(k))) return;
6310
7319
  const ctx = this._ctx;
6311
7320
  if (!ctx) return;
6312
7321
  const addonId = ctx.id;
6313
7322
  setImmediate(() => {
6314
7323
  ctx.api.addons?.restartAddon?.mutate({ addonId }).then(() => {
6315
- ctx.logger.info("addon auto-restart triggered by restart-required setting change", { meta: { changedFields: Object.keys(patch).filter((k) => restartKeys.has(k)) } });
7324
+ ctx.logger.info("addon auto-restart triggered by restart-required setting change", { meta: { changedFields: patchKeys.filter((k) => restartKeys.has(k)) } });
6316
7325
  }).catch((err) => {
6317
7326
  ctx.logger.error("addon auto-restart failed", { meta: { error: err instanceof Error ? err.message : String(err) } });
6318
7327
  });
@@ -6321,7 +7330,7 @@ var BaseAddon = class {
6321
7330
  async getDeviceSettings(deviceId) {
6322
7331
  const schema = this.deviceSettingsSchema();
6323
7332
  if (!schema) return { sections: [] };
6324
- return hydrateSchema(schema, await this._ctx?.settings?.readDeviceStore(deviceId) ?? {});
7333
+ return hydrateSchema(schema, await this.rawSettings()?.readDeviceStore(deviceId) ?? {}, { inlineSecretsAsViews: true });
6325
7334
  }
6326
7335
  async updateDeviceSettings(deviceId, patch) {
6327
7336
  await this._ctx?.settings?.writeDeviceStore(deviceId, patch);
@@ -6451,7 +7460,7 @@ var BaseAddon = class {
6451
7460
  * selection at boot (absent scoped key ⇒ the constructor default wins).
6452
7461
  */
6453
7462
  async resolveConfig() {
6454
- const stored = await this.readAddonStoreWithRetry();
7463
+ const stored = await this.resolveStoredSecrets(await this.readAddonStoreWithRetry());
6455
7464
  const perNode = this.perNodeKeys();
6456
7465
  const localNode = normalizeNodeId(this._ctx?.kernel?.localNodeId);
6457
7466
  const resolved = { ...this.defaults };
@@ -6476,7 +7485,7 @@ var BaseAddon = class {
6476
7485
  key,
6477
7486
  schema,
6478
7487
  fallback,
6479
- read: () => this.readAddonStoreWithRetry(),
7488
+ read: async () => this.resolveStoredSecrets(await this.readAddonStoreWithRetry()),
6480
7489
  write: async (patch) => {
6481
7490
  await this._ctx?.settings?.writeAddonStore(patch);
6482
7491
  },
@@ -6493,7 +7502,7 @@ var BaseAddon = class {
6493
7502
  key,
6494
7503
  schema,
6495
7504
  fallback,
6496
- read: async () => await this._ctx?.settings?.readDeviceStore(deviceId) ?? {},
7505
+ read: async () => this.resolveStoredSecrets(await this.rawSettings()?.readDeviceStore(deviceId) ?? {}, false),
6497
7506
  write: async (patch) => {
6498
7507
  await this._ctx?.settings?.writeDeviceStore(deviceId, patch);
6499
7508
  },
@@ -6505,6 +7514,87 @@ var BaseAddon = class {
6505
7514
  } })
6506
7515
  });
6507
7516
  }
7517
+ /** The addon store's secret tree: schema fields by TYPE, plus `secretStatePaths`. */
7518
+ addonSecretTree() {
7519
+ this._addonSecretTree ??= mergeSecretStatePaths(secretTreeFromSchema(this.globalSettingsSchema()), this.secretStatePaths);
7520
+ return this._addonSecretTree;
7521
+ }
7522
+ deviceSecretTree() {
7523
+ this._deviceSecretTree ??= secretTreeFromSchema(this.deviceSettingsSchema());
7524
+ return this._deviceSecretTree;
7525
+ }
7526
+ /**
7527
+ * Secrets of this addon's stored config that could not be resolved on the
7528
+ * last read, with why. Non-empty means the addon is running WITHOUT them —
7529
+ * an addon whose function needs one should report itself degraded rather
7530
+ * than start on an empty credential.
7531
+ */
7532
+ get unresolvedSecrets() {
7533
+ return this._unresolvedSecrets;
7534
+ }
7535
+ /**
7536
+ * Substitute every keychain marker in a stored blob with its value. With no
7537
+ * keychain (no `ctx.secrets`) or no marker, the blob comes back unchanged.
7538
+ * An unresolvable value is LEFT OUT (never `''`), logged by ref — never by
7539
+ * value — and, when the cause can pass, retried with backoff. Nothing is
7540
+ * ever written back from here.
7541
+ */
7542
+ async resolveStoredSecrets(blob, trackForConfig = true) {
7543
+ const secrets = this._ctx?.secrets;
7544
+ if (secrets === void 0) return blob;
7545
+ const refs = collectSecretMarkerRefs(blob);
7546
+ if (trackForConfig) this._configSecretRefs = new Set(refs);
7547
+ if (refs.length === 0) {
7548
+ if (trackForConfig) this._unresolvedSecrets = [];
7549
+ return blob;
7550
+ }
7551
+ const { value, unresolved } = await resolveSecretMarkers(blob, secrets);
7552
+ if (trackForConfig) {
7553
+ this._unresolvedSecrets = unresolved;
7554
+ if (unresolved.length > 0) {
7555
+ this._ctx?.logger?.error?.("secret unavailable — running without it, will retry", { meta: { secrets: unresolved.map((u) => ({
7556
+ ref: u.ref,
7557
+ reason: u.reason
7558
+ })) } });
7559
+ if (unresolved.some((u) => u.reason !== "missing" && u.reason !== "forbidden")) {
7560
+ this.scheduleSecretReresolve(this._secretRetryDelayMs);
7561
+ this._secretRetryDelayMs = Math.min(this._secretRetryDelayMs * 2, SECRET_RETRY_MAX_MS);
7562
+ }
7563
+ } else this._secretRetryDelayMs = SECRET_RETRY_FIRST_MS;
7564
+ }
7565
+ return value;
7566
+ }
7567
+ /**
7568
+ * The marker-bearing settings reads (D798) — private on purpose. Without a
7569
+ * keychain the context's own view is already raw.
7570
+ */
7571
+ rawSettings() {
7572
+ return this._secretSettings?.raw ?? this._ctx?.settings;
7573
+ }
7574
+ /** An addon-facing read met markers it could not resolve: say so once per ref. */
7575
+ logUnresolvedRead(unresolved) {
7576
+ const fresh = unresolved.filter((u) => !this._loggedUnresolvedReads.has(u.ref));
7577
+ if (fresh.length === 0) return;
7578
+ for (const u of fresh) this._loggedUnresolvedReads.add(u.ref);
7579
+ 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) => ({
7580
+ ref: u.ref,
7581
+ reason: u.reason
7582
+ })) } });
7583
+ }
7584
+ /** Re-resolve the config (a keychain-only change, or a retry) and apply it. */
7585
+ scheduleSecretReresolve(delayMs) {
7586
+ const timerOf = delayMs === SECRET_CHANGE_DEBOUNCE_MS ? "_secretChangeTimer" : "_secretRetryTimer";
7587
+ if (this[timerOf] !== null) return;
7588
+ const timer = setTimeout(() => {
7589
+ this[timerOf] = null;
7590
+ if (this._ctx === null) return;
7591
+ this.resolveConfig().then(() => this.onConfigChanged()).catch((err) => {
7592
+ this._ctx?.logger?.error?.("re-resolving secrets failed", { meta: { error: err instanceof Error ? err.message : String(err) } });
7593
+ });
7594
+ }, delayMs);
7595
+ timer.unref?.();
7596
+ this[timerOf] = timer;
7597
+ }
6508
7598
  /**
6509
7599
  * Wrap `ctx.settings.readAddonStore()` with a short retry budget so a
6510
7600
  * transient settings-store outage (mid-restart of sqlite-settings, tsx-watch
@@ -6517,7 +7607,7 @@ var BaseAddon = class {
6517
7607
  * `{}` (defaults) — the addon's first successful patch will rehydrate.
6518
7608
  */
6519
7609
  async readAddonStoreWithRetry() {
6520
- const settings = this._ctx?.settings;
7610
+ const settings = this.rawSettings();
6521
7611
  if (!settings) return {};
6522
7612
  const delaysMs = [
6523
7613
  150,
@@ -7080,6 +8170,69 @@ method(object({ deviceId: number() }), array(StreamSourceEntrySchema)), method(o
7080
8170
  kind: "mutation",
7081
8171
  auth: "admin"
7082
8172
  }), method(object({ deviceId: number() }), unknown().nullable()), method(object({ deviceId: number() }), RawStateResultSchema.nullable(), { auth: "protected" });
8173
+ function defOf(schema) {
8174
+ return schema._zod?.def ?? {};
8175
+ }
8176
+ function declaredHere(schema) {
8177
+ return globalRegistry.get(schema)?.secret === true;
8178
+ }
8179
+ /** Wrapper kinds whose `innerType` is the field itself. */
8180
+ var WRAPPERS = new Set([
8181
+ "optional",
8182
+ "nullable",
8183
+ "default",
8184
+ "prefault",
8185
+ "catch",
8186
+ "readonly",
8187
+ "nonoptional"
8188
+ ]);
8189
+ /**
8190
+ * The schema layers that make up ONE field: the schema itself and every
8191
+ * wrapper below it (optional / default / nullable / readonly / catch), plus
8192
+ * both sides of a pipe (`z.preprocess` puts the real schema on `out`,
8193
+ * `.transform` on `in`).
8194
+ */
8195
+ function layersOf(schema) {
8196
+ const out = [];
8197
+ const queue = [schema];
8198
+ while (queue.length > 0) {
8199
+ const s = queue.shift();
8200
+ if (!s || out.includes(s)) continue;
8201
+ out.push(s);
8202
+ const def = defOf(s);
8203
+ if (def.type !== void 0 && WRAPPERS.has(def.type) && def.innerType) queue.push(def.innerType);
8204
+ if (def.type === "pipe") {
8205
+ if (def.in) queue.push(def.in);
8206
+ if (def.out) queue.push(def.out);
8207
+ }
8208
+ }
8209
+ return out;
8210
+ }
8211
+ /** True when any layer of this field declares `.meta({ secret: true })`. */
8212
+ function isZodSecret(schema) {
8213
+ return layersOf(schema).some(declaredHere);
8214
+ }
8215
+ /**
8216
+ * Every declared secret path in a config schema: dotted keys, `[]` for "each
8217
+ * element of this array" (`connection.password`, `rows[].token`). A declared
8218
+ * object or array is reported as one path and not descended into — everything
8219
+ * under it is secret.
8220
+ */
8221
+ function collectZodSecretPaths(schema, prefix = "") {
8222
+ if (isZodSecret(schema)) return prefix.length > 0 ? [prefix] : [];
8223
+ const paths = [];
8224
+ for (const layer of layersOf(schema)) {
8225
+ const def = defOf(layer);
8226
+ if (def.type === "object" && def.shape) for (const [key, child] of Object.entries(def.shape)) paths.push(...collectZodSecretPaths(child, prefix ? `${prefix}.${key}` : key));
8227
+ else if (def.type === "array" && def.element) paths.push(...collectZodSecretPaths(def.element, `${prefix}[]`));
8228
+ else if (def.type === "union" && def.options) for (const option of def.options) paths.push(...collectZodSecretPaths(option, prefix));
8229
+ else if (def.type === "intersection") {
8230
+ if (def.left) paths.push(...collectZodSecretPaths(def.left, prefix));
8231
+ if (def.right) paths.push(...collectZodSecretPaths(def.right, prefix));
8232
+ }
8233
+ }
8234
+ return [...new Set(paths)];
8235
+ }
7083
8236
  //#endregion
7084
8237
  //#region ../types/dist/err-msg-DX6i_MY4.mjs
7085
8238
  var DeviceType = /* @__PURE__ */ function(DeviceType) {
@@ -8757,6 +9910,278 @@ var CameraSwitchGroupSchema = object({
8757
9910
  fetchedAt: number()
8758
9911
  });
8759
9912
  /**
9913
+ * The trainer contract — what the hub hands the cloud trainer and what it
9914
+ * gets back (cloud training, D805+).
9915
+ *
9916
+ * The trainer (`hf/camstack-trainer`, published as the Hugging Face repo
9917
+ * `camstack/camstack-trainer`) is a separate AGPL program the hub never
9918
+ * imports: `job.json` goes in, files come out, and progress is `CAMSTACK_EVENT`
9919
+ * lines on stdout. These schemas are the hub's half of that boundary; the
9920
+ * trainer's pydantic models (and the JSON Schemas generated from them under
9921
+ * `hf/camstack-trainer/schemas/`) are the other half. A change here is a
9922
+ * change there, in the same piece of work.
9923
+ *
9924
+ * No `.default()` anywhere: defaults do not run on the addon cap path, so the
9925
+ * orchestrator fills every field of a job spec explicitly.
9926
+ */
9927
+ var TRAINING_JOB_SCHEMA = "camstack.training/v1";
9928
+ var TRAINING_RESULT_SCHEMA = "camstack.training-result/v1";
9929
+ /** What the trainer can export. Edge TPU is a later, separate image. */
9930
+ var TrainingExportSchema = _enum([
9931
+ "onnx",
9932
+ "openvino-fp16",
9933
+ "openvino-int8",
9934
+ "coreml-fp16"
9935
+ ]);
9936
+ var FloorsSchema = record(string(), number().min(0).max(1));
9937
+ object({
9938
+ schema: literal(TRAINING_JOB_SCHEMA),
9939
+ jobKey: string().uuid(),
9940
+ target: object({
9941
+ kind: literal("detector"),
9942
+ step: literal("object-detection")
9943
+ }),
9944
+ base: object({
9945
+ modelId: string().min(1),
9946
+ /** Ultralytics weights id, e.g. `yolov9m.pt`. */
9947
+ weights: string().min(1),
9948
+ imgsz: number().int().positive()
9949
+ }),
9950
+ baseline: object({
9951
+ modelId: string().min(1),
9952
+ /** The baseline ONNX the holdout comparison runs; public mirror URL. */
9953
+ onnxUrl: string().url(),
9954
+ imgsz: number().int().positive(),
9955
+ floors: FloorsSchema
9956
+ }),
9957
+ dataset: object({
9958
+ versionId: string().min(1),
9959
+ annotationHash: string(),
9960
+ /** sha256 of the uploaded archive; the trainer refuses a mismatch (exit 65). */
9961
+ sha256: string().regex(/^[0-9a-f]{64}$/)
9962
+ }),
9963
+ split: object({
9964
+ holdoutCameras: array(number().int()),
9965
+ /** When no camera is held out: the last N days of every camera. */
9966
+ holdoutLastDays: number().int().nonnegative(),
9967
+ valFraction: number().min(0).max(.5),
9968
+ seed: number().int()
9969
+ }),
9970
+ hyper: object({
9971
+ epochs: number().int().positive(),
9972
+ batch: number().int().positive(),
9973
+ lr0: number().positive(),
9974
+ /** Layers frozen from the start of the backbone; 0 = none. */
9975
+ freeze: number().int().nonnegative(),
9976
+ patience: number().int().nonnegative(),
9977
+ seed: number().int()
9978
+ }),
9979
+ replay: object({
9980
+ source: literal("coco2017"),
9981
+ count: number().int().nonnegative()
9982
+ }),
9983
+ exports: array(TrainingExportSchema).min(1),
9984
+ calibration: object({ maxFrames: number().int().positive() }),
9985
+ floors: object({
9986
+ minSupport: number().int().positive(),
9987
+ clamp: number().min(0).max(1)
9988
+ }),
9989
+ int8Gate: object({ maxMap50Drop: number().min(0).max(1) }),
9990
+ catalog: object({
9991
+ id: string().regex(/^[a-z0-9][a-z0-9-]{2,80}$/),
9992
+ name: string().min(1).max(160)
9993
+ })
9994
+ });
9995
+ /** One regular file of the bundle. An mlpackage contributes one row per member. */
9996
+ var TrainingResultFileSchema = object({
9997
+ path: string().min(1),
9998
+ bytes: number().int().nonnegative(),
9999
+ sha256: string().regex(/^[0-9a-f]{64}$/),
10000
+ format: _enum([
10001
+ "onnx",
10002
+ "openvino",
10003
+ "coreml",
10004
+ "pt"
10005
+ ]),
10006
+ variant: _enum(["base", "int8"])
10007
+ });
10008
+ var DraftFormatSchema = object({
10009
+ /** RELATIVE path inside the bundle; the hub rewrites it to `camstack-local://`. */
10010
+ url: string().min(1),
10011
+ sizeMB: number().nonnegative(),
10012
+ isDirectory: boolean().optional(),
10013
+ files: array(string()).optional(),
10014
+ runtimes: array(literal("python")).optional(),
10015
+ revision: string().min(1)
10016
+ });
10017
+ /** The trainer's half of a catalog entry; the hub completes it (labels, licence, group). */
10018
+ var TrainingCatalogDraftSchema = object({
10019
+ id: string().min(1),
10020
+ name: string().min(1),
10021
+ description: string(),
10022
+ labels: array(unknown()),
10023
+ inputSize: object({
10024
+ width: number().int().positive(),
10025
+ height: number().int().positive()
10026
+ }),
10027
+ preprocessMode: literal("letterbox"),
10028
+ defaultClassFloors: FloorsSchema,
10029
+ formats: object({
10030
+ onnx: DraftFormatSchema.optional(),
10031
+ openvino: DraftFormatSchema.optional(),
10032
+ coreml: DraftFormatSchema.optional()
10033
+ })
10034
+ });
10035
+ /** One class of one model's holdout report (the eval harness's summary). */
10036
+ var TrainingEvalClassSchema = object({
10037
+ positives: number().int(),
10038
+ floor: number().nullable(),
10039
+ tp: number().int(),
10040
+ fp: number().int(),
10041
+ fn: number().int(),
10042
+ precision: number().nullable(),
10043
+ recall: number().nullable(),
10044
+ ap50: number().nullable(),
10045
+ recallByCamera: record(string(), number().nullable()).optional(),
10046
+ recallByLight: record(string(), number().nullable()).optional(),
10047
+ fpByCamera: record(string(), number()).optional(),
10048
+ smallFound: number().int().optional(),
10049
+ smallTotal: number().int().optional()
10050
+ }).passthrough();
10051
+ var TrainingEvalReportSchema = object({
10052
+ frames: number().int(),
10053
+ classes: record(string(), TrainingEvalClassSchema)
10054
+ }).passthrough();
10055
+ /**
10056
+ * A succeeded result carries every block; a failed one carries the error and
10057
+ * whatever was known by then — the other blocks are ABSENT, not null. The
10058
+ * orchestrator checks the blocks it needs before it trusts a success.
10059
+ */
10060
+ var TrainingResultSchema = object({
10061
+ schema: literal(TRAINING_RESULT_SCHEMA),
10062
+ jobKey: string(),
10063
+ status: _enum(["succeeded", "failed"]),
10064
+ error: object({
10065
+ stage: string(),
10066
+ code: string(),
10067
+ message: string()
10068
+ }).nullable(),
10069
+ trainer: object({
10070
+ version: string(),
10071
+ revision: string()
10072
+ }),
10073
+ toolchain: record(string(), string().nullable()),
10074
+ dataset: object({
10075
+ versionId: string(),
10076
+ annotationHash: string(),
10077
+ sha256: string(),
10078
+ frames: object({
10079
+ train: number().int(),
10080
+ val: number().int(),
10081
+ holdout: number().int()
10082
+ }),
10083
+ holdoutCameras: array(number().int()),
10084
+ replayImages: number().int()
10085
+ }).optional(),
10086
+ training: object({
10087
+ epochsRun: number().int(),
10088
+ bestEpoch: number().int(),
10089
+ bestMap50: number(),
10090
+ bestMap50_95: number(),
10091
+ seconds: number()
10092
+ }).optional(),
10093
+ evaluation: object({
10094
+ holdoutFrames: number().int(),
10095
+ baseline: TrainingEvalReportSchema.nullable(),
10096
+ candidate: TrainingEvalReportSchema.nullable(),
10097
+ candidateInt8: TrainingEvalReportSchema.nullable(),
10098
+ recallDeltaByCamera: record(string(), record(string(), number())).nullable(),
10099
+ map50: record(string(), number().nullable())
10100
+ }).optional(),
10101
+ floors: object({
10102
+ baseline: FloorsSchema,
10103
+ candidate: FloorsSchema,
10104
+ candidateInt8: FloorsSchema.nullable(),
10105
+ notes: array(string())
10106
+ }).optional(),
10107
+ int8: object({
10108
+ kept: boolean(),
10109
+ map50Fp16: number().nullable(),
10110
+ map50Int8: number().nullable(),
10111
+ reason: string().nullable()
10112
+ }).optional(),
10113
+ exportsDropped: array(object({
10114
+ export: string(),
10115
+ reason: string()
10116
+ })).optional(),
10117
+ files: array(TrainingResultFileSchema).optional(),
10118
+ bundle: object({
10119
+ path: literal("bundle.tar"),
10120
+ bytes: number().int().nonnegative(),
10121
+ sha256: string().regex(/^[0-9a-f]{64}$/)
10122
+ }).nullable().optional(),
10123
+ catalogDraft: object({
10124
+ base: TrainingCatalogDraftSchema,
10125
+ int8: TrainingCatalogDraftSchema.nullable()
10126
+ }).nullable().optional(),
10127
+ licence: string()
10128
+ });
10129
+ var TrainingStageSchema = _enum([
10130
+ "prepare",
10131
+ "replay",
10132
+ "train",
10133
+ "eval",
10134
+ "export",
10135
+ "package"
10136
+ ]);
10137
+ var EventBase = {
10138
+ v: literal(1),
10139
+ ts: number()
10140
+ };
10141
+ discriminatedUnion("type", [
10142
+ object({
10143
+ ...EventBase,
10144
+ type: literal("stage"),
10145
+ stage: TrainingStageSchema
10146
+ }),
10147
+ object({
10148
+ ...EventBase,
10149
+ type: literal("epoch"),
10150
+ epoch: number().int(),
10151
+ epochs: number().int(),
10152
+ boxLoss: number().nullable().optional(),
10153
+ map50: number().nullable().optional(),
10154
+ map50_95: number().nullable().optional(),
10155
+ etaSec: number().nullable().optional()
10156
+ }),
10157
+ object({
10158
+ ...EventBase,
10159
+ type: literal("metric"),
10160
+ name: string(),
10161
+ value: number()
10162
+ }),
10163
+ object({
10164
+ ...EventBase,
10165
+ type: literal("artifact"),
10166
+ path: string(),
10167
+ bytes: number(),
10168
+ sha256: string()
10169
+ }),
10170
+ object({
10171
+ ...EventBase,
10172
+ type: literal("done"),
10173
+ status: _enum(["succeeded", "failed"]),
10174
+ resultSha256: string().nullable().optional()
10175
+ }),
10176
+ object({
10177
+ ...EventBase,
10178
+ type: literal("error"),
10179
+ stage: string(),
10180
+ code: string(),
10181
+ message: string()
10182
+ })
10183
+ ]);
10184
+ /**
8760
10185
  * What the gate decided about a birth, from the CALLER's point of view.
8761
10186
  *
8762
10187
  * Deliberately not `ConfirmationVerdict`: `undecided` is not a birth decision
@@ -11084,7 +12509,9 @@ var AddonHttpRouteSchema = object({
11084
12509
  "authenticated",
11085
12510
  "admin"
11086
12511
  ]).optional(),
11087
- description: string().optional()
12512
+ description: string().optional(),
12513
+ /** The hub limits this route per client address before the handler runs. */
12514
+ rateLimit: _enum(["auth"]).optional()
11088
12515
  });
11089
12516
  /**
11090
12517
  * Cross-process route invocation envelope. The hub captures the
@@ -11789,6 +13216,37 @@ var BackupDestinationInfoSchema = object({
11789
13216
  lastError: string().optional()
11790
13217
  });
11791
13218
  /**
13219
+ * How an archive is encrypted (operator decision 2026-10-09): to a backup
13220
+ * PUBLIC key the hub holds, so only the operator's secret key opens it.
13221
+ * Absent on a plain `.tar.gz` — every archive made before encryption, or
13222
+ * with it off — which restores without a key.
13223
+ */
13224
+ var BackupArchiveEncryptionSchema = object({
13225
+ /** `x25519-hkdf-aes256gcm-stream-v1`. */
13226
+ scheme: string(),
13227
+ /** 16 hex — the backup key whose secret restores this archive. */
13228
+ keyId: string()
13229
+ });
13230
+ /**
13231
+ * The backup encryption setting. The hub keeps PUBLIC keys only: the active
13232
+ * one new archives are encrypted to, and the retired ones older archives
13233
+ * still need. The secret key is shown once, at `setupEncryption`.
13234
+ */
13235
+ var BackupEncryptionStatusSchema = object({
13236
+ enabled: boolean(),
13237
+ active: object({
13238
+ keyId: string(),
13239
+ publicKey: string(),
13240
+ createdAt: number()
13241
+ }).nullable(),
13242
+ /** Every key ever set up, newest first. */
13243
+ keys: array(object({
13244
+ keyId: string(),
13245
+ createdAt: number(),
13246
+ retiredAt: number().nullable()
13247
+ })).readonly()
13248
+ });
13249
+ /**
11792
13250
  * Per-archive entry returned by `backup.listArchives({ destinationId })`.
11793
13251
  * Same shape the destination drill-in renders. Sourced from the per-
11794
13252
  * location `manifests.json` (no per-archive tarball read required).
@@ -11800,7 +13258,9 @@ var BackupArchiveEntrySchema = object({
11800
13258
  sizeBytes: number(),
11801
13259
  label: string().optional(),
11802
13260
  /** Top-level locations included in the archive (db, addons, tls, …). */
11803
- locations: array(string()).readonly()
13261
+ locations: array(string()).readonly(),
13262
+ /** Present when the archive is encrypted; restore then needs that key. */
13263
+ encryption: BackupArchiveEncryptionSchema.optional()
11804
13264
  });
11805
13265
  var BackupEntrySchema = object({
11806
13266
  id: string(),
@@ -11809,7 +13269,8 @@ var BackupEntrySchema = object({
11809
13269
  label: string().optional(),
11810
13270
  createdAt: number(),
11811
13271
  sizeBytes: number(),
11812
- locations: array(string()).optional()
13272
+ locations: array(string()).optional(),
13273
+ encryption: BackupArchiveEncryptionSchema.optional()
11813
13274
  });
11814
13275
  var ArchiveEntrySchema = object({
11815
13276
  path: string(),
@@ -11998,10 +13459,40 @@ method(_void(), array(BackupDestinationInfoSchema).readonly(), { auth: "admin" }
11998
13459
  * this list and skips entries whose path doesn't start with
11999
13460
  * any of them.
12000
13461
  */
12001
- locations: array(string()).optional()
13462
+ locations: array(string()).optional(),
13463
+ /**
13464
+ * The backup SECRET key, for an encrypted archive (ignored for a plain
13465
+ * one). The archive is decrypted into the hub's private staging
13466
+ * before the restart; the key is not stored. A wrong or missing key
13467
+ * is refused before the archive is downloaded.
13468
+ */
13469
+ backupSecretKey: string().optional()
12002
13470
  }), _void(), {
12003
13471
  kind: "mutation",
12004
13472
  auth: "admin"
13473
+ }), method(_void(), BackupEncryptionStatusSchema, { auth: "admin" }), method(object({}), object({
13474
+ keyId: string(),
13475
+ secretKey: string(),
13476
+ publicKey: string(),
13477
+ createdAt: number(),
13478
+ replacedKeyId: string().nullable()
13479
+ }), {
13480
+ kind: "mutation",
13481
+ auth: "admin"
13482
+ }), method(object({}), object({ disabledKeyId: string().nullable() }), {
13483
+ kind: "mutation",
13484
+ auth: "admin"
13485
+ }), method(object({ backupSecretKey: string() }), object({
13486
+ valid: boolean(),
13487
+ keyId: string().nullable(),
13488
+ /** The hub knows this key (active or retired). */
13489
+ known: boolean(),
13490
+ /** It is the key new archives are encrypted to. */
13491
+ active: boolean(),
13492
+ error: string().optional()
13493
+ }), {
13494
+ kind: "mutation",
13495
+ auth: "admin"
12005
13496
  }), method(object({
12006
13497
  destinationId: string(),
12007
13498
  backupId: string()
@@ -13727,7 +15218,60 @@ var CustomModelDescriptorSchema = object({
13727
15218
  stepId: string(),
13728
15219
  entry: ModelCatalogEntrySchema
13729
15220
  });
13730
- method(_void(), array(CustomModelDescriptorSchema).readonly(), { auth: "admin" });
15221
+ /** One regular file of an imported bundle, as the producer measured it. */
15222
+ var ModelBundleFileSchema = object({
15223
+ /** Relative path inside the bundle tar; an mlpackage member is `<x>.mlpackage/<member>`. */
15224
+ path: string().min(1),
15225
+ bytes: number().int().nonnegative(),
15226
+ sha256: string().regex(/^[0-9a-f]{64}$/)
15227
+ });
15228
+ var ImportModelBundleInputSchema = object({
15229
+ /** The registry provider that keeps the model (Model Studio). */
15230
+ addonId: string(),
15231
+ stepId: string().min(1),
15232
+ /**
15233
+ * The catalog rows to register, complete, every format URL already
15234
+ * `camstack-local://<modelId>/<file>` naming a file of the bundle. One
15235
+ * bundle may carry several rows (a base and its INT8 variant).
15236
+ */
15237
+ entries: array(ModelCatalogEntrySchema).min(1).max(4),
15238
+ /** The bundle tar, offered by the producer over `ctx.peerBytes` (same host). */
15239
+ bundle: object({
15240
+ ticket: PeerBytesTicketSchema,
15241
+ bytes: number().int().positive(),
15242
+ sha256: string().regex(/^[0-9a-f]{64}$/)
15243
+ }),
15244
+ /** Every file the tar must hold; anything missing, extra or different is refused. */
15245
+ files: array(ModelBundleFileSchema).min(1).max(64),
15246
+ /** Convert missing engine formats and push the model to every agent afterwards. */
15247
+ distribute: boolean()
15248
+ });
15249
+ var ImportModelBundleResultSchema = discriminatedUnion("kind", [object({
15250
+ kind: literal("imported"),
15251
+ modelIds: array(string()).readonly(),
15252
+ distributed: array(object({
15253
+ modelId: string(),
15254
+ nodeId: string(),
15255
+ format: _enum(MODEL_FORMATS),
15256
+ ok: boolean(),
15257
+ error: string().optional()
15258
+ })).readonly()
15259
+ }), object({
15260
+ kind: literal("refused"),
15261
+ reason: _enum([
15262
+ "transfer-failed",
15263
+ "checksum-mismatch",
15264
+ "bundle-mismatch",
15265
+ "invalid-entry",
15266
+ "id-taken"
15267
+ ]),
15268
+ detail: string()
15269
+ })]);
15270
+ method(_void(), array(CustomModelDescriptorSchema).readonly(), { auth: "admin" }), method(ImportModelBundleInputSchema, ImportModelBundleResultSchema, {
15271
+ kind: "mutation",
15272
+ auth: "admin",
15273
+ timeoutMs: 30 * 6e4
15274
+ });
13731
15275
  /**
13732
15276
  * Query filter for settings-store collections.
13733
15277
  */
@@ -14110,6 +15654,253 @@ id: union([string(), number()]) }), {
14110
15654
  kind: "mutation",
14111
15655
  auth: "admin"
14112
15656
  });
15657
+ /**
15658
+ * `keychain` — the hub's encrypted store of secret values (D787).
15659
+ *
15660
+ * Settings blobs never hold a secret: they hold a marker
15661
+ * `{"$secret":"secret://<owner>/<scope>/<fieldPath>","v":1}` and the value
15662
+ * lives here, AES-256-GCM under a data key that a master key wraps. This cap
15663
+ * is the OWNER's door to its own values: every method is owner-checked
15664
+ * against the CALLER, never against anything the caller claims.
15665
+ *
15666
+ * Who the caller is: the transport stamps `callerAddonId` into the args of a
15667
+ * call that crossed a process (the parent `LocalChildRegistry` from the UDS
15668
+ * connection, the agent from its child's connection carried in
15669
+ * `$hub-cap-fwd`'s envelope). A stamp always overwrites; a wire call with no
15670
+ * stamp has its claim stripped. Only a hub in-process caller may state its own
15671
+ * identity — `ctx.secrets` does that with the addon id closed over. This is
15672
+ * identity against BUGS and misrouting, not against a malicious addon (every
15673
+ * runner is the same OS user): see the threat model in
15674
+ * `docs/design/2026-10-08-secrets-keychain.md`.
15675
+ *
15676
+ * `callerAddonId` is deliberately NOT in any input schema: the tRPC router
15677
+ * parses the input, so a session can never supply it, and the internal mount
15678
+ * floors every method to admin anyway (D240).
15679
+ *
15680
+ * Internal: addons reach it through `ctx.secrets`, never directly.
15681
+ */
15682
+ /** Why a value cannot be served right now. Never folded into "missing". */
15683
+ var KeychainUnavailableReasonSchema = _enum([
15684
+ "key-missing",
15685
+ "wrong-key",
15686
+ "key-file-unreadable",
15687
+ "store-unavailable",
15688
+ "not-initialized",
15689
+ "decrypt-failed"
15690
+ ]);
15691
+ var KeychainStateSchema = discriminatedUnion("state", [object({ state: literal("ready") }), object({
15692
+ state: literal("locked"),
15693
+ reason: KeychainUnavailableReasonSchema
15694
+ })]);
15695
+ var KeychainResolveEntrySchema = discriminatedUnion("kind", [
15696
+ object({
15697
+ kind: literal("value"),
15698
+ value: string(),
15699
+ version: number().int()
15700
+ }),
15701
+ object({ kind: literal("missing") }),
15702
+ object({
15703
+ kind: literal("unavailable"),
15704
+ reason: KeychainUnavailableReasonSchema
15705
+ }),
15706
+ object({ kind: literal("forbidden") })
15707
+ ]);
15708
+ var KeychainResolveResultSchema = record(string(), KeychainResolveEntrySchema);
15709
+ /** Metadata of one stored value — never the value. */
15710
+ var KeychainSecretMetaSchema = object({
15711
+ ref: string(),
15712
+ owner: string(),
15713
+ /** Formatted scope (`global`, `node/<id>`, `device/<id>`, …). */
15714
+ scope: string(),
15715
+ fieldPath: string(),
15716
+ version: number().int(),
15717
+ createdAt: number(),
15718
+ updatedAt: number(),
15719
+ /** `addon:<id>` | `user:<id>` | `system`. */
15720
+ updatedBy: string(),
15721
+ /** Coarse — written at most once an hour per ref. `null` = never read. */
15722
+ lastReadAt: number().nullable()
15723
+ });
15724
+ var RefListSchema = array(string().min(1)).max(512);
15725
+ method(object({
15726
+ ref: string().min(1),
15727
+ value: string().min(1)
15728
+ }), object({
15729
+ ref: string(),
15730
+ version: number().int()
15731
+ }), {
15732
+ kind: "mutation",
15733
+ auth: "admin"
15734
+ }), method(object({ refs: RefListSchema }), KeychainResolveResultSchema, { auth: "admin" }), method(object({ refs: RefListSchema }), object({ deleted: number().int() }), {
15735
+ kind: "mutation",
15736
+ auth: "admin"
15737
+ }), method(object({}), array(KeychainSecretMetaSchema).readonly(), { auth: "admin" }), method(object({}), KeychainStateSchema, { auth: "admin" });
15738
+ var KeychainKeySourceSchema = object({
15739
+ kind: _enum([
15740
+ "config-file",
15741
+ "previous-config-file",
15742
+ "platform",
15743
+ "default-file"
15744
+ ]),
15745
+ /** File sources only — a path is not a secret. */
15746
+ path: string().optional(),
15747
+ /**
15748
+ * True when a whole-volume backup of the data directory carries this key
15749
+ * next to the database it protects (the default file). The page warns.
15750
+ */
15751
+ sharesBackupWithDatabase: boolean()
15752
+ });
15753
+ /**
15754
+ * One keychain reset, as the Secrets page reports it until the operator
15755
+ * acknowledges it. Never a value: refs, counts and table names only.
15756
+ */
15757
+ var KeychainResetRecordSchema = object({
15758
+ id: string(),
15759
+ at: number(),
15760
+ /** `user:<id>` or {@link KEYCHAIN_RESET_TRIGGER_ACTOR}. */
15761
+ actor: string(),
15762
+ /** Why the keychain was locked when it was reset; `null` when it was not locked. */
15763
+ lockedReason: string().nullable(),
15764
+ /** Values moved into the archive table (ciphertext under the lost key). */
15765
+ archived: number().int(),
15766
+ /** `keychain:secrets-orphaned-<ts>`, or `null` when nothing was stored. */
15767
+ archivedCollection: string().nullable(),
15768
+ /**
15769
+ * `keychain:keys-orphaned-<ts>`: the wrapped data keys of the archive, kept
15770
+ * so the archive can still be opened if the lost master key turns up.
15771
+ */
15772
+ archivedKeysCollection: string().nullable(),
15773
+ /**
15774
+ * `system-settings` keys whose marker the reset cleared — the cluster
15775
+ * secret's: a marker left pointing at an archived value would refuse every
15776
+ * agent forever (D797).
15777
+ */
15778
+ clearedSettingsKeys: array(string()).readonly(),
15779
+ /** When an operator dismissed the notice on the Secrets page; `null` until then. */
15780
+ acknowledgedAt: number().nullable()
15781
+ });
15782
+ var KeychainStatusSchema = object({
15783
+ keychain: KeychainStateSchema,
15784
+ /** The source of the master key in use; `null` while locked. */
15785
+ keySource: KeychainKeySourceSchema.nullable(),
15786
+ /** The source configured to be primary — differs from `keySource` while a rotation is pending. */
15787
+ configuredSource: KeychainKeySourceSchema,
15788
+ /** Short fingerprint of the master key in use (`HMAC(KEK, label)`, 16 hex). */
15789
+ fingerprint: string().nullable(),
15790
+ activeKeyId: string().nullable(),
15791
+ /**
15792
+ * The keychain unlocked with a NON-primary source: the configured primary
15793
+ * key is not the one that wraps the data key yet. `rotateMasterKey` moves it.
15794
+ */
15795
+ rotationPending: boolean(),
15796
+ /** Wrapped copies of the data key under a previous master key, kept until purged. */
15797
+ retiredWraps: number().int(),
15798
+ recoveryKeyDownloadedAt: number().nullable(),
15799
+ secretCount: number().int(),
15800
+ /** The most recent reset, acknowledged or not; `null` when the keychain was never reset. */
15801
+ lastReset: KeychainResetRecordSchema.nullable()
15802
+ });
15803
+ /**
15804
+ * Whether a stored value is still pointed at by its owner's settings.
15805
+ * `unknown` is a first-class answer: a scope whose blob could not be read is
15806
+ * never reported as an orphan (and never deleted as one).
15807
+ */
15808
+ var KeychainSecretUsageSchema = _enum([
15809
+ "in-use",
15810
+ "orphan",
15811
+ "unknown"
15812
+ ]);
15813
+ var KeychainAdminSecretSchema = KeychainSecretMetaSchema.extend({ usage: KeychainSecretUsageSchema });
15814
+ var KeychainAuditActionSchema = _enum([
15815
+ "put",
15816
+ "delete",
15817
+ "reveal",
15818
+ "rotate-master-key",
15819
+ "purge-retired-keys",
15820
+ "download-recovery-key",
15821
+ "delete-orphans",
15822
+ "reset",
15823
+ "acknowledge-reset",
15824
+ "initialize"
15825
+ ]);
15826
+ var KeychainAuditEntrySchema = object({
15827
+ id: string(),
15828
+ at: number(),
15829
+ action: KeychainAuditActionSchema,
15830
+ /** `addon:<id>` | `user:<id>` | `system` | `trigger-file`. */
15831
+ actor: string(),
15832
+ ref: string().nullable(),
15833
+ detail: string().nullable()
15834
+ });
15835
+ var KEYCHAIN_RESET_CONFIRMATION = "RESET KEYCHAIN";
15836
+ /**
15837
+ * Secrets the HUB itself holds (owner `system`) that no settings form shows:
15838
+ * `jwt-signing-key` — the session signing key (D797). It is always "in use",
15839
+ * never an orphan; it is generated on a fresh hub and replaced only through
15840
+ * {@link keychainAdminCapability.methods.setSystemSecret}.
15841
+ */
15842
+ var SystemHeldSecretNameSchema = _enum(["jwt-signing-key"]);
15843
+ 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({
15844
+ value: string(),
15845
+ version: number().int()
15846
+ }), {
15847
+ kind: "mutation",
15848
+ auth: "admin",
15849
+ caller: "required"
15850
+ }), method(object({
15851
+ name: SystemHeldSecretNameSchema,
15852
+ value: string().min(16)
15853
+ }), object({
15854
+ ref: string(),
15855
+ version: number().int()
15856
+ }), {
15857
+ kind: "mutation",
15858
+ auth: "admin",
15859
+ caller: "required"
15860
+ }), method(object({ refs: array(string().min(1)).max(1e3) }), object({
15861
+ deleted: array(string()).readonly(),
15862
+ kept: array(object({
15863
+ ref: string(),
15864
+ usage: KeychainSecretUsageSchema
15865
+ })).readonly()
15866
+ }), {
15867
+ kind: "mutation",
15868
+ auth: "admin",
15869
+ caller: "required"
15870
+ }), method(object({}), object({
15871
+ fingerprint: string(),
15872
+ keySource: KeychainKeySourceSchema
15873
+ }), {
15874
+ kind: "mutation",
15875
+ auth: "admin",
15876
+ caller: "required"
15877
+ }), method(object({}), object({ purged: number().int() }), {
15878
+ kind: "mutation",
15879
+ auth: "admin",
15880
+ caller: "required"
15881
+ }), method(object({}), object({
15882
+ key: string(),
15883
+ fingerprint: string(),
15884
+ keySource: KeychainKeySourceSchema
15885
+ }), {
15886
+ kind: "mutation",
15887
+ auth: "admin",
15888
+ caller: "required"
15889
+ }), method(object({ confirm: literal(KEYCHAIN_RESET_CONFIRMATION) }), object({
15890
+ archivedCollection: string().nullable(),
15891
+ archived: number().int()
15892
+ }), {
15893
+ kind: "mutation",
15894
+ auth: "admin",
15895
+ caller: "required"
15896
+ }), method(object({}), object({
15897
+ reset: KeychainResetRecordSchema.nullable(),
15898
+ pendingReentry: array(KeychainSecretMetaSchema).readonly()
15899
+ }), { auth: "admin" }), method(object({}), object({ acknowledged: boolean() }), {
15900
+ kind: "mutation",
15901
+ auth: "admin",
15902
+ caller: "required"
15903
+ });
14113
15904
  method(_void(), object({
14114
15905
  id: string(),
14115
15906
  name: string(),
@@ -15352,7 +17143,11 @@ var DeviceRegisterPayloadSchema = object({
15352
17143
  var DeviceRemovePayloadSchema = object({ deviceId: number() });
15353
17144
  var DevicePersistConfigPayloadSchema = object({
15354
17145
  deviceId: number(),
15355
- data: record(string(), unknown())
17146
+ data: record(string(), unknown()),
17147
+ /** The paths the device's schema declares secret (D783), when the caller
17148
+ * knows them — those values are kept in the keychain, not the blob (D787).
17149
+ * Absent: the paths the device last reported at `registerDevice` apply. */
17150
+ secretConfigPaths: array(string()).optional()
15356
17151
  });
15357
17152
  /** What a migration actually did, per switch. `unreachable` is a first-class
15358
17153
  * answer: a camera that could not be asked is not a camera that was silenced. */
@@ -16955,7 +18750,7 @@ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
16955
18750
  * `login-method` — collection cap through which auth addons contribute
16956
18751
  * their pre-auth login surfaces to the login page. This is the SINGLE,
16957
18752
  * generic mechanism that supersedes the dead `auth.listProviders` reader:
16958
- * every auth addon (OIDC, magic-link, WebAuthn/passkey) registers a
18753
+ * every auth addon (OIDC, WebAuthn/passkey) registers a
16959
18754
  * `login-method` provider and the PUBLIC `auth.listLoginMethods`
16960
18755
  * procedure aggregates them for the unauthenticated login page.
16961
18756
  *
@@ -16963,8 +18758,7 @@ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
16963
18758
  *
16964
18759
  * - `redirect` — a declarative button. The login page renders a generic
16965
18760
  * button that navigates to `startUrl` (an addon-owned HTTP route).
16966
- * Covers OIDC (`/addon/auth-oidc/<id>/start`) and magic-link with
16967
- * ZERO shell-side JS. A future SSO addon plugs in the same way — the
18761
+ * Covers OIDC (`/addon/auth-oidc/<id>/start`) with ZERO shell-side JS. A future SSO addon plugs in the same way — the
16968
18762
  * login page needs NO change.
16969
18763
  *
16970
18764
  * - `widget` — a Module-Federation widget the login page mounts (via
@@ -16983,8 +18777,8 @@ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
16983
18777
  * decision.
16984
18778
  *
16985
18779
  * Every contribution carries a `stage`:
16986
- * - `primary` — shown on the first credentials screen (OIDC /
16987
- * magic-link buttons; a future usernameless passkey).
18780
+ * - `primary` — shown on the first credentials screen (OIDC
18781
+ * buttons; a usernameless passkey).
16988
18782
  * - `second-factor` — shown AFTER the password leg, gated on the
16989
18783
  * returned `factors` (passkey-as-2FA today).
16990
18784
  *
@@ -17011,7 +18805,7 @@ var LoginMethodContributionSchema = discriminatedUnion("kind", [
17011
18805
  * The provider names an external identity a signed-in user can link to
17012
18806
  * their own account (D782): `auth.listLinkableProviders` /
17013
18807
  * `beginExternalLink` offer exactly the redirect methods that set this,
17014
- * whatever their id. Absent / false — a login button only (magic-link).
18808
+ * whatever their id. Absent / false — a login button only.
17015
18809
  */
17016
18810
  linkable: boolean().optional()
17017
18811
  }),
@@ -20866,8 +22660,7 @@ method(object({}), object({ rules: array(NcRuleSchema) }), { auth: "admin" }), m
20866
22660
  * `super_admin` — collapsed onto the single boolean because every
20867
22661
  * non-admin caller is governed by the same scope-check rules; the
20868
22662
  * distinction was only ever used to route role-specific procedures
20869
- * which we no longer have. Agents are admin sessions issued via
20870
- * `createServiceToken`; CLI / webhook integrations are `cst_*` tokens
22663
+ * which we no longer have. CLI / webhook integrations are `cst_*` tokens
20871
22664
  * with `isAdmin: false` + an explicit scope list.
20872
22665
  */
20873
22666
  /** Per-method access flavour. Materialised on every cap method via codegen. */
@@ -22369,8 +24162,23 @@ var RetrainMacroClassSchema = _enum([
22369
24162
  ]);
22370
24163
  /** A subject to learn, or a phantom to unlearn (taught by OMISSION). */
22371
24164
  var RetrainAnnotationKindSchema = _enum(["subject", "model_error"]);
22372
- /** Did a human draw this box, or did the assist propose it? */
22373
- var RetrainAnnotationSourceSchema = _enum(["operator", "assist"]);
24165
+ /**
24166
+ * Where a box came from. A machine-sourced box is a DRAFT on the page until
24167
+ * the operator confirms it; once saved it keeps its source as provenance.
24168
+ *
24169
+ * - `operator` — drawn by hand.
24170
+ * - `assist` — proposed by a detector run on the copy (the camera's own
24171
+ * model, or a larger teacher model).
24172
+ * - `pipeline` — the box the live pipeline actually drew on that frame, read
24173
+ * back from the track store (never a re-run).
24174
+ * - `llm` — proposed by a vision-capable LLM profile.
24175
+ */
24176
+ var RetrainAnnotationSourceSchema = _enum([
24177
+ "operator",
24178
+ "assist",
24179
+ "pipeline",
24180
+ "llm"
24181
+ ]);
22374
24182
  /** Normalised `[0,1]` rectangle against the FULL frame — the canonical form. */
22375
24183
  var RetrainBboxSchema = object({
22376
24184
  x: number(),
@@ -22388,7 +24196,8 @@ var RetrainBboxSchema = object({
22388
24196
  */
22389
24197
  var RetrainAnnotationSchema = object({
22390
24198
  id: string(),
22391
- trackId: string(),
24199
+ /** The frame's track. Absent on a recording still, which has none. */
24200
+ trackId: string().optional(),
22392
24201
  deviceId: number(),
22393
24202
  /** The COPY in retrain storage — never the source track's media key. */
22394
24203
  mediaKey: string(),
@@ -22437,13 +24246,47 @@ var RetrainFrameCandidateSchema = object({
22437
24246
  * fail, whatever became of the original. */
22438
24247
  copied: boolean()
22439
24248
  });
24249
+ /**
24250
+ * One box the live pipeline drew on a copied frame — what a correction starts
24251
+ * from. Derived when the frame is listed, from the track store: the subject
24252
+ * box recorded on the source media row when there is one, else the track
24253
+ * position nearest the frame's capture time. Never stored as an annotation
24254
+ * until the operator confirms it.
24255
+ */
24256
+ var RetrainPipelineBoxSchema = object({
24257
+ /** Normalised `[0,1]` against the full frame. */
24258
+ bbox: RetrainBboxSchema,
24259
+ macroClass: RetrainMacroClassSchema,
24260
+ label: string().optional(),
24261
+ subLabel: string().optional(),
24262
+ /** The detection score of the position used, when it was recorded. */
24263
+ score: number().optional(),
24264
+ /** The root model that produced the track, when it was recorded. */
24265
+ modelId: string().optional(),
24266
+ trackId: string(),
24267
+ /** `subject-box`: recorded on this very frame. `position`: the track's
24268
+ * position nearest the capture time, `deltaMs` away. */
24269
+ basis: _enum(["subject-box", "position"]),
24270
+ deltaMs: number()
24271
+ });
24272
+ /**
24273
+ * Where a retrain frame came from: a TRACK's stored media (copy-on-select),
24274
+ * or the RECORDING at an instant — the frame a model saw nothing in has no
24275
+ * track at all.
24276
+ */
24277
+ var RetrainFrameOriginSchema = _enum(["track", "recording"]);
22440
24278
  /** A frame the dataset OWNS: bytes copied at selection time. */
22441
24279
  var RetrainFrameSchema = object({
22442
24280
  frameId: string(),
22443
24281
  deviceId: number(),
22444
- trackId: string(),
22445
- /** Provenance only. It may already point at nothing — that is expected. */
22446
- sourceMediaId: number().int(),
24282
+ origin: RetrainFrameOriginSchema,
24283
+ /** The track it was copied from. Absent on a recording still. */
24284
+ trackId: string().optional(),
24285
+ /** Provenance only. It may already point at nothing — that is expected.
24286
+ * Absent on a recording still. */
24287
+ sourceMediaId: number().int().optional(),
24288
+ /** A recording still: the playhead instant it was taken at. */
24289
+ epochMs: number().optional(),
22447
24290
  sourceKind: MediaFileKindEnum,
22448
24291
  sizeBytes: number().int(),
22449
24292
  width: number().int(),
@@ -22454,7 +24297,12 @@ var RetrainFrameSchema = object({
22454
24297
  /** The operator's "every subject in this frame is boxed". Detector
22455
24298
  * evaluation keeps only complete frames: an unboxed subject would count as
22456
24299
  * a false positive. */
22457
- complete: boolean()
24300
+ complete: boolean(),
24301
+ /** The boxes the pipeline drew on this frame. Present on list answers;
24302
+ * empty when nothing the track store holds can be placed on it. */
24303
+ pipelineBoxes: array(RetrainPipelineBoxSchema).readonly().optional(),
24304
+ /** The named collections this frame belongs to. Present on list answers. */
24305
+ collectionIds: array(string()).readonly().optional()
22458
24306
  });
22459
24307
  /** Why a copy-on-select could not be honoured — named, never a silent skip. */
22460
24308
  var RetrainCopyRefusalSchema = _enum([
@@ -22485,6 +24333,11 @@ var RetrainFrameListSchema = object({
22485
24333
  var RetrainExportFilterSchema = object({
22486
24334
  deviceIds: array(number()).optional(),
22487
24335
  frameIds: array(string()).max(2e4).optional(),
24336
+ /** Only frames in at least one of these named collections. */
24337
+ collectionIds: array(string()).max(200).optional(),
24338
+ /** Exactly the frames of this dataset version (and its completeOnly). An
24339
+ * unknown id selects nothing. */
24340
+ datasetVersionId: string().optional(),
22488
24341
  batchId: string().optional(),
22489
24342
  /** Only frames the operator marked complete (all subjects boxed). */
22490
24343
  completeOnly: boolean().optional()
@@ -22549,6 +24402,170 @@ var RetrainAssistResultSchema = discriminatedUnion("kind", [object({
22549
24402
  reason: string(),
22550
24403
  detail: string().optional()
22551
24404
  })]);
24405
+ /** A named set over the retrain corpus — membership only, it owns no pixels. */
24406
+ var RetrainCollectionSchema = object({
24407
+ id: string(),
24408
+ name: string(),
24409
+ createdAt: number(),
24410
+ frameCount: number().int()
24411
+ });
24412
+ var RetrainCollectionCreateResultSchema = discriminatedUnion("kind", [object({
24413
+ kind: literal("created"),
24414
+ collection: RetrainCollectionSchema
24415
+ }), object({
24416
+ kind: literal("refused"),
24417
+ reason: _enum(["empty-name", "duplicate-name"])
24418
+ })]);
24419
+ var RetrainCollectionRenameResultSchema = discriminatedUnion("kind", [object({
24420
+ kind: literal("renamed"),
24421
+ collection: RetrainCollectionSchema
24422
+ }), object({
24423
+ kind: literal("refused"),
24424
+ reason: _enum([
24425
+ "empty-name",
24426
+ "duplicate-name",
24427
+ "unknown-collection"
24428
+ ])
24429
+ })]);
24430
+ /**
24431
+ * The outcome of adding the frame at a recording instant. Every refusal is
24432
+ * named: `still-unavailable` (not recording, a gap, or an undecodable frame —
24433
+ * `detail` says which), `still-busy` (the recorder is at its decode bound; try
24434
+ * again), `unreadable-image`, `write-failed`, `unknown-collection`.
24435
+ */
24436
+ var AddRetrainFrameFromRecordingResultSchema = discriminatedUnion("kind", [object({
24437
+ kind: literal("added"),
24438
+ collectionId: string(),
24439
+ frame: RetrainFrameSchema,
24440
+ /** The moment was already in the dataset; nothing was decoded. */
24441
+ reused: boolean()
24442
+ }), object({
24443
+ kind: literal("refused"),
24444
+ reason: _enum([
24445
+ "unknown-collection",
24446
+ "still-unavailable",
24447
+ "still-busy",
24448
+ "unreadable-image",
24449
+ "write-failed"
24450
+ ]),
24451
+ detail: string().optional()
24452
+ })]);
24453
+ /** A vision LLM profile the AI assist may use, and where it sends the frame. */
24454
+ var RetrainAssistProfileSchema = object({
24455
+ id: string(),
24456
+ name: string(),
24457
+ model: string(),
24458
+ kind: string(),
24459
+ /** `true` when the frame would leave the house (a cloud vendor, or an
24460
+ * endpoint that is not on the local network). The page confirms each such
24461
+ * run, and the provider refuses one without `allowCloud`. */
24462
+ leavesHouse: boolean()
24463
+ });
24464
+ /** A box the AI assist proposed: a draft, plus the model's own reason. */
24465
+ var RetrainLlmProposalSchema = RetrainAnnotationDraftSchema.extend({ reason: string() });
24466
+ /** What the AI assist said about a box that was already on the canvas. */
24467
+ var RetrainLlmReviewSchema = object({
24468
+ /** The `ref` the page sent the box under. */
24469
+ ref: string(),
24470
+ verdict: _enum([
24471
+ "confirmed",
24472
+ "wrong-class",
24473
+ "not-an-object",
24474
+ "uncertain"
24475
+ ]),
24476
+ suggestedClass: RetrainMacroClassSchema.optional(),
24477
+ reason: string()
24478
+ });
24479
+ /**
24480
+ * The AI assist's answer. `proposed` carries drafts (`source: 'llm'`, the
24481
+ * model and its confidence) and reviews; items the model got wrong (a box off
24482
+ * the frame, an unasked class, an unknown ref) are dropped and counted in
24483
+ * `rejected`. A whole answer that is not the schema is `malformed-answer`.
24484
+ */
24485
+ var RetrainLlmAssistResultSchema = discriminatedUnion("kind", [object({
24486
+ kind: literal("proposed"),
24487
+ profileId: string(),
24488
+ model: string(),
24489
+ /** The frame was sent outside the house for this answer. */
24490
+ leftHouse: boolean(),
24491
+ proposals: array(RetrainLlmProposalSchema).readonly(),
24492
+ reviews: array(RetrainLlmReviewSchema).readonly(),
24493
+ rejected: number().int()
24494
+ }), object({
24495
+ kind: literal("refused"),
24496
+ reason: _enum([
24497
+ "unknown-frame",
24498
+ "unreadable-frame",
24499
+ "unknown-profile",
24500
+ "profile-disabled",
24501
+ "no-vision",
24502
+ "cloud-not-confirmed",
24503
+ "llm-error",
24504
+ "malformed-answer"
24505
+ ]),
24506
+ detail: string().optional()
24507
+ })]);
24508
+ /** What a dataset version is cut from. Every field narrows. */
24509
+ var RetrainDatasetSelectionSchema = object({
24510
+ deviceIds: array(number()).readonly().optional(),
24511
+ collectionIds: array(string()).max(200).readonly().optional(),
24512
+ frameIds: array(string()).max(2e4).readonly().optional()
24513
+ });
24514
+ /** The counts a dataset is judged by. */
24515
+ var RetrainDatasetStatsSchema = object({
24516
+ frames: number().int(),
24517
+ completeFrames: number().int(),
24518
+ /** `completeFrames / frames`, 0..1. */
24519
+ completeness: number(),
24520
+ /** Boxes to learn (model errors excluded). */
24521
+ subjects: number().int(),
24522
+ modelErrors: number().int(),
24523
+ /** Complete frames with no subject. */
24524
+ hardNegatives: number().int(),
24525
+ /** Subjects per class × camera × day/night. */
24526
+ cells: array(object({
24527
+ macroClass: string(),
24528
+ deviceId: number(),
24529
+ lighting: _enum([
24530
+ "day",
24531
+ "night",
24532
+ "unknown"
24533
+ ]),
24534
+ subjects: number().int(),
24535
+ frames: number().int()
24536
+ })).readonly(),
24537
+ cameras: array(object({
24538
+ deviceId: number(),
24539
+ frames: number().int(),
24540
+ completeFrames: number().int()
24541
+ })).readonly()
24542
+ });
24543
+ /** An immutable dataset version, without its frame list. */
24544
+ var RetrainDatasetVersionSchema = object({
24545
+ id: string(),
24546
+ name: string(),
24547
+ createdAt: number(),
24548
+ selection: RetrainDatasetSelectionSchema,
24549
+ layout: RetrainExportLayoutSchema,
24550
+ completeOnly: boolean(),
24551
+ frameCount: number().int(),
24552
+ /** sha256 of what the frames taught when the version was frozen. */
24553
+ annotationHash: string(),
24554
+ /** The export manifest schema the version was cut under. */
24555
+ manifestSchema: string(),
24556
+ stats: RetrainDatasetStatsSchema
24557
+ });
24558
+ var CreateRetrainDatasetVersionResultSchema = discriminatedUnion("kind", [object({
24559
+ kind: literal("created"),
24560
+ version: RetrainDatasetVersionSchema
24561
+ }), object({
24562
+ kind: literal("refused"),
24563
+ reason: _enum([
24564
+ "empty-name",
24565
+ "duplicate-name",
24566
+ "no-frames"
24567
+ ])
24568
+ })]);
22552
24569
  /** The outcome of a lifecycle move owned by the retrain page. */
22553
24570
  var RetrainTransitionResultSchema = object({
22554
24571
  trackId: string(),
@@ -23266,7 +25283,7 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
23266
25283
  auth: "admin"
23267
25284
  }), method(object({
23268
25285
  deviceId: number(),
23269
- trackId: string(),
25286
+ trackId: string().optional(),
23270
25287
  frameId: string()
23271
25288
  }), object({
23272
25289
  removed: boolean(),
@@ -23283,7 +25300,8 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
23283
25300
  auth: "admin"
23284
25301
  }), method(object({
23285
25302
  deviceId: number(),
23286
- trackId: string(),
25303
+ /** The frame's track, when it has one — checked against the frame. */
25304
+ trackId: string().optional(),
23287
25305
  frameId: string(),
23288
25306
  subject: RetrainAssistSubjectSchema,
23289
25307
  /** Which node runs it. Absent ⇒ wherever an unowned call lands. */
@@ -23291,12 +25309,16 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
23291
25309
  }), RetrainAssistResultSchema, {
23292
25310
  kind: "mutation",
23293
25311
  auth: "admin"
23294
- }), method(object({ trackId: string() }), array(RetrainAnnotationSchema).readonly(), {
25312
+ }), method(object({
25313
+ trackId: string().optional(),
25314
+ frameIds: array(string()).max(2e3).optional()
25315
+ }), array(RetrainAnnotationSchema).readonly(), {
23295
25316
  kind: "query",
23296
25317
  auth: "admin"
23297
25318
  }), method(object({
23298
25319
  deviceId: number(),
23299
- trackId: string(),
25320
+ /** The frame's track, when it has one — checked against the frame. */
25321
+ trackId: string().optional(),
23300
25322
  frameId: string(),
23301
25323
  annotations: array(RetrainAnnotationDraftSchema)
23302
25324
  }), array(RetrainAnnotationSchema).readonly(), {
@@ -23319,7 +25341,7 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
23319
25341
  auth: "admin"
23320
25342
  }), method(object({
23321
25343
  deviceId: number(),
23322
- trackId: string(),
25344
+ trackId: string().optional(),
23323
25345
  frameId: string(),
23324
25346
  complete: boolean()
23325
25347
  }), RetrainFrameSchema, {
@@ -23333,6 +25355,115 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
23333
25355
  kind: "mutation",
23334
25356
  auth: "admin",
23335
25357
  timeoutMs: 60 * 6e4
25358
+ }), method(object({
25359
+ filter: RetrainExportFilterSchema,
25360
+ layout: RetrainExportLayoutSchema
25361
+ }), object({
25362
+ ticket: PeerBytesTicketSchema,
25363
+ frames: number().int(),
25364
+ annotations: number().int()
25365
+ }), {
25366
+ kind: "mutation",
25367
+ auth: "admin",
25368
+ timeoutMs: 12e4
25369
+ }), method(object({
25370
+ selection: RetrainDatasetSelectionSchema,
25371
+ completeOnly: boolean().optional()
25372
+ }), RetrainDatasetStatsSchema, {
25373
+ kind: "query",
25374
+ auth: "admin"
25375
+ }), method(object({
25376
+ name: string().max(120),
25377
+ selection: RetrainDatasetSelectionSchema,
25378
+ layout: RetrainExportLayoutSchema,
25379
+ completeOnly: boolean()
25380
+ }), CreateRetrainDatasetVersionResultSchema, {
25381
+ kind: "mutation",
25382
+ auth: "admin",
25383
+ timeoutMs: 12e4
25384
+ }), method(object({}), array(RetrainDatasetVersionSchema).readonly(), {
25385
+ kind: "query",
25386
+ auth: "admin"
25387
+ }), method(object({ id: string() }), object({ deleted: boolean() }), {
25388
+ kind: "mutation",
25389
+ auth: "admin"
25390
+ }), method(object({ id: string() }), object({
25391
+ found: boolean(),
25392
+ annotationHash: string(),
25393
+ matches: boolean(),
25394
+ missingFrames: number().int()
25395
+ }), {
25396
+ kind: "query",
25397
+ auth: "admin",
25398
+ timeoutMs: 12e4
25399
+ }), method(object({}), array(RetrainAssistProfileSchema).readonly(), {
25400
+ kind: "query",
25401
+ auth: "admin"
25402
+ }), method(object({
25403
+ deviceId: number(),
25404
+ trackId: string().optional(),
25405
+ frameId: string(),
25406
+ profileId: string(),
25407
+ classes: array(RetrainMacroClassSchema).min(1),
25408
+ boxes: array(object({
25409
+ ref: string(),
25410
+ bbox: RetrainBboxSchema,
25411
+ macroClass: RetrainMacroClassSchema,
25412
+ label: string().optional()
25413
+ })).max(50),
25414
+ allowCloud: boolean()
25415
+ }), RetrainLlmAssistResultSchema, {
25416
+ kind: "mutation",
25417
+ auth: "admin",
25418
+ timeoutMs: 18e4
25419
+ }), method(object({ name: string().max(120) }), RetrainCollectionCreateResultSchema, {
25420
+ kind: "mutation",
25421
+ auth: "admin"
25422
+ }), method(object({}), array(RetrainCollectionSchema).readonly(), {
25423
+ kind: "query",
25424
+ auth: "admin"
25425
+ }), method(object({
25426
+ id: string(),
25427
+ name: string().max(120)
25428
+ }), RetrainCollectionRenameResultSchema, {
25429
+ kind: "mutation",
25430
+ auth: "admin"
25431
+ }), method(object({ id: string() }), object({
25432
+ deleted: boolean(),
25433
+ removedFrames: number().int()
25434
+ }), {
25435
+ kind: "mutation",
25436
+ auth: "admin"
25437
+ }), method(object({
25438
+ collectionId: string(),
25439
+ deviceId: number(),
25440
+ epochMs: number()
25441
+ }), AddRetrainFrameFromRecordingResultSchema, {
25442
+ kind: "mutation",
25443
+ auth: "admin",
25444
+ timeoutMs: 6e4
25445
+ }), method(object({
25446
+ collectionId: string(),
25447
+ frameIds: array(string()).min(1).max(500)
25448
+ }), object({
25449
+ added: number().int(),
25450
+ alreadyMember: number().int(),
25451
+ unknownFrameIds: array(string()).readonly()
25452
+ }), {
25453
+ kind: "mutation",
25454
+ auth: "admin"
25455
+ }), method(object({
25456
+ collectionId: string(),
25457
+ frameId: string()
25458
+ }), object({
25459
+ removed: boolean(),
25460
+ deletedFrame: boolean()
25461
+ }), {
25462
+ kind: "mutation",
25463
+ auth: "admin"
25464
+ }), method(object({ collectionId: string() }), array(RetrainFrameSchema).readonly(), {
25465
+ kind: "query",
25466
+ auth: "admin"
23336
25467
  }), method(object({
23337
25468
  /** Which of the three event tables owns the row. */
23338
25469
  ownerType: EventOwnerTypeSchema,
@@ -23956,13 +26087,31 @@ var RecommendationReasonSchema = discriminatedUnion("kind", [
23956
26087
  object({
23957
26088
  kind: literal("no-family-build"),
23958
26089
  format: ModelFormatSchema$1
26090
+ }),
26091
+ object({
26092
+ kind: literal("kept-custom-pin"),
26093
+ modelId: string(),
26094
+ deviceKey: string()
23959
26095
  })
23960
26096
  ]);
26097
+ /** Why a device is left exactly as it is, whatever the plan would pick (D786). */
26098
+ var KeptReasonSchema = _enum(["custom-pin"]);
26099
+ /**
26100
+ * Where a choice's latency came from (D791): this node's own benchmark
26101
+ * result, or the hardware-class table. Measured on the node beats the table.
26102
+ */
26103
+ var LatencySourceSchema = discriminatedUnion("kind", [object({ kind: literal("table") }), object({
26104
+ kind: literal("node-benchmark"),
26105
+ resultId: string(),
26106
+ measuredAtMs: number()
26107
+ })]);
23961
26108
  var DeviceModelChoiceSchema = object({
23962
26109
  modelId: string(),
23963
26110
  p50Ms: number(),
23964
26111
  fps: number(),
23965
26112
  measured: boolean(),
26113
+ /** Absent on a plan from before D791 — read as the table. */
26114
+ source: LatencySourceSchema.optional(),
23966
26115
  /** Parallel sessions at the camera rate with the headroom kept free: ⌊fps × (1 − headroom) / camera fps⌋. */
23967
26116
  capacitySessions: number(),
23968
26117
  personRecall: number()
@@ -23973,6 +26122,8 @@ var DeviceRecommendationSchema = object({
23973
26122
  enabled: boolean(),
23974
26123
  available: boolean(),
23975
26124
  chosen: DeviceModelChoiceSchema.nullable(),
26125
+ /** Present when the device is kept as is: Apply writes nothing on it. */
26126
+ kept: KeptReasonSchema.optional(),
23976
26127
  reasons: array(RecommendationReasonSchema).readonly()
23977
26128
  });
23978
26129
  var NodeRecommendationSchema = object({
@@ -24026,6 +26177,17 @@ var AutoTuneWarningSchema = discriminatedUnion("kind", [
24026
26177
  kind: literal("coral-enabled"),
24027
26178
  nodeId: string(),
24028
26179
  deviceKey: string()
26180
+ }),
26181
+ object({
26182
+ kind: literal("custom-pin-kept"),
26183
+ nodeId: string(),
26184
+ deviceKey: string().nullable(),
26185
+ deviceId: number().nullable(),
26186
+ modelId: string()
26187
+ }),
26188
+ object({
26189
+ kind: literal("custom-registry-unreadable"),
26190
+ error: string()
24029
26191
  })
24030
26192
  ]);
24031
26193
  var AutoTuneOptionsSchema = object({
@@ -24204,13 +26366,14 @@ var SuggestSharesResultSchema = object({
24204
26366
  nodes: array(SuggestedNodeShareSchema).readonly()
24205
26367
  });
24206
26368
  /**
24207
- * Where the node and device shares come from (D750, D755).
24208
- * - `hardware` (default) — computed by the system from each node's static
24209
- * capacity (its accelerators at their Auto tune models, from the measured
24210
- * latency table), recomputed whenever a node or device joins, leaves, is
24211
- * switched on or off, or changes model. No load input.
24212
- * - `benchmark` — the same, from each node's measured capacity (node
24213
- * benchmark results); a node without results falls back to `hardware`.
26369
+ * Where the node and device shares come from (D750, D755, D791).
26370
+ * - `benchmark` (default since D791) — each node's capacity as its own node
26371
+ * benchmark measured it; a node without fresh results is sized from
26372
+ * `hardware` and says so. Measured on the node beats the table.
26373
+ * - `hardware` — computed from each node's static capacity only (its
26374
+ * accelerators at their Auto tune models, from the latency table).
26375
+ * Both are recomputed whenever a node or device joins, leaves, is switched
26376
+ * on or off, changes model, or a benchmark result is written. No load input.
24214
26377
  * - `manual` — the operator's stored sliders.
24215
26378
  * Either way a node or device that cannot take sessions gives its share to
24216
26379
  * the others in proportion; the stored values are never rewritten for that.
@@ -24259,6 +26422,362 @@ var EffectiveSharesSchema = object({
24259
26422
  nodeWeights: record(string(), number()),
24260
26423
  deviceWeights: record(string(), record(string(), number()))
24261
26424
  });
26425
+ /**
26426
+ * Wire shapes of the node benchmark (D791): the operator's plan, the
26427
+ * preflight the confirmation shows, the run the orchestrator owns, what the
26428
+ * measuring runner reports, and the result rows Auto tune and the automatic
26429
+ * shares read.
26430
+ *
26431
+ * ONE node at a time, owned by the pipeline orchestrator. While a run is
26432
+ * active the cluster is in BENCHMARK MODE for that node: it is not a
26433
+ * detection candidate, camera pins naming it are ignored so its sessions move
26434
+ * elsewhere, and both come back when the mode ends — after a crash or a hub
26435
+ * restart too (a persisted manifest, reconciled against the registry).
26436
+ *
26437
+ * Two measurements, both on the node, driven by its own runner (frames never
26438
+ * cross a process at frame rate, D9):
26439
+ * - `device` — one accelerator × one candidate detector, root only, open
26440
+ * loop: how many streams at the camera rate it carries inside the frame
26441
+ * interval;
26442
+ * - `pipeline` — the chosen detector plus the operator's detail steps
26443
+ * (faces, plates, classifiers, CLIP…), on varied frames from the bench
26444
+ * clip: how many parallel sessions the node carries before latency, drops,
26445
+ * CPU, RAM or the event loop give out.
26446
+ */
26447
+ /** Defaults and bounds, one place. */
26448
+ var NODE_BENCHMARK_DEFAULTS = {
26449
+ fpsPerStream: 10,
26450
+ budgetMinutes: 45,
26451
+ minBudgetMinutes: 10,
26452
+ maxBudgetMinutes: 120,
26453
+ /** A result older than this no longer beats the table. */
26454
+ staleAfterDays: 30,
26455
+ /** Warm-in per ramp step (not accounted). */
26456
+ settleSec: 5,
26457
+ /** Accounted window per ramp step. */
26458
+ measureSec: 20,
26459
+ /** Longest the drain may take before the run is refused. */
26460
+ drainTimeoutSec: 120,
26461
+ /** Candidate models per device in one run. */
26462
+ maxModelsPerDevice: 6
26463
+ };
26464
+ /** The two measurements a run can make. */
26465
+ var NodeBenchmarkPhaseSchema = _enum(["device", "pipeline"]);
26466
+ var NodeBenchmarkDevicePlanSchema = object({
26467
+ /** `<backend>:<device>` — `openvino:npu`, `coreml:all`, `cpu`. */
26468
+ deviceKey: string().min(1),
26469
+ /**
26470
+ * Root detector candidates for the `device` measurement, in the order
26471
+ * measured. The FIRST is the one the `pipeline` measurement runs.
26472
+ */
26473
+ modelIds: array(string().min(1)).min(1).max(NODE_BENCHMARK_DEFAULTS.maxModelsPerDevice)
26474
+ });
26475
+ /** What the operator confirmed. */
26476
+ var NodeBenchmarkPlanSchema = object({
26477
+ nodeId: string().min(1),
26478
+ devices: array(NodeBenchmarkDevicePlanSchema).min(1),
26479
+ /** Which measurements run. At least one. */
26480
+ phases: array(NodeBenchmarkPhaseSchema).min(1).default(["device", "pipeline"]),
26481
+ /**
26482
+ * Detail steps (catalog step ids under the root: faces, plates,
26483
+ * classifiers, CLIP…) the `pipeline` measurement enables. The root
26484
+ * detector always runs.
26485
+ */
26486
+ steps: array(string().min(1)).default([]),
26487
+ /** Offered rate of one stream / session. */
26488
+ fpsPerStream: number().int().min(1).max(30).default(NODE_BENCHMARK_DEFAULTS.fpsPerStream),
26489
+ /** Hard deadline: the mode ends and the cluster is restored when it passes. */
26490
+ budgetMinutes: number().int().min(NODE_BENCHMARK_DEFAULTS.minBudgetMinutes).max(NODE_BENCHMARK_DEFAULTS.maxBudgetMinutes).default(NODE_BENCHMARK_DEFAULTS.budgetMinutes),
26491
+ /** Keep the models the run downloaded (default: delete what was not installed before). */
26492
+ keepDownloadedModels: boolean().default(false),
26493
+ /** Start although the other nodes' capacity does not cover the sessions running now. */
26494
+ acceptInsufficientHeadroom: boolean().default(false)
26495
+ });
26496
+ var NodeBenchmarkRefusalSchema = object({
26497
+ kind: _enum([
26498
+ "benchmark-active",
26499
+ "node-offline",
26500
+ "unknown-device",
26501
+ "no-phase",
26502
+ "insufficient-headroom"
26503
+ ]),
26504
+ detail: string(),
26505
+ overridable: boolean()
26506
+ });
26507
+ /** A camera whose detection leaves the node for the run. */
26508
+ var NodeBenchmarkMovingCameraSchema = object({
26509
+ deviceId: number(),
26510
+ /** Placed on the node now (a standing attach or a running session). */
26511
+ placedOnNode: boolean(),
26512
+ /** A node pin naming this node, ignored for the run. */
26513
+ pinnedToNode: boolean()
26514
+ });
26515
+ /** A camera that cannot leave: no other node can obtain its frames. */
26516
+ var NodeBenchmarkStayingCameraSchema = object({
26517
+ deviceId: number(),
26518
+ reason: literal("only-frame-source")
26519
+ });
26520
+ var NodeBenchmarkPreflightSchema = object({
26521
+ nodeId: string(),
26522
+ online: boolean(),
26523
+ moving: array(NodeBenchmarkMovingCameraSchema).readonly(),
26524
+ /** Keep running on the node during the run; the result is flagged contaminated. */
26525
+ staying: array(NodeBenchmarkStayingCameraSchema).readonly(),
26526
+ estimatedDurationMs: number(),
26527
+ /** The run ends and the cluster is restored at the latest after this long. */
26528
+ budgetMs: number(),
26529
+ phases: array(NodeBenchmarkPhaseSchema).readonly(),
26530
+ steps: array(string()).readonly(),
26531
+ devices: array(NodeBenchmarkDevicePlanSchema).readonly(),
26532
+ /** Parallel sessions the cluster runs now, and what the other nodes can carry. */
26533
+ headroom: object({
26534
+ sessionsNow: number(),
26535
+ otherNodesCapacitySessions: number().nullable()
26536
+ }),
26537
+ refusals: array(NodeBenchmarkRefusalSchema).readonly(),
26538
+ canStart: boolean()
26539
+ });
26540
+ /** Where the measuring runner is. */
26541
+ var NodeBenchProgressSchema = object({
26542
+ phase: _enum([
26543
+ "preparing",
26544
+ "device",
26545
+ "pipeline",
26546
+ "cleanup"
26547
+ ]),
26548
+ deviceKey: string().nullable(),
26549
+ modelId: string().nullable(),
26550
+ /** Streams (device) or sessions (pipeline) of the step running now. */
26551
+ load: number().nullable(),
26552
+ cellsDone: number(),
26553
+ cellsTotal: number(),
26554
+ message: string()
26555
+ });
26556
+ /** What limited a ramp. `none` = the ramp ran out of steps still passing. */
26557
+ var NodeBenchLimitSchema = _enum([
26558
+ "p95",
26559
+ "drops",
26560
+ "errors",
26561
+ "stall",
26562
+ "cpu",
26563
+ "ram",
26564
+ "none"
26565
+ ]);
26566
+ var NodeBenchRampStepSchema = object({
26567
+ load: number(),
26568
+ pass: boolean(),
26569
+ p95Ms: number(),
26570
+ dropRatio: number(),
26571
+ /** Completed frames per second over the accounted window. */
26572
+ fps: number(),
26573
+ cpuPct: number().nullable(),
26574
+ ramFreePct: number().nullable(),
26575
+ failReasons: array(string()).readonly()
26576
+ });
26577
+ var NodeBenchCellSchema = discriminatedUnion("phase", [object({
26578
+ phase: literal("device"),
26579
+ deviceKey: string(),
26580
+ modelId: string(),
26581
+ /** Single-stream latency (the K = 1 step). */
26582
+ p50Ms: number(),
26583
+ p95Ms: number(),
26584
+ p99Ms: number(),
26585
+ /** Frames per second sustained at the last passing step. */
26586
+ fps: number(),
26587
+ /** Streams at the camera rate the device carried inside the frame interval; 0 = not even one. */
26588
+ kMax: number(),
26589
+ limitedBy: NodeBenchLimitSchema,
26590
+ /** First call (model load + warm-up). */
26591
+ warmupMs: number(),
26592
+ ramp: array(NodeBenchRampStepSchema).readonly()
26593
+ }), object({
26594
+ phase: literal("pipeline"),
26595
+ deviceKey: string(),
26596
+ modelId: string(),
26597
+ steps: array(string()).readonly(),
26598
+ /** Parallel sessions at the camera rate the node carried; 0 = not even one. */
26599
+ maxSessions: number(),
26600
+ limitedBy: NodeBenchLimitSchema,
26601
+ /** Detail steps that produced at least one result on the clip — a step that never fired measured nothing. */
26602
+ stepsFired: array(string()).readonly(),
26603
+ warmupMs: number(),
26604
+ ramp: array(NodeBenchRampStepSchema).readonly()
26605
+ })]);
26606
+ /**
26607
+ * What a result was measured ON. A result whose fingerprint no longer matches
26608
+ * the node no longer beats the table.
26609
+ */
26610
+ var NodeBenchFingerprintSchema = object({
26611
+ pipelineVersion: string().nullable(),
26612
+ cpuModel: string().nullable(),
26613
+ ramGb: number().nullable(),
26614
+ os: string().nullable(),
26615
+ /** Per device: the pool the cells ran on (runtime + tuning). */
26616
+ pools: record(string(), object({
26617
+ runtime: string(),
26618
+ numWorkers: number(),
26619
+ concurrency: number(),
26620
+ batchMode: string()
26621
+ })).default({})
26622
+ });
26623
+ /** The frames the run used. */
26624
+ var NodeBenchClipSchema = object({
26625
+ /** `camstack-bench-v1` or `reference-images` (the fallback when the clip is not reachable). */
26626
+ id: string(),
26627
+ revision: string().nullable(),
26628
+ frames: number(),
26629
+ width: number(),
26630
+ height: number()
26631
+ });
26632
+ var NodeBenchRunnerInputSchema = object({
26633
+ runId: string().min(1),
26634
+ devices: array(NodeBenchmarkDevicePlanSchema).min(1),
26635
+ phases: array(NodeBenchmarkPhaseSchema).min(1),
26636
+ /** The full detail step tree root for the `pipeline` measurement is built on the node from these ids. */
26637
+ steps: array(string()).default([]),
26638
+ fpsPerStream: number().int().min(1).max(30),
26639
+ /** The runner stops on its own past this instant, whatever the hub does. */
26640
+ deadlineAtMs: number(),
26641
+ settleSec: number().min(0).max(60).default(NODE_BENCHMARK_DEFAULTS.settleSec),
26642
+ measureSec: number().min(2).max(300).default(NODE_BENCHMARK_DEFAULTS.measureSec),
26643
+ keepDownloadedModels: boolean().default(false)
26644
+ });
26645
+ var NodeBenchRunnerStateSchema = _enum([
26646
+ "running",
26647
+ "done",
26648
+ "failed",
26649
+ "aborted"
26650
+ ]);
26651
+ var NodeBenchRunnerStatusSchema = object({
26652
+ runId: string(),
26653
+ nodeId: string(),
26654
+ state: NodeBenchRunnerStateSchema,
26655
+ progress: NodeBenchProgressSchema.nullable(),
26656
+ /** Every finished cell so far — a run stopped half way keeps what it measured. */
26657
+ cells: array(NodeBenchCellSchema).readonly(),
26658
+ fingerprint: NodeBenchFingerprintSchema.nullable(),
26659
+ clip: NodeBenchClipSchema.nullable(),
26660
+ /** Cameras seen running on the node during the run (they share its pools). */
26661
+ activeCameraIds: array(number()).readonly(),
26662
+ /** Models the run downloaded and then deleted (not installed before). */
26663
+ deletedModels: array(string()).readonly(),
26664
+ error: string().nullable(),
26665
+ startedAtMs: number(),
26666
+ finishedAtMs: number().nullable()
26667
+ });
26668
+ var NodeBenchmarkStateSchema = _enum([
26669
+ "draining",
26670
+ "measuring",
26671
+ "restoring",
26672
+ "done",
26673
+ "failed",
26674
+ "aborted"
26675
+ ]);
26676
+ /** Why a run ended. */
26677
+ var NodeBenchmarkEndReasonSchema = _enum([
26678
+ "completed",
26679
+ "operator-abort",
26680
+ "deadline",
26681
+ "node-lost",
26682
+ "runner-lost",
26683
+ "hub-restart",
26684
+ "drain-timeout",
26685
+ "failed"
26686
+ ]);
26687
+ var NodeBenchmarkRunSchema = object({
26688
+ runId: string(),
26689
+ nodeId: string(),
26690
+ state: NodeBenchmarkStateSchema,
26691
+ plan: NodeBenchmarkPlanSchema,
26692
+ startedAtMs: number(),
26693
+ deadlineAtMs: number(),
26694
+ finishedAtMs: number().nullable(),
26695
+ endReason: NodeBenchmarkEndReasonSchema.nullable(),
26696
+ error: string().nullable(),
26697
+ /** Cameras moved off the node for the run. */
26698
+ moved: array(number()).readonly(),
26699
+ /** Cameras that stayed (their only frame source is the node). */
26700
+ staying: array(number()).readonly(),
26701
+ /** Something else ran on the node's pools during the run. */
26702
+ contaminated: boolean(),
26703
+ progress: NodeBenchProgressSchema.nullable(),
26704
+ resultIds: array(string()).readonly()
26705
+ });
26706
+ /** `getNodeBenchmarkStatus`: the active run (or the last one), and whether benchmark mode is on. */
26707
+ var NodeBenchmarkStatusSchema = object({
26708
+ /** The node the cluster is in benchmark mode for; null = none. */
26709
+ modeNodeId: string().nullable(),
26710
+ run: NodeBenchmarkRunSchema.nullable()
26711
+ });
26712
+ /**
26713
+ * One stored measurement — the only authority Auto tune and the automatic
26714
+ * shares read measured capacity from. Written by the orchestrator when a run
26715
+ * ends, never by anyone else.
26716
+ */
26717
+ var NodeBenchmarkResultSchema = object({
26718
+ id: string(),
26719
+ runId: string(),
26720
+ nodeId: string(),
26721
+ cell: NodeBenchCellSchema,
26722
+ fpsPerStream: number(),
26723
+ fingerprint: NodeBenchFingerprintSchema.nullable(),
26724
+ clip: NodeBenchClipSchema.nullable(),
26725
+ /** Other work shared the node's pools (a camera that could not move, or the hub's own duties). */
26726
+ contaminated: boolean(),
26727
+ stayingCameras: array(number()).readonly(),
26728
+ /** The run ended early; the cell itself completed. */
26729
+ partialRun: boolean(),
26730
+ measuredAtMs: number()
26731
+ });
26732
+ var ListNodeBenchmarkResultsInputSchema = object({
26733
+ nodeId: string().optional(),
26734
+ deviceKey: string().optional()
26735
+ });
26736
+ /** A result with its standing today: does it still beat the table? */
26737
+ var NodeBenchmarkResultViewSchema = NodeBenchmarkResultSchema.extend({
26738
+ /** `fresh` beats the table; `stale` falls back to it; `superseded` = a newer row covers the same cell. */
26739
+ standing: _enum([
26740
+ "fresh",
26741
+ "stale",
26742
+ "superseded"
26743
+ ]),
26744
+ staleWhy: _enum([
26745
+ "age",
26746
+ "runtime",
26747
+ "pool-tuning"
26748
+ ]).nullable()
26749
+ });
26750
+ object({
26751
+ runId: string(),
26752
+ nodeId: string(),
26753
+ startedAtMs: number(),
26754
+ deadlineAtMs: number(),
26755
+ plan: NodeBenchmarkPlanSchema,
26756
+ moved: array(number()).readonly(),
26757
+ staying: array(number()).readonly()
26758
+ });
26759
+ /** Candidate detectors per device, for the plan editor. */
26760
+ var NodeBenchmarkCandidatesSchema = object({
26761
+ nodeId: string(),
26762
+ reachable: boolean(),
26763
+ devices: array(object({
26764
+ deviceKey: string(),
26765
+ enabled: boolean(),
26766
+ available: boolean(),
26767
+ /** Ordered: what Auto tune would pick first, then the rest of the family by accuracy. */
26768
+ suggested: array(string()).readonly(),
26769
+ /** Every root detector the device has a build for. */
26770
+ all: array(string()).readonly(),
26771
+ /** The model the device runs now, when pinned. */
26772
+ currentModelId: string().nullable()
26773
+ })).readonly(),
26774
+ /** Detail steps the node's catalog offers under the root (for the `pipeline` measurement). */
26775
+ steps: array(object({
26776
+ id: string(),
26777
+ name: string(),
26778
+ slot: string()
26779
+ })).readonly()
26780
+ });
24262
26781
  object({
24263
26782
  activeCameras: number(),
24264
26783
  throttledCameras: number(),
@@ -25387,7 +27906,16 @@ method(RunnerCameraConfigSchema, object({ success: literal(true) }), { kind: "mu
25387
27906
  }), ParkedTrackFrameSchema.nullable()), method(object({
25388
27907
  deviceId: number(),
25389
27908
  trackId: string()
25390
- }), object({ released: number().int().nonnegative() }), { kind: "mutation" });
27909
+ }), object({ released: number().int().nonnegative() }), { kind: "mutation" }), method(NodeBenchRunnerInputSchema, object({
27910
+ accepted: literal(true),
27911
+ runId: string()
27912
+ }), {
27913
+ kind: "mutation",
27914
+ auth: "admin"
27915
+ }), method(object({ runId: string() }), NodeBenchRunnerStatusSchema.nullable(), { auth: "admin" }), method(object({ runId: string() }), object({ aborted: boolean() }), {
27916
+ kind: "mutation",
27917
+ auth: "admin"
27918
+ });
25391
27919
  var CameraPipelineConfigSchema = object({
25392
27920
  engine: PipelineEngineChoiceSchema.optional(),
25393
27921
  steps: array(PipelineStepInputSchema).readonly(),
@@ -26026,6 +28554,21 @@ method(object({
26026
28554
  }), method(PlacementStatsInputSchema, PlacementStatsSchema, { auth: "admin" }), method(SuggestSharesInputSchema, SuggestSharesResultSchema, { auth: "admin" }), method(_void(), EffectiveSharesSchema, { auth: "admin" }), method(SetShareSourceInputSchema, object({ success: literal(true) }), {
26027
28555
  kind: "mutation",
26028
28556
  auth: "admin"
28557
+ }), method(NodeBenchmarkPlanSchema, NodeBenchmarkPreflightSchema, { auth: "admin" }), method(NodeBenchmarkPlanSchema, discriminatedUnion("kind", [object({
28558
+ kind: literal("started"),
28559
+ runId: string()
28560
+ }), object({
28561
+ kind: literal("refused"),
28562
+ preflight: NodeBenchmarkPreflightSchema
28563
+ })]), {
28564
+ kind: "mutation",
28565
+ auth: "admin"
28566
+ }), method(_void(), NodeBenchmarkStatusSchema, { auth: "admin" }), method(object({ runId: string() }), object({ aborted: boolean() }), {
28567
+ kind: "mutation",
28568
+ auth: "admin"
28569
+ }), method(object({ nodeId: string() }), NodeBenchmarkCandidatesSchema, { auth: "admin" }), method(ListNodeBenchmarkResultsInputSchema, array(NodeBenchmarkResultViewSchema).readonly(), { auth: "admin" }), method(object({ id: string() }), object({ deleted: boolean() }), {
28570
+ kind: "mutation",
28571
+ auth: "admin"
26029
28572
  }), method(object({ deviceId: number() }), CameraPipelineSettingsSchema.nullable()), method(object({
26030
28573
  deviceId: number(),
26031
28574
  addonId: string(),
@@ -26431,8 +28974,8 @@ version: string().optional() }), ServerUpdateActionResultSchema, {
26431
28974
  * `smtp-provider` — pluggable email delivery surface.
26432
28975
  *
26433
28976
  * Collection cap: a deployment may install multiple SMTP relays (e.g.
26434
- * one for transactional / one for notifications). Consumers (magic-link,
26435
- * notifier addons, …) walk the collection and pick the first
28977
+ * one for transactional / one for notifications). Consumers (notifier
28978
+ * addons, …) walk the collection and pick the first
26436
28979
  * ready provider OR target a specific addonId.
26437
28980
  *
26438
28981
  * The shape stays small on purpose — `sendEmail` is enough for the
@@ -26611,7 +29154,7 @@ targets: array(object({
26611
29154
  })));
26612
29155
  /**
26613
29156
  * `sso-bridge` — internal hub-only cap that lets SSO-style auth
26614
- * providers (OIDC, SAML, magic-link, …) mint an HMAC-signed token
29157
+ * providers (OIDC, SAML, …) mint an HMAC-signed token
26615
29158
  * carrying the post-callback claims before redirecting back to
26616
29159
  * `/api/auth/sso/finish`.
26617
29160
  *
@@ -26674,7 +29217,14 @@ var SsoBridgeClaimsSchema = object({
26674
29217
  * Verified `iss` of the id_token behind an OIDC login bridge (D782). A
26675
29218
  * subject is unique only per issuer, so a link is bound to it.
26676
29219
  */
26677
- issuer: string().optional()
29220
+ issuer: string().optional(),
29221
+ /**
29222
+ * SHA-256 (hex) of the `camstack_sso_state` cookie the IdP `/start` set in
29223
+ * the browser that began this sign-in. `/api/auth/sso/finish` requires the
29224
+ * request to present the matching cookie — a login bridge is useless in
29225
+ * any other browser.
29226
+ */
29227
+ browserBinding: string().optional()
26678
29228
  });
26679
29229
  method(object({
26680
29230
  claims: SsoBridgeClaimsSchema,
@@ -32141,6 +34691,9 @@ var CreateIntegrationInputSchema = object({
32141
34691
  enabled: boolean().optional(),
32142
34692
  info: record(string(), unknown()).optional(),
32143
34693
  settings: record(string(), unknown()).optional(),
34694
+ /** Keys of `settings` the form's schema declares secret (by type) — kept in
34695
+ * the keychain, not the table (D787). */
34696
+ secretKeys: array(string()).optional(),
32144
34697
  skipRestart: boolean().optional()
32145
34698
  });
32146
34699
  var UpdateIntegrationInputSchema = object({
@@ -32164,7 +34717,9 @@ method(_void(), array(IntegrationWithStateSchema)), method(object({ id: string()
32164
34717
  auth: "admin"
32165
34718
  }), method(object({ id: string() }), record(string(), unknown()), { auth: "admin" }), method(object({
32166
34719
  id: string(),
32167
- settings: record(string(), unknown())
34720
+ settings: record(string(), unknown()),
34721
+ /** Keys the form's schema declares secret (by type) — keychain-stored (D787). */
34722
+ secretKeys: array(string()).optional()
32168
34723
  }), object({ success: boolean() }), {
32169
34724
  kind: "mutation",
32170
34725
  auth: "admin"
@@ -38936,16 +41491,6 @@ var ApiKeySummarySchema = object({
38936
41491
  createdAt: number(),
38937
41492
  lastUsedAt: number().optional()
38938
41493
  });
38939
- var CreateApiKeyInputSchema = object({
38940
- label: string(),
38941
- isAdmin: boolean().default(false),
38942
- allowedProviders: union([array(string()), literal("*")]).optional(),
38943
- allowedDevices: record(string(), union([array(string()), literal("*")])).optional()
38944
- });
38945
- var CreateApiKeyResultSchema = object({
38946
- token: string(),
38947
- record: ApiKeySummarySchema
38948
- });
38949
41494
  var ScopedTokenSummarySchema = object({
38950
41495
  id: string(),
38951
41496
  userId: string(),
@@ -39044,17 +41589,10 @@ method(_void(), array(UserSummarySchema), { auth: "admin" }), method(CreateUserI
39044
41589
  }), UserSummarySchema.extend({ passwordHash: string() }).nullable(), {
39045
41590
  kind: "mutation",
39046
41591
  access: "view"
39047
- }), method(_void(), array(ApiKeySummarySchema), { auth: "admin" }), method(CreateApiKeyInputSchema, CreateApiKeyResultSchema, {
39048
- kind: "mutation",
39049
- auth: "admin",
39050
- access: "create"
39051
- }), method(object({ id: string() }), object({ success: literal(true) }), {
41592
+ }), method(_void(), array(ApiKeySummarySchema), { auth: "admin" }), method(object({ id: string() }), object({ success: literal(true) }), {
39052
41593
  kind: "mutation",
39053
41594
  auth: "admin",
39054
41595
  access: "delete"
39055
- }), method(object({ token: string() }), ApiKeySummarySchema.nullable(), {
39056
- kind: "mutation",
39057
- access: "view"
39058
41596
  }), method(CreateScopedTokenInputSchema, CreateScopedTokenResultSchema, {
39059
41597
  kind: "mutation",
39060
41598
  auth: "admin",
@@ -39128,15 +41666,7 @@ method(_void(), array(UserSummarySchema), { auth: "admin" }), method(CreateUserI
39128
41666
  }).nullable(), { access: "view" }), method(object({ userId: string() }), array(ExternalIdentitySchema), { auth: "admin" }), method(ExternalIdentityKeySchema, object({
39129
41667
  userId: string(),
39130
41668
  issuer: string()
39131
- }).nullable(), { auth: "admin" }), method(ExternalIdentityKeySchema.extend({
39132
- userId: string(),
39133
- issuer: string().min(1),
39134
- label: string().optional()
39135
- }), object({ success: literal(true) }), {
39136
- kind: "mutation",
39137
- auth: "admin",
39138
- access: "create"
39139
- }), method(ExternalIdentityKeySchema.extend({ userId: string() }), object({ success: boolean() }), {
41669
+ }).nullable(), { auth: "admin" }), method(ExternalIdentityKeySchema.extend({ userId: string() }), object({ success: boolean() }), {
39140
41670
  kind: "mutation",
39141
41671
  auth: "admin",
39142
41672
  access: "delete"
@@ -39841,6 +42371,451 @@ var zoneRulesCapability = {
39841
42371
  */
39842
42372
  durability: "restored"
39843
42373
  };
42374
+ /**
42375
+ * `training-provider` — ONE cloud that can run the CamStack trainer.
42376
+ *
42377
+ * A thin, mockable translation layer: it knows how to run a container with a
42378
+ * GPU, move a dataset in, read the job's stdout and hand artefacts back. It
42379
+ * knows nothing about datasets, splits, floors, cost policy or Model Studio —
42380
+ * those are the `training` orchestrator's (D805). Every rule written there
42381
+ * once is what makes a second provider (RunPod, a local NVIDIA node) a new
42382
+ * manifest entry and nothing else.
42383
+ *
42384
+ * Collection, routed by the `addonId` in every single-row input (the `llm` /
42385
+ * `notification-output` posture); `describe` concat-fans across providers.
42386
+ * Every method is `admin`: these spend money.
42387
+ *
42388
+ * Every cloud object a provider creates is tagged with the orchestrator's
42389
+ * `jobKey`, so a retried submit finds the job it already started instead of
42390
+ * starting a second GPU, and `listJobs` can find orphans.
42391
+ *
42392
+ * Bytes never ride a cap field: the dataset arrives as a `ctx.peerBytes`
42393
+ * ticket the producer (pipeline-analytics) minted, and artefacts leave as a
42394
+ * ticket the provider mints (D613).
42395
+ */
42396
+ var TrainingGpuOptionSchema = object({
42397
+ id: string(),
42398
+ label: string(),
42399
+ /** List price, USD per GPU-hour, before any region multiplier. */
42400
+ usdPerHour: number().nonnegative(),
42401
+ vramGb: number().nonnegative()
42402
+ });
42403
+ var TrainingRegionOptionSchema = object({
42404
+ /** `''` = any region (the provider's choice). */
42405
+ id: string(),
42406
+ label: string(),
42407
+ priceMultiplier: number().positive()
42408
+ });
42409
+ /**
42410
+ * The provider's per-account settings, as the orchestrator reads them. They
42411
+ * live in the PROVIDER addon's settings (operator decision 2026-10-08: they
42412
+ * depend on the user's account), never hard-coded in the orchestrator.
42413
+ */
42414
+ var TrainingProviderDefaultsSchema = object({
42415
+ gpuType: string(),
42416
+ region: string(),
42417
+ costCapUsd: number().nonnegative(),
42418
+ maxRuntimeSec: number().int().positive(),
42419
+ /** Hours a FAILED job's cloud dataset is kept for debugging; 0 = delete at once. */
42420
+ failedDatasetGraceHours: number().nonnegative()
42421
+ });
42422
+ var TrainingProviderDescriptorSchema = object({
42423
+ addonId: string(),
42424
+ /** `modal`, `runpod`, `fake`, … */
42425
+ kind: string(),
42426
+ label: string(),
42427
+ gpuTypes: array(TrainingGpuOptionSchema).readonly(),
42428
+ regions: array(TrainingRegionOptionSchema).readonly(),
42429
+ maxDatasetBytes: number().int().positive(),
42430
+ maxRuntimeSec: number().int().positive(),
42431
+ freeTierNote: string().optional(),
42432
+ /** Where the data goes, in one sentence the confirm dialog repeats. */
42433
+ dataResidencyNote: string(),
42434
+ /** Credentials are present — never the values. */
42435
+ configured: boolean(),
42436
+ defaults: TrainingProviderDefaultsSchema
42437
+ });
42438
+ var TrainingCredentialCheckSchema = object({
42439
+ ok: boolean(),
42440
+ /** Workspace / account name, when the provider says. */
42441
+ account: string().optional(),
42442
+ reason: _enum([
42443
+ "missing",
42444
+ "invalid",
42445
+ "forbidden",
42446
+ "network",
42447
+ "quota"
42448
+ ]).optional(),
42449
+ detail: string().optional()
42450
+ });
42451
+ var ProviderJobStateSchema = _enum([
42452
+ "pending",
42453
+ "starting",
42454
+ "running",
42455
+ "succeeded",
42456
+ "failed",
42457
+ "cancelled",
42458
+ "lost"
42459
+ ]);
42460
+ var ProviderJobStatusSchema = object({
42461
+ jobKey: string(),
42462
+ providerJobId: string().optional(),
42463
+ state: ProviderJobStateSchema,
42464
+ startedAt: number().optional(),
42465
+ endedAt: number().optional(),
42466
+ exitCode: number().int().optional(),
42467
+ failureReason: string().optional(),
42468
+ gpuType: string(),
42469
+ region: string().optional(),
42470
+ billedSeconds: number().nonnegative(),
42471
+ costUsd: number().nonnegative(),
42472
+ /** True when `costUsd` is runtime × list price, not a billing answer. */
42473
+ costIsEstimate: boolean(),
42474
+ lastFetchedAt: number()
42475
+ });
42476
+ /**
42477
+ * The trainer the job runs, by SOURCE revision: the provider turns it into an
42478
+ * image its own way (Modal builds the published Dockerfile at that revision;
42479
+ * a registry-pull provider maps it to a tag). Recorded on the job and echoed
42480
+ * in `result.json`.
42481
+ */
42482
+ var TrainerSourceRefSchema = object({
42483
+ /** Hugging Face repo id, e.g. `camstack/camstack-trainer`. */
42484
+ repo: string().min(1),
42485
+ /** A commit sha (never a branch) — the job must be reproducible. */
42486
+ revision: string().regex(/^[0-9a-f]{7,64}$/)
42487
+ });
42488
+ var JobRef = {
42489
+ addonId: string(),
42490
+ jobKey: string().uuid()
42491
+ };
42492
+ var TrainingLogLineSchema = object({
42493
+ ts: number(),
42494
+ text: string()
42495
+ });
42496
+ method(object({}), array(TrainingProviderDescriptorSchema).readonly(), { auth: "admin" }), method(object({ addonId: string() }), TrainingCredentialCheckSchema, {
42497
+ kind: "mutation",
42498
+ auth: "admin",
42499
+ timeoutMs: 3e4
42500
+ }), method(object({
42501
+ addonId: string(),
42502
+ gpuType: string(),
42503
+ region: string(),
42504
+ datasetBytes: number().int().nonnegative(),
42505
+ gpuSecondsLow: number().nonnegative(),
42506
+ gpuSecondsHigh: number().nonnegative()
42507
+ }), object({
42508
+ usdLow: number().nonnegative(),
42509
+ usdHigh: number().nonnegative(),
42510
+ notes: array(string()).readonly()
42511
+ }), { auth: "admin" }), method(object({
42512
+ ...JobRef,
42513
+ ticket: PeerBytesTicketSchema
42514
+ }), object({
42515
+ bytes: number().int().nonnegative(),
42516
+ sha256: string()
42517
+ }), {
42518
+ kind: "mutation",
42519
+ auth: "admin",
42520
+ timeoutMs: 120 * 6e4
42521
+ }), method(object({
42522
+ ...JobRef,
42523
+ trainer: TrainerSourceRefSchema,
42524
+ jobSpecJson: string().min(2).max(64e3),
42525
+ gpuType: string(),
42526
+ region: string(),
42527
+ maxRuntimeSec: number().int().positive()
42528
+ }), ProviderJobStatusSchema, {
42529
+ kind: "mutation",
42530
+ auth: "admin",
42531
+ timeoutMs: 30 * 6e4
42532
+ }), method(object(JobRef), ProviderJobStatusSchema, {
42533
+ auth: "admin",
42534
+ timeoutMs: 6e4
42535
+ }), method(object({
42536
+ ...JobRef,
42537
+ cursor: string().optional(),
42538
+ max: number().int().min(1).max(500)
42539
+ }), object({
42540
+ lines: array(TrainingLogLineSchema).readonly(),
42541
+ cursor: string()
42542
+ }), {
42543
+ auth: "admin",
42544
+ timeoutMs: 6e4
42545
+ }), method(object(JobRef), object({ ok: literal(true) }), {
42546
+ kind: "mutation",
42547
+ auth: "admin",
42548
+ timeoutMs: 6e4
42549
+ }), method(object(JobRef), object({
42550
+ found: boolean(),
42551
+ text: string().optional()
42552
+ }), {
42553
+ kind: "mutation",
42554
+ auth: "admin",
42555
+ timeoutMs: 5 * 6e4
42556
+ }), method(object({
42557
+ ...JobRef,
42558
+ path: _enum(["bundle.tar"])
42559
+ }), object({ ticket: PeerBytesTicketSchema }), {
42560
+ kind: "mutation",
42561
+ auth: "admin",
42562
+ timeoutMs: 5 * 6e4
42563
+ }), method(object(JobRef), object({ deleted: array(string()).readonly() }), {
42564
+ kind: "mutation",
42565
+ auth: "admin",
42566
+ timeoutMs: 5 * 6e4
42567
+ }), method(object({ addonId: string() }), array(ProviderJobStatusSchema).readonly(), {
42568
+ auth: "admin",
42569
+ timeoutMs: 2 * 6e4
42570
+ });
42571
+ /**
42572
+ * `training` — the cloud-training orchestrator (D805). Hub-only singleton,
42573
+ * provided by `addon-training`.
42574
+ *
42575
+ * It owns what every provider must agree on, written once:
42576
+ *
42577
+ * - **Dataset versions.** Taken over from pipeline-analytics (D796): the rows
42578
+ * live here (D808); pipeline-analytics still CUTS a version (it owns the corpus and
42579
+ * the export plan) and reaches this store through the five row methods
42580
+ * below, so the Retrain page and the export did not change.
42581
+ * - **Jobs.** A persisted state machine, a reconcile loop against the
42582
+ * provider, a cost guard, a daily orphan sweep and the retention rules.
42583
+ * - **The return flow.** Verified artefacts → Model Studio
42584
+ * (`custom-model-registry.importModelBundle`) → canary on cameras →
42585
+ * rollback. Nothing is ever registered automatically.
42586
+ *
42587
+ * Every method is `admin`.
42588
+ */
42589
+ /** A version WITH its frame list — what the export and a job read. */
42590
+ var TrainingDatasetVersionRowSchema = RetrainDatasetVersionSchema.omit({ frameCount: true }).extend({ frameIds: array(string()).max(2e4).readonly() });
42591
+ /** A base model a detector job can fine-tune, and the baseline it is judged against. */
42592
+ var TrainingBaseModelSchema = object({
42593
+ modelId: string(),
42594
+ label: string(),
42595
+ weights: string(),
42596
+ imgsz: number().int(),
42597
+ baselineOnnxUrl: string(),
42598
+ baselineFloors: record(string(), number()),
42599
+ /** The base the fleet runs most — the UI's default. */
42600
+ recommended: boolean()
42601
+ });
42602
+ var TrainingPresetSchema = _enum([
42603
+ "quick",
42604
+ "standard",
42605
+ "thorough"
42606
+ ]);
42607
+ var TrainingJobRequestSchema = object({
42608
+ datasetVersionId: string().min(1),
42609
+ /** The `training-provider` addon that runs it. */
42610
+ addonId: string().min(1),
42611
+ gpuType: string().min(1),
42612
+ region: string(),
42613
+ baseModelId: string().min(1),
42614
+ preset: TrainingPresetSchema,
42615
+ /** Freeze the backbone's first N layers; `null` = the preset's choice. */
42616
+ freeze: number().int().nonnegative().nullable(),
42617
+ /** Cameras held out whole for evaluation; `null` = the orchestrator's default. */
42618
+ holdoutCameras: array(number().int()).nullable()
42619
+ });
42620
+ var TrainingSplitPlanSchema = object({
42621
+ holdoutCameras: array(number().int()).readonly(),
42622
+ /** Used when no camera is held out: the last N days of every camera. */
42623
+ holdoutLastDays: number().int().nonnegative(),
42624
+ /** Holdout subjects per class (camera holdout only; `null` = known only after the split). */
42625
+ holdoutSupport: record(string(), number().int()).nullable(),
42626
+ trainSubjects: number().int()
42627
+ });
42628
+ var TrainingRefusalReasonSchema = _enum([
42629
+ "unknown-dataset",
42630
+ "unknown-provider",
42631
+ "provider-not-configured",
42632
+ "unknown-base-model",
42633
+ "unknown-gpu",
42634
+ "dataset-too-large",
42635
+ "no-training-subjects",
42636
+ "job-already-running"
42637
+ ]);
42638
+ var TrainingJobPlanSchema = object({
42639
+ refusal: object({
42640
+ reason: TrainingRefusalReasonSchema,
42641
+ detail: string()
42642
+ }).nullable(),
42643
+ warnings: array(string()).readonly(),
42644
+ split: TrainingSplitPlanSchema.nullable(),
42645
+ estimate: object({
42646
+ datasetBytes: number().int(),
42647
+ uploadMinutesAt20Mbps: number(),
42648
+ gpuSecondsLow: number(),
42649
+ gpuSecondsHigh: number(),
42650
+ usdLow: number(),
42651
+ usdHigh: number(),
42652
+ notes: array(string()).readonly()
42653
+ }).nullable(),
42654
+ /** Pre-filled from the provider's settings; the operator may lower or raise them. */
42655
+ defaults: object({
42656
+ maxCostUsd: number(),
42657
+ maxRuntimeSec: number().int()
42658
+ }).nullable(),
42659
+ /** The sentence the confirm dialog repeats: where the frames go and when they are deleted. */
42660
+ dataNotice: string()
42661
+ });
42662
+ /**
42663
+ * Orchestrator-owned states, persisted. `uploading` covers exporting the
42664
+ * archive (it is streamed, never staged). Terminal: `failed`, `cancelled`,
42665
+ * `lost`, `expired`, `discarded`. `registered` and `canary` are where a
42666
+ * result lives after the operator acted on it.
42667
+ */
42668
+ var TrainingJobStateSchema = _enum([
42669
+ "uploading",
42670
+ "submitted",
42671
+ "starting",
42672
+ "running",
42673
+ "collecting",
42674
+ "ready",
42675
+ "registered",
42676
+ "canary",
42677
+ "failed",
42678
+ "cancelling",
42679
+ "cancelled",
42680
+ "lost",
42681
+ "expired",
42682
+ "discarded"
42683
+ ]);
42684
+ var TrainingFailureReasonSchema = _enum([
42685
+ "cost-cap",
42686
+ "runtime-cap",
42687
+ "upload-failed",
42688
+ "submit-failed",
42689
+ "trainer-failed",
42690
+ "result-invalid",
42691
+ "checksum-mismatch",
42692
+ "fetch-failed",
42693
+ "provider-error",
42694
+ "hub-restart-during-upload"
42695
+ ]);
42696
+ var TrainingProgressPointSchema = object({
42697
+ epoch: number().int(),
42698
+ map50: number().nullable(),
42699
+ map50_95: number().nullable()
42700
+ });
42701
+ var TrainingCanarySchema = object({
42702
+ deviceIds: array(number().int()).readonly(),
42703
+ since: number(),
42704
+ /** Every override the canary replaced, exactly, so rollback restores it. */
42705
+ previous: array(object({
42706
+ deviceId: number().int(),
42707
+ nodeId: string(),
42708
+ deviceKey: string(),
42709
+ patch: object({
42710
+ modelId: string().optional(),
42711
+ settings: record(string(), unknown()).readonly().optional()
42712
+ }).nullable()
42713
+ })).readonly()
42714
+ });
42715
+ var TrainingJobSchema = object({
42716
+ id: string(),
42717
+ idempotencyKey: string(),
42718
+ name: string(),
42719
+ createdAt: number(),
42720
+ updatedAt: number(),
42721
+ state: TrainingJobStateSchema,
42722
+ stage: TrainingStageSchema.nullable(),
42723
+ failure: object({
42724
+ reason: TrainingFailureReasonSchema,
42725
+ stage: string().nullable(),
42726
+ detail: string()
42727
+ }).nullable(),
42728
+ request: TrainingJobRequestSchema,
42729
+ maxCostUsd: number().nonnegative(),
42730
+ maxRuntimeSec: number().int().positive(),
42731
+ trainer: TrainerSourceRefSchema,
42732
+ datasetLayout: RetrainExportLayoutSchema,
42733
+ dataset: object({
42734
+ bytes: number().int(),
42735
+ sha256: string(),
42736
+ uploadedAt: number()
42737
+ }).nullable(),
42738
+ split: TrainingSplitPlanSchema,
42739
+ provider: object({
42740
+ state: ProviderJobStateSchema.nullable(),
42741
+ providerJobId: string().nullable(),
42742
+ startedAt: number().nullable(),
42743
+ endedAt: number().nullable(),
42744
+ billedSeconds: number(),
42745
+ costUsd: number(),
42746
+ costIsEstimate: boolean(),
42747
+ lastPolledAt: number().nullable()
42748
+ }),
42749
+ progress: object({
42750
+ epoch: number().int().nullable(),
42751
+ epochs: number().int().nullable(),
42752
+ etaSec: number().nullable(),
42753
+ series: array(TrainingProgressPointSchema).readonly()
42754
+ }),
42755
+ /** The last lines of the job's output (≤ 200), newest last. Never frame paths. */
42756
+ logTail: array(string()).readonly(),
42757
+ logCursor: string().nullable(),
42758
+ artifacts: object({
42759
+ bundleBytes: number().int(),
42760
+ bundleSha256: string(),
42761
+ fetchedAt: number(),
42762
+ /** When the staged artefacts are deleted from the hub. */
42763
+ expiresAt: number()
42764
+ }).nullable(),
42765
+ /** When the provider-side copy of the frames was deleted; null while it exists. */
42766
+ cloudDatasetDeletedAt: number().nullable(),
42767
+ /** A failed job's dataset is kept until then (the provider's grace), then deleted. */
42768
+ cloudCleanupDueAt: number().nullable(),
42769
+ /** Model ids registered from this job (base, and int8 when kept). */
42770
+ registeredModelIds: array(string()).readonly(),
42771
+ canary: TrainingCanarySchema.nullable()
42772
+ });
42773
+ var IdInput = object({ id: string().min(1) });
42774
+ method(TrainingDatasetVersionRowSchema, object({ stored: boolean() }), {
42775
+ kind: "mutation",
42776
+ auth: "admin"
42777
+ }), 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() }), {
42778
+ kind: "mutation",
42779
+ auth: "admin"
42780
+ }), method(object({}), array(TrainingBaseModelSchema).readonly(), { auth: "admin" }), method(TrainingJobRequestSchema, TrainingJobPlanSchema, {
42781
+ auth: "admin",
42782
+ timeoutMs: 6e4
42783
+ }), method(TrainingJobRequestSchema.extend({
42784
+ name: string().min(1).max(120),
42785
+ maxCostUsd: number().positive(),
42786
+ maxRuntimeSec: number().int().positive(),
42787
+ idempotencyKey: string().min(8).max(80)
42788
+ }), discriminatedUnion("kind", [object({
42789
+ kind: literal("started"),
42790
+ job: TrainingJobSchema
42791
+ }), object({
42792
+ kind: literal("refused"),
42793
+ reason: TrainingRefusalReasonSchema,
42794
+ detail: string()
42795
+ })]), {
42796
+ kind: "mutation",
42797
+ auth: "admin",
42798
+ timeoutMs: 12e4
42799
+ }), method(object({}), array(TrainingJobSchema).readonly(), { auth: "admin" }), method(IdInput, TrainingJobSchema.nullable(), { auth: "admin" }), method(IdInput, TrainingJobSchema, {
42800
+ kind: "mutation",
42801
+ auth: "admin",
42802
+ timeoutMs: 12e4
42803
+ }), method(IdInput, TrainingResultSchema.nullable(), { auth: "admin" }), method(IdInput.extend({ canaryDeviceIds: array(number().int()).readonly() }), TrainingJobSchema, {
42804
+ kind: "mutation",
42805
+ auth: "admin",
42806
+ timeoutMs: 30 * 6e4
42807
+ }), method(IdInput.extend({ deviceIds: array(number().int()).min(1).readonly() }), TrainingJobSchema, {
42808
+ kind: "mutation",
42809
+ auth: "admin",
42810
+ timeoutMs: 12e4
42811
+ }), method(IdInput, TrainingJobSchema, {
42812
+ kind: "mutation",
42813
+ auth: "admin",
42814
+ timeoutMs: 12e4
42815
+ }), method(IdInput, TrainingJobSchema, {
42816
+ kind: "mutation",
42817
+ auth: "admin"
42818
+ });
39844
42819
  SOURCE_CAPS.filter((cap) => cap !== "switch" && cap !== "motion");
39845
42820
  Object.freeze({
39846
42821
  person: .5,
@@ -40327,7 +43302,8 @@ var BaseDevice$1 = class {
40327
43302
  this.role = options.role;
40328
43303
  this.parentDeviceId = ctx.parentDeviceId;
40329
43304
  const seedData = ctx.persistedConfig ?? {};
40330
- this.config = DeviceConfig.fromSchema(schema, (data) => ctx.persistConfig(data), seedData, ({ droppedKeys, issues }) => {
43305
+ const declaredSecretPaths = collectZodSecretPaths(schema);
43306
+ this.config = DeviceConfig.fromSchema(schema, (data) => ctx.persistConfig(data, { secretConfigPaths: declaredSecretPaths }), seedData, ({ droppedKeys, issues }) => {
40331
43307
  ctx.logger.warn("Device config recovery: dropping invalid persisted fields", {
40332
43308
  tags: {
40333
43309
  deviceId: ctx.id,
@@ -41988,6 +44964,12 @@ Object.freeze({
41988
44964
  addonId: null,
41989
44965
  access: "create"
41990
44966
  },
44967
+ "backup.checkBackupKey": {
44968
+ capName: "backup",
44969
+ capScope: "system",
44970
+ addonId: null,
44971
+ access: "create"
44972
+ },
41991
44973
  "backup.delete": {
41992
44974
  capName: "backup",
41993
44975
  capScope: "system",
@@ -42000,6 +44982,18 @@ Object.freeze({
42000
44982
  addonId: null,
42001
44983
  access: "delete"
42002
44984
  },
44985
+ "backup.disableEncryption": {
44986
+ capName: "backup",
44987
+ capScope: "system",
44988
+ addonId: null,
44989
+ access: "create"
44990
+ },
44991
+ "backup.getEncryption": {
44992
+ capName: "backup",
44993
+ capScope: "system",
44994
+ addonId: null,
44995
+ access: "view"
44996
+ },
42003
44997
  "backup.getEntries": {
42004
44998
  capName: "backup",
42005
44999
  capScope: "system",
@@ -42054,6 +45048,12 @@ Object.freeze({
42054
45048
  addonId: null,
42055
45049
  access: "create"
42056
45050
  },
45051
+ "backup.setupEncryption": {
45052
+ capName: "backup",
45053
+ capScope: "system",
45054
+ addonId: null,
45055
+ access: "create"
45056
+ },
42057
45057
  "backup.trigger": {
42058
45058
  capName: "backup",
42059
45059
  capScope: "system",
@@ -42606,6 +45606,12 @@ Object.freeze({
42606
45606
  addonId: null,
42607
45607
  access: "create"
42608
45608
  },
45609
+ "customModelRegistry.importModelBundle": {
45610
+ capName: "custom-model-registry",
45611
+ capScope: "system",
45612
+ addonId: null,
45613
+ access: "create"
45614
+ },
42609
45615
  "customModelRegistry.listModels": {
42610
45616
  capName: "custom-model-registry",
42611
45617
  capScope: "system",
@@ -44016,6 +47022,108 @@ Object.freeze({
44016
47022
  addonId: null,
44017
47023
  access: "create"
44018
47024
  },
47025
+ "keychain.delete": {
47026
+ capName: "keychain",
47027
+ capScope: "system",
47028
+ addonId: null,
47029
+ access: "delete"
47030
+ },
47031
+ "keychain.getState": {
47032
+ capName: "keychain",
47033
+ capScope: "system",
47034
+ addonId: null,
47035
+ access: "view"
47036
+ },
47037
+ "keychain.listMeta": {
47038
+ capName: "keychain",
47039
+ capScope: "system",
47040
+ addonId: null,
47041
+ access: "view"
47042
+ },
47043
+ "keychain.put": {
47044
+ capName: "keychain",
47045
+ capScope: "system",
47046
+ addonId: null,
47047
+ access: "create"
47048
+ },
47049
+ "keychain.resolve": {
47050
+ capName: "keychain",
47051
+ capScope: "system",
47052
+ addonId: null,
47053
+ access: "view"
47054
+ },
47055
+ "keychainAdmin.acknowledgeReset": {
47056
+ capName: "keychain-admin",
47057
+ capScope: "system",
47058
+ addonId: null,
47059
+ access: "create"
47060
+ },
47061
+ "keychainAdmin.deleteOrphans": {
47062
+ capName: "keychain-admin",
47063
+ capScope: "system",
47064
+ addonId: null,
47065
+ access: "delete"
47066
+ },
47067
+ "keychainAdmin.downloadRecoveryKey": {
47068
+ capName: "keychain-admin",
47069
+ capScope: "system",
47070
+ addonId: null,
47071
+ access: "create"
47072
+ },
47073
+ "keychainAdmin.listAudit": {
47074
+ capName: "keychain-admin",
47075
+ capScope: "system",
47076
+ addonId: null,
47077
+ access: "view"
47078
+ },
47079
+ "keychainAdmin.listSecrets": {
47080
+ capName: "keychain-admin",
47081
+ capScope: "system",
47082
+ addonId: null,
47083
+ access: "view"
47084
+ },
47085
+ "keychainAdmin.purgeRetiredKeys": {
47086
+ capName: "keychain-admin",
47087
+ capScope: "system",
47088
+ addonId: null,
47089
+ access: "delete"
47090
+ },
47091
+ "keychainAdmin.resetKeychain": {
47092
+ capName: "keychain-admin",
47093
+ capScope: "system",
47094
+ addonId: null,
47095
+ access: "delete"
47096
+ },
47097
+ "keychainAdmin.resetReport": {
47098
+ capName: "keychain-admin",
47099
+ capScope: "system",
47100
+ addonId: null,
47101
+ access: "delete"
47102
+ },
47103
+ "keychainAdmin.reveal": {
47104
+ capName: "keychain-admin",
47105
+ capScope: "system",
47106
+ addonId: null,
47107
+ access: "create"
47108
+ },
47109
+ "keychainAdmin.rotateMasterKey": {
47110
+ capName: "keychain-admin",
47111
+ capScope: "system",
47112
+ addonId: null,
47113
+ access: "create"
47114
+ },
47115
+ "keychainAdmin.setSystemSecret": {
47116
+ capName: "keychain-admin",
47117
+ capScope: "system",
47118
+ addonId: null,
47119
+ access: "create"
47120
+ },
47121
+ "keychainAdmin.status": {
47122
+ capName: "keychain-admin",
47123
+ capScope: "system",
47124
+ addonId: null,
47125
+ access: "view"
47126
+ },
44019
47127
  "lawnMowerControl.dock": {
44020
47128
  capName: "lawn-mower-control",
44021
47129
  capScope: "device",
@@ -45390,6 +48498,18 @@ Object.freeze({
45390
48498
  addonId: null,
45391
48499
  access: "create"
45392
48500
  },
48501
+ "pipelineAnalytics.addRetrainFrameFromRecording": {
48502
+ capName: "pipeline-analytics",
48503
+ capScope: "device",
48504
+ addonId: null,
48505
+ access: "create"
48506
+ },
48507
+ "pipelineAnalytics.addRetrainFramesToCollection": {
48508
+ capName: "pipeline-analytics",
48509
+ capScope: "device",
48510
+ addonId: null,
48511
+ access: "create"
48512
+ },
45393
48513
  "pipelineAnalytics.applyDeviceSettingsPatch": {
45394
48514
  capName: "pipeline-analytics",
45395
48515
  capScope: "device",
@@ -45438,12 +48558,36 @@ Object.freeze({
45438
48558
  addonId: null,
45439
48559
  access: "view"
45440
48560
  },
48561
+ "pipelineAnalytics.createRetrainCollection": {
48562
+ capName: "pipeline-analytics",
48563
+ capScope: "device",
48564
+ addonId: null,
48565
+ access: "create"
48566
+ },
48567
+ "pipelineAnalytics.createRetrainDatasetVersion": {
48568
+ capName: "pipeline-analytics",
48569
+ capScope: "device",
48570
+ addonId: null,
48571
+ access: "create"
48572
+ },
45441
48573
  "pipelineAnalytics.deleteDeviceEvents": {
45442
48574
  capName: "pipeline-analytics",
45443
48575
  capScope: "device",
45444
48576
  addonId: null,
45445
48577
  access: "delete"
45446
48578
  },
48579
+ "pipelineAnalytics.deleteRetrainCollection": {
48580
+ capName: "pipeline-analytics",
48581
+ capScope: "device",
48582
+ addonId: null,
48583
+ access: "delete"
48584
+ },
48585
+ "pipelineAnalytics.deleteRetrainDatasetVersion": {
48586
+ capName: "pipeline-analytics",
48587
+ capScope: "device",
48588
+ addonId: null,
48589
+ access: "delete"
48590
+ },
45447
48591
  "pipelineAnalytics.deleteTracks": {
45448
48592
  capName: "pipeline-analytics",
45449
48593
  capScope: "device",
@@ -45648,6 +48792,30 @@ Object.freeze({
45648
48792
  addonId: null,
45649
48793
  access: "view"
45650
48794
  },
48795
+ "pipelineAnalytics.listRetrainAssistProfiles": {
48796
+ capName: "pipeline-analytics",
48797
+ capScope: "device",
48798
+ addonId: null,
48799
+ access: "view"
48800
+ },
48801
+ "pipelineAnalytics.listRetrainCollectionFrames": {
48802
+ capName: "pipeline-analytics",
48803
+ capScope: "device",
48804
+ addonId: null,
48805
+ access: "view"
48806
+ },
48807
+ "pipelineAnalytics.listRetrainCollections": {
48808
+ capName: "pipeline-analytics",
48809
+ capScope: "device",
48810
+ addonId: null,
48811
+ access: "view"
48812
+ },
48813
+ "pipelineAnalytics.listRetrainDatasetVersions": {
48814
+ capName: "pipeline-analytics",
48815
+ capScope: "device",
48816
+ addonId: null,
48817
+ access: "view"
48818
+ },
45651
48819
  "pipelineAnalytics.listRetrainFrames": {
45652
48820
  capName: "pipeline-analytics",
45653
48821
  capScope: "device",
@@ -45678,6 +48846,12 @@ Object.freeze({
45678
48846
  addonId: null,
45679
48847
  access: "view"
45680
48848
  },
48849
+ "pipelineAnalytics.offerRetrainArchive": {
48850
+ capName: "pipeline-analytics",
48851
+ capScope: "device",
48852
+ addonId: null,
48853
+ access: "create"
48854
+ },
45681
48855
  "pipelineAnalytics.ownersWithMedia": {
45682
48856
  capName: "pipeline-analytics",
45683
48857
  capScope: "device",
@@ -45690,12 +48864,24 @@ Object.freeze({
45690
48864
  addonId: null,
45691
48865
  access: "create"
45692
48866
  },
48867
+ "pipelineAnalytics.previewRetrainDataset": {
48868
+ capName: "pipeline-analytics",
48869
+ capScope: "device",
48870
+ addonId: null,
48871
+ access: "view"
48872
+ },
45693
48873
  "pipelineAnalytics.proposeRetrainAnnotations": {
45694
48874
  capName: "pipeline-analytics",
45695
48875
  capScope: "device",
45696
48876
  addonId: null,
45697
48877
  access: "create"
45698
48878
  },
48879
+ "pipelineAnalytics.proposeRetrainAnnotationsWithLlm": {
48880
+ capName: "pipeline-analytics",
48881
+ capScope: "device",
48882
+ addonId: null,
48883
+ access: "create"
48884
+ },
45699
48885
  "pipelineAnalytics.pruneEvents": {
45700
48886
  capName: "pipeline-analytics",
45701
48887
  capScope: "device",
@@ -45750,6 +48936,18 @@ Object.freeze({
45750
48936
  addonId: null,
45751
48937
  access: "create"
45752
48938
  },
48939
+ "pipelineAnalytics.removeRetrainFrameFromCollection": {
48940
+ capName: "pipeline-analytics",
48941
+ capScope: "device",
48942
+ addonId: null,
48943
+ access: "delete"
48944
+ },
48945
+ "pipelineAnalytics.renameRetrainCollection": {
48946
+ capName: "pipeline-analytics",
48947
+ capScope: "device",
48948
+ addonId: null,
48949
+ access: "create"
48950
+ },
45753
48951
  "pipelineAnalytics.restageRetrainTrack": {
45754
48952
  capName: "pipeline-analytics",
45755
48953
  capScope: "device",
@@ -45810,6 +49008,12 @@ Object.freeze({
45810
49008
  addonId: null,
45811
49009
  access: "create"
45812
49010
  },
49011
+ "pipelineAnalytics.verifyRetrainDatasetVersion": {
49012
+ capName: "pipeline-analytics",
49013
+ capScope: "device",
49014
+ addonId: null,
49015
+ access: "view"
49016
+ },
45813
49017
  "pipelineAnalytics.wipeAllAnalytics": {
45814
49018
  capName: "pipeline-analytics",
45815
49019
  capScope: "device",
@@ -46038,6 +49242,12 @@ Object.freeze({
46038
49242
  addonId: null,
46039
49243
  access: "view"
46040
49244
  },
49245
+ "pipelineOrchestrator.abortNodeBenchmark": {
49246
+ capName: "pipeline-orchestrator",
49247
+ capScope: "system",
49248
+ addonId: null,
49249
+ access: "create"
49250
+ },
46041
49251
  "pipelineOrchestrator.applyAutoTune": {
46042
49252
  capName: "pipeline-orchestrator",
46043
49253
  capScope: "system",
@@ -46062,6 +49272,12 @@ Object.freeze({
46062
49272
  addonId: null,
46063
49273
  access: "create"
46064
49274
  },
49275
+ "pipelineOrchestrator.deleteNodeBenchmarkResult": {
49276
+ capName: "pipeline-orchestrator",
49277
+ capScope: "system",
49278
+ addonId: null,
49279
+ access: "delete"
49280
+ },
46065
49281
  "pipelineOrchestrator.getAgentLoad": {
46066
49282
  capName: "pipeline-orchestrator",
46067
49283
  capScope: "system",
@@ -46170,6 +49386,24 @@ Object.freeze({
46170
49386
  addonId: null,
46171
49387
  access: "view"
46172
49388
  },
49389
+ "pipelineOrchestrator.getNodeBenchmarkCandidates": {
49390
+ capName: "pipeline-orchestrator",
49391
+ capScope: "system",
49392
+ addonId: null,
49393
+ access: "view"
49394
+ },
49395
+ "pipelineOrchestrator.getNodeBenchmarkPreflight": {
49396
+ capName: "pipeline-orchestrator",
49397
+ capScope: "system",
49398
+ addonId: null,
49399
+ access: "view"
49400
+ },
49401
+ "pipelineOrchestrator.getNodeBenchmarkStatus": {
49402
+ capName: "pipeline-orchestrator",
49403
+ capScope: "system",
49404
+ addonId: null,
49405
+ access: "view"
49406
+ },
46173
49407
  "pipelineOrchestrator.getNodeInferenceDevices": {
46174
49408
  capName: "pipeline-orchestrator",
46175
49409
  capScope: "system",
@@ -46212,6 +49446,12 @@ Object.freeze({
46212
49446
  addonId: null,
46213
49447
  access: "view"
46214
49448
  },
49449
+ "pipelineOrchestrator.listNodeBenchmarkResults": {
49450
+ capName: "pipeline-orchestrator",
49451
+ capScope: "system",
49452
+ addonId: null,
49453
+ access: "view"
49454
+ },
46215
49455
  "pipelineOrchestrator.pauseForStorageMigration": {
46216
49456
  capName: "pipeline-orchestrator",
46217
49457
  capScope: "system",
@@ -46356,6 +49596,12 @@ Object.freeze({
46356
49596
  addonId: null,
46357
49597
  access: "create"
46358
49598
  },
49599
+ "pipelineOrchestrator.startNodeBenchmark": {
49600
+ capName: "pipeline-orchestrator",
49601
+ capScope: "system",
49602
+ addonId: null,
49603
+ access: "create"
49604
+ },
46359
49605
  "pipelineOrchestrator.suggestShares": {
46360
49606
  capName: "pipeline-orchestrator",
46361
49607
  capScope: "system",
@@ -46374,6 +49620,12 @@ Object.freeze({
46374
49620
  addonId: null,
46375
49621
  access: "create"
46376
49622
  },
49623
+ "pipelineRunner.abortNodeBench": {
49624
+ capName: "pipeline-runner",
49625
+ capScope: "system",
49626
+ addonId: null,
49627
+ access: "create"
49628
+ },
46377
49629
  "pipelineRunner.attachCamera": {
46378
49630
  capName: "pipeline-runner",
46379
49631
  capScope: "system",
@@ -46422,6 +49674,12 @@ Object.freeze({
46422
49674
  addonId: null,
46423
49675
  access: "view"
46424
49676
  },
49677
+ "pipelineRunner.getNodeBenchStatus": {
49678
+ capName: "pipeline-runner",
49679
+ capScope: "system",
49680
+ addonId: null,
49681
+ access: "view"
49682
+ },
46425
49683
  "pipelineRunner.getParkedTrackFrame": {
46426
49684
  capName: "pipeline-runner",
46427
49685
  capScope: "system",
@@ -46464,6 +49722,12 @@ Object.freeze({
46464
49722
  addonId: null,
46465
49723
  access: "create"
46466
49724
  },
49725
+ "pipelineRunner.startNodeBench": {
49726
+ capName: "pipeline-runner",
49727
+ capScope: "system",
49728
+ addonId: null,
49729
+ access: "create"
49730
+ },
46467
49731
  "plateGallery.assignPlate": {
46468
49732
  capName: "plate-gallery",
46469
49733
  capScope: "system",
@@ -48126,6 +51390,174 @@ Object.freeze({
48126
51390
  addonId: null,
48127
51391
  access: "view"
48128
51392
  },
51393
+ "training.canaryResult": {
51394
+ capName: "training",
51395
+ capScope: "system",
51396
+ addonId: null,
51397
+ access: "create"
51398
+ },
51399
+ "training.cancelJob": {
51400
+ capName: "training",
51401
+ capScope: "system",
51402
+ addonId: null,
51403
+ access: "create"
51404
+ },
51405
+ "training.discardResult": {
51406
+ capName: "training",
51407
+ capScope: "system",
51408
+ addonId: null,
51409
+ access: "create"
51410
+ },
51411
+ "training.findDatasetVersionIdByName": {
51412
+ capName: "training",
51413
+ capScope: "system",
51414
+ addonId: null,
51415
+ access: "view"
51416
+ },
51417
+ "training.getDatasetVersion": {
51418
+ capName: "training",
51419
+ capScope: "system",
51420
+ addonId: null,
51421
+ access: "view"
51422
+ },
51423
+ "training.getJob": {
51424
+ capName: "training",
51425
+ capScope: "system",
51426
+ addonId: null,
51427
+ access: "view"
51428
+ },
51429
+ "training.getJobResult": {
51430
+ capName: "training",
51431
+ capScope: "system",
51432
+ addonId: null,
51433
+ access: "view"
51434
+ },
51435
+ "training.listBaseModels": {
51436
+ capName: "training",
51437
+ capScope: "system",
51438
+ addonId: null,
51439
+ access: "view"
51440
+ },
51441
+ "training.listDatasetVersions": {
51442
+ capName: "training",
51443
+ capScope: "system",
51444
+ addonId: null,
51445
+ access: "view"
51446
+ },
51447
+ "training.listJobs": {
51448
+ capName: "training",
51449
+ capScope: "system",
51450
+ addonId: null,
51451
+ access: "view"
51452
+ },
51453
+ "training.planJob": {
51454
+ capName: "training",
51455
+ capScope: "system",
51456
+ addonId: null,
51457
+ access: "view"
51458
+ },
51459
+ "training.putDatasetVersion": {
51460
+ capName: "training",
51461
+ capScope: "system",
51462
+ addonId: null,
51463
+ access: "create"
51464
+ },
51465
+ "training.registerResult": {
51466
+ capName: "training",
51467
+ capScope: "system",
51468
+ addonId: null,
51469
+ access: "create"
51470
+ },
51471
+ "training.removeDatasetVersion": {
51472
+ capName: "training",
51473
+ capScope: "system",
51474
+ addonId: null,
51475
+ access: "delete"
51476
+ },
51477
+ "training.rollbackCanary": {
51478
+ capName: "training",
51479
+ capScope: "system",
51480
+ addonId: null,
51481
+ access: "create"
51482
+ },
51483
+ "training.startJob": {
51484
+ capName: "training",
51485
+ capScope: "system",
51486
+ addonId: null,
51487
+ access: "create"
51488
+ },
51489
+ "trainingProvider.cancelJob": {
51490
+ capName: "training-provider",
51491
+ capScope: "system",
51492
+ addonId: null,
51493
+ access: "create"
51494
+ },
51495
+ "trainingProvider.cleanupJob": {
51496
+ capName: "training-provider",
51497
+ capScope: "system",
51498
+ addonId: null,
51499
+ access: "create"
51500
+ },
51501
+ "trainingProvider.describe": {
51502
+ capName: "training-provider",
51503
+ capScope: "system",
51504
+ addonId: null,
51505
+ access: "view"
51506
+ },
51507
+ "trainingProvider.estimateJob": {
51508
+ capName: "training-provider",
51509
+ capScope: "system",
51510
+ addonId: null,
51511
+ access: "view"
51512
+ },
51513
+ "trainingProvider.getJob": {
51514
+ capName: "training-provider",
51515
+ capScope: "system",
51516
+ addonId: null,
51517
+ access: "view"
51518
+ },
51519
+ "trainingProvider.listJobEvents": {
51520
+ capName: "training-provider",
51521
+ capScope: "system",
51522
+ addonId: null,
51523
+ access: "view"
51524
+ },
51525
+ "trainingProvider.listJobs": {
51526
+ capName: "training-provider",
51527
+ capScope: "system",
51528
+ addonId: null,
51529
+ access: "view"
51530
+ },
51531
+ "trainingProvider.offerArtifact": {
51532
+ capName: "training-provider",
51533
+ capScope: "system",
51534
+ addonId: null,
51535
+ access: "create"
51536
+ },
51537
+ "trainingProvider.readResult": {
51538
+ capName: "training-provider",
51539
+ capScope: "system",
51540
+ addonId: null,
51541
+ access: "create"
51542
+ },
51543
+ "trainingProvider.submitJob": {
51544
+ capName: "training-provider",
51545
+ capScope: "system",
51546
+ addonId: null,
51547
+ access: "create"
51548
+ },
51549
+ "trainingProvider.uploadDataset": {
51550
+ capName: "training-provider",
51551
+ capScope: "system",
51552
+ addonId: null,
51553
+ access: "create"
51554
+ },
51555
+ "trainingProvider.validateCredentials": {
51556
+ capName: "training-provider",
51557
+ capScope: "system",
51558
+ addonId: null,
51559
+ access: "create"
51560
+ },
48129
51561
  "turnProvider.getTurnServers": {
48130
51562
  capName: "turn-provider",
48131
51563
  capScope: "system",
@@ -48150,12 +51582,6 @@ Object.freeze({
48150
51582
  addonId: null,
48151
51583
  access: "create"
48152
51584
  },
48153
- "userManagement.createApiKey": {
48154
- capName: "user-management",
48155
- capScope: "system",
48156
- addonId: null,
48157
- access: "create"
48158
- },
48159
51585
  "userManagement.createScopedToken": {
48160
51586
  capName: "user-management",
48161
51587
  capScope: "system",
@@ -48192,12 +51618,6 @@ Object.freeze({
48192
51618
  addonId: null,
48193
51619
  access: "view"
48194
51620
  },
48195
- "userManagement.linkExternalIdentity": {
48196
- capName: "user-management",
48197
- capScope: "system",
48198
- addonId: null,
48199
- access: "create"
48200
- },
48201
51621
  "userManagement.listApiKeys": {
48202
51622
  capName: "user-management",
48203
51623
  capScope: "system",
@@ -48300,12 +51720,6 @@ Object.freeze({
48300
51720
  addonId: null,
48301
51721
  access: "create"
48302
51722
  },
48303
- "userManagement.validateApiKey": {
48304
- capName: "user-management",
48305
- capScope: "system",
48306
- addonId: null,
48307
- access: "view"
48308
- },
48309
51723
  "userManagement.validateCredentials": {
48310
51724
  capName: "user-management",
48311
51725
  capScope: "system",
@@ -51393,6 +54807,11 @@ Object.freeze({
51393
54807
  form: "single",
51394
54808
  optional: false
51395
54809
  }],
54810
+ "pipelineAnalytics.addRetrainFrameFromRecording": [{
54811
+ name: "deviceId",
54812
+ form: "single",
54813
+ optional: false
54814
+ }],
51396
54815
  "pipelineAnalytics.applyDeviceSettingsPatch": [{
51397
54816
  name: "deviceId",
51398
54817
  form: "single",
@@ -51583,6 +55002,11 @@ Object.freeze({
51583
55002
  form: "single",
51584
55003
  optional: false
51585
55004
  }],
55005
+ "pipelineAnalytics.proposeRetrainAnnotationsWithLlm": [{
55006
+ name: "deviceId",
55007
+ form: "single",
55008
+ optional: false
55009
+ }],
51586
55010
  "pipelineAnalytics.pruneEventsBefore": [{
51587
55011
  name: "deviceId",
51588
55012
  form: "single",
@@ -52409,6 +55833,11 @@ Object.freeze({
52409
55833
  form: "single",
52410
55834
  optional: false
52411
55835
  }],
55836
+ "training.canaryResult": [{
55837
+ name: "deviceIds",
55838
+ form: "array",
55839
+ optional: false
55840
+ }],
52412
55841
  "update.getStatus": [{
52413
55842
  name: "deviceId",
52414
55843
  form: "single",