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